@deepstrike/wasm 0.2.77 → 0.2.78
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 +61 -1
- package/dist/runtime/kernel-step.d.ts +13 -2
- package/dist/runtime/os-snapshot.js +1 -0
- package/dist/runtime/runner.d.ts +40 -25
- package/dist/runtime/runner.js +196 -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 +69 -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 +2 -0
- package/dist/runtime/sub-agent-orchestrator.js +2 -0
- package/dist/runtime/types/agent.d.ts +9 -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,20 @@ 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
|
+
};
|
|
50
86
|
case "rollbacked":
|
|
51
87
|
return {
|
|
52
88
|
kind: "rollbacked",
|
|
@@ -200,6 +236,15 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
200
236
|
name: obs.name ?? "",
|
|
201
237
|
size_bytes: obs.size_bytes ?? 0,
|
|
202
238
|
};
|
|
239
|
+
case "memory_candidate_pending":
|
|
240
|
+
// M2 · the kernel's PersistMemory effect settled as a candidate (the child-request path).
|
|
241
|
+
return {
|
|
242
|
+
kind: "memory_candidate_pending",
|
|
243
|
+
turn: t,
|
|
244
|
+
candidate_id: String(obs.candidate_id ?? ""),
|
|
245
|
+
source: "child_request",
|
|
246
|
+
name: obs.name ?? "",
|
|
247
|
+
};
|
|
203
248
|
case "memory_queried":
|
|
204
249
|
return {
|
|
205
250
|
kind: "memory_queried",
|
|
@@ -216,6 +261,21 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
216
261
|
record_id: obs.record_id ?? "",
|
|
217
262
|
error: obs.error ?? "",
|
|
218
263
|
};
|
|
264
|
+
case "memory_write_failed":
|
|
265
|
+
return {
|
|
266
|
+
kind: "memory_write_failed",
|
|
267
|
+
turn: t,
|
|
268
|
+
record_id: obs.record_id ?? "",
|
|
269
|
+
error: obs.error ?? "",
|
|
270
|
+
};
|
|
271
|
+
case "memory_query_failed":
|
|
272
|
+
return {
|
|
273
|
+
kind: "memory_query_failed",
|
|
274
|
+
turn: t,
|
|
275
|
+
scope: obs.scope ?? { tenant_id: "", namespace: "" },
|
|
276
|
+
query: obs.query ?? "",
|
|
277
|
+
error: obs.error ?? "",
|
|
278
|
+
};
|
|
219
279
|
case "workflow_batch_spawned": {
|
|
220
280
|
const nodes = obs.nodes ?? [];
|
|
221
281
|
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 { 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,15 @@ 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[];
|
|
129
140
|
archived_count?: number;
|
|
130
141
|
turn?: number;
|
|
131
142
|
checkpoint_history_len?: number;
|
package/dist/runtime/runner.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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";
|
|
@@ -9,7 +11,6 @@ import { type GovernancePolicy, type LivePolicyPatch } from "../governance.js";
|
|
|
9
11
|
import type { KernelJournal } from "./kernel-journal.js";
|
|
10
12
|
import type { AgentRunSpec, MilestonePolicy, MilestoneContract, MilestoneCheckResult, WorkflowSpec, 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,13 @@ 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>;
|
|
142
144
|
/** Skill name → markdown body (WASM has no filesystem). */
|
|
143
145
|
skillContentMap?: Map<string, string>;
|
|
146
|
+
memoryRuntimePolicy?: MemoryRuntimePolicy;
|
|
147
|
+
memoryCandidateSink?: MemoryCandidateSink;
|
|
144
148
|
memoryStore?: MemoryStore;
|
|
145
149
|
/** M4: advisory callback when a recalled record crosses the promotion threshold. */
|
|
146
150
|
onPromotionSuggested?: (info: {
|
|
@@ -209,8 +213,6 @@ export interface RuntimeOptions {
|
|
|
209
213
|
onToolSuspend?: (event: ToolSuspendEvent) => Promise<unknown> | unknown;
|
|
210
214
|
onPermissionRequest?: (event: PermissionRequestEvent) => Promise<PermissionResponse | boolean> | PermissionResponse | boolean;
|
|
211
215
|
subAgentOrchestrator?: SubAgentOrchestrator;
|
|
212
|
-
/** G2: custom reducers for `NodeKind::Reduce` workflow nodes, merged over the built-ins. */
|
|
213
|
-
reducers?: ReducerRegistry;
|
|
214
216
|
milestonePolicy?: MilestonePolicy;
|
|
215
217
|
milestoneContract?: MilestoneContract;
|
|
216
218
|
onMilestoneEvaluate?: (ctx: {
|
|
@@ -269,14 +271,18 @@ export interface RuntimeOptions {
|
|
|
269
271
|
* to exactly their declared tools + meta-tools. (wasm skills come from `skillContentMap`; gating
|
|
270
272
|
* engages only once that carries per-skill tool lists.) */
|
|
271
273
|
stableCoreToolIds?: string[];
|
|
272
|
-
memoryProvider?: LLMProvider;
|
|
273
|
-
memorySummarizer?: MemorySummarizer;
|
|
274
|
-
memorySystemPrompt?: string;
|
|
275
274
|
payloadStore?: PayloadStore;
|
|
276
275
|
}
|
|
277
276
|
export type OperationCancellationReason = "user" | "deadline" | "lease_lost" | "host_shutdown";
|
|
277
|
+
/** The kernel's wire form of the tiers a provider performs natively, or nothing when it performs
|
|
278
|
+
* none — an operation that delegates nothing configures exactly as before. */
|
|
279
|
+
export declare function delegatedContextTiers(native: NativeContextTiers | undefined): {
|
|
280
|
+
tool_result_clearing?: true;
|
|
281
|
+
compaction?: true;
|
|
282
|
+
} | undefined;
|
|
278
283
|
export declare class RuntimeRunner {
|
|
279
284
|
private readonly opts;
|
|
285
|
+
private readonly memoryRuntimeGates;
|
|
280
286
|
private interrupted;
|
|
281
287
|
private cancellationReason;
|
|
282
288
|
/** #2-B-ii: aborts the in-flight provider stream on interrupt/preempt. Recreated per `execute`. */
|
|
@@ -357,9 +363,28 @@ export declare class RuntimeRunner {
|
|
|
357
363
|
* §22.13 · a host-authored memory write. The kernel decides whether it may happen: a live
|
|
358
364
|
* operation answers through `admit_memory_write` (the model's validation rule and rolling write
|
|
359
365
|
* quota); with no live operation the same kernel rule answers statelessly. Resolves `true` when
|
|
360
|
-
* the record was persisted.
|
|
366
|
+
* the record was persisted or submitted as a pending candidate.
|
|
361
367
|
*/
|
|
362
|
-
writeMemory(memory: MemoryRecord, sessionId?: string
|
|
368
|
+
writeMemory(memory: MemoryRecord, sessionId?: string, candidate?: {
|
|
369
|
+
source: MemoryCandidateSource;
|
|
370
|
+
candidateId: string;
|
|
371
|
+
}): Promise<boolean>;
|
|
372
|
+
/**
|
|
373
|
+
* M4 · a host-initiated recall (an explicit `recall`). Same path as the prefetch: the retrieval
|
|
374
|
+
* gate, the policy's `retrievalTopK`, the kernel-derived recall lifecycle, and a
|
|
375
|
+
* `memory_retrieval_result` audit.
|
|
376
|
+
*/
|
|
377
|
+
queryMemory(query: MemoryQuery, sessionId?: string): Promise<MemoryRecall[]>;
|
|
378
|
+
private persistMemoryEffectResult;
|
|
379
|
+
/** The host's side of every memory write: the store, or the candidate sink's receipt contract. */
|
|
380
|
+
private memoryWriter;
|
|
381
|
+
/** The audit fact for a sink's answer. Only an accepted candidate is a written record. */
|
|
382
|
+
private memoryCandidateEvent;
|
|
383
|
+
/** Host memory-policy gate: a path is on unless the host set its switch to `"disabled"`. */
|
|
384
|
+
private memoryPathEnabled;
|
|
385
|
+
/** M2 · whether a write path hands its writes to the candidate sink. Off unless the host set the
|
|
386
|
+
* path to `"candidate_sink"` — unlike the on/off gates, the default here is the store. */
|
|
387
|
+
private memoryPathToCandidateSink;
|
|
363
388
|
private admitMemoryWrite;
|
|
364
389
|
/** The run's memory policy as the kernel's canonical wire carries it. */
|
|
365
390
|
private kernelMemoryPolicyWire;
|
|
@@ -409,12 +434,6 @@ export declare class RuntimeRunner {
|
|
|
409
434
|
* reason (an `Error`-terminated result fails the node in-kernel, starving its dependents).
|
|
410
435
|
*/
|
|
411
436
|
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
437
|
/**
|
|
419
438
|
* W0-ABI: run a declarative workflow DAG. The kernel owns the DAG and gates every node spawn
|
|
420
439
|
* through the syscall trap; this driver runs each kernel-emitted batch of nodes in parallel,
|
|
@@ -450,13 +469,9 @@ export declare class RuntimeRunner {
|
|
|
450
469
|
*/
|
|
451
470
|
private driveWorkflow;
|
|
452
471
|
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;
|
|
472
|
+
/** The kernel's own recall for the run goal (plan task 2.1). `preQueryMemory` may rewrite it
|
|
473
|
+
* into several scoped queries; their hits are merged, one per record. */
|
|
474
|
+
private kernelRecallHits;
|
|
460
475
|
}
|
|
461
476
|
export declare function replayMessages(events: Array<{
|
|
462
477
|
seq: number;
|