@deepstrike/wasm 0.2.50 → 0.2.52

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.
Files changed (37) hide show
  1. package/README.md +2 -1
  2. package/dist/index.d.ts +4 -3
  3. package/dist/index.js +3 -2
  4. package/dist/runtime/canonical-kernel-step.d.ts +155 -0
  5. package/dist/runtime/canonical-kernel-step.js +1523 -0
  6. package/dist/runtime/execution-plane.d.ts +0 -3
  7. package/dist/runtime/execution-plane.js +0 -25
  8. package/dist/runtime/facade.js +3 -0
  9. package/dist/runtime/index.d.ts +7 -7
  10. package/dist/runtime/index.js +4 -3
  11. package/dist/runtime/kernel-event-log.d.ts +0 -1
  12. package/dist/runtime/kernel-event-log.js +7 -13
  13. package/dist/runtime/kernel-journal.d.ts +332 -0
  14. package/dist/runtime/kernel-journal.js +681 -0
  15. package/dist/runtime/kernel-step.d.ts +34 -89
  16. package/dist/runtime/kernel-step.js +67 -167
  17. package/dist/runtime/os-snapshot.d.ts +2 -2
  18. package/dist/runtime/os-snapshot.js +2 -6
  19. package/dist/runtime/payload-store.d.ts +30 -0
  20. package/dist/runtime/payload-store.js +66 -0
  21. package/dist/runtime/runner.d.ts +27 -75
  22. package/dist/runtime/runner.js +408 -632
  23. package/dist/runtime/session-log.d.ts +24 -27
  24. package/dist/runtime/session-log.js +11 -52
  25. package/dist/runtime/session-repair.d.ts +2 -36
  26. package/dist/runtime/session-repair.js +2 -47
  27. package/dist/runtime/sub-agent-orchestrator.d.ts +2 -2
  28. package/dist/runtime/sub-agent-orchestrator.js +36 -40
  29. package/dist/runtime/types/agent.d.ts +13 -16
  30. package/dist/runtime/types/agent.js +16 -41
  31. package/package.json +4 -3
  32. package/dist/runtime/kernel-rebuild.d.ts +0 -8
  33. package/dist/runtime/kernel-rebuild.js +0 -65
  34. package/dist/runtime/kernel-transaction-log.d.ts +0 -61
  35. package/dist/runtime/kernel-transaction-log.js +0 -140
  36. package/dist/runtime/large-result-spool.d.ts +0 -57
  37. package/dist/runtime/large-result-spool.js +0 -169
@@ -6,12 +6,12 @@ import type { SignalSource, RuntimeSignal } from "../signals/index.js";
6
6
  import type { SessionLog, SessionEvent } from "./session-log.js";
7
7
  import type { ExecutionPlane } from "./execution-plane.js";
8
8
  import { type GovernancePolicy } from "../governance.js";
9
- import { type RecoveredNodeOutcome } from "./session-repair.js";
10
- import type { AgentRunSpec, SubAgentResult, MilestonePolicy, MilestoneContract, MilestoneCheckResult, WorkflowSpec, WorkflowOutcome } from "./types/agent.js";
9
+ import type { KernelJournal } from "./kernel-journal.js";
10
+ import type { AgentRunSpec, MilestonePolicy, MilestoneContract, MilestoneCheckResult, WorkflowSpec, WorkflowOutcome } from "./types/agent.js";
11
11
  import { type SubAgentOrchestrator } from "./sub-agent-orchestrator.js";
12
12
  import { type ReducerRegistry } from "./reducers.js";
13
13
  import { type NativeOsProfile, type OsProfileId, type SignalPolicy } from "./os-profile.js";
14
- import { LargeResultSpool } from "./large-result-spool.js";
14
+ import { PayloadStore } from "./payload-store.js";
15
15
  import { type ContextPolicyOverridesV1 } from "./context-policy.js";
