@bastani/atomic 0.9.16-alpha.10 → 0.9.16-alpha.11

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 (155) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +4 -4
  3. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  4. package/dist/builtin/intercom/README.md +2 -5
  5. package/dist/builtin/intercom/index.bundle.mjs +176 -132
  6. package/dist/builtin/intercom/package.json +2 -2
  7. package/dist/builtin/intercom/skills/intercom/SKILL.md +1 -1
  8. package/dist/builtin/mcp/index.bundle.mjs +176 -120
  9. package/dist/builtin/mcp/package.json +2 -2
  10. package/dist/builtin/subagents/CHANGELOG.md +11 -0
  11. package/dist/builtin/subagents/README.md +3 -3
  12. package/dist/builtin/subagents/package.json +3 -3
  13. package/dist/builtin/subagents/src/extension/index.bundle.mjs +396 -208
  14. package/dist/builtin/web-access/index.bundle.mjs +176 -120
  15. package/dist/builtin/web-access/package.json +2 -2
  16. package/dist/builtin/workflows/CHANGELOG.md +11 -0
  17. package/dist/builtin/workflows/README.md +1 -1
  18. package/dist/builtin/workflows/builtin/{chunk-tr5kqhba.js → chunk-3y1hmzw6.js} +1 -1
  19. package/dist/builtin/workflows/builtin/{chunk-xhrvz7wj.js → chunk-bz1c9732.js} +1 -1
  20. package/dist/builtin/workflows/builtin/{chunk-1ryp6jxq.js → chunk-dattsgxg.js} +1 -1
  21. package/dist/builtin/workflows/builtin/{chunk-peps7f1q.js → chunk-gdx0avpx.js} +329 -135
  22. package/dist/builtin/workflows/builtin/{chunk-5n8ras9g.js → chunk-w9c7rkrk.js} +1 -1
  23. package/dist/builtin/workflows/builtin/goal.js +3 -3
  24. package/dist/builtin/workflows/builtin/index.js +4 -4
  25. package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
  26. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  27. package/dist/builtin/workflows/package.json +2 -2
  28. package/dist/builtin/workflows/src/extension/index.bundle.mjs +427 -196
  29. package/dist/builtin/workflows/src/index.js +186 -140
  30. package/dist/cli/args.js +6 -6
  31. package/dist/cli/args.js.map +1 -1
  32. package/dist/cli/config-selector.d.ts.map +1 -1
  33. package/dist/cli/config-selector.js +2 -1
  34. package/dist/cli/config-selector.js.map +1 -1
  35. package/dist/cli/session-picker.d.ts +2 -1
  36. package/dist/cli/session-picker.d.ts.map +1 -1
  37. package/dist/cli/session-picker.js +3 -2
  38. package/dist/cli/session-picker.js.map +1 -1
  39. package/dist/cli/startup-ui.d.ts.map +1 -1
  40. package/dist/cli/startup-ui.js +2 -1
  41. package/dist/cli/startup-ui.js.map +1 -1
  42. package/dist/core/agent-session-services.d.ts.map +1 -1
  43. package/dist/core/agent-session-services.js +6 -3
  44. package/dist/core/agent-session-services.js.map +1 -1
  45. package/dist/core/agent-session-state.d.ts.map +1 -1
  46. package/dist/core/agent-session-state.js +7 -5
  47. package/dist/core/agent-session-state.js.map +1 -1
  48. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  49. package/dist/core/agent-session-tool-hooks.js +9 -109
  50. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  51. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  52. package/dist/core/agent-session-tool-registry.js +9 -2
  53. package/dist/core/agent-session-tool-registry.js.map +1 -1
  54. package/dist/core/builtin-packages.d.ts +4 -0
  55. package/dist/core/builtin-packages.d.ts.map +1 -1
  56. package/dist/core/builtin-packages.js +22 -1
  57. package/dist/core/builtin-packages.js.map +1 -1
  58. package/dist/core/callback-activity.d.ts.map +1 -1
  59. package/dist/core/callback-activity.js +6 -3
  60. package/dist/core/callback-activity.js.map +1 -1
  61. package/dist/core/extensions/loader-core.d.ts +1 -0
  62. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  63. package/dist/core/extensions/loader-core.js +11 -1
  64. package/dist/core/extensions/loader-core.js.map +1 -1
  65. package/dist/core/extensions/loader.d.ts +1 -1
  66. package/dist/core/extensions/loader.d.ts.map +1 -1
  67. package/dist/core/extensions/loader.js +1 -1
  68. package/dist/core/extensions/loader.js.map +1 -1
  69. package/dist/core/extensions/runner-registries.d.ts.map +1 -1
  70. package/dist/core/extensions/runner-registries.js +9 -4
  71. package/dist/core/extensions/runner-registries.js.map +1 -1
  72. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  73. package/dist/core/extensions/runner-shortcuts.js +1 -0
  74. package/dist/core/extensions/runner-shortcuts.js.map +1 -1
  75. package/dist/core/keybindings.d.ts +5 -0
  76. package/dist/core/keybindings.d.ts.map +1 -1
  77. package/dist/core/keybindings.js +4 -0
  78. package/dist/core/keybindings.js.map +1 -1
  79. package/dist/core/mandatory-resource-loader.d.ts +6 -0
  80. package/dist/core/mandatory-resource-loader.d.ts.map +1 -0
  81. package/dist/core/mandatory-resource-loader.js +94 -0
  82. package/dist/core/mandatory-resource-loader.js.map +1 -0
  83. package/dist/core/mandatory-runtime-tools.d.ts +10 -0
  84. package/dist/core/mandatory-runtime-tools.d.ts.map +1 -0
  85. package/dist/core/mandatory-runtime-tools.js +31 -0
  86. package/dist/core/mandatory-runtime-tools.js.map +1 -0
  87. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  88. package/dist/core/resource-loader-reload.js +24 -13
  89. package/dist/core/resource-loader-reload.js.map +1 -1
  90. package/dist/core/sdk.d.ts.map +1 -1
  91. package/dist/core/sdk.js +2 -0
  92. package/dist/core/sdk.js.map +1 -1
  93. package/dist/core/settings-manager-ui-accessors.d.ts +4 -1
  94. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  95. package/dist/core/settings-manager-ui-accessors.js +22 -0
  96. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  97. package/dist/core/settings-types.d.ts +4 -0
  98. package/dist/core/settings-types.d.ts.map +1 -1
  99. package/dist/core/settings-types.js.map +1 -1
  100. package/dist/core/slash-commands.js +1 -1
  101. package/dist/core/slash-commands.js.map +1 -1
  102. package/dist/main-session.d.ts.map +1 -1
  103. package/dist/main-session.js +3 -2
  104. package/dist/main-session.js.map +1 -1
  105. package/dist/main.d.ts.map +1 -1
  106. package/dist/main.js +6 -0
  107. package/dist/main.js.map +1 -1
  108. package/dist/modes/interactive/components/fast-mode-selector.js +2 -2
  109. package/dist/modes/interactive/components/fast-mode-selector.js.map +1 -1
  110. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  112. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  113. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  114. package/dist/modes/interactive/components/settings-selector-items.js +7 -0
  115. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  116. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
  117. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  118. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  119. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  120. package/dist/modes/interactive/interactive-deferred-startup.js +1 -0
  121. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  122. package/dist/modes/interactive/interactive-input-handling.js +3 -0
  123. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  124. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  125. package/dist/modes/interactive/interactive-mode-base.js +15 -1
  126. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  127. package/dist/modes/interactive/interactive-mode-surface.d.ts +6 -1
  128. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  129. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  130. package/dist/modes/interactive/interactive-selectors.js +6 -1
  131. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  132. package/dist/modes/interactive/interactive-session-runtime.js +3 -0
  133. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  134. package/dist/modes/interactive/interactive-slash-commands.js +7 -12
  135. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  136. package/dist/modes/interactive/interactive-tui.d.ts +1 -0
  137. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  138. package/dist/modes/interactive/interactive-tui.js +16 -0
  139. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  140. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  141. package/dist/modes/rpc/rpc-session-binding.js +2 -0
  142. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  143. package/docs/environment-variables.md +2 -0
  144. package/docs/extensions.md +1 -1
  145. package/docs/intercom.md +6 -7
  146. package/docs/keybindings.md +5 -2
  147. package/docs/packages.md +1 -1
  148. package/docs/providers.md +1 -1
  149. package/docs/sdk.md +9 -7
  150. package/docs/settings.md +9 -3
  151. package/docs/subagents.md +2 -2
  152. package/docs/usage.md +7 -6
  153. package/docs/workflows.md +9 -7
  154. package/npm-shrinkwrap.json +59 -77
  155. 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",
