@dreb/coding-agent 2.66.0 → 2.66.2

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.
@@ -36,7 +36,7 @@ By default, `reserveTokens` is 16384 tokens (configurable in `~/.dreb/agent/sett
36
36
 
37
37
  The threshold is checked after a run ends, before a new prompt, and inside a running agent loop before each LLM request. Mid-turn checks run only when context is settled on a user or tool-result message, after all tool calls from the preceding assistant message have matching results. If the threshold is crossed, dreb compacts and replaces the running loop's context before that loop makes its next request; it does not start a second agent run.
38
38
 
39
- If response-length retries are exhausted, dreb distinguishes a genuine output-budget failure from a full-context truncation using recorded usage. Usage at or beyond `contextWindow` enters overflow compact-and-retry recovery; usage below it remains a loud output-budget error.
39
+ When a response reaches its configured output limit, length retries discard the partial response and retry at that same configured limit; they never increase `maxTokens`. After those retries are exhausted, dreb distinguishes a genuine output-budget failure from possible context pressure. It enters one reactive compact-and-retry recovery only when the provider reports context exhaustion, recorded usage reaches `contextWindow`, or the measured request input plus configured output maximum could not fit in the window. Otherwise the turn fails loudly without discarding conversation history. This reactive recovery does not change the proactive threshold above: a large theoretical output maximum alone never triggers early compaction.
40
40
 
41
41
  You can also trigger manually with `/compact [instructions]`, where optional instructions focus the summary.
42
42
 
package/docs/dashboard.md CHANGED
@@ -132,8 +132,8 @@ networking window above.
132
132
 
133
133
  | Screen | What it does |
134
134
  |---|---|
135
- | **Fleet** | Home. Live-first: one grid of every live session at the top — status chip (● running / ◆ needs-attention / ○ idle / ✕ error), project path, activity line, live subagent lines, tasks progress, ctx%, model, terminal provider-error reason, last activity. Live cards keep a deterministic order by project path, then session start time; needs-attention cards badge the browser tab without jumping around. Below the grid: past sessions grouped by project, three compact rows per group with an "all N on disk" expander, resume and delete. |
136
- | **Session view** | Full chat drill-in. Markdown streaming transcript (text, thinking blocks with expand preference, inline provider/API failures with partial output preserved, agent-result cards, tool cards with bespoke read/write/edit/bash bodies plus full expandable inputs, markdown-rendered results for markdown-contract tools like subagent/skill/web_fetch/suggest_next, and inline tool-result images, compaction/branch summaries, custom messages), per-message copy, tasks panel, a bounded scrollable subagent panel that lists every retained agent newest-first with full running/done counts, a shared dismissible banner region for model fallback, extension notices, retry/compaction/paused/provider status, and local action results, a controls-only dock line with elapsed time plus ■ stop and explicitly labelled retry/compaction aborts, a persistent session-header live indicator, and an info bar with cwd, branch, session name, token breakdown, cost/(sub)/daily rollup, ctx%, a TUI-parity latest-100 median TPS indicator (`~31 tok/s [100] · 10% ↑ median [10000]`), and a stats popover. A fleet sidebar lists every other live session beside the transcript with the fleet cards' project, status/reasons, activity/latest-assistant preview, running/done subagent summaries, task progress, model, context, cost, message count, and last activity, deterministically ordered by project path then session start time (the fleet page's comparator), so needs-attention/error entries are emphasized — a filled attention chip or outlined error chip plus an entry border — without moving position; clicking an entry navigates to that session, desktop collapse and pointer/keyboard-resizable width persist browser-locally (default expanded, 260px), the hidden toggle border reflects the highest-priority other-session status, and neither sidebar nor toggle renders when no other live sessions exist. The subagent drill-in shows the same sidebar with its parent session excluded. Composer supports auto-grow, history, `/` autocomplete from `get_commands`, image attach/paste with sent images retained as user-message previews, queued-message chips with restore-all, steer/follow-up modes, and suggest-next. Registered built-in slash commands are discovered generically, deduplicated ahead of colliding resource commands, and intercepted before prompting: dashboard actions cover settings, model, scoped-models, export/import, name/session stats, fork/tree, new/compact/dream, resume/reload, and quit. `/scoped-models` deep-links to the Settings editor with the session's current cwd as project context; login/logout show an explicit not-yet-implemented notice, while copy/hotkeys/buddy give terminal-only guidance. Future built-ins are intercepted automatically. The RPC prompt boundary rejects any built-in that reaches it during command-loading races or failures, so slash text cannot leak to the model. Attachments are retained and the command is visibly rejected rather than silently discarded. The ⋯ menu covers export HTML, compact, rename, fork-from-message, loaded context, and tool expand/collapse. Session names update live from manual rename or auto-naming. Extension UI requests for select/confirm/input/editor render as modals; a rich `ask`/`ask_user` request renders inline as a single wizard that presents all its questions together — each with Markdown-formatted question text, choices, optional free text — plus an in-card Stop agent action, Escape-to-stop, and the authoritative auto-stop countdown, and is answered as one batch submit. Pending questions set needs-attention state and use the existing hidden-page notification path. Extension notifications for the viewed session render in its banner region; other sessions' and app-global notices use the fixed top-center toast stack. |
135
+ | **Fleet** | Home. Live-first: one grid of every live session at the top — status chip (● running / ◆ needs-attention / ○ idle / ✕ error), project path, activity line, live subagent lines, tasks progress, ctx%, model, terminal provider-error reason, last activity. Live cards keep a deterministic order by project path, then session start time; needs-attention cards badge the browser tab without jumping around. Below the grid: past sessions grouped by their historical project, three compact rows per group with an "all N on disk" expander, resume and delete. Sessions remain visible when that historical directory is missing; resume opens an explicit runtime-directory chooser instead of mutating or hiding the session. |
136
+ | **Session view** | Full chat drill-in. Markdown streaming transcript (text, thinking blocks with expand preference, inline provider/API failures with partial output preserved, agent-result cards, tool cards with bespoke read/write/edit/bash bodies plus full expandable inputs, markdown-rendered results for markdown-contract tools like subagent/skill/web_fetch/suggest_next, and inline tool-result images, compaction/branch summaries, custom messages), per-message copy, tasks panel, a bounded scrollable subagent panel that lists every retained agent newest-first with full running/done counts, a shared dismissible banner region for model fallback, extension notices, retry/compaction/paused/provider status, and local action results, a controls-only dock line with elapsed time plus ■ stop and explicitly labelled retry/compaction aborts, a persistent session-header live indicator, and an info bar with cwd, original-session provenance when a historical session is resumed in a different runtime directory, branch, session name, token breakdown, cost/(sub)/daily rollup, ctx%, a TUI-parity latest-100 median TPS indicator (`~31 tok/s [100] · 10% ↑ median [10000]`), and a stats popover. A fleet sidebar lists every other live session beside the transcript with the fleet cards' project, status/reasons, activity/latest-assistant preview, running/done subagent summaries, task progress, model, context, cost, message count, last activity, and any original-session provenance, deterministically ordered by project path then session start time (the fleet page's comparator), so needs-attention/error entries are emphasized — a filled attention chip or outlined error chip plus an entry border — without moving position; clicking an entry navigates to that session, desktop collapse and pointer/keyboard-resizable width persist browser-locally (default expanded, 260px), the hidden toggle border reflects the highest-priority other-session status, and neither sidebar nor toggle renders when no other live sessions exist. The subagent drill-in shows the same sidebar with its parent session excluded. Closed-session banners offer direct resume when the captured runtime directory still exists and an explicit directory chooser when the historical directory is missing or should be replaced. Composer supports auto-grow, history, `/` autocomplete from `get_commands`, image attach/paste with sent images retained as user-message previews, queued-message chips with restore-all, steer/follow-up modes, and suggest-next. Registered built-in slash commands are discovered generically, deduplicated ahead of colliding resource commands, and intercepted before prompting: dashboard actions cover settings, model, scoped-models, export/import, name/session stats, fork/tree, new/compact/dream, resume/reload, and quit. `/scoped-models` deep-links to the Settings editor with the session's current cwd as project context; login/logout show an explicit not-yet-implemented notice, while copy/hotkeys/buddy give terminal-only guidance. Future built-ins are intercepted automatically. The RPC prompt boundary rejects any built-in that reaches it during command-loading races or failures, so slash text cannot leak to the model. Attachments are retained and the command is visibly rejected rather than silently discarded. The ⋯ menu covers export HTML, compact, rename, fork-from-message, loaded context, and tool expand/collapse. Session names update live from manual rename or auto-naming. Extension UI requests for select/confirm/input/editor render as modals; a rich `ask`/`ask_user` request renders inline as a single wizard that presents all its questions together — each with Markdown-formatted question text, choices, optional free text — plus an in-card Stop agent action, Escape-to-stop, and the authoritative auto-stop countdown, and is answered as one batch submit. Pending questions set needs-attention state and use the existing hidden-page notification path. Extension notifications for the viewed session render in its banner region; other sessions' and app-global notices use the fixed top-center toast stack. |
137
137
  | **Subagent view** | Transcript of a background agent: live events via the RPC relay, hydrated from the agent's on-disk session log (`/subagents/:agentId/messages`) so the transcript survives browser reloads. Shows the task, streaming output, tool activity, and any safe Dispatch Arbiter changed/unchanged/failure records with the final agent/model/thinking. No raw arbiter output is displayed or transported. While the child is running, a composer sends the user's text unchanged to that specific child as steering input, displays its pending steering queue, and reports its effective `one-at-a-time` or `all` delivery mode. Completed, failed, rehydrated, and unavailable children remain read-only. |
138
138
  | **Files** | Host-wide browser with places shortcuts (home, /tmp, project roots), breadcrumbs to `/`, new-folder, download, drop-zone/picker upload with explicit collision prompts, and "new session here" on any directory. It also shows the **effective global nested-context trust** for the displayed canonical directory: untrusted, trusted by that root, inherited from a granting root, or global expert trust-all. You can trust the displayed folder and descendants, or untrust the actual granting root; untrusting an inherited folder removes that root's trust for all descendants. |
139
139
  | **Memories** | Dreb-only memory management for `~/.dreb/memory` and `.dreb/memory` under active/disk project roots. It lists existing `MEMORY.md` indexes and direct child `.md` entries only (no Claude paths, create, or rename), shows entry frontmatter or metadata errors so malformed files can be repaired, renders sanitized Markdown preview beside a raw editor, and uses exact SHA-256 revisions so stale saves/deletes return conflicts while preserving drafts. The index view is complete, not truncated, and warns when it exceeds the 200-line memory-index convention. Entry deletion requires both entry and index revisions, removes only matching safe Markdown-link index lines (`file.md` / `./file.md`), writes the cleaned index atomically before unlinking the entry, and rolls back loudly if the unlink fails. |
@@ -205,7 +205,32 @@ captured) and **Return to fleet** actions. It is not a live runtime: composers,
205
205
  steering, model/thinking controls, stop controls, polling, and other runtime
206
206
  actions are disabled. Leaving that session's main/subagent route family releases
207
207
  the retained snapshot; Fleet shows no live card, and the authoritative on-disk
208
- session remains in its project group for normal resume.
208
+ session remains in its project group for normal resume. Closed views also offer
209
+ **Choose directory…** if their captured runtime path has disappeared.
210
+
211
+ ### Historical and runtime working directories
212
+
213
+ A persisted session's `cwd` is historical metadata: it records where the session
214
+ started and remains unchanged when the JSONL file is copied to another host or
215
+ its project moves. Dashboard inventory reports that session even when the path no
216
+ longer exists. Missing paths are labelled unavailable and are excluded from
217
+ memory scopes, recent-project choices, and new-session shortcuts.
218
+
219
+ A live runtime has a separate effective CWD. Valid historical paths are
220
+ canonicalized and continue to resume directly. If the historical path is
221
+ unavailable, Dashboard requires the user to choose an existing absolute
222
+ directory; missing, unreadable, and non-directory paths are rejected before the
223
+ RPC child is created. Tools, initial project context, settings, extensions, skills, git state,
224
+ and project agent discovery use the effective runtime directory. Fleet cards and
225
+ session chrome show that effective directory and retain the historical path as a
226
+ separate note whenever they differ. Switching to another transcript inside an
227
+ existing runtime does not change the process CWD.
228
+
229
+ Choosing a fallback never rewrites the original session header. Normal resumed
230
+ work can still append conversation entries. Starting `/new` from that runtime
231
+ records the effective runtime directory in the new session's header, while the
232
+ source transcript retains its historical path. Existing session-format migration
233
+ behavior is unchanged.
209
234
 
210
235
  ### Dispatch Arbiter observability
211
236
 
@@ -311,9 +336,12 @@ nor a disk inventory scan.
311
336
 
312
337
  Live runtime state and on-disk session inventory have separate refresh paths.
313
338
  Before fleet, inventory, or resync serialization, the server explicitly projects
314
- each on-disk session to the declared browser DTO and bounds its first-message
315
- preview to 256 Unicode characters. Internal parent paths and complete searchable
316
- transcript text never cross this browser boundary. After creating, resuming,
339
+ each on-disk session to the declared browser DTO, includes server-validated
340
+ historical-CWD availability and its canonical candidate, and bounds its
341
+ first-message preview to 256 Unicode characters. Unavailable historical paths
342
+ remain visible but do not enter operational project-root inventories. Internal
343
+ parent paths and complete searchable transcript text never cross this browser
344
+ boundary. After creating, resuming,
317
345
  stopping, or deleting a session, the client narrowly refreshes the disk list
318
346
  through `GET /api/sessions` rather than reloading the whole fleet. While the
319
347
  Fleet screen or a session/subagent fleet sidebar is visible, it polls live-runtime
@@ -524,13 +524,11 @@ dreb.on("stream_retry", async (event, ctx) => {
524
524
 
525
525
  #### length_retry
526
526
 
527
- Fired when a turn ends with `stopReason: "length"` (the model exhausted its output token budget mid-response) and dreb discards the truncated partial before retrying with a larger `maxTokens` budget. If all retries are exhausted (or the budget already sits at the model's ceiling), the turn fails loudly instead with an error message ("Response truncated at token limit after N attempts") rather than returning a silently truncated response.
527
+ Fired when a turn ends with `stopReason: "length"` (the model exhausted its configured output limit mid-response) and dreb discards the truncated partial before retrying at that same configured limit. If all retries are exhausted, the agent loop fails loudly with an error message ("Response truncated at the configured output token limit after N attempts") rather than returning a silently truncated response. The session layer may then perform one compact-and-retry recovery when provider evidence or input-plus-output arithmetic indicates that remaining context, rather than the output limit alone, caused the truncation.
528
528
 
529
529
  ```typescript
530
530
  dreb.on("length_retry", async (event, ctx) => {
531
- // event.attempt, event.maxAttempts
532
- // event.previousMaxTokens - the budget used for the truncated attempt
533
- // event.nextMaxTokens - the escalated budget the retry will request
531
+ // event.attempt, event.maxAttempts, event.maxTokens
534
532
  // event.discardedPartial - partial assistant message discarded before retry (debug/instrumentation only)
535
533
  });
536
534
  ```
package/docs/models.md CHANGED
@@ -200,12 +200,14 @@ Leave `authHeader` unset or `false` for endpoints that expect `x-api-key`.
200
200
  | `reasoning` | No | `false` | Supports extended thinking |
201
201
  | `input` | No | `["text"]` | Input types: `["text"]` or `["text", "image"]` |
202
202
  | `contextWindow` | No | `128000` | Context window size in tokens |
203
- | `maxTokens` | No | `16384` | Maximum output tokens |
203
+ | `maxTokens` | No | `16384` | Ordinary request maximum output tokens, including per-model overrides; explicit bounded internal calls may use less |
204
204
  | `cost` | No | all zeros | `{"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}` (per million tokens) |
205
205
  | `compat` | No | provider `compat` | OpenAI compatibility overrides. Merged with provider-level `compat` when both are set. |
206
206
  | `systemPrompt` | No | — | Replace dreb's built-in prompt whenever this exact custom model is active. Mutually exclusive with `appendSystemPrompt`. |
207
207
  | `appendSystemPrompt` | No | — | Preserve the selected base prompt and append model-specific instructions. Mutually exclusive with `systemPrompt`. |
208
208
 
209
+ `maxTokens` is sent as the ordinary request's output maximum; dreb does not reserve or pre-consume that allowance, and providers charge only for tokens actually generated. Purpose-specific internal calls may pass a smaller explicit limit. The ChatGPT-backed `openai-codex` protocol rejects `max_output_tokens`, so its built-in ceiling remains server-controlled and dreb rejects `maxTokens` overrides for that provider rather than silently ignoring them.
210
+
209
211
  Current behavior:
210
212
  - `/model` and `--list-models` list entries by model `id`.
211
213
  - The configured `name` is used for model matching and detail/status text.
@@ -287,7 +289,7 @@ Use `modelOverrides` to customize specific built-in models without replacing the
287
289
  }
288
290
  ```
289
291
 
290
- `modelOverrides` supports these fields per model: `name`, `reasoning`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`, `systemPrompt`, `appendSystemPrompt`.
292
+ `modelOverrides` supports these fields per model: `name`, `reasoning`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`, `systemPrompt`, `appendSystemPrompt`. The ChatGPT-backed `openai-codex` protocol rejects `max_output_tokens`, so dreb rejects `maxTokens` overrides for that provider rather than silently ignoring them; its built-in model ceiling remains server-controlled.
291
293
 
292
294
  Prompt fields follow the same rules as custom model entries: choose replacement or append,
293
295
  not both; use a non-empty string; and do not also configure prompt behavior for the canonical
package/docs/rpc.md CHANGED
@@ -18,6 +18,19 @@ await client.start();
18
18
 
19
19
  This enables per-user filesystem isolation by plain Unix DAC: give each authenticated user a dedicated UID and a working directory owned by that UID at mode `0700`. If the parent lacks the required capability (or the platform doesn't support `uid`/`gid`, e.g. Windows), the spawn fails and `start()` rejects rather than silently running as the parent user.
20
20
 
21
+ ### Runtime CWD and historical session CWD
22
+
23
+ `RpcClientOptions.cwd` is the effective runtime directory supplied to the child
24
+ process. Tools, resource and project-agent discovery, git/tab-title metadata,
25
+ and relative runtime commands use it. Opening or switching to a persisted JSONL
26
+ session does not replace that process directory.
27
+
28
+ A session listing's `cwd` is different: it is historical metadata copied from
29
+ the session header. It can name a moved or missing directory and is not rewritten
30
+ merely because a host launches the transcript in another runtime directory.
31
+ Embedders should display both values when they differ rather than treating the
32
+ historical field as a safe process-spawn path.
33
+
21
34
  ### Process exit and pipe errors
22
35
 
23
36
  `RpcClient.onExit(listener)` receives an `RpcExitInfo` when the child dies: `{ code, signal }` from a process `exit`, or `{ error }` from a spawn/runtime `error`. Process exits also carry `stderrTail` — the last **2000 characters** of the child's captured stderr — so a host that only watches for exit codes can still surface the child's own diagnostic (for example the stdout backpressure guard's abort message) instead of an opaque exit code. In-flight requests are rejected with the exit reason.
@@ -203,7 +216,7 @@ Response:
203
216
  {"type": "response", "command": "dream", "success": true, "data": {"message": "Dream backup path: /home/user/.dreb/memory-archive"}}
204
217
  ```
205
218
 
206
- A consolidation run performs and verifies the backup before prompting the agent. Backup, lock, path-validation, settings-write, or consolidation failures are explicit RPC errors.
219
+ A relative backup path is resolved from the effective runtime CWD, not the historical CWD in a resumed session header. A consolidation run performs and verifies the backup before prompting the agent. Backup, lock, path-validation, settings-write, or consolidation failures are explicit RPC errors.
207
220
 
208
221
  ### State
209
222
 
@@ -302,7 +315,7 @@ Response:
302
315
 
303
316
  #### get_git_branch
304
317
 
305
- Get the current git branch for the session cwd. Returns `null` outside a git repository and `"detached"` for detached HEAD.
318
+ Get the current git branch for the effective runtime CWD. Returns `null` outside a git repository and `"detached"` for detached HEAD.
306
319
 
307
320
  ```json
308
321
  {"type": "get_git_branch"}
@@ -1054,7 +1067,7 @@ The extension SDK's `dreb.getCommands()` contract is unchanged: it continues to
1054
1067
 
1055
1068
  #### list_sessions
1056
1069
 
1057
- List sessions for the current working directory. Returns sessions sorted by most recently modified first.
1070
+ List sessions associated with the current persisted session store and its historical working-directory provenance. Returns sessions sorted by most recently modified first. This is a transcript listing operation; switching one of these sessions does not change the RPC process's effective runtime CWD.
1058
1071
 
1059
1072
  ```json
1060
1073
  {"type": "list_sessions"}
@@ -1178,7 +1191,7 @@ The response data is `{ "steeringMode": "one-at-a-time" | "all", "pending": RpcP
1178
1191
 
1179
1192
  #### list_agent_types
1180
1193
 
1181
- List discoverable subagent types for the current session working directory. This includes package-bundled agents, user-level agents, and project-level agents in `.dreb/agents/*.md`. Results are sorted by `name`.
1194
+ List discoverable subagent types for the effective runtime working directory. This includes package-bundled agents, user-level agents, and project-level agents in `.dreb/agents/*.md`. Results are sorted by `name`.
1182
1195
 
1183
1196
  ```json
1184
1197
  {"type": "list_agent_types"}
@@ -1770,7 +1783,7 @@ Response:
1770
1783
  | `tool_execution_update` | Tool execution progress (streaming output) |
1771
1784
  | `tool_execution_end` | Tool completes |
1772
1785
  | `stream_retry` | Stream dropped mid-turn; retrying (partial output discarded) |
1773
- | `length_retry` | Response hit the token limit; retrying with a larger budget |
1786
+ | `length_retry` | Response hit the token limit; retrying at the configured output limit |
1774
1787
  | `auto_compaction_start` | Auto-compaction begins |
1775
1788
  | `auto_compaction_end` | Auto-compaction completes |
1776
1789
  | `context_window_upgrade` | Wire model tier auto-upgraded (e.g. Kimi K3 256k → 1M); includes `provider`, `modelId`, `fromContextWindow`, `toContextWindow` |
package/docs/session.md CHANGED
@@ -386,7 +386,7 @@ Key methods for working with sessions programmatically.
386
386
  - `SessionManager.listAll(onProgress?)` - List all sessions across all projects
387
387
 
388
388
  ### Instance Methods - Session Management
389
- - `newSession(options?)` - Start a new session (options: `{ parentSession?: string }`)
389
+ - `newSession(options?)` - Start a new session (options: `{ parentSession?: string, cwd?: string }`)
390
390
  - `setSessionFile(path)` - Switch to a different session file
391
391
  - `createBranchedSession(leafId)` - Extract a branch to a new session file while preserving the current session name metadata
392
392
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreb/coding-agent",
3
- "version": "2.66.0",
3
+ "version": "2.66.2",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "drebConfig": {