@inf-monkeys-tech/monkeys 1.0.14 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ import { type AgentSessionEvent, type AgentSessionSnapshot, type AgentSessionStatus, type AgentSessionViewModel } from "../contracts/agent";
2
+ export interface AgentSessionEventGap {
3
+ expectedSequence: number;
4
+ receivedSequence: number;
5
+ }
6
+ export interface AgentSessionEventProjection {
7
+ sessionId: string;
8
+ events: AgentSessionEvent[];
9
+ lastSequence: number;
10
+ status: AgentSessionStatus;
11
+ resumable: boolean;
12
+ gap?: AgentSessionEventGap;
13
+ }
14
+ export declare function createAgentSessionEventProjection(sessionId: string): AgentSessionEventProjection;
15
+ export declare function projectAgentSessionEvents(current: AgentSessionEventProjection, candidates: readonly unknown[]): AgentSessionEventProjection;
16
+ export declare function toAgentSessionViewModel(projection: AgentSessionEventProjection, snapshot: AgentSessionSnapshot): AgentSessionViewModel;
17
+ //# sourceMappingURL=agent-session-projector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-session-projector.d.ts","sourceRoot":"","sources":["../../src/runtime/agent-session-projector.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,oBAAoB,CAAC;CAC5B;AAED,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,GAChB,2BAA2B,CAQ7B;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,2BAA2B,EACpC,UAAU,EAAE,SAAS,OAAO,EAAE,GAC7B,2BAA2B,CA4E7B;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,2BAA2B,EACvC,QAAQ,EAAE,oBAAoB,GAC7B,qBAAqB,CAUvB"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toAgentSessionViewModel = exports.projectAgentSessionEvents = exports.createAgentSessionEventProjection = void 0;
4
+ const agent_1 = require("../contracts/agent");
5
+ function createAgentSessionEventProjection(sessionId) {
6
+ return {
7
+ sessionId,
8
+ events: [],
9
+ lastSequence: -1,
10
+ status: "queued",
11
+ resumable: false,
12
+ };
13
+ }
14
+ exports.createAgentSessionEventProjection = createAgentSessionEventProjection;
15
+ function projectAgentSessionEvents(current, candidates) {
16
+ const parsed = candidates.map((candidate) => agent_1.AgentSessionEventSchema.parse(candidate));
17
+ if (parsed.some((event) => event.sessionId !== current.sessionId)) {
18
+ throw new TypeError("Agent session event sessionId does not match the projection sessionId.");
19
+ }
20
+ const eventIds = new Set(current.events.map((event) => event.eventId));
21
+ const idempotencyKeys = new Set(current.events.map((event) => event.idempotencyKey));
22
+ const eventsBySequence = new Map(current.events.map((event) => [event.sequence, event]));
23
+ const acceptedCandidates = [];
24
+ for (const event of parsed.sort((left, right) => left.sequence - right.sequence)) {
25
+ if (eventIds.has(event.eventId) ||
26
+ idempotencyKeys.has(event.idempotencyKey))
27
+ continue;
28
+ const existing = eventsBySequence.get(event.sequence);
29
+ if (existing) {
30
+ throw new TypeError(`Conflicting Agent session events share sequence ${event.sequence}.`);
31
+ }
32
+ eventsBySequence.set(event.sequence, event);
33
+ eventIds.add(event.eventId);
34
+ idempotencyKeys.add(event.idempotencyKey);
35
+ acceptedCandidates.push(event);
36
+ }
37
+ for (const event of acceptedCandidates)
38
+ eventsBySequence.delete(event.sequence);
39
+ let expectedSequence = current.lastSequence + 1;
40
+ let gap;
41
+ for (const event of acceptedCandidates) {
42
+ if (event.sequence < expectedSequence) {
43
+ throw new TypeError(`Agent session event sequence ${event.sequence} is behind the recovery cursor.`);
44
+ }
45
+ if (event.sequence > expectedSequence) {
46
+ gap = { expectedSequence, receivedSequence: event.sequence };
47
+ break;
48
+ }
49
+ eventsBySequence.set(event.sequence, event);
50
+ eventIds.add(event.eventId);
51
+ idempotencyKeys.add(event.idempotencyKey);
52
+ expectedSequence += 1;
53
+ }
54
+ const events = [...eventsBySequence.values()].sort((left, right) => left.sequence - right.sequence);
55
+ let status = "queued";
56
+ let resumable = false;
57
+ for (const event of events) {
58
+ if (event.eventType === "status")
59
+ status = event.payload.status;
60
+ if (event.eventType === "resume")
61
+ resumable = event.payload.resumable;
62
+ }
63
+ return {
64
+ sessionId: current.sessionId,
65
+ events,
66
+ lastSequence: events.length > 0 ? events[events.length - 1].sequence : -1,
67
+ status,
68
+ resumable,
69
+ ...(gap ? { gap } : {}),
70
+ };
71
+ }
72
+ exports.projectAgentSessionEvents = projectAgentSessionEvents;
73
+ function toAgentSessionViewModel(projection, snapshot) {
74
+ return agent_1.AgentSessionViewModelSchema.parse({
75
+ contract: "AgentSessionViewModel",
76
+ sessionId: projection.sessionId,
77
+ snapshot,
78
+ status: projection.status,
79
+ events: projection.events,
80
+ lastSequence: projection.lastSequence,
81
+ resumable: projection.resumable,
82
+ });
83
+ }
84
+ exports.toAgentSessionViewModel = toAgentSessionViewModel;
85
+ //# sourceMappingURL=agent-session-projector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-session-projector.js","sourceRoot":"","sources":["../../src/runtime/agent-session-projector.ts"],"names":[],"mappings":";;;AAAA,8CAO4B;AAgB5B,SAAgB,iCAAiC,CAC/C,SAAiB;IAEjB,OAAO;QACL,SAAS;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,CAAC,CAAC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C,CAAC,CAAC;AACL,CAAC;AAbD,0DAaC"}
@@ -1,4 +1,5 @@
1
1
  export * from './capability-registry';
