@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/turnLog.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, unlinkSync, } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { TURNS_DIR } from './config.js';
|
|
4
|
+
import { RuntimeStore } from './runtimeStore.js';
|
|
4
5
|
/** Frame `type`s that end a turn. Mirrors the relay's TERMINAL_TYPES — `code_result`
|
|
5
6
|
* and `clone_result` are NOT terminal (a `done` follows). */
|
|
6
7
|
const TERMINAL_TYPES = new Set(['done', 'error', 'cancelled']);
|
|
@@ -72,56 +73,13 @@ function appendLine(path, line) {
|
|
|
72
73
|
return false;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
/**
|
|
76
|
-
* One turn's log. Owns the per-requestId `seq` counter (a shared handle, NOT a closure
|
|
77
|
-
* local, so a concurrent `cancel`'s terminal frame gets the next `seq` on the same
|
|
78
|
-
* counter). Seeds itself from any existing file so seq keeps climbing across a daemon
|
|
79
|
-
* restart (a re-created handle resumes from the file's `maxSeq`).
|
|
80
|
-
*/
|
|
81
|
-
export class TurnLog {
|
|
82
|
-
path;
|
|
83
|
-
maxBytes;
|
|
84
|
-
nextSeq;
|
|
85
|
-
bytes;
|
|
86
|
-
terminatedFlag;
|
|
87
|
-
constructor(requestId, dir, maxBytes = MAX_TURN_LOG_BYTES) {
|
|
88
|
-
this.path = join(dir, `${requestId}.jsonl`);
|
|
89
|
-
this.maxBytes = maxBytes;
|
|
90
|
-
const st = scanTurnFile(this.path);
|
|
91
|
-
this.nextSeq = st.maxSeq + 1;
|
|
92
|
-
this.bytes = st.bytes;
|
|
93
|
-
this.terminatedFlag = st.terminated;
|
|
94
|
-
}
|
|
95
|
-
get terminated() {
|
|
96
|
-
return this.terminatedFlag;
|
|
97
|
-
}
|
|
98
|
-
/** Stamp the next `seq`, append the frame (unless a droppable delta past the byte cap),
|
|
99
|
-
* and return the stamped frame to put on the wire. */
|
|
100
|
-
write(event) {
|
|
101
|
-
const seq = this.nextSeq++;
|
|
102
|
-
const frame = { ...event, seq };
|
|
103
|
-
const type = typeof event.type === 'string' ? event.type : '';
|
|
104
|
-
const droppable = type === 'delta' && this.bytes >= this.maxBytes;
|
|
105
|
-
if (!droppable) {
|
|
106
|
-
const line = JSON.stringify(frame) + '\n';
|
|
107
|
-
if (appendLine(this.path, line))
|
|
108
|
-
this.bytes += Buffer.byteLength(line, 'utf8');
|
|
109
|
-
}
|
|
110
|
-
if (isTerminalType(type))
|
|
111
|
-
this.terminatedFlag = true;
|
|
112
|
-
return frame;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* All turn logs for this daemon. Keeps an in-memory {@link TurnLog} per in-flight turn
|
|
117
|
-
* (the live seq counter), dropped once the turn terminates — the file lives on for 24h.
|
|
118
|
-
* The file is the source of truth for replay ({@link read}).
|
|
119
|
-
*/
|
|
76
|
+
/** Compatibility reader/exporter around the transactional local runtime ledger. */
|
|
120
77
|
export class TurnLogStore {
|
|
121
78
|
dir;
|
|
122
79
|
clock;
|
|
123
80
|
maxBytes;
|
|
124
|
-
|
|
81
|
+
exportBytes = new Map();
|
|
82
|
+
runtime;
|
|
125
83
|
queueDirectory() {
|
|
126
84
|
return join(this.dir, 'queue');
|
|
127
85
|
}
|
|
@@ -129,6 +87,7 @@ export class TurnLogStore {
|
|
|
129
87
|
this.dir = opts.dir ?? TURNS_DIR;
|
|
130
88
|
this.clock = opts.now ?? Date.now;
|
|
131
89
|
this.maxBytes = opts.maxBytes ?? MAX_TURN_LOG_BYTES;
|
|
90
|
+
this.runtime = new RuntimeStore(join(this.dir, 'runtime.sqlite'));
|
|
132
91
|
try {
|
|
133
92
|
mkdirSync(this.dir, { recursive: true });
|
|
134
93
|
}
|
|
@@ -138,21 +97,39 @@ export class TurnLogStore {
|
|
|
138
97
|
}
|
|
139
98
|
/** Log + stamp one outgoing stream frame; returns the stamped frame to send. */
|
|
140
99
|
append(requestId, event) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
100
|
+
if (!this.runtime.status(requestId).exists)
|
|
101
|
+
this.read(requestId);
|
|
102
|
+
const before = this.runtime.status(requestId);
|
|
103
|
+
const frame = this.runtime.append(requestId, event);
|
|
104
|
+
if (before.terminated)
|
|
105
|
+
return frame;
|
|
106
|
+
// Bounded diagnostic exports are optional; a failed export never loses the SQLite event.
|
|
107
|
+
const path = join(this.dir, `${requestId}.jsonl`);
|
|
108
|
+
const bytes = this.exportBytes.get(requestId) ?? (existsSync(path) ? statSync(path).size : 0);
|
|
109
|
+
if (event.type !== 'delta' || bytes < this.maxBytes) {
|
|
110
|
+
const line = JSON.stringify(frame) + '\n';
|
|
111
|
+
if (appendLine(path, line))
|
|
112
|
+
this.exportBytes.set(requestId, bytes + Buffer.byteLength(line));
|
|
145
113
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.logs.delete(requestId); // free memory; file persists
|
|
114
|
+
if (TERMINAL_TYPES.has(String(event.type)))
|
|
115
|
+
this.exportBytes.delete(requestId);
|
|
149
116
|
return frame;
|
|
150
117
|
}
|
|
151
|
-
/** The durable state of a turn, read from disk — for serving a `pull`. */
|
|
152
118
|
read(requestId) {
|
|
153
|
-
const
|
|
154
|
-
|
|
119
|
+
const state = this.runtime.read(requestId);
|
|
120
|
+
if (state.exists)
|
|
121
|
+
return state;
|
|
122
|
+
this.runtime.importLog(requestId, scanTurnFile(join(this.dir, `${requestId}.jsonl`)));
|
|
123
|
+
return this.runtime.read(requestId);
|
|
124
|
+
}
|
|
125
|
+
/** Startup recovery is independent of whether a phone asks to replay a turn. */
|
|
126
|
+
reconcile(owns) {
|
|
127
|
+
for (const name of readdirSync(this.dir))
|
|
128
|
+
if (name.endsWith('.jsonl'))
|
|
129
|
+
this.read(name.slice(0, -6));
|
|
130
|
+
this.runtime.reconcile(owns);
|
|
155
131
|
}
|
|
132
|
+
close() { this.runtime.close(); }
|
|
156
133
|
/** Delete turn logs whose file hasn't been touched in `maxAgeMs`. Never throws. */
|
|
157
134
|
prune(maxAgeMs = TURN_LOG_MAX_AGE_MS) {
|
|
158
135
|
const now = this.clock();
|
package/dist/vault.d.ts
CHANGED
|
@@ -19,9 +19,12 @@ export interface Vault {
|
|
|
19
19
|
/** SOUL.md if present (and non-empty), else the packaged default — seeding SOUL.md so it's editable. */
|
|
20
20
|
readPersona(): string;
|
|
21
21
|
/** Durable facts from MEMORY.md (empty if absent/malformed). */
|
|
22
|
-
readMemoryFacts(): string[];
|
|
23
|
-
writeMemoryFacts(facts: string[]): void;
|
|
24
|
-
writeSessionLog(entry: SessionEntry
|
|
22
|
+
readMemoryFacts(strict?: boolean): string[];
|
|
23
|
+
writeMemoryFacts(facts: string[], strict?: boolean): void;
|
|
24
|
+
writeSessionLog(entry: SessionEntry, receipt?: {
|
|
25
|
+
id: string;
|
|
26
|
+
strict: boolean;
|
|
27
|
+
}): void;
|
|
25
28
|
}
|
|
26
29
|
export declare function createVault(vaultPath: string): Vault;
|
|
27
30
|
//# sourceMappingURL=vault.d.ts.map
|
package/dist/vault.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wGAAwG;IACxG,WAAW,IAAI,MAAM,CAAC;IACtB,gEAAgE;IAChE,eAAe,
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wGAAwG;IACxG,WAAW,IAAI,MAAM,CAAC;IACtB,gEAAgE;IAChE,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;IAC5C,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1D,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACvF;AAMD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,CAsEpD"}
|
package/dist/vault.js
CHANGED
|
@@ -27,27 +27,31 @@ export function createVault(vaultPath) {
|
|
|
27
27
|
}
|
|
28
28
|
return def;
|
|
29
29
|
},
|
|
30
|
-
readMemoryFacts() {
|
|
30
|
+
readMemoryFacts(strict = false) {
|
|
31
31
|
if (!existsSync(memoryPath))
|
|
32
32
|
return [];
|
|
33
33
|
try {
|
|
34
34
|
return parseFacts(readFileSync(memoryPath, 'utf8'));
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
|
37
|
+
if (strict)
|
|
38
|
+
throw err;
|
|
37
39
|
console.error(`[vault] could not read MEMORY.md: ${msg(err)}`);
|
|
38
40
|
return [];
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
|
-
writeMemoryFacts(facts) {
|
|
43
|
+
writeMemoryFacts(facts, strict = false) {
|
|
42
44
|
try {
|
|
43
45
|
mkdirSync(vaultPath, { recursive: true });
|
|
44
46
|
writeFileSync(memoryPath, renderMemoryFile(facts), 'utf8');
|
|
45
47
|
}
|
|
46
48
|
catch (err) {
|
|
49
|
+
if (strict)
|
|
50
|
+
throw err;
|
|
47
51
|
console.error(`[vault] could not write MEMORY.md: ${msg(err)}`);
|
|
48
52
|
}
|
|
49
53
|
},
|
|
50
|
-
writeSessionLog(entry) {
|
|
54
|
+
writeSessionLog(entry, receipt) {
|
|
51
55
|
try {
|
|
52
56
|
mkdirSync(sessionsDir, { recursive: true });
|
|
53
57
|
const kind = entry.kind ?? 'briefing';
|
|
@@ -59,9 +63,19 @@ export function createVault(vaultPath) {
|
|
|
59
63
|
`Delivered via: ${entry.deliveredVia}\n\n` +
|
|
60
64
|
`## Message\n\n${entry.body.trim()}\n\n` +
|
|
61
65
|
`## Facts learned\n\n${facts}\n`;
|
|
62
|
-
|
|
66
|
+
if (receipt && !/^[a-zA-Z0-9-]+$/.test(receipt.id))
|
|
67
|
+
throw new Error('Invalid session receipt ID');
|
|
68
|
+
const path = join(sessionsDir, `${receipt?.id ?? stamp}-${kind}.md`);
|
|
69
|
+
if (receipt && existsSync(path)) {
|
|
70
|
+
if (readFileSync(path, 'utf8') !== content)
|
|
71
|
+
throw new Error('The saved briefing was changed outside this run.');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
writeFileSync(path, content, { encoding: 'utf8', flag: receipt ? 'wx' : 'w' });
|
|
63
75
|
}
|
|
64
76
|
catch (err) {
|
|
77
|
+
if (receipt?.strict)
|
|
78
|
+
throw err;
|
|
65
79
|
console.error(`[vault] could not write session log: ${msg(err)}`);
|
|
66
80
|
}
|
|
67
81
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencorelabs/lucidity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Lucidity's local personal agent, command-line interface, and MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"native"
|
|
26
26
|
],
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=22"
|
|
28
|
+
"node": ">=22.13.0"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
|
31
31
|
"lucidity",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"chrono-node": "^2.10.1",
|
|
43
43
|
"zod": "^4.3.5 ^4.3.6",
|
|
44
44
|
"@js-temporal/polyfill": "^0.5.1",
|
|
45
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
45
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.287",
|
|
46
46
|
"@modelcontextprotocol/sdk": "1.29.0 ^1.12.1",
|
|
47
|
-
"@openai/codex": "0.
|
|
47
|
+
"@openai/codex": "0.160.0",
|
|
48
48
|
"croner": "^10.0.0",
|
|
49
49
|
"uuidv7": "^1.1.0",
|
|
50
50
|
"ws": "^8.18.1",
|
package/src/automations/agent.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
isDesignerInput,
|
|
12
12
|
} from '@lucidity/shared';
|
|
13
13
|
import { AutomationStore } from './store.js';
|
|
14
|
+
import { WorkflowInterrupted } from './workflow.js';
|
|
14
15
|
|
|
15
16
|
export function nextOccurrence(
|
|
16
17
|
schedule: AutomationSchedule,
|
|
@@ -37,6 +38,7 @@ export function nextOccurrence(
|
|
|
37
38
|
|
|
38
39
|
export interface AutomationServiceDeps {
|
|
39
40
|
store: AutomationStore;
|
|
41
|
+
resumable?: (job: AutomationJob) => boolean;
|
|
40
42
|
execute: (
|
|
41
43
|
job: AutomationJob,
|
|
42
44
|
run: AutomationRun,
|
|
@@ -65,6 +67,7 @@ export class AutomationService {
|
|
|
65
67
|
constructor(private readonly deps: AutomationServiceDeps) {
|
|
66
68
|
this.now = deps.now ?? (() => new Date());
|
|
67
69
|
for (const run of deps.store.runs()) {
|
|
70
|
+
if (run.status === 'running' && run.workflow) continue;
|
|
68
71
|
if (run.status === 'running')
|
|
69
72
|
this.finish(run, {
|
|
70
73
|
status: 'interrupted',
|
|
@@ -180,7 +183,7 @@ export class AutomationService {
|
|
|
180
183
|
this.deps.changed?.();
|
|
181
184
|
}
|
|
182
185
|
private assertIdle(jobId: string) {
|
|
183
|
-
if (this.active.has(jobId))
|
|
186
|
+
if (this.active.has(jobId) || this.deps.store.runs().some((run) => run.jobId === jobId && run.status === 'running'))
|
|
184
187
|
throw new Error(
|
|
185
188
|
'This automation already has a running job. Open it or cancel it before starting another.',
|
|
186
189
|
);
|
|
@@ -276,9 +279,10 @@ export class AutomationService {
|
|
|
276
279
|
} else if (command.action === 'cancel') {
|
|
277
280
|
const run = this.deps.store.run(command.runId);
|
|
278
281
|
const active = this.active.get(run.jobId);
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
active.controller.abort();
|
|
282
|
+
if (run.status !== 'running') throw new Error('This run has already ended');
|
|
283
|
+
this.deps.store.saveRun({ ...run, cancelRequested: true });
|
|
284
|
+
if (active?.runId === run.id) active.controller.abort();
|
|
285
|
+
else this.finish(run, { status: 'cancelled', cancelRequested: true });
|
|
282
286
|
message =
|
|
283
287
|
'Cancellation requested. Completed external edits remain available for review.';
|
|
284
288
|
} else {
|
|
@@ -384,6 +388,7 @@ export class AutomationService {
|
|
|
384
388
|
}
|
|
385
389
|
tick() {
|
|
386
390
|
const now = this.now();
|
|
391
|
+
this.resumeAccepted(now);
|
|
387
392
|
for (const job of this.deps.store.jobs()) {
|
|
388
393
|
if (!this.deps.scheduledWork() && job.id !== 'builtin:prune') continue;
|
|
389
394
|
if (!job.enabled || (job.pausedUntil && new Date(job.pausedUntil) > now))
|
|
@@ -395,15 +400,15 @@ export class AutomationService {
|
|
|
395
400
|
}
|
|
396
401
|
if (new Date(job.nextRunAt) > now) continue;
|
|
397
402
|
const late = now.getTime() - Date.parse(job.nextRunAt) > 90_000;
|
|
398
|
-
//
|
|
399
|
-
|
|
403
|
+
// The occurrence and its run are admitted in the same transaction.
|
|
404
|
+
const claim = { occurrence: job.nextRunAt, job: {
|
|
400
405
|
...job,
|
|
401
406
|
pausedUntil: undefined,
|
|
402
407
|
nextRunAt: nextOccurrence(job.schedule, now),
|
|
403
|
-
}
|
|
404
|
-
if (this.
|
|
408
|
+
} };
|
|
409
|
+
if (this.hasAccepted(job.id) || (late && job.catchUp === 'skip')) {
|
|
405
410
|
const at = now.toISOString();
|
|
406
|
-
this.deps.store.
|
|
411
|
+
this.deps.store.admit({
|
|
407
412
|
id: uuidv7(),
|
|
408
413
|
jobId: job.id,
|
|
409
414
|
jobName: job.name,
|
|
@@ -417,12 +422,12 @@ export class AutomationService {
|
|
|
417
422
|
status: 'skipped',
|
|
418
423
|
startedAt: at,
|
|
419
424
|
finishedAt: at,
|
|
420
|
-
summary: this.
|
|
425
|
+
summary: this.hasAccepted(job.id)
|
|
421
426
|
? 'Previous run is still active.'
|
|
422
427
|
: 'Scheduled time was missed while the computer was unavailable. Catch-up is disabled.',
|
|
423
428
|
directions: [],
|
|
424
429
|
feedback: [],
|
|
425
|
-
});
|
|
430
|
+
}, claim);
|
|
426
431
|
} else
|
|
427
432
|
this.launch(
|
|
428
433
|
job,
|
|
@@ -432,6 +437,7 @@ export class AutomationService {
|
|
|
432
437
|
? 'agent'
|
|
433
438
|
: 'design',
|
|
434
439
|
late ? 'catch-up' : 'scheduled',
|
|
440
|
+
undefined, claim,
|
|
435
441
|
);
|
|
436
442
|
}
|
|
437
443
|
}
|
|
@@ -440,6 +446,7 @@ export class AutomationService {
|
|
|
440
446
|
stage: AutomationRun['stage'],
|
|
441
447
|
trigger: AutomationRun['trigger'],
|
|
442
448
|
parent?: AutomationRun,
|
|
449
|
+
claim?: { job: AutomationJob; occurrence: string },
|
|
443
450
|
): string {
|
|
444
451
|
this.assertIdle(job.id);
|
|
445
452
|
const run: AutomationRun = {
|
|
@@ -451,6 +458,7 @@ export class AutomationService {
|
|
|
451
458
|
status: 'running',
|
|
452
459
|
startedAt: this.now().toISOString(),
|
|
453
460
|
summary: 'Starting…',
|
|
461
|
+
...(this.deps.resumable?.(job) ? { workflow: { version: 1, attempts: 1, possibleAdditionalCost: false, steps: [] } } : {}),
|
|
454
462
|
input: job.input,
|
|
455
463
|
parentRunId: parent?.id,
|
|
456
464
|
feedback: parent?.feedback ?? [],
|
|
@@ -458,22 +466,41 @@ export class AutomationService {
|
|
|
458
466
|
selectedDirectionId:
|
|
459
467
|
stage === 'implementation' ? parent?.selectedDirectionId : undefined,
|
|
460
468
|
};
|
|
461
|
-
this.deps.store.
|
|
469
|
+
if (!this.deps.store.admit(run, claim)) return run.id;
|
|
470
|
+
this.executeAccepted(job, run);
|
|
471
|
+
return run.id;
|
|
472
|
+
}
|
|
473
|
+
private hasAccepted(jobId: string) {
|
|
474
|
+
return this.active.has(jobId) || this.deps.store.runs().some((run) => run.jobId === jobId && run.status === 'running');
|
|
475
|
+
}
|
|
476
|
+
private resumeAccepted(now: Date) {
|
|
477
|
+
for (const run of this.deps.store.runs()) {
|
|
478
|
+
if (run.status !== 'running' || this.active.has(run.jobId)) continue;
|
|
479
|
+
const job = this.deps.store.jobs().find((job) => job.id === run.jobId);
|
|
480
|
+
if (run.cancelRequested) { this.finish(run, { status: 'cancelled' }); continue; }
|
|
481
|
+
if (!job || !this.deps.resumable?.(job) || run.workflow?.version !== 1) {
|
|
482
|
+
this.finish(run, { status: 'interrupted', error: 'This saved workflow cannot resume with the installed version.' });
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (!this.deps.scheduledWork() || !job.enabled || (job.pausedUntil && new Date(job.pausedUntil) > now)) continue;
|
|
486
|
+
const resumed = { ...run, workflow: { ...run.workflow, attempts: run.workflow.attempts + 1 } };
|
|
487
|
+
this.deps.store.saveRun(resumed);
|
|
488
|
+
this.executeAccepted(job, resumed);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
private executeAccepted(job: AutomationJob, run: AutomationRun) {
|
|
462
492
|
const controller = new AbortController();
|
|
463
493
|
// Microtask admission makes the active marker visible before any executor can finish.
|
|
464
494
|
const done = Promise.resolve()
|
|
465
495
|
.then(async () => {
|
|
466
496
|
try {
|
|
467
497
|
const result = await this.deps.execute(job, run, controller.signal);
|
|
468
|
-
this.
|
|
469
|
-
|
|
470
|
-
controller.signal.aborted
|
|
471
|
-
? { ...result, status: 'cancelled' }
|
|
472
|
-
: result,
|
|
473
|
-
);
|
|
498
|
+
if (controller.signal.aborted && run.workflow && !this.deps.store.run(run.id).cancelRequested) return;
|
|
499
|
+
this.finish(run, controller.signal.aborted ? { ...result, status: 'cancelled' } : result);
|
|
474
500
|
} catch (error) {
|
|
501
|
+
if (controller.signal.aborted && run.workflow && !this.deps.store.run(run.id).cancelRequested) return;
|
|
475
502
|
this.finish(run, {
|
|
476
|
-
status: controller.signal.aborted ? 'cancelled' : 'failed',
|
|
503
|
+
status: controller.signal.aborted ? 'cancelled' : error instanceof WorkflowInterrupted ? 'interrupted' : 'failed',
|
|
477
504
|
error: error instanceof Error ? error.message : String(error),
|
|
478
505
|
});
|
|
479
506
|
} finally {
|
|
@@ -488,12 +515,11 @@ export class AutomationService {
|
|
|
488
515
|
});
|
|
489
516
|
this.active.set(job.id, { runId: run.id, controller, done });
|
|
490
517
|
this.deps.changed?.();
|
|
491
|
-
return run.id;
|
|
492
518
|
}
|
|
493
519
|
private finish(run: AutomationRun, patch: Partial<AutomationRun>) {
|
|
494
520
|
const finishedAt = this.now().toISOString();
|
|
495
521
|
this.deps.store.saveRun({
|
|
496
|
-
...run,
|
|
522
|
+
...this.deps.store.run(run.id),
|
|
497
523
|
status: 'completed',
|
|
498
524
|
...patch,
|
|
499
525
|
id: run.id,
|
package/src/automations/store.ts
CHANGED
|
@@ -1,63 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
existsSync,
|
|
3
|
-
mkdirSync,
|
|
4
|
-
readFileSync,
|
|
5
|
-
readdirSync,
|
|
6
|
-
renameSync,
|
|
7
|
-
writeFileSync,
|
|
8
|
-
} from 'node:fs';
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
|
|
9
2
|
import { join } from 'node:path';
|
|
10
3
|
import {
|
|
11
|
-
AutomationJobSchema,
|
|
12
|
-
|
|
13
|
-
type AutomationJob,
|
|
14
|
-
type AutomationRun,
|
|
4
|
+
AutomationJobSchema, AutomationRunSchema,
|
|
5
|
+
type AutomationJob, type AutomationRun,
|
|
15
6
|
} from '@lucidity/shared';
|
|
7
|
+
import { RuntimeStore } from '../runtimeStore.js';
|
|
16
8
|
|
|
17
|
-
/**
|
|
9
|
+
/** The daemon owns admission and execution. Legacy JSON remains untouched after import. */
|
|
18
10
|
export class AutomationStore {
|
|
19
|
-
|
|
11
|
+
readonly runtime: RuntimeStore;
|
|
12
|
+
constructor(readonly directory: string, runtime?: RuntimeStore) {
|
|
20
13
|
mkdirSync(join(directory, 'runs'), { recursive: true, mode: 0o700 });
|
|
14
|
+
this.runtime = runtime ?? new RuntimeStore(join(directory, 'automations.sqlite'));
|
|
15
|
+
if (!this.runtime.get('automation-migrations', directory)) {
|
|
16
|
+
const path = join(directory, 'jobs.json');
|
|
17
|
+
const jobs = existsSync(path) ? AutomationJobSchema.array().parse(JSON.parse(readFileSync(path, 'utf8'))) : [];
|
|
18
|
+
const runs = readdirSync(join(directory, 'runs')).filter((name) => name.endsWith('.json')).map((name) =>
|
|
19
|
+
AutomationRunSchema.parse(JSON.parse(readFileSync(join(directory, 'runs', name), 'utf8'))));
|
|
20
|
+
this.runtime.transaction(() => {
|
|
21
|
+
for (const job of jobs) if (!this.runtime.get('automation-jobs', job.id)) this.saveJob(job);
|
|
22
|
+
for (const run of runs) if (!this.runtime.get('automation-runs', run.id)) this.saveRun(run);
|
|
23
|
+
this.runtime.set('automation-migrations', directory, true);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
writeFileSync(temporary, JSON.stringify(value, null, 2), { mode: 0o600 });
|
|
25
|
-
renameSync(temporary, path);
|
|
26
|
-
}
|
|
27
|
-
jobs(): AutomationJob[] {
|
|
28
|
-
const path = join(this.directory, 'jobs.json');
|
|
29
|
-
if (!existsSync(path)) return [];
|
|
30
|
-
// Corruption must be surfaced, never mistaken for an empty store and overwritten.
|
|
31
|
-
return AutomationJobSchema.array().parse(
|
|
32
|
-
JSON.parse(readFileSync(path, 'utf8')),
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
saveJob(job: AutomationJob) {
|
|
36
|
-
const jobs = this.jobs();
|
|
37
|
-
this.write(join(this.directory, 'jobs.json'), [
|
|
38
|
-
...jobs.filter((row) => row.id !== job.id),
|
|
39
|
-
AutomationJobSchema.parse(job),
|
|
40
|
-
]);
|
|
41
|
-
}
|
|
27
|
+
jobs(): AutomationJob[] { return this.runtime.list<AutomationJob>('automation-jobs').map((job) => AutomationJobSchema.parse(job)); }
|
|
28
|
+
saveJob(job: AutomationJob) { this.runtime.set('automation-jobs', job.id, AutomationJobSchema.parse(job)); }
|
|
42
29
|
run(id: string): AutomationRun {
|
|
43
30
|
if (!/^[a-zA-Z0-9-]+$/.test(id)) throw new Error('Invalid run ID');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
saveRun(run: AutomationRun) {
|
|
51
|
-
if (!/^[a-zA-Z0-9-]+$/.test(run.id)) throw new Error('Invalid run ID');
|
|
52
|
-
this.write(
|
|
53
|
-
join(this.directory, 'runs', `${run.id}.json`),
|
|
54
|
-
AutomationRunSchema.parse(run),
|
|
55
|
-
);
|
|
31
|
+
const run = this.runtime.get('automation-runs', id);
|
|
32
|
+
if (!run) throw new Error('Automation run not found');
|
|
33
|
+
return AutomationRunSchema.parse(run);
|
|
56
34
|
}
|
|
35
|
+
saveRun(run: AutomationRun) { this.runtime.set('automation-runs', run.id, AutomationRunSchema.parse(run)); }
|
|
57
36
|
runs(): AutomationRun[] {
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
37
|
+
return this.runtime.list<AutomationRun>('automation-runs').map((run) => AutomationRunSchema.parse(run)).sort((a, b) => b.id.localeCompare(a.id));
|
|
38
|
+
}
|
|
39
|
+
/** Advancing a schedule and accepting its one run commit together, including skipped occurrences. */
|
|
40
|
+
admit(run: AutomationRun, claim?: { job: AutomationJob; occurrence: string }): boolean {
|
|
41
|
+
return this.runtime.transaction(() => {
|
|
42
|
+
if (this.runtime.get('automation-runs', run.id)) return false;
|
|
43
|
+
if (claim) {
|
|
44
|
+
const current = this.runtime.get<AutomationJob>('automation-jobs', claim.job.id);
|
|
45
|
+
const key = JSON.stringify([claim.job.id, claim.occurrence]);
|
|
46
|
+
if (current?.nextRunAt !== claim.occurrence || this.runtime.get('automation-occurrences', key)) return false;
|
|
47
|
+
this.runtime.set('automation-occurrences', key, run.id);
|
|
48
|
+
this.saveJob(claim.job);
|
|
49
|
+
}
|
|
50
|
+
this.saveRun(run);
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
62
53
|
}
|
|
63
54
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AutomationRun } from '@lucidity/shared';
|
|
2
|
+
import type { AutomationStore } from './store.js';
|
|
3
|
+
|
|
4
|
+
type Step = NonNullable<AutomationRun['workflow']>['steps'][number] & { value?: unknown };
|
|
5
|
+
interface Checkpoint { version: number; steps: Step[] }
|
|
6
|
+
export class WorkflowInterrupted extends Error {}
|
|
7
|
+
|
|
8
|
+
/** A small ordered-step journal. Only pure reads and tool-less generation may retry. */
|
|
9
|
+
export class SavedWorkflow {
|
|
10
|
+
private checkpoint: Checkpoint;
|
|
11
|
+
constructor(private readonly store: AutomationStore, readonly runId: string, private readonly signal?: AbortSignal) {
|
|
12
|
+
this.checkpoint = store.runtime.get<Checkpoint>('workflow-steps', runId) ?? { version: 1, steps: [] };
|
|
13
|
+
if (this.checkpoint.version !== 1) throw new WorkflowInterrupted('This run uses an incompatible saved workflow version. Its saved output has been retained.');
|
|
14
|
+
}
|
|
15
|
+
private save(step: Step) {
|
|
16
|
+
this.checkpoint.steps = [...this.checkpoint.steps.filter((old) => old.key !== step.key), step];
|
|
17
|
+
this.store.runtime.transaction(() => {
|
|
18
|
+
this.store.runtime.set('workflow-steps', this.runId, this.checkpoint);
|
|
19
|
+
const run = this.store.run(this.runId);
|
|
20
|
+
this.store.saveRun({ ...run, workflow: {
|
|
21
|
+
version: 1, attempts: run.workflow?.attempts ?? 1,
|
|
22
|
+
possibleAdditionalCost: this.checkpoint.steps.some((s) => s.attempts > 1 && ['Generate briefing', 'Reflect'].includes(s.key)),
|
|
23
|
+
steps: this.checkpoint.steps.map(({ value: _, ...progress }) => progress),
|
|
24
|
+
}, ...(step.key === 'Generate briefing' && step.status === 'completed' ? { summary: (step.value as { text: string }).text, costUsd: (step.value as { costUsd?: number }).costUsd, sessionId: (step.value as { sessionId?: string }).sessionId } : {}) });
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async step<T>(key: string, policy: 'retry' | 'effect', action: () => Promise<T> | T): Promise<T> {
|
|
28
|
+
if (this.signal?.aborted || this.store.run(this.runId).cancelRequested) throw new Error('Run stopped.');
|
|
29
|
+
const old = this.checkpoint.steps.find((step) => step.key === key);
|
|
30
|
+
if (old?.status === 'completed') return old.value as T;
|
|
31
|
+
if (old && policy === 'effect') {
|
|
32
|
+
const error = `${key} may already have happened. Review the saved output before doing it again.`;
|
|
33
|
+
this.save({ ...old, status: 'uncertain', error });
|
|
34
|
+
throw new WorkflowInterrupted(error);
|
|
35
|
+
}
|
|
36
|
+
if ((old?.attempts ?? 0) >= 3) throw new WorkflowInterrupted(`${key} reached its three-attempt recovery limit. Saved work has been retained.`);
|
|
37
|
+
const started: Step = { key, status: 'running', attempts: (old?.attempts ?? 0) + 1 };
|
|
38
|
+
this.save(started);
|
|
39
|
+
let value: T;
|
|
40
|
+
try { value = await action(); }
|
|
41
|
+
catch (error) {
|
|
42
|
+
this.save({ ...started, status: policy === 'effect' ? 'uncertain' : 'failed', error: error instanceof Error ? error.message : String(error) });
|
|
43
|
+
if (policy === 'effect') throw new WorkflowInterrupted(`${key} has an uncertain outcome: ${String(error)}`);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
this.save({ ...started, status: 'completed', value });
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/chat/server.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type { McpWiring } from '../mcp/config.js';
|
|
|
23
23
|
import type { AutomationService } from '../automations/service.js';
|
|
24
24
|
|
|
25
25
|
export interface ChatServerDeps {
|
|
26
|
+
signal?: AbortSignal;
|
|
26
27
|
automations?: AutomationService;
|
|
27
28
|
config: DaemonConfig;
|
|
28
29
|
executor: AgentExecutor;
|
|
@@ -73,6 +74,11 @@ export function createChatServer(deps: ChatServerDeps): Server {
|
|
|
73
74
|
req: IncomingMessage,
|
|
74
75
|
res: ServerResponse,
|
|
75
76
|
): Promise<void> {
|
|
77
|
+
if (deps.signal?.aborted) {
|
|
78
|
+
res.writeHead(503);
|
|
79
|
+
res.end('Lucidity is restarting. Reconnect before sending.');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
76
82
|
if (req.method === 'GET' && req.url === '/health') {
|
|
77
83
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
78
84
|
res.end(JSON.stringify({ ok: true }));
|
|
@@ -170,7 +176,7 @@ export function createChatServer(deps: ChatServerDeps): Server {
|
|
|
170
176
|
const input = await buildChatInput();
|
|
171
177
|
for await (const ev of executor.runStream!({
|
|
172
178
|
...input,
|
|
173
|
-
signal: ac.signal,
|
|
179
|
+
signal: deps.signal ? AbortSignal.any([ac.signal, deps.signal]) : ac.signal,
|
|
174
180
|
})) {
|
|
175
181
|
if (ev.type === 'session')
|
|
176
182
|
send({ type: 'session', sessionId: ev.sessionId });
|
package/src/coding/listPrs.ts
CHANGED
|
@@ -69,3 +69,17 @@ export async function listPrs(
|
|
|
69
69
|
return { branch, prs: [], error: (raw.split('\n')[0] ?? '').slice(0, 200) };
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
/** The head commit of the merged pull request opened from `branch`, if there is one. Never throws. */
|
|
74
|
+
export async function mergedPrHead(repoRoot: string, branch: string): Promise<string | undefined> {
|
|
75
|
+
try {
|
|
76
|
+
const { stdout } = await exec(
|
|
77
|
+
'gh',
|
|
78
|
+
['pr', 'list', '--head', branch, '--state', 'merged', '--limit', '1', '--json', 'headRefOid'],
|
|
79
|
+
{ cwd: repoRoot, env: { ...process.env, PATH: GH_PATH }, maxBuffer: 1024 * 1024 },
|
|
80
|
+
);
|
|
81
|
+
return (JSON.parse(stdout) as { headRefOid?: string }[])[0]?.headRefOid;
|
|
82
|
+
} catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|