MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getStructuredIO

Function getStructuredIO

src/cli/print.ts:5199–5233  ·  view source on GitHub ↗
(
  inputPrompt: string | AsyncIterable<string>,
  options: {
    sdkUrl: string | undefined
    replayUserMessages?: boolean
  },
)

Source from the content-addressed store, hash-verified

5197}
5198
5199function getStructuredIO(
5200 inputPrompt: string | AsyncIterable<string>,
5201 options: {
5202 sdkUrl: string | undefined
5203 replayUserMessages?: boolean
5204 },
5205): StructuredIO {
5206 let inputStream: AsyncIterable<string>
5207 if (typeof inputPrompt === 'string') {
5208 if (inputPrompt.trim() !== '') {
5209 // Normalize to a streaming input.
5210 inputStream = fromArray([
5211 jsonStringify({
5212 type: 'user',
5213 session_id: '',
5214 message: {
5215 role: 'user',
5216 content: inputPrompt,
5217 },
5218 parent_tool_use_id: null,
5219 } satisfies SDKUserMessage),
5220 ])
5221 } else {
5222 // Empty string - create empty stream
5223 inputStream = fromArray([])
5224 }
5225 } else {
5226 inputStream = inputPrompt
5227 }
5228
5229 // Use RemoteIO if sdkUrl is provided, otherwise use regular StructuredIO
5230 return options.sdkUrl
5231 ? new RemoteIO(options.sdkUrl, inputStream, options.replayUserMessages)
5232 : new StructuredIO(inputStream, options.replayUserMessages)
5233}
5234
5235/**
5236 * Handles unexpected permission responses by looking up the unresolved tool

Callers 1

runHeadlessFunction · 0.85

Calls 2

fromArrayFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected