agent-bober 0.15.0 → 0.17.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/.claude-plugin/marketplace.json +20 -0
- package/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +30 -0
- package/README.md +127 -3
- package/agents/bober-architect.md +34 -0
- package/agents/bober-code-reviewer.md +2 -0
- package/agents/bober-curator.md +12 -0
- package/agents/bober-documenter.md +129 -0
- package/agents/bober-evaluator.md +46 -0
- package/agents/bober-generator.md +12 -0
- package/agents/bober-planner.md +8 -1
- package/dist/cli/commands/graph.js +3 -3
- package/dist/cli/commands/graph.js.map +1 -1
- package/dist/cli/commands/init.js +4 -0
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/memory.d.ts +14 -0
- package/dist/cli/commands/memory.d.ts.map +1 -0
- package/dist/cli/commands/memory.js +132 -0
- package/dist/cli/commands/memory.js.map +1 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +14 -3
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +7 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/role-providers.d.ts +29 -0
- package/dist/config/role-providers.d.ts.map +1 -0
- package/dist/config/role-providers.js +115 -0
- package/dist/config/role-providers.js.map +1 -0
- package/dist/config/schema.d.ts +383 -14
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +42 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/contracts/eval-result.d.ts +112 -56
- package/dist/contracts/eval-result.d.ts.map +1 -1
- package/dist/contracts/eval-result.js +3 -0
- package/dist/contracts/eval-result.js.map +1 -1
- package/dist/contracts/sprint-contract.d.ts +30 -30
- package/dist/fleet/aggregator.d.ts +5 -0
- package/dist/fleet/aggregator.d.ts.map +1 -0
- package/dist/fleet/aggregator.js +39 -0
- package/dist/fleet/aggregator.js.map +1 -0
- package/dist/fleet/child-config.d.ts +12 -0
- package/dist/fleet/child-config.d.ts.map +1 -0
- package/dist/fleet/child-config.js +38 -0
- package/dist/fleet/child-config.js.map +1 -0
- package/dist/fleet/coordinator.d.ts +25 -0
- package/dist/fleet/coordinator.d.ts.map +1 -0
- package/dist/fleet/coordinator.js +40 -0
- package/dist/fleet/coordinator.js.map +1 -0
- package/dist/fleet/index.d.ts +40 -0
- package/dist/fleet/index.d.ts.map +1 -0
- package/dist/fleet/index.js +117 -0
- package/dist/fleet/index.js.map +1 -0
- package/dist/fleet/manifest.d.ts +51 -0
- package/dist/fleet/manifest.d.ts.map +1 -0
- package/dist/fleet/manifest.js +32 -0
- package/dist/fleet/manifest.js.map +1 -0
- package/dist/fleet/reporter.d.ts +32 -0
- package/dist/fleet/reporter.d.ts.map +1 -0
- package/dist/fleet/reporter.js +71 -0
- package/dist/fleet/reporter.js.map +1 -0
- package/dist/fleet/runner.d.ts +48 -0
- package/dist/fleet/runner.d.ts.map +1 -0
- package/dist/fleet/runner.js +104 -0
- package/dist/fleet/runner.js.map +1 -0
- package/dist/fleet/scaffolder.d.ts +12 -0
- package/dist/fleet/scaffolder.d.ts.map +1 -0
- package/dist/fleet/scaffolder.js +82 -0
- package/dist/fleet/scaffolder.js.map +1 -0
- package/dist/fleet/types.d.ts +21 -0
- package/dist/fleet/types.d.ts.map +1 -0
- package/dist/fleet/types.js +2 -0
- package/dist/fleet/types.js.map +1 -0
- package/dist/graph/cli.d.ts +6 -2
- package/dist/graph/cli.d.ts.map +1 -1
- package/dist/graph/cli.js +53 -12
- package/dist/graph/cli.js.map +1 -1
- package/dist/graph/pipeline-lifecycle.d.ts +9 -0
- package/dist/graph/pipeline-lifecycle.d.ts.map +1 -1
- package/dist/graph/pipeline-lifecycle.js +12 -0
- package/dist/graph/pipeline-lifecycle.js.map +1 -1
- package/dist/graph/preflight-injector.d.ts +14 -0
- package/dist/graph/preflight-injector.d.ts.map +1 -1
- package/dist/graph/preflight-injector.js +84 -4
- package/dist/graph/preflight-injector.js.map +1 -1
- package/dist/incident/types.d.ts +24 -24
- package/dist/mcp/tools/graph-schemas.d.ts +7 -7
- package/dist/mcp/tools/init.d.ts.map +1 -1
- package/dist/mcp/tools/init.js +2 -0
- package/dist/mcp/tools/init.js.map +1 -1
- package/dist/orchestrator/agent-loader.d.ts.map +1 -1
- package/dist/orchestrator/agent-loader.js +15 -1
- package/dist/orchestrator/agent-loader.js.map +1 -1
- package/dist/orchestrator/agentic-loop.d.ts +51 -0
- package/dist/orchestrator/agentic-loop.d.ts.map +1 -1
- package/dist/orchestrator/agentic-loop.js +123 -4
- package/dist/orchestrator/agentic-loop.js.map +1 -1
- package/dist/orchestrator/arch-lenses.d.ts +7 -0
- package/dist/orchestrator/arch-lenses.d.ts.map +1 -0
- package/dist/orchestrator/arch-lenses.js +22 -0
- package/dist/orchestrator/arch-lenses.js.map +1 -0
- package/dist/orchestrator/architect-agent.d.ts +16 -0
- package/dist/orchestrator/architect-agent.d.ts.map +1 -1
- package/dist/orchestrator/architect-agent.js +509 -1
- package/dist/orchestrator/architect-agent.js.map +1 -1
- package/dist/orchestrator/curator-agent.js +1 -1
- package/dist/orchestrator/curator-agent.js.map +1 -1
- package/dist/orchestrator/deploy/types.d.ts +2 -2
- package/dist/orchestrator/documenter-agent.d.ts +57 -0
- package/dist/orchestrator/documenter-agent.d.ts.map +1 -0
- package/dist/orchestrator/documenter-agent.js +195 -0
- package/dist/orchestrator/documenter-agent.js.map +1 -0
- package/dist/orchestrator/environment.d.ts +45 -0
- package/dist/orchestrator/environment.d.ts.map +1 -0
- package/dist/orchestrator/environment.js +151 -0
- package/dist/orchestrator/environment.js.map +1 -0
- package/dist/orchestrator/eval-lenses.d.ts +7 -0
- package/dist/orchestrator/eval-lenses.d.ts.map +1 -0
- package/dist/orchestrator/eval-lenses.js +19 -0
- package/dist/orchestrator/eval-lenses.js.map +1 -0
- package/dist/orchestrator/eval-persist.d.ts +25 -0
- package/dist/orchestrator/eval-persist.d.ts.map +1 -0
- package/dist/orchestrator/eval-persist.js +74 -0
- package/dist/orchestrator/eval-persist.js.map +1 -0
- package/dist/orchestrator/evaluator-agent.d.ts +23 -0
- package/dist/orchestrator/evaluator-agent.d.ts.map +1 -1
- package/dist/orchestrator/evaluator-agent.js +60 -3
- 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 +32 -0
- package/dist/orchestrator/generator-agent.js.map +1 -1
- package/dist/orchestrator/memory/distill.d.ts +60 -0
- package/dist/orchestrator/memory/distill.d.ts.map +1 -0
- package/dist/orchestrator/memory/distill.js +177 -0
- package/dist/orchestrator/memory/distill.js.map +1 -0
- package/dist/orchestrator/memory/eval-source.d.ts +20 -0
- package/dist/orchestrator/memory/eval-source.d.ts.map +1 -0
- package/dist/orchestrator/memory/eval-source.js +88 -0
- package/dist/orchestrator/memory/eval-source.js.map +1 -0
- package/dist/orchestrator/memory/retrieve.d.ts +45 -0
- package/dist/orchestrator/memory/retrieve.d.ts.map +1 -0
- package/dist/orchestrator/memory/retrieve.js +102 -0
- package/dist/orchestrator/memory/retrieve.js.map +1 -0
- package/dist/orchestrator/model-resolver.d.ts.map +1 -1
- package/dist/orchestrator/model-resolver.js +12 -0
- package/dist/orchestrator/model-resolver.js.map +1 -1
- package/dist/orchestrator/pipeline.d.ts +10 -0
- package/dist/orchestrator/pipeline.d.ts.map +1 -1
- package/dist/orchestrator/pipeline.js +111 -3
- package/dist/orchestrator/pipeline.js.map +1 -1
- package/dist/orchestrator/planner-agent.d.ts +22 -1
- package/dist/orchestrator/planner-agent.d.ts.map +1 -1
- package/dist/orchestrator/planner-agent.js +160 -4
- package/dist/orchestrator/planner-agent.js.map +1 -1
- package/dist/orchestrator/research-agent.js +2 -2
- package/dist/orchestrator/research-agent.js.map +1 -1
- package/dist/orchestrator/tools/handlers.d.ts +14 -0
- package/dist/orchestrator/tools/handlers.d.ts.map +1 -1
- package/dist/orchestrator/tools/handlers.js +29 -4
- package/dist/orchestrator/tools/handlers.js.map +1 -1
- package/dist/orchestrator/tools/schemas.js +5 -5
- package/dist/orchestrator/tools/schemas.js.map +1 -1
- package/dist/orchestrator/workflow/args-builder.d.ts +35 -0
- package/dist/orchestrator/workflow/args-builder.d.ts.map +1 -0
- package/dist/orchestrator/workflow/args-builder.js +142 -0
- package/dist/orchestrator/workflow/args-builder.js.map +1 -0
- package/dist/orchestrator/workflow/budget.d.ts +57 -0
- package/dist/orchestrator/workflow/budget.d.ts.map +1 -0
- package/dist/orchestrator/workflow/budget.js +80 -0
- package/dist/orchestrator/workflow/budget.js.map +1 -0
- package/dist/orchestrator/workflow/conformance.d.ts +27 -0
- package/dist/orchestrator/workflow/conformance.d.ts.map +1 -0
- package/dist/orchestrator/workflow/conformance.js +111 -0
- package/dist/orchestrator/workflow/conformance.js.map +1 -0
- package/dist/orchestrator/workflow/eligibility.d.ts +8 -0
- package/dist/orchestrator/workflow/eligibility.d.ts.map +1 -0
- package/dist/orchestrator/workflow/eligibility.js +10 -0
- package/dist/orchestrator/workflow/eligibility.js.map +1 -0
- package/dist/orchestrator/workflow/engine.d.ts +10 -0
- package/dist/orchestrator/workflow/engine.d.ts.map +1 -0
- package/dist/orchestrator/workflow/engine.js +2 -0
- package/dist/orchestrator/workflow/engine.js.map +1 -0
- package/dist/orchestrator/workflow/errors.d.ts +13 -0
- package/dist/orchestrator/workflow/errors.d.ts.map +1 -0
- package/dist/orchestrator/workflow/errors.js +26 -0
- package/dist/orchestrator/workflow/errors.js.map +1 -0
- package/dist/orchestrator/workflow/flusher.d.ts +19 -0
- package/dist/orchestrator/workflow/flusher.d.ts.map +1 -0
- package/dist/orchestrator/workflow/flusher.js +81 -0
- package/dist/orchestrator/workflow/flusher.js.map +1 -0
- package/dist/orchestrator/workflow/interpreter.d.ts +48 -0
- package/dist/orchestrator/workflow/interpreter.d.ts.map +1 -0
- package/dist/orchestrator/workflow/interpreter.js +92 -0
- package/dist/orchestrator/workflow/interpreter.js.map +1 -0
- package/dist/orchestrator/workflow/pure-sprint.d.ts +65 -0
- package/dist/orchestrator/workflow/pure-sprint.d.ts.map +1 -0
- package/dist/orchestrator/workflow/pure-sprint.js +82 -0
- package/dist/orchestrator/workflow/pure-sprint.js.map +1 -0
- package/dist/orchestrator/workflow/reconciler.d.ts +15 -0
- package/dist/orchestrator/workflow/reconciler.d.ts.map +1 -0
- package/dist/orchestrator/workflow/reconciler.js +65 -0
- package/dist/orchestrator/workflow/reconciler.js.map +1 -0
- package/dist/orchestrator/workflow/resume-cursor.d.ts +10 -0
- package/dist/orchestrator/workflow/resume-cursor.d.ts.map +1 -0
- package/dist/orchestrator/workflow/resume-cursor.js +25 -0
- package/dist/orchestrator/workflow/resume-cursor.js.map +1 -0
- package/dist/orchestrator/workflow/retry.d.ts +50 -0
- package/dist/orchestrator/workflow/retry.d.ts.map +1 -0
- package/dist/orchestrator/workflow/retry.js +100 -0
- package/dist/orchestrator/workflow/retry.js.map +1 -0
- package/dist/orchestrator/workflow/scheduler.d.ts +87 -0
- package/dist/orchestrator/workflow/scheduler.d.ts.map +1 -0
- package/dist/orchestrator/workflow/scheduler.js +158 -0
- package/dist/orchestrator/workflow/scheduler.js.map +1 -0
- package/dist/orchestrator/workflow/selector.d.ts +26 -0
- package/dist/orchestrator/workflow/selector.d.ts.map +1 -0
- package/dist/orchestrator/workflow/selector.js +54 -0
- package/dist/orchestrator/workflow/selector.js.map +1 -0
- package/dist/orchestrator/workflow/synthesizer.d.ts +52 -0
- package/dist/orchestrator/workflow/synthesizer.d.ts.map +1 -0
- package/dist/orchestrator/workflow/synthesizer.js +75 -0
- package/dist/orchestrator/workflow/synthesizer.js.map +1 -0
- package/dist/orchestrator/workflow/ts-engine.d.ts +13 -0
- package/dist/orchestrator/workflow/ts-engine.d.ts.map +1 -0
- package/dist/orchestrator/workflow/ts-engine.js +14 -0
- package/dist/orchestrator/workflow/ts-engine.js.map +1 -0
- package/dist/orchestrator/workflow/types.d.ts +55 -0
- package/dist/orchestrator/workflow/types.d.ts.map +1 -0
- package/dist/orchestrator/workflow/types.js +3 -0
- package/dist/orchestrator/workflow/types.js.map +1 -0
- package/dist/orchestrator/workflow/workflow-engine.d.ts +31 -0
- package/dist/orchestrator/workflow/workflow-engine.d.ts.map +1 -0
- package/dist/orchestrator/workflow/workflow-engine.js +70 -0
- package/dist/orchestrator/workflow/workflow-engine.js.map +1 -0
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +49 -6
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/claude-code.d.ts +44 -0
- package/dist/providers/claude-code.d.ts.map +1 -0
- package/dist/providers/claude-code.js +143 -0
- package/dist/providers/claude-code.js.map +1 -0
- package/dist/providers/factory.d.ts +16 -2
- package/dist/providers/factory.d.ts.map +1 -1
- package/dist/providers/factory.js +66 -12
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +27 -3
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/index.d.ts +3 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +3 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +24 -3
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/preflight.d.ts +22 -0
- package/dist/providers/preflight.d.ts.map +1 -0
- package/dist/providers/preflight.js +54 -0
- package/dist/providers/preflight.js.map +1 -0
- package/dist/providers/structured.d.ts +130 -0
- package/dist/providers/structured.d.ts.map +1 -0
- package/dist/providers/structured.js +205 -0
- package/dist/providers/structured.js.map +1 -0
- package/dist/providers/types.d.ts +28 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/state/history-rotation.d.ts +17 -0
- package/dist/state/history-rotation.d.ts.map +1 -0
- package/dist/state/history-rotation.js +84 -0
- package/dist/state/history-rotation.js.map +1 -0
- package/dist/state/history.d.ts +16 -4
- package/dist/state/history.d.ts.map +1 -1
- package/dist/state/history.js +62 -20
- package/dist/state/history.js.map +1 -1
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +1 -1
- package/dist/state/index.js.map +1 -1
- package/dist/state/memory.d.ts +60 -0
- package/dist/state/memory.d.ts.map +1 -0
- package/dist/state/memory.js +242 -0
- package/dist/state/memory.js.map +1 -0
- package/hooks/hooks.json +12 -2
- package/package.json +9 -5
- package/scripts/spike-claude-code-provider.mjs +66 -0
- package/scripts/spike-deepseek.mjs +63 -0
- package/scripts/sync-targets.json +12 -0
- package/scripts/update-all.mjs +255 -0
- package/skills/bober.architect/SKILL.md +13 -0
- package/skills/bober.architect/references/arch-lens-panel.md +126 -0
- package/skills/bober.eval/SKILL.md +9 -0
- package/skills/bober.eval/references/lens-panel.md +115 -0
- package/skills/bober.plan/SKILL.md +6 -0
- package/skills/bober.run/SKILL.md +23 -4
- package/skills/bober.run/references/lens-panel.md +115 -0
- package/skills/bober.sprint/SKILL.md +44 -2
- package/skills/bober.sprint/references/lens-panel.md +115 -0
- package/skills/shared/arch-lens-panel.md +126 -0
- package/skills/shared/lens-panel.md +115 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PlanSpec } from "../../contracts/spec.js";
|
|
2
|
+
import type { SprintContract } from "../../contracts/sprint-contract.js";
|
|
3
|
+
import type { EvalResult } from "../../contracts/eval-result.js";
|
|
4
|
+
import type { HistoryEntry } from "../../state/history.js";
|
|
5
|
+
import type { PipelineEngineName } from "./engine.js";
|
|
6
|
+
export type { PipelineEngineName } from "./engine.js";
|
|
7
|
+
export type WorkflowArgs = {
|
|
8
|
+
userPrompt: string;
|
|
9
|
+
knobs: {
|
|
10
|
+
maxIterations: number;
|
|
11
|
+
maxSprints: number;
|
|
12
|
+
researchPhase: boolean;
|
|
13
|
+
architectPhase: boolean;
|
|
14
|
+
curatorEnabled: boolean;
|
|
15
|
+
codeReviewEnabled: boolean;
|
|
16
|
+
requireContracts: boolean;
|
|
17
|
+
};
|
|
18
|
+
models: {
|
|
19
|
+
planner: string;
|
|
20
|
+
curator: string;
|
|
21
|
+
generator: string;
|
|
22
|
+
evaluator: string;
|
|
23
|
+
};
|
|
24
|
+
evaluatorLenses: string[];
|
|
25
|
+
principles: string;
|
|
26
|
+
preloadedSpec?: PlanSpec;
|
|
27
|
+
preloadedContracts: SprintContract[];
|
|
28
|
+
resumeCursor: ResumeCursor;
|
|
29
|
+
};
|
|
30
|
+
export type WorkflowRunResult = {
|
|
31
|
+
spec: PlanSpec;
|
|
32
|
+
perSprint: Array<{
|
|
33
|
+
contract: SprintContract;
|
|
34
|
+
finalVerdict: EvalResult;
|
|
35
|
+
iterationsUsed: number;
|
|
36
|
+
outcome: "passed" | "needs-rework" | "failed";
|
|
37
|
+
lensVerdicts: EvalResult[];
|
|
38
|
+
}>;
|
|
39
|
+
needsClarification: boolean;
|
|
40
|
+
pendingHistory: Array<Omit<HistoryEntry, "timestamp">>;
|
|
41
|
+
};
|
|
42
|
+
export type ResumeCursor = {
|
|
43
|
+
specId: string;
|
|
44
|
+
completedSprintNumbers: number[];
|
|
45
|
+
lastObservedSprintNumber: number;
|
|
46
|
+
};
|
|
47
|
+
export type ConformanceReport = {
|
|
48
|
+
equivalent: boolean;
|
|
49
|
+
diffs: Array<{
|
|
50
|
+
artifact: "spec" | "contract" | "eval-result" | "history";
|
|
51
|
+
path: string;
|
|
52
|
+
engines: PipelineEngineName[];
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/workflow/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE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YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;CACxD,CAAC;AAIF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAIF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;QACX,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,aAAa,GAAG,SAAS,CAAC;QAC1D,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,kBAAkB,EAAE,CAAC;KAC/B,CAAC,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/orchestrator/workflow/types.ts"],"names":[],"mappings":"AAAA,uEAAuE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BoberConfig } from "../../config/schema.js";
|
|
2
|
+
import type { PipelineResult } from "../pipeline.js";
|
|
3
|
+
import type { PipelineEngine, PipelineEngineName } from "./engine.js";
|
|
4
|
+
/**
|
|
5
|
+
* Pipeline engine that assembles and invokes the Dynamic Workflows runtime.
|
|
6
|
+
*
|
|
7
|
+
* Control flow (eligibility FIRST — avoids MissingKnobError on the downgrade path):
|
|
8
|
+
* 1. if (!isWorkflowEligible(config)) → log once + return tsEngine.run(...) ← NO args built
|
|
9
|
+
* 2. cursor = reconstruct(...) ← read-only (listContracts + loadHistory)
|
|
10
|
+
* 3. args = build(...) ← pure; may throw MissingKnobError (acceptable: eligible)
|
|
11
|
+
* 4. try { result = invoke(args); return flush(result) }
|
|
12
|
+
* catch WorkflowUnavailableError → log once + return tsEngine.run(...) ← NO partial flush
|
|
13
|
+
* catch other → rethrow
|
|
14
|
+
*
|
|
15
|
+
* invoke() is DORMANT this release — always throws WorkflowUnavailableError.
|
|
16
|
+
* The eligible path is only reachable in tests that force eligibility=true via
|
|
17
|
+
* the injection seam (constructor param + vi.mock).
|
|
18
|
+
*/
|
|
19
|
+
export declare class WorkflowEngine implements PipelineEngine {
|
|
20
|
+
private readonly tsEngineFactory;
|
|
21
|
+
readonly name: PipelineEngineName;
|
|
22
|
+
/**
|
|
23
|
+
* Injection seam — tsEngineFactory defaults to () => new TsPipelineEngine().
|
|
24
|
+
* Tests inject a fake factory that returns a sentinel PipelineResult without
|
|
25
|
+
* spawning real LLM agents.
|
|
26
|
+
*/
|
|
27
|
+
constructor(tsEngineFactory?: () => PipelineEngine);
|
|
28
|
+
run(userPrompt: string, projectRoot: string, config: BoberConfig): Promise<PipelineResult>;
|
|
29
|
+
private invoke;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=workflow-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-engine.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/workflow/workflow-engine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAWtE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,YAAW,cAAc;IASjD,OAAO,CAAC,QAAQ,CAAC,eAAe;IARlC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAc;IAE/C;;;;OAIG;gBAEgB,eAAe,GAAE,MAAM,cAChB;IAGpB,GAAG,CACP,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,cAAc,CAAC;YAwCZ,MAAM;CAKrB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// ── WorkflowEngine ─────────────────────────────────────────────────
|
|
2
|
+
import { logger } from "../../utils/logger.js";
|
|
3
|
+
import { isWorkflowEligible } from "./eligibility.js";
|
|
4
|
+
import { ResumeCursorReconstructor } from "./resume-cursor.js";
|
|
5
|
+
import { ArgsPayloadBuilder } from "./args-builder.js";
|
|
6
|
+
import { RunResultFlusher } from "./flusher.js";
|
|
7
|
+
import { TsPipelineEngine } from "./ts-engine.js";
|
|
8
|
+
import { WorkflowUnavailableError } from "./errors.js";
|
|
9
|
+
// ── WorkflowEngine ──────────────────────────────────────────────────
|
|
10
|
+
/**
|
|
11
|
+
* Pipeline engine that assembles and invokes the Dynamic Workflows runtime.
|
|
12
|
+
*
|
|
13
|
+
* Control flow (eligibility FIRST — avoids MissingKnobError on the downgrade path):
|
|
14
|
+
* 1. if (!isWorkflowEligible(config)) → log once + return tsEngine.run(...) ← NO args built
|
|
15
|
+
* 2. cursor = reconstruct(...) ← read-only (listContracts + loadHistory)
|
|
16
|
+
* 3. args = build(...) ← pure; may throw MissingKnobError (acceptable: eligible)
|
|
17
|
+
* 4. try { result = invoke(args); return flush(result) }
|
|
18
|
+
* catch WorkflowUnavailableError → log once + return tsEngine.run(...) ← NO partial flush
|
|
19
|
+
* catch other → rethrow
|
|
20
|
+
*
|
|
21
|
+
* invoke() is DORMANT this release — always throws WorkflowUnavailableError.
|
|
22
|
+
* The eligible path is only reachable in tests that force eligibility=true via
|
|
23
|
+
* the injection seam (constructor param + vi.mock).
|
|
24
|
+
*/
|
|
25
|
+
export class WorkflowEngine {
|
|
26
|
+
tsEngineFactory;
|
|
27
|
+
name = "workflow";
|
|
28
|
+
/**
|
|
29
|
+
* Injection seam — tsEngineFactory defaults to () => new TsPipelineEngine().
|
|
30
|
+
* Tests inject a fake factory that returns a sentinel PipelineResult without
|
|
31
|
+
* spawning real LLM agents.
|
|
32
|
+
*/
|
|
33
|
+
constructor(tsEngineFactory = () => new TsPipelineEngine()) {
|
|
34
|
+
this.tsEngineFactory = tsEngineFactory;
|
|
35
|
+
}
|
|
36
|
+
async run(userPrompt, projectRoot, config) {
|
|
37
|
+
// ── STEP 1: Eligibility check FIRST (avoids MissingKnobError on downgrade path) ──
|
|
38
|
+
if (!isWorkflowEligible(config)) {
|
|
39
|
+
logger.info("workflow runtime unavailable — re-dispatching TS engine");
|
|
40
|
+
return this.tsEngineFactory().run(userPrompt, projectRoot, config);
|
|
41
|
+
}
|
|
42
|
+
// ── STEP 2: Reconstruct cursor (read-only — writes nothing) ────────────────
|
|
43
|
+
// specId is derived from config or empty — invoke is dormant so this is
|
|
44
|
+
// never persisted. The PipelineEngine.run() signature is frozen (no specId).
|
|
45
|
+
const specId = config.project?.specId ?? "";
|
|
46
|
+
const cursor = await new ResumeCursorReconstructor().reconstruct(projectRoot, specId);
|
|
47
|
+
// ── STEP 3: Build args (pure — throws MissingKnobError if knobs missing) ────
|
|
48
|
+
const args = new ArgsPayloadBuilder().build(userPrompt, config, cursor, "");
|
|
49
|
+
// ── STEP 4: Invoke → flush; catch WorkflowUnavailableError → re-dispatch ───
|
|
50
|
+
try {
|
|
51
|
+
const result = await this.invoke(args);
|
|
52
|
+
return await new RunResultFlusher().flush(projectRoot, config, result);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
if (e instanceof WorkflowUnavailableError) {
|
|
56
|
+
logger.info("workflow runtime unavailable — re-dispatching TS engine");
|
|
57
|
+
return this.tsEngineFactory().run(userPrompt, projectRoot, config);
|
|
58
|
+
}
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// ── Dormant invoke (non-goal: no live transport this release) ──────────────
|
|
63
|
+
//
|
|
64
|
+
// Always throws WorkflowUnavailableError so the run() catch block re-dispatches
|
|
65
|
+
// to the TS engine with zero partial flush (flush is only reached post-invoke).
|
|
66
|
+
async invoke(_args) {
|
|
67
|
+
throw new WorkflowUnavailableError("Programmatic workflow invoke is not implemented this release.");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=workflow-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-engine.js","sourceRoot":"","sources":["../../../src/orchestrator/workflow/workflow-engine.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAItE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,uEAAuE;AAEvE;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAc;IASN;IARV,IAAI,GAAuB,UAAU,CAAC;IAE/C;;;;OAIG;IACH,YACmB,kBAAwC,GAAG,EAAE,CAC5D,IAAI,gBAAgB,EAAE;QADP,oBAAe,GAAf,eAAe,CACR;IACvB,CAAC;IAEJ,KAAK,CAAC,GAAG,CACP,UAAkB,EAClB,WAAmB,EACnB,MAAmB;QAEnB,oFAAoF;QACpF,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CACT,yDAAyD,CAC1D,CAAC;YACF,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QACrE,CAAC;QAED,8EAA8E;QAC9E,wEAAwE;QACxE,6EAA6E;QAC7E,MAAM,MAAM,GAAI,MAAM,CAAC,OAA2C,EAAE,MAAM,IAAI,EAAE,CAAC;QACjF,MAAM,MAAM,GAAG,MAAM,IAAI,yBAAyB,EAAE,CAAC,WAAW,CAC9D,WAAW,EACX,MAAM,CACP,CAAC;QAEF,+EAA+E;QAC/E,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U,GAAG,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAKb,MAAM,YAAY,CAAC;AA6LpB;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;gBAE5B,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE;IAKzD,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;CA8FtD"}
|
|
@@ -178,8 +178,26 @@ export class AnthropicAdapter {
|
|
|
178
178
|
const { model, system, messages, tools, maxTokens = 16384, effort } = params;
|
|
179
179
|
// Convert provider-agnostic Message[] to Anthropic MessageParam[]
|
|
180
180
|
const anthropicMessages = messages.map(toAnthropicMessage);
|
|
181
|
-
//
|
|
182
|
-
|
|
181
|
+
// ── Structured output branch ────────────────────────────────────
|
|
182
|
+
// When responseSchema is set, force a single "structured_output" tool
|
|
183
|
+
// whose input_schema IS the schema, and do NOT forward the user's tools.
|
|
184
|
+
// tool_choice forces the model to call it, and we stringify the resulting
|
|
185
|
+
// tool input into ChatResponse.text (with empty toolCalls).
|
|
186
|
+
const structured = params.responseSchema !== undefined;
|
|
187
|
+
const forcedTool = structured
|
|
188
|
+
? {
|
|
189
|
+
name: "structured_output",
|
|
190
|
+
description: "Return your answer as a single structured JSON object matching the schema.",
|
|
191
|
+
input_schema: params.responseSchema,
|
|
192
|
+
}
|
|
193
|
+
: undefined;
|
|
194
|
+
// Convert ToolDef[] to Anthropic.Messages.Tool[]. In the structured branch
|
|
195
|
+
// the user's tools are intentionally suppressed in favour of the forced tool.
|
|
196
|
+
const anthropicTools = structured
|
|
197
|
+
? [forcedTool]
|
|
198
|
+
: tools && tools.length > 0
|
|
199
|
+
? tools.map(toAnthropicTool)
|
|
200
|
+
: undefined;
|
|
183
201
|
// ── Prompt caching branch ──────────────────────────────────────
|
|
184
202
|
// When enabled: system becomes a TextBlockParam[] with cache_control,
|
|
185
203
|
// and breakpoints are attached to the final block of up to the last 3
|
|
@@ -198,16 +216,41 @@ export class AnthropicAdapter {
|
|
|
198
216
|
messages: cachedMessages,
|
|
199
217
|
tools: anthropicTools,
|
|
200
218
|
...(effort !== undefined ? { output_config: { effort } } : {}),
|
|
219
|
+
...(structured
|
|
220
|
+
? {
|
|
221
|
+
tool_choice: {
|
|
222
|
+
type: "tool",
|
|
223
|
+
name: "structured_output",
|
|
224
|
+
},
|
|
225
|
+
}
|
|
226
|
+
: {}),
|
|
201
227
|
});
|
|
202
228
|
const { text, toolCalls } = normalizeContent(response.content);
|
|
229
|
+
const usage = {
|
|
230
|
+
inputTokens: response.usage.input_tokens,
|
|
231
|
+
outputTokens: response.usage.output_tokens,
|
|
232
|
+
};
|
|
233
|
+
// ── Structured output normalisation ─────────────────────────────
|
|
234
|
+
// Take the forced tool call's input, stringify it into text, and return
|
|
235
|
+
// empty toolCalls with a clean "end" stop reason. If the forced tool call
|
|
236
|
+
// is somehow absent, fall back to the normal normalized result so the
|
|
237
|
+
// caller's coerce/repair can still try.
|
|
238
|
+
if (structured) {
|
|
239
|
+
const forced = toolCalls.find((tc) => tc.name === "structured_output");
|
|
240
|
+
if (forced !== undefined) {
|
|
241
|
+
return {
|
|
242
|
+
text: JSON.stringify(forced.input),
|
|
243
|
+
toolCalls: [],
|
|
244
|
+
stopReason: "end",
|
|
245
|
+
usage,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
203
249
|
return {
|
|
204
250
|
text,
|
|
205
251
|
toolCalls,
|
|
206
252
|
stopReason: normalizeStopReason(response.stop_reason),
|
|
207
|
-
usage
|
|
208
|
-
inputTokens: response.usage.input_tokens,
|
|
209
|
-
outputTokens: response.usage.output_tokens,
|
|
210
|
-
},
|
|
253
|
+
usage,
|
|
211
254
|
};
|
|
212
255
|
}
|
|
213
256
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAY1C,uEAAuE;AAEvE;;;;;GAKG;AACH,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,YAAY,EAAE,IAAI,CAAC,YAAuD;KAC3E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAC1B,MAAiD;IAEjD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,UAAU;YACb,OAAO,KAAK,CAAC;QACf,KAAK,UAAU;YACb,OAAO,UAAU,CAAC;QACpB,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,MAAM,IAAI,KAAK,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CACvB,OAA0C;IAE1C,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,MAAM,SAAS,GAAe,EAAE,CAAC;IAEjC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1B,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;QACrB,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACrC,SAAS,CAAC,IAAI,CAAC;gBACb,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,KAAgC;aAC9C,CAAC,CAAC;QACL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AC;QAED,OAAO;YACL,IAAI;YACJ,SAAS;YACT,UAAU,EAAE,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC;YACrD,KAAK;SACN,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code subscription provider.
|
|
3
|
+
*
|
|
4
|
+
* Backs the LLMClient interface with the local `claude` CLI in headless
|
|
5
|
+
* print mode (`claude -p --output-format json`), so model calls bill against
|
|
6
|
+
* the user's Claude Pro/Max SUBSCRIPTION credit instead of an
|
|
7
|
+
* ANTHROPIC_API_KEY. No API key is read or required by this adapter.
|
|
8
|
+
*
|
|
9
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
10
|
+
* CAPABILITY BOUNDARY:
|
|
11
|
+
*
|
|
12
|
+
* agent-bober drives its OWN agentic loop: chat() is contracted to take MY
|
|
13
|
+
* tools, return ONE model turn, stop at tool_use, and let the caller execute
|
|
14
|
+
* the tool. The `claude` CLI does the OPPOSITE — it runs ITS OWN loop with
|
|
15
|
+
* ITS OWN built-in tools (Read/Write/Bash) and never hands custom tool_use
|
|
16
|
+
* blocks back. There is no faithful single-turn-with-my-tools mode.
|
|
17
|
+
*
|
|
18
|
+
* Therefore this adapter supports ONLY the no-tools case (system + messages
|
|
19
|
+
* → text). That covers the pure prompt→text roles (planner, researcher
|
|
20
|
+
* question-gen). If `params.tools` is non-empty it THROWS rather than
|
|
21
|
+
* silently dropping the tools and corrupting the caller's loop.
|
|
22
|
+
*
|
|
23
|
+
* COST CAVEAT: `claude -p` injects Claude Code's full system prompt
|
|
24
|
+
* (~40k cache-creation tokens) on every call, and post-2026-06-15 these calls
|
|
25
|
+
* bill at standard API rates against a capped monthly subscription credit
|
|
26
|
+
* (Max 5×=$100/mo, 20×=$200/mo, no rollover). This path is NOT free-unlimited.
|
|
27
|
+
*
|
|
28
|
+
* TERMS: programmatic subscription use via `claude -p` is permitted by
|
|
29
|
+
* Anthropic as of 2026-06-15, billed from the separate Agent-SDK/CLI credit.
|
|
30
|
+
* Verify current terms before relying on it at scale.
|
|
31
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
32
|
+
*/
|
|
33
|
+
import type { LLMClient, ChatParams, ChatResponse } from "./types.js";
|
|
34
|
+
export declare class ClaudeCodeAdapter implements LLMClient {
|
|
35
|
+
private readonly binary;
|
|
36
|
+
private readonly timeoutMs;
|
|
37
|
+
/**
|
|
38
|
+
* @param binary Path/name of the claude CLI (default "claude").
|
|
39
|
+
* @param timeoutMs Per-call timeout. Default 180s (sprints make long calls).
|
|
40
|
+
*/
|
|
41
|
+
constructor(binary?: string, timeoutMs?: number);
|
|
42
|
+
chat(params: ChatParams): Promise<ChatResponse>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=claude-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../src/providers/claude-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAEb,MAAM,YAAY,CAAC;AAyDpB,qBAAa,iBAAkB,YAAW,SAAS;IAM/C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAN5B;;;OAGG;gBAEgB,MAAM,GAAE,MAAiB,EACzB,SAAS,GAAE,MAAgB;IAGxC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;CA0EtD"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code subscription provider.
|
|
3
|
+
*
|
|
4
|
+
* Backs the LLMClient interface with the local `claude` CLI in headless
|
|
5
|
+
* print mode (`claude -p --output-format json`), so model calls bill against
|
|
6
|
+
* the user's Claude Pro/Max SUBSCRIPTION credit instead of an
|
|
7
|
+
* ANTHROPIC_API_KEY. No API key is read or required by this adapter.
|
|
8
|
+
*
|
|
9
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
10
|
+
* CAPABILITY BOUNDARY:
|
|
11
|
+
*
|
|
12
|
+
* agent-bober drives its OWN agentic loop: chat() is contracted to take MY
|
|
13
|
+
* tools, return ONE model turn, stop at tool_use, and let the caller execute
|
|
14
|
+
* the tool. The `claude` CLI does the OPPOSITE — it runs ITS OWN loop with
|
|
15
|
+
* ITS OWN built-in tools (Read/Write/Bash) and never hands custom tool_use
|
|
16
|
+
* blocks back. There is no faithful single-turn-with-my-tools mode.
|
|
17
|
+
*
|
|
18
|
+
* Therefore this adapter supports ONLY the no-tools case (system + messages
|
|
19
|
+
* → text). That covers the pure prompt→text roles (planner, researcher
|
|
20
|
+
* question-gen). If `params.tools` is non-empty it THROWS rather than
|
|
21
|
+
* silently dropping the tools and corrupting the caller's loop.
|
|
22
|
+
*
|
|
23
|
+
* COST CAVEAT: `claude -p` injects Claude Code's full system prompt
|
|
24
|
+
* (~40k cache-creation tokens) on every call, and post-2026-06-15 these calls
|
|
25
|
+
* bill at standard API rates against a capped monthly subscription credit
|
|
26
|
+
* (Max 5×=$100/mo, 20×=$200/mo, no rollover). This path is NOT free-unlimited.
|
|
27
|
+
*
|
|
28
|
+
* TERMS: programmatic subscription use via `claude -p` is permitted by
|
|
29
|
+
* Anthropic as of 2026-06-15, billed from the separate Agent-SDK/CLI credit.
|
|
30
|
+
* Verify current terms before relying on it at scale.
|
|
31
|
+
* ─────────────────────────────────────────────────────────────────────────
|
|
32
|
+
*/
|
|
33
|
+
import { execa } from "execa";
|
|
34
|
+
/** Map the CLI's stop_reason onto agent-bober's normalized StopReason. */
|
|
35
|
+
function mapStopReason(raw) {
|
|
36
|
+
switch (raw) {
|
|
37
|
+
case "end_turn":
|
|
38
|
+
return "end";
|
|
39
|
+
case "tool_use":
|
|
40
|
+
return "tool_use";
|
|
41
|
+
case "max_tokens":
|
|
42
|
+
return "max_tokens";
|
|
43
|
+
default:
|
|
44
|
+
return raw ?? "end";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Flatten the provider-agnostic Message[] into a single prompt string for the
|
|
49
|
+
* CLI's `-p` argument. The CLI takes one prompt, not a structured transcript,
|
|
50
|
+
* so we render the conversation as labelled turns. Adequate for the no-tools
|
|
51
|
+
* roles this adapter targets; NOT a faithful multi-turn tool transcript.
|
|
52
|
+
*/
|
|
53
|
+
function flattenMessages(messages) {
|
|
54
|
+
const parts = [];
|
|
55
|
+
for (const m of messages) {
|
|
56
|
+
if ("systemUpdate" in m) {
|
|
57
|
+
parts.push(`[system update]\n${m.systemUpdate}`);
|
|
58
|
+
}
|
|
59
|
+
else if ("toolResults" in m) {
|
|
60
|
+
// No-tools adapter: tool results shouldn't occur, but render defensively.
|
|
61
|
+
for (const r of m.toolResults) {
|
|
62
|
+
parts.push(`[tool result ${r.toolUseId}]\n${r.content}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (m.role === "assistant") {
|
|
66
|
+
parts.push(`Assistant: ${m.content}`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
parts.push(`User: ${m.content}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return parts.join("\n\n");
|
|
73
|
+
}
|
|
74
|
+
export class ClaudeCodeAdapter {
|
|
75
|
+
binary;
|
|
76
|
+
timeoutMs;
|
|
77
|
+
/**
|
|
78
|
+
* @param binary Path/name of the claude CLI (default "claude").
|
|
79
|
+
* @param timeoutMs Per-call timeout. Default 180s (sprints make long calls).
|
|
80
|
+
*/
|
|
81
|
+
constructor(binary = "claude", timeoutMs = 180_000) {
|
|
82
|
+
this.binary = binary;
|
|
83
|
+
this.timeoutMs = timeoutMs;
|
|
84
|
+
}
|
|
85
|
+
async chat(params) {
|
|
86
|
+
const { system, messages, tools, model } = params;
|
|
87
|
+
// Hard fail on tools — see SPIKE SCOPE. Silent drop would corrupt the
|
|
88
|
+
// caller's agentic loop (it would wait forever for tool_use that can't come).
|
|
89
|
+
if (tools && tools.length > 0) {
|
|
90
|
+
throw new Error("ClaudeCodeAdapter (spike) does not support custom tools: the `claude` " +
|
|
91
|
+
"CLI runs its own tool loop and cannot return custom tool_use blocks. " +
|
|
92
|
+
"Use this provider only for prompt→text roles (e.g. planner), or use " +
|
|
93
|
+
"the anthropic/openai-compat providers for tool-driven roles.");
|
|
94
|
+
}
|
|
95
|
+
const prompt = flattenMessages(messages);
|
|
96
|
+
const args = [
|
|
97
|
+
"-p",
|
|
98
|
+
prompt,
|
|
99
|
+
"--output-format",
|
|
100
|
+
"json",
|
|
101
|
+
// Disable Claude Code's built-in tools — we want pure completion, not its loop.
|
|
102
|
+
"--disallowed-tools",
|
|
103
|
+
"Read Edit Write Bash Glob Grep WebFetch WebSearch Task",
|
|
104
|
+
// Don't inherit the project's MCP servers (keeps the call hermetic).
|
|
105
|
+
"--strict-mcp-config",
|
|
106
|
+
];
|
|
107
|
+
if (system && system.trim().length > 0) {
|
|
108
|
+
args.push("--append-system-prompt", system);
|
|
109
|
+
}
|
|
110
|
+
if (model) {
|
|
111
|
+
args.push("--model", model);
|
|
112
|
+
}
|
|
113
|
+
const result = await execa(this.binary, args, {
|
|
114
|
+
reject: false,
|
|
115
|
+
timeout: this.timeoutMs,
|
|
116
|
+
// No stdin; everything is in args.
|
|
117
|
+
input: "",
|
|
118
|
+
});
|
|
119
|
+
if (result.exitCode !== 0) {
|
|
120
|
+
throw new Error(`claude CLI exited ${String(result.exitCode)}: ${result.stderr || result.stdout || "no output"}`);
|
|
121
|
+
}
|
|
122
|
+
let parsed;
|
|
123
|
+
try {
|
|
124
|
+
parsed = JSON.parse(result.stdout);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
throw new Error(`claude CLI returned non-JSON output: ${result.stdout.slice(0, 200)}`);
|
|
128
|
+
}
|
|
129
|
+
if (parsed.is_error) {
|
|
130
|
+
throw new Error(`claude CLI reported an error: ${parsed.result ?? parsed.subtype ?? "unknown"}`);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
text: parsed.result ?? "",
|
|
134
|
+
toolCalls: [],
|
|
135
|
+
stopReason: mapStopReason(parsed.stop_reason),
|
|
136
|
+
usage: {
|
|
137
|
+
inputTokens: parsed.usage?.input_tokens ?? 0,
|
|
138
|
+
outputTokens: parsed.usage?.output_tokens ?? 0,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=claude-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/providers/claude-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAwB9B,0EAA0E;AAC1E,SAAS,aAAa,CAAC,GAAuB;IAC5C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,UAAU;YACb,OAAO,KAAK,CAAC;QACf,KAAK,UAAU;YACb,OAAO,UAAU,CAAC;QACpB,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,GAAG,IAAI,KAAK,CAAC;IACxB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,QAAgC;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;QACnD,CAAC;aAAM,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;YAC9B,0EAA0E;YAC1E,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;gBAC9B,KAAK,CAAC,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Y,EAAE,MAAM,CAAC,KAAK,EAAE,aAAa,IAAI,CAAC;aAC/C;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,16 +2,30 @@ import type { LLMClient } from "./types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The set of provider names currently supported.
|
|
4
4
|
*/
|
|
5
|
-
export type ProviderName = "anthropic" | "openai" | "google" | "openai-compat";
|
|
5
|
+
export type ProviderName = "anthropic" | "openai" | "google" | "openai-compat" | "claude-code";
|
|
6
|
+
/**
|
|
7
|
+
* Injectable probe function for verifying the claude CLI is on PATH.
|
|
8
|
+
* Defaults to an execa-based check; override in tests to avoid real CLI calls.
|
|
9
|
+
*/
|
|
10
|
+
export type BinaryProbe = (binary: string) => Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Verify the claude CLI binary is on PATH. Throws an Error naming the binary
|
|
13
|
+
* when it is absent. Call this before using the claude-code provider.
|
|
14
|
+
*
|
|
15
|
+
* @param binary - CLI binary name/path (default "claude").
|
|
16
|
+
* @param probe - Injectable PATH-check function (default uses execa; override in tests).
|
|
17
|
+
*/
|
|
18
|
+
export declare function preflightClaudeBinary(binary?: string, probe?: BinaryProbe): Promise<void>;
|
|
6
19
|
/**
|
|
7
20
|
* Validate that the required API key environment variable is set for a given provider.
|
|
8
21
|
*
|
|
9
22
|
* @param resolvedProvider - The resolved provider name.
|
|
10
23
|
* @param role - Optional role label (e.g. "Planner", "Generator", "Evaluator") for the error message.
|
|
11
24
|
* @param apiKey - Optional explicit API key from providerConfig (skips env var check if set).
|
|
25
|
+
* @param endpoint - Optional endpoint URL used to distinguish DeepSeek from other openai-compat servers.
|
|
12
26
|
* @throws If the required environment variable is missing and no explicit apiKey was provided.
|
|
13
27
|
*/
|
|
14
|
-
export declare function validateApiKey(resolvedProvider: string, role?: string, apiKey?: string): void;
|
|
28
|
+
export declare function validateApiKey(resolvedProvider: string, role?: string, apiKey?: string, endpoint?: string): void;
|
|
15
29
|
/**
|
|
16
30
|
* Create an LLMClient for the given provider.
|
|
17
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAA4B,MAAM,YAAY,CAAC;AAItE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,GAAG,aAAa,CAAC;AA6B/F;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAW/D;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,SAAW,EACjB,KAAK,GAAE,WAAgC,GACtC,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CA0DN;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EACxB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,GACZ,SAAS,CAmGX"}
|