@opencorelabs/lucidity 0.3.0 → 0.7.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 +18 -3
- 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 +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -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 +185 -40
- 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 +5 -0
- package/dist/mcp/clients.d.ts.map +1 -1
- package/dist/mcp/clients.js +1 -1
- package/dist/mcp/config.d.ts +3 -1
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +48 -6
- package/dist/mcp/paired.js +1 -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 +266 -47
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +9 -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/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 +29 -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 +202 -67
- 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 +1 -1
- package/src/mcp/config.ts +56 -6
- package/src/mcp/paired.ts +1 -0
- package/src/notesContext.ts +3 -2
- package/src/room/client.ts +320 -54
- package/src/room/computer.ts +9 -0
- package/src/room/context.ts +12 -3
- package/src/room/turnQueue.ts +358 -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/dayPlan.d.ts +9 -0
- package/vendor/decisions/dist/dayPlan.js +82 -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 +6 -0
- package/vendor/decisions/dist/index.js +6 -0
- package/vendor/decisions/dist/jev.d.ts +15 -0
- package/vendor/decisions/dist/jev.js +244 -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/dayPlan.ts +80 -0
- package/vendor/decisions/src/gate.ts +32 -0
- package/vendor/decisions/src/index.ts +6 -0
- package/vendor/decisions/src/jev.ts +295 -0
- package/vendor/decisions/src/types.ts +79 -0
- package/vendor/mcp-server/README.md +6 -1
- 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 +21 -6
- 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 +25 -4
- 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/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 +67 -27
- 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 +20 -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 +24 -3
- 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/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 +66 -30
- 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 +117 -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 +214 -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 +10 -0
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.d.ts +2 -0
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +46 -1
- package/vendor/runtime/dist/harness/types.d.ts +5 -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/dayPlanning.d.ts +44 -0
- package/vendor/runtime/dist/prompts/dayPlanning.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/dayPlanning.js +42 -0
- 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 +137 -7
- package/vendor/runtime/src/executor/claudeCode.ts +6 -4
- package/vendor/runtime/src/executor/codex.ts +281 -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 +10 -0
- package/vendor/runtime/src/harness/index.ts +51 -6
- package/vendor/runtime/src/harness/types.ts +5 -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/dayPlanning.ts +46 -0
- 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/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 +664 -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 +1534 -0
- package/vendor/shared/dist/commands.d.ts.map +1 -0
- package/vendor/shared/dist/commands.js +233 -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 +12 -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/dayPlan.d.ts +86 -0
- package/vendor/shared/dist/dayPlan.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlan.js +46 -0
- package/vendor/shared/dist/dayPlanning.d.ts +139 -0
- package/vendor/shared/dist/dayPlanning.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlanning.js +67 -0
- 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 +28 -2
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +25 -2
- 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 +976 -59
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +124 -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/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/cardStatement.ts +49 -0
- package/vendor/shared/src/cardStudio.ts +340 -0
- package/vendor/shared/src/commandLocal.ts +740 -0
- package/vendor/shared/src/commandText.ts +25 -0
- package/vendor/shared/src/commands.ts +255 -0
- package/vendor/shared/src/computer.ts +25 -6
- package/vendor/shared/src/constants.ts +9 -2
- package/vendor/shared/src/dayPlan.ts +81 -0
- package/vendor/shared/src/dayPlanning.ts +77 -0
- package/vendor/shared/src/githubContributions.ts +70 -0
- package/vendor/shared/src/habitContributions.ts +144 -0
- package/vendor/shared/src/index.ts +44 -1
- 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 +146 -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/smartCapture.ts +67 -0
- package/vendor/shared/src/speech.ts +44 -0
- package/vendor/shared/src/spokenNames.ts +128 -0
- package/vendor/shared/src/taskActivity.ts +34 -0
- package/vendor/shared/src/vault-search.ts +243 -0
- package/vendor/shared/src/voiceCapture.ts +34 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync, statSync, unlinkSync, } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { HarnessRequestSchema } from '@lucidity/shared';
|
|
4
|
+
export function turnLane(req) {
|
|
5
|
+
return req.kind === 'ask'
|
|
6
|
+
? 'room:ask'
|
|
7
|
+
: `room:code:${req.repoId}${req.workerId ? `:${req.workerId}` : ''}`;
|
|
8
|
+
}
|
|
9
|
+
/** Persist before acknowledgement, resolve continuity on the computer, and never replay
|
|
10
|
+
* an execution whose outcome became uncertain. The socket only observes this queue. */
|
|
11
|
+
export class DurableTurnQueue {
|
|
12
|
+
deps;
|
|
13
|
+
entries = new Map();
|
|
14
|
+
scheduled = new Set();
|
|
15
|
+
stopped = false;
|
|
16
|
+
pumping = false;
|
|
17
|
+
constructor(deps) {
|
|
18
|
+
this.deps = deps;
|
|
19
|
+
mkdirSync(deps.dir, { recursive: true, mode: 0o700 });
|
|
20
|
+
for (const name of readdirSync(deps.dir)
|
|
21
|
+
.filter((name) => name.endsWith('.json'))
|
|
22
|
+
.sort()) {
|
|
23
|
+
const entry = JSON.parse(readFileSync(join(deps.dir, name), 'utf8'));
|
|
24
|
+
if (['done', 'failed', 'skipped'].includes(entry.state) &&
|
|
25
|
+
Date.now() - statSync(join(deps.dir, name)).mtimeMs > 24 * 60 * 60_000) {
|
|
26
|
+
unlinkSync(join(deps.dir, name));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const parsed = HarnessRequestSchema.parse(entry.request);
|
|
30
|
+
if (parsed.kind !== 'ask' && parsed.kind !== 'code')
|
|
31
|
+
throw new Error('Invalid queued turn');
|
|
32
|
+
entry.request = parsed;
|
|
33
|
+
this.entries.set(parsed.id, entry);
|
|
34
|
+
const terminal = this.terminal(parsed.id);
|
|
35
|
+
if (entry.state === 'running' || entry.state === 'steering') {
|
|
36
|
+
if (terminal?.type === 'done') {
|
|
37
|
+
this.save({
|
|
38
|
+
...entry,
|
|
39
|
+
state: 'done',
|
|
40
|
+
resume: this.session(parsed.id),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.fail(entry, 'Lucid restarted during this turn. It was not run again. Review the result before resending.');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if (entry.state === 'skipped' && !terminal) {
|
|
48
|
+
this.publish(parsed.id, {
|
|
49
|
+
type: 'cancelled',
|
|
50
|
+
queueAction: entry.action,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else if (entry.state === 'failed' && !terminal) {
|
|
54
|
+
this.publish(parsed.id, {
|
|
55
|
+
type: 'error',
|
|
56
|
+
message: 'This queued turn could not finish. Review it before resending.',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const entry of this.entries.values()) {
|
|
61
|
+
const previous = entry.request.afterRequestId;
|
|
62
|
+
if (entry.state === 'queued' &&
|
|
63
|
+
previous &&
|
|
64
|
+
!this.entries.has(previous) &&
|
|
65
|
+
!this.terminal(previous))
|
|
66
|
+
this.fail(entry, 'Lucid restarted before the preceding turn finished. Review it before resending this message.');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
save(entry) {
|
|
70
|
+
const path = join(this.deps.dir, `${entry.request.id}.json`);
|
|
71
|
+
writeFileSync(`${path}.tmp`, JSON.stringify(entry), {
|
|
72
|
+
mode: 0o600,
|
|
73
|
+
flush: true,
|
|
74
|
+
});
|
|
75
|
+
renameSync(`${path}.tmp`, path);
|
|
76
|
+
this.entries.set(entry.request.id, entry);
|
|
77
|
+
}
|
|
78
|
+
publish(id, event) {
|
|
79
|
+
const frame = this.deps.logs.append(id, { ...event, requestId: id });
|
|
80
|
+
if (!this.deps.logs.read(id).frames.some((saved) => saved.seq === frame.seq))
|
|
81
|
+
throw new Error('Could not save the queue receipt on this computer.');
|
|
82
|
+
this.deps.sendRaw(frame);
|
|
83
|
+
}
|
|
84
|
+
terminal(id) {
|
|
85
|
+
return this.deps.logs
|
|
86
|
+
.read(id)
|
|
87
|
+
.frames.slice()
|
|
88
|
+
.reverse()
|
|
89
|
+
.find((frame) => ['done', 'error', 'cancelled'].includes(String(frame.type)));
|
|
90
|
+
}
|
|
91
|
+
session(id) {
|
|
92
|
+
const frames = this.deps.logs.read(id).frames;
|
|
93
|
+
const value = frames
|
|
94
|
+
.slice()
|
|
95
|
+
.reverse()
|
|
96
|
+
.find((frame) => typeof frame.sessionId === 'string')?.sessionId;
|
|
97
|
+
return typeof value === 'string' ? value : undefined;
|
|
98
|
+
}
|
|
99
|
+
fail(entry, message) {
|
|
100
|
+
this.save({ ...entry, state: 'failed' });
|
|
101
|
+
if (!this.deps.logs.read(entry.request.id).terminated)
|
|
102
|
+
this.publish(entry.request.id, { type: 'error', message });
|
|
103
|
+
this.wake();
|
|
104
|
+
}
|
|
105
|
+
owns(id) {
|
|
106
|
+
const state = this.entries.get(id)?.state;
|
|
107
|
+
return state === 'queued' || state === 'running' || state === 'steering';
|
|
108
|
+
}
|
|
109
|
+
confirm(id) {
|
|
110
|
+
const entry = this.entries.get(id);
|
|
111
|
+
if (entry && this.owns(id))
|
|
112
|
+
this.publish(id, {
|
|
113
|
+
type: 'queue_state',
|
|
114
|
+
state: entry.state === 'running' ? 'running' : 'queued',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
enqueue(request) {
|
|
118
|
+
if (!request.stream)
|
|
119
|
+
throw new Error('Queued turns require streaming replies.');
|
|
120
|
+
const existing = this.entries.get(request.id);
|
|
121
|
+
if (existing) {
|
|
122
|
+
if (JSON.stringify(existing.request) !== JSON.stringify(request))
|
|
123
|
+
throw new Error('Request ID already belongs to another message.');
|
|
124
|
+
for (const frame of this.deps.logs.read(request.id).frames)
|
|
125
|
+
this.deps.sendRaw(frame);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (this.deps.logs.read(request.id).exists)
|
|
129
|
+
throw new Error('This request was already submitted.');
|
|
130
|
+
if ([...this.entries.values()].filter((e) => this.owns(e.request.id))
|
|
131
|
+
.length >= 100)
|
|
132
|
+
throw new Error('The computer queue is full. Wait for some messages to finish.');
|
|
133
|
+
if (request.afterRequestId) {
|
|
134
|
+
const previous = this.entries.get(request.afterRequestId)?.request;
|
|
135
|
+
const receipt = this.deps.logs
|
|
136
|
+
.read(request.afterRequestId)
|
|
137
|
+
.frames.find((frame) => frame.type === 'accepted');
|
|
138
|
+
const scope = previous ?? receipt?.scope;
|
|
139
|
+
const same = scope &&
|
|
140
|
+
(request.kind === 'ask'
|
|
141
|
+
? scope.kind === 'ask'
|
|
142
|
+
: (scope.kind === 'code' &&
|
|
143
|
+
scope.repoId === request.repoId &&
|
|
144
|
+
scope.workerId === request.workerId &&
|
|
145
|
+
(scope.mode ?? 'worktree') === (request.mode ?? 'worktree')) ||
|
|
146
|
+
(scope.kind === 'conduct' &&
|
|
147
|
+
scope.repoId === request.repoId &&
|
|
148
|
+
!!request.workerId));
|
|
149
|
+
if (!same)
|
|
150
|
+
throw new Error('The preceding turn does not belong to this conversation. Refresh it before sending again.');
|
|
151
|
+
}
|
|
152
|
+
const entry = { request, state: 'queued' };
|
|
153
|
+
this.save(entry);
|
|
154
|
+
try {
|
|
155
|
+
this.publish(request.id, { type: 'queue_state', state: 'queued' });
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
this.save({ ...entry, state: 'failed' });
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
this.wake();
|
|
162
|
+
}
|
|
163
|
+
/** Skipped queue entries inherit their predecessor, so removing B from A→B→C
|
|
164
|
+
* never starts a new conversation or strands C. Failed executions stop dependants. */
|
|
165
|
+
predecessor(entry) {
|
|
166
|
+
const id = entry.request.afterRequestId;
|
|
167
|
+
if (!id)
|
|
168
|
+
return { ready: true, resume: entry.request.resume };
|
|
169
|
+
const previous = this.entries.get(id);
|
|
170
|
+
if (previous) {
|
|
171
|
+
if (previous.state === 'skipped')
|
|
172
|
+
return this.predecessor(previous);
|
|
173
|
+
if (previous.state === 'failed')
|
|
174
|
+
throw new Error('The previous turn did not finish. Review it before resending this message.');
|
|
175
|
+
if (previous.state !== 'done')
|
|
176
|
+
return { ready: false };
|
|
177
|
+
if (!previous.resume)
|
|
178
|
+
throw new Error('The previous turn has no session to continue. Start a new conversation.');
|
|
179
|
+
return { ready: true, resume: previous.resume };
|
|
180
|
+
}
|
|
181
|
+
const terminal = this.terminal(id);
|
|
182
|
+
if (!terminal)
|
|
183
|
+
return { ready: false };
|
|
184
|
+
if (terminal.type !== 'done')
|
|
185
|
+
throw new Error('The previous turn did not finish. Review it before resending this message.');
|
|
186
|
+
const receipt = this.deps.logs
|
|
187
|
+
.read(id)
|
|
188
|
+
.frames.find((frame) => frame.type === 'accepted');
|
|
189
|
+
const scope = receipt?.scope;
|
|
190
|
+
const source = scope?.kind === 'conduct' && entry.request.kind === 'code'
|
|
191
|
+
? entry.request.workerId
|
|
192
|
+
: id;
|
|
193
|
+
if (source !== id && this.terminal(source)?.type !== 'done')
|
|
194
|
+
throw new Error('The worker did not finish. Review it before resending this message.');
|
|
195
|
+
const resume = this.session(source);
|
|
196
|
+
if (!resume)
|
|
197
|
+
throw new Error('The previous turn has no session to continue. Start a new conversation.');
|
|
198
|
+
return { ready: true, resume };
|
|
199
|
+
}
|
|
200
|
+
wake() {
|
|
201
|
+
if (this.stopped || this.pumping)
|
|
202
|
+
return;
|
|
203
|
+
this.pumping = true;
|
|
204
|
+
queueMicrotask(() => {
|
|
205
|
+
this.pumping = false;
|
|
206
|
+
if (this.stopped)
|
|
207
|
+
return;
|
|
208
|
+
const occupied = new Set();
|
|
209
|
+
for (const [id, entry] of this.entries) {
|
|
210
|
+
const lane = turnLane(entry.request);
|
|
211
|
+
if (!this.owns(id))
|
|
212
|
+
continue;
|
|
213
|
+
if (occupied.has(lane))
|
|
214
|
+
continue;
|
|
215
|
+
occupied.add(lane);
|
|
216
|
+
if (entry.state !== 'queued' || this.scheduled.has(id))
|
|
217
|
+
continue;
|
|
218
|
+
try {
|
|
219
|
+
if (!this.predecessor(entry).ready)
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
this.fail(entry, String(error.message));
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
this.scheduled.add(id);
|
|
227
|
+
void this.deps.lanes
|
|
228
|
+
.run(turnLane(entry.request), async () => {
|
|
229
|
+
const current = this.entries.get(id);
|
|
230
|
+
if (this.stopped || current.state !== 'queued')
|
|
231
|
+
return;
|
|
232
|
+
const previous = this.predecessor(current);
|
|
233
|
+
if (!previous.ready)
|
|
234
|
+
return;
|
|
235
|
+
this.save({ ...current, state: 'running' });
|
|
236
|
+
this.publish(id, { type: 'queue_state', state: 'running' });
|
|
237
|
+
await this.deps.execute({
|
|
238
|
+
...current.request,
|
|
239
|
+
resume: previous.resume,
|
|
240
|
+
queue: false,
|
|
241
|
+
afterRequestId: undefined,
|
|
242
|
+
});
|
|
243
|
+
if (this.terminal(id)?.type === 'done')
|
|
244
|
+
this.save({
|
|
245
|
+
...current,
|
|
246
|
+
state: 'done',
|
|
247
|
+
resume: this.session(id),
|
|
248
|
+
});
|
|
249
|
+
else
|
|
250
|
+
this.fail(current, 'The turn ended before completion. Review it before resending.');
|
|
251
|
+
})
|
|
252
|
+
.catch((error) => this.fail(this.entries.get(id), String(error.message)))
|
|
253
|
+
.finally(() => {
|
|
254
|
+
this.scheduled.delete(id);
|
|
255
|
+
this.wake();
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
async control(id, action, activeId) {
|
|
261
|
+
const entry = this.entries.get(id);
|
|
262
|
+
if (!entry)
|
|
263
|
+
throw new Error('This message is not in the computer queue.');
|
|
264
|
+
if (entry.state === 'skipped' && entry.action === action) {
|
|
265
|
+
const frame = this.terminal(id);
|
|
266
|
+
if (frame)
|
|
267
|
+
this.deps.sendRaw(frame);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (entry.state !== 'queued')
|
|
271
|
+
throw new Error('This message has already started or left the queue.');
|
|
272
|
+
if (action === 'steer') {
|
|
273
|
+
if (entry.request.images?.length)
|
|
274
|
+
throw new Error('Attachments must run as a separate turn.');
|
|
275
|
+
if (!activeId || !this.deps.steer)
|
|
276
|
+
throw new Error('There is no active turn to influence.');
|
|
277
|
+
const active = this.entries.get(activeId);
|
|
278
|
+
// For a spawned fleet worker, the active request uses the worker's own ID.
|
|
279
|
+
if (active
|
|
280
|
+
? turnLane(active.request) !== turnLane(entry.request) ||
|
|
281
|
+
active.state !== 'running'
|
|
282
|
+
: entry.request.kind !== 'code' || entry.request.workerId !== activeId)
|
|
283
|
+
throw new Error('The active turn does not belong to this conversation.');
|
|
284
|
+
this.save({ ...entry, state: 'steering' });
|
|
285
|
+
try {
|
|
286
|
+
await this.deps.steer(activeId, entry.request.prompt);
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
this.save(entry);
|
|
290
|
+
this.wake();
|
|
291
|
+
throw error;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
this.save({ ...entry, state: 'skipped', action });
|
|
295
|
+
this.publish(id, { type: 'cancelled', queueAction: action });
|
|
296
|
+
this.wake();
|
|
297
|
+
}
|
|
298
|
+
stop() {
|
|
299
|
+
this.stopped = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lucidity-automations
|
|
3
|
+
description: Create, trial, schedule, review, revise, and troubleshoot Lucidity automations shared with the mobile app. Use when someone wants recurring work on their paired computer, asks about Lucidity jobs or run history, or wants a UI designer, briefing, notes review, or custom research automation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Lucidity automations
|
|
7
|
+
|
|
8
|
+
Use Lucidity's `get_automations`, `get_automation_run`, and `manage_automation` MCP tools. They operate on the same jobs shown in the app's Automations screen. This skill supplies a workflow; it does not add permissions or start a separate scheduler.
|
|
9
|
+
|
|
10
|
+
## Establish the job
|
|
11
|
+
|
|
12
|
+
1. Read `get_automations`. Identify the computer, existing jobs, supported sources, connection configuration, and any relevant failures. Reuse the intended job instead of creating a duplicate. Connection flags indicate configuration, not verified authentication.
|
|
13
|
+
2. Turn the user's idea into a concise name and instructions describing the goal, sources, and useful output. Ask only for missing details that affect execution: source/destination links, project when needed, or schedule/timezone. Honor decisions and authorization already provided.
|
|
14
|
+
3. Choose the workflow:
|
|
15
|
+
- `agent`: read selected `tasks`, `journal`, `notes`, `repository`, or `web` sources and save a Markdown result. Templates are `custom`, `daily-briefing`, `weekly-plan`, `notes-review`. Notes needs a connected folder; repository needs an available `repoId`. This workflow proposes changes; it cannot apply external writes.
|
|
16
|
+
- `ui-designer`: create reviewable native Figma proposals from a product brief and destination `figmaUrl`. `pinterestUrl` and `repoId` are optional. Derive product rules from the brief and saved guidance; do not assume Lucidity cards, dimensions, or a particular aesthetic for other users.
|
|
17
|
+
4. Save using `manage_automation` with `action=save`. New drafts use `enabled=false`; use `frequency=manual` when no recurring schedule was requested. Include an IANA timezone. Supported schedules: manual, daily, weekdays, weekly, or intervals of 1/2/3/4/6/8/12 hours. Explain that jobs run on the named computer while it is awake and connected. `catchUp=skip` is the default; `once` coalesces missed work into one run.
|
|
18
|
+
|
|
19
|
+
Minimal general input (inside `command: {action: "save", input: ...}`):
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"workflow": "agent",
|
|
24
|
+
"template": "daily-briefing",
|
|
25
|
+
"name": "Morning priorities",
|
|
26
|
+
"brief": "Review my tasks and prepare a concise morning plan with source task links. Propose changes without modifying tasks.",
|
|
27
|
+
"sources": ["tasks"],
|
|
28
|
+
"reviewRequired": true,
|
|
29
|
+
"enabled": false,
|
|
30
|
+
"schedule": {"frequency": "daily", "time": "09:00", "timezone": "Asia/Kolkata"}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Use the user's timezone rather than copying the example. Save provider/model and sensible `timeoutMinutes` / `maxToolCalls` limits. These bounds are not guaranteed spending caps.
|
|
35
|
+
|
|
36
|
+
## Trial, review, and schedule
|
|
37
|
+
|
|
38
|
+
- `run` starts asynchronously and returns a durable run ID. Inspect `get_automation_run` until it finishes, using bounded polling. Report **started** while it is running; report success only from the completed record.
|
|
39
|
+
- The UI designer automatically studies available Pinterest images in small vision batches before generation. It keeps per-image observations in private per-job memory, reuses unchanged image analysis, and groups distinct visual families. `referenceStudy` reports the current feed coverage, observations and source links. Inferred visual evidence is used automatically; it is not a claim that the user approved every property in every pin. Explicit preferences and product rules take precedence. A public feed is a bounded recent sample, never proof that the whole board was studied.
|
|
40
|
+
- `stage=taste` additionally proposes human-readable guidance without writing designs. Review drafts and use `save-guidance` when the user accepts them. This saves explicit project/automation guidance; the automatic reference-memory step does not depend on manually accepting a taste draft. Guidance is saved in the job, or `docs/taste.md` and `docs/design.md` when a repo is selected. Repo guidance should be reviewed and committed for other worktrees to receive it.
|
|
41
|
+
- `stage=design` creates Figma proposals, then a separate read-only reviewer inspects screenshots against learned references and the brief. One bounded repair and re-review are allowed. Inspect `critiques` along with node links and the saved summary. A failed review stays failed and retains created artifacts. `revise` records user feedback and starts a linked revision; previous output remains available.
|
|
42
|
+
- General reports and failures can be `acknowledge`d to clear attention while preserving their status/history. Do not hide a failure by calling it completed.
|
|
43
|
+
- Enable the agreed recurring schedule with `enable`. Do not require a second confirmation if the user already authorized it. Pause with `enabled=false`, or `enabled=true` plus a future `pausedUntil` for a temporary pause.
|
|
44
|
+
- A design `review` approval requires a real `directionId`. `implement` additionally needs a selected repository and creates a dedicated coding branch, requesting a draft PR. Only do this when implementation is in the user's scope. Design approval alone does not authorize merging or deployment.
|
|
45
|
+
|
|
46
|
+
## Recover and explain
|
|
47
|
+
|
|
48
|
+
Read saved jobs/runs after an uncertain mutation before retrying. Runs cannot overlap within one job. Restarts mark unfinished work interrupted, and cancellation preserves existing external edits. Inspect those edits before repeating a write.
|
|
49
|
+
|
|
50
|
+
If tools are absent, run `lucidity setup-mcp` on the computer, then reconnect the coding client. The daemon must be running locally for these MCP tools. Lucid's companion chat needs the separate **Automations** capability; task access alone does not grant it. Code chat supplies the tools directly. Figma setup for Codex is `lucidity setup-design`; other authenticated transports are configured locally, never by committing credentials.
|
|
51
|
+
|
|
52
|
+
CLI fallback: `lucidity automations list`, `get <run-id>`, or `command <json-file>` use the same service. An OS crontab, GitHub workflow, or client-local scheduled task is not a Lucidity automation and will not appear in the app.
|
|
53
|
+
|
|
54
|
+
Finish with the saved name/ID, actual result or blocker, schedule state and next run, and where to review it. Never claim a job exists, a source was read, or a design was created without tool evidence.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type VoiceCaptureInput, type VoiceCaptureReceipt, type SpeechAudio, type SpeechTranscript } from '@lucidity/shared';
|
|
2
|
+
type Options = {
|
|
3
|
+
directory: string;
|
|
4
|
+
transcribe: (audio: SpeechAudio, signal: AbortSignal) => Promise<SpeechTranscript>;
|
|
5
|
+
act: (transcript: string, signal: AbortSignal) => Promise<string>;
|
|
6
|
+
logger?: (message: string) => void;
|
|
7
|
+
};
|
|
8
|
+
/** Durable acceptance precedes the HTTP acknowledgement. Never repeat an action
|
|
9
|
+
* whose outcome may have been committed before a crash or lost provider reply. */
|
|
10
|
+
export declare class VoiceCaptureService {
|
|
11
|
+
private readonly opts;
|
|
12
|
+
private readonly records;
|
|
13
|
+
private readonly controller;
|
|
14
|
+
private running;
|
|
15
|
+
private faulted;
|
|
16
|
+
constructor(opts: Options);
|
|
17
|
+
private key;
|
|
18
|
+
private terminal;
|
|
19
|
+
private atomic;
|
|
20
|
+
private save;
|
|
21
|
+
private removeAudio;
|
|
22
|
+
status(credentialId: string, captureId: string): VoiceCaptureReceipt | null;
|
|
23
|
+
submit(credentialId: string, input: VoiceCaptureInput): VoiceCaptureReceipt;
|
|
24
|
+
wake(): void;
|
|
25
|
+
private update;
|
|
26
|
+
private drain;
|
|
27
|
+
stop(): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=captures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captures.d.ts","sourceRoot":"","sources":["../../src/speech/captures.ts"],"names":[],"mappings":"AAeA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAQ1B,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,CACV,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/B,GAAG,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF;kFACkF;AAClF,qBAAa,mBAAmB;IAKlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBACK,IAAI,EAAE,OAAO;IAoC1C,OAAO,CAAC,GAAG;IAGX,OAAO,CAAC,QAAQ;IAGhB,OAAO,CAAC,MAAM;IAiBd,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,WAAW;IAInB,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAM3E,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,mBAAmB;IAiD3E,IAAI;IAsBJ,OAAO,CAAC,MAAM;YAiBA,KAAK;IAiDnB,IAAI;CAGL"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync, renameSync, readdirSync, unlinkSync, existsSync, openSync, fsyncSync, closeSync, } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { MAX_CAPTURE_BYTES, MAX_CAPTURE_SECONDS, VoiceCaptureInputSchema, VoiceCaptureReceiptSchema, } from '@lucidity/shared';
|
|
6
|
+
const StoredSchema = z.object({
|
|
7
|
+
credentialId: z.uuid(),
|
|
8
|
+
digest: z.string().regex(/^[a-f0-9]{64}$/),
|
|
9
|
+
receipt: VoiceCaptureReceiptSchema,
|
|
10
|
+
});
|
|
11
|
+
/** Durable acceptance precedes the HTTP acknowledgement. Never repeat an action
|
|
12
|
+
* whose outcome may have been committed before a crash or lost provider reply. */
|
|
13
|
+
export class VoiceCaptureService {
|
|
14
|
+
opts;
|
|
15
|
+
records = new Map();
|
|
16
|
+
controller = new AbortController();
|
|
17
|
+
running = false;
|
|
18
|
+
faulted = false;
|
|
19
|
+
constructor(opts) {
|
|
20
|
+
this.opts = opts;
|
|
21
|
+
mkdirSync(opts.directory, { recursive: true, mode: 0o700 });
|
|
22
|
+
for (const name of readdirSync(opts.directory)) {
|
|
23
|
+
if (!name.endsWith('.json'))
|
|
24
|
+
continue;
|
|
25
|
+
// Fail closed on a corrupt receipt. Ignoring it could replay an action.
|
|
26
|
+
const record = StoredSchema.parse(JSON.parse(readFileSync(join(opts.directory, name), 'utf8')));
|
|
27
|
+
const key = this.key(record.credentialId, record.receipt.captureId);
|
|
28
|
+
if (name !== `${key}.json`)
|
|
29
|
+
throw new Error('Invalid voice capture receipt filename.');
|
|
30
|
+
if (record.receipt.state === 'acting') {
|
|
31
|
+
record.receipt = {
|
|
32
|
+
...record.receipt,
|
|
33
|
+
state: 'uncertain',
|
|
34
|
+
message: 'The computer restarted during this action. Check Lucidity before recording it again.',
|
|
35
|
+
updatedAt: new Date().toISOString(),
|
|
36
|
+
};
|
|
37
|
+
this.save(key, record);
|
|
38
|
+
}
|
|
39
|
+
else if (record.receipt.state === 'transcribing') {
|
|
40
|
+
record.receipt.state = 'queued';
|
|
41
|
+
this.save(key, record);
|
|
42
|
+
}
|
|
43
|
+
this.records.set(key, record);
|
|
44
|
+
if (this.terminal(record.receipt))
|
|
45
|
+
this.removeAudio(key);
|
|
46
|
+
}
|
|
47
|
+
// Remove incomplete writes left before acceptance, never accepted recordings.
|
|
48
|
+
for (const name of readdirSync(opts.directory)) {
|
|
49
|
+
if (name.endsWith('.tmp') ||
|
|
50
|
+
(name.endsWith('.m4a') && !this.records.has(name.slice(0, -4))))
|
|
51
|
+
unlinkSync(join(opts.directory, name));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
key(credentialId, captureId) {
|
|
55
|
+
return `${z.uuid().parse(credentialId)}_${z.uuid().parse(captureId)}`;
|
|
56
|
+
}
|
|
57
|
+
terminal(receipt) {
|
|
58
|
+
return ['done', 'failed', 'uncertain'].includes(receipt.state);
|
|
59
|
+
}
|
|
60
|
+
atomic(path, bytes) {
|
|
61
|
+
const temporary = `${path}.tmp`;
|
|
62
|
+
writeFileSync(temporary, bytes, { mode: 0o600 });
|
|
63
|
+
const fd = openSync(temporary, 'r');
|
|
64
|
+
try {
|
|
65
|
+
fsyncSync(fd);
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
closeSync(fd);
|
|
69
|
+
}
|
|
70
|
+
renameSync(temporary, path);
|
|
71
|
+
const directory = openSync(this.opts.directory, 'r');
|
|
72
|
+
try {
|
|
73
|
+
fsyncSync(directory);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
closeSync(directory);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
save(key, record) {
|
|
80
|
+
this.atomic(join(this.opts.directory, `${key}.json`), JSON.stringify(record));
|
|
81
|
+
}
|
|
82
|
+
removeAudio(key) {
|
|
83
|
+
const path = join(this.opts.directory, `${key}.m4a`);
|
|
84
|
+
if (existsSync(path))
|
|
85
|
+
unlinkSync(path);
|
|
86
|
+
}
|
|
87
|
+
status(credentialId, captureId) {
|
|
88
|
+
const receipt = this.records.get(this.key(credentialId, captureId))?.receipt;
|
|
89
|
+
return receipt ? { ...receipt } : null;
|
|
90
|
+
}
|
|
91
|
+
submit(credentialId, input) {
|
|
92
|
+
const parsed = VoiceCaptureInputSchema.parse(input);
|
|
93
|
+
const key = this.key(credentialId, parsed.captureId);
|
|
94
|
+
const bytes = Buffer.from(parsed.audio.base64, 'base64');
|
|
95
|
+
if (!bytes.length ||
|
|
96
|
+
bytes.length > MAX_CAPTURE_BYTES ||
|
|
97
|
+
bytes.toString('base64') !== parsed.audio.base64)
|
|
98
|
+
throw new Error('The recording is incomplete or larger than 2 MB.');
|
|
99
|
+
const digest = createHash('sha256').update(bytes).digest('hex');
|
|
100
|
+
const previous = this.records.get(key);
|
|
101
|
+
if (previous) {
|
|
102
|
+
if (previous.digest !== digest)
|
|
103
|
+
throw new Error('This capture ID already belongs to another recording.');
|
|
104
|
+
return { ...previous.receipt };
|
|
105
|
+
}
|
|
106
|
+
if (this.faulted)
|
|
107
|
+
throw new Error('Voice capture storage needs attention on your computer.');
|
|
108
|
+
if (this.controller.signal.aborted)
|
|
109
|
+
throw new Error('The computer is shutting down. Keep the recording and retry.');
|
|
110
|
+
if ([...this.records.values()].filter((r) => !this.terminal(r.receipt))
|
|
111
|
+
.length >= 20)
|
|
112
|
+
throw new Error('The computer capture queue is full. Keep the recording and retry later.');
|
|
113
|
+
const record = {
|
|
114
|
+
credentialId,
|
|
115
|
+
digest,
|
|
116
|
+
receipt: {
|
|
117
|
+
captureId: parsed.captureId,
|
|
118
|
+
state: 'queued',
|
|
119
|
+
updatedAt: new Date().toISOString(),
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
this.atomic(join(this.opts.directory, `${key}.m4a`), bytes);
|
|
123
|
+
this.save(key, record);
|
|
124
|
+
this.records.set(key, record);
|
|
125
|
+
this.wake();
|
|
126
|
+
return { ...record.receipt };
|
|
127
|
+
}
|
|
128
|
+
wake() {
|
|
129
|
+
if (this.running || this.faulted || this.controller.signal.aborted)
|
|
130
|
+
return;
|
|
131
|
+
this.running = true;
|
|
132
|
+
// Defer so acceptance can reach the client before model loading starts.
|
|
133
|
+
void Promise.resolve()
|
|
134
|
+
.then(() => this.drain())
|
|
135
|
+
.catch(() => {
|
|
136
|
+
this.faulted = true;
|
|
137
|
+
this.opts.logger?.('Voice capture processing stopped because a receipt could not be saved.');
|
|
138
|
+
})
|
|
139
|
+
.finally(() => {
|
|
140
|
+
this.running = false;
|
|
141
|
+
if ([...this.records.values()].some((record) => record.receipt.state === 'queued'))
|
|
142
|
+
this.wake();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
update(key, record, patch) {
|
|
146
|
+
const next = {
|
|
147
|
+
...record,
|
|
148
|
+
receipt: {
|
|
149
|
+
...record.receipt,
|
|
150
|
+
...patch,
|
|
151
|
+
updatedAt: new Date().toISOString(),
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
this.save(key, next);
|
|
155
|
+
this.records.set(key, next);
|
|
156
|
+
return next;
|
|
157
|
+
}
|
|
158
|
+
async drain() {
|
|
159
|
+
for (const [key, original] of this.records) {
|
|
160
|
+
if (this.controller.signal.aborted)
|
|
161
|
+
return;
|
|
162
|
+
if (original.receipt.state !== 'queued')
|
|
163
|
+
continue;
|
|
164
|
+
let record = original;
|
|
165
|
+
let actionStarted = false;
|
|
166
|
+
try {
|
|
167
|
+
const signal = this.controller.signal;
|
|
168
|
+
record = this.update(key, record, { state: 'transcribing' });
|
|
169
|
+
const audio = readFileSync(join(this.opts.directory, `${key}.m4a`));
|
|
170
|
+
const transcript = await this.opts.transcribe({ format: 'm4a', base64: audio.toString('base64') }, signal);
|
|
171
|
+
signal.throwIfAborted();
|
|
172
|
+
if (transcript.durationSeconds > MAX_CAPTURE_SECONDS ||
|
|
173
|
+
!transcript.text.trim() ||
|
|
174
|
+
transcript.text.length > 8000)
|
|
175
|
+
throw new Error('Record a shorter instruction, up to two minutes.');
|
|
176
|
+
record = this.update(key, record, {
|
|
177
|
+
state: 'acting',
|
|
178
|
+
transcript: transcript.text,
|
|
179
|
+
});
|
|
180
|
+
actionStarted = true;
|
|
181
|
+
this.removeAudio(key);
|
|
182
|
+
const result = await this.opts.act(transcript.text, signal);
|
|
183
|
+
signal.throwIfAborted();
|
|
184
|
+
record = this.update(key, record, {
|
|
185
|
+
state: 'done',
|
|
186
|
+
result: result.slice(0, 4000),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
if (this.controller.signal.aborted && !actionStarted) {
|
|
191
|
+
this.update(key, record, { state: 'queued' });
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// An action may already have caused effects. Do not offer automatic retry.
|
|
195
|
+
record = this.update(key, record, {
|
|
196
|
+
state: actionStarted ? 'uncertain' : 'failed',
|
|
197
|
+
message: actionStarted
|
|
198
|
+
? 'The action could not be confirmed. Check Lucidity before recording it again.'
|
|
199
|
+
: 'The recording could not be processed. Check speech recognition on your computer.',
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (this.terminal(record.receipt))
|
|
203
|
+
this.removeAudio(key);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
stop() {
|
|
207
|
+
this.controller.abort();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SpeechEngine } from './types.js';
|
|
2
|
+
/** Lazy, reusable native process. Model download/loading happens only after an audio request. */
|
|
3
|
+
export declare class FluidAudioEngine implements SpeechEngine {
|
|
4
|
+
private readonly options;
|
|
5
|
+
readonly models: {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description: string;
|
|
9
|
+
}[];
|
|
10
|
+
private child?;
|
|
11
|
+
private idleTimer?;
|
|
12
|
+
private pending?;
|
|
13
|
+
constructor(options?: {
|
|
14
|
+
helperPath?: string;
|
|
15
|
+
modelRoot?: string;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
idleMs?: number;
|
|
18
|
+
});
|
|
19
|
+
availability(): {
|
|
20
|
+
available: boolean;
|
|
21
|
+
reason?: string;
|
|
22
|
+
};
|
|
23
|
+
transcribe(input: Parameters<SpeechEngine['transcribe']>[0]): ReturnType<SpeechEngine['transcribe']>;
|
|
24
|
+
private failChild;
|
|
25
|
+
private stopChild;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=fluidAudio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluidAudio.d.ts","sourceRoot":"","sources":["../../src/speech/fluidAudio.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwC/C,iGAAiG;AACjG,qBAAa,gBAAiB,YAAW,YAAY;IAOjD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,QAAQ,CAAC,MAAM;;;;QAAU;IACzB,OAAO,CAAC,KAAK,CAAC,CAAiC;IAC/C,OAAO,CAAC,SAAS,CAAC,CAAgC;IAClD,OAAO,CAAC,OAAO,CAAC,CAAqC;gBAGlC,OAAO,GAAE;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ;IAGR,YAAY,IAAI;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAsBjD,UAAU,CACd,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/C,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IA6HzC,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,SAAS;IAajB,OAAO,IAAI,IAAI;CAOhB"}
|