@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,32 @@
|
|
|
1
|
+
import type { ChoiceAnswer } from './types.js';
|
|
2
|
+
|
|
3
|
+
/** Thresholds must be evaluated for each task. Acceptance is never permission to act. */
|
|
4
|
+
export function gateDecision<T extends string>(
|
|
5
|
+
answer: ChoiceAnswer<T>,
|
|
6
|
+
options: { minConfidence: number; abstain: readonly T[] },
|
|
7
|
+
):
|
|
8
|
+
| { accepted: true; choice: T }
|
|
9
|
+
| {
|
|
10
|
+
accepted: false;
|
|
11
|
+
reason: 'unclear' | 'missing_confidence' | 'low_confidence';
|
|
12
|
+
} {
|
|
13
|
+
if (
|
|
14
|
+
!Number.isFinite(options.minConfidence) ||
|
|
15
|
+
options.minConfidence < 0 ||
|
|
16
|
+
options.minConfidence > 1
|
|
17
|
+
) {
|
|
18
|
+
throw new Error('Decision confidence threshold must be between 0 and 1.');
|
|
19
|
+
}
|
|
20
|
+
if (options.abstain.includes(answer.choice))
|
|
21
|
+
return { accepted: false, reason: 'unclear' };
|
|
22
|
+
if (answer.confidence === undefined)
|
|
23
|
+
return { accepted: false, reason: 'missing_confidence' };
|
|
24
|
+
if (
|
|
25
|
+
!Number.isFinite(answer.confidence) ||
|
|
26
|
+
answer.confidence < options.minConfidence ||
|
|
27
|
+
answer.confidence > 1
|
|
28
|
+
) {
|
|
29
|
+
return { accepted: false, reason: 'low_confidence' };
|
|
30
|
+
}
|
|
31
|
+
return { accepted: true, choice: answer.choice };
|
|
32
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnswerFor,
|
|
3
|
+
DecisionClient,
|
|
4
|
+
DecisionFailureReason,
|
|
5
|
+
DecisionQuestion,
|
|
6
|
+
DecisionRequest,
|
|
7
|
+
DecisionResult,
|
|
8
|
+
} from './types.js';
|
|
9
|
+
|
|
10
|
+
export const JEV_MODEL = 'typesafe-ai/jev';
|
|
11
|
+
const ENDPOINT = 'https://ai-gateway.vercel.sh/v1/evaluate';
|
|
12
|
+
export const DEFAULT_DECISION_TIMEOUT_MS = 2_000;
|
|
13
|
+
|
|
14
|
+
type ObjectValue = Record<string, unknown>;
|
|
15
|
+
function object(value: unknown): value is ObjectValue {
|
|
16
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
function probability(value: unknown): value is number {
|
|
19
|
+
return (
|
|
20
|
+
typeof value === 'number' &&
|
|
21
|
+
Number.isFinite(value) &&
|
|
22
|
+
value >= 0 &&
|
|
23
|
+
value <= 1
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function nonnegative(value: unknown): value is number {
|
|
27
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
28
|
+
}
|
|
29
|
+
function money(value: unknown): number | undefined {
|
|
30
|
+
if (typeof value !== 'string' && typeof value !== 'number') return;
|
|
31
|
+
if (typeof value === 'string' && !/^\d+(\.\d+)?$/.test(value)) return;
|
|
32
|
+
const parsed = Number(value);
|
|
33
|
+
return nonnegative(parsed) ? parsed : undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function distribution(
|
|
37
|
+
value: unknown,
|
|
38
|
+
options: string[],
|
|
39
|
+
): value is Record<string, number> {
|
|
40
|
+
if (!object(value) || Object.keys(value).length !== options.length)
|
|
41
|
+
return false;
|
|
42
|
+
if (
|
|
43
|
+
!options.every(
|
|
44
|
+
(key) => Object.hasOwn(value, key) && probability(value[key]),
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
return false;
|
|
48
|
+
// Allow provider rounding, but reject incomplete/invalid distributions.
|
|
49
|
+
const sum = options.reduce((total, key) => total + (value[key] as number), 0);
|
|
50
|
+
return Math.abs(sum - 1) <= 0.02;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function validQuestions(questions: Record<string, DecisionQuestion>): boolean {
|
|
54
|
+
if (!object(questions) || Object.keys(questions).length === 0) return false;
|
|
55
|
+
return Object.values(questions).every((question) => {
|
|
56
|
+
if (
|
|
57
|
+
!object(question) ||
|
|
58
|
+
typeof question.instructions !== 'string' ||
|
|
59
|
+
!question.instructions.trim()
|
|
60
|
+
)
|
|
61
|
+
return false;
|
|
62
|
+
if (question.type === 'boolean') return true;
|
|
63
|
+
if (question.type === 'choice') {
|
|
64
|
+
return (
|
|
65
|
+
object(question.criteria) &&
|
|
66
|
+
Object.keys(question.criteria).length >= 2 &&
|
|
67
|
+
Object.keys(question.criteria).length <= 255 &&
|
|
68
|
+
Object.entries(question.criteria).every(
|
|
69
|
+
([key, value]) =>
|
|
70
|
+
key.length > 0 &&
|
|
71
|
+
typeof value === 'string' &&
|
|
72
|
+
value.trim().length > 0,
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return (
|
|
77
|
+
question.type === 'score' &&
|
|
78
|
+
Array.isArray(question.criteria) &&
|
|
79
|
+
question.criteria.length >= 2 &&
|
|
80
|
+
question.criteria.length <= 10 &&
|
|
81
|
+
question.criteria.every(
|
|
82
|
+
(level) => typeof level === 'string' && level.trim().length > 0,
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function parseAnswers<Q extends Record<string, DecisionQuestion>>(
|
|
89
|
+
body: ObjectValue,
|
|
90
|
+
questions: Q,
|
|
91
|
+
) {
|
|
92
|
+
if (!object(body.answers)) return;
|
|
93
|
+
const metadata = object(body.providerMetadata) ? body.providerMetadata : {};
|
|
94
|
+
const typesafe = object(metadata.typesafe) ? metadata.typesafe : {};
|
|
95
|
+
const confidence = object(typesafe.confidence) ? typesafe.confidence : {};
|
|
96
|
+
const entries: [string, unknown][] = [];
|
|
97
|
+
for (const [key, question] of Object.entries(questions)) {
|
|
98
|
+
const answer = body.answers[key];
|
|
99
|
+
if (
|
|
100
|
+
!Object.hasOwn(body.answers, key) ||
|
|
101
|
+
!object(answer) ||
|
|
102
|
+
answer.type !== question.type
|
|
103
|
+
)
|
|
104
|
+
return;
|
|
105
|
+
if (question.type === 'boolean') {
|
|
106
|
+
if (!probability(answer.probability)) return;
|
|
107
|
+
entries.push([key, { type: 'boolean', probability: answer.probability }]);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const direct = answer.confidence;
|
|
111
|
+
const extra = Object.hasOwn(confidence, key) ? confidence[key] : undefined;
|
|
112
|
+
if (
|
|
113
|
+
(direct !== undefined && !probability(direct)) ||
|
|
114
|
+
(extra !== undefined && !probability(extra))
|
|
115
|
+
)
|
|
116
|
+
return;
|
|
117
|
+
if (
|
|
118
|
+
direct !== undefined &&
|
|
119
|
+
extra !== undefined &&
|
|
120
|
+
Math.abs((direct as number) - (extra as number)) > 0.000001
|
|
121
|
+
)
|
|
122
|
+
return;
|
|
123
|
+
const certainty = direct ?? extra;
|
|
124
|
+
const common = certainty === undefined ? {} : { confidence: certainty };
|
|
125
|
+
if (question.type === 'choice') {
|
|
126
|
+
if (
|
|
127
|
+
typeof answer.choice !== 'string' ||
|
|
128
|
+
!Object.hasOwn(question.criteria, answer.choice) ||
|
|
129
|
+
!distribution(answer.probabilities, Object.keys(question.criteria))
|
|
130
|
+
)
|
|
131
|
+
return;
|
|
132
|
+
entries.push([
|
|
133
|
+
key,
|
|
134
|
+
{
|
|
135
|
+
type: 'choice',
|
|
136
|
+
choice: answer.choice,
|
|
137
|
+
probabilities: answer.probabilities,
|
|
138
|
+
...common,
|
|
139
|
+
},
|
|
140
|
+
]);
|
|
141
|
+
} else {
|
|
142
|
+
const levels = question.criteria.map((_, index) => String(index));
|
|
143
|
+
if (
|
|
144
|
+
!nonnegative(answer.score) ||
|
|
145
|
+
answer.score > question.criteria.length - 1 ||
|
|
146
|
+
!distribution(answer.probabilities, levels)
|
|
147
|
+
)
|
|
148
|
+
return;
|
|
149
|
+
entries.push([
|
|
150
|
+
key,
|
|
151
|
+
{
|
|
152
|
+
type: 'score',
|
|
153
|
+
score: answer.score,
|
|
154
|
+
probabilities: answer.probabilities,
|
|
155
|
+
...common,
|
|
156
|
+
},
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return Object.fromEntries(entries) as { [K in keyof Q]: AnswerFor<Q[K]> };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function httpFailure(status: number, body: unknown): DecisionFailureReason {
|
|
164
|
+
const error = object(body) && object(body.error) ? body.error : {};
|
|
165
|
+
if (error.type === 'customer_verification_required' || status === 402)
|
|
166
|
+
return 'billing';
|
|
167
|
+
if (status === 401 || status === 403) return 'authentication';
|
|
168
|
+
if (status === 400 || status === 422) return 'invalid_request';
|
|
169
|
+
if (status === 429) return 'rate_limit';
|
|
170
|
+
return 'unavailable';
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface JevDecisionClientOptions {
|
|
174
|
+
apiKey: string;
|
|
175
|
+
timeoutMs?: number;
|
|
176
|
+
/** Test seam. Production calls always use the fixed HTTPS Gateway endpoint. */
|
|
177
|
+
fetch?: typeof fetch;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** A single bounded attempt. The caller owns fallback and any eventual action. */
|
|
181
|
+
export class JevDecisionClient implements DecisionClient {
|
|
182
|
+
#apiKey: string;
|
|
183
|
+
#fetch: typeof fetch;
|
|
184
|
+
#timeoutMs: number;
|
|
185
|
+
|
|
186
|
+
constructor(options: JevDecisionClientOptions) {
|
|
187
|
+
this.#apiKey = options.apiKey.trim();
|
|
188
|
+
this.#fetch = options.fetch ?? fetch;
|
|
189
|
+
this.#timeoutMs = options.timeoutMs ?? DEFAULT_DECISION_TIMEOUT_MS;
|
|
190
|
+
if (!this.#apiKey || /[\r\n]/.test(this.#apiKey))
|
|
191
|
+
throw new Error('A valid AI Gateway key is required.');
|
|
192
|
+
if (
|
|
193
|
+
!Number.isInteger(this.#timeoutMs) ||
|
|
194
|
+
this.#timeoutMs < 1 ||
|
|
195
|
+
this.#timeoutMs > 30_000
|
|
196
|
+
) {
|
|
197
|
+
throw new Error('Decision timeout must be between 1 and 30000 ms.');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async evaluate<Q extends Record<string, DecisionQuestion>>(
|
|
202
|
+
request: DecisionRequest<Q>,
|
|
203
|
+
): Promise<DecisionResult<Q>> {
|
|
204
|
+
const start = performance.now();
|
|
205
|
+
const elapsed = () => Math.round(performance.now() - start);
|
|
206
|
+
const fail = (
|
|
207
|
+
reason: DecisionFailureReason,
|
|
208
|
+
status?: number,
|
|
209
|
+
): DecisionResult<Q> => ({
|
|
210
|
+
ok: false,
|
|
211
|
+
reason,
|
|
212
|
+
elapsedMs: elapsed(),
|
|
213
|
+
...(status === undefined ? {} : { status }),
|
|
214
|
+
});
|
|
215
|
+
if (request.signal?.aborted) return fail('cancelled');
|
|
216
|
+
let payload: string;
|
|
217
|
+
try {
|
|
218
|
+
if (!validQuestions(request.questions) || request.state === undefined)
|
|
219
|
+
return fail('invalid_request');
|
|
220
|
+
payload = JSON.stringify({
|
|
221
|
+
model: JEV_MODEL,
|
|
222
|
+
state: request.state,
|
|
223
|
+
questions: request.questions,
|
|
224
|
+
});
|
|
225
|
+
// Byte guard, not a token estimate. Reject oversized state instead of silently truncating it.
|
|
226
|
+
if (new TextEncoder().encode(payload).length > 128_000)
|
|
227
|
+
return fail('invalid_request');
|
|
228
|
+
} catch {
|
|
229
|
+
return fail('invalid_request');
|
|
230
|
+
}
|
|
231
|
+
const controller = new AbortController();
|
|
232
|
+
const cancel = () => controller.abort();
|
|
233
|
+
request.signal?.addEventListener('abort', cancel, { once: true });
|
|
234
|
+
let timedOut = false;
|
|
235
|
+
const timer = setTimeout(() => {
|
|
236
|
+
timedOut = true;
|
|
237
|
+
controller.abort();
|
|
238
|
+
}, this.#timeoutMs);
|
|
239
|
+
try {
|
|
240
|
+
const response = await this.#fetch(ENDPOINT, {
|
|
241
|
+
method: 'POST',
|
|
242
|
+
headers: {
|
|
243
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
244
|
+
'Content-Type': 'application/json',
|
|
245
|
+
},
|
|
246
|
+
body: payload,
|
|
247
|
+
signal: controller.signal,
|
|
248
|
+
redirect: 'error',
|
|
249
|
+
});
|
|
250
|
+
const body: unknown = await response.json().catch(() => undefined);
|
|
251
|
+
if (request.signal?.aborted) return fail('cancelled');
|
|
252
|
+
if (timedOut) return fail('timeout');
|
|
253
|
+
if (!response.ok)
|
|
254
|
+
return fail(httpFailure(response.status, body), response.status);
|
|
255
|
+
if (!object(body) || body.model !== JEV_MODEL)
|
|
256
|
+
return fail('invalid_response');
|
|
257
|
+
const answers = parseAnswers(body, request.questions);
|
|
258
|
+
if (!answers) return fail('invalid_response');
|
|
259
|
+
const meta = object(body.providerMetadata) ? body.providerMetadata : {};
|
|
260
|
+
const gateway = object(meta.gateway) ? meta.gateway : {};
|
|
261
|
+
const usage =
|
|
262
|
+
object(body.usage) &&
|
|
263
|
+
nonnegative(body.usage.inputTokens) &&
|
|
264
|
+
nonnegative(body.usage.outputTokens)
|
|
265
|
+
? {
|
|
266
|
+
inputTokens: body.usage.inputTokens,
|
|
267
|
+
outputTokens: body.usage.outputTokens,
|
|
268
|
+
}
|
|
269
|
+
: undefined;
|
|
270
|
+
return {
|
|
271
|
+
ok: true,
|
|
272
|
+
answers,
|
|
273
|
+
model: JEV_MODEL,
|
|
274
|
+
elapsedMs: elapsed(),
|
|
275
|
+
usage,
|
|
276
|
+
costUsd: money(gateway.cost),
|
|
277
|
+
marketCostUsd: money(gateway.marketCost),
|
|
278
|
+
};
|
|
279
|
+
} catch {
|
|
280
|
+
// Never propagate provider bodies, request state, headers, or credential-bearing exceptions.
|
|
281
|
+
return fail(
|
|
282
|
+
request.signal?.aborted
|
|
283
|
+
? 'cancelled'
|
|
284
|
+
: timedOut
|
|
285
|
+
? 'timeout'
|
|
286
|
+
: 'unavailable',
|
|
287
|
+
);
|
|
288
|
+
} finally {
|
|
289
|
+
clearTimeout(timer);
|
|
290
|
+
request.signal?.removeEventListener('abort', cancel);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type DecisionState =
|
|
2
|
+
| string
|
|
3
|
+
| number
|
|
4
|
+
| boolean
|
|
5
|
+
| null
|
|
6
|
+
| DecisionState[]
|
|
7
|
+
| { [key: string]: DecisionState };
|
|
8
|
+
|
|
9
|
+
export type DecisionQuestion =
|
|
10
|
+
| { type: 'choice'; instructions: string; criteria: Record<string, string> }
|
|
11
|
+
| { type: 'boolean'; instructions: string }
|
|
12
|
+
| { type: 'score'; instructions: string; criteria: readonly string[] };
|
|
13
|
+
|
|
14
|
+
export interface ChoiceAnswer<T extends string = string> {
|
|
15
|
+
type: 'choice';
|
|
16
|
+
choice: T;
|
|
17
|
+
probabilities: Record<T, number>;
|
|
18
|
+
/** Provider statistic, distinct from the selected option's probability. */
|
|
19
|
+
confidence?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ScoreAnswer {
|
|
23
|
+
type: 'score';
|
|
24
|
+
score: number;
|
|
25
|
+
probabilities: Record<string, number>;
|
|
26
|
+
confidence?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface BooleanAnswer {
|
|
30
|
+
type: 'boolean';
|
|
31
|
+
probability: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type AnswerFor<Q extends DecisionQuestion> = Q extends { type: 'choice' }
|
|
35
|
+
? ChoiceAnswer<Extract<keyof Q['criteria'], string>>
|
|
36
|
+
: Q extends { type: 'score' }
|
|
37
|
+
? ScoreAnswer
|
|
38
|
+
: BooleanAnswer;
|
|
39
|
+
|
|
40
|
+
export interface DecisionRequest<Q extends Record<string, DecisionQuestion>> {
|
|
41
|
+
state: DecisionState;
|
|
42
|
+
questions: Q;
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type DecisionFailureReason =
|
|
47
|
+
| 'invalid_request'
|
|
48
|
+
| 'authentication'
|
|
49
|
+
| 'billing'
|
|
50
|
+
| 'rate_limit'
|
|
51
|
+
| 'unavailable'
|
|
52
|
+
| 'invalid_response'
|
|
53
|
+
| 'timeout'
|
|
54
|
+
| 'cancelled';
|
|
55
|
+
|
|
56
|
+
export type DecisionResult<Q extends Record<string, DecisionQuestion>> =
|
|
57
|
+
| {
|
|
58
|
+
ok: true;
|
|
59
|
+
answers: { [K in keyof Q]: AnswerFor<Q[K]> };
|
|
60
|
+
model: string;
|
|
61
|
+
elapsedMs: number;
|
|
62
|
+
usage?: { inputTokens: number; outputTokens: number };
|
|
63
|
+
/** Provider-reported dollars; absent means unknown, not free. */
|
|
64
|
+
costUsd?: number;
|
|
65
|
+
marketCostUsd?: number;
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
ok: false;
|
|
69
|
+
reason: DecisionFailureReason;
|
|
70
|
+
elapsedMs: number;
|
|
71
|
+
status?: number;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Decisions only. Implementations cannot call tools or mutate Lucidity tasks. */
|
|
75
|
+
export interface DecisionClient {
|
|
76
|
+
evaluate<Q extends Record<string, DecisionQuestion>>(
|
|
77
|
+
request: DecisionRequest<Q>,
|
|
78
|
+
): Promise<DecisionResult<Q>>;
|
|
79
|
+
}
|
|
@@ -1,87 +1,169 @@
|
|
|
1
1
|
# @lucidity/mcp-server
|
|
2
2
|
|
|
3
|
-
MCP server for managing Lucidity tasks
|
|
3
|
+
MCP server for managing Lucidity tasks, projects, milestones, comments, and local
|
|
4
|
+
markdown notes from Codex, Claude Code, Claude Desktop, and other MCP clients.
|
|
5
|
+
The same server runs over stdio for every client; each client needs its own registration.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
The server is included in the public `@opencorelabs/lucidity` package. Most users
|
|
10
|
+
should follow the [package guide](../../npm/README.md). The internal workspace
|
|
11
|
+
package `@lucidity/mcp-server` is not published separately.
|
|
12
|
+
|
|
13
|
+
### Build from source or configure a custom client
|
|
14
|
+
|
|
15
|
+
### 1. Get an API key
|
|
16
|
+
|
|
17
|
+
In the Lucidity app: **Settings > API Key > Generate**. Reuse an existing key when
|
|
18
|
+
adding another client: generating a new key revokes the previous one.
|
|
19
|
+
|
|
20
|
+
### 2. Build the server and its workspace dependencies
|
|
21
|
+
|
|
22
|
+
Run from the repository root after installing dependencies with `pnpm install`:
|
|
9
23
|
|
|
10
|
-
### 2. Build the MCP Server
|
|
11
24
|
```bash
|
|
12
|
-
|
|
13
|
-
pnpm build
|
|
25
|
+
pnpm exec turbo run build --filter=@lucidity/mcp-server...
|
|
14
26
|
```
|
|
15
27
|
|
|
16
|
-
|
|
28
|
+
The server depends on `@lucidity/notes` and `@lucidity/runtime`, which also need
|
|
29
|
+
their compiled output. This workspace package is not published separately. A global link is
|
|
30
|
+
optional; the commands below use an absolute entry path and the current Node
|
|
31
|
+
executable so they also work when a desktop client starts outside the repository.
|
|
32
|
+
|
|
33
|
+
### 3. Register with your client
|
|
34
|
+
|
|
35
|
+
Run the following commands from the repository root, replacing the API key.
|
|
36
|
+
|
|
37
|
+
#### Codex
|
|
38
|
+
|
|
17
39
|
```bash
|
|
18
|
-
|
|
19
|
-
|
|
40
|
+
codex mcp add lucidity \
|
|
41
|
+
--env LUCIDITY_API_KEY=luc_your_api_key_here \
|
|
42
|
+
--env LUCIDITY_API_URL=https://api.lucidity.my \
|
|
43
|
+
-- "$(node -p 'process.execPath')" "$PWD/packages/mcp-server/dist/index.js"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Codex stores this registration in `~/.codex/config.toml` (or your configured
|
|
47
|
+
`CODEX_HOME`). Local desktop, CLI, and IDE clients on the same Codex host share
|
|
48
|
+
it. Claude's `~/.claude.json` and `.mcp.json` entries do not register this server
|
|
49
|
+
with Codex.
|
|
50
|
+
|
|
51
|
+
For manual configuration, add this to your personal Codex `config.toml`, using
|
|
52
|
+
the paths printed by `node -p 'process.execPath'` and your repository location:
|
|
53
|
+
|
|
54
|
+
```toml
|
|
55
|
+
[mcp_servers.lucidity]
|
|
56
|
+
command = "/absolute/path/to/node"
|
|
57
|
+
args = ["/absolute/path/to/lucidity/packages/mcp-server/dist/index.js"]
|
|
58
|
+
|
|
59
|
+
[mcp_servers.lucidity.env]
|
|
60
|
+
LUCIDITY_API_KEY = "luc_your_api_key_here"
|
|
61
|
+
LUCIDITY_API_URL = "https://api.lucidity.my"
|
|
62
|
+
# Optional local notes:
|
|
63
|
+
# LUCIDITY_NOTES_PATH = "/absolute/path/to/notes"
|
|
20
64
|
```
|
|
21
65
|
|
|
22
|
-
|
|
66
|
+
Keep the API key in personal configuration, outside version control. If you
|
|
67
|
+
already supply it in the environment that launches Codex, you can instead set
|
|
68
|
+
`env_vars = ["LUCIDITY_API_KEY"]` in `[mcp_servers.lucidity]` and omit the key from
|
|
69
|
+
the `env` table. Desktop clients must actually inherit that environment variable.
|
|
23
70
|
|
|
24
|
-
|
|
25
|
-
|
|
71
|
+
Restart the client/server after adding it, then check `/mcp` in Codex CLI and ask
|
|
72
|
+
it to call `get_task_stats`. `codex mcp list` checks registration; a successful
|
|
73
|
+
tool call verifies both server startup and API authentication.
|
|
74
|
+
|
|
75
|
+
See the [official Codex MCP documentation](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)
|
|
76
|
+
for project configuration, tool allowlists, and timeouts. Codex supports this
|
|
77
|
+
server's stdio transport and initialization instructions; no HTTP transport or
|
|
78
|
+
Codex-specific tool schemas are required for local use.
|
|
79
|
+
|
|
80
|
+
#### Claude Code
|
|
26
81
|
|
|
27
82
|
```bash
|
|
28
83
|
claude mcp add lucidity \
|
|
29
84
|
--scope user \
|
|
30
85
|
-e LUCIDITY_API_KEY=luc_your_api_key_here \
|
|
31
86
|
-e LUCIDITY_API_URL=https://api.lucidity.my \
|
|
32
|
-
--
|
|
87
|
+
-- "$(node -p 'process.execPath')" "$PWD/packages/mcp-server/dist/index.js"
|
|
33
88
|
```
|
|
34
89
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
90
|
+
`--scope user` makes it available across projects. Restart Claude Code after
|
|
91
|
+
registration. For local development, set `LUCIDITY_API_URL=http://localhost:3001`.
|
|
92
|
+
|
|
93
|
+
#### Claude Desktop
|
|
94
|
+
|
|
95
|
+
Add an entry to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"mcpServers": {
|
|
100
|
+
"lucidity": {
|
|
101
|
+
"command": "/absolute/path/to/node",
|
|
102
|
+
"args": ["/absolute/path/to/lucidity/packages/mcp-server/dist/index.js"],
|
|
103
|
+
"env": {
|
|
104
|
+
"LUCIDITY_API_KEY": "luc_your_api_key_here",
|
|
105
|
+
"LUCIDITY_API_URL": "https://api.lucidity.my"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
42
110
|
```
|
|
43
111
|
|
|
44
|
-
|
|
45
|
-
- `--scope user` - Available across all projects (recommended)
|
|
46
|
-
- `--scope local` - Available only in current project (default)
|
|
47
|
-
- `--scope project` - Shared with team via `.mcp.json` file
|
|
112
|
+
Merge this entry with any existing servers, then restart Claude Desktop.
|
|
48
113
|
|
|
49
|
-
|
|
50
|
-
Close and reopen Claude Code for the changes to take effect.
|
|
114
|
+
## Optional local storage
|
|
51
115
|
|
|
52
|
-
|
|
116
|
+
- `LUCIDITY_NOTES_PATH`: a markdown vault directory, enabling note operations.
|
|
117
|
+
Without it, note tools return an explicit configuration error; API tools still work.
|
|
118
|
+
- `LUCIDITY_VAULT_PATH`: Lucid's memory directory, enabling `read_memory`,
|
|
119
|
+
`remember`, and `forget`. These access `MEMORY.md` and share it with the daemon
|
|
120
|
+
if configured to the same directory. Omit this to leave memory tools unavailable.
|
|
53
121
|
|
|
54
|
-
|
|
122
|
+
Use absolute paths (a leading `~/` is also supported). `LUCIDITY_API_KEY` is
|
|
123
|
+
required at startup. `LUCIDITY_API_URL` defaults to `https://api.lucidity.my`.
|
|
55
124
|
|
|
56
|
-
|
|
57
|
-
# Check if the command is available
|
|
58
|
-
which lucidity-mcp
|
|
125
|
+
## Daemon integration
|
|
59
126
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
127
|
+
`apps/daemon/src/mcp/config.ts` generates private MCP configuration for Lucid's
|
|
128
|
+
internal provider executors. The Claude and Codex adapters apply the corresponding
|
|
129
|
+
tool restrictions. This module does not install the server in external clients;
|
|
130
|
+
that is a separate setup operation. Registering an external client does not
|
|
131
|
+
change the daemon's model provider or capability settings.
|
|
63
132
|
|
|
64
133
|
## Uninstalling
|
|
65
134
|
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
cd packages/mcp-server
|
|
69
|
-
pnpm unlink --global
|
|
70
|
-
```
|
|
135
|
+
Remove the registration from the relevant client:
|
|
71
136
|
|
|
72
|
-
To remove from Claude Code:
|
|
73
137
|
```bash
|
|
74
|
-
|
|
138
|
+
codex mcp remove lucidity
|
|
139
|
+
# Or, for Claude Code:
|
|
140
|
+
claude mcp remove lucidity --scope user
|
|
75
141
|
```
|
|
76
142
|
|
|
143
|
+
If you previously linked `lucidity-mcp` globally, run `pnpm unlink --global`
|
|
144
|
+
from `packages/mcp-server` to remove that optional link.
|
|
145
|
+
|
|
77
146
|
## Tools
|
|
78
147
|
|
|
79
|
-
- **Tasks:** `list_tasks` `create_task` `update_task` `complete_task` `delete_task` `mark_task_reviewed`
|
|
148
|
+
- **Tasks:** `get_task` `list_tasks` `create_task` `update_task` `complete_task` `delete_task` `mark_task_reviewed`
|
|
80
149
|
- **Projects:** `list_projects` `create_project` `update_project`
|
|
81
|
-
- **Milestones:** `list_milestones` `create_milestone` `update_milestone` `delete_milestone` `get_milestone_progress`
|
|
82
|
-
- **Comments:** `list_comments` `create_comment`
|
|
150
|
+
- **Milestones:** `list_milestones` `create_milestone` `update_milestone` `delete_milestone` `merge_milestones` `get_milestone_progress`
|
|
151
|
+
- **Comments:** `list_comments` `create_comment` `delete_comment`
|
|
83
152
|
- **Queries:** `get_today` `get_week` `search` `get_task_stats` `get_unreviewed_tasks`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
153
|
+
- **Notes:** `list_notes` `read_note` `search_notes` `write_note` `edit_note`
|
|
154
|
+
- **Journal:** `search_journal` `read_journal_day` — search spoken entries across all dates, then read a matching day. Searches use corrected transcripts and return local journal dates, excerpts, and `nextOffset` for pagination.
|
|
155
|
+
- **Memory (opt-in):** `read_memory` `remember` `forget`
|
|
156
|
+
|
|
157
|
+
Tools advertise MCP annotations for reads, writes, destructive operations, and
|
|
158
|
+
access limited to the configured Lucidity account and local vaults. These are
|
|
159
|
+
client guidance; the API and local vault checks still enforce access.
|
|
160
|
+
`complete_task` toggles state, so repeating it can
|
|
161
|
+
undo a completion or advance a recurring task again. `create_comment.source`
|
|
162
|
+
uses the legacy API value `claude` for AI-authored comments from any client,
|
|
163
|
+
including Codex. Set `agent_provider` to `claude` or `codex` when known;
|
|
164
|
+
otherwise recognized Claude/Codex MCP client names supply it automatically for AI
|
|
165
|
+
comments. Generic hosts remain unknown unless the caller supplies the provider.
|
|
166
|
+
Human comments never carry provider attribution. The API stores this as optional
|
|
167
|
+
`agentProvider`; old comments remain unknown because their legacy source is ambiguous.
|
|
168
|
+
|
|
169
|
+
See [/docs/mcp-server.md](../../docs/mcp-server.md) for architecture and auth design.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS,QAEnE;AA2BD,wBAAsB,UAAU,CAAC,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,CAAC,CAAC,CA8DZ"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { commentProvider } from './commentProvider.js';
|
|
1
2
|
const API_KEY = process.env['LUCIDITY_API_KEY'];
|
|
2
3
|
const API_URL = process.env['LUCIDITY_API_URL'] || 'https://api.lucidity.my';
|
|
4
|
+
let getClientName = () => undefined;
|
|
5
|
+
export function setClientNameReader(reader) {
|
|
6
|
+
getClientName = reader;
|
|
7
|
+
}
|
|
3
8
|
if (!API_KEY) {
|
|
4
9
|
console.error('LUCIDITY_API_KEY environment variable is required.\n' +
|
|
5
10
|
'Generate one in Lucidity app: Settings → API Key → Generate.');
|
|
@@ -22,6 +27,7 @@ const BACKOFF_MS = [400, 1200];
|
|
|
22
27
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
23
28
|
export async function apiRequest(endpoint, options = {}) {
|
|
24
29
|
const url = `${API_URL}${endpoint}`;
|
|
30
|
+
const provider = commentProvider(getClientName());
|
|
25
31
|
let lastStatus = 0;
|
|
26
32
|
let lastMessage = '';
|
|
27
33
|
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
|
|
@@ -32,6 +38,8 @@ export async function apiRequest(endpoint, options = {}) {
|
|
|
32
38
|
headers: {
|
|
33
39
|
'Content-Type': 'application/json',
|
|
34
40
|
Authorization: `Bearer ${API_KEY}`,
|
|
41
|
+
'X-Lucidity-Actor': 'agent',
|
|
42
|
+
...(provider ? { 'X-Lucidity-Agent-Provider': provider } : {}),
|
|
35
43
|
...options.headers,
|
|
36
44
|
},
|
|
37
45
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commentProvider.d.ts","sourceRoot":"","sources":["../src/commentProvider.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAOnF"}
|