( toolkit: T )
| 364 | * @category Schemas |
| 365 | */ |
| 366 | export const StreamPart = <T extends Toolkit.Any | Toolkit.WithHandler<any>>( |
| 367 | toolkit: T |
| 368 | ): Schema.Schema< |
| 369 | StreamPart< |
| 370 | T extends Toolkit.Any ? Toolkit.Tools<T> : Toolkit.WithHandlerTools<T> |
| 371 | >, |
| 372 | StreamPartEncoded |
| 373 | > => { |
| 374 | const toolCalls: Array<Schema.Schema<ToolCallPart<string, any>, ToolCallPartEncoded>> = [] |
| 375 | const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any, any>, ToolResultPartEncoded>> = [] |
| 376 | for (const tool of Object.values(toolkit.tools as Record<string, Tool.Any>)) { |
| 377 | toolCalls.push(ToolCallPart(tool.name, tool.parametersSchema as any)) |
| 378 | toolCallResults.push(ToolResultPart(tool.name, tool.successSchema, tool.failureSchema)) |
| 379 | } |
| 380 | return Schema.Union( |
| 381 | TextStartPart, |
| 382 | TextDeltaPart, |
| 383 | TextEndPart, |
| 384 | ReasoningStartPart, |
| 385 | ReasoningDeltaPart, |
| 386 | ReasoningEndPart, |
| 387 | ToolParamsStartPart, |
| 388 | ToolParamsDeltaPart, |
| 389 | ToolParamsEndPart, |
| 390 | FilePart, |
| 391 | DocumentSourcePart, |
| 392 | UrlSourcePart, |
| 393 | ResponseMetadataPart, |
| 394 | FinishPart, |
| 395 | ErrorPart, |
| 396 | ...toolCalls, |
| 397 | ...toolCallResults |
| 398 | ) as any |
| 399 | } |
| 400 | |
| 401 | // ============================================================================= |
| 402 | // Utility Types |
nothing calls this directly
no test coverage detected