agent-bober 0.15.0 → 0.17.1
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 +40 -0
- package/README.md +137 -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.d.ts +9 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +5 -1
- 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/commands/update.d.ts +18 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +81 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/index.js +9 -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
|
@@ -21,6 +21,22 @@ export interface AgenticLoopParams {
|
|
|
21
21
|
onToolUse?: (name: string, input: unknown) => void;
|
|
22
22
|
/** Called after each completed turn (for progress tracking). */
|
|
23
23
|
onTurnComplete?: (turn: number, toolsCalled: string[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Optional completion predicate. When the model ends a turn WITHOUT calling a
|
|
26
|
+
* tool, the loop normally treats that as "done". Some OpenAI-compatible models
|
|
27
|
+
* (e.g. DeepSeek) instead narrate intentions ("let me write the files...") and
|
|
28
|
+
* stop without calling any tool — which would end the loop with no work done.
|
|
29
|
+
*
|
|
30
|
+
* When this predicate is provided and returns `false` for a tool-less turn,
|
|
31
|
+
* the loop injects a nudge message (see `nudgeMessage`) and continues, up to
|
|
32
|
+
* `maxNudges` times, instead of returning prematurely. When omitted, behavior
|
|
33
|
+
* is unchanged (any tool-less turn ends the loop).
|
|
34
|
+
*/
|
|
35
|
+
completionCheck?: (text: string) => boolean;
|
|
36
|
+
/** Max nudges before giving up on an apparently-incomplete tool-less turn. Default 2. */
|
|
37
|
+
maxNudges?: number;
|
|
38
|
+
/** The nudge text appended when `completionCheck` fails. A sensible default is used if omitted. */
|
|
39
|
+
nudgeMessage?: string;
|
|
24
40
|
}
|
|
25
41
|
export interface AgenticLoopResult {
|
|
26
42
|
/** The final text response from the model. */
|
|
@@ -37,6 +53,41 @@ export interface AgenticLoopResult {
|
|
|
37
53
|
/** The stop reason of the final API response. */
|
|
38
54
|
stopReason: string;
|
|
39
55
|
}
|
|
56
|
+
export interface CoerceJsonParams {
|
|
57
|
+
client: LLMClient;
|
|
58
|
+
model: string;
|
|
59
|
+
systemPrompt: string;
|
|
60
|
+
/** The original task/user message that started the loop. */
|
|
61
|
+
userMessage: string;
|
|
62
|
+
/** The (non-JSON / wrong-shape) text the agentic loop produced, fed back for context. */
|
|
63
|
+
priorText: string;
|
|
64
|
+
/**
|
|
65
|
+
* Final instruction telling the model EXACTLY what JSON to emit. Because we
|
|
66
|
+
* use the provider's loose json_object mode (not strict json_schema — DeepSeek
|
|
67
|
+
* rejects the latter), this instruction must spell out every required field;
|
|
68
|
+
* json_object mode only guarantees the output is *a* valid JSON object.
|
|
69
|
+
*/
|
|
70
|
+
instruction: string;
|
|
71
|
+
maxTokens?: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Force a structured-JSON response after an agentic loop failed to produce the
|
|
75
|
+
* required object. Some OpenAI-compatible models (notably DeepSeek) either
|
|
76
|
+
* narrate prose instead of JSON, or emit valid JSON of the WRONG shape (e.g.
|
|
77
|
+
* following a short "summary" prompt instead of the full schema).
|
|
78
|
+
*
|
|
79
|
+
* Strategy: re-ask with `json_object` response_format (broadly supported,
|
|
80
|
+
* including DeepSeek) plus an explicit field-by-field instruction. If the
|
|
81
|
+
* provider rejects response_format at all (some servers 400 on it), fall back
|
|
82
|
+
* to a plain prompt-only call — the instruction itself demands JSON-only output.
|
|
83
|
+
*
|
|
84
|
+
* Provider-agnostic and meant as a *fallback* after a normal parse attempt
|
|
85
|
+
* fails, so it's a no-op for models that already comply (Claude).
|
|
86
|
+
*
|
|
87
|
+
* @returns The raw text of the coerced response (a JSON document). The caller
|
|
88
|
+
* still validates/repairs it against its domain schema.
|
|
89
|
+
*/
|
|
90
|
+
export declare function coerceJsonOutput(params: CoerceJsonParams): Promise<string>;
|
|
40
91
|
/**
|
|
41
92
|
* Run a multi-turn agentic conversation loop.
|
|
42
93
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentic-loop.d.ts","sourceRoot":"","sources":["../../src/orchestrator/agentic-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAA4D,MAAM,uBAAuB,CAAC;AAE1H,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAKpD,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,MAAM,EAAE,SAAS,CAAC;IAClB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,sDAAsD;IACtD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IAC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AAC,EAAE,MAAM,CAAC;IACnB,mGAAmG;IACnG,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,8BAA8B;IAC9B,KAAK,EAAE;QACL,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AAyED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,MAAM,CAAC,CA0CjB;AAID;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CA0L5B"}
|
|
@@ -1,4 +1,102 @@
|
|
|
1
1
|
import { logger } from "../utils/logger.js";
|
|
2
|
+
// ── Transient-error retry ──────────────────────────────────────────
|
|
3
|
+
/** Max retry attempts for transient API failures before giving up. */
|
|
4
|
+
const MAX_CHAT_RETRIES = 5;
|
|
5
|
+
/**
|
|
6
|
+
* Substrings that mark a *transient* failure worth retrying. Slower
|
|
7
|
+
* OpenAI-compatible providers (e.g. DeepSeek) routinely drop a connection
|
|
8
|
+
* mid-request ("terminated") or return 429/5xx under load. Auth errors (401),
|
|
9
|
+
* bad requests (400), and the like are NOT listed here, so they fail fast.
|
|
10
|
+
*/
|
|
11
|
+
const TRANSIENT_ERROR_PATTERNS = [
|
|
12
|
+
"terminated",
|
|
13
|
+
"econnreset",
|
|
14
|
+
"etimedout",
|
|
15
|
+
"enotfound",
|
|
16
|
+
"fetch failed",
|
|
17
|
+
"socket hang up",
|
|
18
|
+
"epipe",
|
|
19
|
+
"network",
|
|
20
|
+
"timeout",
|
|
21
|
+
"overloaded",
|
|
22
|
+
"rate limit",
|
|
23
|
+
"429",
|
|
24
|
+
"500",
|
|
25
|
+
"502",
|
|
26
|
+
"503",
|
|
27
|
+
"504",
|
|
28
|
+
];
|
|
29
|
+
function isTransientError(message) {
|
|
30
|
+
const m = message.toLowerCase();
|
|
31
|
+
return TRANSIENT_ERROR_PATTERNS.some((p) => m.includes(p));
|
|
32
|
+
}
|
|
33
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
34
|
+
/**
|
|
35
|
+
* Call client.chat() with exponential backoff on transient errors.
|
|
36
|
+
* Non-transient errors are rethrown immediately (no point retrying a 401).
|
|
37
|
+
*/
|
|
38
|
+
async function chatWithRetry(client, params, turn) {
|
|
39
|
+
let lastErr;
|
|
40
|
+
for (let attempt = 1; attempt <= MAX_CHAT_RETRIES; attempt++) {
|
|
41
|
+
try {
|
|
42
|
+
return await client.chat(params);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
lastErr = err;
|
|
46
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
47
|
+
if (!isTransientError(message) || attempt === MAX_CHAT_RETRIES) {
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
const backoffMs = Math.min(1000 * 2 ** (attempt - 1), 30_000);
|
|
51
|
+
logger.warn(`Transient API error on turn ${turn} ` +
|
|
52
|
+
`(attempt ${attempt}/${MAX_CHAT_RETRIES}): ${message}. ` +
|
|
53
|
+
`Retrying in ${backoffMs}ms...`);
|
|
54
|
+
await sleep(backoffMs);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
throw lastErr;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Force a structured-JSON response after an agentic loop failed to produce the
|
|
61
|
+
* required object. Some OpenAI-compatible models (notably DeepSeek) either
|
|
62
|
+
* narrate prose instead of JSON, or emit valid JSON of the WRONG shape (e.g.
|
|
63
|
+
* following a short "summary" prompt instead of the full schema).
|
|
64
|
+
*
|
|
65
|
+
* Strategy: re-ask with `json_object` response_format (broadly supported,
|
|
66
|
+
* including DeepSeek) plus an explicit field-by-field instruction. If the
|
|
67
|
+
* provider rejects response_format at all (some servers 400 on it), fall back
|
|
68
|
+
* to a plain prompt-only call — the instruction itself demands JSON-only output.
|
|
69
|
+
*
|
|
70
|
+
* Provider-agnostic and meant as a *fallback* after a normal parse attempt
|
|
71
|
+
* fails, so it's a no-op for models that already comply (Claude).
|
|
72
|
+
*
|
|
73
|
+
* @returns The raw text of the coerced response (a JSON document). The caller
|
|
74
|
+
* still validates/repairs it against its domain schema.
|
|
75
|
+
*/
|
|
76
|
+
export async function coerceJsonOutput(params) {
|
|
77
|
+
const { client, model, systemPrompt, userMessage, priorText, instruction, maxTokens = 16384, } = params;
|
|
78
|
+
const messages = [
|
|
79
|
+
{ role: "user", content: userMessage },
|
|
80
|
+
{ role: "assistant", content: priorText || "(no output produced)" },
|
|
81
|
+
{ role: "user", content: instruction },
|
|
82
|
+
];
|
|
83
|
+
try {
|
|
84
|
+
const response = await chatWithRetry(client, { model, system: systemPrompt, messages, jsonObjectMode: true, maxTokens }, 0);
|
|
85
|
+
return response.text;
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
89
|
+
// Provider rejected response_format (e.g. DeepSeek 400 "response_format type
|
|
90
|
+
// is unavailable"). Retry without it — the instruction still demands JSON.
|
|
91
|
+
if (/response_format|json/i.test(message)) {
|
|
92
|
+
logger.warn(`Provider rejected json_object mode (${message}); ` +
|
|
93
|
+
`retrying coercion without response_format.`);
|
|
94
|
+
const response = await chatWithRetry(client, { model, system: systemPrompt, messages, maxTokens }, 0);
|
|
95
|
+
return response.text;
|
|
96
|
+
}
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
2
100
|
// ── Main loop ──────────────────────────────────────────────────────
|
|
3
101
|
/**
|
|
4
102
|
* Run a multi-turn agentic conversation loop.
|
|
@@ -14,7 +112,7 @@ import { logger } from "../utils/logger.js";
|
|
|
14
112
|
* @returns The final text response and metadata about the conversation.
|
|
15
113
|
*/
|
|
16
114
|
export async function runAgenticLoop(params) {
|
|
17
|
-
const { client, model, systemPrompt, userMessage, tools, toolHandlers, maxTurns, maxTokens = 16384, onToolUse, onTurnComplete, } = params;
|
|
115
|
+
const { client, model, systemPrompt, userMessage, tools, toolHandlers, maxTurns, maxTokens = 16384, onToolUse, onTurnComplete, completionCheck, maxNudges = 2, nudgeMessage, } = params;
|
|
18
116
|
const messages = [
|
|
19
117
|
{ role: "user", content: userMessage },
|
|
20
118
|
];
|
|
@@ -22,17 +120,18 @@ export async function runAgenticLoop(params) {
|
|
|
22
120
|
let totalOutputTokens = 0;
|
|
23
121
|
const allToolsCalled = [];
|
|
24
122
|
let finalText = "";
|
|
123
|
+
let nudgesUsed = 0;
|
|
25
124
|
for (let turn = 1; turn <= maxTurns; turn++) {
|
|
26
125
|
logger.debug(`Agentic loop turn ${turn}/${maxTurns}...`);
|
|
27
126
|
let response;
|
|
28
127
|
try {
|
|
29
|
-
response = await client
|
|
128
|
+
response = await chatWithRetry(client, {
|
|
30
129
|
model,
|
|
31
130
|
system: systemPrompt,
|
|
32
131
|
messages,
|
|
33
132
|
tools: tools.length > 0 ? tools : undefined,
|
|
34
133
|
maxTokens,
|
|
35
|
-
});
|
|
134
|
+
}, turn);
|
|
36
135
|
}
|
|
37
136
|
catch (err) {
|
|
38
137
|
// Handle context window exhaustion or other API errors
|
|
@@ -53,9 +152,29 @@ export async function runAgenticLoop(params) {
|
|
|
53
152
|
totalInputTokens += response.usage.inputTokens;
|
|
54
153
|
totalOutputTokens += response.usage.outputTokens;
|
|
55
154
|
const turnStopReason = response.stopReason;
|
|
56
|
-
// If the model is done (no more tool use), return
|
|
155
|
+
// If the model is done (no more tool use), return — UNLESS a completion
|
|
156
|
+
// predicate says this tool-less turn isn't actually complete (model narrated
|
|
157
|
+
// intentions instead of acting). In that case, nudge it to act and continue.
|
|
57
158
|
if (response.stopReason !== "tool_use") {
|
|
58
159
|
finalText = response.text;
|
|
160
|
+
const incomplete = completionCheck !== undefined &&
|
|
161
|
+
!completionCheck(finalText) &&
|
|
162
|
+
nudgesUsed < maxNudges;
|
|
163
|
+
if (incomplete) {
|
|
164
|
+
nudgesUsed += 1;
|
|
165
|
+
logger.warn(`Model ended turn ${turn} without calling a tool and without ` +
|
|
166
|
+
`completing (nudge ${nudgesUsed}/${maxNudges}). Prompting it to continue.`);
|
|
167
|
+
messages.push({ role: "assistant", content: finalText });
|
|
168
|
+
messages.push({
|
|
169
|
+
role: "user",
|
|
170
|
+
content: nudgeMessage ??
|
|
171
|
+
"You stopped without calling any tool and without producing your " +
|
|
172
|
+
"final result. If work remains, CALL THE APPROPRIATE TOOL now to " +
|
|
173
|
+
"do it (do not describe what you would do — actually call the tool). " +
|
|
174
|
+
"If you are genuinely finished, output ONLY your final result now.",
|
|
175
|
+
});
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
59
178
|
return {
|
|
60
179
|
finalText,
|
|
61
180
|
turnsUsed: turn,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentic-loop.js","sourceRoot":"","sources":["../../src/orchestrator/agentic-loop.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"agentic-loop.js","sourceRoot":"","sources":["../../src/orchestrator/agentic-loop.ts"],"names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W;SACZ,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEjC,cAAc,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,2CAA2C;IAC3C,MAAM,CAAC,IAAI,CACT,oCAAoC,QAAQ,8BAA8B,CAC3E,CAAC;IAEF,OAAO;QACL,SAAS,EACP,SAAS;YACT,6EAA6E;QAC/E,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,cAAc;QAC3B,KAAK,EAAE;YACL,WAAW,EAAE,gBAAgB;YAC7B,YAAY,EAAE,iBAAiB;SAChC;QACD,UAAU,EAAE,oBAAoB;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve an architect lens name to its focus fragment.
|
|
3
|
+
* Returns the catalog entry for a known lens, or a generic non-empty
|
|
4
|
+
* fallback for any unknown custom string — never throws (C2).
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveArchLensFocus(lens: string): string;
|
|
7
|
+
//# sourceMappingURL=arch-lenses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arch-lenses.d.ts","sourceRoot":"","sources":["../../src/orchestrator/arch-lenses.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// ── Lens catalog ────────────────────────────────────────────────────
|
|
2
|
+
/** Built-in architect lens focus fragments. Each must be distinct and non-empty (C2). */
|
|
3
|
+
const ARCH_LENS_CATALOG = {
|
|
4
|
+
scalability: "Focus on whether the proposed architecture can handle projected load growth. Evaluate horizontal and vertical scaling paths, bottlenecks, stateful vs stateless components, and whether partitioning or sharding strategies are available when needed.",
|
|
5
|
+
security: "Focus on the threat surface introduced by this architecture. Evaluate trust boundaries, data flows across zones, authentication and authorisation enforcement points, secrets management, and exposure of internal services.",
|
|
6
|
+
cost: "Focus on the total cost of ownership implied by this architecture. Evaluate compute, storage, and egress costs at projected scale, licensing or SaaS subscription expenses, and the operational overhead of running, monitoring, and scaling the system.",
|
|
7
|
+
operability: "Focus on how easy it will be to operate this architecture in production. Evaluate observability (metrics, logs, traces), deployment complexity, rollout and rollback procedures, on-call burden, and the blast radius of common failure modes.",
|
|
8
|
+
maintainability: "Focus on how easy it will be to change and extend this architecture over time. Evaluate coupling between components, clarity of boundaries, documentation needs, onboarding friction for new contributors, and the risk of accruing technical debt.",
|
|
9
|
+
reversibility: "Focus on how difficult or costly it would be to undo or replace this architectural decision. Evaluate lock-in to vendors or proprietary technologies, data migration complexity, and whether a strangler-fig or incremental migration path exists if the approach needs to change.",
|
|
10
|
+
simplicity: "Focus on whether this is the simplest architecture that satisfies the Checkpoint 1 constraints. Challenge whether each component needs to exist, whether a native platform feature or an already-present dependency removes a proposed custom layer, whether two components should collapse into one, and whether any abstraction is speculative — added for a use case absent from the problem statement. Reward the smallest design that honours every hard constraint; penalise layers introduced for unproven future flexibility, but never at the expense of a stated constraint.",
|
|
11
|
+
};
|
|
12
|
+
// ── Resolver ────────────────────────────────────────────────────────
|
|
13
|
+
/**
|
|
14
|
+
* Resolve an architect lens name to its focus fragment.
|
|
15
|
+
* Returns the catalog entry for a known lens, or a generic non-empty
|
|
16
|
+
* fallback for any unknown custom string — never throws (C2).
|
|
17
|
+
*/
|
|
18
|
+
export function resolveArchLensFocus(lens) {
|
|
19
|
+
return (ARCH_LENS_CATALOG[lens] ??
|
|
20
|
+
`Evaluate this architecture specifically through the '${lens}' lens.`);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=arch-lenses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arch-lenses.js","sourceRoot":"","sources":["../../src/orchestrator/arch-lenses.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,yFAAyF;AACzF,MAAM,iBAAiB,GAA2B;IAChD,WAAW,EACT,wPAAwP;IAC1P,QAAQ,EACN,8NAA8N;IAChO,IAAI,EACF,0PAA0P;IAC5P,WAAW,EACT,gPAAgP;IAClP,eAAe,EACb,qPAAqP;IACvP,aAAa,EACX,oRAAoR;IACtR,UAAU,EACR,wjBAAwjB;CAC3jB,CAAC;AAEF,uEAAuE;AAEvE;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,CACL,iBAAiB,CAAC,IAAI,CAAC;QACvB,wDAAwD,IAAI,SAAS,CACtE,CAAC;AACJ,CAAC"}
|
|
@@ -15,6 +15,22 @@ export interface ArchitectResult {
|
|
|
15
15
|
componentCount: number;
|
|
16
16
|
/** Number of Architecture Decision Records produced. */
|
|
17
17
|
decisionCount: number;
|
|
18
|
+
/** Per-lens scores from the panel path (additive, optional — absent on the off path). */
|
|
19
|
+
lensScores?: Array<{
|
|
20
|
+
lens: string;
|
|
21
|
+
scores: Record<string, number>;
|
|
22
|
+
}>;
|
|
23
|
+
/** The approach selected by synthesize().winner on the panel path (additive, optional — absent on the off path). */
|
|
24
|
+
selectedApproach?: string;
|
|
25
|
+
/** Per-lens CP5 review verdicts from the panel path (additive, optional — absent on the off path). */
|
|
26
|
+
lensReviews?: Array<{
|
|
27
|
+
lens: string;
|
|
28
|
+
passed: boolean;
|
|
29
|
+
summary: string;
|
|
30
|
+
feedback: string;
|
|
31
|
+
}>;
|
|
32
|
+
/** The reconciled panel verdict for CP5 (additive, optional). false = fail-closed. */
|
|
33
|
+
panelReviewPassed?: boolean;
|
|
18
34
|
}
|
|
19
35
|
/**
|
|
20
36
|
* Run the 5-checkpoint architect flow in autonomous mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect-agent.d.ts","sourceRoot":"","sources":["../../src/orchestrator/architect-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"architect-agent.d.ts","sourceRoot":"","sources":["../../src/orchestrator/architect-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAuBvD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uFAAuF;IACvF,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IACrE,oHAAoH;IACpH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sGAAsG;IACtG,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1F,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AA6FD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC,CAQ1B"}
|