@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
@@ -1126,15 +1126,15 @@ ${chalk.bold("Options:")}
1126
1126
  --name, -n <name> Set session display name
1127
1127
  --models <patterns> Comma-separated model patterns for ctrl+p cycling
1128
1128
  Supports globs (anthropic/*, *sonnet*) and fuzzy matching
1129
- --no-tools, -nt Disable all tools by default (built-in and extension)
1129
+ --no-tools, -nt Disable every tool except mandatory ordinary intercom
1130
1130
  --no-builtin-tools, -nbt Disable built-in tools by default but keep extension/custom tools enabled
1131
- --tools, -t <tools> Comma-separated allowlist of tool names to enable
1132
- Applies to built-in, extension, and custom tools
1133
- --exclude-tools, -xt <tools> Comma-separated denylist of tool names to disable
1134
- Applies to built-in, extension, and custom tools
1131
+ --tools, -t <tools> Comma-separated allowlist of non-mandatory tool names
1132
+ Mandatory ordinary intercom remains available
1133
+ --exclude-tools, -xt <tools> Comma-separated denylist of non-mandatory tool names
1134
+ Mandatory ordinary intercom cannot be excluded
1135
1135
  --thinking <level> Set thinking level: off, minimal, low, medium, high, xhigh, max
1136
1136
  --extension, -e <path> Load an extension file (can be used multiple times)
1137
- --no-extensions, -ne Disable extension discovery (explicit -e paths still work)
1137
+ --no-extensions, -ne Disable optional extension discovery; mandatory bundled Intercom remains loaded
1138
1138
  --skill <path> Load a skill file or directory (can be used multiple times)
1139
1139
  --no-skills, -ns Disable skills discovery and loading
1140
1140
  --prompt-template <path> Load a prompt template file or directory (can be used multiple times)
@@ -10019,11 +10019,13 @@ function runSynchronousCallback(descriptor, callback) {
10019
10019
  }
10020
10020
  }
10021
10021
  async function runCallback(descriptor, callback) {
10022
+ if (!reporter)
10023
+ return callback();
10024
+ await yieldToEventLoop();
10022
10025
  const active = beginActivity(descriptor);
10023
10026
  if (!active)
10024
10027
  return callback();
10025
10028
  try {
10026
- await yieldToEventLoop();
10027
10029
  return await callback();
10028
10030
  } finally {
10029
10031
  active.reporter.finished(active.activity.id);
@@ -13013,12 +13015,45 @@ var init_runner_events = __esm(() => {
13013
13015
  init_callback_activity();
13014
13016
  });
13015
13017
 
13018
+ // src/core/mandatory-runtime-tools.ts
13019
+ function markTrustedMandatoryRuntimeExtension(extension) {
13020
+ extension.sourceInfo = { ...extension.sourceInfo, configurationOrigin: "bundled" };
13021
+ for (const registration of extension.tools.values()) {
13022
+ registration.sourceInfo = extension.sourceInfo;
13023
+ if (MANDATORY_TOOL_NAMES.has(registration.definition.name)) {
13024
+ TRUSTED_MANDATORY_DEFINITIONS.add(registration.definition);
13025
+ }
13026
+ }
13027
+ for (const command of extension.commands.values())
13028
+ command.sourceInfo = extension.sourceInfo;
13029
+ }
13030
+ function isTrustedMandatoryRuntimeTool(registration) {
13031
+ return MANDATORY_TOOL_NAMES.has(registration.definition.name) && TRUSTED_MANDATORY_DEFINITIONS.has(registration.definition);
13032
+ }
13033
+ function isMandatoryRuntimeTool(name) {
13034
+ return MANDATORY_TOOL_NAMES.has(name);
13035
+ }
13036
+ function appendRegisteredMandatoryTools(tools, registry) {
13037
+ for (const name of MANDATORY_TOOL_NAMES) {
13038
+ const tool = registry.get(name);
13039
+ if (tool && !tools.some((candidate) => candidate.name === name))
13040
+ tools.push(tool);
13041
+ }
13042
+ return tools;
13043
+ }
13044
+ var MANDATORY_TOOL_NAMES, TRUSTED_MANDATORY_DEFINITIONS;
13045
+ var init_mandatory_runtime_tools = __esm(() => {
13046
+ MANDATORY_TOOL_NAMES = new Set(["intercom"]);
13047
+ TRUSTED_MANDATORY_DEFINITIONS = new WeakSet;
13048
+ });
13049
+
13016
13050
  // src/core/extensions/runner-registries.ts
13017
13051
  function collectRegisteredTools(extensions) {
13018
13052
  const toolsByName = new Map;
13019
13053
  for (const ext of extensions) {
13020
13054
  for (const tool of ext.tools.values()) {
13021
- if (!toolsByName.has(tool.definition.name)) {
13055
+ const existing = toolsByName.get(tool.definition.name);
13056
+ if (!existing || isMandatoryRuntimeTool(tool.definition.name) && isTrustedMandatoryRuntimeTool(tool)) {
13022
13057
  toolsByName.set(tool.definition.name, tool);
13023
13058
  }
13024
13059
  }
@@ -13026,13 +13061,16 @@ function collectRegisteredTools(extensions) {
13026
13061
  return Array.from(toolsByName.values());
13027
13062
  }
13028
13063
  function findToolDefinition(extensions, toolName) {
13064
+ let first;
13029
13065
  for (const ext of extensions) {
13030
13066
  const tool = ext.tools.get(toolName);
13031
- if (tool) {
13067
+ if (!tool)
13068
+ continue;
13069
+ first ??= tool;
13070
+ if (isMandatoryRuntimeTool(toolName) && isTrustedMandatoryRuntimeTool(tool))
13032
13071
  return tool.definition;
13033
- }
13034
13072
  }
13035
- return;
13073
+ return first?.definition;
13036
13074
  }
13037
13075
  function collectFlags(extensions) {
13038
13076
  const allFlags = new Map;
@@ -13100,6 +13138,9 @@ function resolveRegisteredCommands(extensions) {
13100
13138
  return { ...command, invocationName };
13101
13139
  });
13102
13140
  }
13141
+ var init_runner_registries = __esm(() => {
13142
+ init_mandatory_runtime_tools();
13143
+ });
13103
13144
 
13104
13145
  // src/core/extensions/runner-shortcuts.ts
13105
13146
  function resolveExtensionShortcuts(extensions, resolvedKeybindings, hasUI) {
@@ -13163,6 +13204,7 @@ var init_runner_shortcuts = __esm(() => {
13163
13204
  "app.thinking.toggle",
13164
13205
  "app.editor.external",
13165
13206
  "app.message.followUp",
13207
+ "app.message.copy",
13166
13208
  "tui.input.submit",
13167
13209
  "tui.select.confirm",
13168
13210
  "tui.select.cancel",
@@ -13654,6 +13696,7 @@ var init_runner = __esm(() => {
13654
13696
  init_loader_runtime();
13655
13697
  init_runner_context();
13656
13698
  init_runner_events();
13699
+ init_runner_registries();
13657
13700
  init_runner_shortcuts();
13658
13701
  init_runner_ui();
13659
13702
  init_stale_context();
@@ -15886,11 +15929,13 @@ async function _runAgentContinue() {
15886
15929
  }
15887
15930
  async function _continueQueuedAgentMessages() {
15888
15931
  await this._agentEventQueue;
15889
- while (!this._queuedMessagesPaused && this.agent.hasQueuedMessages()) {
15932
+ while (!this._stopAfterTurnBlockedContinuation && !this._queuedMessagesPaused && this.agent.hasQueuedMessages()) {
15890
15933
  await this.agent.continue();
15891
15934
  await this.waitForRetry();
15892
15935
  await this._agentEventQueue;
15893
15936
  }
15937
+ if (this._stopAfterTurnBlockedContinuation)
15938
+ return;
15894
15939
  await answerAdmittedQueuedMessage(this);
15895
15940
  }
15896
15941
  async function answerAdmittedQueuedMessage(session) {
@@ -17598,14 +17643,13 @@ function getToolDefinition(name) {
17598
17643
  }
17599
17644
  function setActiveToolsByName(toolNames) {
17600
17645
  const tools = [];
17601
- const validToolNames = [];
17602
17646
  for (const name of toolNames) {
17603
17647
  const tool = this._toolRegistry.get(name);
17604
- if (tool) {
17648
+ if (tool)
17605
17649
  tools.push(tool);
17606
- validToolNames.push(name);
17607
- }
17608
17650
  }
17651
+ appendRegisteredMandatoryTools(tools, this._toolRegistry);
17652
+ const validToolNames = tools.map((tool) => tool.name);
17609
17653
  this.agent.state.tools = tools;
17610
17654
  this._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);
17611
17655
  this.agent.state.systemPrompt = this._systemPromptOverride ?? this._baseSystemPrompt;
@@ -17662,7 +17706,7 @@ function _rebuildSystemPrompt(toolNames) {
17662
17706
  customPrompt: loaderSystemPrompt,
17663
17707
  appendSystemPrompt,
17664
17708
  selectedTools: validToolNames,
17665
- excludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames) : undefined,
17709
+ excludedTools: this._excludedToolNames ? Array.from(this._excludedToolNames).filter((name) => !isMandatoryRuntimeTool(name)) : undefined,
17666
17710
  toolSnippets,
17667
17711
  promptGuidelines
17668
17712
  };
@@ -17675,6 +17719,7 @@ function _refreshBaseSystemPromptFromActiveTools() {
17675
17719
  }
17676
17720
  var agentSessionStateMethods;
17677
17721
  var init_agent_session_state = __esm(() => {
17722
+ init_mandatory_runtime_tools();
17678
17723
  init_skill_catalog();
17679
17724
  init_system_prompt();
17680
17725
  agentSessionStateMethods = {
@@ -18702,6 +18747,17 @@ function _installAgentToolHooks() {
18702
18747
  }
18703
18748
  function _installAgentNextTurnRefresh() {
18704
18749
  const previousPrepareNextTurnWithContext = this.agent.prepareNextTurnWithContext ?? (this.agent.prepareNextTurn ? async (_turn, signal) => await this.agent.prepareNextTurn?.(signal) : undefined);
18750
+ const previousShouldStopAfterTurn = this.agent.shouldStopAfterTurn;
18751
+ this.agent.shouldStopAfterTurn = async (turn, signal) => {
18752
+ const toolCallIds = turn.message.content.filter((part) => part.type === "toolCall").map((part) => part.id);
18753
+ const terminatingBatch = toolCallIds.length > 0 && toolCallIds.every((id) => this._terminatingToolCallIds.has(id));
18754
+ for (const id of toolCallIds)
18755
+ this._terminatingToolCallIds.delete(id);
18756
+ const shouldStop = await previousShouldStopAfterTurn?.(turn, signal) ?? false;
18757
+ this._stopAfterTurnBlockedContinuation = shouldStop;
18758
+ await settleFallbackAfterTurn(this, turn, terminatingBatch);
18759
+ return shouldStop;
18760
+ };
18705
18761
  const previousTransformContext = this.agent.transformContext;
18706
18762
  this.agent.transformContext = async (messages, signal) => {
18707
18763
  const transformed = previousTransformContext ? await previousTransformContext(messages, signal) : messages;
@@ -18709,24 +18765,17 @@ function _installAgentNextTurnRefresh() {
18709
18765
  assertToolPairingInvariant(guarded);
18710
18766
  return guarded;
18711
18767
  };
18712
- this.agent.prepareNextTurnWithContext = async (turn, signal) => {
18713
- const previousSnapshot = await previousPrepareNextTurnWithContext?.(turn, signal);
18714
- const previousContext = previousSnapshot?.context ?? turn.context;
18715
- const toolCallIds = turn.message.content.filter((part) => part.type === "toolCall").map((part) => part.id);
18716
- const terminatingBatch = toolCallIds.length > 0 && toolCallIds.every((id) => this._terminatingToolCallIds.has(id));
18717
- for (const id of toolCallIds)
18718
- this._terminatingToolCallIds.delete(id);
18719
- const messages = turn.toolResults.length > 0 && !terminatingBatch ? await this._preflightPostToolContext(previousContext.messages, signal) : previousContext.messages;
18720
- const preserveFallbackForFailure = turn.message.role === "assistant" && !this.agent.hasQueuedMessages() && (turn.message.stopReason === "length" || this._isEmptyCompletion?.(turn.message) === true || this._isSafetyRefusal?.(turn.message) === true);
18721
- if (!preserveFallbackForFailure && (turn.toolResults.length === 0 || terminatingBatch)) {
18722
- await this._agentEventQueue;
18723
- await this._settleFallbackModelScope();
18724
- }
18768
+ const prepareTurn = async (turn, signal) => {
18769
+ const compactedMessages = turn.toolResults.length > 0 ? await this._preflightPostToolContext(turn.context.messages, signal) : turn.context.messages;
18770
+ const compactedContext = compactedMessages === turn.context.messages ? turn.context : { ...turn.context, messages: compactedMessages };
18771
+ const preparedTurn = compactedContext === turn.context ? turn : { ...turn, context: compactedContext };
18772
+ const previousSnapshot = await previousPrepareNextTurnWithContext?.(preparedTurn, signal);
18773
+ const previousContext = previousSnapshot?.context ?? compactedContext;
18725
18774
  return {
18726
18775
  ...previousSnapshot,
18727
18776
  context: {
18728
18777
  ...previousContext,
18729
- messages,
18778
+ messages: previousContext.messages,
18730
18779
  systemPrompt: this._systemPromptOverride ?? this._baseSystemPrompt,
18731
18780
  tools: this.agent.state.tools.slice()
18732
18781
  },
@@ -18734,6 +18783,14 @@ function _installAgentNextTurnRefresh() {
18734
18783
  thinkingLevel: this.agent.state.thinkingLevel
18735
18784
  };
18736
18785
  };
18786
+ this.agent.prepareNextTurnWithContext = prepareTurn;
18787
+ }
18788
+ async function settleFallbackAfterTurn(session, turn, terminatingBatch) {
18789
+ const preserveFallbackForFailure = turn.message.role === "assistant" && !session.agent.hasQueuedMessages() && (turn.message.stopReason === "length" || session._isEmptyCompletion?.(turn.message) === true || session._isSafetyRefusal?.(turn.message) === true);
18790
+ if (!preserveFallbackForFailure && (turn.toolResults.length === 0 || terminatingBatch)) {
18791
+ await session._agentEventQueue;
18792
+ await session._settleFallbackModelScope();
18793
+ }
18737
18794
  }
18738
18795
  var agentSessionToolHooksMethods;
18739
18796
  var init_agent_session_tool_hooks = __esm(() => {
@@ -19631,6 +19688,14 @@ var init_loader_virtual_modules = __esm(() => {
19631
19688
 
19632
19689
  // src/core/extensions/loader-core.ts
19633
19690
  import * as path7 from "node:path";
19691
+ function getExtensionRuntimeEventBus(runtime) {
19692
+ let eventBus = runtimeEventBuses.get(runtime);
19693
+ if (!eventBus) {
19694
+ eventBus = createEventBus();
19695
+ runtimeEventBuses.set(runtime, eventBus);
19696
+ }
19697
+ return eventBus;
19698
+ }
19634
19699
  function createExtension(extensionPath, resolvedPath) {
19635
19700
  const source = extensionPath.startsWith("<") && extensionPath.endsWith(">") ? extensionPath.slice(1, -1).split(":")[0] || "temporary" : "local";
19636
19701
  const baseDir = extensionPath.startsWith("<") ? undefined : path7.dirname(resolvedPath);
@@ -19696,6 +19761,7 @@ async function loadExtensionsInternal(paths, cwd, eventBus, workflowResourceProv
19696
19761
  const resolvedCwd = cacheToken?.cwd ?? resolvePath(cwd);
19697
19762
  const resolvedEventBus = eventBus ?? createEventBus();
19698
19763
  const resolvedRuntime = runtime ?? createExtensionRuntime();
19764
+ runtimeEventBuses.set(resolvedRuntime, resolvedEventBus);
19699
19765
  let processedExtensionCount = 0;
19700
19766
  let lastYieldAt = Date.now();
19701
19767
  for (const extPath of paths) {
@@ -19727,7 +19793,7 @@ async function loadExtensions(paths, cwd, eventBus, workflowResourceProvider = e
19727
19793
  async function loadExtensionsCached(paths, cwd, eventBus, workflowResourceProvider = emptyWorkflowResourceProvider, runtime, resourceLoaderInheritanceSnapshotProvider) {
19728
19794
  return loadExtensionsInternal(paths, cwd, eventBus, workflowResourceProvider, runtime, resourceLoaderInheritanceSnapshotProvider, true);
19729
19795
  }
19730
- var INTER_EXTENSION_YIELD_THRESHOLD_MS = 16;
19796
+ var runtimeEventBuses, INTER_EXTENSION_YIELD_THRESHOLD_MS = 16;
19731
19797
  var init_loader_core = __esm(() => {
19732
19798
  init_event_loop();
19733
19799
  init_paths();
@@ -19737,6 +19803,7 @@ var init_loader_core = __esm(() => {
19737
19803
  init_loader_resources();
19738
19804
  init_loader_runtime();
19739
19805
  init_loader_virtual_modules();
19806
+ runtimeEventBuses = new WeakMap;
19740
19807
  });
19741
19808
 
19742
19809
  // src/core/package-manager-manifest.ts
@@ -28275,7 +28342,7 @@ class FastModeSelectorComponent {
28275
28342
  }
28276
28343
  invalidate() {}
28277
28344
  render(width) {
28278
- const lines = [truncateToWidth10(theme.bold(theme.fg("accent", "Codex fast mode")), width)];
28345
+ const lines = [truncateToWidth10(theme.bold(theme.fg("accent", "Fast mode")), width)];
28279
28346
  for (const line of wrapTextWithAnsi3(DESCRIPTION, Math.max(20, width))) {
28280
28347
  lines.push(theme.fg("muted", line));
28281
28348
  }
@@ -28358,7 +28425,7 @@ class FastModeSelectorComponent {
28358
28425
  return this.getFocusedRow() === row ? theme.fg("muted", text) : theme.fg("dim", text);
28359
28426
  }
28360
28427
  }
28361
- var ROWS, LABEL_WIDTH = 16, DESCRIPTION = "Priority tier for supported OpenAI and shared ChatGPT Codex transports.", ROW_DETAILS;
28428
+ var ROWS, LABEL_WIDTH = 16, DESCRIPTION = "Use faster routing for the selected model when supported by its provider.", ROW_DETAILS;
28362
28429
  var init_fast_mode_selector = __esm(() => {
28363
28430
  init_theme();
28364
28431
  ROWS = ["chat", "workflow"];
@@ -29664,6 +29731,10 @@ var init_keybindings = __esm(() => {
29664
29731
  defaultKeys: windowsKeybindings ? "alt+q" : "alt+up",
29665
29732
  description: "Restore queued messages"
29666
29733
  },
29734
+ "app.message.copy": {
29735
+ defaultKeys: "ctrl+x",
29736
+ description: "Copy fullscreen selection or last agent message"
29737
+ },
29667
29738
  "app.clipboard.pasteImage": {
29668
29739
  defaultKeys: windowsKeybindings ? "alt+v" : "ctrl+v",
29669
29740
  description: "Paste image from clipboard (text fallback)"
@@ -31056,6 +31127,9 @@ function createSettingsChangeHandler(callbacks) {
31056
31127
  case "fullscreen-exit-output":
31057
31128
  callbacks.onFullscreenExitOutputChange(newValue);
31058
31129
  break;
31130
+ case "fullscreen-copy-on-select":
31131
+ callbacks.onFullscreenCopyOnSelectChange(newValue === "true");
31132
+ break;
31059
31133
  case "editor-padding":
31060
31134
  callbacks.onEditorPaddingXChange(parseInt(newValue, 10));
31061
31135
  break;
@@ -31443,6 +31517,13 @@ function insertUiToggles(items, config) {
31443
31517
  values: ["transcript", "resume-hint"]
31444
31518
  });
31445
31519
  insertAfter(items, "fullscreen-exit-output", {
31520
+ id: "fullscreen-copy-on-select",
31521
+ label: "Fullscreen copy on select",
31522
+ description: "Copy selected transcript text automatically on mouse release",
31523
+ currentValue: config.fullscreenCopyOnSelect ? "true" : "false",
31524
+ values: ["true", "false"]
31525
+ });
31526
+ insertAfter(items, "fullscreen-copy-on-select", {
31446
31527
  id: "editor-padding",
31447
31528
  label: "Editor padding",
31448
31529
  description: "Horizontal padding for input editor (0-3)",
@@ -44720,6 +44801,8 @@ function _refreshToolRegistry(options) {
44720
44801
  const allowedToolNames = this._allowedToolNames;
44721
44802
  const excludedToolNames = this._excludedToolNames;
44722
44803
  const isExposedTool = (name) => {
44804
+ if (isMandatoryRuntimeTool(name))
44805
+ return true;
44723
44806
  if (allowedToolNames && !allowedToolNames.has(name)) {
44724
44807
  return false;
44725
44808
  }
@@ -44728,10 +44811,10 @@ function _refreshToolRegistry(options) {
44728
44811
  }
44729
44812
  return true;
44730
44813
  };
44731
- const registeredTools = this._extensionRunner.getAllRegisteredTools();
44814
+ const registeredTools = this._extensionRunner.getAllRegisteredTools().filter((tool) => !isMandatoryRuntimeTool(tool.definition.name) || isTrustedMandatoryRuntimeTool(tool));
44732
44815
  const allCustomTools = [
44733
44816
  ...registeredTools,
44734
- ...this._customTools.map((definition) => ({
44817
+ ...this._customTools.filter((definition) => !isMandatoryRuntimeTool(definition.name)).map((definition) => ({
44735
44818
  definition,
44736
44819
  sourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: "sdk" })
44737
44820
  }))
@@ -44852,6 +44935,7 @@ function _buildRuntime(options) {
44852
44935
  var agentSessionToolRegistryMethods;
44853
44936
  var init_agent_session_tool_registry = __esm(() => {
44854
44937
  init_extensions();
44938
+ init_mandatory_runtime_tools();
44855
44939
  init_model_registry();
44856
44940
  init_tools();
44857
44941
  init_session_temp_dir();
@@ -45694,6 +45778,7 @@ class AgentSessionBase {
45694
45778
  _postToolCompactionPreflightError = undefined;
45695
45779
  _pendingPostToolCompactionGuard = undefined;
45696
45780
  _terminatingToolCallIds = new Set;
45781
+ _stopAfterTurnBlockedContinuation = false;
45697
45782
  _disposed = false;
45698
45783
  _branchSummaryAbortController = undefined;
45699
45784
  _sessionSummaryAbortController = undefined;
@@ -46281,6 +46366,23 @@ function getBuiltinPackagePaths() {
46281
46366
  return packageDir ? [packageDir] : [];
46282
46367
  });
46283
46368
  }
46369
+ function getMandatoryBuiltinPackagePaths() {
46370
+ const context = getBuiltinPackageCandidateContext();
46371
+ return BUILTIN_PACKAGES.filter((descriptor) => descriptor.mandatory).flatMap((descriptor) => {
46372
+ const packageDir = firstExistingPackageDir([...descriptor.sourceCandidates(context), ...distCandidates(context, descriptor)], descriptor);
46373
+ return packageDir ? [packageDir] : [];
46374
+ });
46375
+ }
46376
+ function getMandatoryBuiltinExtensionPaths() {
46377
+ return getMandatoryBuiltinPackagePaths().flatMap((packageDir) => {
46378
+ try {
46379
+ const manifest = JSON.parse(stripBom(readFileSync21(join43(packageDir, "package.json"), "utf-8")));
46380
+ return (manifest.atomic?.extensions ?? manifest.pi?.extensions ?? []).map((entry) => resolve12(packageDir, entry));
46381
+ } catch {
46382
+ return [];
46383
+ }
46384
+ });
46385
+ }
46284
46386
  var WORKSPACE_BUILTINS, BUILTIN_PACKAGES;
46285
46387
  var init_builtin_packages = __esm(() => {
46286
46388
  init_config();
@@ -46291,11 +46393,12 @@ var init_builtin_packages = __esm(() => {
46291
46393
  { packageName: "@bastani/subagents", workspaceDirName: "subagents", distDirName: "subagents" },
46292
46394
  { packageName: "@bastani/mcp", workspaceDirName: "mcp", distDirName: "mcp" },
46293
46395
  { packageName: "@bastani/web-access", workspaceDirName: "web-access", distDirName: "web-access" },
46294
- { packageName: "@bastani/intercom", workspaceDirName: "intercom", distDirName: "intercom" }
46396
+ { packageName: "@bastani/intercom", workspaceDirName: "intercom", distDirName: "intercom", mandatory: true }
46295
46397
  ];
46296
46398
  BUILTIN_PACKAGES = WORKSPACE_BUILTINS.map((spec) => ({
46297
46399
  packageName: spec.packageName,
46298
46400
  distDirName: spec.distDirName,
46401
+ mandatory: spec.mandatory === true,
46299
46402
  requiredEntries: requiredEntriesForBuiltin(spec.distDirName),
46300
46403
  sourceCandidates: ({ here, packageDir, isSourceCheckout }) => isSourceCheckout ? [join43(packageDir, "..", spec.workspaceDirName), join43(here, "..", "..", "..", spec.workspaceDirName)] : []
46301
46404
  }));
@@ -52270,6 +52373,13 @@ function getEnabledResources(resources, metadataByPath) {
52270
52373
  function getEnabledPaths(resources, metadataByPath) {
52271
52374
  return getEnabledResources(resources, metadataByPath).map((r) => r.path);
52272
52375
  }
52376
+ function getBuiltinExtensionPaths(resources, metadataByPath, noExtensions) {
52377
+ for (const resource of resources) {
52378
+ if (!metadataByPath.has(resource.path))
52379
+ metadataByPath.set(resource.path, resource.metadata);
52380
+ }
52381
+ return noExtensions ? [] : resources.filter((resource) => resource.enabled).map((resource) => resource.path);
52382
+ }
52273
52383
  function mapSkillPath(resource, metadataByPath) {
52274
52384
  if (resource.metadata.source !== "auto" && resource.metadata.origin !== "package") {
52275
52385
  return resource.path;
@@ -52313,12 +52423,12 @@ async function loadProjectTrustExtensions(loader) {
52313
52423
  const metadataByPath = new Map;
52314
52424
  const cliEnabledExtensions = getEnabledPaths(cliExtensionPaths.extensions, metadataByPath);
52315
52425
  const enabledExtensions = getEnabledPaths(resolvedPaths.extensions, metadataByPath);
52316
- const builtinEnabledExtensions = state.noExtensions ? [] : getEnabledPaths(builtinPackagePaths.extensions, metadataByPath);
52426
+ const builtinEnabledExtensions = getBuiltinExtensionPaths(builtinPackagePaths.extensions, metadataByPath, state.noExtensions);
52317
52427
  const workflowResources = collectWorkflowResources(resolvedPaths, cliExtensionPaths, builtinPackagePaths);
52318
52428
  state.workflowResources = workflowResources;
52319
52429
  const workflowResourceProvider = createWorkflowResourceProvider(loader);
52320
52430
  const inheritanceSnapshotProvider = createInheritanceSnapshotProvider(loader);
52321
- const extensionPaths = state.noExtensions ? cliEnabledExtensions : mergeResourcePaths(state.cwd, cliEnabledExtensions, [...enabledExtensions, ...builtinEnabledExtensions]);
52431
+ const extensionPaths = mergeResourcePaths(state.cwd, cliEnabledExtensions, state.noExtensions ? builtinEnabledExtensions : [...enabledExtensions, ...builtinEnabledExtensions]);
52322
52432
  const extensionsResult = await loadExtensionsCached(extensionPaths, state.cwd, state.eventBus, workflowResourceProvider, undefined, inheritanceSnapshotProvider);
52323
52433
  const inlineExtensions = await loadExtensionFactories(loader, extensionsResult.runtime, workflowResourceProvider, inheritanceSnapshotProvider);
52324
52434
  extensionsResult.extensions.push(...inlineExtensions.extensions);
@@ -52398,7 +52508,7 @@ async function reloadDefaultResourceLoader(loader, options) {
52398
52508
  const enabledSkillResources = getEnabledResources(resolvedPaths.skills, metadataByPath);
52399
52509
  const enabledPrompts = getEnabledPaths(resolvedPaths.prompts, metadataByPath);
52400
52510
  const enabledThemes = getEnabledPaths(resolvedPaths.themes, metadataByPath);
52401
- const builtinEnabledExtensions = state.noExtensions ? [] : getEnabledPaths(builtinPackagePaths.extensions, metadataByPath);
52511
+ const builtinEnabledExtensions = getBuiltinExtensionPaths(builtinPackagePaths.extensions, metadataByPath, state.noExtensions);
52402
52512
  const builtinEnabledSkillResources = state.noSkills ? [] : getEnabledResources(builtinPackagePaths.skills, metadataByPath);
52403
52513
  const builtinEnabledPrompts = state.noPromptTemplates ? [] : getEnabledPaths(builtinPackagePaths.prompts, metadataByPath);
52404
52514
  const builtinEnabledThemes = state.noThemes ? [] : getEnabledPaths(builtinPackagePaths.themes, metadataByPath);
@@ -52412,9 +52522,13 @@ async function reloadDefaultResourceLoader(loader, options) {
52412
52522
  const workflowResources = collectWorkflowResources(resolvedPaths, cliExtensionPaths, builtinPackagePaths);
52413
52523
  state.workflowResources = workflowResources;
52414
52524
  const workflowResourceProvider = createWorkflowResourceProvider(loader);
52415
- const extensionPaths = state.noExtensions ? cliEnabledExtensions : mergeResourcePaths(state.cwd, cliEnabledExtensions, [...enabledExtensions, ...builtinEnabledExtensions]);
52525
+ const extensionPaths = mergeResourcePaths(state.cwd, cliEnabledExtensions, state.noExtensions ? builtinEnabledExtensions : [...enabledExtensions, ...builtinEnabledExtensions]);
52416
52526
  const inheritanceSnapshotProvider = createInheritanceSnapshotProvider(loader);
52417
52527
  const extensionsResult = options?.deferExtensions ? { extensions: [], errors: [], runtime: createExtensionRuntime() } : await loadFinalExtensionSet(loader, extensionPaths, preTrustExtensions, workflowResourceProvider, inheritanceSnapshotProvider);
52528
+ const mandatoryExtensionPaths = new Set(getMandatoryBuiltinExtensionPaths().map((path16) => resolvePath(path16, state.cwd, { normalizeUnicodeSpaces: true })));
52529
+ const loadedMandatoryExtensions = new Set(extensionsResult.extensions.filter((extension) => mandatoryExtensionPaths.has(resolvePath(extension.resolvedPath, state.cwd, { normalizeUnicodeSpaces: true }))));
52530
+ for (const extension of loadedMandatoryExtensions)
52531
+ markTrustedMandatoryRuntimeExtension(extension);
52418
52532
  for (const p of state.additionalExtensionPaths) {
52419
52533
  if (isLocalPath(p)) {
52420
52534
  const resolved = resolveResourcePath(state.cwd, p);
@@ -52425,6 +52539,12 @@ async function reloadDefaultResourceLoader(loader, options) {
52425
52539
  }
52426
52540
  state.extensionsResult = state.extensionsOverride ? state.extensionsOverride(extensionsResult) : extensionsResult;
52427
52541
  applyExtensionSourceInfo(loader, state.extensionsResult.extensions, metadataByPath);
52542
+ for (const extension of state.extensionsResult.extensions) {
52543
+ const registration = extension.tools.get("intercom");
52544
+ if (loadedMandatoryExtensions.has(extension) && registration && isTrustedMandatoryRuntimeTool(registration)) {
52545
+ markTrustedMandatoryRuntimeExtension(extension);
52546
+ }
52547
+ }
52428
52548
  resolveInheritedExtensionOverlaps(state.extensionsResult);
52429
52549
  const skillPaths = state.noSkills ? mergeResourcePaths(state.cwd, cliEnabledSkills, state.additionalSkillPaths) : mergeResourcePaths(state.cwd, [...cliEnabledSkills, ...enabledSkills, ...builtinEnabledSkills], state.additionalSkillPaths);
52430
52550
  state.lastSkillPaths = skillPaths;
@@ -52504,7 +52624,9 @@ async function reloadDefaultResourceLoader(loader, options) {
52504
52624
  var init_resource_loader_reload = __esm(() => {
52505
52625
  init_event_loop();
52506
52626
  init_paths();
52627
+ init_builtin_packages();
52507
52628
  init_loader();
52629
+ init_mandatory_runtime_tools();
52508
52630
  init_resource_loader_assets();
52509
52631
  init_resource_loader_context_files();
52510
52632
  init_resource_loader_discovery();
@@ -53661,6 +53783,28 @@ var init_settings_manager_ui_accessors = __esm(() => {
53661
53783
  state.markModified("fullscreenExitOutput");
53662
53784
  state.save();
53663
53785
  },
53786
+ getFullscreenCopyOnSelect() {
53787
+ return settingsInternals(this).settings.fullscreenCopyOnSelect !== false;
53788
+ },
53789
+ setFullscreenCopyOnSelect(enabled) {
53790
+ const state = settingsInternals(this);
53791
+ state.globalSettings.fullscreenCopyOnSelect = enabled;
53792
+ state.markModified("fullscreenCopyOnSelect");
53793
+ state.save();
53794
+ },
53795
+ getTerminalCapabilityOverrides() {
53796
+ const terminal = settingsInternals(this).settings.terminal;
53797
+ const overrides = {};
53798
+ if (typeof terminal?.hyperlinks === "boolean")
53799
+ overrides.hyperlinks = terminal.hyperlinks;
53800
+ if (terminal?.images === "kitty" || terminal?.images === "iterm2")
53801
+ overrides.images = terminal.images;
53802
+ else if (terminal?.images === false)
53803
+ overrides.images = null;
53804
+ if (typeof terminal?.trueColor === "boolean")
53805
+ overrides.trueColor = terminal.trueColor;
53806
+ return overrides;
53807
+ },
53664
53808
  getEditorPaddingX() {
53665
53809
  return settingsInternals(this).settings.editorPaddingX ?? 0;
53666
53810
  },
@@ -54211,6 +54355,105 @@ function restoreAnthropicReplayThinkingBlocks(payload, sourceMessages, model) {
54211
54355
  return { ...payload, messages: nextPayloadMessages };
54212
54356
  }
54213
54357
 
54358
+ // src/core/mandatory-resource-loader.ts
54359
+ function hasTrustedIntercom(extension) {
54360
+ const registration = extension.tools.get("intercom");
54361
+ return registration !== undefined && isTrustedMandatoryRuntimeTool(registration);
54362
+ }
54363
+ async function restoreMandatoryExtensions(target, cwd) {
54364
+ if (target.extensions.some(hasTrustedIntercom))
54365
+ return target;
54366
+ const loaded = await loadExtensions(getMandatoryBuiltinExtensionPaths(), cwd, getExtensionRuntimeEventBus(target.runtime), undefined, target.runtime);
54367
+ for (const extension of loaded.extensions)
54368
+ markTrustedMandatoryRuntimeExtension(extension);
54369
+ const restored = {
54370
+ ...target,
54371
+ extensions: [...target.extensions, ...loaded.extensions],
54372
+ errors: [...target.errors, ...loaded.errors]
54373
+ };
54374
+ if (!restored.extensions.some(hasTrustedIntercom)) {
54375
+ const detail = loaded.errors.map(({ error }) => error).join("; ") || "extension did not register intercom";
54376
+ throw new Error(`Mandatory bundled Intercom is unavailable: ${detail}`);
54377
+ }
54378
+ return restored;
54379
+ }
54380
+
54381
+ class MandatoryResourceLoader {
54382
+ delegate;
54383
+ cwd;
54384
+ extensionsResult;
54385
+ toolOnly = false;
54386
+ constructor(delegate, cwd, extensionsResult) {
54387
+ this.delegate = delegate;
54388
+ this.cwd = cwd;
54389
+ this.extensionsResult = extensionsResult;
54390
+ }
54391
+ limitToTool() {
54392
+ this.toolOnly = true;
54393
+ this.removeLocalInteractionSurfaces();
54394
+ }
54395
+ removeLocalInteractionSurfaces() {
54396
+ const extension = this.extensionsResult.extensions.find(hasTrustedIntercom);
54397
+ extension?.commands.delete("intercom");
54398
+ extension?.shortcuts.delete("alt+m");
54399
+ }
54400
+ getExtensions() {
54401
+ return this.extensionsResult;
54402
+ }
54403
+ getSkills() {
54404
+ return this.delegate.getSkills();
54405
+ }
54406
+ getSkillCatalog() {
54407
+ return this.delegate.getSkillCatalog?.() ?? buildSkillCatalog(this.delegate.getSkills().skills);
54408
+ }
54409
+ getPrompts() {
54410
+ return this.delegate.getPrompts();
54411
+ }
54412
+ getThemes() {
54413
+ return this.delegate.getThemes();
54414
+ }
54415
+ getAgentsFiles() {
54416
+ return this.delegate.getAgentsFiles();
54417
+ }
54418
+ getSystemPrompt() {
54419
+ return this.delegate.getSystemPrompt();
54420
+ }
54421
+ getSystemPromptSource() {
54422
+ return this.delegate.getSystemPromptSource();
54423
+ }
54424
+ getAppendSystemPrompt() {
54425
+ return this.delegate.getAppendSystemPrompt();
54426
+ }
54427
+ getAppendSystemPromptSources() {
54428
+ return this.delegate.getAppendSystemPromptSources();
54429
+ }
54430
+ extendResources(paths) {
54431
+ return this.delegate.extendResources(paths);
54432
+ }
54433
+ async reload(options) {
54434
+ await this.delegate.reload(options);
54435
+ this.extensionsResult = await restoreMandatoryExtensions(this.delegate.getExtensions(), this.cwd);
54436
+ if (this.toolOnly)
54437
+ this.removeLocalInteractionSurfaces();
54438
+ }
54439
+ }
54440
+ async function withMandatoryResourceLoader(loader, cwd) {
54441
+ if (loader instanceof MandatoryResourceLoader)
54442
+ return loader;
54443
+ const extensionsResult = await restoreMandatoryExtensions(loader.getExtensions(), cwd);
54444
+ return new MandatoryResourceLoader(loader, cwd, extensionsResult);
54445
+ }
54446
+ function limitMandatoryIntercomToTool(loader) {
54447
+ if (loader instanceof MandatoryResourceLoader)
54448
+ loader.limitToTool();
54449
+ }
54450
+ var init_mandatory_resource_loader = __esm(() => {
54451
+ init_builtin_packages();
54452
+ init_loader();
54453
+ init_mandatory_runtime_tools();
54454
+ init_skill_catalog();
54455
+ });
54456
+
54214
54457
  // src/core/model-resolver-defaults.ts
54215
54458
  function findPreferredAvailableModel(availableModels) {
54216
54459
  for (const [provider, defaultId] of Object.entries(defaultModelPerProvider)) {
@@ -54251,7 +54494,7 @@ var init_model_resolver_defaults = __esm(() => {
54251
54494
  huggingface: "moonshotai/Kimi-K2.6",
54252
54495
  fireworks: "accounts/fireworks/models/kimi-k2p6",
54253
54496
  together: "moonshotai/Kimi-K2.6",
54254
- baseten: "zai-org/GLM-5.2",
54497
+ baseten: "zai-org/GLM-5.3",
54255
54498
  opencode: "kimi-k2.6",
54256
54499
  "opencode-go": "kimi-k2.6",
54257
54500
  "kimi-coding": "kimi-for-coding",
@@ -55040,14 +55283,16 @@ async function createAgentSessionServices(options) {
55040
55283
  const settingsSpan = startTimingSpan("createAgentSessionServices.settingsManager");
55041
55284
  const settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir);
55042
55285
  endTimingSpan(settingsSpan);
55043
- const resourceLoader = new DefaultResourceLoader({
55044
- ...options.resourceLoaderOptions ?? {},
55286
+ const resourceLoaderOptions = options.resourceLoaderOptions ?? {};
55287
+ const defaultResourceLoader = new DefaultResourceLoader({
55288
+ ...resourceLoaderOptions,
55045
55289
  cwd,
55046
55290
  agentDir,
55047
55291
  settingsManager
55048
55292
  });
55049
55293
  const reloadSpan = startTimingSpan("createAgentSessionServices.resourceLoader.reload");
55050
- await resourceLoader.reload(options.resourceLoaderReloadOptions);
55294
+ await defaultResourceLoader.reload(options.resourceLoaderReloadOptions);
55295
+ const resourceLoader = await withMandatoryResourceLoader(defaultResourceLoader, cwd);
55051
55296
  endTimingSpan(reloadSpan);
55052
55297
  const diagnostics = [];
55053
55298
  const providerSpan = startTimingSpan("createAgentSessionServices.providerRegistrations");
@@ -55100,6 +55345,7 @@ async function createAgentSessionFromServices(options) {
55100
55345
  var init_agent_session_services = __esm(() => {
55101
55346
  init_config();
55102
55347
  init_paths();
55348
+ init_mandatory_resource_loader();
55103
55349
  init_model_runtime();
55104
55350
  init_resource_loader();
55105
55351
  init_sdk();
@@ -55482,6 +55728,7 @@ async function createAgentSession(options = {}) {
55482
55728
  await resourceLoader.reload();
55483
55729
  time("resourceLoader.reload");
55484
55730
  }
55731
+ resourceLoader = await withMandatoryResourceLoader(resourceLoader, cwd);
55485
55732
  const existingSession = sessionManager.buildSessionContext();
55486
55733
  const repairedMessages = repairOrphanToolResults(existingSession.messages, { repairTrailing: true });
55487
55734
  const existingMessages = options.initialContextTransform ? options.initialContextTransform(repairedMessages) : repairedMessages;
@@ -55707,6 +55954,7 @@ var init_sdk = __esm(() => {
55707
55954
  init_agent_session();
55708
55955
  init_auth_guidance();
55709
55956
  init_codex_fast_mode();
55957
+ init_mandatory_resource_loader();
55710
55958
  init_messages();
55711
55959
  init_model_resolver();
55712
55960
  init_model_runtime();
@@ -56283,8 +56531,14 @@ var init_list_models = __esm(() => {
56283
56531
 
56284
56532
  // src/cli/startup-ui.ts
56285
56533
  import { existsSync as existsSync45 } from "node:fs";
56286
- import { ProcessTerminal, setKeybindings, TuiMainScreen } from "@earendil-works/pi-tui";
56534
+ import {
56535
+ ProcessTerminal,
56536
+ setCapabilityOverrides,
56537
+ setKeybindings,
56538
+ TuiMainScreen
56539
+ } from "@earendil-works/pi-tui";
56287
56540
  function createStartupTui(settingsManager) {
56541
+ setCapabilityOverrides(settingsManager.getTerminalCapabilityOverrides());
56288
56542
  initTheme(settingsManager.getTheme());
56289
56543
  setKeybindings(KeybindingsManager.create());
56290
56544
  const ui = new TuiMainScreen(new ProcessTerminal, settingsManager.getShowHardwareCursor(), getAgentDir());
@@ -58114,8 +58368,9 @@ async function applyCliRuntimeApiKey(modelRuntime, providerId, apiKey, signal) {
58114
58368
  }
58115
58369
 
58116
58370
  // src/cli/session-picker.ts
58117
- import { ProcessTerminal as ProcessTerminal2, setKeybindings as setKeybindings2, TuiMainScreen as TuiMainScreen2 } from "@earendil-works/pi-tui";
58118
- async function selectSession(currentSessionsLoader, allSessionsLoader) {
58371
+ import { ProcessTerminal as ProcessTerminal2, setCapabilityOverrides as setCapabilityOverrides2, setKeybindings as setKeybindings2, TuiMainScreen as TuiMainScreen2 } from "@earendil-works/pi-tui";
58372
+ async function selectSession(currentSessionsLoader, allSessionsLoader, settingsManager) {
58373
+ setCapabilityOverrides2(settingsManager.getTerminalCapabilityOverrides());
58119
58374
  return new Promise((resolve23) => {
58120
58375
  const ui = new TuiMainScreen2(new ProcessTerminal2, undefined, getAgentDir());
58121
58376
  const keybindings = KeybindingsManager.create();
@@ -58153,7 +58408,7 @@ var init_session_picker = __esm(() => {
58153
58408
 
58154
58409
  // src/main-session.ts
58155
58410
  import { createInterface as createInterface3 } from "node:readline";
58156
- import { ProcessTerminal as ProcessTerminal3, setKeybindings as setKeybindings3, TuiMainScreen as TuiMainScreen3 } from "@earendil-works/pi-tui";
58411
+ import { ProcessTerminal as ProcessTerminal3, setCapabilityOverrides as setCapabilityOverrides3, setKeybindings as setKeybindings3, TuiMainScreen as TuiMainScreen3 } from "@earendil-works/pi-tui";
58157
58412
  import chalk10 from "chalk";
58158
58413
  async function findLocalSessionByExactId(sessionId, cwd, sessionDir) {
58159
58414
  const localSessions = await SessionManager.list(cwd, sessionDir);
@@ -58292,7 +58547,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
58292
58547
  if (parsed.resume) {
58293
58548
  initTheme(settingsManager.getTheme(), true);
58294
58549
  try {
58295
- const selectedPath = await selectSession((onProgress) => SessionManager.list(cwd, sessionDir, onProgress), (onProgress) => SessionManager.listAll(sessionDir, onProgress));
58550
+ const selectedPath = await selectSession((onProgress) => SessionManager.list(cwd, sessionDir, onProgress), (onProgress) => SessionManager.listAll(sessionDir, onProgress), settingsManager);
58296
58551
  if (!selectedPath) {
58297
58552
  console.log(chalk10.dim("No session selected"));
58298
58553
  process.exit(0);
@@ -58315,6 +58570,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
58315
58570
  return SessionManager.create(cwd, sessionDir, { id: parsed.sessionId });
58316
58571
  }
58317
58572
  async function promptForMissingSessionCwd(issue, settingsManager) {
58573
+ setCapabilityOverrides3(settingsManager.getTerminalCapabilityOverrides());
58318
58574
  initTheme(settingsManager.getTheme());
58319
58575
  setKeybindings3(KeybindingsManager.create());
58320
58576
  return new Promise((resolve23) => {
@@ -61900,7 +62156,7 @@ var init_slash_commands = __esm(() => {
61900
62156
  { name: "tree", description: "Navigate session tree (switch branches)" },
61901
62157
  { name: "thinking", description: "Set thinking level", argumentHint: "<level>" },
61902
62158
  { name: "scoped-models", description: "Enable/disable models for ctrl+p cycling" },
61903
- { name: "fast", description: "Configure OpenAI fast mode for chat and workflows in supported models" },
62159
+ { name: "fast", description: "Configure fast mode for chat and workflows on supported models" },
61904
62160
  { name: "export", description: "Export session (HTML default, or specify path: .html/.jsonl)" },
61905
62161
  { name: "import", description: "Import and resume a session from a JSONL file" },
61906
62162
  { name: "share", description: "Share session as a secret GitHub gist" },
@@ -62536,6 +62792,7 @@ function createFullscreenTui(options) {
62536
62792
  openUrl: openBrowser
62537
62793
  }),
62538
62794
  onRightClickPaste: options.onRightClickPaste,
62795
+ copyOnSelect: options.copyOnSelect,
62539
62796
  copySelection: options.copySelection ?? copySelectionToHostClipboard
62540
62797
  }, options.shouldHandleViewportInput, options.onOverlayUnhandledInput);
62541
62798
  }
@@ -62577,7 +62834,7 @@ function createInteractiveTuiReference(getTui) {
62577
62834
  getPrototypeOf: () => Reflect.getPrototypeOf(getTui())
62578
62835
  });
62579
62836
  }
62580
- var viewportInputListeners, viewportInputGates, overlayUnhandledInputHandlers, viewportInputReplays, viewportInputSubscriptions, SGR_MOUSE_SEQUENCE, LEFT_MOUSE_MODIFIER_MASK, AtomicTuiAltScreen, AtomicTuiMainScreen;
62837
+ var viewportInputListeners, viewportInputGates, overlayUnhandledInputHandlers, viewportInputReplays, overlayOwnedSelections, viewportInputSubscriptions, SGR_MOUSE_SEQUENCE, LEFT_MOUSE_MODIFIER_MASK, AtomicTuiAltScreen, AtomicTuiMainScreen;
62581
62838
  var init_interactive_tui = __esm(() => {
62582
62839
  init_clipboard();
62583
62840
  init_open_browser();
@@ -62586,6 +62843,7 @@ var init_interactive_tui = __esm(() => {
62586
62843
  viewportInputGates = new WeakMap;
62587
62844
  overlayUnhandledInputHandlers = new WeakMap;
62588
62845
  viewportInputReplays = new WeakSet;
62846
+ overlayOwnedSelections = new WeakSet;
62589
62847
  viewportInputSubscriptions = new WeakMap;
62590
62848
  SGR_MOUSE_SEQUENCE = /^\x1b\[<(\d+);\d+;\d+([Mm])/;
62591
62849
  LEFT_MOUSE_MODIFIER_MASK = 4 | 8 | 16;
@@ -62601,8 +62859,20 @@ var init_interactive_tui = __esm(() => {
62601
62859
  deferral.shouldDeferViewportInputToOverlay = () => !viewportInputReplays.has(this) && deferToOverlay?.() === true;
62602
62860
  }
62603
62861
  applyLineResets(lines) {
62862
+ if (overlayOwnedSelections.has(this) && !this.isFocusedOverlay())
62863
+ this.clearOverlayOwnedSelection();
62604
62864
  return stripOverlayActiveRowMarker(super.applyLineResets(lines));
62605
62865
  }
62866
+ clearOverlayOwnedSelection() {
62867
+ const selection = this;
62868
+ selection.selectionAnchor = undefined;
62869
+ selection.selectionFocus = undefined;
62870
+ selection.selectionInitialRange = undefined;
62871
+ selection.selectionPressActive = false;
62872
+ selection.selectionDragged = false;
62873
+ selection.lastClick = undefined;
62874
+ overlayOwnedSelections.delete(this);
62875
+ }
62606
62876
  isPiTuiMouseSequence(data) {
62607
62877
  if (parseMouseSequences(data))
62608
62878
  return true;
@@ -62679,6 +62949,7 @@ var init_interactive_tui = __esm(() => {
62679
62949
  if (isLeftMouseButton(sequence))
62680
62950
  viewportListener(sequence.data);
62681
62951
  }
62952
+ overlayOwnedSelections.add(this);
62682
62953
  }
62683
62954
  replayViewportInput(viewportListener, data) {
62684
62955
  viewportInputReplays.add(this);
@@ -62746,7 +63017,11 @@ var init_interactive_tui = __esm(() => {
62746
63017
  });
62747
63018
 
62748
63019
  // src/modes/interactive/interactive-mode-base.ts
62749
- import { isKeyRelease as isKeyRelease3, isViewportTUI } from "@earendil-works/pi-tui";
63020
+ import {
63021
+ isKeyRelease as isKeyRelease3,
63022
+ isViewportTUI,
63023
+ setCapabilityOverrides as setCapabilityOverrides4
63024
+ } from "@earendil-works/pi-tui";
62750
63025
  function isFullscreenViewportAction(data, keybindings) {
62751
63026
  return FULLSCREEN_VIEWPORT_ACTIONS.some((action) => keybindings.matches(data, action));
62752
63027
  }
@@ -62807,6 +63082,18 @@ class InteractiveModeBase {
62807
63082
  return false;
62808
63083
  return this.defaultEditor.handleInput(data);
62809
63084
  }
63085
+ setFullscreenCopyOnSelect(enabled) {
63086
+ if (this.renderer.mode === "fullscreen")
63087
+ this.renderer.setCopyOnSelect(enabled);
63088
+ }
63089
+ getFullscreenCopyOnSelect() {
63090
+ return this.renderer.mode === "fullscreen" ? this.renderer.getCopyOnSelect() : undefined;
63091
+ }
63092
+ async copyActiveFullscreenSelection() {
63093
+ if (this.renderer.mode !== "fullscreen" || !this.renderer.hasActiveSelection())
63094
+ return;
63095
+ return this.renderer.copyActiveSelectionToClipboard();
63096
+ }
62810
63097
  onRightClickPaste = () => {
62811
63098
  this.handleRightClickPaste();
62812
63099
  };
@@ -63006,11 +63293,13 @@ class InteractiveModeBase {
63006
63293
  await this.rebindCurrentSession();
63007
63294
  await this.themeController.applyFromSettings();
63008
63295
  });
63296
+ setCapabilityOverrides4(this.settingsManager.getTerminalCapabilityOverrides());
63009
63297
  this.version = VERSION;
63010
63298
  this.renderer = createInteractiveTui({
63011
63299
  showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
63012
63300
  logDirectory: runtimeHost.services.agentDir,
63013
63301
  terminal: options.terminal,
63302
+ copyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
63014
63303
  onRightClickPaste: this.onRightClickPaste,
63015
63304
  shouldHandleViewportInput: this.shouldHandleViewportInput,
63016
63305
  onOverlayUnhandledInput: this.onOverlayUnhandledInput,
@@ -64133,6 +64422,7 @@ var init_interactive_deferred_startup = __esm(() => {
64133
64422
  try {
64134
64423
  await this.bindCurrentSessionExtensions();
64135
64424
  await this.session.reload({ reason: "startup" });
64425
+ this.applyRuntimeSettings();
64136
64426
  this.rebuildChatFromMessages();
64137
64427
  if (!this.promptTurnWorkingLoaderActive) {
64138
64428
  this.stopWorkingLoader();
@@ -64821,6 +65111,7 @@ ${warningLines}`, 0, 0));
64821
65111
  });
64822
65112
 
64823
65113
  // src/modes/interactive/interactive-session-runtime.ts
65114
+ import { setCapabilityOverrides as setCapabilityOverrides5 } from "@earendil-works/pi-tui";
64824
65115
  var init_interactive_session_runtime = __esm(() => {
64825
65116
  init_interactive_mode_base();
64826
65117
  init_interactive_mode_deps();
@@ -64907,6 +65198,8 @@ var init_interactive_session_runtime = __esm(() => {
64907
65198
  }
64908
65199
  };
64909
65200
  InteractiveModeBase.prototype.applyRuntimeSettings = function() {
65201
+ setCapabilityOverrides5(this.settingsManager.getTerminalCapabilityOverrides());
65202
+ this.setFullscreenCopyOnSelect(this.settingsManager.getFullscreenCopyOnSelect());
64910
65203
  this.transcriptScrollView?.setScrollbar(this.settingsManager.getFullscreenScrollbar());
64911
65204
  this.footer.setSession(this.session);
64912
65205
  this.usageMeter.setSession(this.session);
@@ -66423,6 +66716,9 @@ var init_interactive_input_handling = __esm(() => {
66423
66716
  });
66424
66717
  this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
66425
66718
  this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
66719
+ this.defaultEditor.onAction("app.message.copy", () => {
66720
+ this.handleCopyCommand({ preferSelection: true });
66721
+ });
66426
66722
  this.defaultEditor.onAction("app.session.new", () => this.handleClearCommand());
66427
66723
  this.defaultEditor.onAction("app.session.tree", () => this.showTreeSelector());
66428
66724
  this.defaultEditor.onAction("app.session.fork", () => this.showUserMessageSelector());
@@ -67330,7 +67626,8 @@ var init_interactive_agent_events = __esm(() => {
67330
67626
  } else if (event.reason === "manual") {
67331
67627
  this.manualCompactionTakeoverPending = false;
67332
67628
  }
67333
- if (!manualTakeoverPending && this.settingsManager.getShowTerminalProgress()) {
67629
+ const resumesActiveRun = event.midTurn && !event.aborted && !event.errorMessage && !manualTakeoverPending;
67630
+ if (!manualTakeoverPending && !resumesActiveRun && this.settingsManager.getShowTerminalProgress()) {
67334
67631
  this.ui.terminal.setProgress(false);
67335
67632
  }
67336
67633
  if (!manualTakeoverPending && this.autoCompactionEscapeHandlerSaved) {
@@ -68346,7 +68643,7 @@ var init_interactive_selectors = __esm(() => {
68346
68643
  };
68347
68644
  InteractiveModeBase.prototype.showFastModeSelector = function() {
68348
68645
  if (!this.hasCodexFastModeSupportedModels()) {
68349
- this.showWarning("Codex fast mode requires a supported OpenAI or shared ChatGPT Codex transport model.");
68646
+ this.showWarning("Fast mode isn't available for any configured model.");
68350
68647
  return;
68351
68648
  }
68352
68649
  this.showSelector((done) => {
@@ -68405,6 +68702,7 @@ var init_interactive_selectors = __esm(() => {
68405
68702
  showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
68406
68703
  fullscreenScrollbar: this.settingsManager.getFullscreenScrollbar(),
68407
68704
  fullscreenExitOutput: this.settingsManager.getFullscreenExitOutput(),
68705
+ fullscreenCopyOnSelect: this.settingsManager.getFullscreenCopyOnSelect(),
68408
68706
  editorPaddingX: this.settingsManager.getEditorPaddingX(),
68409
68707
  outputPad: this.settingsManager.getOutputPad(),
68410
68708
  showCacheMissNotices: this.settingsManager.getShowCacheMissNotices(),
@@ -68522,6 +68820,10 @@ var init_interactive_selectors = __esm(() => {
68522
68820
  onFullscreenExitOutputChange: (output) => {
68523
68821
  this.settingsManager.setFullscreenExitOutput(output);
68524
68822
  },
68823
+ onFullscreenCopyOnSelectChange: (enabled) => {
68824
+ this.settingsManager.setFullscreenCopyOnSelect(enabled);
68825
+ this.setFullscreenCopyOnSelect(enabled);
68826
+ },
68525
68827
  onEditorPaddingXChange: (padding) => {
68526
68828
  this.settingsManager.setEditorPaddingX(padding);
68527
68829
  this.defaultEditor.setPaddingX(padding);
@@ -69508,18 +69810,8 @@ var init_interactive_slash_commands = __esm(() => {
69508
69810
  activeHeader.setExpanded(this.toolOutputExpanded);
69509
69811
  }
69510
69812
  setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
69511
- this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
69813
+ this.applyRuntimeSettings();
69512
69814
  await this.themeController.applyFromSettings();
69513
- const editorPaddingX = this.settingsManager.getEditorPaddingX();
69514
- const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
69515
- this.defaultEditor.setPaddingX(editorPaddingX);
69516
- this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);
69517
- if (this.editor !== this.defaultEditor) {
69518
- this.editor.setPaddingX?.(editorPaddingX);
69519
- this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);
69520
- }
69521
- this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());
69522
- this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
69523
69815
  this.setupAutocompleteProvider();
69524
69816
  const runner = this.session.extensionRunner;
69525
69817
  this.setupExtensionShortcuts(runner);
@@ -69712,7 +70004,12 @@ Gist: ${hyperlink3(gistUrl, gistUrl)}`);
69712
70004
  }
69713
70005
  }
69714
70006
  };
69715
- InteractiveModeBase.prototype.handleCopyCommand = async function() {
70007
+ InteractiveModeBase.prototype.handleCopyCommand = async function(options = {}) {
70008
+ if (options.preferSelection && this.getFullscreenCopyOnSelect() === false) {
70009
+ const selectionCopied = await this.copyActiveFullscreenSelection();
70010
+ if (selectionCopied !== undefined)
70011
+ return;
70012
+ }
69716
70013
  const text = this.session.getLastAssistantText();
69717
70014
  if (!text) {
69718
70015
  this.showError("No agent messages to copy yet.");
@@ -73766,6 +74063,8 @@ var init_rpc_extension_ui = __esm(() => {
73766
74063
  });
73767
74064
 
73768
74065
  // src/modes/rpc/rpc-session-binding.ts
74066
+ import { setCapabilityOverrides as setCapabilityOverrides6 } from "@earendil-works/pi-tui";
74067
+
73769
74068
  class RpcSessionBinding {
73770
74069
  session;
73771
74070
  unsubscribe;
@@ -73809,6 +74108,7 @@ class RpcSessionBinding {
73809
74108
  this.session = this.runtimeHost.session;
73810
74109
  this.disposeSubscriptions();
73811
74110
  const session = this.session;
74111
+ setCapabilityOverrides6(session.settingsManager.getTerminalCapabilityOverrides());
73812
74112
  this.renderService?.bindSession(session);
73813
74113
  this.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());
73814
74114
  const models = session.scopedModels.length > 0 ? session.scopedModels.map((scoped) => scoped.model) : session.modelRuntime.getAvailableSnapshot();
@@ -74704,8 +75004,9 @@ var init_config_selector = __esm(() => {
74704
75004
  });
74705
75005
 
74706
75006
  // src/cli/config-selector.ts
74707
- import { ProcessTerminal as ProcessTerminal6, TuiMainScreen as TuiMainScreen8 } from "@earendil-works/pi-tui";
75007
+ import { ProcessTerminal as ProcessTerminal6, setCapabilityOverrides as setCapabilityOverrides7, TuiMainScreen as TuiMainScreen8 } from "@earendil-works/pi-tui";
74708
75008
  async function selectConfig(options) {
75009
+ setCapabilityOverrides7(options.settingsManager.getTerminalCapabilityOverrides());
74709
75010
  initTheme(options.settingsManager.getTheme(), true);
74710
75011
  return new Promise((resolve23) => {
74711
75012
  const ui = new TuiMainScreen8(new ProcessTerminal6, undefined, options.agentDir);
@@ -75558,6 +75859,7 @@ var init_package_manager_cli = __esm(() => {
75558
75859
  });
75559
75860
 
75560
75861
  // src/main.ts
75862
+ import { setCapabilityOverrides as setCapabilityOverrides8 } from "@earendil-works/pi-tui";
75561
75863
  import chalk15 from "chalk";
75562
75864
  function authCheckErrorMessage(error) {
75563
75865
  return error instanceof AuthCommandError ? error.message : "Failed to check provider readiness";
@@ -75792,6 +76094,7 @@ async function main(argv, options) {
75792
76094
  startupEarlyInputCapture = undefined;
75793
76095
  }
75794
76096
  const startupSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: startupProjectTrusted });
76097
+ setCapabilityOverrides8(startupSettingsManager.getTerminalCapabilityOverrides());
75795
76098
  const startupSettingsDiagnostics = collectSettingsDiagnostics(startupSettingsManager, "startup session lookup");
75796
76099
  if (appMode === "interactive" && parsed.useTheme !== undefined) {
75797
76100
  startupSettingsManager.applyOverrides({ theme: parsed.useTheme });
@@ -75926,6 +76229,8 @@ async function main(argv, options) {
75926
76229
  extensionFactories: isolateInteractiveHost ? undefined : extensionFactories
75927
76230
  }
75928
76231
  });
76232
+ if (isolateInteractiveHost)
76233
+ limitMandatoryIntercomToTool(services2.resourceLoader);
75929
76234
  const { settingsManager: settingsManager2, modelRuntime: modelRuntime2, resourceLoader: resourceLoader2 } = services2;
75930
76235
  const diagnostics = [
75931
76236
  ...services2.diagnostics,
@@ -75988,6 +76293,7 @@ async function main(argv, options) {
75988
76293
  endTimingSpan(runtimeCreationSpan);
75989
76294
  const { services, session, modelFallbackMessage } = runtime;
75990
76295
  const { settingsManager, modelRuntime, resourceLoader } = services;
76296
+ setCapabilityOverrides8(settingsManager.getTerminalCapabilityOverrides());
75991
76297
  applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy);
75992
76298
  configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());
75993
76299
  if (parsed.help) {
@@ -76119,6 +76425,7 @@ var init_main = __esm(() => {
76119
76425
  init_auth_storage();
76120
76426
  init_builtin_packages();
76121
76427
  init_http_dispatcher();
76428
+ init_mandatory_resource_loader();
76122
76429
  init_model_resolver();
76123
76430
  init_model_runtime();
76124
76431
  init_output_guard();
@@ -92658,6 +92965,7 @@ function serializePendingStageMessages(messages2) {
92658
92965
  id: entry.from.id,
92659
92966
  ...entry.from.name !== undefined ? { name: entry.from.name } : {},
92660
92967
  ...entry.from.group !== undefined ? { group: entry.from.group } : {},
92968
+ ...entry.from.groups !== undefined ? { groups: [...entry.from.groups] } : {},
92661
92969
  ...entry.from.cwd !== undefined ? { cwd: entry.from.cwd } : {},
92662
92970
  ...entry.from.model !== undefined ? { model: entry.from.model } : {},
92663
92971
  ...entry.from.pid !== undefined ? { pid: entry.from.pid } : {},
@@ -92699,7 +93007,7 @@ function isPendingStageMessage(value) {
92699
93007
  return typeof value.id === "string" && typeof value.runId === "string" && typeof value.stageKey === "string" && (value.stageId === undefined || typeof value.stageId === "string") && (value.stageReplayKey === undefined || typeof value.stageReplayKey === "string") && (value.senderRegistrationName === undefined || typeof value.senderRegistrationName === "string") && (value.senderReturnAddress === undefined || typeof value.senderReturnAddress === "string") && typeof value.queuedAt === "string" && (value.admissionOrder === undefined || typeof value.admissionOrder === "number" && Number.isSafeInteger(value.admissionOrder) && value.admissionOrder > 0) && (value.status === "queued" || value.status === "delivered" || value.status === "undeliverable") && (value.deliveredAt === undefined || typeof value.deliveredAt === "string") && (value.undeliverableReason === undefined || typeof value.undeliverableReason === "string") && (value.undeliverableNotificationId === undefined || typeof value.undeliverableNotificationId === "string") && (value.undeliverableNotifiedAt === undefined || typeof value.undeliverableNotifiedAt === "string") && isPendingStageSender(value.from) && isPendingStageIntercomMessage(value.message);
92700
93008
  }
92701
93009
  function isPendingStageSender(value) {
92702
- return isSerializableObject(value) && typeof value.id === "string" && (value.name === undefined || typeof value.name === "string") && (value.group === undefined || typeof value.group === "string") && (value.cwd === undefined || typeof value.cwd === "string") && (value.model === undefined || typeof value.model === "string") && (value.pid === undefined || typeof value.pid === "number") && (value.startedAt === undefined || typeof value.startedAt === "number") && (value.lastActivity === undefined || typeof value.lastActivity === "number") && (value.status === undefined || typeof value.status === "string");
93010
+ return isSerializableObject(value) && typeof value.id === "string" && (value.name === undefined || typeof value.name === "string") && (value.group === undefined || typeof value.group === "string") && (value.groups === undefined || Array.isArray(value.groups) && value.groups.every((group) => typeof group === "string")) && (value.cwd === undefined || typeof value.cwd === "string") && (value.model === undefined || typeof value.model === "string") && (value.pid === undefined || typeof value.pid === "number") && (value.startedAt === undefined || typeof value.startedAt === "number") && (value.lastActivity === undefined || typeof value.lastActivity === "number") && (value.status === undefined || typeof value.status === "string");
92703
93011
  }
92704
93012
  function isPendingStageIntercomMessage(value) {
92705
93013
  if (!isSerializableObject(value) || typeof value.id !== "string" || typeof value.timestamp !== "number")
@@ -93233,8 +93541,8 @@ class DbosDurableBackend {
93233
93541
  locallyRegistered = new Set;
93234
93542
  promptReservations;
93235
93543
  executorId;
93236
- writeQueue = Promise.resolve();
93237
- writeErrors = [];
93544
+ writeQueues = new Map;
93545
+ writeErrors = new Map;
93238
93546
  constructor(sdk, options) {
93239
93547
  this.sdk = sdk;
93240
93548
  this.executorId = options?.executorId ?? getAtomicExecutorId();
@@ -93242,7 +93550,7 @@ class DbosDurableBackend {
93242
93550
  pendingPrompts: (workflowId) => this.mem.getWorkflow(workflowId)?.pendingPrompts ?? 0,
93243
93551
  adjustPendingPrompts: (workflowId, delta) => this.mem.adjustPendingPrompts(workflowId, delta),
93244
93552
  persist: (workflowId, stepName, output) => {
93245
- this.enqueueWrite(() => this.sdk.recordStepOutput(workflowId, stepName, output));
93553
+ this.enqueueWrite(workflowId, () => this.sdk.recordStepOutput(workflowId, stepName, output));
93246
93554
  }
93247
93555
  });
93248
93556
  }
@@ -93255,14 +93563,14 @@ class DbosDurableBackend {
93255
93563
  this.locallyRegistered.add(handle.workflowId);
93256
93564
  const pendingPrompts2 = this.promptReservations.registerWorkflow(handle.workflowId, handle.pendingPrompts, this.mem.getWorkflow(handle.workflowId)?.pendingPrompts ?? 0);
93257
93565
  this.mem.registerWorkflow({ ...handle, pendingPrompts: pendingPrompts2 });
93258
- this.enqueueWrite(async () => {
93566
+ this.enqueueWrite(handle.workflowId, async () => {
93259
93567
  await this.sdk.startWorkflow(handle.workflowId, handle.name, handle.inputs);
93260
93568
  await this.writeMetadata(handle.workflowId);
93261
93569
  });
93262
93570
  }
93263
93571
  async persistPendingStageMessages(workflowId, messages2, logicalRunId = workflowId) {
93264
93572
  let persisted = false;
93265
- await this.enqueueWrite(async () => {
93573
+ await this.enqueueWrite(workflowId, async () => {
93266
93574
  if (!this.isWorkflowLoadable(workflowId))
93267
93575
  return;
93268
93576
  const handle = this.mem.getWorkflow(workflowId);
@@ -93287,7 +93595,7 @@ class DbosDurableBackend {
93287
93595
  if (!this.isWorkflowLoadable(checkpoint.workflowId))
93288
93596
  return;
93289
93597
  this.mem.recordCheckpoint(checkpoint);
93290
- this.enqueueWrite(() => this.persistCheckpoint(checkpoint));
93598
+ this.enqueueWrite(checkpoint.workflowId, () => this.persistCheckpoint(checkpoint));
93291
93599
  }
93292
93600
  async recordCheckpointAsync(checkpoint, options) {
93293
93601
  if (!this.isWorkflowLoadable(checkpoint.workflowId))
@@ -93295,7 +93603,7 @@ class DbosDurableBackend {
93295
93603
  const signal = options?.signal;
93296
93604
  if (signal?.aborted)
93297
93605
  throw abortSignalReason(signal);
93298
- await this.enqueueWrite(async () => {
93606
+ await this.enqueueWrite(checkpoint.workflowId, async () => {
93299
93607
  if (signal?.aborted || !this.isWorkflowLoadable(checkpoint.workflowId))
93300
93608
  return;
93301
93609
  const persist = (async () => {
@@ -93332,7 +93640,7 @@ class DbosDurableBackend {
93332
93640
  if (!this.isWorkflowLoadable(checkpoint.workflowId))
93333
93641
  return true;
93334
93642
  const encoded = encodeCheckpoint(checkpoint);
93335
- return await this.enqueueBestEffortWrite(async () => {
93643
+ return await this.enqueueBestEffortWrite(checkpoint.workflowId, async () => {
93336
93644
  if (!this.isWorkflowLoadable(checkpoint.workflowId))
93337
93645
  return;
93338
93646
  await this.sdk.recordStepOutput(checkpoint.workflowId, checkpoint.checkpointId, encoded);
@@ -93377,7 +93685,7 @@ class DbosDurableBackend {
93377
93685
  this.promptReservations.setBaseline(workflowId, pendingPrompts2);
93378
93686
  }
93379
93687
  this.mem.setWorkflowStatus(workflowId, status, pendingPrompts2, resumable, failure2);
93380
- this.enqueueWrite(async () => {
93688
+ this.enqueueWrite(workflowId, async () => {
93381
93689
  if (!this.isWorkflowLoadable(workflowId))
93382
93690
  return;
93383
93691
  if (status === "cancelled")
@@ -93391,14 +93699,14 @@ class DbosDurableBackend {
93391
93699
  return await transitionDbosWorkflowStatus({
93392
93700
  expectedStatuses: expected,
93393
93701
  status,
93394
- flush: () => this.flush(),
93702
+ flush: () => this.flush(workflowId),
93395
93703
  local: () => this.getLoadableWorkflow(workflowId),
93396
93704
  read: async () => classifyLatestMetadata(await this.sdk.listStepRecords(workflowId), workflowId),
93397
93705
  reconcile: (entry) => this.mem.setWorkflowStatus(workflowId, entry.status, undefined, entry.resumable),
93398
93706
  claim: (authoritative, generation) => this.claimStatusTransition(workflowId, authoritative, generation, status, pendingPrompts2, resumable),
93399
93707
  write: async () => {
93400
93708
  this.setWorkflowStatus(workflowId, status, pendingPrompts2, resumable);
93401
- await this.flush();
93709
+ await this.flush(workflowId);
93402
93710
  }
93403
93711
  });
93404
93712
  }
@@ -93460,13 +93768,13 @@ class DbosDurableBackend {
93460
93768
  this.locallyRegistered.delete(workflowId);
93461
93769
  this.promptReservations.delete(workflowId);
93462
93770
  await this.mem.deleteWorkflow(workflowId);
93463
- await this.enqueueWrite(async () => {
93771
+ await this.enqueueWrite(workflowId, async () => {
93464
93772
  await this.sdk.deleteWorkflowData(workflowId);
93465
93773
  await this.sdk.recordStepOutput(workflowId, DBOS_DELETION_STEP, encodeDbosDeletionTombstone(workflowId));
93466
93774
  });
93467
93775
  }
93468
93776
  async deleteWorkflowIfInactive(workflowId) {
93469
- await this.flush();
93777
+ await this.flush(workflowId);
93470
93778
  await this.hydrateWorkflow(workflowId);
93471
93779
  const handle = this.getLoadableWorkflow(workflowId);
93472
93780
  if (handle === undefined)
@@ -93477,7 +93785,7 @@ class DbosDurableBackend {
93477
93785
  if (!guarded)
93478
93786
  return { ok: false, reason: "running" };
93479
93787
  await this.deleteWorkflow(workflowId);
93480
- await this.flush();
93788
+ await this.flush(workflowId);
93481
93789
  return { ok: true };
93482
93790
  }
93483
93791
  isWorkflowLoadable(workflowId) {
@@ -93489,16 +93797,19 @@ class DbosDurableBackend {
93489
93797
  this.current.clear();
93490
93798
  this.locallyRegistered.clear();
93491
93799
  this.promptReservations.clear();
93492
- this.writeQueue = Promise.resolve();
93493
- this.writeErrors = [];
93494
- }
93495
- async flush() {
93496
- await this.writeQueue;
93497
- if (this.writeErrors.length === 0)
93498
- return;
93499
- const [first] = this.writeErrors;
93500
- this.writeErrors = [];
93501
- throw first;
93800
+ this.writeQueues.clear();
93801
+ this.writeErrors.clear();
93802
+ }
93803
+ async flush(workflowId) {
93804
+ const workflowIds = workflowId === undefined ? [...new Set([...this.writeQueues.keys(), ...this.writeErrors.keys()])] : [workflowId];
93805
+ await Promise.all(workflowIds.map(async (id) => await this.writeQueues.get(id)));
93806
+ for (const id of workflowIds) {
93807
+ const errors = this.writeErrors.get(id);
93808
+ if (errors === undefined || errors.length === 0)
93809
+ continue;
93810
+ this.writeErrors.delete(id);
93811
+ throw errors[0];
93812
+ }
93502
93813
  }
93503
93814
  async hydrateWorkflow(workflowId) {
93504
93815
  await this.hydrateWorkflowForInspection(workflowId);
@@ -93592,21 +93903,33 @@ class DbosDurableBackend {
93592
93903
  this.promptReservations.delete(workflowId);
93593
93904
  await this.mem.deleteWorkflow(workflowId);
93594
93905
  }
93595
- enqueueWrite(fn) {
93596
- const next = this.writeQueue.then(fn, fn);
93597
- this.writeQueue = next.catch((err) => {
93906
+ enqueueWrite(workflowId, fn) {
93907
+ const previous2 = this.writeQueues.get(workflowId) ?? Promise.resolve();
93908
+ const next = previous2.then(fn, fn);
93909
+ const tracked = next.catch((err) => {
93598
93910
  const error = err instanceof Error ? err : new Error(String(err));
93599
- this.writeErrors.push(error);
93911
+ const errors = this.writeErrors.get(workflowId) ?? [];
93912
+ errors.push(error);
93913
+ this.writeErrors.set(workflowId, errors);
93600
93914
  });
93915
+ this.trackWriteQueue(workflowId, tracked);
93601
93916
  return next;
93602
93917
  }
93603
- async enqueueBestEffortWrite(fn) {
93604
- const next = this.writeQueue.then(fn, fn);
93605
- this.writeQueue = next.catch(() => {
93918
+ async enqueueBestEffortWrite(workflowId, fn) {
93919
+ const previous2 = this.writeQueues.get(workflowId) ?? Promise.resolve();
93920
+ const next = previous2.then(fn, fn);
93921
+ this.trackWriteQueue(workflowId, next.catch(() => {
93606
93922
  return;
93607
- });
93923
+ }));
93608
93924
  return await next.then(() => true, () => false);
93609
93925
  }
93926
+ trackWriteQueue(workflowId, queue) {
93927
+ this.writeQueues.set(workflowId, queue);
93928
+ queue.finally(() => {
93929
+ if (this.writeQueues.get(workflowId) === queue)
93930
+ this.writeQueues.delete(workflowId);
93931
+ });
93932
+ }
93610
93933
  async writeMetadata(workflowId) {
93611
93934
  const value = this.mem.toMetadata(workflowId);
93612
93935
  if (value === undefined)
@@ -96610,7 +96933,7 @@ async function markDurableQuit(runId, run) {
96610
96933
  if (!transitioned)
96611
96934
  return "refused";
96612
96935
  recordRunTimingCheckpoint(backend, run);
96613
- await backend.flush();
96936
+ await backend.flush(runId);
96614
96937
  return "transitioned";
96615
96938
  }
96616
96939
  function discoverDurableQuitBackend(runId) {
@@ -96838,7 +97161,7 @@ async function markDurableResumed(runId) {
96838
97161
  const authoritative = getLoadableDurableWorkflow(backend, runId);
96839
97162
  return authoritative?.status === "running" ? "not_needed" : "refused";
96840
97163
  }
96841
- await backend.flush();
97164
+ await backend.flush(runId);
96842
97165
  pending.delete(runId);
96843
97166
  return "transitioned";
96844
97167
  } catch (error) {
@@ -101136,6 +101459,10 @@ var orchestratorModelConfig = {
101136
101459
  "github-copilot/grok-4.6:xhigh",
101137
101460
  "zai/glm-5.3:high",
101138
101461
  "zai-coding-cn/glm-5.3:high",
101462
+ "zai/glm-5.3-flash:high",
101463
+ "zai-coding-cn/glm-5.3-flash:high",
101464
+ "baseten/zai-org/GLM-5.3:high",
101465
+ "baseten/zai-org/GLM-5.3-Flash:high",
101139
101466
  "openrouter/anthropic/claude-opus-5:high",
101140
101467
  "openrouter/openai/gpt-5.6-sol:xhigh",
101141
101468
  "openrouter/anthropic/claude-fable-5:high",
@@ -101143,7 +101470,9 @@ var orchestratorModelConfig = {
101143
101470
  "openrouter/sakana/fugu-ultra:high",
101144
101471
  "openrouter/openai/gpt-5.5:xhigh",
101145
101472
  "openrouter/anthropic/claude-opus-4-8:high",
101146
- "openrouter/x-ai/grok-4.6"
101473
+ "openrouter/x-ai/grok-4.6",
101474
+ "openrouter/z-ai/glm-5.3:high",
101475
+ "openrouter/z-ai/glm-5.3-flash:high"
101147
101476
  ],
101148
101477
  excludedTools: ["ask_user_question"]
101149
101478
  };
@@ -101168,6 +101497,10 @@ var reviewerModelConfig = {
101168
101497
  "github-copilot/grok-4.6:xhigh",
101169
101498
  "zai/glm-5.3:high",
101170
101499
  "zai-coding-cn/glm-5.3:high",
101500
+ "zai/glm-5.3-flash:high",
101501
+ "zai-coding-cn/glm-5.3-flash:high",
101502
+ "baseten/zai-org/GLM-5.3:high",
101503
+ "baseten/zai-org/GLM-5.3-Flash:high",
101171
101504
  "openrouter/anthropic/claude-opus-5:high",
101172
101505
  "openrouter/anthropic/claude-fable-5:high",
101173
101506
  "openrouter/openai/gpt-5.6-sol:xhigh",
@@ -101175,7 +101508,9 @@ var reviewerModelConfig = {
101175
101508
  "openrouter/sakana/fugu-ultra:high",
101176
101509
  "openrouter/openai/gpt-5.5:xhigh",
101177
101510
  "openrouter/anthropic/claude-opus-4-8:high",
101178
- "openrouter/x-ai/grok-4.6"
101511
+ "openrouter/x-ai/grok-4.6",
101512
+ "openrouter/z-ai/glm-5.3:high",
101513
+ "openrouter/z-ai/glm-5.3-flash:high"
101179
101514
  ],
101180
101515
  excludedTools: ["ask_user_question"],
101181
101516
  schema: reviewDecisionSchema
@@ -103271,13 +103606,19 @@ async function runOpenClaudeDesignWorkflow(ctx) {
103271
103606
  "github-copilot/grok-4.6:xhigh",
103272
103607
  "zai/glm-5.3:high",
103273
103608
  "zai-coding-cn/glm-5.3:high",
103609
+ "zai/glm-5.3-flash:high",
103610
+ "zai-coding-cn/glm-5.3-flash:high",
103611
+ "baseten/zai-org/GLM-5.3:high",
103612
+ "baseten/zai-org/GLM-5.3-Flash:high",
103274
103613
  "openrouter/anthropic/claude-opus-5:high",
103275
103614
  "openrouter/anthropic/claude-fable-5:high",
103276
103615
  "openrouter/anthropic/claude-opus-4-8:high",
103277
103616
  "openrouter/moonshotai/kimi-k3:max",
103278
103617
  "openrouter/openai/gpt-5.6-sol:xhigh",
103279
103618
  "openrouter/sakana/fugu-ultra:high",
103280
- "openrouter/x-ai/grok-4.6"
103619
+ "openrouter/x-ai/grok-4.6",
103620
+ "openrouter/z-ai/glm-5.3:high",
103621
+ "openrouter/z-ai/glm-5.3-flash:high"
103281
103622
  ]
103282
103623
  };
103283
103624
  const frontDoor = await runDiscoveryAndInit({
@@ -104298,6 +104639,10 @@ var promptEngineerModelConfig = {
104298
104639
  "github-copilot/grok-4.6:xhigh",
104299
104640
  "zai/glm-5.3:high",
104300
104641
  "zai-coding-cn/glm-5.3:high",
104642
+ "zai/glm-5.3-flash:high",
104643
+ "zai-coding-cn/glm-5.3-flash:high",
104644
+ "baseten/zai-org/GLM-5.3:high",
104645
+ "baseten/zai-org/GLM-5.3-Flash:high",
104301
104646
  "openrouter/anthropic/claude-opus-5:high",
104302
104647
  "openrouter/anthropic/claude-fable-5:high",
104303
104648
  "openrouter/openai/gpt-5.6-sol:xhigh",
@@ -104305,7 +104650,9 @@ var promptEngineerModelConfig = {
104305
104650
  "openrouter/sakana/fugu-ultra:high",
104306
104651
  "openrouter/openai/gpt-5.5:xhigh",
104307
104652
  "openrouter/anthropic/claude-opus-4-8:high",
104308
- "openrouter/x-ai/grok-4.6"
104653
+ "openrouter/x-ai/grok-4.6",
104654
+ "openrouter/z-ai/glm-5.3:high",
104655
+ "openrouter/z-ai/glm-5.3-flash:high"
104309
104656
  ],
104310
104657
  excludedTools: ["ask_user_question"]
104311
104658
  };
@@ -104330,6 +104677,10 @@ var researchModelConfig = {
104330
104677
  "github-copilot/grok-4.6:xhigh",
104331
104678
  "zai/glm-5.3:high",
104332
104679
  "zai-coding-cn/glm-5.3:high",
104680
+ "zai/glm-5.3-flash:high",
104681
+ "zai-coding-cn/glm-5.3-flash:high",
104682
+ "baseten/zai-org/GLM-5.3:high",
104683
+ "baseten/zai-org/GLM-5.3-Flash:high",
104333
104684
  "openrouter/anthropic/claude-opus-5:high",
104334
104685
  "openrouter/openai/gpt-5.6-sol:xhigh",
104335
104686
  "openrouter/anthropic/claude-fable-5:high",
@@ -104337,7 +104688,9 @@ var researchModelConfig = {
104337
104688
  "openrouter/sakana/fugu-ultra:high",
104338
104689
  "openrouter/openai/gpt-5.5:xhigh",
104339
104690
  "openrouter/anthropic/claude-opus-4-8:high",
104340
- "openrouter/x-ai/grok-4.6"
104691
+ "openrouter/x-ai/grok-4.6",
104692
+ "openrouter/z-ai/glm-5.3:high",
104693
+ "openrouter/z-ai/glm-5.3-flash:high"
104341
104694
  ],
104342
104695
  excludedTools: ["ask_user_question"]
104343
104696
  };
@@ -104362,6 +104715,10 @@ var orchestratorModelConfig2 = {
104362
104715
  "github-copilot/grok-4.6:xhigh",
104363
104716
  "zai/glm-5.3:high",
104364
104717
  "zai-coding-cn/glm-5.3:high",
104718
+ "zai/glm-5.3-flash:high",
104719
+ "zai-coding-cn/glm-5.3-flash:high",
104720
+ "baseten/zai-org/GLM-5.3:high",
104721
+ "baseten/zai-org/GLM-5.3-Flash:high",
104365
104722
  "openrouter/anthropic/claude-opus-5:high",
104366
104723
  "openrouter/openai/gpt-5.6-sol:xhigh",
104367
104724
  "openrouter/anthropic/claude-fable-5:high",
@@ -104369,7 +104726,9 @@ var orchestratorModelConfig2 = {
104369
104726
  "openrouter/sakana/fugu-ultra:high",
104370
104727
  "openrouter/openai/gpt-5.5:xhigh",
104371
104728
  "openrouter/anthropic/claude-opus-4-8:high",
104372
- "openrouter/x-ai/grok-4.6"
104729
+ "openrouter/x-ai/grok-4.6",
104730
+ "openrouter/z-ai/glm-5.3:high",
104731
+ "openrouter/z-ai/glm-5.3-flash:high"
104373
104732
  ],
104374
104733
  excludedTools: ["ask_user_question"]
104375
104734
  };
@@ -104394,6 +104753,10 @@ var reviewerAModelConfig = {
104394
104753
  "github-copilot/grok-4.6:xhigh",
104395
104754
  "zai/glm-5.3:high",
104396
104755
  "zai-coding-cn/glm-5.3:high",
104756
+ "zai/glm-5.3-flash:high",
104757
+ "zai-coding-cn/glm-5.3-flash:high",
104758
+ "baseten/zai-org/GLM-5.3:high",
104759
+ "baseten/zai-org/GLM-5.3-Flash:high",
104397
104760
  "openrouter/anthropic/claude-opus-5:high",
104398
104761
  "openrouter/anthropic/claude-fable-5:high",
104399
104762
  "openrouter/moonshotai/kimi-k3:max",
@@ -104401,7 +104764,9 @@ var reviewerAModelConfig = {
104401
104764
  "openrouter/sakana/fugu-ultra:high",
104402
104765
  "openrouter/openai/gpt-5.5:xhigh",
104403
104766
  "openrouter/anthropic/claude-opus-4-8:high",
104404
- "openrouter/x-ai/grok-4.6"
104767
+ "openrouter/x-ai/grok-4.6",
104768
+ "openrouter/z-ai/glm-5.3:high",
104769
+ "openrouter/z-ai/glm-5.3-flash:high"
104405
104770
  ],
104406
104771
  excludedTools: ["ask_user_question"],
104407
104772
  schema: reviewDecisionSchema2
@@ -104427,6 +104792,10 @@ var reviewerBModelConfig = {
104427
104792
  "github-copilot/grok-4.6:xhigh",
104428
104793
  "zai/glm-5.3:high",
104429
104794
  "zai-coding-cn/glm-5.3:high",
104795
+ "zai/glm-5.3-flash:high",
104796
+ "zai-coding-cn/glm-5.3-flash:high",
104797
+ "baseten/zai-org/GLM-5.3:high",
104798
+ "baseten/zai-org/GLM-5.3-Flash:high",
104430
104799
  "openrouter/openai/gpt-5.6-sol:xhigh",
104431
104800
  "openrouter/anthropic/claude-opus-5:high",
104432
104801
  "openrouter/anthropic/claude-fable-5:high",
@@ -104434,7 +104803,9 @@ var reviewerBModelConfig = {
104434
104803
  "openrouter/openai/gpt-5.5:xhigh",
104435
104804
  "openrouter/sakana/fugu-ultra:high",
104436
104805
  "openrouter/anthropic/claude-opus-4-8:high",
104437
- "openrouter/x-ai/grok-4.6"
104806
+ "openrouter/x-ai/grok-4.6",
104807
+ "openrouter/z-ai/glm-5.3:high",
104808
+ "openrouter/z-ai/glm-5.3-flash:high"
104438
104809
  ],
104439
104810
  excludedTools: ["ask_user_question"],
104440
104811
  schema: reviewDecisionSchema2
@@ -105492,6 +105863,8 @@ import { extname as extname2, isAbsolute as isAbsolute20, join as join100, resol
105492
105863
  // dist/builtin/workflows/src/extension/workflow-module-loader.ts
105493
105864
  import { createJiti as createJiti2 } from "jiti/static";
105494
105865
  import * as typeboxModule from "typebox";
105866
+ import * as typeboxCompileModule from "typebox/compile";
105867
+ import * as typeboxValueModule from "typebox/value";
105495
105868
 
105496
105869
  // dist/builtin/workflows/src/sdk-surface.ts
105497
105870
  var exports_sdk_surface = {};
@@ -106830,8 +107203,8 @@ class ScopedDurableBackend {
106830
107203
  async recordAdditiveCheckpointBestEffort(checkpoint) {
106831
107204
  return await this.inner.recordAdditiveCheckpointBestEffort(this.remap(checkpoint));
106832
107205
  }
106833
- flush() {
106834
- return this.inner.flush();
107206
+ flush(workflowId) {
107207
+ return workflowId === undefined ? this.inner.flush() : this.inner.flush(this.scope.rootWorkflowId);
106835
107208
  }
106836
107209
  getToolOutput(_workflowId, argsHash) {
106837
107210
  return this.inner.getToolOutput(this.scope.rootWorkflowId, this.scopeKey(argsHash));
@@ -110185,17 +110558,7 @@ function resolveStageGroup(stageOptions, workflowGroup) {
110185
110558
  const trimmed = group.trim();
110186
110559
  return trimmed.length > 0 ? trimmed : undefined;
110187
110560
  }
110188
- function stageHasIntercomAccess(stageOptions) {
110189
- if (!stageOptions)
110190
- return true;
110191
- if (stageOptions.noTools === "all")
110192
- return false;
110193
- const tools = stageOptions.tools;
110194
- if (Array.isArray(tools) && !tools.includes("intercom"))
110195
- return false;
110196
- const excluded = stageOptions.excludedTools;
110197
- if (Array.isArray(excluded) && excluded.includes("intercom"))
110198
- return false;
110561
+ function stageHasIntercomAccess(_stageOptions) {
110199
110562
  return true;
110200
110563
  }
110201
110564
  function stageCanUseWorkflowPendingStageRoute(stageOptions, workflowGroup) {
@@ -110619,11 +110982,11 @@ function wrapUiWithDurable(base, deps) {
110619
110982
  };
110620
110983
  const releasePending = async (identity, token) => {
110621
110984
  releaseDurablePrompt(deps.backend, deps.workflowId, identity.hash, token);
110622
- await deps.backend.flush();
110985
+ await deps.backend.flush(deps.workflowId);
110623
110986
  };
110624
110987
  const beginPending = (identity) => {
110625
110988
  const token = reserveDurablePrompt(deps.backend, deps.workflowId, identity.hash);
110626
- const write = deps.backend.flush();
110989
+ const write = deps.backend.flush(deps.workflowId);
110627
110990
  return { token, write };
110628
110991
  };
110629
110992
  const waitForPendingWrite = async (identity, pending) => {
@@ -110634,7 +110997,7 @@ function wrapUiWithDurable(base, deps) {
110634
110997
  } catch (error) {
110635
110998
  releaseDurablePrompt(deps.backend, deps.workflowId, identity.hash, pending.token);
110636
110999
  try {
110637
- await deps.backend.flush();
111000
+ await deps.backend.flush(deps.workflowId);
110638
111001
  } catch {}
110639
111002
  throw error;
110640
111003
  }
@@ -110931,7 +111294,7 @@ async function admitDurableRootRun(args) {
110931
111294
  args.backend.setWorkflowStatus(args.runId, "running");
110932
111295
  }
110933
111296
  if (!args.isChildRun)
110934
- await args.backend.flush();
111297
+ await args.backend.flush(args.runId);
110935
111298
  }
110936
111299
 
110937
111300
  // dist/builtin/workflows/src/engine/run-durable-finalize.ts
@@ -110962,7 +111325,7 @@ async function finalizeDurableTerminalStatus(input2) {
110962
111325
  } : undefined;
110963
111326
  input2.durableBackend.setWorkflowStatus(input2.runId, durableStatus, undefined, input2.runSnapshot.resumable, failure2);
110964
111327
  }
110965
- await input2.durableBackend.flush();
111328
+ await input2.durableBackend.flush(input2.runId);
110966
111329
  }
110967
111330
  function toDurableStatus(status) {
110968
111331
  switch (status) {
@@ -111517,7 +111880,7 @@ async function resumeDurableWorkflow(workflowId, deps, catalog) {
111517
111880
  });
111518
111881
  } catch (error) {
111519
111882
  backend.setWorkflowStatus(resolved.workflowId, handle.status, handle.pendingPrompts, handle.resumable);
111520
- await backend.flush();
111883
+ await backend.flush(resolved.workflowId);
111521
111884
  return {
111522
111885
  ok: false,
111523
111886
  reason: "startup_failed",
@@ -111531,7 +111894,7 @@ async function resumeDurableWorkflow(workflowId, deps, catalog) {
111531
111894
  const error = workflowStartupFailureMessage(admission, snapshot2?.error, `Workflow ${resolved.workflowId} ended before startup admission`);
111532
111895
  deps.baseRunOpts.store?.removeRun(accepted2.runId);
111533
111896
  backend.setWorkflowStatus(resolved.workflowId, handle.status, handle.pendingPrompts, handle.resumable);
111534
- await backend.flush();
111897
+ await backend.flush(resolved.workflowId);
111535
111898
  return {
111536
111899
  ok: false,
111537
111900
  reason: "startup_failed",
@@ -117482,7 +117845,7 @@ async function run(def, inputs, opts = {}) {
117482
117845
  const result = normalizeWorkflowRunOutput(def.name, rawResult);
117483
117846
  assertWorkflowRunOutputs(def.name, result, def.outputs);
117484
117847
  assertWorkflowCreatedExecution(runSnapshot);
117485
- await durableBackend.flush();
117848
+ await durableBackend.flush(runId);
117486
117849
  const returned = classifyReturnedRunStatus(result, runSnapshot);
117487
117850
  const recorded = activeStore.recordRunEnd(runId, returned.status, result, returned.error, returned.metadata);
117488
117851
  appendRunEndWhenRecorded(opts.persistence, recorded, {
@@ -117498,7 +117861,7 @@ async function run(def, inputs, opts = {}) {
117498
117861
  if (opts.parentRun === undefined)
117499
117862
  recordRunTimingCheckpoint(durableBackend, runSnapshot);
117500
117863
  durableBackend.setWorkflowStatus(runId, returned.status, undefined, returned.metadata?.resumable);
117501
- await durableBackend.flush();
117864
+ await durableBackend.flush(runId);
117502
117865
  return reconcileTerminalRunResult(runId, runSnapshot, activeStore, { status: returned.status, result, error: returned.error }, opts.onRunEnd);
117503
117866
  } catch (err) {
117504
117867
  terminalEvents.selectFailure(err);
@@ -117655,10 +118018,21 @@ function createWorkflowVirtualModules(moduleSpecifier) {
117655
118018
  [`${builtinModuleSpecifier}/steering-context`]: exports_steering_context
117656
118019
  };
117657
118020
  }
118021
+ var TYPEBOX_COMPILE_MODULE = {
118022
+ ...typeboxCompileModule
118023
+ };
118024
+ var TYPEBOX_VALUE_MODULE = {
118025
+ ...typeboxValueModule
118026
+ };
117658
118027
  var WORKFLOWS_VIRTUAL_MODULES = {
117659
118028
  ...createWorkflowVirtualModules(WORKFLOWS_MODULE_SPECIFIER),
117660
118029
  ...createWorkflowVirtualModules(LEGACY_WORKFLOWS_MODULE_SPECIFIER),
117661
- [TYPEBOX_MODULE_SPECIFIER]: TYPEBOX_MODULE
118030
+ [TYPEBOX_MODULE_SPECIFIER]: TYPEBOX_MODULE,
118031
+ "typebox/compile": TYPEBOX_COMPILE_MODULE,
118032
+ "typebox/value": TYPEBOX_VALUE_MODULE,
118033
+ "@sinclair/typebox": TYPEBOX_MODULE,
118034
+ "@sinclair/typebox/compile": TYPEBOX_COMPILE_MODULE,
118035
+ "@sinclair/typebox/value": TYPEBOX_VALUE_MODULE
117662
118036
  };
117663
118037
  var workflowModuleLoader = createJiti2(import.meta.url, {
117664
118038
  moduleCache: false,
@@ -118035,7 +118409,7 @@ async function discardUnadmittedRun(runId, activeStore) {
118035
118409
  const handle = backend.getWorkflow(runId);
118036
118410
  if (handle?.status === "running") {
118037
118411
  backend.setWorkflowStatus(runId, "failed", handle.pendingPrompts, false);
118038
- await backend.flush();
118412
+ await backend.flush(runId);
118039
118413
  }
118040
118414
  const deleted = await backend.deleteWorkflowIfInactive(runId);
118041
118415
  if (!deleted.ok && deleted.reason !== "not_found") {
@@ -118198,7 +118572,7 @@ async function discardFailedActiveBlockedContinuation(backend, runId, store2) {
118198
118572
  const handle = backend.getWorkflow(runId);
118199
118573
  if (handle?.status === "running") {
118200
118574
  backend.setWorkflowStatus(runId, "failed", handle.pendingPrompts, false);
118201
- await backend.flush();
118575
+ await backend.flush(runId);
118202
118576
  }
118203
118577
  const deleted = await backend.deleteWorkflowIfInactive(runId);
118204
118578
  if (!deleted.ok && deleted.reason !== "not_found") {
@@ -119032,7 +119406,7 @@ function formatWorkflowHeartbeatNoticeText(details) {
119032
119406
  const workflowName = escapeQuotedText3(details.workflowName);
119033
119407
  const elapsed = formatWorkflowHeartbeatElapsed(details);
119034
119408
  const cadence = formatWorkflowHeartbeatCadence(details.intervalMinutes);
119035
- return `${WORKFLOW_HEARTBEAT_GLYPH} Workflow "${workflowName}" heartbeat (run ${details.runId}) — still running` + `${elapsed === undefined ? "" : ` after ${elapsed}`}, on a ${cadence} cadence. ` + "This is a periodic alignment check. Review whether the run is still on goal. " + "When steering or communication is useful, use Intercom. Consider the expanded workflow topology and match " + "each update's reach to its impact: send a local update to its affected stage; when shared scope or acceptance " + "criteria change, send the same authoritative Intercom update to every relevant live and known unstarted " + "`<runId>:<stageKey>`, including each worker-to-reviewer loop. Intercom delivers immediately to live stages and " + "queues updates for known stages that have not started, delivering them before their first model turn, so workers " + "and reviewers begin with one consistent contract. " + "Use `ask` once the target has a live session that can reply. " + "Use workflow pause, resume, interrupt, or quit for run control. " + "Continue the progressing run when no intervention is needed, or ask the user when a decision is needed. " + `Inspect: /workflow status ${details.runId}`;
119409
+ return `${WORKFLOW_HEARTBEAT_GLYPH} Workflow "${workflowName}" heartbeat (run ${details.runId}) — still running` + `${elapsed === undefined ? "" : ` after ${elapsed}`}, on a ${cadence} cadence. ` + "This is a periodic alignment check. Review whether the run is still on goal. " + "When steering or communication is useful, use Intercom. Before steering a stage, join its invocation group. " + "Use the Intercom `groups` action to discover it. Workflow invocation groups are named `workflow:<rootRunId>`. " + "Consider the expanded workflow topology and match each update's reach to its impact: send a local update to " + "its affected stage; when shared scope or acceptance " + "criteria change, send the same authoritative Intercom update to every relevant live and known unstarted " + "`<runId>:<stageKey>`, including each worker-to-reviewer loop. Intercom delivers immediately to live stages and " + "queues updates for known stages that have not started, delivering them before their first model turn, so workers " + "and reviewers begin with one consistent contract. " + "Use `ask` once the target has a live session that can reply. " + "Use workflow pause, resume, interrupt, or quit for run control. " + "Continue the progressing run when no intervention is needed, or ask the user when a decision is needed. " + `Inspect: /workflow status ${details.runId}`;
119036
119410
  }
119037
119411
  function registerWorkflowHeartbeatRenderer(options) {
119038
119412
  const register = options.registerMessageRenderer;
@@ -119702,6 +120076,9 @@ function workflowModelCatalogFromContext(ctx) {
119702
120076
  };
119703
120077
  }
119704
120078
 
120079
+ // dist/builtin/workflows/src/extension/workflow-ports.ts
120080
+ init_src();
120081
+
119705
120082
  // dist/builtin/workflows/src/extension/mcp.ts
119706
120083
  init_src();
119707
120084
  function setMcpScope(pi, opts) {
@@ -119736,19 +120113,30 @@ function clearMcpScope(pi, stageId) {
119736
120113
  }
119737
120114
 
119738
120115
  // dist/builtin/workflows/src/extension/workflow-ports.ts
120116
+ function unlessStale(append) {
120117
+ try {
120118
+ return append();
120119
+ } catch (error) {
120120
+ if (isStaleExtensionContextError(error))
120121
+ return;
120122
+ throw error;
120123
+ }
120124
+ }
119739
120125
  function makePersistencePort(pi, persistRuns) {
119740
120126
  if (!persistRuns)
119741
120127
  return;
119742
120128
  if (typeof pi.appendEntry !== "function")
119743
120129
  return;
119744
120130
  const port = {
119745
- appendEntry: (type, payload) => pi.appendEntry(type, payload)
120131
+ appendEntry: (type, payload) => unlessStale(() => pi.appendEntry(type, payload))
119746
120132
  };
119747
120133
  if (typeof pi.setLabel === "function") {
119748
- port.setLabel = (entryId, label) => pi.setLabel(entryId, label);
120134
+ port.setLabel = (entryId, label) => {
120135
+ unlessStale(() => pi.setLabel(entryId, label));
120136
+ };
119749
120137
  }
119750
120138
  if (typeof pi.appendCustomMessageEntry === "function") {
119751
- port.appendCustomMessageEntry = (content, meta2) => pi.appendCustomMessageEntry(content, meta2);
120139
+ port.appendCustomMessageEntry = (content, meta2) => unlessStale(() => pi.appendCustomMessageEntry(content, meta2));
119752
120140
  }
119753
120141
  return port;
119754
120142
  }
@@ -124570,7 +124958,7 @@ function renderResult(result, opts) {
124570
124958
  }
124571
124959
 
124572
124960
  // dist/builtin/workflows/src/extension/workflow-prompts.ts
124573
- var WORKFLOW_TOOL_DESCRIPTION = "Run named builtin, project, user, or package workflows; custom definitions may import reusable project/package workflows or builtin definitions from @bastani/atomic/workflows/builtin and nest them with ctx.workflow(...), including deeper composition within the configured maxDepth; " + "when workflow execution fits but another shape would better achieve the task, author a custom TypeScript workflow({...}) inline with normal coding tools, reload it, and run it; after successfully creating and reloading a newly authored custom workflow, report the folder containing its generated code as 'Custom workflow created. You can inspect its code at: <workflow-folder-path>'; do this only for newly created custom workflows, never builtin or pre-existing workflows; " + "discover with list/get/inputs/models, list session runs with status (no runId; statusFilter narrows the list), inspect status/stages/stage details, " + "answer pending prompts only while the root workflow is nonterminal, pause/resume/interrupt/quit runs, and reload workflow resources. " + "When steering or communication is useful, use Intercom; address a workflow stage as `<runId>:<stageKey>`. Live delivery is immediate; a known stage that has not started is queued and receives the message before its first model turn. Use `ask` only for a reply-capable live session. " + "Treat a blocked run as continuable by default: resume resumable blocks, answer pending prompts, steer past the obstacle, or start a follow-up workflow past a terminal block, and escalate to the user only when the blocked result is so ambiguous that human input or steering must settle it; when ask_user_question or human input is unavailable, continue fully autonomously on the interpretation best supported by the objective and repository evidence, and record the assumption. " + "For action 'run' and 'resume', budget accepts per-field duration, token, cost, and warning overrides; fields resolve over the workflow declaration and config, and 0 disables a field. " + "Pass budget only when the user asked for a limit; otherwise omit it entirely and inherit the declaration and config rather than inventing a cap. " + "For primitive prompt answers, use booleans or the documented confirm labels, exact case-insensitive select labels or 1-based indexes, and text strings for input/editor; an invalid answer remains pending and returns guidance instead of choosing a default. " + "For large stage handoffs, write context to files/artifacts, pass paths via reads, and prompt downstream agents to 'Read the file at <path>...' instead of injecting large previous text. " + "Wrap critical parts of run inputs and steering messages in <keepContext>...</keepContext> so compaction preserves them verbatim in the stages that inherit them; tag role constraints, prohibitions, must-hold criteria, and identifiers, not background or bulk reference material. " + "For transcripts, prefer status/stages/stage to get sessionFile/transcriptPath, " + "quote the exact path without rewriting separators (Windows backslashes are valid), " + "then search it with rg/grep and read small ranges; transcript is path-only by default when sessionFile/transcriptPath exists, explicit tail/limit returns bounded previews, and missing transcript paths fall back to a small preview. " + "Use action 'models' to inspect models in the configured catalog; the result is a configured-auth snapshot showing what's present in the registry with configured authentication, not proof of credentials, entitlements, OAuth freshness, or live provider access. " + "When authoring a workflow that should dynamically select a model, first call workflow({ action: 'models' }) to inspect the configured catalog, then select from the returned provider/id entries considering the isCurrent marker and available thinking levels.";
124961
+ var WORKFLOW_TOOL_DESCRIPTION = "Run named builtin, project, user, or package workflows; custom definitions may import reusable project/package workflows or builtin definitions from @bastani/atomic/workflows/builtin and nest them with ctx.workflow(...), including deeper composition within the configured maxDepth; " + "when workflow execution fits but another shape would better achieve the task, author a custom TypeScript workflow({...}) inline with normal coding tools, reload it, and run it; after successfully creating and reloading a newly authored custom workflow, report the folder containing its generated code as 'Custom workflow created. You can inspect its code at: <workflow-folder-path>'; do this only for newly created custom workflows, never builtin or pre-existing workflows; " + "discover with list/get/inputs/models, list session runs with status (no runId; statusFilter narrows the list), inspect status/stages/stage details, " + "answer pending prompts only while the root workflow is nonterminal, pause/resume/interrupt/quit runs, and reload workflow resources. " + "When steering or communication is useful, use Intercom. Before steering a stage, join its invocation group. Use the Intercom `groups` action to discover it. Workflow invocation groups are named `workflow:<rootRunId>`. Then address the stage as `<runId>:<stageKey>`. Live delivery is immediate; a known stage that has not started is queued and receives the message before its first model turn. Use `ask` only for a reply-capable live session. " + "Treat a blocked run as continuable by default: resume resumable blocks, answer pending prompts, steer past the obstacle, or start a follow-up workflow past a terminal block, and escalate to the user only when the blocked result is so ambiguous that human input or steering must settle it; when ask_user_question or human input is unavailable, continue fully autonomously on the interpretation best supported by the objective and repository evidence, and record the assumption. " + "For action 'run' and 'resume', budget accepts per-field duration, token, cost, and warning overrides; fields resolve over the workflow declaration and config, and 0 disables a field. " + "Pass budget only when the user asked for a limit; otherwise omit it entirely and inherit the declaration and config rather than inventing a cap. " + "For primitive prompt answers, use booleans or the documented confirm labels, exact case-insensitive select labels or 1-based indexes, and text strings for input/editor; an invalid answer remains pending and returns guidance instead of choosing a default. " + "For large stage handoffs, write context to files/artifacts, pass paths via reads, and prompt downstream agents to 'Read the file at <path>...' instead of injecting large previous text. " + "Wrap critical parts of run inputs and steering messages in <keepContext>...</keepContext> so compaction preserves them verbatim in the stages that inherit them; tag role constraints, prohibitions, must-hold criteria, and identifiers, not background or bulk reference material. " + "For transcripts, prefer status/stages/stage to get sessionFile/transcriptPath, " + "quote the exact path without rewriting separators (Windows backslashes are valid), " + "then search it with rg/grep and read small ranges; transcript is path-only by default when sessionFile/transcriptPath exists, explicit tail/limit returns bounded previews, and missing transcript paths fall back to a small preview. " + "Use action 'models' to inspect models in the configured catalog; the result is a configured-auth snapshot showing what's present in the registry with configured authentication, not proof of credentials, entitlements, OAuth freshness, or live provider access. " + "When authoring a workflow that should dynamically select a model, first call workflow({ action: 'models' }) to inspect the configured catalog, then select from the returned provider/id entries considering the isCurrent marker and available thinking levels.";
124574
124962
  var DEFAULT_PROMPT_GUIDANCE = [
124575
124963
  `**Workflows**: Treat workflows as the default execution path for any non-trivial task and for any request that has inherent structure plus an objective you can make verifiable. Use the \`workflow\` tool for existing named workflows; when the task needs a graph that is not installed, author a custom TypeScript \`workflow({...})\` inline with normal coding tools, reload workflow resources, and run it.
124576
124964
  - Workflow fit check: prefer a workflow for implementation, build, debug/diagnosis, bug-fix, migration, new-feature, scoped multi-file, or docs/code changes with validation; and whenever there are multiple steps, dependencies, handoffs, uncertainty, review/validation needs, long-running work, measurable done criteria, or an outcome that needs evidence.
@@ -124606,7 +124994,7 @@ var DEFAULT_PROMPT_GUIDANCE = [
124606
124994
  - Wrap critical parts of the \`inputs\` you pass — objective, prompt, acceptance criteria — in \`<keepContext>\` / \`</keepContext>\`. Tagged text survives compaction verbatim regardless of the compression ratio, and stages inherit it because workflows inject your inputs into their prompts. A long stage is compacted repeatedly, and compaction ranks lines individually: a verbose restated objective outlives the one line that bounds it, so a stage can end up executing a coherent but unbounded version of what you asked for. Decide this per launch rather than tagging everything — tag role constraints, prohibitions, must-hold criteria, and identifiers such as a target branch, worktree path, or issue number; leave background, quoted issue text, and reference material untagged and pass bulk through files and \`reads\`. Protected lines count against the keep target rather than raising it, so an over-tagged input makes the evidence stages need compress harder.
124607
124995
  - Tag steering the same way. An Intercom \`send\` amendment is authoritative and stages must carry it forward, but it arrives late in an already-long session and is exactly one short message competing with the whole transcript; \`<keepContext>\` around the requirement keeps it from being compacted away before the stage acts on it.
124608
124996
  - In interactive chat, named workflow launches run in the background. Run \`/workflow connect <run>\` to see agents working and chat with and steer each stage. Inspection and control calls (\`status\`, \`stages\`, \`stage\`, \`transcript\`, \`answer\`, \`pause\`, \`resume\`, \`interrupt\`, \`quit\`) remain available while work runs.
124609
- - \`workflow answer\` handles a pending human-input prompt. Send free-form updates through Intercom to \`<runId>:<stageKey>\`; Atomic delivers immediately to live stages and queues messages for known stages that have not started, delivering them before their first model turn. Use \`ask\` once the target has a live session that can reply. Use explicit \`/workflow attach <run> <stage>\` for user-driven post-mortem chat.
124997
+ - \`workflow answer\` handles a pending human-input prompt. Before steering a stage, join its invocation group. Use the Intercom \`groups\` action to discover it. Workflow invocation groups are named \`workflow:<rootRunId>\`. Send free-form updates through Intercom to \`<runId>:<stageKey>\`; Atomic delivers immediately to live stages and queues messages for known stages that have not started, delivering them before their first model turn. Use \`ask\` once the target has a live session that can reply. Use explicit \`/workflow attach <run> <stage>\` for user-driven post-mortem chat.
124610
124998
  - A blocked run is a changed condition, not a stop order. On a blocked status or a WORKFLOW BLOCKED lifecycle notice, keep the work moving by default: resume a resumable block, answer the pending prompt, steer the stage past the obstacle, or start a follow-up workflow that carries the remaining tracked work past a terminal block — continue inline only if the remaining work is minimal. Stop for user input only when the task is so ambiguous that competing interpretations lead to materially different outcomes and judgment cannot infer intent from the stated objective and repository evidence; then ask one grouped question or wait for steering.
124611
124999
  - A budget-exceeded stop (the resumable \`budget_exceeded\` blocked rail) is the exception: the exhausted budget is a boundary someone chose, so do not raise it silently. Summarize progress and the estimated next steps, ask the user whether to proceed — prefer the \`ask_user_question\` tool when it is available — and resume with a raised \`budget\` only after approval.
124612
125000
  - When human input is unavailable — \`ask_user_question\` is not among your tools, the session is headless, or nobody answers — do not stall on a question. Choose the interpretation best supported by the stated objective and repository evidence — mine git history, commits, PRs, issues, and the user's own comments to infer how they would decide — record the assumption and rationale in the result or an artifact, and continue fully autonomously on best judgment.
@@ -124628,7 +125016,7 @@ var DEFAULT_PROMPT_GUIDANCE = [
124628
125016
  - Cyclic workflow graphs are unsupported. Workflow authors and coding agents MUST NOT create self-edges or dependency edges from the current frontier to an existing ancestor. Every materialized execution topology must remain a DAG. Redesign or stop before launch if a cycle cannot be removed.
124629
125017
  - Bounded loops must create distinct tracked work for every iteration; never reopen an ancestor below its downstream work. Stacked implementation slices are unrolled, not looped: each slice gets a fresh child boundary and distinct tracked nodes, and no slice may add an edge back to the current frontier, itself, or an ancestor. If a retained session receives follow-up without new dependency work, keep it as non-topological activity metadata rather than adding a back-edge. Before launch, sketch nodes and dependencies for every branch and loop and reject any proposed parent edge to the node itself or an ancestor.
124630
125018
  - Treat dynamic graph validation during execution, replay, and DBOS hydration as the authoritative cycle boundary. If runtime topology code changes, require incremental edge checks and DBOS hydration validation; prompt guidance and TypeScript types cannot replace those runtime checks.
124631
- - Every workflow invocation automatically receives one stable, non-default Intercom group. Intercom-capable stages inherit it, nested workflows keep the top-level invocation group, and subagents inherit their launching stage's group. Do not mint or thread group names through ordinary workflow definitions. Use an explicit \`group\` only for an intentional override: a named group or \`group: true\` creates a subgroup, while \`group: "default"\` opts into the shared default group. Stages without Intercom access receive no group, and \`contact_supervisor\` still crosses group boundaries for authorized escalation.
125019
+ - Every workflow invocation automatically receives one stable, non-default Intercom group named \`workflow:<rootRunId>\`. Every model stage inherits it because ordinary \`intercom\` is mandatory even under tool and extension restrictions; nested workflows keep the top-level invocation group, and subagents inherit their launching stage's group. Do not mint or thread group names through ordinary workflow definitions. Use an explicit \`group\` only for an intentional override: a named group or \`group: true\` creates a subgroup, while \`group: "default"\` opts into the shared default group. \`contact_supervisor\` still crosses group boundaries only for authorized subagent escalation.
124632
125020
  - Prefer \`ctx.tool(name, args, fn)\` for workflow-owned TypeScript operations with side effects, such as filesystem writes, network mutations, and external API actions. It creates a tracked, non-attachable durable graph node before invoking \`fn\`; it may be used before, between, after, or without model stages. A completed \`ctx.tool\` call is durably checkpointed with its serializable result, so resume replays that result without rerunning \`fn\`. For checks that may fail during a bounded repair loop, opt into \`failureMode: "return"\`, branch on the typed outcome, and pass only the needed error fields to the repair stage or artifact yourself; Atomic does not inject failure evidence into later prompts. Retries do not bound a hung callback, so every \`ctx.tool\` callback that starts a child process or performs network I/O MUST set an explicit positive finite \`timeoutMs\` and forward the supplied \`signal\` to cancellable work. A timeout applies per attempt, aborts that attempt's signal, and gives retries a fresh deadline and signal. Cancellation and storage faults still throw. Keep pure computation and side-effect-free transformations as ordinary TypeScript. Do not wrap agent-stage internals or every function call indiscriminately; this rule applies to side effects orchestrated directly by the workflow definition.
124633
125021
  - Pass large stage context through files/artifacts and \`reads\` with an explicit \`Read the file at <path>...\` prompt rather than large \`previous\` payloads or injected session history.
124634
125022
  - Wrap critical stage-prompt content in \`<keepContext>\` / \`</keepContext>\`. Tagged content survives compression verbatim regardless of the compression ratio, and every line of the span including the tag lines is protected. A long-running stage will be compacted, and compaction ranks lines individually: an objective is verbose and restated while the constraint that narrows it is usually one line, so the constraint is the cheaper deletion and what survives reads as broader permission than intended. Tag role constraints that bound a stage to part of the work, acceptance criteria and immutable contracts, explicit prohibitions, and identifiers a stage must not lose such as a target branch, worktree path, or run ID. Do not tag bulk context: protected lines count against the keep target rather than raising it, so a large protected span makes the surrounding transcript compress harder — tag the constraint, not the material it applies to.