@@ -12777,14 +12813,13 @@ function getToolDefinition(name) {
12777
12813
  }
12778
12814
  function setActiveToolsByName(toolNames) {
12779
12815
  const tools = [];
12780
- const validToolNames = [];
12781
12816
  for (const name of toolNames) {
12782
12817
  const tool = this._toolRegistry.get(name);
12783
- if (tool) {
12818
+ if (tool)
12784
12819
  tools.push(tool);
12785
- validToolNames.push(name);
12786
- }
12787
12820
  }
12821
+ appendRegisteredMandatoryTools(tools, this._toolRegistry);
12822
+ const validToolNames = tools.map((tool) => tool.name);
12788
12823
  this.agent.state.tools = tools;
12789
12824
  this._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);
12790
12825
  this.agent.state.systemPrompt = this._systemPromptOverride ?? this._baseSystemPrompt;
@@ -12841,7 +12876,7 @@ function _rebuildSystemPrompt(toolNames) {
12841
12876
  customPrompt: loaderSystemPrompt,
12842
12877
  appendSystemPrompt,
12843
12878
  selectedTools: validToolNames,
12844
- excludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames) : undefined,
12879
+ excludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames).filter((name) => !isMandatoryRuntimeTool(name)) : undefined,
12845
12880
  toolSnippets,
12846
12881
  promptGuidelines
12847
12882
  };
@@ -13853,31 +13888,14 @@ function _installAgentToolHooks() {
13853
13888
  function _installAgentNextTurnRefresh() {
13854
13889
  const previousPrepareNextTurnWithContext = this.agent.prepareNextTurnWithContext ?? (this.agent.prepareNextTurn ? async (_turn, signal) => await this.agent.prepareNextTurn?.(signal) : undefined);
13855
13890
  const previousShouldStopAfterTurn = this.agent.shouldStopAfterTurn;
13856
- let pendingStopResult;
13857
- const pendingStopMatches = (turn) => {
13858
- const pending = pendingStopResult;
13859
- return pending?.message === turn.message && pending.toolResults === turn.toolResults && pending.newMessages === turn.newMessages;
13860
- };
13861
- const clearPendingStopResult = (turn) => {
13862
- if (pendingStopMatches(turn))
13863
- pendingStopResult = undefined;
13864
- };
13865
13891
  this.agent.shouldStopAfterTurn = async (turn, signal) => {
13866
- const pending = pendingStopResult;
13867
- if (pending && pendingStopMatches(turn)) {
13868
- pendingStopResult = undefined;
13869
- return pending.shouldStop;
13870
- }
13871
- return await previousShouldStopAfterTurn?.(turn, signal) ?? false;
13872
- };
13873
- const cacheStopResult = 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);
13874
13896
  const shouldStop = await previousShouldStopAfterTurn?.(turn, signal) ?? false;
13875
- pendingStopResult = {
13876
- message: turn.message,
13877
- toolResults: turn.toolResults,
13878
- newMessages: turn.newMessages,
13879
- shouldStop
13880
- };
13897
+ this._stopAfterTurnBlockedContinuation = shouldStop;
13898
+ await settleFallbackAfterTurn(this, turn, terminatingBatch);
13881
13899
  return shouldStop;
13882
13900
  };
