@slopus/rig 0.0.1
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/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/agent/Agent.d.ts +73 -0
- package/dist/agent/Agent.d.ts.map +1 -0
- package/dist/agent/Agent.js +247 -0
- package/dist/agent/agentMessageToText.d.ts +3 -0
- package/dist/agent/agentMessageToText.d.ts.map +1 -0
- package/dist/agent/agentMessageToText.js +20 -0
- package/dist/agent/agentsMdProjectDocMaxBytes.d.ts +2 -0
- package/dist/agent/agentsMdProjectDocMaxBytes.d.ts.map +1 -0
- package/dist/agent/agentsMdProjectDocMaxBytes.js +1 -0
- package/dist/agent/assistantMessageToAgentMessage.d.ts +4 -0
- package/dist/agent/assistantMessageToAgentMessage.d.ts.map +1 -0
- package/dist/agent/assistantMessageToAgentMessage.js +32 -0
- package/dist/agent/buildAncestorDirs.d.ts +2 -0
- package/dist/agent/buildAncestorDirs.d.ts.map +1 -0
- package/dist/agent/buildAncestorDirs.js +16 -0
- package/dist/agent/contentBlockToText.d.ts +3 -0
- package/dist/agent/contentBlockToText.d.ts.map +1 -0
- package/dist/agent/contentBlockToText.js +6 -0
- package/dist/agent/context/AgentContext.d.ts +9 -0
- package/dist/agent/context/AgentContext.d.ts.map +1 -0
- package/dist/agent/context/AgentContext.js +1 -0
- package/dist/agent/context/BashContext.d.ts +18 -0
- package/dist/agent/context/BashContext.d.ts.map +1 -0
- package/dist/agent/context/BashContext.js +1 -0
- package/dist/agent/context/FileSystemContext.d.ts +25 -0
- package/dist/agent/context/FileSystemContext.d.ts.map +1 -0
- package/dist/agent/context/FileSystemContext.js +1 -0
- package/dist/agent/context/SubagentContext.d.ts +18 -0
- package/dist/agent/context/SubagentContext.d.ts.map +1 -0
- package/dist/agent/context/SubagentContext.js +1 -0
- package/dist/agent/context/capOutput.d.ts +2 -0
- package/dist/agent/context/capOutput.d.ts.map +1 -0
- package/dist/agent/context/capOutput.js +7 -0
- package/dist/agent/context/createJustBashAgentContext.d.ts +4 -0
- package/dist/agent/context/createJustBashAgentContext.d.ts.map +1 -0
- package/dist/agent/context/createJustBashAgentContext.js +8 -0
- package/dist/agent/context/createJustBashBashContext.d.ts +4 -0
- package/dist/agent/context/createJustBashBashContext.d.ts.map +1 -0
- package/dist/agent/context/createJustBashBashContext.js +31 -0
- package/dist/agent/context/createJustBashFileSystemContext.d.ts +4 -0
- package/dist/agent/context/createJustBashFileSystemContext.d.ts.map +1 -0
- package/dist/agent/context/createJustBashFileSystemContext.js +31 -0
- package/dist/agent/context/createNodeAgentContext.d.ts +8 -0
- package/dist/agent/context/createNodeAgentContext.d.ts.map +1 -0
- package/dist/agent/context/createNodeAgentContext.js +11 -0
- package/dist/agent/context/createNodeBashContext.d.ts +8 -0
- package/dist/agent/context/createNodeBashContext.d.ts.map +1 -0
- package/dist/agent/context/createNodeBashContext.js +23 -0
- package/dist/agent/context/createNodeFileSystemContext.d.ts +6 -0
- package/dist/agent/context/createNodeFileSystemContext.d.ts.map +1 -0
- package/dist/agent/context/createNodeFileSystemContext.js +43 -0
- package/dist/agent/context/toFileSystemStat.d.ts +9 -0
- package/dist/agent/context/toFileSystemStat.d.ts.map +1 -0
- package/dist/agent/context/toFileSystemStat.js +9 -0
- package/dist/agent/createSubagentInstructions.d.ts +2 -0
- package/dist/agent/createSubagentInstructions.d.ts.map +1 -0
- package/dist/agent/createSubagentInstructions.js +16 -0
- package/dist/agent/createSystemPrompt.d.ts +12 -0
- package/dist/agent/createSystemPrompt.d.ts.map +1 -0
- package/dist/agent/createSystemPrompt.js +28 -0
- package/dist/agent/findAgentsMdPaths.d.ts +3 -0
- package/dist/agent/findAgentsMdPaths.d.ts.map +1 -0
- package/dist/agent/findAgentsMdPaths.js +18 -0
- package/dist/agent/findLastAgentResponseText.d.ts +3 -0
- package/dist/agent/findLastAgentResponseText.d.ts.map +1 -0
- package/dist/agent/findLastAgentResponseText.js +17 -0
- package/dist/agent/findProjectRoot.d.ts +3 -0
- package/dist/agent/findProjectRoot.d.ts.map +1 -0
- package/dist/agent/findProjectRoot.js +17 -0
- package/dist/agent/formatAgentsMdInstructions.d.ts +2 -0
- package/dist/agent/formatAgentsMdInstructions.d.ts.map +1 -0
- package/dist/agent/formatAgentsMdInstructions.js +7 -0
- package/dist/agent/index.d.ts +32 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +20 -0
- package/dist/agent/isFileAtPath.d.ts +3 -0
- package/dist/agent/isFileAtPath.d.ts.map +1 -0
- package/dist/agent/isFileAtPath.js +8 -0
- package/dist/agent/isInvalidImageRequestError.d.ts +2 -0
- package/dist/agent/isInvalidImageRequestError.d.ts.map +1 -0
- package/dist/agent/isInvalidImageRequestError.js +36 -0
- package/dist/agent/loadAgentsMdInstructions.d.ts +3 -0
- package/dist/agent/loadAgentsMdInstructions.d.ts.map +1 -0
- package/dist/agent/loadAgentsMdInstructions.js +22 -0
- package/dist/agent/loop.d.ts +28 -0
- package/dist/agent/loop.d.ts.map +1 -0
- package/dist/agent/loop.js +369 -0
- package/dist/agent/prepareProviderImageContent.d.ts +4 -0
- package/dist/agent/prepareProviderImageContent.d.ts.map +1 -0
- package/dist/agent/prepareProviderImageContent.js +27 -0
- package/dist/agent/prepareProviderMessageImages.d.ts +4 -0
- package/dist/agent/prepareProviderMessageImages.d.ts.map +1 -0
- package/dist/agent/prepareProviderMessageImages.js +21 -0
- package/dist/agent/printAgentMessageToConsole.d.ts +6 -0
- package/dist/agent/printAgentMessageToConsole.d.ts.map +1 -0
- package/dist/agent/printAgentMessageToConsole.js +11 -0
- package/dist/agent/prompts/claudeCodeSystemPrompt.d.ts +2 -0
- package/dist/agent/prompts/claudeCodeSystemPrompt.d.ts.map +1 -0
- package/dist/agent/prompts/claudeCodeSystemPrompt.js +1 -0
- package/dist/agent/prompts/gpt54SystemPrompt.d.ts +2 -0
- package/dist/agent/prompts/gpt54SystemPrompt.d.ts.map +1 -0
- package/dist/agent/prompts/gpt54SystemPrompt.js +1 -0
- package/dist/agent/prompts/gpt55SystemPrompt.d.ts +2 -0
- package/dist/agent/prompts/gpt55SystemPrompt.d.ts.map +1 -0
- package/dist/agent/prompts/gpt55SystemPrompt.js +1 -0
- package/dist/agent/prompts/kimiSystemPrompt.d.ts +2 -0
- package/dist/agent/prompts/kimiSystemPrompt.d.ts.map +1 -0
- package/dist/agent/prompts/kimiSystemPrompt.js +1 -0
- package/dist/agent/readAgentsMdFile.d.ts +3 -0
- package/dist/agent/readAgentsMdFile.d.ts.map +1 -0
- package/dist/agent/readAgentsMdFile.js +8 -0
- package/dist/agent/replaceLastTurnToolResultImages.d.ts +3 -0
- package/dist/agent/replaceLastTurnToolResultImages.d.ts.map +1 -0
- package/dist/agent/replaceLastTurnToolResultImages.js +33 -0
- package/dist/agent/selectSystemPromptForModel.d.ts +3 -0
- package/dist/agent/selectSystemPromptForModel.d.ts.map +1 -0
- package/dist/agent/selectSystemPromptForModel.js +35 -0
- package/dist/agent/selectToolsForModel.d.ts +8 -0
- package/dist/agent/selectToolsForModel.d.ts.map +1 -0
- package/dist/agent/selectToolsForModel.js +19 -0
- package/dist/agent/skills/Skill.d.ts +8 -0
- package/dist/agent/skills/Skill.d.ts.map +1 -0
- package/dist/agent/skills/Skill.js +1 -0
- package/dist/agent/skills/SkillFrontmatter.d.ts +6 -0
- package/dist/agent/skills/SkillFrontmatter.d.ts.map +1 -0
- package/dist/agent/skills/SkillFrontmatter.js +1 -0
- package/dist/agent/skills/escapeXml.d.ts +2 -0
- package/dist/agent/skills/escapeXml.d.ts.map +1 -0
- package/dist/agent/skills/escapeXml.js +8 -0
- package/dist/agent/skills/findSkillFilePaths.d.ts +3 -0
- package/dist/agent/skills/findSkillFilePaths.d.ts.map +1 -0
- package/dist/agent/skills/findSkillFilePaths.js +44 -0
- package/dist/agent/skills/findSkillRootPaths.d.ts +3 -0
- package/dist/agent/skills/findSkillRootPaths.d.ts.map +1 -0
- package/dist/agent/skills/findSkillRootPaths.js +30 -0
- package/dist/agent/skills/formatSkillInvocation.d.ts +3 -0
- package/dist/agent/skills/formatSkillInvocation.d.ts.map +1 -0
- package/dist/agent/skills/formatSkillInvocation.js +12 -0
- package/dist/agent/skills/formatSkillsForPrompt.d.ts +3 -0
- package/dist/agent/skills/formatSkillsForPrompt.d.ts.map +1 -0
- package/dist/agent/skills/formatSkillsForPrompt.js +25 -0
- package/dist/agent/skills/isDirectoryAtPath.d.ts +3 -0
- package/dist/agent/skills/isDirectoryAtPath.d.ts.map +1 -0
- package/dist/agent/skills/isDirectoryAtPath.js +8 -0
- package/dist/agent/skills/isFileAtPath.d.ts +3 -0
- package/dist/agent/skills/isFileAtPath.d.ts.map +1 -0
- package/dist/agent/skills/isFileAtPath.js +8 -0
- package/dist/agent/skills/isValidSkillDescription.d.ts +2 -0
- package/dist/agent/skills/isValidSkillDescription.d.ts.map +1 -0
- package/dist/agent/skills/isValidSkillDescription.js +7 -0
- package/dist/agent/skills/isValidSkillName.d.ts +2 -0
- package/dist/agent/skills/isValidSkillName.d.ts.map +1 -0
- package/dist/agent/skills/isValidSkillName.js +9 -0
- package/dist/agent/skills/loadSkillFromFile.d.ts +4 -0
- package/dist/agent/skills/loadSkillFromFile.d.ts.map +1 -0
- package/dist/agent/skills/loadSkillFromFile.js +36 -0
- package/dist/agent/skills/loadSkillInstructions.d.ts +3 -0
- package/dist/agent/skills/loadSkillInstructions.d.ts.map +1 -0
- package/dist/agent/skills/loadSkillInstructions.js +5 -0
- package/dist/agent/skills/loadSkills.d.ts +4 -0
- package/dist/agent/skills/loadSkills.d.ts.map +1 -0
- package/dist/agent/skills/loadSkills.js +15 -0
- package/dist/agent/skills/parseSkillFrontmatter.d.ts +7 -0
- package/dist/agent/skills/parseSkillFrontmatter.d.ts.map +1 -0
- package/dist/agent/skills/parseSkillFrontmatter.js +26 -0
- package/dist/agent/systemContentBlockToText.d.ts +3 -0
- package/dist/agent/systemContentBlockToText.d.ts.map +1 -0
- package/dist/agent/systemContentBlockToText.js +6 -0
- package/dist/agent/systemMessageToText.d.ts +3 -0
- package/dist/agent/systemMessageToText.d.ts.map +1 -0
- package/dist/agent/systemMessageToText.js +4 -0
- package/dist/agent/types.d.ts +111 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +7 -0
- package/dist/app/AppTranscriptEntry.d.ts +9 -0
- package/dist/app/AppTranscriptEntry.d.ts.map +1 -0
- package/dist/app/AppTranscriptEntry.js +1 -0
- package/dist/app/CodingAssistantAgentBackend.d.ts +20 -0
- package/dist/app/CodingAssistantAgentBackend.d.ts.map +1 -0
- package/dist/app/CodingAssistantAgentBackend.js +1 -0
- package/dist/app/CodingAssistantApp.d.ts +47 -0
- package/dist/app/CodingAssistantApp.d.ts.map +1 -0
- package/dist/app/CodingAssistantApp.js +1895 -0
- package/dist/app/CodingAssistantRuntime.d.ts +11 -0
- package/dist/app/CodingAssistantRuntime.d.ts.map +1 -0
- package/dist/app/CodingAssistantRuntime.js +1 -0
- package/dist/app/StartupStatusApp.d.ts +17 -0
- package/dist/app/StartupStatusApp.d.ts.map +1 -0
- package/dist/app/StartupStatusApp.js +101 -0
- package/dist/app/createAgentMarkdownTheme.d.ts +3 -0
- package/dist/app/createAgentMarkdownTheme.d.ts.map +1 -0
- package/dist/app/createAgentMarkdownTheme.js +39 -0
- package/dist/app/createCodingAssistantAgent.d.ts +19 -0
- package/dist/app/createCodingAssistantAgent.d.ts.map +1 -0
- package/dist/app/createCodingAssistantAgent.js +77 -0
- package/dist/app/createDefaultInstructions.d.ts +2 -0
- package/dist/app/createDefaultInstructions.d.ts.map +1 -0
- package/dist/app/createDefaultInstructions.js +8 -0
- package/dist/app/createSelectionPanel.d.ts +11 -0
- package/dist/app/createSelectionPanel.d.ts.map +1 -0
- package/dist/app/createSelectionPanel.js +64 -0
- package/dist/app/createSlashCommands.d.ts +6 -0
- package/dist/app/createSlashCommands.d.ts.map +1 -0
- package/dist/app/createSlashCommands.js +46 -0
- package/dist/app/createStopOnceHandler.d.ts +2 -0
- package/dist/app/createStopOnceHandler.d.ts.map +1 -0
- package/dist/app/createStopOnceHandler.js +9 -0
- package/dist/app/describeModelChoice.d.ts +5 -0
- package/dist/app/describeModelChoice.d.ts.map +1 -0
- package/dist/app/describeModelChoice.js +13 -0
- package/dist/app/describeReasoningLevel.d.ts +5 -0
- package/dist/app/describeReasoningLevel.d.ts.map +1 -0
- package/dist/app/describeReasoningLevel.js +21 -0
- package/dist/app/encodeModelChoice.d.ts +2 -0
- package/dist/app/encodeModelChoice.d.ts.map +1 -0
- package/dist/app/encodeModelChoice.js +3 -0
- package/dist/app/ensureSessionCanResume.d.ts +3 -0
- package/dist/app/ensureSessionCanResume.d.ts.map +1 -0
- package/dist/app/ensureSessionCanResume.js +5 -0
- package/dist/app/formatActivityElapsedTime.d.ts +2 -0
- package/dist/app/formatActivityElapsedTime.d.ts.map +1 -0
- package/dist/app/formatActivityElapsedTime.js +15 -0
- package/dist/app/formatSessionSummaries.d.ts +6 -0
- package/dist/app/formatSessionSummaries.d.ts.map +1 -0
- package/dist/app/formatSessionSummaries.js +73 -0
- package/dist/app/highlightAgentCode.d.ts +2 -0
- package/dist/app/highlightAgentCode.d.ts.map +1 -0
- package/dist/app/highlightAgentCode.js +82 -0
- package/dist/app/humanizeProviderId.d.ts +2 -0
- package/dist/app/humanizeProviderId.d.ts.map +1 -0
- package/dist/app/humanizeProviderId.js +22 -0
- package/dist/app/humanizeReasoningLevel.d.ts +2 -0
- package/dist/app/humanizeReasoningLevel.d.ts.map +1 -0
- package/dist/app/humanizeReasoningLevel.js +28 -0
- package/dist/app/index.d.ts +17 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +8 -0
- package/dist/app/isMainModule.d.ts +2 -0
- package/dist/app/isMainModule.d.ts.map +1 -0
- package/dist/app/isMainModule.js +6 -0
- package/dist/app/main.d.ts +2 -0
- package/dist/app/main.d.ts.map +1 -0
- package/dist/app/main.js +64 -0
- package/dist/app/readClipboardImage.d.ts +10 -0
- package/dist/app/readClipboardImage.d.ts.map +1 -0
- package/dist/app/readClipboardImage.js +134 -0
- package/dist/app/readPackageVersion.d.ts +2 -0
- package/dist/app/readPackageVersion.d.ts.map +1 -0
- package/dist/app/readPackageVersion.js +11 -0
- package/dist/app/renderActivityWave.d.ts +3 -0
- package/dist/app/renderActivityWave.d.ts.map +1 -0
- package/dist/app/renderActivityWave.js +28 -0
- package/dist/app/renderAgentMarkdown.d.ts +7 -0
- package/dist/app/renderAgentMarkdown.d.ts.map +1 -0
- package/dist/app/renderAgentMarkdown.js +23 -0
- package/dist/app/resolvePortlessCliPath.d.ts +2 -0
- package/dist/app/resolvePortlessCliPath.d.ts.map +1 -0
- package/dist/app/resolvePortlessCliPath.js +31 -0
- package/dist/app/runApp.d.ts +12 -0
- package/dist/app/runApp.d.ts.map +1 -0
- package/dist/app/runApp.js +157 -0
- package/dist/app/runDaemonCommand.d.ts +3 -0
- package/dist/app/runDaemonCommand.d.ts.map +1 -0
- package/dist/app/runDaemonCommand.js +50 -0
- package/dist/app/runMonit.d.ts +6 -0
- package/dist/app/runMonit.d.ts.map +1 -0
- package/dist/app/runMonit.js +13 -0
- package/dist/app/runWebCommand.d.ts +2 -0
- package/dist/app/runWebCommand.d.ts.map +1 -0
- package/dist/app/runWebCommand.js +52 -0
- package/dist/app/web/createWebHttpServer.d.ts +8 -0
- package/dist/app/web/createWebHttpServer.d.ts.map +1 -0
- package/dist/app/web/createWebHttpServer.js +150 -0
- package/dist/app/web/runWebServer.d.ts +2 -0
- package/dist/app/web/runWebServer.d.ts.map +1 -0
- package/dist/app/web/runWebServer.js +63 -0
- package/dist/app/web/webPortlessRoute.d.ts +3 -0
- package/dist/app/web/webPortlessRoute.d.ts.map +1 -0
- package/dist/app/web/webPortlessRoute.js +2 -0
- package/dist/client/ProtocolHttpClient.d.ts +42 -0
- package/dist/client/ProtocolHttpClient.d.ts.map +1 -0
- package/dist/client/ProtocolHttpClient.js +181 -0
- package/dist/client/RemoteAgent.d.ts +28 -0
- package/dist/client/RemoteAgent.d.ts.map +1 -0
- package/dist/client/RemoteAgent.js +270 -0
- package/dist/client/ensureLocalProtocolServer.d.ts +13 -0
- package/dist/client/ensureLocalProtocolServer.d.ts.map +1 -0
- package/dist/client/ensureLocalProtocolServer.js +112 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/config/createConfigFile.d.ts +3 -0
- package/dist/config/createConfigFile.d.ts.map +1 -0
- package/dist/config/createConfigFile.js +22 -0
- package/dist/config/defaultConfig.d.ts +3 -0
- package/dist/config/defaultConfig.d.ts.map +1 -0
- package/dist/config/defaultConfig.js +8 -0
- package/dist/config/getDefaultGlobalConfigPath.d.ts +2 -0
- package/dist/config/getDefaultGlobalConfigPath.d.ts.map +1 -0
- package/dist/config/getDefaultGlobalConfigPath.js +6 -0
- package/dist/config/getDefaultLocalConfigPath.d.ts +2 -0
- package/dist/config/getDefaultLocalConfigPath.d.ts.map +1 -0
- package/dist/config/getDefaultLocalConfigPath.js +4 -0
- package/dist/config/getDefaultRuntimeConfigPath.d.ts +2 -0
- package/dist/config/getDefaultRuntimeConfigPath.d.ts.map +1 -0
- package/dist/config/getDefaultRuntimeConfigPath.js +6 -0
- package/dist/config/index.d.ts +13 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +11 -0
- package/dist/config/loadConfig.d.ts +3 -0
- package/dist/config/loadConfig.d.ts.map +1 -0
- package/dist/config/loadConfig.js +20 -0
- package/dist/config/mergeConfigValues.d.ts +3 -0
- package/dist/config/mergeConfigValues.d.ts.map +1 -0
- package/dist/config/mergeConfigValues.js +22 -0
- package/dist/config/parseConfigToml.d.ts +3 -0
- package/dist/config/parseConfigToml.d.ts.map +1 -0
- package/dist/config/parseConfigToml.js +50 -0
- package/dist/config/readConfigFile.d.ts +3 -0
- package/dist/config/readConfigFile.d.ts.map +1 -0
- package/dist/config/readConfigFile.js +25 -0
- package/dist/config/resolveConfigPaths.d.ts +3 -0
- package/dist/config/resolveConfigPaths.d.ts.map +1 -0
- package/dist/config/resolveConfigPaths.js +10 -0
- package/dist/config/types.d.ts +51 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/config/writeRuntimeConfig.d.ts +3 -0
- package/dist/config/writeRuntimeConfig.d.ts.map +1 -0
- package/dist/config/writeRuntimeConfig.js +31 -0
- package/dist/config/writeRuntimeConfigDefaults.d.ts +3 -0
- package/dist/config/writeRuntimeConfigDefaults.d.ts.map +1 -0
- package/dist/config/writeRuntimeConfigDefaults.js +4 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +10 -0
- package/dist/processes/NativeProxessManager.d.ts +27 -0
- package/dist/processes/NativeProxessManager.d.ts.map +1 -0
- package/dist/processes/NativeProxessManager.js +330 -0
- package/dist/processes/index.d.ts +4 -0
- package/dist/processes/index.d.ts.map +1 -0
- package/dist/processes/index.js +2 -0
- package/dist/processes/killProcessTree.d.ts +2 -0
- package/dist/processes/killProcessTree.d.ts.map +1 -0
- package/dist/processes/killProcessTree.js +31 -0
- package/dist/processes/types.d.ts +34 -0
- package/dist/processes/types.d.ts.map +1 -0
- package/dist/processes/types.js +1 -0
- package/dist/protocol/EventId.d.ts +2 -0
- package/dist/protocol/EventId.d.ts.map +1 -0
- package/dist/protocol/EventId.js +1 -0
- package/dist/protocol/SessionProtocol.d.ts +191 -0
- package/dist/protocol/SessionProtocol.d.ts.map +1 -0
- package/dist/protocol/SessionProtocol.js +1 -0
- package/dist/protocol/createEventIdFactory.d.ts +6 -0
- package/dist/protocol/createEventIdFactory.d.ts.map +1 -0
- package/dist/protocol/createEventIdFactory.js +36 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +1 -0
- package/dist/providers/applyBedrockAdaptiveThinking.d.ts +2 -0
- package/dist/providers/applyBedrockAdaptiveThinking.d.ts.map +1 -0
- package/dist/providers/applyBedrockAdaptiveThinking.js +17 -0
- package/dist/providers/applyBedrockGlmThinking.d.ts +2 -0
- package/dist/providers/applyBedrockGlmThinking.d.ts.map +1 -0
- package/dist/providers/applyBedrockGlmThinking.js +19 -0
- package/dist/providers/applyBedrockKimiThinking.d.ts +2 -0
- package/dist/providers/applyBedrockKimiThinking.d.ts.map +1 -0
- package/dist/providers/applyBedrockKimiThinking.js +15 -0
- package/dist/providers/applyBedrockOpenAIResponse.d.ts +4 -0
- package/dist/providers/applyBedrockOpenAIResponse.d.ts.map +1 -0
- package/dist/providers/applyBedrockOpenAIResponse.js +25 -0
- package/dist/providers/applyCodexImageDetailsToPayload.d.ts +2 -0
- package/dist/providers/applyCodexImageDetailsToPayload.d.ts.map +1 -0
- package/dist/providers/applyCodexImageDetailsToPayload.js +34 -0
- package/dist/providers/bedrock-model-routes.d.ts +29 -0
- package/dist/providers/bedrock-model-routes.d.ts.map +1 -0
- package/dist/providers/bedrock-model-routes.js +301 -0
- package/dist/providers/bedrock-openai-types.d.ts +6 -0
- package/dist/providers/bedrock-openai-types.d.ts.map +1 -0
- package/dist/providers/bedrock-openai-types.js +1 -0
- package/dist/providers/bedrock.d.ts +14 -0
- package/dist/providers/bedrock.d.ts.map +1 -0
- package/dist/providers/bedrock.js +49 -0
- package/dist/providers/classifyCodexErrorCode.d.ts +3 -0
- package/dist/providers/classifyCodexErrorCode.d.ts.map +1 -0
- package/dist/providers/classifyCodexErrorCode.js +11 -0
- package/dist/providers/claude-sdk.d.ts +12 -0
- package/dist/providers/claude-sdk.d.ts.map +1 -0
- package/dist/providers/claude-sdk.js +814 -0
- package/dist/providers/codex.d.ts +12 -0
- package/dist/providers/codex.d.ts.map +1 -0
- package/dist/providers/codex.js +76 -0
- package/dist/providers/collectImageDetails.d.ts +3 -0
- package/dist/providers/collectImageDetails.d.ts.map +1 -0
- package/dist/providers/collectImageDetails.js +14 -0
- package/dist/providers/createBedrockMantleStream.d.ts +13 -0
- package/dist/providers/createBedrockMantleStream.d.ts.map +1 -0
- package/dist/providers/createBedrockMantleStream.js +234 -0
- package/dist/providers/createBedrockOpenAIClient.d.ts +7 -0
- package/dist/providers/createBedrockOpenAIClient.d.ts.map +1 -0
- package/dist/providers/createBedrockOpenAIClient.js +7 -0
- package/dist/providers/createBedrockOpenAIRequest.d.ts +9 -0
- package/dist/providers/createBedrockOpenAIRequest.d.ts.map +1 -0
- package/dist/providers/createBedrockOpenAIRequest.js +30 -0
- package/dist/providers/createBedrockRuntimeStream.d.ts +14 -0
- package/dist/providers/createBedrockRuntimeStream.d.ts.map +1 -0
- package/dist/providers/createBedrockRuntimeStream.js +41 -0
- package/dist/providers/createInferenceStream.d.ts +3 -0
- package/dist/providers/createInferenceStream.d.ts.map +1 -0
- package/dist/providers/createInferenceStream.js +45 -0
- package/dist/providers/createPiBedrockRuntimeModel.d.ts +4 -0
- package/dist/providers/createPiBedrockRuntimeModel.d.ts.map +1 -0
- package/dist/providers/createPiBedrockRuntimeModel.js +20 -0
- package/dist/providers/finishBedrockOpenAIOutputItem.d.ts +5 -0
- package/dist/providers/finishBedrockOpenAIOutputItem.d.ts.map +1 -0
- package/dist/providers/finishBedrockOpenAIOutputItem.js +53 -0
- package/dist/providers/getBedrockModelRoute.d.ts +3 -0
- package/dist/providers/getBedrockModelRoute.d.ts.map +1 -0
- package/dist/providers/getBedrockModelRoute.js +4 -0
- package/dist/providers/isBedrockModelAvailableInRegion.d.ts +3 -0
- package/dist/providers/isBedrockModelAvailableInRegion.d.ts.map +1 -0
- package/dist/providers/isBedrockModelAvailableInRegion.js +3 -0
- package/dist/providers/models.d.ts +21 -0
- package/dist/providers/models.d.ts.map +1 -0
- package/dist/providers/models.js +96 -0
- package/dist/providers/parseOpenAIToolArguments.d.ts +2 -0
- package/dist/providers/parseOpenAIToolArguments.d.ts.map +1 -0
- package/dist/providers/parseOpenAIToolArguments.js +11 -0
- package/dist/providers/pi-bridge.d.ts +8 -0
- package/dist/providers/pi-bridge.d.ts.map +1 -0
- package/dist/providers/pi-bridge.js +246 -0
- package/dist/providers/readBedrockBearerToken.d.ts +2 -0
- package/dist/providers/readBedrockBearerToken.d.ts.map +1 -0
- package/dist/providers/readBedrockBearerToken.js +4 -0
- package/dist/providers/readClaudeCodeOAuthToken.d.ts +2 -0
- package/dist/providers/readClaudeCodeOAuthToken.d.ts.map +1 -0
- package/dist/providers/readClaudeCodeOAuthToken.js +51 -0
- package/dist/providers/replaceAssistantContent.d.ts +3 -0
- package/dist/providers/replaceAssistantContent.d.ts.map +1 -0
- package/dist/providers/replaceAssistantContent.js +5 -0
- package/dist/providers/requestAnthropicMessage.d.ts +6 -0
- package/dist/providers/requestAnthropicMessage.d.ts.map +1 -0
- package/dist/providers/requestAnthropicMessage.js +36 -0
- package/dist/providers/resolveBedrockRegion.d.ts +2 -0
- package/dist/providers/resolveBedrockRegion.d.ts.map +1 -0
- package/dist/providers/resolveBedrockRegion.js +3 -0
- package/dist/providers/resolveBedrockRuntimeModelId.d.ts +3 -0
- package/dist/providers/resolveBedrockRuntimeModelId.d.ts.map +1 -0
- package/dist/providers/resolveBedrockRuntimeModelId.js +8 -0
- package/dist/providers/resolveClaudeCodeExecutablePath.d.ts +2 -0
- package/dist/providers/resolveClaudeCodeExecutablePath.d.ts.map +1 -0
- package/dist/providers/resolveClaudeCodeExecutablePath.js +28 -0
- package/dist/providers/toBedrockAssistantContent.d.ts +4 -0
- package/dist/providers/toBedrockAssistantContent.d.ts.map +1 -0
- package/dist/providers/toBedrockAssistantContent.js +18 -0
- package/dist/providers/toOpenAIReasoningEffort.d.ts +3 -0
- package/dist/providers/toOpenAIReasoningEffort.d.ts.map +1 -0
- package/dist/providers/toOpenAIReasoningEffort.js +14 -0
- package/dist/providers/toOpenAIResponseInput.d.ts +4 -0
- package/dist/providers/toOpenAIResponseInput.d.ts.map +1 -0
- package/dist/providers/toOpenAIResponseInput.js +81 -0
- package/dist/providers/toOpenAIResponseTools.d.ts +4 -0
- package/dist/providers/toOpenAIResponseTools.d.ts.map +1 -0
- package/dist/providers/toOpenAIResponseTools.js +9 -0
- package/dist/providers/toPiReasoningLevel.d.ts +3 -0
- package/dist/providers/toPiReasoningLevel.d.ts.map +1 -0
- package/dist/providers/toPiReasoningLevel.js +16 -0
- package/dist/providers/types.d.ts +187 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +18 -0
- package/dist/server/AgentSessionManager.d.ts +19 -0
- package/dist/server/AgentSessionManager.d.ts.map +1 -0
- package/dist/server/AgentSessionManager.js +65 -0
- package/dist/server/InMemorySession.d.ts +88 -0
- package/dist/server/InMemorySession.d.ts.map +1 -0
- package/dist/server/InMemorySession.js +676 -0
- package/dist/server/InMemorySessionStore.d.ts +19 -0
- package/dist/server/InMemorySessionStore.d.ts.map +1 -0
- package/dist/server/InMemorySessionStore.js +69 -0
- package/dist/server/LocalServerPaths.d.ts +10 -0
- package/dist/server/LocalServerPaths.d.ts.map +1 -0
- package/dist/server/LocalServerPaths.js +14 -0
- package/dist/server/PersistentSessionStore.d.ts +28 -0
- package/dist/server/PersistentSessionStore.d.ts.map +1 -0
- package/dist/server/PersistentSessionStore.js +619 -0
- package/dist/server/SessionEventLog.d.ts +17 -0
- package/dist/server/SessionEventLog.d.ts.map +1 -0
- package/dist/server/SessionEventLog.js +42 -0
- package/dist/server/SessionStore.d.ts +13 -0
- package/dist/server/SessionStore.d.ts.map +1 -0
- package/dist/server/SessionStore.js +1 -0
- package/dist/server/createModelCatalog.d.ts +7 -0
- package/dist/server/createModelCatalog.d.ts.map +1 -0
- package/dist/server/createModelCatalog.js +40 -0
- package/dist/server/createProtocolHttpServer.d.ts +12 -0
- package/dist/server/createProtocolHttpServer.d.ts.map +1 -0
- package/dist/server/createProtocolHttpServer.js +280 -0
- package/dist/server/generateSessionTitle.d.ts +8 -0
- package/dist/server/generateSessionTitle.d.ts.map +1 -0
- package/dist/server/generateSessionTitle.js +59 -0
- package/dist/server/getDefaultSessionDatabasePath.d.ts +2 -0
- package/dist/server/getDefaultSessionDatabasePath.d.ts.map +1 -0
- package/dist/server/getDefaultSessionDatabasePath.js +6 -0
- package/dist/server/getProviderIdForModel.d.ts +3 -0
- package/dist/server/getProviderIdForModel.d.ts.map +1 -0
- package/dist/server/getProviderIdForModel.js +4 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +14 -0
- package/dist/server/prepareLocalServerDirectory.d.ts +2 -0
- package/dist/server/prepareLocalServerDirectory.d.ts.map +1 -0
- package/dist/server/prepareLocalServerDirectory.js +5 -0
- package/dist/server/readLocalServerToken.d.ts +2 -0
- package/dist/server/readLocalServerToken.d.ts.map +1 -0
- package/dist/server/readLocalServerToken.js +4 -0
- package/dist/server/removeStaleSocket.d.ts +2 -0
- package/dist/server/removeStaleSocket.d.ts.map +1 -0
- package/dist/server/removeStaleSocket.js +19 -0
- package/dist/server/resolveInitialModelSelection.d.ts +8 -0
- package/dist/server/resolveInitialModelSelection.d.ts.map +1 -0
- package/dist/server/resolveInitialModelSelection.js +31 -0
- package/dist/server/runLocalProtocolServer.d.ts +6 -0
- package/dist/server/runLocalProtocolServer.d.ts.map +1 -0
- package/dist/server/runLocalProtocolServer.js +82 -0
- package/dist/server/uniqueModelsById.d.ts +3 -0
- package/dist/server/uniqueModelsById.d.ts.map +1 -0
- package/dist/server/uniqueModelsById.js +3 -0
- package/dist/server/writeLocalServerToken.d.ts +2 -0
- package/dist/server/writeLocalServerToken.d.ts.map +1 -0
- package/dist/server/writeLocalServerToken.js +11 -0
- package/dist/tools/Agent.d.ts +9 -0
- package/dist/tools/Agent.d.ts.map +1 -0
- package/dist/tools/Agent.js +49 -0
- package/dist/tools/claude/Bash.d.ts +12 -0
- package/dist/tools/claude/Bash.d.ts.map +1 -0
- package/dist/tools/claude/Bash.js +30 -0
- package/dist/tools/claude/Edit.d.ts +13 -0
- package/dist/tools/claude/Edit.d.ts.map +1 -0
- package/dist/tools/claude/Edit.js +44 -0
- package/dist/tools/claude/Glob.d.ts +7 -0
- package/dist/tools/claude/Glob.d.ts.map +1 -0
- package/dist/tools/claude/Glob.js +36 -0
- package/dist/tools/claude/Grep.d.ts +19 -0
- package/dist/tools/claude/Grep.d.ts.map +1 -0
- package/dist/tools/claude/Grep.js +103 -0
- package/dist/tools/claude/Read.d.ts +18 -0
- package/dist/tools/claude/Read.d.ts.map +1 -0
- package/dist/tools/claude/Read.js +84 -0
- package/dist/tools/claude/TodoWrite.d.ts +10 -0
- package/dist/tools/claude/TodoWrite.d.ts.map +1 -0
- package/dist/tools/claude/TodoWrite.js +27 -0
- package/dist/tools/claude/WebFetch.d.ts +29 -0
- package/dist/tools/claude/WebFetch.d.ts.map +1 -0
- package/dist/tools/claude/WebFetch.js +114 -0
- package/dist/tools/claude/WebSearch.d.ts +35 -0
- package/dist/tools/claude/WebSearch.d.ts.map +1 -0
- package/dist/tools/claude/WebSearch.js +83 -0
- package/dist/tools/claude/Write.d.ts +7 -0
- package/dist/tools/claude/Write.d.ts.map +1 -0
- package/dist/tools/claude/Write.js +32 -0
- package/dist/tools/claude/index.d.ts +107 -0
- package/dist/tools/claude/index.d.ts.map +1 -0
- package/dist/tools/claude/index.js +29 -0
- package/dist/tools/claude/webFetch/applyPromptToMarkdown.d.ts +3 -0
- package/dist/tools/claude/webFetch/applyPromptToMarkdown.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/applyPromptToMarkdown.js +21 -0
- package/dist/tools/claude/webFetch/cache.d.ts +6 -0
- package/dist/tools/claude/webFetch/cache.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/cache.js +15 -0
- package/dist/tools/claude/webFetch/checkWebFetchDomain.d.ts +2 -0
- package/dist/tools/claude/webFetch/checkWebFetchDomain.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/checkWebFetchDomain.js +29 -0
- package/dist/tools/claude/webFetch/createTimedSignal.d.ts +6 -0
- package/dist/tools/claude/webFetch/createTimedSignal.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/createTimedSignal.js +18 -0
- package/dist/tools/claude/webFetch/getTurndownService.d.ts +3 -0
- package/dist/tools/claude/webFetch/getTurndownService.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/getTurndownService.js +5 -0
- package/dist/tools/claude/webFetch/getUrlMarkdownContent.d.ts +3 -0
- package/dist/tools/claude/webFetch/getUrlMarkdownContent.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/getUrlMarkdownContent.js +46 -0
- package/dist/tools/claude/webFetch/getWithPermittedRedirects.d.ts +7 -0
- package/dist/tools/claude/webFetch/getWithPermittedRedirects.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/getWithPermittedRedirects.js +50 -0
- package/dist/tools/claude/webFetch/isBinaryContentType.d.ts +2 -0
- package/dist/tools/claude/webFetch/isBinaryContentType.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/isBinaryContentType.js +15 -0
- package/dist/tools/claude/webFetch/isPermittedWebFetchRedirect.d.ts +2 -0
- package/dist/tools/claude/webFetch/isPermittedWebFetchRedirect.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/isPermittedWebFetchRedirect.js +18 -0
- package/dist/tools/claude/webFetch/isPreapprovedWebFetchUrl.d.ts +2 -0
- package/dist/tools/claude/webFetch/isPreapprovedWebFetchUrl.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/isPreapprovedWebFetchUrl.js +111 -0
- package/dist/tools/claude/webFetch/makeWebFetchModelPrompt.d.ts +2 -0
- package/dist/tools/claude/webFetch/makeWebFetchModelPrompt.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/makeWebFetchModelPrompt.js +17 -0
- package/dist/tools/claude/webFetch/persistWebFetchBinary.d.ts +2 -0
- package/dist/tools/claude/webFetch/persistWebFetchBinary.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/persistWebFetchBinary.js +29 -0
- package/dist/tools/claude/webFetch/readWebFetchResponse.d.ts +2 -0
- package/dist/tools/claude/webFetch/readWebFetchResponse.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/readWebFetchResponse.js +26 -0
- package/dist/tools/claude/webFetch/types.d.ts +17 -0
- package/dist/tools/claude/webFetch/types.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/types.js +1 -0
- package/dist/tools/claude/webFetch/validateWebFetchUrl.d.ts +2 -0
- package/dist/tools/claude/webFetch/validateWebFetchUrl.d.ts.map +1 -0
- package/dist/tools/claude/webFetch/validateWebFetchUrl.js +19 -0
- package/dist/tools/claude/webSearch/formatWebSearchOutput.d.ts +3 -0
- package/dist/tools/claude/webSearch/formatWebSearchOutput.d.ts.map +1 -0
- package/dist/tools/claude/webSearch/formatWebSearchOutput.js +17 -0
- package/dist/tools/claude/webSearch/makeWebSearchOutput.d.ts +4 -0
- package/dist/tools/claude/webSearch/makeWebSearchOutput.d.ts.map +1 -0
- package/dist/tools/claude/webSearch/makeWebSearchOutput.js +40 -0
- package/dist/tools/claude/webSearch/performWebSearch.d.ts +3 -0
- package/dist/tools/claude/webSearch/performWebSearch.d.ts.map +1 -0
- package/dist/tools/claude/webSearch/performWebSearch.js +32 -0
- package/dist/tools/claude/webSearch/types.d.ts +19 -0
- package/dist/tools/claude/webSearch/types.d.ts.map +1 -0
- package/dist/tools/claude/webSearch/types.js +1 -0
- package/dist/tools/codex/apply_patch.d.ts +7 -0
- package/dist/tools/codex/apply_patch.d.ts.map +1 -0
- package/dist/tools/codex/apply_patch.js +24 -0
- package/dist/tools/codex/exec_command.d.ts +15 -0
- package/dist/tools/codex/exec_command.d.ts.map +1 -0
- package/dist/tools/codex/exec_command.js +45 -0
- package/dist/tools/codex/index.d.ts +37 -0
- package/dist/tools/codex/index.d.ts.map +1 -0
- package/dist/tools/codex/index.js +14 -0
- package/dist/tools/codex/view_image.d.ts +8 -0
- package/dist/tools/codex/view_image.d.ts.map +1 -0
- package/dist/tools/codex/view_image.js +64 -0
- package/dist/tools/codex/write_stdin.d.ts +9 -0
- package/dist/tools/codex/write_stdin.d.ts.map +1 -0
- package/dist/tools/codex/write_stdin.js +29 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +5 -0
- package/dist/tools/pi/bash.d.ts +7 -0
- package/dist/tools/pi/bash.d.ts.map +1 -0
- package/dist/tools/pi/bash.js +31 -0
- package/dist/tools/pi/edit.d.ts +14 -0
- package/dist/tools/pi/edit.d.ts.map +1 -0
- package/dist/tools/pi/edit.js +73 -0
- package/dist/tools/pi/find.d.ts +8 -0
- package/dist/tools/pi/find.d.ts.map +1 -0
- package/dist/tools/pi/find.js +32 -0
- package/dist/tools/pi/grep.d.ts +12 -0
- package/dist/tools/pi/grep.d.ts.map +1 -0
- package/dist/tools/pi/grep.js +55 -0
- package/dist/tools/pi/index.d.ts +65 -0
- package/dist/tools/pi/index.d.ts.map +1 -0
- package/dist/tools/pi/index.js +23 -0
- package/dist/tools/pi/ls.d.ts +7 -0
- package/dist/tools/pi/ls.d.ts.map +1 -0
- package/dist/tools/pi/ls.js +31 -0
- package/dist/tools/pi/read.d.ts +13 -0
- package/dist/tools/pi/read.d.ts.map +1 -0
- package/dist/tools/pi/read.js +32 -0
- package/dist/tools/pi/write.d.ts +9 -0
- package/dist/tools/pi/write.d.ts.map +1 -0
- package/dist/tools/pi/write.js +22 -0
- package/dist/tools/testing/createJustBashToolHarness.d.ts +18 -0
- package/dist/tools/testing/createJustBashToolHarness.d.ts.map +1 -0
- package/dist/tools/testing/createJustBashToolHarness.js +33 -0
- package/dist/tools/testing/validImageFixtures.d.ts +7 -0
- package/dist/tools/testing/validImageFixtures.d.ts.map +1 -0
- package/dist/tools/testing/validImageFixtures.js +6 -0
- package/dist/tools/utils/ImageProcessingError.d.ts +4 -0
- package/dist/tools/utils/ImageProcessingError.d.ts.map +1 -0
- package/dist/tools/utils/ImageProcessingError.js +6 -0
- package/dist/tools/utils/content.d.ts +11 -0
- package/dist/tools/utils/content.d.ts.map +1 -0
- package/dist/tools/utils/content.js +24 -0
- package/dist/tools/utils/countTextLines.d.ts +2 -0
- package/dist/tools/utils/countTextLines.d.ts.map +1 -0
- package/dist/tools/utils/countTextLines.js +6 -0
- package/dist/tools/utils/file.d.ts +90 -0
- package/dist/tools/utils/file.d.ts.map +1 -0
- package/dist/tools/utils/file.js +331 -0
- package/dist/tools/utils/getImageProcessor.d.ts +3 -0
- package/dist/tools/utils/getImageProcessor.d.ts.map +1 -0
- package/dist/tools/utils/getImageProcessor.js +9 -0
- package/dist/tools/utils/image.d.ts +2 -0
- package/dist/tools/utils/image.d.ts.map +1 -0
- package/dist/tools/utils/image.js +15 -0
- package/dist/tools/utils/index.d.ts +17 -0
- package/dist/tools/utils/index.d.ts.map +1 -0
- package/dist/tools/utils/index.js +16 -0
- package/dist/tools/utils/patch.d.ts +7 -0
- package/dist/tools/utils/patch.d.ts.map +1 -0
- package/dist/tools/utils/patch.js +107 -0
- package/dist/tools/utils/path.d.ts +4 -0
- package/dist/tools/utils/path.d.ts.map +1 -0
- package/dist/tools/utils/path.js +17 -0
- package/dist/tools/utils/prepareImageForClaude.d.ts +7 -0
- package/dist/tools/utils/prepareImageForClaude.d.ts.map +1 -0
- package/dist/tools/utils/prepareImageForClaude.js +195 -0
- package/dist/tools/utils/prepareImageForPrompt.d.ts +12 -0
- package/dist/tools/utils/prepareImageForPrompt.d.ts.map +1 -0
- package/dist/tools/utils/prepareImageForPrompt.js +100 -0
- package/dist/tools/utils/promptImageOutputDimensions.d.ts +10 -0
- package/dist/tools/utils/promptImageOutputDimensions.d.ts.map +1 -0
- package/dist/tools/utils/promptImageOutputDimensions.js +26 -0
- package/dist/tools/utils/search.d.ts +34 -0
- package/dist/tools/utils/search.d.ts.map +1 -0
- package/dist/tools/utils/search.js +133 -0
- package/dist/tools/utils/shell.d.ts +27 -0
- package/dist/tools/utils/shell.d.ts.map +1 -0
- package/dist/tools/utils/shell.js +48 -0
- package/dist/tools/utils/singleLineText.d.ts +2 -0
- package/dist/tools/utils/singleLineText.d.ts.map +1 -0
- package/dist/tools/utils/singleLineText.js +3 -0
- package/dist/tools/utils/summarizeShellOutput.d.ts +4 -0
- package/dist/tools/utils/summarizeShellOutput.d.ts.map +1 -0
- package/dist/tools/utils/summarizeShellOutput.js +11 -0
- package/dist/tools/utils/summarizeTextOutput.d.ts +2 -0
- package/dist/tools/utils/summarizeTextOutput.d.ts.map +1 -0
- package/dist/tools/utils/summarizeTextOutput.js +12 -0
- package/dist/web/assets/abap-BdImnpbu.js +1 -0
- package/dist/web/assets/actionscript-3-CoDkCxhg.js +1 -0
- package/dist/web/assets/ada-bCR0ucgS.js +1 -0
- package/dist/web/assets/andromeeda-C4gqWexZ.js +1 -0
- package/dist/web/assets/angular-html-DA-rfuFy.js +1 -0
- package/dist/web/assets/angular-ts-BrjP3tb8.js +1 -0
- package/dist/web/assets/apache-Pmp26Uib.js +1 -0
- package/dist/web/assets/apex-Dqspr-GT.js +1 -0
- package/dist/web/assets/apl-CORt7UWP.js +1 -0
- package/dist/web/assets/applescript-Co6uUVPk.js +1 -0
- package/dist/web/assets/ara-BRHolxvo.js +1 -0
- package/dist/web/assets/asciidoc-Ve4PFQV2.js +1 -0
- package/dist/web/assets/asm-D_Q5rh1f.js +1 -0
- package/dist/web/assets/astro-HNnZUWAn.js +1 -0
- package/dist/web/assets/aurora-x-D-2ljcwZ.js +1 -0
- package/dist/web/assets/awk-DMzUqQB5.js +1 -0
- package/dist/web/assets/ayu-dark-DYE7WIF3.js +1 -0
- package/dist/web/assets/ayu-light-BA47KaF1.js +1 -0
- package/dist/web/assets/ayu-mirage-32ctXXKs.js +1 -0
- package/dist/web/assets/ballerina-BFfxhgS-.js +1 -0
- package/dist/web/assets/bat-BkioyH1T.js +1 -0
- package/dist/web/assets/beancount-k_qm7-4y.js +1 -0
- package/dist/web/assets/berry-uYugtg8r.js +1 -0
- package/dist/web/assets/bibtex-CHM0blh-.js +1 -0
- package/dist/web/assets/bicep-Bmn6On1c.js +1 -0
- package/dist/web/assets/bird2-BIv1doCn.js +1 -0
- package/dist/web/assets/blade-2xfisSek.js +1 -0
- package/dist/web/assets/bsl-BO_Y6i37.js +1 -0
- package/dist/web/assets/c-BIGW1oBm.js +1 -0
- package/dist/web/assets/c3-MRO5bC_T.js +1 -0
- package/dist/web/assets/cadence-Bv_4Rxtq.js +1 -0
- package/dist/web/assets/cairo-KRGpt6FW.js +1 -0
- package/dist/web/assets/catppuccin-frappe-DFWUc33u.js +1 -0
- package/dist/web/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
- package/dist/web/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
- package/dist/web/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
- package/dist/web/assets/clarity-D53aC0YG.js +1 -0
- package/dist/web/assets/clojure-P80f7IUj.js +1 -0
- package/dist/web/assets/cmake-D1j8_8rp.js +1 -0
- package/dist/web/assets/cobol-nBiQ_Alo.js +1 -0
- package/dist/web/assets/codeowners-Bp6g37R7.js +1 -0
- package/dist/web/assets/codeql-DsOJ9woJ.js +1 -0
- package/dist/web/assets/coffee-Ch7k5sss.js +1 -0
- package/dist/web/assets/common-lisp-Cg-RD9OK.js +1 -0
- package/dist/web/assets/coq-DkFqJrB1.js +1 -0
- package/dist/web/assets/cpp-UfJy6YNI.js +1 -0
- package/dist/web/assets/crystal-DGywbUpC.js +1 -0
- package/dist/web/assets/csharp-DSvCPggb.js +1 -0
- package/dist/web/assets/css-CLj8gQPS.js +1 -0
- package/dist/web/assets/csv-fuZLfV_i.js +1 -0
- package/dist/web/assets/cue-D82EKSYY.js +1 -0
- package/dist/web/assets/cypher-COkxafJQ.js +1 -0
- package/dist/web/assets/d-85-TOEBH.js +1 -0
- package/dist/web/assets/dark-plus-C3mMm8J8.js +1 -0
- package/dist/web/assets/dart-bE4Kk8sk.js +1 -0
- package/dist/web/assets/dax-CEL-wOlO.js +1 -0
- package/dist/web/assets/desktop-BmXAJ9_W.js +1 -0
- package/dist/web/assets/diff-D97Zzqfu.js +1 -0
- package/dist/web/assets/docker-BcOcwvcX.js +1 -0
- package/dist/web/assets/dotenv-Da5cRb03.js +1 -0
- package/dist/web/assets/dracula-BzJJZx-M.js +1 -0
- package/dist/web/assets/dracula-soft-BXkSAIEj.js +1 -0
- package/dist/web/assets/dream-maker-BtqSS_iP.js +1 -0
- package/dist/web/assets/edge-FbVlp4U3.js +1 -0
- package/dist/web/assets/elixir-CkH2-t6x.js +1 -0
- package/dist/web/assets/elm-DbKCFpqz.js +1 -0
- package/dist/web/assets/emacs-lisp-CXvaQtF9.js +1 -0
- package/dist/web/assets/erb-Dm6A9KJ5.js +1 -0
- package/dist/web/assets/erlang-DsQrWhSR.js +1 -0
- package/dist/web/assets/everforest-dark-BgDCqdQA.js +1 -0
- package/dist/web/assets/everforest-light-C8M2exoo.js +1 -0
- package/dist/web/assets/fennel-BYunw83y.js +1 -0
- package/dist/web/assets/fish-BvzEVeQv.js +1 -0
- package/dist/web/assets/fluent-C4IJs8-o.js +1 -0
- package/dist/web/assets/fortran-fixed-form-CkoXwp7k.js +1 -0
- package/dist/web/assets/fortran-free-form-BxgE0vQu.js +1 -0
- package/dist/web/assets/fsharp-CXgrBDvD.js +1 -0
- package/dist/web/assets/gdresource-BOOCDP_w.js +1 -0
- package/dist/web/assets/gdscript-C5YyOfLZ.js +1 -0
- package/dist/web/assets/gdshader-DkwncUOv.js +1 -0
- package/dist/web/assets/genie-D0YGMca9.js +1 -0
- package/dist/web/assets/gherkin-DyxjwDmM.js +1 -0
- package/dist/web/assets/git-commit-F4YmCXRG.js +1 -0
- package/dist/web/assets/git-rebase-r7XF79zn.js +1 -0
- package/dist/web/assets/github-dark-DHJKELXO.js +1 -0
- package/dist/web/assets/github-dark-default-Cuk6v7N8.js +1 -0
- package/dist/web/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
- package/dist/web/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
- package/dist/web/assets/github-light-DAi9KRSo.js +1 -0
- package/dist/web/assets/github-light-default-D7oLnXFd.js +1 -0
- package/dist/web/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
- package/dist/web/assets/gleam-BspZqrRM.js +1 -0
- package/dist/web/assets/glimmer-js-ByusRIyA.js +1 -0
- package/dist/web/assets/glimmer-ts-BfAWNZQY.js +1 -0
- package/dist/web/assets/glsl-DplSGwfg.js +1 -0
- package/dist/web/assets/gn-n2N0HUVH.js +1 -0
- package/dist/web/assets/gnuplot-DdkO51Og.js +1 -0
- package/dist/web/assets/go-C27-OAKa.js +1 -0
- package/dist/web/assets/graphql-ChdNCCLP.js +1 -0
- package/dist/web/assets/groovy-gcz8RCvz.js +1 -0
- package/dist/web/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
- package/dist/web/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
- package/dist/web/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
- package/dist/web/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
- package/dist/web/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
- package/dist/web/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
- package/dist/web/assets/hack-DbPARsA_.js +1 -0
- package/dist/web/assets/haml-D5jkg6IW.js +1 -0
- package/dist/web/assets/handlebars-BpdQsYii.js +1 -0
- package/dist/web/assets/haskell-Df6bDoY_.js +1 -0
- package/dist/web/assets/haxe-CzTSHFRz.js +1 -0
- package/dist/web/assets/hcl-BWvSN4gD.js +1 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-CyimQElG.js +1 -0
- package/dist/web/assets/hjson-D5-asLiD.js +1 -0
- package/dist/web/assets/hlsl-D3lLCCz7.js +1 -0
- package/dist/web/assets/horizon-BUw7H-hv.js +1 -0
- package/dist/web/assets/horizon-bright-CUuTKBJd.js +1 -0
- package/dist/web/assets/houston-DnULxvSX.js +1 -0
- package/dist/web/assets/html-derivative-DlHx6ybY.js +1 -0
- package/dist/web/assets/html-pp8916En.js +1 -0
- package/dist/web/assets/http-jrhK8wxY.js +1 -0
- package/dist/web/assets/hurl-irOxFIW8.js +1 -0
- package/dist/web/assets/hxml-Bvhsp5Yf.js +1 -0
- package/dist/web/assets/hy-DFXneXwc.js +1 -0
- package/dist/web/assets/imba-DGztddWO.js +1 -0
- package/dist/web/assets/index-D5rSlaXz.js +341 -0
- package/dist/web/assets/index-YIUxhOuk.css +1 -0
- package/dist/web/assets/ini-BEwlwnbL.js +1 -0
- package/dist/web/assets/java-CylS5w8V.js +1 -0
- package/dist/web/assets/javascript-wDzz0qaB.js +1 -0
- package/dist/web/assets/jinja-f2NsQr07.js +1 -0
- package/dist/web/assets/jison-wvAkD_A8.js +1 -0
- package/dist/web/assets/json-Cp-IABpG.js +1 -0
- package/dist/web/assets/json5-C9tS-k6U.js +1 -0
- package/dist/web/assets/jsonc-Des-eS-w.js +1 -0
- package/dist/web/assets/jsonl-DcaNXYhu.js +1 -0
- package/dist/web/assets/jsonnet-DFQXde-d.js +1 -0
- package/dist/web/assets/jssm-C2t-YnRu.js +1 -0
- package/dist/web/assets/jsx-g9-lgVsj.js +1 -0
- package/dist/web/assets/julia-D7OTSIA_.js +1 -0
- package/dist/web/assets/just-CUsbIsdP.js +1 -0
- package/dist/web/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
- package/dist/web/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
- package/dist/web/assets/kanagawa-wave-DWedfzmr.js +1 -0
- package/dist/web/assets/kdl-DV7GczEv.js +1 -0
- package/dist/web/assets/kotlin-BdnUsdx6.js +1 -0
- package/dist/web/assets/kusto-wEQ09or8.js +1 -0
- package/dist/web/assets/laserwave-DUszq2jm.js +1 -0
- package/dist/web/assets/latex-CaSxy8MP.js +1 -0
- package/dist/web/assets/lean-BZvkOJ9d.js +1 -0
- package/dist/web/assets/less-B1dDrJ26.js +1 -0
- package/dist/web/assets/light-plus-B7mTdjB0.js +1 -0
- package/dist/web/assets/liquid-C0sCDyMI.js +1 -0
- package/dist/web/assets/llvm-DjAJT7YJ.js +1 -0
- package/dist/web/assets/log-2UxHyX5q.js +1 -0
- package/dist/web/assets/logo-BtOb2qkB.js +1 -0
- package/dist/web/assets/lua-BaeVxFsk.js +1 -0
- package/dist/web/assets/luau-KW6xsasC.js +1 -0
- package/dist/web/assets/make-CHLpvVh8.js +1 -0
- package/dist/web/assets/markdown-Cvjx9yec.js +1 -0
- package/dist/web/assets/marko-DjSrsDqO.js +1 -0
- package/dist/web/assets/material-theme-D5KoaKCx.js +1 -0
- package/dist/web/assets/material-theme-darker-BfHTSMKl.js +1 -0
- package/dist/web/assets/material-theme-lighter-B0m2ddpp.js +1 -0
- package/dist/web/assets/material-theme-ocean-CyktbL80.js +1 -0
- package/dist/web/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
- package/dist/web/assets/matlab-D7o27uSR.js +1 -0
- package/dist/web/assets/mdc-DTYItulj.js +1 -0
- package/dist/web/assets/mdx-Cmh6b_Ma.js +1 -0
- package/dist/web/assets/mermaid-mWjccvbQ.js +1 -0
- package/dist/web/assets/min-dark-CafNBF8u.js +1 -0
- package/dist/web/assets/min-light-CTRr51gU.js +1 -0
- package/dist/web/assets/mipsasm-CKIfxQSi.js +1 -0
- package/dist/web/assets/mojo-rZm6bMo-.js +1 -0
- package/dist/web/assets/monokai-D4h5O-jR.js +1 -0
- package/dist/web/assets/moonbit-_H4v1dQx.js +1 -0
- package/dist/web/assets/move-IF9eRakj.js +1 -0
- package/dist/web/assets/narrat-DRg8JJMk.js +1 -0
- package/dist/web/assets/nextflow-C-mBbutL.js +1 -0
- package/dist/web/assets/nextflow-groovy-vE_lwT2v.js +1 -0
- package/dist/web/assets/nginx-BpAMiNFr.js +1 -0
- package/dist/web/assets/night-owl-C39BiMTA.js +1 -0
- package/dist/web/assets/night-owl-light-CMTm3GFP.js +1 -0
- package/dist/web/assets/nim-BIad80T-.js +1 -0
- package/dist/web/assets/nix-CwoSXNpI.js +1 -0
- package/dist/web/assets/nord-Ddv68eIx.js +1 -0
- package/dist/web/assets/nushell-Cz2AlsmD.js +1 -0
- package/dist/web/assets/objective-c-DXmwc3jG.js +1 -0
- package/dist/web/assets/objective-cpp-CLxacb5B.js +1 -0
- package/dist/web/assets/ocaml-C0hk2d4L.js +1 -0
- package/dist/web/assets/odin-BBf5iR-q.js +1 -0
- package/dist/web/assets/one-dark-pro-DVMEJ2y_.js +1 -0
- package/dist/web/assets/one-light-C3Wv6jpd.js +1 -0
- package/dist/web/assets/openscad-C4EeE6gA.js +1 -0
- package/dist/web/assets/pascal-D93ZcfNL.js +1 -0
- package/dist/web/assets/perl-B9cMNwum.js +1 -0
- package/dist/web/assets/php-Csjmro_R.js +1 -0
- package/dist/web/assets/pkl-u5AG7uiY.js +1 -0
- package/dist/web/assets/plastic-3e1v2bzS.js +1 -0
- package/dist/web/assets/plsql-ChMvpjG-.js +1 -0
- package/dist/web/assets/po-BTJTHyun.js +1 -0
- package/dist/web/assets/poimandres-CS3Unz2-.js +1 -0
- package/dist/web/assets/polar-C0HS_06l.js +1 -0
- package/dist/web/assets/postcss-CXtECtnM.js +1 -0
- package/dist/web/assets/powerquery-CEu0bR-o.js +1 -0
- package/dist/web/assets/powershell-Dpen1YoG.js +1 -0
- package/dist/web/assets/prisma-Dd19v3D-.js +1 -0
- package/dist/web/assets/prolog-CbFg5uaA.js +1 -0
- package/dist/web/assets/proto-C7zT0LnQ.js +1 -0
- package/dist/web/assets/pug-DKIMFp6K.js +1 -0
- package/dist/web/assets/puppet-BMWR74SV.js +1 -0
- package/dist/web/assets/purescript-CklMAg4u.js +1 -0
- package/dist/web/assets/python-B6aJPvgy.js +1 -0
- package/dist/web/assets/qml-3beO22l8.js +1 -0
- package/dist/web/assets/qmldir-C8lEn-DE.js +1 -0
- package/dist/web/assets/qss-IeuSbFQv.js +1 -0
- package/dist/web/assets/r-Dspwwk_N.js +1 -0
- package/dist/web/assets/racket-BqYA7rlc.js +1 -0
- package/dist/web/assets/raku-DXvB9xmW.js +1 -0
- package/dist/web/assets/razor-BjBPvh-w.js +1 -0
- package/dist/web/assets/red-bN70gL4F.js +1 -0
- package/dist/web/assets/reg-C-SQnVFl.js +1 -0
- package/dist/web/assets/regexp-CDVJQ6XC.js +1 -0
- package/dist/web/assets/rel-C3B-1QV4.js +1 -0
- package/dist/web/assets/riscv-BM1_JUlF.js +1 -0
- package/dist/web/assets/ron-D8l8udqQ.js +1 -0
- package/dist/web/assets/rose-pine-dawn-DHQR4-dF.js +1 -0
- package/dist/web/assets/rose-pine-moon-D4_iv3hh.js +1 -0
- package/dist/web/assets/rose-pine-qdsjHGoJ.js +1 -0
- package/dist/web/assets/rosmsg-BJDFO7_C.js +1 -0
- package/dist/web/assets/rst-CpCqk9r5.js +1 -0
- package/dist/web/assets/ruby-DyJCeAvU.js +1 -0
- package/dist/web/assets/rust-B1yitclQ.js +1 -0
- package/dist/web/assets/sas-DEy46yEz.js +1 -0
- package/dist/web/assets/sass-Cj5Yp3dK.js +1 -0
- package/dist/web/assets/scala-C151Ov-r.js +1 -0
- package/dist/web/assets/scheme-C98Dy4si.js +1 -0
- package/dist/web/assets/scss-D5BDwBP9.js +1 -0
- package/dist/web/assets/sdbl-DVxCFoDh.js +1 -0
- package/dist/web/assets/shaderlab-Dg9Lc6iA.js +1 -0
- package/dist/web/assets/shellscript-Yzrsuije.js +1 -0
- package/dist/web/assets/shellsession-BADoaaVG.js +1 -0
- package/dist/web/assets/slack-dark-BthQWCQV.js +1 -0
- package/dist/web/assets/slack-ochin-DqwNpetd.js +1 -0
- package/dist/web/assets/smalltalk-BERRCDM3.js +1 -0
- package/dist/web/assets/snazzy-light-Bw305WKR.js +1 -0
- package/dist/web/assets/solarized-dark-DXbdFlpD.js +1 -0
- package/dist/web/assets/solarized-light-L9t79GZl.js +1 -0
- package/dist/web/assets/solidity-rGO070M0.js +1 -0
- package/dist/web/assets/soy-8wufbnw4.js +1 -0
- package/dist/web/assets/sparql-rVzFXLq3.js +1 -0
- package/dist/web/assets/splunk-BtCnVYZw.js +1 -0
- package/dist/web/assets/sql-CRqJ_cUM.js +1 -0
- package/dist/web/assets/ssh-config-_ykCGR6B.js +1 -0
- package/dist/web/assets/stata-DI20mbqo.js +1 -0
- package/dist/web/assets/stylus-BEDo0Tqx.js +1 -0
- package/dist/web/assets/surrealql-Bq5Q-fJD.js +1 -0
- package/dist/web/assets/svelte-Cy7k_4gC.js +1 -0
- package/dist/web/assets/swift-D82vCrfD.js +1 -0
- package/dist/web/assets/synthwave-84-CbfX1IO0.js +1 -0
- package/dist/web/assets/system-verilog-CnnmHF94.js +1 -0
- package/dist/web/assets/systemd-4A_iFExJ.js +1 -0
- package/dist/web/assets/talonscript-CkByrt1z.js +1 -0
- package/dist/web/assets/tasl-QIJgUcNo.js +1 -0
- package/dist/web/assets/tcl-dwOrl1Do.js +1 -0
- package/dist/web/assets/templ-DhtptRzy.js +1 -0
- package/dist/web/assets/terraform-BETggiCN.js +1 -0
- package/dist/web/assets/tex-idrVyKtj.js +1 -0
- package/dist/web/assets/tokyo-night-hegEt444.js +1 -0
- package/dist/web/assets/toml-vGWfd6FD.js +1 -0
- package/dist/web/assets/ts-tags-D351s5mN.js +1 -0
- package/dist/web/assets/tsv-B_m7g4N7.js +1 -0
- package/dist/web/assets/tsx-COt5Ahok.js +1 -0
- package/dist/web/assets/turtle-BsS91CYL.js +1 -0
- package/dist/web/assets/twig-CW1WmMYd.js +1 -0
- package/dist/web/assets/typescript-BPQ3VLAy.js +1 -0
- package/dist/web/assets/typespec-CAFt9gP4.js +1 -0
- package/dist/web/assets/typst-DHCkPAjA.js +1 -0
- package/dist/web/assets/v-BcVCzyr7.js +1 -0
- package/dist/web/assets/vala-CsfeWuGM.js +1 -0
- package/dist/web/assets/vb-D17OF-Vu.js +1 -0
- package/dist/web/assets/verilog-BQ8w6xss.js +1 -0
- package/dist/web/assets/vesper-DRje8inN.js +1 -0
- package/dist/web/assets/vhdl-CeAyd5Ju.js +1 -0
- package/dist/web/assets/viml-CJc9bBzg.js +1 -0
- package/dist/web/assets/vitesse-black-Bkuqu6BP.js +1 -0
- package/dist/web/assets/vitesse-dark-D0r3Knsf.js +1 -0
- package/dist/web/assets/vitesse-light-CVO1_9PV.js +1 -0
- package/dist/web/assets/vue-D2xRrEX4.js +1 -0
- package/dist/web/assets/vue-html-AaS7Mt5G.js +1 -0
- package/dist/web/assets/vue-vine-BoDAl6tE.js +1 -0
- package/dist/web/assets/vyper-CDx5xZoG.js +1 -0
- package/dist/web/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/web/assets/wasm-MzD3tlZU.js +1 -0
- package/dist/web/assets/wenyan-BV7otONQ.js +1 -0
- package/dist/web/assets/wgsl-Dx-B1_4e.js +1 -0
- package/dist/web/assets/wikitext-BhOHFoWU.js +1 -0
- package/dist/web/assets/wit-5i3qLPDT.js +1 -0
- package/dist/web/assets/wolfram-lXgVvXCa.js +1 -0
- package/dist/web/assets/xml-sdJ4AIDG.js +1 -0
- package/dist/web/assets/xsl-CtQFsRM5.js +1 -0
- package/dist/web/assets/yaml-Buea-lGh.js +1 -0
- package/dist/web/assets/zenscript-DVFEvuxE.js +1 -0
- package/dist/web/assets/zig-VOosw3JB.js +1 -0
- package/dist/web/index.html +13 -0
- package/package.json +99 -0
|
@@ -0,0 +1,1895 @@
|
|
|
1
|
+
import { createId } from "@paralleldrive/cuid2";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { basename, join } from "node:path";
|
|
4
|
+
import { CURSOR_MARKER, Editor, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
5
|
+
import { formatSkillInvocation, loadSkills, } from "../agent/index.js";
|
|
6
|
+
import { parseSkillFrontmatter } from "../agent/skills/parseSkillFrontmatter.js";
|
|
7
|
+
import { createSelectionPanel } from "./createSelectionPanel.js";
|
|
8
|
+
import { createSlashCommands } from "./createSlashCommands.js";
|
|
9
|
+
import { describeModelChoice } from "./describeModelChoice.js";
|
|
10
|
+
import { describeReasoningLevel } from "./describeReasoningLevel.js";
|
|
11
|
+
import { encodeModelChoice } from "./encodeModelChoice.js";
|
|
12
|
+
import { formatActivityElapsedTime } from "./formatActivityElapsedTime.js";
|
|
13
|
+
import { humanizeReasoningLevel } from "./humanizeReasoningLevel.js";
|
|
14
|
+
import { readClipboardImage, } from "./readClipboardImage.js";
|
|
15
|
+
import { ACTIVITY_WAVE_FRAME_COUNT, renderActivityWave } from "./renderActivityWave.js";
|
|
16
|
+
import { renderAgentMarkdown } from "./renderAgentMarkdown.js";
|
|
17
|
+
const RESET = "\x1b[0m";
|
|
18
|
+
const BOLD = "\x1b[1m";
|
|
19
|
+
const DIM = "\x1b[2m";
|
|
20
|
+
const NOT_BOLD_OR_DIM = "\x1b[22m";
|
|
21
|
+
const GREEN = "\x1b[32m";
|
|
22
|
+
const CYAN = "\x1b[36m";
|
|
23
|
+
const YELLOW = "\x1b[33m";
|
|
24
|
+
const RED = "\x1b[31m";
|
|
25
|
+
const RIG_ORANGE = "\x1b[38;5;202m";
|
|
26
|
+
const CURSOR_BG = "\x1b[48;5;244m";
|
|
27
|
+
const CURSOR_FG = "\x1b[38;5;232m";
|
|
28
|
+
const SURFACE_BG = "\x1b[48;5;236m";
|
|
29
|
+
const SURFACE_FG = "\x1b[38;5;252m";
|
|
30
|
+
const INPUT_FG = "\x1b[38;5;255m";
|
|
31
|
+
const SURFACE_MUTED_FG = "\x1b[38;5;245m";
|
|
32
|
+
const FOOTER_MODEL_FG = "\x1b[38;5;252m";
|
|
33
|
+
const FOOTER_CWD_FG = "\x1b[38;5;245m";
|
|
34
|
+
const FOOTER_QUEUED_FG = "\x1b[38;5;246m";
|
|
35
|
+
const INPUT_PLACEHOLDER = "Ask Rig to do anything";
|
|
36
|
+
const INPUT_PROMPT = "› ";
|
|
37
|
+
const INPUT_LINE_INDENT = " ";
|
|
38
|
+
const PENDING_TOOL_CALL_TITLE = "Working";
|
|
39
|
+
const CURSOR_BLINK_MS = 530;
|
|
40
|
+
const CURSOR_TYPING_DEBOUNCE_MS = 530;
|
|
41
|
+
const ACTIVITY_ANIMATION_MS = 120;
|
|
42
|
+
const REASONING_DOWN_RAW_KEYS = new Set(["\x1b,", "\x1b[1;2B"]);
|
|
43
|
+
const REASONING_UP_RAW_KEYS = new Set(["\x1b.", "\x1b[1;2A"]);
|
|
44
|
+
const MODEL_MENU_RAW_KEYS = new Set(["\x1bm", "\x1bM"]);
|
|
45
|
+
const IMAGE_PASTE_RAW_KEYS = new Set(["\x16", "\x1bv"]);
|
|
46
|
+
const SLASH_COMMAND_MAX_VISIBLE = 6;
|
|
47
|
+
const BRACKETED_PASTE_START = "\x1b[200~";
|
|
48
|
+
const BRACKETED_PASTE_END = "\x1b[201~";
|
|
49
|
+
const IMAGE_PLACEHOLDER_REGEX = /\[Image #(\d+) [A-Z0-9]+\]/gu;
|
|
50
|
+
const IMAGE_CHIP_BG = "\x1b[48;5;240m";
|
|
51
|
+
const IMAGE_CHIP_FG = "\x1b[38;5;255m";
|
|
52
|
+
const EDITOR_THEME = {
|
|
53
|
+
borderColor: (text) => text,
|
|
54
|
+
selectList: {
|
|
55
|
+
selectedPrefix: (text) => text,
|
|
56
|
+
selectedText: (text) => `${RIG_ORANGE}${text}${RESET}${INPUT_FG}`,
|
|
57
|
+
description: (text) => `${DIM}${SURFACE_MUTED_FG}${text}${RESET}${INPUT_FG}`,
|
|
58
|
+
scrollInfo: (text) => `${DIM}${SURFACE_MUTED_FG}${text}${RESET}${INPUT_FG}`,
|
|
59
|
+
noMatch: (text) => `${SURFACE_MUTED_FG}${text}${RESET}${INPUT_FG}`,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
const MAX_TRANSCRIPT_ENTRIES = 500;
|
|
63
|
+
export class CodingAssistantApp {
|
|
64
|
+
#agent;
|
|
65
|
+
#cwd;
|
|
66
|
+
#idFactory;
|
|
67
|
+
#now;
|
|
68
|
+
#editor;
|
|
69
|
+
#onDefaultModelChange;
|
|
70
|
+
#onSettingsChange;
|
|
71
|
+
#onExit;
|
|
72
|
+
#processManager;
|
|
73
|
+
#readClipboardImage;
|
|
74
|
+
#tui;
|
|
75
|
+
#version;
|
|
76
|
+
#exitPromise;
|
|
77
|
+
#abortController;
|
|
78
|
+
#abortNotified = false;
|
|
79
|
+
#activeRun;
|
|
80
|
+
#activityAnimationFrame = 0;
|
|
81
|
+
#activityStartedAtMs;
|
|
82
|
+
#activityAnimationTimer;
|
|
83
|
+
#cursorBlinkTimer;
|
|
84
|
+
#cursorTyping = false;
|
|
85
|
+
#cursorTypingDebounceTimer;
|
|
86
|
+
#cursorVisible = true;
|
|
87
|
+
#entries = [];
|
|
88
|
+
#exiting = false;
|
|
89
|
+
#exitResolve;
|
|
90
|
+
#focused = false;
|
|
91
|
+
#pendingPrompts = [];
|
|
92
|
+
#pastedImagesById = new Map();
|
|
93
|
+
#selectionPanel;
|
|
94
|
+
#dismissedSlashCommandText;
|
|
95
|
+
#activeSubmission;
|
|
96
|
+
#bracketedPasteBuffer;
|
|
97
|
+
#showReasoning;
|
|
98
|
+
#sessionBacked;
|
|
99
|
+
#modelLocked;
|
|
100
|
+
#slashCommandSelectionIndex = 0;
|
|
101
|
+
#slashCommands = createSlashCommands();
|
|
102
|
+
#skillCommands = [];
|
|
103
|
+
#skillCommandsLoaded = false;
|
|
104
|
+
#skillCommandsRefresh;
|
|
105
|
+
#skillsByName = new Map();
|
|
106
|
+
#imagePasteInFlight;
|
|
107
|
+
#nextPastedImageId = 1;
|
|
108
|
+
#runToken = 0;
|
|
109
|
+
#running = false;
|
|
110
|
+
#seenToolCallIds = new Set();
|
|
111
|
+
#statusText = "Idle";
|
|
112
|
+
#stopped = false;
|
|
113
|
+
#streamEntryId;
|
|
114
|
+
#thinkingEntryIdsByContentIndex = new Map();
|
|
115
|
+
#toolCallEntryIdsByContentIndex = new Map();
|
|
116
|
+
constructor(options) {
|
|
117
|
+
this.#agent = options.agent;
|
|
118
|
+
this.#cwd = options.cwd;
|
|
119
|
+
this.#idFactory = options.idFactory ?? createId;
|
|
120
|
+
this.#now = options.now ?? Date.now;
|
|
121
|
+
this.#onDefaultModelChange = options.onDefaultModelChange;
|
|
122
|
+
this.#onSettingsChange = options.onSettingsChange;
|
|
123
|
+
this.#onExit = options.onExit;
|
|
124
|
+
this.#processManager = options.processManager;
|
|
125
|
+
this.#readClipboardImage = options.readClipboardImage ?? readClipboardImage;
|
|
126
|
+
this.#sessionBacked = options.sessionBacked ?? false;
|
|
127
|
+
this.#showReasoning = options.showReasoning ?? false;
|
|
128
|
+
this.#modelLocked = options.modelLocked ?? !options.agent.canChangeModel;
|
|
129
|
+
this.#tui = options.tui;
|
|
130
|
+
this.#version = options.version ?? "0.0.0";
|
|
131
|
+
this.#editor = new Editor(this.#tui, EDITOR_THEME, { paddingX: 0 });
|
|
132
|
+
this.#exitPromise = new Promise((resolve) => {
|
|
133
|
+
this.#exitResolve = resolve;
|
|
134
|
+
});
|
|
135
|
+
this.#editor.onSubmit = (value) => {
|
|
136
|
+
this.#submit(value);
|
|
137
|
+
};
|
|
138
|
+
for (const event of options.initialSessionEvents ?? []) {
|
|
139
|
+
this.applySessionEvent(event);
|
|
140
|
+
}
|
|
141
|
+
void this.#refreshSkillCommands();
|
|
142
|
+
}
|
|
143
|
+
get focused() {
|
|
144
|
+
return this.#focused;
|
|
145
|
+
}
|
|
146
|
+
set focused(value) {
|
|
147
|
+
this.#focused = value;
|
|
148
|
+
this.#editor.focused = value;
|
|
149
|
+
this.#cursorVisible = true;
|
|
150
|
+
if (value) {
|
|
151
|
+
this.#cursorTyping = false;
|
|
152
|
+
this.#startCursorBlink();
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.#stopCursorBlink();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
start(options = {}) {
|
|
159
|
+
this.#tui.addChild(this);
|
|
160
|
+
this.focused = true;
|
|
161
|
+
this.#tui.setFocus(this);
|
|
162
|
+
if (options.tuiAlreadyStarted !== true) {
|
|
163
|
+
this.#tui.start();
|
|
164
|
+
}
|
|
165
|
+
this.#requestRender();
|
|
166
|
+
}
|
|
167
|
+
async stop() {
|
|
168
|
+
if (this.#stopped || this.#exiting) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.#exiting = true;
|
|
172
|
+
this.#statusText = "Stopped";
|
|
173
|
+
this.#abortController?.abort();
|
|
174
|
+
this.#stopActivityAnimation();
|
|
175
|
+
this.#stopCursorBlink();
|
|
176
|
+
this.#editor.setText("");
|
|
177
|
+
this.#pastedImagesById.clear();
|
|
178
|
+
this.#requestRender();
|
|
179
|
+
await this.#waitForShutdownRender();
|
|
180
|
+
this.#stopped = true;
|
|
181
|
+
this.#tui.stop();
|
|
182
|
+
try {
|
|
183
|
+
await this.#processManager.killAll({ forceAfterMs: 500 });
|
|
184
|
+
await this.#onExit?.();
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
this.#exitResolve?.();
|
|
188
|
+
this.#requestRender();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
waitForExit() {
|
|
192
|
+
return this.#exitPromise;
|
|
193
|
+
}
|
|
194
|
+
applySessionEvent(event) {
|
|
195
|
+
if (event.type === "message_submitted") {
|
|
196
|
+
this.#modelLocked = true;
|
|
197
|
+
this.#appendEntry({ role: "user", text: event.data.displayText });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (event.type === "run_started") {
|
|
201
|
+
this.#running = true;
|
|
202
|
+
this.#statusText = "Running";
|
|
203
|
+
this.#activityStartedAtMs = this.#now();
|
|
204
|
+
this.#startActivityAnimation();
|
|
205
|
+
this.#requestRender();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (event.type === "agent_event") {
|
|
209
|
+
this.#applyAgentEvent(event.data.event);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (event.type === "agent_message") {
|
|
213
|
+
this.#applyAgentMessage(event.data.message);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (event.type === "run_finished") {
|
|
217
|
+
this.#running = false;
|
|
218
|
+
this.#statusText =
|
|
219
|
+
event.data.stopReason === "stop" ? "Idle" : `Stopped: ${event.data.stopReason}`;
|
|
220
|
+
this.#stopActivityAnimation();
|
|
221
|
+
this.#streamEntryId = undefined;
|
|
222
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
223
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
224
|
+
this.#requestRender();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (event.type === "run_error") {
|
|
228
|
+
this.#running = false;
|
|
229
|
+
this.#statusText = "Error";
|
|
230
|
+
this.#stopActivityAnimation();
|
|
231
|
+
this.#appendEntry({ role: "error", text: event.data.errorMessage });
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (event.type === "session_reset") {
|
|
235
|
+
this.#entries = [];
|
|
236
|
+
this.#modelLocked = false;
|
|
237
|
+
this.#seenToolCallIds.clear();
|
|
238
|
+
this.#streamEntryId = undefined;
|
|
239
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
240
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
241
|
+
this.#appendEntry({
|
|
242
|
+
role: "system",
|
|
243
|
+
text: "Session reset. Started a new session.",
|
|
244
|
+
});
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (event.type === "session_title_changed") {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (event.type === "model_changed") {
|
|
251
|
+
this.#appendEntry({
|
|
252
|
+
role: "event",
|
|
253
|
+
title: "model",
|
|
254
|
+
text: `Model changed to ${this.#modelDisplayName()}.`,
|
|
255
|
+
});
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (event.type === "effort_changed") {
|
|
259
|
+
this.#appendEntry({
|
|
260
|
+
role: "event",
|
|
261
|
+
title: "reasoning",
|
|
262
|
+
text: `Reasoning changed to ${humanizeReasoningLevel(event.data.effort ?? "off")}.`,
|
|
263
|
+
});
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async waitForIdle() {
|
|
268
|
+
for (;;) {
|
|
269
|
+
const activeSubmission = this.#activeSubmission;
|
|
270
|
+
if (activeSubmission !== undefined) {
|
|
271
|
+
await activeSubmission;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const activeRun = this.#activeRun;
|
|
275
|
+
if (activeRun === undefined) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
await activeRun;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
handleInput(data) {
|
|
282
|
+
if (this.#stopped || this.#exiting) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (this.#selectionPanel !== undefined) {
|
|
286
|
+
if (matchesKey(data, "ctrl+c") || data === "\x03") {
|
|
287
|
+
void this.stop();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this.#selectionPanel.handleInput?.(data);
|
|
291
|
+
this.#requestRender();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (this.#handlePastedInput(data)) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (this.#handleImagePasteShortcut(data)) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (matchesKey(data, "ctrl+c") || data === "\x03") {
|
|
301
|
+
void this.stop();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (matchesKey(data, "ctrl+d") && this.#editor.getText().length === 0) {
|
|
305
|
+
void this.stop();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const previousSlashCommandSuggestionCount = this.#slashCommandSuggestions().length;
|
|
309
|
+
if (this.#handleSlashCommandAutocompleteInput(data)) {
|
|
310
|
+
const nextSlashCommandSuggestionCount = this.#slashCommandSuggestions().length;
|
|
311
|
+
this.#requestRender(nextSlashCommandSuggestionCount < previousSlashCommandSuggestionCount);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (matchesKey(data, "escape")) {
|
|
315
|
+
this.#markTypingActivity();
|
|
316
|
+
this.#handleEscape();
|
|
317
|
+
this.#requestRender();
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (this.#handleModelMenuShortcut(data)) {
|
|
321
|
+
this.#requestRender();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (this.#handleReasoningShortcut(data)) {
|
|
325
|
+
this.#requestRender();
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
this.#markTypingActivity();
|
|
329
|
+
this.#editor.handleInput(data);
|
|
330
|
+
this.#syncSlashCommandAutocompleteState();
|
|
331
|
+
const nextSlashCommandSuggestionCount = this.#slashCommandSuggestions().length;
|
|
332
|
+
this.#requestRender(nextSlashCommandSuggestionCount < previousSlashCommandSuggestionCount);
|
|
333
|
+
}
|
|
334
|
+
#handlePastedInput(data) {
|
|
335
|
+
if (this.#bracketedPasteBuffer !== undefined) {
|
|
336
|
+
return this.#appendBracketedPaste(data);
|
|
337
|
+
}
|
|
338
|
+
const startIndex = data.indexOf(BRACKETED_PASTE_START);
|
|
339
|
+
if (startIndex !== -1) {
|
|
340
|
+
const beforePaste = data.slice(0, startIndex);
|
|
341
|
+
if (beforePaste.length > 0) {
|
|
342
|
+
this.#editor.handleInput(beforePaste);
|
|
343
|
+
}
|
|
344
|
+
const pastePayload = data.slice(startIndex + BRACKETED_PASTE_START.length);
|
|
345
|
+
this.#appendBracketedPaste(pastePayload);
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
if (this.#isPlainPastePayload(data)) {
|
|
349
|
+
this.#insertPaste(data);
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
#handleImagePasteShortcut(data) {
|
|
355
|
+
if (!matchesKey(data, "ctrl+v") &&
|
|
356
|
+
!matchesKey(data, "alt+v") &&
|
|
357
|
+
!matchesKey(data, "super+v") &&
|
|
358
|
+
!IMAGE_PASTE_RAW_KEYS.has(data)) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
if (this.#imagePasteInFlight !== undefined) {
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
const paste = this.#pasteClipboardImage().finally(() => {
|
|
365
|
+
if (this.#imagePasteInFlight === paste) {
|
|
366
|
+
this.#imagePasteInFlight = undefined;
|
|
367
|
+
}
|
|
368
|
+
this.#requestRender();
|
|
369
|
+
});
|
|
370
|
+
this.#imagePasteInFlight = paste;
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
async #pasteClipboardImage() {
|
|
374
|
+
try {
|
|
375
|
+
const image = await this.#readClipboardImage({
|
|
376
|
+
outputDirectory: join(this.#cwd, ".context", "clipboard-images"),
|
|
377
|
+
});
|
|
378
|
+
if (image === undefined) {
|
|
379
|
+
this.#appendEntry({
|
|
380
|
+
role: "event",
|
|
381
|
+
title: "clipboard",
|
|
382
|
+
text: "No image found in the clipboard.",
|
|
383
|
+
});
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
this.#insertPastedImage(image);
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
this.#appendEntry({
|
|
390
|
+
role: "error",
|
|
391
|
+
title: "clipboard",
|
|
392
|
+
text: `Image paste failed: ${this.#formatError(error)}`,
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
#insertPastedImage(image) {
|
|
397
|
+
const id = this.#nextPastedImageId++;
|
|
398
|
+
const placeholder = `[Image #${id} ${this.#formatImageType(image.mediaType)}]`;
|
|
399
|
+
this.#pastedImagesById.set(id, {
|
|
400
|
+
data: image.data,
|
|
401
|
+
mediaType: image.mediaType,
|
|
402
|
+
path: image.path,
|
|
403
|
+
placeholder,
|
|
404
|
+
});
|
|
405
|
+
const currentText = this.#editor.getText();
|
|
406
|
+
const prefix = currentText.length > 0 && !/\s$/u.test(currentText) ? " " : "";
|
|
407
|
+
this.#markTypingActivity();
|
|
408
|
+
this.#editor.insertTextAtCursor(`${prefix}${placeholder} `);
|
|
409
|
+
this.#syncSlashCommandAutocompleteState();
|
|
410
|
+
this.#requestRender();
|
|
411
|
+
}
|
|
412
|
+
#appendBracketedPaste(data) {
|
|
413
|
+
const currentBuffer = this.#bracketedPasteBuffer ?? "";
|
|
414
|
+
const nextBuffer = currentBuffer + data;
|
|
415
|
+
const endIndex = nextBuffer.indexOf(BRACKETED_PASTE_END);
|
|
416
|
+
if (endIndex === -1) {
|
|
417
|
+
this.#bracketedPasteBuffer = nextBuffer;
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
const pastedText = nextBuffer.slice(0, endIndex);
|
|
421
|
+
const remaining = nextBuffer.slice(endIndex + BRACKETED_PASTE_END.length);
|
|
422
|
+
this.#bracketedPasteBuffer = undefined;
|
|
423
|
+
this.#insertPaste(pastedText);
|
|
424
|
+
if (remaining.length > 0) {
|
|
425
|
+
this.handleInput(remaining);
|
|
426
|
+
}
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
#insertPaste(text) {
|
|
430
|
+
if (text.length === 0) {
|
|
431
|
+
this.#syncSlashCommandAutocompleteState();
|
|
432
|
+
this.#requestRender();
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this.#markTypingActivity();
|
|
436
|
+
this.#editor.handleInput(`${BRACKETED_PASTE_START}${text}${BRACKETED_PASTE_END}`);
|
|
437
|
+
this.#syncSlashCommandAutocompleteState();
|
|
438
|
+
this.#requestRender();
|
|
439
|
+
}
|
|
440
|
+
#isPlainPastePayload(data) {
|
|
441
|
+
return data.length > 1 && !data.includes("\x1b") && !matchesKey(data, "enter");
|
|
442
|
+
}
|
|
443
|
+
invalidate() {
|
|
444
|
+
this.#editor.invalidate();
|
|
445
|
+
}
|
|
446
|
+
render(width) {
|
|
447
|
+
const safeWidth = Math.max(20, width);
|
|
448
|
+
const header = this.#renderHeader(safeWidth);
|
|
449
|
+
const slashCommandSuggestions = this.#slashCommandSuggestions();
|
|
450
|
+
const footer = this.#renderFooter(safeWidth, slashCommandSuggestions);
|
|
451
|
+
const input = this.#renderInput(safeWidth);
|
|
452
|
+
if (this.#exiting) {
|
|
453
|
+
return [...header, ...this.#renderTranscript(safeWidth)];
|
|
454
|
+
}
|
|
455
|
+
return [
|
|
456
|
+
...header,
|
|
457
|
+
...this.#renderTranscript(safeWidth),
|
|
458
|
+
"",
|
|
459
|
+
...(this.#selectionPanel === undefined
|
|
460
|
+
? input
|
|
461
|
+
: this.#selectionPanel.render(safeWidth)),
|
|
462
|
+
"",
|
|
463
|
+
...footer,
|
|
464
|
+
"",
|
|
465
|
+
"",
|
|
466
|
+
];
|
|
467
|
+
}
|
|
468
|
+
#submit(value) {
|
|
469
|
+
const submission = this.#submitAsync(value).catch((error) => {
|
|
470
|
+
this.#appendEntry({ role: "error", text: this.#formatError(error) });
|
|
471
|
+
});
|
|
472
|
+
const trackedSubmission = submission.finally(() => {
|
|
473
|
+
if (this.#activeSubmission === trackedSubmission) {
|
|
474
|
+
this.#activeSubmission = undefined;
|
|
475
|
+
}
|
|
476
|
+
this.#requestRender();
|
|
477
|
+
});
|
|
478
|
+
this.#activeSubmission = trackedSubmission;
|
|
479
|
+
}
|
|
480
|
+
async #submitAsync(value) {
|
|
481
|
+
const submission = this.#createPromptSubmission(value);
|
|
482
|
+
if (submission === undefined) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const prompt = submission.displayText;
|
|
486
|
+
this.#editor.setText("");
|
|
487
|
+
if (prompt.startsWith("/skill:")) {
|
|
488
|
+
await this.#submitSkillCommand(prompt);
|
|
489
|
+
this.#requestRender();
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (this.#handleCommand(prompt)) {
|
|
493
|
+
this.#requestRender();
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
this.#modelLocked = true;
|
|
497
|
+
if (!this.#sessionBacked) {
|
|
498
|
+
this.#appendEntry({ role: "user", text: prompt });
|
|
499
|
+
}
|
|
500
|
+
if (this.#running && !this.#sessionBacked) {
|
|
501
|
+
this.#appendEntry({
|
|
502
|
+
role: "event",
|
|
503
|
+
title: "queue",
|
|
504
|
+
text: `Queued behind the active run.`,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
this.#pendingPrompts.push(submission);
|
|
508
|
+
this.#startDrainQueue();
|
|
509
|
+
this.#requestRender();
|
|
510
|
+
}
|
|
511
|
+
#createPromptSubmission(value) {
|
|
512
|
+
const prompt = value.trim();
|
|
513
|
+
if (prompt.length === 0) {
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
const content = this.#contentFromPrompt(prompt);
|
|
517
|
+
this.#clearSubmittedImages(prompt);
|
|
518
|
+
return {
|
|
519
|
+
content,
|
|
520
|
+
displayText: prompt,
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
#contentFromPrompt(prompt) {
|
|
524
|
+
const blocks = [];
|
|
525
|
+
let cursor = 0;
|
|
526
|
+
let hasImage = false;
|
|
527
|
+
for (const match of prompt.matchAll(IMAGE_PLACEHOLDER_REGEX)) {
|
|
528
|
+
const rawMatch = match[0];
|
|
529
|
+
const matchIndex = match.index;
|
|
530
|
+
const imageId = Number(match[1]);
|
|
531
|
+
const image = this.#pastedImagesById.get(imageId);
|
|
532
|
+
if (image === undefined || image.placeholder !== rawMatch) {
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
const text = prompt.slice(cursor, matchIndex);
|
|
536
|
+
if (text.trim().length > 0) {
|
|
537
|
+
blocks.push({ type: "text", text });
|
|
538
|
+
}
|
|
539
|
+
blocks.push({
|
|
540
|
+
type: "image",
|
|
541
|
+
data: image.data,
|
|
542
|
+
mediaType: image.mediaType,
|
|
543
|
+
});
|
|
544
|
+
cursor = matchIndex + rawMatch.length;
|
|
545
|
+
hasImage = true;
|
|
546
|
+
}
|
|
547
|
+
if (!hasImage) {
|
|
548
|
+
return prompt;
|
|
549
|
+
}
|
|
550
|
+
const trailingText = prompt.slice(cursor);
|
|
551
|
+
if (trailingText.trim().length > 0) {
|
|
552
|
+
blocks.push({ type: "text", text: trailingText });
|
|
553
|
+
}
|
|
554
|
+
return blocks;
|
|
555
|
+
}
|
|
556
|
+
#clearSubmittedImages(prompt) {
|
|
557
|
+
for (const match of prompt.matchAll(IMAGE_PLACEHOLDER_REGEX)) {
|
|
558
|
+
const imageId = Number(match[1]);
|
|
559
|
+
const image = this.#pastedImagesById.get(imageId);
|
|
560
|
+
if (image !== undefined && image.placeholder === match[0]) {
|
|
561
|
+
this.#pastedImagesById.delete(imageId);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
async #submitSkillCommand(prompt) {
|
|
566
|
+
const parsed = /^\/skill:([a-z0-9-]+)(?:\s+([\s\S]*))?$/u.exec(prompt);
|
|
567
|
+
if (parsed === null) {
|
|
568
|
+
this.#appendEntry({
|
|
569
|
+
role: "event",
|
|
570
|
+
title: "skill",
|
|
571
|
+
text: "Use /skill:<name> followed by optional instructions.",
|
|
572
|
+
});
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
await this.#refreshSkillCommands({ force: true });
|
|
576
|
+
const skillName = parsed[1];
|
|
577
|
+
const skill = skillName === undefined ? undefined : this.#skillsByName.get(skillName);
|
|
578
|
+
if (skill === undefined) {
|
|
579
|
+
this.#appendEntry({
|
|
580
|
+
role: "event",
|
|
581
|
+
title: "skill",
|
|
582
|
+
text: `Skill '${skillName ?? ""}' was not found.`,
|
|
583
|
+
});
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
let content;
|
|
587
|
+
try {
|
|
588
|
+
content = await this.#agent.context.fs.readFile(skill.filePath);
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
this.#appendEntry({
|
|
592
|
+
role: "error",
|
|
593
|
+
title: "skill",
|
|
594
|
+
text: this.#formatError(error),
|
|
595
|
+
});
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
const expandedPrompt = formatSkillInvocation(skill, parseSkillFrontmatter(content).body, parsed[2] ?? "");
|
|
599
|
+
this.#modelLocked = true;
|
|
600
|
+
if (!this.#sessionBacked) {
|
|
601
|
+
this.#appendEntry({ role: "user", text: prompt });
|
|
602
|
+
}
|
|
603
|
+
if (this.#running && !this.#sessionBacked) {
|
|
604
|
+
this.#appendEntry({
|
|
605
|
+
role: "event",
|
|
606
|
+
title: "queue",
|
|
607
|
+
text: `Queued behind the active run.`,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
this.#pendingPrompts.push({ content: expandedPrompt, displayText: prompt });
|
|
611
|
+
this.#startDrainQueue();
|
|
612
|
+
}
|
|
613
|
+
#handleCommand(prompt) {
|
|
614
|
+
if (prompt === "/model") {
|
|
615
|
+
this.#openModelMenu();
|
|
616
|
+
return true;
|
|
617
|
+
}
|
|
618
|
+
if (prompt === "/effort" || prompt === "/ford") {
|
|
619
|
+
this.#openReasoningMenu({
|
|
620
|
+
model: this.#agent.model,
|
|
621
|
+
providerId: this.#agent.provider.id,
|
|
622
|
+
});
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
if (prompt === "/configure") {
|
|
626
|
+
this.#openConfigureMenu();
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
if (prompt === "/new") {
|
|
630
|
+
this.#resetSession();
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
if (prompt === "/exit") {
|
|
634
|
+
void this.stop();
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
if (prompt === "/clear") {
|
|
638
|
+
this.#entries = [];
|
|
639
|
+
this.#streamEntryId = undefined;
|
|
640
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
641
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
642
|
+
this.#appendEntry({ role: "system", text: "Transcript cleared." });
|
|
643
|
+
return true;
|
|
644
|
+
}
|
|
645
|
+
if (prompt === "/abort") {
|
|
646
|
+
if (!this.#abortActiveRun()) {
|
|
647
|
+
this.#appendEntry({
|
|
648
|
+
role: "event",
|
|
649
|
+
title: "abort",
|
|
650
|
+
text: "No active run.",
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
return true;
|
|
654
|
+
}
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
#resetSession() {
|
|
658
|
+
this.#abortActiveRun({ silent: true });
|
|
659
|
+
this.#runToken += 1;
|
|
660
|
+
this.#pendingPrompts = [];
|
|
661
|
+
this.#pastedImagesById.clear();
|
|
662
|
+
this.#entries = [];
|
|
663
|
+
this.#modelLocked = false;
|
|
664
|
+
this.#seenToolCallIds.clear();
|
|
665
|
+
this.#streamEntryId = undefined;
|
|
666
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
667
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
668
|
+
this.#abortNotified = false;
|
|
669
|
+
this.#statusText = "Idle";
|
|
670
|
+
this.#agent.reset();
|
|
671
|
+
this.#appendEntry({
|
|
672
|
+
role: "system",
|
|
673
|
+
text: "Session reset. Started a new session.",
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
#startDrainQueue() {
|
|
677
|
+
if (this.#activeRun !== undefined) {
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
this.#activeRun = this.#drainQueue().finally(() => {
|
|
681
|
+
this.#activeRun = undefined;
|
|
682
|
+
this.#requestRender();
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
async #drainQueue() {
|
|
686
|
+
while (!this.#stopped) {
|
|
687
|
+
const prompt = this.#pendingPrompts.shift();
|
|
688
|
+
if (prompt === undefined) {
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
await this.#runPrompt(prompt);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
async #runPrompt(prompt) {
|
|
695
|
+
const controller = new AbortController();
|
|
696
|
+
const runToken = ++this.#runToken;
|
|
697
|
+
this.#abortController = controller;
|
|
698
|
+
this.#abortNotified = false;
|
|
699
|
+
this.#running = true;
|
|
700
|
+
this.#statusText = "Running";
|
|
701
|
+
this.#streamEntryId = undefined;
|
|
702
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
703
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
704
|
+
this.#activityStartedAtMs = this.#now();
|
|
705
|
+
this.#startActivityAnimation();
|
|
706
|
+
this.#requestRender();
|
|
707
|
+
try {
|
|
708
|
+
await this.#refreshSkillCommands({ force: true });
|
|
709
|
+
if (!this.#isCurrentRun(runToken)) {
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
const result = await this.#agent.send(prompt.content, {
|
|
713
|
+
displayText: prompt.displayText,
|
|
714
|
+
signal: controller.signal,
|
|
715
|
+
...(this.#sessionBacked
|
|
716
|
+
? {}
|
|
717
|
+
: {
|
|
718
|
+
onEvent: (event) => this.#handleAgentEvent(event, runToken),
|
|
719
|
+
onMessage: (message) => this.#handleAgentMessage(message, runToken),
|
|
720
|
+
}),
|
|
721
|
+
});
|
|
722
|
+
if (!this.#isCurrentRun(runToken)) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
if (result.stopReason === "aborted") {
|
|
726
|
+
this.#statusText = "Idle";
|
|
727
|
+
this.#appendAbortNotice();
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
this.#statusText =
|
|
731
|
+
result.stopReason === "stop" ? "Idle" : `Stopped: ${result.stopReason}`;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
catch (error) {
|
|
735
|
+
if (!this.#isCurrentRun(runToken)) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (controller.signal.aborted) {
|
|
739
|
+
this.#statusText = "Idle";
|
|
740
|
+
this.#appendAbortNotice();
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
this.#statusText = "Error";
|
|
744
|
+
this.#appendEntry({ role: "error", text: this.#formatError(error) });
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
finally {
|
|
748
|
+
if (!this.#isCurrentRun(runToken)) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (this.#abortController === controller) {
|
|
752
|
+
this.#abortController = undefined;
|
|
753
|
+
}
|
|
754
|
+
this.#running = false;
|
|
755
|
+
this.#stopActivityAnimation();
|
|
756
|
+
this.#streamEntryId = undefined;
|
|
757
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
758
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
759
|
+
this.#requestRender();
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
#handleEscape() {
|
|
763
|
+
if (this.#abortActiveRun()) {
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
void this.stop();
|
|
767
|
+
}
|
|
768
|
+
#abortActiveRun(options = {}) {
|
|
769
|
+
if (!this.#running || this.#abortController === undefined) {
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
const controller = this.#abortController;
|
|
773
|
+
this.#runToken += 1;
|
|
774
|
+
controller.abort();
|
|
775
|
+
this.#abortController = undefined;
|
|
776
|
+
this.#pendingPrompts = [];
|
|
777
|
+
this.#running = false;
|
|
778
|
+
this.#statusText = "Idle";
|
|
779
|
+
this.#streamEntryId = undefined;
|
|
780
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
781
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
782
|
+
this.#stopActivityAnimation();
|
|
783
|
+
void this.#processManager.killAll({ forceAfterMs: 500 }).catch((error) => {
|
|
784
|
+
this.#appendEntry({ role: "error", text: this.#formatError(error) });
|
|
785
|
+
});
|
|
786
|
+
if (options.silent !== true) {
|
|
787
|
+
this.#appendAbortNotice();
|
|
788
|
+
}
|
|
789
|
+
this.#requestRender();
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
#isCurrentRun(runToken) {
|
|
793
|
+
return !this.#stopped && runToken === this.#runToken;
|
|
794
|
+
}
|
|
795
|
+
#handleAgentEvent(event, runToken) {
|
|
796
|
+
if (!this.#isCurrentRun(runToken)) {
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
this.#applyAgentEvent(event);
|
|
800
|
+
}
|
|
801
|
+
#applyAgentEvent(event) {
|
|
802
|
+
if (event.type === "inference_iteration_start") {
|
|
803
|
+
this.#statusText = "Running";
|
|
804
|
+
this.#streamEntryId = undefined;
|
|
805
|
+
this.#thinkingEntryIdsByContentIndex.clear();
|
|
806
|
+
this.#toolCallEntryIdsByContentIndex.clear();
|
|
807
|
+
if (event.iteration > 1) {
|
|
808
|
+
this.#appendEntry({ role: "separator", text: "" });
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
else if (event.type === "text_start") {
|
|
812
|
+
this.#statusText = "Running";
|
|
813
|
+
}
|
|
814
|
+
else if (event.type === "text_delta") {
|
|
815
|
+
this.#appendStreamText(event.delta);
|
|
816
|
+
}
|
|
817
|
+
else if (event.type === "text_end") {
|
|
818
|
+
this.#finishStreamText(event.content);
|
|
819
|
+
}
|
|
820
|
+
else if (event.type === "thinking_start") {
|
|
821
|
+
this.#statusText = "Thinking";
|
|
822
|
+
}
|
|
823
|
+
else if (event.type === "thinking_delta") {
|
|
824
|
+
this.#statusText = "Thinking";
|
|
825
|
+
this.#appendThinkingText(event.contentIndex, event.delta);
|
|
826
|
+
}
|
|
827
|
+
else if (event.type === "thinking_end") {
|
|
828
|
+
this.#statusText = "Thinking";
|
|
829
|
+
this.#finishThinkingText(event.contentIndex, event.content);
|
|
830
|
+
}
|
|
831
|
+
else if (event.type === "toolcall_start") {
|
|
832
|
+
this.#statusText = "Running";
|
|
833
|
+
this.#ensureToolCallEntry(event.contentIndex);
|
|
834
|
+
}
|
|
835
|
+
else if (event.type === "toolcall_delta") {
|
|
836
|
+
this.#statusText = "Running";
|
|
837
|
+
this.#ensureToolCallEntry(event.contentIndex);
|
|
838
|
+
}
|
|
839
|
+
else if (event.type === "toolcall_end") {
|
|
840
|
+
this.#finishToolCall(event.contentIndex, event.toolCall);
|
|
841
|
+
}
|
|
842
|
+
else if (event.type === "done") {
|
|
843
|
+
this.#statusText = event.reason === "toolUse" ? "Running tools" : "Idle";
|
|
844
|
+
}
|
|
845
|
+
else if (event.type === "error") {
|
|
846
|
+
if (event.reason === "aborted") {
|
|
847
|
+
this.#statusText = "Idle";
|
|
848
|
+
this.#appendAbortNotice();
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
this.#statusText = "Error";
|
|
852
|
+
this.#appendEntry({
|
|
853
|
+
role: "error",
|
|
854
|
+
text: event.error.errorMessage ?? "Provider returned an error.",
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
this.#requestRender();
|
|
858
|
+
}
|
|
859
|
+
#appendAbortNotice() {
|
|
860
|
+
if (this.#abortNotified) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
this.#abortNotified = true;
|
|
864
|
+
this.#appendEntry({
|
|
865
|
+
role: "error",
|
|
866
|
+
title: "Session interrupted",
|
|
867
|
+
text: "The active run was stopped.",
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
#handleAgentMessage(message, runToken) {
|
|
871
|
+
if (!this.#isCurrentRun(runToken) || message.role !== "agent") {
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
this.#applyAgentMessage(message);
|
|
875
|
+
}
|
|
876
|
+
#applyAgentMessage(message) {
|
|
877
|
+
if (message.role !== "agent") {
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
let pendingText = "";
|
|
881
|
+
let textSegment = 0;
|
|
882
|
+
const flushText = () => {
|
|
883
|
+
if (pendingText.length === 0) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
const id = textSegment === 0 ? message.id : `${message.id}:text:${textSegment}`;
|
|
887
|
+
this.#finishAssistantMessage(id, pendingText);
|
|
888
|
+
pendingText = "";
|
|
889
|
+
textSegment += 1;
|
|
890
|
+
};
|
|
891
|
+
for (const [contentIndex, block] of message.blocks.entries()) {
|
|
892
|
+
if (block.type === "text") {
|
|
893
|
+
pendingText += block.text;
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
flushText();
|
|
897
|
+
if (block.type === "thinking") {
|
|
898
|
+
this.#finishThinkingMessage(message.id, contentIndex, block.thinking);
|
|
899
|
+
}
|
|
900
|
+
else if (block.type === "tool_call" && !this.#seenToolCallIds.has(block.id)) {
|
|
901
|
+
this.#seenToolCallIds.add(block.id);
|
|
902
|
+
this.#appendEntry({
|
|
903
|
+
id: block.id,
|
|
904
|
+
role: "tool",
|
|
905
|
+
title: block.name,
|
|
906
|
+
text: this.#formatToolCall(block.name, block.arguments),
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
else if (block.type === "tool_result") {
|
|
910
|
+
this.#finishToolResult(block);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
flushText();
|
|
914
|
+
this.#requestRender();
|
|
915
|
+
}
|
|
916
|
+
#ensureStreamEntry() {
|
|
917
|
+
const existing = this.#streamEntryId === undefined
|
|
918
|
+
? undefined
|
|
919
|
+
: this.#entries.find((entry) => entry.id === this.#streamEntryId);
|
|
920
|
+
if (existing !== undefined) {
|
|
921
|
+
return existing;
|
|
922
|
+
}
|
|
923
|
+
const entry = this.#appendEntry({ role: "assistant", text: "" });
|
|
924
|
+
this.#streamEntryId = entry.id;
|
|
925
|
+
return entry;
|
|
926
|
+
}
|
|
927
|
+
#appendStreamText(delta) {
|
|
928
|
+
const entry = this.#ensureStreamEntry();
|
|
929
|
+
entry.text += delta;
|
|
930
|
+
}
|
|
931
|
+
#finishStreamText(text) {
|
|
932
|
+
const entry = this.#ensureStreamEntry();
|
|
933
|
+
entry.text = text;
|
|
934
|
+
}
|
|
935
|
+
#ensureThinkingEntry(contentIndex) {
|
|
936
|
+
const existingId = this.#thinkingEntryIdsByContentIndex.get(contentIndex);
|
|
937
|
+
const existing = existingId === undefined
|
|
938
|
+
? undefined
|
|
939
|
+
: this.#entries.find((entry) => entry.id === existingId);
|
|
940
|
+
if (existing !== undefined) {
|
|
941
|
+
return existing;
|
|
942
|
+
}
|
|
943
|
+
const entry = this.#appendEntry({ role: "thinking", text: "" });
|
|
944
|
+
this.#thinkingEntryIdsByContentIndex.set(contentIndex, entry.id);
|
|
945
|
+
return entry;
|
|
946
|
+
}
|
|
947
|
+
#appendThinkingText(contentIndex, delta) {
|
|
948
|
+
if (delta.length === 0) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const entry = this.#ensureThinkingEntry(contentIndex);
|
|
952
|
+
entry.text += delta;
|
|
953
|
+
}
|
|
954
|
+
#finishThinkingText(contentIndex, text) {
|
|
955
|
+
if (text.length === 0 && !this.#thinkingEntryIdsByContentIndex.has(contentIndex)) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
const entry = this.#ensureThinkingEntry(contentIndex);
|
|
959
|
+
entry.text = text;
|
|
960
|
+
}
|
|
961
|
+
#ensureToolCallEntry(contentIndex) {
|
|
962
|
+
const existingId = this.#toolCallEntryIdsByContentIndex.get(contentIndex);
|
|
963
|
+
const existing = existingId === undefined
|
|
964
|
+
? undefined
|
|
965
|
+
: this.#entries.find((entry) => entry.id === existingId);
|
|
966
|
+
if (existing !== undefined) {
|
|
967
|
+
return existing;
|
|
968
|
+
}
|
|
969
|
+
const entry = this.#appendEntry({
|
|
970
|
+
role: "tool",
|
|
971
|
+
title: PENDING_TOOL_CALL_TITLE,
|
|
972
|
+
text: PENDING_TOOL_CALL_TITLE,
|
|
973
|
+
});
|
|
974
|
+
this.#toolCallEntryIdsByContentIndex.set(contentIndex, entry.id);
|
|
975
|
+
return entry;
|
|
976
|
+
}
|
|
977
|
+
#finishToolCall(contentIndex, toolCall) {
|
|
978
|
+
this.#seenToolCallIds.add(toolCall.id);
|
|
979
|
+
this.#statusText = `Calling ${toolCall.name}`;
|
|
980
|
+
const existingId = this.#toolCallEntryIdsByContentIndex.get(contentIndex);
|
|
981
|
+
const existing = existingId === undefined
|
|
982
|
+
? undefined
|
|
983
|
+
: this.#entries.find((entry) => entry.id === existingId);
|
|
984
|
+
if (existing !== undefined) {
|
|
985
|
+
existing.id = toolCall.id;
|
|
986
|
+
existing.title = toolCall.name;
|
|
987
|
+
existing.text = this.#formatToolCall(toolCall.name, toolCall.arguments);
|
|
988
|
+
this.#toolCallEntryIdsByContentIndex.delete(contentIndex);
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
this.#toolCallEntryIdsByContentIndex.delete(contentIndex);
|
|
992
|
+
this.#appendEntry({
|
|
993
|
+
id: toolCall.id,
|
|
994
|
+
role: "tool",
|
|
995
|
+
title: toolCall.name,
|
|
996
|
+
text: this.#formatToolCall(toolCall.name, toolCall.arguments),
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
#finishThinkingMessage(messageId, contentIndex, text) {
|
|
1000
|
+
if (text.length === 0) {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
const entry = this.#ensureThinkingEntry(contentIndex);
|
|
1004
|
+
entry.id = `${messageId}:thinking:${contentIndex}`;
|
|
1005
|
+
entry.text = text;
|
|
1006
|
+
this.#thinkingEntryIdsByContentIndex.set(contentIndex, entry.id);
|
|
1007
|
+
}
|
|
1008
|
+
#finishAssistantMessage(messageId, text) {
|
|
1009
|
+
if (this.#streamEntryId !== undefined) {
|
|
1010
|
+
const entry = this.#entries.find((candidate) => candidate.id === this.#streamEntryId);
|
|
1011
|
+
if (entry !== undefined) {
|
|
1012
|
+
entry.id = messageId;
|
|
1013
|
+
entry.text = text;
|
|
1014
|
+
this.#streamEntryId = undefined;
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
this.#appendEntry({ id: messageId, role: "assistant", text });
|
|
1019
|
+
}
|
|
1020
|
+
#appendEntry(entry) {
|
|
1021
|
+
const completeEntry = {
|
|
1022
|
+
id: entry.id ?? this.#idFactory(),
|
|
1023
|
+
role: entry.role,
|
|
1024
|
+
text: entry.text,
|
|
1025
|
+
};
|
|
1026
|
+
if (entry.detail !== undefined) {
|
|
1027
|
+
completeEntry.detail = entry.detail;
|
|
1028
|
+
}
|
|
1029
|
+
if (entry.title !== undefined) {
|
|
1030
|
+
completeEntry.title = entry.title;
|
|
1031
|
+
}
|
|
1032
|
+
this.#entries.push(completeEntry);
|
|
1033
|
+
if (this.#entries.length > MAX_TRANSCRIPT_ENTRIES) {
|
|
1034
|
+
this.#entries = this.#entries.slice(-MAX_TRANSCRIPT_ENTRIES);
|
|
1035
|
+
}
|
|
1036
|
+
this.#requestRender();
|
|
1037
|
+
return completeEntry;
|
|
1038
|
+
}
|
|
1039
|
+
#renderHeader(width) {
|
|
1040
|
+
return [
|
|
1041
|
+
...this.#renderStartupBox(width, [
|
|
1042
|
+
`${RIG_ORANGE}>_${RESET} ${BOLD}Rig${NOT_BOLD_OR_DIM} ${this.#version}`,
|
|
1043
|
+
"Agentic coding CLI for local project work.",
|
|
1044
|
+
"Keeps sessions in a private local daemon.",
|
|
1045
|
+
`Directory: ${this.#directoryName()}`,
|
|
1046
|
+
]),
|
|
1047
|
+
"",
|
|
1048
|
+
];
|
|
1049
|
+
}
|
|
1050
|
+
#renderTranscript(width) {
|
|
1051
|
+
const sourceEntries = this.#entries.length === 0
|
|
1052
|
+
? [{ id: "ready", role: "system", text: "Ready." }]
|
|
1053
|
+
: this.#entries;
|
|
1054
|
+
const entries = this.#showReasoning
|
|
1055
|
+
? sourceEntries
|
|
1056
|
+
: sourceEntries.filter((entry) => entry.role !== "thinking");
|
|
1057
|
+
const lines = [];
|
|
1058
|
+
for (const entry of entries) {
|
|
1059
|
+
if (lines.length > 0) {
|
|
1060
|
+
lines.push("");
|
|
1061
|
+
}
|
|
1062
|
+
lines.push(...this.#renderEntry(entry, width));
|
|
1063
|
+
}
|
|
1064
|
+
const activityLabel = this.#activityLabel();
|
|
1065
|
+
if (activityLabel !== undefined && this.#shouldRenderActivityAsLastMessage()) {
|
|
1066
|
+
if (lines.length > 0) {
|
|
1067
|
+
lines.push("");
|
|
1068
|
+
}
|
|
1069
|
+
lines.push(...this.#renderActivityLine(activityLabel, width));
|
|
1070
|
+
}
|
|
1071
|
+
return lines;
|
|
1072
|
+
}
|
|
1073
|
+
#renderEntry(entry, width) {
|
|
1074
|
+
if (entry.role === "separator") {
|
|
1075
|
+
return [this.#turnSeparator(width)];
|
|
1076
|
+
}
|
|
1077
|
+
if (entry.role === "user") {
|
|
1078
|
+
return this.#renderUserEntry(entry, width);
|
|
1079
|
+
}
|
|
1080
|
+
if (entry.role === "assistant") {
|
|
1081
|
+
return this.#renderAssistantEntry(entry, width);
|
|
1082
|
+
}
|
|
1083
|
+
if (entry.role === "thinking") {
|
|
1084
|
+
return this.#renderThinkingEntry(entry, width);
|
|
1085
|
+
}
|
|
1086
|
+
if (entry.role === "tool") {
|
|
1087
|
+
return this.#renderToolEntry(entry, width, false);
|
|
1088
|
+
}
|
|
1089
|
+
if (entry.role === "error") {
|
|
1090
|
+
return entry.detail === undefined
|
|
1091
|
+
? this.#renderNoticeEntry(entry.title ?? "Error", entry.text, width, RED)
|
|
1092
|
+
: this.#renderToolEntry(entry, width, true);
|
|
1093
|
+
}
|
|
1094
|
+
if (entry.role === "event") {
|
|
1095
|
+
return this.#renderNoticeEntry(entry.title ?? "event", entry.text, width, YELLOW);
|
|
1096
|
+
}
|
|
1097
|
+
return this.#renderNoticeEntry("system", entry.text, width, SURFACE_MUTED_FG);
|
|
1098
|
+
}
|
|
1099
|
+
#renderFooter(width, slashCommandSuggestions = this.#slashCommandSuggestions()) {
|
|
1100
|
+
if (slashCommandSuggestions.length > 0) {
|
|
1101
|
+
return this.#renderSlashCommandAutocomplete(width, slashCommandSuggestions);
|
|
1102
|
+
}
|
|
1103
|
+
const parts = [`${FOOTER_MODEL_FG}${this.#modelWithReasoningDisplayName()}${RESET}`];
|
|
1104
|
+
parts.push(`${FOOTER_CWD_FG}${this.#cwdDisplayName()}${RESET}`);
|
|
1105
|
+
if (this.#pendingPrompts.length > 0) {
|
|
1106
|
+
parts.push(`${FOOTER_QUEUED_FG}queued ${this.#pendingPrompts.length}${RESET}`);
|
|
1107
|
+
}
|
|
1108
|
+
const line = `${" ".repeat(visibleWidth(INPUT_PROMPT))}${parts.join(`${DIM} • ${RESET}`)}`;
|
|
1109
|
+
return [this.#fitLine(line, width)];
|
|
1110
|
+
}
|
|
1111
|
+
#renderSlashCommandAutocomplete(width, suggestions, maxVisible = SLASH_COMMAND_MAX_VISIBLE) {
|
|
1112
|
+
const rowWidth = Math.max(1, width - 1);
|
|
1113
|
+
const visibleCount = Math.max(1, Math.min(maxVisible, SLASH_COMMAND_MAX_VISIBLE));
|
|
1114
|
+
const selectedIndex = Math.min(this.#slashCommandSelectionIndex, suggestions.length - 1);
|
|
1115
|
+
const startIndex = Math.max(0, Math.min(selectedIndex - Math.floor(visibleCount / 2), suggestions.length - visibleCount));
|
|
1116
|
+
const visibleSuggestions = suggestions.slice(startIndex, startIndex + visibleCount);
|
|
1117
|
+
const labelWidth = Math.max(8, ...visibleSuggestions.map((item) => visibleWidth(this.#singleLine(item.label)) + 2));
|
|
1118
|
+
const labelColumnWidth = Math.min(labelWidth, Math.max(1, rowWidth - 2));
|
|
1119
|
+
return visibleSuggestions.map((item, index) => {
|
|
1120
|
+
const absoluteIndex = startIndex + index;
|
|
1121
|
+
const isSelected = absoluteIndex === selectedIndex;
|
|
1122
|
+
const marker = isSelected ? "→ " : " ";
|
|
1123
|
+
const label = this.#fitAndPadLine(this.#singleLine(item.label), labelColumnWidth);
|
|
1124
|
+
const remainingWidth = Math.max(0, rowWidth - visibleWidth(marker) - visibleWidth(label));
|
|
1125
|
+
const description = truncateToWidth(this.#singleLine(item.description ?? ""), remainingWidth, "", false);
|
|
1126
|
+
const line = isSelected
|
|
1127
|
+
? `${RIG_ORANGE}${marker}${label}${description}${RESET}`
|
|
1128
|
+
: `${marker}${label}${DIM}${SURFACE_MUTED_FG}${description}${RESET}`;
|
|
1129
|
+
return this.#fitLine(line, rowWidth);
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
#openModelMenu() {
|
|
1133
|
+
if (this.#exiting || this.#stopped) {
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
const selectedModelId = this.#agent.model.id;
|
|
1137
|
+
const selectedProviderId = this.#agent.provider.id;
|
|
1138
|
+
const selectedValue = encodeModelChoice(selectedProviderId, selectedModelId);
|
|
1139
|
+
const choices = this.#modelChoices();
|
|
1140
|
+
const panel = createSelectionPanel({
|
|
1141
|
+
title: "Choose Model",
|
|
1142
|
+
subtitle: this.#modelLocked
|
|
1143
|
+
? "Model is locked for this session"
|
|
1144
|
+
: "Enter selects, Esc cancels",
|
|
1145
|
+
selectedValue,
|
|
1146
|
+
items: choices.map((choice) => ({
|
|
1147
|
+
value: encodeModelChoice(choice.providerId, choice.model.id),
|
|
1148
|
+
label: choice.model.name,
|
|
1149
|
+
description: describeModelChoice(choice.model, choice.providerId, choice.model.id === selectedModelId && choice.providerId === selectedProviderId, {
|
|
1150
|
+
locked: this.#modelLocked &&
|
|
1151
|
+
(choice.model.id !== selectedModelId ||
|
|
1152
|
+
choice.providerId !== selectedProviderId),
|
|
1153
|
+
}),
|
|
1154
|
+
})),
|
|
1155
|
+
onSelect: (item) => {
|
|
1156
|
+
const choice = choices.find((candidate) => encodeModelChoice(candidate.providerId, candidate.model.id) === item.value);
|
|
1157
|
+
if (choice === undefined) {
|
|
1158
|
+
this.#closeSelectionPanel();
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
if (this.#modelLocked && item.value !== selectedValue) {
|
|
1162
|
+
this.#appendEntry({
|
|
1163
|
+
role: "event",
|
|
1164
|
+
title: "model",
|
|
1165
|
+
text: "Model cannot be changed after the first message. Use /effort to change reasoning.",
|
|
1166
|
+
});
|
|
1167
|
+
this.#closeSelectionPanel();
|
|
1168
|
+
this.#requestRender();
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
this.#closeSelectionPanel();
|
|
1172
|
+
this.#openReasoningMenu(choice);
|
|
1173
|
+
},
|
|
1174
|
+
onCancel: () => {
|
|
1175
|
+
this.#closeSelectionPanel();
|
|
1176
|
+
},
|
|
1177
|
+
});
|
|
1178
|
+
this.#showSelectionPanel(panel);
|
|
1179
|
+
}
|
|
1180
|
+
#openReasoningMenu(choice) {
|
|
1181
|
+
const { model, providerId } = choice;
|
|
1182
|
+
const currentEffort = this.#agent.snapshot().effort;
|
|
1183
|
+
const defaultEffort = model.defaultThinkingLevel;
|
|
1184
|
+
const isCurrent = model.id === this.#agent.model.id && providerId === this.#agent.provider.id;
|
|
1185
|
+
const selectedEffort = isCurrent && currentEffort !== undefined && model.thinkingLevels.includes(currentEffort)
|
|
1186
|
+
? currentEffort
|
|
1187
|
+
: defaultEffort;
|
|
1188
|
+
const panel = createSelectionPanel({
|
|
1189
|
+
title: "Choose Reasoning",
|
|
1190
|
+
subtitle: model.name,
|
|
1191
|
+
selectedValue: selectedEffort,
|
|
1192
|
+
items: model.thinkingLevels.map((level) => ({
|
|
1193
|
+
value: level,
|
|
1194
|
+
label: humanizeReasoningLevel(level),
|
|
1195
|
+
description: describeReasoningLevel(level, {
|
|
1196
|
+
isCurrent: isCurrent && level === currentEffort,
|
|
1197
|
+
isDefault: level === defaultEffort,
|
|
1198
|
+
}),
|
|
1199
|
+
})),
|
|
1200
|
+
onSelect: (item) => {
|
|
1201
|
+
if (this.#modelLocked || isCurrent) {
|
|
1202
|
+
this.#agent.setEffort(item.value);
|
|
1203
|
+
if (!this.#sessionBacked) {
|
|
1204
|
+
this.#appendEntry({
|
|
1205
|
+
role: "event",
|
|
1206
|
+
title: "reasoning",
|
|
1207
|
+
text: `Reasoning changed to ${humanizeReasoningLevel(item.value)}.`,
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
else {
|
|
1212
|
+
this.#agent.setModel(model.id, item.value, providerId);
|
|
1213
|
+
this.#persistDefaultModel(model.id, item.value, providerId);
|
|
1214
|
+
if (!this.#sessionBacked) {
|
|
1215
|
+
this.#appendEntry({
|
|
1216
|
+
role: "event",
|
|
1217
|
+
title: "model",
|
|
1218
|
+
text: `Model changed to ${model.name} with ${humanizeReasoningLevel(item.value)} reasoning.`,
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
this.#closeSelectionPanel();
|
|
1223
|
+
this.#requestRender();
|
|
1224
|
+
},
|
|
1225
|
+
onCancel: () => {
|
|
1226
|
+
this.#closeSelectionPanel();
|
|
1227
|
+
},
|
|
1228
|
+
});
|
|
1229
|
+
this.#showSelectionPanel(panel);
|
|
1230
|
+
}
|
|
1231
|
+
#openConfigureMenu() {
|
|
1232
|
+
if (this.#exiting || this.#stopped) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
const selectedValue = this.#showReasoning ? "show" : "hide";
|
|
1236
|
+
const panel = createSelectionPanel({
|
|
1237
|
+
title: "Configure",
|
|
1238
|
+
subtitle: "App settings",
|
|
1239
|
+
selectedValue,
|
|
1240
|
+
items: [
|
|
1241
|
+
{
|
|
1242
|
+
value: "show",
|
|
1243
|
+
label: "Show reasoning",
|
|
1244
|
+
description: this.#showReasoning
|
|
1245
|
+
? "Current setting"
|
|
1246
|
+
: "Display reasoning blocks in the transcript.",
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
value: "hide",
|
|
1250
|
+
label: "Hide reasoning",
|
|
1251
|
+
description: this.#showReasoning
|
|
1252
|
+
? "Hide reasoning blocks from the transcript."
|
|
1253
|
+
: "Current setting",
|
|
1254
|
+
},
|
|
1255
|
+
],
|
|
1256
|
+
onSelect: (item) => {
|
|
1257
|
+
const showReasoning = item.value === "show";
|
|
1258
|
+
this.#setShowReasoning(showReasoning);
|
|
1259
|
+
this.#closeSelectionPanel();
|
|
1260
|
+
this.#appendEntry({
|
|
1261
|
+
role: "event",
|
|
1262
|
+
title: "settings",
|
|
1263
|
+
text: showReasoning
|
|
1264
|
+
? "Reasoning display enabled."
|
|
1265
|
+
: "Reasoning display disabled.",
|
|
1266
|
+
});
|
|
1267
|
+
this.#requestRender();
|
|
1268
|
+
},
|
|
1269
|
+
onCancel: () => {
|
|
1270
|
+
this.#closeSelectionPanel();
|
|
1271
|
+
},
|
|
1272
|
+
});
|
|
1273
|
+
this.#showSelectionPanel(panel);
|
|
1274
|
+
}
|
|
1275
|
+
#showSelectionPanel(component) {
|
|
1276
|
+
this.#selectionPanel = component;
|
|
1277
|
+
}
|
|
1278
|
+
#closeSelectionPanel() {
|
|
1279
|
+
this.#selectionPanel = undefined;
|
|
1280
|
+
}
|
|
1281
|
+
#renderInput(width) {
|
|
1282
|
+
return [
|
|
1283
|
+
this.#surfaceLine("", width),
|
|
1284
|
+
...this.#renderInputContent(width),
|
|
1285
|
+
this.#surfaceLine("", width),
|
|
1286
|
+
];
|
|
1287
|
+
}
|
|
1288
|
+
#renderInputContent(width) {
|
|
1289
|
+
if (this.#editor.getText().length === 0) {
|
|
1290
|
+
return [this.#inputSurfaceLine(this.#emptyInputLine(), width)];
|
|
1291
|
+
}
|
|
1292
|
+
const promptWidth = visibleWidth(INPUT_PROMPT);
|
|
1293
|
+
const editorWidth = Math.max(1, width - promptWidth);
|
|
1294
|
+
const contentLines = this.#stripSpuriousLeadingEmptyLine(this.#stripEditorChrome(this.#editor.render(editorWidth)));
|
|
1295
|
+
return contentLines.map((line, index) => {
|
|
1296
|
+
const prefix = index === 0 ? this.#inputPrompt() : INPUT_LINE_INDENT;
|
|
1297
|
+
const rendered = `${prefix}${this.#styleImagePlaceholders(line)}`;
|
|
1298
|
+
return this.#inputSurfaceLine(this.#cursorVisible ? rendered : this.#hideCursor(rendered), width);
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
#finishToolResult(block) {
|
|
1302
|
+
const existing = this.#entries.find((entry) => entry.id === block.toolCallId);
|
|
1303
|
+
const detail = this.#formatToolResult(block);
|
|
1304
|
+
if (existing !== undefined) {
|
|
1305
|
+
existing.role = block.isError ? "error" : "tool";
|
|
1306
|
+
existing.title = block.toolName;
|
|
1307
|
+
existing.detail = detail;
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
this.#appendEntry({
|
|
1311
|
+
id: block.toolCallId,
|
|
1312
|
+
role: block.isError ? "error" : "tool",
|
|
1313
|
+
title: block.toolName,
|
|
1314
|
+
text: block.toolName,
|
|
1315
|
+
detail,
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
#formatToolCall(toolName, args) {
|
|
1319
|
+
const record = this.#isRecord(args) ? args : {};
|
|
1320
|
+
const stringField = (key) => {
|
|
1321
|
+
const value = record[key];
|
|
1322
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
1323
|
+
};
|
|
1324
|
+
const normalized = toolName.toLowerCase();
|
|
1325
|
+
const command = stringField("cmd") ?? stringField("command");
|
|
1326
|
+
if (command !== undefined) {
|
|
1327
|
+
return this.#singleLine(command);
|
|
1328
|
+
}
|
|
1329
|
+
const path = stringField("file_path") ?? stringField("path");
|
|
1330
|
+
if (path !== undefined) {
|
|
1331
|
+
return this.#singleLine(path);
|
|
1332
|
+
}
|
|
1333
|
+
const pattern = stringField("pattern");
|
|
1334
|
+
if (pattern !== undefined) {
|
|
1335
|
+
return this.#singleLine(pattern);
|
|
1336
|
+
}
|
|
1337
|
+
const query = stringField("query");
|
|
1338
|
+
if (query !== undefined) {
|
|
1339
|
+
return this.#singleLine(query);
|
|
1340
|
+
}
|
|
1341
|
+
if (normalized === "todowrite") {
|
|
1342
|
+
const todos = record.todos;
|
|
1343
|
+
return Array.isArray(todos)
|
|
1344
|
+
? `${todos.length} todo${todos.length === 1 ? "" : "s"}`
|
|
1345
|
+
: "todos";
|
|
1346
|
+
}
|
|
1347
|
+
return toolName;
|
|
1348
|
+
}
|
|
1349
|
+
#formatToolResult(block) {
|
|
1350
|
+
return this.#singleLine(block.display.length > 0 ? block.display : "(empty result)");
|
|
1351
|
+
}
|
|
1352
|
+
#formatError(error) {
|
|
1353
|
+
if (error instanceof Error) {
|
|
1354
|
+
return error.message;
|
|
1355
|
+
}
|
|
1356
|
+
return String(error);
|
|
1357
|
+
}
|
|
1358
|
+
#formatImageType(mediaType) {
|
|
1359
|
+
const subtype = mediaType.split("/")[1]?.split(";")[0]?.trim();
|
|
1360
|
+
if (subtype === undefined || subtype.length === 0) {
|
|
1361
|
+
return "IMAGE";
|
|
1362
|
+
}
|
|
1363
|
+
const upperSubtype = subtype.toUpperCase();
|
|
1364
|
+
return upperSubtype === "JPEG" ? "JPG" : upperSubtype;
|
|
1365
|
+
}
|
|
1366
|
+
#styleImagePlaceholders(text) {
|
|
1367
|
+
return text.replace(IMAGE_PLACEHOLDER_REGEX, (placeholder) => `${IMAGE_CHIP_BG}${IMAGE_CHIP_FG}${placeholder}${SURFACE_BG}${INPUT_FG}`);
|
|
1368
|
+
}
|
|
1369
|
+
#fitLine(line, width) {
|
|
1370
|
+
return truncateToWidth(line, width, "", true);
|
|
1371
|
+
}
|
|
1372
|
+
#truncateLine(line, width) {
|
|
1373
|
+
return truncateToWidth(line, width, "", false);
|
|
1374
|
+
}
|
|
1375
|
+
#renderStartupBox(width, rows) {
|
|
1376
|
+
const maxInnerWidth = Math.max(1, width - 4);
|
|
1377
|
+
const contentWidth = rows
|
|
1378
|
+
.map((row) => visibleWidth(row))
|
|
1379
|
+
.reduce((maxWidth, rowWidth) => Math.max(maxWidth, rowWidth), 1);
|
|
1380
|
+
const innerWidth = Math.min(maxInnerWidth, contentWidth);
|
|
1381
|
+
const rule = "─".repeat(innerWidth + 2);
|
|
1382
|
+
const top = `╭${rule}╮`;
|
|
1383
|
+
const bottom = `╰${rule}╯`;
|
|
1384
|
+
return [
|
|
1385
|
+
this.#truncateLine(`${DIM}${top}${RESET}`, width),
|
|
1386
|
+
...rows.map((row) => {
|
|
1387
|
+
const paddedText = this.#fitAndPadLine(row, innerWidth);
|
|
1388
|
+
return this.#truncateLine(`${DIM}│ ${NOT_BOLD_OR_DIM}${paddedText}${DIM} │${RESET}`, width);
|
|
1389
|
+
}),
|
|
1390
|
+
this.#truncateLine(`${DIM}${bottom}${RESET}`, width),
|
|
1391
|
+
];
|
|
1392
|
+
}
|
|
1393
|
+
#renderUserEntry(entry, width) {
|
|
1394
|
+
const prefix = `${BOLD}›${NOT_BOLD_OR_DIM} `;
|
|
1395
|
+
const prefixWidth = visibleWidth(prefix);
|
|
1396
|
+
const contentWidth = Math.max(1, width - prefixWidth);
|
|
1397
|
+
const text = this.#styleImagePlaceholders(entry.text.length === 0 ? " " : entry.text);
|
|
1398
|
+
const wrapped = wrapTextWithAnsi(text, contentWidth);
|
|
1399
|
+
const indent = " ".repeat(prefixWidth);
|
|
1400
|
+
return [
|
|
1401
|
+
this.#surfaceLine("", width),
|
|
1402
|
+
...wrapped.map((line, index) => this.#inputSurfaceLine(`${index === 0 ? prefix : indent}${line}`, width)),
|
|
1403
|
+
this.#surfaceLine("", width),
|
|
1404
|
+
];
|
|
1405
|
+
}
|
|
1406
|
+
#renderAssistantEntry(entry, width) {
|
|
1407
|
+
const prefix = `${DIM}•${RESET} `;
|
|
1408
|
+
const prefixWidth = visibleWidth(prefix);
|
|
1409
|
+
const contentWidth = Math.max(1, width - prefixWidth);
|
|
1410
|
+
const renderedMarkdown = renderAgentMarkdown({
|
|
1411
|
+
text: entry.text,
|
|
1412
|
+
width: contentWidth,
|
|
1413
|
+
cwd: this.#cwd,
|
|
1414
|
+
});
|
|
1415
|
+
const indent = " ".repeat(prefixWidth);
|
|
1416
|
+
return renderedMarkdown.map((line, index) => this.#fitLine(`${index === 0 ? prefix : indent}${line}`, width));
|
|
1417
|
+
}
|
|
1418
|
+
#renderThinkingEntry(entry, width) {
|
|
1419
|
+
const prefix = `${DIM}•${RESET} `;
|
|
1420
|
+
const prefixWidth = visibleWidth(prefix);
|
|
1421
|
+
const contentWidth = Math.max(1, width - prefixWidth);
|
|
1422
|
+
const renderedMarkdown = renderAgentMarkdown({
|
|
1423
|
+
text: entry.text,
|
|
1424
|
+
width: contentWidth,
|
|
1425
|
+
cwd: this.#cwd,
|
|
1426
|
+
});
|
|
1427
|
+
const indent = " ".repeat(prefixWidth);
|
|
1428
|
+
return renderedMarkdown.map((line, index) => this.#fitLine(`${index === 0 ? prefix : indent}${line}`, width));
|
|
1429
|
+
}
|
|
1430
|
+
#renderToolEntry(entry, width, isError) {
|
|
1431
|
+
if (!isError &&
|
|
1432
|
+
entry.title === PENDING_TOOL_CALL_TITLE &&
|
|
1433
|
+
entry.text === PENDING_TOOL_CALL_TITLE) {
|
|
1434
|
+
return [
|
|
1435
|
+
this.#fitLine(`${DIM}•${RESET} ${renderActivityWave(PENDING_TOOL_CALL_TITLE, this.#activityAnimationFrame)}`, width),
|
|
1436
|
+
];
|
|
1437
|
+
}
|
|
1438
|
+
const toolName = entry.title ?? "tool";
|
|
1439
|
+
const verb = isError ? "Failed" : this.#toolVerb(toolName);
|
|
1440
|
+
const dot = isError ? RED : GREEN;
|
|
1441
|
+
const callText = this.#singleLine(entry.text);
|
|
1442
|
+
const titleSuffix = callText.length > 0 && callText !== toolName
|
|
1443
|
+
? ` ${CYAN}${callText}${RESET}`
|
|
1444
|
+
: ` ${CYAN}${toolName}${RESET}`;
|
|
1445
|
+
const title = `${dot}•${RESET} ${RIG_ORANGE}${BOLD}${verb}${NOT_BOLD_OR_DIM}${titleSuffix}`;
|
|
1446
|
+
const lines = [this.#fitLine(title, width)];
|
|
1447
|
+
if (entry.detail !== undefined) {
|
|
1448
|
+
const detailText = entry.detail.length > 0 ? entry.detail : "(empty result)";
|
|
1449
|
+
lines.push(this.#fitLine(` ${DIM}└${RESET} ${DIM}${detailText}${RESET}`, width));
|
|
1450
|
+
}
|
|
1451
|
+
return lines;
|
|
1452
|
+
}
|
|
1453
|
+
#renderNoticeEntry(title, text, width, color) {
|
|
1454
|
+
const prefix = `${color}•${RESET} ${BOLD}${title}${NOT_BOLD_OR_DIM} `;
|
|
1455
|
+
const prefixWidth = visibleWidth(prefix);
|
|
1456
|
+
const wrapped = wrapTextWithAnsi(text.length === 0 ? " " : text, Math.max(1, width - prefixWidth));
|
|
1457
|
+
const indent = " ".repeat(prefixWidth);
|
|
1458
|
+
return wrapped.map((line, index) => this.#fitLine(`${index === 0 ? prefix : indent}${line}`, width));
|
|
1459
|
+
}
|
|
1460
|
+
#emptyInputLine() {
|
|
1461
|
+
const marker = this.#focused ? CURSOR_MARKER : "";
|
|
1462
|
+
if (!this.#focused || !this.#cursorVisible) {
|
|
1463
|
+
return `${this.#inputPrompt()}${marker}${SURFACE_MUTED_FG}${INPUT_PLACEHOLDER}${INPUT_FG}`;
|
|
1464
|
+
}
|
|
1465
|
+
const firstCharacter = INPUT_PLACEHOLDER[0] ?? " ";
|
|
1466
|
+
const rest = INPUT_PLACEHOLDER.slice(firstCharacter.length);
|
|
1467
|
+
return `${this.#inputPrompt()}${marker}${CURSOR_BG}${CURSOR_FG}${firstCharacter}${RESET}${SURFACE_MUTED_FG}${rest}${INPUT_FG}`;
|
|
1468
|
+
}
|
|
1469
|
+
#surfaceLine(line, width) {
|
|
1470
|
+
return `${SURFACE_BG}${SURFACE_FG}${this.#fitAndPadLine(line, width)}${RESET}`;
|
|
1471
|
+
}
|
|
1472
|
+
#inputSurfaceLine(line, width) {
|
|
1473
|
+
const softened = this.#softenFakeCursor(line);
|
|
1474
|
+
return `${SURFACE_BG}${INPUT_FG}${this.#fitAndPadLine(this.#restoreInputSurface(softened), width)}${RESET}`;
|
|
1475
|
+
}
|
|
1476
|
+
#restoreInputSurface(line) {
|
|
1477
|
+
return line.replaceAll(RESET, `${RESET}${SURFACE_BG}${INPUT_FG}`);
|
|
1478
|
+
}
|
|
1479
|
+
#softenFakeCursor(line) {
|
|
1480
|
+
return line.replace(/\x1b\[7m([\s\S]*?)\x1b\[(?:27|0)m/gu, `${CURSOR_BG}${CURSOR_FG}$1${SURFACE_BG}${INPUT_FG}`);
|
|
1481
|
+
}
|
|
1482
|
+
#activityText() {
|
|
1483
|
+
const label = this.#activityLabel();
|
|
1484
|
+
if (label === undefined) {
|
|
1485
|
+
return undefined;
|
|
1486
|
+
}
|
|
1487
|
+
const elapsed = this.#activityElapsedText();
|
|
1488
|
+
if (elapsed === undefined) {
|
|
1489
|
+
return label;
|
|
1490
|
+
}
|
|
1491
|
+
return `${label} (${elapsed})`;
|
|
1492
|
+
}
|
|
1493
|
+
#activityElapsedText() {
|
|
1494
|
+
if (this.#activityStartedAtMs === undefined) {
|
|
1495
|
+
return undefined;
|
|
1496
|
+
}
|
|
1497
|
+
return formatActivityElapsedTime(this.#now() - this.#activityStartedAtMs);
|
|
1498
|
+
}
|
|
1499
|
+
#activityLabel() {
|
|
1500
|
+
if (this.#statusText === "Idle") {
|
|
1501
|
+
return undefined;
|
|
1502
|
+
}
|
|
1503
|
+
if (this.#statusText === "Running") {
|
|
1504
|
+
return "Working";
|
|
1505
|
+
}
|
|
1506
|
+
if (this.#statusText.startsWith("Stopped:")) {
|
|
1507
|
+
return undefined;
|
|
1508
|
+
}
|
|
1509
|
+
return this.#statusText;
|
|
1510
|
+
}
|
|
1511
|
+
#shouldRenderActivityAsLastMessage() {
|
|
1512
|
+
if (this.#streamEntryId !== undefined) {
|
|
1513
|
+
return false;
|
|
1514
|
+
}
|
|
1515
|
+
const lastEntry = this.#entries.at(-1);
|
|
1516
|
+
return (lastEntry === undefined ||
|
|
1517
|
+
lastEntry.role === "separator" ||
|
|
1518
|
+
lastEntry.role === "user" ||
|
|
1519
|
+
lastEntry.role === "system" ||
|
|
1520
|
+
(lastEntry.role === "thinking" && !this.#showReasoning));
|
|
1521
|
+
}
|
|
1522
|
+
#renderActivityLine(label, width) {
|
|
1523
|
+
const prefix = `${RIG_ORANGE}•${RESET} `;
|
|
1524
|
+
const frame = this.#activityAnimationFrame;
|
|
1525
|
+
const elapsed = this.#activityElapsedText();
|
|
1526
|
+
const elapsedSuffix = elapsed === undefined ? "" : ` ${DIM}${SURFACE_MUTED_FG}(${elapsed})${RESET}`;
|
|
1527
|
+
return [
|
|
1528
|
+
this.#fitLine(`${prefix}${renderActivityWave(label, frame)}${elapsedSuffix}`, width),
|
|
1529
|
+
];
|
|
1530
|
+
}
|
|
1531
|
+
#hideCursor(line) {
|
|
1532
|
+
return line.replace(/\x1b\[7m([\s\S]*?)\x1b\[(?:27|0)m/gu, "$1");
|
|
1533
|
+
}
|
|
1534
|
+
#fitAndPadLine(line, width) {
|
|
1535
|
+
const fitted = truncateToWidth(line, width, "", false);
|
|
1536
|
+
const padding = " ".repeat(Math.max(0, width - visibleWidth(fitted)));
|
|
1537
|
+
return `${fitted}${padding}`;
|
|
1538
|
+
}
|
|
1539
|
+
#turnSeparator(width) {
|
|
1540
|
+
return this.#fitLine(`${DIM}${"─".repeat(width)}${RESET}`, width);
|
|
1541
|
+
}
|
|
1542
|
+
#directoryName() {
|
|
1543
|
+
return basename(this.#cwd) || this.#cwd;
|
|
1544
|
+
}
|
|
1545
|
+
#inputPrompt() {
|
|
1546
|
+
return `${RIG_ORANGE}${BOLD}›${NOT_BOLD_OR_DIM}${INPUT_FG} `;
|
|
1547
|
+
}
|
|
1548
|
+
#handleReasoningShortcut(data) {
|
|
1549
|
+
const direction = this.#reasoningShortcutDirection(data);
|
|
1550
|
+
if (direction === undefined) {
|
|
1551
|
+
return false;
|
|
1552
|
+
}
|
|
1553
|
+
const nextEffort = this.#nextReasoningEffort(direction);
|
|
1554
|
+
if (nextEffort !== undefined) {
|
|
1555
|
+
this.#agent.setEffort(nextEffort);
|
|
1556
|
+
if (!this.#modelLocked) {
|
|
1557
|
+
this.#persistDefaultModel(this.#agent.model.id, nextEffort);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
return true;
|
|
1561
|
+
}
|
|
1562
|
+
#persistDefaultModel(modelId, effort, providerId = this.#agent.provider.id) {
|
|
1563
|
+
if (this.#onDefaultModelChange === undefined) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
void Promise.resolve(this.#onDefaultModelChange({
|
|
1567
|
+
modelId,
|
|
1568
|
+
providerId,
|
|
1569
|
+
effort,
|
|
1570
|
+
})).catch(() => {
|
|
1571
|
+
if (this.#stopped || this.#exiting) {
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
this.#appendEntry({
|
|
1575
|
+
role: "event",
|
|
1576
|
+
title: "config",
|
|
1577
|
+
text: "Could not update the config file.",
|
|
1578
|
+
});
|
|
1579
|
+
this.#requestRender();
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
#setShowReasoning(showReasoning) {
|
|
1583
|
+
if (this.#showReasoning === showReasoning) {
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
this.#showReasoning = showReasoning;
|
|
1587
|
+
this.#persistSettings();
|
|
1588
|
+
}
|
|
1589
|
+
#persistSettings() {
|
|
1590
|
+
if (this.#onSettingsChange === undefined) {
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
void Promise.resolve(this.#onSettingsChange({
|
|
1594
|
+
showReasoning: this.#showReasoning,
|
|
1595
|
+
})).catch(() => {
|
|
1596
|
+
if (this.#stopped || this.#exiting) {
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
this.#appendEntry({
|
|
1600
|
+
role: "event",
|
|
1601
|
+
title: "config",
|
|
1602
|
+
text: "Could not update the config file.",
|
|
1603
|
+
});
|
|
1604
|
+
this.#requestRender();
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
#modelChoices() {
|
|
1608
|
+
return (this.#agent.modelChoices ??
|
|
1609
|
+
this.#agent.provider.models.map((model) => ({
|
|
1610
|
+
model,
|
|
1611
|
+
providerId: this.#agent.provider.id,
|
|
1612
|
+
})));
|
|
1613
|
+
}
|
|
1614
|
+
#handleModelMenuShortcut(data) {
|
|
1615
|
+
if (MODEL_MENU_RAW_KEYS.has(data) || matchesKey(data, "alt+m")) {
|
|
1616
|
+
this.#openModelMenu();
|
|
1617
|
+
return true;
|
|
1618
|
+
}
|
|
1619
|
+
return false;
|
|
1620
|
+
}
|
|
1621
|
+
#refreshSkillCommands(options = {}) {
|
|
1622
|
+
if (options.force !== true &&
|
|
1623
|
+
(this.#skillCommandsLoaded || this.#skillCommandsRefresh !== undefined)) {
|
|
1624
|
+
return this.#skillCommandsRefresh ?? Promise.resolve();
|
|
1625
|
+
}
|
|
1626
|
+
const refresh = loadSkills(this.#agent.context.fs)
|
|
1627
|
+
.then((skills) => {
|
|
1628
|
+
this.#skillsByName = new Map(skills.map((skill) => [skill.name, skill]));
|
|
1629
|
+
this.#skillCommands = skills.map((skill) => ({
|
|
1630
|
+
value: `skill:${skill.name}`,
|
|
1631
|
+
label: `/skill:${skill.name}`,
|
|
1632
|
+
description: skill.description,
|
|
1633
|
+
aliases: [],
|
|
1634
|
+
}));
|
|
1635
|
+
this.#skillCommandsLoaded = true;
|
|
1636
|
+
})
|
|
1637
|
+
.catch(() => {
|
|
1638
|
+
this.#skillsByName = new Map();
|
|
1639
|
+
this.#skillCommands = [];
|
|
1640
|
+
this.#skillCommandsLoaded = true;
|
|
1641
|
+
});
|
|
1642
|
+
const trackedRefresh = refresh.finally(() => {
|
|
1643
|
+
if (this.#skillCommandsRefresh === trackedRefresh) {
|
|
1644
|
+
this.#skillCommandsRefresh = undefined;
|
|
1645
|
+
}
|
|
1646
|
+
this.#requestRender();
|
|
1647
|
+
});
|
|
1648
|
+
this.#skillCommandsRefresh = trackedRefresh;
|
|
1649
|
+
return trackedRefresh;
|
|
1650
|
+
}
|
|
1651
|
+
#handleSlashCommandAutocompleteInput(data) {
|
|
1652
|
+
const suggestions = this.#slashCommandSuggestions();
|
|
1653
|
+
if (suggestions.length === 0) {
|
|
1654
|
+
return false;
|
|
1655
|
+
}
|
|
1656
|
+
if (matchesKey(data, "up")) {
|
|
1657
|
+
this.#slashCommandSelectionIndex =
|
|
1658
|
+
(this.#slashCommandSelectionIndex + suggestions.length - 1) % suggestions.length;
|
|
1659
|
+
return true;
|
|
1660
|
+
}
|
|
1661
|
+
if (matchesKey(data, "down")) {
|
|
1662
|
+
this.#slashCommandSelectionIndex =
|
|
1663
|
+
(this.#slashCommandSelectionIndex + 1) % suggestions.length;
|
|
1664
|
+
return true;
|
|
1665
|
+
}
|
|
1666
|
+
if (matchesKey(data, "escape")) {
|
|
1667
|
+
this.#dismissedSlashCommandText = this.#editor.getText();
|
|
1668
|
+
return true;
|
|
1669
|
+
}
|
|
1670
|
+
if (matchesKey(data, "enter") || matchesKey(data, "tab")) {
|
|
1671
|
+
const selected = suggestions[this.#slashCommandSelectionIndex] ?? suggestions[0];
|
|
1672
|
+
if (selected === undefined) {
|
|
1673
|
+
return true;
|
|
1674
|
+
}
|
|
1675
|
+
this.#dismissedSlashCommandText = undefined;
|
|
1676
|
+
this.#submit(`/${selected.value}`);
|
|
1677
|
+
return true;
|
|
1678
|
+
}
|
|
1679
|
+
return false;
|
|
1680
|
+
}
|
|
1681
|
+
#slashCommandSuggestions() {
|
|
1682
|
+
const text = this.#editor.getText();
|
|
1683
|
+
if (text.length === 0 ||
|
|
1684
|
+
text === this.#dismissedSlashCommandText ||
|
|
1685
|
+
text.includes("\n") ||
|
|
1686
|
+
!text.startsWith("/") ||
|
|
1687
|
+
/\s/u.test(text)) {
|
|
1688
|
+
return [];
|
|
1689
|
+
}
|
|
1690
|
+
const query = text.slice(1).toLowerCase();
|
|
1691
|
+
if (!this.#skillCommandsLoaded && this.#skillCommandsRefresh === undefined) {
|
|
1692
|
+
void this.#refreshSkillCommands();
|
|
1693
|
+
}
|
|
1694
|
+
const suggestions = [...this.#slashCommands, ...this.#skillCommands].filter((command) => command.value.toLowerCase().startsWith(query) ||
|
|
1695
|
+
command.aliases.some((alias) => alias.toLowerCase().startsWith(query)));
|
|
1696
|
+
if (this.#slashCommandSelectionIndex >= suggestions.length) {
|
|
1697
|
+
this.#slashCommandSelectionIndex = 0;
|
|
1698
|
+
}
|
|
1699
|
+
return suggestions;
|
|
1700
|
+
}
|
|
1701
|
+
#syncSlashCommandAutocompleteState() {
|
|
1702
|
+
const text = this.#editor.getText();
|
|
1703
|
+
if (this.#dismissedSlashCommandText !== undefined &&
|
|
1704
|
+
text !== this.#dismissedSlashCommandText) {
|
|
1705
|
+
this.#dismissedSlashCommandText = undefined;
|
|
1706
|
+
}
|
|
1707
|
+
this.#slashCommandSuggestions();
|
|
1708
|
+
}
|
|
1709
|
+
#reasoningShortcutDirection(data) {
|
|
1710
|
+
if (REASONING_DOWN_RAW_KEYS.has(data) ||
|
|
1711
|
+
matchesKey(data, "alt+,") ||
|
|
1712
|
+
matchesKey(data, "shift+down")) {
|
|
1713
|
+
return "down";
|
|
1714
|
+
}
|
|
1715
|
+
if (REASONING_UP_RAW_KEYS.has(data) ||
|
|
1716
|
+
matchesKey(data, "alt+.") ||
|
|
1717
|
+
matchesKey(data, "shift+up")) {
|
|
1718
|
+
return "up";
|
|
1719
|
+
}
|
|
1720
|
+
return undefined;
|
|
1721
|
+
}
|
|
1722
|
+
#nextReasoningEffort(direction) {
|
|
1723
|
+
const choices = [...this.#agent.model.thinkingLevels];
|
|
1724
|
+
if (choices.length === 0) {
|
|
1725
|
+
return undefined;
|
|
1726
|
+
}
|
|
1727
|
+
const firstChoice = choices[0];
|
|
1728
|
+
if (firstChoice === undefined) {
|
|
1729
|
+
return undefined;
|
|
1730
|
+
}
|
|
1731
|
+
const snapshotEffort = this.#agent.snapshot().effort;
|
|
1732
|
+
const fallbackEffort = this.#agent.model.defaultThinkingLevel;
|
|
1733
|
+
const currentEffort = snapshotEffort !== undefined && choices.includes(snapshotEffort)
|
|
1734
|
+
? snapshotEffort
|
|
1735
|
+
: choices.includes(fallbackEffort)
|
|
1736
|
+
? fallbackEffort
|
|
1737
|
+
: firstChoice;
|
|
1738
|
+
const currentIndex = choices.indexOf(currentEffort);
|
|
1739
|
+
const nextIndex = direction === "up" ? currentIndex + 1 : currentIndex - 1;
|
|
1740
|
+
return choices[nextIndex];
|
|
1741
|
+
}
|
|
1742
|
+
#modelDisplayName() {
|
|
1743
|
+
return this.#agent.model.name;
|
|
1744
|
+
}
|
|
1745
|
+
#modelWithReasoningDisplayName() {
|
|
1746
|
+
const effort = this.#agent.snapshot().effort ?? this.#agent.model.defaultThinkingLevel;
|
|
1747
|
+
return effort === undefined
|
|
1748
|
+
? this.#modelDisplayName()
|
|
1749
|
+
: `${this.#modelDisplayName()} ${humanizeReasoningLevel(effort)}`;
|
|
1750
|
+
}
|
|
1751
|
+
#cwdDisplayName() {
|
|
1752
|
+
const home = homedir();
|
|
1753
|
+
if (this.#cwd === home) {
|
|
1754
|
+
return "~";
|
|
1755
|
+
}
|
|
1756
|
+
if (this.#cwd.startsWith(`${home}/`)) {
|
|
1757
|
+
return `~/${this.#cwd.slice(home.length + 1)}`;
|
|
1758
|
+
}
|
|
1759
|
+
return this.#cwd;
|
|
1760
|
+
}
|
|
1761
|
+
#toolVerb(toolName) {
|
|
1762
|
+
const normalized = toolName.toLowerCase();
|
|
1763
|
+
if (normalized.includes("bash") || normalized.includes("exec")) {
|
|
1764
|
+
return "Ran";
|
|
1765
|
+
}
|
|
1766
|
+
if (normalized.includes("grep") ||
|
|
1767
|
+
normalized.includes("find") ||
|
|
1768
|
+
normalized.includes("glob") ||
|
|
1769
|
+
normalized === "ls") {
|
|
1770
|
+
return "Explored";
|
|
1771
|
+
}
|
|
1772
|
+
if (normalized.includes("read") || normalized.includes("view")) {
|
|
1773
|
+
return "Read";
|
|
1774
|
+
}
|
|
1775
|
+
if (normalized.includes("write") ||
|
|
1776
|
+
normalized.includes("edit") ||
|
|
1777
|
+
normalized.includes("patch")) {
|
|
1778
|
+
return "Edited";
|
|
1779
|
+
}
|
|
1780
|
+
return "Used";
|
|
1781
|
+
}
|
|
1782
|
+
#isRecord(value) {
|
|
1783
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1784
|
+
}
|
|
1785
|
+
#singleLine(text) {
|
|
1786
|
+
return text.replace(/\s+/gu, " ").trim();
|
|
1787
|
+
}
|
|
1788
|
+
#markTypingActivity() {
|
|
1789
|
+
this.#cursorTyping = true;
|
|
1790
|
+
this.#cursorVisible = true;
|
|
1791
|
+
if (this.#cursorTypingDebounceTimer !== undefined) {
|
|
1792
|
+
clearTimeout(this.#cursorTypingDebounceTimer);
|
|
1793
|
+
}
|
|
1794
|
+
this.#cursorTypingDebounceTimer = setTimeout(() => {
|
|
1795
|
+
this.#cursorTypingDebounceTimer = undefined;
|
|
1796
|
+
this.#cursorTyping = false;
|
|
1797
|
+
}, CURSOR_TYPING_DEBOUNCE_MS);
|
|
1798
|
+
this.#cursorTypingDebounceTimer.unref?.();
|
|
1799
|
+
}
|
|
1800
|
+
#stripEditorChrome(lines) {
|
|
1801
|
+
let content = [...lines];
|
|
1802
|
+
while (content.length > 0 && this.#isEditorBorderLine(content[0] ?? "")) {
|
|
1803
|
+
content = content.slice(1);
|
|
1804
|
+
}
|
|
1805
|
+
while (content.length > 0 && this.#isEditorBorderLine(content[content.length - 1] ?? "")) {
|
|
1806
|
+
content = content.slice(0, -1);
|
|
1807
|
+
}
|
|
1808
|
+
return content.filter((line) => !line.includes(" more ") && !this.#isEditorBorderLine(line));
|
|
1809
|
+
}
|
|
1810
|
+
#isEditorBorderLine(line) {
|
|
1811
|
+
const stripped = line.replace(/\x1b\[[0-9;]*m/g, "");
|
|
1812
|
+
return stripped.length > 0 && [...stripped].every((character) => character === "─");
|
|
1813
|
+
}
|
|
1814
|
+
#stripSpuriousLeadingEmptyLine(lines) {
|
|
1815
|
+
if (lines.length <= 1) {
|
|
1816
|
+
return lines;
|
|
1817
|
+
}
|
|
1818
|
+
const first = lines[0] ?? "";
|
|
1819
|
+
if (this.#isVisibleEditorLine(first)) {
|
|
1820
|
+
return lines;
|
|
1821
|
+
}
|
|
1822
|
+
return lines.slice(1);
|
|
1823
|
+
}
|
|
1824
|
+
#isVisibleEditorLine(line) {
|
|
1825
|
+
const stripped = line
|
|
1826
|
+
.replace(/\x1b\[[0-9;]*m/g, "")
|
|
1827
|
+
.replaceAll(CURSOR_MARKER, "")
|
|
1828
|
+
.trim();
|
|
1829
|
+
return stripped.length > 0 || line.includes("\x1b[7m") || line.includes(CURSOR_MARKER);
|
|
1830
|
+
}
|
|
1831
|
+
#startCursorBlink() {
|
|
1832
|
+
if (this.#cursorBlinkTimer !== undefined || this.#stopped) {
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
this.#cursorBlinkTimer = setInterval(() => {
|
|
1836
|
+
if (!this.#focused || this.#stopped || this.#cursorTyping) {
|
|
1837
|
+
return;
|
|
1838
|
+
}
|
|
1839
|
+
this.#cursorVisible = !this.#cursorVisible;
|
|
1840
|
+
this.#requestRender();
|
|
1841
|
+
}, CURSOR_BLINK_MS);
|
|
1842
|
+
this.#cursorBlinkTimer.unref?.();
|
|
1843
|
+
}
|
|
1844
|
+
#stopCursorBlink() {
|
|
1845
|
+
if (this.#cursorTypingDebounceTimer !== undefined) {
|
|
1846
|
+
clearTimeout(this.#cursorTypingDebounceTimer);
|
|
1847
|
+
this.#cursorTypingDebounceTimer = undefined;
|
|
1848
|
+
}
|
|
1849
|
+
this.#cursorTyping = false;
|
|
1850
|
+
if (this.#cursorBlinkTimer === undefined) {
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
clearInterval(this.#cursorBlinkTimer);
|
|
1854
|
+
this.#cursorBlinkTimer = undefined;
|
|
1855
|
+
this.#cursorVisible = true;
|
|
1856
|
+
}
|
|
1857
|
+
#startActivityAnimation() {
|
|
1858
|
+
if (this.#activityAnimationTimer !== undefined || this.#stopped) {
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
this.#activityAnimationFrame = 0;
|
|
1862
|
+
this.#activityAnimationTimer = setInterval(() => {
|
|
1863
|
+
if (this.#stopped || this.#exiting) {
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
this.#activityAnimationFrame =
|
|
1867
|
+
(this.#activityAnimationFrame + 1) % ACTIVITY_WAVE_FRAME_COUNT;
|
|
1868
|
+
if (this.#activityText() !== undefined && this.#shouldRenderActivityAsLastMessage()) {
|
|
1869
|
+
this.#requestRender();
|
|
1870
|
+
}
|
|
1871
|
+
}, ACTIVITY_ANIMATION_MS);
|
|
1872
|
+
this.#activityAnimationTimer.unref?.();
|
|
1873
|
+
}
|
|
1874
|
+
#stopActivityAnimation() {
|
|
1875
|
+
if (this.#activityAnimationTimer === undefined) {
|
|
1876
|
+
this.#activityAnimationFrame = 0;
|
|
1877
|
+
this.#activityStartedAtMs = undefined;
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
clearInterval(this.#activityAnimationTimer);
|
|
1881
|
+
this.#activityAnimationTimer = undefined;
|
|
1882
|
+
this.#activityAnimationFrame = 0;
|
|
1883
|
+
this.#activityStartedAtMs = undefined;
|
|
1884
|
+
}
|
|
1885
|
+
#requestRender(force = false) {
|
|
1886
|
+
if (!this.#stopped) {
|
|
1887
|
+
this.#tui.requestRender(force);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
#waitForShutdownRender() {
|
|
1891
|
+
return new Promise((resolve) => {
|
|
1892
|
+
setTimeout(resolve, 25);
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
}
|