agent-bober 0.6.2 → 0.8.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/README.md +220 -30
- package/dist/cli/commands/eval.d.ts +2 -0
- package/dist/cli/commands/eval.d.ts.map +1 -1
- package/dist/cli/commands/eval.js +10 -0
- package/dist/cli/commands/eval.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +357 -62
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/plan.d.ts +2 -0
- package/dist/cli/commands/plan.d.ts.map +1 -1
- package/dist/cli/commands/plan.js +10 -0
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/run.d.ts +2 -0
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +10 -0
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/sprint.d.ts +2 -0
- package/dist/cli/commands/sprint.d.ts.map +1 -1
- package/dist/cli/commands/sprint.js +10 -0
- package/dist/cli/commands/sprint.js.map +1 -1
- package/dist/cli/index.js +22 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/config/schema.d.ts +160 -43
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +11 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/contracts/sprint-contract.d.ts +8 -8
- package/dist/discovery/config-generator.d.ts +28 -0
- package/dist/discovery/config-generator.d.ts.map +1 -0
- package/dist/discovery/config-generator.js +225 -0
- package/dist/discovery/config-generator.js.map +1 -0
- package/dist/discovery/index.d.ts +20 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +19 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/scanner.d.ts +17 -0
- package/dist/discovery/scanner.d.ts.map +1 -0
- package/dist/discovery/scanner.js +120 -0
- package/dist/discovery/scanner.js.map +1 -0
- package/dist/discovery/scanners/ci-checks.d.ts +10 -0
- package/dist/discovery/scanners/ci-checks.d.ts.map +1 -0
- package/dist/discovery/scanners/ci-checks.js +169 -0
- package/dist/discovery/scanners/ci-checks.js.map +1 -0
- package/dist/discovery/scanners/code-conventions.d.ts +12 -0
- package/dist/discovery/scanners/code-conventions.d.ts.map +1 -0
- package/dist/discovery/scanners/code-conventions.js +216 -0
- package/dist/discovery/scanners/code-conventions.js.map +1 -0
- package/dist/discovery/scanners/documentation.d.ts +17 -0
- package/dist/discovery/scanners/documentation.d.ts.map +1 -0
- package/dist/discovery/scanners/documentation.js +92 -0
- package/dist/discovery/scanners/documentation.js.map +1 -0
- package/dist/discovery/scanners/git-conventions.d.ts +11 -0
- package/dist/discovery/scanners/git-conventions.d.ts.map +1 -0
- package/dist/discovery/scanners/git-conventions.js +128 -0
- package/dist/discovery/scanners/git-conventions.js.map +1 -0
- package/dist/discovery/scanners/package-scripts.d.ts +9 -0
- package/dist/discovery/scanners/package-scripts.d.ts.map +1 -0
- package/dist/discovery/scanners/package-scripts.js +112 -0
- package/dist/discovery/scanners/package-scripts.js.map +1 -0
- package/dist/discovery/scanners/test-conventions.d.ts +9 -0
- package/dist/discovery/scanners/test-conventions.d.ts.map +1 -0
- package/dist/discovery/scanners/test-conventions.js +231 -0
- package/dist/discovery/scanners/test-conventions.js.map +1 -0
- package/dist/discovery/synthesizer.d.ts +30 -0
- package/dist/discovery/synthesizer.d.ts.map +1 -0
- package/dist/discovery/synthesizer.js +348 -0
- package/dist/discovery/synthesizer.js.map +1 -0
- package/dist/discovery/types.d.ts +160 -0
- package/dist/discovery/types.d.ts.map +1 -0
- package/dist/discovery/types.js +9 -0
- package/dist/discovery/types.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/run-manager.d.ts +47 -0
- package/dist/mcp/run-manager.d.ts.map +1 -0
- package/dist/mcp/run-manager.js +79 -0
- package/dist/mcp/run-manager.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +107 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/config.d.ts +2 -0
- package/dist/mcp/tools/config.d.ts.map +1 -0
- package/dist/mcp/tools/config.js +153 -0
- package/dist/mcp/tools/config.js.map +1 -0
- package/dist/mcp/tools/contracts.d.ts +2 -0
- package/dist/mcp/tools/contracts.d.ts.map +1 -0
- package/dist/mcp/tools/contracts.js +61 -0
- package/dist/mcp/tools/contracts.js.map +1 -0
- package/dist/mcp/tools/eval.d.ts +2 -0
- package/dist/mcp/tools/eval.d.ts.map +1 -0
- package/dist/mcp/tools/eval.js +157 -0
- package/dist/mcp/tools/eval.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +20 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +47 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/init.d.ts +2 -0
- package/dist/mcp/tools/init.d.ts.map +1 -0
- package/dist/mcp/tools/init.js +222 -0
- package/dist/mcp/tools/init.js.map +1 -0
- package/dist/mcp/tools/plan.d.ts +2 -0
- package/dist/mcp/tools/plan.d.ts.map +1 -0
- package/dist/mcp/tools/plan.js +97 -0
- package/dist/mcp/tools/plan.js.map +1 -0
- package/dist/mcp/tools/principles.d.ts +2 -0
- package/dist/mcp/tools/principles.d.ts.map +1 -0
- package/dist/mcp/tools/principles.js +66 -0
- package/dist/mcp/tools/principles.js.map +1 -0
- package/dist/mcp/tools/registry.d.ts +45 -0
- package/dist/mcp/tools/registry.d.ts.map +1 -0
- package/dist/mcp/tools/registry.js +23 -0
- package/dist/mcp/tools/registry.js.map +1 -0
- package/dist/mcp/tools/run.d.ts +2 -0
- package/dist/mcp/tools/run.d.ts.map +1 -0
- package/dist/mcp/tools/run.js +66 -0
- package/dist/mcp/tools/run.js.map +1 -0
- package/dist/mcp/tools/spec.d.ts +2 -0
- package/dist/mcp/tools/spec.d.ts.map +1 -0
- package/dist/mcp/tools/spec.js +32 -0
- package/dist/mcp/tools/spec.js.map +1 -0
- package/dist/mcp/tools/sprint.d.ts +2 -0
- package/dist/mcp/tools/sprint.d.ts.map +1 -0
- package/dist/mcp/tools/sprint.js +243 -0
- package/dist/mcp/tools/sprint.js.map +1 -0
- package/dist/mcp/tools/status.d.ts +2 -0
- package/dist/mcp/tools/status.d.ts.map +1 -0
- package/dist/mcp/tools/status.js +76 -0
- package/dist/mcp/tools/status.js.map +1 -0
- package/dist/orchestrator/agentic-loop.d.ts +7 -6
- package/dist/orchestrator/agentic-loop.d.ts.map +1 -1
- package/dist/orchestrator/agentic-loop.js +33 -40
- package/dist/orchestrator/agentic-loop.js.map +1 -1
- package/dist/orchestrator/context-handoff.d.ts +20 -20
- package/dist/orchestrator/evaluator-agent.d.ts.map +1 -1
- package/dist/orchestrator/evaluator-agent.js +2 -2
- package/dist/orchestrator/evaluator-agent.js.map +1 -1
- package/dist/orchestrator/generator-agent.d.ts.map +1 -1
- package/dist/orchestrator/generator-agent.js +2 -2
- package/dist/orchestrator/generator-agent.js.map +1 -1
- package/dist/orchestrator/model-resolver.d.ts +35 -4
- package/dist/orchestrator/model-resolver.d.ts.map +1 -1
- package/dist/orchestrator/model-resolver.js +68 -15
- package/dist/orchestrator/model-resolver.js.map +1 -1
- package/dist/orchestrator/planner-agent.d.ts.map +1 -1
- package/dist/orchestrator/planner-agent.js +2 -2
- package/dist/orchestrator/planner-agent.js.map +1 -1
- package/dist/orchestrator/tools/index.d.ts +3 -4
- package/dist/orchestrator/tools/index.d.ts.map +1 -1
- package/dist/orchestrator/tools/index.js.map +1 -1
- package/dist/orchestrator/tools/schemas.d.ts +11 -12
- package/dist/orchestrator/tools/schemas.d.ts.map +1 -1
- package/dist/orchestrator/tools/schemas.js +3 -2
- package/dist/orchestrator/tools/schemas.js.map +1 -1
- package/dist/providers/anthropic.d.ts +15 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +133 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/factory.d.ts +37 -0
- package/dist/providers/factory.d.ts.map +1 -0
- package/dist/providers/factory.js +119 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/google.d.ts +39 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +195 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/index.d.ts +7 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +6 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/openai-compat.d.ts +39 -0
- package/dist/providers/openai-compat.d.ts.map +1 -0
- package/dist/providers/openai-compat.js +42 -0
- package/dist/providers/openai-compat.js.map +1 -0
- package/dist/providers/openai.d.ts +41 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +205 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/types.d.ts +144 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +8 -0
- package/dist/providers/types.js.map +1 -0
- package/package.json +22 -4
- package/skills/bober.principles/SKILL.md +36 -3
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// ── bober_sprint tool ────────────────────────────────────────────────
|
|
2
|
+
//
|
|
3
|
+
// Executes the next pending sprint cycle (generate + evaluate).
|
|
4
|
+
// Accepts { continue?: boolean }. Returns a JSON summary of the result.
|
|
5
|
+
import { cwd } from "node:process";
|
|
6
|
+
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
import { configExists, loadConfig } from "../../config/loader.js";
|
|
8
|
+
import { updateContractStatus } from "../../contracts/sprint-contract.js";
|
|
9
|
+
import { createHandoff, summarizeOlderSprints, } from "../../orchestrator/context-handoff.js";
|
|
10
|
+
import { runGenerator } from "../../orchestrator/generator-agent.js";
|
|
11
|
+
import { runEvaluatorAgent } from "../../orchestrator/evaluator-agent.js";
|
|
12
|
+
import { ensureBoberDir, listContracts, updateContract, loadLatestSpec, appendHistory, } from "../../state/index.js";
|
|
13
|
+
import { getCurrentBranch, getChangedFiles, commitAll } from "../../utils/git.js";
|
|
14
|
+
import { registerTool } from "./registry.js";
|
|
15
|
+
// ── Helpers ──────────────────────────────────────────────────────────
|
|
16
|
+
const PENDING_STATUSES = new Set([
|
|
17
|
+
"proposed",
|
|
18
|
+
"negotiating",
|
|
19
|
+
"agreed",
|
|
20
|
+
"needs-rework",
|
|
21
|
+
]);
|
|
22
|
+
function findNextPendingSprint(contracts) {
|
|
23
|
+
return contracts.find((c) => PENDING_STATUSES.has(c.status)) ?? null;
|
|
24
|
+
}
|
|
25
|
+
async function buildProjectContext(projectRoot, config) {
|
|
26
|
+
let currentBranch;
|
|
27
|
+
try {
|
|
28
|
+
currentBranch = await getCurrentBranch(projectRoot);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
currentBranch = "unknown";
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
name: config.project.name,
|
|
35
|
+
type: config.project.mode,
|
|
36
|
+
techStack: [],
|
|
37
|
+
entryPoints: [],
|
|
38
|
+
currentBranch,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// ── Registration ─────────────────────────────────────────────────────
|
|
42
|
+
export function registerSprintTool() {
|
|
43
|
+
registerTool({
|
|
44
|
+
name: "bober_sprint",
|
|
45
|
+
description: "Execute the next pending sprint in the Bober pipeline (generate + evaluate). " +
|
|
46
|
+
"Finds the first contract in 'proposed' or 'needs-rework' status, runs the " +
|
|
47
|
+
"generate-evaluate-iterate cycle, and returns a JSON result with pass/fail status " +
|
|
48
|
+
"and evaluator feedback. Requires a plan to exist (run bober_plan first).",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
continue: {
|
|
53
|
+
type: "boolean",
|
|
54
|
+
description: "If true, keep running sprints until all are complete or one fails.",
|
|
55
|
+
default: false,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
},
|
|
60
|
+
handler: async (args) => {
|
|
61
|
+
const shouldContinue = Boolean(args.continue ?? false);
|
|
62
|
+
const projectRoot = cwd();
|
|
63
|
+
const hasConfig = await configExists(projectRoot);
|
|
64
|
+
if (!hasConfig) {
|
|
65
|
+
throw new McpError(ErrorCode.InvalidRequest, "No bober.config.json found. Run bober_init first.");
|
|
66
|
+
}
|
|
67
|
+
let config;
|
|
68
|
+
try {
|
|
69
|
+
config = await loadConfig(projectRoot);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
return JSON.stringify({
|
|
73
|
+
error: `Failed to load config: ${err instanceof Error ? err.message : String(err)}`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
await ensureBoberDir(projectRoot);
|
|
77
|
+
const spec = await loadLatestSpec(projectRoot);
|
|
78
|
+
if (!spec) {
|
|
79
|
+
return JSON.stringify({
|
|
80
|
+
error: "No plan found. Run bober_plan first to generate a plan.",
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const contracts = await listContracts(projectRoot);
|
|
84
|
+
if (contracts.length === 0) {
|
|
85
|
+
return JSON.stringify({
|
|
86
|
+
error: "No sprint contracts found. Run bober_plan first.",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const projectContext = await buildProjectContext(projectRoot, config);
|
|
90
|
+
const results = [];
|
|
91
|
+
let continueLoop = true;
|
|
92
|
+
while (continueLoop) {
|
|
93
|
+
const nextSprint = findNextPendingSprint(contracts);
|
|
94
|
+
if (!nextSprint) {
|
|
95
|
+
if (results.length === 0) {
|
|
96
|
+
return JSON.stringify({
|
|
97
|
+
status: "all-complete",
|
|
98
|
+
message: "All sprints are already completed.",
|
|
99
|
+
contracts: contracts.map((c) => ({
|
|
100
|
+
id: c.id,
|
|
101
|
+
feature: c.feature,
|
|
102
|
+
status: c.status,
|
|
103
|
+
})),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
process.stderr.write(`[bober_sprint] Starting sprint: ${nextSprint.feature} (${nextSprint.id})\n`);
|
|
109
|
+
const completedContracts = contracts.filter((c) => c.status === "passed");
|
|
110
|
+
const maxIterations = config.evaluator.maxIterations;
|
|
111
|
+
let currentContract = updateContractStatus(nextSprint, "in-progress");
|
|
112
|
+
await updateContract(projectRoot, currentContract);
|
|
113
|
+
const contractIndex = contracts.findIndex((c) => c.id === currentContract.id);
|
|
114
|
+
if (contractIndex !== -1) {
|
|
115
|
+
contracts[contractIndex] = currentContract;
|
|
116
|
+
}
|
|
117
|
+
let sprintPassed = false;
|
|
118
|
+
let lastEvalSummary;
|
|
119
|
+
let lastEvalScore;
|
|
120
|
+
for (let iteration = 1; iteration <= maxIterations; iteration++) {
|
|
121
|
+
process.stderr.write(`[bober_sprint] Iteration ${iteration}/${maxIterations} for ${currentContract.id}\n`);
|
|
122
|
+
const handoff = createHandoff({
|
|
123
|
+
from: iteration === 1 ? "planner" : "evaluator",
|
|
124
|
+
to: "generator",
|
|
125
|
+
projectContext,
|
|
126
|
+
spec,
|
|
127
|
+
currentContract,
|
|
128
|
+
sprintHistory: completedContracts,
|
|
129
|
+
instructions: `Implement sprint: ${currentContract.feature}\n\n${currentContract.description}`,
|
|
130
|
+
issues: currentContract.evaluatorFeedback
|
|
131
|
+
? [currentContract.evaluatorFeedback]
|
|
132
|
+
: [],
|
|
133
|
+
});
|
|
134
|
+
const compactedHandoff = summarizeOlderSprints(handoff, 3);
|
|
135
|
+
// Generate
|
|
136
|
+
await appendHistory(projectRoot, {
|
|
137
|
+
timestamp: new Date().toISOString(),
|
|
138
|
+
event: "generator-start",
|
|
139
|
+
phase: "generating",
|
|
140
|
+
sprintId: currentContract.id,
|
|
141
|
+
details: { iteration },
|
|
142
|
+
});
|
|
143
|
+
const generatorResult = await runGenerator(compactedHandoff, projectRoot, config);
|
|
144
|
+
if (!generatorResult.success) {
|
|
145
|
+
process.stderr.write(`[bober_sprint] Generator failed: ${generatorResult.notes}\n`);
|
|
146
|
+
currentContract = {
|
|
147
|
+
...currentContract,
|
|
148
|
+
generatorNotes: generatorResult.notes,
|
|
149
|
+
};
|
|
150
|
+
await updateContract(projectRoot, currentContract);
|
|
151
|
+
if (iteration < maxIterations) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
currentContract = updateContractStatus(currentContract, "needs-rework");
|
|
155
|
+
await updateContract(projectRoot, currentContract);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
// Auto-commit
|
|
159
|
+
if (config.generator.autoCommit) {
|
|
160
|
+
try {
|
|
161
|
+
const hash = await commitAll(projectRoot, `bober: ${currentContract.feature} (round ${iteration})`);
|
|
162
|
+
process.stderr.write(`[bober_sprint] Committed: ${hash}\n`);
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
process.stderr.write(`[bober_sprint] Auto-commit skipped: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Evaluate
|
|
169
|
+
currentContract = updateContractStatus(currentContract, "evaluating");
|
|
170
|
+
await updateContract(projectRoot, currentContract);
|
|
171
|
+
let changedFiles;
|
|
172
|
+
try {
|
|
173
|
+
changedFiles = await getChangedFiles(projectRoot);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
changedFiles = generatorResult.filesChanged;
|
|
177
|
+
}
|
|
178
|
+
const evalHandoff = createHandoff({
|
|
179
|
+
from: "generator",
|
|
180
|
+
to: "evaluator",
|
|
181
|
+
projectContext,
|
|
182
|
+
spec,
|
|
183
|
+
currentContract,
|
|
184
|
+
sprintHistory: completedContracts,
|
|
185
|
+
instructions: `Evaluate sprint: ${currentContract.feature}`,
|
|
186
|
+
changedFiles,
|
|
187
|
+
});
|
|
188
|
+
const evaluation = await runEvaluatorAgent(evalHandoff, projectRoot, config);
|
|
189
|
+
lastEvalSummary = evaluation.summary;
|
|
190
|
+
lastEvalScore = evaluation.score;
|
|
191
|
+
if (evaluation.passed) {
|
|
192
|
+
currentContract = updateContractStatus(currentContract, "passed");
|
|
193
|
+
currentContract = {
|
|
194
|
+
...currentContract,
|
|
195
|
+
evaluatorFeedback: evaluation.summary,
|
|
196
|
+
};
|
|
197
|
+
await updateContract(projectRoot, currentContract);
|
|
198
|
+
sprintPassed = true;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
// Failed
|
|
202
|
+
currentContract = {
|
|
203
|
+
...currentContract,
|
|
204
|
+
evaluatorFeedback: evaluation.summary,
|
|
205
|
+
};
|
|
206
|
+
await updateContract(projectRoot, currentContract);
|
|
207
|
+
if (iteration >= maxIterations) {
|
|
208
|
+
currentContract = updateContractStatus(currentContract, "needs-rework");
|
|
209
|
+
await updateContract(projectRoot, currentContract);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Update local array
|
|
213
|
+
if (contractIndex !== -1) {
|
|
214
|
+
contracts[contractIndex] = currentContract;
|
|
215
|
+
}
|
|
216
|
+
results.push({
|
|
217
|
+
contractId: currentContract.id,
|
|
218
|
+
feature: currentContract.feature,
|
|
219
|
+
status: currentContract.status,
|
|
220
|
+
passed: sprintPassed,
|
|
221
|
+
score: lastEvalScore,
|
|
222
|
+
iteration: maxIterations,
|
|
223
|
+
evaluatorFeedback: lastEvalSummary ?? currentContract.evaluatorFeedback ?? null,
|
|
224
|
+
});
|
|
225
|
+
if (!shouldContinue) {
|
|
226
|
+
continueLoop = false;
|
|
227
|
+
}
|
|
228
|
+
else if (!sprintPassed && config.sprint.requireContracts) {
|
|
229
|
+
continueLoop = false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Return single result if only one sprint ran, otherwise array
|
|
233
|
+
if (results.length === 1) {
|
|
234
|
+
return JSON.stringify(results[0], null, 2);
|
|
235
|
+
}
|
|
236
|
+
return JSON.stringify({
|
|
237
|
+
sprintsRun: results.length,
|
|
238
|
+
results,
|
|
239
|
+
}, null, 2);
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=sprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sprint.js","sourceRoot":"","sources":["../../../src/mcp/tools/sprint.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,gEAAgE;AAChE,wEAAwE;AAExE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EACL,aAAa,EACb,qBAAqB,GACtB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,wEAAwE;AAExE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,UAAU;IACV,aAAa;IACb,QAAQ;IACR,cAAc;CACf,CAAC,CAAC;AAEH,SAAS,qBAAqB,CAAC,SAA2B;IACxD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC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AC,gBAAgB,EAAE,CAAC;oBAC3D,YAAY,GAAG,KAAK,CAAC;gBACvB,CAAC;YACH,CAAC;YAED,+DAA+D;YAC/D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC7C,CAAC;YAED,OAAO,IAAI,CAAC,SAAS,CACnB;gBACE,UAAU,EAAE,OAAO,CAAC,MAAM;gBAC1B,OAAO;aACR,EACD,IAAI,EACJ,CAAC,CACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/status.ts"],"names":[],"mappings":"AAgBA,wBAAgB,kBAAkB,IAAI,IAAI,CAmFzC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// ── bober_status tool ────────────────────────────────────────────────
|
|
2
|
+
//
|
|
3
|
+
// Returns the current pipeline run state.
|
|
4
|
+
// - If a run is active: {runId, status: 'running', progress}
|
|
5
|
+
// - If a run completed/failed: {runId, status: 'completed'|'failed', result}
|
|
6
|
+
// - If no run ever started: {status: 'idle', progress: <progress.md content>}
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { cwd } from "node:process";
|
|
10
|
+
import { registerTool } from "./registry.js";
|
|
11
|
+
import { runManager } from "../run-manager.js";
|
|
12
|
+
// ── Registration ─────────────────────────────────────────────────────
|
|
13
|
+
export function registerStatusTool() {
|
|
14
|
+
registerTool({
|
|
15
|
+
name: "bober_status",
|
|
16
|
+
description: "Check the status of the running or most recent Bober pipeline. " +
|
|
17
|
+
"Returns progress when active, or the final result when complete. " +
|
|
18
|
+
"When idle, returns the contents of .bober/progress.md.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {},
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
handler: async (_args) => {
|
|
25
|
+
const state = runManager.getStatus();
|
|
26
|
+
// No run has ever been started
|
|
27
|
+
if (state === null) {
|
|
28
|
+
const projectRoot = cwd();
|
|
29
|
+
const progressPath = join(projectRoot, ".bober", "progress.md");
|
|
30
|
+
let progressContent;
|
|
31
|
+
try {
|
|
32
|
+
progressContent = await readFile(progressPath, "utf-8");
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
progressContent = "No progress information available yet. Run bober_run to start a pipeline.";
|
|
36
|
+
}
|
|
37
|
+
return JSON.stringify({
|
|
38
|
+
status: "idle",
|
|
39
|
+
progress: progressContent,
|
|
40
|
+
}, null, 2);
|
|
41
|
+
}
|
|
42
|
+
// Active run
|
|
43
|
+
if (state.status === "running") {
|
|
44
|
+
return JSON.stringify({
|
|
45
|
+
runId: state.runId,
|
|
46
|
+
status: state.status,
|
|
47
|
+
task: state.task,
|
|
48
|
+
startedAt: state.startedAt,
|
|
49
|
+
progress: state.progress,
|
|
50
|
+
}, null, 2);
|
|
51
|
+
}
|
|
52
|
+
// Completed run
|
|
53
|
+
if (state.status === "completed") {
|
|
54
|
+
return JSON.stringify({
|
|
55
|
+
runId: state.runId,
|
|
56
|
+
status: state.status,
|
|
57
|
+
task: state.task,
|
|
58
|
+
startedAt: state.startedAt,
|
|
59
|
+
completedAt: state.completedAt,
|
|
60
|
+
result: state.result,
|
|
61
|
+
}, null, 2);
|
|
62
|
+
}
|
|
63
|
+
// Failed run
|
|
64
|
+
return JSON.stringify({
|
|
65
|
+
runId: state.runId,
|
|
66
|
+
status: state.status,
|
|
67
|
+
task: state.task,
|
|
68
|
+
startedAt: state.startedAt,
|
|
69
|
+
completedAt: state.completedAt,
|
|
70
|
+
error: state.error,
|
|
71
|
+
result: state.result,
|
|
72
|
+
}, null, 2);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}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,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { LLMClient, ToolDef } from "../providers/types.js";
|
|
2
2
|
import type { ToolHandler } from "./tools/index.js";
|
|
3
|
-
type Tool = Anthropic.Messages.Tool;
|
|
4
3
|
export interface AgenticLoopParams {
|
|
5
|
-
/**
|
|
6
|
-
client:
|
|
4
|
+
/** Provider-agnostic LLM client. */
|
|
5
|
+
client: LLMClient;
|
|
7
6
|
/** Model ID (resolved via model-resolver). */
|
|
8
7
|
model: string;
|
|
9
8
|
/** System prompt (loaded from agent .md file). */
|
|
@@ -11,7 +10,7 @@ export interface AgenticLoopParams {
|
|
|
11
10
|
/** Initial user message (task description, handoff, etc.). */
|
|
12
11
|
userMessage: string;
|
|
13
12
|
/** Tool schemas to pass to the API. */
|
|
14
|
-
tools:
|
|
13
|
+
tools: ToolDef[];
|
|
15
14
|
/** Handler functions for each tool, keyed by name. */
|
|
16
15
|
toolHandlers: Map<string, ToolHandler>;
|
|
17
16
|
/** Max tool-use round trips before stopping. */
|
|
@@ -46,8 +45,10 @@ export interface AgenticLoopResult {
|
|
|
46
45
|
* This continues until the model stops requesting tools or maxTurns
|
|
47
46
|
* is exceeded.
|
|
48
47
|
*
|
|
48
|
+
* Uses provider-agnostic types throughout. The LLMClient implementation
|
|
49
|
+
* handles all conversion to/from provider-specific formats.
|
|
50
|
+
*
|
|
49
51
|
* @returns The final text response and metadata about the conversation.
|
|
50
52
|
*/
|
|
51
53
|
export declare function runAgenticLoop(params: AgenticLoopParams): Promise<AgenticLoopResult>;
|
|
52
|
-
export {};
|
|
53
54
|
//# sourceMappingURL=agentic-loop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentic-loop.d.ts","sourceRoot":"","sources":["../../src/orchestrator/agentic-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"agentic-loop.d.ts","sourceRoot":"","sources":["../../src/orchestrator/agentic-loop.ts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
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { logger } from "../utils/logger.js";
|
|
2
|
-
// ── Helpers ─────────────────────────────────────────────────────────
|
|
3
|
-
function extractText(content) {
|
|
4
|
-
return content
|
|
5
|
-
.filter((b) => b.type === "text")
|
|
6
|
-
.map((b) => b.text)
|
|
7
|
-
.join("");
|
|
8
|
-
}
|
|
9
2
|
// ── Main loop ──────────────────────────────────────────────────────
|
|
10
3
|
/**
|
|
11
4
|
* Run a multi-turn agentic conversation loop.
|
|
@@ -15,6 +8,9 @@ function extractText(content) {
|
|
|
15
8
|
* This continues until the model stops requesting tools or maxTurns
|
|
16
9
|
* is exceeded.
|
|
17
10
|
*
|
|
11
|
+
* Uses provider-agnostic types throughout. The LLMClient implementation
|
|
12
|
+
* handles all conversion to/from provider-specific formats.
|
|
13
|
+
*
|
|
18
14
|
* @returns The final text response and metadata about the conversation.
|
|
19
15
|
*/
|
|
20
16
|
export async function runAgenticLoop(params) {
|
|
@@ -30,12 +26,12 @@ export async function runAgenticLoop(params) {
|
|
|
30
26
|
logger.debug(`Agentic loop turn ${turn}/${maxTurns}...`);
|
|
31
27
|
let response;
|
|
32
28
|
try {
|
|
33
|
-
response = await client.
|
|
29
|
+
response = await client.chat({
|
|
34
30
|
model,
|
|
35
|
-
max_tokens: maxTokens,
|
|
36
31
|
system: systemPrompt,
|
|
37
|
-
tools: tools.length > 0 ? tools : undefined,
|
|
38
32
|
messages,
|
|
33
|
+
tools: tools.length > 0 ? tools : undefined,
|
|
34
|
+
maxTokens,
|
|
39
35
|
});
|
|
40
36
|
}
|
|
41
37
|
catch (err) {
|
|
@@ -54,14 +50,12 @@ export async function runAgenticLoop(params) {
|
|
|
54
50
|
};
|
|
55
51
|
}
|
|
56
52
|
// Accumulate usage
|
|
57
|
-
totalInputTokens += response.usage
|
|
58
|
-
totalOutputTokens += response.usage
|
|
59
|
-
|
|
60
|
-
const turnText = extractText(response.content);
|
|
61
|
-
const turnStopReason = response.stop_reason ?? "unknown";
|
|
53
|
+
totalInputTokens += response.usage.inputTokens;
|
|
54
|
+
totalOutputTokens += response.usage.outputTokens;
|
|
55
|
+
const turnStopReason = response.stopReason;
|
|
62
56
|
// If the model is done (no more tool use), return
|
|
63
|
-
if (response.
|
|
64
|
-
finalText =
|
|
57
|
+
if (response.stopReason !== "tool_use") {
|
|
58
|
+
finalText = response.text;
|
|
65
59
|
return {
|
|
66
60
|
finalText,
|
|
67
61
|
turnsUsed: turn,
|
|
@@ -73,20 +67,20 @@ export async function runAgenticLoop(params) {
|
|
|
73
67
|
stopReason: turnStopReason,
|
|
74
68
|
};
|
|
75
69
|
}
|
|
76
|
-
// Model wants to use tools —
|
|
77
|
-
//
|
|
78
|
-
|
|
70
|
+
// Model wants to use tools — append the assistant's full response
|
|
71
|
+
// (text + tool calls) as an AssistantMessage.
|
|
72
|
+
const assistantMessage = {
|
|
79
73
|
role: "assistant",
|
|
80
|
-
content: response.
|
|
81
|
-
|
|
74
|
+
content: response.text,
|
|
75
|
+
toolCalls: response.toolCalls,
|
|
76
|
+
};
|
|
77
|
+
messages.push(assistantMessage);
|
|
82
78
|
// Execute each tool and collect results
|
|
83
79
|
const toolResults = [];
|
|
84
80
|
const turnTools = [];
|
|
85
|
-
for (const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const toolName = block.name;
|
|
89
|
-
const toolInput = block.input;
|
|
81
|
+
for (const toolCall of response.toolCalls) {
|
|
82
|
+
const toolName = toolCall.name;
|
|
83
|
+
const toolInput = toolCall.input;
|
|
90
84
|
turnTools.push(toolName);
|
|
91
85
|
allToolsCalled.push(toolName);
|
|
92
86
|
onToolUse?.(toolName, toolInput);
|
|
@@ -94,38 +88,37 @@ export async function runAgenticLoop(params) {
|
|
|
94
88
|
if (!handler) {
|
|
95
89
|
logger.warn(`Unknown tool requested: "${toolName}"`);
|
|
96
90
|
toolResults.push({
|
|
97
|
-
|
|
98
|
-
tool_use_id: block.id,
|
|
91
|
+
toolUseId: toolCall.id,
|
|
99
92
|
content: `Error: Unknown tool "${toolName}". Available tools: ${[...toolHandlers.keys()].join(", ")}`,
|
|
100
|
-
|
|
93
|
+
isError: true,
|
|
101
94
|
});
|
|
102
95
|
continue;
|
|
103
96
|
}
|
|
104
97
|
try {
|
|
105
98
|
const result = await handler(toolInput);
|
|
106
99
|
toolResults.push({
|
|
107
|
-
|
|
108
|
-
tool_use_id: block.id,
|
|
100
|
+
toolUseId: toolCall.id,
|
|
109
101
|
content: result.output,
|
|
110
|
-
|
|
102
|
+
isError: result.isError,
|
|
111
103
|
});
|
|
112
104
|
}
|
|
113
105
|
catch (err) {
|
|
114
106
|
const message = err instanceof Error ? err.message : String(err);
|
|
115
107
|
logger.warn(`Tool "${toolName}" threw: ${message}`);
|
|
116
108
|
toolResults.push({
|
|
117
|
-
|
|
118
|
-
tool_use_id: block.id,
|
|
109
|
+
toolUseId: toolCall.id,
|
|
119
110
|
content: `Error: Tool execution failed: ${message}`,
|
|
120
|
-
|
|
111
|
+
isError: true,
|
|
121
112
|
});
|
|
122
113
|
}
|
|
123
114
|
}
|
|
124
|
-
// Append tool results as a user
|
|
125
|
-
|
|
115
|
+
// Append tool results as a ToolResultMessage (user role).
|
|
116
|
+
// The adapter converts this to provider-specific format.
|
|
117
|
+
const toolResultMessage = {
|
|
126
118
|
role: "user",
|
|
127
|
-
|
|
128
|
-
}
|
|
119
|
+
toolResults,
|
|
120
|
+
};
|
|
121
|
+
messages.push(toolResultMessage);
|
|
129
122
|
onTurnComplete?.(turn, turnTools);
|
|
130
123
|
}
|
|
131
124
|
// Max turns exceeded — return what we have
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentic-loop.js","sourceRoot":"","sources":["../../src/orchestrator/agentic-loop.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"agentic-loop.js","sourceRoot":"","sources":["../../src/orchestrator/agentic-loop.ts"],"names":[],"mappings":"AAG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