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

Function createDirectRuntimeTurnLedger

scripts/computer-use/direct-runtime-ledger.mjs:6–50  ·  view source on GitHub ↗
({ sessionId, turnId, text, newId, now })

Source from the content-addressed store, hash-verified

4} from '../../packages/runtime/dist/ai-sdk-flow.js';
5
6export function createDirectRuntimeTurnLedger({ sessionId, turnId, text, newId, now }) {
7 const invocationId = `${sessionId}-invocation`;
8 const runId = `${sessionId}-run`;
9 const anchor = {
10 id: newId(),
11 invocationId,
12 runId,
13 sessionId,
14 turnId,
15 ts: now(),
16 partial: false,
17 role: 'user',
18 author: 'user',
19 content: { kind: 'text', text },
20 };
21 const events = [anchor];
22 const memory = createSessionEventMapMemory();
23 const context = {
24 sessionId,
25 invocationId,
26 runId,
27 turnId,
28 source: 'desktop',
29 startedAt: anchor.ts,
30 request: {
31 sessionId,
32 turnId,
33 text,
34 source: 'desktop',
35 initialRuntimeEvent: anchor,
36 },
37 newId,
38 now,
39 };
40
41 return {
42 anchor,
43 loadTurnRuntimeEvents: async (requestedTurnId) =>
44 events.filter((event) => event.turnId === requestedTurnId),
45 record(sessionEvent) {
46 const event = mapSessionEventToRuntimeEvent(sessionEvent, context, memory);
47 if (event.partial !== true && event.content?.kind !== 'error') events.push(event);
48 },
49 };
50}

Callers 2

runtime-model.mjsFile · 0.90

Calls 3

newIdFunction · 0.50
nowFunction · 0.50

Tested by

no test coverage detected