@dreb/coding-agent 2.45.4 → 2.46.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.
Files changed (60) hide show
  1. package/README.md +6 -2
  2. package/dist/core/agent-session.d.ts +10 -2
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +75 -15
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/context-buffer.d.ts +2 -0
  7. package/dist/core/context-buffer.d.ts.map +1 -1
  8. package/dist/core/context-buffer.js +8 -0
  9. package/dist/core/context-buffer.js.map +1 -1
  10. package/dist/core/dispatch-arbiter.d.ts +94 -0
  11. package/dist/core/dispatch-arbiter.d.ts.map +1 -0
  12. package/dist/core/dispatch-arbiter.js +316 -0
  13. package/dist/core/dispatch-arbiter.js.map +1 -0
  14. package/dist/core/git-repo-state.d.ts +2 -0
  15. package/dist/core/git-repo-state.d.ts.map +1 -1
  16. package/dist/core/git-repo-state.js +19 -0
  17. package/dist/core/git-repo-state.js.map +1 -1
  18. package/dist/core/model-routing-guide.d.ts +15 -0
  19. package/dist/core/model-routing-guide.d.ts.map +1 -0
  20. package/dist/core/model-routing-guide.js +186 -0
  21. package/dist/core/model-routing-guide.js.map +1 -0
  22. package/dist/core/settings-manager.d.ts +18 -0
  23. package/dist/core/settings-manager.d.ts.map +1 -1
  24. package/dist/core/settings-manager.js +33 -0
  25. package/dist/core/settings-manager.js.map +1 -1
  26. package/dist/core/thinking.d.ts +14 -0
  27. package/dist/core/thinking.d.ts.map +1 -1
  28. package/dist/core/thinking.js +35 -2
  29. package/dist/core/thinking.js.map +1 -1
  30. package/dist/core/tools/index.d.ts +7 -1
  31. package/dist/core/tools/index.d.ts.map +1 -1
  32. package/dist/core/tools/index.js.map +1 -1
  33. package/dist/core/tools/subagent.d.ts +53 -6
  34. package/dist/core/tools/subagent.d.ts.map +1 -1
  35. package/dist/core/tools/subagent.js +343 -53
  36. package/dist/core/tools/subagent.js.map +1 -1
  37. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  38. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  39. package/dist/modes/interactive/components/settings-selector.js +99 -1
  40. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  41. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  42. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  43. package/dist/modes/interactive/interactive-mode.js +75 -1
  44. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  45. package/dist/modes/rpc/rpc-mode.d.ts +2 -2
  46. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  47. package/dist/modes/rpc/rpc-mode.js +65 -0
  48. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  49. package/dist/modes/rpc/rpc-types.d.ts +8 -0
  50. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  51. package/dist/modes/rpc/rpc-types.js.map +1 -1
  52. package/docs/agent-models.md +33 -1
  53. package/docs/dashboard.md +8 -2
  54. package/docs/json.md +31 -5
  55. package/docs/rpc.md +60 -9
  56. package/docs/session.md +7 -1
  57. package/docs/settings.md +33 -1
  58. package/docs/skills.md +38 -0
  59. package/package.json +1 -1
  60. package/skills/model-routing-guide/SKILL.md +182 -0
package/README.md CHANGED
@@ -388,7 +388,7 @@ The `subagent` tool delegates tasks to independent child agent processes. Each s
388
388
  - **Parallel** (`tasks`): Up to 8 concurrent agents (max 4 at a time)
389
389
  - **Chain** (`chain`): Sequential pipeline where each step can reference the previous step's output via `{previous}`
390
390
 
391
- **Agent type inheritance:** The top-level `agent` parameter is inherited by parallel tasks and chain steps that don't specify their own. Precedence: per-task `agent` > top-level `agent` > default (`"Explore"`). The `model` parameter follows the same inheritance.
391
+ **Agent type and override inheritance:** The top-level `agent` parameter is inherited by parallel tasks and chain steps that don't specify their own. Precedence: per-task `agent` > top-level `agent` > default (`"Explore"`). The `model` and optional `thinking` parameters follow the same per-task-over-top-level inheritance. Explicit thinking accepts `off`, `minimal`, `low`, `medium`, `high`, or `xhigh`; unsupported levels for the resolved model fail before spawn. Omit `thinking` to preserve the child's normal settings/default behavior.
392
392
 
