@vellumai/assistant 0.10.7 → 0.10.8-dev.202607102228.5945895
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/AGENTS.md +3 -1
- package/ARCHITECTURE.md +9 -9
- package/README.md +1 -1
- package/docs/architecture/memory.md +1 -3
- package/docs/credential-execution-service.md +9 -96
- package/docs/runbook-trusted-contacts.md +132 -93
- package/docs/trusted-contact-access.md +125 -115
- package/docs/workspace-tools.md +4 -2
- package/eslint-rules/__tests__/cli-no-daemon-internals.test.ts +62 -360
- package/eslint-rules/cli-no-daemon-internals.js +91 -269
- package/eslint.config.mjs +4 -4
- package/knip.json +2 -1
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +1 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +104 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +118 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +1 -2
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +104 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +118 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/node_modules/@vellumai/gateway-client/src/__tests__/invite-contract.test.ts +0 -18
- package/node_modules/@vellumai/gateway-client/src/__tests__/trust-verdict-contract.test.ts +40 -6
- package/node_modules/@vellumai/gateway-client/src/channel-permission-contract.ts +13 -0
- package/node_modules/@vellumai/gateway-client/src/index.ts +24 -2
- package/node_modules/@vellumai/gateway-client/src/invite-contract.ts +146 -16
- package/node_modules/@vellumai/gateway-client/src/trust-verdict-contract.ts +22 -4
- package/node_modules/@vellumai/service-contracts/package.json +1 -2
- package/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +104 -0
- package/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +118 -0
- package/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/openapi.yaml +1648 -676
- package/package.json +4 -5
- package/scripts/build-test-fixtures.ts +105 -0
- package/scripts/memory-inspect.ts +2 -8
- package/scripts/test.ts +597 -0
- package/src/__tests__/access-request-card-view.test.ts +38 -0
- package/src/__tests__/activation-early-marking.test.ts +1 -8
- package/src/__tests__/actor-token-service.test.ts +1 -22
- package/src/__tests__/add-message-preassigned-id.test.ts +1 -1
- package/src/__tests__/agent-image-optimize.test.ts +104 -1
- package/src/__tests__/agent-loop-callsite-precedence.test.ts +0 -5
- package/src/__tests__/agent-loop-compaction-events.test.ts +1 -1
- package/src/__tests__/agent-loop-compaction-strip.test.ts +1 -1
- package/src/__tests__/agent-loop-exit-reason.test.ts +1 -1
- package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +0 -6
- package/src/__tests__/agent-loop-override-profile.test.ts +66 -5
- package/src/__tests__/agent-loop-pushes-post-hook-prompt.test.ts +1 -9
- package/src/__tests__/agent-loop-regrowth-guard.test.ts +1 -1
- package/src/__tests__/agent-loop-set-system-prompt.test.ts +1 -7
- package/src/__tests__/agent-wake-disk-pressure-callsite.test.ts +1 -0
- package/src/__tests__/agent-wake-override-profile.test.ts +21 -1
- package/src/__tests__/annotate-activity-metadata.test.ts +4 -10
- package/src/__tests__/annotate-risk-options.test.ts +4 -10
- package/src/__tests__/anthropic-error-formatting.test.ts +193 -2
- package/src/__tests__/anthropic-gateway-shared.test.ts +140 -0
- package/src/__tests__/anthropic-provider.test.ts +58 -0
- package/src/__tests__/app-bundler.test.ts +0 -8
- package/src/__tests__/app-conversation-ids-backfill.test.ts +1 -8
- package/src/__tests__/app-routes-csp.test.ts +0 -8
- package/src/__tests__/approval-cascade.test.ts +0 -21
- package/src/__tests__/approval-interception-trust-gates.test.ts +0 -7
- package/src/__tests__/approval-primitive.test.ts +1 -9
- package/src/__tests__/approval-routes-http.test.ts +1 -16
- package/src/__tests__/assistant-attachment-directive.test.ts +1 -0
- package/src/__tests__/assistant-attachments.test.ts +211 -0
- package/src/__tests__/assistant-event-hub-machine-name.test.ts +0 -7
- package/src/__tests__/assistant-events-sse-hardening.test.ts +0 -7
- package/src/__tests__/assistant-feature-flag-guard.test.ts +3 -3
- package/src/__tests__/assistant-feature-flag-guardrails.test.ts +1 -1
- package/src/__tests__/attachment-stored-path-annotation.test.ts +0 -7
- package/src/__tests__/attachment-upload-trusted-source.test.ts +0 -7
- package/src/__tests__/attachments-store-heic-normalize.test.ts +0 -7
- package/src/__tests__/attachments-store.test.ts +43 -8
- package/src/__tests__/attachments.test.ts +77 -0
- package/src/__tests__/audit-log-rotation.test.ts +1 -9
- package/src/__tests__/auth-fallback-events-store.test.ts +0 -7
- package/src/__tests__/available-skills.test.ts +266 -0
- package/src/__tests__/avatar-generator.test.ts +0 -9
- package/src/__tests__/background-shell-host-bash.test.ts +0 -7
- package/src/__tests__/background-workers-disk-pressure.test.ts +4 -3
- package/src/__tests__/browser-fill-credential.test.ts +0 -7
- package/src/__tests__/browser-manager.test.ts +1 -8
- package/src/__tests__/btw-routes.test.ts +0 -7
- package/src/__tests__/build-persisted-content.test.ts +0 -8
- package/src/__tests__/call-constants.test.ts +1 -1
- package/src/__tests__/call-controller.test.ts +783 -34
- package/src/__tests__/call-conversation-messages.test.ts +2 -9
- package/src/__tests__/call-domain.test.ts +7 -24
- package/src/__tests__/call-pointer-message-composer.test.ts +0 -8
- package/src/__tests__/call-pointer-messages.test.ts +1 -8
- package/src/__tests__/call-recovery.test.ts +1 -8
- package/src/__tests__/call-routes-http.test.ts +0 -7
- package/src/__tests__/call-setup-flow-invite.test.ts +1 -1
- package/src/__tests__/call-setup-flow-midcall-trust.test.ts +76 -97
- package/src/__tests__/call-setup-flow-name-capture.test.ts +1 -1
- package/src/__tests__/call-setup-flow-verification.test.ts +1 -1
- package/src/__tests__/call-setup-flow.test.ts +2 -2
- package/src/__tests__/call-site-routing-provider.test.ts +1 -5
- package/src/__tests__/call-state.test.ts +1 -8
- package/src/__tests__/call-store.test.ts +1 -8
- package/src/__tests__/cancel-resolves-conversation-key.test.ts +0 -7
- package/src/__tests__/canonical-guardian-store.test.ts +1 -8
- package/src/__tests__/catalog-cache.test.ts +0 -8
- package/src/__tests__/catalog-files.test.ts +0 -8
- package/src/__tests__/catalog-install-normalize.test.ts +0 -7
- package/src/__tests__/ces-rpc-credential-backend.test.ts +0 -7
- package/src/__tests__/channel-approval-routes.test.ts +0 -7
- package/src/__tests__/channel-approvals.test.ts +0 -7
- package/src/__tests__/channel-delivery-store.test.ts +0 -7
- package/src/__tests__/channel-guardian.test.ts +29 -16
- package/src/__tests__/channel-inbound-disk-pressure.test.ts +0 -7
- package/src/__tests__/channel-reply-delivery.test.ts +18 -5
- package/src/__tests__/channel-retry-sweep.test.ts +0 -7
- package/src/__tests__/clawhub-files.test.ts +0 -8
- package/src/__tests__/clawhub.test.ts +0 -7
- package/src/__tests__/clear-all-lexical.test.ts +0 -6
- package/src/__tests__/client-os-metadata-persistence.test.ts +0 -5
- package/src/__tests__/compaction-direct.test.ts +47 -0
- package/src/__tests__/compaction-events.test.ts +14 -29
- package/src/__tests__/compaction-ledger-store.test.ts +1 -7
- package/src/__tests__/compaction-summary-head-persisted-count.test.ts +417 -0
- package/src/__tests__/compaction-trail-store.test.ts +2 -8
- package/src/__tests__/compaction.benchmark.test.ts +0 -5
- package/src/__tests__/compactor-call-site-logging.test.ts +0 -21
- package/src/__tests__/compactor-fixed-boundary.test.ts +334 -0
- package/src/__tests__/compactor-low-watermark-cut.test.ts +8 -23
- package/src/__tests__/compactor-media-strip.test.ts +0 -21
- package/src/__tests__/compactor-preserved-tail-count.test.ts +0 -21
- package/src/__tests__/compactor-summary-call-truncation.test.ts +0 -21
- package/src/__tests__/compactor-web-search-strip.test.ts +21 -25
- package/src/__tests__/config-get-vision-flag.test.ts +0 -6
- package/src/__tests__/config-loader-backfill.test.ts +332 -316
- package/src/__tests__/config-loader-platform-defaults.test.ts +0 -21
- package/src/__tests__/config-loader-validation-reset-notice.test.ts +183 -0
- package/src/__tests__/config-schema.test.ts +85 -30
- package/src/__tests__/config-set-route.test.ts +0 -6
- package/src/__tests__/config-watcher-cleanup-throttle.test.ts +12 -24
- package/src/__tests__/config-watcher-skill-reseed.test.ts +1 -8
- package/src/__tests__/config-watcher.test.ts +22 -12
- package/src/__tests__/confirmation-request-guardian-bridge.test.ts +1 -9
- package/src/__tests__/contact-store-interaction-info.test.ts +1 -8
- package/src/__tests__/contact-store-user-file.test.ts +1 -14
- package/src/__tests__/contacts-tools.test.ts +0 -7
- package/src/__tests__/contacts-write.test.ts +1 -8
- package/src/__tests__/context-search-memory-source.test.ts +0 -1
- package/src/__tests__/context-search-memory-v2-source.test.ts +0 -6
- package/src/__tests__/context-window-manager-compact-retry.test.ts +118 -21
- package/src/__tests__/context-window-manager-overflow-rung.test.ts +0 -21
- package/src/__tests__/conversation-abort-tool-results.test.ts +0 -5
- package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +0 -12
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +5 -12
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +45 -21
- package/src/__tests__/conversation-agent-loop.test.ts +192 -70
- package/src/__tests__/conversation-app-control-instantiation.test.ts +20 -8
- package/src/__tests__/conversation-app-control-lifecycle.test.ts +0 -9
- package/src/__tests__/conversation-attachments.test.ts +1 -7
- package/src/__tests__/conversation-attention-store.test.ts +1 -9
- package/src/__tests__/conversation-attention-telegram.test.ts +0 -8
- package/src/__tests__/conversation-clear-safety.test.ts +0 -7
- package/src/__tests__/conversation-confirmation-signals.test.ts +0 -21
- package/src/__tests__/conversation-crud-enabled-plugins.test.ts +1 -7
- package/src/__tests__/conversation-crud-inference-profile.test.ts +1 -7
- package/src/__tests__/conversation-delete-schedule-cleanup.test.ts +0 -7
- package/src/__tests__/conversation-disk-view-integration.test.ts +0 -7
- package/src/__tests__/conversation-disk-view.test.ts +0 -7
- package/src/__tests__/conversation-enabledplugins-route.test.ts +2 -8
- package/src/__tests__/conversation-error.test.ts +299 -3
- package/src/__tests__/conversation-fork-crud.test.ts +52 -37
- package/src/__tests__/conversation-fork-retrospective.test.ts +486 -7
- package/src/__tests__/conversation-fork-route.test.ts +0 -7
- package/src/__tests__/conversation-history-web-search.test.ts +39 -17
- package/src/__tests__/conversation-inference-profile-list.test.ts +0 -6
- package/src/__tests__/conversation-inference-profile-route.test.ts +0 -5
- package/src/__tests__/conversation-init.benchmark.test.ts +6 -2
- package/src/__tests__/conversation-initial-prompt.test.ts +1 -1
- package/src/__tests__/conversation-key-store-disk-view.test.ts +0 -7
- package/src/__tests__/conversation-lifecycle.test.ts +108 -62
- package/src/__tests__/conversation-list-source.test.ts +0 -7
- package/src/__tests__/conversation-load-history-repair.test.ts +39 -53
- package/src/__tests__/conversation-load-history-stripped.test.ts +12 -19
- package/src/__tests__/conversation-loop-db-lock-resilience.test.ts +10 -15
- package/src/__tests__/conversation-message-id-uuidv7.test.ts +73 -0
- package/src/__tests__/conversation-pairing.test.ts +0 -7
- package/src/__tests__/conversation-process-app-control-preactivation.test.ts +0 -5
- package/src/__tests__/conversation-process-callsite.test.ts +14 -7
- package/src/__tests__/conversation-provider-retry-repair.test.ts +0 -5
- package/src/__tests__/conversation-queue.test.ts +91 -21
- package/src/__tests__/conversation-routes-disk-view.test.ts +0 -11
- package/src/__tests__/conversation-routes-enabled-plugins.test.ts +3 -11
- package/src/__tests__/conversation-routes-guardian-reply.test.ts +3 -11
- package/src/__tests__/conversation-routes-hidden-queue.test.ts +3 -11
- package/src/__tests__/conversation-routes-slash-commands.test.ts +24 -13
- package/src/__tests__/conversation-runtime-assembly.test.ts +37 -9
- package/src/__tests__/conversation-skill-tools.test.ts +31 -15
- package/src/__tests__/conversation-slash-commands.test.ts +5 -4
- package/src/__tests__/conversation-slash-queue.test.ts +0 -5
- package/src/__tests__/conversation-slash-unknown.test.ts +0 -5
- package/src/__tests__/conversation-speed-override.test.ts +13 -23
- package/src/__tests__/conversation-starter-routes.test.ts +0 -7
- package/src/__tests__/conversation-store.test.ts +9 -22
- package/src/__tests__/conversation-summarize-route.test.ts +445 -0
- package/src/__tests__/conversation-summarize-up-to.test.ts +711 -0
- package/src/__tests__/conversation-surfaces-activation-emit.test.ts +0 -8
- package/src/__tests__/conversation-surfaces-data-persist.test.ts +4 -2
- package/src/__tests__/conversation-title-service.test.ts +0 -7
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +0 -19
- package/src/__tests__/conversation-tool-setup-attribution.test.ts +4 -8
- package/src/__tests__/conversation-unread-route.test.ts +0 -7
- package/src/__tests__/conversation-usage.test.ts +10 -8
- package/src/__tests__/conversation-wait-for-idle.test.ts +391 -0
- package/src/__tests__/conversation-workspace-cache-state.test.ts +0 -5
- package/src/__tests__/conversation-workspace-injection.test.ts +0 -5
- package/src/__tests__/conversation-workspace-tool-tracking.test.ts +0 -5
- package/src/__tests__/conversations-import-system-filter.test.ts +0 -7
- package/src/__tests__/credential-broker-browser-fill.test.ts +0 -9
- package/src/__tests__/credential-broker-server-use.test.ts +0 -9
- package/src/__tests__/credential-execution-api-key-propagation.test.ts +0 -40
- package/src/__tests__/credential-execution-client.test.ts +3 -38
- package/src/__tests__/credential-execution-managed-contract.test.ts +10 -106
- package/src/__tests__/credential-health-service.test.ts +0 -9
- package/src/__tests__/credential-metadata-store.test.ts +0 -8
- package/src/__tests__/credential-prompt-route.test.ts +80 -9
- package/src/__tests__/credential-request-route.test.ts +76 -0
- package/src/__tests__/credential-resolve.test.ts +0 -8
- package/src/__tests__/credential-security-invariants.test.ts +3 -10
- package/src/__tests__/credential-token-resolver.test.ts +0 -9
- package/src/__tests__/custom-profile-ensure.test.ts +232 -0
- package/src/__tests__/daemon-assistant-events.test.ts +1 -9
- package/src/__tests__/daemon-credential-client.test.ts +0 -7
- package/src/__tests__/db-conversation-fork-lineage-migration.test.ts +1 -8
- package/src/__tests__/db-conversation-inference-profile-migration.test.ts +1 -7
- package/src/__tests__/db-llm-request-log-provider-migration.test.ts +0 -8
- package/src/__tests__/db-processing-resume-attempts-migration.test.ts +116 -0
- package/src/__tests__/db-readiness-http-gate.test.ts +0 -7
- package/src/__tests__/db-rename-inference-profile-snake-case-migration.test.ts +1 -7
- package/src/__tests__/default-provider-ensure.test.ts +343 -0
- package/src/__tests__/delete-managed-skill-tool.test.ts +0 -7
- package/src/__tests__/delete-propagation.test.ts +0 -7
- package/src/__tests__/deterministic-verification-control-plane.test.ts +0 -7
- package/src/__tests__/device-id.test.ts +1 -9
- package/src/__tests__/disk-pressure-tools.test.ts +0 -4
- package/src/__tests__/dm-backfill.test.ts +0 -7
- package/src/__tests__/dm-persistence.test.ts +0 -5
- package/src/__tests__/docker-signing-key-bootstrap.test.ts +1 -8
- package/src/__tests__/drain-requeue-on-contention.test.ts +202 -0
- package/src/__tests__/dynamic-skill-background-guard.test.ts +174 -0
- package/src/__tests__/edit-propagation.test.ts +1 -8
- package/src/__tests__/embedding-managed-proxy-selection.test.ts +0 -8
- package/src/__tests__/emit-signal-routing-intent.test.ts +175 -7
- package/src/__tests__/encrypted-store.test.ts +0 -9
- package/src/__tests__/ensure-conversation-exists.test.ts +85 -0
- package/src/__tests__/events-client-registration.test.ts +0 -7
- package/src/__tests__/events-dev-bypass-actor.test.ts +2 -9
- package/src/__tests__/events-tail-route.test.ts +172 -0
- package/src/__tests__/file-write-tool.test.ts +9 -13
- package/src/__tests__/followup-tools.test.ts +0 -7
- package/src/__tests__/gateway-flag-listener.test.ts +2 -23
- package/src/__tests__/gemini-inline-media.test.ts +2 -2
- package/src/__tests__/gemini-provider.test.ts +140 -1
- package/src/__tests__/get-skill-detail-audit.test.ts +89 -1
- package/src/__tests__/graph-extraction-event-date.test.ts +0 -9
- package/src/__tests__/guardian-action-sweep.test.ts +0 -7
- package/src/__tests__/guardian-binding-drift-heal.test.ts +0 -7
- package/src/__tests__/guardian-card-withdrawal.test.ts +0 -8
- package/src/__tests__/guardian-decision-primitive-canonical.test.ts +1 -9
- package/src/__tests__/guardian-dispatch.test.ts +0 -7
- package/src/__tests__/guardian-expiry-notifier.test.ts +1 -9
- package/src/__tests__/guardian-outbound-http.test.ts +0 -7
- package/src/__tests__/guardian-principal-id-roundtrip.test.ts +1 -8
- package/src/__tests__/guardian-routing-invariants.test.ts +0 -8
- package/src/__tests__/guardian-routing-state.test.ts +1 -9
- package/src/__tests__/guardian-verification-voice-binding.test.ts +0 -7
- package/src/__tests__/handlers-skills-memory-v2-reseed.test.ts +0 -2
- package/src/__tests__/handlers-user-message-approval-consumption.test.ts +4 -5
- package/src/__tests__/headless-browser-interactions.test.ts +0 -7
- package/src/__tests__/headless-browser-mode.test.ts +0 -9
- package/src/__tests__/headless-browser-navigate.test.ts +91 -13
- package/src/__tests__/headless-browser-read-tools.test.ts +0 -7
- package/src/__tests__/headless-browser-snapshot.test.ts +0 -7
- package/src/__tests__/heartbeat-disk-pressure.test.ts +0 -9
- package/src/__tests__/helpers/set-config.ts +40 -0
- package/src/__tests__/host-bash-proxy.test.ts +3 -3
- package/src/__tests__/host-browser-proxy.test.ts +15 -20
- package/src/__tests__/host-cu-routes-targeted.test.ts +0 -1
- package/src/__tests__/host-shell-tool.test.ts +5 -69
- package/src/__tests__/http-conversation-lineage.test.ts +0 -7
- package/src/__tests__/http-user-message-parity.test.ts +0 -7
- package/src/__tests__/identity-routes.test.ts +1 -9
- package/src/__tests__/image-recovery-hook.test.ts +36 -0
- package/src/__tests__/inbound-admitted-introduction-nudge.test.ts +296 -0
- package/src/__tests__/inbound-invite-redemption.test.ts +0 -7
- package/src/__tests__/inbound-slack-persistence.test.ts +0 -5
- package/src/__tests__/inbound-trust-verdict.test.ts +1 -8
- package/src/__tests__/inference-profile-reaper.test.ts +1 -7
- package/src/__tests__/inference-profile-session-handler.test.ts +0 -6
- package/src/__tests__/inference-profile-session-ipc.test.ts +0 -6
- package/src/__tests__/ingress-url-consistency.test.ts +1 -23
- package/src/__tests__/injection-block.test.ts +0 -1
- package/src/__tests__/injector-chain.test.ts +17 -0
- package/src/__tests__/injector-config-validation-reset-notice.test.ts +121 -0
- package/src/__tests__/injector-pkb-v2-silenced.test.ts +8 -0
- package/src/__tests__/injector-registry-order-guard.test.ts +1 -0
- package/src/__tests__/inline-command-runner.test.ts +0 -7
- package/src/__tests__/inline-skill-load-permissions.test.ts +29 -31
- package/src/__tests__/internal-telemetry-routes.test.ts +72 -7
- package/src/__tests__/interrupted-turn-reconciler.test.ts +126 -0
- package/src/__tests__/introduction-card-resolver.test.ts +0 -9
- package/src/__tests__/invite-redeemed-ipc.test.ts +0 -7
- package/src/__tests__/invite-routes-http.test.ts +46 -11
- package/src/__tests__/job-handler-registration-guard.test.ts +1 -1
- package/src/__tests__/jobs-store-qdrant-breaker.test.ts +0 -7
- package/src/__tests__/jobs-store-upsert-debounced.test.ts +0 -7
- package/src/__tests__/lexical-index-dual-write.test.ts +2 -8
- package/src/__tests__/list-messages-attachments.test.ts +0 -7
- package/src/__tests__/list-messages-background-tool-completion.test.ts +0 -7
- package/src/__tests__/list-messages-client-message-id.test.ts +0 -7
- package/src/__tests__/list-messages-hidden-metadata.test.ts +0 -7
- package/src/__tests__/list-messages-page-latest.test.ts +0 -7
- package/src/__tests__/list-messages-queued.test.ts +9 -10
- package/src/__tests__/list-messages-tool-merge.test.ts +0 -7
- package/src/__tests__/llm-catalog-parity.test.ts +20 -0
- package/src/__tests__/llm-context-resolution.test.ts +26 -1
- package/src/__tests__/llm-context-route-provider.test.ts +1 -8
- package/src/__tests__/llm-request-log-agent-loop-exit-reason.test.ts +9 -16
- package/src/__tests__/llm-request-log-call-site.test.ts +5 -12
- package/src/__tests__/llm-request-log-clickhouse-routing.test.ts +117 -0
- package/src/__tests__/llm-request-log-clickhouse-writer-guards.test.ts +115 -0
- package/src/__tests__/llm-request-log-disabled-writes.test.ts +72 -0
- package/src/__tests__/llm-request-log-sink-clickhouse.test.ts +211 -0
- package/src/__tests__/llm-request-log-source-clickhouse.test.ts +1 -22
- package/src/__tests__/llm-request-log-source-factory.test.ts +0 -21
- package/src/__tests__/llm-request-log-turn-query.test.ts +0 -7
- package/src/__tests__/llm-resolver-override-or-default.test.ts +563 -0
- package/src/__tests__/llm-resolver.test.ts +167 -6
- package/src/__tests__/llm-usage-store.test.ts +1 -7
- package/src/__tests__/log-export-routes.test.ts +0 -7
- package/src/__tests__/log-export-workspace.test.ts +0 -7
- package/src/__tests__/managed-profile-guard.test.ts +240 -6
- package/src/__tests__/managed-skill-lifecycle.test.ts +0 -7
- package/src/__tests__/managed-store.test.ts +1 -16
- package/src/__tests__/mcp-auth-routes.test.ts +1 -8
- package/src/__tests__/mcp-config-secret-boundary.test.ts +17 -5
- package/src/__tests__/media-generate-image.test.ts +20 -7
- package/src/__tests__/media-stream-output.test.ts +755 -71
- package/src/__tests__/media-stream-server-integration.test.ts +290 -60
- package/src/__tests__/media-stream-stt-session.test.ts +26 -13
- package/src/__tests__/memory-config-file-parity.test.ts +187 -0
- package/src/__tests__/memory-identity-context-parity.test.ts +103 -0
- package/src/__tests__/memory-jobs-worker-backoff.test.ts +8 -7
- package/src/__tests__/memory-jobs-worker-cleanup-cadence.test.ts +296 -0
- package/src/__tests__/memory-jobs-worker-lanes.test.ts +0 -7
- package/src/__tests__/memory-recall-log-store.test.ts +0 -7
- package/src/__tests__/memory-upsert-concurrency.test.ts +0 -7
- package/src/__tests__/message-queue.test.ts +40 -0
- package/src/__tests__/messages-after-tiebreaker.test.ts +1 -8
- package/src/__tests__/messaging-send-tool.test.ts +0 -7
- package/src/__tests__/migration-cross-version-compatibility.test.ts +0 -7
- package/src/__tests__/migration-export-http.test.ts +10 -12
- package/src/__tests__/migration-export-streaming.test.ts +0 -7
- package/src/__tests__/migration-export-to-gcs.test.ts +60 -7
- package/src/__tests__/migration-import-commit-http.test.ts +11 -12
- package/src/__tests__/migration-import-from-gcs.test.ts +0 -7
- package/src/__tests__/migration-import-from-url.test.ts +0 -7
- package/src/__tests__/migration-import-preflight-http.test.ts +10 -11
- package/src/__tests__/migration-jobs-status.test.ts +8 -11
- package/src/__tests__/migration-validate-http.test.ts +2 -8
- package/src/__tests__/model-intents.test.ts +18 -0
- package/src/__tests__/mtime-cache.test.ts +102 -9
- package/src/__tests__/non-member-access-request.test.ts +145 -7
- package/src/__tests__/notification-broadcaster.test.ts +0 -7
- package/src/__tests__/notification-candidate-guardian-context.test.ts +1 -8
- package/src/__tests__/notification-decision-fallback.test.ts +0 -7
- package/src/__tests__/notification-decision-identity.test.ts +0 -7
- package/src/__tests__/notification-decision-recipient-context.test.ts +0 -7
- package/src/__tests__/notification-deep-link.test.ts +415 -11
- package/src/__tests__/notification-guardian-path.test.ts +0 -7
- package/src/__tests__/notification-platform-adapter.test.ts +0 -7
- package/src/__tests__/notification-routing-intent.test.ts +1 -9
- package/src/__tests__/notification-schedule-notify-dedup.test.ts +1 -9
- package/src/__tests__/notification-telegram-adapter.test.ts +0 -7
- package/src/__tests__/oauth-cli.test.ts +0 -1
- package/src/__tests__/oauth-connect-orchestrator.test.ts +0 -8
- package/src/__tests__/oauth-connect-routes.test.ts +19 -18
- package/src/__tests__/oauth-provider-profiles.test.ts +0 -7
- package/src/__tests__/oauth-provider-visibility.test.ts +0 -7
- package/src/__tests__/oauth-store.test.ts +0 -7
- package/src/__tests__/openai-provider.test.ts +11 -0
- package/src/__tests__/openrouter-provider-only.test.ts +16 -5
- package/src/__tests__/openrouter-token-estimation.test.ts +2 -2
- package/src/__tests__/outbound-slack-persistence.test.ts +9 -7
- package/src/__tests__/outlook-email-watcher.test.ts +0 -9
- package/src/__tests__/path-policy.test.ts +0 -7
- package/src/__tests__/pending-interactions-resolved-event.test.ts +26 -4
- package/src/__tests__/persist-media-references.test.ts +112 -0
- package/src/__tests__/persist-unsendable-image-downscale.test.ts +9 -4
- package/src/__tests__/persist-unsendable-image.test.ts +39 -7
- package/src/__tests__/persist-user-message-set-processing-failure.test.ts +41 -0
- package/src/__tests__/persistence-secret-redaction.test.ts +7 -7
- package/src/__tests__/persona-resolver.test.ts +1 -1
- package/src/__tests__/personal-memory-auth-bypass.test.ts +2 -4
- package/src/__tests__/platform-bash-auto-approve.test.ts +20 -10
- package/src/__tests__/platform-callback-registration.test.ts +10 -9
- package/src/__tests__/platform-proxy-context.test.ts +0 -8
- package/src/__tests__/playbook-execution.test.ts +2 -33
- package/src/__tests__/playbook-tools.test.ts +0 -7
- package/src/__tests__/plugin-api-model-profiles.test.ts +25 -4
- package/src/__tests__/plugin-effective-enabled-set.test.ts +29 -29
- package/src/__tests__/plugin-hook-pipeline-hardening.test.ts +249 -0
- package/src/__tests__/plugin-import-boundary-guard.test.ts +13 -25
- package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +316 -0
- package/src/__tests__/plugin-types.test.ts +1 -1
- package/src/__tests__/pointer-conversation-trust.test.ts +2 -4
- package/src/__tests__/pricing.test.ts +85 -2
- package/src/__tests__/process-message-background-slack.test.ts +4 -5
- package/src/__tests__/process-message-display-content.test.ts +102 -10
- package/src/__tests__/processing-flag-persist-failure.test.ts +0 -5
- package/src/__tests__/provider-commit-message-generator.test.ts +15 -8
- package/src/__tests__/provider-error-scenarios.test.ts +68 -5
- package/src/__tests__/provider-platform-proxy-integration.test.ts +17 -2
- package/src/__tests__/provider-registry-ollama.test.ts +14 -1
- package/src/__tests__/provider-send-message-override-profile.test.ts +13 -5
- package/src/__tests__/provider-streaming.benchmark.test.ts +1 -6
- package/src/__tests__/provider-usage-tracking.test.ts +9 -6
- package/src/__tests__/proxy-approval-callback.test.ts +0 -6
- package/src/__tests__/prune-old-conversations-job.test.ts +1 -9
- package/src/__tests__/prune-old-tool-invocations-job.test.ts +1 -9
- package/src/__tests__/public-ingress-urls.test.ts +1 -24
- package/src/__tests__/qdrant-collection-migration.test.ts +0 -7
- package/src/__tests__/qdrant-manager.test.ts +0 -8
- package/src/__tests__/ratelimit.test.ts +1 -8
- package/src/__tests__/reaction-persistence.test.ts +0 -7
- package/src/__tests__/rebuild-index-graph-nodes.test.ts +0 -11
- package/src/__tests__/registry.test.ts +39 -12
- package/src/__tests__/request-secret-standalone-channel-gate.test.ts +270 -0
- package/src/__tests__/require-fresh-approval.test.ts +47 -182
- package/src/__tests__/resolve-trust-class.test.ts +1 -1
- package/src/__tests__/retry-openrouter-only-normalization.test.ts +9 -5
- package/src/__tests__/retry-thinking-adaptive-only.test.ts +19 -5
- package/src/__tests__/retry-thinking-tool-choice.test.ts +65 -5
- package/src/__tests__/retry-verbosity-normalization.test.ts +9 -5
- package/src/__tests__/runtime-attachment-metadata.test.ts +0 -7
- package/src/__tests__/runtime-events-sse-bilingual.test.ts +0 -7
- package/src/__tests__/runtime-events-sse-parity.test.ts +0 -7
- package/src/__tests__/runtime-events-sse-reconnect.test.ts +0 -7
- package/src/__tests__/runtime-events-sse.test.ts +0 -7
- package/src/__tests__/scaffold-managed-skill-tool.test.ts +131 -9
- package/src/__tests__/schedule-retry.test.ts +0 -8
- package/src/__tests__/schedule-routes-workflow-validation.test.ts +0 -7
- package/src/__tests__/schedule-routes.test.ts +0 -7
- package/src/__tests__/schedule-store.test.ts +0 -8
- package/src/__tests__/schedule-tools.test.ts +0 -7
- package/src/__tests__/scheduler-disk-pressure.test.ts +0 -10
- package/src/__tests__/scheduler-recurrence.test.ts +19 -96
- package/src/__tests__/scheduler-reuse-conversation.test.ts +75 -88
- package/src/__tests__/scheduler-wake.test.ts +12 -60
- package/src/__tests__/scheduler-worker-standdown.test.ts +0 -8
- package/src/__tests__/scoped-approval-grants.test.ts +1 -9
- package/src/__tests__/scoped-grant-security-matrix.test.ts +1 -9
- package/src/__tests__/secret-allowlist.test.ts +1 -8
- package/src/__tests__/secret-ingress-channel.test.ts +0 -7
- package/src/__tests__/secret-ingress-cli.test.ts +0 -7
- package/src/__tests__/secret-ingress-http.test.ts +3 -11
- package/src/__tests__/secret-patterns.test.ts +27 -0
- package/src/__tests__/secret-prompter-channel-fallback.test.ts +35 -9
- package/src/__tests__/secret-response-routing.test.ts +1 -1
- package/src/__tests__/secret-routes-platform-proxy.test.ts +0 -7
- package/src/__tests__/secure-keys-managed-failover.test.ts +0 -7
- package/src/__tests__/secure-keys.test.ts +142 -33
- package/src/__tests__/send-endpoint-busy.test.ts +0 -19
- package/src/__tests__/sequence-store.test.ts +0 -9
- package/src/__tests__/server-history-render.test.ts +61 -8
- package/src/__tests__/service-contracts-import-guard.test.ts +4 -9
- package/src/__tests__/set-permission-mode.test.ts +0 -7
- package/src/__tests__/settings-routes.test.ts +0 -7
- package/src/__tests__/shell-credential-ref.test.ts +0 -8
- package/src/__tests__/shell-tool-proxy-mode.test.ts +0 -7
- package/src/__tests__/skill-projection-feature-flag.test.ts +35 -17
- package/src/__tests__/skill-projection.benchmark.test.ts +7 -7
- package/src/__tests__/skill-script-runner-sandbox.test.ts +0 -7
- package/src/__tests__/skills-files-catalog-fallback.test.ts +0 -7
- package/src/__tests__/slack-channels-routes.test.ts +34 -16
- package/src/__tests__/slack-inbound-verification.test.ts +0 -7
- package/src/__tests__/slack-reaction-canonical-approval.test.ts +0 -8
- package/src/__tests__/slack-users-routes.test.ts +148 -0
- package/src/__tests__/slim-skill-category.test.ts +0 -7
- package/src/__tests__/stale-approval-dedup.test.ts +0 -7
- package/src/__tests__/subagent-call-site-routing.test.ts +45 -11
- package/src/__tests__/subagent-detail.test.ts +2 -1
- package/src/__tests__/subagent-fork-prompt-role.test.ts +0 -5
- package/src/__tests__/subagent-fork-spawn.test.ts +0 -37
- package/src/__tests__/subagent-spawn-and-await.test.ts +0 -5
- package/src/__tests__/subagent-tool-gate-mode.test.ts +1 -7
- package/src/__tests__/subagent-tools.test.ts +77 -36
- package/src/__tests__/suggestion-routes.test.ts +28 -42
- package/src/__tests__/summarize-boundary.test.ts +169 -0
- package/src/__tests__/task-compiler.test.ts +0 -7
- package/src/__tests__/task-management-tools.test.ts +0 -7
- package/src/__tests__/task-memory-cleanup.test.ts +0 -18
- package/src/__tests__/task-scheduler.test.ts +40 -9
- package/src/__tests__/telegram-bot-username-resolution.test.ts +0 -8
- package/src/__tests__/telephony-tts-guard.test.ts +118 -26
- package/src/__tests__/test-preload.ts +11 -1
- package/src/__tests__/thread-backfill.test.ts +2 -8
- package/src/__tests__/token-manager.test.ts +0 -9
- package/src/__tests__/tool-approval-handler.test.ts +57 -88
- package/src/__tests__/{tool-audit-listener.test.ts → tool-audit.test.ts} +230 -255
- package/src/__tests__/tool-execution-abort-cleanup.test.ts +5 -33
- package/src/__tests__/tool-execution-pipeline.benchmark.test.ts +1 -8
- package/src/__tests__/tool-executor-lifecycle-events.test.ts +308 -411
- package/src/__tests__/tool-executor.test.ts +37 -26
- package/src/__tests__/tool-grant-request-escalation.test.ts +17 -31
- package/src/__tests__/tool-preview-lifecycle.test.ts +2 -8
- package/src/__tests__/tool-profiler.test.ts +139 -0
- package/src/__tests__/tool-result-metadata-plumbing.test.ts +0 -8
- package/src/__tests__/tool-start-timestamp.test.ts +4 -10
- package/src/__tests__/tools-get-route.test.ts +75 -3
- package/src/__tests__/trust-context-guards.test.ts +1 -1
- package/src/__tests__/trusted-contact-approval-notifier.test.ts +1 -1
- package/src/__tests__/trusted-contact-inline-approval-integration.test.ts +9 -26
- package/src/__tests__/trusted-contact-lifecycle-notifications.test.ts +0 -7
- package/src/__tests__/trusted-contact-multichannel.test.ts +0 -7
- package/src/__tests__/trusted-contact-verification.test.ts +6 -139
- package/src/__tests__/turn-boundary-resolution.test.ts +0 -7
- package/src/__tests__/turn-events-store.test.ts +51 -7
- package/src/__tests__/turn-outcome-read.test.ts +75 -0
- package/src/__tests__/twilio-config.test.ts +0 -7
- package/src/__tests__/twilio-provider.test.ts +0 -7
- package/src/__tests__/twilio-routes-twiml.test.ts +1 -8
- package/src/__tests__/twilio-routes.test.ts +12 -5
- package/src/__tests__/twilio-validation.test.ts +0 -7
- package/src/__tests__/usage-attribution.test.ts +91 -1
- package/src/__tests__/usage-cache-backfill-migration.test.ts +0 -7
- package/src/__tests__/usage-routes.test.ts +1 -8
- package/src/__tests__/vbundle-pax-and-symlink.test.ts +0 -7
- package/src/__tests__/vercel-ai-gateway-provider.test.ts +283 -0
- package/src/__tests__/vercel-config.test.ts +0 -7
- package/src/__tests__/verification-control-plane-policy.test.ts +60 -31
- package/src/__tests__/voice-approval-resolver-relay.test.ts +3 -9
- package/src/__tests__/voice-config-update.test.ts +1 -22
- package/src/__tests__/voice-guardian-cold-cache-warm.test.ts +8 -17
- package/src/__tests__/voice-scoped-grant-consumer.test.ts +1 -10
- package/src/__tests__/voice-session-bridge-processing-wait.test.ts +0 -7
- package/src/__tests__/voice-session-bridge.test.ts +116 -68
- package/src/__tests__/workspace-git-service.test.ts +207 -2
- package/src/__tests__/workspace-migration-009-backfill-conversation-disk-view.test.ts +0 -8
- package/src/__tests__/workspace-migration-013-repair-conversation-disk-view.test.ts +0 -8
- package/src/__tests__/workspace-migration-028-recover-conversations-from-disk-view.test.ts +0 -8
- package/src/__tests__/workspace-migration-126-strip-managed-profile-bodies.test.ts +192 -0
- package/src/__tests__/workspace-migration-127-backfill-default-provider.test.ts +277 -0
- package/src/__tests__/workspace-migration-128-repair-stale-openrouter-grok-model-ids.test.ts +135 -0
- package/src/__tests__/workspace-migration-129-remove-analyze-conversation-config.test.ts +190 -0
- package/src/__tests__/workspace-tool-loader.test.ts +5 -1
- package/src/a2a/__tests__/e2e-a2a-channel.test.ts +1 -10
- package/src/a2a/__tests__/task-store.test.ts +0 -9
- package/src/acp/__tests__/session-manager-persistence.test.ts +1 -8
- package/src/acp/__tests__/session-manager-resume.test.ts +0 -7
- package/src/acp/__tests__/session-manager-startup.test.ts +1 -8
- package/src/agent/attachments.ts +57 -0
- package/src/agent/image-optimize.ts +80 -0
- package/src/agent/loop-exclusive-tool.test.ts +28 -5
- package/src/agent/loop.ts +25 -63
- package/src/api/responses/conversation-message.ts +9 -15
- package/src/approvals/guardian-expiry-notifier.ts +6 -0
- package/src/approvals/guardian-request-resolvers.ts +42 -21
- package/src/background-wake/wake-intent-hooks.test.ts +2 -10
- package/src/browser/operation-meta.ts +493 -0
- package/src/browser/operations.ts +2 -477
- package/src/calls/__tests__/call-setup-router.test.ts +341 -321
- package/src/calls/__tests__/channel-admission-reader.test.ts +50 -24
- package/src/calls/__tests__/fish-audio-client.test.ts +35 -11
- package/src/calls/__tests__/inbound-trust-reader.test.ts +157 -34
- package/src/calls/__tests__/tts-text-sanitizer.test.ts +22 -0
- package/src/calls/__tests__/voice-session-bridge.test.ts +884 -0
- package/src/calls/access-request-wait.ts +3 -1
- package/src/calls/audio-store.ts +6 -6
- package/src/calls/call-constants.ts +1 -1
- package/src/calls/call-controller.ts +242 -64
- package/src/calls/call-setup-flow-types.ts +2 -2
- package/src/calls/call-setup-flow.ts +19 -57
- package/src/calls/call-setup-router.ts +63 -39
- package/src/calls/call-speech-output.ts +39 -39
- package/src/calls/call-transport.ts +17 -5
- package/src/calls/channel-admission-reader.ts +38 -28
- package/src/calls/fish-audio-client.ts +24 -52
- package/src/calls/gateway-invite-reader.ts +15 -19
- package/src/calls/inbound-trust-reader.ts +74 -25
- package/src/calls/media-stream-audio-transcode.ts +1 -1
- package/src/calls/media-stream-output.ts +482 -64
- package/src/calls/media-stream-server.ts +156 -83
- package/src/calls/media-stream-stt-session.ts +1 -0
- package/src/calls/resolve-call-tts-provider.ts +60 -17
- package/src/calls/telephony-tts-capability.ts +13 -13
- package/src/calls/tts-text-sanitizer.ts +5 -3
- package/src/calls/unresolved-caller-trust.ts +36 -0
- package/src/calls/voice-session-bridge.ts +397 -52
- package/src/channels/__tests__/gateway-invites.test.ts +257 -0
- package/src/channels/gateway-invites.ts +142 -0
- package/src/channels/gateway-verification-sessions.ts +4 -8
- package/src/cli/AGENTS.md +60 -51
- package/src/cli/commands/__tests__/inference-models.test.ts +86 -0
- package/src/cli/commands/__tests__/inference-profiles.test.ts +254 -0
- package/src/cli/commands/__tests__/inference-providers.test.ts +171 -0
- package/src/cli/commands/__tests__/schedules.test.ts +133 -1
- package/src/cli/commands/__tests__/usage.test.ts +131 -0
- package/src/cli/commands/attachment.help.ts +100 -0
- package/src/cli/commands/attachment.ts +92 -157
- package/src/cli/commands/audit.help.ts +40 -0
- package/src/cli/commands/audit.ts +66 -86
- package/src/cli/commands/auth.help.ts +46 -0
- package/src/cli/commands/auth.ts +10 -43
- package/src/cli/commands/avatar.help.ts +236 -0
- package/src/cli/commands/avatar.ts +66 -250
- package/src/cli/commands/backup.help.ts +190 -0
- package/src/cli/commands/backup.ts +109 -276
- package/src/cli/commands/bash.help.ts +45 -0
- package/src/cli/commands/bash.ts +55 -75
- package/src/cli/commands/browser.help.ts +196 -0
- package/src/cli/commands/browser.ts +241 -352
- package/src/cli/commands/config.ts +166 -164
- package/src/cli/commands/contacts.ts +13 -22
- package/src/cli/commands/credentials.ts +38 -28
- package/src/cli/commands/db/repair-step-conversation-backfill.ts +19 -10
- package/src/cli/commands/db/repair.ts +20 -8
- package/src/cli/commands/default-action.ts +8 -3
- package/src/cli/commands/domain.ts +36 -22
- package/src/cli/commands/email.ts +77 -36
- package/src/cli/commands/inference-callsites.ts +158 -0
- package/src/cli/commands/inference-models.ts +84 -0
- package/src/cli/commands/inference-profiles.ts +371 -0
- package/src/cli/commands/inference-providers-default.ts +89 -0
- package/src/cli/commands/inference-providers.ts +117 -24
- package/src/cli/commands/inference.ts +6 -0
- package/src/cli/commands/keys.ts +27 -38
- package/src/cli/commands/memory/index.ts +8 -0
- package/src/cli/commands/memory/memory-retrospective.ts +7 -5
- package/src/cli/commands/memory/memory-v2-compare-render.ts +2 -2
- package/src/cli/commands/memory/nodes.ts +301 -0
- package/src/cli/commands/oauth/shared.ts +1 -1
- package/src/cli/commands/oauth/status.test.ts +6 -6
- package/src/cli/commands/oauth/status.ts +12 -6
- package/src/cli/commands/oauth/token.ts +1 -26
- package/src/cli/commands/plugins.ts +210 -116
- package/src/cli/commands/schedules.ts +17 -2
- package/src/cli/commands/tools-run.ts +4 -4
- package/src/cli/commands/tools.ts +23 -7
- package/src/cli/commands/ui.ts +2 -3
- package/src/cli/commands/usage.ts +59 -21
- package/src/cli/index.help.ts +31 -0
- package/src/cli/lib/__tests__/cli-output.test.ts +20 -0
- package/src/cli/lib/__tests__/diff-plugin.test.ts +2 -5
- package/src/cli/lib/__tests__/inspect-plugin.test.ts +1 -1
- package/src/cli/lib/__tests__/install-from-github.test.ts +37 -5
- package/src/cli/lib/__tests__/install-from-platform.test.ts +497 -0
- package/src/cli/lib/__tests__/list-installed-plugins.test.ts +36 -0
- package/src/cli/lib/__tests__/plugin-artifact.test.ts +54 -1
- package/src/cli/lib/__tests__/plugin-details.test.ts +137 -1
- package/src/cli/lib/__tests__/plugin-icon-file.test.ts +142 -0
- package/src/cli/lib/__tests__/plugin-marketplace.test.ts +1 -1
- package/src/cli/lib/__tests__/plugin-pin-history.test.ts +1 -1
- package/src/cli/lib/__tests__/search-plugins.test.ts +1 -1
- package/src/cli/lib/__tests__/uninstall-plugin.test.ts +82 -21
- package/src/cli/lib/__tests__/upgrade-plugin.test.ts +1 -1
- package/src/cli/lib/cli-command-help.ts +119 -0
- package/src/cli/lib/cli-output.ts +55 -0
- package/src/cli/lib/diff-plugin.ts +2 -2
- package/src/cli/lib/fetch-like.ts +11 -0
- package/src/cli/lib/inspect-plugin.ts +2 -2
- package/src/cli/lib/install-from-github.ts +61 -15
- package/src/cli/lib/install-from-platform.ts +618 -0
- package/src/cli/lib/list-installed-plugins.ts +39 -5
- package/src/cli/lib/plugin-artifact.ts +30 -0
- package/src/cli/lib/plugin-constants.ts +27 -0
- package/src/cli/lib/plugin-details.ts +51 -11
- package/src/cli/lib/plugin-icon-file.ts +101 -0
- package/src/cli/lib/plugin-marketplace.ts +1 -4
- package/src/cli/lib/plugin-pin-history.ts +27 -12
- package/src/cli/lib/publish-plugin.ts +3 -3
- package/src/cli/lib/search-plugins.ts +2 -6
- package/src/cli/lib/uninstall-plugin.ts +24 -2
- package/src/cli/lib/upgrade-plugin.ts +8 -22
- package/src/cli/program.ts +0 -2
- package/src/cli.ts +22 -13
- package/src/config/__tests__/default-profile-catalog.test.ts +384 -0
- package/src/config/__tests__/default-provider.test.ts +245 -0
- package/src/config/__tests__/deployment-context-defaults.test.ts +0 -21
- package/src/config/__tests__/loader-callsite-strip-fallback.test.ts +0 -21
- package/src/config/__tests__/loader-last-known-good.test.ts +208 -0
- package/src/config/__tests__/loader-sparse-array-cleanup.test.ts +145 -0
- package/src/config/__tests__/profile-materialization.test.ts +297 -0
- package/src/config/__tests__/seed-default-provider.test.ts +210 -0
- package/src/config/__tests__/sync-gated-profiles.test.ts +27 -34
- package/src/config/assistant-feature-flags.ts +1 -1
- package/src/config/bundled-skills/_shared/CLI_RETRIEVAL_PATTERN.md +9 -8
- package/src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts +0 -6
- package/src/config/bundled-skills/phone-calls/references/CONFIG.md +2 -2
- package/src/config/bundled-skills/playbooks/tools/playbook-create.ts +0 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-delete.ts +0 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-list.ts +1 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-update.ts +0 -4
- package/src/config/bundled-skills/schedule/SKILL.md +17 -0
- package/src/config/bundled-skills/transcribe/tools/transcribe-media.test.ts +0 -7
- package/src/config/call-site-defaults.ts +5 -2
- package/src/config/default-profile-catalog.ts +481 -0
- package/src/config/default-profile-names.ts +44 -0
- package/src/config/default-provider-resolution.ts +33 -0
- package/src/config/default-provider.ts +38 -0
- package/src/config/env-registry.ts +2 -0
- package/src/config/env.ts +0 -6
- package/src/config/feature-flag-registry.json +42 -50
- package/src/config/inference-profile-validation.ts +5 -4
- package/src/config/llm-resolver.ts +447 -24
- package/src/config/loader.ts +345 -10
- package/src/config/profile-materialization.ts +151 -0
- package/src/config/schema.ts +2 -52
- package/src/config/schemas/__tests__/live-voice.test.ts +108 -0
- package/src/config/schemas/__tests__/llm-request-logs.test.ts +33 -5
- package/src/config/schemas/call-site-catalog.ts +0 -6
- package/src/config/schemas/calls.ts +9 -0
- package/src/config/schemas/conversations.ts +1 -1
- package/src/config/schemas/live-voice.ts +77 -0
- package/src/config/schemas/llm-request-logs.ts +78 -27
- package/src/config/schemas/llm.ts +53 -2
- package/src/config/schemas/memory-lifecycle.ts +0 -6
- package/src/config/schemas/memory.ts +57 -1
- package/src/config/seed-inference-profiles.ts +100 -289
- package/src/config/sync-gated-profiles.ts +17 -23
- package/src/contacts/canonical-guardian-store.ts +6 -0
- package/src/contacts/contact-store.ts +272 -51
- package/src/contacts/contacts-write.ts +0 -22
- package/src/contacts/guardian-contact-reader.ts +3 -2
- package/src/contacts/member-write-relay.ts +2 -19
- package/src/contacts/types.ts +2 -1
- package/src/context/compactor.ts +230 -38
- package/src/context/image-dimensions.ts +25 -3
- package/src/context/token-estimator.ts +11 -7
- package/src/conversations/__tests__/message-consolidation.test.ts +6 -5
- package/src/conversations/job-handlers/summarization.ts +0 -2
- package/src/conversations/message-consolidation.ts +34 -112
- package/src/credential-execution/executable-discovery.ts +16 -144
- package/src/credential-execution/process-manager.test.ts +1 -112
- package/src/credential-execution/process-manager.ts +13 -379
- package/src/credential-execution/prompted-credential.ts +1 -1
- package/src/daemon/__tests__/conversation-surfaces-launch.test.ts +1 -1
- package/src/daemon/__tests__/inference-profile-notification.test.ts +0 -8
- package/src/daemon/__tests__/inflight-message-content.test.ts +219 -0
- package/src/daemon/__tests__/native-web-search-metadata.test.ts +0 -8
- package/src/daemon/__tests__/wake-conversation-ops-completion.test.ts +0 -6
- package/src/daemon/__tests__/web-search-status-text.test.ts +0 -8
- package/src/daemon/approval-generators.ts +17 -11
- package/src/daemon/assistant-attachments.ts +86 -87
- package/src/daemon/config-watcher.ts +67 -21
- package/src/daemon/conversation-agent-loop-handlers.ts +146 -50
- package/src/daemon/conversation-agent-loop.ts +136 -34
- package/src/daemon/conversation-error.ts +291 -109
- package/src/daemon/conversation-history.ts +6 -12
- package/src/daemon/conversation-initial-prompt.ts +1 -1
- package/src/daemon/conversation-launch.ts +1 -1
- package/src/daemon/conversation-lifecycle.ts +5 -22
- package/src/daemon/conversation-media-retry.ts +3 -2
- package/src/daemon/conversation-messaging.ts +296 -66
- package/src/daemon/conversation-notifiers.ts +1 -1
- package/src/daemon/conversation-process.ts +162 -12
- package/src/daemon/conversation-queue-manager.ts +12 -0
- package/src/daemon/conversation-runtime-assembly.ts +197 -53
- package/src/daemon/conversation-skill-tools.ts +27 -9
- package/src/daemon/conversation-slash.ts +2 -4
- package/src/daemon/conversation-store.ts +11 -13
- package/src/daemon/conversation-surfaces.ts +145 -176
- package/src/daemon/conversation-tool-setup.ts +18 -12
- package/src/daemon/conversation-turn-finalize.ts +18 -1
- package/src/daemon/conversation.ts +265 -85
- package/src/daemon/disk-pressure-policy.ts +1 -1
- package/src/daemon/event-loop-watchdog.test.ts +1 -6
- package/src/daemon/event-loop-watchdog.ts +2 -20
- package/src/daemon/handlers/__tests__/config-a2a-accept.test.ts +0 -7
- package/src/daemon/handlers/__tests__/config-a2a-complete.test.ts +1 -8
- package/src/daemon/handlers/__tests__/config-a2a-invite.test.ts +1 -8
- package/src/daemon/handlers/__tests__/config-a2a-redeem.test.ts +1 -8
- package/src/daemon/handlers/__tests__/config-a2a.test.ts +1 -8
- package/src/daemon/handlers/config-a2a.ts +0 -3
- package/src/daemon/handlers/conversation-history.ts +6 -4
- package/src/daemon/handlers/shared.ts +224 -79
- package/src/daemon/handlers/skills.ts +8 -0
- package/src/daemon/inflight-message-content.ts +228 -0
- package/src/daemon/interrupted-turn-reconciler.ts +134 -0
- package/src/daemon/lifecycle.ts +120 -64
- package/src/daemon/main.ts +1 -5
- package/src/daemon/message-types/conversations.ts +2 -0
- package/src/daemon/message-types/host-bash.ts +1 -1
- package/src/daemon/message-types/skills.ts +6 -0
- package/src/daemon/message-types/sync.ts +1 -0
- package/src/daemon/orphan-reaper.test.ts +1 -6
- package/src/daemon/persist-media-references.ts +151 -0
- package/src/daemon/pointer-conversation-trust.ts +2 -4
- package/src/daemon/process-message.ts +82 -8
- package/src/daemon/providers-setup.ts +1 -4
- package/src/daemon/shutdown-handlers.ts +0 -4
- package/src/daemon/sqlite-corruption-watchdog.test.ts +0 -13
- package/src/daemon/sqlite-corruption-watchdog.ts +2 -15
- package/src/daemon/summarize-boundary.ts +62 -0
- package/src/daemon/tool-setup-types.ts +1 -1
- package/src/daemon/trust-context-types.ts +61 -0
- package/src/daemon/trust-context.ts +5 -55
- package/src/daemon/wake-conversation-ops.ts +4 -1
- package/src/documents/document-comments-store.test.ts +1 -7
- package/src/export/__tests__/transcript-formatter.test.ts +13 -8
- package/src/export/formatter.ts +8 -17
- package/src/export/transcript-formatter.ts +13 -40
- package/src/heartbeat/__tests__/heartbeat-run-store.test.ts +0 -9
- package/src/heartbeat/__tests__/heartbeat-service.test.ts +0 -2
- package/src/home/__tests__/home-content-refresh.test.ts +0 -7
- package/src/home/__tests__/suggested-prompts.test.ts +4 -12
- package/src/home/conversation-starter-checkpoints.ts +9 -5
- package/src/home/job-handlers/conversation-starters.ts +24 -54
- package/src/home/suggested-prompts-cache.ts +91 -0
- package/src/home/suggested-prompts.ts +4 -77
- package/src/hooks/__tests__/hook-live-reload.test.ts +62 -48
- package/src/hooks/hook-loader.ts +215 -194
- package/src/hooks/types.ts +2 -2
- package/src/ipc/__tests__/contacts-info-ipc.test.ts +66 -11
- package/src/ipc/assistant-server.ts +14 -34
- package/src/ipc/gateway-flag-listener.ts +14 -25
- package/src/ipc/gateway-validated-call.ts +32 -0
- package/src/ipc/routes/__tests__/contacts-mirror-ipc-routes.test.ts +149 -17
- package/src/ipc/routes/__tests__/contacts-mirror-merge-contact.test.ts +197 -0
- package/src/ipc/routes/__tests__/contacts-mirror-upsert-full.test.ts +368 -0
- package/src/ipc/routes/__tests__/guardian-label-ipc-routes.test.ts +74 -0
- package/src/ipc/routes/__tests__/invite-ipc-routes.test.ts +0 -7
- package/src/ipc/routes/__tests__/memory-v2-backfill.test.ts +5 -7
- package/src/ipc/routes/contacts-info-ipc-routes.ts +5 -2
- package/src/ipc/routes/contacts-mirror-ipc-routes.ts +78 -1
- package/src/ipc/routes/db-proxy.ts +9 -15
- package/src/ipc/routes/guardian-label-ipc-routes.ts +42 -0
- package/src/live-voice/__tests__/live-voice-archive.test.ts +1 -8
- package/src/live-voice/__tests__/live-voice-credential-preflight.test.ts +275 -0
- package/src/live-voice/__tests__/live-voice-integration.test.ts +124 -0
- package/src/live-voice/__tests__/live-voice-metrics.test.ts +67 -0
- package/src/live-voice/__tests__/live-voice-session-preflight.test.ts +156 -0
- package/src/live-voice/__tests__/live-voice-stt.test.ts +464 -19
- package/src/live-voice/__tests__/live-voice-tts-session.test.ts +350 -4
- package/src/live-voice/__tests__/live-voice-tts.test.ts +186 -10
- package/src/live-voice/__tests__/live-voice-vad.test.ts +372 -10
- package/src/live-voice/__tests__/protocol.test.ts +2 -0
- package/src/live-voice/__tests__/runtime-websocket-shell.test.ts +61 -9
- package/src/live-voice/live-voice-credential-preflight.ts +205 -0
- package/src/live-voice/live-voice-metrics.ts +44 -0
- package/src/live-voice/live-voice-session-manager.ts +19 -0
- package/src/live-voice/live-voice-session.ts +1015 -276
- package/src/live-voice/live-voice-tts.ts +50 -4
- package/src/live-voice/protocol.ts +8 -0
- package/src/mcp/__tests__/mcp-auth-orchestrator.test.ts +3 -7
- package/src/messaging/channel-binding-schema.ts +15 -7
- package/src/messaging/providers/a2a/__tests__/deliver.test.ts +0 -9
- package/src/messaging/providers/slack/__tests__/download.test.ts +1 -8
- package/src/messaging/providers/slack/binding-metadata.test.ts +63 -0
- package/src/messaging/providers/slack/binding-metadata.ts +6 -0
- package/src/messaging/providers/slack/conversation-utils.ts +7 -4
- package/src/messaging/providers/slack/send.test.ts +0 -7
- package/src/messaging/providers/slack/types.ts +2 -0
- package/src/messaging/providers/slack/withdraw.test.ts +0 -6
- package/src/messaging/providers/telegram-bot/send.test.ts +0 -7
- package/src/monitoring/__tests__/resource-sampler.test.ts +2 -4
- package/src/monitoring/__tests__/stall-capture.test.ts +1 -1
- package/src/monitoring/process-memory.ts +6 -1
- package/src/monitoring/resource-sample-types.ts +71 -0
- package/src/monitoring/resource-sampler.ts +7 -69
- package/src/monitoring/stall-capture.ts +1 -1
- package/src/notifications/__tests__/broadcaster.test.ts +100 -9
- package/src/notifications/__tests__/connected-channels.test.ts +11 -8
- package/src/notifications/__tests__/decision-engine.test.ts +0 -7
- package/src/notifications/__tests__/destination-resolver.test.ts +18 -12
- package/src/notifications/__tests__/deterministic-checks.test.ts +1 -9
- package/src/notifications/access-request-copy.ts +33 -1
- package/src/notifications/adapters/slack.ts +7 -2
- package/src/notifications/approval-card-data.ts +4 -2
- package/src/notifications/broadcaster.ts +118 -67
- package/src/notifications/copy-composer.ts +6 -2
- package/src/notifications/emit-signal.ts +23 -1
- package/src/notifications/signal.ts +5 -4
- package/src/notifications/types.ts +1 -1
- package/src/notifications/urgency.ts +5 -0
- package/src/oauth/byo-connection.test.ts +1 -10
- package/src/oauth/connect-orchestrator.ts +1 -1
- package/src/oauth/connection-resolver.test.ts +140 -7
- package/src/oauth/connection-resolver.ts +48 -12
- package/src/oauth/oauth-store.ts +4 -11
- package/src/onboarding/__tests__/onboarding-events-store.test.ts +0 -8
- package/src/permissions/approval-policy.test.ts +0 -314
- package/src/permissions/approval-policy.ts +38 -90
- package/src/permissions/checker.test.ts +3 -14
- package/src/permissions/checker.ts +95 -19
- package/src/permissions/confirmation-canonical-request.ts +118 -0
- package/src/permissions/gateway-threshold-reader.test.ts +0 -8
- package/src/permissions/ipc-risk-types.ts +2 -0
- package/src/permissions/prompter.ts +16 -3
- package/src/permissions/secret-prompt-types.ts +34 -0
- package/src/permissions/secret-prompter.ts +21 -19
- package/src/permissions/types.ts +0 -14
- package/src/persistence/__tests__/bulk-write-gate.test.ts +159 -0
- package/src/persistence/__tests__/conversation-queries-search.test.ts +0 -7
- package/src/persistence/__tests__/immediate-transaction-guard.test.ts +70 -0
- package/src/persistence/__tests__/message-content-file.test.ts +259 -0
- package/src/persistence/__tests__/slow-query-log.test.ts +125 -0
- package/src/persistence/attachments-store.ts +90 -26
- package/src/persistence/auto-analysis-constants.ts +4 -13
- package/src/persistence/bulk-write-gate.ts +82 -0
- package/src/persistence/cleanup-schedule-state.ts +51 -21
- package/src/persistence/conversation-bootstrap.ts +3 -3
- package/src/persistence/conversation-crud.ts +382 -105
- package/src/persistence/conversation-disk-view.ts +32 -15
- package/src/persistence/conversation-group-migration.test.ts +1 -8
- package/src/persistence/conversation-key-store.ts +0 -2
- package/src/persistence/conversation-plugin-facade.ts +190 -0
- package/src/persistence/conversation-row-batch-delete.ts +16 -1
- package/src/persistence/conversation-title-service.ts +59 -22
- package/src/persistence/conversation-types.ts +19 -4
- package/src/persistence/db-async-query.ts +18 -9
- package/src/persistence/db-connection.ts +20 -4
- package/src/persistence/db-init.ts +16 -173
- package/src/persistence/db-maintenance.ts +78 -6
- package/src/persistence/embeddings/__tests__/messages-lexical-index.test.ts +0 -7
- package/src/persistence/embeddings/plugin-facade.ts +37 -0
- package/src/persistence/embeddings/qdrant-client.ts +2 -18
- package/src/persistence/fork-message-copy.ts +18 -4
- package/src/persistence/job-handlers/__tests__/message-lexical-backfill.test.ts +0 -7
- package/src/persistence/job-handlers/__tests__/message-lexical-enqueue.test.ts +0 -6
- package/src/persistence/job-handlers/__tests__/message-lexical.test.ts +0 -7
- package/src/persistence/job-handlers/message-lexical-backfill.ts +8 -5
- package/src/persistence/job-handlers/message-lexical.ts +2 -2
- package/src/persistence/jobs-store.ts +48 -85
- package/src/persistence/llm-request-log-sink-clickhouse.ts +325 -0
- package/src/persistence/llm-request-log-store.ts +213 -100
- package/src/persistence/llm-request-log-writer-types.ts +80 -0
- package/src/persistence/message-content-file.ts +301 -0
- package/src/persistence/message-content.ts +33 -72
- package/src/persistence/migrations/321-canonical-guardian-request-trigger.ts +27 -0
- package/src/persistence/migrations/322-add-processing-resume-attempts.ts +31 -0
- package/src/persistence/migrations/323-delete-non-default-memory-scopes.test.ts +148 -0
- package/src/persistence/migrations/323-delete-non-default-memory-scopes.ts +35 -0
- package/src/persistence/migrations/324-message-finalized-column.ts +26 -0
- package/src/persistence/migrations/325-create-config-setting-events.ts +40 -0
- package/src/persistence/migrations/326-move-injection-events-to-memory-db.ts +104 -0
- package/src/persistence/migrations/327-create-flush-checkpoints.ts +86 -0
- package/src/persistence/migrations/__tests__/297-move-llm-request-logs.test.ts +2 -2
- package/src/persistence/migrations/__tests__/327-create-flush-checkpoints.test.ts +124 -0
- package/src/persistence/schema/conversations.ts +25 -1
- package/src/persistence/schema/guardian.ts +5 -0
- package/src/persistence/schema/infrastructure.ts +33 -0
- package/src/persistence/schema/memory-core.ts +17 -28
- package/src/persistence/schema/memory-graph.ts +0 -4
- package/src/persistence/schema/memory-injection.ts +3 -1
- package/src/persistence/schema/tasks.ts +0 -1
- package/src/persistence/slow-query-log.ts +58 -21
- package/src/persistence/steps.ts +14 -0
- package/src/platform/consent-cache.test.ts +0 -7
- package/src/platform/managed-speech.test.ts +218 -0
- package/src/platform/managed-speech.ts +195 -0
- package/src/playbooks/playbook-compiler.ts +2 -10
- package/src/plugin-api/index.ts +79 -0
- package/src/plugin-api/model-profiles.test.ts +31 -3
- package/src/plugin-api/model-profiles.ts +3 -1
- package/src/plugin-api/types.ts +12 -3
- package/src/plugin-api/vision-support.ts +4 -3
- package/src/plugins/AGENTS.md +19 -0
- package/src/plugins/__tests__/plugin-state-boundary-guard.test.ts +65 -0
- package/src/plugins/defaults/compaction/compact.ts +13 -0
- package/src/plugins/defaults/compaction/window-manager.ts +207 -43
- package/src/plugins/defaults/image-fallback/__tests__/caption-cache-persistence.test.ts +216 -0
- package/src/plugins/defaults/image-fallback/__tests__/image-fallback.test.ts +281 -2
- package/src/plugins/defaults/image-fallback/__tests__/vision-recovery.test.ts +268 -0
- package/src/plugins/defaults/image-fallback/hooks/conversation-deleted.ts +27 -0
- package/src/plugins/defaults/image-fallback/hooks/init.ts +16 -0
- package/src/plugins/defaults/image-fallback/hooks/post-compact.ts +52 -0
- package/src/plugins/defaults/image-fallback/hooks/post-model-call.ts +80 -0
- package/src/plugins/defaults/image-fallback/hooks/post-tool-use.ts +7 -4
- package/src/plugins/defaults/image-fallback/hooks/shutdown.ts +14 -0
- package/src/plugins/defaults/image-fallback/hooks/stop.ts +23 -0
- package/src/plugins/defaults/image-fallback/hooks/user-prompt-submit.ts +12 -12
- package/src/plugins/defaults/image-fallback/src/caption-blocks.ts +73 -15
- package/src/plugins/defaults/image-fallback/src/caption-cache.ts +206 -20
- package/src/plugins/defaults/image-fallback/src/recovery-state.ts +49 -0
- package/src/plugins/defaults/image-fallback/src/vision-caption.ts +11 -3
- package/src/plugins/defaults/image-fallback/src/vision-error.ts +19 -0
- package/src/plugins/defaults/image-recovery/detect.ts +32 -10
- package/src/plugins/defaults/image-recovery/hooks/post-model-call.ts +20 -18
- package/src/plugins/defaults/image-recovery/recover.ts +97 -61
- package/src/plugins/defaults/index.ts +29 -5
- package/src/plugins/defaults/injector-order.ts +1 -0
- package/src/plugins/defaults/memory/__tests__/activation-session-store.test.ts +1 -8
- package/src/plugins/defaults/memory/__tests__/clear-stale-processing-flags.test.ts +1 -8
- package/src/plugins/defaults/memory/__tests__/conversation-queries.test.ts +1 -8
- package/src/plugins/defaults/memory/__tests__/conversation-row-batch-delete.test.ts +0 -6
- package/src/plugins/defaults/memory/__tests__/db-maintenance.test.ts +105 -11
- package/src/plugins/defaults/memory/__tests__/db-memory-attach.test.ts +22 -18
- package/src/plugins/defaults/memory/__tests__/embedding-cache.test.ts +0 -6
- package/src/plugins/defaults/memory/__tests__/find-most-recent-retrospective-for.test.ts +1 -8
- package/src/plugins/defaults/memory/__tests__/fork-message-copy.test.ts +0 -6
- package/src/plugins/defaults/memory/__tests__/jobs-store-enqueue-gate.test.ts +7 -70
- package/src/plugins/defaults/memory/__tests__/jobs-worker-memory-disabled.test.ts +0 -7
- package/src/plugins/defaults/memory/__tests__/jobs-worker-pkb-schedule.test.ts +7 -0
- package/src/plugins/defaults/memory/__tests__/jobs-worker-v2-graph-trigger-embed.test.ts +0 -5
- package/src/plugins/defaults/memory/__tests__/jobs-worker-v2-schedule.test.ts +7 -0
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-enqueue.test.ts +0 -7
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +186 -19
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +926 -0
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-startup-cleanup.test.ts +136 -82
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-state.test.ts +0 -6
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-trigger-check.test.ts +217 -2
- package/src/plugins/defaults/memory/__tests__/memory-v2-activation-log-store.test.ts +0 -7
- package/src/plugins/defaults/memory/__tests__/memory-v2-concept-frequency.test.ts +0 -7
- package/src/plugins/defaults/memory/__tests__/table-relocation.test.ts +49 -0
- package/src/plugins/defaults/memory/activation-session-store.ts +1 -1
- package/src/plugins/defaults/memory/anisotropy.ts +1 -1
- package/src/plugins/defaults/memory/config.ts +155 -6
- package/src/plugins/defaults/memory/context-search/agent-protocol.ts +1 -1
- package/src/plugins/defaults/memory/context-search/search.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/conversations.ts +26 -23
- package/src/plugins/defaults/memory/context-search/sources/memory-v2.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/memory.ts +1 -1
- package/src/plugins/defaults/memory/embeddings.ts +8 -40
- package/src/plugins/defaults/memory/filing-jobs.ts +1 -1
- package/src/plugins/defaults/memory/fork-conversation-memory.ts +8 -4
- package/src/plugins/defaults/memory/frontmatter.ts +1 -1
- package/src/plugins/defaults/memory/graph/__tests__/handle-remember-v2.test.ts +4 -25
- package/src/plugins/defaults/memory/graph/bootstrap.ts +13 -19
- package/src/plugins/defaults/memory/graph/capability-seed.ts +62 -33
- package/src/plugins/defaults/memory/graph/consolidation.ts +8 -15
- package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +12 -4
- package/src/plugins/defaults/memory/graph/decay.ts +5 -10
- package/src/plugins/defaults/memory/graph/extraction-job.ts +2 -3
- package/src/plugins/defaults/memory/graph/extraction.test.ts +1 -9
- package/src/plugins/defaults/memory/graph/extraction.ts +149 -64
- package/src/plugins/defaults/memory/graph/graph-search.test.ts +0 -6
- package/src/plugins/defaults/memory/graph/graph-search.ts +33 -15
- package/src/plugins/defaults/memory/graph/image-ref-utils.ts +7 -3
- package/src/plugins/defaults/memory/graph/injection.test.ts +0 -1
- package/src/plugins/defaults/memory/graph/injection.ts +1 -1
- package/src/plugins/defaults/memory/graph/narrative.ts +2 -4
- package/src/plugins/defaults/memory/graph/pattern-scan.ts +2 -5
- package/src/plugins/defaults/memory/graph/retriever.test.ts +27 -28
- package/src/plugins/defaults/memory/graph/retriever.ts +89 -42
- package/src/plugins/defaults/memory/graph/scoring.test.ts +0 -1
- package/src/plugins/defaults/memory/graph/store.test.ts +6 -58
- package/src/plugins/defaults/memory/graph/store.ts +5 -43
- package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +318 -0
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +244 -8
- package/src/plugins/defaults/memory/graph/tools.ts +1 -1
- package/src/plugins/defaults/memory/graph/types.ts +0 -3
- package/src/plugins/defaults/memory/graph-topology/__tests__/build-memory-graph.test.ts +130 -0
- package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +303 -0
- package/src/plugins/defaults/memory/graph-topology/flag.ts +14 -0
- package/src/plugins/defaults/memory/graph-topology/types.ts +84 -0
- package/src/plugins/defaults/memory/hooks/init.ts +1 -1
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +10 -10
- package/src/plugins/defaults/memory/host-utils.ts +80 -0
- package/src/plugins/defaults/memory/identity-context.ts +39 -0
- package/src/plugins/defaults/memory/indexer.ts +18 -54
- package/src/plugins/defaults/memory/injectors.ts +5 -8
- package/src/plugins/defaults/memory/job-handler-registration.ts +0 -4
- package/src/plugins/defaults/memory/job-handlers/backfill.ts +10 -8
- package/src/plugins/defaults/memory/job-handlers/embedding.test.ts +0 -8
- package/src/plugins/defaults/memory/job-handlers/embedding.ts +31 -17
- package/src/plugins/defaults/memory/job-handlers/index-maintenance.ts +13 -6
- package/src/plugins/defaults/memory/job-handlers.ts +10 -9
- package/src/plugins/defaults/memory/jobs/__tests__/embed-concept-page.test.ts +0 -7
- package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +3 -3
- package/src/plugins/defaults/memory/jobs/embed-pkb-file.test.ts +41 -28
- package/src/plugins/defaults/memory/jobs/embed-pkb-file.ts +10 -5
- package/src/plugins/defaults/memory/jobs-worker.ts +161 -50
- package/src/plugins/defaults/memory/logging.ts +17 -0
- package/src/plugins/defaults/memory/memory-retrospective-accounting.ts +143 -0
- package/src/plugins/defaults/memory/memory-retrospective-constants.ts +19 -7
- package/src/plugins/defaults/memory/memory-retrospective-enqueue.ts +5 -6
- package/src/plugins/defaults/memory/memory-retrospective-fork-boundary.ts +57 -20
- package/src/plugins/defaults/memory/memory-retrospective-job.ts +220 -79
- package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +448 -0
- package/src/plugins/defaults/memory/memory-retrospective-startup-cleanup.ts +52 -39
- package/src/plugins/defaults/memory/memory-retrospective-state.ts +14 -10
- package/src/plugins/defaults/memory/memory-retrospective-trigger-check.ts +8 -3
- package/src/plugins/defaults/memory/message-media.ts +80 -0
- package/src/plugins/defaults/memory/paths.ts +48 -0
- package/src/plugins/defaults/memory/pkb/autoinject.ts +1 -1
- package/src/plugins/defaults/memory/pkb/context.ts +2 -2
- package/src/plugins/defaults/memory/pkb/pkb-index.test.ts +25 -44
- package/src/plugins/defaults/memory/pkb/pkb-index.ts +24 -25
- package/src/plugins/defaults/memory/pkb/pkb-reconcile.test.ts +46 -34
- package/src/plugins/defaults/memory/pkb/pkb-reconcile.ts +4 -9
- package/src/plugins/defaults/memory/pkb/pkb-search.test.ts +5 -17
- package/src/plugins/defaults/memory/pkb/pkb-search.ts +2 -9
- package/src/plugins/defaults/memory/pkb/types.ts +1 -12
- package/src/plugins/defaults/memory/pkb-schedule.ts +2 -2
- package/src/plugins/defaults/memory/rerank-local.ts +3 -4
- package/src/plugins/defaults/memory/routes/__tests__/memory-v2-simulate-route.test.ts +9 -17
- package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +2 -2
- package/src/plugins/defaults/memory/routes/memory-graph-routes.ts +71 -0
- package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +149 -9
- package/src/plugins/defaults/memory/routes/memory-item-routes.ts +147 -12
- package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +7 -11
- package/src/plugins/defaults/memory/routes/memory-v3-routes.ts +1 -1
- package/src/plugins/defaults/memory/startup.ts +3 -4
- package/src/plugins/defaults/memory/task-memory-cleanup.ts +1 -1
- package/src/plugins/defaults/memory/tools.test.ts +1 -9
- package/src/plugins/defaults/memory/tools.ts +0 -1
- package/src/plugins/defaults/memory/v2/__tests__/activation.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/__tests__/backfill-jobs.test.ts +0 -6
- package/src/plugins/defaults/memory/v2/__tests__/cli-command-store.test.ts +6 -6
- package/src/plugins/defaults/memory/v2/__tests__/consolidation-job.test.ts +48 -6
- package/src/plugins/defaults/memory/v2/__tests__/harness-compare.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/__tests__/harness-oracle.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/__tests__/harness-replay-input.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/__tests__/injection-events.test.ts +61 -69
- package/src/plugins/defaults/memory/v2/__tests__/injection.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/__tests__/migration.test.ts +0 -6
- package/src/plugins/defaults/memory/v2/__tests__/page-index.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/__tests__/prompts-consolidation.test.ts +28 -0
- package/src/plugins/defaults/memory/v2/__tests__/qdrant.test.ts +3 -6
- package/src/plugins/defaults/memory/v2/__tests__/reranker.test.ts +3 -5
- package/src/plugins/defaults/memory/v2/__tests__/router.test.ts +16 -27
- package/src/plugins/defaults/memory/v2/__tests__/sim.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/__tests__/skill-content.test.ts +1 -1
- package/src/plugins/defaults/memory/v2/__tests__/skill-store.test.ts +56 -22
- package/src/plugins/defaults/memory/v2/__tests__/static-context.test.ts +9 -6
- package/src/plugins/defaults/memory/v2/__tests__/sweep-job.test.ts +6 -6
- package/src/plugins/defaults/memory/v2/backfill-jobs.ts +31 -16
- package/src/plugins/defaults/memory/v2/cli-command-content.ts +78 -0
- package/src/plugins/defaults/memory/v2/cli-command-store.ts +32 -11
- package/src/plugins/defaults/memory/v2/consolidation-job.ts +45 -5
- package/src/plugins/defaults/memory/v2/frontmatter-sweep.ts +1 -1
- package/src/plugins/defaults/memory/v2/harness/harness-types.ts +12 -0
- package/src/plugins/defaults/memory/v2/harness/retriever.ts +1 -8
- package/src/plugins/defaults/memory/v2/harness/router-retriever.ts +1 -8
- package/src/plugins/defaults/memory/v2/harness/trace.ts +1 -1
- package/src/plugins/defaults/memory/v2/injection-events.ts +34 -15
- package/src/plugins/defaults/memory/v2/injection.ts +3 -4
- package/src/plugins/defaults/memory/v2/memory-v2-startup.test.ts +0 -5
- package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +2 -2
- package/src/plugins/defaults/memory/v2/migration.ts +1 -1
- package/src/plugins/defaults/memory/v2/page-index.ts +1 -1
- package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +6 -2
- package/src/plugins/defaults/memory/v2/prompts/router.ts +1 -1
- package/src/plugins/defaults/memory/v2/qdrant.ts +2 -2
- package/src/plugins/defaults/memory/v2/reranker.ts +2 -2
- package/src/plugins/defaults/memory/v2/router.ts +10 -20
- package/src/plugins/defaults/memory/v2/skill-content.ts +23 -4
- package/src/plugins/defaults/memory/v2/skill-store.ts +44 -43
- package/src/plugins/defaults/memory/v2/static-context.ts +7 -12
- package/src/plugins/defaults/memory/v2/sweep-job.ts +24 -13
- package/src/plugins/defaults/memory/v3/__tests__/carry-integration.test.ts +19 -0
- package/src/plugins/defaults/memory/v3/__tests__/dense.test.ts +0 -5
- package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +17 -0
- package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +14 -4
- package/src/plugins/defaults/memory/v3/__tests__/maintain-job.test.ts +23 -17
- package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +20 -6
- package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +2 -0
- package/src/plugins/defaults/memory/v3/__tests__/section-dense-store.test.ts +0 -5
- package/src/plugins/defaults/memory/v3/candidate-match.ts +20 -11
- package/src/plugins/defaults/memory/v3/dense.ts +1 -1
- package/src/plugins/defaults/memory/v3/injector.ts +1 -1
- package/src/plugins/defaults/memory/v3/learned-edges.test.ts +14 -0
- package/src/plugins/defaults/memory/v3/learned-edges.ts +6 -1
- package/src/plugins/defaults/memory/v3/maintain-job.ts +39 -31
- package/src/plugins/defaults/memory/v3/orchestrate.ts +1 -1
- package/src/plugins/defaults/memory/v3/page-content.ts +1 -1
- package/src/plugins/defaults/memory/v3/pool-select.ts +2 -3
- package/src/plugins/defaults/memory/v3/prune.test.ts +10 -0
- package/src/plugins/defaults/memory/v3/prune.ts +1 -1
- package/src/plugins/defaults/memory/v3/section-dense-store.ts +1 -1
- package/src/plugins/defaults/memory/v3/selection-log-store.ts +1 -1
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +47 -25
- package/src/plugins/defaults/memory/v3-eval/eval-packets.ts +31 -11
- package/src/plugins/defaults/memory/worker.ts +2 -2
- package/src/plugins/defaults/workspace/injectors.ts +116 -5
- package/src/plugins/mtime-cache.ts +207 -105
- package/src/plugins/pipeline.ts +195 -5
- package/src/plugins/surface-import.ts +52 -14
- package/src/plugins/types.ts +10 -15
- package/src/prompts/persona-resolver.ts +1 -1
- package/src/prompts/system-prompt.ts +2 -4
- package/src/prompts/templates/system-sections.ts +12 -0
- package/src/providers/__tests__/connection-model-compat.test.ts +0 -5
- package/src/providers/__tests__/count-tokens-forwarding.test.ts +1 -21
- package/src/providers/__tests__/dispatch-connection-routing.test.ts +12 -6
- package/src/providers/__tests__/preflight-resolved-config.test.ts +189 -0
- package/src/providers/__tests__/registry-native-web-search.test.ts +21 -3
- package/src/providers/__tests__/retry-callsite.test.ts +207 -8
- package/src/providers/__tests__/satellite-connection-routing.test.ts +12 -6
- package/src/providers/__tests__/vellum-mismatch-routing.test.ts +0 -5
- package/src/providers/anthropic/client.ts +109 -7
- package/src/providers/anthropic-gateway-shared.ts +63 -0
- package/src/providers/call-site-routing.ts +1 -0
- package/src/providers/connection-resolution.ts +192 -6
- package/src/providers/content-block-schema.ts +149 -0
- package/src/providers/gemini/client.ts +84 -22
- package/src/providers/gemini/inline-media.ts +2 -3
- package/src/providers/inference/__tests__/base-url-route-validation.test.ts +5 -0
- package/src/providers/inference/__tests__/codex-token-refresh.test.ts +1 -15
- package/src/providers/inference/adapter-factory.ts +13 -0
- package/src/providers/inference/connection-availability.ts +193 -0
- package/src/providers/inference/connections.ts +6 -10
- package/src/providers/media-resolve.ts +193 -0
- package/src/providers/model-catalog.ts +337 -17
- package/src/providers/model-intents.ts +6 -0
- package/src/providers/openai/__tests__/api-error-normalization.test.ts +98 -0
- package/src/providers/openai/__tests__/chat-completions-provider-reasoning.test.ts +112 -0
- package/src/providers/openai/api-error-normalization.ts +61 -0
- package/src/providers/openai/chat-completions-provider.ts +73 -10
- package/src/providers/openai/responses-provider.ts +10 -3
- package/src/providers/openrouter/client.ts +6 -39
- package/src/providers/platform-proxy/constants.ts +4 -0
- package/src/providers/provider-availability.ts +23 -1
- package/src/providers/provider-send-message.ts +19 -3
- package/src/providers/registry.ts +5 -1
- package/src/providers/retry.ts +91 -29
- package/src/providers/speech-to-text/__tests__/resolve.test.ts +31 -0
- package/src/providers/speech-to-text/deepgram-realtime.test.ts +393 -1
- package/src/providers/speech-to-text/deepgram-realtime.ts +213 -13
- package/src/providers/speech-to-text/resolve.ts +33 -5
- package/src/providers/types.ts +69 -24
- package/src/providers/vellum-model-routing.ts +11 -0
- package/src/providers/vercel-ai-gateway/client.ts +142 -0
- package/src/runtime/__tests__/actor-trust-resolver.test.ts +132 -0
- package/src/runtime/__tests__/agent-wake.test.ts +232 -16
- package/src/runtime/__tests__/background-job-runner.test.ts +71 -2
- package/src/runtime/__tests__/guardian-vellum-migration.test.ts +5 -15
- package/src/runtime/__tests__/local-principal-trust.test.ts +0 -6
- package/src/runtime/__tests__/member-verdict-cache.test.ts +2 -15
- package/src/runtime/__tests__/trust-verdict-consumer.test.ts +91 -30
- package/src/runtime/access-request-helper.ts +75 -3
- package/src/runtime/actor-trust-resolver.ts +33 -108
- package/src/runtime/agent-wake.ts +45 -25
- package/src/runtime/assistant-event-hub.ts +0 -105
- package/src/runtime/auth/__tests__/middleware.test.ts +1 -10
- package/src/runtime/auth/__tests__/route-policy.test.ts +0 -7
- package/src/runtime/auth/__tests__/token-service.test.ts +1 -8
- package/src/runtime/background-job-runner.ts +57 -2
- package/src/runtime/capabilities.ts +3 -3
- package/src/runtime/channel-reply-delivery.ts +38 -19
- package/src/runtime/channel-retry-sweep.ts +1 -1
- package/src/runtime/confirmation-request-guardian-bridge.ts +4 -3
- package/src/runtime/effective-capabilities.test.ts +0 -36
- package/src/runtime/effective-capabilities.ts +8 -23
- package/src/runtime/guardian-vellum-migration.ts +12 -16
- package/src/runtime/http-router-types.ts +119 -0
- package/src/runtime/http-router.ts +2 -115
- package/src/runtime/http-server.ts +11 -2
- package/src/runtime/http-types.ts +1 -1
- package/src/runtime/introduction-policy.ts +89 -0
- package/src/runtime/local-actor-identity.ts +4 -50
- package/src/runtime/local-principal-trust.ts +1 -1
- package/src/runtime/member-verdict-cache.ts +0 -0
- package/src/runtime/migrations/__tests__/gcs-signed-url.test.ts +51 -1
- package/src/runtime/migrations/__tests__/origin-mode.test.ts +62 -0
- package/src/runtime/migrations/gcs-signed-url.ts +21 -7
- package/src/runtime/migrations/origin-mode.ts +16 -11
- package/src/runtime/pending-interactions.ts +8 -3
- package/src/runtime/routes/__tests__/acp-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/backup-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/bookmark-routes.test.ts +0 -1
- package/src/runtime/routes/__tests__/channel-verification-revoke.test.ts +0 -16
- package/src/runtime/routes/__tests__/client-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/connection-routes-vs-cli-parity.test.ts +4 -5
- package/src/runtime/routes/__tests__/consolidation-routes.test.ts +8 -8
- package/src/runtime/routes/__tests__/contact-routes.test.ts +2 -3
- package/src/runtime/routes/__tests__/content-source-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/conversation-compaction-routes.test.ts +31 -9
- package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/conversation-management-routes.test.ts +0 -8
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +260 -11
- package/src/runtime/routes/__tests__/conversation-surface-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/default-provider-routes.test.ts +499 -0
- package/src/runtime/routes/__tests__/global-search-routes.test.ts +0 -1
- package/src/runtime/routes/__tests__/inference-callsites-routes.test.ts +54 -0
- package/src/runtime/routes/__tests__/inference-models-routes.test.ts +54 -0
- package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +403 -0
- package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +219 -6
- package/src/runtime/routes/__tests__/inference-routes-registration.test.ts +42 -0
- package/src/runtime/routes/__tests__/invite-relay-routes.test.ts +70 -15
- package/src/runtime/routes/__tests__/monitoring-routes.test.ts +1 -1
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +182 -38
- package/src/runtime/routes/__tests__/retrospective-routes.test.ts +1 -8
- package/src/runtime/routes/__tests__/sanity-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/stt-routes.test.ts +0 -9
- package/src/runtime/routes/__tests__/suggest-trust-rule-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/task-routes.test.ts +2 -2
- package/src/runtime/routes/__tests__/theme-routes.test.ts +66 -0
- package/src/runtime/routes/__tests__/tts-routes.test.ts +0 -7
- package/src/runtime/routes/__tests__/user-route-dispatcher.test.ts +1 -9
- package/src/runtime/routes/__tests__/wake-conversation-routes.test.ts +0 -7
- package/src/runtime/routes/acp-routes.ts +20 -14
- package/src/runtime/routes/approval-routes.ts +21 -2
- package/src/runtime/routes/canned-message-complete.ts +82 -0
- package/src/runtime/routes/channel-metadata.ts +49 -0
- package/src/runtime/routes/contact-routes.ts +75 -43
- package/src/runtime/routes/conversation-attention-routes.ts +1 -1
- package/src/runtime/routes/conversation-cli-routes.ts +2 -2
- package/src/runtime/routes/conversation-compaction-routes.ts +5 -0
- package/src/runtime/routes/conversation-management-routes.ts +147 -2
- package/src/runtime/routes/conversation-query-routes.ts +378 -43
- package/src/runtime/routes/conversation-routes.ts +89 -181
- package/src/runtime/routes/conversation-starter-routes.ts +12 -23
- package/src/runtime/routes/credential-prompt-routes.ts +48 -4
- package/src/runtime/routes/credential-request-routes.ts +85 -0
- package/src/runtime/routes/credential-routes.ts +40 -5
- package/src/runtime/routes/default-provider-routes.ts +132 -0
- package/src/runtime/routes/errors.ts +17 -0
- package/src/runtime/routes/events-routes.ts +158 -39
- package/src/runtime/routes/guardian-approval-interception.ts +1 -1
- package/src/runtime/routes/http-adapter.ts +1 -1
- package/src/runtime/routes/inbound-message-handler.ts +61 -6
- package/src/runtime/routes/inbound-stages/acl-enforcement.test.ts +58 -26
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +73 -87
- package/src/runtime/routes/inbound-stages/admission-policy.ts +2 -1
- package/src/runtime/routes/inbound-stages/background-dispatch.test.ts +1 -8
- package/src/runtime/routes/inbound-stages/background-dispatch.ts +3 -2
- package/src/runtime/routes/inbound-stages/bootstrap-intercept.test.ts +0 -5
- package/src/runtime/routes/inbound-stages/edit-intercept.ts +5 -1
- package/src/runtime/routes/inbound-stages/escalation-intercept.test.ts +0 -5
- package/src/runtime/routes/inbound-stages/guardian-activation-intercept.test.ts +0 -9
- package/src/runtime/routes/inbound-stages/guardian-reply-intercept.test.ts +0 -9
- package/src/runtime/routes/inbound-stages/reaction-intercept.test.ts +302 -0
- package/src/runtime/routes/inbound-stages/reaction-intercept.ts +27 -37
- package/src/runtime/routes/inbound-stages/secret-ingress-check.ts +1 -1
- package/src/runtime/routes/inbound-stages/transcribe-audio.test.ts +0 -9
- package/src/runtime/routes/index.ts +16 -4
- package/src/runtime/routes/inference-callsites-routes.ts +211 -0
- package/src/runtime/routes/inference-models-routes.ts +104 -0
- package/src/runtime/routes/inference-profile-session-handler.ts +2 -1
- package/src/runtime/routes/inference-profiles-routes.ts +717 -0
- package/src/runtime/routes/inference-provider-connection-routes.ts +38 -1
- package/src/runtime/routes/inference-send-routes.ts +2 -1
- package/src/runtime/routes/integrations/slack/channels.ts +26 -4
- package/src/runtime/routes/integrations/slack/users.ts +78 -0
- package/src/runtime/routes/internal-telemetry-routes.ts +44 -0
- package/src/runtime/routes/llm-call-sites-routes.ts +2 -1
- package/src/runtime/routes/llm-request-logs-access.ts +19 -0
- package/src/runtime/routes/migration-routes.ts +94 -47
- package/src/runtime/routes/monitoring-routes.ts +1 -1
- package/src/runtime/routes/notification-routes.ts +1 -1
- package/src/runtime/routes/playground/__tests__/reset-circuit.test.ts +0 -7
- package/src/runtime/routes/plugins-routes.ts +169 -16
- package/src/runtime/routes/schedule-routes.ts +38 -1
- package/src/runtime/routes/secret-routes.ts +0 -7
- package/src/runtime/routes/settings-routes.ts +160 -22
- package/src/runtime/routes/skills-routes.ts +6 -0
- package/src/runtime/routes/subagents-routes.ts +17 -18
- package/src/runtime/routes/surface-action-routes.ts +4 -2
- package/src/runtime/routes/theme-routes.ts +36 -0
- package/src/runtime/routes/types.ts +2 -1
- package/src/runtime/routes/workflow-routes.ts +1 -1
- package/src/runtime/services/__tests__/auto-analysis-guard.test.ts +2 -16
- package/src/runtime/services/__tests__/conversation-serializer.test.ts +0 -1
- package/src/runtime/services/auto-analysis-guard.ts +5 -5
- package/src/runtime/services/conversation-serializer.ts +2 -3
- package/src/runtime/sync/resource-sync-events.ts +4 -0
- package/src/runtime/trust-context-resolver.ts +9 -9
- package/src/runtime/trust-verdict-consumer.ts +46 -5
- package/src/schedule/scheduler.ts +61 -18
- package/src/security/__tests__/oauth2-device-code.test.ts +12 -60
- package/src/security/__tests__/provider-key-env-fallback.test.ts +0 -10
- package/src/security/__tests__/secret-normalize.test.ts +96 -0
- package/src/security/secret-normalize.ts +41 -0
- package/src/security/secret-patterns.ts +3 -0
- package/src/security/secure-keys.ts +222 -49
- package/src/sequence/engine.ts +15 -6
- package/src/signals/user-message.ts +3 -1
- package/src/skills/available-skills.ts +134 -0
- package/src/skills/install-meta.ts +8 -0
- package/src/skills/managed-store.ts +10 -0
- package/src/stt/types.ts +33 -2
- package/src/subagent/manager.ts +5 -6
- package/src/tasks/SPEC.md +10 -17
- package/src/tasks/tool-sanitizer.ts +3 -1
- package/src/telemetry/__tests__/config-setting-events-store.test.ts +126 -0
- package/src/telemetry/__tests__/flush-checkpoints.test.ts +56 -0
- package/src/telemetry/__tests__/watchdog-events-store.test.ts +0 -8
- package/src/telemetry/config-setting-events-store.ts +97 -0
- package/src/telemetry/flush-checkpoints.ts +70 -0
- package/src/telemetry/skill-loaded-events-store.test.ts +0 -8
- package/src/telemetry/telemetry-event-sources.ts +571 -0
- package/src/telemetry/tool-audit.ts +285 -0
- package/src/telemetry/tool-executed-events-store.test.ts +19 -27
- package/src/telemetry/tool-executed-events-store.ts +5 -5
- package/src/telemetry/turn-events-store.ts +36 -0
- package/src/telemetry/turn-outcome.ts +116 -0
- package/src/telemetry/turn-trace-store.test.ts +156 -8
- package/src/telemetry/turn-trace-store.ts +53 -4
- package/src/telemetry/types.ts +91 -2
- package/src/telemetry/usage-telemetry-reporter.test.ts +373 -119
- package/src/telemetry/usage-telemetry-reporter.ts +110 -675
- package/src/telemetry/watchdog-direct-emit.test.ts +0 -5
- package/src/theme/workspace-theme.test.ts +269 -0
- package/src/theme/workspace-theme.ts +304 -0
- package/src/tools/AGENTS.md +0 -26
- package/src/tools/acp/spawn.test.ts +0 -7
- package/src/tools/browser/browser-execution.ts +99 -75
- package/src/tools/browser/cdp-client/__tests__/cdp-inspect-client.test.ts +1 -11
- package/src/tools/browser/cdp-client/__tests__/local-cdp-client.test.ts +0 -10
- package/src/tools/browser/network-recorder.test.ts +0 -11
- package/src/tools/document/document-comment-tool.test.ts +1 -7
- package/src/tools/execution-target.test.ts +31 -0
- package/src/tools/execution-target.ts +1 -1
- package/src/tools/executor.ts +63 -275
- package/src/tools/filesystem/write.ts +0 -2
- package/src/tools/host-terminal/host-shell.test.ts +0 -7
- package/src/tools/host-terminal/host-shell.ts +6 -49
- package/src/tools/permission-checker.ts +33 -81
- package/src/tools/registry.ts +261 -166
- package/src/tools/run-standalone.ts +6 -13
- package/src/tools/side-effects.ts +0 -1
- package/src/tools/skills/find-similar-skills.test.ts +5 -9
- package/src/tools/skills/scaffold-managed.ts +31 -4
- package/src/tools/skills/skill-script-runner.ts +17 -31
- package/src/tools/skills/skill-tool-factory.ts +2 -6
- package/src/tools/subagent/read.ts +6 -4
- package/src/tools/subagent/spawn.ts +28 -29
- package/src/tools/terminal/safe-env.ts +8 -3
- package/src/tools/terminal/shell.test.ts +0 -6
- package/src/tools/terminal/shell.ts +1 -50
- package/src/tools/tool-approval-handler.ts +99 -166
- package/src/tools/tool-defaults.ts +2 -6
- package/src/tools/tool-manifest.ts +0 -49
- package/src/{events/tool-profiling-listener.ts → tools/tool-profiler.ts} +64 -32
- package/src/tools/tool-types.ts +4 -95
- package/src/tools/types.ts +27 -140
- package/src/tools/workflows/manage-workflows.ts +2 -1
- package/src/tools/workflows/run-workflow.test.ts +6 -1
- package/src/tools/workflows/run-workflow.ts +2 -4
- package/src/tools/workspace-tools/loader.ts +26 -14
- package/src/tts/__tests__/pcm-chunk-aligner.test.ts +48 -0
- package/src/tts/__tests__/pcm-sample-rates.test.ts +59 -0
- package/src/tts/__tests__/provider-adapters.test.ts +891 -22
- package/src/tts/__tests__/provider-catalog.test.ts +43 -10
- package/src/tts/__tests__/speakable-segments.test.ts +427 -0
- package/src/tts/__tests__/synthesis-stream.test.ts +5 -1
- package/src/tts/pcm-chunk-aligner.ts +29 -0
- package/src/tts/pcm-sample-rates.ts +47 -0
- package/src/tts/provider-definition.ts +6 -7
- package/src/tts/providers/__tests__/xai-tts-socket.test.ts +406 -0
- package/src/tts/providers/deepgram-provider.ts +160 -102
- package/src/tts/providers/elevenlabs-provider.ts +182 -105
- package/src/tts/providers/fish-audio-provider.ts +72 -105
- package/src/tts/providers/xai-provider.ts +131 -22
- package/src/tts/providers/xai-tts-socket.ts +311 -0
- package/src/tts/speakable-segments.ts +188 -0
- package/src/tts/stream-read.ts +136 -0
- package/src/tts/synthesis-stream.ts +9 -5
- package/src/tts/synthesize-text.ts +15 -5
- package/src/tts/types.ts +21 -0
- package/src/usage/attribution.ts +43 -9
- package/src/util/errors.ts +26 -0
- package/src/util/image-conversion.ts +23 -5
- package/src/util/logger.ts +67 -68
- package/src/util/platform.ts +19 -60
- package/src/util/pricing.ts +14 -11
- package/src/util/process-tree.ts +25 -13
- package/src/util/provider-error-patterns.ts +21 -0
- package/src/util/sqlite-query-label.ts +51 -0
- package/src/util/sqlite-retry.ts +14 -2
- package/src/util/unicode.ts +1 -1
- package/src/watcher/__tests__/engine-auth-notify.test.ts +316 -0
- package/src/watcher/engine.ts +87 -2
- package/src/workflows/capabilities.test.ts +2 -32
- package/src/workflows/capabilities.ts +18 -25
- package/src/workflows/engine-integration.test.ts +1 -7
- package/src/workflows/engine.test.ts +2 -10
- package/src/workflows/engine.ts +1 -1
- package/src/workflows/fanout-load.test.ts +1 -1
- package/src/workflows/journal-store.test.ts +1 -9
- package/src/workflows/leaf-runner.test.ts +0 -6
- package/src/workflows/leaf-runner.ts +4 -5
- package/src/workflows/library.test.ts +1 -9
- package/src/workflows/run-manager.test.ts +2 -10
- package/src/workflows/run-manager.ts +2 -4
- package/src/workspace/adaptive-thinking-repair.ts +1 -1
- package/src/workspace/custom-profile-ensure.ts +133 -0
- package/src/workspace/default-provider-ensure.ts +162 -0
- package/src/workspace/git-service.ts +160 -15
- package/src/workspace/migrations/028-recover-conversations-from-disk-view.ts +0 -1
- package/src/workspace/migrations/097-enable-adaptive-thinking-managed-profiles.ts +1 -1
- package/src/workspace/migrations/126-strip-managed-profile-bodies.ts +92 -0
- package/src/workspace/migrations/127-backfill-default-provider.ts +176 -0
- package/src/workspace/migrations/128-repair-stale-openrouter-grok-model-ids.ts +112 -0
- package/src/workspace/migrations/129-remove-analyze-conversation-config.ts +59 -0
- package/src/workspace/migrations/registry.ts +8 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/scripts/generate-bundled-tool-registry.ts +0 -223
- package/scripts/test.sh +0 -494
- package/src/__tests__/actor-trust-resolver-address-fallback.test.ts +0 -255
- package/src/__tests__/agent-loop-sentry-hygiene.test.ts +0 -137
- package/src/__tests__/auto-analysis-end-to-end.test.ts +0 -621
- package/src/__tests__/auto-analysis-prompt.test.ts +0 -50
- package/src/__tests__/config-analysis.test.ts +0 -83
- package/src/__tests__/conversation-analysis-routes.test.ts +0 -156
- package/src/__tests__/credential-execution-admin-cli.test.ts +0 -504
- package/src/__tests__/credential-execution-approval-bridge.test.ts +0 -297
- package/src/__tests__/credential-execution-feature-gates.test.ts +0 -185
- package/src/__tests__/credential-execution-shell-lockdown.test.ts +0 -120
- package/src/__tests__/credential-execution-tools.test.ts +0 -289
- package/src/__tests__/db-proxy-transaction.test.ts +0 -206
- package/src/__tests__/event-bus.test.ts +0 -222
- package/src/__tests__/reaction-intercept-cold-cache-warm.test.ts +0 -141
- package/src/__tests__/reaction-intercept-member-verdict-warm.test.ts +0 -157
- package/src/__tests__/skill-memory.test.ts +0 -85
- package/src/__tests__/skill-runtime-path.test.ts +0 -63
- package/src/__tests__/tool-domain-event-publisher.test.ts +0 -216
- package/src/__tests__/tool-metrics-listener.test.ts +0 -194
- package/src/__tests__/tool-profiling-listener.test.ts +0 -219
- package/src/cli/commands/credential-execution.ts +0 -362
- package/src/config/__tests__/bundled-tool-registry-guard.test.ts +0 -120
- package/src/config/bundled-tool-registry.ts +0 -281
- package/src/config/schemas/analysis.ts +0 -32
- package/src/credential-execution/approval-bridge.ts +0 -320
- package/src/credential-execution/feature-gates.ts +0 -61
- package/src/daemon/__tests__/conversation-lifecycle-auto-analyze.test.ts +0 -449
- package/src/events/bus.ts +0 -177
- package/src/events/domain-events.ts +0 -68
- package/src/events/tool-audit-listener.ts +0 -184
- package/src/events/tool-domain-event-publisher.ts +0 -90
- package/src/events/tool-metrics-listener.ts +0 -134
- package/src/events/tool-permission-telemetry-listener.ts +0 -44
- package/src/instrument.ts +0 -213
- package/src/ipc/routes/db-proxy-transaction.ts +0 -151
- package/src/plugins/defaults/memory/__tests__/find-analysis-conversation.test.ts +0 -197
- package/src/runtime/routes/conversation-analysis-routes.ts +0 -75
- package/src/runtime/routes/work-items-routes.test.ts +0 -74
- package/src/runtime/routes/work-items-routes.ts +0 -881
- package/src/runtime/services/__tests__/analyze-conversation.test.ts +0 -477
- package/src/runtime/services/__tests__/auto-analysis-enqueue.test.ts +0 -386
- package/src/runtime/services/__tests__/auto-analysis-prompt.test.ts +0 -53
- package/src/runtime/services/__tests__/conversation-analyze-job.test.ts +0 -213
- package/src/runtime/services/__tests__/manual-analysis-prompt.test.ts +0 -41
- package/src/runtime/services/analyze-conversation.ts +0 -332
- package/src/runtime/services/auto-analysis-enqueue.ts +0 -130
- package/src/runtime/services/auto-analysis-prompt.ts +0 -55
- package/src/runtime/services/conversation-analyze-job.ts +0 -53
- package/src/skills/skill-memory.ts +0 -44
- package/src/tools/credential-execution/make-authenticated-request.ts +0 -198
- package/src/tools/credential-execution/manage-secure-command-tool.ts +0 -371
- package/src/tools/credential-execution/run-authenticated-command.ts +0 -261
- package/src/tools/flag-gated-tools.test.ts +0 -76
- package/src/util/sentry-log-stream.ts +0 -51
|
@@ -11,17 +11,20 @@ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
|
|
|
11
11
|
// Module mocks (must precede production imports)
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
14
|
+
// Watermark storage fake, injected via the reporter's constructor (see
|
|
15
|
+
// `makeReporter` below) — the real store lives on the telemetry DB and has
|
|
16
|
+
// its own DB-backed test, so it is deliberately NOT module-mocked here.
|
|
17
|
+
const mockGetFlushCheckpoint = mock<(key: string) => string | null>(() => null);
|
|
18
|
+
const mockSetFlushCheckpoint = mock<(key: string, value: string) => void>(
|
|
18
19
|
() => {},
|
|
19
20
|
);
|
|
21
|
+
const mockIsFlushCheckpointStoreAvailable = mock<() => boolean>(() => true);
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const fakeFlushCheckpointStore = {
|
|
24
|
+
isAvailable: () => mockIsFlushCheckpointStoreAvailable(),
|
|
25
|
+
get: (key: string) => mockGetFlushCheckpoint(key),
|
|
26
|
+
set: (key: string, value: string) => mockSetFlushCheckpoint(key, value),
|
|
27
|
+
};
|
|
25
28
|
|
|
26
29
|
const mockQueryUnreportedUsageEvents = mock(
|
|
27
30
|
() =>
|
|
@@ -45,6 +48,9 @@ const mockQueryUnreportedTurnEvents = mock(
|
|
|
45
48
|
interfaceId: string | null;
|
|
46
49
|
channelId: string | null;
|
|
47
50
|
clientMetadata: string | null;
|
|
51
|
+
outcome?: string | null;
|
|
52
|
+
batchedInto?: string | null;
|
|
53
|
+
failureCode?: string | null;
|
|
48
54
|
}[],
|
|
49
55
|
);
|
|
50
56
|
|
|
@@ -81,13 +87,6 @@ mock.module("../util/device-id.js", () => ({
|
|
|
81
87
|
getDeviceId: mockGetDeviceId,
|
|
82
88
|
}));
|
|
83
89
|
|
|
84
|
-
mock.module("../util/logger.js", () => ({
|
|
85
|
-
getLogger: () =>
|
|
86
|
-
new Proxy({} as Record<string, unknown>, {
|
|
87
|
-
get: () => () => {},
|
|
88
|
-
}),
|
|
89
|
-
}));
|
|
90
|
-
|
|
91
90
|
mock.module("../version.js", () => ({
|
|
92
91
|
APP_VERSION: "1.2.3-test",
|
|
93
92
|
}));
|
|
@@ -123,14 +122,21 @@ mock.module("../config/loader.js", () => ({
|
|
|
123
122
|
}));
|
|
124
123
|
|
|
125
124
|
interface MockTurnTrace {
|
|
126
|
-
schema_version:
|
|
125
|
+
schema_version: 3;
|
|
127
126
|
messages: {
|
|
128
127
|
id: string;
|
|
129
128
|
role: string;
|
|
130
129
|
created_at: number;
|
|
131
130
|
content: unknown;
|
|
131
|
+
model: string | null;
|
|
132
132
|
}[];
|
|
133
133
|
tool_calls: unknown[];
|
|
134
|
+
system_prompt: string | null;
|
|
135
|
+
tool_definitions: {
|
|
136
|
+
name: string;
|
|
137
|
+
description: string;
|
|
138
|
+
input_schema: Record<string, unknown>;
|
|
139
|
+
}[];
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
// Returns a non-null bounded trace by default; individual tests override the
|
|
@@ -141,16 +147,25 @@ function defaultBoundedTurnTrace(boundary: {
|
|
|
141
147
|
userMessageCreatedAt: number;
|
|
142
148
|
}): MockTurnTrace | null {
|
|
143
149
|
return {
|
|
144
|
-
schema_version:
|
|
150
|
+
schema_version: 3,
|
|
145
151
|
messages: [
|
|
146
152
|
{
|
|
147
153
|
id: boundary.userMessageId,
|
|
148
154
|
role: "user",
|
|
149
155
|
created_at: boundary.userMessageCreatedAt,
|
|
150
156
|
content: [{ type: "text", text: "hello" }],
|
|
157
|
+
model: null,
|
|
151
158
|
},
|
|
152
159
|
],
|
|
153
160
|
tool_calls: [],
|
|
161
|
+
system_prompt: "You are a helpful assistant.",
|
|
162
|
+
tool_definitions: [
|
|
163
|
+
{
|
|
164
|
+
name: "web_search",
|
|
165
|
+
description: "Search the web",
|
|
166
|
+
input_schema: {},
|
|
167
|
+
},
|
|
168
|
+
],
|
|
154
169
|
};
|
|
155
170
|
}
|
|
156
171
|
|
|
@@ -224,10 +239,11 @@ import {
|
|
|
224
239
|
TOOL_INVOCATION_PII_SENTINEL as TOOL_PII_SENTINEL,
|
|
225
240
|
type ToolInvocationSeedSpec,
|
|
226
241
|
} from "../__tests__/test-support/tool-invocation-seed.js";
|
|
227
|
-
import { getDb } from "../persistence/db-connection.js";
|
|
242
|
+
import { getDb, getTelemetryDb } from "../persistence/db-connection.js";
|
|
228
243
|
import { initializeDb } from "../persistence/db-init.js";
|
|
229
244
|
import {
|
|
230
245
|
authFallbackEvents,
|
|
246
|
+
configSettingEvents,
|
|
231
247
|
conversations,
|
|
232
248
|
skillLoadedEvents,
|
|
233
249
|
toolInvocations,
|
|
@@ -238,9 +254,19 @@ import {
|
|
|
238
254
|
ACTIVATION_FUNNEL_VERSION,
|
|
239
255
|
buildActivationDaemonEventId,
|
|
240
256
|
} from "./activation-funnel.js";
|
|
257
|
+
import { recordConfigSettingEvent } from "./config-setting-events-store.js";
|
|
241
258
|
import { recordSkillLoadedEvent } from "./skill-loaded-events-store.js";
|
|
242
259
|
import { UsageTelemetryReporter } from "./usage-telemetry-reporter.js";
|
|
243
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Construct a reporter wired to the in-memory checkpoint fake. All tests go
|
|
263
|
+
* through this so watermark reads/writes stay assertable via the mocks
|
|
264
|
+
* without process-global module mocking of the real telemetry-DB store.
|
|
265
|
+
*/
|
|
266
|
+
function makeReporter(): UsageTelemetryReporter {
|
|
267
|
+
return new UsageTelemetryReporter(undefined, fakeFlushCheckpointStore);
|
|
268
|
+
}
|
|
269
|
+
|
|
244
270
|
await initializeDb();
|
|
245
271
|
|
|
246
272
|
// ---------------------------------------------------------------------------
|
|
@@ -338,10 +364,10 @@ function useStatefulCheckpoints(
|
|
|
338
364
|
seed: Record<string, string> = {},
|
|
339
365
|
): Map<string, string> {
|
|
340
366
|
const checkpoints = new Map(Object.entries(seed));
|
|
341
|
-
|
|
367
|
+
mockGetFlushCheckpoint.mockImplementation(
|
|
342
368
|
(key) => checkpoints.get(key) ?? null,
|
|
343
369
|
);
|
|
344
|
-
|
|
370
|
+
mockSetFlushCheckpoint.mockImplementation((key, value) => {
|
|
345
371
|
checkpoints.set(key, value);
|
|
346
372
|
});
|
|
347
373
|
return checkpoints;
|
|
@@ -375,8 +401,10 @@ beforeEach(() => {
|
|
|
375
401
|
mockAssembleBoundedTurnTrace.mockImplementation(defaultBoundedTurnTrace);
|
|
376
402
|
mockIsTurnSettled.mockReset();
|
|
377
403
|
mockIsTurnSettled.mockReturnValue(true);
|
|
378
|
-
|
|
379
|
-
|
|
404
|
+
mockGetFlushCheckpoint.mockReset();
|
|
405
|
+
mockSetFlushCheckpoint.mockReset();
|
|
406
|
+
mockIsFlushCheckpointStoreAvailable.mockReset();
|
|
407
|
+
mockIsFlushCheckpointStoreAvailable.mockReturnValue(true);
|
|
380
408
|
mockQueryUnreportedUsageEvents.mockReset();
|
|
381
409
|
mockQueryUnreportedTurnEvents.mockReset();
|
|
382
410
|
mockQueryUnreportedTurnEvents.mockReturnValue([]);
|
|
@@ -387,6 +415,7 @@ beforeEach(() => {
|
|
|
387
415
|
getDb().delete(authFallbackEvents).run();
|
|
388
416
|
getDb().delete(toolInvocations).run();
|
|
389
417
|
getDb().delete(skillLoadedEvents).run();
|
|
418
|
+
getTelemetryDb()?.delete(configSettingEvents).run();
|
|
390
419
|
delete process.env.VELLUM_DISABLE_PLATFORM;
|
|
391
420
|
delete process.env.IS_PLATFORM;
|
|
392
421
|
mockGetPlatformBaseUrl.mockReset();
|
|
@@ -398,7 +427,7 @@ beforeEach(() => {
|
|
|
398
427
|
mockGetPlatformUserId.mockReturnValue("");
|
|
399
428
|
|
|
400
429
|
// Defaults
|
|
401
|
-
|
|
430
|
+
mockGetFlushCheckpoint.mockReturnValue(null);
|
|
402
431
|
mockGetPlatformBaseUrl.mockReturnValue("https://platform.vellum.ai");
|
|
403
432
|
|
|
404
433
|
mockFetch = mock(() =>
|
|
@@ -442,7 +471,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
442
471
|
const events = [makeUsageEvent(), makeUsageEvent()];
|
|
443
472
|
mockQueryUnreportedUsageEvents.mockReturnValue(events);
|
|
444
473
|
|
|
445
|
-
const reporter =
|
|
474
|
+
const reporter = makeReporter();
|
|
446
475
|
await reporter.flush();
|
|
447
476
|
|
|
448
477
|
expect(clientFetchMock).toHaveBeenCalledTimes(1);
|
|
@@ -460,11 +489,11 @@ describe("UsageTelemetryReporter", () => {
|
|
|
460
489
|
const events = [makeUsageEvent()];
|
|
461
490
|
mockQueryUnreportedUsageEvents.mockReturnValue(events);
|
|
462
491
|
|
|
463
|
-
const reporter =
|
|
492
|
+
const reporter = makeReporter();
|
|
464
493
|
await reporter.flush();
|
|
465
494
|
|
|
466
495
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
467
|
-
const watermarkCalls =
|
|
496
|
+
const watermarkCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
468
497
|
(c) => c[0] === "telemetry:usage:last_reported_at",
|
|
469
498
|
);
|
|
470
499
|
expect(watermarkCalls.length).toBe(0);
|
|
@@ -479,14 +508,14 @@ describe("UsageTelemetryReporter", () => {
|
|
|
479
508
|
const events = [makeUsageEvent()];
|
|
480
509
|
mockQueryUnreportedUsageEvents.mockReturnValue(events);
|
|
481
510
|
|
|
482
|
-
const reporter =
|
|
511
|
+
const reporter = makeReporter();
|
|
483
512
|
// Construction initializes the absent tool_executed watermark; clear that
|
|
484
513
|
// call so the assertion below covers only the flush.
|
|
485
|
-
|
|
514
|
+
mockSetFlushCheckpoint.mockClear();
|
|
486
515
|
await reporter.flush();
|
|
487
516
|
|
|
488
517
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
489
|
-
expect(
|
|
518
|
+
expect(mockSetFlushCheckpoint).not.toHaveBeenCalled();
|
|
490
519
|
});
|
|
491
520
|
|
|
492
521
|
test("VELLUM_DISABLE_PLATFORM is ignored when IS_PLATFORM is set (managed mode)", async () => {
|
|
@@ -499,7 +528,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
499
528
|
const events = [makeUsageEvent()];
|
|
500
529
|
mockQueryUnreportedUsageEvents.mockReturnValue(events);
|
|
501
530
|
|
|
502
|
-
const reporter =
|
|
531
|
+
const reporter = makeReporter();
|
|
503
532
|
await reporter.flush();
|
|
504
533
|
|
|
505
534
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -515,10 +544,10 @@ describe("UsageTelemetryReporter", () => {
|
|
|
515
544
|
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
516
545
|
);
|
|
517
546
|
|
|
518
|
-
const reporter =
|
|
547
|
+
const reporter = makeReporter();
|
|
519
548
|
await reporter.flush();
|
|
520
549
|
|
|
521
|
-
const watermarkCalls =
|
|
550
|
+
const watermarkCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
522
551
|
(c) => c[0] === "telemetry:usage:last_reported_at",
|
|
523
552
|
);
|
|
524
553
|
expect(watermarkCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -528,7 +557,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
528
557
|
);
|
|
529
558
|
|
|
530
559
|
// The compound cursor ID should also be set to the last event's id
|
|
531
|
-
const idCalls =
|
|
560
|
+
const idCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
532
561
|
(c) => c[0] === "telemetry:usage:last_reported_id",
|
|
533
562
|
);
|
|
534
563
|
expect(idCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -542,10 +571,10 @@ describe("UsageTelemetryReporter", () => {
|
|
|
542
571
|
Promise.resolve(new Response("error", { status: 500 })),
|
|
543
572
|
);
|
|
544
573
|
|
|
545
|
-
const reporter =
|
|
574
|
+
const reporter = makeReporter();
|
|
546
575
|
await reporter.flush();
|
|
547
576
|
|
|
548
|
-
const watermarkCalls =
|
|
577
|
+
const watermarkCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
549
578
|
(c) => c[0] === "telemetry:usage:last_reported_at",
|
|
550
579
|
);
|
|
551
580
|
expect(watermarkCalls.length).toBe(0);
|
|
@@ -558,7 +587,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
558
587
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
559
588
|
);
|
|
560
589
|
|
|
561
|
-
const reporter =
|
|
590
|
+
const reporter = makeReporter();
|
|
562
591
|
|
|
563
592
|
// First flush — should use the per-device ID
|
|
564
593
|
await reporter.flush();
|
|
@@ -581,7 +610,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
581
610
|
test("empty batch makes no HTTP call", async () => {
|
|
582
611
|
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
583
612
|
|
|
584
|
-
const reporter =
|
|
613
|
+
const reporter = makeReporter();
|
|
585
614
|
await reporter.flush();
|
|
586
615
|
|
|
587
616
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
@@ -597,7 +626,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
597
626
|
Promise.resolve(new Response('{"accepted":500}', { status: 200 })),
|
|
598
627
|
);
|
|
599
628
|
|
|
600
|
-
const reporter =
|
|
629
|
+
const reporter = makeReporter();
|
|
601
630
|
await reporter.flush();
|
|
602
631
|
|
|
603
632
|
// MAX_CONSECUTIVE_BATCHES = 10
|
|
@@ -611,7 +640,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
611
640
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
612
641
|
);
|
|
613
642
|
|
|
614
|
-
const reporter =
|
|
643
|
+
const reporter = makeReporter();
|
|
615
644
|
reporter.start();
|
|
616
645
|
|
|
617
646
|
// Wait a tick so start()'s immediate flush settles.
|
|
@@ -645,7 +674,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
645
674
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
646
675
|
);
|
|
647
676
|
|
|
648
|
-
const reporter =
|
|
677
|
+
const reporter = makeReporter();
|
|
649
678
|
await reporter.flush();
|
|
650
679
|
|
|
651
680
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -714,7 +743,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
714
743
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
715
744
|
);
|
|
716
745
|
|
|
717
|
-
const reporter =
|
|
746
|
+
const reporter = makeReporter();
|
|
718
747
|
await reporter.flush();
|
|
719
748
|
|
|
720
749
|
const body = JSON.parse(
|
|
@@ -738,7 +767,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
738
767
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
739
768
|
);
|
|
740
769
|
|
|
741
|
-
const reporter =
|
|
770
|
+
const reporter = makeReporter();
|
|
742
771
|
await reporter.flush();
|
|
743
772
|
|
|
744
773
|
const body = JSON.parse(
|
|
@@ -765,7 +794,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
765
794
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
766
795
|
);
|
|
767
796
|
|
|
768
|
-
const reporter =
|
|
797
|
+
const reporter = makeReporter();
|
|
769
798
|
await reporter.flush();
|
|
770
799
|
|
|
771
800
|
const body = JSON.parse(
|
|
@@ -783,7 +812,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
783
812
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
784
813
|
);
|
|
785
814
|
|
|
786
|
-
const reporter =
|
|
815
|
+
const reporter = makeReporter();
|
|
787
816
|
await reporter.flush();
|
|
788
817
|
|
|
789
818
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -803,7 +832,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
803
832
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
804
833
|
);
|
|
805
834
|
|
|
806
|
-
const reporter =
|
|
835
|
+
const reporter = makeReporter();
|
|
807
836
|
await reporter.flush();
|
|
808
837
|
|
|
809
838
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -821,7 +850,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
821
850
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
822
851
|
);
|
|
823
852
|
|
|
824
|
-
const reporter =
|
|
853
|
+
const reporter = makeReporter();
|
|
825
854
|
await reporter.flush();
|
|
826
855
|
|
|
827
856
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -850,7 +879,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
850
879
|
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
851
880
|
);
|
|
852
881
|
|
|
853
|
-
const reporter =
|
|
882
|
+
const reporter = makeReporter();
|
|
854
883
|
await reporter.flush();
|
|
855
884
|
|
|
856
885
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -918,7 +947,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
918
947
|
Promise.resolve(new Response('{"accepted":3}', { status: 200 })),
|
|
919
948
|
);
|
|
920
949
|
|
|
921
|
-
const reporter =
|
|
950
|
+
const reporter = makeReporter();
|
|
922
951
|
await reporter.flush();
|
|
923
952
|
|
|
924
953
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -997,7 +1026,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
997
1026
|
Promise.resolve(new Response('{"accepted":4}', { status: 200 })),
|
|
998
1027
|
);
|
|
999
1028
|
|
|
1000
|
-
const reporter =
|
|
1029
|
+
const reporter = makeReporter();
|
|
1001
1030
|
await reporter.flush();
|
|
1002
1031
|
|
|
1003
1032
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -1079,7 +1108,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1079
1108
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1080
1109
|
);
|
|
1081
1110
|
|
|
1082
|
-
const reporter =
|
|
1111
|
+
const reporter = makeReporter();
|
|
1083
1112
|
await reporter.flush();
|
|
1084
1113
|
|
|
1085
1114
|
// The gate consults the `trace-collection` flag.
|
|
@@ -1107,8 +1136,9 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1107
1136
|
expect(turn.type).toBe("turn");
|
|
1108
1137
|
expect(turn.daemon_event_id).toBe("evt-turn-trace");
|
|
1109
1138
|
expect(turn.trace).toBeDefined();
|
|
1110
|
-
expect(turn.trace.schema_version).toBe(
|
|
1139
|
+
expect(turn.trace.schema_version).toBe(3);
|
|
1111
1140
|
expect(turn.trace.messages[0].id).toBe("evt-turn-trace");
|
|
1141
|
+
expect(turn.trace.messages[0].model).toBeNull();
|
|
1112
1142
|
expect(Array.isArray(turn.trace.tool_calls)).toBe(true);
|
|
1113
1143
|
});
|
|
1114
1144
|
|
|
@@ -1121,7 +1151,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1121
1151
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1122
1152
|
);
|
|
1123
1153
|
|
|
1124
|
-
const reporter =
|
|
1154
|
+
const reporter = makeReporter();
|
|
1125
1155
|
await reporter.flush();
|
|
1126
1156
|
|
|
1127
1157
|
// Gate off → no assembly at all (no PII touched).
|
|
@@ -1151,7 +1181,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1151
1181
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1152
1182
|
);
|
|
1153
1183
|
|
|
1154
|
-
const reporter =
|
|
1184
|
+
const reporter = makeReporter();
|
|
1155
1185
|
await reporter.flush();
|
|
1156
1186
|
|
|
1157
1187
|
// Version below threshold → no assembly at all (no PII touched).
|
|
@@ -1177,7 +1207,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1177
1207
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1178
1208
|
);
|
|
1179
1209
|
|
|
1180
|
-
const reporter =
|
|
1210
|
+
const reporter = makeReporter();
|
|
1181
1211
|
await reporter.flush();
|
|
1182
1212
|
|
|
1183
1213
|
expect(mockAssembleBoundedTurnTrace).not.toHaveBeenCalled();
|
|
@@ -1197,7 +1227,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1197
1227
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1198
1228
|
);
|
|
1199
1229
|
|
|
1200
|
-
const reporter =
|
|
1230
|
+
const reporter = makeReporter();
|
|
1201
1231
|
await reporter.flush();
|
|
1202
1232
|
|
|
1203
1233
|
// Flag off → gate closed → no assembly at all (no PII touched).
|
|
@@ -1222,7 +1252,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1222
1252
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1223
1253
|
);
|
|
1224
1254
|
|
|
1225
|
-
const reporter =
|
|
1255
|
+
const reporter = makeReporter();
|
|
1226
1256
|
await reporter.flush();
|
|
1227
1257
|
|
|
1228
1258
|
expect(mockAssembleBoundedTurnTrace).toHaveBeenCalledTimes(1);
|
|
@@ -1242,7 +1272,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1242
1272
|
mockGetCachedShareDiagnostics.mockReturnValue(true);
|
|
1243
1273
|
mockQueryUnreportedTurnEvents.mockReturnValue(singleTurnEvent());
|
|
1244
1274
|
|
|
1245
|
-
const reporter =
|
|
1275
|
+
const reporter = makeReporter();
|
|
1246
1276
|
await reporter.flush();
|
|
1247
1277
|
|
|
1248
1278
|
expect(mockAssembleBoundedTurnTrace).not.toHaveBeenCalled();
|
|
@@ -1253,7 +1283,16 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1253
1283
|
// Trace completeness barrier — don't emit partial traces mid-turn
|
|
1254
1284
|
// -------------------------------------------------------------------------
|
|
1255
1285
|
|
|
1256
|
-
function turnEvent(
|
|
1286
|
+
function turnEvent(
|
|
1287
|
+
id: string,
|
|
1288
|
+
createdAt: number,
|
|
1289
|
+
conversationId: string,
|
|
1290
|
+
overrides: {
|
|
1291
|
+
outcome?: string | null;
|
|
1292
|
+
batchedInto?: string | null;
|
|
1293
|
+
failureCode?: string | null;
|
|
1294
|
+
} = {},
|
|
1295
|
+
) {
|
|
1257
1296
|
return {
|
|
1258
1297
|
id,
|
|
1259
1298
|
createdAt,
|
|
@@ -1263,6 +1302,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1263
1302
|
interfaceId: "macos",
|
|
1264
1303
|
channelId: "vellum",
|
|
1265
1304
|
clientMetadata: null,
|
|
1305
|
+
...overrides,
|
|
1266
1306
|
};
|
|
1267
1307
|
}
|
|
1268
1308
|
|
|
@@ -1276,7 +1316,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1276
1316
|
// The turn's response is still streaming — not settled.
|
|
1277
1317
|
mockIsTurnSettled.mockReturnValue(false);
|
|
1278
1318
|
|
|
1279
|
-
const reporter =
|
|
1319
|
+
const reporter = makeReporter();
|
|
1280
1320
|
await reporter.flush();
|
|
1281
1321
|
|
|
1282
1322
|
// No trace assembled, and the turn is NOT sent (the only event was deferred).
|
|
@@ -1297,7 +1337,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1297
1337
|
|
|
1298
1338
|
// Flush 1: turn in progress -> deferred, nothing sent.
|
|
1299
1339
|
mockIsTurnSettled.mockReturnValue(false);
|
|
1300
|
-
const reporter =
|
|
1340
|
+
const reporter = makeReporter();
|
|
1301
1341
|
await reporter.flush();
|
|
1302
1342
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
1303
1343
|
|
|
@@ -1305,22 +1345,26 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1305
1345
|
// the full trace assembles. The same (still-unreported) turn now ships.
|
|
1306
1346
|
mockIsTurnSettled.mockReturnValue(true);
|
|
1307
1347
|
mockAssembleBoundedTurnTrace.mockReturnValue({
|
|
1308
|
-
schema_version:
|
|
1348
|
+
schema_version: 3,
|
|
1309
1349
|
messages: [
|
|
1310
1350
|
{
|
|
1311
1351
|
id: "evt-inflight",
|
|
1312
1352
|
role: "user",
|
|
1313
1353
|
created_at: 1700000050000,
|
|
1314
1354
|
content: [{ type: "text", text: "do a thing" }],
|
|
1355
|
+
model: null,
|
|
1315
1356
|
},
|
|
1316
1357
|
{
|
|
1317
1358
|
id: "asst-1",
|
|
1318
1359
|
role: "assistant",
|
|
1319
1360
|
created_at: 1700000051000,
|
|
1320
1361
|
content: [{ type: "text", text: "done" }],
|
|
1362
|
+
model: "claude-fable-5",
|
|
1321
1363
|
},
|
|
1322
1364
|
],
|
|
1323
1365
|
tool_calls: [{ id: "ti-1" }],
|
|
1366
|
+
system_prompt: "You are a helpful assistant.",
|
|
1367
|
+
tool_definitions: [],
|
|
1324
1368
|
});
|
|
1325
1369
|
await reporter.flush();
|
|
1326
1370
|
|
|
@@ -1360,7 +1404,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1360
1404
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1361
1405
|
);
|
|
1362
1406
|
|
|
1363
|
-
const reporter =
|
|
1407
|
+
const reporter = makeReporter();
|
|
1364
1408
|
await reporter.flush();
|
|
1365
1409
|
|
|
1366
1410
|
expect(mockAssembleBoundedTurnTrace).toHaveBeenCalledTimes(1);
|
|
@@ -1394,7 +1438,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1394
1438
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1395
1439
|
);
|
|
1396
1440
|
|
|
1397
|
-
const reporter =
|
|
1441
|
+
const reporter = makeReporter();
|
|
1398
1442
|
await reporter.flush();
|
|
1399
1443
|
|
|
1400
1444
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -1415,34 +1459,52 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1415
1459
|
);
|
|
1416
1460
|
});
|
|
1417
1461
|
|
|
1418
|
-
test("with tracing disabled, an in-progress turn is
|
|
1419
|
-
// The completeness barrier
|
|
1420
|
-
//
|
|
1421
|
-
//
|
|
1462
|
+
test("with tracing disabled, an in-progress turn is still deferred (outcome stamps must ship with the event)", async () => {
|
|
1463
|
+
// The completeness barrier applies to every turn event, not just
|
|
1464
|
+
// trace-eligible ones: the `outcome` stamp is written while the
|
|
1465
|
+
// conversation is still processing, and the watermark advances on ship,
|
|
1466
|
+
// so an in-flight turn reported early would be frozen without its stamp.
|
|
1422
1467
|
mockGetCachedShareDiagnostics.mockReturnValue(false);
|
|
1423
1468
|
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
1424
1469
|
const checkpoints = useStatefulCheckpoints();
|
|
1425
1470
|
mockQueryUnreportedTurnEvents.mockReturnValue([
|
|
1426
1471
|
turnEvent("evt-inflight", 1700000050000, "conv-1"),
|
|
1427
1472
|
]);
|
|
1428
|
-
// Even though the turn would be "in-flight", the gate is off so this is
|
|
1429
|
-
// never consulted.
|
|
1430
1473
|
mockIsTurnSettled.mockReturnValue(false);
|
|
1431
1474
|
mockFetch.mockImplementation(() =>
|
|
1432
1475
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1433
1476
|
);
|
|
1434
1477
|
|
|
1435
|
-
const reporter =
|
|
1478
|
+
const reporter = makeReporter();
|
|
1479
|
+
await reporter.flush();
|
|
1480
|
+
|
|
1481
|
+
expect(mockIsTurnSettled).toHaveBeenCalled();
|
|
1482
|
+
// Nothing ships and the watermark holds, so the turn is retried complete.
|
|
1483
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
1484
|
+
expect(checkpoints.get("telemetry:turns:last_reported_at")).toBeUndefined();
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1487
|
+
test("with tracing disabled, a settled turn ships trace-free and advances the watermark", async () => {
|
|
1488
|
+
mockGetCachedShareDiagnostics.mockReturnValue(false);
|
|
1489
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
1490
|
+
const checkpoints = useStatefulCheckpoints();
|
|
1491
|
+
mockQueryUnreportedTurnEvents.mockReturnValue([
|
|
1492
|
+
turnEvent("evt-settled", 1700000050000, "conv-1"),
|
|
1493
|
+
]);
|
|
1494
|
+
mockIsTurnSettled.mockReturnValue(true);
|
|
1495
|
+
mockFetch.mockImplementation(() =>
|
|
1496
|
+
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1497
|
+
);
|
|
1498
|
+
|
|
1499
|
+
const reporter = makeReporter();
|
|
1436
1500
|
await reporter.flush();
|
|
1437
1501
|
|
|
1438
|
-
expect(mockIsTurnSettled).not.toHaveBeenCalled();
|
|
1439
|
-
// The turn ships immediately, trace-free.
|
|
1440
1502
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
1441
1503
|
const body = JSON.parse(
|
|
1442
1504
|
(mockFetch.mock.calls[0] as [string, RequestInit])[1].body as string,
|
|
1443
1505
|
);
|
|
1444
1506
|
expect(body.events.length).toBe(1);
|
|
1445
|
-
expect(body.events[0].daemon_event_id).toBe("evt-
|
|
1507
|
+
expect(body.events[0].daemon_event_id).toBe("evt-settled");
|
|
1446
1508
|
expect("trace" in body.events[0]).toBe(false);
|
|
1447
1509
|
// Watermark advances as usual.
|
|
1448
1510
|
expect(checkpoints.get("telemetry:turns:last_reported_at")).toBe(
|
|
@@ -1450,6 +1512,82 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1450
1512
|
);
|
|
1451
1513
|
});
|
|
1452
1514
|
|
|
1515
|
+
test("outcome stamps ride the turn event: batched carries batched_into, failed carries failure_code", async () => {
|
|
1516
|
+
mockGetCachedShareDiagnostics.mockReturnValue(false);
|
|
1517
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
1518
|
+
useStatefulCheckpoints();
|
|
1519
|
+
mockQueryUnreportedTurnEvents.mockReturnValue([
|
|
1520
|
+
turnEvent("evt-batched-head", 1700000010000, "conv-1", {
|
|
1521
|
+
outcome: "batched",
|
|
1522
|
+
batchedInto: "evt-batch-final",
|
|
1523
|
+
}),
|
|
1524
|
+
turnEvent("evt-batch-final", 1700000011000, "conv-1"),
|
|
1525
|
+
turnEvent("evt-failed", 1700000012000, "conv-2", {
|
|
1526
|
+
outcome: "failed",
|
|
1527
|
+
failureCode: "PROVIDER_RATE_LIMIT",
|
|
1528
|
+
}),
|
|
1529
|
+
turnEvent("evt-cancelled", 1700000013000, "conv-3", {
|
|
1530
|
+
outcome: "cancelled",
|
|
1531
|
+
}),
|
|
1532
|
+
]);
|
|
1533
|
+
mockIsTurnSettled.mockReturnValue(true);
|
|
1534
|
+
mockFetch.mockImplementation(() =>
|
|
1535
|
+
Promise.resolve(new Response('{"accepted":4}', { status: 200 })),
|
|
1536
|
+
);
|
|
1537
|
+
|
|
1538
|
+
const reporter = makeReporter();
|
|
1539
|
+
await reporter.flush();
|
|
1540
|
+
|
|
1541
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
1542
|
+
const body = JSON.parse(
|
|
1543
|
+
(mockFetch.mock.calls[0] as [string, RequestInit])[1].body as string,
|
|
1544
|
+
);
|
|
1545
|
+
const byId = Object.fromEntries(
|
|
1546
|
+
body.events.map((e: { daemon_event_id: string }) => [
|
|
1547
|
+
e.daemon_event_id,
|
|
1548
|
+
e,
|
|
1549
|
+
]),
|
|
1550
|
+
);
|
|
1551
|
+
expect(byId["evt-batched-head"].outcome).toBe("batched");
|
|
1552
|
+
expect(byId["evt-batched-head"].batched_into).toBe("evt-batch-final");
|
|
1553
|
+
expect("failure_code" in byId["evt-batched-head"]).toBe(false);
|
|
1554
|
+
// The batch-final turn replied normally: no outcome keys at all.
|
|
1555
|
+
expect("outcome" in byId["evt-batch-final"]).toBe(false);
|
|
1556
|
+
expect("batched_into" in byId["evt-batch-final"]).toBe(false);
|
|
1557
|
+
expect(byId["evt-failed"].outcome).toBe("failed");
|
|
1558
|
+
expect(byId["evt-failed"].failure_code).toBe("PROVIDER_RATE_LIMIT");
|
|
1559
|
+
expect("batched_into" in byId["evt-failed"]).toBe(false);
|
|
1560
|
+
expect(byId["evt-cancelled"].outcome).toBe("cancelled");
|
|
1561
|
+
expect("failure_code" in byId["evt-cancelled"]).toBe(false);
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
test("an unrecognized outcome value in metadata is dropped from the wire", async () => {
|
|
1565
|
+
mockGetCachedShareDiagnostics.mockReturnValue(false);
|
|
1566
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
1567
|
+
useStatefulCheckpoints();
|
|
1568
|
+
mockQueryUnreportedTurnEvents.mockReturnValue([
|
|
1569
|
+
turnEvent("evt-garbage", 1700000010000, "conv-1", {
|
|
1570
|
+
outcome: "exploded",
|
|
1571
|
+
batchedInto: "evt-other",
|
|
1572
|
+
failureCode: "BOOM",
|
|
1573
|
+
}),
|
|
1574
|
+
]);
|
|
1575
|
+
mockIsTurnSettled.mockReturnValue(true);
|
|
1576
|
+
mockFetch.mockImplementation(() =>
|
|
1577
|
+
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1578
|
+
);
|
|
1579
|
+
|
|
1580
|
+
const reporter = makeReporter();
|
|
1581
|
+
await reporter.flush();
|
|
1582
|
+
|
|
1583
|
+
const body = JSON.parse(
|
|
1584
|
+
(mockFetch.mock.calls[0] as [string, RequestInit])[1].body as string,
|
|
1585
|
+
);
|
|
1586
|
+
expect("outcome" in body.events[0]).toBe(false);
|
|
1587
|
+
expect("batched_into" in body.events[0]).toBe(false);
|
|
1588
|
+
expect("failure_code" in body.events[0]).toBe(false);
|
|
1589
|
+
});
|
|
1590
|
+
|
|
1453
1591
|
test("llm_usage events carry conversation_id, conversation_type, and turn_index", async () => {
|
|
1454
1592
|
// Three LLM calls across the spectrum of the new fields:
|
|
1455
1593
|
// - tied to a conversation, mid-turn (typical foreground)
|
|
@@ -1479,7 +1617,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1479
1617
|
Promise.resolve(new Response('{"accepted":3}', { status: 200 })),
|
|
1480
1618
|
);
|
|
1481
1619
|
|
|
1482
|
-
const reporter =
|
|
1620
|
+
const reporter = makeReporter();
|
|
1483
1621
|
await reporter.flush();
|
|
1484
1622
|
|
|
1485
1623
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -1538,22 +1676,22 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1538
1676
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1539
1677
|
);
|
|
1540
1678
|
|
|
1541
|
-
const reporter =
|
|
1679
|
+
const reporter = makeReporter();
|
|
1542
1680
|
// Construction initializes the absent tool_executed watermark; clear that
|
|
1543
1681
|
// call so the count below covers only the flush's advancement.
|
|
1544
|
-
|
|
1682
|
+
mockSetFlushCheckpoint.mockClear();
|
|
1545
1683
|
await reporter.flush();
|
|
1546
1684
|
|
|
1547
1685
|
// No HTTP call should have been made
|
|
1548
1686
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
1549
1687
|
|
|
1550
|
-
// All
|
|
1688
|
+
// All 9 timestamp watermarks should have been advanced, and all 9 ID
|
|
1551
1689
|
// watermarks pinned to the high-sorting sentinel (a truthy value keeps
|
|
1552
1690
|
// the compound-cursor branch active while closing its same-millisecond
|
|
1553
1691
|
// arm against opt-out rows).
|
|
1554
|
-
expect(
|
|
1692
|
+
expect(mockSetFlushCheckpoint).toHaveBeenCalledTimes(18);
|
|
1555
1693
|
|
|
1556
|
-
const calls =
|
|
1694
|
+
const calls = mockSetFlushCheckpoint.mock.calls;
|
|
1557
1695
|
const keys = calls.map((c) => c[0]);
|
|
1558
1696
|
const eventTypes = [
|
|
1559
1697
|
"usage",
|
|
@@ -1564,6 +1702,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1564
1702
|
"tool_executed",
|
|
1565
1703
|
"skill_loaded",
|
|
1566
1704
|
"watchdog",
|
|
1705
|
+
"config_setting",
|
|
1567
1706
|
];
|
|
1568
1707
|
for (const eventType of eventTypes) {
|
|
1569
1708
|
expect(keys).toContain(`telemetry:${eventType}:last_reported_at`);
|
|
@@ -1585,23 +1724,44 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1585
1724
|
const events = [makeUsageEvent()];
|
|
1586
1725
|
mockQueryUnreportedUsageEvents.mockReturnValue(events);
|
|
1587
1726
|
|
|
1588
|
-
const reporter =
|
|
1727
|
+
const reporter = makeReporter();
|
|
1589
1728
|
// Construction initializes the absent tool_executed watermark; clear that
|
|
1590
1729
|
// call so the assertion below covers only the flush.
|
|
1591
|
-
|
|
1730
|
+
mockSetFlushCheckpoint.mockClear();
|
|
1731
|
+
await reporter.flush();
|
|
1732
|
+
|
|
1733
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
1734
|
+
expect(mockSetFlushCheckpoint).not.toHaveBeenCalled();
|
|
1735
|
+
});
|
|
1736
|
+
|
|
1737
|
+
test("flush skipped entirely when the flush-checkpoint store is unavailable", async () => {
|
|
1738
|
+
// An unreadable checkpoint store must not be mistaken for cursor 0 —
|
|
1739
|
+
// that would requery and re-ship history from the beginning. Nothing is
|
|
1740
|
+
// sent and no watermark is touched (not even the opt-out sentinel);
|
|
1741
|
+
// the cycle retries once the store is back.
|
|
1742
|
+
mockIsFlushCheckpointStoreAvailable.mockReturnValue(false);
|
|
1743
|
+
const events = [makeUsageEvent()];
|
|
1744
|
+
mockQueryUnreportedUsageEvents.mockReturnValue(events);
|
|
1745
|
+
|
|
1746
|
+
const reporter = makeReporter();
|
|
1747
|
+
// Construction initializes the absent tool_executed watermark; clear
|
|
1748
|
+
// those calls so the assertions below cover only the flush.
|
|
1749
|
+
mockGetFlushCheckpoint.mockClear();
|
|
1750
|
+
mockSetFlushCheckpoint.mockClear();
|
|
1592
1751
|
await reporter.flush();
|
|
1593
1752
|
|
|
1594
1753
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
1595
|
-
expect(
|
|
1754
|
+
expect(mockGetFlushCheckpoint).not.toHaveBeenCalled();
|
|
1755
|
+
expect(mockSetFlushCheckpoint).not.toHaveBeenCalled();
|
|
1596
1756
|
});
|
|
1597
1757
|
|
|
1598
1758
|
test("events sent normally after re-granting share_analytics consent", async () => {
|
|
1599
1759
|
// First flush with opt-out — watermarks advance, nothing sent
|
|
1600
1760
|
mockGetCachedShareAnalytics.mockReturnValue(false);
|
|
1601
|
-
const reporter =
|
|
1761
|
+
const reporter = makeReporter();
|
|
1602
1762
|
await reporter.flush();
|
|
1603
1763
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
1604
|
-
|
|
1764
|
+
mockSetFlushCheckpoint.mockReset();
|
|
1605
1765
|
|
|
1606
1766
|
// Re-grant consent and flush with new events
|
|
1607
1767
|
mockGetCachedShareAnalytics.mockReturnValue(true);
|
|
@@ -1646,7 +1806,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1646
1806
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1647
1807
|
);
|
|
1648
1808
|
|
|
1649
|
-
const reporter =
|
|
1809
|
+
const reporter = makeReporter();
|
|
1650
1810
|
await reporter.flush();
|
|
1651
1811
|
|
|
1652
1812
|
const body = JSON.parse(
|
|
@@ -1670,7 +1830,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1670
1830
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1671
1831
|
);
|
|
1672
1832
|
|
|
1673
|
-
const reporter =
|
|
1833
|
+
const reporter = makeReporter();
|
|
1674
1834
|
await reporter.flush();
|
|
1675
1835
|
|
|
1676
1836
|
const body = JSON.parse(
|
|
@@ -1707,7 +1867,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1707
1867
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1708
1868
|
);
|
|
1709
1869
|
|
|
1710
|
-
const reporter =
|
|
1870
|
+
const reporter = makeReporter();
|
|
1711
1871
|
await reporter.flush();
|
|
1712
1872
|
|
|
1713
1873
|
const body = JSON.parse(
|
|
@@ -1736,7 +1896,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1736
1896
|
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
1737
1897
|
);
|
|
1738
1898
|
|
|
1739
|
-
const reporter =
|
|
1899
|
+
const reporter = makeReporter();
|
|
1740
1900
|
await reporter.flush();
|
|
1741
1901
|
|
|
1742
1902
|
const body = JSON.parse(
|
|
@@ -1768,7 +1928,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1768
1928
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1769
1929
|
);
|
|
1770
1930
|
|
|
1771
|
-
const reporter =
|
|
1931
|
+
const reporter = makeReporter();
|
|
1772
1932
|
await reporter.flush();
|
|
1773
1933
|
|
|
1774
1934
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -1820,10 +1980,10 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1820
1980
|
.all();
|
|
1821
1981
|
const lastRow = rows[rows.length - 1];
|
|
1822
1982
|
|
|
1823
|
-
const reporter =
|
|
1983
|
+
const reporter = makeReporter();
|
|
1824
1984
|
await reporter.flush();
|
|
1825
1985
|
|
|
1826
|
-
const watermarkCalls =
|
|
1986
|
+
const watermarkCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
1827
1987
|
(c) => c[0] === "telemetry:auth_fallback:last_reported_at",
|
|
1828
1988
|
);
|
|
1829
1989
|
expect(watermarkCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -1831,7 +1991,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1831
1991
|
String(lastRow.createdAt),
|
|
1832
1992
|
);
|
|
1833
1993
|
|
|
1834
|
-
const idCalls =
|
|
1994
|
+
const idCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
1835
1995
|
(c) => c[0] === "telemetry:auth_fallback:last_reported_id",
|
|
1836
1996
|
);
|
|
1837
1997
|
expect(idCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -1862,7 +2022,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1862
2022
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1863
2023
|
);
|
|
1864
2024
|
|
|
1865
|
-
const reporter =
|
|
2025
|
+
const reporter = makeReporter();
|
|
1866
2026
|
await reporter.flush();
|
|
1867
2027
|
|
|
1868
2028
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -1904,7 +2064,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1904
2064
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1905
2065
|
);
|
|
1906
2066
|
|
|
1907
|
-
const reporter =
|
|
2067
|
+
const reporter = makeReporter();
|
|
1908
2068
|
await reporter.flush();
|
|
1909
2069
|
|
|
1910
2070
|
const body = JSON.parse(
|
|
@@ -1937,7 +2097,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1937
2097
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
1938
2098
|
);
|
|
1939
2099
|
|
|
1940
|
-
const reporter =
|
|
2100
|
+
const reporter = makeReporter();
|
|
1941
2101
|
await reporter.flush();
|
|
1942
2102
|
|
|
1943
2103
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -1995,7 +2155,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
1995
2155
|
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
1996
2156
|
);
|
|
1997
2157
|
|
|
1998
|
-
const reporter =
|
|
2158
|
+
const reporter = makeReporter();
|
|
1999
2159
|
await reporter.flush();
|
|
2000
2160
|
|
|
2001
2161
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -2051,10 +2211,10 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2051
2211
|
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
2052
2212
|
);
|
|
2053
2213
|
|
|
2054
|
-
const reporter =
|
|
2214
|
+
const reporter = makeReporter();
|
|
2055
2215
|
await reporter.flush();
|
|
2056
2216
|
|
|
2057
|
-
const watermarkCalls =
|
|
2217
|
+
const watermarkCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
2058
2218
|
(c) => c[0] === "telemetry:tool_executed:last_reported_at",
|
|
2059
2219
|
);
|
|
2060
2220
|
expect(watermarkCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -2062,7 +2222,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2062
2222
|
String(1700000002000),
|
|
2063
2223
|
);
|
|
2064
2224
|
|
|
2065
|
-
const idCalls =
|
|
2225
|
+
const idCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
2066
2226
|
(c) => c[0] === "telemetry:tool_executed:last_reported_id",
|
|
2067
2227
|
);
|
|
2068
2228
|
expect(idCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -2074,18 +2234,20 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2074
2234
|
seedToolInvocation({ id: "ti-r1", createdAt: 1700000001000 });
|
|
2075
2235
|
seedToolInvocation({ id: "ti-r2", createdAt: 1700000002000 });
|
|
2076
2236
|
// A previous flush already reported ti-r1.
|
|
2077
|
-
|
|
2237
|
+
mockGetFlushCheckpoint.mockImplementation((key) => {
|
|
2078
2238
|
if (key === "telemetry:tool_executed:last_reported_at") {
|
|
2079
2239
|
return String(1700000001000);
|
|
2080
2240
|
}
|
|
2081
|
-
if (key === "telemetry:tool_executed:last_reported_id")
|
|
2241
|
+
if (key === "telemetry:tool_executed:last_reported_id") {
|
|
2242
|
+
return "ti-r1";
|
|
2243
|
+
}
|
|
2082
2244
|
return null;
|
|
2083
2245
|
});
|
|
2084
2246
|
mockFetch.mockImplementation(() =>
|
|
2085
2247
|
Promise.resolve(new Response('{"accepted":1}', { status: 200 })),
|
|
2086
2248
|
);
|
|
2087
2249
|
|
|
2088
|
-
const reporter =
|
|
2250
|
+
const reporter = makeReporter();
|
|
2089
2251
|
await reporter.flush();
|
|
2090
2252
|
|
|
2091
2253
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -2106,7 +2268,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2106
2268
|
// predating the reporter) stay behind the watermark.
|
|
2107
2269
|
const checkpoints = useStatefulCheckpoints();
|
|
2108
2270
|
|
|
2109
|
-
const reporter =
|
|
2271
|
+
const reporter = makeReporter();
|
|
2110
2272
|
const rowCreatedAt =
|
|
2111
2273
|
Number(checkpoints.get("telemetry:tool_executed:last_reported_at")) +
|
|
2112
2274
|
1000;
|
|
@@ -2145,7 +2307,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2145
2307
|
createdAt: Date.now() - 60_000,
|
|
2146
2308
|
});
|
|
2147
2309
|
|
|
2148
|
-
const reporter =
|
|
2310
|
+
const reporter = makeReporter();
|
|
2149
2311
|
|
|
2150
2312
|
// The checkpoint is persisted immediately at construction so a crash
|
|
2151
2313
|
// before the first flush can't re-initialize later.
|
|
@@ -2190,7 +2352,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2190
2352
|
// opted-in rows.
|
|
2191
2353
|
seedToolInvocation({ id: "ti-backlog", createdAt: 1700000002000 });
|
|
2192
2354
|
|
|
2193
|
-
const reporter =
|
|
2355
|
+
const reporter = makeReporter();
|
|
2194
2356
|
expect(checkpoints.get("telemetry:tool_executed:last_reported_at")).toBe(
|
|
2195
2357
|
String(1700000001000),
|
|
2196
2358
|
);
|
|
@@ -2224,7 +2386,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2224
2386
|
id: "ti-opt-out-window",
|
|
2225
2387
|
createdAt: optOutRowCreatedAt,
|
|
2226
2388
|
});
|
|
2227
|
-
const optedOutReporter =
|
|
2389
|
+
const optedOutReporter = makeReporter();
|
|
2228
2390
|
await optedOutReporter.stop(); // shutdown path: runs the final flush
|
|
2229
2391
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
2230
2392
|
const advanced = Number(
|
|
@@ -2236,7 +2398,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2236
2398
|
// after the opt-out epoch ship — the opt-out-window row never does.
|
|
2237
2399
|
mockGetCachedShareAnalytics.mockReturnValue(true);
|
|
2238
2400
|
seedToolInvocation({ id: "ti-after-opt-in", createdAt: advanced + 1000 });
|
|
2239
|
-
const reporter =
|
|
2401
|
+
const reporter = makeReporter();
|
|
2240
2402
|
await reporter.flush();
|
|
2241
2403
|
|
|
2242
2404
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -2260,7 +2422,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2260
2422
|
// Opted-out flush: advances the timestamp watermark to Date.now() and
|
|
2261
2423
|
// must also pin the ID watermark to the high-sorting sentinel.
|
|
2262
2424
|
mockGetCachedShareAnalytics.mockReturnValue(false);
|
|
2263
|
-
const optedOutReporter =
|
|
2425
|
+
const optedOutReporter = makeReporter();
|
|
2264
2426
|
await optedOutReporter.flush();
|
|
2265
2427
|
expect(mockFetch).not.toHaveBeenCalled();
|
|
2266
2428
|
const watermark = Number(
|
|
@@ -2279,7 +2441,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2279
2441
|
// Re-opt-in: only rows strictly after the opt-out epoch ship.
|
|
2280
2442
|
mockGetCachedShareAnalytics.mockReturnValue(true);
|
|
2281
2443
|
seedToolInvocation({ id: "ti-after-opt-in", createdAt: watermark + 1000 });
|
|
2282
|
-
const reporter =
|
|
2444
|
+
const reporter = makeReporter();
|
|
2283
2445
|
await reporter.flush();
|
|
2284
2446
|
|
|
2285
2447
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -2295,17 +2457,17 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2295
2457
|
// initializeDb() failures are tolerated at daemon startup (degraded
|
|
2296
2458
|
// mode), so the constructor's checkpoint init must never throw out of
|
|
2297
2459
|
// the constructor and abort the daemon.
|
|
2298
|
-
|
|
2460
|
+
mockGetFlushCheckpoint.mockImplementation(() => {
|
|
2299
2461
|
throw new Error("database disk image is malformed");
|
|
2300
2462
|
});
|
|
2301
|
-
expect(() =>
|
|
2463
|
+
expect(() => makeReporter()).not.toThrow();
|
|
2302
2464
|
|
|
2303
2465
|
// The write path failing is equally non-fatal.
|
|
2304
|
-
|
|
2305
|
-
|
|
2466
|
+
mockGetFlushCheckpoint.mockImplementation(() => null);
|
|
2467
|
+
mockSetFlushCheckpoint.mockImplementation(() => {
|
|
2306
2468
|
throw new Error("database disk image is malformed");
|
|
2307
2469
|
});
|
|
2308
|
-
expect(() =>
|
|
2470
|
+
expect(() => makeReporter()).not.toThrow();
|
|
2309
2471
|
});
|
|
2310
2472
|
|
|
2311
2473
|
// -------------------------------------------------------------------------
|
|
@@ -2329,7 +2491,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2329
2491
|
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
2330
2492
|
);
|
|
2331
2493
|
|
|
2332
|
-
const reporter =
|
|
2494
|
+
const reporter = makeReporter();
|
|
2333
2495
|
await reporter.flush();
|
|
2334
2496
|
|
|
2335
2497
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
@@ -2385,10 +2547,10 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2385
2547
|
.all();
|
|
2386
2548
|
const lastRow = rows[rows.length - 1];
|
|
2387
2549
|
|
|
2388
|
-
const reporter =
|
|
2550
|
+
const reporter = makeReporter();
|
|
2389
2551
|
await reporter.flush();
|
|
2390
2552
|
|
|
2391
|
-
const watermarkCalls =
|
|
2553
|
+
const watermarkCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
2392
2554
|
(c) => c[0] === "telemetry:skill_loaded:last_reported_at",
|
|
2393
2555
|
);
|
|
2394
2556
|
expect(watermarkCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -2396,7 +2558,7 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2396
2558
|
String(lastRow.createdAt),
|
|
2397
2559
|
);
|
|
2398
2560
|
|
|
2399
|
-
const idCalls =
|
|
2561
|
+
const idCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
2400
2562
|
(c) => c[0] === "telemetry:skill_loaded:last_reported_id",
|
|
2401
2563
|
);
|
|
2402
2564
|
expect(idCalls.length).toBeGreaterThanOrEqual(1);
|
|
@@ -2417,10 +2579,102 @@ describe("UsageTelemetryReporter", () => {
|
|
|
2417
2579
|
Promise.resolve(new Response('{"accepted":500}', { status: 200 })),
|
|
2418
2580
|
);
|
|
2419
2581
|
|
|
2420
|
-
const reporter =
|
|
2582
|
+
const reporter = makeReporter();
|
|
2421
2583
|
await reporter.flush();
|
|
2422
2584
|
|
|
2423
2585
|
// MAX_CONSECUTIVE_BATCHES = 10
|
|
2424
2586
|
expect(mockFetch).toHaveBeenCalledTimes(10);
|
|
2425
2587
|
});
|
|
2588
|
+
|
|
2589
|
+
// -------------------------------------------------------------------------
|
|
2590
|
+
// Config-setting events
|
|
2591
|
+
// -------------------------------------------------------------------------
|
|
2592
|
+
|
|
2593
|
+
test("config_setting events ship the key/value pair on the standard envelope", async () => {
|
|
2594
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
2595
|
+
recordConfigSettingEvent({
|
|
2596
|
+
configKey: "memory.enabled",
|
|
2597
|
+
configValue: "true",
|
|
2598
|
+
});
|
|
2599
|
+
recordConfigSettingEvent({
|
|
2600
|
+
configKey: "memory.v2.enabled",
|
|
2601
|
+
configValue: "false",
|
|
2602
|
+
});
|
|
2603
|
+
mockFetch.mockImplementation(() =>
|
|
2604
|
+
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
2605
|
+
);
|
|
2606
|
+
|
|
2607
|
+
const reporter = makeReporter();
|
|
2608
|
+
await reporter.flush();
|
|
2609
|
+
|
|
2610
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
2611
|
+
const body = JSON.parse(
|
|
2612
|
+
(mockFetch.mock.calls[0] as [string, RequestInit])[1].body as string,
|
|
2613
|
+
);
|
|
2614
|
+
expect(body.events.length).toBe(2);
|
|
2615
|
+
|
|
2616
|
+
const byKey: Record<string, Record<string, unknown>> = {};
|
|
2617
|
+
for (const e of body.events as Array<{ config_key: string }>) {
|
|
2618
|
+
byKey[e.config_key] = e;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
expect(byKey["memory.enabled"]).toMatchObject({
|
|
2622
|
+
type: "config_setting",
|
|
2623
|
+
config_key: "memory.enabled",
|
|
2624
|
+
config_value: "true",
|
|
2625
|
+
assistant_version: "1.2.3-test",
|
|
2626
|
+
});
|
|
2627
|
+
expect(typeof byKey["memory.enabled"].daemon_event_id).toBe("string");
|
|
2628
|
+
expect(typeof byKey["memory.enabled"].recorded_at).toBe("number");
|
|
2629
|
+
expect(byKey["memory.v2.enabled"]).toMatchObject({
|
|
2630
|
+
type: "config_setting",
|
|
2631
|
+
config_key: "memory.v2.enabled",
|
|
2632
|
+
config_value: "false",
|
|
2633
|
+
});
|
|
2634
|
+
});
|
|
2635
|
+
|
|
2636
|
+
test("config_setting watermark advances to the last reported row on success", async () => {
|
|
2637
|
+
mockQueryUnreportedUsageEvents.mockReturnValue([]);
|
|
2638
|
+
recordConfigSettingEvent({
|
|
2639
|
+
configKey: "memory.enabled",
|
|
2640
|
+
configValue: "true",
|
|
2641
|
+
});
|
|
2642
|
+
recordConfigSettingEvent({
|
|
2643
|
+
configKey: "memory.v2.enabled",
|
|
2644
|
+
configValue: "true",
|
|
2645
|
+
});
|
|
2646
|
+
mockFetch.mockImplementation(() =>
|
|
2647
|
+
Promise.resolve(new Response('{"accepted":2}', { status: 200 })),
|
|
2648
|
+
);
|
|
2649
|
+
|
|
2650
|
+
// The last row by the reporter's (createdAt, id) cursor order is the one
|
|
2651
|
+
// whose watermark should be persisted after a successful upload.
|
|
2652
|
+
const telemetryDb = getTelemetryDb();
|
|
2653
|
+
if (!telemetryDb) {
|
|
2654
|
+
throw new Error("telemetry DB unavailable in test");
|
|
2655
|
+
}
|
|
2656
|
+
const rows = telemetryDb
|
|
2657
|
+
.select()
|
|
2658
|
+
.from(configSettingEvents)
|
|
2659
|
+
.orderBy(configSettingEvents.createdAt, configSettingEvents.id)
|
|
2660
|
+
.all();
|
|
2661
|
+
const lastRow = rows[rows.length - 1];
|
|
2662
|
+
|
|
2663
|
+
const reporter = makeReporter();
|
|
2664
|
+
await reporter.flush();
|
|
2665
|
+
|
|
2666
|
+
const watermarkCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
2667
|
+
(c) => c[0] === "telemetry:config_setting:last_reported_at",
|
|
2668
|
+
);
|
|
2669
|
+
expect(watermarkCalls.length).toBeGreaterThanOrEqual(1);
|
|
2670
|
+
expect(watermarkCalls[watermarkCalls.length - 1][1]).toBe(
|
|
2671
|
+
String(lastRow.createdAt),
|
|
2672
|
+
);
|
|
2673
|
+
|
|
2674
|
+
const idCalls = mockSetFlushCheckpoint.mock.calls.filter(
|
|
2675
|
+
(c) => c[0] === "telemetry:config_setting:last_reported_id",
|
|
2676
|
+
);
|
|
2677
|
+
expect(idCalls.length).toBeGreaterThanOrEqual(1);
|
|
2678
|
+
expect(idCalls[idCalls.length - 1][1]).toBe(lastRow.id);
|
|
2679
|
+
});
|
|
2426
2680
|
});
|