@deepstrike/wasm 0.2.76 → 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
|
@@ -1,59 +0,0 @@
|
|
|
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;
|
|
@@ -1,64 +0,0 @@
|
|
|
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,21 +0,0 @@
|
|
|
1
|
-
/** Instruction appended to a loop iteration's goal. DW-3: the continuation verb is the
|
|
2
|
-
* kernel-adjudicated `pace` meta-tool (armed on every iteration run), not a text blob — one
|
|
3
|
-
* vocabulary shared with the round-level loop agent. Iterations share one session, so "the work
|
|
4
|
-
* so far" is simply the visible transcript. */
|
|
5
|
-
export declare function loopInstruction(maxIters: number, iteration?: number): string;
|
|
6
|
-
/** W-N2: dependency outputs appended to a dependent node's goal — a DAG edge carries data, not
|
|
7
|
-
* just ordering (fan-out→synthesize was an uninformed synthesis without this). Each dependency's
|
|
8
|
-
* output is clipped so a chain of large nodes can't blow the child's context; empty/unknown
|
|
9
|
-
* outputs are skipped. Returns "" when the node has no dependencies. */
|
|
10
|
-
export declare function dependencyOutputsNote(inputAgentIds: string[] | undefined, outputs: Map<string, string> | undefined, maxPerDep?: number): string;
|
|
11
|
-
/** Instruction appended to a classify node's goal: pick exactly one of the kernel's branch labels. */
|
|
12
|
-
export declare function classifyInstruction(labels: string[]): string;
|
|
13
|
-
/** Build a tournament judge's goal: the controller's criterion + the two candidates to compare. */
|
|
14
|
-
export declare function judgeGoal(criterion: string, leftOutput: string, rightOutput: string): string;
|
|
15
|
-
/** Extract the chosen branch label from a classifier's output. Prefers `{branch: "..."}`; falls back
|
|
16
|
-
* to a bare label string that exactly matches one of the valid labels. Returns `undefined` when no
|
|
17
|
-
* recognizable choice was made (the kernel then prunes every branch — a safe "none matched"). */
|
|
18
|
-
export declare function extractClassifyBranch(text: string, labels: string[]): string | undefined;
|
|
19
|
-
/** Extract a tournament judge's verdict ("left" or "right"). Defaults to "left" when the verdict is
|
|
20
|
-
* unparseable, so the bracket always advances to a champion rather than stalling with no winner. */
|
|
21
|
-
export declare function extractJudgeWinner(text: string): "left" | "right";
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
//! A#2: SDK-side execution of the kernel's control-flow workflow node kinds (Loop / Classify /
|
|
2
|
-
//! Tournament). The kernel owns the scheduling — it re-arms loops, prunes classify branches, and
|
|
3
|
-
//! runs the tournament bracket — and tells the SDK *which* kind a spawn is via the spawn descriptor
|
|
4
|
-
//! (`loop_max_iters` / `classify_labels` / `judge_match`). This module is the SDK half of the "one
|
|
5
|
-
//! agent per node + one additive result field" contract: it builds the prompt that solicits the
|
|
6
|
-
//! decision from the node's agent and extracts the matching result signal (`loopContinue` /
|
|
7
|
-
//! `classifyBranch` / `tournamentWinner`) the kernel reads back.
|
|
8
|
-
import { extractJsonValue } from "./output-schema.js";
|
|
9
|
-
/** Instruction appended to a loop iteration's goal. DW-3: the continuation verb is the
|
|
10
|
-
* kernel-adjudicated `pace` meta-tool (armed on every iteration run), not a text blob — one
|
|
11
|
-
* vocabulary shared with the round-level loop agent. Iterations share one session, so "the work
|
|
12
|
-
* so far" is simply the visible transcript. */
|
|
13
|
-
export function loopInstruction(maxIters, iteration = 0) {
|
|
14
|
-
return (`This task runs as a LOOP — this is iteration ${iteration + 1} of up to ${maxIters}. Your prior ` +
|
|
15
|
-
`iterations' work (if any) is visible above; do the NEXT increment now. Then call the \`pace\` tool: ` +
|
|
16
|
-
`\`{"next": "continue"}\` to request another iteration, or \`{"next": "stop"}\` when the overall ` +
|
|
17
|
-
`task is complete. Ending without calling \`pace\` also completes the loop.`);
|
|
18
|
-
}
|
|
19
|
-
/** W-N2: dependency outputs appended to a dependent node's goal — a DAG edge carries data, not
|
|
20
|
-
* just ordering (fan-out→synthesize was an uninformed synthesis without this). Each dependency's
|
|
21
|
-
* output is clipped so a chain of large nodes can't blow the child's context; empty/unknown
|
|
22
|
-
* outputs are skipped. Returns "" when the node has no dependencies. */
|
|
23
|
-
export function dependencyOutputsNote(inputAgentIds, outputs, maxPerDep = 8_000) {
|
|
24
|
-
if (!inputAgentIds?.length || !outputs)
|
|
25
|
-
return "";
|
|
26
|
-
const blocks = inputAgentIds
|
|
27
|
-
.map(id => {
|
|
28
|
-
const out = outputs.get(id) ?? "";
|
|
29
|
-
if (!out)
|
|
30
|
-
return "";
|
|
31
|
-
const clipped = out.length > maxPerDep ? `${out.slice(0, maxPerDep)}\n…[truncated]` : out;
|
|
32
|
-
return `[dependency ${id} output]\n${clipped}`;
|
|
33
|
-
})
|
|
34
|
-
.filter(Boolean);
|
|
35
|
-
return blocks.join("\n\n");
|
|
36
|
-
}
|
|
37
|
-
/** Instruction appended to a classify node's goal: pick exactly one of the kernel's branch labels. */
|
|
38
|
-
export function classifyInstruction(labels) {
|
|
39
|
-
return (`Classify the input and choose EXACTLY ONE label from: ${labels.map(l => JSON.stringify(l)).join(", ")}. ` +
|
|
40
|
-
`Respond with ONLY a JSON object: {"branch": "<one of the labels>"}.`);
|
|
41
|
-
}
|
|
42
|
-
/** Build a tournament judge's goal: the controller's criterion + the two candidates to compare. */
|
|
43
|
-
export function judgeGoal(criterion, leftOutput, rightOutput) {
|
|
44
|
-
return (`${criterion}\n\nCompare the two candidate outputs below and decide which one better satisfies the ` +
|
|
45
|
-
`criterion above.\n\n[CANDIDATE left]\n${leftOutput}\n\n[CANDIDATE right]\n${rightOutput}\n\n` +
|
|
46
|
-
`Respond with ONLY a JSON object: {"winner": "left"} or {"winner": "right"}.`);
|
|
47
|
-
}
|
|
48
|
-
/** Extract the chosen branch label from a classifier's output. Prefers `{branch: "..."}`; falls back
|
|
49
|
-
* to a bare label string that exactly matches one of the valid labels. Returns `undefined` when no
|
|
50
|
-
* recognizable choice was made (the kernel then prunes every branch — a safe "none matched"). */
|
|
51
|
-
export function extractClassifyBranch(text, labels) {
|
|
52
|
-
const v = extractJsonValue(text);
|
|
53
|
-
if (v && typeof v === "object" && !Array.isArray(v)) {
|
|
54
|
-
const o = v;
|
|
55
|
-
if (typeof o.branch === "string")
|
|
56
|
-
return o.branch;
|
|
57
|
-
if (typeof o.label === "string")
|
|
58
|
-
return o.label;
|
|
59
|
-
}
|
|
60
|
-
if (typeof v === "string" && labels.includes(v))
|
|
61
|
-
return v;
|
|
62
|
-
const trimmed = (text ?? "").trim();
|
|
63
|
-
if (labels.includes(trimmed))
|
|
64
|
-
return trimmed;
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
/** Extract a tournament judge's verdict ("left" or "right"). Defaults to "left" when the verdict is
|
|
68
|
-
* unparseable, so the bracket always advances to a champion rather than stalling with no winner. */
|
|
69
|
-
export function extractJudgeWinner(text) {
|
|
70
|
-
const v = extractJsonValue(text);
|
|
71
|
-
if (v && typeof v === "object" && !Array.isArray(v)) {
|
|
72
|
-
const w = v.winner;
|
|
73
|
-
if (w === "right")
|
|
74
|
-
return "right";
|
|
75
|
-
if (w === "left")
|
|
76
|
-
return "left";
|
|
77
|
-
}
|
|
78
|
-
const lowered = (text ?? "").toLowerCase();
|
|
79
|
-
// Last resort: a bare mention. Bias to "left" on ambiguity (both/neither mentioned).
|
|
80
|
-
if (lowered.includes("right") && !lowered.includes("left"))
|
|
81
|
-
return "right";
|
|
82
|
-
return "left";
|
|
83
|
-
}
|