@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,406 @@
|
|
|
1
|
+
import { Cron } from 'croner';
|
|
2
|
+
import { uuidv7 } from 'uuidv7';
|
|
3
|
+
import { AutomationCommandSchema, isDesignerInput, } from '@lucidity/shared';
|
|
4
|
+
export function nextOccurrence(schedule, after) {
|
|
5
|
+
if (schedule.frequency === 'manual')
|
|
6
|
+
return null;
|
|
7
|
+
const [hour, minute] = schedule.time.split(':');
|
|
8
|
+
const expression = schedule.frequency === 'interval'
|
|
9
|
+
? `0 */${schedule.everyHours} * * *`
|
|
10
|
+
: `${minute} ${hour} * * ${schedule.frequency === 'weekly' ? schedule.dayOfWeek : schedule.frequency === 'weekdays' ? '1-5' : '*'}`;
|
|
11
|
+
const cron = new Cron(expression, {
|
|
12
|
+
timezone: schedule.timezone,
|
|
13
|
+
paused: true,
|
|
14
|
+
});
|
|
15
|
+
try {
|
|
16
|
+
const next = cron.nextRun(after);
|
|
17
|
+
if (!next)
|
|
18
|
+
throw new Error('This schedule has no next occurrence');
|
|
19
|
+
return next.toISOString();
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
cron.stop();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** A single writer serializes admission; inference runs asynchronously and is always recorded. */
|
|
26
|
+
export class AutomationService {
|
|
27
|
+
deps;
|
|
28
|
+
active = new Map();
|
|
29
|
+
timer;
|
|
30
|
+
now;
|
|
31
|
+
constructor(deps) {
|
|
32
|
+
this.deps = deps;
|
|
33
|
+
this.now = deps.now ?? (() => new Date());
|
|
34
|
+
for (const run of deps.store.runs()) {
|
|
35
|
+
if (run.status === 'running')
|
|
36
|
+
this.finish(run, {
|
|
37
|
+
status: 'interrupted',
|
|
38
|
+
error: 'The computer restarted before this run finished. Review any saved or external output before retrying.',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
registerBuiltin(id, name, schedule, enabled = true) {
|
|
43
|
+
const previous = this.deps.store.jobs().find((job) => job.id === id);
|
|
44
|
+
const configSignature = JSON.stringify({ schedule, enabled });
|
|
45
|
+
if (previous?.configSignature === configSignature)
|
|
46
|
+
return;
|
|
47
|
+
const now = this.now().toISOString();
|
|
48
|
+
this.deps.store.saveJob({
|
|
49
|
+
id,
|
|
50
|
+
kind: 'builtin',
|
|
51
|
+
name,
|
|
52
|
+
schedule,
|
|
53
|
+
enabled,
|
|
54
|
+
configSignature,
|
|
55
|
+
catchUp: 'skip',
|
|
56
|
+
nextRunAt: nextOccurrence(schedule, this.now()),
|
|
57
|
+
createdAt: previous?.createdAt ?? now,
|
|
58
|
+
updatedAt: now,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
start() {
|
|
62
|
+
if (this.timer)
|
|
63
|
+
return;
|
|
64
|
+
const tick = () => {
|
|
65
|
+
try {
|
|
66
|
+
this.tick();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
this.deps.logger?.(`Automations: ${String(error)}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
tick();
|
|
73
|
+
this.timer = setInterval(tick, 30_000);
|
|
74
|
+
this.timer.unref();
|
|
75
|
+
}
|
|
76
|
+
async stop() {
|
|
77
|
+
clearInterval(this.timer);
|
|
78
|
+
this.timer = undefined;
|
|
79
|
+
const active = [...this.active.values()];
|
|
80
|
+
for (const entry of active)
|
|
81
|
+
entry.controller.abort();
|
|
82
|
+
await Promise.allSettled(active.map((entry) => entry.done));
|
|
83
|
+
}
|
|
84
|
+
snapshot(options = {}) {
|
|
85
|
+
const history = this.deps.store.runs();
|
|
86
|
+
const all = options.runId
|
|
87
|
+
? [this.deps.store.run(options.runId)]
|
|
88
|
+
: history.filter((run) => (!options.jobId || run.jobId === options.jobId) &&
|
|
89
|
+
(!options.before || run.id < options.before));
|
|
90
|
+
const limit = Math.min(30, Math.max(1, options.limit ?? 20));
|
|
91
|
+
return {
|
|
92
|
+
jobs: this.deps.store.jobs(),
|
|
93
|
+
runs: all.slice(0, limit).map((run) => options.runId
|
|
94
|
+
? run
|
|
95
|
+
: {
|
|
96
|
+
...run,
|
|
97
|
+
guidance: undefined,
|
|
98
|
+
tasteDraft: undefined,
|
|
99
|
+
designDraft: undefined,
|
|
100
|
+
summary: run.summary.slice(0, 4000),
|
|
101
|
+
}),
|
|
102
|
+
pendingRuns: history.flatMap((run) => (run.status === 'running' ||
|
|
103
|
+
run.status === 'needs_review' ||
|
|
104
|
+
run.status === 'failed' ||
|
|
105
|
+
run.status === 'interrupted') &&
|
|
106
|
+
!run.acknowledgedAt
|
|
107
|
+
? [
|
|
108
|
+
{
|
|
109
|
+
id: run.id,
|
|
110
|
+
jobName: run.jobName,
|
|
111
|
+
jobId: run.jobId,
|
|
112
|
+
status: run.status,
|
|
113
|
+
startedAt: run.startedAt,
|
|
114
|
+
},
|
|
115
|
+
]
|
|
116
|
+
: []),
|
|
117
|
+
...(all.length > limit ? { nextBefore: all[limit - 1].id } : {}),
|
|
118
|
+
connections: this.deps.connections(),
|
|
119
|
+
scheduledWork: this.deps.scheduledWork(),
|
|
120
|
+
computerName: this.deps.computerName,
|
|
121
|
+
supportedSources: this.deps.supportedSources?.(),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
job(id) {
|
|
125
|
+
const job = this.deps.store.jobs().find((entry) => entry.id === id);
|
|
126
|
+
if (!job)
|
|
127
|
+
throw new Error('Automation not found');
|
|
128
|
+
return job;
|
|
129
|
+
}
|
|
130
|
+
saveJob(job) {
|
|
131
|
+
this.deps.store.saveJob({ ...job, updatedAt: this.now().toISOString() });
|
|
132
|
+
this.deps.changed?.();
|
|
133
|
+
}
|
|
134
|
+
assertIdle(jobId) {
|
|
135
|
+
if (this.active.has(jobId))
|
|
136
|
+
throw new Error('This automation already has a running job. Open it or cancel it before starting another.');
|
|
137
|
+
}
|
|
138
|
+
async command(raw) {
|
|
139
|
+
const command = AutomationCommandSchema.parse(raw);
|
|
140
|
+
let runId, jobId, message;
|
|
141
|
+
if (command.action === 'save') {
|
|
142
|
+
if (command.input.repoId)
|
|
143
|
+
this.deps.validateRepo(command.input.repoId);
|
|
144
|
+
const previous = command.jobId ? this.job(command.jobId) : undefined;
|
|
145
|
+
if (previous?.kind === 'builtin')
|
|
146
|
+
throw new Error('Use schedule controls to edit a built-in job.');
|
|
147
|
+
if (previous?.input && previous.input.workflow !== command.input.workflow)
|
|
148
|
+
throw new Error('Create a separate automation to change workflow type.');
|
|
149
|
+
if (command.input.enabled) {
|
|
150
|
+
if (command.input.schedule.frequency === 'manual')
|
|
151
|
+
throw new Error('Choose a schedule before enabling recurring runs.');
|
|
152
|
+
this.deps.validateInput?.(command.input);
|
|
153
|
+
}
|
|
154
|
+
jobId = previous?.id ?? uuidv7();
|
|
155
|
+
const now = this.now().toISOString();
|
|
156
|
+
this.saveJob({
|
|
157
|
+
id: jobId,
|
|
158
|
+
kind: isDesignerInput(command.input) ? 'deck-designer' : 'agent',
|
|
159
|
+
name: command.input.name,
|
|
160
|
+
input: command.input,
|
|
161
|
+
enabled: command.input.enabled,
|
|
162
|
+
pausedUntil: command.input.enabled ? previous?.pausedUntil : undefined,
|
|
163
|
+
catchUp: command.input.catchUp,
|
|
164
|
+
schedule: command.input.schedule,
|
|
165
|
+
nextRunAt: nextOccurrence(command.input.schedule, new Date(Math.max(Date.parse(now), command.input.enabled && previous?.pausedUntil
|
|
166
|
+
? Date.parse(previous.pausedUntil)
|
|
167
|
+
: 0))),
|
|
168
|
+
createdAt: previous?.createdAt ?? now,
|
|
169
|
+
updatedAt: now,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else if (command.action === 'enable' || command.action === 'schedule') {
|
|
173
|
+
const job = this.job(command.jobId);
|
|
174
|
+
if (command.action === 'schedule') {
|
|
175
|
+
job.schedule = command.schedule;
|
|
176
|
+
if (command.schedule.frequency === 'manual') {
|
|
177
|
+
job.enabled = false;
|
|
178
|
+
if (job.input)
|
|
179
|
+
job.input.enabled = false;
|
|
180
|
+
}
|
|
181
|
+
if (job.input)
|
|
182
|
+
job.input.schedule = command.schedule;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
if (command.enabled && job.schedule.frequency === 'manual')
|
|
186
|
+
throw new Error('Choose a schedule before turning this automation on. Run now is available anytime.');
|
|
187
|
+
if (command.enabled && job.input)
|
|
188
|
+
this.deps.validateInput?.(job.input);
|
|
189
|
+
if (command.pausedUntil && new Date(command.pausedUntil) <= this.now())
|
|
190
|
+
throw new Error('Choose a pause end in the future');
|
|
191
|
+
job.enabled = command.enabled;
|
|
192
|
+
job.pausedUntil = command.pausedUntil;
|
|
193
|
+
if (job.input)
|
|
194
|
+
job.input.enabled = command.enabled;
|
|
195
|
+
}
|
|
196
|
+
job.nextRunAt = nextOccurrence(job.schedule, new Date(Math.max(this.now().getTime(), job.pausedUntil ? Date.parse(job.pausedUntil) : 0)));
|
|
197
|
+
this.saveJob(job);
|
|
198
|
+
}
|
|
199
|
+
else if (command.action === 'run') {
|
|
200
|
+
const job = this.job(command.jobId);
|
|
201
|
+
runId = this.launch(job, job.kind === 'builtin'
|
|
202
|
+
? 'builtin'
|
|
203
|
+
: job.kind === 'agent'
|
|
204
|
+
? 'agent'
|
|
205
|
+
: command.stage === 'agent'
|
|
206
|
+
? 'design'
|
|
207
|
+
: command.stage, 'manual');
|
|
208
|
+
}
|
|
209
|
+
else if (command.action === 'cancel') {
|
|
210
|
+
const run = this.deps.store.run(command.runId);
|
|
211
|
+
const active = this.active.get(run.jobId);
|
|
212
|
+
if (!active || active.runId !== run.id)
|
|
213
|
+
throw new Error('This run has already ended');
|
|
214
|
+
active.controller.abort();
|
|
215
|
+
message =
|
|
216
|
+
'Cancellation requested. Completed external edits remain available for review.';
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const run = this.deps.store.run(command.runId);
|
|
220
|
+
if (run.status === 'running')
|
|
221
|
+
throw new Error('Wait for this run to finish before reviewing it');
|
|
222
|
+
if (command.action === 'acknowledge') {
|
|
223
|
+
run.acknowledgedAt = this.now().toISOString();
|
|
224
|
+
this.deps.store.saveRun(run);
|
|
225
|
+
}
|
|
226
|
+
else if (command.action === 'review') {
|
|
227
|
+
if (command.decision === 'approve') {
|
|
228
|
+
if (!['needs_review', 'approved'].includes(run.status))
|
|
229
|
+
throw new Error('Only a completed proposal can be approved');
|
|
230
|
+
if (!['agent', 'design', 'revision'].includes(run.stage))
|
|
231
|
+
throw new Error('Choose a design proposal to approve. Save accepted taste drafts with save-guidance.');
|
|
232
|
+
if (run.stage !== 'agent' &&
|
|
233
|
+
!run.directions.some((direction) => direction.id === command.directionId))
|
|
234
|
+
throw new Error('Choose a direction from this run');
|
|
235
|
+
run.selectedDirectionId = command.directionId;
|
|
236
|
+
run.status = 'approved';
|
|
237
|
+
}
|
|
238
|
+
else
|
|
239
|
+
run.status = 'archived';
|
|
240
|
+
this.deps.store.saveRun(run);
|
|
241
|
+
}
|
|
242
|
+
else if (command.action === 'save-guidance') {
|
|
243
|
+
if (!run.tasteDraft ||
|
|
244
|
+
!run.designDraft ||
|
|
245
|
+
!['needs_review', 'approved'].includes(run.status))
|
|
246
|
+
throw new Error('This run has no guidance ready to save');
|
|
247
|
+
const saved = await this.deps.saveGuidance(run);
|
|
248
|
+
run.status = 'approved';
|
|
249
|
+
this.deps.store.saveRun(run);
|
|
250
|
+
message =
|
|
251
|
+
saved ??
|
|
252
|
+
'Saved docs/taste.md and docs/design.md in the repository. Review and commit them so other worktrees can use them.';
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
const job = this.job(run.jobId);
|
|
256
|
+
if (!run.input || job.kind === 'builtin')
|
|
257
|
+
throw new Error('This action is available for custom automations');
|
|
258
|
+
this.assertIdle(job.id);
|
|
259
|
+
if (command.action === 'implement') {
|
|
260
|
+
if (!isDesignerInput(run.input) || !run.input.repoId)
|
|
261
|
+
throw new Error('Implementation requires a UI design created with a selected project repository.');
|
|
262
|
+
if (run.status !== 'approved' || !run.selectedDirectionId)
|
|
263
|
+
throw new Error('Approve a design direction before implementation');
|
|
264
|
+
if (this.deps.store
|
|
265
|
+
.runs()
|
|
266
|
+
.some((entry) => entry.parentRunId === run.id &&
|
|
267
|
+
entry.stage === 'implementation' &&
|
|
268
|
+
!['failed', 'cancelled', 'interrupted'].includes(entry.status)))
|
|
269
|
+
throw new Error('This design already has an implementation run');
|
|
270
|
+
runId = this.launch({ ...job, input: run.input }, 'implementation', 'manual', run);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
if (run.stage === 'implementation')
|
|
274
|
+
throw new Error('Continue implementation changes on its saved branch. Revise the parent design to create a new proposal.');
|
|
275
|
+
run.feedback.push({
|
|
276
|
+
at: this.now().toISOString(),
|
|
277
|
+
text: command.feedback,
|
|
278
|
+
});
|
|
279
|
+
this.deps.store.saveRun(run);
|
|
280
|
+
runId = this.launch({ ...job, input: run.input }, run.stage === 'agent'
|
|
281
|
+
? 'agent'
|
|
282
|
+
: run.stage === 'taste'
|
|
283
|
+
? 'taste'
|
|
284
|
+
: 'revision', 'manual', run);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
this.deps.changed?.();
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
...this.snapshot(),
|
|
291
|
+
...(runId ? { runId } : {}),
|
|
292
|
+
...(jobId ? { jobId } : {}),
|
|
293
|
+
...(message ? { message } : {}),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
tick() {
|
|
297
|
+
const now = this.now();
|
|
298
|
+
for (const job of this.deps.store.jobs()) {
|
|
299
|
+
if (!this.deps.scheduledWork() && job.id !== 'builtin:prune')
|
|
300
|
+
continue;
|
|
301
|
+
if (!job.enabled || (job.pausedUntil && new Date(job.pausedUntil) > now))
|
|
302
|
+
continue;
|
|
303
|
+
if (job.schedule.frequency === 'manual')
|
|
304
|
+
continue;
|
|
305
|
+
if (!job.nextRunAt) {
|
|
306
|
+
this.saveJob({ ...job, nextRunAt: nextOccurrence(job.schedule, now) });
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (new Date(job.nextRunAt) > now)
|
|
310
|
+
continue;
|
|
311
|
+
const late = now.getTime() - Date.parse(job.nextRunAt) > 90_000;
|
|
312
|
+
// Claim the scheduled occurrence before inference. A crash never replays it.
|
|
313
|
+
this.saveJob({
|
|
314
|
+
...job,
|
|
315
|
+
pausedUntil: undefined,
|
|
316
|
+
nextRunAt: nextOccurrence(job.schedule, now),
|
|
317
|
+
});
|
|
318
|
+
if (this.active.has(job.id) || (late && job.catchUp === 'skip')) {
|
|
319
|
+
const at = now.toISOString();
|
|
320
|
+
this.deps.store.saveRun({
|
|
321
|
+
id: uuidv7(),
|
|
322
|
+
jobId: job.id,
|
|
323
|
+
jobName: job.name,
|
|
324
|
+
stage: job.kind === 'builtin'
|
|
325
|
+
? 'builtin'
|
|
326
|
+
: job.kind === 'agent'
|
|
327
|
+
? 'agent'
|
|
328
|
+
: 'design',
|
|
329
|
+
trigger: 'scheduled',
|
|
330
|
+
status: 'skipped',
|
|
331
|
+
startedAt: at,
|
|
332
|
+
finishedAt: at,
|
|
333
|
+
summary: this.active.has(job.id)
|
|
334
|
+
? 'Previous run is still active.'
|
|
335
|
+
: 'Scheduled time was missed while the computer was unavailable. Catch-up is disabled.',
|
|
336
|
+
directions: [],
|
|
337
|
+
feedback: [],
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
else
|
|
341
|
+
this.launch(job, job.kind === 'builtin'
|
|
342
|
+
? 'builtin'
|
|
343
|
+
: job.kind === 'agent'
|
|
344
|
+
? 'agent'
|
|
345
|
+
: 'design', late ? 'catch-up' : 'scheduled');
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
launch(job, stage, trigger, parent) {
|
|
349
|
+
this.assertIdle(job.id);
|
|
350
|
+
const run = {
|
|
351
|
+
id: uuidv7(),
|
|
352
|
+
jobId: job.id,
|
|
353
|
+
jobName: job.name,
|
|
354
|
+
stage,
|
|
355
|
+
trigger,
|
|
356
|
+
status: 'running',
|
|
357
|
+
startedAt: this.now().toISOString(),
|
|
358
|
+
summary: 'Starting…',
|
|
359
|
+
input: job.input,
|
|
360
|
+
parentRunId: parent?.id,
|
|
361
|
+
feedback: parent?.feedback ?? [],
|
|
362
|
+
directions: stage === 'implementation' ? (parent?.directions ?? []) : [],
|
|
363
|
+
selectedDirectionId: stage === 'implementation' ? parent?.selectedDirectionId : undefined,
|
|
364
|
+
};
|
|
365
|
+
this.deps.store.saveRun(run);
|
|
366
|
+
const controller = new AbortController();
|
|
367
|
+
// Microtask admission makes the active marker visible before any executor can finish.
|
|
368
|
+
const done = Promise.resolve()
|
|
369
|
+
.then(async () => {
|
|
370
|
+
try {
|
|
371
|
+
const result = await this.deps.execute(job, run, controller.signal);
|
|
372
|
+
this.finish(run, controller.signal.aborted
|
|
373
|
+
? { ...result, status: 'cancelled' }
|
|
374
|
+
: result);
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
this.finish(run, {
|
|
378
|
+
status: controller.signal.aborted ? 'cancelled' : 'failed',
|
|
379
|
+
error: error instanceof Error ? error.message : String(error),
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
this.active.delete(job.id);
|
|
384
|
+
this.deps.changed?.();
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
.catch((error) => {
|
|
388
|
+
this.deps.logger?.(`Could not persist automation result ${run.id}: ${String(error)}`);
|
|
389
|
+
});
|
|
390
|
+
this.active.set(job.id, { runId: run.id, controller, done });
|
|
391
|
+
this.deps.changed?.();
|
|
392
|
+
return run.id;
|
|
393
|
+
}
|
|
394
|
+
finish(run, patch) {
|
|
395
|
+
const finishedAt = this.now().toISOString();
|
|
396
|
+
this.deps.store.saveRun({
|
|
397
|
+
...run,
|
|
398
|
+
status: 'completed',
|
|
399
|
+
...patch,
|
|
400
|
+
id: run.id,
|
|
401
|
+
jobId: run.jobId,
|
|
402
|
+
finishedAt,
|
|
403
|
+
durationMs: Date.parse(finishedAt) - Date.parse(run.startedAt),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/automations/setup.ts"],"names":[],"mappings":"AAMA,kFAAkF;AAClF,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,iBA+D/C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { clientCommand } from '../mcp/clients.js';
|
|
5
|
+
import { CONFIG_DIR } from '../config.js';
|
|
6
|
+
/** Explicit interactive setup; never launched by a scheduled job or the phone. */
|
|
7
|
+
export async function setupDesign(args) {
|
|
8
|
+
if (args.includes('--help')) {
|
|
9
|
+
process.stdout.write('lucidity setup-design\nConnect Figma through the bundled Codex OAuth client and save the daemon’s design connection.\nFor Claude or an authenticated Pinterest server, see docs/deck-designer.md.\n');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const path = join(CONFIG_DIR, 'design-mcp.json');
|
|
13
|
+
const config = existsSync(path)
|
|
14
|
+
? JSON.parse(readFileSync(path, 'utf8'))
|
|
15
|
+
: { mcpServers: {} };
|
|
16
|
+
const server = config.mcpServers?.figma;
|
|
17
|
+
if (server &&
|
|
18
|
+
(server.type !== 'http' || server.url !== 'https://mcp.figma.com/mcp'))
|
|
19
|
+
throw new Error('A custom Figma connection already exists. Keep it or edit design-mcp.json explicitly before using this setup.');
|
|
20
|
+
const cli = clientCommand('codex');
|
|
21
|
+
const run = (argv, capture = false) => new Promise((resolve, reject) => {
|
|
22
|
+
const child = spawn(cli.command, [...cli.prefix, ...argv], {
|
|
23
|
+
stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit',
|
|
24
|
+
});
|
|
25
|
+
let output = '';
|
|
26
|
+
child.stdout?.on('data', (data) => {
|
|
27
|
+
output += data;
|
|
28
|
+
});
|
|
29
|
+
child.on('error', () => reject(new Error('Could not start the bundled Codex client')));
|
|
30
|
+
child.on('exit', (code) => code === 0
|
|
31
|
+
? resolve(output)
|
|
32
|
+
: reject(new Error('Figma setup did not complete. Existing credentials and jobs were preserved.')));
|
|
33
|
+
});
|
|
34
|
+
const servers = JSON.parse(await run(['mcp', 'list', '--json'], true));
|
|
35
|
+
const existing = servers.find((entry) => entry.name === 'figma');
|
|
36
|
+
if (existing && existing.transport?.url !== 'https://mcp.figma.com/mcp')
|
|
37
|
+
throw new Error('Codex already has a different server named figma. Resolve that name explicitly before connecting.');
|
|
38
|
+
if (!existing)
|
|
39
|
+
await run(['mcp', 'add', 'figma', '--url', 'https://mcp.figma.com/mcp']);
|
|
40
|
+
await run(['mcp', 'login', 'figma']);
|
|
41
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
42
|
+
config.mcpServers = {
|
|
43
|
+
...config.mcpServers,
|
|
44
|
+
figma: server ?? { type: 'http', url: 'https://mcp.figma.com/mcp' },
|
|
45
|
+
};
|
|
46
|
+
writeFileSync(path, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
|
|
47
|
+
process.stdout.write('Figma is configured for Codex design runs. In Lucidity, open Automations, save your board and Figma links, and run Study my taste.\n');
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/automations/skill.ts"],"names":[],"mappings":"AAIA,qFAAqF;AACrF,wBAAgB,sBAAsB,CACpC,MAAM,GAAE,MAAe,EACvB,IAAI,SAAgB,YAgCrB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
/** Project-scoped installation is explicit and never replaces a customized skill. */
|
|
5
|
+
export function installAutomationSkill(client = 'both', root = process.cwd()) {
|
|
6
|
+
if (!['claude', 'codex', 'both'].includes(client))
|
|
7
|
+
throw new Error('Use lucidity automations install-skill [claude|codex|both] from your project directory.');
|
|
8
|
+
const directory = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const source = [
|
|
10
|
+
join(directory, '../skills/lucidity-automations/SKILL.md'),
|
|
11
|
+
join(directory, '../../skills/lucidity-automations/SKILL.md'),
|
|
12
|
+
].find(existsSync);
|
|
13
|
+
if (!source)
|
|
14
|
+
throw new Error('This installation is missing the automation skill. Reinstall Lucidity.');
|
|
15
|
+
const content = readFileSync(source, 'utf8');
|
|
16
|
+
const targets = (client === 'both'
|
|
17
|
+
? ['.agents', '.claude']
|
|
18
|
+
: [client === 'codex' ? '.agents' : '.claude']).map((folder) => join(root, folder, 'skills/lucidity-automations/SKILL.md'));
|
|
19
|
+
for (const target of targets)
|
|
20
|
+
if (existsSync(target) && readFileSync(target, 'utf8') !== content)
|
|
21
|
+
throw new Error(`A customized skill exists at ${target}. Keep it or update it explicitly; it was not replaced.`);
|
|
22
|
+
for (const target of targets) {
|
|
23
|
+
if (existsSync(target))
|
|
24
|
+
continue;
|
|
25
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
26
|
+
writeFileSync(target, content, { flag: 'wx' });
|
|
27
|
+
}
|
|
28
|
+
return targets;
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type AutomationJob, type AutomationRun } from '@lucidity/shared';
|
|
2
|
+
/** Only the daemon writes this store; CLI and phone go through its authenticated gateway. */
|
|
3
|
+
export declare class AutomationStore {
|
|
4
|
+
readonly directory: string;
|
|
5
|
+
constructor(directory: string);
|
|
6
|
+
private write;
|
|
7
|
+
jobs(): AutomationJob[];
|
|
8
|
+
saveJob(job: AutomationJob): void;
|
|
9
|
+
run(id: string): AutomationRun;
|
|
10
|
+
saveRun(run: AutomationRun): void;
|
|
11
|
+
runs(): AutomationRun[];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/automations/store.ts"],"names":[],"mappings":"AASA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAE1B,6FAA6F;AAC7F,qBAAa,eAAe;IACd,QAAQ,CAAC,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;IAGtC,OAAO,CAAC,KAAK;IAKb,IAAI,IAAI,aAAa,EAAE;IAQvB,OAAO,CAAC,GAAG,EAAE,aAAa;IAO1B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa;IAQ9B,OAAO,CAAC,GAAG,EAAE,aAAa;IAO1B,IAAI,IAAI,aAAa,EAAE;CAMxB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync, } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { AutomationJobSchema, AutomationRunSchema, } from '@lucidity/shared';
|
|
4
|
+
/** Only the daemon writes this store; CLI and phone go through its authenticated gateway. */
|
|
5
|
+
export class AutomationStore {
|
|
6
|
+
directory;
|
|
7
|
+
constructor(directory) {
|
|
8
|
+
this.directory = directory;
|
|
9
|
+
mkdirSync(join(directory, 'runs'), { recursive: true, mode: 0o700 });
|
|
10
|
+
}
|
|
11
|
+
write(path, value) {
|
|
12
|
+
const temporary = `${path}.tmp`;
|
|
13
|
+
writeFileSync(temporary, JSON.stringify(value, null, 2), { mode: 0o600 });
|
|
14
|
+
renameSync(temporary, path);
|
|
15
|
+
}
|
|
16
|
+
jobs() {
|
|
17
|
+
const path = join(this.directory, 'jobs.json');
|
|
18
|
+
if (!existsSync(path))
|
|
19
|
+
return [];
|
|
20
|
+
// Corruption must be surfaced, never mistaken for an empty store and overwritten.
|
|
21
|
+
return AutomationJobSchema.array().parse(JSON.parse(readFileSync(path, 'utf8')));
|
|
22
|
+
}
|
|
23
|
+
saveJob(job) {
|
|
24
|
+
const jobs = this.jobs();
|
|
25
|
+
this.write(join(this.directory, 'jobs.json'), [
|
|
26
|
+
...jobs.filter((row) => row.id !== job.id),
|
|
27
|
+
AutomationJobSchema.parse(job),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
run(id) {
|
|
31
|
+
if (!/^[a-zA-Z0-9-]+$/.test(id))
|
|
32
|
+
throw new Error('Invalid run ID');
|
|
33
|
+
return AutomationRunSchema.parse(JSON.parse(readFileSync(join(this.directory, 'runs', `${id}.json`), 'utf8')));
|
|
34
|
+
}
|
|
35
|
+
saveRun(run) {
|
|
36
|
+
if (!/^[a-zA-Z0-9-]+$/.test(run.id))
|
|
37
|
+
throw new Error('Invalid run ID');
|
|
38
|
+
this.write(join(this.directory, 'runs', `${run.id}.json`), AutomationRunSchema.parse(run));
|
|
39
|
+
}
|
|
40
|
+
runs() {
|
|
41
|
+
return readdirSync(join(this.directory, 'runs'))
|
|
42
|
+
.filter((name) => name.endsWith('.json'))
|
|
43
|
+
.map((name) => this.run(name.slice(0, -5)))
|
|
44
|
+
.sort((a, b) => b.id.localeCompare(a.id));
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/chat/server.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { type AgentExecutor } from '@lucidity/runtime';
|
|
|
3
3
|
import type { DaemonConfig, ChatAgentWiring } from '../config.js';
|
|
4
4
|
import { LaneQueue } from '../queue.js';
|
|
5
5
|
import type { McpWiring } from '../mcp/config.js';
|
|
6
|
+
import type { AutomationService } from '../automations/service.js';
|
|
6
7
|
export interface ChatServerDeps {
|
|
8
|
+
automations?: AutomationService;
|
|
7
9
|
config: DaemonConfig;
|
|
8
10
|
executor: AgentExecutor;
|
|
9
11
|
token: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/chat/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/chat/server.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,MAAM,EAEZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAKL,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,uEAAuE;IACvE,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,qFAAqF;IACrF,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAiBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CA+N7D"}
|
package/dist/chat/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { privateJournalBackend } from '@lucidity/notes';
|
|
1
2
|
import { createServer, } from 'node:http';
|
|
2
3
|
import { randomUUID } from 'node:crypto';
|
|
3
4
|
import { buildChatSystemPrompt, buildChatToolsNote, createApiClient, loadJournalContext, } from '@lucidity/runtime';
|
|
@@ -9,6 +10,10 @@ function readBody(req) {
|
|
|
9
10
|
let data = '';
|
|
10
11
|
req.on('data', (c) => {
|
|
11
12
|
data += c;
|
|
13
|
+
if (data.length > 128_000) {
|
|
14
|
+
reject(new Error('Request body too large'));
|
|
15
|
+
req.destroy();
|
|
16
|
+
}
|
|
12
17
|
});
|
|
13
18
|
req.on('end', () => resolve(data));
|
|
14
19
|
req.on('error', reject);
|
|
@@ -38,7 +43,8 @@ export function createChatServer(deps) {
|
|
|
38
43
|
res.end(JSON.stringify({ ok: true }));
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
41
|
-
if (req.method !== 'POST' ||
|
|
46
|
+
if (req.method !== 'POST' ||
|
|
47
|
+
!['/chat', '/automations'].includes(req.url ?? '')) {
|
|
42
48
|
res.writeHead(404);
|
|
43
49
|
res.end('not found');
|
|
44
50
|
return;
|
|
@@ -48,6 +54,39 @@ export function createChatServer(deps) {
|
|
|
48
54
|
res.end(JSON.stringify({ error: 'unauthorized' }));
|
|
49
55
|
return;
|
|
50
56
|
}
|
|
57
|
+
if (req.url === '/automations') {
|
|
58
|
+
res.setHeader('Content-Type', 'application/json');
|
|
59
|
+
if (!deps.automations) {
|
|
60
|
+
res.writeHead(503);
|
|
61
|
+
res.end(JSON.stringify({
|
|
62
|
+
error: 'Automations are unavailable on this daemon',
|
|
63
|
+
}));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const body = JSON.parse(await readBody(req));
|
|
68
|
+
// The same shared wire contract validates HTTP and room callers.
|
|
69
|
+
const { HarnessRequestSchema } = await import('@lucidity/shared');
|
|
70
|
+
const { uuidv7 } = await import('uuidv7');
|
|
71
|
+
const request = HarnessRequestSchema.parse({ ...body, id: uuidv7() });
|
|
72
|
+
if (request.kind !== 'getAutomations' && request.kind !== 'automation')
|
|
73
|
+
throw new Error('Expected an automation request');
|
|
74
|
+
const snapshot = request.kind === 'getAutomations'
|
|
75
|
+
? deps.automations.snapshot(request)
|
|
76
|
+
: await deps.automations.command(request.command);
|
|
77
|
+
res.writeHead(200);
|
|
78
|
+
res.end(JSON.stringify(snapshot));
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
res.writeHead(400);
|
|
82
|
+
res.end(JSON.stringify({
|
|
83
|
+
error: error instanceof Error
|
|
84
|
+
? error.message
|
|
85
|
+
: 'Invalid automation request',
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
51
90
|
let parsed;
|
|
52
91
|
try {
|
|
53
92
|
parsed = JSON.parse(await readBody(req));
|
|
@@ -147,7 +186,11 @@ export function createChatServer(deps) {
|
|
|
147
186
|
// The journal read is keyed on the message, so a question about the sauna project
|
|
148
187
|
// pulls the days that mention it rather than only the last three. Failure here is
|
|
149
188
|
// deliberately non-fatal — a chat turn without journal memory is worse, not broken.
|
|
150
|
-
|
|
189
|
+
const journalBackend = await privateJournalBackend((path) => api.request(path), config.notesPath);
|
|
190
|
+
journal = (await loadJournalContext(api, {
|
|
191
|
+
query: message,
|
|
192
|
+
backend: journalBackend,
|
|
193
|
+
}))?.text;
|
|
151
194
|
if (tasks.length)
|
|
152
195
|
context = `Today/overdue tasks: ${tasks
|
|
153
196
|
.map((t) => t.title)
|
|
@@ -160,6 +203,7 @@ export function createChatServer(deps) {
|
|
|
160
203
|
const tools = buildChatToolsNote(name, !!mcp, {
|
|
161
204
|
tasks: config.capabilities.tasks,
|
|
162
205
|
memory: config.capabilities.memory,
|
|
206
|
+
automations: config.capabilities.automations,
|
|
163
207
|
}, chatAgent ? { cwd: chatAgent.cwd } : undefined);
|
|
164
208
|
const systemPrompt = buildChatSystemPrompt({
|
|
165
209
|
user: { name },
|