MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / getStructuredIO

Function getStructuredIO

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

Source from the content-addressed store, hash-verified

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