@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
|
@@ -183,38 +183,6 @@ describe("hasUnclaimedGuardianForm", () => {
|
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
-
describe("resolveFormFromCallback", () => {
|
|
187
|
-
test("passes a writer's own fields through untouched", async () => {
|
|
188
|
-
// The rail is only reusable if a new form's result reaches its caller. A
|
|
189
|
-
// callback that enumerated contact fields would drop everything else.
|
|
190
|
-
const { requestId, settled } = openForm();
|
|
191
|
-
|
|
192
|
-
const { resolveFormFromCallback } =
|
|
193
|
-
await import("../routes/guardian-form-routes.js");
|
|
194
|
-
resolveFormFromCallback({
|
|
195
|
-
body: { requestId, id: "row-7", rows: 3, skipped: false },
|
|
196
|
-
} as never);
|
|
197
|
-
|
|
198
|
-
expect(await settled).toEqual({
|
|
199
|
-
ok: true,
|
|
200
|
-
id: "row-7",
|
|
201
|
-
rows: 3,
|
|
202
|
-
skipped: false,
|
|
203
|
-
} as never);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test("an error makes the outcome a failure", async () => {
|
|
207
|
-
const { requestId, settled } = openForm();
|
|
208
|
-
const { resolveFormFromCallback } =
|
|
209
|
-
await import("../routes/guardian-form-routes.js");
|
|
210
|
-
resolveFormFromCallback({
|
|
211
|
-
body: { requestId, error: "nope", id: "ignored" },
|
|
212
|
-
} as never);
|
|
213
|
-
|
|
214
|
-
expect(await settled).toEqual({ ok: false, error: "nope" });
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
186
|
describe("claiming names the form", () => {
|
|
219
187
|
test("a claim for a different kind is refused", async () => {
|
|
220
188
|
// An id alone does not say which form it belongs to. Without this check a
|
|
@@ -131,6 +131,50 @@ describe("observeHostScreen", () => {
|
|
|
131
131
|
expect(pendingInteractions.getAll()).toHaveLength(0);
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* The user's pick travels as the request's input and nothing else does. The
|
|
136
|
+
* helper reads these two keys, so a target has to arrive as exactly one of
|
|
137
|
+
* them and an absent target as neither.
|
|
138
|
+
*/
|
|
139
|
+
test("carries a window target as the request's input", async () => {
|
|
140
|
+
const observation = observe({
|
|
141
|
+
captureTarget: { kind: "window", windowId: 4211 },
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const request = sentMessages.find((m) => m.type === "host_cu_request");
|
|
145
|
+
expect(request?.input).toEqual({ captureWindowId: 4211 });
|
|
146
|
+
|
|
147
|
+
await postResult({ requestId: sentRequestId(), axTree: "Window [1]" });
|
|
148
|
+
expect(await observation).toEqual({ ok: true, axTree: "Window [1]" });
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The helper diffs each tree against the last one filed under the same
|
|
153
|
+
* key, and the diff names what changed, so a session's key has to be its
|
|
154
|
+
* own or the first read of one session is described against the last one.
|
|
155
|
+
*/
|
|
156
|
+
test("files the request under the caller's state key", async () => {
|
|
157
|
+
const observation = observe({ stateKey: "watch:sess-1" });
|
|
158
|
+
|
|
159
|
+
const request = sentMessages.find((m) => m.type === "host_cu_request");
|
|
160
|
+
expect(request?.conversationId).toBe("watch:sess-1");
|
|
161
|
+
|
|
162
|
+
await postResult({ requestId: sentRequestId(), axTree: "Window [1]" });
|
|
163
|
+
expect(await observation).toEqual({ ok: true, axTree: "Window [1]" });
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("carries a display target as the request's input", async () => {
|
|
167
|
+
const observation = observe({
|
|
168
|
+
captureTarget: { kind: "display", displayId: 69734400 },
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const request = sentMessages.find((m) => m.type === "host_cu_request");
|
|
172
|
+
expect(request?.input).toEqual({ captureDisplayId: 69734400 });
|
|
173
|
+
|
|
174
|
+
await postResult({ requestId: sentRequestId(), axTree: "Window [1]" });
|
|
175
|
+
expect(await observation).toEqual({ ok: true, axTree: "Window [1]" });
|
|
176
|
+
});
|
|
177
|
+
|
|
134
178
|
test("times out cleanly and unregisters the pending interaction", async () => {
|
|
135
179
|
const result = await observe({ timeoutMs: 20 });
|
|
136
180
|
|
|
@@ -12,9 +12,16 @@
|
|
|
12
12
|
* Client-oriented queries (list, find-by-capability) are methods on the hub.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import {
|
|
16
|
+
DESKTOP_PRESENCE_STATES,
|
|
17
|
+
type DesktopPresenceState,
|
|
18
|
+
} from "@vellumai/service-contracts/desktop-presence";
|
|
19
|
+
|
|
15
20
|
import type { AssistantEvent } from "../api/index.js";
|
|
16
21
|
import type { HostProxyCapability, InterfaceId } from "../channels/types.js";
|
|
17
22
|
|
|
23
|
+
export { DESKTOP_PRESENCE_STATES, type DesktopPresenceState };
|
|
24
|
+
|
|
18
25
|
// ---------------------------------------------------------------------------
|
|
19
26
|
// Message type → capability inference
|
|
20
27
|
// ---------------------------------------------------------------------------
|
|
@@ -95,14 +102,6 @@ interface BaseSubscriberEntry {
|
|
|
95
102
|
connectionId: string;
|
|
96
103
|
}
|
|
97
104
|
|
|
98
|
-
/**
|
|
99
|
-
* The presence states a desktop client may report. Single runtime source: the
|
|
100
|
-
* stored type and the route's wire enum both derive from this tuple.
|
|
101
|
-
*/
|
|
102
|
-
export const DESKTOP_PRESENCE_STATES = ["active", "idle", "away"] as const;
|
|
103
|
-
|
|
104
|
-
export type DesktopPresenceState = (typeof DESKTOP_PRESENCE_STATES)[number];
|
|
105
|
-
|
|
106
105
|
export interface ClientPresence {
|
|
107
106
|
state: DesktopPresenceState;
|
|
108
107
|
/** When the daemon last heard from the client. Drives staleness. */
|
|
@@ -743,7 +742,13 @@ export function broadcastMessage(
|
|
|
743
742
|
const targetInterfaceId = options?.targetInterfaceId;
|
|
744
743
|
|
|
745
744
|
const event = buildAssistantEvent(msg, resolvedConversationId);
|
|
746
|
-
|
|
745
|
+
// A reconnect can overlap an older executor with the same device ID.
|
|
746
|
+
// Filter at delivery too, not only when HostCuProxy resolves its target.
|
|
747
|
+
const targetCapability =
|
|
748
|
+
msg.type === "host_cu_request" &&
|
|
749
|
+
Object.hasOwn(msg.input, "capture_window_id")
|
|
750
|
+
? "host_cu_window_capture"
|
|
751
|
+
: capabilityForMessageType(msg.type);
|
|
747
752
|
// Self-echo suppression: a `sync_changed` carrying an `originClientId`
|
|
748
753
|
// means a specific client just mutated the resource. The hub must not
|
|
749
754
|
// re-deliver the invalidation to that client — it already updated its
|
|
@@ -73,8 +73,7 @@ describe("route policy coverage", () => {
|
|
|
73
73
|
// returned allowed). Migration preserves behavior. Triage these
|
|
74
74
|
// and assign real policies in a follow-up PR:
|
|
75
75
|
// - PATCH/DELETE documents/:id/comments/:commentId
|
|
76
|
-
// - integrations/a2a/
|
|
77
|
-
// - integrations/vercel/config
|
|
76
|
+
// - integrations/a2a/invite/accept
|
|
78
77
|
const INTENTIONALLY_UNPROTECTED = new Set([
|
|
79
78
|
// A — design-intentional
|
|
80
79
|
"health",
|
|
@@ -91,9 +90,7 @@ describe("route policy coverage", () => {
|
|
|
91
90
|
"playground/seeded-conversations/:id",
|
|
92
91
|
// C — pre-existing latent unprotected (follow-up audit owed)
|
|
93
92
|
"documents/:id/comments/:commentId",
|
|
94
|
-
"integrations/a2a/config",
|
|
95
93
|
"integrations/a2a/invite/accept",
|
|
96
|
-
"integrations/vercel/config",
|
|
97
94
|
]);
|
|
98
95
|
|
|
99
96
|
const unprotectedFound: string[] = [];
|
|
@@ -297,4 +297,69 @@ describe("ROUTES policy declarations", () => {
|
|
|
297
297
|
expect(r.policy === null || typeof r.policy === "object").toBe(true);
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
|
+
|
|
301
|
+
test.each([
|
|
302
|
+
["integrations_vercel_config_get", "settings.read"],
|
|
303
|
+
["integrations_vercel_config_post", "settings.write"],
|
|
304
|
+
["integrations_vercel_config_delete", "settings.write"],
|
|
305
|
+
["integrations_a2a_config_get", "settings.read"],
|
|
306
|
+
["integrations_a2a_config_post", "settings.write"],
|
|
307
|
+
["integrations_a2a_config_delete", "settings.write"],
|
|
308
|
+
] as const)(
|
|
309
|
+
"%s requires %s and actor principals",
|
|
310
|
+
async (operationId, scope) => {
|
|
311
|
+
const { ROUTES } = await import("../../routes/index.js");
|
|
312
|
+
const route = ROUTES.find((r) => r.operationId === operationId);
|
|
313
|
+
expect(route).toBeDefined();
|
|
314
|
+
expect(route!.policy).not.toBeNull();
|
|
315
|
+
expect(route!.policy!.requiredScopes).toEqual([scope]);
|
|
316
|
+
expect(route!.policy!.allowedPrincipalTypes).toEqual([
|
|
317
|
+
"actor",
|
|
318
|
+
"svc_gateway",
|
|
319
|
+
"svc_daemon",
|
|
320
|
+
"local",
|
|
321
|
+
]);
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
test("vercel config GET denies a chat-only actor and POST denies without settings.write", async () => {
|
|
326
|
+
const { ROUTES } = await import("../../routes/index.js");
|
|
327
|
+
const getRoute = ROUTES.find(
|
|
328
|
+
(r) => r.operationId === "integrations_vercel_config_get",
|
|
329
|
+
);
|
|
330
|
+
const postRoute = ROUTES.find(
|
|
331
|
+
(r) => r.operationId === "integrations_vercel_config_post",
|
|
332
|
+
);
|
|
333
|
+
expect(getRoute?.policy).not.toBeNull();
|
|
334
|
+
expect(postRoute?.policy).not.toBeNull();
|
|
335
|
+
|
|
336
|
+
authDisabled = false;
|
|
337
|
+
const chatOnly = buildTestContext({
|
|
338
|
+
principalType: "actor",
|
|
339
|
+
scopes: ["chat.read", "chat.write"],
|
|
340
|
+
});
|
|
341
|
+
const getDenied = enforcePolicy(
|
|
342
|
+
getRoute!.endpoint,
|
|
343
|
+
getRoute!.policy!,
|
|
344
|
+
chatOnly,
|
|
345
|
+
);
|
|
346
|
+
expect(getDenied).not.toBeNull();
|
|
347
|
+
expect(getDenied!.status).toBe(403);
|
|
348
|
+
|
|
349
|
+
const postDenied = enforcePolicy(
|
|
350
|
+
postRoute!.endpoint,
|
|
351
|
+
postRoute!.policy!,
|
|
352
|
+
chatOnly,
|
|
353
|
+
);
|
|
354
|
+
expect(postDenied).not.toBeNull();
|
|
355
|
+
expect(postDenied!.status).toBe(403);
|
|
356
|
+
|
|
357
|
+
const settingsActor = buildTestContext({
|
|
358
|
+
principalType: "actor",
|
|
359
|
+
scopes: ["settings.write"],
|
|
360
|
+
});
|
|
361
|
+
expect(
|
|
362
|
+
enforcePolicy(postRoute!.endpoint, postRoute!.policy!, settingsActor),
|
|
363
|
+
).toBeNull();
|
|
364
|
+
});
|
|
300
365
|
});
|
|
@@ -73,6 +73,9 @@ export type SameActorOp =
|
|
|
73
73
|
| "host_bash"
|
|
74
74
|
| "host_file"
|
|
75
75
|
| "host_cu"
|
|
76
|
+
// Rides the host_cu transport but is granted separately, so a rejection
|
|
77
|
+
// logged as host_cu would name a capability the caller may well hold.
|
|
78
|
+
| "host_cu_annotate"
|
|
76
79
|
| "host_browser"
|
|
77
80
|
| "host_app_control"
|
|
78
81
|
| "host_transfer"
|
|
@@ -138,9 +141,7 @@ function detectRejection(
|
|
|
138
141
|
? args.hub.getActorPrincipalIdForClient(targetClientId)
|
|
139
142
|
: (args.targetActorPrincipalId ??
|
|
140
143
|
(isHttpAuthDisabled()
|
|
141
|
-
? args.hubForMissingTarget?.getActorPrincipalIdForClient(
|
|
142
|
-
targetClientId,
|
|
143
|
-
)
|
|
144
|
+
? args.hubForMissingTarget?.getActorPrincipalIdForClient(targetClientId)
|
|
144
145
|
: undefined));
|
|
145
146
|
|
|
146
147
|
let reason: RejectionReason | undefined;
|
|
@@ -436,6 +436,16 @@ export async function runBackgroundJob(
|
|
|
436
436
|
jobName: opts.jobName,
|
|
437
437
|
sourceChannel: "assistant_tool",
|
|
438
438
|
sourceContextId: conversationId,
|
|
439
|
+
// Presence suppression is only safe when this conversation already
|
|
440
|
+
// rendered the failure. A carried `turnFailure` is that proof: every
|
|
441
|
+
// path that stamps a failed turn outcome emits `conversation_error`
|
|
442
|
+
// first. The other arrivals here render nothing to duplicate. A
|
|
443
|
+
// timeout leaves `processMessage` running, so the transcript still
|
|
444
|
+
// reads as an in-progress turn, and bootstrap or message-persistence
|
|
445
|
+
// throws never reach the agent loop at all.
|
|
446
|
+
...(turnFailure !== undefined
|
|
447
|
+
? { presenceConversationId: conversationId }
|
|
448
|
+
: {}),
|
|
439
449
|
errorKind,
|
|
440
450
|
errorMessage: error.message,
|
|
441
451
|
...(failureCode !== undefined ? { failureCode } : {}),
|
|
@@ -3,25 +3,15 @@ import type { MessageAudience } from "@vellumai/gateway-client";
|
|
|
3
3
|
import { stripVellumLinks } from "../daemon/assistant-attachments.js";
|
|
4
4
|
import type { RenderedHistoryContent } from "../daemon/handlers/shared.js";
|
|
5
5
|
import { renderHistoryContent } from "../daemon/handlers/shared.js";
|
|
6
|
-
import type { ProviderMessageMetadata } from "../messaging/provider-message-metadata.js";
|
|
7
|
-
import {
|
|
8
|
-
everyPostDeleted,
|
|
9
|
-
readProviderMessageMetadata,
|
|
10
|
-
} from "../messaging/provider-message-metadata.js";
|
|
11
6
|
import { editChannelMessage } from "../messaging/providers/index.js";
|
|
12
|
-
import { providerMetadataOfPreSendSlackEnvelope } from "../messaging/providers/slack/message-metadata.js";
|
|
13
7
|
import { getAttachmentMetadataForMessage } from "../persistence/attachments-store.js";
|
|
14
8
|
import {
|
|
15
9
|
getMessageById,
|
|
16
10
|
getMessages,
|
|
17
11
|
parseMessageMetadata,
|
|
18
|
-
updateMessageMetadata,
|
|
19
12
|
} from "../persistence/conversation-crud.js";
|
|
20
13
|
import { isReactionMessageMetadata } from "../persistence/conversation-types.js";
|
|
21
|
-
import { recordOutboundPost } from "../persistence/delivery-crud.js";
|
|
22
|
-
import { safeParseRecord } from "../util/json.js";
|
|
23
14
|
import { getLogger } from "../util/logger.js";
|
|
24
|
-
import { withSqliteRetry } from "../util/sqlite-retry.js";
|
|
25
15
|
import type { ChannelDeliveryResult } from "./gateway-client.js";
|
|
26
16
|
import { deliverChannelReply } from "./gateway-client.js";
|
|
27
17
|
import type { RuntimeAttachmentMetadata } from "./http-types.js";
|
|
@@ -29,6 +19,7 @@ import {
|
|
|
29
19
|
containsNoResponseMarker,
|
|
30
20
|
stripNoResponseMarkers,
|
|
31
21
|
} from "./no-response.js";
|
|
22
|
+
import { makeSentMessageIdReconciler } from "./outbound-post-reconciliation.js";
|
|
32
23
|
|
|
33
24
|
const log = getLogger("channel-reply-delivery");
|
|
34
25
|
|
|
@@ -538,155 +529,3 @@ export async function deliverReplyViaCallback(
|
|
|
538
529
|
}
|
|
539
530
|
}
|
|
540
531
|
}
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* Build an `onMessageTs` handler that reconciles the persisted assistant
|
|
544
|
-
* row's provider message ids from the transport's authoritative ones. Every
|
|
545
|
-
* channel's reply row carries the neutral envelope (`readReplyEnvelope`
|
|
546
|
-
* names the one pending row that may not yet), so there is one rule:
|
|
547
|
-
* the first reported id becomes `providerMeta.messageId`, the further posts
|
|
548
|
-
* of a reply split at tool boundaries or length limits accumulate under
|
|
549
|
-
* `additionalMessageIds`, and every id lands in the `channel_outbound_posts`
|
|
550
|
-
* index, which is what lets a later reaction or delete naming any of the
|
|
551
|
-
* assistant's posts resolve back to this row.
|
|
552
|
-
*
|
|
553
|
-
* An id the row already names is a redelivery and is skipped. A row
|
|
554
|
-
* persisted with no envelope (e.g. vellum outbound) is left untouched. Every
|
|
555
|
-
* write retries transient SQLite contention (`withSqliteRetry`), because
|
|
556
|
-
* this is the only durable record of the sent message's id and nothing
|
|
557
|
-
* revisits it once the event is marked delivered. Remaining failures are
|
|
558
|
-
* logged and swallowed so a DB error cannot break the outbound delivery
|
|
559
|
-
* itself.
|
|
560
|
-
*/
|
|
561
|
-
function makeSentMessageIdReconciler(
|
|
562
|
-
messageId: string,
|
|
563
|
-
): (ts: string) => Promise<void> {
|
|
564
|
-
return async (ts: string): Promise<void> => {
|
|
565
|
-
if (!ts) {
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
try {
|
|
569
|
-
const row = getMessageById(messageId);
|
|
570
|
-
if (row === null || row.metadata === null) {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
const providerMeta = readReplyEnvelope(safeParseRecord(row.metadata));
|
|
574
|
-
if (
|
|
575
|
-
providerMeta === null ||
|
|
576
|
-
providerIdPatchFor(providerMeta, ts) === null
|
|
577
|
-
) {
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
// The index first: it is the resolution contract, and the insert is
|
|
581
|
-
// conflict-ignoring, so a redelivered id is a no-op there too.
|
|
582
|
-
await withSqliteRetry(
|
|
583
|
-
() =>
|
|
584
|
-
recordOutboundPost({
|
|
585
|
-
sourceChannel: providerMeta.source,
|
|
586
|
-
externalChatId: providerMeta.conversationExternalId,
|
|
587
|
-
providerMessageId: ts,
|
|
588
|
-
messageId,
|
|
589
|
-
conversationId: row.conversationId,
|
|
590
|
-
}),
|
|
591
|
-
{ op: "record_outbound_post", context: { messageId } },
|
|
592
|
-
);
|
|
593
|
-
// The envelope is read and written in one synchronous step, re-read on
|
|
594
|
-
// every attempt, and the delete stage stamps its rows the same way, so
|
|
595
|
-
// neither overwrites the other's patch: bun:sqlite is synchronous and
|
|
596
|
-
// nothing yields between the read and the write.
|
|
597
|
-
await withSqliteRetry(() => stampSentMessageId(messageId, ts), {
|
|
598
|
-
op: "reconcile_sent_message_id",
|
|
599
|
-
context: { messageId },
|
|
600
|
-
});
|
|
601
|
-
} catch (err) {
|
|
602
|
-
log.warn(
|
|
603
|
-
{ err, messageId },
|
|
604
|
-
"Failed to reconcile the sent message id on the outbound assistant row",
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* Record a reported id on the row's envelope. A post just reported is on the
|
|
612
|
-
* channel, so the row-level deletion marker is recomputed: it stays only
|
|
613
|
-
* when every post the row now names, this one included, is already recorded
|
|
614
|
-
* as deleted (a deletion can land between the index write and this stamp,
|
|
615
|
-
* and it can name this very post); a marker left by an earlier state in
|
|
616
|
-
* which every known post was gone is cleared. Synchronous by design; see
|
|
617
|
-
* the caller.
|
|
618
|
-
*/
|
|
619
|
-
function stampSentMessageId(messageId: string, ts: string): void {
|
|
620
|
-
const row = getMessageById(messageId);
|
|
621
|
-
if (row === null || row.metadata === null) {
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
const envelope = safeParseRecord(row.metadata);
|
|
625
|
-
const providerMeta = readReplyEnvelope(envelope);
|
|
626
|
-
if (providerMeta === null) {
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
const patch = providerIdPatchFor(providerMeta, ts);
|
|
630
|
-
if (patch === null) {
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
const posts = [
|
|
634
|
-
...(providerMeta.messageId !== undefined ? [providerMeta.messageId] : []),
|
|
635
|
-
...(providerMeta.additionalMessageIds ?? []),
|
|
636
|
-
ts,
|
|
637
|
-
];
|
|
638
|
-
const { deletedAt, ...rest } = providerMeta;
|
|
639
|
-
updateMessageMetadata(messageId, {
|
|
640
|
-
providerMeta: JSON.stringify({
|
|
641
|
-
...rest,
|
|
642
|
-
...patch,
|
|
643
|
-
...(deletedAt !== undefined &&
|
|
644
|
-
everyPostDeleted(posts, providerMeta.deletedMessageIds)
|
|
645
|
-
? { deletedAt }
|
|
646
|
-
: {}),
|
|
647
|
-
}),
|
|
648
|
-
// A row reserved with Slack's pre-send envelope converges on the neutral
|
|
649
|
-
// one here: `updateMessageMetadata` serializes the merged envelope with
|
|
650
|
-
// `JSON.stringify`, which drops a key set to undefined.
|
|
651
|
-
...(envelope.slackMeta !== undefined ? { slackMeta: undefined } : {}),
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* The envelope a reply row stamps its sent ids onto: the neutral one every
|
|
657
|
-
* reply the daemon reserves carries, or, for a reply still pending from a
|
|
658
|
-
* daemon that reserved Slack replies under Slack's own envelope, the neutral
|
|
659
|
-
* reading of that pre-send envelope (transitional; see
|
|
660
|
-
* `providerMetadataOfPreSendSlackEnvelope`).
|
|
661
|
-
*/
|
|
662
|
-
function readReplyEnvelope(
|
|
663
|
-
envelope: Record<string, unknown>,
|
|
664
|
-
): ProviderMessageMetadata | null {
|
|
665
|
-
return (
|
|
666
|
-
readProviderMessageMetadata(envelope.providerMeta) ??
|
|
667
|
-
providerMetadataOfPreSendSlackEnvelope(envelope)
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Where a newly reported id belongs on the neutral envelope: `messageId` when
|
|
673
|
-
* the row names none yet, otherwise appended to `additionalMessageIds`.
|
|
674
|
-
* `null` when the envelope already names it, which is a redelivery.
|
|
675
|
-
*/
|
|
676
|
-
function providerIdPatchFor(
|
|
677
|
-
providerMeta: ProviderMessageMetadata,
|
|
678
|
-
ts: string,
|
|
679
|
-
): Partial<ProviderMessageMetadata> | null {
|
|
680
|
-
if (providerMeta.messageId === undefined) {
|
|
681
|
-
return { messageId: ts };
|
|
682
|
-
}
|
|
683
|
-
if (
|
|
684
|
-
providerMeta.messageId === ts ||
|
|
685
|
-
providerMeta.additionalMessageIds?.includes(ts)
|
|
686
|
-
) {
|
|
687
|
-
return null;
|
|
688
|
-
}
|
|
689
|
-
return {
|
|
690
|
-
additionalMessageIds: [...(providerMeta.additionalMessageIds ?? []), ts],
|
|
691
|
-
};
|
|
692
|
-
}
|
|
@@ -64,6 +64,16 @@ export type ProcessGuardianDecisionResult =
|
|
|
64
64
|
ok: true;
|
|
65
65
|
applied: false;
|
|
66
66
|
reason: string;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the decision was recorded before the decline. Present only
|
|
69
|
+
* for the two resolver failures: `true` under `resolver_failed` (the
|
|
70
|
+
* decision committed and its follow-through failed), `false` under
|
|
71
|
+
* `decision_not_persisted` (nothing was written; the guardian can
|
|
72
|
+
* retry). A client reads this rather than the reason so an older
|
|
73
|
+
* daemon, which reports both under `resolver_failed` and omits the
|
|
74
|
+
* field, is not misread as having committed.
|
|
75
|
+
*/
|
|
76
|
+
committed?: boolean;
|
|
67
77
|
resolverFailureReason?: string;
|
|
68
78
|
requestId?: string;
|
|
69
79
|
}
|
|
@@ -138,10 +148,19 @@ export async function processGuardianDecision(
|
|
|
138
148
|
// 4. Map the canonical result
|
|
139
149
|
if (decisionResult.applied) {
|
|
140
150
|
if (decisionResult.resolverFailed) {
|
|
151
|
+
// Two failures share the primitive's `resolverFailed` flag and a
|
|
152
|
+
// client has to tell them apart: a decision that committed and whose
|
|
153
|
+
// follow-through then failed is settled (another attempt can only
|
|
154
|
+
// come back already resolved), while one whose persist never landed
|
|
155
|
+
// is still pending and is the guardian's to retry. The primitive
|
|
156
|
+
// marks the difference by omitting `decidedAction` when nothing was
|
|
157
|
+
// committed (see `decisionPersistFailure`).
|
|
158
|
+
const committed = decisionResult.decidedAction !== undefined;
|
|
141
159
|
return {
|
|
142
160
|
ok: true,
|
|
143
161
|
applied: false,
|
|
144
|
-
reason: "resolver_failed",
|
|
162
|
+
reason: committed ? "resolver_failed" : "decision_not_persisted",
|
|
163
|
+
committed,
|
|
145
164
|
resolverFailureReason: decisionResult.resolverFailureReason,
|
|
146
165
|
requestId: decisionResult.requestId,
|
|
147
166
|
};
|
|
@@ -59,6 +59,34 @@ export interface HostObservationFields {
|
|
|
59
59
|
executionError?: string;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* What the desktop client is asked to read: one display, one window, or
|
|
64
|
+
* whatever it reads by default (the main display and the focused window).
|
|
65
|
+
*
|
|
66
|
+
* Ids are the window server's own, `CGDirectDisplayID` and `CGWindowID`, as
|
|
67
|
+
* the client enumerated them. The daemon never interprets them: it carries the
|
|
68
|
+
* user's pick from the surface that offered it to the helper that honours it.
|
|
69
|
+
*/
|
|
70
|
+
export type HostCaptureTarget =
|
|
71
|
+
| { readonly kind: "display"; readonly displayId: number }
|
|
72
|
+
| { readonly kind: "window"; readonly windowId: number };
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The observe request's `input`, from the target. The helper reads these two
|
|
76
|
+
* keys and nothing else, so an absent target is an empty input rather than a
|
|
77
|
+
* key set to nothing.
|
|
78
|
+
*/
|
|
79
|
+
export function captureTargetInput(
|
|
80
|
+
target: HostCaptureTarget | undefined,
|
|
81
|
+
): Record<string, number> {
|
|
82
|
+
if (target === undefined) {
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
return target.kind === "display"
|
|
86
|
+
? { captureDisplayId: target.displayId }
|
|
87
|
+
: { captureWindowId: target.windowId };
|
|
88
|
+
}
|
|
89
|
+
|
|
62
90
|
/** A successful observation, or a structured failure. Never throws. */
|
|
63
91
|
export type HostObservation =
|
|
64
92
|
| ({ ok: true } & HostObservationFields)
|
|
@@ -82,6 +110,23 @@ export interface ObserveHostScreenOptions {
|
|
|
82
110
|
* connected.
|
|
83
111
|
*/
|
|
84
112
|
clientId?: string;
|
|
113
|
+
/**
|
|
114
|
+
* What to read. Defaults to the client's own choice, which is the main
|
|
115
|
+
* display and the focused window. Passed through to the helper as the
|
|
116
|
+
* request's `input`, so a session scoped to one window reads that window
|
|
117
|
+
* even while the user works in another.
|
|
118
|
+
*/
|
|
119
|
+
captureTarget?: HostCaptureTarget;
|
|
120
|
+
/**
|
|
121
|
+
* The key the helper files this request's per-session state under, when
|
|
122
|
+
* the caller has a session. The helper diffs each observation's
|
|
123
|
+
* accessibility tree against the previous one filed under the same key,
|
|
124
|
+
* and the diff names what changed, so two sessions sharing a key would
|
|
125
|
+
* carry text from one into the first observation of the next. A watch
|
|
126
|
+
* session passes its own id; absent is the shared default the ad hoc
|
|
127
|
+
* callers always used.
|
|
128
|
+
*/
|
|
129
|
+
stateKey?: string;
|
|
85
130
|
}
|
|
86
131
|
|
|
87
132
|
/**
|
|
@@ -175,7 +220,11 @@ export async function observeHostScreen(
|
|
|
175
220
|
return;
|
|
176
221
|
}
|
|
177
222
|
broadcastMessage(
|
|
178
|
-
{
|
|
223
|
+
{
|
|
224
|
+
type: "host_cu_cancel",
|
|
225
|
+
requestId,
|
|
226
|
+
conversationId: options.stateKey ?? "",
|
|
227
|
+
},
|
|
179
228
|
undefined,
|
|
180
229
|
{ targetClientId },
|
|
181
230
|
);
|
|
@@ -202,12 +251,13 @@ export async function observeHostScreen(
|
|
|
202
251
|
{
|
|
203
252
|
type: "host_cu_request",
|
|
204
253
|
requestId,
|
|
205
|
-
//
|
|
206
|
-
// state
|
|
207
|
-
// desktop executor sends when no
|
|
208
|
-
|
|
254
|
+
// No conversation is attached; the native helper only uses this
|
|
255
|
+
// to key its per-session state (see `stateKey`), and an empty
|
|
256
|
+
// string is already what the desktop executor sends when no
|
|
257
|
+
// conversation is attached.
|
|
258
|
+
conversationId: options.stateKey ?? "",
|
|
209
259
|
toolName: "computer_use_observe",
|
|
210
|
-
input:
|
|
260
|
+
input: captureTargetInput(options.captureTarget),
|
|
211
261
|
stepNumber: 1,
|
|
212
262
|
},
|
|
213
263
|
undefined,
|