13883
13901
  const previousTransformContext = this.agent.transformContext;
@@ -13905,68 +13923,7 @@ function _installAgentNextTurnRefresh() {
13905
13923
  thinkingLevel: this.agent.state.thinkingLevel
13906
13924
  };
13907
13925
  };
13908
- let deferredPreparation;
13909
- const prepareDeferredTurn = async (loopConfig) => {
13910
- const deferred = deferredPreparation;
13911
- if (!deferred)
13912
- return;
13913
- deferredPreparation = undefined;
13914
- const snapshot = await prepareTurn(deferred.turn, deferred.signal);
13915
- const nextContext = snapshot.context ?? deferred.turn.context;
13916
- deferred.loopContext.systemPrompt = nextContext.systemPrompt;
13917
- deferred.loopContext.messages = nextContext.messages;
13918
- deferred.loopContext.tools = nextContext.tools;
13919
- loopConfig.model = snapshot.model ?? loopConfig.model;
13920
- loopConfig.reasoning = snapshot.thinkingLevel === undefined ? loopConfig.reasoning : snapshot.thinkingLevel === "off" ? undefined : snapshot.thinkingLevel;
13921
- };
13922
- const agentLoopDoor = this.agent;
13923
- const previousCreateLoopConfig = agentLoopDoor.createLoopConfig.bind(this.agent);
13924
- agentLoopDoor.createLoopConfig = (options) => {
13925
- deferredPreparation = undefined;
13926
- this._stopAfterTurnBlockedContinuation = false;
13927
- const loopConfig = previousCreateLoopConfig(options);
13928
- const wrapQueuePoll = (poll) => async function() {
13929
- const messages = await poll?.() ?? [];
13930
- if (messages.length > 0)
13931
- await prepareDeferredTurn(this);
13932
- return messages;
13933
- };
13934
- loopConfig.getSteeringMessages = wrapQueuePoll(loopConfig.getSteeringMessages);
13935
- loopConfig.getFollowUpMessages = wrapQueuePoll(loopConfig.getFollowUpMessages);
13936
- return loopConfig;
13937
- };
13938
- this.agent.prepareNextTurnWithContext = async (turn, signal) => {
13939
- const toolCallIds = turn.message.content.filter((part) => part.type === "toolCall").map((part) => part.id);
13940
- const terminatingBatch = toolCallIds.length > 0 && toolCallIds.every((id) => this._terminatingToolCallIds.has(id));
13941
- for (const id of toolCallIds)
13942
- this._terminatingToolCallIds.delete(id);
13943
- const shouldStop = await cacheStopResult(turn, signal);
13944
- try {
13945
- if (shouldStop) {
13946
- deferredPreparation = undefined;
13947
- this._stopAfterTurnBlockedContinuation = true;
13948
- await settleFallbackAfterTurn(this, turn, terminatingBatch);
13949
- return;
13950
- }
13951
- if (turn.toolResults.length > 0 && !terminatingBatch) {
13952
- deferredPreparation = undefined;
13953
- const snapshot = await prepareTurn(turn, signal);
13954
- await settleFallbackAfterTurn(this, turn, terminatingBatch);
13955
- return snapshot;
13956
- }
13957
- await settleFallbackAfterTurn(this, turn, terminatingBatch);
13958
- const loopContext = {
13959
- ...turn.context,
13960
- messages: turn.context.messages.slice(),
13961
- tools: turn.context.tools?.slice()
13962
- };
13963
- deferredPreparation = { turn, signal, loopContext };
13964
- return { context: loopContext };
13965
- } catch (error) {
13966
- clearPendingStopResult(turn);
13967
- throw error;
13968
- }
13969
- };
13926
+ this.agent.prepareNextTurnWithContext = prepareTurn;
13970
13927
  }
13971
13928
  async function settleFallbackAfterTurn(session, turn, terminatingBatch) {
13972
13929
  const preserveFallbackForFailure = turn.message.role === "assistant" && !session.agent.hasQueuedMessages() && (turn.message.stopReason === "length" || session._isEmptyCompletion?.(turn.message) === true || session._isSafetyRefusal?.(turn.message) === true);
@@ -14467,7 +14424,7 @@ async function loadVirtualModules() {
14467
14424
  import("@bastani/pi-ai/oauth"),
14468
14425
  import("@bastani/pi-ai/api/cloudflare-gateway-binding"),
14469
14426
  import("proper-lockfile"),
14470
- import("./chunk-1ryp6jxq.js")
14427
+ import("./chunk-dattsgxg.js")
14471
14428
  ]);
14472
14429
  return {
14473
14430
  typebox,
@@ -14852,6 +14809,15 @@ async function loadExtensionModule(extensionPath, cacheToken) {
14852
14809
  }
14853
14810
 
14854
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
+ }
14855
14821
  var INTER_EXTENSION_YIELD_THRESHOLD_MS = 16;
