@deepstrike/sdk 0.1.9 → 0.1.11
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/contract.d.ts +55 -0
- package/dist/collaboration/contract.js +65 -0
- package/dist/collaboration/handoff.d.ts +79 -0
- package/dist/collaboration/handoff.js +98 -0
- package/dist/collaboration/harness.d.ts +55 -0
- package/dist/collaboration/harness.js +150 -0
- package/dist/collaboration/index.d.ts +10 -0
- package/dist/collaboration/index.js +9 -0
- package/dist/collaboration/modes/creator-verifier.d.ts +69 -0
- package/dist/collaboration/modes/creator-verifier.js +124 -0
- package/dist/collaboration/pool.d.ts +46 -0
- package/dist/collaboration/pool.js +80 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/skills/loader.js +3 -3
- package/package.json +2 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VerificationContract — first-class type for contract-driven development.
|
|
3
|
+
*
|
|
4
|
+
* Contracts travel in the executor's system partition (never compressed) and
|
|
5
|
+
* are given to the verifier alongside the artifact. The verifier never sees
|
|
6
|
+
* the executor's implementation history — only the goal, contract, and artifact.
|
|
7
|
+
*/
|
|
8
|
+
export interface AcceptanceCriterion {
|
|
9
|
+
/** Stable id — matched in ContractCheckResult. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Human-readable statement of what correct looks like. */
|
|
12
|
+
text: string;
|
|
13
|
+
/** If true, failure here fails the entire contract regardless of score. */
|
|
14
|
+
required: boolean;
|
|
15
|
+
/** Contribution to the weighted overall score [0.0–1.0]. */
|
|
16
|
+
weight: number;
|
|
17
|
+
/** If true the SDK can verify this deterministically (e.g. word count, schema). */
|
|
18
|
+
machineCheckable: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface VerificationContract {
|
|
21
|
+
/** Stable id — doubles as the skill name on successful extraction. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Goal this contract governs. Injected into the executor's context. */
|
|
24
|
+
goal: string;
|
|
25
|
+
acceptance: AcceptanceCriterion[];
|
|
26
|
+
/** Patterns the executor must avoid. Checked by the verifier. */
|
|
27
|
+
antiPatterns: string[];
|
|
28
|
+
/** Artifacts that must be present before the verifier runs. */
|
|
29
|
+
evidenceRequired: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface ContractCheckResult {
|
|
32
|
+
criterionId: string;
|
|
33
|
+
passed: boolean;
|
|
34
|
+
evidence?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Build a contract incrementally. */
|
|
37
|
+
export declare class ContractBuilder {
|
|
38
|
+
private contract;
|
|
39
|
+
constructor(id: string, goal: string);
|
|
40
|
+
criterion(id: string, text: string, opts?: {
|
|
41
|
+
required?: boolean;
|
|
42
|
+
weight?: number;
|
|
43
|
+
machineCheckable?: boolean;
|
|
44
|
+
}): this;
|
|
45
|
+
antiPattern(pattern: string): this;
|
|
46
|
+
evidence(item: string): this;
|
|
47
|
+
build(): VerificationContract;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Render the contract as a markdown block for injection into a system prompt.
|
|
51
|
+
* Used by ContractDrivenHarness to inject into the executor's system partition.
|
|
52
|
+
*/
|
|
53
|
+
export declare function formatContractForSystemPrompt(contract: VerificationContract): string;
|
|
54
|
+
/** Derive a flat string[] of criterion texts for the existing HarnessLoop criteria API. */
|
|
55
|
+
export declare function contractToCriteriaStrings(contract: VerificationContract): string[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VerificationContract — first-class type for contract-driven development.
|
|
3
|
+
*
|
|
4
|
+
* Contracts travel in the executor's system partition (never compressed) and
|
|
5
|
+
* are given to the verifier alongside the artifact. The verifier never sees
|
|
6
|
+
* the executor's implementation history — only the goal, contract, and artifact.
|
|
7
|
+
*/
|
|
8
|
+
/** Build a contract incrementally. */
|
|
9
|
+
export class ContractBuilder {
|
|
10
|
+
contract;
|
|
11
|
+
constructor(id, goal) {
|
|
12
|
+
this.contract = { id, goal, acceptance: [], antiPatterns: [], evidenceRequired: [] };
|
|
13
|
+
}
|
|
14
|
+
criterion(id, text, opts = {}) {
|
|
15
|
+
this.contract.acceptance.push({
|
|
16
|
+
id,
|
|
17
|
+
text,
|
|
18
|
+
required: opts.required ?? true,
|
|
19
|
+
weight: Math.min(1, Math.max(0, opts.weight ?? 1.0)),
|
|
20
|
+
machineCheckable: opts.machineCheckable ?? false,
|
|
21
|
+
});
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
antiPattern(pattern) {
|
|
25
|
+
this.contract.antiPatterns.push(pattern);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
evidence(item) {
|
|
29
|
+
this.contract.evidenceRequired.push(item);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
build() {
|
|
33
|
+
return structuredClone(this.contract);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Render the contract as a markdown block for injection into a system prompt.
|
|
38
|
+
* Used by ContractDrivenHarness to inject into the executor's system partition.
|
|
39
|
+
*/
|
|
40
|
+
export function formatContractForSystemPrompt(contract) {
|
|
41
|
+
const lines = [
|
|
42
|
+
`## Verification Contract: ${contract.id}`,
|
|
43
|
+
"",
|
|
44
|
+
`Goal: ${contract.goal}`,
|
|
45
|
+
"",
|
|
46
|
+
"### Acceptance Criteria",
|
|
47
|
+
];
|
|
48
|
+
contract.acceptance.forEach((c, i) => {
|
|
49
|
+
const req = c.required ? "[REQUIRED]" : "[OPTIONAL]";
|
|
50
|
+
lines.push(`${i + 1}. ${req} ${c.text} (id: \`${c.id}\`, weight: ${c.weight.toFixed(1)})`);
|
|
51
|
+
});
|
|
52
|
+
if (contract.antiPatterns.length > 0) {
|
|
53
|
+
lines.push("", "### Anti-Patterns (must avoid)");
|
|
54
|
+
contract.antiPatterns.forEach(p => lines.push(`- ${p}`));
|
|
55
|
+
}
|
|
56
|
+
if (contract.evidenceRequired.length > 0) {
|
|
57
|
+
lines.push("", "### Required Evidence");
|
|
58
|
+
contract.evidenceRequired.forEach(e => lines.push(`- ${e}`));
|
|
59
|
+
}
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
62
|
+
/** Derive a flat string[] of criterion texts for the existing HarnessLoop criteria API. */
|
|
63
|
+
export function contractToCriteriaStrings(contract) {
|
|
64
|
+
return contract.acceptance.map(c => c.text);
|
|
65
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ContractCheckResult, VerificationContract } from "./contract.js";
|
|
2
|
+
import type { DreamResult } from "../memory/protocols.js";
|
|
3
|
+
/**
|
|
4
|
+
* HandoffArtifact — the single exchange token between sprints and agent instances.
|
|
5
|
+
*
|
|
6
|
+
* All handoff paths converge here:
|
|
7
|
+
* - ContractDrivenHarness completion → HandoffBus.fromContractOutcome()
|
|
8
|
+
* - Sub-agent completion → HandoffBus.fromSubAgentResult()
|
|
9
|
+
* - Dream consolidation → HandoffBus.fromDream()
|
|
10
|
+
* - Context renewal (kernel) → carried in kernel's HandoffArtifact type
|
|
11
|
+
*
|
|
12
|
+
* The invariant: a HandoffArtifact tells the next agent not only *what was done*
|
|
13
|
+
* but *what has been proven*. The contract_status field is never discarded on renewal.
|
|
14
|
+
*/
|
|
15
|
+
export interface HandoffArtifact {
|
|
16
|
+
goal: string;
|
|
17
|
+
sprint: number;
|
|
18
|
+
progressSummary: string;
|
|
19
|
+
openTasks: string[];
|
|
20
|
+
/** Per-criterion verification results from the most recent contract run. */
|
|
21
|
+
contractStatus: ContractCheckResult[];
|
|
22
|
+
/** Ratio of verification failures over 24 h (failed / total). 0.0 if no data. */
|
|
23
|
+
driftRate24h: number;
|
|
24
|
+
/** Issues blocking completion — require human or orchestrator attention. */
|
|
25
|
+
blockedOn: string[];
|
|
26
|
+
}
|
|
27
|
+
/** Input to HandoffBus.fromContractOutcome */
|
|
28
|
+
export interface ContractOutcomeInput {
|
|
29
|
+
contract: VerificationContract;
|
|
30
|
+
checkResults: ContractCheckResult[];
|
|
31
|
+
artifact: string;
|
|
32
|
+
success: boolean;
|
|
33
|
+
blockedOn?: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* HandoffBus — the canonical factory for HandoffArtifact.
|
|
37
|
+
*
|
|
38
|
+
* Every transition between agent contexts goes through one of these static methods.
|
|
39
|
+
* This ensures that the resulting artifact always carries contract_status, never just
|
|
40
|
+
* a prose summary.
|
|
41
|
+
*/
|
|
42
|
+
export declare class HandoffBus {
|
|
43
|
+
/**
|
|
44
|
+
* Build a HandoffArtifact from a ContractDrivenHarness outcome.
|
|
45
|
+
* The artifact field is used as the progress summary.
|
|
46
|
+
*/
|
|
47
|
+
static fromContractOutcome(input: ContractOutcomeInput): HandoffArtifact;
|
|
48
|
+
/**
|
|
49
|
+
* Build a HandoffArtifact from a sub-agent's final message.
|
|
50
|
+
* Matches the convention established by `report_sub_agent` (only final message injected).
|
|
51
|
+
*/
|
|
52
|
+
static fromSubAgentResult(opts: {
|
|
53
|
+
goal: string;
|
|
54
|
+
finalMessage: string;
|
|
55
|
+
sprint?: number;
|
|
56
|
+
}): HandoffArtifact;
|
|
57
|
+
/**
|
|
58
|
+
* Build a HandoffArtifact from a dream consolidation result.
|
|
59
|
+
* Used when the idle pipeline produces new memories that should be
|
|
60
|
+
* carried into the next sprint's context.
|
|
61
|
+
*/
|
|
62
|
+
static fromDream(opts: {
|
|
63
|
+
goal: string;
|
|
64
|
+
dreamResult: DreamResult;
|
|
65
|
+
sprint?: number;
|
|
66
|
+
}): HandoffArtifact;
|
|
67
|
+
/**
|
|
68
|
+
* Render the artifact as a compact injection string for the next agent's
|
|
69
|
+
* working partition (not system — this is a handoff note, not a permanent rule).
|
|
70
|
+
*/
|
|
71
|
+
static toContextNote(artifact: HandoffArtifact): string;
|
|
72
|
+
/**
|
|
73
|
+
* True when drift rate exceeds threshold or required criteria are blocked.
|
|
74
|
+
* Use to decide whether to pause autonomous delegation and escalate.
|
|
75
|
+
*/
|
|
76
|
+
static requiresEscalation(artifact: HandoffArtifact, opts?: {
|
|
77
|
+
driftThreshold?: number;
|
|
78
|
+
}): boolean;
|
|
79
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HandoffBus — the canonical factory for HandoffArtifact.
|
|
3
|
+
*
|
|
4
|
+
* Every transition between agent contexts goes through one of these static methods.
|
|
5
|
+
* This ensures that the resulting artifact always carries contract_status, never just
|
|
6
|
+
* a prose summary.
|
|
7
|
+
*/
|
|
8
|
+
export class HandoffBus {
|
|
9
|
+
/**
|
|
10
|
+
* Build a HandoffArtifact from a ContractDrivenHarness outcome.
|
|
11
|
+
* The artifact field is used as the progress summary.
|
|
12
|
+
*/
|
|
13
|
+
static fromContractOutcome(input) {
|
|
14
|
+
const failedRequired = input.checkResults.filter(r => {
|
|
15
|
+
if (r.passed)
|
|
16
|
+
return false;
|
|
17
|
+
const c = input.contract.acceptance.find(a => a.id === r.criterionId);
|
|
18
|
+
return c?.required ?? false;
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
goal: input.contract.goal,
|
|
22
|
+
sprint: 1,
|
|
23
|
+
progressSummary: input.success
|
|
24
|
+
? `Completed: ${input.artifact.slice(0, 200)}${input.artifact.length > 200 ? "…" : ""}`
|
|
25
|
+
: `Incomplete after max attempts. ${failedRequired.length} required criteria failed.`,
|
|
26
|
+
openTasks: input.success ? [] : failedRequired.map(r => `Fix criterion: ${r.criterionId}`),
|
|
27
|
+
contractStatus: input.checkResults,
|
|
28
|
+
driftRate24h: input.checkResults.length > 0
|
|
29
|
+
? input.checkResults.filter(r => !r.passed).length / input.checkResults.length
|
|
30
|
+
: 0,
|
|
31
|
+
blockedOn: input.blockedOn ?? [],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build a HandoffArtifact from a sub-agent's final message.
|
|
36
|
+
* Matches the convention established by `report_sub_agent` (only final message injected).
|
|
37
|
+
*/
|
|
38
|
+
static fromSubAgentResult(opts) {
|
|
39
|
+
return {
|
|
40
|
+
goal: opts.goal,
|
|
41
|
+
sprint: opts.sprint ?? 1,
|
|
42
|
+
progressSummary: opts.finalMessage.slice(0, 500),
|
|
43
|
+
openTasks: [],
|
|
44
|
+
contractStatus: [],
|
|
45
|
+
driftRate24h: 0,
|
|
46
|
+
blockedOn: [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build a HandoffArtifact from a dream consolidation result.
|
|
51
|
+
* Used when the idle pipeline produces new memories that should be
|
|
52
|
+
* carried into the next sprint's context.
|
|
53
|
+
*/
|
|
54
|
+
static fromDream(opts) {
|
|
55
|
+
return {
|
|
56
|
+
goal: opts.goal,
|
|
57
|
+
sprint: opts.sprint ?? 1,
|
|
58
|
+
progressSummary: `Memory consolidated: ${opts.dreamResult.entriesAdded} added, ${opts.dreamResult.entriesRemoved} removed.`,
|
|
59
|
+
openTasks: [],
|
|
60
|
+
contractStatus: [],
|
|
61
|
+
driftRate24h: 0,
|
|
62
|
+
blockedOn: [],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Render the artifact as a compact injection string for the next agent's
|
|
67
|
+
* working partition (not system — this is a handoff note, not a permanent rule).
|
|
68
|
+
*/
|
|
69
|
+
static toContextNote(artifact) {
|
|
70
|
+
const lines = [
|
|
71
|
+
`[Handoff from sprint ${artifact.sprint}]`,
|
|
72
|
+
`Goal: ${artifact.goal}`,
|
|
73
|
+
`Progress: ${artifact.progressSummary}`,
|
|
74
|
+
];
|
|
75
|
+
if (artifact.openTasks.length > 0) {
|
|
76
|
+
lines.push(`Open tasks: ${artifact.openTasks.join("; ")}`);
|
|
77
|
+
}
|
|
78
|
+
if (artifact.contractStatus.length > 0) {
|
|
79
|
+
const passed = artifact.contractStatus.filter(r => r.passed).length;
|
|
80
|
+
lines.push(`Contract: ${passed}/${artifact.contractStatus.length} criteria passed`);
|
|
81
|
+
}
|
|
82
|
+
if (artifact.blockedOn.length > 0) {
|
|
83
|
+
lines.push(`BLOCKED ON: ${artifact.blockedOn.join("; ")}`);
|
|
84
|
+
}
|
|
85
|
+
if (artifact.driftRate24h > 0) {
|
|
86
|
+
lines.push(`Drift rate: ${(artifact.driftRate24h * 100).toFixed(1)}%`);
|
|
87
|
+
}
|
|
88
|
+
return lines.join("\n");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* True when drift rate exceeds threshold or required criteria are blocked.
|
|
92
|
+
* Use to decide whether to pause autonomous delegation and escalate.
|
|
93
|
+
*/
|
|
94
|
+
static requiresEscalation(artifact, opts = {}) {
|
|
95
|
+
const threshold = opts.driftThreshold ?? 0.05;
|
|
96
|
+
return artifact.driftRate24h > threshold || artifact.blockedOn.length > 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AgentPool } from "./pool.js";
|
|
2
|
+
import type { VerificationContract, ContractCheckResult } from "./contract.js";
|
|
3
|
+
import type { HandoffArtifact } from "./handoff.js";
|
|
4
|
+
export interface Violation {
|
|
5
|
+
criterionId: string;
|
|
6
|
+
text: string;
|
|
7
|
+
detail: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ContractOutcome {
|
|
10
|
+
success: boolean;
|
|
11
|
+
artifact: string;
|
|
12
|
+
checkResults: ContractCheckResult[];
|
|
13
|
+
attemptsUsed: number;
|
|
14
|
+
totalTokensConsumed: number;
|
|
15
|
+
handoff: HandoffArtifact;
|
|
16
|
+
}
|
|
17
|
+
export interface ContractHarnessOptions {
|
|
18
|
+
maxAttempts?: number;
|
|
19
|
+
onViolation?: (violations: Violation[]) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* ContractDrivenHarness — the core multi-agent execution primitive.
|
|
23
|
+
*
|
|
24
|
+
* Differs from HarnessLoop in three ways:
|
|
25
|
+
* 1. Executor and verifier are **separate Agent instances** — no shared history.
|
|
26
|
+
* 2. Verifier receives only the artifact + contract, not the implementation transcript.
|
|
27
|
+
* 3. Feedback returned to the executor is a structured list of Violations,
|
|
28
|
+
* not a free-text LLM summary.
|
|
29
|
+
*
|
|
30
|
+
* Protocol per attempt:
|
|
31
|
+
* executor.run(goal, contract) → artifact
|
|
32
|
+
* verifier.runIsolated(artifact, contract) → audit text
|
|
33
|
+
* parse audit text → ContractCheckResult[]
|
|
34
|
+
* all required criteria pass → Done
|
|
35
|
+
* violations remain → inject only violation list into next executor goal
|
|
36
|
+
* maxAttempts exceeded → produce HandoffArtifact with blocked_on
|
|
37
|
+
*/
|
|
38
|
+
export declare class ContractDrivenHarness {
|
|
39
|
+
private pool;
|
|
40
|
+
private contract;
|
|
41
|
+
private maxAttempts;
|
|
42
|
+
private onViolation?;
|
|
43
|
+
constructor(pool: AgentPool, contract: VerificationContract, options?: ContractHarnessOptions);
|
|
44
|
+
run(): Promise<ContractOutcome>;
|
|
45
|
+
private _findViolations;
|
|
46
|
+
private _formatViolationsForFeedback;
|
|
47
|
+
/**
|
|
48
|
+
* Parse the verifier's free-text audit into structured ContractCheckResult[].
|
|
49
|
+
*
|
|
50
|
+
* The verifier is prompted to produce a structured PASS/FAIL per criterion.
|
|
51
|
+
* This parser handles the common patterns; callers can subclass and override
|
|
52
|
+
* for stricter parsing.
|
|
53
|
+
*/
|
|
54
|
+
private _parseAuditText;
|
|
55
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { formatContractForSystemPrompt, contractToCriteriaStrings } from "./contract.js";
|
|
2
|
+
import { HandoffBus } from "./handoff.js";
|
|
3
|
+
/**
|
|
4
|
+
* ContractDrivenHarness — the core multi-agent execution primitive.
|
|
5
|
+
*
|
|
6
|
+
* Differs from HarnessLoop in three ways:
|
|
7
|
+
* 1. Executor and verifier are **separate Agent instances** — no shared history.
|
|
8
|
+
* 2. Verifier receives only the artifact + contract, not the implementation transcript.
|
|
9
|
+
* 3. Feedback returned to the executor is a structured list of Violations,
|
|
10
|
+
* not a free-text LLM summary.
|
|
11
|
+
*
|
|
12
|
+
* Protocol per attempt:
|
|
13
|
+
* executor.run(goal, contract) → artifact
|
|
14
|
+
* verifier.runIsolated(artifact, contract) → audit text
|
|
15
|
+
* parse audit text → ContractCheckResult[]
|
|
16
|
+
* all required criteria pass → Done
|
|
17
|
+
* violations remain → inject only violation list into next executor goal
|
|
18
|
+
* maxAttempts exceeded → produce HandoffArtifact with blocked_on
|
|
19
|
+
*/
|
|
20
|
+
export class ContractDrivenHarness {
|
|
21
|
+
pool;
|
|
22
|
+
contract;
|
|
23
|
+
maxAttempts;
|
|
24
|
+
onViolation;
|
|
25
|
+
constructor(pool, contract, options = {}) {
|
|
26
|
+
this.pool = pool;
|
|
27
|
+
this.contract = contract;
|
|
28
|
+
this.maxAttempts = options.maxAttempts ?? 3;
|
|
29
|
+
this.onViolation = options.onViolation;
|
|
30
|
+
}
|
|
31
|
+
async run() {
|
|
32
|
+
let artifact = "";
|
|
33
|
+
let checkResults = [];
|
|
34
|
+
let attemptsUsed = 0;
|
|
35
|
+
let currentGoal = this.contract.goal;
|
|
36
|
+
for (let attempt = 1; attempt <= this.maxAttempts; attempt++) {
|
|
37
|
+
attemptsUsed = attempt;
|
|
38
|
+
// ── Phase 1: Executor ──────────────────────────────────────────────────
|
|
39
|
+
// Executor sees: contract block + goal. No verifier history.
|
|
40
|
+
const contractBlock = formatContractForSystemPrompt(this.contract);
|
|
41
|
+
const violationNote = attempt > 1
|
|
42
|
+
? `\n\n[Previous attempt failed. Violations to fix:\n${this._formatViolationsForFeedback(checkResults)}]`
|
|
43
|
+
: "";
|
|
44
|
+
const executorGoal = `${contractBlock}\n\n---\n\n${currentGoal}${violationNote}`;
|
|
45
|
+
artifact = await this.pool.get("executor").run(executorGoal, contractToCriteriaStrings(this.contract));
|
|
46
|
+
// ── Phase 2: Verifier ──────────────────────────────────────────────────
|
|
47
|
+
// Verifier sees: artifact + contract only. No executor history.
|
|
48
|
+
const auditText = await this.pool.runVerifier({ contract: this.contract, artifact });
|
|
49
|
+
// ── Phase 3: Parse audit → ContractCheckResult[] ──────────────────────
|
|
50
|
+
checkResults = this._parseAuditText(auditText);
|
|
51
|
+
const violations = this._findViolations(checkResults);
|
|
52
|
+
if (violations.length === 0) {
|
|
53
|
+
// All required criteria passed
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
artifact,
|
|
57
|
+
checkResults,
|
|
58
|
+
attemptsUsed,
|
|
59
|
+
totalTokensConsumed: 0,
|
|
60
|
+
handoff: HandoffBus.fromContractOutcome({
|
|
61
|
+
contract: this.contract,
|
|
62
|
+
checkResults,
|
|
63
|
+
artifact,
|
|
64
|
+
success: true,
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
this.onViolation?.(violations);
|
|
69
|
+
}
|
|
70
|
+
// Max attempts exhausted
|
|
71
|
+
const blockedOn = this._findViolations(checkResults).map(v => `[${v.criterionId}] ${v.text}: ${v.detail}`);
|
|
72
|
+
return {
|
|
73
|
+
success: false,
|
|
74
|
+
artifact,
|
|
75
|
+
checkResults,
|
|
76
|
+
attemptsUsed,
|
|
77
|
+
totalTokensConsumed: 0,
|
|
78
|
+
handoff: HandoffBus.fromContractOutcome({
|
|
79
|
+
contract: this.contract,
|
|
80
|
+
checkResults,
|
|
81
|
+
artifact,
|
|
82
|
+
success: false,
|
|
83
|
+
blockedOn,
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
_findViolations(results) {
|
|
88
|
+
const violations = [];
|
|
89
|
+
for (const result of results) {
|
|
90
|
+
if (!result.passed) {
|
|
91
|
+
const criterion = this.contract.acceptance.find(c => c.id === result.criterionId);
|
|
92
|
+
if (criterion?.required) {
|
|
93
|
+
violations.push({
|
|
94
|
+
criterionId: result.criterionId,
|
|
95
|
+
text: criterion.text,
|
|
96
|
+
detail: result.evidence ?? "no evidence provided",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return violations;
|
|
102
|
+
}
|
|
103
|
+
_formatViolationsForFeedback(results) {
|
|
104
|
+
return this._findViolations(results)
|
|
105
|
+
.map(v => `- [${v.criterionId}] ${v.text}: ${v.detail}`)
|
|
106
|
+
.join("\n");
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parse the verifier's free-text audit into structured ContractCheckResult[].
|
|
110
|
+
*
|
|
111
|
+
* The verifier is prompted to produce a structured PASS/FAIL per criterion.
|
|
112
|
+
* This parser handles the common patterns; callers can subclass and override
|
|
113
|
+
* for stricter parsing.
|
|
114
|
+
*/
|
|
115
|
+
_parseAuditText(auditText) {
|
|
116
|
+
const results = [];
|
|
117
|
+
const lower = auditText.toLowerCase();
|
|
118
|
+
for (const criterion of this.contract.acceptance) {
|
|
119
|
+
// Look for explicit "id: PASS" or "id: FAIL" patterns from the verifier prompt
|
|
120
|
+
const idPattern = new RegExp(`\\b${criterion.id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b[^\\n]*?(pass|fail)`, "i");
|
|
121
|
+
const match = auditText.match(idPattern);
|
|
122
|
+
if (match) {
|
|
123
|
+
const passed = match[1].toLowerCase() === "pass";
|
|
124
|
+
// Extract the line as evidence
|
|
125
|
+
const lineStart = auditText.lastIndexOf("\n", match.index ?? 0) + 1;
|
|
126
|
+
const lineEnd = auditText.indexOf("\n", match.index ?? 0);
|
|
127
|
+
const evidence = auditText.slice(lineStart, lineEnd > 0 ? lineEnd : undefined).trim();
|
|
128
|
+
results.push({ criterionId: criterion.id, passed, evidence });
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// Fallback: search for criterion text near PASS/FAIL keywords
|
|
132
|
+
const textIdx = lower.indexOf(criterion.text.toLowerCase().slice(0, 30));
|
|
133
|
+
if (textIdx !== -1) {
|
|
134
|
+
const window = lower.slice(textIdx, textIdx + 200);
|
|
135
|
+
const passed = window.includes("pass") && !window.includes("fail");
|
|
136
|
+
results.push({ criterionId: criterion.id, passed, evidence: "inferred from context" });
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// No mention found — conservative: treat as failed
|
|
140
|
+
results.push({
|
|
141
|
+
criterionId: criterion.id,
|
|
142
|
+
passed: false,
|
|
143
|
+
evidence: "criterion not mentioned in audit",
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return results;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { AcceptanceCriterion, VerificationContract, ContractCheckResult, } from "./contract.js";
|
|
2
|
+
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./contract.js";
|
|
3
|
+
export { AgentPool } from "./pool.js";
|
|
4
|
+
export type { AgentRole, IsolatedVerifierContext } from "./pool.js";
|
|
5
|
+
export { ContractDrivenHarness } from "./harness.js";
|
|
6
|
+
export type { ContractOutcome, ContractHarnessOptions, Violation, } from "./harness.js";
|
|
7
|
+
export { HandoffBus } from "./handoff.js";
|
|
8
|
+
export type { HandoffArtifact, ContractOutcomeInput } from "./handoff.js";
|
|
9
|
+
export { CreatorVerifierMode, OrchestrationMode } from "./modes/creator-verifier.js";
|
|
10
|
+
export type { CreatorVerifierMetrics } from "./modes/creator-verifier.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./contract.js";
|
|
2
|
+
// AgentPool
|
|
3
|
+
export { AgentPool } from "./pool.js";
|
|
4
|
+
// ContractDrivenHarness
|
|
5
|
+
export { ContractDrivenHarness } from "./harness.js";
|
|
6
|
+
// HandoffBus
|
|
7
|
+
export { HandoffBus } from "./handoff.js";
|
|
8
|
+
// Collaboration modes
|
|
9
|
+
export { CreatorVerifierMode, OrchestrationMode } from "./modes/creator-verifier.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { AgentPool } from "../pool.js";
|
|
2
|
+
import type { VerificationContract } from "../contract.js";
|
|
3
|
+
import type { ContractOutcome } from "../harness.js";
|
|
4
|
+
export interface CreatorVerifierMetrics {
|
|
5
|
+
total: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
driftRate: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* CreatorVerifierMode — the simplest multi-agent collaboration pattern.
|
|
11
|
+
*
|
|
12
|
+
* Wires an executor + verifier from an AgentPool into a ContractDrivenHarness.
|
|
13
|
+
* The executor creates, the verifier audits. Contexts are fully isolated.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```ts
|
|
17
|
+
* const pool = new AgentPool()
|
|
18
|
+
* .add("executor", new Agent(provider, { maxTokens: 32_000, skillDir }))
|
|
19
|
+
* .add("verifier", new Agent(provider, { maxTokens: 8_000 }))
|
|
20
|
+
*
|
|
21
|
+
* const mode = new CreatorVerifierMode(pool)
|
|
22
|
+
* const result = await mode.run(contract)
|
|
23
|
+
*
|
|
24
|
+
* if (HandoffBus.requiresEscalation(result.handoff)) {
|
|
25
|
+
* // drift > 5% or blocked_on is non-empty → pause autonomous delegation
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class CreatorVerifierMode {
|
|
30
|
+
private pool;
|
|
31
|
+
private options;
|
|
32
|
+
private _total;
|
|
33
|
+
private _failed;
|
|
34
|
+
constructor(pool: AgentPool, options?: {
|
|
35
|
+
maxAttempts?: number;
|
|
36
|
+
});
|
|
37
|
+
run(contract: VerificationContract): Promise<ContractOutcome>;
|
|
38
|
+
/** Aggregate drift metrics across all runs through this mode instance. */
|
|
39
|
+
getMetrics(): CreatorVerifierMetrics;
|
|
40
|
+
/**
|
|
41
|
+
* True when accumulated drift rate exceeds threshold.
|
|
42
|
+
* When true, pause autonomous delegation and surface to human or orchestrator.
|
|
43
|
+
*/
|
|
44
|
+
isDrifting(threshold?: number): boolean;
|
|
45
|
+
/** Reset accumulated metrics (e.g. at the start of a new sprint). */
|
|
46
|
+
resetMetrics(): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* OrchestrationMode — three-role collaboration: orchestrator → executor → verifier.
|
|
50
|
+
*
|
|
51
|
+
* The orchestrator produces a VerificationContract from a raw goal, then
|
|
52
|
+
* CreatorVerifierMode executes it.
|
|
53
|
+
*
|
|
54
|
+
* Requires all three roles in the pool: orchestrator, executor, verifier.
|
|
55
|
+
*/
|
|
56
|
+
export declare class OrchestrationMode {
|
|
57
|
+
private pool;
|
|
58
|
+
private options;
|
|
59
|
+
private inner;
|
|
60
|
+
constructor(pool: AgentPool, options?: {
|
|
61
|
+
maxAttempts?: number;
|
|
62
|
+
});
|
|
63
|
+
run(goal: string): Promise<ContractOutcome & {
|
|
64
|
+
contract: VerificationContract;
|
|
65
|
+
}>;
|
|
66
|
+
getMetrics(): CreatorVerifierMetrics;
|
|
67
|
+
isDrifting(threshold?: number): boolean;
|
|
68
|
+
private _parseContract;
|
|
69
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ContractDrivenHarness } from "../harness.js";
|
|
2
|
+
/**
|
|
3
|
+
* CreatorVerifierMode — the simplest multi-agent collaboration pattern.
|
|
4
|
+
*
|
|
5
|
+
* Wires an executor + verifier from an AgentPool into a ContractDrivenHarness.
|
|
6
|
+
* The executor creates, the verifier audits. Contexts are fully isolated.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```ts
|
|
10
|
+
* const pool = new AgentPool()
|
|
11
|
+
* .add("executor", new Agent(provider, { maxTokens: 32_000, skillDir }))
|
|
12
|
+
* .add("verifier", new Agent(provider, { maxTokens: 8_000 }))
|
|
13
|
+
*
|
|
14
|
+
* const mode = new CreatorVerifierMode(pool)
|
|
15
|
+
* const result = await mode.run(contract)
|
|
16
|
+
*
|
|
17
|
+
* if (HandoffBus.requiresEscalation(result.handoff)) {
|
|
18
|
+
* // drift > 5% or blocked_on is non-empty → pause autonomous delegation
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class CreatorVerifierMode {
|
|
23
|
+
pool;
|
|
24
|
+
options;
|
|
25
|
+
_total = 0;
|
|
26
|
+
_failed = 0;
|
|
27
|
+
constructor(pool, options = {}) {
|
|
28
|
+
this.pool = pool;
|
|
29
|
+
this.options = options;
|
|
30
|
+
}
|
|
31
|
+
async run(contract) {
|
|
32
|
+
this._total++;
|
|
33
|
+
const harness = new ContractDrivenHarness(this.pool, contract, {
|
|
34
|
+
maxAttempts: this.options.maxAttempts ?? 3,
|
|
35
|
+
});
|
|
36
|
+
const outcome = await harness.run();
|
|
37
|
+
if (!outcome.success) {
|
|
38
|
+
this._failed++;
|
|
39
|
+
}
|
|
40
|
+
return outcome;
|
|
41
|
+
}
|
|
42
|
+
/** Aggregate drift metrics across all runs through this mode instance. */
|
|
43
|
+
getMetrics() {
|
|
44
|
+
return {
|
|
45
|
+
total: this._total,
|
|
46
|
+
failed: this._failed,
|
|
47
|
+
driftRate: this._total > 0 ? this._failed / this._total : 0,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* True when accumulated drift rate exceeds threshold.
|
|
52
|
+
* When true, pause autonomous delegation and surface to human or orchestrator.
|
|
53
|
+
*/
|
|
54
|
+
isDrifting(threshold = 0.05) {
|
|
55
|
+
return this.getMetrics().driftRate > threshold;
|
|
56
|
+
}
|
|
57
|
+
/** Reset accumulated metrics (e.g. at the start of a new sprint). */
|
|
58
|
+
resetMetrics() {
|
|
59
|
+
this._total = 0;
|
|
60
|
+
this._failed = 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* OrchestrationMode — three-role collaboration: orchestrator → executor → verifier.
|
|
65
|
+
*
|
|
66
|
+
* The orchestrator produces a VerificationContract from a raw goal, then
|
|
67
|
+
* CreatorVerifierMode executes it.
|
|
68
|
+
*
|
|
69
|
+
* Requires all three roles in the pool: orchestrator, executor, verifier.
|
|
70
|
+
*/
|
|
71
|
+
export class OrchestrationMode {
|
|
72
|
+
pool;
|
|
73
|
+
options;
|
|
74
|
+
inner;
|
|
75
|
+
constructor(pool, options = {}) {
|
|
76
|
+
this.pool = pool;
|
|
77
|
+
this.options = options;
|
|
78
|
+
this.inner = new CreatorVerifierMode(pool, options);
|
|
79
|
+
}
|
|
80
|
+
async run(goal) {
|
|
81
|
+
// Step 1: orchestrator produces a VerificationContract
|
|
82
|
+
const contractJson = await this.pool.runOrchestrator(goal);
|
|
83
|
+
const contract = this._parseContract(contractJson, goal);
|
|
84
|
+
// Step 2: CreatorVerifierMode executes against the contract
|
|
85
|
+
const outcome = await this.inner.run(contract);
|
|
86
|
+
return { ...outcome, contract };
|
|
87
|
+
}
|
|
88
|
+
getMetrics() {
|
|
89
|
+
return this.inner.getMetrics();
|
|
90
|
+
}
|
|
91
|
+
isDrifting(threshold = 0.05) {
|
|
92
|
+
return this.inner.isDrifting(threshold);
|
|
93
|
+
}
|
|
94
|
+
_parseContract(json, fallbackGoal) {
|
|
95
|
+
try {
|
|
96
|
+
// Extract JSON block from markdown fences if present
|
|
97
|
+
const match = json.match(/```(?:json)?\s*([\s\S]*?)```/) ?? [null, json];
|
|
98
|
+
const raw = JSON.parse(match[1] ?? json);
|
|
99
|
+
return {
|
|
100
|
+
id: raw.id ?? "orchestrated",
|
|
101
|
+
goal: raw.goal ?? fallbackGoal,
|
|
102
|
+
acceptance: (raw.acceptance ?? []).map((c) => ({
|
|
103
|
+
id: String(c.id ?? "criterion"),
|
|
104
|
+
text: String(c.text ?? ""),
|
|
105
|
+
required: c.required !== false,
|
|
106
|
+
weight: Number(c.weight ?? 1.0),
|
|
107
|
+
machineCheckable: Boolean(c.machineCheckable ?? false),
|
|
108
|
+
})),
|
|
109
|
+
antiPatterns: (raw.antiPatterns ?? []).map(String),
|
|
110
|
+
evidenceRequired: (raw.evidenceRequired ?? []).map(String),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// Orchestrator produced unparseable output — return a minimal contract
|
|
115
|
+
return {
|
|
116
|
+
id: "fallback",
|
|
117
|
+
goal: fallbackGoal,
|
|
118
|
+
acceptance: [{ id: "complete", text: "Goal is satisfactorily completed", required: true, weight: 1.0, machineCheckable: false }],
|
|
119
|
+
antiPatterns: [],
|
|
120
|
+
evidenceRequired: [],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Agent } from "../agent.js";
|
|
2
|
+
import type { VerificationContract } from "./contract.js";
|
|
3
|
+
/**
|
|
4
|
+
* Roles in a multi-agent collaboration.
|
|
5
|
+
*
|
|
6
|
+
* - orchestrator: strong-reasoning, produces VerificationContracts; no tools beyond planning
|
|
7
|
+
* - executor: code/task execution, full tool access, sees goal + contract only
|
|
8
|
+
* - verifier: adversarial auditor, no tools, low temperature, sees artifact + contract only
|
|
9
|
+
*/
|
|
10
|
+
export type AgentRole = "orchestrator" | "executor" | "verifier";
|
|
11
|
+
/** Context passed to a verifier run — intentionally minimal. */
|
|
12
|
+
export interface IsolatedVerifierContext {
|
|
13
|
+
contract: VerificationContract;
|
|
14
|
+
/** The artifact produced by the executor. */
|
|
15
|
+
artifact: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* AgentPool manages a set of role-specific Agent instances.
|
|
19
|
+
*
|
|
20
|
+
* Each role runs in its own Agent instance with an independent history partition,
|
|
21
|
+
* ensuring that the verifier never sees the executor's implementation transcript.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```ts
|
|
25
|
+
* const pool = new AgentPool()
|
|
26
|
+
* .add("executor", executorAgent)
|
|
27
|
+
* .add("verifier", verifierAgent)
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class AgentPool {
|
|
31
|
+
private agents;
|
|
32
|
+
add(role: AgentRole, agent: Agent): this;
|
|
33
|
+
has(role: AgentRole): boolean;
|
|
34
|
+
get(role: AgentRole): Agent;
|
|
35
|
+
/**
|
|
36
|
+
* Run the verifier with an isolated context — only the artifact and contract.
|
|
37
|
+
* The verifier does NOT receive the executor's conversation history.
|
|
38
|
+
* Returns a structured audit response as a plain string.
|
|
39
|
+
*/
|
|
40
|
+
runVerifier(ctx: IsolatedVerifierContext): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Run the orchestrator to decompose a high-level goal into a VerificationContract.
|
|
43
|
+
* The orchestrator receives the goal and must produce a structured contract in JSON.
|
|
44
|
+
*/
|
|
45
|
+
runOrchestrator(goal: string): Promise<string>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { formatContractForSystemPrompt } from "./contract.js";
|
|
2
|
+
/**
|
|
3
|
+
* AgentPool manages a set of role-specific Agent instances.
|
|
4
|
+
*
|
|
5
|
+
* Each role runs in its own Agent instance with an independent history partition,
|
|
6
|
+
* ensuring that the verifier never sees the executor's implementation transcript.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```ts
|
|
10
|
+
* const pool = new AgentPool()
|
|
11
|
+
* .add("executor", executorAgent)
|
|
12
|
+
* .add("verifier", verifierAgent)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class AgentPool {
|
|
16
|
+
agents = new Map();
|
|
17
|
+
add(role, agent) {
|
|
18
|
+
this.agents.set(role, agent);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
has(role) {
|
|
22
|
+
return this.agents.has(role);
|
|
23
|
+
}
|
|
24
|
+
get(role) {
|
|
25
|
+
const agent = this.agents.get(role);
|
|
26
|
+
if (!agent)
|
|
27
|
+
throw new Error(`AgentPool: no agent registered for role "${role}"`);
|
|
28
|
+
return agent;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Run the verifier with an isolated context — only the artifact and contract.
|
|
32
|
+
* The verifier does NOT receive the executor's conversation history.
|
|
33
|
+
* Returns a structured audit response as a plain string.
|
|
34
|
+
*/
|
|
35
|
+
async runVerifier(ctx) {
|
|
36
|
+
const agent = this.get("verifier");
|
|
37
|
+
const contractBlock = formatContractForSystemPrompt(ctx.contract);
|
|
38
|
+
const auditGoal = [
|
|
39
|
+
contractBlock,
|
|
40
|
+
"",
|
|
41
|
+
"---",
|
|
42
|
+
"",
|
|
43
|
+
"## Artifact to Audit",
|
|
44
|
+
"",
|
|
45
|
+
ctx.artifact,
|
|
46
|
+
"",
|
|
47
|
+
"---",
|
|
48
|
+
"",
|
|
49
|
+
"Audit the artifact against every criterion in the contract above.",
|
|
50
|
+
"For each criterion, state whether it PASSED or FAILED and cite specific evidence.",
|
|
51
|
+
"List any anti-patterns you detected.",
|
|
52
|
+
"Conclude with an overall PASS or FAIL verdict.",
|
|
53
|
+
].join("\n");
|
|
54
|
+
return agent.run(auditGoal);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Run the orchestrator to decompose a high-level goal into a VerificationContract.
|
|
58
|
+
* The orchestrator receives the goal and must produce a structured contract in JSON.
|
|
59
|
+
*/
|
|
60
|
+
async runOrchestrator(goal) {
|
|
61
|
+
const agent = this.get("orchestrator");
|
|
62
|
+
const orchestratorGoal = [
|
|
63
|
+
`You are a planning orchestrator. Decompose the following goal into a VerificationContract.`,
|
|
64
|
+
``,
|
|
65
|
+
`Goal: ${goal}`,
|
|
66
|
+
``,
|
|
67
|
+
`Produce a JSON object with this schema:`,
|
|
68
|
+
`{`,
|
|
69
|
+
` "id": "<kebab-case-id>",`,
|
|
70
|
+
` "goal": "<restated goal>",`,
|
|
71
|
+
` "acceptance": [{ "id": "<id>", "text": "<criterion>", "required": true, "weight": 0.x, "machineCheckable": false }],`,
|
|
72
|
+
` "antiPatterns": ["<pattern>"],`,
|
|
73
|
+
` "evidenceRequired": ["<evidence item>"]`,
|
|
74
|
+
`}`,
|
|
75
|
+
``,
|
|
76
|
+
`Output ONLY the JSON object, no prose.`,
|
|
77
|
+
].join("\n");
|
|
78
|
+
return agent.run(orchestratorGoal);
|
|
79
|
+
}
|
|
80
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -32,3 +32,13 @@ export type { PermissionDecision, Permission } from "./safety/permissions.js";
|
|
|
32
32
|
export { Governance } from "./governance.js";
|
|
33
33
|
export type { GovernanceVerdict } from "./governance.js";
|
|
34
34
|
export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolResultEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, LLMProvider, RetryConfig, TokenUsage, ProviderToolSpec, ProviderRunState, } from "./types.js";
|
|
35
|
+
export type { AcceptanceCriterion, VerificationContract, ContractCheckResult, } from "./collaboration/contract.js";
|
|
36
|
+
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./collaboration/contract.js";
|
|
37
|
+
export { AgentPool } from "./collaboration/pool.js";
|
|
38
|
+
export type { AgentRole, IsolatedVerifierContext } from "./collaboration/pool.js";
|
|
39
|
+
export { ContractDrivenHarness } from "./collaboration/harness.js";
|
|
40
|
+
export type { ContractOutcome, ContractHarnessOptions, Violation } from "./collaboration/harness.js";
|
|
41
|
+
export { HandoffBus } from "./collaboration/handoff.js";
|
|
42
|
+
export type { HandoffArtifact, ContractOutcomeInput } from "./collaboration/handoff.js";
|
|
43
|
+
export { CreatorVerifierMode, OrchestrationMode } from "./collaboration/modes/creator-verifier.js";
|
|
44
|
+
export type { CreatorVerifierMetrics } from "./collaboration/modes/creator-verifier.js";
|
package/dist/index.js
CHANGED
|
@@ -20,3 +20,8 @@ export { ScheduledPrompt } from "./signals/scheduled.js";
|
|
|
20
20
|
export { SignalGateway } from "./signals/gateway.js";
|
|
21
21
|
export { PermissionManager, PermissionMode } from "./safety/permissions.js";
|
|
22
22
|
export { Governance } from "./governance.js";
|
|
23
|
+
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./collaboration/contract.js";
|
|
24
|
+
export { AgentPool } from "./collaboration/pool.js";
|
|
25
|
+
export { ContractDrivenHarness } from "./collaboration/harness.js";
|
|
26
|
+
export { HandoffBus } from "./collaboration/handoff.js";
|
|
27
|
+
export { CreatorVerifierMode, OrchestrationMode } from "./collaboration/modes/creator-verifier.js";
|
package/dist/skills/loader.js
CHANGED
|
@@ -28,10 +28,10 @@ export async function scanSkillDir(skillDir) {
|
|
|
28
28
|
const results = [];
|
|
29
29
|
for (const file of files.filter(f => f.endsWith(".md"))) {
|
|
30
30
|
const name = file.slice(0, -3);
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
31
|
+
const raw = await readFile(path.join(skillDir, `${name}.md`), "utf8").catch(() => null);
|
|
32
|
+
if (!raw)
|
|
33
33
|
continue;
|
|
34
|
-
const { meta } = parseFrontmatter(
|
|
34
|
+
const { meta } = parseFrontmatter(raw);
|
|
35
35
|
results.push({
|
|
36
36
|
name: meta.name ? String(meta.name) : name,
|
|
37
37
|
description: meta.description ? String(meta.description) : "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "DeepStrike Node.js SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
19
|
-
"@deepstrike/core": "0.1.
|
|
19
|
+
"@deepstrike/core": "0.1.11",
|
|
20
20
|
"@google/generative-ai": "^0.24.1",
|
|
21
21
|
"openai": "^4.77.0"
|
|
22
22
|
},
|