@iaforged/context-code 2.1.5 → 2.1.7
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/commands/add-dir/add-dir.js +1 -1
- package/dist/src/commands/add-dir/validation.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 +91 -1
- 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/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Align as e,BoxSizing as t,Dimension as i,Direction as s,Display as n,Edge as a,Errata as l,ExperimentalFeature as r,FlexDirection as o,Gutter as u,Justify as h,MeasureMode as c,Overflow as f,PositionType as d,Unit as y,Wrap as g}from"./enums.js";export{e as Align,t as BoxSizing,i as Dimension,s as Direction,n as Display,a as Edge,l as Errata,r as ExperimentalFeature,o as FlexDirection,u as Gutter,h as Justify,c as MeasureMode,f as Overflow,d as PositionType,y as Unit,g as Wrap};const m={unit:y.Undefined,value:NaN},_={unit:y.Auto,value:NaN};function pointValue(e){return{unit:y.Point,value:e}}function percentValue(e){return{unit:y.Percent,value:e}}function resolveValue(e,t){switch(e.unit){case y.Point:return e.value;case y.Percent:return isNaN(t)?NaN:e.value*t/100;default:return NaN}}function isDefined(e){return!isNaN(e)}function sameFloat(e,t){return e===t||e!=e&&t!=t}function defaultStyle(){return{direction:s.Inherit,flexDirection:o.Column,justifyContent:h.FlexStart,alignItems:e.Stretch,alignSelf:e.Auto,alignContent:e.FlexStart,flexWrap:g.NoWrap,overflow:f.Visible,display:n.Flex,positionType:d.Relative,flexGrow:0,flexShrink:0,flexBasis:_,margin:new Array(9).fill(m),padding:new Array(9).fill(m),border:new Array(9).fill(m),position:new Array(9).fill(m),gap:new Array(3).fill(m),width:_,height:_,minWidth:m,minHeight:m,maxWidth:m,maxHeight:m}}function resolveEdge(e,t,i,s=!1){let n=e[t];return n.unit===y.Undefined&&(n=0===t||2===t?e[a.Horizontal]:e[a.Vertical]),n.unit===y.Undefined&&(n=e[a.All]),n.unit===y.Undefined&&(0===t&&(n=e[a.Start]),2===t&&(n=e[a.End])),n.unit===y.Undefined?0:n.unit===y.Auto?s?NaN:0:resolveValue(n,i)}function resolveEdgeRaw(e,t){let i=e[t];return i.unit===y.Undefined&&(i=0===t||2===t?e[a.Horizontal]:e[a.Vertical]),i.unit===y.Undefined&&(i=e[a.All]),i.unit===y.Undefined&&(0===t&&(i=e[a.Start]),2===t&&(i=e[a.End])),i}function isMarginAuto(e,t){return resolveEdgeRaw(e,t).unit===y.Auto}function hasAnyAutoEdge(e){for(let t=0;t<9;t++)if(3===e[t].unit)return!0;return!1}function hasAnyDefinedEdge(e){for(let t=0;t<9;t++)if(0!==e[t].unit)return!0;return!1}function resolveEdges4Into(e,t,i){const s=e[6],n=e[7],a=e[8],l=e[4],r=e[5],o=isNaN(t)?NaN:t/100;let u=e[0];0===u.unit&&(u=s),0===u.unit&&(u=a),0===u.unit&&(u=l),i[0]=1===u.unit?u.value:2===u.unit?u.value*o:0,u=e[1],0===u.unit&&(u=n),0===u.unit&&(u=a),i[1]=1===u.unit?u.value:2===u.unit?u.value*o:0,u=e[2],0===u.unit&&(u=s),0===u.unit&&(u=a),0===u.unit&&(u=r),i[2]=1===u.unit?u.value:2===u.unit?u.value*o:0,u=e[3],0===u.unit&&(u=n),0===u.unit&&(u=a),i[3]=1===u.unit?u.value:2===u.unit?u.value*o:0}function isRow(e){return e===o.Row||e===o.RowReverse}function isReverse(e){return e===o.RowReverse||e===o.ColumnReverse}function leadingEdge(e){switch(e){case o.Row:return 0;case o.RowReverse:return 2;case o.Column:return 1;case o.ColumnReverse:return 3}}function trailingEdge(e){switch(e){case o.Row:return 2;case o.RowReverse:return 0;case o.Column:return 3;case o.ColumnReverse:return 1}}function createConfig(){const e={pointScaleFactor:1,errata:l.None,useWebDefaults:!1,free(){},isExperimentalFeatureEnabled:()=>!1,setExperimentalFeatureEnabled(){},setPointScaleFactor(t){e.pointScaleFactor=t},getErrata:()=>e.errata,setErrata(t){e.errata=t},setUseWebDefaults(t){e.useWebDefaults=t}};return e}export class Node{style;layout;parent;children;measureFunc;config;isDirty_;isReferenceBaseline_;_flexBasis=0;_mainSize=0;_crossSize=0;_lineIndex=0;_hasAutoMargin=!1;_hasPosition=!1;_hasPadding=!1;_hasBorder=!1;_hasMargin=!1;_lW=NaN;_lH=NaN;_lWM=0;_lHM=0;_lOW=NaN;_lOH=NaN;_lFW=!1;_lFH=!1;_lOutW=NaN;_lOutH=NaN;_hasL=!1;_mW=NaN;_mH=NaN;_mWM=0;_mHM=0;_mOW=NaN;_mOH=NaN;_mOutW=NaN;_mOutH=NaN;_hasM=!1;_fbBasis=NaN;_fbOwnerW=NaN;_fbOwnerH=NaN;_fbAvailMain=NaN;_fbAvailCross=NaN;_fbCrossMode=0;_fbGen=-1;_cIn=null;_cOut=null;_cGen=-1;_cN=0;_cWr=0;constructor(e){this.style=defaultStyle(),this.layout={left:0,top:0,width:0,height:0,border:[0,0,0,0],padding:[0,0,0,0],margin:[0,0,0,0]},this.parent=null,this.children=[],this.measureFunc=null,this.config=e??p,this.isDirty_=!0,this.isReferenceBaseline_=!1,M++}insertChild(e,t){e.parent=this,this.children.splice(t,0,e),this.markDirty()}removeChild(e){const t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=null,this.markDirty())}getChild(e){return this.children[e]}getChildCount(){return this.children.length}getParent(){return this.parent}free(){this.parent=null,this.children=[],this.measureFunc=null,this._cIn=null,this._cOut=null,M--}freeRecursive(){for(const e of this.children)e.freeRecursive();this.free()}reset(){this.style=defaultStyle(),this.children=[],this.parent=null,this.measureFunc=null,this.isDirty_=!0,this._hasAutoMargin=!1,this._hasPosition=!1,this._hasPadding=!1,this._hasBorder=!1,this._hasMargin=!1,this._hasL=!1,this._hasM=!1,this._cN=0,this._cWr=0,this._fbBasis=NaN}markDirty(){this.isDirty_=!0,this.parent&&!this.parent.isDirty_&&this.parent.markDirty()}isDirty(){return this.isDirty_}hasNewLayout(){return!0}markLayoutSeen(){}setMeasureFunc(e){this.measureFunc=e,this.markDirty()}unsetMeasureFunc(){this.measureFunc=null,this.markDirty()}getComputedLeft(){return this.layout.left}getComputedTop(){return this.layout.top}getComputedWidth(){return this.layout.width}getComputedHeight(){return this.layout.height}getComputedRight(){const e=this.parent;return e?e.layout.width-this.layout.left-this.layout.width:0}getComputedBottom(){const e=this.parent;return e?e.layout.height-this.layout.top-this.layout.height:0}getComputedLayout(){return{left:this.layout.left,top:this.layout.top,right:this.getComputedRight(),bottom:this.getComputedBottom(),width:this.layout.width,height:this.layout.height}}getComputedBorder(e){return this.layout.border[physicalEdge(e)]}getComputedPadding(e){return this.layout.padding[physicalEdge(e)]}getComputedMargin(e){return this.layout.margin[physicalEdge(e)]}setWidth(e){this.style.width=parseDimension(e),this.markDirty()}setWidthPercent(e){this.style.width=percentValue(e),this.markDirty()}setWidthAuto(){this.style.width=_,this.markDirty()}setHeight(e){this.style.height=parseDimension(e),this.markDirty()}setHeightPercent(e){this.style.height=percentValue(e),this.markDirty()}setHeightAuto(){this.style.height=_,this.markDirty()}setMinWidth(e){this.style.minWidth=parseDimension(e),this.markDirty()}setMinWidthPercent(e){this.style.minWidth=percentValue(e),this.markDirty()}setMinHeight(e){this.style.minHeight=parseDimension(e),this.markDirty()}setMinHeightPercent(e){this.style.minHeight=percentValue(e),this.markDirty()}setMaxWidth(e){this.style.maxWidth=parseDimension(e),this.markDirty()}setMaxWidthPercent(e){this.style.maxWidth=percentValue(e),this.markDirty()}setMaxHeight(e){this.style.maxHeight=parseDimension(e),this.markDirty()}setMaxHeightPercent(e){this.style.maxHeight=percentValue(e),this.markDirty()}setFlexDirection(e){this.style.flexDirection=e,this.markDirty()}setFlexGrow(e){this.style.flexGrow=e??0,this.markDirty()}setFlexShrink(e){this.style.flexShrink=e??0,this.markDirty()}setFlex(e){void 0===e||isNaN(e)?(this.style.flexGrow=0,this.style.flexShrink=0):e>0?(this.style.flexGrow=e,this.style.flexShrink=1,this.style.flexBasis=pointValue(0)):e<0?(this.style.flexGrow=0,this.style.flexShrink=-e):(this.style.flexGrow=0,this.style.flexShrink=0),this.markDirty()}setFlexBasis(e){this.style.flexBasis=parseDimension(e),this.markDirty()}setFlexBasisPercent(e){this.style.flexBasis=percentValue(e),this.markDirty()}setFlexBasisAuto(){this.style.flexBasis=_,this.markDirty()}setFlexWrap(e){this.style.flexWrap=e,this.markDirty()}setAlignItems(e){this.style.alignItems=e,this.markDirty()}setAlignSelf(e){this.style.alignSelf=e,this.markDirty()}setAlignContent(e){this.style.alignContent=e,this.markDirty()}setJustifyContent(e){this.style.justifyContent=e,this.markDirty()}setDisplay(e){this.style.display=e,this.markDirty()}getDisplay(){return this.style.display}setPositionType(e){this.style.positionType=e,this.markDirty()}setPosition(e,t){this.style.position[e]=parseDimension(t),this._hasPosition=hasAnyDefinedEdge(this.style.position),this.markDirty()}setPositionPercent(e,t){this.style.position[e]=percentValue(t),this._hasPosition=!0,this.markDirty()}setPositionAuto(e){this.style.position[e]=_,this._hasPosition=!0,this.markDirty()}setOverflow(e){this.style.overflow=e,this.markDirty()}setDirection(e){this.style.direction=e,this.markDirty()}setBoxSizing(e){}setMargin(e,t){const i=parseDimension(t);this.style.margin[e]=i,i.unit===y.Auto?this._hasAutoMargin=!0:this._hasAutoMargin=hasAnyAutoEdge(this.style.margin),this._hasMargin=this._hasAutoMargin||hasAnyDefinedEdge(this.style.margin),this.markDirty()}setMarginPercent(e,t){this.style.margin[e]=percentValue(t),this._hasAutoMargin=hasAnyAutoEdge(this.style.margin),this._hasMargin=!0,this.markDirty()}setMarginAuto(e){this.style.margin[e]=_,this._hasAutoMargin=!0,this._hasMargin=!0,this.markDirty()}setPadding(e,t){this.style.padding[e]=parseDimension(t),this._hasPadding=hasAnyDefinedEdge(this.style.padding),this.markDirty()}setPaddingPercent(e,t){this.style.padding[e]=percentValue(t),this._hasPadding=!0,this.markDirty()}setBorder(e,t){this.style.border[e]=void 0===t?m:pointValue(t),this._hasBorder=hasAnyDefinedEdge(this.style.border),this.markDirty()}setGap(e,t){this.style.gap[e]=parseDimension(t),this.markDirty()}setGapPercent(e,t){this.style.gap[e]=percentValue(t),this.markDirty()}getFlexDirection(){return this.style.flexDirection}getJustifyContent(){return this.style.justifyContent}getAlignItems(){return this.style.alignItems}getAlignSelf(){return this.style.alignSelf}getAlignContent(){return this.style.alignContent}getFlexGrow(){return this.style.flexGrow}getFlexShrink(){return this.style.flexShrink}getFlexBasis(){return this.style.flexBasis}getFlexWrap(){return this.style.flexWrap}getWidth(){return this.style.width}getHeight(){return this.style.height}getOverflow(){return this.style.overflow}getPositionType(){return this.style.positionType}getDirection(){return this.style.direction}copyStyle(e){}setDirtiedFunc(e){}unsetDirtiedFunc(){}setIsReferenceBaseline(e){this.isReferenceBaseline_=e,this.markDirty()}isReferenceBaseline(){return this.isReferenceBaseline_}setAspectRatio(e){}getAspectRatio(){return NaN}setAlwaysFormsContainingBlock(e){}calculateLayout(e,t,i){v=0,w=0,A=0,D++;const s=void 0===e?NaN:e,n=void 0===t?NaN:t;layoutNode(this,s,n,isDefined(s)?c.Exactly:c.Undefined,isDefined(n)?c.Exactly:c.Undefined,s,n,!0);const a=this.layout.margin,l=resolveValue(resolveEdgeRaw(this.style.position,0),isDefined(s)?s:0),r=resolveValue(resolveEdgeRaw(this.style.position,1),isDefined(s)?s:0);this.layout.left=a[0]+(isDefined(l)?l:0),this.layout.top=a[1]+(isDefined(r)?r:0),roundLayout(this,this.config.pointScaleFactor,0,0)}}const p=createConfig(),x=4;function cacheWrite(e,t,i,s,n,a,l,r,o,u){e._cIn||(e._cIn=new Float64Array(8*x),e._cOut=new Float64Array(2*x)),u&&e._cGen!==D&&(e._cN=0,e._cWr=0);const h=e._cWr++%x;e._cN<x&&(e._cN=e._cWr);const c=8*h,f=e._cIn;f[c]=t,f[c+1]=i,f[c+2]=s,f[c+3]=n,f[c+4]=a,f[c+5]=l,f[c+6]=r?1:0,f[c+7]=o?1:0,e._cOut[2*h]=e.layout.width,e._cOut[2*h+1]=e.layout.height,e._cGen=D}function commitCacheOutputs(e,t){t?(e._lOutW=e.layout.width,e._lOutH=e.layout.height):(e._mOutW=e.layout.width,e._mOutH=e.layout.height)}let D=0,v=0,w=0,A=0,M=0;export function getYogaCounters(){return{visited:v,measured:w,cacheHits:A,live:M}}function layoutNode(t,i,s,n,a,l,r,d,y=!1,m=!1){v++;const _=t.style,p=t.layout,x=t._cGen===D&&!d;if(!t.isDirty_||x){if(!t.isDirty_&&t._hasL&&t._lWM===n&&t._lHM===a&&t._lFW===y&&t._lFH===m&&sameFloat(t._lW,i)&&sameFloat(t._lH,s)&&sameFloat(t._lOW,l)&&sameFloat(t._lOH,r))return A++,p.width=t._lOutW,void(p.height=t._lOutH);if(t._cN>0&&(x||!t.isDirty_)){const e=t._cIn;for(let o=0;o<t._cN;o++){const u=8*o;if(e[u+2]===n&&e[u+3]===a&&e[u+6]===(y?1:0)&&e[u+7]===(m?1:0)&&sameFloat(e[u],i)&&sameFloat(e[u+1],s)&&sameFloat(e[u+4],l)&&sameFloat(e[u+5],r))return p.width=t._cOut[2*o],p.height=t._cOut[2*o+1],void A++}}if(!t.isDirty_&&!d&&t._hasM&&t._mWM===n&&t._mHM===a&&sameFloat(t._mW,i)&&sameFloat(t._mH,s)&&sameFloat(t._mOW,l)&&sameFloat(t._mOH,r))return p.width=t._mOutW,p.height=t._mOutH,void A++}const M=t.isDirty_;d?(t._lW=i,t._lH=s,t._lWM=n,t._lHM=a,t._lOW=l,t._lOH=r,t._lFW=y,t._lFH=m,t._hasL=!0,t.isDirty_=!1,M&&(t._hasM=!1)):(t._mW=i,t._mH=s,t._mWM=n,t._mHM=a,t._mOW=l,t._mOH=r,t._hasM=!0,M&&(t._hasL=!1));const N=p.padding,b=p.border,F=p.margin;t._hasPadding?resolveEdges4Into(_.padding,l,N):N[0]=N[1]=N[2]=N[3]=0,t._hasBorder?resolveEdges4Into(_.border,l,b):b[0]=b[1]=b[2]=b[3]=0,t._hasMargin?resolveEdges4Into(_.margin,l,F):F[0]=F[1]=F[2]=F[3]=0;const E=N[0]+N[2]+b[0]+b[2],S=N[1]+N[3]+b[1]+b[3],k=y?NaN:resolveValue(_.width,l),W=m?NaN:resolveValue(_.height,r);let C=i,B=s,R=n,H=a;if(isDefined(k)&&(C=k,R=c.Exactly),isDefined(W)&&(B=W,H=c.Exactly),C=boundAxis(_,!0,C,l,r),B=boundAxis(_,!1,B,l,r),t.measureFunc&&0===t.children.length){const e=R===c.Undefined?NaN:Math.max(0,C-E),o=H===c.Undefined?NaN:Math.max(0,B-S);w++;const u=t.measureFunc(e,R,o,H);return t.layout.width=R===c.Exactly?C:boundAxis(_,!0,(u.width??0)+E,l,r),t.layout.height=H===c.Exactly?B:boundAxis(_,!1,(u.height??0)+S,l,r),commitCacheOutputs(t,d),void cacheWrite(t,i,s,n,a,l,r,y,m,M)}if(0===t.children.length)return t.layout.width=R===c.Exactly?C:boundAxis(_,!0,E,l,r),t.layout.height=H===c.Exactly?B:boundAxis(_,!1,S,l,r),commitCacheOutputs(t,d),void cacheWrite(t,i,s,n,a,l,r,y,m,M);const V=_.flexDirection,O=isRow(V)?o.Column:o.Row;const P=isRow(V),I=P?C:B,G=P?B:C,z=P?R:H,L=P?H:R,U=P?E:S,j=P?S:E,T=isDefined(I)?Math.max(0,I-U):NaN,J=isDefined(G)?Math.max(0,G-j):NaN,Y=resolveGap(_,P?u.Column:u.Row,T),q=[],K=[];collectLayoutChildren(t,q,K);const Q=isDefined(C)?C:NaN,X=isDefined(B)?B:NaN,Z=_.flexWrap!==g.NoWrap,$=resolveGap(_,P?u.Row:u.Column,J);for(const e of q)e._flexBasis=computeFlexBasis(e,V,T,J,L,Q,X);const ee=[];if(Z&&isDefined(T)&&0!==q.length){let e=0,t=0;for(let i=0;i<q.length;i++){const s=q[i],n=boundAxis(s.style,P,s._flexBasis,Q,X),a=Math.max(0,n)+childMarginForAxis(s,V,Q),l=i>e?Y:0;i>e&&t+l+a>T?(ee.push(q.slice(e,i)),e=i,t=a):t+=l+a,s._lineIndex=ee.length}ee.push(q.slice(e))}else{for(const e of q)e._lineIndex=0;ee.push(q)}const te=ee.length,ie=function(t,i){if(!isRow(t.style.flexDirection))return!1;if(t.style.alignItems===e.Baseline)return!0;for(const t of i)if(t.style.alignSelf===e.Baseline)return!0;return!1}(t,q),se=new Array(te),ne=new Array(te),ae=ie?new Array(te).fill(0):[];let le=0,re=0;for(let i=0;i<te;i++){const s=ee[i],n=s.length>1?Y*(s.length-1):0;let a=n;for(const e of s)a+=e._flexBasis+childMarginForAxis(e,V,Q);let o=T;if(!isDefined(o)){const e=P?l:r,t=resolveValue(P?_.minWidth:_.minHeight,e),i=resolveValue(P?_.maxWidth:_.maxHeight,e);isDefined(i)&&a>i-U?o=Math.max(0,i-U):isDefined(t)&&a<t-U&&(o=Math.max(0,t-U))}resolveFlexibleLengths(s,o,a,P,Q,X);let u=0;for(const t of s){const i=t.style,s=i.alignSelf===e.Auto?_.alignItems:i.alignSelf,n=childMarginForAxis(t,O,Q);let a=NaN,l=c.Undefined;const r=resolveValue(P?i.height:i.width,P?X:Q),o=P?1:0,h=P?3:2,f=t._hasAutoMargin&&(isMarginAuto(i.margin,o)||isMarginAuto(i.margin,h));isDefined(r)?(a=r,l=c.Exactly):s!==e.Stretch||f||Z||!isDefined(J)||L!==c.Exactly?!Z&&isDefined(J)&&(a=Math.max(0,J-n),l=c.AtMost):(a=Math.max(0,J-n),l=c.Exactly);layoutNode(t,P?t._mainSize:a,P?a:t._mainSize,P?c.Exactly:l,P?l:c.Exactly,Q,X,d,P,!P),t._crossSize=P?t.layout.height:t.layout.width,u=Math.max(u,t._crossSize+n)}if(ie){let n=0,a=0;for(const i of s){if(resolveChildAlign(t,i)!==e.Baseline)continue;const s=resolveEdge(i.style.margin,1,Q),l=resolveEdge(i.style.margin,3,Q),r=calculateBaseline(i)+s,o=i.layout.height+s+l-r;r>n&&(n=r),o>a&&(a=o)}ae[i]=n,n+a>u&&(u=n+a)}const h=leadingEdge(V),f=trailingEdge(V);let y=n;for(const e of s){const t=e.layout.margin;y+=e._mainSize+t[h]+t[f]}se[i]=y,ne[i]=u,le=Math.max(le,y),re+=u}re+=te>1?$*(te-1):0;const oe=_.overflow===f.Scroll,ue=le+U,he=z===c.Exactly?I:z===c.AtMost&&oe?Math.max(Math.min(I,ue),U):Z&&te>1&&z===c.AtMost?I:ue,ce=re+j,fe=L===c.Exactly?G:L===c.AtMost&&oe?Math.max(Math.min(G,ce),j):ce;if(t.layout.width=boundAxis(_,!0,P?he:fe,l,r),t.layout.height=boundAxis(_,!1,P?fe:he,l,r),commitCacheOutputs(t,d),cacheWrite(t,i,s,n,a,l,r,y,m,M),!d)return;const de=(P?t.layout.width:t.layout.height)-U,ye=(P?t.layout.height:t.layout.width)-j,ge=leadingEdge(V),me=trailingEdge(V),_e=P?1:0,pe=P?3:2,xe=isReverse(V),De=P?t.layout.width:t.layout.height;let ve=N[_e]+b[_e],we=$;const Ae=ye-re;if(1!==te||Z||ie){const t=Math.max(0,Ae);switch(_.alignContent){case e.FlexStart:break;case e.Center:ve+=Ae/2;break;case e.FlexEnd:ve+=Ae;break;case e.Stretch:if(te>0&&t>0){const e=t/te;for(let t=0;t<te;t++)ne[t]+=e}break;case e.SpaceBetween:te>1&&(we+=t/(te-1));break;case e.SpaceAround:te>0&&(we+=t/te,ve+=t/te/2);break;case e.SpaceEvenly:te>0&&(we+=t/(te+1),ve+=t/(te+1))}}else ne[0]=ye;const Me=_.flexWrap===g.WrapReverse,Ne=P?t.layout.height:t.layout.width;let be=ve;for(let t=0;t<te;t++){const i=ee[t],s=ne[t],n=se[t],a=i.length;if(Z||L!==c.Exactly)for(const t of i){const i=t.style,n=i.alignSelf===e.Auto?_.alignItems:i.alignSelf,a=isDefined(resolveValue(P?i.height:i.width,P?X:Q)),l=t._hasAutoMargin&&(isMarginAuto(i.margin,_e)||isMarginAuto(i.margin,pe));if(n===e.Stretch&&!a&&!l){const e=childMarginForAxis(t,O,Q),i=Math.max(0,s-e);if(t._crossSize!==i){layoutNode(t,P?t._mainSize:i,P?i:t._mainSize,c.Exactly,c.Exactly,Q,X,d,P,!P),t._crossSize=i}}}let l=N[ge]+b[ge],r=Y,o=0;for(const e of i)e._hasAutoMargin&&(isMarginAuto(e.style.margin,ge)&&o++,isMarginAuto(e.style.margin,me)&&o++);const u=de-n,f=Math.max(0,u),y=o>0&&f>0?f/o:0;if(0===o)switch(_.justifyContent){case h.FlexStart:break;case h.Center:l+=u/2;break;case h.FlexEnd:l+=u;break;case h.SpaceBetween:a>1&&(r+=f/(a-1));break;case h.SpaceAround:a>0&&(r+=f/a,l+=f/a/2);break;case h.SpaceEvenly:a>0&&(r+=f/(a+1),l+=f/(a+1))}const g=Me?Ne-be-s:be;let m=l;for(const n of i){const i=n.style.margin,a=n.layout.margin;let l,o,u,h,c=!1,f=!1,d=!1,p=!1;n._hasAutoMargin?(c=isMarginAuto(i,ge),f=isMarginAuto(i,me),d=isMarginAuto(i,_e),p=isMarginAuto(i,pe),l=c?y:a[ge],o=f?y:a[me],u=d?0:a[_e],h=p?0:a[pe]):(l=a[ge],o=a[me],u=a[_e],h=a[pe]);const x=xe?De-(m+l)-n._mainSize:m+l,D=n.style.alignSelf===e.Auto?_.alignItems:n.style.alignSelf;let v=g+u;const w=s-n._crossSize-u-h;if(d&&p)v+=Math.max(0,w)/2;else if(d)v+=Math.max(0,w);else if(p);else switch(D){case e.FlexStart:case e.Stretch:Me&&(v+=w);break;case e.Center:v+=w/2;break;case e.FlexEnd:Me||(v+=w);break;case e.Baseline:ie&&(v=g+ae[t]-calculateBaseline(n))}let A=0,M=0;if(n._hasPosition){const e=resolveValue(resolveEdgeRaw(n.style.position,0),Q),t=resolveValue(resolveEdgeRaw(n.style.position,2),Q),i=resolveValue(resolveEdgeRaw(n.style.position,1),Q),s=resolveValue(resolveEdgeRaw(n.style.position,3),Q);A=isDefined(e)?e:isDefined(t)?-t:0,M=isDefined(i)?i:isDefined(s)?-s:0}P?(n.layout.left=x+A,n.layout.top=v+M):(n.layout.left=v+A,n.layout.top=x+M),m+=n._mainSize+l+o+r}be+=s+we}for(const e of K)layoutAbsoluteChild(t,e,t.layout.width,t.layout.height,N,b)}function layoutAbsoluteChild(t,i,s,n,a,l){const r=i.style,o=resolveEdgeRaw(r.position,0),u=resolveEdgeRaw(r.position,2),h=resolveEdgeRaw(r.position,1),f=resolveEdgeRaw(r.position,3),d=resolveValue(o,s),y=resolveValue(u,s),m=resolveValue(h,n),_=resolveValue(f,n),p=s-l[0]-l[2],x=n-l[1]-l[3];let D=resolveValue(r.width,p),v=resolveValue(r.height,x);!isDefined(D)&&isDefined(d)&&isDefined(y)&&(D=p-d-y),!isDefined(v)&&isDefined(m)&&isDefined(_)&&(v=x-m-_),layoutNode(i,D,v,isDefined(D)?c.Exactly:c.Undefined,isDefined(v)?c.Exactly:c.Undefined,p,x,!0);const w=resolveEdge(r.margin,0,s),A=resolveEdge(r.margin,1,s),M=resolveEdge(r.margin,2,s),N=resolveEdge(r.margin,3,s),b=t.style.flexDirection,F=isReverse(b),E=isRow(b),S=t.style.flexWrap===g.WrapReverse,k=r.alignSelf===e.Auto?t.style.alignItems:r.alignSelf;let W,C;if(isDefined(d))W=l[0]+d+w;else if(isDefined(y))W=s-l[2]-y-i.layout.width-M;else if(E){const e=a[0]+l[0],n=s-a[2]-l[2];W=F?n-i.layout.width-M:justifyAbsolute(t.style.justifyContent,e,n,i.layout.width)+w}else W=alignAbsolute(k,a[0]+l[0],s-a[2]-l[2],i.layout.width,S)+w;if(isDefined(m))C=l[1]+m+A;else if(isDefined(_))C=n-l[3]-_-i.layout.height-N;else if(E)C=alignAbsolute(k,a[1]+l[1],n-a[3]-l[3],i.layout.height,S)+A;else{const e=a[1]+l[1],s=n-a[3]-l[3];C=F?s-i.layout.height-N:justifyAbsolute(t.style.justifyContent,e,s,i.layout.height)+A}i.layout.left=W,i.layout.top=C}function justifyAbsolute(e,t,i,s){switch(e){case h.Center:return t+(i-t-s)/2;case h.FlexEnd:return i-s;default:return t}}function alignAbsolute(t,i,s,n,a){switch(t){case e.Center:return i+(s-i-n)/2;case e.FlexEnd:return a?i:s-n;default:return a?s-n:i}}function computeFlexBasis(t,i,s,n,a,l,r){if((t._fbGen===D||!t.isDirty_)&&t._fbCrossMode===a&&sameFloat(t._fbOwnerW,l)&&sameFloat(t._fbOwnerH,r)&&sameFloat(t._fbAvailMain,s)&&sameFloat(t._fbAvailCross,n))return t._fbBasis;const o=t.style,u=isRow(i),h=resolveValue(o.flexBasis,s);if(isDefined(h)){const e=Math.max(0,h);return t._fbBasis=e,t._fbOwnerW=l,t._fbOwnerH=r,t._fbAvailMain=s,t._fbAvailCross=n,t._fbCrossMode=a,t._fbGen=D,e}const f=resolveValue(u?o.width:o.height,u?l:r);if(isDefined(f)){const e=Math.max(0,f);return t._fbBasis=e,t._fbOwnerW=l,t._fbOwnerH=r,t._fbAvailMain=s,t._fbAvailCross=n,t._fbCrossMode=a,t._fbGen=D,e}let d=resolveValue(u?o.height:o.width,u?r:l),y=isDefined(d)?c.Exactly:c.Undefined;!isDefined(d)&&isDefined(n)&&(d=n,y=a===c.Exactly&&function(t){const i=t.parent;if(!i)return!1;const s=t.style.alignSelf===e.Auto?i.style.alignItems:t.style.alignSelf;return s===e.Stretch}(t)?c.Exactly:c.AtMost);let g=NaN,m=c.Undefined;u&&isDefined(s)&&hasMeasureFuncInSubtree(t)&&(g=s,m=c.AtMost);layoutNode(t,u?g:d,u?d:g,u?m:y,u?y:m,l,r,!1);const _=u?t.layout.width:t.layout.height;return t._fbBasis=_,t._fbOwnerW=l,t._fbOwnerH=r,t._fbAvailMain=s,t._fbAvailCross=n,t._fbCrossMode=a,t._fbGen=D,_}function hasMeasureFuncInSubtree(e){if(e.measureFunc)return!0;for(const t of e.children)if(hasMeasureFuncInSubtree(t))return!0;return!1}function resolveFlexibleLengths(e,t,i,s,n,a){const l=e.length,r=new Array(l).fill(!1),o=isDefined(t)?t-i:0;for(let i=0;i<l;i++){const l=e[i],u=boundAxis(l.style,s,l._flexBasis,n,a);!isDefined(t)||(o>=0?0===l.style.flexGrow:0===l.style.flexShrink)?(l._mainSize=Math.max(0,u),r[i]=!0):l._mainSize=l._flexBasis}const u=new Array(l);for(let t=0;t<=l;t++){let t=0,i=0,h=0,c=0;for(let s=0;s<l;s++){const n=e[s];r[s]?t+=n._mainSize-n._flexBasis:(i+=n.style.flexGrow,h+=n.style.flexShrink*n._flexBasis,c++)}if(0===c)break;let f=o-t;if(f>0&&i>0&&i<1){const e=o*i;e<f&&(f=e)}else if(f<0&&h>0){let t=0;for(let i=0;i<l;i++)r[i]||(t+=e[i].style.flexShrink);if(t<1){const e=o*t;e>f&&(f=e)}}let d=0;for(let t=0;t<l;t++){if(r[t])continue;const l=e[t];let o=l._flexBasis;f>0&&i>0?o+=f*l.style.flexGrow/i:f<0&&h>0&&(o+=f*(l.style.flexShrink*l._flexBasis)/h),u[t]=o;const c=Math.max(0,boundAxis(l.style,s,o,n,a));l._mainSize=c,d+=c-o}if(0===d)break;let y=!1;for(let t=0;t<l;t++){if(r[t])continue;const i=e[t]._mainSize-u[t];(d>0&&i>0||d<0&&i<0)&&(r[t]=!0,y=!0)}if(!y)break}}function resolveChildAlign(t,i){return i.style.alignSelf===e.Auto?t.style.alignItems:i.style.alignSelf}function calculateBaseline(t){let i=null;for(const s of t.children){if(s._lineIndex>0)break;if(s.style.positionType!==d.Absolute&&s.style.display!==n.None){if(resolveChildAlign(t,s)===e.Baseline||s.isReferenceBaseline_){i=s;break}null===i&&(i=s)}}return null===i?t.layout.height:calculateBaseline(i)+i.layout.top}function childMarginForAxis(e,t,i){if(!e._hasMargin)return 0;return resolveEdge(e.style.margin,leadingEdge(t),i)+resolveEdge(e.style.margin,trailingEdge(t),i)}function resolveGap(e,t,i){let s=e.gap[t];s.unit===y.Undefined&&(s=e.gap[u.All]);const n=resolveValue(s,i);return isDefined(n)?Math.max(0,n):0}function boundAxis(e,t,i,s,n){const a=t?e.minWidth:e.minHeight,l=t?e.maxWidth:e.maxHeight,r=a.unit,o=l.unit;if(0===r&&0===o)return i;const u=t?s:n;let h=i;if(1===o)h>l.value&&(h=l.value);else if(2===o){const e=l.value*u/100;e==e&&h>e&&(h=e)}if(1===r)h<a.value&&(h=a.value);else if(2===r){const e=a.value*u/100;e==e&&h<e&&(h=e)}return h}function zeroLayoutRecursive(e){for(const t of e.children)t.layout.left=0,t.layout.top=0,t.layout.width=0,t.layout.height=0,t.isDirty_=!0,t._hasL=!1,t._hasM=!1,zeroLayoutRecursive(t)}function collectLayoutChildren(e,t,i){for(const s of e.children){const e=s.style.display;e===n.None?(s.layout.left=0,s.layout.top=0,s.layout.width=0,s.layout.height=0,zeroLayoutRecursive(s)):e===n.Contents?(s.layout.left=0,s.layout.top=0,s.layout.width=0,s.layout.height=0,collectLayoutChildren(s,t,i)):s.style.positionType===d.Absolute?i.push(s):t.push(s)}}function roundLayout(e,t,i,s){if(0===t)return;const n=e.layout,a=n.left,l=n.top,r=n.width,o=n.height,u=i+a,h=s+l,c=null!==e.measureFunc;n.left=roundValue(a,t,!1,c),n.top=roundValue(l,t,!1,c);const f=u+r,d=h+o,y=!isWholeNumber(r*t),g=!isWholeNumber(o*t);n.width=roundValue(f,t,c&&y,c&&!y)-roundValue(u,t,!1,c),n.height=roundValue(d,t,c&&g,c&&!g)-roundValue(h,t,!1,c);for(const i of e.children)roundLayout(i,t,u,h)}function isWholeNumber(e){const t=e-Math.floor(e);return t<1e-4||t>.9999}function roundValue(e,t,i,s){let n=e*t,a=n-Math.floor(n);return a<0&&(a+=1),n=a<1e-4?Math.floor(n):a>.9999||i?Math.ceil(n):s?Math.floor(n):Math.floor(n)+(a>=.4999?1:0),n/t}function parseDimension(e){if(void 0===e)return m;if("auto"===e)return _;if("number"==typeof e)return Number.isFinite(e)?pointValue(e):m;if("string"==typeof e&&e.endsWith("%"))return percentValue(parseFloat(e));const t=parseFloat(e);return isNaN(t)?m:pointValue(t)}function physicalEdge(e){switch(e){case a.Left:case a.Start:return 0;case a.Top:return 1;case a.Right:case a.End:return 2;case a.Bottom:return 3;default:return 0}}const N={Config:{create:createConfig,destroy(){}},Node:{create:e=>new Node(e),createDefault:()=>new Node,createWithConfig:e=>new Node(e),destroy(){}}};export function loadYoga(){return Promise.resolve(N)}export default N;
|
|
1
|
+
import{Align as e,BoxSizing as t,Dimension as i,Direction as s,Display as n,Edge as a,Errata as r,ExperimentalFeature as l,FlexDirection as o,Gutter as u,Justify as h,MeasureMode as c,Overflow as f,PositionType as d,Unit as y,Wrap as g}from"./enums.js";export{e as Align,t as BoxSizing,i as Dimension,s as Direction,n as Display,a as Edge,r as Errata,l as ExperimentalFeature,o as FlexDirection,u as Gutter,h as Justify,c as MeasureMode,f as Overflow,d as PositionType,y as Unit,g as Wrap};const m={unit:y.Undefined,value:NaN},_={unit:y.Auto,value:NaN};function pointValue(e){return{unit:y.Point,value:e}}function percentValue(e){return{unit:y.Percent,value:e}}function resolveValue(e,t){switch(e.unit){case y.Point:return e.value;case y.Percent:return isNaN(t)?NaN:e.value*t/100;default:return NaN}}function isDefined(e){return!isNaN(e)}function sameFloat(e,t){return e===t||e!=e&&t!=t}function defaultStyle(){return{direction:s.Inherit,flexDirection:o.Column,justifyContent:h.FlexStart,alignItems:e.Stretch,alignSelf:e.Auto,alignContent:e.FlexStart,flexWrap:g.NoWrap,overflow:f.Visible,display:n.Flex,positionType:d.Relative,flexGrow:0,flexShrink:0,flexBasis:_,margin:new Array(9).fill(m),padding:new Array(9).fill(m),border:new Array(9).fill(m),position:new Array(9).fill(m),gap:new Array(3).fill(m),width:_,height:_,minWidth:m,minHeight:m,maxWidth:m,maxHeight:m}}function resolveEdge(e,t,i,s=!1){let n=e[t];return n.unit===y.Undefined&&(n=0===t||2===t?e[a.Horizontal]:e[a.Vertical]),n.unit===y.Undefined&&(n=e[a.All]),n.unit===y.Undefined&&(0===t&&(n=e[a.Start]),2===t&&(n=e[a.End])),n.unit===y.Undefined?0:n.unit===y.Auto?s?NaN:0:resolveValue(n,i)}function resolveEdgeRaw(e,t){let i=e[t];return i.unit===y.Undefined&&(i=0===t||2===t?e[a.Horizontal]:e[a.Vertical]),i.unit===y.Undefined&&(i=e[a.All]),i.unit===y.Undefined&&(0===t&&(i=e[a.Start]),2===t&&(i=e[a.End])),i}function isMarginAuto(e,t){return resolveEdgeRaw(e,t).unit===y.Auto}function hasAnyAutoEdge(e){for(let t=0;t<9;t++)if(3===e[t].unit)return!0;return!1}function hasAnyDefinedEdge(e){for(let t=0;t<9;t++)if(0!==e[t].unit)return!0;return!1}function resolveEdges4Into(e,t,i){const s=e[6],n=e[7],a=e[8],r=e[4],l=e[5],o=isNaN(t)?NaN:t/100;let u=e[0];0===u.unit&&(u=s),0===u.unit&&(u=a),0===u.unit&&(u=r),i[0]=1===u.unit?u.value:2===u.unit?u.value*o:0,u=e[1],0===u.unit&&(u=n),0===u.unit&&(u=a),i[1]=1===u.unit?u.value:2===u.unit?u.value*o:0,u=e[2],0===u.unit&&(u=s),0===u.unit&&(u=a),0===u.unit&&(u=l),i[2]=1===u.unit?u.value:2===u.unit?u.value*o:0,u=e[3],0===u.unit&&(u=n),0===u.unit&&(u=a),i[3]=1===u.unit?u.value:2===u.unit?u.value*o:0}function isRow(e){return e===o.Row||e===o.RowReverse}function isReverse(e){return e===o.RowReverse||e===o.ColumnReverse}function leadingEdge(e){switch(e){case o.Row:return 0;case o.RowReverse:return 2;case o.Column:return 1;case o.ColumnReverse:return 3}}function trailingEdge(e){switch(e){case o.Row:return 2;case o.RowReverse:return 0;case o.Column:return 3;case o.ColumnReverse:return 1}}function createConfig(){const e={pointScaleFactor:1,errata:r.None,useWebDefaults:!1,free(){},isExperimentalFeatureEnabled:()=>!1,setExperimentalFeatureEnabled(){},setPointScaleFactor(t){e.pointScaleFactor=t},getErrata:()=>e.errata,setErrata(t){e.errata=t},setUseWebDefaults(t){e.useWebDefaults=t}};return e}export class Node{style;layout;parent;children;measureFunc;config;isDirty_;isReferenceBaseline_;_flexBasis=0;_mainSize=0;_crossSize=0;_lineIndex=0;_hasAutoMargin=!1;_hasPosition=!1;_hasPadding=!1;_hasBorder=!1;_hasMargin=!1;_lW=NaN;_lH=NaN;_lWM=0;_lHM=0;_lOW=NaN;_lOH=NaN;_lFW=!1;_lFH=!1;_lOutW=NaN;_lOutH=NaN;_hasL=!1;_mW=NaN;_mH=NaN;_mWM=0;_mHM=0;_mOW=NaN;_mOH=NaN;_mOutW=NaN;_mOutH=NaN;_hasM=!1;_fbBasis=NaN;_fbOwnerW=NaN;_fbOwnerH=NaN;_fbAvailMain=NaN;_fbAvailCross=NaN;_fbCrossMode=0;_fbGen=-1;_cIn=null;_cOut=null;_cGen=-1;_cN=0;_cWr=0;constructor(e){this.style=defaultStyle(),this.layout={left:0,top:0,width:0,height:0,border:[0,0,0,0],padding:[0,0,0,0],margin:[0,0,0,0]},this.parent=null,this.children=[],this.measureFunc=null,this.config=e??p,this.isDirty_=!0,this.isReferenceBaseline_=!1,M++}insertChild(e,t){e.parent=this,this.children.splice(t,0,e),this.markDirty()}removeChild(e){const t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=null,this.markDirty())}getChild(e){return this.children[e]}getChildCount(){return this.children.length}getParent(){return this.parent}free(){this.parent=null,this.children=[],this.measureFunc=null,this._cIn=null,this._cOut=null,M--}freeRecursive(){for(const e of this.children)e.freeRecursive();this.free()}reset(){this.style=defaultStyle(),this.children=[],this.parent=null,this.measureFunc=null,this.isDirty_=!0,this._hasAutoMargin=!1,this._hasPosition=!1,this._hasPadding=!1,this._hasBorder=!1,this._hasMargin=!1,this._hasL=!1,this._hasM=!1,this._cN=0,this._cWr=0,this._fbBasis=NaN}markDirty(){this.isDirty_=!0,this.parent&&!this.parent.isDirty_&&this.parent.markDirty()}isDirty(){return this.isDirty_}hasNewLayout(){return!0}markLayoutSeen(){}setMeasureFunc(e){this.measureFunc=e,this.markDirty()}unsetMeasureFunc(){this.measureFunc=null,this.markDirty()}getComputedLeft(){return this.layout.left}getComputedTop(){return this.layout.top}getComputedWidth(){return this.layout.width}getComputedHeight(){return this.layout.height}getComputedRight(){const e=this.parent;return e?e.layout.width-this.layout.left-this.layout.width:0}getComputedBottom(){const e=this.parent;return e?e.layout.height-this.layout.top-this.layout.height:0}getComputedLayout(){return{left:this.layout.left,top:this.layout.top,right:this.getComputedRight(),bottom:this.getComputedBottom(),width:this.layout.width,height:this.layout.height}}getComputedBorder(e){return this.layout.border[physicalEdge(e)]}getComputedPadding(e){return this.layout.padding[physicalEdge(e)]}getComputedMargin(e){return this.layout.margin[physicalEdge(e)]}setWidth(e){this.style.width=parseDimension(e),this.markDirty()}setWidthPercent(e){this.style.width=percentValue(e),this.markDirty()}setWidthAuto(){this.style.width=_,this.markDirty()}setHeight(e){this.style.height=parseDimension(e),this.markDirty()}setHeightPercent(e){this.style.height=percentValue(e),this.markDirty()}setHeightAuto(){this.style.height=_,this.markDirty()}setMinWidth(e){this.style.minWidth=parseDimension(e),this.markDirty()}setMinWidthPercent(e){this.style.minWidth=percentValue(e),this.markDirty()}setMinHeight(e){this.style.minHeight=parseDimension(e),this.markDirty()}setMinHeightPercent(e){this.style.minHeight=percentValue(e),this.markDirty()}setMaxWidth(e){this.style.maxWidth=parseDimension(e),this.markDirty()}setMaxWidthPercent(e){this.style.maxWidth=percentValue(e),this.markDirty()}setMaxHeight(e){this.style.maxHeight=parseDimension(e),this.markDirty()}setMaxHeightPercent(e){this.style.maxHeight=percentValue(e),this.markDirty()}setFlexDirection(e){this.style.flexDirection=e,this.markDirty()}setFlexGrow(e){this.style.flexGrow=e??0,this.markDirty()}setFlexShrink(e){this.style.flexShrink=e??0,this.markDirty()}setFlex(e){void 0===e||isNaN(e)?(this.style.flexGrow=0,this.style.flexShrink=0):e>0?(this.style.flexGrow=e,this.style.flexShrink=1,this.style.flexBasis=pointValue(0)):e<0?(this.style.flexGrow=0,this.style.flexShrink=-e):(this.style.flexGrow=0,this.style.flexShrink=0),this.markDirty()}setFlexBasis(e){this.style.flexBasis=parseDimension(e),this.markDirty()}setFlexBasisPercent(e){this.style.flexBasis=percentValue(e),this.markDirty()}setFlexBasisAuto(){this.style.flexBasis=_,this.markDirty()}setFlexWrap(e){this.style.flexWrap=e,this.markDirty()}setAlignItems(e){this.style.alignItems=e,this.markDirty()}setAlignSelf(e){this.style.alignSelf=e,this.markDirty()}setAlignContent(e){this.style.alignContent=e,this.markDirty()}setJustifyContent(e){this.style.justifyContent=e,this.markDirty()}setDisplay(e){this.style.display=e,this.markDirty()}getDisplay(){return this.style.display}setPositionType(e){this.style.positionType=e,this.markDirty()}setPosition(e,t){this.style.position[e]=parseDimension(t),this._hasPosition=hasAnyDefinedEdge(this.style.position),this.markDirty()}setPositionPercent(e,t){this.style.position[e]=percentValue(t),this._hasPosition=!0,this.markDirty()}setPositionAuto(e){this.style.position[e]=_,this._hasPosition=!0,this.markDirty()}setOverflow(e){this.style.overflow=e,this.markDirty()}setDirection(e){this.style.direction=e,this.markDirty()}setBoxSizing(e){}setMargin(e,t){const i=parseDimension(t);this.style.margin[e]=i,i.unit===y.Auto?this._hasAutoMargin=!0:this._hasAutoMargin=hasAnyAutoEdge(this.style.margin),this._hasMargin=this._hasAutoMargin||hasAnyDefinedEdge(this.style.margin),this.markDirty()}setMarginPercent(e,t){this.style.margin[e]=percentValue(t),this._hasAutoMargin=hasAnyAutoEdge(this.style.margin),this._hasMargin=!0,this.markDirty()}setMarginAuto(e){this.style.margin[e]=_,this._hasAutoMargin=!0,this._hasMargin=!0,this.markDirty()}setPadding(e,t){this.style.padding[e]=parseDimension(t),this._hasPadding=hasAnyDefinedEdge(this.style.padding),this.markDirty()}setPaddingPercent(e,t){this.style.padding[e]=percentValue(t),this._hasPadding=!0,this.markDirty()}setBorder(e,t){this.style.border[e]=void 0===t?m:pointValue(t),this._hasBorder=hasAnyDefinedEdge(this.style.border),this.markDirty()}setGap(e,t){this.style.gap[e]=parseDimension(t),this.markDirty()}setGapPercent(e,t){this.style.gap[e]=percentValue(t),this.markDirty()}getFlexDirection(){return this.style.flexDirection}getJustifyContent(){return this.style.justifyContent}getAlignItems(){return this.style.alignItems}getAlignSelf(){return this.style.alignSelf}getAlignContent(){return this.style.alignContent}getFlexGrow(){return this.style.flexGrow}getFlexShrink(){return this.style.flexShrink}getFlexBasis(){return this.style.flexBasis}getFlexWrap(){return this.style.flexWrap}getWidth(){return this.style.width}getHeight(){return this.style.height}getOverflow(){return this.style.overflow}getPositionType(){return this.style.positionType}getDirection(){return this.style.direction}copyStyle(e){}setDirtiedFunc(e){}unsetDirtiedFunc(){}setIsReferenceBaseline(e){this.isReferenceBaseline_=e,this.markDirty()}isReferenceBaseline(){return this.isReferenceBaseline_}setAspectRatio(e){}getAspectRatio(){return NaN}setAlwaysFormsContainingBlock(e){}calculateLayout(e,t,i){v=0,w=0,A=0,D++;const s=void 0===e?NaN:e,n=void 0===t?NaN:t;layoutNode(this,s,n,isDefined(s)?c.Exactly:c.Undefined,isDefined(n)?c.Exactly:c.Undefined,s,n,!0);const a=this.layout.margin,r=resolveValue(resolveEdgeRaw(this.style.position,0),isDefined(s)?s:0),l=resolveValue(resolveEdgeRaw(this.style.position,1),isDefined(s)?s:0);this.layout.left=a[0]+(isDefined(r)?r:0),this.layout.top=a[1]+(isDefined(l)?l:0),roundLayout(this,this.config.pointScaleFactor,0,0)}}const p=createConfig(),x=4;function cacheWrite(e,t,i,s,n,a,r,l,o,u){e._cIn||(e._cIn=new Float64Array(8*x),e._cOut=new Float64Array(2*x)),u&&e._cGen!==D&&(e._cN=0,e._cWr=0);const h=e._cWr++%x;e._cN<x&&(e._cN=e._cWr);const c=8*h,f=e._cIn;f[c]=t,f[c+1]=i,f[c+2]=s,f[c+3]=n,f[c+4]=a,f[c+5]=r,f[c+6]=l?1:0,f[c+7]=o?1:0,e._cOut[2*h]=e.layout.width,e._cOut[2*h+1]=e.layout.height,e._cGen=D}function commitCacheOutputs(e,t){t?(e._lOutW=e.layout.width,e._lOutH=e.layout.height):(e._mOutW=e.layout.width,e._mOutH=e.layout.height)}let D=0,v=0,w=0,A=0,M=0;export function getYogaCounters(){return{visited:v,measured:w,cacheHits:A,live:M}}function layoutNode(t,i,s,n,a,r,l,d,y=!1,m=!1){v++;const _=t.style,p=t.layout,x=t._cGen===D&&!d;if(!t.isDirty_||x){if(!t.isDirty_&&t._hasL&&t._lWM===n&&t._lHM===a&&t._lFW===y&&t._lFH===m&&sameFloat(t._lW,i)&&sameFloat(t._lH,s)&&sameFloat(t._lOW,r)&&sameFloat(t._lOH,l))return A++,p.width=t._lOutW,void(p.height=t._lOutH);if(t._cN>0&&(x||!t.isDirty_)){const e=t._cIn;for(let o=0;o<t._cN;o++){const u=8*o;if(e[u+2]===n&&e[u+3]===a&&e[u+6]===(y?1:0)&&e[u+7]===(m?1:0)&&sameFloat(e[u],i)&&sameFloat(e[u+1],s)&&sameFloat(e[u+4],r)&&sameFloat(e[u+5],l))return p.width=t._cOut[2*o],p.height=t._cOut[2*o+1],void A++}}if(!t.isDirty_&&!d&&t._hasM&&t._mWM===n&&t._mHM===a&&sameFloat(t._mW,i)&&sameFloat(t._mH,s)&&sameFloat(t._mOW,r)&&sameFloat(t._mOH,l))return p.width=t._mOutW,p.height=t._mOutH,void A++}const M=t.isDirty_;d?(t._lW=i,t._lH=s,t._lWM=n,t._lHM=a,t._lOW=r,t._lOH=l,t._lFW=y,t._lFH=m,t._hasL=!0,t.isDirty_=!1,M&&(t._hasM=!1)):(t._mW=i,t._mH=s,t._mWM=n,t._mHM=a,t._mOW=r,t._mOH=l,t._hasM=!0,M&&(t._hasL=!1));const N=p.padding,b=p.border,E=p.margin;t._hasPadding?resolveEdges4Into(_.padding,r,N):N[0]=N[1]=N[2]=N[3]=0,t._hasBorder?resolveEdges4Into(_.border,r,b):b[0]=b[1]=b[2]=b[3]=0,t._hasMargin?resolveEdges4Into(_.margin,r,E):E[0]=E[1]=E[2]=E[3]=0;const F=N[0]+N[2]+b[0]+b[2],S=N[1]+N[3]+b[1]+b[3],k=y?NaN:resolveValue(_.width,r),W=m?NaN:resolveValue(_.height,l);let C=i,B=s,R=n,H=a;if(isDefined(k)&&(C=k,R=c.Exactly),isDefined(W)&&(B=W,H=c.Exactly),C=boundAxis(_,!0,C,r,l),B=boundAxis(_,!1,B,r,l),t.measureFunc&&0===t.children.length){const e=R===c.Undefined?NaN:Math.max(0,C-F),o=H===c.Undefined?NaN:Math.max(0,B-S);w++;const u=t.measureFunc(e,R,o,H);return t.layout.width=R===c.Exactly?C:boundAxis(_,!0,(u.width??0)+F,r,l),t.layout.height=H===c.Exactly?B:boundAxis(_,!1,(u.height??0)+S,r,l),commitCacheOutputs(t,d),void cacheWrite(t,i,s,n,a,r,l,y,m,M)}if(0===t.children.length)return t.layout.width=R===c.Exactly?C:boundAxis(_,!0,F,r,l),t.layout.height=H===c.Exactly?B:boundAxis(_,!1,S,r,l),commitCacheOutputs(t,d),void cacheWrite(t,i,s,n,a,r,l,y,m,M);const V=_.flexDirection,O=isRow(V)?o.Column:o.Row,P=isRow(V),I=P?C:B,G=P?B:C,z=P?R:H,L=P?H:R,U=P?F:S,T=P?S:F,j=isDefined(I)?Math.max(0,I-U):NaN,J=isDefined(G)?Math.max(0,G-T):NaN,Y=resolveGap(_,P?u.Column:u.Row,j),q=[],K=[];collectLayoutChildren(t,q,K);const Q=isDefined(C)?C:NaN,X=isDefined(B)?B:NaN,Z=_.flexWrap!==g.NoWrap,$=resolveGap(_,P?u.Row:u.Column,J);for(const e of q)e._flexBasis=computeFlexBasis(e,V,j,J,L,Q,X);const ee=[];if(Z&&isDefined(j)&&0!==q.length){let e=0,t=0;for(let i=0;i<q.length;i++){const s=q[i],n=boundAxis(s.style,P,s._flexBasis,Q,X),a=Math.max(0,n)+childMarginForAxis(s,V,Q),r=i>e?Y:0;i>e&&t+r+a>j?(ee.push(q.slice(e,i)),e=i,t=a):t+=r+a,s._lineIndex=ee.length}ee.push(q.slice(e))}else{for(const e of q)e._lineIndex=0;ee.push(q)}const te=ee.length,ie=function(t,i){if(!isRow(t.style.flexDirection))return!1;if(t.style.alignItems===e.Baseline)return!0;for(const t of i)if(t.style.alignSelf===e.Baseline)return!0;return!1}(t,q),se=new Array(te),ne=new Array(te),ae=ie?new Array(te).fill(0):[];let re=0,le=0;for(let i=0;i<te;i++){const s=ee[i],n=s.length>1?Y*(s.length-1):0;let a=n;for(const e of s)a+=e._flexBasis+childMarginForAxis(e,V,Q);let o=j;if(!isDefined(o)){const e=P?r:l,t=resolveValue(P?_.minWidth:_.minHeight,e),i=resolveValue(P?_.maxWidth:_.maxHeight,e);isDefined(i)&&a>i-U?o=Math.max(0,i-U):isDefined(t)&&a<t-U&&(o=Math.max(0,t-U))}resolveFlexibleLengths(s,o,a,P,Q,X);let u=0;for(const t of s){const i=t.style,s=i.alignSelf===e.Auto?_.alignItems:i.alignSelf,n=childMarginForAxis(t,O,Q);let a=NaN,r=c.Undefined;const l=resolveValue(P?i.height:i.width,P?X:Q),o=P?1:0,h=P?3:2,f=t._hasAutoMargin&&(isMarginAuto(i.margin,o)||isMarginAuto(i.margin,h));isDefined(l)?(a=l,r=c.Exactly):s!==e.Stretch||f||Z||!isDefined(J)||L!==c.Exactly?!Z&&isDefined(J)&&(a=Math.max(0,J-n),r=c.AtMost):(a=Math.max(0,J-n),r=c.Exactly),layoutNode(t,P?t._mainSize:a,P?a:t._mainSize,P?c.Exactly:r,P?r:c.Exactly,Q,X,d,P,!P),t._crossSize=P?t.layout.height:t.layout.width,u=Math.max(u,t._crossSize+n)}if(ie){let n=0,a=0;for(const i of s){if(resolveChildAlign(t,i)!==e.Baseline)continue;const s=resolveEdge(i.style.margin,1,Q),r=resolveEdge(i.style.margin,3,Q),l=calculateBaseline(i)+s,o=i.layout.height+s+r-l;l>n&&(n=l),o>a&&(a=o)}ae[i]=n,n+a>u&&(u=n+a)}const h=leadingEdge(V),f=trailingEdge(V);let y=n;for(const e of s){const t=e.layout.margin;y+=e._mainSize+t[h]+t[f]}se[i]=y,ne[i]=u,re=Math.max(re,y),le+=u}le+=te>1?$*(te-1):0;const oe=_.overflow===f.Scroll,ue=re+U,he=z===c.Exactly?I:z===c.AtMost&&oe?Math.max(Math.min(I,ue),U):Z&&te>1&&z===c.AtMost?I:ue,ce=le+T,fe=L===c.Exactly?G:L===c.AtMost&&oe?Math.max(Math.min(G,ce),T):ce;if(t.layout.width=boundAxis(_,!0,P?he:fe,r,l),t.layout.height=boundAxis(_,!1,P?fe:he,r,l),commitCacheOutputs(t,d),cacheWrite(t,i,s,n,a,r,l,y,m,M),!d)return;const de=(P?t.layout.width:t.layout.height)-U,ye=(P?t.layout.height:t.layout.width)-T,ge=leadingEdge(V),me=trailingEdge(V),_e=P?1:0,pe=P?3:2,xe=isReverse(V),De=P?t.layout.width:t.layout.height;let ve=N[_e]+b[_e],we=$;const Ae=ye-le;if(1!==te||Z||ie){const t=Math.max(0,Ae);switch(_.alignContent){case e.FlexStart:break;case e.Center:ve+=Ae/2;break;case e.FlexEnd:ve+=Ae;break;case e.Stretch:if(te>0&&t>0){const e=t/te;for(let t=0;t<te;t++)ne[t]+=e}break;case e.SpaceBetween:te>1&&(we+=t/(te-1));break;case e.SpaceAround:te>0&&(we+=t/te,ve+=t/te/2);break;case e.SpaceEvenly:te>0&&(we+=t/(te+1),ve+=t/(te+1))}}else ne[0]=ye;const Me=_.flexWrap===g.WrapReverse,Ne=P?t.layout.height:t.layout.width;let be=ve;for(let t=0;t<te;t++){const i=ee[t],s=ne[t],n=se[t],a=i.length;if(Z||L!==c.Exactly)for(const t of i){const i=t.style,n=i.alignSelf===e.Auto?_.alignItems:i.alignSelf,a=isDefined(resolveValue(P?i.height:i.width,P?X:Q)),r=t._hasAutoMargin&&(isMarginAuto(i.margin,_e)||isMarginAuto(i.margin,pe));if(n===e.Stretch&&!a&&!r){const e=childMarginForAxis(t,O,Q),i=Math.max(0,s-e);t._crossSize!==i&&(layoutNode(t,P?t._mainSize:i,P?i:t._mainSize,c.Exactly,c.Exactly,Q,X,d,P,!P),t._crossSize=i)}}let r=N[ge]+b[ge],l=Y,o=0;for(const e of i)e._hasAutoMargin&&(isMarginAuto(e.style.margin,ge)&&o++,isMarginAuto(e.style.margin,me)&&o++);const u=de-n,f=Math.max(0,u),y=o>0&&f>0?f/o:0;if(0===o)switch(_.justifyContent){case h.FlexStart:break;case h.Center:r+=u/2;break;case h.FlexEnd:r+=u;break;case h.SpaceBetween:a>1&&(l+=f/(a-1));break;case h.SpaceAround:a>0&&(l+=f/a,r+=f/a/2);break;case h.SpaceEvenly:a>0&&(l+=f/(a+1),r+=f/(a+1))}const g=Me?Ne-be-s:be;let m=r;for(const n of i){const i=n.style.margin,a=n.layout.margin;let r,o,u,h,c=!1,f=!1,d=!1,p=!1;n._hasAutoMargin?(c=isMarginAuto(i,ge),f=isMarginAuto(i,me),d=isMarginAuto(i,_e),p=isMarginAuto(i,pe),r=c?y:a[ge],o=f?y:a[me],u=d?0:a[_e],h=p?0:a[pe]):(r=a[ge],o=a[me],u=a[_e],h=a[pe]);const x=xe?De-(m+r)-n._mainSize:m+r,D=n.style.alignSelf===e.Auto?_.alignItems:n.style.alignSelf;let v=g+u;const w=s-n._crossSize-u-h;if(d&&p)v+=Math.max(0,w)/2;else if(d)v+=Math.max(0,w);else if(p);else switch(D){case e.FlexStart:case e.Stretch:Me&&(v+=w);break;case e.Center:v+=w/2;break;case e.FlexEnd:Me||(v+=w);break;case e.Baseline:ie&&(v=g+ae[t]-calculateBaseline(n))}let A=0,M=0;if(n._hasPosition){const e=resolveValue(resolveEdgeRaw(n.style.position,0),Q),t=resolveValue(resolveEdgeRaw(n.style.position,2),Q),i=resolveValue(resolveEdgeRaw(n.style.position,1),Q),s=resolveValue(resolveEdgeRaw(n.style.position,3),Q);A=isDefined(e)?e:isDefined(t)?-t:0,M=isDefined(i)?i:isDefined(s)?-s:0}P?(n.layout.left=x+A,n.layout.top=v+M):(n.layout.left=v+A,n.layout.top=x+M),m+=n._mainSize+r+o+l}be+=s+we}for(const e of K)layoutAbsoluteChild(t,e,t.layout.width,t.layout.height,N,b)}function layoutAbsoluteChild(t,i,s,n,a,r){const l=i.style,o=resolveEdgeRaw(l.position,0),u=resolveEdgeRaw(l.position,2),h=resolveEdgeRaw(l.position,1),f=resolveEdgeRaw(l.position,3),d=resolveValue(o,s),y=resolveValue(u,s),m=resolveValue(h,n),_=resolveValue(f,n),p=s-r[0]-r[2],x=n-r[1]-r[3];let D=resolveValue(l.width,p),v=resolveValue(l.height,x);!isDefined(D)&&isDefined(d)&&isDefined(y)&&(D=p-d-y),!isDefined(v)&&isDefined(m)&&isDefined(_)&&(v=x-m-_),layoutNode(i,D,v,isDefined(D)?c.Exactly:c.Undefined,isDefined(v)?c.Exactly:c.Undefined,p,x,!0);const w=resolveEdge(l.margin,0,s),A=resolveEdge(l.margin,1,s),M=resolveEdge(l.margin,2,s),N=resolveEdge(l.margin,3,s),b=t.style.flexDirection,E=isReverse(b),F=isRow(b),S=t.style.flexWrap===g.WrapReverse,k=l.alignSelf===e.Auto?t.style.alignItems:l.alignSelf;let W,C;if(isDefined(d))W=r[0]+d+w;else if(isDefined(y))W=s-r[2]-y-i.layout.width-M;else if(F){const e=a[0]+r[0],n=s-a[2]-r[2];W=E?n-i.layout.width-M:justifyAbsolute(t.style.justifyContent,e,n,i.layout.width)+w}else W=alignAbsolute(k,a[0]+r[0],s-a[2]-r[2],i.layout.width,S)+w;if(isDefined(m))C=r[1]+m+A;else if(isDefined(_))C=n-r[3]-_-i.layout.height-N;else if(F)C=alignAbsolute(k,a[1]+r[1],n-a[3]-r[3],i.layout.height,S)+A;else{const e=a[1]+r[1],s=n-a[3]-r[3];C=E?s-i.layout.height-N:justifyAbsolute(t.style.justifyContent,e,s,i.layout.height)+A}i.layout.left=W,i.layout.top=C}function justifyAbsolute(e,t,i,s){switch(e){case h.Center:return t+(i-t-s)/2;case h.FlexEnd:return i-s;default:return t}}function alignAbsolute(t,i,s,n,a){switch(t){case e.Center:return i+(s-i-n)/2;case e.FlexEnd:return a?i:s-n;default:return a?s-n:i}}function computeFlexBasis(t,i,s,n,a,r,l){if((t._fbGen===D||!t.isDirty_)&&t._fbCrossMode===a&&sameFloat(t._fbOwnerW,r)&&sameFloat(t._fbOwnerH,l)&&sameFloat(t._fbAvailMain,s)&&sameFloat(t._fbAvailCross,n))return t._fbBasis;const o=t.style,u=isRow(i),h=resolveValue(o.flexBasis,s);if(isDefined(h)){const e=Math.max(0,h);return t._fbBasis=e,t._fbOwnerW=r,t._fbOwnerH=l,t._fbAvailMain=s,t._fbAvailCross=n,t._fbCrossMode=a,t._fbGen=D,e}const f=resolveValue(u?o.width:o.height,u?r:l);if(isDefined(f)){const e=Math.max(0,f);return t._fbBasis=e,t._fbOwnerW=r,t._fbOwnerH=l,t._fbAvailMain=s,t._fbAvailCross=n,t._fbCrossMode=a,t._fbGen=D,e}let d=resolveValue(u?o.height:o.width,u?l:r),y=isDefined(d)?c.Exactly:c.Undefined;!isDefined(d)&&isDefined(n)&&(d=n,y=a===c.Exactly&&function(t){const i=t.parent;if(!i)return!1;return(t.style.alignSelf===e.Auto?i.style.alignItems:t.style.alignSelf)===e.Stretch}(t)?c.Exactly:c.AtMost);let g=NaN,m=c.Undefined;u&&isDefined(s)&&hasMeasureFuncInSubtree(t)&&(g=s,m=c.AtMost),layoutNode(t,u?g:d,u?d:g,u?m:y,u?y:m,r,l,!1);const _=u?t.layout.width:t.layout.height;return t._fbBasis=_,t._fbOwnerW=r,t._fbOwnerH=l,t._fbAvailMain=s,t._fbAvailCross=n,t._fbCrossMode=a,t._fbGen=D,_}function hasMeasureFuncInSubtree(e){if(e.measureFunc)return!0;for(const t of e.children)if(hasMeasureFuncInSubtree(t))return!0;return!1}function resolveFlexibleLengths(e,t,i,s,n,a){const r=e.length,l=new Array(r).fill(!1),o=isDefined(t)?t-i:0;for(let i=0;i<r;i++){const r=e[i],u=boundAxis(r.style,s,r._flexBasis,n,a);isDefined(t)&&(o>=0?0!==r.style.flexGrow:0!==r.style.flexShrink)?r._mainSize=r._flexBasis:(r._mainSize=Math.max(0,u),l[i]=!0)}const u=new Array(r);for(let t=0;t<=r;t++){let t=0,i=0,h=0,c=0;for(let s=0;s<r;s++){const n=e[s];l[s]?t+=n._mainSize-n._flexBasis:(i+=n.style.flexGrow,h+=n.style.flexShrink*n._flexBasis,c++)}if(0===c)break;let f=o-t;if(f>0&&i>0&&i<1){const e=o*i;e<f&&(f=e)}else if(f<0&&h>0){let t=0;for(let i=0;i<r;i++)l[i]||(t+=e[i].style.flexShrink);if(t<1){const e=o*t;e>f&&(f=e)}}let d=0;for(let t=0;t<r;t++){if(l[t])continue;const r=e[t];let o=r._flexBasis;f>0&&i>0?o+=f*r.style.flexGrow/i:f<0&&h>0&&(o+=f*(r.style.flexShrink*r._flexBasis)/h),u[t]=o;const c=Math.max(0,boundAxis(r.style,s,o,n,a));r._mainSize=c,d+=c-o}if(0===d)break;let y=!1;for(let t=0;t<r;t++){if(l[t])continue;const i=e[t]._mainSize-u[t];(d>0&&i>0||d<0&&i<0)&&(l[t]=!0,y=!0)}if(!y)break}}function resolveChildAlign(t,i){return i.style.alignSelf===e.Auto?t.style.alignItems:i.style.alignSelf}function calculateBaseline(t){let i=null;for(const s of t.children){if(s._lineIndex>0)break;if(s.style.positionType!==d.Absolute&&s.style.display!==n.None){if(resolveChildAlign(t,s)===e.Baseline||s.isReferenceBaseline_){i=s;break}null===i&&(i=s)}}return null===i?t.layout.height:calculateBaseline(i)+i.layout.top}function childMarginForAxis(e,t,i){return e._hasMargin?resolveEdge(e.style.margin,leadingEdge(t),i)+resolveEdge(e.style.margin,trailingEdge(t),i):0}function resolveGap(e,t,i){let s=e.gap[t];s.unit===y.Undefined&&(s=e.gap[u.All]);const n=resolveValue(s,i);return isDefined(n)?Math.max(0,n):0}function boundAxis(e,t,i,s,n){const a=t?e.minWidth:e.minHeight,r=t?e.maxWidth:e.maxHeight,l=a.unit,o=r.unit;if(0===l&&0===o)return i;const u=t?s:n;let h=i;if(1===o)h>r.value&&(h=r.value);else if(2===o){const e=r.value*u/100;e==e&&h>e&&(h=e)}if(1===l)h<a.value&&(h=a.value);else if(2===l){const e=a.value*u/100;e==e&&h<e&&(h=e)}return h}function zeroLayoutRecursive(e){for(const t of e.children)t.layout.left=0,t.layout.top=0,t.layout.width=0,t.layout.height=0,t.isDirty_=!0,t._hasL=!1,t._hasM=!1,zeroLayoutRecursive(t)}function collectLayoutChildren(e,t,i){for(const s of e.children){const e=s.style.display;e===n.None?(s.layout.left=0,s.layout.top=0,s.layout.width=0,s.layout.height=0,zeroLayoutRecursive(s)):e===n.Contents?(s.layout.left=0,s.layout.top=0,s.layout.width=0,s.layout.height=0,collectLayoutChildren(s,t,i)):s.style.positionType===d.Absolute?i.push(s):t.push(s)}}function roundLayout(e,t,i,s){if(0===t)return;const n=e.layout,a=n.left,r=n.top,l=n.width,o=n.height,u=i+a,h=s+r,c=null!==e.measureFunc;n.left=roundValue(a,t,!1,c),n.top=roundValue(r,t,!1,c);const f=u+l,d=h+o,y=!isWholeNumber(l*t),g=!isWholeNumber(o*t);n.width=roundValue(f,t,c&&y,c&&!y)-roundValue(u,t,!1,c),n.height=roundValue(d,t,c&&g,c&&!g)-roundValue(h,t,!1,c);for(const i of e.children)roundLayout(i,t,u,h)}function isWholeNumber(e){const t=e-Math.floor(e);return t<1e-4||t>.9999}function roundValue(e,t,i,s){let n=e*t,a=n-Math.floor(n);return a<0&&(a+=1),n=a<1e-4?Math.floor(n):a>.9999||i?Math.ceil(n):s?Math.floor(n):Math.floor(n)+(a>=.4999?1:0),n/t}function parseDimension(e){if(void 0===e)return m;if("auto"===e)return _;if("number"==typeof e)return Number.isFinite(e)?pointValue(e):m;if("string"==typeof e&&e.endsWith("%"))return percentValue(parseFloat(e));const t=parseFloat(e);return isNaN(t)?m:pointValue(t)}function physicalEdge(e){switch(e){case a.Left:case a.Start:return 0;case a.Top:return 1;case a.Right:case a.End:return 2;case a.Bottom:return 3;default:return 0}}const N={Config:{create:createConfig,destroy(){}},Node:{create:e=>new Node(e),createDefault:()=>new Node,createWithConfig:e=>new Node(e),destroy(){}}};export function loadYoga(){return Promise.resolve(N)}export default N;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HOOK_EVENTS as e}from"
|
|
1
|
+
import{HOOK_EVENTS as e}from"src/entrypoints/agentSdkTypes.js";import{z as o}from"zod/v4";import{lazySchema as t}from"../utils/lazySchema.js";import{SHELL_TYPES as s}from"../utils/shell/shellProvider.js";const i=t(()=>o.string().optional().describe('Permission rule syntax to filter when this hook runs (e.g., "Bash(git *)"). Only runs if the tool call matches the pattern. Avoids spawning hooks for non-matching commands.'));export const HookCommandSchema=t(()=>{const{BashCommandHookSchema:e,PromptHookSchema:t,AgentHookSchema:r,HttpHookSchema:n}={BashCommandHookSchema:o.object({type:o.literal("command").describe("Shell command hook type"),command:o.string().describe("Shell command to execute"),if:i(),shell:o.enum(s).optional().describe("Shell interpreter. 'bash' uses your $SHELL (bash/zsh/sh); 'powershell' uses pwsh. Defaults to bash."),timeout:o.number().positive().optional().describe("Timeout in seconds for this specific command"),statusMessage:o.string().optional().describe("Custom status message to display in spinner while hook runs"),once:o.boolean().optional().describe("If true, hook runs once and is removed after execution"),async:o.boolean().optional().describe("If true, hook runs in background without blocking"),asyncRewake:o.boolean().optional().describe("If true, hook runs in background and wakes the model on exit code 2 (blocking error). Implies async.")}),PromptHookSchema:o.object({type:o.literal("prompt").describe("LLM prompt hook type"),prompt:o.string().describe("Prompt to evaluate with LLM. Use $ARGUMENTS placeholder for hook input JSON."),if:i(),timeout:o.number().positive().optional().describe("Timeout in seconds for this specific prompt evaluation"),model:o.string().optional().describe('Model to use for this prompt hook (e.g., "claude-sonnet-4-6"). If not specified, uses the default small fast model.'),statusMessage:o.string().optional().describe("Custom status message to display in spinner while hook runs"),once:o.boolean().optional().describe("If true, hook runs once and is removed after execution")}),HttpHookSchema:o.object({type:o.literal("http").describe("HTTP hook type"),url:o.string().url().describe("URL to POST the hook input JSON to"),if:i(),timeout:o.number().positive().optional().describe("Timeout in seconds for this specific request"),headers:o.record(o.string(),o.string()).optional().describe('Additional headers to include in the request. Values may reference environment variables using $VAR_NAME or ${VAR_NAME} syntax (e.g., "Authorization": "Bearer $MY_TOKEN"). Only variables listed in allowedEnvVars will be interpolated.'),allowedEnvVars:o.array(o.string()).optional().describe("Explicit list of environment variable names that may be interpolated in header values. Only variables listed here will be resolved; all other $VAR references are left as empty strings. Required for env var interpolation to work."),statusMessage:o.string().optional().describe("Custom status message to display in spinner while hook runs"),once:o.boolean().optional().describe("If true, hook runs once and is removed after execution")}),AgentHookSchema:o.object({type:o.literal("agent").describe("Agentic verifier hook type"),prompt:o.string().describe('Prompt describing what to verify (e.g. "Verify that unit tests ran and passed."). Use $ARGUMENTS placeholder for hook input JSON.'),if:i(),timeout:o.number().positive().optional().describe("Timeout in seconds for agent execution (default 60)"),model:o.string().optional().describe('Model to use for this agent hook (e.g., "claude-sonnet-4-6"). If not specified, uses Haiku.'),statusMessage:o.string().optional().describe("Custom status message to display in spinner while hook runs"),once:o.boolean().optional().describe("If true, hook runs once and is removed after execution")})};return o.discriminatedUnion("type",[e,t,r,n])});export const HookMatcherSchema=t(()=>o.object({matcher:o.string().optional().describe('String pattern to match (e.g. tool names like "Write")'),hooks:o.array(HookCommandSchema()).describe("List of hooks to execute when the matcher matches")}));export const HooksSchema=t(()=>o.partialRecord(o.enum(e),o.array(HookMatcherSchema())));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isFsInaccessible as e}from"../../utils/errors.js";import{getFsImplementation as t}from"../../utils/fsOperations.js";import{getSessionMemoryPath as o}from"../../utils/permissions/filesystem.js";import{sleep as n}from"../../utils/sleep.js";import{logEvent as
|
|
1
|
+
import{isFsInaccessible as e}from"../../utils/errors.js";import{getFsImplementation as t}from"../../utils/fsOperations.js";import{getSessionMemoryPath as o}from"../../utils/permissions/filesystem.js";import{sleep as n}from"../../utils/sleep.js";import{logEvent as s}from"../analytics/index.js";export const DEFAULT_SESSION_MEMORY_CONFIG={minimumMessageTokensToInit:1e4,minimumTokensBetweenUpdate:5e3,toolCallsBetweenUpdates:3};let i,r,a={...DEFAULT_SESSION_MEMORY_CONFIG},m=0,u=!1;export function getLastSummarizedMessageId(){return i}export function setLastSummarizedMessageId(e){i=e}export function markExtractionStarted(){r=Date.now()}export function markExtractionCompleted(){r=void 0}export async function waitForSessionMemoryExtraction(){const e=Date.now();for(;r;){if(Date.now()-r>6e4)return;if(Date.now()-e>15e3)return;await n(1e3)}}export async function getSessionMemoryContent(){const n=t(),i=o();try{const e=await n.readFile(i,{encoding:"utf-8"});return s("tengu_session_memory_loaded",{content_length:e.length}),e}catch(t){if(e(t))return null;throw t}}export function setSessionMemoryConfig(e){a={...a,...e}}export function getSessionMemoryConfig(){return{...a}}export function recordExtractionTokenCount(e){m=e}export function isSessionMemoryInitialized(){return u}export function markSessionMemoryInitialized(){u=!0}export function hasMetInitializationThreshold(e){return e>=a.minimumMessageTokensToInit}export function hasMetUpdateThreshold(e){return e-m>=a.minimumTokensBetweenUpdate}export function getToolCallsBetweenUpdates(){return a.toolCallsBetweenUpdates}export function resetSessionMemoryState(){a={...DEFAULT_SESSION_MEMORY_CONFIG},m=0,u=!1,i=void 0,r=void 0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@anthropic-ai/sdk/index.js";import{randomUUID as r}from"crypto";import{checkAndRefreshOAuthTokenIfNeeded as
|
|
1
|
+
import e from"@anthropic-ai/sdk/index.js";import{randomUUID as r}from"crypto";import{checkAndRefreshOAuthTokenIfNeeded as s,getAnthropicApiKey as o,getApiKeyFromApiKeyHelper as t,getClaudeAIOAuthTokens as n,getMiniMaxAccessToken as i,isClaudeAISubscriber as c,refreshAndGetAwsCredentials as a,refreshGcpCredentialsIfNeeded as E}from"src/utils/auth.js";import{getUserAgent as _}from"src/utils/http.js";import{getSmallFastModel as p}from"src/utils/model/model.js";import{getAPIProvider as A,isFirstPartyAnthropicBaseUrl as T}from"src/utils/model/providers.js";import{getConfiguredProviderBaseUrl as O}from"src/utils/model/providerBaseUrls.js";import{getProxyFetchOptions as C}from"src/utils/proxy.js";import{getIsNonInteractiveSession as D,getSessionId as l}from"../../bootstrap/state.js";import{getOauthConfig as u}from"../../constants/oauth.js";import{isDebugToStdErr as d,logForDebugging as R}from"../../utils/debug.js";import{getAWSRegion as I,getVertexRegionForModel as g,isEnvTruthy as S}from"../../utils/envUtils.js";function createStderrLogger(){return{error:(e,...r)=>console.error("[Anthropic SDK ERROR]",e,...r),warn:(e,...r)=>console.error("[Anthropic SDK WARN]",e,...r),info:(e,...r)=>console.error("[Anthropic SDK INFO]",e,...r),debug:(e,...r)=>console.error("[Anthropic SDK DEBUG]",e,...r)}}export async function getAnthropicClient({apiKey:m,maxRetries:U,model:h,fetchOverride:v,source:N}){const f=A(),P=process.env.CONTEXT_CODE_CONTAINER_ID??process.env.CLAUDE_CODE_CONTAINER_ID,L=process.env.CONTEXT_CODE_REMOTE_SESSION_ID??process.env.CLAUDE_CODE_REMOTE_SESSION_ID,K=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,H=function(){const e={},r=process.env.ANTHROPIC_CUSTOM_HEADERS;if(!r)return e;const s=r.split(/\n|\r\n/);for(const r of s){if(!r.trim())continue;const s=r.indexOf(":");if(-1===s)continue;const o=r.slice(0,s).trim(),t=r.slice(s+1).trim();o&&(e[o]=t)}return e}(),w={"x-app":"cli","User-Agent":_(),"X-Claude-Code-Session-Id":l(),...H,...P?{"x-claude-remote-container-id":P}:{},...L?{"x-claude-remote-session-id":L}:{},...K?{"x-client-app":K}:{}};R(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!H.Authorization}`),S(process.env.CONTEXT_CODE_ADDITIONAL_PROTECTION??process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)&&(w["x-anthropic-additional-protection"]="true"),R("[API:auth] OAuth token check starting"),await s(),R("[API:auth] OAuth token check complete"),"minimax"===f||c()||await async function(e,r){const s=process.env.ANTHROPIC_AUTH_TOKEN||await t(r);s&&(e.Authorization=`Bearer ${s}`)}(w,D());const x=function(e,s){const o=e??globalThis.fetch,t="firstParty"===A()&&T();return(e,n)=>{const i=new Headers(n?.headers);t&&!i.has(CLIENT_REQUEST_ID_HEADER)&&i.set(CLIENT_REQUEST_ID_HEADER,r());try{const r=e instanceof Request?e.url:String(e),o=i.get(CLIENT_REQUEST_ID_HEADER);R(`[API REQUEST] ${new URL(r).pathname}${o?` ${CLIENT_REQUEST_ID_HEADER}=${o}`:""} source=${s??"unknown"}`)}catch{}return o(e,{...n,headers:i})}}(v,N),k={defaultHeaders:w,maxRetries:U,timeout:parseInt(process.env.API_TIMEOUT_MS||String(6e5),10),dangerouslyAllowBrowser:!0,fetchOptions:C({forAnthropicAPI:!0}),...x&&{fetch:x}};if(S(process.env.CONTEXT_CODE_USE_BEDROCK)||S(process.env.CLAUDE_CODE_USE_BEDROCK)){const{AnthropicBedrock:e}=await import("@anthropic-ai/bedrock-sdk"),r=h===p()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:I(),s={...k,awsRegion:r,...(S(process.env.CONTEXT_CODE_SKIP_BEDROCK_AUTH)||S(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH))&&{skipAuth:!0},...d()&&{logger:createStderrLogger()}};if(process.env.AWS_BEARER_TOKEN_BEDROCK)s.skipAuth=!0,s.defaultHeaders={...s.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`};else if(!S(process.env.CONTEXT_CODE_SKIP_BEDROCK_AUTH)&&!S(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)){const e=await a();e&&(s.awsAccessKey=e.accessKeyId,s.awsSecretKey=e.secretAccessKey,s.awsSessionToken=e.sessionToken)}return new e(s)}if(S(process.env.CONTEXT_CODE_USE_FOUNDRY)||S(process.env.CLAUDE_CODE_USE_FOUNDRY)){const{AnthropicFoundry:e}=await import("@anthropic-ai/foundry-sdk");let r;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(S(process.env.CONTEXT_CODE_SKIP_FOUNDRY_AUTH)||S(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH))r=()=>Promise.resolve("");else{const{DefaultAzureCredential:e,getBearerTokenProvider:s}=await import("@azure/identity");r=s(new e,"https://cognitiveservices.azure.com/.default")}return new e({...k,...r&&{azureADTokenProvider:r},...d()&&{logger:createStderrLogger()}})}if(S(process.env.CONTEXT_CODE_USE_VERTEX)||S(process.env.CLAUDE_CODE_USE_VERTEX)){S(process.env.CONTEXT_CODE_SKIP_VERTEX_AUTH)||S(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)||await E();const[{AnthropicVertex:e},{GoogleAuth:r}]=await Promise.all([import("@anthropic-ai/vertex-sdk"),import("google-auth-library")]),s=process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project,o=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,t=S(process.env.CONTEXT_CODE_SKIP_VERTEX_AUTH)||S(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new r({scopes:["https://www.googleapis.com/auth/cloud-platform"],...s||o?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...k,region:g(h),googleAuth:t,...d()&&{logger:createStderrLogger()}})}const y=process.env.MINIMAX_BASE_URL||O("minimax")||"https://api.minimax.io/anthropic",B=i(),X={apiKey:"minimax"===f?B:c()?null:m||o(),authToken:"minimax"===f?B:c()?n()?.accessToken:void 0,..."minimax"===f?{baseURL:y}:{},..."ant"===process.env.USER_TYPE&&S(process.env.USE_STAGING_OAUTH)?{baseURL:u().BASE_API_URL}:{},...k,...d()&&{logger:createStderrLogger()}};return new e(X)}export const CLIENT_REQUEST_ID_HEADER="x-client-request-id";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as t}from"crypto";import{promises as e}from"fs";import{dirname as s,join as
|
|
1
|
+
import{createHash as t}from"crypto";import{promises as e}from"fs";import{dirname as s,join as a}from"path";import{getSessionId as n}from"../../bootstrap/state.js";import{getClaudeConfigHomeDir as o}from"../../utils/envUtils.js";import{jsonParse as i,jsonStringify as r}from"../../utils/slowOperations.js";const p=[],c=new Map;export function getLastApiRequests(){return[...p]}export function clearApiRequestCache(){p.length=0}export function clearDumpState(t){c.delete(t)}export function clearAllDumpState(){c.clear()}export function addApiRequestToCache(t){"ant"===process.env.USER_TYPE&&(p.push({timestamp:(new Date).toISOString(),request:t}),p.length>5&&p.shift())}export function getDumpPromptsPath(t){return a(o(),"dump-prompts",`${t??n()}.jsonl`)}function dumpRequest(a,n,o,p){try{const m=i(a);if(addApiRequestToCache(m),"ant"!==process.env.USER_TYPE)return;const l=[],u=m.messages??[],d=function(t){const e=t.tools,s=t.system,a="string"==typeof s?s.length:Array.isArray(s)?s.reduce((t,e)=>t+(e.text?.length??0),0):0,n=e?.map(t=>t.name??"").join(",")??"";return`${t.model}|${n}|${a}`}(m);if(!o.initialized||d!==o.lastInitFingerprint){const{messages:e,...s}=m,a=r(s),i=(c=a,t("sha256").update(c).digest("hex"));o.lastInitFingerprint=d,o.initialized?i!==o.lastInitDataHash&&(o.lastInitDataHash=i,l.push(`{"type":"system_update","timestamp":"${n}","data":${a}}`)):(o.initialized=!0,o.lastInitDataHash=i,l.push(`{"type":"init","timestamp":"${n}","data":${a}}`))}for(const t of u.slice(o.messageCountSeen))"user"===t.role&&l.push(r({type:"message",timestamp:n,data:t}));o.messageCountSeen=u.length,function(t,a){0!==a.length&&e.mkdir(s(t),{recursive:!0}).then(()=>e.appendFile(t,a.join("\n")+"\n")).catch(()=>{})}(p,l)}catch{}var c}export function createDumpPromptsFetch(t){const s=getDumpPromptsPath(t);return async(a,n)=>{const o=c.get(t)??{initialized:!1,messageCountSeen:0,lastInitDataHash:"",lastInitFingerprint:""};let p;c.set(t,o),"POST"===n?.method&&n.body&&(p=(new Date).toISOString(),setImmediate(dumpRequest,n.body,p,o,s));const m=await globalThis.fetch(a,n);if(p&&m.ok&&"ant"===process.env.USER_TYPE){const t=m.clone();(async()=>{try{const a=t.headers.get("content-type")?.includes("text/event-stream");let n;if(a&&t.body){const e=t.body.getReader(),s=new TextDecoder;let a="";try{for(;;){const{done:t,value:n}=await e.read();if(t)break;a+=s.decode(n,{stream:!0})}}finally{e.releaseLock()}const o=[];for(const t of a.split("\n\n"))for(const e of t.split("\n"))if(e.startsWith("data: ")&&"data: [DONE]"!==e)try{o.push(i(e.slice(6)))}catch{}n={stream:!0,chunks:o}}else n=await t.json();await e.appendFile(s,r({type:"response",timestamp:p,data:n})+"\n")}catch{}})()}return m}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=new Set(["UNABLE_TO_VERIFY_LEAF_SIGNATURE","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","CERT_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CERT_REVOKED","CERT_REJECTED","CERT_UNTRUSTED","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","CERT_CHAIN_TOO_LONG","PATH_LENGTH_EXCEEDED","ERR_TLS_CERT_ALTNAME_INVALID","HOSTNAME_MISMATCH","ERR_TLS_HANDSHAKE_TIMEOUT","ERR_SSL_WRONG_VERSION_NUMBER","ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC"]);export function extractConnectionErrorDetails(t){if(!t||"object"!=typeof t)return null;let r=t
|
|
1
|
+
const e=new Set(["UNABLE_TO_VERIFY_LEAF_SIGNATURE","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","CERT_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CERT_REVOKED","CERT_REJECTED","CERT_UNTRUSTED","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","CERT_CHAIN_TOO_LONG","PATH_LENGTH_EXCEEDED","ERR_TLS_CERT_ALTNAME_INVALID","HOSTNAME_MISMATCH","ERR_TLS_HANDSHAKE_TIMEOUT","ERR_SSL_WRONG_VERSION_NUMBER","ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC"]);export function extractConnectionErrorDetails(t){if(!t||"object"!=typeof t)return null;let r=t,n=0;for(;r&&n<5;){if(r instanceof Error&&"code"in r&&"string"==typeof r.code){const t=r.code,n=e.has(t);return{code:t,message:r.message,isSSLError:n}}if(!(r instanceof Error&&"cause"in r&&r.cause!==r))break;r=r.cause,n++}return null}export function getSSLErrorHint(e){const t=extractConnectionErrorDetails(e);return t?.isSSLError?`SSL certificate error (${t.code}). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run /doctor for details.`:null}function sanitizeMessageHTML(e){if(e.includes("<!DOCTYPE html")||e.includes("<html")){const t=e.match(/<title>([^<]+)<\/title>/);return t&&t[1]?t[1].trim():""}return e}export function sanitizeAPIError(e){const t=e.message;return t?sanitizeMessageHTML(t):""}export function formatAPIError(e){const t=extractConnectionErrorDetails(e);if(t){const{code:e,isSSLError:r}=t;if("ETIMEDOUT"===e)return"Request timed out. Check your internet connection and proxy settings";if(r)switch(e){case"UNABLE_TO_VERIFY_LEAF_SIGNATURE":case"UNABLE_TO_GET_ISSUER_CERT":case"UNABLE_TO_GET_ISSUER_CERT_LOCALLY":return"Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates";case"CERT_HAS_EXPIRED":return"Unable to connect to API: SSL certificate has expired";case"CERT_REVOKED":return"Unable to connect to API: SSL certificate has been revoked";case"DEPTH_ZERO_SELF_SIGNED_CERT":case"SELF_SIGNED_CERT_IN_CHAIN":return"Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates";case"ERR_TLS_CERT_ALTNAME_INVALID":case"HOSTNAME_MISMATCH":return"Unable to connect to API: SSL certificate hostname mismatch";case"CERT_NOT_YET_VALID":return"Unable to connect to API: SSL certificate is not yet valid";default:return`Unable to connect to API: SSL error (${e})`}}if("Connection error."===e.message)return t?.code?`Unable to connect to API (${t.code})`:"Unable to connect to API. Check your internet connection";if(!e.message)return function(e){if("object"!=typeof(t=e)||null===t||!("error"in t)||"object"!=typeof t.error||null===t.error)return null;var t;const r=e.error,n=r?.error?.message;if("string"==typeof n&&n.length>0){const e=sanitizeMessageHTML(n);if(e.length>0)return e}const o=r?.message;if("string"==typeof o&&o.length>0){const e=sanitizeMessageHTML(o);if(e.length>0)return e}return null}(e)??`API error (status ${e.status??"unknown"})`;const r=sanitizeAPIError(e);return r!==e.message&&r.length>0?r:e.message}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createPatch as e}from"diff";import{mkdir as t,writeFile as a}from"fs/promises";import{join as o}from"path";import{logForDebugging as n}from"
|
|
1
|
+
import{createPatch as e}from"diff";import{mkdir as t,writeFile as a}from"fs/promises";import{join as o}from"path";import{logForDebugging as n}from"src/utils/debug.js";import{djb2Hash as s}from"src/utils/hash.js";import{logError as r}from"src/utils/log.js";import{getClaudeTempDir as l}from"src/utils/permissions/filesystem.js";import{jsonStringify as d}from"src/utils/slowOperations.js";import{logEvent as c}from"../analytics/index.js";const h=new Map,i=["repl_main_thread","sdk","agent:custom","agent:default","agent:builtin"];export const CACHE_TTL_1HOUR_MS=36e5;function getTrackingKey(e,t){if("compact"===e)return"repl_main_thread";for(const a of i)if(e.startsWith(a))return t||e;return null}function stripCacheControl(e){return e.map(e=>{if(!("cache_control"in e))return e;const{cache_control:t,...a}=e;return a})}function computeHash(e){const t=d(e);if("undefined"!=typeof Bun){const e=Bun.hash(t);return"bigint"==typeof e?Number(0xffffffffn&e):e}return s(t)}function sanitizeToolName(e){return e.startsWith("mcp__")?"mcp":e}export function recordPromptState(e){try{const{system:t,toolSchemas:a,querySource:o,model:n,agentId:s,fastMode:r,globalCacheStrategy:l="",betas:c=[],autoModeActive:i=!1,isUsingOverage:g=!1,cachedMCEnabled:u=!1,effortValue:m,extraBodyParams:C}=e,f=getTrackingKey(o,s);if(!f)return;const p=stripCacheControl(t),y=stripCacheControl(a),b=computeHash(p),v=computeHash(y),T=computeHash(t.map(e=>"cache_control"in e?e.cache_control:null)),M=a.map(e=>"name"in e?e.name:"unknown"),computeToolHashes=()=>function(e,t){const a={};for(let o=0;o<e.length;o++)a[t[o]??`__idx_${o}`]=computeHash(e[o]);return a}(y,M),S=function(e){let t=0;for(const a of e)t+=a.text.length;return t}(t),lazyDiffableContent=()=>function(e,t,a){const o=e.map(e=>e.text).join("\n\n"),n=t.map(e=>{if(!("name"in e))return"unknown";const t="description"in e?e.description:"",a="input_schema"in e?d(e.input_schema):"";return`${e.name}\n description: ${t}\n input_schema: ${a}`}).sort().join("\n\n");return`Model: ${a}\n\n=== System Prompt ===\n\n${o}\n\n=== Tools (${t.length}) ===\n\n${n}\n`}(t,a,n),$=r??!1,k=[...c].sort(),x=void 0===m?"":String(m),H=void 0===C?0:computeHash(C),w=h.get(f);if(!w){for(;h.size>=10;){const e=h.keys().next().value;void 0!==e&&h.delete(e)}return void h.set(f,{systemHash:b,toolsHash:v,cacheControlHash:T,toolNames:M,systemCharCount:S,model:n,fastMode:$,globalCacheStrategy:l,betas:k,autoModeActive:i,isUsingOverage:g,cachedMCEnabled:u,effortValue:x,extraBodyHash:H,callCount:1,pendingChanges:null,prevCacheReadTokens:null,cacheDeletionsPending:!1,buildDiffableContent:lazyDiffableContent,perToolHashes:computeToolHashes()})}w.callCount++;const B=b!==w.systemHash,_=v!==w.toolsHash,j=n!==w.model,D=$!==w.fastMode,P=T!==w.cacheControlHash,A=l!==w.globalCacheStrategy,E=k.length!==w.betas.length||k.some((e,t)=>e!==w.betas[t]),R=i!==w.autoModeActive,N=g!==w.isUsingOverage,O=u!==w.cachedMCEnabled,V=x!==w.effortValue,G=H!==w.extraBodyHash;if(B||_||j||D||P||A||E||R||N||O||V||G){const e=new Set(w.toolNames),t=new Set(M),a=new Set(w.betas),o=new Set(k),s=M.filter(t=>!e.has(t)),r=w.toolNames.filter(e=>!t.has(e)),d=[];if(_){const t=computeToolHashes();for(const a of M)e.has(a)&&t[a]!==w.perToolHashes[a]&&d.push(a);w.perToolHashes=t}w.pendingChanges={systemPromptChanged:B,toolSchemasChanged:_,modelChanged:j,fastModeChanged:D,cacheControlChanged:P,globalCacheStrategyChanged:A,betasChanged:E,autoModeChanged:R,overageChanged:N,cachedMCChanged:O,effortChanged:V,extraBodyChanged:G,addedToolCount:s.length,removedToolCount:r.length,addedTools:s,removedTools:r,changedToolSchemas:d,systemCharDelta:S-w.systemCharCount,previousModel:w.model,newModel:n,prevGlobalCacheStrategy:w.globalCacheStrategy,newGlobalCacheStrategy:l,addedBetas:k.filter(e=>!a.has(e)),removedBetas:w.betas.filter(e=>!o.has(e)),prevEffortValue:w.effortValue,newEffortValue:x,buildPrevDiffableContent:w.buildDiffableContent}}else w.pendingChanges=null;w.systemHash=b,w.toolsHash=v,w.cacheControlHash=T,w.toolNames=M,w.systemCharCount=S,w.model=n,w.fastMode=$,w.globalCacheStrategy=l,w.betas=k,w.autoModeActive=i,w.isUsingOverage=g,w.cachedMCEnabled=u,w.effortValue=x,w.extraBodyHash=H,w.buildDiffableContent=lazyDiffableContent}catch(e){r(e)}}export async function checkResponseForCacheBreak(s,d,i,g,u,m){try{const r=getTrackingKey(s,u);if(!r)return;const C=h.get(r);if(!C)return;if(C.model.includes("haiku"))return;const f=C.prevCacheReadTokens;C.prevCacheReadTokens=d;const p=g.findLast(e=>"assistant"===e.type),y=p?Date.now()-new Date(p.timestamp).getTime():null;if(null===f)return;const b=C.pendingChanges;if(C.cacheDeletionsPending)return C.cacheDeletionsPending=!1,n(`[PROMPT CACHE] cache deletion applied, cache read: ${f} → ${d} (expected drop)`),void(C.pendingChanges=null);if(d>=.95*f||f-d<2e3)return void(C.pendingChanges=null);const v=[];if(b){if(b.modelChanged&&v.push(`model changed (${b.previousModel} → ${b.newModel})`),b.systemPromptChanged){const e=b.systemCharDelta,t=0===e?"":e>0?` (+${e} chars)`:` (${e} chars)`;v.push(`system prompt changed${t}`)}if(b.toolSchemasChanged){const e=b.addedToolCount>0||b.removedToolCount>0?` (+${b.addedToolCount}/-${b.removedToolCount} tools)`:" (tool prompt/schema changed, same tool set)";v.push(`tools changed${e}`)}if(b.fastModeChanged&&v.push("fast mode toggled"),b.globalCacheStrategyChanged&&v.push(`global cache strategy changed (${b.prevGlobalCacheStrategy||"none"} → ${b.newGlobalCacheStrategy||"none"})`),!b.cacheControlChanged||b.globalCacheStrategyChanged||b.systemPromptChanged||v.push("cache_control changed (scope or TTL)"),b.betasChanged){const e=[b.addedBetas.length?`+${b.addedBetas.join(",")}`:"",b.removedBetas.length?`-${b.removedBetas.join(",")}`:""].filter(Boolean).join(" ");v.push("betas changed"+(e?` (${e})`:""))}b.autoModeChanged&&v.push("auto mode toggled"),b.overageChanged&&v.push("overage state changed (TTL latched, no flip)"),b.cachedMCChanged&&v.push("cached microcompact toggled"),b.effortChanged&&v.push(`effort changed (${b.prevEffortValue||"default"} → ${b.newEffortValue||"default"})`),b.extraBodyChanged&&v.push("extra body params changed")}const T=null!==y&&y>3e5,M=null!==y&&y>36e5;let S,$;S=v.length>0?v.join(", "):M?"possible 1h TTL expiry (prompt unchanged)":T?"possible 5min TTL expiry (prompt unchanged)":null!==y?"likely server-side (prompt unchanged, <5min gap)":"unknown cause",c("tengu_prompt_cache_break",{systemPromptChanged:b?.systemPromptChanged??!1,toolSchemasChanged:b?.toolSchemasChanged??!1,modelChanged:b?.modelChanged??!1,fastModeChanged:b?.fastModeChanged??!1,cacheControlChanged:b?.cacheControlChanged??!1,globalCacheStrategyChanged:b?.globalCacheStrategyChanged??!1,betasChanged:b?.betasChanged??!1,autoModeChanged:b?.autoModeChanged??!1,overageChanged:b?.overageChanged??!1,cachedMCChanged:b?.cachedMCChanged??!1,effortChanged:b?.effortChanged??!1,extraBodyChanged:b?.extraBodyChanged??!1,addedToolCount:b?.addedToolCount??0,removedToolCount:b?.removedToolCount??0,systemCharDelta:b?.systemCharDelta??0,addedTools:(b?.addedTools??[]).map(sanitizeToolName).join(","),removedTools:(b?.removedTools??[]).map(sanitizeToolName).join(","),changedToolSchemas:(b?.changedToolSchemas??[]).map(sanitizeToolName).join(","),addedBetas:(b?.addedBetas??[]).join(","),removedBetas:(b?.removedBetas??[]).join(","),prevGlobalCacheStrategy:b?.prevGlobalCacheStrategy??"",newGlobalCacheStrategy:b?.newGlobalCacheStrategy??"",callNumber:C.callCount,prevCacheReadTokens:f,cacheReadTokens:d,cacheCreationTokens:i,timeSinceLastAssistantMsg:y??-1,lastAssistantMsgOver5minAgo:T,lastAssistantMsgOver1hAgo:M,requestId:m??""}),b?.buildPrevDiffableContent&&($=await async function(n,s){try{const r=function(){let e="";for(let t=0;t<4;t++)e+="abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())];return o(l(),`cache-break-${e}.diff`)}();await t(l(),{recursive:!0});const d=e("prompt-state",n,s,"before","after");return await a(r,d),r}catch{return}}(b.buildPrevDiffableContent(),C.buildDiffableContent()));const k=$?`, diff: ${$}`:"",x=`[PROMPT CACHE BREAK] ${S} [source=${s}, call #${C.callCount}, cache read: ${f} → ${d}, creation: ${i}${k}]`;n(x,{level:"warn"}),C.pendingChanges=null}catch(e){r(e)}}export function notifyCacheDeletion(e,t){const a=getTrackingKey(e,t),o=a?h.get(a):void 0;o&&(o.cacheDeletionsPending=!0)}export function notifyCompaction(e,t){const a=getTrackingKey(e,t),o=a?h.get(a):void 0;o&&(o.prevCacheReadTokens=null)}export function cleanupAgentTracking(e){h.delete(e)}export function resetPromptCacheBreakDetection(){h.clear()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{feature as e}from"
|
|
1
|
+
import{feature as e}from"bun:bundle";import{APIConnectionError as t,APIError as r,APIUserAbortError as s}from"@anthropic-ai/sdk/index.js";import{isAwsCredentialsProviderError as o}from"src/utils/aws.js";import{logForDebugging as n}from"src/utils/debug.js";import{logError as a}from"src/utils/log.js";import{createSystemAPIErrorMessage as i}from"src/utils/messages.js";import{getAPIProviderForStatsig as l}from"src/utils/model/providers.js";import{clearApiKeyHelperCache as u,clearAwsCredentialsCache as c,clearGcpCredentialsCache as d,getClaudeAIOAuthTokens as f,handleOAuth401Error as E,isClaudeAISubscriber as m,isEnterpriseSubscriber as p}from"../../utils/auth.js";import{isEnvTruthy as _}from"../../utils/envUtils.js";import{errorMessage as g}from"../../utils/errors.js";import{handleFastModeOverageRejection as h,handleFastModeRejectedByAPI as R,isFastModeCooldown as C,isFastModeEnabled as y,triggerFastModeCooldown as k}from"../../utils/fastMode.js";import{isNonCustomOpusModel as M}from"../../utils/model/model.js";import{disableKeepAlive as T}from"../../utils/proxy.js";import{sleep as A}from"../../utils/sleep.js";import{getFeatureValue_CACHED_MAY_BE_STALE as x}from"../analytics/growthbook.js";import{logEvent as v}from"../analytics/index.js";import{checkMockRateLimitError as b,isMockRateLimitError as w}from"../rateLimitMocking.js";import{REPEATED_529_ERROR_MESSAGE as O}from"./errors.js";import{extractConnectionErrorDetails as D}from"./errorUtils.js";const abortError=()=>new s;export const BASE_DELAY_MS=500;const S=new Set(["repl_main_thread","repl_main_thread:outputStyle:custom","repl_main_thread:outputStyle:Explanatory","repl_main_thread:outputStyle:Learning","sdk","agent:custom","agent:default","agent:builtin","compact","hook_agent","hook_prompt","verification_agent","side_question","auto_mode",...e("BASH_CLASSIFIER")?["bash_classifier"]:[]]);function shouldRetry529(e){return void 0===e||S.has(e)}const N=3e5,P=216e5;function isPersistentRetryEnabled(){return!!e("UNATTENDED_RETRY")&&(_(process.env.CONTEXT_CODE_UNATTENDED_RETRY)||_(process.env.CLAUDE_CODE_UNATTENDED_RETRY))}function isTransientCapacityError(e){return is529Error(e)||e instanceof r&&429===e.status}function isStaleConnectionError(e){if(!(e instanceof t))return!1;const r=D(e);return"ECONNRESET"===r?.code||"EPIPE"===r?.code}export class CannotRetryError extends Error{originalError;retryContext;constructor(e,t){super(g(e)),this.originalError=e,this.retryContext=t,this.name="RetryError",e instanceof Error&&e.stack&&(this.stack=e.stack)}}export class FallbackTriggeredError extends Error{originalModel;fallbackModel;constructor(e,t){super(`Model fallback triggered: ${e} -> ${t}`),this.originalModel=e,this.fallbackModel=t,this.name="FallbackTriggeredError"}}export async function*withRetry(e,t,o){const u=function(e){return e.maxRetries??getDefaultMaxRetries()}(o),c={model:o.model,thinkingConfig:o.thinkingConfig,...y()&&{fastMode:o.fastMode}};let d,p=null,_=o.initialConsecutive529Errors??0,w=0;for(let D=1;D<=u+1;D++){if(o.signal?.aborted)throw new s;const S=!!y()&&c.fastMode&&!C();try{if("ant"===process.env.USER_TYPE){const e=b(c.model,S);if(e)throw e}const s=isStaleConnectionError(d);if(s&&x("tengu_disable_keepalive_on_econnreset",!1)&&(n("Stale connection (ECONNRESET/EPIPE) — disabling keep-alive for retry"),T()),null===p||d instanceof r&&401===d.status||isOAuthTokenRevokedError(d)||isBedrockAuthError(d)||isVertexAuthError(d)||s){if(d instanceof r&&401===d.status||isOAuthTokenRevokedError(d)){const e=f()?.accessToken;e&&await E(e)}p=await e()}return await t(p,D,c)}catch(e){if(d=e,n(`API error (attempt ${D}/${u+1}): ${e instanceof r?`${e.status} ${e.message}`:g(e)}`,{level:"error"}),S&&!isPersistentRetryEnabled()&&e instanceof r&&(429===e.status||is529Error(e))){const t=e.headers?.get("anthropic-ratelimit-unified-overage-disabled-reason");if(null!=t){h(t),c.fastMode=!1;continue}const r=getRetryAfterMs(e);if(null!==r&&r<j){await A(r,o.signal,{abortError});continue}const s=Math.max(r??L,I),n=is529Error(e)?"overloaded":"rate_limit";k(Date.now()+s,n),y()&&(c.fastMode=!1);continue}if(S&&isFastModeNotEnabledError(e)){R(),c.fastMode=!1;continue}if(is529Error(e)&&!shouldRetry529(o.querySource))throw v("tengu_api_529_background_dropped",{query_source:o.querySource}),new CannotRetryError(e,c);if(is529Error(e)&&(process.env.FALLBACK_FOR_ALL_PRIMARY_MODELS||!m()&&M(o.model))&&(_++,_>=3)){if(o.fallbackModel)throw v("tengu_api_opus_fallback_triggered",{original_model:o.model,fallback_model:o.fallbackModel,provider:l()}),new FallbackTriggeredError(o.model,o.fallbackModel);if("external"===process.env.USER_TYPE&&!process.env.IS_SANDBOX&&!isPersistentRetryEnabled())throw v("tengu_api_custom_529_overloaded_error",{}),new CannotRetryError(new Error(O),c)}const t=isPersistentRetryEnabled()&&isTransientCapacityError(e);if(D>u&&!t)throw new CannotRetryError(e,c);if(!(handleAwsCredentialError(e)||handleGcpCredentialError(e)||e instanceof r&&shouldRetry(e)))throw new CannotRetryError(e,c);if(e instanceof r){const t=parseMaxTokensContextOverflowError(e);if(t){const{inputTokens:r,contextLimit:s}=t,o=1e3,n=Math.max(0,s-r-o);if(n<3e3)throw a(new Error(`availableContext ${n} is less than FLOOR_OUTPUT_TOKENS 3000`)),e;const i=("enabled"===c.thinkingConfig.type?c.thinkingConfig.budgetTokens:0)+1,l=Math.max(3e3,n,i);c.maxTokensOverride=l,v("tengu_max_tokens_context_overflow_adjustment",{inputTokens:r,contextLimit:s,adjustedMaxTokens:l,attempt:D});continue}}const f=getRetryAfter(e);let E;t&&e instanceof r&&429===e.status?(w++,E=getRateLimitResetDelayMs(e)??Math.min(getRetryDelay(w,f,N),P)):t?(w++,E=Math.min(getRetryDelay(w,f,N),P)):E=getRetryDelay(D,f);const p=t?w:D;if(v("tengu_api_retry",{attempt:p,delayMs:E,error:e.message,status:e.status,provider:l()}),t){E>6e4&&v("tengu_api_persistent_retry_wait",{status:e.status,delayMs:E,attempt:p,provider:l()});let t=E;for(;t>0;){if(o.signal?.aborted)throw new s;e instanceof r&&(yield i(e,t,p,u));const n=Math.min(t,3e4);await A(n,o.signal,{abortError}),t-=n}D>=u&&(D=u)}else e instanceof r&&(yield i(e,E,D,u)),await A(E,o.signal,{abortError})}}throw new CannotRetryError(d,c)}function getRetryAfter(e){return(e.headers?.["retry-after"]||e.headers?.get?.("retry-after"))??null}export function getRetryDelay(e,t,r=32e3){if(t){const e=parseInt(t,10);if(!isNaN(e))return 1e3*e}const s=Math.min(500*Math.pow(2,e-1),r);return s+.25*Math.random()*s}export function parseMaxTokensContextOverflowError(e){if(400!==e.status||!e.message)return;if(!e.message.includes("input length and `max_tokens` exceed context limit"))return;const t=e.message.match(/input length and `max_tokens` exceed context limit: (\d+) \+ (\d+) > (\d+)/);if(!t||4!==t.length)return;if(!t[1]||!t[2]||!t[3])return void a(new Error("Unable to parse max_tokens from max_tokens exceed context limit error message"));const r=parseInt(t[1],10),s=parseInt(t[2],10),o=parseInt(t[3],10);return isNaN(r)||isNaN(s)||isNaN(o)?void 0:{inputTokens:r,maxTokens:s,contextLimit:o}}function isFastModeNotEnabledError(e){return e instanceof r&&400===e.status&&(e.message?.includes("Fast mode is not enabled")??!1)}export function is529Error(e){return e instanceof r&&(529===e.status||(e.message?.includes('"type":"overloaded_error"')??!1))}function isOAuthTokenRevokedError(e){return e instanceof r&&403===e.status&&(e.message?.includes("OAuth token has been revoked")??!1)}function isBedrockAuthError(e){return!(!_(process.env.CONTEXT_CODE_USE_BEDROCK)&&!_(process.env.CLAUDE_CODE_USE_BEDROCK)||!(o(e)||e instanceof r&&403===e.status))}function handleAwsCredentialError(e){return!!isBedrockAuthError(e)&&(c(),!0)}function isVertexAuthError(e){if(_(process.env.CONTEXT_CODE_USE_VERTEX)||_(process.env.CLAUDE_CODE_USE_VERTEX)){if(function(e){if(!(e instanceof Error))return!1;const t=e.message;return t.includes("Could not load the default credentials")||t.includes("Could not refresh access token")||t.includes("invalid_grant")}(e))return!0;if(e instanceof r&&401===e.status)return!0}return!1}function handleGcpCredentialError(e){return!!isVertexAuthError(e)&&(d(),!0)}function shouldRetry(e){if(w(e))return!1;if(isPersistentRetryEnabled()&&isTransientCapacityError(e))return!0;if((_(process.env.CONTEXT_CODE_REMOTE)||_(process.env.CLAUDE_CODE_REMOTE))&&(401===e.status||403===e.status))return!0;if(e.message?.includes('"type":"overloaded_error"'))return!0;if(parseMaxTokensContextOverflowError(e))return!0;if(function(e){if(!(e instanceof r))return!1;const t=e.message?.toLowerCase()??"";return t.includes("insufficient balance")||t.includes("(1008)")}(e))return!1;const s=e.headers?.get("x-should-retry");if("true"===s&&(!m()||p()))return!0;if("false"===s){const t=void 0!==e.status&&e.status>=500;if("ant"!==process.env.USER_TYPE||!t)return!1}return e instanceof t||!!e.status&&(408===e.status||409===e.status||(429===e.status?!m()||p():401===e.status?(u(),!0):!!isOAuthTokenRevokedError(e)||!!(e.status&&e.status>=500)))}export function getDefaultMaxRetries(){const e=process.env.CONTEXT_CODE_MAX_RETRIES;return e?parseInt(e,10):10}const L=18e5,j=2e4,I=6e5;function getRetryAfterMs(e){const t=getRetryAfter(e);if(t){const e=parseInt(t,10);if(!isNaN(e))return 1e3*e}return null}function getRateLimitResetDelayMs(e){const t=e.headers?.get?.("anthropic-ratelimit-unified-reset");if(!t)return null;const r=Number(t);if(!Number.isFinite(r))return null;const s=1e3*r-Date.now();return s<=0?null:Math.min(s,P)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdir as t,readFile as
|
|
1
|
+
import{mkdir as t,readFile as i,stat as o,unlink as s,utimes as a,writeFile as r}from"fs/promises";import{join as e}from"path";import{getOriginalCwd as n}from"../../bootstrap/state.js";import{getAutoMemPath as c}from"../../memdir/paths.js";import{logForDebugging as l}from"../../utils/debug.js";import{isProcessRunning as m}from"../../utils/genericProcessUtils.js";import{listCandidates as u}from"../../utils/listSessionsImpl.js";import{getProjectDir as d}from"../../utils/sessionStorage.js";function lockPath(){return e(c(),".consolidate-lock")}export async function readLastConsolidatedAt(){try{return(await o(lockPath())).mtimeMs}catch{return 0}}export async function tryAcquireConsolidationLock(){const s=lockPath();let a,e,n;try{const[t,r]=await Promise.all([o(s),i(s,"utf8")]);a=t.mtimeMs;const n=parseInt(r.trim(),10);e=Number.isFinite(n)?n:void 0}catch{}if(void 0!==a&&Date.now()-a<36e5&&void 0!==e&&m(e))return l(`[autoDream] lock held by live PID ${e} (mtime ${Math.round((Date.now()-a)/1e3)}s ago)`),null;await t(c(),{recursive:!0}),await r(s,String(process.pid));try{n=await i(s,"utf8")}catch{return null}return parseInt(n.trim(),10)!==process.pid?null:a??0}export async function rollbackConsolidationLock(t){const i=lockPath();try{if(0===t)return void await s(i);await r(i,"");const o=t/1e3;await a(i,o,o)}catch(t){l(`[autoDream] rollback failed: ${t.message} — next trigger delayed to minHours`)}}export async function listSessionsTouchedSince(t){const i=d(n());return(await u(i,!0)).filter(i=>i.mtime>t).map(t=>t.sessionId)}export async function recordConsolidation(){try{await t(c(),{recursive:!0}),await r(lockPath(),String(process.pid))}catch(t){l(`[autoDream] recordConsolidation write failed: ${t.message}`)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ElicitationCompleteNotificationSchema as i,ElicitRequestSchema as t}from"@modelcontextprotocol/sdk/types.js";import{executeElicitationHooks as e,executeElicitationResultHooks as o,executeNotificationHooks as n}from"../../utils/hooks.js";import{logMCPDebug as a,logMCPError as r}from"../../utils/log.js";import{jsonStringify as c}from"../../utils/slowOperations.js";import{logEvent as s}from"../analytics/index.js";export function registerElicitationHandler(e,o,l){try{e.setRequestHandler(t,async(i,t)=>{a(o,`Received elicitation request: ${c(i)}`);const e="url"===i.params.mode?"url":"form";s("tengu_mcp_elicitation_shown",{mode:e});try{const n=await runElicitationHooks(o,i.params,t.signal);if(n)return a(o,`Elicitation resolved by hook: ${c(n)}`),s("tengu_mcp_elicitation_response",{mode:e,action:n.action}),n;const r="url"===e&&"elicitationId"in i.params?i.params.elicitationId:void 0,u=new Promise(n=>{const onAbort=()=>{n({action:"cancel"})};if(t.signal.aborted)return void onAbort();const a=r?{actionLabel:"Skip confirmation"}:void 0;l(r=>({...r,elicitation:{queue:[...r.elicitation.queue,{serverName:o,requestId:t.requestId,params:i.params,signal:t.signal,waitingState:a,respond:i=>{t.signal.removeEventListener("abort",onAbort),s("tengu_mcp_elicitation_response",{mode:e,action:i.action}),n(i)}}]}})),t.signal.addEventListener("abort",onAbort,{once:!0})}),m=await u;a(o,`Elicitation response: ${c(m)}`)
|
|
1
|
+
import{ElicitationCompleteNotificationSchema as i,ElicitRequestSchema as t}from"@modelcontextprotocol/sdk/types.js";import{executeElicitationHooks as e,executeElicitationResultHooks as o,executeNotificationHooks as n}from"../../utils/hooks.js";import{logMCPDebug as a,logMCPError as r}from"../../utils/log.js";import{jsonStringify as c}from"../../utils/slowOperations.js";import{logEvent as s}from"../analytics/index.js";export function registerElicitationHandler(e,o,l){try{e.setRequestHandler(t,async(i,t)=>{a(o,`Received elicitation request: ${c(i)}`);const e="url"===i.params.mode?"url":"form";s("tengu_mcp_elicitation_shown",{mode:e});try{const n=await runElicitationHooks(o,i.params,t.signal);if(n)return a(o,`Elicitation resolved by hook: ${c(n)}`),s("tengu_mcp_elicitation_response",{mode:e,action:n.action}),n;const r="url"===e&&"elicitationId"in i.params?i.params.elicitationId:void 0,u=new Promise(n=>{const onAbort=()=>{n({action:"cancel"})};if(t.signal.aborted)return void onAbort();const a=r?{actionLabel:"Skip confirmation"}:void 0;l(r=>({...r,elicitation:{queue:[...r.elicitation.queue,{serverName:o,requestId:t.requestId,params:i.params,signal:t.signal,waitingState:a,respond:i=>{t.signal.removeEventListener("abort",onAbort),s("tengu_mcp_elicitation_response",{mode:e,action:i.action}),n(i)}}]}})),t.signal.addEventListener("abort",onAbort,{once:!0})}),m=await u;return a(o,`Elicitation response: ${c(m)}`),await runElicitationResultHooks(o,m,t.signal,e,r)}catch(i){return r(o,`Elicitation error: ${i}`),{action:"cancel"}}}),e.setNotificationHandler(i,i=>{const{elicitationId:t}=i.params;a(o,`Received elicitation completion notification: ${t}`),n({message:`MCP server "${o}" confirmed elicitation ${t} complete`,notificationType:"elicitation_complete"});let e=!1;l(i=>{const n=function(i,t,e){return i.findIndex(i=>i.serverName===t&&"url"===i.params.mode&&"elicitationId"in i.params&&i.params.elicitationId===e)}(i.elicitation.queue,o,t);if(-1===n)return i;e=!0;const a=[...i.elicitation.queue];return a[n]={...a[n],completed:!0},{...i,elicitation:{queue:a}}}),e||a(o,`Ignoring completion notification for unknown elicitation: ${t}`)})}catch{return}}export async function runElicitationHooks(i,t,o){try{const n="url"===t.mode?"url":"form",a="url"in t?t.url:void 0,r="elicitationId"in t?t.elicitationId:void 0,{elicitationResponse:c,blockingError:s}=await e({serverName:i,message:t.message,requestedSchema:"requestedSchema"in t?t.requestedSchema:void 0,signal:o,mode:n,url:a,elicitationId:r});return s?{action:"decline"}:c?{action:c.action,content:c.content}:void 0}catch(t){return void r(i,`Elicitation hook error: ${t}`)}}export async function runElicitationResultHooks(i,t,e,a,c){try{const{elicitationResultResponse:r,blockingError:s}=await o({serverName:i,action:t.action,content:t.content,signal:e,mode:a,elicitationId:c});if(s)return n({message:`Elicitation response for server "${i}": decline`,notificationType:"elicitation_response"}),{action:"decline"};const l=r?{action:r.action,content:r.content??t.content}:t;return n({message:`Elicitation response for server "${i}": ${l.action}`,notificationType:"elicitation_response"}),l}catch(e){return r(i,`ElicitationResult hook error: ${e}`),n({message:`Elicitation response for server "${i}": ${t.action}`,notificationType:"elicitation_response"}),t}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeNameForMCP as e}from"./normalization.js";export function mcpInfoFromString(e){const
|
|
1
|
+
import{normalizeNameForMCP as e}from"./normalization.js";export function mcpInfoFromString(e){const o=e.split("__"),[r,t,...n]=o;return"mcp"===r&&t?{serverName:t,toolName:n.length>0?n.join("__"):void 0}:null}export function getMcpPrefix(o){return`mcp__${e(o)}__`}export function buildMcpToolName(o,r){return`${getMcpPrefix(o)}${e(r)}`}export function getToolNameForPermissionCheck(e){return e.mcpInfo?buildMcpToolName(e.mcpInfo.serverName,e.mcpInfo.toolName):e.name}export function getMcpDisplayName(o,r){const t=`mcp__${e(r)}__`;return o.replace(t,"")}export function extractMcpToolDisplayName(e){let o=e.replace(/\s*\(MCP\)\s*$/,"");o=o.trim();const r=o.indexOf(" - ");return-1!==r?o.substring(r+3).trim():o}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createServer as t}from"http";import{getPlatform as r}from"../../utils/platform.js";const o="windows"===r()?{min:39152,max:49151}:{min:49152,max:65535}
|
|
1
|
+
import{createServer as t}from"http";import{getPlatform as r}from"../../utils/platform.js";const o="windows"===r()?{min:39152,max:49151}:{min:49152,max:65535};export function buildRedirectUri(t=3118){return`http://localhost:${t}/callback`}export async function findAvailablePort(){const r=function(){const t=parseInt(process.env.MCP_OAUTH_CALLBACK_PORT||"",10);return t>0?t:void 0}();if(r)return r;const{min:n,max:e}=o,a=e-n+1,c=Math.min(a,100);for(let r=0;r<c;r++){const r=n+Math.floor(Math.random()*a);try{return await new Promise((o,n)=>{const e=t();e.once("error",n),e.listen(r,()=>{e.close(()=>o())})}),r}catch{continue}}try{return await new Promise((r,o)=>{const n=t();n.once("error",o),n.listen(3118,()=>{n.close(()=>r())})}),3118}catch{throw new Error("No available ports for OAuth redirect")}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logForDebugging as e}from"
|
|
1
|
+
import{logForDebugging as e}from"src/utils/debug.js";import{z as t}from"zod/v4";import{lazySchema as o}from"../../utils/lazySchema.js";import{checkStatsigFeatureGate_CACHED_MAY_BE_STALE as n,getFeatureValue_CACHED_MAY_BE_STALE as a}from"../analytics/growthbook.js";import{logEvent as i}from"../analytics/index.js";export const LogEventNotificationSchema=o(()=>t.object({method:t.literal("log_event"),params:t.object({eventName:t.string(),eventData:t.object({}).passthrough()})}));let c=null;export function notifyVscodeFileUpdated(t,o,n){"ant"===process.env.USER_TYPE&&c&&c.client.notification({method:"file_updated",params:{filePath:t,oldContent:o,newContent:n}}).catch(t=>{e(`[VSCode] Failed to send file_updated notification: ${t.message}`)})}export function setupVscodeSdkMcp(e){const t=e.find(e=>"claude-vscode"===e.name);if(t&&"connected"===t.type){c=t,t.client.setNotificationHandler(LogEventNotificationSchema(),async e=>{const{eventName:t,eventData:o}=e.params;i(`tengu_vscode_${t}`,o)});const e={tengu_vscode_review_upsell:n("tengu_vscode_review_upsell"),tengu_vscode_onboarding:n("tengu_vscode_onboarding"),tengu_quiet_fern:a("tengu_quiet_fern",!1),tengu_vscode_cc_auth:a("tengu_vscode_cc_auth",!1)},o=function(){const e=a("tengu_auto_mode_config",{})?.enabled;return"enabled"===e||"disabled"===e||"opt-in"===e?e:void 0}();void 0!==o&&(e.tengu_auto_mode_state=o),t.client.notification({method:"experiment_gates",params:{gates:e}})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import{logEvent as t}from"../analytics/index.js";import{ALL_OAUTH_SCOPES as o,CLAUDE_AI_INFERENCE_SCOPE as a,CLAUDE_AI_OAUTH_SCOPES as n,getOauthConfig as r,getOpenAIOAuthConfig as i}from"../../constants/oauth.js";import{checkAndRefreshOAuthTokenIfNeeded as s,getClaudeAIOAuthTokens as c,hasProfileScope as u,isClaudeAISubscriber as d,saveApiKey as p}from"../../utils/auth.js";import{getGlobalConfig as l,saveGlobalConfig as _}from"../../utils/config.js";import{logForDebugging as h}from"../../utils/debug.js";import{getOauthProfileFromOauthToken as A}from"./getOauthProfile.js";export function shouldUseClaudeAIAuth(e){return Boolean(e?.includes(a))}export function parseScopes(e){return e?.split(" ").filter(Boolean)??[]}function getProviderConfig(e){if("openai"===e){const e=i();if(!e)throw new Error("OpenAI OAuth is not configured. Set OPENAI_OAUTH_AUTHORIZE_URL, OPENAI_OAUTH_TOKEN_URL, OPENAI_OAUTH_CLIENT_ID, and OPENAI_OAUTH_MANUAL_REDIRECT_URL.");return e}const t=r();return{AUTHORIZE_URL:t.CLAUDE_AI_AUTHORIZE_URL,TOKEN_URL:t.TOKEN_URL,CLIENT_ID:t.CLIENT_ID,MANUAL_REDIRECT_URL:t.MANUAL_REDIRECT_URL,SUCCESS_URL:t.CLAUDEAI_SUCCESS_URL,FILE_SUFFIX:t.OAUTH_FILE_SUFFIX,BASE_API_URL:t.BASE_API_URL,PROFILE_URL:`${t.BASE_API_URL}/api/oauth/profile`,API_KEY_URL:t.API_KEY_URL,ROLES_URL:t.ROLES_URL}}export function getOAuthRequestDetails({port:e,isManual:t,provider:n="anthropic",inferenceOnly:i,loginWithClaudeAi:s}){const c=getProviderConfig(n),u="openai"===n?c.AUTHORIZE_URL:s?r().CLAUDE_AI_AUTHORIZE_URL:r().CONSOLE_AUTHORIZE_URL,d=t?c.MANUAL_REDIRECT_URL:function(e,t,o){return"openai"===e&&t.LOCAL_REDIRECT_URL?t.LOCAL_REDIRECT_URL:`http://localhost:${o}${t.CALLBACK_PATH??"/callback"}`}(n,c,e),p=i?[a]:"openai"===n?c.SCOPES??[]:o;return{authorizeUrl:u,tokenUrl:c.TOKEN_URL,redirectUri:d,clientId:c.CLIENT_ID,scopes:p}}export function buildAuthUrl({codeChallenge:e,state:t,port:o,isManual:a,loginWithClaudeAi:n,provider:r="anthropic",inferenceOnly:i,orgUUID:s,loginHint:c,loginMethod:u}){getProviderConfig(r);const d=getOAuthRequestDetails({port:o,isManual:a,provider:r,inferenceOnly:i,loginWithClaudeAi:n}),p=new URL(d.authorizeUrl);return"openai"!==r&&p.searchParams.append("code","true"),p.searchParams.append("client_id",d.clientId),p.searchParams.append("response_type","code"),p.searchParams.append("redirect_uri",d.redirectUri),p.searchParams.append("scope",d.scopes.join(" ")),p.searchParams.append("code_challenge",e),p.searchParams.append("code_challenge_method","S256"),p.searchParams.append("state",t),"openai"===r&&(p.searchParams.append("id_token_add_organizations","true"),p.searchParams.append("codex_cli_simplified_flow","true"),p.searchParams.append("originator","pi")),s&&p.searchParams.append("orgUUID",s),c&&p.searchParams.append("login_hint",c),u&&p.searchParams.append("login_method",u),p.toString()}export async function exchangeCodeForTokens(o,a,n,r,i=!1,s,c="anthropic"){const u=getOAuthRequestDetails({port:r,isManual:i,provider:c}),d={grant_type:"authorization_code",code:o,redirect_uri:u.redirectUri,client_id:u.clientId,code_verifier:n};let p;"openai"!==c&&(d.state=a),void 0!==s&&(d.expires_in=s);try{p="openai"===c?await e.post(u.tokenUrl,new URLSearchParams(Object.entries(d).map(([e,t])=>[e,String(t)])),{headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:15e3}):await e.post(u.tokenUrl,d,{headers:{"Content-Type":"application/json"},timeout:15e3})}catch(t){if(e.isAxiosError(t)){const e=t.response?.status,o="string"==typeof t.response?.data?t.response.data:JSON.stringify(t.response?.data??{}),a=["Token exchange failed"+(e?` (${e})`:""),`redirect_uri=${u.redirectUri}`,`client_id=${u.clientId}`,`scope=${u.scopes.join(" ")}`,o&&"{}"!==o?`response=${o}`:""].filter(Boolean);throw new Error(a.join("\n"))}throw t}if(200!==p.status)throw new Error(401===p.status?"Authentication failed: Invalid authorization code":`Token exchange failed (${p.status}): ${p.statusText}`);return t("tengu_oauth_token_exchange_success",{}),p.data}export async function refreshOAuthToken(o,{scopes:a}={}){const i={grant_type:"refresh_token",refresh_token:o,client_id:r().CLIENT_ID,scope:(a?.length?a:n).join(" ")};try{const a=await e.post(r().TOKEN_URL,i,{headers:{"Content-Type":"application/json"},timeout:15e3});if(200!==a.status)throw new Error(`Token refresh failed: ${a.statusText}`);const n=a.data,{access_token:s,refresh_token:u=o,expires_in:d}=n,p=Date.now()+1e3*d,h=parseScopes(n.scope);t("tengu_oauth_token_refresh_success",{});const A=l(),g=c(),U=void 0!==A.oauthAccount?.billingType&&void 0!==A.oauthAccount?.accountCreatedAt&&void 0!==A.oauthAccount?.subscriptionCreatedAt&&null!=g?.subscriptionType&&null!=g?.rateLimitTier?null:await fetchProfileInfo(s);if(U&&A.oauthAccount){const e={};void 0!==U.displayName&&(e.displayName=U.displayName),"boolean"==typeof U.hasExtraUsageEnabled&&(e.hasExtraUsageEnabled=U.hasExtraUsageEnabled),null!==U.billingType&&(e.billingType=U.billingType),void 0!==U.accountCreatedAt&&(e.accountCreatedAt=U.accountCreatedAt),void 0!==U.subscriptionCreatedAt&&(e.subscriptionCreatedAt=U.subscriptionCreatedAt),Object.keys(e).length>0&&_(t=>({...t,oauthAccount:t.oauthAccount?{...t.oauthAccount,...e}:t.oauthAccount}))}return{accessToken:s,refreshToken:u,expiresAt:p,scopes:h,subscriptionType:U?.subscriptionType??g?.subscriptionType??null,rateLimitTier:U?.rateLimitTier??g?.rateLimitTier??null,profile:U?.rawProfile,tokenAccount:n.account?{uuid:n.account.uuid,emailAddress:n.account.email_address,organizationUuid:n.organization?.uuid}:void 0}}catch(o){const a=e.isAxiosError(o)&&o.response?.data?JSON.stringify(o.response.data):void 0;throw t("tengu_oauth_token_refresh_failure",{error:o.message,...a&&{responseBody:a}}),o}}export async function refreshOpenAIOAuthToken(o,{scopes:a}={}){const n=getProviderConfig("openai"),r={grant_type:"refresh_token",refresh_token:o,client_id:n.CLIENT_ID,...a?.length||n.SCOPES?.length?{scope:(a?.length?a:n.SCOPES??[]).join(" ")}:{}};try{const t=await e.post(n.TOKEN_URL,r,{headers:{"Content-Type":"application/json"},timeout:15e3});if(200!==t.status)throw new Error(`OpenAI token refresh failed: ${t.statusText}`);const a=t.data,{access_token:i,refresh_token:s=o,expires_in:c}=a;return{accessToken:i,refreshToken:s,expiresAt:c?Date.now()+1e3*c:null,scopes:parseScopes(a.scope),subscriptionType:null,rateLimitTier:null,tokenAccount:a.account?{uuid:a.account.uuid,emailAddress:a.account.email_address,organizationUuid:a.organization?.uuid}:void 0}}catch(o){const a=e.isAxiosError(o)&&o.response?.data?JSON.stringify(o.response.data):void 0;throw t("tengu_openai_oauth_token_refresh_failure",{error:o.message,...a&&{responseBody:a}}),o}}export async function fetchAndStoreUserRoles(o){const a=await e.get(r().ROLES_URL,{headers:{Authorization:`Bearer ${o}`}});if(200!==a.status)throw new Error(`Failed to fetch user roles: ${a.statusText}`);const n=a.data;if(!l().oauthAccount)throw new Error("OAuth account information not found in config");_(e=>({...e,oauthAccount:e.oauthAccount?{...e.oauthAccount,organizationRole:n.organization_role,workspaceRole:n.workspace_role,organizationName:n.organization_name}:e.oauthAccount})),t("tengu_oauth_roles_stored",{org_role:n.organization_role})}export async function createAndStoreApiKey(o){try{const a=await e.post(r().API_KEY_URL,null,{headers:{Authorization:`Bearer ${o}`}}),n=a.data?.raw_key;return n?(await p(n),t("tengu_oauth_api_key",{status:"success",statusCode:a.status}),n):null}catch(e){throw t("tengu_oauth_api_key",{status:"failure",error:e instanceof Error?e.message:String(e)}),e}}export function isOAuthTokenExpired(e){if(null===e)return!1;return Date.now()+3e5>=e}export async function fetchProfileInfo(e){const o=await A(e),a=o?.organization?.organization_type;let n=null;switch(a){case"claude_max":n="max";break;case"claude_pro":n="pro";break;case"claude_enterprise":n="enterprise";break;case"claude_team":n="team";break;default:n=null}const r={subscriptionType:n,rateLimitTier:o?.organization?.rate_limit_tier??null,hasExtraUsageEnabled:o?.organization?.has_extra_usage_enabled??null,billingType:o?.organization?.billing_type??null};return o?.account?.display_name&&(r.displayName=o.account.display_name),o?.account?.created_at&&(r.accountCreatedAt=o.account.created_at),o?.organization?.subscription_created_at&&(r.subscriptionCreatedAt=o.organization.subscription_created_at),t("tengu_oauth_profile_fetch_success",{}),{...r,rawProfile:o}}export async function getOrganizationUUID(){const e=l(),t=e.oauthAccount?.organizationUuid;if(t)return t;const o=c()?.accessToken;if(void 0===o||!u())return null;const a=await A(o),n=a?.organization?.uuid;return n||null}export async function populateOAuthAccountInfoIfNeeded(){const e=process.env.CONTEXT_CODE_ACCOUNT_UUID??process.env.CLAUDE_CODE_ACCOUNT_UUID,t=process.env.CONTEXT_CODE_USER_EMAIL??process.env.CLAUDE_CODE_USER_EMAIL,o=process.env.CONTEXT_CODE_ORGANIZATION_UUID??process.env.CLAUDE_CODE_ORGANIZATION_UUID,a=Boolean(e&&t&&o);e&&t&&o&&(l().oauthAccount||storeOAuthAccountInfo({accountUuid:e,emailAddress:t,organizationUuid:o})),await s();const n=l();if(n.oauthAccount&&void 0!==n.oauthAccount.billingType&&void 0!==n.oauthAccount.accountCreatedAt&&void 0!==n.oauthAccount.subscriptionCreatedAt||!d()||!u())return!1;const r=c();if(r?.accessToken){const e=await A(r.accessToken);if(e)return a&&h("OAuth profile fetch succeeded, overriding env var account info",{level:"info"}),storeOAuthAccountInfo({accountUuid:e.account.uuid,emailAddress:e.account.email,organizationUuid:e.organization.uuid,displayName:e.account.display_name||void 0,hasExtraUsageEnabled:e.organization.has_extra_usage_enabled??!1,billingType:e.organization.billing_type??void 0,accountCreatedAt:e.account.created_at,subscriptionCreatedAt:e.organization.subscription_created_at??void 0}),!0}return!1}export function storeOAuthAccountInfo({accountUuid:e,emailAddress:t,organizationUuid:o,displayName:a,hasExtraUsageEnabled:n,billingType:r,accountCreatedAt:i,subscriptionCreatedAt:s}){const c={accountUuid:e,emailAddress:t,organizationUuid:o,hasExtraUsageEnabled:n,billingType:r,accountCreatedAt:i,subscriptionCreatedAt:s};a&&(c.displayName=a),_(e=>e.oauthAccount?.accountUuid===c.accountUuid&&e.oauthAccount?.emailAddress===c.emailAddress&&e.oauthAccount?.organizationUuid===c.organizationUuid&&e.oauthAccount?.displayName===c.displayName&&e.oauthAccount?.hasExtraUsageEnabled===c.hasExtraUsageEnabled&&e.oauthAccount?.billingType===c.billingType&&e.oauthAccount?.accountCreatedAt===c.accountCreatedAt&&e.oauthAccount?.subscriptionCreatedAt===c.subscriptionCreatedAt?e:{...e,oauthAccount:c})}
|
|
1
|
+
import e from"axios";import{logEvent as t}from"src/services/analytics/index.js";import{ALL_OAUTH_SCOPES as a,CLAUDE_AI_INFERENCE_SCOPE as o,CLAUDE_AI_OAUTH_SCOPES as n,getOauthConfig as r,getOpenAIOAuthConfig as i}from"../../constants/oauth.js";import{checkAndRefreshOAuthTokenIfNeeded as s,getClaudeAIOAuthTokens as c,hasProfileScope as u,isClaudeAISubscriber as d,saveApiKey as l}from"../../utils/auth.js";import{getGlobalConfig as p,saveGlobalConfig as _}from"../../utils/config.js";import{logForDebugging as A}from"../../utils/debug.js";import{getOauthProfileFromOauthToken as h}from"./getOauthProfile.js";export function shouldUseClaudeAIAuth(e){return Boolean(e?.includes(o))}export function parseScopes(e){return e?.split(" ").filter(Boolean)??[]}function getProviderConfig(e){if("openai"===e){const e=i();if(!e)throw new Error("OpenAI OAuth is not configured. Set OPENAI_OAUTH_AUTHORIZE_URL, OPENAI_OAUTH_TOKEN_URL, OPENAI_OAUTH_CLIENT_ID, and OPENAI_OAUTH_MANUAL_REDIRECT_URL.");return e}const t=r();return{AUTHORIZE_URL:t.CLAUDE_AI_AUTHORIZE_URL,TOKEN_URL:t.TOKEN_URL,CLIENT_ID:t.CLIENT_ID,MANUAL_REDIRECT_URL:t.MANUAL_REDIRECT_URL,SUCCESS_URL:t.CLAUDEAI_SUCCESS_URL,FILE_SUFFIX:t.OAUTH_FILE_SUFFIX,BASE_API_URL:t.BASE_API_URL,PROFILE_URL:`${t.BASE_API_URL}/api/oauth/profile`,API_KEY_URL:t.API_KEY_URL,ROLES_URL:t.ROLES_URL}}export function getOAuthRequestDetails({port:e,isManual:t,provider:n="anthropic",inferenceOnly:i,loginWithClaudeAi:s}){const c=getProviderConfig(n),u="openai"===n?c.AUTHORIZE_URL:s?r().CLAUDE_AI_AUTHORIZE_URL:r().CONSOLE_AUTHORIZE_URL,d=t?c.MANUAL_REDIRECT_URL:function(e,t,a){return"openai"===e&&t.LOCAL_REDIRECT_URL?t.LOCAL_REDIRECT_URL:`http://localhost:${a}${t.CALLBACK_PATH??"/callback"}`}(n,c,e),l=i?[o]:"openai"===n?c.SCOPES??[]:a;return{authorizeUrl:u,tokenUrl:c.TOKEN_URL,redirectUri:d,clientId:c.CLIENT_ID,scopes:l}}export function buildAuthUrl({codeChallenge:e,state:t,port:a,isManual:o,loginWithClaudeAi:n,provider:r="anthropic",inferenceOnly:i,orgUUID:s,loginHint:c,loginMethod:u}){getProviderConfig(r);const d=getOAuthRequestDetails({port:a,isManual:o,provider:r,inferenceOnly:i,loginWithClaudeAi:n}),l=new URL(d.authorizeUrl);return"openai"!==r&&l.searchParams.append("code","true"),l.searchParams.append("client_id",d.clientId),l.searchParams.append("response_type","code"),l.searchParams.append("redirect_uri",d.redirectUri),l.searchParams.append("scope",d.scopes.join(" ")),l.searchParams.append("code_challenge",e),l.searchParams.append("code_challenge_method","S256"),l.searchParams.append("state",t),"openai"===r&&(l.searchParams.append("id_token_add_organizations","true"),l.searchParams.append("codex_cli_simplified_flow","true"),l.searchParams.append("originator","pi")),s&&l.searchParams.append("orgUUID",s),c&&l.searchParams.append("login_hint",c),u&&l.searchParams.append("login_method",u),l.toString()}export async function exchangeCodeForTokens(a,o,n,r,i=!1,s,c="anthropic"){const u=getOAuthRequestDetails({port:r,isManual:i,provider:c}),d={grant_type:"authorization_code",code:a,redirect_uri:u.redirectUri,client_id:u.clientId,code_verifier:n};let l;"openai"!==c&&(d.state=o),void 0!==s&&(d.expires_in=s);try{l="openai"===c?await e.post(u.tokenUrl,new URLSearchParams(Object.entries(d).map(([e,t])=>[e,String(t)])),{headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:15e3}):await e.post(u.tokenUrl,d,{headers:{"Content-Type":"application/json"},timeout:15e3})}catch(t){if(e.isAxiosError(t)){const e=t.response?.status,a="string"==typeof t.response?.data?t.response.data:JSON.stringify(t.response?.data??{}),o=["Token exchange failed"+(e?` (${e})`:""),`redirect_uri=${u.redirectUri}`,`client_id=${u.clientId}`,`scope=${u.scopes.join(" ")}`,a&&"{}"!==a?`response=${a}`:""].filter(Boolean);throw new Error(o.join("\n"))}throw t}if(200!==l.status)throw new Error(401===l.status?"Authentication failed: Invalid authorization code":`Token exchange failed (${l.status}): ${l.statusText}`);return t("tengu_oauth_token_exchange_success",{}),l.data}export async function refreshOAuthToken(a,{scopes:o}={}){const i={grant_type:"refresh_token",refresh_token:a,client_id:r().CLIENT_ID,scope:(o?.length?o:n).join(" ")};try{const o=await e.post(r().TOKEN_URL,i,{headers:{"Content-Type":"application/json"},timeout:15e3});if(200!==o.status)throw new Error(`Token refresh failed: ${o.statusText}`);const n=o.data,{access_token:s,refresh_token:u=a,expires_in:d}=n,l=Date.now()+1e3*d,A=parseScopes(n.scope);t("tengu_oauth_token_refresh_success",{});const h=p(),g=c(),f=void 0!==h.oauthAccount?.billingType&&void 0!==h.oauthAccount?.accountCreatedAt&&void 0!==h.oauthAccount?.subscriptionCreatedAt&&null!=g?.subscriptionType&&null!=g?.rateLimitTier?null:await fetchProfileInfo(s);if(f&&h.oauthAccount){const e={};void 0!==f.displayName&&(e.displayName=f.displayName),"boolean"==typeof f.hasExtraUsageEnabled&&(e.hasExtraUsageEnabled=f.hasExtraUsageEnabled),null!==f.billingType&&(e.billingType=f.billingType),void 0!==f.accountCreatedAt&&(e.accountCreatedAt=f.accountCreatedAt),void 0!==f.subscriptionCreatedAt&&(e.subscriptionCreatedAt=f.subscriptionCreatedAt),Object.keys(e).length>0&&_(t=>({...t,oauthAccount:t.oauthAccount?{...t.oauthAccount,...e}:t.oauthAccount}))}return{accessToken:s,refreshToken:u,expiresAt:l,scopes:A,subscriptionType:f?.subscriptionType??g?.subscriptionType??null,rateLimitTier:f?.rateLimitTier??g?.rateLimitTier??null,profile:f?.rawProfile,tokenAccount:n.account?{uuid:n.account.uuid,emailAddress:n.account.email_address,organizationUuid:n.organization?.uuid}:void 0}}catch(a){const o=e.isAxiosError(a)&&a.response?.data?JSON.stringify(a.response.data):void 0;throw t("tengu_oauth_token_refresh_failure",{error:a.message,...o&&{responseBody:o}}),a}}export async function refreshOpenAIOAuthToken(a,{scopes:o}={}){const n=getProviderConfig("openai"),r={grant_type:"refresh_token",refresh_token:a,client_id:n.CLIENT_ID,...o?.length||n.SCOPES?.length?{scope:(o?.length?o:n.SCOPES??[]).join(" ")}:{}};try{const t=await e.post(n.TOKEN_URL,r,{headers:{"Content-Type":"application/json"},timeout:15e3});if(200!==t.status)throw new Error(`OpenAI token refresh failed: ${t.statusText}`);const o=t.data,{access_token:i,refresh_token:s=a,expires_in:c}=o;return{accessToken:i,refreshToken:s,expiresAt:c?Date.now()+1e3*c:null,scopes:parseScopes(o.scope),subscriptionType:null,rateLimitTier:null,tokenAccount:o.account?{uuid:o.account.uuid,emailAddress:o.account.email_address,organizationUuid:o.organization?.uuid}:void 0}}catch(a){const o=e.isAxiosError(a)&&a.response?.data?JSON.stringify(a.response.data):void 0;throw t("tengu_openai_oauth_token_refresh_failure",{error:a.message,...o&&{responseBody:o}}),a}}export async function fetchAndStoreUserRoles(a){const o=await e.get(r().ROLES_URL,{headers:{Authorization:`Bearer ${a}`}});if(200!==o.status)throw new Error(`Failed to fetch user roles: ${o.statusText}`);const n=o.data;if(!p().oauthAccount)throw new Error("OAuth account information not found in config");_(e=>({...e,oauthAccount:e.oauthAccount?{...e.oauthAccount,organizationRole:n.organization_role,workspaceRole:n.workspace_role,organizationName:n.organization_name}:e.oauthAccount})),t("tengu_oauth_roles_stored",{org_role:n.organization_role})}export async function createAndStoreApiKey(a){try{const o=await e.post(r().API_KEY_URL,null,{headers:{Authorization:`Bearer ${a}`}}),n=o.data?.raw_key;return n?(await l(n),t("tengu_oauth_api_key",{status:"success",statusCode:o.status}),n):null}catch(e){throw t("tengu_oauth_api_key",{status:"failure",error:e instanceof Error?e.message:String(e)}),e}}export function isOAuthTokenExpired(e){return null!==e&&Date.now()+3e5>=e}export async function fetchProfileInfo(e){const a=await h(e),o=a?.organization?.organization_type;let n=null;switch(o){case"claude_max":n="max";break;case"claude_pro":n="pro";break;case"claude_enterprise":n="enterprise";break;case"claude_team":n="team";break;default:n=null}const r={subscriptionType:n,rateLimitTier:a?.organization?.rate_limit_tier??null,hasExtraUsageEnabled:a?.organization?.has_extra_usage_enabled??null,billingType:a?.organization?.billing_type??null};return a?.account?.display_name&&(r.displayName=a.account.display_name),a?.account?.created_at&&(r.accountCreatedAt=a.account.created_at),a?.organization?.subscription_created_at&&(r.subscriptionCreatedAt=a.organization.subscription_created_at),t("tengu_oauth_profile_fetch_success",{}),{...r,rawProfile:a}}export async function getOrganizationUUID(){const e=p(),t=e.oauthAccount?.organizationUuid;if(t)return t;const a=c()?.accessToken;if(void 0===a||!u())return null;const o=await h(a),n=o?.organization?.uuid;return n||null}export async function populateOAuthAccountInfoIfNeeded(){const e=process.env.CONTEXT_CODE_ACCOUNT_UUID??process.env.CLAUDE_CODE_ACCOUNT_UUID,t=process.env.CONTEXT_CODE_USER_EMAIL??process.env.CLAUDE_CODE_USER_EMAIL,a=process.env.CONTEXT_CODE_ORGANIZATION_UUID??process.env.CLAUDE_CODE_ORGANIZATION_UUID,o=Boolean(e&&t&&a);e&&t&&a&&(p().oauthAccount||storeOAuthAccountInfo({accountUuid:e,emailAddress:t,organizationUuid:a})),await s();const n=p();if(n.oauthAccount&&void 0!==n.oauthAccount.billingType&&void 0!==n.oauthAccount.accountCreatedAt&&void 0!==n.oauthAccount.subscriptionCreatedAt||!d()||!u())return!1;const r=c();if(r?.accessToken){const e=await h(r.accessToken);if(e)return o&&A("OAuth profile fetch succeeded, overriding env var account info",{level:"info"}),storeOAuthAccountInfo({accountUuid:e.account.uuid,emailAddress:e.account.email,organizationUuid:e.organization.uuid,displayName:e.account.display_name||void 0,hasExtraUsageEnabled:e.organization.has_extra_usage_enabled??!1,billingType:e.organization.billing_type??void 0,accountCreatedAt:e.account.created_at,subscriptionCreatedAt:e.organization.subscription_created_at??void 0}),!0}return!1}export function storeOAuthAccountInfo({accountUuid:e,emailAddress:t,organizationUuid:a,displayName:o,hasExtraUsageEnabled:n,billingType:r,accountCreatedAt:i,subscriptionCreatedAt:s}){const c={accountUuid:e,emailAddress:t,organizationUuid:a,hasExtraUsageEnabled:n,billingType:r,accountCreatedAt:i,subscriptionCreatedAt:s};o&&(c.displayName=o),_(e=>e.oauthAccount?.accountUuid===c.accountUuid&&e.oauthAccount?.emailAddress===c.emailAddress&&e.oauthAccount?.organizationUuid===c.organizationUuid&&e.oauthAccount?.displayName===c.displayName&&e.oauthAccount?.hasExtraUsageEnabled===c.hasExtraUsageEnabled&&e.oauthAccount?.billingType===c.billingType&&e.oauthAccount?.accountCreatedAt===c.accountCreatedAt&&e.oauthAccount?.subscriptionCreatedAt===c.subscriptionCreatedAt?e:{...e,oauthAccount:c})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"axios";import{getOauthConfig as o,OAUTH_BETA_HEADER as a}from"
|
|
1
|
+
import t from"axios";import{getOauthConfig as o,OAUTH_BETA_HEADER as a}from"src/constants/oauth.js";import{getAnthropicApiKey as r}from"src/utils/auth.js";import{getGlobalConfig as i}from"src/utils/config.js";import{logError as e}from"src/utils/log.js";export async function getOauthProfileFromApiKey(){const c=i(),n=c.oauthAccount?.accountUuid,s=r();if(!n||!s)return;const u=`${o().BASE_API_URL}/api/claude_cli_profile`;try{return(await t.get(u,{headers:{"x-api-key":s,"anthropic-beta":a},params:{account_uuid:n},timeout:1e4})).data}catch(t){e(t)}}export async function getOauthProfileFromOauthToken(a){const r=`${o().BASE_API_URL}/api/oauth/profile`;try{return(await t.get(r,{headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},timeout:1e4})).data}catch(t){e(t)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function formatearDuracion(
|
|
1
|
+
export function formatearDuracion(o){const r=Math.max(0,Math.floor(o/1e3));if(r<60)return`${r}s`;const t=Math.floor(r/60);return t<60?`${t}m ${r%60}s`:`${Math.floor(t/60)}h ${t%60}m`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{APIError as e}from"@anthropic-ai/sdk/index.js";import{applyMockHeaders as
|
|
1
|
+
import{APIError as e}from"@anthropic-ai/sdk/index.js";import{applyMockHeaders as t,checkMockFastModeRateLimit as r,getMockHeaderless429Message as i,getMockHeaders as s,isMockFastModeRateLimitScenario as o,shouldProcessMockLimits as a}from"./mockRateLimits.js";export function processRateLimitHeaders(e){return a()?t(e):e}export function shouldProcessRateLimits(e){return e||a()}export function checkMockRateLimitError(t,n){if(!a())return null;const c=i();if(c)return new e(429,{error:{type:"rate_limit_error",message:c}},c,new globalThis.Headers);const l=s();if(!l)return null;const d=l["anthropic-ratelimit-unified-status"],u=l["anthropic-ratelimit-unified-overage-status"],m="seven_day_opus"===l["anthropic-ratelimit-unified-representative-claim"],p=t.includes("opus");if(m&&!p)return null;if(o()){const t=r(n);return null===t?null:new e(429,{error:{type:"rate_limit_error",message:"Rate limit exceeded"}},"Rate limit exceeded",new globalThis.Headers(Object.entries(t).filter(([e,t])=>void 0!==t)))}return"rejected"!==d||u&&"rejected"!==u?null:new e(429,{error:{type:"rate_limit_error",message:"Rate limit exceeded"}},"Rate limit exceeded",new globalThis.Headers(Object.entries(l).filter(([e,t])=>void 0!==t)))}export function isMockRateLimitError(e){return a()&&429===e.status}export{a as shouldProcessMockLimits};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as t}from"path";import{getClaudeConfigHomeDir as e}from"../../utils/envUtils.js";import{readFileSync as n}from"../../utils/fileRead.js";import{stripBOM as r}from"../../utils/jsonRead.js";import{resetSettingsCache as
|
|
1
|
+
import{join as t}from"path";import{getClaudeConfigHomeDir as e}from"../../utils/envUtils.js";import{readFileSync as n}from"../../utils/fileRead.js";import{stripBOM as r}from"../../utils/jsonRead.js";import{resetSettingsCache as s}from"../../utils/settings/settingsCache.js";import{jsonParse as i}from"../../utils/slowOperations.js";let o,a=null;export function setSessionCache(t){a=t}export function resetSyncCache(){a=null,o=void 0}export function setEligibility(t){return o=t,t}export function getSettingsPath(){return t(e(),"remote-settings.json")}export function getRemoteManagedSettingsSyncFromCache(){if(!0!==o)return null;if(a)return a;const t=function(){try{const t=n(getSettingsPath()),e=i(r(t));return!e||"object"!=typeof e||Array.isArray(e)?null:e}catch{return null}}();return t?(a=t,s(),t):null}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{constants as e}from"fs";import{mkdir as t,open as n}from"fs/promises";import{dirname as o,isAbsolute as s,join as i,normalize as l,sep as r}from"path";import{logForDebugging as a}from"../utils/debug.js";import{getBundledSkillsRoot as c}from"../utils/permissions/filesystem.js";const d=[];export function registerBundledSkill(e){const{files:s}=e;let i,l=e.getPromptForCommand;if(s&&Object.keys(s).length>0){let r;i=getBundledSkillExtractDir(e.name);const c=e.getPromptForCommand;l=async(i,l)=>{r??=async function(e,s){const i=getBundledSkillExtractDir(e);try{return await async function(e,s){const i=new Map;for(const[t,n]of Object.entries(s)){const s=resolveSkillFilePath(e,t),l=o(s),r=[s,n],a=i.get(l);a?a.push(r):i.set(l,[r])}await Promise.all([...i].map(async([e,o])=>{await t(e,{recursive:!0,mode:448}),await Promise.all(o.map(([e,t])=>async function(e,t){const o=await n(e,m,384);try{await o.writeFile(t,"utf8")}finally{await o.close()}}(e,t)))}))}(i,s),i}catch(t){return a(`Failed to extract bundled skill '${e}' to ${i}: ${t instanceof Error?t.message:String(t)}`),null}}(e.name,s);const d=await r,u=await c(i,l);return null===d?u:function(e,t){const n=`Base directory for this skill: ${t}\n\n`;
|
|
1
|
+
import{constants as e}from"fs";import{mkdir as t,open as n}from"fs/promises";import{dirname as o,isAbsolute as s,join as i,normalize as l,sep as r}from"path";import{logForDebugging as a}from"../utils/debug.js";import{getBundledSkillsRoot as c}from"../utils/permissions/filesystem.js";const d=[];export function registerBundledSkill(e){const{files:s}=e;let i,l=e.getPromptForCommand;if(s&&Object.keys(s).length>0){let r;i=getBundledSkillExtractDir(e.name);const c=e.getPromptForCommand;l=async(i,l)=>{r??=async function(e,s){const i=getBundledSkillExtractDir(e);try{return await async function(e,s){const i=new Map;for(const[t,n]of Object.entries(s)){const s=resolveSkillFilePath(e,t),l=o(s),r=[s,n],a=i.get(l);a?a.push(r):i.set(l,[r])}await Promise.all([...i].map(async([e,o])=>{await t(e,{recursive:!0,mode:448}),await Promise.all(o.map(([e,t])=>async function(e,t){const o=await n(e,m,384);try{await o.writeFile(t,"utf8")}finally{await o.close()}}(e,t)))}))}(i,s),i}catch(t){return a(`Failed to extract bundled skill '${e}' to ${i}: ${t instanceof Error?t.message:String(t)}`),null}}(e.name,s);const d=await r,u=await c(i,l);return null===d?u:function(e,t){const n=`Base directory for this skill: ${t}\n\n`;return e.length>0&&"text"===e[0].type?[{type:"text",text:n+e[0].text},...e.slice(1)]:[{type:"text",text:n},...e]}(u,d)}}const r={type:"prompt",name:e.name,description:e.description,aliases:e.aliases,hasUserSpecifiedDescription:!0,allowedTools:e.allowedTools??[],argumentHint:e.argumentHint,whenToUse:e.whenToUse,model:e.model,disableModelInvocation:e.disableModelInvocation??!1,userInvocable:e.userInvocable??!0,contentLength:0,source:"bundled",loadedFrom:"bundled",hooks:e.hooks,skillRoot:i,context:e.context,agent:e.agent,isEnabled:e.isEnabled,isHidden:!(e.userInvocable??1),progressMessage:"running",getPromptForCommand:l};d.push(r)}export function getBundledSkills(){return[...d]}export function clearBundledSkills(){d.length=0}export function getBundledSkillExtractDir(e){return i(c(),e)}const u=e.O_NOFOLLOW??0,m="win32"===process.platform?"wx":e.O_WRONLY|e.O_CREAT|e.O_EXCL|u;function resolveSkillFilePath(e,t){const n=l(t);if(s(n)||n.split(r).includes("..")||n.split("/").includes(".."))throw new Error(`bundled skill file path escapes skill dir: ${t}`);return i(e,n)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rollbackConsolidationLock as e}from"../../services/autoDream/consolidationLock.js";import{createTaskStateBase as t,generateTaskId as o}from"../../Task.js";import{registerTask as r,updateTaskState as
|
|
1
|
+
import{rollbackConsolidationLock as e}from"../../services/autoDream/consolidationLock.js";import{createTaskStateBase as t,generateTaskId as o}from"../../Task.js";import{registerTask as r,updateTaskState as a}from"../../utils/task/framework.js";export function isDreamTask(e){return"object"==typeof e&&null!==e&&"type"in e&&"dream"===e.type}export function registerDreamTask(e,a){const s=o("dream"),n={...t(s,"dream","dreaming"),type:"dream",status:"running",phase:"starting",sessionsReviewing:a.sessionsReviewing,filesTouched:[],turns:[],abortController:a.abortController,priorMtime:a.priorMtime};return r(n,e),s}export function addDreamTurn(e,t,o,r){a(e,r,e=>{const r=new Set(e.filesTouched),a=o.filter(e=>!r.has(e)&&r.add(e));return""===t.text&&0===t.toolUseCount&&0===a.length?e:{...e,phase:a.length>0?"updating":e.phase,filesTouched:a.length>0?[...e.filesTouched,...a]:e.filesTouched,turns:e.turns.slice(-29).concat(t)}})}export function completeDreamTask(e,t){a(e,t,e=>({...e,status:"completed",endTime:Date.now(),notified:!0,abortController:void 0}))}export function failDreamTask(e,t){a(e,t,e=>({...e,status:"failed",endTime:Date.now(),notified:!0,abortController:void 0}))}export const DreamTask={name:"DreamTask",type:"dream",async kill(t,o){let r;a(t,o,e=>"running"!==e.status?e:(e.abortController?.abort(),r=e.priorMtime,{...e,status:"killed",endTime:Date.now(),notified:!0,abortController:void 0})),void 0!==r&&await e(r)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,normalize as t,sep as r}from"path";import{getProjectRoot as o}from"../../bootstrap/state.js";import{buildMemoryPrompt as
|
|
1
|
+
import{join as e,normalize as t,sep as r}from"path";import{getProjectRoot as o}from"../../bootstrap/state.js";import{buildMemoryPrompt as s,ensureMemoryDirExists as n}from"../../memdir/memdir.js";import{getMemoryBaseDir as i}from"../../memdir/paths.js";import{getCwd as c}from"../../utils/cwd.js";import{findCanonicalGitRoot as a}from"../../utils/git.js";import{sanitizePath as m}from"../../utils/path.js";function resolveProjectAgentMemoryRoot(t){const r=c();return e(r,".context",t)}function getLocalAgentMemoryDir(t){const s=process.env.CONTEXT_CODE_REMOTE_MEMORY_DIR??process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR;return s?e(s,"projects",m(a(o())??o()),"agent-memory-local",t)+r:e(resolveProjectAgentMemoryRoot("agent-memory-local"),t)+r}export function getAgentMemoryDir(t,o){const s=function(e){return e.replace(/:/g,"-")}(t);switch(o){case"project":return e(resolveProjectAgentMemoryRoot("agent-memory"),s)+r;case"local":return getLocalAgentMemoryDir(s);case"user":return e(i(),"agent-memory",s)+r}}export function isAgentMemoryPath(o){const s=t(o),n=i();if(s.startsWith(e(n,"agent-memory")+r))return!0;if(s.startsWith(e(c(),".context","agent-memory")+r))return!0;const a=process.env.CONTEXT_CODE_REMOTE_MEMORY_DIR??process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR;if(a){if(s.includes(r+"agent-memory-local"+r)&&s.startsWith(e(a,"projects")+r))return!0}else if(s.startsWith(e(c(),".context","agent-memory-local")+r))return!0;return!1}export function getAgentMemoryEntrypoint(t,r){return e(getAgentMemoryDir(t,r),"MEMORY.md")}export function getMemoryScopeDisplay(t){switch(t){case"user":return`User (${e(i(),"agent-memory")}/)`;case"project":return"Project (.context/agent-memory/)";case"local":return`Local (${getLocalAgentMemoryDir("...")})`;default:return"None"}}export function loadAgentMemoryPrompt(e,t){let r;switch(t){case"user":r="- Since this memory is user-scope, keep learnings general since they apply across all projects";break;case"project":r="- Since this memory is project-scope and shared with your team via version control, tailor your memories to this project";break;case"local":r="- Since this memory is local-scope (not checked into version control), tailor your memories to this project and machine"}const o=getAgentMemoryDir(e,t);n(o);const i=process.env.CONTEXT_COWORK_MEMORY_EXTRA_GUIDELINES??process.env.CLAUDE_COWORK_MEMORY_EXTRA_GUIDELINES;return s({displayName:"Persistent Agent Memory",memoryDir:o,extraGuidelines:i&&i.trim().length>0?[r,i]:[r]})}
|