@deepstrike/wasm 0.2.68 → 0.2.70

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 (38) hide show
  1. package/dist/index.d.ts +8 -1
  2. package/dist/index.js +3 -0
  3. package/dist/providers/anthropic.d.ts +8 -5
  4. package/dist/providers/anthropic.js +12 -1
  5. package/dist/providers/base.d.ts +5 -5
  6. package/dist/providers/base.js +1 -1
  7. package/dist/providers/openai.d.ts +6 -4
  8. package/dist/providers/openai.js +28 -24
  9. package/dist/providers/prepared-request.d.ts +4 -0
  10. package/dist/providers/prepared-request.js +78 -0
  11. package/dist/providers/request-plan.d.ts +8 -1
  12. package/dist/providers/request-plan.js +4 -3
  13. package/dist/runtime/canonical-kernel-step.d.ts +4 -3
  14. package/dist/runtime/canonical-kernel-step.js +16 -7
  15. package/dist/runtime/context.d.ts +28 -0
  16. package/dist/runtime/context.js +16 -0
  17. package/dist/runtime/eval.d.ts +2 -2
  18. package/dist/runtime/evolution.d.ts +189 -0
  19. package/dist/runtime/evolution.js +25 -0
  20. package/dist/runtime/kernel-step.d.ts +8 -7
  21. package/dist/runtime/provider-replay.d.ts +2 -2
  22. package/dist/runtime/provider-replay.js +1 -1
  23. package/dist/runtime/replay-fixture.d.ts +4 -4
  24. package/dist/runtime/replay-fixture.js +2 -2
  25. package/dist/runtime/replay-provider.d.ts +3 -3
  26. package/dist/runtime/runner.d.ts +8 -6
  27. package/dist/runtime/runner.js +22 -5
  28. package/dist/runtime/session-log.d.ts +9 -4
  29. package/dist/runtime/session-log.js +1 -0
  30. package/dist/runtime/session-repair.d.ts +3 -4
  31. package/dist/runtime/session-repair.js +1 -4
  32. package/dist/runtime/sub-agent-orchestrator.js +1 -1
  33. package/dist/runtime/types/agent.d.ts +4 -4
  34. package/dist/runtime/verifiable-report.d.ts +59 -0
  35. package/dist/runtime/verifiable-report.js +64 -0
  36. package/dist/tools/index.d.ts +2 -2
  37. package/dist/types.d.ts +19 -10
  38. package/package.json +2 -2
