(input: {
model: MockLanguageModelV4;
computerTool: ReturnType<typeof buildComputerUseTools>[number];
messages: StoredMessage[];
telemetry: ToolInvocationRecord[];
connection?: LlmConnection;
durable?: ReturnType<typeof createDurableTurnHarness>;
})
| 357 | } |
| 358 | |
| 359 | function createRuntime(input: { |
| 360 | model: MockLanguageModelV4; |
| 361 | computerTool: ReturnType<typeof buildComputerUseTools>[number]; |
| 362 | messages: StoredMessage[]; |
| 363 | telemetry: ToolInvocationRecord[]; |
| 364 | connection?: LlmConnection; |
| 365 | durable?: ReturnType<typeof createDurableTurnHarness>; |
| 366 | }): AiSdkBackend { |
| 367 | const selectedConnection = input.connection ?? connection('openai'); |
| 368 | return createTestAiSdkBackend({ |
| 369 | sessionId: 'session-1', |
| 370 | header: header(), |
| 371 | appendMessage: async (message) => { |
| 372 | input.messages.push(message); |
| 373 | }, |
| 374 | connection: selectedConnection, |
| 375 | apiKey: 'test-key', |
| 376 | modelId: 'mock-computer-model', |
| 377 | modelFactory: () => input.model, |
| 378 | tools: [input.computerTool], |
| 379 | ...(input.durable ? { loadTurnRuntimeEvents: input.durable.loadTurnRuntimeEvents } : {}), |
| 380 | newId: idGenerator(), |
| 381 | now: monotonicClock(), |
| 382 | recordToolInvocation: (record) => { |
| 383 | input.telemetry.push(record); |
| 384 | }, |
| 385 | }); |
| 386 | } |
| 387 | |
| 388 | function toolCall(id: string, args: Record<string, unknown>): LanguageModelV4StreamPart[] { |
| 389 | return [ |
no test coverage detected