@vellumai/assistant 0.10.11 → 0.10.12-dev.202607242227.e52a30c

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 (932) hide show
  1. package/ARCHITECTURE.md +30 -21
  2. package/README.md +1 -1
  3. package/docs/architecture/memory.md +101 -630
  4. package/docs/architecture/security.md +7 -2
  5. package/docs/trusted-contact-access.md +29 -15
  6. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +2 -0
  7. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +449 -0
  8. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  9. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +260 -0
  10. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +468 -0
  11. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +2 -0
  12. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +449 -0
  13. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  14. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +260 -0
  15. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/secret-detection.ts +468 -0
  16. package/node_modules/@vellumai/gateway-client/src/__tests__/binding-strength-contract.test.ts +122 -0
  17. package/node_modules/@vellumai/gateway-client/src/binding-strength-contract.ts +155 -0
  18. package/node_modules/@vellumai/gateway-client/src/index.ts +14 -0
  19. package/node_modules/@vellumai/service-contracts/package.json +2 -0
  20. package/node_modules/@vellumai/service-contracts/src/__tests__/secret-detection.test.ts +449 -0
  21. package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  22. package/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +260 -0
  23. package/node_modules/@vellumai/service-contracts/src/secret-detection.ts +468 -0
  24. package/node_modules/@vellumai/slack-text/src/index.test.ts +71 -0
  25. package/node_modules/@vellumai/slack-text/src/index.ts +67 -20
  26. package/openapi.yaml +168 -14
  27. package/package.json +1 -1
  28. package/scripts/build-plugin-api.ts +22 -2
  29. package/scripts/generate-openapi.ts +21 -110
  30. package/scripts/voice-ttft-spike.ts +241 -0
  31. package/src/__tests__/acp-session.test.ts +3 -3
  32. package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +7 -0
  33. package/src/__tests__/approval-cascade.test.ts +12 -12
  34. package/src/__tests__/approval-routes-http.test.ts +3 -3
  35. package/src/__tests__/approval-source-link.test.ts +208 -0
  36. package/src/__tests__/assistant-event-hub-self-exclusion.test.ts +16 -16
  37. package/src/__tests__/assistant-event-hub-targeted.test.ts +13 -11
  38. package/src/__tests__/assistant-event-hub.test.ts +13 -11
  39. package/src/__tests__/assistant-event.test.ts +12 -9
  40. package/src/__tests__/assistant-events-sse-shed.test.ts +4 -4
  41. package/src/__tests__/assistant-id-boundary-guard.test.ts +0 -58
  42. package/src/__tests__/assistant-stream-state.test.ts +5 -3
  43. package/src/__tests__/avatar-identity-sync.test.ts +3 -3
  44. package/src/__tests__/browser-fill-credential.test.ts +3 -3
  45. package/src/__tests__/btw-routes.test.ts +13 -2
  46. package/src/__tests__/call-setup-flow-name-capture.test.ts +65 -3
  47. package/src/__tests__/channel-approvals.test.ts +0 -27
  48. package/src/__tests__/channel-delivery-store.test.ts +141 -0
  49. package/src/__tests__/channel-guardian.test.ts +85 -512
  50. package/src/__tests__/channel-retry-sweep.test.ts +344 -2
  51. package/src/__tests__/channel-setup-panel-ack.test.ts +10 -14
  52. package/src/__tests__/chat-reveal-guard-priming.test.ts +28 -28
  53. package/src/__tests__/cli-memory-v2-reembed-skills.test.ts +2 -2
  54. package/src/__tests__/compaction-events.test.ts +8 -8
  55. package/src/__tests__/config-loader-backfill.test.ts +22 -22
  56. package/src/__tests__/config-loader-platform-defaults.test.ts +59 -31
  57. package/src/__tests__/config-model-image-provider.test.ts +20 -0
  58. package/src/__tests__/config-schema.test.ts +118 -4
  59. package/src/__tests__/config-set-platform-guard.test.ts +39 -24
  60. package/src/__tests__/config-sounds-sync.test.ts +4 -4
  61. package/src/__tests__/config-watcher-skill-reseed.test.ts +170 -176
  62. package/src/__tests__/context-search-agent-runner.test.ts +2 -0
  63. package/src/__tests__/context-search-memory-v2-source.test.ts +5 -5
  64. package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +2 -2
  65. package/src/__tests__/conversation-agent-loop-fatal-cleanup.test.ts +3 -3
  66. package/src/__tests__/conversation-agent-loop-handlers-max-tokens.test.ts +4 -4
  67. package/src/__tests__/conversation-agent-loop-overflow.test.ts +12 -12
  68. package/src/__tests__/conversation-agent-loop.test.ts +29 -29
  69. package/src/__tests__/conversation-confirmation-signals.test.ts +14 -14
  70. package/src/__tests__/conversation-delete-missing-logs-db.test.ts +198 -0
  71. package/src/__tests__/conversation-delete-schedule-cleanup.test.ts +1 -1
  72. package/src/__tests__/conversation-fork-crud.test.ts +28 -22
  73. package/src/__tests__/conversation-fork-retrospective.test.ts +13 -10
  74. package/src/__tests__/conversation-history-web-search.test.ts +7 -0
  75. package/src/__tests__/conversation-key-store-disk-view.test.ts +5 -5
  76. package/src/__tests__/conversation-loop-db-lock-resilience.test.ts +5 -5
  77. package/src/__tests__/conversation-message-sync-tags.test.ts +4 -4
  78. package/src/__tests__/conversation-queue.test.ts +81 -81
  79. package/src/__tests__/conversation-retry-route.test.ts +72 -3
  80. package/src/__tests__/conversation-runtime-assembly.test.ts +27 -0
  81. package/src/__tests__/conversation-slash-queue.test.ts +11 -11
  82. package/src/__tests__/conversation-slash-unknown.test.ts +2 -2
  83. package/src/__tests__/conversation-speed-override.test.ts +2 -2
  84. package/src/__tests__/conversation-starter-routes.test.ts +2 -2
  85. package/src/__tests__/conversation-store-ephemeral.test.ts +182 -0
  86. package/src/__tests__/conversation-store.test.ts +4 -0
  87. package/src/__tests__/conversation-surface-state.test.ts +125 -0
  88. package/src/__tests__/conversation-surfaces-action-delivery.test.ts +22 -37
  89. package/src/__tests__/conversation-surfaces-activation-emit.test.ts +28 -29
  90. package/src/__tests__/conversation-surfaces-app-open.test.ts +52 -9
  91. package/src/__tests__/conversation-surfaces-data-persist.test.ts +8 -11
  92. package/src/__tests__/conversation-surfaces-deselection.test.ts +3 -9
  93. package/src/__tests__/conversation-surfaces-standalone-payloads.test.ts +9 -9
  94. package/src/__tests__/conversation-surfaces-standalone.test.ts +12 -12
  95. package/src/__tests__/conversation-surfaces-state-update.test.ts +154 -9
  96. package/src/__tests__/conversation-surfaces-table-action.test.ts +4 -5
  97. package/src/__tests__/conversation-surfaces-task-progress.test.ts +83 -65
  98. package/src/__tests__/conversation-sync-tags.test.ts +5 -5
  99. package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +1 -5
  100. package/src/__tests__/conversation-tool-setup-attribution.test.ts +1 -5
  101. package/src/__tests__/conversation-usage.test.ts +27 -0
  102. package/src/__tests__/conversation-wait-for-idle.test.ts +2 -2
  103. package/src/__tests__/credential-broker-browser-fill.test.ts +2 -2
  104. package/src/__tests__/credential-broker-server-use.test.ts +2 -2
  105. package/src/__tests__/credential-broker.test.ts +1 -1
  106. package/src/__tests__/credential-routes.test.ts +167 -0
  107. package/src/__tests__/credential-security-invariants.test.ts +3 -1
  108. package/src/__tests__/credential-transcript-scrub.test.ts +550 -0
  109. package/src/__tests__/daemon-assistant-events.test.ts +15 -15
  110. package/src/__tests__/document-preview-surface-schema.test.ts +33 -0
  111. package/src/__tests__/dynamic-skill-background-guard.test.ts +102 -13
  112. package/src/__tests__/emit-event-signal.test.ts +6 -6
  113. package/src/__tests__/estimator-calibration.test.ts +26 -0
  114. package/src/__tests__/events-tail-route.test.ts +6 -4
  115. package/src/__tests__/external-plugin-loader.test.ts +94 -1
  116. package/src/__tests__/guardian-card-withdrawal.test.ts +57 -0
  117. package/src/__tests__/helpers/native-web-search-harness.ts +10 -10
  118. package/src/__tests__/host-browser-proxy.test.ts +1 -1
  119. package/src/__tests__/host-transfer-pending-interactions.test.ts +17 -19
  120. package/src/__tests__/image-credentials.test.ts +65 -8
  121. package/src/__tests__/inference-no-mode-boot-e2e.test.ts +0 -1
  122. package/src/__tests__/injector-pkb-v2-silenced.test.ts +37 -7
  123. package/src/__tests__/injector-v3-suppression.test.ts +7 -0
  124. package/src/__tests__/inline-skill-load-permissions.test.ts +29 -6
  125. package/src/__tests__/introduction-card-resolver.test.ts +55 -4
  126. package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
  127. package/src/__tests__/lifecycle-memory-v2-seed.test.ts +20 -12
  128. package/src/__tests__/list-messages-page-latest.test.ts +2 -2
  129. package/src/__tests__/llm-context-resolution.test.ts +18 -0
  130. package/src/__tests__/llm-resolver-override-or-default.test.ts +22 -4
  131. package/src/__tests__/llm-usage-store.test.ts +116 -0
  132. package/src/__tests__/log-redact.test.ts +82 -0
  133. package/src/__tests__/managed-profile-guard.test.ts +66 -1
  134. package/src/__tests__/managed-skill-lifecycle.test.ts +2 -2
  135. package/src/__tests__/managed-store.test.ts +205 -0
  136. package/src/__tests__/media-generate-image.test.ts +62 -11
  137. package/src/__tests__/memory-retrieval-hook.test.ts +4 -4
  138. package/src/__tests__/memory-upsert-concurrency.test.ts +1 -1
  139. package/src/__tests__/mtime-cache.test.ts +88 -125
  140. package/src/__tests__/non-member-access-request.test.ts +87 -137
  141. package/src/__tests__/notification-deep-link.test.ts +12 -12
  142. package/src/__tests__/notification-vellum-adapter.test.ts +8 -8
  143. package/src/__tests__/openai-responses-prompt-cache.test.ts +27 -7
  144. package/src/__tests__/outbound-slack-persistence.test.ts +22 -23
  145. package/src/__tests__/pending-interactions-resolved-event.test.ts +6 -6
  146. package/src/__tests__/playbook-execution.test.ts +2 -2
  147. package/src/__tests__/playbook-tools.test.ts +2 -2
  148. package/src/__tests__/plugin-api-app-globals.test.ts +44 -0
  149. package/src/__tests__/plugin-api-shim.test.ts +52 -6
  150. package/src/__tests__/plugin-event-hub-facade.test.ts +18 -15
  151. package/src/__tests__/plugin-import-boundary-guard.test.ts +14 -8
  152. package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +0 -1
  153. package/src/__tests__/plugin-secret-pattern-contribution.test.ts +324 -0
  154. package/src/__tests__/plugin-secret-patterns.test.ts +234 -0
  155. package/src/__tests__/plugin-types.test.ts +3 -0
  156. package/src/__tests__/provider-commit-message-generator.test.ts +19 -0
  157. package/src/__tests__/provider-connections-backfill.test.ts +13 -0
  158. package/src/__tests__/provider-platform-proxy-integration.test.ts +0 -3
  159. package/src/__tests__/provider-registry-ollama.test.ts +1 -6
  160. package/src/__tests__/provider-usage-tracking.test.ts +33 -0
  161. package/src/__tests__/prune-old-conversations-job.test.ts +5 -0
  162. package/src/__tests__/qdrant-manager.test.ts +19 -0
  163. package/src/__tests__/rebuild-index-graph-nodes.test.ts +7 -1
  164. package/src/__tests__/record-persisted-seq-lock-resilience.test.ts +95 -0
  165. package/src/__tests__/request-secret-standalone-channel-gate.test.ts +3 -3
  166. package/src/__tests__/runtime-events-sse-bilingual.test.ts +7 -3
  167. package/src/__tests__/runtime-events-sse-parity.test.ts +10 -10
  168. package/src/__tests__/runtime-events-sse-reconnect.test.ts +48 -20
  169. package/src/__tests__/runtime-events-sse.test.ts +14 -5
  170. package/src/__tests__/safe-parse-surface-data.test.ts +25 -0
  171. package/src/__tests__/scaffold-managed-skill-tool.test.ts +68 -0
  172. package/src/__tests__/schedule-routes.test.ts +2 -2
  173. package/src/__tests__/schedule-store.test.ts +3 -3
  174. package/src/__tests__/script-proxy-connect-tunnel.test.ts +71 -0
  175. package/src/__tests__/secret-ingress.test.ts +137 -0
  176. package/src/__tests__/secret-prompt-log-hygiene.test.ts +3 -3
  177. package/src/__tests__/secret-prompter-channel-fallback.test.ts +3 -3
  178. package/src/__tests__/secret-response-routing.test.ts +3 -3
  179. package/src/__tests__/secret-routes-platform-proxy.test.ts +6 -3
  180. package/src/__tests__/secret-routes-scrub.test.ts +276 -0
  181. package/src/__tests__/secret-scanner.test.ts +121 -1
  182. package/src/__tests__/send-endpoint-busy.test.ts +7 -7
  183. package/src/__tests__/slack-channels-routes.test.ts +16 -5
  184. package/src/__tests__/slack-inbound-verification.test.ts +45 -20
  185. package/src/__tests__/slack-messaging-token-resolution.test.ts +6 -0
  186. package/src/__tests__/slack-notification-approval-card.test.ts +103 -20
  187. package/src/__tests__/slack-share-routes.test.ts +22 -16
  188. package/src/__tests__/slack-users-routes.test.ts +12 -5
  189. package/src/__tests__/starter-task-flow.test.ts +6 -3
  190. package/src/__tests__/subagent-call-site-routing.test.ts +2 -2
  191. package/src/__tests__/subagent-disposal.test.ts +10 -10
  192. package/src/__tests__/subagent-fork-notifications.test.ts +4 -4
  193. package/src/__tests__/subagent-fork-prompt-role.test.ts +3 -3
  194. package/src/__tests__/subagent-fork-spawn.test.ts +4 -4
  195. package/src/__tests__/subagent-manager-notify.test.ts +10 -10
  196. package/src/__tests__/subagent-spawn-and-await.test.ts +31 -14
  197. package/src/__tests__/subagent-tool-gate-mode.test.ts +1 -5
  198. package/src/__tests__/surface-type-registry-guard.test.ts +66 -0
  199. package/src/__tests__/sync-message-contract.test.ts +3 -3
  200. package/src/__tests__/task-memory-cleanup.test.ts +13 -11
  201. package/src/__tests__/tool-approval-handler.test.ts +25 -1
  202. package/src/__tests__/tool-approval-seed-content-blocks.test.ts +179 -96
  203. package/src/__tests__/tool-preview-lifecycle.test.ts +135 -30
  204. package/src/__tests__/tool-result-metadata-plumbing.test.ts +5 -5
  205. package/src/__tests__/tool-start-timestamp.test.ts +4 -4
  206. package/src/__tests__/trusted-contact-multichannel.test.ts +0 -4
  207. package/src/__tests__/ui-choice-copy-surfaces.test.ts +178 -25
  208. package/src/__tests__/ui-work-result-surface.test.ts +7 -19
  209. package/src/__tests__/voice-config-update.test.ts +92 -1
  210. package/src/__tests__/voice-scoped-grant-consumer.test.ts +6 -6
  211. package/src/__tests__/voice-session-bridge.test.ts +44 -44
  212. package/src/__tests__/worker-entrypoint-guards.test.ts +2 -0
  213. package/src/__tests__/workspace-migration-132-web-search-mode-to-provider.test.ts +239 -0
  214. package/src/__tests__/workspace-migration-133-collapse-provider-connections.test.ts +449 -0
  215. package/src/__tests__/workspace-migration-134-image-generation-mode-to-provider.test.ts +284 -0
  216. package/src/acp/__tests__/client-handler.test.ts +3 -3
  217. package/src/acp/__tests__/prepare-agent-env.test.ts +2 -2
  218. package/src/acp/__tests__/session-manager-persistence.test.ts +21 -21
  219. package/src/acp/__tests__/session-manager-resume.test.ts +18 -14
  220. package/src/acp/agent-process.ts +1 -1
  221. package/src/acp/client-handler.ts +26 -12
  222. package/src/acp/prepare-agent-env.ts +6 -4
  223. package/src/acp/session-manager.ts +39 -22
  224. package/src/api/events/app-files-changed.ts +20 -0
  225. package/src/api/events/assistant-status.ts +20 -0
  226. package/src/api/events/bookmark-created.ts +37 -0
  227. package/src/api/events/bookmark-deleted.ts +20 -0
  228. package/src/api/events/client-settings-update.ts +25 -0
  229. package/src/api/events/config-changed.ts +19 -0
  230. package/src/api/events/confirmation-state-changed.ts +37 -0
  231. package/src/api/events/contacts-changed.ts +19 -0
  232. package/src/api/events/context-compacted.ts +38 -0
  233. package/src/api/events/conversation-inference-profile-updated.ts +26 -0
  234. package/src/api/events/document-editor-show.ts +26 -0
  235. package/src/api/events/heartbeat-alert.ts +20 -0
  236. package/src/api/events/heartbeat-conversation-created.ts +23 -0
  237. package/src/api/events/host-app-control.ts +146 -0
  238. package/src/api/events/host-bash.ts +40 -0
  239. package/src/api/events/host-browser.ts +43 -0
  240. package/src/api/events/host-cu.ts +37 -0
  241. package/src/api/events/host-file.ts +65 -0
  242. package/src/api/events/host-transfer.ts +59 -0
  243. package/src/api/events/host-ui-snapshot.ts +46 -0
  244. package/src/api/events/memory-recalled.ts +59 -0
  245. package/src/api/events/memory-status.ts +29 -0
  246. package/src/api/events/message-steered.ts +21 -0
  247. package/src/api/events/model-info.ts +39 -0
  248. package/src/api/events/notification-conversation-created.ts +51 -0
  249. package/src/api/events/oauth-connect-result.ts +26 -0
  250. package/src/api/events/platform-disconnected.ts +21 -0
  251. package/src/api/events/recording.ts +68 -0
  252. package/src/api/events/schedule-conversation-created.ts +24 -0
  253. package/src/api/events/service-group-update-complete.ts +29 -0
  254. package/src/api/events/service-group-update-progress.ts +23 -0
  255. package/src/api/events/service-group-update-starting.ts +26 -0
  256. package/src/api/events/show-platform-login.ts +20 -0
  257. package/src/api/events/skill-state-changed.ts +23 -0
  258. package/src/api/events/sounds-config-updated.ts +21 -0
  259. package/src/api/events/subagent-event.ts +2 -2
  260. package/src/api/events/tool-input-delta.ts +30 -0
  261. package/src/api/events/ui-surface-undo-result.ts +27 -0
  262. package/src/api/index.ts +356 -0
  263. package/src/api/surfaces.ts +565 -3
  264. package/src/approvals/guardian-card-withdrawal.ts +53 -8
  265. package/src/approvals/guardian-decision-primitive.ts +24 -1
  266. package/src/approvals/guardian-request-resolvers.ts +38 -6
  267. package/src/background-wake/platform-client.test.ts +20 -0
  268. package/src/background-wake/platform-client.ts +17 -0
  269. package/src/calls/__tests__/voice-control-protocol.test.ts +20 -19
  270. package/src/calls/__tests__/voice-session-bridge.test.ts +441 -7
  271. package/src/calls/__tests__/voice-triage-escalate.test.ts +271 -63
  272. package/src/calls/call-controller.ts +27 -27
  273. package/src/calls/call-domain.ts +1 -1
  274. package/src/calls/call-setup-flow.ts +22 -5
  275. package/src/calls/fish-audio-client.ts +1 -1
  276. package/src/calls/voice-control-protocol.ts +17 -9
  277. package/src/calls/voice-session-bridge.ts +361 -24
  278. package/src/calls/voice-triage-escalate.ts +240 -75
  279. package/src/channels/slack-callback-url.ts +54 -0
  280. package/src/channels/types.ts +10 -7
  281. package/src/cli/commands/__tests__/credentials.test.ts +216 -0
  282. package/src/cli/commands/__tests__/keys.test.ts +189 -0
  283. package/src/cli/commands/__tests__/tts.test.ts +121 -1
  284. package/src/cli/commands/config.help.ts +6 -2
  285. package/src/cli/commands/config.ts +40 -4
  286. package/src/cli/commands/contacts.ts +1 -9
  287. package/src/cli/commands/credentials.help.ts +14 -1
  288. package/src/cli/commands/credentials.ts +12 -13
  289. package/src/cli/commands/db/__tests__/repair.test.ts +5 -2
  290. package/src/cli/commands/keys.help.ts +16 -1
  291. package/src/cli/commands/keys.ts +37 -12
  292. package/src/cli/commands/memory/index.help.ts +21 -8
  293. package/src/cli/commands/memory/memory-v2.ts +1 -1
  294. package/src/cli/commands/memory/memory-v3.ts +2 -2
  295. package/src/cli/commands/memory/nodes.ts +29 -4
  296. package/src/cli/commands/oauth/connect.ts +1 -1
  297. package/src/cli/commands/plugins.help.ts +6 -2
  298. package/src/cli/commands/plugins.ts +33 -18
  299. package/src/cli/commands/routes-worker.ts +102 -0
  300. package/src/cli/commands/routes.help.ts +49 -0
  301. package/src/cli/commands/routes.ts +6 -1
  302. package/src/cli/commands/tts.help.ts +33 -0
  303. package/src/cli/commands/tts.ts +80 -0
  304. package/src/cli/lib/__tests__/install-from-github.test.ts +106 -8
  305. package/src/cli/lib/__tests__/parse-github-plugin-spec.test.ts +60 -0
  306. package/src/cli/lib/__tests__/upgrade-plugin.test.ts +151 -6
  307. package/src/cli/lib/bundled-marketplace.json +25 -0
  308. package/src/cli/lib/install-from-github.ts +118 -10
  309. package/src/cli/lib/parse-github-plugin-spec.ts +73 -7
  310. package/src/cli/lib/upgrade-plugin.ts +76 -13
  311. package/src/cli/output.ts +9 -0
  312. package/src/cli/utils/inline-secret-guard.ts +35 -0
  313. package/src/cli.ts +2 -109
  314. package/src/config/__tests__/default-profile-catalog.test.ts +68 -9
  315. package/src/config/__tests__/deployment-context-defaults.test.ts +14 -2
  316. package/src/config/__tests__/profile-materialization.test.ts +11 -0
  317. package/src/config/__tests__/sync-gated-profiles.test.ts +3 -3
  318. package/src/config/bundled-skills/_shared/CLI_RETRIEVAL_PATTERN.md +1 -1
  319. package/src/config/bundled-skills/app-builder/references/CUSTOM_ROUTES.md +11 -2
  320. package/src/config/bundled-skills/image-studio/tools/media-generate-image.ts +13 -7
  321. package/src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts +3 -2
  322. package/src/config/bundled-skills/playbooks/tools/playbook-create.ts +5 -2
  323. package/src/config/bundled-skills/playbooks/tools/playbook-list.ts +5 -2
  324. package/src/config/bundled-skills/playbooks/tools/playbook-update.ts +5 -2
  325. package/src/config/bundled-skills/settings/TOOLS.json +3 -3
  326. package/src/config/bundled-skills/settings/tools/voice-config-update.ts +42 -14
  327. package/src/config/bundled-skills/skill-management/SKILL.md +5 -0
  328. package/src/config/bundled-skills/skill-management/TOOLS.json +8 -4
  329. package/src/config/call-site-defaults.ts +18 -8
  330. package/src/config/default-profile-catalog.ts +168 -81
  331. package/src/config/default-profile-names.ts +27 -0
  332. package/src/config/feature-flag-registry.json +26 -24
  333. package/src/config/llm-context-resolution.ts +11 -2
  334. package/src/config/llm-resolver.ts +32 -5
  335. package/src/config/loader.ts +12 -5
  336. package/src/config/managed-speech-defaults.ts +74 -30
  337. package/src/config/memory-v3-gate.test.ts +40 -0
  338. package/src/config/memory-v3-gate.ts +54 -0
  339. package/src/config/profile-materialization.ts +23 -2
  340. package/src/config/raw-config-utils.ts +1 -1
  341. package/src/config/schema.ts +6 -0
  342. package/src/config/schemas/__tests__/live-voice.test.ts +54 -0
  343. package/src/config/schemas/__tests__/user-routes.test.ts +23 -0
  344. package/src/config/schemas/api-rate-limit.ts +31 -0
  345. package/src/config/schemas/call-site-catalog.ts +7 -0
  346. package/src/config/schemas/live-voice.ts +73 -1
  347. package/src/config/schemas/llm.ts +92 -1
  348. package/src/config/schemas/memory-retrospective.ts +13 -0
  349. package/src/config/schemas/security.ts +8 -0
  350. package/src/config/schemas/services.ts +19 -7
  351. package/src/config/schemas/user-routes.ts +27 -0
  352. package/src/config/seed-inference-profiles.ts +6 -4
  353. package/src/config/types.ts +1 -0
  354. package/src/contacts/member-status.ts +21 -1
  355. package/src/context/estimator-calibration.ts +9 -2
  356. package/src/conversations/job-handlers/summarization.ts +3 -0
  357. package/src/credential-execution/prompted-credential.ts +24 -0
  358. package/src/daemon/__tests__/channel-ui-capability.test.ts +26 -0
  359. package/src/daemon/__tests__/conversation-surfaces-launch.test.ts +5 -9
  360. package/src/daemon/__tests__/embedding-reconcile.test.ts +2 -2
  361. package/src/daemon/__tests__/native-web-search-metadata.test.ts +5 -5
  362. package/src/daemon/__tests__/wake-conversation-ops-completion.test.ts +32 -2
  363. package/src/daemon/__tests__/web-search-status-text.test.ts +2 -2
  364. package/src/daemon/channel-ui-capability.ts +38 -8
  365. package/src/daemon/chat-credential-redaction.ts +36 -13
  366. package/src/daemon/config-watcher.ts +75 -79
  367. package/src/daemon/conversation-agent-loop-handlers.ts +107 -30
  368. package/src/daemon/conversation-agent-loop.ts +31 -39
  369. package/src/daemon/conversation-error.ts +2 -0
  370. package/src/daemon/conversation-lifecycle.ts +7 -24
  371. package/src/daemon/conversation-messaging.ts +25 -14
  372. package/src/daemon/conversation-notifiers.ts +2 -2
  373. package/src/daemon/conversation-process.ts +8 -6
  374. package/src/daemon/conversation-queue-manager.ts +7 -7
  375. package/src/daemon/conversation-registry.ts +14 -2
  376. package/src/daemon/conversation-runtime-assembly.ts +15 -10
  377. package/src/daemon/conversation-store.ts +14 -2
  378. package/src/daemon/conversation-surface-state.ts +212 -0
  379. package/src/daemon/conversation-surfaces.ts +238 -291
  380. package/src/daemon/conversation-tool-setup.ts +34 -15
  381. package/src/daemon/conversation-usage.ts +24 -14
  382. package/src/daemon/conversation.ts +18 -61
  383. package/src/daemon/credential-transcript-scrub.ts +482 -0
  384. package/src/daemon/doordash-steps.ts +50 -20
  385. package/src/daemon/embedding-reconcile.ts +4 -4
  386. package/src/daemon/external-plugins-bootstrap.ts +17 -0
  387. package/src/daemon/handlers/config-channels.ts +40 -134
  388. package/src/daemon/handlers/config-model.test.ts +2 -0
  389. package/src/daemon/handlers/config-model.ts +15 -7
  390. package/src/daemon/handlers/shared.ts +11 -1
  391. package/src/daemon/host-browser-proxy.ts +20 -13
  392. package/src/daemon/host-file-proxy.ts +5 -3
  393. package/src/daemon/host-proxy-base.ts +4 -4
  394. package/src/daemon/inflight-turn-registry.ts +65 -0
  395. package/src/daemon/lifecycle.ts +13 -0
  396. package/src/daemon/message-protocol.ts +17 -190
  397. package/src/daemon/message-types/computer-use.ts +8 -50
  398. package/src/daemon/message-types/conversations.ts +9 -462
  399. package/src/daemon/message-types/diagnostics.ts +1 -23
  400. package/src/daemon/message-types/host-app-control.ts +11 -133
  401. package/src/daemon/message-types/host-browser.ts +5 -27
  402. package/src/daemon/message-types/host-ui-snapshot.ts +6 -31
  403. package/src/daemon/message-types/messages.ts +1 -114
  404. package/src/daemon/message-types/notifications.ts +0 -38
  405. package/src/daemon/message-types/skills.ts +6 -151
  406. package/src/daemon/message-types/surfaces.ts +131 -395
  407. package/src/daemon/message-types/sync.ts +0 -2
  408. package/src/daemon/process-message.ts +5 -5
  409. package/src/daemon/shutdown-handlers.ts +5 -0
  410. package/src/daemon/skill-memory-refresh.ts +1 -1
  411. package/src/daemon/tool-setup-types.ts +12 -0
  412. package/src/daemon/tool-side-effects.ts +26 -13
  413. package/src/daemon/trust-context-types.ts +8 -0
  414. package/src/daemon/trust-context.ts +1 -1
  415. package/src/daemon/wake-conversation-ops.ts +21 -4
  416. package/src/embedded/plugin-api.ts +3 -1
  417. package/src/heartbeat/heartbeat-service.ts +45 -17
  418. package/src/home/conversation-starter-checkpoints.ts +2 -2
  419. package/src/home/job-handlers/conversation-starters.ts +15 -11
  420. package/src/hooks/registry.ts +3 -3
  421. package/src/hooks/types.ts +12 -0
  422. package/src/ipc/assistant-server.ts +5 -2
  423. package/src/ipc/routes/__tests__/conversation-sync-ipc-routes.test.ts +87 -5
  424. package/src/ipc/routes/__tests__/events-ipc-routes.test.ts +74 -0
  425. package/src/ipc/routes/__tests__/memory-v2-backfill.test.ts +1 -1
  426. package/src/ipc/routes/conversation-sync-ipc-routes.ts +16 -8
  427. package/src/ipc/routes/events-ipc-routes.ts +80 -0
  428. package/src/live-voice/__tests__/front-decision.test.ts +405 -76
  429. package/src/live-voice/__tests__/live-voice-connection.test.ts +271 -0
  430. package/src/live-voice/__tests__/live-voice-events.test.ts +7 -2
  431. package/src/live-voice/__tests__/live-voice-managed-speech-fallback.test.ts +245 -0
  432. package/src/live-voice/__tests__/live-voice-metrics.test.ts +29 -1
  433. package/src/live-voice/__tests__/live-voice-progress.test.ts +757 -0
  434. package/src/live-voice/__tests__/live-voice-triage-escalate.test.ts +76 -48
  435. package/src/live-voice/__tests__/live-voice-tts-session.test.ts +8 -8
  436. package/src/live-voice/__tests__/live-voice-tts.test.ts +1 -0
  437. package/src/live-voice/__tests__/live-voice-vad.test.ts +360 -2
  438. package/src/live-voice/__tests__/runtime-websocket-shell.test.ts +1 -0
  439. package/src/live-voice/ack-phrases.ts +23 -5
  440. package/src/live-voice/front-decision.ts +222 -44
  441. package/src/live-voice/live-voice-connection.ts +225 -0
  442. package/src/live-voice/live-voice-credential-preflight.ts +39 -28
  443. package/src/live-voice/live-voice-manager.ts +53 -0
  444. package/src/live-voice/live-voice-metrics.ts +65 -7
  445. package/src/live-voice/live-voice-session-manager.ts +1 -0
  446. package/src/live-voice/live-voice-session.ts +1033 -121
  447. package/src/live-voice/live-voice-tts.ts +8 -1
  448. package/src/live-voice/protocol.ts +6 -0
  449. package/src/mcp/__tests__/mcp-oauth-provider.test.ts +75 -0
  450. package/src/mcp/mcp-oauth-provider.ts +59 -1
  451. package/src/media/app-icon-generator.ts +15 -8
  452. package/src/media/avatar-router.ts +9 -5
  453. package/src/media/image-credentials.ts +42 -10
  454. package/src/media/image-service.ts +1 -13
  455. package/src/media/types.ts +26 -3
  456. package/src/messaging/channel-binding-schema.ts +6 -2
  457. package/src/messaging/providers/slack/__tests__/adapter-token-routing.test.ts +4 -0
  458. package/src/messaging/providers/slack/__tests__/auth.test.ts +74 -0
  459. package/src/messaging/providers/slack/adapter.ts +17 -23
  460. package/src/messaging/providers/slack/approval-source.ts +87 -0
  461. package/src/messaging/providers/slack/auth.ts +78 -0
  462. package/src/messaging/providers/slack/deep-link.ts +45 -8
  463. package/src/messaging/providers/slack/message-metadata.ts +16 -0
  464. package/src/messaging/providers/slack/withdraw.test.ts +71 -0
  465. package/src/messaging/providers/slack/withdraw.ts +53 -5
  466. package/src/messaging/providers/telegram-bot/send.test.ts +88 -0
  467. package/src/messaging/providers/telegram-bot/send.ts +43 -3
  468. package/src/messaging/providers/telegram-bot/transport.ts +26 -8
  469. package/src/monitoring/recovery/__tests__/orphaned-channel-events.test.ts +144 -0
  470. package/src/monitoring/recovery/orphaned-channel-events.ts +72 -0
  471. package/src/monitoring/recovery/run-recovery.ts +2 -0
  472. package/src/notifications/AGENTS.md +2 -0
  473. package/src/notifications/access-request-copy.ts +10 -21
  474. package/src/notifications/adapters/macos.ts +3 -3
  475. package/src/notifications/adapters/slack.ts +73 -13
  476. package/src/notifications/approval-card-data.ts +58 -16
  477. package/src/notifications/broadcaster.ts +41 -19
  478. package/src/notifications/guardian-question-mode.ts +81 -0
  479. package/src/notifications/types.ts +5 -0
  480. package/src/oauth/AGENTS.md +1 -1
  481. package/src/outbound-proxy/connect-tunnel.ts +19 -0
  482. package/src/permissions/checker.test.ts +7 -0
  483. package/src/permissions/checker.ts +18 -21
  484. package/src/permissions/confirmation-guardian-request.test.ts +2 -2
  485. package/src/permissions/confirmation-guardian-request.ts +19 -3
  486. package/src/permissions/prompter.ts +8 -5
  487. package/src/permissions/question-prompter.test.ts +8 -8
  488. package/src/permissions/secret-prompter.ts +2 -2
  489. package/src/persistence/__tests__/conversation-queries-search.test.ts +40 -0
  490. package/src/persistence/conversation-bootstrap.ts +11 -0
  491. package/src/persistence/conversation-crud.ts +152 -45
  492. package/src/persistence/conversation-queries.ts +29 -9
  493. package/src/persistence/conversation-title-service.ts +39 -2
  494. package/src/persistence/db-connection.ts +34 -5
  495. package/src/persistence/delivery-crud.ts +88 -5
  496. package/src/persistence/delivery-status.ts +60 -2
  497. package/src/persistence/embeddings/__tests__/messages-lexical-index.test.ts +45 -0
  498. package/src/persistence/embeddings/graph-node-orphan-sweep.ts +9 -3
  499. package/src/persistence/embeddings/messages-lexical-index.ts +73 -0
  500. package/src/persistence/embeddings/qdrant-manager.ts +67 -21
  501. package/src/persistence/external-conversation-store.ts +22 -0
  502. package/src/persistence/job-handlers/cleanup.ts +14 -2
  503. package/src/persistence/jobs-store.ts +4 -0
  504. package/src/persistence/llm-usage-store.ts +69 -2
  505. package/src/persistence/message-content-file.ts +25 -15
  506. package/src/persistence/migrations/340-sweep-orphaned-graph-node-vectors.test.ts +16 -0
  507. package/src/persistence/migrations/341-sweep-cacheless-graph-node-vectors.test.ts +5 -8
  508. package/src/persistence/migrations/342-add-conversation-parent-id.test.ts +141 -0
  509. package/src/persistence/migrations/342-add-conversation-parent-id.ts +46 -0
  510. package/src/persistence/migrations/343-move-activation-state-to-memory-db.ts +74 -0
  511. package/src/persistence/migrations/344-move-conversation-graph-memory-state-to-memory-db.ts +66 -0
  512. package/src/persistence/migrations/345-move-memory-v3-ever-injected-to-memory-db.ts +62 -0
  513. package/src/persistence/migrations/346-move-memory-retrospective-state-to-memory-db.ts +67 -0
  514. package/src/persistence/migrations/347-delete-stray-greeting-conversation.ts +46 -0
  515. package/src/persistence/migrations/348-memory-summaries-scope-updated-index.ts +25 -0
  516. package/src/persistence/migrations/349-move-memory-graph-tables-to-memory-db.ts +227 -0
  517. package/src/persistence/migrations/350-conversations-total-input-tokens-nullable.ts +77 -0
  518. package/src/persistence/migrations/__tests__/347-delete-stray-greeting-conversation.test.ts +100 -0
  519. package/src/persistence/migrations/__tests__/350-conversations-total-input-tokens-nullable.test.ts +75 -0
  520. package/src/persistence/raw-query.ts +14 -0
  521. package/src/persistence/real-user-turn-filter.ts +26 -0
  522. package/src/persistence/schema/bookmarks.ts +1 -2
  523. package/src/persistence/schema/conversations.ts +20 -4
  524. package/src/persistence/schema/memory-core.ts +3 -0
  525. package/src/persistence/schema/memory-graph.ts +3 -0
  526. package/src/persistence/schema/memory-injection.ts +3 -1
  527. package/src/persistence/steps.ts +76 -0
  528. package/src/playbooks/playbook-compiler.ts +5 -2
  529. package/src/plugin-api/__tests__/publish-event.test.ts +54 -0
  530. package/src/plugin-api/app-globals.d.ts +84 -0
  531. package/src/plugin-api/constants.ts +2 -0
  532. package/src/plugin-api/conversation-turn.ts +4 -4
  533. package/src/plugin-api/event-hub-facade.ts +6 -4
  534. package/src/plugin-api/index.ts +55 -1
  535. package/src/plugin-api/publish-event.ts +39 -0
  536. package/src/plugin-api/transcription-session.test.ts +54 -0
  537. package/src/plugin-api/transcription-session.ts +39 -0
  538. package/src/plugin-api/types.ts +2 -0
  539. package/src/plugin-api/vision-support.test.ts +12 -0
  540. package/src/plugin-api/vision-support.ts +7 -1
  541. package/src/plugins/AGENTS.md +1 -2
  542. package/src/plugins/defaults/image-fallback/src/vision-caption.ts +1 -0
  543. package/src/plugins/defaults/index.ts +2 -0
  544. package/src/plugins/defaults/main.ts +64 -14
  545. package/src/plugins/defaults/memory/__tests__/conversation-memory-orphan-sweep.test.ts +91 -0
  546. package/src/plugins/defaults/memory/__tests__/conversation-memory-purge.test.ts +123 -0
  547. package/src/plugins/defaults/memory/__tests__/db-memory-attach.test.ts +14 -3
  548. package/src/plugins/defaults/memory/__tests__/jobs-worker-retrospective-sweep.test.ts +135 -0
  549. package/src/plugins/defaults/memory/__tests__/jobs-worker-v2-schedule.test.ts +72 -2
  550. package/src/plugins/defaults/memory/__tests__/memory-log-stores-degraded.test.ts +19 -39
  551. package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +13 -0
  552. package/src/plugins/defaults/memory/__tests__/memory-retrospective-state.test.ts +55 -40
  553. package/src/plugins/defaults/memory/__tests__/memory-retrospective-sweep.test.ts +251 -0
  554. package/src/plugins/defaults/memory/__tests__/memory-retrospective-trigger-check.test.ts +6 -2
  555. package/src/plugins/defaults/memory/__tests__/memory-v2-concept-frequency.test.ts +1 -1
  556. package/src/plugins/defaults/memory/__tests__/relocated-memory-test-rows.ts +103 -0
  557. package/src/plugins/defaults/memory/__tests__/table-relocation.test.ts +439 -0
  558. package/src/plugins/defaults/memory/__tests__/tools-delete-memory-page.test.ts +1 -1
  559. package/src/plugins/defaults/memory/context-search/agent-runner.ts +2 -0
  560. package/src/plugins/defaults/memory/context-search/sources/memory-v2.ts +5 -5
  561. package/src/plugins/defaults/memory/context-search/sources/memory.ts +2 -1
  562. package/src/plugins/defaults/memory/conversation-memory-orphan-sweep.ts +130 -0
  563. package/src/plugins/defaults/memory/conversation-memory-purge.ts +76 -0
  564. package/src/plugins/defaults/memory/fork-conversation-memory.ts +16 -14
  565. package/src/plugins/defaults/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +31 -9
  566. package/src/plugins/defaults/memory/graph/__tests__/handle-remember-v2.test.ts +23 -39
  567. package/src/plugins/defaults/memory/graph/bootstrap.test.ts +22 -0
  568. package/src/plugins/defaults/memory/graph/bootstrap.ts +7 -3
  569. package/src/plugins/defaults/memory/graph/capability-seed.ts +14 -10
  570. package/src/plugins/defaults/memory/graph/consolidation.ts +11 -3
  571. package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +32 -32
  572. package/src/plugins/defaults/memory/graph/decay.ts +3 -2
  573. package/src/plugins/defaults/memory/graph/extraction.ts +8 -0
  574. package/src/plugins/defaults/memory/graph/graph-memory-state-store.ts +13 -8
  575. package/src/plugins/defaults/memory/graph/graph-search.ts +9 -7
  576. package/src/plugins/defaults/memory/graph/retriever.test.ts +7 -11
  577. package/src/plugins/defaults/memory/graph/retriever.ts +25 -5
  578. package/src/plugins/defaults/memory/graph/store.test.ts +4 -6
  579. package/src/plugins/defaults/memory/graph/store.ts +43 -22
  580. package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +28 -5
  581. package/src/plugins/defaults/memory/graph/tool-handlers.ts +46 -65
  582. package/src/plugins/defaults/memory/graph/tools.ts +13 -14
  583. package/src/plugins/defaults/memory/graph/types.test.ts +91 -0
  584. package/src/plugins/defaults/memory/graph/types.ts +47 -0
  585. package/src/plugins/defaults/memory/graph-topology/__tests__/build-memory-graph.test.ts +1 -1
  586. package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +48 -40
  587. package/src/plugins/defaults/memory/graph-topology/pending-buffer.test.ts +181 -0
  588. package/src/plugins/defaults/memory/graph-topology/pending-buffer.ts +235 -0
  589. package/src/plugins/defaults/memory/hooks/conversation-deleted.ts +18 -9
  590. package/src/plugins/defaults/memory/hooks/conversations-cleared.ts +25 -0
  591. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +2 -2
  592. package/src/plugins/defaults/memory/indexer.ts +22 -21
  593. package/src/plugins/defaults/memory/injectors.ts +15 -10
  594. package/src/plugins/defaults/memory/job-handler-registration.ts +5 -5
  595. package/src/plugins/defaults/memory/job-handlers/index-maintenance.ts +24 -17
  596. package/src/plugins/defaults/memory/job-handlers.ts +11 -5
  597. package/src/plugins/defaults/memory/jobs/__tests__/embed-concept-page.test.ts +2 -2
  598. package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +3 -3
  599. package/src/plugins/defaults/memory/jobs/embed-pkb-file.ts +7 -6
  600. package/src/plugins/defaults/memory/jobs-worker.ts +155 -46
  601. package/src/plugins/defaults/memory/memory-db.ts +18 -1
  602. package/src/plugins/defaults/memory/memory-retrospective-enqueue.ts +14 -6
  603. package/src/plugins/defaults/memory/memory-retrospective-prompt.ts +4 -2
  604. package/src/plugins/defaults/memory/memory-retrospective-state.ts +93 -50
  605. package/src/plugins/defaults/memory/memory-retrospective-sweep.ts +234 -0
  606. package/src/plugins/defaults/memory/memory-v2-concept-frequency.ts +1 -1
  607. package/src/plugins/defaults/memory/pkb/pkb-search.ts +5 -4
  608. package/src/plugins/defaults/memory/search/semantic.ts +6 -4
  609. package/src/plugins/defaults/memory/{routes → src}/__tests__/memory-v2-routes.test.ts +2 -2
  610. package/src/plugins/defaults/memory/{routes → src}/__tests__/memory-v2-simulate-route.test.ts +4 -3
  611. package/src/plugins/defaults/memory/{routes → src}/memory-item-routes.test.ts +195 -9
  612. package/src/plugins/defaults/memory/{routes → src}/memory-item-routes.ts +136 -20
  613. package/src/plugins/defaults/memory/{routes → src}/memory-v2-routes.ts +20 -18
  614. package/src/plugins/defaults/memory/{routes → src}/memory-v3-routes.ts +3 -2
  615. package/src/plugins/defaults/memory/startup.ts +16 -14
  616. package/src/plugins/defaults/memory/task-memory-cleanup.ts +94 -25
  617. package/src/plugins/defaults/memory/tools.test.ts +29 -55
  618. package/src/plugins/defaults/memory/tools.ts +9 -8
  619. package/src/plugins/defaults/memory/v2/__tests__/activation-store.test.ts +89 -21
  620. package/src/plugins/defaults/memory/v2/__tests__/activation.test.ts +4 -3
  621. package/src/plugins/defaults/memory/v2/__tests__/backfill-jobs.test.ts +8 -7
  622. package/src/plugins/defaults/memory/v2/__tests__/injection.test.ts +36 -97
  623. package/src/plugins/defaults/memory/v2/__tests__/reranker.test.ts +2 -2
  624. package/src/plugins/defaults/memory/v2/__tests__/router.test.ts +4 -3
  625. package/src/plugins/defaults/memory/v2/activation-store.ts +48 -27
  626. package/src/plugins/defaults/memory/v2/activation.ts +8 -5
  627. package/src/plugins/defaults/memory/v2/backfill-jobs.ts +16 -7
  628. package/src/plugins/defaults/memory/v2/harness/replay-input.ts +1 -1
  629. package/src/plugins/defaults/memory/v2/harness/retriever.ts +1 -1
  630. package/src/plugins/defaults/memory/v2/injection.ts +18 -24
  631. package/src/plugins/defaults/memory/v2/migration.ts +9 -7
  632. package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
  633. package/src/plugins/defaults/memory/v2/router.ts +10 -4
  634. package/src/plugins/defaults/memory/v3/__tests__/candidate-match.test.ts +2 -2
  635. package/src/plugins/defaults/memory/v3/__tests__/capabilities.test.ts +42 -15
  636. package/src/plugins/defaults/memory/v3/__tests__/carry-integration.test.ts +11 -7
  637. package/src/plugins/defaults/memory/v3/__tests__/edge.test.ts +1 -1
  638. package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +29 -2
  639. package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +16 -3
  640. package/src/plugins/defaults/memory/v3/__tests__/maintain-job.test.ts +10 -3
  641. package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +1 -1
  642. package/src/plugins/defaults/memory/v3/__tests__/shadow-integration.test.ts +1 -1
  643. package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +96 -18
  644. package/src/plugins/defaults/memory/v3/candidate-match.ts +2 -2
  645. package/src/plugins/defaults/memory/v3/capabilities.ts +69 -25
  646. package/src/plugins/defaults/memory/v3/card.ts +1 -1
  647. package/src/plugins/defaults/memory/v3/edge.ts +1 -1
  648. package/src/plugins/defaults/memory/v3/ever-injected-store.test.ts +74 -24
  649. package/src/plugins/defaults/memory/v3/ever-injected-store.ts +214 -115
  650. package/src/plugins/defaults/memory/v3/injector.ts +4 -0
  651. package/src/plugins/defaults/memory/v3/lanes-version-store.test.ts +62 -0
  652. package/src/plugins/defaults/memory/v3/lanes-version-store.ts +91 -0
  653. package/src/plugins/defaults/memory/v3/maintain-job.ts +3 -3
  654. package/src/plugins/defaults/memory/v3/page-content.ts +5 -5
  655. package/src/plugins/defaults/memory/v3/pool-select.ts +1 -0
  656. package/src/plugins/defaults/memory/v3/prune.test.ts +4 -2
  657. package/src/plugins/defaults/memory/v3/prune.ts +4 -4
  658. package/src/plugins/defaults/memory/v3/selection-log-store.ts +1 -1
  659. package/src/plugins/defaults/memory/v3/shadow-plugin.ts +90 -25
  660. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/cli-command-store.test.ts +4 -4
  661. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/consolidation-job.test.ts +33 -6
  662. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/consolidation-prompt-flag-gating-guard.test.ts +8 -0
  663. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/frontmatter-sweep.test.ts +2 -2
  664. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/memory-v2-startup.test.ts +4 -4
  665. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/page-index.test.ts +35 -0
  666. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/page-store.test.ts +38 -0
  667. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/prompts-consolidation.test.ts +135 -2
  668. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/qdrant.test.ts +8 -5
  669. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/sim.test.ts +11 -8
  670. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/skill-content.test.ts +1 -1
  671. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/skill-store.test.ts +8 -8
  672. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/sparse-bm25.test.ts +1 -1
  673. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/static-context.test.ts +3 -3
  674. package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/sweep-job.test.ts +7 -5
  675. package/src/plugins/defaults/memory/{v2 → v3/substrate}/cli-command-content.ts +24 -1
  676. package/src/plugins/defaults/memory/{v2 → v3/substrate}/cli-command-store.ts +5 -5
  677. package/src/plugins/defaults/memory/{v2 → v3/substrate}/consolidation-job.ts +30 -12
  678. package/src/plugins/defaults/memory/{v2 → v3/substrate}/frontmatter-sweep.ts +7 -6
  679. package/src/plugins/defaults/memory/{v2 → v3/substrate}/memory-v2-startup.test.ts +11 -4
  680. package/src/plugins/defaults/memory/{v2 → v3/substrate}/memory-v2-startup.ts +14 -13
  681. package/src/plugins/defaults/memory/{v2 → v3/substrate}/page-index.ts +46 -3
  682. package/src/plugins/defaults/memory/{v2 → v3/substrate}/page-store.ts +25 -3
  683. package/src/plugins/defaults/memory/{v2 → v3/substrate}/prompts/consolidation.ts +118 -22
  684. package/src/plugins/defaults/memory/{v2 → v3/substrate}/qdrant.ts +5 -5
  685. package/src/plugins/defaults/memory/{v2 → v3/substrate}/sim.ts +5 -5
  686. package/src/plugins/defaults/memory/{v2 → v3/substrate}/skill-content.ts +1 -1
  687. package/src/plugins/defaults/memory/{v2 → v3/substrate}/skill-store.ts +5 -5
  688. package/src/plugins/defaults/memory/{v2 → v3/substrate}/sparse-bm25.ts +2 -2
  689. package/src/plugins/defaults/memory/{v2 → v3/substrate}/static-context.ts +9 -8
  690. package/src/plugins/defaults/memory/{v2 → v3/substrate}/sweep-job.ts +15 -14
  691. package/src/plugins/defaults/memory/{v2 → v3/substrate}/types.ts +4 -0
  692. package/src/plugins/defaults/memory/v3-eval/eval-packets.ts +2 -2
  693. package/src/plugins/defaults/platform-hosted/__tests__/reengage.test.ts +109 -12
  694. package/src/plugins/defaults/platform-hosted/routes/reengage.ts +110 -12
  695. package/src/plugins/ensure-plugin-api-shim.ts +31 -2
  696. package/src/plugins/external-plugin-loader.ts +73 -3
  697. package/src/plugins/mtime-cache.ts +168 -140
  698. package/src/plugins/types.ts +23 -2
  699. package/src/prompts/templates/system-sections.ts +5 -1
  700. package/src/providers/__tests__/dispatch-connection-routing.test.ts +182 -2
  701. package/src/providers/__tests__/preflight-resolved-config.test.ts +88 -0
  702. package/src/providers/__tests__/registry-native-web-search.test.ts +0 -2
  703. package/src/providers/__tests__/retry-callsite.test.ts +25 -0
  704. package/src/providers/__tests__/satellite-connection-routing.test.ts +1 -1
  705. package/src/providers/__tests__/search-provider-catalog.test.ts +6 -0
  706. package/src/providers/anthropic/client.ts +11 -9
  707. package/src/providers/call-site-routing.ts +29 -0
  708. package/src/providers/connection-resolution.ts +36 -37
  709. package/src/providers/inference/__tests__/connections-credential-normalize.test.ts +87 -0
  710. package/src/providers/inference/__tests__/credential-slot-repair.test.ts +138 -0
  711. package/src/providers/inference/auth.ts +20 -0
  712. package/src/providers/inference/backfill.ts +12 -1
  713. package/src/providers/inference/connections.ts +30 -14
  714. package/src/providers/inference/credential-slot-repair.ts +110 -0
  715. package/src/providers/model-catalog.ts +81 -0
  716. package/src/providers/openai/__tests__/chat-completions-provider-reasoning.test.ts +39 -0
  717. package/src/providers/openai/chat-completions-provider.ts +7 -1
  718. package/src/providers/openai/responses-provider.ts +13 -4
  719. package/src/providers/provider-send-message.ts +12 -1
  720. package/src/providers/registry.ts +19 -5
  721. package/src/providers/retry.ts +5 -3
  722. package/src/providers/routing-identity.ts +99 -0
  723. package/src/providers/search-provider-catalog.ts +14 -4
  724. package/src/providers/speech-to-text/resolve.ts +25 -23
  725. package/src/providers/types.ts +7 -0
  726. package/src/providers/usage-tracking.ts +1 -1
  727. package/src/routes/__tests__/control.test.ts +100 -0
  728. package/src/routes/__tests__/route-host.test.ts +203 -0
  729. package/src/routes/control.ts +127 -0
  730. package/src/routes/route-host-client.ts +289 -0
  731. package/src/routes/route-host-protocol.ts +46 -0
  732. package/src/routes/worker.ts +235 -0
  733. package/src/runtime/AGENTS.md +9 -1
  734. package/src/runtime/access-request-helper.ts +71 -58
  735. package/src/runtime/agent-wake.ts +15 -31
  736. package/src/runtime/approval-source-link.ts +107 -0
  737. package/src/runtime/assistant-event-hub.ts +18 -18
  738. package/src/runtime/assistant-event.ts +23 -11
  739. package/src/runtime/assistant-stream-state.ts +4 -4
  740. package/src/runtime/channel-approval-types.ts +22 -0
  741. package/src/runtime/channel-approvals.ts +0 -25
  742. package/src/runtime/channel-retry-sweep.ts +200 -22
  743. package/src/runtime/confirmation-request-guardian-bridge.ts +9 -0
  744. package/src/runtime/guardian-action-service.ts +14 -1
  745. package/src/runtime/http-server.ts +35 -182
  746. package/src/runtime/http-types.ts +2 -2
  747. package/src/runtime/introduction-policy.test.ts +8 -0
  748. package/src/runtime/introduction-policy.ts +37 -56
  749. package/src/runtime/middleware/__tests__/rate-limiter.test.ts +53 -1
  750. package/src/runtime/middleware/rate-limiter.ts +53 -9
  751. package/src/runtime/routes/__tests__/browser-tabs-routes.test.ts +35 -0
  752. package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +28 -0
  753. package/src/runtime/routes/__tests__/default-plugin-routes.test.ts +115 -23
  754. package/src/runtime/routes/__tests__/defer-routes.test.ts +39 -0
  755. package/src/runtime/routes/__tests__/events-routes.test.ts +40 -0
  756. package/src/runtime/routes/__tests__/global-search-routes.test.ts +170 -0
  757. package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +67 -3
  758. package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +160 -0
  759. package/src/runtime/routes/__tests__/mcp-auth-routes.test.ts +69 -0
  760. package/src/runtime/routes/__tests__/route-host-worker-routes.test.ts +121 -0
  761. package/src/runtime/routes/__tests__/route-tags-guard.test.ts +26 -0
  762. package/src/runtime/routes/__tests__/sequence-routes.test.ts +56 -0
  763. package/src/runtime/routes/__tests__/suggest-trust-rule-routes.test.ts +29 -0
  764. package/src/runtime/routes/__tests__/ui-request-routes.test.ts +37 -0
  765. package/src/runtime/routes/__tests__/user-route-dispatcher-host.test.ts +210 -0
  766. package/src/runtime/routes/__tests__/user-route-dispatcher.test.ts +17 -13
  767. package/src/runtime/routes/__tests__/user-routes-cli.test.ts +43 -0
  768. package/src/runtime/routes/__tests__/watcher-routes.test.ts +42 -0
  769. package/src/runtime/routes/acp-routes-event-log.test.ts +17 -11
  770. package/src/runtime/routes/acp-routes.ts +2 -2
  771. package/src/runtime/routes/brain-graph-routes.ts +11 -11
  772. package/src/runtime/routes/browser-tabs-routes.ts +2 -1
  773. package/src/runtime/routes/btw-routes.ts +9 -2
  774. package/src/runtime/routes/canned-message-complete.ts +2 -2
  775. package/src/runtime/routes/chatgpt-subscription-auth-routes.ts +2 -1
  776. package/src/runtime/routes/consolidation-routes.ts +12 -13
  777. package/src/runtime/routes/content-source-routes.ts +1 -0
  778. package/src/runtime/routes/conversation-management-routes.ts +11 -5
  779. package/src/runtime/routes/conversation-query-routes.ts +120 -28
  780. package/src/runtime/routes/conversation-routes.ts +16 -3
  781. package/src/runtime/routes/credential-routes.ts +33 -0
  782. package/src/runtime/routes/debug-routes.ts +2 -2
  783. package/src/runtime/routes/defer-routes.ts +7 -4
  784. package/src/runtime/routes/events-routes.ts +2 -1
  785. package/src/runtime/routes/filing-routes.ts +5 -2
  786. package/src/runtime/routes/global-search-routes.ts +76 -10
  787. package/src/runtime/routes/guardian-approval-prompt.ts +2 -2
  788. package/src/runtime/routes/identity-routes.ts +87 -31
  789. package/src/runtime/routes/image-generation-routes.ts +12 -9
  790. package/src/runtime/routes/inbound-conversation.ts +19 -3
  791. package/src/runtime/routes/inbound-message-handler.ts +200 -82
  792. package/src/runtime/routes/inbound-stages/acl-enforcement.test.ts +60 -52
  793. package/src/runtime/routes/inbound-stages/acl-enforcement.ts +25 -40
  794. package/src/runtime/routes/inbound-stages/background-dispatch.test.ts +157 -94
  795. package/src/runtime/routes/inbound-stages/background-dispatch.ts +95 -87
  796. package/src/runtime/routes/inbound-stages/channel-turn-admission.test.ts +141 -0
  797. package/src/runtime/routes/inbound-stages/channel-turn-admission.ts +111 -0
  798. package/src/runtime/routes/inbound-stages/inbound-content-prep.test.ts +53 -0
  799. package/src/runtime/routes/inbound-stages/inbound-content-prep.ts +64 -0
  800. package/src/runtime/routes/index.ts +10 -6
  801. package/src/runtime/routes/inference-profiles-routes.ts +53 -2
  802. package/src/runtime/routes/inference-provider-connection-routes.ts +101 -6
  803. package/src/runtime/routes/integrations/slack/__tests__/{share.test.ts → token-routing.test.ts} +52 -49
  804. package/src/runtime/routes/integrations/slack/channels.ts +109 -84
  805. package/src/runtime/routes/integrations/slack/share.ts +12 -6
  806. package/src/runtime/routes/integrations/slack/users.ts +6 -4
  807. package/src/runtime/routes/live-voice-routes.test.ts +73 -0
  808. package/src/runtime/routes/live-voice-routes.ts +65 -0
  809. package/src/runtime/routes/log-export/AGENTS.md +24 -0
  810. package/src/runtime/routes/log-export/__tests__/installed-inventory-error.test.ts +31 -0
  811. package/src/runtime/routes/log-export/__tests__/installed-inventory.test.ts +200 -0
  812. package/src/runtime/routes/log-export/installed-inventory.ts +203 -0
  813. package/src/runtime/routes/log-export-routes.ts +37 -0
  814. package/src/runtime/routes/mcp-auth-routes.ts +42 -44
  815. package/src/runtime/routes/migration-routes.ts +9 -9
  816. package/src/runtime/routes/oauth-connect-routes.ts +1 -1
  817. package/src/runtime/routes/parse-body.ts +31 -0
  818. package/src/runtime/routes/playground/__tests__/inject-failures.test.ts +7 -7
  819. package/src/runtime/routes/playground/__tests__/reset-circuit.test.ts +5 -5
  820. package/src/runtime/routes/plugins-routes.ts +50 -15
  821. package/src/runtime/routes/route-host-worker-routes.ts +144 -0
  822. package/src/runtime/routes/sanity-routes.ts +2 -0
  823. package/src/runtime/routes/secret-routes.ts +46 -1
  824. package/src/runtime/routes/sequence-routes.ts +7 -6
  825. package/src/runtime/routes/suggest-trust-rule-routes.ts +6 -19
  826. package/src/runtime/routes/surface-action-routes.ts +10 -0
  827. package/src/runtime/routes/surface-conversation-resolver.ts +28 -32
  828. package/src/runtime/routes/ui-request-routes.ts +2 -1
  829. package/src/runtime/routes/upgrade-broadcast-routes.ts +6 -8
  830. package/src/runtime/routes/user-route-dispatcher.ts +98 -10
  831. package/src/runtime/routes/user-route-resolution.ts +39 -10
  832. package/src/runtime/routes/user-routes-cli.ts +9 -1
  833. package/src/runtime/routes/user-routes.ts +0 -2
  834. package/src/runtime/routes/watcher-routes.ts +9 -6
  835. package/src/runtime/routes/workspace-routes.test.ts +2 -2
  836. package/src/runtime/slack-reply-session.test.ts +44 -12
  837. package/src/runtime/slack-reply-session.ts +30 -19
  838. package/src/runtime/sync/sync-publisher.test.ts +7 -5
  839. package/src/runtime/tool-grant-request-helper.ts +14 -0
  840. package/src/security/AGENTS.md +1 -1
  841. package/src/security/credential-key.ts +17 -0
  842. package/src/security/plugin-secret-patterns.ts +465 -0
  843. package/src/security/secret-ingress.ts +76 -80
  844. package/src/security/secret-patterns.ts +8 -139
  845. package/src/security/secret-scanner.ts +43 -7
  846. package/src/signals/emit-event.ts +3 -3
  847. package/src/signals/event-stream.ts +5 -5
  848. package/src/skills/managed-store.ts +110 -3
  849. package/src/subagent/manager.ts +16 -15
  850. package/src/telemetry/__tests__/telemetry-event-fixtures.ts +4 -0
  851. package/src/telemetry/telemetry-event-sources.ts +2 -0
  852. package/src/telemetry/telemetry-wire-source.json +1 -1
  853. package/src/telemetry/telemetry-wire.generated.ts +12 -1
  854. package/src/telemetry/turn-events-store.ts +2 -24
  855. package/src/telemetry/turn-trace-store.ts +1 -15
  856. package/src/telemetry/types.ts +16 -0
  857. package/src/telemetry/usage-telemetry-reporter.test.ts +24 -6
  858. package/src/tools/acp/context.ts +5 -5
  859. package/src/tools/ask-question/ask-question-tool.test.ts +87 -1
  860. package/src/tools/ask-question/ask-question-tool.ts +58 -0
  861. package/src/tools/browser/browser-execution.ts +2 -2
  862. package/src/tools/browser/browser-screencast.ts +6 -6
  863. package/src/tools/credentials/broker.ts +48 -24
  864. package/src/tools/network/__tests__/web-search.test.ts +113 -15
  865. package/src/tools/network/managed-search-proxy.ts +12 -0
  866. package/src/tools/network/web-search.ts +31 -15
  867. package/src/tools/permission-checker.ts +42 -9
  868. package/src/tools/registry.ts +26 -17
  869. package/src/tools/skills/scaffold-managed.ts +34 -9
  870. package/src/tools/subagent/spawn.ts +3 -3
  871. package/src/tools/terminal/shell.ts +8 -4
  872. package/src/tools/tool-approval-handler.ts +26 -4
  873. package/src/tools/tool-types.ts +8 -0
  874. package/src/tools/types.ts +17 -0
  875. package/src/tools/ui-surface/definitions.ts +20 -16
  876. package/src/tools/ui-surface/surface-shape-docs.ts +21 -6
  877. package/src/tts/__tests__/tts-voice-field.test.ts +45 -0
  878. package/src/tts/providers/deepgram-provider.ts +4 -2
  879. package/src/tts/providers/elevenlabs-provider.ts +2 -2
  880. package/src/tts/providers/fish-audio-provider.ts +1 -1
  881. package/src/tts/providers/xai-provider.ts +2 -2
  882. package/src/tts/tts-config-resolver.ts +10 -2
  883. package/src/tts/tts-voice-field.ts +67 -0
  884. package/src/usage/attribution.ts +33 -2
  885. package/src/util/log-redact.ts +22 -6
  886. package/src/util/platform.ts +36 -0
  887. package/src/util/single-flight.test.ts +88 -0
  888. package/src/util/single-flight.ts +57 -0
  889. package/src/workflows/leaf-runner.ts +5 -5
  890. package/src/workspace/migrations/132-web-search-mode-to-provider.ts +117 -0
  891. package/src/workspace/migrations/133-collapse-provider-connections.ts +316 -0
  892. package/src/workspace/migrations/134-image-generation-mode-to-provider.ts +128 -0
  893. package/src/workspace/migrations/__tests__/backfill-v3-leaves.test.ts +2 -2
  894. package/src/workspace/migrations/registry.ts +6 -0
  895. package/src/workspace/provider-commit-message-generator.ts +10 -2
  896. package/src/__tests__/secret-patterns.test.ts +0 -27
  897. package/src/channels/slack-thread-store.ts +0 -184
  898. package/src/daemon/message-types/acp.ts +0 -78
  899. package/src/daemon/message-types/apps.ts +0 -356
  900. package/src/daemon/message-types/background-tools.ts +0 -28
  901. package/src/daemon/message-types/bookmarks.ts +0 -18
  902. package/src/daemon/message-types/contacts.ts +0 -67
  903. package/src/daemon/message-types/document-comments.ts +0 -14
  904. package/src/daemon/message-types/documents.ts +0 -82
  905. package/src/daemon/message-types/guardian-actions.ts +0 -48
  906. package/src/daemon/message-types/home.ts +0 -15
  907. package/src/daemon/message-types/host-bash.ts +0 -30
  908. package/src/daemon/message-types/host-cu.ts +0 -27
  909. package/src/daemon/message-types/host-file.ts +0 -54
  910. package/src/daemon/message-types/host-transfer.ts +0 -45
  911. package/src/daemon/message-types/inbox.ts +0 -65
  912. package/src/daemon/message-types/integrations.ts +0 -249
  913. package/src/daemon/message-types/memory.ts +0 -48
  914. package/src/daemon/message-types/schedules.ts +0 -197
  915. package/src/daemon/message-types/settings.ts +0 -61
  916. package/src/daemon/message-types/subagents.ts +0 -81
  917. package/src/daemon/message-types/upgrades.ts +0 -31
  918. package/src/daemon/message-types/workflows.ts +0 -131
  919. package/src/daemon/message-types/workspace.ts +0 -137
  920. package/src/plugins/defaults/memory/graph-topology/flag.ts +0 -14
  921. package/src/runtime/routes/integrations/slack/token.ts +0 -43
  922. /package/src/plugins/defaults/memory/{routes → src}/__tests__/memory-worker-routes.test.ts +0 -0
  923. /package/src/plugins/defaults/memory/{routes → src}/memory-eval-routes.ts +0 -0
  924. /package/src/plugins/defaults/memory/{routes → src}/memory-graph-routes.ts +0 -0
  925. /package/src/plugins/defaults/memory/{routes → src}/memory-worker-routes.ts +0 -0
  926. /package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/concept-page-frontmatter-schema.test.ts +0 -0
  927. /package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/edge-index.test.ts +0 -0
  928. /package/src/plugins/defaults/memory/{v2 → v3/substrate}/__tests__/injected-block-slugs.test.ts +0 -0
  929. /package/src/plugins/defaults/memory/{v2 → v3/substrate}/constants.ts +0 -0
  930. /package/src/plugins/defaults/memory/{v2 → v3/substrate}/edge-index.ts +0 -0
  931. /package/src/plugins/defaults/memory/{v2 → v3/substrate}/injected-block-slugs.ts +0 -0
  932. /package/src/plugins/defaults/memory/{v2 → v3/substrate}/prompts/sweep.ts +0 -0
