@bastani/atomic 0.9.16-alpha.9 → 0.9.16

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 (191) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +4 -4
  3. package/dist/builtin/intercom/CHANGELOG.md +42 -0
  4. package/dist/builtin/intercom/README.md +18 -17
  5. package/dist/builtin/intercom/broker/broker.ts +43 -18
  6. package/dist/builtin/intercom/broker/client.ts +138 -7
  7. package/dist/builtin/intercom/broker/group-isolation.ts +3 -3
  8. package/dist/builtin/intercom/broker/group-membership.ts +55 -0
  9. package/dist/builtin/intercom/broker/presence-handler.ts +62 -50
  10. package/dist/builtin/intercom/broker/send-handler.ts +2 -3
  11. package/dist/builtin/intercom/group.ts +40 -0
  12. package/dist/builtin/intercom/index.bundle.mjs +490 -183
  13. package/dist/builtin/intercom/package.json +2 -2
  14. package/dist/builtin/intercom/skills/intercom/SKILL.md +16 -10
  15. package/dist/builtin/intercom/types.ts +24 -2
  16. package/dist/builtin/mcp/index.bundle.mjs +202 -52
  17. package/dist/builtin/mcp/package.json +2 -2
  18. package/dist/builtin/subagents/CHANGELOG.md +51 -0
  19. package/dist/builtin/subagents/README.md +3 -3
  20. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  21. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  22. package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
  23. package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
  24. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
  25. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
  26. package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
  27. package/dist/builtin/subagents/agents/debugger.md +1 -1
  28. package/dist/builtin/subagents/agents/worker.md +1 -1
  29. package/dist/builtin/subagents/package.json +3 -3
  30. package/dist/builtin/subagents/src/extension/index.bundle.mjs +422 -140
  31. package/dist/builtin/web-access/index.bundle.mjs +202 -52
  32. package/dist/builtin/web-access/package.json +2 -2
  33. package/dist/builtin/workflows/CHANGELOG.md +70 -0
  34. package/dist/builtin/workflows/README.md +2 -2
  35. package/dist/builtin/workflows/builtin/{chunk-h5e65g7g.js → chunk-3y1hmzw6.js} +36 -6
  36. package/dist/builtin/workflows/builtin/{chunk-nqr34qp3.js → chunk-6rbajjf5.js} +7 -1
  37. package/dist/builtin/workflows/builtin/{chunk-qe6bfpbd.js → chunk-bz1c9732.js} +15 -3
  38. package/dist/builtin/workflows/builtin/{chunk-8v8wmb7z.js → chunk-dattsgxg.js} +1 -1
  39. package/dist/builtin/workflows/builtin/{chunk-17zk6ffd.js → chunk-gdx0avpx.js} +355 -67
  40. package/dist/builtin/workflows/builtin/{chunk-rbnj9621.js → chunk-w9c7rkrk.js} +1 -1
  41. package/dist/builtin/workflows/builtin/goal.js +3 -3
  42. package/dist/builtin/workflows/builtin/index.js +5 -5
  43. package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
  44. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  45. package/dist/builtin/workflows/package.json +2 -2
  46. package/dist/builtin/workflows/src/extension/index.bundle.mjs +531 -143
  47. package/dist/builtin/workflows/src/index.js +212 -72
  48. package/dist/cli/args.js +6 -6
  49. package/dist/cli/args.js.map +1 -1
  50. package/dist/cli/config-selector.d.ts.map +1 -1
  51. package/dist/cli/config-selector.js +2 -1
  52. package/dist/cli/config-selector.js.map +1 -1
  53. package/dist/cli/session-picker.d.ts +2 -1
  54. package/dist/cli/session-picker.d.ts.map +1 -1
  55. package/dist/cli/session-picker.js +3 -2
  56. package/dist/cli/session-picker.js.map +1 -1
  57. package/dist/cli/startup-ui.d.ts.map +1 -1
  58. package/dist/cli/startup-ui.js +2 -1
  59. package/dist/cli/startup-ui.js.map +1 -1
  60. package/dist/core/agent-session-methods.d.ts +1 -0
  61. package/dist/core/agent-session-methods.d.ts.map +1 -1
  62. package/dist/core/agent-session-methods.js.map +1 -1
  63. package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
  64. package/dist/core/agent-session-post-tool-compaction.js +3 -6
  65. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  66. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  67. package/dist/core/agent-session-prompt.js +3 -1
  68. package/dist/core/agent-session-prompt.js.map +1 -1
  69. package/dist/core/agent-session-services.d.ts.map +1 -1
  70. package/dist/core/agent-session-services.js +6 -3
  71. package/dist/core/agent-session-services.js.map +1 -1
  72. package/dist/core/agent-session-state.d.ts.map +1 -1
  73. package/dist/core/agent-session-state.js +7 -5
  74. package/dist/core/agent-session-state.js.map +1 -1
  75. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  76. package/dist/core/agent-session-tool-hooks.js +37 -23
  77. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  78. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  79. package/dist/core/agent-session-tool-registry.js +9 -2
  80. package/dist/core/agent-session-tool-registry.js.map +1 -1
  81. package/dist/core/agent-session.d.ts +2 -0
  82. package/dist/core/agent-session.d.ts.map +1 -1
  83. package/dist/core/agent-session.js +2 -0
  84. package/dist/core/agent-session.js.map +1 -1
  85. package/dist/core/builtin-packages.d.ts +4 -0
  86. package/dist/core/builtin-packages.d.ts.map +1 -1
  87. package/dist/core/builtin-packages.js +22 -1
  88. package/dist/core/builtin-packages.js.map +1 -1
  89. package/dist/core/callback-activity.d.ts.map +1 -1
  90. package/dist/core/callback-activity.js +6 -3
  91. package/dist/core/callback-activity.js.map +1 -1
  92. package/dist/core/extensions/loader-core.d.ts +1 -0
  93. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  94. package/dist/core/extensions/loader-core.js +11 -1
  95. package/dist/core/extensions/loader-core.js.map +1 -1
  96. package/dist/core/extensions/loader.d.ts +1 -1
  97. package/dist/core/extensions/loader.d.ts.map +1 -1
  98. package/dist/core/extensions/loader.js +1 -1
  99. package/dist/core/extensions/loader.js.map +1 -1
  100. package/dist/core/extensions/runner-registries.d.ts.map +1 -1
  101. package/dist/core/extensions/runner-registries.js +9 -4
  102. package/dist/core/extensions/runner-registries.js.map +1 -1
  103. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  104. package/dist/core/extensions/runner-shortcuts.js +1 -0
  105. package/dist/core/extensions/runner-shortcuts.js.map +1 -1
  106. package/dist/core/keybindings.d.ts +5 -0
  107. package/dist/core/keybindings.d.ts.map +1 -1
  108. package/dist/core/keybindings.js +4 -0
  109. package/dist/core/keybindings.js.map +1 -1
  110. package/dist/core/mandatory-resource-loader.d.ts +6 -0
  111. package/dist/core/mandatory-resource-loader.d.ts.map +1 -0
  112. package/dist/core/mandatory-resource-loader.js +94 -0
  113. package/dist/core/mandatory-resource-loader.js.map +1 -0
  114. package/dist/core/mandatory-runtime-tools.d.ts +10 -0
  115. package/dist/core/mandatory-runtime-tools.d.ts.map +1 -0
  116. package/dist/core/mandatory-runtime-tools.js +31 -0
  117. package/dist/core/mandatory-runtime-tools.js.map +1 -0
  118. package/dist/core/model-resolver-defaults.js +1 -1
  119. package/dist/core/model-resolver-defaults.js.map +1 -1
  120. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  121. package/dist/core/resource-loader-reload.js +24 -13
  122. package/dist/core/resource-loader-reload.js.map +1 -1
  123. package/dist/core/sdk.d.ts.map +1 -1
  124. package/dist/core/sdk.js +2 -0
  125. package/dist/core/sdk.js.map +1 -1
  126. package/dist/core/settings-manager-ui-accessors.d.ts +4 -1
  127. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  128. package/dist/core/settings-manager-ui-accessors.js +22 -0
  129. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  130. package/dist/core/settings-types.d.ts +4 -0
  131. package/dist/core/settings-types.d.ts.map +1 -1
  132. package/dist/core/settings-types.js.map +1 -1
  133. package/dist/core/slash-commands.js +1 -1
  134. package/dist/core/slash-commands.js.map +1 -1
  135. package/dist/main-session.d.ts.map +1 -1
  136. package/dist/main-session.js +3 -2
  137. package/dist/main-session.js.map +1 -1
  138. package/dist/main.d.ts.map +1 -1
  139. package/dist/main.js +6 -0
  140. package/dist/main.js.map +1 -1
  141. package/dist/modes/interactive/components/fast-mode-selector.js +2 -2
  142. package/dist/modes/interactive/components/fast-mode-selector.js.map +1 -1
  143. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  144. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  145. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  146. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  147. package/dist/modes/interactive/components/settings-selector-items.js +7 -0
  148. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  149. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
  150. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  151. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  152. package/dist/modes/interactive/interactive-agent-events.js +2 -1
  153. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  154. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  155. package/dist/modes/interactive/interactive-deferred-startup.js +1 -0
  156. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  157. package/dist/modes/interactive/interactive-input-handling.js +3 -0
  158. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  159. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  160. package/dist/modes/interactive/interactive-mode-base.js +15 -1
  161. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  162. package/dist/modes/interactive/interactive-mode-surface.d.ts +6 -1
  163. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  164. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  165. package/dist/modes/interactive/interactive-selectors.js +6 -1
  166. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  167. package/dist/modes/interactive/interactive-session-runtime.js +3 -0
  168. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  169. package/dist/modes/interactive/interactive-slash-commands.js +7 -12
  170. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  171. package/dist/modes/interactive/interactive-tui.d.ts +1 -0
  172. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  173. package/dist/modes/interactive/interactive-tui.js +16 -0
  174. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  175. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  176. package/dist/modes/rpc/rpc-session-binding.js +2 -0
  177. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  178. package/docs/compaction.md +1 -1
  179. package/docs/environment-variables.md +2 -0
  180. package/docs/extensions.md +1 -1
  181. package/docs/intercom.md +29 -24
  182. package/docs/keybindings.md +5 -2
  183. package/docs/packages.md +1 -1
  184. package/docs/providers.md +2 -2
  185. package/docs/sdk.md +9 -7
  186. package/docs/settings.md +9 -3
  187. package/docs/subagents.md +2 -2
  188. package/docs/usage.md +7 -6
  189. package/docs/workflows.md +11 -7
  190. package/npm-shrinkwrap.json +59 -77
  191. package/package.json +7 -7
