@opencorelabs/lucidity 0.7.0 → 0.9.5
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 +9 -2
- package/dist/assets/speech/lucidity-speech +0 -0
- package/dist/automations/agent.d.ts.map +1 -1
- package/dist/automations/agent.js +2 -0
- package/dist/automations/designer.d.ts +1 -1
- package/dist/automations/service.d.ts +4 -0
- package/dist/automations/service.d.ts.map +1 -1
- package/dist/automations/service.js +60 -22
- package/dist/automations/store.d.ts +9 -3
- package/dist/automations/store.d.ts.map +1 -1
- package/dist/automations/store.js +45 -32
- package/dist/automations/workflow.d.ts +14 -0
- package/dist/automations/workflow.d.ts.map +1 -0
- package/dist/automations/workflow.js +57 -0
- package/dist/chat/server.d.ts +1 -0
- package/dist/chat/server.d.ts.map +1 -1
- package/dist/chat/server.js +6 -1
- package/dist/coding/listPrs.d.ts +2 -0
- package/dist/coding/listPrs.d.ts.map +1 -1
- package/dist/coding/listPrs.js +10 -0
- package/dist/coding/runCodeTurn.d.ts +6 -30
- package/dist/coding/runCodeTurn.d.ts.map +1 -1
- package/dist/coding/runCodeTurn.js +145 -218
- package/dist/coding/runReview.d.ts +10 -0
- package/dist/coding/runReview.d.ts.map +1 -0
- package/dist/coding/runReview.js +87 -0
- package/dist/coding/workspaceRegistry.d.ts +72 -0
- package/dist/coding/workspaceRegistry.d.ts.map +1 -0
- package/dist/coding/workspaceRegistry.js +421 -0
- package/dist/coding/worktree.d.ts +72 -32
- package/dist/coding/worktree.d.ts.map +1 -1
- package/dist/coding/worktree.js +190 -38
- package/dist/coding/worktreeSetup.d.ts +7 -0
- package/dist/coding/worktreeSetup.d.ts.map +1 -0
- package/dist/coding/worktreeSetup.js +49 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/daemonLease.d.ts +12 -0
- package/dist/daemonLease.d.ts.map +1 -0
- package/dist/daemonLease.js +32 -0
- package/dist/goals/assessment.d.ts +115 -0
- package/dist/goals/assessment.d.ts.map +1 -0
- package/dist/goals/assessment.js +67 -0
- package/dist/goals/notes.d.ts +18 -0
- package/dist/goals/notes.d.ts.map +1 -0
- package/dist/goals/notes.js +72 -0
- package/dist/index.js +75 -40
- package/dist/jobs/briefing.d.ts +2 -16
- package/dist/jobs/briefing.d.ts.map +1 -1
- package/dist/jobs/briefing.js +65 -93
- package/dist/jobs/goals.d.ts +15 -0
- package/dist/jobs/goals.d.ts.map +1 -0
- package/dist/jobs/goals.js +286 -0
- package/dist/jobs/weeklyReview.d.ts.map +1 -1
- package/dist/jobs/weeklyReview.js +3 -2
- package/dist/logTimestamps.d.ts +10 -0
- package/dist/logTimestamps.d.ts.map +1 -0
- package/dist/logTimestamps.js +12 -0
- package/dist/providerRecovery.d.ts +48 -0
- package/dist/providerRecovery.d.ts.map +1 -0
- package/dist/providerRecovery.js +100 -0
- package/dist/queue.d.ts +1 -0
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +4 -0
- package/dist/room/client.d.ts +6 -19
- package/dist/room/client.d.ts.map +1 -1
- package/dist/room/client.js +127 -123
- package/dist/room/computer.js +1 -1
- package/dist/room/durablePublish.d.ts +6 -0
- package/dist/room/durablePublish.d.ts.map +1 -0
- package/dist/room/durablePublish.js +19 -0
- package/dist/room/incidents.d.ts +4 -1
- package/dist/room/incidents.d.ts.map +1 -1
- package/dist/room/incidents.js +15 -7
- package/dist/room/turnQueue.d.ts.map +1 -1
- package/dist/room/turnQueue.js +55 -46
- package/dist/runtimeStore.d.ts +46 -0
- package/dist/runtimeStore.d.ts.map +1 -0
- package/dist/runtimeStore.js +205 -0
- package/dist/setup/server.js +1 -1
- package/dist/turnLog.d.ts +10 -40
- package/dist/turnLog.d.ts.map +1 -1
- package/dist/turnLog.js +33 -56
- package/dist/vault.d.ts +6 -3
- package/dist/vault.d.ts.map +1 -1
- package/dist/vault.js +18 -4
- package/package.json +4 -4
- package/src/automations/agent.ts +2 -0
- package/src/automations/service.ts +47 -21
- package/src/automations/store.ts +41 -50
- package/src/automations/workflow.ts +49 -0
- package/src/chat/server.ts +7 -1
- package/src/coding/listPrs.ts +14 -0
- package/src/coding/runCodeTurn.ts +51 -139
- package/src/coding/runReview.ts +83 -0
- package/src/coding/workspaceRegistry.ts +380 -0
- package/src/coding/worktree.ts +205 -40
- package/src/coding/worktreeSetup.ts +50 -0
- package/src/config.ts +2 -0
- package/src/daemonLease.ts +33 -0
- package/src/goals/assessment.ts +106 -0
- package/src/goals/notes.ts +88 -0
- package/src/index.ts +76 -46
- package/src/jobs/briefing.ts +62 -109
- package/src/jobs/goals.ts +384 -0
- package/src/jobs/weeklyReview.ts +4 -3
- package/src/logTimestamps.ts +14 -0
- package/src/providerRecovery.ts +99 -0
- package/src/queue.ts +4 -0
- package/src/room/client.ts +84 -116
- package/src/room/computer.ts +1 -1
- package/src/room/durablePublish.ts +25 -0
- package/src/room/incidents.ts +20 -8
- package/src/room/turnQueue.ts +53 -56
- package/src/runtimeStore.ts +207 -0
- package/src/setup/server.ts +1 -1
- package/src/turnLog.ts +32 -75
- package/src/vault.ts +16 -7
- package/vendor/mcp-server/dist/index.js +2 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts +4 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/goals.js +38 -0
- package/vendor/mcp-server/package.json +1 -1
- package/vendor/mcp-server/src/index.ts +2 -0
- package/vendor/mcp-server/src/tools/goals.ts +62 -0
- package/vendor/runtime/README.md +36 -2
- package/vendor/runtime/dist/executor/asyncQueue.d.ts +1 -0
- package/vendor/runtime/dist/executor/asyncQueue.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/asyncQueue.js +3 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts +5 -1
- package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.js +77 -13
- package/vendor/runtime/dist/executor/codex.d.ts +8 -2
- package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codex.js +113 -38
- package/vendor/runtime/dist/executor/codexProtocol/AgentPath.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/AgentPath.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/AgentPath.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationFailure.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.d.ts +12 -0
- package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/ImageGenerationItem.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.d.ts +24 -0
- package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/LegacyAppPathString.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/MessagePhase.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/SleepItem.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/SleepItem.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/SleepItem.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.d.ts +14 -0
- package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/SubAgentSource.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/ThreadId.d.ts +7 -0
- package/vendor/runtime/dist/executor/codexProtocol/ThreadId.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/ThreadId.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.d.ts +15 -0
- package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/WebSearchItem.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/AgentMessageDelivery.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/AsyncUserInputQuestion.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.d.ts +29 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CodexErrorInfo.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentState.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentTool.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CollabAgentToolCallStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.d.ts +20 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandAction.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionSource.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CommandExecutionStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.d.ts +11 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/DynamicToolCallStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.d.ts +7 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/FileUpdateChange.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GitInfo.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/HookPromptFragment.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppDisplayMode.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.d.ts +9 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpAppUi.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallAppContext.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.d.ts +4 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallError.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.d.ts +7 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallResult.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/McpToolCallStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitation.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.d.ts +7 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MemoryCitationEntry.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.d.ts +16 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentErrorDetails.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.d.ts +4 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/MisalignmentSteer.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts +11 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/NonSteerableTurnKind.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/PatchApplyStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.d.ts +9 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/PatchChangeKind.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +4 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.d.ts +7 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SessionSource.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SubAgentActivityKind.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.d.ts +100 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Thread.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadActiveFlag.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadHistoryMode.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.d.ts +216 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadItem.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.d.ts +11 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadParams.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadReadResponse.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.d.ts +19 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSection.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSectionAppearance.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts +3 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.d.ts +12 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.d.ts +36 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Turn.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.d.ts +12 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnError.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnItemsView.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts +7 -2
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.d.ts +15 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/WebSearchAction.js +2 -0
- package/vendor/runtime/dist/executor/codexRpc.d.ts +13 -4
- package/vendor/runtime/dist/executor/codexRpc.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexRpc.js +21 -5
- package/vendor/runtime/dist/executor/codexSessions.d.ts +30 -0
- package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexSessions.js +88 -0
- package/vendor/runtime/dist/executor/health.d.ts +8 -2
- package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/health.js +21 -5
- package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -1
- package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/liveTurns.js +12 -5
- package/vendor/runtime/dist/executor/ownership.d.ts +40 -0
- package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/ownership.js +106 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts +1 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/providerRouter.js +5 -0
- package/vendor/runtime/dist/executor/types.d.ts +27 -0
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +1 -0
- package/vendor/runtime/dist/index.d.ts +2 -1
- package/vendor/runtime/dist/index.d.ts.map +1 -1
- package/vendor/runtime/dist/index.js +1 -0
- package/vendor/runtime/src/executor/asyncQueue.ts +3 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +66 -13
- package/vendor/runtime/src/executor/codex.ts +124 -47
- package/vendor/runtime/src/executor/codexProtocol/AgentPath.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/FunctionCallOutputContentItem.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/ImageGenerationFailure.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/ImageGenerationItem.ts +7 -0
- package/vendor/runtime/src/executor/codexProtocol/LegacyAppPathString.ts +27 -0
- package/vendor/runtime/src/executor/codexProtocol/MessagePhase.ts +11 -0
- package/vendor/runtime/src/executor/codexProtocol/Personality.ts +3 -0
- package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/README.md +2 -2
- package/vendor/runtime/src/executor/codexProtocol/SleepItem.ts +8 -0
- package/vendor/runtime/src/executor/codexProtocol/SubAgentSource.ts +7 -0
- package/vendor/runtime/src/executor/codexProtocol/ThreadId.ts +10 -0
- package/vendor/runtime/src/executor/codexProtocol/WebSearchItem.ts +14 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/AgentMessageDelivery.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/AsyncUserInputQuestion.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CodexErrorInfo.ts +12 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentState.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentTool.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CollabAgentToolCallStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CommandAction.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CommandExecutionSource.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CommandExecutionStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CyberAccessProgram.ts +9 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/DynamicToolCallOutputContentItem.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/DynamicToolCallStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/FileUpdateChange.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/GitInfo.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/HookPromptFragment.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/McpAppDisplayMode.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/McpAppUi.ts +9 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallAppContext.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallError.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallResult.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/McpToolCallStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/MemoryCitation.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/MemoryCitationEntry.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/MisalignmentErrorDetails.ts +18 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/MisalignmentSteer.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/Model.ts +11 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/ModelAccessPrograms.ts +13 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/NonSteerableTurnKind.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/PatchApplyStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/PatchChangeKind.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +2 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SessionSource.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SubAgentActivityKind.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/Thread.ts +104 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadActiveFlag.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadHistoryMode.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadItem.ts +125 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadReadParams.ts +12 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadReadResponse.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadResumeParams.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSection.ts +21 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSectionAppearance.ts +8 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStartParams.ts +4 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStatus.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/Turn.ts +37 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/TurnError.ts +11 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/TurnItemsView.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/TurnStartParams.ts +7 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/TurnStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/UserInput.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/WebSearchAction.ts +5 -0
- package/vendor/runtime/src/executor/codexRpc.ts +26 -6
- package/vendor/runtime/src/executor/codexSessions.ts +108 -0
- package/vendor/runtime/src/executor/health.ts +21 -7
- package/vendor/runtime/src/executor/liveTurns.ts +12 -5
- package/vendor/runtime/src/executor/ownership.ts +83 -0
- package/vendor/runtime/src/executor/providerRouter.ts +6 -0
- package/vendor/runtime/src/executor/types.ts +20 -1
- package/vendor/runtime/src/harness/index.ts +1 -0
- package/vendor/runtime/src/index.ts +2 -1
- package/vendor/shared/dist/agentCommands.d.ts +1 -0
- package/vendor/shared/dist/agentCommands.d.ts.map +1 -1
- package/vendor/shared/dist/automations.d.ts +34 -0
- package/vendor/shared/dist/automations.d.ts.map +1 -1
- package/vendor/shared/dist/automations.js +12 -0
- package/vendor/shared/dist/cardStudio.d.ts +41 -0
- package/vendor/shared/dist/cardStudio.d.ts.map +1 -1
- package/vendor/shared/dist/cardStudio.js +13 -3
- package/vendor/shared/dist/computer.d.ts +7 -1
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +13 -4
- package/vendor/shared/dist/constants.d.ts +3 -3
- package/vendor/shared/dist/constants.d.ts.map +1 -1
- package/vendor/shared/dist/constants.js +8 -14
- package/vendor/shared/dist/goalNotes.d.ts +4 -0
- package/vendor/shared/dist/goalNotes.d.ts.map +1 -0
- package/vendor/shared/dist/goalNotes.js +23 -0
- package/vendor/shared/dist/goals.d.ts +835 -0
- package/vendor/shared/dist/goals.d.ts.map +1 -0
- package/vendor/shared/dist/goals.js +198 -0
- package/vendor/shared/dist/index.d.ts +7 -2
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +6 -1
- package/vendor/shared/dist/journal-vault.d.ts +1 -1
- package/vendor/shared/dist/messagingSafety.d.ts +21 -0
- package/vendor/shared/dist/messagingSafety.d.ts.map +1 -0
- package/vendor/shared/dist/messagingSafety.js +8 -0
- package/vendor/shared/dist/schemas/harness.d.ts +199 -169
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +25 -124
- package/vendor/shared/dist/smartCapture.d.ts +24 -0
- package/vendor/shared/dist/smartCapture.d.ts.map +1 -1
- package/vendor/shared/dist/smartCapture.js +15 -0
- package/vendor/shared/dist/taskSync.d.ts +342 -0
- package/vendor/shared/dist/taskSync.d.ts.map +1 -0
- package/vendor/shared/dist/taskSync.js +111 -0
- package/vendor/shared/dist/types.d.ts +1 -4
- package/vendor/shared/dist/types.d.ts.map +1 -1
- package/vendor/shared/dist/voiceCapture.d.ts +1 -1
- package/vendor/shared/dist/workspaces.d.ts +255 -0
- package/vendor/shared/dist/workspaces.d.ts.map +1 -0
- package/vendor/shared/dist/workspaces.js +89 -0
- package/vendor/shared/src/agentCommands.ts +1 -0
- package/vendor/shared/src/automations.ts +12 -0
- package/vendor/shared/src/cardStudio.ts +13 -3
- package/vendor/shared/src/computer.ts +19 -5
- package/vendor/shared/src/constants.ts +8 -14
- package/vendor/shared/src/goalNotes.ts +23 -0
- package/vendor/shared/src/goals.ts +237 -0
- package/vendor/shared/src/index.ts +7 -6
- package/vendor/shared/src/messagingSafety.ts +11 -0
- package/vendor/shared/src/schemas/harness.ts +24 -130
- package/vendor/shared/src/smartCapture.ts +27 -0
- package/vendor/shared/src/taskSync.ts +81 -0
- package/vendor/shared/src/types.ts +0 -6
- package/vendor/shared/src/workspaces.ts +103 -0
- package/dist/coding/conduct.d.ts +0 -69
- package/dist/coding/conduct.d.ts.map +0 -1
- package/dist/coding/conduct.js +0 -348
- package/dist/coding/fleetIntegrate.d.ts +0 -37
- package/dist/coding/fleetIntegrate.d.ts.map +0 -1
- package/dist/coding/fleetIntegrate.js +0 -64
- package/dist/coding/fleetPlan.d.ts +0 -20
- package/dist/coding/fleetPlan.d.ts.map +0 -1
- package/dist/coding/fleetPlan.js +0 -125
- package/dist/coding/fleetTasks.d.ts +0 -33
- package/dist/coding/fleetTasks.d.ts.map +0 -1
- package/dist/coding/fleetTasks.js +0 -75
- package/dist/coding/openFleetPr.d.ts +0 -41
- package/dist/coding/openFleetPr.d.ts.map +0 -1
- package/dist/coding/openFleetPr.js +0 -121
- package/src/coding/conduct.ts +0 -462
- package/src/coding/fleetIntegrate.ts +0 -95
- package/src/coding/fleetPlan.ts +0 -135
- package/src/coding/fleetTasks.ts +0 -109
- package/src/coding/openFleetPr.ts +0 -148
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { realpath } from 'node:fs/promises';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { RepoSettingsSchema, sessionProvider } from '@lucidity/shared';
|
|
6
|
+
import { conversationKey } from '../runtimeStore.js';
|
|
7
|
+
import { LaneQueue } from '../queue.js';
|
|
8
|
+
import { resolveRepo } from './repos.js';
|
|
9
|
+
import { archiveWorktree, archivedHead, deleteArchivedWorktree, ensureWorkspace, headSha, restoreArchivedFiles, sessionBranch, sessionWorktreePath, unmergedArchivedWork, workspaceBase, workspaceBranchExists } from './worktree.js';
|
|
10
|
+
import { copyIncludedFiles, matchedFiles, runSetupScript } from './worktreeSetup.js';
|
|
11
|
+
import { inspectRun, continuationRequest } from './runReview.js';
|
|
12
|
+
/** "Worktree 3": the next number this repository has not used. */
|
|
13
|
+
export function nextWorkerTitle(titles) {
|
|
14
|
+
const used = titles.map((title) => (title.startsWith('Worktree ') ? Number(title.slice(9)) : 0));
|
|
15
|
+
return `Worktree ${Math.max(0, ...used.filter(Number.isInteger)) + 1}`;
|
|
16
|
+
}
|
|
17
|
+
// Two checkouts fighting over :3001 and :8081 is half of CLAUDE.md's gotchas. Every worktree
|
|
18
|
+
// gets ten ports of its own, kept for its lifetime, well away from those defaults and from the
|
|
19
|
+
// owner's phone Metro on 8090.
|
|
20
|
+
const PORT_BASE = 4100;
|
|
21
|
+
const PORT_BLOCK = 10;
|
|
22
|
+
/** The lowest block of ports no other worktree on this computer holds. */
|
|
23
|
+
export function nextPortBlock(taken) {
|
|
24
|
+
const used = new Set(taken);
|
|
25
|
+
let port = PORT_BASE;
|
|
26
|
+
while (used.has(port))
|
|
27
|
+
port += PORT_BLOCK;
|
|
28
|
+
return port;
|
|
29
|
+
}
|
|
30
|
+
/** Workspace lifetime is independent of runs, provider sessions, PRs, and phone storage. */
|
|
31
|
+
export class WorkspaceRegistry {
|
|
32
|
+
store;
|
|
33
|
+
repos;
|
|
34
|
+
baseDir;
|
|
35
|
+
lanes = new LaneQueue();
|
|
36
|
+
setups = new Map();
|
|
37
|
+
constructor(store, repos, baseDir) {
|
|
38
|
+
this.store = store;
|
|
39
|
+
this.repos = repos;
|
|
40
|
+
this.baseDir = baseDir;
|
|
41
|
+
}
|
|
42
|
+
repo(id) {
|
|
43
|
+
const repo = resolveRepo(id, this.repos());
|
|
44
|
+
if (!repo)
|
|
45
|
+
throw new Error('This repository is not available on the paired computer.');
|
|
46
|
+
return repo;
|
|
47
|
+
}
|
|
48
|
+
public(worker) {
|
|
49
|
+
const { path: _, legacyMessages: __, sessionCheckout: ___, legacy: ____, ...row } = worker;
|
|
50
|
+
return { ...row, resume: this.store.latestSession(worker.conversationId) ?? row.resume,
|
|
51
|
+
...(this.setups.has(worker.workerId) ? { setup: 'running' } : {}) };
|
|
52
|
+
}
|
|
53
|
+
list(repoId) {
|
|
54
|
+
return this.store.list('workers')
|
|
55
|
+
.filter((w) => (!repoId || w.repoId === repoId) && this.repos().some((r) => r.id === w.repoId))
|
|
56
|
+
.map((w) => this.public(w));
|
|
57
|
+
}
|
|
58
|
+
/** How this repository's worktrees are prepared. Nothing is copied or run until the owner sets it. */
|
|
59
|
+
settings(repoId) {
|
|
60
|
+
return RepoSettingsSchema.parse(this.store.get('repo-settings', repoId) ?? {});
|
|
61
|
+
}
|
|
62
|
+
places(repoId) {
|
|
63
|
+
const root = this.repo(repoId).root;
|
|
64
|
+
return { root, worktrees: dirname(sessionWorktreePath(repoId, this.baseDir, 'x')),
|
|
65
|
+
copyMatches: matchedFiles(root, this.settings(repoId).copy) };
|
|
66
|
+
}
|
|
67
|
+
/** Run the archive command, then free the folder. Shared by the phone's Archive and archive-on-merge. */
|
|
68
|
+
async archive(worker) {
|
|
69
|
+
const { repoId, workerId } = worker;
|
|
70
|
+
if (worker.state === 'creating' || this.setups.has(workerId))
|
|
71
|
+
throw new Error('Wait for workspace setup to finish before archiving.');
|
|
72
|
+
if (this.store.unfinished(worker.conversationId))
|
|
73
|
+
throw new Error('Stop this worker and its queued messages before archiving it.');
|
|
74
|
+
// The session checkout is shared with the classic single session, so its folder stays.
|
|
75
|
+
if (!worker.sessionCheckout) {
|
|
76
|
+
const root = this.repo(repoId).root;
|
|
77
|
+
const settings = this.settings(repoId);
|
|
78
|
+
const path = sessionWorktreePath(repoId, this.baseDir, workerId);
|
|
79
|
+
if (settings.archiveScript && existsSync(path))
|
|
80
|
+
await runSetupScript(root, path, worker.title, settings.archiveScript, worker.port).catch((error) => {
|
|
81
|
+
const detail = String(error.stderr || error.message).trim().slice(-600);
|
|
82
|
+
throw new Error(`The archive command failed, so this worktree was kept. ${detail}`);
|
|
83
|
+
});
|
|
84
|
+
await archiveWorktree(root, { path, branch: worker.branch ?? sessionBranch(repoId, workerId), mode: 'worktree' }, workerId, { deleteBranch: settings.deleteBranchOnArchive });
|
|
85
|
+
}
|
|
86
|
+
this.save({ ...worker, state: 'archived' });
|
|
87
|
+
}
|
|
88
|
+
/** Remove an archived worktree for good: its local branch, its snapshot and its record. Answers
|
|
89
|
+
* with the work that would be lost, deleting nothing, unless there is none or `force` is set. */
|
|
90
|
+
delete(repoId, workerId, force) {
|
|
91
|
+
const root = this.repo(repoId).root;
|
|
92
|
+
// Queued behind create, so a restore that is already under way finishes first and is seen here.
|
|
93
|
+
return this.lanes.run(root, async () => {
|
|
94
|
+
const worker = this.store.get('workers', workerId);
|
|
95
|
+
// Already gone: another device may still list a worktree that was deleted from this one.
|
|
96
|
+
if (!worker)
|
|
97
|
+
return undefined;
|
|
98
|
+
if (worker.repoId !== repoId)
|
|
99
|
+
throw new Error('This worker is not registered in this repository.');
|
|
100
|
+
if (worker.state !== 'archived')
|
|
101
|
+
throw new Error('Archive this worktree before deleting it.');
|
|
102
|
+
// The session checkout's branch and folder belong to the classic single session, so they stay.
|
|
103
|
+
if (!worker.sessionCheckout) {
|
|
104
|
+
const branch = worker.branch ?? sessionBranch(repoId, workerId);
|
|
105
|
+
if (!force) {
|
|
106
|
+
const unmerged = await unmergedArchivedWork(root, workerId, branch, [worker.baseRef, this.settings(repoId).baseRef, this.repos().find((r) => r.id === repoId)?.baseRef]);
|
|
107
|
+
if (unmerged.commits || unmerged.uncommitted)
|
|
108
|
+
return unmerged;
|
|
109
|
+
}
|
|
110
|
+
await deleteArchivedWorktree(root, workerId, branch).catch((error) => {
|
|
111
|
+
const detail = String(error.stderr || error.message).trim().slice(-600);
|
|
112
|
+
throw new Error(`This worktree's branch could not be deleted, so it was kept. ${detail}`);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// The conversation's runs stay: they are the receipts that stop a replayed request running twice.
|
|
116
|
+
this.store.transaction(() => {
|
|
117
|
+
this.store.delete('workers', workerId);
|
|
118
|
+
this.store.delete('workspaces', worker.conversationId);
|
|
119
|
+
});
|
|
120
|
+
return undefined;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/** Archive ready worktrees whose pull request has merged, in repositories that asked for it.
|
|
124
|
+
* A worktree with commits past the merged head, or a turn in flight, is left alone. */
|
|
125
|
+
async archiveMerged(mergedHead) {
|
|
126
|
+
const archived = [];
|
|
127
|
+
for (const worker of this.store.list('workers')) {
|
|
128
|
+
if (worker.state !== 'ready' || worker.sessionCheckout || !worker.path || !worker.branch)
|
|
129
|
+
continue;
|
|
130
|
+
try {
|
|
131
|
+
if (!this.settings(worker.repoId).archiveOnMerge || !existsSync(worker.path))
|
|
132
|
+
continue;
|
|
133
|
+
const merged = await mergedHead(this.repo(worker.repoId).root, worker.branch);
|
|
134
|
+
if (!merged || merged !== await headSha(worker.path))
|
|
135
|
+
continue;
|
|
136
|
+
await this.archive(worker);
|
|
137
|
+
archived.push(worker.workerId);
|
|
138
|
+
}
|
|
139
|
+
catch { /* busy, or the repository is gone: try again on the next sweep */ }
|
|
140
|
+
}
|
|
141
|
+
return archived;
|
|
142
|
+
}
|
|
143
|
+
save(worker) {
|
|
144
|
+
this.store.set('workers', worker.workerId, { ...worker, updatedAt: new Date().toISOString() });
|
|
145
|
+
}
|
|
146
|
+
resume(request) {
|
|
147
|
+
if (!request.workerId && request.mode === 'in-place' && !request.handoff) {
|
|
148
|
+
const conversation = conversationKey({ ...request, kind: 'code' });
|
|
149
|
+
const checkout = this.store.get('checkout-conversations', conversation);
|
|
150
|
+
const resume = this.store.latestSession(conversation, checkout?.clearedThrough) ?? checkout?.resume ??
|
|
151
|
+
(checkout && checkout.revision !== '0' ? undefined : request.resume);
|
|
152
|
+
return request.provider && sessionProvider(resume) !== request.provider ? undefined : resume;
|
|
153
|
+
}
|
|
154
|
+
if (!request.workerId || request.handoff)
|
|
155
|
+
return request.resume;
|
|
156
|
+
const worker = this.store.get('workers', request.workerId);
|
|
157
|
+
if (!worker || worker.repoId !== request.repoId)
|
|
158
|
+
return request.resume;
|
|
159
|
+
const resume = this.store.latestSession(worker.conversationId) ?? worker.resume ?? request.resume;
|
|
160
|
+
return request.provider && sessionProvider(resume) !== request.provider ? undefined : resume;
|
|
161
|
+
}
|
|
162
|
+
async create(repoId, workerId, title, brief = '') {
|
|
163
|
+
const repo = this.repo(repoId);
|
|
164
|
+
return this.lanes.run(repo.root, async () => {
|
|
165
|
+
const previous = this.store.get('workers', workerId);
|
|
166
|
+
if (previous && previous.repoId !== repoId)
|
|
167
|
+
throw new Error('This worker belongs to another repository.');
|
|
168
|
+
if (previous?.state === 'archived')
|
|
169
|
+
throw new Error('Restore this worker before continuing.');
|
|
170
|
+
if (previous?.state === 'ready')
|
|
171
|
+
return this.public(previous);
|
|
172
|
+
const now = new Date().toISOString();
|
|
173
|
+
const worker = previous ?? {
|
|
174
|
+
workerId, repoId, title: title || nextWorkerTitle(this.store.list('workers').filter((w) => w.repoId === repoId).map((w) => w.title)), brief,
|
|
175
|
+
workspaceId: workerId, conversationId: conversationKey({ kind: 'code', repoId, workerId }),
|
|
176
|
+
state: 'creating', createdAt: now, updatedAt: now,
|
|
177
|
+
};
|
|
178
|
+
this.save({ ...worker, state: 'creating', error: undefined });
|
|
179
|
+
try {
|
|
180
|
+
const gitWorkerId = worker.sessionCheckout ? undefined : workerId;
|
|
181
|
+
const path = sessionWorktreePath(repoId, this.baseDir, gitWorkerId);
|
|
182
|
+
const branchExists = await workspaceBranchExists(repo.root, repoId, gitWorkerId);
|
|
183
|
+
// A branch deleted on archive is re-created from the commit its snapshot was taken on.
|
|
184
|
+
const archivedTip = gitWorkerId && !branchExists && !existsSync(path) ? await archivedHead(repo.root, workerId) : undefined;
|
|
185
|
+
if (worker.legacy && !existsSync(path) && !branchExists && !archivedTip)
|
|
186
|
+
throw new Error('The original worker branch and files are missing. Its conversation is preserved; create a new worker for new work.');
|
|
187
|
+
// A known legacy directory is adopted without fetching or resetting it.
|
|
188
|
+
const base = existsSync(path) || branchExists || archivedTip || previous?.baseSha
|
|
189
|
+
? previous?.baseSha ? { ref: previous.baseRef, sha: previous.baseSha } : undefined
|
|
190
|
+
: await workspaceBase(repo.root, this.settings(repoId).baseRef || this.repos().find((r) => r.id === repoId)?.baseRef);
|
|
191
|
+
if (base)
|
|
192
|
+
this.save({ ...worker, state: 'creating', baseRef: base.ref, baseSha: base.sha });
|
|
193
|
+
const fresh = !existsSync(path);
|
|
194
|
+
const workspace = await ensureWorkspace(repo.root, repoId, { workerId: gitWorkerId, baseDir: this.baseDir, startPoint: archivedTip ?? base?.sha });
|
|
195
|
+
if (gitWorkerId)
|
|
196
|
+
await restoreArchivedFiles(repo.root, workspace, workerId);
|
|
197
|
+
const ready = { ...worker, state: 'ready', error: undefined, path: await realpath(workspace.path),
|
|
198
|
+
port: this.portOf(worker), branch: workspace.branch, ...(base ? { baseRef: base.ref, baseSha: base.sha } : {}) };
|
|
199
|
+
this.save(ready);
|
|
200
|
+
if (fresh && gitWorkerId)
|
|
201
|
+
this.setUp(repo.root, ready);
|
|
202
|
+
return this.public(ready);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
const reserved = this.store.get('workers', workerId) ?? worker;
|
|
206
|
+
this.save({ ...reserved, state: 'setup_failed', error: error instanceof Error ? error.message : String(error) });
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/** A worktree's port block. Archived worktrees keep theirs so a restore comes back on the same ports. */
|
|
212
|
+
portOf(worker) {
|
|
213
|
+
return worker.port ?? nextPortBlock(this.store.list('workers').map((w) => w.port));
|
|
214
|
+
}
|
|
215
|
+
/** Fill in a worktree: the repository's listed files, then its setup command. This runs after the
|
|
216
|
+
* worktree is reported ready so the phone is not kept waiting; a turn waits for it in prepare().
|
|
217
|
+
* A failure is noted on the worker and never fails the worktree. */
|
|
218
|
+
setUp(repoRoot, worker) {
|
|
219
|
+
const settings = this.settings(worker.repoId);
|
|
220
|
+
if (!settings.copy.length && !settings.setup)
|
|
221
|
+
return;
|
|
222
|
+
this.save({ ...worker, setup: undefined, error: undefined });
|
|
223
|
+
const run = (async () => {
|
|
224
|
+
copyIncludedFiles(repoRoot, worker.path, settings.copy);
|
|
225
|
+
if (settings.setup)
|
|
226
|
+
await runSetupScript(repoRoot, worker.path, worker.title, settings.setup, worker.port);
|
|
227
|
+
})().catch((error) => {
|
|
228
|
+
const detail = String(error.stderr || error.message).trim().slice(-600);
|
|
229
|
+
console.error(`[workspaces] setup failed for ${worker.workerId}: ${detail}`);
|
|
230
|
+
const current = this.store.get('workers', worker.workerId);
|
|
231
|
+
if (current?.state === 'ready')
|
|
232
|
+
this.save({ ...current, setup: 'failed', error: detail });
|
|
233
|
+
}).finally(() => this.setups.delete(worker.workerId));
|
|
234
|
+
this.setups.set(worker.workerId, run);
|
|
235
|
+
}
|
|
236
|
+
async prepare(request) {
|
|
237
|
+
this.checkRecoveryWorkspace(request);
|
|
238
|
+
const repo = this.repo(request.repoId);
|
|
239
|
+
let gitWorkerId = request.workerId;
|
|
240
|
+
if (request.workerId) {
|
|
241
|
+
await this.create(request.repoId, request.workerId, undefined, request.prompt);
|
|
242
|
+
await this.setups.get(request.workerId);
|
|
243
|
+
const worker = this.store.get('workers', request.workerId);
|
|
244
|
+
if (worker.sessionCheckout)
|
|
245
|
+
gitWorkerId = undefined;
|
|
246
|
+
if (!worker.path || !existsSync(worker.path)) {
|
|
247
|
+
this.save({ ...worker, state: 'setup_failed', error: 'Workspace files are missing. Restore or retry setup to recover the branch.' });
|
|
248
|
+
throw new Error('Workspace files are missing. Retry setup to recover the branch.');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const workspace = await ensureWorkspace(repo.root, request.repoId, {
|
|
252
|
+
mode: request.workerId ? 'worktree' : request.mode, workerId: gitWorkerId, baseDir: this.baseDir,
|
|
253
|
+
});
|
|
254
|
+
this.store.set('workspaces', conversationKey({ ...request, kind: 'code' }), { ...workspace, repoId: request.repoId });
|
|
255
|
+
const worker = request.workerId ? this.store.get('workers', request.workerId) : undefined;
|
|
256
|
+
if (!worker || worker.sessionCheckout)
|
|
257
|
+
return workspace;
|
|
258
|
+
// Worktrees made before ports existed get their block on their next turn.
|
|
259
|
+
const port = this.portOf(worker);
|
|
260
|
+
if (worker.port !== port)
|
|
261
|
+
this.save({ ...worker, port });
|
|
262
|
+
return { ...workspace, env: { LUCIDITY_PORT: String(port), LUCIDITY_WORKTREE_NAME: worker.title } };
|
|
263
|
+
}
|
|
264
|
+
checkout(command, commandId) {
|
|
265
|
+
if (!command.repoId || command.workerId)
|
|
266
|
+
throw new Error('Select a repository main checkout.');
|
|
267
|
+
this.repo(command.repoId);
|
|
268
|
+
const conversationId = conversationKey({ kind: 'code', repoId: command.repoId, mode: 'in-place' });
|
|
269
|
+
if (!['history', 'import', 'clear-history'].includes(command.action))
|
|
270
|
+
throw new Error('Main checkout supports history, import and clear.');
|
|
271
|
+
const saved = () => this.store.get('checkout-conversations', conversationId) ?? { revision: '0' };
|
|
272
|
+
if (command.action !== 'history') {
|
|
273
|
+
this.store.transaction(() => {
|
|
274
|
+
const receipt = commandId && this.store.get('workspace-commands', commandId);
|
|
275
|
+
if (receipt) {
|
|
276
|
+
if (receipt.input !== JSON.stringify(command))
|
|
277
|
+
throw new Error('This command ID already belongs to different input.');
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const checkout = saved();
|
|
281
|
+
if ((command.revision ?? '0') !== checkout.revision)
|
|
282
|
+
throw new Error('This conversation changed on the computer. Refresh before changing its history.');
|
|
283
|
+
if (command.action === 'clear-history') {
|
|
284
|
+
if (this.store.unfinished(conversationId))
|
|
285
|
+
throw new Error('Finish or stop active and queued messages before clearing this conversation.');
|
|
286
|
+
this.store.set('checkout-conversations', conversationId, {
|
|
287
|
+
revision: commandId ?? `${Date.now()}:${checkout.revision}`,
|
|
288
|
+
clearedThrough: this.store.lastCommand(conversationId),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const messages = new Map((checkout.legacyMessages ?? []).map((message) => [message.id, message]));
|
|
293
|
+
for (const message of command.legacy?.messages ?? [])
|
|
294
|
+
if (!messages.has(message.id))
|
|
295
|
+
messages.set(message.id, message);
|
|
296
|
+
this.store.set('checkout-conversations', conversationId, { ...checkout,
|
|
297
|
+
legacyMessages: [...messages.values()], resume: checkout.resume ?? command.legacy?.resume,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
if (commandId)
|
|
301
|
+
this.store.set('workspace-commands', commandId, { input: JSON.stringify(command) });
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
const checkout = saved();
|
|
305
|
+
const page = this.store.commands(conversationId, { before: command.before, after: checkout.clearedThrough, limit: 10 });
|
|
306
|
+
return {
|
|
307
|
+
workers: [], checkout: { repoId: command.repoId, conversationId, revision: checkout.revision,
|
|
308
|
+
resume: this.store.latestSession(conversationId, checkout.clearedThrough) ?? checkout.resume },
|
|
309
|
+
legacyMessages: command.before ? [] : checkout.legacyMessages,
|
|
310
|
+
runs: this.historyRuns(page),
|
|
311
|
+
...(page.length === 10 ? { nextBefore: page[0].request.id } : {}),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
historyRuns(page) {
|
|
315
|
+
return page.map(({ request, state }) => ({ requestId: request.id, prompt: 'prompt' in request ? request.prompt : '',
|
|
316
|
+
...('handoff' in request && request.handoff && request.provider ? { handoff: { from: request.handoff.from, to: request.provider } } : {}),
|
|
317
|
+
frames: state.frames, terminated: state.terminated }));
|
|
318
|
+
}
|
|
319
|
+
async command(command, commandId) {
|
|
320
|
+
if (command.action === 'inspect-run' || command.action === 'continue-run') {
|
|
321
|
+
if (!command.repoId)
|
|
322
|
+
throw new Error('Select a repository.');
|
|
323
|
+
const repo = this.repo(command.repoId);
|
|
324
|
+
const path = command.checkout ? repo.root : command.workerId ? this.store.get('workers', command.workerId)?.path : undefined;
|
|
325
|
+
if (command.action === 'continue-run')
|
|
326
|
+
return { workers: this.list(command.repoId), review: this.store.get('run-reviews', command.requestId) };
|
|
327
|
+
return { workers: this.list(command.repoId), review: await inspectRun(this.store, command, path) };
|
|
328
|
+
}
|
|
329
|
+
if (command.checkout)
|
|
330
|
+
return this.checkout(command, commandId);
|
|
331
|
+
if (command.action === 'clear-history')
|
|
332
|
+
throw new Error('Select Main checkout to clear its history.');
|
|
333
|
+
const { action, repoId } = command;
|
|
334
|
+
let workerId = command.workerId;
|
|
335
|
+
if (action === 'list')
|
|
336
|
+
return { workers: this.list(repoId) };
|
|
337
|
+
if (action === 'settings' || action === 'save-settings') {
|
|
338
|
+
if (!repoId)
|
|
339
|
+
throw new Error('Select a repository.');
|
|
340
|
+
this.repo(repoId);
|
|
341
|
+
if (action === 'save-settings')
|
|
342
|
+
this.store.set('repo-settings', repoId, RepoSettingsSchema.parse(command.settings ?? {}));
|
|
343
|
+
return { workers: this.list(repoId), settings: this.settings(repoId), places: this.places(repoId) };
|
|
344
|
+
}
|
|
345
|
+
if (action === 'import' && repoId && command.legacy?.sessionCheckout) {
|
|
346
|
+
const key = createHash('sha256').update(this.repo(repoId).root).digest('hex');
|
|
347
|
+
workerId = `${key.slice(0, 8)}-${key.slice(8, 12)}-7${key.slice(13, 16)}-8${key.slice(17, 20)}-${key.slice(20, 32)}`;
|
|
348
|
+
}
|
|
349
|
+
if (!repoId || !workerId)
|
|
350
|
+
throw new Error('Select a repository and worker.');
|
|
351
|
+
this.repo(repoId);
|
|
352
|
+
if (action === 'create')
|
|
353
|
+
await this.create(repoId, workerId, command.title, command.brief);
|
|
354
|
+
else if (action === 'import') {
|
|
355
|
+
const previous = this.store.get('workers', workerId);
|
|
356
|
+
if (previous && previous.repoId !== repoId)
|
|
357
|
+
throw new Error('This worker belongs to another repository.');
|
|
358
|
+
if (!previous) {
|
|
359
|
+
const now = new Date().toISOString();
|
|
360
|
+
this.save({ workerId, repoId, title: command.title ?? 'Worker', brief: command.brief ?? '',
|
|
361
|
+
workspaceId: workerId, conversationId: conversationKey({ kind: 'code', repoId, workerId }),
|
|
362
|
+
state: 'setup_failed', createdAt: now, updatedAt: now,
|
|
363
|
+
legacyMessages: command.legacy?.messages ?? [], resume: command.legacy?.resume,
|
|
364
|
+
sessionCheckout: command.legacy?.sessionCheckout, legacy: true });
|
|
365
|
+
await this.create(repoId, workerId).catch(() => { });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else if (action === 'delete') {
|
|
369
|
+
const unmerged = await this.delete(repoId, workerId, command.force);
|
|
370
|
+
return { workers: this.list(repoId), ...(unmerged ? { unmerged } : {}) };
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
const worker = this.store.get('workers', workerId);
|
|
374
|
+
if (!worker || worker.repoId !== repoId)
|
|
375
|
+
throw new Error('This worker is not registered in this repository.');
|
|
376
|
+
if (action === 'history') {
|
|
377
|
+
const page = this.store.commands(worker.conversationId, { before: command.before, limit: 10 });
|
|
378
|
+
const frames = page.flatMap((r) => r.state.frames);
|
|
379
|
+
const resume = [...frames].reverse().find((f) => typeof f.sessionId === 'string')?.sessionId;
|
|
380
|
+
return { workers: [{ ...this.public(worker), ...(typeof resume === 'string' ? { resume } : {}) }],
|
|
381
|
+
legacyMessages: command.before ? [] : worker.legacyMessages,
|
|
382
|
+
runs: this.historyRuns(page),
|
|
383
|
+
...(page.length === 10 ? { nextBefore: page[0].request.id } : {}) };
|
|
384
|
+
}
|
|
385
|
+
if (action === 'archive') {
|
|
386
|
+
await this.archive(worker);
|
|
387
|
+
}
|
|
388
|
+
else if (action === 'setup') {
|
|
389
|
+
if (worker.state !== 'ready' || worker.sessionCheckout || !worker.path)
|
|
390
|
+
throw new Error('This worktree is not ready for setup.');
|
|
391
|
+
if (!this.setups.has(workerId))
|
|
392
|
+
this.setUp(this.repo(repoId).root, worker);
|
|
393
|
+
}
|
|
394
|
+
else if (action === 'restore') {
|
|
395
|
+
this.save({ ...worker, state: 'creating' });
|
|
396
|
+
await this.create(repoId, workerId);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return { workers: this.list(repoId) };
|
|
400
|
+
}
|
|
401
|
+
continuation(command) {
|
|
402
|
+
if (!command.repoId)
|
|
403
|
+
throw new Error('Select a repository.');
|
|
404
|
+
this.repo(command.repoId);
|
|
405
|
+
if (command.workerId && this.store.get('workers', command.workerId)?.state !== 'ready')
|
|
406
|
+
throw new Error('Restore this worker before continuing.');
|
|
407
|
+
const request = continuationRequest(this.store, command);
|
|
408
|
+
this.checkRecoveryWorkspace(request);
|
|
409
|
+
return request;
|
|
410
|
+
}
|
|
411
|
+
checkRecoveryWorkspace(request) {
|
|
412
|
+
if (!request.recoveryOf)
|
|
413
|
+
return;
|
|
414
|
+
const review = this.store.get('run-reviews', request.recoveryOf);
|
|
415
|
+
const worker = request.workerId ? this.store.get('workers', request.workerId) : undefined;
|
|
416
|
+
const path = !request.workerId && request.mode === 'in-place' ? this.repo(request.repoId).root :
|
|
417
|
+
sessionWorktreePath(request.repoId, this.baseDir, worker?.sessionCheckout ? undefined : request.workerId);
|
|
418
|
+
if (!review?.workspace || !existsSync(review.workspace) || !existsSync(path) || realpathSync(path) !== realpathSync(review.workspace))
|
|
419
|
+
throw new Error('The configured workspace changed since this turn. Restore the reviewed workspace before continuing.');
|
|
420
|
+
}
|
|
421
|
+
}
|
|
@@ -8,27 +8,29 @@ export interface Workspace {
|
|
|
8
8
|
/** The branch commits land on. `HEAD` when the in-place checkout is detached. */
|
|
9
9
|
branch: string;
|
|
10
10
|
mode: WorkspaceMode;
|
|
11
|
+
/** Variables the turn's agent runs with, such as the worktree's port block. */
|
|
12
|
+
env?: Record<string, string>;
|
|
11
13
|
}
|
|
12
|
-
/** The stable branch name for a coding session.
|
|
13
|
-
* a
|
|
14
|
-
* subtask's id), so N workers on one repo hold N isolated branches.
|
|
14
|
+
/** The stable branch name for a coding session. The repository's main session is
|
|
15
|
+
* `lucid/<repo>`; a worktree gets `wt/<repo>/<workerId>`.
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* exclusive (the D/F conflict). Keeping workers under `fleet/` leaves the bare
|
|
20
|
-
* `lucid/<repo>` — the classic single session AND the fleet's integration target,
|
|
21
|
-
* the one branch a fleet PR opens from — untouched. `workerId` absent → the classic
|
|
22
|
-
* branch, byte-for-byte as before. */
|
|
17
|
+
* Worktrees live under their own `wt/` namespace instead of `lucid/<repo>/…` because a git
|
|
18
|
+
* ref can't be both a leaf and a directory, so `lucid/<repo>` and `lucid/<repo>/<workerId>`
|
|
19
|
+
* cannot both exist. */
|
|
23
20
|
export declare function sessionBranch(repoId: string, workerId?: string): string;
|
|
24
|
-
/** The stable
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* default root (tests point it at a temp dir); `workerId` absent → the classic path. */
|
|
21
|
+
/** The stable folder for a coding session (constant across turns, so `--resume` resolves).
|
|
22
|
+
* The main session lives at `<base>/<repo>`; a worktree at `<base>/wt/<repo>/<workerId>`, a
|
|
23
|
+
* sibling of it and never nested inside it (which would put a checkout within a checkout).
|
|
24
|
+
* `baseDir` overrides the default root (tests point it at a temp dir). */
|
|
29
25
|
export declare function sessionWorktreePath(repoId: string, baseDir?: string, workerId?: string): string;
|
|
30
26
|
/** The branch checked out in `repoRoot`, or `HEAD` when detached. */
|
|
31
27
|
export declare function currentBranch(repoRoot: string): Promise<string>;
|
|
28
|
+
export declare function workspaceBranchExists(repoRoot: string, repoId: string, workerId?: string): Promise<boolean>;
|
|
29
|
+
/** Resolve the fetched remote base without changing the existing checkout. */
|
|
30
|
+
export declare function workspaceBase(repoRoot: string, configured?: string): Promise<{
|
|
31
|
+
ref: string;
|
|
32
|
+
sha: string;
|
|
33
|
+
}>;
|
|
32
34
|
/**
|
|
33
35
|
* How many commits this worktree's HEAD carries that `base` doesn't.
|
|
34
36
|
*
|
|
@@ -62,27 +64,14 @@ export declare function githubWebUrlFromRemote(raw: string): string | undefined;
|
|
|
62
64
|
* `git remote` rather than `gh` so it needs no auth and works even when `gh` is absent — the phone
|
|
63
65
|
* appends `/pulls`, `/issues`, `/projects` to jump straight there. */
|
|
64
66
|
export declare function repoWebUrl(repoRoot: string): Promise<string | undefined>;
|
|
65
|
-
/**
|
|
66
|
-
* Prepare the workspace for a coding turn.
|
|
67
|
-
*
|
|
68
|
-
* `worktree` (default): ensure the persistent worktree for this repo's session exists
|
|
69
|
-
* on its `lucid/<repoId>` branch, at a STABLE path so Claude Code's `--resume` resolves
|
|
70
|
-
* across turns. `fresh: true` (a new session — no resume) resets the branch and worktree
|
|
71
|
-
* to HEAD, discarding any prior session's state. Otherwise the existing worktree is
|
|
72
|
-
* reused as-is so prior turns' commits (files) carry forward; if it's missing (first
|
|
73
|
-
* turn, or pruned), it's created off HEAD.
|
|
74
|
-
*
|
|
75
|
-
* `in-place` (#121): the user's own checkout, on its live branch, uncommitted work and
|
|
76
|
-
* all — the point of the mode is that Lucid continues from where the user left off, so
|
|
77
|
-
* `fresh` resets NOTHING here. It would mean discarding their work.
|
|
78
|
-
*/
|
|
67
|
+
/** Resolve a persistent workspace. Provider session changes never reset its files. */
|
|
79
68
|
export declare function ensureWorkspace(repoRoot: string, repoId: string, opts?: {
|
|
80
69
|
mode?: WorkspaceMode;
|
|
70
|
+
/** Legacy callers may pass this; conversation resets never reset a workspace. */
|
|
81
71
|
fresh?: boolean;
|
|
72
|
+
startPoint?: string;
|
|
82
73
|
baseDir?: string;
|
|
83
|
-
/**
|
|
84
|
-
* worktree/branch so N workers run in parallel on one repo. Absent → the classic
|
|
85
|
-
* single session, unchanged. */
|
|
74
|
+
/** Present → that worktree's own folder and branch. Absent → the main session. */
|
|
86
75
|
workerId?: string;
|
|
87
76
|
}): Promise<Workspace>;
|
|
88
77
|
/**
|
|
@@ -146,4 +135,55 @@ export declare function commitWorkspace(ws: Workspace, message: string, paths: s
|
|
|
146
135
|
export declare function removeWorktree(repoRoot: string, ws: Workspace, opts?: {
|
|
147
136
|
keepBranch?: boolean;
|
|
148
137
|
}): Promise<void>;
|
|
138
|
+
/** Where an archived worker's files are parked. Under `refs/lucid/`, so no branch or push sees it. */
|
|
139
|
+
export declare function archivedWorktreeRef(workerId: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* Free an archived worker's folder. Its full working state (tracked, staged and untracked,
|
|
142
|
+
* gitignored files excluded) is parked first as a commit on top of the worktree's HEAD, so
|
|
143
|
+
* uncommitted work survives. The branch stays. Throws before removing anything if the
|
|
144
|
+
* snapshot cannot be written.
|
|
145
|
+
*/
|
|
146
|
+
export declare function archiveWorktree(repoRoot: string, ws: Workspace, workerId: string, opts?: {
|
|
147
|
+
deleteBranch?: boolean;
|
|
148
|
+
}): Promise<void>;
|
|
149
|
+
/** The commit an archived worker's branch pointed at, for re-creating a branch deleted on archive. */
|
|
150
|
+
export declare function archivedHead(repoRoot: string, workerId: string): Promise<string | undefined>;
|
|
151
|
+
/**
|
|
152
|
+
* What deleting an archived worker would lose: commits on its branch (or, when the branch was
|
|
153
|
+
* deleted on archive, on the commit its snapshot was taken from) that are in none of `baseRefs`,
|
|
154
|
+
* the remote default branch or the branch's own remote copy, plus whether the snapshot holds
|
|
155
|
+
* files that were never committed.
|
|
156
|
+
*
|
|
157
|
+
* A commit whose change is already in the base under another sha does not count, so a branch
|
|
158
|
+
* that was rebase-merged reads as merged. A squash merge cannot be recognised this way and
|
|
159
|
+
* still counts. Remote refs are refreshed first when anything looks unmerged, since a pull
|
|
160
|
+
* request merged on GitHub is only visible after a fetch; offline, the last fetched state is used.
|
|
161
|
+
*/
|
|
162
|
+
export declare function unmergedArchivedWork(repoRoot: string, workerId: string, branch: string, baseRefs?: (string | undefined)[]): Promise<{
|
|
163
|
+
commits: number;
|
|
164
|
+
uncommitted: boolean;
|
|
165
|
+
}>;
|
|
166
|
+
/** Remove what an archived worker left in the repository: its local branch, if it still has one,
|
|
167
|
+
* and its snapshot. The remote branch is not touched. */
|
|
168
|
+
export declare function deleteArchivedWorktree(repoRoot: string, workerId: string, branch: string): Promise<void>;
|
|
169
|
+
/** Per-file added and removed line counts for everything in a folder that differs from `base`,
|
|
170
|
+
* committed or not. Tracked files only; a binary file counts as zero lines. */
|
|
171
|
+
export declare function numstatSince(path: string, base: string): Promise<Map<string, [added: number, removed: number]>>;
|
|
172
|
+
/** What changed between two readings of {@link numstatSince} taken against the same base: the
|
|
173
|
+
* turn's own work, with whatever was already uncommitted when it started taken out. */
|
|
174
|
+
export declare function turnChangeCounts(before: Map<string, [number, number]>, after: Map<string, [number, number]>): {
|
|
175
|
+
added: number;
|
|
176
|
+
removed: number;
|
|
177
|
+
files: string[];
|
|
178
|
+
} | undefined;
|
|
179
|
+
/** The commit checked out in a folder. */
|
|
180
|
+
export declare function headSha(path: string): Promise<string>;
|
|
181
|
+
/**
|
|
182
|
+
* Put an archived worker's uncommitted files back into its re-created worktree. They return
|
|
183
|
+
* unstaged. If the branch moved while the worker was archived the snapshot no longer fits, so
|
|
184
|
+
* it is left under its ref for a manual `git restore --source` and nothing is overwritten.
|
|
185
|
+
*/
|
|
186
|
+
export declare function restoreArchivedFiles(repoRoot: string, ws: Workspace, workerId: string): Promise<void>;
|
|
187
|
+
/** A review can inspect tracked changes without staging or reading unrelated untracked files. */
|
|
188
|
+
export declare function reviewDiff(ws: Workspace): Promise<string>;
|
|
149
189
|
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/coding/worktree.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAStD;;kEAEkE;AAClE,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/coding/worktree.ts"],"names":[],"mappings":"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"}
|