14856
14822
  function createExtension(extensionPath, resolvedPath) {
14857
14823
  const source = extensionPath.startsWith("<") && extensionPath.endsWith(">") ? extensionPath.slice(1, -1).split(":")[0] || "temporary" : "local";
@@ -14918,6 +14884,7 @@ async function loadExtensionsInternal(paths, cwd, eventBus, workflowResourceProv
14918
14884
  const resolvedCwd = cacheToken?.cwd ?? resolvePath(cwd);
14919
14885
  const resolvedEventBus = eventBus ?? createEventBus();
14920
14886
  const resolvedRuntime = runtime ?? createExtensionRuntime();
14887
+ runtimeEventBuses.set(resolvedRuntime, resolvedEventBus);
14921
14888
  let processedExtensionCount = 0;
14922
14889
  let lastYieldAt = Date.now();
14923
14890
  for (const extPath of paths) {
@@ -23257,7 +23224,7 @@ class ExtensionSelectorComponent extends Container12 {
23257
23224
  import { matchesKey as matchesKey5, truncateToWidth as truncateToWidth10, wrapTextWithAnsi as wrapTextWithAnsi3 } from "@earendil-works/pi-tui";
23258
23225
  var ROWS = ["chat", "workflow"];
23259
23226
  var LABEL_WIDTH = 16;
23260
- 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.";
23261
23228
  var ROW_DETAILS = {
23262
23229
  chat: {
23263
23230
  label: "Chat",
@@ -23279,7 +23246,7 @@ class FastModeSelectorComponent {
23279
23246
  }
23280
23247
  invalidate() {}
23281
23248
  render(width) {
23282
- const lines = [truncateToWidth10(theme.bold(theme.fg("accent", "Codex fast mode")), width)];
23249
+ const lines = [truncateToWidth10(theme.bold(theme.fg("accent", "Fast mode")), width)];
23283
23250
  for (const line of wrapTextWithAnsi3(DESCRIPTION, Math.max(20, width))) {
23284
23251
  lines.push(theme.fg("muted", line));
23285
23252
  }
@@ -24553,6 +24520,10 @@ var KEYBINDINGS = {
24553
24520
  defaultKeys: windowsKeybindings ? "alt+q" : "alt+up",
24554
24521
  description: "Restore queued messages"
24555
24522
  },
24523
+ "app.message.copy": {
24524
+ defaultKeys: "ctrl+x",
24525
+ description: "Copy fullscreen selection or last agent message"
24526
+ },
24556
24527
  "app.clipboard.pasteImage": {
24557
24528
  defaultKeys: windowsKeybindings ? "alt+v" : "ctrl+v",
24558
24529
  description: "Paste image from clipboard (text fallback)"
@@ -25971,6 +25942,9 @@ function createSettingsChangeHandler(callbacks) {
25971
25942
  case "fullscreen-exit-output":
25972
25943
  callbacks.onFullscreenExitOutputChange(newValue);
25973
25944
  break;
25945
+ case "fullscreen-copy-on-select":
25946
+ callbacks.onFullscreenCopyOnSelectChange(newValue === "true");
25947
+ break;
25974
25948
  case "editor-padding":
25975
25949
  callbacks.onEditorPaddingXChange(parseInt(newValue, 10));
25976
25950
  break;
@@ -26357,6 +26331,13 @@ function insertUiToggles(items, config) {
26357
26331
  values: ["transcript", "resume-hint"]
26358
26332
  });
26359
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", {
26360
26341
  id: "editor-padding",
26361
26342
  label: "Editor padding",
26362
26343
  description: "Horizontal padding for input editor (0-3)",
@@ -39235,6 +39216,8 @@ function _refreshToolRegistry(options) {
39235
39216
  const allowedToolNames = this._allowedToolNames;
39236
39217
  const excludedToolNames = this._excludedToolNames;
39237
39218
  const isExposedTool = (name) => {
39219
+ if (isMandatoryRuntimeTool(name))
39220
+ return true;
39238
39221
  if (allowedToolNames && !allowedToolNames.has(name)) {
39239
39222
  return false;
39240
39223
  }
@@ -39243,10 +39226,10 @@ function _refreshToolRegistry(options) {
39243
39226
  }
39244
39227
  return true;
39245
39228
  };
39246
- const registeredTools = this._extensionRunner.getAllRegisteredTools();
39229
+ const registeredTools = this._extensionRunner.getAllRegisteredTools().filter((tool) => !isMandatoryRuntimeTool(tool.definition.name) || isTrustedMandatoryRuntimeTool(tool));
39247
39230
  const allCustomTools = [
39248
39231
  ...registeredTools,
39249
- ...this._customTools.map((definition) => ({
39232
+ ...this._customTools.filter((definition) => !isMandatoryRuntimeTool(definition.name)).map((definition) => ({
39250
39233
  definition,
39251
39234
  sourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: "sdk" })
39252
39235
  }))
@@ -40701,11 +40684,12 @@ var WORKSPACE_BUILTINS = [
40701
40684
  { packageName: "@bastani/subagents", workspaceDirName: "subagents", distDirName: "subagents" },
40702
40685
  { packageName: "@bastani/mcp", workspaceDirName: "mcp", distDirName: "mcp" },
40703
40686
  { packageName: "@bastani/web-access", workspaceDirName: "web-access", distDirName: "web-access" },
40704
- { packageName: "@bastani/intercom", workspaceDirName: "intercom", distDirName: "intercom" }
40687
+ { packageName: "@bastani/intercom", workspaceDirName: "intercom", distDirName: "intercom", mandatory: true }
40705
40688
  ];
40706
40689
  var BUILTIN_PACKAGES = WORKSPACE_BUILTINS.map((spec) => ({
40707
40690
  packageName: spec.packageName,
40708
40691
  distDirName: spec.distDirName,
40692
+ mandatory: spec.mandatory === true,
40709
40693
  requiredEntries: requiredEntriesForBuiltin(spec.distDirName),
40710
40694
  sourceCandidates: ({ here, packageDir, isSourceCheckout }) => isSourceCheckout ? [join29(packageDir, "..", spec.workspaceDirName), join29(here, "..", "..", "..", spec.workspaceDirName)] : []
40711
40695
  }));
@@ -40761,6 +40745,23 @@ function getBuiltinPackagePaths() {
40761
40745
  return packageDir ? [packageDir] : [];
40762
40746
  });
40763
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
+ }
40764
40765
  // src/core/cloudflare-gateway-binding.ts
40765
40766
  import {
40766
40767
  CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL,
@@ -46539,6 +46540,13 @@ function getEnabledResources(resources, metadataByPath) {
46539
46540
  function getEnabledPaths(resources, metadataByPath) {
46540
46541
  return getEnabledResources(resources, metadataByPath).map((r) => r.path);
46541
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
+ }
46542
46550
  function mapSkillPath(resource, metadataByPath) {
46543
46551
  if (resource.metadata.source !== "auto" && resource.metadata.origin !== "package") {
46544
46552
  return resource.path;
@@ -46582,12 +46590,12 @@ async function loadProjectTrustExtensions(loader) {
46582
46590
  const metadataByPath = new Map;
46583
46591
  const cliEnabledExtensions = getEnabledPaths(cliExtensionPaths.extensions, metadataByPath);
46584
46592
  const enabledExtensions = getEnabledPaths(resolvedPaths.extensions, metadataByPath);
46585
- const builtinEnabledExtensions = state.noExtensions ? [] : getEnabledPaths(builtinPackagePaths.extensions, metadataByPath);
46593
+ const builtinEnabledExtensions = getBuiltinExtensionPaths(builtinPackagePaths.extensions, metadataByPath, state.noExtensions);
46586
46594
  const workflowResources = collectWorkflowResources(resolvedPaths, cliExtensionPaths, builtinPackagePaths);
46587
46595
  state.workflowResources = workflowResources;
46588
46596
  const workflowResourceProvider = createWorkflowResourceProvider(loader);
46589
46597
  const inheritanceSnapshotProvider = createInheritanceSnapshotProvider(loader);
46590
- const extensionPaths = state.noExtensions ? cliEnabledExtensions : mergeResourcePaths(state.cwd, cliEnabledExtensions, [...enabledExtensions, ...builtinEnabledExtensions]);
46598
+ const extensionPaths = mergeResourcePaths(state.cwd, cliEnabledExtensions, state.noExtensions ? builtinEnabledExtensions : [...enabledExtensions, ...builtinEnabledExtensions]);
46591
46599
  const extensionsResult = await loadExtensionsCached(extensionPaths, state.cwd, state.eventBus, workflowResourceProvider, undefined, inheritanceSnapshotProvider);
46592
46600
  const inlineExtensions = await loadExtensionFactories(loader, extensionsResult.runtime, workflowResourceProvider, inheritanceSnapshotProvider);
46593
46601
  extensionsResult.extensions.push(...inlineExtensions.extensions);
@@ -46667,7 +46675,7 @@ async function reloadDefaultResourceLoader(loader, options) {
46667
46675
  const enabledSkillResources = getEnabledResources(resolvedPaths.skills, metadataByPath);
46668
46676
  const enabledPrompts = getEnabledPaths(resolvedPaths.prompts, metadataByPath);
46669
46677
  const enabledThemes = getEnabledPaths(resolvedPaths.themes, metadataByPath);
46670
- const builtinEnabledExtensions = state.noExtensions ? [] : getEnabledPaths(builtinPackagePaths.extensions, metadataByPath);
46678
+ const builtinEnabledExtensions = getBuiltinExtensionPaths(builtinPackagePaths.extensions, metadataByPath, state.noExtensions);
46671
46679
  const builtinEnabledSkillResources = state.noSkills ? [] : getEnabledResources(builtinPackagePaths.skills, metadataByPath);
46672
46680
  const builtinEnabledPrompts = state.noPromptTemplates ? [] : getEnabledPaths(builtinPackagePaths.prompts, metadataByPath);
46673
46681
  const builtinEnabledThemes = state.noThemes ? [] : getEnabledPaths(builtinPackagePaths.themes, metadataByPath);
@@ -46681,9 +46689,13 @@ async function reloadDefaultResourceLoader(loader, options) {
46681
46689
  const workflowResources = collectWorkflowResources(resolvedPaths, cliExtensionPaths, builtinPackagePaths);
46682
46690
  state.workflowResources = workflowResources;
46683
46691
  const workflowResourceProvider = createWorkflowResourceProvider(loader);
46684
- const extensionPaths = state.noExtensions ? cliEnabledExtensions : mergeResourcePaths(state.cwd, cliEnabledExtensions, [...enabledExtensions, ...builtinEnabledExtensions]);
46692
+ const extensionPaths = mergeResourcePaths(state.cwd, cliEnabledExtensions, state.noExtensions ? builtinEnabledExtensions : [...enabledExtensions, ...builtinEnabledExtensions]);
46685
46693
  const inheritanceSnapshotProvider = createInheritanceSnapshotProvider(loader);
46686
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);
46687
46699
  for (const p of state.additionalExtensionPaths) {
46688
46700
  if (isLocalPath(p)) {
46689
46701
  const resolved = resolveResourcePath(state.cwd, p);
@@ -46694,6 +46706,12 @@ async function reloadDefaultResourceLoader(loader, options) {
46694
46706
  }
46695
46707
  state.extensionsResult = state.extensionsOverride ? state.extensionsOverride(extensionsResult) : extensionsResult;
46696
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
+ }
46697
46715
  resolveInheritedExtensionOverlaps(state.extensionsResult);
46698
46716
  const skillPaths = state.noSkills ? mergeResourcePaths(state.cwd, cliEnabledSkills, state.additionalSkillPaths) : mergeResourcePaths(state.cwd, [...cliEnabledSkills, ...enabledSkills, ...builtinEnabledSkills], state.additionalSkillPaths);
46699
46717
  state.lastSkillPaths = skillPaths;
@@ -47896,6 +47914,28 @@ var uiAccessors = {
47896
47914
  state.markModified("fullscreenExitOutput");
47897
47915
  state.save();
47898
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
+ },
47899
47939
  getEditorPaddingX() {
47900
47940
  return settingsInternals(this).settings.editorPaddingX ?? 0;
47901
47941
  },
@@ -48423,6 +48463,99 @@ function restoreAnthropicReplayThinkingBlocks(payload, sourceMessages, model) {
48423
48463
  return { ...payload, messages: nextPayloadMessages };
48424
48464
  }
48425
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
+
48426
48559
  // src/core/model-resolver-defaults.ts
48427
48560
  var defaultModelPerProvider = {
48428
48561
  "amazon-bedrock": "us.anthropic.claude-opus-4-6-v1",
@@ -49213,14 +49346,16 @@ async function createAgentSessionServices(options) {
49213
49346
  const settingsSpan = startTimingSpan("createAgentSessionServices.settingsManager");
49214
49347
  const settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);
49215
49348
  endTimingSpan(settingsSpan);
49216
- const resourceLoader = new DefaultResourceLoader({
49217
- ...options.resourceLoaderOptions ?? {},
49349
+ const resourceLoaderOptions = options.resourceLoaderOptions ?? {};
49350
+ const defaultResourceLoader = new DefaultResourceLoader({
49351
+ ...resourceLoaderOptions,
49218
49352
  cwd,
49219
49353
  agentDir,
49220
49354
  settingsManager
49221
49355
  });
49222
49356
  const reloadSpan = startTimingSpan("createAgentSessionServices.resourceLoader.reload");
49223
- await resourceLoader.reload(options.resourceLoaderReloadOptions);
49357
+ await defaultResourceLoader.reload(options.resourceLoaderReloadOptions);
49358
+ const resourceLoader = await withMandatoryResourceLoader(defaultResourceLoader, cwd);
49224
49359
  endTimingSpan(reloadSpan);
49225
49360
  const diagnostics = [];
49226
49361
  const providerSpan = startTimingSpan("createAgentSessionServices.providerRegistrations");
@@ -49619,6 +49754,7 @@ async function createAgentSession(options = {}) {
49619
49754
  await resourceLoader.reload();
49620
49755
  time("resourceLoader.reload");
49621
49756
  }
49757
+ resourceLoader = await withMandatoryResourceLoader(resourceLoader, cwd);
49622
49758
  const existingSession = sessionManager.buildSessionContext();
49623
49759
  const repairedMessages = repairOrphanToolResults(existingSession.messages, { repairTrailing: true });
49624
49760
  const existingMessages = options.initialContextTransform ? options.initialContextTransform(repairedMessages) : repairedMessages;
@@ -49839,6 +49975,7 @@ async function createAgentSession(options = {}) {
49839
49975
  };
49840
49976
  }
49841
49977
  // src/main.ts
49978
+ import { setCapabilityOverrides as setCapabilityOverrides8 } from "@earendil-works/pi-tui";
49842
49979
  import chalk13 from "chalk";
49843
49980
 
49844
49981
  // src/cli/auth-check.ts
@@ -50389,8 +50526,14 @@ import chalk6 from "chalk";
50389
50526
 
50390
50527
  // src/cli/startup-ui.ts
50391
50528
  import { existsSync as existsSync35 } from "node:fs";
50392
- 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";
50393
50535
  function createStartupTui(settingsManager) {
50536
+ setCapabilityOverrides(settingsManager.getTerminalCapabilityOverrides());
50394
50537
  initTheme(settingsManager.getTheme());
50395
50538
  setKeybindings(KeybindingsManager.create());
50396
50539
  const ui = new TuiMainScreen(new ProcessTerminal, settingsManager.getShowHardwareCursor(), getAgentDir());
@@ -52169,12 +52312,13 @@ async function applyCliRuntimeApiKey(modelRuntime, providerId, apiKey, signal) {
52169
52312
 
52170
52313
  // src/main-session.ts
52171
52314
  import { createInterface as createInterface3 } from "node:readline";
52172
- 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";
52173
52316
  import chalk8 from "chalk";
52174
52317
 
52175
52318
  // src/cli/session-picker.ts
52176
- import { ProcessTerminal as ProcessTerminal2, setKeybindings as setKeybindings2, TuiMainScreen as TuiMainScreen2 } from "@earendil-works/pi-tui";
52177
- 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());
52178
52322
  return new Promise((resolve20) => {
52179
52323
  const ui = new TuiMainScreen2(new ProcessTerminal2, undefined, getAgentDir());
52180
52324
  const keybindings = KeybindingsManager.create();
@@ -52343,7 +52487,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
52343
52487
  if (parsed.resume) {
52344
52488
  initTheme(settingsManager.getTheme(), true);
52345
52489
  try {
52346
- 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);
52347
52491
  if (!selectedPath) {
52348
52492
  console.log(chalk8.dim("No session selected"));
52349
52493
  process.exit(0);
@@ -52366,6 +52510,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
52366
52510
  return SessionManager.create(cwd, sessionDir, { id: parsed.sessionId });
52367
52511
  }
52368
52512
  async function promptForMissingSessionCwd(issue, settingsManager) {
52513
+ setCapabilityOverrides3(settingsManager.getTerminalCapabilityOverrides());
52369
52514
  initTheme(settingsManager.getTheme());
52370
52515
  setKeybindings3(KeybindingsManager.create());
52371
52516
  return new Promise((resolve20) => {
@@ -55478,7 +55623,11 @@ function onInteractiveEngineRemoteCommandsChanged(runtime, listener) {
55478
55623
  }
55479
55624
 
55480
55625
  // src/modes/interactive/interactive-mode-base.ts
55481
- 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";
55482
55631
 
55483
55632
  // src/modes/interactive-engine/engine-diagnostic-view.ts
55484
55633
  function renderEngineDiagnostic(diagnostic, view) {
@@ -55903,7 +56052,7 @@ var BUILTIN_SLASH_COMMANDS = [
55903
56052
  { name: "tree", description: "Navigate session tree (switch branches)" },
55904
56053
  { name: "thinking", description: "Set thinking level", argumentHint: "<level>" },
55905
56054
  { name: "scoped-models", description: "Enable/disable models for ctrl+p cycling" },
55906
- { 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" },
55907
56056
  { name: "export", description: "Export session (HTML default, or specify path: .html/.jsonl)" },
55908
56057
  { name: "import", description: "Import and resume a session from a JSONL file" },
55909
56058
  { name: "share", description: "Share session as a secret GitHub gist" },
@@ -56360,6 +56509,7 @@ var viewportInputListeners = new WeakSet;
56360
56509
  var viewportInputGates = new WeakMap;
56361
56510
  var overlayUnhandledInputHandlers = new WeakMap;
56362
56511
  var viewportInputReplays = new WeakSet;
56512
+ var overlayOwnedSelections = new WeakSet;
56363
56513
  var viewportInputSubscriptions = new WeakMap;
56364
56514
  var SGR_MOUSE_SEQUENCE = /^\x1b\[<(\d+);\d+;\d+([Mm])/;
56365
56515
  var LEFT_MOUSE_MODIFIER_MASK = 4 | 8 | 16;
@@ -56428,8 +56578,20 @@ class AtomicTuiAltScreen extends TuiAltScreen {
56428
56578
  deferral.shouldDeferViewportInputToOverlay = () => !viewportInputReplays.has(this) && deferToOverlay?.() === true;
56429
56579
  }
56430
56580
  applyLineResets(lines) {
56581
+ if (overlayOwnedSelections.has(this) && !this.isFocusedOverlay())
56582
+ this.clearOverlayOwnedSelection();
56431
56583
  return stripOverlayActiveRowMarker(super.applyLineResets(lines));
56432
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
+ }
56433
56595
  isPiTuiMouseSequence(data) {
56434
56596
  if (parseMouseSequences(data))
56435
56597
  return true;
@@ -56506,6 +56668,7 @@ class AtomicTuiAltScreen extends TuiAltScreen {
56506
56668
  if (isLeftMouseButton(sequence))
56507
56669
  viewportListener(sequence.data);
56508
56670
  }
56671
+ overlayOwnedSelections.add(this);
56509
56672
  }
56510
56673
  replayViewportInput(viewportListener, data) {
56511
56674
  viewportInputReplays.add(this);
@@ -56586,6 +56749,7 @@ function createFullscreenTui(options) {
56586
56749
  openUrl: openBrowser
56587
56750
  }),
56588
56751
  onRightClickPaste: options.onRightClickPaste,
56752
+ copyOnSelect: options.copyOnSelect,
56589
56753
  copySelection: options.copySelection ?? copySelectionToHostClipboard
56590
56754
  }, options.shouldHandleViewportInput, options.onOverlayUnhandledInput);
56591
56755
  }
@@ -56708,6 +56872,18 @@ class InteractiveModeBase {
56708
56872
  return false;
56709
56873
  return this.defaultEditor.handleInput(data);
56710
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
+ }
56711
56887
  onRightClickPaste = () => {
56712
56888
  this.handleRightClickPaste();
56713
56889
  };
@@ -56907,11 +57083,13 @@ class InteractiveModeBase {
56907
57083
  await this.rebindCurrentSession();
56908
57084
  await this.themeController.applyFromSettings();
56909
57085
  });
57086
+ setCapabilityOverrides4(this.settingsManager.getTerminalCapabilityOverrides());
56910
57087
  this.version = VERSION;
56911
57088
  this.renderer = createInteractiveTui({
56912
57089
  showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
56913
57090
  logDirectory: runtimeHost.services.agentDir,
56914
57091
  terminal: options.terminal,
57092
+ copyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
56915
57093
  onRightClickPaste: this.onRightClickPaste,
56916
57094
  shouldHandleViewportInput: this.shouldHandleViewportInput,
56917
57095
  onOverlayUnhandledInput: this.onOverlayUnhandledInput,
@@ -57939,6 +58117,7 @@ InteractiveModeBase.prototype.completeDeferredStartup = async function() {
57939
58117
  try {
57940
58118
  await this.bindCurrentSessionExtensions();
57941
58119
  await this.session.reload({ reason: "startup" });
58120
+ this.applyRuntimeSettings();
57942
58121
  this.rebuildChatFromMessages();
57943
58122
  if (!this.promptTurnWorkingLoaderActive) {
57944
58123
  this.stopWorkingLoader();
@@ -58640,6 +58819,7 @@ ${warningLines}`, 0, 0));
58640
58819
  };
58641
58820
 
58642
58821
  // src/modes/interactive/interactive-session-runtime.ts
58822
+ import { setCapabilityOverrides as setCapabilityOverrides5 } from "@earendil-works/pi-tui";
58643
58823
  InteractiveModeBase.prototype.bindCurrentSessionExtensions = async function() {
58644
58824
  const uiContext = this.createExtensionUIContext();
58645
58825
  await this.session.bindExtensions({
@@ -58723,6 +58903,8 @@ InteractiveModeBase.prototype.bindCurrentSessionExtensions = async function() {
58723
58903
  }
58724
58904
  };
58725
58905
  InteractiveModeBase.prototype.applyRuntimeSettings = function() {
58906
+ setCapabilityOverrides5(this.settingsManager.getTerminalCapabilityOverrides());
58907
+ this.setFullscreenCopyOnSelect(this.settingsManager.getFullscreenCopyOnSelect());
58726
58908
  this.transcriptScrollView?.setScrollbar(this.settingsManager.getFullscreenScrollbar());
58727
58909
  this.footer.setSession(this.session);
58728
58910
  this.usageMeter.setSession(this.session);
@@ -60186,6 +60368,9 @@ InteractiveModeBase.prototype.setupKeyHandlers = function() {
60186
60368
  });
60187
60369
  this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
60188
60370
  this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
60371
+ this.defaultEditor.onAction("app.message.copy", () => {
60372
+ this.handleCopyCommand({ preferSelection: true });
60373
+ });
60189
60374
  this.defaultEditor.onAction("app.session.new", () => this.handleClearCommand());
60190
60375
  this.defaultEditor.onAction("app.session.tree", () => this.showTreeSelector());
60191
60376
  this.defaultEditor.onAction("app.session.fork", () => this.showUserMessageSelector());
@@ -62062,7 +62247,7 @@ InteractiveModeBase.prototype.showSelector = function(create) {
62062
62247
  };
62063
62248
  InteractiveModeBase.prototype.showFastModeSelector = function() {
62064
62249
  if (!this.hasCodexFastModeSupportedModels()) {
62065
- 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.");
62066
62251
  return;
62067
62252
  }
62068
62253
  this.showSelector((done) => {
@@ -62121,6 +62306,7 @@ InteractiveModeBase.prototype.showSettingsSelector = function() {
62121
62306
  showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
62122
62307
  fullscreenScrollbar: this.settingsManager.getFullscreenScrollbar(),
62123
62308
  fullscreenExitOutput: this.settingsManager.getFullscreenExitOutput(),
62309
+ fullscreenCopyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
62124
62310
  editorPaddingX: this.settingsManager.getEditorPaddingX(),
62125
62311
  outputPad: this.settingsManager.getOutputPad(),
62126
62312
  showCacheMissNotices: this.settingsManager.getShowCacheMissNotices(),
@@ -62238,6 +62424,10 @@ InteractiveModeBase.prototype.showSettingsSelector = function() {
62238
62424
  onFullscreenExitOutputChange: (output) => {
62239
62425
  this.settingsManager.setFullscreenExitOutput(output);
62240
62426
  },
62427
+ onFullscreenCopyOnSelectChange: (enabled) => {
62428
+ this.settingsManager.setFullscreenCopyOnSelect(enabled);
62429
+ this.setFullscreenCopyOnSelect(enabled);
62430
+ },
62241
62431
  onEditorPaddingXChange: (padding) => {
62242
62432
  this.settingsManager.setEditorPaddingX(padding);
62243
62433
  this.defaultEditor.setPaddingX(padding);
@@ -63190,18 +63380,8 @@ InteractiveModeBase.prototype.handleReloadCommand = async function() {
63190
63380
  activeHeader.setExpanded(this.toolOutputExpanded);
63191
63381
  }
63192
63382
  setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
63193
- this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
63383
+ this.applyRuntimeSettings();
63194
63384
  await this.themeController.applyFromSettings();
63195
- const editorPaddingX = this.settingsManager.getEditorPaddingX();
63196
- const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
63197
- this.defaultEditor.setPaddingX(editorPaddingX);
63198
- this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);
63199
- if (this.editor !== this.defaultEditor) {
63200
- this.editor.setPaddingX?.(editorPaddingX);
63201
- this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
63202
- }
63203
- this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());
63204
- this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
63205
63385
  this.setupAutocompleteProvider();
63206
63386
  const runner = this.session.extensionRunner;
63207
63387
  this.setupExtensionShortcuts(runner);
@@ -63394,7 +63574,12 @@ Gist: ${hyperlink3(gistUrl, gistUrl)}`);
63394
63574
  }
63395
63575
  }
63396
63576
  };
63397
- 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
+ }
63398
63583
  const text = this.session.getLastAssistantText();
63399
63584
  if (!text) {
63400
63585
  this.showError("No agent messages to copy yet.");
@@ -67058,6 +67243,9 @@ class RpcOutputBuffer {
67058
67243
  }
67059
67244
  }
67060
67245
 
67246
+ // src/modes/rpc/rpc-session-binding.ts
67247
+ import { setCapabilityOverrides as setCapabilityOverrides6 } from "@earendil-works/pi-tui";
67248
+
67061
67249
  // src/modes/rpc/rpc-extension-ui.ts
67062
67250
  import * as crypto5 from "node:crypto";
67063
67251
  function createDialogPromise({
@@ -67343,6 +67531,7 @@ class RpcSessionBinding {
67343
67531
  this.session = this.runtimeHost.session;
67344
67532
  this.disposeSubscriptions();
67345
67533
  const session = this.session;
67534
+ setCapabilityOverrides6(session.settingsManager.getTerminalCapabilityOverrides());
67346
67535
  this.renderService?.bindSession(session);
67347
67536
  this.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());
67348
67537
  const models = session.scopedModels.length > 0 ? session.scopedModels.map((scoped) => scoped.model) : session.modelRuntime.getAvailableSnapshot();
@@ -67657,7 +67846,7 @@ import { join as join59 } from "node:path";
67657
67846
  import chalk12 from "chalk";
67658
67847
 
67659
67848
  // src/cli/config-selector.ts
67660
- 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";
67661
67850
 
67662
67851
  // src/modes/interactive/components/config-selector.ts
67663
67852
  import {
@@ -68196,6 +68385,7 @@ class ConfigSelectorComponent extends Container35 {
68196
68385
 
68197
68386
  // src/cli/config-selector.ts
68198
68387
  async function selectConfig(options) {
68388
+ setCapabilityOverrides7(options.settingsManager.getTerminalCapabilityOverrides());
68199
68389
  initTheme(options.settingsManager.getTheme(), true);
68200
68390
  return new Promise((resolve20) => {
68201
68391
  const ui = new TuiMainScreen8(new ProcessTerminal6, undefined, options.agentDir);
@@ -69246,6 +69436,7 @@ async function main(argv, options) {
69246
69436
  startupEarlyInputCapture = undefined;
69247
69437
  }
69248
69438
  const startupSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: startupProjectTrusted });
69439
+ setCapabilityOverrides8(startupSettingsManager.getTerminalCapabilityOverrides());
69249
69440
  const startupSettingsDiagnostics = collectSettingsDiagnostics(startupSettingsManager, "startup session lookup");
69250
69441
  if (appMode === "interactive" && parsed.useTheme !== undefined) {
69251
69442
  startupSettingsManager.applyOverrides({ theme: parsed.useTheme });
@@ -69380,6 +69571,8 @@ async function main(argv, options) {
69380
69571
  extensionFactories: isolateInteractiveHost ? undefined : extensionFactories
69381
69572
  }
69382
69573
  });
69574
+ if (isolateInteractiveHost)
69575
+ limitMandatoryIntercomToTool(services2.resourceLoader);
69383
69576
  const { settingsManager: settingsManager2, modelRuntime: modelRuntime2, resourceLoader: resourceLoader2 } = services2;
69384
69577
  const diagnostics = [
69385
69578
  ...services2.diagnostics,
@@ -69442,6 +69635,7 @@ async function main(argv, options) {
69442
69635
  endTimingSpan(runtimeCreationSpan);
69443
69636
  const { services, session, modelFallbackMessage } = runtime;
69444
69637
  const { settingsManager, modelRuntime, resourceLoader } = services;
69638
+ setCapabilityOverrides8(settingsManager.getTerminalCapabilityOverrides());
69445
69639
  applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy);
69446
69640
  configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());
69447
69641
  if (parsed.help) {