@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
3
|
import { realpath } from 'node:fs/promises';
|
|
4
|
-
import { createHash } from 'node:crypto';
|
|
5
|
-
import { RepoSettingsSchema, sessionProvider, type RepoSettings, type RunReview, type UnmergedWork, type WorkspaceCommand, type WorkspaceSnapshot, type WorkerWorkspace } from '@lucidity/shared';
|
|
4
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
+
import { CodeRequestSchema, RepoSettingsSchema, WorkspaceModelPreferencesSchema, sessionProvider, type HarnessImage, type WorktreeOperation, type WorktreeLifecycleRequest, type WorkspaceModelPreferences, type RepoSettings, type RunReview, type UnmergedWork, type WorkspaceCommand, type WorkspaceSnapshot, type WorkerWorkspace } from '@lucidity/shared';
|
|
6
6
|
import { RuntimeStore, conversationKey } from '../runtimeStore.js';
|
|
7
7
|
import type { RepoEntry } from '../config.js';
|
|
8
8
|
import { LaneQueue } from '../queue.js';
|
|
@@ -11,6 +11,17 @@ import { archiveWorktree, archivedHead, deleteArchivedWorktree, ensureWorkspace,
|
|
|
11
11
|
import type { CodeTurnRequest } from './runCodeTurn.js';
|
|
12
12
|
import { copyIncludedFiles, matchedFiles, runSetupScript } from './worktreeSetup.js';
|
|
13
13
|
import { inspectRun, continuationRequest } from './runReview.js';
|
|
14
|
+
import { WorkspaceOverviews, overviewMetadataRequestSchema, type OverviewEntry } from './workspaceOverview.js';
|
|
15
|
+
import { overviewEntry, sourceKey, recallMessageId } from './overviewSources.js';
|
|
16
|
+
import { existingWorkspace } from '../editor/existingWorkspace.js';
|
|
17
|
+
import type { RecallDocument } from '@lucidity/shared';
|
|
18
|
+
import { isGreetingTitle, worktreeTitleSchema } from './workspaceTitle.js';
|
|
19
|
+
|
|
20
|
+
function imageMetadata(input?: { images?: HarnessImage[]; imageOnly?: boolean }) {
|
|
21
|
+
return input?.images?.length ? { imageCount: input.images.length,
|
|
22
|
+
...(input.images.some(image => image.name) ? { imageNames: input.images.map(image => image.name ?? null) } : {}),
|
|
23
|
+
...(input.imageOnly !== undefined ? { imageOnly: input.imageOnly } : {}) } : {};
|
|
24
|
+
}
|
|
14
25
|
|
|
15
26
|
/** "Worktree 3": the next number this repository has not used. */
|
|
16
27
|
export function nextWorkerTitle(titles: string[]): string {
|
|
@@ -30,14 +41,213 @@ export function nextPortBlock(taken: Array<number | undefined>): number {
|
|
|
30
41
|
while (used.has(port)) port += PORT_BLOCK;
|
|
31
42
|
return port;
|
|
32
43
|
}
|
|
33
|
-
type
|
|
34
|
-
type
|
|
44
|
+
type ImportContext = { provider: 'claude' | 'codex'; transcript: string };
|
|
45
|
+
type TitleSuggestion = { title: string; requestId: string; revision?: string };
|
|
46
|
+
type SavedWorker = WorkerWorkspace & { titleSuggestion?: TitleSuggestion; pendingTitleSuggestion?: TitleSuggestion; titleSource?: 'default' | 'custom' | 'generated'; titleRequestId?: string; titleDeferredThrough?: string; titleRevision?: string; path?: string; externalDesktop?: boolean; importContext?: ImportContext; setupDeferred?: boolean; sessionCheckout?: boolean; legacy?: boolean; legacyMessages?: NonNullable<WorkspaceSnapshot['legacyMessages']> };
|
|
47
|
+
type SavedOperation = WorktreeOperation & { force?: boolean };
|
|
48
|
+
type CreationRequest = Extract<WorktreeLifecycleRequest, { action: 'create' }>;
|
|
49
|
+
type SavedCreation = CreationRequest & { state: 'creating' | 'ready' | 'failed'; message?: string };
|
|
50
|
+
type SavedCheckout = { revision: string; clearedThrough?: string; legacyMessages?: WorkspaceSnapshot['legacyMessages']; resume?: string; importContext?: ImportContext };
|
|
35
51
|
|
|
36
52
|
/** Workspace lifetime is independent of runs, provider sessions, PRs, and phone storage. */
|
|
37
53
|
export class WorkspaceRegistry {
|
|
38
54
|
private lanes = new LaneQueue();
|
|
39
55
|
private setups = new Map<string, Promise<void>>();
|
|
40
|
-
|
|
56
|
+
private listeners = new Set<() => void>();
|
|
57
|
+
private processing = false;
|
|
58
|
+
private archiving = new Set<string>();
|
|
59
|
+
private editorGuards = new Set<(repoId: string, workerId?: string) => boolean>();
|
|
60
|
+
constructor(private readonly store: RuntimeStore, private readonly repos: () => RepoEntry[], private readonly baseDir?: string,
|
|
61
|
+
private readonly overviews?: WorkspaceOverviews) {
|
|
62
|
+
// Preserve existing numbered labels first; custom titles receive a stable unused number.
|
|
63
|
+
const workers = this.store.list<SavedWorker>('workers');
|
|
64
|
+
for (const worker of workers) {
|
|
65
|
+
if (!worker.shortName && /^Worktree [1-9]\d*$/.test(worker.title)) {
|
|
66
|
+
worker.shortName = worker.title;
|
|
67
|
+
this.store.set('workers', worker.workerId, worker);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const worker of workers.sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.workerId.localeCompare(b.workerId))) {
|
|
71
|
+
if (!worker.shortName) {
|
|
72
|
+
worker.shortName = nextWorkerTitle(workers.filter(other => other.repoId === worker.repoId).map(other => other.shortName ?? other.title));
|
|
73
|
+
this.store.set('workers', worker.workerId, worker);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// An archive hook may have run before the crash. Never replay an uncertain mutation.
|
|
77
|
+
for (const operation of this.store.list<SavedOperation>('worktree-operations')) {
|
|
78
|
+
if (operation.state === 'running') this.saveOperation({ ...operation, state: 'failed',
|
|
79
|
+
message: 'The computer restarted during this operation. Inspect the worktree before retrying.' });
|
|
80
|
+
}
|
|
81
|
+
for (const creation of this.store.list<SavedCreation>('agent-worktree-creations')) {
|
|
82
|
+
if (creation.state === 'creating') this.store.set('agent-worktree-creations', creation.workerId,
|
|
83
|
+
{ ...creation, state: 'failed', message: 'The computer restarted during creation. Inspect the worktree before retrying setup.' });
|
|
84
|
+
}
|
|
85
|
+
for (const worker of workers) this.nameWorktree(worker.workerId);
|
|
86
|
+
for (const id of this.overviews?.pendingRequests() ?? []) {
|
|
87
|
+
const request = this.store.command(id);
|
|
88
|
+
if (request?.kind === 'code' && this.store.status(id).terminated) this.refreshOverview(request);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
subscribe(listener: () => void): () => void {
|
|
93
|
+
this.listeners.add(listener);
|
|
94
|
+
return () => { this.listeners.delete(listener); };
|
|
95
|
+
}
|
|
96
|
+
private changed(): void {
|
|
97
|
+
this.store.set('workspace-revision', 'current', this.revision() + 1);
|
|
98
|
+
for (const listener of this.listeners) { try { listener(); } catch { /* Reconnect repairs a missed push. */ } }
|
|
99
|
+
}
|
|
100
|
+
private revision(): number { return this.store.get<number>('workspace-revision', 'current') ?? 0; }
|
|
101
|
+
snapshot(repoId?: string): WorkspaceSnapshot {
|
|
102
|
+
const repoIds = this.repos().map(r => r.id).filter(id => !repoId || id === repoId);
|
|
103
|
+
return { workers: this.list(repoId), scope: { repoIds, revision: this.revision() },
|
|
104
|
+
openedCheckouts: repoIds.filter(id => {
|
|
105
|
+
const conversation = conversationKey({ kind: 'code', repoId: id, mode: 'in-place' });
|
|
106
|
+
return this.store.get('opened-checkouts', conversation) || this.store.get('checkout-conversations', conversation) ||
|
|
107
|
+
this.store.lastCommand(conversation);
|
|
108
|
+
}),
|
|
109
|
+
operations: this.store.list<SavedOperation>('worktree-operations')
|
|
110
|
+
.filter(op => repoIds.includes(op.repoId)).filter((op, index, all) => op.state === 'waiting' || op.state === 'running' || index >= all.length - 100).map(({ force: _, ...op }) => op) };
|
|
111
|
+
}
|
|
112
|
+
/** Local tools can match the exact checkout without guessing IDs from branch names. */
|
|
113
|
+
locations() {
|
|
114
|
+
return this.store.list<SavedWorker>('workers').filter(w => this.repos().some(r => r.id === w.repoId))
|
|
115
|
+
.map(w => ({ workerId: w.workerId, repoId: w.repoId, path: w.path }));
|
|
116
|
+
}
|
|
117
|
+
/** Ready worktrees can receive their first turn; discovery itself never starts one. */
|
|
118
|
+
agentConversations() {
|
|
119
|
+
return this.repos().flatMap(repo => {
|
|
120
|
+
if (!resolveRepo(repo.id, this.repos())) return [];
|
|
121
|
+
const scopes = [{ repoId: repo.id, workerId: undefined as string | undefined, title: 'Main checkout' },
|
|
122
|
+
...this.list(repo.id).filter(w => w.state === 'ready').map(w => ({ repoId: repo.id, workerId: w.workerId, title: w.title }))];
|
|
123
|
+
return scopes.flatMap(scope => {
|
|
124
|
+
try {
|
|
125
|
+
const workspace = this.editorWorkspace({ ...scope, checkout: !scope.workerId });
|
|
126
|
+
const mode = scope.workerId ? 'worktree' as const : 'in-place' as const;
|
|
127
|
+
const conversationId = conversationKey({ ...scope, kind: 'code', mode });
|
|
128
|
+
const checkout = scope.workerId ? undefined : this.store.get<SavedCheckout>('checkout-conversations', conversationId);
|
|
129
|
+
const resume = this.resume({ ...scope, mode, id: '', prompt: '' });
|
|
130
|
+
const lastRequestId = this.store.lastCommand(conversationId);
|
|
131
|
+
const started = Boolean(resume || (scope.workerId && lastRequestId) || this.store.unfinished(conversationId));
|
|
132
|
+
if (!started && !scope.workerId) return [];
|
|
133
|
+
return [{ ...scope, mode, conversationId, revision: checkout?.revision ?? '0',
|
|
134
|
+
started,
|
|
135
|
+
path: workspace.path, provider: resume ? sessionProvider(resume) : undefined,
|
|
136
|
+
status: workspace.status, lastRequestId }];
|
|
137
|
+
} catch { return []; }
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** Read only the registered checkout; an editor request never creates one. */
|
|
142
|
+
editorWorkspace(scope: { repoId: string; workerId?: string; checkout?: boolean }, allowPending = false) {
|
|
143
|
+
const repo = this.repo(scope.repoId);
|
|
144
|
+
const worker = scope.workerId ? this.store.get<SavedWorker>('workers', scope.workerId) : undefined;
|
|
145
|
+
if (scope.workerId && (!worker || worker.repoId !== repo.id || worker.state !== 'ready' || !worker.path ||
|
|
146
|
+
worker.setup || this.setups.has(worker.workerId) || (!allowPending && this.pending(worker.workerId)) || this.archiving.has(worker.workerId)))
|
|
147
|
+
throw new Error('This worktree is not ready for editing. Restore it or finish its setup first.');
|
|
148
|
+
if (!scope.workerId && !scope.checkout) throw new Error('Select Main checkout or a registered worktree.');
|
|
149
|
+
const conversation = conversationKey({ kind: 'code', repoId: scope.repoId, workerId: scope.workerId, mode: scope.checkout ? 'in-place' : 'worktree' });
|
|
150
|
+
return { path: realpathSync(worker?.path ?? repo.root), branch: worker?.branch ?? '',
|
|
151
|
+
revision: worker ? '0' : this.store.get<SavedCheckout>('checkout-conversations', conversation)?.revision ?? '0',
|
|
152
|
+
status: this.store.unfinished(conversation) ? 'running' as const : 'idle' as const };
|
|
153
|
+
}
|
|
154
|
+
/** File/Git mutations cannot race worktree archive, restore, or deletion. */
|
|
155
|
+
withEditorWorkspace<T>(scope: { repoId: string; workerId?: string; checkout?: boolean }, action: () => Promise<T>, allowPending = false): Promise<T> {
|
|
156
|
+
const repo = this.repo(scope.repoId);
|
|
157
|
+
return this.lanes.run(repo.root, async () => { this.editorWorkspace(scope, allowPending); return action(); });
|
|
158
|
+
}
|
|
159
|
+
guardEditorLifetime(guard: (repoId: string, workerId?: string) => boolean): () => void {
|
|
160
|
+
this.editorGuards.add(guard); return () => { this.editorGuards.delete(guard); };
|
|
161
|
+
}
|
|
162
|
+
private editorActive(worker: SavedWorker): boolean { return [...this.editorGuards].some((guard) => guard(worker.repoId, worker.workerId)); }
|
|
163
|
+
private saveOperation(operation: SavedOperation): void {
|
|
164
|
+
this.store.set('worktree-operations', operation.id, { ...operation, updatedAt: new Date().toISOString() });
|
|
165
|
+
this.changed();
|
|
166
|
+
}
|
|
167
|
+
private pending(workerId: string): SavedOperation | undefined {
|
|
168
|
+
return this.store.list<SavedOperation>('worktree-operations').find(op => op.workerId === workerId &&
|
|
169
|
+
(op.state === 'waiting' || op.state === 'running'));
|
|
170
|
+
}
|
|
171
|
+
creations() {
|
|
172
|
+
return this.store.list<SavedCreation>('agent-worktree-creations').filter(c => this.repos().some(r => r.id === c.repoId));
|
|
173
|
+
}
|
|
174
|
+
requestCreation(request: CreationRequest, run: (work: () => Promise<WorkerWorkspace>) => Promise<WorkerWorkspace> = work => work()): SavedCreation {
|
|
175
|
+
this.repo(request.repoId);
|
|
176
|
+
const previous = this.store.get<SavedCreation>('agent-worktree-creations', request.workerId);
|
|
177
|
+
if (previous) {
|
|
178
|
+
if (previous.repoId !== request.repoId || previous.title !== request.title)
|
|
179
|
+
throw new Error('This creation ID already belongs to another request. Retry with the original input.');
|
|
180
|
+
return previous;
|
|
181
|
+
}
|
|
182
|
+
if (this.store.get('workers', request.workerId) || this.store.get('deleted-workers', request.workerId))
|
|
183
|
+
throw new Error('This worktree ID is already in use. Select a new creation ID.');
|
|
184
|
+
const receipt: SavedCreation = { ...request, state: 'creating' };
|
|
185
|
+
this.store.set('agent-worktree-creations', request.workerId, receipt);
|
|
186
|
+
void run(async () => {
|
|
187
|
+
const worker = await this.create(request.repoId, request.workerId, request.title);
|
|
188
|
+
this.store.set('agent-worktree-creations', request.workerId, { ...receipt, state: 'ready' });
|
|
189
|
+
this.changed();
|
|
190
|
+
return worker;
|
|
191
|
+
}).catch(error => {
|
|
192
|
+
this.store.set('agent-worktree-creations', request.workerId, { ...receipt, state: 'failed', message: String(error.message ?? error) });
|
|
193
|
+
this.changed();
|
|
194
|
+
});
|
|
195
|
+
return receipt;
|
|
196
|
+
}
|
|
197
|
+
requestLifecycle(request: Extract<WorktreeLifecycleRequest, { action: 'archive' | 'delete' }>): WorktreeOperation {
|
|
198
|
+
this.repo(request.repoId);
|
|
199
|
+
const previous = this.store.get<SavedOperation>('worktree-operations', request.id);
|
|
200
|
+
if (previous) {
|
|
201
|
+
if (previous.repoId !== request.repoId || previous.workerId !== request.workerId ||
|
|
202
|
+
previous.action !== request.action || !!previous.force !== !!request.force)
|
|
203
|
+
throw new Error('This operation ID already belongs to a different request.');
|
|
204
|
+
return previous;
|
|
205
|
+
}
|
|
206
|
+
const worker = this.store.get<SavedWorker>('workers', request.workerId);
|
|
207
|
+
if (!worker || worker.repoId !== request.repoId) throw new Error('This worktree is not registered in this repository.');
|
|
208
|
+
if (request.force && (request.action !== 'delete' || worker.state !== 'archived'))
|
|
209
|
+
throw new Error('Archive and inspect saved work before confirming its permanent deletion.');
|
|
210
|
+
if (worker.sessionCheckout) throw new Error('The shared session checkout cannot be removed through an agent tool.');
|
|
211
|
+
const pending = this.pending(worker.workerId);
|
|
212
|
+
if (pending) {
|
|
213
|
+
if (pending.action !== request.action || !!pending.force !== !!request.force)
|
|
214
|
+
throw new Error('A different operation is already waiting for this worktree.');
|
|
215
|
+
return pending;
|
|
216
|
+
}
|
|
217
|
+
const operation: SavedOperation = { ...request, title: worker.title, state: 'waiting',
|
|
218
|
+
message: 'Waiting for active work, queued messages and setup to finish.', updatedAt: new Date().toISOString() };
|
|
219
|
+
this.saveOperation(operation);
|
|
220
|
+
return operation;
|
|
221
|
+
}
|
|
222
|
+
/** Called by the daemon, independently of the agent's HTTP request or the phone connection. */
|
|
223
|
+
async processLifecycle(): Promise<void> {
|
|
224
|
+
if (this.processing) return;
|
|
225
|
+
this.processing = true;
|
|
226
|
+
try {
|
|
227
|
+
for (const operation of this.store.list<SavedOperation>('worktree-operations')) {
|
|
228
|
+
if (operation.state !== 'waiting') continue;
|
|
229
|
+
const worker = this.store.get<SavedWorker>('workers', operation.workerId);
|
|
230
|
+
if (worker && (this.archiving.has(worker.workerId) || worker.state === 'creating' || this.setups.has(worker.workerId) || this.store.unfinished(worker.conversationId) || this.editorActive(worker))) continue;
|
|
231
|
+
this.saveOperation({ ...operation, state: 'running',
|
|
232
|
+
message: operation.action === 'delete' ? 'Deleting worktree…' : 'Archiving worktree…' });
|
|
233
|
+
try {
|
|
234
|
+
if (worker && worker.state !== 'archived') await this.archive(worker);
|
|
235
|
+
if (operation.action === 'delete') {
|
|
236
|
+
const unmerged = await this.delete(operation.repoId, operation.workerId, operation.force);
|
|
237
|
+
if (unmerged) {
|
|
238
|
+
this.saveOperation({ ...operation, state: 'blocked', message:
|
|
239
|
+
`Worktree archived, but not deleted: ${unmerged.commits} unmerged commits${unmerged.uncommitted ? ' and uncommitted files' : ''}. Review its saved work before confirming deletion.` });
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
} else if (!worker) throw new Error('This worktree no longer exists.');
|
|
243
|
+
this.saveOperation({ ...operation, state: 'done',
|
|
244
|
+
message: operation.action === 'delete' ? 'Worktree deleted' : 'Worktree archived' });
|
|
245
|
+
} catch (error) {
|
|
246
|
+
this.saveOperation({ ...operation, state: 'failed', message: error instanceof Error ? error.message : String(error) });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} finally { this.processing = false; }
|
|
250
|
+
}
|
|
41
251
|
|
|
42
252
|
private repo(id: string) {
|
|
43
253
|
const repo = resolveRepo(id, this.repos());
|
|
@@ -45,8 +255,10 @@ export class WorkspaceRegistry {
|
|
|
45
255
|
return repo;
|
|
46
256
|
}
|
|
47
257
|
private public(worker: SavedWorker): WorkerWorkspace {
|
|
48
|
-
const { path: _, legacyMessages: __, sessionCheckout: ___, legacy: ____,
|
|
258
|
+
const { path: _, legacyMessages: __, sessionCheckout: ___, legacy: ____, setupDeferred: _____,
|
|
259
|
+
titleSuggestion: _suggestion, pendingTitleSuggestion: _pendingSuggestion, externalDesktop: _external, importContext: _context, titleSource: _titleSource, titleRequestId: _titleRequestId, titleDeferredThrough: _titleDeferredThrough, titleRevision: _titleRevision, ...row } = worker;
|
|
49
260
|
return { ...row, resume: this.store.latestSession(worker.conversationId) ?? row.resume,
|
|
261
|
+
overview: this.overviews?.peek(worker.conversationId),
|
|
50
262
|
...(this.setups.has(worker.workerId) ? { setup: 'running' as const } : {}) };
|
|
51
263
|
}
|
|
52
264
|
list(repoId?: string): WorkerWorkspace[] {
|
|
@@ -54,6 +266,310 @@ export class WorkspaceRegistry {
|
|
|
54
266
|
.filter((w) => (!repoId || w.repoId === repoId) && this.repos().some((r) => r.id === w.repoId))
|
|
55
267
|
.map((w) => this.public(w));
|
|
56
268
|
}
|
|
269
|
+
|
|
270
|
+
private overviewHistory(command: Pick<WorkspaceCommand, 'repoId' | 'workerId'>) {
|
|
271
|
+
if (!command.repoId) throw new Error('Select a repository.');
|
|
272
|
+
this.repo(command.repoId);
|
|
273
|
+
const worker = command.workerId ? this.store.get<SavedWorker>('workers', command.workerId) : undefined;
|
|
274
|
+
if (command.workerId && (!worker || worker.repoId !== command.repoId))
|
|
275
|
+
throw new Error('This worktree is not registered in this repository.');
|
|
276
|
+
const conversationId = worker?.conversationId ?? conversationKey({ kind: 'code', repoId: command.repoId, mode: 'in-place' });
|
|
277
|
+
const checkout = worker ? undefined : this.store.get<SavedCheckout>('checkout-conversations', conversationId);
|
|
278
|
+
const key = worker ? conversationId : `${conversationId}:${checkout?.revision ?? '0'}`;
|
|
279
|
+
const legacy = worker?.legacyMessages ?? checkout?.legacyMessages ?? [];
|
|
280
|
+
const entries: OverviewEntry[] = legacy.filter(m => m.role !== 'notice' && m.text.trim()).map(m =>
|
|
281
|
+
overviewEntry({ conversationId: key, kind: 'legacy', messageId: m.id }, m.role === 'user' ? 'user' : 'assistant', m.text));
|
|
282
|
+
for (const run of this.store.completedText(conversationId, checkout?.clearedThrough)) {
|
|
283
|
+
if (run.queueAction === 'cancel') continue;
|
|
284
|
+
const identity = { conversationId: key, requestId: run.id };
|
|
285
|
+
const savedAt = new Date(run.completedAt).toISOString();
|
|
286
|
+
entries.push({ ...overviewEntry({ ...identity, kind: 'prompt', messageId: run.id }, run.senderKind === 'agent' ? 'assistant' : 'user', run.prompt), savedAt });
|
|
287
|
+
const corrections = this.store.get<Record<string, string>>('overview-steering', run.id) ?? {};
|
|
288
|
+
const times = this.store.get<Record<string, string>>('overview-steering-times', run.id) ?? {};
|
|
289
|
+
for (const [id, text] of Object.entries(corrections)) entries.push({ ...overviewEntry({ ...identity,
|
|
290
|
+
kind: 'steering', messageId: id, ...(times[id] ? { recordedAt: times[id] } : {}) }, 'user', text), savedAt });
|
|
291
|
+
if (run.text.trim()) entries.push({ ...overviewEntry({ ...identity, kind: 'reply', messageId: run.id,
|
|
292
|
+
recordedAt: savedAt }, 'assistant', run.text, run.outcome), savedAt });
|
|
293
|
+
}
|
|
294
|
+
return { key, entries };
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Current accessible history, including archived workers. Cleared/deleted scopes never enter recall. */
|
|
298
|
+
recallDocuments(): RecallDocument[] {
|
|
299
|
+
const documents: RecallDocument[] = [];
|
|
300
|
+
for (const repo of this.repos()) {
|
|
301
|
+
if (!resolveRepo(repo.id, this.repos())) continue;
|
|
302
|
+
const scopes = [{ repoId: repo.id, workerId: undefined as string | undefined, title: 'Main' },
|
|
303
|
+
...this.list(repo.id).map(w => ({ repoId: repo.id, workerId: w.workerId, title: w.title }))];
|
|
304
|
+
for (const scope of scopes) {
|
|
305
|
+
const { key, entries } = this.overviewHistory(scope);
|
|
306
|
+
const title = `${repo.id} / ${scope.title}`;
|
|
307
|
+
const location = { repoId: repo.id, workerId: scope.workerId };
|
|
308
|
+
const sourceKeys = new Set(entries.map(e => sourceKey(e.source)));
|
|
309
|
+
for (const entry of entries) {
|
|
310
|
+
const source = entry.source;
|
|
311
|
+
const id = recallMessageId(source);
|
|
312
|
+
documents.push({ id, revision: source.revision, kind: 'message', authority: 'original',
|
|
313
|
+
title: `${title} / ${entry.role}`, text: entry.text, repoId: repo.id, conversationId: key,
|
|
314
|
+
speaker: entry.role, savedAt: entry.savedAt, recordedAt: source.recordedAt, location: { ...location, source } });
|
|
315
|
+
}
|
|
316
|
+
for (const topic of this.overviews?.peek(key)?.topics ?? []) {
|
|
317
|
+
// Stale derived summaries are never indexed after their evidence changes or disappears.
|
|
318
|
+
const supportingSources = [...(topic.sources ?? []), ...(topic.decisionSources ?? []).flat(), ...(topic.decisionCompletionSources ?? []).flat()];
|
|
319
|
+
if (!topic.id || !topic.sources?.length || supportingSources
|
|
320
|
+
.some(s => !sourceKeys.has(sourceKey(s)))) continue;
|
|
321
|
+
const text = [topic.summary, ...topic.decisions].join('\n');
|
|
322
|
+
documents.push({ id: `topic:${key}:${topic.id}`, revision: createHash('sha256').update(JSON.stringify(topic)).digest('hex'),
|
|
323
|
+
kind: 'topic', authority: 'derived', title: `${title} / ${topic.title}`, text,
|
|
324
|
+
repoId: repo.id, conversationId: key, recordedAt: topic.lastRecordedAt,
|
|
325
|
+
location, sources: topic.sources,
|
|
326
|
+
sourceIds: [...new Map(supportingSources.map(s => [recallMessageId(s), { id: recallMessageId(s), revision: s.revision }])).values()] });
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// A memory may be saved before its turn finishes. Keep only the turn identity;
|
|
331
|
+
// derive text from the original command so clearing/deletion still revokes it.
|
|
332
|
+
const indexed = new Set(documents.map(doc => doc.id));
|
|
333
|
+
for (const { requestId } of this.store.list<{ requestId: string }>('memory-source-turns')) {
|
|
334
|
+
for (const doc of this.turnMemoryDocuments(requestId)) {
|
|
335
|
+
if (!indexed.has(doc.id)) { documents.push(doc); indexed.add(doc.id); }
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return documents;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private turnMemoryDocuments(requestId: string): RecallDocument[] {
|
|
342
|
+
const request = this.store.command(requestId);
|
|
343
|
+
if (request?.kind !== 'code' || (!request.workerId && request.mode !== 'in-place') ||
|
|
344
|
+
!resolveRepo(request.repoId, this.repos())) return [];
|
|
345
|
+
const worker = request.workerId ? this.store.get<SavedWorker>('workers', request.workerId) : undefined;
|
|
346
|
+
if (request.workerId && (!worker || worker.repoId !== request.repoId)) return [];
|
|
347
|
+
const conversation = worker?.conversationId ?? conversationKey(request);
|
|
348
|
+
const checkout = worker ? undefined : this.store.get<SavedCheckout>('checkout-conversations', conversation);
|
|
349
|
+
if (checkout?.clearedThrough && request.id <= checkout.clearedThrough) return [];
|
|
350
|
+
const key = worker ? conversation : `${conversation}:${checkout?.revision ?? '0'}`;
|
|
351
|
+
const entries: OverviewEntry[] = request.senderKind === 'agent' ? [] : [overviewEntry({ conversationId: key,
|
|
352
|
+
requestId, messageId: requestId, kind: 'prompt' }, 'user', request.prompt)];
|
|
353
|
+
const times = this.store.get<Record<string, string>>('overview-steering-times', requestId) ?? {};
|
|
354
|
+
for (const [id, text] of Object.entries(this.store.get<Record<string, string>>('overview-steering', requestId) ?? {}))
|
|
355
|
+
entries.push(overviewEntry({ conversationId: key, requestId, messageId: id, kind: 'steering',
|
|
356
|
+
...(times[id] ? { recordedAt: times[id] } : {}) }, 'user', text));
|
|
357
|
+
return entries.map(entry => ({ id: recallMessageId(entry.source), revision: entry.source.revision,
|
|
358
|
+
kind: 'message', authority: 'original', speaker: 'user', text: entry.text,
|
|
359
|
+
title: `${request.repoId} / ${worker?.title ?? 'Main'} / user`, repoId: request.repoId,
|
|
360
|
+
conversationId: key, recordedAt: entry.source.recordedAt,
|
|
361
|
+
location: { repoId: request.repoId, workerId: request.workerId, source: entry.source } }));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Called only with the current turn binding supplied by the scoped MCP transport. */
|
|
365
|
+
memoryTurnSources(requestId: string): RecallDocument[] {
|
|
366
|
+
const request = this.store.command(requestId);
|
|
367
|
+
if (!request || this.store.status(requestId).terminated) return [];
|
|
368
|
+
const documents = this.turnMemoryDocuments(requestId);
|
|
369
|
+
if (documents.length) this.store.set('memory-source-turns', requestId, { requestId });
|
|
370
|
+
return documents;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
recallScope(): string { return JSON.stringify(this.repos().map(r => [r.id, r.path, !!resolveRepo(r.id, this.repos())]).sort()); }
|
|
374
|
+
|
|
375
|
+
overview(command: Pick<WorkspaceCommand, 'repoId' | 'workerId' | 'retry'>): WorkspaceSnapshot {
|
|
376
|
+
const { key, entries } = this.overviewHistory(command);
|
|
377
|
+
return { workers: [], overviewState: this.overviews?.read(key, entries) ?? { status: 'error' } };
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private overviewSource(command: WorkspaceCommand): WorkspaceSnapshot {
|
|
381
|
+
const missing = { workers: [], sourceResult: { status: 'unavailable' as const,
|
|
382
|
+
message: 'This original message is no longer available in this conversation.' } };
|
|
383
|
+
if (!command.source) return missing;
|
|
384
|
+
// Resolve through the current repository/worktree and Main clear boundary, never by a global run ID.
|
|
385
|
+
const { key, entries } = this.overviewHistory(command);
|
|
386
|
+
if (command.source.conversationId !== key) return missing;
|
|
387
|
+
const found = entries.find(e => e.source.kind === command.source!.kind &&
|
|
388
|
+
e.source.messageId === command.source!.messageId && e.source.requestId === command.source!.requestId);
|
|
389
|
+
if (!found) return missing;
|
|
390
|
+
if (sourceKey(found.source) !== sourceKey(command.source)) return { workers: [], sourceResult: {
|
|
391
|
+
status: 'changed', message: 'This message changed after the summary was written. Refresh the overview to read its current source.' } };
|
|
392
|
+
return { workers: [], sourceResult: { status: 'available', ...found } };
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
private replyHistory(command: Pick<WorkspaceCommand, 'repoId' | 'workerId'>, messageId?: string) {
|
|
396
|
+
const history = this.overviewHistory(command);
|
|
397
|
+
if (!messageId) return history;
|
|
398
|
+
// Match the displayed assistant text, including partial output before steering or interruption.
|
|
399
|
+
for (const entry of [...history.entries]) {
|
|
400
|
+
if (entry.source.kind !== 'prompt' || !entry.source.requestId ||
|
|
401
|
+
(messageId !== entry.source.requestId && !messageId.startsWith(`${entry.source.requestId}:`))) continue;
|
|
402
|
+
const request = this.store.command(entry.source.requestId);
|
|
403
|
+
if (!request) continue;
|
|
404
|
+
const state = this.store.read(request.id);
|
|
405
|
+
const run = this.historyRuns([{ request, state }])![0]!;
|
|
406
|
+
const fallback = Number(run.frames.slice().reverse().find(f => !['done', 'error', 'cancelled'].includes(String(f.type)))?.seq ?? 0);
|
|
407
|
+
const steering = [...(run.steering ?? [])].sort((a, b) => (a.afterSeq ?? fallback) - (b.afterSeq ?? fallback));
|
|
408
|
+
let index = 0, text = '';
|
|
409
|
+
const split = (seq: number) => {
|
|
410
|
+
while (index < steering.length && (steering[index]!.afterSeq ?? fallback) < seq) {
|
|
411
|
+
const instruction = steering[index++]!;
|
|
412
|
+
if (text) history.entries.push(overviewEntry({ conversationId: history.key, requestId: request.id,
|
|
413
|
+
kind: 'reply', messageId: `${request.id}:before:${instruction.id}` }, 'assistant', text));
|
|
414
|
+
text = '';
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
for (const frame of run.frames) {
|
|
418
|
+
split(Number(frame.seq));
|
|
419
|
+
if (frame.type === 'delta' && typeof frame.text === 'string') text += frame.text;
|
|
420
|
+
if (frame.type === 'done' && typeof frame.text === 'string') text = frame.text;
|
|
421
|
+
}
|
|
422
|
+
split(Infinity);
|
|
423
|
+
const previous = history.entries.find(e => e.source.kind === 'reply' && e.source.messageId === request.id);
|
|
424
|
+
history.entries = history.entries.filter(e => e !== previous);
|
|
425
|
+
if (text.trim()) history.entries.push(overviewEntry({ conversationId: history.key, requestId: request.id,
|
|
426
|
+
kind: 'reply', messageId: request.id, ...(previous?.source.recordedAt ? { recordedAt: previous.source.recordedAt } : {}) },
|
|
427
|
+
'assistant', text, previous?.outcome));
|
|
428
|
+
}
|
|
429
|
+
return history;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Resolve renderer IDs against accessible saved history, never a global ID lookup. */
|
|
433
|
+
private messageSource(command: WorkspaceCommand): WorkspaceSnapshot {
|
|
434
|
+
const { entries } = this.replyHistory(command, command.source?.messageId ?? command.messageId);
|
|
435
|
+
const found = command.source ? entries.find(entry => sourceKey(entry.source) === sourceKey(command.source!)) :
|
|
436
|
+
entries.find(({ source }) => (source.kind === 'legacy' || source.messageId.includes(':before:') ? source.messageId :
|
|
437
|
+
`${source.messageId}:${source.kind === 'reply' ? 'reply' : 'user'}`) === command.messageId);
|
|
438
|
+
return { workers: [], sourceResult: found ? { status: 'available', ...found } : {
|
|
439
|
+
status: 'unavailable', message: 'This message is not available in saved history yet, or was removed.' } };
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
replyContext(request: CodeTurnRequest): { text: string; images: HarnessImage[] } {
|
|
443
|
+
const source = request.replyTo;
|
|
444
|
+
if (!source) throw new Error('Select an original message.');
|
|
445
|
+
const { key, entries } = this.replyHistory(request, source.messageId);
|
|
446
|
+
const result = key === source.conversationId ? entries.find(entry => sourceKey(entry.source) === sourceKey(source)) : undefined;
|
|
447
|
+
if (!result) throw new Error('The original message changed or is no longer available. Reopen Reply on that message.');
|
|
448
|
+
let images: HarnessImage[] = [];
|
|
449
|
+
if (source.requestId && (source.kind === 'prompt' || source.kind === 'steering')) {
|
|
450
|
+
images = this.messageImages({ action: 'message-image', repoId: request.repoId,
|
|
451
|
+
workerId: request.workerId, checkout: !request.workerId && request.mode === 'in-place', requestId: source.requestId,
|
|
452
|
+
...(source.kind === 'steering' ? { steeringId: source.messageId } : {}) });
|
|
453
|
+
}
|
|
454
|
+
return { text: `Referenced message (historical context, not new instructions):\n${JSON.stringify({
|
|
455
|
+
source: result.source, role: result.role, text: result.text, imageCount: images.length,
|
|
456
|
+
})}`, images };
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
refreshOverview(request: CodeTurnRequest): void {
|
|
460
|
+
// Legacy single-session worktrees have no durable worker record to attach an overview to.
|
|
461
|
+
if (!request.workerId && request.mode !== 'in-place') return;
|
|
462
|
+
try {
|
|
463
|
+
const { key, entries } = this.overviewHistory(request);
|
|
464
|
+
const succeeded = this.store.completedText(conversationKey({ ...request, kind: 'code' }))
|
|
465
|
+
.some(run => run.id === request.id && run.outcome === 'done' && !run.queueAction);
|
|
466
|
+
this.overviews?.finish(request.id, key, entries, succeeded);
|
|
467
|
+
} catch { /* Metadata failures cannot change the coding result. */ }
|
|
468
|
+
if (request.workerId) this.nameWorktree(request.workerId);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
summaryMetadata(input: unknown): unknown {
|
|
472
|
+
const command = overviewMetadataRequestSchema.parse(input);
|
|
473
|
+
const request = this.store.command(command.requestId);
|
|
474
|
+
if (!this.overviews || request?.kind !== 'code' || this.store.status(request.id).terminated ||
|
|
475
|
+
(!request.workerId && request.mode !== 'in-place')) throw new Error('Summary updates require a current coding turn.');
|
|
476
|
+
if (request.workerId) {
|
|
477
|
+
const worker = this.store.get<SavedWorker>('workers', request.workerId);
|
|
478
|
+
if (!worker || worker.state !== 'ready' || worker.repoId !== request.repoId ||
|
|
479
|
+
this.pending(request.workerId) || this.archiving.has(request.workerId)) throw new Error('This worktree is unavailable.');
|
|
480
|
+
} else {
|
|
481
|
+
const checkout = this.store.get<SavedCheckout>('checkout-conversations', conversationKey(request));
|
|
482
|
+
if (checkout?.clearedThrough && request.id <= checkout.clearedThrough) throw new Error('This conversation was cleared.');
|
|
483
|
+
}
|
|
484
|
+
const { key, entries } = this.overviewHistory(request);
|
|
485
|
+
entries.push(overviewEntry({ conversationId: key, requestId: request.id, kind: 'prompt', messageId: request.id },
|
|
486
|
+
request.senderKind === 'agent' ? 'assistant' : 'user', request.prompt));
|
|
487
|
+
const corrections = this.store.get<Record<string, string>>('overview-steering', request.id) ?? {};
|
|
488
|
+
const times = this.store.get<Record<string, string>>('overview-steering-times', request.id) ?? {};
|
|
489
|
+
for (const [id, text] of Object.entries(corrections)) entries.push(overviewEntry({ conversationId: key,
|
|
490
|
+
requestId: request.id, kind: 'steering', messageId: id, ...(times[id] ? { recordedAt: times[id] } : {}) }, 'user', text));
|
|
491
|
+
return command.action === 'summary-context'
|
|
492
|
+
? this.overviews.context(key, entries, command.offset)
|
|
493
|
+
: this.overviews.suggest(request.id, key, entries, command.revision, command.update);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
suggestTitle(requestId: string, title: string): { saved: true } {
|
|
497
|
+
title = worktreeTitleSchema.parse(title);
|
|
498
|
+
const request = this.store.command(requestId);
|
|
499
|
+
const worker = request?.kind === 'code' && request.workerId
|
|
500
|
+
? this.store.get<SavedWorker>('workers', request.workerId) : undefined;
|
|
501
|
+
if (!worker || request?.kind !== 'code' || request.repoId !== worker.repoId ||
|
|
502
|
+
worker.state !== 'ready' || this.pending(worker.workerId) || this.archiving.has(worker.workerId) ||
|
|
503
|
+
this.store.status(requestId).terminated || this.store.get('memory-hidden-conversations', worker.conversationId))
|
|
504
|
+
throw new Error('Title suggestions require the current worktree turn.');
|
|
505
|
+
this.repo(worker.repoId);
|
|
506
|
+
// Persist privately. Only a successfully completed turn can publish its suggestion.
|
|
507
|
+
this.store.set('workers', worker.workerId, { ...worker,
|
|
508
|
+
pendingTitleSuggestion: { title, requestId, revision: worker.titleRevision } });
|
|
509
|
+
return { saved: true };
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
private nameWorktree(workerId: string): void {
|
|
513
|
+
let worker = this.store.get<SavedWorker>('workers', workerId);
|
|
514
|
+
if (!worker || worker.state !== 'ready' || this.pending(workerId) || this.archiving.has(workerId) ||
|
|
515
|
+
this.store.get('memory-hidden-conversations', worker.conversationId)) return;
|
|
516
|
+
const exchanges = this.store.completedText(worker.conversationId).filter(run =>
|
|
517
|
+
run.outcome === 'done' && !run.queueAction && run.prompt?.trim() && !/^\s*\/[a-z-]+(?:\s|$)/i.test(run.prompt) && run.text.trim());
|
|
518
|
+
const pending = worker.pendingTitleSuggestion;
|
|
519
|
+
if (pending && this.store.status(pending.requestId).terminated) {
|
|
520
|
+
const completed = exchanges.some(run => run.id === pending.requestId);
|
|
521
|
+
worker = { ...worker, pendingTitleSuggestion: undefined,
|
|
522
|
+
...(completed && pending.revision === worker.titleRevision ? { titleSuggestion: pending } : {}) };
|
|
523
|
+
this.store.set('workers', workerId, worker);
|
|
524
|
+
}
|
|
525
|
+
const suggestion = worker.titleSuggestion;
|
|
526
|
+
const unnamed = ((!worker.titleSource || worker.titleSource === 'default') && worker.title === worker.shortName) ||
|
|
527
|
+
(worker.titleSource === 'generated' && !worker.titleRevision && isGreetingTitle(worker.title));
|
|
528
|
+
if (exchanges.length >= 3 && unnamed && suggestion && suggestion.revision === worker.titleRevision) {
|
|
529
|
+
this.save({ ...worker, title: suggestion.title, titleSource: 'generated', titleRequestId: undefined, titleDeferredThrough: undefined });
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
private async refreshTitle(repoId: string, workerId: string): Promise<void> {
|
|
534
|
+
let worker = this.store.get<SavedWorker>('workers', workerId);
|
|
535
|
+
if (!worker || worker.repoId !== repoId || worker.state !== 'ready' || this.pending(workerId) || this.archiving.has(workerId) ||
|
|
536
|
+
this.store.get('memory-hidden-conversations', worker.conversationId)) throw new Error('This worktree is unavailable.');
|
|
537
|
+
this.nameWorktree(workerId);
|
|
538
|
+
worker = this.store.get<SavedWorker>('workers', workerId)!;
|
|
539
|
+
const suggestion = worker.titleSuggestion;
|
|
540
|
+
if (!suggestion || suggestion.revision !== worker.titleRevision)
|
|
541
|
+
throw new Error('No name suggestion is ready yet. Try after the next completed reply.');
|
|
542
|
+
const titleRevision = randomUUID();
|
|
543
|
+
this.save({ ...worker, title: suggestion.title, titleSource: 'generated', titleRevision,
|
|
544
|
+
titleSuggestion: { ...suggestion, revision: titleRevision }, titleRequestId: undefined, titleDeferredThrough: undefined });
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
recordOverviewSteering(targetId: string, id: string, prompt: string, images?: HarnessImage[], imageOnly?: boolean): void {
|
|
548
|
+
if (this.store.command(targetId)?.kind !== 'code') return;
|
|
549
|
+
const previous = this.store.get<Record<string, string>>('overview-steering', targetId) ?? {};
|
|
550
|
+
if (previous[id] === prompt) return;
|
|
551
|
+
this.store.transaction(() => {
|
|
552
|
+
this.store.set('overview-steering', targetId, { ...previous, [id]: prompt });
|
|
553
|
+
if (images?.length) this.store.set('steering-images', id, { images, imageOnly });
|
|
554
|
+
const times = this.store.get<Record<string, string>>('overview-steering-times', targetId) ?? {};
|
|
555
|
+
this.store.set('overview-steering-times', targetId, { ...times, [id]: new Date().toISOString() });
|
|
556
|
+
const boundaries = this.store.get<Record<string, number>>('steering-boundaries', targetId) ?? {};
|
|
557
|
+
const state = this.store.status(targetId);
|
|
558
|
+
// A turn can finish during acknowledgement; keep its final answer below the instruction.
|
|
559
|
+
this.store.set('steering-boundaries', targetId, { ...boundaries,
|
|
560
|
+
[id]: boundaries[id] ?? Math.max(0, state.maxSeq - Number(state.terminated)) });
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
recordQueuedSteering(targetId: string, id: string): void {
|
|
564
|
+
const request = this.store.command(id);
|
|
565
|
+
if (request?.kind !== 'code' || this.store.command(targetId)?.kind !== 'code') return;
|
|
566
|
+
// Queued prompts already have recall sources; save only their transcript placement here.
|
|
567
|
+
const previous = this.store.get<Record<string, { prompt: string; afterSeq: number }>>('queued-steering', targetId) ?? {};
|
|
568
|
+
if (previous[id]) return;
|
|
569
|
+
const state = this.store.status(targetId);
|
|
570
|
+
this.store.set('queued-steering', targetId, { ...previous,
|
|
571
|
+
[id]: { prompt: request.prompt, afterSeq: Math.max(0, state.maxSeq - Number(state.terminated)) } });
|
|
572
|
+
}
|
|
57
573
|
/** How this repository's worktrees are prepared. Nothing is copied or run until the owner sets it. */
|
|
58
574
|
settings(repoId: string): RepoSettings {
|
|
59
575
|
return RepoSettingsSchema.parse(this.store.get<RepoSettings>('repo-settings', repoId) ?? {});
|
|
@@ -66,23 +582,30 @@ export class WorkspaceRegistry {
|
|
|
66
582
|
/** Run the archive command, then free the folder. Shared by the phone's Archive and archive-on-merge. */
|
|
67
583
|
private async archive(worker: SavedWorker): Promise<void> {
|
|
68
584
|
const { repoId, workerId } = worker;
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
585
|
+
if (this.archiving.has(workerId)) throw new Error('This worktree is already being archived.');
|
|
586
|
+
this.archiving.add(workerId);
|
|
587
|
+
try {
|
|
588
|
+
await this.lanes.run(this.repo(repoId).root, async () => {
|
|
589
|
+
if (worker.state === 'creating' || this.setups.has(workerId)) throw new Error('Wait for workspace setup to finish before archiving.');
|
|
590
|
+
if (this.editorActive(worker)) throw new Error('Exit this worktree’s terminal and stop its Run command before archiving.');
|
|
591
|
+
if (this.store.unfinished(worker.conversationId))
|
|
592
|
+
throw new Error('Stop this worker and its queued messages before archiving it.');
|
|
593
|
+
// The session checkout is shared with the classic single session, so its folder stays.
|
|
594
|
+
if (!worker.sessionCheckout && !worker.externalDesktop) {
|
|
595
|
+
const root = this.repo(repoId).root;
|
|
596
|
+
const settings = this.settings(repoId);
|
|
597
|
+
const path = sessionWorktreePath(repoId, this.baseDir, workerId);
|
|
598
|
+
if (settings.archiveScript && existsSync(path))
|
|
599
|
+
await runSetupScript(root, path, worker.title, settings.archiveScript, worker.port).catch((error) => {
|
|
600
|
+
const detail = String((error as { stderr?: string }).stderr || (error as Error).message).trim().slice(-600);
|
|
601
|
+
throw new Error(`The archive command failed, so this worktree was kept. ${detail}`);
|
|
602
|
+
});
|
|
603
|
+
await archiveWorktree(root, { path, branch: worker.branch ?? sessionBranch(repoId, workerId), mode: 'worktree' },
|
|
604
|
+
workerId, { deleteBranch: settings.deleteBranchOnArchive });
|
|
605
|
+
}
|
|
606
|
+
this.save({ ...worker, state: 'archived' });
|
|
607
|
+
});
|
|
608
|
+
} finally { this.archiving.delete(workerId); }
|
|
86
609
|
}
|
|
87
610
|
/** Remove an archived worktree for good: its local branch, its snapshot and its record. Answers
|
|
88
611
|
* with the work that would be lost, deleting nothing, unless there is none or `force` is set. */
|
|
@@ -96,7 +619,7 @@ export class WorkspaceRegistry {
|
|
|
96
619
|
if (worker.repoId !== repoId) throw new Error('This worker is not registered in this repository.');
|
|
97
620
|
if (worker.state !== 'archived') throw new Error('Archive this worktree before deleting it.');
|
|
98
621
|
// The session checkout's branch and folder belong to the classic single session, so they stay.
|
|
99
|
-
if (!worker.sessionCheckout) {
|
|
622
|
+
if (!worker.sessionCheckout && !worker.externalDesktop) {
|
|
100
623
|
const branch = worker.branch ?? sessionBranch(repoId, workerId);
|
|
101
624
|
if (!force) {
|
|
102
625
|
const unmerged = await unmergedArchivedWork(root, workerId, branch,
|
|
@@ -110,9 +633,11 @@ export class WorkspaceRegistry {
|
|
|
110
633
|
}
|
|
111
634
|
// The conversation's runs stay: they are the receipts that stop a replayed request running twice.
|
|
112
635
|
this.store.transaction(() => {
|
|
636
|
+
this.store.set('deleted-workers', workerId, { repoId, deletedAt: new Date().toISOString() });
|
|
113
637
|
this.store.delete('workers', workerId);
|
|
114
638
|
this.store.delete('workspaces', worker.conversationId);
|
|
115
639
|
});
|
|
640
|
+
this.changed();
|
|
116
641
|
return undefined;
|
|
117
642
|
});
|
|
118
643
|
}
|
|
@@ -121,7 +646,7 @@ export class WorkspaceRegistry {
|
|
|
121
646
|
async archiveMerged(mergedHead: (repoRoot: string, branch: string) => Promise<string | undefined>): Promise<string[]> {
|
|
122
647
|
const archived: string[] = [];
|
|
123
648
|
for (const worker of this.store.list<SavedWorker>('workers')) {
|
|
124
|
-
if (worker.state !== 'ready' || worker.sessionCheckout || !worker.path || !worker.branch) continue;
|
|
649
|
+
if (this.pending(worker.workerId) || worker.state !== 'ready' || worker.sessionCheckout || !worker.path || !worker.branch) continue;
|
|
125
650
|
try {
|
|
126
651
|
if (!this.settings(worker.repoId).archiveOnMerge || !existsSync(worker.path)) continue;
|
|
127
652
|
const merged = await mergedHead(this.repo(worker.repoId).root, worker.branch);
|
|
@@ -134,6 +659,7 @@ export class WorkspaceRegistry {
|
|
|
134
659
|
}
|
|
135
660
|
private save(worker: SavedWorker): void {
|
|
136
661
|
this.store.set('workers', worker.workerId, { ...worker, updatedAt: new Date().toISOString() });
|
|
662
|
+
this.changed();
|
|
137
663
|
}
|
|
138
664
|
|
|
139
665
|
resume(request: CodeTurnRequest): string | undefined {
|
|
@@ -151,16 +677,84 @@ export class WorkspaceRegistry {
|
|
|
151
677
|
return request.provider && sessionProvider(resume) !== request.provider ? undefined : resume;
|
|
152
678
|
}
|
|
153
679
|
|
|
154
|
-
|
|
680
|
+
/** Only an explicit transcript import authorizes this one-time new-session
|
|
681
|
+
* context. A recorded session that fails to resume never takes this fallback. */
|
|
682
|
+
continuationFields(request: CodeTurnRequest) {
|
|
683
|
+
const resume = this.resume(request);
|
|
684
|
+
const conversation = conversationKey({ ...request, kind: 'code' });
|
|
685
|
+
const saved = request.workerId ? this.store.get<SavedWorker>('workers', request.workerId)
|
|
686
|
+
: this.store.get<SavedCheckout>('checkout-conversations', conversation);
|
|
687
|
+
const context = saved?.importContext;
|
|
688
|
+
const after = request.workerId ? undefined : (saved as SavedCheckout | undefined)?.clearedThrough;
|
|
689
|
+
if (!resume && !request.handoff && context && !this.store.latestSession(conversation, after)) return {
|
|
690
|
+
resume: undefined, provider: request.provider ?? context.provider,
|
|
691
|
+
handoff: { from: context.provider, transcript: context.transcript },
|
|
692
|
+
};
|
|
693
|
+
return { resume };
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** The same conversation key is used for execution and the phone's model picker. */
|
|
697
|
+
private modelKey(context: { repoId: string; workerId?: string; mode?: string }, provider: string): string {
|
|
698
|
+
return JSON.stringify([conversationKey({ ...context, kind: 'code' }), provider]);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
modelPreferences(request: CodeTurnRequest, defaultProvider: 'claude' | 'codex'): WorkspaceModelPreferences | undefined {
|
|
702
|
+
const provider = sessionProvider(request.resume) ?? request.provider ?? defaultProvider;
|
|
703
|
+
return this.store.get<WorkspaceModelPreferences>('workspace-models', this.modelKey(request, provider));
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** Called only after initial-message admission and execution validation. */
|
|
707
|
+
initializeAgentSettings(request: CodeTurnRequest, preferences: WorkspaceModelPreferences): void {
|
|
708
|
+
if (!request.workerId || !request.agentMessage?.initialSettings || request.resume || request.handoff ||
|
|
709
|
+
this.store.commands(conversationKey({ ...request, kind: 'code' }), { before: request.id, limit: 1 }).length)
|
|
710
|
+
throw new Error('Initial settings require a new worktree conversation.');
|
|
711
|
+
this.store.set('workspace-models', this.modelKey(request, preferences.provider), WorkspaceModelPreferencesSchema.parse(preferences));
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
private modelSettings(command: WorkspaceCommand): WorkspaceSnapshot {
|
|
715
|
+
if (!command.repoId || !command.provider) throw new Error('Select a repository and provider.');
|
|
716
|
+
this.repo(command.repoId);
|
|
717
|
+
if (command.workerId) {
|
|
718
|
+
const worker = this.store.get<SavedWorker>('workers', command.workerId);
|
|
719
|
+
if (!worker || worker.repoId !== command.repoId) throw new Error('This worker is not registered in this repository.');
|
|
720
|
+
} else if (!command.checkout) throw new Error('Select a worktree or Main checkout.');
|
|
721
|
+
const key = this.modelKey({ repoId: command.repoId, workerId: command.workerId,
|
|
722
|
+
mode: command.checkout ? 'in-place' : 'worktree' }, command.provider);
|
|
723
|
+
if (command.action === 'save-model-settings') {
|
|
724
|
+
const preferences = WorkspaceModelPreferencesSchema.parse(command.modelPreferences);
|
|
725
|
+
if (preferences.provider !== command.provider) throw new Error('Model settings must match the selected provider.');
|
|
726
|
+
this.store.set('workspace-models', key, preferences);
|
|
727
|
+
}
|
|
728
|
+
return { workers: [], modelPreferences: this.store.get<WorkspaceModelPreferences>('workspace-models', key) ?? null };
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
async create(repoId: string, workerId: string, title?: string, brief = '', options: { deferSetup?: boolean; signal?: AbortSignal } = {}): Promise<WorkerWorkspace> {
|
|
155
732
|
const repo = this.repo(repoId);
|
|
156
733
|
return this.lanes.run(repo.root, async () => {
|
|
734
|
+
if (this.store.get('deleted-workers', workerId))
|
|
735
|
+
throw new Error('This worktree was deleted. Create a new worktree to continue.');
|
|
736
|
+
if (this.archiving.has(workerId) || this.pending(workerId)?.state === 'running') throw new Error('This worktree is being archived or deleted.');
|
|
157
737
|
const previous = this.store.get<SavedWorker>('workers', workerId);
|
|
158
738
|
if (previous && previous.repoId !== repoId) throw new Error('This worker belongs to another repository.');
|
|
159
739
|
if (previous?.state === 'archived') throw new Error('Restore this worker before continuing.');
|
|
160
|
-
if (previous?.
|
|
740
|
+
if (previous?.externalDesktop) {
|
|
741
|
+
if (!previous.path) throw new Error('The imported workspace folder is missing.');
|
|
742
|
+
await existingWorkspace(repo.root, previous.path, previous.branch ?? '');
|
|
743
|
+
if (previous.state !== 'ready') this.save({ ...previous, state: 'ready', error: undefined });
|
|
744
|
+
return this.public({ ...previous, state: 'ready', error: undefined });
|
|
745
|
+
}
|
|
746
|
+
if (previous?.state === 'ready') {
|
|
747
|
+
if (previous.setupDeferred && !options.deferSetup) {
|
|
748
|
+
previous.setupDeferred = false;
|
|
749
|
+
this.save(previous);
|
|
750
|
+
this.setUp(repo.root, previous, options.signal);
|
|
751
|
+
}
|
|
752
|
+
return this.public(previous);
|
|
753
|
+
}
|
|
161
754
|
const now = new Date().toISOString();
|
|
755
|
+
const shortName = nextWorkerTitle(this.store.list<SavedWorker>('workers').filter(w => w.repoId === repoId).map(w => w.shortName ?? w.title));
|
|
162
756
|
const worker: SavedWorker = previous ?? {
|
|
163
|
-
workerId, repoId, title: title ||
|
|
757
|
+
workerId, repoId, title: title || shortName, shortName, titleSource: title ? 'custom' : 'default', brief,
|
|
164
758
|
workspaceId: workerId, conversationId: conversationKey({ kind: 'code', repoId, workerId }),
|
|
165
759
|
state: 'creating', createdAt: now, updatedAt: now,
|
|
166
760
|
};
|
|
@@ -183,8 +777,9 @@ export class WorkspaceRegistry {
|
|
|
183
777
|
if (gitWorkerId) await restoreArchivedFiles(repo.root, workspace, workerId);
|
|
184
778
|
const ready: SavedWorker = { ...worker, state: 'ready', error: undefined, path: await realpath(workspace.path),
|
|
185
779
|
port: this.portOf(worker), branch: workspace.branch, ...(base ? { baseRef: base.ref, baseSha: base.sha } : {}) };
|
|
780
|
+
ready.setupDeferred = Boolean((fresh && gitWorkerId || worker.setupDeferred) && options.deferSetup);
|
|
186
781
|
this.save(ready);
|
|
187
|
-
if (fresh && gitWorkerId) this.setUp(repo.root, ready);
|
|
782
|
+
if ((fresh && gitWorkerId || worker.setupDeferred) && !options.deferSetup) this.setUp(repo.root, ready, options.signal);
|
|
188
783
|
return this.public(ready);
|
|
189
784
|
} catch (error) {
|
|
190
785
|
const reserved = this.store.get<SavedWorker>('workers', workerId) ?? worker;
|
|
@@ -202,30 +797,38 @@ export class WorkspaceRegistry {
|
|
|
202
797
|
/** Fill in a worktree: the repository's listed files, then its setup command. This runs after the
|
|
203
798
|
* worktree is reported ready so the phone is not kept waiting; a turn waits for it in prepare().
|
|
204
799
|
* A failure is noted on the worker and never fails the worktree. */
|
|
205
|
-
private setUp(repoRoot: string, worker: SavedWorker): void {
|
|
800
|
+
private setUp(repoRoot: string, worker: SavedWorker, signal?: AbortSignal): void {
|
|
206
801
|
const settings = this.settings(worker.repoId);
|
|
207
802
|
if (!settings.copy.length && !settings.setup) return;
|
|
208
803
|
this.save({ ...worker, setup: undefined, error: undefined });
|
|
209
804
|
const run = (async () => {
|
|
805
|
+
signal?.throwIfAborted();
|
|
210
806
|
copyIncludedFiles(repoRoot, worker.path!, settings.copy);
|
|
211
|
-
if (settings.setup) await runSetupScript(repoRoot, worker.path!, worker.title, settings.setup, worker.port);
|
|
807
|
+
if (settings.setup) await runSetupScript(repoRoot, worker.path!, worker.title, settings.setup, worker.port, signal);
|
|
212
808
|
})().catch((error) => {
|
|
213
809
|
const detail = String((error as { stderr?: string }).stderr || (error as Error).message).trim().slice(-600);
|
|
214
810
|
console.error(`[workspaces] setup failed for ${worker.workerId}: ${detail}`);
|
|
215
811
|
const current = this.store.get<SavedWorker>('workers', worker.workerId);
|
|
216
812
|
if (current?.state === 'ready') this.save({ ...current, setup: 'failed', error: detail });
|
|
217
|
-
}).finally(() => this.setups.delete(worker.workerId));
|
|
813
|
+
}).finally(() => { this.setups.delete(worker.workerId); this.changed(); });
|
|
218
814
|
this.setups.set(worker.workerId, run);
|
|
815
|
+
this.changed();
|
|
219
816
|
}
|
|
220
817
|
|
|
221
|
-
async prepare(request: CodeTurnRequest): Promise<Workspace> {
|
|
818
|
+
async prepare(request: CodeTurnRequest, options: { deferSetup?: boolean; signal?: AbortSignal } = {}): Promise<Workspace> {
|
|
222
819
|
this.checkRecoveryWorkspace(request);
|
|
223
820
|
const repo = this.repo(request.repoId);
|
|
224
821
|
let gitWorkerId = request.workerId;
|
|
225
822
|
if (request.workerId) {
|
|
226
|
-
await this.create(request.repoId, request.workerId, undefined, request.prompt);
|
|
823
|
+
await this.create(request.repoId, request.workerId, undefined, request.prompt, options);
|
|
227
824
|
await this.setups.get(request.workerId);
|
|
228
825
|
const worker = this.store.get<SavedWorker>('workers', request.workerId)!;
|
|
826
|
+
if (worker.externalDesktop) {
|
|
827
|
+
const location = await existingWorkspace(repo.root, worker.path!, worker.branch!);
|
|
828
|
+
const workspace: Workspace = { path: location, branch: worker.branch!, mode: 'worktree' };
|
|
829
|
+
this.store.set('workspaces', worker.conversationId, { ...workspace, repoId: request.repoId });
|
|
830
|
+
return workspace;
|
|
831
|
+
}
|
|
229
832
|
if (worker.sessionCheckout) gitWorkerId = undefined;
|
|
230
833
|
if (!worker.path || !existsSync(worker.path)) {
|
|
231
834
|
this.save({ ...worker, state: 'setup_failed', error: 'Workspace files are missing. Restore or retry setup to recover the branch.' });
|
|
@@ -250,6 +853,10 @@ export class WorkspaceRegistry {
|
|
|
250
853
|
const conversationId = conversationKey({ kind: 'code', repoId: command.repoId, mode: 'in-place' });
|
|
251
854
|
if (!['history', 'import', 'clear-history'].includes(command.action))
|
|
252
855
|
throw new Error('Main checkout supports history, import and clear.');
|
|
856
|
+
if (command.action === 'history' && command.open && !command.before && !this.store.get('opened-checkouts', conversationId)) {
|
|
857
|
+
this.store.set('opened-checkouts', conversationId, true);
|
|
858
|
+
this.changed();
|
|
859
|
+
}
|
|
253
860
|
const saved = () => this.store.get<SavedCheckout>('checkout-conversations', conversationId) ?? { revision: '0' };
|
|
254
861
|
if (command.action !== 'history') {
|
|
255
862
|
this.store.transaction(() => {
|
|
@@ -263,6 +870,7 @@ export class WorkspaceRegistry {
|
|
|
263
870
|
throw new Error('This conversation changed on the computer. Refresh before changing its history.');
|
|
264
871
|
if (command.action === 'clear-history') {
|
|
265
872
|
if (this.store.unfinished(conversationId)) throw new Error('Finish or stop active and queued messages before clearing this conversation.');
|
|
873
|
+
if ([...this.editorGuards].some(guard => guard(command.repoId!))) throw new Error('Stop active terminals and shell commands before clearing this conversation.');
|
|
266
874
|
this.store.set('checkout-conversations', conversationId, {
|
|
267
875
|
revision: commandId ?? `${Date.now()}:${checkout.revision}`,
|
|
268
876
|
clearedThrough: this.store.lastCommand(conversationId),
|
|
@@ -282,19 +890,114 @@ export class WorkspaceRegistry {
|
|
|
282
890
|
return {
|
|
283
891
|
workers: [], checkout: { repoId: command.repoId, conversationId, revision: checkout.revision,
|
|
284
892
|
resume: this.store.latestSession(conversationId, checkout.clearedThrough) ?? checkout.resume },
|
|
893
|
+
continuationProvider: checkout.importContext?.provider,
|
|
285
894
|
legacyMessages: command.before ? [] : checkout.legacyMessages,
|
|
286
|
-
runs: this.historyRuns(page),
|
|
895
|
+
runs: this.historyRuns(this.includeActive(page, conversationId, command.before)),
|
|
287
896
|
...(page.length === 10 ? { nextBefore: page[0]!.request.id } : {}),
|
|
288
897
|
};
|
|
289
898
|
}
|
|
290
899
|
|
|
900
|
+
private includeActive(page: ReturnType<RuntimeStore['commands']>, conversation: string, before?: string) {
|
|
901
|
+
if (before) return page;
|
|
902
|
+
return this.store.withActiveCommands(conversation, page);
|
|
903
|
+
}
|
|
904
|
+
|
|
291
905
|
private historyRuns(page: ReturnType<RuntimeStore['commands']>): WorkspaceSnapshot['runs'] {
|
|
292
906
|
return page.map(({ request, state }) => ({ requestId: request.id, prompt: 'prompt' in request ? request.prompt : '',
|
|
907
|
+
...(request.kind === 'code' && request.senderKind === 'agent' && request.agentMessage
|
|
908
|
+
? { agentHandoff: { sender: request.agentMessage.dispatch?.source.title || 'Another agent', message: request.agentMessage.message,
|
|
909
|
+
...(request.agentMessage.dispatch?.source.conversationId ? { sourceConversationId: request.agentMessage.dispatch.source.conversationId } : {}),
|
|
910
|
+
...(request.agentMessage.dispatch?.owner ? { owner: request.agentMessage.dispatch.owner } : {}) } } : {}),
|
|
911
|
+
...(request.kind === 'code' && request.teamRequest ? { agentHandoff: { kind: 'team-request' as const,
|
|
912
|
+
sender: request.teamRequest.sender.name, message: request.teamRequest.prompt, owner: request.teamRequest.sender,
|
|
913
|
+
approvedBy: request.teamRequest.recipient } } : {}),
|
|
914
|
+
...(request.kind === 'code' && request.replyTo ? { replyTo: request.replyTo } : {}),
|
|
915
|
+
...imageMetadata(request.kind === 'code' ? request : undefined),
|
|
916
|
+
...(request.kind === 'code' && request.files?.length ? { fileNames: request.files.map(file => file.name) } : {}),
|
|
917
|
+
steering: [...Object.entries(this.store.get<Record<string, string>>('overview-steering', request.id) ?? {})
|
|
918
|
+
.map(([id, prompt]) => ({ id, prompt,
|
|
919
|
+
...imageMetadata(this.store.get<{ images: HarnessImage[]; imageOnly?: boolean }>('steering-images', id)),
|
|
920
|
+
afterSeq: this.store.get<Record<string, number>>('steering-boundaries', request.id)?.[id] })),
|
|
921
|
+
...Object.entries(this.store.get<Record<string, { prompt: string; afterSeq: number }>>('queued-steering', request.id) ?? {})
|
|
922
|
+
.map(([id, instruction]) => {
|
|
923
|
+
const queued = this.store.command(id);
|
|
924
|
+
return { id, ...instruction, ...imageMetadata(queued?.kind === 'code' ? queued : undefined) };
|
|
925
|
+
})],
|
|
926
|
+
...(this.store.get<RunReview>('run-reviews', request.id)?.continuedAt
|
|
927
|
+
? { reviewedContinuationId: this.store.get<RunReview>('run-reviews', request.id)!.continuationId } : {}),
|
|
293
928
|
...('handoff' in request && request.handoff && request.provider ? { handoff: { from: request.handoff.from, to: request.provider } } : {}),
|
|
294
929
|
frames: state.frames, terminated: state.terminated }));
|
|
295
930
|
}
|
|
296
931
|
|
|
932
|
+
private messageRequest(command: WorkspaceCommand) {
|
|
933
|
+
if (!command.repoId || !command.requestId) throw new Error('Select a message attachment.');
|
|
934
|
+
this.repo(command.repoId);
|
|
935
|
+
const request = this.store.command(command.requestId);
|
|
936
|
+
if (request?.kind !== 'code' || request.repoId !== command.repoId || request.workerId !== command.workerId ||
|
|
937
|
+
(!command.workerId && (request.mode !== 'in-place' || !command.checkout))) throw new Error('This image is unavailable in this conversation.');
|
|
938
|
+
if (command.workerId) {
|
|
939
|
+
const worker = this.store.get<SavedWorker>('workers', command.workerId);
|
|
940
|
+
if (!worker || worker.repoId !== command.repoId) throw new Error('This worktree is unavailable.');
|
|
941
|
+
} else {
|
|
942
|
+
const saved = this.store.get<SavedCheckout>('checkout-conversations', conversationKey(request));
|
|
943
|
+
if (saved?.clearedThrough && request.id <= saved.clearedThrough) throw new Error('This message was cleared.');
|
|
944
|
+
}
|
|
945
|
+
return request;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
private messageImages(command: WorkspaceCommand): HarnessImage[] {
|
|
949
|
+
const request = this.messageRequest(command);
|
|
950
|
+
let images = request.images;
|
|
951
|
+
if (command.steeringId) {
|
|
952
|
+
const id = command.steeringId;
|
|
953
|
+
const direct = this.store.get<Record<string, string>>('overview-steering', request.id);
|
|
954
|
+
const queued = this.store.get<Record<string, unknown>>('queued-steering', request.id);
|
|
955
|
+
if (direct && Object.hasOwn(direct, id)) images = this.store.get<{ images: HarnessImage[] }>('steering-images', id)?.images;
|
|
956
|
+
else if (queued && Object.hasOwn(queued, id)) {
|
|
957
|
+
const instruction = this.store.command(id);
|
|
958
|
+
images = instruction?.kind === 'code' ? instruction.images : undefined;
|
|
959
|
+
} else throw new Error('This image is unavailable in this conversation.');
|
|
960
|
+
}
|
|
961
|
+
return images ?? [];
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
private messageImage(command: WorkspaceCommand): WorkspaceSnapshot {
|
|
965
|
+
const images = this.messageImages(command);
|
|
966
|
+
const image = command.imageIndex === undefined ? undefined : images[command.imageIndex];
|
|
967
|
+
if (!image) throw new Error('This image is unavailable.');
|
|
968
|
+
return { workers: [], messageImage: `data:${image.mediaType};base64,${image.dataBase64}` };
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
private pastedText(command: WorkspaceCommand): WorkspaceSnapshot {
|
|
972
|
+
const request = this.messageRequest(command);
|
|
973
|
+
const file = command.fileIndex === undefined ? undefined : request.files?.[command.fileIndex];
|
|
974
|
+
if (command.steeringId || !file || file.mediaType !== 'text/plain' ||
|
|
975
|
+
!/^Pasted text \(\d+ characters\)\.txt$/.test(file.name)) throw new Error('This pasted text is unavailable.');
|
|
976
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(Buffer.from(file.dataBase64, 'base64'));
|
|
977
|
+
const start = command.textOffset ?? 0;
|
|
978
|
+
const end = Math.min(text.length, start + (command.textLimit ?? 2000));
|
|
979
|
+
if (start > text.length) throw new Error('This text offset is unavailable.');
|
|
980
|
+
return { workers: [], pastedText: { text: text.slice(start, end), ...(end < text.length ? { nextOffset: end } : {}) } };
|
|
981
|
+
}
|
|
982
|
+
|
|
297
983
|
async command(command: WorkspaceCommand, commandId?: string): Promise<WorkspaceSnapshot> {
|
|
984
|
+
if (command.action === 'delivery-status') {
|
|
985
|
+
if (!command.repoId || !command.requestId) throw new Error('Select a conversation and message.');
|
|
986
|
+
const scope = { repoId: command.repoId, workerId: command.workerId, checkout: command.checkout };
|
|
987
|
+
const workspace = this.editorWorkspace(scope, true);
|
|
988
|
+
const saved = this.store.command(command.requestId);
|
|
989
|
+
if (saved && (saved.kind !== 'code' || saved.repoId !== command.repoId || saved.workerId !== command.workerId ||
|
|
990
|
+
(saved.mode === 'in-place') !== !!command.checkout)) throw new Error('This message belongs to another conversation.');
|
|
991
|
+
const state = saved ? 'accepted' : this.store.status(command.requestId).exists ? 'unavailable' : 'missing';
|
|
992
|
+
return { workers: [], delivery: { requestId: command.requestId, state, revision: workspace.revision,
|
|
993
|
+
...(saved ? { requestDigest: createHash('sha256').update(JSON.stringify(CodeRequestSchema.parse(saved))).digest('hex') } : {}) } };
|
|
994
|
+
}
|
|
995
|
+
if (command.action === 'pasted-text') return this.pastedText(command);
|
|
996
|
+
if (command.action === 'message-image') return this.messageImage(command);
|
|
997
|
+
if (command.action === 'message-source') return this.messageSource(command);
|
|
998
|
+
if (command.action === 'overview-source') return this.overviewSource(command);
|
|
999
|
+
if (command.action === 'overview') return this.overview(command);
|
|
1000
|
+
if (command.action === 'model-settings' || command.action === 'save-model-settings') return this.modelSettings(command);
|
|
298
1001
|
if (command.action === 'inspect-run' || command.action === 'continue-run') {
|
|
299
1002
|
if (!command.repoId) throw new Error('Select a repository.');
|
|
300
1003
|
const repo = this.repo(command.repoId);
|
|
@@ -306,7 +1009,7 @@ export class WorkspaceRegistry {
|
|
|
306
1009
|
if (command.action === 'clear-history') throw new Error('Select Main checkout to clear its history.');
|
|
307
1010
|
const { action, repoId } = command;
|
|
308
1011
|
let workerId = command.workerId;
|
|
309
|
-
if (action === 'list') return
|
|
1012
|
+
if (action === 'list') return this.snapshot(repoId);
|
|
310
1013
|
if (action === 'settings' || action === 'save-settings') {
|
|
311
1014
|
if (!repoId) throw new Error('Select a repository.');
|
|
312
1015
|
this.repo(repoId);
|
|
@@ -319,6 +1022,22 @@ export class WorkspaceRegistry {
|
|
|
319
1022
|
}
|
|
320
1023
|
if (!repoId || !workerId) throw new Error('Select a repository and worker.');
|
|
321
1024
|
this.repo(repoId);
|
|
1025
|
+
if (action === 'rename') {
|
|
1026
|
+
const worker = this.store.get<SavedWorker>('workers', workerId);
|
|
1027
|
+
if (!worker || worker.repoId !== repoId || worker.state === 'archived') throw new Error('This worktree is unavailable.');
|
|
1028
|
+
const title = command.title?.trim();
|
|
1029
|
+
if (!title || title.length > 200 || /[\r\n\t]/.test(title)) throw new Error('Enter a name of 1–200 characters on one line.');
|
|
1030
|
+
this.save({ ...worker, title, titleSource: 'custom', titleRequestId: undefined, titleRevision: randomUUID() });
|
|
1031
|
+
return this.snapshot(repoId);
|
|
1032
|
+
}
|
|
1033
|
+
if (action === 'refresh-title') {
|
|
1034
|
+
await this.refreshTitle(repoId, workerId);
|
|
1035
|
+
return this.snapshot(repoId);
|
|
1036
|
+
}
|
|
1037
|
+
if (['create', 'import', 'restore', 'setup'].includes(action) && this.store.get('deleted-workers', workerId))
|
|
1038
|
+
throw new Error('This worktree was deleted. Create a new worktree to continue.');
|
|
1039
|
+
if (['create', 'import', 'restore', 'archive', 'delete', 'setup'].includes(action) && (this.pending(workerId) || this.archiving.has(workerId)))
|
|
1040
|
+
throw new Error('A worktree archive or deletion is already pending. Wait for its result.');
|
|
322
1041
|
if (action === 'create') await this.create(repoId, workerId, command.title, command.brief);
|
|
323
1042
|
else if (action === 'import') {
|
|
324
1043
|
const previous = this.store.get<SavedWorker>('workers', workerId);
|
|
@@ -343,8 +1062,9 @@ export class WorkspaceRegistry {
|
|
|
343
1062
|
const frames = page.flatMap((r) => r.state.frames);
|
|
344
1063
|
const resume = [...frames].reverse().find((f) => typeof f.sessionId === 'string')?.sessionId;
|
|
345
1064
|
return { workers: [{ ...this.public(worker), ...(typeof resume === 'string' ? { resume } : {}) }],
|
|
1065
|
+
continuationProvider: worker.importContext?.provider,
|
|
346
1066
|
legacyMessages: command.before ? [] : worker.legacyMessages,
|
|
347
|
-
runs: this.historyRuns(page),
|
|
1067
|
+
runs: this.historyRuns(this.includeActive(page, worker.conversationId, command.before)),
|
|
348
1068
|
...(page.length === 10 ? { nextBefore: page[0]!.request.id } : {}) };
|
|
349
1069
|
}
|
|
350
1070
|
if (action === 'archive') {
|
|
@@ -368,13 +1088,16 @@ export class WorkspaceRegistry {
|
|
|
368
1088
|
this.checkRecoveryWorkspace(request);
|
|
369
1089
|
return request;
|
|
370
1090
|
}
|
|
1091
|
+
recoveryContext(requestId: string): RunReview | undefined {
|
|
1092
|
+
return this.store.get<RunReview>('run-reviews', requestId);
|
|
1093
|
+
}
|
|
371
1094
|
private checkRecoveryWorkspace(request: CodeTurnRequest) {
|
|
372
1095
|
if (!request.recoveryOf) return;
|
|
373
1096
|
const review = this.store.get<RunReview>('run-reviews', request.recoveryOf);
|
|
374
1097
|
const worker = request.workerId ? this.store.get<SavedWorker>('workers', request.workerId) : undefined;
|
|
375
1098
|
const path = !request.workerId && request.mode === 'in-place' ? this.repo(request.repoId).root :
|
|
376
|
-
sessionWorktreePath(request.repoId, this.baseDir, worker?.sessionCheckout ? undefined : request.workerId);
|
|
377
|
-
if (!review?.workspace || !existsSync(review.workspace) || !existsSync(path) || realpathSync(path) !== realpathSync(review.workspace))
|
|
1099
|
+
worker?.externalDesktop ? worker.path : sessionWorktreePath(request.repoId, this.baseDir, worker?.sessionCheckout ? undefined : request.workerId);
|
|
1100
|
+
if (!review?.workspace || !path || !existsSync(review.workspace) || !existsSync(path) || realpathSync(path) !== realpathSync(review.workspace))
|
|
378
1101
|
throw new Error('The configured workspace changed since this turn. Restore the reviewed workspace before continuing.');
|
|
379
1102
|
}
|
|
380
1103
|
}
|