@draht/coding-agent 2026.4.5 → 2026.4.23

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 (222) hide show
  1. package/CHANGELOG.md +790 -625
  2. package/README.md +105 -96
  3. package/dist/cli/args.d.ts +7 -10
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +42 -44
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +1 -0
  9. package/dist/cli.js.map +1 -1
  10. package/dist/config.d.ts +9 -0
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js +18 -0
  13. package/dist/config.js.map +1 -1
  14. package/dist/core/agent-session-runtime.d.ts +53 -106
  15. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  16. package/dist/core/agent-session-runtime.js +116 -147
  17. package/dist/core/agent-session-runtime.js.map +1 -1
  18. package/dist/core/agent-session-services.d.ts +86 -0
  19. package/dist/core/agent-session-services.d.ts.map +1 -0
  20. package/dist/core/agent-session-services.js +116 -0
  21. package/dist/core/agent-session-services.js.map +1 -0
  22. package/dist/core/agent-session.d.ts +4 -12
  23. package/dist/core/agent-session.d.ts.map +1 -1
  24. package/dist/core/agent-session.js +122 -43
  25. package/dist/core/agent-session.js.map +1 -1
  26. package/dist/core/bash-executor.d.ts.map +1 -1
  27. package/dist/core/bash-executor.js +19 -7
  28. package/dist/core/bash-executor.js.map +1 -1
  29. package/dist/core/compaction/compaction.d.ts +1 -1
  30. package/dist/core/compaction/compaction.d.ts.map +1 -1
  31. package/dist/core/compaction/compaction.js +18 -17
  32. package/dist/core/compaction/compaction.js.map +1 -1
  33. package/dist/core/extensions/index.d.ts +1 -1
  34. package/dist/core/extensions/index.d.ts.map +1 -1
  35. package/dist/core/extensions/index.js.map +1 -1
  36. package/dist/core/extensions/loader.d.ts.map +1 -1
  37. package/dist/core/extensions/loader.js +7 -7
  38. package/dist/core/extensions/loader.js.map +1 -1
  39. package/dist/core/extensions/runner.d.ts +1 -0
  40. package/dist/core/extensions/runner.d.ts.map +1 -1
  41. package/dist/core/extensions/runner.js +4 -0
  42. package/dist/core/extensions/runner.js.map +1 -1
  43. package/dist/core/extensions/types.d.ts +15 -14
  44. package/dist/core/extensions/types.d.ts.map +1 -1
  45. package/dist/core/extensions/types.js.map +1 -1
  46. package/dist/core/index.d.ts +2 -1
  47. package/dist/core/index.d.ts.map +1 -1
  48. package/dist/core/index.js +2 -1
  49. package/dist/core/index.js.map +1 -1
  50. package/dist/core/keybindings.d.ts +14 -1
  51. package/dist/core/keybindings.d.ts.map +1 -1
  52. package/dist/core/keybindings.js +13 -14
  53. package/dist/core/keybindings.js.map +1 -1
  54. package/dist/core/model-registry.d.ts.map +1 -1
  55. package/dist/core/model-registry.js +30 -1
  56. package/dist/core/model-registry.js.map +1 -1
  57. package/dist/core/package-manager.d.ts +21 -1
  58. package/dist/core/package-manager.d.ts.map +1 -1
  59. package/dist/core/package-manager.js +108 -43
  60. package/dist/core/package-manager.js.map +1 -1
  61. package/dist/core/prompt-templates.d.ts.map +1 -1
  62. package/dist/core/prompt-templates.js +1 -22
  63. package/dist/core/prompt-templates.js.map +1 -1
  64. package/dist/core/resource-loader.d.ts +0 -2
  65. package/dist/core/resource-loader.d.ts.map +1 -1
  66. package/dist/core/resource-loader.js +26 -8
  67. package/dist/core/resource-loader.js.map +1 -1
  68. package/dist/core/sdk.d.ts +2 -2
  69. package/dist/core/sdk.d.ts.map +1 -1
  70. package/dist/core/sdk.js +2 -2
  71. package/dist/core/sdk.js.map +1 -1
  72. package/dist/core/session-cwd.d.ts +19 -0
  73. package/dist/core/session-cwd.d.ts.map +1 -0
  74. package/dist/core/session-cwd.js +38 -0
  75. package/dist/core/session-cwd.js.map +1 -0
  76. package/dist/core/session-manager.d.ts +5 -1
  77. package/dist/core/session-manager.d.ts.map +1 -1
  78. package/dist/core/session-manager.js +16 -8
  79. package/dist/core/session-manager.js.map +1 -1
  80. package/dist/core/settings-manager.d.ts +3 -1
  81. package/dist/core/settings-manager.d.ts.map +1 -1
  82. package/dist/core/settings-manager.js +5 -1
  83. package/dist/core/settings-manager.js.map +1 -1
  84. package/dist/core/skills.d.ts +1 -1
  85. package/dist/core/skills.d.ts.map +1 -1
  86. package/dist/core/skills.js +3 -3
  87. package/dist/core/skills.js.map +1 -1
  88. package/dist/core/system-prompt.d.ts.map +1 -1
  89. package/dist/core/system-prompt.js +6 -6
  90. package/dist/core/system-prompt.js.map +1 -1
  91. package/dist/core/timings.d.ts +1 -0
  92. package/dist/core/timings.d.ts.map +1 -1
  93. package/dist/core/timings.js +6 -0
  94. package/dist/core/timings.js.map +1 -1
  95. package/dist/core/tools/bash.d.ts.map +1 -1
  96. package/dist/core/tools/bash.js +19 -9
  97. package/dist/core/tools/bash.js.map +1 -1
  98. package/dist/core/tools/edit-diff.d.ts +23 -1
  99. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  100. package/dist/core/tools/edit-diff.js +150 -57
  101. package/dist/core/tools/edit-diff.js.map +1 -1
  102. package/dist/core/tools/edit.d.ts +13 -11
  103. package/dist/core/tools/edit.d.ts.map +1 -1
  104. package/dist/core/tools/edit.js +55 -77
  105. package/dist/core/tools/edit.js.map +1 -1
  106. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  107. package/dist/core/tools/file-mutation-queue.js +4 -4
  108. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  109. package/dist/core/tools/index.d.ts +9 -6
  110. package/dist/core/tools/index.d.ts.map +1 -1
  111. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  112. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  113. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  114. package/dist/index.d.ts +2 -4
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +3 -5
  117. package/dist/index.js.map +1 -1
  118. package/dist/main.d.ts.map +1 -1
  119. package/dist/main.js +248 -450
  120. package/dist/main.js.map +1 -1
  121. package/dist/migrations.d.ts +3 -3
  122. package/dist/migrations.d.ts.map +1 -1
  123. package/dist/migrations.js +25 -5
  124. package/dist/migrations.js.map +1 -1
  125. package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
  126. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/assistant-message.js +14 -3
  128. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  129. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  130. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  131. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  132. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  133. package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
  134. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  135. package/dist/modes/interactive/components/tool-execution.js +2 -7
  136. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  137. package/dist/modes/interactive/components/tree-selector.d.ts +4 -2
  138. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  139. package/dist/modes/interactive/components/tree-selector.js +48 -15
  140. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  141. package/dist/modes/interactive/interactive-mode.d.ts +12 -3
  142. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  143. package/dist/modes/interactive/interactive-mode.js +220 -124
  144. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  145. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  146. package/dist/modes/interactive/theme/theme.js +9 -0
  147. package/dist/modes/interactive/theme/theme.js.map +1 -1
  148. package/dist/modes/print-mode.d.ts +4 -4
  149. package/dist/modes/print-mode.d.ts.map +1 -1
  150. package/dist/modes/print-mode.js +6 -2
  151. package/dist/modes/print-mode.js.map +1 -1
  152. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  153. package/dist/modes/rpc/rpc-client.js +1 -0
  154. package/dist/modes/rpc/rpc-client.js.map +1 -1
  155. package/dist/modes/rpc/rpc-mode.d.ts +2 -2
  156. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  157. package/dist/modes/rpc/rpc-mode.js +26 -15
  158. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  159. package/dist/package-manager-cli.d.ts +4 -0
  160. package/dist/package-manager-cli.d.ts.map +1 -0
  161. package/dist/package-manager-cli.js +234 -0
  162. package/dist/package-manager-cli.js.map +1 -0
  163. package/dist/prompts/commands/atomic-commit.md +17 -0
  164. package/dist/prompts/commands/discuss-phase.md +15 -0
  165. package/dist/prompts/commands/execute-phase.md +14 -0
  166. package/dist/prompts/commands/fix.md +14 -0
  167. package/dist/prompts/commands/init-project.md +16 -0
  168. package/dist/prompts/commands/map-codebase.md +16 -0
  169. package/dist/prompts/commands/new-project.md +16 -0
  170. package/dist/prompts/commands/next-milestone.md +16 -0
  171. package/dist/prompts/commands/pause-work.md +13 -0
  172. package/dist/prompts/commands/plan-phase.md +15 -0
  173. package/dist/prompts/commands/progress.md +13 -0
  174. package/dist/prompts/commands/quick.md +14 -0
  175. package/dist/prompts/commands/resume-work.md +13 -0
  176. package/dist/prompts/commands/review.md +15 -0
  177. package/dist/prompts/commands/verify-work.md +15 -0
  178. package/dist/utils/paths.d.ts +7 -0
  179. package/dist/utils/paths.d.ts.map +1 -0
  180. package/dist/utils/paths.js +19 -0
  181. package/dist/utils/paths.js.map +1 -0
  182. package/docs/compaction.md +5 -3
  183. package/docs/custom-provider.md +1 -1
  184. package/docs/development.md +3 -1
  185. package/docs/extensions.md +150 -54
  186. package/docs/json.md +5 -2
  187. package/docs/keybindings.md +2 -0
  188. package/docs/models.md +55 -4
  189. package/docs/rpc.md +21 -7
  190. package/docs/sdk.md +116 -48
  191. package/docs/session.md +3 -3
  192. package/docs/settings.md +12 -0
  193. package/docs/skills.md +3 -2
  194. package/docs/tree.md +5 -2
  195. package/examples/README.md +1 -1
  196. package/examples/extensions/README.md +1 -0
  197. package/examples/extensions/antigravity-image-gen.ts +1 -1
  198. package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
  199. package/examples/extensions/doom-overlay/doom/build.sh +2 -2
  200. package/examples/extensions/hidden-thinking-label.ts +53 -0
  201. package/examples/extensions/overlay-qa-tests.ts +2 -2
  202. package/examples/extensions/sandbox/index.ts +8 -4
  203. package/examples/extensions/subagent/index.ts +5 -5
  204. package/examples/extensions/trigger-compact.ts +11 -1
  205. package/examples/sdk/13-session-runtime.ts +30 -12
  206. package/examples/sdk/README.md +4 -2
  207. package/package.json +7 -8
  208. package/prompts/commands/atomic-commit.md +17 -0
  209. package/prompts/commands/discuss-phase.md +15 -0
  210. package/prompts/commands/execute-phase.md +14 -0
  211. package/prompts/commands/fix.md +14 -0
  212. package/prompts/commands/init-project.md +16 -0
  213. package/prompts/commands/map-codebase.md +16 -0
  214. package/prompts/commands/new-project.md +16 -0
  215. package/prompts/commands/next-milestone.md +16 -0
  216. package/prompts/commands/pause-work.md +13 -0
  217. package/prompts/commands/plan-phase.md +15 -0
  218. package/prompts/commands/progress.md +13 -0
  219. package/prompts/commands/quick.md +14 -0
  220. package/prompts/commands/resume-work.md +13 -0
  221. package/prompts/commands/review.md +15 -0
  222. package/prompts/commands/verify-work.md +15 -0