2
+ export * from './agent-session-projector';
2
3
  export * from './declaration-compiler';
3
4
  export * from './page-compiler';
4
5
  export * from './product-runtime';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./capability-registry"), exports);
18
+ __exportStar(require("./agent-session-projector"), exports);
18
19
  __exportStar(require("./declaration-compiler"), exports);
19
20
  __exportStar(require("./page-compiler"), exports);
20
21
  __exportStar(require("./product-runtime"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,yDAAuC;AACvC,kDAAgC;AAChC,oDAAkC;AAClC,yDAAuC;AACvC,kDAAgC;AAChC,4DAA0C;AAC1C,iDAA+B;AAC/B,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,4DAA0C;AAC1C,yDAAuC;AACvC,kDAAgC;AAChC,oDAAkC;AAClC,yDAAuC;AACvC,kDAAgC;AAChC,4DAA0C;AAC1C,iDAA+B;AAC/B,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inf-monkeys-tech/monkeys",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Monkeys JS SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -29,11 +29,13 @@
29
29
  "require": "./lib/runtime/index.js",
30
30
  "default": "./lib/runtime/index.js"
31
31
  },
32
+ "./fixtures/*": "./test/fixtures/*",
32
33
  "./json-schema/*": "./lib/json-schema/*",
33
34
  "./package.json": "./package.json"
34
35
  },
35
36
  "files": [
36
37
  "lib",
38
+ "test/fixtures",
37
39
  "README.md"
38
40
  ],
