@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,483 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServer,
|
|
3
|
+
type IncomingMessage,
|
|
4
|
+
type ServerResponse,
|
|
5
|
+
} from 'node:http';
|
|
6
|
+
import { randomBytes, createHash, timingSafeEqual } from 'node:crypto';
|
|
7
|
+
import { hostname } from 'node:os';
|
|
8
|
+
import {
|
|
9
|
+
mkdirSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
writeFileSync,
|
|
12
|
+
existsSync,
|
|
13
|
+
unlinkSync,
|
|
14
|
+
linkSync,
|
|
15
|
+
chmodSync,
|
|
16
|
+
} from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
import { spawn } from 'node:child_process';
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import {
|
|
21
|
+
ClaudeAgentExecutor,
|
|
22
|
+
CodexExecutor,
|
|
23
|
+
providerFailure,
|
|
24
|
+
} from '@lucidity/runtime';
|
|
25
|
+
import { CONFIG_DIR } from '../config.js';
|
|
26
|
+
import { localSetupPage } from './page.js';
|
|
27
|
+
import {
|
|
28
|
+
createClientSetup,
|
|
29
|
+
CLIENT_IDS,
|
|
30
|
+
type ClientStatus,
|
|
31
|
+
} from '../mcp/clients.js';
|
|
32
|
+
|
|
33
|
+
const clientChoices = z.array(z.enum(CLIENT_IDS)).max(2).default([]);
|
|
34
|
+
|
|
35
|
+
const sha = (s: string) => createHash('sha256').update(s).digest('hex');
|
|
36
|
+
const pendingSchema = z.object({
|
|
37
|
+
id: z.string().uuid(),
|
|
38
|
+
code: z.string().regex(/^[A-F0-9]{24}$/),
|
|
39
|
+
expiresAt: z.string().datetime(),
|
|
40
|
+
secret: z.string().regex(/^[a-f0-9]{64}$/),
|
|
41
|
+
key: z.string().regex(/^luc_pc_[a-f0-9]{64}$/),
|
|
42
|
+
apiUrl: z.string().url(),
|
|
43
|
+
name: z.string().min(1).max(120),
|
|
44
|
+
});
|
|
45
|
+
type Pending = z.infer<typeof pendingSchema>;
|
|
46
|
+
export function setupApiUrl(value: string) {
|
|
47
|
+
const url = new URL(value);
|
|
48
|
+
if (
|
|
49
|
+
url.username ||
|
|
50
|
+
url.password ||
|
|
51
|
+
url.search ||
|
|
52
|
+
url.hash ||
|
|
53
|
+
(url.pathname !== '/' && url.pathname !== '')
|
|
54
|
+
)
|
|
55
|
+
throw new Error('Use the API origin without a path or credentials.');
|
|
56
|
+
if (
|
|
57
|
+
url.protocol !== 'https:' &&
|
|
58
|
+
!(
|
|
59
|
+
url.protocol === 'http:' &&
|
|
60
|
+
['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
throw new Error(
|
|
64
|
+
'Setup requires HTTPS, except for a local development API.',
|
|
65
|
+
);
|
|
66
|
+
return url.origin;
|
|
67
|
+
}
|
|
68
|
+
export function writeNewSetupConfig(
|
|
69
|
+
dir: string,
|
|
70
|
+
config: Record<string, unknown>,
|
|
71
|
+
) {
|
|
72
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
73
|
+
const temporary = join(dir, `.setup-${randomBytes(8).toString('hex')}.json`);
|
|
74
|
+
writeFileSync(temporary, JSON.stringify(config, null, 2) + '\n', {
|
|
75
|
+
flag: 'wx',
|
|
76
|
+
mode: 0o600,
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
linkSync(temporary, join(dir, 'config.json'));
|
|
80
|
+
} finally {
|
|
81
|
+
unlinkSync(temporary);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function acquireSetupLock(dir: string) {
|
|
85
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
86
|
+
const path = join(dir, 'setup.lock');
|
|
87
|
+
if (existsSync(path)) {
|
|
88
|
+
const pid = Number(readFileSync(path, 'utf8'));
|
|
89
|
+
if (!Number.isInteger(pid) || pid < 1)
|
|
90
|
+
throw new Error(
|
|
91
|
+
'The saved setup lock is invalid. Your configuration has not been changed.',
|
|
92
|
+
);
|
|
93
|
+
let alive = true;
|
|
94
|
+
try {
|
|
95
|
+
process.kill(pid, 0);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
if ((e as NodeJS.ErrnoException).code === 'ESRCH') alive = false;
|
|
98
|
+
}
|
|
99
|
+
if (alive)
|
|
100
|
+
throw new Error(
|
|
101
|
+
'Setup is already open for this computer. Return to its browser window.',
|
|
102
|
+
);
|
|
103
|
+
unlinkSync(path);
|
|
104
|
+
}
|
|
105
|
+
writeFileSync(path, String(process.pid), { flag: 'wx', mode: 0o600 });
|
|
106
|
+
return () => {
|
|
107
|
+
if (existsSync(path) && readFileSync(path, 'utf8') === String(process.pid))
|
|
108
|
+
unlinkSync(path);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export async function checkSetupProviders() {
|
|
112
|
+
return Promise.all(
|
|
113
|
+
(['claude', 'codex'] as const).map(async (id) => {
|
|
114
|
+
const executor =
|
|
115
|
+
id === 'claude' ? new ClaudeAgentExecutor() : new CodexExecutor();
|
|
116
|
+
try {
|
|
117
|
+
await executor.models();
|
|
118
|
+
return {
|
|
119
|
+
id,
|
|
120
|
+
label: id === 'claude' ? 'Claude' : 'Codex',
|
|
121
|
+
auth: 'authenticated',
|
|
122
|
+
message: '',
|
|
123
|
+
};
|
|
124
|
+
} catch (e) {
|
|
125
|
+
const health = providerFailure(e);
|
|
126
|
+
return {
|
|
127
|
+
id,
|
|
128
|
+
label: id === 'claude' ? 'Claude' : 'Codex',
|
|
129
|
+
auth: health.auth === 'authenticated' ? 'unknown' : health.auth,
|
|
130
|
+
message:
|
|
131
|
+
health.problem === 'login'
|
|
132
|
+
? id === 'claude'
|
|
133
|
+
? 'Sign in with Claude Code on this computer, then check again.'
|
|
134
|
+
: 'Run codex login on this computer, then check again.'
|
|
135
|
+
: 'Could not check this provider. Confirm it is installed and your network is available, then check again.',
|
|
136
|
+
};
|
|
137
|
+
} finally {
|
|
138
|
+
await executor.dispose();
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface SetupOptions {
|
|
145
|
+
apiUrl?: string;
|
|
146
|
+
directory?: string;
|
|
147
|
+
fetch?: typeof globalThis.fetch;
|
|
148
|
+
providers?: typeof checkSetupProviders;
|
|
149
|
+
clients?: ReturnType<typeof createClientSetup>;
|
|
150
|
+
onFinish?: (start: boolean) => void;
|
|
151
|
+
}
|
|
152
|
+
export async function createSetupServer(options: SetupOptions = {}) {
|
|
153
|
+
const apiUrl = setupApiUrl(
|
|
154
|
+
options.apiUrl ?? process.env.LUCIDITY_API_URL ?? 'https://api.lucidity.my',
|
|
155
|
+
);
|
|
156
|
+
const dir = options.directory ?? CONFIG_DIR;
|
|
157
|
+
const pendingPath = join(dir, 'setup-pending.json');
|
|
158
|
+
const configPath = join(dir, 'config.json');
|
|
159
|
+
const clients = options.clients ?? createClientSetup({ configPath });
|
|
160
|
+
const token = randomBytes(32).toString('hex');
|
|
161
|
+
const nonce = randomBytes(18).toString('base64');
|
|
162
|
+
let pending: Pending | undefined;
|
|
163
|
+
let finished = false;
|
|
164
|
+
let mutation = false;
|
|
165
|
+
let providerCheck: ReturnType<typeof checkSetupProviders> | undefined;
|
|
166
|
+
if (!existsSync(configPath) && existsSync(pendingPath)) {
|
|
167
|
+
const parsed = pendingSchema.safeParse(
|
|
168
|
+
JSON.parse(readFileSync(pendingPath, 'utf8')),
|
|
169
|
+
);
|
|
170
|
+
if (!parsed.success)
|
|
171
|
+
throw new Error(
|
|
172
|
+
'Saved setup is invalid. Your existing configuration has not been changed.',
|
|
173
|
+
);
|
|
174
|
+
if (parsed.data.apiUrl !== apiUrl)
|
|
175
|
+
throw new Error(
|
|
176
|
+
'A connection is pending for a different Lucidity server. Finish or cancel it using that server before starting again.',
|
|
177
|
+
);
|
|
178
|
+
pending = parsed.data;
|
|
179
|
+
}
|
|
180
|
+
const api = async (path: string, body: unknown) => {
|
|
181
|
+
const response = await (options.fetch ?? fetch)(
|
|
182
|
+
apiUrl + '/api/auth/computers/' + path,
|
|
183
|
+
{
|
|
184
|
+
method: 'POST',
|
|
185
|
+
headers: { 'Content-Type': 'application/json' },
|
|
186
|
+
body: JSON.stringify(body),
|
|
187
|
+
signal: AbortSignal.timeout(15000),
|
|
188
|
+
redirect: 'error',
|
|
189
|
+
},
|
|
190
|
+
);
|
|
191
|
+
const value = await response.json().catch(() => ({}));
|
|
192
|
+
if (!response.ok)
|
|
193
|
+
throw new Error(
|
|
194
|
+
response.status === 404
|
|
195
|
+
? 'This Lucidity server does not support guided setup yet. Update the server before trying again.'
|
|
196
|
+
: typeof value.error === 'string'
|
|
197
|
+
? value.error
|
|
198
|
+
: 'Lucidity could not be reached. Check your connection and try again.',
|
|
199
|
+
);
|
|
200
|
+
return value;
|
|
201
|
+
};
|
|
202
|
+
const publicState = () =>
|
|
203
|
+
pending
|
|
204
|
+
? {
|
|
205
|
+
name: pending.name,
|
|
206
|
+
code: pending.code,
|
|
207
|
+
approvalUrl:
|
|
208
|
+
(apiUrl === 'https://api.lucidity.my'
|
|
209
|
+
? 'https://lucidity.my'
|
|
210
|
+
: apiUrl) +
|
|
211
|
+
'/connect-computer#code=' +
|
|
212
|
+
pending.code,
|
|
213
|
+
}
|
|
214
|
+
: {};
|
|
215
|
+
const removePending = () => {
|
|
216
|
+
if (existsSync(pendingPath)) unlinkSync(pendingPath);
|
|
217
|
+
pending = undefined;
|
|
218
|
+
};
|
|
219
|
+
async function body(req: IncomingMessage) {
|
|
220
|
+
const chunks: Buffer[] = [];
|
|
221
|
+
let size = 0;
|
|
222
|
+
for await (const chunk of req) {
|
|
223
|
+
size += chunk.length;
|
|
224
|
+
if (size > 2048) throw new Error('Request too large.');
|
|
225
|
+
chunks.push(chunk);
|
|
226
|
+
}
|
|
227
|
+
return JSON.parse(Buffer.concat(chunks).toString('utf8')) as unknown;
|
|
228
|
+
}
|
|
229
|
+
const send = (res: ServerResponse, status: number, value: unknown) => {
|
|
230
|
+
res.writeHead(status, { 'Content-Type': 'application/json' });
|
|
231
|
+
res.end(JSON.stringify(value));
|
|
232
|
+
};
|
|
233
|
+
let origin = '';
|
|
234
|
+
const releaseLock = acquireSetupLock(dir);
|
|
235
|
+
const server = createServer(async (req, res) => {
|
|
236
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
237
|
+
res.setHeader('Referrer-Policy', 'no-referrer');
|
|
238
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
239
|
+
res.setHeader(
|
|
240
|
+
'Content-Security-Policy',
|
|
241
|
+
`default-src 'none'; script-src 'nonce-${nonce}'; style-src 'unsafe-inline'; img-src data:; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'`,
|
|
242
|
+
);
|
|
243
|
+
if (req.headers.host !== new URL(origin).host)
|
|
244
|
+
return send(res, 403, { error: 'Unrecognized setup host.' });
|
|
245
|
+
if (req.method === 'GET' && req.url === '/') {
|
|
246
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
247
|
+
res.end(localSetupPage(nonce));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const provided = req.headers['x-setup-token'];
|
|
251
|
+
if (
|
|
252
|
+
req.method !== 'POST' ||
|
|
253
|
+
req.headers.origin !== origin ||
|
|
254
|
+
req.headers['content-type'] !== 'application/json' ||
|
|
255
|
+
typeof provided !== 'string' ||
|
|
256
|
+
!/^[a-f0-9]{64}$/.test(provided) ||
|
|
257
|
+
!timingSafeEqual(Buffer.from(provided), Buffer.from(token))
|
|
258
|
+
)
|
|
259
|
+
return send(res, 403, {
|
|
260
|
+
error: 'This setup session is unavailable. Run lucidity setup again.',
|
|
261
|
+
});
|
|
262
|
+
try {
|
|
263
|
+
const input = await body(req);
|
|
264
|
+
if (finished) return send(res, 409, { error: 'Setup has finished.' });
|
|
265
|
+
if (req.url === '/api/state')
|
|
266
|
+
return send(res, 200, {
|
|
267
|
+
existing: existsSync(configPath),
|
|
268
|
+
...publicState(),
|
|
269
|
+
});
|
|
270
|
+
if (req.url === '/api/poll') {
|
|
271
|
+
if (!pending) throw new Error('Start a connection first.');
|
|
272
|
+
return send(
|
|
273
|
+
res,
|
|
274
|
+
200,
|
|
275
|
+
await api('poll', { id: pending.id, secret: pending.secret }),
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
if (req.url === '/api/providers') {
|
|
279
|
+
providerCheck ??= (options.providers ?? checkSetupProviders)().finally(
|
|
280
|
+
() => {
|
|
281
|
+
providerCheck = undefined;
|
|
282
|
+
},
|
|
283
|
+
);
|
|
284
|
+
return send(res, 200, { providers: await providerCheck });
|
|
285
|
+
}
|
|
286
|
+
if (req.url === '/api/clients')
|
|
287
|
+
return send(res, 200, { clients: await clients.inspect() });
|
|
288
|
+
if (mutation)
|
|
289
|
+
return send(res, 409, { error: 'A setup step is already running.' });
|
|
290
|
+
mutation = true;
|
|
291
|
+
try {
|
|
292
|
+
if (req.url === '/api/configure-clients') {
|
|
293
|
+
if (!existsSync(configPath))
|
|
294
|
+
throw new Error('Finish connecting your account first.');
|
|
295
|
+
const selected = z
|
|
296
|
+
.object({ clients: clientChoices })
|
|
297
|
+
.parse(input).clients;
|
|
298
|
+
return send(res, 200, { clients: await clients.configure(selected) });
|
|
299
|
+
}
|
|
300
|
+
if (req.url === '/api/begin') {
|
|
301
|
+
if (existsSync(configPath))
|
|
302
|
+
throw new Error(
|
|
303
|
+
'This computer is already configured. Your settings have been kept.',
|
|
304
|
+
);
|
|
305
|
+
const restart = z
|
|
306
|
+
.object({ restart: z.boolean().optional() })
|
|
307
|
+
.parse(input).restart;
|
|
308
|
+
if (
|
|
309
|
+
pending &&
|
|
310
|
+
!restart &&
|
|
311
|
+
new Date(pending.expiresAt).getTime() > Date.now()
|
|
312
|
+
)
|
|
313
|
+
return send(res, 200, publicState());
|
|
314
|
+
if (pending) {
|
|
315
|
+
await api('cancel', { id: pending.id, secret: pending.secret });
|
|
316
|
+
removePending();
|
|
317
|
+
}
|
|
318
|
+
const secret = randomBytes(32).toString('hex');
|
|
319
|
+
const key = 'luc_pc_' + randomBytes(32).toString('hex');
|
|
320
|
+
const name = hostname().slice(0, 120) || 'My computer';
|
|
321
|
+
const created = await api('begin', {
|
|
322
|
+
name,
|
|
323
|
+
secretHash: sha(secret),
|
|
324
|
+
keyHash: sha(key),
|
|
325
|
+
});
|
|
326
|
+
pending = pendingSchema.parse({
|
|
327
|
+
...created,
|
|
328
|
+
secret,
|
|
329
|
+
key,
|
|
330
|
+
apiUrl,
|
|
331
|
+
name,
|
|
332
|
+
});
|
|
333
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
334
|
+
writeFileSync(pendingPath, JSON.stringify(pending), { mode: 0o600 });
|
|
335
|
+
chmodSync(pendingPath, 0o600);
|
|
336
|
+
return send(res, 200, publicState());
|
|
337
|
+
}
|
|
338
|
+
if (req.url === '/api/finish') {
|
|
339
|
+
const preferences = z
|
|
340
|
+
.object({
|
|
341
|
+
provider: z.enum(['claude', 'codex']),
|
|
342
|
+
tasks: z.boolean(),
|
|
343
|
+
scheduledWork: z.boolean(),
|
|
344
|
+
clients: clientChoices,
|
|
345
|
+
})
|
|
346
|
+
.parse(input);
|
|
347
|
+
if (!pending) throw new Error('Connect your account first.');
|
|
348
|
+
const approved = await api('poll', {
|
|
349
|
+
id: pending.id,
|
|
350
|
+
secret: pending.secret,
|
|
351
|
+
});
|
|
352
|
+
if (approved.status !== 'approved')
|
|
353
|
+
throw new Error(
|
|
354
|
+
'Approve this computer in your Lucidity account first.',
|
|
355
|
+
);
|
|
356
|
+
const health = await (options.providers ?? checkSetupProviders)();
|
|
357
|
+
if (
|
|
358
|
+
!health.some(
|
|
359
|
+
(p) =>
|
|
360
|
+
p.id === preferences.provider && p.auth === 'authenticated',
|
|
361
|
+
)
|
|
362
|
+
)
|
|
363
|
+
throw new Error(
|
|
364
|
+
'Sign in to your selected provider and check again.',
|
|
365
|
+
);
|
|
366
|
+
writeNewSetupConfig(dir, {
|
|
367
|
+
apiKey: pending.key,
|
|
368
|
+
apiUrl,
|
|
369
|
+
machineName: pending.name,
|
|
370
|
+
chatProvider: preferences.provider,
|
|
371
|
+
codeProvider: preferences.provider,
|
|
372
|
+
chatModel: 'default',
|
|
373
|
+
codeModel: 'default',
|
|
374
|
+
delivery: 'stdout',
|
|
375
|
+
scheduledWork: preferences.scheduledWork,
|
|
376
|
+
reflect: false,
|
|
377
|
+
weeklyReview: preferences.scheduledWork,
|
|
378
|
+
capabilities: {
|
|
379
|
+
tasks: preferences.tasks,
|
|
380
|
+
memory: false,
|
|
381
|
+
connected: false,
|
|
382
|
+
},
|
|
383
|
+
repos: [],
|
|
384
|
+
});
|
|
385
|
+
removePending();
|
|
386
|
+
let clientResults: ClientStatus[] = [];
|
|
387
|
+
if (preferences.clients.length) {
|
|
388
|
+
try {
|
|
389
|
+
clientResults = await clients.configure(preferences.clients);
|
|
390
|
+
} catch {
|
|
391
|
+
// Pairing has succeeded. A client-config failure must not send the
|
|
392
|
+
// user back through pairing or revoke the saved credential.
|
|
393
|
+
clientResults = preferences.clients.map((id) => ({
|
|
394
|
+
id,
|
|
395
|
+
label: id === 'claude' ? 'Claude Code' : 'Codex',
|
|
396
|
+
status: 'error',
|
|
397
|
+
message:
|
|
398
|
+
'Your account is connected. Run lucidity setup-mcp to finish adding your tools.',
|
|
399
|
+
}));
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
finished = true;
|
|
403
|
+
send(res, 200, { ok: true, clients: clientResults });
|
|
404
|
+
setTimeout(() => {
|
|
405
|
+
server.close();
|
|
406
|
+
options.onFinish?.(true);
|
|
407
|
+
}, 500);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (req.url === '/api/cancel') {
|
|
411
|
+
if (pending)
|
|
412
|
+
await api('cancel', { id: pending.id, secret: pending.secret });
|
|
413
|
+
removePending();
|
|
414
|
+
finished = true;
|
|
415
|
+
send(res, 200, { ok: true });
|
|
416
|
+
setTimeout(() => {
|
|
417
|
+
server.close();
|
|
418
|
+
options.onFinish?.(false);
|
|
419
|
+
}, 500);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
send(res, 404, { error: 'Unknown setup action.' });
|
|
423
|
+
} finally {
|
|
424
|
+
mutation = false;
|
|
425
|
+
}
|
|
426
|
+
} catch (e) {
|
|
427
|
+
send(res, 400, {
|
|
428
|
+
error:
|
|
429
|
+
e instanceof z.ZodError
|
|
430
|
+
? 'Invalid setup choice.'
|
|
431
|
+
: e instanceof Error
|
|
432
|
+
? e.message
|
|
433
|
+
: 'Setup could not finish.',
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
server.once('close', releaseLock);
|
|
438
|
+
server.once('error', releaseLock);
|
|
439
|
+
server.requestTimeout = 20000;
|
|
440
|
+
await new Promise<void>((resolve, reject) => {
|
|
441
|
+
server.once('error', reject);
|
|
442
|
+
server.listen(0, '127.0.0.1', resolve);
|
|
443
|
+
});
|
|
444
|
+
const address = server.address();
|
|
445
|
+
if (!address || typeof address === 'string')
|
|
446
|
+
throw new Error('Could not open setup.');
|
|
447
|
+
origin = 'http://127.0.0.1:' + address.port;
|
|
448
|
+
const expires = setTimeout(
|
|
449
|
+
() => {
|
|
450
|
+
server.closeAllConnections();
|
|
451
|
+
server.close();
|
|
452
|
+
options.onFinish?.(false);
|
|
453
|
+
},
|
|
454
|
+
30 * 60 * 1000,
|
|
455
|
+
);
|
|
456
|
+
expires.unref();
|
|
457
|
+
server.on('close', () => clearTimeout(expires));
|
|
458
|
+
return { server, url: origin + '/#session=' + token, token, origin };
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export async function runSetup(): Promise<boolean> {
|
|
462
|
+
return new Promise<boolean>((resolve, reject) => {
|
|
463
|
+
void createSetupServer({ onFinish: resolve }).then(({ url }) => {
|
|
464
|
+
console.error('Open this private setup link on this computer:\n' + url);
|
|
465
|
+
const command =
|
|
466
|
+
process.platform === 'darwin'
|
|
467
|
+
? 'open'
|
|
468
|
+
: process.platform === 'win32'
|
|
469
|
+
? 'rundll32'
|
|
470
|
+
: 'xdg-open';
|
|
471
|
+
const args =
|
|
472
|
+
process.platform === 'win32'
|
|
473
|
+
? ['url.dll,FileProtocolHandler', url]
|
|
474
|
+
: [url];
|
|
475
|
+
const child = spawn(command, args, {
|
|
476
|
+
stdio: 'ignore',
|
|
477
|
+
windowsHide: true,
|
|
478
|
+
});
|
|
479
|
+
child.on('error', () => {});
|
|
480
|
+
child.unref();
|
|
481
|
+
}, reject);
|
|
482
|
+
});
|
|
483
|
+
}
|