@@ -15,6 +15,7 @@ import { KeybindingsManager } from "../../core/keybindings.js";
15
15
  import { createCompactionSummaryMessage } from "../../core/messages.js";
16
16
  import { findExactModelReferenceMatch, resolveModelScope } from "../../core/model-resolver.js";
17
17
  import { DefaultPackageManager } from "../../core/package-manager.js";
18
+ import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
18
19
  import { SessionManager } from "../../core/session-manager.js";
19
20
  import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
20
21
  import { getChangelogPath, getNewEntries, parseChangelog } from "../../utils/changelog.js";
@@ -32,6 +33,7 @@ import { CustomEditor } from "./components/custom-editor.js";
32
33
  import { CustomMessageComponent } from "./components/custom-message.js";
33
34
  import { DaxnutsComponent } from "./components/daxnuts.js";
34
35
  import { DynamicBorder } from "./components/dynamic-border.js";
36
+ import { EarendilAnnouncementComponent } from "./components/earendil-announcement.js";
35
37
  import { ExtensionEditorComponent } from "./components/extension-editor.js";
36
38
  import { ExtensionInputComponent } from "./components/extension-input.js";
37
39
  import { ExtensionSelectorComponent } from "./components/extension-selector.js";
@@ -48,10 +50,14 @@ import { ToolExecutionComponent } from "./components/tool-execution.js";
48
50
  import { TreeSelectorComponent } from "./components/tree-selector.js";
