@vellumai/assistant 0.11.0 → 0.11.1-staging.1

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.
Files changed (1591) hide show
  1. package/ARCHITECTURE.md +14 -9
  2. package/Dockerfile +1 -0
  3. package/docs/architecture/memory.md +59 -0
  4. package/docs/stt-provider-onboarding.md +10 -7
  5. package/eslint.config.mjs +34 -1
  6. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +1 -0
  7. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/conversation-handle.test.ts +316 -0
  8. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/redacted-credential.test.ts +1 -1
  9. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/conversation-handle.ts +246 -0
  10. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  11. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +2 -2
  12. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +1 -0
  13. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/conversation-handle.test.ts +316 -0
  14. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/redacted-credential.test.ts +1 -1
  15. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/conversation-handle.ts +246 -0
  16. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  17. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +2 -2
  18. package/node_modules/@vellumai/ipc-server-utils/src/index.ts +10 -0
  19. package/{src/ipc → node_modules/@vellumai/ipc-server-utils/src}/ipc-framing.ts +21 -7
  20. package/node_modules/@vellumai/service-contracts/package.json +1 -0
  21. package/node_modules/@vellumai/service-contracts/src/__tests__/conversation-handle.test.ts +316 -0
  22. package/node_modules/@vellumai/service-contracts/src/__tests__/redacted-credential.test.ts +1 -1
  23. package/node_modules/@vellumai/service-contracts/src/conversation-handle.ts +246 -0
  24. package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  25. package/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +2 -2
  26. package/openapi.yaml +358 -10
  27. package/package.json +1 -1
  28. package/scripts/build-plugin-api.ts +11 -4
  29. package/scripts/capture-x-graphql.ts +54 -20
  30. package/scripts/generate-openapi.ts +7 -3
  31. package/scripts/memory-inspect.ts +17 -6
  32. package/scripts/sync-llm-catalog.ts +44 -19
  33. package/scripts/sync-web-search-catalog.ts +3 -1
  34. package/scripts/voice-ttft-spike.ts +6 -3
  35. package/src/__tests__/add-message-skip-indexing.test.ts +3 -2
  36. package/src/__tests__/agent-loop-history-repair.test.ts +180 -0
  37. package/src/__tests__/agent-loop-output-hooks.test.ts +35 -11
  38. package/src/__tests__/agent-loop-regrowth-guard.test.ts +3 -1
  39. package/src/__tests__/agent-loop.test.ts +5 -2
  40. package/src/__tests__/anthropic-error-formatting.test.ts +3 -1
  41. package/src/__tests__/app-control-flow.test.ts +3 -1
  42. package/src/__tests__/app-control-tool-schemas.test.ts +6 -2
  43. package/src/__tests__/app-dir-path-guard.test.ts +9 -3
  44. package/src/__tests__/app-routes-csp.test.ts +12 -4
  45. package/src/__tests__/app-source-watcher.test.ts +3 -1
  46. package/src/__tests__/approval-primitive.test.ts +66 -22
  47. package/src/__tests__/assistant-feature-flag-guard.test.ts +6 -2
  48. package/src/__tests__/assistant-feature-flag-guardrails.test.ts +12 -4
  49. package/src/__tests__/assistant-id-boundary-guard.test.ts +26 -9
  50. package/src/__tests__/attachments-store.test.ts +12 -4
  51. package/src/__tests__/avatar-generator.test.ts +3 -1
  52. package/src/__tests__/background-shell-bash.test.ts +3 -1
  53. package/src/__tests__/browser-fill-credential.test.ts +6 -2
  54. package/src/__tests__/browser-runtime-check.test.ts +3 -1
  55. package/src/__tests__/build-persisted-content.test.ts +3 -1
  56. package/src/__tests__/bundled-skill-retrieval-guard.test.ts +15 -5
  57. package/src/__tests__/byok-default-profile-ensure.test.ts +1095 -0
  58. package/src/__tests__/call-controller.test.ts +9 -3
  59. package/src/__tests__/call-domain.test.ts +15 -8
  60. package/src/__tests__/call-setup-flow-midcall-trust.test.ts +3 -1
  61. package/src/__tests__/call-state-machine.test.ts +3 -1
  62. package/src/__tests__/channel-approval-routes.test.ts +2 -1
  63. package/src/__tests__/channel-approval.test.ts +9 -6
  64. package/src/__tests__/channel-guardian.test.ts +3 -1
  65. package/src/__tests__/channel-setup-panel-ack.test.ts +1 -3
  66. package/src/__tests__/clawhub.test.ts +3 -1
  67. package/src/__tests__/cli-memory-v2-reembed-skills.test.ts +3 -1
  68. package/src/__tests__/compact-event-conversation-id-guard.test.ts +3 -2
  69. package/src/__tests__/compaction-summary-head-persisted-count.test.ts +1 -1
  70. package/src/__tests__/config-get-vision-flag.test.ts +1 -1
  71. package/src/__tests__/config-loader-backfill.test.ts +199 -134
  72. package/src/__tests__/config-loader-corrupt.test.ts +3 -1
  73. package/src/__tests__/config-loader-platform-defaults.test.ts +3 -1
  74. package/src/__tests__/config-loader-quarantine-notice.test.ts +3 -1
  75. package/src/__tests__/config-loader-validation-reset-notice.test.ts +3 -1
  76. package/src/__tests__/config-model-image-provider.test.ts +3 -1
  77. package/src/__tests__/config-set-platform-guard.test.ts +3 -1
  78. package/src/__tests__/config-watcher.test.ts +3 -1
  79. package/src/__tests__/connection-model-compat.test.ts +3 -1
  80. package/src/__tests__/contact-store-user-file.test.ts +18 -6
  81. package/src/__tests__/contacts-relay-reads.test.ts +31 -22
  82. package/src/__tests__/contacts-tools.test.ts +3 -1
  83. package/src/__tests__/context-overflow-reducer.test.ts +3 -1
  84. package/src/__tests__/context-search-conversations-source.test.ts +4 -1
  85. package/src/__tests__/context-search-memory-v2-source.test.ts +3 -1
  86. package/src/__tests__/conversation-agent-loop-handlers-max-tokens.test.ts +3 -1
  87. package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +1 -1
  88. package/src/__tests__/conversation-agent-loop-overflow.test.ts +1 -1
  89. package/src/__tests__/conversation-agent-loop.test.ts +1 -1
  90. package/src/__tests__/conversation-delete-schedule-cleanup.test.ts +3 -3
  91. package/src/__tests__/conversation-delete-subagent-rows.test.ts +303 -0
  92. package/src/__tests__/conversation-fork-route.test.ts +3 -1
  93. package/src/__tests__/conversation-inference-profile-list.test.ts +3 -1
  94. package/src/__tests__/conversation-list-source.test.ts +3 -1
  95. package/src/__tests__/conversation-loop-db-lock-resilience.test.ts +9 -8
  96. package/src/__tests__/conversation-pairing.test.ts +6 -2
  97. package/src/__tests__/conversation-pre-run-repair.test.ts +1 -1
  98. package/src/__tests__/conversation-queue.test.ts +65 -1
  99. package/src/__tests__/conversation-routes-disk-view.test.ts +18 -6
  100. package/src/__tests__/conversation-slash-commands.test.ts +27 -9
  101. package/src/__tests__/conversation-slash.test.ts +92 -0
  102. package/src/__tests__/conversation-starter-routes.test.ts +6 -2
  103. package/src/__tests__/conversation-surfaces-app-control.test.ts +3 -1
  104. package/src/__tests__/conversation-surfaces-app-open.test.ts +1 -3
  105. package/src/__tests__/conversation-surfaces-queued-emit.test.ts +86 -0
  106. package/src/__tests__/conversation-surfaces-standalone.test.ts +6 -2
  107. package/src/__tests__/conversation-surfaces-state-update.test.ts +1 -3
  108. package/src/__tests__/conversation-surfaces-table-action.test.ts +1 -3
  109. package/src/__tests__/conversation-usage.test.ts +159 -0
  110. package/src/__tests__/conversations-import-system-filter.test.ts +101 -4
  111. package/src/__tests__/credential-broker-server-use.test.ts +21 -7
  112. package/src/__tests__/credential-broker.test.ts +30 -10
  113. package/src/__tests__/credential-execution-client.test.ts +17 -6
  114. package/src/__tests__/credential-security-invariants.test.ts +3 -1
  115. package/src/__tests__/custom-group-listing-visibility.test.ts +93 -0
  116. package/src/__tests__/db-migration-rollback.test.ts +21 -7
  117. package/src/__tests__/db-readiness-http-gate.test.ts +3 -1
  118. package/src/__tests__/db-schedule-syntax-migration.test.ts +1 -0
  119. package/src/__tests__/default-provider-ensure.test.ts +10 -1
  120. package/src/__tests__/disk-pressure-guard.test.ts +3 -1
  121. package/src/__tests__/dm-backfill.test.ts +3 -1
  122. package/src/__tests__/dm-persistence.test.ts +3 -1
  123. package/src/__tests__/docker-signing-key-bootstrap.test.ts +2 -1
  124. package/src/__tests__/edit-engine.test.ts +42 -14
  125. package/src/__tests__/events-dev-bypass-actor.test.ts +3 -1
  126. package/src/__tests__/file-ops-service.test.ts +60 -20
  127. package/src/__tests__/filesystem-tools.test.ts +90 -30
  128. package/src/__tests__/fixtures/mock-chrome-extension.ts +18 -6
  129. package/src/__tests__/fixtures/mock-signup-server.ts +6 -2
  130. package/src/__tests__/fuzzy-match-property.test.ts +18 -6
  131. package/src/__tests__/gateway-flag-listener.test.ts +9 -3
  132. package/src/__tests__/gateway-only-enforcement.test.ts +2 -1
  133. package/src/__tests__/gateway-only-guard.test.ts +12 -4
  134. package/src/__tests__/gemini-image-service.test.ts +3 -1
  135. package/src/__tests__/gemini-provider.test.ts +81 -2
  136. package/src/__tests__/get-skill-detail-audit.test.ts +9 -3
  137. package/src/__tests__/google-calendar-watcher.test.ts +75 -0
  138. package/src/__tests__/guardian-card-rehydration.test.ts +210 -0
  139. package/src/__tests__/guardian-card-withdrawal.test.ts +37 -2
  140. package/src/__tests__/guardian-decision-primitive-canonical.test.ts +42 -14
  141. package/src/__tests__/guardian-expiry-notifier.test.ts +3 -1
  142. package/src/__tests__/guardian-question-mode.test.ts +12 -4
  143. package/src/__tests__/headless-browser-interactions.test.ts +6 -2
  144. package/src/__tests__/headless-browser-mode.test.ts +6 -2
  145. package/src/__tests__/headless-browser-navigate.test.ts +33 -11
  146. package/src/__tests__/headless-browser-read-tools.test.ts +24 -8
  147. package/src/__tests__/headless-browser-snapshot.test.ts +3 -1
  148. package/src/__tests__/helpers/channel-test-adapter.ts +17 -7
  149. package/src/__tests__/helpers/create-guardian-binding.ts +3 -1
  150. package/src/__tests__/helpers/derive-guardian-delivery.ts +3 -1
  151. package/src/__tests__/helpers/gateway-acl-store.ts +6 -2
  152. package/src/__tests__/helpers/gateway-classify-mock.ts +3 -1
  153. package/src/__tests__/helpers/seed-contact-channel.ts +3 -1
  154. package/src/__tests__/helpers/tar-fixtures.ts +3 -1
  155. package/src/__tests__/history-repair-observability.test.ts +1 -1
  156. package/src/__tests__/history-repair.test.ts +2 -2
  157. package/src/__tests__/host-app-control-routes.test.ts +98 -2
  158. package/src/__tests__/host-bash-routes.test.ts +66 -0
  159. package/src/__tests__/host-cu-proxy.test.ts +7 -1
  160. package/src/__tests__/host-cu-routes-targeted.test.ts +87 -0
  161. package/src/__tests__/host-file-routes-targeted.test.ts +60 -0
  162. package/src/__tests__/host-proxy-preactivation.test.ts +1 -5
  163. package/src/__tests__/host-transfer-proxy.test.ts +4 -4
  164. package/src/__tests__/host-transfer-routes-targeted.test.ts +3 -1
  165. package/src/__tests__/image-recovery-hook.test.ts +3 -3
  166. package/src/__tests__/inbound-slack-persistence.test.ts +3 -1
  167. package/src/__tests__/injector-config-quarantine-notice.test.ts +3 -1
  168. package/src/__tests__/injector-config-validation-reset-notice.test.ts +3 -1
  169. package/src/__tests__/injector-disk-pressure.test.ts +3 -1
  170. package/src/__tests__/injector-document-comments.test.ts +3 -1
  171. package/src/__tests__/injector-v3-suppression.test.ts +6 -2
  172. package/src/__tests__/inline-skill-authoring-guard.test.ts +12 -4
  173. package/src/__tests__/internal-telemetry-routes.test.ts +3 -1
  174. package/src/__tests__/lexical-index-dual-write.test.ts +3 -1
  175. package/src/__tests__/lifecycle-memory-v2-seed.test.ts +9 -3
  176. package/src/__tests__/llm-callsite-catalog.test.ts +3 -1
  177. package/src/__tests__/llm-catalog-parity.test.ts +21 -7
  178. package/src/__tests__/managed-profile-guard.test.ts +53 -0
  179. package/src/__tests__/max-tokens-continue-hook.test.ts +120 -0
  180. package/src/__tests__/mcp-cli.test.ts +10 -3
  181. package/src/__tests__/media-stream-output.test.ts +9 -3
  182. package/src/__tests__/media-stream-parser.test.ts +111 -37
  183. package/src/__tests__/media-stream-stt-session.test.ts +34 -11
  184. package/src/__tests__/memory-upsert-concurrency.test.ts +19 -16
  185. package/src/__tests__/message-delete-segment-purge.test.ts +98 -0
  186. package/src/__tests__/migration-cross-version-compatibility.test.ts +3 -1
  187. package/src/__tests__/migration-export-http.test.ts +9 -3
  188. package/src/__tests__/migration-export-streaming.test.ts +9 -3
  189. package/src/__tests__/migration-import-commit-http.test.ts +21 -7
  190. package/src/__tests__/migration-import-preflight-http.test.ts +3 -1
  191. package/src/__tests__/migration-validate-http.test.ts +3 -1
  192. package/src/__tests__/mock-fetch.ts +3 -1
  193. package/src/__tests__/mock-gateway-ipc.ts +20 -7
  194. package/src/__tests__/mock-signup-server.test.ts +9 -3
  195. package/src/__tests__/model-intents.test.ts +1 -1
  196. package/src/__tests__/native-web-search.test.ts +3 -1
  197. package/src/__tests__/no-is-trusted-guard.test.ts +3 -1
  198. package/src/__tests__/notification-broadcaster.test.ts +5 -3
  199. package/src/__tests__/notification-platform-adapter.test.ts +12 -4
  200. package/src/__tests__/oauth-apps-routes.test.ts +3 -1
  201. package/src/__tests__/oauth-commands-routes.test.ts +9 -3
  202. package/src/__tests__/oauth-connect-orchestrator.test.ts +33 -11
  203. package/src/__tests__/oauth-connect-routes.test.ts +3 -1
  204. package/src/__tests__/oauth-providers-routes.test.ts +15 -10
  205. package/src/__tests__/oauth2-refresh-retry.test.ts +3 -1
  206. package/src/__tests__/onboarding-persona-write.test.ts +12 -10
  207. package/src/__tests__/openai-image-service.test.ts +6 -2
  208. package/src/__tests__/openai-provider.test.ts +3 -1
  209. package/src/__tests__/openai-responses-cutover-guard.test.ts +3 -1
  210. package/src/__tests__/openai-responses-provider.test.ts +3 -1
  211. package/src/__tests__/outbound-slack-persistence.test.ts +18 -6
  212. package/src/__tests__/persist-media-references.test.ts +3 -1
  213. package/src/__tests__/persist-onboarding-artifacts.test.ts +3 -1
  214. package/src/__tests__/persist-unsendable-image-downscale.test.ts +3 -3
  215. package/src/__tests__/persist-unsendable-image.test.ts +3 -3
  216. package/src/__tests__/persist-user-message-set-processing-failure.test.ts +3 -1
  217. package/src/__tests__/persistence-secret-redaction.test.ts +9 -3
  218. package/src/__tests__/persona-resolver.test.ts +3 -1
  219. package/src/__tests__/plugin-api-tool-definition.test.ts +5 -8
  220. package/src/__tests__/plugin-bootstrap.test.ts +2 -3
  221. package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -0
  222. package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +1 -4
  223. package/src/__tests__/post-turn-tool-result-truncation.test.ts +112 -1
  224. package/src/__tests__/prechat-onboarding-contract.test.ts +6 -2
  225. package/src/__tests__/pricing.test.ts +2 -2
  226. package/src/__tests__/process-message-background-slack.test.ts +3 -1
  227. package/src/__tests__/profiler-routes.test.ts +10 -12
  228. package/src/__tests__/provider-catalog-visibility.test.ts +12 -4
  229. package/src/__tests__/provider-error-scenarios.test.ts +27 -9
  230. package/src/__tests__/provider-streaming.benchmark.test.ts +12 -4
  231. package/src/__tests__/recording-handler.test.ts +7 -3
  232. package/src/__tests__/retry-thinking-preadaptive.test.ts +204 -0
  233. package/src/__tests__/run-conversation-turn-persistence.test.ts +3 -1
  234. package/src/__tests__/runtime-events-sse-reconnect.test.ts +3 -1
  235. package/src/__tests__/schedule-retry.test.ts +3 -1
  236. package/src/__tests__/schedule-routes-workflow-validation.test.ts +9 -3
  237. package/src/__tests__/schedule-routes.test.ts +3 -1
  238. package/src/__tests__/schedule-store.test.ts +113 -9
  239. package/src/__tests__/schedule-tools.test.ts +106 -0
  240. package/src/__tests__/scheduler-reuse-conversation.test.ts +3 -1
  241. package/src/__tests__/scheduler-wake.test.ts +47 -8
  242. package/src/__tests__/script-proxy-injection-runtime.test.ts +14 -5
  243. package/src/__tests__/script-proxy-mitm-handler.test.ts +12 -4
  244. package/src/__tests__/script-proxy-rewrite-specificity.test.ts +12 -4
  245. package/src/__tests__/search-skills-unified.test.ts +27 -9
  246. package/src/__tests__/service-contracts-import-guard.test.ts +12 -4
  247. package/src/__tests__/settings-routes.test.ts +3 -1
  248. package/src/__tests__/shell-credential-ref.test.ts +6 -2
  249. package/src/__tests__/shell-observability.test.ts +3 -1
  250. package/src/__tests__/skill-cache-store.test.ts +3 -1
  251. package/src/__tests__/skill-feature-flags-integration.test.ts +3 -1
  252. package/src/__tests__/skill-secret-handling-guard.test.ts +11 -4
  253. package/src/__tests__/skills-file-content-endpoint.test.ts +93 -31
  254. package/src/__tests__/skills-files-catalog-fallback.test.ts +33 -11
  255. package/src/__tests__/skills.test.ts +33 -14
  256. package/src/__tests__/slack-channel-config.test.ts +6 -2
  257. package/src/__tests__/slack-messaging-token-resolution.test.ts +6 -2
  258. package/src/__tests__/sse-actor-principal-guardian-source.test.ts +3 -1
  259. package/src/__tests__/steer-on-enqueue-question.test.ts +3 -1
  260. package/src/__tests__/steer-tool-repair.test.ts +6 -2
  261. package/src/__tests__/stt-language-catalog-parity.test.ts +131 -0
  262. package/src/__tests__/subagent-allowlist-validation.test.ts +3 -1
  263. package/src/__tests__/subagent-detail.test.ts +317 -3
  264. package/src/__tests__/subagent-disposal.test.ts +149 -1
  265. package/src/__tests__/subagent-fork-prompt-role.test.ts +3 -1
  266. package/src/__tests__/subagent-notify-parent.test.ts +1 -0
  267. package/src/__tests__/subagent-persistence.test.ts +444 -7
  268. package/src/__tests__/subagent-reconcile-route.test.ts +423 -0
  269. package/src/__tests__/subagent-role-registry.test.ts +3 -1
  270. package/src/__tests__/subagent-tools.test.ts +304 -0
  271. package/src/__tests__/system-prompt.test.ts +12 -5
  272. package/src/__tests__/task-progress-nudge-hook.test.ts +3 -1
  273. package/src/__tests__/telegram-bot-username-resolution.test.ts +3 -1
  274. package/src/__tests__/telegram-config.test.ts +3 -1
  275. package/src/__tests__/telemetry-routes.test.ts +8 -3
  276. package/src/__tests__/thinking-block-replay.test.ts +1 -2
  277. package/src/__tests__/thread-backfill.test.ts +24 -8
  278. package/src/__tests__/token-estimator-accuracy.benchmark.test.ts +6 -2
  279. package/src/__tests__/token-manager.test.ts +36 -12
  280. package/src/__tests__/tool-preview-lifecycle.test.ts +3 -6
  281. package/src/__tests__/tool-result-truncation.test.ts +3 -1
  282. package/src/__tests__/trusted-contact-approval-notifier.test.ts +6 -2
  283. package/src/__tests__/tts-catalog-parity.test.ts +6 -2
  284. package/src/__tests__/twilio-provider.test.ts +6 -2
  285. package/src/__tests__/unicode.test.ts +1 -3
  286. package/src/__tests__/usage-cli.test.ts +3 -1
  287. package/src/__tests__/usage-routes.test.ts +3 -1
  288. package/src/__tests__/validate-input.test.ts +27 -9
  289. package/src/__tests__/voice-approval-resolver-relay.test.ts +15 -5
  290. package/src/__tests__/voice-config-update.test.ts +257 -2
  291. package/src/__tests__/wake-schedule-escalation.test.ts +477 -0
  292. package/src/__tests__/wake-schedule-trust.test.ts +255 -0
  293. package/src/__tests__/web-fetch.test.ts +21 -7
  294. package/src/__tests__/web-search-catalog-parity.test.ts +11 -4
  295. package/src/__tests__/web-search-history.test.ts +72 -78
  296. package/src/__tests__/web-search.test.ts +15 -5
  297. package/src/__tests__/workspace-greetings.test.ts +3 -1
  298. package/src/__tests__/workspace-migration-026-backfill-install-meta.test.ts +3 -1
  299. package/src/__tests__/workspace-migration-043-release-notes-latex-rendering.test.ts +3 -1
  300. package/src/__tests__/workspace-migration-082-backfill-managed-profile-labels.test.ts +1 -4
  301. package/src/__tests__/workspace-migration-130-speech-mode-to-provider.test.ts +3 -1
  302. package/src/__tests__/workspace-migration-136-repair-stale-fireworks-kimi-model-id.test.ts +139 -0
  303. package/src/__tests__/workspace-migration-down-functions.test.ts +5 -2
  304. package/src/__tests__/workspace-migration-meets.test.ts +4 -6
  305. package/src/__tests__/workspace-migration-memory-v2-init.test.ts +3 -1
  306. package/src/__tests__/workspace-migration-seed-device-id.test.ts +3 -1
  307. package/src/a2a/__tests__/agent-card.test.ts +5 -21
  308. package/src/a2a/agent-card.ts +11 -17
  309. package/src/acp/__tests__/helpers/exec-file-stub.ts +3 -1
  310. package/src/acp/__tests__/prepare-agent-env.test.ts +3 -1
  311. package/src/acp/agent-process.ts +18 -6
  312. package/src/acp/auto-install.test.ts +9 -3
  313. package/src/acp/auto-install.ts +6 -2
  314. package/src/acp/failure-error.ts +8 -3
  315. package/src/acp/prepare-agent-env.ts +3 -1
  316. package/src/acp/resolve-agent.test.ts +81 -27
  317. package/src/acp/resolve-agent.ts +9 -3
  318. package/src/{plugins/defaults/history-repair/terminal.ts → agent/history-repair/history-repair.ts} +42 -11
  319. package/src/agent/image-optimize.ts +18 -6
  320. package/src/agent/loop.ts +45 -10
  321. package/src/api/events/contact-request.ts +1 -0
  322. package/src/api/events/message-dequeued.ts +4 -0
  323. package/src/api/events/message-queued-deleted.ts +4 -0
  324. package/src/api/events/message-queued.ts +4 -0
  325. package/src/api/events/tool-result.ts +1 -0
  326. package/src/api/responses/subagent-detail.ts +13 -6
  327. package/src/approvals/guardian-card-withdrawal.ts +30 -11
  328. package/src/apps/app-store.ts +65 -22
  329. package/src/apps/shared-app-links-store.ts +9 -3
  330. package/src/avatar/__tests__/avatar-store.test.ts +6 -2
  331. package/src/avatar/avatar-manifest.ts +18 -6
  332. package/src/avatar/resvg-lazy.test.ts +6 -2
  333. package/src/background-wake/background-wake-routes.test.ts +9 -3
  334. package/src/background-wake/next-wake.ts +15 -5
  335. package/src/background-wake/platform-client.ts +18 -6
  336. package/src/background-wake/publisher.ts +3 -1
  337. package/src/backup/__tests__/paths.test.ts +0 -1
  338. package/src/backup/__tests__/restore.test.ts +1 -6
  339. package/src/backup/__tests__/snapshot-lock.test.ts +3 -2
  340. package/src/backup/list-snapshots.ts +15 -5
  341. package/src/backup/local-writer.ts +9 -3
  342. package/src/backup/paths.ts +6 -3
  343. package/src/backup/snapshot-lock.ts +18 -6
  344. package/src/browser-session/__tests__/manager.test.ts +6 -2
  345. package/src/browser-session/manager.ts +6 -2
  346. package/src/bundler/app-compiler.ts +44 -15
  347. package/src/bundler/bundle-scanner.ts +29 -10
  348. package/src/bundler/bundle-signer.ts +3 -1
  349. package/src/bundler/compiler-tools.ts +15 -5
  350. package/src/bundler/package-resolver.ts +3 -1
  351. package/src/bundler/signature-verifier.ts +3 -1
  352. package/src/calls/__tests__/inbound-trust-reader.test.ts +1 -4
  353. package/src/calls/__tests__/tts-text-sanitizer.test.ts +11 -11
  354. package/src/calls/access-request-wait.ts +9 -3
  355. package/src/calls/audio-store.ts +9 -3
  356. package/src/calls/call-constants.ts +6 -2
  357. package/src/calls/call-controller.ts +72 -25
  358. package/src/calls/call-pointer-message-composer.ts +11 -4
  359. package/src/calls/call-pointer-messages.ts +24 -8
  360. package/src/calls/call-store.ts +12 -4
  361. package/src/calls/guardian-action-sweep.ts +3 -1
  362. package/src/calls/inbound-trust-reader.ts +5 -1
  363. package/src/calls/media-stream-audio-transcode.ts +9 -3
  364. package/src/calls/media-stream-output.ts +41 -15
  365. package/src/calls/media-stream-stt-session.ts +21 -7
  366. package/src/calls/media-turn-detector.ts +9 -3
  367. package/src/calls/speaker-identification.ts +21 -7
  368. package/src/calls/telephony-credential-preflight.ts +1 -3
  369. package/src/calls/tts-text-sanitizer.ts +2 -8
  370. package/src/calls/twilio-config.ts +3 -1
  371. package/src/calls/twilio-provider.ts +3 -1
  372. package/src/calls/twilio-rest.ts +3 -1
  373. package/src/calls/voice-control-protocol.ts +12 -4
  374. package/src/channels/__tests__/gateway-verification-sessions.test.ts +2 -3
  375. package/src/channels/permission-profiles.ts +9 -3
  376. package/src/channels/slack-callback-url.ts +9 -3
  377. package/src/channels/types.ts +17 -6
  378. package/src/cli/__tests__/run-assistant-command.ts +3 -1
  379. package/src/cli/__tests__/unknown-command.test.ts +3 -1
  380. package/src/cli/commands/__tests__/attachment.test.ts +3 -1
  381. package/src/cli/commands/__tests__/avatar.test.ts +18 -10
  382. package/src/cli/commands/__tests__/backup.test.ts +30 -10
  383. package/src/cli/commands/__tests__/browser.test.ts +3 -1
  384. package/src/cli/commands/__tests__/cache.test.ts +3 -1
  385. package/src/cli/commands/__tests__/changelog.test.ts +3 -1
  386. package/src/cli/commands/__tests__/channel-verification-sessions.test.ts +11 -6
  387. package/src/cli/commands/__tests__/conversations-import.test.ts +3 -1
  388. package/src/cli/commands/__tests__/conversations-new.test.ts +9 -3
  389. package/src/cli/commands/__tests__/conversations-slack.test.ts +15 -5
  390. package/src/cli/commands/__tests__/conversations-wake.test.ts +13 -3
  391. package/src/cli/commands/__tests__/domain-register.test.ts +1 -3
  392. package/src/cli/commands/__tests__/domain-status.test.ts +13 -5
  393. package/src/cli/commands/__tests__/email-attachment.test.ts +61 -19
  394. package/src/cli/commands/__tests__/email-core.test.ts +126 -49
  395. package/src/cli/commands/__tests__/gateway.test.ts +6 -2
  396. package/src/cli/commands/__tests__/image-generation.test.ts +5 -2
  397. package/src/cli/commands/__tests__/inference-send.test.ts +3 -1
  398. package/src/cli/commands/__tests__/skills.test.ts +3 -1
  399. package/src/cli/commands/__tests__/status.test.ts +16 -3
  400. package/src/cli/commands/__tests__/stt.test.ts +23 -5
  401. package/src/cli/commands/__tests__/trust.test.ts +3 -1
  402. package/src/cli/commands/__tests__/tts.test.ts +6 -2
  403. package/src/cli/commands/__tests__/ui-confirm.test.ts +3 -1
  404. package/src/cli/commands/__tests__/ui.test.ts +3 -1
  405. package/src/cli/commands/__tests__/watchers.test.ts +3 -1
  406. package/src/cli/commands/__tests__/webhooks.test.ts +23 -5
  407. package/src/cli/commands/audit.ts +7 -3
  408. package/src/cli/commands/avatar.ts +14 -7
  409. package/src/cli/commands/backup.ts +42 -17
  410. package/src/cli/commands/cache.ts +9 -3
  411. package/src/cli/commands/changelog.ts +50 -18
  412. package/src/cli/commands/channel-verification-sessions.ts +25 -10
  413. package/src/cli/commands/channels/__tests__/channels.test.ts +8 -13
  414. package/src/cli/commands/channels/index.ts +12 -4
  415. package/src/cli/commands/clients.ts +12 -4
  416. package/src/cli/commands/contacts.help.ts +5 -0
  417. package/src/cli/commands/contacts.ts +30 -12
  418. package/src/cli/commands/conversations-import.ts +2 -1
  419. package/src/cli/commands/conversations.ts +12 -4
  420. package/src/cli/commands/db/__tests__/repair.test.ts +6 -2
  421. package/src/cli/commands/db/format.ts +18 -6
  422. package/src/cli/commands/db/repair-steps.ts +3 -1
  423. package/src/cli/commands/db/status.ts +6 -2
  424. package/src/cli/commands/gateway.ts +25 -9
  425. package/src/cli/commands/image-generation.ts +5 -2
  426. package/src/cli/commands/inference-session.ts +6 -2
  427. package/src/cli/commands/inference.ts +44 -6
  428. package/src/cli/commands/memory/__tests__/memory-ingest.test.ts +591 -0
  429. package/src/cli/commands/memory/__tests__/memory-v2.test.ts +3 -1
  430. package/src/cli/commands/memory/__tests__/memory-v3.test.ts +3 -1
  431. package/src/cli/commands/memory/__tests__/worker.test.ts +3 -1
  432. package/src/cli/commands/memory/index.help.ts +55 -1
  433. package/src/cli/commands/memory/index.ts +2 -0
  434. package/src/cli/commands/memory/memory-ingest.ts +273 -0
  435. package/src/cli/commands/memory/memory-v2-compare-render.ts +3 -1
  436. package/src/cli/commands/memory/memory-v2.ts +12 -4
  437. package/src/cli/commands/memory/memory-v3.ts +3 -1
  438. package/src/cli/commands/notifications.ts +56 -19
  439. package/src/cli/commands/oauth/apps.ts +15 -5
  440. package/src/cli/commands/oauth/disconnect.ts +9 -3
  441. package/src/cli/commands/oauth/mode.ts +6 -2
  442. package/src/cli/commands/oauth/ping.ts +9 -3
  443. package/src/cli/commands/oauth/providers.ts +223 -92
  444. package/src/cli/commands/oauth/request.ts +26 -9
  445. package/src/cli/commands/oauth/token.ts +9 -3
  446. package/src/cli/commands/platform/__tests__/callback-routes-list.test.ts +7 -8
  447. package/src/cli/commands/platform/__tests__/plans.test.ts +129 -0
  448. package/src/cli/commands/platform/__tests__/subscription.test.ts +121 -0
  449. package/src/cli/commands/platform/connect.ts +2 -1
  450. package/src/cli/commands/platform/disconnect.ts +2 -1
  451. package/src/cli/commands/platform/index.help.ts +55 -0
  452. package/src/cli/commands/platform/index.ts +118 -4
  453. package/src/cli/commands/ps.ts +3 -1
  454. package/src/cli/commands/sequence.ts +43 -15
  455. package/src/cli/commands/skills.ts +103 -45
  456. package/src/cli/commands/status.ts +3 -1
  457. package/src/cli/commands/telemetry.ts +2 -1
  458. package/src/cli/commands/ui.ts +6 -2
  459. package/src/cli/commands/watchers.ts +31 -11
  460. package/src/cli/commands/webhooks.ts +4 -2
  461. package/src/cli/lib/__tests__/inspect-plugin.test.ts +3 -1
  462. package/src/cli/lib/__tests__/list-installed-plugins.test.ts +4 -2
  463. package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +5 -2
  464. package/src/cli/lib/__tests__/plugin-catalog-resolve.test.ts +20 -11
  465. package/src/cli/lib/__tests__/plugin-details.test.ts +13 -7
  466. package/src/cli/lib/__tests__/plugin-pin-history.test.ts +3 -1
  467. package/src/cli/lib/__tests__/plugins-install-offline.test.ts +17 -5
  468. package/src/cli/lib/__tests__/publish-plugin.test.ts +51 -22
  469. package/src/cli/lib/__tests__/search-plugins.test.ts +13 -6
  470. package/src/cli/lib/__tests__/upgrade-plugin.test.ts +9 -3
  471. package/src/cli/lib/bundled-marketplace.json +13 -0
  472. package/src/cli/lib/cli-colors.ts +24 -8
  473. package/src/cli/lib/confirm-prompt.ts +3 -1
  474. package/src/cli/lib/install-from-github.ts +6 -2
  475. package/src/cli/lib/ipc-params.ts +6 -2
  476. package/src/cli/lib/list-installed-plugins.ts +21 -7
  477. package/src/cli/lib/parse-github-plugin-spec.ts +15 -5
  478. package/src/cli/lib/plugin-artifact.ts +9 -3
  479. package/src/cli/lib/plugin-catalog-platform.ts +7 -2
  480. package/src/cli/lib/plugin-catalog-resolve.ts +7 -5
  481. package/src/cli/lib/plugin-marketplace.ts +12 -4
  482. package/src/cli/lib/plugin-surfaces.ts +15 -5
  483. package/src/cli/lib/publish-plugin.ts +24 -8
  484. package/src/cli/lib/search-plugins.ts +3 -1
  485. package/src/cli/lib/time-ago.ts +18 -6
  486. package/src/cli/lib/unknown-command.ts +12 -4
  487. package/src/cli/output.ts +3 -1
  488. package/src/cli/program.ts +3 -1
  489. package/src/cli/utils/__tests__/conversation-id.test.ts +3 -3
  490. package/src/cli/utils/conversation-id.ts +9 -3
  491. package/src/cli/utils/parse-duration.ts +6 -2
  492. package/src/config/__tests__/default-plugin-skill-discovery.test.ts +158 -0
  493. package/src/config/__tests__/default-profile-catalog.test.ts +60 -1
  494. package/src/config/__tests__/deployment-context-defaults.test.ts +9 -3
  495. package/src/config/__tests__/feature-flag-registry-guard.test.ts +7 -2
  496. package/src/config/__tests__/loader-callsite-strip-fallback.test.ts +9 -3
  497. package/src/config/__tests__/plugin-resident-skill-discovery.test.ts +5 -2
  498. package/src/config/__tests__/seed-default-provider.test.ts +16 -0
  499. package/src/config/__tests__/sync-gated-profiles.test.ts +6 -2
  500. package/src/config/assistant-feature-flags.ts +32 -11
  501. package/src/config/bundled-skills/app-builder/SKILL.md +3 -3
  502. package/src/config/bundled-skills/app-builder/references/CUSTOM_ROUTES.md +24 -34
  503. package/src/config/bundled-skills/app-builder/references/DESIGN_SYSTEM.md +1 -1
  504. package/src/config/bundled-skills/app-builder/references/SLIDES.md +1 -0
  505. package/src/config/bundled-skills/app-builder/references/WIDGETS.md +1 -1
  506. package/src/config/bundled-skills/app-builder/tools/app-generate-icon.ts +3 -1
  507. package/src/config/bundled-skills/app-builder/tools/app-refresh.ts +3 -1
  508. package/src/config/bundled-skills/app-builder/tools/app-update.ts +3 -1
  509. package/src/config/bundled-skills/contacts/tools/contact-search.ts +11 -4
  510. package/src/config/bundled-skills/contacts/tools/google-contacts.ts +6 -2
  511. package/src/config/bundled-skills/media-processing/__tests__/extract-keyframes.test.ts +3 -1
  512. package/src/config/bundled-skills/media-processing/services/preprocess.ts +9 -3
  513. package/src/config/bundled-skills/media-processing/services/processing-pipeline.ts +9 -3
  514. package/src/config/bundled-skills/media-processing/services/reduce.ts +3 -1
  515. package/src/config/bundled-skills/media-processing/tools/generate-clip.ts +3 -1
  516. package/src/config/bundled-skills/media-processing/tools/ingest-media.ts +12 -4
  517. package/src/config/bundled-skills/messaging/SKILL.md +2 -2
  518. package/src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts +6 -2
  519. package/src/config/bundled-skills/messaging/tools/messaging-draft.ts +23 -8
  520. package/src/config/bundled-skills/messaging/tools/messaging-send.ts +5 -2
  521. package/src/config/bundled-skills/messaging/tools/shared.ts +21 -7
  522. package/src/config/bundled-skills/phone-calls/references/TRANSCRIPTS.md +7 -7
  523. package/src/config/bundled-skills/playbooks/tools/playbook-list.ts +11 -4
  524. package/src/config/bundled-skills/schedule/SKILL.md +4 -0
  525. package/src/config/bundled-skills/schedule/TOOLS.json +8 -0
  526. package/src/config/bundled-skills/sequences/tools/sequence-create.ts +8 -3
  527. package/src/config/bundled-skills/sequences/tools/sequence-delete.ts +6 -2
  528. package/src/config/bundled-skills/sequences/tools/sequence-enroll.ts +12 -4
  529. package/src/config/bundled-skills/sequences/tools/sequence-enrollment-list.ts +3 -1
  530. package/src/config/bundled-skills/sequences/tools/sequence-get.ts +6 -2
  531. package/src/config/bundled-skills/sequences/tools/sequence-import.ts +13 -5
  532. package/src/config/bundled-skills/sequences/tools/sequence-list.ts +3 -1
  533. package/src/config/bundled-skills/sequences/tools/sequence-update.ts +17 -7
  534. package/src/config/bundled-skills/settings/TOOLS.json +4 -3
  535. package/src/config/bundled-skills/settings/tools/voice-config-update.ts +226 -2
  536. package/src/config/bundled-skills/skill-management/SKILL.md +1 -1
  537. package/src/config/bundled-skills/skill-management/TOOLS.json +1 -1
  538. package/src/config/bundled-skills/transcribe/tools/transcribe-media.test.ts +3 -1
  539. package/src/config/bundled-skills/transcribe/tools/transcribe-media.ts +15 -5
  540. package/src/config/default-profile-catalog.ts +103 -42
  541. package/src/config/default-profile-names.ts +16 -2
  542. package/src/config/env-registry.ts +3 -1
  543. package/src/config/env.ts +6 -2
  544. package/src/config/feature-flag-registry.json +8 -8
  545. package/src/config/llm-resolver.ts +4 -4
  546. package/src/config/loader.ts +42 -14
  547. package/src/config/prune-seeded-callsite-defaults.ts +30 -10
  548. package/src/config/schema-utils.ts +9 -3
  549. package/src/config/schemas/__tests__/stt.test.ts +27 -0
  550. package/src/config/schemas/llm.ts +48 -4
  551. package/src/config/schemas/memory-v3.ts +7 -7
  552. package/src/config/schemas/stt.ts +20 -1
  553. package/src/config/seed-inference-profiles.ts +84 -160
  554. package/src/config/skills.ts +195 -45
  555. package/src/config/sync-gated-profiles.ts +21 -7
  556. package/src/contacts/__tests__/guardian-contact-reader.test.ts +3 -1
  557. package/src/contacts/contact-store.ts +106 -37
  558. package/src/contacts/guardian-contact-reader.ts +3 -1
  559. package/src/contacts/guardian-delivery-reader.ts +15 -5
  560. package/src/context/compactor.ts +96 -32
  561. package/src/context/estimator-calibration.ts +9 -3
  562. package/src/context/image-dimensions.ts +75 -25
  563. package/src/context/post-turn-tool-result-truncation.ts +158 -23
  564. package/src/context/strip-injections.ts +15 -5
  565. package/src/context/token-estimator.ts +3 -1
  566. package/src/context/tool-result-spool.ts +3 -1
  567. package/src/context/tool-result-truncation.ts +6 -2
  568. package/src/conversations/job-handlers/summarization.ts +18 -6
  569. package/src/credential-execution/ces-runtime.ts +10 -10
  570. package/src/credential-execution/process-manager.test.ts +3 -1
  571. package/src/credential-execution/process-manager.ts +6 -2
  572. package/src/credential-health/credential-health-service.ts +30 -10
  573. package/src/daemon/__tests__/embedding-reconcile.test.ts +3 -1
  574. package/src/daemon/app-source-watcher.ts +21 -7
  575. package/src/daemon/assistant-attachments.ts +44 -15
  576. package/src/daemon/classifier.ts +9 -3
  577. package/src/daemon/connection-policy.ts +6 -2
  578. package/src/daemon/conversation-agent-loop.ts +10 -1
  579. package/src/daemon/conversation-error.ts +12 -4
  580. package/src/daemon/conversation-evictor.ts +12 -4
  581. package/src/daemon/conversation-media-retry.ts +18 -6
  582. package/src/daemon/conversation-messaging.ts +58 -15
  583. package/src/daemon/conversation-notices.ts +6 -2
  584. package/src/daemon/conversation-plugin-scope.ts +3 -1
  585. package/src/daemon/conversation-process.ts +2 -0
  586. package/src/daemon/conversation-queue-manager.ts +16 -8
  587. package/src/daemon/conversation-registry.ts +9 -3
  588. package/src/daemon/conversation-resting-trust.ts +64 -0
  589. package/src/daemon/conversation-runtime-assembly.ts +6 -2
  590. package/src/daemon/conversation-slash.ts +50 -17
  591. package/src/daemon/conversation-store.ts +16 -5
  592. package/src/daemon/conversation-surfaces.ts +2 -7
  593. package/src/daemon/conversation-usage.ts +109 -15
  594. package/src/daemon/conversation-workspace.ts +5 -2
  595. package/src/daemon/conversation.ts +1 -1
  596. package/src/daemon/daemon-control.ts +42 -14
  597. package/src/daemon/date-context.ts +15 -5
  598. package/src/daemon/dictation-profile-store.ts +26 -10
  599. package/src/daemon/dictation-text-processing.ts +9 -3
  600. package/src/daemon/disk-pressure-guard.ts +12 -4
  601. package/src/daemon/disk-pressure-policy.ts +15 -5
  602. package/src/daemon/first-greeting.ts +9 -3
  603. package/src/daemon/handlers/__tests__/config-channels.test.ts +9 -3
  604. package/src/daemon/handlers/config-channels.ts +3 -1
  605. package/src/daemon/handlers/conversations.ts +6 -2
  606. package/src/daemon/handlers/identity.ts +6 -2
  607. package/src/daemon/handlers/skills.ts +138 -48
  608. package/src/daemon/host-app-control-proxy.ts +3 -1
  609. package/src/daemon/host-bash-proxy.ts +11 -4
  610. package/src/daemon/host-cu-proxy.ts +20 -7
  611. package/src/daemon/host-transfer-proxy.ts +24 -8
  612. package/src/daemon/identity-helpers.ts +3 -1
  613. package/src/daemon/install-symlink.ts +18 -6
  614. package/src/daemon/interrupted-turn-reconciler.ts +7 -33
  615. package/src/daemon/lifecycle.ts +20 -5
  616. package/src/daemon/message-types/web-activity.ts +1 -0
  617. package/src/daemon/now-scratchpad.ts +3 -1
  618. package/src/daemon/orphan-reaper.test.ts +17 -6
  619. package/src/daemon/orphan-reaper.ts +24 -8
  620. package/src/daemon/parse-actual-tokens-from-error.ts +27 -9
  621. package/src/daemon/persist-media-references.ts +6 -2
  622. package/src/daemon/pkb-context-tracker.test.ts +37 -9
  623. package/src/daemon/pkb-context-tracker.ts +12 -4
  624. package/src/daemon/pointer-conversation-trust.ts +3 -1
  625. package/src/daemon/process-message.ts +3 -1
  626. package/src/daemon/profiler-run-store.ts +21 -7
  627. package/src/daemon/sqlite-corruption-watchdog.ts +6 -2
  628. package/src/daemon/summarize-boundary.ts +3 -1
  629. package/src/daemon/turn-latency-tracker.ts +33 -11
  630. package/src/daemon/verification-session-intent.ts +3 -1
  631. package/src/daemon/wake-conversation-ops.ts +3 -1
  632. package/src/daemon/web-search-history.ts +12 -4
  633. package/src/documents/document-store.ts +15 -5
  634. package/src/followups/followup-store.ts +9 -3
  635. package/src/heartbeat/heartbeat-run-store.ts +3 -1
  636. package/src/home/conversation-starter-checkpoints.ts +3 -1
  637. package/src/home/feed-source-enrichment.test.ts +7 -0
  638. package/src/home/feed-source-enrichment.ts +11 -2
  639. package/src/home/feed-writer.ts +27 -9
  640. package/src/home/home-greeting-cache.ts +3 -1
  641. package/src/home/job-handlers/conversation-starters.ts +15 -5
  642. package/src/home/post-connect-feed.ts +3 -1
  643. package/src/home/progress-formula.ts +6 -2
  644. package/src/home/relationship-state-writer.ts +78 -25
  645. package/src/ipc/__tests__/exit-helper.test.ts +12 -8
  646. package/src/ipc/__tests__/streaming-client.test.ts +54 -16
  647. package/src/ipc/__tests__/streaming-framing.test.ts +31 -8
  648. package/src/ipc/__tests__/ui-request-route.test.ts +3 -1
  649. package/src/ipc/__tests__/watcher-ipc.test.ts +6 -2
  650. package/src/ipc/assistant-server.ts +21 -13
  651. package/src/ipc/cli-client.ts +38 -13
  652. package/src/ipc/gateway-client.ts +6 -2
  653. package/src/ipc/gateway-flag-listener.ts +9 -3
  654. package/src/ipc/routes/__tests__/contacts-mirror-apply-atomicity.test.ts +7 -4
  655. package/src/ipc/routes/__tests__/contacts-mirror-apply.test.ts +22 -10
  656. package/src/ipc/routes/__tests__/contacts-mirror-ipc-routes.test.ts +26 -13
  657. package/src/ipc/routes/__tests__/contacts-mirror-merge-contact.test.ts +35 -9
  658. package/src/ipc/routes/__tests__/contacts-mirror-upsert-full.test.ts +37 -20
  659. package/src/ipc/routes/__tests__/guardian-label-ipc-routes.test.ts +4 -6
  660. package/src/ipc/routes/contacts-info-ipc-routes.ts +9 -6
  661. package/src/ipc/routes/trust-rules.test.ts +6 -2
  662. package/src/ipc/socket-cleanup.ts +6 -2
  663. package/src/live-voice/__tests__/live-activity-reporter.test.ts +194 -0
  664. package/src/live-voice/__tests__/live-voice-archive.test.ts +24 -8
  665. package/src/live-voice/__tests__/live-voice-stt.test.ts +330 -3
  666. package/src/live-voice/__tests__/live-voice-vad.test.ts +11 -1
  667. package/src/live-voice/__tests__/protocol.test.ts +45 -15
  668. package/src/live-voice/__tests__/runtime-websocket-shell.test.ts +6 -2
  669. package/src/live-voice/live-activity-reporter.ts +180 -0
  670. package/src/live-voice/live-voice-archive.ts +18 -6
  671. package/src/live-voice/live-voice-metrics.ts +24 -8
  672. package/src/live-voice/live-voice-session.ts +154 -15
  673. package/src/live-voice/protocol.ts +6 -2
  674. package/src/mcp/client.ts +9 -3
  675. package/src/mcp/manager.ts +3 -1
  676. package/src/mcp/mcp-auth-orchestrator.ts +3 -1
  677. package/src/mcp/mcp-header-store.ts +3 -1
  678. package/src/mcp/mcp-oauth-provider.ts +12 -4
  679. package/src/media/gemini-image-service.ts +15 -5
  680. package/src/media/openai-image-service.ts +9 -3
  681. package/src/messaging/draft-store.ts +3 -1
  682. package/src/messaging/providers/__tests__/transport-dispatch.test.ts +3 -1
  683. package/src/messaging/providers/a2a/__tests__/deliver.test.ts +3 -1
  684. package/src/messaging/providers/a2a/deliver.ts +3 -1
  685. package/src/messaging/providers/callback-routing.ts +3 -1
  686. package/src/messaging/providers/gmail/adapter.ts +36 -12
  687. package/src/messaging/providers/gmail/client.ts +71 -24
  688. package/src/messaging/providers/gmail/mime-builder.ts +6 -2
  689. package/src/messaging/providers/gmail/people-client.ts +3 -1
  690. package/src/messaging/providers/outlook/client.ts +30 -10
  691. package/src/messaging/providers/slack/__tests__/adapter-token-routing.test.ts +15 -6
  692. package/src/messaging/providers/slack/adapter.ts +51 -17
  693. package/src/messaging/providers/slack/api.ts +39 -13
  694. package/src/messaging/providers/slack/client.ts +9 -3
  695. package/src/messaging/providers/slack/deep-link.ts +15 -5
  696. package/src/messaging/providers/slack/message-metadata.ts +21 -7
  697. package/src/messaging/providers/slack/render-transcript.ts +54 -18
  698. package/src/messaging/providers/slack/render.ts +50 -17
  699. package/src/messaging/providers/slack/transport.ts +9 -3
  700. package/src/messaging/providers/telegram-bot/adapter.ts +6 -2
  701. package/src/messaging/providers/telegram-bot/api.ts +3 -1
  702. package/src/messaging/providers/telegram-bot/render.ts +33 -11
  703. package/src/messaging/providers/telegram-bot/send.ts +3 -1
  704. package/src/messaging/providers/whatsapp/adapter.ts +3 -1
  705. package/src/messaging/providers/whatsapp/api.ts +9 -3
  706. package/src/messaging/registry.ts +3 -1
  707. package/src/messaging/style-analyzer.ts +3 -1
  708. package/src/monitoring/__tests__/db-integrity-sample.test.ts +96 -0
  709. package/src/monitoring/__tests__/sample-ring-buffer.test.ts +12 -4
  710. package/src/monitoring/db-integrity-check.ts +163 -0
  711. package/src/monitoring/db-integrity-sample.ts +171 -0
  712. package/src/monitoring/process-memory.ts +2 -1
  713. package/src/monitoring/sample-ring-buffer.ts +15 -5
  714. package/src/monitoring/worker.ts +12 -0
  715. package/src/notifications/adapters/platform.ts +6 -7
  716. package/src/notifications/adapters/shared.ts +9 -3
  717. package/src/notifications/conversation-candidates.ts +21 -7
  718. package/src/notifications/conversation-seed-composer.ts +21 -7
  719. package/src/notifications/copy-composer.ts +12 -4
  720. package/src/notifications/decisions-store.ts +6 -2
  721. package/src/notifications/deferred-emit.ts +18 -6
  722. package/src/notifications/deliveries-store.ts +3 -1
  723. package/src/notifications/destination-resolver.ts +12 -6
  724. package/src/notifications/deterministic-checks.ts +6 -2
  725. package/src/notifications/edit-notification.ts +3 -1
  726. package/src/notifications/events-store.ts +3 -1
  727. package/src/notifications/guardian-question-mode.ts +15 -5
  728. package/src/notifications/home-feed-side-effect.ts +12 -4
  729. package/src/notifications/notification-utils.ts +8 -3
  730. package/src/notifications/preference-extractor.ts +5 -2
  731. package/src/notifications/preference-summary.ts +3 -1
  732. package/src/oauth/__tests__/oauth-connect-state.test.ts +4 -1
  733. package/src/oauth/byo-connection.test.ts +15 -5
  734. package/src/oauth/byo-connection.ts +6 -2
  735. package/src/oauth/connect-orchestrator.ts +3 -1
  736. package/src/oauth/connection-resolver.test.ts +6 -2
  737. package/src/oauth/connection-resolver.ts +12 -4
  738. package/src/oauth/identity-verifier.ts +30 -10
  739. package/src/oauth/manual-token-connection.ts +12 -4
  740. package/src/oauth/oauth-connect-state.ts +15 -3
  741. package/src/oauth/oauth-store.ts +132 -52
  742. package/src/oauth/provider-serializer.ts +9 -3
  743. package/src/oauth/provider-visibility.ts +3 -1
  744. package/src/oauth/scope-utils.ts +3 -1
  745. package/src/onboarding/checkin-event.ts +33 -11
  746. package/src/outbound-proxy/certs.ts +6 -2
  747. package/src/outbound-proxy/connect-tunnel.ts +15 -5
  748. package/src/outbound-proxy/host-pattern-match.ts +3 -1
  749. package/src/outbound-proxy/http-forwarder.ts +9 -3
  750. package/src/outbound-proxy/logging.ts +6 -2
  751. package/src/outbound-proxy/mitm-handler.ts +9 -3
  752. package/src/outbound-proxy/policy.ts +12 -4
  753. package/src/outbound-proxy/router.ts +3 -1
  754. package/src/outbound-proxy/server.ts +15 -5
  755. package/src/permissions/approval-provenance.test.ts +13 -4
  756. package/src/permissions/question-prompter.test.ts +12 -4
  757. package/src/permissions/question-prompter.ts +6 -2
  758. package/src/persistence/__tests__/raw-query-telemetry.test.ts +3 -1
  759. package/src/persistence/a2a-invite-store.ts +1 -4
  760. package/src/persistence/attachments-store.ts +60 -20
  761. package/src/persistence/bookmark-crud.ts +6 -2
  762. package/src/persistence/compaction-ledger-store.ts +6 -2
  763. package/src/persistence/compaction-log-store-clickhouse.ts +29 -10
  764. package/src/persistence/conversation-attention-store.ts +3 -1
  765. package/src/persistence/conversation-crud.ts +241 -93
  766. package/src/persistence/conversation-directories.ts +9 -3
  767. package/src/persistence/conversation-group-migration.ts +17 -1
  768. package/src/persistence/conversation-key-store.ts +3 -1
  769. package/src/persistence/conversation-queries.ts +146 -47
  770. package/src/persistence/conversation-search-lexical.ts +3 -1
  771. package/src/persistence/db-async-query.ts +9 -3
  772. package/src/persistence/delivery-channels.ts +3 -1
  773. package/src/persistence/embeddings/__tests__/embedding-identity.test.ts +9 -3
  774. package/src/persistence/embeddings/__tests__/plugin-facade-index.test.ts +73 -0
  775. package/src/persistence/embeddings/__tests__/plugin-index.test.ts +323 -0
  776. package/src/persistence/embeddings/embed.ts +21 -7
  777. package/src/persistence/embeddings/embedding-backend.test.ts +12 -4
  778. package/src/persistence/embeddings/embedding-backend.ts +72 -24
  779. package/src/persistence/embeddings/embedding-billing-breaker.ts +21 -7
  780. package/src/persistence/embeddings/embedding-cache.ts +6 -2
  781. package/src/persistence/embeddings/embedding-gemini.ts +6 -2
  782. package/src/persistence/embeddings/embedding-identity.ts +12 -4
  783. package/src/persistence/embeddings/embedding-local.ts +54 -19
  784. package/src/persistence/embeddings/embedding-ollama.ts +6 -2
  785. package/src/persistence/embeddings/embedding-openai.ts +3 -1
  786. package/src/persistence/embeddings/embedding-runtime-manager.ts +25 -9
  787. package/src/persistence/embeddings/embedding-types.ts +3 -1
  788. package/src/persistence/embeddings/messages-lexical-index.ts +12 -4
  789. package/src/persistence/embeddings/plugin-facade.ts +102 -3
  790. package/src/persistence/embeddings/plugin-index.ts +341 -0
  791. package/src/persistence/embeddings/qdrant-circuit-breaker.ts +6 -2
  792. package/src/persistence/embeddings/qdrant-client.test.ts +10 -4
  793. package/src/persistence/embeddings/qdrant-client.ts +173 -9
  794. package/src/persistence/embeddings/qdrant-manager.ts +21 -7
  795. package/src/persistence/external-conversation-store.ts +6 -2
  796. package/src/persistence/group-crud.test.ts +59 -0
  797. package/src/persistence/group-crud.ts +36 -11
  798. package/src/persistence/job-handlers/cleanup.ts +30 -12
  799. package/src/persistence/job-utils.ts +46 -26
  800. package/src/persistence/llm-request-log-sink-clickhouse.ts +12 -4
  801. package/src/persistence/llm-request-log-source-clickhouse.ts +18 -6
  802. package/src/persistence/llm-request-log-store.ts +26 -9
  803. package/src/persistence/migrations/001-job-deferrals.ts +3 -1
  804. package/src/persistence/migrations/002-tool-invocations-fk.ts +6 -2
  805. package/src/persistence/migrations/003-memory-fts-backfill.ts +3 -1
  806. package/src/persistence/migrations/004-entity-relation-dedup.ts +3 -1
  807. package/src/persistence/migrations/005-fingerprint-scope-unique.ts +3 -1
  808. package/src/persistence/migrations/006-scope-salted-fingerprints.ts +6 -2
  809. package/src/persistence/migrations/007-assistant-id-to-self.ts +3 -1
  810. package/src/persistence/migrations/008-remove-assistant-id-columns.ts +6 -2
  811. package/src/persistence/migrations/009-llm-usage-events-drop-assistant-id.ts +6 -2
  812. package/src/persistence/migrations/011-call-sessions-provider-sid-dedup.ts +9 -3
  813. package/src/persistence/migrations/014-backfill-inbox-thread-state.ts +3 -1
  814. package/src/persistence/migrations/015-drop-active-search-index.ts +3 -1
  815. package/src/persistence/migrations/019-notification-tables-schema-migration.ts +3 -1
  816. package/src/persistence/migrations/020-rename-macos-ios-channel-to-vellum.ts +3 -1
  817. package/src/persistence/migrations/024-embedding-vector-blob.ts +6 -2
  818. package/src/persistence/migrations/025-messages-fts-backfill.ts +3 -1
  819. package/src/persistence/migrations/026a-embeddings-nullable-vector-json.ts +9 -3
  820. package/src/persistence/migrations/036-normalize-phone-identities.ts +36 -12
  821. package/src/persistence/migrations/120-fk-cascade-rebuilds.ts +12 -4
  822. package/src/persistence/migrations/126-backfill-guardian-principal-id.ts +6 -2
  823. package/src/persistence/migrations/127-guardian-principal-id-not-null.ts +15 -5
  824. package/src/persistence/migrations/134-contacts-notes-column.ts +10 -4
  825. package/src/persistence/migrations/135-backfill-contact-interaction-stats.ts +6 -2
  826. package/src/persistence/migrations/136-drop-assistant-id-columns.ts +12 -4
  827. package/src/persistence/migrations/140-backfill-usage-cache-accounting.ts +24 -8
  828. package/src/persistence/migrations/141-rename-verification-table.ts +12 -4
  829. package/src/persistence/migrations/142-rename-verification-session-id-column.ts +6 -2
  830. package/src/persistence/migrations/147-migrate-reminders-to-schedules.ts +6 -2
  831. package/src/persistence/migrations/150-oauth-apps-client-secret-path.ts +12 -4
  832. package/src/persistence/migrations/157-invite-contact-id.ts +3 -1
  833. package/src/persistence/migrations/162-guardian-timestamps-epoch-ms.ts +21 -8
  834. package/src/persistence/migrations/174-rename-thread-starters-table.ts +12 -4
  835. package/src/persistence/migrations/180-backfill-inline-attachments-to-disk.ts +3 -1
  836. package/src/persistence/migrations/196-strip-integration-prefix-from-provider-keys.ts +6 -2
  837. package/src/persistence/migrations/206-scrub-corrupted-image-attachments.ts +3 -1
  838. package/src/persistence/migrations/209-strip-thinking-from-consolidated.ts +3 -1
  839. package/src/persistence/migrations/220-normalize-user-file-by-principal.ts +24 -8
  840. package/src/persistence/migrations/222-strip-placeholder-sentinels-from-messages.ts +3 -1
  841. package/src/persistence/migrations/231-repair-memory-graph-event-dates.ts +18 -6
  842. package/src/persistence/migrations/241-activation-state-fk-cascade.ts +6 -2
  843. package/src/persistence/migrations/246-backfill-provider-connection-label.ts +3 -1
  844. package/src/persistence/migrations/247-external-conversation-binding-thread-id.ts +3 -1
  845. package/src/persistence/migrations/249-normalize-slack-external-content.ts +30 -10
  846. package/src/persistence/migrations/256-memory-v2-injection-events.ts +24 -8
  847. package/src/persistence/migrations/296-rewrite-balanced-economy-profile-pins.test.ts +3 -1
  848. package/src/persistence/migrations/296-rewrite-balanced-economy-profile-pins.ts +6 -2
  849. package/src/persistence/migrations/297-move-llm-request-logs-to-logs-db.ts +3 -1
  850. package/src/persistence/migrations/302-create-compaction-events.ts +3 -1
  851. package/src/persistence/migrations/306-rewrite-frontier-profile-pins.test.ts +3 -1
  852. package/src/persistence/migrations/306-rewrite-frontier-profile-pins.ts +6 -2
  853. package/src/persistence/migrations/311-create-subagents-table.ts +5 -3
  854. package/src/persistence/migrations/318-drop-contact-channel-telemetry.ts +3 -1
  855. package/src/persistence/migrations/319-remove-legacy-managed-connections.ts +3 -1
  856. package/src/persistence/migrations/329-move-onboarding-events-to-telemetry-db.ts +3 -1
  857. package/src/persistence/migrations/340-sweep-orphaned-graph-node-vectors.test.ts +9 -0
  858. package/src/persistence/migrations/342-add-conversation-parent-id.test.ts +1 -3
  859. package/src/persistence/migrations/352-drop-schedule-skill-script-handoff.ts +3 -1
  860. package/src/persistence/migrations/355-add-schedule-group-id.ts +22 -0
  861. package/src/persistence/migrations/356-add-subagent-parent-tool-use-id.test.ts +87 -0
  862. package/src/persistence/migrations/356-add-subagent-parent-tool-use-id.ts +31 -0
  863. package/src/persistence/migrations/357-move-memory-segments-to-memory-db.ts +95 -0
  864. package/src/persistence/migrations/358-move-memory-embeddings-to-memory-db.ts +83 -0
  865. package/src/persistence/migrations/359-move-memory-summaries-to-memory-db.ts +86 -0
  866. package/src/persistence/migrations/__tests__/350-conversations-total-input-tokens-nullable.test.ts +3 -1
  867. package/src/persistence/migrations/run-migrations.ts +12 -4
  868. package/src/persistence/migrations/validate-migration-state.ts +12 -4
  869. package/src/persistence/raw-query.ts +9 -3
  870. package/src/persistence/schema/conversation-groups.ts +2 -0
  871. package/src/persistence/schema/infrastructure.ts +1 -0
  872. package/src/persistence/slow-query-log.ts +27 -9
  873. package/src/persistence/slow-sync-log.ts +3 -1
  874. package/src/persistence/steps.ts +60 -0
  875. package/src/persistence/subagent-store.ts +187 -8
  876. package/src/persistence/usage-buckets.ts +9 -3
  877. package/src/persistence/usage-grouped-buckets.ts +6 -2
  878. package/src/platform/feature-gate.ts +3 -1
  879. package/src/platform/sync-identity.ts +9 -3
  880. package/src/playbooks/playbook-compiler.ts +3 -1
  881. package/src/plugin-api/index.ts +34 -1
  882. package/src/plugin-api/model-profiles.test.ts +30 -0
  883. package/src/plugin-api/model-profiles.ts +11 -4
  884. package/src/plugin-api/vision-support.test.ts +65 -2
  885. package/src/plugin-api/vision-support.ts +15 -3
  886. package/src/plugins/defaults/channel/injectors.ts +12 -4
  887. package/src/plugins/defaults/compaction/window-manager.ts +30 -10
  888. package/src/plugins/defaults/documents/injectors.ts +18 -6
  889. package/src/plugins/defaults/empty-response/hooks/post-model-call.ts +9 -3
  890. package/src/plugins/defaults/exploration-drift/hooks/post-tool-use.ts +26 -8
  891. package/src/plugins/defaults/image-fallback/hooks/post-compact.ts +3 -1
  892. package/src/plugins/defaults/image-fallback/hooks/post-tool-use.ts +6 -2
  893. package/src/plugins/defaults/image-fallback/hooks/user-prompt-submit.ts +3 -1
  894. package/src/plugins/defaults/image-fallback/src/caption-blocks.ts +6 -2
  895. package/src/plugins/defaults/image-fallback/src/image-persist.ts +3 -1
  896. package/src/plugins/defaults/image-fallback/src/vision-caption.ts +6 -2
  897. package/src/plugins/defaults/index.ts +0 -28
  898. package/src/plugins/defaults/injection-presence.ts +3 -1
  899. package/src/plugins/defaults/main.ts +31 -0
  900. package/src/plugins/defaults/max-tokens-continue/hooks/post-model-call.ts +62 -6
  901. package/src/plugins/defaults/memory/AGENTS.md +10 -7
  902. package/src/plugins/defaults/memory/__tests__/capability-seed-embed-gate.test.ts +4 -4
  903. package/src/plugins/defaults/memory/__tests__/compaction-log-store-clickhouse.test.ts +6 -2
  904. package/src/plugins/defaults/memory/__tests__/conversation-memory-purge.test.ts +1 -0
  905. package/src/plugins/defaults/memory/__tests__/conversation-queries.test.ts +224 -0
  906. package/src/plugins/defaults/memory/__tests__/conversation-row-batch-delete.test.ts +18 -34
  907. package/src/plugins/defaults/memory/__tests__/db-async-query.test.ts +3 -1
  908. package/src/plugins/defaults/memory/__tests__/db-memory-attach.test.ts +3 -0
  909. package/src/plugins/defaults/memory/__tests__/embedding-cache.test.ts +10 -7
  910. package/src/plugins/defaults/memory/__tests__/indexer-tier-dispatch.test.ts +62 -2
  911. package/src/plugins/defaults/memory/__tests__/relocated-memory-test-rows.ts +16 -0
  912. package/src/plugins/defaults/memory/__tests__/table-relocation.test.ts +183 -0
  913. package/src/plugins/defaults/memory/__tests__/worker-control.test.ts +6 -2
  914. package/src/plugins/defaults/memory/anisotropy.test.ts +18 -6
  915. package/src/plugins/defaults/memory/anisotropy.ts +45 -15
  916. package/src/plugins/defaults/memory/context-search/agent-protocol.ts +3 -1
  917. package/src/plugins/defaults/memory/context-search/agent-runner.ts +6 -2
  918. package/src/plugins/defaults/memory/context-search/limits.ts +6 -2
  919. package/src/plugins/defaults/memory/context-search/search.ts +30 -10
  920. package/src/plugins/defaults/memory/context-search/sources/memory.ts +9 -3
  921. package/src/plugins/defaults/memory/context-search/sources/workspace.ts +33 -11
  922. package/src/plugins/defaults/memory/conversation-memory-purge.ts +5 -0
  923. package/src/plugins/defaults/memory/find-most-recent-retrospective-for.ts +3 -1
  924. package/src/plugins/defaults/memory/frontmatter.ts +3 -1
  925. package/src/plugins/defaults/memory/graph/__tests__/conversation-graph-memory-recent-summaries.test.ts +142 -0
  926. package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +117 -45
  927. package/src/plugins/defaults/memory/graph/graph-memory-state-store.ts +9 -3
  928. package/src/plugins/defaults/memory/graph/graph-search.ts +3 -1
  929. package/src/plugins/defaults/memory/graph/store.ts +113 -45
  930. package/src/plugins/defaults/memory/graph/types.ts +20 -7
  931. package/src/plugins/defaults/memory/graph-topology/__tests__/build-memory-graph.test.ts +1 -0
  932. package/src/plugins/defaults/memory/indexer.ts +40 -3
  933. package/src/plugins/defaults/memory/jobs/__tests__/embed-concept-page.test.ts +2 -2
  934. package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +20 -21
  935. package/src/plugins/defaults/memory/memory-db.ts +3 -1
  936. package/src/plugins/defaults/memory/memory-retrospective-accounting.ts +18 -6
  937. package/src/plugins/defaults/memory/memory-retrospective-state.ts +30 -10
  938. package/src/plugins/defaults/memory/memory-retrospective-trigger-check.ts +18 -6
  939. package/src/plugins/defaults/memory/prompt-override.ts +6 -2
  940. package/src/plugins/defaults/memory/segmenter.ts +6 -2
  941. package/src/plugins/defaults/memory/src/__tests__/memory-ingest-routes.test.ts +176 -0
  942. package/src/plugins/defaults/memory/src/__tests__/memory-worker-routes.test.ts +3 -1
  943. package/src/plugins/defaults/memory/src/memory-ingest-routes.ts +125 -0
  944. package/src/plugins/defaults/memory/src/memory-v2-routes.ts +5 -2
  945. package/src/plugins/defaults/memory/substrate/__tests__/consolidation-lock.test.ts +136 -0
  946. package/src/plugins/defaults/memory/substrate/__tests__/ingest.test.ts +440 -0
  947. package/src/plugins/defaults/memory/substrate/__tests__/page-index.test.ts +129 -2
  948. package/src/plugins/defaults/memory/substrate/__tests__/page-store.test.ts +31 -0
  949. package/src/plugins/defaults/memory/substrate/consolidation-job.ts +10 -218
  950. package/src/plugins/defaults/memory/substrate/consolidation-lock.ts +250 -0
  951. package/src/plugins/defaults/memory/substrate/ingest.ts +360 -0
  952. package/src/plugins/defaults/memory/substrate/page-index.ts +110 -1
  953. package/src/plugins/defaults/memory/substrate/page-store.ts +20 -24
  954. package/src/plugins/defaults/memory/substrate/types.ts +12 -0
  955. package/src/plugins/defaults/memory/task-memory-cleanup.ts +18 -6
  956. package/src/plugins/defaults/memory/v1/graph/bootstrap.ts +27 -10
  957. package/src/plugins/defaults/memory/v1/graph/consolidation.ts +57 -21
  958. package/src/plugins/defaults/memory/v1/graph/decay.ts +6 -2
  959. package/src/plugins/defaults/memory/v1/graph/extraction-job.ts +3 -1
  960. package/src/plugins/defaults/memory/v1/graph/injection.ts +24 -8
  961. package/src/plugins/defaults/memory/v1/graph/narrative.ts +3 -1
  962. package/src/plugins/defaults/memory/v1/graph/pattern-scan.ts +3 -1
  963. package/src/plugins/defaults/memory/v1/graph/scoring.ts +18 -6
  964. package/src/plugins/defaults/memory/v1/graph/serendipity.ts +9 -3
  965. package/src/plugins/defaults/memory/v1/graph/triggers.ts +30 -10
  966. package/src/plugins/defaults/memory/v1/job-handlers/embedding.ts +10 -3
  967. package/src/plugins/defaults/memory/v1/job-handlers/index-maintenance.ts +12 -12
  968. package/src/plugins/defaults/memory/v1/jobs/embed-pkb-file.ts +9 -3
  969. package/src/plugins/defaults/memory/v1/pkb/autoinject.ts +3 -1
  970. package/src/plugins/defaults/memory/v1/pkb/context.ts +12 -4
  971. package/src/plugins/defaults/memory/v1/pkb/pkb-reconcile.test.ts +3 -1
  972. package/src/plugins/defaults/memory/v1/pkb/pkb-reconcile.ts +3 -1
  973. package/src/plugins/defaults/memory/v1/pkb/pkb-search.test.ts +6 -2
  974. package/src/plugins/defaults/memory/v1/pkb/pkb-search.ts +15 -5
  975. package/src/plugins/defaults/memory/v1/pkb-schedule.ts +3 -1
  976. package/src/plugins/defaults/memory/v1/semantic-search.ts +30 -15
  977. package/src/plugins/defaults/memory/v2/harness/metrics.ts +9 -3
  978. package/src/plugins/defaults/memory/v2/harness/runner.ts +9 -3
  979. package/src/plugins/defaults/memory/v2/injection-events.ts +21 -7
  980. package/src/plugins/defaults/memory/v3/__tests__/card.test.ts +2 -2
  981. package/src/plugins/defaults/memory/v3/__tests__/carry-integration.test.ts +1 -0
  982. package/src/plugins/defaults/memory/v3/__tests__/dense.test.ts +9 -3
  983. package/src/plugins/defaults/memory/v3/__tests__/edge.test.ts +9 -1
  984. package/src/plugins/defaults/memory/v3/__tests__/fresh-set.test.ts +39 -5
  985. package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +6 -2
  986. package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +1 -0
  987. package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +2 -0
  988. package/src/plugins/defaults/memory/v3/__tests__/section-dense-store.test.ts +13 -3
  989. package/src/plugins/defaults/memory/v3/__tests__/shadow-integration.test.ts +1 -0
  990. package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +4 -0
  991. package/src/plugins/defaults/memory/v3/card.ts +1 -1
  992. package/src/plugins/defaults/memory/v3/core-set.ts +6 -2
  993. package/src/plugins/defaults/memory/v3/dense.ts +15 -5
  994. package/src/plugins/defaults/memory/v3/entity-lane.ts +9 -3
  995. package/src/plugins/defaults/memory/v3/ever-injected-store.ts +39 -13
  996. package/src/plugins/defaults/memory/v3/fresh-set.ts +27 -15
  997. package/src/plugins/defaults/memory/v3/hot-set.ts +6 -2
  998. package/src/plugins/defaults/memory/v3/injector.ts +51 -17
  999. package/src/plugins/defaults/memory/v3/learned-edges.ts +21 -7
  1000. package/src/plugins/defaults/memory/v3/llm-retry.ts +3 -1
  1001. package/src/plugins/defaults/memory/v3/orchestrate.ts +15 -5
  1002. package/src/plugins/defaults/memory/v3/pool-select.test.ts +3 -1
  1003. package/src/plugins/defaults/memory/v3/pool-select.ts +15 -5
  1004. package/src/plugins/defaults/memory/v3/render-injection.ts +6 -2
  1005. package/src/plugins/defaults/memory/v3/section-dense-store.ts +51 -25
  1006. package/src/plugins/defaults/memory/v3/section-needle.ts +27 -9
  1007. package/src/plugins/defaults/memory/v3/sections.ts +6 -2
  1008. package/src/plugins/defaults/memory/v3/shadow-plugin.ts +24 -17
  1009. package/src/plugins/defaults/memory/v3-eval/__tests__/eval-tally.test.ts +9 -3
  1010. package/src/plugins/defaults/memory/v3-eval/eval-packets.ts +6 -0
  1011. package/src/plugins/defaults/memory/v3-eval/eval-tally.ts +22 -9
  1012. package/src/plugins/defaults/session/injectors.ts +15 -5
  1013. package/src/plugins/defaults/surface-completion-nudge/hooks/post-model-call.ts +49 -17
  1014. package/src/plugins/defaults/task-progress-nudge/hooks/post-tool-use.ts +33 -11
  1015. package/src/plugins/defaults/title-generate/hooks/stop.ts +15 -5
  1016. package/src/plugins/defaults/title-generate/hooks/user-prompt-submit.ts +6 -2
  1017. package/src/plugins/defaults/tool-error/hooks/post-tool-use.ts +21 -7
  1018. package/src/plugins/defaults/tool-result-truncate/terminal.ts +3 -1
  1019. package/src/plugins/defaults/turn-context/injectors.ts +3 -1
  1020. package/src/plugins/defaults/workspace/injectors.ts +52 -18
  1021. package/src/plugins/external-plugin-loader.ts +21 -7
  1022. package/src/plugins/injector-registry.ts +6 -2
  1023. package/src/prompts/__tests__/system-prompt.test.ts +5 -2
  1024. package/src/prompts/bootstrap-cleanup.ts +3 -1
  1025. package/src/prompts/normalize-onboarding.ts +9 -3
  1026. package/src/prompts/persona-resolver.ts +33 -11
  1027. package/src/prompts/sections.ts +42 -14
  1028. package/src/prompts/system-prompt.ts +30 -10
  1029. package/src/prompts/template-detection.ts +6 -2
  1030. package/src/prompts/templates/system-sections.ts +55 -20
  1031. package/src/prompts/user-reference.ts +6 -2
  1032. package/src/providers/__tests__/connection-model-compat.test.ts +6 -1
  1033. package/src/providers/__tests__/inference.test.ts +24 -8
  1034. package/src/providers/__tests__/request-diagnostics.test.ts +131 -0
  1035. package/src/providers/__tests__/retry-callsite.test.ts +30 -0
  1036. package/src/providers/__tests__/search-provider-catalog.test.ts +4 -1
  1037. package/src/providers/anthropic/client.ts +119 -41
  1038. package/src/providers/call-site-routing.ts +7 -0
  1039. package/src/providers/connection-model-compat.ts +12 -4
  1040. package/src/providers/fetch-provider-catalog.ts +3 -2
  1041. package/src/providers/gemini/client.ts +86 -12
  1042. package/src/providers/inference/codex-token-refresh.ts +6 -2
  1043. package/src/providers/inference/connections.ts +34 -12
  1044. package/src/providers/media-resolve.ts +21 -7
  1045. package/src/providers/model-catalog.ts +104 -63
  1046. package/src/providers/model-intents.ts +2 -2
  1047. package/src/providers/ollama/client.ts +3 -1
  1048. package/src/providers/openai/__tests__/chat-completions-input-audio.test.ts +3 -1
  1049. package/src/providers/openai/__tests__/chat-completions-provider-endpoint.test.ts +3 -1
  1050. package/src/providers/openai/__tests__/chat-completions-provider-reasoning.test.ts +3 -1
  1051. package/src/providers/openai/api-error-normalization.ts +75 -25
  1052. package/src/providers/openai/chat-completions-provider.ts +49 -16
  1053. package/src/providers/openai/codex-models.ts +9 -5
  1054. package/src/providers/openai/coerce-object-args.ts +12 -4
  1055. package/src/providers/openai/responses-provider.ts +31 -11
  1056. package/src/providers/openrouter/client.ts +9 -3
  1057. package/src/providers/platform-proxy/context.ts +9 -3
  1058. package/src/providers/provider-catalog-visibility.ts +4 -4
  1059. package/src/providers/provider-send-message.ts +6 -0
  1060. package/src/providers/ratelimit.ts +6 -2
  1061. package/src/providers/request-diagnostics.ts +225 -0
  1062. package/src/providers/retry.ts +68 -17
  1063. package/src/providers/search-provider-catalog.ts +18 -0
  1064. package/src/providers/speech-to-text/__tests__/deepgram.test.ts +27 -0
  1065. package/src/providers/speech-to-text/__tests__/provider-catalog.test.ts +25 -0
  1066. package/src/providers/speech-to-text/__tests__/resolve.test.ts +195 -1
  1067. package/src/providers/speech-to-text/deepgram-realtime.test.ts +18 -6
  1068. package/src/providers/speech-to-text/deepgram-realtime.ts +9 -1
  1069. package/src/providers/speech-to-text/deepgram.ts +117 -1
  1070. package/src/providers/speech-to-text/google-gemini-live-stream.test.ts +116 -132
  1071. package/src/providers/speech-to-text/google-gemini-live-stream.ts +87 -31
  1072. package/src/providers/speech-to-text/provider-catalog.ts +17 -0
  1073. package/src/providers/speech-to-text/resolve.ts +64 -5
  1074. package/src/providers/speech-to-text/xai-realtime.test.ts +18 -6
  1075. package/src/providers/speech-to-text/xai-realtime.ts +60 -20
  1076. package/src/providers/speech-to-text/xai.test.ts +43 -0
  1077. package/src/providers/speech-to-text/xai.ts +48 -7
  1078. package/src/providers/stop-reasons.ts +3 -1
  1079. package/src/providers/thinking-config.ts +7 -1
  1080. package/src/providers/tool-progress-events.ts +15 -5
  1081. package/src/providers/usage-tracking.ts +6 -2
  1082. package/src/routes/route-host-client.ts +3 -2
  1083. package/src/routes/route-host-protocol.ts +1 -1
  1084. package/src/routes/worker.ts +3 -2
  1085. package/src/runtime/__tests__/agent-wake.test.ts +3 -1
  1086. package/src/runtime/__tests__/interactive-ui.test.ts +3 -1
  1087. package/src/runtime/__tests__/local-principal-trust.test.ts +10 -8
  1088. package/src/runtime/anchored-guardian.test.ts +45 -8
  1089. package/src/runtime/anchored-guardian.ts +4 -1
  1090. package/src/runtime/approval-conversation-turn.ts +17 -7
  1091. package/src/runtime/approval-message-composer.ts +6 -2
  1092. package/src/runtime/auth/__tests__/guard-tests.test.ts +24 -8
  1093. package/src/runtime/auth/middleware.ts +0 -2
  1094. package/src/runtime/auth/owner-caller.ts +95 -0
  1095. package/src/runtime/auth/require-bound-guardian.ts +7 -22
  1096. package/src/runtime/auth/same-actor.ts +12 -4
  1097. package/src/runtime/background-job-runner.ts +12 -4
  1098. package/src/runtime/channel-invite-transports/slack.ts +6 -2
  1099. package/src/runtime/channel-invite-transports/telegram.ts +6 -2
  1100. package/src/runtime/channel-verification-service.ts +9 -3
  1101. package/src/runtime/decision-token.ts +3 -1
  1102. package/src/runtime/guardian-action-message-composer.ts +6 -2
  1103. package/src/runtime/guardian-vellum-migration.ts +18 -6
  1104. package/src/runtime/http-router.ts +18 -6
  1105. package/src/runtime/invite-service.ts +6 -2
  1106. package/src/runtime/local-principal-trust.ts +6 -2
  1107. package/src/runtime/member-verdict-cache.ts +18 -6
  1108. package/src/runtime/middleware/__tests__/request-logger.test.ts +1 -3
  1109. package/src/runtime/middleware/auth.ts +37 -13
  1110. package/src/runtime/middleware/error-handler.ts +1 -4
  1111. package/src/runtime/middleware/rate-limiter.ts +12 -4
  1112. package/src/runtime/middleware/request-logger.ts +12 -4
  1113. package/src/runtime/migrations/__tests__/rebind-secrets-credentials.test.ts +18 -6
  1114. package/src/runtime/migrations/__tests__/vbundle-builder-credentials.test.ts +3 -1
  1115. package/src/runtime/migrations/__tests__/vbundle-import-parity.test.ts +9 -3
  1116. package/src/runtime/migrations/__tests__/vbundle-import-version-compat.test.ts +11 -4
  1117. package/src/runtime/migrations/__tests__/vbundle-streaming-importer.test.ts +84 -28
  1118. package/src/runtime/migrations/__tests__/vbundle-symlink-importer.test.ts +18 -6
  1119. package/src/runtime/migrations/__tests__/vbundle-symlink-streaming-importer.test.ts +0 -0
  1120. package/src/runtime/migrations/__tests__/vbundle-symlink-tar.test.ts +24 -8
  1121. package/src/runtime/migrations/__tests__/vbundle-tar-stream.test.ts +3 -1
  1122. package/src/runtime/migrations/__tests__/vbundle-validator-v1-schema.test.ts +6 -2
  1123. package/src/runtime/migrations/gcs-signed-url.ts +21 -7
  1124. package/src/runtime/migrations/job-registry.ts +24 -8
  1125. package/src/runtime/migrations/migration-wizard.ts +9 -3
  1126. package/src/runtime/migrations/transfer-progress-screen.ts +3 -1
  1127. package/src/runtime/migrations/validation-results-screen.ts +3 -1
  1128. package/src/runtime/migrations/vbundle-builder.ts +33 -11
  1129. package/src/runtime/migrations/vbundle-import-analyzer.ts +3 -1
  1130. package/src/runtime/migrations/vbundle-import-policy.ts +21 -7
  1131. package/src/runtime/migrations/vbundle-importer.ts +9 -3
  1132. package/src/runtime/migrations/vbundle-metadata-merge.ts +12 -4
  1133. package/src/runtime/migrations/vbundle-streaming-importer.ts +57 -19
  1134. package/src/runtime/migrations/vbundle-tar-stream.ts +15 -5
  1135. package/src/runtime/migrations/vbundle-validator.ts +6 -2
  1136. package/src/runtime/nl-approval-parser.ts +6 -3
  1137. package/src/runtime/no-response.ts +12 -4
  1138. package/src/runtime/pending-interactions.ts +9 -3
  1139. package/src/runtime/pre-first-message-gate.ts +3 -1
  1140. package/src/runtime/routes/__tests__/acp-routes.test.ts +24 -8
  1141. package/src/runtime/routes/__tests__/avatar-state-routes.test.ts +9 -3
  1142. package/src/runtime/routes/__tests__/backup-routes.test.ts +3 -1
  1143. package/src/runtime/routes/__tests__/channel-verification-revoke.test.ts +9 -3
  1144. package/src/runtime/routes/__tests__/client-routes.test.ts +3 -1
  1145. package/src/runtime/routes/__tests__/connection-routes-vs-cli-parity.test.ts +12 -4
  1146. package/src/runtime/routes/__tests__/consolidation-routes.test.ts +3 -1
  1147. package/src/runtime/routes/__tests__/contact-routes-update-channel-relay.test.ts +3 -1
  1148. package/src/runtime/routes/__tests__/contact-routes.test.ts +3 -1
  1149. package/src/runtime/routes/__tests__/content-source-routes.test.ts +3 -1
  1150. package/src/runtime/routes/__tests__/conversation-compaction-routes.test.ts +3 -1
  1151. package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +3 -1
  1152. package/src/runtime/routes/__tests__/conversation-management-routes.test.ts +3 -1
  1153. package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +116 -1
  1154. package/src/runtime/routes/__tests__/conversation-surface-routes.test.ts +3 -1
  1155. package/src/runtime/routes/__tests__/default-plugin-routes.test.ts +4 -14
  1156. package/src/runtime/routes/__tests__/deprecated-route-context.test.ts +112 -0
  1157. package/src/runtime/routes/__tests__/gateway-log-routes.test.ts +3 -1
  1158. package/src/runtime/routes/__tests__/gateway-status-routes.test.ts +3 -1
  1159. package/src/runtime/routes/__tests__/global-search-routes.test.ts +12 -0
  1160. package/src/runtime/routes/__tests__/heartbeat-routes.test.ts +3 -1
  1161. package/src/runtime/routes/__tests__/home-feed-routes.test.ts +6 -3
  1162. package/src/runtime/routes/__tests__/inference-send-routes.test.ts +79 -2
  1163. package/src/runtime/routes/__tests__/invite-relay-routes.test.ts +3 -1
  1164. package/src/runtime/routes/__tests__/ps-routes.test.ts +12 -4
  1165. package/src/runtime/routes/__tests__/question-routes.test.ts +6 -2
  1166. package/src/runtime/routes/__tests__/retrospective-routes.test.ts +3 -1
  1167. package/src/runtime/routes/__tests__/sanity-routes.test.ts +6 -2
  1168. package/src/runtime/routes/__tests__/schedule-routes-create.test.ts +3 -1
  1169. package/src/runtime/routes/__tests__/slack-channel-routes.test.ts +3 -1
  1170. package/src/runtime/routes/__tests__/stt-routes.test.ts +22 -3
  1171. package/src/runtime/routes/__tests__/surface-action-routes.test.ts +9 -3
  1172. package/src/runtime/routes/__tests__/surface-content-routes.test.ts +3 -1
  1173. package/src/runtime/routes/__tests__/tts-routes.test.ts +9 -3
  1174. package/src/runtime/routes/__tests__/user-route-dispatcher-host.test.ts +3 -12
  1175. package/src/runtime/routes/__tests__/user-route-dispatcher.test.ts +26 -115
  1176. package/src/runtime/routes/__tests__/wake-conversation-routes.test.ts +3 -1
  1177. package/src/runtime/routes/acp-routes-list.test.ts +9 -3
  1178. package/src/runtime/routes/acp-routes.test.ts +18 -6
  1179. package/src/runtime/routes/app-management-routes.ts +13 -5
  1180. package/src/runtime/routes/app-routes.ts +3 -1
  1181. package/src/runtime/routes/archive-utils.ts +3 -1
  1182. package/src/runtime/routes/attachment-routes.ts +6 -2
  1183. package/src/runtime/routes/background-wake-routes.ts +12 -4
  1184. package/src/runtime/routes/backup-routes.ts +6 -2
  1185. package/src/runtime/routes/browser-routes.ts +3 -1
  1186. package/src/runtime/routes/call-routes.ts +3 -1
  1187. package/src/runtime/routes/contact-prompt-routes.ts +8 -1
  1188. package/src/runtime/routes/contact-routes.ts +9 -3
  1189. package/src/runtime/routes/conversation-list-routes.ts +3 -1
  1190. package/src/runtime/routes/conversation-management-routes.ts +6 -2
  1191. package/src/runtime/routes/conversation-query-routes.ts +63 -7
  1192. package/src/runtime/routes/conversation-routes.ts +6 -2
  1193. package/src/runtime/routes/conversation-starter-routes.ts +12 -4
  1194. package/src/runtime/routes/conversations-import-routes.ts +28 -2
  1195. package/src/runtime/routes/debug-bash-routes.ts +3 -1
  1196. package/src/runtime/routes/default-provider-routes.ts +8 -4
  1197. package/src/runtime/routes/defer-routes.ts +17 -14
  1198. package/src/runtime/routes/deprecated-route-context.ts +125 -0
  1199. package/src/runtime/routes/diagnostics-routes.ts +3 -1
  1200. package/src/runtime/routes/disk-pressure-routes.ts +12 -4
  1201. package/src/runtime/routes/email-routes.ts +18 -6
  1202. package/src/runtime/routes/errors.ts +13 -0
  1203. package/src/runtime/routes/events-routes.ts +9 -3
  1204. package/src/runtime/routes/global-search-routes.ts +28 -8
  1205. package/src/runtime/routes/group-routes.ts +47 -5
  1206. package/src/runtime/routes/guardian-action-routes.ts +2 -1
  1207. package/src/runtime/routes/heartbeat-routes.ts +12 -6
  1208. package/src/runtime/routes/home-feed-routes.ts +51 -18
  1209. package/src/runtime/routes/host-app-control-routes.ts +40 -45
  1210. package/src/runtime/routes/host-bash-routes.ts +31 -22
  1211. package/src/runtime/routes/host-browser-routes.ts +6 -3
  1212. package/src/runtime/routes/host-cu-routes.ts +26 -36
  1213. package/src/runtime/routes/host-file-routes.ts +29 -40
  1214. package/src/runtime/routes/host-transfer-routes.ts +21 -9
  1215. package/src/runtime/routes/http-adapter.ts +15 -5
  1216. package/src/runtime/routes/identity-routes.ts +15 -5
  1217. package/src/runtime/routes/inbound-stages/admission-policy.test.ts +9 -3
  1218. package/src/runtime/routes/inbound-stages/channel-turn-admission.ts +2 -2
  1219. package/src/runtime/routes/inbound-stages/guardian-activation-intercept.ts +12 -4
  1220. package/src/runtime/routes/index.ts +2 -0
  1221. package/src/runtime/routes/inference-profile-session-handler.ts +6 -2
  1222. package/src/runtime/routes/inference-profile-session-reaper.ts +6 -2
  1223. package/src/runtime/routes/inference-profiles-routes.ts +10 -5
  1224. package/src/runtime/routes/inference-provider-connection-routes.ts +9 -3
  1225. package/src/runtime/routes/inference-send-routes.ts +88 -22
  1226. package/src/runtime/routes/integrations/twilio.ts +3 -1
  1227. package/src/runtime/routes/internal-oauth-routes.ts +6 -2
  1228. package/src/runtime/routes/llm-call-sites-routes.ts +5 -2
  1229. package/src/runtime/routes/llm-context-normalization.ts +36 -12
  1230. package/src/runtime/routes/log-export/__tests__/workspace-allowlist.test.ts +12 -4
  1231. package/src/runtime/routes/log-export/workspace-allowlist.ts +33 -11
  1232. package/src/runtime/routes/log-export-routes.ts +51 -17
  1233. package/src/runtime/routes/mcp-auth-routes.ts +23 -8
  1234. package/src/runtime/routes/migration-rollback-routes.ts +4 -2
  1235. package/src/runtime/routes/migration-routes.ts +24 -8
  1236. package/src/runtime/routes/oauth-apps.ts +3 -1
  1237. package/src/runtime/routes/oauth-commands-routes.ts +66 -22
  1238. package/src/runtime/routes/oauth-connect-routes.ts +14 -5
  1239. package/src/runtime/routes/oauth-providers.ts +89 -34
  1240. package/src/runtime/routes/onboarding-checkin-routes.ts +3 -1
  1241. package/src/runtime/routes/platform-routes.ts +162 -50
  1242. package/src/runtime/routes/playground/__tests__/force-compact.test.ts +6 -2
  1243. package/src/runtime/routes/playground/__tests__/inject-failures.test.ts +9 -3
  1244. package/src/runtime/routes/playground/__tests__/reset-circuit.test.ts +3 -1
  1245. package/src/runtime/routes/playground/__tests__/seed-conversation.test.ts +3 -1
  1246. package/src/runtime/routes/playground/__tests__/seeded-conversations.test.ts +3 -1
  1247. package/src/runtime/routes/playground/__tests__/state.test.ts +3 -1
  1248. package/src/runtime/routes/playground/helpers.ts +9 -3
  1249. package/src/runtime/routes/playground/seeded-conversations.ts +3 -1
  1250. package/src/runtime/routes/profiler-routes.ts +12 -4
  1251. package/src/runtime/routes/question-routes.ts +3 -1
  1252. package/src/runtime/routes/redact-staged-export.ts +15 -5
  1253. package/src/runtime/routes/schedule-routes.ts +135 -38
  1254. package/src/runtime/routes/sequence-routes.ts +23 -10
  1255. package/src/runtime/routes/skills-routes.ts +45 -15
  1256. package/src/runtime/routes/slack-channel-routes.ts +6 -2
  1257. package/src/runtime/routes/sounds-config-routes.ts +15 -5
  1258. package/src/runtime/routes/stt-routes.ts +12 -3
  1259. package/src/runtime/routes/subagents-routes.ts +182 -47
  1260. package/src/runtime/routes/tool-call-question-enrichment.ts +6 -2
  1261. package/src/runtime/routes/user-route-dispatcher.ts +23 -64
  1262. package/src/runtime/routes/user-routes-cli.ts +3 -1
  1263. package/src/runtime/routes/user-routes.ts +1 -10
  1264. package/src/runtime/routes/watcher-routes.ts +15 -5
  1265. package/src/runtime/routes/workflow-routes.test.ts +9 -3
  1266. package/src/runtime/routes/workflow-routes.ts +12 -4
  1267. package/src/runtime/routes/workspace-greetings.ts +12 -4
  1268. package/src/runtime/routes/workspace-routes.ts +12 -4
  1269. package/src/runtime/routes/workspace-utils.ts +6 -2
  1270. package/src/runtime/services/conversation-serializer.ts +9 -3
  1271. package/src/runtime/slack-reply-session.test.ts +3 -1
  1272. package/src/runtime/slack-reply-session.ts +42 -14
  1273. package/src/runtime/trust-verdict-consumer.ts +9 -3
  1274. package/src/runtime/verification-outbound-actions.ts +3 -1
  1275. package/src/runtime/verification-rate-limiter.ts +6 -2
  1276. package/src/schedule/__tests__/run-script.test.ts +62 -0
  1277. package/src/schedule/defer-provenance.ts +51 -0
  1278. package/src/schedule/integration-status.ts +6 -2
  1279. package/src/schedule/recurrence-engine.ts +35 -13
  1280. package/src/schedule/recurrence-types.ts +6 -2
  1281. package/src/schedule/run-script.ts +111 -21
  1282. package/src/schedule/schedule-recovery.ts +6 -2
  1283. package/src/schedule/schedule-store.ts +308 -57
  1284. package/src/schedule/scheduler.ts +9 -11
  1285. package/src/schedule/wake-schedule-options.ts +94 -0
  1286. package/src/security/AGENTS.md +14 -0
  1287. package/src/security/__tests__/oauth2-exchange-body.test.ts +1 -4
  1288. package/src/security/__tests__/provider-key-env-fallback.test.ts +6 -2
  1289. package/src/security/__tests__/untrusted-content.test.ts +21 -2
  1290. package/src/security/ces-credential-client.ts +15 -5
  1291. package/src/security/ces-rpc-credential-backend.ts +6 -2
  1292. package/src/security/credential-key.ts +6 -2
  1293. package/src/security/encrypted-store.ts +47 -18
  1294. package/src/security/oauth-callback-registry.ts +6 -2
  1295. package/src/security/oauth2-device-code.ts +7 -2
  1296. package/src/security/oauth2.ts +36 -7
  1297. package/src/security/redact-json.ts +3 -1
  1298. package/src/security/redaction.ts +3 -1
  1299. package/src/security/secret-allowlist.ts +21 -7
  1300. package/src/security/secret-ingress.ts +3 -1
  1301. package/src/security/secret-scanner.ts +23 -8
  1302. package/src/security/token-manager.ts +4 -2
  1303. package/src/security/tool-approval-digest.ts +3 -1
  1304. package/src/security/untrusted-content.ts +11 -3
  1305. package/src/sequence/analytics.ts +6 -2
  1306. package/src/sequence/guardrails.ts +6 -2
  1307. package/src/sequence/importer.ts +18 -6
  1308. package/src/sequence/reply-matcher.ts +18 -6
  1309. package/src/sequence/store.ts +40 -15
  1310. package/src/services/published-app-updater.ts +9 -3
  1311. package/src/signals/cancel.ts +3 -1
  1312. package/src/signals/conversation-undo.ts +3 -1
  1313. package/src/skills/active-skill-tools.ts +9 -3
  1314. package/src/skills/catalog-cache.ts +4 -1
  1315. package/src/skills/catalog-files.ts +93 -31
  1316. package/src/skills/catalog-install.ts +30 -10
  1317. package/src/skills/categories-cache.ts +9 -3
  1318. package/src/skills/clawhub-files.ts +21 -7
  1319. package/src/skills/clawhub.ts +18 -6
  1320. package/src/skills/frontmatter.ts +3 -1
  1321. package/src/skills/include-graph.ts +33 -11
  1322. package/src/skills/inline-command-expansions.ts +9 -3
  1323. package/src/skills/inline-command-runner.ts +6 -2
  1324. package/src/skills/install-meta.ts +17 -6
  1325. package/src/skills/managed-store.ts +3 -1
  1326. package/src/skills/remote-skill-policy.ts +6 -2
  1327. package/src/skills/skill-cache-store.ts +6 -2
  1328. package/src/skills/skillssh-files.ts +42 -14
  1329. package/src/skills/skillssh-registry.ts +18 -6
  1330. package/src/skills/validate-input.ts +60 -20
  1331. package/src/skills/version-hash.ts +6 -2
  1332. package/src/stt/__tests__/daemon-batch-transcriber.test.ts +136 -2
  1333. package/src/stt/daemon-batch-transcriber.ts +39 -22
  1334. package/src/subagent/consult-prompt.ts +3 -1
  1335. package/src/subagent/consult-transcript.ts +6 -2
  1336. package/src/subagent/index.ts +11 -2
  1337. package/src/subagent/manager.ts +162 -47
  1338. package/src/subagent/types.ts +67 -0
  1339. package/src/subagent/validate-allowlists.ts +6 -2
  1340. package/src/telemetry/tool-usage-store.ts +6 -2
  1341. package/src/telemetry/watchdog-direct-emit.ts +6 -2
  1342. package/src/telemetry/watchdog-events-store.ts +6 -3
  1343. package/src/tools/background-tool-registry.ts +6 -2
  1344. package/src/tools/browser/__tests__/auth-detector.test.ts +20 -0
  1345. package/src/tools/browser/__tests__/browser-untrusted-content.test.ts +512 -0
  1346. package/src/tools/browser/auth-cache.ts +6 -2
  1347. package/src/tools/browser/auth-detector.ts +24 -6
  1348. package/src/tools/browser/browser-execution.ts +245 -47
  1349. package/src/tools/browser/browser-manager.ts +66 -24
  1350. package/src/tools/browser/browser-screencast.ts +6 -2
  1351. package/src/tools/browser/cdp-client/__tests__/accessibility-snapshot.test.ts +27 -0
  1352. package/src/tools/browser/cdp-client/__tests__/browser-tabs-factory.test.ts +75 -27
  1353. package/src/tools/browser/cdp-client/__tests__/cdp-dom-helpers.test.ts +39 -14
  1354. package/src/tools/browser/cdp-client/__tests__/cdp-inspect-client.test.ts +9 -3
  1355. package/src/tools/browser/cdp-client/__tests__/types.test.ts +4 -1
  1356. package/src/tools/browser/cdp-client/accessibility-snapshot.ts +67 -19
  1357. package/src/tools/browser/cdp-client/cdp-dom-helpers.ts +15 -5
  1358. package/src/tools/browser/cdp-client/cdp-inspect/__tests__/ws-transport.test.ts +9 -3
  1359. package/src/tools/browser/cdp-client/cdp-inspect/discovery.ts +33 -11
  1360. package/src/tools/browser/cdp-client/cdp-inspect/ws-transport.ts +42 -14
  1361. package/src/tools/browser/cdp-client/cdp-inspect-client.ts +36 -11
  1362. package/src/tools/browser/cdp-client/extension-cdp-client.ts +9 -3
  1363. package/src/tools/browser/cdp-client/factory.ts +45 -27
  1364. package/src/tools/browser/cdp-client/local-cdp-client.ts +21 -6
  1365. package/src/tools/browser/cdp-client/types.ts +5 -1
  1366. package/src/tools/browser/network-recorder.ts +45 -15
  1367. package/src/tools/browser/pinned-tabs.ts +28 -9
  1368. package/src/tools/browser/runtime-check.ts +21 -7
  1369. package/src/tools/credentials/broker.ts +3 -1
  1370. package/src/tools/credentials/domain-policy.ts +12 -4
  1371. package/src/tools/credentials/host-pattern-match.ts +3 -1
  1372. package/src/tools/credentials/post-connect-hooks.ts +6 -2
  1373. package/src/tools/credentials/resolve.ts +21 -7
  1374. package/src/tools/credentials/selection.ts +15 -5
  1375. package/src/tools/credentials/tool-policy.ts +6 -2
  1376. package/src/tools/execution-target.ts +3 -1
  1377. package/src/tools/filesystem/fuzzy-match.ts +54 -18
  1378. package/src/tools/filesystem/search.ts +34 -12
  1379. package/src/tools/filesystem/write.ts +12 -4
  1380. package/src/tools/network/__tests__/web-search-metadata.test.ts +9 -3
  1381. package/src/tools/network/__tests__/web-search.test.ts +111 -4
  1382. package/src/tools/network/domain-normalize.ts +12 -4
  1383. package/src/tools/network/managed-search-proxy.ts +24 -8
  1384. package/src/tools/network/script-proxy/session-manager.ts +39 -13
  1385. package/src/tools/network/url-safety.ts +63 -21
  1386. package/src/tools/network/web-fetch.ts +62 -21
  1387. package/src/tools/network/web-search-error.ts +30 -13
  1388. package/src/tools/network/web-search.ts +237 -10
  1389. package/src/tools/schedule/create.ts +18 -0
  1390. package/src/tools/schedule/update.ts +19 -2
  1391. package/src/tools/sensitive-output-placeholders.ts +15 -5
  1392. package/src/tools/shared/filesystem/file-ops-service.ts +6 -2
  1393. package/src/tools/shared/filesystem/image-read.ts +3 -1
  1394. package/src/tools/shared/filesystem/size-guard.ts +6 -2
  1395. package/src/tools/skills/execute.ts +24 -8
  1396. package/src/tools/skills/find-similar-skills.ts +6 -2
  1397. package/src/tools/skills/load.ts +25 -9
  1398. package/src/tools/skills/sandbox-runner.ts +6 -2
  1399. package/src/tools/subagent/read.ts +7 -4
  1400. package/src/tools/subagent/resolve.ts +73 -3
  1401. package/src/tools/subagent/status.ts +66 -5
  1402. package/src/tools/tool-input-summary.ts +3 -1
  1403. package/src/tools/tool-name-aliases.ts +3 -1
  1404. package/src/tools/verification-control-plane-policy.ts +12 -4
  1405. package/src/tools/workflows/manage-workflows.ts +5 -2
  1406. package/src/tts/__tests__/provider-adapters.test.ts +9 -3
  1407. package/src/tts/__tests__/speakable-segments.test.ts +4 -4
  1408. package/src/tts/providers/__tests__/xai-tts-socket.test.ts +26 -12
  1409. package/src/tts/providers/deepgram-provider.ts +3 -1
  1410. package/src/tts/providers/elevenlabs-provider.ts +9 -3
  1411. package/src/tts/providers/fish-audio-provider.ts +3 -1
  1412. package/src/tts/providers/xai-provider.ts +3 -1
  1413. package/src/tts/providers/xai-tts-socket.ts +36 -11
  1414. package/src/tts/synthesize-text.ts +3 -1
  1415. package/src/usage/pricing.ts +27 -9
  1416. package/src/util/abort-reasons.ts +3 -1
  1417. package/src/util/bun-runtime.ts +9 -3
  1418. package/src/util/bundled-asset.ts +6 -2
  1419. package/src/util/canonicalize-identity.ts +3 -1
  1420. package/src/util/cgroup-memory.ts +12 -4
  1421. package/src/util/debounce.ts +11 -4
  1422. package/src/util/diff.ts +18 -6
  1423. package/src/util/disk-usage.ts +15 -5
  1424. package/src/util/errors.ts +1 -0
  1425. package/src/util/favicon.ts +9 -3
  1426. package/src/util/fs.ts +3 -1
  1427. package/src/util/image-conversion.ts +15 -5
  1428. package/src/util/log-redact.ts +6 -2
  1429. package/src/util/logger.ts +15 -5
  1430. package/src/util/phone.ts +6 -2
  1431. package/src/util/platform.ts +18 -6
  1432. package/src/util/pricing.ts +30 -10
  1433. package/src/util/process-liveness.ts +6 -2
  1434. package/src/util/promise-guard.ts +3 -1
  1435. package/src/util/retry.ts +21 -7
  1436. package/src/util/row-mapper.ts +6 -2
  1437. package/src/util/spinner.ts +6 -2
  1438. package/src/util/strip-comment-lines.ts +3 -1
  1439. package/src/util/time.ts +18 -6
  1440. package/src/util/truncate.ts +6 -2
  1441. package/src/util/unicode.ts +9 -3
  1442. package/src/util/xml.ts +1 -4
  1443. package/src/version.ts +9 -3
  1444. package/src/watcher/__tests__/engine.test.ts +331 -4
  1445. package/src/watcher/__tests__/payload-bounds.test.ts +414 -0
  1446. package/src/watcher/constants.ts +69 -0
  1447. package/src/watcher/engine.ts +135 -25
  1448. package/src/watcher/payload-bounds.ts +443 -0
  1449. package/src/watcher/provider-types.ts +13 -0
  1450. package/src/watcher/providers/github.ts +18 -6
  1451. package/src/watcher/providers/gmail.ts +1 -0
  1452. package/src/watcher/providers/google-calendar.ts +36 -16
  1453. package/src/watcher/providers/linear.ts +16 -5
  1454. package/src/watcher/providers/outlook-calendar.ts +4 -1
  1455. package/src/watcher/providers/outlook.ts +1 -0
  1456. package/src/watcher/telemetry.ts +3 -1
  1457. package/src/watcher/watcher-store.ts +32 -12
  1458. package/src/workflows/deterministic-stringify.ts +6 -2
  1459. package/src/workflows/engine-integration.test.ts +3 -1
  1460. package/src/workflows/engine.test.ts +17 -6
  1461. package/src/workflows/engine.ts +88 -32
  1462. package/src/workflows/journal-store.ts +3 -1
  1463. package/src/workflows/leaf-runner.ts +9 -2
  1464. package/src/workflows/library.test.ts +5 -2
  1465. package/src/workflows/library.ts +15 -5
  1466. package/src/workflows/run-manager.test.ts +9 -3
  1467. package/src/workflows/run-manager.ts +18 -6
  1468. package/src/workflows/sandbox.ts +6 -2
  1469. package/src/workspace/adaptive-thinking-repair.ts +33 -11
  1470. package/src/workspace/byok-default-profile-ensure.ts +627 -0
  1471. package/src/workspace/commit-message-enrichment-service.ts +15 -5
  1472. package/src/workspace/custom-profile-ensure.ts +26 -15
  1473. package/src/workspace/default-provider-ensure.ts +11 -10
  1474. package/src/workspace/git-service.ts +12 -4
  1475. package/src/workspace/hatched-date.ts +12 -4
  1476. package/src/workspace/heartbeat-service.ts +3 -1
  1477. package/src/workspace/migrations/003-seed-device-id.ts +12 -4
  1478. package/src/workspace/migrations/004-extract-collect-usage-data.ts +27 -9
  1479. package/src/workspace/migrations/006-services-config.ts +17 -6
  1480. package/src/workspace/migrations/007-web-search-provider-rename.ts +34 -10
  1481. package/src/workspace/migrations/010-app-dir-rename.ts +21 -7
  1482. package/src/workspace/migrations/012-rename-conversation-disk-view-dirs.ts +30 -10
  1483. package/src/workspace/migrations/016-extract-feature-flags-to-protected.ts +12 -4
  1484. package/src/workspace/migrations/017-seed-persona-dirs.ts +15 -5
  1485. package/src/workspace/migrations/018-rekey-compound-credential-keys.ts +30 -10
  1486. package/src/workspace/migrations/019-scope-journal-to-guardian.ts +18 -6
  1487. package/src/workspace/migrations/020-rename-oauth-skill-dirs.ts +6 -2
  1488. package/src/workspace/migrations/021-move-signals-to-workspace.ts +6 -2
  1489. package/src/workspace/migrations/022-move-hooks-to-workspace.ts +6 -2
  1490. package/src/workspace/migrations/023-move-config-files-to-workspace.ts +6 -2
  1491. package/src/workspace/migrations/024-move-runtime-files-to-workspace.ts +6 -2
  1492. package/src/workspace/migrations/025-remove-oauth-app-setup-skills.ts +3 -1
  1493. package/src/workspace/migrations/026-backfill-install-meta.ts +27 -9
  1494. package/src/workspace/migrations/028-recover-conversations-from-disk-view.ts +9 -3
  1495. package/src/workspace/migrations/029-seed-pkb.ts +3 -1
  1496. package/src/workspace/migrations/030-seed-pkb-autoinject.ts +6 -2
  1497. package/src/workspace/migrations/031-drop-user-md.ts +25 -10
  1498. package/src/workspace/migrations/031-llm-log-retention-zero-to-null.ts +28 -10
  1499. package/src/workspace/migrations/032-tts-provider-unification.ts +33 -11
  1500. package/src/workspace/migrations/033-stt-service-explicit-config.ts +12 -4
  1501. package/src/workspace/migrations/034-remove-calls-voice-transcription-provider.ts +24 -8
  1502. package/src/workspace/migrations/036-update-pkb-index-bar.ts +6 -2
  1503. package/src/workspace/migrations/037-create-meets-dir.ts +3 -1
  1504. package/src/workspace/migrations/038-unify-llm-callsite-configs.ts +27 -9
  1505. package/src/workspace/migrations/039-drop-legacy-llm-keys.ts +9 -3
  1506. package/src/workspace/migrations/040-seed-latency-callsite-defaults.ts +15 -5
  1507. package/src/workspace/migrations/041-backfill-google-gmail-settings-scope.ts +9 -3
  1508. package/src/workspace/migrations/042-fix-backfill-google-gmail-settings-scope.ts +9 -3
  1509. package/src/workspace/migrations/044-bump-stale-provider-stream-timeout.ts +11 -4
  1510. package/src/workspace/migrations/046-seed-conversation-starters-callsite.ts +12 -4
  1511. package/src/workspace/migrations/047-remove-watch-callsites.ts +18 -5
  1512. package/src/workspace/migrations/050-seed-main-agent-opus-callsite.ts +9 -3
  1513. package/src/workspace/migrations/051-seed-conversation-summarization-callsite.ts +12 -4
  1514. package/src/workspace/migrations/052-seed-default-inference-profiles.ts +12 -4
  1515. package/src/workspace/migrations/054-seed-recall-callsite.ts +12 -4
  1516. package/src/workspace/migrations/057-repair-stale-gemini-model-ids.ts +39 -13
  1517. package/src/workspace/migrations/059-move-pid-to-workspace.ts +6 -2
  1518. package/src/workspace/migrations/061-move-backup-key-to-workspace.ts +6 -2
  1519. package/src/workspace/migrations/064-unwind-main-agent-opus-seed.ts +21 -7
  1520. package/src/workspace/migrations/065-bump-stale-heartbeat-interval.ts +12 -3
  1521. package/src/workspace/migrations/066-seed-heartbeat-callsite-cost-default.ts +18 -6
  1522. package/src/workspace/migrations/069-seed-onboarding-threads.ts +9 -3
  1523. package/src/workspace/migrations/072-seed-reply-suggestion-callsite.ts +12 -4
  1524. package/src/workspace/migrations/073-repair-recall-callsite-empty-profile.ts +21 -7
  1525. package/src/workspace/migrations/074-drop-deprecated-secret-detection-keys.ts +12 -4
  1526. package/src/workspace/migrations/075-memory-v2-bm25-b-default-reembed.ts +9 -3
  1527. package/src/workspace/migrations/076-drop-services-inference-mode.ts +13 -5
  1528. package/src/workspace/migrations/077-seed-memory-router-callsite.ts +9 -3
  1529. package/src/workspace/migrations/079-home-feed-notification-only.ts +21 -7
  1530. package/src/workspace/migrations/080-restrict-vercel-api-token-metadata.ts +3 -1
  1531. package/src/workspace/migrations/081-backfill-bash-allowed-tools-for-injection-credentials.ts +9 -3
  1532. package/src/workspace/migrations/082-backfill-managed-profile-labels.ts +15 -5
  1533. package/src/workspace/migrations/083-system-prompt-prefix-to-file.ts +8 -3
  1534. package/src/workspace/migrations/084-remove-legacy-skills-index.ts +42 -14
  1535. package/src/workspace/migrations/085-memory-v2-bm25-b-reembed-disabled-v2-pages.ts +12 -4
  1536. package/src/workspace/migrations/086-revert-stale-gemini-mis-rewrites.ts +33 -11
  1537. package/src/workspace/migrations/087-memory-router-balanced-profile.ts +15 -5
  1538. package/src/workspace/migrations/088-deprecate-background-conversation-override.ts +9 -3
  1539. package/src/workspace/migrations/089-move-memory-tree-out-of-v3.ts +6 -2
  1540. package/src/workspace/migrations/090-memory-router-cost-optimized-profile.ts +21 -7
  1541. package/src/workspace/migrations/091-retighten-migration-onboarding-thread.ts +9 -3
  1542. package/src/workspace/migrations/092-backfill-v3-leaves.ts +30 -10
  1543. package/src/workspace/migrations/093-backfill-leaf-ids.ts +15 -5
  1544. package/src/workspace/migrations/094-seed-avatar-manifest.ts +9 -3
  1545. package/src/workspace/migrations/095-bump-heartbeat-interval-30m-to-60m.ts +12 -3
  1546. package/src/workspace/migrations/096-reduce-quality-profile-effort.ts +18 -6
  1547. package/src/workspace/migrations/097-enable-adaptive-thinking-managed-profiles.ts +27 -9
  1548. package/src/workspace/migrations/099-disable-cache-one-shot-callsites.ts +24 -8
  1549. package/src/workspace/migrations/100-upgrade-quality-profile-to-fable-5.ts +21 -7
  1550. package/src/workspace/migrations/101-upgrade-balanced-economy-to-minimax-m3.ts +15 -5
  1551. package/src/workspace/migrations/102-preserve-heartbeat-enabled-for-existing-workspaces.ts +9 -3
  1552. package/src/workspace/migrations/103-upgrade-quality-profile-to-opus-4-8.ts +21 -7
  1553. package/src/workspace/migrations/104-recheck-adaptive-thinking-model-implied-anthropic.ts +27 -9
  1554. package/src/workspace/migrations/105-enable-memory-v3-live-for-new-workspaces.ts +21 -7
  1555. package/src/workspace/migrations/106-drop-collect-usage-data.ts +9 -3
  1556. package/src/workspace/migrations/107-drop-send-diagnostics.ts +9 -3
  1557. package/src/workspace/migrations/108-drop-balanced-economy-profile.ts +18 -6
  1558. package/src/workspace/migrations/109-swap-quality-profile-to-glm-5p2.ts +9 -3
  1559. package/src/workspace/migrations/110-flip-balanced-profile-to-together.ts +12 -4
  1560. package/src/workspace/migrations/111-prune-seeded-callsite-defaults.ts +36 -12
  1561. package/src/workspace/migrations/112-remove-advisor-callsite-override.ts +18 -5
  1562. package/src/workspace/migrations/113-swap-balanced-profile-to-glm-5p2.ts +18 -6
  1563. package/src/workspace/migrations/114-swap-quality-profile-to-opus.ts +12 -4
  1564. package/src/workspace/migrations/115-drop-frontier-profile.ts +18 -6
  1565. package/src/workspace/migrations/117-normalize-stale-lean-memory-v3-defaults.ts +15 -5
  1566. package/src/workspace/migrations/118-seed-now-md.ts +3 -1
  1567. package/src/workspace/migrations/119-strip-persisted-memory-v3-tuning-defaults.ts +18 -6
  1568. package/src/workspace/migrations/120-revise-onboarding-threads.ts +9 -3
  1569. package/src/workspace/migrations/121-seed-default-user-guardrails.ts +3 -1
  1570. package/src/workspace/migrations/123-swap-quality-profile-to-fable.ts +24 -8
  1571. package/src/workspace/migrations/125-repoint-managed-connections-to-vellum.ts +21 -7
  1572. package/src/workspace/migrations/126-strip-managed-profile-bodies.ts +21 -7
  1573. package/src/workspace/migrations/129-remove-analyze-conversation-config.ts +9 -3
  1574. package/src/workspace/migrations/130-speech-mode-to-provider.ts +24 -8
  1575. package/src/workspace/migrations/131-drop-web-fetch-mode.ts +13 -5
  1576. package/src/workspace/migrations/133-collapse-provider-connections.ts +30 -10
  1577. package/src/workspace/migrations/136-repair-stale-fireworks-kimi-model-id.ts +127 -0
  1578. package/src/workspace/migrations/__tests__/backfill-leaf-ids.test.ts +3 -1
  1579. package/src/workspace/migrations/migrate-to-workspace-volume.ts +9 -3
  1580. package/src/workspace/migrations/rebuild-conversation-disk-view.ts +23 -8
  1581. package/src/workspace/migrations/registry.ts +2 -0
  1582. package/src/workspace/migrations/utils.ts +3 -1
  1583. package/src/workspace/top-level-renderer.ts +3 -1
  1584. package/src/__tests__/history-repair-hook.test.ts +0 -392
  1585. package/src/daemon/__tests__/route-conversation-post.test.ts +0 -158
  1586. package/src/daemon/route-conversation-post.ts +0 -158
  1587. package/src/plugins/defaults/history-repair/hooks/post-model-call.ts +0 -50
  1588. package/src/plugins/defaults/history-repair/hooks/stop.ts +0 -22
  1589. package/src/plugins/defaults/history-repair/hooks/user-prompt-submit.ts +0 -35
  1590. package/src/plugins/defaults/history-repair/package.json +0 -14
  1591. package/src/plugins/defaults/history-repair/repair-state-store.ts +0 -51
