@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
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { describe, expect, test } from "bun:test";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
HOSTED_STEERING_MODEL,
|
|
8
|
+
hostedDirectionsExtraBody,
|
|
9
|
+
mapPersonalitySlidersToDirections,
|
|
10
|
+
parsePersonalitySliderSidecar,
|
|
11
|
+
PERSONALITY_SLIDERS_PATH,
|
|
12
|
+
readPersonalitySliderSidecar,
|
|
13
|
+
resolveHostedDirections,
|
|
14
|
+
} from "./personality-directions.js";
|
|
15
|
+
|
|
16
|
+
function sliders(overrides: Record<string, number>): Record<string, number> {
|
|
17
|
+
return {
|
|
18
|
+
"companion-coworker": 50,
|
|
19
|
+
"genz-boomer": 50,
|
|
20
|
+
"execute-collaborate": 50,
|
|
21
|
+
"playful-serious": 50,
|
|
22
|
+
"polite-unfiltered": 50,
|
|
23
|
+
...overrides,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("mapPersonalitySlidersToDirections", () => {
|
|
28
|
+
test("center and omitted values produce no directions", () => {
|
|
29
|
+
expect(mapPersonalitySlidersToDirections(undefined)).toBeUndefined();
|
|
30
|
+
expect(mapPersonalitySlidersToDirections(null)).toBeUndefined();
|
|
31
|
+
expect(mapPersonalitySlidersToDirections(sliders({}))).toBeUndefined();
|
|
32
|
+
expect(
|
|
33
|
+
mapPersonalitySlidersToDirections(sliders({ "companion-coworker": 50 })),
|
|
34
|
+
).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("maps 0 / 25 / 75 / 100 onto one-sided alphas", () => {
|
|
38
|
+
expect(
|
|
39
|
+
mapPersonalitySlidersToDirections(sliders({ "companion-coworker": 0 })),
|
|
40
|
+
).toEqual({ companion: 1 });
|
|
41
|
+
expect(
|
|
42
|
+
mapPersonalitySlidersToDirections(sliders({ "companion-coworker": 25 })),
|
|
43
|
+
).toEqual({ companion: 0.5 });
|
|
44
|
+
expect(
|
|
45
|
+
mapPersonalitySlidersToDirections(sliders({ "companion-coworker": 75 })),
|
|
46
|
+
).toEqual({ coworker: 0.5 });
|
|
47
|
+
expect(
|
|
48
|
+
mapPersonalitySlidersToDirections(sliders({ "companion-coworker": 100 })),
|
|
49
|
+
).toEqual({ coworker: 1 });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("maps each axis onto its left or right pole", () => {
|
|
53
|
+
expect(
|
|
54
|
+
mapPersonalitySlidersToDirections(
|
|
55
|
+
sliders({
|
|
56
|
+
"companion-coworker": 0,
|
|
57
|
+
"genz-boomer": 100,
|
|
58
|
+
"execute-collaborate": 25,
|
|
59
|
+
"playful-serious": 75,
|
|
60
|
+
"polite-unfiltered": 0,
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
).toEqual({
|
|
64
|
+
companion: 1,
|
|
65
|
+
boomer: 1,
|
|
66
|
+
independent: 0.5,
|
|
67
|
+
serious: 0.5,
|
|
68
|
+
polite: 1,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("clamps out-of-range sliders and ignores non-finite values", () => {
|
|
73
|
+
expect(
|
|
74
|
+
mapPersonalitySlidersToDirections(
|
|
75
|
+
sliders({
|
|
76
|
+
"companion-coworker": -20,
|
|
77
|
+
"genz-boomer": 140,
|
|
78
|
+
"playful-serious": Number.NaN,
|
|
79
|
+
}),
|
|
80
|
+
),
|
|
81
|
+
).toEqual({ companion: 1, boomer: 1 });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("ignores unknown slider ids", () => {
|
|
85
|
+
expect(
|
|
86
|
+
mapPersonalitySlidersToDirections(
|
|
87
|
+
sliders({ "not-an-axis": 0, "companion-coworker": 25 }),
|
|
88
|
+
),
|
|
89
|
+
).toEqual({ companion: 0.5 });
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe("resolveHostedDirections", () => {
|
|
94
|
+
test("attaches directions only for the hosted Qwen snapshot", () => {
|
|
95
|
+
const values = sliders({ "companion-coworker": 0 });
|
|
96
|
+
expect(
|
|
97
|
+
resolveHostedDirections({
|
|
98
|
+
model: HOSTED_STEERING_MODEL,
|
|
99
|
+
sliders: values,
|
|
100
|
+
}),
|
|
101
|
+
).toEqual({ companion: 1 });
|
|
102
|
+
expect(
|
|
103
|
+
resolveHostedDirections({
|
|
104
|
+
model: "claude-opus-4-8",
|
|
105
|
+
sliders: values,
|
|
106
|
+
}),
|
|
107
|
+
).toBeUndefined();
|
|
108
|
+
expect(
|
|
109
|
+
resolveHostedDirections({
|
|
110
|
+
model: HOSTED_STEERING_MODEL,
|
|
111
|
+
sliders: sliders({}),
|
|
112
|
+
}),
|
|
113
|
+
).toBeUndefined();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("personality slider sidecar", () => {
|
|
118
|
+
test("parses a valid sidecar and rejects malformed payloads", () => {
|
|
119
|
+
expect(
|
|
120
|
+
parsePersonalitySliderSidecar(
|
|
121
|
+
JSON.stringify({ "companion-coworker": 25, extra: "nope" }),
|
|
122
|
+
),
|
|
123
|
+
).toEqual({ "companion-coworker": 25 });
|
|
124
|
+
expect(parsePersonalitySliderSidecar("not-json")).toBeNull();
|
|
125
|
+
expect(parsePersonalitySliderSidecar("[]")).toBeNull();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("reads data/personality-sliders.json from the workspace", () => {
|
|
129
|
+
const workspace = mkdtempSync(join(tmpdir(), "personality-sliders-"));
|
|
130
|
+
mkdirSync(join(workspace, "data"));
|
|
131
|
+
writeFileSync(
|
|
132
|
+
join(workspace, PERSONALITY_SLIDERS_PATH),
|
|
133
|
+
JSON.stringify({ "companion-coworker": 0 }),
|
|
134
|
+
);
|
|
135
|
+
expect(readPersonalitySliderSidecar(workspace)).toEqual({
|
|
136
|
+
"companion-coworker": 0,
|
|
137
|
+
});
|
|
138
|
+
expect(readPersonalitySliderSidecar(join(workspace, "missing"))).toBeNull();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("builds extraBody only for hosted Qwen with a nonzero sidecar", () => {
|
|
142
|
+
const workspace = mkdtempSync(join(tmpdir(), "personality-extra-body-"));
|
|
143
|
+
mkdirSync(join(workspace, "data"));
|
|
144
|
+
writeFileSync(
|
|
145
|
+
join(workspace, PERSONALITY_SLIDERS_PATH),
|
|
146
|
+
JSON.stringify({ "companion-coworker": 25 }),
|
|
147
|
+
);
|
|
148
|
+
expect(hostedDirectionsExtraBody(HOSTED_STEERING_MODEL, workspace)).toEqual(
|
|
149
|
+
{
|
|
150
|
+
directions: { companion: 0.5 },
|
|
151
|
+
},
|
|
152
|
+
);
|
|
153
|
+
expect(
|
|
154
|
+
hostedDirectionsExtraBody("claude-opus-4-8", workspace),
|
|
155
|
+
).toBeUndefined();
|
|
156
|
+
expect(
|
|
157
|
+
hostedDirectionsExtraBody(
|
|
158
|
+
HOSTED_STEERING_MODEL,
|
|
159
|
+
join(workspace, "missing"),
|
|
160
|
+
),
|
|
161
|
+
).toBeUndefined();
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map persisted personality sliders onto hosted-inference direction alphas.
|
|
3
|
+
*
|
|
4
|
+
* Sliders are one-sided around center: 50 is no steer. Values below 50
|
|
5
|
+
* activate the left pole; values above 50 activate the right pole. The
|
|
6
|
+
* GPU server never sees slider ids, only `{ pole: alpha }` in `(0, 1]`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { readFileSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
PERSONALITY_DIRECTION_AXES,
|
|
14
|
+
PERSONALITY_SLIDERS_PATH,
|
|
15
|
+
} from "../../api/constants/personality-sliders.js";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
PERSONALITY_DIRECTION_AXES,
|
|
19
|
+
PERSONALITY_SLIDERS_PATH,
|
|
20
|
+
} from "../../api/constants/personality-sliders.js";
|
|
21
|
+
|
|
22
|
+
export const HOSTED_STEERING_MODEL = "qwen/qwen3-8b";
|
|
23
|
+
|
|
24
|
+
export type PersonalityDirections = Record<string, number>;
|
|
25
|
+
|
|
26
|
+
export function isHostedSteeringModel(model: string): boolean {
|
|
27
|
+
return model === HOSTED_STEERING_MODEL;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function clampSlider(value: number): number {
|
|
31
|
+
if (value < 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
if (value > 100) {
|
|
35
|
+
return 100;
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function mapPersonalitySlidersToDirections(
|
|
41
|
+
values: Record<string, number> | null | undefined,
|
|
42
|
+
): PersonalityDirections | undefined {
|
|
43
|
+
if (!values) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const directions: PersonalityDirections = {};
|
|
47
|
+
for (const axis of PERSONALITY_DIRECTION_AXES) {
|
|
48
|
+
const raw = values[axis.sliderId];
|
|
49
|
+
if (typeof raw !== "number" || !Number.isFinite(raw)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const slider = clampSlider(raw);
|
|
53
|
+
if (slider < 50) {
|
|
54
|
+
directions[axis.left] = (50 - slider) / 50;
|
|
55
|
+
} else if (slider > 50) {
|
|
56
|
+
directions[axis.right] = (slider - 50) / 50;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (Object.keys(directions).length === 0) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return directions;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function parsePersonalitySliderSidecar(
|
|
66
|
+
raw: string,
|
|
67
|
+
): Record<string, number> | null {
|
|
68
|
+
let parsed: unknown;
|
|
69
|
+
try {
|
|
70
|
+
parsed = JSON.parse(raw);
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const values: Record<string, number> = {};
|
|
78
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
79
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
80
|
+
values[key] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return values;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function readPersonalitySliderSidecar(
|
|
87
|
+
workspaceDir: string,
|
|
88
|
+
): Record<string, number> | null {
|
|
89
|
+
try {
|
|
90
|
+
return parsePersonalitySliderSidecar(
|
|
91
|
+
readFileSync(join(workspaceDir, PERSONALITY_SLIDERS_PATH), "utf-8"),
|
|
92
|
+
);
|
|
93
|
+
} catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function resolveHostedDirections(args: {
|
|
99
|
+
model: string;
|
|
100
|
+
sliders: Record<string, number> | null | undefined;
|
|
101
|
+
}): PersonalityDirections | undefined {
|
|
102
|
+
if (!isHostedSteeringModel(args.model)) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return mapPersonalitySlidersToDirections(args.sliders);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function hostedDirectionsExtraBody(
|
|
109
|
+
model: string,
|
|
110
|
+
workspaceDir: string,
|
|
111
|
+
): Record<string, unknown> | undefined {
|
|
112
|
+
const directions = resolveHostedDirections({
|
|
113
|
+
model,
|
|
114
|
+
sliders: readPersonalitySliderSidecar(workspaceDir),
|
|
115
|
+
});
|
|
116
|
+
if (!directions) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return { directions };
|
|
120
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Salvage Anthropic-style XML tool calls that some OpenAI-compatible models
|
|
3
|
+
* emit as assistant text instead of native `tool_calls`.
|
|
4
|
+
*
|
|
5
|
+
* Off by default. DeepSeek model ids enable it because those models are
|
|
6
|
+
* trained to emit DSML `invoke` markup and OpenAI-compatible hosts sometimes
|
|
7
|
+
* leave a prefix-stripped variant in `content`. Invokes inside markdown
|
|
8
|
+
* fences stay as text.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { indexOfTag, partialTagSuffix } from "../util/think-tag-stream.js";
|
|
12
|
+
|
|
13
|
+
/** Openers a streaming scanner holds back so XML tool calls are not shown as text. */
|
|
14
|
+
export const XML_TOOL_CALL_OPEN_TAGS = [
|
|
15
|
+
"<invoke",
|
|
16
|
+
"<function_calls",
|
|
17
|
+
"<minimax:tool_call",
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
export interface SalvagedXmlToolCall {
|
|
21
|
+
name: string;
|
|
22
|
+
input: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface XmlToolCallSalvage {
|
|
26
|
+
/** Assistant text with salvaged invoke blocks removed. */
|
|
27
|
+
text: string;
|
|
28
|
+
calls: SalvagedXmlToolCall[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const INVOKE_CLOSE = "</invoke>";
|
|
32
|
+
const NAME_ATTR_RE = /\bname\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i;
|
|
33
|
+
const PARAMETER_CLOSE = "</parameter>";
|
|
34
|
+
|
|
35
|
+
const EMPTY_WRAPPER_RE =
|
|
36
|
+
/<(?:function_calls|minimax:tool_call)>\s*<\/(?:function_calls|minimax:tool_call)>/gi;
|
|
37
|
+
|
|
38
|
+
/** True when the model id is a DeepSeek variant that leaks XML tool calls. */
|
|
39
|
+
export function shouldSalvageXmlToolCalls(
|
|
40
|
+
model: string | null | undefined,
|
|
41
|
+
): boolean {
|
|
42
|
+
return typeof model === "string" && /deepseek/i.test(model);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function salvageXmlToolCalls(
|
|
46
|
+
text: string,
|
|
47
|
+
offeredToolNames: ReadonlySet<string>,
|
|
48
|
+
): XmlToolCallSalvage | null {
|
|
49
|
+
if (!text || offeredToolNames.size === 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const spans: Array<{
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
call: SalvagedXmlToolCall;
|
|
57
|
+
}> = [];
|
|
58
|
+
|
|
59
|
+
const invokeOpenRe = /<invoke\b[^>]*>/gi;
|
|
60
|
+
let openMatch: RegExpExecArray | null = invokeOpenRe.exec(text);
|
|
61
|
+
while (openMatch) {
|
|
62
|
+
const openTag = openMatch[0];
|
|
63
|
+
const rawName = parseNameAttr(openTag);
|
|
64
|
+
const bodyStart = openMatch.index + openTag.length;
|
|
65
|
+
const closeIdx = text.indexOf(INVOKE_CLOSE, bodyStart);
|
|
66
|
+
if (closeIdx < 0) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const canonicalName = rawName
|
|
71
|
+
? resolveOfferedName(rawName, offeredToolNames)
|
|
72
|
+
: null;
|
|
73
|
+
if (canonicalName && !isInsideMarkdownFence(text, openMatch.index)) {
|
|
74
|
+
spans.push({
|
|
75
|
+
start: openMatch.index,
|
|
76
|
+
end: closeIdx + INVOKE_CLOSE.length,
|
|
77
|
+
call: {
|
|
78
|
+
name: canonicalName,
|
|
79
|
+
input: parseParameters(text.slice(bodyStart, closeIdx)),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
invokeOpenRe.lastIndex = closeIdx + INVOKE_CLOSE.length;
|
|
85
|
+
openMatch = invokeOpenRe.exec(text);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (spans.length === 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let leftover = "";
|
|
93
|
+
let cursor = 0;
|
|
94
|
+
for (const span of spans) {
|
|
95
|
+
leftover += text.slice(cursor, span.start);
|
|
96
|
+
cursor = span.end;
|
|
97
|
+
}
|
|
98
|
+
leftover += text.slice(cursor);
|
|
99
|
+
leftover = leftover.replace(EMPTY_WRAPPER_RE, "").trim();
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
text: leftover,
|
|
103
|
+
calls: spans.map((span) => span.call),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Split streamed text so a complete or in-progress XML tool-call opener is
|
|
109
|
+
* held back rather than shown as user-visible content.
|
|
110
|
+
*/
|
|
111
|
+
export function splitXmlToolCallHoldback(buffer: string): {
|
|
112
|
+
visible: string;
|
|
113
|
+
held: string;
|
|
114
|
+
} {
|
|
115
|
+
if (!buffer) {
|
|
116
|
+
return { visible: "", held: "" };
|
|
117
|
+
}
|
|
118
|
+
const hit = indexOfTag(buffer, XML_TOOL_CALL_OPEN_TAGS, false);
|
|
119
|
+
if (hit) {
|
|
120
|
+
return {
|
|
121
|
+
visible: buffer.slice(0, hit.index),
|
|
122
|
+
held: buffer.slice(hit.index),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const partial = partialTagSuffix(buffer, XML_TOOL_CALL_OPEN_TAGS, false);
|
|
126
|
+
if (partial > 0) {
|
|
127
|
+
return {
|
|
128
|
+
visible: buffer.slice(0, buffer.length - partial),
|
|
129
|
+
held: buffer.slice(buffer.length - partial),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return { visible: buffer, held: "" };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function parseNameAttr(tag: string): string | null {
|
|
136
|
+
const match = NAME_ATTR_RE.exec(tag);
|
|
137
|
+
if (!match) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const name = match[1] ?? match[2] ?? match[3];
|
|
141
|
+
return name && name.length > 0 ? name : null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function resolveOfferedName(
|
|
145
|
+
name: string,
|
|
146
|
+
offeredToolNames: ReadonlySet<string>,
|
|
147
|
+
): string | null {
|
|
148
|
+
if (offeredToolNames.has(name)) {
|
|
149
|
+
return name;
|
|
150
|
+
}
|
|
151
|
+
const lower = name.toLowerCase();
|
|
152
|
+
for (const offered of offeredToolNames) {
|
|
153
|
+
if (offered.toLowerCase() === lower) {
|
|
154
|
+
return offered;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function parseParameters(body: string): Record<string, unknown> {
|
|
161
|
+
const input: Record<string, unknown> = {};
|
|
162
|
+
const parameterOpenRe = /<parameter\b[^>]*>/gi;
|
|
163
|
+
let paramMatch: RegExpExecArray | null = parameterOpenRe.exec(body);
|
|
164
|
+
while (paramMatch) {
|
|
165
|
+
const openTag = paramMatch[0];
|
|
166
|
+
const paramName = parseNameAttr(openTag);
|
|
167
|
+
const valueStart = paramMatch.index + openTag.length;
|
|
168
|
+
const closeIdx = body.indexOf(PARAMETER_CLOSE, valueStart);
|
|
169
|
+
if (closeIdx < 0) {
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
if (paramName) {
|
|
173
|
+
input[paramName] = parseParamValue(
|
|
174
|
+
decodeXmlEntities(body.slice(valueStart, closeIdx)),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
parameterOpenRe.lastIndex = closeIdx + PARAMETER_CLOSE.length;
|
|
178
|
+
paramMatch = parameterOpenRe.exec(body);
|
|
179
|
+
}
|
|
180
|
+
return input;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function parseParamValue(raw: string): unknown {
|
|
184
|
+
try {
|
|
185
|
+
return JSON.parse(raw);
|
|
186
|
+
} catch {
|
|
187
|
+
return raw;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function decodeXmlEntities(value: string): string {
|
|
192
|
+
return value
|
|
193
|
+
.replace(/</g, "<")
|
|
194
|
+
.replace(/>/g, ">")
|
|
195
|
+
.replace(/"/g, '"')
|
|
196
|
+
.replace(/'/g, "'")
|
|
197
|
+
.replace(/&/g, "&");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function isInsideMarkdownFence(text: string, index: number): boolean {
|
|
201
|
+
let inside = false;
|
|
202
|
+
let searchFrom = 0;
|
|
203
|
+
while (searchFrom < index) {
|
|
204
|
+
const next = text.indexOf("```", searchFrom);
|
|
205
|
+
if (next < 0 || next >= index) {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
inside = !inside;
|
|
209
|
+
searchFrom = next + 3;
|
|
210
|
+
}
|
|
211
|
+
return inside;
|
|
212
|
+
}
|
package/src/runtime/AGENTS.md
CHANGED
|
@@ -218,10 +218,15 @@ the gateway's Channel Identity Vocabulary, which covers the wire side.
|
|
|
218
218
|
an outbound assistant reply is stamped with a partial envelope at reserve
|
|
219
219
|
time (`buildAssistantChannelMetadata`) whose `messageId` (and, for a reply
|
|
220
220
|
split into several posts, `additionalMessageIds`) the post-send
|
|
221
|
-
reconciliation in `
|
|
221
|
+
reconciliation in `outbound-post-reconciliation.ts` back-fills from the
|
|
222
222
|
transport's delivery results, the assistant's own reaction rows write it
|
|
223
223
|
(`daemon/reaction-record.ts`), and bot-authored Slack backfill rows write
|
|
224
|
-
it.
|
|
224
|
+
it. A notification the pipeline delivers to a channel and a message the
|
|
225
|
+
messaging tool sends to a channel chat are recorded the same way, but
|
|
226
|
+
only after the adapter acknowledges the send (`notifications/delivered-post-record.ts`):
|
|
227
|
+
the row is written with the sent text and the neutral envelope, then the
|
|
228
|
+
same reconciliation stamps the acknowledged id, so a failed or pending
|
|
229
|
+
delivery never has a row. Every channel except Slack writes it for inbound rows too: a reaction
|
|
225
230
|
row carries the whole shape (`inbound-stages/reaction-intercept.ts`), and
|
|
226
231
|
an edit or a delete stamps `editedAt` / `deletedAt` onto whatever the row
|
|
227
232
|
already said about itself through `mergeProviderMessageMetadata`
|
|
@@ -13,18 +13,23 @@
|
|
|
13
13
|
|
|
14
14
|
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
15
15
|
|
|
16
|
+
import { setOverridesForTesting } from "../../__tests__/feature-flag-test-helpers.js";
|
|
16
17
|
import type { TrustContext } from "../../daemon/trust-context-types.js";
|
|
17
18
|
|
|
18
19
|
// ── Module mocks ─────────────────────────────────────────────────────
|
|
19
20
|
|
|
20
21
|
let bootstrapCalls = 0;
|
|
21
22
|
let bootstrapLastArgs: Record<string, unknown> | null = null;
|
|
23
|
+
let bootstrapError: Error | null = null;
|
|
22
24
|
const STUB_CONVERSATION_ID = "conv-test-1";
|
|
23
25
|
|
|
24
26
|
mock.module("../../persistence/conversation-bootstrap.js", () => ({
|
|
25
27
|
bootstrapConversation: (opts: Record<string, unknown>) => {
|
|
26
28
|
bootstrapCalls += 1;
|
|
27
29
|
bootstrapLastArgs = opts;
|
|
30
|
+
if (bootstrapError) {
|
|
31
|
+
throw bootstrapError;
|
|
32
|
+
}
|
|
28
33
|
return { id: STUB_CONVERSATION_ID };
|
|
29
34
|
},
|
|
30
35
|
}));
|
|
@@ -34,10 +39,14 @@ const addMessageCalls: Array<{
|
|
|
34
39
|
role: string;
|
|
35
40
|
content: string;
|
|
36
41
|
}> = [];
|
|
42
|
+
let addMessageError: Error | null = null;
|
|
37
43
|
|
|
38
44
|
mock.module("../../persistence/conversation-crud.js", () => ({
|
|
39
45
|
addMessage: async (conversationId: string, role: string, content: string) => {
|
|
40
46
|
addMessageCalls.push({ conversationId, role, content });
|
|
47
|
+
if (addMessageError) {
|
|
48
|
+
throw addMessageError;
|
|
49
|
+
}
|
|
41
50
|
return { id: `msg-${addMessageCalls.length}` };
|
|
42
51
|
},
|
|
43
52
|
reserveMessage: mock(async () => ({ id: "msg-reserve" })),
|
|
@@ -94,6 +103,20 @@ mock.module("../pre-first-message-gate.js", () => ({
|
|
|
94
103
|
hasReceivedUserMessage: () => preFirstMessageGateOpen,
|
|
95
104
|
}));
|
|
96
105
|
|
|
106
|
+
// Web presence backs the `visibleInSourceNow` attention hint. Recording the
|
|
107
|
+
// arguments lets the suppression tests assert not just the resolved hint but
|
|
108
|
+
// whether presence was consulted at all.
|
|
109
|
+
let webConversationFocused = false;
|
|
110
|
+
const webPresenceArgs: unknown[][] = [];
|
|
111
|
+
const realWebPresence = await import("../web-presence.js");
|
|
112
|
+
mock.module("../web-presence.js", () => ({
|
|
113
|
+
...realWebPresence,
|
|
114
|
+
isWebConversationFocused: (...args: unknown[]) => {
|
|
115
|
+
webPresenceArgs.push(args);
|
|
116
|
+
return webConversationFocused;
|
|
117
|
+
},
|
|
118
|
+
}));
|
|
119
|
+
|
|
97
120
|
// Import after mocks are in place.
|
|
98
121
|
const { runBackgroundJob } = await import("../background-job-runner.js");
|
|
99
122
|
|
|
@@ -120,10 +143,14 @@ function baseOpts(overrides: Record<string, unknown> = {}) {
|
|
|
120
143
|
beforeEach(() => {
|
|
121
144
|
bootstrapCalls = 0;
|
|
122
145
|
bootstrapLastArgs = null;
|
|
146
|
+
bootstrapError = null;
|
|
123
147
|
processMessageCalls.length = 0;
|
|
124
148
|
emitCalls.length = 0;
|
|
125
149
|
addMessageCalls.length = 0;
|
|
150
|
+
addMessageError = null;
|
|
126
151
|
preFirstMessageGateOpen = true;
|
|
152
|
+
webConversationFocused = false;
|
|
153
|
+
webPresenceArgs.length = 0;
|
|
127
154
|
processMessageImpl = async () => ({ messageId: "msg-1" });
|
|
128
155
|
emitImpl = async () => ({
|
|
129
156
|
signalId: "sig-1",
|
|
@@ -532,3 +559,91 @@ describe("runBackgroundJob", () => {
|
|
|
532
559
|
});
|
|
533
560
|
});
|
|
534
561
|
});
|
|
562
|
+
|
|
563
|
+
// Runs last on purpose: it is the only block that turns the presence flag on,
|
|
564
|
+
// so every test above reads the flag in its default off state.
|
|
565
|
+
describe("runBackgroundJob presence suppression opt-in", () => {
|
|
566
|
+
beforeEach(() => {
|
|
567
|
+
setOverridesForTesting({ "activity-presence-suppression": true });
|
|
568
|
+
webConversationFocused = true;
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
function emittedHint(): Record<string, unknown> {
|
|
572
|
+
expect(emitCalls).toHaveLength(1);
|
|
573
|
+
return emitCalls[0].attentionHints as Record<string, unknown>;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
test("a carried turn failure lets a focused conversation suppress the alert", async () => {
|
|
577
|
+
// Every path that stamps a failed turn outcome emits `conversation_error`
|
|
578
|
+
// first, so the focused conversation is already showing this failure.
|
|
579
|
+
processMessageImpl = async () => ({
|
|
580
|
+
messageId: "msg-failed-turn",
|
|
581
|
+
turnFailure: { failureCode: "PROVIDER_BILLING" },
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
const result = await runBackgroundJob(baseOpts());
|
|
585
|
+
|
|
586
|
+
expect(result.ok).toBe(false);
|
|
587
|
+
expect(emittedHint()).toMatchObject({ visibleInSourceNow: true });
|
|
588
|
+
expect(webPresenceArgs).toEqual([[STUB_CONVERSATION_ID]]);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
test("a timeout alerts even when the conversation is focused", async () => {
|
|
592
|
+
// The timeout does not abort `processMessage`, so the transcript still
|
|
593
|
+
// reads as an in-progress turn and there is no rendered error to duplicate.
|
|
594
|
+
processMessageImpl = () => new Promise(() => {});
|
|
595
|
+
|
|
596
|
+
const result = await runBackgroundJob(baseOpts({ timeoutMs: 20 }));
|
|
597
|
+
|
|
598
|
+
expect(result.errorKind).toBe("timeout");
|
|
599
|
+
expect(emittedHint()).toMatchObject({ visibleInSourceNow: false });
|
|
600
|
+
expect(webPresenceArgs).toEqual([]);
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
test("a throw out of processMessage alerts even when the conversation is focused", async () => {
|
|
604
|
+
// Message preparation and persistence run before the agent loop, so a
|
|
605
|
+
// throw from there never reaches the code that renders a failure.
|
|
606
|
+
processMessageImpl = async () => {
|
|
607
|
+
throw new Error("failed to persist the user message");
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
const result = await runBackgroundJob(baseOpts());
|
|
611
|
+
|
|
612
|
+
expect(result.errorKind).toBe("exception");
|
|
613
|
+
expect(result.turnFailure).toBeUndefined();
|
|
614
|
+
expect(emittedHint()).toMatchObject({ visibleInSourceNow: false });
|
|
615
|
+
expect(webPresenceArgs).toEqual([]);
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
test("a sandwich persistence failure alerts even when the conversation is focused", async () => {
|
|
619
|
+
// The conversation exists and is focused, but nothing has run in it yet.
|
|
620
|
+
addMessageError = new Error("sandwich write failed");
|
|
621
|
+
|
|
622
|
+
const result = await runBackgroundJob(
|
|
623
|
+
baseOpts({
|
|
624
|
+
assistantSandwich: {
|
|
625
|
+
preamble: "TRUSTED_PRE",
|
|
626
|
+
content: "UNTRUSTED_PAYLOAD",
|
|
627
|
+
postamble: "TRUSTED_POST",
|
|
628
|
+
},
|
|
629
|
+
}),
|
|
630
|
+
);
|
|
631
|
+
|
|
632
|
+
expect(result.ok).toBe(false);
|
|
633
|
+
expect(result.conversationId).toBe(STUB_CONVERSATION_ID);
|
|
634
|
+
expect(processMessageCalls).toHaveLength(0);
|
|
635
|
+
expect(emittedHint()).toMatchObject({ visibleInSourceNow: false });
|
|
636
|
+
expect(webPresenceArgs).toEqual([]);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
test("a bootstrap failure alerts even when a conversation is focused", async () => {
|
|
640
|
+
bootstrapError = new Error("bootstrap boom");
|
|
641
|
+
|
|
642
|
+
const result = await runBackgroundJob(baseOpts());
|
|
643
|
+
|
|
644
|
+
expect(result.ok).toBe(false);
|
|
645
|
+
expect(result.conversationId).toBe("");
|
|
646
|
+
expect(emittedHint()).toMatchObject({ visibleInSourceNow: false });
|
|
647
|
+
expect(webPresenceArgs).toEqual([]);
|
|
648
|
+
});
|
|
649
|
+
});
|