ummaya 0.2.13 → 0.2.15

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 (566) hide show
  1. package/npm-shrinkwrap.json +2 -2
  2. package/package.json +7 -4
  3. package/pyproject.toml +2 -2
  4. package/tui/package.json +1 -1
  5. package/tui/src/buddy/CompanionSprite.tsx +1 -2
  6. package/tui/src/buddy/useBuddyNotification.tsx +1 -2
  7. package/tui/src/cli/controlAuth.ts +20 -0
  8. package/tui/src/cli/handlers/auth.ts +7 -7
  9. package/tui/src/cli/handlers/mcp.tsx +0 -1
  10. package/tui/src/cli/handlers/util.tsx +2 -3
  11. package/tui/src/cli/print.ts +7 -4
  12. package/tui/src/commands/add-dir/add-dir.tsx +1 -2
  13. package/tui/src/commands/agents/agents.tsx +1 -2
  14. package/tui/src/commands/bridge/bridge.tsx +1 -2
  15. package/tui/src/commands/btw/btw.tsx +1 -2
  16. package/tui/src/commands/config/config.tsx +1 -2
  17. package/tui/src/commands/context/context.tsx +1 -2
  18. package/tui/src/commands/copy/copy.tsx +1 -2
  19. package/tui/src/commands/desktop/desktop.tsx +1 -2
  20. package/tui/src/commands/diff/diff.tsx +1 -2
  21. package/tui/src/commands/doctor/doctor.tsx +1 -2
  22. package/tui/src/commands/effort/effort.tsx +1 -2
  23. package/tui/src/commands/exit/exit.tsx +1 -2
  24. package/tui/src/commands/export/export.tsx +1 -2
  25. package/tui/src/commands/extra-usage/extra-usage.tsx +1 -2
  26. package/tui/src/commands/fast/fast.tsx +0 -1
  27. package/tui/src/commands/feedback/feedback.tsx +1 -2
  28. package/tui/src/commands/help/help.tsx +1 -2
  29. package/tui/src/commands/hooks/hooks.tsx +1 -2
  30. package/tui/src/commands/ide/ide.tsx +0 -1
  31. package/tui/src/commands/install-github-app/OAuthFlowStep.tsx +1 -2
  32. package/tui/src/commands/install-github-app/install-github-app.tsx +4 -4
  33. package/tui/src/commands/install.tsx +0 -1
  34. package/tui/src/commands/login/login.tsx +1 -2
  35. package/tui/src/commands/logout/logout.tsx +0 -1
  36. package/tui/src/commands/mcp/mcp.tsx +1 -2
  37. package/tui/src/commands/memory/memory.tsx +0 -1
  38. package/tui/src/commands/mobile/mobile.tsx +0 -1
  39. package/tui/src/commands/model/model.tsx +0 -1
  40. package/tui/src/commands/output-style/output-style.tsx +1 -2
  41. package/tui/src/commands/passes/passes.tsx +1 -2
  42. package/tui/src/commands/permissions/permissions.tsx +1 -2
  43. package/tui/src/commands/plan/plan.tsx +1 -2
  44. package/tui/src/commands/plugin/AddMarketplace.tsx +1 -2
  45. package/tui/src/commands/plugin/BrowseMarketplace.tsx +1 -2
  46. package/tui/src/commands/plugin/DiscoverPlugins.tsx +0 -1
  47. package/tui/src/commands/plugin/ManageMarketplaces.tsx +0 -1
  48. package/tui/src/commands/plugin/ManagePlugins.tsx +1 -2
  49. package/tui/src/commands/plugin/PluginErrors.tsx +1 -2
  50. package/tui/src/commands/plugin/PluginOptionsDialog.tsx +1 -2
  51. package/tui/src/commands/plugin/PluginOptionsFlow.tsx +1 -2
  52. package/tui/src/commands/plugin/PluginSettings.tsx +1 -2
  53. package/tui/src/commands/plugin/PluginTrustWarning.tsx +0 -1
  54. package/tui/src/commands/plugin/UnifiedInstalledCell.tsx +1 -2
  55. package/tui/src/commands/plugin/ValidatePlugin.tsx +1 -2
  56. package/tui/src/commands/plugin/index.tsx +0 -1
  57. package/tui/src/commands/plugin/plugin.tsx +1 -2
  58. package/tui/src/commands/plugin/pluginDetailsHelpers.tsx +1 -2
  59. package/tui/src/commands/privacy-settings/privacy-settings.tsx +0 -1
  60. package/tui/src/commands/rate-limit-options/rate-limit-options.tsx +1 -2
  61. package/tui/src/commands/remote-env/remote-env.tsx +1 -2
  62. package/tui/src/commands/remote-setup/remote-setup.tsx +0 -1
  63. package/tui/src/commands/resume/resume.tsx +1 -2
  64. package/tui/src/commands/review/UltrareviewOverageDialog.tsx +1 -2
  65. package/tui/src/commands/review/ultrareviewCommand.tsx +0 -1
  66. package/tui/src/commands/sandbox-toggle/sandbox-toggle.tsx +1 -2
  67. package/tui/src/commands/session/session.tsx +0 -1
  68. package/tui/src/commands/skills/skills.tsx +1 -2
  69. package/tui/src/commands/stats/stats.tsx +1 -2
  70. package/tui/src/commands/status/status.tsx +1 -2
  71. package/tui/src/commands/statusline.tsx +0 -1
  72. package/tui/src/commands/tag/tag.tsx +1 -2
  73. package/tui/src/commands/tasks/tasks.tsx +1 -2
  74. package/tui/src/commands/terminalSetup/terminalSetup.tsx +1 -2
  75. package/tui/src/commands/theme/theme.tsx +1 -2
  76. package/tui/src/commands/thinkback/thinkback.tsx +0 -1
  77. package/tui/src/commands/ultraplan.tsx +0 -1
  78. package/tui/src/commands/usage/usage.tsx +1 -2
  79. package/tui/src/commands/voice/voice.ts +2 -2
  80. package/tui/src/components/AgentProgressLine.tsx +1 -2
  81. package/tui/src/components/App.tsx +1 -2
  82. package/tui/src/components/ApproveApiKey.tsx +1 -2
  83. package/tui/src/components/AutoModeOptInDialog.tsx +0 -1
  84. package/tui/src/components/AutoUpdater.tsx +1 -2
  85. package/tui/src/components/AutoUpdaterWrapper.tsx +1 -2
  86. package/tui/src/components/AwsAuthStatusBox.tsx +1 -2
  87. package/tui/src/components/BaseTextInput.tsx +0 -1
  88. package/tui/src/components/BashModeProgress.tsx +1 -2
  89. package/tui/src/components/BridgeDialog.tsx +1 -2
  90. package/tui/src/components/BypassPermissionsModeDialog.tsx +0 -1
  91. package/tui/src/components/ChannelDowngradeDialog.tsx +1 -2
  92. package/tui/src/components/ClaudeCodeHint/PluginHintMenu.tsx +1 -2
  93. package/tui/src/components/ClaudeMdExternalIncludesDialog.tsx +0 -1
  94. package/tui/src/components/ClickableImageRef.tsx +1 -2
  95. package/tui/src/components/CompactSummary.tsx +1 -2
  96. package/tui/src/components/ConfigurableShortcutHint.tsx +1 -2
  97. package/tui/src/components/ContextSuggestions.tsx +1 -2
  98. package/tui/src/components/ContextVisualization.tsx +1 -2
  99. package/tui/src/components/CoordinatorAgentStatus.tsx +1 -2
  100. package/tui/src/components/CostThresholdDialog.tsx +0 -1
  101. package/tui/src/components/CtrlOToExpand.tsx +1 -2
  102. package/tui/src/components/CustomSelect/SelectMulti.tsx +1 -2
  103. package/tui/src/components/CustomSelect/select-input-option.tsx +1 -2
  104. package/tui/src/components/CustomSelect/select-option.tsx +1 -2
  105. package/tui/src/components/CustomSelect/select.tsx +1 -2
  106. package/tui/src/components/DesktopHandoff.tsx +0 -1
  107. package/tui/src/components/DesktopUpsell/DesktopUpsellStartup.tsx +0 -1
  108. package/tui/src/components/DevBar.tsx +1 -2
  109. package/tui/src/components/DevChannelsDialog.tsx +1 -2
  110. package/tui/src/components/DiagnosticsDisplay.tsx +1 -2
  111. package/tui/src/components/EffortCallout.tsx +1 -2
  112. package/tui/src/components/ExitFlow.tsx +1 -2
  113. package/tui/src/components/ExportDialog.tsx +1 -2
  114. package/tui/src/components/FallbackToolUseErrorMessage.tsx +0 -1
  115. package/tui/src/components/FallbackToolUseRejectedMessage.tsx +1 -2
  116. package/tui/src/components/FastIcon.tsx +1 -2
  117. package/tui/src/components/Feedback.tsx +0 -1
  118. package/tui/src/components/FeedbackSurvey/FeedbackSurvey.tsx +1 -2
  119. package/tui/src/components/FeedbackSurvey/FeedbackSurveyView.tsx +0 -1
  120. package/tui/src/components/FeedbackSurvey/TranscriptSharePrompt.tsx +0 -1
  121. package/tui/src/components/FeedbackSurvey/useFeedbackSurvey.tsx +0 -1
  122. package/tui/src/components/FeedbackSurvey/useMemorySurvey.tsx +0 -1
  123. package/tui/src/components/FeedbackSurvey/usePostCompactSurvey.tsx +0 -1
  124. package/tui/src/components/FeedbackSurvey/useSurveyState.tsx +1 -2
  125. package/tui/src/components/FileEditToolDiff.tsx +1 -2
  126. package/tui/src/components/FileEditToolUpdatedMessage.tsx +1 -2
  127. package/tui/src/components/FileEditToolUseRejectedMessage.tsx +1 -2
  128. package/tui/src/components/FilePathLink.tsx +1 -2
  129. package/tui/src/components/FullscreenLayout.tsx +1 -2
  130. package/tui/src/components/GlobalSearchDialog.tsx +1 -2
  131. package/tui/src/components/HelpV2/Commands.tsx +1 -2
  132. package/tui/src/components/HelpV2/General.tsx +0 -1
  133. package/tui/src/components/HelpV2/HelpV2.tsx +0 -1
  134. package/tui/src/components/HighlightedCode/Fallback.tsx +1 -2
  135. package/tui/src/components/HighlightedCode.tsx +1 -2
  136. package/tui/src/components/HistorySearchDialog.tsx +1 -2
  137. package/tui/src/components/IdeAutoConnectDialog.tsx +1 -2
  138. package/tui/src/components/IdeOnboardingDialog.tsx +0 -1
  139. package/tui/src/components/IdeStatusIndicator.tsx +1 -2
  140. package/tui/src/components/IdleReturnDialog.tsx +1 -2
  141. package/tui/src/components/InterruptedByUser.tsx +0 -1
  142. package/tui/src/components/InvalidConfigDialog.tsx +1 -2
  143. package/tui/src/components/InvalidSettingsDialog.tsx +1 -2
  144. package/tui/src/components/KeybindingWarnings.tsx +1 -2
  145. package/tui/src/components/LanguagePicker.tsx +1 -2
  146. package/tui/src/components/LogSelector.tsx +0 -1
  147. package/tui/src/components/LogoV2/AnimatedAsterisk.tsx +1 -2
  148. package/tui/src/components/LogoV2/AnimatedClawd.tsx +1 -2
  149. package/tui/src/components/LogoV2/ChannelsNotice.tsx +0 -1
  150. package/tui/src/components/LogoV2/Clawd.tsx +1 -2
  151. package/tui/src/components/LogoV2/CondensedLogo.tsx +0 -1
  152. package/tui/src/components/LogoV2/EmergencyTip.tsx +0 -1
  153. package/tui/src/components/LogoV2/Feed.tsx +1 -2
  154. package/tui/src/components/LogoV2/FeedColumn.tsx +1 -2
  155. package/tui/src/components/LogoV2/GuestPassesUpsell.tsx +0 -1
  156. package/tui/src/components/LogoV2/LogoV2.tsx +0 -1
  157. package/tui/src/components/LogoV2/Opus1mMergeNotice.tsx +1 -2
  158. package/tui/src/components/LogoV2/OverageCreditUpsell.tsx +1 -2
  159. package/tui/src/components/LogoV2/VoiceModeNotice.tsx +1 -2
  160. package/tui/src/components/LogoV2/feedConfigs.tsx +0 -1
  161. package/tui/src/components/LspRecommendation/LspRecommendationMenu.tsx +1 -2
  162. package/tui/src/components/MCPServerApprovalDialog.tsx +1 -2
  163. package/tui/src/components/MCPServerDesktopImportDialog.tsx +0 -1
  164. package/tui/src/components/MCPServerDialogCopy.tsx +0 -1
  165. package/tui/src/components/MCPServerMultiselectDialog.tsx +1 -2
  166. package/tui/src/components/ManagedSettingsSecurityDialog/ManagedSettingsSecurityDialog.tsx +0 -1
  167. package/tui/src/components/Markdown.tsx +1 -2
  168. package/tui/src/components/MarkdownTable.tsx +1 -2
  169. package/tui/src/components/MemoryUsageIndicator.tsx +1 -2
  170. package/tui/src/components/Message.tsx +1 -2
  171. package/tui/src/components/MessageModel.tsx +1 -2
  172. package/tui/src/components/MessageResponse.tsx +1 -2
  173. package/tui/src/components/MessageRow.tsx +1 -2
  174. package/tui/src/components/MessageSelector.tsx +1 -2
  175. package/tui/src/components/MessageTimestamp.tsx +1 -2
  176. package/tui/src/components/Messages.tsx +0 -1
  177. package/tui/src/components/ModelPicker.tsx +0 -1
  178. package/tui/src/components/NativeAutoUpdater.tsx +1 -2
  179. package/tui/src/components/NotebookEditToolUseRejectedMessage.tsx +1 -2
  180. package/tui/src/components/OffscreenFreeze.tsx +1 -2
  181. package/tui/src/components/Onboarding.tsx +2 -3
  182. package/tui/src/components/OutputStylePicker.tsx +0 -1
  183. package/tui/src/components/PackageManagerAutoUpdater.tsx +0 -1
  184. package/tui/src/components/Passes/Passes.tsx +0 -1
  185. package/tui/src/components/PrBadge.tsx +1 -2
  186. package/tui/src/components/PressEnterToContinue.tsx +1 -2
  187. package/tui/src/components/PromptInput/HistorySearchInput.tsx +1 -2
  188. package/tui/src/components/PromptInput/IssueFlagBanner.tsx +1 -2
  189. package/tui/src/components/PromptInput/Notifications.tsx +1 -2
  190. package/tui/src/components/PromptInput/PromptInput.tsx +0 -1
  191. package/tui/src/components/PromptInput/PromptInputFooter.tsx +1 -2
  192. package/tui/src/components/PromptInput/PromptInputFooterLeftSide.tsx +1 -2
  193. package/tui/src/components/PromptInput/PromptInputFooterSuggestions.tsx +1 -2
  194. package/tui/src/components/PromptInput/PromptInputHelpMenu.tsx +1 -2
  195. package/tui/src/components/PromptInput/PromptInputModeIndicator.tsx +1 -2
  196. package/tui/src/components/PromptInput/PromptInputQueuedCommands.tsx +1 -2
  197. package/tui/src/components/PromptInput/PromptInputStashNotice.tsx +1 -2
  198. package/tui/src/components/PromptInput/SandboxPromptFooterHint.tsx +1 -2
  199. package/tui/src/components/PromptInput/ShimmeredInput.tsx +1 -2
  200. package/tui/src/components/PromptInput/VoiceIndicator.tsx +1 -2
  201. package/tui/src/components/QuickOpenDialog.tsx +1 -2
  202. package/tui/src/components/RemoteCallout.tsx +0 -1
  203. package/tui/src/components/RemoteEnvironmentDialog.tsx +0 -1
  204. package/tui/src/components/ResumeTask.tsx +0 -1
  205. package/tui/src/components/SandboxViolationExpandedView.tsx +1 -2
  206. package/tui/src/components/ScrollKeybindingHandler.tsx +0 -1
  207. package/tui/src/components/SearchBox.tsx +1 -2
  208. package/tui/src/components/SessionBackgroundHint.tsx +1 -2
  209. package/tui/src/components/SessionPreview.tsx +1 -2
  210. package/tui/src/components/Settings/Config.tsx +0 -1
  211. package/tui/src/components/Settings/Settings.tsx +1 -2
  212. package/tui/src/components/Settings/Status.tsx +1 -2
  213. package/tui/src/components/Settings/Usage.tsx +1 -2
  214. package/tui/src/components/ShowInIDEPrompt.tsx +1 -2
  215. package/tui/src/components/SkillImprovementSurvey.tsx +1 -2
  216. package/tui/src/components/Spinner/FlashingChar.tsx +1 -2
  217. package/tui/src/components/Spinner/GlimmerMessage.tsx +1 -2
  218. package/tui/src/components/Spinner/ShimmerChar.tsx +1 -2
  219. package/tui/src/components/Spinner/SpinnerAnimationRow.tsx +1 -2
  220. package/tui/src/components/Spinner/SpinnerGlyph.tsx +1 -2
  221. package/tui/src/components/Spinner/TeammateSpinnerLine.tsx +1 -2
  222. package/tui/src/components/Spinner/TeammateSpinnerTree.tsx +1 -2
  223. package/tui/src/components/Spinner.tsx +0 -1
  224. package/tui/src/components/Stats.tsx +0 -1
  225. package/tui/src/components/StatusLine.tsx +1 -2
  226. package/tui/src/components/StatusNotices.tsx +1 -2
  227. package/tui/src/components/StructuredDiff/Fallback.tsx +1 -2
  228. package/tui/src/components/StructuredDiff.tsx +1 -2
  229. package/tui/src/components/StructuredDiffList.tsx +1 -2
  230. package/tui/src/components/TagTabs.tsx +1 -2
  231. package/tui/src/components/TaskListV2.tsx +1 -2
  232. package/tui/src/components/TeammateViewHeader.tsx +1 -2
  233. package/tui/src/components/TeleportError.tsx +0 -1
  234. package/tui/src/components/TeleportProgress.tsx +1 -2
  235. package/tui/src/components/TeleportRepoMismatchDialog.tsx +0 -1
  236. package/tui/src/components/TeleportStash.tsx +1 -2
  237. package/tui/src/components/TextInput.tsx +1 -2
  238. package/tui/src/components/ThemePicker.tsx +0 -1
  239. package/tui/src/components/ThinkingToggle.tsx +0 -1
  240. package/tui/src/components/TokenWarning.tsx +1 -2
  241. package/tui/src/components/ToolUseLoader.tsx +1 -2
  242. package/tui/src/components/TrustDialog/TrustDialog.tsx +0 -1
  243. package/tui/src/components/ValidationErrorsList.tsx +1 -2
  244. package/tui/src/components/VimTextInput.tsx +1 -2
  245. package/tui/src/components/VirtualMessageList.tsx +1 -2
  246. package/tui/src/components/WorktreeExitDialog.tsx +1 -2
  247. package/tui/src/components/agents/AgentDetail.tsx +0 -1
  248. package/tui/src/components/agents/AgentEditor.tsx +1 -2
  249. package/tui/src/components/agents/AgentNavigationFooter.tsx +1 -2
  250. package/tui/src/components/agents/AgentsList.tsx +0 -1
  251. package/tui/src/components/agents/AgentsMenu.tsx +1 -2
  252. package/tui/src/components/agents/ColorPicker.tsx +1 -2
  253. package/tui/src/components/agents/ModelSelector.tsx +1 -2
  254. package/tui/src/components/agents/ToolSelector.tsx +1 -2
  255. package/tui/src/components/agents/new-agent-creation/CreateAgentWizard.tsx +1 -2
  256. package/tui/src/components/agents/new-agent-creation/wizard-steps/ColorStep.tsx +1 -2
  257. package/tui/src/components/agents/new-agent-creation/wizard-steps/ConfirmStep.tsx +0 -1
  258. package/tui/src/components/agents/new-agent-creation/wizard-steps/ConfirmStepWrapper.tsx +1 -2
  259. package/tui/src/components/agents/new-agent-creation/wizard-steps/DescriptionStep.tsx +0 -1
  260. package/tui/src/components/agents/new-agent-creation/wizard-steps/GenerateStep.tsx +1 -2
  261. package/tui/src/components/agents/new-agent-creation/wizard-steps/LocationStep.tsx +1 -2
  262. package/tui/src/components/agents/new-agent-creation/wizard-steps/MemoryStep.tsx +1 -2
  263. package/tui/src/components/agents/new-agent-creation/wizard-steps/MethodStep.tsx +0 -1
  264. package/tui/src/components/agents/new-agent-creation/wizard-steps/ModelStep.tsx +1 -2
  265. package/tui/src/components/agents/new-agent-creation/wizard-steps/PromptStep.tsx +1 -2
  266. package/tui/src/components/agents/new-agent-creation/wizard-steps/ToolsStep.tsx +1 -2
  267. package/tui/src/components/agents/new-agent-creation/wizard-steps/TypeStep.tsx +1 -2
  268. package/tui/src/components/design-system/Byline.tsx +1 -2
  269. package/tui/src/components/design-system/Dialog.tsx +1 -2
  270. package/tui/src/components/design-system/Divider.tsx +1 -2
  271. package/tui/src/components/design-system/FuzzyPicker.tsx +1 -2
  272. package/tui/src/components/design-system/KeyboardShortcutHint.tsx +1 -2
  273. package/tui/src/components/design-system/ListItem.tsx +1 -2
  274. package/tui/src/components/design-system/LoadingState.tsx +0 -1
  275. package/tui/src/components/design-system/Pane.tsx +1 -2
  276. package/tui/src/components/design-system/ProgressBar.tsx +1 -2
  277. package/tui/src/components/design-system/Ratchet.tsx +1 -2
  278. package/tui/src/components/design-system/StatusIcon.tsx +1 -2
  279. package/tui/src/components/design-system/Tabs.tsx +1 -2
  280. package/tui/src/components/design-system/ThemeProvider.tsx +1 -2
  281. package/tui/src/components/design-system/ThemedBox.tsx +1 -2
  282. package/tui/src/components/design-system/ThemedText.tsx +1 -2
  283. package/tui/src/components/diff/DiffDetailView.tsx +1 -2
  284. package/tui/src/components/diff/DiffDialog.tsx +1 -2
  285. package/tui/src/components/diff/DiffFileList.tsx +1 -2
  286. package/tui/src/components/grove/Grove.tsx +0 -1
  287. package/tui/src/components/hooks/HooksConfigMenu.tsx +0 -1
  288. package/tui/src/components/hooks/PromptDialog.tsx +1 -2
  289. package/tui/src/components/hooks/SelectEventMode.tsx +0 -1
  290. package/tui/src/components/hooks/SelectHookMode.tsx +0 -1
  291. package/tui/src/components/hooks/SelectMatcherMode.tsx +0 -1
  292. package/tui/src/components/hooks/ViewHookMode.tsx +0 -1
  293. package/tui/src/components/mcp/CapabilitiesSection.tsx +1 -2
  294. package/tui/src/components/mcp/ElicitationDialog.tsx +0 -1
  295. package/tui/src/components/mcp/MCPAgentServerMenu.tsx +1 -2
  296. package/tui/src/components/mcp/MCPListPanel.tsx +0 -1
  297. package/tui/src/components/mcp/MCPReconnect.tsx +1 -2
  298. package/tui/src/components/mcp/MCPRemoteServerMenu.tsx +2 -3
  299. package/tui/src/components/mcp/MCPSettings.tsx +0 -1
  300. package/tui/src/components/mcp/MCPStdioServerMenu.tsx +1 -2
  301. package/tui/src/components/mcp/MCPToolDetailView.tsx +1 -2
  302. package/tui/src/components/mcp/MCPToolListView.tsx +1 -2
  303. package/tui/src/components/mcp/McpParsingWarnings.tsx +0 -1
  304. package/tui/src/components/mcp/utils/reconnectHelpers.tsx +1 -2
  305. package/tui/src/components/memory/MemoryFileSelector.tsx +1 -2
  306. package/tui/src/components/memory/MemoryUpdateNotification.tsx +1 -2
  307. package/tui/src/components/messageActions.tsx +1 -2
  308. package/tui/src/components/messages/AdvisorMessage.tsx +1 -2
  309. package/tui/src/components/messages/AssistantRedactedThinkingMessage.tsx +1 -2
  310. package/tui/src/components/messages/AssistantThinkingMessage.tsx +1 -2
  311. package/tui/src/components/messages/AssistantToolUseMessage.tsx +0 -1
  312. package/tui/src/components/messages/AttachmentMessage.tsx +1 -2
  313. package/tui/src/components/messages/CollapsedReadSearchContent.tsx +1 -2
  314. package/tui/src/components/messages/CompactBoundaryMessage.tsx +1 -2
  315. package/tui/src/components/messages/GroupedToolUseContent.tsx +1 -2
  316. package/tui/src/components/messages/HighlightedThinkingText.tsx +1 -2
  317. package/tui/src/components/messages/HookProgressMessage.tsx +1 -2
  318. package/tui/src/components/messages/PlanApprovalMessage.tsx +1 -2
  319. package/tui/src/components/messages/RateLimitMessage.tsx +1 -2
  320. package/tui/src/components/messages/ShutdownMessage.tsx +1 -2
  321. package/tui/src/components/messages/SystemAPIErrorMessage.tsx +1 -2
  322. package/tui/src/components/messages/SystemTextMessage.tsx +1 -2
  323. package/tui/src/components/messages/TaskAssignmentMessage.tsx +1 -2
  324. package/tui/src/components/messages/UserAgentNotificationMessage.tsx +1 -2
  325. package/tui/src/components/messages/UserBashInputMessage.tsx +1 -2
  326. package/tui/src/components/messages/UserBashOutputMessage.tsx +1 -2
  327. package/tui/src/components/messages/UserChannelMessage.tsx +1 -2
  328. package/tui/src/components/messages/UserCommandMessage.tsx +1 -2
  329. package/tui/src/components/messages/UserImageMessage.tsx +1 -2
  330. package/tui/src/components/messages/UserLocalCommandOutputMessage.tsx +1 -2
  331. package/tui/src/components/messages/UserMemoryInputMessage.tsx +1 -2
  332. package/tui/src/components/messages/UserPlanMessage.tsx +1 -2
  333. package/tui/src/components/messages/UserPromptMessage.tsx +1 -2
  334. package/tui/src/components/messages/UserResourceUpdateMessage.tsx +1 -2
  335. package/tui/src/components/messages/UserTeammateMessage.tsx +1 -2
  336. package/tui/src/components/messages/UserTextMessage.tsx +1 -2
  337. package/tui/src/components/messages/UserToolResultMessage/RejectedPlanMessage.tsx +0 -1
  338. package/tui/src/components/messages/UserToolResultMessage/RejectedToolUseMessage.tsx +1 -2
  339. package/tui/src/components/messages/UserToolResultMessage/UserToolCanceledMessage.tsx +1 -2
  340. package/tui/src/components/messages/UserToolResultMessage/UserToolErrorMessage.tsx +1 -2
  341. package/tui/src/components/messages/UserToolResultMessage/UserToolRejectMessage.tsx +1 -2
  342. package/tui/src/components/messages/UserToolResultMessage/UserToolResultMessage.tsx +1 -2
  343. package/tui/src/components/messages/UserToolResultMessage/UserToolSuccessMessage.tsx +1 -2
  344. package/tui/src/components/messages/UserToolResultMessage/utils.tsx +0 -1
  345. package/tui/src/components/messages/teamMemCollapsed.tsx +1 -2
  346. package/tui/src/components/permissions/AskUserQuestionPermissionRequest/AskUserQuestionPermissionRequest.tsx +1 -2
  347. package/tui/src/components/permissions/AskUserQuestionPermissionRequest/PreviewBox.tsx +1 -2
  348. package/tui/src/components/permissions/AskUserQuestionPermissionRequest/PreviewQuestionView.tsx +1 -2
  349. package/tui/src/components/permissions/AskUserQuestionPermissionRequest/QuestionNavigationBar.tsx +1 -2
  350. package/tui/src/components/permissions/AskUserQuestionPermissionRequest/QuestionView.tsx +1 -2
  351. package/tui/src/components/permissions/AskUserQuestionPermissionRequest/SubmitQuestionsView.tsx +1 -2
  352. package/tui/src/components/permissions/BashPermissionRequest/BashPermissionRequest.tsx +1 -2
  353. package/tui/src/components/permissions/BashPermissionRequest/bashToolUseOptions.tsx +0 -1
  354. package/tui/src/components/permissions/ComputerUseApproval/ComputerUseApproval.tsx +0 -1
  355. package/tui/src/components/permissions/EnterPlanModePermissionRequest/EnterPlanModePermissionRequest.tsx +0 -1
  356. package/tui/src/components/permissions/ExitPlanModePermissionRequest/ExitPlanModePermissionRequest.tsx +0 -1
  357. package/tui/src/components/permissions/FallbackPermissionRequest.tsx +1 -2
  358. package/tui/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +1 -2
  359. package/tui/src/components/permissions/FilePermissionDialog/FilePermissionDialog.tsx +1 -2
  360. package/tui/src/components/permissions/FilePermissionDialog/permissionOptions.tsx +0 -1
  361. package/tui/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +1 -2
  362. package/tui/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +1 -2
  363. package/tui/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +1 -2
  364. package/tui/src/components/permissions/NotebookEditPermissionRequest/NotebookEditPermissionRequest.tsx +1 -2
  365. package/tui/src/components/permissions/NotebookEditPermissionRequest/NotebookEditToolDiff.tsx +1 -2
  366. package/tui/src/components/permissions/PermissionDecisionDebugInfo.tsx +1 -2
  367. package/tui/src/components/permissions/PermissionDialog.tsx +1 -2
  368. package/tui/src/components/permissions/PermissionExplanation.tsx +1 -2
  369. package/tui/src/components/permissions/PermissionPrompt.tsx +0 -1
  370. package/tui/src/components/permissions/PermissionRequest.tsx +0 -1
  371. package/tui/src/components/permissions/PermissionRequestTitle.tsx +1 -2
  372. package/tui/src/components/permissions/PermissionRuleExplanation.tsx +1 -2
  373. package/tui/src/components/permissions/PowerShellPermissionRequest/PowerShellPermissionRequest.tsx +1 -2
  374. package/tui/src/components/permissions/PowerShellPermissionRequest/powershellToolUseOptions.tsx +0 -1
  375. package/tui/src/components/permissions/SandboxPermissionRequest.tsx +0 -1
  376. package/tui/src/components/permissions/SedEditPermissionRequest/SedEditPermissionRequest.tsx +1 -2
  377. package/tui/src/components/permissions/SkillPermissionRequest/SkillPermissionRequest.tsx +0 -1
  378. package/tui/src/components/permissions/WebFetchPermissionRequest/WebFetchPermissionRequest.tsx +0 -1
  379. package/tui/src/components/permissions/WorkerBadge.tsx +1 -2
  380. package/tui/src/components/permissions/WorkerPendingPermission.tsx +1 -2
  381. package/tui/src/components/permissions/rules/AddPermissionRules.tsx +0 -1
  382. package/tui/src/components/permissions/rules/AddWorkspaceDirectory.tsx +0 -1
  383. package/tui/src/components/permissions/rules/PermissionRuleDescription.tsx +1 -2
  384. package/tui/src/components/permissions/rules/PermissionRuleInput.tsx +1 -2
  385. package/tui/src/components/permissions/rules/PermissionRuleList.tsx +0 -1
  386. package/tui/src/components/permissions/rules/RecentDenialsTab.tsx +1 -2
  387. package/tui/src/components/permissions/rules/RemoveWorkspaceDirectory.tsx +0 -1
  388. package/tui/src/components/permissions/rules/WorkspaceTab.tsx +1 -2
  389. package/tui/src/components/permissions/shellPermissionHelpers.tsx +1 -2
  390. package/tui/src/components/sandbox/SandboxConfigTab.tsx +1 -2
  391. package/tui/src/components/sandbox/SandboxDependenciesTab.tsx +1 -2
  392. package/tui/src/components/sandbox/SandboxDoctorSection.tsx +1 -2
  393. package/tui/src/components/sandbox/SandboxOverridesTab.tsx +0 -1
  394. package/tui/src/components/sandbox/SandboxSettings.tsx +0 -1
  395. package/tui/src/components/shell/ExpandShellOutputContext.tsx +1 -2
  396. package/tui/src/components/shell/OutputLine.tsx +1 -2
  397. package/tui/src/components/shell/ShellProgressMessage.tsx +1 -2
  398. package/tui/src/components/shell/ShellTimeDisplay.tsx +1 -2
  399. package/tui/src/components/skills/SkillsMenu.tsx +0 -1
  400. package/tui/src/components/tasks/AsyncAgentDetailDialog.tsx +1 -2
  401. package/tui/src/components/tasks/BackgroundTask.tsx +1 -2
  402. package/tui/src/components/tasks/BackgroundTaskStatus.tsx +1 -2
  403. package/tui/src/components/tasks/BackgroundTasksDialog.tsx +1 -2
  404. package/tui/src/components/tasks/DreamDetailDialog.tsx +1 -2
  405. package/tui/src/components/tasks/InProcessTeammateDetailDialog.tsx +1 -2
  406. package/tui/src/components/tasks/RemoteSessionDetailDialog.tsx +0 -1
  407. package/tui/src/components/tasks/RemoteSessionProgress.tsx +1 -2
  408. package/tui/src/components/tasks/ShellDetailDialog.tsx +1 -2
  409. package/tui/src/components/tasks/ShellProgress.tsx +1 -2
  410. package/tui/src/components/tasks/renderToolActivity.tsx +1 -2
  411. package/tui/src/components/tasks/taskStatusUtils.tsx +1 -2
  412. package/tui/src/components/teams/TeamStatus.tsx +1 -2
  413. package/tui/src/components/teams/TeamsDialog.tsx +1 -2
  414. package/tui/src/components/ui/OrderedList.tsx +1 -2
  415. package/tui/src/components/ui/OrderedListItem.tsx +1 -2
  416. package/tui/src/components/ui/TreeSelect.tsx +1 -2
  417. package/tui/src/components/wizard/WizardDialogLayout.tsx +1 -2
  418. package/tui/src/components/wizard/WizardNavigationFooter.tsx +1 -2
  419. package/tui/src/components/wizard/WizardProvider.tsx +1 -2
  420. package/tui/src/context/QueuedMessageContext.tsx +1 -2
  421. package/tui/src/context/fpsMetrics.tsx +1 -2
  422. package/tui/src/context/mailbox.tsx +1 -2
  423. package/tui/src/context/modalContext.tsx +1 -2
  424. package/tui/src/context/notifications.tsx +1 -2
  425. package/tui/src/context/overlayContext.tsx +1 -2
  426. package/tui/src/context/promptOverlayContext.tsx +1 -2
  427. package/tui/src/context/stats.tsx +1 -2
  428. package/tui/src/context/voice.tsx +1 -2
  429. package/tui/src/dialogLaunchers.tsx +0 -1
  430. package/tui/src/entrypoints/cli.tsx +0 -1
  431. package/tui/src/hooks/notifs/useCanSwitchToExistingSubscription.tsx +0 -1
  432. package/tui/src/hooks/notifs/useDeprecationWarningNotification.tsx +1 -2
  433. package/tui/src/hooks/notifs/useFastModeNotification.tsx +1 -2
  434. package/tui/src/hooks/notifs/useIDEStatusIndicator.tsx +1 -2
  435. package/tui/src/hooks/notifs/useInstallMessages.tsx +1 -2
  436. package/tui/src/hooks/notifs/useLspInitializationNotification.tsx +1 -2
  437. package/tui/src/hooks/notifs/useMcpConnectivityStatus.tsx +0 -1
  438. package/tui/src/hooks/notifs/useModelMigrationNotifications.tsx +1 -2
  439. package/tui/src/hooks/notifs/useNpmDeprecationNotification.tsx +1 -2
  440. package/tui/src/hooks/notifs/usePluginAutoupdateNotification.tsx +1 -2
  441. package/tui/src/hooks/notifs/usePluginInstallationStatus.tsx +1 -2
  442. package/tui/src/hooks/notifs/useRateLimitWarningNotification.tsx +1 -2
  443. package/tui/src/hooks/notifs/useSettingsErrors.tsx +1 -2
  444. package/tui/src/hooks/useApiKeyVerification.ts +7 -7
  445. package/tui/src/hooks/useArrowKeyHistory.tsx +1 -2
  446. package/tui/src/hooks/useCanUseTool.tsx +0 -1
  447. package/tui/src/hooks/useChromeExtensionNotification.tsx +0 -1
  448. package/tui/src/hooks/useClaudeCodeHintRecommendation.tsx +1 -2
  449. package/tui/src/hooks/useCommandKeybindings.tsx +1 -2
  450. package/tui/src/hooks/useGlobalKeybindings.tsx +1 -2
  451. package/tui/src/hooks/useIDEIntegration.tsx +1 -2
  452. package/tui/src/hooks/useLspPluginRecommendation.tsx +1 -2
  453. package/tui/src/hooks/useOfficialMarketplaceNotification.tsx +0 -1
  454. package/tui/src/hooks/usePluginRecommendationBase.tsx +1 -2
  455. package/tui/src/hooks/usePromptsFromClaudeInChrome.tsx +1 -2
  456. package/tui/src/hooks/useReplBridge.tsx +1 -2
  457. package/tui/src/hooks/useTypeahead.tsx +0 -1
  458. package/tui/src/hooks/useVoiceIntegration.tsx +1 -2
  459. package/tui/src/ink/Ansi.tsx +1 -2
  460. package/tui/src/ink/components/AlternateScreen.tsx +1 -2
  461. package/tui/src/ink/components/App.tsx +0 -1
  462. package/tui/src/ink/components/Box.tsx +1 -2
  463. package/tui/src/ink/components/Button.tsx +1 -2
  464. package/tui/src/ink/components/ClockContext.tsx +1 -2
  465. package/tui/src/ink/components/ErrorOverview.tsx +1 -2
  466. package/tui/src/ink/components/Link.tsx +1 -2
  467. package/tui/src/ink/components/Newline.tsx +1 -2
  468. package/tui/src/ink/components/NoSelect.tsx +1 -2
  469. package/tui/src/ink/components/RawAnsi.tsx +1 -2
  470. package/tui/src/ink/components/ScrollBox.tsx +1 -2
  471. package/tui/src/ink/components/Spacer.tsx +1 -2
  472. package/tui/src/ink/components/TerminalFocusContext.tsx +1 -2
  473. package/tui/src/ink/components/TerminalSizeContext.tsx +1 -2
  474. package/tui/src/ink/components/Text.tsx +1 -2
  475. package/tui/src/ink/ink.tsx +0 -1
  476. package/tui/src/interactiveHelpers.tsx +0 -1
  477. package/tui/src/keybindings/KeybindingContext.tsx +1 -2
  478. package/tui/src/keybindings/KeybindingProviderSetup.tsx +1 -2
  479. package/tui/src/main.tsx +0 -1
  480. package/tui/src/moreright/useMoreRight.tsx +1 -2
  481. package/tui/src/replLauncher.tsx +1 -2
  482. package/tui/src/screens/Doctor.tsx +0 -1
  483. package/tui/src/screens/REPL.tsx +0 -1
  484. package/tui/src/screens/ResumeConversation.tsx +0 -1
  485. package/tui/src/services/mcp/MCPConnectionManager.tsx +1 -2
  486. package/tui/src/services/mcp/claudeai.ts +1 -1
  487. package/tui/src/services/mcpServerApproval.tsx +1 -2
  488. package/tui/src/services/oauth/client.ts +16 -14
  489. package/tui/src/services/oauth/getOauthProfile.ts +2 -2
  490. package/tui/src/services/oauth/index.ts +12 -16
  491. package/tui/src/services/policyLimits/index.ts +3 -3
  492. package/tui/src/services/remoteManagedSettings/index.ts +3 -3
  493. package/tui/src/services/remoteManagedSettings/securityCheck.tsx +1 -2
  494. package/tui/src/services/remoteManagedSettings/syncCache.ts +3 -3
  495. package/tui/src/services/voiceStreamSTT.ts +2 -2
  496. package/tui/src/state/AppState.tsx +1 -2
  497. package/tui/src/tasks/InProcessTeammateTask/InProcessTeammateTask.tsx +1 -2
  498. package/tui/src/tasks/LocalAgentTask/LocalAgentTask.tsx +1 -2
  499. package/tui/src/tasks/LocalShellTask/LocalShellTask.tsx +1 -2
  500. package/tui/src/tasks/RemoteAgentTask/RemoteAgentTask.tsx +0 -1
  501. package/tui/src/tools/AgentTool/UI.tsx +1 -2
  502. package/tui/src/tools/BashTool/BashToolResultMessage.tsx +0 -1
  503. package/tui/src/tools/BashTool/UI.tsx +1 -2
  504. package/tui/src/tools/BriefTool/UI.tsx +0 -1
  505. package/tui/src/tools/ConfigTool/ConfigTool.ts +2 -2
  506. package/tui/src/tools/ConfigTool/UI.tsx +1 -2
  507. package/tui/src/tools/EnterPlanModeTool/UI.tsx +0 -1
  508. package/tui/src/tools/EnterWorktreeTool/UI.tsx +1 -2
  509. package/tui/src/tools/ExitPlanModeTool/UI.tsx +0 -1
  510. package/tui/src/tools/ExitWorktreeTool/UI.tsx +1 -2
  511. package/tui/src/tools/FileEditTool/UI.tsx +1 -2
  512. package/tui/src/tools/FileReadTool/UI.tsx +1 -2
  513. package/tui/src/tools/FileWriteTool/UI.tsx +1 -2
  514. package/tui/src/tools/GlobTool/UI.tsx +1 -2
  515. package/tui/src/tools/GrepTool/UI.tsx +1 -2
  516. package/tui/src/tools/LSPTool/UI.tsx +1 -2
  517. package/tui/src/tools/ListMcpResourcesTool/UI.tsx +1 -2
  518. package/tui/src/tools/MCPTool/UI.tsx +1 -2
  519. package/tui/src/tools/NotebookEditTool/UI.tsx +1 -2
  520. package/tui/src/tools/PowerShellTool/UI.tsx +0 -1
  521. package/tui/src/tools/ReadMcpResourceTool/UI.tsx +1 -2
  522. package/tui/src/tools/RemoteTriggerTool/UI.tsx +1 -2
  523. package/tui/src/tools/ScheduleCronTool/UI.tsx +1 -2
  524. package/tui/src/tools/SendMessageTool/UI.tsx +1 -2
  525. package/tui/src/tools/SkillTool/UI.tsx +1 -2
  526. package/tui/src/tools/TaskStopTool/UI.tsx +1 -2
  527. package/tui/src/tools/TeamCreateTool/UI.tsx +1 -2
  528. package/tui/src/tools/TeamDeleteTool/UI.tsx +1 -2
  529. package/tui/src/tools/WebFetchTool/UI.tsx +1 -2
  530. package/tui/src/tools/testing/TestingPermissionTool.tsx +1 -2
  531. package/tui/src/utils/auth.ts +8 -8
  532. package/tui/src/utils/autoRunIssue.tsx +1 -2
  533. package/tui/src/utils/billing.ts +2 -2
  534. package/tui/src/utils/computerUse/toolRendering.tsx +1 -2
  535. package/tui/src/utils/computerUse/wrapper.tsx +0 -1
  536. package/tui/src/utils/exportRenderer.tsx +1 -2
  537. package/tui/src/utils/fastMode.ts +2 -2
  538. package/tui/src/utils/highlightMatch.tsx +1 -2
  539. package/tui/src/utils/http.ts +2 -2
  540. package/tui/src/utils/managedEnv.ts +1 -1
  541. package/tui/src/utils/messages/systemInit.ts +2 -2
  542. package/tui/src/utils/plugins/performStartupChecks.tsx +1 -2
  543. package/tui/src/utils/preflightChecks.tsx +0 -1
  544. package/tui/src/utils/processUserInput/processBashCommand.tsx +1 -2
  545. package/tui/src/utils/processUserInput/processSlashCommand.tsx +0 -1
  546. package/tui/src/utils/staticRender.tsx +1 -2
  547. package/tui/src/utils/status.tsx +1 -2
  548. package/tui/src/utils/statusNoticeDefinitions.tsx +5 -6
  549. package/tui/src/utils/swarm/It2SetupPrompt.tsx +1 -2
  550. package/tui/src/utils/teleport.tsx +0 -1
  551. package/tui/src/voice/voiceModeEnabled.ts +3 -3
  552. package/uv.lock +1 -1
  553. package/src/ummaya/llm/_cc_reference/README.md +0 -104
  554. package/src/ummaya/llm/_cc_reference/api.ts +0 -721
  555. package/src/ummaya/llm/_cc_reference/claude.ts +0 -3422
  556. package/src/ummaya/llm/_cc_reference/client.ts +0 -392
  557. package/src/ummaya/llm/_cc_reference/emptyUsage.ts +0 -25
  558. package/src/ummaya/llm/_cc_reference/errors.ts +0 -1210
  559. package/src/ummaya/llm/_cc_reference/messages.ts +0 -5515
  560. package/src/ummaya/llm/_cc_reference/permissions.ts +0 -1489
  561. package/src/ummaya/llm/_cc_reference/prompts.ts +0 -917
  562. package/src/ummaya/llm/_cc_reference/query.ts +0 -1732
  563. package/src/ummaya/llm/_cc_reference/toolExecution.ts +0 -1748
  564. package/src/ummaya/llm/_cc_reference/toolOrchestration.ts +0 -191
  565. package/src/ummaya/llm/_cc_reference/toolResultStorage.ts +0 -1043
  566. package/src/ummaya/llm/_cc_reference/tools.ts +0 -392
