@pythonluvr/openwar 0.4.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/LICENSE +21 -0
- package/README.md +297 -0
- package/bin/openwar +45 -0
- package/dist/adapters/anthropic.d.ts +15 -0
- package/dist/adapters/anthropic.d.ts.map +1 -0
- package/dist/adapters/anthropic.js +179 -0
- package/dist/adapters/anthropic.js.map +1 -0
- package/dist/adapters/gemini.d.ts +15 -0
- package/dist/adapters/gemini.d.ts.map +1 -0
- package/dist/adapters/gemini.js +141 -0
- package/dist/adapters/gemini.js.map +1 -0
- package/dist/adapters/grok.d.ts +6 -0
- package/dist/adapters/grok.d.ts.map +1 -0
- package/dist/adapters/grok.js +15 -0
- package/dist/adapters/grok.js.map +1 -0
- package/dist/adapters/index.d.ts +16 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +35 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/mock.d.ts +17 -0
- package/dist/adapters/mock.d.ts.map +1 -0
- package/dist/adapters/mock.js +33 -0
- package/dist/adapters/mock.js.map +1 -0
- package/dist/adapters/openai-compat.d.ts +6 -0
- package/dist/adapters/openai-compat.d.ts.map +1 -0
- package/dist/adapters/openai-compat.js +19 -0
- package/dist/adapters/openai-compat.js.map +1 -0
- package/dist/adapters/openai.d.ts +23 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +176 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/adapters/sse.d.ts +6 -0
- package/dist/adapters/sse.d.ts.map +1 -0
- package/dist/adapters/sse.js +45 -0
- package/dist/adapters/sse.js.map +1 -0
- package/dist/adapters/types.d.ts +7 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/auth/categories.d.ts +13 -0
- package/dist/auth/categories.d.ts.map +1 -0
- package/dist/auth/categories.js +47 -0
- package/dist/auth/categories.js.map +1 -0
- package/dist/auth/check.d.ts +31 -0
- package/dist/auth/check.d.ts.map +1 -0
- package/dist/auth/check.js +59 -0
- package/dist/auth/check.js.map +1 -0
- package/dist/auth/role-scope.d.ts +18 -0
- package/dist/auth/role-scope.d.ts.map +1 -0
- package/dist/auth/role-scope.js +62 -0
- package/dist/auth/role-scope.js.map +1 -0
- package/dist/auth/wildcards.d.ts +5 -0
- package/dist/auth/wildcards.d.ts.map +1 -0
- package/dist/auth/wildcards.js +36 -0
- package/dist/auth/wildcards.js.map +1 -0
- package/dist/brief.d.ts +9 -0
- package/dist/brief.d.ts.map +1 -0
- package/dist/brief.js +514 -0
- package/dist/brief.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +585 -0
- package/dist/cli.js.map +1 -0
- package/dist/coordinator/cost-tracker.d.ts +14 -0
- package/dist/coordinator/cost-tracker.d.ts.map +1 -0
- package/dist/coordinator/cost-tracker.js +63 -0
- package/dist/coordinator/cost-tracker.js.map +1 -0
- package/dist/coordinator/driver.d.ts +37 -0
- package/dist/coordinator/driver.d.ts.map +1 -0
- package/dist/coordinator/driver.js +644 -0
- package/dist/coordinator/driver.js.map +1 -0
- package/dist/coordinator/index.d.ts +14 -0
- package/dist/coordinator/index.d.ts.map +1 -0
- package/dist/coordinator/index.js +8 -0
- package/dist/coordinator/index.js.map +1 -0
- package/dist/coordinator/plan-parser.d.ts +17 -0
- package/dist/coordinator/plan-parser.d.ts.map +1 -0
- package/dist/coordinator/plan-parser.js +44 -0
- package/dist/coordinator/plan-parser.js.map +1 -0
- package/dist/coordinator/result-aggregator.d.ts +21 -0
- package/dist/coordinator/result-aggregator.d.ts.map +1 -0
- package/dist/coordinator/result-aggregator.js +58 -0
- package/dist/coordinator/result-aggregator.js.map +1 -0
- package/dist/coordinator/retry-policy.d.ts +7 -0
- package/dist/coordinator/retry-policy.d.ts.map +1 -0
- package/dist/coordinator/retry-policy.js +17 -0
- package/dist/coordinator/retry-policy.js.map +1 -0
- package/dist/coordinator/state-machine.d.ts +63 -0
- package/dist/coordinator/state-machine.d.ts.map +1 -0
- package/dist/coordinator/state-machine.js +242 -0
- package/dist/coordinator/state-machine.js.map +1 -0
- package/dist/coordinator/types.d.ts +3 -0
- package/dist/coordinator/types.d.ts.map +1 -0
- package/dist/coordinator/types.js +5 -0
- package/dist/coordinator/types.js.map +1 -0
- package/dist/detectors/banned-phrases.d.ts +3 -0
- package/dist/detectors/banned-phrases.d.ts.map +1 -0
- package/dist/detectors/banned-phrases.js +33 -0
- package/dist/detectors/banned-phrases.js.map +1 -0
- package/dist/detectors/blocker.d.ts +3 -0
- package/dist/detectors/blocker.d.ts.map +1 -0
- package/dist/detectors/blocker.js +62 -0
- package/dist/detectors/blocker.js.map +1 -0
- package/dist/detectors/completion.d.ts +3 -0
- package/dist/detectors/completion.d.ts.map +1 -0
- package/dist/detectors/completion.js +17 -0
- package/dist/detectors/completion.js.map +1 -0
- package/dist/detectors/confirmation-summary.d.ts +3 -0
- package/dist/detectors/confirmation-summary.d.ts.map +1 -0
- package/dist/detectors/confirmation-summary.js +76 -0
- package/dist/detectors/confirmation-summary.js.map +1 -0
- package/dist/detectors/destructive.d.ts +3 -0
- package/dist/detectors/destructive.d.ts.map +1 -0
- package/dist/detectors/destructive.js +96 -0
- package/dist/detectors/destructive.js.map +1 -0
- package/dist/detectors/index.d.ts +12 -0
- package/dist/detectors/index.d.ts.map +1 -0
- package/dist/detectors/index.js +19 -0
- package/dist/detectors/index.js.map +1 -0
- package/dist/detectors/phase-marker.d.ts +3 -0
- package/dist/detectors/phase-marker.d.ts.map +1 -0
- package/dist/detectors/phase-marker.js +25 -0
- package/dist/detectors/phase-marker.js.map +1 -0
- package/dist/framework.d.ts +2 -0
- package/dist/framework.d.ts.map +1 -0
- package/dist/framework.js +34 -0
- package/dist/framework.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +25 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +83 -0
- package/dist/io.js.map +1 -0
- package/dist/mcp/client.d.ts +22 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +44 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +6 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/registry.d.ts +16 -0
- package/dist/mcp/registry.d.ts.map +1 -0
- package/dist/mcp/registry.js +53 -0
- package/dist/mcp/registry.js.map +1 -0
- package/dist/mcp/transport-stdio.d.ts +26 -0
- package/dist/mcp/transport-stdio.d.ts.map +1 -0
- package/dist/mcp/transport-stdio.js +138 -0
- package/dist/mcp/transport-stdio.js.map +1 -0
- package/dist/mcp/types.d.ts +90 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +23 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/orchestration/handoff.d.ts +27 -0
- package/dist/orchestration/handoff.d.ts.map +1 -0
- package/dist/orchestration/handoff.js +322 -0
- package/dist/orchestration/handoff.js.map +1 -0
- package/dist/phases/blocker.d.ts +8 -0
- package/dist/phases/blocker.d.ts.map +1 -0
- package/dist/phases/blocker.js +11 -0
- package/dist/phases/blocker.js.map +1 -0
- package/dist/phases/completion.d.ts +10 -0
- package/dist/phases/completion.d.ts.map +1 -0
- package/dist/phases/completion.js +47 -0
- package/dist/phases/completion.js.map +1 -0
- package/dist/phases/destructive.d.ts +10 -0
- package/dist/phases/destructive.d.ts.map +1 -0
- package/dist/phases/destructive.js +31 -0
- package/dist/phases/destructive.js.map +1 -0
- package/dist/phases/execute.d.ts +30 -0
- package/dist/phases/execute.d.ts.map +1 -0
- package/dist/phases/execute.js +222 -0
- package/dist/phases/execute.js.map +1 -0
- package/dist/phases/intake.d.ts +16 -0
- package/dist/phases/intake.d.ts.map +1 -0
- package/dist/phases/intake.js +105 -0
- package/dist/phases/intake.js.map +1 -0
- package/dist/roles/critic.d.ts +3 -0
- package/dist/roles/critic.d.ts.map +1 -0
- package/dist/roles/critic.js +35 -0
- package/dist/roles/critic.js.map +1 -0
- package/dist/roles/executor.d.ts +3 -0
- package/dist/roles/executor.d.ts.map +1 -0
- package/dist/roles/executor.js +46 -0
- package/dist/roles/executor.js.map +1 -0
- package/dist/roles/index.d.ts +8 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +8 -0
- package/dist/roles/index.js.map +1 -0
- package/dist/roles/planner.d.ts +3 -0
- package/dist/roles/planner.d.ts.map +1 -0
- package/dist/roles/planner.js +50 -0
- package/dist/roles/planner.js.map +1 -0
- package/dist/roles/prompt-overlay.d.ts +9 -0
- package/dist/roles/prompt-overlay.d.ts.map +1 -0
- package/dist/roles/prompt-overlay.js +25 -0
- package/dist/roles/prompt-overlay.js.map +1 -0
- package/dist/roles/registry.d.ts +8 -0
- package/dist/roles/registry.d.ts.map +1 -0
- package/dist/roles/registry.js +45 -0
- package/dist/roles/registry.js.map +1 -0
- package/dist/roles/reviewer.d.ts +3 -0
- package/dist/roles/reviewer.d.ts.map +1 -0
- package/dist/roles/reviewer.js +46 -0
- package/dist/roles/reviewer.js.map +1 -0
- package/dist/roles/types.d.ts +2 -0
- package/dist/roles/types.d.ts.map +1 -0
- package/dist/roles/types.js +4 -0
- package/dist/roles/types.js.map +1 -0
- package/dist/runner.d.ts +3 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +473 -0
- package/dist/runner.js.map +1 -0
- package/dist/sandbox/host-allowlist.d.ts +13 -0
- package/dist/sandbox/host-allowlist.d.ts.map +1 -0
- package/dist/sandbox/host-allowlist.js +85 -0
- package/dist/sandbox/host-allowlist.js.map +1 -0
- package/dist/sandbox/output-cap.d.ts +9 -0
- package/dist/sandbox/output-cap.d.ts.map +1 -0
- package/dist/sandbox/output-cap.js +66 -0
- package/dist/sandbox/output-cap.js.map +1 -0
- package/dist/sandbox/timeout.d.ts +7 -0
- package/dist/sandbox/timeout.d.ts.map +1 -0
- package/dist/sandbox/timeout.js +52 -0
- package/dist/sandbox/timeout.js.map +1 -0
- package/dist/sandbox/types.d.ts +18 -0
- package/dist/sandbox/types.d.ts.map +1 -0
- package/dist/sandbox/types.js +27 -0
- package/dist/sandbox/types.js.map +1 -0
- package/dist/sandbox/workdir.d.ts +9 -0
- package/dist/sandbox/workdir.d.ts.map +1 -0
- package/dist/sandbox/workdir.js +83 -0
- package/dist/sandbox/workdir.js.map +1 -0
- package/dist/state/index.d.ts +4 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/paths.d.ts +5 -0
- package/dist/state/paths.d.ts.map +1 -0
- package/dist/state/paths.js +18 -0
- package/dist/state/paths.js.map +1 -0
- package/dist/state/persist.d.ts +14 -0
- package/dist/state/persist.d.ts.map +1 -0
- package/dist/state/persist.js +146 -0
- package/dist/state/persist.js.map +1 -0
- package/dist/state/transcript.d.ts +9 -0
- package/dist/state/transcript.d.ts.map +1 -0
- package/dist/state/transcript.js +34 -0
- package/dist/state/transcript.js.map +1 -0
- package/dist/tools/native/apply_patch.d.ts +18 -0
- package/dist/tools/native/apply_patch.d.ts.map +1 -0
- package/dist/tools/native/apply_patch.js +245 -0
- package/dist/tools/native/apply_patch.js.map +1 -0
- package/dist/tools/native/http_fetch.d.ts +6 -0
- package/dist/tools/native/http_fetch.d.ts.map +1 -0
- package/dist/tools/native/http_fetch.js +168 -0
- package/dist/tools/native/http_fetch.js.map +1 -0
- package/dist/tools/native/index.d.ts +9 -0
- package/dist/tools/native/index.d.ts.map +1 -0
- package/dist/tools/native/index.js +22 -0
- package/dist/tools/native/index.js.map +1 -0
- package/dist/tools/native/list_dir.d.ts +4 -0
- package/dist/tools/native/list_dir.d.ts.map +1 -0
- package/dist/tools/native/list_dir.js +175 -0
- package/dist/tools/native/list_dir.js.map +1 -0
- package/dist/tools/native/read_file.d.ts +4 -0
- package/dist/tools/native/read_file.d.ts.map +1 -0
- package/dist/tools/native/read_file.js +91 -0
- package/dist/tools/native/read_file.js.map +1 -0
- package/dist/tools/native/shell_exec.d.ts +4 -0
- package/dist/tools/native/shell_exec.d.ts.map +1 -0
- package/dist/tools/native/shell_exec.js +180 -0
- package/dist/tools/native/shell_exec.js.map +1 -0
- package/dist/tools/native/write_file.d.ts +4 -0
- package/dist/tools/native/write_file.d.ts.map +1 -0
- package/dist/tools/native/write_file.js +101 -0
- package/dist/tools/native/write_file.js.map +1 -0
- package/dist/tools/types.d.ts +48 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +10 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types.d.ts +385 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/examples/README.md +73 -0
- package/examples/creative-brief.md +34 -0
- package/examples/critic-disagreement-brief.md +42 -0
- package/examples/engineering-brief.md +35 -0
- package/examples/file-editing-brief.md +33 -0
- package/examples/mcp-brief.md +34 -0
- package/examples/multi-agent-brief.md +43 -0
- package/examples/research-brief.md +35 -0
- package/openwar.md +248 -0
- package/package.json +76 -0
- package/templates/brief.md +62 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { snapshot } from "../detectors/index.js";
|
|
2
|
+
import { checkAuthorization } from "../auth/check.js";
|
|
3
|
+
const DEFAULT_MAX_STEPS = 30;
|
|
4
|
+
const DEFAULT_MAX_TOOL_ROUNDS_PER_STEP = 3;
|
|
5
|
+
const PHASE_1_KICKOFF = `
|
|
6
|
+
The Confirmation Summary has been accepted. Begin Phase 1: Execution.
|
|
7
|
+
|
|
8
|
+
Execute the brief one step at a time. After each step, briefly state what you did and what's next.
|
|
9
|
+
Surface decision points and meaningful checkpoints. Flag blockers (Phase 2) and any
|
|
10
|
+
destructive or out-of-directive actions (Phase 3) before performing them.
|
|
11
|
+
`.trim();
|
|
12
|
+
export async function runExecute(opts) {
|
|
13
|
+
const { brief, adapter, system, io, mode, signal, onMessage } = opts;
|
|
14
|
+
const maxSteps = opts.maxSteps ?? DEFAULT_MAX_STEPS;
|
|
15
|
+
const maxToolRounds = opts.maxToolRoundsPerStep ?? DEFAULT_MAX_TOOL_ROUNDS_PER_STEP;
|
|
16
|
+
const history = [...opts.history];
|
|
17
|
+
const hasTools = (opts.toolDefinitions?.length ?? 0) > 0 && !!opts.toolExecutors && !!opts.sandbox;
|
|
18
|
+
io.banner(`Phase 1: Execution (${mode})${hasTools ? ` [tools: ${opts.toolDefinitions.length}]` : ""}`);
|
|
19
|
+
const kickoff = {
|
|
20
|
+
role: "user",
|
|
21
|
+
content: mode === "auto"
|
|
22
|
+
? `${PHASE_1_KICKOFF}\n\nMode: auto-pilot. Execute clean steps without asking; only stop for blockers (Phase 2) or destructive / out-of-directive actions (Phase 3).`
|
|
23
|
+
: `${PHASE_1_KICKOFF}\n\nMode: per-step gating. After each step, wait for the operator's "ok" before continuing.`,
|
|
24
|
+
at: new Date().toISOString(),
|
|
25
|
+
meta: { phase: "execute", step_index: 0 },
|
|
26
|
+
};
|
|
27
|
+
history.push(kickoff);
|
|
28
|
+
onMessage?.(kickoff);
|
|
29
|
+
for (let step = 0; step < maxSteps; step++) {
|
|
30
|
+
// ---- Inner tool-call loop. Multiple LLM turns may happen per step if
|
|
31
|
+
// the model calls tools, we run them, and the model continues. ----
|
|
32
|
+
let priorToolCalls = [];
|
|
33
|
+
let priorToolResults = [];
|
|
34
|
+
let stepText = "";
|
|
35
|
+
let roundsThisStep = 0;
|
|
36
|
+
while (true) {
|
|
37
|
+
const collected = await streamAndCollect(adapter, system, history, io, opts.toolDefinitions, priorToolCalls, priorToolResults, signal);
|
|
38
|
+
stepText = collected.text;
|
|
39
|
+
if (collected.toolCalls.length === 0)
|
|
40
|
+
break;
|
|
41
|
+
// Authorization check across all calls. Any unauthorized call halts.
|
|
42
|
+
for (const call of collected.toolCalls) {
|
|
43
|
+
const toolDef = opts.toolDefinitions.find(t => t.name === call.name);
|
|
44
|
+
if (!toolDef) {
|
|
45
|
+
// Unknown tool. Surface as a denial-style tool result for the LLM
|
|
46
|
+
// to react to (not a Phase 3, just an error).
|
|
47
|
+
priorToolCalls = [...collected.toolCalls];
|
|
48
|
+
priorToolResults = collected.toolCalls.map(c => ({
|
|
49
|
+
call_id: c.id,
|
|
50
|
+
content: `Tool "${c.name}" is not registered.`,
|
|
51
|
+
is_error: true,
|
|
52
|
+
}));
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const decision = checkAuthorization({
|
|
56
|
+
tool: toolDef,
|
|
57
|
+
authorizedCosts: brief.frontmatter.authorized_costs,
|
|
58
|
+
sessionApproved: opts.sessionApproved ?? [],
|
|
59
|
+
});
|
|
60
|
+
if (!decision.allowed) {
|
|
61
|
+
return {
|
|
62
|
+
history,
|
|
63
|
+
outcome: "destructive_denied",
|
|
64
|
+
reason: `tool "${call.name}" requires unauthorized categories: ${decision.missing_categories.join(", ")}`,
|
|
65
|
+
destructive_tool_call: call,
|
|
66
|
+
destructive_missing_categories: decision.missing_categories,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Execute each call sequentially via its executor.
|
|
71
|
+
priorToolCalls = collected.toolCalls;
|
|
72
|
+
priorToolResults = [];
|
|
73
|
+
for (const call of collected.toolCalls) {
|
|
74
|
+
const executor = opts.toolExecutors.get(call.name);
|
|
75
|
+
if (!executor) {
|
|
76
|
+
priorToolResults.push({
|
|
77
|
+
call_id: call.id,
|
|
78
|
+
content: `Tool "${call.name}" has no executor registered.`,
|
|
79
|
+
is_error: true,
|
|
80
|
+
});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
io.write(`\n→ ${call.name}(${JSON.stringify(call.arguments).slice(0, 120)})\n`);
|
|
84
|
+
const result = await executor(call, opts.sandbox);
|
|
85
|
+
const round = {
|
|
86
|
+
call_id: call.id,
|
|
87
|
+
content: result.content,
|
|
88
|
+
...(result.success ? {} : { is_error: true }),
|
|
89
|
+
};
|
|
90
|
+
priorToolResults.push(round);
|
|
91
|
+
opts.onToolCall?.(call, round);
|
|
92
|
+
io.write(` ↳ ${result.success ? "ok" : "error"} (${result.meta?.duration_ms ?? 0}ms)\n`);
|
|
93
|
+
}
|
|
94
|
+
// Persist the round in transcript history as assistant + tool messages.
|
|
95
|
+
const assistantToolUseMsg = {
|
|
96
|
+
role: "assistant",
|
|
97
|
+
content: stepText + (stepText && priorToolCalls.length ? "\n" : "") +
|
|
98
|
+
priorToolCalls.map(c => `[tool: ${c.name}(${JSON.stringify(c.arguments)})]`).join("\n"),
|
|
99
|
+
at: new Date().toISOString(),
|
|
100
|
+
meta: { phase: "execute", step_index: step + 1 },
|
|
101
|
+
};
|
|
102
|
+
history.push(assistantToolUseMsg);
|
|
103
|
+
onMessage?.(assistantToolUseMsg);
|
|
104
|
+
for (const r of priorToolResults) {
|
|
105
|
+
const m = {
|
|
106
|
+
role: "user",
|
|
107
|
+
content: `[tool_result ${r.call_id}${r.is_error ? " (error)" : ""}]\n${r.content}`,
|
|
108
|
+
at: new Date().toISOString(),
|
|
109
|
+
meta: { phase: "execute", step_index: step + 1 },
|
|
110
|
+
};
|
|
111
|
+
history.push(m);
|
|
112
|
+
onMessage?.(m);
|
|
113
|
+
}
|
|
114
|
+
roundsThisStep++;
|
|
115
|
+
if (roundsThisStep >= maxToolRounds) {
|
|
116
|
+
io.warn(`Tool-call round cap reached for step ${step + 1}.`);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
// Next inner-loop iteration: send the LLM the tool results.
|
|
120
|
+
}
|
|
121
|
+
// ---- Detector pass on the final assistant text of this step. ----
|
|
122
|
+
const detectors = snapshot(stepText, {
|
|
123
|
+
authorized_costs: brief.frontmatter.authorized_costs,
|
|
124
|
+
});
|
|
125
|
+
const assistant = {
|
|
126
|
+
role: "assistant",
|
|
127
|
+
content: stepText,
|
|
128
|
+
at: new Date().toISOString(),
|
|
129
|
+
meta: { phase: "execute", step_index: step + 1, detectors },
|
|
130
|
+
};
|
|
131
|
+
history.push(assistant);
|
|
132
|
+
onMessage?.(assistant);
|
|
133
|
+
if (detectors.banned_phrases && detectors.banned_phrases.count > 0) {
|
|
134
|
+
io.warn(`Voice rules: ${detectors.banned_phrases.count} banned phrase(s) detected: ${detectors.banned_phrases.phrases.join(", ")}`);
|
|
135
|
+
}
|
|
136
|
+
if (detectors.blocker?.blocked) {
|
|
137
|
+
return {
|
|
138
|
+
history,
|
|
139
|
+
outcome: "blocker",
|
|
140
|
+
reason: detectors.blocker.reason ?? "unspecified blocker",
|
|
141
|
+
blocking_detectors: detectors,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (detectors.destructive?.destructive && !detectors.destructive.authorized) {
|
|
145
|
+
return {
|
|
146
|
+
history,
|
|
147
|
+
outcome: "destructive_denied",
|
|
148
|
+
reason: detectors.destructive.action ?? "destructive intent",
|
|
149
|
+
blocking_detectors: detectors,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (detectors.completion?.complete) {
|
|
153
|
+
return { history, outcome: "completion" };
|
|
154
|
+
}
|
|
155
|
+
if (mode === "gated") {
|
|
156
|
+
const reply = await io.prompt('Continue? Type "ok"/"go" to proceed, "done" to finish, or send a redirect:');
|
|
157
|
+
const lower = reply.trim().toLowerCase();
|
|
158
|
+
if (lower === "done" || lower === "stop" || lower === "halt") {
|
|
159
|
+
return { history, outcome: "operator_done", reason: reply };
|
|
160
|
+
}
|
|
161
|
+
const next = {
|
|
162
|
+
role: "user",
|
|
163
|
+
content: lower === "" || /^(ok|go|continue|next|proceed|y|yes)$/.test(lower)
|
|
164
|
+
? "Continue with the next step."
|
|
165
|
+
: reply,
|
|
166
|
+
at: new Date().toISOString(),
|
|
167
|
+
meta: { phase: "execute", step_index: step + 1 },
|
|
168
|
+
};
|
|
169
|
+
history.push(next);
|
|
170
|
+
onMessage?.(next);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const next = {
|
|
174
|
+
role: "user",
|
|
175
|
+
content: "Continue with the next step. If the brief is complete, declare Phase 4 and stop.",
|
|
176
|
+
at: new Date().toISOString(),
|
|
177
|
+
meta: { phase: "execute", step_index: step + 1 },
|
|
178
|
+
};
|
|
179
|
+
history.push(next);
|
|
180
|
+
onMessage?.(next);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return { history, outcome: "max_steps", reason: `reached max_steps=${maxSteps}` };
|
|
184
|
+
}
|
|
185
|
+
async function streamAndCollect(adapter, system, messages, io, tools, priorToolCalls, priorToolResults, signal) {
|
|
186
|
+
let assembled = "";
|
|
187
|
+
const toolCalls = [];
|
|
188
|
+
for await (const ev of adapter.sendMessage({
|
|
189
|
+
system,
|
|
190
|
+
messages,
|
|
191
|
+
...(tools && tools.length > 0 && { tools }),
|
|
192
|
+
...(priorToolCalls.length > 0 && { prior_tool_calls: priorToolCalls }),
|
|
193
|
+
...(priorToolResults.length > 0 && { prior_tool_results: priorToolResults }),
|
|
194
|
+
...(signal ? { signal } : {}),
|
|
195
|
+
})) {
|
|
196
|
+
if (ev.type === "text_delta") {
|
|
197
|
+
io.write(ev.delta);
|
|
198
|
+
assembled += ev.delta;
|
|
199
|
+
}
|
|
200
|
+
else if (ev.type === "tool_call_complete") {
|
|
201
|
+
toolCalls.push(ev.call);
|
|
202
|
+
}
|
|
203
|
+
else if (ev.type === "done") {
|
|
204
|
+
io.write("\n");
|
|
205
|
+
if (ev.message && ev.message.length >= assembled.length) {
|
|
206
|
+
assembled = ev.message;
|
|
207
|
+
}
|
|
208
|
+
if (ev.tool_calls) {
|
|
209
|
+
for (const c of ev.tool_calls) {
|
|
210
|
+
if (!toolCalls.some(existing => existing.id === c.id))
|
|
211
|
+
toolCalls.push(c);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { text: assembled, toolCalls };
|
|
215
|
+
}
|
|
216
|
+
else if (ev.type === "error") {
|
|
217
|
+
throw ev.error;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return { text: assembled, toolCalls };
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/phases/execute.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAmCtD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAE3C,MAAM,eAAe,GAAG;;;;;;CAMvB,CAAC,IAAI,EAAE,CAAC;AAOT,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAiB;IAChD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACpD,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,IAAI,gCAAgC,CAAC;IACpF,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAEnG,EAAE,CAAC,MAAM,CAAC,uBAAuB,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,eAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAExG,MAAM,OAAO,GAAY;QACvB,IAAI,EAAE,M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,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;wBAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAC3E,CAAC;YACH,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QACxC,CAAC;aAAM,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC/B,MAAM,EAAE,CAAC,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentAdapter, Brief, Message, RunnerIO } from "../types.js";
|
|
2
|
+
export interface IntakeResult {
|
|
3
|
+
accepted: boolean;
|
|
4
|
+
operator_reply: string;
|
|
5
|
+
assistant_message: Message;
|
|
6
|
+
brief_prompt: Message;
|
|
7
|
+
}
|
|
8
|
+
export interface IntakeOpts {
|
|
9
|
+
brief: Brief;
|
|
10
|
+
adapter: AgentAdapter;
|
|
11
|
+
system: string;
|
|
12
|
+
io: RunnerIO;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
export declare function runIntake(opts: IntakeOpts): Promise<IntakeResult>;
|
|
16
|
+
//# sourceMappingURL=intake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intake.d.ts","sourceRoot":"","sources":["../../src/phases/intake.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,KAAK,EACL,OAAO,EACP,QAAQ,EAET,MAAM,aAAa,CAAC;AAKrB,MAAM,WAAW,YAAY;IAE3B,QAAQ,EAAE,OAAO,CAAC;IAGlB,cAAc,EAAE,MAAM,CAAC;IAEvB,iBAAiB,EAAE,OAAO,CAAC;IAE3B,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAiBD,wBAAsB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAwEvE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { renderBriefForAgent } from "../brief.js";
|
|
2
|
+
import { detectConfirmationSummary, snapshot } from "../detectors/index.js";
|
|
3
|
+
const INTAKE_INSTRUCTION = `
|
|
4
|
+
You have just received a brief under the OpenWar framework. Execute Phase 0 (Brief Intake) now.
|
|
5
|
+
|
|
6
|
+
1. Read the entire brief.
|
|
7
|
+
2. Produce a Confirmation Summary with these sections, in this order:
|
|
8
|
+
- Objective
|
|
9
|
+
- Deliverables
|
|
10
|
+
- Constraints
|
|
11
|
+
- Tools required
|
|
12
|
+
- Unknowns
|
|
13
|
+
3. End by asking which execution mode the operator wants (per-step gating or auto-pilot), unless the brief's frontmatter already specifies mode.
|
|
14
|
+
|
|
15
|
+
Do not begin execution. Stop after the Confirmation Summary and wait for the operator.
|
|
16
|
+
`.trim();
|
|
17
|
+
export async function runIntake(opts) {
|
|
18
|
+
const { brief, adapter, system, io, signal } = opts;
|
|
19
|
+
const briefBody = renderBriefForAgent(brief);
|
|
20
|
+
const briefPrompt = {
|
|
21
|
+
role: "user",
|
|
22
|
+
content: `${briefBody}\n\n---\n\n${INTAKE_INSTRUCTION}\n`,
|
|
23
|
+
at: new Date().toISOString(),
|
|
24
|
+
meta: { phase: "intake", step_index: 0 },
|
|
25
|
+
};
|
|
26
|
+
io.banner("Phase 0: Brief intake");
|
|
27
|
+
const assistantText = await streamAndCollect(adapter, system, [briefPrompt], io, signal);
|
|
28
|
+
let assistantMessage = {
|
|
29
|
+
role: "assistant",
|
|
30
|
+
content: assistantText,
|
|
31
|
+
at: new Date().toISOString(),
|
|
32
|
+
meta: {
|
|
33
|
+
phase: "intake",
|
|
34
|
+
step_index: 0,
|
|
35
|
+
detectors: snapshot(assistantText, { authorized_costs: brief.frontmatter.authorized_costs }),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
// If the model skipped the Confirmation Summary shape, nudge it once.
|
|
39
|
+
const conf = detectConfirmationSummary(assistantText);
|
|
40
|
+
if (!conf.found) {
|
|
41
|
+
io.warn("Confirmation Summary not detected in agent reply. Asking the model to restate in OpenWar shape.");
|
|
42
|
+
const nudge = {
|
|
43
|
+
role: "user",
|
|
44
|
+
content: "That reply did not contain a Confirmation Summary in OpenWar's required shape. " +
|
|
45
|
+
"Restate as: Objective / Deliverables / Constraints / Tools required / Unknowns, " +
|
|
46
|
+
"then ask which execution mode the operator wants. Do not begin execution.",
|
|
47
|
+
at: new Date().toISOString(),
|
|
48
|
+
meta: { phase: "intake", step_index: 1 },
|
|
49
|
+
};
|
|
50
|
+
const retry = await streamAndCollect(adapter, system, [briefPrompt, assistantMessage, nudge], io, signal);
|
|
51
|
+
assistantMessage = {
|
|
52
|
+
role: "assistant",
|
|
53
|
+
content: retry,
|
|
54
|
+
at: new Date().toISOString(),
|
|
55
|
+
meta: {
|
|
56
|
+
phase: "intake",
|
|
57
|
+
step_index: 1,
|
|
58
|
+
detectors: snapshot(retry, { authorized_costs: brief.frontmatter.authorized_costs }),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Hand control to operator.
|
|
63
|
+
io.write("\n");
|
|
64
|
+
const reply = await io.prompt('Acknowledge Confirmation Summary. Type "go" to accept, or describe a correction:');
|
|
65
|
+
const accepted = isAcceptance(reply);
|
|
66
|
+
return {
|
|
67
|
+
accepted,
|
|
68
|
+
operator_reply: reply,
|
|
69
|
+
assistant_message: assistantMessage,
|
|
70
|
+
brief_prompt: briefPrompt,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function isAcceptance(reply) {
|
|
74
|
+
const trimmed = reply.trim().toLowerCase();
|
|
75
|
+
if (!trimmed)
|
|
76
|
+
return false;
|
|
77
|
+
return /^(go|ok|okay|yes|y|approved|approve|confirmed|confirm|ship it|run it|do it|sounds good|looks good)$/.test(trimmed);
|
|
78
|
+
}
|
|
79
|
+
async function streamAndCollect(adapter, system, messages, io, signal) {
|
|
80
|
+
let assembled = "";
|
|
81
|
+
for await (const ev of adapter.sendMessage({
|
|
82
|
+
system,
|
|
83
|
+
messages,
|
|
84
|
+
...(signal ? { signal } : {}),
|
|
85
|
+
})) {
|
|
86
|
+
if (ev.type === "text_delta") {
|
|
87
|
+
io.write(ev.delta);
|
|
88
|
+
assembled += ev.delta;
|
|
89
|
+
}
|
|
90
|
+
else if (ev.type === "done") {
|
|
91
|
+
io.write("\n");
|
|
92
|
+
// Some adapters won't have streamed every chunk into `assembled`;
|
|
93
|
+
// prefer the canonical message.
|
|
94
|
+
if (ev.message && ev.message.length >= assembled.length) {
|
|
95
|
+
assembled = ev.message;
|
|
96
|
+
}
|
|
97
|
+
return assembled;
|
|
98
|
+
}
|
|
99
|
+
else if (ev.type === "error") {
|
|
100
|
+
throw ev.error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return assembled;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=intake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intake.js","sourceRoot":"","sources":["../../src/phases/intake.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAuB5E,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;CAa1B,CAAC,IAAI,EAAE,CAAC;AAET,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAgB;IAC9C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,G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AC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9B,CAA+B,EAAE,CAAC;QACjC,IAAI,EAAE,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAC7B,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YACnB,SAAS,IAAI,EAAE,CAAC,KAAK,CAAC;QACxB,CAAC;aAAM,IAAI,EAAE,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC9B,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACf,kEAAkE;YAClE,gCAAgC;YAChC,IAAI,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;gBACxD,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC;YACzB,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;aAAM,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC/B,MAAM,EAAE,CAAC,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"critic.d.ts","sourceRoot":"","sources":["../../src/roles/critic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,gBAAgB,EAAE,cAkC9B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const criticDefinition = {
|
|
2
|
+
id: "critic",
|
|
3
|
+
description: "Optional second-opinion reviewer. Runs in parallel with the reviewer; " +
|
|
4
|
+
"disagreement halts the coordinator into Phase 2 for operator decision.",
|
|
5
|
+
// Same scope as reviewer: read-only file access.
|
|
6
|
+
tool_categories: ["filesystem_read"],
|
|
7
|
+
allow_read_file: true,
|
|
8
|
+
prompt_overlay: `
|
|
9
|
+
You are the **critic** role under the OpenWar multi-agent coordinator.
|
|
10
|
+
|
|
11
|
+
You run in parallel with the **reviewer**. Your job is to give an
|
|
12
|
+
independent verdict on the executor's output against the sub-task's
|
|
13
|
+
acceptance criteria. You do not know the reviewer's verdict; you must form
|
|
14
|
+
your own.
|
|
15
|
+
|
|
16
|
+
When you disagree with the reviewer, the coordinator halts the run into
|
|
17
|
+
Phase 2 and asks the operator which verdict to accept. Therefore: be
|
|
18
|
+
honest. Do not soften your reading to align with what you imagine the
|
|
19
|
+
reviewer said. Independent verdicts are the whole point.
|
|
20
|
+
|
|
21
|
+
Output rules are identical to the reviewer's:
|
|
22
|
+
|
|
23
|
+
End your reply with a single fenced \`\`\`json block:
|
|
24
|
+
{
|
|
25
|
+
"kind": "review",
|
|
26
|
+
"subtask_id": "<the sub-task id>",
|
|
27
|
+
"verdict": "pass" | "fail" | "needs_retry",
|
|
28
|
+
"rationale": "<terse explanation, point-by-point against criteria>",
|
|
29
|
+
"suggested_revision": "<only when verdict is needs_retry>"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
You have read-only file access (filesystem_read). No write or shell.
|
|
33
|
+
`.trim(),
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=critic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"critic.js","sourceRoot":"","sources":["../../src/roles/critic.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAmB;IAC9C,EAAE,EAAE,QAAQ;IACZ,WAAW,EACT,wEAAwE;QACxE,wEAAwE;IAC1E,iDAAiD;IACjD,eAAe,EAAE,CAAC,iBAAiB,CAAC;IACpC,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjB,CAAC,IAAI,EAAE;CACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/roles/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,kBAAkB,EAAE,cA6ChC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const executorDefinition = {
|
|
2
|
+
id: "executor",
|
|
3
|
+
description: "Executes one sub-task at a time using the v0.3 tool layer. Standard " +
|
|
4
|
+
"authorization gates apply. Produces an ExecutionHandoff for the reviewer.",
|
|
5
|
+
// Executor inherits the brief's full authorized_costs. The wildcard here
|
|
6
|
+
// means "anything the brief itself authorizes." The runtime composes
|
|
7
|
+
// role-scope with the brief check; the planner/reviewer's narrower
|
|
8
|
+
// scopes still block them from broader tool use.
|
|
9
|
+
tool_categories: ["*"],
|
|
10
|
+
allow_read_file: true,
|
|
11
|
+
prompt_overlay: `
|
|
12
|
+
You are the **executor** role under the OpenWar multi-agent coordinator.
|
|
13
|
+
|
|
14
|
+
You receive one sub-task at a time. Each sub-task has:
|
|
15
|
+
- a title and instruction (what to do)
|
|
16
|
+
- acceptance criteria (what the reviewer will check)
|
|
17
|
+
|
|
18
|
+
Your responsibilities:
|
|
19
|
+
|
|
20
|
+
1. Execute the instruction using whatever tools you have access to. Tool
|
|
21
|
+
calls go through the normal v0.3 authorization gates; if a tool requires
|
|
22
|
+
a category not pre-approved in the brief's authorized_costs, the
|
|
23
|
+
coordinator will halt for a Phase 3 operator prompt before running it.
|
|
24
|
+
2. Stay within the sub-task's scope. If you find yourself needing to do
|
|
25
|
+
something the sub-task does not authorize, stop and declare a blocker
|
|
26
|
+
(Phase 2). Do not silently expand scope.
|
|
27
|
+
3. Produce one ExecutionHandoff per sub-task. End your reply with a single
|
|
28
|
+
fenced \`\`\`json block in this shape:
|
|
29
|
+
{
|
|
30
|
+
"kind": "execution",
|
|
31
|
+
"subtask_id": "<the sub-task id you executed>",
|
|
32
|
+
"output": "<the substantive result the reviewer will evaluate>",
|
|
33
|
+
"tool_calls": [<summarized tool-call records>],
|
|
34
|
+
"notes": "<your own narrative about decisions, surprises, caveats>"
|
|
35
|
+
}
|
|
36
|
+
4. If the sub-task is impossible without operator help, emit an
|
|
37
|
+
EscalationHandoff instead. Same fenced JSON, kind: "escalation".
|
|
38
|
+
5. Voice rules from the framework apply. Phase 3 destructive flag applies.
|
|
39
|
+
No banned phrases, no apologies as openers.
|
|
40
|
+
|
|
41
|
+
The reviewer will run after you and check your output against the
|
|
42
|
+
acceptance criteria. If the reviewer says "needs_retry", you will be
|
|
43
|
+
re-invoked with their suggested revision as additional context.
|
|
44
|
+
`.trim(),
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/roles/executor.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAChD,EAAE,EAAE,UAAU;IACd,WAAW,EACT,sEAAsE;QACtE,2EAA2E;IAC7E,yEAAyE;IACzE,qEAAqE;IACrE,mEAAmE;IACnE,iDAAiD;IACjD,eAAe,EAAE,CAAC,GAAG,CAAC;IACtB,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCjB,CAAC,IAAI,EAAE;CACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { registerRole, getRole, listRoles, listRoleIds, setRole, _resetRegistryToBuiltIns } from "./registry.js";
|
|
3
|
+
export { buildSystemPrompt } from "./prompt-overlay.js";
|
|
4
|
+
export { plannerDefinition } from "./planner.js";
|
|
5
|
+
export { executorDefinition } from "./executor.js";
|
|
6
|
+
export { reviewerDefinition } from "./reviewer.js";
|
|
7
|
+
export { criticDefinition } from "./critic.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { registerRole, getRole, listRoles, listRoleIds, setRole, _resetRegistryToBuiltIns } from "./registry.js";
|
|
3
|
+
export { buildSystemPrompt } from "./prompt-overlay.js";
|
|
4
|
+
export { plannerDefinition } from "./planner.js";
|
|
5
|
+
export { executorDefinition } from "./executor.js";
|
|
6
|
+
export { reviewerDefinition } from "./reviewer.js";
|
|
7
|
+
export { criticDefinition } from "./critic.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../src/roles/planner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,iBAAiB,EAAE,cAiD/B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const plannerDefinition = {
|
|
2
|
+
id: "planner",
|
|
3
|
+
description: "Decomposes the brief into ordered sub-tasks with acceptance criteria. " +
|
|
4
|
+
"No tool access. Output is a structured plan handoff.",
|
|
5
|
+
// Planner cannot call any tool. Coordinator enforces this structurally:
|
|
6
|
+
// role-scope check denies every tool category.
|
|
7
|
+
tool_categories: [],
|
|
8
|
+
allow_read_file: false,
|
|
9
|
+
prompt_overlay: `
|
|
10
|
+
You are the **planner** role under the OpenWar multi-agent coordinator.
|
|
11
|
+
|
|
12
|
+
Your only job is to decompose the brief into a linear, ordered list of
|
|
13
|
+
sub-tasks the executor can act on, each with concrete acceptance criteria
|
|
14
|
+
the reviewer can evaluate.
|
|
15
|
+
|
|
16
|
+
Output rules:
|
|
17
|
+
|
|
18
|
+
1. Begin with a short rationale (one paragraph) describing how you split the
|
|
19
|
+
work and why this ordering.
|
|
20
|
+
2. End your reply with a single fenced \`\`\`json block containing the plan
|
|
21
|
+
handoff. The runtime parses only this block as the plan; any prose
|
|
22
|
+
before it is logged but not executed.
|
|
23
|
+
3. The plan handoff schema:
|
|
24
|
+
{
|
|
25
|
+
"kind": "plan",
|
|
26
|
+
"subtasks": [
|
|
27
|
+
{
|
|
28
|
+
"id": "<short-stable-id>",
|
|
29
|
+
"title": "<one-line title>",
|
|
30
|
+
"instruction": "<concrete instruction for the executor>",
|
|
31
|
+
"acceptance_criteria": ["<criterion>", "..."],
|
|
32
|
+
"order": <integer, 0-based>,
|
|
33
|
+
"depends_on": []
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"rationale": "<the same rationale you wrote above>"
|
|
37
|
+
}
|
|
38
|
+
4. v0.4 supports **linear plans only**. Sub-task N may declare
|
|
39
|
+
\`depends_on: ["<id of N-1>"]\` or omit the field. Anything else is
|
|
40
|
+
rejected.
|
|
41
|
+
5. Do not call tools. You have no tool access. If the brief seems to require
|
|
42
|
+
reading files to plan, surface that as an Unknown and let the operator
|
|
43
|
+
decide before you produce a plan.
|
|
44
|
+
6. Do not include sub-tasks that violate the brief's scope or
|
|
45
|
+
authorized_costs.
|
|
46
|
+
7. If the brief is fully ambiguous, produce one sub-task whose instruction
|
|
47
|
+
is "ask the operator for clarification on: X" and stop. Do not invent.
|
|
48
|
+
`.trim(),
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.js","sourceRoot":"","sources":["../../src/roles/planner.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,EAAE,EAAE,SAAS;IACb,WAAW,EACT,wEAAwE;QACxE,sDAAsD;IACxD,wEAAwE;IACxE,+CAA+C;IAC/C,eAAe,EAAE,EAAE;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCjB,CAAC,IAAI,EAAE;CACP,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Brief, RoleDefinition } from "../types.js";
|
|
2
|
+
export interface OverlayInput {
|
|
3
|
+
framework: string;
|
|
4
|
+
brief: Brief;
|
|
5
|
+
role: RoleDefinition;
|
|
6
|
+
extra?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildSystemPrompt(input: OverlayInput): string;
|
|
9
|
+
//# sourceMappingURL=prompt-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-overlay.d.ts","sourceRoot":"","sources":["../../src/roles/prompt-overlay.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGzD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IAGrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAc7D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Assembles the system prompt for a role invocation. Layered as:
|
|
2
|
+
//
|
|
3
|
+
// framework_doc + brief_rendering + role_overlay
|
|
4
|
+
//
|
|
5
|
+
// The role overlay never overrides the framework's hard rules; it scopes
|
|
6
|
+
// what the role does on top of them. Hard-rule words ("Phase 0", "Phase 3
|
|
7
|
+
// destructive flag", "blocker", banned phrases) are not redefined; the
|
|
8
|
+
// overlay only adds role-specific instructions.
|
|
9
|
+
import { renderBriefForAgent } from "../brief.js";
|
|
10
|
+
export function buildSystemPrompt(input) {
|
|
11
|
+
const parts = [];
|
|
12
|
+
parts.push(input.framework.trim());
|
|
13
|
+
parts.push("\n---\n");
|
|
14
|
+
parts.push("# Brief (verbatim from the operator)\n");
|
|
15
|
+
parts.push(renderBriefForAgent(input.brief).trim());
|
|
16
|
+
parts.push("\n---\n");
|
|
17
|
+
parts.push(`# Role: ${input.role.id}\n`);
|
|
18
|
+
parts.push(input.role.prompt_overlay.trim());
|
|
19
|
+
if (input.extra && input.extra.trim()) {
|
|
20
|
+
parts.push("\n---\n");
|
|
21
|
+
parts.push(input.extra.trim());
|
|
22
|
+
}
|
|
23
|
+
return parts.join("\n");
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=prompt-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-overlay.js","sourceRoot":"","sources":["../../src/roles/prompt-overlay.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,uEAAuE;AACvE,gDAAgD;AAGhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAWlD,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACnD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACnC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtB,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACrD,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtB,KAAK,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IACzC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RoleDefinition, RoleId } from "../types.js";
|
|
2
|
+
export declare function registerRole(def: RoleDefinition): void;
|
|
3
|
+
export declare function getRole(id: RoleId): RoleDefinition | undefined;
|
|
4
|
+
export declare function listRoles(): RoleDefinition[];
|
|
5
|
+
export declare function listRoleIds(): RoleId[];
|
|
6
|
+
export declare function setRole(def: RoleDefinition): void;
|
|
7
|
+
export declare function _resetRegistryToBuiltIns(): void;
|
|
8
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/roles/registry.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQ1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAKtD;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE9D;AAED,wBAAgB,SAAS,IAAI,cAAc,EAAE,CAE5C;AAED,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAEtC;AAID,wBAAgB,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAEjD;AAKD,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C"}
|