393
393
  **Agent definitions** live in `~/.dreb/agents/` (global) and `.dreb/agents/` (project). Each is a markdown file with YAML frontmatter specifying `name`, `model` (with provider fallback list), and optional `systemPrompt`. Built-in agents include `Explore` (read-only codebase exploration), `Sandbox` (restricted to `/tmp`), `feature-dev` (strong-tier coding), and several review agents.
394
394
 
@@ -396,9 +396,11 @@ The `subagent` tool delegates tasks to independent child agent processes. Each s
396
396
 
397
397
  **Per-agent model overrides:** The model used by each agent type can be overridden via the `agentModels.models` setting (a map of agent name → ordered fallback list) without copying or editing the agent definition `.md` files. Configure it in `settings.json` or via `/settings` → **Agent Models**. Resolution order: per-invocation `model` override → `agentModels` setting → agent definition `model` → parent session model. See [docs/agent-models.md](docs/agent-models.md).
398
398
 
399
+ **Optional Dispatch Arbiter:** A global-only `subagentArbiter` setting can enable a fully headless, direct model call after the proposal above resolves but before each child process spawns. It uses the validated routing guide, live explicit model scope, and bounded title-setter-style parent activity including useful tool outputs; existing secret scrubbing applies before inference. It may change only the existing agent type, exact scoped provider/model, and supported thinking level. It has no tools, cannot rewrite the task/cwd or agent definitions, and fails closed on configuration, guide, scope, inference, output, or validation errors. It runs once per single/parallel child and after `{previous}` substitution for every chain step. Interactive `/settings` and dashboard Settings both expose enable/disable, exact model selection, thinking, guide path, and loud readiness/validation feedback. Safe typed changed/unchanged/failure records are persisted outside parent model context and relayed to the TUI, JSON/RPC, and dashboard. See [Dispatch Arbiter](docs/agent-models.md#dispatch-arbiter) and [settings](docs/settings.md#dispatch-arbiter).
400
+
399
401
  **Model identity in system prompt:** The parent session's running model is exposed in its own system prompt as `You are running on: provider/id`. This lets the model make self-aware routing decisions (e.g. delegate vision tasks to a multimodal subagent, or use a differently-architected model as a critic). The line updates automatically on mid-session model switches.
400
402
 
401
- **Session metadata:** Each child process records its agent type in the session JSONL header (`agentType` field), providing an audit trail of which agent definition executed the work.
403
+ **Session and event metadata:** Each child process records its agent type in the session JSONL header (`agentType` field), providing an audit trail of which agent definition executed the work. Child `agent_start`, subagent results, and `background_agent_end` also expose the canonical resolved `provider/model` and effective thinking level, including defaults used when no override was supplied. Chain completion events expose ordered per-step metadata because steps may use different models or thinking levels. Enabled arbiter attempts add a separate `subagent_arbitration` event with proposed/final routes, changed fields, status, optional chain step, and safe host error metadata; raw prompts, responses, and reasoning are never included.
402
404
 
403
405
  **Background-agent guardrail:** Background subagents run asynchronously and return control to you while they work. To stop the parent agent from spinning ahead of results, a guardrail pauses it after `backgroundAgents.parentTurnLimit` turns (default 3) while subagents are still running. When this happens, dreb surfaces a friendly, non-error notification in the TUI and Telegram — explaining that background agents are still working and the parent paused intentionally, and that it resumes when they report back or when you send a message to steer it. This is a frontend/session event, not a model-context steer, so it can't go stale. Set `backgroundAgents.parentTurnGuardrail` to `false` to let the parent run unbounded while subagents work, or raise `parentTurnLimit` to relax the guardrail. See [settings](docs/settings.md#background-agents).
404
406
 
@@ -462,6 +464,8 @@ Place in `~/.dreb/agent/skills/`, `~/.agents/skills/`, `.dreb/skills/`, or `.age
462
464
 
463
465
  dreb ships with **mach6** — a built-in development workflow (issue → plan → push → review → fix → publish) that uses GitHub as shared memory and multi-agent code review. See [docs/mach6.md](docs/mach6.md).
464
466
 
467
+ It also ships with the explicitly invoked **`model-routing-guide`** skill. Pass comma-separated model patterns as arguments, or run it without arguments to use the effective non-empty `enabledModels` array. Prefix either form with `update` to diff an existing guide against the resolved scope, preserve retained entries, remove stale ones, and research newly added models instead of rebuilding everything. Those are its only scope sources: it cannot discover a session's runtime `--models` value, so pass those same patterns explicitly when that is the intended scope. It researches canonical provider/model candidates, external evidence, and sanitized aggregate subagent history, then validates and writes `~/.dreb/agent/model-routing-guide.md` atomically. The optional global Dispatch Arbiter consumes the guide only when its exact coverage matches the live explicit scope. See [docs/skills.md](docs/skills.md#model-routing-guide) and [docs/agent-models.md](docs/agent-models.md#dispatch-arbiter).
468
+
465
469
  ### Extensions
466
470
 
467
471
  <p align="center"><img src="docs/images/doom-extension.png" alt="Doom Extension" width="600"></p>
@@ -16,6 +16,7 @@ import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLe
16
16
  import type { ImageContent, Model, TextContent } from "@dreb/ai";
17
17
  import { type BashResult } from "./bash-executor.js";
18
18
  import { type CompactionResult } from "./compaction/index.js";
19
+ import { type DispatchArbiterDeps } from "./dispatch-arbiter.js";
19
20
  import { type ContextUsage, type ExtensionCommandContextActions, type ExtensionErrorListener, ExtensionRunner, type ExtensionUIContext, type InputSource, type ShutdownHandler, type ToolDefinition, type ToolInfo } from "./extensions/index.js";
20
21
  import type { CustomMessage } from "./messages.js";
21
22
  import type { ModelRegistry } from "./model-registry.js";
@@ -25,7 +26,7 @@ import type { ResourceLoader } from "./resource-loader.js";
25
26
  import type { BranchSummaryEntry, SessionManager } from "./session-manager.js";
26
27
  import { type SettingsManager } from "./settings-manager.js";
27
28
  import type { BashOperations } from "./tools/bash.js";
28
- import { type SessionTask, type SubagentResult } from "./tools/index.js";
29
+ import { type SessionTask, type SubagentArbitrationEvent, type SubagentResult, type SubagentStepMetadata } from "./tools/index.js";
29
30
  /** Parsed skill block from a user message */
30
31
  export interface ParsedSkillBlock {
31
32
  name: string;
@@ -39,7 +40,7 @@ export interface ParsedSkillBlock {
39
40
  */
40
41
  export declare function parseSkillBlock(text: string): ParsedSkillBlock | null;
41
42
  /** Session-specific events that extend the core AgentEvent */
42
- export type AgentSessionEvent = AgentEvent | {
43
+ export type AgentSessionEvent = AgentEvent | SubagentArbitrationEvent | {
43
44
  type: "auto_compaction_start";
44
45
  reason: "threshold" | "overflow";
45
46
  } | {
@@ -70,6 +71,9 @@ export type AgentSessionEvent = AgentEvent | {
70
71
  agentId: string;
71
72
  agentType: string;
72
73
  success: boolean;
74
+ model?: string;
75
+ thinking?: ThinkingLevel;
76
+ steps?: SubagentStepMetadata[];
73
77
  sessionFile?: string;
74
78
  } | {
75
79
  type: "background_agent_event";
@@ -126,6 +130,8 @@ export interface AgentSessionConfig {
126
130
  uiType?: string;
127
131
  /** Optional performance tracker override, primarily for isolated tests. */
128
132
  performanceTracker?: PerformanceTracker;
133
+ /** Inject the headless arbiter completion seam for deterministic, offline integration tests. */
134
+ dispatchArbiterComplete?: DispatchArbiterDeps["complete"];
129
135
  }
130
136
  export interface ExtensionBindings {
131
137
  uiContext?: ExtensionUIContext;
@@ -234,11 +240,13 @@ export declare class AgentSession {
234
240
  private performanceTracker;
235
241
  private _ownsPerformanceTracker;
236
242
  private _gitRepoState;
243
+ private _dispatchArbiter;
237
244
  constructor(config: AgentSessionConfig);
238
245
  /** Model registry for API key resolution and model discovery */
239
246
  get modelRegistry(): ModelRegistry;
240
247
  /** Performance tracker for recording and querying model throughput */
241
248
  getPerformanceTracker(): PerformanceTracker;
249
+ private _compileExtraSecretPatterns;
242
250
  /**
243
251
  * Install tool hooks once on the Agent instance.
244
252
  *