@@ -0,0 +1,59 @@
1
+ /** Framework-facing API plus the Rust verifiable-runtime report ABI. */
2
+ export declare const VERIFIABLE_REPORT_SCHEMA: "verifiable-report/v2";
3
+ export declare const VERIFIABLE_FORK_SCHEMA: "verifiable-fork/v2";
4
+ export type VerifiableCommand = "inspect" | "verify" | "replay" | "fork";
5
+ export type CheckVerdict = "pass" | "degraded" | "fail" | "unavailable";
6
+ export type ReplayVerdict = "pass" | "fail" | "unavailable";
7
+ export type VerifiableReport = {
8
+ readonly schema: typeof VERIFIABLE_REPORT_SCHEMA;
9
+ readonly command: VerifiableCommand;
10
+ readonly operation_id: string;
11
+ readonly [key: string]: unknown;
12
+ };
13
+ export interface VerifiableEvidence {
14
+ readonly journal: ReadonlyArray<Uint8Array>;
15
+ readonly sessionLogs?: ReadonlyArray<ReadonlyArray<Uint8Array>>;
16
+ readonly checkpoints?: ReadonlyArray<Uint8Array>;
17
+ }
18
+ export interface VerifyOptions {
19
+ readonly strict?: boolean;
20
+ readonly requireComplete?: boolean;
21
+ }
22
+ export interface ReplayOptions {
23
+ readonly strict?: boolean;
24
+ readonly atStep?: number;
25
+ }
26
+ export interface VerifiableForkManifest {
27
+ schema: typeof VERIFIABLE_FORK_SCHEMA;
28
+ operation_id: string;
29
+ at_step: string;
30
+ parent_record_digest: string;
31
+ parent_input_id: string;
32
+ source_records: number;
33
+ }
34
+ export type ForkPlan = VerifiableForkManifest;
35
+ export interface VerifiableRuntimeAdapter {
36
+ inspect(operationId: string, evidence: VerifiableEvidence, strict: boolean): VerifiableReport;
37
+ verify(operationId: string, evidence: VerifiableEvidence, options: VerifyOptions): VerifiableReport;
38
+ replay(operationId: string, evidence: VerifiableEvidence, options: ReplayOptions): VerifiableReport;
39
+ prepareFork(operationId: string, evidence: VerifiableEvidence, atStep: number, strict: boolean): ForkPlan;
40
+ }
41
+ export type VerifiableOperationJson = (request: string) => string;
42
+ /** Create the SDK adapter backed by the Rust core JSON bridge. */
43
+ export declare function createVerifiableRuntimeAdapter(operationJson: VerifiableOperationJson): VerifiableRuntimeAdapter;
44
+ /** Create the adapter from the lazily loaded WASM binding. */
45
+ export declare function createNativeVerifiableRuntimeAdapter(): Promise<VerifiableRuntimeAdapter>;
46
+ /** Storage-neutral framework handle. Store access remains in the host adapter. */
47
+ export declare class VerifiableOperation {
48
+ readonly operationId: string;
49
+ readonly evidence: VerifiableEvidence;
50
+ private readonly adapter;
51
+ constructor(operationId: string, evidence: VerifiableEvidence, adapter: VerifiableRuntimeAdapter);
52
+ inspect(strict?: boolean): VerifiableReport;
53
+ verify(options?: VerifyOptions): VerifiableReport;
54
+ replay(options?: ReplayOptions): VerifiableReport;
55
+ prepareFork(atStep: number, strict?: boolean): ForkPlan;
56
+ }
57
+ export declare function assertVerifiableReportSchema(value: {
58
+ schema?: unknown;
59
+ }): void;
@@ -0,0 +1,64 @@
1
+ import { getKernel } from "./kernel.js";
2
+ /** Framework-facing API plus the Rust verifiable-runtime report ABI. */
3
+ export const VERIFIABLE_REPORT_SCHEMA = "verifiable-report/v2";
4
+ export const VERIFIABLE_FORK_SCHEMA = "verifiable-fork/v2";
5
+ /** Create the SDK adapter backed by the Rust core JSON bridge. */
6
+ export function createVerifiableRuntimeAdapter(operationJson) {
7
+ const call = (operationId, evidence, command, options = {}) => {
8
+ const result = JSON.parse(operationJson(JSON.stringify({
9
+ operation_id: operationId,
10
+ command,
11
+ evidence: {
12
+ journal: evidence.journal.map((bytes) => Array.from(bytes)),
13
+ session_logs: (evidence.sessionLogs ?? []).map((stream) => stream.map((bytes) => Array.from(bytes))),
14
+ checkpoints: (evidence.checkpoints ?? []).map((bytes) => Array.from(bytes)),
15
+ },
16
+ strict: options.strict ?? false,
17
+ require_complete: "requireComplete" in options ? options.requireComplete ?? false : false,
18
+ at_step: "atStep" in options ? options.atStep : undefined,
19
+ })));
20
+ if (command === "fork")
21
+ return result;
22
+ assertVerifiableReportSchema(result);
23
+ return result;
24
+ };
25
+ return {
26
+ inspect: (operationId, evidence, strict) => call(operationId, evidence, "inspect", { strict }),
27
+ verify: (operationId, evidence, options) => call(operationId, evidence, "verify", options),
28
+ replay: (operationId, evidence, options) => call(operationId, evidence, "replay", options),
29
+ prepareFork: (operationId, evidence, atStep, strict) => call(operationId, evidence, "fork", { atStep, strict }),
30
+ };
31
+ }
32
+ /** Create the adapter from the lazily loaded WASM binding. */
33
+ export async function createNativeVerifiableRuntimeAdapter() {
34
+ const kernel = await getKernel();
35
+ return createVerifiableRuntimeAdapter(kernel.verifiableOperationJson);
36
+ }
37
+ /** Storage-neutral framework handle. Store access remains in the host adapter. */
38
+ export class VerifiableOperation {
39
+ operationId;
40
+ evidence;
41
+ adapter;
42
+ constructor(operationId, evidence, adapter) {
43
+ this.operationId = operationId;
44
+ this.evidence = evidence;
45
+ this.adapter = adapter;
46
+ }
47
+ inspect(strict = false) {
48
+ return this.adapter.inspect(this.operationId, this.evidence, strict);
49
+ }
50
+ verify(options = {}) {
51
+ return this.adapter.verify(this.operationId, this.evidence, options);
52
+ }
53
+ replay(options = {}) {
54
+ return this.adapter.replay(this.operationId, this.evidence, options);
55
+ }
56
+ prepareFork(atStep, strict = false) {
57
+ return this.adapter.prepareFork(this.operationId, this.evidence, atStep, strict);
58
+ }
59
+ }
60
+ export function assertVerifiableReportSchema(value) {
61
+ if (value.schema !== VERIFIABLE_REPORT_SCHEMA) {
62
+ throw new Error(`unsupported verifiable report schema: ${String(value.schema)}`);
63
+ }
64
+ }
@@ -1,4 +1,4 @@
1
- import type { ToolSchema, ToolResult } from "../types.js";
1
+ import type { ToolSchema, ToolExecutionResult } from "../types.js";
2
2
  /** M3/G4: the runtime context a tool may read when executing (carries the working directory). A
3
3
  * narrow, dependency-free shape; the execution plane's `RunContext` is structurally assignable to it.
4
4
  * (WASM has no filesystem, so worktree isolation is N/A here — this keeps the tool ABI in parity
@@ -22,4 +22,4 @@ export declare function executeTools(calls: {
22
22
  id: string;
23
23
  name: string;
24
24
  arguments: string;
25
- }[], registry: Map<string, RegisteredTool>): Promise<ToolResult[]>;
25
+ }[], registry: Map<string, RegisteredTool>): Promise<ToolExecutionResult[]>;
package/dist/types.d.ts CHANGED
@@ -39,7 +39,7 @@ export type ToolOutputBlock = {
39
39
  mediaType?: string;
40
40
  providerOptions?: Record<string, unknown>;
41
41
  };
42
- export interface Message {
42
+ export interface ProviderMessage {
43
43
  role: "system" | "user" | "assistant" | "tool";
44
44
  content: string;
45
45
  toolCalls?: ToolCall[];
@@ -53,7 +53,7 @@ export interface ToolCall {
53
53
  arguments: string;
54
54
  }
55
55
  export type ToolErrorKind = "recoverable" | "fatal" | "governance_denied" | "provider_failure" | "timeout" | "user_interrupt";
56
- export interface ToolResult {
56
+ export interface ToolExecutionResult {
57
57
  callId: string;
58
58
  output: string;
59
59
  isError: boolean;
@@ -71,11 +71,11 @@ export interface RenderedContext {
71
71
  systemText: string;
72
72
  systemStable?: string;
73
73
  systemKnowledge?: string;
74
- turns: Message[];
74
+ turns: ProviderMessage[];
75
75
  /** Volatile State turn (task_state + signals), rendered after the cacheable
76
76
  * history. Absent on un-rebuilt bindings — then it's still inside turns[0]. */
