MCPcopy
hub / github.com/TanStack/ai / handleUser

Function handleUser

packages/ai-claude-code/src/stream/translate.ts:294–315  ·  view source on GitHub ↗
(message: SdkUserMessage)

Source from the content-addressed store, hash-verified

292 }
293
294 function* handleUser(message: SdkUserMessage): Generator<StreamChunk> {
295 const content = message.message.content
296 if (typeof content === 'string') return
297 for (const block of content) {
298 if (block.type !== 'tool_result') continue
299 const toolResult = block as {
300 tool_use_id: string
301 content?: SdkToolResultContent
302 is_error?: boolean
303 }
304 unresolvedToolCalls.delete(toolResult.tool_use_id)
305 yield {
306 type: EventType.TOOL_CALL_RESULT,
307 toolCallId: toolResult.tool_use_id,
308 messageId: genId(),
309 model,
310 timestamp: now(),
311 content: stringifyToolResultContent(toolResult.content),
312 ...(toolResult.is_error === true && { state: 'output-error' as const }),
313 }
314 }
315 }
316
317 function* handleResult(message: SdkResultMessage): Generator<StreamChunk> {
318 yield* closePartialText()

Callers 1

translateSdkStreamFunction · 0.85

Calls 3

nowFunction · 0.70
deleteMethod · 0.65

Tested by

no test coverage detected