49
51
  import { UserMessageComponent } from "./components/user-message.js";
50
52
  import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
51
- import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, initTheme, onThemeChange, setRegisteredThemes, setTheme, setThemeInstance, Theme, theme, } from "./theme/theme.js";
53
+ import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, initTheme, onThemeChange, setRegisteredThemes, setTheme, setThemeInstance, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
52
54
  function isExpandable(obj) {
53
55
  return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
54
56
  }
57
+ const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING = "Anthropic subscription auth is active. Third-party usage now draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.";
58
+ function isAnthropicSubscriptionAuthKey(apiKey) {
59
+ return typeof apiKey === "string" && apiKey.startsWith("sk-ant-oat");
60
+ }
55
61
  export class InteractiveMode {
56
62
  options;
57
63
  runtimeHost;
@@ -74,9 +80,13 @@ export class InteractiveMode {
74
80
  loadingAnimation = undefined;
75
81
  pendingWorkingMessage = undefined;
76
82
  defaultWorkingMessage = "Working...";
83
+ defaultHiddenThinkingLabel = "Thinking...";
84
+ hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
77
85
  lastSigintTime = 0;
78
86
  lastEscapeTime = 0;
79
87
  changelogMarkdown = undefined;
88
+ startupNoticesShown = false;
89
+ anthropicSubscriptionWarningShown = false;
80
90
  // Status line tracking (for mutating immediately-sequential status updates)
81
91
  lastStatusSpacer = undefined;
82
92
  lastStatusText = undefined;
@@ -278,6 +288,32 @@ export class InteractiveMode {
278
288
  this.editor.setAutocompleteProvider?.(this.autocompleteProvider);
279
289
  }
280
290
  }
291
+ showStartupNoticesIfNeeded() {
292
+ if (this.startupNoticesShown) {
293
+ return;
294
+ }
295
+ this.startupNoticesShown = true;
296
+ if (!this.changelogMarkdown) {
297
+ return;
298
+ }
299
+ if (this.chatContainer.children.length > 0) {
300
+ this.chatContainer.addChild(new Spacer(1));
301
+ }
302
+ this.chatContainer.addChild(new DynamicBorder());
303
+ if (this.settingsManager.getCollapseChangelog()) {
304
+ const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
305
+ const latestVersion = versionMatch ? versionMatch[1] : this.version;
306
+ const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
307
+ this.chatContainer.addChild(new Text(condensedText, 1, 0));
308
+ }
309
+ else {
310
+ this.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
311
+ this.chatContainer.addChild(new Spacer(1));
312
+ this.chatContainer.addChild(new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()));
313
+ this.chatContainer.addChild(new Spacer(1));
314
+ }
315
+ this.chatContainer.addChild(new DynamicBorder());
316
+ }
281
317
  async init() {
282
318
  if (this.isInitialized)
283
319
  return;
@@ -315,41 +351,17 @@ export class InteractiveMode {
315
351
  hint("app.clipboard.pasteImage", "to paste image"),
316
352
  rawKeyHint("drop files", "to attach"),
317
353
  ].join("\n");
318
- this.builtInHeader = new Text(`${logo}\n${instructions}`, 1, 0);
354
+ const onboarding = theme.fg("dim", `Draht can explain its own features and look up its docs. Ask it how to use or extend draht.`);
355
+ this.builtInHeader = new Text(`${logo}\n${instructions}\n\n${onboarding}`, 1, 0);
319
356
  // Setup UI layout
320
357
  this.headerContainer.addChild(new Spacer(1));
321
358
  this.headerContainer.addChild(this.builtInHeader);
322
359
  this.headerContainer.addChild(new Spacer(1));
323
- // Add changelog if provided
324
- if (this.changelogMarkdown) {
325
- this.headerContainer.addChild(new DynamicBorder());
326
- if (this.settingsManager.getCollapseChangelog()) {
327
- const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
328
- const latestVersion = versionMatch ? versionMatch[1] : this.version;
329
- const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
330
- this.headerContainer.addChild(new Text(condensedText, 1, 0));
331
- }
332
- else {
333
- this.headerContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
334
- this.headerContainer.addChild(new Spacer(1));
335
- this.headerContainer.addChild(new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()));
336
- this.headerContainer.addChild(new Spacer(1));
337
- }
338
- this.headerContainer.addChild(new DynamicBorder());
339
- }
340
360
  }