77
- stateTurn?: Message;
78
- /** Message count of the frozen history prefix (compaction boundary). When set,
77
+ stateTurn?: ProviderMessage;
78
+ /** ProviderMessage count of the frozen history prefix (compaction boundary). When set,
79
79
  * Anthropic pins a deep cache breakpoint here instead of the rolling pair. */
80
80
  frozenPrefixLen?: number;
81
81
  budgetOverflow?: ContextBudgetOverflow;
@@ -283,7 +283,16 @@ export interface ProviderTransportTelemetry {
283
283
  rungs: number;
284
284
  responseId?: string;
285
285
  }
286
+ /** Frozen host request; scope distinguishes encoded body from a custom adapter input. */
287
+ export interface PreparedProviderRequest {
288
+ readonly scope: "encoded_body" | "adapter_input";
289
+ readonly request: unknown;
290
+ readonly state: unknown;
291
+ stream(signal?: AbortSignal): AsyncIterable<StreamEvent>;
292
+ countTokens?(): Promise<PromptMeasurement>;
293
+ }
286
294
  export interface LLMProvider {
295
+ prepareRequest?(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>, state?: ProviderRunState): PreparedProviderRequest;
287
296
  createRunState?(): ProviderRunState;
288
297
  runtimePolicy?(): {
289
298
  maxTurns?: number;
@@ -299,12 +308,12 @@ export interface LLMProvider {
299
308
  baseURL?: string;
300
309
  };
301
310
  };
302
- peekProviderReplay?(message: Pick<Message, "content" | "toolCalls">): ProviderReplay | undefined;
303
- seedProviderReplay?(message: Pick<Message, "content" | "toolCalls">, replay: ProviderReplay): void;
311
+ peekProviderReplay?(message: Pick<ProviderMessage, "content" | "toolCalls">): ProviderReplay | undefined;
312
+ seedProviderReplay?(message: Pick<ProviderMessage, "content" | "toolCalls">, replay: ProviderReplay): void;
304
313
  /** P4-S1 mirror: transport facts of the most recent execution (host evidence only, B7). */
305
314
  peekTransportTelemetry?(): ProviderTransportTelemetry | undefined;
306
- countTokens?(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<PromptMeasurement>;
307
- complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<Message>;
315
+ countTokens?(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>, state?: ProviderRunState): Promise<PromptMeasurement>;
316
+ complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<ProviderMessage>;
308
317
  stream(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>, state?: ProviderRunState,
309
318
  /** #2-B-ii: when provided, a preempt (`interrupt()`) aborts the in-flight request. SDK-client
310
319
  * providers forward it via `{ signal }`; the runner also breaks the consume loop on abort, so
@@ -312,7 +321,7 @@ export interface LLMProvider {
312
321
  signal?: AbortSignal): AsyncIterable<StreamEvent>;
313
322
  }
314
323
  export interface MemorySummarizer {
315
- summarize(archived: Message[], context: {
324
+ summarize(archived: ProviderMessage[], context: {
316
325
  action?: string;
317
326
  }): Promise<string>;
318
327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/wasm",
3
- "version": "0.2.68",
3
+ "version": "0.2.70",
4
4
  "description": "DeepStrike WASM SDK — browser, Cloudflare Workers, Deno Deploy",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "test:canonical-binding": "wasm-pack build ../crates/deepstrike-wasm --target nodejs --dev --out-dir ../../wasm/pkg-node && node tests/canonical-binding.node.cjs && node tests/golden-fixtures-sweep.node.cjs"
18
18
  },
19
19
  "dependencies": {
20
- "@deepstrike/wasm-kernel": "0.2.68"
20
+ "@deepstrike/wasm-kernel": "0.2.70"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/jest": "^30.0.0",