@iaforged/context-code 2.1.7 → 2.1.8
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.
- package/dist/src/Task.js +1 -1
- package/dist/src/constants/oauth.js +1 -1
- package/dist/src/context/mailbox.js +1 -1
- package/dist/src/context/voice.js +1 -1
- package/dist/src/hooks/useTerminalSize.js +1 -1
- package/dist/src/ink/Ansi.js +1 -1
- package/dist/src/ink/clearTerminal.js +1 -1
- package/dist/src/ink/colorize.js +1 -1
- package/dist/src/ink/components/App.js +1 -1
- package/dist/src/ink/components/Button.js +1 -1
- package/dist/src/ink/components/ClockContext.js +1 -1
- package/dist/src/ink/components/CursorDeclarationContext.js +1 -1
- package/dist/src/ink/components/Link.js +1 -1
- package/dist/src/ink/components/StdinContext.js +1 -1
- package/dist/src/ink/components/TerminalFocusContext.js +1 -1
- package/dist/src/ink/dom.js +1 -1
- package/dist/src/ink/events/keyboard-event.js +1 -1
- package/dist/src/ink/hit-test.js +1 -1
- package/dist/src/ink/hooks/use-animation-frame.js +1 -1
- package/dist/src/ink/hooks/use-app.js +1 -1
- package/dist/src/ink/hooks/use-input.js +1 -1
- package/dist/src/ink/hooks/use-interval.js +1 -1
- package/dist/src/ink/hooks/use-selection.js +1 -1
- package/dist/src/ink/hooks/use-tab-status.js +1 -1
- package/dist/src/ink/hooks/use-terminal-focus.js +1 -1
- package/dist/src/ink/hooks/use-terminal-title.js +1 -1
- package/dist/src/ink/hooks/use-terminal-viewport.js +1 -1
- package/dist/src/ink/ink.js +1 -1
- package/dist/src/ink/layout/yoga.js +1 -1
- package/dist/src/ink/line-width-cache.js +1 -1
- package/dist/src/ink/log-update.js +1 -1
- package/dist/src/ink/measure-text.js +1 -1
- package/dist/src/ink/output.js +1 -1
- package/dist/src/ink/parse-keypress.js +1 -1
- package/dist/src/ink/reconciler.js +1 -1
- package/dist/src/ink/render-border.js +1 -1
- package/dist/src/ink/render-node-to-output.js +1 -1
- package/dist/src/ink/render-to-screen.js +1 -1
- package/dist/src/ink/renderer.js +1 -1
- package/dist/src/ink/root.js +1 -1
- package/dist/src/ink/screen.js +1 -1
- package/dist/src/ink/searchHighlight.js +1 -1
- package/dist/src/ink/selection.js +1 -1
- package/dist/src/ink/squash-text-nodes.js +1 -1
- package/dist/src/ink/stringWidth.js +1 -1
- package/dist/src/ink/tabstops.js +1 -1
- package/dist/src/ink/terminal.js +1 -1
- package/dist/src/ink/termio/osc.js +1 -1
- package/dist/src/ink/termio/parser.js +1 -1
- package/dist/src/ink/termio/tokenize.js +1 -1
- package/dist/src/ink/useTerminalNotification.js +1 -1
- package/dist/src/ink/warn.js +1 -1
- package/dist/src/ink/widest-line.js +1 -1
- package/dist/src/ink/wrap-text.js +1 -1
- package/dist/src/ink/wrapAnsi.js +1 -1
- package/dist/src/native-ts/yoga-layout/index.js +1 -1
- package/dist/src/schemas/hooks.js +1 -1
- package/dist/src/services/SessionMemory/sessionMemoryUtils.js +1 -1
- package/dist/src/services/api/client.js +1 -1
- package/dist/src/services/api/dumpPrompts.js +1 -1
- package/dist/src/services/api/errorUtils.js +1 -1
- package/dist/src/services/api/promptCacheBreakDetection.js +1 -1
- package/dist/src/services/api/withRetry.js +1 -1
- package/dist/src/services/autoDream/consolidationLock.js +1 -1
- package/dist/src/services/mcp/elicitationHandler.js +1 -1
- package/dist/src/services/mcp/mcpStringUtils.js +1 -1
- package/dist/src/services/mcp/oauthPort.js +1 -1
- package/dist/src/services/mcp/vscodeSdkMcp.js +1 -1
- package/dist/src/services/oauth/client.js +1 -1
- package/dist/src/services/oauth/getOauthProfile.js +1 -1
- package/dist/src/services/objetivo/types.js +1 -1
- package/dist/src/services/rateLimitMocking.js +1 -1
- package/dist/src/services/remoteManagedSettings/syncCacheState.js +1 -1
- package/dist/src/skills/bundledSkills.js +1 -1
- package/dist/src/tasks/DreamTask/DreamTask.js +1 -1
- package/dist/src/tools/AgentTool/agentMemory.js +1 -1
- package/dist/src/tools/AgentTool/forkSubagent.js +1 -1
- package/dist/src/tools/BashTool/BashToolResultMessage.js +1 -1
- package/dist/src/tools/BashTool/UI.js +1 -1
- package/dist/src/tools/BashTool/sedEditParser.js +1 -1
- package/dist/src/tools/BashTool/utils.js +1 -1
- package/dist/src/tools/FileReadTool/imageProcessor.js +1 -1
- package/dist/src/tools/FileReadTool/prompt.js +1 -1
- package/dist/src/tools/ListMcpResourcesTool/ListMcpResourcesTool.js +1 -1
- package/dist/src/tools/ListMcpResourcesTool/UI.js +1 -1
- package/dist/src/tools/MCPTool/MCPTool.js +1 -1
- package/dist/src/tools/MCPTool/UI.js +1 -1
- package/dist/src/tools/McpAuthTool/McpAuthTool.js +1 -1
- package/dist/src/tools/NotebookEditTool/prompt.js +1 -1
- package/dist/src/tools/PowerShellTool/PowerShellTool.js +1 -1
- package/dist/src/tools/PowerShellTool/UI.js +1 -1
- package/dist/src/tools/PowerShellTool/gitSafety.js +1 -1
- package/dist/src/tools/PowerShellTool/modeValidation.js +1 -1
- package/dist/src/tools/PowerShellTool/pathValidation.js +1 -1
- package/dist/src/tools/PowerShellTool/powershellPermissions.js +1 -1
- package/dist/src/tools/PowerShellTool/powershellSecurity.js +1 -1
- package/dist/src/tools/PowerShellTool/prompt.js +1 -1
- package/dist/src/tools/PowerShellTool/readOnlyValidation.js +1 -1
- package/dist/src/tools/REPLTool/constants.js +1 -1
- package/dist/src/tools/REPLTool/primitiveTools.js +1 -1
- package/dist/src/tools/ReadMcpResourceTool/ReadMcpResourceTool.js +1 -1
- package/dist/src/tools/ReadMcpResourceTool/UI.js +1 -1
- package/dist/src/tools/ScheduleCronTool/prompt.js +1 -1
- package/dist/src/tools/SkillTool/prompt.js +1 -1
- package/dist/src/tools/TodoWriteTool/TodoWriteTool.js +1 -1
- package/dist/src/tools/ToolSearchTool/prompt.js +1 -1
- package/dist/src/tools/WebSearchTool/prompt.js +1 -1
- package/dist/src/tools/shared/gitOperationTracking.js +1 -1
- package/dist/src/types/permissions.js +1 -1
- package/dist/src/utils/Cursor.js +1 -1
- package/dist/src/utils/QueryGuard.js +1 -1
- package/dist/src/utils/Shell.js +1 -1
- package/dist/src/utils/ShellCommand.js +1 -1
- package/dist/src/utils/activityManager.js +1 -1
- package/dist/src/utils/advisor.js +1 -1
- package/dist/src/utils/appleTerminalBackup.js +1 -1
- package/dist/src/utils/argumentSubstitution.js +1 -1
- package/dist/src/utils/authFileDescriptor.js +1 -1
- package/dist/src/utils/autoUpdater.js +1 -1
- package/dist/src/utils/background/remote/preconditions.js +1 -1
- package/dist/src/utils/background/remote/remoteSession.js +1 -1
- package/dist/src/utils/bash/ShellSnapshot.js +1 -1
- package/dist/src/utils/bash/ast.js +1 -1
- package/dist/src/utils/bash/bashParser.js +1 -1
- package/dist/src/utils/bash/bashPipeCommand.js +1 -1
- package/dist/src/utils/bash/parser.js +1 -1
- package/dist/src/utils/bash/shellQuote.js +1 -1
- package/dist/src/utils/bash/shellQuoting.js +1 -1
- package/dist/src/utils/billing.js +1 -1
- package/dist/src/utils/caCerts.js +1 -1
- package/dist/src/utils/claudeInChrome/common.js +1 -1
- package/dist/src/utils/claudeInChrome/setupPortable.js +1 -1
- package/dist/src/utils/claudemd.js +1 -1
- package/dist/src/utils/collapseBackgroundBashNotifications.js +1 -1
- package/dist/src/utils/collapseReadSearch.js +1 -1
- package/dist/src/utils/completionCache.js +1 -1
- package/dist/src/utils/computerUse/common.js +1 -1
- package/dist/src/utils/concurrentSessions.js +1 -1
- package/dist/src/utils/context.js +1 -1
- package/dist/src/utils/cron.js +1 -1
- package/dist/src/utils/cronTasks.js +1 -1
- package/dist/src/utils/cwd.js +1 -1
- package/dist/src/utils/debug.js +1 -1
- package/dist/src/utils/debugFilter.js +1 -1
- package/dist/src/utils/detectRepository.js +1 -1
- package/dist/src/utils/diagLogs.js +1 -1
- package/dist/src/utils/diff.js +1 -1
- package/dist/src/utils/directMemberMessage.js +1 -1
- package/dist/src/utils/doctorDiagnostic.js +1 -1
- package/dist/src/utils/dxt/helpers.js +1 -1
- package/dist/src/utils/dxt/zip.js +1 -1
- package/dist/src/utils/earlyInput.js +1 -1
- package/dist/src/utils/editor.js +1 -1
- package/dist/src/utils/effort.js +1 -1
- package/dist/src/utils/embeddedTools.js +1 -1
- package/dist/src/utils/envDynamic.js +1 -1
- package/dist/src/utils/envUtils.js +1 -1
- package/dist/src/utils/execFileNoThrowPortable.js +1 -1
- package/dist/src/utils/execSyncWrapper.js +1 -1
- package/dist/src/utils/exportRenderer.js +1 -1
- package/dist/src/utils/extraUsage.js +1 -1
- package/dist/src/utils/fastMode.js +1 -1
- package/dist/src/utils/fileOperationAnalytics.js +1 -1
- package/dist/src/utils/fileRead.js +1 -1
- package/dist/src/utils/findExecutable.js +1 -1
- package/dist/src/utils/format.js +1 -1
- package/dist/src/utils/frontmatterParser.js +1 -1
- package/dist/src/utils/fsOperations.js +1 -1
- package/dist/src/utils/fullscreen.js +1 -1
- package/dist/src/utils/genericProcessUtils.js +1 -1
- package/dist/src/utils/getWorktreePaths.js +1 -1
- package/dist/src/utils/git/gitConfigParser.js +1 -1
- package/dist/src/utils/git/gitFilesystem.js +1 -1
- package/dist/src/utils/git/gitignore.js +1 -1
- package/dist/src/utils/gitDiff.js +1 -1
- package/dist/src/utils/gitSettings.js +1 -1
- package/dist/src/utils/glob.js +1 -1
- package/dist/src/utils/gracefulShutdown.js +1 -1
- package/dist/src/utils/groupToolUses.js +1 -1
- package/dist/src/utils/handlePromptSubmit.js +1 -1
- package/dist/src/utils/hash.js +1 -1
- package/dist/src/utils/hooks/fileChangedWatcher.js +1 -1
- package/dist/src/utils/hooks/hooksSettings.js +1 -1
- package/dist/src/utils/hooks/registerSkillHooks.js +1 -1
- package/dist/src/utils/hooks/sessionHooks.js +1 -1
- package/dist/src/utils/http.js +1 -1
- package/dist/src/utils/hyperlink.js +1 -1
- package/dist/src/utils/ide.js +1 -1
- package/dist/src/utils/idePathConversion.js +1 -1
- package/dist/src/utils/imagePaste.js +1 -1
- package/dist/src/utils/imageResizer.js +1 -1
- package/dist/src/utils/imageStore.js +1 -1
- package/dist/src/utils/inProcessTeammateHelpers.js +1 -1
- package/dist/src/utils/ink.js +1 -1
- package/dist/src/utils/jetbrains.js +1 -1
- package/dist/src/utils/json.js +1 -1
- package/dist/src/utils/listSessionsImpl.js +1 -1
- package/dist/src/utils/localInstaller.js +1 -1
- package/dist/src/utils/lockfile.js +1 -1
- package/dist/src/utils/logoV2Utils.js +1 -1
- package/dist/src/utils/markdown.js +1 -1
- package/dist/src/utils/mcp/dateTimeParser.js +1 -1
- package/dist/src/utils/mcpOutputStorage.js +1 -1
- package/dist/src/utils/mcpValidation.js +1 -1
- package/dist/src/utils/memoize.js +1 -1
- package/dist/src/utils/memory/types.js +1 -1
- package/dist/src/utils/memoryFileDetection.js +1 -1
- package/dist/src/utils/messageQueueManager.js +1 -1
- package/dist/src/utils/messages/mappers.js +1 -1
- package/dist/src/utils/messages/systemInit.js +1 -1
- package/dist/src/utils/model/antModels.js +1 -1
- package/dist/src/utils/model/check1mAccess.js +1 -1
- package/dist/src/utils/model/contextWindowUpgradeCheck.js +1 -1
- package/dist/src/utils/model/model.js +1 -1
- package/dist/src/utils/model/modelAllowlist.js +1 -1
- package/dist/src/utils/model/modelCapabilities.js +1 -1
- package/dist/src/utils/model/modelOptions.js +1 -1
- package/dist/src/utils/model/modelStrings.js +1 -1
- package/dist/src/utils/model/providerModels.js +1 -1
- package/dist/src/utils/model/providerProfiles.js +1 -1
- package/dist/src/utils/model/providerProfilesDb.js +1 -1
- package/dist/src/utils/model/providerSwitch.js +1 -1
- package/dist/src/utils/model/providers.js +1 -1
- package/dist/src/utils/modelCost.js +1 -1
- package/dist/src/utils/modifiers.js +1 -1
- package/dist/src/utils/mtls.js +1 -1
- package/dist/src/utils/nativeInstaller/download.js +1 -1
- package/dist/src/utils/nativeInstaller/installer.js +1 -1
- package/dist/src/utils/nativeInstaller/packageManagers.js +1 -1
- package/dist/src/utils/nativeInstaller/pidLock.js +1 -1
- package/dist/src/utils/notebook.js +1 -1
- package/dist/src/utils/pasteStore.js +1 -1
- package/dist/src/utils/path.js +1 -1
- package/dist/src/utils/permissions/PermissionMode.js +1 -1
- package/dist/src/utils/permissions/PermissionPromptToolResultSchema.js +1 -1
- package/dist/src/utils/permissions/PermissionUpdate.js +1 -1
- package/dist/src/utils/permissions/PermissionUpdateSchema.js +1 -1
- package/dist/src/utils/permissions/autoModeState.js +1 -1
- package/dist/src/utils/permissions/bypassPermissionsKillswitch.js +1 -1
- package/dist/src/utils/permissions/filesystem.js +1 -1
- package/dist/src/utils/permissions/getNextPermissionMode.js +1 -1
- package/dist/src/utils/permissions/pathValidation.js +1 -1
- package/dist/src/utils/permissions/permissionRuleParser.js +1 -1
- package/dist/src/utils/permissions/permissionsDb.js +1 -1
- package/dist/src/utils/permissions/permissionsLoader.js +1 -1
- package/dist/src/utils/permissions/shellRuleMatching.js +1 -1
- package/dist/src/utils/planModeV2.js +1 -1
- package/dist/src/utils/plans.js +1 -1
- package/dist/src/utils/platform.js +1 -1
- package/dist/src/utils/plugins/addDirPluginSettings.js +1 -1
- package/dist/src/utils/plugins/cacheUtils.js +1 -1
- package/dist/src/utils/plugins/dependencyResolver.js +1 -1
- package/dist/src/utils/plugins/fetchTelemetry.js +1 -1
- package/dist/src/utils/plugins/gitAvailability.js +1 -1
- package/dist/src/utils/plugins/hintRecommendation.js +1 -1
- package/dist/src/utils/plugins/installedPluginsManager.js +1 -1
- package/dist/src/utils/plugins/loadPluginAgents.js +1 -1
- package/dist/src/utils/plugins/loadPluginCommands.js +1 -1
- package/dist/src/utils/plugins/loadPluginHooks.js +1 -1
- package/dist/src/utils/plugins/loadPluginOutputStyles.js +1 -1
- package/dist/src/utils/plugins/lspPluginIntegration.js +1 -1
- package/dist/src/utils/plugins/lspRecommendation.js +1 -1
- package/dist/src/utils/plugins/managedPlugins.js +1 -1
- package/dist/src/utils/plugins/marketplaceHelpers.js +1 -1
- package/dist/src/utils/plugins/marketplaceManager.js +1 -1
- package/dist/src/utils/plugins/mcpPluginIntegration.js +1 -1
- package/dist/src/utils/plugins/mcpbHandler.js +1 -1
- package/dist/src/utils/plugins/officialMarketplaceGcs.js +1 -1
- package/dist/src/utils/plugins/officialMarketplaceStartupCheck.js +1 -1
- package/dist/src/utils/plugins/orphanedPluginFilter.js +1 -1
- package/dist/src/utils/plugins/performStartupChecks.js +1 -1
- package/dist/src/utils/plugins/pluginAutoupdate.js +1 -1
- package/dist/src/utils/plugins/pluginBlocklist.js +1 -1
- package/dist/src/utils/plugins/pluginDirectories.js +1 -1
- package/dist/src/utils/plugins/pluginFlagging.js +1 -1
- package/dist/src/utils/plugins/pluginInstallationHelpers.js +1 -1
- package/dist/src/utils/plugins/pluginLoader.js +1 -1
- package/dist/src/utils/plugins/pluginOptionsStorage.js +1 -1
- package/dist/src/utils/plugins/pluginPolicy.js +1 -1
- package/dist/src/utils/plugins/pluginStartupCheck.js +1 -1
- package/dist/src/utils/plugins/pluginVersioning.js +1 -1
- package/dist/src/utils/plugins/reconciler.js +1 -1
- package/dist/src/utils/plugins/refresh.js +1 -1
- package/dist/src/utils/plugins/schemas.js +1 -1
- package/dist/src/utils/plugins/walkPluginMarkdown.js +1 -1
- package/dist/src/utils/plugins/zipCache.js +1 -1
- package/dist/src/utils/powershell/parser.js +1 -1
- package/dist/src/utils/processUserInput/processBashCommand.js +1 -1
- package/dist/src/utils/processUserInput/processSlashCommand.js +1 -1
- package/dist/src/utils/processUserInput/processTextPrompt.js +1 -1
- package/dist/src/utils/processUserInput/processUserInput.js +1 -1
- package/dist/src/utils/profilerBase.js +1 -1
- package/dist/src/utils/promptCategory.js +1 -1
- package/dist/src/utils/promptEditor.js +1 -1
- package/dist/src/utils/promptShellExecution.js +1 -1
- package/dist/src/utils/proxy.js +1 -1
- package/dist/src/utils/queryHelpers.js +1 -1
- package/dist/src/utils/queryProfiler.js +1 -1
- package/dist/src/utils/queueProcessor.js +1 -1
- package/dist/src/utils/readFileInRange.js +1 -1
- package/dist/src/utils/releaseNotes.js +1 -1
- package/dist/src/utils/renderOptions.js +1 -1
- package/dist/src/utils/ripgrep.js +1 -1
- package/dist/src/utils/sandbox/sandbox-adapter.js +1 -1
- package/dist/src/utils/sdkEventQueue.js +1 -1
- package/dist/src/utils/secureStorage/index.js +1 -1
- package/dist/src/utils/secureStorage/macOsKeychainHelpers.js +1 -1
- package/dist/src/utils/secureStorage/macOsKeychainStorage.js +1 -1
- package/dist/src/utils/secureStorage/plainTextStorage.js +1 -1
- package/dist/src/utils/secureStorage/sqliteStorage.js +1 -1
- package/dist/src/utils/sessionEnvironment.js +1 -1
- package/dist/src/utils/sessionIngressAuth.js +1 -1
- package/dist/src/utils/sessionRestore.js +1 -1
- package/dist/src/utils/sessionStart.js +1 -1
- package/dist/src/utils/sessionTitle.js +1 -1
- package/dist/src/utils/settings/managedPath.js +1 -1
- package/dist/src/utils/settings/mdm/rawRead.js +1 -1
- package/dist/src/utils/settings/mdm/settings.js +1 -1
- package/dist/src/utils/settings/permissionValidation.js +1 -1
- package/dist/src/utils/settings/pluginOnlyPolicy.js +1 -1
- package/dist/src/utils/settings/schemaOutput.js +1 -1
- package/dist/src/utils/settings/settings.js +1 -1
- package/dist/src/utils/settings/types.js +1 -1
- package/dist/src/utils/settings/validateEditTool.js +1 -1
- package/dist/src/utils/settings/validation.js +1 -1
- package/dist/src/utils/shell/bashProvider.js +1 -1
- package/dist/src/utils/shell/powershellDetection.js +1 -1
- package/dist/src/utils/shell/powershellProvider.js +1 -1
- package/dist/src/utils/shell/readOnlyCommandValidation.js +1 -1
- package/dist/src/utils/shell/resolveDefaultShell.js +1 -1
- package/dist/src/utils/shell/shellToolUtils.js +1 -1
- package/dist/src/utils/shell/specPrefix.js +1 -1
- package/dist/src/utils/shellConfig.js +1 -1
- package/dist/src/utils/sideQuestion.js +1 -1
- package/dist/src/utils/skills/skillChangeDetector.js +1 -1
- package/dist/src/utils/slashCommandParsing.js +1 -1
- package/dist/src/utils/sliceAnsi.js +1 -1
- package/dist/src/utils/slowOperations.js +1 -1
- package/dist/src/utils/standaloneAgent.js +1 -1
- package/dist/src/utils/startupProfiler.js +1 -1
- package/dist/src/utils/staticRender.js +1 -1
- package/dist/src/utils/status.js +1 -1
- package/dist/src/utils/statusNoticeDefinitions.js +1 -1
- package/dist/src/utils/suggestions/commandSuggestions.js +1 -1
- package/dist/src/utils/suggestions/directoryCompletion.js +1 -1
- package/dist/src/utils/suggestions/shellHistoryCompletion.js +1 -1
- package/dist/src/utils/suggestions/skillUsageTracking.js +1 -1
- package/dist/src/utils/suggestions/slackChannelSuggestions.js +1 -1
- package/dist/src/utils/swarm/backends/detection.js +1 -1
- package/dist/src/utils/swarm/permissionSync.js +1 -1
- package/dist/src/utils/swarm/reconnection.js +1 -1
- package/dist/src/utils/swarm/spawnUtils.js +1 -91
- package/dist/src/utils/swarm/teammateInit.js +1 -1
- package/dist/src/utils/systemDirectories.js +1 -1
- package/dist/src/utils/systemPrompt.js +1 -1
- package/dist/src/utils/systemTheme.js +1 -1
- package/dist/src/utils/task/TaskOutput.js +1 -1
- package/dist/src/utils/task/diskOutput.js +1 -1
- package/dist/src/utils/tasks.js +1 -1
- package/dist/src/utils/teamDiscovery.js +1 -1
- package/dist/src/utils/teamMemoryOps.js +1 -1
- package/dist/src/utils/teammateMailbox.js +1 -1
- package/dist/src/utils/telemetry/betaSessionTracing.js +1 -1
- package/dist/src/utils/telemetry/bigqueryExporter.js +1 -1
- package/dist/src/utils/telemetry/events.js +1 -1
- package/dist/src/utils/telemetry/instrumentation.js +1 -1
- package/dist/src/utils/telemetry/logger.js +1 -1
- package/dist/src/utils/telemetry/perfettoTracing.js +1 -1
- package/dist/src/utils/telemetry/pluginTelemetry.js +1 -1
- package/dist/src/utils/telemetry/sessionTracing.js +1 -1
- package/dist/src/utils/telemetryAttributes.js +1 -1
- package/dist/src/utils/teleport/api.js +1 -1
- package/dist/src/utils/teleport/environments.js +1 -1
- package/dist/src/utils/teleport/gitBundle.js +1 -1
- package/dist/src/utils/teleport.js +1 -1
- package/dist/src/utils/tempfile.js +1 -1
- package/dist/src/utils/terminal.js +1 -1
- package/dist/src/utils/terminalPanel.js +1 -1
- package/dist/src/utils/textHighlighting.js +1 -1
- package/dist/src/utils/theme.js +1 -1
- package/dist/src/utils/themes/bootstrap.js +1 -1
- package/dist/src/utils/themes/loader.js +1 -1
- package/dist/src/utils/thinking.js +1 -1
- package/dist/src/utils/tmuxSocket.js +1 -1
- package/dist/src/utils/tokens.js +1 -1
- package/dist/src/utils/toolPool.js +1 -1
- package/dist/src/utils/toolResultStorage.js +1 -1
- package/dist/src/utils/transcriptSearch.js +1 -1
- package/dist/src/utils/truncate.js +1 -1
- package/dist/src/utils/ultraplan/keyword.js +1 -1
- package/dist/src/utils/unaryLogging.js +1 -1
- package/dist/src/utils/undercover.js +1 -1
- package/dist/src/utils/user.js +1 -1
- package/dist/src/utils/userPromptKeywords.js +1 -1
- package/dist/src/utils/which.js +1 -1
- package/dist/src/utils/windowsPaths.js +1 -1
- package/dist/src/utils/worktree.js +1 -1
- package/dist/src/utils/zodToJsonSchema.js +1 -1
- package/dist/src/vim/operators.js +1 -1
- package/dist/src/vim/textObjects.js +1 -1
- package/dist/src/vim/transitions.js +1 -1
- package/dist/src/voice/voiceModeEnabled.js +1 -1
- package/dist/src/webapp/auth.js +1 -1
- package/dist/src/webapp/tunnel.js +1 -1
- package/dist/src/whatsapp/bridge.js +1 -1
- package/dist/src/whatsapp/mirror.js +1 -1
- package/dist/webapp/main-MTQLKGXD.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{STATUS_TAG as
|
|
1
|
+
import{STATUS_TAG as t,SUMMARY_TAG as e,TASK_NOTIFICATION_TAG as s}from"../constants/xml.js";import{BACKGROUND_BASH_SUMMARY_PREFIX as o}from"../tasks/LocalShellTask/LocalShellTask.js";import{isFullscreenEnvEnabled as r}from"./fullscreen.js";import{extractTag as n}from"./messages.js";function isCompletedBackgroundBash(r){if("user"!==r.type)return!1;const l=r.message.content[0];return"text"===l?.type&&(!!l.text.includes(`<${s}`)&&("completed"===n(l.text,t)&&(n(l.text,e)?.startsWith(o)??!1)))}export function collapseBackgroundBashNotifications(o,n){if(!r())return o;if(n)return o;const l=[];let c=0;for(;c<o.length;){const r=o[c];if(isCompletedBackgroundBash(r)){let n=0;for(;c<o.length&&isCompletedBackgroundBash(o[c]);)n++,c++;1===n?l.push(r):l.push({...r,message:{role:"user",content:[{type:"text",text:`<${s}><${t}>completed</${t}><${e}>${n} background commands completed</${e}></${s}>`}]}})}else l.push(r),c++}return l}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"module";const t=e(import.meta.url);import{feature as s}from"bun:bundle";import{findToolByName as o}from"../Tool.js";import{extractBashCommentLabel as n}from"../tools/BashTool/commentLabel.js";import{BASH_TOOL_NAME as r}from"../tools/BashTool/toolName.js";import{FILE_EDIT_TOOL_NAME as a}from"../tools/FileEditTool/constants.js";import{FILE_WRITE_TOOL_NAME as i}from"../tools/FileWriteTool/prompt.js";import{REPL_TOOL_NAME as l}from"../tools/REPLTool/constants.js";import{getReplPrimitiveTools as m}from"../tools/REPLTool/primitiveTools.js";import{detectGitOperation as u}from"../tools/shared/gitOperationTracking.js";import{TOOL_SEARCH_TOOL_NAME as c}from"../tools/ToolSearchTool/prompt.js";import{getDisplayPath as p}from"./file.js";import{isFullscreenEnvEnabled as h}from"./fullscreen.js";import{isAutoManagedMemoryFile as d,isAutoManagedMemoryPattern as f,isMemoryDirectory as y,isShellCommandTargetingMemory as g}from"./memoryFileDetection.js";const M=s("TEAMMEM")?t("./teamMemoryOps.js"):null,C=s("HISTORY_SNIP")?t("../tools/SnipTool/prompt.js").SNIP_TOOL_NAME:null;function isMemorySearch(e){const t=e;return!!(t&&(t.path&&(d(t.path)||y(t.path))||t.glob&&f(t.glob)||t.command&&g(t.command)))}function commandAsHint(e){const t="$ "+e.split("\n").map(e=>e.replace(/\s+/g," ").trim()).filter(e=>""!==e).join("\n");return t.length>300?t.slice(0,299)+"…":t}export function getToolSearchOrReadInfo(e,t,n){if(e===l)return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!0,isMemoryWrite:!1,isAbsorbedSilently:!0};if(function(e,t){if(e!==i&&e!==a)return!1;const s=function(e){const t=e;return t?.file_path??t?.path}(t);return void 0!==s&&d(s)}(e,t))return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!0,isAbsorbedSilently:!1};if(s("HISTORY_SNIP")&&e===C||h()&&e===c)return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!0};const u=o(n,e)??o(m(),e);if(!u?.isSearchOrReadCommand)return{isCollapsible:!1,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!1};const p=u.isSearchOrReadCommand(t),f=p.isList??!1,y=p.isSearch||p.isRead||f;return{isCollapsible:y||!!h()&&e===r,isSearch:p.isSearch,isRead:p.isRead,isList:f,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!1,...u.isMcp&&{mcpServerName:u.mcpInfo?.serverName},isBash:h()?!y&&e===r:void 0}}export function getSearchOrReadFromContent(e,t){if("tool_use"===e?.type&&e.name){const s=getToolSearchOrReadInfo(e.name,e.input,t);if(s.isCollapsible||s.isREPL)return{isSearch:s.isSearch,isRead:s.isRead,isList:s.isList,isREPL:s.isREPL,isMemoryWrite:s.isMemoryWrite,isAbsorbedSilently:s.isAbsorbedSilently,mcpServerName:s.mcpServerName,isBash:s.isBash}}return null}function isToolSearchOrRead(e,t,s){return getToolSearchOrReadInfo(e,t,s).isCollapsible}function getCollapsibleToolInfo(e,t){if("assistant"===e.type){const s=e.message.content[0],o=getSearchOrReadFromContent(s,t);if(o&&"tool_use"===s?.type)return{name:s.name,input:s.input,...o}}if("grouped_tool_use"===e.type){const s=e.messages[0]?.message.content[0],o=getSearchOrReadFromContent(s?{type:"tool_use",name:e.toolName,input:s.input}:void 0,t);if(o&&"tool_use"===s?.type)return{name:e.toolName,input:s.input,...o}}return null}function isTextBreaker(e){if("assistant"===e.type){const t=e.message.content[0];if("text"===t?.type&&t.text.trim().length>0)return!0}return!1}function isNonCollapsibleToolUse(e,t){if("assistant"===e.type){const s=e.message.content[0];if("tool_use"===s?.type&&!isToolSearchOrRead(s.name,s.input,t))return!0}if("grouped_tool_use"===e.type){const s=e.messages[0]?.message.content[0];if("tool_use"===s?.type&&!isToolSearchOrRead(e.toolName,s.input,t))return!0}return!1}function isPreToolHookSummary(e){return"system"===e.type&&"stop_hook_summary"===e.subtype&&"PreToolUse"===e.hookLabel}function shouldSkipMessage(e){if("assistant"===e.type){const t=e.message.content[0];if("thinking"===t?.type||"redacted_thinking"===t?.type)return!0}return"attachment"===e.type||"system"===e.type}function isCollapsibleToolUse(e,t){if("assistant"===e.type){const s=e.message.content[0];return"tool_use"===s?.type&&isToolSearchOrRead(s.name,s.input,t)}if("grouped_tool_use"===e.type){const s=e.messages[0]?.message.content[0];return"tool_use"===s?.type&&isToolSearchOrRead(e.toolName,s.input,t)}return!1}function isCollapsibleToolResult(e,t){if("user"===e.type){const s=e.message.content.filter(e=>"tool_result"===e.type);return s.length>0&&s.every(e=>t.has(e.tool_use_id))}return!1}function getToolUseIdsFromMessage(e){if("assistant"===e.type){const t=e.message.content[0];if("tool_use"===t?.type)return[t.id]}return"grouped_tool_use"===e.type?e.messages.map(e=>{const t=e.message.content[0];return"tool_use"===t.type?t.id:""}).filter(Boolean):[]}export function getToolUseIdsFromCollapsedGroup(e){const t=[];for(const s of e.messages)t.push(...getToolUseIdsFromMessage(s));return t}export function hasAnyToolInProgress(e,t){return getToolUseIdsFromCollapsedGroup(e).some(e=>t.has(e))}export function getDisplayMessageFromCollapsed(e){const t=e.displayMessage;return"grouped_tool_use"===t.type?t.displayMessage:t}function countToolUses(e){return"grouped_tool_use"===e.type?e.messages.length:1}function getFilePathsFromReadMessage(e){const t=[];if("assistant"===e.type){const s=e.message.content[0];if("tool_use"===s?.type){const e=s.input;e?.file_path&&t.push(e.file_path)}}else if("grouped_tool_use"===e.type)for(const s of e.messages){const e=s.message.content[0];if("tool_use"===e?.type){const s=e.input;s?.file_path&&t.push(s.file_path)}}return t}function scanBashResultForGitOps(e,t){if("user"!==e.type)return;const s=e.toolUseResult;if(!s?.stdout&&!s?.stderr)return;const o=(s.stdout??"")+"\n"+(s.stderr??"");for(const s of e.message.content){if("tool_result"!==s.type)continue;const e=t.bashCommands?.get(s.tool_use_id);if(!e)continue;const{commit:n,push:r,branch:a,pr:i}=u(e,o);n&&t.commits?.push(n),r&&t.pushes?.push(r),a&&t.branches?.push(a),i&&t.prs?.push(i),(n||r||a||i)&&(t.gitOpBashCount=(t.gitOpBashCount??0)+1)}}function createEmptyGroup(){const e={messages:[],searchCount:0,readFilePaths:new Set,readOperationCount:0,listCount:0,toolUseIds:new Set,memorySearchCount:0,memoryReadFilePaths:new Set,memoryWriteCount:0,nonMemSearchArgs:[],latestDisplayHint:void 0,hookTotalMs:0,hookCount:0,hookInfos:[]};return s("TEAMMEM")&&(e.teamMemorySearchCount=0,e.teamMemoryReadFilePaths=new Set,e.teamMemoryWriteCount=0),e.mcpCallCount=0,e.mcpServerNames=new Set,h()&&(e.bashCount=0,e.bashCommands=new Map,e.commits=[],e.pushes=[],e.branches=[],e.prs=[],e.gitOpBashCount=0),e}export function collapseReadSearchGroups(e,t){const o=[];let r=createEmptyGroup(),a=[];function flushGroup(){if(0!==r.messages.length){o.push(function(e){const t=e.messages[0],o=e.readFilePaths.size>0?e.readFilePaths.size:e.readOperationCount,n=e.memoryReadFilePaths.size,r=n+(e.relevantMemories?.length??0),a=s("TEAMMEM")?e.teamMemoryReadFilePaths:void 0,i=[...e.readFilePaths].filter(t=>!e.memoryReadFilePaths.has(t)&&!a?.has(t)),l=s("TEAMMEM")?e.teamMemorySearchCount??0:0,m=s("TEAMMEM")?e.teamMemoryReadFilePaths?.size??0:0,u=s("TEAMMEM")?e.teamMemoryWriteCount??0:0,c={type:"collapsed_read_search",searchCount:Math.max(0,e.searchCount-e.memorySearchCount-l),readCount:Math.max(0,o-n-m),listCount:e.listCount,replCount:0,memorySearchCount:e.memorySearchCount,memoryReadCount:r,memoryWriteCount:e.memoryWriteCount,readFilePaths:i,searchArgs:e.nonMemSearchArgs,latestDisplayHint:e.latestDisplayHint,messages:e.messages,displayMessage:t,uuid:`collapsed-${t.uuid}`,timestamp:t.timestamp};return s("TEAMMEM")&&(c.teamMemorySearchCount=l,c.teamMemoryReadCount=m,c.teamMemoryWriteCount=u),(e.mcpCallCount??0)>0&&(c.mcpCallCount=e.mcpCallCount,c.mcpServerNames=[...e.mcpServerNames??[]]),h()&&((e.bashCount??0)>0&&(c.bashCount=e.bashCount,c.gitOpBashCount=e.gitOpBashCount),(e.commits?.length??0)>0&&(c.commits=e.commits),(e.pushes?.length??0)>0&&(c.pushes=e.pushes),(e.branches?.length??0)>0&&(c.branches=e.branches),(e.prs?.length??0)>0&&(c.prs=e.prs)),e.hookCount>0&&(c.hookTotalMs=e.hookTotalMs,c.hookCount=e.hookCount,c.hookInfos=e.hookInfos),e.relevantMemories&&e.relevantMemories.length>0&&(c.relevantMemories=e.relevantMemories),c}(r));for(const e of a)o.push(e);a=[],r=createEmptyGroup()}}for(const i of e)if(isCollapsibleToolUse(i,t)){const e=getCollapsibleToolInfo(i,t);if(e.isMemoryWrite){const t=countToolUses(i);s("TEAMMEM")&&M?.isTeamMemoryWriteOrEdit(e.name,e.input)?r.teamMemoryWriteCount=(r.teamMemoryWriteCount??0)+t:r.memoryWriteCount+=t}else if(e.isAbsorbedSilently);else if(e.mcpServerName){const t=countToolUses(i);r.mcpCallCount=(r.mcpCallCount??0)+t,r.mcpServerNames?.add(e.mcpServerName);const s=e.input;s?.query&&(r.latestDisplayHint=`"${s.query}"`)}else if(h()&&e.isBash){const t=countToolUses(i);r.bashCount=(r.bashCount??0)+t;const s=e.input;if(s?.command){r.latestDisplayHint=n(s.command)??commandAsHint(s.command);for(const e of getToolUseIdsFromMessage(i))r.bashCommands?.set(e,s.command)}}else if(e.isList){r.listCount+=countToolUses(i);const t=e.input;t?.command&&(r.latestDisplayHint=commandAsHint(t.command))}else if(e.isSearch){const t=countToolUses(i);if(r.searchCount+=t,s("TEAMMEM")&&M?.isTeamMemorySearch(e.input))r.teamMemorySearchCount=(r.teamMemorySearchCount??0)+t;else if(isMemorySearch(e.input))r.memorySearchCount+=t;else{const t=e.input;t?.pattern&&(r.nonMemSearchArgs.push(t.pattern),r.latestDisplayHint=`"${t.pattern}"`)}}else{const t=getFilePathsFromReadMessage(i);for(const e of t)r.readFilePaths.add(e),s("TEAMMEM")&&M?.isTeamMemFile(e)?r.teamMemoryReadFilePaths?.add(e):d(e)?r.memoryReadFilePaths.add(e):r.latestDisplayHint=p(e);if(0===t.length){r.readOperationCount+=countToolUses(i);const t=e.input;t?.command&&(r.latestDisplayHint=commandAsHint(t.command))}}for(const e of getToolUseIdsFromMessage(i))r.toolUseIds.add(e);r.messages.push(i)}else isCollapsibleToolResult(i,r.toolUseIds)?(r.messages.push(i),h()&&r.bashCommands?.size&&scanBashResultForGitOps(i,r)):r.messages.length>0&&isPreToolHookSummary(i)?(r.hookCount+=i.hookCount,r.hookTotalMs+=i.totalDurationMs??i.hookInfos.reduce((e,t)=>e+(t.durationMs??0),0),r.hookInfos.push(...i.hookInfos)):r.messages.length>0&&"attachment"===i.type&&"relevant_memories"===i.attachment.type?(r.relevantMemories??=[],r.relevantMemories.push(...i.attachment.memories)):shouldSkipMessage(i)?r.messages.length>0&&("attachment"!==i.type||"nested_memory"!==i.attachment.type)?a.push(i):o.push(i):isTextBreaker(i)?(flushGroup(),o.push(i)):(isNonCollapsibleToolUse(i,t),flushGroup(),o.push(i));return flushGroup(),o}export function getSearchReadSummaryText(e,t,o,n=0,r,a=0){const i=[];if(r){const{memorySearchCount:e,memoryReadCount:t,memoryWriteCount:n}=r;if(t>0){const e=o?0===i.length?"Recalling":"recalling":0===i.length?"Recalled":"recalled";i.push(`${e} ${t} ${1===t?"memory":"memories"}`)}if(e>0){const e=o?0===i.length?"Searching":"searching":0===i.length?"Searched":"searched";i.push(`${e} memories`)}if(n>0){const e=o?0===i.length?"Writing":"writing":0===i.length?"Wrote":"wrote";i.push(`${e} ${n} ${1===n?"memory":"memories"}`)}s("TEAMMEM")&&M&&M.appendTeamMemorySummaryParts(r,o,i)}if(e>0){const t=o?0===i.length?"Searching for":"searching for":0===i.length?"Searched for":"searched for";i.push(`${t} ${e} ${1===e?"pattern":"patterns"}`)}if(t>0){const e=o?0===i.length?"Reading":"reading":0===i.length?"Read":"read";i.push(`${e} ${t} ${1===t?"file":"files"}`)}if(a>0){const e=o?0===i.length?"Listing":"listing":0===i.length?"Listed":"listed";i.push(`${e} ${a} ${1===a?"directory":"directories"}`)}if(n>0){const e=o?"REPL'ing":"REPL'd";i.push(`${e} ${n} ${1===n?"time":"times"}`)}const l=i.join(", ");return o?`${l}…`:l}export function summarizeRecentActivities(e){if(0===e.length)return;let t=0,s=0;for(let o=e.length-1;o>=0;o--){const n=e[o];if(n.isSearch)t++;else{if(!n.isRead)break;s++}}if(t+s>=2)return getSearchReadSummaryText(t,s,!0);for(let t=e.length-1;t>=0;t--)if(e[t]?.activityDescription)return e[t].activityDescription}
|
|
1
|
+
import{feature as e}from"../recovery/bunBundleShim.js";import{createRequire as t}from"module";const o=t(import.meta.url);import{findToolByName as s}from"../Tool.js";import{extractBashCommentLabel as n}from"../tools/BashTool/commentLabel.js";import{BASH_TOOL_NAME as r}from"../tools/BashTool/toolName.js";import{FILE_EDIT_TOOL_NAME as i}from"../tools/FileEditTool/constants.js";import{FILE_WRITE_TOOL_NAME as a}from"../tools/FileWriteTool/prompt.js";import{REPL_TOOL_NAME as l}from"../tools/REPLTool/constants.js";import{getReplPrimitiveTools as m}from"../tools/REPLTool/primitiveTools.js";import{detectGitOperation as u}from"../tools/shared/gitOperationTracking.js";import{TOOL_SEARCH_TOOL_NAME as c}from"../tools/ToolSearchTool/prompt.js";import{getDisplayPath as p}from"./file.js";import{isFullscreenEnvEnabled as h}from"./fullscreen.js";import{isAutoManagedMemoryFile as d,isAutoManagedMemoryPattern as f,isMemoryDirectory as y,isShellCommandTargetingMemory as g}from"./memoryFileDetection.js";const M=e("TEAMMEM")?o("./teamMemoryOps.js"):null,C=e("HISTORY_SNIP")?o("../tools/SnipTool/prompt.js").SNIP_TOOL_NAME:null;function isMemorySearch(e){const t=e;return!!t&&(!(!t.path||!d(t.path)&&!y(t.path))||(!(!t.glob||!f(t.glob))||!(!t.command||!g(t.command))))}function commandAsHint(e){const t="$ "+e.split("\n").map(e=>e.replace(/\s+/g," ").trim()).filter(e=>""!==e).join("\n");return t.length>300?t.slice(0,299)+"…":t}export function getToolSearchOrReadInfo(t,o,n){if(t===l)return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!0,isMemoryWrite:!1,isAbsorbedSilently:!0};if(function(e,t){if(e!==a&&e!==i)return!1;const o=function(e){const t=e;return t?.file_path??t?.path}(t);return void 0!==o&&d(o)}(t,o))return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!0,isAbsorbedSilently:!1};if(e("HISTORY_SNIP")&&t===C||h()&&t===c)return{isCollapsible:!0,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!0};const u=s(n,t)??s(m(),t);if(!u?.isSearchOrReadCommand)return{isCollapsible:!1,isSearch:!1,isRead:!1,isList:!1,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!1};const p=u.isSearchOrReadCommand(o),f=p.isList??!1,y=p.isSearch||p.isRead||f;return{isCollapsible:y||!!h()&&t===r,isSearch:p.isSearch,isRead:p.isRead,isList:f,isREPL:!1,isMemoryWrite:!1,isAbsorbedSilently:!1,...u.isMcp&&{mcpServerName:u.mcpInfo?.serverName},isBash:h()?!y&&t===r:void 0}}export function getSearchOrReadFromContent(e,t){if("tool_use"===e?.type&&e.name){const o=getToolSearchOrReadInfo(e.name,e.input,t);if(o.isCollapsible||o.isREPL)return{isSearch:o.isSearch,isRead:o.isRead,isList:o.isList,isREPL:o.isREPL,isMemoryWrite:o.isMemoryWrite,isAbsorbedSilently:o.isAbsorbedSilently,mcpServerName:o.mcpServerName,isBash:o.isBash}}return null}function isToolSearchOrRead(e,t,o){return getToolSearchOrReadInfo(e,t,o).isCollapsible}function getCollapsibleToolInfo(e,t){if("assistant"===e.type){const o=e.message.content[0],s=getSearchOrReadFromContent(o,t);if(s&&"tool_use"===o?.type)return{name:o.name,input:o.input,...s}}if("grouped_tool_use"===e.type){const o=e.messages[0]?.message.content[0],s=getSearchOrReadFromContent(o?{type:"tool_use",name:e.toolName,input:o.input}:void 0,t);if(s&&"tool_use"===o?.type)return{name:e.toolName,input:o.input,...s}}return null}function isTextBreaker(e){if("assistant"===e.type){const t=e.message.content[0];if("text"===t?.type&&t.text.trim().length>0)return!0}return!1}function isNonCollapsibleToolUse(e,t){if("assistant"===e.type){const o=e.message.content[0];if("tool_use"===o?.type&&!isToolSearchOrRead(o.name,o.input,t))return!0}if("grouped_tool_use"===e.type){const o=e.messages[0]?.message.content[0];if("tool_use"===o?.type&&!isToolSearchOrRead(e.toolName,o.input,t))return!0}return!1}function isPreToolHookSummary(e){return"system"===e.type&&"stop_hook_summary"===e.subtype&&"PreToolUse"===e.hookLabel}function shouldSkipMessage(e){if("assistant"===e.type){const t=e.message.content[0];if("thinking"===t?.type||"redacted_thinking"===t?.type)return!0}return"attachment"===e.type||"system"===e.type}function isCollapsibleToolUse(e,t){if("assistant"===e.type){const o=e.message.content[0];return"tool_use"===o?.type&&isToolSearchOrRead(o.name,o.input,t)}if("grouped_tool_use"===e.type){const o=e.messages[0]?.message.content[0];return"tool_use"===o?.type&&isToolSearchOrRead(e.toolName,o.input,t)}return!1}function isCollapsibleToolResult(e,t){if("user"===e.type){const o=e.message.content.filter(e=>"tool_result"===e.type);return o.length>0&&o.every(e=>t.has(e.tool_use_id))}return!1}function getToolUseIdsFromMessage(e){if("assistant"===e.type){const t=e.message.content[0];if("tool_use"===t?.type)return[t.id]}return"grouped_tool_use"===e.type?e.messages.map(e=>{const t=e.message.content[0];return"tool_use"===t.type?t.id:""}).filter(Boolean):[]}export function getToolUseIdsFromCollapsedGroup(e){const t=[];for(const o of e.messages)t.push(...getToolUseIdsFromMessage(o));return t}export function hasAnyToolInProgress(e,t){return getToolUseIdsFromCollapsedGroup(e).some(e=>t.has(e))}export function getDisplayMessageFromCollapsed(e){const t=e.displayMessage;return"grouped_tool_use"===t.type?t.displayMessage:t}function countToolUses(e){return"grouped_tool_use"===e.type?e.messages.length:1}function getFilePathsFromReadMessage(e){const t=[];if("assistant"===e.type){const o=e.message.content[0];if("tool_use"===o?.type){const e=o.input;e?.file_path&&t.push(e.file_path)}}else if("grouped_tool_use"===e.type)for(const o of e.messages){const e=o.message.content[0];if("tool_use"===e?.type){const o=e.input;o?.file_path&&t.push(o.file_path)}}return t}function scanBashResultForGitOps(e,t){if("user"!==e.type)return;const o=e.toolUseResult;if(!o?.stdout&&!o?.stderr)return;const s=(o.stdout??"")+"\n"+(o.stderr??"");for(const o of e.message.content){if("tool_result"!==o.type)continue;const e=t.bashCommands?.get(o.tool_use_id);if(!e)continue;const{commit:n,push:r,branch:i,pr:a}=u(e,s);n&&t.commits?.push(n),r&&t.pushes?.push(r),i&&t.branches?.push(i),a&&t.prs?.push(a),(n||r||i||a)&&(t.gitOpBashCount=(t.gitOpBashCount??0)+1)}}function createEmptyGroup(){const t={messages:[],searchCount:0,readFilePaths:new Set,readOperationCount:0,listCount:0,toolUseIds:new Set,memorySearchCount:0,memoryReadFilePaths:new Set,memoryWriteCount:0,nonMemSearchArgs:[],latestDisplayHint:void 0,hookTotalMs:0,hookCount:0,hookInfos:[]};return e("TEAMMEM")&&(t.teamMemorySearchCount=0,t.teamMemoryReadFilePaths=new Set,t.teamMemoryWriteCount=0),t.mcpCallCount=0,t.mcpServerNames=new Set,h()&&(t.bashCount=0,t.bashCommands=new Map,t.commits=[],t.pushes=[],t.branches=[],t.prs=[],t.gitOpBashCount=0),t}export function collapseReadSearchGroups(t,o){const s=[];let r=createEmptyGroup(),i=[];function flushGroup(){if(0!==r.messages.length){s.push(function(t){const o=t.messages[0],s=t.readFilePaths.size>0?t.readFilePaths.size:t.readOperationCount,n=t.memoryReadFilePaths.size,r=n+(t.relevantMemories?.length??0),i=e("TEAMMEM")?t.teamMemoryReadFilePaths:void 0,a=[...t.readFilePaths].filter(e=>!t.memoryReadFilePaths.has(e)&&!i?.has(e)),l=e("TEAMMEM")?t.teamMemorySearchCount??0:0,m=e("TEAMMEM")?t.teamMemoryReadFilePaths?.size??0:0,u=e("TEAMMEM")?t.teamMemoryWriteCount??0:0,c={type:"collapsed_read_search",searchCount:Math.max(0,t.searchCount-t.memorySearchCount-l),readCount:Math.max(0,s-n-m),listCount:t.listCount,replCount:0,memorySearchCount:t.memorySearchCount,memoryReadCount:r,memoryWriteCount:t.memoryWriteCount,readFilePaths:a,searchArgs:t.nonMemSearchArgs,latestDisplayHint:t.latestDisplayHint,messages:t.messages,displayMessage:o,uuid:`collapsed-${o.uuid}`,timestamp:o.timestamp};return e("TEAMMEM")&&(c.teamMemorySearchCount=l,c.teamMemoryReadCount=m,c.teamMemoryWriteCount=u),(t.mcpCallCount??0)>0&&(c.mcpCallCount=t.mcpCallCount,c.mcpServerNames=[...t.mcpServerNames??[]]),h()&&((t.bashCount??0)>0&&(c.bashCount=t.bashCount,c.gitOpBashCount=t.gitOpBashCount),(t.commits?.length??0)>0&&(c.commits=t.commits),(t.pushes?.length??0)>0&&(c.pushes=t.pushes),(t.branches?.length??0)>0&&(c.branches=t.branches),(t.prs?.length??0)>0&&(c.prs=t.prs)),t.hookCount>0&&(c.hookTotalMs=t.hookTotalMs,c.hookCount=t.hookCount,c.hookInfos=t.hookInfos),t.relevantMemories&&t.relevantMemories.length>0&&(c.relevantMemories=t.relevantMemories),c}(r));for(const e of i)s.push(e);i=[],r=createEmptyGroup()}}for(const a of t)if(isCollapsibleToolUse(a,o)){const t=getCollapsibleToolInfo(a,o);if(t.isMemoryWrite){const o=countToolUses(a);e("TEAMMEM")&&M?.isTeamMemoryWriteOrEdit(t.name,t.input)?r.teamMemoryWriteCount=(r.teamMemoryWriteCount??0)+o:r.memoryWriteCount+=o}else if(t.isAbsorbedSilently);else if(t.mcpServerName){const e=countToolUses(a);r.mcpCallCount=(r.mcpCallCount??0)+e,r.mcpServerNames?.add(t.mcpServerName);const o=t.input;o?.query&&(r.latestDisplayHint=`"${o.query}"`)}else if(h()&&t.isBash){const e=countToolUses(a);r.bashCount=(r.bashCount??0)+e;const o=t.input;if(o?.command){r.latestDisplayHint=n(o.command)??commandAsHint(o.command);for(const e of getToolUseIdsFromMessage(a))r.bashCommands?.set(e,o.command)}}else if(t.isList){r.listCount+=countToolUses(a);const e=t.input;e?.command&&(r.latestDisplayHint=commandAsHint(e.command))}else if(t.isSearch){const o=countToolUses(a);if(r.searchCount+=o,e("TEAMMEM")&&M?.isTeamMemorySearch(t.input))r.teamMemorySearchCount=(r.teamMemorySearchCount??0)+o;else if(isMemorySearch(t.input))r.memorySearchCount+=o;else{const e=t.input;e?.pattern&&(r.nonMemSearchArgs.push(e.pattern),r.latestDisplayHint=`"${e.pattern}"`)}}else{const o=getFilePathsFromReadMessage(a);for(const t of o)r.readFilePaths.add(t),e("TEAMMEM")&&M?.isTeamMemFile(t)?r.teamMemoryReadFilePaths?.add(t):d(t)?r.memoryReadFilePaths.add(t):r.latestDisplayHint=p(t);if(0===o.length){r.readOperationCount+=countToolUses(a);const e=t.input;e?.command&&(r.latestDisplayHint=commandAsHint(e.command))}}for(const e of getToolUseIdsFromMessage(a))r.toolUseIds.add(e);r.messages.push(a)}else isCollapsibleToolResult(a,r.toolUseIds)?(r.messages.push(a),h()&&r.bashCommands?.size&&scanBashResultForGitOps(a,r)):r.messages.length>0&&isPreToolHookSummary(a)?(r.hookCount+=a.hookCount,r.hookTotalMs+=a.totalDurationMs??a.hookInfos.reduce((e,t)=>e+(t.durationMs??0),0),r.hookInfos.push(...a.hookInfos)):r.messages.length>0&&"attachment"===a.type&&"relevant_memories"===a.attachment.type?(r.relevantMemories??=[],r.relevantMemories.push(...a.attachment.memories)):shouldSkipMessage(a)?r.messages.length>0&&("attachment"!==a.type||"nested_memory"!==a.attachment.type)?i.push(a):s.push(a):isTextBreaker(a)?(flushGroup(),s.push(a)):(isNonCollapsibleToolUse(a,o),flushGroup(),s.push(a));return flushGroup(),s}export function getSearchReadSummaryText(t,o,s,n=0,r,i=0){const a=[];if(r){const{memorySearchCount:t,memoryReadCount:o,memoryWriteCount:n}=r;if(o>0){const e=s?0===a.length?"Recalling":"recalling":0===a.length?"Recalled":"recalled";a.push(`${e} ${o} ${1===o?"memory":"memories"}`)}if(t>0){const e=s?0===a.length?"Searching":"searching":0===a.length?"Searched":"searched";a.push(`${e} memories`)}if(n>0){const e=s?0===a.length?"Writing":"writing":0===a.length?"Wrote":"wrote";a.push(`${e} ${n} ${1===n?"memory":"memories"}`)}e("TEAMMEM")&&M&&M.appendTeamMemorySummaryParts(r,s,a)}if(t>0){const e=s?0===a.length?"Searching for":"searching for":0===a.length?"Searched for":"searched for";a.push(`${e} ${t} ${1===t?"pattern":"patterns"}`)}if(o>0){const e=s?0===a.length?"Reading":"reading":0===a.length?"Read":"read";a.push(`${e} ${o} ${1===o?"file":"files"}`)}if(i>0){const e=s?0===a.length?"Listing":"listing":0===a.length?"Listed":"listed";a.push(`${e} ${i} ${1===i?"directory":"directories"}`)}if(n>0){const e=s?"REPL'ing":"REPL'd";a.push(`${e} ${n} ${1===n?"time":"times"}`)}const l=a.join(", ");return s?`${l}…`:l}export function summarizeRecentActivities(e){if(0===e.length)return;let t=0,o=0;for(let s=e.length-1;s>=0;s--){const n=e[s];if(n.isSearch)t++;else{if(!n.isRead)break;o++}}if(t+o>=2)return getSearchReadSummaryText(t,o,!0);for(let t=e.length-1;t>=0;t--)if(e[t]?.activityDescription)return e[t].activityDescription}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import{mkdir as
|
|
1
|
+
import e from"chalk";import{mkdir as t,readFile as n,writeFile as o}from"fs/promises";import{homedir as i}from"os";import{dirname as c,join as l}from"path";import{pathToFileURL as r}from"url";import{color as s}from"../components/design-system/color.js";import{supportsHyperlinks as a}from"../ink/supports-hyperlinks.js";import{logForDebugging as m}from"./debug.js";import{isENOENT as h}from"./errors.js";import{execFileNoThrow as $}from"./execFileNoThrow.js";import{logError as p}from"./log.js";const u="\n";function detectShell(){const e=process.env.SHELL||"",t=i(),n=l(t,".claude");if(e.endsWith("/zsh")||e.endsWith("/zsh.exe")){const e=l(n,"completion.zsh");return{name:"zsh",rcFile:l(t,".zshrc"),cacheFile:e,completionLine:`[[ -f "${e}" ]] && source "${e}"`,shellFlag:"zsh"}}if(e.endsWith("/bash")||e.endsWith("/bash.exe")){const e=l(n,"completion.bash");return{name:"bash",rcFile:l(t,".bashrc"),cacheFile:e,completionLine:`[ -f "${e}" ] && source "${e}"`,shellFlag:"bash"}}if(e.endsWith("/fish")||e.endsWith("/fish.exe")){const e=process.env.XDG_CONFIG_HOME||l(t,".config"),o=l(n,"completion.fish");return{name:"fish",rcFile:l(e,"fish","config.fish"),cacheFile:o,completionLine:`[ -f "${o}" ] && source "${o}"`,shellFlag:"fish"}}return null}function formatPathLink(e){if(!a())return e;return`]8;;${r(e).href}${e}]8;;`}export async function setupShellCompletion(i){const l=detectShell();if(!l)return"";try{await t(c(l.cacheFile),{recursive:!0})}catch(t){return p(t),`${u}${s("warning",i)(`Could not write ${l.name} completion cache`)}${u}${e.dim(`Run manually: context completion ${l.shellFlag} > ${l.cacheFile}`)}${u}`}const r=process.argv[1]||"claude";if(0!==(await $(r,["completion",l.shellFlag,"--output",l.cacheFile])).code)return`${u}${s("warning",i)(`Could not generate ${l.name} shell completions`)}${u}${e.dim(`Run manually: context completion ${l.shellFlag} > ${l.cacheFile}`)}${u}`;let a="";try{if(a=await n(l.rcFile,{encoding:"utf-8"}),a.includes("context completion")||a.includes(l.cacheFile))return`${u}${s("success",i)(`Shell completions updated for ${l.name}`)}${u}${e.dim(`See ${formatPathLink(l.rcFile)}`)}${u}`}catch(t){if(!h(t))return p(t),`${u}${s("warning",i)(`Could not install ${l.name} shell completions`)}${u}${e.dim(`Add this to ${formatPathLink(l.rcFile)}:`)}${u}${e.dim(l.completionLine)}${u}`}try{const n=c(l.rcFile);await t(n,{recursive:!0});const r=a&&!a.endsWith("\n")?"\n":"",m=`${a}${r}\n# Context Code shell completions\n${l.completionLine}\n`;return await o(l.rcFile,m,{encoding:"utf-8"}),`${u}${s("success",i)(`Installed ${l.name} shell completions`)}${u}${e.dim(`Added to ${formatPathLink(l.rcFile)}`)}${u}${e.dim(`Run: source ${l.rcFile}`)}${u}`}catch(t){return p(t),`${u}${s("warning",i)(`Could not install ${l.name} shell completions`)}${u}${e.dim(`Add this to ${formatPathLink(l.rcFile)}:`)}${u}${e.dim(l.completionLine)}${u}`}}export async function regenerateCompletionCache(){const e=detectShell();if(!e)return;m(`update: Regenerating ${e.name} completion cache`);const t=process.argv[1]||"claude";0===(await $(t,["completion",e.shellFlag,"--output",e.cacheFile])).code?m(`update: Regenerated ${e.name} completion cache at ${e.cacheFile}`):m(`update: Failed to regenerate ${e.name} completion cache`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeNameForMCP as e}from"../../services/mcp/normalization.js";import{env as o}from"../env.js";export const COMPUTER_USE_MCP_SERVER_NAME="computer-use";export const CLI_HOST_BUNDLE_ID="com.anthropic.claude-code.cli-no-window";const
|
|
1
|
+
import{normalizeNameForMCP as e}from"../../services/mcp/normalization.js";import{env as o}from"../env.js";export const COMPUTER_USE_MCP_SERVER_NAME="computer-use";export const CLI_HOST_BUNDLE_ID="com.anthropic.claude-code.cli-no-window";const t={"iTerm.app":"com.googlecode.iterm2",Apple_Terminal:"com.apple.Terminal",ghostty:"com.mitchellh.ghostty",kitty:"net.kovidgoyal.kitty",WarpTerminal:"dev.warp.Warp-Stable",vscode:"com.microsoft.VSCode"};export function getTerminalBundleId(){const e=process.env.__CFBundleIdentifier;return e||(t[o.terminal??""]??null)}export const CLI_CU_CAPABILITIES={screenshotFiltering:"native",platform:"darwin"};export function isComputerUseMCPServer(o){return"computer-use"===e(o)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{feature as
|
|
1
|
+
import{feature as e}from"../recovery/bunBundleShim.js";import{chmod as s,mkdir as t,readdir as n,readFile as o,unlink as r,writeFile as i}from"fs/promises";import{join as a}from"path";import{getOriginalCwd as c,getSessionId as p,onSessionSwitch as S}from"../bootstrap/state.js";import{registerCleanup as d}from"./cleanupRegistry.js";import{logForDebugging as u}from"./debug.js";import{getClaudeConfigHomeDir as E}from"./envUtils.js";import{errorMessage as m,isFsInaccessible as _}from"./errors.js";import{isProcessRunning as f}from"./genericProcessUtils.js";import{getPlatform as O}from"./platform.js";import{jsonParse as D,jsonStringify as N}from"./slowOperations.js";import{getAgentId as C}from"./teammate.js";function getSessionsDir(){return a(E(),"sessions")}function envSessionKind(){if(e("BG_SESSIONS")){const e=process.env.CONTEXT_CODE_SESSION_KIND??process.env.CLAUDE_CODE_SESSION_KIND;if("bg"===e||"daemon"===e||"daemon-worker"===e)return e}}export function isBgSession(){return"bg"===envSessionKind()}export async function registerSession(){if(null!=C())return!1;const n=envSessionKind()??"interactive",o=getSessionsDir(),E=a(o,`${process.pid}.json`);d(async()=>{try{await r(E)}catch{}});try{return await t(o,{recursive:!0,mode:448}),await s(o,448),await i(E,N({pid:process.pid,sessionId:p(),cwd:c(),startedAt:Date.now(),kind:n,entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT,...e("UDS_INBOX")?{messagingSocketPath:process.env.CONTEXT_CODE_MESSAGING_SOCKET??process.env.CLAUDE_CODE_MESSAGING_SOCKET}:{},...e("BG_SESSIONS")?{name:process.env.CONTEXT_CODE_SESSION_NAME??process.env.CLAUDE_CODE_SESSION_NAME,logPath:process.env.CONTEXT_CODE_SESSION_LOG??process.env.CLAUDE_CODE_SESSION_LOG,agent:process.env.CONTEXT_CODE_AGENT??process.env.CLAUDE_CODE_AGENT}:{}})),S(e=>{updatePidFile({sessionId:e})}),!0}catch(e){return u(`[concurrentSessions] register failed: ${m(e)}`),!1}}async function updatePidFile(e){const s=a(getSessionsDir(),`${process.pid}.json`);try{const t=D(await o(s,"utf8"));await i(s,N({...t,...e}))}catch(e){u(`[concurrentSessions] updatePidFile failed: ${m(e)}`)}}export async function updateSessionName(e){e&&await updatePidFile({name:e})}export async function updateSessionBridgeId(e){await updatePidFile({bridgeSessionId:e})}export async function updateSessionActivity(s){e("BG_SESSIONS")&&await updatePidFile({...s,updatedAt:Date.now()})}export async function countConcurrentSessions(){const e=getSessionsDir();let s;try{s=await n(e)}catch(e){return _(e)||u(`[concurrentSessions] readdir failed: ${m(e)}`),0}let t=0;for(const n of s){if(!/^\d+\.json$/.test(n))continue;const s=parseInt(n.slice(0,-5),10);s!==process.pid?f(s)?t++:"wsl"!==O()&&r(a(e,n)).catch(()=>{}):t++}return t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONTEXT_1M_BETA_HEADER as e}from"../constants/betas.js";import{getGlobalConfig as n}from"./config.js";import{isEnvTruthy as t}from"./envUtils.js";import{getCanonicalName as o}from"./model/model.js";import{getModelCapability as s}from"./model/modelCapabilities.js";export const MODEL_CONTEXT_WINDOW_DEFAULT=2e5;export const COMPACT_MAX_OUTPUT_TOKENS=2e4;export const CAPPED_DEFAULT_MAX_TOKENS=8e3;export const ESCALATED_MAX_TOKENS=64e3;export function is1mContextDisabled(){return t(process.env.CONTEXT_CODE_DISABLE_1M_CONTEXT)||t(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}export function has1mContext(e){return!is1mContextDisabled()&&/\[1m\]/i.test(e)}export function modelSupports1M(e){if(is1mContextDisabled())return!1;const n=o(e);return n.includes("claude-sonnet-4")||n.includes("opus-4-7")||n.includes("opus-4-6")}export function getContextWindowForModel(n,t){if("ant"===process.env.USER_TYPE){const e=process.env.CONTEXT_CODE_MAX_CONTEXT_TOKENS??process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS;if(e){const n=parseInt(e,10);if(!isNaN(n)&&n>0)return n}}if(has1mContext(n))return 1e6;const o=s(n);if(o?.max_input_tokens&&o.max_input_tokens>=1e5)return o.max_input_tokens>2e5&&is1mContextDisabled()?2e5:o.max_input_tokens;if(t?.includes(e)&&modelSupports1M(n))return 1e6;if(getSonnet1mExpTreatmentEnabled(n))return 1e6;if("ant"===process.env.USER_TYPE){const e=resolveAntModel(n);if(e?.contextWindow)return e.contextWindow}return 2e5}export function getSonnet1mExpTreatmentEnabled(e){return!is1mContextDisabled()
|
|
1
|
+
import{CONTEXT_1M_BETA_HEADER as e}from"../constants/betas.js";import{getGlobalConfig as n}from"./config.js";import{isEnvTruthy as t}from"./envUtils.js";import{getCanonicalName as o}from"./model/model.js";import{getModelCapability as s}from"./model/modelCapabilities.js";export const MODEL_CONTEXT_WINDOW_DEFAULT=2e5;export const COMPACT_MAX_OUTPUT_TOKENS=2e4;export const CAPPED_DEFAULT_MAX_TOKENS=8e3;export const ESCALATED_MAX_TOKENS=64e3;export function is1mContextDisabled(){return t(process.env.CONTEXT_CODE_DISABLE_1M_CONTEXT)||t(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}export function has1mContext(e){return!is1mContextDisabled()&&/\[1m\]/i.test(e)}export function modelSupports1M(e){if(is1mContextDisabled())return!1;const n=o(e);return n.includes("claude-sonnet-4")||n.includes("opus-4-7")||n.includes("opus-4-6")}export function getContextWindowForModel(n,t){if("ant"===process.env.USER_TYPE){const e=process.env.CONTEXT_CODE_MAX_CONTEXT_TOKENS??process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS;if(e){const n=parseInt(e,10);if(!isNaN(n)&&n>0)return n}}if(has1mContext(n))return 1e6;const o=s(n);if(o?.max_input_tokens&&o.max_input_tokens>=1e5)return o.max_input_tokens>2e5&&is1mContextDisabled()?2e5:o.max_input_tokens;if(t?.includes(e)&&modelSupports1M(n))return 1e6;if(getSonnet1mExpTreatmentEnabled(n))return 1e6;if("ant"===process.env.USER_TYPE){const e=resolveAntModel(n);if(e?.contextWindow)return e.contextWindow}return 2e5}export function getSonnet1mExpTreatmentEnabled(e){return!is1mContextDisabled()&&(!has1mContext(e)&&(!!o(e).includes("sonnet-4-6")&&"true"===n().clientDataCache?.coral_reef_sonnet))}export function calculateContextPercentages(e,n){if(!e)return{used:null,remaining:null};const t=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens,o=Math.round(t/n*100),s=Math.min(100,Math.max(0,o));return{used:s,remaining:100-s}}export function getModelMaxOutputTokens(e){let n,t;if("ant"===process.env.USER_TYPE){const o=resolveAntModel(e.toLowerCase());if(o)return n=o.defaultMaxTokens??32e3,t=o.upperMaxTokensLimit??64e3,{default:n,upperLimit:t}}const i=o(e);i.includes("opus-4-7")||i.includes("opus-4-6")?(n=64e3,t=128e3):i.includes("sonnet-4-6")?(n=32e3,t=128e3):i.includes("opus-4-5")||i.includes("sonnet-4")||i.includes("haiku-4")?(n=32e3,t=64e3):i.includes("opus-4-1")||i.includes("opus-4")?(n=32e3,t=32e3):i.includes("claude-3-opus")?(n=4096,t=4096):i.includes("claude-3-sonnet")?(n=8192,t=8192):i.includes("claude-3-haiku")?(n=4096,t=4096):i.includes("3-5-sonnet")||i.includes("3-5-haiku")?(n=8192,t=8192):(i.includes("3-7-sonnet"),n=32e3,t=64e3);const r=s(e);return r?.max_tokens&&r.max_tokens>=4096&&(t=r.max_tokens,n=Math.min(n,t)),{default:n,upperLimit:t}}export function getMaxThinkingTokensForModel(e){return getModelMaxOutputTokens(e).upperLimit-1}
|
package/dist/src/utils/cron.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=[{min:0,max:59},{min:0,max:23},{min:1,max:31},{min:1,max:12},{min:0,max:6}];function expandField(t,e){const{min:n,max:r}=e,o=new Set;for(const e of t.split(",")){const t=e.match(/^\*(?:\/(\d+))?$/);if(t){const e=t[1]?parseInt(t[1],10):1;if(e<1)return null;for(let t=n;t<=r;t+=e)o.add(t);continue}const a=e.match(/^(\d+)-(\d+)(?:\/(\d+))?$/);if(a){const t=parseInt(a[1],10),e=parseInt(a[2],10),s=a[3]?parseInt(a[3],10):1,i=0===n&&6===r;if(t>e||s<1||t<n||e>(i?7:r))return null;for(let n=t;n<=e;n+=s)o.add(i&&7===n?0:n);continue}if(e.match(/^\d+$/)){let t=parseInt(e,10);if(0===n&&6===r&&7===t&&(t=0),t<n||t>r)return null;o.add(t);continue}return null}return 0===o.size?null:Array.from(o).sort((t,e)=>t-e)}export function parseCronExpression(e){const n=e.trim().split(/\s+/);if(5!==n.length)return null;const r=[];for(let e=0;e<5;e++){const o=expandField(n[e],t[e]);if(!o)return null;r.push(o)}return{minute:r[0],hour:r[1],dayOfMonth:r[2],month:r[3],dayOfWeek:r[4]}}export function computeNextCronRun(t,e){const n=new Set(t.minute),r=new Set(t.hour),o=new Set(t.dayOfMonth),a=new Set(t.month),s=new Set(t.dayOfWeek),i=31===t.dayOfMonth.length,u=7===t.dayOfWeek.length,c=new Date(e.getTime());c.setSeconds(0,0),c.setMinutes(c.getMinutes()+1);for(let t=0;t<527040;t++){const t=c.getMonth()+1;if(!a.has(t)){c.setMonth(c.getMonth()+1,1),c.setHours(0,0,0,0);continue}const e=c.getDate(),m=c.getDay();if(i
|
|
1
|
+
const t=[{min:0,max:59},{min:0,max:23},{min:1,max:31},{min:1,max:12},{min:0,max:6}];function expandField(t,e){const{min:n,max:r}=e,o=new Set;for(const e of t.split(",")){const t=e.match(/^\*(?:\/(\d+))?$/);if(t){const e=t[1]?parseInt(t[1],10):1;if(e<1)return null;for(let t=n;t<=r;t+=e)o.add(t);continue}const a=e.match(/^(\d+)-(\d+)(?:\/(\d+))?$/);if(a){const t=parseInt(a[1],10),e=parseInt(a[2],10),s=a[3]?parseInt(a[3],10):1,i=0===n&&6===r;if(t>e||s<1||t<n||e>(i?7:r))return null;for(let n=t;n<=e;n+=s)o.add(i&&7===n?0:n);continue}if(e.match(/^\d+$/)){let t=parseInt(e,10);if(0===n&&6===r&&7===t&&(t=0),t<n||t>r)return null;o.add(t);continue}return null}return 0===o.size?null:Array.from(o).sort((t,e)=>t-e)}export function parseCronExpression(e){const n=e.trim().split(/\s+/);if(5!==n.length)return null;const r=[];for(let e=0;e<5;e++){const o=expandField(n[e],t[e]);if(!o)return null;r.push(o)}return{minute:r[0],hour:r[1],dayOfMonth:r[2],month:r[3],dayOfWeek:r[4]}}export function computeNextCronRun(t,e){const n=new Set(t.minute),r=new Set(t.hour),o=new Set(t.dayOfMonth),a=new Set(t.month),s=new Set(t.dayOfWeek),i=31===t.dayOfMonth.length,u=7===t.dayOfWeek.length,c=new Date(e.getTime());c.setSeconds(0,0),c.setMinutes(c.getMinutes()+1);for(let t=0;t<527040;t++){const t=c.getMonth()+1;if(!a.has(t)){c.setMonth(c.getMonth()+1,1),c.setHours(0,0,0,0);continue}const e=c.getDate(),m=c.getDay();if(!(!i||!u)||(i?s.has(m):u?o.has(e):o.has(e)||s.has(m)))if(r.has(c.getHours())){if(n.has(c.getMinutes()))return c;c.setMinutes(c.getMinutes()+1)}else c.setHours(c.getHours()+1,0,0,0);else c.setDate(c.getDate()+1),c.setHours(0,0,0,0)}return null}const e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function formatLocalTime(t,e){return new Date(2e3,0,1,e,t).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}function formatUtcTimeAsLocal(t,e){const n=new Date;return n.setUTCHours(e,t,0,0),n.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZoneName:"short"})}export function cronToHuman(t,n){const r=n?.utc??!1,o=t.trim().split(/\s+/);if(5!==o.length)return t;const[a,s,i,u,c]=o,m=a.match(/^\*\/(\d+)$/);if(m&&"*"===s&&"*"===i&&"*"===u&&"*"===c){const t=parseInt(m[1],10);return 1===t?"Every minute":`Every ${t} minutes`}if(a.match(/^\d+$/)&&"*"===s&&"*"===i&&"*"===u&&"*"===c){const t=parseInt(a,10);return 0===t?"Every hour":`Every hour at :${t.toString().padStart(2,"0")}`}const f=s.match(/^\*\/(\d+)$/);if(a.match(/^\d+$/)&&f&&"*"===i&&"*"===u&&"*"===c){const t=parseInt(f[1],10),e=parseInt(a,10),n=0===e?"":` at :${e.toString().padStart(2,"0")}`;return 1===t?`Every hour${n}`:`Every ${t} hours${n}`}if(!a.match(/^\d+$/)||!s.match(/^\d+$/))return t;const d=parseInt(a,10),h=parseInt(s,10),l=r?formatUtcTimeAsLocal:formatLocalTime;if("*"===i&&"*"===u&&"*"===c)return`Every day at ${l(d,h)}`;if("*"===i&&"*"===u&&c.match(/^\d$/)){const t=parseInt(c,10)%7;let n;if(r){const r=new Date,o=(t-r.getUTCDay()+7)%7;r.setUTCDate(r.getUTCDate()+o),r.setUTCHours(h,d,0,0),n=e[r.getDay()]}else n=e[t];if(n)return`Every ${n} at ${l(d,h)}`}return"*"===i&&"*"===u&&"1-5"===c?`Weekdays at ${l(d,h)}`:t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID as
|
|
1
|
+
import{randomUUID as t}from"crypto";import{readFileSync as r}from"fs";import{mkdir as n,writeFile as e}from"fs/promises";import{dirname as o,join as s}from"path";import{addSessionCronTask as i,getProjectRoot as a,getSessionCronTasks as c,removeSessionCronTasks as u}from"../bootstrap/state.js";import{computeNextCronRun as f,parseCronExpression as p}from"./cron.js";import{logForDebugging as l}from"./debug.js";import{isFsInaccessible as d}from"./errors.js";import{getFsImplementation as m}from"./fsOperations.js";import{safeParseJSON as C}from"./json.js";import{logError as h}from"./log.js";import{jsonStringify as g}from"./slowOperations.js";const k=s(".context","scheduled_tasks.json");export function getCronFilePath(t){const r=t??a();return s(r,k)}export async function readCronTasks(t){const r=m();let n;try{n=await r.readFile(getCronFilePath(t),{encoding:"utf-8"})}catch(t){return d(t)||h(t),[]}const e=C(n,!1);if(!e||"object"!=typeof e)return[];const o=e;if(!Array.isArray(o.tasks))return[];const s=[];for(const t of o.tasks)t&&"string"==typeof t.id&&"string"==typeof t.cron&&"string"==typeof t.prompt&&"number"==typeof t.createdAt?p(t.cron)?s.push({id:t.id,cron:t.cron,prompt:t.prompt,createdAt:t.createdAt,..."number"==typeof t.lastFiredAt?{lastFiredAt:t.lastFiredAt}:{},...t.recurring?{recurring:!0}:{},...t.permanent?{permanent:!0}:{}}):l(`[ScheduledTasks] skipping task ${t.id} with invalid cron '${t.cron}'`):l(`[ScheduledTasks] skipping malformed task: ${g(t)}`);return s}export function hasCronTasksSync(t){let n;try{n=r(getCronFilePath(t),"utf-8")}catch{return!1}const e=C(n,!1);if(!e||"object"!=typeof e)return!1;const o=e.tasks;return Array.isArray(o)&&o.length>0}export async function writeCronTasks(t,r){const s=getCronFilePath(r??a());await n(o(s),{recursive:!0});const i={tasks:t.map(({durable:t,...r})=>r)};await e(s,g(i,null,2)+"\n","utf-8")}export async function addCronTask(r,n,e,o,s){const a=t().slice(0,8),c={id:a,cron:r,prompt:n,createdAt:Date.now(),...e?{recurring:!0}:{}};if(!o)return i({...c,...s?{agentId:s}:{}}),a;const u=await readCronTasks();return u.push(c),await writeCronTasks(u),a}export async function removeCronTasks(t,r){if(0===t.length)return;if(void 0===r&&u(t)===t.length)return;const n=new Set(t),e=await readCronTasks(r),o=e.filter(t=>!n.has(t.id));o.length!==e.length&&await writeCronTasks(o,r)}export async function markCronTasksFired(t,r,n){if(0===t.length)return;const e=new Set(t),o=await readCronTasks(n);let s=!1;for(const t of o)e.has(t.id)&&(t.lastFiredAt=r,s=!0);s&&await writeCronTasks(o,n)}export async function listAllCronTasks(t){const r=await readCronTasks(t);if(void 0!==t)return r;const n=c().map(t=>({...t,durable:!1}));return[...r,...n]}export function nextCronRunMs(t,r){const n=p(t);if(!n)return null;const e=f(n,new Date(r));return e?e.getTime():null}export const DEFAULT_CRON_JITTER_CONFIG={recurringFrac:.1,recurringCapMs:9e5,oneShotMaxMs:9e4,oneShotFloorMs:0,oneShotMinuteMod:30,recurringMaxAgeMs:6048e5};function jitterFrac(t){const r=parseInt(t.slice(0,8),16)/4294967296;return Number.isFinite(r)?r:0}export function jitteredNextCronRunMs(t,r,n,e=DEFAULT_CRON_JITTER_CONFIG){const o=nextCronRunMs(t,r);if(null===o)return null;const s=nextCronRunMs(t,o);if(null===s)return o;return o+Math.min(jitterFrac(n)*e.recurringFrac*(s-o),e.recurringCapMs)}export function oneShotJitteredNextCronRunMs(t,r,n,e=DEFAULT_CRON_JITTER_CONFIG){const o=nextCronRunMs(t,r);if(null===o)return null;if(new Date(o).getMinutes()%e.oneShotMinuteMod!==0)return o;const s=e.oneShotFloorMs+jitterFrac(n)*(e.oneShotMaxMs-e.oneShotFloorMs);return Math.max(o-s,r)}export function findMissedTasks(t,r){return t.filter(t=>{const n=nextCronRunMs(t.cron,t.createdAt);return null!==n&&n<r})}
|
package/dist/src/utils/cwd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AsyncLocalStorage as t}from"async_hooks";import{getCwdState as r,getOriginalCwd as
|
|
1
|
+
import{AsyncLocalStorage as t}from"async_hooks";import{getCwdState as r,getOriginalCwd as o}from"../bootstrap/state.js";const n=new t;export function runWithCwdOverride(t,r){return n.run(t,r)}export function pwd(){return n.getStore()??r()}export function getCwd(){try{return pwd()}catch{return o()}}
|
package/dist/src/utils/debug.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{appendFile as e,mkdir as t,symlink as r,unlink as
|
|
1
|
+
import{appendFile as e,mkdir as t,symlink as r,unlink as o}from"fs/promises";import s from"lodash-es/memoize.js";import{dirname as n,join as i}from"path";import{getSessionId as u}from"../bootstrap/state.js";import{createBufferedWriter as c}from"./bufferedWriter.js";import{registerCleanup as g}from"./cleanupRegistry.js";import{parseDebugFilter as a,shouldShowDebugMessage as p}from"./debugFilter.js";import{getClaudeConfigHomeDir as l,isEnvTruthy as f}from"./envUtils.js";import{getFsImplementation as d}from"./fsOperations.js";import{writeToStderr as b}from"./process.js";import{jsonStringify as D}from"./slowOperations.js";const m={verbose:0,debug:1,info:2,warn:3,error:4};export const getMinDebugLogLevel=s(()=>{const e=(process.env.CONTEXT_CODE_DEBUG_LOG_LEVEL??process.env.CLAUDE_CODE_DEBUG_LOG_LEVEL)?.toLowerCase().trim();return e&&Object.hasOwn(m,e)?e:"debug"});let v=!1;export const isDebugMode=s(()=>v||f(process.env.DEBUG)||f(process.env.DEBUG_SDK)||process.argv.includes("--debug")||process.argv.includes("-d")||isDebugToStdErr()||process.argv.some(e=>e.startsWith("--debug="))||null!==getDebugFilePath());export function enableDebugLogging(){const e=isDebugMode()||"ant"===process.env.USER_TYPE;return v=!0,isDebugMode.cache.clear?.(),e}export const getDebugFilter=s(()=>{const e=process.argv.find(e=>e.startsWith("--debug="));if(!e)return null;const t=e.substring(8);return a(t)});export const isDebugToStdErr=s(()=>process.argv.includes("--debug-to-stderr")||process.argv.includes("-d2e"));export const getDebugFilePath=s(()=>{for(let e=0;e<process.argv.length;e++){const t=process.argv[e];if(t.startsWith("--debug-file="))return t.substring(13);if("--debug-file"===t&&e+1<process.argv.length)return process.argv[e+1]}return null});let E=!1;export function setHasFormattedOutput(e){E=e}export function getHasFormattedOutput(){return E}let h=null,L=Promise.resolve();async function appendAsync(r,o,s,n){r&&await t(o,{recursive:!0}).catch(()=>{}),await e(s,n),_()}function noop(){}function getDebugWriter(){if(!h){let e=null;h=c({writeFn:t=>{const r=getDebugLogPath(),o=n(r),s=e!==o;if(e=o,isDebugMode()){if(s)try{d().mkdirSync(o)}catch{}return d().appendFileSync(r,t),void _()}L=L.then(appendAsync.bind(null,s,o,r,t)).catch(noop)},flushIntervalMs:1e3,maxBufferSize:100,immediateMode:isDebugMode()}),g(async()=>{h?.dispose(),await L})}return h}export async function flushDebugLogs(){h?.flush(),await L}export function logForDebugging(e,{level:t}={level:"debug"}){if(m[t]<m[getMinDebugLogLevel()])return;if(!function(e){if("test"===process.env.NODE_ENV&&!isDebugToStdErr())return!1;if("ant"!==process.env.USER_TYPE&&!isDebugMode())return!1;if("undefined"==typeof process||void 0===process.versions||void 0===process.versions.node)return!1;const t=getDebugFilter();return p(e,t)}(e))return;E&&e.includes("\n")&&(e=D(e));const r=`${(new Date).toISOString()} [${t.toUpperCase()}] ${e.trim()}\n`;isDebugToStdErr()?b(r):getDebugWriter().write(r)}export function getDebugLogPath(){return getDebugFilePath()??process.env.CONTEXT_CODE_DEBUG_LOGS_DIR??process.env.CLAUDE_CODE_DEBUG_LOGS_DIR??i(l(),"debug",`${u()}.txt`)}const _=s(async()=>{try{const e=getDebugLogPath(),t=n(e),s=i(t,"latest");await o(s).catch(()=>{}),await r(e,s)}catch{}});export function logAntError(e,t){"ant"===process.env.USER_TYPE&&t instanceof Error&&t.stack&&logForDebugging(`[ANT-ONLY] ${e} stack trace:\n${t.stack}`,{level:"error"})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"lodash-es/memoize.js";export const parseDebugFilter=e(e=>{if(!e||""===e.trim())return null;const t=e.split(",").map(e=>e.trim()).filter(Boolean);if(0===t.length)return null;const s=t.some(e=>e.startsWith("!")),o=t.some(e=>!e.startsWith("!"));if(s&&o)return null;const r=t.map(e=>e.replace(/^!/,"").toLowerCase());return{include:s?[]:r,exclude:s?r:[],isExclusive:s}});export function extractDebugCategories(e){const t=[],s=e.match(/^MCP server ["']([^"']+)["']/);if(s&&s[1])t.push("mcp"),t.push(s[1].toLowerCase());else{const s=e.match(/^([^:[]+):/);s&&s[1]&&t.push(s[1].trim().toLowerCase())}const o=e.match(/^\[([^\]]+)]/);o&&o[1]&&t.push(o[1].trim().toLowerCase()),e.toLowerCase().includes("1p event:")&&t.push("1p");const r=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(r&&r[1]){const e=r[1].trim().toLowerCase();e.length<30&&!e.includes(" ")&&t.push(e)}return Array.from(new Set(t))}export function shouldShowDebugCategories(e,t){return!t||0!==e.length&&(t.isExclusive?!e.some(e=>t.exclude.includes(e)):e.some(e=>t.include.includes(e)))}export function shouldShowDebugMessage(e,t){return!
|
|
1
|
+
import e from"lodash-es/memoize.js";export const parseDebugFilter=e(e=>{if(!e||""===e.trim())return null;const t=e.split(",").map(e=>e.trim()).filter(Boolean);if(0===t.length)return null;const s=t.some(e=>e.startsWith("!")),o=t.some(e=>!e.startsWith("!"));if(s&&o)return null;const r=t.map(e=>e.replace(/^!/,"").toLowerCase());return{include:s?[]:r,exclude:s?r:[],isExclusive:s}});export function extractDebugCategories(e){const t=[],s=e.match(/^MCP server ["']([^"']+)["']/);if(s&&s[1])t.push("mcp"),t.push(s[1].toLowerCase());else{const s=e.match(/^([^:[]+):/);s&&s[1]&&t.push(s[1].trim().toLowerCase())}const o=e.match(/^\[([^\]]+)]/);o&&o[1]&&t.push(o[1].trim().toLowerCase()),e.toLowerCase().includes("1p event:")&&t.push("1p");const r=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(r&&r[1]){const e=r[1].trim().toLowerCase();e.length<30&&!e.includes(" ")&&t.push(e)}return Array.from(new Set(t))}export function shouldShowDebugCategories(e,t){return!t||0!==e.length&&(t.isExclusive?!e.some(e=>t.exclude.includes(e)):e.some(e=>t.include.includes(e)))}export function shouldShowDebugMessage(e,t){if(!t)return!0;return shouldShowDebugCategories(extractDebugCategories(e),t)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCwd as t}from"./cwd.js";import{logForDebugging as e}from"./debug.js";import{getRemoteUrl as o}from"./git.js";const n=new Map;export function clearRepositoryCaches(){n.clear()}export async function detectCurrentRepository(){const t=await detectCurrentRepositoryWithHost();return t?"github.com"!==t.host?null:`${t.owner}/${t.name}`:null}export async function detectCurrentRepositoryWithHost(){const r=t();if(n.has(r))return n.get(r)??null;try{const t=await o();if(e(`Git remote URL: ${t}`),!t)return e("No git remote URL found"),n.set(r,null),null;const s=parseGitRemote(t);return e(`Parsed repository: ${s?`${s.host}/${s.owner}/${s.name}`:null} from URL: ${t}`),n.set(r,s),s}catch(t){return e(`Error detecting repository: ${t}`),n.set(r,null),null}}export function getCachedRepository(){const e=n.get(t());return e&&"github.com"===e.host?`${e.owner}/${e.name}`:null}export function parseGitRemote(t){const e=t.trim(),o=e.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/);if(o?.[1]&&o[2]&&o[3])return looksLikeRealHostname(o[1])?{host:o[1],owner:o[2],name:o[3]}:null;const n=e.match(/^(https?|ssh|git):\/\/(?:[^@]+@)?([^/:]+(?::\d+)?)\/([^/]+)\/([^/]+?)(?:\.git)?$/);if(n?.[1]&&n[2]&&n[3]&&n[4]){const t=n[1],e=n[2],o=e.split(":")[0]??"";
|
|
1
|
+
import{getCwd as t}from"./cwd.js";import{logForDebugging as e}from"./debug.js";import{getRemoteUrl as o}from"./git.js";const n=new Map;export function clearRepositoryCaches(){n.clear()}export async function detectCurrentRepository(){const t=await detectCurrentRepositoryWithHost();return t?"github.com"!==t.host?null:`${t.owner}/${t.name}`:null}export async function detectCurrentRepositoryWithHost(){const r=t();if(n.has(r))return n.get(r)??null;try{const t=await o();if(e(`Git remote URL: ${t}`),!t)return e("No git remote URL found"),n.set(r,null),null;const s=parseGitRemote(t);return e(`Parsed repository: ${s?`${s.host}/${s.owner}/${s.name}`:null} from URL: ${t}`),n.set(r,s),s}catch(t){return e(`Error detecting repository: ${t}`),n.set(r,null),null}}export function getCachedRepository(){const e=n.get(t());return e&&"github.com"===e.host?`${e.owner}/${e.name}`:null}export function parseGitRemote(t){const e=t.trim(),o=e.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/);if(o?.[1]&&o[2]&&o[3])return looksLikeRealHostname(o[1])?{host:o[1],owner:o[2],name:o[3]}:null;const n=e.match(/^(https?|ssh|git):\/\/(?:[^@]+@)?([^/:]+(?::\d+)?)\/([^/]+)\/([^/]+?)(?:\.git)?$/);if(n?.[1]&&n[2]&&n[3]&&n[4]){const t=n[1],e=n[2],o=e.split(":")[0]??"";if(!looksLikeRealHostname(o))return null;return{host:"https"===t||"http"===t?e:o,owner:n[3],name:n[4]}}return null}export function parseGitHubRepository(t){const o=t.trim(),n=parseGitRemote(o);if(n)return"github.com"!==n.host?null:`${n.owner}/${n.name}`;if(!o.includes("://")&&!o.includes("@")&&o.includes("/")){const t=o.split("/");if(2===t.length&&t[0]&&t[1]){const e=t[1].replace(/\.git$/,"");return`${t[0]}/${e}`}}return e(`Could not parse repository from: ${o}`),null}function looksLikeRealHostname(t){if(!t.includes("."))return!1;const e=t.split(".").pop();return!!e&&/^[a-zA-Z]+$/.test(e)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname as o}from"path";import{getFsImplementation as t}from"./fsOperations.js";import{jsonStringify as n}from"./slowOperations.js";export function logForDiagnosticsNoPII(i,r,
|
|
1
|
+
import{dirname as o}from"path";import{getFsImplementation as t}from"./fsOperations.js";import{jsonStringify as n}from"./slowOperations.js";export function logForDiagnosticsNoPII(i,r,e){const s=process.env.CONTEXT_CODE_DIAGNOSTICS_FILE??process.env.CLAUDE_CODE_DIAGNOSTICS_FILE;if(!s)return;const a={timestamp:(new Date).toISOString(),level:i,event:r,data:e??{}},c=t(),p=n(a)+"\n";try{c.appendFileSync(s,p)}catch{try{c.mkdirSync(o(s)),c.appendFileSync(s,p)}catch{}}}export async function withDiagnosticsTiming(o,t,n){const i=Date.now();logForDiagnosticsNoPII("info",`${o}_started`);try{const r=await t(),e=n?n(r):{};return logForDiagnosticsNoPII("info",`${o}_completed`,{duration_ms:Date.now()-i,...e}),r}catch(t){throw logForDiagnosticsNoPII("error",`${o}_failed`,{duration_ms:Date.now()-i}),t}}
|
package/dist/src/utils/diff.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{structuredPatch as e}from"diff";import{logEvent as t}from"
|
|
1
|
+
import{structuredPatch as e}from"diff";import{logEvent as t}from"../services/analytics/index.js";import{getLocCounter as r}from"../bootstrap/state.js";import{addToTotalLinesChanged as n}from"../cost-tracker.js";import{count as o}from"./array.js";import{convertLeadingTabsToSpaces as i}from"./file.js";export const CONTEXT_LINES=3;export const DIFF_TIMEOUT_MS=5e3;export function adjustHunkLineNumbers(e,t){return 0===t?e:e.map(e=>({...e,oldStart:e.oldStart+t,newStart:e.newStart+t}))}const s="<<:AMPERSAND_TOKEN:>>",a="<<:DOLLAR_TOKEN:>>";function escapeForDiff(e){return e.replaceAll("&",s).replaceAll("$",a)}function unescapeFromDiff(e){return e.replaceAll(s,"&").replaceAll(a,"$")}export function countLinesChanged(e,i){let s=0,a=0;0===e.length&&i?s=i.split(/\r?\n/).length:(s=e.reduce((e,t)=>e+o(t.lines,e=>e.startsWith("+")),0),a=e.reduce((e,t)=>e+o(t.lines,e=>e.startsWith("-")),0)),n(s,a),r()?.add(s,{type:"added"}),r()?.add(a,{type:"removed"}),t("tengu_file_changed",{lines_added:s,lines_removed:a})}export function getPatchFromContents({filePath:t,oldContent:r,newContent:n,ignoreWhitespace:o=!1,singleHunk:i=!1}){const s=e(t,t,escapeForDiff(r),escapeForDiff(n),void 0,void 0,{ignoreWhitespace:o,context:i?1e5:3,timeout:5e3});return s?s.hunks.map(e=>({...e,lines:e.lines.map(unescapeFromDiff)})):[]}export function getPatchForDisplay({filePath:t,fileContents:r,edits:n,ignoreWhitespace:o=!1}){const s=escapeForDiff(i(r)),a=e(t,t,s,n.reduce((e,t)=>{const{old_string:r,new_string:n}=t,o="replace_all"in t&&t.replace_all,s=escapeForDiff(i(r)),a=escapeForDiff(i(n));return o?e.replaceAll(s,()=>a):e.replace(s,()=>a)},s),void 0,void 0,{context:3,ignoreWhitespace:o,timeout:5e3});return a?a.hunks.map(e=>({...e,lines:e.lines.map(unescapeFromDiff)})):[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function parseDirectMemberMessage(e){const t=e.match(/^@([\w-]+)\s+(.+)$/s);if(!t)return null;const[,n
|
|
1
|
+
export function parseDirectMemberMessage(e){const t=e.match(/^@([\w-]+)\s+(.+)$/s);if(!t)return null;const[,r,n]=t;if(!r||!n)return null;const s=n.trim();return s?{recipientName:r,message:s}:null}export async function sendDirectMemberMessage(e,t,r,n){if(!r||!n)return{success:!1,error:"no_team_context"};return Object.values(r.teammates??{}).find(t=>t.name===e)?(await n(e,{from:"user",text:t,timestamp:(new Date).toISOString()},r.teamName),{success:!0,recipientName:e}):{success:!1,error:"unknown_recipient",recipientName:e}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MACRO as
|
|
1
|
+
import{MACRO as t}from"../recovery/bunBundleShim.js";import{execa as e}from"execa";import{readFile as n,realpath as a}from"fs/promises";import{homedir as o}from"os";import{delimiter as s,join as i,posix as r,win32 as l}from"path";import{checkGlobalInstallPermissions as c}from"./autoUpdater.js";import{isInBundledMode as p}from"./bundledMode.js";import{formatAutoUpdaterDisabledReason as u,getAutoUpdaterDisabledReason as m,getGlobalConfig as d}from"./config.js";import{getCwd as f}from"./cwd.js";import{isEnvTruthy as g}from"./envUtils.js";import{execFileNoThrow as h}from"./execFileNoThrow.js";import{getFsImplementation as x}from"./fsOperations.js";import{getShellType as b,isRunningFromLocalInstallation as w,localInstallationExists as v}from"./localInstaller.js";import{detectApk as y,detectAsdf as j,detectDeb as E,detectHomebrew as $,detectMise as P,detectPacman as A,detectRpm as C,detectWinget as k,getPackageManager as L}from"./nativeInstaller/packageManagers.js";import{getPlatform as I}from"./platform.js";import{getRipgrepStatus as _}from"./ripgrep.js";import{SandboxManager as M}from"./sandbox/sandbox-adapter.js";import{getManagedFilePath as O}from"./settings/managedPath.js";import{CUSTOMIZATION_SURFACES as T}from"./settings/types.js";import{findClaudeAlias as U,findValidClaudeAlias as H,getShellConfigPaths as N}from"./shellConfig.js";import{jsonParse as S}from"./slowOperations.js";import{which as G}from"./which.js";export async function getCurrentInstallationType(){if("development"===process.env.NODE_ENV)return"development";const[t]=function(){let t=process.argv[1]||"",e=process.execPath||process.argv[0]||"";return"windows"===I()&&(t=t.split(l.sep).join(r.sep),e=e.split(l.sep).join(r.sep)),[t,e]}();if(p())return $()||k()||P()||j()||await A()||await E()||await C()||await y()?"package-manager":"native";if(w())return"npm-local";if(["/usr/local/lib/node_modules","/usr/lib/node_modules","/opt/homebrew/lib/node_modules","/opt/homebrew/bin","/usr/local/bin","/.nvm/versions/node/"].some(e=>t.includes(e)))return"npm-global";if(t.includes("/npm/")||t.includes("/nvm/"))return"npm-global";const n=await e("npm config get prefix",{shell:!0,reject:!1}),a=0===n.exitCode?n.stdout.trim():null;return a&&t.startsWith(a)?"npm-global":"unknown"}export function getInvokedBinary(){try{return p()?process.execPath||"unknown":process.argv[1]||"unknown"}catch{return"unknown"}}export function detectLinuxGlobPatternWarnings(){if("linux"!==I())return[];const t=[],e=M.getLinuxGlobPatternWarnings();if(e.length>0){const n=e.slice(0,3).join(", "),a=e.length-3,o=a>0?`${n} (${a} more)`:n;t.push({issue:"Los patrones glob en las reglas de permisos del sandbox no están totalmente soportados en Linux",fix:`Se han encontrado ${e.length} patrón(es): ${o}. En Linux, los patrones glob en las reglas de Editar/Leer serán ignorados.`})}return t}export async function getDoctorDiagnostic(){const e=await getCurrentInstallationType(),w=void 0!==t&&t.VERSION?t.VERSION:"unknown",y=await async function(){if("development"===process.env.NODE_ENV)return f();if(p()){try{return await a(process.execPath)}catch{}try{const t=await G("context");if(t)return t}catch{}try{return await x().stat(i(o(),".local/bin/context")),i(o(),".local/bin/context")}catch{}return"native"}try{return process.argv[0]||"unknown"}catch{return"unknown"}}(),j=getInvokedBinary(),E=await async function(){const e=x(),n=[],s=i(o(),".context","local");await v()&&n.push({type:"npm-local",path:s});const r=["@iaforged/context-code"];t.PACKAGE_URL&&"@iaforged/context-code"!==t.PACKAGE_URL&&r.push(t.PACKAGE_URL);const l=await h("npm",["-g","config","get","prefix"]);if(0===l.code&&l.stdout){const t=l.stdout.trim(),o="windows"===I(),s=o?i(t,"context"):i(t,"bin","context");let c=!1;try{await e.stat(s),c=!0}catch{}if(c){let t=!1;try{(await a(s)).includes("/Caskroom/")&&(t=$())}catch{}t||n.push({type:"npm-global",path:s})}else for(const a of r){const s=o?i(t,"node_modules",a):i(t,"lib","node_modules",a);try{await e.stat(s),n.push({type:"npm-global-orphan",path:s})}catch{}}}const c=i(o(),".local","bin","context");try{await e.stat(c),n.push({type:"native",path:c})}catch{}if("native"===d().installMethod){const t=i(o(),".local","share","context");try{await e.stat(t),n.some(t=>"native"===t.type)||n.push({type:"native",path:t})}catch{}}return n}(),P=await async function(t){const e=[];try{const t=await n(i(O(),"managed-settings.json"),"utf-8"),a=S(t),o=a&&"object"==typeof a?a.strictPluginOnlyCustomization:void 0;if(void 0!==o&&"boolean"!=typeof o)if(Array.isArray(o)){const t=o.filter(t=>"string"==typeof t&&!T.includes(t));t.length>0&&e.push({issue:`managed-settings.json: strictPluginOnlyCustomization tiene ${t.length} valor(es) que este cliente no reconoce: ${t.map(String).join(", ")}`,fix:`Estos se ignoran silenciosamente. Superficies conocidas para esta versión: ${T.join(", ")}. Elimínalos o actualiza el cliente.`})}else e.push({issue:`managed-settings.json: strictPluginOnlyCustomization tiene un valor no válido (se esperaba boolean o array, se obtuvo ${typeof o})`,fix:`El campo se ignora silenciosamente. Establécelo en true o en un array de: ${T.join(", ")}.`})}catch{}const a=d();if("development"===t)return e;if("native"===t){const t=(process.env.PATH||"").split(s),n=o(),a=i(n,".local","bin");let c=a;if("windows"===I()&&(c=a.split(l.sep).join(r.sep)),!t.some(t=>{let e=t;"windows"===I()&&(e=t.split(l.sep).join(r.sep));const n=e.replace(/\/+$/,""),a=t.replace(/[/\\]+$/,"");return n===c||"~/.local/bin"===a||"$HOME/.local/bin"===a}))if("windows"===I()){const t=a.split(r.sep).join(l.sep);e.push({issue:`Existe una instalación nativa pero ${t} no está en tu PATH`,fix:"Añádelo abriendo: Propiedades del sistema → Variables de entorno → Editar PATH de usuario → Nuevo → Añade la ruta de arriba. Luego reinicia tu terminal."})}else{const t=b(),n=N()[t],a=n?n.replace(o(),"~"):"your shell config file";e.push({issue:"Existe una instalación nativa pero ~/.local/bin no está en tu PATH",fix:`Ejecuta: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ${a} luego abre una nueva terminal o ejecuta: source ${a}`})}}g(process.env.DISABLE_INSTALLATION_CHECKS)||("npm-local"===t&&"local"!==a.installMethod&&e.push({issue:`Ejecutando desde una instalación local pero el método de instalación configurado es '${a.installMethod}'`,fix:"Considera usar la instalación nativa: context install"}),"native"===t&&"native"!==a.installMethod&&e.push({issue:`Ejecutando instalación nativa pero el método de instalación configurado es '${a.installMethod}'`,fix:"Ejecuta context install para actualizar la configuración"})),"npm-global"===t&&await v()&&e.push({issue:"Existe una instalación local pero no se está usando",fix:"Considera usar la instalación nativa: context install"});const c=await U(),p=await H();"npm-local"===t&&(await G("claude")||p||(c?e.push({issue:"Instalación local no accesible",fix:`El alias existe pero apunta a un destino no válido: ${c}. Actualiza el alias: alias context="~/.context/local/context"`}):e.push({issue:"Instalación local no accesible",fix:'Crea un alias: alias context="~/.context/local/context"'})));return e}(e);if(P.push(...detectLinuxGlobPatternWarnings()),"native"===e){const e=E.filter(t=>"npm-global"===t.type||"npm-global-orphan"===t.type||"npm-local"===t.type),n="windows"===I();for(const a of e)if("npm-global"===a.type){let e="npm -g uninstall @iaforged/context-code";t.PACKAGE_URL&&"@iaforged/context-code"!==t.PACKAGE_URL&&(e+=` && npm -g uninstall ${t.PACKAGE_URL}`),P.push({issue:`Quedan restos de una instalación global de npm en ${a.path}`,fix:`Ejecuta: ${e}`})}else"npm-global-orphan"===a.type?P.push({issue:`Paquete global de npm huérfano en ${a.path}`,fix:n?`Ejecuta: rmdir /s /q "${a.path}"`:`Ejecuta: rm -rf ${a.path}`}):"npm-local"===a.type&&P.push({issue:`Quedan restos de una instalación local de npm en ${a.path}`,fix:n?`Ejecuta: rmdir /s /q "${a.path}"`:`Ejecuta: rm -rf ${a.path}`})}const A=d().installMethod||"not set";let C=null;if("npm-global"===e){C=(await c()).hasPermissions,C||m()||P.push({issue:"Permisos insuficientes para actualizaciones automáticas",fix:"Haz una de las dos: (1) Reinstala node sin sudo, o (2) Usa `context install` para una instalación nativa"})}const k=_(),M={working:k.working??!0,mode:k.mode,systemPath:"system"===k.mode?k.path:null},R="package-manager"===e?await L():void 0;return{installationType:e,version:w,installationPath:y,invokedBinary:j,configInstallMethod:A,autoUpdates:(()=>{const t=m();return t?`disabled (${u(t)})`:"enabled"})(),hasUpdatePermissions:C,multipleInstallations:E,warnings:P,packageManager:R,ripgrepStatus:M}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{errorMessage as e}from"../errors.js";import{jsonParse as r}from"../slowOperations.js";export async function validateManifest(e){const{McpbManifestSchema:r}=await import("@anthropic-ai/mcpb"),
|
|
1
|
+
import{errorMessage as e}from"../errors.js";import{jsonParse as r}from"../slowOperations.js";export async function validateManifest(e){const{McpbManifestSchema:r}=await import("@anthropic-ai/mcpb"),t=r.safeParse(e);if(!t.success){const e=t.error.flatten(),r=[...Object.entries(e.fieldErrors).map(([e,r])=>`${e}: ${r?.join(", ")}`),...e.formErrors||[]].filter(Boolean).join("; ");throw new Error(`Invalid manifest: ${r}`)}return t.data}export async function parseAndValidateManifestFromText(t){let a;try{a=r(t)}catch(r){throw new Error(`Invalid JSON in manifest.json: ${e(r)}`)}return validateManifest(a)}export async function parseAndValidateManifestFromBytes(e){return parseAndValidateManifestFromText((new TextDecoder).decode(e))}export function generateExtensionId(e,r){const sanitize=e=>e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-_.]/g,"").replace(/-+/g,"-").replace(/^-+|-+$/g,""),t=e.author.name,a=e.name,n=sanitize(t),o=sanitize(a);return r?`${r}.${n}.${o}`:`${n}.${o}`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAbsolute as e,normalize as t}from"path";import{logForDebugging as r}from"../debug.js";import{isENOENT as o}from"../errors.js";import{getFsImplementation as n}from"../fsOperations.js";import{containsPathTraversal as
|
|
1
|
+
import{isAbsolute as e,normalize as t}from"path";import{logForDebugging as r}from"../debug.js";import{isENOENT as o}from"../errors.js";import{getFsImplementation as n}from"../fsOperations.js";import{containsPathTraversal as i}from"../path.js";const a=536870912,s=1073741824,l=1e5,f=50;export function isPathSafe(r){if(i(r))return!1;const o=t(r);return!e(o)}export function validateZipFile(e,t){let r;t.fileCount++,t.fileCount>l&&(r=`Archive contains too many files: ${t.fileCount} (max: ${l})`),isPathSafe(e.name)||(r=`Unsafe file path detected: "${e.name}". Path traversal or absolute paths are not allowed.`);const o=e.originalSize||0;o>a&&(r=`File "${e.name}" is too large: ${Math.round(o/1024/1024)}MB (max: ${Math.round(a/1024/1024)}MB)`),t.totalUncompressedSize+=o,t.totalUncompressedSize>s&&(r=`Archive total size is too large: ${Math.round(t.totalUncompressedSize/1024/1024)}MB (max: ${Math.round(s/1024/1024)}MB)`);const n=t.totalUncompressedSize/t.compressedSize;return n>f&&(r=`Suspicious compression ratio detected: ${n.toFixed(1)}:1 (max: ${f}:1). This may be a zip bomb.`),r?{isValid:!1,error:r}:{isValid:!0}}export async function unzipFile(e){const{unzipSync:t}=await import("fflate"),o={fileCount:0,totalUncompressedSize:0,compressedSize:e.length,errors:[]},n=t(new Uint8Array(e),{filter:e=>{const t=validateZipFile(e,o);if(!t.isValid)throw new Error(t.error);return!0}});return r(`Zip extraction completed: ${o.fileCount} files, ${Math.round(o.totalUncompressedSize/1024)}KB uncompressed`),n}export function parseZipModes(e){const t=Buffer.from(e.buffer,e.byteOffset,e.byteLength),r={},o=Math.max(0,t.length-22-65535);let n=-1;for(let e=t.length-22;e>=o;e--)if(101010256===t.readUInt32LE(e)){n=e;break}if(n<0)return r;const i=t.readUInt16LE(n+10);let a=t.readUInt32LE(n+16);for(let e=0;e<i&&!(a+46>t.length||33639248!==t.readUInt32LE(a));e++){const e=t.readUInt16LE(a+4),o=t.readUInt16LE(a+28),n=t.readUInt16LE(a+30),i=t.readUInt16LE(a+32),s=t.readUInt32LE(a+38),l=t.toString("utf8",a+46,a+46+o);if(e>>8==3){const e=s>>>16&65535;e&&(r[l]=e)}a+=46+o+n+i}return r}export async function readAndUnzipFile(e){const t=n();try{const r=await t.readFileBytes(e);return await unzipFile(r)}catch(e){if(o(e))throw e;const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to read or unzip file: ${t}`)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lastGrapheme as t}from"./intl.js";let
|
|
1
|
+
import{lastGrapheme as t}from"./intl.js";let n="",r=!1,e=null;export function startCapturingEarlyInput(){if(process.stdin.isTTY&&!r&&!process.argv.includes("-p")&&!process.argv.includes("--print")){r=!0,n="";try{process.stdin.setEncoding("utf8"),process.stdin.setRawMode(!0),process.stdin.ref(),e=()=>{let t=process.stdin.read();for(;null!==t;)"string"==typeof t&&processChunk(t),t=process.stdin.read()},process.stdin.on("readable",e)}catch{r=!1}}}function processChunk(r){let e=0;for(;e<r.length;){const s=r[e],o=s.charCodeAt(0);if(3===o)return stopCapturingEarlyInput(),void process.exit(130);if(4===o)return void stopCapturingEarlyInput();if(127!==o&&8!==o)if(27!==o)o<32&&9!==o&&10!==o&&13!==o?e++:13!==o?(n+=s,e++):(n+="\n",e++);else{for(e++;e<r.length&&!(r.charCodeAt(e)>=64&&r.charCodeAt(e)<=126);)e++;e<r.length&&e++}else{if(n.length>0){const r=t(n);n=n.slice(0,-(r.length||1))}e++}}}export function stopCapturingEarlyInput(){r&&(r=!1,e&&(process.stdin.removeListener("readable",e),e=null))}export function consumeEarlyInput(){stopCapturingEarlyInput();const t=n.trim();return n="",t}export function hasEarlyInput(){return n.trim().length>0}export function seedEarlyInput(t){n=t}export function isCapturingEarlyInput(){return r}
|
package/dist/src/utils/editor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as
|
|
1
|
+
import{spawn as r,spawnSync as e}from"child_process";import t from"lodash-es/memoize.js";import{basename as o}from"path";import n from"../ink/instances.js";import{logForDebugging as i}from"./debug.js";import{whichSync as s}from"./which.js";const c=["code","cursor","windsurf","codium","subl","atom","gedit","notepad++","notepad"],l=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,p=new Set(["code","cursor","windsurf","codium"]);export function classifyGuiEditor(r){const e=o(r.split(" ")[0]??"");return c.find(r=>e.includes(r))}export function openFileInExternalEditor(t,s){const c=getExternalEditor();if(!c)return!1;const d=c.split(" "),f=d[0]??c,a=d.slice(1),m=classifyGuiEditor(c);if(m){const e=function(r,e,t){return t?p.has(r)?["-g",`${e}:${t}`]:"subl"===r?[`${e}:${t}`]:[e]:[e]}(m,t,s),o={detached:!0,stdio:"ignore"};let n;if("win32"===process.platform){const t=e.map(r=>`"${r}"`).join(" ");n=r(`${c} ${t}`,{...o,shell:!0})}else n=r(f,[...a,...e],o);return n.on("error",r=>i(`editor spawn failed: ${r}`,{level:"error"})),n.unref(),!0}const u=n.get(process.stdout);if(!u)return!1;const $=s&&l.test(o(f));u.enterAlternateScreen();try{const r={stdio:"inherit"};let o;if("win32"===process.platform){o=e(`${c} ${$?`+${s} `:""}"${t}"`,{...r,shell:!0})}else{const n=[...a,...$?[`+${s}`,t]:[t]];o=e(f,n,r)}return!o.error||(i(`editor spawn failed: ${o.error}`,{level:"error"}),!1)}finally{u.exitAlternateScreen()}}export const getExternalEditor=t(()=>{if(process.env.VISUAL?.trim())return process.env.VISUAL.trim();if(process.env.EDITOR?.trim())return process.env.EDITOR.trim();if("win32"===process.platform)return"start /wait notepad";return["code","vi","nano"].find(r=>function(r){return!!s(r)}(r))});
|
package/dist/src/utils/effort.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isUltrathinkEnabled as e}from"./thinking.js";import{getInitialSettings as
|
|
1
|
+
import{isUltrathinkEnabled as e}from"./thinking.js";import{getInitialSettings as o}from"./settings/settings.js";import{isProSubscriber as t,isMaxSubscriber as r,isTeamSubscriber as n}from"./auth.js";import{getFeatureValue_CACHED_MAY_BE_STALE as i}from"../services/analytics/growthbook.js";import{getAPIProvider as s}from"./model/providers.js";import{get3PModelCapabilityOverride as f}from"./model/modelSupportOverrides.js";import{isEnvTruthy as u}from"./envUtils.js";export const EFFORT_LEVELS=["low","medium","high","max"];export function modelSupportsEffort(e){const o=e.toLowerCase();if(u(process.env.CONTEXT_CODE_ALWAYS_ENABLE_EFFORT)||u(process.env.CLAUDE_CODE_ALWAYS_ENABLE_EFFORT))return!0;const t=f(e,"effort");return void 0!==t?t:!!(o.includes("opus-4-7")||o.includes("opus-4-6")||o.includes("sonnet-4-6"))||!(o.includes("haiku")||o.includes("sonnet")||o.includes("opus"))&&"firstParty"===s()}export function modelSupportsMaxEffort(e){const o=f(e,"max_effort");return void 0!==o?o:!(!e.toLowerCase().includes("opus-4-7")&&!e.toLowerCase().includes("opus-4-6"))||!("ant"!==process.env.USER_TYPE||!resolveAntModel(e))}export function isEffortLevel(e){return EFFORT_LEVELS.includes(e)}export function parseEffortValue(e){if(null==e||""===e)return;if("number"==typeof e&&isValidNumericEffort(e))return e;const o=String(e).toLowerCase();if(isEffortLevel(o))return o;const t=parseInt(o,10);return!isNaN(t)&&isValidNumericEffort(t)?t:void 0}export function toPersistableEffort(e){return"low"===e||"medium"===e||"high"===e||"max"===e&&"ant"===process.env.USER_TYPE?e:void 0}export function getInitialEffortSetting(){return toPersistableEffort(o().effortLevel)}export function resolvePickerEffortPersistence(e,o,t,r){return void 0!==t||r||e!==o?e:void 0}export function getEffortEnvOverride(){const e=process.env.CONTEXT_CODE_EFFORT_LEVEL??process.env.CLAUDE_CODE_EFFORT_LEVEL;return"unset"===e?.toLowerCase()||"auto"===e?.toLowerCase()?null:parseEffortValue(e)}export function resolveAppliedEffort(e,o){const t=getEffortEnvOverride();if(null===t)return;const r=t??o??getDefaultEffortForModel(e);return"max"!==r||modelSupportsMaxEffort(e)?r:"high"}export const levelTranslations={low:"bajo",medium:"medio",high:"alto",max:"máximo"};export function getDisplayedEffortLevel(e,o){return convertEffortValueToLevel(resolveAppliedEffort(e,o)??"high")}export function getEffortSuffix(e,o){if(void 0===o)return"";const t=resolveAppliedEffort(e,o);if(void 0===t)return"";const r=convertEffortValueToLevel(t);return` con esfuerzo ${levelTranslations[r]??r}`}export function isValidNumericEffort(e){return Number.isInteger(e)}export function convertEffortValueToLevel(e){return"string"==typeof e?isEffortLevel(e)?e:"high":"ant"===process.env.USER_TYPE&&"number"==typeof e?e<=50?"low":e<=85?"medium":e<=100?"high":"max":"high"}export function getEffortLevelDescription(e){switch(e){case"low":return"Implementación rápida y directa con mínima sobrecarga";case"medium":return"Equilibrio entre implementación estándar y pruebas";case"high":return"Implementación exhaustiva con pruebas y documentación extensas";case"max":return"Capacidad máxima con el razonamiento más profundo (solo Opus 4.6)"}}export function getEffortValueDescription(e){return"ant"===process.env.USER_TYPE&&"number"==typeof e?`[SOLO-ANT] Valor de esfuerzo numérico de ${e}`:"string"==typeof e?getEffortLevelDescription(e):"Enfoque equilibrado con implementación y pruebas estándar"}const a={enabled:!0,dialogTitle:"Recomendamos el esfuerzo medio para Opus",dialogDescription:"El esfuerzo determina cuánto tiempo piensa Context antes de completar tu tarea. Recomendamos el esfuerzo medio para la mayoría de las tareas para equilibrar velocidad e inteligencia y maximizar los límites de frecuencia. Usa ultrathink para activar el esfuerzo alto cuando sea necesario."};export function getOpusDefaultEffortConfig(){const e=i("tengu_grey_step2",a);return{...a,...e}}export function getDefaultEffortForModel(o){if("ant"===process.env.USER_TYPE){const e=getAntModelOverrideConfig();if(void 0!==e?.defaultModel&&o.toLowerCase()===e.defaultModel.toLowerCase()&&e?.defaultModelEffortLevel)return e.defaultModelEffortLevel;const t=resolveAntModel(o);if(t){if(t.defaultEffortLevel)return t.defaultEffortLevel;if(void 0!==t.defaultEffortValue)return t.defaultEffortValue}return}if(o.toLowerCase().includes("opus-4-7")||o.toLowerCase().includes("opus-4-6")){if(t())return"medium";if(getOpusDefaultEffortConfig().enabled&&(r()||n()))return"medium"}if(e()&&modelSupportsEffort(o))return"medium"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEnvTruthy as e}from"./envUtils.js";export function hasEmbeddedSearchTools(){if(!e(process.env.EMBEDDED_SEARCH_TOOLS))return!1;const
|
|
1
|
+
import{isEnvTruthy as e}from"./envUtils.js";export function hasEmbeddedSearchTools(){if(!e(process.env.EMBEDDED_SEARCH_TOOLS))return!1;const r=process.env.CLAUDE_CODE_ENTRYPOINT;return"sdk-ts"!==r&&"sdk-py"!==r&&"sdk-cli"!==r&&"local-agent"!==r}export function embeddedSearchToolsBinaryPath(){return process.execPath}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{feature as e}from"
|
|
1
|
+
import{feature as e}from"../recovery/bunBundleShim.js";import{stat as r}from"fs/promises";import t from"lodash-es/memoize.js";import{env as n,JETBRAINS_IDES as i}from"./env.js";import{isEnvTruthy as o}from"./envUtils.js";import{execFileNoThrow as s}from"./execFileNoThrow.js";import{getAncestorCommandsAsync as c}from"./genericProcessUtils.js";const a=t(async()=>{if("linux"!==process.platform)return!1;const{code:e}=await s("test",["-f","/.dockerenv"]);return 0===e});let m,l=null;if("linux"===process.platform){r(`/lib/libc.musl-${"x64"===process.arch?"x86_64":"aarch64"}.so.1`).then(()=>{l=!0},()=>{l=!1})}async function detectJetBrainsIDEFromParentProcessAsync(){if(void 0!==m)return m;if("darwin"===process.platform)return m=null,null;try{const e=await c(process.pid,10);for(const r of e){const e=r.toLowerCase();for(const r of i)if(e.includes(r))return m=r,r}}catch{}return m=null,null}export async function getTerminalWithJetBrainsDetectionAsync(){if("JetBrains-JediTerm"===process.env.TERMINAL_EMULATOR&&"darwin"!==n.platform){return await detectJetBrainsIDEFromParentProcessAsync()||"pycharm"}return n.terminal}export function getTerminalWithJetBrainsDetection(){return"JetBrains-JediTerm"===process.env.TERMINAL_EMULATOR&&"darwin"!==n.platform?void 0!==m&&m||"pycharm":n.terminal}export async function initJetBrainsDetection(){"JetBrains-JediTerm"===process.env.TERMINAL_EMULATOR&&await detectJetBrainsIDEFromParentProcessAsync()}export const envDynamic={...n,terminal:getTerminalWithJetBrainsDetection(),getIsDocker:a,getIsBubblewrapSandbox:function(){return"linux"===process.platform&&(o(process.env.CONTEXT_CODE_BUBBLEWRAP)||o(process.env.CLAUDE_CODE_BUBBLEWRAP))},isMuslEnvironment:function(){return!!e("IS_LIBC_MUSL")||!e("IS_LIBC_GLIBC")&&("linux"===process.platform&&(l??!1))},getTerminalWithJetBrainsDetectionAsync,initJetBrainsDetection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"module";const n=e(import.meta.url);import r from"lodash-es/memoize.js";import{homedir as
|
|
1
|
+
import{createRequire as e}from"module";const n=e(import.meta.url);import r from"lodash-es/memoize.js";import{homedir as t}from"os";import{join as o}from"path";export const getContextConfigHomeDir=r(()=>(process.env.CONTEXT_CONFIG_DIR??o(t(),".context")).normalize("NFC"),()=>`${process.env.CONTEXT_CONFIG_DIR??""}`);export const getClaudeConfigHomeDir=getContextConfigHomeDir;export function getTeamsDir(){return o(getContextConfigHomeDir(),"teams")}export function hasNodeOption(e){const n=process.env.NODE_OPTIONS;return!!n&&n.split(/\s+/).includes(e)}export function isEnvTruthy(e){if(!e)return!1;if("boolean"==typeof e)return e;const n=e.toLowerCase().trim();return["1","true","yes","on"].includes(n)}export function isEnvDefinedFalsy(e){if(void 0===e)return!1;if("boolean"==typeof e)return!e;if(!e)return!1;const n=e.toLowerCase().trim();return["0","false","no","off"].includes(n)}export function isBareMode(){return isEnvTruthy(process.env.CONTEXT_CODE_SIMPLE)||isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)||process.argv.includes("--bare")}export function parseEnvVars(e){const n={};if(e)for(const r of e){const[e,...t]=r.split("=");if(!e||0===t.length)throw new Error(`Invalid environment variable format: ${r}, environment variables should be added as: -e KEY1=value1 -e KEY2=value2`);n[e]=t.join("=")}return n}export function getAWSRegion(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||"us-east-1"}export function getDefaultVertexRegion(){return process.env.CLOUD_ML_REGION||"us-east5"}export function shouldMaintainProjectWorkingDir(){return isEnvTruthy(process.env.CONTEXT_BASH_MAINTAIN_PROJECT_WORKING_DIR)||isEnvTruthy(process.env.CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR)}export function readForkEnvVar(e,n){return process.env[e]??process.env[n]}export function isForkEnvVarTruthy(e,n){return isEnvTruthy(process.env[e])||isEnvTruthy(process.env[n])}export function isBackgroundTasksDisabled(){return isForkEnvVarTruthy("CONTEXT_CODE_DISABLE_BACKGROUND_TASKS","CLAUDE_CODE_DISABLE_BACKGROUND_TASKS")}export function isCoordinatorMode(){return isForkEnvVarTruthy("CONTEXT_CODE_COORDINATOR_MODE","CLAUDE_CODE_COORDINATOR_MODE")}export function isRunningOnHomespace(){return"ant"===process.env.USER_TYPE&&isEnvTruthy(process.env.COO_RUNNING_ON_HOMESPACE)}export function isInProtectedNamespace(){return"ant"===process.env.USER_TYPE&&n("./protectedNamespace.js").checkProtectedNamespace()}const s=[["claude-haiku-4-5","VERTEX_REGION_CLAUDE_HAIKU_4_5"],["claude-3-5-haiku","VERTEX_REGION_CLAUDE_3_5_HAIKU"],["claude-3-5-sonnet","VERTEX_REGION_CLAUDE_3_5_SONNET"],["claude-3-7-sonnet","VERTEX_REGION_CLAUDE_3_7_SONNET"],["claude-opus-4-1","VERTEX_REGION_CLAUDE_4_1_OPUS"],["claude-opus-4","VERTEX_REGION_CLAUDE_4_0_OPUS"],["claude-sonnet-4-6","VERTEX_REGION_CLAUDE_4_6_SONNET"],["claude-sonnet-4-5","VERTEX_REGION_CLAUDE_4_5_SONNET"],["claude-sonnet-4","VERTEX_REGION_CLAUDE_4_0_SONNET"]];export function getVertexRegionForModel(e){if(e){const n=s.find(([n])=>e.startsWith(n));if(n)return process.env[n[1]]||getDefaultVertexRegion()}return getDefaultVertexRegion()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=this&&this.__addDisposableResource||function(r,e,o){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var s
|
|
1
|
+
var r=this&&this.__addDisposableResource||function(r,e,o){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var t,s;if(o){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");t=e[Symbol.asyncDispose]}if(void 0===t){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");t=e[Symbol.dispose],o&&(s=t)}if("function"!=typeof t)throw new TypeError("Object not disposable.");s&&(t=function(){try{s.call(this)}catch(r){return Promise.reject(r)}}),r.stack.push({value:e,dispose:t,async:o})}else o&&r.stack.push({async:!0});return e},e=this&&this.__disposeResources||function(r){return function(e){function fail(o){e.error=e.hasError?new r(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var o,t=0;return function next(){for(;o=e.stack.pop();)try{if(!o.async&&1===t)return t=0,e.stack.push(o),Promise.resolve().then(next);if(o.dispose){var r=o.dispose.call(o.value);if(o.async)return t|=2,Promise.resolve(r).then(next,function(r){return fail(r),next()})}else t|=1}catch(r){fail(r)}if(1===t)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(r,e,o){var t=new Error(o);return t.name="SuppressedError",t.error=r,t.suppressed=e,t});import{execaSync as o}from"execa";import{getCwd as t}from"./cwd.js";import{slowLogging as s}from"./slowOperations.js";const n=1e3,i=60;export function execSyncWithDefaults_DEPRECATED(c,a,p=10*i*n){const u={stack:[],error:void 0,hasError:!1};try{let e;e=void 0===a?{}:a instanceof AbortSignal?{abortSignal:a,timeout:p}:a;const{abortSignal:f,timeout:l=10*i*n,input:d,stdio:h=["ignore","pipe","pipe"]}=e;f?.throwIfAborted();r(u,s`exec: ${c.slice(0,200)}`,!1);try{const r=o(c,{env:process.env,maxBuffer:1e6,timeout:l,cwd:t(),stdio:h,shell:!0,reject:!1,input:d});return r.stdout&&r.stdout.trim()||null}catch{return null}}catch(r){u.error=r,u.hasError=!0}finally{e(u)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=this&&this.__addDisposableResource||function(r,e,o){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var s,n;if(o){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],o&&(n=s)}if("function"!=typeof s)throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(r){return Promise.reject(r)}}),r.stack.push({value:e,dispose:s,async:o})}else o&&r.stack.push({async:!0});return e},e=this&&this.__disposeResources||function(r){return function(e){function fail(o){e.error=e.hasError?new r(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var o,s=0;return function next(){for(;o=e.stack.pop();)try{if(!o.async&&1===s)return s=0,e.stack.push(o),Promise.resolve().then(next);if(o.dispose){var r=o.dispose.call(o.value);if(o.async)return s|=2,Promise.resolve(r).then(next,function(r){return fail(r),next()})}else s|=1}catch(r){fail(r)}if(1===s)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(r,e,o){var s=new Error(o);return s.name="SuppressedError",s.error=r,s.suppressed=e,s});import{execSync as o}from"child_process";import{slowLogging as s}from"./slowOperations.js";export function execSync_DEPRECATED(n,t){const i={stack:[],error:void 0,hasError:!1};try{
|
|
1
|
+
var r=this&&this.__addDisposableResource||function(r,e,o){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var s,n;if(o){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],o&&(n=s)}if("function"!=typeof s)throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(r){return Promise.reject(r)}}),r.stack.push({value:e,dispose:s,async:o})}else o&&r.stack.push({async:!0});return e},e=this&&this.__disposeResources||function(r){return function(e){function fail(o){e.error=e.hasError?new r(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var o,s=0;return function next(){for(;o=e.stack.pop();)try{if(!o.async&&1===s)return s=0,e.stack.push(o),Promise.resolve().then(next);if(o.dispose){var r=o.dispose.call(o.value);if(o.async)return s|=2,Promise.resolve(r).then(next,function(r){return fail(r),next()})}else s|=1}catch(r){fail(r)}if(1===s)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(r,e,o){var s=new Error(o);return s.name="SuppressedError",s.error=r,s.suppressed=e,s});import{execSync as o}from"child_process";import{slowLogging as s}from"./slowOperations.js";export function execSync_DEPRECATED(n,t){const i={stack:[],error:void 0,hasError:!1};try{r(i,s`execSync: ${n.slice(0,100)}`,!1);return o(n,t)}catch(r){i.error=r,i.hasError=!0}finally{e(i)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useRef as n}from"react";import r from"strip-ansi";import{Messages as s}from"../components/Messages.js";import{KeybindingProvider as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useRef as n}from"react";import r from"strip-ansi";import{Messages as s}from"../components/Messages.js";import{KeybindingProvider as t}from"../keybindings/KeybindingContext.js";import{loadKeybindingsSyncWithWarnings as o}from"../keybindings/loadUserBindings.js";import{AppStateProvider as i}from"../state/AppState.js";import{renderToAnsiString as a}from"./staticRender.js";function StaticKeybindingProvider({children:r}){const{bindings:s}=o(),i=n(null),a=n(new Map),d=n(new Set).current;return e(t,{bindings:s,pendingChordRef:i,pendingChord:null,setPendingChord:()=>{},activeContexts:d,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:a,children:r})}function normalizedUpperBound(e){if(!("message"in e))return 1;const n=e.message.content;return Array.isArray(n)?n.length:1}export async function streamRenderedMessages(n,t,o,{columns:d,verbose:c=!1,chunkSize:m=40,onProgress:l}={}){const renderChunk=r=>a(e(i,{children:e(StaticKeybindingProvider,{children:e(s,{messages:n,tools:t,commands:[],verbose:c,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:"export",screen:"prompt",streamingToolUses:[],showAllInTranscript:!0,isLoading:!1,renderRange:r})})}),d);let g=m;for(const e of n)g+=normalizedUpperBound(e);for(let e=0;e<g;e+=m){const n=await renderChunk([e,e+m]);if(""===r(n).trim())break;await o(n),l?.(e+m)}}export async function renderMessagesToPlainText(e,n=[],s){const t=[];return await streamRenderedMessages(e,n,e=>{t.push(r(e))},{columns:s}),t.join("")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isClaudeAISubscriber as e}from"./auth.js";import{has1mContext as
|
|
1
|
+
import{isClaudeAISubscriber as e}from"./auth.js";import{has1mContext as r}from"./context.js";export function isBilledAsExtraUsage(t,n,o){if(!e())return!1;if(n)return!0;if(null===t||!r(t))return!1;const s=t.toLowerCase().replace(/\[1m\]$/,"").trim(),u="opus"===s||s.includes("opus-4-7")||s.includes("opus-4-6"),i="sonnet"===s||s.includes("sonnet-4-6");return(!u||!o)&&(u||i)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import{getOauthConfig as t,OAUTH_BETA_HEADER as
|
|
1
|
+
import e from"axios";import{getOauthConfig as t,OAUTH_BETA_HEADER as o}from"../constants/oauth.js";import{getFeatureValue_CACHED_MAY_BE_STALE as a}from"../services/analytics/growthbook.js";import{getIsNonInteractiveSession as s,getKairosActive as n,preferThirdPartyAuthentication as r}from"../bootstrap/state.js";import{logEvent as i}from"../services/analytics/index.js";import{getAnthropicApiKey as d,getClaudeAIOAuthTokens as l,handleOAuth401Error as u,hasProfileScope as c}from"./auth.js";import{isInBundledMode as b}from"./bundledMode.js";import{getGlobalConfig as f,saveGlobalConfig as p}from"./config.js";import{logForDebugging as g}from"./debug.js";import{isEnvTruthy as _}from"./envUtils.js";import{getDefaultMainLoopModelSetting as m,isOpus1mMergeEnabled as F,parseUserSpecifiedModel as v}from"./model/model.js";import{getAPIProvider as M}from"./model/providers.js";import{isEssentialTrafficOnly as E}from"./privacyLevel.js";import{getInitialSettings as w,getSettingsForSource as x,updateSettingsForSource as h}from"./settings/settings.js";import{createSignal as y}from"./signal.js";export function isFastModeEnabled(){return!_(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}export function isFastModeAvailable(){return!!isFastModeEnabled()&&null===getFastModeUnavailableReason()}export function getFastModeUnavailableReason(){if(!isFastModeEnabled())return"Fast mode is not available";const e=a("tengu_penguins_off",null);if(null!==e)return g(`Fast mode unavailable: ${e}`),e;if(!b()&&a("tengu_marble_sandcastle",!1))return"Fast mode requires the native binary · Install from: https://claude.com/product/claude-code";if(s()&&r()&&!n()){const e=x("flagSettings")?.fastMode;if(!e){const e="Fast mode is not available in the Agent SDK";return g(`Fast mode unavailable: ${e}`),e}}if("firstParty"!==M()){const e="Fast mode is not available on Bedrock, Vertex, or Foundry";return g(`Fast mode unavailable: ${e}`),e}if("disabled"===R.status){if(("network_error"===R.reason||"unknown"===R.reason)&&(_(process.env.CONTEXT_CODE_SKIP_FAST_MODE_NETWORK_ERRORS)||_(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS)))return null;const e=null!==l()?"oauth":"api-key",t=function(e,t){switch(e){case"free":return"oauth"===t?"Fast mode requires a paid subscription":"Fast mode unavailable during evaluation. Please purchase credits.";case"preference":return"Fast mode has been disabled by your organization";case"extra_usage_disabled":return"Fast mode requires extra usage billing · /extra-usage to enable";case"network_error":return"Fast mode unavailable due to network connectivity issues";case"unknown":return"Fast mode is currently unavailable"}}(R.reason,e);return g(`Fast mode unavailable: ${t}`),t}return null}export const FAST_MODE_MODEL_DISPLAY="Opus 4.6";export function getFastModeModel(){return"opus"+(F()?"[1m]":"")}export function getInitialFastModeSetting(e){if(!isFastModeEnabled())return!1;if(!isFastModeAvailable())return!1;if(!isFastModeSupportedByModel(e))return!1;const t=w();return!t.fastModePerSessionOptIn&&!0===t.fastMode}export function isFastModeSupportedByModel(e){if(!isFastModeEnabled())return!1;const t=e??m(),o=v(t);return o.toLowerCase().includes("opus-4-7")||o.toLowerCase().includes("opus-4-6")}let S={status:"active"},O=!1;const k=y(),A=y();export const onCooldownTriggered=k.subscribe;export const onCooldownExpired=A.subscribe;export function getFastModeRuntimeState(){return"cooldown"===S.status&&Date.now()>=S.resetAt&&(isFastModeEnabled()&&!O&&(g("Fast mode cooldown expired, re-enabling fast mode"),O=!0,A.emit()),S={status:"active"}),S}export function triggerFastModeCooldown(e,t){if(!isFastModeEnabled())return;S={status:"cooldown",resetAt:e,reason:t},O=!1;const o=e-Date.now();g(`Fast mode cooldown triggered (${t}), duration ${Math.round(o/1e3)}s`),i("tengu_fast_mode_fallback_triggered",{cooldown_duration_ms:o,cooldown_reason:t}),k.emit(e,t)}export function clearFastModeCooldown(){S={status:"active"}}export function handleFastModeRejectedByAPI(){"disabled"!==R.status&&(R={status:"disabled",reason:"preference"},h("userSettings",{fastMode:void 0}),p(e=>({...e,penguinModeOrgEnabled:!1})),T.emit(!1))}const j=y();export const onFastModeOverageRejection=j.subscribe;export function handleFastModeOverageRejection(e){const t=function(e){switch(e){case"out_of_credits":return"Fast mode disabled · extra usage credits exhausted";case"org_level_disabled":case"org_service_level_disabled":return"Fast mode disabled · extra usage disabled by your organization";case"org_level_disabled_until":return"Fast mode disabled · extra usage spending cap reached";case"member_level_disabled":return"Fast mode disabled · extra usage disabled for your account";case"seat_tier_level_disabled":case"seat_tier_zero_credit_limit":case"member_zero_credit_limit":return"Fast mode disabled · extra usage not available for your plan";case"overage_not_provisioned":case"no_limits_configured":return"Fast mode requires extra usage billing · /extra-usage to enable";default:return"Fast mode disabled · extra usage not available"}}(e);g(`Fast mode overage rejection: ${e??"unknown"} — ${t}`),i("tengu_fast_mode_overage_rejected",{overage_disabled_reason:e??"unknown"}),function(e){return"org_level_disabled_until"===e||"out_of_credits"===e}(e)||(h("userSettings",{fastMode:void 0}),p(e=>({...e,penguinModeOrgEnabled:!1}))),j.emit(t)}export function isFastModeCooldown(){return"cooldown"===getFastModeRuntimeState().status}export function getFastModeState(e,t){const o=isFastModeEnabled()&&isFastModeAvailable()&&!!t&&isFastModeSupportedByModel(e);return o&&isFastModeCooldown()?"cooldown":o?"on":"off"}let R={status:"pending"};const T=y();export const onOrgFastModeChanged=T.subscribe;let C=0,D=null;export function resolveFastModeStatusFromCache(){if(!isFastModeEnabled())return;if("pending"!==R.status)return;const e="ant"===process.env.USER_TYPE,t=!0===f().penguinModeOrgEnabled;R=e||t?{status:"enabled"}:{status:"disabled",reason:"unknown"}}export async function prefetchFastModeStatus(){if(E())return;if(!isFastModeEnabled())return;if(D)return g("Fast mode prefetch in progress, returning in-flight promise"),D;const a=d();if(!(l()?.accessToken&&c())&&!a){const e="ant"===process.env.USER_TYPE,t=!0===f().penguinModeOrgEnabled;return void(R=e||t?{status:"enabled"}:{status:"disabled",reason:"preference"})}const s=Date.now();if(s-C<3e4)return void g("Skipping fast mode prefetch, fetched recently");C=s;const fetchWithCurrentAuth=async()=>{const s=l(),n=s?.accessToken&&c()?{accessToken:s.accessToken}:a?{apiKey:a}:null;if(!n)throw new Error("No auth available");return async function(a){const s=`${t().BASE_API_URL}/api/claude_code_penguin_mode`,n="accessToken"in a?{Authorization:`Bearer ${a.accessToken}`,"anthropic-beta":o}:{"x-api-key":a.apiKey};return(await e.get(s,{headers:n})).data}(n)};return D=async function(){try{let t;try{t=await fetchWithCurrentAuth()}catch(o){if(!(e.isAxiosError(o)&&(401===o.response?.status||403===o.response?.status&&"string"==typeof o.response?.data&&o.response.data.includes("OAuth token has been revoked"))))throw o;{const e=l()?.accessToken;if(!e)throw o;await u(e),t=await fetchWithCurrentAuth()}}const o="pending"!==R.status?"enabled"===R.status:f().penguinModeOrgEnabled;R=t.enabled?{status:"enabled"}:{status:"disabled",reason:t.disabled_reason??"preference"},o!==t.enabled&&(t.enabled||h("userSettings",{fastMode:void 0}),p(e=>({...e,penguinModeOrgEnabled:t.enabled})),T.emit(t.enabled)),g("Org fast mode: "+(t.enabled?"enabled":`disabled (${t.disabled_reason??"preference"})`))}catch(e){const t="ant"===process.env.USER_TYPE,o=!0===f().penguinModeOrgEnabled;R=t||o?{status:"enabled"}:{status:"disabled",reason:"network_error"},g(`Failed to fetch org fast mode status, defaulting to ${"enabled"===R.status?"enabled (cached)":"disabled (network_error)"}: ${e}`,{level:"error"}),i("tengu_org_penguin_mode_fetch_failed",{})}finally{D=null}}(),D}
|