341
361
  else {
342
362
  // Minimal header when silenced
343
363
  this.builtInHeader = new Text("", 0, 0);
344
364
  this.headerContainer.addChild(this.builtInHeader);
345
- if (this.changelogMarkdown) {
346
- // Still show changelog notification even in silent mode
347
- this.headerContainer.addChild(new Spacer(1));
348
- const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
349
- const latestVersion = versionMatch ? versionMatch[1] : this.version;
350
- const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
351
- this.headerContainer.addChild(new Text(condensedText, 1, 0));
352
- }
353
365
  }
354
366
  this.ui.addChild(this.chatContainer);
355
367
  this.ui.addChild(this.pendingMessagesContainer);
@@ -393,10 +405,10 @@ export class InteractiveMode {
393
405
  const cwdBasename = path.basename(this.sessionManager.getCwd());
394
406
  const sessionName = this.sessionManager.getSessionName();
395
407
  if (sessionName) {
396
- this.ui.terminal.setTitle(`D - ${sessionName} - ${cwdBasename}`);
408
+ this.ui.terminal.setTitle(`π - ${sessionName} - ${cwdBasename}`);
397
409
  }
398
410
  else {
399
- this.ui.terminal.setTitle(`D - ${cwdBasename}`);
411
+ this.ui.terminal.setTitle(`π - ${cwdBasename}`);
400
412
  }
401
413
  }