@@ -1,721 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0 (Anthropic upstream) — research-use mirror
2
- // Source: .references/claude-code-sourcemap/restored-src/src/utils/api.ts (CC 2.1.88)
3
-
4
- import type Anthropic from '@anthropic-ai/sdk'
5
- import type {
6
- BetaTool,
7
- BetaToolUnion,
8
- } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs'
9
- import { createHash } from 'crypto'
10
- import { SYSTEM_PROMPT_DYNAMIC_BOUNDARY } from 'src/constants/prompts.js'
11
- import { getSystemContext, getUserContext } from 'src/context.js'
12
- import { isAnalyticsDisabled } from 'src/services/analytics/config.js'
13
- import {
14
- checkStatsigFeatureGate_CACHED_MAY_BE_STALE,
15
- getFeatureValue_CACHED_MAY_BE_STALE,
16
- } from 'src/services/analytics/growthbook.js'
17
- import {
18
- type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
19
- logEvent,
20
- } from 'src/services/analytics/index.js'
21
- import { prefetchAllMcpResources } from 'src/services/mcp/client.js'
22
- import type { ScopedMcpServerConfig } from 'src/services/mcp/types.js'
23
- import { BashTool } from 'src/tools/BashTool/BashTool.js'
24
- import { FileEditTool } from 'src/tools/FileEditTool/FileEditTool.js'
25
- import {
26
- normalizeFileEditInput,
27
- stripTrailingWhitespace,
28
- } from 'src/tools/FileEditTool/utils.js'
29
- import { FileWriteTool } from 'src/tools/FileWriteTool/FileWriteTool.js'
30
- import { getTools } from 'src/tools.js'
31
- import type { AgentId } from 'src/types/ids.js'
32
- import type { z } from 'zod/v4'
33
- import { CLI_SYSPROMPT_PREFIXES } from '../constants/system.js'
34
- import { roughTokenCountEstimation } from '../services/tokenEstimation.js'
35
- import type { Tool, ToolPermissionContext, Tools } from '../Tool.js'
36
- import { AGENT_TOOL_NAME } from '../tools/AgentTool/constants.js'
37
- import type { AgentDefinition } from '../tools/AgentTool/loadAgentsDir.js'
38
- import { EXIT_PLAN_MODE_V2_TOOL_NAME } from '../tools/ExitPlanModeTool/constants.js'
39
- import { TASK_OUTPUT_TOOL_NAME } from '../tools/TaskOutputTool/constants.js'
40
- import type { Message } from '../types/message.js'
41
- import { isAgentSwarmsEnabled } from './agentSwarmsEnabled.js'
42
- import {
43
- modelSupportsStructuredOutputs,
44
- shouldUseGlobalCacheScope,
45
- } from './betas.js'
46
- import { getCwd } from './cwd.js'
47
- import { logForDebugging } from './debug.js'
48
- import { isEnvTruthy } from './envUtils.js'
49
- import { createUserMessage } from './messages.js'
50
- import {
51
- getAPIProvider,
52
- isFirstPartyAnthropicBaseUrl,
53
- } from './model/providers.js'
54
- import {
55
- getFileReadIgnorePatterns,
56
- normalizePatternsToPath,
57
- } from './permissions/filesystem.js'
58
- import {
59
- getPlan,
60
- getPlanFilePath,
61
- persistFileSnapshotIfRemote,
62
- } from './plans.js'
63
- import { getPlatform } from './platform.js'
64
- import { countFilesRoundedRg } from './ripgrep.js'
65
- import { jsonStringify } from './slowOperations.js'
66
- import type { SystemPrompt } from './systemPromptType.js'
67
- import { getToolSchemaCache } from './toolSchemaCache.js'
68
- import { windowsPathToPosixPath } from './windowsPaths.js'
69
- import { zodToJsonSchema } from './zodToJsonSchema.js'
70
-
71
- // Extended BetaTool type with strict mode and defer_loading support
72
- type BetaToolWithExtras = BetaTool & {
73
- strict?: boolean
74
- defer_loading?: boolean
75
- cache_control?: {
76
- type: 'ephemeral'
77
- scope?: 'global' | 'org'
78
- ttl?: '5m' | '1h'
79
- }
80
- eager_input_streaming?: boolean
81
- }
82
-
83
- export type CacheScope = 'global' | 'org'
84
- export type SystemPromptBlock = {
85
- text: string
86
- cacheScope: CacheScope | null
87
- }
88
-
89
- // Fields to filter from tool schemas when swarms are not enabled
90
- const SWARM_FIELDS_BY_TOOL: Record<string, string[]> = {
91
- [EXIT_PLAN_MODE_V2_TOOL_NAME]: ['launchSwarm', 'teammateCount'],
92
- [AGENT_TOOL_NAME]: ['name', 'team_name', 'mode'],
93
- }
94
-
95
- /**
96
- * Filter swarm-related fields from a tool's input schema.
97
- * Called at runtime when isAgentSwarmsEnabled() returns false.
98
- */
99
- function filterSwarmFieldsFromSchema(
100
- toolName: string,
101
- schema: Anthropic.Tool.InputSchema,
102
- ): Anthropic.Tool.InputSchema {
103
- const fieldsToRemove = SWARM_FIELDS_BY_TOOL[toolName]
104
- if (!fieldsToRemove || fieldsToRemove.length === 0) {
105
- return schema
106
- }
107
-
108
- // Clone the schema to avoid mutating the original
109
- const filtered = { ...schema }
110
- const props = filtered.properties
111
- if (props && typeof props === 'object') {
112
- const filteredProps = { ...(props as Record<string, unknown>) }
113
- for (const field of fieldsToRemove) {
114
- delete filteredProps[field]
115
- }
116
- filtered.properties = filteredProps
117
- }
118
-
119
- return filtered
120
- }
121
-
122
- export async function toolToAPISchema(
123
- tool: Tool,
124
- options: {
125
- getToolPermissionContext: () => Promise<ToolPermissionContext>
126
- tools: Tools
127
- agents: AgentDefinition[]
128
- allowedAgentTypes?: string[]
129
- model?: string
130
- /** When true, mark this tool with defer_loading for tool search */
131
- deferLoading?: boolean
132
- cacheControl?: {
133
- type: 'ephemeral'
134
- scope?: 'global' | 'org'
135
- ttl?: '5m' | '1h'
136
- }
137
- },
138
- ): Promise<BetaToolUnion> {
139
- // Session-stable base schema: name, description, input_schema, strict,
140
- // eager_input_streaming. These are computed once per session and cached to
141
- // prevent mid-session GrowthBook flips (tengu_tool_pear, tengu_fgts) or
142
- // tool.prompt() drift from churning the serialized tool array bytes.
143
- // See toolSchemaCache.ts for rationale.
144
- //
145
- // Cache key includes inputJSONSchema when present. StructuredOutput instances
146
- // share the name 'StructuredOutput' but carry different schemas per workflow
147
- // call — name-only keying returned a stale schema (5.4% → 51% err rate, see
148
- // PR#25424). MCP tools also set inputJSONSchema but each has a stable schema,
149
- // so including it preserves their GB-flip cache stability.
150
- const cacheKey =
151
- 'inputJSONSchema' in tool && tool.inputJSONSchema
152
- ? `${tool.name}:${jsonStringify(tool.inputJSONSchema)}`
153
- : tool.name
154
- const cache = getToolSchemaCache()
155
- let base = cache.get(cacheKey)
156
- if (!base) {
157
- const strictToolsEnabled =
158
- checkStatsigFeatureGate_CACHED_MAY_BE_STALE('tengu_tool_pear')
159
- // Use tool's JSON schema directly if provided, otherwise convert Zod schema
160
- let input_schema = (
161
- 'inputJSONSchema' in tool && tool.inputJSONSchema
162
- ? tool.inputJSONSchema
163
- : zodToJsonSchema(tool.inputSchema)
164
- ) as Anthropic.Tool.InputSchema
165
-
166
- // Filter out swarm-related fields when swarms are not enabled
167
- // This ensures external non-EAP users don't see swarm features in the schema
168
- if (!isAgentSwarmsEnabled()) {
169
- input_schema = filterSwarmFieldsFromSchema(tool.name, input_schema)
170
- }
171
-
172
- base = {
173
- name: tool.name,
174
- description: await tool.prompt({
175
- getToolPermissionContext: options.getToolPermissionContext,
176
- tools: options.tools,
177
- agents: options.agents,
178
- allowedAgentTypes: options.allowedAgentTypes,
179
- }),
180
- input_schema,
181
- }
182
-
183
- // Only add strict if:
184
- // 1. Feature flag is enabled
185
- // 2. Tool has strict: true
186
- // 3. Model is provided and supports it (not all models support it right now)
187
- // (if model is not provided, assume we can't use strict tools)
188
- if (
189
- strictToolsEnabled &&
190
- tool.strict === true &&
191
- options.model &&
192
- modelSupportsStructuredOutputs(options.model)
193
- ) {
194
- base.strict = true
195
- }
196
-
197
- // Enable fine-grained tool streaming via per-tool API field.
198
- // Without FGTS, the API buffers entire tool input parameters before sending
199
- // input_json_delta events, causing multi-minute hangs on large tool inputs.
200
- // Gated to direct api.anthropic.com: proxies (LiteLLM etc.) and Bedrock/Vertex
201
- // with Claude 4.5 reject this field with 400. See GH#32742, PR #21729.
202
- if (
203
- getAPIProvider() === 'firstParty' &&
204
- isFirstPartyAnthropicBaseUrl() &&
205
- (getFeatureValue_CACHED_MAY_BE_STALE('tengu_fgts', false) ||
206
- isEnvTruthy(process.env.CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING))
207
- ) {
208
- base.eager_input_streaming = true
209
- }
210
-
211
- cache.set(cacheKey, base)
212
- }
213
-
214
- // Per-request overlay: defer_loading and cache_control vary by call
215
- // (tool search defers different tools per turn; cache markers move).
216
- // Explicit field copy avoids mutating the cached base and sidesteps
217
- // BetaTool.cache_control's `| null` clashing with our narrower type.
218
- const schema: BetaToolWithExtras = {
219
- name: base.name,
220
- description: base.description,
221
- input_schema: base.input_schema,
222
- ...(base.strict && { strict: true }),
223
- ...(base.eager_input_streaming && { eager_input_streaming: true }),
224
- }
225
-
226
- // Add defer_loading if requested (for tool search feature)
227
- if (options.deferLoading) {
228
- schema.defer_loading = true
229
- }
230
-
231
- if (options.cacheControl) {
232
- schema.cache_control = options.cacheControl
233
- }
234
-
235
- // CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS is the kill switch for beta API
236
- // shapes. Proxy gateways (ANTHROPIC_BASE_URL → LiteLLM → Bedrock) reject
237
- // fields like defer_loading with "Extra inputs are not permitted". The gates
238
- // above each field are scattered and not all provider-aware, so this strips
239
- // everything not in the base-tool allowlist at the one choke point all tool
240
- // schemas pass through — including fields added in the future.
241
- // cache_control is allowlisted: the base {type: 'ephemeral'} shape is
242
- // standard prompt caching (Bedrock/Vertex supported); the beta sub-fields
243
- // (scope, ttl) are already gated upstream by shouldIncludeFirstPartyOnlyBetas
244
- // which independently respects this kill switch.
245
- // github.com/anthropics/claude-code/issues/20031
246
- if (isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)) {
247
- const allowed = new Set([
248
- 'name',
249
- 'description',
250
- 'input_schema',
251
- 'cache_control',
252
- ])
253
- const stripped = Object.keys(schema).filter(k => !allowed.has(k))
254
- if (stripped.length > 0) {
255
- logStripOnce(stripped)
256
- return {
257
- name: schema.name,
258
- description: schema.description,
259
- input_schema: schema.input_schema,
260
- ...(schema.cache_control && { cache_control: schema.cache_control }),
261
- }
262
- }
263
- }
264
-
265
- // Note: We cast to BetaTool but the extra fields are still present at runtime
266
- // and will be serialized in the API request, even though they're not in the SDK's
267
- // BetaTool type definition. This is intentional for beta features.
268
- return schema as BetaTool
269
- }
270
-
271
- let loggedStrip = false
272
- function logStripOnce(stripped: string[]): void {
273
- if (loggedStrip) return
274
- loggedStrip = true
275
- logForDebugging(
276
- `[betas] Stripped from tool schemas: [${stripped.join(', ')}] (CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1)`,
277
- )
278
- }
279
-
280
- /**
281
- * Log stats about first block for analyzing prefix matching config
282
- * (see https://console.statsig.com/4aF3Ewatb6xPVpCwxb5nA3/dynamic_configs/claude_cli_system_prompt_prefixes)
283
- */
284
- export function logAPIPrefix(systemPrompt: SystemPrompt): void {
285
- const [firstSyspromptBlock] = splitSysPromptPrefix(systemPrompt)
286
- const firstSystemPrompt = firstSyspromptBlock?.text
287
- logEvent('tengu_sysprompt_block', {
288
- snippet: firstSystemPrompt?.slice(
289
- 0,
290
- 20,
291
- ) as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
292
- length: firstSystemPrompt?.length ?? 0,
293
- hash: (firstSystemPrompt
294
- ? createHash('sha256').update(firstSystemPrompt).digest('hex')
295
- : '') as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
296
- })
297
- }
298
-
299
- /**
300
- * Split system prompt blocks by content type for API matching and cache control.
301
- * See https://console.statsig.com/4aF3Ewatb6xPVpCwxb5nA3/dynamic_configs/claude_cli_system_prompt_prefixes
302
- *
303
- * Behavior depends on feature flags and options:
304
- *
305
- * 1. MCP tools present (skipGlobalCacheForSystemPrompt=true):
306
- * Returns up to 3 blocks with org-level caching (no global cache on system prompt):
307
- * - Attribution header (cacheScope=null)
308
- * - System prompt prefix (cacheScope='org')
309
- * - Everything else concatenated (cacheScope='org')
310
- *
311
- * 2. Global cache mode with boundary marker (1P only, boundary found):
312
- * Returns up to 4 blocks:
313
- * - Attribution header (cacheScope=null)
314
- * - System prompt prefix (cacheScope=null)
315
- * - Static content before boundary (cacheScope='global')
316
- * - Dynamic content after boundary (cacheScope=null)
317
- *
318
- * 3. Default mode (3P providers, or boundary missing):
319
- * Returns up to 3 blocks with org-level caching:
320
- * - Attribution header (cacheScope=null)
321
- * - System prompt prefix (cacheScope='org')
322
- * - Everything else concatenated (cacheScope='org')
323
- */
324
- export function splitSysPromptPrefix(
325
- systemPrompt: SystemPrompt,
326
- options?: { skipGlobalCacheForSystemPrompt?: boolean },
327
- ): SystemPromptBlock[] {
328
- const useGlobalCacheFeature = shouldUseGlobalCacheScope()
329
- if (useGlobalCacheFeature && options?.skipGlobalCacheForSystemPrompt) {
330
- logEvent('tengu_sysprompt_using_tool_based_cache', {
331
- promptBlockCount: systemPrompt.length,
332
- })
333
-
334
- // Filter out boundary marker, return blocks without global scope
335
- let attributionHeader: string | undefined
336
- let systemPromptPrefix: string | undefined
337
- const rest: string[] = []
338
-
339
- for (const prompt of systemPrompt) {
340
- if (!prompt) continue
341
- if (prompt === SYSTEM_PROMPT_DYNAMIC_BOUNDARY) continue // Skip boundary
342
- if (prompt.startsWith('x-anthropic-billing-header')) {
343
- attributionHeader = prompt
344
- } else if (CLI_SYSPROMPT_PREFIXES.has(prompt)) {
345
- systemPromptPrefix = prompt
346
- } else {
347
- rest.push(prompt)
348
- }
349
- }
350
-
351
- const result: SystemPromptBlock[] = []
352
- if (attributionHeader) {
353
- result.push({ text: attributionHeader, cacheScope: null })
354
- }
355
- if (systemPromptPrefix) {
356
- result.push({ text: systemPromptPrefix, cacheScope: 'org' })
357
- }
358
- const restJoined = rest.join('\n\n')
359
- if (restJoined) {
360
- result.push({ text: restJoined, cacheScope: 'org' })
361
- }
362
- return result
363
- }
364
-
365
- if (useGlobalCacheFeature) {
366
- const boundaryIndex = systemPrompt.findIndex(
367
- s => s === SYSTEM_PROMPT_DYNAMIC_BOUNDARY,
368
- )
369
- if (boundaryIndex !== -1) {
370
- let attributionHeader: string | undefined
371
- let systemPromptPrefix: string | undefined
372
- const staticBlocks: string[] = []
373
- const dynamicBlocks: string[] = []
374
-
375
- for (let i = 0; i < systemPrompt.length; i++) {
376
- const block = systemPrompt[i]
377
- if (!block || block === SYSTEM_PROMPT_DYNAMIC_BOUNDARY) continue
378
-
379
- if (block.startsWith('x-anthropic-billing-header')) {
380
- attributionHeader = block
381
- } else if (CLI_SYSPROMPT_PREFIXES.has(block)) {
382
- systemPromptPrefix = block
383
- } else if (i < boundaryIndex) {
384
- staticBlocks.push(block)
385
- } else {
386
- dynamicBlocks.push(block)
387
- }
388
- }
389
-
390
- const result: SystemPromptBlock[] = []
391
- if (attributionHeader)
392
- result.push({ text: attributionHeader, cacheScope: null })
393
- if (systemPromptPrefix)
394
- result.push({ text: systemPromptPrefix, cacheScope: null })
395
- const staticJoined = staticBlocks.join('\n\n')
396
- if (staticJoined)
397
- result.push({ text: staticJoined, cacheScope: 'global' })
398
- const dynamicJoined = dynamicBlocks.join('\n\n')
399
- if (dynamicJoined) result.push({ text: dynamicJoined, cacheScope: null })
400
-
401
- logEvent('tengu_sysprompt_boundary_found', {
402
- blockCount: result.length,
403
- staticBlockLength: staticJoined.length,
404
- dynamicBlockLength: dynamicJoined.length,
405
- })
406
-
407
- return result
408
- } else {
409
- logEvent('tengu_sysprompt_missing_boundary_marker', {
410
- promptBlockCount: systemPrompt.length,
411
- })
412
- }
413
- }
414
- let attributionHeader: string | undefined
415
- let systemPromptPrefix: string | undefined
416
- const rest: string[] = []
417
-
418
- for (const block of systemPrompt) {
419
- if (!block) continue
420
-
421
- if (block.startsWith('x-anthropic-billing-header')) {
422
- attributionHeader = block
423
- } else if (CLI_SYSPROMPT_PREFIXES.has(block)) {
424
- systemPromptPrefix = block
425
- } else {
426
- rest.push(block)
427
- }
428
- }
429
-
430
- const result: SystemPromptBlock[] = []
431
- if (attributionHeader)
432
- result.push({ text: attributionHeader, cacheScope: null })
433
- if (systemPromptPrefix)
434
- result.push({ text: systemPromptPrefix, cacheScope: 'org' })
435
- const restJoined = rest.join('\n\n')
436
- if (restJoined) result.push({ text: restJoined, cacheScope: 'org' })
437
- return result
438
- }
439
-
440
- export function appendSystemContext(
441
- systemPrompt: SystemPrompt,
442
- context: { [k: string]: string },
443
- ): string[] {
444
- return [
445
- ...systemPrompt,
446
- Object.entries(context)
447
- .map(([key, value]) => `${key}: ${value}`)
448
- .join('\n'),
449
- ].filter(Boolean)
450
- }
451
-
452
- export function prependUserContext(
453
- messages: Message[],
454
- context: { [k: string]: string },
455
- ): Message[] {
456
- if (process.env.NODE_ENV === 'test') {
457
- return messages
458
- }
459
-
460
- if (Object.entries(context).length === 0) {
461
- return messages
462
- }
463
-
464
- return [
465
- createUserMessage({
466
- content: `<system-reminder>\nAs you answer the user's questions, you can use the following context:\n${Object.entries(
467
- context,
468
- )
469
- .map(([key, value]) => `# ${key}\n${value}`)
470
- .join('\n')}
471
-
472
- IMPORTANT: this context may or may not be relevant to your tasks. You should not respond to this context unless it is highly relevant to your task.\n</system-reminder>\n`,
473
- isMeta: true,
474
- }),
475
- ...messages,
476
- ]
477
- }
478
-
479
- /**
480
- * Log metrics about context and system prompt size
481
- */
482
- export async function logContextMetrics(
483
- mcpConfigs: Record<string, ScopedMcpServerConfig>,
484
- toolPermissionContext: ToolPermissionContext,
485
- ): Promise<void> {
486
- // Early return if logging is disabled
487
- if (isAnalyticsDisabled()) {
488
- return
489
- }
490
- const [{ tools: mcpTools }, tools, userContext, systemContext] =
491
- await Promise.all([
492
- prefetchAllMcpResources(mcpConfigs),
493
- getTools(toolPermissionContext),
494
- getUserContext(),
495
- getSystemContext(),
496
- ])
497
- // Extract individual context sizes and calculate total
498
- const gitStatusSize = systemContext.gitStatus?.length ?? 0
499
- const claudeMdSize = userContext.claudeMd?.length ?? 0
500
-
501
- // Calculate total context size
502
- const totalContextSize = gitStatusSize + claudeMdSize
503
-
504
- // Get file count using ripgrep (rounded to nearest power of 10 for privacy)
505
- const currentDir = getCwd()
506
- const ignorePatternsByRoot = getFileReadIgnorePatterns(toolPermissionContext)
507
- const normalizedIgnorePatterns = normalizePatternsToPath(
508
- ignorePatternsByRoot,
509
- currentDir,
510
- )
511
- const fileCount = await countFilesRoundedRg(
512
- currentDir,
513
- AbortSignal.timeout(1000),
514
- normalizedIgnorePatterns,
515
- )
516
-
517
- // Calculate tool metrics
518
- let mcpToolsCount = 0
519
- let mcpServersCount = 0
520
- let mcpToolsTokens = 0
521
- let nonMcpToolsCount = 0
522
- let nonMcpToolsTokens = 0
523
-
524
- const nonMcpTools = tools.filter(tool => !tool.isMcp)
525
- mcpToolsCount = mcpTools.length
526
- nonMcpToolsCount = nonMcpTools.length
527
-
528
- // Extract unique server names from MCP tool names (format: mcp__servername__toolname)
529
- const serverNames = new Set<string>()
530
- for (const tool of mcpTools) {
531
- const parts = tool.name.split('__')
532
- if (parts.length >= 3 && parts[1]) {
533
- serverNames.add(parts[1])
534
- }
535
- }
536
- mcpServersCount = serverNames.size
537
-
538
- // Estimate tool tokens locally for analytics (avoids N API calls per session)
539
- // Use inputJSONSchema (plain JSON Schema) when available, otherwise convert Zod schema
540
- for (const tool of mcpTools) {
541
- const schema =
542
- 'inputJSONSchema' in tool && tool.inputJSONSchema
543
- ? tool.inputJSONSchema
544
- : zodToJsonSchema(tool.inputSchema)
545
- mcpToolsTokens += roughTokenCountEstimation(jsonStringify(schema))
546
- }
547
- for (const tool of nonMcpTools) {
548
- const schema =
549
- 'inputJSONSchema' in tool && tool.inputJSONSchema
550
- ? tool.inputJSONSchema
551
- : zodToJsonSchema(tool.inputSchema)
552
- nonMcpToolsTokens += roughTokenCountEstimation(jsonStringify(schema))
553
- }
554
-
555
- logEvent('tengu_context_size', {
556
- git_status_size: gitStatusSize,
557
- claude_md_size: claudeMdSize,
558
- total_context_size: totalContextSize,
559
- project_file_count_rounded: fileCount,
560
- mcp_tools_count: mcpToolsCount,
561
- mcp_servers_count: mcpServersCount,
562
- mcp_tools_tokens: mcpToolsTokens,
563
- non_mcp_tools_count: nonMcpToolsCount,
564
- non_mcp_tools_tokens: nonMcpToolsTokens,
565
- })
566
- }
567
-
568
- // TODO: Generalize this to all tools
569
- export function normalizeToolInput<T extends Tool>(
570
- tool: T,
571
- input: z.infer<T['inputSchema']>,
572
- agentId?: AgentId,
573
- ): z.infer<T['inputSchema']> {
574
- switch (tool.name) {
575
- case EXIT_PLAN_MODE_V2_TOOL_NAME: {
576
- // Always inject plan content and file path for ExitPlanModeV2 so hooks/SDK get the plan.
577
- // The V2 tool reads plan from file instead of input, but hooks/SDK
578
- const plan = getPlan(agentId)
579
- const planFilePath = getPlanFilePath(agentId)
580
- // Persist file snapshot for CCR sessions so the plan survives pod recycling
581
- void persistFileSnapshotIfRemote()
582
- return plan !== null ? { ...input, plan, planFilePath } : input
583
- }
584
- case BashTool.name: {
585
- // Validated upstream, won't throw
586
- const parsed = BashTool.inputSchema.parse(input)
587
- const { command, timeout, description } = parsed
588
- const cwd = getCwd()
589
- let normalizedCommand = command.replace(`cd ${cwd} && `, '')
590
- if (getPlatform() === 'windows') {
591
- normalizedCommand = normalizedCommand.replace(
592
- `cd ${windowsPathToPosixPath(cwd)} && `,
593
- '',
594
- )
595
- }
596
-
597
- // Replace \\; with \; (commonly needed for find -exec commands)
598
- normalizedCommand = normalizedCommand.replace(/\\\\;/g, '\\;')
599
-
600
- // Logging for commands that are only echoing a string. This is to help us understand how often Claude talks via bash
601
- if (/^echo\s+["']?[^|&;><]*["']?$/i.test(normalizedCommand.trim())) {
602
- logEvent('tengu_bash_tool_simple_echo', {})
603
- }
604
-
605
- // Check for run_in_background (may not exist in schema if CLAUDE_CODE_DISABLE_BACKGROUND_TASKS is set)
606
- const run_in_background =
607
- 'run_in_background' in parsed ? parsed.run_in_background : undefined
608
-
609
- // SAFETY: Cast is safe because input was validated by .parse() above.
610
- // TypeScript can't narrow the generic T based on switch(tool.name), so it
611
- // doesn't know the return type matches T['inputSchema']. This is a fundamental
612
- // TS limitation with generics, not bypassable without major refactoring.
613
- return {
614
- command: normalizedCommand,
615
- description,
616
- ...(timeout !== undefined && { timeout }),
617
- ...(description !== undefined && { description }),
618
- ...(run_in_background !== undefined && { run_in_background }),
619
- ...('dangerouslyDisableSandbox' in parsed &&
620
- parsed.dangerouslyDisableSandbox !== undefined && {
621
- dangerouslyDisableSandbox: parsed.dangerouslyDisableSandbox,
622
- }),
623
- } as z.infer<T['inputSchema']>
624
- }
625
- case FileEditTool.name: {
626
- // Validated upstream, won't throw
627
- const parsedInput = FileEditTool.inputSchema.parse(input)
628
-
629
- // This is a workaround for tokens claude can't see
630
- const { file_path, edits } = normalizeFileEditInput({
631
- file_path: parsedInput.file_path,
632
- edits: [
633
- {
634
- old_string: parsedInput.old_string,
635
- new_string: parsedInput.new_string,
636
- replace_all: parsedInput.replace_all,
637
- },
638
- ],
639
- })
640
-
641
- // SAFETY: See comment in BashTool case above
642
- return {
643
- replace_all: edits[0]!.replace_all,
644
- file_path,
645
- old_string: edits[0]!.old_string,
646
- new_string: edits[0]!.new_string,
647
- } as z.infer<T['inputSchema']>
648
- }
649
- case FileWriteTool.name: {
650
- // Validated upstream, won't throw
651
- const parsedInput = FileWriteTool.inputSchema.parse(input)
652
-
653
- // Markdown uses two trailing spaces as a hard line break — don't strip.
654
- const isMarkdown = /\.(md|mdx)$/i.test(parsedInput.file_path)
655
-
656
- // SAFETY: See comment in BashTool case above
657
- return {
658
- file_path: parsedInput.file_path,
659
- content: isMarkdown
660
- ? parsedInput.content
661
- : stripTrailingWhitespace(parsedInput.content),
662
- } as z.infer<T['inputSchema']>
663
- }
664
- case TASK_OUTPUT_TOOL_NAME: {
665
- // Normalize legacy parameter names from AgentOutputTool/BashOutputTool
666
- const legacyInput = input as Record<string, unknown>
667
- const taskId =
668
- legacyInput.task_id ?? legacyInput.agentId ?? legacyInput.bash_id
669
- const timeout =
670
- legacyInput.timeout ??
671
- (typeof legacyInput.wait_up_to === 'number'
672
- ? legacyInput.wait_up_to * 1000
673
- : undefined)
674
- // SAFETY: See comment in BashTool case above
675
- return {
676
- task_id: taskId ?? '',
677
- block: legacyInput.block ?? true,
678
- timeout: timeout ?? 30000,
679
- } as z.infer<T['inputSchema']>
680
- }
681
- default:
682
- return input
683
- }
684
- }
685
-
686
- // Strips fields that were added by normalizeToolInput before sending to API
687
- // (e.g., plan field from ExitPlanModeV2 which has an empty input schema)
688
- export function normalizeToolInputForAPI<T extends Tool>(
689
- tool: T,
690
- input: z.infer<T['inputSchema']>,
691
- ): z.infer<T['inputSchema']> {
692
- switch (tool.name) {
693
- case EXIT_PLAN_MODE_V2_TOOL_NAME: {
694
- // Strip injected fields before sending to API (schema expects empty object)
695
- if (
696
- input &&
697
- typeof input === 'object' &&
698
- ('plan' in input || 'planFilePath' in input)
699
- ) {
700
- const { plan, planFilePath, ...rest } = input as Record<string, unknown>
701
- return rest as z.infer<T['inputSchema']>
702
- }
703
- return input
704
- }
705
- case FileEditTool.name: {
706
- // Strip synthetic old_string/new_string/replace_all from OLD sessions
707
- // that were resumed from transcripts written before PR #20357, where
708
- // normalizeToolInput used to synthesize these. Needed so old --resume'd
709
- // transcripts don't send whole-file copies to the API. New sessions
710
- // don't need this (synthesis moved to emission time).
711
- if (input && typeof input === 'object' && 'edits' in input) {
712
- const { old_string, new_string, replace_all, ...rest } =
713
- input as Record<string, unknown>
714
- return rest as z.infer<T['inputSchema']>
715
- }
716
- return input
717
- }
718
- default:
719
- return input
720
- }
721
- }