@@ -276,13 +276,17 @@ The `allowOneTimeSend` config gate (default: `false`) enables a secondary "Send
276
276
  - The credentials prompt route output confirms delivery without including the secret value — the value is never returned to the model
277
277
  - The config gate must be explicitly enabled by the operator
278
278
 
279
+ ### Ingress Secret Detection
280
+
281
+ User messages are scanned at ingress (`secret-ingress.ts`) against known credential prefix patterns plus any plugin-declared patterns: plugins can declare `credentialKeyPatterns` in their manifest, and those patterns feed ingress blocking, display-time secret scanning (`secret-scanner.ts`), and log redaction (`log-redact.ts`) while the plugin is active. In addition, when `secretDetection.blockTokenShapedMessages` is enabled (default: `true`), a whole-message heuristic blocks messages whose entire trimmed content is a single token-shaped value — an alphanumeric head, a secret-keyword infix (`token`, `key`, `secret`, …), and a long random tail — catching pasted credentials whose prefix is not a known format while keeping false positives near zero.
282
+
279
283
  ### Storage Layout
280
284
 
281
285
  | Component | Location | What it stores |
282
286
  | ------------------- | ------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
283
287
  | Secret values | CES credential store or encrypted file store | Encrypted credential values keyed as `credential/{service}/{field}`. Stored via CES RPC (primary), CES HTTP (containerized), or encrypted file store (fallback). |
