@vellumai/assistant 0.11.9 → 0.11.10-dev.202609091114.7b6342c
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/ARCHITECTURE.md +2 -2
- package/Dockerfile +6 -12
- package/docs/architecture/memory.md +17 -9
- package/docs/guardian-request-flow.md +7 -4
- package/docs/runbook-trusted-contacts.md +13 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +3 -1
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +3 -1
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
- package/node_modules/@vellumai/gateway-client/src/gateway-ipc-contracts.ts +72 -0
- package/node_modules/@vellumai/service-contracts/package.json +3 -1
- package/node_modules/@vellumai/service-contracts/src/__tests__/plan-credit.test.ts +51 -0
- package/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +2 -0
- package/node_modules/@vellumai/service-contracts/src/desktop-presence.ts +11 -0
- package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/service-contracts/src/plan-credit.ts +66 -0
- package/node_modules/@vellumai/service-contracts/src/secret-detection.ts +7 -0
- package/openapi.yaml +729 -63
- package/package.json +1 -1
- package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +19 -21
- package/src/__tests__/assistant-event-hub-machine-name.test.ts +40 -0
- package/src/__tests__/assistant-event-hub.test.ts +45 -0
- package/src/__tests__/cli-memory-v2-reembed-skills.test.ts +0 -1
- package/src/__tests__/compactor-assistant-tail-preview.test.ts +111 -0
- package/src/__tests__/compactor-tail-resolution.test.ts +116 -0
- package/src/__tests__/computer-use-native-history.test.ts +30 -0
- package/src/__tests__/computer-use-window-schema.test.ts +24 -0
- package/src/__tests__/config-get-vision-flag.test.ts +36 -0
- package/src/__tests__/config-loader-validation-reset-notice.test.ts +47 -15
- package/src/__tests__/context-search-conversations-source.test.ts +27 -5
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +189 -195
- package/src/__tests__/conversation-agent-loop.test.ts +690 -50
- package/src/__tests__/conversation-fork-crud.test.ts +132 -45
- package/src/__tests__/conversation-fork-retrospective.test.ts +9 -7
- package/src/__tests__/conversation-lifecycle.test.ts +684 -10
- package/src/__tests__/conversation-pairing.test.ts +10 -9
- package/src/__tests__/conversation-runtime-assembly.test.ts +288 -1
- package/src/__tests__/conversation-surfaces-history-restored-completion.test.ts +21 -4
- package/src/__tests__/conversation-surfaces-point-at-budget.test.ts +150 -0
- package/src/__tests__/conversation-surfaces-point-at-capability.test.ts +161 -0
- package/src/__tests__/copy-composer-tc-templates.test.ts +2 -2
- package/src/__tests__/credential-security-invariants.test.ts +1 -0
- package/src/__tests__/delivered-post-record.test.ts +107 -0
- package/src/__tests__/guardian-action-service-scope.test.ts +53 -0
- package/src/__tests__/guardian-question-mode.test.ts +88 -138
- package/src/__tests__/headless-browser-mode.test.ts +63 -13
- package/src/__tests__/heartbeat-disk-pressure.test.ts +2 -0
- package/src/__tests__/heartbeat-service.test.ts +118 -27
- package/src/__tests__/host-cu-proxy.test.ts +159 -1
- package/src/__tests__/host-proxy-interface.test.ts +15 -0
- package/src/__tests__/host-proxy-preactivation.test.ts +61 -0
- package/src/__tests__/injector-chain.test.ts +3 -3
- package/src/__tests__/injector-registry-order-guard.test.ts +1 -1
- package/src/__tests__/injector-v3-suppression.test.ts +587 -45
- package/src/__tests__/llm-schema.test.ts +70 -2
- package/src/__tests__/logger.test.ts +33 -32
- package/src/__tests__/mcp-config-secret-boundary.test.ts +2 -0
- package/src/__tests__/memory-config-file-parity.test.ts +18 -0
- package/src/__tests__/memory-retrieval-hook.test.ts +53 -3
- package/src/__tests__/messages-read-boundary-guard.test.ts +0 -1
- package/src/__tests__/messaging-send-tool.test.ts +251 -128
- package/src/__tests__/messaging-shared.test.ts +19 -0
- package/src/__tests__/notification-decision-fallback.test.ts +98 -76
- package/src/__tests__/notification-decision-strategy.test.ts +10 -38
- package/src/__tests__/notification-events-source-context-probe.test.ts +211 -0
- package/src/__tests__/openai-responses-prompt-cache.test.ts +7 -2
- package/src/__tests__/openai-responses-provider.test.ts +42 -0
- package/src/__tests__/outlook-messaging-provider.test.ts +9 -0
- package/src/__tests__/platform-callback-registration.test.ts +162 -3
- package/src/__tests__/plugin-api-webhook-url.test.ts +66 -4
- package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -0
- package/src/__tests__/pricing.test.ts +29 -0
- package/src/__tests__/prompt-cache-cross-turn-stability.test.ts +63 -3
- package/src/__tests__/scheduler-result-notification.test.ts +209 -0
- package/src/__tests__/strip-memory-injections.test.ts +75 -27
- package/src/__tests__/tool-approval-seed-content-blocks.test.ts +4 -13
- package/src/acp/auto-install.test.ts +35 -1
- package/src/acp/resolve-agent.test.ts +3 -3
- package/src/agent/loop.ts +116 -45
- package/src/api/constants/personality-sliders.test.ts +21 -0
- package/src/api/constants/personality-sliders.ts +64 -0
- package/src/api/events/contact-record-request.ts +16 -4
- package/src/api/events/contact-request.ts +10 -1
- package/src/api/index.ts +12 -0
- package/src/api/responses/memory-v3-selection-log.ts +64 -13
- package/src/api/surfaces.ts +6 -5
- package/src/background-wake/next-wake.test.ts +13 -0
- package/src/background-wake/next-wake.ts +4 -2
- package/src/calls/__tests__/voice-session-bridge.test.ts +166 -0
- package/src/calls/__tests__/voice-turn-sight-hold.test.ts +301 -0
- package/src/calls/voice-session-bridge.ts +162 -1
- package/src/calls/voice-triage-escalate.ts +1 -1
- package/src/channels/types.ts +14 -0
- package/src/cli/__tests__/catalog-search-help.test.ts +1 -0
- package/src/cli/__tests__/contacts-address-prompt-cli.test.ts +701 -0
- package/src/cli/__tests__/contacts-record-prompt-cli.test.ts +276 -15
- package/src/cli/__tests__/roadmap-cli.test.ts +313 -0
- package/src/cli/__tests__/run-assistant-command.ts +59 -20
- package/src/cli/commands/__tests__/conversations-slack.test.ts +12 -0
- package/src/cli/commands/__tests__/plugins-search.test.ts +81 -0
- package/src/cli/commands/config.help.ts +3 -1
- package/src/cli/commands/contacts.help.ts +179 -12
- package/src/cli/commands/contacts.ts +442 -47
- package/src/cli/commands/memory/worker.ts +1 -1
- package/src/cli/commands/platform/__tests__/credits-format.test.ts +152 -0
- package/src/cli/commands/platform/__tests__/credits.test.ts +20 -0
- package/src/cli/commands/platform/credits-format.ts +108 -0
- package/src/cli/commands/platform/index.help.ts +33 -11
- package/src/cli/commands/platform/index.ts +7 -18
- package/src/cli/commands/plugins.help.ts +4 -1
- package/src/cli/commands/plugins.ts +2 -1
- package/src/cli/commands/roadmap.help.ts +171 -0
- package/src/cli/commands/roadmap.ts +358 -0
- package/src/cli/index.help.ts +2 -0
- package/src/cli/lib/__tests__/cli-output.test.ts +5 -0
- package/src/cli/lib/cli-output.ts +6 -6
- package/src/cli/program.ts +2 -0
- package/src/config/__tests__/webhook-routing.test.ts +42 -0
- package/src/config/acp-defaults.test.ts +3 -3
- package/src/config/acp-defaults.ts +5 -5
- package/src/config/bundled-skills/acp/SKILL.md +8 -11
- package/src/config/bundled-skills/computer-use/SKILL.md +21 -0
- package/src/config/bundled-skills/computer-use/TOOLS.json +6 -0
- package/src/config/bundled-skills/contacts/SKILL.md +61 -11
- package/src/config/bundled-skills/messaging/SKILL.md +2 -0
- package/src/config/bundled-skills/messaging/TOOLS.json +4 -4
- package/src/config/bundled-skills/messaging/tools/messaging-send.ts +160 -36
- package/src/config/bundled-skills/messaging/tools/shared.ts +6 -0
- package/src/config/bundled-skills/schedule/SKILL.md +10 -2
- package/src/config/bundled-skills/screen-annotation/SKILL.md +80 -0
- package/src/config/bundled-skills/screen-annotation/TOOLS.json +73 -0
- package/src/config/bundled-skills/screen-annotation/tools/screen-annotation.test.ts +74 -0
- package/src/config/bundled-skills/screen-annotation/tools/screen-clear-marks.ts +33 -0
- package/src/config/bundled-skills/screen-annotation/tools/screen-point-at.ts +25 -0
- package/src/config/env-registry.ts +2 -0
- package/src/config/feature-flag-registry.json +39 -7
- package/src/config/input-modalities.test.ts +71 -0
- package/src/config/input-modalities.ts +95 -0
- package/src/config/loader.ts +2 -0
- package/src/config/schemas/__tests__/memory-v3.test.ts +58 -15
- package/src/config/schemas/heartbeat.ts +3 -3
- package/src/config/schemas/llm.ts +47 -10
- package/src/config/schemas/memory-storage.test.ts +39 -0
- package/src/config/schemas/memory-storage.ts +21 -0
- package/src/config/schemas/memory-v3.ts +73 -46
- package/src/config/schemas/services.ts +18 -0
- package/src/config/webhook-routing.ts +12 -2
- package/src/context/compactor.ts +12 -13
- package/src/context/strip-injections.ts +29 -25
- package/src/context/token-estimator.ts +2 -2
- package/src/daemon/__tests__/embedding-reconcile.test.ts +77 -0
- package/src/daemon/__tests__/lifecycle-embedding-reconcile.test.ts +3 -0
- package/src/daemon/__tests__/turn-actor.test.ts +68 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +152 -22
- package/src/daemon/conversation-agent-loop.ts +19 -3
- package/src/daemon/conversation-messaging.ts +3 -2
- package/src/daemon/conversation-runtime-assembly.ts +191 -69
- package/src/daemon/conversation-surfaces.ts +32 -62
- package/src/daemon/conversation.ts +153 -46
- package/src/daemon/embedding-reconcile.ts +64 -1
- package/src/daemon/handlers/config-embeddings.ts +31 -0
- package/src/daemon/host-cu-proxy.ts +66 -50
- package/src/daemon/host-cu-target.ts +139 -0
- package/src/daemon/host-proxy-preactivation.ts +29 -1
- package/src/daemon/mcp-reload-service.ts +6 -0
- package/src/daemon/providers-setup.ts +5 -26
- package/src/daemon/trust-context.ts +1 -1
- package/src/daemon/turn-actor.ts +46 -0
- package/src/heartbeat/heartbeat-service.ts +72 -13
- package/src/inbound/platform-callback-registration.ts +77 -11
- package/src/inbound/pod-webhook-claim.ts +35 -0
- package/src/inbound/velay-webhooks-gate.ts +20 -0
- package/src/ipc/gateway-client.ts +91 -0
- package/src/live-voice/__tests__/live-voice-photo.test.ts +174 -0
- package/src/live-voice/__tests__/live-voice-session-guardian.test.ts +127 -0
- package/src/live-voice/__tests__/live-voice-session-telemetry.test.ts +42 -2
- package/src/live-voice/__tests__/live-voice-sight-frame.test.ts +81 -0
- package/src/live-voice/__tests__/protocol.test.ts +67 -0
- package/src/live-voice/live-voice-connection.ts +14 -1
- package/src/live-voice/live-voice-photo.ts +109 -4
- package/src/live-voice/live-voice-session-manager.ts +10 -1
- package/src/live-voice/live-voice-session.ts +196 -31
- package/src/live-voice/protocol.ts +134 -1
- package/src/mcp/__tests__/reload-signal-emission.test.ts +54 -0
- package/src/mcp/__tests__/reload-signal.test.ts +57 -0
- package/src/mcp/__tests__/startup.test.ts +150 -0
- package/src/mcp/reload-signal.ts +50 -0
- package/src/mcp/startup.ts +101 -0
- package/src/messaging/providers/outlook/adapter.ts +2 -13
- package/src/messaging/providers/outlook/client.ts +13 -1
- package/src/messaging/providers/outlook/types.ts +3 -0
- package/src/messaging/providers/telegram-bot/adapter.ts +9 -2
- package/src/messaging/providers/telegram-bot/client.ts +8 -2
- package/src/messaging/providers/whatsapp/adapter.ts +9 -2
- package/src/messaging/providers/whatsapp/client.ts +8 -2
- package/src/notifications/AGENTS.md +5 -0
- package/src/notifications/README.md +21 -7
- package/src/notifications/__tests__/assistant-reply-producer.test.ts +3 -10
- package/src/notifications/__tests__/background-failure-signal.test.ts +96 -0
- package/src/notifications/__tests__/broadcaster.test.ts +171 -7
- package/src/notifications/__tests__/decision-engine.test.ts +79 -6
- package/src/notifications/__tests__/edit-notification.test.ts +59 -0
- package/src/notifications/__tests__/resolve-visible-in-source.test.ts +96 -0
- package/src/notifications/__tests__/schedule-result-producer.test.ts +397 -0
- package/src/notifications/access-request-copy.ts +5 -5
- package/src/notifications/approval-card-data.ts +29 -13
- package/src/notifications/assistant-reply-producer.ts +0 -4
- package/src/notifications/background-failure-signal.ts +13 -1
- package/src/notifications/broadcaster.ts +65 -2
- package/src/notifications/conversation-pairing.ts +263 -155
- package/src/notifications/copy-composer.ts +38 -22
- package/src/notifications/decision-engine.ts +89 -61
- package/src/notifications/delivered-post-record.ts +81 -0
- package/src/notifications/deliveries-store.ts +8 -1
- package/src/notifications/edit-notification.ts +16 -0
- package/src/notifications/events-store.ts +68 -2
- package/src/notifications/guardian-question-mode.ts +24 -232
- package/src/notifications/home-feed-side-effect.ts +1 -0
- package/src/notifications/notification-utils.ts +13 -5
- package/src/notifications/resolve-visible-in-source.ts +56 -0
- package/src/notifications/schedule-result-producer.ts +275 -0
- package/src/notifications/signal.ts +5 -0
- package/src/oauth/__tests__/seed-providers-managed.test.ts +82 -0
- package/src/oauth/seed-providers.ts +201 -3
- package/src/onboarding/onboarding-events-store.ts +14 -8
- package/src/persistence/conversation-crud.ts +68 -19
- package/src/persistence/embeddings/embedding-backend.test.ts +162 -0
- package/src/persistence/embeddings/embedding-backend.ts +148 -11
- package/src/persistence/embeddings/embedding-gemini.test.ts +328 -9
- package/src/persistence/embeddings/embedding-gemini.ts +211 -27
- package/src/persistence/embeddings/embedding-openai.test.ts +113 -0
- package/src/persistence/embeddings/embedding-openai.ts +55 -4
- package/src/persistence/embeddings/embedding-types.test.ts +24 -0
- package/src/persistence/embeddings/embedding-types.ts +25 -1
- package/src/persistence/job-utils.ts +6 -2
- package/src/persistence/message-metadata.ts +20 -0
- package/src/persistence/migrations/283-memory-v3-selections-message-id-and-sections.ts +2 -1
- package/src/persistence/migrations/376-notification-deliveries-canonical-message-id.ts +37 -0
- package/src/persistence/schema/memory-injection.ts +31 -9
- package/src/persistence/schema/notifications.ts +8 -0
- package/src/persistence/steps.ts +2 -0
- package/src/plugin-api/index.ts +2 -1
- package/src/plugin-api/vision-support.test.ts +81 -0
- package/src/plugin-api/vision-support.ts +57 -10
- package/src/plugin-api/webhook-url.ts +18 -4
- package/src/plugins/AGENTS.md +1 -1
- package/src/plugins/defaults/channel/injectors.ts +3 -1
- package/src/plugins/defaults/injector-order.ts +2 -2
- package/src/plugins/defaults/memory/AGENTS.md +263 -30
- package/src/plugins/defaults/memory/__tests__/conversation-memory-orphan-sweep.test.ts +4 -0
- package/src/plugins/defaults/memory/__tests__/conversation-memory-purge.test.ts +6 -0
- package/src/plugins/defaults/memory/__tests__/db-memory-attach.test.ts +9 -3
- package/src/plugins/defaults/memory/__tests__/memory-log-stores-degraded.test.ts +3 -7
- package/src/plugins/defaults/memory/__tests__/relocated-memory-test-rows.ts +18 -0
- package/src/plugins/defaults/memory/context-search/sources/conversations.ts +16 -2
- package/src/plugins/defaults/memory/conversation-memory-purge.ts +2 -0
- package/src/plugins/defaults/memory/fork-conversation-memory.ts +13 -13
- package/src/plugins/defaults/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +19 -12
- package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +17 -15
- package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +1 -1
- package/src/plugins/defaults/memory/hooks/__tests__/post-compact.test.ts +121 -0
- package/src/plugins/defaults/memory/hooks/init.ts +10 -0
- package/src/plugins/defaults/memory/hooks/injection-metadata.ts +100 -0
- package/src/plugins/defaults/memory/hooks/post-compact.ts +19 -7
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +11 -83
- package/src/plugins/defaults/memory/injectors.ts +4 -4
- package/src/plugins/defaults/memory/job-handlers.ts +4 -1
- package/src/plugins/defaults/memory/jobs/__tests__/embed-concept-page.test.ts +1 -0
- package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +11 -3
- package/src/plugins/defaults/memory/memory-db.ts +4 -0
- package/src/plugins/defaults/memory/memory-marker.ts +28 -17
- package/src/plugins/defaults/memory/src/__tests__/memory-v2-simulate-route.test.ts +0 -1
- package/src/plugins/defaults/memory/src/__tests__/memory-worker-routes.test.ts +20 -0
- package/src/plugins/defaults/memory/src/memory-item-routes.test.ts +0 -1
- package/src/plugins/defaults/memory/src/memory-worker-routes.ts +3 -1
- package/src/plugins/defaults/memory/substrate/__tests__/cli-command-store.test.ts +1 -1
- package/src/plugins/defaults/memory/substrate/__tests__/consolidation-job.test.ts +66 -0
- package/src/plugins/defaults/memory/substrate/__tests__/injected-block-slugs.test.ts +345 -0
- package/src/plugins/defaults/memory/substrate/__tests__/page-index.test.ts +0 -1
- package/src/plugins/defaults/memory/substrate/__tests__/prompts-consolidation.test.ts +170 -1
- package/src/plugins/defaults/memory/substrate/__tests__/reembed-job.test.ts +1 -0
- package/src/plugins/defaults/memory/substrate/capability-slugs.ts +53 -0
- package/src/plugins/defaults/memory/substrate/cli-command-store.ts +4 -18
- package/src/plugins/defaults/memory/substrate/consolidation-job.ts +40 -1
- package/src/plugins/defaults/memory/substrate/ingest.ts +11 -9
- package/src/plugins/defaults/memory/substrate/injected-block-slugs.ts +426 -42
- package/src/plugins/defaults/memory/substrate/page-index.ts +5 -4
- package/src/plugins/defaults/memory/substrate/prompts/consolidation.ts +127 -14
- package/src/plugins/defaults/memory/substrate/skill-store.ts +1 -18
- package/src/plugins/defaults/memory/v2/__tests__/backfill-jobs.test.ts +1 -0
- package/src/plugins/defaults/memory/v2/__tests__/injection.test.ts +2 -8
- package/src/plugins/defaults/memory/v2/__tests__/router.test.ts +0 -1
- package/src/plugins/defaults/memory/v2/injection.ts +4 -4
- package/src/plugins/defaults/memory/v3/__tests__/capabilities.test.ts +16 -0
- package/src/plugins/defaults/memory/v3/__tests__/carry-integration.test.ts +1004 -319
- package/src/plugins/defaults/memory/v3/__tests__/dense.test.ts +227 -4
- package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +836 -263
- package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +65 -38
- package/src/plugins/defaults/memory/v3/__tests__/maintain-job.test.ts +354 -3
- package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +688 -104
- package/src/plugins/defaults/memory/v3/__tests__/overlong-sections.test.ts +109 -0
- package/src/plugins/defaults/memory/v3/__tests__/page-content.test.ts +144 -0
- package/src/plugins/defaults/memory/v3/__tests__/plugin-schema.test.ts +534 -0
- package/src/plugins/defaults/memory/v3/__tests__/pool-log-store.test.ts +449 -0
- package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +265 -27
- package/src/plugins/defaults/memory/v3/__tests__/render-injection.test.ts +34 -117
- package/src/plugins/defaults/memory/v3/__tests__/section-dense-store.test.ts +491 -4
- package/src/plugins/defaults/memory/v3/__tests__/section-needle.test.ts +124 -1
- package/src/plugins/defaults/memory/v3/__tests__/sections.test.ts +264 -4
- package/src/plugins/defaults/memory/v3/__tests__/selection-log-store.test.ts +560 -22
- package/src/plugins/defaults/memory/v3/__tests__/shadow-integration.test.ts +40 -33
- package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +718 -63
- package/src/plugins/defaults/memory/v3/__tests__/types.test.ts +83 -2
- package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
- package/src/plugins/defaults/memory/v3/capabilities.ts +90 -14
- package/src/plugins/defaults/memory/v3/card.test.ts +15 -16
- package/src/plugins/defaults/memory/v3/card.ts +16 -15
- package/src/plugins/defaults/memory/v3/dense.ts +10 -0
- package/src/plugins/defaults/memory/v3/ever-injected-store.test.ts +643 -140
- package/src/plugins/defaults/memory/v3/ever-injected-store.ts +462 -212
- package/src/plugins/defaults/memory/v3/hot-set.test.ts +2 -2
- package/src/plugins/defaults/memory/v3/injector.ts +366 -278
- package/src/plugins/defaults/memory/v3/learned-edges.test.ts +2 -2
- package/src/plugins/defaults/memory/v3/maintain-job.ts +299 -73
- package/src/plugins/defaults/memory/v3/orchestrate.ts +327 -214
- package/src/plugins/defaults/memory/v3/overlong-sections.ts +83 -0
- package/src/plugins/defaults/memory/v3/page-content.ts +72 -92
- package/src/plugins/defaults/memory/v3/plugin-schema.ts +346 -0
- package/src/plugins/defaults/memory/v3/pool-log-store.ts +291 -0
- package/src/plugins/defaults/memory/v3/pool-select.test.ts +2 -2
- package/src/plugins/defaults/memory/v3/pool-select.ts +160 -60
- package/src/plugins/defaults/memory/v3/prune.test.ts +1042 -329
- package/src/plugins/defaults/memory/v3/prune.ts +433 -270
- package/src/plugins/defaults/memory/v3/rare-term-lane.test.ts +269 -0
- package/src/plugins/defaults/memory/v3/rare-term-lane.ts +141 -0
- package/src/plugins/defaults/memory/v3/render-injection.ts +43 -82
- package/src/plugins/defaults/memory/v3/section-dense-store.ts +316 -28
- package/src/plugins/defaults/memory/v3/section-needle.ts +145 -11
- package/src/plugins/defaults/memory/v3/sections.ts +103 -16
- package/src/plugins/defaults/memory/v3/selection-log-store.ts +243 -78
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +189 -68
- package/src/plugins/defaults/memory/v3/tuning-profile.ts +6 -0
- package/src/plugins/defaults/memory/v3/types.ts +169 -23
- package/src/plugins/defaults/memory/v3-eval/__tests__/eval-packets.test.ts +21 -4
- package/src/plugins/defaults/memory/v3-eval/eval-packets.ts +77 -26
- package/src/plugins/types.ts +14 -0
- package/src/providers/__tests__/connection-model-compat.test.ts +1 -0
- package/src/providers/__tests__/provider-secret-catalog.test.ts +4 -0
- package/src/providers/__tests__/xml-tool-call-salvage.test.ts +172 -0
- package/src/providers/inline-audio-support.test.ts +34 -0
- package/src/providers/inline-audio-support.ts +27 -0
- package/src/providers/model-catalog.ts +102 -0
- package/src/providers/openai/__tests__/chat-completions-extra-body.test.ts +51 -0
- package/src/providers/openai/__tests__/chat-completions-provider-xml-salvage.test.ts +291 -0
- package/src/providers/openai/chat-completions-provider.ts +114 -14
- package/src/providers/openai/codex-models.ts +1 -0
- package/src/providers/openai/responses-provider.ts +65 -15
- package/src/providers/opencode/client.test.ts +24 -0
- package/src/providers/opencode/client.ts +6 -1
- package/src/providers/provider-secret-catalog.ts +11 -1
- package/src/providers/retry.ts +6 -0
- package/src/providers/vellum/client.ts +14 -1
- package/src/providers/vellum/personality-directions.test.ts +163 -0
- package/src/providers/vellum/personality-directions.ts +120 -0
- package/src/providers/xml-tool-call-salvage.ts +212 -0
- package/src/runtime/AGENTS.md +7 -2
- package/src/runtime/__tests__/background-job-runner.test.ts +115 -0
- package/src/runtime/__tests__/guardian-form-registry.test.ts +0 -32
- package/src/runtime/__tests__/host-observe.test.ts +44 -0
- package/src/runtime/assistant-event-hub.ts +14 -9
- package/src/runtime/auth/__tests__/guard-tests.test.ts +1 -4
- package/src/runtime/auth/__tests__/route-policy.test.ts +65 -0
- package/src/runtime/auth/same-actor.ts +4 -3
- package/src/runtime/background-job-runner.ts +10 -0
- package/src/runtime/channel-reply-delivery.ts +1 -162
- package/src/runtime/guardian-action-service.ts +20 -1
- package/src/runtime/host-observe.ts +56 -6
- package/src/runtime/http-server.ts +35 -0
- package/src/runtime/outbound-post-reconciliation.ts +183 -0
- package/src/runtime/routes/__tests__/contact-address-prompt-route.test.ts +231 -0
- package/src/runtime/routes/__tests__/contact-record-prompt-route.test.ts +59 -3
- package/src/runtime/routes/__tests__/guardian-form-routes.test.ts +85 -0
- package/src/runtime/routes/__tests__/heartbeat-routes.test.ts +24 -0
- package/src/runtime/routes/__tests__/platform-credits-routes.test.ts +239 -0
- package/src/runtime/routes/__tests__/roadmap-routes.test.ts +469 -0
- package/src/runtime/routes/__tests__/watch-routes.test.ts +70 -1
- package/src/runtime/routes/__tests__/webhook-routes.test.ts +83 -0
- package/src/runtime/routes/contact-prompt-routes.ts +177 -28
- package/src/runtime/routes/conversation-query-routes.ts +53 -11
- package/src/runtime/routes/events-routes.ts +13 -3
- package/src/runtime/routes/guardian-action-routes.ts +7 -0
- package/src/runtime/routes/guardian-form-routes.ts +6 -4
- package/src/runtime/routes/heartbeat-routes.ts +41 -53
- package/src/runtime/routes/index.ts +2 -2
- package/src/runtime/routes/integrations/a2a.ts +12 -3
- package/src/runtime/routes/integrations/vercel.ts +13 -3
- package/src/runtime/routes/platform-routes.ts +175 -23
- package/src/runtime/routes/roadmap-routes.ts +744 -0
- package/src/runtime/routes/watch-routes.ts +50 -0
- package/src/runtime/routes/webhook-routes.ts +24 -2
- package/src/runtime/web-presence.ts +13 -9
- package/src/schedule/__tests__/schedule-timezone.test.ts +21 -3
- package/src/schedule/__tests__/worker-mcp-tools.test.ts +88 -0
- package/src/schedule/schedule-timezone.ts +25 -0
- package/src/schedule/scheduler.ts +19 -0
- package/src/schedule/worker.ts +119 -2
- package/src/telemetry/__tests__/live-voice-funnel.test.ts +32 -0
- package/src/telemetry/live-voice-funnel.ts +33 -0
- package/src/tools/acp/list-agents.test.ts +1 -1
- package/src/tools/browser/__tests__/browser-status.test.ts +3 -0
- package/src/tools/browser/browser-execution.ts +117 -53
- package/src/tools/browser/browser-status-constants.ts +6 -6
- package/src/tools/capability-offer.test.ts +87 -0
- package/src/tools/capability-offer.ts +93 -0
- package/src/tools/computer-use/definitions.ts +6 -0
- package/src/tools/computer-use/skill-proxy-bridge.ts +10 -0
- package/src/tools/terminal/safe-env.ts +2 -0
- package/src/watch/__tests__/watch-retro.test.ts +11 -10
- package/src/watch/__tests__/watch-session-manager.test.ts +75 -1
- package/src/watch/watch-retro.ts +10 -9
- package/src/watch/watch-session-manager.ts +17 -0
- package/src/runtime/routes/__tests__/sight-frame-routes.test.ts +0 -487
- package/src/runtime/routes/sight-frame-routes.ts +0 -136
|
@@ -3,7 +3,11 @@ import { beforeEach, describe, expect, jest, test } from "bun:test";
|
|
|
3
3
|
|
|
4
4
|
import { getConversation } from "../../persistence/conversation-crud.js";
|
|
5
5
|
import { initializeDb } from "../../persistence/db-init.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
HostCaptureTarget,
|
|
8
|
+
HostObservation,
|
|
9
|
+
observeHostScreen,
|
|
10
|
+
} from "../../runtime/host-observe.js";
|
|
7
11
|
import { WatchSessionManager } from "../watch-session-manager.js";
|
|
8
12
|
import { renderWatchTimeline } from "../watch-timeline.js";
|
|
9
13
|
|
|
@@ -200,6 +204,76 @@ describe("watch session manager", () => {
|
|
|
200
204
|
manager.stop();
|
|
201
205
|
});
|
|
202
206
|
|
|
207
|
+
/**
|
|
208
|
+
* The pick is the session's for its whole life: every read carries it, and a
|
|
209
|
+
* session started without one carries none rather than a key set to nothing.
|
|
210
|
+
*/
|
|
211
|
+
test("reads the window the session was started on, every time", async () => {
|
|
212
|
+
const targets: (HostCaptureTarget | undefined)[] = [];
|
|
213
|
+
const manager = new WatchSessionManager({
|
|
214
|
+
now: () => nowMs,
|
|
215
|
+
observe: async (options) => {
|
|
216
|
+
targets.push(options.captureTarget);
|
|
217
|
+
return richObservation();
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
const target: HostCaptureTarget = { kind: "window", windowId: 4211 };
|
|
221
|
+
const result = manager.start({
|
|
222
|
+
sourceActorPrincipalId: PRINCIPAL_ID,
|
|
223
|
+
captureTarget: target,
|
|
224
|
+
});
|
|
225
|
+
expect(result.status).toBe("started");
|
|
226
|
+
await settle();
|
|
227
|
+
await elapse(6_000);
|
|
228
|
+
await manager.handleNarrationStart();
|
|
229
|
+
|
|
230
|
+
expect(targets).toEqual([target, target]);
|
|
231
|
+
|
|
232
|
+
manager.stop();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test("keys the helper's state by the session, so no two share it", async () => {
|
|
236
|
+
const keys: (string | undefined)[] = [];
|
|
237
|
+
const manager = new WatchSessionManager({
|
|
238
|
+
now: () => nowMs,
|
|
239
|
+
observe: async (received) => {
|
|
240
|
+
keys.push(received.stateKey);
|
|
241
|
+
return richObservation();
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
const first = start(manager);
|
|
245
|
+
await settle();
|
|
246
|
+
manager.stop();
|
|
247
|
+
const second = start(manager);
|
|
248
|
+
await settle();
|
|
249
|
+
manager.stop();
|
|
250
|
+
|
|
251
|
+
expect(first.status).toBe("started");
|
|
252
|
+
expect(second.status).toBe("started");
|
|
253
|
+
expect(keys).toHaveLength(2);
|
|
254
|
+
expect(keys[0]).toMatch(/^watch:/);
|
|
255
|
+
expect(keys[1]).toMatch(/^watch:/);
|
|
256
|
+
expect(keys[0]).not.toBe(keys[1]);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test("names no target for a session started without one", async () => {
|
|
260
|
+
const options: Parameters<typeof observeHostScreen>[0][] = [];
|
|
261
|
+
const manager = new WatchSessionManager({
|
|
262
|
+
now: () => nowMs,
|
|
263
|
+
observe: async (received) => {
|
|
264
|
+
options.push(received);
|
|
265
|
+
return richObservation();
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
start(manager);
|
|
269
|
+
await settle();
|
|
270
|
+
|
|
271
|
+
expect(options).toHaveLength(1);
|
|
272
|
+
expect("captureTarget" in options[0]!).toBe(false);
|
|
273
|
+
|
|
274
|
+
manager.stop();
|
|
275
|
+
});
|
|
276
|
+
|
|
203
277
|
test("observes on speech onset rather than waiting for the sentence to land", async () => {
|
|
204
278
|
const { manager, calls } = newManager();
|
|
205
279
|
start(manager);
|
package/src/watch/watch-retro.ts
CHANGED
|
@@ -127,12 +127,13 @@ const WATCH_RETRO_WAKE_SOURCE = "watch-retro";
|
|
|
127
127
|
* be enumerated, the question is not ready to be asked, and the honest move is
|
|
128
128
|
* to leave the step described rather than explained.
|
|
129
129
|
*
|
|
130
|
-
* **
|
|
131
|
-
* `
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
130
|
+
* **The first option is the recommended one, and the card marks it as such.**
|
|
131
|
+
* On a `pick` that is the reading the recording already supports. On a `gate`
|
|
132
|
+
* it must be the cautious one, the single place where the recommendation is
|
|
133
|
+
* deliberately not the model's guess. Nothing is selected for the user: a
|
|
134
|
+
* `pick` or a `gate` is answered by tapping an option, so the answer that comes
|
|
135
|
+
* back is one they chose. Only the `fill` is skippable, and a skipped `fill`
|
|
136
|
+
* keeps its pre-filled suggestion, so it is an edit rather than a blank.
|
|
136
137
|
*
|
|
137
138
|
* **The skill loads before the card is shown, and nothing follows the card.**
|
|
138
139
|
* `skill-management` opens on "Ask before doing anything", so a turn that loads
|
|
@@ -169,11 +170,11 @@ The payload:
|
|
|
169
170
|
- \`eyebrow\`: what the session cost, in the teaching's own words, e.g. "Taught in 4 min" or "Taught in 4 min, 11 screens". Never "watched": the user taught you this, they did not perform for you.
|
|
170
171
|
- \`questions\`: at most three, most consequential first. Fewer is better, and none is a valid answer if the recording settled everything. Each question is \`{ id, kind, prompt }\`: \`prompt\` is the question worded the way you would ask it out loud, and \`id\` is a handle no other question on this card uses. A \`pick\` or a \`gate\` adds \`options\`, each of them \`{ id, label }\` and optionally a \`note\`: \`label\` is the answer as the user reads it, and \`id\` is that option's own handle. Use those names exactly. A question's text is \`prompt\` and never \`question\` or \`text\`; an option's text is \`label\` and never \`value\` or \`title\`. Anything sent under another name is dropped on the way to the card, and the page it belonged to is lost.
|
|
171
172
|
|
|
172
|
-
Every question is answerable in one tap and
|
|
173
|
+
Every question is answerable in one tap, and the user has to answer each one to save, so ask only about what you are genuinely guessing at: a value you could not read, a choice whose rule you could not infer, a step you only saw the result of. Do not ask the user to confirm something the recording already showed you.
|
|
173
174
|
|
|
174
175
|
- \`kind: "fill"\` is a single text field, and there is at most one of them: what they would say to start this task, in their own words. Always ask it, because the recording cannot tell you. Put your best guess in \`suggestion\` so skipping keeps a working phrase instead of leaving it blank.
|
|
175
|
-
- \`kind: "pick"\` is two to four named alternatives. The first option is the
|
|
176
|
-
- \`kind: "gate"\` is for a destructive or irreversible step, and it is asked however plainly the step was seen. Not "did you do this" (you watched them), but whether you may do it unattended. The first option must be the cautious one ("Ask me first"), because
|
|
176
|
+
- \`kind: "pick"\` is two to four named alternatives. The first option is shown as the recommended one and must be the reading the recording supports; mark it with a \`note\` saying so. Never ask a yes/no whose "no" tells you nothing: "was the rule X?" wastes the question, where "what decides this?" with X first among the options gets an answer either way. If you cannot name the alternatives, you do not understand the gap well enough to ask about it, so leave the step described and ask nothing.
|
|
177
|
+
- \`kind: "gate"\` is for a destructive or irreversible step, and it is asked however plainly the step was seen. Not "did you do this" (you watched them), but whether you may do it unattended. The first option must be the cautious one ("Ask me first"), because it is the one shown as recommended.
|
|
177
178
|
|
|
178
179
|
Ask about the done condition only if it is genuinely unclear, and as a \`pick\`.`;
|
|
179
180
|
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
getConversation,
|
|
24
24
|
} from "../persistence/conversation-crud.js";
|
|
25
25
|
import {
|
|
26
|
+
type HostCaptureTarget,
|
|
26
27
|
type HostObservationFields,
|
|
27
28
|
observeHostScreen,
|
|
28
29
|
} from "../runtime/host-observe.js";
|
|
@@ -141,6 +142,8 @@ function shouldAttachScreenshot(observation: HostObservationFields): boolean {
|
|
|
141
142
|
return observation.axDiff?.includes(WHOLE_WINDOW_REPLACEMENT_MARKER) === true;
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
export type { HostCaptureTarget } from "../runtime/host-observe.js";
|
|
146
|
+
|
|
144
147
|
/** What a finished session leaves behind for the retrospective to read. */
|
|
145
148
|
export interface WatchSessionSummary {
|
|
146
149
|
readonly sessionId: string;
|
|
@@ -168,6 +171,12 @@ export interface WatchSessionStartOptions {
|
|
|
168
171
|
* client and returns an ambiguity error otherwise.
|
|
169
172
|
*/
|
|
170
173
|
readonly clientId?: string;
|
|
174
|
+
/**
|
|
175
|
+
* What the session reads: one display, one window, or the client's default.
|
|
176
|
+
* Fixed for the session's life, since it is the user's pick from the
|
|
177
|
+
* surface that started it, and passed to every observation unchanged.
|
|
178
|
+
*/
|
|
179
|
+
readonly captureTarget?: HostCaptureTarget;
|
|
171
180
|
/**
|
|
172
181
|
* Called once for each screen read that landed on the timeline, so whoever
|
|
173
182
|
* started the session can tell the user their screen was just read.
|
|
@@ -221,6 +230,7 @@ interface ActiveWatchSession {
|
|
|
221
230
|
readonly conversationId: string;
|
|
222
231
|
readonly sourceActorPrincipalId: string;
|
|
223
232
|
readonly clientId: string | undefined;
|
|
233
|
+
readonly captureTarget: HostCaptureTarget | undefined;
|
|
224
234
|
readonly onObservation: (() => void) | undefined;
|
|
225
235
|
readonly startedAtMs: number;
|
|
226
236
|
entryCount: number;
|
|
@@ -300,6 +310,7 @@ export class WatchSessionManager {
|
|
|
300
310
|
conversationId,
|
|
301
311
|
sourceActorPrincipalId: options.sourceActorPrincipalId,
|
|
302
312
|
clientId: options.clientId,
|
|
313
|
+
captureTarget: options.captureTarget,
|
|
303
314
|
onObservation: options.onObservation,
|
|
304
315
|
startedAtMs: this.now(),
|
|
305
316
|
entryCount: 0,
|
|
@@ -456,6 +467,12 @@ export class WatchSessionManager {
|
|
|
456
467
|
sourceActorPrincipalId: session.sourceActorPrincipalId,
|
|
457
468
|
timeoutMs: OBSERVE_TIMEOUT_MS,
|
|
458
469
|
...(session.clientId ? { clientId: session.clientId } : {}),
|
|
470
|
+
...(session.captureTarget
|
|
471
|
+
? { captureTarget: session.captureTarget }
|
|
472
|
+
: {}),
|
|
473
|
+
// The helper's diff state is this session's alone, so its first
|
|
474
|
+
// observation is never described against the last session's.
|
|
475
|
+
stateKey: `watch:${session.sessionId}`,
|
|
459
476
|
});
|
|
460
477
|
if (session.stopped) {
|
|
461
478
|
return;
|
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for POST /v1/conversations/:id/sight-frame, the HTTP door the text
|
|
3
|
-
* chat's camera tile persists a kept frame through.
|
|
4
|
-
*
|
|
5
|
-
* Exercises the guards the handler owns (an id that names no conversation, a
|
|
6
|
-
* body with no attachment), the actor the row is attributed to, and the
|
|
7
|
-
* persist behaviour it inherits from the live-voice path, including the one
|
|
8
|
-
* difference: a keep taken beside the composer is not a voice session turn.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { describe, expect, mock, spyOn, test } from "bun:test";
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
createMockProvider,
|
|
15
|
-
textResponse,
|
|
16
|
-
} from "../../../__tests__/helpers/mock-provider.js";
|
|
17
|
-
import { setConfig } from "../../../__tests__/helpers/set-config.js";
|
|
18
|
-
|
|
19
|
-
setConfig("memory", { enabled: false });
|
|
20
|
-
|
|
21
|
-
import { Conversation } from "../../../daemon/conversation.js";
|
|
22
|
-
import {
|
|
23
|
-
deleteConversation,
|
|
24
|
-
setConversation,
|
|
25
|
-
} from "../../../daemon/conversation-registry.js";
|
|
26
|
-
import { destroyActiveConversation } from "../../../daemon/conversation-store.js";
|
|
27
|
-
import { _setProcessingWaitMsForTests } from "../../../live-voice/live-voice-photo.js";
|
|
28
|
-
import {
|
|
29
|
-
getAttachmentById,
|
|
30
|
-
uploadAttachment,
|
|
31
|
-
} from "../../../persistence/attachments-store.js";
|
|
32
|
-
import {
|
|
33
|
-
createConversation,
|
|
34
|
-
deleteConversation as deleteConversationRows,
|
|
35
|
-
getConversation,
|
|
36
|
-
getMessages,
|
|
37
|
-
type MessageRow,
|
|
38
|
-
} from "../../../persistence/conversation-crud.js";
|
|
39
|
-
import { sightFrameAttachmentIdsFromMetadata } from "../../../persistence/conversation-types.js";
|
|
40
|
-
import { getDb } from "../../../persistence/db-connection.js";
|
|
41
|
-
import { initializeDb } from "../../../persistence/db-init.js";
|
|
42
|
-
import { conversations } from "../../../persistence/schema/index.js";
|
|
43
|
-
import { BadRequestError, NotFoundError } from "../errors.js";
|
|
44
|
-
import type { RouteDefinition } from "../types.js";
|
|
45
|
-
import * as vellumActorTrust from "../vellum-actor-trust.js";
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Run something in the window the handler opens between accepting the request
|
|
49
|
-
* and persisting the frame.
|
|
50
|
-
*
|
|
51
|
-
* Resolving the request's actor is the only thing the handler awaits in
|
|
52
|
-
* between, so a hook here lands inside that window without a timer to race.
|
|
53
|
-
* Armed per test and cleared as it fires; every other test leaves it null and
|
|
54
|
-
* gets the real resolver.
|
|
55
|
-
*/
|
|
56
|
-
let duringTrustResolution: (() => void) | null = null;
|
|
57
|
-
const realVellumActorTrust = { ...vellumActorTrust };
|
|
58
|
-
mock.module("../vellum-actor-trust.js", () => ({
|
|
59
|
-
...realVellumActorTrust,
|
|
60
|
-
resolveVellumActorTrustContext: (
|
|
61
|
-
...args: Parameters<
|
|
62
|
-
typeof realVellumActorTrust.resolveVellumActorTrustContext
|
|
63
|
-
>
|
|
64
|
-
) => {
|
|
65
|
-
const hook = duringTrustResolution;
|
|
66
|
-
duringTrustResolution = null;
|
|
67
|
-
hook?.();
|
|
68
|
-
return realVellumActorTrust.resolveVellumActorTrustContext(...args);
|
|
69
|
-
},
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
|
-
const { ROUTES: SIGHT_FRAME_ROUTES } = await import("../sight-frame-routes.js");
|
|
73
|
-
|
|
74
|
-
await initializeDb();
|
|
75
|
-
|
|
76
|
-
const IMAGE_BASE64 =
|
|
77
|
-
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk";
|
|
78
|
-
|
|
79
|
-
function findHandler(routes: RouteDefinition[], operationId: string) {
|
|
80
|
-
const route = routes.find((r) => r.operationId === operationId);
|
|
81
|
-
if (!route) {
|
|
82
|
-
throw new Error(`Route ${operationId} not found`);
|
|
83
|
-
}
|
|
84
|
-
return route.handler;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const sightFrameHandler = findHandler(
|
|
88
|
-
SIGHT_FRAME_ROUTES,
|
|
89
|
-
"conversationSightFrame",
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
interface SightFrameResponse {
|
|
93
|
-
persisted: boolean;
|
|
94
|
-
messageId?: string;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function persist(
|
|
98
|
-
id: string,
|
|
99
|
-
body: Record<string, unknown>,
|
|
100
|
-
headers?: Record<string, string>,
|
|
101
|
-
): Promise<SightFrameResponse> {
|
|
102
|
-
return sightFrameHandler({
|
|
103
|
-
pathParams: { id },
|
|
104
|
-
body,
|
|
105
|
-
...(headers ? { headers } : {}),
|
|
106
|
-
}) as Promise<SightFrameResponse>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Tear the conversation down the way DELETE /v1/conversations/:id does. */
|
|
110
|
-
function deleteEverywhere(id: string): void {
|
|
111
|
-
destroyActiveConversation(id, { keepSubagentRecords: true });
|
|
112
|
-
deleteConversationRows(id);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** A registered conversation the persist path can reach, plus its teardown. */
|
|
116
|
-
function liveConversation(title: string) {
|
|
117
|
-
const row = createConversation(title);
|
|
118
|
-
const { provider } = createMockProvider([textResponse("")]);
|
|
119
|
-
const activeConversation = new Conversation(
|
|
120
|
-
row.id,
|
|
121
|
-
provider,
|
|
122
|
-
"system prompt",
|
|
123
|
-
() => {},
|
|
124
|
-
"/tmp",
|
|
125
|
-
{ maxTokens: 4096 },
|
|
126
|
-
);
|
|
127
|
-
activeConversation.setTrustContext({
|
|
128
|
-
trustClass: "guardian",
|
|
129
|
-
sourceChannel: "vellum",
|
|
130
|
-
});
|
|
131
|
-
setConversation(row.id, activeConversation);
|
|
132
|
-
return {
|
|
133
|
-
id: row.id,
|
|
134
|
-
activeConversation,
|
|
135
|
-
dispose: () => {
|
|
136
|
-
deleteConversation(row.id);
|
|
137
|
-
activeConversation.dispose();
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function metadataOf(row: MessageRow): Record<string, unknown> {
|
|
143
|
-
return JSON.parse(row.metadata ?? "{}") as Record<string, unknown>;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function conversationCount(): number {
|
|
147
|
-
return getDb().select({ id: conversations.id }).from(conversations).all()
|
|
148
|
-
.length;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function uploadFrame(name: string): Promise<string> {
|
|
152
|
-
return uploadAttachment(name, "image/png", IMAGE_BASE64).then((a) => a.id);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** True while the attachment's row is still in the store. */
|
|
156
|
-
function frameStored(attachmentId: string): boolean {
|
|
157
|
-
return getAttachmentById(attachmentId) !== null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function sleep(ms: number): Promise<void> {
|
|
161
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
describe("POST /v1/conversations/:id/sight-frame", () => {
|
|
165
|
-
test("404s for an unknown id without minting a conversation for it", async () => {
|
|
166
|
-
// The persist calls `getOrCreateConversation`, so an id the handler lets
|
|
167
|
-
// through becomes a conversation holding nothing but camera frames.
|
|
168
|
-
const before = conversationCount();
|
|
169
|
-
|
|
170
|
-
await expect(
|
|
171
|
-
persist(crypto.randomUUID(), { attachmentId: "att-1" }),
|
|
172
|
-
).rejects.toThrow(NotFoundError);
|
|
173
|
-
|
|
174
|
-
expect(conversationCount()).toBe(before);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test("400s when the body carries no attachment", async () => {
|
|
178
|
-
const live = liveConversation("Chat keep bad body");
|
|
179
|
-
try {
|
|
180
|
-
await expect(persist(live.id, {})).rejects.toThrow(BadRequestError);
|
|
181
|
-
await expect(persist(live.id, { attachmentId: "" })).rejects.toThrow(
|
|
182
|
-
BadRequestError,
|
|
183
|
-
);
|
|
184
|
-
await expect(persist(live.id, { attachmentId: 7 })).rejects.toThrow(
|
|
185
|
-
BadRequestError,
|
|
186
|
-
);
|
|
187
|
-
expect(getMessages(live.id)).toHaveLength(0);
|
|
188
|
-
} finally {
|
|
189
|
-
live.dispose();
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
test("persists the frame as its own tagged row and names it", async () => {
|
|
194
|
-
const live = liveConversation("Chat keep happy path");
|
|
195
|
-
try {
|
|
196
|
-
const attachmentId = await uploadFrame("frame.png");
|
|
197
|
-
|
|
198
|
-
const response = await persist(live.id, { attachmentId });
|
|
199
|
-
|
|
200
|
-
const [row] = getMessages(live.id);
|
|
201
|
-
expect(response).toEqual({ persisted: true, messageId: row.id });
|
|
202
|
-
expect(row.content.filter((block) => block.type === "text")).toEqual([
|
|
203
|
-
{ type: "text", text: "(camera frame)" },
|
|
204
|
-
]);
|
|
205
|
-
// Retention reads the tag and the memory-privacy guard reads the pair of
|
|
206
|
-
// `scripted` and the tag, so a chat keep has to carry both.
|
|
207
|
-
expect(metadataOf(row).scripted).toBe(true);
|
|
208
|
-
expect(sightFrameAttachmentIdsFromMetadata(metadataOf(row))).toEqual([
|
|
209
|
-
attachmentId,
|
|
210
|
-
]);
|
|
211
|
-
} finally {
|
|
212
|
-
live.dispose();
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
test("attributes the row to the verified actor, not the conversation's trust", async () => {
|
|
217
|
-
// The conversation rests on the trust of whoever used it last, so a row
|
|
218
|
-
// stamped from the slot names that actor rather than the one this request
|
|
219
|
-
// was verified as. Actor-scoped history reads the stamp, so the wrong one
|
|
220
|
-
// either hides the frame from its owner or lends guardian standing to
|
|
221
|
-
// content that has none.
|
|
222
|
-
const live = liveConversation("Chat keep actor attribution");
|
|
223
|
-
try {
|
|
224
|
-
const attachmentId = await uploadFrame("frame.png");
|
|
225
|
-
// A principal no guardian binding names, which the vellum-channel
|
|
226
|
-
// resolver fails closed to `unknown`.
|
|
227
|
-
const headers = { "x-vellum-actor-principal-id": "actor-not-bound" };
|
|
228
|
-
expect(live.activeConversation.trustContext?.trustClass).toBe("guardian");
|
|
229
|
-
|
|
230
|
-
expect(await persist(live.id, { attachmentId }, headers)).toMatchObject({
|
|
231
|
-
persisted: true,
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
const metadata = metadataOf(getMessages(live.id)[0]);
|
|
235
|
-
expect(metadata.provenanceTrustClass).toBe("unknown");
|
|
236
|
-
expect(metadata.provenanceSourceChannel).toBe("vellum");
|
|
237
|
-
} finally {
|
|
238
|
-
live.dispose();
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
test("attributes a caller with no actor header to the guardian", async () => {
|
|
243
|
-
// A local or IPC caller carries no actor header and is the guardian by
|
|
244
|
-
// construction, the same reading canonical ingress gives it.
|
|
245
|
-
const live = liveConversation("Chat keep local caller");
|
|
246
|
-
try {
|
|
247
|
-
const attachmentId = await uploadFrame("frame.png");
|
|
248
|
-
|
|
249
|
-
expect(await persist(live.id, { attachmentId })).toMatchObject({
|
|
250
|
-
persisted: true,
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
const metadata = metadataOf(getMessages(live.id)[0]);
|
|
254
|
-
expect(metadata.provenanceTrustClass).toBe("guardian");
|
|
255
|
-
expect(metadata.provenanceSourceChannel).toBe("vellum");
|
|
256
|
-
} finally {
|
|
257
|
-
live.dispose();
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
test("does not mark a composer keep as a voice session turn", async () => {
|
|
262
|
-
// The mark says a reply reaches the user over a session that is still
|
|
263
|
-
// open. Nothing is open here, so a reply that follows this row has to be
|
|
264
|
-
// pushed like any other.
|
|
265
|
-
const live = liveConversation("Chat keep voice mark");
|
|
266
|
-
try {
|
|
267
|
-
const attachmentId = await uploadFrame("frame.png");
|
|
268
|
-
|
|
269
|
-
expect(await persist(live.id, { attachmentId })).toMatchObject({
|
|
270
|
-
persisted: true,
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
expect(
|
|
274
|
-
metadataOf(getMessages(live.id)[0]).voiceSessionTurn,
|
|
275
|
-
).toBeUndefined();
|
|
276
|
-
} finally {
|
|
277
|
-
live.dispose();
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
test("a frame from another actor makes the resident history reload", async () => {
|
|
282
|
-
// The persist stamps the ROW for the actor that sent it, but the message
|
|
283
|
-
// it appends to the resident history carries no scope of its own. A
|
|
284
|
-
// conversation resident under one actor would go on sending that array to
|
|
285
|
-
// the model, image included, while a reload would have filtered it out.
|
|
286
|
-
const live = liveConversation("Chat keep cross trust");
|
|
287
|
-
// Scope the resident history for the conversation's own actor.
|
|
288
|
-
await live.activeConversation.ensureActorScopedHistory();
|
|
289
|
-
const reload = spyOn(Conversation.prototype, "loadFromDb");
|
|
290
|
-
try {
|
|
291
|
-
const attachmentId = await uploadFrame("cross-trust.png");
|
|
292
|
-
// A principal no guardian binding names, which the vellum-channel
|
|
293
|
-
// resolver fails closed to `unknown`: not the class this history holds.
|
|
294
|
-
expect(
|
|
295
|
-
await persist(
|
|
296
|
-
live.id,
|
|
297
|
-
{ attachmentId },
|
|
298
|
-
{ "x-vellum-actor-principal-id": "actor-not-bound" },
|
|
299
|
-
),
|
|
300
|
-
).toMatchObject({ persisted: true });
|
|
301
|
-
|
|
302
|
-
await live.activeConversation.ensureActorScopedHistory();
|
|
303
|
-
|
|
304
|
-
// Reloaded and re-filtered rather than reusing the array the frame was
|
|
305
|
-
// appended to.
|
|
306
|
-
expect(reload).toHaveBeenCalled();
|
|
307
|
-
} finally {
|
|
308
|
-
reload.mockRestore();
|
|
309
|
-
live.dispose();
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
test("a frame from the resident actor does not force a reload", async () => {
|
|
314
|
-
// The control on the check above. Frames arrive on a camera's cadence, so
|
|
315
|
-
// a reload apiece is a real cost and only a differing scope earns one.
|
|
316
|
-
const live = liveConversation("Chat keep same trust");
|
|
317
|
-
await live.activeConversation.ensureActorScopedHistory();
|
|
318
|
-
const reload = spyOn(Conversation.prototype, "loadFromDb");
|
|
319
|
-
try {
|
|
320
|
-
const attachmentId = await uploadFrame("same-trust.png");
|
|
321
|
-
// No actor header, which the resolver reads as the guardian: the class
|
|
322
|
-
// the resident history is already scoped for.
|
|
323
|
-
expect(await persist(live.id, { attachmentId })).toMatchObject({
|
|
324
|
-
persisted: true,
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
await live.activeConversation.ensureActorScopedHistory();
|
|
328
|
-
|
|
329
|
-
expect(reload).not.toHaveBeenCalled();
|
|
330
|
-
} finally {
|
|
331
|
-
reload.mockRestore();
|
|
332
|
-
live.dispose();
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
test("reports a frame whose attachment does not resolve", async () => {
|
|
337
|
-
const live = liveConversation("Chat keep missing attachment");
|
|
338
|
-
try {
|
|
339
|
-
expect(await persist(live.id, { attachmentId: "att-missing" })).toEqual({
|
|
340
|
-
persisted: false,
|
|
341
|
-
});
|
|
342
|
-
expect(getMessages(live.id)).toHaveLength(0);
|
|
343
|
-
} finally {
|
|
344
|
-
live.dispose();
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
test("two overlapping keeps write one at a time", async () => {
|
|
349
|
-
// The processing flag is a boolean rather than a counted lock, so two
|
|
350
|
-
// persists in flight at once would both read it free and both take it.
|
|
351
|
-
const live = liveConversation("Chat keep serialized");
|
|
352
|
-
try {
|
|
353
|
-
const first = await uploadFrame("first.png");
|
|
354
|
-
const second = await uploadFrame("second.png");
|
|
355
|
-
|
|
356
|
-
live.activeConversation.setProcessing(true);
|
|
357
|
-
const firstKeep = persist(live.id, { attachmentId: first });
|
|
358
|
-
// Long enough for the first keep to reach the idle wait, so the second
|
|
359
|
-
// queues behind a job that has already begun rather than replacing it.
|
|
360
|
-
await sleep(30);
|
|
361
|
-
const secondKeep = persist(live.id, { attachmentId: second });
|
|
362
|
-
await sleep(30);
|
|
363
|
-
live.activeConversation.setProcessing(false);
|
|
364
|
-
|
|
365
|
-
expect(await firstKeep).toMatchObject({ persisted: true });
|
|
366
|
-
expect(await secondKeep).toMatchObject({ persisted: true });
|
|
367
|
-
expect(getMessages(live.id)).toHaveLength(2);
|
|
368
|
-
} finally {
|
|
369
|
-
live.dispose();
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
test("a newer keep replaces one still waiting, and its upload is reclaimed", async () => {
|
|
374
|
-
// What bounds the chain: keeps arrive every few seconds while each job can
|
|
375
|
-
// wait out a turn for far longer. The displaced upload is the daemon's to
|
|
376
|
-
// collect, because the client's own abandon-delete fires on a refused
|
|
377
|
-
// send and this send was accepted.
|
|
378
|
-
const live = liveConversation("Chat keep superseded");
|
|
379
|
-
try {
|
|
380
|
-
const running = await uploadFrame("running.png");
|
|
381
|
-
const stale = await uploadFrame("stale.png");
|
|
382
|
-
const newest = await uploadFrame("newest.png");
|
|
383
|
-
|
|
384
|
-
live.activeConversation.setProcessing(true);
|
|
385
|
-
const runningKeep = persist(live.id, { attachmentId: running });
|
|
386
|
-
await sleep(30);
|
|
387
|
-
const staleKeep = persist(live.id, { attachmentId: stale });
|
|
388
|
-
const newestKeep = persist(live.id, { attachmentId: newest });
|
|
389
|
-
await sleep(30);
|
|
390
|
-
live.activeConversation.setProcessing(false);
|
|
391
|
-
|
|
392
|
-
expect(await runningKeep).toMatchObject({ persisted: true });
|
|
393
|
-
expect(await staleKeep).toEqual({ persisted: false });
|
|
394
|
-
expect(await newestKeep).toMatchObject({ persisted: true });
|
|
395
|
-
|
|
396
|
-
expect(getMessages(live.id)).toHaveLength(2);
|
|
397
|
-
expect(frameStored(stale)).toBe(false);
|
|
398
|
-
expect(frameStored(running)).toBe(true);
|
|
399
|
-
expect(frameStored(newest)).toBe(true);
|
|
400
|
-
} finally {
|
|
401
|
-
live.dispose();
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
test("a deletion is final for a keep still queued behind another", async () => {
|
|
406
|
-
// The route's 404 speaks only for the moment it ran. A keep queued behind
|
|
407
|
-
// another one starts later, so the job re-reads the conversation before it
|
|
408
|
-
// touches anything: the persist reaches it through
|
|
409
|
-
// `getOrCreateConversation`, which writes the row back for an id it finds
|
|
410
|
-
// missing, and a deleted conversation must not return carrying nothing but
|
|
411
|
-
// camera frames.
|
|
412
|
-
const restoreWait = _setProcessingWaitMsForTests(150);
|
|
413
|
-
const live = liveConversation("Chat keep deleted mid-queue");
|
|
414
|
-
const holder = await uploadFrame("holder.png");
|
|
415
|
-
const queued = await uploadFrame("queued.png");
|
|
416
|
-
try {
|
|
417
|
-
// The first keep holds the chain by waiting out a turn that never ends,
|
|
418
|
-
// so the second is still queued and has touched nothing.
|
|
419
|
-
live.activeConversation.setProcessing(true);
|
|
420
|
-
const holderKeep = persist(live.id, { attachmentId: holder });
|
|
421
|
-
await sleep(30);
|
|
422
|
-
const queuedKeep = persist(live.id, { attachmentId: queued });
|
|
423
|
-
|
|
424
|
-
deleteEverywhere(live.id);
|
|
425
|
-
const countAfterDelete = conversationCount();
|
|
426
|
-
|
|
427
|
-
expect(await holderKeep).toEqual({ persisted: false });
|
|
428
|
-
expect(await queuedKeep).toEqual({ persisted: false });
|
|
429
|
-
|
|
430
|
-
expect(getConversation(live.id)).toBeNull();
|
|
431
|
-
expect(conversationCount()).toBe(countAfterDelete);
|
|
432
|
-
expect(getMessages(live.id)).toHaveLength(0);
|
|
433
|
-
expect(frameStored(queued)).toBe(false);
|
|
434
|
-
} finally {
|
|
435
|
-
_setProcessingWaitMsForTests(restoreWait);
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
test("a frame does not land in a conversation replaced while the actor resolves", async () => {
|
|
440
|
-
// The 404 gate is where the frame is accepted, and resolving the request's
|
|
441
|
-
// actor is awaited after it. A delete and recreate under this id inside
|
|
442
|
-
// that await leaves a row the gate never saw, and a persist that read the
|
|
443
|
-
// id for itself afterwards would take the replacement for the conversation
|
|
444
|
-
// the client addressed.
|
|
445
|
-
const live = liveConversation("Chat keep replaced mid-trust");
|
|
446
|
-
try {
|
|
447
|
-
const frame = await uploadFrame("mid-trust.png");
|
|
448
|
-
|
|
449
|
-
duringTrustResolution = () => {
|
|
450
|
-
deleteConversationRows(live.id);
|
|
451
|
-
createConversation({ id: live.id, title: "Recreated" });
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
expect(await persist(live.id, { attachmentId: frame })).toEqual({
|
|
455
|
-
persisted: false,
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
expect(getMessages(live.id)).toHaveLength(0);
|
|
459
|
-
// Nothing else would ever collect it: the client's abandon-delete fires
|
|
460
|
-
// on a refused send, and this send was accepted.
|
|
461
|
-
expect(frameStored(frame)).toBe(false);
|
|
462
|
-
} finally {
|
|
463
|
-
duringTrustResolution = null;
|
|
464
|
-
live.dispose();
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
test("reports a keep that outwaited the turn ahead of it", async () => {
|
|
469
|
-
const restoreWait = _setProcessingWaitMsForTests(120);
|
|
470
|
-
const live = liveConversation("Chat keep wait timeout");
|
|
471
|
-
try {
|
|
472
|
-
const frame = await uploadFrame("timed-out.png");
|
|
473
|
-
|
|
474
|
-
live.activeConversation.setProcessing(true);
|
|
475
|
-
expect(await persist(live.id, { attachmentId: frame })).toEqual({
|
|
476
|
-
persisted: false,
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
expect(frameStored(frame)).toBe(false);
|
|
480
|
-
expect(getMessages(live.id)).toHaveLength(0);
|
|
481
|
-
} finally {
|
|
482
|
-
live.activeConversation.setProcessing(false);
|
|
483
|
-
live.dispose();
|
|
484
|
-
_setProcessingWaitMsForTests(restoreWait);
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
});
|