@@ -324,15 +324,15 @@ ${chalk.bold("Options:")}
324
324
  --name, -n <name> Set session display name
325
325
  --models <patterns> Comma-separated model patterns for ctrl+p cycling
326
326
  Supports globs (anthropic/*, *sonnet*) and fuzzy matching
327
- --no-tools, -nt Disable all tools by default (built-in and extension)
327
+ --no-tools, -nt Disable every tool except mandatory ordinary intercom
328
328
  --no-builtin-tools, -nbt Disable built-in tools by default but keep extension/custom tools enabled
329
- --tools, -t <tools> Comma-separated allowlist of tool names to enable
330
- Applies to built-in, extension, and custom tools
331
- --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable
332
- Applies to built-in, extension, and custom tools
329
+ --tools, -t <tools> Comma-separated allowlist of non-mandatory tool names
330
+ Mandatory ordinary intercom remains available
331
+ --exclude-tools, -xt <tools> Comma-separated denylist of non-mandatory tool names
332
+ Mandatory ordinary intercom cannot be excluded
333
333
  --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max
334
334
  --extension, -e <path> Load an extension file (can be used multiple times)
335
- --no-extensions, -ne Disable extension discovery (explicit -e paths still work)
335
+ --no-extensions, -ne Disable optional extension discovery; mandatory bundled Intercom remains loaded
336
336
  --skill <path> Load a skill file or directory (can be used multiple times)
337
337
  --no-skills, -ns Disable skills discovery and loading
338
338
  --prompt-template <path> Load a prompt template file or directory (can be used multiple times)
@@ -5820,11 +5820,13 @@ function runSynchronousCallback(descriptor, callback) {
5820
5820
  }
5821
5821
  }
5822
5822
  async function runCallback(descriptor, callback) {
5823
+ if (!reporter)
5824
+ return callback();
5825
+ await yieldToEventLoop();
5823
5826
  const active = beginActivity(descriptor);
5824
5827
  if (!active)
5825
5828
  return callback();
5826
5829
  try {
5827
- await yieldToEventLoop();
5828
5830
  return await callback();
5829
5831
  } finally {
5830
5832
  active.reporter.finished(active.activity.id);
@@ -8260,12 +8262,42 @@ async function runInputHandlers(extensions, ctx, text, images, source, streaming
8260
8262
  return currentText !== text || currentImages !== images ? { action: "transform", text: currentText, images: currentImages } : { action: "continue" };
8261
8263
  }
8262
8264
 
8265
+ // src/core/mandatory-runtime-tools.ts
8266
+ var MANDATORY_TOOL_NAMES = new Set(["intercom"]);
8267
+ var TRUSTED_MANDATORY_DEFINITIONS = new WeakSet;
8268
+ function markTrustedMandatoryRuntimeExtension(extension) {
8269
+ extension.sourceInfo = { ...extension.sourceInfo, configurationOrigin: "bundled" };
8270
+ for (const registration of extension.tools.values()) {
8271
+ registration.sourceInfo = extension.sourceInfo;
8272
+ if (MANDATORY_TOOL_NAMES.has(registration.definition.name)) {
8273
+ TRUSTED_MANDATORY_DEFINITIONS.add(registration.definition);
8274
+ }
8275
+ }
8276
+ for (const command of extension.commands.values())
8277
+ command.sourceInfo = extension.sourceInfo;
8278
+ }
8279
+ function isTrustedMandatoryRuntimeTool(registration) {
8280
+ return MANDATORY_TOOL_NAMES.has(registration.definition.name) && TRUSTED_MANDATORY_DEFINITIONS.has(registration.definition);
8281
+ }
8282
+ function isMandatoryRuntimeTool(name) {
8283
+ return MANDATORY_TOOL_NAMES.has(name);
8284
+ }
8285
+ function appendRegisteredMandatoryTools(tools, registry) {
8286
+ for (const name of MANDATORY_TOOL_NAMES) {
8287
+ const tool = registry.get(name);
8288
+ if (tool && !tools.some((candidate) => candidate.name === name))
8289
+ tools.push(tool);
8290
+ }
8291
+ return tools;
8292
+ }
8293
+
8263
8294
  // src/core/extensions/runner-registries.ts
8264
8295
  function collectRegisteredTools(extensions) {
8265
8296
  const toolsByName = new Map;
8266
8297
  for (const ext of extensions) {
8267
8298
  for (const tool of ext.tools.values()) {
8268
- if (!toolsByName.has(tool.definition.name)) {
8299
+ const existing = toolsByName.get(tool.definition.name);
8300
+ if (!existing || isMandatoryRuntimeTool(tool.definition.name) && isTrustedMandatoryRuntimeTool(tool)) {
8269
8301
  toolsByName.set(tool.definition.name, tool);
8270
8302
  }
8271
8303
  }
@@ -8273,13 +8305,16 @@ function collectRegisteredTools(extensions) {
8273
8305
  return Array.from(toolsByName.values());
8274
8306
  }
8275
8307
  function findToolDefinition(extensions, toolName) {
8308
+ let first;
8276
8309
  for (const ext of extensions) {
8277
8310
  const tool = ext.tools.get(toolName);
8278
- if (tool) {
8311
+ if (!tool)
8312
+ continue;
8313
+ first ??= tool;
8314
+ if (isMandatoryRuntimeTool(toolName) && isTrustedMandatoryRuntimeTool(tool))
8279
8315
  return tool.definition;
8280
- }
8281
8316
  }
8282
- return;
8317
+ return first?.definition;
8283
8318
  }
8284
8319
  function collectFlags(extensions) {
8285
8320
  const allFlags = new Map;
@@ -8362,6 +8397,7 @@ var RESERVED_KEYBINDINGS_FOR_EXTENSION_CONFLICTS = [
8362
8397
  "app.thinking.toggle",
8363
8398
  "app.editor.external",
8364
8399
  "app.message.followUp",
8400
+ "app.message.copy",
8365
8401
  "tui.input.submit",
8366
8402
  "tui.select.confirm",
8367
8403
  "tui.select.cancel",
@@ -11087,11 +11123,13 @@ async function _runAgentContinue() {
11087
11123
  }
11088
11124
  async function _continueQueuedAgentMessages() {
11089
11125
  await this._agentEventQueue;
11090
- while (!this._queuedMessagesPaused && this.agent.hasQueuedMessages()) {
11126
+ while (!this._stopAfterTurnBlockedContinuation && !this._queuedMessagesPaused && this.agent.hasQueuedMessages()) {
11091
11127
  await this.agent.continue();
11092
11128
  await this.waitForRetry();
11093
11129
  await this._agentEventQueue;
11094
11130
  }
11131
+ if (this._stopAfterTurnBlockedContinuation)
11132
+ return;
11095
11133
  await answerAdmittedQueuedMessage(this);
11096
11134
  }
11097
11135
  async function answerAdmittedQueuedMessage(session) {
@@ -12775,14 +12813,13 @@ function getToolDefinition(name) {
12775
12813
  }
12776
12814
  function setActiveToolsByName(toolNames) {
12777
12815
  const tools = [];
12778
- const validToolNames = [];
12779
12816
  for (const name of toolNames) {
12780
12817
  const tool = this._toolRegistry.get(name);
12781
- if (tool) {
12818
+ if (tool)
12782
12819
  tools.push(tool);
12783
- validToolNames.push(name);
12784
- }
12785
12820
  }
12821
+ appendRegisteredMandatoryTools(tools, this._toolRegistry);
12822
+ const validToolNames = tools.map((tool) => tool.name);
12786
12823
  this.agent.state.tools = tools;
12787
12824
  this._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);
12788
12825
  this.agent.state.systemPrompt = this._systemPromptOverride ?? this._baseSystemPrompt;
@@ -12839,7 +12876,7 @@ function _rebuildSystemPrompt(toolNames) {
12839
12876
  customPrompt: loaderSystemPrompt,
12840
12877
  appendSystemPrompt,
12841
12878
  selectedTools: validToolNames,
12842
- excludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames) : undefined,
12879
+ excludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames).filter((name) => !isMandatoryRuntimeTool(name)) : undefined,
12843
12880
  toolSnippets,
12844
12881
  promptGuidelines
12845
12882
  };
@@ -13850,6 +13887,17 @@ function _installAgentToolHooks() {
13850
13887
  }
13851
13888
  function _installAgentNextTurnRefresh() {
13852
13889
  const previousPrepareNextTurnWithContext = this.agent.prepareNextTurnWithContext ?? (this.agent.prepareNextTurn ? async (_turn, signal) => await this.agent.prepareNextTurn?.(signal) : undefined);
13890
+ const previousShouldStopAfterTurn = this.agent.shouldStopAfterTurn;
13891
+ this.agent.shouldStopAfterTurn = async (turn, signal) => {
13892
+ const toolCallIds = turn.message.content.filter((part) => part.type === "toolCall").map((part) => part.id);
13893
+ const terminatingBatch = toolCallIds.length > 0 && toolCallIds.every((id) => this._terminatingToolCallIds.has(id));
13894
+ for (const id of toolCallIds)
13895
+ this._terminatingToolCallIds.delete(id);
13896
+ const shouldStop = await previousShouldStopAfterTurn?.(turn, signal) ?? false;
13897
+ this._stopAfterTurnBlockedContinuation = shouldStop;
13898
+ await settleFallbackAfterTurn(this, turn, terminatingBatch);
13899
+ return shouldStop;
13900
+ };
13853
13901
  const previousTransformContext = this.agent.transformContext;
13854
13902
  this.agent.transformContext = async (messages, signal) => {
13855
13903
  const transformed = previousTransformContext ? await previousTransformContext(messages, signal) : messages;
@@ -13857,24 +13905,17 @@ function _installAgentNextTurnRefresh() {
13857
13905
  assertToolPairingInvariant(guarded);
13858
13906
  return guarded;
13859
13907
  };
13860
- this.agent.prepareNextTurnWithContext = async (turn, signal) => {
13861
- const previousSnapshot = await previousPrepareNextTurnWithContext?.(turn, signal);
13862
- const previousContext = previousSnapshot?.context ?? turn.context;
13863
- const toolCallIds = turn.message.content.filter((part) => part.type === "toolCall").map((part) => part.id);
13864
- const terminatingBatch = toolCallIds.length > 0 && toolCallIds.every((id) => this._terminatingToolCallIds.has(id));
13865
- for (const id of toolCallIds)
13866
- this._terminatingToolCallIds.delete(id);
13867
- const messages = turn.toolResults.length > 0 && !terminatingBatch ? await this._preflightPostToolContext(previousContext.messages, signal) : previousContext.messages;
13868
- const preserveFallbackForFailure = turn.message.role === "assistant" && !this.agent.hasQueuedMessages() && (turn.message.stopReason === "length" || this._isEmptyCompletion?.(turn.message) === true || this._isSafetyRefusal?.(turn.message) === true);
13869
- if (!preserveFallbackForFailure && (turn.toolResults.length === 0 || terminatingBatch)) {
13870
- await this._agentEventQueue;
13871
- await this._settleFallbackModelScope();
13872
- }
13908
+ const prepareTurn = async (turn, signal) => {
13909
+ const compactedMessages = turn.toolResults.length > 0 ? await this._preflightPostToolContext(turn.context.messages, signal) : turn.context.messages;
13910
+ const compactedContext = compactedMessages === turn.context.messages ? turn.context : { ...turn.context, messages: compactedMessages };
13911
+ const preparedTurn = compactedContext === turn.context ? turn : { ...turn, context: compactedContext };
13912
+ const previousSnapshot = await previousPrepareNextTurnWithContext?.(preparedTurn, signal);
13913
+ const previousContext = previousSnapshot?.context ?? compactedContext;
13873
13914
  return {
13874
13915
  ...previousSnapshot,
13875
13916
  context: {
13876
13917
  ...previousContext,
13877
- messages,
13918
+ messages: previousContext.messages,
13878
13919
  systemPrompt: this._systemPromptOverride ?? this._baseSystemPrompt,
13879
13920
  tools: this.agent.state.tools.slice()
13880
13921
  },
@@ -13882,6 +13923,14 @@ function _installAgentNextTurnRefresh() {
13882
13923
  thinkingLevel: this.agent.state.thinkingLevel
13883
13924
  };
13884
13925
  };
13926
+ this.agent.prepareNextTurnWithContext = prepareTurn;
13927
+ }
13928
+ async function settleFallbackAfterTurn(session, turn, terminatingBatch) {
13929
+ const preserveFallbackForFailure = turn.message.role === "assistant" && !session.agent.hasQueuedMessages() && (turn.message.stopReason === "length" || session._isEmptyCompletion?.(turn.message) === true || session._isSafetyRefusal?.(turn.message) === true);
13930
+ if (!preserveFallbackForFailure && (turn.toolResults.length === 0 || terminatingBatch)) {
13931
+ await session._agentEventQueue;
13932
+ await session._settleFallbackModelScope();
13933
+ }
13885
13934
  }
13886
13935
  var agentSessionToolHooksMethods = {
13887
13936
  _installAgentToolHooks,
@@ -14375,7 +14424,7 @@ async function loadVirtualModules() {
14375
14424
  import("@bastani/pi-ai/oauth"),
14376
14425
  import("@bastani/pi-ai/api/cloudflare-gateway-binding"),
14377
14426
  import("proper-lockfile"),
14378
- import("./chunk-8v8wmb7z.js")
14427
+ import("./chunk-dattsgxg.js")
14379
14428
  ]);
14380
14429
  return {
14381
14430
  typebox,
@@ -14760,6 +14809,15 @@ async function loadExtensionModule(extensionPath, cacheToken) {
14760
14809
  }
14761
14810
 
14762
14811
  // src/core/extensions/loader-core.ts
14812
+ var runtimeEventBuses = new WeakMap;
14813
+ function getExtensionRuntimeEventBus(runtime) {
14814
+ let eventBus = runtimeEventBuses.get(runtime);
14815
+ if (!eventBus) {
14816
+ eventBus = createEventBus();
14817
+ runtimeEventBuses.set(runtime, eventBus);
14818
+ }
14819
+ return eventBus;
14820
+ }
14763
14821
  var INTER_EXTENSION_YIELD_THRESHOLD_MS = 16;
14764
14822
  function createExtension(extensionPath, resolvedPath) {
14765
14823
  const source = extensionPath.startsWith("<") && extensionPath.endsWith(">") ? extensionPath.slice(1, -1).split(":")[0] || "temporary" : "local";
@@ -14826,6 +14884,7 @@ async function loadExtensionsInternal(paths, cwd, eventBus, workflowResourceProv
14826
14884
  const resolvedCwd = cacheToken?.cwd ?? resolvePath(cwd);
14827
14885
  const resolvedEventBus = eventBus ?? createEventBus();
14828
14886
  const resolvedRuntime = runtime ?? createExtensionRuntime();
14887
+ runtimeEventBuses.set(resolvedRuntime, resolvedEventBus);
14829
14888
  let processedExtensionCount = 0;
14830
14889
  let lastYieldAt = Date.now();
14831
14890
  for (const extPath of paths) {
@@ -23165,7 +23224,7 @@ class ExtensionSelectorComponent extends Container12 {
23165
23224
  import { matchesKey as matchesKey5, truncateToWidth as truncateToWidth10, wrapTextWithAnsi as wrapTextWithAnsi3 } from "@earendil-works/pi-tui";
23166
23225
  var ROWS = ["chat", "workflow"];
23167
23226
  var LABEL_WIDTH = 16;
23168
- var DESCRIPTION = "Priority tier for supported OpenAI and shared ChatGPT Codex transports.";
23227
+ var DESCRIPTION = "Use faster routing for the selected model when supported by its provider.";
23169
23228
  var ROW_DETAILS = {
23170
23229
  chat: {
23171
23230
  label: "Chat",
@@ -23187,7 +23246,7 @@ class FastModeSelectorComponent {
23187
23246
  }
23188
23247
  invalidate() {}
23189
23248
  render(width) {
23190
- const lines = [truncateToWidth10(theme.bold(theme.fg("accent", "Codex fast mode")), width)];
23249
+ const lines = [truncateToWidth10(theme.bold(theme.fg("accent", "Fast mode")), width)];
23191
23250
  for (const line of wrapTextWithAnsi3(DESCRIPTION, Math.max(20, width))) {
23192
23251
  lines.push(theme.fg("muted", line));
23193
23252
  }
@@ -24461,6 +24520,10 @@ var KEYBINDINGS = {
24461
24520
  defaultKeys: windowsKeybindings ? "alt+q" : "alt+up",
24462
24521
  description: "Restore queued messages"
24463
24522
  },
24523
+ "app.message.copy": {
24524
+ defaultKeys: "ctrl+x",
24525
+ description: "Copy fullscreen selection or last agent message"
24526
+ },
24464
24527
  "app.clipboard.pasteImage": {
24465
24528
  defaultKeys: windowsKeybindings ? "alt+v" : "ctrl+v",
24466
24529
  description: "Paste image from clipboard (text fallback)"
@@ -25879,6 +25942,9 @@ function createSettingsChangeHandler(callbacks) {
25879
25942
  case "fullscreen-exit-output":
25880
25943
  callbacks.onFullscreenExitOutputChange(newValue);
25881
25944
  break;
25945
+ case "fullscreen-copy-on-select":
25946
+ callbacks.onFullscreenCopyOnSelectChange(newValue === "true");
25947
+ break;
25882
25948
  case "editor-padding":
25883
25949
  callbacks.onEditorPaddingXChange(parseInt(newValue, 10));
25884
25950
  break;
@@ -26265,6 +26331,13 @@ function insertUiToggles(items, config) {
26265
26331
  values: ["transcript", "resume-hint"]
26266
26332
  });
26267
26333
  insertAfter(items, "fullscreen-exit-output", {
26334
+ id: "fullscreen-copy-on-select",
26335
+ label: "Fullscreen copy on select",
26336
+ description: "Copy selected transcript text automatically on mouse release",
26337
+ currentValue: config.fullscreenCopyOnSelect ? "true" : "false",
26338
+ values: ["true", "false"]
26339
+ });
26340
+ insertAfter(items, "fullscreen-copy-on-select", {
26268
26341
  id: "editor-padding",
26269
26342
  label: "Editor padding",
26270
26343
  description: "Horizontal padding for input editor (0-3)",
@@ -39143,6 +39216,8 @@ function _refreshToolRegistry(options) {
39143
39216
  const allowedToolNames = this._allowedToolNames;
39144
39217
  const excludedToolNames = this._excludedToolNames;
39145
39218
  const isExposedTool = (name) => {
39219
+ if (isMandatoryRuntimeTool(name))
39220
+ return true;
39146
39221
  if (allowedToolNames && !allowedToolNames.has(name)) {
39147
39222
  return false;
39148
39223
  }
@@ -39151,10 +39226,10 @@ function _refreshToolRegistry(options) {
39151
39226
  }
39152
39227
  return true;
39153
39228
  };
39154
- const registeredTools = this._extensionRunner.getAllRegisteredTools();
39229
+ const registeredTools = this._extensionRunner.getAllRegisteredTools().filter((tool) => !isMandatoryRuntimeTool(tool.definition.name) || isTrustedMandatoryRuntimeTool(tool));
39155
39230
  const allCustomTools = [
39156
39231
  ...registeredTools,
39157
- ...this._customTools.map((definition) => ({
39232
+ ...this._customTools.filter((definition) => !isMandatoryRuntimeTool(definition.name)).map((definition) => ({
39158
39233
  definition,
39159
39234
  sourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: "sdk" })
39160
39235
  }))
@@ -40104,6 +40179,7 @@ class AgentSessionBase {
40104
40179
  _postToolCompactionPreflightError = undefined;
40105
40180
  _pendingPostToolCompactionGuard = undefined;
40106
40181
  _terminatingToolCallIds = new Set;
40182
+ _stopAfterTurnBlockedContinuation = false;
40107
40183
  _disposed = false;
40108
40184
  _branchSummaryAbortController = undefined;
40109
40185
  _sessionSummaryAbortController = undefined;
@@ -40608,11 +40684,12 @@ var WORKSPACE_BUILTINS = [
40608
40684
  { packageName: "@bastani/subagents", workspaceDirName: "subagents", distDirName: "subagents" },
40609
40685
  { packageName: "@bastani/mcp", workspaceDirName: "mcp", distDirName: "mcp" },
40610
40686
  { packageName: "@bastani/web-access", workspaceDirName: "web-access", distDirName: "web-access" },
40611
- { packageName: "@bastani/intercom", workspaceDirName: "intercom", distDirName: "intercom" }
40687
+ { packageName: "@bastani/intercom", workspaceDirName: "intercom", distDirName: "intercom", mandatory: true }
40612
40688
  ];
40613
40689
  var BUILTIN_PACKAGES = WORKSPACE_BUILTINS.map((spec) => ({
40614
40690
  packageName: spec.packageName,
40615
40691
  distDirName: spec.distDirName,
40692
+ mandatory: spec.mandatory === true,
40616
40693
  requiredEntries: requiredEntriesForBuiltin(spec.distDirName),
40617
40694
  sourceCandidates: ({ here, packageDir, isSourceCheckout }) => isSourceCheckout ? [join29(packageDir, "..", spec.workspaceDirName), join29(here, "..", "..", "..", spec.workspaceDirName)] : []
40618
40695
  }));
@@ -40668,6 +40745,23 @@ function getBuiltinPackagePaths() {
40668
40745
  return packageDir ? [packageDir] : [];
40669
40746
  });
40670
40747
  }
40748
+ function getMandatoryBuiltinPackagePaths() {
40749
+ const context = getBuiltinPackageCandidateContext();
40750
+ return BUILTIN_PACKAGES.filter((descriptor) => descriptor.mandatory).flatMap((descriptor) => {
40751
+ const packageDir = firstExistingPackageDir([...descriptor.sourceCandidates(context), ...distCandidates(context, descriptor)], descriptor);
40752
+ return packageDir ? [packageDir] : [];
40753
+ });
40754
+ }
40755
+ function getMandatoryBuiltinExtensionPaths() {
40756
+ return getMandatoryBuiltinPackagePaths().flatMap((packageDir) => {
40757
+ try {
40758
+ const manifest = JSON.parse(stripBom(readFileSync16(join29(packageDir, "package.json"), "utf-8")));
40759
+ return (manifest.atomic?.extensions ?? manifest.pi?.extensions ?? []).map((entry) => resolve9(packageDir, entry));
40760
+ } catch {
40761
+ return [];
40762
+ }
40763
+ });
40764
+ }
40671
40765
  // src/core/cloudflare-gateway-binding.ts
40672
40766
  import {
40673
40767
  CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL,
@@ -46446,6 +46540,13 @@ function getEnabledResources(resources, metadataByPath) {
46446
46540
  function getEnabledPaths(resources, metadataByPath) {
46447
46541
  return getEnabledResources(resources, metadataByPath).map((r) => r.path);
46448
46542
  }
46543
+ function getBuiltinExtensionPaths(resources, metadataByPath, noExtensions) {
46544
+ for (const resource of resources) {
46545
+ if (!metadataByPath.has(resource.path))
46546
+ metadataByPath.set(resource.path, resource.metadata);
46547
+ }
46548
+ return noExtensions ? [] : resources.filter((resource) => resource.enabled).map((resource) => resource.path);
46549
+ }
46449
46550
  function mapSkillPath(resource, metadataByPath) {
46450
46551
  if (resource.metadata.source !== "auto" && resource.metadata.origin !== "package") {
46451
46552
  return resource.path;
@@ -46489,12 +46590,12 @@ async function loadProjectTrustExtensions(loader) {
46489
46590
  const metadataByPath = new Map;
46490
46591
  const cliEnabledExtensions = getEnabledPaths(cliExtensionPaths.extensions, metadataByPath);
46491
46592
  const enabledExtensions = getEnabledPaths(resolvedPaths.extensions, metadataByPath);
46492
- const builtinEnabledExtensions = state.noExtensions ? [] : getEnabledPaths(builtinPackagePaths.extensions, metadataByPath);
46593
+ const builtinEnabledExtensions = getBuiltinExtensionPaths(builtinPackagePaths.extensions, metadataByPath, state.noExtensions);
46493
46594
  const workflowResources = collectWorkflowResources(resolvedPaths, cliExtensionPaths, builtinPackagePaths);
46494
46595
  state.workflowResources = workflowResources;
46495
46596
  const workflowResourceProvider = createWorkflowResourceProvider(loader);
46496
46597
  const inheritanceSnapshotProvider = createInheritanceSnapshotProvider(loader);
46497
- const extensionPaths = state.noExtensions ? cliEnabledExtensions : mergeResourcePaths(state.cwd, cliEnabledExtensions, [...enabledExtensions, ...builtinEnabledExtensions]);
46598
+ const extensionPaths = mergeResourcePaths(state.cwd, cliEnabledExtensions, state.noExtensions ? builtinEnabledExtensions : [...enabledExtensions, ...builtinEnabledExtensions]);
46498
46599
  const extensionsResult = await loadExtensionsCached(extensionPaths, state.cwd, state.eventBus, workflowResourceProvider, undefined, inheritanceSnapshotProvider);
46499
46600
  const inlineExtensions = await loadExtensionFactories(loader, extensionsResult.runtime, workflowResourceProvider, inheritanceSnapshotProvider);
46500
46601
  extensionsResult.extensions.push(...inlineExtensions.extensions);
@@ -46574,7 +46675,7 @@ async function reloadDefaultResourceLoader(loader, options) {
46574
46675
  const enabledSkillResources = getEnabledResources(resolvedPaths.skills, metadataByPath);
46575
46676
  const enabledPrompts = getEnabledPaths(resolvedPaths.prompts, metadataByPath);
46576
46677
  const enabledThemes = getEnabledPaths(resolvedPaths.themes, metadataByPath);
46577
- const builtinEnabledExtensions = state.noExtensions ? [] : getEnabledPaths(builtinPackagePaths.extensions, metadataByPath);
46678
+ const builtinEnabledExtensions = getBuiltinExtensionPaths(builtinPackagePaths.extensions, metadataByPath, state.noExtensions);
46578
46679
  const builtinEnabledSkillResources = state.noSkills ? [] : getEnabledResources(builtinPackagePaths.skills, metadataByPath);
46579
46680
  const builtinEnabledPrompts = state.noPromptTemplates ? [] : getEnabledPaths(builtinPackagePaths.prompts, metadataByPath);
46580
46681
  const builtinEnabledThemes = state.noThemes ? [] : getEnabledPaths(builtinPackagePaths.themes, metadataByPath);
@@ -46588,9 +46689,13 @@ async function reloadDefaultResourceLoader(loader, options) {
46588
46689
  const workflowResources = collectWorkflowResources(resolvedPaths, cliExtensionPaths, builtinPackagePaths);
46589
46690
  state.workflowResources = workflowResources;
46590
46691
  const workflowResourceProvider = createWorkflowResourceProvider(loader);
46591
- const extensionPaths = state.noExtensions ? cliEnabledExtensions : mergeResourcePaths(state.cwd, cliEnabledExtensions, [...enabledExtensions, ...builtinEnabledExtensions]);
46692
+ const extensionPaths = mergeResourcePaths(state.cwd, cliEnabledExtensions, state.noExtensions ? builtinEnabledExtensions : [...enabledExtensions, ...builtinEnabledExtensions]);
46592
46693
  const inheritanceSnapshotProvider = createInheritanceSnapshotProvider(loader);
46593
46694
  const extensionsResult = options?.deferExtensions ? { extensions: [], errors: [], runtime: createExtensionRuntime() } : await loadFinalExtensionSet(loader, extensionPaths, preTrustExtensions, workflowResourceProvider, inheritanceSnapshotProvider);
46695
+ const mandatoryExtensionPaths = new Set(getMandatoryBuiltinExtensionPaths().map((path14) => resolvePath(path14, state.cwd, { normalizeUnicodeSpaces: true })));
46696
+ const loadedMandatoryExtensions = new Set(extensionsResult.extensions.filter((extension) => mandatoryExtensionPaths.has(resolvePath(extension.resolvedPath, state.cwd, { normalizeUnicodeSpaces: true }))));
46697
+ for (const extension of loadedMandatoryExtensions)
46698
+ markTrustedMandatoryRuntimeExtension(extension);
46594
46699
  for (const p of state.additionalExtensionPaths) {
46595
46700
  if (isLocalPath(p)) {
46596
46701
  const resolved = resolveResourcePath(state.cwd, p);
@@ -46601,6 +46706,12 @@ async function reloadDefaultResourceLoader(loader, options) {
46601
46706
  }
46602
46707
  state.extensionsResult = state.extensionsOverride ? state.extensionsOverride(extensionsResult) : extensionsResult;
46603
46708
  applyExtensionSourceInfo(loader, state.extensionsResult.extensions, metadataByPath);
46709
+ for (const extension of state.extensionsResult.extensions) {
46710
+ const registration = extension.tools.get("intercom");
46711
+ if (loadedMandatoryExtensions.has(extension) && registration && isTrustedMandatoryRuntimeTool(registration)) {
46712
+ markTrustedMandatoryRuntimeExtension(extension);
46713
+ }
46714
+ }
46604
46715
  resolveInheritedExtensionOverlaps(state.extensionsResult);
46605
46716
  const skillPaths = state.noSkills ? mergeResourcePaths(state.cwd, cliEnabledSkills, state.additionalSkillPaths) : mergeResourcePaths(state.cwd, [...cliEnabledSkills, ...enabledSkills, ...builtinEnabledSkills], state.additionalSkillPaths);
46606
46717
  state.lastSkillPaths = skillPaths;
@@ -47803,6 +47914,28 @@ var uiAccessors = {
47803
47914
  state.markModified("fullscreenExitOutput");
47804
47915
  state.save();
47805
47916
  },
47917
+ getFullscreenCopyOnSelect() {
47918
+ return settingsInternals(this).settings.fullscreenCopyOnSelect !== false;
47919
+ },
47920
+ setFullscreenCopyOnSelect(enabled) {
47921
+ const state = settingsInternals(this);
47922
+ state.globalSettings.fullscreenCopyOnSelect = enabled;
47923
+ state.markModified("fullscreenCopyOnSelect");
47924
+ state.save();
47925
+ },
47926
+ getTerminalCapabilityOverrides() {
47927
+ const terminal = settingsInternals(this).settings.terminal;
47928
+ const overrides = {};
47929
+ if (typeof terminal?.hyperlinks === "boolean")
47930
+ overrides.hyperlinks = terminal.hyperlinks;
47931
+ if (terminal?.images === "kitty" || terminal?.images === "iterm2")
47932
+ overrides.images = terminal.images;
47933
+ else if (terminal?.images === false)
47934
+ overrides.images = null;
47935
+ if (typeof terminal?.trueColor === "boolean")
47936
+ overrides.trueColor = terminal.trueColor;
47937
+ return overrides;
47938
+ },
47806
47939
  getEditorPaddingX() {
47807
47940
  return settingsInternals(this).settings.editorPaddingX ?? 0;
47808
47941
  },
@@ -48330,6 +48463,99 @@ function restoreAnthropicReplayThinkingBlocks(payload, sourceMessages, model) {
48330
48463
  return { ...payload, messages: nextPayloadMessages };
48331
48464
  }
48332
48465
 
48466
+ // src/core/mandatory-resource-loader.ts
48467
+ function hasTrustedIntercom(extension) {
48468
+ const registration = extension.tools.get("intercom");
48469
+ return registration !== undefined && isTrustedMandatoryRuntimeTool(registration);
48470
+ }
48471
+ async function restoreMandatoryExtensions(target, cwd) {
48472
+ if (target.extensions.some(hasTrustedIntercom))
48473
+ return target;
48474
+ const loaded = await loadExtensions(getMandatoryBuiltinExtensionPaths(), cwd, getExtensionRuntimeEventBus(target.runtime), undefined, target.runtime);
48475
+ for (const extension of loaded.extensions)
48476
+ markTrustedMandatoryRuntimeExtension(extension);
48477
+ const restored = {
48478
+ ...target,
48479
+ extensions: [...target.extensions, ...loaded.extensions],
48480
+ errors: [...target.errors, ...loaded.errors]
48481
+ };
48482
+ if (!restored.extensions.some(hasTrustedIntercom)) {
48483
+ const detail = loaded.errors.map(({ error }) => error).join("; ") || "extension did not register intercom";
48484
+ throw new Error(`Mandatory bundled Intercom is unavailable: ${detail}`);
48485
+ }
48486
+ return restored;
48487
+ }
48488
+
48489
+ class MandatoryResourceLoader {
48490
+ delegate;
48491
+ cwd;
48492
+ extensionsResult;
48493
+ toolOnly = false;
48494
+ constructor(delegate, cwd, extensionsResult) {
48495
+ this.delegate = delegate;
48496
+ this.cwd = cwd;
48497
+ this.extensionsResult = extensionsResult;
48498
+ }
48499
+ limitToTool() {
48500
+ this.toolOnly = true;
48501
+ this.removeLocalInteractionSurfaces();
48502
+ }
48503
+ removeLocalInteractionSurfaces() {
48504
+ const extension = this.extensionsResult.extensions.find(hasTrustedIntercom);
48505
+ extension?.commands.delete("intercom");
48506
+ extension?.shortcuts.delete("alt+m");
48507
+ }
48508
+ getExtensions() {
48509
+ return this.extensionsResult;
48510
+ }
48511
+ getSkills() {
48512
+ return this.delegate.getSkills();
48513
+ }
48514
+ getSkillCatalog() {
48515
+ return this.delegate.getSkillCatalog?.() ?? buildSkillCatalog(this.delegate.getSkills().skills);
48516
+ }
48517
+ getPrompts() {
48518
+ return this.delegate.getPrompts();
48519
+ }
48520
+ getThemes() {
48521
+ return this.delegate.getThemes();
48522
+ }
48523
+ getAgentsFiles() {
48524
+ return this.delegate.getAgentsFiles();
48525
+ }
48526
+ getSystemPrompt() {
48527
+ return this.delegate.getSystemPrompt();
48528
+ }
48529
+ getSystemPromptSource() {
48530
+ return this.delegate.getSystemPromptSource();
48531
+ }
48532
+ getAppendSystemPrompt() {
48533
+ return this.delegate.getAppendSystemPrompt();
48534
+ }
48535
+ getAppendSystemPromptSources() {
48536
+ return this.delegate.getAppendSystemPromptSources();
48537
+ }
48538
+ extendResources(paths) {
48539
+ return this.delegate.extendResources(paths);
48540
+ }
48541
+ async reload(options) {
48542
+ await this.delegate.reload(options);
48543
+ this.extensionsResult = await restoreMandatoryExtensions(this.delegate.getExtensions(), this.cwd);
48544
+ if (this.toolOnly)
48545
+ this.removeLocalInteractionSurfaces();
48546
+ }
48547
+ }
48548
+ async function withMandatoryResourceLoader(loader, cwd) {
48549
+ if (loader instanceof MandatoryResourceLoader)
48550
+ return loader;
48551
+ const extensionsResult = await restoreMandatoryExtensions(loader.getExtensions(), cwd);
48552
+ return new MandatoryResourceLoader(loader, cwd, extensionsResult);
48553
+ }
48554
+ function limitMandatoryIntercomToTool(loader) {
48555
+ if (loader instanceof MandatoryResourceLoader)
48556
+ loader.limitToTool();
48557
+ }
48558
+
48333
48559
  // src/core/model-resolver-defaults.ts
48334
48560
  var defaultModelPerProvider = {
48335
48561
  "amazon-bedrock": "us.anthropic.claude-opus-4-6-v1",
@@ -48359,7 +48585,7 @@ var defaultModelPerProvider = {
48359
48585
  huggingface: "moonshotai/Kimi-K2.6",
48360
48586
  fireworks: "accounts/fireworks/models/kimi-k2p6",
48361
48587
  together: "moonshotai/Kimi-K2.6",
48362
- baseten: "zai-org/GLM-5.2",
48588
+ baseten: "zai-org/GLM-5.3",
48363
48589
  opencode: "kimi-k2.6",
48364
48590
  "opencode-go": "kimi-k2.6",
48365
48591
  "kimi-coding": "kimi-for-coding",
@@ -49120,14 +49346,16 @@ async function createAgentSessionServices(options) {
49120
49346
  const settingsSpan = startTimingSpan("createAgentSessionServices.settingsManager");
49121
49347
  const settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);
49122
49348
  endTimingSpan(settingsSpan);
49123
- const resourceLoader = new DefaultResourceLoader({
49124
- ...options.resourceLoaderOptions ?? {},
49349
+ const resourceLoaderOptions = options.resourceLoaderOptions ?? {};
49350
+ const defaultResourceLoader = new DefaultResourceLoader({
49351
+ ...resourceLoaderOptions,
49125
49352
  cwd,
49126
49353
  agentDir,
49127
49354
  settingsManager
49128
49355
  });
49129
49356
  const reloadSpan = startTimingSpan("createAgentSessionServices.resourceLoader.reload");
49130
- await resourceLoader.reload(options.resourceLoaderReloadOptions);
49357
+ await defaultResourceLoader.reload(options.resourceLoaderReloadOptions);
49358
+ const resourceLoader = await withMandatoryResourceLoader(defaultResourceLoader, cwd);
49131
49359
  endTimingSpan(reloadSpan);
49132
49360
  const diagnostics = [];
49133
49361
  const providerSpan = startTimingSpan("createAgentSessionServices.providerRegistrations");
@@ -49526,6 +49754,7 @@ async function createAgentSession(options = {}) {
49526
49754
  await resourceLoader.reload();
49527
49755
  time("resourceLoader.reload");
49528
49756
  }
49757
+ resourceLoader = await withMandatoryResourceLoader(resourceLoader, cwd);
49529
49758
  const existingSession = sessionManager.buildSessionContext();
49530
49759
  const repairedMessages = repairOrphanToolResults(existingSession.messages, { repairTrailing: true });
49531
49760
  const existingMessages = options.initialContextTransform ? options.initialContextTransform(repairedMessages) : repairedMessages;
@@ -49746,6 +49975,7 @@ async function createAgentSession(options = {}) {
49746
49975
  };
49747
49976
  }
49748
49977
  // src/main.ts
49978
+ import { setCapabilityOverrides as setCapabilityOverrides8 } from "@earendil-works/pi-tui";
49749
49979
  import chalk13 from "chalk";
49750
49980
 
49751
49981
  // src/cli/auth-check.ts
@@ -50296,8 +50526,14 @@ import chalk6 from "chalk";
50296
50526
 
50297
50527
  // src/cli/startup-ui.ts
50298
50528
  import { existsSync as existsSync35 } from "node:fs";
50299
- import { ProcessTerminal, setKeybindings, TuiMainScreen } from "@earendil-works/pi-tui";
50529
+ import {
50530
+ ProcessTerminal,
50531
+ setCapabilityOverrides,
50532
+ setKeybindings,
50533
+ TuiMainScreen
50534
+ } from "@earendil-works/pi-tui";
50300
50535
  function createStartupTui(settingsManager) {
50536
+ setCapabilityOverrides(settingsManager.getTerminalCapabilityOverrides());
50301
50537
  initTheme(settingsManager.getTheme());
50302
50538
  setKeybindings(KeybindingsManager.create());
50303
50539
  const ui = new TuiMainScreen(new ProcessTerminal, settingsManager.getShowHardwareCursor(), getAgentDir());
@@ -52076,12 +52312,13 @@ async function applyCliRuntimeApiKey(modelRuntime, providerId, apiKey, signal) {
52076
52312
 
52077
52313
  // src/main-session.ts
52078
52314
  import { createInterface as createInterface3 } from "node:readline";
52079
- import { ProcessTerminal as ProcessTerminal3, setKeybindings as setKeybindings3, TuiMainScreen as TuiMainScreen3 } from "@earendil-works/pi-tui";
52315
+ import { ProcessTerminal as ProcessTerminal3, setCapabilityOverrides as setCapabilityOverrides3, setKeybindings as setKeybindings3, TuiMainScreen as TuiMainScreen3 } from "@earendil-works/pi-tui";
52080
52316
  import chalk8 from "chalk";
52081
52317
 
52082
52318
  // src/cli/session-picker.ts
52083
- import { ProcessTerminal as ProcessTerminal2, setKeybindings as setKeybindings2, TuiMainScreen as TuiMainScreen2 } from "@earendil-works/pi-tui";
52084
- async function selectSession(currentSessionsLoader, allSessionsLoader) {
52319
+ import { ProcessTerminal as ProcessTerminal2, setCapabilityOverrides as setCapabilityOverrides2, setKeybindings as setKeybindings2, TuiMainScreen as TuiMainScreen2 } from "@earendil-works/pi-tui";
52320
+ async function selectSession(currentSessionsLoader, allSessionsLoader, settingsManager) {
52321
+ setCapabilityOverrides2(settingsManager.getTerminalCapabilityOverrides());
52085
52322
  return new Promise((resolve20) => {
52086
52323
  const ui = new TuiMainScreen2(new ProcessTerminal2, undefined, getAgentDir());
52087
52324
  const keybindings = KeybindingsManager.create();
@@ -52250,7 +52487,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
52250
52487
  if (parsed.resume) {
52251
52488
  initTheme(settingsManager.getTheme(), true);
52252
52489
  try {
52253
- const selectedPath = await selectSession((onProgress) => SessionManager.list(cwd, sessionDir, onProgress), (onProgress) => SessionManager.listAll(sessionDir, onProgress));
52490
+ const selectedPath = await selectSession((onProgress) => SessionManager.list(cwd, sessionDir, onProgress), (onProgress) => SessionManager.listAll(sessionDir, onProgress), settingsManager);
52254
52491
  if (!selectedPath) {
52255
52492
  console.log(chalk8.dim("No session selected"));
52256
52493
  process.exit(0);
@@ -52273,6 +52510,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
52273
52510
  return SessionManager.create(cwd, sessionDir, { id: parsed.sessionId });
52274
52511
  }
52275
52512
  async function promptForMissingSessionCwd(issue, settingsManager) {
52513
+ setCapabilityOverrides3(settingsManager.getTerminalCapabilityOverrides());
52276
52514
  initTheme(settingsManager.getTheme());
52277
52515
  setKeybindings3(KeybindingsManager.create());
52278
52516
  return new Promise((resolve20) => {
@@ -55385,7 +55623,11 @@ function onInteractiveEngineRemoteCommandsChanged(runtime, listener) {
55385
55623
  }
55386
55624
 
55387
55625
  // src/modes/interactive/interactive-mode-base.ts
55388
- import { isKeyRelease as isKeyRelease3, isViewportTUI } from "@earendil-works/pi-tui";
55626
+ import {
55627
+ isKeyRelease as isKeyRelease3,
55628
+ isViewportTUI,
55629
+ setCapabilityOverrides as setCapabilityOverrides4
55630
+ } from "@earendil-works/pi-tui";
55389
55631
 
55390
55632
  // src/modes/interactive-engine/engine-diagnostic-view.ts
55391
55633
  function renderEngineDiagnostic(diagnostic, view) {
@@ -55810,7 +56052,7 @@ var BUILTIN_SLASH_COMMANDS = [
55810
56052
  { name: "tree", description: "Navigate session tree (switch branches)" },
55811
56053
  { name: "thinking", description: "Set thinking level", argumentHint: "<level>" },
55812
56054
  { name: "scoped-models", description: "Enable/disable models for ctrl+p cycling" },
55813
- { name: "fast", description: "Configure OpenAI fast mode for chat and workflows in supported models" },
56055
+ { name: "fast", description: "Configure fast mode for chat and workflows on supported models" },
55814
56056
  { name: "export", description: "Export session (HTML default, or specify path: .html/.jsonl)" },
55815
56057
  { name: "import", description: "Import and resume a session from a JSONL file" },
55816
56058
  { name: "share", description: "Share session as a secret GitHub gist" },
@@ -56267,6 +56509,7 @@ var viewportInputListeners = new WeakSet;
56267
56509
  var viewportInputGates = new WeakMap;
56268
56510
  var overlayUnhandledInputHandlers = new WeakMap;
56269
56511
  var viewportInputReplays = new WeakSet;
56512
+ var overlayOwnedSelections = new WeakSet;
56270
56513
  var viewportInputSubscriptions = new WeakMap;
56271
56514
  var SGR_MOUSE_SEQUENCE = /^\x1b\[<(\d+);\d+;\d+([Mm])/;
56272
56515
  var LEFT_MOUSE_MODIFIER_MASK = 4 | 8 | 16;
@@ -56335,8 +56578,20 @@ class AtomicTuiAltScreen extends TuiAltScreen {
56335
56578
  deferral.shouldDeferViewportInputToOverlay = () => !viewportInputReplays.has(this) && deferToOverlay?.() === true;
56336
56579
  }
56337
56580
  applyLineResets(lines) {
56581
+ if (overlayOwnedSelections.has(this) && !this.isFocusedOverlay())
56582
+ this.clearOverlayOwnedSelection();
56338
56583
  return stripOverlayActiveRowMarker(super.applyLineResets(lines));
56339
56584
  }
56585
+ clearOverlayOwnedSelection() {
56586
+ const selection = this;
56587
+ selection.selectionAnchor = undefined;
56588
+ selection.selectionFocus = undefined;
56589
+ selection.selectionInitialRange = undefined;
56590
+ selection.selectionPressActive = false;
56591
+ selection.selectionDragged = false;
56592
+ selection.lastClick = undefined;
56593
+ overlayOwnedSelections.delete(this);
56594
+ }
56340
56595
  isPiTuiMouseSequence(data) {
56341
56596
  if (parseMouseSequences(data))
56342
56597
  return true;
@@ -56413,6 +56668,7 @@ class AtomicTuiAltScreen extends TuiAltScreen {
56413
56668
  if (isLeftMouseButton(sequence))
56414
56669
  viewportListener(sequence.data);
56415
56670
  }
56671
+ overlayOwnedSelections.add(this);
56416
56672
  }
56417
56673
  replayViewportInput(viewportListener, data) {
56418
56674
  viewportInputReplays.add(this);
@@ -56493,6 +56749,7 @@ function createFullscreenTui(options) {
56493
56749
  openUrl: openBrowser
56494
56750
  }),
56495
56751
  onRightClickPaste: options.onRightClickPaste,
56752
+ copyOnSelect: options.copyOnSelect,
56496
56753
  copySelection: options.copySelection ?? copySelectionToHostClipboard
56497
56754
  }, options.shouldHandleViewportInput, options.onOverlayUnhandledInput);
56498
56755
  }
@@ -56615,6 +56872,18 @@ class InteractiveModeBase {
56615
56872
  return false;
56616
56873
  return this.defaultEditor.handleInput(data);
56617
56874
  }
56875
+ setFullscreenCopyOnSelect(enabled) {
56876
+ if (this.renderer.mode === "fullscreen")
56877
+ this.renderer.setCopyOnSelect(enabled);
56878
+ }
56879
+ getFullscreenCopyOnSelect() {
56880
+ return this.renderer.mode === "fullscreen" ? this.renderer.getCopyOnSelect() : undefined;
56881
+ }
56882
+ async copyActiveFullscreenSelection() {
56883
+ if (this.renderer.mode !== "fullscreen" || !this.renderer.hasActiveSelection())
56884
+ return;
56885
+ return this.renderer.copyActiveSelectionToClipboard();
56886
+ }
56618
56887
  onRightClickPaste = () => {
56619
56888
  this.handleRightClickPaste();
56620
56889
  };
@@ -56814,11 +57083,13 @@ class InteractiveModeBase {
56814
57083
  await this.rebindCurrentSession();
56815
57084
  await this.themeController.applyFromSettings();
56816
57085
  });
57086
+ setCapabilityOverrides4(this.settingsManager.getTerminalCapabilityOverrides());
56817
57087
  this.version = VERSION;
56818
57088
  this.renderer = createInteractiveTui({
56819
57089
  showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
56820
57090
  logDirectory: runtimeHost.services.agentDir,
56821
57091
  terminal: options.terminal,
57092
+ copyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
56822
57093
  onRightClickPaste: this.onRightClickPaste,
56823
57094
  shouldHandleViewportInput: this.shouldHandleViewportInput,
56824
57095
  onOverlayUnhandledInput: this.onOverlayUnhandledInput,
@@ -57846,6 +58117,7 @@ InteractiveModeBase.prototype.completeDeferredStartup = async function() {
57846
58117
  try {
57847
58118
  await this.bindCurrentSessionExtensions();
57848
58119
  await this.session.reload({ reason: "startup" });
58120
+ this.applyRuntimeSettings();
57849
58121
  this.rebuildChatFromMessages();
57850
58122
  if (!this.promptTurnWorkingLoaderActive) {
57851
58123
  this.stopWorkingLoader();
@@ -58547,6 +58819,7 @@ ${warningLines}`, 0, 0));
58547
58819
  };
58548
58820
 
58549
58821
  // src/modes/interactive/interactive-session-runtime.ts
58822
+ import { setCapabilityOverrides as setCapabilityOverrides5 } from "@earendil-works/pi-tui";
58550
58823
  InteractiveModeBase.prototype.bindCurrentSessionExtensions = async function() {
58551
58824
  const uiContext = this.createExtensionUIContext();
58552
58825
  await this.session.bindExtensions({
@@ -58630,6 +58903,8 @@ InteractiveModeBase.prototype.bindCurrentSessionExtensions = async function() {
58630
58903
  }
58631
58904
  };
58632
58905
  InteractiveModeBase.prototype.applyRuntimeSettings = function() {
58906
+ setCapabilityOverrides5(this.settingsManager.getTerminalCapabilityOverrides());
58907
+ this.setFullscreenCopyOnSelect(this.settingsManager.getFullscreenCopyOnSelect());
58633
58908
  this.transcriptScrollView?.setScrollbar(this.settingsManager.getFullscreenScrollbar());
58634
58909
  this.footer.setSession(this.session);
58635
58910
  this.usageMeter.setSession(this.session);
@@ -60093,6 +60368,9 @@ InteractiveModeBase.prototype.setupKeyHandlers = function() {
60093
60368
  });
60094
60369
  this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
60095
60370
  this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
60371
+ this.defaultEditor.onAction("app.message.copy", () => {
60372
+ this.handleCopyCommand({ preferSelection: true });
60373
+ });
60096
60374
  this.defaultEditor.onAction("app.session.new", () => this.handleClearCommand());
60097
60375
  this.defaultEditor.onAction("app.session.tree", () => this.showTreeSelector());
60098
60376
  this.defaultEditor.onAction("app.session.fork", () => this.showUserMessageSelector());
@@ -60984,7 +61262,8 @@ InteractiveModeBase.prototype.handleEvent = async function(event) {
60984
61262
  } else if (event.reason === "manual") {
60985
61263
  this.manualCompactionTakeoverPending = false;
60986
61264
  }
60987
- if (!manualTakeoverPending && this.settingsManager.getShowTerminalProgress()) {
61265
+ const resumesActiveRun = event.midTurn && !event.aborted && !event.errorMessage && !manualTakeoverPending;
61266
+ if (!manualTakeoverPending && !resumesActiveRun && this.settingsManager.getShowTerminalProgress()) {
60988
61267
  this.ui.terminal.setProgress(false);
60989
61268
  }
60990
61269
  if (!manualTakeoverPending && this.autoCompactionEscapeHandlerSaved) {
@@ -61968,7 +62247,7 @@ InteractiveModeBase.prototype.showSelector = function(create) {
61968
62247
  };
61969
62248
  InteractiveModeBase.prototype.showFastModeSelector = function() {
61970
62249
  if (!this.hasCodexFastModeSupportedModels()) {
61971
- this.showWarning("Codex fast mode requires a supported OpenAI or shared ChatGPT Codex transport model.");
62250
+ this.showWarning("Fast mode isn't available for any configured model.");
61972
62251
  return;
61973
62252
  }
61974
62253
  this.showSelector((done) => {
@@ -62027,6 +62306,7 @@ InteractiveModeBase.prototype.showSettingsSelector = function() {
62027
62306
  showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
62028
62307
  fullscreenScrollbar: this.settingsManager.getFullscreenScrollbar(),
62029
62308
  fullscreenExitOutput: this.settingsManager.getFullscreenExitOutput(),
62309
+ fullscreenCopyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
62030
62310
  editorPaddingX: this.settingsManager.getEditorPaddingX(),
62031
62311
  outputPad: this.settingsManager.getOutputPad(),
62032
62312
  showCacheMissNotices: this.settingsManager.getShowCacheMissNotices(),
@@ -62144,6 +62424,10 @@ InteractiveModeBase.prototype.showSettingsSelector = function() {
62144
62424
  onFullscreenExitOutputChange: (output) => {
62145
62425
  this.settingsManager.setFullscreenExitOutput(output);
62146
62426
  },
62427
+ onFullscreenCopyOnSelectChange: (enabled) => {
62428
+ this.settingsManager.setFullscreenCopyOnSelect(enabled);
62429
+ this.setFullscreenCopyOnSelect(enabled);
62430
+ },
62147
62431
  onEditorPaddingXChange: (padding) => {
62148
62432
  this.settingsManager.setEditorPaddingX(padding);
62149
62433
  this.defaultEditor.setPaddingX(padding);
@@ -63096,18 +63380,8 @@ InteractiveModeBase.prototype.handleReloadCommand = async function() {
63096
63380
  activeHeader.setExpanded(this.toolOutputExpanded);
63097
63381
  }
63098
63382
  setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
63099
- this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
63383
+ this.applyRuntimeSettings();
63100
63384
  await this.themeController.applyFromSettings();
63101
- const editorPaddingX = this.settingsManager.getEditorPaddingX();
63102
- const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
63103
- this.defaultEditor.setPaddingX(editorPaddingX);
63104
- this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);
63105
- if (this.editor !== this.defaultEditor) {
63106
- this.editor.setPaddingX?.(editorPaddingX);
63107
- this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
63108
- }
63109
- this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());
63110
- this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
63111
63385
  this.setupAutocompleteProvider();
63112
63386
  const runner = this.session.extensionRunner;
63113
63387
  this.setupExtensionShortcuts(runner);
@@ -63300,7 +63574,12 @@ Gist: ${hyperlink3(gistUrl, gistUrl)}`);
63300
63574
  }
63301
63575
  }
63302
63576
  };
63303
- InteractiveModeBase.prototype.handleCopyCommand = async function() {
63577
+ InteractiveModeBase.prototype.handleCopyCommand = async function(options = {}) {
63578
+ if (options.preferSelection && this.getFullscreenCopyOnSelect() === false) {
63579
+ const selectionCopied = await this.copyActiveFullscreenSelection();
63580
+ if (selectionCopied !== undefined)
63581
+ return;
63582
+ }
63304
63583
  const text = this.session.getLastAssistantText();
63305
63584
  if (!text) {
63306
63585
  this.showError("No agent messages to copy yet.");
@@ -66964,6 +67243,9 @@ class RpcOutputBuffer {
66964
67243
  }
66965
67244
  }
66966
67245
 
67246
+ // src/modes/rpc/rpc-session-binding.ts
67247
+ import { setCapabilityOverrides as setCapabilityOverrides6 } from "@earendil-works/pi-tui";
67248
+
66967
67249
  // src/modes/rpc/rpc-extension-ui.ts
66968
67250
  import * as crypto5 from "node:crypto";
66969
67251
  function createDialogPromise({
@@ -67249,6 +67531,7 @@ class RpcSessionBinding {
67249
67531
  this.session = this.runtimeHost.session;
67250
67532
  this.disposeSubscriptions();
67251
67533
  const session = this.session;
67534
+ setCapabilityOverrides6(session.settingsManager.getTerminalCapabilityOverrides());
67252
67535
  this.renderService?.bindSession(session);
67253
67536
  this.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());
67254
67537
  const models = session.scopedModels.length > 0 ? session.scopedModels.map((scoped) => scoped.model) : session.modelRuntime.getAvailableSnapshot();
@@ -67563,7 +67846,7 @@ import { join as join59 } from "node:path";
67563
67846
  import chalk12 from "chalk";
67564
67847
 
67565
67848
  // src/cli/config-selector.ts
67566
- import { ProcessTerminal as ProcessTerminal6, TuiMainScreen as TuiMainScreen8 } from "@earendil-works/pi-tui";
67849
+ import { ProcessTerminal as ProcessTerminal6, setCapabilityOverrides as setCapabilityOverrides7, TuiMainScreen as TuiMainScreen8 } from "@earendil-works/pi-tui";
67567
67850
 
67568
67851
  // src/modes/interactive/components/config-selector.ts
67569
67852
  import {
@@ -68102,6 +68385,7 @@ class ConfigSelectorComponent extends Container35 {
68102
68385
 
68103
68386
  // src/cli/config-selector.ts
68104
68387
  async function selectConfig(options) {
68388
+ setCapabilityOverrides7(options.settingsManager.getTerminalCapabilityOverrides());
68105
68389
  initTheme(options.settingsManager.getTheme(), true);
68106
68390
  return new Promise((resolve20) => {
68107
68391
  const ui = new TuiMainScreen8(new ProcessTerminal6, undefined, options.agentDir);
@@ -69152,6 +69436,7 @@ async function main(argv, options) {
69152
69436
  startupEarlyInputCapture = undefined;
69153
69437
  }
69154
69438
  const startupSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: startupProjectTrusted });
69439
+ setCapabilityOverrides8(startupSettingsManager.getTerminalCapabilityOverrides());
69155
69440
  const startupSettingsDiagnostics = collectSettingsDiagnostics(startupSettingsManager, "startup session lookup");
69156
69441
  if (appMode === "interactive" && parsed.useTheme !== undefined) {
69157
69442
  startupSettingsManager.applyOverrides({ theme: parsed.useTheme });
@@ -69286,6 +69571,8 @@ async function main(argv, options) {
69286
69571
  extensionFactories: isolateInteractiveHost ? undefined : extensionFactories
69287
69572
  }
69288
69573
  });
69574
+ if (isolateInteractiveHost)
69575
+ limitMandatoryIntercomToTool(services2.resourceLoader);
69289
69576
  const { settingsManager: settingsManager2, modelRuntime: modelRuntime2, resourceLoader: resourceLoader2 } = services2;
69290
69577
  const diagnostics = [
69291
69578
  ...services2.diagnostics,
@@ -69348,6 +69635,7 @@ async function main(argv, options) {
69348
69635
  endTimingSpan(runtimeCreationSpan);
69349
69636
  const { services, session, modelFallbackMessage } = runtime;
69350
69637
  const { settingsManager, modelRuntime, resourceLoader } = services;
69638
+ setCapabilityOverrides8(settingsManager.getTerminalCapabilityOverrides());
69351
69639
  applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy);
69352
69640
  configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());
69353
69641
  if (parsed.help) {