402
414
  /**
@@ -435,6 +447,7 @@ export class InteractiveMode {
435
447
  if (modelFallbackMessage) {
436
448
  this.showWarning(modelFallbackMessage);
437
449
  }
450
+ void this.maybeWarnAboutAnthropicSubscriptionAuth();
438
451
  // Process initial messages
439
452
  if (initialMessage) {
440
453
  try {
@@ -897,23 +910,33 @@ export class InteractiveMode {
897
910
  this.loadingAnimation = undefined;
898
911
  }
899
912
  this.statusContainer.clear();
900
- const result = await this.runtimeHost.newSession(options);
901
- if (!result.cancelled) {
902
- await this.handleRuntimeSessionChange();
903
- this.renderCurrentSessionState();
904
- this.ui.requestRender();
913
+ try {
914
+ const result = await this.runtimeHost.newSession(options);
915
+ if (!result.cancelled) {
916
+ await this.handleRuntimeSessionChange();
917
+ this.renderCurrentSessionState();
918
+ this.ui.requestRender();
919
+ }
920
+ return result;
921
+ }
922
+ catch (error) {
923
+ return this.handleFatalRuntimeError("Failed to create session", error);
905
924
  }
906
- return result;
907
925
  },
908
926
  fork: async (entryId) => {
909
- const result = await this.runtimeHost.fork(entryId);
910
- if (!result.cancelled) {
911
- await this.handleRuntimeSessionChange();
912
- this.renderCurrentSessionState();
913
- this.editor.setText(result.selectedText ?? "");
914
- this.showStatus("Forked to new session");
927
+ try {
928
+ const result = await this.runtimeHost.fork(entryId);
929
+ if (!result.cancelled) {
930
+ await this.handleRuntimeSessionChange();
931
+ this.renderCurrentSessionState();
932
+ this.editor.setText(result.selectedText ?? "");
933
+ this.showStatus("Forked to new session");
934
+ }
935
+ return { cancelled: result.cancelled };
936
+ }
937
+ catch (error) {
938
+ return this.handleFatalRuntimeError("Failed to fork session", error);
915
939
  }
916
- return { cancelled: result.cancelled };
917
940
  },
918
941
  navigateTree: async (targetId, options) => {
919
942
  const result = await this.session.navigateTree(targetId, {
@@ -956,10 +979,12 @@ export class InteractiveMode {
956
979
  const extensionRunner = this.session.extensionRunner;
957
980
  if (!extensionRunner) {
958
981
  this.showLoadedResources({ extensions: [], force: false });
982
+ this.showStartupNoticesIfNeeded();
959
983
  return;
960
984
  }
961
985
  this.setupExtensionShortcuts(extensionRunner);
962
986
  this.showLoadedResources({ force: false });
987
+ this.showStartupNoticesIfNeeded();
963
988
  }
964
989
  applyRuntimeSettings() {
965
990
  this.footer.setSession(this.session);
@@ -988,6 +1013,13 @@ export class InteractiveMode {
988
1013
  this.updateEditorBorderColor();
989
1014
  this.updateTerminalTitle();
990
1015
  }
1016
+ async handleFatalRuntimeError(prefix, error) {
1017
+ const message = error instanceof Error ? error.message : String(error);
1018
+ this.showError(`${prefix}: ${message}`);
1019
+ stopThemeWatcher();
1020
+ this.stop();
1021
+ process.exit(1);
1022
+ }
991
1023
  renderCurrentSessionState() {
992
1024
  this.chatContainer.clear();
993
1025
  this.pendingMessagesContainer.clear();
@@ -1019,6 +1051,7 @@ export class InteractiveMode {
1019
1051
  modelRegistry: this.session.modelRegistry,
1020
1052
  model: this.session.model,
1021
1053
  isIdle: () => !this.session.isStreaming,
1054
+ signal: this.session.agent.signal,
1022
1055
  abort: () => this.session.abort(),
1023
1056
  hasPendingMessages: () => this.session.pendingMessageCount > 0,
1024
1057
  shutdown: () => {
@@ -1028,10 +1061,8 @@ export class InteractiveMode {
1028
1061
  compact: (options) => {
1029
1062
  void (async () => {
1030
1063
  try {
1031
- const result = await this.executeCompaction(options?.customInstructions, false);
1032
- if (result) {
1033
- options?.onComplete?.(result);
1034
- }
1064
+ const result = await this.session.compact(options?.customInstructions);
1065
+ options?.onComplete?.(result);
1035
1066
  }
1036
1067
  catch (error) {
1037
1068
  const err = error instanceof Error ? error : new Error(String(error));
@@ -1063,6 +1094,18 @@ export class InteractiveMode {
1063
1094
  this.footerDataProvider.setExtensionStatus(key, text);
1064
1095
  this.ui.requestRender();
1065
1096
  }
1097
+ setHiddenThinkingLabel(label) {
1098
+ this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;
1099
+ for (const child of this.chatContainer.children) {
1100
+ if (child instanceof AssistantMessageComponent) {
1101
+ child.setHiddenThinkingLabel(this.hiddenThinkingLabel);
1102
+ }
1103
+ }
1104
+ if (this.streamingComponent) {
1105
+ this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);
1106
+ }
1107
+ this.ui.requestRender();
1108
+ }
1066
1109
  /**
1067
1110
  * Set an extension widget (string array or custom component).
1068
1111
  */
@@ -1134,6 +1177,7 @@ export class InteractiveMode {
1134
1177
  if (this.loadingAnimation) {
1135
1178
  this.loadingAnimation.setMessage(`${this.defaultWorkingMessage} (${keyText("app.interrupt")} to interrupt)`);
1136
1179
  }
1180
+ this.setHiddenThinkingLabel();
1137
1181
  }
1138
1182
  // Maximum total widget lines to prevent viewport overflow
1139
1183
  static MAX_WIDGET_LINES = 10;
@@ -1263,6 +1307,7 @@ export class InteractiveMode {
1263
1307
  this.pendingWorkingMessage = message;
1264
1308
  }
1265
1309
  },
1310
+ setHiddenThinkingLabel: (label) => this.setHiddenThinkingLabel(label),
1266
1311
  setWidget: (key, content, options) => this.setExtensionWidget(key, content, options),
1267
1312
  setFooter: (factory) => this.setExtensionFooter(factory),
1268
1313
  setHeader: (factory) => this.setExtensionHeader(factory),
@@ -1344,6 +1389,10 @@ export class InteractiveMode {
1344
1389
  const result = await this.showExtensionSelector(`${title}\n${message}`, ["Yes", "No"], opts);
1345
1390
  return result === "Yes";
1346
1391
  }
1392
+ async promptForMissingSessionCwd(error) {
1393
+ const confirmed = await this.showExtensionConfirm("Session cwd not found", formatMissingSessionCwdPrompt(error.issue));
1394
+ return confirmed ? error.issue.fallbackCwd : undefined;
1395
+ }
1347
1396
  /**
1348
1397
  * Show a text input for extensions.
1349
1398
  */
@@ -1771,6 +1820,11 @@ export class InteractiveMode {
1771
1820
  this.editor.setText("");
1772
1821
  return;
1773
1822
  }
