@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
package/src/coding/conduct.ts
DELETED
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
import type { AgentExecutor } from '@lucidity/runtime';
|
|
2
|
-
import type { FleetPlan, HarnessImage, WorkerStatus } from '@lucidity/shared';
|
|
3
|
-
import type { RepoEntry } from '../config.js';
|
|
4
|
-
import { resolveRepo } from './repos.js';
|
|
5
|
-
import { isAbortError } from '../streamDeadline.js';
|
|
6
|
-
import {
|
|
7
|
-
commitSubjects,
|
|
8
|
-
commitsAhead,
|
|
9
|
-
currentBranch,
|
|
10
|
-
removeWorktree,
|
|
11
|
-
sessionBranch,
|
|
12
|
-
sessionWorktreePath,
|
|
13
|
-
} from './worktree.js';
|
|
14
|
-
import { buildConductPlanPrompt, parseFleetPlan } from './fleetPlan.js';
|
|
15
|
-
import { createFleetTasks, syncWorkerStatus } from './fleetTasks.js';
|
|
16
|
-
import { openFleetPr, workerPrSummary, type FleetPrResult } from './openFleetPr.js';
|
|
17
|
-
import { runCodeTurn, type CodeTurnRequest, type RunCodeTurnDeps } from './runCodeTurn.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The conductor: one Lucid "lead" that decomposes a goal, fans it out to isolated worker
|
|
21
|
-
* worktrees, and integrates them back onto lucid/<repo> in order. Daemon-side authority — the
|
|
22
|
-
* daemon owns every worker's resume handle and its lane; the phone is a thin client that sees
|
|
23
|
-
* a plan, approves it, then watches the fleet.
|
|
24
|
-
*
|
|
25
|
-
* Two phases over one turn. `plan` runs a read-only lead turn to produce a FleetPlan (streamed
|
|
26
|
-
* back as a fleet_plan event; nothing is created, so a discarded plan leaves no trace). `run`
|
|
27
|
-
* takes the approved plan and: creates the task graph (worker = subtask), dispatches the workers
|
|
28
|
-
* in parallel up to a cap (isolated worktrees make that safe), then integrates sequentially in
|
|
29
|
-
* merge order — the one place overlap can bite. Each worker's own code frames stream under
|
|
30
|
-
* `requestId === workerId`, so a worker reuses the entire existing code-turn pipeline; this
|
|
31
|
-
* layer only adds the fleet-level events (plan, worker_status, conflict, done).
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
export interface ConductTurnRequest {
|
|
35
|
-
id: string;
|
|
36
|
-
repoId: string;
|
|
37
|
-
phase: 'plan' | 'run' | 'setup' | 'integrate';
|
|
38
|
-
prompt: string;
|
|
39
|
-
images?: HarnessImage[];
|
|
40
|
-
plan?: FleetPlan;
|
|
41
|
-
resume?: string;
|
|
42
|
-
/** Skip the dogfood task graph (quick incremental spawn — the fleet UI tracks it anyway). */
|
|
43
|
-
ephemeral?: boolean;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type Api = { request<T>(endpoint: string, options?: RequestInit): Promise<T> };
|
|
47
|
-
|
|
48
|
-
export interface RunConductTurnDeps {
|
|
49
|
-
repos: RepoEntry[];
|
|
50
|
-
executor: AgentExecutor;
|
|
51
|
-
onWorkerApproval?: (requestId: string, approval: import('@lucidity/runtime').ExecutorApproval) => Promise<boolean>;
|
|
52
|
-
onEnd?: (requestId: string) => void;
|
|
53
|
-
send: (obj: unknown) => void;
|
|
54
|
-
signal?: AbortSignal;
|
|
55
|
-
model?: string;
|
|
56
|
-
effort?: string;
|
|
57
|
-
/** Task API for the dogfood (goal + subtasks). Absent → tasks are skipped, fleet still runs. */
|
|
58
|
-
api?: Api;
|
|
59
|
-
/** Project the fleet's tasks land in. Absent → the Inbox (projectId null). */
|
|
60
|
-
projectId?: string | null;
|
|
61
|
-
/** Default parallel-worker cap when the plan doesn't set one (quota guard). */
|
|
62
|
-
maxParallel?: number;
|
|
63
|
-
/** Worktree base override (tests point it at a temp dir). */
|
|
64
|
-
baseDir?: string;
|
|
65
|
-
/** Seam: run one worker's coding turn. Defaults to {@link runCodeTurn}. */
|
|
66
|
-
runWorker?: (req: CodeTurnRequest, deps: RunCodeTurnDeps) => Promise<void>;
|
|
67
|
-
/** Seam: open one worker's PR (push its branch + open/reuse a PR). Defaults to {@link openFleetPr}. */
|
|
68
|
-
openPr?: typeof openFleetPr;
|
|
69
|
-
/** Seam: how many commits a worker's branch carries. Defaults to {@link commitsAhead}. */
|
|
70
|
-
commitsAhead?: typeof commitsAhead;
|
|
71
|
-
/** Seam: the subjects of those commits, for the PR title. Defaults to {@link commitSubjects}. */
|
|
72
|
-
commitSubjects?: typeof commitSubjects;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const DEFAULT_MAX_PARALLEL = 2;
|
|
76
|
-
|
|
77
|
-
function msg(e: unknown): string {
|
|
78
|
-
return e instanceof Error ? e.message : String(e);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Count +/- lines and files in a unified diff, for a worker card's "+N −M". */
|
|
82
|
-
export function diffStat(diff: string): { added: number; removed: number; files: number } {
|
|
83
|
-
let added = 0;
|
|
84
|
-
let removed = 0;
|
|
85
|
-
let files = 0;
|
|
86
|
-
for (const line of diff.split('\n')) {
|
|
87
|
-
if (line.startsWith('+++') || line.startsWith('---')) continue;
|
|
88
|
-
if (line.startsWith('diff --git')) files++;
|
|
89
|
-
else if (line.startsWith('+')) added++;
|
|
90
|
-
else if (line.startsWith('-')) removed++;
|
|
91
|
-
}
|
|
92
|
-
return { added, removed, files };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** Run `fn` over `items` with at most `cap` in flight. */
|
|
96
|
-
async function runWithCap<T>(
|
|
97
|
-
items: T[],
|
|
98
|
-
cap: number,
|
|
99
|
-
fn: (item: T) => Promise<void>,
|
|
100
|
-
): Promise<void> {
|
|
101
|
-
const queue = [...items];
|
|
102
|
-
const lanes = Array.from(
|
|
103
|
-
{ length: Math.max(1, Math.min(cap, items.length || 1)) },
|
|
104
|
-
async () => {
|
|
105
|
-
for (let item = queue.shift(); item !== undefined; item = queue.shift()) {
|
|
106
|
-
await fn(item);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
);
|
|
110
|
-
await Promise.all(lanes);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export async function runConductTurn(
|
|
114
|
-
req: ConductTurnRequest,
|
|
115
|
-
deps: RunConductTurnDeps,
|
|
116
|
-
): Promise<void> {
|
|
117
|
-
const repo = resolveRepo(req.repoId, deps.repos);
|
|
118
|
-
if (!repo) {
|
|
119
|
-
deps.send({
|
|
120
|
-
type: 'error',
|
|
121
|
-
requestId: req.id,
|
|
122
|
-
message: `Repo "${req.repoId}" isn't on this daemon's allowlist.`,
|
|
123
|
-
});
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (!deps.executor.runStream) {
|
|
127
|
-
deps.send({
|
|
128
|
-
type: 'error',
|
|
129
|
-
requestId: req.id,
|
|
130
|
-
message: 'The conductor needs a streaming executor.',
|
|
131
|
-
});
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (req.phase === 'plan') return planPhase(req, deps, repo.root);
|
|
136
|
-
if (req.phase === 'setup') return setupPhase(req, deps);
|
|
137
|
-
if (req.phase === 'integrate') return integratePhase(req, deps, repo.root);
|
|
138
|
-
return runPhase(req, deps, repo.root);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Design-first flow: materialize an approved plan WITHOUT writing any code. Create the task graph
|
|
143
|
-
* (worker = subtask) and announce each worker as `queued`, then finish. The phone drives each
|
|
144
|
-
* worker from here with `code` turns carrying its `workerId` (a conversation, in the worker's own
|
|
145
|
-
* `fleet/<repo>/<workerId>` worktree), and merges with a later `integrate`. The counterpart to
|
|
146
|
-
* `run`, which instead codes everything itself.
|
|
147
|
-
*/
|
|
148
|
-
async function setupPhase(
|
|
149
|
-
req: ConductTurnRequest,
|
|
150
|
-
deps: RunConductTurnDeps,
|
|
151
|
-
): Promise<void> {
|
|
152
|
-
const plan = req.plan;
|
|
153
|
-
if (!plan) {
|
|
154
|
-
deps.send({ type: 'error', requestId: req.id, message: 'Setup needs an approved plan.' });
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
let parentTaskId: string | undefined;
|
|
158
|
-
if (deps.api) {
|
|
159
|
-
try {
|
|
160
|
-
({ parentTaskId } = await createFleetTasks(deps.api, plan, { projectId: deps.projectId }));
|
|
161
|
-
} catch (err) {
|
|
162
|
-
console.error(`[conduct] couldn't create the fleet task graph: ${msg(err)}`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
deps.send({
|
|
166
|
-
type: 'fleet_plan',
|
|
167
|
-
requestId: req.id,
|
|
168
|
-
plan: { ...plan, ...(parentTaskId ? { parentTaskId } : {}) },
|
|
169
|
-
});
|
|
170
|
-
for (const w of plan.workers) {
|
|
171
|
-
deps.send({ type: 'worker_status', requestId: req.id, workerId: w.workerId, status: 'queued' });
|
|
172
|
-
if (deps.api) void syncWorkerStatus(deps.api, w.workerId, 'queued');
|
|
173
|
-
}
|
|
174
|
-
deps.send({
|
|
175
|
-
type: 'done',
|
|
176
|
-
requestId: req.id,
|
|
177
|
-
text: `Fleet set up: ${plan.workers.length} worker${plan.workers.length === 1 ? '' : 's'} ready to brief.`,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** Design-first flow: deliver the plan's workers as their own PRs on the user's "Deliver" tap.
|
|
182
|
-
* Same per-feature delivery + cleanup as the tail of `run`, run on demand instead. */
|
|
183
|
-
async function integratePhase(
|
|
184
|
-
req: ConductTurnRequest,
|
|
185
|
-
deps: RunConductTurnDeps,
|
|
186
|
-
repoRoot: string,
|
|
187
|
-
): Promise<void> {
|
|
188
|
-
const plan = req.plan;
|
|
189
|
-
if (!plan) {
|
|
190
|
-
deps.send({ type: 'error', requestId: req.id, message: 'Deliver needs the fleet plan.' });
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
const sync = (workerId: string, status: WorkerStatus): Promise<void> =>
|
|
194
|
-
deps.api ? syncWorkerStatus(deps.api, workerId, status) : Promise.resolve();
|
|
195
|
-
await deliverAndReport(req, deps, repoRoot, plan, sync);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/** Read-only lead turn → a FleetPlan, streamed back as a fleet_plan event. Creates nothing. */
|
|
199
|
-
async function planPhase(
|
|
200
|
-
req: ConductTurnRequest,
|
|
201
|
-
deps: RunConductTurnDeps,
|
|
202
|
-
repoRoot: string,
|
|
203
|
-
): Promise<void> {
|
|
204
|
-
let text = '';
|
|
205
|
-
let sessionId: string | undefined;
|
|
206
|
-
try {
|
|
207
|
-
for await (const ev of deps.executor.runStream!({
|
|
208
|
-
requestId: req.id,
|
|
209
|
-
userPrompt: buildConductPlanPrompt(req.prompt),
|
|
210
|
-
cwd: repoRoot,
|
|
211
|
-
// Auto mode lets the lead READ the repo (ls/grep/cat) to inform the split; a mutating
|
|
212
|
-
// tool has no approver here, so the prompt tells it to plan only, never edit.
|
|
213
|
-
// Read-only: the lead may ls/grep/cat the repo to inform the split but must never edit
|
|
214
|
-
// the user's live checkout. `plan` mode blocks every mutating tool, so even an off-script
|
|
215
|
-
// or prompt-injected planning turn can't touch the working tree.
|
|
216
|
-
permissionMode: 'plan',
|
|
217
|
-
model: deps.model,
|
|
218
|
-
effort: deps.effort,
|
|
219
|
-
resume: req.resume,
|
|
220
|
-
signal: deps.signal,
|
|
221
|
-
})) {
|
|
222
|
-
if (ev.type === 'session') {
|
|
223
|
-
deps.send({ type: 'session', requestId: req.id, sessionId: ev.sessionId });
|
|
224
|
-
} else if (ev.type === 'delta') {
|
|
225
|
-
text += ev.text;
|
|
226
|
-
deps.send({ type: 'delta', requestId: req.id, text: ev.text });
|
|
227
|
-
} else if (ev.type === 'tool_call') {
|
|
228
|
-
deps.send({ type: 'tool_call', requestId: req.id, name: ev.name, phase: ev.phase });
|
|
229
|
-
} else if (ev.type === 'done') {
|
|
230
|
-
sessionId = ev.sessionId;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
} catch (err) {
|
|
234
|
-
if (isAbortError(err)) return;
|
|
235
|
-
deps.send({ type: 'error', requestId: req.id, message: msg(err) });
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
let plan: FleetPlan;
|
|
240
|
-
try {
|
|
241
|
-
plan = parseFleetPlan(text, { goal: req.prompt });
|
|
242
|
-
} catch (err) {
|
|
243
|
-
deps.send({
|
|
244
|
-
type: 'error',
|
|
245
|
-
requestId: req.id,
|
|
246
|
-
message: `Couldn't turn that into a fan-out plan: ${msg(err)}`,
|
|
247
|
-
});
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
deps.send({ type: 'fleet_plan', requestId: req.id, plan });
|
|
252
|
-
deps.send({ type: 'done', requestId: req.id, text, sessionId });
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/** Execute an approved plan: create tasks, run workers, integrate, report. */
|
|
256
|
-
async function runPhase(
|
|
257
|
-
req: ConductTurnRequest,
|
|
258
|
-
deps: RunConductTurnDeps,
|
|
259
|
-
repoRoot: string,
|
|
260
|
-
): Promise<void> {
|
|
261
|
-
const plan = req.plan;
|
|
262
|
-
if (!plan) {
|
|
263
|
-
deps.send({
|
|
264
|
-
type: 'error',
|
|
265
|
-
requestId: req.id,
|
|
266
|
-
message: 'A run needs an approved plan.',
|
|
267
|
-
});
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const emitStatus = (
|
|
272
|
-
workerId: string,
|
|
273
|
-
status: WorkerStatus,
|
|
274
|
-
extra?: { detail?: string; diffStat?: { added: number; removed: number; files: number } },
|
|
275
|
-
) =>
|
|
276
|
-
deps.send({
|
|
277
|
-
type: 'worker_status',
|
|
278
|
-
requestId: req.id,
|
|
279
|
-
workerId,
|
|
280
|
-
status,
|
|
281
|
-
...(extra?.detail ? { detail: extra.detail } : {}),
|
|
282
|
-
...(extra?.diffStat ? { diffStat: extra.diffStat } : {}),
|
|
283
|
-
});
|
|
284
|
-
const sync = (workerId: string, status: WorkerStatus): Promise<void> =>
|
|
285
|
-
deps.api && !req.ephemeral ? syncWorkerStatus(deps.api, workerId, status) : Promise.resolve();
|
|
286
|
-
|
|
287
|
-
// Dogfood: the goal + one subtask per worker (worker = subtask). Skipped for ephemeral spawns so
|
|
288
|
-
// quick incremental tasks don't spam the board. Best-effort; a fleet still runs if it can't write.
|
|
289
|
-
let parentTaskId: string | undefined;
|
|
290
|
-
if (deps.api && !req.ephemeral) {
|
|
291
|
-
try {
|
|
292
|
-
({ parentTaskId } = await createFleetTasks(deps.api, plan, {
|
|
293
|
-
projectId: deps.projectId,
|
|
294
|
-
}));
|
|
295
|
-
} catch (err) {
|
|
296
|
-
console.error(`[conduct] couldn't create the fleet task graph: ${msg(err)}`);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
// Echo the plan with the parent id so the phone can link the Fleet board to the goal task.
|
|
300
|
-
deps.send({
|
|
301
|
-
type: 'fleet_plan',
|
|
302
|
-
requestId: req.id,
|
|
303
|
-
plan: { ...plan, ...(parentTaskId ? { parentTaskId } : {}) },
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
const runWorker = deps.runWorker ?? runCodeTurn;
|
|
307
|
-
const cap = plan.maxParallel ?? deps.maxParallel ?? DEFAULT_MAX_PARALLEL;
|
|
308
|
-
const diffStats = new Map<string, { added: number; removed: number; files: number }>();
|
|
309
|
-
const failed = new Set<string>();
|
|
310
|
-
|
|
311
|
-
await runWithCap(plan.workers, cap, async (w) => {
|
|
312
|
-
// A cancel mid-fleet drops the workers still queued behind the cap — we don't spin up new
|
|
313
|
-
// worktrees for a run the user has already stopped.
|
|
314
|
-
if (deps.signal?.aborted) return;
|
|
315
|
-
emitStatus(w.workerId, 'working');
|
|
316
|
-
await sync(w.workerId, 'working');
|
|
317
|
-
|
|
318
|
-
// The worker's code frames already carry requestId === workerId (we set the turn id to it),
|
|
319
|
-
// so we forward them verbatim — the phone routes them to the worker's lane through the
|
|
320
|
-
// existing code-turn rendering. We only peek to capture the diff size and any error.
|
|
321
|
-
let sawError = false;
|
|
322
|
-
let wasCancelled = false;
|
|
323
|
-
const workerSend = (obj: unknown) => {
|
|
324
|
-
const o = obj as { type?: string; diff?: string };
|
|
325
|
-
if (o?.type === 'code_result' && typeof o.diff === 'string') {
|
|
326
|
-
diffStats.set(w.workerId, diffStat(o.diff));
|
|
327
|
-
}
|
|
328
|
-
if (o?.type === 'error') sawError = true;
|
|
329
|
-
if (o?.type === 'cancelled') { wasCancelled = true; sawError = true; }
|
|
330
|
-
deps.send(obj);
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
try {
|
|
334
|
-
await runWorker(
|
|
335
|
-
{
|
|
336
|
-
id: w.workerId,
|
|
337
|
-
repoId: req.repoId,
|
|
338
|
-
workerId: w.workerId,
|
|
339
|
-
prompt: w.brief,
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
repos: deps.repos,
|
|
343
|
-
executor: deps.executor,
|
|
344
|
-
onApproval: deps.onWorkerApproval ? (approval) => deps.onWorkerApproval!(w.workerId, approval) : undefined,
|
|
345
|
-
send: workerSend,
|
|
346
|
-
signal: deps.signal,
|
|
347
|
-
model: deps.model,
|
|
348
|
-
effort: deps.effort,
|
|
349
|
-
baseDir: deps.baseDir,
|
|
350
|
-
},
|
|
351
|
-
);
|
|
352
|
-
} catch (err) {
|
|
353
|
-
if (!isAbortError(err)) sawError = true;
|
|
354
|
-
} finally { deps.onEnd?.(w.workerId); }
|
|
355
|
-
|
|
356
|
-
if (sawError) {
|
|
357
|
-
failed.add(w.workerId);
|
|
358
|
-
emitStatus(w.workerId, 'failed', wasCancelled ? { detail: 'Stopped' } : undefined);
|
|
359
|
-
await sync(w.workerId, 'failed');
|
|
360
|
-
} else {
|
|
361
|
-
emitStatus(w.workerId, 'review', { diffStat: diffStats.get(w.workerId) });
|
|
362
|
-
await sync(w.workerId, 'review');
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
// A cancel during the worker phase must stop here — never mutate git or the backlog for a
|
|
367
|
-
// run the user halted. (Without this, integration would still reset lucid/<repo> and mark
|
|
368
|
-
// every subtask completed.)
|
|
369
|
-
if (deps.signal?.aborted) return;
|
|
370
|
-
|
|
371
|
-
await deliverAndReport(req, deps, repoRoot, plan, sync, failed);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Per-feature delivery: push each successful worker's OWN branch and open its OWN PR against the
|
|
376
|
-
* base branch, then reclaim its worktree (keeping the branch — the PR points at it). Independent
|
|
377
|
-
* features become independent, separately-reviewable PRs instead of one combined branch, which is
|
|
378
|
-
* how you actually want a set of unrelated changes to land. No cross-worker merge, so nothing
|
|
379
|
-
* conflicts locally (any overlap surfaces when the PRs are merged on GitHub, per-PR, the user's
|
|
380
|
-
* call). Reports a `worker_pr` per delivered worker + `worker_status: merged`, then `fleet_done`
|
|
381
|
-
* (delivered/total) + `done`. Shared by the auto `run` (with the run's `failed` set) and the
|
|
382
|
-
* on-demand `integrate` phase. A failed/no-commit worker can't open a PR — it's skipped and its
|
|
383
|
-
* `worker_pr` carries the reason.
|
|
384
|
-
*/
|
|
385
|
-
async function deliverAndReport(
|
|
386
|
-
req: ConductTurnRequest,
|
|
387
|
-
deps: RunConductTurnDeps,
|
|
388
|
-
repoRoot: string,
|
|
389
|
-
plan: FleetPlan,
|
|
390
|
-
sync: (workerId: string, status: WorkerStatus) => Promise<void>,
|
|
391
|
-
failed?: Set<string>,
|
|
392
|
-
): Promise<void> {
|
|
393
|
-
const openPr = deps.openPr ?? openFleetPr;
|
|
394
|
-
// Base = the branch each worker forked from (repo HEAD), so a worker's PR is only its own work,
|
|
395
|
-
// not everything the checkout is ahead of the remote default by.
|
|
396
|
-
const base = await currentBranch(repoRoot).then(
|
|
397
|
-
(b) => (b && b !== 'HEAD' ? b : undefined),
|
|
398
|
-
() => undefined,
|
|
399
|
-
);
|
|
400
|
-
const toDeliver = plan.workers.filter((w) => !failed?.has(w.workerId));
|
|
401
|
-
let delivered = 0;
|
|
402
|
-
|
|
403
|
-
for (const w of toDeliver) {
|
|
404
|
-
if (deps.signal?.aborted) return;
|
|
405
|
-
const worktree = sessionWorktreePath(req.repoId, deps.baseDir, w.workerId);
|
|
406
|
-
const branch = sessionBranch(req.repoId, w.workerId);
|
|
407
|
-
// A worker that stopped to ask you something never committed anything: its branch still sits
|
|
408
|
-
// on base. Delivering it opens an empty PR that fails, and parks it under DELIVERED wearing
|
|
409
|
-
// that error while it's actually waiting for an answer. Leave it in review, keep its worktree
|
|
410
|
-
// (a steer continues in it), and say nothing — it isn't done, so it isn't delivered.
|
|
411
|
-
if (base && (await (deps.commitsAhead ?? commitsAhead)(worktree, base)) === 0) {
|
|
412
|
-
deps.send({
|
|
413
|
-
type: 'worker_status',
|
|
414
|
-
requestId: req.id,
|
|
415
|
-
workerId: w.workerId,
|
|
416
|
-
status: 'review',
|
|
417
|
-
detail: 'Waiting on you — nothing committed yet.',
|
|
418
|
-
});
|
|
419
|
-
void sync(w.workerId, 'review');
|
|
420
|
-
continue;
|
|
421
|
-
}
|
|
422
|
-
// A worker's commit subjects are the only account of what it actually CHANGED, and they're
|
|
423
|
-
// on its branch in both delivery paths (#308): a spawn delivering itself at the tail of its
|
|
424
|
-
// own run, and a steered worker delivered later from the phone in a different turn, possibly
|
|
425
|
-
// a different daemon process. Nothing from the run survives that second path, git does.
|
|
426
|
-
const subjects = base ? await (deps.commitSubjects ?? commitSubjects)(worktree, base) : [];
|
|
427
|
-
const pr: FleetPrResult = await openPr(
|
|
428
|
-
worktree,
|
|
429
|
-
branch,
|
|
430
|
-
workerPrSummary(w.title, w.brief, subjects),
|
|
431
|
-
base,
|
|
432
|
-
).catch((e) => ({ error: msg(e) }));
|
|
433
|
-
if (pr.url) delivered++;
|
|
434
|
-
deps.send({
|
|
435
|
-
type: 'worker_pr',
|
|
436
|
-
requestId: req.id,
|
|
437
|
-
workerId: w.workerId,
|
|
438
|
-
...(pr.url ? { url: pr.url } : {}),
|
|
439
|
-
...(pr.error ? { error: pr.error } : {}),
|
|
440
|
-
});
|
|
441
|
-
deps.send({ type: 'worker_status', requestId: req.id, workerId: w.workerId, status: 'merged' });
|
|
442
|
-
void sync(w.workerId, 'merged');
|
|
443
|
-
// Reclaim the worktree, KEEP the branch — the open PR points at it.
|
|
444
|
-
await removeWorktree(
|
|
445
|
-
repoRoot,
|
|
446
|
-
{ path: worktree, branch, mode: 'worktree' },
|
|
447
|
-
{ keepBranch: true },
|
|
448
|
-
).catch(() => {});
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
deps.send({
|
|
452
|
-
type: 'fleet_done',
|
|
453
|
-
requestId: req.id,
|
|
454
|
-
delivered,
|
|
455
|
-
total: plan.workers.length,
|
|
456
|
-
});
|
|
457
|
-
deps.send({
|
|
458
|
-
type: 'done',
|
|
459
|
-
requestId: req.id,
|
|
460
|
-
text: `Fleet finished: ${delivered} of ${plan.workers.length} delivered as pull requests.`,
|
|
461
|
-
});
|
|
462
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
import { ensureWorkspace, sessionBranch } from './worktree.js';
|
|
4
|
-
|
|
5
|
-
const exec = promisify(execFile);
|
|
6
|
-
|
|
7
|
-
async function git(cwd: string, args: string[]): Promise<string> {
|
|
8
|
-
const { stdout } = await exec('git', args, { cwd, maxBuffer: 32 * 1024 * 1024 });
|
|
9
|
-
return stdout;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FleetConflict {
|
|
13
|
-
workerId: string;
|
|
14
|
-
/** The files that couldn't merge cleanly. */
|
|
15
|
-
paths: string[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface IntegrationResult {
|
|
19
|
-
/** The branch the workers were integrated onto — the bare `lucid/<repo>` session, which
|
|
20
|
-
* is also where the fleet's single PR opens from. */
|
|
21
|
-
branch: string;
|
|
22
|
-
/** Worker ids that merged cleanly, in the order they landed. */
|
|
23
|
-
merged: string[];
|
|
24
|
-
/** Workers whose branch conflicted; their merge was aborted and left for the user to hand
|
|
25
|
-
* back to the worker as a fresh turn. */
|
|
26
|
-
conflicts: FleetConflict[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Integrate finished workers onto the fleet branch, one at a time in merge order.
|
|
31
|
-
*
|
|
32
|
-
* The integration worktree is the bare repo session (`lucid/<repo>`), reset to HEAD, so the
|
|
33
|
-
* fan-out's result is a single branch cut fresh from where the user started — clean history to
|
|
34
|
-
* open one PR from. Each worker's `fleet/<repo>/<workerId>` branch is merged in; a conflict is
|
|
35
|
-
* caught (not thrown), the merge aborted so the next worker can still land, and reported via
|
|
36
|
-
* `onConflict` so the conductor surfaces it in the feed rather than silently dropping work.
|
|
37
|
-
*
|
|
38
|
-
* Sequential and in order because that's where overlap actually bites: the workers ran in
|
|
39
|
-
* isolated worktrees and never raced each other on disk — only the merge can conflict, and only
|
|
40
|
-
* against what already landed.
|
|
41
|
-
*/
|
|
42
|
-
export async function integrateWorkers(
|
|
43
|
-
repoRoot: string,
|
|
44
|
-
repoId: string,
|
|
45
|
-
workers: { workerId: string; mergeOrder: number }[],
|
|
46
|
-
opts: {
|
|
47
|
-
baseDir?: string;
|
|
48
|
-
onMerged?: (workerId: string) => void;
|
|
49
|
-
onConflict?: (conflict: FleetConflict) => void;
|
|
50
|
-
} = {},
|
|
51
|
-
): Promise<IntegrationResult> {
|
|
52
|
-
const branch = sessionBranch(repoId);
|
|
53
|
-
// Fresh bare session = lucid/<repo> reset to HEAD: the integration target.
|
|
54
|
-
const ws = await ensureWorkspace(repoRoot, repoId, {
|
|
55
|
-
fresh: true,
|
|
56
|
-
baseDir: opts.baseDir,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const ordered = [...workers].sort((a, b) => a.mergeOrder - b.mergeOrder);
|
|
60
|
-
const merged: string[] = [];
|
|
61
|
-
const conflicts: FleetConflict[] = [];
|
|
62
|
-
|
|
63
|
-
for (const w of ordered) {
|
|
64
|
-
const workerBranch = sessionBranch(repoId, w.workerId);
|
|
65
|
-
try {
|
|
66
|
-
await git(ws.path, [
|
|
67
|
-
'merge',
|
|
68
|
-
'--no-ff',
|
|
69
|
-
'-m',
|
|
70
|
-
`Merge fleet worker ${w.workerId}`,
|
|
71
|
-
workerBranch,
|
|
72
|
-
]);
|
|
73
|
-
merged.push(w.workerId);
|
|
74
|
-
opts.onMerged?.(w.workerId);
|
|
75
|
-
} catch {
|
|
76
|
-
// A conflict (or any merge failure): record the unmerged paths, abort so the branch is
|
|
77
|
-
// clean for the next worker, and report. Never fatal — one bad lane can't sink the fleet.
|
|
78
|
-
const unmerged = await git(ws.path, [
|
|
79
|
-
'diff',
|
|
80
|
-
'--name-only',
|
|
81
|
-
'--diff-filter=U',
|
|
82
|
-
]).catch(() => '');
|
|
83
|
-
const paths = unmerged
|
|
84
|
-
.split('\n')
|
|
85
|
-
.map((s) => s.trim())
|
|
86
|
-
.filter(Boolean);
|
|
87
|
-
await git(ws.path, ['merge', '--abort']).catch(() => {});
|
|
88
|
-
const conflict: FleetConflict = { workerId: w.workerId, paths };
|
|
89
|
-
conflicts.push(conflict);
|
|
90
|
-
opts.onConflict?.(conflict);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return { branch, merged, conflicts };
|
|
95
|
-
}
|
package/src/coding/fleetPlan.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { uuidv7 } from 'uuidv7';
|
|
3
|
-
import { FleetPlanSchema, type FleetPlan } from '@lucidity/shared';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The conductor's planning brain, kept pure so it's unit-testable without a model or a repo.
|
|
7
|
-
*
|
|
8
|
-
* A `conduct` `plan` turn asks the lead to decompose a goal into independent workers; this
|
|
9
|
-
* module builds that prompt, parses the lead's JSON answer into a validated {@link FleetPlan}
|
|
10
|
-
* (minting a stable workerId per worker), and derives the owned-path overlaps that become the
|
|
11
|
-
* Fan-out card's ⚠ and the reason a merge order exists. Nothing here runs code or touches git.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** The lead's JSON, before we mint ids — what we ask the model to emit. Lenient on purpose:
|
|
15
|
-
* a missing mergeOrder falls back to array order, so a terse model still yields a usable plan. */
|
|
16
|
-
const RawWorkerSchema = z.object({
|
|
17
|
-
title: z.string().min(1).max(200),
|
|
18
|
-
brief: z.string().min(1).max(8000),
|
|
19
|
-
ownedPaths: z.array(z.string()).max(200).default([]),
|
|
20
|
-
mergeOrder: z.number().int().optional(),
|
|
21
|
-
});
|
|
22
|
-
const RawPlanSchema = z.object({
|
|
23
|
-
workers: z.array(RawWorkerSchema).min(1).max(16),
|
|
24
|
-
maxParallel: z.number().int().positive().max(16).optional(),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export function buildConductPlanPrompt(goal: string): string {
|
|
28
|
-
return [
|
|
29
|
-
'You are the lead engineer of a small fleet of coding agents working in one repository.',
|
|
30
|
-
'Decompose the goal below into independent WORKERS that can each run in its own git worktree.',
|
|
31
|
-
'',
|
|
32
|
-
'Rules:',
|
|
33
|
-
'- Prefer the FEWEST workers that cleanly cover the goal. A goal that is really one coherent',
|
|
34
|
-
' change is ONE worker — do not split for the sake of it.',
|
|
35
|
-
'- Give each worker a set of owned paths (files or directories it may touch). Keep owned',
|
|
36
|
-
' paths DISJOINT between workers wherever you can; two workers that must touch the same file',
|
|
37
|
-
' will be integrated one after another, so note that by giving them different merge orders.',
|
|
38
|
-
'- `mergeOrder` is the order their branches integrate back (lower first). Put a worker whose',
|
|
39
|
-
' work others build on earlier.',
|
|
40
|
-
'',
|
|
41
|
-
'Answer with a short sentence of reasoning, then a single fenced ```json block of the form:',
|
|
42
|
-
'{ "workers": [ { "title": "...", "brief": "the full instruction for this worker",',
|
|
43
|
-
' "ownedPaths": ["path/or/dir", "..."], "mergeOrder": 1 } ] }',
|
|
44
|
-
'',
|
|
45
|
-
`GOAL: ${goal}`,
|
|
46
|
-
].join('\n');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Strip a path down to what it "covers" for overlap purposes — drop a trailing glob/slash. */
|
|
50
|
-
function pathBase(p: string): string {
|
|
51
|
-
return p
|
|
52
|
-
.trim()
|
|
53
|
-
.replace(/\/+$/, '')
|
|
54
|
-
.replace(/\/\*\*?$/, '')
|
|
55
|
-
.replace(/\/+$/, '');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Do two owned-path entries cover any of the same tree — the same file, or one a directory of
|
|
59
|
-
* the other? (`src/config.ts` vs `src/config.ts`; `src` vs `src/config.ts`.) */
|
|
60
|
-
export function pathsOverlap(a: string, b: string): boolean {
|
|
61
|
-
const x = pathBase(a);
|
|
62
|
-
const y = pathBase(b);
|
|
63
|
-
if (!x || !y) return false;
|
|
64
|
-
return x === y || x.startsWith(`${y}/`) || y.startsWith(`${x}/`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Every worker pair whose owned paths intersect, with the offending paths — the Fan-out card's
|
|
68
|
-
* ⚠, and what tells the runner these two must integrate sequentially rather than race a merge. */
|
|
69
|
-
export function detectOverlaps(
|
|
70
|
-
workers: FleetPlan['workers'],
|
|
71
|
-
): FleetPlan['overlaps'] {
|
|
72
|
-
const out: NonNullable<FleetPlan['overlaps']> = [];
|
|
73
|
-
for (let i = 0; i < workers.length; i++) {
|
|
74
|
-
for (let j = i + 1; j < workers.length; j++) {
|
|
75
|
-
const paths: string[] = [];
|
|
76
|
-
for (const pa of workers[i]!.ownedPaths) {
|
|
77
|
-
for (const pb of workers[j]!.ownedPaths) {
|
|
78
|
-
if (pathsOverlap(pa, pb)) paths.push(pathBase(pa));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (paths.length) {
|
|
82
|
-
out.push({
|
|
83
|
-
a: workers[i]!.workerId,
|
|
84
|
-
b: workers[j]!.workerId,
|
|
85
|
-
paths: [...new Set(paths)],
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return out.length ? out : undefined;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** Pull the first JSON object out of the lead's answer — a fenced ```json block if present,
|
|
94
|
-
* else the first balanced `{…}`. Returns the raw string or throws a readable error. */
|
|
95
|
-
function extractJson(text: string): string {
|
|
96
|
-
const fenced = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
97
|
-
if (fenced?.[1]) return fenced[1].trim();
|
|
98
|
-
const start = text.indexOf('{');
|
|
99
|
-
const end = text.lastIndexOf('}');
|
|
100
|
-
if (start !== -1 && end > start) return text.slice(start, end + 1);
|
|
101
|
-
throw new Error('the plan had no JSON block');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Parse the lead's answer into a validated FleetPlan, minting a stable `workerId` (uuidv7) per
|
|
106
|
-
* worker — the id doubles as the fleet subtask's id and the stream id its code frames arrive
|
|
107
|
-
* under. `genId` is injectable so tests get deterministic ids. Throws on unparseable output.
|
|
108
|
-
*/
|
|
109
|
-
export function parseFleetPlan(
|
|
110
|
-
modelText: string,
|
|
111
|
-
opts: { goal: string; genId?: () => string },
|
|
112
|
-
): FleetPlan {
|
|
113
|
-
const genId = opts.genId ?? uuidv7;
|
|
114
|
-
const raw = RawPlanSchema.parse(JSON.parse(extractJson(modelText)));
|
|
115
|
-
const workers = raw.workers.map((w, i) => ({
|
|
116
|
-
workerId: genId(),
|
|
117
|
-
title: w.title,
|
|
118
|
-
brief: w.brief,
|
|
119
|
-
ownedPaths: w.ownedPaths,
|
|
120
|
-
mergeOrder: w.mergeOrder ?? i + 1,
|
|
121
|
-
}));
|
|
122
|
-
const plan: FleetPlan = {
|
|
123
|
-
goal: opts.goal,
|
|
124
|
-
workers,
|
|
125
|
-
overlaps: detectOverlaps(workers),
|
|
126
|
-
maxParallel: raw.maxParallel,
|
|
127
|
-
};
|
|
128
|
-
// Validate the assembled plan against the wire schema before it leaves the daemon.
|
|
129
|
-
return FleetPlanSchema.parse(plan);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Workers in the order their branches should integrate (lower mergeOrder first, stable). */
|
|
133
|
-
export function integrationOrder(plan: FleetPlan): FleetPlan['workers'] {
|
|
134
|
-
return [...plan.workers].sort((a, b) => a.mergeOrder - b.mergeOrder);
|
|
135
|
-
}
|