@deepstrike/wasm 0.2.60 → 0.2.62
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.
- package/dist/runtime/canonical-kernel-step.d.ts +2 -2
- package/dist/runtime/canonical-kernel-step.js +180 -233
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/kernel-step.d.ts +10 -4
- package/dist/runtime/kernel-step.js +12 -0
- package/dist/runtime/runner.js +8 -4
- package/package.json +2 -2
|
@@ -37,8 +37,8 @@ export interface CanonicalTransition {
|
|
|
37
37
|
replayed: boolean;
|
|
38
38
|
}
|
|
39
39
|
export declare function canonicalUnsupportedEffectResolution(effectId: string, effectKind: string): CanonicalKernelInput;
|
|
40
|
-
/**
|
|
41
|
-
export declare function
|
|
40
|
+
/** Adapt the additive core CurrentProjection JSON into the existing WASM action surface. */
|
|
41
|
+
export declare function canonicalActionFromProjectionJson(raw: string): KernelRunnerAction | null;
|
|
42
42
|
export declare class CanonicalKernelRejectedError extends Error {
|
|
43
43
|
readonly fault: Record<string, unknown>;
|
|
44
44
|
constructor(faultJson: string);
|
|
@@ -27,240 +27,186 @@ export function canonicalUnsupportedEffectResolution(effectId, effectKind) {
|
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
turnsUsed = Number(result.turns_used ?? turnsUsed);
|
|
41
|
-
const finalMessage = asObject(result.final_message);
|
|
42
|
-
const pace = asObject(result.pace_decision);
|
|
43
|
-
if (Object.keys(finalMessage).length > 0) {
|
|
44
|
-
return {
|
|
45
|
-
kind: "done",
|
|
46
|
-
effectId: "",
|
|
47
|
-
result: {
|
|
48
|
-
termination,
|
|
49
|
-
turnsUsed,
|
|
50
|
-
totalTokensUsed: totalUsageTokens(terminal),
|
|
51
|
-
finalMessage: {
|
|
52
|
-
role: String(finalMessage.role ?? "assistant"),
|
|
53
|
-
content: String(finalMessage.content ?? ""),
|
|
54
|
-
toolCalls: (Array.isArray(finalMessage.tool_calls) ? finalMessage.tool_calls : [])
|
|
55
|
-
.map(value => {
|
|
56
|
-
const call = asObject(value);
|
|
57
|
-
return {
|
|
58
|
-
id: String(call.call_id ?? ""),
|
|
59
|
-
name: String(call.name ?? ""),
|
|
60
|
-
arguments: JSON.stringify(call.arguments ?? {}),
|
|
61
|
-
};
|
|
62
|
-
}),
|
|
63
|
-
},
|
|
64
|
-
...(Object.keys(pace).length > 0
|
|
65
|
-
? {
|
|
66
|
-
paceDecision: {
|
|
67
|
-
action: String(pace.action ?? "stop"),
|
|
68
|
-
...(pace.delay_ms !== undefined ? { delayMs: Number(pace.delay_ms) } : {}),
|
|
69
|
-
reason: String(pace.reason ?? ""),
|
|
70
|
-
...(pace.coerced_from ? { coercedFrom: String(pace.coerced_from) } : {}),
|
|
71
|
-
},
|
|
72
|
-
}
|
|
73
|
-
: {}),
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (terminal.kind === "workflow") {
|
|
79
|
-
const outcome = asObject(terminal.outcome);
|
|
80
|
-
termination = String(outcome.status ?? "completed");
|
|
81
|
-
}
|
|
82
|
-
else if (terminal.kind === "cancelled") {
|
|
83
|
-
termination = String(terminal.reason ?? "cancelled");
|
|
84
|
-
}
|
|
85
|
-
else if (terminal.kind === "failed") {
|
|
86
|
-
const failure = asObject(terminal.failure);
|
|
87
|
-
termination = failure.code === "provider_recovery_exhausted"
|
|
88
|
-
? "context_overflow"
|
|
89
|
-
: "error";
|
|
90
|
-
}
|
|
30
|
+
function canonicalDoneFromTerminal(terminal) {
|
|
31
|
+
const usage = asObject(terminal.usage);
|
|
32
|
+
let termination = String(terminal.kind ?? "failed");
|
|
33
|
+
let turnsUsed = Number(usage.turns ?? 0);
|
|
34
|
+
if (terminal.kind === "agent") {
|
|
35
|
+
const result = asObject(terminal.result);
|
|
36
|
+
termination = String(result.termination ?? "completed");
|
|
37
|
+
turnsUsed = Number(result.turns_used ?? turnsUsed);
|
|
38
|
+
const finalMessage = asObject(result.final_message);
|
|
39
|
+
const pace = asObject(result.pace_decision);
|
|
91
40
|
return {
|
|
92
|
-
kind: "done",
|
|
93
|
-
effectId: "",
|
|
41
|
+
kind: "done", effectId: "",
|
|
94
42
|
result: {
|
|
95
|
-
termination,
|
|
96
|
-
|
|
97
|
-
|
|
43
|
+
termination, turnsUsed, totalTokensUsed: totalUsageTokens(terminal),
|
|
44
|
+
...(Object.keys(finalMessage).length > 0 ? { finalMessage: {
|
|
45
|
+
role: String(finalMessage.role ?? "assistant"),
|
|
46
|
+
content: String(finalMessage.content ?? ""),
|
|
47
|
+
toolCalls: (Array.isArray(finalMessage.tool_calls) ? finalMessage.tool_calls : []).map(value => {
|
|
48
|
+
const call = asObject(value);
|
|
49
|
+
return { id: String(call.call_id ?? ""), name: String(call.name ?? ""), arguments: JSON.stringify(call.arguments ?? {}) };
|
|
50
|
+
}),
|
|
51
|
+
} } : {}),
|
|
52
|
+
...(Object.keys(pace).length > 0 ? { paceDecision: {
|
|
53
|
+
action: String(pace.action ?? "stop"),
|
|
54
|
+
...(pace.delay_ms !== undefined ? { delayMs: Number(pace.delay_ms) } : {}),
|
|
55
|
+
reason: String(pace.reason ?? ""),
|
|
56
|
+
...(pace.coerced_from ? { coercedFrom: String(pace.coerced_from) } : {}),
|
|
57
|
+
} } : {}),
|
|
98
58
|
},
|
|
99
59
|
};
|
|
100
60
|
}
|
|
101
|
-
|
|
102
|
-
|
|
61
|
+
if (terminal.kind === "workflow")
|
|
62
|
+
termination = String(asObject(terminal.outcome).status ?? "completed");
|
|
63
|
+
if (terminal.kind === "cancelled")
|
|
64
|
+
termination = String(terminal.reason ?? "cancelled");
|
|
65
|
+
if (terminal.kind === "failed")
|
|
66
|
+
termination = asObject(terminal.failure).code === "provider_recovery_exhausted" ? "context_overflow" : "error";
|
|
67
|
+
return { kind: "done", effectId: "", result: { termination, turnsUsed, totalTokensUsed: totalUsageTokens(terminal) } };
|
|
68
|
+
}
|
|
69
|
+
/** Adapt the additive core CurrentProjection JSON into the existing WASM action surface. */
|
|
70
|
+
export function canonicalActionFromProjectionJson(raw) {
|
|
71
|
+
const projection = asObject(JSON.parse(raw));
|
|
72
|
+
const state = String(projection.state ?? "idle");
|
|
73
|
+
if (state === "idle")
|
|
103
74
|
return null;
|
|
104
|
-
if (
|
|
105
|
-
|
|
75
|
+
if (state === "terminal") {
|
|
76
|
+
return canonicalDoneFromTerminal(asObject(projection.action));
|
|
106
77
|
}
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
}),
|
|
126
|
-
};
|
|
127
|
-
case "execute_tools":
|
|
128
|
-
return {
|
|
129
|
-
kind: "execute_tool",
|
|
130
|
-
effectId,
|
|
131
|
-
calls: (Array.isArray(effect.calls) ? effect.calls : []).map(raw => {
|
|
132
|
-
const call = asObject(raw);
|
|
133
|
-
return {
|
|
134
|
-
id: String(call.call_id ?? ""),
|
|
135
|
-
name: String(call.name ?? ""),
|
|
136
|
-
arguments: JSON.stringify(call.arguments ?? {}),
|
|
137
|
-
};
|
|
138
|
-
}),
|
|
139
|
-
};
|
|
140
|
-
case "request_approval":
|
|
141
|
-
return {
|
|
142
|
-
kind: "request_approval",
|
|
143
|
-
effectId,
|
|
144
|
-
requests: (Array.isArray(effect.requests) ? effect.requests : []).map(raw => {
|
|
145
|
-
const request = asObject(raw);
|
|
146
|
-
return {
|
|
147
|
-
callId: String(request.call_id ?? ""),
|
|
148
|
-
tool: String(request.tool_name ?? ""),
|
|
149
|
-
arguments: JSON.stringify(request.arguments ?? {}),
|
|
150
|
-
reason: String(request.reason ?? ""),
|
|
151
|
-
};
|
|
152
|
-
}),
|
|
153
|
-
};
|
|
154
|
-
case "spawn_tasks":
|
|
155
|
-
return {
|
|
156
|
-
kind: "spawn_workflow",
|
|
157
|
-
effectId,
|
|
158
|
-
nodes: (Array.isArray(effect.tasks) ? effect.tasks : []).map(raw => {
|
|
159
|
-
const task = asObject(raw);
|
|
160
|
-
const spec = asObject(task.spec);
|
|
161
|
-
return {
|
|
162
|
-
agent_id: String(task.task_id ?? ""),
|
|
163
|
-
task_id: String(task.task_id ?? ""),
|
|
164
|
-
attempt_id: String(task.attempt_id ?? ""),
|
|
165
|
-
launch_token: String(task.launch_token ?? ""),
|
|
166
|
-
node_id: String(task.node_id ?? ""),
|
|
167
|
-
goal: String(spec.goal ?? ""),
|
|
168
|
-
role: String(spec.role ?? "custom"),
|
|
169
|
-
isolation: String(spec.isolation ?? "shared"),
|
|
170
|
-
context_inheritance: String(spec.context_inheritance ?? "none"),
|
|
171
|
-
...(spec.metadata && typeof spec.metadata === "object"
|
|
172
|
-
? asObject(spec.metadata)
|
|
173
|
-
: {}),
|
|
174
|
-
};
|
|
175
|
-
}),
|
|
176
|
-
...(effect.budget ? { budget: asObject(effect.budget) } : {}),
|
|
177
|
-
};
|
|
178
|
-
case "preempt_tasks": {
|
|
179
|
-
const attempts = (Array.isArray(effect.attempts) ? effect.attempts : []).map(raw => {
|
|
180
|
-
const attempt = asObject(raw);
|
|
78
|
+
const action = asObject(projection.action);
|
|
79
|
+
const payload = asObject(action.payload);
|
|
80
|
+
const effectId = String(action.effect_id ?? "");
|
|
81
|
+
if (action.kind === "query_memory") {
|
|
82
|
+
return {
|
|
83
|
+
kind: "query_memory",
|
|
84
|
+
effectId,
|
|
85
|
+
query: asObject(payload.query),
|
|
86
|
+
requestedK: Number(payload.requested_k ?? 0),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (action.kind === "execute_tools") {
|
|
90
|
+
return {
|
|
91
|
+
kind: "execute_tool",
|
|
92
|
+
effectId,
|
|
93
|
+
calls: (Array.isArray(payload.calls) ? payload.calls : []).map(raw => {
|
|
94
|
+
const call = asObject(raw);
|
|
181
95
|
return {
|
|
182
|
-
|
|
183
|
-
|
|
96
|
+
id: String(call.call_id ?? ""),
|
|
97
|
+
name: String(call.name ?? ""),
|
|
98
|
+
arguments: JSON.stringify(call.arguments ?? {}),
|
|
184
99
|
};
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (action.kind === "call_provider") {
|
|
104
|
+
const context = asObject(payload.context);
|
|
105
|
+
return {
|
|
106
|
+
kind: "call_provider",
|
|
107
|
+
effectId,
|
|
108
|
+
context: renderedContextToSdk(context),
|
|
109
|
+
tools: (Array.isArray(payload.tools) ? payload.tools : []).map(raw => {
|
|
110
|
+
const tool = asObject(raw);
|
|
111
|
+
return {
|
|
112
|
+
name: String(tool.name ?? ""),
|
|
113
|
+
description: String(tool.description ?? ""),
|
|
114
|
+
parameters: JSON.stringify(tool.parameters ?? {}),
|
|
115
|
+
};
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (action.kind === "request_approval") {
|
|
120
|
+
return {
|
|
121
|
+
kind: "request_approval",
|
|
122
|
+
effectId,
|
|
123
|
+
requests: (Array.isArray(payload.requests) ? payload.requests : []).map(raw => {
|
|
124
|
+
const request = asObject(raw);
|
|
125
|
+
return {
|
|
126
|
+
callId: String(request.call_id ?? ""),
|
|
127
|
+
tool: String(request.tool_name ?? ""),
|
|
128
|
+
arguments: JSON.stringify(request.arguments ?? {}),
|
|
129
|
+
reason: String(request.reason ?? ""),
|
|
130
|
+
};
|
|
131
|
+
}),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (action.kind === "load_payload") {
|
|
135
|
+
return {
|
|
136
|
+
kind: "load_payload",
|
|
137
|
+
effectId,
|
|
138
|
+
handleId: String(payload.handle_id ?? ""),
|
|
139
|
+
payloadRef: String(payload.payload_ref ?? ""),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (action.kind === "evaluate_milestone") {
|
|
143
|
+
const request = asObject(payload.request);
|
|
144
|
+
return {
|
|
145
|
+
kind: "evaluate_milestone",
|
|
146
|
+
effectId,
|
|
147
|
+
phaseId: String(request.phase_id ?? ""),
|
|
148
|
+
criteria: [],
|
|
149
|
+
requiredEvidence: [],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (action.kind === "spawn_tasks") {
|
|
153
|
+
return {
|
|
154
|
+
kind: "spawn_workflow",
|
|
155
|
+
effectId,
|
|
156
|
+
nodes: (Array.isArray(payload.tasks) ? payload.tasks : []).map(raw => {
|
|
157
|
+
const task = asObject(raw);
|
|
158
|
+
const spec = asObject(task.spec);
|
|
159
|
+
return {
|
|
160
|
+
agent_id: String(task.task_id ?? ""), task_id: String(task.task_id ?? ""),
|
|
161
|
+
attempt_id: String(task.attempt_id ?? ""), launch_token: String(task.launch_token ?? ""),
|
|
162
|
+
node_id: String(task.node_id ?? ""), goal: String(spec.goal ?? ""),
|
|
163
|
+
role: String(spec.role ?? "custom"), isolation: String(spec.isolation ?? "shared"),
|
|
164
|
+
context_inheritance: String(spec.context_inheritance ?? "none"),
|
|
165
|
+
...(spec.metadata && typeof spec.metadata === "object" ? asObject(spec.metadata) : {}),
|
|
166
|
+
};
|
|
167
|
+
}),
|
|
168
|
+
...(payload.budget ? { budget: asObject(payload.budget) } : {}),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (action.kind === "preempt_tasks") {
|
|
172
|
+
const attempts = (Array.isArray(payload.attempts) ? payload.attempts : []).map(raw => {
|
|
173
|
+
const attempt = asObject(raw);
|
|
174
|
+
return { task_id: String(attempt.task_id ?? ""), attempt_id: String(attempt.attempt_id ?? "") };
|
|
175
|
+
});
|
|
176
|
+
return { kind: "preempt_sub_agents", effectId, attempts, agentIds: attempts.map(a => a.task_id), reason: String(payload.reason ?? "") };
|
|
177
|
+
}
|
|
178
|
+
if (action.kind === "persist_memory") {
|
|
179
|
+
return { kind: "persist_memory", effectId, memory: asObject(payload.memory) };
|
|
180
|
+
}
|
|
181
|
+
if (action.kind === "archive_page_out") {
|
|
182
|
+
const archivePayload = asObject(payload.payload);
|
|
183
|
+
let archived = [];
|
|
184
|
+
try {
|
|
185
|
+
const decoded = JSON.parse(String(archivePayload.content ?? ""));
|
|
186
|
+
if (Array.isArray(decoded))
|
|
187
|
+
archived = decoded.map(value => kernelMessageToSdk(asObject(value)));
|
|
239
188
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
kind: "load_payload",
|
|
243
|
-
effectId,
|
|
244
|
-
handleId: String(effect.handle_id ?? ""),
|
|
245
|
-
payloadRef: String(effect.payload_ref ?? ""),
|
|
246
|
-
};
|
|
247
|
-
case "evaluate_milestone": {
|
|
248
|
-
const request = asObject(effect.request);
|
|
249
|
-
return {
|
|
250
|
-
kind: "evaluate_milestone",
|
|
251
|
-
effectId,
|
|
252
|
-
phaseId: String(request.phase_id ?? ""),
|
|
253
|
-
criteria: [],
|
|
254
|
-
requiredEvidence: [],
|
|
255
|
-
};
|
|
189
|
+
catch {
|
|
190
|
+
// The opaque archive payload remains authoritative even when presentation decoding fails.
|
|
256
191
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
192
|
+
return {
|
|
193
|
+
kind: "archive_page_out",
|
|
194
|
+
effectId,
|
|
195
|
+
handleId: String(payload.handle_id ?? ""),
|
|
196
|
+
payload: {
|
|
197
|
+
content: String(archivePayload.content ?? ""),
|
|
198
|
+
digest: String(archivePayload.digest ?? ""),
|
|
199
|
+
original_size: String(archivePayload.original_size ?? "0"),
|
|
200
|
+
...(archivePayload.preview ? { preview: String(archivePayload.preview) } : {}),
|
|
201
|
+
},
|
|
202
|
+
archived,
|
|
203
|
+
};
|
|
263
204
|
}
|
|
205
|
+
return {
|
|
206
|
+
kind: "unsupported_effect",
|
|
207
|
+
effectId,
|
|
208
|
+
effectKind: String(action.kind ?? ""),
|
|
209
|
+
};
|
|
264
210
|
}
|
|
265
211
|
export class CanonicalKernelRejectedError extends Error {
|
|
266
212
|
fault;
|
|
@@ -1165,6 +1111,16 @@ export class CanonicalRunnerRuntime {
|
|
|
1165
1111
|
throw new Error("canonical observation is missing kind");
|
|
1166
1112
|
this.hostObservations.push({ ...raw, kind });
|
|
1167
1113
|
}
|
|
1114
|
+
// §7.11 · a committed step that publishes effects is a fact worth recording in the
|
|
1115
|
+
// host event log: the journal stores only a digest of the step, so this manifest is
|
|
1116
|
+
// what makes the published effect ids + kinds recoverable post-hoc without replaying.
|
|
1117
|
+
const published = JSON.parse(this.host.kernel.publishedEffectsManifestJson(JSON.stringify(transition.plannedStep)));
|
|
1118
|
+
if (published.length > 0) {
|
|
1119
|
+
this.hostObservations.push({
|
|
1120
|
+
kind: "step_published_effects",
|
|
1121
|
+
effects: published,
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1168
1124
|
if (transition.checkpointAdvice) {
|
|
1169
1125
|
this.hostObservations.push({
|
|
1170
1126
|
kind: "checkpoint_advised",
|
|
@@ -1178,7 +1134,7 @@ export class CanonicalRunnerRuntime {
|
|
|
1178
1134
|
});
|
|
1179
1135
|
}
|
|
1180
1136
|
}
|
|
1181
|
-
this.lastAction =
|
|
1137
|
+
this.lastAction = canonicalActionFromProjectionJson(this.host.kernel.projectPlannedStepJson(JSON.stringify(transition.plannedStep)));
|
|
1182
1138
|
}
|
|
1183
1139
|
if (this.lastAction?.kind !== "unsupported_effect")
|
|
1184
1140
|
return this.lastAction;
|
|
@@ -1186,16 +1142,7 @@ export class CanonicalRunnerRuntime {
|
|
|
1186
1142
|
}
|
|
1187
1143
|
}
|
|
1188
1144
|
currentAction() {
|
|
1189
|
-
|
|
1190
|
-
if (terminal) {
|
|
1191
|
-
return canonicalActionFromPlannedStep({
|
|
1192
|
-
disposition: { kind: "terminal", terminal: JSON.parse(terminal) },
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
const effects = this.pendingEffects();
|
|
1196
|
-
return canonicalActionFromPlannedStep({
|
|
1197
|
-
disposition: { kind: "effects", effects },
|
|
1198
|
-
});
|
|
1145
|
+
return canonicalActionFromProjectionJson(this.host.kernel.currentProjectionJson());
|
|
1199
1146
|
}
|
|
1200
1147
|
pendingEffects() {
|
|
1201
1148
|
return JSON.parse(this.host.kernel.pendingEffectsJson());
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { MemoryPolicy, MemoryWriteRateLimit, OperationCancellationReason, P
|
|
|
9
9
|
export { RuntimeRunner, collectText } from "./runner.js";
|
|
10
10
|
export { MemoryPayloadDriver, PayloadStore } from "./payload-store.js";
|
|
11
11
|
export type { PayloadStorageDriver, PayloadStoreConfig } from "./payload-store.js";
|
|
12
|
-
export { CanonicalKernelHost, CanonicalKernelRejectedError, CanonicalKernelRebuildRequiredError, CanonicalRunnerRuntime,
|
|
12
|
+
export { CanonicalKernelHost, CanonicalKernelRejectedError, CanonicalKernelRebuildRequiredError, CanonicalRunnerRuntime, sha256, } from "./canonical-kernel-step.js";
|
|
13
13
|
export type { CanonicalKernelInput, CanonicalPlannedStep, CanonicalRunnerRuntimeOptions, CanonicalTransition, CanonicalTransitionOptions, } from "./canonical-kernel-step.js";
|
|
14
14
|
export { runAgent, runFanout } from "./facade.js";
|
|
15
15
|
export type { RunAgentOptions, RunFanoutOptions } from "./facade.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export * from "./context-policy.js";
|
|
|
5
5
|
export { LocalExecutionPlane } from "./execution-plane.js";
|
|
6
6
|
export { RuntimeRunner, collectText } from "./runner.js";
|
|
7
7
|
export { MemoryPayloadDriver, PayloadStore } from "./payload-store.js";
|
|
8
|
-
export { CanonicalKernelHost, CanonicalKernelRejectedError, CanonicalKernelRebuildRequiredError, CanonicalRunnerRuntime,
|
|
8
|
+
export { CanonicalKernelHost, CanonicalKernelRejectedError, CanonicalKernelRebuildRequiredError, CanonicalRunnerRuntime, sha256, } from "./canonical-kernel-step.js";
|
|
9
9
|
export { runAgent, runFanout } from "./facade.js";
|
|
10
10
|
export { builtinReducers, resolveReducer } from "./reducers.js";
|
|
11
11
|
export { getKernel } from "./kernel.js";
|
|
@@ -84,11 +84,7 @@ export type KernelRunnerAction = {
|
|
|
84
84
|
} | {
|
|
85
85
|
kind: "archive_page_out";
|
|
86
86
|
effectId: string;
|
|
87
|
-
turn?: number;
|
|
88
|
-
action?: string;
|
|
89
|
-
summary?: string;
|
|
90
87
|
archived: Message[];
|
|
91
|
-
tier?: string;
|
|
92
88
|
handleId?: string;
|
|
93
89
|
payload?: {
|
|
94
90
|
content: string;
|
|
@@ -204,7 +200,17 @@ export interface KernelObservation {
|
|
|
204
200
|
rollbacks_in_window?: number;
|
|
205
201
|
window_turns?: number;
|
|
206
202
|
threshold?: number;
|
|
203
|
+
effects?: Array<{
|
|
204
|
+
effect_id: string;
|
|
205
|
+
kind: string;
|
|
206
|
+
}>;
|
|
207
207
|
}
|
|
208
|
+
/** Presentation/policy facts for archive actions are sourced from committed observations. */
|
|
209
|
+
export declare function archivePresentationFromObservations(observations: readonly KernelObservation[]): {
|
|
210
|
+
action?: string;
|
|
211
|
+
summary?: string;
|
|
212
|
+
tier?: "semantic" | "durable";
|
|
213
|
+
};
|
|
208
214
|
export declare function toolSchemaToKernel(schema: ToolSchema): Record<string, unknown>;
|
|
209
215
|
export declare function skillMetadataToKernel(skill: SkillMetadata): Record<string, unknown>;
|
|
210
216
|
export declare function messageToKernelMessage(message: Message): Record<string, unknown>;
|
|
@@ -25,6 +25,18 @@ export function decodeCanonicalContentParts(content) {
|
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
/** Presentation/policy facts for archive actions are sourced from committed observations. */
|
|
29
|
+
export function archivePresentationFromObservations(observations) {
|
|
30
|
+
const compressed = [...observations].reverse().find(observation => observation.kind === "compressed");
|
|
31
|
+
const action = compressed?.action;
|
|
32
|
+
if (action !== "snip_compact" && action !== "micro_compact" && action !== "context_collapse" && action !== "auto_compact")
|
|
33
|
+
return {};
|
|
34
|
+
return {
|
|
35
|
+
action,
|
|
36
|
+
...(compressed?.summary ? { summary: compressed.summary } : {}),
|
|
37
|
+
tier: action === "context_collapse" || action === "auto_compact" ? "semantic" : "durable",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
28
40
|
function tryParseJson(s) {
|
|
29
41
|
try {
|
|
30
42
|
return JSON.parse(s);
|
package/dist/runtime/runner.js
CHANGED
|
@@ -8,7 +8,7 @@ import { sanitizeReplayText } from "./replay-sanitize.js";
|
|
|
8
8
|
import { decodeDurableContent, decodeDurableToolResult, durableBlocksToToolOutput, toolOutputBlocksToDurable } from "./durable-content.js";
|
|
9
9
|
import { formatToolError } from "../tools/errors.js";
|
|
10
10
|
import { buildLlmCompletedEvent, buildRunTerminalEvent, buildWorkflowNodeCompletedEvent, buildWorkflowNodesSubmittedEvent, } from "./session-repair.js";
|
|
11
|
-
import { messageToKernelMessage, skillMetadataToKernel, taskUpdateToKernel, toolResultToKernel, toolSchemaToKernel, } from "./kernel-step.js";
|
|
11
|
+
import { messageToKernelMessage, archivePresentationFromObservations, skillMetadataToKernel, taskUpdateToKernel, toolResultToKernel, toolSchemaToKernel, } from "./kernel-step.js";
|
|
12
12
|
import { agentRunSpecToKernel, MILESTONE_UNVERIFIED_REASON, milestoneCheckFail, milestoneCheckPass, milestoneCheckResultToKernel, subAgentResultToKernel, workflowBudgetNote, workflowNodeSpecToKernel, workflowNodeOutcomeFromKernel, workflowNodeStatusFromTermination, workflowNodeToManifest, workflowNodeToSpec, workflowSpecToKernel, } from "./types/agent.js";
|
|
13
13
|
import { defaultSubAgentOrchestrator } from "./sub-agent-orchestrator.js";
|
|
14
14
|
import { extractJsonValue, schemaInstruction, schemaRetryInstruction, validateAgainstSchema, } from "./output-schema.js";
|
|
@@ -899,8 +899,8 @@ export class RuntimeRunner {
|
|
|
899
899
|
error = formatToolError(cause);
|
|
900
900
|
}
|
|
901
901
|
const archived = action.archived;
|
|
902
|
-
const archiveAction =
|
|
903
|
-
const archiveTier =
|
|
902
|
+
const archiveAction = archiveMeta.action ?? "auto_compact";
|
|
903
|
+
const archiveTier = archiveMeta.tier;
|
|
904
904
|
if (!error)
|
|
905
905
|
this.activePageOutArchive = undefined;
|
|
906
906
|
action = await this.commitKernelAction(runtime, this.pendingObservations, {
|
|
@@ -1767,7 +1767,11 @@ export class RuntimeRunner {
|
|
|
1767
1767
|
const compressedSeq = await this.opts.sessionLog.append(sessionId, event);
|
|
1768
1768
|
if (event.kind === "compressed") {
|
|
1769
1769
|
if ((obs.archived_count ?? 0) > 0) {
|
|
1770
|
-
this.pendingPageOutArchives.push({
|
|
1770
|
+
this.pendingPageOutArchives.push({
|
|
1771
|
+
archiveStart: nextArchiveStart,
|
|
1772
|
+
compressedSeq,
|
|
1773
|
+
...archivePresentationFromObservations([obs]),
|
|
1774
|
+
});
|
|
1771
1775
|
}
|
|
1772
1776
|
nextArchiveStart = compressedSeq + 1;
|
|
1773
1777
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/wasm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.62",
|
|
4
4
|
"description": "DeepStrike WASM SDK — browser, Cloudflare Workers, Deno Deploy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"test:canonical-binding": "wasm-pack build ../crates/deepstrike-wasm --target nodejs --dev --out-dir ../../wasm/pkg-node && node tests/canonical-binding.node.cjs"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@deepstrike/wasm-kernel": "0.2.
|
|
19
|
+
"@deepstrike/wasm-kernel": "0.2.62"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/jest": "^30.0.0",
|