@deepstrike/sdk 0.1.15 → 0.2.0
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/collaboration/harness.d.ts +4 -1
- package/dist/collaboration/harness.js +20 -6
- package/dist/collaboration/modes/creator-verifier.d.ts +8 -2
- package/dist/collaboration/modes/creator-verifier.js +9 -3
- package/dist/collaboration/pool.d.ts +24 -3
- package/dist/collaboration/pool.js +65 -5
- package/dist/harness/harness.d.ts +5 -1
- package/dist/harness/harness.js +23 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +5 -0
- package/dist/kernel.d.ts +12 -43
- package/dist/kernel.js +1 -1
- package/dist/providers/anthropic.js +7 -2
- package/dist/providers/base.d.ts +12 -0
- package/dist/providers/base.js +75 -0
- package/dist/providers/catalog.d.ts +3 -2
- package/dist/providers/catalog.js +61 -13
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/gemini.d.ts +3 -0
- package/dist/providers/gemini.js +26 -6
- package/dist/providers/glm.d.ts +9 -0
- package/dist/providers/glm.js +21 -0
- package/dist/providers/kimi.js +2 -0
- package/dist/providers/minimax.js +5 -0
- package/dist/providers/openai-responses.js +9 -0
- package/dist/providers/openai.js +52 -6
- package/dist/providers/profiles.d.ts +1304 -242
- package/dist/providers/profiles.js +429 -26
- package/dist/providers/qwen.d.ts +3 -1
- package/dist/providers/qwen.js +43 -13
- package/dist/runtime/archive.d.ts +15 -0
- package/dist/runtime/archive.js +35 -0
- package/dist/runtime/execution-plane.js +14 -4
- package/dist/runtime/filtered-plane.d.ts +14 -0
- package/dist/runtime/filtered-plane.js +45 -0
- package/dist/runtime/kernel-step.d.ts +88 -0
- package/dist/runtime/kernel-step.js +262 -0
- package/dist/runtime/process-sandbox-plane.d.ts +4 -4
- package/dist/runtime/process-sandbox-plane.js +5 -5
- package/dist/runtime/provider-replay.js +37 -3
- package/dist/runtime/replay-sanitize.d.ts +5 -0
- package/dist/runtime/replay-sanitize.js +25 -0
- package/dist/runtime/runner.d.ts +60 -4
- package/dist/runtime/runner.js +589 -86
- package/dist/runtime/session-log.d.ts +93 -1
- package/dist/runtime/session-repair.d.ts +37 -0
- package/dist/runtime/session-repair.js +77 -0
- package/dist/runtime/sub-agent-orchestrator.d.ts +19 -0
- package/dist/runtime/sub-agent-orchestrator.js +114 -0
- package/dist/skills/watcher.d.ts +19 -0
- package/dist/skills/watcher.js +38 -0
- package/dist/tools/index.d.ts +4 -1
- package/dist/tools/index.js +82 -11
- package/dist/types/agent.d.ts +68 -0
- package/dist/types/agent.js +78 -0
- package/dist/types.d.ts +27 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentPool } from "./pool.js";
|
|
1
|
+
import type { AgentPool, CoordinatorConfig } from "./pool.js";
|
|
2
2
|
import type { VerificationContract, ContractCheckResult } from "./contract.js";
|
|
3
3
|
import type { HandoffArtifact } from "./handoff.js";
|
|
4
4
|
export interface Violation {
|
|
@@ -17,6 +17,8 @@ export interface ContractOutcome {
|
|
|
17
17
|
export interface ContractHarnessOptions {
|
|
18
18
|
maxAttempts?: number;
|
|
19
19
|
onViolation?: (violations: Violation[]) => void;
|
|
20
|
+
/** When set with pool.configureCoordinator(), enables kernel spawn path. */
|
|
21
|
+
coordinator?: CoordinatorConfig;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* ContractDrivenHarness — the core multi-agent execution primitive.
|
|
@@ -41,6 +43,7 @@ export declare class ContractDrivenHarness {
|
|
|
41
43
|
private maxAttempts;
|
|
42
44
|
private onViolation?;
|
|
43
45
|
constructor(pool: AgentPool, contract: VerificationContract, options?: ContractHarnessOptions);
|
|
46
|
+
stream(): AsyncIterable<ContractOutcome>;
|
|
44
47
|
run(): Promise<ContractOutcome>;
|
|
45
48
|
private _findViolations;
|
|
46
49
|
private _formatViolationsForFeedback;
|
|
@@ -28,6 +28,12 @@ export class ContractDrivenHarness {
|
|
|
28
28
|
this.contract = contract;
|
|
29
29
|
this.maxAttempts = options.maxAttempts ?? 3;
|
|
30
30
|
this.onViolation = options.onViolation;
|
|
31
|
+
if (options.coordinator) {
|
|
32
|
+
this.pool.configureCoordinator(options.coordinator.opts, options.coordinator.sessionId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async *stream() {
|
|
36
|
+
yield await this.run();
|
|
31
37
|
}
|
|
32
38
|
async run() {
|
|
33
39
|
let artifact = "";
|
|
@@ -43,14 +49,22 @@ export class ContractDrivenHarness {
|
|
|
43
49
|
? `\n\n[Previous attempt failed. Violations to fix:\n${this._formatViolationsForFeedback(checkResults)}]`
|
|
44
50
|
: "";
|
|
45
51
|
const executorGoal = `${contractBlock}\n\n---\n\n${currentGoal}${violationNote}`;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
if (this.pool.usesSpawnPath()) {
|
|
53
|
+
const execResult = await this.pool.spawn("executor", executorGoal, {
|
|
54
|
+
verificationContractId: this.contract.id,
|
|
55
|
+
});
|
|
56
|
+
artifact = execResult.result.finalMessage?.content ?? "";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
artifact = await collectText(this.pool.get("executor").run({
|
|
60
|
+
sessionId: crypto.randomUUID(),
|
|
61
|
+
goal: executorGoal,
|
|
62
|
+
criteria: contractToCriteriaStrings(this.contract),
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
51
65
|
// ── Phase 2: Verifier ──────────────────────────────────────────────────
|
|
52
66
|
// Verifier sees: artifact + contract only. No executor history.
|
|
53
|
-
const auditText = await this.pool.
|
|
67
|
+
const auditText = await this.pool.verify({ contract: this.contract, artifact });
|
|
54
68
|
// ── Phase 3: Parse audit → ContractCheckResult[] ──────────────────────
|
|
55
69
|
checkResults = this._parseAuditText(auditText);
|
|
56
70
|
const violations = this._findViolations(checkResults);
|
|
@@ -9,8 +9,8 @@ export interface CreatorVerifierMetrics {
|
|
|
9
9
|
/**
|
|
10
10
|
* CreatorVerifierMode — the simplest multi-agent collaboration pattern.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* By default uses the kernel spawn path via `pool.ensureCoordinator()`.
|
|
13
|
+
* Pass `useLegacyRunners: true` to fall back to independent runner sessions.
|
|
14
14
|
*
|
|
15
15
|
* Usage:
|
|
16
16
|
* ```ts
|
|
@@ -33,6 +33,10 @@ export declare class CreatorVerifierMode {
|
|
|
33
33
|
private _failed;
|
|
34
34
|
constructor(pool: AgentPool, options?: {
|
|
35
35
|
maxAttempts?: number;
|
|
36
|
+
/** Stable orchestration session for kernel lineage audit. */
|
|
37
|
+
coordinatorSessionId?: string;
|
|
38
|
+
/** Opt out of kernel spawn path and use legacy independent runner sessions. */
|
|
39
|
+
useLegacyRunners?: boolean;
|
|
36
40
|
});
|
|
37
41
|
run(contract: VerificationContract): Promise<ContractOutcome>;
|
|
38
42
|
/** Aggregate drift metrics across all runs through this mode instance. */
|
|
@@ -59,6 +63,8 @@ export declare class OrchestrationMode {
|
|
|
59
63
|
private inner;
|
|
60
64
|
constructor(pool: AgentPool, options?: {
|
|
61
65
|
maxAttempts?: number;
|
|
66
|
+
coordinatorSessionId?: string;
|
|
67
|
+
useLegacyRunners?: boolean;
|
|
62
68
|
});
|
|
63
69
|
run(goal: string): Promise<ContractOutcome & {
|
|
64
70
|
contract: VerificationContract;
|
|
@@ -2,8 +2,8 @@ import { ContractDrivenHarness } from "../harness.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* CreatorVerifierMode — the simplest multi-agent collaboration pattern.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* By default uses the kernel spawn path via `pool.ensureCoordinator()`.
|
|
6
|
+
* Pass `useLegacyRunners: true` to fall back to independent runner sessions.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
9
|
* ```ts
|
|
@@ -30,6 +30,9 @@ export class CreatorVerifierMode {
|
|
|
30
30
|
}
|
|
31
31
|
async run(contract) {
|
|
32
32
|
this._total++;
|
|
33
|
+
if (!this.options.useLegacyRunners) {
|
|
34
|
+
this.pool.ensureCoordinator(this.options.coordinatorSessionId);
|
|
35
|
+
}
|
|
33
36
|
const harness = new ContractDrivenHarness(this.pool, contract, {
|
|
34
37
|
maxAttempts: this.options.maxAttempts ?? 3,
|
|
35
38
|
});
|
|
@@ -78,8 +81,11 @@ export class OrchestrationMode {
|
|
|
78
81
|
this.inner = new CreatorVerifierMode(pool, options);
|
|
79
82
|
}
|
|
80
83
|
async run(goal) {
|
|
84
|
+
if (!this.options.useLegacyRunners) {
|
|
85
|
+
this.pool.ensureCoordinator(this.options.coordinatorSessionId);
|
|
86
|
+
}
|
|
81
87
|
// Step 1: orchestrator produces a VerificationContract
|
|
82
|
-
const contractJson = await this.pool.
|
|
88
|
+
const contractJson = await this.pool.orchestrate(goal);
|
|
83
89
|
const contract = this._parseContract(contractJson, goal);
|
|
84
90
|
// Step 2: CreatorVerifierMode executes against the contract
|
|
85
91
|
const outcome = await this.inner.run(contract);
|
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
import type { RuntimeRunner } from "../runtime/runner.js";
|
|
1
|
+
import type { RuntimeOptions, RuntimeRunner } from "../runtime/runner.js";
|
|
2
2
|
import type { VerificationContract } from "./contract.js";
|
|
3
|
+
import type { AgentRunSpec, KernelAgentRole, SubAgentResult } from "../types/agent.js";
|
|
4
|
+
/** Legacy pool roles — mapped to kernel AgentRole when using spawn path. */
|
|
3
5
|
export type AgentRole = "orchestrator" | "executor" | "verifier";
|
|
6
|
+
export declare const KERNEL_ROLE_MAP: Record<AgentRole, KernelAgentRole>;
|
|
4
7
|
export interface IsolatedVerifierContext {
|
|
5
8
|
contract: VerificationContract;
|
|
6
9
|
artifact: string;
|
|
7
10
|
}
|
|
11
|
+
export interface CoordinatorConfig {
|
|
12
|
+
opts: RuntimeOptions;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
}
|
|
8
15
|
export declare class AgentPool {
|
|
9
16
|
private runners;
|
|
17
|
+
private coordinator?;
|
|
10
18
|
add(role: AgentRole, runner: RuntimeRunner): this;
|
|
19
|
+
/** Enable kernel spawn path with lineage recorded under `sessionId`. */
|
|
20
|
+
configureCoordinator(opts: RuntimeOptions, sessionId: string): this;
|
|
21
|
+
/**
|
|
22
|
+
* Infer coordinator from a registered runner (executor → orchestrator → verifier).
|
|
23
|
+
* Idempotent when coordinator is already configured.
|
|
24
|
+
*/
|
|
25
|
+
ensureCoordinator(sessionId?: string): this;
|
|
26
|
+
usesSpawnPath(): boolean;
|
|
11
27
|
has(role: AgentRole): boolean;
|
|
12
28
|
get(role: AgentRole): RuntimeRunner;
|
|
13
|
-
|
|
14
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Spawn a kernel-isolated sub-agent. Requires `configureCoordinator()`.
|
|
31
|
+
* Maps legacy pool roles to kernel roles (executor → implement, etc.).
|
|
32
|
+
*/
|
|
33
|
+
spawn(role: AgentRole | KernelAgentRole, goal: string, extra?: Partial<Omit<AgentRunSpec, "identity" | "role" | "goal">>): Promise<SubAgentResult>;
|
|
34
|
+
verify(ctx: IsolatedVerifierContext): Promise<string>;
|
|
35
|
+
orchestrate(goal: string): Promise<string>;
|
|
15
36
|
}
|
|
@@ -1,11 +1,41 @@
|
|
|
1
1
|
import { collectText } from "../runtime/runner.js";
|
|
2
|
+
import { spawnStandalone } from "../runtime/sub-agent-orchestrator.js";
|
|
2
3
|
import { formatContractForSystemPrompt } from "./contract.js";
|
|
4
|
+
import { agentIdentitySub } from "../types/agent.js";
|
|
5
|
+
export const KERNEL_ROLE_MAP = {
|
|
6
|
+
orchestrator: "plan",
|
|
7
|
+
executor: "implement",
|
|
8
|
+
verifier: "verify",
|
|
9
|
+
};
|
|
3
10
|
export class AgentPool {
|
|
4
11
|
runners = new Map();
|
|
12
|
+
coordinator;
|
|
5
13
|
add(role, runner) {
|
|
6
14
|
this.runners.set(role, runner);
|
|
7
15
|
return this;
|
|
8
16
|
}
|
|
17
|
+
/** Enable kernel spawn path with lineage recorded under `sessionId`. */
|
|
18
|
+
configureCoordinator(opts, sessionId) {
|
|
19
|
+
this.coordinator = { opts, sessionId };
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Infer coordinator from a registered runner (executor → orchestrator → verifier).
|
|
24
|
+
* Idempotent when coordinator is already configured.
|
|
25
|
+
*/
|
|
26
|
+
ensureCoordinator(sessionId) {
|
|
27
|
+
if (this.coordinator)
|
|
28
|
+
return this;
|
|
29
|
+
const source = this.has("executor")
|
|
30
|
+
? "executor"
|
|
31
|
+
: this.has("orchestrator")
|
|
32
|
+
? "orchestrator"
|
|
33
|
+
: "verifier";
|
|
34
|
+
return this.configureCoordinator(this.get(source).hostOptions, sessionId ?? crypto.randomUUID());
|
|
35
|
+
}
|
|
36
|
+
usesSpawnPath() {
|
|
37
|
+
return this.coordinator !== undefined;
|
|
38
|
+
}
|
|
9
39
|
has(role) {
|
|
10
40
|
return this.runners.has(role);
|
|
11
41
|
}
|
|
@@ -15,8 +45,24 @@ export class AgentPool {
|
|
|
15
45
|
throw new Error(`AgentPool: no runner registered for role "${role}"`);
|
|
16
46
|
return runner;
|
|
17
47
|
}
|
|
18
|
-
|
|
19
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Spawn a kernel-isolated sub-agent. Requires `configureCoordinator()`.
|
|
50
|
+
* Maps legacy pool roles to kernel roles (executor → implement, etc.).
|
|
51
|
+
*/
|
|
52
|
+
async spawn(role, goal, extra) {
|
|
53
|
+
if (!this.coordinator) {
|
|
54
|
+
throw new Error("AgentPool.configureCoordinator() required for kernel spawn path");
|
|
55
|
+
}
|
|
56
|
+
const kernelRole = role in KERNEL_ROLE_MAP ? KERNEL_ROLE_MAP[role] : role;
|
|
57
|
+
const spec = {
|
|
58
|
+
identity: agentIdentitySub(`${kernelRole}-${crypto.randomUUID()}`, crypto.randomUUID(), this.coordinator.sessionId),
|
|
59
|
+
role: kernelRole,
|
|
60
|
+
goal,
|
|
61
|
+
...extra,
|
|
62
|
+
};
|
|
63
|
+
return spawnStandalone(this.coordinator.opts, this.coordinator.sessionId, spec);
|
|
64
|
+
}
|
|
65
|
+
async verify(ctx) {
|
|
20
66
|
const contractBlock = formatContractForSystemPrompt(ctx.contract);
|
|
21
67
|
const auditGoal = [
|
|
22
68
|
contractBlock, "",
|
|
@@ -29,10 +75,17 @@ export class AgentPool {
|
|
|
29
75
|
"List any anti-patterns you detected.",
|
|
30
76
|
"Conclude with an overall PASS or FAIL verdict.",
|
|
31
77
|
].join("\n");
|
|
78
|
+
if (this.coordinator) {
|
|
79
|
+
const result = await this.spawn("verify", auditGoal, {
|
|
80
|
+
verificationContractId: ctx.contract.id,
|
|
81
|
+
isolation: "read_only",
|
|
82
|
+
});
|
|
83
|
+
return result.result.finalMessage?.content ?? "";
|
|
84
|
+
}
|
|
85
|
+
const runner = this.get("verifier");
|
|
32
86
|
return collectText(runner.run({ sessionId: crypto.randomUUID(), goal: auditGoal }));
|
|
33
87
|
}
|
|
34
|
-
async
|
|
35
|
-
const runner = this.get("orchestrator");
|
|
88
|
+
async orchestrate(goal) {
|
|
36
89
|
const orchestratorGoal = [
|
|
37
90
|
`You are a planning orchestrator. Decompose the following goal into a VerificationContract.`,
|
|
38
91
|
``,
|
|
@@ -49,6 +102,13 @@ export class AgentPool {
|
|
|
49
102
|
``,
|
|
50
103
|
`Output ONLY the JSON object, no prose.`,
|
|
51
104
|
].join("\n");
|
|
52
|
-
|
|
105
|
+
if (this.coordinator) {
|
|
106
|
+
const result = await this.spawn("plan", orchestratorGoal);
|
|
107
|
+
return result.result.finalMessage?.content ?? "";
|
|
108
|
+
}
|
|
109
|
+
return collectText(this.get("orchestrator").run({
|
|
110
|
+
sessionId: crypto.randomUUID(),
|
|
111
|
+
goal: orchestratorGoal,
|
|
112
|
+
}));
|
|
53
113
|
}
|
|
54
114
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RuntimeRunner } from "../runtime/runner.js";
|
|
2
2
|
import { collectText } from "../runtime/runner.js";
|
|
3
|
+
import type { StreamEvent } from "../types.js";
|
|
3
4
|
export interface Criterion {
|
|
4
5
|
text: string;
|
|
5
6
|
required: boolean;
|
|
@@ -75,6 +76,7 @@ export declare class SinglePassHarness {
|
|
|
75
76
|
private runner;
|
|
76
77
|
constructor(runner: RuntimeRunner);
|
|
77
78
|
run(request: HarnessRequest): Promise<HarnessOutcome>;
|
|
79
|
+
stream(request: HarnessRequest): AsyncIterable<StreamEvent>;
|
|
78
80
|
}
|
|
79
81
|
export declare class EvalLoopHarness {
|
|
80
82
|
private runner;
|
|
@@ -82,6 +84,7 @@ export declare class EvalLoopHarness {
|
|
|
82
84
|
private maxAttempts;
|
|
83
85
|
constructor(runner: RuntimeRunner, gate: QualityGate, maxAttempts?: number);
|
|
84
86
|
run(request: HarnessRequest): Promise<HarnessOutcome>;
|
|
87
|
+
stream(request: HarnessRequest): AsyncIterable<StreamEvent>;
|
|
85
88
|
}
|
|
86
89
|
export interface HarnessLoopOptions {
|
|
87
90
|
maxAttempts?: number;
|
|
@@ -93,6 +96,7 @@ export declare class HarnessLoop {
|
|
|
93
96
|
private maxAttempts;
|
|
94
97
|
private skillDir?;
|
|
95
98
|
constructor(runner: RuntimeRunner, evalProvider: import("../types.js").LLMProvider, options?: HarnessLoopOptions);
|
|
96
|
-
|
|
99
|
+
run(request: HarnessRequest): Promise<HarnessOutcome>;
|
|
100
|
+
stream(request: HarnessRequest): AsyncIterable<HarnessEvent>;
|
|
97
101
|
}
|
|
98
102
|
export { collectText };
|
package/dist/harness/harness.js
CHANGED
|
@@ -22,6 +22,9 @@ export class SinglePassHarness {
|
|
|
22
22
|
async run(request) {
|
|
23
23
|
return { ...await runOnce(this.runner, request), passed: true };
|
|
24
24
|
}
|
|
25
|
+
async *stream(request) {
|
|
26
|
+
yield* this.runner.run({ sessionId: crypto.randomUUID(), goal: request.goal, criteria: request.criteria?.map(c => c.text), extensions: request.extensions });
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
export class EvalLoopHarness {
|
|
27
30
|
runner;
|
|
@@ -41,6 +44,9 @@ export class EvalLoopHarness {
|
|
|
41
44
|
}
|
|
42
45
|
return outcome;
|
|
43
46
|
}
|
|
47
|
+
async *stream(request) {
|
|
48
|
+
yield* this.runner.run({ sessionId: crypto.randomUUID(), goal: request.goal, criteria: request.criteria?.map(c => c.text), extensions: request.extensions });
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
export class HarnessLoop {
|
|
46
52
|
runner;
|
|
@@ -53,7 +59,23 @@ export class HarnessLoop {
|
|
|
53
59
|
this.maxAttempts = options.maxAttempts ?? 3;
|
|
54
60
|
this.skillDir = options.skillDir;
|
|
55
61
|
}
|
|
56
|
-
async
|
|
62
|
+
async run(request) {
|
|
63
|
+
let last;
|
|
64
|
+
for await (const evt of this.stream(request))
|
|
65
|
+
last = evt;
|
|
66
|
+
const done = last?.type === "done" ? last : undefined;
|
|
67
|
+
return {
|
|
68
|
+
result: "",
|
|
69
|
+
passed: done?.verdict.passed ?? false,
|
|
70
|
+
iterations: done?.iterations ?? 0,
|
|
71
|
+
totalTokens: done?.totalTokens ?? 0,
|
|
72
|
+
status: done?.status ?? "error",
|
|
73
|
+
overallScore: done?.verdict.overallScore,
|
|
74
|
+
feedback: done?.verdict.feedback,
|
|
75
|
+
details: done?.verdict.details,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async *stream(request) {
|
|
57
79
|
const kernel = getKernel();
|
|
58
80
|
const pipeline = new kernel.EvalPipeline({ extractSkillOnPass: true });
|
|
59
81
|
const criteria = request.criteria ?? [];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export { RuntimeRunner, collectText } from "./runtime/runner.js";
|
|
2
2
|
export type { RuntimeOptions } from "./runtime/runner.js";
|
|
3
|
+
export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
|
4
|
+
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
|
|
5
|
+
export type { SubAgentRunContext } from "./runtime/sub-agent-orchestrator.js";
|
|
3
6
|
export { LocalExecutionPlane } from "./runtime/execution-plane.js";
|
|
4
7
|
export type { ExecutionPlane, RunContext } from "./runtime/execution-plane.js";
|
|
5
8
|
export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
|
|
6
9
|
export type { SessionLog, SessionEvent } from "./runtime/session-log.js";
|
|
10
|
+
export { NullArchiveStore, FileArchiveStore } from "./runtime/archive.js";
|
|
11
|
+
export type { ArchiveStore } from "./runtime/archive.js";
|
|
7
12
|
export { EnvCredentialVault, InMemoryCredentialVault, ChainedCredentialVault } from "./runtime/credential-vault.js";
|
|
8
13
|
export type { CredentialVault } from "./runtime/credential-vault.js";
|
|
9
14
|
export { ProcessSandboxPlane } from "./runtime/process-sandbox-plane.js";
|
|
@@ -25,6 +30,7 @@ export { OpenAIChatAdapter } from "./providers/openai-chat.js";
|
|
|
25
30
|
export { OpenAIResponsesAdapter, OpenAIResponsesProvider } from "./providers/openai-responses.js";
|
|
26
31
|
export type { OpenAIResponsesRunState } from "./providers/openai-responses.js";
|
|
27
32
|
export { endpointProfiles, modelProfiles, getModelProfile } from "./providers/profiles.js";
|
|
33
|
+
export type { ModelProfileId, ProviderId } from "./providers/profiles.js";
|
|
28
34
|
export { createProvider } from "./providers/catalog.js";
|
|
29
35
|
export type { CreateProviderOptions, EndpointProfileId } from "./providers/catalog.js";
|
|
30
36
|
export { tool, streamingTool, executeTools, readFile, validateToolArguments } from "./tools/index.js";
|
|
@@ -44,10 +50,13 @@ export type { GovernanceVerdict } from "./governance.js";
|
|
|
44
50
|
export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness/harness.js";
|
|
45
51
|
export type { HarnessRequest, HarnessOutcome, HarnessLoopOptions, QualityGate } from "./harness/harness.js";
|
|
46
52
|
export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolChunk, ToolDeltaEvent, ToolSuspendEvent, ToolResultEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, LLMProvider, RetryConfig, TokenUsage, ProviderToolSpec, ProviderRunState, ProviderReplay, RenderedContext, } from "./types.js";
|
|
53
|
+
export type { AgentCapabilityFilter, AgentIdentity, AgentIsolation, AgentRunSpec, AgentSpawnedObservation, ContextInheritance, KernelAgentRole, LoopResult, MilestoneCheckResult, MilestoneContract, MilestonePhase, MilestonePolicy, SubAgentResult, TerminationReason, } from "./types/agent.js";
|
|
54
|
+
export { agentIdentitySub, agentRunSpecToKernel, milestoneCheckFail, milestoneCheckPass, milestoneCheckResultToKernel, subAgentResultToKernel, } from "./types/agent.js";
|
|
47
55
|
export type { AcceptanceCriterion, VerificationContract, ContractCheckResult, } from "./collaboration/contract.js";
|
|
48
56
|
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./collaboration/contract.js";
|
|
49
57
|
export { AgentPool } from "./collaboration/pool.js";
|
|
50
|
-
export type { AgentRole, IsolatedVerifierContext } from "./collaboration/pool.js";
|
|
58
|
+
export type { AgentRole, IsolatedVerifierContext, CoordinatorConfig } from "./collaboration/pool.js";
|
|
59
|
+
export { KERNEL_ROLE_MAP } from "./collaboration/pool.js";
|
|
51
60
|
export { ContractDrivenHarness } from "./collaboration/harness.js";
|
|
52
61
|
export type { ContractOutcome, ContractHarnessOptions, Violation } from "./collaboration/harness.js";
|
|
53
62
|
export { HandoffBus } from "./collaboration/handoff.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// ── Runtime (Layer 1.5) ────────────────────────────────────────────────────
|
|
2
2
|
export { RuntimeRunner, collectText } from "./runtime/runner.js";
|
|
3
|
+
export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
|
4
|
+
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
|
|
3
5
|
export { LocalExecutionPlane } from "./runtime/execution-plane.js";
|
|
4
6
|
export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
|
|
7
|
+
export { NullArchiveStore, FileArchiveStore } from "./runtime/archive.js";
|
|
5
8
|
export { EnvCredentialVault, InMemoryCredentialVault, ChainedCredentialVault } from "./runtime/credential-vault.js";
|
|
6
9
|
export { ProcessSandboxPlane } from "./runtime/process-sandbox-plane.js";
|
|
7
10
|
export { McpProxyPlane } from "./runtime/mcp-proxy-plane.js";
|
|
@@ -32,8 +35,10 @@ export { PermissionManager, PermissionMode } from "./safety/permissions.js";
|
|
|
32
35
|
export { Governance } from "./governance.js";
|
|
33
36
|
// ── Harness ────────────────────────────────────────────────────────────────
|
|
34
37
|
export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness/harness.js";
|
|
38
|
+
export { agentIdentitySub, agentRunSpecToKernel, milestoneCheckFail, milestoneCheckPass, milestoneCheckResultToKernel, subAgentResultToKernel, } from "./types/agent.js";
|
|
35
39
|
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./collaboration/contract.js";
|
|
36
40
|
export { AgentPool } from "./collaboration/pool.js";
|
|
41
|
+
export { KERNEL_ROLE_MAP } from "./collaboration/pool.js";
|
|
37
42
|
export { ContractDrivenHarness } from "./collaboration/harness.js";
|
|
38
43
|
export { HandoffBus } from "./collaboration/handoff.js";
|
|
39
44
|
export { CreatorVerifierMode, OrchestrationMode } from "./collaboration/modes/creator-verifier.js";
|
package/dist/kernel.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Message, RenderedContext
|
|
2
|
-
import type { SkillMetadata } from "./skills/loader.js";
|
|
1
|
+
import type { Message, RenderedContext } from "./types.js";
|
|
3
2
|
export interface GovernanceVerdict {
|
|
4
3
|
kind: "allow" | "deny" | "rate_limited" | "ask_user";
|
|
5
4
|
reason?: string;
|
|
@@ -26,45 +25,6 @@ export interface RuntimeSignal {
|
|
|
26
25
|
dedupeKey?: string;
|
|
27
26
|
timestampMs: number;
|
|
28
27
|
}
|
|
29
|
-
export interface LoopAction {
|
|
30
|
-
kind: "call_llm" | "execute_tools" | "done";
|
|
31
|
-
context?: RenderedContext;
|
|
32
|
-
tools?: ToolSchema[];
|
|
33
|
-
calls?: ToolCall[];
|
|
34
|
-
result?: {
|
|
35
|
-
termination: string;
|
|
36
|
-
turnsUsed: number;
|
|
37
|
-
totalTokensUsed: bigint;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
interface LoopObservation {
|
|
41
|
-
kind: "compressed";
|
|
42
|
-
action?: string;
|
|
43
|
-
rhoAfter?: number;
|
|
44
|
-
}
|
|
45
|
-
interface LoopStateMachineInstance {
|
|
46
|
-
setAvailableSkills(skills: SkillMetadata[]): void;
|
|
47
|
-
setMemoryEnabled(enabled: boolean): void;
|
|
48
|
-
setKnowledgeEnabled(enabled: boolean): void;
|
|
49
|
-
addSystemMessage(content: string, tokens: number): void;
|
|
50
|
-
addMemoryMessage(content: string, tokens: number): void;
|
|
51
|
-
addHistoryMessage(message: Message, tokens: number): void;
|
|
52
|
-
setTools(tools: ToolSchema[]): void;
|
|
53
|
-
start(task: {
|
|
54
|
-
goal: string;
|
|
55
|
-
criteria: string[];
|
|
56
|
-
}): LoopAction;
|
|
57
|
-
resumeAfterPreload(): LoopAction;
|
|
58
|
-
feedLlmResponse(message: Message): LoopAction;
|
|
59
|
-
feedToolResults(results: ToolResult[]): LoopAction;
|
|
60
|
-
feedTimeout(): LoopAction;
|
|
61
|
-
isTerminal(): boolean;
|
|
62
|
-
preloadHistory(messages: Message[]): void;
|
|
63
|
-
drainNewMessages(): Message[];
|
|
64
|
-
readonly turn: number;
|
|
65
|
-
pressure(): number;
|
|
66
|
-
takeObservations(): LoopObservation[];
|
|
67
|
-
}
|
|
68
28
|
interface SignalRouterInstance {
|
|
69
29
|
ingest(signal: RuntimeSignal, isRunning: boolean): string;
|
|
70
30
|
next(): RuntimeSignal | null;
|
|
@@ -135,14 +95,23 @@ interface IdlePipelineInstance {
|
|
|
135
95
|
}>, nowMs: number): IdlePipelineAction;
|
|
136
96
|
feedSynthesisResult(content: string): IdlePipelineAction;
|
|
137
97
|
}
|
|
98
|
+
export interface KernelRuntimeInstance {
|
|
99
|
+
step(inputJson: string): string;
|
|
100
|
+
isTerminal(): boolean;
|
|
101
|
+
turn(): number;
|
|
102
|
+
recoveryContentBytes(): number;
|
|
103
|
+
render(): RenderedContext;
|
|
104
|
+
drainNewMessages(): Message[];
|
|
105
|
+
preservedRefs(): string[];
|
|
106
|
+
}
|
|
138
107
|
interface KernelModule {
|
|
139
108
|
Governance: new (defaultAction?: "allow" | "deny" | "ask_user") => GovernanceInstance;
|
|
140
|
-
|
|
109
|
+
KernelRuntime: new (policy: {
|
|
141
110
|
maxTokens: number;
|
|
142
111
|
maxTurns?: number;
|
|
143
112
|
maxTotalTokens?: bigint;
|
|
144
113
|
timeoutMs?: bigint;
|
|
145
|
-
}) =>
|
|
114
|
+
}) => KernelRuntimeInstance;
|
|
146
115
|
SignalRouter: new (maxQueueSize: number) => SignalRouterInstance;
|
|
147
116
|
EvalPipeline: new (options?: {
|
|
148
117
|
extractSkillOnPass?: boolean;
|
package/dist/kernel.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
const cjsRequire = createRequire(import.meta.url);
|
|
6
6
|
let cachedKernel;
|
|
7
7
|
function resolveCoreModule() {
|
|
8
|
-
const localCore = join(dirname(fileURLToPath(import.meta.url)), "
|
|
8
|
+
const localCore = join(dirname(fileURLToPath(import.meta.url)), "../../crates/deepstrike-node");
|
|
9
9
|
if (existsSync(join(localCore, "index.js")))
|
|
10
10
|
return localCore;
|
|
11
11
|
return "@deepstrike/core";
|
|
@@ -3,11 +3,14 @@ import { assistantReplayKey } from "../runtime/provider-replay.js";
|
|
|
3
3
|
import { withServerRuntimeGuard } from "../runtime/server.js";
|
|
4
4
|
import { CircuitBreaker, normalizeToolCall, omitExtensionKeys, toAnthropicMessages } from "./base.js";
|
|
5
5
|
const CLAUDE_POLICIES = {
|
|
6
|
+
"claude-opus-4-1": { maxTurns: 50 },
|
|
6
7
|
"claude-opus-4-7": { maxTurns: 50 },
|
|
7
8
|
"claude-opus-4-6": { maxTurns: 50 },
|
|
9
|
+
"claude-opus-4-0": { maxTurns: 50 },
|
|
8
10
|
"claude-sonnet-4-6": { maxTurns: 25 },
|
|
11
|
+
"claude-sonnet-4-0": { maxTurns: 25 },
|
|
9
12
|
"claude-haiku-4-5": { maxTurns: 15 },
|
|
10
|
-
"claude-
|
|
13
|
+
"claude-3-5-haiku-latest": { maxTurns: 15 },
|
|
11
14
|
};
|
|
12
15
|
export class AnthropicProvider {
|
|
13
16
|
model;
|
|
@@ -19,7 +22,9 @@ export class AnthropicProvider {
|
|
|
19
22
|
constructor(apiKey, model = "claude-sonnet-4-6", retry = { maxRetries: 3, baseDelay: 1000 }, options = {}) {
|
|
20
23
|
this.model = model;
|
|
21
24
|
this.client = withServerRuntimeGuard(() => new Anthropic({
|
|
22
|
-
...(options.authMode === "bearer"
|
|
25
|
+
...(options.authMode === "bearer"
|
|
26
|
+
? { authToken: apiKey, apiKey: null }
|
|
27
|
+
: { apiKey, authToken: null }),
|
|
23
28
|
...(options.baseURL ? { baseURL: options.baseURL } : {}),
|
|
24
29
|
}));
|
|
25
30
|
this.circuit = new CircuitBreaker();
|
package/dist/providers/base.d.ts
CHANGED
|
@@ -23,3 +23,15 @@ export declare function toOpenAIContent(msg: Message): string | Array<Record<str
|
|
|
23
23
|
/** Build the full OpenAI messages array from a RenderedContext.
|
|
24
24
|
* Prepends systemText as the first system message, then converts turns. */
|
|
25
25
|
export declare function toOpenAIMessageParams(context: RenderedContext): Array<Record<string, unknown>>;
|
|
26
|
+
export declare class ThinkingTagStreamExtractor {
|
|
27
|
+
private buffer;
|
|
28
|
+
private inThinking;
|
|
29
|
+
feed(chunk: string): Array<{
|
|
30
|
+
type: "text" | "thinking";
|
|
31
|
+
content: string;
|
|
32
|
+
}>;
|
|
33
|
+
flush(): Array<{
|
|
34
|
+
type: "text" | "thinking";
|
|
35
|
+
content: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
package/dist/providers/base.js
CHANGED
|
@@ -166,3 +166,78 @@ export function toOpenAIMessageParams(context) {
|
|
|
166
166
|
}
|
|
167
167
|
return result;
|
|
168
168
|
}
|
|
169
|
+
export class ThinkingTagStreamExtractor {
|
|
170
|
+
buffer = "";
|
|
171
|
+
inThinking = false;
|
|
172
|
+
feed(chunk) {
|
|
173
|
+
this.buffer += chunk;
|
|
174
|
+
const events = [];
|
|
175
|
+
while (true) {
|
|
176
|
+
if (!this.inThinking) {
|
|
177
|
+
const thinkIndex = this.buffer.indexOf("<think>");
|
|
178
|
+
if (thinkIndex !== -1) {
|
|
179
|
+
const textBefore = this.buffer.substring(0, thinkIndex);
|
|
180
|
+
if (textBefore) {
|
|
181
|
+
events.push({ type: "text", content: textBefore });
|
|
182
|
+
}
|
|
183
|
+
this.inThinking = true;
|
|
184
|
+
this.buffer = this.buffer.substring(thinkIndex + 7);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const possibleTagStart = this.buffer.lastIndexOf("<");
|
|
188
|
+
if (possibleTagStart !== -1 && "<think>".startsWith(this.buffer.substring(possibleTagStart))) {
|
|
189
|
+
const toEmit = this.buffer.substring(0, possibleTagStart);
|
|
190
|
+
if (toEmit) {
|
|
191
|
+
events.push({ type: "text", content: toEmit });
|
|
192
|
+
}
|
|
193
|
+
this.buffer = this.buffer.substring(possibleTagStart);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
if (this.buffer) {
|
|
198
|
+
events.push({ type: "text", content: this.buffer });
|
|
199
|
+
this.buffer = "";
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
const endThinkIndex = this.buffer.indexOf("</think>");
|
|
206
|
+
if (endThinkIndex !== -1) {
|
|
207
|
+
const thinkingContent = this.buffer.substring(0, endThinkIndex);
|
|
208
|
+
if (thinkingContent) {
|
|
209
|
+
events.push({ type: "thinking", content: thinkingContent });
|
|
210
|
+
}
|
|
211
|
+
this.inThinking = false;
|
|
212
|
+
this.buffer = this.buffer.substring(endThinkIndex + 8);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const possibleEndStart = this.buffer.lastIndexOf("<");
|
|
216
|
+
if (possibleEndStart !== -1 && "</think>".startsWith(this.buffer.substring(possibleEndStart))) {
|
|
217
|
+
const toEmit = this.buffer.substring(0, possibleEndStart);
|
|
218
|
+
if (toEmit) {
|
|
219
|
+
events.push({ type: "thinking", content: toEmit });
|
|
220
|
+
}
|
|
221
|
+
this.buffer = this.buffer.substring(possibleEndStart);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
if (this.buffer) {
|
|
226
|
+
events.push({ type: "thinking", content: this.buffer });
|
|
227
|
+
this.buffer = "";
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return events;
|
|
234
|
+
}
|
|
235
|
+
flush() {
|
|
236
|
+
const events = [];
|
|
237
|
+
if (this.buffer) {
|
|
238
|
+
events.push({ type: this.inThinking ? "thinking" : "text", content: this.buffer });
|
|
239
|
+
this.buffer = "";
|
|
240
|
+
}
|
|
241
|
+
return events;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { LLMProvider } from "../types.js";
|
|
2
|
-
import { endpointProfiles, type ModelProfileId } from "./profiles.js";
|
|
2
|
+
import { endpointProfiles, type ModelProfileId, type ProviderId } from "./profiles.js";
|
|
3
3
|
export type EndpointProfileId = keyof typeof endpointProfiles;
|
|
4
4
|
export interface CreateProviderOptions {
|
|
5
|
-
model: ModelProfileId;
|
|
5
|
+
model: ModelProfileId | string;
|
|
6
6
|
apiKey: string;
|
|
7
|
+
provider?: ProviderId;
|
|
7
8
|
endpoint?: EndpointProfileId;
|
|
8
9
|
retry?: {
|
|
9
10
|
maxRetries: number;
|