@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
1
3
|
import OpenAI from "openai";
|
|
2
4
|
|
|
3
5
|
import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "../../prompts/cache-boundary.js";
|
|
@@ -9,12 +11,12 @@ import { extractRetryAfterMs } from "../../util/retry.js";
|
|
|
9
11
|
import { partialTagSuffix as sharedPartialTagSuffix } from "../../util/think-tag-stream.js";
|
|
10
12
|
import { clampProviderString } from "../content-block-size.js";
|
|
11
13
|
import { fileBlockToProviderText } from "../file-block-text.js";
|
|
14
|
+
import { requestSupportsInlineAudio } from "../inline-audio-support.js";
|
|
12
15
|
import {
|
|
13
16
|
base64Source,
|
|
14
17
|
mediaSourceByteLength,
|
|
15
18
|
resolveMediaReferences,
|
|
16
19
|
} from "../media-resolve.js";
|
|
17
|
-
import { modelSupportsAudioInput } from "../model-catalog.js";
|
|
18
20
|
import { PLACEHOLDER_EMPTY_TURN } from "../placeholder-sentinels.js";
|
|
19
21
|
import { recordProviderRequestDiagnostics } from "../request-diagnostics.js";
|
|
20
22
|
import { createStreamTimeout } from "../stream-timeout.js";
|
|
@@ -34,6 +36,11 @@ import {
|
|
|
34
36
|
isUnparseableToolArgs,
|
|
35
37
|
wrapUnparseableToolArgs,
|
|
36
38
|
} from "../unparseable-tool-args.js";
|
|
39
|
+
import {
|
|
40
|
+
salvageXmlToolCalls,
|
|
41
|
+
shouldSalvageXmlToolCalls,
|
|
42
|
+
splitXmlToolCallHoldback,
|
|
43
|
+
} from "../xml-tool-call-salvage.js";
|
|
37
44
|
import {
|
|
38
45
|
captureRawErrorBodyFetch,
|
|
39
46
|
formatNormalizedOpenAIAPIError,
|
|
@@ -177,6 +184,12 @@ export interface OpenAIChatCompletionsProviderOptions {
|
|
|
177
184
|
* with minimax-m3 on Fireworks). Off by default; scalars/arrays unaffected.
|
|
178
185
|
* See {@link coerceObjectParamsToJsonString}. */
|
|
179
186
|
coerceObjectArgsToJsonString?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Convert complete `<invoke>` XML in assistant text into `tool_use` blocks.
|
|
189
|
+
* Defaults to on for DeepSeek model ids and off otherwise. Set explicitly to
|
|
190
|
+
* override the model-id default.
|
|
191
|
+
*/
|
|
192
|
+
salvageXmlToolCalls?: boolean;
|
|
180
193
|
/** Drop `tool_choice` when thinking/reasoning is on the wire. Strict
|
|
181
194
|
* OpenAI-compatible reasoning upstreams (DeepSeek thinking mode) reject any
|
|
182
195
|
* explicit `tool_choice` with `Thinking mode does not support this
|
|
@@ -191,7 +204,7 @@ const log = getLogger("chat-completions");
|
|
|
191
204
|
/** Wire-level reasoning_effort values. The OpenAI SDK type doesn't include
|
|
192
205
|
* `"max"`, but Fireworks accepts it for DeepSeek V4; the assignment to
|
|
193
206
|
* `params.reasoning_effort` casts through this union. */
|
|
194
|
-
type ReasoningEffortWire = "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
207
|
+
export type ReasoningEffortWire = "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
195
208
|
|
|
196
209
|
const REASONING_EFFORT_RANK: Record<ReasoningEffortWire, number> = {
|
|
197
210
|
none: 0,
|
|
@@ -692,8 +705,11 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
692
705
|
private requestHeaders: Record<string, string>;
|
|
693
706
|
private parseThinkTags: boolean;
|
|
694
707
|
private assistantReasoningField:
|
|
695
|
-
|
|
708
|
+
| "reasoning"
|
|
709
|
+
| "reasoning_content"
|
|
710
|
+
| undefined;
|
|
696
711
|
private coerceObjectArgsToJsonString: boolean;
|
|
712
|
+
private salvageXmlToolCalls: boolean;
|
|
697
713
|
private omitToolChoiceWhenReasoning: boolean;
|
|
698
714
|
|
|
699
715
|
constructor(
|
|
@@ -722,6 +738,8 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
722
738
|
this.assistantReasoningField = options.assistantReasoningField;
|
|
723
739
|
this.coerceObjectArgsToJsonString =
|
|
724
740
|
options.coerceObjectArgsToJsonString ?? false;
|
|
741
|
+
this.salvageXmlToolCalls =
|
|
742
|
+
options.salvageXmlToolCalls ?? shouldSalvageXmlToolCalls(model);
|
|
725
743
|
this.omitToolChoiceWhenReasoning =
|
|
726
744
|
options.omitToolChoiceWhenReasoning ?? false;
|
|
727
745
|
}
|
|
@@ -740,12 +758,15 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
740
758
|
const modelOverride = configObj?.model as string | undefined;
|
|
741
759
|
const effort = configObj?.effort as string | undefined;
|
|
742
760
|
const logitBias = configObj?.logit_bias as
|
|
743
|
-
Record<string, number>
|
|
761
|
+
| Record<string, number>
|
|
762
|
+
| undefined;
|
|
744
763
|
const topP = configObj?.top_p as number | undefined;
|
|
745
764
|
const usageAttributionHeaders = configObj?.usageAttributionHeaders as
|
|
746
|
-
Record<string, string>
|
|
765
|
+
| Record<string, string>
|
|
766
|
+
| undefined;
|
|
747
767
|
const perRequestHeaders = configObj?.requestHeaders as
|
|
748
|
-
Record<string, string>
|
|
768
|
+
| Record<string, string>
|
|
769
|
+
| undefined;
|
|
749
770
|
|
|
750
771
|
// Per-tool keys whose object schemas were rewritten to JSON strings for the
|
|
751
772
|
// wire, to be decoded back on the response. Empty unless
|
|
@@ -756,7 +777,7 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
756
777
|
const openaiMessages = await this.toOpenAIMessages(
|
|
757
778
|
messages,
|
|
758
779
|
systemPrompt,
|
|
759
|
-
|
|
780
|
+
requestSupportsInlineAudio(modelOverride ?? this.model),
|
|
760
781
|
);
|
|
761
782
|
|
|
762
783
|
recordProviderRequestDiagnostics({
|
|
@@ -812,6 +833,9 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
812
833
|
) as OpenAI.Chat.Completions.ChatCompletionCreateParams["reasoning_effort"];
|
|
813
834
|
}
|
|
814
835
|
|
|
836
|
+
const offeredToolNames = new Set((tools ?? []).map((t) => t.name));
|
|
837
|
+
let xmlToolCallSalvageEnabled = false;
|
|
838
|
+
|
|
815
839
|
if (tools && tools.length > 0) {
|
|
816
840
|
params.tools = tools.map((t) => {
|
|
817
841
|
let parameters = t.input_schema as OpenAI.FunctionParameters;
|
|
@@ -844,6 +868,8 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
844
868
|
// receive them; the generic openai-compatible adapter drops every
|
|
845
869
|
// explicit value in thinking mode via `omitToolChoiceWhenReasoning`.
|
|
846
870
|
const toolChoice = mapNeutralToolChoice(configObj?.tool_choice);
|
|
871
|
+
xmlToolCallSalvageEnabled =
|
|
872
|
+
this.salvageXmlToolCalls && toolChoice !== "none";
|
|
847
873
|
if (toolChoice !== undefined) {
|
|
848
874
|
const thinkingOn = isThinkingEnabledOnWire(params);
|
|
849
875
|
const skipAutoDefault = thinkingOn && toolChoice === "auto";
|
|
@@ -862,6 +888,33 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
862
888
|
let reasoningText = "";
|
|
863
889
|
let insideThinkBlock = false;
|
|
864
890
|
let pendingContent = "";
|
|
891
|
+
let xmlHeld = "";
|
|
892
|
+
|
|
893
|
+
const emitVisibleText = (delta: string): void => {
|
|
894
|
+
if (!delta) {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
if (!xmlToolCallSalvageEnabled) {
|
|
898
|
+
contentText += delta;
|
|
899
|
+
onEvent?.({ type: "text_delta", text: delta });
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const split = splitXmlToolCallHoldback(xmlHeld + delta);
|
|
903
|
+
xmlHeld = split.held;
|
|
904
|
+
if (split.visible) {
|
|
905
|
+
contentText += split.visible;
|
|
906
|
+
onEvent?.({ type: "text_delta", text: split.visible });
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
const flushHeldXmlAsText = (): void => {
|
|
911
|
+
if (!xmlHeld) {
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
contentText += xmlHeld;
|
|
915
|
+
onEvent?.({ type: "text_delta", text: xmlHeld });
|
|
916
|
+
xmlHeld = "";
|
|
917
|
+
};
|
|
865
918
|
|
|
866
919
|
const flushPendingContent = (final: boolean): void => {
|
|
867
920
|
while (pendingContent.length > 0) {
|
|
@@ -896,8 +949,7 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
896
949
|
if (openIdx >= 0) {
|
|
897
950
|
const text = pendingContent.substring(0, openIdx);
|
|
898
951
|
if (text) {
|
|
899
|
-
|
|
900
|
-
onEvent?.({ type: "text_delta", text });
|
|
952
|
+
emitVisibleText(text);
|
|
901
953
|
}
|
|
902
954
|
insideThinkBlock = true;
|
|
903
955
|
pendingContent = pendingContent.substring(
|
|
@@ -909,9 +961,7 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
909
961
|
: partialTagSuffix(pendingContent, "<think>");
|
|
910
962
|
const safeLen = pendingContent.length - partial;
|
|
911
963
|
if (safeLen > 0) {
|
|
912
|
-
|
|
913
|
-
contentText += t;
|
|
914
|
-
onEvent?.({ type: "text_delta", text: t });
|
|
964
|
+
emitVisibleText(pendingContent.substring(0, safeLen));
|
|
915
965
|
}
|
|
916
966
|
pendingContent =
|
|
917
967
|
partial > 0 ? pendingContent.substring(safeLen) : "";
|
|
@@ -940,6 +990,10 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
940
990
|
...(usageAttributionHeaders ?? {}),
|
|
941
991
|
...(perRequestHeaders ?? {}),
|
|
942
992
|
};
|
|
993
|
+
const extraBody = this.buildRequestExtraBody(options);
|
|
994
|
+
if (extraBody) {
|
|
995
|
+
Object.assign(params, extraBody);
|
|
996
|
+
}
|
|
943
997
|
const createStream = () =>
|
|
944
998
|
this.client.chat.completions.create(params, {
|
|
945
999
|
signal: timeoutSignal,
|
|
@@ -1020,8 +1074,7 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
1020
1074
|
pendingContent += choice.delta.content;
|
|
1021
1075
|
flushPendingContent(false);
|
|
1022
1076
|
} else {
|
|
1023
|
-
|
|
1024
|
-
onEvent?.({ type: "text_delta", text: choice.delta.content });
|
|
1077
|
+
emitVisibleText(choice.delta.content);
|
|
1025
1078
|
}
|
|
1026
1079
|
}
|
|
1027
1080
|
|
|
@@ -1142,6 +1195,42 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
1142
1195
|
flushPendingContent(true);
|
|
1143
1196
|
}
|
|
1144
1197
|
|
|
1198
|
+
// DeepSeek (and any caller that sets salvageXmlToolCalls) may emit
|
|
1199
|
+
// `<invoke>` XML as assistant text instead of native `tool_calls`.
|
|
1200
|
+
// Convert complete offered-tool invokes into tool_use blocks so the
|
|
1201
|
+
// agent loop can execute them. Native tool_calls win.
|
|
1202
|
+
if (xmlToolCallSalvageEnabled && toolCallMap.size === 0) {
|
|
1203
|
+
const salvaged = salvageXmlToolCalls(
|
|
1204
|
+
contentText + xmlHeld,
|
|
1205
|
+
offeredToolNames,
|
|
1206
|
+
);
|
|
1207
|
+
if (salvaged) {
|
|
1208
|
+
contentText = salvaged.text;
|
|
1209
|
+
xmlHeld = "";
|
|
1210
|
+
log.info(
|
|
1211
|
+
{
|
|
1212
|
+
salvagedToolCount: salvaged.calls.length,
|
|
1213
|
+
salvagedToolNames: salvaged.calls.map((call) => call.name),
|
|
1214
|
+
},
|
|
1215
|
+
"Converted XML-formatted assistant text into native tool calls",
|
|
1216
|
+
);
|
|
1217
|
+
for (const [index, call] of salvaged.calls.entries()) {
|
|
1218
|
+
toolCallMap.set(index, {
|
|
1219
|
+
id: `call_${randomUUID()}`,
|
|
1220
|
+
name: call.name,
|
|
1221
|
+
args: JSON.stringify(call.input),
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
if (finishReason === "stop" || finishReason === "unknown") {
|
|
1225
|
+
finishReason = "tool_calls";
|
|
1226
|
+
}
|
|
1227
|
+
} else {
|
|
1228
|
+
flushHeldXmlAsText();
|
|
1229
|
+
}
|
|
1230
|
+
} else {
|
|
1231
|
+
flushHeldXmlAsText();
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1145
1234
|
// Build content blocks
|
|
1146
1235
|
const finalReasoning = this.parseThinkTags
|
|
1147
1236
|
? reasoningText.trim()
|
|
@@ -1362,6 +1451,17 @@ export class OpenAIChatCompletionsProvider implements Provider {
|
|
|
1362
1451
|
return this.extraCreateParams;
|
|
1363
1452
|
}
|
|
1364
1453
|
|
|
1454
|
+
/**
|
|
1455
|
+
* Fields merged onto the `chat.completions.create` params object. The
|
|
1456
|
+
* OpenAI Node SDK sends unknown body fields as-is, so hosted-Qwen
|
|
1457
|
+
* `directions` reach the runtime proxy on the JSON body.
|
|
1458
|
+
*/
|
|
1459
|
+
protected buildRequestExtraBody(
|
|
1460
|
+
_options?: SendMessageOptions,
|
|
1461
|
+
): Record<string, unknown> | undefined {
|
|
1462
|
+
return undefined;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1365
1465
|
/**
|
|
1366
1466
|
* Per-request reasoning_effort ceiling. Defaults to the provider-wide
|
|
1367
1467
|
* `maxReasoningEffort` from constructor options. Subclasses (e.g. Fireworks)
|
|
@@ -8,7 +8,11 @@ import { extractRetryAfterMs } from "../../util/retry.js";
|
|
|
8
8
|
import { clampProviderString } from "../content-block-size.js";
|
|
9
9
|
import { fileBlockToProviderText } from "../file-block-text.js";
|
|
10
10
|
import { base64Source, resolveMediaReferences } from "../media-resolve.js";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
modelEffortCeilings,
|
|
13
|
+
modelSupportedEfforts,
|
|
14
|
+
PROMPT_CACHE_BREAKPOINT_MODEL_IDS,
|
|
15
|
+
} from "../model-catalog.js";
|
|
12
16
|
import { recordProviderRequestDiagnostics } from "../request-diagnostics.js";
|
|
13
17
|
import { createStreamTimeout } from "../stream-timeout.js";
|
|
14
18
|
import { createToolProgressEmitter } from "../tool-progress-events.js";
|
|
@@ -26,7 +30,12 @@ import {
|
|
|
26
30
|
formatNormalizedOpenAIAPIError,
|
|
27
31
|
normalizeOpenAIAPIError,
|
|
28
32
|
} from "./api-error-normalization.js";
|
|
29
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
clampReasoningEffort,
|
|
35
|
+
detectOpenAICompatibleContextOverflow,
|
|
36
|
+
type ReasoningEffortWire,
|
|
37
|
+
snapReasoningEffortToSupported,
|
|
38
|
+
} from "./chat-completions-provider.js";
|
|
30
39
|
import { serializeToolResult } from "./orphaned-tool-result.js";
|
|
31
40
|
|
|
32
41
|
const log = getLogger("openai-responses");
|
|
@@ -46,22 +55,63 @@ export interface OpenAIResponsesProviderOptions {
|
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
/** Map our internal effort values to the Responses API reasoning.effort parameter.
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
> = {
|
|
58
|
+
* `"max"` is emitted raw and then clamped to the model's catalog ceiling
|
|
59
|
+
* ({@link mapResponsesReasoningEffort}); models that omit `maxEffort`
|
|
60
|
+
* inherit OpenAI's historical `xhigh` cap. `"none"` is passed through
|
|
61
|
+
* explicitly because OpenAI defaults `reasoning.effort` to "medium" when
|
|
62
|
+
* the field is omitted, except on models whose `supportedEfforts` omit
|
|
63
|
+
* `none` (those snap to the lowest accepted value). */
|
|
64
|
+
const EFFORT_TO_REASONING_EFFORT: Record<string, ReasoningEffortWire> = {
|
|
57
65
|
none: "none",
|
|
58
66
|
low: "low",
|
|
59
67
|
medium: "medium",
|
|
60
68
|
high: "high",
|
|
61
69
|
xhigh: "xhigh",
|
|
62
|
-
max: "
|
|
70
|
+
max: "max",
|
|
63
71
|
};
|
|
64
72
|
|
|
73
|
+
const OPENAI_EFFORT_CEILINGS = modelEffortCeilings("openai");
|
|
74
|
+
const OPENROUTER_EFFORT_CEILINGS = modelEffortCeilings("openrouter");
|
|
75
|
+
const OPENAI_SUPPORTED_EFFORTS = modelSupportedEfforts("openai");
|
|
76
|
+
const OPENROUTER_SUPPORTED_EFFORTS = modelSupportedEfforts("openrouter");
|
|
77
|
+
|
|
78
|
+
function effortCeilingForModel(model: string): "high" | "xhigh" | "max" {
|
|
79
|
+
return (
|
|
80
|
+
OPENAI_EFFORT_CEILINGS.get(model) ??
|
|
81
|
+
OPENROUTER_EFFORT_CEILINGS.get(model) ??
|
|
82
|
+
"xhigh"
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function supportedEffortsForModel(
|
|
87
|
+
model: string,
|
|
88
|
+
): readonly ("low" | "medium" | "high" | "xhigh" | "max")[] | undefined {
|
|
89
|
+
return (
|
|
90
|
+
OPENAI_SUPPORTED_EFFORTS.get(model) ??
|
|
91
|
+
OPENROUTER_SUPPORTED_EFFORTS.get(model)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Translate a Vellum effort value onto the Responses wire for `model`. */
|
|
96
|
+
function mapResponsesReasoningEffort(
|
|
97
|
+
effort: string,
|
|
98
|
+
model: string,
|
|
99
|
+
): ReasoningEffortWire | undefined {
|
|
100
|
+
const raw = EFFORT_TO_REASONING_EFFORT[effort];
|
|
101
|
+
if (!raw) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const supported = supportedEffortsForModel(model);
|
|
105
|
+
if (raw === "none") {
|
|
106
|
+
if (supported && supported.length > 0) {
|
|
107
|
+
return supported[0];
|
|
108
|
+
}
|
|
109
|
+
return "none";
|
|
110
|
+
}
|
|
111
|
+
const clamped = clampReasoningEffort(raw, effortCeilingForModel(model));
|
|
112
|
+
return supported ? snapReasoningEffortToSupported(clamped, supported) : clamped;
|
|
113
|
+
}
|
|
114
|
+
|
|
65
115
|
/** Values accepted by the Responses API `text.verbosity` parameter. */
|
|
66
116
|
const VALID_VERBOSITIES = new Set<string>(["low", "medium", "high"]);
|
|
67
117
|
|
|
@@ -102,15 +152,15 @@ export function mapNeutralToolChoiceForResponses(
|
|
|
102
152
|
}
|
|
103
153
|
}
|
|
104
154
|
|
|
105
|
-
/** `text.verbosity` is a GPT-5-series
|
|
155
|
+
/** `text.verbosity` is a GPT-5/GPT-6-series parameter. Older models on the
|
|
106
156
|
* Responses API (o-series, etc.) reject unknown wire fields with HTTP 400, so
|
|
107
157
|
* gate forwarding by model name here. The retry layer can't make this call
|
|
108
158
|
* because verbosity defaults to "medium" in the LLM schema, so every
|
|
109
159
|
* callSite-resolved request would otherwise carry it regardless of model.
|
|
110
160
|
* Also matches OpenAI fine-tune IDs of the form `ft:gpt-5.x:org::id` so users
|
|
111
|
-
* on GPT-5 fine-tunes keep explicit verbosity control. */
|
|
161
|
+
* on GPT-5/GPT-6 fine-tunes keep explicit verbosity control. */
|
|
112
162
|
function modelSupportsVerbosity(model: string): boolean {
|
|
113
|
-
return /^(ft:)?gpt-
|
|
163
|
+
return /^(ft:)?gpt-[56](\b|[-.])/i.test(model);
|
|
114
164
|
}
|
|
115
165
|
|
|
116
166
|
/** Loosely-typed Responses stream event to avoid `any` while the SDK types settle. */
|
|
@@ -295,7 +345,7 @@ export class OpenAIResponsesProvider implements Provider {
|
|
|
295
345
|
}
|
|
296
346
|
|
|
297
347
|
const reasoningEffort = effort
|
|
298
|
-
?
|
|
348
|
+
? mapResponsesReasoningEffort(effort, effectiveModel)
|
|
299
349
|
: undefined;
|
|
300
350
|
if (reasoningEffort) {
|
|
301
351
|
// Request a human-readable reasoning summary whenever the model will
|
|
@@ -47,6 +47,30 @@ describe("buildOpenCodeRequestHeaders", () => {
|
|
|
47
47
|
expect(headers).not.toHaveProperty("session_id");
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
test("falls back to the stable device id when there is no conversation", () => {
|
|
51
|
+
expect(
|
|
52
|
+
buildOpenCodeRequestHeaders({ fallbackSessionId: "dev-123" }),
|
|
53
|
+
).toEqual({ [OPENCODE_SESSION_HEADER]: "dev-123" });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("conversation id wins over the fallback session id", () => {
|
|
57
|
+
expect(
|
|
58
|
+
buildOpenCodeRequestHeaders({
|
|
59
|
+
conversationId: "conv-xyz",
|
|
60
|
+
fallbackSessionId: "dev-123",
|
|
61
|
+
}),
|
|
62
|
+
).toEqual({ [OPENCODE_SESSION_HEADER]: "conv-xyz" });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("blank conversation id falls through to the fallback session id", () => {
|
|
66
|
+
expect(
|
|
67
|
+
buildOpenCodeRequestHeaders({
|
|
68
|
+
conversationId: " ",
|
|
69
|
+
fallbackSessionId: "dev-123",
|
|
70
|
+
}),
|
|
71
|
+
).toEqual({ [OPENCODE_SESSION_HEADER]: "dev-123" });
|
|
72
|
+
});
|
|
73
|
+
|
|
50
74
|
test("sets only the ids that are present", () => {
|
|
51
75
|
expect(
|
|
52
76
|
buildOpenCodeRequestHeaders({ conversationId: "conv-xyz" }),
|
|
@@ -26,13 +26,18 @@ export function resolveOpenCodeBaseURL(configuredBaseURL?: string): string {
|
|
|
26
26
|
* OpenCode-owned request headers for support lookup. Sends session and
|
|
27
27
|
* request ids only when they exist. Never sets `session_id` (zen/go
|
|
28
28
|
* returns 500 when that header is present).
|
|
29
|
+
*
|
|
30
|
+
* `conversationId` wins for the session header; `fallbackSessionId` (a
|
|
31
|
+
* stable per-device ID supplied by the caller) covers non-conversation
|
|
32
|
+
* background calls so they still identify a session to zen/go.
|
|
29
33
|
*/
|
|
30
34
|
export function buildOpenCodeRequestHeaders(opts: {
|
|
31
35
|
conversationId?: string;
|
|
36
|
+
fallbackSessionId?: string;
|
|
32
37
|
requestId?: string;
|
|
33
38
|
}): Record<string, string> {
|
|
34
39
|
const headers: Record<string, string> = {};
|
|
35
|
-
const session = opts.conversationId?.trim();
|
|
40
|
+
const session = opts.conversationId?.trim() || opts.fallbackSessionId?.trim();
|
|
36
41
|
if (session) {
|
|
37
42
|
headers[OPENCODE_SESSION_HEADER] = session;
|
|
38
43
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Canonical source for API-key-addressable providers.
|
|
3
3
|
*
|
|
4
4
|
* This module composes the full set of providers that store API keys in
|
|
5
|
-
* secure storage (the `api_key` secret type) from
|
|
5
|
+
* secure storage (the `api_key` secret type) from five sources:
|
|
6
6
|
*
|
|
7
7
|
* 1. **LLM providers** -- derived from `PROVIDER_CATALOG`
|
|
8
8
|
* (`model-catalog.ts`). Adding a provider to the catalog automatically
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* 4. **TTS catalog providers** -- dynamically derived from the canonical
|
|
16
16
|
* TTS provider catalog by selecting entries whose secret requirements
|
|
17
17
|
* use the bare-name (non-credential) storage convention.
|
|
18
|
+
* 5. **Embedding-only providers** -- currently `custom`, the
|
|
19
|
+
* OpenAI-compatible memory embeddings endpoint.
|
|
18
20
|
*
|
|
19
21
|
* Consumers that need the set of valid API-key provider names should
|
|
20
22
|
* import {@link API_KEY_PROVIDERS} from this module rather than
|
|
@@ -116,6 +118,13 @@ function catalogApiKeyNames(): string[] {
|
|
|
116
118
|
);
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Embedding-only API-key names. `custom` is the OpenAI-compatible memory
|
|
123
|
+
* embeddings provider and is not an LLM catalog entry, so it is declared
|
|
124
|
+
* here rather than in `PROVIDER_CATALOG`.
|
|
125
|
+
*/
|
|
126
|
+
const EMBEDDING_API_KEY_PROVIDERS: readonly string[] = ["custom"];
|
|
127
|
+
|
|
119
128
|
// ---------------------------------------------------------------------------
|
|
120
129
|
// Unified export
|
|
121
130
|
// ---------------------------------------------------------------------------
|
|
@@ -148,6 +157,7 @@ export const API_KEY_PROVIDERS: readonly string[] = (() => {
|
|
|
148
157
|
...LLM_AND_SEARCH_API_KEY_PROVIDERS,
|
|
149
158
|
...sttApiKeyProviderNames(),
|
|
150
159
|
...catalogApiKeyNames(),
|
|
160
|
+
...EMBEDDING_API_KEY_PROVIDERS,
|
|
151
161
|
]) {
|
|
152
162
|
if (!seen.has(name)) {
|
|
153
163
|
seen.add(name);
|
package/src/providers/retry.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
sanitizeUsageMetadataValue,
|
|
11
11
|
} from "../usage/attribution.js";
|
|
12
12
|
import { resolveSubagentAttribution } from "../usage/subagent-attribution.js";
|
|
13
|
+
import { getExistingDeviceId } from "../util/device-id.js";
|
|
13
14
|
import {
|
|
14
15
|
type ProviderCredentialSource,
|
|
15
16
|
ProviderError,
|
|
@@ -647,6 +648,11 @@ function normalizeSendMessageOptions(
|
|
|
647
648
|
: undefined;
|
|
648
649
|
const requestHeaders = buildOpenCodeRequestHeaders({
|
|
649
650
|
conversationId,
|
|
651
|
+
// Background call paths (memory/commit-message enrichment,
|
|
652
|
+
// proactivity, workflow runs) have no conversationId - reuse the
|
|
653
|
+
// existing stable per-device ID so those requests still carry a
|
|
654
|
+
// session header instead of persisting a new ID for this purpose.
|
|
655
|
+
fallbackSessionId: getExistingDeviceId() ?? undefined,
|
|
650
656
|
requestId: randomUUID(),
|
|
651
657
|
});
|
|
652
658
|
if (Object.keys(requestHeaders).length > 0) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { getWorkspaceDir } from "../../util/platform.js";
|
|
1
2
|
import { OpenAIChatCompletionsProvider } from "../openai/chat-completions-provider.js";
|
|
3
|
+
import type { SendMessageOptions } from "../types.js";
|
|
4
|
+
import { hostedDirectionsExtraBody } from "./personality-directions.js";
|
|
2
5
|
|
|
3
6
|
export interface VellumProviderOptions {
|
|
4
7
|
apiKey?: string;
|
|
@@ -7,7 +10,7 @@ export interface VellumProviderOptions {
|
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
|
-
* OpenAI-compatible client for Vellum-hosted GPU inference
|
|
13
|
+
* OpenAI-compatible client for Vellum-hosted GPU inference.
|
|
11
14
|
* Managed requests set `baseURL` to the platform `/v1/runtime-proxy/vellum`
|
|
12
15
|
* path and authenticate with the assistant API key. These models have no
|
|
13
16
|
* bring-your-own-key path.
|
|
@@ -26,4 +29,14 @@ export class VellumProvider extends OpenAIChatCompletionsProvider {
|
|
|
26
29
|
...(options.baseURL ? { baseURL: options.baseURL } : {}),
|
|
27
30
|
});
|
|
28
31
|
}
|
|
32
|
+
|
|
33
|
+
protected override buildRequestExtraBody(
|
|
34
|
+
options?: SendMessageOptions,
|
|
35
|
+
): Record<string, unknown> | undefined {
|
|
36
|
+
const config = options?.config as { model?: string } | undefined;
|
|
37
|
+
return hostedDirectionsExtraBody(
|
|
38
|
+
config?.model ?? this.defaultModel,
|
|
39
|
+
getWorkspaceDir(),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
29
42
|
}
|