@slopus/rig 0.0.4 → 0.0.6
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/README.md +144 -1
- package/dist/agent/Agent.d.ts +16 -0
- package/dist/agent/Agent.d.ts.map +1 -1
- package/dist/agent/Agent.js +106 -0
- package/dist/agent/compaction/compactConversation.d.ts +22 -0
- package/dist/agent/compaction/compactConversation.d.ts.map +1 -0
- package/dist/agent/compaction/compactConversation.js +77 -0
- package/dist/agent/compaction/estimateMessagesTokens.d.ts +3 -0
- package/dist/agent/compaction/estimateMessagesTokens.d.ts.map +1 -0
- package/dist/agent/compaction/estimateMessagesTokens.js +39 -0
- package/dist/agent/compaction/formatMessagesForCompaction.d.ts +3 -0
- package/dist/agent/compaction/formatMessagesForCompaction.d.ts.map +1 -0
- package/dist/agent/compaction/formatMessagesForCompaction.js +30 -0
- package/dist/agent/compaction/requestCompactionSummary.d.ts +11 -0
- package/dist/agent/compaction/requestCompactionSummary.d.ts.map +1 -0
- package/dist/agent/compaction/requestCompactionSummary.js +43 -0
- package/dist/agent/context/AgentContext.d.ts +8 -0
- package/dist/agent/context/AgentContext.d.ts.map +1 -1
- package/dist/agent/context/BashContext.d.ts +23 -0
- package/dist/agent/context/BashContext.d.ts.map +1 -1
- package/dist/agent/context/GoalContext.d.ts +7 -0
- package/dist/agent/context/GoalContext.d.ts.map +1 -0
- package/dist/agent/context/GoalContext.js +1 -0
- package/dist/agent/context/SubagentContext.d.ts +20 -1
- package/dist/agent/context/SubagentContext.d.ts.map +1 -1
- package/dist/agent/context/TaskContext.d.ts +8 -0
- package/dist/agent/context/TaskContext.d.ts.map +1 -0
- package/dist/agent/context/TaskContext.js +1 -0
- package/dist/agent/context/UserInputContext.d.ts +7 -0
- package/dist/agent/context/UserInputContext.d.ts.map +1 -0
- package/dist/agent/context/UserInputContext.js +1 -0
- package/dist/agent/context/assertCanWritePath.d.ts +3 -0
- package/dist/agent/context/assertCanWritePath.d.ts.map +1 -0
- package/dist/agent/context/assertCanWritePath.js +11 -0
- package/dist/agent/context/createJustBashBashContext.d.ts.map +1 -1
- package/dist/agent/context/createJustBashBashContext.js +127 -0
- package/dist/agent/context/createNodeAgentContext.d.ts +8 -0
- package/dist/agent/context/createNodeAgentContext.d.ts.map +1 -1
- package/dist/agent/context/createNodeAgentContext.js +15 -2
- package/dist/agent/context/createNodeBashContext.d.ts +2 -0
- package/dist/agent/context/createNodeBashContext.d.ts.map +1 -1
- package/dist/agent/context/createNodeBashContext.js +123 -4
- package/dist/agent/context/createNodeFileSystemContext.d.ts +2 -0
- package/dist/agent/context/createNodeFileSystemContext.d.ts.map +1 -1
- package/dist/agent/context/createNodeFileSystemContext.js +18 -8
- package/dist/agent/context/createSandboxedCommand.d.ts +7 -0
- package/dist/agent/context/createSandboxedCommand.d.ts.map +1 -0
- package/dist/agent/context/createSandboxedCommand.js +47 -0
- package/dist/agent/context/findGitWritablePaths.d.ts +2 -0
- package/dist/agent/context/findGitWritablePaths.d.ts.map +1 -0
- package/dist/agent/context/findGitWritablePaths.js +54 -0
- package/dist/agent/context/isPathInsideWorkspace.d.ts +2 -0
- package/dist/agent/context/isPathInsideWorkspace.d.ts.map +1 -0
- package/dist/agent/context/isPathInsideWorkspace.js +14 -0
- package/dist/agent/context/resolvePotentialPath.d.ts +2 -0
- package/dist/agent/context/resolvePotentialPath.d.ts.map +1 -0
- package/dist/agent/context/resolvePotentialPath.js +32 -0
- package/dist/agent/createPermissionInstructions.d.ts +3 -0
- package/dist/agent/createPermissionInstructions.d.ts.map +1 -0
- package/dist/agent/createPermissionInstructions.js +12 -0
- package/dist/agent/createSubagentInstructions.js +1 -1
- package/dist/agent/createSystemPrompt.d.ts.map +1 -1
- package/dist/agent/createSystemPrompt.js +4 -0
- package/dist/agent/index.d.ts +7 -3
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/loop.d.ts +16 -2
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +115 -15
- package/dist/agent/printAgentMessageToConsole.d.ts +1 -0
- package/dist/agent/printAgentMessageToConsole.d.ts.map +1 -1
- package/dist/agent/types.d.ts +1 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/app/CodingAssistantAgentBackend.d.ts +11 -1
- package/dist/app/CodingAssistantAgentBackend.d.ts.map +1 -1
- package/dist/app/CodingAssistantApp.d.ts +7 -1
- package/dist/app/CodingAssistantApp.d.ts.map +1 -1
- package/dist/app/CodingAssistantApp.js +678 -45
- package/dist/app/ScrollbackPreservingTerminal.d.ts +5 -0
- package/dist/app/ScrollbackPreservingTerminal.d.ts.map +1 -0
- package/dist/app/ScrollbackPreservingTerminal.js +7 -0
- package/dist/app/StartupStatusApp.js +1 -1
- package/dist/app/createCodingAssistantAgent.d.ts +6 -1
- package/dist/app/createCodingAssistantAgent.d.ts.map +1 -1
- package/dist/app/createCodingAssistantAgent.js +22 -5
- package/dist/app/createSlashCommands.d.ts.map +1 -1
- package/dist/app/createSlashCommands.js +42 -0
- package/dist/app/highlightAgentCode.d.ts.map +1 -1
- package/dist/app/highlightAgentCode.js +10 -7
- package/dist/app/humanizeGoalStatus.d.ts +3 -0
- package/dist/app/humanizeGoalStatus.d.ts.map +1 -0
- package/dist/app/humanizeGoalStatus.js +9 -0
- package/dist/app/humanizePermissionMode.d.ts +3 -0
- package/dist/app/humanizePermissionMode.d.ts.map +1 -0
- package/dist/app/humanizePermissionMode.js +9 -0
- package/dist/app/humanizeToolName.d.ts +2 -0
- package/dist/app/humanizeToolName.d.ts.map +1 -0
- package/dist/app/humanizeToolName.js +40 -0
- package/dist/app/main.d.ts.map +1 -1
- package/dist/app/main.js +4 -0
- package/dist/app/renderAgentMarkdown.d.ts.map +1 -1
- package/dist/app/renderAgentMarkdown.js +2 -1
- package/dist/app/runApp.d.ts +2 -0
- package/dist/app/runApp.d.ts.map +1 -1
- package/dist/app/runApp.js +48 -3
- package/dist/app/sanitizeTerminalText.d.ts +2 -0
- package/dist/app/sanitizeTerminalText.d.ts.map +1 -0
- package/dist/app/sanitizeTerminalText.js +55 -0
- package/dist/app/upsertSubagentSummary.d.ts +3 -0
- package/dist/app/upsertSubagentSummary.d.ts.map +1 -0
- package/dist/app/upsertSubagentSummary.js +6 -0
- package/dist/client/ProtocolHttpClient.d.ts +12 -1
- package/dist/client/ProtocolHttpClient.d.ts.map +1 -1
- package/dist/client/ProtocolHttpClient.js +21 -0
- package/dist/client/RemoteAgent.d.ts +11 -1
- package/dist/client/RemoteAgent.d.ts.map +1 -1
- package/dist/client/RemoteAgent.js +91 -1
- package/dist/config/createConfigFile.d.ts.map +1 -1
- package/dist/config/createConfigFile.js +5 -0
- package/dist/config/defaultConfig.d.ts.map +1 -1
- package/dist/config/defaultConfig.js +2 -0
- package/dist/config/mergeConfigValues.d.ts.map +1 -1
- package/dist/config/mergeConfigValues.js +8 -1
- package/dist/config/parseConfigToml.d.ts.map +1 -1
- package/dist/config/parseConfigToml.js +88 -0
- package/dist/config/serializeMcpServers.d.ts +3 -0
- package/dist/config/serializeMcpServers.d.ts.map +1 -0
- package/dist/config/serializeMcpServers.js +34 -0
- package/dist/config/types.d.ts +6 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/writeRuntimeConfig.d.ts.map +1 -1
- package/dist/config/writeRuntimeConfig.js +3 -0
- package/dist/goals/SessionGoal.d.ts +14 -0
- package/dist/goals/SessionGoal.d.ts.map +1 -0
- package/dist/goals/SessionGoal.js +1 -0
- package/dist/goals/createGoalContinuationPrompt.d.ts +3 -0
- package/dist/goals/createGoalContinuationPrompt.d.ts.map +1 -0
- package/dist/goals/createGoalContinuationPrompt.js +17 -0
- package/dist/goals/index.d.ts +5 -0
- package/dist/goals/index.d.ts.map +1 -0
- package/dist/goals/index.js +3 -0
- package/dist/goals/isGoalStatus.d.ts +3 -0
- package/dist/goals/isGoalStatus.d.ts.map +1 -0
- package/dist/goals/isGoalStatus.js +3 -0
- package/dist/goals/normalizeGoalObjective.d.ts +3 -0
- package/dist/goals/normalizeGoalObjective.d.ts.map +1 -0
- package/dist/goals/normalizeGoalObjective.js +11 -0
- package/dist/mcp/McpClientManager.d.ts +12 -0
- package/dist/mcp/McpClientManager.d.ts.map +1 -0
- package/dist/mcp/McpClientManager.js +123 -0
- package/dist/mcp/connectMcpServer.d.ts +8 -0
- package/dist/mcp/connectMcpServer.d.ts.map +1 -0
- package/dist/mcp/connectMcpServer.js +47 -0
- package/dist/mcp/createMcpTool.d.ts +11 -0
- package/dist/mcp/createMcpTool.d.ts.map +1 -0
- package/dist/mcp/createMcpTool.js +43 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/loadMcpServerConfigs.d.ts +4 -0
- package/dist/mcp/loadMcpServerConfigs.d.ts.map +1 -0
- package/dist/mcp/loadMcpServerConfigs.js +122 -0
- package/dist/mcp/mcpResultToContentBlocks.d.ts +3 -0
- package/dist/mcp/mcpResultToContentBlocks.d.ts.map +1 -0
- package/dist/mcp/mcpResultToContentBlocks.js +51 -0
- package/dist/mcp/mergeMcpTools.d.ts +7 -0
- package/dist/mcp/mergeMcpTools.d.ts.map +1 -0
- package/dist/mcp/mergeMcpTools.js +34 -0
- package/dist/mcp/normalizeMcpName.d.ts +2 -0
- package/dist/mcp/normalizeMcpName.d.ts.map +1 -0
- package/dist/mcp/normalizeMcpName.js +3 -0
- package/dist/mcp/types.d.ts +37 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +1 -0
- package/dist/permissions/PermissionContext.d.ts +7 -0
- package/dist/permissions/PermissionContext.d.ts.map +1 -0
- package/dist/permissions/PermissionContext.js +1 -0
- package/dist/permissions/PermissionMode.d.ts +3 -0
- package/dist/permissions/PermissionMode.d.ts.map +1 -0
- package/dist/permissions/PermissionMode.js +1 -0
- package/dist/permissions/createPermissionContext.d.ts +4 -0
- package/dist/permissions/createPermissionContext.d.ts.map +1 -0
- package/dist/permissions/createPermissionContext.js +16 -0
- package/dist/permissions/index.d.ts +13 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +9 -0
- package/dist/permissions/isPermissionMode.d.ts +3 -0
- package/dist/permissions/isPermissionMode.d.ts.map +1 -0
- package/dist/permissions/isPermissionMode.js +6 -0
- package/dist/permissions/parseAutoPermissionReview.d.ts +7 -0
- package/dist/permissions/parseAutoPermissionReview.d.ts.map +1 -0
- package/dist/permissions/parseAutoPermissionReview.js +33 -0
- package/dist/permissions/parsePermissionMode.d.ts +3 -0
- package/dist/permissions/parsePermissionMode.d.ts.map +1 -0
- package/dist/permissions/parsePermissionMode.js +6 -0
- package/dist/permissions/requestAutoPermissionApproval.d.ts +9 -0
- package/dist/permissions/requestAutoPermissionApproval.d.ts.map +1 -0
- package/dist/permissions/requestAutoPermissionApproval.js +26 -0
- package/dist/permissions/reviewAutoPermission.d.ts +13 -0
- package/dist/permissions/reviewAutoPermission.d.ts.map +1 -0
- package/dist/permissions/reviewAutoPermission.js +70 -0
- package/dist/permissions/shouldElevateToolInAutoMode.d.ts +2 -0
- package/dist/permissions/shouldElevateToolInAutoMode.d.ts.map +1 -0
- package/dist/permissions/shouldElevateToolInAutoMode.js +37 -0
- package/dist/permissions/shouldReviewToolInAutoMode.d.ts +2 -0
- package/dist/permissions/shouldReviewToolInAutoMode.d.ts.map +1 -0
- package/dist/permissions/shouldReviewToolInAutoMode.js +85 -0
- package/dist/permissions/summarizePermissionAction.d.ts +2 -0
- package/dist/permissions/summarizePermissionAction.d.ts.map +1 -0
- package/dist/permissions/summarizePermissionAction.js +29 -0
- package/dist/protocol/SessionProtocol.d.ts +49 -2
- package/dist/protocol/SessionProtocol.d.ts.map +1 -1
- package/dist/protocol/index.d.ts +4 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/providers/claude-sdk.d.ts.map +1 -1
- package/dist/providers/claude-sdk.js +7 -6
- package/dist/providers/models.d.ts +12 -12
- package/dist/providers/models.d.ts.map +1 -1
- package/dist/providers/models.js +18 -0
- package/dist/providers/types.d.ts +3 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/review/createCodeReviewPrompt.d.ts +2 -0
- package/dist/review/createCodeReviewPrompt.d.ts.map +1 -0
- package/dist/review/createCodeReviewPrompt.js +11 -0
- package/dist/review/index.d.ts +2 -0
- package/dist/review/index.d.ts.map +1 -0
- package/dist/review/index.js +1 -0
- package/dist/server/AgentSessionManager.d.ts +10 -1
- package/dist/server/AgentSessionManager.d.ts.map +1 -1
- package/dist/server/AgentSessionManager.js +203 -12
- package/dist/server/InMemorySession.d.ts +34 -1
- package/dist/server/InMemorySession.d.ts.map +1 -1
- package/dist/server/InMemorySession.js +558 -10
- package/dist/server/InMemorySessionStore.d.ts +2 -0
- package/dist/server/InMemorySessionStore.d.ts.map +1 -1
- package/dist/server/InMemorySessionStore.js +7 -0
- package/dist/server/PersistentSessionStore.d.ts +2 -0
- package/dist/server/PersistentSessionStore.d.ts.map +1 -1
- package/dist/server/PersistentSessionStore.js +80 -5
- package/dist/server/createGoalTitle.d.ts +2 -0
- package/dist/server/createGoalTitle.d.ts.map +1 -0
- package/dist/server/createGoalTitle.js +4 -0
- package/dist/server/createProtocolHttpServer.d.ts.map +1 -1
- package/dist/server/createProtocolHttpServer.js +119 -2
- package/dist/server/runLocalProtocolServer.d.ts.map +1 -1
- package/dist/server/runLocalProtocolServer.js +18 -2
- package/dist/tasks/index.d.ts +2 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +1 -0
- package/dist/tasks/types.d.ts +39 -0
- package/dist/tasks/types.d.ts.map +1 -0
- package/dist/tasks/types.js +1 -0
- package/dist/tools/Agent.d.ts +13 -3
- package/dist/tools/Agent.d.ts.map +1 -1
- package/dist/tools/Agent.js +40 -12
- package/dist/tools/claude/AskUserQuestion.d.ts +23 -0
- package/dist/tools/claude/AskUserQuestion.d.ts.map +1 -0
- package/dist/tools/claude/AskUserQuestion.js +52 -0
- package/dist/tools/claude/Bash.d.ts +2 -0
- package/dist/tools/claude/Bash.d.ts.map +1 -1
- package/dist/tools/claude/Bash.js +20 -2
- package/dist/tools/claude/SendMessage.d.ts +10 -0
- package/dist/tools/claude/SendMessage.d.ts.map +1 -0
- package/dist/tools/claude/SendMessage.js +33 -0
- package/dist/tools/claude/TaskCreate.d.ts +12 -0
- package/dist/tools/claude/TaskCreate.d.ts.map +1 -0
- package/dist/tools/claude/TaskCreate.js +34 -0
- package/dist/tools/claude/TaskGet.d.ts +16 -0
- package/dist/tools/claude/TaskGet.d.ts.map +1 -0
- package/dist/tools/claude/TaskGet.js +44 -0
- package/dist/tools/claude/TaskList.d.ts +10 -0
- package/dist/tools/claude/TaskList.d.ts.map +1 -0
- package/dist/tools/claude/TaskList.js +51 -0
- package/dist/tools/claude/TaskOutput.d.ts +17 -0
- package/dist/tools/claude/TaskOutput.d.ts.map +1 -0
- package/dist/tools/claude/TaskOutput.js +74 -0
- package/dist/tools/claude/TaskStop.d.ts +10 -0
- package/dist/tools/claude/TaskStop.d.ts.map +1 -0
- package/dist/tools/claude/TaskStop.js +42 -0
- package/dist/tools/claude/TaskUpdate.d.ts +21 -0
- package/dist/tools/claude/TaskUpdate.d.ts.map +1 -0
- package/dist/tools/claude/TaskUpdate.js +55 -0
- package/dist/tools/claude/index.d.ts +111 -5
- package/dist/tools/claude/index.d.ts.map +1 -1
- package/dist/tools/claude/index.js +24 -2
- package/dist/tools/claude/parseBackgroundTaskId.d.ts +2 -0
- package/dist/tools/claude/parseBackgroundTaskId.d.ts.map +1 -0
- package/dist/tools/claude/parseBackgroundTaskId.js +7 -0
- package/dist/tools/claude/taskSchemas.d.ts +14 -0
- package/dist/tools/claude/taskSchemas.d.ts.map +1 -0
- package/dist/tools/claude/taskSchemas.js +18 -0
- package/dist/tools/codex/exec_command.d.ts +8 -6
- package/dist/tools/codex/exec_command.d.ts.map +1 -1
- package/dist/tools/codex/exec_command.js +37 -18
- package/dist/tools/codex/followup_task.d.ts +11 -0
- package/dist/tools/codex/followup_task.d.ts.map +1 -0
- package/dist/tools/codex/followup_task.js +18 -0
- package/dist/tools/codex/humanizeTaskName.d.ts +2 -0
- package/dist/tools/codex/humanizeTaskName.d.ts.map +1 -0
- package/dist/tools/codex/humanizeTaskName.js +4 -0
- package/dist/tools/codex/index.d.ts +90 -7
- package/dist/tools/codex/index.d.ts.map +1 -1
- package/dist/tools/codex/index.js +24 -0
- package/dist/tools/codex/interrupt_agent.d.ts +10 -0
- package/dist/tools/codex/interrupt_agent.d.ts.map +1 -0
- package/dist/tools/codex/interrupt_agent.js +17 -0
- package/dist/tools/codex/list_agents.d.ts +12 -0
- package/dist/tools/codex/list_agents.d.ts.map +1 -0
- package/dist/tools/codex/list_agents.js +23 -0
- package/dist/tools/codex/request_user_input.d.ts +16 -0
- package/dist/tools/codex/request_user_input.d.ts.map +1 -0
- package/dist/tools/codex/request_user_input.js +58 -0
- package/dist/tools/codex/requireSubagentContext.d.ts +3 -0
- package/dist/tools/codex/requireSubagentContext.d.ts.map +1 -0
- package/dist/tools/codex/requireSubagentContext.js +6 -0
- package/dist/tools/codex/spawn_agent.d.ts +9 -0
- package/dist/tools/codex/spawn_agent.d.ts.map +1 -0
- package/dist/tools/codex/spawn_agent.js +35 -0
- package/dist/tools/codex/subagentSchemas.d.ts +8 -0
- package/dist/tools/codex/subagentSchemas.d.ts.map +1 -0
- package/dist/tools/codex/subagentSchemas.js +13 -0
- package/dist/tools/codex/unifiedExecOutput.d.ts +14 -0
- package/dist/tools/codex/unifiedExecOutput.d.ts.map +1 -0
- package/dist/tools/codex/unifiedExecOutput.js +44 -0
- package/dist/tools/codex/update_plan.d.ts +10 -0
- package/dist/tools/codex/update_plan.d.ts.map +1 -0
- package/dist/tools/codex/update_plan.js +34 -0
- package/dist/tools/codex/wait_agent.d.ts +13 -0
- package/dist/tools/codex/wait_agent.d.ts.map +1 -0
- package/dist/tools/codex/wait_agent.js +32 -0
- package/dist/tools/codex/write_stdin.d.ts +6 -1
- package/dist/tools/codex/write_stdin.d.ts.map +1 -1
- package/dist/tools/codex/write_stdin.js +44 -12
- package/dist/tools/goals/create_goal.d.ts +11 -0
- package/dist/tools/goals/create_goal.d.ts.map +1 -0
- package/dist/tools/goals/create_goal.js +29 -0
- package/dist/tools/goals/get_goal.d.ts +9 -0
- package/dist/tools/goals/get_goal.d.ts.map +1 -0
- package/dist/tools/goals/get_goal.js +26 -0
- package/dist/tools/goals/goalSchemas.d.ts +8 -0
- package/dist/tools/goals/goalSchemas.d.ts.map +1 -0
- package/dist/tools/goals/goalSchemas.js +13 -0
- package/dist/tools/goals/index.d.ts +30 -0
- package/dist/tools/goals/index.d.ts.map +1 -0
- package/dist/tools/goals/index.js +7 -0
- package/dist/tools/goals/update_goal.d.ts +11 -0
- package/dist/tools/goals/update_goal.d.ts.map +1 -0
- package/dist/tools/goals/update_goal.js +33 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/pi/bash.d.ts.map +1 -1
- package/dist/tools/pi/bash.js +2 -0
- package/dist/tools/utils/readSessionWithProgress.d.ts +9 -0
- package/dist/tools/utils/readSessionWithProgress.d.ts.map +1 -0
- package/dist/tools/utils/readSessionWithProgress.js +27 -0
- package/dist/tools/utils/shell.d.ts +2 -0
- package/dist/tools/utils/shell.d.ts.map +1 -1
- package/dist/tools/utils/shell.js +37 -0
- package/dist/tools/utils/summarizeShellOutput.d.ts.map +1 -1
- package/dist/tools/utils/summarizeShellOutput.js +2 -0
- package/dist/user-input/index.d.ts +2 -0
- package/dist/user-input/index.d.ts.map +1 -0
- package/dist/user-input/index.js +1 -0
- package/dist/user-input/types.d.ts +19 -0
- package/dist/user-input/types.d.ts.map +1 -0
- package/dist/user-input/types.js +1 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-BuJOCQJD.js +1 -0
- package/dist/web/assets/highlighted-body-OFNGDK62-TwhCqUaJ.js +1 -0
- package/dist/web/assets/index-B6Bc6sUJ.css +1 -0
- package/dist/web/assets/index-BC99-iZC.js +341 -0
- package/dist/web/assets/index-BZN9jSiw.js +341 -0
- package/dist/web/assets/index-CcF0unjO.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -25,9 +25,16 @@ rig stays close to pi and to upstream vendor behavior, but adds a curated defaul
|
|
|
25
25
|
- Simplified system prompts that are easier to reason about and reuse.
|
|
26
26
|
- Per-model and per-vendor prompt/tool optimizations, so different inference providers can work well without forcing users into one stack.
|
|
27
27
|
- Bundled subagents for common coding workflows.
|
|
28
|
-
-
|
|
28
|
+
- Provider-aligned task planning with Codex `update_plan` and Claude's persistent task tools.
|
|
29
|
+
- Structured user questions with provider-aligned tools and terminal or web answer controls.
|
|
30
|
+
- MCP tool servers over stdio or streamable HTTP, with Codex- and Claude-compatible configuration.
|
|
31
|
+
- Background subagents with completion notifications and follow-up turns.
|
|
32
|
+
- Managed shell sessions for long-running commands and interactive input.
|
|
29
33
|
- Workflow presets for repeated engineering operations.
|
|
30
34
|
- Auto mode for hands-off execution when a project allows it.
|
|
35
|
+
- Persistent goals that continue across agent turns until they are completed, paused, or blocked.
|
|
36
|
+
- Findings-first local code review with `/review` for current workspace changes.
|
|
37
|
+
- Automatic conversation compaction for long sessions, plus `/compact` when you want to free context space immediately.
|
|
31
38
|
- Sandboxing defaults that make local execution practical while keeping controls visible.
|
|
32
39
|
- Per-project enable/disable behavior, so teams can use rig where it helps and leave other repos untouched.
|
|
33
40
|
|
|
@@ -35,12 +42,23 @@ rig stays close to pi and to upstream vendor behavior, but adds a curated defaul
|
|
|
35
42
|
|
|
36
43
|
rig is intentionally opinionated, but not locked down:
|
|
37
44
|
|
|
45
|
+
- Best of both worlds. Combine the strongest ideas from Codex and Claude Code into one coherent experience instead of cloning either product wholesale.
|
|
38
46
|
- Good defaults first. A fresh install should already feel usable.
|
|
47
|
+
- Simplicity and polish. Prefer clear, pleasant workflows over obscure features, exhaustive parity, or unnecessary configuration.
|
|
39
48
|
- Provider flexibility. The harness should work across proprietary and open source models.
|
|
40
49
|
- Project-local control. Repos should be able to enable, disable, or override behavior without changing global machine state.
|
|
41
50
|
- Close to upstream. Tool definitions and model expectations should track vendor semantics closely.
|
|
42
51
|
- Less ceremony. Common agent features should not require a custom setup ritual on every machine.
|
|
43
52
|
|
|
53
|
+
## Deliberate non-goals
|
|
54
|
+
|
|
55
|
+
rig aims for the best mainstream coding-agent experience, not a union of every
|
|
56
|
+
feature exposed by Codex and Claude Code. It intentionally does not implement:
|
|
57
|
+
|
|
58
|
+
- A dedicated Plan mode. Planning remains part of the normal agent workflow instead of a separate permission mode or interaction state.
|
|
59
|
+
- Vim or other modal terminal editing modes. The terminal input experience stays simple and conventional.
|
|
60
|
+
- Niche parity features whose main value is matching a rarely used upstream flag, command, protocol, or edge case. New parity work should solve a common user need and fit rig's simpler product model.
|
|
61
|
+
|
|
44
62
|
## Intended experience
|
|
45
63
|
|
|
46
64
|
Install rig once, open a project, and get a capable coding harness with prompts, tools, subagents, workflows, workers, automation, and sandboxing already wired together.
|
|
@@ -51,6 +69,11 @@ When a project needs different behavior, configure it locally. When a machine ch
|
|
|
51
69
|
|
|
52
70
|
This is a single-package TypeScript project. Source files live in `sources/`, with `sources/main.ts` as the CLI entry point.
|
|
53
71
|
|
|
72
|
+
Reference implementations for coding agents live in
|
|
73
|
+
`~/Developer/coding-assistant-sources`, including the Codex and Claude Code
|
|
74
|
+
source trees. Use them when implementing or comparing provider-aligned behavior,
|
|
75
|
+
then adapt the useful parts to rig's simpler, curated experience.
|
|
76
|
+
|
|
54
77
|
```sh
|
|
55
78
|
pnpm install
|
|
56
79
|
pnpm run check
|
|
@@ -108,6 +131,126 @@ pnpm dev:web
|
|
|
108
131
|
Open the Vite URL printed by `pnpm dev:web`, usually `http://127.0.0.1:5173`.
|
|
109
132
|
The Vite dev server proxies `/api/*` to the local daemon socket.
|
|
110
133
|
|
|
134
|
+
### Permission modes
|
|
135
|
+
|
|
136
|
+
New sessions start in **Workspace write** mode. File tools can edit the working
|
|
137
|
+
directory, while shell writes outside it and shell network access are blocked.
|
|
138
|
+
Git metadata and temporary files remain writable so normal development commands
|
|
139
|
+
continue to work.
|
|
140
|
+
|
|
141
|
+
Use `/permissions` in the terminal or the Permissions control in the web
|
|
142
|
+
inspector to switch the current session and its subagents between:
|
|
143
|
+
|
|
144
|
+
- **Auto** — run routine workspace work immediately and review risky actions automatically, asking only when needed.
|
|
145
|
+
- **Workspace write** — write in the working directory with shell network access blocked.
|
|
146
|
+
- **Read only** — keep project files read only; shell commands may write temporary files.
|
|
147
|
+
- **Full access** — allow unrestricted filesystem, shell, and network access.
|
|
148
|
+
|
|
149
|
+
In Auto mode, shell commands remain workspace-sandboxed by default. Codex
|
|
150
|
+
`exec_command` can request `sandbox_permissions = "require_escalated"`, and
|
|
151
|
+
Claude `Bash` can request `dangerouslyDisableSandbox = true`; both requests are
|
|
152
|
+
reviewed before receiving one-call full access.
|
|
153
|
+
|
|
154
|
+
Set the terminal default in global or project-local `rig.toml`:
|
|
155
|
+
|
|
156
|
+
```toml
|
|
157
|
+
[defaults]
|
|
158
|
+
permission_mode = "workspace_write"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`RIG_PERMISSION_MODE` overrides the configured default for a newly created
|
|
162
|
+
terminal session. Accepted values are `workspace_write`, `read_only`, and
|
|
163
|
+
`full_access`, and `auto`.
|
|
164
|
+
|
|
165
|
+
### Persistent goals
|
|
166
|
+
|
|
167
|
+
Use `/goal` followed by an objective to start long-running work that may need
|
|
168
|
+
more than one agent turn. Rig keeps the objective on the session and
|
|
169
|
+
automatically continues while the goal remains active. Use `/goal` by itself to
|
|
170
|
+
check its status, `/goal pause` to stop automatic continuation, `/goal resume`
|
|
171
|
+
to continue, and `/goal clear` to remove it.
|
|
172
|
+
|
|
173
|
+
Models receive `get_goal`, `create_goal`, and `update_goal` tools. A model can
|
|
174
|
+
mark the goal complete after verifying the full objective, or blocked when it
|
|
175
|
+
cannot make meaningful progress without user input or an external change.
|
|
176
|
+
Goals survive daemon restarts and are available from both the terminal and web
|
|
177
|
+
session inspector.
|
|
178
|
+
|
|
179
|
+
### Code review
|
|
180
|
+
|
|
181
|
+
Use `/review` to inspect current staged, unstaged, and untracked changes without
|
|
182
|
+
modifying them. Add a focus after the command when useful, such as
|
|
183
|
+
`/review focus on concurrency`. Reviews lead with actionable findings ordered
|
|
184
|
+
by severity and include file references, concrete impact, and remaining test
|
|
185
|
+
gaps. The command works in terminal and web-backed sessions.
|
|
186
|
+
|
|
187
|
+
### Task tracking
|
|
188
|
+
|
|
189
|
+
Claude sessions use the current `TaskCreate`, `TaskGet`, `TaskUpdate`, and
|
|
190
|
+
`TaskList` tools. Tasks, dependencies, and progress survive daemon restarts and
|
|
191
|
+
are shared with the session's subagents. Use `/tasks` in the terminal or the
|
|
192
|
+
Tasks section in the web inspector to see the current list.
|
|
193
|
+
|
|
194
|
+
### Background subagents
|
|
195
|
+
|
|
196
|
+
Claude sessions can set `run_in_background` on the `Agent` tool and use
|
|
197
|
+
`SendMessage` for follow-up work. Codex sessions use `spawn_agent`,
|
|
198
|
+
`followup_task`, `wait_agent`, `list_agents`, and
|
|
199
|
+
`interrupt_agent`. Each child keeps its own persisted conversation, reports a
|
|
200
|
+
completion notification to its parent, and can receive more work without losing
|
|
201
|
+
context. Use `/agents` in the terminal or Delegated work in the web inspector to
|
|
202
|
+
see current status and open a child transcript.
|
|
203
|
+
|
|
204
|
+
Team/swarm coordination, remote agents, and automatic worktree isolation are
|
|
205
|
+
intentionally outside this core workflow.
|
|
206
|
+
|
|
207
|
+
### Long-running commands
|
|
208
|
+
|
|
209
|
+
Codex `exec_command` now yields a live session when a command outlasts its wait
|
|
210
|
+
window; `write_stdin` can poll it, send input, or interrupt it. Claude `Bash`
|
|
211
|
+
honors `run_in_background`, with `TaskOutput` for later results and `TaskStop`
|
|
212
|
+
for cancellation. These commands retain the session's permission and sandbox
|
|
213
|
+
mode instead of escaping into an unmanaged process.
|
|
214
|
+
|
|
215
|
+
### MCP tool servers
|
|
216
|
+
|
|
217
|
+
Rig discovers tools from MCP servers when a workspace first runs. Codex-style
|
|
218
|
+
servers can be configured globally in `~/.config/rig/config.toml` or locally in
|
|
219
|
+
`rig.toml`:
|
|
220
|
+
|
|
221
|
+
```toml
|
|
222
|
+
[mcp_servers.docs]
|
|
223
|
+
command = "docs-mcp-server"
|
|
224
|
+
args = ["--stdio"]
|
|
225
|
+
tool_timeout_sec = 30
|
|
226
|
+
|
|
227
|
+
[mcp_servers.issues]
|
|
228
|
+
url = "https://example.com/mcp"
|
|
229
|
+
bearer_token_env_var = "ISSUES_MCP_TOKEN"
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Claude-style project configuration is also supported in `.mcp.json`:
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"mcpServers": {
|
|
237
|
+
"docs": {
|
|
238
|
+
"type": "stdio",
|
|
239
|
+
"command": "docs-mcp-server",
|
|
240
|
+
"args": ["--stdio"]
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Use `/mcp` in the terminal or the MCP servers section in the web inspector to
|
|
247
|
+
check connection failures and discovered tool counts. Restart the daemon after
|
|
248
|
+
changing MCP configuration. OAuth, legacy SSE transports, MCP prompts, and MCP
|
|
249
|
+
resources are not yet supported.
|
|
250
|
+
|
|
251
|
+
Only configure servers you trust. Stdio servers are local processes that receive
|
|
252
|
+
the daemon environment and are not restricted by the session filesystem sandbox.
|
|
253
|
+
|
|
111
254
|
## Publishing
|
|
112
255
|
|
|
113
256
|
Authenticate with npm once using `pnpm login`, then publish from a clean, up-to-date
|
package/dist/agent/Agent.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type AgentLoopEvent, type AgentLoopResult } from "./loop.js";
|
|
|
3
3
|
import { type AgentConsole } from "./printAgentMessageToConsole.js";
|
|
4
4
|
import type { AnyDefinedTool, ContentBlock, Message, SystemMessage, UserMessage } from "./types.js";
|
|
5
5
|
import type { Model, Provider } from "../providers/types.js";
|
|
6
|
+
import type { PermissionMode } from "../permissions/index.js";
|
|
6
7
|
export type AgentStatus = "idle" | "running" | "aborted";
|
|
7
8
|
export interface QueuedAgentMessage {
|
|
8
9
|
id: string;
|
|
@@ -16,6 +17,8 @@ export interface AgentSnapshot {
|
|
|
16
17
|
status: AgentStatus;
|
|
17
18
|
instructions?: string;
|
|
18
19
|
messages: readonly Message[];
|
|
20
|
+
/** Compacted model-facing history. Omitted while it matches the visible transcript. */
|
|
21
|
+
contextMessages?: readonly Message[];
|
|
19
22
|
queue: readonly QueuedAgentMessage[];
|
|
20
23
|
tools: readonly string[];
|
|
21
24
|
lastRunId?: string;
|
|
@@ -27,6 +30,7 @@ export interface AgentOptions {
|
|
|
27
30
|
id?: string;
|
|
28
31
|
effort?: string;
|
|
29
32
|
messages?: readonly Message[];
|
|
33
|
+
contextMessages?: readonly Message[];
|
|
30
34
|
instructions?: string;
|
|
31
35
|
tools?: readonly AnyDefinedTool[];
|
|
32
36
|
idFactory?: () => string;
|
|
@@ -45,6 +49,13 @@ export interface AgentRunOptions {
|
|
|
45
49
|
export interface AgentRunResult extends AgentLoopResult {
|
|
46
50
|
runId: string;
|
|
47
51
|
}
|
|
52
|
+
export interface AgentCompactionResult {
|
|
53
|
+
compacted: boolean;
|
|
54
|
+
compactedMessageCount: number;
|
|
55
|
+
estimatedTokensAfter: number;
|
|
56
|
+
estimatedTokensBefore: number;
|
|
57
|
+
retainedMessageCount: number;
|
|
58
|
+
}
|
|
48
59
|
export declare class Agent {
|
|
49
60
|
#private;
|
|
50
61
|
readonly id: string;
|
|
@@ -56,17 +67,22 @@ export declare class Agent {
|
|
|
56
67
|
get messages(): readonly Message[];
|
|
57
68
|
get queue(): readonly QueuedAgentMessage[];
|
|
58
69
|
get tools(): readonly AnyDefinedTool[];
|
|
70
|
+
get permissionMode(): PermissionMode;
|
|
59
71
|
get canChangeModel(): boolean;
|
|
60
72
|
setInstructions(instructions: string | undefined): void;
|
|
61
73
|
setEffort(effort: string | undefined): void;
|
|
62
74
|
setModel(modelId: string, effort: string | undefined): void;
|
|
63
75
|
setTools(tools: readonly AnyDefinedTool[]): void;
|
|
76
|
+
setPermissionMode(mode: PermissionMode): void;
|
|
64
77
|
reset(): void;
|
|
65
78
|
addSteering(text: string): SystemMessage;
|
|
66
79
|
enqueueSystemMessage(text: string): SystemMessage;
|
|
67
80
|
enqueueUserMessage(text: string | readonly ContentBlock[]): UserMessage;
|
|
68
81
|
enqueueMessage(message: Message): QueuedAgentMessage;
|
|
69
82
|
send(text: string | readonly ContentBlock[], options?: AgentRunOptions): Promise<AgentRunResult>;
|
|
83
|
+
steer(content: string | readonly ContentBlock[]): Promise<void>;
|
|
84
|
+
steerMessage(message: UserMessage): void;
|
|
85
|
+
compact(signal?: AbortSignal): Promise<AgentCompactionResult>;
|
|
70
86
|
run(options?: AgentRunOptions): Promise<AgentRunResult>;
|
|
71
87
|
snapshot(): AgentSnapshot;
|
|
72
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../sources/agent/Agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../sources/agent/Agent.ts"],"names":[],"mappings":"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"}
|
package/dist/agent/Agent.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createId } from "@paralleldrive/cuid2";
|
|
2
|
+
import { compactConversation } from "./compaction/compactConversation.js";
|
|
2
3
|
import { runAgentLoop } from "./loop.js";
|
|
3
4
|
import { printAgentMessageToConsole } from "./printAgentMessageToConsole.js";
|
|
4
5
|
import { selectToolsForModel } from "./selectToolsForModel.js";
|
|
@@ -18,7 +19,9 @@ export class Agent {
|
|
|
18
19
|
#onEvent;
|
|
19
20
|
#onMessage;
|
|
20
21
|
#messages = [];
|
|
22
|
+
#contextMessages;
|
|
21
23
|
#queue = [];
|
|
24
|
+
#steeringQueue = [];
|
|
22
25
|
#status = "idle";
|
|
23
26
|
#lastRunId;
|
|
24
27
|
#activeRunId;
|
|
@@ -44,6 +47,8 @@ export class Agent {
|
|
|
44
47
|
this.#onEvent = options.onEvent;
|
|
45
48
|
this.#onMessage = options.onMessage;
|
|
46
49
|
this.#messages = [...(options.messages ?? [])];
|
|
50
|
+
this.#contextMessages =
|
|
51
|
+
options.contextMessages === undefined ? undefined : [...options.contextMessages];
|
|
47
52
|
}
|
|
48
53
|
get status() {
|
|
49
54
|
return this.#status;
|
|
@@ -60,6 +65,9 @@ export class Agent {
|
|
|
60
65
|
get tools() {
|
|
61
66
|
return this.#tools;
|
|
62
67
|
}
|
|
68
|
+
get permissionMode() {
|
|
69
|
+
return this.context.permissions?.mode ?? "full_access";
|
|
70
|
+
}
|
|
63
71
|
get canChangeModel() {
|
|
64
72
|
return (this.#messages.length === 0 &&
|
|
65
73
|
this.#queue.length === 0 &&
|
|
@@ -82,12 +90,24 @@ export class Agent {
|
|
|
82
90
|
});
|
|
83
91
|
}
|
|
84
92
|
}
|
|
93
|
+
#takeSteering() {
|
|
94
|
+
const steering = this.#steeringQueue;
|
|
95
|
+
this.#steeringQueue = [];
|
|
96
|
+
for (const message of steering)
|
|
97
|
+
this.#printMessage(message);
|
|
98
|
+
return steering;
|
|
99
|
+
}
|
|
85
100
|
setTools(tools) {
|
|
86
101
|
this.#tools = tools;
|
|
87
102
|
}
|
|
103
|
+
setPermissionMode(mode) {
|
|
104
|
+
this.context.permissions?.setMode(mode);
|
|
105
|
+
}
|
|
88
106
|
reset() {
|
|
89
107
|
this.#messages = [];
|
|
108
|
+
this.#contextMessages = undefined;
|
|
90
109
|
this.#queue = [];
|
|
110
|
+
this.#steeringQueue = [];
|
|
91
111
|
this.#lastRunId = undefined;
|
|
92
112
|
this.#resetVersion += 1;
|
|
93
113
|
if (this.#activeRunId === undefined) {
|
|
@@ -130,6 +150,42 @@ export class Agent {
|
|
|
130
150
|
this.enqueueUserMessage(text);
|
|
131
151
|
return this.run(options);
|
|
132
152
|
}
|
|
153
|
+
async steer(content) {
|
|
154
|
+
this.steerMessage({
|
|
155
|
+
role: "user",
|
|
156
|
+
id: this.#idFactory(),
|
|
157
|
+
blocks: typeof content === "string" ? [{ type: "text", text: content }] : content,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
steerMessage(message) {
|
|
161
|
+
if (this.#activeRunId === undefined) {
|
|
162
|
+
throw new Error(`Agent '${this.id}' is not running`);
|
|
163
|
+
}
|
|
164
|
+
this.#steeringQueue.push(message);
|
|
165
|
+
}
|
|
166
|
+
async compact(signal) {
|
|
167
|
+
if (this.#activeRunId !== undefined) {
|
|
168
|
+
throw new Error("Wait for the active response to finish before compacting.");
|
|
169
|
+
}
|
|
170
|
+
const runId = this.#idFactory();
|
|
171
|
+
this.#activeRunId = runId;
|
|
172
|
+
this.#status = "running";
|
|
173
|
+
try {
|
|
174
|
+
const result = await this.#compactContext({
|
|
175
|
+
force: true,
|
|
176
|
+
preserveLatestUserMessage: false,
|
|
177
|
+
...(signal !== undefined ? { signal } : {}),
|
|
178
|
+
});
|
|
179
|
+
this.#status = "idle";
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
if (this.#activeRunId === runId)
|
|
184
|
+
this.#activeRunId = undefined;
|
|
185
|
+
if (this.#status === "running")
|
|
186
|
+
this.#status = signal?.aborted ? "aborted" : "idle";
|
|
187
|
+
}
|
|
188
|
+
}
|
|
133
189
|
async run(options = {}) {
|
|
134
190
|
if (this.#activeRunId !== undefined) {
|
|
135
191
|
throw new Error(`Agent '${this.id}' is already running`);
|
|
@@ -141,6 +197,20 @@ export class Agent {
|
|
|
141
197
|
this.#status = "running";
|
|
142
198
|
this.#drainQueueToTranscript();
|
|
143
199
|
try {
|
|
200
|
+
try {
|
|
201
|
+
await this.#compactContext({
|
|
202
|
+
force: false,
|
|
203
|
+
preserveLatestUserMessage: true,
|
|
204
|
+
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
// The main loop still gets a chance to report an abort or the provider's
|
|
209
|
+
// context-limit error when automatic compaction is unavailable.
|
|
210
|
+
if (!options.signal?.aborted) {
|
|
211
|
+
this.#console.error?.(`[agent:${this.id}] automatic compaction failed`, error);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
144
214
|
const loopOptions = {
|
|
145
215
|
provider: this.provider,
|
|
146
216
|
modelId: this.#model.id,
|
|
@@ -152,7 +222,11 @@ export class Agent {
|
|
|
152
222
|
context: this.context,
|
|
153
223
|
onEvent: async (event) => this.#handleEvent(event, options),
|
|
154
224
|
onMessage: async (message) => this.#handleMessage(message, options),
|
|
225
|
+
takeSteering: () => this.#takeSteering(),
|
|
155
226
|
};
|
|
227
|
+
if (this.#contextMessages !== undefined) {
|
|
228
|
+
loopOptions.contextMessages = this.#contextMessages;
|
|
229
|
+
}
|
|
156
230
|
if (this.#effort !== undefined)
|
|
157
231
|
loopOptions.effort = this.#effort;
|
|
158
232
|
if (this.#instructions !== undefined)
|
|
@@ -163,8 +237,12 @@ export class Agent {
|
|
|
163
237
|
if (this.#activeRunId === runId) {
|
|
164
238
|
this.#activeRunId = undefined;
|
|
165
239
|
}
|
|
240
|
+
this.#steeringQueue = [];
|
|
166
241
|
if (this.#resetVersion === resetVersion) {
|
|
167
242
|
this.#messages = [...result.messages];
|
|
243
|
+
if (this.#contextMessages !== undefined) {
|
|
244
|
+
this.#contextMessages = [...result.contextMessages];
|
|
245
|
+
}
|
|
168
246
|
this.#status = result.stopReason === "aborted" ? "aborted" : "idle";
|
|
169
247
|
}
|
|
170
248
|
else if (this.#status === "running") {
|
|
@@ -179,6 +257,7 @@ export class Agent {
|
|
|
179
257
|
if (this.#activeRunId === runId) {
|
|
180
258
|
this.#activeRunId = undefined;
|
|
181
259
|
}
|
|
260
|
+
this.#steeringQueue = [];
|
|
182
261
|
if (this.#resetVersion === resetVersion) {
|
|
183
262
|
this.#status = options.signal?.aborted ? "aborted" : "idle";
|
|
184
263
|
}
|
|
@@ -198,6 +277,9 @@ export class Agent {
|
|
|
198
277
|
queue: [...this.#queue],
|
|
199
278
|
tools: this.#tools.map((tool) => tool.name),
|
|
200
279
|
...(this.#effort !== undefined ? { effort: this.#effort } : {}),
|
|
280
|
+
...(this.#contextMessages !== undefined
|
|
281
|
+
? { contextMessages: [...this.#contextMessages] }
|
|
282
|
+
: {}),
|
|
201
283
|
...(this.#instructions !== undefined ? { instructions: this.#instructions } : {}),
|
|
202
284
|
...(this.#lastRunId !== undefined ? { lastRunId: this.#lastRunId } : {}),
|
|
203
285
|
};
|
|
@@ -217,9 +299,33 @@ export class Agent {
|
|
|
217
299
|
this.#queue = [];
|
|
218
300
|
for (const entry of queued) {
|
|
219
301
|
this.#messages.push(entry.message);
|
|
302
|
+
this.#contextMessages?.push(entry.message);
|
|
220
303
|
this.#printMessage(entry.message);
|
|
221
304
|
}
|
|
222
305
|
}
|
|
306
|
+
async #compactContext(options) {
|
|
307
|
+
const result = await compactConversation({
|
|
308
|
+
provider: this.provider,
|
|
309
|
+
model: this.#model,
|
|
310
|
+
messages: this.#contextMessages ?? this.#messages,
|
|
311
|
+
idFactory: this.#idFactory,
|
|
312
|
+
now: this.#now,
|
|
313
|
+
force: options.force,
|
|
314
|
+
preserveLatestUserMessage: options.preserveLatestUserMessage,
|
|
315
|
+
...(this.#effort !== undefined ? { effort: this.#effort } : {}),
|
|
316
|
+
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
317
|
+
});
|
|
318
|
+
if (result.compacted) {
|
|
319
|
+
this.#contextMessages = [...result.contextMessages];
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
compacted: result.compacted,
|
|
323
|
+
compactedMessageCount: result.compactedMessageCount,
|
|
324
|
+
estimatedTokensAfter: result.estimatedTokensAfter,
|
|
325
|
+
estimatedTokensBefore: result.estimatedTokensBefore,
|
|
326
|
+
retainedMessageCount: result.retainedMessageCount,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
223
329
|
#printMessage(message) {
|
|
224
330
|
if (!this.#printToConsole) {
|
|
225
331
|
return;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Message } from "../types.js";
|
|
2
|
+
import type { Model, Provider } from "../../providers/types.js";
|
|
3
|
+
export interface CompactConversationResult {
|
|
4
|
+
compacted: boolean;
|
|
5
|
+
compactedMessageCount: number;
|
|
6
|
+
contextMessages: readonly Message[];
|
|
7
|
+
estimatedTokensAfter: number;
|
|
8
|
+
estimatedTokensBefore: number;
|
|
9
|
+
retainedMessageCount: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function compactConversation(options: {
|
|
12
|
+
provider: Provider;
|
|
13
|
+
model: Model;
|
|
14
|
+
messages: readonly Message[];
|
|
15
|
+
idFactory: () => string;
|
|
16
|
+
now: () => number;
|
|
17
|
+
effort?: string;
|
|
18
|
+
force: boolean;
|
|
19
|
+
preserveLatestUserMessage: boolean;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
}): Promise<CompactConversationResult>;
|
|
22
|
+
//# sourceMappingURL=compactConversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compactConversation.d.ts","sourceRoot":"","sources":["../../../sources/agent/compaction/compactConversation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMhE,MAAM,WAAW,yBAAyB;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE,SAAS,OAAO,EAAE,CAAC;IACpC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;CAChC;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IAC/C,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7B,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,yBAAyB,EAAE,OAAO,CAAC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAkDrC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { estimateMessagesTokens } from "./estimateMessagesTokens.js";
|
|
2
|
+
import { requestCompactionSummary } from "./requestCompactionSummary.js";
|
|
3
|
+
const DEFAULT_CONTEXT_WINDOW = 200_000;
|
|
4
|
+
const AUTO_COMPACT_FRACTION = 0.85;
|
|
5
|
+
const RETAINED_CONTEXT_FRACTION = 0.1;
|
|
6
|
+
export async function compactConversation(options) {
|
|
7
|
+
const estimatedTokensBefore = estimateMessagesTokens(options.messages);
|
|
8
|
+
const contextWindow = options.model.contextWindow ?? DEFAULT_CONTEXT_WINDOW;
|
|
9
|
+
if (!options.force && estimatedTokensBefore < contextWindow * AUTO_COMPACT_FRACTION) {
|
|
10
|
+
return unchanged(options.messages, estimatedTokensBefore);
|
|
11
|
+
}
|
|
12
|
+
const systemMessages = options.messages.filter((message) => message.role === "system");
|
|
13
|
+
const conversation = options.messages.filter((message) => message.role !== "system");
|
|
14
|
+
const keepStart = options.preserveLatestUserMessage
|
|
15
|
+
? findRetainedStart(conversation, contextWindow)
|
|
16
|
+
: conversation.length;
|
|
17
|
+
const messagesToCompact = conversation.slice(0, keepStart);
|
|
18
|
+
const retainedMessages = conversation.slice(keepStart);
|
|
19
|
+
if (messagesToCompact.length < 2 ||
|
|
20
|
+
!messagesToCompact.some((message) => message.role === "agent")) {
|
|
21
|
+
return unchanged(options.messages, estimatedTokensBefore);
|
|
22
|
+
}
|
|
23
|
+
const summary = await requestCompactionSummary({
|
|
24
|
+
provider: options.provider,
|
|
25
|
+
model: options.model,
|
|
26
|
+
messages: messagesToCompact,
|
|
27
|
+
now: options.now,
|
|
28
|
+
...(options.effort !== undefined ? { effort: options.effort } : {}),
|
|
29
|
+
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
30
|
+
});
|
|
31
|
+
const summaryMessage = {
|
|
32
|
+
role: "user",
|
|
33
|
+
id: options.idFactory(),
|
|
34
|
+
blocks: [
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: `<conversation_summary>\n${summary}\n</conversation_summary>`,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
const contextMessages = [...systemMessages, summaryMessage, ...retainedMessages];
|
|
42
|
+
return {
|
|
43
|
+
compacted: true,
|
|
44
|
+
compactedMessageCount: messagesToCompact.length,
|
|
45
|
+
contextMessages,
|
|
46
|
+
estimatedTokensAfter: estimateMessagesTokens(contextMessages),
|
|
47
|
+
estimatedTokensBefore,
|
|
48
|
+
retainedMessageCount: retainedMessages.length,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function findRetainedStart(messages, contextWindow) {
|
|
52
|
+
const userIndexes = messages.flatMap((message, index) => message.role === "user" ? [index] : []);
|
|
53
|
+
const latestUserIndex = userIndexes.at(-1);
|
|
54
|
+
if (latestUserIndex === undefined)
|
|
55
|
+
return messages.length;
|
|
56
|
+
const retainedTokenTarget = Math.max(32, Math.floor(contextWindow * RETAINED_CONTEXT_FRACTION));
|
|
57
|
+
let keepStart = latestUserIndex;
|
|
58
|
+
for (let index = userIndexes.length - 2; index >= 0; index -= 1) {
|
|
59
|
+
const candidate = userIndexes[index];
|
|
60
|
+
if (candidate === undefined)
|
|
61
|
+
continue;
|
|
62
|
+
if (estimateMessagesTokens(messages.slice(candidate)) > retainedTokenTarget)
|
|
63
|
+
break;
|
|
64
|
+
keepStart = candidate;
|
|
65
|
+
}
|
|
66
|
+
return keepStart;
|
|
67
|
+
}
|
|
68
|
+
function unchanged(messages, estimatedTokens) {
|
|
69
|
+
return {
|
|
70
|
+
compacted: false,
|
|
71
|
+
compactedMessageCount: 0,
|
|
72
|
+
contextMessages: messages,
|
|
73
|
+
estimatedTokensAfter: estimatedTokens,
|
|
74
|
+
estimatedTokensBefore: estimatedTokens,
|
|
75
|
+
retainedMessageCount: messages.length,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimateMessagesTokens.d.ts","sourceRoot":"","sources":["../../../sources/agent/compaction/estimateMessagesTokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CA8B3E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const IMAGE_TOKEN_ESTIMATE = 1_600;
|
|
2
|
+
const MESSAGE_OVERHEAD_TOKENS = 8;
|
|
3
|
+
export function estimateMessagesTokens(messages) {
|
|
4
|
+
let characters = 0;
|
|
5
|
+
let fixedTokens = messages.length * MESSAGE_OVERHEAD_TOKENS;
|
|
6
|
+
for (const message of messages) {
|
|
7
|
+
for (const block of message.blocks) {
|
|
8
|
+
if (block.type === "image") {
|
|
9
|
+
fixedTokens += IMAGE_TOKEN_ESTIMATE;
|
|
10
|
+
}
|
|
11
|
+
else if (block.type === "text") {
|
|
12
|
+
characters += block.text.length;
|
|
13
|
+
}
|
|
14
|
+
else if (block.type === "thinking") {
|
|
15
|
+
characters += block.thinking.length;
|
|
16
|
+
}
|
|
17
|
+
else if (block.type === "tool_call") {
|
|
18
|
+
characters += block.name.length + safeJson(block.arguments).length;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
characters +=
|
|
22
|
+
block.toolName.length +
|
|
23
|
+
block.rendered.reduce((total, content) => total +
|
|
24
|
+
(content.type === "text"
|
|
25
|
+
? content.text.length
|
|
26
|
+
: IMAGE_TOKEN_ESTIMATE * 4), 0);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return fixedTokens + Math.ceil(characters / 4);
|
|
31
|
+
}
|
|
32
|
+
function safeJson(value) {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.stringify(value) ?? String(value);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return String(value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatMessagesForCompaction.d.ts","sourceRoot":"","sources":["../../../sources/agent/compaction/formatMessagesForCompaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAqBhF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function formatMessagesForCompaction(messages) {
|
|
2
|
+
return messages
|
|
3
|
+
.map((message) => {
|
|
4
|
+
const blocks = message.blocks.flatMap((block) => {
|
|
5
|
+
if (block.type === "text")
|
|
6
|
+
return [block.text];
|
|
7
|
+
if (block.type === "image")
|
|
8
|
+
return ["[Image shared in the conversation]"];
|
|
9
|
+
if (block.type === "thinking")
|
|
10
|
+
return [];
|
|
11
|
+
if (block.type === "tool_call") {
|
|
12
|
+
return [`[Tool call: ${block.name} ${safeJson(block.arguments)}]`];
|
|
13
|
+
}
|
|
14
|
+
const result = block.rendered
|
|
15
|
+
.map((content) => content.type === "text" ? content.text : "[Image returned by tool]")
|
|
16
|
+
.join("\n");
|
|
17
|
+
return [`[Tool result: ${block.toolName}]\n${result}`];
|
|
18
|
+
});
|
|
19
|
+
return `<message role="${message.role}">\n${blocks.join("\n")}\n</message>`;
|
|
20
|
+
})
|
|
21
|
+
.join("\n\n");
|
|
22
|
+
}
|
|
23
|
+
function safeJson(value) {
|
|
24
|
+
try {
|
|
25
|
+
return JSON.stringify(value) ?? String(value);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return String(value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Message } from "../types.js";
|
|
2
|
+
import type { Model, Provider } from "../../providers/types.js";
|
|
3
|
+
export declare function requestCompactionSummary(options: {
|
|
4
|
+
provider: Provider;
|
|
5
|
+
model: Model;
|
|
6
|
+
messages: readonly Message[];
|
|
7
|
+
effort?: string;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
now: () => number;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
//# sourceMappingURL=requestCompactionSummary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestCompactionSummary.d.ts","sourceRoot":"","sources":["../../../sources/agent/compaction/requestCompactionSummary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAM/E,wBAAsB,wBAAwB,CAAC,OAAO,EAAE;IACpD,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,GAAG,EAAE,MAAM,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4ClB"}
|