@@ -17,6 +17,7 @@ import {
17
17
  PLACEHOLDER_BLOCKS_OMITTED,
18
18
  PLACEHOLDER_EMPTY_TURN,
19
19
  } from "../placeholder-sentinels.js";
20
+ import { recordProviderRequestDiagnostics } from "../request-diagnostics.js";
20
21
  import { createStreamTimeout } from "../stream-timeout.js";
21
22
  import type {
22
23
  ContentBlock,
@@ -55,7 +56,9 @@ export function detectAnthropicContextOverflow(
55
56
  error: InstanceType<typeof Anthropic.APIError>,
56
57
  ): { actualTokens?: number; maxTokens?: number } | null {
57
58
  // 413 is theoretically adjacent but Anthropic does not emit it today.
58
- if (error.status !== 400) return null;
59
+ if (error.status !== 400) {
60
+ return null;
61
+ }
59
62
  const body = error.error as
60
63
  | {
61
64
  type?: string;
@@ -69,7 +72,9 @@ export function detectAnthropicContextOverflow(
69
72
  : undefined) ?? "";
70
73
  const topLevelMessage = error.message ?? "";
71
74
  const combined = `${innerMessage} ${topLevelMessage}`;
72
- if (!/prompt.?is.?too.?long|prompt_too_long/i.test(combined)) return null;
75
+ if (!/prompt.?is.?too.?long|prompt_too_long/i.test(combined)) {
76
+ return null;
77
+ }
73
78
  // Prefer the clean inner message over the JSON-stringified top-level string.
74
79
  return extractOverflowTokensFromMessage(innerMessage || topLevelMessage);
75
80
  }
@@ -153,9 +158,15 @@ export function deriveAnthropicReason(
153
158
  if (apiType === "not_found_error" || status === 404) {
154
159
  return mentionsModel ? "model_not_found" : "bad_request";
155
160
  }
156
- if (apiType === "rate_limit_error" || status === 429) return "rate_limited";
157
- if (apiType === "overloaded_error" || status === 529) return "overloaded";
158
- if (status !== undefined && status >= 500) return "server_error";
161
+ if (apiType === "rate_limit_error" || status === 429) {
162
+ return "rate_limited";
163
+ }
164
+ if (apiType === "overloaded_error" || status === 529) {
165
+ return "overloaded";
166
+ }
167
+ if (status !== undefined && status >= 500) {
168
+ return "server_error";
169
+ }
159
170
  if (
160
171
  apiType === "invalid_request_error" ||
161
172
  (status !== undefined && status >= 400)
@@ -174,15 +185,23 @@ function logOrphanedSurrogateWarning(
174
185
  messages: Anthropic.MessageParam[],
175
186
  ): void {
176
187
  const now = Date.now();
177
- if (now - lastOrphanWarningMs < ORPHAN_WARNING_THROTTLE_MS) return;
188
+ if (now - lastOrphanWarningMs < ORPHAN_WARNING_THROTTLE_MS) {
189
+ return;
190
+ }
178
191
  lastOrphanWarningMs = now;
179
192
  const blockTypes = new Set<string>();
180
193
  for (const msg of messages) {
181
- if (!Array.isArray(msg.content)) continue;
194
+ if (!Array.isArray(msg.content)) {
195
+ continue;
196
+ }
182
197
  for (const block of msg.content) {
183
- if (typeof block !== "object" || block == null) continue;
198
+ if (typeof block !== "object" || block == null) {
199
+ continue;
200
+ }
184
201
  const type = (block as { type?: string }).type;
185
- if (type) blockTypes.add(type);
202
+ if (type) {
203
+ blockTypes.add(type);
204
+ }
186
205
  }
187
206
  }
188
207
  log.warn(
@@ -257,7 +276,9 @@ function isTextBasedMimeType(mediaType: string): boolean {
257
276
 
258
277
  /** Anthropic requires tool_use IDs to match ^[a-zA-Z0-9_-]+$ */
259
278
  function sanitizeToolId(id: string): string {
260
- if (!id) return "empty";
279
+ if (!id) {
280
+ return "empty";
281
+ }
261
282
  // Escape `x` itself (to `x78`) so it can safely serve as the hex-escape
262
283
  // prefix without collisions. E.g. "a:" → "ax3a", "ax3a" → "ax783a".
263
284
  return id.replace(TOOL_ID_RE, (ch) => {
@@ -306,13 +327,18 @@ function summarizeMessages(messages: Anthropic.MessageParam[]): string[] {
306
327
  const content = Array.isArray(m.content) ? m.content : [{ type: "text" }];
307
328
  const blockDescs = content.map((b) => {
308
329
  const bt = (b as { type: string }).type;
309
- if (bt === "tool_use") return `tool_use(${(b as { id: string }).id})`;
310
- if (bt === "server_tool_use")
330
+ if (bt === "tool_use") {
331
+ return `tool_use(${(b as { id: string }).id})`;
332
+ }
333
+ if (bt === "server_tool_use") {
311
334
  return `server_tool_use(${(b as { id: string }).id})`;
312
- if (bt === "tool_result")
335
+ }
336
+ if (bt === "tool_result") {
313
337
  return `tool_result(${(b as { tool_use_id: string }).tool_use_id})`;
314
- if (bt === "web_search_tool_result")
338
+ }
339
+ if (bt === "web_search_tool_result") {
315
340
  return `web_search_tool_result(${(b as { tool_use_id: string }).tool_use_id})`;
341
+ }
316
342
  return bt;
317
343
  });
318
344
  return `[${idx}] ${m.role}: ${blockDescs.join(", ") || "(empty)"}`;
@@ -355,12 +381,18 @@ function hasOrderedToolResultPrefix(
355
381
  content: Anthropic.ContentBlockParam[],
356
382
  orderedToolUseIds: string[],
357
383
  ): boolean {
358
- if (content.length < orderedToolUseIds.length) return false;
384
+ if (content.length < orderedToolUseIds.length) {
385
+ return false;
386
+ }
359
387
  for (let idx = 0; idx < orderedToolUseIds.length; idx++) {
360
388
  const block = content[idx];
361
389
  const expectedId = orderedToolUseIds[idx];
362
- if (!isToolResultBlock(block)) return false;
363
- if (block.tool_use_id !== expectedId) return false;
390
+ if (!isToolResultBlock(block)) {
391
+ return false;
392
+ }
393
+ if (block.tool_use_id !== expectedId) {
394
+ return false;
395
+ }
364
396
  }
365
397
  return true;
366
398
  }
@@ -498,7 +530,9 @@ function repairOrphanedServerToolBlocks(
498
530
  messages: Anthropic.MessageParam[],
499
531
  ): Anthropic.MessageParam[] {
500
532
  return messages.map((msg) => {
501
- if (msg.role !== "assistant") return msg;
533
+ if (msg.role !== "assistant") {
534
+ return msg;
535
+ }
502
536
  const content = Array.isArray(msg.content) ? msg.content : [];
503
537
 
504
538
  const serverToolUseIds = new Set<string>();
@@ -514,11 +548,15 @@ function repairOrphanedServerToolBlocks(
514
548
 
515
549
  const orphanServerToolUseIds = new Set<string>();
516
550
  for (const id of serverToolUseIds) {
517
- if (!webSearchResultIds.has(id)) orphanServerToolUseIds.add(id);
551
+ if (!webSearchResultIds.has(id)) {
552
+ orphanServerToolUseIds.add(id);
553
+ }
518
554
  }
519
555
  const orphanWebSearchResultIds = new Set<string>();
520
556
  for (const id of webSearchResultIds) {
521
- if (!serverToolUseIds.has(id)) orphanWebSearchResultIds.add(id);
557
+ if (!serverToolUseIds.has(id)) {
558
+ orphanWebSearchResultIds.add(id);
559
+ }
522
560
  }
523
561
 
524
562
  if (
@@ -644,7 +682,9 @@ function findActiveToolUseContinuationStart(
644
682
  const hasToolResult = content.some(
645
683
  (b) => typeof b !== "string" && isToolResultBlock(b),
646
684
  );
647
- if (!hasToolResult) break;
685
+ if (!hasToolResult) {
686
+ break;
687
+ }
648
688
  // This user message has tool_result — the preceding assistant message
649
689
  // should have the matching tool_use and its thinking blocks preserved.
650
690
  i--;
@@ -653,7 +693,9 @@ function findActiveToolUseContinuationStart(
653
693
  const hasToolUse = content.some(
654
694
  (b) => typeof b !== "string" && isToolUseBlock(b),
655
695
  );
656
- if (!hasToolUse) break;
696
+ if (!hasToolUse) {
697
+ break;
698
+ }
657
699
  // This assistant message has tool_use — it's part of the active span.
658
700
  // Check if the preceding user message continues the chain.
659
701
  i--;
@@ -808,10 +850,14 @@ function ensureToolPairing(
808
850
  // within assistant messages and are not validated here.
809
851
  for (let j = 0; j < result.length; j++) {
810
852
  const m = result[j];
811
- if (m.role !== "assistant") continue;
853
+ if (m.role !== "assistant") {
854
+ continue;
855
+ }
812
856
  const c = Array.isArray(m.content) ? m.content : [];
813
857
  const validationIds = getOrderedToolUseIds(c);
814
- if (validationIds.length === 0) continue;
858
+ if (validationIds.length === 0) {
859
+ continue;
860
+ }
815
861
 
816
862
  const nxt = result[j + 1];
817
863
  const nxtContent =
@@ -1049,7 +1095,9 @@ export class AnthropicProvider implements Provider {
1049
1095
  text,
1050
1096
  ...(disableCache ? {} : { cache_control: cacheControl }),
1051
1097
  }));
1052
- if (params.system.length === 0) delete params.system;
1098
+ if (params.system.length === 0) {
1099
+ delete params.system;
1100
+ }
1053
1101
  }
1054
1102
 
1055
1103
  // Tools precede the system blocks in the cached prefix, so the first
@@ -1106,20 +1154,26 @@ export class AnthropicProvider implements Provider {
1106
1154
  const findUserTextMsgIdx = (startIdx: number): number => {
1107
1155
  for (let i = startIdx; i >= 0; i--) {
1108
1156
  const msg = msgs[i];
1109
- if (msg.role !== "user" || !Array.isArray(msg.content)) continue;
1157
+ if (msg.role !== "user" || !Array.isArray(msg.content)) {
1158
+ continue;
1159
+ }
1110
1160
  const hasText = msg.content.some(
1111
1161
  (b) =>
1112
1162
  typeof b !== "string" &&
1113
1163
  b.type === "text" &&
1114
1164
  b.text !== SYNTHETIC_CONTINUATION_TEXT,
1115
1165
  );
1116
- if (hasText) return i;
1166
+ if (hasText) {
1167
+ return i;
1168
+ }
1117
1169
  }
1118
1170
  return -1;
1119
1171
  };
1120
1172
  const applyCacheControlToLastBlock = (msgIdx: number): void => {
1121
1173
  const content = msgs[msgIdx].content;
1122
- if (!Array.isArray(content) || content.length === 0) return;
1174
+ if (!Array.isArray(content) || content.length === 0) {
1175
+ return;
1176
+ }
1123
1177
  const lastBlock = content[content.length - 1];
1124
1178
  if (typeof lastBlock !== "string") {
1125
1179
  (lastBlock as unknown as Record<string, unknown>).cache_control =
@@ -1162,8 +1216,9 @@ export class AnthropicProvider implements Provider {
1162
1216
  turnStartIdx > 0
1163
1217
  ) {
1164
1218
  const prevTurnAnchorIdx = findUserTextMsgIdx(turnStartIdx - 1);
1165
- if (prevTurnAnchorIdx >= 0)
1219
+ if (prevTurnAnchorIdx >= 0) {
1166
1220
  applyCacheControlToLastBlock(prevTurnAnchorIdx);
1221
+ }
1167
1222
  }
1168
1223
 
1169
1224
  // Advancing tail: place a short-lived 5m cache breakpoint on the last
@@ -1241,13 +1296,19 @@ export class AnthropicProvider implements Provider {
1241
1296
  // The client's own breakpoints already omit it for Haiku.
1242
1297
  if (disableCache || isHaiku) {
1243
1298
  for (const msg of sentMessages) {
1244
- if (!Array.isArray(msg.content)) continue;
1299
+ if (!Array.isArray(msg.content)) {
1300
+ continue;
1301
+ }
1245
1302
  for (const block of msg.content) {
1246
- if (typeof block === "string") continue;
1303
+ if (typeof block === "string") {
1304
+ continue;
1305
+ }
1247
1306
  const blockRecord = block as {
1248
1307
  cache_control?: { ttl?: unknown };
1249
1308
  };
1250
- if (!blockRecord.cache_control) continue;
1309
+ if (!blockRecord.cache_control) {
1310
+ continue;
1311
+ }
1251
1312
  if (disableCache) {
1252
1313
  delete blockRecord.cache_control;
1253
1314
  } else if ("ttl" in blockRecord.cache_control) {
@@ -1286,6 +1347,7 @@ export class AnthropicProvider implements Provider {
1286
1347
 
1287
1348
  let response: Anthropic.Message;
1288
1349
  try {
1350
+ recordProviderRequestDiagnostics({ model_id: params.model });
1289
1351
  const requestHeaders = {
1290
1352
  ...this.requestHeaders,
1291
1353
  ...(usageAttributionHeaders ?? {}),
@@ -1338,7 +1400,9 @@ export class AnthropicProvider implements Provider {
1338
1400
 
1339
1401
  stream.on("text", (text) => {
1340
1402
  textBuffer += text;
1341
- if (couldBePlaceholderSentinelPrefix(textBuffer)) return;
1403
+ if (couldBePlaceholderSentinelPrefix(textBuffer)) {
1404
+ return;
1405
+ }
1342
1406
  onEvent?.({ type: "text_delta", text: textBuffer });
1343
1407
  textBuffer = "";
1344
1408
  });
@@ -1491,7 +1555,9 @@ export class AnthropicProvider implements Provider {
1491
1555
  accumulatedServerToolInputJson += partialJson;
1492
1556
  return;
1493
1557
  }
1494
- if (!currentStreamingToolName) return;
1558
+ if (!currentStreamingToolName) {
1559
+ return;
1560
+ }
1495
1561
  accumulatedInputJson += partialJson;
1496
1562
  const now = Date.now();
1497
1563
  if (now - lastInputJsonEmitMs >= 150) {
@@ -1660,24 +1726,33 @@ export class AnthropicProvider implements Provider {
1660
1726
  apiErrorType?: string;
1661
1727
  apiErrorCode?: string;
1662
1728
  } = {};
1663
- if (retryAfterMs !== undefined)
1729
+ if (retryAfterMs !== undefined) {
1664
1730
  errorOptions.retryAfterMs = retryAfterMs;
1665
- if (abortReason) errorOptions.abortReason = abortReason;
1731
+ }
1732
+ if (abortReason) {
1733
+ errorOptions.abortReason = abortReason;
1734
+ }
1666
1735
  // Stamp the semantic reason + structured type/code so downstream
1667
1736
  // classification/retry can switch on intent. Skip on caller-abort:
1668
1737
  // abortReason already short-circuits and carries the intent.
1669
1738
  if (!abortReason) {
1670
1739
  errorOptions.reason = deriveAnthropicReason(error);
1671
1740
  const apiErrorType = readAnthropicErrorType(error);
1672
- if (apiErrorType) errorOptions.apiErrorType = apiErrorType;
1741
+ if (apiErrorType) {
1742
+ errorOptions.apiErrorType = apiErrorType;
1743
+ }
1673
1744
  const apiErrorCode = readAnthropicErrorCode(error);
1674
- if (apiErrorCode) errorOptions.apiErrorCode = apiErrorCode;
1745
+ if (apiErrorCode) {
1746
+ errorOptions.apiErrorCode = apiErrorCode;
1747
+ }
1675
1748
  }
1676
1749
  // Only preserve the original error as `cause` for transport aborts
1677
1750
  // without a daemon-tagged reason — it's the diagnostic signal the
1678
1751
  // retry layer and log reader rely on. Don't leak it through the
1679
1752
  // caller-aborted path, which already carries `abortReason`.
1680
- if (!abortReason && isAbortMessage) errorOptions.cause = error;
1753
+ if (!abortReason && isAbortMessage) {
1754
+ errorOptions.cause = error;
1755
+ }
1681
1756
  // Rewrite the message only for inner-timeout, so the retry layer
1682
1757
  // won't retry a request that already hit its 30-min deadline.
1683
1758
  const rewrittenMessage =
@@ -1859,8 +1934,9 @@ export class AnthropicProvider implements Provider {
1859
1934
  c.length !== 1 ||
1860
1935
  typeof c[0] === "string" ||
1861
1936
  c[0].type !== "text"
1862
- )
1937
+ ) {
1863
1938
  return false;
1939
+ }
1864
1940
  const text = (c[0] as { text?: string }).text;
1865
1941
  return typeof text === "string" && isPlaceholderSentinelText(text);
1866
1942
  };
@@ -1921,7 +1997,9 @@ export class AnthropicProvider implements Provider {
1921
1997
  const activeToolUseStart = findActiveToolUseContinuationStart(formatted);
1922
1998
  for (let i = 0; i < activeToolUseStart; i++) {
1923
1999
  const msg = formatted[i];
1924
- if (msg.role !== "assistant" || !Array.isArray(msg.content)) continue;
2000
+ if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
2001
+ continue;
2002
+ }
1925
2003
  const stripped = (msg.content as Anthropic.ContentBlockParam[]).filter(
1926
2004
  (b) =>
1927
2005
  typeof b === "string" ||
@@ -37,6 +37,7 @@ import {
37
37
  import { listConnections } from "./inference/connections.js";
38
38
  import type { ProvidersConfig } from "./registry.js";
39
39
  import { shouldUseNativeWebSearch } from "./registry.js";
40
+ import { recordProviderRequestDiagnostics } from "./request-diagnostics.js";
40
41
  import type {
41
42
  Message,
42
43
  Provider,
@@ -266,6 +267,12 @@ export class CallSiteRoutingProvider implements Provider {
266
267
  resolved.model,
267
268
  );
268
269
  if (connectionProvider) {
270
+ // The connection whose credential the call authenticates with is only
271
+ // known here, and diagnostics for a failed request are unactionable
272
+ // without it ("which key was this?"). Recorded once the adapter exists,
273
+ // so a connection that fell back to the default transport is not
274
+ // reported as the one that signed the request.
275
+ recordProviderRequestDiagnostics({ connection_name: connectionName });
269
276
  return connectionProvider;
270
277
  }
271
278
  // Soft credential failure: the routed connection yielded no usable
@@ -32,8 +32,12 @@ export function isConnectionCompatibleWithModel(
32
32
  connection: Pick<ProviderConnection, "auth">,
33
33
  model: string | undefined,
34
34
  ): boolean {
35
- if (connection.auth.type !== "oauth_subscription") return true;
36
- if (!model) return true;
35
+ if (connection.auth.type !== "oauth_subscription") {
36
+ return true;
37
+ }
38
+ if (!model) {
39
+ return true;
40
+ }
37
41
  return isCodexSubscriptionModel(model);
38
42
  }
39
43
 
@@ -49,13 +53,17 @@ export function describeSubscriptionModelIncompatibility(
49
53
  candidates: Pick<ProviderConnection, "auth">[],
50
54
  model: string | undefined,
51
55
  ): string | null {
52
- if (!model || candidates.length === 0) return null;
56
+ if (!model || candidates.length === 0) {
57
+ return null;
58
+ }
53
59
  if (candidates.some((c) => isConnectionCompatibleWithModel(c, model))) {
54
60
  return null;
55
61
  }
56
62
  const allSubscription = candidates.every(
57
63
  (c) => c.auth.type === "oauth_subscription",
58
64
  );
59
- if (!allSubscription) return null;
65
+ if (!allSubscription) {
66
+ return null;
67
+ }
60
68
  return `Model "${model}" isn't available through your ChatGPT subscription. Select a supported model or add an OpenAI API key connection.`;
61
69
  }
@@ -68,8 +68,9 @@ export const FETCH_PROVIDER_CATALOG: readonly FetchProviderCatalogEntry[] = [
68
68
  ];
69
69
 
70
70
  /** Provider ids accepted by the web-fetch config schema. */
71
- export const FETCH_PROVIDER_IDS: readonly string[] =
72
- FETCH_PROVIDER_CATALOG.map((p) => p.id);
71
+ export const FETCH_PROVIDER_IDS: readonly string[] = FETCH_PROVIDER_CATALOG.map(
72
+ (p) => p.id,
73
+ );
73
74
 
74
75
  /** Catalog entries that require a user-supplied API key. */
75
76
  export const BYOK_FETCH_PROVIDERS: readonly FetchProviderCatalogEntry[] =
@@ -12,6 +12,7 @@ import { getLogger } from "../../util/logger.js";
12
12
  import { DAILY_LIMIT_PATTERNS } from "../../util/provider-error-patterns.js";
13
13
  import { base64Source, resolveMediaReferences } from "../media-resolve.js";
14
14
  import { PROVIDER_CATALOG } from "../model-catalog.js";
15
+ import { recordProviderRequestDiagnostics } from "../request-diagnostics.js";
15
16
  import { createStreamTimeout } from "../stream-timeout.js";
16
17
  import type {
17
18
  ContentBlock,
@@ -116,7 +117,9 @@ function buildThinkingConfig(
116
117
  thinking: Record<string, unknown> | undefined,
117
118
  model: string,
118
119
  ): genai.ThinkingConfig | undefined {
119
- if (!thinking) return undefined;
120
+ if (!thinking) {
121
+ return undefined;
122
+ }
120
123
  const floor = geminiThinkingFloor(model);
121
124
 
122
125
  if (thinking.type === "disabled") {
@@ -125,7 +128,9 @@ function buildThinkingConfig(
125
128
  includeThoughts: false,
126
129
  };
127
130
  }
128
- if (thinking.type !== "adaptive") return undefined;
131
+ if (thinking.type !== "adaptive") {
132
+ return undefined;
133
+ }
129
134
 
130
135
  const result: genai.ThinkingConfig = {};
131
136
  if (
@@ -196,13 +201,17 @@ export function detectGeminiContextOverflow(
196
201
  const status = error.status;
197
202
  // 400 = INVALID_ARGUMENT (prompt too long), 413 occasional,
198
203
  // 429 with RESOURCE_EXHAUSTED is the Vertex path.
199
- if (status !== 400 && status !== 413 && status !== 429) return null;
204
+ if (status !== 400 && status !== 413 && status !== 429) {
205
+ return null;
206
+ }
200
207
  const message = error.message ?? "";
201
208
 
202
209
  // 429 has two meanings (quota vs context-overflow) — require a
203
210
  // token/context-specific phrase to classify as overflow.
204
211
  if (status === 429) {
205
- if (!GEMINI_CONTEXT_OVERFLOW_TOKEN_PATTERNS.test(message)) return null;
212
+ if (!GEMINI_CONTEXT_OVERFLOW_TOKEN_PATTERNS.test(message)) {
213
+ return null;
214
+ }
206
215
  return extractOverflowTokensFromMessage(message);
207
216
  }
208
217
 
@@ -211,7 +220,9 @@ export function detectGeminiContextOverflow(
211
220
  const matches =
212
221
  /resource.?exhausted/i.test(message) ||
213
222
  GEMINI_CONTEXT_OVERFLOW_TOKEN_PATTERNS.test(message);
214
- if (!matches) return null;
223
+ if (!matches) {
224
+ return null;
225
+ }
215
226
  return extractOverflowTokensFromMessage(message);
216
227
  }
217
228
 
@@ -229,12 +240,47 @@ const GEMINI_MODEL_RESTRICTED_PATTERNS =
229
240
  /** 5xx/UNAVAILABLE bodies that indicate transient overload rather than a generic server error. */
230
241
  const GEMINI_OVERLOAD_PATTERNS = /overload/i;
231
242
 
243
+ /**
244
+ * Detect whether an `ApiError` has an empty (or whitespace-only) message.
245
+ * Google's API always returns a JSON body with a real message on genuine
246
+ * errors. An empty message means the response had no body — the SDK's
247
+ * fallback `ApiError` construction — which indicates a proxy or egress
248
+ * filter intercepted the request before it reached Google.
249
+ */
250
+ function hasEmptyMessage(error: ApiError): boolean {
251
+ return (error.message ?? "").trim().length === 0;
252
+ }
253
+
254
+ /**
255
+ * Format a human-readable error message from a Gemini `ApiError`. When the
256
+ * error has an empty message (no JSON body returned), surface a distinct,
257
+ * actionable message pointing at network/proxy interception instead of the
258
+ * generic "Gemini API error (404): " which reads as "model not found."
259
+ */
260
+ export function formatGeminiErrorMessage(error: ApiError): string {
261
+ if (hasEmptyMessage(error)) {
262
+ return (
263
+ `Gemini API returned ${error.status} with no response body — ` +
264
+ "this typically indicates a network proxy or egress filter " +
265
+ "intercepting the request, not a genuine Google API error. " +
266
+ "Check your network configuration and ensure requests to " +
267
+ "generativelanguage.googleapis.com are allowed."
268
+ );
269
+ }
270
+ return `Gemini API error (${error.status}): ${error.message}`;
271
+ }
272
+
232
273
  /**
233
274
  * Map a Gemini `ApiError`'s HTTP status / status-name to a semantic
234
275
  * {@link ProviderErrorReason}. The SDK's `ApiError` exposes only `status` and
235
276
  * `message`, and the canonical status-name (e.g. `PERMISSION_DENIED`) rides the
236
277
  * message body, so we match on both. Context-overflow is handled separately by
237
278
  * {@link detectGeminiContextOverflow}; a plain 429 here is a rate limit.
279
+ *
280
+ * When the error message is empty (no JSON body), the response did not come
281
+ * from Google's API — a proxy or egress filter intercepted the request. In
282
+ * that case we return `"network_error"` for 404/403 status codes rather than
283
+ * `"model_not_found"` / `"invalid_credentials"`, which would mislead users.
238
284
  */
239
285
  export function deriveGeminiReason(error: ApiError): ProviderErrorReason {
240
286
  const status = error.status;
@@ -242,6 +288,13 @@ export function deriveGeminiReason(error: ApiError): ProviderErrorReason {
242
288
  const upper = message.toUpperCase();
243
289
  const hasName = (name: string) => upper.includes(name);
244
290
 
291
+ // Empty message → proxy/network interception, not a genuine Google error.
292
+ // Check this before the status-code branches so 404-with-empty-body doesn't
293
+ // get misclassified as "model_not_found."
294
+ if (hasEmptyMessage(error) && (status === 404 || status === 403)) {
295
+ return "network_error";
296
+ }
297
+
245
298
  // The managed proxy's daily-limit 402 body carries a specific code; match it
246
299
  // before the status branches so it isn't classified as a generic 4xx.
247
300
  if (DAILY_LIMIT_PATTERNS.some((re) => re.test(message))) {
@@ -299,9 +352,19 @@ export async function validateGeminiApiKey(
299
352
  return { valid: false, reason: "API key is invalid or expired." };
300
353
  }
301
354
  if (error.status === 403) {
355
+ // An empty-body 403 likely came from a proxy, not Google's API.
356
+ // Treat it as inconclusive (allow key storage) rather than rejecting
357
+ // with a non-actionable "Gemini API error (403): " message.
358
+ if (hasEmptyMessage(error)) {
359
+ log.warn(
360
+ { status: 403 },
361
+ "Gemini API returned 403 with empty body during key validation — likely proxy interception, allowing key storage",
362
+ );
363
+ return { valid: true };
364
+ }
302
365
  return {
303
366
  valid: false,
304
- reason: `Gemini API error (${error.status}): ${error.message}`,
367
+ reason: formatGeminiErrorMessage(error),
305
368
  };
306
369
  }
307
370
  // Transient errors (429, 5xx, etc.) — validation is inconclusive,
@@ -370,6 +433,7 @@ export class GeminiProvider implements Provider {
370
433
  : undefined;
371
434
 
372
435
  try {
436
+ recordProviderRequestDiagnostics({ model_id: activeModel });
373
437
  const geminiContents = this.toGeminiContents(messages, activeModel);
374
438
 
375
439
  const geminiConfig: genai.GenerateContentConfig = {};
@@ -454,7 +518,9 @@ export class GeminiProvider implements Provider {
454
518
  if (functionCallParts.length > 0) {
455
519
  for (const part of functionCallParts) {
456
520
  const fc = part.functionCall;
457
- if (!fc) continue;
521
+ if (!fc) {
522
+ continue;
523
+ }
458
524
  appendFunctionCall(fc, part.thoughtSignature);
459
525
  }
460
526
  } else {
@@ -561,7 +627,7 @@ export class GeminiProvider implements Provider {
561
627
  );
562
628
  }
563
629
  throw new ProviderError(
564
- `Gemini API error (${error.status}): ${error.message}`,
630
+ formatGeminiErrorMessage(error),
565
631
  "gemini",
566
632
  error.status,
567
633
  // Skip reason on caller-abort: abortReason already carries the intent
@@ -812,18 +878,26 @@ export class GeminiProvider implements Provider {
812
878
  parts: genai.Part[],
813
879
  model: string,
814
880
  ): void {
815
- if (!isGemini3Model(model)) return;
881
+ if (!isGemini3Model(model)) {
882
+ return;
883
+ }
816
884
 
817
885
  const functionCallParts = parts.filter((part) => part.functionCall);
818
- if (functionCallParts.length === 0) return;
886
+ if (functionCallParts.length === 0) {
887
+ return;
888
+ }
819
889
 
820
890
  const hasRealThoughtSignature = functionCallParts.some((part) =>
821
891
  Boolean(part.thoughtSignature),
822
892
  );
823
- if (hasRealThoughtSignature) return;
893
+ if (hasRealThoughtSignature) {
894
+ return;
895
+ }
824
896
 
825
897
  const firstFunctionCallPart = functionCallParts[0];
826
- if (!firstFunctionCallPart) return;
898
+ if (!firstFunctionCallPart) {
899
+ return;
900
+ }
827
901
  firstFunctionCallPart.thoughtSignature =
828
902
  GEMINI_3_UNSIGNED_TOOL_CALL_THOUGHT_SIGNATURE;
829
903
  }
@@ -41,12 +41,16 @@ export async function getValidCodexAccessToken(
41
41
  const accessToken = await getSecureKeyAsync(
42
42
  `${credentialPrefix}/access_token`,
43
43
  );
44
- if (!accessToken) return null;
44
+ if (!accessToken) {
45
+ return null;
46
+ }
45
47
 
46
48
  const expiresAtStr = await getSecureKeyAsync(
47
49
  `${credentialPrefix}/expires_at`,
48
50
  );
49
- if (!expiresAtStr) return accessToken; // no expiry info — use token as-is
51
+ if (!expiresAtStr) {
52
+ return accessToken;
53
+ } // no expiry info — use token as-is
50
54
 
51
55
  const expiresAt = Number(expiresAtStr);
52
56
  const now = Date.now() / 1000;