@vellumai/assistant 0.10.1 → 0.10.2-dev.202606241651.2d2b40d
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/docs/workspace-tools.md +42 -33
- package/eslint-rules/cli-no-daemon-internals.js +6 -0
- package/node_modules/@vellumai/gateway-client/src/__tests__/guardian-delivery-contract.test.ts +91 -0
- package/node_modules/@vellumai/gateway-client/src/__tests__/trust-verdict-contract.test.ts +31 -0
- package/node_modules/@vellumai/gateway-client/src/guardian-delivery-contract.ts +48 -0
- package/node_modules/@vellumai/gateway-client/src/index.ts +14 -0
- package/node_modules/@vellumai/gateway-client/src/trust-verdict-contract.ts +17 -0
- package/openapi.yaml +74 -1
- package/package.json +1 -1
- package/scripts/test.sh +36 -15
- package/src/__tests__/actor-token-service.test.ts +36 -14
- package/src/__tests__/agent-loop-override-profile.test.ts +1 -0
- package/src/__tests__/agent-wake-disk-pressure-callsite.test.ts +2 -0
- package/src/__tests__/agent-wake-override-profile.test.ts +2 -0
- package/src/__tests__/annotate-activity-metadata.test.ts +2 -0
- package/src/__tests__/annotate-risk-options.test.ts +2 -0
- package/src/__tests__/approval-cascade.test.ts +2 -0
- package/src/__tests__/background-workers-disk-pressure.test.ts +2 -0
- package/src/__tests__/btw-routes.test.ts +2 -0
- package/src/__tests__/build-persisted-content.test.ts +2 -0
- package/src/__tests__/call-controller.test.ts +19 -0
- package/src/__tests__/channel-guardian.test.ts +94 -58
- package/src/__tests__/channel-reply-delivery.test.ts +2 -0
- package/src/__tests__/compaction-events.test.ts +2 -0
- package/src/__tests__/compaction.benchmark.test.ts +2 -0
- package/src/__tests__/compactor-call-site-logging.test.ts +2 -0
- package/src/__tests__/compactor-low-watermark-cut.test.ts +2 -0
- package/src/__tests__/compactor-preserved-tail-count.test.ts +2 -0
- package/src/__tests__/compactor-summary-call-truncation.test.ts +2 -0
- package/src/__tests__/compactor-web-search-strip.test.ts +2 -0
- package/src/__tests__/computer-use-tools.test.ts +13 -0
- package/src/__tests__/config-loader-backfill.test.ts +5 -1
- package/src/__tests__/config-schema.test.ts +1 -0
- package/src/__tests__/confirmation-request-guardian-bridge.test.ts +31 -29
- package/src/__tests__/contacts-relay-reads.test.ts +13 -15
- package/src/__tests__/conversation-abort-tool-results.test.ts +2 -0
- package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +2 -0
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +2 -0
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +2 -0
- package/src/__tests__/conversation-agent-loop.test.ts +7 -0
- package/src/__tests__/conversation-analysis-routes.test.ts +2 -0
- package/src/__tests__/conversation-app-control-lifecycle.test.ts +2 -0
- package/src/__tests__/conversation-confirmation-signals.test.ts +2 -0
- package/src/__tests__/conversation-history-web-search.test.ts +2 -0
- package/src/__tests__/conversation-load-history-repair.test.ts +2 -0
- package/src/__tests__/conversation-load-history-stripped.test.ts +2 -0
- package/src/__tests__/conversation-pairing.test.ts +2 -0
- package/src/__tests__/conversation-process-app-control-preactivation.test.ts +2 -0
- package/src/__tests__/conversation-process-callsite.test.ts +2 -0
- package/src/__tests__/conversation-provider-retry-repair.test.ts +2 -0
- package/src/__tests__/conversation-queue.test.ts +91 -0
- package/src/__tests__/conversation-routes-guardian-reply.test.ts +14 -0
- package/src/__tests__/conversation-routes-slash-commands.test.ts +14 -0
- package/src/__tests__/conversation-slash-queue.test.ts +2 -0
- package/src/__tests__/conversation-slash-unknown.test.ts +2 -0
- package/src/__tests__/conversation-speed-override.test.ts +2 -0
- package/src/__tests__/conversation-surfaces-action-delivery.test.ts +65 -0
- package/src/__tests__/conversation-title-service.test.ts +2 -0
- package/src/__tests__/conversation-tool-setup-attribution.test.ts +47 -0
- package/src/__tests__/conversation-usage.test.ts +2 -0
- package/src/__tests__/conversation-workspace-cache-state.test.ts +2 -0
- package/src/__tests__/conversation-workspace-injection.test.ts +2 -0
- package/src/__tests__/conversation-workspace-tool-tracking.test.ts +2 -0
- package/src/__tests__/credential-security-invariants.test.ts +0 -1
- package/src/__tests__/db-migration-rollback.test.ts +205 -171
- package/src/__tests__/db-test-helpers.ts +5 -4
- package/src/__tests__/deterministic-verification-control-plane.test.ts +4 -2
- package/src/__tests__/disk-pressure-guard.test.ts +41 -0
- package/src/__tests__/dm-persistence.test.ts +2 -0
- package/src/__tests__/emit-signal-routing-intent.test.ts +10 -5
- package/src/__tests__/events-dev-bypass-actor.test.ts +7 -1
- package/src/__tests__/filing-service.test.ts +2 -0
- package/src/__tests__/guardian-binding-drift-heal.test.ts +75 -10
- package/src/__tests__/guardian-dispatch.test.ts +95 -1
- package/src/__tests__/guardian-outbound-http.test.ts +13 -0
- package/src/__tests__/heartbeat-disk-pressure.test.ts +2 -0
- package/src/__tests__/heartbeat-service.test.ts +2 -0
- package/src/__tests__/helpers/channel-test-adapter.ts +1 -7
- package/src/__tests__/host-app-control-routes.test.ts +24 -30
- package/src/__tests__/host-bash-routes.test.ts +31 -41
- package/src/__tests__/host-browser-routes.test.ts +26 -32
- package/src/__tests__/host-cu-proxy.test.ts +299 -0
- package/src/__tests__/host-cu-routes-targeted.test.ts +25 -33
- package/src/__tests__/host-file-routes-targeted.test.ts +40 -52
- package/src/__tests__/host-transfer-routes-targeted.test.ts +31 -43
- package/src/__tests__/http-user-message-parity.test.ts +167 -8
- package/src/__tests__/inbound-slack-persistence.test.ts +2 -0
- package/src/__tests__/invite-redemption-service.test.ts +43 -0
- package/src/__tests__/llm-context-normalization.test.ts +105 -0
- package/src/__tests__/llm-usage-store.test.ts +25 -0
- package/src/__tests__/media-stream-server-integration.test.ts +127 -0
- package/src/__tests__/memory-retrieval-hook.test.ts +2 -0
- package/src/__tests__/messaging-send-tool.test.ts +2 -0
- package/src/__tests__/migration-import-from-url.test.ts +2 -2
- package/src/__tests__/native-web-search.test.ts +2 -0
- package/src/__tests__/non-member-access-request.test.ts +189 -17
- package/src/__tests__/notification-broadcaster.test.ts +4 -0
- package/src/__tests__/notification-decision-recipient-context.test.ts +33 -32
- package/src/__tests__/notification-deep-link.test.ts +6 -0
- package/src/__tests__/notification-guardian-path.test.ts +19 -0
- package/src/__tests__/outbound-slack-persistence.test.ts +2 -0
- package/src/__tests__/pending-interactions-resolved-event.test.ts +7 -4
- package/src/__tests__/persistence-secret-redaction.test.ts +2 -0
- package/src/__tests__/plugin-bootstrap.test.ts +3 -73
- package/src/__tests__/plugin-route-contribution.test.ts +4 -17
- package/src/__tests__/plugin-tool-contribution.test.ts +3 -18
- package/src/__tests__/plugin-types.test.ts +0 -2
- package/src/__tests__/process-message-background-slack.test.ts +2 -0
- package/src/__tests__/process-message-display-content.test.ts +2 -0
- package/src/__tests__/provider-usage-tracking.test.ts +39 -0
- package/src/__tests__/regenerate-fire-and-forget-trace.test.ts +2 -0
- package/src/__tests__/registry.test.ts +3 -0
- package/src/__tests__/relay-server.test.ts +694 -25
- package/src/__tests__/runtime-attachment-metadata.test.ts +0 -1
- package/src/__tests__/secret-ingress-http.test.ts +14 -0
- package/src/__tests__/send-endpoint-busy.test.ts +30 -8
- package/src/__tests__/skills.test.ts +44 -0
- package/src/__tests__/slack-inbound-verification.test.ts +47 -2
- package/src/__tests__/sse-actor-principal-guardian-source.test.ts +102 -0
- package/src/__tests__/steer-on-enqueue-question.test.ts +181 -0
- package/src/__tests__/stt-hints.test.ts +44 -13
- package/src/__tests__/subagent-detail.test.ts +27 -0
- package/src/__tests__/subagent-disposal.test.ts +65 -0
- package/src/__tests__/subagent-notify-parent.test.ts +2 -0
- package/src/__tests__/subagent-spawn-tool-fork.test.ts +2 -0
- package/src/__tests__/subagent-tools.test.ts +2 -0
- package/src/__tests__/suggestion-routes.test.ts +2 -0
- package/src/__tests__/title-generate-hook.test.ts +2 -0
- package/src/__tests__/tool-executor-lifecycle-events.test.ts +2 -0
- package/src/__tests__/tool-executor.test.ts +16 -11
- package/src/__tests__/tool-preview-lifecycle.test.ts +2 -0
- package/src/__tests__/tool-result-metadata-plumbing.test.ts +2 -0
- package/src/__tests__/tool-start-timestamp.test.ts +2 -0
- package/src/__tests__/trusted-contact-inline-approval-integration.test.ts +10 -10
- package/src/__tests__/twilio-routes.test.ts +96 -0
- package/src/__tests__/verification-control-plane-policy.test.ts +2 -0
- package/src/__tests__/web-search-backend-failure.test.ts +2 -0
- package/src/__tests__/workspace-tool-loader.test.ts +195 -2
- package/src/agent/loop-exclusive-tool.test.ts +150 -0
- package/src/agent/loop.ts +56 -0
- package/src/api/constants/sse-replay.ts +41 -0
- package/src/api/index.ts +6 -0
- package/src/api/responses/llm-request-log-entry.ts +25 -0
- package/src/api/responses/subagent-detail.ts +17 -0
- package/src/calls/__tests__/relay-setup-router.test.ts +262 -4
- package/src/calls/call-domain.ts +3 -3
- package/src/calls/guardian-dispatch.ts +10 -8
- package/src/calls/inbound-trust-reader.ts +17 -1
- package/src/calls/media-stream-server.ts +21 -0
- package/src/calls/relay-server.ts +167 -50
- package/src/calls/relay-setup-router.ts +37 -7
- package/src/calls/relay-verification.ts +4 -4
- package/src/calls/stt-hints.ts +9 -12
- package/src/calls/twilio-routes.ts +14 -4
- package/src/cli/commands/__tests__/cache.test.ts +8 -1
- package/src/cli/commands/cache.ts +194 -181
- package/src/cli/commands/db/__tests__/repair.test.ts +6 -5
- package/src/cli/commands/db/status.ts +37 -1
- package/src/cli/commands/mcp.ts +252 -218
- package/src/cli/commands/memory/__tests__/worker.test.ts +302 -0
- package/src/cli/commands/memory/index.ts +2 -0
- package/src/cli/commands/memory/worker.ts +175 -0
- package/src/cli/commands/plugins.ts +75 -3
- package/src/cli/lib/__tests__/install-from-github.test.ts +102 -0
- package/src/cli/lib/__tests__/list-installed-plugins.test.ts +160 -1
- package/src/cli/lib/list-installed-plugins.ts +179 -1
- package/src/config/__tests__/loader-callsite-strip-fallback.test.ts +143 -0
- package/src/config/bundled-skills/computer-use/TOOLS.json +6 -1
- package/src/config/bundled-skills/contacts/tools/contact-merge.ts +27 -17
- package/src/config/bundled-skills/contacts/tools/contact-search.ts +13 -3
- package/src/config/feature-flag-registry.json +0 -8
- package/src/config/loader.ts +36 -5
- package/src/config/schemas/__tests__/memory-v3.test.ts +1 -0
- package/src/config/schemas/memory-lifecycle.ts +12 -0
- package/src/config/schemas/memory-v3.ts +7 -0
- package/src/config/schemas/memory.ts +4 -0
- package/src/config/schemas/timeouts.ts +8 -0
- package/src/config/seed-inference-profiles.ts +14 -5
- package/src/config/skills.ts +27 -5
- package/src/contacts/__tests__/guardian-delivery-reader.test.ts +312 -0
- package/src/contacts/contacts-write.ts +3 -0
- package/src/contacts/guardian-delivery-reader.ts +223 -0
- package/src/daemon/conversation-agent-loop.ts +9 -0
- package/src/daemon/conversation-process.ts +39 -17
- package/src/daemon/conversation-surfaces.ts +8 -0
- package/src/daemon/conversation-tool-setup.ts +49 -16
- package/src/daemon/conversation.ts +21 -2
- package/src/daemon/disk-pressure-guard.ts +12 -2
- package/src/daemon/event-loop-watchdog.ts +28 -1
- package/src/daemon/external-plugins-bootstrap.ts +4 -34
- package/src/daemon/handlers/__tests__/config-a2a-redeem.test.ts +25 -0
- package/src/daemon/handlers/__tests__/config-channels.test.ts +225 -0
- package/src/daemon/handlers/config-a2a.ts +6 -14
- package/src/daemon/handlers/config-channels.ts +78 -22
- package/src/daemon/handlers/conversations.ts +77 -0
- package/src/daemon/host-cu-proxy.ts +102 -11
- package/src/daemon/lifecycle.ts +4 -0
- package/src/daemon/memory-v2-startup.test.ts +72 -0
- package/src/daemon/memory-v2-startup.ts +87 -19
- package/src/daemon/server.ts +0 -4
- package/src/daemon/shutdown-handlers.ts +20 -0
- package/src/daemon/tool-setup-types.ts +9 -0
- package/src/ipc/__tests__/clients-list-ipc.test.ts +1 -1
- package/src/ipc/assistant-server.ts +2 -2
- package/src/memory/__tests__/301-create-watchdog-events.test.ts +110 -0
- package/src/memory/__tests__/memory-retrospective-job.test.ts +8 -0
- package/src/memory/__tests__/prompt-override.test.ts +192 -0
- package/src/memory/__tests__/watchdog-events-store.test.ts +161 -0
- package/src/memory/conversation-crud.ts +38 -0
- package/src/memory/db-connection.ts +22 -3
- package/src/memory/db-init.ts +36 -502
- package/src/memory/db-singleton.ts +6 -4
- package/src/memory/jobs-worker.ts +58 -0
- package/src/memory/llm-usage-store.ts +48 -20
- package/src/memory/memory-retrospective-job.ts +9 -8
- package/src/memory/migrations/014-backfill-inbox-thread-state.ts +13 -3
- package/src/memory/migrations/136-drop-assistant-id-columns.ts +52 -27
- package/src/memory/migrations/209-strip-thinking-from-consolidated.ts +130 -56
- package/src/memory/migrations/300-add-processing-started-at.ts +30 -0
- package/src/memory/migrations/301-create-watchdog-events.ts +45 -0
- package/src/memory/migrations/__tests__/014-backfill-inbox-thread-state.test.ts +108 -0
- package/src/memory/migrations/__tests__/136-drop-assistant-id-columns.test.ts +82 -0
- package/src/memory/migrations/__tests__/209-strip-thinking-from-consolidated.test.ts +224 -0
- package/src/memory/migrations/__tests__/run-migrations.test.ts +2 -2
- package/src/memory/migrations/run-migrations.ts +90 -6
- package/src/memory/migrations/schema-introspection.ts +14 -0
- package/src/memory/migrations/validate-migration-state.ts +101 -66
- package/src/memory/prompt-override.ts +129 -0
- package/src/memory/schema/conversations.ts +9 -0
- package/src/memory/schema/infrastructure.ts +20 -0
- package/src/memory/steps.ts +573 -0
- package/src/memory/v2/__tests__/cli-command-store.test.ts +25 -0
- package/src/memory/v2/__tests__/skill-store.test.ts +80 -0
- package/src/memory/v2/cli-command-store.ts +75 -38
- package/src/memory/v2/prompts/consolidation.ts +13 -82
- package/src/memory/v2/prompts/router.ts +21 -93
- package/src/memory/v2/skill-store.ts +68 -31
- package/src/memory/watchdog-events-store.ts +87 -0
- package/src/memory/worker-control.ts +118 -0
- package/src/memory/worker-process.ts +72 -0
- package/src/notifications/__tests__/broadcaster.test.ts +16 -8
- package/src/notifications/__tests__/connected-channels.test.ts +114 -0
- package/src/notifications/__tests__/decision-engine.test.ts +78 -9
- package/src/notifications/__tests__/destination-resolver.test.ts +256 -0
- package/src/notifications/broadcaster.ts +8 -1
- package/src/notifications/decision-engine.ts +15 -7
- package/src/notifications/destination-resolver.ts +68 -24
- package/src/notifications/emit-signal.ts +39 -14
- package/src/onboarding/checkin-event.test.ts +220 -0
- package/src/onboarding/checkin-event.ts +321 -0
- package/src/onboarding/schedule-checkin.ts +190 -0
- package/src/permissions/question-prompter.test.ts +1 -1
- package/src/permissions/question-prompter.ts +7 -4
- package/src/plugin-api/index.ts +6 -6
- package/src/plugin-api/types.ts +3 -5
- package/src/plugin-api/vision-support.test.ts +28 -4
- package/src/plugin-api/vision-support.ts +66 -31
- package/src/plugins/defaults/advisor/__tests__/consult.test.ts +161 -0
- package/src/plugins/defaults/advisor/__tests__/context-pack-gating.test.ts +106 -0
- package/src/plugins/defaults/advisor/__tests__/context-pack.test.ts +60 -0
- package/src/plugins/defaults/advisor/consult.ts +110 -6
- package/src/plugins/defaults/advisor/context-pack.ts +288 -0
- package/src/plugins/defaults/advisor/steering.ts +14 -2
- package/src/plugins/defaults/advisor/tools/advisor.ts +32 -5
- package/src/plugins/defaults/image-fallback/__tests__/image-fallback.test.ts +47 -7
- package/src/plugins/defaults/image-fallback/hooks/post-tool-use.ts +10 -11
- package/src/plugins/defaults/image-fallback/hooks/user-prompt-submit.ts +12 -20
- package/src/plugins/defaults/image-fallback/src/caption-blocks.ts +42 -11
- package/src/plugins/defaults/memory-v3-shadow/orchestrate.ts +11 -2
- package/src/plugins/defaults/memory-v3-shadow/pool-select.test.ts +146 -0
- package/src/plugins/defaults/memory-v3-shadow/pool-select.ts +29 -1
- package/src/plugins/defaults/memory-v3-shadow/shadow-plugin.ts +8 -1
- package/src/plugins/mtime-cache.ts +7 -2
- package/src/plugins/types.ts +0 -2
- package/src/providers/anthropic/client.ts +5 -0
- package/src/providers/call-site-routing.ts +4 -0
- package/src/providers/model-catalog.ts +16 -0
- package/src/providers/openai/responses-provider.ts +5 -0
- package/src/providers/openrouter/client.ts +5 -0
- package/src/providers/provider-send-message.ts +4 -0
- package/src/providers/ratelimit.ts +4 -0
- package/src/providers/retry.ts +4 -0
- package/src/providers/types.ts +9 -0
- package/src/providers/usage-tracking.ts +4 -0
- package/src/runtime/__tests__/channel-verification-service.test.ts +133 -0
- package/src/runtime/__tests__/guardian-vellum-migration.test.ts +181 -0
- package/src/runtime/__tests__/is-guardian-bound-for-channel.test.ts +66 -0
- package/src/runtime/__tests__/local-principal-trust.test.ts +164 -0
- package/src/runtime/__tests__/trust-verdict-consumer.test.ts +335 -3
- package/src/runtime/access-request-helper.ts +19 -39
- package/src/runtime/actor-trust-resolver.ts +2 -2
- package/src/runtime/anchored-guardian.test.ts +156 -0
- package/src/runtime/anchored-guardian.ts +135 -0
- package/src/runtime/assistant-event-hub.ts +1 -1
- package/src/runtime/assistant-stream-state.ts +9 -2
- package/src/runtime/auth/__tests__/require-bound-guardian.test.ts +99 -0
- package/src/runtime/auth/require-bound-guardian.ts +21 -11
- package/src/runtime/channel-verification-service.ts +56 -31
- package/src/runtime/confirmation-request-guardian-bridge.ts +3 -3
- package/src/runtime/guardian-vellum-migration.ts +66 -7
- package/src/runtime/invite-redemption-service.ts +50 -18
- package/src/runtime/local-actor-identity.ts +76 -11
- package/src/runtime/local-principal-trust.ts +52 -0
- package/src/runtime/pending-interactions.ts +11 -1
- package/src/runtime/routes/__tests__/channel-verification-revoke.test.ts +56 -5
- package/src/runtime/routes/__tests__/channel-verification-routes.test.ts +1 -1
- package/src/runtime/routes/__tests__/contact-routes.test.ts +212 -0
- package/src/runtime/routes/__tests__/global-search-routes.test.ts +93 -0
- package/src/runtime/routes/__tests__/surface-action-routes.test.ts +215 -1
- package/src/runtime/routes/browser-routes.ts +1 -1
- package/src/runtime/routes/channel-verification-routes.ts +3 -3
- package/src/runtime/routes/contact-routes.ts +8 -32
- package/src/runtime/routes/conversation-cli-routes.ts +4 -5
- package/src/runtime/routes/conversation-list-routes.ts +4 -7
- package/src/runtime/routes/conversation-routes.ts +74 -81
- package/src/runtime/routes/events-routes.ts +2 -2
- package/src/runtime/routes/global-search-routes.ts +3 -1
- package/src/runtime/routes/guardian-action-routes.ts +4 -5
- package/src/runtime/routes/host-app-control-routes.ts +5 -4
- package/src/runtime/routes/host-bash-routes.ts +5 -4
- package/src/runtime/routes/host-browser-routes.ts +9 -11
- package/src/runtime/routes/host-cu-routes.ts +5 -4
- package/src/runtime/routes/host-file-routes.ts +5 -4
- package/src/runtime/routes/host-transfer-routes.ts +6 -6
- package/src/runtime/routes/http-adapter.ts +1 -1
- package/src/runtime/routes/identity-routes.ts +3 -2
- package/src/runtime/routes/inbound-message-handler.ts +5 -5
- package/src/runtime/routes/inbound-stages/acl-enforcement.test.ts +97 -5
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +61 -49
- package/src/runtime/routes/inbound-stages/background-dispatch.ts +16 -4
- package/src/runtime/routes/inbound-stages/escalation-intercept.ts +7 -7
- package/src/runtime/routes/inbound-stages/guardian-activation-intercept.test.ts +21 -8
- package/src/runtime/routes/inbound-stages/guardian-activation-intercept.ts +14 -3
- package/src/runtime/routes/index.ts +2 -0
- package/src/runtime/routes/llm-context-normalization.ts +71 -0
- package/src/runtime/routes/mcp-auth-routes.ts +38 -15
- package/src/runtime/routes/migration-rollback-routes.ts +4 -3
- package/src/runtime/routes/migration-routes.ts +4 -1
- package/src/runtime/routes/onboarding-checkin-routes.ts +86 -0
- package/src/runtime/routes/subagents-routes.ts +5 -0
- package/src/runtime/routes/surface-action-routes.ts +51 -55
- package/src/runtime/services/__tests__/conversation-serializer.test.ts +1 -0
- package/src/runtime/services/conversation-serializer.ts +7 -9
- package/src/runtime/tool-grant-request-helper.ts +3 -3
- package/src/runtime/trust-verdict-consumer.ts +85 -9
- package/src/runtime/verification-outbound-actions.ts +18 -18
- package/src/signals/user-message.ts +16 -0
- package/src/subagent/manager.ts +9 -0
- package/src/telemetry/types.ts +34 -1
- package/src/telemetry/usage-telemetry-reporter.test.ts +3 -2
- package/src/telemetry/usage-telemetry-reporter.ts +87 -3
- package/src/tools/ask-question/ask-question-tool.test.ts +29 -0
- package/src/tools/ask-question/ask-question-tool.ts +13 -0
- package/src/tools/computer-use/definitions.ts +8 -2
- package/src/tools/executor.ts +4 -4
- package/src/tools/registry.ts +18 -0
- package/src/tools/tool-approval-handler.ts +1 -1
- package/src/tools/tool-defaults.ts +9 -2
- package/src/tools/types.ts +17 -2
- package/src/tools/workspace-tools/loader.ts +348 -244
- package/src/util/platform.ts +5 -0
- package/src/util/telemetry-db-path.ts +24 -0
- package/src/workspace/migrations/017-seed-persona-dirs.ts +3 -34
- package/src/workspace/migrations/019-scope-journal-to-guardian.ts +3 -24
- package/src/__tests__/workspace-tools-watcher-flag.test.ts +0 -70
- package/src/daemon/workspace-tools-watcher.ts +0 -328
- package/src/memory/migrations/registry.ts +0 -573
package/src/calls/call-domain.ts
CHANGED
|
@@ -267,9 +267,9 @@ type CreateInboundVoiceSessionResult = {
|
|
|
267
267
|
* returned without creating a duplicate. This handles Twilio webhook
|
|
268
268
|
* replays gracefully.
|
|
269
269
|
*/
|
|
270
|
-
export function createInboundVoiceSession(
|
|
270
|
+
export async function createInboundVoiceSession(
|
|
271
271
|
input: CreateInboundVoiceSessionInput,
|
|
272
|
-
): CreateInboundVoiceSessionResult {
|
|
272
|
+
): Promise<CreateInboundVoiceSessionResult> {
|
|
273
273
|
const {
|
|
274
274
|
callSid,
|
|
275
275
|
fromNumber,
|
|
@@ -312,7 +312,7 @@ export function createInboundVoiceSession(
|
|
|
312
312
|
updateCallSession(session.id, { providerCallSid: callSid });
|
|
313
313
|
session.providerCallSid = callSid;
|
|
314
314
|
|
|
315
|
-
const callerIsGuardian = isGuardian(assistantId, "phone", fromNumber);
|
|
315
|
+
const callerIsGuardian = await isGuardian(assistantId, "phone", fromNumber);
|
|
316
316
|
const metadataHints: string[] = [
|
|
317
317
|
callerIsGuardian
|
|
318
318
|
? "Caller is the guardian"
|
|
@@ -86,14 +86,16 @@ async function dispatchGuardianQuestionInner(
|
|
|
86
86
|
try {
|
|
87
87
|
const expiresAt = Date.now() + getUserConsultationTimeoutMs();
|
|
88
88
|
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
// Resolve the request principal from the same local source as the
|
|
90
|
+
// submitting actor (guardian-action-routes / actor-trust-resolver both read
|
|
91
|
+
// findGuardianForChannel("vellum")?.contact.principalId), so they cannot
|
|
92
|
+
// diverge. applyCanonicalGuardianDecision requires strict equality with
|
|
93
|
+
// request.guardianPrincipalId; sharing this local source guarantees the
|
|
94
|
+
// stamped principal == the submitting principal even when the gateway and
|
|
95
|
+
// local bindings drift during migration. This pair converts to the gateway
|
|
96
|
+
// together with the actor-trust path.
|
|
97
|
+
const guardianPrincipalId =
|
|
98
|
+
findGuardianForChannel("vellum")?.contact.principalId ?? undefined;
|
|
97
99
|
|
|
98
100
|
if (!guardianPrincipalId) {
|
|
99
101
|
log.error(
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
* fail-closed); this reader only reports the verdict or `null`.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
type TrustVerdict,
|
|
15
|
+
TrustVerdictSchema,
|
|
16
|
+
} from "@vellumai/gateway-client";
|
|
14
17
|
|
|
15
18
|
import type { ChannelId } from "../channels/types.js";
|
|
16
19
|
import { ipcCall } from "../ipc/gateway-client.js";
|
|
@@ -38,3 +41,16 @@ export async function getInboundTrustVerdict(input: {
|
|
|
38
41
|
return null;
|
|
39
42
|
}
|
|
40
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Resolve the verdict for a phone caller by their external number. Callers
|
|
47
|
+
* compute `otherPartyNumber` from their own transport-specific direction.
|
|
48
|
+
*/
|
|
49
|
+
export function getPhoneCallerVerdict(
|
|
50
|
+
otherPartyNumber: string | undefined,
|
|
51
|
+
): Promise<TrustVerdict | null> {
|
|
52
|
+
return getInboundTrustVerdict({
|
|
53
|
+
channelType: "phone",
|
|
54
|
+
actorExternalId: otherPartyNumber || undefined,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
} from "./call-store.js";
|
|
53
53
|
import { getChannelAdmissionPolicy } from "./channel-admission-reader.js";
|
|
54
54
|
import { finalizeCall } from "./finalize-call.js";
|
|
55
|
+
import { getPhoneCallerVerdict } from "./inbound-trust-reader.js";
|
|
55
56
|
import { MediaStreamOutput } from "./media-stream-output.js";
|
|
56
57
|
import { parseMediaStreamFrame } from "./media-stream-parser.js";
|
|
57
58
|
import type { MediaStreamStartEvent } from "./media-stream-protocol.js";
|
|
@@ -391,6 +392,25 @@ export class MediaStreamCallSession {
|
|
|
391
392
|
return;
|
|
392
393
|
}
|
|
393
394
|
|
|
395
|
+
// Verdict-first caller trust so this transport enforces the same gateway
|
|
396
|
+
// ACL as ConversationRelay. routeSetup uses it when present and not
|
|
397
|
+
// resolutionFailed, else falls back to local resolution. The reader returns
|
|
398
|
+
// null on failure, keeping the local path on a gateway blip.
|
|
399
|
+
const isInbound = session?.initiatedFromConversationId == null;
|
|
400
|
+
const otherPartyNumber = isInbound ? from : to;
|
|
401
|
+
const verdict = await getPhoneCallerVerdict(otherPartyNumber);
|
|
402
|
+
|
|
403
|
+
// The verdict read above yields the event loop; abort if the session was
|
|
404
|
+
// disposed meanwhile, matching the admission-read guard above.
|
|
405
|
+
if (this.disposed) {
|
|
406
|
+
log.info(
|
|
407
|
+
{ callSessionId: this.callSessionId },
|
|
408
|
+
"Media-stream session disposed during verdict read — aborting setup",
|
|
409
|
+
);
|
|
410
|
+
this.setupRouting = false;
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
394
414
|
const { outcome, resolved } = routeSetup({
|
|
395
415
|
callSessionId: this.callSessionId,
|
|
396
416
|
session: session ?? null,
|
|
@@ -398,6 +418,7 @@ export class MediaStreamCallSession {
|
|
|
398
418
|
to,
|
|
399
419
|
customParameters: event.start.customParameters,
|
|
400
420
|
admissionPolicy,
|
|
421
|
+
verdict,
|
|
401
422
|
});
|
|
402
423
|
|
|
403
424
|
log.info(
|
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
import { randomInt } from "node:crypto";
|
|
10
10
|
|
|
11
|
-
import type { AdmissionPolicy } from "@vellumai/gateway-client";
|
|
11
|
+
import type { AdmissionPolicy, TrustVerdict } from "@vellumai/gateway-client";
|
|
12
12
|
import type { ServerWebSocket } from "bun";
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "../contacts/
|
|
15
|
+
getGuardianDelivery,
|
|
16
|
+
voiceGuardianDisplayName,
|
|
17
|
+
} from "../contacts/guardian-delivery-reader.js";
|
|
18
18
|
import { getAssistantName } from "../daemon/identity-helpers.js";
|
|
19
19
|
import type { ServerMessage } from "../daemon/message-protocol.js";
|
|
20
|
+
import type { TrustContext } from "../daemon/trust-context.js";
|
|
20
21
|
import { getCanonicalGuardianRequest } from "../memory/canonical-guardian-store.js";
|
|
21
22
|
import { addMessage } from "../memory/conversation-crud.js";
|
|
22
23
|
import { revokeScopedApprovalGrantsForContext } from "../memory/scoped-approval-grants.js";
|
|
@@ -26,6 +27,11 @@ import {
|
|
|
26
27
|
resolveActorTrust,
|
|
27
28
|
toTrustContext,
|
|
28
29
|
} from "../runtime/actor-trust-resolver.js";
|
|
30
|
+
import {
|
|
31
|
+
trustContextFromVerdict,
|
|
32
|
+
verdictHasMemberIdentity,
|
|
33
|
+
verdictMemberUnresolvable,
|
|
34
|
+
} from "../runtime/trust-verdict-consumer.js";
|
|
29
35
|
import {
|
|
30
36
|
composeVerificationVoice,
|
|
31
37
|
GUARDIAN_VERIFY_TEMPLATE_KEYS,
|
|
@@ -50,6 +56,10 @@ import {
|
|
|
50
56
|
import { ConversationRelayTransport } from "./call-transport.js";
|
|
51
57
|
import { getChannelAdmissionPolicy } from "./channel-admission-reader.js";
|
|
52
58
|
import { finalizeCall } from "./finalize-call.js";
|
|
59
|
+
import {
|
|
60
|
+
getInboundTrustVerdict,
|
|
61
|
+
getPhoneCallerVerdict,
|
|
62
|
+
} from "./inbound-trust-reader.js";
|
|
53
63
|
import {
|
|
54
64
|
classifyWaitUtterance,
|
|
55
65
|
emitAccessRequestCallbackHandoff,
|
|
@@ -252,6 +262,10 @@ export class RelayConnection {
|
|
|
252
262
|
private accessRequestWaitStartedAt: number = 0;
|
|
253
263
|
private heartbeatSequence = 0;
|
|
254
264
|
|
|
265
|
+
// Guardian displayName primed from the gateway binding at setup, read
|
|
266
|
+
// synchronously by the heartbeat-driven wait-label path.
|
|
267
|
+
private primedGuardianDisplayName: string | undefined;
|
|
268
|
+
|
|
255
269
|
// In-wait prompt handling state
|
|
256
270
|
private lastInWaitReplyAt = 0;
|
|
257
271
|
private static readonly IN_WAIT_REPLY_COOLDOWN_MS = 3000;
|
|
@@ -261,6 +275,12 @@ export class RelayConnection {
|
|
|
261
275
|
private callbackOptIn = false;
|
|
262
276
|
private callbackHandoffNotified = false;
|
|
263
277
|
|
|
278
|
+
// True while mid-call trust is being re-resolved (async). handlePrompt defers
|
|
279
|
+
// prompts to trustReResolvePending so a verified caller can't start a turn
|
|
280
|
+
// under the stale pre-verification trust context during the await window.
|
|
281
|
+
private trustReResolving = false;
|
|
282
|
+
private trustReResolvePending: RelayPromptMessage[] = [];
|
|
283
|
+
|
|
264
284
|
constructor(ws: ServerWebSocket<RelayWebSocketData>, callSessionId: string) {
|
|
265
285
|
this.ws = ws;
|
|
266
286
|
this.callSessionId = callSessionId;
|
|
@@ -581,12 +601,21 @@ export class RelayConnection {
|
|
|
581
601
|
const session = getCallSession(this.callSessionId);
|
|
582
602
|
this.recordSetupBookkeeping(session, msg);
|
|
583
603
|
|
|
604
|
+
await this.primeGuardianDisplayName();
|
|
605
|
+
|
|
584
606
|
// Resolve the phone channel's inbound admission floor. The reader fails
|
|
585
607
|
// open to `null` by contract, so a transport hiccup admits the caller.
|
|
586
608
|
const admissionPolicy = await getChannelAdmissionPolicy("phone");
|
|
587
609
|
|
|
610
|
+
// Verdict-first caller trust. routeSetup uses it when present and not
|
|
611
|
+
// resolutionFailed, else falls back to local resolution. The reader
|
|
612
|
+
// returns null on failure, so a gateway blip keeps the local path.
|
|
613
|
+
const isInbound = session?.initiatedFromConversationId == null;
|
|
614
|
+
const otherPartyNumber = isInbound ? msg.from : msg.to;
|
|
615
|
+
const verdict = await getPhoneCallerVerdict(otherPartyNumber);
|
|
616
|
+
|
|
588
617
|
try {
|
|
589
|
-
await this.routeSetupOutcome(msg, session, admissionPolicy);
|
|
618
|
+
await this.routeSetupOutcome(msg, session, admissionPolicy, verdict);
|
|
590
619
|
} catch (err) {
|
|
591
620
|
// Never leave the connection stranded in "setting_up": a setup that
|
|
592
621
|
// throws before reaching a terminal outcome would otherwise drop every
|
|
@@ -615,6 +644,7 @@ export class RelayConnection {
|
|
|
615
644
|
msg: RelaySetupMessage,
|
|
616
645
|
session: ReturnType<typeof getCallSession>,
|
|
617
646
|
admissionPolicy: AdmissionPolicy | null,
|
|
647
|
+
verdict: TrustVerdict | null,
|
|
618
648
|
): Promise<void> {
|
|
619
649
|
const { outcome, resolved } = routeSetup({
|
|
620
650
|
callSessionId: this.callSessionId,
|
|
@@ -623,6 +653,7 @@ export class RelayConnection {
|
|
|
623
653
|
to: msg.to,
|
|
624
654
|
customParameters: msg.customParameters,
|
|
625
655
|
admissionPolicy,
|
|
656
|
+
verdict,
|
|
626
657
|
});
|
|
627
658
|
|
|
628
659
|
const initialTrustContext = toTrustContext(
|
|
@@ -871,6 +902,95 @@ export class RelayConnection {
|
|
|
871
902
|
);
|
|
872
903
|
}
|
|
873
904
|
|
|
905
|
+
/**
|
|
906
|
+
* Re-resolve caller trust after a mid-call verification/activation. Prefers
|
|
907
|
+
* the gateway verdict (authoritative right after the gateway updated the
|
|
908
|
+
* binding); falls back to local resolution on a missing/failed/unusable
|
|
909
|
+
* verdict so a blip never drops the call. Mirrors the setup path's
|
|
910
|
+
* verdict-first-with-fallback condition.
|
|
911
|
+
*/
|
|
912
|
+
private async resolveMidCallTrustContext(
|
|
913
|
+
assistantId: string,
|
|
914
|
+
fromNumber: string,
|
|
915
|
+
): Promise<TrustContext> {
|
|
916
|
+
const verdict = await getInboundTrustVerdict({
|
|
917
|
+
channelType: "phone",
|
|
918
|
+
actorExternalId: fromNumber,
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
// Only a MEMBERLESS unknown verdict is treated as a stale gateway view and
|
|
922
|
+
// falls back to local: the caller was just activated, and invite redemption
|
|
923
|
+
// writes the channel assistant-side, so the gateway may not see the member
|
|
924
|
+
// yet — local resolution has it. A MEMBERFUL unknown verdict (blocked/revoked
|
|
925
|
+
// member, carrying contactId/channelId) is honored so its deny ACL is
|
|
926
|
+
// enforced; falling back could lose the gateway's member status if local
|
|
927
|
+
// state is stale.
|
|
928
|
+
const memberlessUnknown =
|
|
929
|
+
verdict?.trustClass === "unknown" && !verdictHasMemberIdentity(verdict);
|
|
930
|
+
const usable =
|
|
931
|
+
verdict &&
|
|
932
|
+
!verdict.resolutionFailed &&
|
|
933
|
+
!verdictMemberUnresolvable(verdict) &&
|
|
934
|
+
!memberlessUnknown;
|
|
935
|
+
|
|
936
|
+
if (usable) {
|
|
937
|
+
return trustContextFromVerdict(verdict, {
|
|
938
|
+
sourceChannel: "phone",
|
|
939
|
+
conversationExternalId: fromNumber,
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
return toTrustContext(
|
|
944
|
+
resolveActorTrust({
|
|
945
|
+
assistantId,
|
|
946
|
+
sourceChannel: "phone",
|
|
947
|
+
conversationExternalId: fromNumber,
|
|
948
|
+
actorExternalId: fromNumber,
|
|
949
|
+
}),
|
|
950
|
+
fromNumber,
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Re-resolve mid-call trust and install it on the controller, deferring any
|
|
956
|
+
* prompt that arrives during the async window. Guards the gap between
|
|
957
|
+
* connectionState flipping to "connected" and the upgraded context landing so
|
|
958
|
+
* a verified caller never starts a turn under the stale pre-verification
|
|
959
|
+
* trust. Clears the guard in a finally and flushes buffered prompts under the
|
|
960
|
+
* new context, so an IPC error can't wedge the call.
|
|
961
|
+
*/
|
|
962
|
+
private async reResolveAndApplyTrustContext(
|
|
963
|
+
assistantId: string,
|
|
964
|
+
fromNumber: string,
|
|
965
|
+
): Promise<void> {
|
|
966
|
+
if (!this.controller) return;
|
|
967
|
+
this.trustReResolving = true;
|
|
968
|
+
try {
|
|
969
|
+
const context = await this.resolveMidCallTrustContext(
|
|
970
|
+
assistantId,
|
|
971
|
+
fromNumber,
|
|
972
|
+
);
|
|
973
|
+
this.controller.setTrustContext(context);
|
|
974
|
+
} finally {
|
|
975
|
+
this.trustReResolving = false;
|
|
976
|
+
this.flushDeferredPrompts();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Replay prompts buffered while trust was re-resolving. Runs after the
|
|
982
|
+
* upgraded context is installed so deferred utterances are answered under the
|
|
983
|
+
* correct trust.
|
|
984
|
+
*/
|
|
985
|
+
private flushDeferredPrompts(): void {
|
|
986
|
+
if (this.trustReResolvePending.length === 0) return;
|
|
987
|
+
const pending = this.trustReResolvePending;
|
|
988
|
+
this.trustReResolvePending = [];
|
|
989
|
+
for (const msg of pending) {
|
|
990
|
+
void this.handlePrompt(msg);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
874
994
|
/**
|
|
875
995
|
* Shared post-activation handoff for all trusted-contact success paths
|
|
876
996
|
* (access-request approval, invite redemption, verification code).
|
|
@@ -878,7 +998,7 @@ export class RelayConnection {
|
|
|
878
998
|
* transition copy, and marks the next utterance as opening-ack so the
|
|
879
999
|
* LLM continues naturally.
|
|
880
1000
|
*/
|
|
881
|
-
private continueCallAfterTrustedContactActivation(params: {
|
|
1001
|
+
private async continueCallAfterTrustedContactActivation(params: {
|
|
882
1002
|
assistantId: string;
|
|
883
1003
|
fromNumber: string;
|
|
884
1004
|
activationReason?:
|
|
@@ -893,26 +1013,25 @@ export class RelayConnection {
|
|
|
893
1013
|
* address.
|
|
894
1014
|
*/
|
|
895
1015
|
inviteeName?: string | null;
|
|
896
|
-
}): void {
|
|
1016
|
+
}): Promise<void> {
|
|
897
1017
|
const { assistantId, fromNumber } = params;
|
|
898
1018
|
|
|
899
1019
|
// Contact activation is handled by the gateway — the assistant no
|
|
900
1020
|
// longer writes contact/channel records on inbound voice calls.
|
|
901
1021
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1022
|
+
// Reach connected and clear wait/verification flags before re-resolving
|
|
1023
|
+
// trust, so a prompt buffered during re-resolution flushes onto the
|
|
1024
|
+
// real-turn path, not the verification/wait branches.
|
|
1025
|
+
this.connectionState = "connected";
|
|
1026
|
+
this.verificationSessionActive = false;
|
|
1027
|
+
this.inviteRedemptionActive = false;
|
|
1028
|
+
this.accessRequestWaitActive = false;
|
|
1029
|
+
updateCallSession(this.callSessionId, { status: "in_progress" });
|
|
908
1030
|
|
|
909
1031
|
if (this.controller) {
|
|
910
|
-
this.
|
|
1032
|
+
await this.reResolveAndApplyTrustContext(assistantId, fromNumber);
|
|
911
1033
|
}
|
|
912
1034
|
|
|
913
|
-
this.connectionState = "connected";
|
|
914
|
-
updateCallSession(this.callSessionId, { status: "in_progress" });
|
|
915
|
-
|
|
916
1035
|
const guardianLabel = this.resolveGuardianLabel();
|
|
917
1036
|
let handoffText: string;
|
|
918
1037
|
|
|
@@ -1045,7 +1164,7 @@ export class RelayConnection {
|
|
|
1045
1164
|
const assistantId = this.verificationAssistantId;
|
|
1046
1165
|
const fromNumber = this.verificationFromNumber;
|
|
1047
1166
|
|
|
1048
|
-
const result = attemptVerificationCode({
|
|
1167
|
+
const result = await attemptVerificationCode({
|
|
1049
1168
|
verificationAssistantId: assistantId,
|
|
1050
1169
|
verificationFromNumber: fromNumber,
|
|
1051
1170
|
enteredCode,
|
|
@@ -1091,15 +1210,7 @@ export class RelayConnection {
|
|
|
1091
1210
|
|
|
1092
1211
|
// Update trust context on the controller so the LLM knows this is the guardian
|
|
1093
1212
|
if (this.controller) {
|
|
1094
|
-
|
|
1095
|
-
assistantId,
|
|
1096
|
-
sourceChannel: "phone",
|
|
1097
|
-
conversationExternalId: fromNumber,
|
|
1098
|
-
actorExternalId: fromNumber,
|
|
1099
|
-
});
|
|
1100
|
-
this.controller.setTrustContext(
|
|
1101
|
-
toTrustContext(verifiedActorTrust, fromNumber),
|
|
1102
|
-
);
|
|
1213
|
+
await this.reResolveAndApplyTrustContext(assistantId, fromNumber);
|
|
1103
1214
|
}
|
|
1104
1215
|
|
|
1105
1216
|
// Mark session as in-progress and transition to guardian conversation
|
|
@@ -1116,7 +1227,7 @@ export class RelayConnection {
|
|
|
1116
1227
|
);
|
|
1117
1228
|
}
|
|
1118
1229
|
} else if (result.verificationType === "trusted_contact") {
|
|
1119
|
-
this.continueCallAfterTrustedContactActivation({
|
|
1230
|
+
await this.continueCallAfterTrustedContactActivation({
|
|
1120
1231
|
assistantId,
|
|
1121
1232
|
fromNumber,
|
|
1122
1233
|
activationReason: "trusted_contact_verified",
|
|
@@ -1125,15 +1236,7 @@ export class RelayConnection {
|
|
|
1125
1236
|
// Inbound guardian verification: binding already handled above,
|
|
1126
1237
|
// proceed to normal call flow.
|
|
1127
1238
|
if (this.controller) {
|
|
1128
|
-
|
|
1129
|
-
assistantId,
|
|
1130
|
-
sourceChannel: "phone",
|
|
1131
|
-
conversationExternalId: fromNumber,
|
|
1132
|
-
actorExternalId: fromNumber,
|
|
1133
|
-
});
|
|
1134
|
-
this.controller.setTrustContext(
|
|
1135
|
-
toTrustContext(verifiedActorTrust, fromNumber),
|
|
1136
|
-
);
|
|
1239
|
+
await this.reResolveAndApplyTrustContext(assistantId, fromNumber);
|
|
1137
1240
|
this.startNormalCallFlow(this.controller, true);
|
|
1138
1241
|
}
|
|
1139
1242
|
}
|
|
@@ -1296,7 +1399,7 @@ export class RelayConnection {
|
|
|
1296
1399
|
* Creates a canonical access request, notifies the guardian, and
|
|
1297
1400
|
* enters the bounded wait loop for the guardian decision.
|
|
1298
1401
|
*/
|
|
1299
|
-
private handleNameCaptureResponse(callerName: string): void {
|
|
1402
|
+
private async handleNameCaptureResponse(callerName: string): Promise<void> {
|
|
1300
1403
|
if (!this.accessRequestAssistantId || !this.accessRequestFromNumber) {
|
|
1301
1404
|
return;
|
|
1302
1405
|
}
|
|
@@ -1317,7 +1420,7 @@ export class RelayConnection {
|
|
|
1317
1420
|
// Create canonical access request and notify the guardian, including
|
|
1318
1421
|
// the caller's spoken name and voice channel metadata.
|
|
1319
1422
|
try {
|
|
1320
|
-
const accessResult = notifyGuardianOfAccessRequest({
|
|
1423
|
+
const accessResult = await notifyGuardianOfAccessRequest({
|
|
1321
1424
|
canonicalAssistantId: this.accessRequestAssistantId,
|
|
1322
1425
|
sourceChannel: "phone",
|
|
1323
1426
|
conversationExternalId: this.accessRequestFromNumber,
|
|
@@ -1410,7 +1513,7 @@ export class RelayConnection {
|
|
|
1410
1513
|
}
|
|
1411
1514
|
|
|
1412
1515
|
if (request.status === "approved") {
|
|
1413
|
-
this.handleAccessRequestApproved();
|
|
1516
|
+
void this.handleAccessRequestApproved();
|
|
1414
1517
|
} else if (request.status === "denied") {
|
|
1415
1518
|
void this.handleAccessRequestDenied();
|
|
1416
1519
|
}
|
|
@@ -1462,7 +1565,7 @@ export class RelayConnection {
|
|
|
1462
1565
|
* Handle an approved access request: activate the caller as a trusted
|
|
1463
1566
|
* contact, update runtime context, and continue with normal call flow.
|
|
1464
1567
|
*/
|
|
1465
|
-
private handleAccessRequestApproved(): void {
|
|
1568
|
+
private async handleAccessRequestApproved(): Promise<void> {
|
|
1466
1569
|
this.clearAccessRequestWait();
|
|
1467
1570
|
|
|
1468
1571
|
const assistantId = this.accessRequestAssistantId!;
|
|
@@ -1480,7 +1583,7 @@ export class RelayConnection {
|
|
|
1480
1583
|
"Access request approved — caller activated and continuing call",
|
|
1481
1584
|
);
|
|
1482
1585
|
|
|
1483
|
-
this.continueCallAfterTrustedContactActivation({
|
|
1586
|
+
await this.continueCallAfterTrustedContactActivation({
|
|
1484
1587
|
assistantId,
|
|
1485
1588
|
fromNumber,
|
|
1486
1589
|
activationReason: "access_approved",
|
|
@@ -1688,7 +1791,7 @@ export class RelayConnection {
|
|
|
1688
1791
|
"Voice invite redemption succeeded",
|
|
1689
1792
|
);
|
|
1690
1793
|
|
|
1691
|
-
this.continueCallAfterTrustedContactActivation({
|
|
1794
|
+
await this.continueCallAfterTrustedContactActivation({
|
|
1692
1795
|
assistantId: this.inviteRedemptionAssistantId,
|
|
1693
1796
|
fromNumber: this.inviteRedemptionFromNumber,
|
|
1694
1797
|
activationReason: "invite_redeemed",
|
|
@@ -1731,15 +1834,20 @@ export class RelayConnection {
|
|
|
1731
1834
|
* Resolve a human-readable guardian label for voice wait copy.
|
|
1732
1835
|
* Delegates to the shared resolveGuardianName() which checks the
|
|
1733
1836
|
* guardian's per-user persona file (users/<slug>.md) first, then falls
|
|
1734
|
-
* back to
|
|
1837
|
+
* back to the primed gateway-binding displayName, then
|
|
1838
|
+
* DEFAULT_USER_REFERENCE.
|
|
1735
1839
|
*/
|
|
1736
1840
|
private resolveGuardianLabel(): string {
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
const guardianChannels = voiceGuardian ? null : listGuardianChannels();
|
|
1740
|
-
const guardianContact = voiceGuardian?.contact ?? guardianChannels?.contact;
|
|
1841
|
+
return resolveGuardianName(this.primedGuardianDisplayName);
|
|
1842
|
+
}
|
|
1741
1843
|
|
|
1742
|
-
|
|
1844
|
+
/**
|
|
1845
|
+
* Prime the guardian displayName from the gateway binding so the
|
|
1846
|
+
* synchronous wait-label path can read it without an IPC round-trip.
|
|
1847
|
+
*/
|
|
1848
|
+
private async primeGuardianDisplayName(): Promise<void> {
|
|
1849
|
+
const list = await getGuardianDelivery();
|
|
1850
|
+
this.primedGuardianDisplayName = voiceGuardianDisplayName(list);
|
|
1743
1851
|
}
|
|
1744
1852
|
|
|
1745
1853
|
/**
|
|
@@ -1917,6 +2025,15 @@ export class RelayConnection {
|
|
|
1917
2025
|
return;
|
|
1918
2026
|
}
|
|
1919
2027
|
|
|
2028
|
+
// Defer (don't drop) prompts while trust is being re-resolved mid-call so a
|
|
2029
|
+
// verified caller's first utterance runs under the upgraded context, not the
|
|
2030
|
+
// stale pre-verification one. flushDeferredPrompts replays them in order
|
|
2031
|
+
// once the new context lands.
|
|
2032
|
+
if (this.trustReResolving) {
|
|
2033
|
+
this.trustReResolvePending.push(msg);
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
|
|
1920
2037
|
// Prompts arriving before setup routing/ACL completes are dropped — never
|
|
1921
2038
|
// persisted or emitted — so a not-yet-authorized caller's speech can't be
|
|
1922
2039
|
// stored ahead of the admission floor / trust ACL decision.
|
|
@@ -1942,7 +2059,7 @@ export class RelayConnection {
|
|
|
1942
2059
|
{ callSessionId: this.callSessionId, callerName },
|
|
1943
2060
|
"Name captured from unknown inbound caller",
|
|
1944
2061
|
);
|
|
1945
|
-
this.handleNameCaptureResponse(callerName);
|
|
2062
|
+
await this.handleNameCaptureResponse(callerName);
|
|
1946
2063
|
return;
|
|
1947
2064
|
}
|
|
1948
2065
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* next — without performing any side effects itself.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { AdmissionPolicy } from "@vellumai/gateway-client";
|
|
9
|
+
import type { AdmissionPolicy, TrustVerdict } from "@vellumai/gateway-client";
|
|
10
10
|
|
|
11
11
|
import { getConfig } from "../config/loader.js";
|
|
12
12
|
import { getContact } from "../contacts/contact-store.js";
|
|
@@ -21,6 +21,10 @@ import {
|
|
|
21
21
|
type AdmissionPolicyResult,
|
|
22
22
|
enforceAdmissionPolicy,
|
|
23
23
|
} from "../runtime/routes/inbound-stages/admission-policy.js";
|
|
24
|
+
import {
|
|
25
|
+
actorTrustContextFromVerdict,
|
|
26
|
+
verdictMemberUnresolvable,
|
|
27
|
+
} from "../runtime/trust-verdict-consumer.js";
|
|
24
28
|
import { getLogger } from "../util/logger.js";
|
|
25
29
|
import type { CallSession } from "./types.js";
|
|
26
30
|
|
|
@@ -40,6 +44,12 @@ interface SetupContext {
|
|
|
40
44
|
* preserving all pre-admission behavior.
|
|
41
45
|
*/
|
|
42
46
|
admissionPolicy?: AdmissionPolicy | null;
|
|
47
|
+
/**
|
|
48
|
+
* Gateway-stamped caller trust verdict. When present and not
|
|
49
|
+
* `resolutionFailed`, the caller's trust is built from it; otherwise the
|
|
50
|
+
* router falls back to local resolution.
|
|
51
|
+
*/
|
|
52
|
+
verdict?: TrustVerdict | null;
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
// ── Setup outcomes ───────────────────────────────────────────────────
|
|
@@ -112,12 +122,32 @@ export function routeSetup(ctx: SetupContext): {
|
|
|
112
122
|
const isInbound = ctx.session?.initiatedFromConversationId == null;
|
|
113
123
|
const otherPartyNumber = isInbound ? ctx.from : ctx.to;
|
|
114
124
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
// Verdict-first: build caller trust from the gateway verdict when present.
|
|
126
|
+
// Voice falls back to local resolution on a missing/failed verdict so a
|
|
127
|
+
// gateway blip does not drop a known guardian's call — the deliberate
|
|
128
|
+
// difference from the fail-closed text path.
|
|
129
|
+
//
|
|
130
|
+
// A verdict that claims a member (contactId/channelId) but whose ACL can't be
|
|
131
|
+
// reassembled (malformed/mixed-version status·policy) also falls back to local
|
|
132
|
+
// resolution, so voice never trusts a member it cannot ACL-check. A real
|
|
133
|
+
// stranger verdict (no member identity) still takes the verdict path —
|
|
134
|
+
// memberRecord null is correct there.
|
|
135
|
+
const usable =
|
|
136
|
+
ctx.verdict &&
|
|
137
|
+
!ctx.verdict.resolutionFailed &&
|
|
138
|
+
!verdictMemberUnresolvable(ctx.verdict);
|
|
139
|
+
const actorTrust = usable
|
|
140
|
+
? actorTrustContextFromVerdict(ctx.verdict!, {
|
|
141
|
+
sourceChannel: "phone",
|
|
142
|
+
conversationExternalId: otherPartyNumber,
|
|
143
|
+
actorDisplayName: undefined,
|
|
144
|
+
})
|
|
145
|
+
: resolveActorTrust({
|
|
146
|
+
assistantId,
|
|
147
|
+
sourceChannel: "phone",
|
|
148
|
+
conversationExternalId: otherPartyNumber,
|
|
149
|
+
actorExternalId: otherPartyNumber || undefined,
|
|
150
|
+
});
|
|
121
151
|
|
|
122
152
|
const resolved: SetupResolved = {
|
|
123
153
|
assistantId,
|
|
@@ -112,9 +112,9 @@ type VerificationCallResult =
|
|
|
112
112
|
* so the caller can apply side-effects (state mutations, TTS, session
|
|
113
113
|
* updates) without this function needing access to the relay connection.
|
|
114
114
|
*/
|
|
115
|
-
export function attemptVerificationCode(
|
|
115
|
+
export async function attemptVerificationCode(
|
|
116
116
|
params: VerificationCallParams,
|
|
117
|
-
): VerificationCallResult {
|
|
117
|
+
): Promise<VerificationCallResult> {
|
|
118
118
|
const {
|
|
119
119
|
verificationAssistantId,
|
|
120
120
|
verificationFromNumber,
|
|
@@ -142,7 +142,7 @@ export function attemptVerificationCode(
|
|
|
142
142
|
let canonicalPrincipal: string | undefined;
|
|
143
143
|
|
|
144
144
|
if (result.verificationType === "guardian") {
|
|
145
|
-
const existingBinding = getGuardianBinding(
|
|
145
|
+
const existingBinding = await getGuardianBinding(
|
|
146
146
|
verificationAssistantId,
|
|
147
147
|
"phone",
|
|
148
148
|
);
|
|
@@ -155,7 +155,7 @@ export function attemptVerificationCode(
|
|
|
155
155
|
};
|
|
156
156
|
} else {
|
|
157
157
|
// Resolve canonical principal from the vellum channel binding
|
|
158
|
-
const vellumBinding = getGuardianBinding(
|
|
158
|
+
const vellumBinding = await getGuardianBinding(
|
|
159
159
|
verificationAssistantId,
|
|
160
160
|
"vellum",
|
|
161
161
|
);
|
package/src/calls/stt-hints.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { findContactByAddress, listContacts } from "../contacts/contact-store.js";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
listGuardianChannels,
|
|
6
|
-
} from "../contacts/contact-store.js";
|
|
3
|
+
getGuardianDelivery,
|
|
4
|
+
voiceGuardianDisplayName,
|
|
5
|
+
} from "../contacts/guardian-delivery-reader.js";
|
|
7
6
|
import { getAssistantName } from "../daemon/identity-helpers.js";
|
|
8
7
|
import { DEFAULT_USER_REFERENCE, resolveGuardianName } from "../prompts/user-reference.js";
|
|
9
8
|
import { getLogger } from "../util/logger.js";
|
|
@@ -119,7 +118,7 @@ export function buildSttHints(input: SttHintsInput): string {
|
|
|
119
118
|
* {@link buildSttHints}. All DB lookups are best-effort — errors are
|
|
120
119
|
* logged but never propagate so hints can never fail a call.
|
|
121
120
|
*/
|
|
122
|
-
export function resolveCallHints(
|
|
121
|
+
export async function resolveCallHints(
|
|
123
122
|
session: {
|
|
124
123
|
task: string | null;
|
|
125
124
|
toNumber: string;
|
|
@@ -129,16 +128,14 @@ export function resolveCallHints(
|
|
|
129
128
|
inviteGuardianName: string | null;
|
|
130
129
|
} | null,
|
|
131
130
|
staticHints: string[],
|
|
132
|
-
): string {
|
|
131
|
+
): Promise<string> {
|
|
133
132
|
const assistantName = getAssistantName();
|
|
134
133
|
|
|
135
|
-
//
|
|
134
|
+
// Resolve the guardian displayName from the gateway binding for STT vocabulary.
|
|
136
135
|
let guardianDisplayName: string | undefined;
|
|
137
136
|
try {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const guardianContact = voiceGuardian?.contact ?? guardianChannels?.contact;
|
|
141
|
-
guardianDisplayName = guardianContact?.displayName;
|
|
137
|
+
const list = await getGuardianDelivery();
|
|
138
|
+
guardianDisplayName = voiceGuardianDisplayName(list);
|
|
142
139
|
} catch (err) {
|
|
143
140
|
logger.warn({ err }, "Failed to look up guardian contact for STT hints");
|
|
144
141
|
}
|