16
16
  export interface MemoryWriteRateLimit {
17
17
  maxWrites: number;
@@ -44,11 +44,10 @@ export interface PromptBudget {
44
44
  /**
45
45
  * Long-term memory policy (`set_memory_policy`) — opt-in, kernel-enforced. `validationEnabled:
46
46
  * false` admits writes without validation, `maxContentBytes` / `maxNameLength` override the
47
- * validation limits, and `retrievalTopK` caps `query_memory` breadth. `memoryPath` /
48
- * `staleWarningDays` are carried for SDK recall I/O. Omitted fields keep the kernel defaults.
47
+ * validation limits, and `retrievalTopK` caps `query_memory` breadth. Host storage is configured
48
+ * on the `DreamStore` and never enters this contract. Omitted fields keep the kernel defaults.
49
49
  */
50
50
  export interface MemoryPolicy {
51
- memoryPath?: string;
52
51
  staleWarningDays?: number;
53
52
  retrievalTopK?: number;
54
53
  validationEnabled?: boolean;
@@ -56,19 +55,10 @@ export interface MemoryPolicy {
56
55
  maxNameLength?: number;
57
56
  }
58
57
  export interface KernelReliabilityOptions {
59
- eventReplayCapacity?: number;
60
- completedEffectReplayCapacity?: number;
61
58
  providerRecoveryAttempts?: number;
62
59
  outputRecoveryAttempts?: number;
63
- hostEffectRetryAttempts?: number;
64
- spoolThresholdBytes?: number;
65
- spoolPreviewBytes?: number;
66
- /** Max accepted ABI transactions retained for a portable KernelSnapshot rebuild. */
67
- snapshotInputLimit?: number;
68
60
  /** Max canonical JSON bytes accepted for one kernel input, 256..64MiB. */
69
61
  maxInputBytes?: number;
70
- /** Max canonical JSON bytes retained by the snapshot journal, 256..1GiB. */
71
- snapshotJournalBytesLimit?: number;
72
62
  }
73
63
  export interface ArchiveStore {
74
64
  write(sessionId: string, startSeq: number, messages: Message[]): Promise<string | undefined>;
@@ -105,6 +95,8 @@ export interface ToolResultHookDecision {
105
95
  }
106
96
  export interface RuntimeOptions {
107
97
  provider: LLMProvider;
98
+ /** Required for ABI-v3 operation recovery unless the SessionLog embeds one. */
99
+ kernelJournal?: KernelJournal;
108
100
  /** M1/G3 intelligence routing: resolve a per-node provider from a workflow node's `modelHint`.
109
101
  * Returns undefined ⇒ fall back to `provider`. Without this hook the hint is a no-op. */
110
102
  providerFor?: (modelHint: string) => LLMProvider | undefined;
@@ -195,10 +187,6 @@ export interface RuntimeOptions {
195
187
  onToolSuspend?: (event: ToolSuspendEvent) => Promise<unknown> | unknown;
196
188
  onPermissionRequest?: (event: PermissionRequestEvent) => Promise<PermissionResponse | boolean> | PermissionResponse | boolean;
197
189
  subAgentOrchestrator?: SubAgentOrchestrator;
198
- /** M5 v2.1: marks this runner as a workflow node (child of the workflow driver). A workflow node's
199
- * `start_workflow` FLATTENS to the parent kernel; a top-level run (unset) AUTO-PIVOTS — bootstraps +
200
- * drives the authored workflow in its own kernel, then resumes the reason loop with the outcome. */
201
- isWorkflowNode?: boolean;
202
190
  /** G2: custom reducers for `NodeKind::Reduce` workflow nodes, merged over the built-ins. */
203
191
  reducers?: ReducerRegistry;
204
192
  milestonePolicy?: MilestonePolicy;
@@ -265,7 +253,7 @@ export interface RuntimeOptions {
265
253
  dreamProvider?: LLMProvider;
266
254
  dreamSummarizer?: DreamSummarizer;
267
255
  dreamSystemPrompt?: string;
268
- resultSpool?: LargeResultSpool;
256
+ payloadStore?: PayloadStore;
269
257
  }
270
258
  export type OperationCancellationReason = "user" | "deadline" | "lease_lost" | "host_shutdown";
271
259
  export declare class RuntimeRunner {
@@ -277,6 +265,7 @@ export declare class RuntimeRunner {
277
265
  private pendingObservations;
278
266
  private activeKernel;
279
267
  private currentSessionId;
268
+ private fallbackPayloadStore;
280
269
  /** O2 (system-reminder channel): host-pushed notes awaiting the next turn-boundary drain. */
281
270
  private injectedSignals;
282
271
  /** Skill names whose content has already been pushed into the durable `knowledge` slot this
@@ -290,11 +279,14 @@ export declare class RuntimeRunner {
290
279
  private nextArchiveStart;
291
280
  private pendingPageOutArchives;
292
281
  private activePageOutArchive;
293
- /** M5 v2.1: sub-workflow specs a top-level agent authored via `start_workflow`, awaiting auto-drive
294
- * at the next safe point (after the tool turn resolves, kernel back in Reason). */
295
- private pendingAuthoredWorkflows;
282
+ /** Provider continuation emitted after a canonical nested workflow completes. */
296
283
  private workflowContinuation;
297
284
  constructor(opts: RuntimeOptions);
285
+ private resolveKernelJournal;
286
+ private createCanonicalRuntime;
287
+ private commitKernelApply;
288
+ private commitKernelMaybeAction;
289
+ private commitKernelAction;
298
290
  get hostOptions(): RuntimeOptions;
299
291
  interrupt(reason?: OperationCancellationReason): void;
300
292
  /** Push a contextual note into the run's signal stream (the system-reminder channel): it drains at
@@ -331,23 +323,16 @@ export declare class RuntimeRunner {
331
323
  pushKnowledge(message: Message, tokens?: number, opts?: {
332
324
  key?: string;
333
325
  pinned?: boolean;
334
- }): void;
326
+ }): Promise<void>;
327
+ private payloadStore;
335
328
  /** K1: mark a keyed knowledge entry for removal at the next compaction/renewal boundary.
336
329
  * Errs-open: an unknown key is a kernel-side no-op. */
337
- removeKnowledge(key: string): void;
330
+ removeKnowledge(key: string): Promise<void>;
338
331
  /** K3: host-driven skill deactivation — toolset re-widens at the next provider call, the
339
332
  * skill's knowledge pin drops at the next boundary. Errs-open: not-active is a no-op. */
340
- deactivateSkill(name: string): void;
333
+ deactivateSkill(name: string): Promise<void>;
341
334
  private resolveKernelSuspend;
342
- /**
343
- * O7: resolve a `read_result` meta-tool call to the full text of a previously-evicted tool
344
- * output. Resolution order: (a) the result spool committed by `large_result_spool_result`,
345
- * (b) a session-log scan for the original `tool_completed` event carrying that `call_id`.
346
- * Slices the resolved text by `[offset, offset + maxBytes)` (plain string slice — "bytes-ish").
347
- */
348
- private resolveReadResult;
349
335
  private execute;
350
- spawnSubAgent(spec: AgentRunSpec): Promise<SubAgentResult>;
351
336
  /**
352
337
  * G3: run one workflow node, enforcing its `output_schema` (if any) by instructing the agent,
353
338
  * validating its output (the supported JSON-Schema subset), and re-running once with the errors
@@ -368,44 +353,21 @@ export declare class RuntimeRunner {
368
353
  */
369
354
  /**
370
355
  * Lower the declarative governance / attention / scheduler-budget / resource-quota / memory policies
371
- * into a freshly-created kernel. Shared by `execute()` (full run) and `bootstrapWorkflowKernel()`
356
+ * into a freshly-created kernel. Shared by `execute()` (full run) and `initializeWorkflowKernel()`
372
357
  * (standalone workflow) so a DAG's node spawns are gated and quota'd exactly as a mid-run spawn.
373
- * Must run BEFORE `start_run`. No config ⇒ native-profile defaults.
358
+ * Must run before the canonical root start. No config ⇒ native-profile defaults.
374
359
  */
375
360
  private applyKernelPolicies;
376
361
  /**
377
- * Bootstrap a standalone kernel for a host-driven workflow with no active parent run — the path a
378
- * stateless handler (browser/edge worker) takes when it calls `runWorkflow(spec)` directly. Mirrors
379
- * `execute()`'s pre-run setup (policies via `applyKernelPolicies`, then `start_run`) and records a
380
- * best-effort `run_started` so the run is resumable. `runWorkflow` tears the kernel down afterward.
362
+ * Bootstrap a standalone kernel for a host-driven workflow with no active parent run. The caller
363
+ * durably records `run_started` with the same `runId` before this method can create journal state.
364
+ * `StartOperation { Workflow }` is the sole root transition; `runWorkflow` tears the kernel down.
381
365
  */
382
- private bootstrapWorkflowKernel;
366
+ private initializeWorkflowKernel;
383
367
  runWorkflow(spec: WorkflowSpec, opts?: {
384
- /** Typed recovered terminal outcomes, including control signals and output. */
385
- resumedOutcomes?: RecoveredNodeOutcome[];
386
- resumedSubmissions?: Record<string, unknown>[][];
387
- /** R3-1: original base index per submission batch (parallel to resumedSubmissions). */
388
- resumedSubmissionBases?: number[];
389
368
  /** Standalone session id when bootstrapping (no active parent run). Defaults to a fresh uuid. */
390
369
  sessionId?: string;
391
370
  }): Promise<WorkflowOutcome>;
392
- /**
393
- * M5/G1: bootstrap an **agent-authored** workflow ("the model writes its own harness"). Routes the
394
- * spec through the agent-reachable `Syscall::LoadWorkflow` (`submit_workflow`): with no workflow
395
- * active the kernel bootstraps the DAG, else it flattens onto the running one (bootstrap-or-flatten —
396
- * one kernel, one quota). The same shared driver runs the resulting batches.
397
- */
398
- bootstrapWorkflow(spec: WorkflowSpec, opts?: {
399
- submitterAgentId?: string;
400
- }): Promise<WorkflowOutcome>;
401
- /**
402
- * M5 v2.1: drive the sub-workflow(s) a top-level agent authored via `start_workflow`, at the safe
403
- * point (tool turn resolved → kernel in Reason). Each runs in THIS kernel (the kernel resumes the
404
- * reason loop on `workflow_completed`), then the outcome is injected as a user message and a fresh
405
- * `call_provider` is synthesized from the updated context (the workflow drive consumed its own
406
- * kernel actions — same re-render pattern as the reactive-compact retry path).
407
- */
408
- private driveAuthoredWorkflows;
409
371
  /**
410
372
  * #2-B-ii: while a workflow batch is in flight, poll the signal source; a Critical `InterruptNow`
411
373
  * routes through the kernel (root in `SubAgentAwait` → preempt → `AgentPreempted` + tears the
@@ -414,20 +376,10 @@ export declare class RuntimeRunner {
414
376
  */
415
377
  private monitorWorkflowPreemption;
416
378
  /**
417
- * Shared workflow driver for `runWorkflow` (host `load_workflow`) and `bootstrapWorkflow` (agent
418
- * `submit_workflow`): run each kernel-emitted batch in parallel, feed completions back (appending any
419
- * agent-submitted nodes first), and loop until the kernel reports the workflow complete.
379
+ * Shared canonical workflow driver: run each kernel-emitted batch in parallel, feed completions
380
+ * back, and loop until the kernel reports the workflow complete.
420
381
  */
421
382
  private driveWorkflow;
422
- /**
423
- * Resume a workflow from the parent session's completed nodes.
424
- * Reads the session log, extracts completed workflow node records (with their W-1 control
425
- * signals + outputs), and calls runWorkflow so the kernel skips those nodes, replays control
426
- * flow (classify prune / loop stop), and the driver re-seeds its outputs map.
427
- */
428
- resumeWorkflow(spec: WorkflowSpec, opts?: {
429
- sessionId?: string;
430
- }): Promise<WorkflowOutcome>;
431
383
  private appendObservations;
432
384
  /** I4 + K4: fetch long-term memory hits for the current goal and land them in `history` as an
433
385
  * ordinary user turn — single-use retrieval content that decays with the compression pyramid,