284
288
  | Credential metadata | `$VELLUM_WORKSPACE_DIR/data/credentials/metadata.json` | Service, field, label, policy (allowedTools, allowedDomains), timestamps |
285
- | Config | `$VELLUM_WORKSPACE_DIR/config.*` | `secretDetection` settings: enabled, blockIngress, allowOneTimeSend |
289
+ | Config | `$VELLUM_WORKSPACE_DIR/config.*` | `secretDetection` settings: enabled, blockIngress, allowOneTimeSend, blockTokenShapedMessages (default `true` — whole-message token-shape heuristic) |
286
290
 
287
291
  ### Key Files
288
292
 
@@ -296,7 +300,8 @@ The `allowOneTimeSend` config gate (default: `false`) enables a secondary "Send
296
300
  | `assistant/src/tools/credentials/policy-validate.ts` | Policy input validation (allowedTools, allowedDomains) |
297
301
  | `assistant/src/permissions/secret-prompter.ts` | HTTP secret_request/secret_response flow |
298
302
  | `assistant/src/security/secret-scanner.ts` | Prefix + shape-based secret regex detection (used by display-time `redactSecrets`) |
299
- | `assistant/src/security/secret-ingress.ts` | Prefix-only ingress check on user messages |
303
+ | `assistant/src/security/secret-ingress.ts` | Ingress check on user messages: prefix + plugin patterns + token-shape heuristic |
304
+ | `assistant/src/security/plugin-secret-patterns.ts` | Registry of plugin-declared `credentialKeyPatterns` feeding detection/redaction |
300
305
  | `assistant/src/util/log-redact.ts` | Pino log serializers — prefix-based redaction for logs |
