@opencorelabs/lucidity 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -5
- package/bin/lucidity.js +9 -1
- package/dist/agentControls.d.ts +3 -3
- package/dist/agentControls.d.ts.map +1 -1
- package/dist/agentControls.js +9 -6
- package/dist/assets/speech/lucidity-speech +0 -0
- package/dist/automations/agent.d.ts.map +1 -1
- package/dist/automations/agent.js +8 -3
- package/dist/automations/githubIssues.d.ts +25 -0
- package/dist/automations/githubIssues.d.ts.map +1 -0
- package/dist/automations/githubIssues.js +48 -0
- package/dist/automations/service.d.ts +4 -0
- package/dist/automations/service.d.ts.map +1 -1
- package/dist/automations/service.js +24 -3
- package/dist/automations/skill.d.ts +1 -1
- package/dist/automations/skill.d.ts.map +1 -1
- package/dist/automations/skill.js +3 -25
- package/dist/automations/workflowCrash.integration.d.ts +2 -0
- package/dist/automations/workflowCrash.integration.d.ts.map +1 -0
- package/dist/automations/workflowCrash.integration.js +78 -0
- package/dist/chat/server.d.ts +18 -0
- package/dist/chat/server.d.ts.map +1 -1
- package/dist/chat/server.js +203 -84
- package/dist/coding/agentMessages.d.ts +37 -0
- package/dist/coding/agentMessages.d.ts.map +1 -0
- package/dist/coding/agentMessages.js +220 -0
- package/dist/coding/agentSettings.d.ts +9 -0
- package/dist/coding/agentSettings.d.ts.map +1 -0
- package/dist/coding/agentSettings.js +22 -0
- package/dist/coding/fileContext.d.ts +4 -0
- package/dist/coding/fileContext.d.ts.map +1 -0
- package/dist/coding/fileContext.js +61 -0
- package/dist/coding/listPrs.d.ts +4 -0
- package/dist/coding/listPrs.d.ts.map +1 -1
- package/dist/coding/listPrs.js +1 -1
- package/dist/coding/lucidRouting.d.ts +67 -0
- package/dist/coding/lucidRouting.d.ts.map +1 -0
- package/dist/coding/lucidRouting.js +216 -0
- package/dist/coding/overviewSources.d.ts +52 -0
- package/dist/coding/overviewSources.d.ts.map +1 -0
- package/dist/coding/overviewSources.js +78 -0
- package/dist/coding/progress.d.ts +27 -0
- package/dist/coding/progress.d.ts.map +1 -0
- package/dist/coding/progress.js +152 -0
- package/dist/coding/repositoryRequests.d.ts +38 -0
- package/dist/coding/repositoryRequests.d.ts.map +1 -0
- package/dist/coding/repositoryRequests.js +137 -0
- package/dist/coding/runCodeTurn.d.ts +25 -8
- package/dist/coding/runCodeTurn.d.ts.map +1 -1
- package/dist/coding/runCodeTurn.js +93 -77
- package/dist/coding/workspaceOverview.d.ts +106 -0
- package/dist/coding/workspaceOverview.d.ts.map +1 -0
- package/dist/coding/workspaceOverview.js +96 -0
- package/dist/coding/workspaceRegistry.d.ts +230 -4
- package/dist/coding/workspaceRegistry.d.ts.map +1 -1
- package/dist/coding/workspaceRegistry.js +827 -37
- package/dist/coding/workspaceTitle.d.ts +14 -0
- package/dist/coding/workspaceTitle.d.ts.map +1 -0
- package/dist/coding/workspaceTitle.js +8 -0
- package/dist/coding/worktree.d.ts +1 -1
- package/dist/coding/worktree.d.ts.map +1 -1
- package/dist/coding/worktree.js +3 -2
- package/dist/coding/worktreeSetup.d.ts +1 -1
- package/dist/coding/worktreeSetup.d.ts.map +1 -1
- package/dist/coding/worktreeSetup.js +43 -10
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +38 -3
- package/dist/editor/existingWorkspace.d.ts +3 -0
- package/dist/editor/existingWorkspace.d.ts.map +1 -0
- package/dist/editor/existingWorkspace.js +19 -0
- package/dist/editor/fileActions.d.ts +26 -0
- package/dist/editor/fileActions.d.ts.map +1 -0
- package/dist/editor/fileActions.js +134 -0
- package/dist/editor/files.d.ts +27 -0
- package/dist/editor/files.d.ts.map +1 -0
- package/dist/editor/files.js +279 -0
- package/dist/editor/gitActions.d.ts +18 -0
- package/dist/editor/gitActions.d.ts.map +1 -0
- package/dist/editor/gitActions.js +140 -0
- package/dist/editor/localEndpoint.d.ts +4 -0
- package/dist/editor/localEndpoint.d.ts.map +1 -0
- package/dist/editor/localEndpoint.js +35 -0
- package/dist/editor/service.d.ts +28 -0
- package/dist/editor/service.d.ts.map +1 -0
- package/dist/editor/service.js +101 -0
- package/dist/editor/shellCommands.d.ts +21 -0
- package/dist/editor/shellCommands.d.ts.map +1 -0
- package/dist/editor/shellCommands.js +165 -0
- package/dist/editor/terminals.d.ts +34 -0
- package/dist/editor/terminals.d.ts.map +1 -0
- package/dist/editor/terminals.js +161 -0
- package/dist/editor/types.d.ts +37 -0
- package/dist/editor/types.d.ts.map +1 -0
- package/dist/editor/types.js +1 -0
- package/dist/files/store.d.ts +13 -0
- package/dist/files/store.d.ts.map +1 -0
- package/dist/files/store.js +150 -0
- package/dist/goals/assessment.d.ts +6 -6
- package/dist/index.js +232 -56
- package/dist/install.d.ts +7 -0
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +5 -2
- package/dist/jobs/briefing.d.ts +1 -1
- package/dist/jobs/briefing.d.ts.map +1 -1
- package/dist/jobs/briefing.js +16 -33
- package/dist/jobs/extraction.d.ts +2 -1
- package/dist/jobs/extraction.d.ts.map +1 -1
- package/dist/jobs/extraction.js +2 -2
- package/dist/jobs/fastModeReview.d.ts +3 -1
- package/dist/jobs/fastModeReview.d.ts.map +1 -1
- package/dist/jobs/fastModeReview.js +20 -11
- package/dist/jobs/voiceReview.js +4 -4
- package/dist/jobs/weeklyReview.d.ts +1 -1
- package/dist/jobs/weeklyReview.d.ts.map +1 -1
- package/dist/jobs/weeklyReview.js +2 -5
- package/dist/lucidInvocations.d.ts +44 -0
- package/dist/lucidInvocations.d.ts.map +1 -0
- package/dist/lucidInvocations.js +164 -0
- package/dist/mcp/config.d.ts +8 -2
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +52 -10
- package/dist/mcp/paired.js +1 -0
- package/dist/providerFallbackContext.d.ts +5 -0
- package/dist/providerFallbackContext.d.ts.map +1 -0
- package/dist/providerFallbackContext.js +58 -0
- package/dist/providerRecovery.d.ts +18 -1
- package/dist/providerRecovery.d.ts.map +1 -1
- package/dist/providerRecovery.js +3 -1
- package/dist/providerRoles.d.ts +9 -0
- package/dist/providerRoles.d.ts.map +1 -0
- package/dist/providerRoles.js +25 -0
- package/dist/recall/command.d.ts +139 -0
- package/dist/recall/command.d.ts.map +1 -0
- package/dist/recall/command.js +35 -0
- package/dist/recall/context.d.ts +5 -0
- package/dist/recall/context.d.ts.map +1 -0
- package/dist/recall/context.js +66 -0
- package/dist/recall/conversations.d.ts +182 -0
- package/dist/recall/conversations.d.ts.map +1 -0
- package/dist/recall/conversations.js +58 -0
- package/dist/recall/documents.d.ts +76 -0
- package/dist/recall/documents.d.ts.map +1 -0
- package/dist/recall/documents.js +32 -0
- package/dist/recall/evaluation.d.ts +77 -0
- package/dist/recall/evaluation.d.ts.map +1 -0
- package/dist/recall/evaluation.js +88 -0
- package/dist/recall/factory.d.ts +6 -0
- package/dist/recall/factory.d.ts.map +1 -0
- package/dist/recall/factory.js +20 -0
- package/dist/recall/index.d.ts +13 -0
- package/dist/recall/index.d.ts.map +1 -0
- package/dist/recall/index.js +92 -0
- package/dist/recall/memories.d.ts +16 -0
- package/dist/recall/memories.d.ts.map +1 -0
- package/dist/recall/memories.js +136 -0
- package/dist/recall/memorySelection.d.ts +4 -0
- package/dist/recall/memorySelection.d.ts.map +1 -0
- package/dist/recall/memorySelection.js +16 -0
- package/dist/recall/memoryService.d.ts +22 -0
- package/dist/recall/memoryService.d.ts.map +1 -0
- package/dist/recall/memoryService.js +171 -0
- package/dist/recall/personal.d.ts +127 -0
- package/dist/recall/personal.d.ts.map +1 -0
- package/dist/recall/personal.js +125 -0
- package/dist/recall/projects.d.ts +67 -0
- package/dist/recall/projects.d.ts.map +1 -0
- package/dist/recall/projects.js +117 -0
- package/dist/recall/query.d.ts +5 -0
- package/dist/recall/query.d.ts.map +1 -0
- package/dist/recall/query.js +17 -0
- package/dist/recall/semanticEvaluation.d.ts +2 -0
- package/dist/recall/semanticEvaluation.d.ts.map +1 -0
- package/dist/recall/semanticEvaluation.js +123 -0
- package/dist/recall/service.d.ts +62 -0
- package/dist/recall/service.d.ts.map +1 -0
- package/dist/recall/service.js +94 -0
- package/dist/room/client.d.ts +41 -0
- package/dist/room/client.d.ts.map +1 -1
- package/dist/room/client.js +224 -25
- package/dist/room/codingActivity.d.ts +21 -0
- package/dist/room/codingActivity.d.ts.map +1 -0
- package/dist/room/codingActivity.js +86 -0
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +19 -3
- package/dist/room/context.d.ts +3 -2
- package/dist/room/context.d.ts.map +1 -1
- package/dist/room/context.js +5 -4
- package/dist/room/desktop-live.integration.d.ts +2 -0
- package/dist/room/desktop-live.integration.d.ts.map +1 -0
- package/dist/room/desktop-live.integration.js +219 -0
- package/dist/room/turnQueue.d.ts +24 -2
- package/dist/room/turnQueue.d.ts.map +1 -1
- package/dist/room/turnQueue.js +96 -30
- package/dist/runtimeStore.d.ts +17 -0
- package/dist/runtimeStore.d.ts.map +1 -1
- package/dist/runtimeStore.js +33 -4
- package/dist/setup/page.d.ts +1 -1
- package/dist/setup/page.d.ts.map +1 -1
- package/dist/setup/page.js +15 -2
- package/dist/setup/server.d.ts +5 -1
- package/dist/setup/server.d.ts.map +1 -1
- package/dist/setup/server.js +37 -13
- package/dist/skills/install.d.ts +8 -0
- package/dist/skills/install.d.ts.map +1 -0
- package/dist/skills/install.js +82 -0
- package/dist/skills/lucidity/SKILL.md +65 -0
- package/dist/skills/lucidity-task-handoff/SKILL.md +122 -0
- package/dist/speech/captures.d.ts +4 -0
- package/dist/speech/captures.d.ts.map +1 -1
- package/dist/speech/captures.js +53 -41
- package/dist/updateCli.d.ts +2 -0
- package/dist/updateCli.d.ts.map +1 -0
- package/dist/updateCli.js +40 -0
- package/dist/updateService.d.ts +3 -0
- package/dist/updateService.d.ts.map +1 -0
- package/dist/updateService.js +23 -0
- package/dist/updates/admission.d.ts +23 -0
- package/dist/updates/admission.d.ts.map +1 -0
- package/dist/updates/admission.js +76 -0
- package/dist/updates/bootstrap.d.ts +23 -0
- package/dist/updates/bootstrap.d.ts.map +1 -0
- package/dist/updates/bootstrap.js +95 -0
- package/dist/updates/bootstrapConfig.d.ts +34 -0
- package/dist/updates/bootstrapConfig.d.ts.map +1 -0
- package/dist/updates/bootstrapConfig.js +35 -0
- package/dist/updates/connection.d.ts +20 -0
- package/dist/updates/connection.d.ts.map +1 -0
- package/dist/updates/connection.js +111 -0
- package/dist/updates/developmentAdmission.d.ts +29 -0
- package/dist/updates/developmentAdmission.d.ts.map +1 -0
- package/dist/updates/developmentAdmission.js +73 -0
- package/dist/updates/developmentCli.d.ts +2 -0
- package/dist/updates/developmentCli.d.ts.map +1 -0
- package/dist/updates/developmentCli.js +61 -0
- package/dist/updates/developmentRefresh.d.ts +73 -0
- package/dist/updates/developmentRefresh.d.ts.map +1 -0
- package/dist/updates/developmentRefresh.js +157 -0
- package/dist/updates/developmentService.d.ts +13 -0
- package/dist/updates/developmentService.d.ts.map +1 -0
- package/dist/updates/developmentService.js +217 -0
- package/dist/updates/download.d.ts +7 -0
- package/dist/updates/download.d.ts.map +1 -0
- package/dist/updates/download.js +52 -0
- package/dist/updates/feed.d.ts +7 -0
- package/dist/updates/feed.d.ts.map +1 -0
- package/dist/updates/feed.js +37 -0
- package/dist/updates/installService.d.ts +3 -0
- package/dist/updates/installService.d.ts.map +1 -0
- package/dist/updates/installService.js +78 -0
- package/dist/updates/installationReferences.d.ts +17 -0
- package/dist/updates/installationReferences.d.ts.map +1 -0
- package/dist/updates/installationReferences.js +104 -0
- package/dist/updates/installationStore.d.ts +49 -0
- package/dist/updates/installationStore.d.ts.map +1 -0
- package/dist/updates/installationStore.js +237 -0
- package/dist/updates/installer.d.ts +29 -0
- package/dist/updates/installer.d.ts.map +1 -0
- package/dist/updates/installer.js +205 -0
- package/dist/updates/journal.d.ts +228 -0
- package/dist/updates/journal.d.ts.map +1 -0
- package/dist/updates/journal.js +249 -0
- package/dist/updates/managedLifecycle.d.ts +26 -0
- package/dist/updates/managedLifecycle.d.ts.map +1 -0
- package/dist/updates/managedLifecycle.js +60 -0
- package/dist/updates/migrateService.d.ts +2 -0
- package/dist/updates/migrateService.d.ts.map +1 -0
- package/dist/updates/migrateService.js +44 -0
- package/dist/updates/migration.d.ts +15 -0
- package/dist/updates/migration.d.ts.map +1 -0
- package/dist/updates/migration.js +108 -0
- package/dist/updates/processControl.d.ts +47 -0
- package/dist/updates/processControl.d.ts.map +1 -0
- package/dist/updates/processControl.js +98 -0
- package/dist/updates/processHost.d.ts +52 -0
- package/dist/updates/processHost.d.ts.map +1 -0
- package/dist/updates/processHost.js +165 -0
- package/dist/updates/registerService.d.ts +4 -0
- package/dist/updates/registerService.d.ts.map +1 -0
- package/dist/updates/registerService.js +34 -0
- package/dist/updates/releases.d.ts +84 -0
- package/dist/updates/releases.d.ts.map +1 -0
- package/dist/updates/releases.js +51 -0
- package/dist/updates/retention.d.ts +32 -0
- package/dist/updates/retention.d.ts.map +1 -0
- package/dist/updates/retention.js +188 -0
- package/dist/updates/runner.d.ts +6 -0
- package/dist/updates/runner.d.ts.map +1 -0
- package/dist/updates/runner.js +117 -0
- package/dist/updates/service.d.ts +53 -0
- package/dist/updates/service.d.ts.map +1 -0
- package/dist/updates/service.js +268 -0
- package/dist/updates/servicePlan.d.ts +29 -0
- package/dist/updates/servicePlan.d.ts.map +1 -0
- package/dist/updates/servicePlan.js +58 -0
- package/dist/updates/signCatalog.d.ts +10 -0
- package/dist/updates/signCatalog.d.ts.map +1 -0
- package/dist/updates/signCatalog.js +44 -0
- package/dist/updates/supervisor.d.ts +27 -0
- package/dist/updates/supervisor.d.ts.map +1 -0
- package/dist/updates/supervisor.js +137 -0
- package/dist/updates/windowsService.d.ts +12 -0
- package/dist/updates/windowsService.d.ts.map +1 -0
- package/dist/updates/windowsService.js +51 -0
- package/dist/video/context.d.ts +4 -0
- package/dist/video/context.d.ts.map +1 -0
- package/dist/video/context.js +74 -0
- package/dist/video/store.d.ts +22 -0
- package/dist/video/store.d.ts.map +1 -0
- package/dist/video/store.js +184 -0
- package/npm-shrinkwrap.json +1792 -0
- package/package.json +4 -1
- package/src/agentControls.ts +11 -7
- package/src/automations/agent.ts +11 -2
- package/src/automations/githubIssues.ts +63 -0
- package/src/automations/service.ts +25 -3
- package/src/automations/skill.ts +5 -37
- package/src/automations/workflowCrash.integration.ts +70 -0
- package/src/chat/server.ts +162 -89
- package/src/coding/agentMessages.ts +217 -0
- package/src/coding/agentSettings.ts +22 -0
- package/src/coding/fileContext.ts +72 -0
- package/src/coding/listPrs.ts +1 -1
- package/src/coding/lucidRouting.ts +211 -0
- package/src/coding/overviewSources.ts +86 -0
- package/src/coding/progress.ts +146 -0
- package/src/coding/repositoryRequests.ts +117 -0
- package/src/coding/runCodeTurn.ts +106 -92
- package/src/coding/workspaceOverview.ts +99 -0
- package/src/coding/workspaceRegistry.ts +762 -39
- package/src/coding/workspaceTitle.ts +10 -0
- package/src/coding/worktree.ts +3 -2
- package/src/coding/worktreeSetup.ts +33 -10
- package/src/config.ts +37 -2
- package/src/editor/existingWorkspace.ts +17 -0
- package/src/editor/fileActions.ts +162 -0
- package/src/editor/files.ts +276 -0
- package/src/editor/gitActions.ts +150 -0
- package/src/editor/localEndpoint.ts +28 -0
- package/src/editor/service.ts +93 -0
- package/src/editor/shellCommands.ts +132 -0
- package/src/editor/terminals.ts +129 -0
- package/src/editor/types.ts +32 -0
- package/src/files/store.ts +131 -0
- package/src/index.ts +224 -50
- package/src/install.ts +4 -2
- package/src/jobs/briefing.ts +18 -29
- package/src/jobs/extraction.ts +5 -4
- package/src/jobs/fastModeReview.ts +22 -11
- package/src/jobs/voiceReview.ts +4 -4
- package/src/jobs/weeklyReview.ts +2 -4
- package/src/lucidInvocations.ts +152 -0
- package/src/mcp/config.ts +48 -10
- package/src/mcp/paired.ts +1 -0
- package/src/providerFallbackContext.ts +48 -0
- package/src/providerRecovery.ts +3 -1
- package/src/providerRoles.ts +35 -0
- package/src/recall/command.ts +42 -0
- package/src/recall/context.ts +64 -0
- package/src/recall/conversations.ts +53 -0
- package/src/recall/documents.ts +32 -0
- package/src/recall/evaluation.ts +89 -0
- package/src/recall/factory.ts +21 -0
- package/src/recall/index.ts +87 -0
- package/src/recall/memories.ts +123 -0
- package/src/recall/memorySelection.ts +17 -0
- package/src/recall/memoryService.ts +138 -0
- package/src/recall/personal.ts +97 -0
- package/src/recall/projects.ts +98 -0
- package/src/recall/query.ts +21 -0
- package/src/recall/semanticEvaluation.ts +101 -0
- package/src/recall/service.ts +85 -0
- package/src/room/client.ts +238 -31
- package/src/room/codingActivity.ts +70 -0
- package/src/room/computer.ts +19 -3
- package/src/room/context.ts +7 -2
- package/src/room/desktop-live.integration.ts +203 -0
- package/src/room/turnQueue.ts +91 -34
- package/src/runtimeStore.ts +36 -4
- package/src/setup/page.ts +15 -2
- package/src/setup/server.ts +28 -5
- package/src/skills/install.ts +65 -0
- package/src/speech/captures.ts +56 -44
- package/src/updateCli.ts +37 -0
- package/src/updateService.ts +21 -0
- package/src/updates/admission.ts +70 -0
- package/src/updates/bootstrap.ts +77 -0
- package/src/updates/bootstrapConfig.ts +29 -0
- package/src/updates/connection.ts +84 -0
- package/src/updates/developmentAdmission.ts +56 -0
- package/src/updates/developmentCli.ts +47 -0
- package/src/updates/developmentRefresh.ts +130 -0
- package/src/updates/developmentService.ts +170 -0
- package/src/updates/download.ts +53 -0
- package/src/updates/feed.ts +34 -0
- package/src/updates/installService.ts +67 -0
- package/src/updates/installationReferences.ts +87 -0
- package/src/updates/installationStore.ts +196 -0
- package/src/updates/installer.ts +203 -0
- package/src/updates/journal.ts +250 -0
- package/src/updates/managedLifecycle.ts +64 -0
- package/src/updates/migrateService.ts +33 -0
- package/src/updates/migration.ts +92 -0
- package/src/updates/processControl.ts +96 -0
- package/src/updates/processHost.ts +159 -0
- package/src/updates/registerService.ts +27 -0
- package/src/updates/releases.ts +53 -0
- package/src/updates/retention.ts +154 -0
- package/src/updates/runner.ts +104 -0
- package/src/updates/service.ts +241 -0
- package/src/updates/servicePlan.ts +63 -0
- package/src/updates/signCatalog.ts +40 -0
- package/src/updates/supervisor.ts +114 -0
- package/src/updates/windowsService.ts +54 -0
- package/src/video/context.ts +101 -0
- package/src/video/store.ts +250 -0
- package/vendor/decisions/dist/followup.d.ts +14 -0
- package/vendor/decisions/dist/followup.js +86 -0
- package/vendor/decisions/dist/index.d.ts +3 -0
- package/vendor/decisions/dist/index.js +3 -0
- package/vendor/decisions/dist/repositoryReplay.d.ts +103 -0
- package/vendor/decisions/dist/repositoryReplay.js +177 -0
- package/vendor/decisions/dist/repositoryRouting.d.ts +21 -0
- package/vendor/decisions/dist/repositoryRouting.js +125 -0
- package/vendor/decisions/src/followup.ts +129 -0
- package/vendor/decisions/src/index.ts +3 -0
- package/vendor/decisions/src/repositoryReplay.ts +312 -0
- package/vendor/decisions/src/repositoryRouting.ts +167 -0
- package/vendor/mcp-server/README.md +6 -0
- package/vendor/mcp-server/dist/index.js +21 -7
- package/vendor/mcp-server/dist/localDaemon.d.ts +4 -0
- package/vendor/mcp-server/dist/localDaemon.d.ts.map +1 -0
- package/vendor/mcp-server/dist/localDaemon.js +41 -0
- package/vendor/mcp-server/dist/tools/agents.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/agents.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/agents.js +60 -0
- package/vendor/mcp-server/dist/tools/artifacts.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/artifacts.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/artifacts.js +22 -0
- package/vendor/mcp-server/dist/tools/automations.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/automations.js +7 -32
- package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts +1 -1
- package/vendor/mcp-server/dist/tools/commandEventFormat.js +2 -2
- package/vendor/mcp-server/dist/tools/commandEvents.js +1 -1
- package/vendor/mcp-server/dist/tools/comments.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/comments.js +5 -1
- package/vendor/mcp-server/dist/tools/journal.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/journal.js +1 -0
- package/vendor/mcp-server/dist/tools/memory.d.ts +0 -10
- package/vendor/mcp-server/dist/tools/memory.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/memory.js +28 -102
- package/vendor/mcp-server/dist/tools/notes.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/notes.js +38 -4
- package/vendor/mcp-server/dist/tools/recall.d.ts +6 -0
- package/vendor/mcp-server/dist/tools/recall.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/recall.js +78 -0
- package/vendor/mcp-server/dist/tools/summary.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/summary.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/summary.js +22 -0
- package/vendor/mcp-server/dist/tools/taskSheet.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/taskSheet.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/taskSheet.js +32 -0
- package/vendor/mcp-server/dist/tools/tasks.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/tasks.js +117 -24
- package/vendor/mcp-server/dist/tools/worktrees.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/worktrees.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/worktrees.js +51 -0
- package/vendor/mcp-server/package.json +1 -1
- package/vendor/mcp-server/src/index.ts +17 -7
- package/vendor/mcp-server/src/localDaemon.ts +56 -0
- package/vendor/mcp-server/src/tools/agents.ts +78 -0
- package/vendor/mcp-server/src/tools/artifacts.ts +26 -0
- package/vendor/mcp-server/src/tools/automations.ts +7 -47
- package/vendor/mcp-server/src/tools/commandEventFormat.ts +2 -2
- package/vendor/mcp-server/src/tools/commandEvents.ts +1 -1
- package/vendor/mcp-server/src/tools/comments.ts +4 -1
- package/vendor/mcp-server/src/tools/journal.ts +1 -0
- package/vendor/mcp-server/src/tools/memory.ts +37 -130
- package/vendor/mcp-server/src/tools/notes.ts +35 -5
- package/vendor/mcp-server/src/tools/recall.ts +89 -0
- package/vendor/mcp-server/src/tools/summary.ts +30 -0
- package/vendor/mcp-server/src/tools/taskSheet.ts +60 -0
- package/vendor/mcp-server/src/tools/tasks.ts +125 -24
- package/vendor/mcp-server/src/tools/worktrees.ts +61 -0
- package/vendor/notes/dist/artifacts.d.ts +8 -0
- package/vendor/notes/dist/artifacts.d.ts.map +1 -0
- package/vendor/notes/dist/artifacts.js +105 -0
- package/vendor/notes/dist/index.d.ts +1 -0
- package/vendor/notes/dist/index.d.ts.map +1 -1
- package/vendor/notes/dist/index.js +1 -0
- package/vendor/notes/dist/vault.d.ts.map +1 -1
- package/vendor/notes/dist/vault.js +2 -0
- package/vendor/notes/src/artifacts.ts +100 -0
- package/vendor/notes/src/index.ts +2 -0
- package/vendor/notes/src/vault.ts +1 -0
- package/vendor/runtime/README.md +8 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts +18 -1
- package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.js +157 -39
- package/vendor/runtime/dist/executor/claudeCode.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeCode.js +19 -2
- package/vendor/runtime/dist/executor/claudeSession.d.ts +32 -0
- package/vendor/runtime/dist/executor/claudeSession.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/claudeSession.js +154 -0
- package/vendor/runtime/dist/executor/codex.d.ts +18 -2
- package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codex.js +134 -18
- package/vendor/runtime/dist/executor/codexSessions.d.ts +5 -10
- package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexSessions.js +12 -78
- package/vendor/runtime/dist/executor/fallback.d.ts +27 -0
- package/vendor/runtime/dist/executor/fallback.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/fallback.js +45 -0
- package/vendor/runtime/dist/executor/health.d.ts +19 -1
- package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/health.js +19 -2
- package/vendor/runtime/dist/executor/integrations.d.ts +4 -0
- package/vendor/runtime/dist/executor/integrations.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/integrations.js +5 -0
- package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -2
- package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/liveTurns.js +3 -3
- package/vendor/runtime/dist/executor/ownership.d.ts +18 -1
- package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/ownership.js +3 -1
- package/vendor/runtime/dist/executor/providerRouter.d.ts +13 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/providerRouter.js +91 -5
- package/vendor/runtime/dist/executor/sessionRetention.d.ts +34 -0
- package/vendor/runtime/dist/executor/sessionRetention.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/sessionRetention.js +126 -0
- package/vendor/runtime/dist/executor/types.d.ts +30 -7
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/usage.d.ts +5 -0
- package/vendor/runtime/dist/executor/usage.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/usage.js +56 -0
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +2 -5
- package/vendor/runtime/dist/harness/types.d.ts +3 -1
- package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
- package/vendor/runtime/dist/index.d.ts +6 -1
- package/vendor/runtime/dist/index.d.ts.map +1 -1
- package/vendor/runtime/dist/index.js +3 -0
- package/vendor/runtime/dist/prompts/recall.d.ts +15 -0
- package/vendor/runtime/dist/prompts/recall.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/recall.js +71 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +149 -37
- package/vendor/runtime/src/executor/claudeCode.ts +17 -3
- package/vendor/runtime/src/executor/claudeSession.ts +180 -0
- package/vendor/runtime/src/executor/codex.ts +136 -21
- package/vendor/runtime/src/executor/codexSessions.ts +18 -82
- package/vendor/runtime/src/executor/fallback.ts +63 -0
- package/vendor/runtime/src/executor/health.ts +16 -2
- package/vendor/runtime/src/executor/integrations.ts +7 -0
- package/vendor/runtime/src/executor/liveTurns.ts +5 -5
- package/vendor/runtime/src/executor/ownership.ts +3 -1
- package/vendor/runtime/src/executor/providerRouter.ts +85 -4
- package/vendor/runtime/src/executor/sessionRetention.ts +166 -0
- package/vendor/runtime/src/executor/types.ts +27 -7
- package/vendor/runtime/src/executor/usage.ts +58 -0
- package/vendor/runtime/src/harness/index.ts +2 -5
- package/vendor/runtime/src/harness/types.ts +3 -1
- package/vendor/runtime/src/index.ts +7 -1
- package/vendor/runtime/src/prompts/recall.ts +72 -0
- package/vendor/shared/dist/accountDevices.d.ts +62 -0
- package/vendor/shared/dist/accountDevices.d.ts.map +1 -0
- package/vendor/shared/dist/accountDevices.js +25 -0
- package/vendor/shared/dist/activityRecovery.d.ts +37 -0
- package/vendor/shared/dist/activityRecovery.d.ts.map +1 -0
- package/vendor/shared/dist/activityRecovery.js +39 -0
- package/vendor/shared/dist/agentMessages.d.ts +187 -0
- package/vendor/shared/dist/agentMessages.d.ts.map +1 -0
- package/vendor/shared/dist/agentMessages.js +70 -0
- package/vendor/shared/dist/aiUsage.d.ts +30 -0
- package/vendor/shared/dist/aiUsage.d.ts.map +1 -0
- package/vendor/shared/dist/aiUsage.js +14 -0
- package/vendor/shared/dist/artifacts.d.ts +28 -0
- package/vendor/shared/dist/artifacts.d.ts.map +1 -0
- package/vendor/shared/dist/artifacts.js +47 -0
- package/vendor/shared/dist/automationTemplates.d.ts.map +1 -1
- package/vendor/shared/dist/automationTemplates.js +1 -0
- package/vendor/shared/dist/automations.d.ts +61 -14
- package/vendor/shared/dist/automations.d.ts.map +1 -1
- package/vendor/shared/dist/automations.js +10 -3
- package/vendor/shared/dist/cardStudio.d.ts +31 -31
- package/vendor/shared/dist/chatActivity.d.ts +17 -0
- package/vendor/shared/dist/chatActivity.d.ts.map +1 -0
- package/vendor/shared/dist/chatActivity.js +47 -0
- package/vendor/shared/dist/codingActivity.d.ts +60 -0
- package/vendor/shared/dist/codingActivity.d.ts.map +1 -0
- package/vendor/shared/dist/codingActivity.js +33 -0
- package/vendor/shared/dist/commandLocal.d.ts +1 -1
- package/vendor/shared/dist/commandLocal.d.ts.map +1 -1
- package/vendor/shared/dist/commands.d.ts +32 -32
- package/vendor/shared/dist/commands.d.ts.map +1 -1
- package/vendor/shared/dist/commands.js +1 -1
- package/vendor/shared/dist/commentMentions.d.ts +20 -0
- package/vendor/shared/dist/commentMentions.d.ts.map +1 -0
- package/vendor/shared/dist/commentMentions.js +14 -0
- package/vendor/shared/dist/computer.d.ts +48 -8
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +25 -0
- package/vendor/shared/dist/constants.d.ts +1 -1
- package/vendor/shared/dist/constants.d.ts.map +1 -1
- package/vendor/shared/dist/constants.js +5 -0
- package/vendor/shared/dist/daemonUpdates.d.ts +123 -0
- package/vendor/shared/dist/daemonUpdates.d.ts.map +1 -0
- package/vendor/shared/dist/daemonUpdates.js +106 -0
- package/vendor/shared/dist/deviceInteraction.d.ts +23 -0
- package/vendor/shared/dist/deviceInteraction.d.ts.map +1 -0
- package/vendor/shared/dist/deviceInteraction.js +32 -0
- package/vendor/shared/dist/doctor.d.ts +50 -0
- package/vendor/shared/dist/doctor.d.ts.map +1 -0
- package/vendor/shared/dist/doctor.js +15 -0
- package/vendor/shared/dist/fileUploads.d.ts +39 -0
- package/vendor/shared/dist/fileUploads.d.ts.map +1 -0
- package/vendor/shared/dist/fileUploads.js +24 -0
- package/vendor/shared/dist/files.d.ts +11 -0
- package/vendor/shared/dist/files.d.ts.map +1 -0
- package/vendor/shared/dist/files.js +19 -0
- package/vendor/shared/dist/githubContributions.d.ts +1 -1
- package/vendor/shared/dist/goals.d.ts +7 -7
- package/vendor/shared/dist/index.d.ts +29 -2
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +26 -1
- package/vendor/shared/dist/lucidFollowups.d.ts +95 -0
- package/vendor/shared/dist/lucidFollowups.d.ts.map +1 -0
- package/vendor/shared/dist/lucidFollowups.js +45 -0
- package/vendor/shared/dist/lucidInvocations.d.ts +82 -0
- package/vendor/shared/dist/lucidInvocations.d.ts.map +1 -0
- package/vendor/shared/dist/lucidInvocations.js +47 -0
- package/vendor/shared/dist/memory.d.ts +162 -0
- package/vendor/shared/dist/memory.d.ts.map +1 -0
- package/vendor/shared/dist/memory.js +26 -0
- package/vendor/shared/dist/messagingSafety.d.ts +43 -0
- package/vendor/shared/dist/messagingSafety.d.ts.map +1 -1
- package/vendor/shared/dist/messagingSafety.js +6 -0
- package/vendor/shared/dist/recall.d.ts +803 -0
- package/vendor/shared/dist/recall.d.ts.map +1 -0
- package/vendor/shared/dist/recall.js +56 -0
- package/vendor/shared/dist/releaseCompatibility.d.ts +228 -0
- package/vendor/shared/dist/releaseCompatibility.d.ts.map +1 -0
- package/vendor/shared/dist/releaseCompatibility.js +145 -0
- package/vendor/shared/dist/repositoryRequests.d.ts +173 -0
- package/vendor/shared/dist/repositoryRequests.d.ts.map +1 -0
- package/vendor/shared/dist/repositoryRequests.js +38 -0
- package/vendor/shared/dist/repositoryRouting.d.ts +169 -0
- package/vendor/shared/dist/repositoryRouting.d.ts.map +1 -0
- package/vendor/shared/dist/repositoryRouting.js +102 -0
- package/vendor/shared/dist/roomClient.d.ts +107 -0
- package/vendor/shared/dist/roomClient.d.ts.map +1 -0
- package/vendor/shared/dist/roomClient.js +371 -0
- package/vendor/shared/dist/schemas/comment.d.ts +46 -0
- package/vendor/shared/dist/schemas/comment.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/comment.js +10 -0
- package/vendor/shared/dist/schemas/conversation.d.ts +80 -1
- package/vendor/shared/dist/schemas/conversation.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/conversation.js +12 -1
- package/vendor/shared/dist/schemas/harness.d.ts +1631 -17
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +106 -3
- package/vendor/shared/dist/schemas/notification.d.ts +3 -1
- package/vendor/shared/dist/schemas/notification.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/notification.js +2 -1
- package/vendor/shared/dist/schemas/organization.d.ts +2 -0
- package/vendor/shared/dist/schemas/organization.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/organization.js +2 -0
- package/vendor/shared/dist/schemas/project.d.ts +2 -2
- package/vendor/shared/dist/schemas/request.d.ts +1 -1
- package/vendor/shared/dist/schemas/task.d.ts +1 -1
- package/vendor/shared/dist/smartCapture.js +1 -1
- package/vendor/shared/dist/spokenNames.d.ts +1 -1
- package/vendor/shared/dist/spokenNames.js +1 -1
- package/vendor/shared/dist/taskActivity.d.ts +5 -5
- package/vendor/shared/dist/taskSharing.d.ts +8 -0
- package/vendor/shared/dist/taskSharing.d.ts.map +1 -0
- package/vendor/shared/dist/taskSharing.js +9 -0
- package/vendor/shared/dist/thinking-orb/engine/core.d.ts +31 -0
- package/vendor/shared/dist/thinking-orb/engine/core.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/core.js +62 -0
- package/vendor/shared/dist/thinking-orb/engine/ctx.d.ts +9 -0
- package/vendor/shared/dist/thinking-orb/engine/ctx.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/ctx.js +1 -0
- package/vendor/shared/dist/thinking-orb/engine/lattice.d.ts +5 -0
- package/vendor/shared/dist/thinking-orb/engine/lattice.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/lattice.js +184 -0
- package/vendor/shared/dist/thinking-orb/engine/morph.d.ts +3 -0
- package/vendor/shared/dist/thinking-orb/engine/morph.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/morph.js +117 -0
- package/vendor/shared/dist/thinking-orb/engine/orbits.d.ts +3 -0
- package/vendor/shared/dist/thinking-orb/engine/orbits.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/orbits.js +66 -0
- package/vendor/shared/dist/thinking-orb/engine/profiles.d.ts +8 -0
- package/vendor/shared/dist/thinking-orb/engine/profiles.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/profiles.js +113 -0
- package/vendor/shared/dist/thinking-orb/engine/registry.d.ts +4 -0
- package/vendor/shared/dist/thinking-orb/engine/registry.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/registry.js +14 -0
- package/vendor/shared/dist/thinking-orb/engine/ribbon.d.ts +3 -0
- package/vendor/shared/dist/thinking-orb/engine/ribbon.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/ribbon.js +64 -0
- package/vendor/shared/dist/thinking-orb/engine/types.d.ts +6 -0
- package/vendor/shared/dist/thinking-orb/engine/types.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/engine/types.js +2 -0
- package/vendor/shared/dist/thinking-orb/index.d.ts +7 -0
- package/vendor/shared/dist/thinking-orb/index.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/index.js +2 -0
- package/vendor/shared/dist/thinking-orb/presets.d.ts +12 -0
- package/vendor/shared/dist/thinking-orb/presets.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/presets.js +67 -0
- package/vendor/shared/dist/thinking-orb/types.d.ts +24 -0
- package/vendor/shared/dist/thinking-orb/types.d.ts.map +1 -0
- package/vendor/shared/dist/thinking-orb/types.js +1 -0
- package/vendor/shared/dist/turnTiming.d.ts +13 -0
- package/vendor/shared/dist/turnTiming.d.ts.map +1 -0
- package/vendor/shared/dist/turnTiming.js +18 -0
- package/vendor/shared/dist/types.d.ts +3 -1
- package/vendor/shared/dist/types.d.ts.map +1 -1
- package/vendor/shared/dist/updateControl.d.ts +168 -0
- package/vendor/shared/dist/updateControl.d.ts.map +1 -0
- package/vendor/shared/dist/updateControl.js +43 -0
- package/vendor/shared/dist/videos.d.ts +31 -0
- package/vendor/shared/dist/videos.d.ts.map +1 -0
- package/vendor/shared/dist/videos.js +34 -0
- package/vendor/shared/dist/workspaceIO.d.ts +188 -0
- package/vendor/shared/dist/workspaceIO.d.ts.map +1 -0
- package/vendor/shared/dist/workspaceIO.js +50 -0
- package/vendor/shared/dist/workspaces.d.ts +740 -2
- package/vendor/shared/dist/workspaces.d.ts.map +1 -1
- package/vendor/shared/dist/workspaces.js +108 -2
- package/vendor/shared/package.json +12 -0
- package/vendor/shared/src/accountDevices.ts +28 -0
- package/vendor/shared/src/activityRecovery.ts +42 -0
- package/vendor/shared/src/agentMessages.ts +82 -0
- package/vendor/shared/src/aiUsage.ts +18 -0
- package/vendor/shared/src/artifacts.ts +48 -0
- package/vendor/shared/src/automationTemplates.ts +1 -0
- package/vendor/shared/src/automations.ts +10 -3
- package/vendor/shared/src/chatActivity.ts +56 -0
- package/vendor/shared/src/codingActivity.ts +40 -0
- package/vendor/shared/src/commandLocal.ts +1 -1
- package/vendor/shared/src/commands.ts +1 -1
- package/vendor/shared/src/commentMentions.ts +20 -0
- package/vendor/shared/src/computer.ts +40 -0
- package/vendor/shared/src/constants.ts +5 -0
- package/vendor/shared/src/daemonUpdates.ts +127 -0
- package/vendor/shared/src/deviceInteraction.ts +35 -0
- package/vendor/shared/src/doctor.ts +19 -0
- package/vendor/shared/src/fileUploads.ts +28 -0
- package/vendor/shared/src/files.ts +21 -0
- package/vendor/shared/src/index.ts +35 -1
- package/vendor/shared/src/lucidFollowups.ts +49 -0
- package/vendor/shared/src/lucidInvocations.ts +62 -0
- package/vendor/shared/src/memory.ts +30 -0
- package/vendor/shared/src/messagingSafety.ts +10 -0
- package/vendor/shared/src/recall.ts +69 -0
- package/vendor/shared/src/releaseCompatibility.ts +162 -0
- package/vendor/shared/src/repositoryRequests.ts +44 -0
- package/vendor/shared/src/repositoryRouting.ts +117 -0
- package/vendor/shared/src/roomClient.ts +351 -0
- package/vendor/shared/src/schemas/comment.ts +10 -0
- package/vendor/shared/src/schemas/conversation.ts +12 -1
- package/vendor/shared/src/schemas/harness.ts +120 -3
- package/vendor/shared/src/schemas/notification.ts +2 -1
- package/vendor/shared/src/schemas/organization.ts +2 -0
- package/vendor/shared/src/smartCapture.ts +1 -1
- package/vendor/shared/src/spokenNames.ts +1 -1
- package/vendor/shared/src/taskSharing.ts +13 -0
- package/vendor/shared/src/thinking-orb/ATTRIBUTION.md +36 -0
- package/vendor/shared/src/thinking-orb/engine/core.ts +81 -0
- package/vendor/shared/src/thinking-orb/engine/ctx.ts +15 -0
- package/vendor/shared/src/thinking-orb/engine/lattice.ts +205 -0
- package/vendor/shared/src/thinking-orb/engine/morph.ts +130 -0
- package/vendor/shared/src/thinking-orb/engine/orbits.ts +80 -0
- package/vendor/shared/src/thinking-orb/engine/profiles.ts +119 -0
- package/vendor/shared/src/thinking-orb/engine/registry.ts +18 -0
- package/vendor/shared/src/thinking-orb/engine/ribbon.ts +71 -0
- package/vendor/shared/src/thinking-orb/engine/types.ts +15 -0
- package/vendor/shared/src/thinking-orb/index.ts +6 -0
- package/vendor/shared/src/thinking-orb/presets.ts +88 -0
- package/vendor/shared/src/thinking-orb/types.ts +25 -0
- package/vendor/shared/src/turnTiming.ts +20 -0
- package/vendor/shared/src/types.ts +1 -1
- package/vendor/shared/src/updateControl.ts +45 -0
- package/vendor/shared/src/videos.ts +37 -0
- package/vendor/shared/src/workspaceIO.ts +61 -0
- package/vendor/shared/src/workspaces.ts +119 -2
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { readFile, writeFile, rename, lstat, mkdir, copyFile, unlink } from 'node:fs/promises';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { DaemonLease } from '../daemonLease.js';
|
|
7
|
+
const MigrationSchema = z.object({
|
|
8
|
+
schema: z.literal(1), configPath: z.string(), legacyPath: z.string(), digest: z.string(),
|
|
9
|
+
phase: z.enum(['saved', 'detached', 'installing', 'registered', 'restored']),
|
|
10
|
+
}).strict();
|
|
11
|
+
/** A stopped standalone installation can migrate without discarding its service definition.
|
|
12
|
+
* A loaded legacy daemon has no authenticated drain contract, so it requires attention.
|
|
13
|
+
* Never infer idle from PID existence, an empty queue display or a health response. */
|
|
14
|
+
export async function migrateStandalone(options) {
|
|
15
|
+
await mkdir(options.directory, { recursive: true, mode: 0o700 });
|
|
16
|
+
const owner = new DaemonLease(join(options.directory, 'migration-owner'));
|
|
17
|
+
const journalPath = join(options.directory, 'migration.json'), backup = join(options.directory, 'standalone.plist');
|
|
18
|
+
const save = async (state) => {
|
|
19
|
+
await writeFile(`${journalPath}.tmp`, JSON.stringify(state), { mode: 0o600, flush: true });
|
|
20
|
+
await rename(`${journalPath}.tmp`, journalPath);
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
let state;
|
|
24
|
+
try {
|
|
25
|
+
state = MigrationSchema.parse(JSON.parse(await readFile(journalPath, 'utf8')));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error.code !== 'ENOENT')
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
if (state && (state.configPath !== options.configPath || state.legacyPath !== options.legacyPath))
|
|
32
|
+
throw new Error('Standalone migration belongs to another installation');
|
|
33
|
+
if (await options.legacyLoaded())
|
|
34
|
+
throw new Error('The standalone daemon cannot prove a safe drain boundary. Finish active work and stop its service, then retry migration. No service was stopped.');
|
|
35
|
+
if (await options.managedLoaded()) {
|
|
36
|
+
if (state?.phase === 'installing' || state?.phase === 'registered') {
|
|
37
|
+
await save({ ...state, phase: 'registered' });
|
|
38
|
+
return 'Managed service is registered. Check its live readiness before running saved commands.';
|
|
39
|
+
}
|
|
40
|
+
throw new Error('A managed service already owns this computer; inspect it before migrating');
|
|
41
|
+
}
|
|
42
|
+
if (await options.managedDefinitionExists() && (!state || !['installing', 'registered'].includes(state.phase)))
|
|
43
|
+
throw new Error('An unrelated managed service definition exists; inspect it before migrating');
|
|
44
|
+
// Verify published metadata and stage through the existing bootstrap, before detaching anything.
|
|
45
|
+
await options.prepare();
|
|
46
|
+
let lease;
|
|
47
|
+
try {
|
|
48
|
+
lease = new DaemonLease(options.daemonDirectory);
|
|
49
|
+
const legacy = await lstat(options.legacyPath).catch(error => {
|
|
50
|
+
if (error.code === 'ENOENT' && state && ['saved', 'detached', 'installing'].includes(state.phase))
|
|
51
|
+
return undefined;
|
|
52
|
+
throw error;
|
|
53
|
+
});
|
|
54
|
+
if (legacy && (!legacy.isFile() || legacy.isSymbolicLink()))
|
|
55
|
+
throw new Error('Expected a regular standalone service definition');
|
|
56
|
+
const contents = await readFile(legacy ? options.legacyPath : backup);
|
|
57
|
+
const digest = createHash('sha256').update(contents).digest('hex');
|
|
58
|
+
if (state && state.digest !== digest)
|
|
59
|
+
throw new Error('Standalone service changed during migration');
|
|
60
|
+
state ??= { schema: 1, configPath: options.configPath, legacyPath: options.legacyPath, digest, phase: 'saved' };
|
|
61
|
+
try {
|
|
62
|
+
await writeFile(backup, contents, { flag: 'wx', mode: 0o600, flush: true });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error.code !== 'EEXIST' || !(await readFile(backup)).equals(contents))
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
await save({ ...state, phase: 'saved' });
|
|
69
|
+
if (await options.legacyLoaded() || await options.managedLoaded())
|
|
70
|
+
throw new Error('Service ownership changed during migration');
|
|
71
|
+
if (legacy)
|
|
72
|
+
await unlink(options.legacyPath);
|
|
73
|
+
await save({ ...state, phase: 'detached' });
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
lease?.close();
|
|
77
|
+
}
|
|
78
|
+
// installUpdateService reacquires the daemon lease and revalidates the signed catalog.
|
|
79
|
+
await save({ ...state, phase: 'installing' });
|
|
80
|
+
try {
|
|
81
|
+
const result = await options.install();
|
|
82
|
+
await save({ ...state, phase: 'registered' });
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
// Registration may have started a healthy service before the caller lost its reply.
|
|
87
|
+
// Never stop it or restore a competing service in that uncertain window.
|
|
88
|
+
// An unloaded definition can still start at the next login. Do not restore
|
|
89
|
+
// the standalone definition alongside a partially registered supervisor.
|
|
90
|
+
if (!await options.managedLoaded() && !await options.managedDefinitionExists()) {
|
|
91
|
+
const stopped = new DaemonLease(options.daemonDirectory);
|
|
92
|
+
try {
|
|
93
|
+
if (createHash('sha256').update(await readFile(backup)).digest('hex') !== state.digest)
|
|
94
|
+
throw new Error('Saved standalone service changed; manual recovery required');
|
|
95
|
+
await copyFile(backup, options.legacyPath, constants.COPYFILE_EXCL); // Exclusive: preserve any concurrent replacement.
|
|
96
|
+
await save({ ...state, phase: 'restored' });
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
stopped.close();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
owner.close();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ControlCommandSchema: z.ZodObject<{
|
|
3
|
+
protocol: z.ZodLiteral<1>;
|
|
4
|
+
token: z.ZodString;
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
command: z.ZodEnum<{
|
|
7
|
+
resume: "resume";
|
|
8
|
+
quiesce: "quiesce";
|
|
9
|
+
shutdown: "shutdown";
|
|
10
|
+
}>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const ControlReplySchema: z.ZodObject<{
|
|
13
|
+
protocol: z.ZodLiteral<1>;
|
|
14
|
+
token: z.ZodString;
|
|
15
|
+
version: z.ZodString;
|
|
16
|
+
id: z.ZodOptional<z.ZodString>;
|
|
17
|
+
event: z.ZodEnum<{
|
|
18
|
+
error: "error";
|
|
19
|
+
ready: "ready";
|
|
20
|
+
quiescent: "quiescent";
|
|
21
|
+
resumed: "resumed";
|
|
22
|
+
}>;
|
|
23
|
+
message: z.ZodOptional<z.ZodString>;
|
|
24
|
+
computerId: z.ZodOptional<z.ZodString>;
|
|
25
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export type ControlReply = z.infer<typeof ControlReplySchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Install before starting any work source. The caller starts with admission closed.
|
|
30
|
+
* announceReady is called only after this process authenticates to the relay.
|
|
31
|
+
* pause must synchronously stop new/queued starts, then await all active mutating work.
|
|
32
|
+
*/
|
|
33
|
+
export declare function attachUpdateControl(options: {
|
|
34
|
+
version: string;
|
|
35
|
+
capabilities?: () => {
|
|
36
|
+
computerId: string;
|
|
37
|
+
features: string[];
|
|
38
|
+
} | undefined;
|
|
39
|
+
pause: () => Promise<void>;
|
|
40
|
+
resume: () => void;
|
|
41
|
+
shutdown: () => Promise<void>;
|
|
42
|
+
fatal?: (error: unknown) => void;
|
|
43
|
+
}): {
|
|
44
|
+
announceReady: () => void;
|
|
45
|
+
dispose: () => void;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=processControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processControl.d.ts","sourceRoot":"","sources":["../../src/updates/processControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,oBAAoB;;;;;;;;;kBAGtB,CAAC;AACZ,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;kBAMpB,CAAC;AACZ,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IAC5E,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAClC,GAAG;IAAE,aAAa,EAAE,MAAM,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAkErD"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DaemonVersionSchema } from '@lucidity/shared';
|
|
3
|
+
// Local inherited IPC only. Do not expose this contract as a remote command API.
|
|
4
|
+
export const ControlCommandSchema = z.object({
|
|
5
|
+
protocol: z.literal(1), token: z.string().uuid(), id: z.string().uuid(),
|
|
6
|
+
command: z.enum(['quiesce', 'resume', 'shutdown']),
|
|
7
|
+
}).strict();
|
|
8
|
+
export const ControlReplySchema = z.object({
|
|
9
|
+
protocol: z.literal(1), token: z.string().uuid(), version: DaemonVersionSchema,
|
|
10
|
+
id: z.string().uuid().optional(),
|
|
11
|
+
event: z.enum(['ready', 'quiescent', 'resumed', 'error']),
|
|
12
|
+
message: z.string().max(500).optional(),
|
|
13
|
+
computerId: z.string().max(128).optional(), features: z.array(z.string().max(80)).max(64).optional(),
|
|
14
|
+
}).strict();
|
|
15
|
+
/**
|
|
16
|
+
* Install before starting any work source. The caller starts with admission closed.
|
|
17
|
+
* announceReady is called only after this process authenticates to the relay.
|
|
18
|
+
* pause must synchronously stop new/queued starts, then await all active mutating work.
|
|
19
|
+
*/
|
|
20
|
+
export function attachUpdateControl(options) {
|
|
21
|
+
const token = z.string().uuid().parse(process.env['LUCIDITY_SUPERVISOR_TOKEN']);
|
|
22
|
+
const version = DaemonVersionSchema.parse(options.version);
|
|
23
|
+
if (!process.send || !process.connected)
|
|
24
|
+
throw new Error('Managed daemon requires inherited supervisor IPC');
|
|
25
|
+
let generation = 0;
|
|
26
|
+
let state = 'starting';
|
|
27
|
+
let announced = false;
|
|
28
|
+
let stopping;
|
|
29
|
+
const shutdown = () => stopping ??= Promise.resolve().then(options.shutdown);
|
|
30
|
+
const fatal = options.fatal ?? ((error) => { console.error('[update-control]', error); process.exit(1); });
|
|
31
|
+
const send = (event, id, message) => {
|
|
32
|
+
if (process.connected)
|
|
33
|
+
process.send({ protocol: 1, token, version, event, ...(event === 'ready' && process.env['LUCIDITY_SUPERVISOR_CAPABILITIES'] === '1' ? options.capabilities?.() : {}), ...(id ? { id } : {}), ...(message ? { message } : {}) }, (error) => { if (error && process.connected)
|
|
34
|
+
fatal(error); });
|
|
35
|
+
};
|
|
36
|
+
const handle = async (raw) => {
|
|
37
|
+
const parsed = ControlCommandSchema.safeParse(raw);
|
|
38
|
+
if (!parsed.success || parsed.data.token !== token)
|
|
39
|
+
return;
|
|
40
|
+
const { command, id } = parsed.data;
|
|
41
|
+
if (state === 'stopping')
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
if (command === 'quiesce') {
|
|
45
|
+
const request = ++generation;
|
|
46
|
+
state = 'draining';
|
|
47
|
+
await options.pause();
|
|
48
|
+
if (generation !== request)
|
|
49
|
+
return; // A timed-out drain was cancelled by resume.
|
|
50
|
+
state = 'paused';
|
|
51
|
+
send('quiescent', id);
|
|
52
|
+
}
|
|
53
|
+
else if (command === 'resume') {
|
|
54
|
+
if (!announced)
|
|
55
|
+
throw new Error('Daemon has not established relay readiness');
|
|
56
|
+
++generation;
|
|
57
|
+
options.resume();
|
|
58
|
+
state = 'running';
|
|
59
|
+
send('resumed', id);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (state === 'running' || state === 'draining')
|
|
63
|
+
throw new Error('Cannot stop before work has drained');
|
|
64
|
+
++generation;
|
|
65
|
+
state = 'stopping';
|
|
66
|
+
await shutdown();
|
|
67
|
+
// shutdown must finish closing stores/providers before resolving.
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
send('error', id, error instanceof Error ? error.message.slice(0, 500) : 'Process control failed');
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const onMessage = (raw) => { void handle(raw); };
|
|
76
|
+
const onDisconnect = () => {
|
|
77
|
+
++generation;
|
|
78
|
+
state = 'stopping';
|
|
79
|
+
// Parent failure never kills active work. A replacement supervisor must prove
|
|
80
|
+
// that the daemon ownership lock is free before starting another process.
|
|
81
|
+
void Promise.resolve().then(options.pause).then(shutdown).then(() => process.exit(0)).catch(fatal);
|
|
82
|
+
};
|
|
83
|
+
process.on('message', onMessage);
|
|
84
|
+
process.on('disconnect', onDisconnect);
|
|
85
|
+
return {
|
|
86
|
+
announceReady() {
|
|
87
|
+
// Initialization may finish after the parent has requested shutdown or died.
|
|
88
|
+
if (announced || state === 'stopping')
|
|
89
|
+
return;
|
|
90
|
+
if (state !== 'starting')
|
|
91
|
+
throw new Error('Unexpected daemon readiness');
|
|
92
|
+
announced = true;
|
|
93
|
+
state = 'paused';
|
|
94
|
+
send('ready');
|
|
95
|
+
},
|
|
96
|
+
dispose() { process.off('message', onMessage); process.off('disconnect', onDisconnect); },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface RuntimeHost {
|
|
2
|
+
/** Start with all work sources paused; resolve after process + relay readiness. */
|
|
3
|
+
start(version: string): Promise<void>;
|
|
4
|
+
quiesce(): Promise<void>;
|
|
5
|
+
resume(): Promise<void>;
|
|
6
|
+
/** Resolve only after process death and proof that no orphan owns the daemon lock. */
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/** A process driver, not a service installer. Paths must come from a verified runtime store. */
|
|
10
|
+
export declare class ProcessRuntimeHost implements RuntimeHost {
|
|
11
|
+
private readonly options;
|
|
12
|
+
private child?;
|
|
13
|
+
private token;
|
|
14
|
+
private version;
|
|
15
|
+
private live?;
|
|
16
|
+
get capabilities(): {
|
|
17
|
+
computerId: string;
|
|
18
|
+
features: string[];
|
|
19
|
+
} | undefined;
|
|
20
|
+
private state;
|
|
21
|
+
private exited;
|
|
22
|
+
private pending;
|
|
23
|
+
private busy;
|
|
24
|
+
get hasProcess(): boolean;
|
|
25
|
+
get ready(): boolean;
|
|
26
|
+
constructor(options: {
|
|
27
|
+
resolveRuntime: (version: string) => Promise<{
|
|
28
|
+
entry: string;
|
|
29
|
+
cwd: string;
|
|
30
|
+
env?: NodeJS.ProcessEnv;
|
|
31
|
+
}>;
|
|
32
|
+
/** Acquire/release the daemon's real ownership lock, not a PID existence check. */
|
|
33
|
+
assertStopped: () => void | Promise<void>;
|
|
34
|
+
startupTimeoutMs?: number;
|
|
35
|
+
drainTimeoutMs?: number;
|
|
36
|
+
commandTimeoutMs?: number;
|
|
37
|
+
execArgv?: string[];
|
|
38
|
+
});
|
|
39
|
+
private wait;
|
|
40
|
+
private rejectPending;
|
|
41
|
+
private exclusively;
|
|
42
|
+
start(version: string): Promise<void>;
|
|
43
|
+
quiesce(): Promise<void>;
|
|
44
|
+
resume(): Promise<void>;
|
|
45
|
+
stop(): Promise<void>;
|
|
46
|
+
private startProcess;
|
|
47
|
+
private command;
|
|
48
|
+
private quiesceProcess;
|
|
49
|
+
private resumeProcess;
|
|
50
|
+
private stopProcess;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=processHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processHost.d.ts","sourceRoot":"","sources":["../../src/updates/processHost.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,mFAAmF;IACnF,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,sFAAsF;IACtF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAID,gGAAgG;AAChG,qBAAa,kBAAmB,YAAW,WAAW;IAYxC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAXpC,OAAO,CAAC,KAAK,CAAC,CAAe;IAC7B,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,IAAI,CAAC,CAA6C;IAC1D,IAAI,YAAY;oBADa,MAAM;kBAAY,MAAM,EAAE;kBACU;IACjE,OAAO,CAAC,KAAK,CAAyE;IACtF,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,IAAI,CAAS;IACrB,IAAI,UAAU,IAAI,OAAO,CAAqC;IAC9D,IAAI,KAAK,IAAI,OAAO,CAAyD;gBAChD,OAAO,EAAE;QACpC,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;SAAE,CAAC,CAAC;QACtG,mFAAmF;QACnF,aAAa,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB;IAED,OAAO,CAAC,IAAI;IAUZ,OAAO,CAAC,aAAa;YAKP,WAAW;IAMzB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACrC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IACxB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAEP,YAAY;YAoDZ,OAAO;YAeP,cAAc;YAOd,aAAa;YAMb,WAAW;CAa1B"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { fork } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { isAbsolute } from 'node:path';
|
|
4
|
+
import { ControlReplySchema } from './processControl.js';
|
|
5
|
+
/** A process driver, not a service installer. Paths must come from a verified runtime store. */
|
|
6
|
+
export class ProcessRuntimeHost {
|
|
7
|
+
options;
|
|
8
|
+
child;
|
|
9
|
+
token = '';
|
|
10
|
+
version = '';
|
|
11
|
+
live;
|
|
12
|
+
get capabilities() { return this.ready ? this.live : undefined; }
|
|
13
|
+
state = 'stopped';
|
|
14
|
+
exited = Promise.resolve();
|
|
15
|
+
pending = new Map();
|
|
16
|
+
busy = false;
|
|
17
|
+
get hasProcess() { return this.child !== undefined; }
|
|
18
|
+
get ready() { return this.hasProcess && this.state !== 'starting'; }
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
}
|
|
22
|
+
wait(id, timeout) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const timer = setTimeout(() => {
|
|
25
|
+
this.pending.delete(id);
|
|
26
|
+
reject(new Error(`Daemon ${id === 'ready' ? 'readiness' : 'control'} timed out`));
|
|
27
|
+
}, timeout);
|
|
28
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
rejectPending(error) {
|
|
32
|
+
for (const pending of this.pending.values()) {
|
|
33
|
+
clearTimeout(pending.timer);
|
|
34
|
+
pending.reject(error);
|
|
35
|
+
}
|
|
36
|
+
this.pending.clear();
|
|
37
|
+
}
|
|
38
|
+
async exclusively(action) {
|
|
39
|
+
if (this.busy)
|
|
40
|
+
throw new Error('Another process control operation is in progress');
|
|
41
|
+
this.busy = true;
|
|
42
|
+
try {
|
|
43
|
+
await action();
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
this.busy = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
start(version) { return this.exclusively(() => this.startProcess(version)); }
|
|
50
|
+
quiesce() { return this.exclusively(() => this.quiesceProcess()); }
|
|
51
|
+
resume() { return this.exclusively(() => this.resumeProcess()); }
|
|
52
|
+
stop() { return this.exclusively(() => this.stopProcess()); }
|
|
53
|
+
async startProcess(version) {
|
|
54
|
+
if (this.child)
|
|
55
|
+
throw new Error('Previous daemon process has not exited');
|
|
56
|
+
await this.options.assertStopped();
|
|
57
|
+
const runtime = await this.options.resolveRuntime(version);
|
|
58
|
+
if (!isAbsolute(runtime.entry) || !isAbsolute(runtime.cwd))
|
|
59
|
+
throw new Error('Runtime paths must be absolute');
|
|
60
|
+
this.live = undefined;
|
|
61
|
+
this.version = version;
|
|
62
|
+
this.token = randomUUID();
|
|
63
|
+
this.state = 'starting';
|
|
64
|
+
const ready = this.wait('ready', this.options.startupTimeoutMs ?? 60_000);
|
|
65
|
+
// Attach the rejection handler before forking; synchronous fork failure also settles ready.
|
|
66
|
+
void ready.catch(() => { });
|
|
67
|
+
let child;
|
|
68
|
+
try {
|
|
69
|
+
child = fork(runtime.entry, [], { cwd: runtime.cwd, execPath: process.execPath,
|
|
70
|
+
execArgv: this.options.execArgv ?? [], stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
|
|
71
|
+
env: { ...process.env, ...runtime.env, LUCIDITY_SUPERVISOR_TOKEN: this.token, LUCIDITY_SUPERVISOR_CAPABILITIES: '1' } });
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
this.state = 'stopped';
|
|
75
|
+
this.rejectPending(new Error('Could not launch daemon process', { cause: error }));
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
this.child = child;
|
|
79
|
+
this.exited = new Promise((resolve) => {
|
|
80
|
+
// close also covers failure to spawn; an error alone is not proof of process death.
|
|
81
|
+
child.once('close', () => {
|
|
82
|
+
this.child = undefined;
|
|
83
|
+
this.state = 'stopped';
|
|
84
|
+
this.rejectPending(new Error('Daemon exited before completing process control'));
|
|
85
|
+
resolve();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
child.on('error', (error) => this.rejectPending(error));
|
|
89
|
+
child.on('message', (raw) => {
|
|
90
|
+
const parsed = ControlReplySchema.safeParse(raw);
|
|
91
|
+
if (!parsed.success || parsed.data.token !== this.token || parsed.data.version !== this.version)
|
|
92
|
+
return;
|
|
93
|
+
const reply = parsed.data;
|
|
94
|
+
const id = reply.event === 'ready' && !reply.id ? 'ready' : reply.id;
|
|
95
|
+
if (!id)
|
|
96
|
+
return;
|
|
97
|
+
const pending = this.pending.get(id);
|
|
98
|
+
if (!pending)
|
|
99
|
+
return;
|
|
100
|
+
clearTimeout(pending.timer);
|
|
101
|
+
this.pending.delete(id);
|
|
102
|
+
if (reply.event === 'error')
|
|
103
|
+
pending.reject(new Error(reply.message ?? 'Daemon process control failed'));
|
|
104
|
+
else
|
|
105
|
+
pending.resolve(reply);
|
|
106
|
+
});
|
|
107
|
+
const readiness = await ready;
|
|
108
|
+
if (readiness.computerId && readiness.features)
|
|
109
|
+
this.live = { computerId: readiness.computerId, features: readiness.features };
|
|
110
|
+
if (!this.child)
|
|
111
|
+
throw new Error('Daemon exited after readiness');
|
|
112
|
+
this.state = 'paused';
|
|
113
|
+
}
|
|
114
|
+
async command(command, timeout) {
|
|
115
|
+
const child = this.child;
|
|
116
|
+
if (!child?.connected)
|
|
117
|
+
throw new Error('Daemon control channel is unavailable');
|
|
118
|
+
const id = randomUUID();
|
|
119
|
+
const result = this.wait(id, timeout);
|
|
120
|
+
child.send({ protocol: 1, token: this.token, id, command }, (error) => {
|
|
121
|
+
if (error) {
|
|
122
|
+
const pending = this.pending.get(id);
|
|
123
|
+
if (pending) {
|
|
124
|
+
clearTimeout(pending.timer);
|
|
125
|
+
this.pending.delete(id);
|
|
126
|
+
pending.reject(error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const reply = await result;
|
|
131
|
+
if (reply.event !== (command === 'quiesce' ? 'quiescent' : 'resumed'))
|
|
132
|
+
throw new Error('Unexpected process control reply');
|
|
133
|
+
}
|
|
134
|
+
async quiesceProcess() {
|
|
135
|
+
if (!this.child || this.state === 'starting')
|
|
136
|
+
throw new Error('Daemon is not ready to drain');
|
|
137
|
+
this.state = 'draining';
|
|
138
|
+
await this.command('quiesce', this.options.drainTimeoutMs ?? 10 * 60_000);
|
|
139
|
+
this.state = 'paused';
|
|
140
|
+
}
|
|
141
|
+
async resumeProcess() {
|
|
142
|
+
if (!this.child || this.state === 'starting')
|
|
143
|
+
throw new Error('Daemon is not ready to resume');
|
|
144
|
+
await this.command('resume', this.options.commandTimeoutMs ?? 10_000);
|
|
145
|
+
this.state = 'running';
|
|
146
|
+
}
|
|
147
|
+
async stopProcess() {
|
|
148
|
+
if (this.child) {
|
|
149
|
+
if (this.state === 'running' || this.state === 'draining')
|
|
150
|
+
throw new Error('Cannot stop an undrained daemon');
|
|
151
|
+
if (this.child.connected)
|
|
152
|
+
this.child.send({ protocol: 1, token: this.token, id: randomUUID(), command: 'shutdown' }, () => { });
|
|
153
|
+
let timer;
|
|
154
|
+
try {
|
|
155
|
+
await Promise.race([this.exited, new Promise((_, reject) => {
|
|
156
|
+
timer = setTimeout(() => reject(new Error('Daemon process did not exit; refusing to switch versions')), this.options.commandTimeoutMs ?? 10_000);
|
|
157
|
+
})]);
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
clearTimeout(timer);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
await this.options.assertStopped();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ServiceCommand, UpdateServicePlan } from './servicePlan.js';
|
|
2
|
+
/** Never overwrite a different installation or restart a running service. */
|
|
3
|
+
export declare function registerUpdateService(plan: UpdateServicePlan, run?: (command: ServiceCommand) => void): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=registerService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerService.d.ts","sourceRoot":"","sources":["../../src/updates/registerService.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAM1E,6EAA6E;AAC7E,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,GAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAc,iBAgBpH"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
const execute = ({ command, args }) => {
|
|
5
|
+
execFileSync(command, args, { stdio: 'pipe', timeout: 30_000, windowsHide: true });
|
|
6
|
+
};
|
|
7
|
+
/** Never overwrite a different installation or restart a running service. */
|
|
8
|
+
export async function registerUpdateService(plan, run = execute) {
|
|
9
|
+
const files = [...(plan.supportFiles ?? []), { path: plan.path, contents: plan.contents, encoding: plan.encoding }];
|
|
10
|
+
for (const file of files) {
|
|
11
|
+
try {
|
|
12
|
+
if (await readFile(file.path, file.encoding ?? 'utf8') !== file.contents)
|
|
13
|
+
throw new Error('Existing updater service differs; refusing to overwrite it');
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error.code !== 'ENOENT')
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
await mkdir(dirname(file.path), { recursive: true, mode: 0o700 });
|
|
22
|
+
try {
|
|
23
|
+
await writeFile(file.path, file.contents, { mode: 0o600, flag: 'wx', encoding: file.encoding ?? 'utf8' });
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error.code !== 'EEXIST')
|
|
27
|
+
throw error;
|
|
28
|
+
if (await readFile(file.path, file.encoding ?? 'utf8') !== file.contents)
|
|
29
|
+
throw new Error('Existing updater service differs; refusing to overwrite it');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const command of plan.register)
|
|
33
|
+
run(command);
|
|
34
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type DaemonUpdateChannel } from '@lucidity/shared';
|
|
3
|
+
export declare const ManifestCheckpointSchema: z.ZodObject<{
|
|
4
|
+
sequence: z.ZodNumber;
|
|
5
|
+
digest: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export type ManifestCheckpoint = z.infer<typeof ManifestCheckpointSchema>;
|
|
8
|
+
/** Trusted keys come from the bootstrap installation, never from the downloaded envelope. */
|
|
9
|
+
export declare function verifyReleaseManifest(raw: string, options: {
|
|
10
|
+
keys: Readonly<Record<string, string>>;
|
|
11
|
+
channel: DaemonUpdateChannel;
|
|
12
|
+
now?: number;
|
|
13
|
+
checkpoint?: ManifestCheckpoint;
|
|
14
|
+
}): {
|
|
15
|
+
manifest: {
|
|
16
|
+
schema: 1;
|
|
17
|
+
channel: "internal" | "beta" | "stable";
|
|
18
|
+
sequence: number;
|
|
19
|
+
issuedAt: string;
|
|
20
|
+
expiresAt: string;
|
|
21
|
+
minimumVersion: string;
|
|
22
|
+
withdrawnVersions: string[];
|
|
23
|
+
release: {
|
|
24
|
+
version: string;
|
|
25
|
+
archiveUrl: string;
|
|
26
|
+
integrity: string;
|
|
27
|
+
bytes: number;
|
|
28
|
+
platforms: ("darwin-arm64" | "darwin-x64" | "win32-x64" | "win32-arm64" | "linux-x64" | "linux-arm64")[];
|
|
29
|
+
nodeMinimum: string;
|
|
30
|
+
updateProtocol: number;
|
|
31
|
+
stateEpoch: number;
|
|
32
|
+
} | null;
|
|
33
|
+
rollout: {
|
|
34
|
+
percent: number;
|
|
35
|
+
salt: string;
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
schema: 2;
|
|
39
|
+
channel: "internal" | "beta" | "stable";
|
|
40
|
+
sequence: number;
|
|
41
|
+
issuedAt: string;
|
|
42
|
+
expiresAt: string;
|
|
43
|
+
minimumVersion: string;
|
|
44
|
+
withdrawnVersions: string[];
|
|
45
|
+
distributionPaused: boolean;
|
|
46
|
+
serverProtocols: number[];
|
|
47
|
+
rollout: {
|
|
48
|
+
percent: number;
|
|
49
|
+
salt: string;
|
|
50
|
+
};
|
|
51
|
+
clients: {
|
|
52
|
+
id: string;
|
|
53
|
+
generation: number;
|
|
54
|
+
platform: "android" | "macos" | "windows" | "ios";
|
|
55
|
+
appVersion: string;
|
|
56
|
+
protocols: number[];
|
|
57
|
+
minimumDaemon: string;
|
|
58
|
+
recommendedDaemon: string;
|
|
59
|
+
supported: boolean;
|
|
60
|
+
}[];
|
|
61
|
+
daemons: {
|
|
62
|
+
artifact: {
|
|
63
|
+
version: string;
|
|
64
|
+
archiveUrl: string;
|
|
65
|
+
integrity: string;
|
|
66
|
+
bytes: number;
|
|
67
|
+
platforms: ("darwin-arm64" | "darwin-x64" | "win32-x64" | "win32-arm64" | "linux-x64" | "linux-arm64")[];
|
|
68
|
+
nodeMinimum: string;
|
|
69
|
+
updateProtocol: number;
|
|
70
|
+
stateEpoch: number;
|
|
71
|
+
};
|
|
72
|
+
clientProtocols: number[];
|
|
73
|
+
serverProtocols: number[];
|
|
74
|
+
features: string[];
|
|
75
|
+
}[];
|
|
76
|
+
};
|
|
77
|
+
checkpoint: {
|
|
78
|
+
sequence: number;
|
|
79
|
+
digest: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/** Stable cohorts without publishing computer IDs in the release feed. */
|
|
83
|
+
export declare function daemonRolloutBucket(computerId: string, salt: string): number;
|
|
84
|
+
//# sourceMappingURL=releases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"releases.d.ts","sourceRoot":"","sources":["../../src/updates/releases.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAStF,eAAO,MAAM,wBAAwB;;;kBAG1B,CAAC;AACZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;IAC1D,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBA;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createHash, createPublicKey, verify } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { DaemonUpdatePolicySchema } from '@lucidity/shared';
|
|
4
|
+
const MAX_MANIFEST_BYTES = 128 * 1024;
|
|
5
|
+
const EnvelopeSchema = z.object({
|
|
6
|
+
keyId: z.string().min(1).max(100),
|
|
7
|
+
payload: z.string().min(1).max(MAX_MANIFEST_BYTES),
|
|
8
|
+
signature: z.string().regex(/^[A-Za-z0-9+/]{86}==$/),
|
|
9
|
+
}).strict();
|
|
10
|
+
export const ManifestCheckpointSchema = z.object({
|
|
11
|
+
sequence: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
12
|
+
digest: z.string().regex(/^[a-f0-9]{64}$/),
|
|
13
|
+
}).strict();
|
|
14
|
+
/** Trusted keys come from the bootstrap installation, never from the downloaded envelope. */
|
|
15
|
+
export function verifyReleaseManifest(raw, options) {
|
|
16
|
+
if (Buffer.byteLength(raw) > MAX_MANIFEST_BYTES)
|
|
17
|
+
throw new Error('Release manifest exceeds size limit');
|
|
18
|
+
const envelope = EnvelopeSchema.parse(JSON.parse(raw));
|
|
19
|
+
const pem = Object.hasOwn(options.keys, envelope.keyId) ? options.keys[envelope.keyId] : undefined;
|
|
20
|
+
if (!pem)
|
|
21
|
+
throw new Error('Unknown release signing key');
|
|
22
|
+
const key = createPublicKey(pem);
|
|
23
|
+
if (key.asymmetricKeyType !== 'ed25519')
|
|
24
|
+
throw new Error('Release signing key must be Ed25519');
|
|
25
|
+
const payload = Buffer.from(envelope.payload, 'base64');
|
|
26
|
+
if (payload.toString('base64') !== envelope.payload)
|
|
27
|
+
throw new Error('Invalid manifest encoding');
|
|
28
|
+
if (!verify(null, payload, key, Buffer.from(envelope.signature, 'base64')))
|
|
29
|
+
throw new Error('Release signature verification failed');
|
|
30
|
+
const manifest = DaemonUpdatePolicySchema.parse(JSON.parse(payload.toString('utf8')));
|
|
31
|
+
if (manifest.channel !== options.channel)
|
|
32
|
+
throw new Error('Release channel mismatch');
|
|
33
|
+
const now = options.now ?? Date.now();
|
|
34
|
+
if (!Number.isFinite(now))
|
|
35
|
+
throw new Error('Invalid verification clock');
|
|
36
|
+
if (Date.parse(manifest.issuedAt) > now + 5 * 60_000)
|
|
37
|
+
throw new Error('Release manifest is from the future');
|
|
38
|
+
if (Date.parse(manifest.expiresAt) <= now)
|
|
39
|
+
throw new Error('Release manifest has expired');
|
|
40
|
+
const checkpoint = { sequence: manifest.sequence, digest: createHash('sha256').update(payload).digest('hex') };
|
|
41
|
+
const previous = options.checkpoint && ManifestCheckpointSchema.parse(options.checkpoint);
|
|
42
|
+
if (previous && (checkpoint.sequence < previous.sequence ||
|
|
43
|
+
(checkpoint.sequence === previous.sequence && checkpoint.digest !== previous.digest)))
|
|
44
|
+
throw new Error('Release manifest replay or sequence reuse');
|
|
45
|
+
return { manifest, checkpoint };
|
|
46
|
+
}
|
|
47
|
+
/** Stable cohorts without publishing computer IDs in the release feed. */
|
|
48
|
+
export function daemonRolloutBucket(computerId, salt) {
|
|
49
|
+
const digest = createHash('sha256').update(JSON.stringify([salt, computerId])).digest();
|
|
50
|
+
return digest.readUInt32BE(0) / 0x1_0000_0000 * 100;
|
|
51
|
+
}
|