@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
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
* - NO blind fallback to a neighbouring turn/message;
|
|
11
11
|
* - the fork fallback: a turn inherited from a fork resolves to the parent's
|
|
12
12
|
* rows via the message's `forkSourceMessageId` back-pointer;
|
|
13
|
-
* -
|
|
13
|
+
* - a pool-only turn (a pool row, no selection rows: the selector rejected
|
|
14
|
+
* everything or the gate hard-skipped) resolves through the pool's
|
|
15
|
+
* stamped message id, with the same fork walk, to an empty selection
|
|
16
|
+
* carrying the pool;
|
|
17
|
+
* - source/section mapping and the rendered `<memory>` block;
|
|
14
18
|
* - `live` reflects the config gate.
|
|
15
19
|
*
|
|
16
20
|
* `mock.module` is process-global and leaks into sibling files in a
|
|
@@ -27,6 +31,12 @@ import { drizzle } from "drizzle-orm/bun-sqlite";
|
|
|
27
31
|
import { setConfig } from "../../../../../__tests__/helpers/set-config.js";
|
|
28
32
|
import { ensureMemoryV3SelectionsSchema } from "../../../../../persistence/migrations/338-move-memory-v3-selections-to-memory-db.js";
|
|
29
33
|
import * as schema from "../../../../../persistence/schema/index.js";
|
|
34
|
+
import {
|
|
35
|
+
ensureMemoryV3PoolsSchema,
|
|
36
|
+
ensureMemoryV3SelectionsSectionKeyOnce,
|
|
37
|
+
} from "../plugin-schema.js";
|
|
38
|
+
import type { PoolCandidateRecord, PoolLane } from "../pool-log-store.js";
|
|
39
|
+
import { type Section, sectionKey } from "../types.js";
|
|
30
40
|
|
|
31
41
|
const realFlags = {
|
|
32
42
|
...(await import("../../../../../config/assistant-feature-flags.js")),
|
|
@@ -35,6 +45,7 @@ const realDb = {
|
|
|
35
45
|
...(await import("../../../../../persistence/db-connection.js")),
|
|
36
46
|
};
|
|
37
47
|
const realPageContent = { ...(await import("../page-content.js")) };
|
|
48
|
+
const realPageStore = { ...(await import("../../substrate/page-store.js")) };
|
|
38
49
|
|
|
39
50
|
let storeMockActive = false;
|
|
40
51
|
let liveEnabled = false;
|
|
@@ -57,25 +68,44 @@ function makeDb() {
|
|
|
57
68
|
testSqlite.exec(`CREATE TABLE messages (id TEXT PRIMARY KEY, metadata TEXT)`);
|
|
58
69
|
memorySqlite = new Database(":memory:");
|
|
59
70
|
ensureMemoryV3SelectionsSchema(memorySqlite);
|
|
71
|
+
// The plugin's own column on the relocated table, so `seed` can write keys.
|
|
72
|
+
ensureMemoryV3SelectionsSectionKeyOnce(memorySqlite);
|
|
73
|
+
ensureMemoryV3PoolsSchema(memorySqlite);
|
|
60
74
|
return db;
|
|
61
75
|
}
|
|
62
76
|
|
|
77
|
+
/** One pooled candidate in the persisted shape `writePool` stores. */
|
|
78
|
+
function candidate(
|
|
79
|
+
slug: string,
|
|
80
|
+
lane: PoolLane,
|
|
81
|
+
chosen: boolean,
|
|
82
|
+
section?: { title: string },
|
|
83
|
+
): PoolCandidateRecord {
|
|
84
|
+
return {
|
|
85
|
+
slug,
|
|
86
|
+
lane,
|
|
87
|
+
section_title: section?.title ?? null,
|
|
88
|
+
section_key: section?.title ?? null,
|
|
89
|
+
chosen,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
63
93
|
function seed(
|
|
64
94
|
conversationId: string,
|
|
65
95
|
turn: number,
|
|
66
96
|
rows: Array<{
|
|
67
97
|
slug: string;
|
|
68
98
|
source: string;
|
|
69
|
-
pinned?: boolean;
|
|
70
99
|
sectionOrdinal?: number;
|
|
71
100
|
sectionTitle?: string;
|
|
101
|
+
sectionKey?: string;
|
|
72
102
|
}>,
|
|
73
103
|
messageId: string | null = null,
|
|
74
104
|
): void {
|
|
75
105
|
const stmt = memorySqlite.query(
|
|
76
106
|
`INSERT INTO memory_v3_selections
|
|
77
|
-
(conversation_id, turn, slug, source,
|
|
78
|
-
message_id, section_ordinal, section_title)
|
|
107
|
+
(conversation_id, turn, slug, source, created_at,
|
|
108
|
+
message_id, section_ordinal, section_title, section_key)
|
|
79
109
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
80
110
|
);
|
|
81
111
|
for (const r of rows) {
|
|
@@ -84,11 +114,11 @@ function seed(
|
|
|
84
114
|
turn,
|
|
85
115
|
r.slug,
|
|
86
116
|
r.source,
|
|
87
|
-
r.pinned ? 1 : 0,
|
|
88
117
|
1000 + turn,
|
|
89
118
|
messageId,
|
|
90
119
|
r.sectionOrdinal ?? null,
|
|
91
120
|
r.sectionTitle ?? null,
|
|
121
|
+
r.sectionKey ?? null,
|
|
92
122
|
);
|
|
93
123
|
}
|
|
94
124
|
}
|
|
@@ -102,6 +132,21 @@ function seedMessage(id: string, forkSourceMessageId?: string): void {
|
|
|
102
132
|
.run(id, metadata);
|
|
103
133
|
}
|
|
104
134
|
|
|
135
|
+
/** Stamp a pool row with its assistant message id, as the turn-end backfill
|
|
136
|
+
* does for the pool and selection rows together. */
|
|
137
|
+
function stampPool(
|
|
138
|
+
conversationId: string,
|
|
139
|
+
turn: number,
|
|
140
|
+
messageId: string,
|
|
141
|
+
): void {
|
|
142
|
+
memorySqlite
|
|
143
|
+
.query(
|
|
144
|
+
`UPDATE memory_v3_pools SET message_id = ?
|
|
145
|
+
WHERE conversation_id = ? AND turn = ?`,
|
|
146
|
+
)
|
|
147
|
+
.run(messageId, conversationId, turn);
|
|
148
|
+
}
|
|
149
|
+
|
|
105
150
|
mock.module("../../../../../config/assistant-feature-flags.js", () => ({
|
|
106
151
|
...realFlags,
|
|
107
152
|
isAssistantFeatureFlagEnabled: (key: string, config: unknown) =>
|
|
@@ -132,18 +177,31 @@ mock.module("../../../../../persistence/db-connection.js", () => ({
|
|
|
132
177
|
: realDb.getMemorySqlite(),
|
|
133
178
|
}));
|
|
134
179
|
|
|
180
|
+
// Bodies of the pages the inspector reconstructs matched sections from; a
|
|
181
|
+
// slug with no entry reads from disk, where this unit's pages do not exist.
|
|
182
|
+
const pageBodies = new Map<string, string>();
|
|
183
|
+
mock.module("../../substrate/page-store.js", () => ({
|
|
184
|
+
...realPageStore,
|
|
185
|
+
readPage: async (workspaceDir: string, slug: string) =>
|
|
186
|
+
storeMockActive && pageBodies.has(slug)
|
|
187
|
+
? ({ body: pageBodies.get(slug)! } as unknown as Awaited<
|
|
188
|
+
ReturnType<typeof realPageStore.readPage>
|
|
189
|
+
>)
|
|
190
|
+
: realPageStore.readPage(workspaceDir, slug),
|
|
191
|
+
}));
|
|
192
|
+
|
|
135
193
|
mock.module("../page-content.js", () => ({
|
|
136
194
|
...realPageContent,
|
|
137
|
-
// The inspector store reconstructs each selection's matched section from
|
|
138
|
-
// current page
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
|
|
195
|
+
// The inspector store reconstructs each selection's matched section from
|
|
196
|
+
// the current page and renders that section, or the lead when the row
|
|
197
|
+
// resolved to none. The mock stands in for that render and names the
|
|
198
|
+
// section it was handed by key, so a repeat or chunk is told apart.
|
|
199
|
+
renderV3InjectionEntry: async (slug: string, section?: Section) =>
|
|
142
200
|
storeMockActive
|
|
143
201
|
? section
|
|
144
|
-
?
|
|
145
|
-
:
|
|
146
|
-
: realPageContent.
|
|
202
|
+
? `# memory/concepts/${slug}.md § ${sectionKey(section)}\nsection[${sectionKey(section)}] for ${slug}`
|
|
203
|
+
: `# memory/concepts/${slug}.md\nbody for ${slug}`
|
|
204
|
+
: realPageContent.renderV3InjectionEntry(slug, undefined),
|
|
147
205
|
}));
|
|
148
206
|
|
|
149
207
|
const {
|
|
@@ -151,6 +209,9 @@ const {
|
|
|
151
209
|
getMemoryV3SelectionForInspectorByMessageIds,
|
|
152
210
|
summarizeSelections,
|
|
153
211
|
} = await import("../selection-log-store.js");
|
|
212
|
+
// The pool writer resolves the same stubbed memory connection, so tests seed
|
|
213
|
+
// pool rows through it and read them back through the inspector store.
|
|
214
|
+
const { writePool } = await import("../pool-log-store.js");
|
|
154
215
|
|
|
155
216
|
beforeEach(() => {
|
|
156
217
|
storeMockActive = true;
|
|
@@ -159,6 +220,7 @@ beforeEach(() => {
|
|
|
159
220
|
// The inspector's `live` flag comes from `isMemoryV3Live(getConfig())`,
|
|
160
221
|
// which reads `memory.v3.live` — seed it for real.
|
|
161
222
|
setConfig("memory", { v3: { live: false } });
|
|
223
|
+
pageBodies.clear();
|
|
162
224
|
testDb = makeDb();
|
|
163
225
|
});
|
|
164
226
|
|
|
@@ -196,14 +258,14 @@ describe("getMemoryV3SelectionForInspector", () => {
|
|
|
196
258
|
expect(await getMemoryV3SelectionForInspector("conv-3", 3)).toBeNull();
|
|
197
259
|
});
|
|
198
260
|
|
|
199
|
-
test("maps source/
|
|
261
|
+
test("maps source/section and renders the <memory> block", async () => {
|
|
200
262
|
// The second row carries a retired free-text source label (the column is
|
|
201
263
|
// permissive); the inspector passes it through verbatim. Neither row has a
|
|
202
264
|
// matched section, so section fields are null and the block falls back to
|
|
203
|
-
//
|
|
265
|
+
// each page's lead.
|
|
204
266
|
seed("conv-4", 1, [
|
|
205
|
-
{ slug: "domain-a/page-1", source: "edge"
|
|
206
|
-
{ slug: "domain-b/page-2", source: "legacy-carry"
|
|
267
|
+
{ slug: "domain-a/page-1", source: "edge" },
|
|
268
|
+
{ slug: "domain-b/page-2", source: "legacy-carry" },
|
|
207
269
|
]);
|
|
208
270
|
|
|
209
271
|
const log = await getMemoryV3SelectionForInspector("conv-4", 1);
|
|
@@ -211,14 +273,12 @@ describe("getMemoryV3SelectionForInspector", () => {
|
|
|
211
273
|
{
|
|
212
274
|
slug: "domain-a/page-1",
|
|
213
275
|
source: "edge",
|
|
214
|
-
pinned: true,
|
|
215
276
|
sectionOrdinal: null,
|
|
216
277
|
sectionHeading: null,
|
|
217
278
|
},
|
|
218
279
|
{
|
|
219
280
|
slug: "domain-b/page-2",
|
|
220
281
|
source: "legacy-carry",
|
|
221
|
-
pinned: false,
|
|
222
282
|
sectionOrdinal: null,
|
|
223
283
|
sectionHeading: null,
|
|
224
284
|
},
|
|
@@ -273,14 +333,12 @@ describe("getMemoryV3SelectionForInspectorByMessageIds", () => {
|
|
|
273
333
|
{
|
|
274
334
|
slug: "domain-a/page-1",
|
|
275
335
|
source: "needle",
|
|
276
|
-
pinned: false,
|
|
277
336
|
sectionOrdinal: 2,
|
|
278
337
|
sectionHeading: "Heading A",
|
|
279
338
|
},
|
|
280
339
|
{
|
|
281
340
|
slug: "domain-b/page-2",
|
|
282
341
|
source: "core",
|
|
283
|
-
pinned: false,
|
|
284
342
|
sectionOrdinal: null,
|
|
285
343
|
sectionHeading: null,
|
|
286
344
|
},
|
|
@@ -288,6 +346,214 @@ describe("getMemoryV3SelectionForInspectorByMessageIds", () => {
|
|
|
288
346
|
expect(log?.injectedText).toContain("<memory>");
|
|
289
347
|
});
|
|
290
348
|
|
|
349
|
+
test("includes the turn's candidate pool when one was persisted", async () => {
|
|
350
|
+
seed(
|
|
351
|
+
"conv-m",
|
|
352
|
+
3,
|
|
353
|
+
[
|
|
354
|
+
{ slug: "domain-a/page-1", source: "core" },
|
|
355
|
+
{
|
|
356
|
+
slug: "domain-b/page-2",
|
|
357
|
+
source: "needle",
|
|
358
|
+
sectionOrdinal: 2,
|
|
359
|
+
sectionTitle: "Heading B",
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
"msg-pool",
|
|
363
|
+
);
|
|
364
|
+
// The pool the selector saw: the core card, an unchosen hot card, and the
|
|
365
|
+
// needle line with its matched section. The join is by the selection rows'
|
|
366
|
+
// (conversation, turn), so the pool row needs no message id of its own.
|
|
367
|
+
writePool(memorySqlite, "conv-m", 3, {
|
|
368
|
+
candidates: [
|
|
369
|
+
candidate("domain-a/page-1", "core", true),
|
|
370
|
+
candidate("domain-c/page-9", "hot", false),
|
|
371
|
+
candidate("domain-b/page-2", "needle", true, { title: "Heading B" }),
|
|
372
|
+
],
|
|
373
|
+
pool_size: 3,
|
|
374
|
+
selected_count: 2,
|
|
375
|
+
selector_ran: true,
|
|
376
|
+
});
|
|
377
|
+
// A pool for a neighbouring turn must not bleed in.
|
|
378
|
+
writePool(memorySqlite, "conv-m", 4, {
|
|
379
|
+
candidates: [candidate("other/page", "core", true)],
|
|
380
|
+
pool_size: 1,
|
|
381
|
+
selected_count: 1,
|
|
382
|
+
selector_ran: true,
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
386
|
+
"msg-pool",
|
|
387
|
+
]);
|
|
388
|
+
expect(log?.pool).toEqual({
|
|
389
|
+
poolSize: 3,
|
|
390
|
+
selectedCount: 2,
|
|
391
|
+
selectorRan: true,
|
|
392
|
+
candidates: [
|
|
393
|
+
{
|
|
394
|
+
slug: "domain-a/page-1",
|
|
395
|
+
lane: "core",
|
|
396
|
+
sectionHeading: null,
|
|
397
|
+
sectionKey: null,
|
|
398
|
+
chosen: true,
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
slug: "domain-c/page-9",
|
|
402
|
+
lane: "hot",
|
|
403
|
+
sectionHeading: null,
|
|
404
|
+
sectionKey: null,
|
|
405
|
+
chosen: false,
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
slug: "domain-b/page-2",
|
|
409
|
+
lane: "needle",
|
|
410
|
+
sectionHeading: "Heading B",
|
|
411
|
+
sectionKey: "Heading B",
|
|
412
|
+
chosen: true,
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
// The turn-keyed variant resolves the same pool.
|
|
417
|
+
const byTurn = await getMemoryV3SelectionForInspector("conv-m", 3);
|
|
418
|
+
expect(byTurn?.pool).toEqual(log?.pool);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
test("pool is null for a turn logged before pools were persisted", async () => {
|
|
422
|
+
seed("conv-m", 0, [{ slug: "domain-a/page-1", source: "needle" }], "msg-1");
|
|
423
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds(["msg-1"]);
|
|
424
|
+
expect(log?.selections).toHaveLength(1);
|
|
425
|
+
expect(log?.pool).toBeNull();
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test("resolves the parent's pool for a forked (inherited) turn", async () => {
|
|
429
|
+
seed(
|
|
430
|
+
"conv-parent",
|
|
431
|
+
4,
|
|
432
|
+
[{ slug: "domain-a/page-1", source: "needle" }],
|
|
433
|
+
"parent-msg",
|
|
434
|
+
);
|
|
435
|
+
writePool(memorySqlite, "conv-parent", 4, {
|
|
436
|
+
candidates: [candidate("domain-a/page-1", "needle", true)],
|
|
437
|
+
pool_size: 1,
|
|
438
|
+
selected_count: 1,
|
|
439
|
+
selector_ran: true,
|
|
440
|
+
});
|
|
441
|
+
seedMessage("fork-msg", "parent-msg");
|
|
442
|
+
|
|
443
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
444
|
+
"fork-msg",
|
|
445
|
+
]);
|
|
446
|
+
expect(log?.pool?.candidates.map((c) => c.slug)).toEqual([
|
|
447
|
+
"domain-a/page-1",
|
|
448
|
+
]);
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
test("a pool-only turn resolves through its stamped message id to an empty selection with the pool", async () => {
|
|
452
|
+
// The selector saw two candidates and rejected both: no selection rows,
|
|
453
|
+
// one pool row, stamped at turn end like the selection rows would be.
|
|
454
|
+
writePool(memorySqlite, "conv-m", 5, {
|
|
455
|
+
candidates: [
|
|
456
|
+
candidate("domain-a/page-1", "core", false),
|
|
457
|
+
candidate("domain-b/page-2", "needle", false, { title: "Heading B" }),
|
|
458
|
+
],
|
|
459
|
+
pool_size: 2,
|
|
460
|
+
selected_count: 0,
|
|
461
|
+
selector_ran: true,
|
|
462
|
+
});
|
|
463
|
+
stampPool("conv-m", 5, "msg-rejected");
|
|
464
|
+
// A selection under another message must not be mistaken for this turn.
|
|
465
|
+
seed("conv-m", 6, [{ slug: "domain-c/page-9", source: "hot" }], "msg-6");
|
|
466
|
+
|
|
467
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
468
|
+
"msg-rejected",
|
|
469
|
+
]);
|
|
470
|
+
expect(log).toEqual({
|
|
471
|
+
turn: 5,
|
|
472
|
+
live: false,
|
|
473
|
+
selections: [],
|
|
474
|
+
injectedText: "",
|
|
475
|
+
pool: {
|
|
476
|
+
poolSize: 2,
|
|
477
|
+
selectedCount: 0,
|
|
478
|
+
selectorRan: true,
|
|
479
|
+
candidates: [
|
|
480
|
+
{
|
|
481
|
+
slug: "domain-a/page-1",
|
|
482
|
+
lane: "core",
|
|
483
|
+
sectionHeading: null,
|
|
484
|
+
sectionKey: null,
|
|
485
|
+
chosen: false,
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
slug: "domain-b/page-2",
|
|
489
|
+
lane: "needle",
|
|
490
|
+
sectionHeading: "Heading B",
|
|
491
|
+
sectionKey: "Heading B",
|
|
492
|
+
chosen: false,
|
|
493
|
+
},
|
|
494
|
+
],
|
|
495
|
+
},
|
|
496
|
+
});
|
|
497
|
+
// The turn-keyed variant resolves the same pool-only log.
|
|
498
|
+
expect(await getMemoryV3SelectionForInspector("conv-m", 5)).toEqual(log);
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
test("a hard-skipped turn resolves to an empty selection whose pool records the selector as not run", async () => {
|
|
502
|
+
writePool(memorySqlite, "conv-m", 5, {
|
|
503
|
+
candidates: [],
|
|
504
|
+
pool_size: 0,
|
|
505
|
+
selected_count: 0,
|
|
506
|
+
selector_ran: false,
|
|
507
|
+
});
|
|
508
|
+
stampPool("conv-m", 5, "msg-skipped");
|
|
509
|
+
|
|
510
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
511
|
+
"msg-skipped",
|
|
512
|
+
]);
|
|
513
|
+
expect(log?.selections).toEqual([]);
|
|
514
|
+
expect(log?.injectedText).toBe("");
|
|
515
|
+
expect(log?.pool).toEqual({
|
|
516
|
+
poolSize: 0,
|
|
517
|
+
selectedCount: 0,
|
|
518
|
+
selectorRan: false,
|
|
519
|
+
candidates: [],
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
test("a fork copy of a pool-only turn resolves through the back-pointer walk", async () => {
|
|
524
|
+
writePool(memorySqlite, "conv-parent", 4, {
|
|
525
|
+
candidates: [candidate("domain-a/page-1", "dense", false)],
|
|
526
|
+
pool_size: 1,
|
|
527
|
+
selected_count: 0,
|
|
528
|
+
selector_ran: true,
|
|
529
|
+
});
|
|
530
|
+
stampPool("conv-parent", 4, "parent-msg");
|
|
531
|
+
// A fork of a fork: neither copy carries rows of its own.
|
|
532
|
+
seedMessage("mid-msg", "parent-msg");
|
|
533
|
+
seedMessage("fork2-msg", "mid-msg");
|
|
534
|
+
|
|
535
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
536
|
+
"fork2-msg",
|
|
537
|
+
]);
|
|
538
|
+
expect(log?.turn).toBe(4);
|
|
539
|
+
expect(log?.selections).toEqual([]);
|
|
540
|
+
expect(log?.pool?.candidates.map((c) => c.slug)).toEqual([
|
|
541
|
+
"domain-a/page-1",
|
|
542
|
+
]);
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
test("does not match a pool row that predates the message-id backfill (null message_id)", async () => {
|
|
546
|
+
writePool(memorySqlite, "conv-m", 5, {
|
|
547
|
+
candidates: [],
|
|
548
|
+
pool_size: 0,
|
|
549
|
+
selected_count: 0,
|
|
550
|
+
selector_ran: false,
|
|
551
|
+
}); // message_id null
|
|
552
|
+
expect(
|
|
553
|
+
await getMemoryV3SelectionForInspectorByMessageIds(["any"]),
|
|
554
|
+
).toBeNull();
|
|
555
|
+
});
|
|
556
|
+
|
|
291
557
|
test("returns null for empty message ids and for an unmatched id", async () => {
|
|
292
558
|
seed("conv-m", 0, [{ slug: "domain-a/page-1", source: "needle" }], "msg-1");
|
|
293
559
|
expect(await getMemoryV3SelectionForInspectorByMessageIds([])).toBeNull();
|
|
@@ -388,7 +654,7 @@ describe("summarizeSelections", () => {
|
|
|
388
654
|
]);
|
|
389
655
|
// Turn 2: page-1 re-selected (needle) + page-2 re-surfaced by edge.
|
|
390
656
|
seed("conv-a", 2, [
|
|
391
|
-
{ slug: "domain-a/page-1", source: "needle"
|
|
657
|
+
{ slug: "domain-a/page-1", source: "needle" },
|
|
392
658
|
{ slug: "domain-b/page-2", source: "edge" },
|
|
393
659
|
]);
|
|
394
660
|
// A different conversation must not bleed into the aggregate.
|
|
@@ -406,6 +672,7 @@ describe("summarizeSelections", () => {
|
|
|
406
672
|
span: 0,
|
|
407
673
|
learned: 0,
|
|
408
674
|
entity: 0,
|
|
675
|
+
rare: 0,
|
|
409
676
|
});
|
|
410
677
|
expect(summary.turns).toBe(2);
|
|
411
678
|
// page-1 and page-2 — distinct across the two turns.
|
|
@@ -425,6 +692,7 @@ describe("summarizeSelections", () => {
|
|
|
425
692
|
span: 0,
|
|
426
693
|
learned: 0,
|
|
427
694
|
entity: 0,
|
|
695
|
+
rare: 0,
|
|
428
696
|
},
|
|
429
697
|
turns: 0,
|
|
430
698
|
distinctSlugs: 0,
|
|
@@ -448,6 +716,7 @@ describe("summarizeSelections", () => {
|
|
|
448
716
|
span: 0,
|
|
449
717
|
learned: 0,
|
|
450
718
|
entity: 0,
|
|
719
|
+
rare: 0,
|
|
451
720
|
},
|
|
452
721
|
turns: 0,
|
|
453
722
|
distinctSlugs: 0,
|
|
@@ -471,3 +740,272 @@ describe("summarizeSelections", () => {
|
|
|
471
740
|
expect(summary.distinctSlugs).toBe(2);
|
|
472
741
|
});
|
|
473
742
|
});
|
|
743
|
+
|
|
744
|
+
describe("matched-section reconstruction", () => {
|
|
745
|
+
const page = [
|
|
746
|
+
"Lead.",
|
|
747
|
+
"",
|
|
748
|
+
"## Heading A",
|
|
749
|
+
"",
|
|
750
|
+
"Body A.",
|
|
751
|
+
"",
|
|
752
|
+
"## Heading B",
|
|
753
|
+
"",
|
|
754
|
+
"Body B.",
|
|
755
|
+
].join("\n");
|
|
756
|
+
|
|
757
|
+
const repeated = [
|
|
758
|
+
"Lead.",
|
|
759
|
+
"",
|
|
760
|
+
"## Notes",
|
|
761
|
+
"",
|
|
762
|
+
"First.",
|
|
763
|
+
"",
|
|
764
|
+
"## Notes",
|
|
765
|
+
"",
|
|
766
|
+
"Second.",
|
|
767
|
+
].join("\n");
|
|
768
|
+
|
|
769
|
+
test("a row recorded with a section key resolves to that exact occurrence of a repeated heading, even when its ordinal now points at the other", async () => {
|
|
770
|
+
// The page now: lead (0), "Notes" (1), "Notes" again (2). Both rows were
|
|
771
|
+
// recorded before a section above the headings was removed, so each
|
|
772
|
+
// recorded ordinal now sits on the OTHER occurrence of the title.
|
|
773
|
+
pageBodies.set("domain-a/page-1", repeated);
|
|
774
|
+
seed(
|
|
775
|
+
"conv-k",
|
|
776
|
+
0,
|
|
777
|
+
[
|
|
778
|
+
{
|
|
779
|
+
slug: "domain-a/page-1",
|
|
780
|
+
source: "needle",
|
|
781
|
+
sectionOrdinal: 2,
|
|
782
|
+
sectionTitle: "Notes",
|
|
783
|
+
sectionKey: "Notes",
|
|
784
|
+
},
|
|
785
|
+
],
|
|
786
|
+
"msg-k-1",
|
|
787
|
+
);
|
|
788
|
+
seed(
|
|
789
|
+
"conv-k",
|
|
790
|
+
1,
|
|
791
|
+
[
|
|
792
|
+
{
|
|
793
|
+
slug: "domain-a/page-1",
|
|
794
|
+
source: "needle",
|
|
795
|
+
sectionOrdinal: 1,
|
|
796
|
+
sectionTitle: "Notes",
|
|
797
|
+
sectionKey: "Notes#1",
|
|
798
|
+
},
|
|
799
|
+
],
|
|
800
|
+
"msg-k-2",
|
|
801
|
+
);
|
|
802
|
+
|
|
803
|
+
const first = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
804
|
+
"msg-k-1",
|
|
805
|
+
]);
|
|
806
|
+
expect(first?.injectedText).toContain("section[Notes] for domain-a/page-1");
|
|
807
|
+
expect(first?.injectedText).not.toContain("Notes#1");
|
|
808
|
+
const second = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
809
|
+
"msg-k-2",
|
|
810
|
+
]);
|
|
811
|
+
expect(second?.injectedText).toContain(
|
|
812
|
+
"section[Notes#1] for domain-a/page-1",
|
|
813
|
+
);
|
|
814
|
+
// The wire shape still carries the recorded title and ordinal as logged.
|
|
815
|
+
expect(second?.selections).toEqual([
|
|
816
|
+
{
|
|
817
|
+
slug: "domain-a/page-1",
|
|
818
|
+
source: "needle",
|
|
819
|
+
sectionOrdinal: 1,
|
|
820
|
+
sectionHeading: "Notes",
|
|
821
|
+
},
|
|
822
|
+
]);
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
test("a keyed row whose key is no longer on the page renders the lead rather than another section of that title", async () => {
|
|
826
|
+
// The page kept a single "Notes"; the row names the repeat that was
|
|
827
|
+
// removed. The surviving occurrence is not what was injected.
|
|
828
|
+
pageBodies.set(
|
|
829
|
+
"domain-a/page-1",
|
|
830
|
+
["Lead.", "", "## Notes", "", "Only."].join("\n"),
|
|
831
|
+
);
|
|
832
|
+
seed(
|
|
833
|
+
"conv-k",
|
|
834
|
+
0,
|
|
835
|
+
[
|
|
836
|
+
{
|
|
837
|
+
slug: "domain-a/page-1",
|
|
838
|
+
source: "needle",
|
|
839
|
+
sectionOrdinal: 2,
|
|
840
|
+
sectionTitle: "Notes",
|
|
841
|
+
sectionKey: "Notes#1",
|
|
842
|
+
},
|
|
843
|
+
],
|
|
844
|
+
"msg-k-3",
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds(["msg-k-3"]);
|
|
848
|
+
expect(log?.injectedText).toContain("body for domain-a/page-1");
|
|
849
|
+
expect(log?.injectedText).not.toContain("section[");
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
test("a selections table created without section_key (as migration 338 leaves it) gains the column on the first read", async () => {
|
|
853
|
+
memorySqlite = new Database(":memory:");
|
|
854
|
+
ensureMemoryV3SelectionsSchema(memorySqlite);
|
|
855
|
+
ensureMemoryV3PoolsSchema(memorySqlite);
|
|
856
|
+
memorySqlite
|
|
857
|
+
.query(
|
|
858
|
+
`INSERT INTO memory_v3_selections
|
|
859
|
+
(conversation_id, turn, slug, source, created_at, message_id,
|
|
860
|
+
section_ordinal, section_title)
|
|
861
|
+
VALUES ('conv-l', 0, 'domain-a/page-1', 'needle', 1000, 'msg-l', 1,
|
|
862
|
+
'Heading A')`,
|
|
863
|
+
)
|
|
864
|
+
.run();
|
|
865
|
+
pageBodies.set("domain-a/page-1", page);
|
|
866
|
+
|
|
867
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds(["msg-l"]);
|
|
868
|
+
expect(log?.injectedText).toContain(
|
|
869
|
+
"section[Heading A] for domain-a/page-1",
|
|
870
|
+
);
|
|
871
|
+
expect(
|
|
872
|
+
(
|
|
873
|
+
memorySqlite
|
|
874
|
+
.query(`PRAGMA table_info(memory_v3_selections)`)
|
|
875
|
+
.all() as Array<{ name: string }>
|
|
876
|
+
).map((column) => column.name),
|
|
877
|
+
).toContain("section_key");
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
test("a row recorded without a key resolves by its title first, so a page re-chunked since the turn still renders the section that was injected", async () => {
|
|
881
|
+
// At the turn, "Heading A" sat at ordinal 2; the page has since been
|
|
882
|
+
// edited and "Heading B" holds that ordinal.
|
|
883
|
+
pageBodies.set("domain-a/page-1", page);
|
|
884
|
+
seed(
|
|
885
|
+
"conv-r",
|
|
886
|
+
0,
|
|
887
|
+
[
|
|
888
|
+
{
|
|
889
|
+
slug: "domain-a/page-1",
|
|
890
|
+
source: "needle",
|
|
891
|
+
sectionOrdinal: 2,
|
|
892
|
+
sectionTitle: "Heading A",
|
|
893
|
+
},
|
|
894
|
+
],
|
|
895
|
+
"msg-r-1",
|
|
896
|
+
);
|
|
897
|
+
|
|
898
|
+
const log = await getMemoryV3SelectionForInspectorByMessageIds(["msg-r-1"]);
|
|
899
|
+
expect(log?.injectedText).toContain(
|
|
900
|
+
"section[Heading A] for domain-a/page-1",
|
|
901
|
+
);
|
|
902
|
+
expect(log?.injectedText).not.toContain("Heading B");
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
test("for a row recorded without a key, the ordinal picks among repeats of the title while it still points at one; otherwise the first occurrence", async () => {
|
|
906
|
+
pageBodies.set("domain-a/page-1", repeated);
|
|
907
|
+
seed(
|
|
908
|
+
"conv-r",
|
|
909
|
+
0,
|
|
910
|
+
[
|
|
911
|
+
{
|
|
912
|
+
slug: "domain-a/page-1",
|
|
913
|
+
source: "needle",
|
|
914
|
+
sectionOrdinal: 2,
|
|
915
|
+
sectionTitle: "Notes",
|
|
916
|
+
},
|
|
917
|
+
],
|
|
918
|
+
"msg-r-2",
|
|
919
|
+
);
|
|
920
|
+
seed(
|
|
921
|
+
"conv-r",
|
|
922
|
+
1,
|
|
923
|
+
[
|
|
924
|
+
{
|
|
925
|
+
slug: "domain-a/page-1",
|
|
926
|
+
source: "needle",
|
|
927
|
+
sectionOrdinal: 7,
|
|
928
|
+
sectionTitle: "Notes",
|
|
929
|
+
},
|
|
930
|
+
],
|
|
931
|
+
"msg-r-3",
|
|
932
|
+
);
|
|
933
|
+
|
|
934
|
+
const pointed = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
935
|
+
"msg-r-2",
|
|
936
|
+
]);
|
|
937
|
+
expect(pointed?.injectedText).toContain(
|
|
938
|
+
"section[Notes#1] for domain-a/page-1",
|
|
939
|
+
);
|
|
940
|
+
const drifted = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
941
|
+
"msg-r-3",
|
|
942
|
+
]);
|
|
943
|
+
expect(drifted?.injectedText).toContain(
|
|
944
|
+
"section[Notes] for domain-a/page-1",
|
|
945
|
+
);
|
|
946
|
+
expect(drifted?.injectedText).not.toContain("Notes#1");
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
test("a title no longer on the page renders the lead; a row recorded without a title falls back to its ordinal", async () => {
|
|
950
|
+
pageBodies.set("domain-a/page-1", page);
|
|
951
|
+
seed(
|
|
952
|
+
"conv-r",
|
|
953
|
+
0,
|
|
954
|
+
[
|
|
955
|
+
{
|
|
956
|
+
slug: "domain-a/page-1",
|
|
957
|
+
source: "needle",
|
|
958
|
+
sectionOrdinal: 1,
|
|
959
|
+
sectionTitle: "Gone",
|
|
960
|
+
},
|
|
961
|
+
],
|
|
962
|
+
"msg-r-4",
|
|
963
|
+
);
|
|
964
|
+
seed(
|
|
965
|
+
"conv-r",
|
|
966
|
+
1,
|
|
967
|
+
[{ slug: "domain-a/page-1", source: "needle", sectionOrdinal: 1 }],
|
|
968
|
+
"msg-r-5",
|
|
969
|
+
);
|
|
970
|
+
|
|
971
|
+
const gone = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
972
|
+
"msg-r-4",
|
|
973
|
+
]);
|
|
974
|
+
expect(gone?.injectedText).toContain("body for domain-a/page-1");
|
|
975
|
+
expect(gone?.injectedText).not.toContain("section[");
|
|
976
|
+
const untitled = await getMemoryV3SelectionForInspectorByMessageIds([
|
|
977
|
+
"msg-r-5",
|
|
978
|
+
]);
|
|
979
|
+
expect(untitled?.injectedText).toContain(
|
|
980
|
+
"section[Heading A] for domain-a/page-1",
|
|
981
|
+
);
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
describe("selection reads after a failed section_key ensure", () => {
|
|
986
|
+
test("a selections table whose column ensure failed reads as no v3 diagnostic rather than an error", async () => {
|
|
987
|
+
// A memory database created before the column existed, on storage the
|
|
988
|
+
// ALTER cannot reach: the ensure fails open, so every read that names
|
|
989
|
+
// `section_key` throws, and the inspector must see no v3 diagnostic
|
|
990
|
+
// instead of a failed route.
|
|
991
|
+
memorySqlite = new Database(":memory:");
|
|
992
|
+
ensureMemoryV3SelectionsSchema(memorySqlite);
|
|
993
|
+
memorySqlite
|
|
994
|
+
.query(
|
|
995
|
+
`INSERT INTO memory_v3_selections
|
|
996
|
+
(conversation_id, turn, slug, source, created_at, message_id)
|
|
997
|
+
VALUES (?, ?, ?, ?, ?, ?)`,
|
|
998
|
+
)
|
|
999
|
+
.run("conv-ro", 0, "domain-a/page-1", "needle", 1000, "msg-ro-1");
|
|
1000
|
+
memorySqlite.exec("PRAGMA query_only = ON");
|
|
1001
|
+
|
|
1002
|
+
await expect(
|
|
1003
|
+
getMemoryV3SelectionForInspectorByMessageIds(["msg-ro-1"]),
|
|
1004
|
+
).resolves.toBeNull();
|
|
1005
|
+
await expect(
|
|
1006
|
+
getMemoryV3SelectionForInspector("conv-ro", 0),
|
|
1007
|
+
).resolves.toBeNull();
|
|
1008
|
+
// A read that names no `section_key` still serves.
|
|
1009
|
+
expect(summarizeSelections("conv-ro").turns).toBe(1);
|
|
1010
|
+
});
|
|
1011
|
+
});
|