@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
|
@@ -43,11 +43,11 @@ let nextTurn = 0;
|
|
|
43
43
|
/** Insert one selector call: every slug shares the same (conv, created_at). */
|
|
44
44
|
function seedCall(slugs: string[], createdAt = NOW, conv = "conv-1"): void {
|
|
45
45
|
const stmt = sqlite.query(
|
|
46
|
-
`INSERT INTO memory_v3_selections (conversation_id, turn, slug, source,
|
|
46
|
+
`INSERT INTO memory_v3_selections (conversation_id, turn, slug, source, created_at) VALUES (?, ?, ?, ?, ?)`,
|
|
47
47
|
);
|
|
48
48
|
const turn = nextTurn++;
|
|
49
49
|
for (const slug of slugs) {
|
|
50
|
-
stmt.run(conv, turn, slug, "needle",
|
|
50
|
+
stmt.run(conv, turn, slug, "needle", createdAt);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -4,31 +4,51 @@
|
|
|
4
4
|
* A flag-gated, best-effort self-maintenance pass over the v3 section dense
|
|
5
5
|
* store and the in-memory lanes. It runs six independent stages, in order:
|
|
6
6
|
*
|
|
7
|
-
* 1. **Section re-embed
|
|
7
|
+
* 1. **Section re-embed**: diff the page index by `modifiedAt` against the
|
|
8
8
|
* last successful pass (the high-water mark below), and for every page that
|
|
9
9
|
* is new or edited since then, re-chunk it into sections
|
|
10
10
|
* (`buildSectionIndex`) and refresh its dense points
|
|
11
11
|
* (`deleteSectionsForArticle` + `upsertSections`). This keeps the
|
|
12
12
|
* section-grain Qdrant collection in sync with on-disk page edits so the
|
|
13
|
-
* dense lane retrieves against current content.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* dense lane retrieves against current content. When the chunker version
|
|
14
|
+
* check (`ensureSectionChunkerVersion`) reports a rebuild pending, the
|
|
15
|
+
* pass also re-embeds every capability row the store already holds (the
|
|
16
|
+
* delta never names one), so every stored point carries the current
|
|
17
|
+
* chunk boundaries before the commit releases the dense-read hold. The
|
|
18
|
+
* high-water mark is advanced only after the pass completes with zero
|
|
19
|
+
* failures (and is captured before any potential mtime bumps) so a page
|
|
20
|
+
* is not re-embedded forever, yet a page whose embed failed (and whose
|
|
21
|
+
* sections were therefore left deleted) stays above the mark and is
|
|
22
|
+
* retried next pass. On a version rebuild the commit also waits for
|
|
23
|
+
* every stored capability row: one whose body renders empty in this
|
|
24
|
+
* process (its capability cache unseeded, or the capability gone)
|
|
25
|
+
* keeps its points, so the commit is settled only after the
|
|
26
|
+
* deleted-page prune (stage 3) has had its chance to remove it, and a
|
|
27
|
+
* row still standing holds the commit, and the rebuild marker. The job
|
|
28
|
+
* runs in the memory worker, whose skill and CLI caches are never
|
|
29
|
+
* seeded, so there every stored capability row renders empty and the
|
|
30
|
+
* prune, whose page index lists no capability row, removes them all: a
|
|
31
|
+
* version rebuild in the worker commits over a store with no
|
|
32
|
+
* capability points, which `backfillAllSections` (run in the daemon,
|
|
33
|
+
* caches seeded) restores.
|
|
34
|
+
* 2. **Capability reconcile**: embed capability rows (synthetic skill/CLI
|
|
19
35
|
* slugs) present in the page index but missing from the section store. The
|
|
20
36
|
* re-embed delta above EXCLUDES capability rows (they have `modifiedAt` 0,
|
|
21
|
-
* no mtime to diff), so
|
|
22
|
-
* `backfillAllSections
|
|
23
|
-
* backfill (e.g. a flag-gated skill
|
|
24
|
-
* index but never reaches the dense
|
|
37
|
+
* no mtime to diff), so their only other embedders are the one-time
|
|
38
|
+
* `backfillAllSections` and the version-triggered rebuild. Without this
|
|
39
|
+
* stage a skill enabled AFTER that backfill (e.g. a flag-gated skill
|
|
40
|
+
* flipped on at runtime) lands in the index but never reaches the dense
|
|
41
|
+
* lane. See {@link reconcileCapabilityRows}.
|
|
25
42
|
* 3. **Deleted-page prune** — diff the dense store's stored articles
|
|
26
43
|
* (`listSectionArticles`) against the live page-index slugs and
|
|
27
44
|
* `deleteSectionsForArticle` for any article that is no longer in the
|
|
28
45
|
* index. A deleted page's slug never reaches the re-embed delta selector
|
|
29
46
|
* (it only names live pages), so without this its section points would
|
|
30
47
|
* linger in Qdrant and the dense lane could still surface the deleted page.
|
|
31
|
-
*
|
|
48
|
+
* A capability row the page index lists is never pruned; one it does not
|
|
49
|
+
* list (the capability gone, or this process's capability caches
|
|
50
|
+
* unseeded, which lists none) is pruned like a deleted page, and that
|
|
51
|
+
* removal also settles the version-rebuild commit stage 1 deferred.
|
|
32
52
|
* 4. **Core-set validation** — load the maintainer-curated core set
|
|
33
53
|
* (`memory/core-pages.md`) and report entries whose page no longer exists
|
|
34
54
|
* in the page index (dangling slugs) via the log + outcome. The file is
|
|
@@ -65,10 +85,7 @@ import {
|
|
|
65
85
|
|
|
66
86
|
import { isMemoryV3Live } from "../../../../config/memory-v3-gate.js";
|
|
67
87
|
import type { AssistantConfig } from "../../../../config/types.js";
|
|
68
|
-
import {
|
|
69
|
-
getMemoryCheckpoint,
|
|
70
|
-
setMemoryCheckpoint,
|
|
71
|
-
} from "../../../../persistence/checkpoints.js";
|
|
88
|
+
import { getMemoryCheckpoint } from "../../../../persistence/checkpoints.js";
|
|
72
89
|
import { EmbeddingBackendUnavailableError } from "../../../../persistence/embeddings/embedding-backend.js";
|
|
73
90
|
import { EmbeddingBillingBlockError } from "../../../../persistence/embeddings/embedding-billing-breaker.js";
|
|
74
91
|
import type { MemoryJob } from "../../../../persistence/jobs-store.js";
|
|
@@ -76,17 +93,20 @@ import { executeDeleteManagedSkill } from "../../../../tools/skills/delete-manag
|
|
|
76
93
|
import { embedWithBackend } from "../embeddings.js";
|
|
77
94
|
import { getLogger } from "../logging.js";
|
|
78
95
|
import { getWorkspaceDir } from "../paths.js";
|
|
96
|
+
import { skillSlugFor } from "../substrate/capability-slugs.js";
|
|
79
97
|
import { getPageIndex } from "../substrate/page-index.js";
|
|
80
98
|
import { readPage } from "../substrate/page-store.js";
|
|
81
|
-
import { skillSlugFor } from "../substrate/skill-store.js";
|
|
82
99
|
import { capabilityOrDiskBody, isCapabilitySlug } from "./capabilities.js";
|
|
83
100
|
import { loadCoreSet as realLoadCoreSet } from "./core-set.js";
|
|
84
101
|
import {
|
|
102
|
+
commitSectionEmbedHighWater,
|
|
85
103
|
deleteSectionsForArticle as realDeleteSectionsForArticle,
|
|
104
|
+
ensureSectionChunkerVersion as realEnsureSectionChunkerVersion,
|
|
86
105
|
ensureSectionCollection as realEnsureSectionCollection,
|
|
87
106
|
listSectionArticles as realListSectionArticles,
|
|
88
107
|
MAINTAIN_EMBED_HIGH_WATER_KEY,
|
|
89
108
|
upsertSections as realUpsertSections,
|
|
109
|
+
warmSectionEmbeddings as realWarmSectionEmbeddings,
|
|
90
110
|
} from "./section-dense-store.js";
|
|
91
111
|
import { buildSectionIndex as realBuildSectionIndex } from "./sections.js";
|
|
92
112
|
import { invalidateLanes as realInvalidateLanes } from "./shadow-plugin.js";
|
|
@@ -142,12 +162,31 @@ export interface MaintainJobDeps {
|
|
|
142
162
|
deleteSectionsForArticle: typeof realDeleteSectionsForArticle;
|
|
143
163
|
/** Embed + upsert an article's current sections into the dense store. */
|
|
144
164
|
upsertSections: typeof realUpsertSections;
|
|
165
|
+
/**
|
|
166
|
+
* Warm the embedding cache for many pages' sections in one batched backend
|
|
167
|
+
* call before the per-page upserts, which then serve from the cache.
|
|
168
|
+
*/
|
|
169
|
+
warmSectionEmbeddings: typeof realWarmSectionEmbeddings;
|
|
145
170
|
/**
|
|
146
171
|
* Persist the high-water mark after a re-embed pass with zero failures. The
|
|
147
172
|
* value is captured before the pass's writes (see the key docstring); the
|
|
148
|
-
* caller skips this when any page failed so failed pages retry next pass
|
|
173
|
+
* caller skips this when any page failed so failed pages retry next pass,
|
|
174
|
+
* and a version rebuild defers it past the deleted-page prune while a
|
|
175
|
+
* stored capability row it could not rebuild remains. The real commit
|
|
176
|
+
* (`commitSectionEmbedHighWater`) also releases the dense read hold a
|
|
177
|
+
* forced chunker rebuild put in place.
|
|
149
178
|
*/
|
|
150
179
|
commitEmbedHighWater: (highWaterMs: number) => void;
|
|
180
|
+
/**
|
|
181
|
+
* Force a full re-embed when the section chunker version on record differs
|
|
182
|
+
* from the current one (see `ensureSectionChunkerVersion`). Runs after the
|
|
183
|
+
* collection is ensured and before deltas are selected, so the cleared
|
|
184
|
+
* high-water is what the selector reads. Resolves to whether a chunker
|
|
185
|
+
* rebuild is pending (forced by this call, or left by an earlier one that
|
|
186
|
+
* no clean pass has committed since), which is the pass's cue to re-embed
|
|
187
|
+
* the capability rows the store holds before committing.
|
|
188
|
+
*/
|
|
189
|
+
ensureChunkerVersion: () => Promise<boolean>;
|
|
151
190
|
/**
|
|
152
191
|
* Every distinct `article` slug that currently has section points in the
|
|
153
192
|
* dense store. The prune stage diffs this against the live page-index slugs
|
|
@@ -211,11 +250,27 @@ export interface BackfillJobDeps {
|
|
|
211
250
|
deleteSectionsForArticle: typeof realDeleteSectionsForArticle;
|
|
212
251
|
/** Embed + upsert an article's current sections into the dense store. */
|
|
213
252
|
upsertSections: typeof realUpsertSections;
|
|
253
|
+
/**
|
|
254
|
+
* Warm the embedding cache for many pages' sections in one batched backend
|
|
255
|
+
* call before the per-page upserts, which then serve from the cache.
|
|
256
|
+
*/
|
|
257
|
+
warmSectionEmbeddings: typeof realWarmSectionEmbeddings;
|
|
214
258
|
/**
|
|
215
259
|
* Persist the high-water mark after the backfill completes with zero
|
|
216
260
|
* failures. Skipped when any page failed so failed pages retry next pass.
|
|
261
|
+
* The real commit (`commitSectionEmbedHighWater`) also releases the dense
|
|
262
|
+
* read hold a forced chunker rebuild put in place.
|
|
217
263
|
*/
|
|
218
264
|
commitEmbedHighWater: (highWaterMs: number) => void;
|
|
265
|
+
/**
|
|
266
|
+
* Record the current section chunker version, forcing the maintain job's
|
|
267
|
+
* rebuild path when the one on record differs (see
|
|
268
|
+
* `ensureSectionChunkerVersion`). Runs after the collection is ensured and
|
|
269
|
+
* before the first write, so the version is on record before this pass
|
|
270
|
+
* commits. The backfill embeds every page and capability row regardless, so
|
|
271
|
+
* the pending-rebuild result is not consulted.
|
|
272
|
+
*/
|
|
273
|
+
ensureChunkerVersion: () => Promise<boolean>;
|
|
219
274
|
/** Epoch-ms stamped as the new high-water mark; injectable for tests. */
|
|
220
275
|
nowMs: () => number;
|
|
221
276
|
/** Active assistant config (for the dense-store/embedding calls). */
|
|
@@ -243,10 +298,22 @@ export interface BackfillOutcome {
|
|
|
243
298
|
export interface MaintainOutcome {
|
|
244
299
|
/** True when both v3 flags were off and the job no-opped. */
|
|
245
300
|
disabled: boolean;
|
|
246
|
-
/**
|
|
301
|
+
/**
|
|
302
|
+
* Articles whose sections were re-chunked + re-embedded this pass: the
|
|
303
|
+
* changed pages plus, on a version-triggered rebuild, the capability rows
|
|
304
|
+
* the store already held.
|
|
305
|
+
*/
|
|
247
306
|
reembedded: number;
|
|
248
|
-
/**
|
|
307
|
+
/** Re-embeds that threw (and were contained). */
|
|
249
308
|
reembedFailures: number;
|
|
309
|
+
/**
|
|
310
|
+
* Stored capability rows (skills/CLI) a version-triggered rebuild left with
|
|
311
|
+
* the previous chunker's points at the end of this pass: their body
|
|
312
|
+
* rendered empty here (this process's capability caches do not resolve
|
|
313
|
+
* them) and the deleted-page prune did not remove them. The embed
|
|
314
|
+
* checkpoint and the dense-read hold wait while any remain.
|
|
315
|
+
*/
|
|
316
|
+
unrebuiltCapabilityRows: Slug[];
|
|
250
317
|
/**
|
|
251
318
|
* Capability rows (skills/CLI) present in the index but missing from the
|
|
252
319
|
* section store that were embedded this pass — how a skill enabled after the
|
|
@@ -333,10 +400,6 @@ async function selectChangedPagesFromWorkspace(
|
|
|
333
400
|
return computeChangedPages(index.entries, readEmbedHighWater());
|
|
334
401
|
}
|
|
335
402
|
|
|
336
|
-
function commitEmbedHighWater(highWaterMs: number): void {
|
|
337
|
-
setMemoryCheckpoint(MAINTAIN_EMBED_HIGH_WATER_KEY, String(highWaterMs));
|
|
338
|
-
}
|
|
339
|
-
|
|
340
403
|
/** Read a page's frontmatter-stripped body; missing/failed reads degrade to "". */
|
|
341
404
|
async function readPageBodyFromWorkspace(
|
|
342
405
|
workspaceDir: string,
|
|
@@ -385,7 +448,9 @@ function defaultDeps(config: AssistantConfig): MaintainJobDeps {
|
|
|
385
448
|
backfillPageBodyFromWorkspace(workspaceDir, slug),
|
|
386
449
|
deleteSectionsForArticle: realDeleteSectionsForArticle,
|
|
387
450
|
upsertSections: realUpsertSections,
|
|
388
|
-
|
|
451
|
+
warmSectionEmbeddings: realWarmSectionEmbeddings,
|
|
452
|
+
commitEmbedHighWater: commitSectionEmbedHighWater,
|
|
453
|
+
ensureChunkerVersion: realEnsureSectionChunkerVersion,
|
|
389
454
|
listSectionArticles: () => realListSectionArticles(config),
|
|
390
455
|
listIndexedSlugs: () => selectAllPagesFromWorkspace(workspaceDir),
|
|
391
456
|
loadCoreSet: () => realLoadCoreSet(workspaceDir),
|
|
@@ -419,7 +484,9 @@ function defaultBackfillDeps(config: AssistantConfig): BackfillJobDeps {
|
|
|
419
484
|
readPageBody: (slug) => backfillPageBodyFromWorkspace(workspaceDir, slug),
|
|
420
485
|
deleteSectionsForArticle: realDeleteSectionsForArticle,
|
|
421
486
|
upsertSections: realUpsertSections,
|
|
422
|
-
|
|
487
|
+
warmSectionEmbeddings: realWarmSectionEmbeddings,
|
|
488
|
+
commitEmbedHighWater: commitSectionEmbedHighWater,
|
|
489
|
+
ensureChunkerVersion: realEnsureSectionChunkerVersion,
|
|
423
490
|
nowMs: () => Date.now(),
|
|
424
491
|
config,
|
|
425
492
|
embedProbe: async () => {
|
|
@@ -440,6 +507,7 @@ async function reembedChangedPages(
|
|
|
440
507
|
): Promise<{ reembedded: number; reembedFailures: number }> {
|
|
441
508
|
let reembedded = 0;
|
|
442
509
|
let reembedFailures = 0;
|
|
510
|
+
await warmEmbeddingCacheForPages(slugs, deps);
|
|
443
511
|
for (const slug of slugs) {
|
|
444
512
|
try {
|
|
445
513
|
const index = await deps.buildSectionIndex([slug], deps.readPageBody);
|
|
@@ -457,58 +525,128 @@ async function reembedChangedPages(
|
|
|
457
525
|
return { reembedded, reembedFailures };
|
|
458
526
|
}
|
|
459
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Warm the embedding cache for every section of `slugs` in batched backend
|
|
530
|
+
* calls before the per-page loop, which otherwise pays one backend call per
|
|
531
|
+
* page. Only worth a call for two or more pages. Best-effort: a failure here
|
|
532
|
+
* is logged, and the per-page loop then embeds each page independently, with
|
|
533
|
+
* each page's failure contained to that page.
|
|
534
|
+
*/
|
|
535
|
+
async function warmEmbeddingCacheForPages(
|
|
536
|
+
slugs: Slug[],
|
|
537
|
+
deps: Pick<
|
|
538
|
+
MaintainJobDeps,
|
|
539
|
+
"buildSectionIndex" | "readPageBody" | "warmSectionEmbeddings" | "config"
|
|
540
|
+
>,
|
|
541
|
+
): Promise<void> {
|
|
542
|
+
if (slugs.length < 2) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
try {
|
|
546
|
+
const index = await deps.buildSectionIndex(slugs, deps.readPageBody);
|
|
547
|
+
await deps.warmSectionEmbeddings(deps.config, index.sections);
|
|
548
|
+
} catch (err) {
|
|
549
|
+
log.warn(
|
|
550
|
+
{
|
|
551
|
+
pages: slugs.length,
|
|
552
|
+
err: err instanceof Error ? err.message : String(err),
|
|
553
|
+
},
|
|
554
|
+
"memory-v3 maintain: embedding cache warm-up failed; each page embeds on its own (non-fatal)",
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
460
559
|
/**
|
|
461
560
|
* Embed capability rows (synthetic skill/CLI slugs) present in the page index
|
|
462
561
|
* but missing from the section dense store. The incremental re-embed selector
|
|
463
|
-
* ({@link computeChangedPages}) excludes capability rows
|
|
464
|
-
* mtime to delta against
|
|
465
|
-
* {@link backfillAllSections}
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
* `reconcileFailures` without aborting the rest. A capability row whose body
|
|
473
|
-
* resolves empty (its store has not seeded yet) is skipped WITHOUT deleting any
|
|
474
|
-
* points — never replace good points with a blank — and is retried next pass.
|
|
562
|
+
* ({@link computeChangedPages}) excludes capability rows (they have no on-disk
|
|
563
|
+
* mtime to delta against), so their only other embedders are the one-time
|
|
564
|
+
* {@link backfillAllSections} and the version-triggered rebuild in
|
|
565
|
+
* {@link maintainJob}'s first stage. Without this, a skill enabled AFTER that
|
|
566
|
+
* backfill (e.g. a flag-gated skill flipped on at runtime) lands in the page
|
|
567
|
+
* index but never reaches the dense lane. This stage makes the periodic
|
|
568
|
+
* maintain pass self-heal: diff the live capability slugs against the stored
|
|
569
|
+
* section articles and embed the missing ones. Per-row containment and the
|
|
570
|
+
* cold-row skip live in {@link refreshCapabilityRows}.
|
|
475
571
|
*/
|
|
476
572
|
async function reconcileCapabilityRows(
|
|
477
573
|
deps: MaintainJobDeps,
|
|
478
574
|
): Promise<{ capabilitiesReconciled: number; reconcileFailures: number }> {
|
|
575
|
+
const missing = await missingCapabilityRows(deps);
|
|
576
|
+
const { embedded, failed } = await refreshCapabilityRows(missing, deps);
|
|
577
|
+
return { capabilitiesReconciled: embedded, reconcileFailures: failed };
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* The capability slugs (synthetic skill/CLI rows) the page index lists that
|
|
582
|
+
* the section dense store holds no points for: what
|
|
583
|
+
* {@link reconcileCapabilityRows} embeds.
|
|
584
|
+
*/
|
|
585
|
+
async function missingCapabilityRows(deps: MaintainJobDeps): Promise<Slug[]> {
|
|
479
586
|
const [indexedSlugs, storedArticles] = await Promise.all([
|
|
480
587
|
deps.listIndexedSlugs(),
|
|
481
588
|
deps.listSectionArticles(),
|
|
482
589
|
]);
|
|
483
590
|
const stored = new Set(storedArticles);
|
|
484
|
-
|
|
591
|
+
return indexedSlugs.filter(
|
|
485
592
|
(slug) => isCapabilitySlug(slug) && !stored.has(slug),
|
|
486
593
|
);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* The capability rows the section dense store currently holds points for:
|
|
598
|
+
* what a version-triggered rebuild re-embeds, since the change-delta selector
|
|
599
|
+
* never names a capability row and the stored points would otherwise keep
|
|
600
|
+
* the previous chunker's boundaries. Read from the store rather than the page
|
|
601
|
+
* index: an index built while this process's capability caches are unseeded
|
|
602
|
+
* lists no capability row, and a stored row it omits still carries the old
|
|
603
|
+
* points.
|
|
604
|
+
*/
|
|
605
|
+
async function storedCapabilityRows(deps: MaintainJobDeps): Promise<Slug[]> {
|
|
606
|
+
return (await deps.listSectionArticles()).filter(isCapabilitySlug);
|
|
607
|
+
}
|
|
487
608
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
609
|
+
/**
|
|
610
|
+
* Re-chunk + re-embed capability rows from their rendered capability bodies
|
|
611
|
+
* (`readCapabilityBody`). Each row is independent: a single build/delete/upsert
|
|
612
|
+
* throw is logged and counted in `failed` without aborting the rest. A row
|
|
613
|
+
* whose body resolves empty is listed in `cold` and skipped WITHOUT deleting
|
|
614
|
+
* any points (never replace good points with a blank): a capability store that
|
|
615
|
+
* has not seeded yet renders every row empty, and a slug the index lists but
|
|
616
|
+
* no store resolves renders empty on every pass. What a cold row means is the
|
|
617
|
+
* caller's: the reconcile stage retries it on a later pass, and a version
|
|
618
|
+
* rebuild holds its commit on it (see {@link maintainJob}).
|
|
619
|
+
*/
|
|
620
|
+
async function refreshCapabilityRows(
|
|
621
|
+
slugs: Slug[],
|
|
622
|
+
deps: MaintainJobDeps,
|
|
623
|
+
): Promise<{ embedded: number; failed: number; cold: Slug[] }> {
|
|
624
|
+
let embedded = 0;
|
|
625
|
+
let failed = 0;
|
|
626
|
+
const cold: Slug[] = [];
|
|
627
|
+
for (const slug of slugs) {
|
|
491
628
|
try {
|
|
492
629
|
const body = await deps.readCapabilityBody(slug);
|
|
493
630
|
if (body.trim().length === 0) {
|
|
631
|
+
cold.push(slug);
|
|
494
632
|
continue;
|
|
495
|
-
}
|
|
633
|
+
}
|
|
496
634
|
const index = await deps.buildSectionIndex(
|
|
497
635
|
[slug],
|
|
498
636
|
deps.readCapabilityBody,
|
|
499
637
|
);
|
|
500
638
|
await deps.deleteSectionsForArticle(deps.config, slug);
|
|
501
639
|
await deps.upsertSections(deps.config, index.sections);
|
|
502
|
-
|
|
640
|
+
embedded += 1;
|
|
503
641
|
} catch (err) {
|
|
504
|
-
|
|
642
|
+
failed += 1;
|
|
505
643
|
log.warn(
|
|
506
644
|
{ slug, err: err instanceof Error ? err.message : String(err) },
|
|
507
|
-
"memory-v3 maintain: capability
|
|
645
|
+
"memory-v3 maintain: capability row embed failed (non-fatal)",
|
|
508
646
|
);
|
|
509
647
|
}
|
|
510
648
|
}
|
|
511
|
-
return {
|
|
649
|
+
return { embedded, failed, cold };
|
|
512
650
|
}
|
|
513
651
|
|
|
514
652
|
/**
|
|
@@ -521,12 +659,15 @@ async function reconcileCapabilityRows(
|
|
|
521
659
|
* diffing against the live slug set.
|
|
522
660
|
*
|
|
523
661
|
* Each deletion is independent: a single `deleteSectionsForArticle` throw is
|
|
524
|
-
* logged and counted in `pruneFailures` without aborting the rest.
|
|
525
|
-
* capability
|
|
662
|
+
* logged and counted in `pruneFailures` without aborting the rest. A
|
|
663
|
+
* capability row the page index lists is never pruned; one it does not list
|
|
664
|
+
* is pruned like any deleted page, and the pruned articles are returned so a
|
|
665
|
+
* version rebuild's deferred commit can settle on them (see
|
|
666
|
+
* {@link maintainJob}).
|
|
526
667
|
*/
|
|
527
668
|
async function pruneDeletedPages(
|
|
528
669
|
deps: MaintainJobDeps,
|
|
529
|
-
): Promise<{
|
|
670
|
+
): Promise<{ prunedArticles: string[]; pruneFailures: number }> {
|
|
530
671
|
const [storedArticles, indexedSlugs] = await Promise.all([
|
|
531
672
|
deps.listSectionArticles(),
|
|
532
673
|
deps.listIndexedSlugs(),
|
|
@@ -534,12 +675,12 @@ async function pruneDeletedPages(
|
|
|
534
675
|
const live = new Set(indexedSlugs);
|
|
535
676
|
const deleted = storedArticles.filter((article) => !live.has(article));
|
|
536
677
|
|
|
537
|
-
|
|
678
|
+
const prunedArticles: string[] = [];
|
|
538
679
|
let pruneFailures = 0;
|
|
539
680
|
for (const article of deleted) {
|
|
540
681
|
try {
|
|
541
682
|
await deps.deleteSectionsForArticle(deps.config, article);
|
|
542
|
-
|
|
683
|
+
prunedArticles.push(article);
|
|
543
684
|
} catch (err) {
|
|
544
685
|
pruneFailures += 1;
|
|
545
686
|
log.warn(
|
|
@@ -548,7 +689,7 @@ async function pruneDeletedPages(
|
|
|
548
689
|
);
|
|
549
690
|
}
|
|
550
691
|
}
|
|
551
|
-
return {
|
|
692
|
+
return { prunedArticles, pruneFailures };
|
|
552
693
|
}
|
|
553
694
|
|
|
554
695
|
/**
|
|
@@ -698,6 +839,9 @@ export async function backfillAllSections(
|
|
|
698
839
|
|
|
699
840
|
const slugs = await deps.selectAllPages();
|
|
700
841
|
await deps.ensureSectionCollection(deps.config);
|
|
842
|
+
// The backfill re-embeds every page regardless; recording the chunker
|
|
843
|
+
// version here keeps the maintain job from forcing a second full pass.
|
|
844
|
+
await deps.ensureChunkerVersion();
|
|
701
845
|
|
|
702
846
|
// Pre-flight: smoke-test the embedding backend BEFORE any delete. Each article
|
|
703
847
|
// is processed delete-then-upsert, so starting a full backfill against a down
|
|
@@ -751,6 +895,13 @@ export async function backfillAllSections(
|
|
|
751
895
|
};
|
|
752
896
|
|
|
753
897
|
const coldCapabilities: Slug[] = [];
|
|
898
|
+
// Real pages warm the embedding cache in one batched call first; capability
|
|
899
|
+
// rows stay on the per-page path below, whose cold-row guard must see each
|
|
900
|
+
// body before anything of it is embedded.
|
|
901
|
+
await warmEmbeddingCacheForPages(
|
|
902
|
+
slugs.filter((slug) => !isCapabilitySlug(slug)),
|
|
903
|
+
deps,
|
|
904
|
+
);
|
|
754
905
|
for (const slug of slugs) {
|
|
755
906
|
if ((await embedOne(slug)) === "cold") {
|
|
756
907
|
coldCapabilities.push(slug);
|
|
@@ -814,6 +965,7 @@ export async function maintainJob(
|
|
|
814
965
|
disabled: false,
|
|
815
966
|
reembedded: 0,
|
|
816
967
|
reembedFailures: 0,
|
|
968
|
+
unrebuiltCapabilityRows: [],
|
|
817
969
|
capabilitiesReconciled: 0,
|
|
818
970
|
reconcileFailures: 0,
|
|
819
971
|
pruned: 0,
|
|
@@ -835,6 +987,12 @@ export async function maintainJob(
|
|
|
835
987
|
// Stage 1: re-chunk + re-embed pages changed since the last pass. Capture the
|
|
836
988
|
// high-water mark BEFORE the pass so an embed write that bumps a page's mtime
|
|
837
989
|
// does not re-trigger it next pass; advance it only when every page succeeded.
|
|
990
|
+
//
|
|
991
|
+
// The commit a version rebuild still owes after this stage: set when the
|
|
992
|
+
// pass had no embed failure but left stored capability rows it could not
|
|
993
|
+
// rebuild, and settled after the deleted-page prune (stage 3), the stage
|
|
994
|
+
// that removes such a row when the page index no longer lists it.
|
|
995
|
+
let deferredCommit: { highWaterMs: number; unrebuilt: Slug[] } | null = null;
|
|
838
996
|
try {
|
|
839
997
|
const startedAtMs = Date.now();
|
|
840
998
|
// Establish the collection BEFORE selecting deltas. If it is absent or
|
|
@@ -845,6 +1003,10 @@ export async function maintainJob(
|
|
|
845
1003
|
// cleared mark visible to `selectChangedPages`, turning this pass into the
|
|
846
1004
|
// full-corpus re-embed the recreate requires.
|
|
847
1005
|
await deps.ensureSectionCollection(deps.config);
|
|
1006
|
+
// A chunker version change clears the high-water the same way, and for
|
|
1007
|
+
// the same reason: the stored points no longer line up with the index.
|
|
1008
|
+
// The pending marker it leaves names this pass a version rebuild.
|
|
1009
|
+
const rebuildPending = await deps.ensureChunkerVersion();
|
|
848
1010
|
const changed = await deps.selectChangedPages();
|
|
849
1011
|
const { reembedded, reembedFailures } = await reembedChangedPages(
|
|
850
1012
|
changed,
|
|
@@ -852,20 +1014,51 @@ export async function maintainJob(
|
|
|
852
1014
|
);
|
|
853
1015
|
outcome.reembedded = reembedded;
|
|
854
1016
|
outcome.reembedFailures = reembedFailures;
|
|
855
|
-
//
|
|
856
|
-
//
|
|
857
|
-
//
|
|
858
|
-
//
|
|
859
|
-
//
|
|
860
|
-
//
|
|
861
|
-
//
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
1017
|
+
// A version rebuild must also refresh the capability rows the store
|
|
1018
|
+
// already holds: the delta selector never names them (modifiedAt 0) and
|
|
1019
|
+
// the reconcile stage below embeds only rows missing from the store, so
|
|
1020
|
+
// without this their points would keep the previous chunker's boundaries
|
|
1021
|
+
// past the commit that releases the dense-read hold. A cold row (its body
|
|
1022
|
+
// renders empty here: this process's capability caches are unseeded, or
|
|
1023
|
+
// the capability is gone) keeps its points, and those points keep the
|
|
1024
|
+
// old boundaries, so it holds the commit until it is rebuilt or removed.
|
|
1025
|
+
let unrebuilt: Slug[] = [];
|
|
1026
|
+
if (rebuildPending) {
|
|
1027
|
+
const { embedded, failed, cold } = await refreshCapabilityRows(
|
|
1028
|
+
await storedCapabilityRows(deps),
|
|
1029
|
+
deps,
|
|
1030
|
+
);
|
|
1031
|
+
outcome.reembedded += embedded;
|
|
1032
|
+
outcome.reembedFailures += failed;
|
|
1033
|
+
unrebuilt = cold;
|
|
1034
|
+
}
|
|
1035
|
+
// Only advance the high-water mark when nothing failed. A failed article
|
|
1036
|
+
// is processed as delete-then-upsert, so a transient embed/Qdrant error
|
|
1037
|
+
// leaves its sections deleted; if we advanced past a page's mtime,
|
|
1038
|
+
// `computeChangedPages` would never re-select it (mtime <= high-water) and
|
|
1039
|
+
// it would stay missing, and a commit would release the dense-read hold
|
|
1040
|
+
// over a capability row whose points are gone. Holding the checkpoint
|
|
1041
|
+
// keeps every failed article in the next pass so it retries; the handful
|
|
1042
|
+
// of already-succeeded articles re-embedding again is idempotent and cheap.
|
|
1043
|
+
// A commit over a cold capability row would likewise release the hold
|
|
1044
|
+
// over points whose ordinals can name the wrong section, so with cold
|
|
1045
|
+
// rows and no failure the commit is deferred until the deleted-page
|
|
1046
|
+
// prune has run: a row the page index no longer lists leaves the store
|
|
1047
|
+
// there, and a row still standing afterwards holds the commit, and the
|
|
1048
|
+
// rebuild marker (in the memory worker, where the job runs, every
|
|
1049
|
+
// capability row is cold and the prune removes them all).
|
|
1050
|
+
if (outcome.reembedFailures > 0) {
|
|
865
1051
|
log.info(
|
|
866
|
-
{
|
|
867
|
-
|
|
1052
|
+
{
|
|
1053
|
+
reembedded: outcome.reembedded,
|
|
1054
|
+
reembedFailures: outcome.reembedFailures,
|
|
1055
|
+
},
|
|
1056
|
+
"memory-v3 maintain: embed checkpoint held (embed failures); failed articles retry next pass",
|
|
868
1057
|
);
|
|
1058
|
+
} else if (unrebuilt.length === 0) {
|
|
1059
|
+
deps.commitEmbedHighWater(startedAtMs);
|
|
1060
|
+
} else {
|
|
1061
|
+
deferredCommit = { highWaterMs: startedAtMs, unrebuilt };
|
|
869
1062
|
}
|
|
870
1063
|
} catch (err) {
|
|
871
1064
|
outcome.failures.push("reembed");
|
|
@@ -877,10 +1070,10 @@ export async function maintainJob(
|
|
|
877
1070
|
|
|
878
1071
|
// Stage 2: embed capability rows (skills/CLI) present in the index but missing
|
|
879
1072
|
// from the section store. They have modifiedAt 0, so computeChangedPages never
|
|
880
|
-
// selects them; the one-time backfill
|
|
881
|
-
//
|
|
882
|
-
// this self-heals it. Contained: a
|
|
883
|
-
// aborting later stages.
|
|
1073
|
+
// selects them; the one-time backfill and the version rebuild above are
|
|
1074
|
+
// otherwise their only embedders, so a skill enabled after that backfill
|
|
1075
|
+
// stays invisible to the dense lane until this self-heals it. Contained: a
|
|
1076
|
+
// failure is logged + recorded without aborting later stages.
|
|
884
1077
|
try {
|
|
885
1078
|
const { capabilitiesReconciled, reconcileFailures } =
|
|
886
1079
|
await reconcileCapabilityRows(deps);
|
|
@@ -897,12 +1090,20 @@ export async function maintainJob(
|
|
|
897
1090
|
// Stage 3: prune section points for pages deleted from the index. A deleted
|
|
898
1091
|
// page's slug never appears in `selectChangedPages` (the delta selector only
|
|
899
1092
|
// names live pages), so its lingering points are cleared by diffing the dense
|
|
900
|
-
// store's stored articles against the live page-index slugs.
|
|
901
|
-
//
|
|
1093
|
+
// store's stored articles against the live page-index slugs. The articles
|
|
1094
|
+
// it removes also settle the commit a version rebuild deferred (below).
|
|
1095
|
+
// Contained: a failure is logged + recorded in `failures` without aborting
|
|
1096
|
+
// invalidation.
|
|
902
1097
|
try {
|
|
903
|
-
const {
|
|
904
|
-
outcome.pruned =
|
|
1098
|
+
const { prunedArticles, pruneFailures } = await pruneDeletedPages(deps);
|
|
1099
|
+
outcome.pruned = prunedArticles.length;
|
|
905
1100
|
outcome.pruneFailures = pruneFailures;
|
|
1101
|
+
if (deferredCommit) {
|
|
1102
|
+
const pruned = new Set(prunedArticles);
|
|
1103
|
+
deferredCommit.unrebuilt = deferredCommit.unrebuilt.filter(
|
|
1104
|
+
(slug) => !pruned.has(slug),
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
906
1107
|
} catch (err) {
|
|
907
1108
|
outcome.failures.push("prune");
|
|
908
1109
|
log.warn(
|
|
@@ -911,6 +1112,30 @@ export async function maintainJob(
|
|
|
911
1112
|
);
|
|
912
1113
|
}
|
|
913
1114
|
|
|
1115
|
+
// Settle the commit stage 1 deferred: a cold capability row the prune
|
|
1116
|
+
// removed carries no stale points any more, so with none left the pass
|
|
1117
|
+
// commits as a clean rebuild; otherwise the checkpoint and the rebuild
|
|
1118
|
+
// marker stay put and the remaining rows are surfaced in the outcome.
|
|
1119
|
+
if (deferredCommit) {
|
|
1120
|
+
try {
|
|
1121
|
+
if (deferredCommit.unrebuilt.length === 0) {
|
|
1122
|
+
deps.commitEmbedHighWater(deferredCommit.highWaterMs);
|
|
1123
|
+
} else {
|
|
1124
|
+
outcome.unrebuiltCapabilityRows = deferredCommit.unrebuilt;
|
|
1125
|
+
log.info(
|
|
1126
|
+
{ unrebuiltCapabilityRows: deferredCommit.unrebuilt },
|
|
1127
|
+
"memory-v3 maintain: embed checkpoint held (stored capability rows this process cannot rebuild keep the previous chunker's points); the next pass retries",
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
} catch (err) {
|
|
1131
|
+
outcome.failures.push("reembed");
|
|
1132
|
+
log.warn(
|
|
1133
|
+
{ err: err instanceof Error ? err.message : String(err) },
|
|
1134
|
+
"memory-v3 maintain: deferred embed commit failed (non-fatal)",
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
914
1139
|
// Stage 4: validate the maintainer-curated core set. Diff `core-pages.md`
|
|
915
1140
|
// entries against the live page-index slugs and REPORT dangling entries
|
|
916
1141
|
// (pages that were renamed or deleted) through the log + outcome — the file
|
|
@@ -976,6 +1201,7 @@ export async function maintainJob(
|
|
|
976
1201
|
{
|
|
977
1202
|
reembedded: outcome.reembedded,
|
|
978
1203
|
reembedFailures: outcome.reembedFailures,
|
|
1204
|
+
unrebuiltCapabilityRows: outcome.unrebuiltCapabilityRows,
|
|
979
1205
|
capabilitiesReconciled: outcome.capabilitiesReconciled,
|
|
980
1206
|
reconcileFailures: outcome.reconcileFailures,
|
|
981
1207
|
pruned: outcome.pruned,
|