@opencorelabs/lucidity 0.2.0 → 0.6.0
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 +36 -34
- package/bin/lucidity.js +2 -0
- package/dist/assets/speech/licenses/FluidAudio/LICENSE +201 -0
- package/dist/assets/speech/licenses/FluidAudio/ThirdPartyLicenses/fastcluster-LICENSE.md +11 -0
- package/dist/assets/speech/licenses/FluidAudio/ThirdPartyLicenses/vbx-LICENSE.md +201 -0
- package/dist/assets/speech/lucidity-speech +0 -0
- package/dist/automations/agent.d.ts +16 -0
- package/dist/automations/agent.d.ts.map +1 -0
- package/dist/automations/agent.js +196 -0
- package/dist/automations/cli.d.ts +4 -0
- package/dist/automations/cli.d.ts.map +1 -0
- package/dist/automations/cli.js +44 -0
- package/dist/automations/connections.d.ts +11 -0
- package/dist/automations/connections.d.ts.map +1 -0
- package/dist/automations/connections.js +74 -0
- package/dist/automations/designer.d.ts +39 -0
- package/dist/automations/designer.d.ts.map +1 -0
- package/dist/automations/designer.js +450 -0
- package/dist/automations/history.d.ts +4 -0
- package/dist/automations/history.d.ts.map +1 -0
- package/dist/automations/history.js +57 -0
- package/dist/automations/learning.d.ts +19 -0
- package/dist/automations/learning.d.ts.map +1 -0
- package/dist/automations/learning.js +121 -0
- package/dist/automations/pinterest.d.ts +21 -0
- package/dist/automations/pinterest.d.ts.map +1 -0
- package/dist/automations/pinterest.js +113 -0
- package/dist/automations/service.d.ts +42 -0
- package/dist/automations/service.d.ts.map +1 -0
- package/dist/automations/service.js +406 -0
- package/dist/automations/setup.d.ts +3 -0
- package/dist/automations/setup.d.ts.map +1 -0
- package/dist/automations/setup.js +48 -0
- package/dist/automations/skill.d.ts +3 -0
- package/dist/automations/skill.d.ts.map +1 -0
- package/dist/automations/skill.js +29 -0
- package/dist/automations/store.d.ts +13 -0
- package/dist/automations/store.d.ts.map +1 -0
- package/dist/automations/store.js +46 -0
- package/dist/chat/server.d.ts +2 -0
- package/dist/chat/server.d.ts.map +1 -1
- package/dist/chat/server.js +46 -2
- package/dist/coding/commandContext.d.ts +6 -0
- package/dist/coding/commandContext.d.ts.map +1 -0
- package/dist/coding/commandContext.js +20 -0
- package/dist/coding/runCodeTurn.d.ts +12 -2
- package/dist/coding/runCodeTurn.d.ts.map +1 -1
- package/dist/coding/runCodeTurn.js +49 -19
- package/dist/coding/worktree.d.ts +3 -4
- package/dist/coding/worktree.d.ts.map +1 -1
- package/dist/coding/worktree.js +3 -4
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +21 -3
- package/dist/decisions/cli.d.ts +2 -0
- package/dist/decisions/cli.d.ts.map +1 -0
- package/dist/decisions/cli.js +106 -0
- package/dist/decisions/client.d.ts +20 -0
- package/dist/decisions/client.d.ts.map +1 -0
- package/dist/decisions/client.js +41 -0
- package/dist/handoff.d.ts +11 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +21 -0
- package/dist/index.js +190 -34
- package/dist/jobs/briefing.js +1 -1
- package/dist/jobs/extraction.d.ts.map +1 -1
- package/dist/jobs/extraction.js +112 -22
- package/dist/jobs/fastModeReview.d.ts +39 -0
- package/dist/jobs/fastModeReview.d.ts.map +1 -0
- package/dist/jobs/fastModeReview.js +192 -0
- package/dist/jobs/voiceReview.d.ts +24 -0
- package/dist/jobs/voiceReview.d.ts.map +1 -0
- package/dist/jobs/voiceReview.js +128 -0
- package/dist/mcp/clients.d.ts +26 -0
- package/dist/mcp/clients.d.ts.map +1 -0
- package/dist/mcp/clients.js +193 -0
- package/dist/mcp/config.d.ts +5 -2
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +48 -6
- package/dist/mcp/paired.d.ts +2 -0
- package/dist/mcp/paired.d.ts.map +1 -0
- package/dist/mcp/paired.js +21 -0
- package/dist/mcp/pairedConfig.d.ts +3 -0
- package/dist/mcp/pairedConfig.d.ts.map +1 -0
- package/dist/mcp/pairedConfig.js +33 -0
- package/dist/notesContext.d.ts.map +1 -1
- package/dist/notesContext.js +3 -2
- package/dist/room/client.d.ts +20 -7
- package/dist/room/client.d.ts.map +1 -1
- package/dist/room/client.js +262 -45
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +8 -0
- package/dist/room/context.d.ts +3 -2
- package/dist/room/context.d.ts.map +1 -1
- package/dist/room/context.js +10 -3
- package/dist/room/turnQueue.d.ts +40 -0
- package/dist/room/turnQueue.d.ts.map +1 -0
- package/dist/room/turnQueue.js +301 -0
- package/dist/setup/page.d.ts +3 -0
- package/dist/setup/page.d.ts.map +1 -0
- package/dist/setup/page.js +120 -0
- package/dist/setup/server.d.ts +26 -0
- package/dist/setup/server.d.ts.map +1 -0
- package/dist/setup/server.js +398 -0
- package/dist/skills/lucidity-automations/SKILL.md +54 -0
- package/dist/speech/captures.d.ts +30 -0
- package/dist/speech/captures.d.ts.map +1 -0
- package/dist/speech/captures.js +209 -0
- package/dist/speech/fluidAudio.d.ts +28 -0
- package/dist/speech/fluidAudio.d.ts.map +1 -0
- package/dist/speech/fluidAudio.js +182 -0
- package/dist/speech/service.d.ts +14 -0
- package/dist/speech/service.d.ts.map +1 -0
- package/dist/speech/service.js +88 -0
- package/dist/speech/types.d.ts +19 -0
- package/dist/speech/types.d.ts.map +1 -0
- package/dist/speech/types.js +1 -0
- package/dist/turnLog.d.ts +1 -0
- package/dist/turnLog.d.ts.map +1 -1
- package/dist/turnLog.js +3 -0
- package/native/speech/Package.resolved +15 -0
- package/native/speech/Package.swift +16 -0
- package/native/speech/Sources/lucidity-speech/Speech.swift +81 -0
- package/package.json +6 -2
- package/src/automations/agent.ts +239 -0
- package/src/automations/cli.ts +52 -0
- package/src/automations/connections.ts +83 -0
- package/src/automations/designer.ts +594 -0
- package/src/automations/history.ts +59 -0
- package/src/automations/learning.ts +180 -0
- package/src/automations/pinterest.ts +146 -0
- package/src/automations/service.ts +505 -0
- package/src/automations/setup.ts +71 -0
- package/src/automations/skill.ts +40 -0
- package/src/automations/store.ts +63 -0
- package/src/chat/server.ts +62 -3
- package/src/coding/commandContext.ts +29 -0
- package/src/coding/runCodeTurn.ts +65 -21
- package/src/coding/worktree.ts +3 -4
- package/src/config.ts +32 -2
- package/src/decisions/cli.ts +136 -0
- package/src/decisions/client.ts +62 -0
- package/src/handoff.ts +28 -0
- package/src/index.ts +204 -58
- package/src/jobs/briefing.ts +1 -1
- package/src/jobs/extraction.ts +157 -32
- package/src/jobs/fastModeReview.ts +221 -0
- package/src/jobs/voiceReview.ts +156 -0
- package/src/mcp/clients.ts +269 -0
- package/src/mcp/config.ts +58 -7
- package/src/mcp/paired.ts +23 -0
- package/src/mcp/pairedConfig.ts +44 -0
- package/src/notesContext.ts +3 -2
- package/src/room/client.ts +316 -52
- package/src/room/computer.ts +8 -0
- package/src/room/context.ts +12 -3
- package/src/room/turnQueue.ts +358 -0
- package/src/setup/page.ts +122 -0
- package/src/setup/server.ts +483 -0
- package/src/speech/captures.ts +265 -0
- package/src/speech/fluidAudio.ts +242 -0
- package/src/speech/service.ts +108 -0
- package/src/speech/types.ts +13 -0
- package/src/turnLog.ts +4 -0
- package/vendor/decisions/LICENSE +662 -0
- package/vendor/decisions/dist/capture.d.ts +79 -0
- package/vendor/decisions/dist/capture.js +183 -0
- package/vendor/decisions/dist/command.d.ts +202 -0
- package/vendor/decisions/dist/command.js +750 -0
- package/vendor/decisions/dist/gate.d.ts +12 -0
- package/vendor/decisions/dist/gate.js +18 -0
- package/vendor/decisions/dist/index.d.ts +5 -0
- package/vendor/decisions/dist/index.js +5 -0
- package/vendor/decisions/dist/jev.d.ts +15 -0
- package/vendor/decisions/dist/jev.js +242 -0
- package/vendor/decisions/dist/types.d.ts +67 -0
- package/vendor/decisions/dist/types.js +1 -0
- package/vendor/decisions/package.json +22 -0
- package/vendor/decisions/src/capture.ts +199 -0
- package/vendor/decisions/src/command.ts +836 -0
- package/vendor/decisions/src/gate.ts +32 -0
- package/vendor/decisions/src/index.ts +5 -0
- package/vendor/decisions/src/jev.ts +293 -0
- package/vendor/decisions/src/types.ts +79 -0
- package/vendor/mcp-server/README.md +130 -48
- package/vendor/mcp-server/dist/client.d.ts +1 -0
- package/vendor/mcp-server/dist/client.d.ts.map +1 -1
- package/vendor/mcp-server/dist/client.js +8 -0
- package/vendor/mcp-server/dist/commentProvider.d.ts +3 -0
- package/vendor/mcp-server/dist/commentProvider.d.ts.map +1 -0
- package/vendor/mcp-server/dist/commentProvider.js +10 -0
- package/vendor/mcp-server/dist/index.js +26 -5
- package/vendor/mcp-server/dist/tools/automations.d.ts +6 -0
- package/vendor/mcp-server/dist/tools/automations.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/automations.js +163 -0
- package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts +52 -0
- package/vendor/mcp-server/dist/tools/commandEventFormat.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/commandEventFormat.js +83 -0
- package/vendor/mcp-server/dist/tools/commandEvents.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/commandEvents.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/commandEvents.js +21 -0
- package/vendor/mcp-server/dist/tools/comments.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/comments.js +41 -5
- package/vendor/mcp-server/dist/tools/index.d.ts +2 -0
- package/vendor/mcp-server/dist/tools/index.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/index.js +2 -0
- package/vendor/mcp-server/dist/tools/journal.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/journal.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/journal.js +131 -0
- package/vendor/mcp-server/dist/tools/memory.d.ts +2 -2
- package/vendor/mcp-server/dist/tools/memory.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/memory.js +24 -14
- package/vendor/mcp-server/dist/tools/milestones.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/milestones.js +30 -0
- package/vendor/mcp-server/dist/tools/notes.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/notes.js +30 -5
- package/vendor/mcp-server/dist/tools/projects.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/projects.js +15 -0
- package/vendor/mcp-server/dist/tools/queries.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/queries.js +27 -2
- package/vendor/mcp-server/dist/tools/taskActivity.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/taskActivity.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/taskActivity.js +32 -0
- package/vendor/mcp-server/dist/tools/taskOccurrences.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/taskOccurrences.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/taskOccurrences.js +12 -0
- package/vendor/mcp-server/dist/tools/taskTrash.d.ts +3 -0
- package/vendor/mcp-server/dist/tools/taskTrash.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/taskTrash.js +21 -0
- package/vendor/mcp-server/dist/tools/tasks.d.ts.map +1 -1
- package/vendor/mcp-server/dist/tools/tasks.js +99 -22
- package/vendor/mcp-server/package.json +5 -1
- package/vendor/mcp-server/src/client.ts +10 -0
- package/vendor/mcp-server/src/commentProvider.ts +9 -0
- package/vendor/mcp-server/src/index.ts +33 -6
- package/vendor/mcp-server/src/tools/automations.ts +199 -0
- package/vendor/mcp-server/src/tools/commandEventFormat.ts +108 -0
- package/vendor/mcp-server/src/tools/commandEvents.ts +27 -0
- package/vendor/mcp-server/src/tools/comments.ts +43 -4
- package/vendor/mcp-server/src/tools/index.ts +2 -0
- package/vendor/mcp-server/src/tools/journal.ts +168 -0
- package/vendor/mcp-server/src/tools/memory.ts +26 -12
- package/vendor/mcp-server/src/tools/milestones.ts +36 -0
- package/vendor/mcp-server/src/tools/notes.ts +35 -4
- package/vendor/mcp-server/src/tools/projects.ts +18 -0
- package/vendor/mcp-server/src/tools/queries.ts +30 -0
- package/vendor/mcp-server/src/tools/taskActivity.ts +55 -0
- package/vendor/mcp-server/src/tools/taskOccurrences.ts +26 -0
- package/vendor/mcp-server/src/tools/taskTrash.ts +23 -0
- package/vendor/mcp-server/src/tools/tasks.ts +104 -24
- package/vendor/notes/dist/index.d.ts +2 -0
- package/vendor/notes/dist/index.d.ts.map +1 -1
- package/vendor/notes/dist/index.js +2 -0
- package/vendor/notes/dist/journal-backend.d.ts +4 -0
- package/vendor/notes/dist/journal-backend.d.ts.map +1 -0
- package/vendor/notes/dist/journal-backend.js +33 -0
- package/vendor/notes/dist/journal.d.ts +7 -0
- package/vendor/notes/dist/journal.d.ts.map +1 -0
- package/vendor/notes/dist/journal.js +173 -0
- package/vendor/notes/dist/vault.d.ts.map +1 -1
- package/vendor/notes/dist/vault.js +6 -1
- package/vendor/notes/src/index.ts +2 -0
- package/vendor/notes/src/journal-backend.ts +53 -0
- package/vendor/notes/src/journal.ts +194 -0
- package/vendor/notes/src/vault.ts +9 -1
- package/vendor/runtime/README.md +4 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts +2 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.js +113 -8
- package/vendor/runtime/dist/executor/claudeCode.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeCode.js +8 -4
- package/vendor/runtime/dist/executor/codex.d.ts +2 -0
- package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codex.js +213 -11
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CreditsSnapshot.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +26 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitReachedType.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.d.ts +27 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCredit.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditStatus.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.d.ts +13 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetCreditsSummary.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitResetType.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +20 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitWindow.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewDelivery.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +12 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.d.ts +17 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewTarget.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillDependencies.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillErrorInfo.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.d.ts +18 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillInterface.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.d.ts +22 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillMetadata.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillScope.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.d.ts +9 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillToolDependency.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListEntry.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SkillsListResponse.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.d.ts +7 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/SpendControlLimitSnapshot.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadSetNameParams.js +2 -0
- package/vendor/runtime/dist/executor/health.d.ts +1 -0
- package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/health.js +3 -0
- package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/liveTurns.js +3 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/providerRouter.js +2 -1
- package/vendor/runtime/dist/executor/types.d.ts +8 -0
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.d.ts +1 -0
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +35 -1
- package/vendor/runtime/dist/harness/types.d.ts +4 -1
- package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
- package/vendor/runtime/dist/index.d.ts +2 -1
- package/vendor/runtime/dist/index.d.ts.map +1 -1
- package/vendor/runtime/dist/index.js +2 -0
- package/vendor/runtime/dist/journal/context.d.ts +18 -0
- package/vendor/runtime/dist/journal/context.d.ts.map +1 -1
- package/vendor/runtime/dist/journal/context.js +19 -5
- package/vendor/runtime/dist/prompts/briefing.d.ts +4 -7
- package/vendor/runtime/dist/prompts/briefing.d.ts.map +1 -1
- package/vendor/runtime/dist/prompts/briefing.js +61 -12
- package/vendor/runtime/dist/prompts/cardStatement.d.ts +7 -0
- package/vendor/runtime/dist/prompts/cardStatement.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/cardStatement.js +52 -0
- package/vendor/runtime/dist/prompts/chat.d.ts +1 -0
- package/vendor/runtime/dist/prompts/chat.d.ts.map +1 -1
- package/vendor/runtime/dist/prompts/chat.js +15 -1
- package/vendor/runtime/dist/prompts/projectCapture.d.ts +7 -0
- package/vendor/runtime/dist/prompts/projectCapture.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/projectCapture.js +31 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +133 -7
- package/vendor/runtime/src/executor/claudeCode.ts +6 -4
- package/vendor/runtime/src/executor/codex.ts +280 -20
- package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/CreditsSnapshot.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +25 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitReachedType.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCredit.ts +27 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCreditStatus.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetCreditsSummary.ts +14 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitResetType.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +14 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitWindow.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewDelivery.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +12 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewTarget.ts +9 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillDependencies.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillErrorInfo.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillInterface.ts +14 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillMetadata.ts +17 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillScope.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillToolDependency.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillsListEntry.ts +7 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SkillsListResponse.ts +6 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/SpendControlLimitSnapshot.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadSetNameParams.ts +5 -0
- package/vendor/runtime/src/executor/health.ts +3 -0
- package/vendor/runtime/src/executor/liveTurns.ts +3 -0
- package/vendor/runtime/src/executor/providerRouter.ts +2 -1
- package/vendor/runtime/src/executor/types.ts +8 -0
- package/vendor/runtime/src/harness/index.ts +40 -6
- package/vendor/runtime/src/harness/types.ts +4 -1
- package/vendor/runtime/src/index.ts +4 -1
- package/vendor/runtime/src/journal/context.ts +40 -7
- package/vendor/runtime/src/prompts/briefing.ts +62 -17
- package/vendor/runtime/src/prompts/cardStatement.ts +64 -0
- package/vendor/runtime/src/prompts/chat.ts +25 -3
- package/vendor/runtime/src/prompts/projectCapture.ts +51 -0
- package/vendor/shared/dist/agentCommands.d.ts +22 -0
- package/vendor/shared/dist/agentCommands.d.ts.map +1 -0
- package/vendor/shared/dist/agentCommands.js +11 -0
- package/vendor/shared/dist/automationTemplates.d.ts +37 -0
- package/vendor/shared/dist/automationTemplates.d.ts.map +1 -0
- package/vendor/shared/dist/automationTemplates.js +48 -0
- package/vendor/shared/dist/automations.d.ts +1052 -0
- package/vendor/shared/dist/automations.d.ts.map +1 -0
- package/vendor/shared/dist/automations.js +300 -0
- package/vendor/shared/dist/brandArtwork.d.ts +4 -0
- package/vendor/shared/dist/brandArtwork.d.ts.map +1 -0
- package/vendor/shared/dist/brandArtwork.js +7 -0
- package/vendor/shared/dist/cardStatement.d.ts +28 -0
- package/vendor/shared/dist/cardStatement.d.ts.map +1 -0
- package/vendor/shared/dist/cardStatement.js +37 -0
- package/vendor/shared/dist/cardStudio.d.ts +756 -0
- package/vendor/shared/dist/cardStudio.d.ts.map +1 -0
- package/vendor/shared/dist/cardStudio.js +297 -0
- package/vendor/shared/dist/commandLocal.d.ts +218 -0
- package/vendor/shared/dist/commandLocal.d.ts.map +1 -0
- package/vendor/shared/dist/commandLocal.js +662 -0
- package/vendor/shared/dist/commandText.d.ts +12 -0
- package/vendor/shared/dist/commandText.d.ts.map +1 -0
- package/vendor/shared/dist/commandText.js +21 -0
- package/vendor/shared/dist/commands.d.ts +1516 -0
- package/vendor/shared/dist/commands.d.ts.map +1 -0
- package/vendor/shared/dist/commands.js +231 -0
- package/vendor/shared/dist/computer.d.ts +9 -9
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +11 -2
- package/vendor/shared/dist/constants.d.ts +3 -3
- package/vendor/shared/dist/constants.d.ts.map +1 -1
- package/vendor/shared/dist/constants.js +9 -2
- package/vendor/shared/dist/githubContributions.d.ts +93 -0
- package/vendor/shared/dist/githubContributions.d.ts.map +1 -0
- package/vendor/shared/dist/githubContributions.js +54 -0
- package/vendor/shared/dist/habitContributions.d.ts +26 -0
- package/vendor/shared/dist/habitContributions.d.ts.map +1 -0
- package/vendor/shared/dist/habitContributions.js +119 -0
- package/vendor/shared/dist/index.d.ts +26 -1
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +23 -1
- package/vendor/shared/dist/journal-migration.d.ts +29 -0
- package/vendor/shared/dist/journal-migration.d.ts.map +1 -0
- package/vendor/shared/dist/journal-migration.js +73 -0
- package/vendor/shared/dist/journal-vault.d.ts +414 -0
- package/vendor/shared/dist/journal-vault.d.ts.map +1 -0
- package/vendor/shared/dist/journal-vault.js +972 -0
- package/vendor/shared/dist/projectCapture.d.ts +73 -0
- package/vendor/shared/dist/projectCapture.d.ts.map +1 -0
- package/vendor/shared/dist/projectCapture.js +66 -0
- package/vendor/shared/dist/quickAdd.d.ts +90 -0
- package/vendor/shared/dist/quickAdd.d.ts.map +1 -0
- package/vendor/shared/dist/quickAdd.js +260 -0
- package/vendor/shared/dist/recurrence.d.ts +44 -0
- package/vendor/shared/dist/recurrence.d.ts.map +1 -0
- package/vendor/shared/dist/recurrence.js +37 -0
- package/vendor/shared/dist/reminderWords.d.ts +11 -0
- package/vendor/shared/dist/reminderWords.d.ts.map +1 -0
- package/vendor/shared/dist/reminderWords.js +63 -0
- package/vendor/shared/dist/schemas/comment.d.ts +13 -1
- package/vendor/shared/dist/schemas/comment.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/comment.js +5 -0
- package/vendor/shared/dist/schemas/conversation.d.ts +3 -3
- package/vendor/shared/dist/schemas/harness.d.ts +922 -59
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +122 -3
- package/vendor/shared/dist/schemas/journal.d.ts +10 -0
- package/vendor/shared/dist/schemas/journal.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/journal.js +10 -2
- package/vendor/shared/dist/schemas/notification.d.ts +1 -1
- package/vendor/shared/dist/schemas/organization.d.ts +3 -2
- package/vendor/shared/dist/schemas/organization.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/organization.js +3 -2
- package/vendor/shared/dist/schemas/proposal.d.ts +7 -3
- package/vendor/shared/dist/schemas/proposal.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/proposal.js +2 -1
- package/vendor/shared/dist/schemas/request.d.ts +44 -4
- package/vendor/shared/dist/schemas/request.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/task.d.ts +83 -8
- package/vendor/shared/dist/schemas/task.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/task.js +20 -2
- package/vendor/shared/dist/schemas/timeSession.d.ts +2 -2
- package/vendor/shared/dist/setupAppearance.d.ts +6 -0
- package/vendor/shared/dist/setupAppearance.d.ts.map +1 -0
- package/vendor/shared/dist/setupAppearance.js +17 -0
- package/vendor/shared/dist/smartCapture.d.ts +60 -0
- package/vendor/shared/dist/smartCapture.d.ts.map +1 -0
- package/vendor/shared/dist/smartCapture.js +56 -0
- package/vendor/shared/dist/speech.d.ts +39 -0
- package/vendor/shared/dist/speech.d.ts.map +1 -0
- package/vendor/shared/dist/speech.js +36 -0
- package/vendor/shared/dist/spokenNames.d.ts +25 -0
- package/vendor/shared/dist/spokenNames.d.ts.map +1 -0
- package/vendor/shared/dist/spokenNames.js +120 -0
- package/vendor/shared/dist/taskActivity.d.ts +76 -0
- package/vendor/shared/dist/taskActivity.d.ts.map +1 -0
- package/vendor/shared/dist/taskActivity.js +27 -0
- package/vendor/shared/dist/vault-search.d.ts +50 -0
- package/vendor/shared/dist/vault-search.d.ts.map +1 -0
- package/vendor/shared/dist/vault-search.js +177 -0
- package/vendor/shared/dist/voiceCapture.d.ts +32 -0
- package/vendor/shared/dist/voiceCapture.d.ts.map +1 -0
- package/vendor/shared/dist/voiceCapture.js +29 -0
- package/vendor/shared/package.json +4 -0
- package/vendor/shared/src/agentCommands.ts +35 -0
- package/vendor/shared/src/automationTemplates.ts +54 -0
- package/vendor/shared/src/automations.ts +329 -0
- package/vendor/shared/src/brandArtwork.ts +7 -0
- package/vendor/shared/src/cardStatement.ts +49 -0
- package/vendor/shared/src/cardStudio.ts +340 -0
- package/vendor/shared/src/commandLocal.ts +738 -0
- package/vendor/shared/src/commandText.ts +25 -0
- package/vendor/shared/src/commands.ts +253 -0
- package/vendor/shared/src/computer.ts +23 -6
- package/vendor/shared/src/constants.ts +9 -2
- package/vendor/shared/src/githubContributions.ts +70 -0
- package/vendor/shared/src/habitContributions.ts +144 -0
- package/vendor/shared/src/index.ts +42 -0
- package/vendor/shared/src/journal-migration.ts +130 -0
- package/vendor/shared/src/journal-vault.ts +1240 -0
- package/vendor/shared/src/projectCapture.ts +86 -0
- package/vendor/shared/src/quickAdd.ts +310 -0
- package/vendor/shared/src/recurrence.ts +37 -0
- package/vendor/shared/src/reminderWords.ts +54 -0
- package/vendor/shared/src/schemas/comment.ts +5 -0
- package/vendor/shared/src/schemas/harness.ts +144 -7
- package/vendor/shared/src/schemas/journal.ts +15 -6
- package/vendor/shared/src/schemas/organization.ts +3 -2
- package/vendor/shared/src/schemas/proposal.ts +6 -1
- package/vendor/shared/src/schemas/task.ts +20 -2
- package/vendor/shared/src/setupAppearance.ts +32 -0
- package/vendor/shared/src/smartCapture.ts +67 -0
- package/vendor/shared/src/speech.ts +44 -0
- package/vendor/shared/src/spokenNames.ts +128 -0
- package/vendor/shared/src/taskActivity.ts +34 -0
- package/vendor/shared/src/vault-search.ts +243 -0
- package/vendor/shared/src/voiceCapture.ts +34 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync, statSync, unlinkSync, } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { HarnessRequestSchema } from '@lucidity/shared';
|
|
4
|
+
export function turnLane(req) {
|
|
5
|
+
return req.kind === 'ask'
|
|
6
|
+
? 'room:ask'
|
|
7
|
+
: `room:code:${req.repoId}${req.workerId ? `:${req.workerId}` : ''}`;
|
|
8
|
+
}
|
|
9
|
+
/** Persist before acknowledgement, resolve continuity on the computer, and never replay
|
|
10
|
+
* an execution whose outcome became uncertain. The socket only observes this queue. */
|
|
11
|
+
export class DurableTurnQueue {
|
|
12
|
+
deps;
|
|
13
|
+
entries = new Map();
|
|
14
|
+
scheduled = new Set();
|
|
15
|
+
stopped = false;
|
|
16
|
+
pumping = false;
|
|
17
|
+
constructor(deps) {
|
|
18
|
+
this.deps = deps;
|
|
19
|
+
mkdirSync(deps.dir, { recursive: true, mode: 0o700 });
|
|
20
|
+
for (const name of readdirSync(deps.dir)
|
|
21
|
+
.filter((name) => name.endsWith('.json'))
|
|
22
|
+
.sort()) {
|
|
23
|
+
const entry = JSON.parse(readFileSync(join(deps.dir, name), 'utf8'));
|
|
24
|
+
if (['done', 'failed', 'skipped'].includes(entry.state) &&
|
|
25
|
+
Date.now() - statSync(join(deps.dir, name)).mtimeMs > 24 * 60 * 60_000) {
|
|
26
|
+
unlinkSync(join(deps.dir, name));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const parsed = HarnessRequestSchema.parse(entry.request);
|
|
30
|
+
if (parsed.kind !== 'ask' && parsed.kind !== 'code')
|
|
31
|
+
throw new Error('Invalid queued turn');
|
|
32
|
+
entry.request = parsed;
|
|
33
|
+
this.entries.set(parsed.id, entry);
|
|
34
|
+
const terminal = this.terminal(parsed.id);
|
|
35
|
+
if (entry.state === 'running' || entry.state === 'steering') {
|
|
36
|
+
if (terminal?.type === 'done') {
|
|
37
|
+
this.save({
|
|
38
|
+
...entry,
|
|
39
|
+
state: 'done',
|
|
40
|
+
resume: this.session(parsed.id),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.fail(entry, 'Lucid restarted during this turn. It was not run again. Review the result before resending.');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (entry.state === 'skipped' && !terminal) {
|
|
48
|
+
this.publish(parsed.id, {
|
|
49
|
+
type: 'cancelled',
|
|
50
|
+
queueAction: entry.action,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else if (entry.state === 'failed' && !terminal) {
|
|
54
|
+
this.publish(parsed.id, {
|
|
55
|
+
type: 'error',
|
|
56
|
+
message: 'This queued turn could not finish. Review it before resending.',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const entry of this.entries.values()) {
|
|
61
|
+
const previous = entry.request.afterRequestId;
|
|
62
|
+
if (entry.state === 'queued' &&
|
|
63
|
+
previous &&
|
|
64
|
+
!this.entries.has(previous) &&
|
|
65
|
+
!this.terminal(previous))
|
|
66
|
+
this.fail(entry, 'Lucid restarted before the preceding turn finished. Review it before resending this message.');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
save(entry) {
|
|
70
|
+
const path = join(this.deps.dir, `${entry.request.id}.json`);
|
|
71
|
+
writeFileSync(`${path}.tmp`, JSON.stringify(entry), {
|
|
72
|
+
mode: 0o600,
|
|
73
|
+
flush: true,
|
|
74
|
+
});
|
|
75
|
+
renameSync(`${path}.tmp`, path);
|
|
76
|
+
this.entries.set(entry.request.id, entry);
|
|
77
|
+
}
|
|
78
|
+
publish(id, event) {
|
|
79
|
+
const frame = this.deps.logs.append(id, { ...event, requestId: id });
|
|
80
|
+
if (!this.deps.logs.read(id).frames.some((saved) => saved.seq === frame.seq))
|
|
81
|
+
throw new Error('Could not save the queue receipt on this computer.');
|
|
82
|
+
this.deps.sendRaw(frame);
|
|
83
|
+
}
|
|
84
|
+
terminal(id) {
|
|
85
|
+
return this.deps.logs
|
|
86
|
+
.read(id)
|
|
87
|
+
.frames.slice()
|
|
88
|
+
.reverse()
|
|
89
|
+
.find((frame) => ['done', 'error', 'cancelled'].includes(String(frame.type)));
|
|
90
|
+
}
|
|
91
|
+
session(id) {
|
|
92
|
+
const frames = this.deps.logs.read(id).frames;
|
|
93
|
+
const value = frames
|
|
94
|
+
.slice()
|
|
95
|
+
.reverse()
|
|
96
|
+
.find((frame) => typeof frame.sessionId === 'string')?.sessionId;
|
|
97
|
+
return typeof value === 'string' ? value : undefined;
|
|
98
|
+
}
|
|
99
|
+
fail(entry, message) {
|
|
100
|
+
this.save({ ...entry, state: 'failed' });
|
|
101
|
+
if (!this.deps.logs.read(entry.request.id).terminated)
|
|
102
|
+
this.publish(entry.request.id, { type: 'error', message });
|
|
103
|
+
this.wake();
|
|
104
|
+
}
|
|
105
|
+
owns(id) {
|
|
106
|
+
const state = this.entries.get(id)?.state;
|
|
107
|
+
return state === 'queued' || state === 'running' || state === 'steering';
|
|
108
|
+
}
|
|
109
|
+
confirm(id) {
|
|
110
|
+
const entry = this.entries.get(id);
|
|
111
|
+
if (entry && this.owns(id))
|
|
112
|
+
this.publish(id, {
|
|
113
|
+
type: 'queue_state',
|
|
114
|
+
state: entry.state === 'running' ? 'running' : 'queued',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
enqueue(request) {
|
|
118
|
+
if (!request.stream)
|
|
119
|
+
throw new Error('Queued turns require streaming replies.');
|
|
120
|
+
const existing = this.entries.get(request.id);
|
|
121
|
+
if (existing) {
|
|
122
|
+
if (JSON.stringify(existing.request) !== JSON.stringify(request))
|
|
123
|
+
throw new Error('Request ID already belongs to another message.');
|
|
124
|
+
for (const frame of this.deps.logs.read(request.id).frames)
|
|
125
|
+
this.deps.sendRaw(frame);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (this.deps.logs.read(request.id).exists)
|
|
129
|
+
throw new Error('This request was already submitted.');
|
|
130
|
+
if ([...this.entries.values()].filter((e) => this.owns(e.request.id))
|
|
131
|
+
.length >= 100)
|
|
132
|
+
throw new Error('The computer queue is full. Wait for some messages to finish.');
|
|
133
|
+
if (request.afterRequestId) {
|
|
134
|
+
const previous = this.entries.get(request.afterRequestId)?.request;
|
|
135
|
+
const receipt = this.deps.logs
|
|
136
|
+
.read(request.afterRequestId)
|
|
137
|
+
.frames.find((frame) => frame.type === 'accepted');
|
|
138
|
+
const scope = previous ?? receipt?.scope;
|
|
139
|
+
const same = scope &&
|
|
140
|
+
(request.kind === 'ask'
|
|
141
|
+
? scope.kind === 'ask'
|
|
142
|
+
: (scope.kind === 'code' &&
|
|
143
|
+
scope.repoId === request.repoId &&
|
|
144
|
+
scope.workerId === request.workerId &&
|
|
145
|
+
(scope.mode ?? 'worktree') === (request.mode ?? 'worktree')) ||
|
|
146
|
+
(scope.kind === 'conduct' &&
|
|
147
|
+
scope.repoId === request.repoId &&
|
|
148
|
+
!!request.workerId));
|
|
149
|
+
if (!same)
|
|
150
|
+
throw new Error('The preceding turn does not belong to this conversation. Refresh it before sending again.');
|
|
151
|
+
}
|
|
152
|
+
const entry = { request, state: 'queued' };
|
|
153
|
+
this.save(entry);
|
|
154
|
+
try {
|
|
155
|
+
this.publish(request.id, { type: 'queue_state', state: 'queued' });
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
this.save({ ...entry, state: 'failed' });
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
this.wake();
|
|
162
|
+
}
|
|
163
|
+
/** Skipped queue entries inherit their predecessor, so removing B from A→B→C
|
|
164
|
+
* never starts a new conversation or strands C. Failed executions stop dependants. */
|
|
165
|
+
predecessor(entry) {
|
|
166
|
+
const id = entry.request.afterRequestId;
|
|
167
|
+
if (!id)
|
|
168
|
+
return { ready: true, resume: entry.request.resume };
|
|
169
|
+
const previous = this.entries.get(id);
|
|
170
|
+
if (previous) {
|
|
171
|
+
if (previous.state === 'skipped')
|
|
172
|
+
return this.predecessor(previous);
|
|
173
|
+
if (previous.state === 'failed')
|
|
174
|
+
throw new Error('The previous turn did not finish. Review it before resending this message.');
|
|
175
|
+
if (previous.state !== 'done')
|
|
176
|
+
return { ready: false };
|
|
177
|
+
if (!previous.resume)
|
|
178
|
+
throw new Error('The previous turn has no session to continue. Start a new conversation.');
|
|
179
|
+
return { ready: true, resume: previous.resume };
|
|
180
|
+
}
|
|
181
|
+
const terminal = this.terminal(id);
|
|
182
|
+
if (!terminal)
|
|
183
|
+
return { ready: false };
|
|
184
|
+
if (terminal.type !== 'done')
|
|
185
|
+
throw new Error('The previous turn did not finish. Review it before resending this message.');
|
|
186
|
+
const receipt = this.deps.logs
|
|
187
|
+
.read(id)
|
|
188
|
+
.frames.find((frame) => frame.type === 'accepted');
|
|
189
|
+
const scope = receipt?.scope;
|
|
190
|
+
const source = scope?.kind === 'conduct' && entry.request.kind === 'code'
|
|
191
|
+
? entry.request.workerId
|
|
192
|
+
: id;
|
|
193
|
+
if (source !== id && this.terminal(source)?.type !== 'done')
|
|
194
|
+
throw new Error('The worker did not finish. Review it before resending this message.');
|
|
195
|
+
const resume = this.session(source);
|
|
196
|
+
if (!resume)
|
|
197
|
+
throw new Error('The previous turn has no session to continue. Start a new conversation.');
|
|
198
|
+
return { ready: true, resume };
|
|
199
|
+
}
|
|
200
|
+
wake() {
|
|
201
|
+
if (this.stopped || this.pumping)
|
|
202
|
+
return;
|
|
203
|
+
this.pumping = true;
|
|
204
|
+
queueMicrotask(() => {
|
|
205
|
+
this.pumping = false;
|
|
206
|
+
if (this.stopped)
|
|
207
|
+
return;
|
|
208
|
+
const occupied = new Set();
|
|
209
|
+
for (const [id, entry] of this.entries) {
|
|
210
|
+
const lane = turnLane(entry.request);
|
|
211
|
+
if (!this.owns(id))
|
|
212
|
+
continue;
|
|
213
|
+
if (occupied.has(lane))
|
|
214
|
+
continue;
|
|
215
|
+
occupied.add(lane);
|
|
216
|
+
if (entry.state !== 'queued' || this.scheduled.has(id))
|
|
217
|
+
continue;
|
|
218
|
+
try {
|
|
219
|
+
if (!this.predecessor(entry).ready)
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
this.fail(entry, String(error.message));
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
this.scheduled.add(id);
|
|
227
|
+
void this.deps.lanes
|
|
228
|
+
.run(turnLane(entry.request), async () => {
|
|
229
|
+
const current = this.entries.get(id);
|
|
230
|
+
if (this.stopped || current.state !== 'queued')
|
|
231
|
+
return;
|
|
232
|
+
const previous = this.predecessor(current);
|
|
233
|
+
if (!previous.ready)
|
|
234
|
+
return;
|
|
235
|
+
this.save({ ...current, state: 'running' });
|
|
236
|
+
this.publish(id, { type: 'queue_state', state: 'running' });
|
|
237
|
+
await this.deps.execute({
|
|
238
|
+
...current.request,
|
|
239
|
+
resume: previous.resume,
|
|
240
|
+
queue: false,
|
|
241
|
+
afterRequestId: undefined,
|
|
242
|
+
});
|
|
243
|
+
if (this.terminal(id)?.type === 'done')
|
|
244
|
+
this.save({
|
|
245
|
+
...current,
|
|
246
|
+
state: 'done',
|
|
247
|
+
resume: this.session(id),
|
|
248
|
+
});
|
|
249
|
+
else
|
|
250
|
+
this.fail(current, 'The turn ended before completion. Review it before resending.');
|
|
251
|
+
})
|
|
252
|
+
.catch((error) => this.fail(this.entries.get(id), String(error.message)))
|
|
253
|
+
.finally(() => {
|
|
254
|
+
this.scheduled.delete(id);
|
|
255
|
+
this.wake();
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
async control(id, action, activeId) {
|
|
261
|
+
const entry = this.entries.get(id);
|
|
262
|
+
if (!entry)
|
|
263
|
+
throw new Error('This message is not in the computer queue.');
|
|
264
|
+
if (entry.state === 'skipped' && entry.action === action) {
|
|
265
|
+
const frame = this.terminal(id);
|
|
266
|
+
if (frame)
|
|
267
|
+
this.deps.sendRaw(frame);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (entry.state !== 'queued')
|
|
271
|
+
throw new Error('This message has already started or left the queue.');
|
|
272
|
+
if (action === 'steer') {
|
|
273
|
+
if (entry.request.images?.length)
|
|
274
|
+
throw new Error('Attachments must run as a separate turn.');
|
|
275
|
+
if (!activeId || !this.deps.steer)
|
|
276
|
+
throw new Error('There is no active turn to influence.');
|
|
277
|
+
const active = this.entries.get(activeId);
|
|
278
|
+
// For a spawned fleet worker, the active request uses the worker's own ID.
|
|
279
|
+
if (active
|
|
280
|
+
? turnLane(active.request) !== turnLane(entry.request) ||
|
|
281
|
+
active.state !== 'running'
|
|
282
|
+
: entry.request.kind !== 'code' || entry.request.workerId !== activeId)
|
|
283
|
+
throw new Error('The active turn does not belong to this conversation.');
|
|
284
|
+
this.save({ ...entry, state: 'steering' });
|
|
285
|
+
try {
|
|
286
|
+
await this.deps.steer(activeId, entry.request.prompt);
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
this.save(entry);
|
|
290
|
+
this.wake();
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
this.save({ ...entry, state: 'skipped', action });
|
|
295
|
+
this.publish(id, { type: 'cancelled', queueAction: action });
|
|
296
|
+
this.wake();
|
|
297
|
+
}
|
|
298
|
+
stop() {
|
|
299
|
+
this.stopped = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const setupScript = "\nlet token = new URLSearchParams(location.hash.slice(1)).get('session');\nif (token) { sessionStorage.setItem('luciditySetupSession', token); history.replaceState(null, '', '/'); }\ntoken = token || sessionStorage.getItem('luciditySetupSession');\nconst content = document.getElementById('stage');\nconst error = document.getElementById('error');\nlet state = {}, selected = sessionStorage.getItem('luciditySetupProvider'), timer, busy = false, revision = 0;\nlet choices = {tasks:false, scheduledWork:false, clients:[]};\ntry { choices = {...choices, ...JSON.parse(sessionStorage.getItem('luciditySetupChoices') || '{}')}; } catch {}\nconst escape = s => String(s).replace(/[&<>\"']/g, c => ({'&':'&','<':'<','>':'>','\"':'"',\"'\":'''}[c]));\nfunction showError(e) { error.textContent = e.message || 'Something went wrong. Please try again.'; error.hidden = false; }\nasync function request(path, body) {\n const response = await fetch('/api/' + path, {method:'POST',headers:{'Content-Type':'application/json','X-Setup-Token':token || ''},body:JSON.stringify(body || {})});\n const value = await response.json();\n if(!response.ok) throw new Error(value.error || 'Please try again.');\n return value;\n}\nfunction render(step, html) {\n revision++; clearTimeout(timer); error.hidden = true;\n document.querySelectorAll('.steps li').forEach((li,i) => { li.className = i === step ? 'active' : i < step ? 'done' : ''; li.toggleAttribute('aria-current', i === step); li.querySelector('b').textContent = i < step ? '\u2713' : String(i+1); });\n content.innerHTML = '<div class=\"section\">' + html + '</div>';\n const title = content.querySelector('h1'); if(title) { title.tabIndex = -1; title.focus({preventScroll:true}); }\n}\nfunction button(id, fn) { document.getElementById(id).onclick = async () => { if(busy) return; busy = true; const b = document.getElementById(id); b.disabled = true; error.hidden = true; try { await fn(); } catch(e) { showError(e); } finally { busy = false; if(b.isConnected) b.disabled = false; } }; }\nfunction welcome() {\n render(0, '<p class=\"eyebrow\">A good place to begin</p><h1>Your ideas.<br>A little more reach.</h1><p class=\"lead\">Connect this computer to bring AI conversations and a helping hand to Lucidity on your phone.</p>' + document.getElementById('art').innerHTML + '<div class=\"actions\"><button class=\"primary\" id=\"begin\">Let\u2019s get connected <span aria-hidden=\"true\">\u2192</span></button></div><p class=\"fine\" style=\"margin-top:18px\">Your tasks already work on their own. This adds the AI.</p>');\n button('begin', async () => { state = await request('begin'); connect(); });\n}\nfunction connect() {\n render(1, '<p class=\"eyebrow\">Connect your account</p><h1>Same you.<br>New possibilities.</h1><p class=\"lead\">Open Lucidity in a new tab, sign in, and confirm this computer. We\u2019ll take care of the connection.</p><div class=\"card\"><strong>' + escape(state.name) + '</strong><p class=\"code\">' + escape(state.code.match(/.{1,4}/g).join(' ')) + '</p></div><div class=\"actions\"><a class=\"primary\" href=\"' + escape(state.approvalUrl) + '\" target=\"_blank\" rel=\"noopener noreferrer\">Connect my account <span aria-hidden=\"true\">\u2197</span></a></div><p class=\"status\" style=\"margin-top:22px\" role=\"status\"><span class=\"dot\"></span>Waiting for your approval</p><p class=\"fine\">Keep this window open. The request expires in 10 minutes.</p><button class=\"secondary\" id=\"new\">Start a new request</button>');\n button('new', async () => { revision++; clearTimeout(timer); state = await request('begin', {restart:true}); connect(); });\n poll();\n}\nasync function poll() {\n const expected = revision;\n try {\n const value = await request('poll');\n if(expected !== revision) return;\n if(value.status === 'approved') { state.account = value.account; return providers(); }\n if(value.status === 'denied') { showError(new Error('This request was declined. Start a new request when you\u2019re ready.')); return; }\n error.hidden = true;\n } catch(e) { if(expected !== revision) return; showError(e); if(/expired|already used/i.test(e.message)) return; }\n timer = setTimeout(poll, 3000);\n}\nasync function providers() {\n render(2, '<p class=\"eyebrow\">Choose your AI</p><h1>A familiar<br>helping hand.</h1><p class=\"lead\">Use the subscription you already have. Lucid will use this provider for chat and coding.</p><p class=\"fine\">Connected as ' + escape(state.account.email) + '</p><div id=\"providers\"><p class=\"status\" role=\"status\"><span class=\"dot\"></span>Checking this computer\u2026</p></div><div class=\"actions\"><button class=\"primary\" id=\"continue\" disabled>Continue <span aria-hidden=\"true\">\u2192</span></button><button class=\"secondary\" id=\"refresh\">Check again</button></div><p class=\"fine\" style=\"margin-top:18px\">Checking sign-in does not use a model or confirm remaining allowance.</p>');\n button('refresh', refreshProviders);\n button('continue', async () => preferences());\n try { await refreshProviders(); } catch(e) { showError(e); }\n}\nasync function refreshProviders() {\n const expected = revision;\n const result = await request('providers');\n if(expected !== revision) return;\n const box = document.getElementById('providers'); box.innerHTML = '';\n for (const p of result.providers) {\n const ready = p.auth === 'authenticated';\n const card = document.createElement('button'); card.className = 'card choice'; card.type = 'button';\n card.setAttribute('aria-pressed', String(selected === p.id));\n card.innerHTML = '<span class=\"badge ' + (ready ? 'good' : '') + '\">' + (ready ? 'Signed in' : 'Needs attention') + '</span><strong>' + escape(p.label) + '</strong><p>' + (ready ? 'Your existing login is ready to use.' : escape(p.message)) + '</p>';\n card.onclick = () => { selected = p.id; sessionStorage.setItem('luciditySetupProvider', selected); box.querySelectorAll('button').forEach(b => b.setAttribute('aria-pressed','false')); card.setAttribute('aria-pressed','true'); document.getElementById('continue').disabled = !ready; };\n box.append(card);\n if(selected === p.id) document.getElementById('continue').disabled = !ready;\n }\n}\nfunction clientResults(rows) {\n return rows.map(c => '<div class=\"card\"><span class=\"badge ' + (c.status === 'configured' ? 'good' : '') + '\">' + (c.status === 'configured' ? 'Added' : 'Needs attention') + '</span><strong>' + escape(c.label) + '</strong><p>' + escape(c.message) + '</p></div>').join('');\n}\nasync function clientChoices() {\n const expected = revision;\n const result = await request('clients');\n if(expected !== revision) return;\n const box = document.getElementById('clients');\n box.innerHTML = '';\n for(const c of result.clients) {\n const available = c.status === 'available';\n const card = document.createElement('label'); card.className = 'card checkrow';\n card.innerHTML = '<input type=\"checkbox\" value=\"' + escape(c.id) + '\" ' + (!available ? 'disabled ' : '') + '><span><strong>Use Lucidity in ' + escape(c.label) + '</strong><p>' + escape(c.message) + '</p></span>';\n const input = card.querySelector('input');\n input.checked = c.status === 'configured' || (available && Array.isArray(choices.clients) && choices.clients.includes(c.id));\n input.onchange = () => { choices.clients = selectedClients(); sessionStorage.setItem('luciditySetupChoices', JSON.stringify(choices)); };\n box.append(card);\n }\n}\nfunction selectedClients() { return Array.from(document.querySelectorAll('#clients input:checked:not(:disabled)')).map(input => input.value); }\nconst clientSection = '<h2>Bring your tasks along.</h2><p>Access your Lucidity tasks, projects and comments in your own AI conversations. We\u2019ll add the connection for you.</p><div id=\"clients\"><p class=\"status\" role=\"status\">Checking your apps\u2026</p></div><p class=\"fine\">Your AI app may ask you to approve its tools. Local files and memories are not shared by this connection.</p>';\nasync function existingClients() {\n render(3, '<p class=\"eyebrow\">Already connected</p><h1>Lucidity, wherever<br>you think.</h1><p class=\"lead\">Add Lucidity to the AI apps you use on this computer. Your account is already connected.</p>' + clientSection + '<div class=\"actions\"><button class=\"primary\" id=\"add-clients\">Connect selected apps <span aria-hidden=\"true\">\u2192</span></button><button class=\"secondary\" id=\"refresh-clients\">Check again</button></div><div id=\"client-results\" aria-live=\"polite\"></div>');\n button('refresh-clients', clientChoices);\n button('add-clients', async () => {\n const selected = selectedClients();\n if(!selected.length) throw new Error('Choose an available app to connect.');\n const result = await request('configure-clients', {clients:selected});\n document.getElementById('client-results').innerHTML = clientResults(result.clients);\n await clientChoices();\n });\n await clientChoices();\n}\nasync function preferences() {\n render(3, '<p class=\"eyebrow\">Make it yours</p><h1>A little help.<br>On your terms.</h1><p class=\"lead\">Choose what Lucid can help with.</p><label class=\"card checkrow\"><input type=\"checkbox\" id=\"tasks\"><span><strong>Help with my tasks</strong><p>Let Lucid read and change your tasks, projects and comments when you ask.</p></span></label><label class=\"card checkrow\"><input type=\"checkbox\" id=\"schedules\"><span><strong>A daily rhythm</strong><p>Enable the 8am briefing, weekly review, journal processing and reminders. AI jobs use your provider allowance.</p></span></label><p class=\"fine\">Local folders and repositories stay private until you grant access.</p>' + clientSection + '<div class=\"notice\">For this preview, keep the terminal open while using AI. Closing your browser is fine. Background startup comes next.</div><div class=\"actions\"><button class=\"primary\" id=\"finish\">Finish setup <span aria-hidden=\"true\">\u2192</span></button><button class=\"secondary\" id=\"back\">Back</button></div>');\n for(const [id, field] of [['tasks','tasks'],['schedules','scheduledWork']]) { const input=document.getElementById(id); input.checked=choices[field] === true; input.onchange=()=>{choices[field]=input.checked;sessionStorage.setItem('luciditySetupChoices',JSON.stringify(choices));}; }\n button('back', providers);\n button('finish', async () => {\n const result = await request('finish', {provider:selected,tasks:document.getElementById('tasks').checked,scheduledWork:document.getElementById('schedules').checked,clients:selectedClients()});\n render(4, '<div class=\"seal\" aria-hidden=\"true\">\u2713</div><p class=\"eyebrow\">Setup complete</p><h1>A clearer day<br>starts here.</h1><p class=\"lead\">Your account and preferences are saved. Lucidity is starting on this computer.</p><div class=\"card\"><strong>Open Lucidity on your phone</strong><p>Go to Connect a computer. Once it shows this computer as ready, send your first message.</p></div>' + clientResults(result.clients || []) + '<p class=\"fine\">You can close this browser window. Keep the terminal open for AI to remain available.</p>');\n document.getElementById('cancel').hidden = true;\n });\n try { await clientChoices(); } catch(e) { document.getElementById('clients').textContent = 'Could not check your apps. You can add them later with lucidity setup-mcp.'; }\n}\nbutton('cancel', async () => { revision++; clearTimeout(timer); await request('cancel'); render(0,'<h1>See you when<br>you\u2019re ready.</h1><p class=\"lead\">Setup has stopped. You can keep using Lucidity on your phone and connect this computer later.</p>'); document.getElementById('cancel').hidden = true; });\n(async () => {\n try { state = await request('state'); if(state.existing) { await existingClients(); } else if(state.code) connect(); else welcome(); }\n catch(e) { showError(e); }\n})();\n";
|
|
2
|
+
export declare function localSetupPage(nonce: string): string;
|
|
3
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/setup/page.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,gvXAkHvB,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAG3C"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { setupPage, setupIllustration } from '@lucidity/shared';
|
|
2
|
+
export const setupScript = `
|
|
3
|
+
let token = new URLSearchParams(location.hash.slice(1)).get('session');
|
|
4
|
+
if (token) { sessionStorage.setItem('luciditySetupSession', token); history.replaceState(null, '', '/'); }
|
|
5
|
+
token = token || sessionStorage.getItem('luciditySetupSession');
|
|
6
|
+
const content = document.getElementById('stage');
|
|
7
|
+
const error = document.getElementById('error');
|
|
8
|
+
let state = {}, selected = sessionStorage.getItem('luciditySetupProvider'), timer, busy = false, revision = 0;
|
|
9
|
+
let choices = {tasks:false, scheduledWork:false, clients:[]};
|
|
10
|
+
try { choices = {...choices, ...JSON.parse(sessionStorage.getItem('luciditySetupChoices') || '{}')}; } catch {}
|
|
11
|
+
const escape = s => String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
|
12
|
+
function showError(e) { error.textContent = e.message || 'Something went wrong. Please try again.'; error.hidden = false; }
|
|
13
|
+
async function request(path, body) {
|
|
14
|
+
const response = await fetch('/api/' + path, {method:'POST',headers:{'Content-Type':'application/json','X-Setup-Token':token || ''},body:JSON.stringify(body || {})});
|
|
15
|
+
const value = await response.json();
|
|
16
|
+
if(!response.ok) throw new Error(value.error || 'Please try again.');
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function render(step, html) {
|
|
20
|
+
revision++; clearTimeout(timer); error.hidden = true;
|
|
21
|
+
document.querySelectorAll('.steps li').forEach((li,i) => { li.className = i === step ? 'active' : i < step ? 'done' : ''; li.toggleAttribute('aria-current', i === step); li.querySelector('b').textContent = i < step ? '✓' : String(i+1); });
|
|
22
|
+
content.innerHTML = '<div class="section">' + html + '</div>';
|
|
23
|
+
const title = content.querySelector('h1'); if(title) { title.tabIndex = -1; title.focus({preventScroll:true}); }
|
|
24
|
+
}
|
|
25
|
+
function button(id, fn) { document.getElementById(id).onclick = async () => { if(busy) return; busy = true; const b = document.getElementById(id); b.disabled = true; error.hidden = true; try { await fn(); } catch(e) { showError(e); } finally { busy = false; if(b.isConnected) b.disabled = false; } }; }
|
|
26
|
+
function welcome() {
|
|
27
|
+
render(0, '<p class="eyebrow">A good place to begin</p><h1>Your ideas.<br>A little more reach.</h1><p class="lead">Connect this computer to bring AI conversations and a helping hand to Lucidity on your phone.</p>' + document.getElementById('art').innerHTML + '<div class="actions"><button class="primary" id="begin">Let’s get connected <span aria-hidden="true">→</span></button></div><p class="fine" style="margin-top:18px">Your tasks already work on their own. This adds the AI.</p>');
|
|
28
|
+
button('begin', async () => { state = await request('begin'); connect(); });
|
|
29
|
+
}
|
|
30
|
+
function connect() {
|
|
31
|
+
render(1, '<p class="eyebrow">Connect your account</p><h1>Same you.<br>New possibilities.</h1><p class="lead">Open Lucidity in a new tab, sign in, and confirm this computer. We’ll take care of the connection.</p><div class="card"><strong>' + escape(state.name) + '</strong><p class="code">' + escape(state.code.match(/.{1,4}/g).join(' ')) + '</p></div><div class="actions"><a class="primary" href="' + escape(state.approvalUrl) + '" target="_blank" rel="noopener noreferrer">Connect my account <span aria-hidden="true">↗</span></a></div><p class="status" style="margin-top:22px" role="status"><span class="dot"></span>Waiting for your approval</p><p class="fine">Keep this window open. The request expires in 10 minutes.</p><button class="secondary" id="new">Start a new request</button>');
|
|
32
|
+
button('new', async () => { revision++; clearTimeout(timer); state = await request('begin', {restart:true}); connect(); });
|
|
33
|
+
poll();
|
|
34
|
+
}
|
|
35
|
+
async function poll() {
|
|
36
|
+
const expected = revision;
|
|
37
|
+
try {
|
|
38
|
+
const value = await request('poll');
|
|
39
|
+
if(expected !== revision) return;
|
|
40
|
+
if(value.status === 'approved') { state.account = value.account; return providers(); }
|
|
41
|
+
if(value.status === 'denied') { showError(new Error('This request was declined. Start a new request when you’re ready.')); return; }
|
|
42
|
+
error.hidden = true;
|
|
43
|
+
} catch(e) { if(expected !== revision) return; showError(e); if(/expired|already used/i.test(e.message)) return; }
|
|
44
|
+
timer = setTimeout(poll, 3000);
|
|
45
|
+
}
|
|
46
|
+
async function providers() {
|
|
47
|
+
render(2, '<p class="eyebrow">Choose your AI</p><h1>A familiar<br>helping hand.</h1><p class="lead">Use the subscription you already have. Lucid will use this provider for chat and coding.</p><p class="fine">Connected as ' + escape(state.account.email) + '</p><div id="providers"><p class="status" role="status"><span class="dot"></span>Checking this computer…</p></div><div class="actions"><button class="primary" id="continue" disabled>Continue <span aria-hidden="true">→</span></button><button class="secondary" id="refresh">Check again</button></div><p class="fine" style="margin-top:18px">Checking sign-in does not use a model or confirm remaining allowance.</p>');
|
|
48
|
+
button('refresh', refreshProviders);
|
|
49
|
+
button('continue', async () => preferences());
|
|
50
|
+
try { await refreshProviders(); } catch(e) { showError(e); }
|
|
51
|
+
}
|
|
52
|
+
async function refreshProviders() {
|
|
53
|
+
const expected = revision;
|
|
54
|
+
const result = await request('providers');
|
|
55
|
+
if(expected !== revision) return;
|
|
56
|
+
const box = document.getElementById('providers'); box.innerHTML = '';
|
|
57
|
+
for (const p of result.providers) {
|
|
58
|
+
const ready = p.auth === 'authenticated';
|
|
59
|
+
const card = document.createElement('button'); card.className = 'card choice'; card.type = 'button';
|
|
60
|
+
card.setAttribute('aria-pressed', String(selected === p.id));
|
|
61
|
+
card.innerHTML = '<span class="badge ' + (ready ? 'good' : '') + '">' + (ready ? 'Signed in' : 'Needs attention') + '</span><strong>' + escape(p.label) + '</strong><p>' + (ready ? 'Your existing login is ready to use.' : escape(p.message)) + '</p>';
|
|
62
|
+
card.onclick = () => { selected = p.id; sessionStorage.setItem('luciditySetupProvider', selected); box.querySelectorAll('button').forEach(b => b.setAttribute('aria-pressed','false')); card.setAttribute('aria-pressed','true'); document.getElementById('continue').disabled = !ready; };
|
|
63
|
+
box.append(card);
|
|
64
|
+
if(selected === p.id) document.getElementById('continue').disabled = !ready;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function clientResults(rows) {
|
|
68
|
+
return rows.map(c => '<div class="card"><span class="badge ' + (c.status === 'configured' ? 'good' : '') + '">' + (c.status === 'configured' ? 'Added' : 'Needs attention') + '</span><strong>' + escape(c.label) + '</strong><p>' + escape(c.message) + '</p></div>').join('');
|
|
69
|
+
}
|
|
70
|
+
async function clientChoices() {
|
|
71
|
+
const expected = revision;
|
|
72
|
+
const result = await request('clients');
|
|
73
|
+
if(expected !== revision) return;
|
|
74
|
+
const box = document.getElementById('clients');
|
|
75
|
+
box.innerHTML = '';
|
|
76
|
+
for(const c of result.clients) {
|
|
77
|
+
const available = c.status === 'available';
|
|
78
|
+
const card = document.createElement('label'); card.className = 'card checkrow';
|
|
79
|
+
card.innerHTML = '<input type="checkbox" value="' + escape(c.id) + '" ' + (!available ? 'disabled ' : '') + '><span><strong>Use Lucidity in ' + escape(c.label) + '</strong><p>' + escape(c.message) + '</p></span>';
|
|
80
|
+
const input = card.querySelector('input');
|
|
81
|
+
input.checked = c.status === 'configured' || (available && Array.isArray(choices.clients) && choices.clients.includes(c.id));
|
|
82
|
+
input.onchange = () => { choices.clients = selectedClients(); sessionStorage.setItem('luciditySetupChoices', JSON.stringify(choices)); };
|
|
83
|
+
box.append(card);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function selectedClients() { return Array.from(document.querySelectorAll('#clients input:checked:not(:disabled)')).map(input => input.value); }
|
|
87
|
+
const clientSection = '<h2>Bring your tasks along.</h2><p>Access your Lucidity tasks, projects and comments in your own AI conversations. We’ll add the connection for you.</p><div id="clients"><p class="status" role="status">Checking your apps…</p></div><p class="fine">Your AI app may ask you to approve its tools. Local files and memories are not shared by this connection.</p>';
|
|
88
|
+
async function existingClients() {
|
|
89
|
+
render(3, '<p class="eyebrow">Already connected</p><h1>Lucidity, wherever<br>you think.</h1><p class="lead">Add Lucidity to the AI apps you use on this computer. Your account is already connected.</p>' + clientSection + '<div class="actions"><button class="primary" id="add-clients">Connect selected apps <span aria-hidden="true">→</span></button><button class="secondary" id="refresh-clients">Check again</button></div><div id="client-results" aria-live="polite"></div>');
|
|
90
|
+
button('refresh-clients', clientChoices);
|
|
91
|
+
button('add-clients', async () => {
|
|
92
|
+
const selected = selectedClients();
|
|
93
|
+
if(!selected.length) throw new Error('Choose an available app to connect.');
|
|
94
|
+
const result = await request('configure-clients', {clients:selected});
|
|
95
|
+
document.getElementById('client-results').innerHTML = clientResults(result.clients);
|
|
96
|
+
await clientChoices();
|
|
97
|
+
});
|
|
98
|
+
await clientChoices();
|
|
99
|
+
}
|
|
100
|
+
async function preferences() {
|
|
101
|
+
render(3, '<p class="eyebrow">Make it yours</p><h1>A little help.<br>On your terms.</h1><p class="lead">Choose what Lucid can help with.</p><label class="card checkrow"><input type="checkbox" id="tasks"><span><strong>Help with my tasks</strong><p>Let Lucid read and change your tasks, projects and comments when you ask.</p></span></label><label class="card checkrow"><input type="checkbox" id="schedules"><span><strong>A daily rhythm</strong><p>Enable the 8am briefing, weekly review, journal processing and reminders. AI jobs use your provider allowance.</p></span></label><p class="fine">Local folders and repositories stay private until you grant access.</p>' + clientSection + '<div class="notice">For this preview, keep the terminal open while using AI. Closing your browser is fine. Background startup comes next.</div><div class="actions"><button class="primary" id="finish">Finish setup <span aria-hidden="true">→</span></button><button class="secondary" id="back">Back</button></div>');
|
|
102
|
+
for(const [id, field] of [['tasks','tasks'],['schedules','scheduledWork']]) { const input=document.getElementById(id); input.checked=choices[field] === true; input.onchange=()=>{choices[field]=input.checked;sessionStorage.setItem('luciditySetupChoices',JSON.stringify(choices));}; }
|
|
103
|
+
button('back', providers);
|
|
104
|
+
button('finish', async () => {
|
|
105
|
+
const result = await request('finish', {provider:selected,tasks:document.getElementById('tasks').checked,scheduledWork:document.getElementById('schedules').checked,clients:selectedClients()});
|
|
106
|
+
render(4, '<div class="seal" aria-hidden="true">✓</div><p class="eyebrow">Setup complete</p><h1>A clearer day<br>starts here.</h1><p class="lead">Your account and preferences are saved. Lucidity is starting on this computer.</p><div class="card"><strong>Open Lucidity on your phone</strong><p>Go to Connect a computer. Once it shows this computer as ready, send your first message.</p></div>' + clientResults(result.clients || []) + '<p class="fine">You can close this browser window. Keep the terminal open for AI to remain available.</p>');
|
|
107
|
+
document.getElementById('cancel').hidden = true;
|
|
108
|
+
});
|
|
109
|
+
try { await clientChoices(); } catch(e) { document.getElementById('clients').textContent = 'Could not check your apps. You can add them later with lucidity setup-mcp.'; }
|
|
110
|
+
}
|
|
111
|
+
button('cancel', async () => { revision++; clearTimeout(timer); await request('cancel'); render(0,'<h1>See you when<br>you’re ready.</h1><p class="lead">Setup has stopped. You can keep using Lucidity on your phone and connect this computer later.</p>'); document.getElementById('cancel').hidden = true; });
|
|
112
|
+
(async () => {
|
|
113
|
+
try { state = await request('state'); if(state.existing) { await existingClients(); } else if(state.code) connect(); else welcome(); }
|
|
114
|
+
catch(e) { showError(e); }
|
|
115
|
+
})();
|
|
116
|
+
`;
|
|
117
|
+
export function localSetupPage(nonce) {
|
|
118
|
+
const body = `<main class="frame"><aside class="rail"><span class="tiny">Your computer, connected</span><h2>More room<br>for your ideas.</h2><ol class="steps" aria-label="Setup progress"><li class="active"><b>1</b>Welcome</li><li><b>2</b>Connect account</li><li><b>3</b>Choose AI</li><li><b>4</b>Make it yours</li><li><b>5</b>Ready</li></ol><p class="rail-note">A private connection.<br>A familiar helping hand.<br>Everything in its place.</p></aside><section class="content"><div id="stage"><p class="status"><span class="dot"></span>Getting things ready…</p></div><div id="error" class="notice error" role="alert" hidden></div><div class="spacer"></div><button class="secondary" id="cancel" style="align-self:flex-start">Finish another time</button></section></main><template id="art">${setupIllustration}</template>`;
|
|
119
|
+
return setupPage(body, setupScript, nonce);
|
|
120
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type IncomingMessage, type ServerResponse } from 'node:http';
|
|
2
|
+
import { createClientSetup } from '../mcp/clients.js';
|
|
3
|
+
export declare function setupApiUrl(value: string): string;
|
|
4
|
+
export declare function writeNewSetupConfig(dir: string, config: Record<string, unknown>): void;
|
|
5
|
+
export declare function checkSetupProviders(): Promise<{
|
|
6
|
+
id: "claude" | "codex";
|
|
7
|
+
label: string;
|
|
8
|
+
auth: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}[]>;
|
|
11
|
+
export interface SetupOptions {
|
|
12
|
+
apiUrl?: string;
|
|
13
|
+
directory?: string;
|
|
14
|
+
fetch?: typeof globalThis.fetch;
|
|
15
|
+
providers?: typeof checkSetupProviders;
|
|
16
|
+
clients?: ReturnType<typeof createClientSetup>;
|
|
17
|
+
onFinish?: (start: boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function createSetupServer(options?: SetupOptions): Promise<{
|
|
20
|
+
server: import("http").Server<typeof IncomingMessage, typeof ServerResponse>;
|
|
21
|
+
url: string;
|
|
22
|
+
token: string;
|
|
23
|
+
origin: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function runSetup(): Promise<boolean>;
|
|
26
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/setup/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AAsBnB,OAAO,EACL,iBAAiB,EAGlB,MAAM,mBAAmB,CAAC;AAe3B,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,UAqBxC;AACD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAahC;AA4BD,wBAAsB,mBAAmB;;;;;KA+BxC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,mBAAmB,CAAC;IACvC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC;AACD,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,YAAiB;;;;;GAmTjE;AAED,wBAAsB,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAsBjD"}
|