@deepstrike/wasm 0.2.77 → 0.2.79
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/agent.d.ts +6 -2
- package/dist/agent.js +59 -19
- package/dist/index.d.ts +7 -9
- package/dist/index.js +3 -5
- package/dist/memory/attestation.d.ts +38 -0
- package/dist/memory/attestation.js +43 -0
- package/dist/memory/authority.d.ts +2 -0
- package/dist/memory/authority.js +3 -1
- package/dist/memory/candidate-sink.d.ts +66 -0
- package/dist/memory/candidate-sink.js +82 -0
- package/dist/memory/durable.d.ts +4 -2
- package/dist/memory/durable.js +2 -0
- package/dist/memory/index.d.ts +9 -1
- package/dist/memory/index.js +5 -0
- package/dist/memory/lifecycle.d.ts +82 -0
- package/dist/memory/lifecycle.js +46 -0
- package/dist/memory/recall-projection.d.ts +5 -0
- package/dist/memory/recall-projection.js +18 -0
- package/dist/memory/runtime-policy.d.ts +15 -0
- package/dist/memory/runtime-policy.js +26 -0
- package/dist/memory/writer.d.ts +22 -0
- package/dist/memory/writer.js +41 -0
- package/dist/providers/anthropic-compaction.d.ts +84 -0
- package/dist/providers/anthropic-compaction.js +222 -0
- package/dist/providers/anthropic.d.ts +41 -1
- package/dist/providers/anthropic.js +187 -18
- package/dist/providers/base.js +11 -1
- package/dist/runtime/canonical-kernel-step.d.ts +1 -2
- package/dist/runtime/canonical-kernel-step.js +74 -8
- package/dist/runtime/execution-plane.js +1 -1
- package/dist/runtime/index.d.ts +0 -2
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/kernel-event-log.d.ts +8 -0
- package/dist/runtime/kernel-event-log.js +63 -1
- package/dist/runtime/kernel-step.d.ts +15 -2
- package/dist/runtime/os-snapshot.js +1 -0
- package/dist/runtime/runner.d.ts +44 -26
- package/dist/runtime/runner.js +206 -240
- package/dist/runtime/session-event-registry.generated.d.ts +212 -0
- package/dist/runtime/session-event-registry.generated.js +112 -0
- package/dist/runtime/session-log.d.ts +83 -16
- package/dist/runtime/session-log.js +10 -58
- package/dist/runtime/session-repair.d.ts +0 -3
- package/dist/runtime/session-repair.js +0 -3
- package/dist/runtime/sub-agent-orchestrator.d.ts +5 -1
- package/dist/runtime/sub-agent-orchestrator.js +4 -0
- package/dist/runtime/types/agent.d.ts +18 -52
- package/dist/runtime/types/agent.js +8 -45
- package/dist/types.d.ts +10 -5
- package/package.json +3 -3
- package/dist/memory/extraction.d.ts +0 -4
- package/dist/memory/extraction.js +0 -48
- package/dist/runtime/context.d.ts +0 -28
- package/dist/runtime/context.js +0 -16
- package/dist/runtime/evolution.d.ts +0 -189
- package/dist/runtime/evolution.js +0 -25
- package/dist/runtime/reducers.d.ts +0 -15
- package/dist/runtime/reducers.js +0 -57
- package/dist/runtime/verifiable-report.d.ts +0 -59
- package/dist/runtime/verifiable-report.js +0 -64
- package/dist/runtime/workflow-control-flow.d.ts +0 -21
- package/dist/runtime/workflow-control-flow.js +0 -83
|
@@ -9,9 +9,13 @@ export function categoryForKind(kind) {
|
|
|
9
9
|
case "page_in_requested":
|
|
10
10
|
case "renewed":
|
|
11
11
|
case "context_renewed":
|
|
12
|
+
case "lifecycle_report":
|
|
13
|
+
case "context_lifecycle_reported":
|
|
12
14
|
case "memory_written":
|
|
13
15
|
case "memory_queried":
|
|
14
16
|
case "memory_validation_failed":
|
|
17
|
+
case "memory_candidate_pending":
|
|
18
|
+
case "memory_candidate_rejected":
|
|
15
19
|
return "mm";
|
|
16
20
|
case "agent_process_changed":
|
|
17
21
|
return "proc";
|
|
@@ -21,9 +25,27 @@ export function categoryForKind(kind) {
|
|
|
21
25
|
return "sched";
|
|
22
26
|
}
|
|
23
27
|
}
|
|
28
|
+
/** The kernel's pressure actions that name a session-level compression action; any other
|
|
29
|
+
* action (e.g. `none`) is omitted from the event. Shared rule across all four SDKs. */
|
|
30
|
+
export function canonicalCompressionAction(action) {
|
|
31
|
+
return action === "snip_compact" || action === "micro_compact" || action === "context_collapse" || action === "auto_compact"
|
|
32
|
+
? action
|
|
33
|
+
: undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Project one kernel observation onto its session event (null = not persisted). Pinned across
|
|
37
|
+
* SDKs by the `kernel_observation_projection` conformance fixture: an absent optional field is
|
|
38
|
+
* omitted, never written as `null`.
|
|
39
|
+
*/
|
|
24
40
|
export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
41
|
+
const event = projectKernelObservation(obs, turn, opts);
|
|
42
|
+
if (!event)
|
|
43
|
+
return null;
|
|
44
|
+
return Object.fromEntries(Object.entries(event).filter(([, value]) => value !== undefined && value !== null));
|
|
45
|
+
}
|
|
46
|
+
function projectKernelObservation(obs, turn, opts = {}) {
|
|
25
47
|
const t = obs.turn ?? turn;
|
|
26
|
-
const compressionAction = opts.compressionAction ??
|
|
48
|
+
const compressionAction = opts.compressionAction ?? canonicalCompressionAction;
|
|
27
49
|
switch (obs.kind) {
|
|
28
50
|
case "compressed": {
|
|
29
51
|
const latest = opts.latestSeq ?? -1;
|
|
@@ -47,6 +69,22 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
47
69
|
sprint: obs.sprint ?? 0,
|
|
48
70
|
handoff_ref: "",
|
|
49
71
|
};
|
|
72
|
+
case "lifecycle_report":
|
|
73
|
+
return {
|
|
74
|
+
kind: "context_lifecycle_reported",
|
|
75
|
+
turn: t,
|
|
76
|
+
knowledge_entries: obs.knowledge_entries ?? 0,
|
|
77
|
+
knowledge_referenced: obs.knowledge_referenced ?? 0,
|
|
78
|
+
regret: obs.regret ?? 0,
|
|
79
|
+
waste_tokens: obs.waste_tokens ?? 0,
|
|
80
|
+
cache_loss_tokens: obs.cache_loss_tokens ?? 0,
|
|
81
|
+
recalled: obs.recalled ?? 0,
|
|
82
|
+
recall_expanded: obs.recall_expanded ?? 0,
|
|
83
|
+
...(obs.items && obs.items.length > 0 ? { items: obs.items } : {}),
|
|
84
|
+
...(obs.history && obs.history.length > 0 ? { history: obs.history } : {}),
|
|
85
|
+
...(obs.history_items && obs.history_items.length > 0 ? { history_items: obs.history_items } : {}),
|
|
86
|
+
...(obs.history_items_omitted ? { history_items_omitted: obs.history_items_omitted } : {}),
|
|
87
|
+
};
|
|
50
88
|
case "rollbacked":
|
|
51
89
|
return {
|
|
52
90
|
kind: "rollbacked",
|
|
@@ -200,6 +238,15 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
200
238
|
name: obs.name ?? "",
|
|
201
239
|
size_bytes: obs.size_bytes ?? 0,
|
|
202
240
|
};
|
|
241
|
+
case "memory_candidate_pending":
|
|
242
|
+
// M2 · the kernel's PersistMemory effect settled as a candidate (the child-request path).
|
|
243
|
+
return {
|
|
244
|
+
kind: "memory_candidate_pending",
|
|
245
|
+
turn: t,
|
|
246
|
+
candidate_id: String(obs.candidate_id ?? ""),
|
|
247
|
+
source: "child_request",
|
|
248
|
+
name: obs.name ?? "",
|
|
249
|
+
};
|
|
203
250
|
case "memory_queried":
|
|
204
251
|
return {
|
|
205
252
|
kind: "memory_queried",
|
|
@@ -216,6 +263,21 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
216
263
|
record_id: obs.record_id ?? "",
|
|
217
264
|
error: obs.error ?? "",
|
|
218
265
|
};
|
|
266
|
+
case "memory_write_failed":
|
|
267
|
+
return {
|
|
268
|
+
kind: "memory_write_failed",
|
|
269
|
+
turn: t,
|
|
270
|
+
record_id: obs.record_id ?? "",
|
|
271
|
+
error: obs.error ?? "",
|
|
272
|
+
};
|
|
273
|
+
case "memory_query_failed":
|
|
274
|
+
return {
|
|
275
|
+
kind: "memory_query_failed",
|
|
276
|
+
turn: t,
|
|
277
|
+
scope: obs.scope ?? { tenant_id: "", namespace: "" },
|
|
278
|
+
query: obs.query ?? "",
|
|
279
|
+
error: obs.error ?? "",
|
|
280
|
+
};
|
|
219
281
|
case "workflow_batch_spawned": {
|
|
220
282
|
const nodes = obs.nodes ?? [];
|
|
221
283
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelMessage, RenderedContext, ToolCall, ToolExecutionResult, ToolSchema } from "../types.js";
|
|
2
|
-
import type { RollbackReason } from "./session-log.js";
|
|
2
|
+
import type { ContextHistoryItemRecord, ContextItemRecord, ContextOriginTally, RollbackReason } from "./session-log.js";
|
|
3
3
|
interface TaskUpdate {
|
|
4
4
|
plan?: string[];
|
|
5
5
|
currentStep?: number;
|
|
@@ -50,7 +50,6 @@ export type KernelRunnerAction = {
|
|
|
50
50
|
effectId: string;
|
|
51
51
|
context: RenderedContext;
|
|
52
52
|
tools: ToolSchema[];
|
|
53
|
-
contextEffect: Record<string, unknown>;
|
|
54
53
|
} | {
|
|
55
54
|
kind: "execute_tool";
|
|
56
55
|
effectId: string;
|
|
@@ -89,6 +88,9 @@ export type KernelRunnerAction = {
|
|
|
89
88
|
requestedK: number;
|
|
90
89
|
} | {
|
|
91
90
|
kind: "archive_page_out";
|
|
91
|
+
action?: string;
|
|
92
|
+
summary?: string;
|
|
93
|
+
tier?: "semantic" | "durable";
|
|
92
94
|
effectId: string;
|
|
93
95
|
archived: ModelMessage[];
|
|
94
96
|
handleId?: string;
|
|
@@ -126,6 +128,17 @@ export interface KernelObservation {
|
|
|
126
128
|
rho_after?: number;
|
|
127
129
|
sprint?: number;
|
|
128
130
|
summary?: string;
|
|
131
|
+
knowledge_entries?: number;
|
|
132
|
+
knowledge_referenced?: number;
|
|
133
|
+
regret?: number;
|
|
134
|
+
waste_tokens?: number;
|
|
135
|
+
cache_loss_tokens?: number;
|
|
136
|
+
recalled?: number;
|
|
137
|
+
recall_expanded?: number;
|
|
138
|
+
items?: ContextItemRecord[];
|
|
139
|
+
history?: ContextOriginTally[];
|
|
140
|
+
history_items?: ContextHistoryItemRecord[];
|
|
141
|
+
history_items_omitted?: number;
|
|
129
142
|
archived_count?: number;
|
|
130
143
|
turn?: number;
|
|
131
144
|
checkpoint_history_len?: number;
|
package/dist/runtime/runner.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { LLMProvider, ModelMessage, StreamEvent, PermissionRequestEvent, PermissionResponse, EntropySample, EntropyWatchOptions,
|
|
1
|
+
import type { LLMProvider, ModelMessage, StreamEvent, PermissionRequestEvent, PermissionResponse, EntropySample, EntropyWatchOptions, NativeContextTiers } from "../types.js";
|
|
2
2
|
import type { ToolSuspendEvent } from "./execution-plane.js";
|
|
3
|
-
import type { MemoryStore, MemoryQuery, MemoryRecord, MemoryScope } from "../memory/index.js";
|
|
3
|
+
import type { MemoryStore, MemoryQuery, MemoryRecall, MemoryRecord, MemoryScope } from "../memory/index.js";
|
|
4
|
+
import { type MemoryRuntimePolicy } from "../memory/runtime-policy.js";
|
|
5
|
+
import { type MemoryCandidateSource, type MemoryCandidateSink } from "../memory/candidate-sink.js";
|
|
4
6
|
import type { KnowledgeSource } from "../knowledge/index.js";
|
|
5
7
|
import type { SignalSource, RuntimeSignal } from "../signals/index.js";
|
|
6
8
|
import type { SessionLog, SessionEvent } from "./session-log.js";
|
|
7
9
|
import type { ExecutionPlane } from "./execution-plane.js";
|
|
8
10
|
import { type GovernancePolicy, type LivePolicyPatch } from "../governance.js";
|
|
9
11
|
import type { KernelJournal } from "./kernel-journal.js";
|
|
10
|
-
import type { AgentRunSpec, MilestonePolicy, MilestoneContract, MilestoneCheckResult, WorkflowSpec, WorkflowOutcome } from "./types/agent.js";
|
|
12
|
+
import type { AgentRunSpec, MilestonePolicy, MilestoneContract, MilestoneCheckResult, WorkflowSpec, InheritedKnowledge, WorkflowOutcome } from "./types/agent.js";
|
|
11
13
|
import { type SubAgentOrchestrator } from "./sub-agent-orchestrator.js";
|
|
12
|
-
import { type ReducerRegistry } from "./reducers.js";
|
|
13
14
|
import { type NativeOsProfile, type OsProfileId, type SignalPolicy } from "./os-profile.js";
|
|
14
15
|
import { PayloadStore } from "./payload-store.js";
|
|
15
16
|
import { type ContextPolicyOverrides } from "./context-policy.js";
|
|
@@ -111,8 +112,6 @@ export interface ToolResultHookDecision {
|
|
|
111
112
|
}
|
|
112
113
|
export interface RuntimeOptions {
|
|
113
114
|
provider: LLMProvider;
|
|
114
|
-
/** Host-owned artifact set identity captured in operation genesis. */
|
|
115
|
-
artifactSetDigest?: string;
|
|
116
115
|
/** Required for ABI operation recovery unless the SessionLog embeds one. */
|
|
117
116
|
kernelJournal?: KernelJournal;
|
|
118
117
|
/** M1/G3 intelligence routing: resolve a per-node provider from a workflow node's `modelHint`.
|
|
@@ -139,8 +138,16 @@ export interface RuntimeOptions {
|
|
|
139
138
|
}) => Promise<MemoryQuery[] | undefined> | MemoryQuery[] | undefined;
|
|
140
139
|
systemPrompt?: string;
|
|
141
140
|
initialMemory?: string[];
|
|
141
|
+
/** Plan task 3.1 · outputs of the workflow nodes this run depends on, by agent id. The kernel
|
|
142
|
+
* holds them; the model reads one with `read_result(call_id="dep:<agent_id>")`. */
|
|
143
|
+
dependencyOutputs?: Record<string, string>;
|
|
144
|
+
/** Plan task 1.1 · the parent knowledge a child run starts with, chosen by the kernel from the
|
|
145
|
+
* items' scope and the node's context inheritance. Set by the workflow driver. */
|
|
146
|
+
inheritedKnowledge?: InheritedKnowledge[];
|
|
142
147
|
/** Skill name → markdown body (WASM has no filesystem). */
|
|
143
148
|
skillContentMap?: Map<string, string>;
|
|
149
|
+
memoryRuntimePolicy?: MemoryRuntimePolicy;
|
|
150
|
+
memoryCandidateSink?: MemoryCandidateSink;
|
|
144
151
|
memoryStore?: MemoryStore;
|
|
145
152
|
/** M4: advisory callback when a recalled record crosses the promotion threshold. */
|
|
146
153
|
onPromotionSuggested?: (info: {
|
|
@@ -209,8 +216,6 @@ export interface RuntimeOptions {
|
|
|
209
216
|
onToolSuspend?: (event: ToolSuspendEvent) => Promise<unknown> | unknown;
|
|
210
217
|
onPermissionRequest?: (event: PermissionRequestEvent) => Promise<PermissionResponse | boolean> | PermissionResponse | boolean;
|
|
211
218
|
subAgentOrchestrator?: SubAgentOrchestrator;
|
|
212
|
-
/** G2: custom reducers for `NodeKind::Reduce` workflow nodes, merged over the built-ins. */
|
|
213
|
-
reducers?: ReducerRegistry;
|
|
214
219
|
milestonePolicy?: MilestonePolicy;
|
|
215
220
|
milestoneContract?: MilestoneContract;
|
|
216
221
|
onMilestoneEvaluate?: (ctx: {
|
|
@@ -269,14 +274,18 @@ export interface RuntimeOptions {
|
|
|
269
274
|
* to exactly their declared tools + meta-tools. (wasm skills come from `skillContentMap`; gating
|
|
270
275
|
* engages only once that carries per-skill tool lists.) */
|
|
271
276
|
stableCoreToolIds?: string[];
|
|
272
|
-
memoryProvider?: LLMProvider;
|
|
273
|
-
memorySummarizer?: MemorySummarizer;
|
|
274
|
-
memorySystemPrompt?: string;
|
|
275
277
|
payloadStore?: PayloadStore;
|
|
276
278
|
}
|
|
277
279
|
export type OperationCancellationReason = "user" | "deadline" | "lease_lost" | "host_shutdown";
|
|
280
|
+
/** The kernel's wire form of the tiers a provider performs natively, or nothing when it performs
|
|
281
|
+
* none — an operation that delegates nothing configures exactly as before. */
|
|
282
|
+
export declare function delegatedContextTiers(native: NativeContextTiers | undefined): {
|
|
283
|
+
tool_result_clearing?: true;
|
|
284
|
+
compaction?: true;
|
|
285
|
+
} | undefined;
|
|
278
286
|
export declare class RuntimeRunner {
|
|
279
287
|
private readonly opts;
|
|
288
|
+
private readonly memoryRuntimeGates;
|
|
280
289
|
private interrupted;
|
|
281
290
|
private cancellationReason;
|
|
282
291
|
/** #2-B-ii: aborts the in-flight provider stream on interrupt/preempt. Recreated per `execute`. */
|
|
@@ -357,9 +366,28 @@ export declare class RuntimeRunner {
|
|
|
357
366
|
* §22.13 · a host-authored memory write. The kernel decides whether it may happen: a live
|
|
358
367
|
* operation answers through `admit_memory_write` (the model's validation rule and rolling write
|
|
359
368
|
* quota); with no live operation the same kernel rule answers statelessly. Resolves `true` when
|
|
360
|
-
* the record was persisted.
|
|
369
|
+
* the record was persisted or submitted as a pending candidate.
|
|
361
370
|
*/
|
|
362
|
-
writeMemory(memory: MemoryRecord, sessionId?: string
|
|
371
|
+
writeMemory(memory: MemoryRecord, sessionId?: string, candidate?: {
|
|
372
|
+
source: MemoryCandidateSource;
|
|
373
|
+
candidateId: string;
|
|
374
|
+
}): Promise<boolean>;
|
|
375
|
+
/**
|
|
376
|
+
* M4 · a host-initiated recall (an explicit `recall`). Same path as the prefetch: the retrieval
|
|
377
|
+
* gate, the policy's `retrievalTopK`, the kernel-derived recall lifecycle, and a
|
|
378
|
+
* `memory_retrieval_result` audit.
|
|
379
|
+
*/
|
|
380
|
+
queryMemory(query: MemoryQuery, sessionId?: string): Promise<MemoryRecall[]>;
|
|
381
|
+
private persistMemoryEffectResult;
|
|
382
|
+
/** The host's side of every memory write: the store, or the candidate sink's receipt contract. */
|
|
383
|
+
private memoryWriter;
|
|
384
|
+
/** The audit fact for a sink's answer. Only an accepted candidate is a written record. */
|
|
385
|
+
private memoryCandidateEvent;
|
|
386
|
+
/** Host memory-policy gate: a path is on unless the host set its switch to `"disabled"`. */
|
|
387
|
+
private memoryPathEnabled;
|
|
388
|
+
/** M2 · whether a write path hands its writes to the candidate sink. Off unless the host set the
|
|
389
|
+
* path to `"candidate_sink"` — unlike the on/off gates, the default here is the store. */
|
|
390
|
+
private memoryPathToCandidateSink;
|
|
363
391
|
private admitMemoryWrite;
|
|
364
392
|
/** The run's memory policy as the kernel's canonical wire carries it. */
|
|
365
393
|
private kernelMemoryPolicyWire;
|
|
@@ -409,12 +437,6 @@ export declare class RuntimeRunner {
|
|
|
409
437
|
* reason (an `Error`-terminated result fails the node in-kernel, starving its dependents).
|
|
410
438
|
*/
|
|
411
439
|
private runWorkflowNode;
|
|
412
|
-
/**
|
|
413
|
-
* G2: execute a deterministic reduce node — run the named reducer (built-ins overlaid with
|
|
414
|
-
* `opts.reducers`) over its dependency outputs and return a synthetic completion. No LLM, zero
|
|
415
|
-
* tokens. An unknown reducer or a thrown reducer fails the node (`Error` → starves dependents).
|
|
416
|
-
*/
|
|
417
|
-
private runReduceNode;
|
|
418
440
|
/**
|
|
419
441
|
* W0-ABI: run a declarative workflow DAG. The kernel owns the DAG and gates every node spawn
|
|
420
442
|
* through the syscall trap; this driver runs each kernel-emitted batch of nodes in parallel,
|
|
@@ -450,13 +472,9 @@ export declare class RuntimeRunner {
|
|
|
450
472
|
*/
|
|
451
473
|
private driveWorkflow;
|
|
452
474
|
private appendObservations;
|
|
453
|
-
/**
|
|
454
|
-
*
|
|
455
|
-
|
|
456
|
-
* re-fired after each sprint renewal (renewal drops the old history INCLUDING earlier memory
|
|
457
|
-
* hits). Errs-open throughout. */
|
|
458
|
-
private prefetchMemoryIntoHistory;
|
|
459
|
-
private archiveSemanticPageOut;
|
|
475
|
+
/** The kernel's own recall for the run goal (plan task 2.1). `preQueryMemory` may rewrite it
|
|
476
|
+
* into several scoped queries; their hits are merged, one per record. */
|
|
477
|
+
private kernelRecallHits;
|
|
460
478
|
}
|
|
461
479
|
export declare function replayMessages(events: Array<{
|
|
462
480
|
seq: number;
|