@deepstrike/wasm 0.2.52 → 0.2.61
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/README.md +15 -14
- package/dist/agent-ir.d.ts +81 -0
- package/dist/agent-ir.js +115 -0
- package/dist/agent.d.ts +140 -0
- package/dist/agent.js +34 -0
- package/dist/governance.d.ts +0 -25
- package/dist/governance.js +1 -53
- package/dist/index.d.ts +23 -8
- package/dist/index.js +11 -4
- package/dist/memory/durable.d.ts +13 -0
- package/dist/memory/durable.js +42 -0
- package/dist/memory/in-memory-store.d.ts +8 -6
- package/dist/memory/in-memory-store.js +8 -2
- package/dist/memory/index.d.ts +18 -2
- package/dist/providers/anthropic.d.ts +9 -0
- package/dist/providers/anthropic.js +12 -33
- package/dist/providers/content-policy.d.ts +16 -0
- package/dist/providers/content-policy.js +39 -0
- package/dist/providers/openai.d.ts +36 -17
- package/dist/providers/openai.js +86 -46
- package/dist/providers/provider-error.d.ts +22 -0
- package/dist/providers/provider-error.js +90 -0
- package/dist/providers/request-plan.d.ts +87 -0
- package/dist/providers/request-plan.js +153 -0
- package/dist/providers/stop-reason.d.ts +5 -0
- package/dist/providers/stop-reason.js +24 -0
- package/dist/runtime/canonical-kernel-step.d.ts +2 -5
- package/dist/runtime/canonical-kernel-step.js +40 -58
- package/dist/runtime/context-policy.d.ts +10 -12
- package/dist/runtime/context-policy.js +6 -8
- package/dist/runtime/durable-content.d.ts +44 -0
- package/dist/runtime/durable-content.js +119 -0
- package/dist/runtime/execution-plane.d.ts +2 -2
- package/dist/runtime/execution-plane.js +2 -2
- package/dist/runtime/kernel-event-log.js +0 -1
- package/dist/runtime/kernel-step.d.ts +1 -2
- package/dist/runtime/kernel-step.js +1 -1
- package/dist/runtime/provider-replay.d.ts +1 -1
- package/dist/runtime/provider-replay.js +12 -20
- package/dist/runtime/runner.d.ts +22 -18
- package/dist/runtime/runner.js +115 -55
- package/dist/runtime/session-log.d.ts +8 -1
- package/dist/runtime/session-repair.d.ts +1 -1
- package/dist/runtime/session-repair.js +1 -1
- package/dist/runtime/sha256.d.ts +2 -0
- package/dist/runtime/sha256.js +38 -0
- package/dist/runtime/sub-agent-orchestrator.d.ts +1 -1
- package/dist/runtime/sub-agent-orchestrator.js +3 -3
- package/dist/runtime/types/agent.d.ts +17 -7
- package/dist/runtime/types/agent.js +30 -4
- package/dist/runtime/workflow-control-flow.d.ts +0 -4
- package/dist/runtime/workflow-control-flow.js +0 -16
- package/dist/types.d.ts +58 -5
- package/package.json +2 -2
|
@@ -36,7 +36,7 @@ export function agentRunSpecToKernel(spec) {
|
|
|
36
36
|
...(spec.loopRound.defaultAction !== undefined ? { default_action: spec.loopRound.defaultAction } : {}),
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
// Exposure baseline: `undefined` ⇒ omit the field entirely (kernel
|
|
39
|
+
// Exposure baseline: `undefined` ⇒ omit the field entirely (kernel canonical default);
|
|
40
40
|
// `[]` ⇒ send `[]` (kernel `Some([])` = the minimal surface). The unset/minimal distinction is
|
|
41
41
|
// load-bearing, so this is deliberately NOT the `length > 0` idiom `allowedToolIds` uses.
|
|
42
42
|
if (spec.exposureBaseline !== undefined)
|
|
@@ -203,6 +203,7 @@ function nodeKindToKernel(n) {
|
|
|
203
203
|
* `submit_workflow_nodes` (R3-1) so the two encodings never drift. */
|
|
204
204
|
export function workflowNodeSpecToKernel(n) {
|
|
205
205
|
const kind = nodeKindToKernel(n);
|
|
206
|
+
const schedulingFactors = schedulingFactorsToKernel(n.schedulingFactors);
|
|
206
207
|
return {
|
|
207
208
|
task: workflowTaskToKernel(n.task),
|
|
208
209
|
role: n.role,
|
|
@@ -218,16 +219,41 @@ export function workflowNodeSpecToKernel(n) {
|
|
|
218
219
|
// O3: per-node turn / wall-clock caps (additive; omitted when unset).
|
|
219
220
|
...(n.maxTurns != null ? { max_turns: n.maxTurns } : {}),
|
|
220
221
|
...(n.maxWallMs != null ? { max_wall_ms: n.maxWallMs } : {}),
|
|
222
|
+
...(schedulingFactors ? { scheduling_factors: schedulingFactors } : {}),
|
|
221
223
|
...(n.dependsOn && n.dependsOn.length ? { depends_on: n.dependsOn } : {}),
|
|
222
224
|
dep_policy: n.depPolicy ?? "all_success",
|
|
223
225
|
};
|
|
224
226
|
}
|
|
227
|
+
function schedulingFactorsToKernel(factors) {
|
|
228
|
+
if (factors === undefined)
|
|
229
|
+
return undefined;
|
|
230
|
+
const allowed = new Set(["deadlineUrgency", "processPriority", "resourcePressure", "budgetPressure"]);
|
|
231
|
+
const unknown = Object.keys(factors).filter(key => !allowed.has(key));
|
|
232
|
+
if (unknown.length > 0)
|
|
233
|
+
throw new TypeError(`unknown scheduling factor(s): ${unknown.join(", ")}`);
|
|
234
|
+
const out = {};
|
|
235
|
+
for (const [host, kernel] of Object.entries({
|
|
236
|
+
deadlineUrgency: "deadline_urgency",
|
|
237
|
+
processPriority: "process_priority",
|
|
238
|
+
resourcePressure: "resource_pressure",
|
|
239
|
+
budgetPressure: "budget_pressure",
|
|
240
|
+
})) {
|
|
241
|
+
const value = factors[host];
|
|
242
|
+
if (value !== undefined) {
|
|
243
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
244
|
+
throw new RangeError(`schedulingFactors.${host} must be a non-negative safe integer`);
|
|
245
|
+
}
|
|
246
|
+
out[kernel] = value;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return out;
|
|
250
|
+
}
|
|
225
251
|
export function workflowSpecToKernel(spec) {
|
|
226
252
|
return { nodes: spec.nodes.map(workflowNodeSpecToKernel) };
|
|
227
253
|
}
|
|
228
254
|
/** R3-1: the tool a workflow-coordinator node's agent calls to append work to the running DAG. */
|
|
229
255
|
/** Shared JSON-Schema for a workflow-node batch (a DAG). Used by both `submit_workflow_nodes`
|
|
230
|
-
* (append) and `start_workflow` (
|
|
256
|
+
* (append) and `start_workflow` (workflow authoring: author a sub-workflow), so the two tools never drift. */
|
|
231
257
|
const workflowNodesArraySchema = {
|
|
232
258
|
type: "array",
|
|
233
259
|
items: {
|
|
@@ -306,9 +332,9 @@ export const submitWorkflowNodesTool = {
|
|
|
306
332
|
required: ["nodes"],
|
|
307
333
|
}),
|
|
308
334
|
};
|
|
309
|
-
/**
|
|
335
|
+
/** workflow authoring: the tool an agent calls to author a sub-workflow — a cohesive DAG of nodes
|
|
310
336
|
* composed onto the running workflow. Lowers to the same append path as `submit_workflow_nodes`
|
|
311
|
-
* (a `WorkflowSpec` is a node batch).
|
|
337
|
+
* (a `WorkflowSpec` is a node batch). Top-level bootstrap uses (the `LoadWorkflow` syscall). */
|
|
312
338
|
export const startWorkflowTool = {
|
|
313
339
|
name: "start_workflow",
|
|
314
340
|
description: "Author and run a sub-workflow: a DAG of nodes (fan-out / classify / tournament / loop / reduce) " +
|
|
@@ -12,10 +12,6 @@ export declare function dependencyOutputsNote(inputAgentIds: string[] | undefine
|
|
|
12
12
|
export declare function classifyInstruction(labels: string[]): string;
|
|
13
13
|
/** Build a tournament judge's goal: the controller's criterion + the two candidates to compare. */
|
|
14
14
|
export declare function judgeGoal(criterion: string, leftOutput: string, rightOutput: string): string;
|
|
15
|
-
/** Extract a loop stop signal from a loop iteration's output. Returns the `loopContinue` value, or
|
|
16
|
-
* `undefined` when the agent gave no clear signal (⇒ the kernel runs the loop to `max_iters`).
|
|
17
|
-
* Accepts `{loop_continue: bool}` or, leniently, `{done: bool}` (continue = !done). */
|
|
18
|
-
export declare function extractLoopContinue(text: string): boolean | undefined;
|
|
19
15
|
/** Extract the chosen branch label from a classifier's output. Prefers `{branch: "..."}`; falls back
|
|
20
16
|
* to a bare label string that exactly matches one of the valid labels. Returns `undefined` when no
|
|
21
17
|
* recognizable choice was made (the kernel then prunes every branch — a safe "none matched"). */
|
|
@@ -45,22 +45,6 @@ export function judgeGoal(criterion, leftOutput, rightOutput) {
|
|
|
45
45
|
`criterion above.\n\n[CANDIDATE left]\n${leftOutput}\n\n[CANDIDATE right]\n${rightOutput}\n\n` +
|
|
46
46
|
`Respond with ONLY a JSON object: {"winner": "left"} or {"winner": "right"}.`);
|
|
47
47
|
}
|
|
48
|
-
/** Extract a loop stop signal from a loop iteration's output. Returns the `loopContinue` value, or
|
|
49
|
-
* `undefined` when the agent gave no clear signal (⇒ the kernel runs the loop to `max_iters`).
|
|
50
|
-
* Accepts `{loop_continue: bool}` or, leniently, `{done: bool}` (continue = !done). */
|
|
51
|
-
export function extractLoopContinue(text) {
|
|
52
|
-
const v = extractJsonValue(text);
|
|
53
|
-
if (v && typeof v === "object" && !Array.isArray(v)) {
|
|
54
|
-
const o = v;
|
|
55
|
-
if (typeof o.loop_continue === "boolean")
|
|
56
|
-
return o.loop_continue;
|
|
57
|
-
if (typeof o.loopContinue === "boolean")
|
|
58
|
-
return o.loopContinue;
|
|
59
|
-
if (typeof o.done === "boolean")
|
|
60
|
-
return !o.done;
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
48
|
/** Extract the chosen branch label from a classifier's output. Prefers `{branch: "..."}`; falls back
|
|
65
49
|
* to a bare label string that exactly matches one of the valid labels. Returns `undefined` when no
|
|
66
50
|
* recognizable choice was made (the kernel then prunes every branch — a safe "none matched"). */
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,34 @@ export interface ContentPart {
|
|
|
14
14
|
output?: string;
|
|
15
15
|
isError?: boolean;
|
|
16
16
|
}
|
|
17
|
+
export type MediaSource = {
|
|
18
|
+
kind: "url";
|
|
19
|
+
url: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "base64";
|
|
22
|
+
data: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "fileId";
|
|
25
|
+
id: string;
|
|
26
|
+
affinity?: {
|
|
27
|
+
providerId: string;
|
|
28
|
+
endpointId: string;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
kind: "object";
|
|
32
|
+
handle: string;
|
|
33
|
+
owner?: string;
|
|
34
|
+
payloadRef?: string;
|
|
35
|
+
};
|
|
36
|
+
export type ToolOutputBlock = {
|
|
37
|
+
type: "text";
|
|
38
|
+
text: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "image" | "audio" | "video" | "file";
|
|
41
|
+
source: MediaSource;
|
|
42
|
+
mediaType?: string;
|
|
43
|
+
providerOptions?: Record<string, unknown>;
|
|
44
|
+
};
|
|
17
45
|
export interface Message {
|
|
18
46
|
role: "system" | "user" | "assistant" | "tool";
|
|
19
47
|
content: string;
|
|
@@ -36,6 +64,7 @@ export interface ToolResult {
|
|
|
36
64
|
isFatal?: boolean;
|
|
37
65
|
errorKind?: ToolErrorKind;
|
|
38
66
|
tokenCount?: number;
|
|
67
|
+
contentParts?: ToolOutputBlock[];
|
|
39
68
|
}
|
|
40
69
|
export interface ToolSchema {
|
|
41
70
|
name: string;
|
|
@@ -100,6 +129,7 @@ export interface ToolResultEvent extends StreamEvent {
|
|
|
100
129
|
isError: boolean;
|
|
101
130
|
isFatal?: boolean;
|
|
102
131
|
errorKind?: ToolErrorKind;
|
|
132
|
+
contentParts?: ToolOutputBlock[];
|
|
103
133
|
}
|
|
104
134
|
/** R3-1: a workflow node's agent called `submit_workflow_nodes`; the runner surfaces the requested nodes (the workflow lives in the parent kernel) and `runWorkflow` sends them to the parent kernel. */
|
|
105
135
|
export interface WorkflowNodesSubmittedEvent extends StreamEvent {
|
|
@@ -165,7 +195,6 @@ export interface ToolArgumentRepairedEvent extends StreamEvent {
|
|
|
165
195
|
export interface EntropySample {
|
|
166
196
|
turn: number;
|
|
167
197
|
score: number;
|
|
168
|
-
scoreVersion: number;
|
|
169
198
|
rho: number;
|
|
170
199
|
repeatPressure: number;
|
|
171
200
|
failureRate: number;
|
|
@@ -219,10 +248,24 @@ export interface ProviderDescriptor {
|
|
|
219
248
|
requiresStrictPairing: boolean;
|
|
220
249
|
};
|
|
221
250
|
}
|
|
251
|
+
export type MeasurementSource = {
|
|
252
|
+
kind: "native";
|
|
253
|
+
provider: string;
|
|
254
|
+
} | {
|
|
255
|
+
kind: "local_exact";
|
|
256
|
+
tokenizer: string;
|
|
257
|
+
} | {
|
|
258
|
+
kind: "heuristic";
|
|
259
|
+
};
|
|
260
|
+
export type MeasurementConfidence = "exact" | "high_confidence" | "low_confidence";
|
|
261
|
+
export interface PromptMeasurement {
|
|
262
|
+
inputTokens: number;
|
|
263
|
+
source: MeasurementSource;
|
|
264
|
+
confidence: MeasurementConfidence;
|
|
265
|
+
}
|
|
222
266
|
export interface ProviderReplay {
|
|
223
|
-
schema_version?: 1 | 2;
|
|
224
267
|
provider?: string;
|
|
225
|
-
protocol
|
|
268
|
+
protocol: ProviderProtocol;
|
|
226
269
|
model?: string;
|
|
227
270
|
native_blocks?: Array<Record<string, unknown>>;
|
|
228
271
|
reasoning_content?: string;
|
|
@@ -237,16 +280,26 @@ export interface LLMProvider {
|
|
|
237
280
|
timeoutMs?: number;
|
|
238
281
|
};
|
|
239
282
|
descriptor?(): ProviderDescriptor;
|
|
283
|
+
requestPlanIdentity?(): {
|
|
284
|
+
providerId?: string;
|
|
285
|
+
modelId?: string;
|
|
286
|
+
endpoint?: {
|
|
287
|
+
id?: string;
|
|
288
|
+
protocol?: string;
|
|
289
|
+
baseURL?: string;
|
|
290
|
+
};
|
|
291
|
+
};
|
|
240
292
|
peekProviderReplay?(message: Pick<Message, "content" | "toolCalls">): ProviderReplay | undefined;
|
|
241
293
|
seedProviderReplay?(message: Pick<Message, "content" | "toolCalls">, replay: ProviderReplay): void;
|
|
294
|
+
countTokens?(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<PromptMeasurement>;
|
|
242
295
|
complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<Message>;
|
|
243
296
|
stream(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>, state?: ProviderRunState,
|
|
244
297
|
/** #2-B-ii: when provided, a preempt (`interrupt()`) aborts the in-flight request. SDK-client
|
|
245
298
|
* providers forward it via `{ signal }`; the runner also breaks the consume loop on abort, so
|
|
246
|
-
* providers that ignore it still stop processing immediately.
|
|
299
|
+
* providers that ignore it still stop processing immediately. */
|
|
247
300
|
signal?: AbortSignal): AsyncIterable<StreamEvent>;
|
|
248
301
|
}
|
|
249
|
-
export interface
|
|
302
|
+
export interface MemorySummarizer {
|
|
250
303
|
summarize(archived: Message[], context: {
|
|
251
304
|
action?: string;
|
|
252
305
|
}): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/wasm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.61",
|
|
4
4
|
"description": "DeepStrike WASM SDK — browser, Cloudflare Workers, Deno Deploy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"test:canonical-binding": "wasm-pack build ../crates/deepstrike-wasm --target nodejs --dev --out-dir ../../wasm/pkg-node && node tests/canonical-binding.node.cjs"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@deepstrike/wasm-kernel": "0.2.
|
|
19
|
+
"@deepstrike/wasm-kernel": "0.2.61"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/jest": "^30.0.0",
|