@ouro.bot/cli 0.1.0-alpha.98 → 0.1.0-alpha.981
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/LICENSE +21 -0
- package/README.md +171 -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/assets/bluebubbles-host +264 -0
- package/assets/sanctuary-host-launcher.sh +16 -0
- package/changelog.json +6195 -16
- package/deploy/unraid/Dockerfile +58 -0
- package/deploy/unraid/INSTALL.md +64 -0
- package/deploy/unraid/README.txt +2997 -0
- package/deploy/unraid/audit-container-spec.sh +4 -0
- package/deploy/unraid/container-runtime.json +1 -0
- package/deploy/unraid/credit-gateway.md +95 -0
- package/deploy/unraid/docker-man-template-transaction.mjs +727 -0
- package/deploy/unraid/docker-man-template-xml.cjs +105 -0
- package/deploy/unraid/install.sh +274 -0
- package/deploy/unraid/migrate-sanctuary-bundle.mjs +63 -0
- package/deploy/unraid/ouro-events/bootstrap-spool.sh +92 -0
- package/deploy/unraid/ouro-events/emit-event.mjs +310 -0
- package/deploy/unraid/ouro-events/emit-usenet-event.sh +54 -0
- package/deploy/unraid/ouro-events/install-usenet-guard.sh +435 -0
- package/deploy/unraid/ouro-events/usenet-health.sh +176 -0
- package/deploy/unraid/sanctuary-acceptance-adapter.sh +43 -0
- package/deploy/unraid/sanctuary-acceptance-contract.json +198 -0
- package/deploy/unraid/sanctuary-acceptance-harness.sh +23 -0
- package/deploy/unraid/sanctuary-authority-installation.json +36 -0
- package/deploy/unraid/sanctuary-authority-service.sh +30 -0
- package/deploy/unraid/sanctuary-butler-upgrade.mjs +1377 -0
- package/deploy/unraid/sanctuary-deployment-target.mjs +710 -0
- package/deploy/unraid/sanctuary-replay-gate.mjs +1776 -0
- package/deploy/unraid/sanctuary-safe-rename.py +24 -0
- package/deploy/unraid/sanctuary-unit16-host-broker.mjs +2088 -0
- package/deploy/unraid/sanctuary-unit16-run.sh +570 -0
- package/deploy/unraid/sanctuary-unit18-target-audit.sh +27 -0
- package/deploy/unraid/sanctuary.ouro/agent.json +66 -0
- package/deploy/unraid/sanctuary.ouro/arc/README.md +3 -0
- package/deploy/unraid/sanctuary.ouro/awaiting/house-care-sweep.md +17 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +5 -0
- package/deploy/unraid/sanctuary.ouro/habits/sanctuary-health.md +8 -0
- package/deploy/unraid/sanctuary.ouro/mcp/media-mcp.mjs +2255 -0
- package/deploy/unraid/sanctuary.ouro/provider-readiness.json +11 -0
- package/deploy/unraid/sanctuary.ouro/psyche/ASPIRATIONS.md +5 -0
- package/deploy/unraid/sanctuary.ouro/psyche/IDENTITY.md +7 -0
- package/deploy/unraid/sanctuary.ouro/psyche/LORE.md +33 -0
- package/deploy/unraid/sanctuary.ouro/psyche/SOUL.md +27 -0
- package/deploy/unraid/sanctuary.ouro/psyche/TACIT.md +21 -0
- package/deploy/unraid/sanctuary.ouro/state/policy/steward.json +7 -0
- package/deploy/unraid/sanctuary.ouro/tool-profiles.json +232 -0
- package/deploy/unraid/sanctuary.xml +29 -0
- package/dist/a2a/card.js +57 -0
- package/dist/a2a/client.js +250 -0
- package/dist/a2a/config.js +50 -0
- package/dist/a2a/delegated-command-grants.js +93 -0
- package/dist/a2a/delegated-command.js +197 -0
- package/dist/a2a/delegation-stores.js +56 -0
- package/dist/a2a/did-resolution.js +93 -0
- package/dist/a2a/escalation-grants.js +84 -0
- package/dist/a2a/escalation-wiring.js +60 -0
- package/dist/a2a/identity.js +258 -0
- package/dist/a2a/inbound-share.js +110 -0
- package/dist/a2a/mission-result-wire.js +196 -0
- package/dist/a2a/onboarding.js +133 -0
- package/dist/a2a/operator-trust.js +399 -0
- package/dist/a2a/outbox-client.js +57 -0
- package/dist/a2a/outbox-store.js +188 -0
- package/dist/a2a/outbox-wire.js +95 -0
- package/dist/a2a/pin-store.js +132 -0
- package/dist/a2a/replay-grant-holders.js +33 -0
- package/dist/a2a/replay-harness.js +188 -0
- package/dist/a2a/resolution-proof.js +53 -0
- package/dist/a2a/sealed-chat.js +113 -0
- package/dist/a2a/seen-ledger.js +120 -0
- package/dist/a2a/server.js +771 -0
- package/dist/a2a/task-store.js +69 -0
- package/dist/a2a/transport.js +45 -0
- package/dist/a2a/trust-commands.js +203 -0
- package/dist/a2a/trusted-files.js +185 -0
- package/dist/a2a/types.js +3 -0
- package/dist/arc/attention-types.js +8 -0
- package/dist/arc/cares.js +360 -0
- package/dist/arc/episodes.js +118 -0
- package/dist/arc/evolution.js +490 -0
- package/dist/arc/flight-recorder.js +1034 -0
- package/dist/arc/intentions.js +134 -0
- package/dist/arc/json-store.js +117 -0
- package/dist/arc/obligations.js +386 -0
- package/dist/arc/packets.js +336 -0
- package/dist/arc/presence.js +185 -0
- package/dist/arc/task-lifecycle.js +57 -0
- package/dist/commerce/store.js +755 -0
- package/dist/commerce/types.js +3 -0
- package/dist/gateway/keys.js +117 -0
- package/dist/gateway/server.js +429 -0
- package/dist/heart/active-work.js +798 -40
- package/dist/heart/agent-entry.js +252 -3
- package/dist/heart/approval-files.js +113 -0
- package/dist/heart/approval-store.js +960 -0
- package/dist/heart/attachments/image-normalize.js +201 -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/bluebubbles.js +156 -0
- package/dist/heart/attachments/sources/cli-local-file.js +78 -0
- package/dist/heart/attachments/sources/index.js +18 -0
- package/dist/heart/attachments/sources/telegram.js +71 -0
- package/dist/heart/attachments/store.js +132 -0
- package/dist/heart/attachments/types.js +93 -0
- package/dist/heart/auth/auth-flow.js +511 -0
- package/dist/heart/autonomy-budget.js +478 -0
- package/dist/heart/awaiting/a2a-await-delivery.js +109 -0
- package/dist/heart/awaiting/await-alert.js +152 -0
- package/dist/heart/awaiting/await-expiry.js +143 -0
- package/dist/heart/awaiting/await-loader.js +91 -0
- package/dist/heart/awaiting/await-parser.js +152 -0
- package/dist/heart/awaiting/await-runtime-state.js +130 -0
- package/dist/heart/awaiting/await-scheduler.js +391 -0
- package/dist/heart/background-operations.js +281 -0
- package/dist/heart/bluebubbles-host-account.js +78 -0
- package/dist/heart/bridges/manager.js +137 -17
- package/dist/heart/bridges/store.js +14 -2
- package/dist/heart/bundle-state.js +168 -0
- package/dist/heart/commitments.js +44 -18
- package/dist/heart/config-registry.js +331 -0
- package/dist/heart/config.js +178 -131
- package/dist/heart/context-loss-gauntlet.js +387 -0
- package/dist/heart/context-loss-sentinel.js +1204 -0
- package/dist/heart/core.js +2377 -586
- package/dist/heart/cross-chat-delivery.js +9 -22
- package/dist/heart/daemon/agent-config-check.js +474 -0
- package/dist/heart/daemon/agent-discovery.js +283 -3
- package/dist/heart/daemon/agent-home.js +319 -0
- package/dist/heart/daemon/agent-service.js +542 -0
- package/dist/heart/daemon/agentic-repair.js +547 -0
- package/dist/heart/daemon/await-private-wake.js +59 -0
- package/dist/heart/daemon/bluebubbles-cli-integration.js +71 -0
- package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
- package/dist/heart/daemon/bluebubbles-host-protocol.js +433 -0
- package/dist/heart/daemon/bluebubbles-host.js +273 -0
- package/dist/heart/daemon/boot-sync-probe.js +197 -0
- package/dist/heart/daemon/cadence.js +180 -0
- package/dist/heart/daemon/cli-arg-redaction.js +26 -0
- package/dist/heart/daemon/cli-defaults.js +881 -0
- package/dist/heart/daemon/cli-desk.js +331 -0
- package/dist/heart/daemon/cli-exec.js +9272 -0
- package/dist/heart/daemon/cli-help.js +754 -0
- package/dist/heart/daemon/cli-parse.js +3329 -0
- package/dist/heart/daemon/cli-render-doctor.js +57 -0
- package/dist/heart/daemon/cli-render.js +819 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/connect-bay.js +323 -0
- package/dist/heart/daemon/container-credential-bootstrap.js +273 -0
- package/dist/heart/daemon/container-healthcheck.js +112 -0
- package/dist/heart/daemon/container-runtime.js +97 -0
- package/dist/heart/daemon/container-spec-auditor-main.js +171 -0
- package/dist/heart/daemon/container-spec-auditor.js +241 -0
- package/dist/heart/daemon/daemon-bootstrap-startup.js +115 -0
- package/dist/heart/daemon/daemon-cli.js +29 -2373
- package/dist/heart/daemon/daemon-entry.js +953 -11
- package/dist/heart/daemon/daemon-health.js +186 -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 +2110 -104
- package/dist/heart/daemon/desk-admin.js +420 -0
- package/dist/heart/daemon/dns-workflow.js +394 -0
- package/dist/heart/daemon/doctor-types.js +8 -0
- package/dist/heart/daemon/doctor.js +1766 -0
- package/dist/heart/daemon/freshness.js +345 -0
- package/dist/heart/daemon/habit-private-wake.js +61 -0
- package/dist/heart/daemon/health-monitor.js +154 -11
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +135 -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 +78 -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 +79 -10
- package/dist/heart/daemon/logs-prune.js +132 -0
- package/dist/heart/daemon/mcp-canary.js +524 -0
- package/dist/heart/daemon/message-router.js +65 -5
- package/dist/heart/daemon/migrate-to-desk.js +848 -0
- package/dist/heart/daemon/os-cron-deps.js +135 -0
- package/dist/heart/daemon/os-cron.js +22 -14
- package/dist/heart/daemon/ouro-bot-entry.js +6 -3
- package/dist/heart/daemon/ouro-entry.js +9 -3
- package/dist/heart/daemon/plugin-cli.js +432 -0
- package/dist/heart/daemon/process-manager.js +760 -61
- package/dist/heart/daemon/provider-discovery.js +137 -0
- package/dist/heart/daemon/provider-ping-progress.js +83 -0
- package/dist/heart/daemon/prunable-bundle.js +144 -0
- package/dist/heart/daemon/pulse.js +511 -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 +47 -14
- package/dist/heart/daemon/runtime-metadata.js +2 -30
- package/dist/heart/daemon/runtime-mode.js +13 -2
- package/dist/heart/daemon/safe-mode.js +161 -0
- package/dist/heart/daemon/sanctuary-acceptance-adapter.js +2662 -0
- package/dist/heart/daemon/sanctuary-acceptance-harness.js +1832 -0
- package/dist/heart/daemon/sanctuary-acceptance-marker.js +267 -0
- package/dist/heart/daemon/sanctuary-acceptance-scenarios.js +956 -0
- package/dist/heart/daemon/sanctuary-authority-codec.js +86 -0
- package/dist/heart/daemon/sanctuary-authority-epoch.js +291 -0
- package/dist/heart/daemon/sanctuary-authority-installation.js +161 -0
- package/dist/heart/daemon/sanctuary-authority-ledger.js +241 -0
- package/dist/heart/daemon/sanctuary-authority-root-lifecycle.js +1326 -0
- package/dist/heart/daemon/sanctuary-authority-vault-migration.js +79 -0
- package/dist/heart/daemon/sanctuary-bundle-migration.js +851 -0
- package/dist/heart/daemon/sanctuary-host-authority.js +1008 -0
- package/dist/heart/daemon/sanctuary-host-detached-supervisor.js +493 -0
- package/dist/heart/daemon/sanctuary-host-executor.js +670 -0
- package/dist/heart/daemon/sanctuary-host-linux-kernel.js +334 -0
- package/dist/heart/daemon/sanctuary-host-supervisor-entry.js +207 -0
- package/dist/heart/daemon/sanctuary-host-supervisor.js +95 -0
- package/dist/heart/daemon/sanctuary-package-management.js +103 -0
- package/dist/heart/daemon/sanctuary-scheduler-liveness.js +227 -0
- package/dist/heart/daemon/sanctuary-scheduler-origin.js +132 -0
- package/dist/heart/daemon/sanctuary-telegram-authority-entry.js +475 -0
- package/dist/heart/daemon/sanctuary-telegram-authority-gateway.js +585 -0
- package/dist/heart/daemon/sanctuary-telegram-authority-service.js +676 -0
- package/dist/heart/daemon/sense-manager.js +786 -48
- package/dist/heart/daemon/session-id-resolver.js +131 -0
- package/dist/heart/daemon/skill-management-installer.js +1 -1
- package/dist/heart/daemon/socket-client.js +180 -12
- package/dist/heart/daemon/stale-bundle-prune.js +113 -0
- package/dist/heart/daemon/startup-tui.js +339 -0
- package/dist/heart/daemon/supercronic-supervisor.js +282 -0
- package/dist/heart/daemon/task-scheduler.js +117 -39
- package/dist/heart/daemon/terminal-ui.js +503 -0
- package/dist/heart/daemon/thoughts.js +138 -54
- package/dist/heart/daemon/up-progress.js +366 -0
- package/dist/heart/daemon/vault-items.js +56 -0
- package/dist/heart/delegation.js +1 -4
- package/dist/heart/external-events/router.js +1531 -0
- package/dist/heart/failure-reports.js +336 -0
- package/dist/heart/file-lock.js +109 -0
- package/dist/heart/frontend-approval-runtime.js +506 -0
- package/dist/heart/frontend-journal.js +215 -0
- package/dist/heart/frontend-session-service.js +271 -0
- package/dist/heart/frontend-socket-client.js +173 -0
- package/dist/heart/frontend-socket.js +434 -0
- package/dist/heart/frontend-turn-errors.js +20 -0
- package/dist/heart/habits/habit-cancel.js +810 -0
- package/dist/heart/habits/habit-lifecycle.js +1327 -0
- package/dist/heart/habits/habit-migration.js +194 -0
- package/dist/heart/habits/habit-parser.js +278 -0
- package/dist/heart/habits/habit-runtime-state.js +93 -0
- package/dist/heart/habits/habit-scheduler.js +653 -0
- package/dist/heart/habits/habit-session-summary.js +318 -0
- package/dist/heart/habits/habit-session.js +636 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +55 -62
- 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 +53 -18
- package/dist/heart/identity.js +239 -59
- package/dist/heart/kept-notes.js +289 -0
- package/dist/heart/kicks.js +1 -1
- package/dist/heart/machine-identity.js +175 -0
- package/dist/heart/mail-import-discovery.js +356 -0
- package/dist/heart/mailbox/mailbox-http-hooks.js +99 -0
- package/dist/heart/mailbox/mailbox-http-response.js +7 -0
- package/dist/heart/mailbox/mailbox-http-routes.js +406 -0
- package/dist/heart/mailbox/mailbox-http-static.js +103 -0
- package/dist/heart/mailbox/mailbox-http-transport.js +272 -0
- package/dist/heart/mailbox/mailbox-http.js +99 -0
- package/dist/heart/mailbox/mailbox-read.js +41 -0
- package/dist/heart/mailbox/mailbox-supervision.js +131 -0
- package/dist/heart/mailbox/mailbox-types.js +27 -0
- package/dist/heart/mailbox/mailbox-view.js +197 -0
- package/dist/heart/mailbox/readers/agent-machine.js +428 -0
- package/dist/heart/mailbox/readers/continuity-readers.js +329 -0
- package/dist/heart/mailbox/readers/mail.js +375 -0
- package/dist/heart/mailbox/readers/runtime-readers.js +823 -0
- package/dist/heart/mailbox/readers/sessions.js +231 -0
- package/dist/heart/mailbox/readers/shared.js +111 -0
- package/dist/heart/mcp/mcp-server.js +760 -0
- package/dist/heart/migrate-config.js +100 -0
- package/dist/heart/model-capabilities.js +83 -16
- package/dist/heart/orientation-frame.js +376 -0
- package/dist/heart/platform.js +81 -0
- package/dist/heart/primitives.js +1 -1
- package/dist/heart/private-runtime/decision-renderer.js +158 -0
- package/dist/heart/private-runtime/index.js +18 -0
- package/dist/heart/private-runtime/ledger.js +221 -0
- package/dist/heart/private-runtime/policy.js +260 -0
- package/dist/heart/private-runtime/types.js +2 -0
- package/dist/heart/progress-story.js +1 -1
- package/dist/heart/provider-attempt.js +137 -0
- package/dist/heart/provider-binding-resolver.js +273 -0
- package/dist/heart/provider-credentials.js +449 -0
- package/dist/heart/provider-failover.js +311 -0
- package/dist/heart/provider-models.js +96 -0
- package/dist/heart/provider-ping.js +266 -0
- package/dist/heart/provider-readiness-cache.js +119 -0
- package/dist/heart/provider-visibility.js +188 -0
- package/dist/heart/providers/anthropic-token.js +131 -0
- package/dist/heart/providers/anthropic.js +248 -67
- package/dist/heart/providers/azure.js +23 -11
- package/dist/heart/providers/error-classification.js +129 -0
- package/dist/heart/providers/github-copilot.js +38 -39
- package/dist/heart/providers/minimax-vlm.js +189 -0
- package/dist/heart/providers/minimax.js +26 -8
- package/dist/heart/providers/openai-codex-token.js +349 -0
- package/dist/heart/providers/openai-codex.js +55 -40
- package/dist/heart/providers/openai-compatible.js +177 -0
- package/dist/heart/reach-channel.js +85 -0
- package/dist/heart/reply-style.js +52 -0
- package/dist/heart/run-ledger.js +247 -0
- package/dist/heart/runtime-capability-check.js +170 -0
- package/dist/heart/runtime-credentials.js +608 -0
- package/dist/heart/runtime-cwd.js +87 -0
- package/dist/heart/sense-truth.js +24 -4
- package/dist/heart/session-activity.js +94 -24
- package/dist/heart/session-events.js +1521 -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-redaction-repair-cli-main.js +31 -0
- package/dist/heart/session-redaction-repair.js +552 -0
- package/dist/heart/session-stats-cli-main.js +5 -0
- package/dist/heart/session-stats.js +183 -0
- package/dist/heart/session-transcript.js +133 -0
- package/dist/heart/shelf-claims.js +78 -0
- package/dist/heart/shepherd/custody-types.js +2 -0
- package/dist/heart/shepherd/mandates.js +352 -0
- package/dist/heart/shepherd/operation-commands.js +19 -0
- package/dist/heart/shepherd/operations.js +135 -0
- package/dist/heart/shepherd/supervision.js +114 -0
- package/dist/heart/shepherd/types.js +2 -0
- package/dist/heart/shepherd-config.js +123 -0
- package/dist/heart/source-grounding.js +313 -0
- package/dist/heart/start-of-turn-packet.js +372 -0
- package/dist/heart/steward-policy.js +656 -0
- package/dist/heart/streaming.js +631 -207
- package/dist/heart/structured-output.js +196 -0
- package/dist/heart/sync-classification.js +176 -0
- package/dist/heart/sync-health.js +152 -0
- package/dist/heart/sync.js +726 -0
- package/dist/heart/target-resolution.js +11 -7
- 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-approval.js +382 -0
- package/dist/heart/tool-description.js +155 -0
- package/dist/heart/tool-friction.js +55 -0
- package/dist/heart/tool-loop.js +206 -0
- package/dist/heart/turn-context.js +496 -0
- package/dist/heart/turn-execution-lease.js +30 -0
- package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +6 -5
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +3 -2
- package/dist/heart/versioning/ouro-path-installer.js +432 -0
- package/dist/heart/versioning/ouro-recovery-launcher.js +76 -0
- package/dist/heart/versioning/ouro-version-manager.js +432 -0
- package/dist/heart/versioning/release-sources.js +173 -0
- package/dist/heart/versioning/self-update-defaults.js +294 -0
- package/dist/heart/versioning/self-update.js +196 -0
- package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
- package/dist/heart/{daemon → versioning}/update-checker.js +6 -1
- package/dist/heart/versioning/update-hooks.js +154 -0
- package/dist/heart/versioning/update-state.js +126 -0
- package/dist/heart/versioning/updater-launchd.js +150 -0
- package/dist/heart/versioning/version-intent.js +114 -0
- package/dist/heart/work-card.js +380 -0
- package/dist/mailbox-ui/assets/index-Dbska1tZ.js +1 -0
- package/dist/mailbox-ui/assets/index-DsiKaPyH.css +1 -0
- package/dist/mailbox-ui/assets/vendor-CcN1XpQ9.js +61 -0
- package/dist/mailbox-ui/index.html +16 -0
- package/dist/mailroom/attention.js +167 -0
- package/dist/mailroom/autonomy.js +209 -0
- package/dist/mailroom/blob-store.js +889 -0
- package/dist/mailroom/body-cache.js +61 -0
- package/dist/mailroom/cache-sync-cli.js +58 -0
- package/dist/mailroom/core.js +803 -0
- package/dist/mailroom/entry.js +160 -0
- package/dist/mailroom/file-store.js +568 -0
- package/dist/mailroom/hosted-cache-sync.js +384 -0
- package/dist/mailroom/mbox-import.js +393 -0
- package/dist/mailroom/migration.js +164 -0
- package/dist/mailroom/outbound.js +380 -0
- package/dist/mailroom/policy.js +263 -0
- package/dist/mailroom/reader.js +292 -0
- package/dist/mailroom/search-cache.js +513 -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 +24 -2
- package/dist/mind/context.js +328 -139
- package/dist/mind/desk-section.js +362 -0
- package/dist/mind/diary-integrity.js +60 -0
- package/dist/mind/{memory.js → diary.js} +68 -77
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/friend-link-codes.js +209 -0
- package/dist/mind/friend-merge.js +336 -0
- package/dist/mind/{associative-recall.js → note-search.js} +47 -58
- package/dist/mind/obligation-steering.js +199 -3
- package/dist/mind/outbound-record.js +168 -0
- package/dist/mind/pending.js +36 -10
- package/dist/mind/prompt-budget.js +479 -0
- package/dist/mind/prompt-refresh.js +3 -2
- package/dist/mind/prompt.js +1166 -203
- package/dist/mind/provenance-trust.js +26 -0
- package/dist/mind/record-paths.js +312 -0
- package/dist/mind/scrutiny.js +173 -0
- package/dist/mind/session-transaction.js +622 -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 +143 -5
- package/dist/nerves/coverage/run-artifacts.js +55 -35
- package/dist/nerves/coverage/source-scanner.js +4 -4
- package/dist/nerves/event-buffer.js +111 -0
- package/dist/nerves/index.js +293 -9
- 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 +159 -0
- package/dist/nerves/runtime.js +17 -1
- package/dist/repertoire/ado-client.js +15 -56
- package/dist/repertoire/ado-semantic.js +16 -10
- package/dist/repertoire/api-client.js +97 -0
- package/dist/repertoire/bitwarden-store.js +1199 -0
- package/dist/repertoire/bundle-templates.js +71 -0
- package/dist/repertoire/bw-installer.js +231 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +331 -0
- package/dist/repertoire/coding/feedback.js +146 -34
- package/dist/repertoire/coding/index.js +15 -3
- package/dist/repertoire/coding/manager.js +159 -10
- package/dist/repertoire/coding/spawner.js +40 -11
- package/dist/repertoire/coding/tools.js +182 -18
- package/dist/repertoire/coding/workbench-client.js +272 -0
- package/dist/repertoire/coding/workbench-manager.js +346 -0
- package/dist/repertoire/commerce-errors.js +109 -0
- package/dist/repertoire/commerce-self-test.js +156 -0
- package/dist/repertoire/credential-access.js +183 -0
- package/dist/repertoire/desk/classifier.js +362 -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 +971 -20
- package/dist/repertoire/house-sweep.js +471 -0
- package/dist/repertoire/mcp-client.js +58 -5
- package/dist/repertoire/mcp-manager.js +427 -139
- package/dist/repertoire/mcp-tools.js +132 -0
- package/dist/repertoire/mcp-write-guard.js +46 -0
- package/dist/repertoire/plugin-mcp.js +175 -0
- package/dist/repertoire/plugins.js +253 -0
- package/dist/repertoire/relationship-authorization.js +322 -0
- package/dist/repertoire/sanctuary-container-policy.js +50 -0
- package/dist/repertoire/shell-sessions.js +134 -0
- package/dist/repertoire/skills.js +48 -4
- package/dist/repertoire/stripe-client.js +131 -0
- package/dist/repertoire/tool-arguments.js +182 -0
- package/dist/repertoire/tool-results.js +29 -0
- package/dist/repertoire/tools-a2a.js +699 -0
- package/dist/repertoire/tools-attachments.js +322 -0
- package/dist/repertoire/tools-awaiting.js +897 -0
- package/dist/repertoire/tools-base.js +83 -1168
- package/dist/repertoire/tools-bluebubbles.js +2 -0
- package/dist/repertoire/tools-bridge.js +144 -0
- package/dist/repertoire/tools-bundle.js +995 -0
- package/dist/repertoire/tools-commerce.js +253 -0
- package/dist/repertoire/tools-config.js +186 -0
- package/dist/repertoire/tools-continuity.js +588 -0
- package/dist/repertoire/tools-credential.js +383 -0
- package/dist/repertoire/tools-escalation.js +84 -0
- package/dist/repertoire/tools-evolution.js +527 -0
- package/dist/repertoire/tools-files.js +344 -0
- package/dist/repertoire/tools-flight.js +290 -0
- package/dist/repertoire/tools-flow.js +119 -0
- package/dist/repertoire/tools-friend-link.js +57 -0
- package/dist/repertoire/tools-github.js +3 -8
- package/dist/repertoire/tools-habits.js +103 -0
- package/dist/repertoire/tools-house-care.js +174 -0
- package/dist/repertoire/tools-mail.js +1828 -0
- package/dist/repertoire/tools-notes.js +501 -0
- package/dist/repertoire/tools-obligations.js +182 -0
- package/dist/repertoire/tools-orientation.js +31 -0
- package/dist/repertoire/tools-record.js +482 -0
- package/dist/repertoire/tools-rsvp.js +139 -0
- package/dist/repertoire/tools-runtime.js +238 -0
- package/dist/repertoire/tools-sanctuary-host.js +202 -0
- package/dist/repertoire/tools-session.js +1141 -0
- package/dist/repertoire/tools-shell.js +154 -0
- package/dist/repertoire/tools-shepherd-guidance.js +171 -0
- package/dist/repertoire/tools-shepherd.js +325 -0
- package/dist/repertoire/tools-steward-policy.js +147 -0
- package/dist/repertoire/tools-stripe.js +224 -0
- package/dist/repertoire/tools-surface.js +369 -0
- package/dist/repertoire/tools-teams.js +50 -39
- package/dist/repertoire/tools-telegram-contacts.js +37 -0
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools-trip.js +982 -0
- package/dist/repertoire/tools-unraid.js +556 -0
- package/dist/repertoire/tools-user-profile.js +146 -0
- package/dist/repertoire/tools-vault.js +40 -0
- package/dist/repertoire/tools-voice-local.js +198 -0
- package/dist/repertoire/tools-voice.js +145 -0
- package/dist/repertoire/tools.js +518 -156
- package/dist/repertoire/travel-api-client.js +360 -0
- package/dist/repertoire/unraid-client.js +155 -0
- package/dist/repertoire/unraid-restart.js +339 -0
- package/dist/repertoire/user-profile.js +131 -0
- package/dist/repertoire/vault-setup.js +246 -0
- package/dist/repertoire/vault-unlock.js +686 -0
- package/dist/rsvp/aisleplanner-client.js +354 -0
- package/dist/rsvp/cli.js +936 -0
- package/dist/rsvp/config.js +327 -0
- package/dist/rsvp/cutover.js +453 -0
- package/dist/rsvp/diagnostics.js +232 -0
- package/dist/rsvp/diff-renderer.js +176 -0
- package/dist/rsvp/habit-policy.js +110 -0
- package/dist/rsvp/habit-stage.js +123 -0
- package/dist/rsvp/incident-bundle.js +97 -0
- package/dist/rsvp/migration.js +204 -0
- package/dist/rsvp/native-habit-runner.js +630 -0
- package/dist/rsvp/outbound-state.js +628 -0
- package/dist/rsvp/query.js +118 -0
- package/dist/rsvp/replay.js +233 -0
- package/dist/rsvp/snapshot.js +232 -0
- package/dist/rsvp/spend-ledger.js +175 -0
- package/dist/scripts/claude-code-hook.js +41 -0
- package/dist/scripts/claude-code-stop-hook.js +47 -0
- package/dist/senses/a2a-entry.js +132 -0
- package/dist/senses/acp-server.js +386 -0
- package/dist/senses/attention-queue.js +186 -0
- package/dist/senses/await-turn-message.js +65 -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} +393 -43
- package/dist/senses/bluebubbles/context-packet.js +207 -0
- package/dist/senses/bluebubbles/context-smoke.js +144 -0
- package/dist/senses/bluebubbles/entry.js +90 -0
- package/dist/senses/bluebubbles/host-account-verifier.js +88 -0
- package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +21 -3
- package/dist/senses/bluebubbles/index.js +4054 -0
- package/dist/senses/bluebubbles/latest-turn.js +311 -0
- package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -71
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +159 -28
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +24 -13
- package/dist/senses/bluebubbles/outbound-state.js +335 -0
- package/dist/senses/bluebubbles/processed-log.js +133 -0
- package/dist/senses/bluebubbles/reaction-policy.js +47 -0
- package/dist/senses/bluebubbles/replay.js +284 -0
- package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +30 -2
- package/dist/senses/bluebubbles/semantic-receipts.js +1986 -0
- package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
- package/dist/senses/bluebubbles/webhook-registration.js +257 -0
- package/dist/senses/bluebubbles-meta-guard.js +39 -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 +241 -0
- package/dist/senses/cli/virtual-list.js +35 -0
- package/dist/senses/cli-entry.js +60 -8
- package/dist/senses/cli.js +570 -309
- package/dist/senses/commands.js +66 -3
- package/dist/senses/context-packet-ledger.js +371 -0
- package/dist/senses/context-packets.js +154 -0
- package/dist/senses/habit-lifecycle-guard.js +24 -0
- package/dist/senses/habit-turn-message.js +160 -0
- package/dist/senses/ingress-evidence.js +2 -0
- package/dist/senses/mail-entry.js +66 -0
- package/dist/senses/mail.js +524 -0
- package/dist/senses/pipeline.js +1158 -204
- package/dist/senses/private-runtime-worker.js +857 -0
- package/dist/senses/private-runtime.js +1627 -0
- package/dist/senses/proactive-content-guard.js +51 -0
- package/dist/senses/root-host-approval-port.js +345 -0
- package/dist/senses/root-host-approval-runtime.js +393 -0
- package/dist/senses/sanctuary-authority-resident.js +102 -0
- package/dist/senses/sanctuary-download-credit-presentation.js +31 -0
- package/dist/senses/sanctuary-full-visibility-contract.js +302 -0
- package/dist/senses/sanctuary-grounding.js +118 -0
- package/dist/senses/sanctuary-health-acceptance-probe-entry.js +12 -0
- package/dist/senses/sanctuary-health-acceptance-probe.js +786 -0
- package/dist/senses/sanctuary-health-runner.js +106 -0
- package/dist/senses/sanctuary-health.js +442 -0
- package/dist/senses/sanctuary-house.js +97 -0
- package/dist/senses/sanctuary-install-state-contract.js +169 -0
- package/dist/senses/sanctuary-interactive-control.js +410 -0
- package/dist/senses/sanctuary-media-catalog-contract.js +268 -0
- package/dist/senses/sanctuary-media-optimization.js +517 -0
- package/dist/senses/sanctuary-runtime.js +390 -0
- package/dist/senses/sanctuary-sab.js +85 -0
- package/dist/senses/sanctuary-storage-optimization-contract.js +32 -0
- package/dist/senses/shared-turn.js +832 -0
- package/dist/senses/shepherd/agent-presentation.js +88 -0
- package/dist/senses/shepherd/attention-page.js +166 -0
- package/dist/senses/shepherd/attention-sidebar.js +76 -0
- package/dist/senses/shepherd/attention.js +295 -0
- package/dist/senses/shepherd/checkin-config.js +76 -0
- package/dist/senses/shepherd/checkin-store.js +386 -0
- package/dist/senses/shepherd/client.js +196 -0
- package/dist/senses/shepherd/cmux.js +483 -0
- package/dist/senses/shepherd/composer.js +336 -0
- package/dist/senses/shepherd/copilot-app.js +648 -0
- package/dist/senses/shepherd/feedback-reply.js +108 -0
- package/dist/senses/shepherd/feedback-source.js +20 -0
- package/dist/senses/shepherd/feedback-store.js +331 -0
- package/dist/senses/shepherd/feedback-submit.js +182 -0
- package/dist/senses/shepherd/feedback-worker.js +208 -0
- package/dist/senses/shepherd/guidance.js +273 -0
- package/dist/senses/shepherd/herdr.js +427 -0
- package/dist/senses/shepherd/host.js +17 -0
- package/dist/senses/shepherd/human-decision-guard.js +29 -0
- package/dist/senses/shepherd/judge-evaluation-command.js +183 -0
- package/dist/senses/shepherd/judge-evaluation-entry.js +13 -0
- package/dist/senses/shepherd/judge-evaluation.js +155 -0
- package/dist/senses/shepherd/judge.js +210 -0
- package/dist/senses/shepherd/notice-outbox.js +262 -0
- package/dist/senses/shepherd/observation-publisher.js +320 -0
- package/dist/senses/shepherd/operations-defaults.js +86 -0
- package/dist/senses/shepherd/operations.js +159 -0
- package/dist/senses/shepherd/owner-notice.js +489 -0
- package/dist/senses/shepherd/prompt-state.js +60 -0
- package/dist/senses/shepherd/recovery.js +543 -0
- package/dist/senses/shepherd/redact.js +66 -0
- package/dist/senses/shepherd/returns.js +79 -0
- package/dist/senses/shepherd/sense.js +849 -0
- package/dist/senses/shepherd/shepherd-judge-corpus-v1.json +170 -0
- package/dist/senses/shepherd/surface.js +123 -0
- package/dist/senses/shepherd/target-binding.js +13 -0
- package/dist/senses/shepherd/terminal-process.js +147 -0
- package/dist/senses/shepherd-entry.js +98 -0
- package/dist/senses/surface-tool.js +109 -0
- package/dist/senses/teams-entry.js +68 -8
- package/dist/senses/teams-image.js +119 -0
- package/dist/senses/teams.js +998 -337
- package/dist/senses/telegram-admission.js +718 -0
- package/dist/senses/telegram-approval-runtime.js +793 -0
- package/dist/senses/telegram-attachments.js +186 -0
- package/dist/senses/telegram-audit-ledger.js +220 -0
- package/dist/senses/telegram-authority-transport.js +231 -0
- package/dist/senses/telegram-client.js +1755 -0
- package/dist/senses/telegram-effect-adapter.js +904 -0
- package/dist/senses/telegram-entry.js +83 -0
- package/dist/senses/telegram-handoff.js +154 -0
- package/dist/senses/telegram.js +2474 -0
- package/dist/senses/trust-gate.js +104 -9
- package/dist/senses/voice/audio-playback.js +237 -0
- package/dist/senses/voice/audio-routing.js +119 -0
- package/dist/senses/voice/call-auth.js +250 -0
- package/dist/senses/voice/elevenlabs.js +202 -0
- package/dist/senses/voice/floor-control.js +431 -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/local-audio-control.js +344 -0
- package/dist/senses/voice/local-audio-devices.js +516 -0
- package/dist/senses/voice/local-audio-disclosure.js +174 -0
- package/dist/senses/voice/local-audio-identity.js +103 -0
- package/dist/senses/voice/local-audio-join.js +325 -0
- package/dist/senses/voice/local-audio-mute.js +199 -0
- package/dist/senses/voice/local-audio-notify.js +124 -0
- package/dist/senses/voice/local-audio-prompts.js +116 -0
- package/dist/senses/voice/local-audio-transport.js +427 -0
- package/dist/senses/voice/local-audio.js +281 -0
- package/dist/senses/voice/local-media-stream.js +145 -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/process-guards.js +51 -0
- package/dist/senses/voice/realtime-eval.js +496 -0
- package/dist/senses/voice/realtime-tool-schema.js +195 -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 +836 -0
- package/dist/senses/voice/twilio-phone.js +5454 -0
- package/dist/senses/voice/types.js +2 -0
- package/dist/senses/voice/whisper.js +161 -0
- package/dist/senses/voice-entry.js +83 -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/dist/util/frontmatter.js +69 -0
- package/npm-shrinkwrap.json +8342 -0
- package/package.json +76 -13
- package/skills/agent-commerce.md +113 -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 -430
- package/dist/heart/daemon/ouro-path-installer.js +0 -260
- package/dist/heart/daemon/ouro-version-manager.js +0 -171
- package/dist/heart/daemon/update-hooks.js +0 -138
- package/dist/heart/obligations.js +0 -191
- package/dist/heart/safe-workspace.js +0 -381
- package/dist/heart/session-recall.js +0 -116
- package/dist/mind/friends/channel.js +0 -84
- package/dist/mind/friends/group-context.js +0 -144
- package/dist/mind/friends/resolver.js +0 -84
- package/dist/mind/friends/store-file.js +0 -190
- package/dist/mind/friends/store.js +0 -4
- package/dist/mind/friends/tokens.js +0 -26
- package/dist/mind/friends/trust-explanation.js +0 -74
- package/dist/mind/friends/types.js +0 -29
- package/dist/repertoire/tasks/board.js +0 -134
- package/dist/repertoire/tasks/index.js +0 -224
- package/dist/repertoire/tasks/lifecycle.js +0 -80
- package/dist/repertoire/tasks/middleware.js +0 -65
- package/dist/repertoire/tasks/parser.js +0 -173
- package/dist/repertoire/tasks/scanner.js +0 -132
- package/dist/repertoire/tasks/transitions.js +0 -144
- package/dist/senses/bluebubbles-entry.js +0 -13
- package/dist/senses/bluebubbles.js +0 -1181
- package/dist/senses/debug-activity.js +0 -154
- package/dist/senses/inner-dialog-worker.js +0 -90
- package/dist/senses/inner-dialog.js +0 -525
- package/subagents/README.md +0 -7
- /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/{repertoire/tasks/types.js → heart/attachments/sources/adapter.js} +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,836 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.agentScopedTwilioPhoneBasePath = agentScopedTwilioPhoneBasePath;
|
|
37
|
+
exports.resolveTwilioPhoneTransportRuntime = resolveTwilioPhoneTransportRuntime;
|
|
38
|
+
exports.startConfiguredTwilioPhoneTransport = startConfiguredTwilioPhoneTransport;
|
|
39
|
+
exports.placeConfiguredTwilioPhoneCall = placeConfiguredTwilioPhoneCall;
|
|
40
|
+
exports.closeTwilioPhoneBridgeServer = closeTwilioPhoneBridgeServer;
|
|
41
|
+
exports.resolveLocalAudioRealtimeOptions = resolveLocalAudioRealtimeOptions;
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const crypto = __importStar(require("node:crypto"));
|
|
44
|
+
const identity_1 = require("../../heart/identity");
|
|
45
|
+
const machine_identity_1 = require("../../heart/machine-identity");
|
|
46
|
+
const provider_credentials_1 = require("../../heart/provider-credentials");
|
|
47
|
+
const runtime_credentials_1 = require("../../heart/runtime-credentials");
|
|
48
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
49
|
+
const elevenlabs_1 = require("./elevenlabs");
|
|
50
|
+
const playback_1 = require("./playback");
|
|
51
|
+
const transcript_1 = require("./transcript");
|
|
52
|
+
const twilio_phone_1 = require("./twilio-phone");
|
|
53
|
+
const turn_1 = require("./turn");
|
|
54
|
+
const whisper_1 = require("./whisper");
|
|
55
|
+
function asRecord(value) {
|
|
56
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
57
|
+
}
|
|
58
|
+
function configString(config, dottedPath) {
|
|
59
|
+
let cursor = config;
|
|
60
|
+
for (const segment of dottedPath.split(".")) {
|
|
61
|
+
const record = asRecord(cursor);
|
|
62
|
+
if (!record)
|
|
63
|
+
return undefined;
|
|
64
|
+
cursor = record[segment];
|
|
65
|
+
}
|
|
66
|
+
return typeof cursor === "string" && cursor.trim() ? cursor.trim() : undefined;
|
|
67
|
+
}
|
|
68
|
+
function configNumber(config, dottedPath) {
|
|
69
|
+
let cursor = config;
|
|
70
|
+
for (const segment of dottedPath.split(".")) {
|
|
71
|
+
const record = asRecord(cursor);
|
|
72
|
+
if (!record)
|
|
73
|
+
return undefined;
|
|
74
|
+
cursor = record[segment];
|
|
75
|
+
}
|
|
76
|
+
if (typeof cursor === "number" && Number.isFinite(cursor))
|
|
77
|
+
return cursor;
|
|
78
|
+
if (typeof cursor === "string" && cursor.trim()) {
|
|
79
|
+
const parsed = Number(cursor);
|
|
80
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
function configBoolean(config, dottedPath) {
|
|
85
|
+
let cursor = config;
|
|
86
|
+
for (const segment of dottedPath.split(".")) {
|
|
87
|
+
const record = asRecord(cursor);
|
|
88
|
+
if (!record)
|
|
89
|
+
return undefined;
|
|
90
|
+
cursor = record[segment];
|
|
91
|
+
}
|
|
92
|
+
if (typeof cursor === "boolean")
|
|
93
|
+
return cursor;
|
|
94
|
+
if (typeof cursor === "string") {
|
|
95
|
+
const normalized = cursor.trim().toLowerCase();
|
|
96
|
+
if (normalized === "true")
|
|
97
|
+
return true;
|
|
98
|
+
if (normalized === "false")
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
function requireConfig(result, label) {
|
|
104
|
+
if (result.ok)
|
|
105
|
+
return result.config;
|
|
106
|
+
throw new Error(`${label} unavailable: ${result.error}`);
|
|
107
|
+
}
|
|
108
|
+
function required(value, guidance) {
|
|
109
|
+
if (value)
|
|
110
|
+
return value;
|
|
111
|
+
throw new Error(guidance);
|
|
112
|
+
}
|
|
113
|
+
function selectedAgentProviders(config) {
|
|
114
|
+
const providers = new Set();
|
|
115
|
+
providers.add(config.humanFacing.provider);
|
|
116
|
+
providers.add(config.agentFacing.provider);
|
|
117
|
+
if (config.provider)
|
|
118
|
+
providers.add(config.provider);
|
|
119
|
+
return [...providers];
|
|
120
|
+
}
|
|
121
|
+
async function cacheSelectedProviderCredentials(agentName) {
|
|
122
|
+
const providers = selectedAgentProviders((0, identity_1.loadAgentConfig)());
|
|
123
|
+
const cached = (0, provider_credentials_1.readProviderCredentialPool)(agentName);
|
|
124
|
+
/* v8 ignore next -- fast path is covered by provider credential pool tests; voice runtime tests exercise refresh/repair paths @preserve */
|
|
125
|
+
if (cached.ok && providers.every((provider) => cached.pool.providers[provider]))
|
|
126
|
+
return;
|
|
127
|
+
const pool = await (0, provider_credentials_1.refreshProviderCredentialPool)(agentName, { providers });
|
|
128
|
+
if (!pool.ok) {
|
|
129
|
+
throw new Error(`provider credentials unavailable for phone voice: ${pool.error}`);
|
|
130
|
+
}
|
|
131
|
+
const missing = providers.filter((provider) => !pool.pool.providers[provider]);
|
|
132
|
+
if (missing.length > 0) {
|
|
133
|
+
throw new Error(`missing provider credentials for phone voice: ${missing.join(", ")}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function agentPathSegment(agentName) {
|
|
137
|
+
return agentName.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "agent";
|
|
138
|
+
}
|
|
139
|
+
function trimOptional(value) {
|
|
140
|
+
return value?.trim() || undefined;
|
|
141
|
+
}
|
|
142
|
+
function resolveOpenAIRealtimeApiKey(options) {
|
|
143
|
+
const overrideKey = trimOptional(options.overrides?.openaiRealtimeApiKey);
|
|
144
|
+
/* v8 ignore next -- operator CLI overrides use the same validated setting shape as stored runtime config @preserve */
|
|
145
|
+
if (overrideKey)
|
|
146
|
+
return { apiKey: overrideKey, source: "override.openaiRealtimeApiKey" };
|
|
147
|
+
const voiceKey = configString(options.runtimeConfig, "voice.openaiRealtimeApiKey");
|
|
148
|
+
if (voiceKey)
|
|
149
|
+
return { apiKey: voiceKey, source: "voice.openaiRealtimeApiKey" };
|
|
150
|
+
const integrationKey = configString(options.runtimeConfig, "integrations.openaiApiKey");
|
|
151
|
+
if (integrationKey)
|
|
152
|
+
return { apiKey: integrationKey, source: "integrations.openaiApiKey" };
|
|
153
|
+
const compatKey = configString(options.runtimeConfig, "integrations.openaiEmbeddingsApiKey");
|
|
154
|
+
if (compatKey)
|
|
155
|
+
return { apiKey: compatKey, source: "integrations.openaiEmbeddingsApiKey" };
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
function configuredConversationEngine(options, overrides, transportMode) {
|
|
159
|
+
const explicit = overrides.conversationEngine
|
|
160
|
+
?? configString(options.machineConfig, "voice.twilioConversationEngine")
|
|
161
|
+
?? configString(options.machineConfig, "voice.conversationEngine")
|
|
162
|
+
?? configString(options.runtimeConfig, "voice.twilioConversationEngine")
|
|
163
|
+
?? configString(options.runtimeConfig, "voice.conversationEngine");
|
|
164
|
+
const hasSipConfig = !!(configString(options.runtimeConfig, "voice.openaiSipProjectId")
|
|
165
|
+
|| configString(options.machineConfig, "voice.openaiSipProjectId"));
|
|
166
|
+
const explicitEngine = explicit ? (0, twilio_phone_1.normalizeTwilioPhoneConversationEngine)(explicit) : undefined;
|
|
167
|
+
if (hasSipConfig && (!explicitEngine || explicitEngine === "cascade"))
|
|
168
|
+
return "openai-sip";
|
|
169
|
+
if (explicitEngine)
|
|
170
|
+
return explicitEngine;
|
|
171
|
+
const hasRealtimeConfig = !!resolveOpenAIRealtimeApiKey({ runtimeConfig: options.runtimeConfig, overrides });
|
|
172
|
+
if (hasRealtimeConfig && transportMode === "media-stream")
|
|
173
|
+
return "openai-realtime";
|
|
174
|
+
return "cascade";
|
|
175
|
+
}
|
|
176
|
+
function configuredOutboundConversationEngine(options, overrides, conversationEngine, transportMode) {
|
|
177
|
+
const defaultOutboundEngine = conversationEngine === "openai-sip" && transportMode === "media-stream"
|
|
178
|
+
? "openai-realtime"
|
|
179
|
+
: conversationEngine;
|
|
180
|
+
const configured = overrides.outboundConversationEngine
|
|
181
|
+
?? (0, twilio_phone_1.normalizeTwilioPhoneConversationEngine)(configString(options.machineConfig, "voice.twilioOutboundConversationEngine")
|
|
182
|
+
?? configString(options.machineConfig, "voice.outboundConversationEngine")
|
|
183
|
+
?? configString(options.runtimeConfig, "voice.twilioOutboundConversationEngine")
|
|
184
|
+
?? configString(options.runtimeConfig, "voice.outboundConversationEngine")
|
|
185
|
+
?? defaultOutboundEngine);
|
|
186
|
+
if (defaultOutboundEngine === "openai-realtime" && configured === "cascade")
|
|
187
|
+
return defaultOutboundEngine;
|
|
188
|
+
return configured;
|
|
189
|
+
}
|
|
190
|
+
function normalizeOpenAIRealtimeReasoningEffort(value) {
|
|
191
|
+
const normalized = value?.trim().toLowerCase();
|
|
192
|
+
if (normalized === "minimal"
|
|
193
|
+
|| normalized === "low"
|
|
194
|
+
|| normalized === "medium"
|
|
195
|
+
|| normalized === "high"
|
|
196
|
+
|| normalized === "xhigh") {
|
|
197
|
+
return normalized;
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
function normalizeOpenAIRealtimeNoiseReduction(value) {
|
|
202
|
+
const normalized = value?.trim().toLowerCase();
|
|
203
|
+
if (normalized === "near_field" || normalized === "far_field" || normalized === "none")
|
|
204
|
+
return normalized;
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
function normalizeOpenAIRealtimeTurnDetectionMode(value) {
|
|
208
|
+
const normalized = value?.trim().toLowerCase();
|
|
209
|
+
/* v8 ignore next -- mode values are passed through from OpenAI config; invalid fallback is the important fail-soft path @preserve */
|
|
210
|
+
if (normalized === "server_vad" || normalized === "semantic_vad")
|
|
211
|
+
return normalized;
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
function normalizeOpenAIRealtimeVadEagerness(value) {
|
|
215
|
+
const normalized = value?.trim().toLowerCase();
|
|
216
|
+
/* v8 ignore next -- eagerness values are passed through from OpenAI config; invalid fallback is the important fail-soft path @preserve */
|
|
217
|
+
if (normalized === "low" || normalized === "medium" || normalized === "high" || normalized === "auto")
|
|
218
|
+
return normalized;
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
function errorMessage(error) {
|
|
222
|
+
/* v8 ignore next -- thrown runtime values are Errors in supported call paths @preserve */
|
|
223
|
+
return error instanceof Error ? error.message : String(error);
|
|
224
|
+
}
|
|
225
|
+
function agentScopedTwilioPhoneBasePath(agentName) {
|
|
226
|
+
return `/voice/agents/${agentPathSegment(agentName)}/twilio`;
|
|
227
|
+
}
|
|
228
|
+
function resolveTwilioPhoneTransportRuntime(options) {
|
|
229
|
+
const overrides = options.overrides ?? {};
|
|
230
|
+
const configuredPublicBaseUrl = trimOptional(overrides.publicBaseUrl)
|
|
231
|
+
?? configString(options.machineConfig, "voice.twilioPublicUrl");
|
|
232
|
+
const explicitEnabled = overrides.enabled ?? configBoolean(options.machineConfig, "voice.twilioEnabled");
|
|
233
|
+
if (!configuredPublicBaseUrl && options.requirePublicUrl) {
|
|
234
|
+
throw new Error("missing voice.twilioPublicUrl in this machine's runtime config");
|
|
235
|
+
}
|
|
236
|
+
const enabled = explicitEnabled ?? !!configuredPublicBaseUrl;
|
|
237
|
+
if (!enabled) {
|
|
238
|
+
return { status: "disabled", reason: "voice.twilioPublicUrl is not configured" };
|
|
239
|
+
}
|
|
240
|
+
if (!configuredPublicBaseUrl) {
|
|
241
|
+
throw new Error("missing voice.twilioPublicUrl in this machine's runtime config");
|
|
242
|
+
}
|
|
243
|
+
const publicUrl = new URL(configuredPublicBaseUrl);
|
|
244
|
+
if (publicUrl.protocol !== "https:") {
|
|
245
|
+
throw new Error("voice.twilioPublicUrl must be an https URL");
|
|
246
|
+
}
|
|
247
|
+
const publicBaseUrl = publicUrl.toString();
|
|
248
|
+
const basePath = (0, twilio_phone_1.normalizeTwilioPhoneBasePath)(overrides.basePath
|
|
249
|
+
?? configString(options.machineConfig, "voice.twilioBasePath")
|
|
250
|
+
?? options.defaultBasePath
|
|
251
|
+
?? twilio_phone_1.TWILIO_PHONE_WEBHOOK_BASE_PATH);
|
|
252
|
+
const explicitTransportModeString = configString(options.machineConfig, "voice.twilioTransportMode");
|
|
253
|
+
// When the operator has only configured OpenAI Realtime (key) or OpenAI SIP
|
|
254
|
+
// (project id) and not picked a transport mode, infer media-stream — the
|
|
255
|
+
// legacy `record-play` default would otherwise pin `conversationEngine` to
|
|
256
|
+
// `cascade`, route inbound calls through the ElevenLabs/Whisper greeting
|
|
257
|
+
// path the operator never configured, and produce a fully silent first
|
|
258
|
+
// turn ("no greeting at all"). Realtime requires media-stream by nature.
|
|
259
|
+
const hasRealtimeApiKey = !!resolveOpenAIRealtimeApiKey({ runtimeConfig: options.runtimeConfig, overrides });
|
|
260
|
+
const hasSipProjectConfig = !!(configString(options.runtimeConfig, "voice.openaiSipProjectId")
|
|
261
|
+
|| configString(options.machineConfig, "voice.openaiSipProjectId"));
|
|
262
|
+
const realtimeImpliesMediaStream = hasRealtimeApiKey || hasSipProjectConfig;
|
|
263
|
+
const transportMode = overrides.transportMode
|
|
264
|
+
?? (0, twilio_phone_1.normalizeTwilioPhoneTransportMode)(explicitTransportModeString
|
|
265
|
+
?? (realtimeImpliesMediaStream ? "media-stream" : twilio_phone_1.DEFAULT_TWILIO_PHONE_TRANSPORT_MODE));
|
|
266
|
+
const conversationEngine = configuredConversationEngine(options, overrides, transportMode);
|
|
267
|
+
const outboundConversationEngine = configuredOutboundConversationEngine(options, overrides, conversationEngine, transportMode);
|
|
268
|
+
const needsOpenAIRealtime = conversationEngine === "openai-realtime"
|
|
269
|
+
|| conversationEngine === "openai-sip"
|
|
270
|
+
|| outboundConversationEngine === "openai-realtime"
|
|
271
|
+
|| outboundConversationEngine === "openai-sip";
|
|
272
|
+
const needsOpenAISip = conversationEngine === "openai-sip" || outboundConversationEngine === "openai-sip";
|
|
273
|
+
const needsCascade = conversationEngine === "cascade" || outboundConversationEngine === "cascade";
|
|
274
|
+
let elevenLabsApiKey = configString(options.runtimeConfig, "integrations.elevenLabsApiKey") ?? "";
|
|
275
|
+
let elevenLabsVoiceId = trimOptional(overrides.elevenLabsVoiceId)
|
|
276
|
+
?? configString(options.runtimeConfig, "integrations.elevenLabsVoiceId")
|
|
277
|
+
?? configString(options.runtimeConfig, "voice.elevenLabsVoiceId")
|
|
278
|
+
?? "";
|
|
279
|
+
let whisperCliPath = trimOptional(overrides.whisperCliPath)
|
|
280
|
+
?? configString(options.machineConfig, "voice.whisperCliPath")
|
|
281
|
+
?? "";
|
|
282
|
+
let whisperModelPath = trimOptional(overrides.whisperModelPath)
|
|
283
|
+
?? configString(options.machineConfig, "voice.whisperModelPath")
|
|
284
|
+
?? "";
|
|
285
|
+
let openaiRealtime;
|
|
286
|
+
let openaiSip;
|
|
287
|
+
if (needsOpenAIRealtime) {
|
|
288
|
+
if ((conversationEngine === "openai-realtime" || outboundConversationEngine === "openai-realtime") && transportMode !== "media-stream") {
|
|
289
|
+
throw new Error("voice.twilioConversationEngine/openai-realtime requires voice.twilioTransportMode=media-stream");
|
|
290
|
+
}
|
|
291
|
+
const key = resolveOpenAIRealtimeApiKey({ runtimeConfig: options.runtimeConfig, overrides });
|
|
292
|
+
if (!key) {
|
|
293
|
+
throw new Error("missing voice.openaiRealtimeApiKey; save an OpenAI Realtime-capable API key before starting phone voice");
|
|
294
|
+
}
|
|
295
|
+
const turnDetection = {
|
|
296
|
+
mode: overrides.openaiRealtimeTurnDetectionMode
|
|
297
|
+
?? normalizeOpenAIRealtimeTurnDetectionMode(configString(options.machineConfig, "voice.openaiRealtimeTurnDetectionMode"))
|
|
298
|
+
?? normalizeOpenAIRealtimeTurnDetectionMode(configString(options.runtimeConfig, "voice.openaiRealtimeTurnDetectionMode")),
|
|
299
|
+
threshold: overrides.openaiRealtimeVadThreshold
|
|
300
|
+
?? configNumber(options.machineConfig, "voice.openaiRealtimeVadThreshold")
|
|
301
|
+
?? configNumber(options.runtimeConfig, "voice.openaiRealtimeVadThreshold"),
|
|
302
|
+
prefixPaddingMs: overrides.openaiRealtimeVadPrefixPaddingMs
|
|
303
|
+
?? configNumber(options.machineConfig, "voice.openaiRealtimeVadPrefixPaddingMs")
|
|
304
|
+
?? configNumber(options.runtimeConfig, "voice.openaiRealtimeVadPrefixPaddingMs"),
|
|
305
|
+
silenceDurationMs: overrides.openaiRealtimeVadSilenceDurationMs
|
|
306
|
+
?? configNumber(options.machineConfig, "voice.openaiRealtimeVadSilenceDurationMs")
|
|
307
|
+
?? configNumber(options.runtimeConfig, "voice.openaiRealtimeVadSilenceDurationMs"),
|
|
308
|
+
idleTimeoutMs: overrides.openaiRealtimeVadIdleTimeoutMs
|
|
309
|
+
?? configNumber(options.machineConfig, "voice.openaiRealtimeVadIdleTimeoutMs")
|
|
310
|
+
?? configNumber(options.runtimeConfig, "voice.openaiRealtimeVadIdleTimeoutMs"),
|
|
311
|
+
eagerness: overrides.openaiRealtimeVadEagerness
|
|
312
|
+
?? normalizeOpenAIRealtimeVadEagerness(configString(options.machineConfig, "voice.openaiRealtimeVadEagerness"))
|
|
313
|
+
?? normalizeOpenAIRealtimeVadEagerness(configString(options.runtimeConfig, "voice.openaiRealtimeVadEagerness")),
|
|
314
|
+
createResponse: overrides.openaiRealtimeVadCreateResponse
|
|
315
|
+
?? configBoolean(options.machineConfig, "voice.openaiRealtimeVadCreateResponse")
|
|
316
|
+
?? configBoolean(options.runtimeConfig, "voice.openaiRealtimeVadCreateResponse"),
|
|
317
|
+
interruptResponse: overrides.openaiRealtimeVadInterruptResponse
|
|
318
|
+
?? configBoolean(options.machineConfig, "voice.openaiRealtimeVadInterruptResponse")
|
|
319
|
+
?? configBoolean(options.runtimeConfig, "voice.openaiRealtimeVadInterruptResponse"),
|
|
320
|
+
};
|
|
321
|
+
openaiRealtime = {
|
|
322
|
+
apiKey: key.apiKey,
|
|
323
|
+
apiKeySource: key.source,
|
|
324
|
+
model: trimOptional(overrides.openaiRealtimeModel)
|
|
325
|
+
?? configString(options.machineConfig, "voice.openaiRealtimeModel")
|
|
326
|
+
?? configString(options.runtimeConfig, "voice.openaiRealtimeModel"),
|
|
327
|
+
voice: trimOptional(overrides.openaiRealtimeVoice)
|
|
328
|
+
?? configString(options.runtimeConfig, "voice.openaiRealtimeVoice")
|
|
329
|
+
?? configString(options.machineConfig, "voice.openaiRealtimeVoice"),
|
|
330
|
+
voiceStyle: trimOptional(overrides.openaiRealtimeVoiceStyle)
|
|
331
|
+
?? configString(options.runtimeConfig, "voice.openaiRealtimeVoiceStyle")
|
|
332
|
+
?? configString(options.machineConfig, "voice.openaiRealtimeVoiceStyle"),
|
|
333
|
+
voiceSpeed: overrides.openaiRealtimeVoiceSpeed
|
|
334
|
+
?? configNumber(options.runtimeConfig, "voice.openaiRealtimeVoiceSpeed")
|
|
335
|
+
?? configNumber(options.machineConfig, "voice.openaiRealtimeVoiceSpeed"),
|
|
336
|
+
websocketUrl: trimOptional(overrides.openaiRealtimeWebsocketUrl)
|
|
337
|
+
?? configString(options.machineConfig, "voice.openaiRealtimeWebsocketUrl")
|
|
338
|
+
?? configString(options.runtimeConfig, "voice.openaiRealtimeWebsocketUrl"),
|
|
339
|
+
reasoningEffort: overrides.openaiRealtimeReasoningEffort
|
|
340
|
+
?? normalizeOpenAIRealtimeReasoningEffort(configString(options.machineConfig, "voice.openaiRealtimeReasoningEffort"))
|
|
341
|
+
?? normalizeOpenAIRealtimeReasoningEffort(configString(options.runtimeConfig, "voice.openaiRealtimeReasoningEffort")),
|
|
342
|
+
noiseReduction: overrides.openaiRealtimeNoiseReduction
|
|
343
|
+
?? normalizeOpenAIRealtimeNoiseReduction(configString(options.machineConfig, "voice.openaiRealtimeNoiseReduction"))
|
|
344
|
+
?? normalizeOpenAIRealtimeNoiseReduction(configString(options.runtimeConfig, "voice.openaiRealtimeNoiseReduction")),
|
|
345
|
+
turnDetection,
|
|
346
|
+
};
|
|
347
|
+
if (needsOpenAISip) {
|
|
348
|
+
const projectId = trimOptional(overrides.openaiSipProjectId)
|
|
349
|
+
?? configString(options.runtimeConfig, "voice.openaiSipProjectId")
|
|
350
|
+
?? configString(options.machineConfig, "voice.openaiSipProjectId");
|
|
351
|
+
if (!projectId) {
|
|
352
|
+
throw new Error("missing voice.openaiSipProjectId; save the OpenAI project id before starting SIP phone voice");
|
|
353
|
+
}
|
|
354
|
+
const allowUnsignedWebhooks = overrides.openaiSipAllowUnsignedWebhooks
|
|
355
|
+
?? configBoolean(options.machineConfig, "voice.openaiSipAllowUnsignedWebhooks")
|
|
356
|
+
?? configBoolean(options.runtimeConfig, "voice.openaiSipAllowUnsignedWebhooks");
|
|
357
|
+
const webhookSecret = trimOptional(overrides.openaiSipWebhookSecret)
|
|
358
|
+
?? configString(options.runtimeConfig, "voice.openaiSipWebhookSecret")
|
|
359
|
+
?? configString(options.machineConfig, "voice.openaiSipWebhookSecret");
|
|
360
|
+
if (!webhookSecret && !allowUnsignedWebhooks) {
|
|
361
|
+
throw new Error("missing voice.openaiSipWebhookSecret; save the OpenAI webhook signing secret before starting SIP phone voice");
|
|
362
|
+
}
|
|
363
|
+
openaiSip = {
|
|
364
|
+
projectId,
|
|
365
|
+
webhookPath: (0, twilio_phone_1.normalizeTwilioPhoneBasePath)(trimOptional(overrides.openaiSipWebhookPath)
|
|
366
|
+
?? configString(options.machineConfig, "voice.openaiSipWebhookPath")
|
|
367
|
+
?? configString(options.runtimeConfig, "voice.openaiSipWebhookPath")
|
|
368
|
+
?? (0, twilio_phone_1.openAISipWebhookPath)(options.agentName)),
|
|
369
|
+
/* v8 ignore next 2 -- unsigned-webhook local-dev mode is resolved by config contract tests; production uses a secret @preserve */
|
|
370
|
+
...(webhookSecret ? { webhookSecret } : {}),
|
|
371
|
+
...(allowUnsignedWebhooks !== undefined ? { allowUnsignedWebhooks } : {}),
|
|
372
|
+
apiBaseUrl: trimOptional(overrides.openaiSipApiBaseUrl)
|
|
373
|
+
?? configString(options.machineConfig, "voice.openaiSipApiBaseUrl")
|
|
374
|
+
?? configString(options.runtimeConfig, "voice.openaiSipApiBaseUrl"),
|
|
375
|
+
websocketBaseUrl: trimOptional(overrides.openaiSipWebsocketBaseUrl)
|
|
376
|
+
?? configString(options.machineConfig, "voice.openaiSipWebsocketBaseUrl")
|
|
377
|
+
?? configString(options.runtimeConfig, "voice.openaiSipWebsocketBaseUrl"),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (needsCascade) {
|
|
382
|
+
elevenLabsApiKey = required(elevenLabsApiKey || undefined, "missing integrations.elevenLabsApiKey; run 'ouro connect voice --agent <agent>' for setup guidance");
|
|
383
|
+
elevenLabsVoiceId = required(elevenLabsVoiceId || undefined, "missing integrations.elevenLabsVoiceId; save the ElevenLabs voice ID before starting phone voice");
|
|
384
|
+
whisperCliPath = required(whisperCliPath || undefined, "missing voice.whisperCliPath in this machine's runtime config");
|
|
385
|
+
whisperModelPath = required(whisperModelPath || undefined, "missing voice.whisperModelPath in this machine's runtime config");
|
|
386
|
+
}
|
|
387
|
+
const outputDir = trimOptional(overrides.outputDir)
|
|
388
|
+
?? configString(options.machineConfig, "voice.twilioOutputDir")
|
|
389
|
+
?? path.join((0, identity_1.getAgentRoot)(options.agentName), "state", "voice", "twilio-phone");
|
|
390
|
+
const settings = {
|
|
391
|
+
agentName: options.agentName,
|
|
392
|
+
publicBaseUrl,
|
|
393
|
+
basePath,
|
|
394
|
+
webhookUrl: (0, twilio_phone_1.twilioPhoneWebhookUrl)(publicBaseUrl, basePath),
|
|
395
|
+
outputDir,
|
|
396
|
+
port: overrides.port
|
|
397
|
+
?? configNumber(options.machineConfig, "voice.twilioPort")
|
|
398
|
+
?? twilio_phone_1.DEFAULT_TWILIO_PHONE_PORT,
|
|
399
|
+
host: trimOptional(overrides.host)
|
|
400
|
+
?? configString(options.machineConfig, "voice.twilioHost")
|
|
401
|
+
?? "127.0.0.1",
|
|
402
|
+
elevenLabsApiKey,
|
|
403
|
+
elevenLabsVoiceId,
|
|
404
|
+
whisperCliPath,
|
|
405
|
+
whisperModelPath,
|
|
406
|
+
twilioAccountSid: configString(options.runtimeConfig, "voice.twilioAccountSid"),
|
|
407
|
+
twilioAuthToken: configString(options.runtimeConfig, "voice.twilioAuthToken"),
|
|
408
|
+
twilioFromNumber: trimOptional(overrides.twilioFromNumber)
|
|
409
|
+
?? configString(options.runtimeConfig, "voice.twilioFromNumber")
|
|
410
|
+
?? configString(options.machineConfig, "voice.twilioFromNumber"),
|
|
411
|
+
defaultFriendId: trimOptional(overrides.defaultFriendId)
|
|
412
|
+
?? configString(options.machineConfig, "voice.twilioDefaultFriendId"),
|
|
413
|
+
recordTimeoutSeconds: overrides.recordTimeoutSeconds
|
|
414
|
+
?? configNumber(options.machineConfig, "voice.twilioRecordTimeoutSeconds")
|
|
415
|
+
?? twilio_phone_1.DEFAULT_TWILIO_RECORD_TIMEOUT_SECONDS,
|
|
416
|
+
recordMaxLengthSeconds: overrides.recordMaxLengthSeconds
|
|
417
|
+
?? configNumber(options.machineConfig, "voice.twilioRecordMaxLengthSeconds")
|
|
418
|
+
?? twilio_phone_1.DEFAULT_TWILIO_RECORD_MAX_LENGTH_SECONDS,
|
|
419
|
+
greetingPrebufferMs: overrides.greetingPrebufferMs
|
|
420
|
+
?? configNumber(options.machineConfig, "voice.twilioGreetingPrebufferMs")
|
|
421
|
+
?? twilio_phone_1.DEFAULT_TWILIO_GREETING_PREBUFFER_MS,
|
|
422
|
+
playbackMode: overrides.playbackMode
|
|
423
|
+
?? (0, twilio_phone_1.normalizeTwilioPhonePlaybackMode)(configString(options.machineConfig, "voice.twilioPlaybackMode") ?? twilio_phone_1.DEFAULT_TWILIO_PHONE_PLAYBACK_MODE),
|
|
424
|
+
transportMode,
|
|
425
|
+
conversationEngine,
|
|
426
|
+
outboundConversationEngine,
|
|
427
|
+
openaiRealtime,
|
|
428
|
+
openaiSip,
|
|
429
|
+
openaiSipWebhookUrl: openaiSip?.webhookPath ? (0, twilio_phone_1.openAISipWebhookUrl)(publicBaseUrl, openaiSip.webhookPath) : undefined,
|
|
430
|
+
};
|
|
431
|
+
return { status: "configured", settings };
|
|
432
|
+
}
|
|
433
|
+
const defaultTwilioPhoneTransportRuntimeDeps = {
|
|
434
|
+
waitForRuntimeCredentialBootstrap: runtime_credentials_1.waitForRuntimeCredentialBootstrap,
|
|
435
|
+
loadMachineIdentity: machine_identity_1.loadOrCreateMachineIdentity,
|
|
436
|
+
refreshRuntimeConfig: runtime_credentials_1.refreshRuntimeCredentialConfig,
|
|
437
|
+
refreshMachineRuntimeConfig: runtime_credentials_1.refreshMachineRuntimeCredentialConfig,
|
|
438
|
+
readRuntimeConfig: runtime_credentials_1.readRuntimeCredentialConfig,
|
|
439
|
+
readMachineRuntimeConfig: runtime_credentials_1.readMachineRuntimeCredentialConfig,
|
|
440
|
+
cacheSelectedProviderCredentials,
|
|
441
|
+
createTranscriber: whisper_1.createWhisperCppTranscriber,
|
|
442
|
+
createTts: elevenlabs_1.createElevenLabsTtsClient,
|
|
443
|
+
startBridgeServer: twilio_phone_1.startTwilioPhoneBridgeServer,
|
|
444
|
+
};
|
|
445
|
+
const defaultTwilioPhoneOutboundCallRuntimeDeps = {
|
|
446
|
+
waitForRuntimeCredentialBootstrap: runtime_credentials_1.waitForRuntimeCredentialBootstrap,
|
|
447
|
+
loadMachineIdentity: machine_identity_1.loadOrCreateMachineIdentity,
|
|
448
|
+
refreshRuntimeConfig: runtime_credentials_1.refreshRuntimeCredentialConfig,
|
|
449
|
+
refreshMachineRuntimeConfig: runtime_credentials_1.refreshMachineRuntimeCredentialConfig,
|
|
450
|
+
readRuntimeConfig: runtime_credentials_1.readRuntimeCredentialConfig,
|
|
451
|
+
readMachineRuntimeConfig: runtime_credentials_1.readMachineRuntimeCredentialConfig,
|
|
452
|
+
createTts: elevenlabs_1.createElevenLabsTtsClient,
|
|
453
|
+
runVoiceLoopbackTurn: turn_1.runVoiceLoopbackTurn,
|
|
454
|
+
writeVoicePlaybackArtifact: playback_1.writeVoicePlaybackArtifact,
|
|
455
|
+
createOutboundCall: twilio_phone_1.createTwilioOutboundCall,
|
|
456
|
+
};
|
|
457
|
+
async function readFreshRuntimeSettings(agentName, overrides, defaultBasePath, requirePublicUrl, deps, options = {}) {
|
|
458
|
+
if (options.preferCached) {
|
|
459
|
+
const cachedRuntimeConfig = deps.readRuntimeConfig(agentName);
|
|
460
|
+
const cachedMachineConfig = deps.readMachineRuntimeConfig(agentName);
|
|
461
|
+
/* v8 ignore next -- stale/missing cache falls through to the refresh path; tests cover enabled and disabled cached states @preserve */
|
|
462
|
+
if (cachedRuntimeConfig.ok && cachedMachineConfig.ok) {
|
|
463
|
+
const resolution = resolveTwilioPhoneTransportRuntime({
|
|
464
|
+
agentName,
|
|
465
|
+
runtimeConfig: cachedRuntimeConfig.config,
|
|
466
|
+
machineConfig: cachedMachineConfig.config,
|
|
467
|
+
overrides,
|
|
468
|
+
defaultBasePath,
|
|
469
|
+
requirePublicUrl,
|
|
470
|
+
});
|
|
471
|
+
if (resolution.status === "disabled") {
|
|
472
|
+
throw new Error(`Twilio phone voice transport is disabled: ${resolution.reason}`);
|
|
473
|
+
}
|
|
474
|
+
return resolution.settings;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const bootstrapped = await deps.waitForRuntimeCredentialBootstrap(agentName);
|
|
478
|
+
const hasBootstrappedConfig = bootstrapped
|
|
479
|
+
&& deps.readRuntimeConfig(agentName).ok
|
|
480
|
+
&& deps.readMachineRuntimeConfig(agentName).ok;
|
|
481
|
+
if (!hasBootstrappedConfig) {
|
|
482
|
+
const machine = deps.loadMachineIdentity();
|
|
483
|
+
await Promise.all([
|
|
484
|
+
deps.refreshRuntimeConfig(agentName, { preserveCachedOnFailure: true }).catch(() => undefined),
|
|
485
|
+
deps.refreshMachineRuntimeConfig(agentName, machine.machineId, { preserveCachedOnFailure: true }).catch(() => undefined),
|
|
486
|
+
]);
|
|
487
|
+
}
|
|
488
|
+
const runtimeConfig = requireConfig(deps.readRuntimeConfig(agentName), "portable runtime/config");
|
|
489
|
+
const machineConfig = requireConfig(deps.readMachineRuntimeConfig(agentName), "machine runtime config");
|
|
490
|
+
const resolution = resolveTwilioPhoneTransportRuntime({
|
|
491
|
+
agentName,
|
|
492
|
+
runtimeConfig,
|
|
493
|
+
machineConfig,
|
|
494
|
+
overrides,
|
|
495
|
+
defaultBasePath,
|
|
496
|
+
requirePublicUrl,
|
|
497
|
+
});
|
|
498
|
+
if (resolution.status === "disabled") {
|
|
499
|
+
throw new Error(`Twilio phone voice transport is disabled: ${resolution.reason}`);
|
|
500
|
+
}
|
|
501
|
+
return resolution.settings;
|
|
502
|
+
}
|
|
503
|
+
async function startConfiguredTwilioPhoneTransport(options, deps = defaultTwilioPhoneTransportRuntimeDeps) {
|
|
504
|
+
let settings;
|
|
505
|
+
try {
|
|
506
|
+
settings = await readFreshRuntimeSettings(options.agentName, options.overrides, options.defaultBasePath, options.requirePublicUrl, deps);
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
if (!errorMessage(error).startsWith("Twilio phone voice transport is disabled:"))
|
|
510
|
+
throw error;
|
|
511
|
+
const reason = errorMessage(error).replace(/^Twilio phone voice transport is disabled: /, "");
|
|
512
|
+
(0, runtime_1.emitNervesEvent)({
|
|
513
|
+
component: "senses",
|
|
514
|
+
event: "senses.voice_twilio_transport_disabled",
|
|
515
|
+
message: "Twilio phone voice transport is not attached on this machine",
|
|
516
|
+
meta: { agentName: options.agentName, reason },
|
|
517
|
+
});
|
|
518
|
+
return { status: "disabled", reason };
|
|
519
|
+
}
|
|
520
|
+
if (!settings.twilioAuthToken?.trim()) {
|
|
521
|
+
// Call tokens and webhook signatures are keyed by the Twilio auth token; without it the bridge
|
|
522
|
+
// could not tell a real Twilio call from a forged one, so it does not listen at all.
|
|
523
|
+
const reason = "voice.twilioAuthToken is required for inbound calls";
|
|
524
|
+
(0, runtime_1.emitNervesEvent)({
|
|
525
|
+
level: "warn",
|
|
526
|
+
component: "senses",
|
|
527
|
+
event: "senses.voice_twilio_transport_disabled",
|
|
528
|
+
message: "Twilio phone voice transport is not attached because the Twilio auth token is missing",
|
|
529
|
+
meta: { agentName: options.agentName, reason },
|
|
530
|
+
});
|
|
531
|
+
return { status: "disabled", reason };
|
|
532
|
+
}
|
|
533
|
+
await deps.cacheSelectedProviderCredentials(options.agentName);
|
|
534
|
+
if (settings.openaiRealtime?.apiKeySource === "integrations.openaiEmbeddingsApiKey") {
|
|
535
|
+
(0, runtime_1.emitNervesEvent)({
|
|
536
|
+
level: "warn",
|
|
537
|
+
component: "senses",
|
|
538
|
+
event: "senses.voice_openai_realtime_compat_key",
|
|
539
|
+
message: "OpenAI Realtime voice is temporarily using the legacy OpenAI embeddings API key",
|
|
540
|
+
meta: { agentName: settings.agentName, source: settings.openaiRealtime.apiKeySource },
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
const settingsNeedsOpenAIRealtime = settings.conversationEngine === "openai-realtime"
|
|
544
|
+
|| settings.conversationEngine === "openai-sip"
|
|
545
|
+
|| settings.outboundConversationEngine === "openai-realtime"
|
|
546
|
+
|| settings.outboundConversationEngine === "openai-sip";
|
|
547
|
+
const settingsNeedsCascade = settings.conversationEngine === "cascade" || settings.outboundConversationEngine === "cascade";
|
|
548
|
+
const transcriber = settingsNeedsOpenAIRealtime && !settingsNeedsCascade
|
|
549
|
+
? {
|
|
550
|
+
transcribe: async () => {
|
|
551
|
+
throw new Error("OpenAI Realtime voice sessions do not use the cascade transcriber");
|
|
552
|
+
},
|
|
553
|
+
}
|
|
554
|
+
: deps.createTranscriber({
|
|
555
|
+
whisperCliPath: settings.whisperCliPath,
|
|
556
|
+
modelPath: settings.whisperModelPath,
|
|
557
|
+
});
|
|
558
|
+
const tts = settingsNeedsOpenAIRealtime && !settingsNeedsCascade
|
|
559
|
+
? {
|
|
560
|
+
synthesize: async () => {
|
|
561
|
+
throw new Error("OpenAI Realtime voice sessions do not use the cascade TTS service");
|
|
562
|
+
},
|
|
563
|
+
}
|
|
564
|
+
: deps.createTts({
|
|
565
|
+
apiKey: settings.elevenLabsApiKey,
|
|
566
|
+
voiceId: settings.elevenLabsVoiceId,
|
|
567
|
+
outputFormat: settings.transportMode === "media-stream" ? "ulaw_8000" : "mp3_44100_128",
|
|
568
|
+
});
|
|
569
|
+
const bridge = await deps.startBridgeServer({
|
|
570
|
+
agentName: settings.agentName,
|
|
571
|
+
publicBaseUrl: settings.publicBaseUrl,
|
|
572
|
+
basePath: settings.basePath,
|
|
573
|
+
outputDir: settings.outputDir,
|
|
574
|
+
transcriber,
|
|
575
|
+
tts,
|
|
576
|
+
port: settings.port,
|
|
577
|
+
host: settings.host,
|
|
578
|
+
twilioAccountSid: settings.twilioAccountSid,
|
|
579
|
+
twilioAuthToken: settings.twilioAuthToken,
|
|
580
|
+
twilioFromNumber: settings.twilioFromNumber,
|
|
581
|
+
defaultFriendId: settings.defaultFriendId,
|
|
582
|
+
recordTimeoutSeconds: settings.recordTimeoutSeconds,
|
|
583
|
+
recordMaxLengthSeconds: settings.recordMaxLengthSeconds,
|
|
584
|
+
greetingPrebufferMs: settings.greetingPrebufferMs,
|
|
585
|
+
transportMode: settings.transportMode,
|
|
586
|
+
playbackMode: settings.playbackMode,
|
|
587
|
+
conversationEngine: settings.conversationEngine,
|
|
588
|
+
outboundConversationEngine: settings.outboundConversationEngine,
|
|
589
|
+
openaiRealtime: settings.openaiRealtime,
|
|
590
|
+
openaiSip: settings.openaiSip,
|
|
591
|
+
});
|
|
592
|
+
(0, runtime_1.emitNervesEvent)({
|
|
593
|
+
component: "senses",
|
|
594
|
+
event: "senses.voice_twilio_transport_ready",
|
|
595
|
+
message: "Twilio phone voice transport is ready",
|
|
596
|
+
meta: {
|
|
597
|
+
agentName: settings.agentName,
|
|
598
|
+
localUrl: bridge.localUrl,
|
|
599
|
+
publicBaseUrl: settings.publicBaseUrl,
|
|
600
|
+
basePath: settings.basePath,
|
|
601
|
+
webhookUrl: settings.webhookUrl,
|
|
602
|
+
openaiSipWebhookUrl: settings.openaiSipWebhookUrl ?? "",
|
|
603
|
+
transportMode: settings.transportMode,
|
|
604
|
+
conversationEngine: settings.conversationEngine,
|
|
605
|
+
outboundConversationEngine: settings.outboundConversationEngine,
|
|
606
|
+
openaiRealtimeModel: settings.openaiRealtime?.model ?? "",
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
return { status: "started", settings, bridge };
|
|
610
|
+
}
|
|
611
|
+
function createOutboundId(now) {
|
|
612
|
+
const timestamp = now.toISOString().replace(/[^0-9A-Za-z]+/g, "").slice(0, 15);
|
|
613
|
+
return `outbound-${timestamp}-${crypto.randomUUID().slice(0, 8)}`;
|
|
614
|
+
}
|
|
615
|
+
function terminalOutboundStatus(status) {
|
|
616
|
+
const normalized = status?.trim().toLowerCase();
|
|
617
|
+
return normalized === "completed"
|
|
618
|
+
|| normalized === "busy"
|
|
619
|
+
|| normalized === "no-answer"
|
|
620
|
+
|| normalized === "failed"
|
|
621
|
+
|| normalized === "canceled"
|
|
622
|
+
|| normalized === "voicemail"
|
|
623
|
+
|| normalized === "fax";
|
|
624
|
+
}
|
|
625
|
+
function safeRuntimeSegment(input) {
|
|
626
|
+
/* v8 ignore next -- generated outbound IDs and E.164 numbers always leave a non-empty safe segment @preserve */
|
|
627
|
+
return input.trim().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "unknown";
|
|
628
|
+
}
|
|
629
|
+
async function prewarmOutboundGreeting(options, deps) {
|
|
630
|
+
/* v8 ignore next -- defensive guard against record-play prewarm calls; the implicit-media-stream default added when realtime/SIP credentials are configured prevents this branch from being reachable in current outbound tests @preserve */
|
|
631
|
+
if (options.settings.transportMode !== "media-stream")
|
|
632
|
+
return undefined;
|
|
633
|
+
/* v8 ignore next -- Realtime/SIP outbound tests assert no cascade prewarm is attempted @preserve */
|
|
634
|
+
if (options.settings.outboundConversationEngine === "openai-realtime" || options.settings.outboundConversationEngine === "openai-sip")
|
|
635
|
+
return undefined;
|
|
636
|
+
const friendId = options.friendId?.trim() || `twilio-${safeRuntimeSegment(options.to)}`;
|
|
637
|
+
const sessionKey = (0, twilio_phone_1.twilioPhoneVoiceSessionKey)({
|
|
638
|
+
defaultFriendId: friendId,
|
|
639
|
+
from: options.to,
|
|
640
|
+
to: options.from,
|
|
641
|
+
});
|
|
642
|
+
const utteranceId = `twilio-${safeRuntimeSegment(options.outboundId)}-outbound-connected`;
|
|
643
|
+
(0, runtime_1.emitNervesEvent)({
|
|
644
|
+
component: "senses",
|
|
645
|
+
event: "senses.voice_twilio_outbound_greeting_prewarm_start",
|
|
646
|
+
message: "prewarming Twilio outbound voice greeting before dialing",
|
|
647
|
+
meta: { agentName: options.settings.agentName, outboundId: safeRuntimeSegment(options.outboundId), sessionKey },
|
|
648
|
+
});
|
|
649
|
+
const transcript = (0, transcript_1.buildVoiceTranscript)({
|
|
650
|
+
utteranceId,
|
|
651
|
+
text: (0, twilio_phone_1.outboundCallAnsweredPrompt)({
|
|
652
|
+
schemaVersion: 1,
|
|
653
|
+
outboundId: options.outboundId,
|
|
654
|
+
agentName: options.settings.agentName,
|
|
655
|
+
/* v8 ignore next -- no-friend outbound calls are covered at placement/job persistence boundary @preserve */
|
|
656
|
+
...(options.friendId?.trim() ? { friendId: options.friendId.trim() } : {}),
|
|
657
|
+
to: options.to,
|
|
658
|
+
from: options.from,
|
|
659
|
+
reason: options.reason,
|
|
660
|
+
createdAt: options.createdAt,
|
|
661
|
+
status: "prewarming",
|
|
662
|
+
}, { From: options.from, To: options.to }),
|
|
663
|
+
source: "loopback",
|
|
664
|
+
});
|
|
665
|
+
const tts = deps.createTts({
|
|
666
|
+
apiKey: options.settings.elevenLabsApiKey,
|
|
667
|
+
voiceId: options.settings.elevenLabsVoiceId,
|
|
668
|
+
outputFormat: "ulaw_8000",
|
|
669
|
+
});
|
|
670
|
+
const turn = await deps.runVoiceLoopbackTurn({
|
|
671
|
+
agentName: options.settings.agentName,
|
|
672
|
+
friendId,
|
|
673
|
+
sessionKey,
|
|
674
|
+
transcript,
|
|
675
|
+
tts,
|
|
676
|
+
});
|
|
677
|
+
if (turn.tts.status !== "delivered") {
|
|
678
|
+
throw new Error(`outbound greeting prewarm failed: ${turn.tts.error}`);
|
|
679
|
+
}
|
|
680
|
+
const playback = await deps.writeVoicePlaybackArtifact({
|
|
681
|
+
utteranceId,
|
|
682
|
+
delivery: turn.tts,
|
|
683
|
+
outputDir: path.join(options.settings.outputDir, "outbound-greetings", safeRuntimeSegment(options.outboundId)),
|
|
684
|
+
});
|
|
685
|
+
const preparedAt = new Date().toISOString();
|
|
686
|
+
(0, runtime_1.emitNervesEvent)({
|
|
687
|
+
component: "senses",
|
|
688
|
+
event: "senses.voice_twilio_outbound_greeting_prewarm_end",
|
|
689
|
+
message: "prewarmed Twilio outbound voice greeting before dialing",
|
|
690
|
+
meta: {
|
|
691
|
+
agentName: options.settings.agentName,
|
|
692
|
+
outboundId: safeRuntimeSegment(options.outboundId),
|
|
693
|
+
sessionKey,
|
|
694
|
+
byteLength: String(playback.byteLength),
|
|
695
|
+
},
|
|
696
|
+
});
|
|
697
|
+
return {
|
|
698
|
+
utteranceId,
|
|
699
|
+
audioPath: playback.audioPath,
|
|
700
|
+
mimeType: playback.mimeType,
|
|
701
|
+
byteLength: playback.byteLength,
|
|
702
|
+
preparedAt,
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
async function placeConfiguredTwilioPhoneCall(options, deps = defaultTwilioPhoneOutboundCallRuntimeDeps) {
|
|
706
|
+
const settings = await readFreshRuntimeSettings(options.agentName, undefined, agentScopedTwilioPhoneBasePath(options.agentName), true, deps, { preferCached: true });
|
|
707
|
+
const to = (0, twilio_phone_1.normalizeTwilioE164PhoneNumber)(options.to);
|
|
708
|
+
const from = (0, twilio_phone_1.normalizeTwilioE164PhoneNumber)(settings.twilioFromNumber);
|
|
709
|
+
if (!to)
|
|
710
|
+
throw new Error("outbound voice call target must be an E.164 phone number");
|
|
711
|
+
if (!from)
|
|
712
|
+
throw new Error("missing voice.twilioFromNumber; save the Twilio caller number before outbound phone calls");
|
|
713
|
+
if (!settings.twilioAccountSid?.trim())
|
|
714
|
+
throw new Error("missing voice.twilioAccountSid; save Twilio credentials before outbound phone calls");
|
|
715
|
+
if (!settings.twilioAuthToken?.trim())
|
|
716
|
+
throw new Error("missing voice.twilioAuthToken; save Twilio credentials before outbound phone calls");
|
|
717
|
+
const accountSid = settings.twilioAccountSid.trim();
|
|
718
|
+
const authToken = settings.twilioAuthToken.trim();
|
|
719
|
+
const now = options.now ?? new Date();
|
|
720
|
+
const recent = await (0, twilio_phone_1.readRecentTwilioOutboundCallJobs)({
|
|
721
|
+
outputDir: settings.outputDir,
|
|
722
|
+
to,
|
|
723
|
+
friendId: options.friendId,
|
|
724
|
+
sinceMs: options.redialGuardMs ?? 120_000,
|
|
725
|
+
now: now.getTime(),
|
|
726
|
+
});
|
|
727
|
+
const activeRecent = recent.find((job) => !terminalOutboundStatus(job.status));
|
|
728
|
+
if (activeRecent) {
|
|
729
|
+
throw new Error("outbound voice call suppressed: a recent call to this friend/number is still active");
|
|
730
|
+
}
|
|
731
|
+
const outboundId = options.outboundId?.trim() || createOutboundId(now);
|
|
732
|
+
const createdAt = now.toISOString();
|
|
733
|
+
const webhookUrl = (0, twilio_phone_1.twilioOutboundCallWebhookUrl)(settings.publicBaseUrl, settings.basePath, outboundId);
|
|
734
|
+
const statusCallbackUrl = (0, twilio_phone_1.twilioOutboundCallStatusCallbackUrl)(settings.publicBaseUrl, settings.basePath, outboundId);
|
|
735
|
+
const amdStatusCallbackUrl = (0, twilio_phone_1.twilioOutboundCallAmdCallbackUrl)(settings.publicBaseUrl, settings.basePath, outboundId);
|
|
736
|
+
await (0, twilio_phone_1.writeTwilioOutboundCallJob)(settings.outputDir, {
|
|
737
|
+
schemaVersion: 1,
|
|
738
|
+
outboundId,
|
|
739
|
+
agentName: options.agentName,
|
|
740
|
+
...(options.friendId?.trim() ? { friendId: options.friendId.trim() } : {}),
|
|
741
|
+
to,
|
|
742
|
+
from,
|
|
743
|
+
reason: options.reason.trim(),
|
|
744
|
+
...(options.initialAudio ? { initialAudio: options.initialAudio } : {}),
|
|
745
|
+
createdAt,
|
|
746
|
+
status: settings.transportMode === "media-stream" && settings.outboundConversationEngine === "cascade"
|
|
747
|
+
? "prewarming"
|
|
748
|
+
: "requested",
|
|
749
|
+
});
|
|
750
|
+
try {
|
|
751
|
+
const prewarmedGreeting = await prewarmOutboundGreeting({
|
|
752
|
+
settings,
|
|
753
|
+
outboundId,
|
|
754
|
+
friendId: options.friendId,
|
|
755
|
+
to,
|
|
756
|
+
from,
|
|
757
|
+
reason: options.reason.trim(),
|
|
758
|
+
createdAt,
|
|
759
|
+
}, deps);
|
|
760
|
+
if (prewarmedGreeting) {
|
|
761
|
+
await (0, twilio_phone_1.updateTwilioOutboundCallJob)(settings.outputDir, outboundId, {
|
|
762
|
+
status: "requested",
|
|
763
|
+
prewarmedGreeting,
|
|
764
|
+
events: [{ at: prewarmedGreeting.preparedAt, status: "greeting-prewarmed" }],
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
const call = await deps.createOutboundCall({
|
|
768
|
+
accountSid,
|
|
769
|
+
authToken,
|
|
770
|
+
to,
|
|
771
|
+
from,
|
|
772
|
+
twimlUrl: webhookUrl,
|
|
773
|
+
statusCallbackUrl,
|
|
774
|
+
machineDetection: "Enable",
|
|
775
|
+
asyncAmd: true,
|
|
776
|
+
asyncAmdStatusCallbackUrl: amdStatusCallbackUrl,
|
|
777
|
+
});
|
|
778
|
+
await (0, twilio_phone_1.updateTwilioOutboundCallJob)(settings.outputDir, outboundId, {
|
|
779
|
+
transportCallSid: call.callSid,
|
|
780
|
+
status: call.status ?? "queued",
|
|
781
|
+
events: [
|
|
782
|
+
...(prewarmedGreeting ? [{ at: prewarmedGreeting.preparedAt, status: "greeting-prewarmed" }] : []),
|
|
783
|
+
{ at: new Date().toISOString(), status: call.status ?? "queued", ...(call.callSid ? { callSid: call.callSid } : {}) },
|
|
784
|
+
],
|
|
785
|
+
});
|
|
786
|
+
(0, runtime_1.emitNervesEvent)({
|
|
787
|
+
component: "senses",
|
|
788
|
+
event: "senses.voice_twilio_outbound_call_requested",
|
|
789
|
+
message: "Twilio outbound voice call requested",
|
|
790
|
+
meta: {
|
|
791
|
+
agentName: options.agentName,
|
|
792
|
+
outboundId: outboundId.replace(/[^A-Za-z0-9._-]+/g, "-"),
|
|
793
|
+
callSid: call.callSid?.replace(/[^A-Za-z0-9._-]+/g, "-") ?? "unknown",
|
|
794
|
+
status: call.status ?? "queued",
|
|
795
|
+
},
|
|
796
|
+
});
|
|
797
|
+
return {
|
|
798
|
+
outboundId,
|
|
799
|
+
callSid: call.callSid,
|
|
800
|
+
status: call.status,
|
|
801
|
+
webhookUrl,
|
|
802
|
+
statusCallbackUrl,
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
catch (error) {
|
|
806
|
+
await (0, twilio_phone_1.updateTwilioOutboundCallJob)(settings.outputDir, outboundId, {
|
|
807
|
+
status: "failed",
|
|
808
|
+
error: errorMessage(error),
|
|
809
|
+
});
|
|
810
|
+
throw error;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
function closeTwilioPhoneBridgeServer(server) {
|
|
814
|
+
return Promise.all([
|
|
815
|
+
server.bridge.close?.() ?? Promise.resolve(),
|
|
816
|
+
new Promise((resolve, reject) => {
|
|
817
|
+
;
|
|
818
|
+
server.server.close((error) => error ? reject(error) : resolve());
|
|
819
|
+
}),
|
|
820
|
+
]).then(() => undefined);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* The OpenAI Realtime settings for a local audio join. Local audio needs no public URL or Twilio
|
|
824
|
+
* credentials, only the Realtime key and voice settings, so the phone resolver is asked for a
|
|
825
|
+
* placeholder-enabled media-stream setup and only its Realtime half is returned.
|
|
826
|
+
*/
|
|
827
|
+
async function resolveLocalAudioRealtimeOptions(agentName, deps = defaultTwilioPhoneOutboundCallRuntimeDeps) {
|
|
828
|
+
const settings = await readFreshRuntimeSettings(agentName, {
|
|
829
|
+
enabled: true,
|
|
830
|
+
publicBaseUrl: "https://local-audio.invalid",
|
|
831
|
+
transportMode: "media-stream",
|
|
832
|
+
conversationEngine: "openai-realtime",
|
|
833
|
+
outboundConversationEngine: "openai-realtime",
|
|
834
|
+
}, undefined, false, deps, { preferCached: true });
|
|
835
|
+
return settings.openaiRealtime;
|
|
836
|
+
}
|