39
41
  "repository": {
@@ -0,0 +1,134 @@
1
+ {
2
+ "contract": "AgentSessionViewModel",
3
+ "sessionId": "agent-session-1",
4
+ "snapshot": {
5
+ "mode": "agent",
6
+ "modelId": "openai:gpt-5.1-codex",
7
+ "capabilities": {
8
+ "text": true,
9
+ "reasoning": false,
10
+ "plan": false,
11
+ "tasks": false,
12
+ "tools": true,
13
+ "mcp": true,
14
+ "shell": true,
15
+ "fileChange": true,
16
+ "skills": true,
17
+ "approval": true,
18
+ "artifacts": true,
19
+ "usage": true,
20
+ "resume": true,
21
+ "diff": false,
22
+ "workspaceFiles": false,
23
+ "terminal": false,
24
+ "testResults": false
25
+ }
26
+ },
27
+ "status": "waiting_approval",
28
+ "events": [
29
+ {
30
+ "contract": "AgentSessionEvent",
31
+ "eventId": "agent-event-1",
32
+ "sessionId": "agent-session-1",
33
+ "sequence": 0,
34
+ "idempotencyKey": "agent-session-1:0",
35
+ "occurredAt": "2026-07-30T08:00:00.000Z",
36
+ "eventType": "status",
37
+ "payload": { "status": "running" }
38
+ },
39
+ {
40
+ "contract": "AgentSessionEvent",
41
+ "eventId": "agent-event-2",
42
+ "sessionId": "agent-session-1",
43
+ "sequence": 1,
44
+ "idempotencyKey": "agent-session-1:1",
45
+ "occurredAt": "2026-07-30T08:00:01.000Z",
46
+ "eventType": "tool",
47
+ "payload": {
48
+ "toolCallId": "tool-1",
49
+ "toolName": "shell",
50
+ "status": "running",
51
+ "input": { "command": "git status" }
52
+ }
53
+ },
54
+ {
55
+ "contract": "AgentSessionEvent",
56
+ "eventId": "agent-event-3",
57
+ "sessionId": "agent-session-1",
58
+ "sequence": 2,
59
+ "idempotencyKey": "agent-session-1:2",
60
+ "occurredAt": "2026-07-30T08:00:02.000Z",
61
+ "eventType": "approval",
62
+ "payload": {
63
+ "approvalId": "approval-1",
64
+ "toolCallId": "tool-1",
65
+ "status": "requested",
66
+ "title": "Run shell command",
67
+ "requestedAction": { "command": "git status" }
68
+ }
69
+ },
70
+ {
71
+ "contract": "AgentSessionEvent",
72
+ "eventId": "agent-event-4",
73
+ "sessionId": "agent-session-1",
74
+ "sequence": 3,
75
+ "idempotencyKey": "agent-session-1:3",
76
+ "occurredAt": "2026-07-30T08:00:03.000Z",
77
+ "eventType": "artifact",
78
+ "payload": {
79
+ "artifactId": "artifact-1",
80
+ "name": "report.txt",
81
+ "kind": "file",
82
+ "status": "ready"
83
+ }
84
+ },
85
+ {
86
+ "contract": "AgentSessionEvent",
87
+ "eventId": "agent-event-5",
88
+ "sessionId": "agent-session-1",
89
+ "sequence": 4,
90
+ "idempotencyKey": "agent-session-1:4",
91
+ "occurredAt": "2026-07-30T08:00:04.000Z",
92
+ "eventType": "usage",
93
+ "payload": { "inputTokens": 24, "outputTokens": 8, "totalTokens": 32 }
94
+ },
95
+ {
96
+ "contract": "AgentSessionEvent",
97
+ "eventId": "agent-event-6",
98
+ "sessionId": "agent-session-1",
99
+ "sequence": 5,
100
+ "idempotencyKey": "agent-session-1:5",
101
+ "occurredAt": "2026-07-30T08:00:05.000Z",
102
+ "eventType": "resume",
103
+ "payload": { "resumable": true, "reason": "approval_required" }
104
+ },
105
+ {
106
+ "contract": "AgentSessionEvent",
107
+ "eventId": "agent-event-7",
108
+ "sessionId": "agent-session-1",
109
+ "sequence": 6,
110
+ "idempotencyKey": "agent-session-1:6",
111
+ "occurredAt": "2026-07-30T08:00:06.000Z",
112
+ "eventType": "status",
113
+ "payload": { "status": "waiting_approval" }
114
+ },
115
+ {
116
+ "contract": "AgentSessionEvent",
117
+ "eventId": "agent-event-8",
118
+ "sessionId": "agent-session-1",
119
+ "sequence": 7,
120
+ "idempotencyKey": "agent-session-1:7",
121
+ "occurredAt": "2026-07-30T08:00:07.000Z",
122
+ "eventType": "message",
123
+ "payload": {
124
+ "messageId": "agent-message-1",
125
+ "role": "assistant",
126
+ "operation": "append",
127
+ "parts": [{ "type": "text", "text": "Waiting for approval" }],
128
+ "status": "streaming"
129
+ }
130
+ }
131
+ ],
132
+ "lastSequence": 7,
133
+ "resumable": true
134
+ }
@@ -0,0 +1,83 @@
1
+ {
2
+ "contract": "AgentSessionViewModel",
3
+ "sessionId": "chatbot-session-1",
4
+ "snapshot": {
5
+ "mode": "chatbot",
6
+ "modelId": "openai:gpt-5.1",
7
+ "capabilities": {
8
+ "text": true,
9
+ "reasoning": false,
10
+ "plan": false,
11
+ "tasks": false,
12
+ "tools": true,
13
+ "mcp": true,
14
+ "shell": false,
15
+ "fileChange": false,
16
+ "skills": true,
17
+ "approval": true,
18
+ "artifacts": false,
19
+ "usage": true,
20
+ "resume": false,
21
+ "diff": false,
22
+ "workspaceFiles": false,
23
+ "terminal": false,
24
+ "testResults": false
25
+ }
26
+ },
27
+ "status": "completed",
28
+ "events": [
29
+ {
30
+ "contract": "AgentSessionEvent",
31
+ "eventId": "chatbot-event-1",
32
+ "sessionId": "chatbot-session-1",
33
+ "sequence": 0,
34
+ "idempotencyKey": "chatbot-session-1:0",
35
+ "occurredAt": "2026-07-30T08:00:00.000Z",
36
+ "eventType": "message",
37
+ "payload": {
38
+ "messageId": "chatbot-message-1",
39
+ "role": "assistant",
40
+ "operation": "append",
41
+ "parts": [{ "type": "text", "text": "Hello" }],
42
+ "status": "completed"
43
+ }
44
+ },
45
+ {
46
+ "contract": "AgentSessionEvent",
47
+ "eventId": "chatbot-event-2",
48
+ "sessionId": "chatbot-session-1",
49
+ "sequence": 1,
50
+ "idempotencyKey": "chatbot-session-1:1",
51
+ "occurredAt": "2026-07-30T08:00:01.000Z",
52
+ "eventType": "tool",
53
+ "payload": {
54
+ "toolCallId": "tool-1",
55
+ "toolName": "search",
56
+ "status": "completed",
57
+ "output": { "count": 1 }
58
+ }
59
+ },
60
+ {
61
+ "contract": "AgentSessionEvent",
62
+ "eventId": "chatbot-event-3",
63
+ "sessionId": "chatbot-session-1",
64
+ "sequence": 2,
65
+ "idempotencyKey": "chatbot-session-1:2",
66
+ "occurredAt": "2026-07-30T08:00:02.000Z",
67
+ "eventType": "usage",
68
+ "payload": { "inputTokens": 12, "outputTokens": 4, "totalTokens": 16 }
69
+ },
70
+ {
71
+ "contract": "AgentSessionEvent",
72
+ "eventId": "chatbot-event-4",
73
+ "sessionId": "chatbot-session-1",
74
+ "sequence": 3,
75
+ "idempotencyKey": "chatbot-session-1:3",
76
+ "occurredAt": "2026-07-30T08:00:03.000Z",
77
+ "eventType": "status",
78
+ "payload": { "status": "completed" }
79
+ }
80
+ ],
81
+ "lastSequence": 3,
82
+ "resumable": false
83
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "commands": [
3
+ {
4
+ "contract": "AgentSessionCommand",
5
+ "commandId": "command-stop-1",
6
+ "sessionId": "agent-session-1",
7
+ "idempotencyKey": "agent-session-1:stop:1",
8
+ "expectedSequence": 2,
9
+ "issuedAt": "2026-07-30T00:00:00.000Z",
10
+ "commandType": "stop",
11
+ "payload": { "reason": "User requested stop." }
12
+ },
13
+ {
14
+ "contract": "AgentSessionCommand",
15
+ "commandId": "command-resume-1",
16
+ "sessionId": "agent-session-1",
17
+ "idempotencyKey": "agent-session-1:resume:1",
18
+ "expectedSequence": 4,
19
+ "issuedAt": "2026-07-30T00:01:00.000Z",
20
+ "commandType": "resume",
21
+ "payload": { "resumeEventId": "resume-event-1" }
22
+ },
23
+ {
24
+ "contract": "AgentSessionCommand",
25
+ "commandId": "command-retry-1",
26
+ "sessionId": "agent-session-1",
27
+ "idempotencyKey": "agent-session-1:retry:1",
28
+ "expectedSequence": 6,
29
+ "issuedAt": "2026-07-30T00:02:00.000Z",
30
+ "commandType": "retry",
31
+ "payload": { "sourceEventId": "error-event-1" }
32
+ },
33
+ {
34
+ "contract": "AgentSessionCommand",
35
+ "commandId": "command-approval-1",
36
+ "sessionId": "agent-session-1",
37
+ "idempotencyKey": "agent-session-1:approval:1",
38
+ "expectedSequence": 8,
39
+ "issuedAt": "2026-07-30T00:03:00.000Z",
40
+ "commandType": "approval",
41
+ "payload": { "approvalId": "approval-1", "decision": "approved" }
42
+ }
43
+ ],
44
+ "results": [
45
+ {
46
+ "contract": "AgentSessionCommandResult",
47
+ "commandId": "command-stop-1",
48
+ "sessionId": "agent-session-1",
49
+ "idempotencyKey": "agent-session-1:stop:1",
50
+ "outcome": "accepted",
51
+ "sessionStatus": "stopping",
52
+ "acceptedSequence": 3,
53
+ "resultEventIds": ["status-event-3"],
54
+ "occurredAt": "2026-07-30T00:00:00.100Z"
55
+ },
56
+ {
57
+ "contract": "AgentSessionCommandResult",
58
+ "commandId": "command-retry-2",
59
+ "sessionId": "agent-session-1",
60
+ "idempotencyKey": "agent-session-1:retry:2",
61
+ "outcome": "rejected",
62
+ "sessionStatus": "completed",
63
+ "resultEventIds": [],
64
+ "error": {
65
+ "code": "INVALID_SESSION_STATE",
66
+ "message": "Retry requires a failed session.",
67
+ "retryable": false
68
+ },
69
+ "occurredAt": "2026-07-30T00:04:00.000Z"
70
+ }
71
+ ]
72
+ }
@@ -0,0 +1,131 @@
1
+ {
2
+ "contract": "AgentSessionViewModel",
3
+ "sessionId": "kernel-session-1",
4
+ "snapshot": {
5
+ "mode": "agent",
6
+ "modelId": "kernel:claude-code",
7
+ "capabilities": {
8
+ "text": true,
9
+ "reasoning": true,
10
+ "plan": false,
11
+ "tasks": false,
12
+ "tools": true,
13
+ "mcp": false,
14
+ "shell": true,
15
+ "fileChange": true,
16
+ "skills": false,
17
+ "approval": true,
18
+ "artifacts": true,
19
+ "usage": false,
20
+ "resume": true,
21
+ "diff": false,
22
+ "workspaceFiles": true,
23
+ "terminal": true,
24
+ "testResults": false
25
+ }
26
+ },
27
+ "status": "running",
28
+ "events": [
29
+ {
30
+ "contract": "AgentSessionEvent",
31
+ "eventId": "kernel-event-1",
32
+ "sessionId": "kernel-session-1",
33
+ "sequence": 0,
34
+ "idempotencyKey": "kernel-session-1:0",
35
+ "occurredAt": "2026-07-30T08:00:00.000Z",
36
+ "eventType": "status",
37
+ "payload": { "status": "running" }
38
+ },
39
+ {
40
+ "contract": "AgentSessionEvent",
41
+ "eventId": "kernel-event-2",
42
+ "sessionId": "kernel-session-1",
43
+ "sequence": 1,
44
+ "idempotencyKey": "kernel-session-1:1",
45
+ "occurredAt": "2026-07-30T08:00:01.000Z",
46
+ "eventType": "workspace-file",
47
+ "payload": {
48
+ "path": "src/index.ts",
49
+ "operation": "upsert",
50
+ "mimeType": "text/typescript",
51
+ "size": 128
52
+ }
53
+ },
54
+ {
55
+ "contract": "AgentSessionEvent",
56
+ "eventId": "kernel-event-3",
57
+ "sessionId": "kernel-session-1",
58
+ "sequence": 2,
59
+ "idempotencyKey": "kernel-session-1:2",
60
+ "occurredAt": "2026-07-30T08:00:02.000Z",
61
+ "eventType": "terminal",
62
+ "payload": {
63
+ "terminalId": "terminal-1",
64
+ "stream": "stdout",
65
+ "chunk": "Tests passed\n"
66
+ }
67
+ },
68
+ {
69
+ "contract": "AgentSessionEvent",
70
+ "eventId": "kernel-event-4",
71
+ "sessionId": "kernel-session-1",
72
+ "sequence": 3,
73
+ "idempotencyKey": "kernel-session-1:3",
74
+ "occurredAt": "2026-07-30T08:00:03.000Z",
75
+ "eventType": "message",
76
+ "payload": {
77
+ "messageId": "kernel-message-1",
78
+ "role": "assistant",
79
+ "operation": "append",
80
+ "parts": [{ "type": "text", "text": "Tests passed" }],
81
+ "status": "completed"
82
+ }
83
+ },
84
+ {
85
+ "contract": "AgentSessionEvent",
86
+ "eventId": "kernel-event-5",
87
+ "sessionId": "kernel-session-1",
88
+ "sequence": 4,
89
+ "idempotencyKey": "kernel-session-1:4",
90
+ "occurredAt": "2026-07-30T08:00:04.000Z",
91
+ "eventType": "reasoning",
92
+ "payload": {
93
+ "reasoningId": "kernel-reasoning-1",
94
+ "text": "Checking tests",
95
+ "status": "completed"
96
+ }
97
+ },
98
+ {
99
+ "contract": "AgentSessionEvent",
100
+ "eventId": "kernel-event-6",
101
+ "sessionId": "kernel-session-1",
102
+ "sequence": 5,
103
+ "idempotencyKey": "kernel-session-1:5",
104
+ "occurredAt": "2026-07-30T08:00:05.000Z",
105
+ "eventType": "tool",
106
+ "payload": {
107
+ "toolCallId": "kernel-tool-1",
108
+ "toolName": "shell",
109
+ "status": "completed",
110
+ "output": "Tests passed"
111
+ }
112
+ },
113
+ {
114
+ "contract": "AgentSessionEvent",
115
+ "eventId": "kernel-event-7",
116
+ "sessionId": "kernel-session-1",
117
+ "sequence": 6,
118
+ "idempotencyKey": "kernel-session-1:6",
119
+ "occurredAt": "2026-07-30T08:00:06.000Z",
120
+ "eventType": "artifact",
121
+ "payload": {
122
+ "artifactId": "kernel-artifact-1",
123
+ "name": "test.log",
124
+ "kind": "file",
125
+ "status": "ready"
126
+ }
127
+ }
128
+ ],
129
+ "lastSequence": 6,
130
+ "resumable": true
131
+ }