MCPcopy Create free account
hub / github.com/apache/maka / createRuntime

Function createRuntime

packages/runtime/src/__tests__/computer-use-model-loop.test.ts:359–386  ·  view source on GitHub ↗
(input: {
  model: MockLanguageModelV4;
  computerTool: ReturnType<typeof buildComputerUseTools>[number];
  messages: StoredMessage[];
  telemetry: ToolInvocationRecord[];
  connection?: LlmConnection;
  durable?: ReturnType<typeof createDurableTurnHarness>;
})

Source from the content-addressed store, hash-verified

357}
358
359function 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
388function toolCall(id: string, args: Record<string, unknown>): LanguageModelV4StreamPart[] {
389 return [

Callers 1

Calls 6

createTestAiSdkBackendFunction · 0.85
connectionFunction · 0.70
headerFunction · 0.70
idGeneratorFunction · 0.70
monotonicClockFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected