( toolkit: T )
| 280 | * @category Schemas |
| 281 | */ |
| 282 | export const Part = <T extends Toolkit.Any | Toolkit.WithHandler<any>>( |
| 283 | toolkit: T |
| 284 | ): Schema.Schema<Part<T extends Toolkit.Any ? Toolkit.Tools<T> : Toolkit.WithHandlerTools<T>>, PartEncoded> => { |
| 285 | const toolCalls: Array<Schema.Schema<ToolCallPart<string, any>, ToolCallPartEncoded>> = [] |
| 286 | const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any, any>, ToolResultPartEncoded>> = [] |
| 287 | for (const tool of Object.values(toolkit.tools as Record<string, Tool.Any>)) { |
| 288 | toolCalls.push(ToolCallPart(tool.name, tool.parametersSchema as any)) |
| 289 | toolCallResults.push(ToolResultPart(tool.name, tool.successSchema, tool.failureSchema)) |
| 290 | } |
| 291 | return Schema.Union( |
| 292 | TextPart, |
| 293 | ReasoningPart, |
| 294 | FilePart, |
| 295 | DocumentSourcePart, |
| 296 | UrlSourcePart, |
| 297 | ResponseMetadataPart, |
| 298 | FinishPart, |
| 299 | ...toolCalls, |
| 300 | ...toolCallResults |
| 301 | ) as any |
| 302 | } |
| 303 | |
| 304 | // ============================================================================= |
| 305 | // Stream Parts |
nothing calls this directly
no test coverage detected