301
306
  | `clients/web/src/domains/chat/components/secret-prompt-card.tsx` | UI for secure credential entry |
302
307
 
@@ -39,7 +39,7 @@ Design doc defining how unknown users gain access to a Vellum assistant via chan
39
39
 
40
40
  This ensures unknown inbound access attempts always trigger guardian notification, even when the requester's source channel has no guardian binding.
41
41
 
42
- 4. **Guardian decides.** All decisions route through the guardian decision primitive (`applyGuardianDecision`, `approvals/guardian-decision-primitive.ts`) and commit via the gateway's `guardian_requests_decide` IPC op: the status CAS and the decision's ACL outcome execute in ONE gateway transaction, so an `approved` request can never exist without its ACL write. The introduction card supports four outcomes: **approve** (start the verification handshake), **trust** (activate directly, no code — used for workspace-vouched identities), **deny** (persist a terminal denial), and **block**.
42
+ 4. **Guardian decides.** All decisions route through the guardian decision primitive (`applyGuardianDecision`, `approvals/guardian-decision-primitive.ts`) and commit via the gateway's `guardian_requests_decide` IPC op: the status CAS and the decision's ACL outcome execute in ONE gateway transaction, so an `approved` request can never exist without its ACL write. The introduction card supports four outcomes: **approve** (start the verification handshake), **trust** (activate directly, no code — used for workspace-vouched identities), **leave unverified** (the `leave_unverified` action id — park the sender as an `unverified` contact, **silently**: the requester is not notified and only learns if they message again; a later trust-requiring inbound re-fires the flow), and **block** (revoke the sender's channel and notify them their request was declined). Note the `unverified` contact left by "leave unverified" is not a guaranteed keep-out — it is still admitted under the permissive admission floors (`any_contact`, `strangers`); **block** (→ revoked) is the hard keep-out.
43
43
  5. **On approval the gateway mints a verification session.** The decide op carries a `mint_outbound_session` outcome; inside the decide transaction the gateway (`gateway/src/verification/session-service.ts`) generates a 6-digit code, persists only its SHA-256 hash in `channel_verification_sessions` (identity-bound to the requester, `verificationPurpose: 'trusted_contact'`), and returns the raw secret to the daemon in the decide response for delivery.
44
44
  6. **The code is delivered.** The daemon delivers the code to the guardian's verified channel (ephemeral + DM on Slack shared channels so other members never see it). On Slack the code is also DM'd straight to the requester; on other channels the guardian relays it out-of-band (in person, text message, phone call). That out-of-band transfer is the trust anchor: it proves the requester has a real-world relationship with the guardian.
45
45
  7. **Requester enters the code** back to the assistant on the same channel. The **gateway** intercepts bare verification codes at ingress (`gateway/src/verification/text-verification.ts`) whenever an interceptable session exists for that channel — the daemon never sees verification code messages.
@@ -52,14 +52,14 @@ Design doc defining how unknown users gain access to a Vellum assistant via chan
52
52
  requested -> pending_guardian -> verification_pending -> active | denied | expired
53
53
  ```
54
54
 
55
- | State | Description | Store representation |
56
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
57
- | `requested` | Unknown user messaged the assistant and was denied. The system records the access attempt. | No member record exists. The inbound is logged in `channel_inbound_events` (assistant DB). A notification signal is emitted via `emitNotificationSignal()`. |
58
- | `pending_guardian` | The guardian has been notified and a decision is pending. | A `guardian_requests` record (gateway DB) with `status: 'pending'`, `kind: 'access_request'`. |
59
- | `verification_pending` | The guardian approved. A verification session is active with a 6-digit code waiting for the requester to enter. | Gateway `channel_verification_sessions` record with `status: 'awaiting_response'`, identity-bound to the requester. The guardian request is `status: 'approved'`. |
60
- | `active` | The requester entered the correct code (or the guardian chose direct trust). They are now a trusted contact. | Gateway `contact_channels` record with `status: 'active'`, `policy: 'allow'`; identity mirrored to the assistant DB. The verification session is `status: 'consumed'`. |
61
- | `denied` | The guardian explicitly denied the request. | The guardian request has `status: 'denied'`. The sender is persisted as an unverified contact and later inbound is suppressed (terminal-deny). |
62
- | `expired` | The guardian never responded (approval TTL elapsed) or the requester never entered the code (session TTL elapsed). | Guardian request: `status: 'expired'` (CAS-expired by the gateway via the daemon's expiry sweep). Verification session: expires naturally when `expiresAt < Date.now()`. |
55
+ | State | Description | Store representation |
56
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
57
+ | `requested` | Unknown user messaged the assistant and was denied. The system records the access attempt. | No member record exists. The inbound is logged in `channel_inbound_events` (assistant DB). A notification signal is emitted via `emitNotificationSignal()`. |
58
+ | `pending_guardian` | The guardian has been notified and a decision is pending. | A `guardian_requests` record (gateway DB) with `status: 'pending'`, `kind: 'access_request'`. |
59
+ | `verification_pending` | The guardian approved. A verification session is active with a 6-digit code waiting for the requester to enter. | Gateway `channel_verification_sessions` record with `status: 'awaiting_response'`, identity-bound to the requester. The guardian request is `status: 'approved'`. |
60
+ | `active` | The requester entered the correct code (or the guardian chose direct trust). They are now a trusted contact. | Gateway `contact_channels` record with `status: 'active'`, `policy: 'allow'`; identity mirrored to the assistant DB. The verification session is `status: 'consumed'`. |
61
+ | `denied` | The guardian resolved the request without granting access — `leave_unverified` (park) or `block` (keep-out). | The guardian request has `status: 'denied'` for both. `leave_unverified` persists an `unverified` contact — a neutral park, so a later trust-requiring inbound **re-fires** the flow; `block` revokes the channel — a durable keep-out, so re-contact is suppressed. Suppression keys off the durable **contact status** (`revoked`/`blocked`), never this request status. |
62
+ | `expired` | The guardian never responded (approval TTL elapsed) or the requester never entered the code (session TTL elapsed). | Guardian request: `status: 'expired'` (CAS-expired by the gateway via the daemon's expiry sweep). Verification session: expires naturally when `expiresAt < Date.now()`. |
63
63
 
64
64
  ## Identity Binding Rules
65
65
 
@@ -112,7 +112,16 @@ Identity binding ensures the verification code can only be consumed by the inten
112
112
  | -------------------------------------------------- | ------------------- | ------------------------------------------------------------- |
113
113
  | gateway `guardian-request-service.ts` (gateway DB) | `guardian_requests` | Updated to `status: 'denied'`, `decidedByExternalUserId` set. |
114
114
 
115
- No trusted-contact activation happens. The sender is persisted as an unverified contact, and the terminal-deny check suppresses re-prompting the guardian for the same sender.
115
+ No trusted-contact activation happens. The `leave_unverified` outcome persists the sender as an `unverified` contact **and sends no requester notification** (silent park); `block` instead revokes the channel and **does** notify the requester ("Your access request was declined.").
116
+
117
+ The two outcomes differ on re-contact. Suppression of re-prompting keys off the **durable contact status**, not this `denied` request status:
118
+
119
+ - `leave_unverified` → `unverified` contact: a neutral park, **not** kept out. If the contact later does something that needs trust — e.g. DMs on a `trusted_contacts` channel — the deny-path flow **re-fires** (self-verify challenge + a fresh guardian card), so the guardian decides afresh. The guardian's way to stop the prompts is to `block`.
120
+ - `block` → `revoked` contact: a durable keep-out. Re-contact is suppressed (no challenge, no guardian notification) on every floor.
121
+
122
+ The resolved approval card mirrors this distinction on every surface (in-app, Slack): a `leave_unverified` park reads as a neutral **"Left unverified"**, while `block` reads as **"Denied"**. Both share the `denied` request status, so the card presentation is keyed off the decided action, not the status (see `PARK_ACTION_SET` / `isParkAction` in `runtime/channel-approval-types.ts`).
123
+
124
+ Separately, the admitted-mode introduction **nudge** (for a contact who cleared the floor unclassified) is quieted once the guardian has decided the contact, so a classified contact is not re-nudged across conversations. That is distinct from the deny-path re-fire above.
116
125
 
117
126
  ### Stage: `expired`
118
127
 
@@ -191,10 +200,15 @@ sequenceDiagram
191
200
  GW->>A: Forward with allow verdict
192
201
  A->>A: Process message normally
193
202
 
194
- else Guardian denies
195
- G->>A: Deny (inline button / app / plain text)
196
- A->>A: Resolver persists denial (terminal-deny)
197
- A-->>U: (No notification — user only knows<br/>they were denied if they message again)
203
+ else Guardian leaves unverified
204
+ G->>A: Leave unverified (inline button / app / plain text)
205
+ A->>A: Resolver seeds unverified contact (neutral park —<br/>a trust-requiring re-contact re-fires the flow)
206
+ A-->>U: (No notification — user only learns<br/>if they message again)
207
+
208
+ else Guardian blocks
209
+ G->>A: Block
210
+ A->>A: Resolver revokes the channel (durable keep-out —<br/>re-contact suppressed)
211
+ A-->>U: "Your access request was declined."
198
212
 
199
213
  else Guardian never responds
200
214
  Note over A: runGuardianExpirySweep()<br/>runs every 60 seconds
@@ -241,7 +255,7 @@ sequenceDiagram
241
255
 
242
256
  - If the unknown user messages the assistant multiple times before the guardian responds, each message hits the ACL denial path independently.
243
257
  - `notifyGuardianOfAccessRequest()` dedupes on the existing pending guardian request for the same (assistant, channel, requester), and the notification pipeline's `dedupeKey` prevents duplicate notification events.
244
- - A prior terminal deny suppresses re-prompting entirely, and an approval whose verification window is still open suppresses a fresh request (the sender is told to enter their code instead).
258
+ - A **durable keep-out** — a `revoked` or `blocked` contact — suppresses re-prompting entirely (`isKeptOutStatus(previousMemberStatus)`). A `leave_unverified` park (`unverified` contact) is **not** a keep-out and re-fires; only `block` stops the prompts. An approval whose verification window is still open also suppresses a fresh request (the sender is told to enter their code instead).
245
259
 
246
260
  ### Requester already has a member record in non-active state
247
261
 
@@ -10,12 +10,14 @@
10
10
  "./client-metadata": "./src/client-metadata.ts",
11
11
  "./credential-rpc": "./src/credential-rpc.ts",
12
12
  "./ingress": "./src/ingress.ts",
13
+ "./remote-web-pairing": "./src/remote-web-pairing.ts",
13
14
  "./twilio-ingress": "./src/twilio-ingress.ts",
14
15
  "./trust-rules": "./src/trust-rules.ts",
15
16
  "./handles": "./src/handles.ts",
16
17
  "./rpc": "./src/rpc.ts",
17
18
  "./attachment-naming": "./src/attachment-naming.ts",
18
19
  "./redacted-credential": "./src/redacted-credential.ts",
20
+ "./secret-detection": "./src/secret-detection.ts",
19
21
  "./error": "./src/error.ts"
20
22
  },
21
23
  "scripts": {
@@ -0,0 +1,449 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ // Self-referencing package import — proves the `./secret-detection` subpath
4
+ // export resolves for consumers.
5
+ import * as subpathExport from "@vellumai/service-contracts/secret-detection";
6
+
7
+ import {
8
+ detectSecretsInText,
9
+ isCompletePrivateKeyBlock,
10
+ PEM_REDACTION_MAX_BODY_LENGTH,
11
+ PREFIX_PATTERNS,
12
+ PRIVATE_KEY_REDACTION_REGEX,
13
+ REDACTION_PREFIX_PATTERNS,
14
+ TOKEN_SHAPE,
15
+ TOKEN_SHAPE_LABEL,
16
+ TOKEN_SHAPE_MAX_LENGTH,
17
+ } from "../secret-detection.js";
18
+
19
+ // All fixtures below are synthetic lookalike tokens — never real key material.
20
+
21
+ function matchingLabels(text: string): string[] {
22
+ return PREFIX_PATTERNS.filter((p) => p.regex.test(text)).map((p) => p.label);
23
+ }
24
+
25
+ const ALNUM = "abcdefghijklmnopqrstuvwxyz0123456789";
26
+
27
+ /** Lowercase-alphanumeric filler of the given length (no separators, so it
28
+ * can never form another pattern's prefix like `npm_` or `key-`). */
29
+ function filler(length: number): string {
30
+ return ALNUM.repeat(Math.ceil(length / ALNUM.length)).slice(0, length);
31
+ }
32
+
33
+ /** One synthetic fixture per provider family, keyed by pattern label. */
34
+ const FIXTURES: Record<string, string> = {
35
+ "AWS Access Key": "AKIAABCDEFGHIJKLMNOP",
36
+ "GitHub Token": `ghp_${filler(36)}`,
37
+ "GitHub Fine-Grained PAT": `github_pat_${filler(22)}`,
38
+ "GitLab Token": `glpat-${filler(20)}`,
39
+ "Stripe Secret Key": `sk_live_${filler(24)}`,
40
+ "Stripe Restricted Key": `rk_live_${filler(24)}`,
41
+ "Slack Bot Token": `xoxb-1234567890-1234567890-${filler(24)}`,
42
+ "Slack User Token": `xoxp-1234567890-1234567890-1234567890-${"0123456789abcdef".repeat(2)}`,
43
+ "Slack App Token": "xapp-1-abc123-4567-defghij890",
44
+ "Telegram Bot Token": `123456789:${filler(35)}`,
45
+ "Anthropic API Key": `sk-ant-${filler(80)}`,
46
+ "OpenAI API Key": `sk-${filler(20)}T3BlbkFJ${filler(20)}`,
47
+ "OpenAI Project Key": `sk-proj-${filler(40)}`,
48
+ "Google API Key": `AIza${filler(35)}`,
49
+ "Google OAuth Client Secret": `GOCSPX-${filler(28)}`,
50
+ "Twilio API Key": `SK${"0123456789abcdef".repeat(2)}`,
51
+ "SendGrid API Key": `SG.${filler(22)}.${filler(43)}`,
52
+ "Mailgun API Key": `key-${filler(32)}`,
53
+ "npm Token": `npm_${filler(36)}`,
54
+ "PyPI API Token": `pypi-${filler(50)}`,
55
+ "Private Key": "-----BEGIN OPENSSH PRIVATE KEY-----",
56
+ "Linear API Key": `lin_api_${filler(32)}`,
57
+ "Notion Integration Token": `ntn_${filler(40)}`,
58
+ "OpenRouter API Key": `sk-or-v1-${filler(40)}`,
59
+ "Vercel AI Gateway API Key": `vck_${filler(24)}`,
60
+ "Fireworks API Key": `fw_${filler(32)}`,
61
+ "Perplexity API Key": `pplx-${filler(40)}`,
62
+ "Tavily API Key": `tvly-${filler(20)}`,
63
+ "Firecrawl API Key": `fc-${filler(20)}`,
64
+ };
65
+
66
+ describe("subpath export", () => {
67
+ test("@vellumai/service-contracts/secret-detection resolves to this module", () => {
68
+ expect(subpathExport.PREFIX_PATTERNS).toBe(PREFIX_PATTERNS);
69
+ expect(subpathExport.detectSecretsInText).toBe(detectSecretsInText);
70
+ });
71
+ });
72
+
73
+ describe("PREFIX_PATTERNS", () => {
74
+ test("every pattern has a fixture", () => {
75
+ expect(Object.keys(FIXTURES).sort()).toEqual(
76
+ PREFIX_PATTERNS.map((p) => p.label).sort(),
77
+ );
78
+ });
79
+
80
+ test("pattern labels are unique", () => {
81
+ const labels = PREFIX_PATTERNS.map((p) => p.label);
82
+ expect(new Set(labels).size).toBe(labels.length);
83
+ });
84
+
85
+ // Label-uniqueness invariant: each fixture matches exactly one pattern, so
86
+ // a detected value always maps to an unambiguous label.
87
+ for (const [label, fixture] of Object.entries(FIXTURES)) {
88
+ test(`${label} fixture matches exactly that pattern`, () => {
89
+ expect(matchingLabels(fixture)).toEqual([label]);
90
+ });
91
+ }
92
+
93
+ test("does not match a short vck_ string", () => {
94
+ expect(matchingLabels("vck_abc")).toEqual([]);
95
+ });
96
+ });
97
+
98
+ describe("detectSecretsInText — prefix patterns", () => {
99
+ for (const [label, fixture] of Object.entries(FIXTURES)) {
100
+ test(`detects a ${label} with the right label and span`, () => {
101
+ const text = `my key is ${fixture} thanks`;
102
+ const start = text.indexOf(fixture);
103
+ expect(detectSecretsInText(text)).toEqual([
104
+ {
105
+ label,
106
+ value: fixture,
107
+ start,
108
+ end: start + fixture.length,
109
+ wholeMessage: false,
110
+ },
111
+ ]);
112
+ });
113
+ }
114
+
115
+ test("does not mutate the shared pattern objects' lastIndex", () => {
116
+ detectSecretsInText(`ghp_${filler(36)}`);
117
+ for (const p of PREFIX_PATTERNS) {
118
+ expect(p.regex.lastIndex).toBe(0);
119
+ }
120
+ });
121
+ });
122
+
123
+ describe("detectSecretsInText — placeholder suppression", () => {
124
+ test("known placeholder text returns no matches", () => {
125
+ expect(detectSecretsInText("your-api-key-here")).toEqual([]);
126
+ expect(detectSecretsInText("sk-xxxxxxxxxxxxxxxxxxxxxxxx")).toEqual([]);
127
+ });
128
+
129
+ test("placeholder-prefixed token-shaped message is suppressed", () => {
130
+ expect(detectSecretsInText(`fake_key_${filler(20)}`)).toEqual([]);
131
+ expect(detectSecretsInText(`test_api_${filler(16)}`)).toEqual([]);
132
+ expect(detectSecretsInText(`dummy-token-${filler(16)}`)).toEqual([]);
133
+ });
134
+
135
+ test("token-shaped message with a placeholder tail is suppressed", () => {
136
+ // TOKEN_SHAPE matches with tail "replace_with_your_key", which is a
137
+ // known placeholder.
138
+ expect(detectSecretsInText("acme_key_replace_with_your_key")).toEqual([]);
139
+ });
140
+
141
+ test("placeholder pre-context suppresses a prefix match (fake_ghp_...)", () => {
142
+ // The GitHub regex matches starting at `ghp_`, so the `fake_` marker
143
+ // sits in the pre-context window rather than the matched value.
144
+ expect(detectSecretsInText(`fake_${"ghp_" + filler(36)}`)).toEqual([]);
145
+ expect(
146
+ detectSecretsInText(`docs use example_ghp_${filler(36)} as a stand-in`),
147
+ ).toEqual([]);
148
+ });
149
+
150
+ test("repeated-character variable portion suppresses a prefix match", () => {
151
+ // AKIA followed by 16 repeated placeholder characters.
152
+ expect(detectSecretsInText("AKIAXXXXXXXXXXXXXXXX")).toEqual([]);
153
+ expect(detectSecretsInText(`set AWS_KEY=AKIA${"X".repeat(16)}`)).toEqual(
154
+ [],
155
+ );
156
+ });
157
+
158
+ test("the same tokens without placeholder context still match", () => {
159
+ const github = `ghp_${filler(36)}`;
160
+ expect(detectSecretsInText(github).map((m) => m.label)).toEqual([
161
+ "GitHub Token",
162
+ ]);
163
+ expect(
164
+ detectSecretsInText("AKIAABCDEFGHIJKLMNOP").map((m) => m.label),
165
+ ).toEqual(["AWS Access Key"]);
166
+ });
167
+
168
+ test("token-shaped message with a repeated-character tail is suppressed", () => {
169
+ expect(detectSecretsInText(`my_key_${"x".repeat(16)}`)).toEqual([]);
170
+ });
171
+ });
172
+
173
+ describe("detectSecretsInText — whole-message token shape", () => {
174
+ test("a whole-message token-shaped value is detected", () => {
175
+ const token = `virlo_tkn_${filler(20)}`;
176
+ expect(TOKEN_SHAPE.test(token)).toBe(true);
177
+ expect(detectSecretsInText(token)).toEqual([
178
+ {
179
+ label: TOKEN_SHAPE_LABEL,
180
+ value: token,
181
+ start: 0,
182
+ end: token.length,
183
+ wholeMessage: true,
184
+ },
185
+ ]);
186
+ });
187
+
188
+ test("surrounding whitespace is trimmed and the span covers the token", () => {
189
+ const token = `acme_secret_${filler(18)}`;
190
+ expect(detectSecretsInText(` ${token} \n`)).toEqual([
191
+ {
192
+ label: TOKEN_SHAPE_LABEL,
193
+ value: token,
194
+ start: 2,
195
+ end: 2 + token.length,
196
+ wholeMessage: true,
197
+ },
198
+ ]);
199
+ });
200
+
201
+ test("a normal sentence returns no matches", () => {
202
+ expect(
203
+ detectSecretsInText("can you review my pull request today?"),
204
+ ).toEqual([]);
205
+ expect(detectSecretsInText("")).toEqual([]);
206
+ });
207
+
208
+ test("token shape is not applied when a prefix pattern already matched", () => {
209
+ const key = `glpat-${filler(20)}`;
210
+ const results = detectSecretsInText(key);
211
+ expect(results).toHaveLength(1);
212
+ expect(results[0]!.label).toBe("GitLab Token");
213
+ });
214
+
215
+ test("a token-shaped value over the max length is not matched", () => {
216
+ // Same shape as a valid token but a tail longer than the shared max — the
217
+ // daemon ingress caps the whole-message heuristic here, so the client must
218
+ // too or a >512-char paste would warn client-side yet pass server-side.
219
+ const tail = filler(TOKEN_SHAPE_MAX_LENGTH + 1);
220
+ const token = `virlo_tkn_${tail}`;
221
+ expect(token.length).toBeGreaterThan(TOKEN_SHAPE_MAX_LENGTH);
222
+ expect(TOKEN_SHAPE.test(token)).toBe(true);
223
+ expect(detectSecretsInText(token)).toEqual([]);
224
+ });
225
+
226
+ test("a token-shaped value exactly at the max length is still matched", () => {
227
+ const prefix = "virlo_tkn_";
228
+ const token = `${prefix}${filler(TOKEN_SHAPE_MAX_LENGTH - prefix.length)}`;
229
+ expect(token.length).toBe(TOKEN_SHAPE_MAX_LENGTH);
230
+ const results = detectSecretsInText(token);
231
+ expect(results).toHaveLength(1);
232
+ expect(results[0]!.label).toBe(TOKEN_SHAPE_LABEL);
233
+ });
234
+ });
235
+
236
+ describe("REDACTION_PREFIX_PATTERNS — bounded whole-block private key", () => {
237
+ const FAKE_PEM_BODY =
238
+ "MIIFAKEfakefakefakefakefakefakefakefakefake\n" +
239
+ "FAKEfakefakefakefakefakefakefakefakefake==";
240
+ const FULL_PEM_BLOCK = `-----BEGIN RSA PRIVATE KEY-----\n${FAKE_PEM_BODY}\n-----END RSA PRIVATE KEY-----`;
241
+
242
+ function redactionPrivateKeyRegex(): RegExp {
243
+ const entry = REDACTION_PREFIX_PATTERNS.find(
244
+ (p) => p.label === "Private Key",
245
+ );
246
+ expect(entry).toBeDefined();
247
+ return new RegExp(entry!.regex.source, "g");
248
+ }
249
+
250
+ test("the redaction private-key entry is the bounded whole-block matcher", () => {
251
+ const entry = REDACTION_PREFIX_PATTERNS.find(
252
+ (p) => p.label === "Private Key",
253
+ );
254
+ expect(entry!.regex.source).toBe(PRIVATE_KEY_REDACTION_REGEX.source);
255
+ });
256
+
257
+ test("the redaction variant matches the WHOLE block, not just the header", () => {
258
+ const regex = redactionPrivateKeyRegex();
259
+ const match = regex.exec(FULL_PEM_BLOCK);
260
+ expect(match).not.toBeNull();
261
+ // The full header→body→footer span, so an in-place replace removes the
262
+ // key body and footer, not only the BEGIN line.
263
+ expect(match![0]).toBe(FULL_PEM_BLOCK);
264
+ });
265
+
266
+ test("an in-place replace with the redaction regex leaves no body or footer", () => {
267
+ const regex = redactionPrivateKeyRegex();
268
+ const text = `before\n${FULL_PEM_BLOCK}\nafter`;
269
+ const redacted = text.replace(regex, "[REDACTED]");
270
+ expect(redacted).toBe("before\n[REDACTED]\nafter");
271
+ // The base64 body and the END footer are gone.
272
+ expect(redacted).not.toContain("MIIFAKE");
273
+ expect(redacted).not.toContain("-----END");
274
+ expect(redacted).not.toContain("-----BEGIN");
275
+ });
276
+
277
+ test("a footerless key still redacts header-only (truncated-key fallback)", () => {
278
+ const regex = redactionPrivateKeyRegex();
279
+ const text = `-----BEGIN RSA PRIVATE KEY-----\n${FAKE_PEM_BODY}`;
280
+ const match = regex.exec(text);
281
+ expect(match).not.toBeNull();
282
+ // No END within the bound → optional footer group fails → header-only
283
+ // match, preserving the detection-fires guarantee.
284
+ expect(match![0]).toBe("-----BEGIN RSA PRIVATE KEY-----");
285
+ });
286
+
287
+ test("a body longer than the bound falls back to header-only, not a hang", () => {
288
+ const regex = redactionPrivateKeyRegex();
289
+ // Footer sits just past the body bound, so the whole-block branch can't
290
+ // reach it and the match degrades to the header (fail-open on redaction:
291
+ // an unbounded key is not a realistic PEM).
292
+ const overlongBody = "a".repeat(PEM_REDACTION_MAX_BODY_LENGTH + 100);
293
+ const text = `-----BEGIN RSA PRIVATE KEY-----\n${overlongBody}\n-----END RSA PRIVATE KEY-----`;
294
+ const match = regex.exec(text);
295
+ expect(match).not.toBeNull();
296
+ expect(match![0]).toBe("-----BEGIN RSA PRIVATE KEY-----");
297
+ });
298
+
299
+ test("many footerless BEGIN headers redact fast (bounded, no O(n²) hang)", () => {
300
+ const regex = redactionPrivateKeyRegex();
301
+ // A pathological paste: thousands of footerless headers, each followed by
302
+ // filler that an unbounded matcher would rescan hunting for a footer. The
303
+ // body bound caps each rescan, so the whole sweep stays linear.
304
+ const chunk = `-----BEGIN RSA PRIVATE KEY-----\n${filler(200)}\n`;
305
+ const text = chunk.repeat(5000);
306
+ const startedAt = Date.now();
307
+ const redacted = text.replace(regex, "[REDACTED]");
308
+ const elapsedMs = Date.now() - startedAt;
309
+ expect(redacted).toContain("[REDACTED]");
310
+ expect(redacted).not.toContain("-----BEGIN");
311
+ expect(elapsedMs).toBeLessThan(2000);
312
+ });
313
+
314
+ test("every non-private-key pattern is shared verbatim with PREFIX_PATTERNS", () => {
315
+ for (let i = 0; i < PREFIX_PATTERNS.length; i++) {
316
+ if (PREFIX_PATTERNS[i]!.label === "Private Key") {
317
+ continue;
318
+ }
319
+ expect(REDACTION_PREFIX_PATTERNS[i]).toBe(PREFIX_PATTERNS[i]);
320
+ }
321
+ });
322
+
323
+ test("detectSecretsInText still captures the whole block (P1 stays fixed)", () => {
324
+ const results = detectSecretsInText(FULL_PEM_BLOCK);
325
+ expect(results).toHaveLength(1);
326
+ expect(results[0]!.label).toBe("Private Key");
327
+ expect(results[0]!.value).toBe(FULL_PEM_BLOCK);
328
+ });
329
+ });
330
+
331
+ describe("detectSecretsInText — PEM private-key blocks", () => {
332
+ // Clearly fake PEM material — never a real key.
333
+ const FAKE_PEM_BODY =
334
+ "MIIFAKEfakefakefakefakefakefakefakefakefake\n" +
335
+ "FAKEfakefakefakefakefakefakefakefakefake==";
336
+ const FULL_PEM_BLOCK = `-----BEGIN RSA PRIVATE KEY-----\n${FAKE_PEM_BODY}\n-----END RSA PRIVATE KEY-----`;
337
+
338
+ test("a complete PEM block is one match spanning header through footer", () => {
339
+ const text = `here is my key\n${FULL_PEM_BLOCK}\nplease use it`;
340
+ const start = text.indexOf(FULL_PEM_BLOCK);
341
+ expect(detectSecretsInText(text)).toEqual([
342
+ {
343
+ label: "Private Key",
344
+ value: FULL_PEM_BLOCK,
345
+ start,
346
+ end: start + FULL_PEM_BLOCK.length,
347
+ wholeMessage: false,
348
+ },
349
+ ]);
350
+ });
351
+
352
+ test("a PGP private-key block with the BLOCK suffix is captured whole", () => {
353
+ const block = `-----BEGIN PGP PRIVATE KEY BLOCK-----\n${FAKE_PEM_BODY}\n-----END PGP PRIVATE KEY BLOCK-----`;
354
+ const results = detectSecretsInText(block);
355
+ expect(results).toHaveLength(1);
356
+ expect(results[0]!.value).toBe(block);
357
+ });
358
+
359
+ test("a header with a body but no END footer still fires — header-only span", () => {
360
+ // Truncated / partially pasted key: detection must not regress, the
361
+ // daemon ingress relies on the header alone to block.
362
+ const text = `-----BEGIN RSA PRIVATE KEY-----\n${FAKE_PEM_BODY}`;
363
+ const results = detectSecretsInText(text);
364
+ expect(results).toEqual([
365
+ {
366
+ label: "Private Key",
367
+ value: "-----BEGIN RSA PRIVATE KEY-----",
368
+ start: 0,
369
+ end: "-----BEGIN RSA PRIVATE KEY-----".length,
370
+ wholeMessage: false,
371
+ },
372
+ ]);
373
+ expect(isCompletePrivateKeyBlock(results[0]!.value)).toBe(false);
374
+ });
375
+
376
+ test("adjacent complete blocks match separately, not as one giant span", () => {
377
+ const text = `${FULL_PEM_BLOCK}\n\n${FULL_PEM_BLOCK}`;
378
+ const results = detectSecretsInText(text);
379
+ expect(results).toHaveLength(2);
380
+ expect(results[0]!.value).toBe(FULL_PEM_BLOCK);
381
+ expect(results[1]!.value).toBe(FULL_PEM_BLOCK);
382
+ expect(results[1]!.start).toBeGreaterThanOrEqual(results[0]!.end);
383
+ });
384
+
385
+ test("a footerless header never swallows a later complete block", () => {
386
+ // The body is tempered — it cannot cross another BEGIN header — so the
387
+ // truncated first key matches header-only and the second key matches
388
+ // as its own complete block.
389
+ const text = `-----BEGIN EC PRIVATE KEY-----\ntruncated\n\n${FULL_PEM_BLOCK}`;
390
+ const results = detectSecretsInText(text);
391
+ expect(results.map((r) => r.value)).toEqual([
392
+ "-----BEGIN EC PRIVATE KEY-----",
393
+ FULL_PEM_BLOCK,
394
+ ]);
395
+ });
396
+
397
+ test("a token-lookalike run inside the block body loses to the block", () => {
398
+ // Base64 can legally contain an AKIA + 16-uppercase run; the Private
399
+ // Key pattern is first in PREFIX_PATTERNS so the whole-block span wins
400
+ // the overlap dedupe instead of being fragmented by the AWS pattern.
401
+ const block = `-----BEGIN RSA PRIVATE KEY-----\nAKIAABCDEFGHIJKLMNOP\n${FAKE_PEM_BODY}\n-----END RSA PRIVATE KEY-----`;
402
+ const results = detectSecretsInText(block);
403
+ expect(results).toHaveLength(1);
404
+ expect(results[0]!.label).toBe("Private Key");
405
+ expect(results[0]!.value).toBe(block);
406
+ });
407
+ });
408
+
409
+ describe("isCompletePrivateKeyBlock", () => {
410
+ test("true for a value ending at the END footer", () => {
411
+ expect(
412
+ isCompletePrivateKeyBlock(
413
+ "-----BEGIN OPENSSH PRIVATE KEY-----\nMIIFAKEfake==\n-----END OPENSSH PRIVATE KEY-----",
414
+ ),
415
+ ).toBe(true);
416
+ });
417
+
418
+ test("false for a header-only match and for non-PEM values", () => {
419
+ expect(
420
+ isCompletePrivateKeyBlock("-----BEGIN OPENSSH PRIVATE KEY-----"),
421
+ ).toBe(false);
422
+ expect(isCompletePrivateKeyBlock(`ghp_${filler(36)}`)).toBe(false);
423
+ });
424
+ });
425
+
426
+ describe("detectSecretsInText — multiple and overlapping matches", () => {
427
+ test("multiple secrets yield sorted, non-overlapping matches", () => {
428
+ const aws = "AKIAABCDEFGHIJKLMNOP";
429
+ const github = `ghp_${filler(36)}`;
430
+ // GitHub appears before AWS in the text but after it in pattern order.
431
+ const text = `first ${github} then ${aws} done`;
432
+ const results = detectSecretsInText(text);
433
+ expect(results.map((r) => r.label)).toEqual([
434
+ "GitHub Token",
435
+ "AWS Access Key",
436
+ ]);
437
+ for (let i = 1; i < results.length; i++) {
438
+ expect(results[i]!.start).toBeGreaterThanOrEqual(results[i - 1]!.end);
439
+ }
440
+ });
441
+
442
+ test("overlapping spans keep the first pattern in list order", () => {
443
+ // The GitHub token's tail embeds an `npm_…` run; GitHub Token precedes
444
+ // npm Token in PREFIX_PATTERNS, so only the GitHub match survives.
445
+ const value = `ghp_npm_${filler(36)}`;
446
+ const results = detectSecretsInText(value);
447
+ expect(results.map((r) => r.label)).toEqual(["GitHub Token"]);
448
+ });
449
+ });
@@ -26,4 +26,5 @@ export * from "./handles.js";
26
26
  export * from "./rpc.js";
27
27
  export * from "./trust-rules.js";
28
28
  export * from "./ingress.js";
29
+ export * from "./remote-web-pairing.js";
29
30
  export * from "./twilio-ingress.js";