1823
+ if (text === "/dementedelves") {
1824
+ this.handleDementedDelves();
1825
+ this.editor.setText("");
1826
+ return;
1827
+ }
1774
1828
  if (text === "/resume") {
1775
1829
  this.showSessionSelector();
1776
1830
  this.editor.setText("");
@@ -1866,6 +1920,10 @@ export class InteractiveMode {
1866
1920
  }
1867
1921
  this.ui.requestRender();
1868
1922
  break;
1923
+ case "queue_update":
1924
+ this.updatePendingMessagesDisplay();
1925
+ this.ui.requestRender();
1926
+ break;
1869
1927
  case "message_start":
1870
1928
  if (event.message.role === "custom") {
1871
1929
  this.addMessageToChat(event.message);
@@ -1877,7 +1935,7 @@ export class InteractiveMode {
1877
1935
  this.ui.requestRender();
1878
1936
  }
1879
1937
  else if (event.message.role === "assistant") {
1880
- this.streamingComponent = new AssistantMessageComponent(undefined, this.hideThinkingBlock, this.getMarkdownThemeWithSettings());
1938
+ this.streamingComponent = new AssistantMessageComponent(undefined, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel);
1881
1939
  this.streamingMessage = event.message;
1882
1940
  this.chatContainer.addChild(this.streamingComponent);
1883
1941
  this.streamingComponent.updateContent(this.streamingMessage);
@@ -1994,54 +2052,54 @@ export class InteractiveMode {
1994
2052
  await this.checkShutdownRequested();
1995
2053
  this.ui.requestRender();
1996
2054
  break;
1997
- case "auto_compaction_start": {
2055
+ case "compaction_start": {
1998
2056
  // Keep editor active; submissions are queued during compaction.
1999
- // Set up escape to abort auto-compaction
2000
2057
  this.autoCompactionEscapeHandler = this.defaultEditor.onEscape;
2001
2058
  this.defaultEditor.onEscape = () => {
2002
2059
  this.session.abortCompaction();
2003
2060
  };
2004
- // Show compacting indicator with reason
2005
2061
  this.statusContainer.clear();
2006
- const reasonText = event.reason === "overflow" ? "Context overflow detected, " : "";
2007
- this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), `${reasonText}Auto-compacting... (${keyText("app.interrupt")} to cancel)`);
2062
+ const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
2063
+ const label = event.reason === "manual"
2064
+ ? `Compacting context... ${cancelHint}`
2065
+ : `${event.reason === "overflow" ? "Context overflow detected, " : ""}Auto-compacting... ${cancelHint}`;
2066
+ this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
2008
2067
  this.statusContainer.addChild(this.autoCompactionLoader);
2009
2068
  this.ui.requestRender();
2010
2069
  break;
2011
2070
  }
2012
- case "auto_compaction_end": {
2013
- // Restore escape handler
2071
+ case "compaction_end": {
2014
2072
  if (this.autoCompactionEscapeHandler) {
2015
2073
  this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
2016
2074
  this.autoCompactionEscapeHandler = undefined;
2017
2075
  }
2018
- // Stop loader
2019
2076
  if (this.autoCompactionLoader) {
2020
2077
  this.autoCompactionLoader.stop();
2021
2078
  this.autoCompactionLoader = undefined;
2022
2079
  this.statusContainer.clear();
2023
2080
  }
2024
- // Handle result
2025
2081
  if (event.aborted) {
2026
- this.showStatus("Auto-compaction cancelled");
2082
+ if (event.reason === "manual") {
2083
+ this.showError("Compaction cancelled");
2084
+ }
2085
+ else {
2086
+ this.showStatus("Auto-compaction cancelled");
2087
+ }
2027
2088
  }
2028
2089
  else if (event.result) {
2029
- // Rebuild chat to show compacted state
2030
2090
  this.chatContainer.clear();
2031
2091
  this.rebuildChatFromMessages();
2032
- // Add compaction component at bottom so user sees it without scrolling
2033
- this.addMessageToChat({
2034
- role: "compactionSummary",
2035
- tokensBefore: event.result.tokensBefore,
2036
- summary: event.result.summary,
2037
- timestamp: Date.now(),
2038
- });
2092
+ this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
2039
2093
  this.footer.invalidate();
2040
2094
  }
2041
2095
  else if (event.errorMessage) {
2042
- // Compaction failed (e.g., quota exceeded, API error)
2043
- this.chatContainer.addChild(new Spacer(1));
2044
- this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
2096
+ if (event.reason === "manual") {
2097
+ this.showError(event.errorMessage);
2098
+ }
2099
+ else {
2100
+ this.chatContainer.addChild(new Spacer(1));
2101
+ this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
2102
+ }
2045
2103
  }
2046
2104
  void this.flushCompactionQueue({ willRetry: event.willRetry });
2047
2105
  this.ui.requestRender();
@@ -2175,7 +2233,7 @@ export class InteractiveMode {
2175
2233
  break;
2176
2234
  }
2177
2235
  case "assistant": {
2178
- const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings());
2236
+ const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel);
2179
2237
  this.chatContainer.addChild(assistantComponent);
2180
2238
  break;
2181
2239
  }
@@ -2418,6 +2476,7 @@ export class InteractiveMode {
2418
2476
  this.updateEditorBorderColor();
2419
2477
  const thinkingStr = result.model.reasoning && result.thinkingLevel !== "off" ? ` (thinking: ${result.thinkingLevel})` : "";
2420
2478
  this.showStatus(`Switched to ${result.model.name || result.model.id}${thinkingStr}`);
2479
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);
2421
2480
  }
2422
2481
  }
2423
2482
  catch (error) {
@@ -2770,7 +2829,7 @@ export class InteractiveMode {
2770
2829
  },
2771
2830
  onTransportChange: (transport) => {
2772
2831
  this.settingsManager.setTransport(transport);
2773
- this.session.agent.setTransport(transport);
2832
+ this.session.agent.transport = transport;
2774
2833
  },
2775
2834
  onThinkingLevelChange: (level) => {
2776
2835
  this.session.setThinkingLevel(level);
@@ -2857,6 +2916,7 @@ export class InteractiveMode {
2857
2916
  this.footer.invalidate();
2858
2917
  this.updateEditorBorderColor();
2859
2918
  this.showStatus(`Model: ${model.id}`);
2919
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
2860
2920
  this.checkDaxnutsEasterEgg(model);
2861
2921
  }
2862
2922
  catch (error) {
@@ -2888,6 +2948,31 @@ export class InteractiveMode {
2888
2948
  const uniqueProviders = new Set(models.map((m) => m.provider));
2889
2949
  this.footerDataProvider.setAvailableProviderCount(uniqueProviders.size);
2890
2950
  }
2951
+ async maybeWarnAboutAnthropicSubscriptionAuth(model = this.session.model) {
2952
+ if (this.anthropicSubscriptionWarningShown) {
2953
+ return;
2954
+ }
2955
+ if (!model || model.provider !== "anthropic") {
2956
+ return;
2957
+ }
2958
+ const storedCredential = this.session.modelRegistry.authStorage.get("anthropic");
2959
+ if (storedCredential?.type === "oauth") {
2960
+ this.anthropicSubscriptionWarningShown = true;
2961
+ this.showWarning(ANTHROPIC_SUBSCRIPTION_AUTH_WARNING);
2962
+ return;
2963
+ }
2964
+ try {
2965
+ const apiKey = await this.session.modelRegistry.getApiKeyForProvider(model.provider);
2966
+ if (!isAnthropicSubscriptionAuthKey(apiKey)) {
2967
+ return;
2968
+ }
2969
+ this.anthropicSubscriptionWarningShown = true;
2970
+ this.showWarning(ANTHROPIC_SUBSCRIPTION_AUTH_WARNING);
2971
+ }
2972
+ catch {
2973
+ // Ignore auth lookup failures for warning-only checks.
2974
+ }
2975
+ }
2891
2976
  showModelSelector(initialSearchInput) {
2892
2977
  this.showSelector((done) => {
2893
2978
  const selector = new ModelSelectorComponent(this.ui, this.session.model, this.settingsManager, this.session.modelRegistry, this.session.scopedModels, async (model) => {
@@ -2897,6 +2982,7 @@ export class InteractiveMode {
2897
2982
  this.updateEditorBorderColor();
2898
2983
  done();
2899
2984
  this.showStatus(`Model: ${model.id}`);
2985
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
2900
2986
  this.checkDaxnutsEasterEgg(model);
2901
2987
  }
2902
2988
  catch (error) {
@@ -3175,13 +3261,33 @@ export class InteractiveMode {
3175
3261
  this.loadingAnimation = undefined;
3176
3262
  }
3177
3263
  this.statusContainer.clear();
3178
- const result = await this.runtimeHost.switchSession(sessionPath);
3179
- if (result.cancelled) {
3180
- return;
3264
+ try {
3265
+ const result = await this.runtimeHost.switchSession(sessionPath);
3266
+ if (result.cancelled) {
3267
+ return;
3268
+ }
3269
+ await this.handleRuntimeSessionChange();
3270
+ this.renderCurrentSessionState();
3271
+ this.showStatus("Resumed session");
3272
+ }
3273
+ catch (error) {
3274
+ if (error instanceof MissingSessionCwdError) {
3275
+ const selectedCwd = await this.promptForMissingSessionCwd(error);
3276
+ if (!selectedCwd) {
3277
+ this.showStatus("Resume cancelled");
3278
+ return;
3279
+ }
3280
+ const result = await this.runtimeHost.switchSession(sessionPath, selectedCwd);
3281
+ if (result.cancelled) {
3282
+ return;
3283
+ }
3284
+ await this.handleRuntimeSessionChange();
3285
+ this.renderCurrentSessionState();
3286
+ this.showStatus("Resumed session in current cwd");
3287
+ return;
3288
+ }
3289
+ await this.handleFatalRuntimeError("Failed to resume session", error);
3181
3290
  }
3182
- await this.handleRuntimeSessionChange();
3183
- this.renderCurrentSessionState();
3184
- this.showStatus("Resumed session");
3185
3291
  }
3186
3292
  async showOAuthSelector(mode) {
3187
3293
  if (mode === "logout") {
@@ -3414,7 +3520,23 @@ export class InteractiveMode {
3414
3520
  this.showStatus(`Session imported from: ${inputPath}`);
3415
3521
  }
3416
3522
  catch (error) {
3417
- this.showError(`Failed to import session: ${error instanceof Error ? error.message : "Unknown error"}`);
3523
+ if (error instanceof MissingSessionCwdError) {
3524
+ const selectedCwd = await this.promptForMissingSessionCwd(error);
3525
+ if (!selectedCwd) {
3526
+ this.showStatus("Import cancelled");
3527
+ return;
3528
+ }
3529
+ const result = await this.runtimeHost.importFromJsonl(inputPath, selectedCwd);
3530
+ if (result.cancelled) {
3531
+ this.showStatus("Import cancelled");
3532
+ return;
3533
+ }
3534
+ await this.handleRuntimeSessionChange();
3535
+ this.renderCurrentSessionState();
3536
+ this.showStatus(`Session imported from: ${inputPath}`);
3537
+ return;
3538
+ }
3539
+ await this.handleFatalRuntimeError("Failed to import session", error);
3418
3540
  }
3419
3541
  }
3420
3542
  async handleShareCommand() {
@@ -3729,15 +3851,20 @@ export class InteractiveMode {
3729
3851
  this.loadingAnimation = undefined;
3730
3852
  }
3731
3853
  this.statusContainer.clear();
3732
- const result = await this.runtimeHost.newSession();
3733
- if (result.cancelled) {
3734
- return;
3854
+ try {
3855
+ const result = await this.runtimeHost.newSession();
3856
+ if (result.cancelled) {
3857
+ return;
3858
+ }
3859
+ await this.handleRuntimeSessionChange();
3860
+ this.renderCurrentSessionState();
3861
+ this.chatContainer.addChild(new Spacer(1));
3862
+ this.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ New session started")}`, 1, 1));
3863
+ this.ui.requestRender();
3864
+ }
3865
+ catch (error) {
3866
+ await this.handleFatalRuntimeError("Failed to create session", error);
3735
3867
  }
3736
- await this.handleRuntimeSessionChange();
3737
- this.renderCurrentSessionState();
3738
- this.chatContainer.addChild(new Spacer(1));
3739
- this.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ New session started")}`, 1, 1));
3740
- this.ui.requestRender();
3741
3868
  }
3742
3869
  handleDebugCommand() {
3743
3870
  const width = this.ui.terminal.columns;
@@ -3771,6 +3898,11 @@ export class InteractiveMode {
3771
3898
  this.chatContainer.addChild(new ArminComponent(this.ui));
3772
3899
  this.ui.requestRender();
3773
3900
  }
3901
+ handleDementedDelves() {
3902
+ this.chatContainer.addChild(new Spacer(1));
3903
+ this.chatContainer.addChild(new EarendilAnnouncementComponent());
3904
+ this.ui.requestRender();
3905
+ }
3774
3906
  handleDaxnuts() {
3775
3907
  this.chatContainer.addChild(new Spacer(1));
3776
3908
  this.chatContainer.addChild(new DaxnutsComponent(this.ui));
@@ -3855,53 +3987,17 @@ export class InteractiveMode {
3855
3987
  this.showWarning("Nothing to compact (no messages yet)");
3856
3988
  return;
3857
3989
  }
3858
- await this.executeCompaction(customInstructions, false);
3859
- }
3860
- async executeCompaction(customInstructions, isAuto = false) {
3861
- // Stop loading animation
3862
3990
  if (this.loadingAnimation) {
3863
3991
  this.loadingAnimation.stop();
3864
3992
  this.loadingAnimation = undefined;
3865
3993
  }
3866
3994
  this.statusContainer.clear();
3867
- // Set up escape handler during compaction
3868
- const originalOnEscape = this.defaultEditor.onEscape;
3869
- this.defaultEditor.onEscape = () => {
3870
- this.session.abortCompaction();
3871
- };
3872
- // Show compacting status
3873
- this.chatContainer.addChild(new Spacer(1));
3874
- const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
3875
- const label = isAuto ? `Auto-compacting context... ${cancelHint}` : `Compacting context... ${cancelHint}`;
3876
- const compactingLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
3877
- this.statusContainer.addChild(compactingLoader);
3878
- this.ui.requestRender();
3879
- let result;
3880
3995
  try {
3881
- result = await this.session.compact(customInstructions);
3882
- // Rebuild UI
3883
- this.rebuildChatFromMessages();
3884
- // Add compaction component at bottom so user sees it without scrolling
3885
- const msg = createCompactionSummaryMessage(result.summary, result.tokensBefore, new Date().toISOString());
3886
- this.addMessageToChat(msg);
3887
- this.footer.invalidate();
3996
+ await this.session.compact(customInstructions);
3888
3997
  }
3889
- catch (error) {
3890
- const message = error instanceof Error ? error.message : String(error);
3891
- if (message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError")) {
3892
- this.showError("Compaction cancelled");
3893
- }
3894
- else {
3895
- this.showError(`Compaction failed: ${message}`);
3896
- }
3897
- }
3898
- finally {
3899
- compactingLoader.stop();
3900
- this.statusContainer.clear();
3901
- this.defaultEditor.onEscape = originalOnEscape;
3998
+ catch {
3999
+ // Ignore, will be emitted as an event
3902
4000
  }
3903
- void this.flushCompactionQueue({ willRetry: false });
3904
- return result;
3905
4001
  }
3906
4002
  stop() {
3907
4003
  if (this.loadingAnimation) {