MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getStructuredIO

Function getStructuredIO

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

Source from the content-addressed store, hash-verified

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