@ouro.bot/cli 0.1.0-alpha.59 → 0.1.0-alpha.590
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 +127 -23
- package/RepairGuide.ouro/agent.json +5 -0
- package/RepairGuide.ouro/psyche/IDENTITY.md +19 -0
- package/RepairGuide.ouro/psyche/SOUL.md +55 -0
- package/RepairGuide.ouro/skills/diagnose-broken-remote.md +63 -0
- package/RepairGuide.ouro/skills/diagnose-stacked-typed-issues.md +35 -0
- package/RepairGuide.ouro/skills/diagnose-sync-blocked.md +54 -0
- package/RepairGuide.ouro/skills/diagnose-vault-expired.md +60 -0
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +4 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +2 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
- package/changelog.json +3805 -0
- package/dist/arc/attention-types.js +8 -0
- package/dist/arc/cares.js +140 -0
- package/dist/arc/episodes.js +117 -0
- package/dist/arc/intentions.js +133 -0
- package/dist/arc/json-store.js +117 -0
- package/dist/arc/obligations.js +237 -0
- package/dist/arc/packets.js +193 -0
- package/dist/arc/presence.js +185 -0
- package/dist/arc/task-lifecycle.js +65 -0
- package/dist/heart/active-work.js +837 -26
- package/dist/heart/agent-entry.js +69 -3
- package/dist/heart/attachments/image-normalize.js +194 -0
- package/dist/heart/attachments/materialize.js +97 -0
- package/dist/heart/attachments/originals.js +88 -0
- package/dist/heart/attachments/render.js +29 -0
- package/dist/heart/attachments/sources/adapter.js +2 -0
- package/dist/heart/attachments/sources/bluebubbles.js +156 -0
- package/dist/heart/attachments/sources/cli-local-file.js +78 -0
- package/dist/heart/attachments/sources/index.js +16 -0
- package/dist/heart/attachments/store.js +103 -0
- package/dist/heart/attachments/types.js +93 -0
- package/dist/heart/auth/auth-flow.js +479 -0
- package/dist/heart/background-operations.js +281 -0
- package/dist/heart/bundle-state.js +168 -0
- package/dist/heart/commitments.js +111 -0
- package/dist/heart/config-registry.js +322 -0
- package/dist/heart/config.js +114 -118
- package/dist/heart/core.js +909 -246
- package/dist/heart/cross-chat-delivery.js +3 -18
- package/dist/heart/daemon/agent-config-check.js +419 -0
- package/dist/heart/daemon/agent-discovery.js +102 -3
- package/dist/heart/daemon/agent-service.js +522 -0
- package/dist/heart/daemon/agentic-repair.js +547 -0
- package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
- package/dist/heart/daemon/boot-sync-probe.js +197 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/cli-defaults.js +776 -0
- package/dist/heart/daemon/cli-exec.js +7559 -0
- package/dist/heart/daemon/cli-help.js +498 -0
- package/dist/heart/daemon/cli-parse.js +1592 -0
- package/dist/heart/daemon/cli-render-doctor.js +57 -0
- package/dist/heart/daemon/cli-render.js +763 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/connect-bay.js +323 -0
- package/dist/heart/daemon/daemon-cli.js +29 -1703
- package/dist/heart/daemon/daemon-entry.js +387 -2
- package/dist/heart/daemon/daemon-health.js +176 -0
- package/dist/heart/daemon/daemon-rollup.js +57 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +88 -13
- package/dist/heart/daemon/daemon-tombstone.js +236 -0
- package/dist/heart/daemon/daemon.js +815 -70
- package/dist/heart/daemon/dns-workflow.js +394 -0
- package/dist/heart/daemon/doctor-types.js +8 -0
- package/dist/heart/daemon/doctor.js +873 -0
- package/dist/heart/daemon/health-monitor.js +122 -1
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +115 -1
- package/dist/heart/daemon/http-health-probe.js +80 -0
- package/dist/heart/daemon/human-command-screens.js +234 -0
- package/dist/heart/daemon/human-readiness.js +114 -0
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/interactive-repair.js +394 -0
- package/dist/heart/daemon/launchd.js +37 -8
- package/dist/heart/daemon/log-tailer.js +78 -9
- package/dist/heart/daemon/logs-prune.js +110 -0
- package/dist/heart/daemon/mcp-canary.js +297 -0
- package/dist/heart/daemon/os-cron-deps.js +135 -0
- package/dist/heart/daemon/os-cron.js +14 -12
- package/dist/heart/daemon/ouro-bot-entry.js +4 -2
- package/dist/heart/daemon/ouro-entry.js +3 -1
- package/dist/heart/daemon/process-manager.js +375 -33
- package/dist/heart/daemon/provider-discovery.js +137 -0
- package/dist/heart/daemon/provider-ping-progress.js +83 -0
- package/dist/heart/daemon/pulse.js +475 -0
- package/dist/heart/daemon/readiness-repair.js +365 -0
- package/dist/heart/daemon/run-hooks.js +2 -0
- package/dist/heart/daemon/runtime-logging.js +10 -2
- package/dist/heart/daemon/runtime-metadata.js +2 -30
- package/dist/heart/daemon/safe-mode.js +161 -0
- package/dist/heart/daemon/sense-manager.js +462 -38
- package/dist/heart/daemon/session-id-resolver.js +131 -0
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +158 -11
- package/dist/heart/daemon/stale-bundle-prune.js +96 -0
- package/dist/heart/daemon/startup-tui.js +330 -0
- package/dist/heart/daemon/task-scheduler.js +3 -25
- package/dist/heart/daemon/terminal-ui.js +499 -0
- package/dist/heart/daemon/thoughts.js +162 -17
- package/dist/heart/daemon/up-progress.js +366 -0
- package/dist/heart/daemon/vault-items.js +56 -0
- package/dist/heart/delegation.js +1 -1
- package/dist/heart/habits/habit-migration.js +189 -0
- package/dist/heart/habits/habit-parser.js +140 -0
- package/dist/heart/habits/habit-runtime-state.js +100 -0
- package/dist/heart/habits/habit-scheduler.js +372 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +32 -56
- package/dist/heart/{daemon → hatch}/hatch-specialist.js +6 -8
- package/dist/heart/{daemon → hatch}/specialist-prompt.js +12 -9
- package/dist/heart/{daemon → hatch}/specialist-tools.js +35 -12
- package/dist/heart/identity.js +166 -55
- package/dist/heart/kept-notes.js +357 -0
- package/dist/heart/kicks.js +1 -1
- package/dist/heart/machine-identity.js +161 -0
- package/dist/heart/mail-import-discovery.js +353 -0
- package/dist/heart/mailbox/mailbox-http-hooks.js +66 -0
- package/dist/heart/mailbox/mailbox-http-response.js +7 -0
- package/dist/heart/mailbox/mailbox-http-routes.js +246 -0
- package/dist/heart/mailbox/mailbox-http-static.js +103 -0
- package/dist/heart/mailbox/mailbox-http-transport.js +116 -0
- package/dist/heart/mailbox/mailbox-http.js +99 -0
- package/dist/heart/mailbox/mailbox-read.js +31 -0
- package/dist/heart/mailbox/mailbox-types.js +27 -0
- package/dist/heart/mailbox/mailbox-view.js +195 -0
- package/dist/heart/mailbox/readers/agent-machine.js +382 -0
- package/dist/heart/mailbox/readers/continuity-readers.js +338 -0
- package/dist/heart/mailbox/readers/mail.js +362 -0
- package/dist/heart/mailbox/readers/runtime-readers.js +651 -0
- package/dist/heart/mailbox/readers/sessions.js +232 -0
- package/dist/heart/mailbox/readers/shared.js +111 -0
- package/dist/heart/mcp/mcp-server.js +656 -0
- package/dist/heart/migrate-config.js +100 -0
- package/dist/heart/model-capabilities.js +19 -0
- package/dist/heart/platform.js +81 -0
- package/dist/heart/provider-attempt.js +134 -0
- package/dist/heart/provider-binding-resolver.js +267 -0
- package/dist/heart/provider-credentials.js +425 -0
- package/dist/heart/provider-failover.js +301 -0
- package/dist/heart/provider-models.js +81 -0
- package/dist/heart/provider-ping.js +262 -0
- package/dist/heart/provider-readiness-cache.js +40 -0
- package/dist/heart/provider-visibility.js +188 -0
- package/dist/heart/providers/anthropic-token.js +131 -0
- package/dist/heart/providers/anthropic.js +139 -52
- package/dist/heart/providers/azure.js +97 -13
- package/dist/heart/providers/error-classification.js +127 -0
- package/dist/heart/providers/github-copilot.js +145 -0
- package/dist/heart/providers/minimax-vlm.js +189 -0
- package/dist/heart/providers/minimax.js +26 -8
- package/dist/heart/providers/openai-codex.js +55 -40
- package/dist/heart/runtime-capability-check.js +170 -0
- package/dist/heart/runtime-credentials.js +367 -0
- package/dist/heart/runtime-cwd.js +87 -0
- package/dist/heart/sense-truth.js +13 -4
- package/dist/heart/session-activity.js +43 -22
- package/dist/heart/session-events.js +1149 -0
- package/dist/heart/session-playback-cli-main.js +5 -0
- package/dist/heart/session-playback-cli.js +36 -0
- package/dist/heart/session-playback.js +231 -0
- package/dist/heart/session-stats-cli-main.js +5 -0
- package/dist/heart/session-stats.js +182 -0
- package/dist/heart/session-transcript.js +243 -0
- package/dist/heart/start-of-turn-packet.js +345 -0
- package/dist/heart/streaming.js +44 -27
- package/dist/heart/sync-classification.js +176 -0
- package/dist/heart/sync.js +449 -0
- package/dist/heart/target-resolution.js +9 -5
- package/dist/heart/tempo.js +93 -0
- package/dist/heart/temporal-view.js +41 -0
- package/dist/heart/timeouts.js +101 -0
- package/dist/heart/tool-activity-callbacks.js +59 -0
- package/dist/heart/tool-description.js +143 -0
- package/dist/heart/tool-friction.js +55 -0
- package/dist/heart/tool-loop.js +200 -0
- package/dist/heart/turn-context.js +421 -0
- package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +6 -5
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
- package/dist/heart/versioning/ouro-path-installer.js +426 -0
- package/dist/heart/versioning/ouro-version-manager.js +295 -0
- package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
- package/dist/heart/{daemon → versioning}/update-checker.js +6 -1
- package/dist/heart/{daemon → versioning}/update-hooks.js +63 -59
- package/dist/mailbox-ui/assets/index-B-461hes.js +61 -0
- package/dist/mailbox-ui/assets/index-BPr5vNuM.css +1 -0
- package/dist/mailbox-ui/index.html +15 -0
- package/dist/mailroom/attention.js +167 -0
- package/dist/mailroom/autonomy.js +209 -0
- package/dist/mailroom/blob-store.js +674 -0
- package/dist/mailroom/body-cache.js +61 -0
- package/dist/mailroom/core.js +720 -0
- package/dist/mailroom/entry.js +160 -0
- package/dist/mailroom/file-store.js +430 -0
- package/dist/mailroom/mbox-import.js +383 -0
- package/dist/mailroom/outbound.js +380 -0
- package/dist/mailroom/policy.js +263 -0
- package/dist/mailroom/reader.js +233 -0
- package/dist/mailroom/search-cache.js +268 -0
- package/dist/mailroom/search-relevance.js +319 -0
- package/dist/mailroom/smtp-ingress.js +176 -0
- package/dist/mailroom/source-state.js +176 -0
- package/dist/mailroom/thread.js +109 -0
- package/dist/mailroom/travel-extract.js +89 -0
- package/dist/mind/bundle-manifest.js +7 -1
- package/dist/mind/context.js +165 -101
- package/dist/mind/diary-integrity.js +60 -0
- package/dist/mind/{memory.js → diary.js} +62 -75
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/friends/channel.js +39 -0
- package/dist/mind/friends/resolver.js +54 -2
- package/dist/mind/friends/store-file.js +39 -3
- package/dist/mind/friends/types.js +2 -2
- package/dist/mind/journal-index.js +161 -0
- package/dist/mind/note-search.js +268 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/pending.js +4 -0
- package/dist/mind/prompt-refresh.js +3 -2
- package/dist/mind/prompt.js +1039 -135
- package/dist/mind/provenance-trust.js +26 -0
- package/dist/mind/scrutiny.js +173 -0
- package/dist/nerves/cli-logging.js +7 -1
- package/dist/nerves/coverage/audit-rules.js +15 -6
- package/dist/nerves/coverage/audit.js +28 -2
- package/dist/nerves/coverage/cli.js +1 -1
- package/dist/nerves/coverage/contract.js +5 -5
- package/dist/nerves/coverage/file-completeness.js +129 -5
- package/dist/nerves/event-buffer.js +111 -0
- package/dist/nerves/index.js +224 -4
- package/dist/nerves/observation.js +20 -0
- package/dist/nerves/redact.js +79 -0
- package/dist/nerves/review/cli-main.js +5 -0
- package/dist/nerves/review/cli.js +156 -0
- package/dist/nerves/review/core.js +152 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/repertoire/ado-client.js +15 -56
- package/dist/repertoire/ado-semantic.js +11 -10
- package/dist/repertoire/api-client.js +97 -0
- package/dist/repertoire/bitwarden-store.js +997 -0
- package/dist/repertoire/bundle-templates.js +72 -0
- package/dist/repertoire/bw-installer.js +180 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +330 -0
- package/dist/repertoire/coding/feedback.js +197 -30
- package/dist/repertoire/coding/manager.js +158 -9
- package/dist/repertoire/coding/spawner.js +55 -9
- package/dist/repertoire/coding/tools.js +170 -7
- package/dist/repertoire/commerce-errors.js +109 -0
- package/dist/repertoire/commerce-self-test.js +156 -0
- package/dist/repertoire/credential-access.js +178 -0
- package/dist/repertoire/duffel-client.js +185 -0
- package/dist/repertoire/github-client.js +14 -55
- package/dist/repertoire/graph-client.js +11 -52
- package/dist/repertoire/guardrails.js +396 -0
- package/dist/repertoire/mcp-client.js +295 -0
- package/dist/repertoire/mcp-manager.js +362 -0
- package/dist/repertoire/mcp-tools.js +63 -0
- package/dist/repertoire/shell-sessions.js +133 -0
- package/dist/repertoire/skills.js +15 -24
- package/dist/repertoire/stripe-client.js +131 -0
- package/dist/repertoire/tasks/board.js +31 -5
- package/dist/repertoire/tasks/fix.js +182 -0
- package/dist/repertoire/tasks/index.js +16 -4
- package/dist/repertoire/tasks/lifecycle.js +2 -2
- package/dist/repertoire/tasks/parser.js +3 -2
- package/dist/repertoire/tasks/scanner.js +194 -37
- package/dist/repertoire/tasks/transitions.js +16 -78
- package/dist/repertoire/tool-results.js +29 -0
- package/dist/repertoire/tools-attachments.js +317 -0
- package/dist/repertoire/tools-base.js +47 -1082
- package/dist/repertoire/tools-bluebubbles.js +1 -0
- package/dist/repertoire/tools-bridge.js +142 -0
- package/dist/repertoire/tools-bundle.js +984 -0
- package/dist/repertoire/tools-config.js +185 -0
- package/dist/repertoire/tools-continuity.js +248 -0
- package/dist/repertoire/tools-credential.js +381 -0
- package/dist/repertoire/tools-files.js +342 -0
- package/dist/repertoire/tools-flight.js +224 -0
- package/dist/repertoire/tools-flow.js +119 -0
- package/dist/repertoire/tools-github.js +1 -7
- package/dist/repertoire/tools-mail.js +1911 -0
- package/dist/repertoire/tools-notes.js +421 -0
- package/dist/repertoire/tools-session.js +809 -0
- package/dist/repertoire/tools-shell.js +120 -0
- package/dist/repertoire/tools-stripe.js +180 -0
- package/dist/repertoire/tools-surface.js +345 -0
- package/dist/repertoire/tools-teams.js +9 -39
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools-trip.js +604 -0
- package/dist/repertoire/tools-user-profile.js +144 -0
- package/dist/repertoire/tools-vault.js +40 -0
- package/dist/repertoire/tools-voice.js +144 -0
- package/dist/repertoire/tools.js +115 -103
- package/dist/repertoire/travel-api-client.js +360 -0
- package/dist/repertoire/user-profile.js +131 -0
- package/dist/repertoire/vault-setup.js +246 -0
- package/dist/repertoire/vault-unlock.js +594 -0
- package/dist/scripts/claude-code-hook.js +41 -0
- package/dist/scripts/claude-code-stop-hook.js +47 -0
- package/dist/senses/attention-queue.js +116 -0
- package/dist/senses/bluebubbles/active-turns.js +216 -0
- package/dist/senses/bluebubbles/attachment-cache.js +53 -0
- package/dist/senses/bluebubbles/attachment-download.js +137 -0
- package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +219 -18
- package/dist/senses/bluebubbles/entry.js +77 -0
- package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +20 -3
- package/dist/senses/bluebubbles/index.js +2487 -0
- package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -71
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +33 -12
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +3 -3
- package/dist/senses/bluebubbles/processed-log.js +133 -0
- package/dist/senses/bluebubbles/replay.js +137 -0
- package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +30 -2
- package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
- package/dist/senses/bluebubbles-meta-guard.js +40 -0
- package/dist/senses/cli/bracketed-paste.js +82 -0
- package/dist/senses/cli/image-paste.js +287 -0
- package/dist/senses/cli/image-ref-navigation.js +75 -0
- package/dist/senses/cli/ink-app.js +156 -0
- package/dist/senses/cli/inline-diff.js +64 -0
- package/dist/senses/cli/input-keys.js +174 -0
- package/dist/senses/cli/kill-ring.js +86 -0
- package/dist/senses/cli/message-list.js +51 -0
- package/dist/senses/cli/ouro-tui.js +607 -0
- package/dist/senses/cli/spinner-imperative.js +135 -0
- package/dist/senses/cli/spinner.js +101 -0
- package/dist/senses/cli/status-line.js +60 -0
- package/dist/senses/cli/streaming-markdown.js +526 -0
- package/dist/senses/cli/tool-display.js +85 -0
- package/dist/senses/cli/tool-render.js +85 -0
- package/dist/senses/cli/tui-store.js +240 -0
- package/dist/senses/cli/virtual-list.js +35 -0
- package/dist/senses/cli-entry.js +60 -8
- package/dist/senses/cli-layout.js +100 -0
- package/dist/senses/cli.js +516 -204
- package/dist/senses/commands.js +66 -3
- package/dist/senses/habit-turn-message.js +108 -0
- package/dist/senses/inner-dialog-worker.js +175 -21
- package/dist/senses/inner-dialog.js +330 -27
- package/dist/senses/mail-entry.js +66 -0
- package/dist/senses/mail.js +379 -0
- package/dist/senses/pipeline.js +654 -181
- package/dist/senses/proactive-content-guard.js +51 -0
- package/dist/senses/shared-turn.js +392 -0
- package/dist/senses/surface-tool.js +70 -0
- package/dist/senses/teams-entry.js +60 -8
- package/dist/senses/teams.js +387 -98
- package/dist/senses/trust-gate.js +100 -5
- package/dist/senses/voice/audio-playback.js +237 -0
- package/dist/senses/voice/audio-routing.js +119 -0
- package/dist/senses/voice/elevenlabs.js +202 -0
- package/dist/senses/voice/floor-control.js +398 -0
- package/dist/senses/voice/floor-controller.js +115 -0
- package/dist/senses/voice/golden-path.js +116 -0
- package/dist/senses/voice/index.js +29 -0
- package/dist/senses/voice/meeting.js +113 -0
- package/dist/senses/voice/outbound.js +190 -0
- package/dist/senses/voice/phone.js +33 -0
- package/dist/senses/voice/playback.js +139 -0
- package/dist/senses/voice/realtime-eval.js +496 -0
- package/dist/senses/voice/realtime-trace.js +531 -0
- package/dist/senses/voice/transcript.js +70 -0
- package/dist/senses/voice/turn.js +191 -0
- package/dist/senses/voice/twilio-phone-runtime.js +794 -0
- package/dist/senses/voice/twilio-phone.js +4995 -0
- package/dist/senses/voice/types.js +2 -0
- package/dist/senses/voice/whisper.js +161 -0
- package/dist/senses/voice-entry.js +81 -0
- package/dist/senses/voice-realtime-eval-command.js +99 -0
- package/dist/senses/voice-realtime-eval-entry.js +21 -0
- package/dist/senses/voice-twilio-entry.js +87 -0
- package/dist/trips/core.js +138 -0
- package/dist/trips/store.js +265 -0
- package/package.json +42 -7
- package/skills/agent-commerce.md +106 -0
- package/skills/browser-navigation.md +117 -0
- package/skills/commerce-setup-guide.md +116 -0
- package/skills/commerce-setup.md +84 -0
- package/skills/configure-dev-tools.md +99 -0
- package/skills/travel-planning.md +138 -0
- package/dist/heart/daemon/auth-flow.js +0 -351
- package/dist/heart/daemon/ouro-path-installer.js +0 -178
- package/dist/heart/daemon/subagent-installer.js +0 -166
- package/dist/heart/safe-workspace.js +0 -228
- package/dist/heart/session-recall.js +0 -116
- package/dist/mind/associative-recall.js +0 -209
- package/dist/senses/bluebubbles-entry.js +0 -13
- package/dist/senses/bluebubbles.js +0 -1177
- package/dist/senses/debug-activity.js +0 -148
- package/subagents/README.md +0 -86
- package/subagents/work-doer.md +0 -237
- package/subagents/work-merger.md +0 -618
- package/subagents/work-planner.md +0 -390
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
- /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
- /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
- /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
- /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInitialVoiceFloorState = createInitialVoiceFloorState;
|
|
4
|
+
exports.canRequestVoiceResponse = canRequestVoiceResponse;
|
|
5
|
+
exports.canSpeakToolHolding = canSpeakToolHolding;
|
|
6
|
+
exports.canSpeakToolResult = canSpeakToolResult;
|
|
7
|
+
exports.applyVoiceFloorEvent = applyVoiceFloorEvent;
|
|
8
|
+
exports.replayVoiceFloorEvents = replayVoiceFloorEvents;
|
|
9
|
+
exports.summarizeVoiceFloorState = summarizeVoiceFloorState;
|
|
10
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
11
|
+
const MAX_TOOL_HOLDING_WORDS = 6;
|
|
12
|
+
function createInitialVoiceFloorState() {
|
|
13
|
+
return {
|
|
14
|
+
phase: "idle",
|
|
15
|
+
floorOwner: "none",
|
|
16
|
+
terminal: false,
|
|
17
|
+
hangupRequested: false,
|
|
18
|
+
pendingToolCallIds: [],
|
|
19
|
+
staleToolCallIds: [],
|
|
20
|
+
spokenToolCallIds: [],
|
|
21
|
+
callerTurnIds: [],
|
|
22
|
+
toolCalls: {},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function decision(allowed, action, reason, details = {}) {
|
|
26
|
+
return { allowed, action, reason, ...details };
|
|
27
|
+
}
|
|
28
|
+
function copyState(state) {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
pendingToolCallIds: [...state.pendingToolCallIds],
|
|
32
|
+
staleToolCallIds: [...state.staleToolCallIds],
|
|
33
|
+
spokenToolCallIds: [...state.spokenToolCallIds],
|
|
34
|
+
callerTurnIds: [...state.callerTurnIds],
|
|
35
|
+
toolCalls: { ...state.toolCalls },
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function withUnique(values, value) {
|
|
39
|
+
return values.includes(value) ? values : [...values, value];
|
|
40
|
+
}
|
|
41
|
+
function withoutValue(values, value) {
|
|
42
|
+
return values.filter((candidate) => candidate !== value);
|
|
43
|
+
}
|
|
44
|
+
function rememberCallerTurn(state, turnId) {
|
|
45
|
+
state.latestCallerTurnId = turnId;
|
|
46
|
+
state.callerTurnIds = withUnique(state.callerTurnIds, turnId);
|
|
47
|
+
}
|
|
48
|
+
function hasNewerCallerTurn(state, turnId) {
|
|
49
|
+
if (!turnId || !state.latestCallerTurnId || state.latestCallerTurnId === turnId)
|
|
50
|
+
return false;
|
|
51
|
+
const originalIndex = state.callerTurnIds.indexOf(turnId);
|
|
52
|
+
const latestIndex = state.callerTurnIds.indexOf(state.latestCallerTurnId);
|
|
53
|
+
return originalIndex >= 0 && latestIndex > originalIndex;
|
|
54
|
+
}
|
|
55
|
+
function toolState(state, toolCallId) {
|
|
56
|
+
return state.toolCalls[toolCallId];
|
|
57
|
+
}
|
|
58
|
+
function setToolState(state, nextTool) {
|
|
59
|
+
state.toolCalls = { ...state.toolCalls, [nextTool.toolCallId]: nextTool };
|
|
60
|
+
}
|
|
61
|
+
function phaseAfterAssistantSpeech(state) {
|
|
62
|
+
const pendingTools = state.pendingToolCallIds.map((toolCallId) => state.toolCalls[toolCallId]).filter(Boolean);
|
|
63
|
+
if (pendingTools.some((tool) => tool.status === "ready"))
|
|
64
|
+
return "tool-result-ready";
|
|
65
|
+
if (pendingTools.some((tool) => tool.status === "running"))
|
|
66
|
+
return "tool-running";
|
|
67
|
+
return "listening";
|
|
68
|
+
}
|
|
69
|
+
function suppressForHangup(state, event) {
|
|
70
|
+
return {
|
|
71
|
+
event,
|
|
72
|
+
state,
|
|
73
|
+
decision: decision(false, "suppress", "hangup_terminal", { atMs: event.atMs }),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function canRequestVoiceResponse(state, input) {
|
|
77
|
+
if (state.terminal || state.hangupRequested || state.floorOwner === "terminal") {
|
|
78
|
+
return decision(false, "suppress", "hangup_terminal", { responseId: input.responseId });
|
|
79
|
+
}
|
|
80
|
+
if (state.floorOwner === "caller" || state.phase === "caller-speaking" || state.phase === "interrupted") {
|
|
81
|
+
return decision(false, "delay", "caller_has_floor", { responseId: input.responseId });
|
|
82
|
+
}
|
|
83
|
+
if (state.floorOwner === "assistant" || state.activeAssistantSpeechId) {
|
|
84
|
+
return decision(false, "delay", "assistant_has_floor", { responseId: input.responseId });
|
|
85
|
+
}
|
|
86
|
+
if (state.pendingSpeech) {
|
|
87
|
+
return decision(false, "delay", "response_pending", { responseId: input.responseId });
|
|
88
|
+
}
|
|
89
|
+
return decision(true, "allow", "ready_for_response", { responseId: input.responseId });
|
|
90
|
+
}
|
|
91
|
+
function canSpeakToolHolding(state, input) {
|
|
92
|
+
if (state.terminal || state.hangupRequested || state.floorOwner === "terminal") {
|
|
93
|
+
return decision(false, "suppress", "hangup_terminal", { toolCallId: input.toolCallId });
|
|
94
|
+
}
|
|
95
|
+
if (state.floorOwner === "caller" || state.phase === "caller-speaking" || state.phase === "interrupted") {
|
|
96
|
+
return decision(false, "delay", "caller_has_floor", { toolCallId: input.toolCallId });
|
|
97
|
+
}
|
|
98
|
+
const tool = toolState(state, input.toolCallId);
|
|
99
|
+
if (!tool || tool.status === "spoken") {
|
|
100
|
+
return decision(false, "suppress", "missing_tool_call", { toolCallId: input.toolCallId });
|
|
101
|
+
}
|
|
102
|
+
if (tool.status === "stale" || state.staleToolCallIds.includes(input.toolCallId)) {
|
|
103
|
+
return decision(false, "suppress", "stale_tool_result", { toolCallId: input.toolCallId });
|
|
104
|
+
}
|
|
105
|
+
const words = input.text?.trim().split(/\s+/).filter(Boolean).length ?? 0;
|
|
106
|
+
if (words > MAX_TOOL_HOLDING_WORDS) {
|
|
107
|
+
return decision(false, "suppress", "tool_holding_too_long", { toolCallId: input.toolCallId });
|
|
108
|
+
}
|
|
109
|
+
return decision(true, "allow", "tool_presence_allowed", { toolCallId: input.toolCallId });
|
|
110
|
+
}
|
|
111
|
+
function canSpeakToolResult(state, input) {
|
|
112
|
+
if (state.terminal || state.hangupRequested || state.floorOwner === "terminal") {
|
|
113
|
+
return decision(false, "suppress", "hangup_terminal", { toolCallId: input.toolCallId });
|
|
114
|
+
}
|
|
115
|
+
if (state.floorOwner === "caller" || state.phase === "caller-speaking" || state.phase === "interrupted") {
|
|
116
|
+
return decision(false, "delay", "caller_has_floor", { toolCallId: input.toolCallId });
|
|
117
|
+
}
|
|
118
|
+
const tool = toolState(state, input.toolCallId);
|
|
119
|
+
if (!tool || tool.status === "spoken") {
|
|
120
|
+
return decision(false, "suppress", "missing_tool_result", { toolCallId: input.toolCallId });
|
|
121
|
+
}
|
|
122
|
+
if (tool.status === "stale" || state.staleToolCallIds.includes(input.toolCallId)) {
|
|
123
|
+
return decision(false, "suppress", "stale_tool_result", { toolCallId: input.toolCallId });
|
|
124
|
+
}
|
|
125
|
+
if (tool.status !== "ready") {
|
|
126
|
+
return decision(false, "delay", "tool_still_running", { toolCallId: input.toolCallId });
|
|
127
|
+
}
|
|
128
|
+
return decision(true, "allow", "tool_result_ready", { toolCallId: input.toolCallId });
|
|
129
|
+
}
|
|
130
|
+
function applyConnected(state, event) {
|
|
131
|
+
const next = copyState(state);
|
|
132
|
+
next.phase = "listening";
|
|
133
|
+
next.floorOwner = "none";
|
|
134
|
+
next.terminal = false;
|
|
135
|
+
next.hangupRequested = false;
|
|
136
|
+
next.callId = event.callId;
|
|
137
|
+
return { event, state: next, decision: decision(true, "allow", "call_connected", { atMs: event.atMs }) };
|
|
138
|
+
}
|
|
139
|
+
function applyCallerSpeechStarted(state, event) {
|
|
140
|
+
const next = copyState(state);
|
|
141
|
+
rememberCallerTurn(next, event.turnId);
|
|
142
|
+
next.floorOwner = "caller";
|
|
143
|
+
if (state.activeAssistantSpeechId) {
|
|
144
|
+
next.phase = "interrupted";
|
|
145
|
+
next.interruption = {
|
|
146
|
+
turnId: event.turnId,
|
|
147
|
+
interruptedSpeechId: state.activeAssistantSpeechId,
|
|
148
|
+
atMs: event.atMs,
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
event,
|
|
152
|
+
state: next,
|
|
153
|
+
decision: decision(false, "cancel", "caller_barge_in", {
|
|
154
|
+
atMs: event.atMs,
|
|
155
|
+
responseId: state.activeAssistantSpeechId,
|
|
156
|
+
interruptionTurnId: event.turnId,
|
|
157
|
+
}),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
next.phase = "caller-speaking";
|
|
161
|
+
return { event, state: next, decision: decision(true, "allow", "caller_floor_started", { atMs: event.atMs }) };
|
|
162
|
+
}
|
|
163
|
+
function applyCallerSpeechEnded(state, event) {
|
|
164
|
+
const next = copyState(state);
|
|
165
|
+
rememberCallerTurn(next, event.turnId);
|
|
166
|
+
if (!next.activeAssistantSpeechId) {
|
|
167
|
+
next.floorOwner = "none";
|
|
168
|
+
next.phase = "listening";
|
|
169
|
+
}
|
|
170
|
+
return { event, state: next, decision: decision(true, "allow", "caller_floor_released", { atMs: event.atMs }) };
|
|
171
|
+
}
|
|
172
|
+
function applyCallerTranscriptFinal(state, event) {
|
|
173
|
+
const next = copyState(state);
|
|
174
|
+
rememberCallerTurn(next, event.turnId);
|
|
175
|
+
if (!next.activeAssistantSpeechId) {
|
|
176
|
+
next.floorOwner = "none";
|
|
177
|
+
next.phase = "thinking";
|
|
178
|
+
}
|
|
179
|
+
return { event, state: next, decision: decision(true, "allow", "caller_turn_ready", { atMs: event.atMs }) };
|
|
180
|
+
}
|
|
181
|
+
function applyAssistantResponseRequested(state, event) {
|
|
182
|
+
const requestDecision = canRequestVoiceResponse(state, { responseId: event.responseId, reason: event.reason });
|
|
183
|
+
if (!requestDecision.allowed)
|
|
184
|
+
return { event, state, decision: { ...requestDecision, atMs: event.atMs } };
|
|
185
|
+
const next = copyState(state);
|
|
186
|
+
next.phase = "thinking";
|
|
187
|
+
next.floorOwner = "none";
|
|
188
|
+
next.pendingSpeech = { responseId: event.responseId, reason: event.reason };
|
|
189
|
+
return { event, state: next, decision: { ...requestDecision, atMs: event.atMs } };
|
|
190
|
+
}
|
|
191
|
+
function applyAssistantSpeechStarted(state, event) {
|
|
192
|
+
const requestDecision = state.floorOwner === "caller"
|
|
193
|
+
? decision(false, "delay", "caller_has_floor", { atMs: event.atMs, responseId: event.responseId })
|
|
194
|
+
: decision(true, "allow", "assistant_speech_allowed", { atMs: event.atMs, responseId: event.responseId });
|
|
195
|
+
if (!requestDecision.allowed)
|
|
196
|
+
return { event, state, decision: requestDecision };
|
|
197
|
+
const next = copyState(state);
|
|
198
|
+
next.phase = "speaking";
|
|
199
|
+
next.floorOwner = "assistant";
|
|
200
|
+
next.activeAssistantSpeechId = event.responseId;
|
|
201
|
+
next.pendingSpeech = undefined;
|
|
202
|
+
return { event, state: next, decision: requestDecision };
|
|
203
|
+
}
|
|
204
|
+
function applyAssistantSpeechDone(state, event) {
|
|
205
|
+
const next = copyState(state);
|
|
206
|
+
if (next.activeAssistantSpeechId === event.responseId)
|
|
207
|
+
next.activeAssistantSpeechId = undefined;
|
|
208
|
+
if (next.floorOwner === "assistant")
|
|
209
|
+
next.floorOwner = "none";
|
|
210
|
+
next.phase = phaseAfterAssistantSpeech(next);
|
|
211
|
+
return { event, state: next, decision: decision(true, "allow", "assistant_speech_done", { atMs: event.atMs, responseId: event.responseId }) };
|
|
212
|
+
}
|
|
213
|
+
function applyAssistantSpeechCancelled(state, event) {
|
|
214
|
+
const next = copyState(state);
|
|
215
|
+
if (next.activeAssistantSpeechId === event.responseId)
|
|
216
|
+
next.activeAssistantSpeechId = undefined;
|
|
217
|
+
if (next.interruption) {
|
|
218
|
+
next.floorOwner = "caller";
|
|
219
|
+
next.phase = "caller-speaking";
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
next.floorOwner = "none";
|
|
223
|
+
next.phase = phaseAfterAssistantSpeech(next);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
event,
|
|
227
|
+
state: next,
|
|
228
|
+
decision: decision(true, "allow", "assistant_speech_cancelled", { atMs: event.atMs, responseId: event.responseId }),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function applyToolStarted(state, event) {
|
|
232
|
+
if (state.toolCalls[event.toolCallId]) {
|
|
233
|
+
return {
|
|
234
|
+
event,
|
|
235
|
+
state,
|
|
236
|
+
decision: decision(true, "allow", "duplicate_tool_start_ignored", { atMs: event.atMs, toolCallId: event.toolCallId }),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
const next = copyState(state);
|
|
240
|
+
next.pendingToolCallIds = withUnique(next.pendingToolCallIds, event.toolCallId);
|
|
241
|
+
setToolState(next, {
|
|
242
|
+
toolCallId: event.toolCallId,
|
|
243
|
+
toolName: event.toolName,
|
|
244
|
+
turnId: event.turnId ?? next.latestCallerTurnId,
|
|
245
|
+
status: "running",
|
|
246
|
+
startedAtMs: event.atMs,
|
|
247
|
+
});
|
|
248
|
+
if (next.floorOwner === "none")
|
|
249
|
+
next.phase = "tool-running";
|
|
250
|
+
return { event, state: next, decision: decision(true, "allow", "tool_started", { atMs: event.atMs, toolCallId: event.toolCallId }) };
|
|
251
|
+
}
|
|
252
|
+
function applyToolHoldingSpoken(state, event) {
|
|
253
|
+
const holdingDecision = canSpeakToolHolding(state, { toolCallId: event.toolCallId, text: event.text });
|
|
254
|
+
if (!holdingDecision.allowed)
|
|
255
|
+
return { event, state, decision: { ...holdingDecision, atMs: event.atMs } };
|
|
256
|
+
return { event, state, decision: { ...holdingDecision, atMs: event.atMs } };
|
|
257
|
+
}
|
|
258
|
+
function applyToolCompleted(state, event) {
|
|
259
|
+
const existing = toolState(state, event.toolCallId);
|
|
260
|
+
if (!existing) {
|
|
261
|
+
return {
|
|
262
|
+
event,
|
|
263
|
+
state,
|
|
264
|
+
decision: decision(false, "suppress", "missing_tool_call", { atMs: event.atMs, toolCallId: event.toolCallId }),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (existing.status !== "running") {
|
|
268
|
+
return {
|
|
269
|
+
event,
|
|
270
|
+
state,
|
|
271
|
+
decision: decision(true, "allow", "duplicate_tool_completion_ignored", { atMs: event.atMs, toolCallId: event.toolCallId }),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const turnId = event.turnId ?? existing.turnId;
|
|
275
|
+
const next = copyState(state);
|
|
276
|
+
if (hasNewerCallerTurn(next, turnId)) {
|
|
277
|
+
next.pendingToolCallIds = withoutValue(next.pendingToolCallIds, event.toolCallId);
|
|
278
|
+
next.staleToolCallIds = withUnique(next.staleToolCallIds, event.toolCallId);
|
|
279
|
+
setToolState(next, { ...existing, turnId, status: "stale", completedAtMs: event.atMs });
|
|
280
|
+
if (next.floorOwner === "none")
|
|
281
|
+
next.phase = "suppressing";
|
|
282
|
+
return {
|
|
283
|
+
event,
|
|
284
|
+
state: next,
|
|
285
|
+
decision: decision(false, "suppress", "newer_user_turn_started", { atMs: event.atMs, toolCallId: event.toolCallId }),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
setToolState(next, { ...existing, turnId, status: "ready", completedAtMs: event.atMs });
|
|
289
|
+
next.pendingToolCallIds = withUnique(next.pendingToolCallIds, event.toolCallId);
|
|
290
|
+
if (next.floorOwner === "none")
|
|
291
|
+
next.phase = "tool-result-ready";
|
|
292
|
+
return { event, state: next, decision: decision(true, "allow", "tool_result_ready", { atMs: event.atMs, toolCallId: event.toolCallId }) };
|
|
293
|
+
}
|
|
294
|
+
function applyToolResultSpoken(state, event) {
|
|
295
|
+
const resultDecision = canSpeakToolResult(state, { toolCallId: event.toolCallId, text: event.text });
|
|
296
|
+
if (!resultDecision.allowed)
|
|
297
|
+
return { event, state, decision: { ...resultDecision, atMs: event.atMs } };
|
|
298
|
+
const existing = toolState(state, event.toolCallId);
|
|
299
|
+
const next = copyState(state);
|
|
300
|
+
setToolState(next, { ...existing, status: "spoken" });
|
|
301
|
+
next.pendingToolCallIds = withoutValue(next.pendingToolCallIds, event.toolCallId);
|
|
302
|
+
next.spokenToolCallIds = withUnique(next.spokenToolCallIds, event.toolCallId);
|
|
303
|
+
next.phase = phaseAfterAssistantSpeech(next);
|
|
304
|
+
return { event, state: next, decision: { ...resultDecision, atMs: event.atMs } };
|
|
305
|
+
}
|
|
306
|
+
function applyHangupRequested(state, event) {
|
|
307
|
+
const next = copyState(state);
|
|
308
|
+
next.phase = "hangup";
|
|
309
|
+
next.floorOwner = "terminal";
|
|
310
|
+
next.hangupRequested = true;
|
|
311
|
+
return { event, state: next, decision: decision(true, "allow", "hangup_requested", { atMs: event.atMs }) };
|
|
312
|
+
}
|
|
313
|
+
function applyCallEnded(state, event) {
|
|
314
|
+
const next = copyState(state);
|
|
315
|
+
next.phase = "ended";
|
|
316
|
+
next.floorOwner = "terminal";
|
|
317
|
+
next.terminal = true;
|
|
318
|
+
next.hangupRequested = true;
|
|
319
|
+
return { event, state: next, decision: decision(true, "allow", "call_ended", { atMs: event.atMs }) };
|
|
320
|
+
}
|
|
321
|
+
function applyVoiceFloorEvent(state, event) {
|
|
322
|
+
if (state.hangupRequested && event.type !== "call.ended" && event.type !== "hangup.requested")
|
|
323
|
+
return suppressForHangup(state, event);
|
|
324
|
+
switch (event.type) {
|
|
325
|
+
case "call.connected":
|
|
326
|
+
return applyConnected(state, event);
|
|
327
|
+
case "caller.speech.started":
|
|
328
|
+
return applyCallerSpeechStarted(state, event);
|
|
329
|
+
case "caller.speech.ended":
|
|
330
|
+
return applyCallerSpeechEnded(state, event);
|
|
331
|
+
case "caller.transcript.final":
|
|
332
|
+
return applyCallerTranscriptFinal(state, event);
|
|
333
|
+
case "assistant.response.requested":
|
|
334
|
+
return applyAssistantResponseRequested(state, event);
|
|
335
|
+
case "assistant.speech.started":
|
|
336
|
+
return applyAssistantSpeechStarted(state, event);
|
|
337
|
+
case "assistant.speech.done":
|
|
338
|
+
return applyAssistantSpeechDone(state, event);
|
|
339
|
+
case "assistant.speech.cancelled":
|
|
340
|
+
return applyAssistantSpeechCancelled(state, event);
|
|
341
|
+
case "tool.call.started":
|
|
342
|
+
return applyToolStarted(state, event);
|
|
343
|
+
case "tool.holding.spoken":
|
|
344
|
+
return applyToolHoldingSpoken(state, event);
|
|
345
|
+
case "tool.call.completed":
|
|
346
|
+
return applyToolCompleted(state, event);
|
|
347
|
+
case "tool.result.spoken":
|
|
348
|
+
return applyToolResultSpoken(state, event);
|
|
349
|
+
case "hangup.requested":
|
|
350
|
+
return applyHangupRequested(state, event);
|
|
351
|
+
case "call.ended":
|
|
352
|
+
return applyCallEnded(state, event);
|
|
353
|
+
default:
|
|
354
|
+
throw new Error(`unknown voice floor event: ${String(event.type)}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function replayVoiceFloorEvents(events) {
|
|
358
|
+
(0, runtime_1.emitNervesEvent)({
|
|
359
|
+
component: "senses",
|
|
360
|
+
event: "senses.voice_floor_replay_start",
|
|
361
|
+
message: "starting Voice floor-control replay",
|
|
362
|
+
meta: { events: events.length },
|
|
363
|
+
});
|
|
364
|
+
let state = createInitialVoiceFloorState();
|
|
365
|
+
const steps = [];
|
|
366
|
+
for (const event of events) {
|
|
367
|
+
const transition = applyVoiceFloorEvent(state, event);
|
|
368
|
+
steps.push(transition);
|
|
369
|
+
state = transition.state;
|
|
370
|
+
}
|
|
371
|
+
(0, runtime_1.emitNervesEvent)({
|
|
372
|
+
component: "senses",
|
|
373
|
+
event: "senses.voice_floor_replay_end",
|
|
374
|
+
message: "finished Voice floor-control replay",
|
|
375
|
+
meta: { events: events.length, phase: state.phase, floorOwner: state.floorOwner },
|
|
376
|
+
});
|
|
377
|
+
return { state, steps };
|
|
378
|
+
}
|
|
379
|
+
function listSummary(values) {
|
|
380
|
+
return values.length > 0 ? values.join(",") : "none";
|
|
381
|
+
}
|
|
382
|
+
function summarizeVoiceFloorState(state) {
|
|
383
|
+
const parts = [
|
|
384
|
+
`phase=${state.phase}`,
|
|
385
|
+
`floor=${state.floorOwner}`,
|
|
386
|
+
];
|
|
387
|
+
if (state.activeAssistantSpeechId)
|
|
388
|
+
parts.push(`activeSpeech=${state.activeAssistantSpeechId}`);
|
|
389
|
+
parts.push(`pendingTools=${listSummary(state.pendingToolCallIds)}`);
|
|
390
|
+
parts.push(`staleTools=${listSummary(state.staleToolCallIds)}`);
|
|
391
|
+
if (state.interruption)
|
|
392
|
+
parts.push(`interruption=${state.interruption.turnId}@${state.interruption.interruptedSpeechId}`);
|
|
393
|
+
if (state.hangupRequested)
|
|
394
|
+
parts.push("hangup=requested");
|
|
395
|
+
if (state.terminal)
|
|
396
|
+
parts.push("terminal=true");
|
|
397
|
+
return parts.join(" ");
|
|
398
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoiceFloorController = void 0;
|
|
4
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
5
|
+
const floor_control_1 = require("./floor-control");
|
|
6
|
+
class VoiceFloorController {
|
|
7
|
+
currentState = (0, floor_control_1.createInitialVoiceFloorState)();
|
|
8
|
+
transport;
|
|
9
|
+
agentName;
|
|
10
|
+
now;
|
|
11
|
+
callId;
|
|
12
|
+
listeners = [];
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.transport = options.transport;
|
|
15
|
+
this.agentName = options.agentName;
|
|
16
|
+
this.callId = options.callId;
|
|
17
|
+
this.now = options.now ?? Date.now;
|
|
18
|
+
}
|
|
19
|
+
get state() {
|
|
20
|
+
return this.currentState;
|
|
21
|
+
}
|
|
22
|
+
isTerminal() {
|
|
23
|
+
return this.currentState.terminal || this.currentState.hangupRequested;
|
|
24
|
+
}
|
|
25
|
+
summary() {
|
|
26
|
+
return (0, floor_control_1.summarizeVoiceFloorState)(this.currentState);
|
|
27
|
+
}
|
|
28
|
+
onTransition(listener) {
|
|
29
|
+
this.listeners.push(listener);
|
|
30
|
+
return () => {
|
|
31
|
+
const index = this.listeners.indexOf(listener);
|
|
32
|
+
if (index >= 0)
|
|
33
|
+
this.listeners.splice(index, 1);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
apply(event) {
|
|
37
|
+
const transition = (0, floor_control_1.applyVoiceFloorEvent)(this.currentState, event);
|
|
38
|
+
this.currentState = transition.state;
|
|
39
|
+
if (event.type === "call.connected" && event.callId)
|
|
40
|
+
this.callId = event.callId;
|
|
41
|
+
(0, runtime_1.emitNervesEvent)({
|
|
42
|
+
component: "senses",
|
|
43
|
+
event: "senses.voice_floor_transition",
|
|
44
|
+
message: `voice floor transition ${event.type} -> ${transition.state.phase}`,
|
|
45
|
+
meta: this.meta({
|
|
46
|
+
eventType: event.type,
|
|
47
|
+
action: transition.decision.action,
|
|
48
|
+
reason: transition.decision.reason,
|
|
49
|
+
allowed: transition.decision.allowed,
|
|
50
|
+
atMs: event.atMs,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
for (const listener of [...this.listeners]) {
|
|
54
|
+
try {
|
|
55
|
+
listener(transition);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
(0, runtime_1.emitNervesEvent)({
|
|
59
|
+
level: "error",
|
|
60
|
+
component: "senses",
|
|
61
|
+
event: "senses.voice_floor_listener_error",
|
|
62
|
+
message: "voice floor transition listener threw",
|
|
63
|
+
meta: this.meta({ error: error instanceof Error ? error.message : String(error) }),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return transition;
|
|
68
|
+
}
|
|
69
|
+
canRequestResponse(input, atMs) {
|
|
70
|
+
const decision = (0, floor_control_1.canRequestVoiceResponse)(this.currentState, input);
|
|
71
|
+
const stamped = { ...decision, atMs: atMs ?? this.now() };
|
|
72
|
+
this.emitDecision("request", stamped, { responseId: input.responseId, inputReason: input.reason });
|
|
73
|
+
return stamped;
|
|
74
|
+
}
|
|
75
|
+
canSpeakToolHolding(input, atMs) {
|
|
76
|
+
const decision = (0, floor_control_1.canSpeakToolHolding)(this.currentState, input);
|
|
77
|
+
const stamped = { ...decision, atMs: atMs ?? this.now() };
|
|
78
|
+
this.emitDecision("tool_holding", stamped, { toolCallId: input.toolCallId });
|
|
79
|
+
return stamped;
|
|
80
|
+
}
|
|
81
|
+
canSpeakToolResult(input, atMs) {
|
|
82
|
+
const decision = (0, floor_control_1.canSpeakToolResult)(this.currentState, input);
|
|
83
|
+
const stamped = { ...decision, atMs: atMs ?? this.now() };
|
|
84
|
+
this.emitDecision("tool_result", stamped, { toolCallId: input.toolCallId });
|
|
85
|
+
return stamped;
|
|
86
|
+
}
|
|
87
|
+
emitDecision(query, decision, extra) {
|
|
88
|
+
(0, runtime_1.emitNervesEvent)({
|
|
89
|
+
component: "senses",
|
|
90
|
+
event: "senses.voice_floor_decision",
|
|
91
|
+
message: `voice floor decision ${query} ${decision.action} (${decision.reason})`,
|
|
92
|
+
meta: this.meta({
|
|
93
|
+
query,
|
|
94
|
+
action: decision.action,
|
|
95
|
+
reason: decision.reason,
|
|
96
|
+
allowed: decision.allowed,
|
|
97
|
+
atMs: decision.atMs,
|
|
98
|
+
...extra,
|
|
99
|
+
}),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
meta(extra) {
|
|
103
|
+
const base = {
|
|
104
|
+
phase: this.currentState.phase,
|
|
105
|
+
floorOwner: this.currentState.floorOwner,
|
|
106
|
+
transport: this.transport,
|
|
107
|
+
};
|
|
108
|
+
if (this.agentName)
|
|
109
|
+
base.agentName = this.agentName;
|
|
110
|
+
if (this.callId)
|
|
111
|
+
base.callId = this.callId;
|
|
112
|
+
return { ...base, ...extra };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.VoiceFloorController = VoiceFloorController;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runVoiceGoldenPath = runVoiceGoldenPath;
|
|
4
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
5
|
+
const audio_routing_1 = require("./audio-routing");
|
|
6
|
+
const meeting_1 = require("./meeting");
|
|
7
|
+
const playback_1 = require("./playback");
|
|
8
|
+
const turn_1 = require("./turn");
|
|
9
|
+
const defaultVoiceMeetingJoiner = {
|
|
10
|
+
async join(request) {
|
|
11
|
+
const result = {
|
|
12
|
+
status: "manual_required",
|
|
13
|
+
detail: `Open ${request.meeting.redactedUrl} in a browser profile whose meeting audio is routed through Multi-Output Device.`,
|
|
14
|
+
};
|
|
15
|
+
(0, runtime_1.emitNervesEvent)({
|
|
16
|
+
component: "senses",
|
|
17
|
+
event: "senses.voice_meeting_join_manual_required",
|
|
18
|
+
message: "voice meeting join requires browser handoff",
|
|
19
|
+
meta: {
|
|
20
|
+
provider: request.meeting.provider,
|
|
21
|
+
sessionKey: request.meeting.sessionKey,
|
|
22
|
+
routingStatus: request.audioRouting.status,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
function defaultUtteranceId() {
|
|
29
|
+
return `voice-${Date.now().toString(36)}`;
|
|
30
|
+
}
|
|
31
|
+
function playbackSkipped() {
|
|
32
|
+
(0, runtime_1.emitNervesEvent)({
|
|
33
|
+
component: "senses",
|
|
34
|
+
event: "senses.voice_golden_path_playback_skipped",
|
|
35
|
+
message: "voice golden path skipped playback because TTS failed",
|
|
36
|
+
meta: { reason: "tts_failed" },
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
status: "skipped",
|
|
40
|
+
reason: "tts_failed",
|
|
41
|
+
playbackAttempted: false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function runVoiceGoldenPath(options) {
|
|
45
|
+
(0, runtime_1.emitNervesEvent)({
|
|
46
|
+
component: "senses",
|
|
47
|
+
event: "senses.voice_golden_path_start",
|
|
48
|
+
message: "starting voice golden path",
|
|
49
|
+
meta: { agentName: options.agentName, friendId: options.friendId },
|
|
50
|
+
});
|
|
51
|
+
try {
|
|
52
|
+
const meeting = (0, meeting_1.parseVoiceMeetingUrl)(options.meetingUrl);
|
|
53
|
+
const audioRouting = await (options.inspectAudioRouting ?? audio_routing_1.inspectVoiceAudioRouting)();
|
|
54
|
+
const joiner = options.meetingJoiner ?? defaultVoiceMeetingJoiner;
|
|
55
|
+
const join = await joiner.join({ meeting, audioRouting });
|
|
56
|
+
const utteranceId = options.utteranceId ?? defaultUtteranceId();
|
|
57
|
+
const transcript = await options.transcriber.transcribe({
|
|
58
|
+
utteranceId,
|
|
59
|
+
audioPath: options.audioPath,
|
|
60
|
+
language: options.language,
|
|
61
|
+
});
|
|
62
|
+
const sessionKey = options.sessionKey ?? meeting.sessionKey;
|
|
63
|
+
const runSenseTurn = options.runSenseTurn;
|
|
64
|
+
const turn = await (0, turn_1.runVoiceLoopbackTurn)({
|
|
65
|
+
agentName: options.agentName,
|
|
66
|
+
friendId: options.friendId,
|
|
67
|
+
sessionKey,
|
|
68
|
+
transcript,
|
|
69
|
+
tts: options.tts,
|
|
70
|
+
runSenseTurn,
|
|
71
|
+
});
|
|
72
|
+
const writePlaybackArtifact = options.writePlaybackArtifact ?? playback_1.writeVoicePlaybackArtifact;
|
|
73
|
+
const playback = turn.tts.status === "delivered"
|
|
74
|
+
? await writePlaybackArtifact({
|
|
75
|
+
utteranceId,
|
|
76
|
+
delivery: turn.tts,
|
|
77
|
+
outputDir: options.outputDir,
|
|
78
|
+
playAudio: options.playAudio ?? false,
|
|
79
|
+
})
|
|
80
|
+
: playbackSkipped();
|
|
81
|
+
const result = {
|
|
82
|
+
meeting,
|
|
83
|
+
audioRouting,
|
|
84
|
+
join,
|
|
85
|
+
transcript,
|
|
86
|
+
responseText: turn.responseText,
|
|
87
|
+
ponderDeferred: turn.ponderDeferred,
|
|
88
|
+
tts: turn.tts,
|
|
89
|
+
playback,
|
|
90
|
+
sessionKey,
|
|
91
|
+
};
|
|
92
|
+
(0, runtime_1.emitNervesEvent)({
|
|
93
|
+
component: "senses",
|
|
94
|
+
event: "senses.voice_golden_path_end",
|
|
95
|
+
message: "finished voice golden path",
|
|
96
|
+
meta: {
|
|
97
|
+
sessionKey,
|
|
98
|
+
joinStatus: join.status,
|
|
99
|
+
ttsStatus: turn.tts.status,
|
|
100
|
+
playbackStatus: playback.status,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
107
|
+
(0, runtime_1.emitNervesEvent)({
|
|
108
|
+
level: "error",
|
|
109
|
+
component: "senses",
|
|
110
|
+
event: "senses.voice_golden_path_error",
|
|
111
|
+
message: "voice golden path failed",
|
|
112
|
+
meta: { error: message },
|
|
113
|
+
});
|
|
114
|
+
throw new Error(`voice golden path failed: ${message}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/* v8 ignore file -- barrel exports only; executable voice helpers are covered directly. @preserve */
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./transcript"), exports);
|
|
20
|
+
__exportStar(require("./whisper"), exports);
|
|
21
|
+
__exportStar(require("./elevenlabs"), exports);
|
|
22
|
+
__exportStar(require("./turn"), exports);
|
|
23
|
+
__exportStar(require("./meeting"), exports);
|
|
24
|
+
__exportStar(require("./audio-routing"), exports);
|
|
25
|
+
__exportStar(require("./playback"), exports);
|
|
26
|
+
__exportStar(require("./golden-path"), exports);
|
|
27
|
+
__exportStar(require("./twilio-phone"), exports);
|
|
28
|
+
__exportStar(require("./twilio-phone-runtime"), exports);
|
|
29
|
+
__exportStar(require("./realtime-eval"), exports);
|