agent-bober 0.12.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 +243 -0
- package/README.md +238 -5
- package/agents/bober-architect.md +72 -0
- package/agents/bober-code-reviewer.md +238 -0
- package/agents/bober-curator.md +49 -0
- package/agents/bober-deployer.md +267 -0
- package/agents/bober-diagnoser.md +289 -0
- package/agents/bober-documenter.md +129 -0
- package/agents/bober-evaluator.md +135 -1
- package/agents/bober-generator.md +80 -3
- package/agents/bober-planner.md +47 -1
- package/agents/bober-postmortemer.md +185 -0
- package/agents/bober-researcher.md +38 -0
- package/dist/cli/commands/approve.d.ts +17 -0
- package/dist/cli/commands/approve.d.ts.map +1 -0
- package/dist/cli/commands/approve.js +64 -0
- package/dist/cli/commands/approve.js.map +1 -0
- package/dist/cli/commands/audit-show.d.ts +14 -0
- package/dist/cli/commands/audit-show.d.ts.map +1 -0
- package/dist/cli/commands/audit-show.js +85 -0
- package/dist/cli/commands/audit-show.js.map +1 -0
- package/dist/cli/commands/config.d.ts +10 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +73 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/graph.d.ts +8 -0
- package/dist/cli/commands/graph.d.ts.map +1 -0
- package/dist/cli/commands/graph.js +219 -0
- package/dist/cli/commands/graph.js.map +1 -0
- package/dist/cli/commands/impact.d.ts +19 -0
- package/dist/cli/commands/impact.d.ts.map +1 -0
- package/dist/cli/commands/impact.js +191 -0
- package/dist/cli/commands/impact.js.map +1 -0
- package/dist/cli/commands/incident.d.ts +19 -0
- package/dist/cli/commands/incident.d.ts.map +1 -0
- package/dist/cli/commands/incident.js +324 -0
- package/dist/cli/commands/incident.js.map +1 -0
- package/dist/cli/commands/init.js +40 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/list-approvals.d.ts +16 -0
- package/dist/cli/commands/list-approvals.d.ts.map +1 -0
- package/dist/cli/commands/list-approvals.js +57 -0
- package/dist/cli/commands/list-approvals.js.map +1 -0
- 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/commands/onboard.d.ts +3 -0
- package/dist/cli/commands/onboard.d.ts.map +1 -0
- package/dist/cli/commands/onboard.js +190 -0
- package/dist/cli/commands/onboard.js.map +1 -0
- package/dist/cli/commands/playbook.d.ts +17 -0
- package/dist/cli/commands/playbook.d.ts.map +1 -0
- package/dist/cli/commands/playbook.js +123 -0
- package/dist/cli/commands/playbook.js.map +1 -0
- package/dist/cli/commands/postmortem.d.ts +12 -0
- package/dist/cli/commands/postmortem.d.ts.map +1 -0
- package/dist/cli/commands/postmortem.js +67 -0
- package/dist/cli/commands/postmortem.js.map +1 -0
- package/dist/cli/commands/reject.d.ts +17 -0
- package/dist/cli/commands/reject.d.ts.map +1 -0
- package/dist/cli/commands/reject.js +52 -0
- package/dist/cli/commands/reject.js.map +1 -0
- package/dist/cli/commands/rollback.d.ts +21 -0
- package/dist/cli/commands/rollback.d.ts.map +1 -0
- package/dist/cli/commands/rollback.js +90 -0
- package/dist/cli/commands/rollback.js.map +1 -0
- package/dist/cli/commands/run.d.ts +9 -0
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +29 -0
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/telemetry.d.ts +16 -0
- package/dist/cli/commands/telemetry.d.ts.map +1 -0
- package/dist/cli/commands/telemetry.js +152 -0
- package/dist/cli/commands/telemetry.js.map +1 -0
- package/dist/cli/commands/worktree.d.ts +12 -0
- package/dist/cli/commands/worktree.d.ts.map +1 -0
- package/dist/cli/commands/worktree.js +57 -0
- package/dist/cli/commands/worktree.js.map +1 -0
- package/dist/cli/index.js +56 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +41 -3
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +4 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +25 -1
- 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 +1350 -61
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +189 -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/artifact-store.d.ts +14 -0
- package/dist/graph/artifact-store.d.ts.map +1 -0
- package/dist/graph/artifact-store.js +100 -0
- package/dist/graph/artifact-store.js.map +1 -0
- package/dist/graph/cli.d.ts +53 -0
- package/dist/graph/cli.d.ts.map +1 -0
- package/dist/graph/cli.js +181 -0
- package/dist/graph/cli.js.map +1 -0
- package/dist/graph/client.d.ts +64 -0
- package/dist/graph/client.d.ts.map +1 -0
- package/dist/graph/client.js +216 -0
- package/dist/graph/client.js.map +1 -0
- package/dist/graph/fallback.d.ts +13 -0
- package/dist/graph/fallback.d.ts.map +1 -0
- package/dist/graph/fallback.js +57 -0
- package/dist/graph/fallback.js.map +1 -0
- package/dist/graph/hook-handler.d.ts +50 -0
- package/dist/graph/hook-handler.d.ts.map +1 -0
- package/dist/graph/hook-handler.js +217 -0
- package/dist/graph/hook-handler.js.map +1 -0
- package/dist/graph/incidents.d.ts +59 -0
- package/dist/graph/incidents.d.ts.map +1 -0
- package/dist/graph/incidents.js +22 -0
- package/dist/graph/incidents.js.map +1 -0
- package/dist/graph/mcp-client.d.ts +51 -0
- package/dist/graph/mcp-client.d.ts.map +1 -0
- package/dist/graph/mcp-client.js +285 -0
- package/dist/graph/mcp-client.js.map +1 -0
- package/dist/graph/onboarding-composer.d.ts +30 -0
- package/dist/graph/onboarding-composer.d.ts.map +1 -0
- package/dist/graph/onboarding-composer.js +275 -0
- package/dist/graph/onboarding-composer.js.map +1 -0
- package/dist/graph/pipeline-lifecycle.d.ts +95 -0
- package/dist/graph/pipeline-lifecycle.d.ts.map +1 -0
- package/dist/graph/pipeline-lifecycle.js +341 -0
- package/dist/graph/pipeline-lifecycle.js.map +1 -0
- package/dist/graph/preflight-budgets.d.ts +52 -0
- package/dist/graph/preflight-budgets.d.ts.map +1 -0
- package/dist/graph/preflight-budgets.js +78 -0
- package/dist/graph/preflight-budgets.js.map +1 -0
- package/dist/graph/preflight-injector.d.ts +130 -0
- package/dist/graph/preflight-injector.d.ts.map +1 -0
- package/dist/graph/preflight-injector.js +618 -0
- package/dist/graph/preflight-injector.js.map +1 -0
- package/dist/graph/prereq.d.ts +12 -0
- package/dist/graph/prereq.d.ts.map +1 -0
- package/dist/graph/prereq.js +61 -0
- package/dist/graph/prereq.js.map +1 -0
- package/dist/graph/prompts.d.ts +42 -0
- package/dist/graph/prompts.d.ts.map +1 -0
- package/dist/graph/prompts.js +80 -0
- package/dist/graph/prompts.js.map +1 -0
- package/dist/graph/sandbox.d.ts +19 -0
- package/dist/graph/sandbox.d.ts.map +1 -0
- package/dist/graph/sandbox.js +25 -0
- package/dist/graph/sandbox.js.map +1 -0
- package/dist/graph/token-usage.d.ts +21 -0
- package/dist/graph/token-usage.d.ts.map +1 -0
- package/dist/graph/token-usage.js +22 -0
- package/dist/graph/token-usage.js.map +1 -0
- package/dist/graph/types.d.ts +129 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +12 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/incident/orchestrator.d.ts +168 -0
- package/dist/incident/orchestrator.d.ts.map +1 -0
- package/dist/incident/orchestrator.js +279 -0
- package/dist/incident/orchestrator.js.map +1 -0
- package/dist/incident/playbook-search.d.ts +67 -0
- package/dist/incident/playbook-search.d.ts.map +1 -0
- package/dist/incident/playbook-search.js +288 -0
- package/dist/incident/playbook-search.js.map +1 -0
- package/dist/incident/postmortem.d.ts +44 -0
- package/dist/incident/postmortem.d.ts.map +1 -0
- package/dist/incident/postmortem.js +486 -0
- package/dist/incident/postmortem.js.map +1 -0
- package/dist/incident/resolution-verify.d.ts +186 -0
- package/dist/incident/resolution-verify.d.ts.map +1 -0
- package/dist/incident/resolution-verify.js +210 -0
- package/dist/incident/resolution-verify.js.map +1 -0
- package/dist/incident/rollback.d.ts +137 -0
- package/dist/incident/rollback.d.ts.map +1 -0
- package/dist/incident/rollback.js +328 -0
- package/dist/incident/rollback.js.map +1 -0
- package/dist/incident/timeline.d.ts +147 -0
- package/dist/incident/timeline.d.ts.map +1 -0
- package/dist/incident/timeline.js +452 -0
- package/dist/incident/timeline.js.map +1 -0
- package/dist/incident/types.d.ts +335 -0
- package/dist/incident/types.d.ts.map +1 -0
- package/dist/incident/types.js +158 -0
- package/dist/incident/types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/event-stream.d.ts +46 -0
- package/dist/mcp/event-stream.d.ts.map +1 -0
- package/dist/mcp/event-stream.js +421 -0
- package/dist/mcp/event-stream.js.map +1 -0
- package/dist/mcp/external-client.d.ts +38 -0
- package/dist/mcp/external-client.d.ts.map +1 -0
- package/dist/mcp/external-client.js +121 -0
- package/dist/mcp/external-client.js.map +1 -0
- package/dist/mcp/run-manager.d.ts +74 -9
- package/dist/mcp/run-manager.d.ts.map +1 -1
- package/dist/mcp/run-manager.js +127 -31
- package/dist/mcp/run-manager.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +56 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/abort-run.d.ts +2 -0
- package/dist/mcp/tools/abort-run.d.ts.map +1 -0
- package/dist/mcp/tools/abort-run.js +62 -0
- package/dist/mcp/tools/abort-run.js.map +1 -0
- package/dist/mcp/tools/anchor.js +1 -1
- package/dist/mcp/tools/anchor.js.map +1 -1
- package/dist/mcp/tools/approve-checkpoint.d.ts +2 -0
- package/dist/mcp/tools/approve-checkpoint.d.ts.map +1 -0
- package/dist/mcp/tools/approve-checkpoint.js +70 -0
- package/dist/mcp/tools/approve-checkpoint.js.map +1 -0
- package/dist/mcp/tools/brownfield.js +1 -1
- package/dist/mcp/tools/brownfield.js.map +1 -1
- package/dist/mcp/tools/get-project-state.d.ts +2 -0
- package/dist/mcp/tools/get-project-state.d.ts.map +1 -0
- package/dist/mcp/tools/get-project-state.js +107 -0
- package/dist/mcp/tools/get-project-state.js.map +1 -0
- package/dist/mcp/tools/get-run-status.d.ts +2 -0
- package/dist/mcp/tools/get-run-status.d.ts.map +1 -0
- package/dist/mcp/tools/get-run-status.js +40 -0
- package/dist/mcp/tools/get-run-status.js.map +1 -0
- package/dist/mcp/tools/graph-schemas.d.ts +100 -0
- package/dist/mcp/tools/graph-schemas.d.ts.map +1 -0
- package/dist/mcp/tools/graph-schemas.js +39 -0
- package/dist/mcp/tools/graph-schemas.js.map +1 -0
- package/dist/mcp/tools/graph.d.ts +19 -0
- package/dist/mcp/tools/graph.d.ts.map +1 -0
- package/dist/mcp/tools/graph.js +263 -0
- package/dist/mcp/tools/graph.js.map +1 -0
- package/dist/mcp/tools/incident.d.ts +2 -0
- package/dist/mcp/tools/incident.d.ts.map +1 -0
- package/dist/mcp/tools/incident.js +246 -0
- package/dist/mcp/tools/incident.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +38 -18
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +74 -18
- package/dist/mcp/tools/index.js.map +1 -1
- 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/mcp/tools/list-active-runs.d.ts +2 -0
- package/dist/mcp/tools/list-active-runs.d.ts.map +1 -0
- package/dist/mcp/tools/list-active-runs.js +35 -0
- package/dist/mcp/tools/list-active-runs.js.map +1 -0
- package/dist/mcp/tools/list-pending-approvals.d.ts +2 -0
- package/dist/mcp/tools/list-pending-approvals.d.ts.map +1 -0
- package/dist/mcp/tools/list-pending-approvals.js +40 -0
- package/dist/mcp/tools/list-pending-approvals.js.map +1 -0
- package/dist/mcp/tools/list-projects.d.ts +2 -0
- package/dist/mcp/tools/list-projects.d.ts.map +1 -0
- package/dist/mcp/tools/list-projects.js +101 -0
- package/dist/mcp/tools/list-projects.js.map +1 -0
- package/dist/mcp/tools/list-specs.d.ts +2 -0
- package/dist/mcp/tools/list-specs.d.ts.map +1 -0
- package/dist/mcp/tools/list-specs.js +48 -0
- package/dist/mcp/tools/list-specs.js.map +1 -0
- package/dist/mcp/tools/playbook.d.ts +2 -0
- package/dist/mcp/tools/playbook.d.ts.map +1 -0
- package/dist/mcp/tools/playbook.js +104 -0
- package/dist/mcp/tools/playbook.js.map +1 -0
- package/dist/mcp/tools/postmortem.d.ts +2 -0
- package/dist/mcp/tools/postmortem.d.ts.map +1 -0
- package/dist/mcp/tools/postmortem.js +75 -0
- package/dist/mcp/tools/postmortem.js.map +1 -0
- package/dist/mcp/tools/react.js +1 -1
- package/dist/mcp/tools/react.js.map +1 -1
- package/dist/mcp/tools/reject-checkpoint.d.ts +2 -0
- package/dist/mcp/tools/reject-checkpoint.d.ts.map +1 -0
- package/dist/mcp/tools/reject-checkpoint.js +79 -0
- package/dist/mcp/tools/reject-checkpoint.js.map +1 -0
- package/dist/mcp/tools/rollback.d.ts +2 -0
- package/dist/mcp/tools/rollback.d.ts.map +1 -0
- package/dist/mcp/tools/rollback.js +78 -0
- package/dist/mcp/tools/rollback.js.map +1 -0
- package/dist/mcp/tools/run-in-worktree.d.ts +2 -0
- package/dist/mcp/tools/run-in-worktree.d.ts.map +1 -0
- package/dist/mcp/tools/run-in-worktree.js +90 -0
- package/dist/mcp/tools/run-in-worktree.js.map +1 -0
- package/dist/mcp/tools/run.js +1 -1
- package/dist/mcp/tools/run.js.map +1 -1
- package/dist/mcp/tools/solidity.js +1 -1
- package/dist/mcp/tools/solidity.js.map +1 -1
- package/dist/mcp/tools/status.d.ts.map +1 -1
- package/dist/mcp/tools/status.js +11 -0
- package/dist/mcp/tools/status.js.map +1 -1
- package/dist/mcp/tools/subscribe-events.d.ts +2 -0
- package/dist/mcp/tools/subscribe-events.d.ts.map +1 -0
- package/dist/mcp/tools/subscribe-events.js +48 -0
- package/dist/mcp/tools/subscribe-events.js.map +1 -0
- package/dist/mcp/tools/unsubscribe-events.d.ts +2 -0
- package/dist/mcp/tools/unsubscribe-events.d.ts.map +1 -0
- package/dist/mcp/tools/unsubscribe-events.js +45 -0
- package/dist/mcp/tools/unsubscribe-events.js.map +1 -0
- package/dist/orchestrator/agent-loader.d.ts +16 -0
- package/dist/orchestrator/agent-loader.d.ts.map +1 -1
- package/dist/orchestrator/agent-loader.js +30 -0
- 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 +546 -9
- package/dist/orchestrator/architect-agent.js.map +1 -1
- package/dist/orchestrator/checkpoints/audit.d.ts +128 -0
- package/dist/orchestrator/checkpoints/audit.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/audit.js +272 -0
- package/dist/orchestrator/checkpoints/audit.js.map +1 -0
- package/dist/orchestrator/checkpoints/feedback-router.d.ts +213 -0
- package/dist/orchestrator/checkpoints/feedback-router.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/feedback-router.js +438 -0
- package/dist/orchestrator/checkpoints/feedback-router.js.map +1 -0
- package/dist/orchestrator/checkpoints/index.d.ts +11 -0
- package/dist/orchestrator/checkpoints/index.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/index.js +12 -0
- package/dist/orchestrator/checkpoints/index.js.map +1 -0
- package/dist/orchestrator/checkpoints/mechanisms/cli.d.ts +35 -0
- package/dist/orchestrator/checkpoints/mechanisms/cli.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/mechanisms/cli.js +153 -0
- package/dist/orchestrator/checkpoints/mechanisms/cli.js.map +1 -0
- package/dist/orchestrator/checkpoints/mechanisms/disk.d.ts +34 -0
- package/dist/orchestrator/checkpoints/mechanisms/disk.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/mechanisms/disk.js +139 -0
- package/dist/orchestrator/checkpoints/mechanisms/disk.js.map +1 -0
- package/dist/orchestrator/checkpoints/mechanisms/pr.d.ts +141 -0
- package/dist/orchestrator/checkpoints/mechanisms/pr.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/mechanisms/pr.js +445 -0
- package/dist/orchestrator/checkpoints/mechanisms/pr.js.map +1 -0
- package/dist/orchestrator/checkpoints/noop.d.ts +12 -0
- package/dist/orchestrator/checkpoints/noop.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/noop.js +13 -0
- package/dist/orchestrator/checkpoints/noop.js.map +1 -0
- package/dist/orchestrator/checkpoints/registry.d.ts +48 -0
- package/dist/orchestrator/checkpoints/registry.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/registry.js +89 -0
- package/dist/orchestrator/checkpoints/registry.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/_util.d.ts +50 -0
- package/dist/orchestrator/checkpoints/renderers/_util.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/_util.js +137 -0
- package/dist/orchestrator/checkpoints/renderers/_util.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/code-review.d.ts +15 -0
- package/dist/orchestrator/checkpoints/renderers/code-review.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/code-review.js +66 -0
- package/dist/orchestrator/checkpoints/renderers/code-review.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/curator-briefing.d.ts +15 -0
- package/dist/orchestrator/checkpoints/renderers/curator-briefing.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/curator-briefing.js +40 -0
- package/dist/orchestrator/checkpoints/renderers/curator-briefing.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/eval-result.d.ts +15 -0
- package/dist/orchestrator/checkpoints/renderers/eval-result.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/eval-result.js +54 -0
- package/dist/orchestrator/checkpoints/renderers/eval-result.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/generator-diff.d.ts +49 -0
- package/dist/orchestrator/checkpoints/renderers/generator-diff.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/generator-diff.js +154 -0
- package/dist/orchestrator/checkpoints/renderers/generator-diff.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/pipeline-summary.d.ts +15 -0
- package/dist/orchestrator/checkpoints/renderers/pipeline-summary.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/pipeline-summary.js +59 -0
- package/dist/orchestrator/checkpoints/renderers/pipeline-summary.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/plan.d.ts +15 -0
- package/dist/orchestrator/checkpoints/renderers/plan.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/plan.js +34 -0
- package/dist/orchestrator/checkpoints/renderers/plan.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/registry.d.ts +43 -0
- package/dist/orchestrator/checkpoints/renderers/registry.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/registry.js +83 -0
- package/dist/orchestrator/checkpoints/renderers/registry.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/research.d.ts +15 -0
- package/dist/orchestrator/checkpoints/renderers/research.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/research.js +39 -0
- package/dist/orchestrator/checkpoints/renderers/research.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-contract.d.ts +20 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-contract.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-contract.js +57 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-contract.js.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-summary.d.ts +15 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-summary.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-summary.js +38 -0
- package/dist/orchestrator/checkpoints/renderers/sprint-summary.js.map +1 -0
- package/dist/orchestrator/checkpoints/sites.d.ts +22 -0
- package/dist/orchestrator/checkpoints/sites.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/sites.js +57 -0
- package/dist/orchestrator/checkpoints/sites.js.map +1 -0
- package/dist/orchestrator/checkpoints/types.d.ts +51 -0
- package/dist/orchestrator/checkpoints/types.d.ts.map +1 -0
- package/dist/orchestrator/checkpoints/types.js +9 -0
- package/dist/orchestrator/checkpoints/types.js.map +1 -0
- package/dist/orchestrator/code-reviewer-agent.d.ts +50 -0
- package/dist/orchestrator/code-reviewer-agent.d.ts.map +1 -0
- package/dist/orchestrator/code-reviewer-agent.js +283 -0
- package/dist/orchestrator/code-reviewer-agent.js.map +1 -0
- package/dist/orchestrator/curator-agent.d.ts.map +1 -1
- package/dist/orchestrator/curator-agent.js +60 -9
- package/dist/orchestrator/curator-agent.js.map +1 -1
- package/dist/orchestrator/deploy/classify.d.ts +31 -0
- package/dist/orchestrator/deploy/classify.d.ts.map +1 -0
- package/dist/orchestrator/deploy/classify.js +109 -0
- package/dist/orchestrator/deploy/classify.js.map +1 -0
- package/dist/orchestrator/deploy/execute.d.ts +45 -0
- package/dist/orchestrator/deploy/execute.d.ts.map +1 -0
- package/dist/orchestrator/deploy/execute.js +146 -0
- package/dist/orchestrator/deploy/execute.js.map +1 -0
- package/dist/orchestrator/deploy/executor.d.ts +22 -0
- package/dist/orchestrator/deploy/executor.d.ts.map +1 -0
- package/dist/orchestrator/deploy/executor.js +31 -0
- package/dist/orchestrator/deploy/executor.js.map +1 -0
- package/dist/orchestrator/deploy/index.d.ts +21 -0
- package/dist/orchestrator/deploy/index.d.ts.map +1 -0
- package/dist/orchestrator/deploy/index.js +21 -0
- package/dist/orchestrator/deploy/index.js.map +1 -0
- package/dist/orchestrator/deploy/resolve.d.ts +51 -0
- package/dist/orchestrator/deploy/resolve.d.ts.map +1 -0
- package/dist/orchestrator/deploy/resolve.js +53 -0
- package/dist/orchestrator/deploy/resolve.js.map +1 -0
- package/dist/orchestrator/deploy/spawn.d.ts +60 -0
- package/dist/orchestrator/deploy/spawn.d.ts.map +1 -0
- package/dist/orchestrator/deploy/spawn.js +62 -0
- package/dist/orchestrator/deploy/spawn.js.map +1 -0
- package/dist/orchestrator/deploy/types.d.ts +98 -0
- package/dist/orchestrator/deploy/types.d.ts.map +1 -0
- package/dist/orchestrator/deploy/types.js +39 -0
- package/dist/orchestrator/deploy/types.js.map +1 -0
- 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 +80 -10
- 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 +53 -8
- 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 +15 -1
- package/dist/orchestrator/model-resolver.js.map +1 -1
- package/dist/orchestrator/observability/index.d.ts +12 -0
- package/dist/orchestrator/observability/index.d.ts.map +1 -0
- package/dist/orchestrator/observability/index.js +12 -0
- package/dist/orchestrator/observability/index.js.map +1 -0
- package/dist/orchestrator/observability/merge.d.ts +73 -0
- package/dist/orchestrator/observability/merge.d.ts.map +1 -0
- package/dist/orchestrator/observability/merge.js +110 -0
- package/dist/orchestrator/observability/merge.js.map +1 -0
- package/dist/orchestrator/pipeline.d.ts +31 -0
- package/dist/orchestrator/pipeline.d.ts.map +1 -1
- package/dist/orchestrator/pipeline.js +267 -5
- 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 +165 -8
- package/dist/orchestrator/planner-agent.js.map +1 -1
- package/dist/orchestrator/research-agent.d.ts.map +1 -1
- package/dist/orchestrator/research-agent.js +48 -11
- package/dist/orchestrator/research-agent.js.map +1 -1
- package/dist/orchestrator/tools/handlers.d.ts +16 -0
- package/dist/orchestrator/tools/handlers.d.ts.map +1 -1
- package/dist/orchestrator/tools/handlers.js +30 -5
- package/dist/orchestrator/tools/handlers.js.map +1 -1
- package/dist/orchestrator/tools/index.d.ts +84 -1
- package/dist/orchestrator/tools/index.d.ts.map +1 -1
- package/dist/orchestrator/tools/index.js +164 -1
- package/dist/orchestrator/tools/index.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/orchestrator/worktree.d.ts +18 -0
- package/dist/orchestrator/worktree.d.ts.map +1 -0
- package/dist/orchestrator/worktree.js +129 -0
- package/dist/orchestrator/worktree.js.map +1 -0
- package/dist/providers/anthropic.d.ts +8 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +135 -11
- 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 +101 -14
- package/dist/providers/factory.js.map +1 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +32 -3
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/index.d.ts +4 -2
- 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 +28 -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 +53 -2
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/state/approval-state.d.ts +74 -0
- package/dist/state/approval-state.d.ts.map +1 -0
- package/dist/state/approval-state.js +127 -0
- package/dist/state/approval-state.js.map +1 -0
- 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 +4 -1
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +5 -2
- 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/dist/state/review-state.d.ts +15 -0
- package/dist/state/review-state.d.ts.map +1 -0
- package/dist/state/review-state.js +51 -0
- package/dist/state/review-state.js.map +1 -0
- package/dist/state/run-state.d.ts +39 -0
- package/dist/state/run-state.d.ts.map +1 -0
- package/dist/state/run-state.js +101 -0
- package/dist/state/run-state.js.map +1 -0
- package/dist/telemetry/emit.d.ts +41 -0
- package/dist/telemetry/emit.d.ts.map +1 -0
- package/dist/telemetry/emit.js +65 -0
- package/dist/telemetry/emit.js.map +1 -0
- package/dist/utils/git.d.ts +27 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +50 -0
- package/dist/utils/git.js.map +1 -1
- package/hooks/hooks.json +27 -1
- package/hooks/session-start +42 -0
- package/package.json +13 -6
- package/scripts/check-prereqs.sh +12 -0
- package/scripts/e2e-graph-smoke.sh +167 -0
- package/scripts/graph-hook.mjs +151 -0
- package/scripts/run-kpi-gate.mjs +245 -0
- package/scripts/spike-claude-code-provider.mjs +66 -0
- package/scripts/spike-deepseek.mjs +63 -0
- package/scripts/sync-skills.mjs +4 -1
- 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.code-review/SKILL.md +186 -0
- package/skills/bober.debug/SKILL.md +300 -0
- package/skills/bober.deploy/SKILL.md +262 -0
- package/skills/bober.diagnose/SKILL.md +254 -0
- package/skills/bober.eval/SKILL.md +9 -0
- package/skills/bober.eval/references/lens-panel.md +115 -0
- package/skills/bober.graph/SKILL.md +85 -0
- package/skills/bober.impact/SKILL.md +101 -0
- package/skills/bober.incident/SKILL.md +245 -0
- package/skills/bober.onboard/SKILL.md +84 -0
- package/skills/bober.plan/SKILL.md +16 -0
- package/skills/bober.postmortem/SKILL.md +231 -0
- package/skills/bober.run/SKILL.md +23 -4
- package/skills/bober.run/references/lens-panel.md +115 -0
- package/skills/bober.runbook/SKILL.md +335 -0
- package/skills/bober.sprint/SKILL.md +44 -2
- package/skills/bober.sprint/references/lens-panel.md +115 -0
- package/skills/bober.using-bober/SKILL.md +133 -0
- package/skills/bober.verify/SKILL.md +143 -0
- package/skills/shared/arch-lens-panel.md +126 -0
- package/skills/shared/lens-panel.md +115 -0
|
@@ -2,16 +2,65 @@ import { AnthropicAdapter } from "./anthropic.js";
|
|
|
2
2
|
import { OpenAIAdapter } from "./openai.js";
|
|
3
3
|
import { GoogleAdapter } from "./google.js";
|
|
4
4
|
import { OpenAICompatAdapter } from "./openai-compat.js";
|
|
5
|
+
import { ClaudeCodeAdapter } from "./claude-code.js";
|
|
6
|
+
import { execa } from "execa";
|
|
5
7
|
import { resolveProviderModel } from "../orchestrator/model-resolver.js";
|
|
8
|
+
// ── Deterministic stub (BOBER_TEST_DETERMINISTIC) ─────────────────────────────
|
|
9
|
+
//
|
|
10
|
+
// When BOBER_TEST_DETERMINISTIC=1 is set in the environment, createClient()
|
|
11
|
+
// returns a stub LLMClient that immediately returns a deterministic "abort me"
|
|
12
|
+
// response instead of calling any real LLM provider. This prevents e2e tests
|
|
13
|
+
// from hitting real API endpoints or failing due to missing API keys.
|
|
14
|
+
//
|
|
15
|
+
// The stub returns end_turn immediately with empty tool calls, which causes
|
|
16
|
+
// the agentic loop to terminate. The pipeline will fail (no plan produced),
|
|
17
|
+
// but the run is still tracked in RunManager and can be tested via the
|
|
18
|
+
// list/abort MCP tools.
|
|
19
|
+
//
|
|
20
|
+
// Sprint 6 (cockpit-integration)
|
|
21
|
+
class DeterministicStubClient {
|
|
22
|
+
async chat(_params) {
|
|
23
|
+
return {
|
|
24
|
+
text: "[BOBER_TEST_DETERMINISTIC] Stub response — no real LLM call made.",
|
|
25
|
+
toolCalls: [],
|
|
26
|
+
stopReason: "end_turn",
|
|
27
|
+
usage: { inputTokens: 0, outputTokens: 0 },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const defaultBinaryProbe = async (binary) => {
|
|
32
|
+
try {
|
|
33
|
+
const r = await execa(binary, ["--version"], { reject: false, timeout: 5_000 });
|
|
34
|
+
return r.exitCode === 0;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false; // ENOENT → not on PATH
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Verify the claude CLI binary is on PATH. Throws an Error naming the binary
|
|
42
|
+
* when it is absent. Call this before using the claude-code provider.
|
|
43
|
+
*
|
|
44
|
+
* @param binary - CLI binary name/path (default "claude").
|
|
45
|
+
* @param probe - Injectable PATH-check function (default uses execa; override in tests).
|
|
46
|
+
*/
|
|
47
|
+
export async function preflightClaudeBinary(binary = "claude", probe = defaultBinaryProbe) {
|
|
48
|
+
const ok = await probe(binary);
|
|
49
|
+
if (!ok) {
|
|
50
|
+
throw new Error(`The "${binary}" CLI was not found on PATH. The claude-code provider ` +
|
|
51
|
+
`requires the Claude Code CLI. Install it and ensure "${binary}" is on your PATH.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
6
54
|
/**
|
|
7
55
|
* Validate that the required API key environment variable is set for a given provider.
|
|
8
56
|
*
|
|
9
57
|
* @param resolvedProvider - The resolved provider name.
|
|
10
58
|
* @param role - Optional role label (e.g. "Planner", "Generator", "Evaluator") for the error message.
|
|
11
59
|
* @param apiKey - Optional explicit API key from providerConfig (skips env var check if set).
|
|
60
|
+
* @param endpoint - Optional endpoint URL used to distinguish DeepSeek from other openai-compat servers.
|
|
12
61
|
* @throws If the required environment variable is missing and no explicit apiKey was provided.
|
|
13
62
|
*/
|
|
14
|
-
export function validateApiKey(resolvedProvider, role, apiKey) {
|
|
63
|
+
export function validateApiKey(resolvedProvider, role, apiKey, endpoint) {
|
|
15
64
|
const roleLabel = role ?? resolvedProvider;
|
|
16
65
|
switch (resolvedProvider) {
|
|
17
66
|
case "anthropic": {
|
|
@@ -41,7 +90,19 @@ export function validateApiKey(resolvedProvider, role, apiKey) {
|
|
|
41
90
|
break;
|
|
42
91
|
}
|
|
43
92
|
case "openai-compat":
|
|
44
|
-
// API key is optional for Ollama and other local servers
|
|
93
|
+
// API key is optional for Ollama and other local servers.
|
|
94
|
+
// DeepSeek (api.deepseek.com) requires a key — check specifically for it.
|
|
95
|
+
if (endpoint?.includes("api.deepseek.com")) {
|
|
96
|
+
const key = apiKey ?? process.env["DEEPSEEK_API_KEY"];
|
|
97
|
+
if (!key) {
|
|
98
|
+
throw new Error(`${roleLabel} is configured to use DeepSeek but neither providerConfig.apiKey nor DEEPSEEK_API_KEY is set. ` +
|
|
99
|
+
`Set the DEEPSEEK_API_KEY environment variable and try again.`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case "claude-code":
|
|
104
|
+
// Subscription provider: no API key is read or required. The `claude`
|
|
105
|
+
// binary PATH preflight is async and runs via preflightClaudeBinary().
|
|
45
106
|
break;
|
|
46
107
|
default:
|
|
47
108
|
// Unknown providers: no validation, let createClient handle the error.
|
|
@@ -70,6 +131,12 @@ export function validateApiKey(resolvedProvider, role, apiKey) {
|
|
|
70
131
|
* @throws If the resolved provider is unsupported or the required API key is missing.
|
|
71
132
|
*/
|
|
72
133
|
export function createClient(provider, endpoint, providerConfig, model, role) {
|
|
134
|
+
// ── BOBER_TEST_DETERMINISTIC guard ─────────────────────────────────
|
|
135
|
+
// When set, skip all provider resolution and return a stub client.
|
|
136
|
+
// This suppresses real LLM calls in e2e tests (cockpit-integration sprint 6).
|
|
137
|
+
if (process.env["BOBER_TEST_DETERMINISTIC"] === "1") {
|
|
138
|
+
return new DeterministicStubClient();
|
|
139
|
+
}
|
|
73
140
|
// endpoint is used by OpenAI and openai-compat adapters as a base URL
|
|
74
141
|
// Resolve provider: explicit wins; otherwise infer from model shorthand
|
|
75
142
|
let resolvedProvider;
|
|
@@ -86,34 +153,54 @@ export function createClient(provider, endpoint, providerConfig, model, role) {
|
|
|
86
153
|
const apiKey = typeof providerConfig?.["apiKey"] === "string"
|
|
87
154
|
? providerConfig["apiKey"]
|
|
88
155
|
: undefined;
|
|
156
|
+
// Hoist endpoint resolution so validateApiKey can distinguish DeepSeek from
|
|
157
|
+
// other openai-compat servers (e.g. Ollama). Explicit arg wins, then model
|
|
158
|
+
// resolution (for deepseek/ and ollama/ shorthands), then providerConfig.
|
|
159
|
+
const resolvedEndpoint = endpoint ??
|
|
160
|
+
(!provider && model ? resolveProviderModel(model).endpoint : undefined) ??
|
|
161
|
+
(typeof providerConfig?.["endpoint"] === "string"
|
|
162
|
+
? providerConfig["endpoint"]
|
|
163
|
+
: undefined);
|
|
89
164
|
// Validate API key before constructing the adapter.
|
|
90
|
-
validateApiKey(resolvedProvider, role, apiKey);
|
|
165
|
+
validateApiKey(resolvedProvider, role, apiKey, resolvedEndpoint);
|
|
91
166
|
// Resolve the model ID (for cases where provider was inferred from shorthand)
|
|
92
167
|
const resolvedModelId = !provider && model
|
|
93
168
|
? resolveProviderModel(model).modelId
|
|
94
169
|
: model ?? resolvedProvider;
|
|
95
170
|
switch (resolvedProvider) {
|
|
96
|
-
case "anthropic":
|
|
97
|
-
|
|
171
|
+
case "anthropic": {
|
|
172
|
+
const promptCaching = typeof providerConfig?.["promptCaching"] === "boolean"
|
|
173
|
+
? providerConfig["promptCaching"]
|
|
174
|
+
: true;
|
|
175
|
+
return new AnthropicAdapter(apiKey, { promptCaching });
|
|
176
|
+
}
|
|
98
177
|
case "openai":
|
|
99
178
|
return new OpenAIAdapter(resolvedModelId, apiKey ?? process.env["OPENAI_API_KEY"], endpoint ?? undefined, providerConfig);
|
|
100
179
|
case "google":
|
|
101
180
|
return new GoogleAdapter(resolvedModelId, apiKey ?? process.env["GOOGLE_API_KEY"] ?? process.env["GEMINI_API_KEY"]);
|
|
102
181
|
case "openai-compat": {
|
|
103
|
-
// Resolve endpoint: explicit arg wins, then model resolution (for ollama/ prefix),
|
|
104
|
-
// then providerConfig, then error.
|
|
105
|
-
const resolvedEndpoint = endpoint ??
|
|
106
|
-
(!provider && model ? resolveProviderModel(model).endpoint : undefined) ??
|
|
107
|
-
(typeof providerConfig?.["endpoint"] === "string"
|
|
108
|
-
? providerConfig["endpoint"]
|
|
109
|
-
: undefined);
|
|
110
182
|
if (!resolvedEndpoint) {
|
|
111
183
|
throw new Error('OpenAI-compatible provider requires an endpoint. Set endpoint in provider config or use the "ollama/" model prefix.');
|
|
112
184
|
}
|
|
113
|
-
|
|
185
|
+
// Inject DEEPSEEK_API_KEY env fallback only for the api.deepseek.com endpoint.
|
|
186
|
+
// Ollama and other openai-compat endpoints keep the no-key (not-needed) behavior.
|
|
187
|
+
const compatKey = apiKey ??
|
|
188
|
+
(resolvedEndpoint.includes("api.deepseek.com")
|
|
189
|
+
? process.env["DEEPSEEK_API_KEY"]
|
|
190
|
+
: undefined);
|
|
191
|
+
return new OpenAICompatAdapter(resolvedEndpoint, resolvedModelId, compatKey);
|
|
192
|
+
}
|
|
193
|
+
case "claude-code": {
|
|
194
|
+
const binary = typeof providerConfig?.["binary"] === "string"
|
|
195
|
+
? providerConfig["binary"]
|
|
196
|
+
: "claude";
|
|
197
|
+
const timeoutMs = typeof providerConfig?.["timeoutMs"] === "number"
|
|
198
|
+
? providerConfig["timeoutMs"]
|
|
199
|
+
: 180_000;
|
|
200
|
+
return new ClaudeCodeAdapter(binary, timeoutMs);
|
|
114
201
|
}
|
|
115
202
|
default:
|
|
116
|
-
throw new Error(`Unsupported provider: "${resolvedProvider}". Supported providers: anthropic, openai, google, openai-compat.`);
|
|
203
|
+
throw new Error(`Unsupported provider: "${resolvedProvider}". Supported providers: anthropic, openai, google, openai-compat, claude-code.`);
|
|
117
204
|
}
|
|
118
205
|
}
|
|
119
206
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5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,MAAM,IAAI,KAAK,CACb,qHAAqH,CACtH,CAAC;YACJ,CAAC;YAED,+EAA+E;YAC/E,kFAAkF;YAClF,MAAM,SAAS,GACb,MAAM;gBACN,CAAC,gBAAgB,CAAC,QAAQ,CAAC,kBAAkB,CAAC;oBAC5C,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;oBACjC,CAAC,CAAC,SAAS,CAAC,CAAC;YAEjB,OAAO,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAC/E,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,MAAM,GACV,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,KAAK,QAAQ;gBAC5C,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;gBAC1B,CAAC,CAAC,QAAQ,CAAC;YACf,MAAM,SAAS,GACb,OAAO,cAAc,EAAE,CAAC,WAAW,CAAC,KAAK,QAAQ;gBAC/C,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC;gBAC7B,CAAC,CAAC,OAAO,CAAC;YACd,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAClD,CAAC;QACD;YACE,MAAM,IAAI,KAAK,CACb,0BAA0B,gBAAgB,gFAAgF,CAC3H,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAIb,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAIb,MAAM,YAAY,CAAC;AA6MpB;;;;;;;;;;;GAWG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C,4DAA4D;IAC5D,OAAO,CAAC,KAAK,CAAmC;gBAEpC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAK1C;;;;;OAKG;YACW,QAAQ;IAmChB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;CAuEtD"}
|
package/dist/providers/google.js
CHANGED
|
@@ -21,6 +21,17 @@ function toGeminiTool(tools) {
|
|
|
21
21
|
})),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Sanitize a JSON Schema for Gemini's `responseSchema`.
|
|
26
|
+
*
|
|
27
|
+
* Gemini rejects the JSON-Schema keyword `additionalProperties`, so we return a
|
|
28
|
+
* shallow copy of the schema with the top-level `additionalProperties` key
|
|
29
|
+
* removed. A shallow strip is sufficient for the flat schemas we use.
|
|
30
|
+
*/
|
|
31
|
+
function sanitizeGeminiResponseSchema(schema) {
|
|
32
|
+
const { additionalProperties: _additionalProperties, ...rest } = schema;
|
|
33
|
+
return rest;
|
|
34
|
+
}
|
|
24
35
|
/**
|
|
25
36
|
* Normalize a Gemini finishReason to our StopReason type.
|
|
26
37
|
*/
|
|
@@ -71,6 +82,11 @@ function toGeminiContents(message) {
|
|
|
71
82
|
}
|
|
72
83
|
return [{ role: "model", parts }];
|
|
73
84
|
}
|
|
85
|
+
// SystemUpdateMessage: best-effort render as a user text part (Gemini has no
|
|
86
|
+
// in-array system role; the top-level systemInstruction is set separately)
|
|
87
|
+
if ("systemUpdate" in message) {
|
|
88
|
+
return [{ role: "user", parts: [{ text: message.systemUpdate }] }];
|
|
89
|
+
}
|
|
74
90
|
// TextMessage — map "user" → "user", "assistant" → "model"
|
|
75
91
|
const textMsg = message;
|
|
76
92
|
const geminiRole = textMsg.role === "assistant" ? "model" : "user";
|
|
@@ -152,17 +168,30 @@ export class GoogleAdapter {
|
|
|
152
168
|
return this.genAI;
|
|
153
169
|
}
|
|
154
170
|
async chat(params) {
|
|
155
|
-
const { model, system, messages, tools, maxTokens: _maxTokens = 16384 } = params;
|
|
171
|
+
const { model, system, messages, tools, responseSchema, maxTokens: _maxTokens = 16384, } = params;
|
|
156
172
|
const genAI = await this.getGenAI();
|
|
173
|
+
// When a responseSchema is set, request Gemini's native structured output.
|
|
174
|
+
// Gemini rejects `additionalProperties`, so strip it before forwarding.
|
|
175
|
+
const generationConfig = responseSchema
|
|
176
|
+
? {
|
|
177
|
+
responseMimeType: "application/json",
|
|
178
|
+
responseSchema: sanitizeGeminiResponseSchema(responseSchema),
|
|
179
|
+
}
|
|
180
|
+
: undefined;
|
|
157
181
|
// Get the generative model — system instruction set at model config level
|
|
158
182
|
const generativeModel = genAI.getGenerativeModel({
|
|
159
183
|
model: model || this.model,
|
|
160
184
|
...(system ? { systemInstruction: system } : {}),
|
|
185
|
+
...(generationConfig ? { generationConfig } : {}),
|
|
161
186
|
});
|
|
162
187
|
// Convert provider-agnostic Message[] to Gemini contents format
|
|
163
188
|
const contents = messages.flatMap(toGeminiContents);
|
|
164
|
-
// Convert ToolDef[] to Gemini tools format (all declarations in one tool)
|
|
165
|
-
|
|
189
|
+
// Convert ToolDef[] to Gemini tools format (all declarations in one tool).
|
|
190
|
+
// responseSchema is mutually exclusive with tools — when set, user tools
|
|
191
|
+
// are NOT forwarded (structured output wins).
|
|
192
|
+
const geminiTools = !responseSchema && tools && tools.length > 0
|
|
193
|
+
? [toGeminiTool(tools)]
|
|
194
|
+
: undefined;
|
|
166
195
|
const result = await generativeModel.generateContent({
|
|
167
196
|
contents,
|
|
168
197
|
...(geminiTools ? { tools: geminiTools } : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAwFH,wEAAwE;AAExE;;GAEG;AACH,SAAS,YAAY,CAAC,KAAgB;IACpC,OAAO;QACL,oBAAoB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACzC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,YAAuC;SACzD,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,4BAA4B,CACnC,MAA+B;IAE/B,MAAM,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACxE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,YAAgC;IAC3D,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAgB;IACxC,kEAAkE;IAClE,IAAI,aAAa,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACtC,IAAI,EAAE,UAAmB;YACzB,KAAK,EAAE;gBACL;oBACE,gBAAgB,EAAE;wBAChB,IAAI,EAAE,EAAE,CAAC,SAAS;wBAClB,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE;qBAClC;iBACF;aACF;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,4EAA4E;IAC5E,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;gBACL,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,gBAAgB,IAAI,CAAC;gBACjE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,IAAI,CAAC;aACvE;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export type { JsonSchemaProperty, JsonSchemaObject, ToolDef, ToolCall, ToolResult, TextMessage, AssistantMessage, ToolResultMessage, Message, ChatParams, ChatResponse, StopReason, LLMClient, } from "./types.js";
|
|
1
|
+
export type { JsonSchemaProperty, JsonSchemaObject, ToolDef, ToolCall, ToolResult, TextMessage, AssistantMessage, ToolResultMessage, SystemUpdateMessage, Message, ChatParams, ChatResponse, StopReason, LLMClient, } from "./types.js";
|
|
2
2
|
export { AnthropicAdapter } from "./anthropic.js";
|
|
3
3
|
export { OpenAIAdapter } from "./openai.js";
|
|
4
4
|
export { GoogleAdapter } from "./google.js";
|
|
5
5
|
export { OpenAICompatAdapter } from "./openai-compat.js";
|
|
6
|
-
export {
|
|
6
|
+
export { ClaudeCodeAdapter } from "./claude-code.js";
|
|
7
|
+
export { createClient, validateApiKey, preflightClaudeBinary, type ProviderName, type BinaryProbe } from "./factory.js";
|
|
8
|
+
export { coerceJson, zodValidator, runStructuredAgent, JsonCoercionError, StructuredOutputError, type Validator, type ValidationResult, type SafeParseable, type RunStructuredAgentOptions, type StructuredAgentResult, } from "./structured.js";
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAExH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAC"}
|
package/dist/providers/index.js
CHANGED
|
@@ -2,5 +2,7 @@ export { AnthropicAdapter } from "./anthropic.js";
|
|
|
2
2
|
export { OpenAIAdapter } from "./openai.js";
|
|
3
3
|
export { GoogleAdapter } from "./google.js";
|
|
4
4
|
export { OpenAICompatAdapter } from "./openai-compat.js";
|
|
5
|
-
export {
|
|
5
|
+
export { ClaudeCodeAdapter } from "./claude-code.js";
|
|
6
|
+
export { createClient, validateApiKey, preflightClaudeBinary } from "./factory.js";
|
|
7
|
+
export { coerceJson, zodValidator, runStructuredAgent, JsonCoercionError, StructuredOutputError, } from "./structured.js";
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAuC,MAAM,cAAc,CAAC;AAExH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GAMtB,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAKb,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,YAAY,EAKb,MAAM,YAAY,CAAC;AAyNpB;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsC;IAErE,4DAA4D;IAC5D,OAAO,CAAC,MAAM,CAA8B;gBAG1C,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQ1C;;;;OAIG;YACW,SAAS;IAqCjB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;CAqEtD"}
|
package/dist/providers/openai.js
CHANGED
|
@@ -69,6 +69,10 @@ function toOpenAIMessages(message) {
|
|
|
69
69
|
};
|
|
70
70
|
return [oaiMsg];
|
|
71
71
|
}
|
|
72
|
+
// SystemUpdateMessage: best-effort render as an OpenAI system message
|
|
73
|
+
if ("systemUpdate" in message) {
|
|
74
|
+
return [{ role: "system", content: message.systemUpdate }];
|
|
75
|
+
}
|
|
72
76
|
// TextMessage (user or assistant without tool calls)
|
|
73
77
|
const textMsg = message;
|
|
74
78
|
if (textMsg.role === "user") {
|
|
@@ -164,19 +168,40 @@ export class OpenAIAdapter {
|
|
|
164
168
|
return this.client;
|
|
165
169
|
}
|
|
166
170
|
async chat(params) {
|
|
167
|
-
const { model, system, messages, tools, maxTokens = 16384 } = params;
|
|
171
|
+
const { model, system, messages, tools, maxTokens = 16384, responseSchema, jsonObjectMode } = params;
|
|
168
172
|
const client = await this.getClient();
|
|
169
173
|
// Build the messages array: system message first, then conversation
|
|
170
174
|
const oaiMessages = [
|
|
171
175
|
{ role: "system", content: system },
|
|
172
176
|
...messages.flatMap(toOpenAIMessages),
|
|
173
177
|
];
|
|
174
|
-
//
|
|
175
|
-
|
|
178
|
+
// Structured output via response_format. `responseSchema` (strict json_schema)
|
|
179
|
+
// wins when set; otherwise `jsonObjectMode` requests the loose json_object
|
|
180
|
+
// mode (broadly supported, incl. DeepSeek, which rejects json_schema).
|
|
181
|
+
// Both disable tool forwarding (mutually exclusive with structured output).
|
|
182
|
+
// strict:false maximises compatibility; the caller validates/repairs output.
|
|
183
|
+
const responseFormat = responseSchema
|
|
184
|
+
? {
|
|
185
|
+
type: "json_schema",
|
|
186
|
+
json_schema: {
|
|
187
|
+
name: "structured_output",
|
|
188
|
+
schema: responseSchema,
|
|
189
|
+
strict: false,
|
|
190
|
+
},
|
|
191
|
+
}
|
|
192
|
+
: jsonObjectMode
|
|
193
|
+
? { type: "json_object" }
|
|
194
|
+
: undefined;
|
|
195
|
+
// Convert ToolDef[] to OpenAI tools format. Skipped entirely when structured
|
|
196
|
+
// output (responseSchema or json_object mode) is requested.
|
|
197
|
+
const oaiTools = !responseSchema && !jsonObjectMode && tools && tools.length > 0
|
|
198
|
+
? tools.map(toOpenAITool)
|
|
199
|
+
: undefined;
|
|
176
200
|
const response = await client.chat.completions.create({
|
|
177
201
|
model: model || this.model,
|
|
178
202
|
messages: oaiMessages,
|
|
179
203
|
...(oaiTools ? { tools: oaiTools } : {}),
|
|
204
|
+
...(responseFormat ? { response_format: responseFormat } : {}),
|
|
180
205
|
max_tokens: maxTokens,
|
|
181
206
|
});
|
|
182
207
|
const choice = response.choices[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmHH,uEAAuE;AAEvE;;GAEG;AACH,SAAS,YAAY,CAAC,IAAa;IACjC,OAAO;QACL,IAAI,EAAE,UAAU;Q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
2
|
+
/** The actionable hint string. MUST contain 'npm install openai'. */
|
|
3
|
+
export declare const OPENAI_PEER_HINT: string;
|
|
4
|
+
/**
|
|
5
|
+
* Injectable importer so tests can simulate openai present/absent without
|
|
6
|
+
* touching the real module graph. Mirrors the getClient() pattern in openai.ts.
|
|
7
|
+
*/
|
|
8
|
+
export type OpenaiImporter = () => Promise<unknown>;
|
|
9
|
+
/** Returns true if any configured role resolves to an openai-family provider. */
|
|
10
|
+
export declare function usesOpenaiFamily(config: Partial<BoberConfig>): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Preflight: if an openai-family provider is configured but the openai package
|
|
13
|
+
* is absent, emit an install hint via logger.warn and return the hint string.
|
|
14
|
+
* If openai is installed OR no openai-family role is configured, return null.
|
|
15
|
+
* NEVER throws — this is a warning/hint only.
|
|
16
|
+
*
|
|
17
|
+
* @param config - The bober config (or partial). Scans planner/curator/generator/evaluator/codeReview roles.
|
|
18
|
+
* @param importer - Injectable importer for testability (default: dynamic import("openai")).
|
|
19
|
+
* @returns The hint string (contains 'npm install openai') if missing, otherwise null.
|
|
20
|
+
*/
|
|
21
|
+
export declare function preflightOpenaiPeer(config: Partial<BoberConfig>, importer?: OpenaiImporter): Promise<string | null>;
|
|
22
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/providers/preflight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,QAEkD,CAAC;AAEhF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AASpD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAiBtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,EAC5B,QAAQ,GAAE,cAAgC,GACzC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASxB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { resolveProviderModel } from "../orchestrator/model-resolver.js";
|
|
2
|
+
import { logger } from "../utils/logger.js";
|
|
3
|
+
/** Providers that require the optional `openai` peer package. */
|
|
4
|
+
const OPENAI_FAMILY = new Set(["openai", "openai-compat"]);
|
|
5
|
+
/** The actionable hint string. MUST contain 'npm install openai'. */
|
|
6
|
+
export const OPENAI_PEER_HINT = 'A configured role uses an OpenAI-family provider (openai/openai-compat/DeepSeek), ' +
|
|
7
|
+
'but the optional "openai" package is not installed. Run: npm install openai';
|
|
8
|
+
const defaultImporter = () => {
|
|
9
|
+
// Construct the specifier at runtime so TypeScript does not attempt
|
|
10
|
+
// to statically resolve the optional peer dependency at compile time.
|
|
11
|
+
const specifier = "openai";
|
|
12
|
+
return import(/* @vite-ignore */ specifier);
|
|
13
|
+
};
|
|
14
|
+
/** Returns true if any configured role resolves to an openai-family provider. */
|
|
15
|
+
export function usesOpenaiFamily(config) {
|
|
16
|
+
const sections = [
|
|
17
|
+
config.planner,
|
|
18
|
+
config.curator,
|
|
19
|
+
config.generator,
|
|
20
|
+
config.evaluator,
|
|
21
|
+
config.codeReview,
|
|
22
|
+
];
|
|
23
|
+
for (const section of sections) {
|
|
24
|
+
if (!section?.model)
|
|
25
|
+
continue;
|
|
26
|
+
const { provider } = resolveProviderModel(section.model, section.provider);
|
|
27
|
+
if (OPENAI_FAMILY.has(provider))
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Preflight: if an openai-family provider is configured but the openai package
|
|
34
|
+
* is absent, emit an install hint via logger.warn and return the hint string.
|
|
35
|
+
* If openai is installed OR no openai-family role is configured, return null.
|
|
36
|
+
* NEVER throws — this is a warning/hint only.
|
|
37
|
+
*
|
|
38
|
+
* @param config - The bober config (or partial). Scans planner/curator/generator/evaluator/codeReview roles.
|
|
39
|
+
* @param importer - Injectable importer for testability (default: dynamic import("openai")).
|
|
40
|
+
* @returns The hint string (contains 'npm install openai') if missing, otherwise null.
|
|
41
|
+
*/
|
|
42
|
+
export async function preflightOpenaiPeer(config, importer = defaultImporter) {
|
|
43
|
+
if (!usesOpenaiFamily(config))
|
|
44
|
+
return null; // sc-3-4: anthropic-only => null
|
|
45
|
+
try {
|
|
46
|
+
await importer(); // sc-3-3: openai present => no hint
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
logger.warn(OPENAI_PEER_HINT); // sc-3-2: openai absent => emit hint
|
|
51
|
+
return OPENAI_PEER_HINT;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/providers/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,iEAAiE;AACjE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;AAE3D,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAC3B,oFAAoF;IACpF,6EAA6E,CAAC;AAQhF,MAAM,eAAe,GAAmB,GAAG,EAAE;IAC3C,oEAAoE;IACpE,sEAAsE;IACtE,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC3B,OAAO,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,MAA4B;IAC3D,MAAM,QAAQ,GAAG;QACf,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,UAAU;KAClB,CAAC;IACF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,EAAE,KAAK;YAAE,SAAS;QAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CACvC,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,QAAQ,CACjB,CAAC;QACF,IAAI,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;IAC/C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAA4B,EAC5B,WAA2B,eAAe;IAE1C,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC,CAAC,iCAAiC;IAC7E,IAAI,CAAC;QACH,MAAM,QAAQ,EAAE,CAAC,CAAC,oCAAoC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,qCAAqC;QACpE,OAAO,gBAAgB,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-constrained ("structured") output utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides a provider-agnostic single-shot structured call that makes JSON
|
|
5
|
+
* output reliable even on small local models (DeepSeek / Ollama / LM Studio),
|
|
6
|
+
* where the server may not honor a strict schema. It:
|
|
7
|
+
*
|
|
8
|
+
* 1. requests native structured output (`ChatParams.responseSchema`) AND
|
|
9
|
+
* injects the schema into the system prompt — belt-and-suspenders for
|
|
10
|
+
* models that ignore the native knob;
|
|
11
|
+
* 2. coerces the model's raw text into JSON, tolerating the failure modes
|
|
12
|
+
* 7B-class models exhibit (markdown fences, surrounding prose);
|
|
13
|
+
* 3. validates the parsed value against a caller-supplied validator
|
|
14
|
+
* (typically backed by a Zod schema); and
|
|
15
|
+
* 4. on failure, performs up to `maxRepairs` repair round-trips, feeding the
|
|
16
|
+
* validation error back to the model.
|
|
17
|
+
*
|
|
18
|
+
* See structured.test.ts for the recovery-rate fixture suite that pins the
|
|
19
|
+
* single-shot + one-repair reliability target.
|
|
20
|
+
*/
|
|
21
|
+
import type { LLMClient, JsonSchemaObject } from "./types.js";
|
|
22
|
+
/** Raised by {@link coerceJson} when no JSON value can be extracted from text. */
|
|
23
|
+
export declare class JsonCoercionError extends Error {
|
|
24
|
+
/** The raw model text that could not be coerced. */
|
|
25
|
+
readonly raw: string;
|
|
26
|
+
constructor(message: string,
|
|
27
|
+
/** The raw model text that could not be coerced. */
|
|
28
|
+
raw: string);
|
|
29
|
+
}
|
|
30
|
+
/** Raised by {@link runStructuredAgent} when every attempt fails validation. */
|
|
31
|
+
export declare class StructuredOutputError extends Error {
|
|
32
|
+
/** The last raw model text seen. */
|
|
33
|
+
readonly raw: string;
|
|
34
|
+
/** Total chat calls made before giving up. */
|
|
35
|
+
readonly attempts: number;
|
|
36
|
+
constructor(message: string,
|
|
37
|
+
/** The last raw model text seen. */
|
|
38
|
+
raw: string,
|
|
39
|
+
/** Total chat calls made before giving up. */
|
|
40
|
+
attempts: number);
|
|
41
|
+
}
|
|
42
|
+
export type ValidationResult<T> = {
|
|
43
|
+
ok: true;
|
|
44
|
+
value: T;
|
|
45
|
+
} | {
|
|
46
|
+
ok: false;
|
|
47
|
+
error: string;
|
|
48
|
+
};
|
|
49
|
+
/** Validates and narrows a coerced JSON value to `T`. */
|
|
50
|
+
export type Validator<T> = (raw: unknown) => ValidationResult<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Structural shape of a Zod schema's `safeParse`. Declared here (instead of
|
|
53
|
+
* importing `zod`) so this module stays dependency-pure and accepts any
|
|
54
|
+
* validator exposing the same surface.
|
|
55
|
+
*/
|
|
56
|
+
export interface SafeParseable<T> {
|
|
57
|
+
safeParse(data: unknown): {
|
|
58
|
+
success: true;
|
|
59
|
+
data: T;
|
|
60
|
+
} | {
|
|
61
|
+
success: false;
|
|
62
|
+
error: {
|
|
63
|
+
issues: ReadonlyArray<{
|
|
64
|
+
path: ReadonlyArray<PropertyKey>;
|
|
65
|
+
message: string;
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build a {@link Validator} from a Zod schema (or anything exposing
|
|
72
|
+
* `safeParse`). Flattens issues into one human-readable string the model can
|
|
73
|
+
* act on during a repair round-trip.
|
|
74
|
+
*/
|
|
75
|
+
export declare function zodValidator<T>(schema: SafeParseable<T>): Validator<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Extract a JSON value from a model's raw text response.
|
|
78
|
+
*
|
|
79
|
+
* Handles the common local-model failure modes, in order:
|
|
80
|
+
* 1. direct `JSON.parse` (well-behaved providers / strict json mode);
|
|
81
|
+
* 2. strip a leading/trailing markdown code fence, then parse;
|
|
82
|
+
* 3. extract the substring spanning the first `{`/`[` to the matching last
|
|
83
|
+
* `}`/`]` (drops surrounding prose), then parse.
|
|
84
|
+
*
|
|
85
|
+
* @throws {JsonCoercionError} if nothing parses.
|
|
86
|
+
*/
|
|
87
|
+
export declare function coerceJson(text: string): unknown;
|
|
88
|
+
export interface RunStructuredAgentOptions<T> {
|
|
89
|
+
/** Provider-agnostic LLM client (any adapter from the provider factory). */
|
|
90
|
+
client: LLMClient;
|
|
91
|
+
/** Model ID (resolved via the factory / model-resolver). */
|
|
92
|
+
model: string;
|
|
93
|
+
/** Base system prompt. The schema instruction is appended automatically. */
|
|
94
|
+
system: string;
|
|
95
|
+
/** The task / user message. */
|
|
96
|
+
prompt: string;
|
|
97
|
+
/** Provider-facing JSON Schema (also injected into the system prompt). */
|
|
98
|
+
schema: JsonSchemaObject;
|
|
99
|
+
/** Validates + narrows the coerced JSON. Typically `zodValidator(SomeSchema)`. */
|
|
100
|
+
validate: Validator<T>;
|
|
101
|
+
/** Max repair round-trips after the first attempt. Default 1. */
|
|
102
|
+
maxRepairs?: number;
|
|
103
|
+
/** Per-call max tokens. */
|
|
104
|
+
maxTokens?: number;
|
|
105
|
+
}
|
|
106
|
+
export interface StructuredAgentResult<T> {
|
|
107
|
+
/** The validated, typed value. */
|
|
108
|
+
value: T;
|
|
109
|
+
/** Total chat calls made (1 = first-try success). */
|
|
110
|
+
attempts: number;
|
|
111
|
+
/** True if any repair round-trip was needed. */
|
|
112
|
+
repaired: boolean;
|
|
113
|
+
/** Cumulative token usage across all attempts. */
|
|
114
|
+
usage: {
|
|
115
|
+
inputTokens: number;
|
|
116
|
+
outputTokens: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Run a single-shot structured-output call with coercion, validation, and
|
|
121
|
+
* bounded repair. Returns a validated, typed value.
|
|
122
|
+
*
|
|
123
|
+
* The returned `ChatResponse.text` is parsed via {@link coerceJson} and checked
|
|
124
|
+
* with `validate`. If either fails and repairs remain, the bad output and the
|
|
125
|
+
* error are fed back as a follow-up turn.
|
|
126
|
+
*
|
|
127
|
+
* @throws {StructuredOutputError} if no attempt produces a schema-valid value.
|
|
128
|
+
*/
|
|
129
|
+
export declare function runStructuredAgent<T>(opts: RunStructuredAgentOptions<T>): Promise<StructuredAgentResult<T>>;
|
|
130
|
+
//# sourceMappingURL=structured.d.ts.map
|