MCPcopy Create free account
hub / github.com/Noumena-Network/code / getStructuredIO

Function getStructuredIO

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

Source from the content-addressed store, hash-verified

5231}
5232
5233function getStructuredIO(
5234 inputPrompt: string | AsyncIterable<string>,
5235 options: {
5236 sdkUrl: string | undefined
5237 replayUserMessages?: boolean
5238 sessionId?: string
5239 },
5240): StructuredIO {
5241 let inputStream: AsyncIterable<string>
5242 if (typeof inputPrompt === 'string') {
5243 if (inputPrompt.trim() !== '') {
5244 // Normalize to a streaming input.
5245 inputStream = fromArray([
5246 jsonStringify({
5247 type: 'user',
5248 session_id: '',
5249 message: {
5250 role: 'user',
5251 content: inputPrompt,
5252 },
5253 parent_tool_use_id: null,
5254 } satisfies SDKUserMessage),
5255 ])
5256 } else {
5257 // Empty string - create empty stream
5258 inputStream = fromArray([])
5259 }
5260 } else {
5261 inputStream = inputPrompt
5262 }
5263
5264 // Use RemoteIO if sdkUrl is provided, otherwise use regular StructuredIO
5265 return options.sdkUrl
5266 ? new RemoteIO(
5267 options.sdkUrl,
5268 inputStream,
5269 options.replayUserMessages,
5270 options.sessionId,
5271 )
5272 : new StructuredIO(inputStream, options.replayUserMessages)
5273}
5274
5275/**
5276 * 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