@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
|
@@ -2,7 +2,7 @@ export type Slug = string;
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Injection-block id for the v3 live `<memory>` block. Shared between the
|
|
5
|
-
* producer (the v3 injector in `
|
|
5
|
+
* producer (the v3 injector in `injector.ts`) and the v2-suppression
|
|
6
6
|
* consumer (`conversation-runtime-assembly.ts`), which keys off this id to
|
|
7
7
|
* detect that v3 actually produced a block this turn. Keeping it in one place
|
|
8
8
|
* makes a rename a compile error on both sides instead of a silent
|
|
@@ -11,48 +11,186 @@ export type Slug = string;
|
|
|
11
11
|
export const MEMORY_V3_BLOCK_ID = "memory-v3" as const;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* `meta` key under which the v3
|
|
15
|
-
* callback. The injector defers its
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* `meta` key under which the v3 sections block carries its attachment-commit
|
|
15
|
+
* callback. The injector defers its section-store write (and the prune-valve
|
|
16
|
+
* schedule) into this callback; runtime assembly invokes it only when the
|
|
17
|
+
* turn's tail is a user message, the same gate as metadata capture, so a
|
|
18
|
+
* block that silently fails to attach never claims its sections in the dedup
|
|
19
|
+
* store. Shared between the producer (`injector.ts`) and the consumer
|
|
20
20
|
* (`conversation-runtime-assembly.ts`) so a rename is a compile error on both
|
|
21
21
|
* sides instead of a silent never-commit.
|
|
22
22
|
*/
|
|
23
23
|
export const MEMORY_V3_COMMIT_META_KEY = "memoryV3Commit" as const;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Injection-block id for the v3 per-turn `<
|
|
27
|
-
*
|
|
28
|
-
* the
|
|
29
|
-
* on the user message that was sent
|
|
26
|
+
* Injection-block id for the v3 per-turn `<memory_pointer>` block: the list
|
|
27
|
+
* of this turn's selected sections that are already resident in history.
|
|
28
|
+
* Distinct from {@link MEMORY_V3_BLOCK_ID}: the pointer never participates in
|
|
29
|
+
* v2 suppression. Each turn's block stays on the user message that was sent
|
|
30
|
+
* with it; a fresh one is spliced only onto the new tail.
|
|
30
31
|
*/
|
|
31
|
-
export const
|
|
32
|
+
export const MEMORY_V3_POINTER_BLOCK_ID = "memory-v3-pointer" as const;
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
|
-
* Message-metadata key for the wrapped `<
|
|
35
|
-
*
|
|
36
|
-
* historical turns keep the
|
|
37
|
-
*
|
|
38
|
-
* `
|
|
39
|
-
* memory feature.
|
|
35
|
+
* Message-metadata key for the wrapped `<memory_pointer>` block persisted on
|
|
36
|
+
* the user row that received it. `loadFromDb` rehydrates from this key so
|
|
37
|
+
* historical turns keep the pointer they were sent with (the provider prefix
|
|
38
|
+
* through those messages stays byte-identical). Kept as a literal in
|
|
39
|
+
* `messageMetadataSchema` (same pattern as `memoryV3InjectedBlock`) so the
|
|
40
|
+
* storage schema does not import the memory feature.
|
|
40
41
|
*/
|
|
41
|
-
export const
|
|
42
|
+
export const MEMORY_V3_POINTER_BLOCK_METADATA_KEY =
|
|
43
|
+
"memoryV3PointerBlock" as const;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Message-metadata key under which builds that shipped the per-turn
|
|
47
|
+
* `<memory_spotlight>` layer persisted each turn's wrapped block. No producer
|
|
48
|
+
* writes it; `loadFromDb` rehydrates a row's legacy block verbatim as inert
|
|
49
|
+
* history so a conversation that spans the upgrade keeps the prefix those
|
|
50
|
+
* turns were sent with.
|
|
51
|
+
*/
|
|
52
|
+
export const LEGACY_MEMORY_V3_SPOTLIGHT_BLOCK_METADATA_KEY =
|
|
42
53
|
"memoryV3SpotlightBlock" as const;
|
|
43
54
|
|
|
55
|
+
/**
|
|
56
|
+
* How a persisted memory-v3 section block was rendered, which decides the
|
|
57
|
+
* grammar a reader parses it with. `"current"`: rendered by a build that
|
|
58
|
+
* stamps `memoryV3InjectedBlockFormat` (`MEMORY_V3_INJECTED_BLOCK_FORMAT` in
|
|
59
|
+
* `ever-injected-store.ts`) beside the block, so its inner text follows the
|
|
60
|
+
* escaped grammar of `substrate/injected-block-slugs.ts` and is parsed,
|
|
61
|
+
* pruned, superseded by newer copies, and fork-seeded at section grain.
|
|
62
|
+
* `"legacy"`: persisted by a build before the stamp existed (a row carrying
|
|
63
|
+
* the block without it), rendered as compact cards, which the rehydration
|
|
64
|
+
* filter and the live strip read with that build's card grammar
|
|
65
|
+
* (`filterLegacyCards` in `substrate/injected-block-slugs.ts`) under each
|
|
66
|
+
* card's lead ref: a card whose lead is tombstoned, or re-injected by a
|
|
67
|
+
* current block after a prune, leaves. The block itself is never pruned,
|
|
68
|
+
* indexed, or fork-seeded, and is gone with the compaction that strips
|
|
69
|
+
* memory blocks and clears the section store. Provenance is explicit, never
|
|
70
|
+
* inferred from a block's content.
|
|
71
|
+
*/
|
|
72
|
+
export type InjectedBlockFormat = "legacy" | "current";
|
|
73
|
+
|
|
74
|
+
/** A persisted section block's unwrapped inner text with its rendering
|
|
75
|
+
* format: the per-block input of the rehydration filter, the live strip,
|
|
76
|
+
* and the fork seeder. */
|
|
77
|
+
export interface InjectedBlock {
|
|
78
|
+
inner: string;
|
|
79
|
+
format: InjectedBlockFormat;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The `<memory>` content blocks memory-v3 itself placed in live history, by
|
|
84
|
+
* object identity: the block runtime assembly attaches for the `memory-v3`
|
|
85
|
+
* injector, the block `loadFromDb` splices from persisted metadata, and the
|
|
86
|
+
* block the prune valve's strip writes back in their place. The live strip
|
|
87
|
+
* owns a block only if it is one of these. Ownership is never decided by
|
|
88
|
+
* text: a pre-cutover v2 block can be byte-identical to a v3 lead entry (v2's
|
|
89
|
+
* full-page fallback on a headingless page), and v2 blocks must never be
|
|
90
|
+
* touched. A block that lost its identity (a cloned history) is simply left
|
|
91
|
+
* alone by the strip; the next `loadFromDb` rebuilds it from metadata, where
|
|
92
|
+
* the pruned and superseded filters are authoritative. Each entry carries
|
|
93
|
+
* the block's rendering format (`InjectedBlockFormat`): current for the
|
|
94
|
+
* blocks the injector renders in this process, and whatever the row's
|
|
95
|
+
* metadata recorded for a block `loadFromDb` spliced, so the strip filters a
|
|
96
|
+
* current owned block and leaves a legacy one verbatim, by provenance rather
|
|
97
|
+
* than content. A `WeakMap`, so entries leave with the histories they
|
|
98
|
+
* belonged to.
|
|
99
|
+
*/
|
|
100
|
+
const v3LiveBlocks = new WeakMap<object, InjectedBlockFormat>();
|
|
101
|
+
|
|
102
|
+
/** Register a block memory-v3 placed in live history, with the format it was
|
|
103
|
+
* rendered in (current unless stated: the injector's own blocks); returns
|
|
104
|
+
* it. */
|
|
105
|
+
export function markV3LiveBlock<T extends object>(
|
|
106
|
+
block: T,
|
|
107
|
+
format: InjectedBlockFormat = "current",
|
|
108
|
+
): T {
|
|
109
|
+
v3LiveBlocks.set(block, format);
|
|
110
|
+
return block;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The rendering format of a block memory-v3 placed in live history, or
|
|
114
|
+
* `undefined` for any other block. */
|
|
115
|
+
export function v3LiveBlockFormat(
|
|
116
|
+
block: object,
|
|
117
|
+
): InjectedBlockFormat | undefined {
|
|
118
|
+
return v3LiveBlocks.get(block);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Whether memory-v3 placed this block in live history. */
|
|
122
|
+
export function isV3LiveBlock(block: object): boolean {
|
|
123
|
+
return v3LiveBlocks.has(block);
|
|
124
|
+
}
|
|
125
|
+
|
|
44
126
|
/**
|
|
45
127
|
* A single section of a page: the lead (text before the first `## heading`,
|
|
46
128
|
* ordinal 0) or a heading-delimited block. Over-long sections are split into
|
|
47
129
|
* multiple ordered `Section`s, each with its own consecutive `ordinal`, so each
|
|
48
130
|
* fits a typical embedding window. `text` is prefixed with a
|
|
49
|
-
* `${lastSlugSegment}
|
|
131
|
+
* `${lastSlugSegment} - ${title}` head line (`sectionHeadLine` in
|
|
132
|
+
* `sections.ts`, which caps the title at `SECTION_HEAD_TITLE_CHARS`) for
|
|
133
|
+
* lexical/dense matching.
|
|
134
|
+
*
|
|
135
|
+
* `occurrence` is this heading's 0-based index among the article's headings
|
|
136
|
+
* that share its title (a repeated `## Topic`); `chunk` is this section's
|
|
137
|
+
* 0-based index among the pieces its over-long heading was split into. Both
|
|
138
|
+
* are absent when 0 (the first, and usually only, section under that title).
|
|
139
|
+
* They feed {@link sectionKey}; `ordinal` alone cannot, because ordinals shift
|
|
140
|
+
* whenever consolidation adds or removes a section above, and one counter over
|
|
141
|
+
* both dimensions cannot either, because re-chunking one heading would then
|
|
142
|
+
* renumber a later repeat of it.
|
|
50
143
|
*/
|
|
51
144
|
export interface Section {
|
|
52
145
|
article: Slug;
|
|
53
146
|
title: string;
|
|
54
147
|
text: string;
|
|
55
148
|
ordinal: number;
|
|
149
|
+
occurrence?: number;
|
|
150
|
+
chunk?: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The stable identity of a section within its page, used as the section
|
|
155
|
+
* store's `section_key` and carried in the injected header
|
|
156
|
+
* (`# memory/concepts/<slug>.md § <key>`): the lead is `""`, a heading
|
|
157
|
+
* section is its trimmed title, the n-th repeat of a heading appends `#<n>`,
|
|
158
|
+
* and the n-th chunk of an over-long section appends `~<n>` (`Topic`,
|
|
159
|
+
* `Topic#1`, `Topic~1`, `Topic#1~1`). Keys are stable across consolidation
|
|
160
|
+
* edits that shift ordinals, and across a re-chunking of one heading, which
|
|
161
|
+
* changes only that heading's own `~` keys.
|
|
162
|
+
*
|
|
163
|
+
* The key is injective over `(title, occurrence, chunk)`: every literal `#`
|
|
164
|
+
* and `~` in the title is doubled before the single-character suffixes are
|
|
165
|
+
* appended, so a heading that itself ends in `#<n>` (`Topic#1`, key
|
|
166
|
+
* `Topic##1`) can never collide with a repeat's key (`Topic` again, key
|
|
167
|
+
* `Topic#1`), nor one ending in `~<n>` with a chunk's.
|
|
168
|
+
*/
|
|
169
|
+
export function sectionKey(section: Section): string {
|
|
170
|
+
const encoded = section.title
|
|
171
|
+
.trim()
|
|
172
|
+
.replaceAll("#", "##")
|
|
173
|
+
.replaceAll("~", "~~");
|
|
174
|
+
const occurrence = section.occurrence ? `#${section.occurrence}` : "";
|
|
175
|
+
const chunk = section.chunk ? `~${section.chunk}` : "";
|
|
176
|
+
return `${encoded}${occurrence}${chunk}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** One injected section's identity in the section store: page slug plus
|
|
180
|
+
* {@link sectionKey} (`""` for the lead or for capability content). */
|
|
181
|
+
export interface SectionRef {
|
|
182
|
+
slug: Slug;
|
|
183
|
+
key: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The one string encoding of a {@link SectionRef}, for keying maps and sets
|
|
188
|
+
* by section: slug and key joined on a NUL, which neither side can contain
|
|
189
|
+
* (a slug is a path, a key derives from one heading line), so the encoding
|
|
190
|
+
* is injective. A pair is never parsed back out of it.
|
|
191
|
+
*/
|
|
192
|
+
export function sectionRefId({ slug, key }: SectionRef): string {
|
|
193
|
+
return `${slug}\u0000${key}`;
|
|
56
194
|
}
|
|
57
195
|
|
|
58
196
|
/**
|
|
@@ -65,10 +203,15 @@ export interface SectionIndex {
|
|
|
65
203
|
byArticle: Map<Slug, number[]>;
|
|
66
204
|
}
|
|
67
205
|
|
|
68
|
-
/**
|
|
206
|
+
/**
|
|
207
|
+
* A page selected from the candidate pool, with the matched sections whose
|
|
208
|
+
* finder lines were selected, in pool order and deduped by {@link sectionKey}.
|
|
209
|
+
* Empty when only the page's stable-prefix card, or a section-less edge or
|
|
210
|
+
* learned line, was selected: the injector then injects the page's lead.
|
|
211
|
+
*/
|
|
69
212
|
export interface SelectedPage {
|
|
70
213
|
slug: Slug;
|
|
71
|
-
|
|
214
|
+
sections: Section[];
|
|
72
215
|
}
|
|
73
216
|
|
|
74
217
|
export interface MemoryRoutingTurn {
|
|
@@ -112,7 +255,9 @@ export interface MemoryRoutingTurn {
|
|
|
112
255
|
* clause chunks as separate queries); `learned` marks candidates
|
|
113
256
|
* surfaced by the co-selection NPMI association graph; `entity` marks
|
|
114
257
|
* candidates surfaced because the message named an entity that titles a section
|
|
115
|
-
* heading (the heading-anchored entity lane)
|
|
258
|
+
* heading (the heading-anchored entity lane); `rare` marks candidates surfaced
|
|
259
|
+
* by the rare-term lane (a query word that occurs in at most a handful of
|
|
260
|
+
* sections, whose sections surface on that word alone).
|
|
116
261
|
*
|
|
117
262
|
* The `memory_v3_selections.source` column is free-text, so tightening this set
|
|
118
263
|
* needs no migration: any historical rows with retired labels (e.g. the old
|
|
@@ -130,6 +275,7 @@ export const SELECTION_SOURCES = [
|
|
|
130
275
|
"span",
|
|
131
276
|
"learned",
|
|
132
277
|
"entity",
|
|
278
|
+
"rare",
|
|
133
279
|
] as const;
|
|
134
280
|
|
|
135
281
|
export type SelectionSource = (typeof SELECTION_SOURCES)[number];
|
|
@@ -158,13 +158,30 @@ describe("buildRetriever + retrieve", () => {
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
describe("renderMemorySet", () => {
|
|
161
|
-
test("renders
|
|
161
|
+
test("renders each hit as its live injection entry (the matched section, no selector card), and a sentinel for empty", async () => {
|
|
162
162
|
const retriever = await buildRetriever(makeCorpus(), fakeEmbed, false);
|
|
163
163
|
const hits = retriever.retrieve("alice laptop", null, 2);
|
|
164
|
-
const set = renderMemorySet(retriever, hits, 1200);
|
|
165
|
-
expect(set).toContain("memory/concepts/alice.md");
|
|
164
|
+
const set = await renderMemorySet(retriever, hits, 1200);
|
|
165
|
+
expect(set).toContain("# memory/concepts/alice.md § laptop\n");
|
|
166
166
|
expect(set).toContain("Alice works on her laptop");
|
|
167
|
-
|
|
167
|
+
// The card's lead and section TOC never reach a packet for a heading
|
|
168
|
+
// match: production does not inject them for that hit.
|
|
169
|
+
expect(set).not.toContain("# Alice");
|
|
170
|
+
expect(set).not.toContain("[sections:");
|
|
171
|
+
expect(await renderMemorySet(retriever, [], 1200)).toBe(
|
|
172
|
+
"(no pages retrieved)",
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("a hit on the lead renders the lead entry, and the body cap applies below the header line", async () => {
|
|
177
|
+
const retriever = await buildRetriever(makeCorpus(), fakeEmbed, false);
|
|
178
|
+
const leadIdx = retriever.index.byArticle.get("alice")![0]!;
|
|
179
|
+
const hits = [{ slug: "alice", sectionIdx: leadIdx }];
|
|
180
|
+
const set = await renderMemorySet(retriever, hits, 1200);
|
|
181
|
+
expect(set).toBe("# memory/concepts/alice.md\n# Alice");
|
|
182
|
+
expect(await renderMemorySet(retriever, hits, 5)).toBe(
|
|
183
|
+
"# memory/concepts/alice.md\n# Ali",
|
|
184
|
+
);
|
|
168
185
|
});
|
|
169
186
|
});
|
|
170
187
|
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Retrieval mirrors the live section-lane engine's cheap lanes: a BM25F needle
|
|
14
14
|
* over sections, optionally unioned with dense cosine over section embeddings.
|
|
15
|
+
* Each hit renders as the injection entry production would attach for it
|
|
16
|
+
* (`renderV3InjectionEntry`, read over the eval corpus): the matched heading
|
|
17
|
+
* section, or the lead when the hit is on the lead. The selector card never
|
|
18
|
+
* reaches a packet: its lead and section TOC are text the injector does not
|
|
19
|
+
* send for a heading match, so a judge reading them would pass a corpus on
|
|
20
|
+
* content production never injects.
|
|
15
21
|
* Everything runs in memory — no Qdrant writes, no live-lane mutation — which is
|
|
16
22
|
* why it is safe to run against arbitrary staging/snapshot directories.
|
|
17
23
|
*/
|
|
@@ -36,9 +42,14 @@ import {
|
|
|
36
42
|
messages,
|
|
37
43
|
} from "../../../../persistence/schema/index.js";
|
|
38
44
|
import { FRONTMATTER_REGEX, parseFrontmatterFields } from "../frontmatter.js";
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
import {
|
|
46
|
+
parsePageContent,
|
|
47
|
+
slugFromConceptPath,
|
|
48
|
+
} from "../substrate/page-store.js";
|
|
49
|
+
import {
|
|
50
|
+
type ConceptPageReader,
|
|
51
|
+
renderV3InjectionEntry,
|
|
52
|
+
} from "../v3/page-content.js";
|
|
42
53
|
import { buildSectionNeedle } from "../v3/section-needle.js";
|
|
43
54
|
import { buildSectionIndex } from "../v3/sections.js";
|
|
44
55
|
import type { SectionIndex, Slug } from "../v3/types.js";
|
|
@@ -55,7 +66,9 @@ export type EmbedAll = (texts: string[]) => Promise<number[][]>;
|
|
|
55
66
|
export interface Corpus {
|
|
56
67
|
/** Flat slugs (path under `dir`, minus `.md`, forward-slashed). */
|
|
57
68
|
slugs: Slug[];
|
|
58
|
-
/** slug -> full file text (frontmatter included; the
|
|
69
|
+
/** slug -> full file text (frontmatter included; the retriever's page
|
|
70
|
+
* reader parses it exactly as the live page store parses a workspace
|
|
71
|
+
* page, so a lead entry carries its `[current: …]` line). */
|
|
59
72
|
rawBySlug: Map<Slug, string>;
|
|
60
73
|
/** slug -> frontmatter-stripped body (what the section index chunks). */
|
|
61
74
|
bodyBySlug: Map<Slug, string>;
|
|
@@ -122,7 +135,10 @@ export interface RetrievalHit {
|
|
|
122
135
|
|
|
123
136
|
export interface Retriever {
|
|
124
137
|
index: SectionIndex;
|
|
125
|
-
|
|
138
|
+
/** Reads a corpus page for `renderV3InjectionEntry`, so a packet entry is
|
|
139
|
+
* what the injector would attach for this corpus rather than for the
|
|
140
|
+
* workspace. */
|
|
141
|
+
readPage: ConceptPageReader;
|
|
126
142
|
/** Top-`k` distinct articles (needle ∪ dense), each with a matched section. */
|
|
127
143
|
retrieve(
|
|
128
144
|
queryText: string,
|
|
@@ -206,34 +222,69 @@ export async function buildRetriever(
|
|
|
206
222
|
return merged;
|
|
207
223
|
}
|
|
208
224
|
|
|
209
|
-
return { index,
|
|
225
|
+
return { index, readPage: corpusPageReader(corpus), retrieve };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** A page reader over a corpus: the corpus file parsed by the live page
|
|
229
|
+
* store's own parser, `null` for a slug the corpus lacks or a page it
|
|
230
|
+
* cannot parse (as the injector's workspace reader resolves). */
|
|
231
|
+
function corpusPageReader(corpus: Corpus): ConceptPageReader {
|
|
232
|
+
return async (slug) => {
|
|
233
|
+
const raw = corpus.rawBySlug.get(slug);
|
|
234
|
+
if (raw === undefined) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
return parsePageContent(slug, raw);
|
|
239
|
+
} catch {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Truncate an entry's body to `cap` characters, keeping its header line
|
|
246
|
+
* whole: the eval's packet budget, applied to the live entry. */
|
|
247
|
+
function capEntryBody(entry: string, cap: number): string {
|
|
248
|
+
const headerEnd = entry.indexOf("\n");
|
|
249
|
+
if (headerEnd === -1) {
|
|
250
|
+
return entry;
|
|
251
|
+
}
|
|
252
|
+
const bodyStart = headerEnd + 1;
|
|
253
|
+
return entry.slice(0, bodyStart) + entry.slice(bodyStart, bodyStart + cap);
|
|
210
254
|
}
|
|
211
255
|
|
|
212
256
|
/**
|
|
213
|
-
* Render the retrieved pages as one "memory set" string: each
|
|
214
|
-
*
|
|
215
|
-
*
|
|
257
|
+
* Render the retrieved pages as one "memory set" string: for each hit, the
|
|
258
|
+
* injection entry the live injector would attach for it, rendered by the
|
|
259
|
+
* injector's own `renderV3InjectionEntry` over the eval corpus (the matched
|
|
260
|
+
* heading section; the lead, with its `[current: …]` line, when the hit is
|
|
261
|
+
* on the lead), so the judge scores exactly the text production injects for
|
|
262
|
+
* that hit. The selector card (lead plus section TOC) is not part of a
|
|
263
|
+
* packet. Each entry's body is capped at `sectionCharCap` characters below
|
|
264
|
+
* its header line (an eval budget); a hit whose entry renders empty is
|
|
265
|
+
* skipped.
|
|
216
266
|
*/
|
|
217
|
-
export function renderMemorySet(
|
|
267
|
+
export async function renderMemorySet(
|
|
218
268
|
retriever: Retriever,
|
|
219
269
|
hits: RetrievalHit[],
|
|
220
270
|
sectionCharCap: number,
|
|
221
|
-
): string {
|
|
222
|
-
|
|
271
|
+
): Promise<string> {
|
|
272
|
+
const entries = await Promise.all(
|
|
273
|
+
hits.map(async (hit) =>
|
|
274
|
+
capEntryBody(
|
|
275
|
+
await renderV3InjectionEntry(
|
|
276
|
+
hit.slug,
|
|
277
|
+
retriever.index.sections[hit.sectionIdx],
|
|
278
|
+
retriever.readPage,
|
|
279
|
+
),
|
|
280
|
+
sectionCharCap,
|
|
281
|
+
),
|
|
282
|
+
),
|
|
283
|
+
);
|
|
284
|
+
const parts = entries.filter((entry) => entry.length > 0);
|
|
285
|
+
if (parts.length === 0) {
|
|
223
286
|
return "(no pages retrieved)";
|
|
224
287
|
}
|
|
225
|
-
const parts: string[] = [];
|
|
226
|
-
for (const hit of hits) {
|
|
227
|
-
const raw = retriever.rawBySlug.get(hit.slug) ?? "";
|
|
228
|
-
const card = renderCard(hit.slug, raw);
|
|
229
|
-
const section = retriever.index.sections[hit.sectionIdx];
|
|
230
|
-
if (section) {
|
|
231
|
-
const body = section.text.trim().slice(0, sectionCharCap);
|
|
232
|
-
parts.push(`${card}\n\n${injectedConceptHeader(hit.slug)}\n${body}`);
|
|
233
|
-
} else {
|
|
234
|
-
parts.push(card);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
288
|
return parts.join("\n\n---\n\n");
|
|
238
289
|
}
|
|
239
290
|
|
|
@@ -492,12 +543,12 @@ export async function buildPackets(
|
|
|
492
543
|
for (let i = 0; i < turns.length; i++) {
|
|
493
544
|
const t = turns[i]!;
|
|
494
545
|
const qVec = queryVecs[i] ?? null;
|
|
495
|
-
const snapSet = renderMemorySet(
|
|
546
|
+
const snapSet = await renderMemorySet(
|
|
496
547
|
snapshot,
|
|
497
548
|
snapshot.retrieve(t.userText, qVec, opts.k),
|
|
498
549
|
opts.sectionCharCap,
|
|
499
550
|
);
|
|
500
|
-
const stageSet = renderMemorySet(
|
|
551
|
+
const stageSet = await renderMemorySet(
|
|
501
552
|
staging,
|
|
502
553
|
staging.retrieve(t.userText, qVec, opts.k),
|
|
503
554
|
opts.sectionCharCap,
|
package/src/plugins/types.ts
CHANGED
|
@@ -212,6 +212,20 @@ export interface TurnContext {
|
|
|
212
212
|
* no focus block is appended.
|
|
213
213
|
*/
|
|
214
214
|
readonly slackActiveThreadFocusBlock?: string | null;
|
|
215
|
+
/**
|
|
216
|
+
* True when an injector earlier in the chain has produced the
|
|
217
|
+
* `"replace-run-messages"` block this assembly swaps `runMessages` for: a
|
|
218
|
+
* transcript rendered from persisted rows (the default chain's Slack
|
|
219
|
+
* chronological transcript). The chain walker sets it on the context of
|
|
220
|
+
* every injector that runs after the replacing one, so it is set exactly
|
|
221
|
+
* when the replacement fires and never for a replacing injector that is
|
|
222
|
+
* absent, disabled with its plugin, or gated off for the turn. Content
|
|
223
|
+
* that lives only in message metadata, such as frozen memory blocks
|
|
224
|
+
* rehydrated onto earlier messages, is absent from that prompt, so an
|
|
225
|
+
* injector that would otherwise point at content already resident in
|
|
226
|
+
* history renders it again instead.
|
|
227
|
+
*/
|
|
228
|
+
readonly replacesRunMessages?: boolean;
|
|
215
229
|
/**
|
|
216
230
|
* When true, inject the `<non_interactive_context>` block so the model
|
|
217
231
|
* knows no human is present to answer clarification questions.
|
|
@@ -54,6 +54,7 @@ describe("isConnectionCompatibleWithModel", () => {
|
|
|
54
54
|
|
|
55
55
|
test("oauth_subscription connection is compatible with a Codex model", () => {
|
|
56
56
|
const conn = { auth: oauthAuth };
|
|
57
|
+
expect(isConnectionCompatibleWithModel(conn, "gpt-6-astra")).toBe(true);
|
|
57
58
|
expect(isConnectionCompatibleWithModel(conn, "gpt-5.6-sol")).toBe(true);
|
|
58
59
|
expect(isConnectionCompatibleWithModel(conn, "gpt-5.6-terra")).toBe(true);
|
|
59
60
|
expect(isConnectionCompatibleWithModel(conn, "gpt-5.6-luna")).toBe(true);
|
|
@@ -47,4 +47,8 @@ describe("API_KEY_PROVIDERS", () => {
|
|
|
47
47
|
expect(API_KEY_PROVIDERS).toContain("tavily");
|
|
48
48
|
expect(API_KEY_PROVIDERS).toContain("firecrawl");
|
|
49
49
|
});
|
|
50
|
+
|
|
51
|
+
test("includes custom for OpenAI-compatible memory embeddings", () => {
|
|
52
|
+
expect(API_KEY_PROVIDERS).toContain("custom");
|
|
53
|
+
});
|
|
50
54
|
});
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
salvageXmlToolCalls,
|
|
5
|
+
shouldSalvageXmlToolCalls,
|
|
6
|
+
splitXmlToolCallHoldback,
|
|
7
|
+
} from "../xml-tool-call-salvage.js";
|
|
8
|
+
|
|
9
|
+
const OFFERED = new Set(["bash", "file_read", "ui_show"]);
|
|
10
|
+
|
|
11
|
+
describe("salvageXmlToolCalls", () => {
|
|
12
|
+
test("converts a DeepSeek-style bash invoke into a structured call", () => {
|
|
13
|
+
const text = `Let me actually run the check.
|
|
14
|
+
|
|
15
|
+
<invoke name="bash">
|
|
16
|
+
<parameter name="command">cd /workspace/example && git status</parameter>
|
|
17
|
+
<parameter name="activity">Checking live repo state</parameter>
|
|
18
|
+
<parameter name="timeout_seconds">60</parameter>
|
|
19
|
+
</invoke>`;
|
|
20
|
+
|
|
21
|
+
const salvaged = salvageXmlToolCalls(text, OFFERED);
|
|
22
|
+
expect(salvaged).not.toBeNull();
|
|
23
|
+
expect(salvaged!.text).toBe("Let me actually run the check.");
|
|
24
|
+
expect(salvaged!.calls).toEqual([
|
|
25
|
+
{
|
|
26
|
+
name: "bash",
|
|
27
|
+
input: {
|
|
28
|
+
command: "cd /workspace/example && git status",
|
|
29
|
+
activity: "Checking live repo state",
|
|
30
|
+
timeout_seconds: 60,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("salvages multiple invokes and strips an empty function_calls wrapper", () => {
|
|
37
|
+
const text = `<function_calls>
|
|
38
|
+
<invoke name="file_read">
|
|
39
|
+
<parameter name="path">/workspace/README.md</parameter>
|
|
40
|
+
</invoke>
|
|
41
|
+
<invoke name="bash">
|
|
42
|
+
<parameter name="command">ls</parameter>
|
|
43
|
+
</invoke>
|
|
44
|
+
</function_calls>`;
|
|
45
|
+
|
|
46
|
+
const salvaged = salvageXmlToolCalls(text, OFFERED);
|
|
47
|
+
expect(salvaged!.text).toBe("");
|
|
48
|
+
expect(salvaged!.calls.map((call) => call.name)).toEqual([
|
|
49
|
+
"file_read",
|
|
50
|
+
"bash",
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("leaves unknown tool names as text", () => {
|
|
55
|
+
const text = `<invoke name="not_a_real_tool">
|
|
56
|
+
<parameter name="command">rm -rf /</parameter>
|
|
57
|
+
</invoke>`;
|
|
58
|
+
|
|
59
|
+
expect(salvageXmlToolCalls(text, OFFERED)).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("salvages offered tools and leaves unknown invokes in the leftover text", () => {
|
|
63
|
+
const text = `<invoke name="bash">
|
|
64
|
+
<parameter name="command">pwd</parameter>
|
|
65
|
+
</invoke>
|
|
66
|
+
<invoke name="not_a_real_tool">
|
|
67
|
+
<parameter name="command">nope</parameter>
|
|
68
|
+
</invoke>`;
|
|
69
|
+
|
|
70
|
+
const salvaged = salvageXmlToolCalls(text, OFFERED);
|
|
71
|
+
expect(salvaged!.calls).toEqual([
|
|
72
|
+
{ name: "bash", input: { command: "pwd" } },
|
|
73
|
+
]);
|
|
74
|
+
expect(salvaged!.text).toContain('name="not_a_real_tool"');
|
|
75
|
+
expect(salvaged!.text).not.toContain('name="bash"');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("does not salvage a truncated invoke", () => {
|
|
79
|
+
const text = `<invoke name="bash">
|
|
80
|
+
<parameter name="command">git status</parameter>
|
|
81
|
+
<parameter name="activity">Checking`;
|
|
82
|
+
|
|
83
|
+
expect(salvageXmlToolCalls(text, OFFERED)).toBeNull();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("matches offered tool names case-insensitively", () => {
|
|
87
|
+
const salvaged = salvageXmlToolCalls(
|
|
88
|
+
`<invoke name="Bash"><parameter name="command">echo hi</parameter></invoke>`,
|
|
89
|
+
OFFERED,
|
|
90
|
+
);
|
|
91
|
+
expect(salvaged!.calls[0]?.name).toBe("bash");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("returns null when no tools were offered", () => {
|
|
95
|
+
const text = `<invoke name="bash"><parameter name="command">ls</parameter></invoke>`;
|
|
96
|
+
expect(salvageXmlToolCalls(text, new Set())).toBeNull();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("decodes XML entities in parameter values", () => {
|
|
100
|
+
const salvaged = salvageXmlToolCalls(
|
|
101
|
+
`<invoke name="bash"><parameter name="command">echo "a & b"</parameter></invoke>`,
|
|
102
|
+
OFFERED,
|
|
103
|
+
);
|
|
104
|
+
expect(salvaged!.calls[0]?.input.command).toBe('echo "a & b"');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("leaves invokes inside markdown fences as text", () => {
|
|
108
|
+
const text = `Example:
|
|
109
|
+
|
|
110
|
+
\`\`\`xml
|
|
111
|
+
<invoke name="bash">
|
|
112
|
+
<parameter name="command">ls</parameter>
|
|
113
|
+
</invoke>
|
|
114
|
+
\`\`\``;
|
|
115
|
+
|
|
116
|
+
expect(salvageXmlToolCalls(text, OFFERED)).toBeNull();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("salvages an unfenced invoke next to a fenced example", () => {
|
|
120
|
+
const text = `<invoke name="bash"><parameter name="command">pwd</parameter></invoke>
|
|
121
|
+
|
|
122
|
+
\`\`\`
|
|
123
|
+
<invoke name="file_read"><parameter name="path">/workspace/README.md</parameter></invoke>
|
|
124
|
+
\`\`\``;
|
|
125
|
+
|
|
126
|
+
const salvaged = salvageXmlToolCalls(text, OFFERED);
|
|
127
|
+
expect(salvaged!.calls).toEqual([{ name: "bash", input: { command: "pwd" } }]);
|
|
128
|
+
expect(salvaged!.text).toContain('name="file_read"');
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("shouldSalvageXmlToolCalls", () => {
|
|
133
|
+
test("is true for DeepSeek model ids", () => {
|
|
134
|
+
expect(
|
|
135
|
+
shouldSalvageXmlToolCalls(
|
|
136
|
+
"accounts/fireworks/models/deepseek-v4-flash-0731",
|
|
137
|
+
),
|
|
138
|
+
).toBe(true);
|
|
139
|
+
expect(shouldSalvageXmlToolCalls("deepseek/deepseek-v4-flash")).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("is false for other models", () => {
|
|
143
|
+
expect(shouldSalvageXmlToolCalls("gpt-5.6")).toBe(false);
|
|
144
|
+
expect(shouldSalvageXmlToolCalls("accounts/fireworks/models/minimax-m3")).toBe(
|
|
145
|
+
false,
|
|
146
|
+
);
|
|
147
|
+
expect(shouldSalvageXmlToolCalls(undefined)).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
describe("splitXmlToolCallHoldback", () => {
|
|
152
|
+
test("holds a complete invoke opener and the rest of the buffer", () => {
|
|
153
|
+
expect(splitXmlToolCallHoldback("Sure.\n<invoke name=\"bash\">")).toEqual({
|
|
154
|
+
visible: "Sure.\n",
|
|
155
|
+
held: `<invoke name="bash">`,
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("holds a partial opener split across chunks", () => {
|
|
160
|
+
expect(splitXmlToolCallHoldback("Okay.<inv")).toEqual({
|
|
161
|
+
visible: "Okay.",
|
|
162
|
+
held: "<inv",
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("passes through text with no opener", () => {
|
|
167
|
+
expect(splitXmlToolCallHoldback("Hello there.")).toEqual({
|
|
168
|
+
visible: "Hello there.",
|
|
169
|
+
held: "",
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|