@deepstrike/wasm 0.2.73 → 0.2.75
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 +117 -36
- package/dist/agent.js +204 -33
- package/dist/governance.d.ts +33 -9
- package/dist/governance.js +25 -28
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -1
- package/dist/memory/authority.d.ts +30 -0
- package/dist/memory/authority.js +34 -0
- package/dist/memory/durable.d.ts +1 -1
- package/dist/memory/durable.js +2 -2
- package/dist/providers/anthropic.js +3 -2
- package/dist/providers/openai.js +2 -1
- package/dist/runtime/canonical-kernel-step.d.ts +32 -0
- package/dist/runtime/canonical-kernel-step.js +391 -141
- package/dist/runtime/execution-plane.d.ts +2 -0
- package/dist/runtime/execution-plane.js +10 -3
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/kernel-step.js +14 -3
- package/dist/runtime/mcp-transport.d.ts +43 -0
- package/dist/runtime/mcp-transport.js +58 -0
- package/dist/runtime/replay-provider.js +4 -3
- package/dist/runtime/runner.d.ts +55 -3
- package/dist/runtime/runner.js +405 -228
- package/dist/runtime/tool-arguments.d.ts +24 -0
- package/dist/runtime/tool-arguments.js +61 -0
- package/dist/runtime/types/agent.d.ts +4 -0
- package/dist/runtime/types/agent.js +6 -55
- package/dist/types.d.ts +2 -1
- package/package.json +4 -4
- package/dist/agent-ir.d.ts +0 -81
- package/dist/agent-ir.js +0 -115
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getKernel } from "../runtime/kernel.js";
|
|
2
|
+
async function ask(request) {
|
|
3
|
+
const kernel = await getKernel();
|
|
4
|
+
return JSON.parse(kernel.memoryAuthorityJson(JSON.stringify(request)));
|
|
5
|
+
}
|
|
6
|
+
/** Would the kernel admit this write? Resolves to the refusal reason, or `undefined` when admitted. */
|
|
7
|
+
export async function checkMemoryWrite(policy, name, content) {
|
|
8
|
+
const answer = await ask({
|
|
9
|
+
op: "check_write",
|
|
10
|
+
...(policy ? { policy } : {}),
|
|
11
|
+
name,
|
|
12
|
+
content_bytes: new TextEncoder().encode(content).byteLength,
|
|
13
|
+
});
|
|
14
|
+
return answer.admitted === true ? undefined : String(answer.error ?? "memory write refused");
|
|
15
|
+
}
|
|
16
|
+
/** Derive one recall's lifecycle from the counts the store reported it held. */
|
|
17
|
+
export async function deriveMemoryRecall(policy, recalledAt, hits) {
|
|
18
|
+
if (hits.length === 0)
|
|
19
|
+
return { recalls: [], promotions: [] };
|
|
20
|
+
const answer = await ask({
|
|
21
|
+
op: "derive_recall",
|
|
22
|
+
...(policy ? { policy } : {}),
|
|
23
|
+
recalled_at: Math.max(0, Math.trunc(recalledAt)),
|
|
24
|
+
recalls: hits.map(hit => ({
|
|
25
|
+
record_id: hit.record.record_id,
|
|
26
|
+
recall_count: Math.max(0, Math.trunc(hit.record.recall_count ?? 0)),
|
|
27
|
+
...(hit.record.pinned ? { pinned: true } : {}),
|
|
28
|
+
})),
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
recalls: (answer.recalls ?? []),
|
|
32
|
+
promotions: (answer.promotions ?? []),
|
|
33
|
+
};
|
|
34
|
+
}
|
package/dist/memory/durable.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import type { Memory, MemoryRecord, MemoryScope, MemorySearchOptions, MemoryStor
|
|
|
3
3
|
export declare class DurableMemory implements Memory {
|
|
4
4
|
private readonly store;
|
|
5
5
|
private readonly agentId;
|
|
6
|
-
private readonly scope;
|
|
7
6
|
readonly namespace: string;
|
|
7
|
+
readonly scope: MemoryScope;
|
|
8
8
|
constructor(store: MemoryStore, agentId: string, scope: MemoryScope);
|
|
9
9
|
search(query: string, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
|
|
10
10
|
get(recordId: string): Promise<MemoryRecord | null>;
|
package/dist/memory/durable.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
export class DurableMemory {
|
|
3
3
|
store;
|
|
4
4
|
agentId;
|
|
5
|
-
scope;
|
|
6
5
|
namespace;
|
|
6
|
+
scope;
|
|
7
7
|
constructor(store, agentId, scope) {
|
|
8
8
|
this.store = store;
|
|
9
9
|
this.agentId = agentId;
|
|
10
|
-
this.scope = scope;
|
|
11
10
|
this.namespace = scope.namespace;
|
|
11
|
+
this.scope = scope;
|
|
12
12
|
}
|
|
13
13
|
async search(query, options = {}) {
|
|
14
14
|
const request = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { requestSnapshot } from "./prepared-request.js";
|
|
2
2
|
import { assistantReplayKey, collectStreamMessage, toAnthropicMessages } from "./base.js";
|
|
3
|
+
import { malformedToolArguments, toolArgumentsText } from "../runtime/tool-arguments.js";
|
|
3
4
|
/** Anthropic accepts at most this many cache_control breakpoints per request. */
|
|
4
5
|
const MAX_CACHE_BREAKPOINTS = 4;
|
|
5
6
|
/** Rolling cache breakpoints reserved for the message history (system uses ≤2). */
|
|
@@ -317,8 +318,8 @@ export class AnthropicProvider {
|
|
|
317
318
|
args = {};
|
|
318
319
|
}
|
|
319
320
|
nativeBlocks[idx] = { ...nativeBlocks[idx], input: args };
|
|
320
|
-
finalToolCalls.push({ id: tb.id, name: tb.name, arguments:
|
|
321
|
-
yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args };
|
|
321
|
+
finalToolCalls.push({ id: tb.id, name: tb.name, arguments: toolArgumentsText(tb.argsBuf) });
|
|
322
|
+
yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args, ...malformedToolArguments(tb.argsBuf) };
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
325
|
}
|
package/dist/providers/openai.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { requestSnapshot } from "./prepared-request.js";
|
|
2
2
|
import { collectStreamMessage, toOpenAIMessages } from "./base.js";
|
|
3
|
+
import { malformedToolArguments } from "../runtime/tool-arguments.js";
|
|
3
4
|
const DEEPSEEK_REASONERS = new Set(["deepseek-reasoner", "deepseek-r1"]);
|
|
4
5
|
const MINIMAX_REASONERS = new Set(["MiniMax-M1", "minimax-m1"]);
|
|
5
6
|
// OpenAI-compatible provider — works for OpenAI, Qwen (DashScope), DeepSeek, MiniMax, Kimi
|
|
@@ -107,7 +108,7 @@ export class OpenAIProvider {
|
|
|
107
108
|
catch {
|
|
108
109
|
args = {};
|
|
109
110
|
}
|
|
110
|
-
yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args };
|
|
111
|
+
yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args, ...malformedToolArguments(tb.argsBuf) };
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
prepareRequest(context, tools, extensions, state) {
|
|
@@ -43,6 +43,12 @@ export declare class CanonicalKernelRejectedError extends Error {
|
|
|
43
43
|
readonly fault: Record<string, unknown>;
|
|
44
44
|
constructor(faultJson: string);
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Whether a run-loop failure was the kernel refusing a malformed input (`invalid_arg`) rather than
|
|
48
|
+
* any other error. Decided by the fault the kernel named, or a binding's argument-conversion
|
|
49
|
+
* status — never by searching the message text.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isInvalidInputError(error: unknown): boolean;
|
|
46
52
|
/**
|
|
47
53
|
* A record is already authoritative once the journal append returns. A later native commit failure
|
|
48
54
|
* is therefore a rebuild boundary, never an abort boundary.
|
|
@@ -68,6 +74,13 @@ export declare class CanonicalKernelHost {
|
|
|
68
74
|
readonly journal: KernelJournal;
|
|
69
75
|
readonly operationId: string;
|
|
70
76
|
constructor(kernel: CanonicalKernelInstance, journal: KernelJournal, operationId: string);
|
|
77
|
+
/**
|
|
78
|
+
* The journal holds one outbound envelope slot per operation, so two transitions of the same
|
|
79
|
+
* operation must never overlap: the second would overwrite the first's staged bytes before its
|
|
80
|
+
* append was acknowledged. Every entry point that stages or drains goes through this queue.
|
|
81
|
+
*/
|
|
82
|
+
private exclusiveTail;
|
|
83
|
+
private exclusive;
|
|
71
84
|
transition(input: CanonicalKernelInput, options?: CanonicalTransitionOptions): Promise<CanonicalTransition>;
|
|
72
85
|
/** Restore the latest installed checkpoint and its authoritative record tail in place. */
|
|
73
86
|
restore(): Promise<CanonicalRestoreCost>;
|
|
@@ -94,6 +107,10 @@ export interface CanonicalRunnerRuntimeOptions {
|
|
|
94
107
|
preview: string;
|
|
95
108
|
}>;
|
|
96
109
|
}
|
|
110
|
+
/** Positional ids for anonymous appended nodes. A known DAG size yields `wf-node{base+i}`, the same
|
|
111
|
+
* id the kernel gives the node internally; an unknown size (after a restore) yields a batch-scoped
|
|
112
|
+
* id that cannot collide with anything already declared. */
|
|
113
|
+
export type WorkflowNodeIdBase = number | string;
|
|
97
114
|
export declare function sha256(value: string): string;
|
|
98
115
|
/**
|
|
99
116
|
* Canonical operation runtime used by the WASM host.
|
|
@@ -108,9 +125,17 @@ export declare class CanonicalRunnerRuntime {
|
|
|
108
125
|
private started;
|
|
109
126
|
private turns;
|
|
110
127
|
private lastAction;
|
|
128
|
+
/** Live policy revision (§13.2): 0 at genesis, then each `live_policy_changed`. Unknown after a
|
|
129
|
+
* restore, when a patch must name the revision it expects explicitly. */
|
|
130
|
+
private policyRevision;
|
|
131
|
+
/** Kernel-minted attempt per launched task, learned from each launch acknowledgement. */
|
|
132
|
+
private readonly taskAttempts;
|
|
111
133
|
private readonly newMessages;
|
|
112
134
|
private readonly hostObservations;
|
|
113
135
|
private spawnedTasks;
|
|
136
|
+
/** Nodes in the active workflow DAG, mirrored from committed facts so anonymous appended nodes get
|
|
137
|
+
* unique positional ids. `undefined` after a restore until the next committed submission. */
|
|
138
|
+
private workflowNodeCount;
|
|
114
139
|
private readonly memoryBindingId;
|
|
115
140
|
private payloadInlineThreshold;
|
|
116
141
|
private payloadPreviewBytes;
|
|
@@ -119,6 +144,8 @@ export declare class CanonicalRunnerRuntime {
|
|
|
119
144
|
get journal(): KernelJournal;
|
|
120
145
|
turn(): number;
|
|
121
146
|
isTerminal(): boolean;
|
|
147
|
+
/** Whether the operation has a root — the precondition for any live host control command. */
|
|
148
|
+
hasStarted(): boolean;
|
|
122
149
|
recoveryContentBytes(): number;
|
|
123
150
|
preservedRefs(): string[];
|
|
124
151
|
drainNewMessages(): ModelMessage[];
|
|
@@ -129,11 +156,16 @@ export declare class CanonicalRunnerRuntime {
|
|
|
129
156
|
resumeAction(): KernelRunnerAction | null;
|
|
130
157
|
startAgent(taskValue: Record<string, unknown>, runSpecValue?: Record<string, unknown>): Promise<KernelRunnerAction | null>;
|
|
131
158
|
startWorkflow(specValue: Record<string, unknown>): Promise<KernelRunnerAction | null>;
|
|
159
|
+
private appendBase;
|
|
132
160
|
applyHostEvent(event: Record<string, unknown>): Promise<KernelRunnerAction | null>;
|
|
133
161
|
private ensureConfigured;
|
|
134
162
|
private commit;
|
|
163
|
+
/** Record what a committed transition tells the host: its observations and published effects. */
|
|
164
|
+
private absorbTransition;
|
|
135
165
|
private currentAction;
|
|
136
166
|
private pendingEffects;
|
|
167
|
+
/** One list field of the pending effect `effectId`, which must be of kind `kind`. */
|
|
168
|
+
private pendingEffectPayload;
|
|
137
169
|
private succeededEffect;
|
|
138
170
|
private failedEffect;
|
|
139
171
|
private pageOutResolution;
|