@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/dist/room/turnQueue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdirSync, readFileSync, readdirSync,
|
|
1
|
+
import { mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { HarnessRequestSchema } from '@lucidity/shared';
|
|
4
4
|
export function turnLane(req) {
|
|
@@ -17,6 +17,8 @@ export class DurableTurnQueue {
|
|
|
17
17
|
constructor(deps) {
|
|
18
18
|
this.deps = deps;
|
|
19
19
|
mkdirSync(deps.dir, { recursive: true, mode: 0o700 });
|
|
20
|
+
for (const entry of deps.logs.runtime.list('queue'))
|
|
21
|
+
this.entries.set(entry.request.id, entry);
|
|
20
22
|
for (const name of readdirSync(deps.dir)
|
|
21
23
|
.filter((name) => name.endsWith('.json'))
|
|
22
24
|
.sort()) {
|
|
@@ -26,6 +28,12 @@ export class DurableTurnQueue {
|
|
|
26
28
|
unlinkSync(join(deps.dir, name));
|
|
27
29
|
continue;
|
|
28
30
|
}
|
|
31
|
+
if (this.entries.has(entry.request.id))
|
|
32
|
+
continue;
|
|
33
|
+
this.deps.logs.runtime.set('queue', entry.request.id, entry);
|
|
34
|
+
this.entries.set(entry.request.id, entry);
|
|
35
|
+
}
|
|
36
|
+
for (const entry of this.entries.values()) {
|
|
29
37
|
const parsed = HarnessRequestSchema.parse(entry.request);
|
|
30
38
|
if (parsed.kind !== 'ask' && parsed.kind !== 'code')
|
|
31
39
|
throw new Error('Invalid queued turn');
|
|
@@ -41,7 +49,7 @@ export class DurableTurnQueue {
|
|
|
41
49
|
});
|
|
42
50
|
}
|
|
43
51
|
else {
|
|
44
|
-
this.fail(entry, 'Lucid restarted during this turn. It was not run again. Review
|
|
52
|
+
this.fail(entry, 'Lucid restarted during this turn. It was not run again. Review its work before continuing.', 'interrupted_unknown');
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
else if (entry.state === 'skipped' && !terminal) {
|
|
@@ -53,7 +61,7 @@ export class DurableTurnQueue {
|
|
|
53
61
|
else if (entry.state === 'failed' && !terminal) {
|
|
54
62
|
this.publish(parsed.id, {
|
|
55
63
|
type: 'error',
|
|
56
|
-
message: 'This queued turn could not finish. Review it before resending.',
|
|
64
|
+
...(entry.failure ?? { message: 'This queued turn could not finish. Review it before resending.' }),
|
|
57
65
|
});
|
|
58
66
|
}
|
|
59
67
|
}
|
|
@@ -67,12 +75,7 @@ export class DurableTurnQueue {
|
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
save(entry) {
|
|
70
|
-
|
|
71
|
-
writeFileSync(`${path}.tmp`, JSON.stringify(entry), {
|
|
72
|
-
mode: 0o600,
|
|
73
|
-
flush: true,
|
|
74
|
-
});
|
|
75
|
-
renameSync(`${path}.tmp`, path);
|
|
78
|
+
this.deps.logs.runtime.set('queue', entry.request.id, entry);
|
|
76
79
|
this.entries.set(entry.request.id, entry);
|
|
77
80
|
}
|
|
78
81
|
publish(id, event) {
|
|
@@ -96,15 +99,16 @@ export class DurableTurnQueue {
|
|
|
96
99
|
.find((frame) => typeof frame.sessionId === 'string')?.sessionId;
|
|
97
100
|
return typeof value === 'string' ? value : undefined;
|
|
98
101
|
}
|
|
99
|
-
fail(entry, message) {
|
|
100
|
-
|
|
102
|
+
fail(entry, message, code) {
|
|
103
|
+
const failure = { message, ...(code ? { code } : {}) };
|
|
104
|
+
this.save({ ...entry, state: 'failed', failure });
|
|
101
105
|
if (!this.deps.logs.read(entry.request.id).terminated)
|
|
102
|
-
this.publish(entry.request.id, { type: 'error',
|
|
106
|
+
this.publish(entry.request.id, { type: 'error', ...failure });
|
|
103
107
|
this.wake();
|
|
104
108
|
}
|
|
105
109
|
owns(id) {
|
|
106
110
|
const state = this.entries.get(id)?.state;
|
|
107
|
-
return state === 'queued' || state === 'running' || state === 'steering';
|
|
111
|
+
return state === 'queued' || state === 'held' || state === 'running' || state === 'steering';
|
|
108
112
|
}
|
|
109
113
|
confirm(id) {
|
|
110
114
|
const entry = this.entries.get(id);
|
|
@@ -112,6 +116,7 @@ export class DurableTurnQueue {
|
|
|
112
116
|
this.publish(id, {
|
|
113
117
|
type: 'queue_state',
|
|
114
118
|
state: entry.state === 'running' ? 'running' : 'queued',
|
|
119
|
+
...(entry.blockedBy ? { blockedBy: entry.blockedBy, message: 'Held for review of the interrupted turn.' } : {}),
|
|
115
120
|
});
|
|
116
121
|
}
|
|
117
122
|
enqueue(request) {
|
|
@@ -119,7 +124,7 @@ export class DurableTurnQueue {
|
|
|
119
124
|
throw new Error('Queued turns require streaming replies.');
|
|
120
125
|
const existing = this.entries.get(request.id);
|
|
121
126
|
if (existing) {
|
|
122
|
-
if (JSON.stringify(existing.request) !== JSON.stringify(request))
|
|
127
|
+
if (JSON.stringify(HarnessRequestSchema.parse(existing.request)) !== JSON.stringify(HarnessRequestSchema.parse(request)))
|
|
123
128
|
throw new Error('Request ID already belongs to another message.');
|
|
124
129
|
for (const frame of this.deps.logs.read(request.id).frames)
|
|
125
130
|
this.deps.sendRaw(frame);
|
|
@@ -139,25 +144,18 @@ export class DurableTurnQueue {
|
|
|
139
144
|
const same = scope &&
|
|
140
145
|
(request.kind === 'ask'
|
|
141
146
|
? scope.kind === 'ask'
|
|
142
|
-
:
|
|
147
|
+
: scope.kind === 'code' &&
|
|
143
148
|
scope.repoId === request.repoId &&
|
|
144
149
|
scope.workerId === request.workerId &&
|
|
145
|
-
(scope.mode ?? 'worktree') === (request.mode ?? 'worktree'))
|
|
146
|
-
(scope.kind === 'conduct' &&
|
|
147
|
-
scope.repoId === request.repoId &&
|
|
148
|
-
!!request.workerId));
|
|
150
|
+
(scope.mode ?? 'worktree') === (request.mode ?? 'worktree'));
|
|
149
151
|
if (!same)
|
|
150
152
|
throw new Error('The preceding turn does not belong to this conversation. Refresh it before sending again.');
|
|
151
153
|
}
|
|
152
154
|
const entry = { request, state: 'queued' };
|
|
153
|
-
this.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
catch (error) {
|
|
158
|
-
this.save({ ...entry, state: 'failed' });
|
|
159
|
-
throw error;
|
|
160
|
-
}
|
|
155
|
+
const accepted = this.deps.logs.runtime.accept(request, entry);
|
|
156
|
+
this.entries.set(request.id, entry);
|
|
157
|
+
for (const frame of accepted.frames)
|
|
158
|
+
this.deps.sendRaw(frame);
|
|
161
159
|
this.wake();
|
|
162
160
|
}
|
|
163
161
|
/** Skipped queue entries inherit their predecessor, so removing B from A→B→C
|
|
@@ -170,6 +168,10 @@ export class DurableTurnQueue {
|
|
|
170
168
|
if (previous) {
|
|
171
169
|
if (previous.state === 'skipped')
|
|
172
170
|
return this.predecessor(previous);
|
|
171
|
+
if (previous.state === 'held')
|
|
172
|
+
return { ready: false, blockedBy: previous.blockedBy ?? id };
|
|
173
|
+
if (previous.state === 'failed' && this.terminal(id)?.code === 'interrupted_unknown')
|
|
174
|
+
return { ready: false, blockedBy: id };
|
|
173
175
|
if (previous.state === 'failed')
|
|
174
176
|
throw new Error('The previous turn did not finish. Review it before resending this message.');
|
|
175
177
|
if (previous.state !== 'done')
|
|
@@ -181,53 +183,56 @@ export class DurableTurnQueue {
|
|
|
181
183
|
const terminal = this.terminal(id);
|
|
182
184
|
if (!terminal)
|
|
183
185
|
return { ready: false };
|
|
186
|
+
if (terminal.code === 'interrupted_unknown')
|
|
187
|
+
return { ready: false, blockedBy: id };
|
|
184
188
|
if (terminal.type !== 'done')
|
|
185
189
|
throw new Error('The previous turn did not finish. Review it before resending this message.');
|
|
186
|
-
const
|
|
187
|
-
.read(id)
|
|
188
|
-
.frames.find((frame) => frame.type === 'accepted');
|
|
189
|
-
const scope = receipt?.scope;
|
|
190
|
-
const source = scope?.kind === 'conduct' && entry.request.kind === 'code'
|
|
191
|
-
? entry.request.workerId
|
|
192
|
-
: id;
|
|
193
|
-
if (source !== id && this.terminal(source)?.type !== 'done')
|
|
194
|
-
throw new Error('The worker did not finish. Review it before resending this message.');
|
|
195
|
-
const resume = this.session(source);
|
|
190
|
+
const resume = this.session(id);
|
|
196
191
|
if (!resume)
|
|
197
192
|
throw new Error('The previous turn has no session to continue. Start a new conversation.');
|
|
198
193
|
return { ready: true, resume };
|
|
199
194
|
}
|
|
200
195
|
wake() {
|
|
201
|
-
if (this.stopped || this.pumping)
|
|
196
|
+
if (this.stopped || this.pumping || !this.deps.logs.runtime.writable)
|
|
202
197
|
return;
|
|
203
198
|
this.pumping = true;
|
|
204
199
|
queueMicrotask(() => {
|
|
205
200
|
this.pumping = false;
|
|
206
|
-
if (this.stopped)
|
|
201
|
+
if (this.stopped || !this.deps.logs.runtime.writable)
|
|
207
202
|
return;
|
|
208
203
|
const occupied = new Set();
|
|
209
204
|
for (const [id, entry] of this.entries) {
|
|
210
205
|
const lane = turnLane(entry.request);
|
|
211
206
|
if (!this.owns(id))
|
|
212
207
|
continue;
|
|
208
|
+
if (entry.state === 'held')
|
|
209
|
+
continue;
|
|
213
210
|
if (occupied.has(lane))
|
|
214
211
|
continue;
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
if (entry.state !== 'queued' || this.scheduled.has(id)) {
|
|
213
|
+
occupied.add(lane);
|
|
217
214
|
continue;
|
|
215
|
+
}
|
|
218
216
|
try {
|
|
219
|
-
|
|
217
|
+
const previous = this.predecessor(entry);
|
|
218
|
+
if (!previous.ready) {
|
|
219
|
+
if (previous.blockedBy) {
|
|
220
|
+
this.save({ ...entry, state: 'held', blockedBy: previous.blockedBy });
|
|
221
|
+
this.confirm(id);
|
|
222
|
+
}
|
|
220
223
|
continue;
|
|
224
|
+
}
|
|
221
225
|
}
|
|
222
226
|
catch (error) {
|
|
223
227
|
this.fail(entry, String(error.message));
|
|
224
228
|
continue;
|
|
225
229
|
}
|
|
230
|
+
occupied.add(lane);
|
|
226
231
|
this.scheduled.add(id);
|
|
227
232
|
void this.deps.lanes
|
|
228
233
|
.run(turnLane(entry.request), async () => {
|
|
229
234
|
const current = this.entries.get(id);
|
|
230
|
-
if (this.stopped || current.state !== 'queued')
|
|
235
|
+
if (this.stopped || !this.deps.logs.runtime.writable || current.state !== 'queued')
|
|
231
236
|
return;
|
|
232
237
|
const previous = this.predecessor(current);
|
|
233
238
|
if (!previous.ready)
|
|
@@ -249,7 +254,10 @@ export class DurableTurnQueue {
|
|
|
249
254
|
else
|
|
250
255
|
this.fail(current, 'The turn ended before completion. Review it before resending.');
|
|
251
256
|
})
|
|
252
|
-
.catch((error) =>
|
|
257
|
+
.catch((error) => {
|
|
258
|
+
if (this.deps.logs.runtime.writable)
|
|
259
|
+
this.fail(this.entries.get(id), String(error.message));
|
|
260
|
+
})
|
|
253
261
|
.finally(() => {
|
|
254
262
|
this.scheduled.delete(id);
|
|
255
263
|
this.wake();
|
|
@@ -267,15 +275,16 @@ export class DurableTurnQueue {
|
|
|
267
275
|
this.deps.sendRaw(frame);
|
|
268
276
|
return;
|
|
269
277
|
}
|
|
270
|
-
if (entry.state !== 'queued')
|
|
278
|
+
if (entry.state !== 'queued' && entry.state !== 'held')
|
|
271
279
|
throw new Error('This message has already started or left the queue.');
|
|
272
280
|
if (action === 'steer') {
|
|
281
|
+
if (entry.state === 'held')
|
|
282
|
+
throw new Error('Review the interrupted turn before using this follow-up.');
|
|
273
283
|
if (entry.request.images?.length)
|
|
274
284
|
throw new Error('Attachments must run as a separate turn.');
|
|
275
285
|
if (!activeId || !this.deps.steer)
|
|
276
286
|
throw new Error('There is no active turn to influence.');
|
|
277
287
|
const active = this.entries.get(activeId);
|
|
278
|
-
// For a spawned fleet worker, the active request uses the worker's own ID.
|
|
279
288
|
if (active
|
|
280
289
|
? turnLane(active.request) !== turnLane(entry.request) ||
|
|
281
290
|
active.state !== 'running'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { HarnessRequest } from '@lucidity/shared';
|
|
2
|
+
import type { TurnFrame, TurnState } from './turnLog.js';
|
|
3
|
+
export declare function conversationKey(request: {
|
|
4
|
+
kind: string;
|
|
5
|
+
repoId?: string;
|
|
6
|
+
workerId?: string;
|
|
7
|
+
mode?: string;
|
|
8
|
+
}): string;
|
|
9
|
+
/** Local execution authority. Transactions commit before their receipts reach the transport. */
|
|
10
|
+
export declare class RuntimeStore {
|
|
11
|
+
private db;
|
|
12
|
+
private storageError?;
|
|
13
|
+
get writable(): boolean;
|
|
14
|
+
private write;
|
|
15
|
+
constructor(path: string);
|
|
16
|
+
transaction<T>(action: () => T): T;
|
|
17
|
+
get<T>(bucket: string, id: string): T | undefined;
|
|
18
|
+
set(bucket: string, id: string, value: unknown): void;
|
|
19
|
+
delete(bucket: string, id: string): void;
|
|
20
|
+
list<T>(bucket: string): T[];
|
|
21
|
+
/** The command and its first replayable receipt are one durable operation. */
|
|
22
|
+
accept(request: HarnessRequest, queuedEntry?: unknown): {
|
|
23
|
+
duplicate: boolean;
|
|
24
|
+
frames: TurnFrame[];
|
|
25
|
+
};
|
|
26
|
+
private appendInside;
|
|
27
|
+
append(id: string, event: Record<string, unknown>): TurnFrame;
|
|
28
|
+
status(id: string): Omit<TurnState, 'frames'>;
|
|
29
|
+
read(id: string): TurnState;
|
|
30
|
+
importLog(id: string, state: TurnState): void;
|
|
31
|
+
commands(conversation: string, page?: {
|
|
32
|
+
before?: string;
|
|
33
|
+
after?: string;
|
|
34
|
+
limit: number;
|
|
35
|
+
}): {
|
|
36
|
+
request: HarnessRequest;
|
|
37
|
+
state: TurnState;
|
|
38
|
+
}[];
|
|
39
|
+
latestSession(conversation: string, after?: string): string | undefined;
|
|
40
|
+
lastCommand(conversation: string): string | undefined;
|
|
41
|
+
command(id: string): HarnessRequest | undefined;
|
|
42
|
+
unfinished(conversation: string): boolean;
|
|
43
|
+
reconcile(owns: (id: string) => boolean): void;
|
|
44
|
+
close(): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=runtimeStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeStore.d.ts","sourceRoot":"","sources":["../src/runtimeStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAWzD,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAIpH;AAED,gGAAgG;AAChG,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,IAAI,QAAQ,IAAI,OAAO,CAA+B;IACtD,OAAO,CAAC,KAAK;gBAUD,IAAI,EAAE,MAAM;IAyBxB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;IAclC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIjD,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIrD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAGxC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE;IAK5B,8EAA8E;IAC9E,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,SAAS,EAAE,CAAA;KAAE;IAkCnG,OAAO,CAAC,YAAY;IAiBpB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAI7D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;IAI7C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAQ3B,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAW7C,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,EAAE;IAS1I,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOvE,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAGrD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI/C,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAIzC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI;IAO9C,KAAK,IAAI,IAAI;CACd"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// @ts-expect-error Node 22 runtime API; the repository's Node type baseline is 20.
|
|
2
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
3
|
+
import { chmodSync, mkdirSync } from 'node:fs';
|
|
4
|
+
import { dirname } from 'node:path';
|
|
5
|
+
const terminalTypes = new Set(['done', 'error', 'cancelled']);
|
|
6
|
+
function canonical(value) {
|
|
7
|
+
if (Array.isArray(value))
|
|
8
|
+
return `[${value.map(canonical).join(',')}]`;
|
|
9
|
+
if (value && typeof value === 'object')
|
|
10
|
+
return `{${Object.entries(value).filter(([, v]) => v !== undefined).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(',')}}`;
|
|
11
|
+
return JSON.stringify(value);
|
|
12
|
+
}
|
|
13
|
+
export function conversationKey(request) {
|
|
14
|
+
return request.kind === 'code'
|
|
15
|
+
? JSON.stringify(['code', request.repoId, request.workerId ?? request.mode ?? 'worktree'])
|
|
16
|
+
: request.kind;
|
|
17
|
+
}
|
|
18
|
+
/** Local execution authority. Transactions commit before their receipts reach the transport. */
|
|
19
|
+
export class RuntimeStore {
|
|
20
|
+
db;
|
|
21
|
+
storageError;
|
|
22
|
+
get writable() { return !this.storageError; }
|
|
23
|
+
write(action) {
|
|
24
|
+
if (this.storageError)
|
|
25
|
+
throw new Error(`Runtime storage is unavailable until restart: ${this.storageError.message}`);
|
|
26
|
+
try {
|
|
27
|
+
return action();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const code = error?.code ?? '';
|
|
31
|
+
if (code.includes('SQLITE') || code === 'ERR_INVALID_STATE')
|
|
32
|
+
this.storageError = error instanceof Error ? error : new Error(String(error));
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
constructor(path) {
|
|
37
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
38
|
+
this.db = new DatabaseSync(path);
|
|
39
|
+
chmodSync(path, 0o600);
|
|
40
|
+
this.db.exec(`
|
|
41
|
+
PRAGMA journal_mode=WAL;
|
|
42
|
+
PRAGMA synchronous=FULL;
|
|
43
|
+
PRAGMA busy_timeout=5000;
|
|
44
|
+
CREATE TABLE IF NOT EXISTS runs (
|
|
45
|
+
id TEXT PRIMARY KEY, command TEXT, conversation TEXT,
|
|
46
|
+
state TEXT NOT NULL DEFAULT 'accepted', cursor INTEGER NOT NULL DEFAULT 0,
|
|
47
|
+
terminal TEXT, updated INTEGER NOT NULL
|
|
48
|
+
);
|
|
49
|
+
CREATE INDEX IF NOT EXISTS runs_conversation ON runs(conversation, updated);
|
|
50
|
+
CREATE TABLE IF NOT EXISTS events (
|
|
51
|
+
run_id TEXT NOT NULL, seq INTEGER NOT NULL, frame TEXT NOT NULL,
|
|
52
|
+
PRIMARY KEY(run_id, seq)
|
|
53
|
+
);
|
|
54
|
+
CREATE TABLE IF NOT EXISTS records (
|
|
55
|
+
bucket TEXT NOT NULL, id TEXT NOT NULL, value TEXT NOT NULL,
|
|
56
|
+
PRIMARY KEY(bucket, id)
|
|
57
|
+
);
|
|
58
|
+
`);
|
|
59
|
+
}
|
|
60
|
+
transaction(action) {
|
|
61
|
+
return this.write(() => {
|
|
62
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
63
|
+
try {
|
|
64
|
+
const result = action();
|
|
65
|
+
this.db.exec('COMMIT');
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
try {
|
|
70
|
+
this.db.exec('ROLLBACK');
|
|
71
|
+
}
|
|
72
|
+
catch { /* preserve the original storage failure */ }
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
get(bucket, id) {
|
|
78
|
+
const row = this.db.prepare('SELECT value FROM records WHERE bucket=? AND id=?').get(bucket, id);
|
|
79
|
+
return row ? JSON.parse(row.value) : undefined;
|
|
80
|
+
}
|
|
81
|
+
set(bucket, id, value) {
|
|
82
|
+
this.write(() => this.db.prepare('INSERT INTO records VALUES (?, ?, ?) ON CONFLICT(bucket,id) DO UPDATE SET value=excluded.value')
|
|
83
|
+
.run(bucket, id, JSON.stringify(value)));
|
|
84
|
+
}
|
|
85
|
+
delete(bucket, id) {
|
|
86
|
+
this.write(() => this.db.prepare('DELETE FROM records WHERE bucket=? AND id=?').run(bucket, id));
|
|
87
|
+
}
|
|
88
|
+
list(bucket) {
|
|
89
|
+
return this.db.prepare('SELECT value FROM records WHERE bucket=? ORDER BY rowid').all(bucket)
|
|
90
|
+
.map((row) => JSON.parse(row.value));
|
|
91
|
+
}
|
|
92
|
+
/** The command and its first replayable receipt are one durable operation. */
|
|
93
|
+
accept(request, queuedEntry) {
|
|
94
|
+
return this.transaction(() => {
|
|
95
|
+
const payload = canonical(request);
|
|
96
|
+
const old = this.db.prepare('SELECT command, cursor FROM runs WHERE id=?').get(request.id);
|
|
97
|
+
if (old?.command && old.command !== payload)
|
|
98
|
+
throw new Error('This request ID already belongs to different input.');
|
|
99
|
+
if (old)
|
|
100
|
+
return { duplicate: true, frames: this.read(request.id).frames };
|
|
101
|
+
if (request.kind === 'code' && request.recoveryOf) {
|
|
102
|
+
const review = this.get('run-reviews', request.recoveryOf);
|
|
103
|
+
const source = this.command(request.recoveryOf);
|
|
104
|
+
if (!review || review.reviewId !== request.recoveryReviewId || review.continuationId !== request.id ||
|
|
105
|
+
source?.kind !== 'code' || conversationKey(source) !== conversationKey(request) ||
|
|
106
|
+
this.read(source.id).frames.at(-1)?.code !== 'interrupted_unknown' ||
|
|
107
|
+
review.continuedAt || !request.prompt.trim() || request.prompt.trim().startsWith('/') || request.prompt.trim() === source.prompt.trim())
|
|
108
|
+
throw new Error('A current review is required before continuing this interrupted turn.');
|
|
109
|
+
this.set('run-reviews', source.id, { ...review, continuedAt: new Date().toISOString(), instruction: request.prompt });
|
|
110
|
+
}
|
|
111
|
+
this.db.prepare('INSERT INTO runs (id,command,conversation,updated) VALUES (?,?,?,?)')
|
|
112
|
+
.run(request.id, payload, conversationKey(request), Date.now());
|
|
113
|
+
const scope = {
|
|
114
|
+
kind: request.kind,
|
|
115
|
+
...('repoId' in request ? { repoId: request.repoId } : {}),
|
|
116
|
+
...('workerId' in request ? { workerId: request.workerId } : {}),
|
|
117
|
+
...('mode' in request ? { mode: request.mode } : {}),
|
|
118
|
+
};
|
|
119
|
+
const frames = [this.appendInside(request.id, { type: 'accepted', requestId: request.id, scope })];
|
|
120
|
+
if (queuedEntry) {
|
|
121
|
+
this.set('queue', request.id, queuedEntry);
|
|
122
|
+
frames.push(this.appendInside(request.id, { type: 'queue_state', requestId: request.id, state: 'queued' }));
|
|
123
|
+
}
|
|
124
|
+
return { duplicate: false, frames };
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
appendInside(id, event) {
|
|
128
|
+
this.db.prepare('INSERT OR IGNORE INTO runs (id,updated) VALUES (?,?)').run(id, Date.now());
|
|
129
|
+
const run = this.db.prepare('SELECT cursor, terminal FROM runs WHERE id=?').get(id);
|
|
130
|
+
if (run.terminal) {
|
|
131
|
+
// Reconfirm the committed outcome, never continue a completed attempt.
|
|
132
|
+
this.set('protocol-fault', id, { type: event.type, at: new Date().toISOString() });
|
|
133
|
+
return JSON.parse(run.terminal);
|
|
134
|
+
}
|
|
135
|
+
const frame = { ...event, seq: run.cursor + 1 };
|
|
136
|
+
const serialized = JSON.stringify(frame);
|
|
137
|
+
const terminal = terminalTypes.has(String(event.type));
|
|
138
|
+
const state = terminal ? String(event.type) : event.type === 'accepted' ? 'accepted' : event.type === 'queue_state' ? String(event.state) : 'running';
|
|
139
|
+
this.db.prepare('INSERT INTO events VALUES (?,?,?)').run(id, frame.seq, serialized);
|
|
140
|
+
this.db.prepare('UPDATE runs SET cursor=?, terminal=?, state=?, updated=? WHERE id=?')
|
|
141
|
+
.run(frame.seq, terminal ? serialized : null, state, Date.now(), id);
|
|
142
|
+
return frame;
|
|
143
|
+
}
|
|
144
|
+
append(id, event) {
|
|
145
|
+
return this.transaction(() => this.appendInside(id, event));
|
|
146
|
+
}
|
|
147
|
+
status(id) {
|
|
148
|
+
const run = this.db.prepare('SELECT cursor, terminal FROM runs WHERE id=?').get(id);
|
|
149
|
+
return { exists: !!run, maxSeq: run?.cursor ?? 0, terminated: !!run?.terminal };
|
|
150
|
+
}
|
|
151
|
+
read(id) {
|
|
152
|
+
const status = this.status(id);
|
|
153
|
+
if (!status.exists)
|
|
154
|
+
return { ...status, frames: [] };
|
|
155
|
+
const frames = this.db.prepare('SELECT frame FROM events WHERE run_id=? ORDER BY seq').all(id)
|
|
156
|
+
.map((row) => JSON.parse(row.frame));
|
|
157
|
+
return { ...status, frames };
|
|
158
|
+
}
|
|
159
|
+
importLog(id, state) {
|
|
160
|
+
if (!state.exists || this.read(id).exists)
|
|
161
|
+
return;
|
|
162
|
+
this.transaction(() => {
|
|
163
|
+
const last = [...state.frames].reverse().find((f) => terminalTypes.has(String(f.type)));
|
|
164
|
+
this.db.prepare('INSERT OR IGNORE INTO runs (id,cursor,terminal,state,updated) VALUES (?,?,?,?,?)')
|
|
165
|
+
.run(id, state.maxSeq, last ? JSON.stringify(last) : null, last ? String(last.type) : 'interrupted_unknown', Date.now());
|
|
166
|
+
for (const frame of state.frames)
|
|
167
|
+
this.db.prepare('INSERT OR IGNORE INTO events VALUES (?,?,?)').run(id, frame.seq, JSON.stringify(frame));
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
commands(conversation, page) {
|
|
171
|
+
const rows = page
|
|
172
|
+
? this.db.prepare(`SELECT id,command FROM runs WHERE conversation=? AND command IS NOT NULL
|
|
173
|
+
AND rowid < COALESCE((SELECT rowid FROM runs WHERE id=?), 9223372036854775807)
|
|
174
|
+
AND rowid > COALESCE((SELECT rowid FROM runs WHERE id=?), 0)
|
|
175
|
+
ORDER BY rowid DESC LIMIT ?`).all(conversation, page.before ?? '', page.after ?? '', page.limit).reverse()
|
|
176
|
+
: this.db.prepare('SELECT id,command FROM runs WHERE conversation=? AND command IS NOT NULL ORDER BY rowid').all(conversation);
|
|
177
|
+
return rows.map((row) => ({ request: JSON.parse(row.command), state: this.read(row.id) }));
|
|
178
|
+
}
|
|
179
|
+
latestSession(conversation, after) {
|
|
180
|
+
return this.db.prepare(`SELECT json_extract(events.frame, '$.sessionId') AS session
|
|
181
|
+
FROM runs JOIN events ON events.run_id=runs.id WHERE runs.conversation=?
|
|
182
|
+
AND json_type(events.frame, '$.sessionId')='text'
|
|
183
|
+
AND runs.rowid > COALESCE((SELECT rowid FROM runs WHERE id=?), 0)
|
|
184
|
+
ORDER BY runs.rowid DESC, events.seq DESC LIMIT 1`).get(conversation, after ?? '')?.session;
|
|
185
|
+
}
|
|
186
|
+
lastCommand(conversation) {
|
|
187
|
+
return this.db.prepare('SELECT id FROM runs WHERE conversation=? AND command IS NOT NULL ORDER BY rowid DESC LIMIT 1').get(conversation)?.id;
|
|
188
|
+
}
|
|
189
|
+
command(id) {
|
|
190
|
+
const row = this.db.prepare('SELECT command FROM runs WHERE id=?').get(id);
|
|
191
|
+
return row?.command ? JSON.parse(row.command) : undefined;
|
|
192
|
+
}
|
|
193
|
+
unfinished(conversation) {
|
|
194
|
+
return !!this.db.prepare('SELECT id FROM runs WHERE conversation=? AND terminal IS NULL LIMIT 1').get(conversation);
|
|
195
|
+
}
|
|
196
|
+
reconcile(owns) {
|
|
197
|
+
for (const row of this.db.prepare('SELECT id FROM runs WHERE terminal IS NULL').all()) {
|
|
198
|
+
if (owns(row.id))
|
|
199
|
+
continue;
|
|
200
|
+
this.append(row.id, { type: 'error', requestId: row.id, code: 'interrupted_unknown',
|
|
201
|
+
message: 'Lucid restarted before this turn settled. It was not run again. Review its work before continuing.' });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
close() { this.db.close(); }
|
|
205
|
+
}
|
package/dist/setup/server.js
CHANGED
|
@@ -86,7 +86,7 @@ export async function checkSetupProviders() {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
catch (e) {
|
|
89
|
-
const health = providerFailure(e);
|
|
89
|
+
const health = providerFailure(e) ?? { auth: 'unknown', problem: 'unavailable' };
|
|
90
90
|
return {
|
|
91
91
|
id,
|
|
92
92
|
label: id === 'claude' ? 'Claude' : 'Codex',
|
package/dist/turnLog.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
+
import { RuntimeStore } from './runtimeStore.js';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* appended (with a monotonic `seq`) BEFORE it goes on the socket, so a frame produced
|
|
6
|
-
* while the socket is down — or while the phone is away — survives on disk. The phone
|
|
7
|
-
* recovers by sending a `pull` request; the daemon replays `readState().frames` after
|
|
8
|
-
* the phone's `sinceSeq`.
|
|
9
|
-
*
|
|
10
|
-
* The daemon OWNS `seq` here (starting at 1, per requestId). This is the linchpin of the
|
|
11
|
-
* whole recovery scheme: the same `seq` must appear on the live-forwarded frame, the
|
|
12
|
-
* server's replay-on-rejoin, and a daemon pull, so the phone can de-dup across all three.
|
|
13
|
-
* The relay forwards frames verbatim (it no longer stamps `seq`).
|
|
14
|
-
*
|
|
15
|
-
* Never throws — a logging or disk error must not take a turn down; it just makes that
|
|
16
|
-
* turn unrecoverable (the live frame still goes out). Mirrors `runlog.ts`.
|
|
3
|
+
* SQLite owns command receipts and ordered run events. JSONL files remain bounded
|
|
4
|
+
* diagnostic exports and are imported once when opening an older installation.
|
|
5
|
+
* A storage failure rejects admission or propagates to the execution owner.
|
|
17
6
|
*/
|
|
18
7
|
/** A logged frame: the exact wire frame plus its daemon-authored `seq`. */
|
|
19
8
|
export type TurnFrame = Record<string, unknown> & {
|
|
@@ -35,34 +24,13 @@ export interface TurnState {
|
|
|
35
24
|
export declare const MAX_TURN_LOG_BYTES: number;
|
|
36
25
|
/** Default retention: prune turn logs untouched for 24h. */
|
|
37
26
|
export declare const TURN_LOG_MAX_AGE_MS: number;
|
|
38
|
-
/**
|
|
39
|
-
* One turn's log. Owns the per-requestId `seq` counter (a shared handle, NOT a closure
|
|
40
|
-
* local, so a concurrent `cancel`'s terminal frame gets the next `seq` on the same
|
|
41
|
-
* counter). Seeds itself from any existing file so seq keeps climbing across a daemon
|
|
42
|
-
* restart (a re-created handle resumes from the file's `maxSeq`).
|
|
43
|
-
*/
|
|
44
|
-
export declare class TurnLog {
|
|
45
|
-
private readonly path;
|
|
46
|
-
private readonly maxBytes;
|
|
47
|
-
private nextSeq;
|
|
48
|
-
private bytes;
|
|
49
|
-
private terminatedFlag;
|
|
50
|
-
constructor(requestId: string, dir: string, maxBytes?: number);
|
|
51
|
-
get terminated(): boolean;
|
|
52
|
-
/** Stamp the next `seq`, append the frame (unless a droppable delta past the byte cap),
|
|
53
|
-
* and return the stamped frame to put on the wire. */
|
|
54
|
-
write(event: Record<string, unknown>): TurnFrame;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* All turn logs for this daemon. Keeps an in-memory {@link TurnLog} per in-flight turn
|
|
58
|
-
* (the live seq counter), dropped once the turn terminates — the file lives on for 24h.
|
|
59
|
-
* The file is the source of truth for replay ({@link read}).
|
|
60
|
-
*/
|
|
27
|
+
/** Compatibility reader/exporter around the transactional local runtime ledger. */
|
|
61
28
|
export declare class TurnLogStore {
|
|
62
29
|
private readonly dir;
|
|
63
30
|
private readonly clock;
|
|
64
31
|
private readonly maxBytes;
|
|
65
|
-
private readonly
|
|
32
|
+
private readonly exportBytes;
|
|
33
|
+
readonly runtime: RuntimeStore;
|
|
66
34
|
queueDirectory(): string;
|
|
67
35
|
constructor(opts?: {
|
|
68
36
|
dir?: string;
|
|
@@ -71,8 +39,10 @@ export declare class TurnLogStore {
|
|
|
71
39
|
});
|
|
72
40
|
/** Log + stamp one outgoing stream frame; returns the stamped frame to send. */
|
|
73
41
|
append(requestId: string, event: Record<string, unknown>): TurnFrame;
|
|
74
|
-
/** The durable state of a turn, read from disk — for serving a `pull`. */
|
|
75
42
|
read(requestId: string): TurnState;
|
|
43
|
+
/** Startup recovery is independent of whether a phone asks to replay a turn. */
|
|
44
|
+
reconcile(owns: (id: string) => boolean): void;
|
|
45
|
+
close(): void;
|
|
76
46
|
/** Delete turn logs whose file hasn't been touched in `maxAgeMs`. Never throws. */
|
|
77
47
|
prune(maxAgeMs?: number): void;
|
|
78
48
|
}
|
package/dist/turnLog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turnLog.d.ts","sourceRoot":"","sources":["../src/turnLog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"turnLog.d.ts","sourceRoot":"","sources":["../src/turnLog.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;GAIG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,kFAAkF;IAClF,MAAM,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,UAAU,EAAE,OAAO,CAAC;CACrB;AAUD;;sFAEsF;AACtF,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AAEnD,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,QAAsB,CAAC;AA0DvD,mFAAmF;AACnF,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IACzD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAE/B,cAAc,IAAI,MAAM;gBAKtB,IAAI,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAapE,gFAAgF;IAChF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAgBpE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAOlC,gFAAgF;IAChF,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI;IAM9C,KAAK,IAAI,IAAI;IAEb,mFAAmF;IACnF,KAAK,CAAC,QAAQ,GAAE,MAA4B,GAAG,IAAI;CAkBpD"}
|