@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,159 @@
|
|
|
1
|
+
import { fork, type ChildProcess } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { isAbsolute } from 'node:path';
|
|
4
|
+
import { ControlReplySchema, type ControlReply } from './processControl.js';
|
|
5
|
+
|
|
6
|
+
export interface RuntimeHost {
|
|
7
|
+
/** Start with all work sources paused; resolve after process + relay readiness. */
|
|
8
|
+
start(version: string): Promise<void>;
|
|
9
|
+
quiesce(): Promise<void>;
|
|
10
|
+
resume(): Promise<void>;
|
|
11
|
+
/** Resolve only after process death and proof that no orphan owns the daemon lock. */
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type Pending = { resolve: (reply: ControlReply) => void; reject: (error: Error) => void; timer: NodeJS.Timeout };
|
|
16
|
+
|
|
17
|
+
/** A process driver, not a service installer. Paths must come from a verified runtime store. */
|
|
18
|
+
export class ProcessRuntimeHost implements RuntimeHost {
|
|
19
|
+
private child?: ChildProcess;
|
|
20
|
+
private token = '';
|
|
21
|
+
private version = '';
|
|
22
|
+
private live?: { computerId: string; features: string[] };
|
|
23
|
+
get capabilities() { return this.ready ? this.live : undefined; }
|
|
24
|
+
private state: 'stopped' | 'starting' | 'paused' | 'running' | 'draining' = 'stopped';
|
|
25
|
+
private exited: Promise<void> = Promise.resolve();
|
|
26
|
+
private pending = new Map<string, Pending>();
|
|
27
|
+
private busy = false;
|
|
28
|
+
get hasProcess(): boolean { return this.child !== undefined; }
|
|
29
|
+
get ready(): boolean { return this.hasProcess && this.state !== 'starting'; }
|
|
30
|
+
constructor(private readonly options: {
|
|
31
|
+
resolveRuntime: (version: string) => Promise<{ entry: string; cwd: string; env?: NodeJS.ProcessEnv }>;
|
|
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
|
+
|
|
40
|
+
private wait(id: string, timeout: number): Promise<ControlReply> {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const timer = setTimeout(() => {
|
|
43
|
+
this.pending.delete(id);
|
|
44
|
+
reject(new Error(`Daemon ${id === 'ready' ? 'readiness' : 'control'} timed out`));
|
|
45
|
+
}, timeout);
|
|
46
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private rejectPending(error: Error) {
|
|
51
|
+
for (const pending of this.pending.values()) { clearTimeout(pending.timer); pending.reject(error); }
|
|
52
|
+
this.pending.clear();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private async exclusively(action: () => Promise<void>): Promise<void> {
|
|
56
|
+
if (this.busy) throw new Error('Another process control operation is in progress');
|
|
57
|
+
this.busy = true;
|
|
58
|
+
try { await action(); } finally { this.busy = false; }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
start(version: string): Promise<void> { return this.exclusively(() => this.startProcess(version)); }
|
|
62
|
+
quiesce(): Promise<void> { return this.exclusively(() => this.quiesceProcess()); }
|
|
63
|
+
resume(): Promise<void> { return this.exclusively(() => this.resumeProcess()); }
|
|
64
|
+
stop(): Promise<void> { return this.exclusively(() => this.stopProcess()); }
|
|
65
|
+
|
|
66
|
+
private async startProcess(version: string): Promise<void> {
|
|
67
|
+
if (this.child) throw new Error('Previous daemon process has not exited');
|
|
68
|
+
await this.options.assertStopped();
|
|
69
|
+
const runtime = await this.options.resolveRuntime(version);
|
|
70
|
+
if (!isAbsolute(runtime.entry) || !isAbsolute(runtime.cwd)) throw new Error('Runtime paths must be absolute');
|
|
71
|
+
this.live = undefined;
|
|
72
|
+
this.version = version;
|
|
73
|
+
this.token = randomUUID();
|
|
74
|
+
this.state = 'starting';
|
|
75
|
+
const ready = this.wait('ready', this.options.startupTimeoutMs ?? 60_000);
|
|
76
|
+
// Attach the rejection handler before forking; synchronous fork failure also settles ready.
|
|
77
|
+
void ready.catch(() => {});
|
|
78
|
+
let child: ChildProcess;
|
|
79
|
+
try {
|
|
80
|
+
child = fork(runtime.entry, [], { cwd: runtime.cwd, execPath: process.execPath,
|
|
81
|
+
execArgv: this.options.execArgv ?? [], stdio: ['ignore', 'inherit', 'inherit', 'ipc'],
|
|
82
|
+
env: { ...process.env, ...runtime.env, LUCIDITY_SUPERVISOR_TOKEN: this.token, LUCIDITY_SUPERVISOR_CAPABILITIES: '1' } });
|
|
83
|
+
} catch (error) {
|
|
84
|
+
this.state = 'stopped';
|
|
85
|
+
this.rejectPending(new Error('Could not launch daemon process', { cause: error }));
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
this.child = child;
|
|
89
|
+
this.exited = new Promise((resolve) => {
|
|
90
|
+
// close also covers failure to spawn; an error alone is not proof of process death.
|
|
91
|
+
child.once('close', () => {
|
|
92
|
+
this.child = undefined;
|
|
93
|
+
this.state = 'stopped';
|
|
94
|
+
this.rejectPending(new Error('Daemon exited before completing process control'));
|
|
95
|
+
resolve();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
child.on('error', (error) => this.rejectPending(error));
|
|
99
|
+
child.on('message', (raw) => {
|
|
100
|
+
const parsed = ControlReplySchema.safeParse(raw);
|
|
101
|
+
if (!parsed.success || parsed.data.token !== this.token || parsed.data.version !== this.version) return;
|
|
102
|
+
const reply = parsed.data;
|
|
103
|
+
const id = reply.event === 'ready' && !reply.id ? 'ready' : reply.id;
|
|
104
|
+
if (!id) return;
|
|
105
|
+
const pending = this.pending.get(id);
|
|
106
|
+
if (!pending) return;
|
|
107
|
+
clearTimeout(pending.timer);
|
|
108
|
+
this.pending.delete(id);
|
|
109
|
+
if (reply.event === 'error') pending.reject(new Error(reply.message ?? 'Daemon process control failed'));
|
|
110
|
+
else pending.resolve(reply);
|
|
111
|
+
});
|
|
112
|
+
const readiness = await ready;
|
|
113
|
+
if (readiness.computerId && readiness.features) this.live = { computerId: readiness.computerId, features: readiness.features };
|
|
114
|
+
if (!this.child) throw new Error('Daemon exited after readiness');
|
|
115
|
+
this.state = 'paused';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private async command(command: 'quiesce' | 'resume', timeout: number): Promise<void> {
|
|
119
|
+
const child = this.child;
|
|
120
|
+
if (!child?.connected) throw new Error('Daemon control channel is unavailable');
|
|
121
|
+
const id = randomUUID();
|
|
122
|
+
const result = this.wait(id, timeout);
|
|
123
|
+
child.send({ protocol: 1, token: this.token, id, command }, (error) => {
|
|
124
|
+
if (error) {
|
|
125
|
+
const pending = this.pending.get(id);
|
|
126
|
+
if (pending) { clearTimeout(pending.timer); this.pending.delete(id); pending.reject(error); }
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
const reply = await result;
|
|
130
|
+
if (reply.event !== (command === 'quiesce' ? 'quiescent' : 'resumed')) throw new Error('Unexpected process control reply');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private async quiesceProcess(): Promise<void> {
|
|
134
|
+
if (!this.child || this.state === 'starting') throw new Error('Daemon is not ready to drain');
|
|
135
|
+
this.state = 'draining';
|
|
136
|
+
await this.command('quiesce', this.options.drainTimeoutMs ?? 10 * 60_000);
|
|
137
|
+
this.state = 'paused';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private async resumeProcess(): Promise<void> {
|
|
141
|
+
if (!this.child || this.state === 'starting') throw new Error('Daemon is not ready to resume');
|
|
142
|
+
await this.command('resume', this.options.commandTimeoutMs ?? 10_000);
|
|
143
|
+
this.state = 'running';
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private async stopProcess(): Promise<void> {
|
|
147
|
+
if (this.child) {
|
|
148
|
+
if (this.state === 'running' || this.state === 'draining') throw new Error('Cannot stop an undrained daemon');
|
|
149
|
+
if (this.child.connected) this.child.send({ protocol: 1, token: this.token, id: randomUUID(), command: 'shutdown' }, () => {});
|
|
150
|
+
let timer: NodeJS.Timeout | undefined;
|
|
151
|
+
try {
|
|
152
|
+
await Promise.race([this.exited, new Promise<never>((_, reject) => {
|
|
153
|
+
timer = setTimeout(() => reject(new Error('Daemon process did not exit; refusing to switch versions')), this.options.commandTimeoutMs ?? 10_000);
|
|
154
|
+
})]);
|
|
155
|
+
} finally { clearTimeout(timer); }
|
|
156
|
+
}
|
|
157
|
+
await this.options.assertStopped();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import type { ServiceCommand, UpdateServicePlan } from './servicePlan.js';
|
|
5
|
+
|
|
6
|
+
const execute = ({ command, args }: ServiceCommand) => {
|
|
7
|
+
execFileSync(command, args, { stdio: 'pipe', timeout: 30_000, windowsHide: true });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** Never overwrite a different installation or restart a running service. */
|
|
11
|
+
export async function registerUpdateService(plan: UpdateServicePlan, run: (command: ServiceCommand) => void = execute) {
|
|
12
|
+
const files = [...(plan.supportFiles ?? []), { path: plan.path, contents: plan.contents, encoding: plan.encoding }];
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
try {
|
|
15
|
+
if (await readFile(file.path, file.encoding ?? 'utf8') !== file.contents) throw new Error('Existing updater service differs; refusing to overwrite it');
|
|
16
|
+
} catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }
|
|
17
|
+
}
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
await mkdir(dirname(file.path), { recursive: true, mode: 0o700 });
|
|
20
|
+
try { await writeFile(file.path, file.contents, { mode: 0o600, flag: 'wx', encoding: file.encoding ?? 'utf8' }); }
|
|
21
|
+
catch (error) {
|
|
22
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;
|
|
23
|
+
if (await readFile(file.path, file.encoding ?? 'utf8') !== file.contents) throw new Error('Existing updater service differs; refusing to overwrite it');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (const command of plan.register) run(command);
|
|
27
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createHash, createPublicKey, verify } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { DaemonUpdatePolicySchema, type DaemonUpdateChannel } from '@lucidity/shared';
|
|
4
|
+
|
|
5
|
+
const MAX_MANIFEST_BYTES = 128 * 1024;
|
|
6
|
+
const EnvelopeSchema = z.object({
|
|
7
|
+
keyId: z.string().min(1).max(100),
|
|
8
|
+
payload: z.string().min(1).max(MAX_MANIFEST_BYTES),
|
|
9
|
+
signature: z.string().regex(/^[A-Za-z0-9+/]{86}==$/),
|
|
10
|
+
}).strict();
|
|
11
|
+
|
|
12
|
+
export const ManifestCheckpointSchema = z.object({
|
|
13
|
+
sequence: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
14
|
+
digest: z.string().regex(/^[a-f0-9]{64}$/),
|
|
15
|
+
}).strict();
|
|
16
|
+
export type ManifestCheckpoint = z.infer<typeof ManifestCheckpointSchema>;
|
|
17
|
+
|
|
18
|
+
/** Trusted keys come from the bootstrap installation, never from the downloaded envelope. */
|
|
19
|
+
export function verifyReleaseManifest(raw: string, options: {
|
|
20
|
+
keys: Readonly<Record<string, string>>;
|
|
21
|
+
channel: DaemonUpdateChannel;
|
|
22
|
+
now?: number;
|
|
23
|
+
checkpoint?: ManifestCheckpoint;
|
|
24
|
+
}) {
|
|
25
|
+
if (Buffer.byteLength(raw) > MAX_MANIFEST_BYTES) throw new Error('Release manifest exceeds size limit');
|
|
26
|
+
const envelope = EnvelopeSchema.parse(JSON.parse(raw));
|
|
27
|
+
const pem = Object.hasOwn(options.keys, envelope.keyId) ? options.keys[envelope.keyId] : undefined;
|
|
28
|
+
if (!pem) throw new Error('Unknown release signing key');
|
|
29
|
+
const key = createPublicKey(pem);
|
|
30
|
+
if (key.asymmetricKeyType !== 'ed25519') throw new Error('Release signing key must be Ed25519');
|
|
31
|
+
const payload = Buffer.from(envelope.payload, 'base64');
|
|
32
|
+
if (payload.toString('base64') !== envelope.payload) throw new Error('Invalid manifest encoding');
|
|
33
|
+
if (!verify(null, payload, key, Buffer.from(envelope.signature, 'base64')))
|
|
34
|
+
throw new Error('Release signature verification failed');
|
|
35
|
+
const manifest = DaemonUpdatePolicySchema.parse(JSON.parse(payload.toString('utf8')));
|
|
36
|
+
if (manifest.channel !== options.channel) throw new Error('Release channel mismatch');
|
|
37
|
+
const now = options.now ?? Date.now();
|
|
38
|
+
if (!Number.isFinite(now)) throw new Error('Invalid verification clock');
|
|
39
|
+
if (Date.parse(manifest.issuedAt) > now + 5 * 60_000) throw new Error('Release manifest is from the future');
|
|
40
|
+
if (Date.parse(manifest.expiresAt) <= now) throw new Error('Release manifest has expired');
|
|
41
|
+
const checkpoint = { sequence: manifest.sequence, digest: createHash('sha256').update(payload).digest('hex') };
|
|
42
|
+
const previous = options.checkpoint && ManifestCheckpointSchema.parse(options.checkpoint);
|
|
43
|
+
if (previous && (checkpoint.sequence < previous.sequence ||
|
|
44
|
+
(checkpoint.sequence === previous.sequence && checkpoint.digest !== previous.digest)))
|
|
45
|
+
throw new Error('Release manifest replay or sequence reuse');
|
|
46
|
+
return { manifest, checkpoint };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Stable cohorts without publishing computer IDs in the release feed. */
|
|
50
|
+
export function daemonRolloutBucket(computerId: string, salt: string): number {
|
|
51
|
+
const digest = createHash('sha256').update(JSON.stringify([salt, computerId])).digest();
|
|
52
|
+
return digest.readUInt32BE(0) / 0x1_0000_0000 * 100;
|
|
53
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { lstat, readdir, rename, rm } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { InstallationStore, inspectTree, inside, owned, readMetadata, writeMetadata } from './installationStore.js';
|
|
5
|
+
|
|
6
|
+
export type InstallationReferences = {
|
|
7
|
+
/** A caller must have verified readiness before allowing automatic retention. */
|
|
8
|
+
healthy: boolean;
|
|
9
|
+
active: string;
|
|
10
|
+
rollback?: string;
|
|
11
|
+
references: Array<{ path: string; reason: string }>;
|
|
12
|
+
};
|
|
13
|
+
export type RetentionReport = {
|
|
14
|
+
at: string; dryRun: boolean; deleted: string[]; eligible: string[];
|
|
15
|
+
retained: Array<{ name: string; reasons: string[] }>;
|
|
16
|
+
reclaimedBytes: number; errors: string[];
|
|
17
|
+
};
|
|
18
|
+
type Deletion = { name: string; trash: string; device: number; inode: number; allocatedBytes: number };
|
|
19
|
+
type Journal = { schema: 1; entries: Deletion[] };
|
|
20
|
+
const TRASH = /^\.trash-[a-f0-9-]{36}$/;
|
|
21
|
+
const STAGE = /^\.prepare-[A-Za-z0-9-]+$/;
|
|
22
|
+
|
|
23
|
+
function reasons(path: string, refs: InstallationReferences): string[] {
|
|
24
|
+
return [
|
|
25
|
+
{ path: refs.active, reason: 'active installation' },
|
|
26
|
+
...(refs.rollback ? [{ path: refs.rollback, reason: 'verified rollback' }] : []),
|
|
27
|
+
...refs.references,
|
|
28
|
+
].filter(ref => inside(path, ref.path) || inside(ref.path, path)).map(ref => ref.reason);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function exists(path: string): Promise<boolean> {
|
|
32
|
+
try { await lstat(path); return true; }
|
|
33
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false; throw error; }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Only known package slots or explicitly owned preparation directories are removed.
|
|
37
|
+
* The journal survives interruption between rename and removal, including partial removal.
|
|
38
|
+
* All callers (installer, activator, inventory and cleanup) share the store lease.
|
|
39
|
+
*/
|
|
40
|
+
export async function retainInstallations(store: InstallationStore,
|
|
41
|
+
readReferences: () => Promise<InstallationReferences>, options: {
|
|
42
|
+
dryRun?: boolean; remove?: (path: string) => Promise<void>;
|
|
43
|
+
} = {}): Promise<RetentionReport> {
|
|
44
|
+
await store.assertLocked();
|
|
45
|
+
const report: RetentionReport = { at: new Date().toISOString(), dryRun: options.dryRun ?? false,
|
|
46
|
+
deleted: [], eligible: [], retained: [], reclaimedBytes: 0, errors: [] };
|
|
47
|
+
const journalPath = join(store.metadata, 'deletions.json');
|
|
48
|
+
let journal: Journal = { schema: 1, entries: [] };
|
|
49
|
+
const save = () => writeMetadata(journalPath, journal);
|
|
50
|
+
const snapshot = async () => {
|
|
51
|
+
await store.assertLocked();
|
|
52
|
+
const refs = await readReferences();
|
|
53
|
+
if (!refs.healthy || !refs.active || !inside(store.root, refs.active) || refs.active === store.root)
|
|
54
|
+
throw new Error('Cleanup requires a verified healthy active installation in this store');
|
|
55
|
+
await owned(refs.active, true);
|
|
56
|
+
return refs;
|
|
57
|
+
};
|
|
58
|
+
const retained = (name: string, why: string[]) => report.retained.push({ name, reasons: [...new Set(why)] });
|
|
59
|
+
try {
|
|
60
|
+
if (!process.getuid) throw new Error('Automatic installation cleanup requires a verified owner ACL implementation on this platform');
|
|
61
|
+
await snapshot();
|
|
62
|
+
if (await exists(journalPath)) journal = await readMetadata<Journal>(journalPath);
|
|
63
|
+
if (journal.schema !== 1 || !Array.isArray(journal.entries) || journal.entries.length > 1000)
|
|
64
|
+
throw new Error('Invalid deletion journal');
|
|
65
|
+
for (const entry of journal.entries) {
|
|
66
|
+
if (!TRASH.test(entry.trash) || !Number.isSafeInteger(entry.device) || !Number.isSafeInteger(entry.inode) ||
|
|
67
|
+
!Number.isFinite(entry.allocatedBytes) || entry.allocatedBytes < 0) throw new Error('Unsafe deletion journal');
|
|
68
|
+
if (!STAGE.test(entry.name)) store.slot(entry.name);
|
|
69
|
+
}
|
|
70
|
+
const remove = options.remove ?? (path => rm(path, { recursive: true, force: false }));
|
|
71
|
+
async function finish(entry: Deletion): Promise<void> {
|
|
72
|
+
const source = join(store.root, entry.name), trash = join(store.root, entry.trash);
|
|
73
|
+
if (!await exists(trash)) {
|
|
74
|
+
// Intent persisted before rename, or removal finished before the journal update.
|
|
75
|
+
if (!await exists(source)) report.deleted.push(entry.name);
|
|
76
|
+
if (!report.dryRun) { journal.entries = journal.entries.filter(item => item !== entry); await save(); }
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const info = await owned(trash, true);
|
|
80
|
+
if (info.dev !== entry.device || info.ino !== entry.inode) throw new Error('Quarantined installation identity changed');
|
|
81
|
+
const refs = await snapshot();
|
|
82
|
+
const protectedBy = [...reasons(source, refs), ...reasons(trash, refs)];
|
|
83
|
+
if (protectedBy.length) {
|
|
84
|
+
if (!report.dryRun && !await exists(source)) {
|
|
85
|
+
await rename(trash, source);
|
|
86
|
+
journal.entries = journal.entries.filter(item => item !== entry); await save();
|
|
87
|
+
}
|
|
88
|
+
retained(entry.name, protectedBy); return;
|
|
89
|
+
}
|
|
90
|
+
// A partially removed tree need no longer contain its package, but ownership,
|
|
91
|
+
// internal links, original inode and the durable intent must still validate.
|
|
92
|
+
const remaining = await inspectTree(trash, source);
|
|
93
|
+
const latest = await snapshot();
|
|
94
|
+
const changed = [...reasons(source, latest), ...reasons(trash, latest)];
|
|
95
|
+
if (changed.length) {
|
|
96
|
+
if (!report.dryRun && !await exists(source)) {
|
|
97
|
+
await rename(trash, source);
|
|
98
|
+
journal.entries = journal.entries.filter(item => item !== entry); await save();
|
|
99
|
+
}
|
|
100
|
+
retained(entry.name, changed); return;
|
|
101
|
+
}
|
|
102
|
+
const finalIdentity = await owned(trash, true);
|
|
103
|
+
if (finalIdentity.dev !== entry.device || finalIdentity.ino !== entry.inode) throw new Error('Deletion target changed');
|
|
104
|
+
report.eligible.push(entry.name);
|
|
105
|
+
if (report.dryRun) return;
|
|
106
|
+
await remove(trash);
|
|
107
|
+
report.deleted.push(entry.name); report.reclaimedBytes += remaining.allocatedBytes;
|
|
108
|
+
journal.entries = journal.entries.filter(item => item !== entry); await save();
|
|
109
|
+
}
|
|
110
|
+
for (const entry of [...journal.entries]) {
|
|
111
|
+
try { await finish(entry); } catch (error) { report.errors.push(`${entry.name}: ${(error as Error).message}`); }
|
|
112
|
+
}
|
|
113
|
+
const pending = new Set(journal.entries.flatMap(item => [item.name, item.trash]));
|
|
114
|
+
for (const name of await readdir(store.root)) {
|
|
115
|
+
if (name === '.maintenance' || pending.has(name)) continue;
|
|
116
|
+
try {
|
|
117
|
+
const path = join(store.root, name), refs = await snapshot();
|
|
118
|
+
const protectedBy = reasons(path, refs);
|
|
119
|
+
if (protectedBy.length) { retained(name, protectedBy); continue; }
|
|
120
|
+
let candidate: { device: number; inode: number; allocatedBytes: number };
|
|
121
|
+
if (STAGE.test(name)) {
|
|
122
|
+
const marker = await readMetadata<{ schema: number; kind: string }>(join(path, '.lucidity-stage.json'));
|
|
123
|
+
if (marker.schema !== 1 || marker.kind !== store.kind) throw new Error('Unowned staging directory');
|
|
124
|
+
const info = await owned(path, true);
|
|
125
|
+
candidate = { device: info.dev, inode: info.ino, ...await inspectTree(path) };
|
|
126
|
+
} else candidate = await store.inspect(name);
|
|
127
|
+
// References can change while scanning a large dependency tree.
|
|
128
|
+
const changed = reasons(path, await snapshot());
|
|
129
|
+
if (changed.length) { retained(name, changed); continue; }
|
|
130
|
+
if (report.dryRun) { report.eligible.push(name); continue; }
|
|
131
|
+
const entry: Deletion = { name, trash: `.trash-${randomUUID()}`, device: candidate.device,
|
|
132
|
+
inode: candidate.inode, allocatedBytes: candidate.allocatedBytes };
|
|
133
|
+
journal.entries.push(entry); await save();
|
|
134
|
+
const identity = await owned(path, true);
|
|
135
|
+
if (identity.dev !== entry.device || identity.ino !== entry.inode) throw new Error('Installation changed before quarantine');
|
|
136
|
+
const lastCheck = reasons(path, await snapshot());
|
|
137
|
+
if (lastCheck.length) {
|
|
138
|
+
journal.entries = journal.entries.filter(item => item !== entry); await save();
|
|
139
|
+
retained(name, lastCheck); continue;
|
|
140
|
+
}
|
|
141
|
+
await rename(path, join(store.root, entry.trash));
|
|
142
|
+
await finish(entry);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
retained(name, ['inspection or cleanup failed']); report.errors.push(`${name}: ${(error as Error).message}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} catch (error) { report.errors.push((error as Error).message); }
|
|
148
|
+
// Never turn successful activation into a rollback because retention failed.
|
|
149
|
+
if (!report.dryRun) {
|
|
150
|
+
try { await writeMetadata(join(store.metadata, 'cleanup-report.json'), report); }
|
|
151
|
+
catch (error) { report.errors.push(`Could not save cleanup report: ${(error as Error).message}`); }
|
|
152
|
+
}
|
|
153
|
+
return report;
|
|
154
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { writeFileSync, renameSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute, join } from 'node:path';
|
|
3
|
+
import { DAEMON_UPDATE_PROTOCOL } from '@lucidity/shared';
|
|
4
|
+
import { CONFIG_DIR, loadConfig } from '../config.js';
|
|
5
|
+
import { computerId } from '../room/computer.js';
|
|
6
|
+
import { DaemonLease } from '../daemonLease.js';
|
|
7
|
+
import { UpdateJournal } from './journal.js';
|
|
8
|
+
import { ProcessRuntimeHost } from './processHost.js';
|
|
9
|
+
import { prepareDaemonRuntime, preparedDaemonRuntime } from './installer.js';
|
|
10
|
+
import { daemonRolloutBucket } from './releases.js';
|
|
11
|
+
import { fetchReleaseCatalog } from './feed.js';
|
|
12
|
+
import { readUpdateBootstrap } from './bootstrapConfig.js';
|
|
13
|
+
export { UpdateBootstrapSchema } from './bootstrapConfig.js';
|
|
14
|
+
import { UpdateService } from './service.js';
|
|
15
|
+
import { connectUpdateControl } from './connection.js';
|
|
16
|
+
import { InstallationStore, withInstallationStore } from './installationStore.js';
|
|
17
|
+
import { installationReferences } from './installationReferences.js';
|
|
18
|
+
import { retainInstallations } from './retention.js';
|
|
19
|
+
|
|
20
|
+
/** The bootstrap installer must prepare its initial slot before invoking this service. */
|
|
21
|
+
export function startUpdateService(configPath: string) {
|
|
22
|
+
if (!isAbsolute(configPath)) throw new Error('Expected an absolute bootstrap configuration path');
|
|
23
|
+
const config = readUpdateBootstrap(configPath);
|
|
24
|
+
const identity = computerId(join(CONFIG_DIR, 'computer-id'));
|
|
25
|
+
const journal = new UpdateJournal(join(config.directory, 'journal'), {
|
|
26
|
+
version: config.release.version, stateEpoch: config.release.stateEpoch, channel: config.channel,
|
|
27
|
+
});
|
|
28
|
+
const runtimes = join(config.directory, 'runtimes');
|
|
29
|
+
let installationLease: InstallationStore | undefined;
|
|
30
|
+
const host = new ProcessRuntimeHost({
|
|
31
|
+
assertStopped: () => { const lease = new DaemonLease(CONFIG_DIR); lease.close(); },
|
|
32
|
+
resolveRuntime: async (version) => {
|
|
33
|
+
const policy = journal.read().policy;
|
|
34
|
+
const release = (policy?.schema === 2 ? policy.daemons.find((entry) => entry.artifact.version === version)?.artifact : undefined)
|
|
35
|
+
?? (config.release.version === version ? config.release : undefined);
|
|
36
|
+
if (!release) throw new Error('No trusted declaration for the selected daemon runtime');
|
|
37
|
+
if (!installationLease) throw new Error('Runtime activation requires the installation lease');
|
|
38
|
+
await installationLease.inspect(version);
|
|
39
|
+
return preparedDaemonRuntime(runtimes, release);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
let binding: { accountId: string; computerId: string } | undefined;
|
|
43
|
+
let connection: ReturnType<typeof connectUpdateControl> | undefined;
|
|
44
|
+
const service = new UpdateService({
|
|
45
|
+
journal, host, keys: config.keys, binding: () => binding, liveCapabilities: () => host.capabilities,
|
|
46
|
+
environment: () => ({ managed: true, platform: `${process.platform}-${process.arch}`, nodeVersion: process.versions.node,
|
|
47
|
+
updateProtocol: DAEMON_UPDATE_PROTOCOL, rolloutBucket: daemonRolloutBucket(identity, journal.read().policy?.rollout.salt ?? 'bootstrap') }),
|
|
48
|
+
fetchCatalog: (signal) => fetchReleaseCatalog(config.feedUrl, { signal }),
|
|
49
|
+
transaction: operation => withInstallationStore(runtimes, 'managed', async lease => {
|
|
50
|
+
installationLease = lease;
|
|
51
|
+
try { await operation(); } finally { installationLease = undefined; }
|
|
52
|
+
}),
|
|
53
|
+
prepare: async (release, signal) => {
|
|
54
|
+
await prepareDaemonRuntime(release, runtimes, { npmCli: config.npmCli, signal, lease: installationLease });
|
|
55
|
+
},
|
|
56
|
+
maintain: async () => {
|
|
57
|
+
if (!installationLease || !host.ready) return;
|
|
58
|
+
const lease = installationLease;
|
|
59
|
+
const report = await retainInstallations(lease, async () => {
|
|
60
|
+
const state = journal.read();
|
|
61
|
+
const pending = state.pending;
|
|
62
|
+
return { healthy: host.ready && (!pending || pending.phase === 'staged'), active: lease.slot(state.current.version),
|
|
63
|
+
rollback: state.previous ? lease.slot(state.previous.version) : undefined,
|
|
64
|
+
references: [
|
|
65
|
+
{ path: lease.slot(config.release.version), reason: 'pinned updater bootstrap' },
|
|
66
|
+
...(pending ? [pending.previous.version, pending.release.version].map(version =>
|
|
67
|
+
({ path: lease.slot(version), reason: 'update in progress' })) : []),
|
|
68
|
+
...await installationReferences(runtimes, { configDirectory: CONFIG_DIR, extraFiles: [configPath] }),
|
|
69
|
+
] };
|
|
70
|
+
});
|
|
71
|
+
if (report.deleted.length || report.errors.length) console.error('[updater] Installation retention', JSON.stringify(report));
|
|
72
|
+
},
|
|
73
|
+
onStatus: (status) => {
|
|
74
|
+
const path = join(config.directory, 'status.json');
|
|
75
|
+
try {
|
|
76
|
+
writeFileSync(`${path}.tmp`, JSON.stringify(status), { mode: 0o600 });
|
|
77
|
+
renameSync(`${path}.tmp`, path);
|
|
78
|
+
} finally { connection?.publish({ type: 'update_status', protocol: DAEMON_UPDATE_PROTOCOL, status, devices: service.deviceStates(), doctor: binding ? service.doctorStates() : undefined }); }
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
connection = connectUpdateControl({
|
|
82
|
+
computerId: identity,
|
|
83
|
+
credentials: () => { const { apiUrl, apiKey } = loadConfig(); return { apiUrl, apiKey }; },
|
|
84
|
+
onBinding: value => { binding = value; },
|
|
85
|
+
onDoctor: request => { void service.receiveDoctor(request).catch(() => console.error('[doctor] Capability recovery could not finish')); },
|
|
86
|
+
onClient: (client) => {
|
|
87
|
+
void service.receiveClient(client).catch(() => { console.error('[updater] Device release check failed'); });
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
let timer: NodeJS.Timeout | undefined, stopped = false;
|
|
91
|
+
const tick = () => {
|
|
92
|
+
void service.poll().catch((error) => { console.error('[updater]', error instanceof Error ? error.message : 'Update check failed'); })
|
|
93
|
+
.finally(() => { if (!stopped) timer = setTimeout(tick, config.pollSeconds * 1000); });
|
|
94
|
+
};
|
|
95
|
+
tick();
|
|
96
|
+
return {
|
|
97
|
+
async stop() {
|
|
98
|
+
stopped = true; clearTimeout(timer);
|
|
99
|
+
connection.stop();
|
|
100
|
+
await service.stop();
|
|
101
|
+
journal.close();
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|