@deepstrike/wasm 0.2.28 → 0.2.31
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/facade.d.ts +35 -0
- package/dist/runtime/facade.js +41 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/runner.js +20 -32
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RuntimeRunner, collectText, InMemorySessionLog, LocalExecutionPlane, DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, ReplayProvider, extractRecordedMessages, judge, buildEvalMessages, parseVerdict, verdictOutputSchema, } from "./runtime/index.js";
|
|
1
|
+
export { RuntimeRunner, collectText, runAgent, runFanout, InMemorySessionLog, LocalExecutionPlane, DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, ReplayProvider, extractRecordedMessages, judge, buildEvalMessages, parseVerdict, verdictOutputSchema, } from "./runtime/index.js";
|
|
2
2
|
export type { ReplayProviderOpts, Criterion, Verdict, VerdictDetail, JudgeArgs, } from "./runtime/index.js";
|
|
3
3
|
export type { NativeOsProfile, OsProfileId, MemoryPolicy, MemoryWriteRateLimit, ResourceQuota, RuntimeOptions, SchedulerBudget, SessionEvent, SessionLog, RunContext, ExecutionPlane, } from "./runtime/index.js";
|
|
4
4
|
export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RuntimeRunner, collectText, InMemorySessionLog, LocalExecutionPlane, DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, ReplayProvider, extractRecordedMessages, judge, buildEvalMessages, parseVerdict, verdictOutputSchema, } from "./runtime/index.js";
|
|
1
|
+
export { RuntimeRunner, collectText, runAgent, runFanout, InMemorySessionLog, LocalExecutionPlane, DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, ReplayProvider, extractRecordedMessages, judge, buildEvalMessages, parseVerdict, verdictOutputSchema, } from "./runtime/index.js";
|
|
2
2
|
export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
|
3
3
|
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
|
|
4
4
|
export { workflowSpecToKernel, workflowNodeSpecToKernel, submitWorkflowNodesToKernel, submitWorkflowToKernel, submitWorkflowNodesTool, startWorkflowTool, fanoutSynthesize, generateAndFilter, verifyRules } from "./runtime/types/agent.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ExecutionPlane } from "./execution-plane.js";
|
|
2
|
+
import type { SessionLog } from "./session-log.js";
|
|
3
|
+
import type { LLMProvider } from "../types.js";
|
|
4
|
+
import type { RegisteredTool } from "../tools/index.js";
|
|
5
|
+
import type { WorkflowTaskSpec, KernelAgentRole } from "./types/agent.js";
|
|
6
|
+
export interface RunAgentOptions {
|
|
7
|
+
provider: LLMProvider;
|
|
8
|
+
goal: string;
|
|
9
|
+
systemPrompt?: string;
|
|
10
|
+
tools?: RegisteredTool[];
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
maxTurns?: number;
|
|
14
|
+
sessionLog?: SessionLog;
|
|
15
|
+
executionPlane?: ExecutionPlane;
|
|
16
|
+
}
|
|
17
|
+
/** Run a single agent to completion and return its final text. */
|
|
18
|
+
export declare function runAgent(opts: RunAgentOptions): Promise<string>;
|
|
19
|
+
export interface RunFanoutOptions {
|
|
20
|
+
provider: LLMProvider;
|
|
21
|
+
tasks: WorkflowTaskSpec[];
|
|
22
|
+
synthesize: string;
|
|
23
|
+
workerRole?: KernelAgentRole;
|
|
24
|
+
synthesisRole?: KernelAgentRole;
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
maxTokens?: number;
|
|
27
|
+
maxTurns?: number;
|
|
28
|
+
sessionLog?: SessionLog;
|
|
29
|
+
executionPlane?: ExecutionPlane;
|
|
30
|
+
}
|
|
31
|
+
/** Parallel fan-out → synthesize over the kernel-gated DAG (standalone runWorkflow). */
|
|
32
|
+
export declare function runFanout(opts: RunFanoutOptions): Promise<{
|
|
33
|
+
synthesis: string;
|
|
34
|
+
outputs: Record<string, string>;
|
|
35
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// High-level facades (parity with the Node SDK's runAgent/runFanout) so the common cases don't require
|
|
2
|
+
// assembling RuntimeRunner + session log + execution plane + collectText by hand. Browser/edge-friendly.
|
|
3
|
+
import { RuntimeRunner, collectText } from "./runner.js";
|
|
4
|
+
import { LocalExecutionPlane } from "./execution-plane.js";
|
|
5
|
+
import { InMemorySessionLog } from "./session-log.js";
|
|
6
|
+
/** Run a single agent to completion and return its final text. */
|
|
7
|
+
export async function runAgent(opts) {
|
|
8
|
+
const plane = opts.executionPlane ??
|
|
9
|
+
(opts.tools ?? []).reduce((p, t) => p.register(t), new LocalExecutionPlane());
|
|
10
|
+
const runner = new RuntimeRunner({
|
|
11
|
+
provider: opts.provider,
|
|
12
|
+
executionPlane: plane,
|
|
13
|
+
sessionLog: opts.sessionLog ?? new InMemorySessionLog(),
|
|
14
|
+
maxTokens: opts.maxTokens ?? 32_000,
|
|
15
|
+
...(opts.maxTurns !== undefined ? { maxTurns: opts.maxTurns } : {}),
|
|
16
|
+
...(opts.systemPrompt !== undefined ? { systemPrompt: opts.systemPrompt } : {}),
|
|
17
|
+
});
|
|
18
|
+
return collectText(runner.run({ sessionId: opts.sessionId ?? `agent-${crypto.randomUUID()}`, goal: opts.goal }));
|
|
19
|
+
}
|
|
20
|
+
/** Parallel fan-out → synthesize over the kernel-gated DAG (standalone runWorkflow). */
|
|
21
|
+
export async function runFanout(opts) {
|
|
22
|
+
const runner = new RuntimeRunner({
|
|
23
|
+
provider: opts.provider,
|
|
24
|
+
executionPlane: opts.executionPlane ?? new LocalExecutionPlane(),
|
|
25
|
+
sessionLog: opts.sessionLog ?? new InMemorySessionLog(),
|
|
26
|
+
maxTokens: opts.maxTokens ?? 32_000,
|
|
27
|
+
...(opts.maxTurns !== undefined ? { maxTurns: opts.maxTurns } : {}),
|
|
28
|
+
});
|
|
29
|
+
const workerRole = opts.workerRole ?? "explore";
|
|
30
|
+
const spec = {
|
|
31
|
+
nodes: [
|
|
32
|
+
...opts.tasks.map(task => ({ task, role: workerRole })),
|
|
33
|
+
{ task: opts.synthesize, role: opts.synthesisRole ?? "plan", dependsOn: opts.tasks.map((_, i) => i) },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
const outcome = await runner.runWorkflow(spec, opts.sessionId ? { sessionId: opts.sessionId } : undefined);
|
|
37
|
+
const synthesisId = `wf-node${opts.tasks.length}`;
|
|
38
|
+
const lastCompleted = outcome.completed[outcome.completed.length - 1];
|
|
39
|
+
const synthesis = outcome.outputs[synthesisId] ?? (lastCompleted ? outcome.outputs[lastCompleted] : undefined) ?? "";
|
|
40
|
+
return { synthesis, outputs: outcome.outputs };
|
|
41
|
+
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type { RunContext, ExecutionPlane } from "./execution-plane.js";
|
|
|
4
4
|
export { LocalExecutionPlane } from "./execution-plane.js";
|
|
5
5
|
export type { MemoryPolicy, MemoryWriteRateLimit, ResourceQuota, RuntimeOptions, SchedulerBudget } from "./runner.js";
|
|
6
6
|
export { RuntimeRunner, collectText } from "./runner.js";
|
|
7
|
+
export { runAgent, runFanout } from "./facade.js";
|
|
8
|
+
export type { RunAgentOptions, RunFanoutOptions } from "./facade.js";
|
|
7
9
|
export { builtinReducers, resolveReducer } from "./reducers.js";
|
|
8
10
|
export type { Reducer, ReducerRegistry, ReducerInput } from "./reducers.js";
|
|
9
11
|
export { getKernel } from "./kernel.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { InMemorySessionLog } from "./session-log.js";
|
|
2
2
|
export { LocalExecutionPlane } from "./execution-plane.js";
|
|
3
3
|
export { RuntimeRunner, collectText } from "./runner.js";
|
|
4
|
+
export { runAgent, runFanout } from "./facade.js";
|
|
4
5
|
export { builtinReducers, resolveReducer } from "./reducers.js";
|
|
5
6
|
export { getKernel } from "./kernel.js";
|
|
6
7
|
export { ReplayProvider } from "./replay-provider.js";
|
package/dist/runtime/runner.js
CHANGED
|
@@ -968,41 +968,27 @@ export class RuntimeRunner {
|
|
|
968
968
|
const osProfile = assertNativeProfile(this.opts.osProfile ?? "native");
|
|
969
969
|
const attentionPolicy = this.opts.attentionPolicy ?? osProfile.attentionPolicy;
|
|
970
970
|
const governancePolicy = this.opts.governancePolicy ?? osProfile.governancePolicy;
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
}
|
|
978
|
-
if (this.opts.schedulerBudget) {
|
|
979
|
-
|
|
980
|
-
kind: "set_scheduler_budget",
|
|
981
|
-
...(this.opts.schedulerBudget.maxWallMs !== undefined
|
|
982
|
-
? { max_wall_ms: this.opts.schedulerBudget.maxWallMs }
|
|
983
|
-
: {}),
|
|
984
|
-
});
|
|
971
|
+
// K2: lower governance / attention / scheduler / quota in ONE `configure_run` event (the 0.2.30
|
|
972
|
+
// core applies each present field via its granular path). `set_memory_policy` stays separate below.
|
|
973
|
+
const { kind: _govKind, ...governance } = governancePolicyToKernelEvent(governancePolicy);
|
|
974
|
+
const config = { governance };
|
|
975
|
+
if (attentionPolicy.maxQueueSize !== undefined) {
|
|
976
|
+
config.attention_max_queue_size = attentionPolicy.maxQueueSize;
|
|
977
|
+
}
|
|
978
|
+
if (this.opts.schedulerBudget?.maxWallMs !== undefined) {
|
|
979
|
+
config.scheduler_max_wall_ms = this.opts.schedulerBudget.maxWallMs;
|
|
985
980
|
}
|
|
986
981
|
if (this.opts.resourceQuota) {
|
|
987
982
|
const q = this.opts.resourceQuota;
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
...(q.memoryWritesPerWindow !== undefined
|
|
996
|
-
? {
|
|
997
|
-
memory_writes_per_window: [
|
|
998
|
-
q.memoryWritesPerWindow.maxWrites,
|
|
999
|
-
q.memoryWritesPerWindow.windowMs,
|
|
1000
|
-
],
|
|
1001
|
-
}
|
|
1002
|
-
: {}),
|
|
1003
|
-
},
|
|
1004
|
-
});
|
|
983
|
+
config.resource_quota = {
|
|
984
|
+
...(q.maxConcurrentSubagents !== undefined ? { max_concurrent_subagents: q.maxConcurrentSubagents } : {}),
|
|
985
|
+
...(q.maxSpawnDepth !== undefined ? { max_spawn_depth: q.maxSpawnDepth } : {}),
|
|
986
|
+
...(q.memoryWritesPerWindow !== undefined
|
|
987
|
+
? { memory_writes_per_window: [q.memoryWritesPerWindow.maxWrites, q.memoryWritesPerWindow.windowMs] }
|
|
988
|
+
: {}),
|
|
989
|
+
};
|
|
1005
990
|
}
|
|
991
|
+
kernelApply(runtime, this.pendingObservations, { kind: "configure_run", config });
|
|
1006
992
|
if (this.opts.memoryPolicy) {
|
|
1007
993
|
const m = this.opts.memoryPolicy;
|
|
1008
994
|
kernelApply(runtime, this.pendingObservations, {
|
|
@@ -1044,7 +1030,9 @@ export class RuntimeRunner {
|
|
|
1044
1030
|
...(this.opts.agentId ? { agent_id: this.opts.agentId } : {}),
|
|
1045
1031
|
})).catch(() => { });
|
|
1046
1032
|
this.applyKernelPolicies(runtime);
|
|
1047
|
-
|
|
1033
|
+
// K1: no explicit `start_run` — the host `load_workflow` (fired next by `runWorkflow`) self-bootstraps
|
|
1034
|
+
// the run on the 0.2.30 core, matching the agent-reachable `submit_workflow` path.
|
|
1035
|
+
void goal;
|
|
1048
1036
|
return runtime;
|
|
1049
1037
|
}
|
|
1050
1038
|
async runWorkflow(spec, opts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/wasm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"description": "DeepStrike WASM SDK — browser, Cloudflare Workers, Deno Deploy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"test": "node --experimental-vm-modules node_modules/.bin/jest"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@deepstrike/wasm-kernel": "0.2.
|
|
18
|
+
"@deepstrike/wasm-kernel": "0.2.31"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/jest": "^30.0.0",
|