@mycadet/gateway 0.13.0 → 0.14.0

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 (410) hide show
  1. package/Dockerfile +1 -0
  2. package/README.md +10 -10
  3. package/eslint.config.mjs +7 -8
  4. package/knip.json +2 -8
  5. package/node_modules/@mycadet/assistant-client/src/__tests__/assistant-client.test.ts +40 -34
  6. package/node_modules/@mycadet/assistant-client/src/http-client.ts +59 -8
  7. package/node_modules/@mycadet/assistant-client/src/index.ts +4 -0
  8. package/node_modules/@mycadet/assistant-client/src/proxy-forward.ts +5 -4
  9. package/node_modules/@mycadet/assistant-client/src/websocket-upstream.ts +21 -31
  10. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/package.json +18 -0
  11. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/src/endpoint.test.ts +36 -0
  12. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/src/endpoint.ts +142 -0
  13. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/src/index.ts +18 -0
  14. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/src/ipc-framing.ts +295 -0
  15. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/src/listen-options.ts +3 -0
  16. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/src/socket-watchdog.test.ts +444 -0
  17. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/src/socket-watchdog.ts +236 -0
  18. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/ipc-server-utils/tsconfig.json +20 -0
  19. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/__tests__/contracts.test.ts +5 -2
  20. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/__tests__/remote-web-pairing.test.ts +17 -14
  21. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/channels.ts +0 -1
  22. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/cloud-credential.ts +5 -5
  23. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/ingress.ts +7 -3
  24. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +32 -70
  25. package/node_modules/@mycadet/ces-client/node_modules/@mycadet/service-contracts/src/rpc.ts +33 -3
  26. package/node_modules/@mycadet/ces-client/package.json +7 -2
  27. package/node_modules/@mycadet/ces-client/src/index.ts +6 -0
  28. package/node_modules/@mycadet/ces-client/src/ipc-credentials.ts +363 -0
  29. package/node_modules/@mycadet/ces-client/src/log-export.ts +187 -0
  30. package/node_modules/@mycadet/ces-client/src/socket-path.ts +34 -0
  31. package/node_modules/@mycadet/ces-client/src/test-support.ts +280 -0
  32. package/node_modules/@mycadet/environments/package.json +0 -1
  33. package/node_modules/@mycadet/environments/src/index.ts +7 -19
  34. package/node_modules/@mycadet/environments/src/shell.test.ts +0 -45
  35. package/node_modules/@mycadet/environments/src/shell.ts +0 -50
  36. package/node_modules/@mycadet/environments/src/test-path-guard.ts +1 -1
  37. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/__tests__/contracts.test.ts +5 -2
  38. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/__tests__/remote-web-pairing.test.ts +17 -14
  39. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/channels.ts +0 -1
  40. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/cloud-credential.ts +5 -5
  41. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/ingress.ts +7 -3
  42. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +32 -70
  43. package/node_modules/@mycadet/gateway-client/node_modules/@mycadet/service-contracts/src/rpc.ts +33 -3
  44. package/node_modules/@mycadet/gateway-client/src/__tests__/gateway-client.test.ts +5 -5
  45. package/node_modules/@mycadet/gateway-client/src/__tests__/package-boundary.test.ts +1 -1
  46. package/node_modules/@mycadet/gateway-client/src/__tests__/status-contracts.test.ts +1 -20
  47. package/node_modules/@mycadet/gateway-client/src/admission-policy-contract.ts +1 -2
  48. package/node_modules/@mycadet/gateway-client/src/gateway-ipc-contracts.ts +0 -16
  49. package/node_modules/@mycadet/ipc-server-utils/src/socket-watchdog.test.ts +1 -1
  50. package/node_modules/@mycadet/service-contracts/src/__tests__/contracts.test.ts +5 -2
  51. package/node_modules/@mycadet/service-contracts/src/__tests__/remote-web-pairing.test.ts +17 -14
  52. package/node_modules/@mycadet/service-contracts/src/channels.ts +0 -1
  53. package/node_modules/@mycadet/service-contracts/src/cloud-credential.ts +5 -5
  54. package/node_modules/@mycadet/service-contracts/src/ingress.ts +7 -3
  55. package/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +32 -70
  56. package/node_modules/@mycadet/service-contracts/src/rpc.ts +33 -3
  57. package/package.json +15 -13
  58. package/scripts/generate-openapi.ts +24 -32
  59. package/src/__tests__/actor-token-revocation.test.ts +14 -7
  60. package/src/__tests__/auto-approve-conversation-thresholds.test.ts +16 -16
  61. package/src/__tests__/auto-approve-thresholds.test.ts +22 -20
  62. package/src/__tests__/binding-helpers.test.ts +9 -12
  63. package/src/__tests__/channel-admission-policy-routes.test.ts +20 -34
  64. package/src/__tests__/channel-permission-overrides-routes.test.ts +20 -26
  65. package/src/__tests__/channel-verification-session-proxy.test.ts +36 -22
  66. package/src/__tests__/cli-entry-init.test.ts +103 -0
  67. package/src/__tests__/config.test.ts +4 -5
  68. package/src/__tests__/contact-handlers.test.ts +8 -10
  69. package/src/__tests__/contact-prompt-submit.test.ts +3 -1
  70. package/src/__tests__/contact-record-submit.test.ts +3 -1
  71. package/src/__tests__/contact-rich-read.test.ts +11 -20
  72. package/src/__tests__/contact-store-bind-principal.test.ts +12 -15
  73. package/src/__tests__/contact-store-invites.test.ts +6 -6
  74. package/src/__tests__/contact-store-mark-channel-verified.test.ts +8 -10
  75. package/src/__tests__/contact-store-merge-contacts.test.ts +7 -10
  76. package/src/__tests__/contact-store-mirror-op-missing.test.ts +7 -11
  77. package/src/__tests__/contacts-control-plane-proxy.test.ts +3 -21
  78. package/src/__tests__/contacts-info-client.test.ts +6 -5
  79. package/src/__tests__/contacts-info-joiner.test.ts +8 -13
  80. package/src/__tests__/contacts-scoped-route-fallthrough.test.ts +14 -12
  81. package/src/__tests__/credential-cache.test.ts +1 -6
  82. package/src/__tests__/credential-reader.test.ts +146 -157
  83. package/src/__tests__/credential-requests.test.ts +1 -3
  84. package/src/__tests__/credential-watcher-cloud-bootstrap.test.ts +57 -104
  85. package/src/__tests__/data-migration-m0007-backfill-ingress-invites.test.ts +14 -17
  86. package/src/__tests__/data-migration-m0008-upsert-acl-columns-from-assistant.test.ts +10 -13
  87. package/src/__tests__/data-migration-m0009-invite-fields-backfill.test.ts +20 -19
  88. package/src/__tests__/data-migration-m0010-drop-assistant-ingress-invites.test.ts +12 -15
  89. package/src/__tests__/data-migration-m0013-verification-sessions-backfill.test.ts +20 -23
  90. package/src/__tests__/data-migration-m0014-drop-assistant-verification-tables.test.ts +12 -15
  91. package/src/__tests__/data-migration-m0015-guardian-requests-backfill.test.ts +6 -9
  92. package/src/__tests__/data-migration-m0016-drop-assistant-guardian-tables.test.ts +16 -19
  93. package/src/__tests__/data-migration-m0017-coerce-escalate-policy.test.ts +6 -10
  94. package/src/__tests__/db-connection-isolation.test.ts +1 -2
  95. package/src/__tests__/db-proxy-allowlist.test.ts +25 -16
  96. package/src/__tests__/desktop-stream-websocket.test.ts +34 -28
  97. package/src/__tests__/device-identity-text.test.ts +4 -6
  98. package/src/__tests__/devices-mine.test.ts +12 -11
  99. package/src/__tests__/devices.test.ts +60 -260
  100. package/src/__tests__/discord-verification-contact-upgrade.test.ts +10 -13
  101. package/src/__tests__/edge-auth.test.ts +10 -148
  102. package/src/__tests__/edge-guardian-auth.test.ts +60 -44
  103. package/src/__tests__/guardian-binding-channel-reuse.test.ts +16 -18
  104. package/src/__tests__/guardian-bootstrap-binding.test.ts +7 -8
  105. package/src/__tests__/guardian-bootstrap-lookups.test.ts +25 -27
  106. package/src/__tests__/guardian-delivery-resolver.test.ts +8 -12
  107. package/src/__tests__/guardian-pin.test.ts +3 -1
  108. package/src/__tests__/handle-inbound-admission.test.ts +3 -12
  109. package/src/__tests__/handle-inbound-app-context.test.ts +3 -6
  110. package/src/__tests__/handle-inbound-invite-intercept.test.ts +3 -6
  111. package/src/__tests__/handle-inbound-trust-verdict.test.ts +3 -12
  112. package/src/__tests__/helpers/contact-route-table.ts +53 -32
  113. package/src/__tests__/helpers/env.ts +19 -0
  114. package/src/__tests__/helpers/gateway-config.ts +32 -0
  115. package/src/__tests__/helpers/remote-web-pairing-fixtures.ts +1 -7
  116. package/src/__tests__/helpers/signing-key.ts +27 -0
  117. package/src/__tests__/inbound-contact-seed.test.ts +7 -8
  118. package/src/__tests__/invite-redemption-engine-voice.test.ts +2 -3
  119. package/src/__tests__/invite-route-auth.test.ts +17 -15
  120. package/src/__tests__/ipc-contact-routes.test.ts +11 -19
  121. package/src/__tests__/ipc-contact-threshold.test.ts +16 -9
  122. package/src/__tests__/ipc-invite-routes.test.ts +6 -5
  123. package/src/__tests__/ipc-server-multi-client.test.ts +8 -1
  124. package/src/__tests__/ipc-server-watchdog.test.ts +16 -6
  125. package/src/__tests__/ipc-slack-thread-routes.test.ts +1 -2
  126. package/src/__tests__/ipc-voice-invite-routes.test.ts +3 -5
  127. package/src/__tests__/live-voice-websocket.test.ts +103 -95
  128. package/src/__tests__/load-guards.test.ts +0 -1
  129. package/src/__tests__/logger-retention.test.ts +11 -9
  130. package/src/__tests__/lum-2783-recovery-e2e.test.ts +3 -1
  131. package/src/__tests__/m0006-reconcile-contacts.test.ts +10 -13
  132. package/src/__tests__/oauth-callback.test.ts +13 -5
  133. package/src/__tests__/pair-origin-allowlist.test.ts +4 -118
  134. package/src/__tests__/rate-limit-loopback.test.ts +1 -5
  135. package/src/__tests__/refresh-device-binding.test.ts +3 -1
  136. package/src/__tests__/remote-web-pairing-challenge.test.ts +71 -132
  137. package/src/__tests__/remote-web-pairing-token.test.ts +16 -140
  138. package/src/__tests__/remote-web-pairing-verification.test.ts +17 -1
  139. package/src/__tests__/remote-web-public-base-url.test.ts +79 -0
  140. package/src/__tests__/resolve-assistant.test.ts +0 -1
  141. package/src/__tests__/runtime-client.test.ts +9 -9
  142. package/src/__tests__/runtime-health-proxy.test.ts +19 -14
  143. package/src/__tests__/runtime-proxy-auth.test.ts +129 -63
  144. package/src/__tests__/runtime-proxy-catchall-methods.test.ts +152 -0
  145. package/src/__tests__/runtime-proxy-device-stamp.test.ts +31 -24
  146. package/src/__tests__/runtime-proxy-error-body.test.ts +28 -30
  147. package/src/__tests__/runtime-proxy.test.ts +66 -59
  148. package/src/__tests__/runtime-stream-test-utils.ts +14 -3
  149. package/src/__tests__/seed-admission-policy.test.ts +1 -10
  150. package/src/__tests__/shared-invite-redeem.test.ts +7 -20
  151. package/src/__tests__/shared-invite-registration.test.ts +0 -34
  152. package/src/__tests__/slack-control-plane-proxy.test.ts +29 -17
  153. package/src/__tests__/slack-display-name.test.ts +3 -6
  154. package/src/__tests__/slack-normalize.test.ts +0 -1
  155. package/src/__tests__/slack-reaction-normalize.test.ts +0 -1
  156. package/src/__tests__/slack-socket-mode-catchup.test.ts +1 -2
  157. package/src/__tests__/slack-socket-mode-group-dm.test.ts +2 -3
  158. package/src/__tests__/slack-socket-mode-liveness.test.ts +6 -29
  159. package/src/__tests__/slack-socket-mode-outbound-root.test.ts +2 -3
  160. package/src/__tests__/slack-socket-mode-thread-tracking.test.ts +2 -3
  161. package/src/__tests__/sleep-wake-detector.test.ts +52 -25
  162. package/src/__tests__/speech-relay-websocket.test.ts +108 -100
  163. package/src/__tests__/stt-stream-websocket.test.ts +62 -69
  164. package/src/__tests__/telegram-control-plane-proxy.test.ts +36 -19
  165. package/src/__tests__/telegram-normalize.test.ts +1 -1
  166. package/src/__tests__/telegram-webhook-drop-visibility.test.ts +2 -3
  167. package/src/__tests__/telegram-webhook-handler.test.ts +121 -68
  168. package/src/__tests__/telegram-webhook-manager.test.ts +70 -90
  169. package/src/__tests__/test-preload.ts +21 -3
  170. package/src/__tests__/text-verification-helpers.test.ts +1 -1
  171. package/src/__tests__/trust-rules-route-auth.test.ts +16 -26
  172. package/src/__tests__/trust-rules-routes.test.ts +22 -25
  173. package/src/__tests__/twilio-media-websocket.test.ts +61 -59
  174. package/src/__tests__/twilio-webhooks.test.ts +5 -6
  175. package/src/__tests__/unversioned-api-fallthrough.test.ts +86 -0
  176. package/src/__tests__/upgrade-policy.test.ts +161 -0
  177. package/src/__tests__/upstream-transport.test.ts +20 -15
  178. package/src/__tests__/vercel-route-auth.test.ts +22 -36
  179. package/src/__tests__/watch-stream-websocket.test.ts +84 -91
  180. package/src/__tests__/whatsapp-download.test.ts +0 -1
  181. package/src/__tests__/whatsapp-webhook.test.ts +3 -3
  182. package/src/attachments/ingest.test.ts +0 -1
  183. package/src/auth/guardian-bootstrap.ts +5 -12
  184. package/src/auth/guardian-refresh.ts +0 -2
  185. package/src/auth/token-exchange.ts +23 -57
  186. package/src/auth/token-service.ts +69 -22
  187. package/src/auth-rate-limiter.ts +6 -0
  188. package/src/channels/inbound-event.test.ts +54 -0
  189. package/src/channels/inbound-event.ts +29 -3
  190. package/src/channels/ingress-verification.ts +10 -3
  191. package/src/channels/plugin-inbound.test.ts +4 -3
  192. package/src/channels/types.ts +0 -2
  193. package/src/cli/__tests__/contacts.test.ts +83 -60
  194. package/src/cli/__tests__/pairing.test.ts +230 -48
  195. package/src/cli/contacts.ts +0 -130
  196. package/src/cli/index.ts +20 -34
  197. package/src/cli/pairing.ts +118 -59
  198. package/src/cli/program.ts +227 -0
  199. package/src/cloud-features.ts +13 -0
  200. package/src/cloud-identity.ts +1 -1
  201. package/src/config-file-cache.ts +6 -0
  202. package/src/config-file-utils.ts +1 -1
  203. package/src/config-file-watcher.ts +104 -0
  204. package/src/config.ts +25 -23
  205. package/src/credential-cache.ts +6 -0
  206. package/src/credential-reader.ts +53 -35
  207. package/src/credential-watcher.ts +219 -22
  208. package/src/db/__tests__/session-store.test.ts +2 -1
  209. package/src/db/admission-policy-store.ts +1 -2
  210. package/src/db/connection.ts +12 -4
  211. package/src/db/contact-store.ts +82 -0
  212. package/src/db/data-migrations/m0002-actor-token-tables-to-gateway.ts +2 -7
  213. package/src/db/schema.ts +15 -0
  214. package/src/db/seed-admission-policy.ts +1 -1
  215. package/src/db/seed-trust-rules.ts +1 -4
  216. package/src/db/session-store.ts +0 -6
  217. package/src/discord/admission-log-visibility.test.ts +2 -2
  218. package/src/discord/forward.test.ts +3 -6
  219. package/src/discord/forward.ts +4 -8
  220. package/src/discord/lifecycle.ts +104 -0
  221. package/src/email/normalize.ts +1 -1
  222. package/src/email/register-callback.test.ts +1 -2
  223. package/src/email/register-callback.ts +4 -11
  224. package/src/guardian-contract.ts +30 -0
  225. package/src/handlers/handle-inbound.ts +2 -2
  226. package/src/http/browser-auth-cookies.ts +27 -22
  227. package/src/http/edge-forwarded-header.ts +0 -39
  228. package/src/http/loopback-guard.ts +0 -47
  229. package/src/http/middleware/auth.ts +35 -188
  230. package/src/http/middleware/cors.test.ts +66 -0
  231. package/src/http/middleware/cors.ts +23 -2
  232. package/src/http/router.ts +188 -151
  233. package/src/http/routes/assistant-handle.test.ts +133 -0
  234. package/src/http/routes/assistant-handle.ts +94 -0
  235. package/src/http/routes/audio-proxy.ts +49 -39
  236. package/src/http/routes/auto-approve-thresholds.ts +308 -230
  237. package/src/http/routes/brain-graph-proxy.ts +61 -52
  238. package/src/http/routes/channel-admission-policy.ts +219 -154
  239. package/src/http/routes/channel-ingress.test.ts +24 -19
  240. package/src/http/routes/channel-ingress.ts +255 -137
  241. package/src/http/routes/channel-permission-overrides.ts +189 -112
  242. package/src/http/routes/channel-readiness-proxy.ts +66 -45
  243. package/src/http/routes/channel-verification-session-proxy.test.ts +33 -82
  244. package/src/http/routes/channel-verification-session-proxy.ts +100 -455
  245. package/src/http/routes/cloud-hop.ts +138 -0
  246. package/src/http/routes/cloud-push-proxy.test.ts +34 -33
  247. package/src/http/routes/cloud-push-proxy.ts +56 -127
  248. package/src/http/routes/contacts-control-plane-proxy.ts +0 -12
  249. package/src/http/routes/contacts-control-plane-route-table.ts +372 -119
  250. package/src/http/routes/credential-entry-page.ts +12 -0
  251. package/src/http/routes/credential-requests.ts +10 -4
  252. package/src/http/routes/desktop-setup-proxy.ts +21 -11
  253. package/src/http/routes/desktop-stream-websocket.ts +67 -41
  254. package/src/http/routes/devices-mine.ts +11 -0
  255. package/src/http/routes/devices.ts +7 -63
  256. package/src/http/routes/email-webhook.test.ts +4 -20
  257. package/src/http/routes/guardian-channel-create.test.ts +6 -9
  258. package/src/http/routes/guardian-pin.ts +1 -1
  259. package/src/http/routes/guardian-refresh.ts +65 -2
  260. package/src/http/routes/index.ts +88 -0
  261. package/src/http/routes/ingress-domains.test.ts +57 -2
  262. package/src/http/routes/ingress-domains.ts +46 -14
  263. package/src/http/routes/integrations-status.ts +18 -0
  264. package/src/http/routes/ipc-runtime-proxy.test.ts +31 -6
  265. package/src/http/routes/ipc-runtime-proxy.ts +6 -3
  266. package/src/http/routes/live-voice-websocket.ts +159 -148
  267. package/src/http/routes/log-export.test.ts +61 -87
  268. package/src/http/routes/log-export.ts +143 -150
  269. package/src/http/routes/log-tail.test.ts +49 -32
  270. package/src/http/routes/log-tail.ts +31 -21
  271. package/src/http/routes/migration-rollback-proxy.ts +38 -32
  272. package/src/http/routes/oauth-apps-proxy.ts +109 -62
  273. package/src/http/routes/oauth-providers-proxy.ts +60 -51
  274. package/src/http/routes/pair.ts +23 -346
  275. package/src/http/routes/plugin-webhook-websocket.test.ts +73 -77
  276. package/src/http/routes/plugin-webhook-websocket.ts +210 -215
  277. package/src/http/routes/plugin-webhook.test.ts +3 -1
  278. package/src/http/routes/plugin-webhook.ts +0 -3
  279. package/src/http/routes/ps.ts +25 -20
  280. package/src/http/routes/regex-to-openapi-path.ts +39 -0
  281. package/src/http/routes/remote-web-pairing-challenge.ts +35 -81
  282. package/src/http/routes/remote-web-pairing-routes.ts +39 -0
  283. package/src/http/routes/remote-web-pairing-token.ts +6 -11
  284. package/src/http/routes/remote-web-pairing-verification.ts +7 -7
  285. package/src/http/routes/runtime-audio-stream.ts +147 -147
  286. package/src/http/routes/runtime-health-proxy.ts +43 -32
  287. package/src/http/routes/runtime-proxy.ts +54 -20
  288. package/src/http/routes/shared-invite-redeem.ts +1 -7
  289. package/src/http/routes/slack-control-plane-proxy.ts +57 -46
  290. package/src/http/routes/speech-relay-websocket.ts +310 -270
  291. package/src/http/routes/stt-stream-websocket.ts +102 -107
  292. package/src/http/routes/telegram-control-plane-proxy.ts +87 -58
  293. package/src/http/routes/telegram-webhook.test.ts +3 -19
  294. package/src/http/routes/telegram-webhook.ts +3 -2
  295. package/src/http/routes/terminal.test.ts +165 -0
  296. package/src/http/routes/terminal.ts +123 -0
  297. package/src/http/routes/trust-rules.suggest.test.ts +14 -22
  298. package/src/http/routes/trust-rules.ts +432 -246
  299. package/src/http/routes/tunnel-status.ts +26 -13
  300. package/src/http/routes/twilio-control-plane-proxy.ts +105 -64
  301. package/src/http/routes/twilio-media-websocket.ts +157 -147
  302. package/src/http/routes/twilio-voice-webhook.test.ts +14 -43
  303. package/src/http/routes/types.ts +92 -10
  304. package/src/http/routes/upgrade-broadcast-proxy.ts +38 -32
  305. package/src/http/routes/upgrade-policy.ts +186 -0
  306. package/src/http/routes/user-profile.test.ts +129 -0
  307. package/src/http/routes/user-profile.ts +204 -0
  308. package/src/http/routes/vercel-control-plane-proxy.ts +74 -52
  309. package/src/http/routes/watch-stream-websocket.ts +99 -138
  310. package/src/http/routes/webhook-routes.ts +214 -0
  311. package/src/http/routes/whatsapp-webhook.test.ts +3 -19
  312. package/src/http/routes/whatsapp-webhook.ts +2 -1
  313. package/src/http/routes/workspace-commit-proxy.ts +38 -30
  314. package/src/index.ts +298 -2481
  315. package/src/ipc/__tests__/admission-policy-handlers.test.ts +4 -18
  316. package/src/ipc/__tests__/guardian-request-routes.test.ts +7 -3
  317. package/src/ipc/__tests__/invite-ipc-routes.test.ts +13 -5
  318. package/src/ipc/__tests__/verification-session-routes.test.ts +5 -3
  319. package/src/ipc/admission-policy-handlers.ts +2 -2
  320. package/src/ipc/channel-socket-health-handlers.test.ts +56 -41
  321. package/src/ipc/channel-socket-health-handlers.ts +41 -31
  322. package/src/ipc/credential-request-handlers.ts +43 -19
  323. package/src/ipc/log-tail-handlers.test.ts +8 -35
  324. package/src/ipc/log-tail-handlers.ts +8 -11
  325. package/src/ipc/risk-classification-handlers.test.ts +0 -3
  326. package/src/ipc/risk-classification-handlers.ts +4 -4
  327. package/src/ipc/routes.ts +37 -0
  328. package/src/ipc/server.ts +13 -43
  329. package/src/ipc/trust-rules-handlers.test.ts +1 -2
  330. package/src/ipc/tunnel-handlers.ts +18 -18
  331. package/src/ipc/webhook-route-handlers.test.ts +5 -27
  332. package/src/ipc/webhook-route-handlers.ts +35 -39
  333. package/src/logger.ts +6 -26
  334. package/src/paths.ts +4 -4
  335. package/src/remote-web/pairing-challenge-store.ts +6 -35
  336. package/src/remote-web/pairing-mint.ts +2 -6
  337. package/src/remote-web/public-base-url.ts +65 -0
  338. package/src/risk/admission-policy-cache.ts +5 -12
  339. package/src/risk/bash-risk-classifier.test.ts +5 -6
  340. package/src/risk/bash-risk-classifier.ts +0 -3
  341. package/src/risk/command-registry/commands/gateway.ts +2 -1
  342. package/src/risk/file-risk-classifier.test.ts +1 -8
  343. package/src/risk/project-boundary.test.ts +3 -1
  344. package/src/risk/shell-identity.ts +1 -4
  345. package/src/risk/shell-parser.ts +1 -5
  346. package/src/risk/skill-risk-classifier.ts +1 -2
  347. package/src/runtime/client.ts +33 -27
  348. package/src/schema.ts +725 -163
  349. package/src/slack/errors.ts +1 -2
  350. package/src/slack/lifecycle.ts +327 -0
  351. package/src/slack/message-schemas.ts +1 -1
  352. package/src/slack/slack-web.ts +0 -1
  353. package/src/slack/socket-mode.ts +1 -1
  354. package/src/sleep-wake-detector.ts +62 -33
  355. package/src/telegram/normalize.test.ts +1 -1
  356. package/src/telegram/normalize.ts +1 -1
  357. package/src/telegram/send.test.ts +3 -19
  358. package/src/telegram/webhook-manager.ts +16 -31
  359. package/src/tunnel/allowed-paths.test.ts +27 -65
  360. package/src/tunnel/allowed-paths.ts +2 -27
  361. package/src/tunnel/binary-websocket.ts +1 -2
  362. package/src/tunnel/bridge-utils.ts +3 -8
  363. package/src/tunnel/client.test.ts +80 -67
  364. package/src/tunnel/client.ts +36 -28
  365. package/src/tunnel/http-bridge.test.ts +13 -40
  366. package/src/tunnel/websocket-bridge.test.ts +11 -2
  367. package/src/tunnel/websocket-bridge.ts +3 -1
  368. package/src/twilio/webhook-sync-trigger.ts +4 -4
  369. package/src/twilio/webhook-sync.test.ts +1 -33
  370. package/src/twilio/webhook-sync.ts +0 -4
  371. package/src/verification/code-parsing.ts +0 -3
  372. package/src/verification/rate-limit-helpers.ts +6 -2
  373. package/src/verification/session-service.ts +1 -1
  374. package/src/verification/shared-invite-registration.ts +3 -13
  375. package/src/verification/text-verification.ts +1 -1
  376. package/src/whatsapp/normalize.ts +1 -1
  377. package/node_modules/@mycadet/environments/src/__tests__/cloud-assistant-hub-url.test.ts +0 -38
  378. package/node_modules/@mycadet/environments/src/seeds.ts +0 -99
  379. package/node_modules/@mycadet/environments/src/types.ts +0 -70
  380. package/openapi.json +0 -2325
  381. package/src/__tests__/feature-flag-defaults-sync.test.ts +0 -44
  382. package/src/__tests__/feature-flag-resolver.test.ts +0 -151
  383. package/src/__tests__/feature-flag-watcher-callback.test.ts +0 -63
  384. package/src/__tests__/feature-flags-route.test.ts +0 -764
  385. package/src/__tests__/guardian-init-lockfile.test.ts +0 -883
  386. package/src/__tests__/ipc-feature-flag-routes.test.ts +0 -240
  387. package/src/__tests__/pair-device-bound.test.ts +0 -296
  388. package/src/__tests__/remote-web-ingress-denylist.test.ts +0 -113
  389. package/src/__tests__/remote-web-pairing-requests.test.ts +0 -277
  390. package/src/__tests__/route-schema-guard.test.ts +0 -489
  391. package/src/cloud-user-id.ts +0 -12
  392. package/src/feature-flag-defaults.ts +0 -197
  393. package/src/feature-flag-env-overrides.test.ts +0 -166
  394. package/src/feature-flag-env-overrides.ts +0 -58
  395. package/src/feature-flag-registry.json +0 -506
  396. package/src/feature-flag-resolver.ts +0 -47
  397. package/src/feature-flag-store.ts +0 -115
  398. package/src/feature-flag-watcher.ts +0 -105
  399. package/src/http/routes/a2a-routes.test.ts +0 -146
  400. package/src/http/routes/a2a-routes.ts +0 -126
  401. package/src/http/routes/auto-approve-thresholds-routes.ts +0 -92
  402. package/src/http/routes/channel-admission-policy-routes.ts +0 -67
  403. package/src/http/routes/channel-ingress-routes.ts +0 -135
  404. package/src/http/routes/channel-permission-overrides-routes.ts +0 -92
  405. package/src/http/routes/contacts-control-plane-routes.ts +0 -278
  406. package/src/http/routes/feature-flags.ts +0 -185
  407. package/src/http/routes/remote-web-pairing-requests.ts +0 -123
  408. package/src/http/routes/trust-rules-routes.ts +0 -188
  409. package/src/ipc/feature-flag-handlers.ts +0 -63
  410. package/src/types.ts +0 -11
package/openapi.json DELETED
@@ -1,2325 +0,0 @@
1
- {
2
- "openapi": "3.1.0",
3
- "info": {
4
- "title": "Cadet Gateway API",
5
- "version": "0.12.9",
6
- "description": "Auto-generated OpenAPI specification for the Cadet Gateway HTTP endpoints."
7
- },
8
- "servers": [{ "url": "", "description": "Same-origin — the gateway" }],
9
- "paths": {
10
- "/v1/permissions/thresholds": {
11
- "get": {
12
- "operationId": "permissionsThresholdsGet",
13
- "summary": "Get global auto-approve thresholds",
14
- "tags": ["permissions"],
15
- "responses": {
16
- "200": {
17
- "description": "Successful response",
18
- "content": {
19
- "application/json": {
20
- "schema": {
21
- "type": "object",
22
- "properties": {
23
- "interactive": {
24
- "type": "string",
25
- "enum": ["none", "low", "medium", "high"]
26
- },
27
- "autonomous": {
28
- "type": "string",
29
- "enum": ["none", "low", "medium", "high"]
30
- },
31
- "headless": {
32
- "type": "string",
33
- "enum": ["none", "low", "medium", "high"]
34
- }
35
- },
36
- "required": ["interactive", "autonomous", "headless"],
37
- "additionalProperties": false
38
- }
39
- }
40
- }
41
- }
42
- }
43
- },
44
- "put": {
45
- "operationId": "permissionsThresholdsPut",
46
- "summary": "Update global auto-approve thresholds",
47
- "tags": ["permissions"],
48
- "description": "Partial update — omitted modes keep their current value. Returns the full post-update set.",
49
- "requestBody": {
50
- "required": true,
51
- "content": {
52
- "application/json": {
53
- "schema": {
54
- "type": "object",
55
- "properties": {
56
- "interactive": {
57
- "type": "string",
58
- "enum": ["none", "low", "medium", "high"]
59
- },
60
- "autonomous": {
61
- "type": "string",
62
- "enum": ["none", "low", "medium", "high"]
63
- },
64
- "headless": {
65
- "type": "string",
66
- "enum": ["none", "low", "medium", "high"]
67
- }
68
- }
69
- }
70
- }
71
- }
72
- },
73
- "responses": {
74
- "200": {
75
- "description": "Successful response",
76
- "content": {
77
- "application/json": {
78
- "schema": {
79
- "type": "object",
80
- "properties": {
81
- "interactive": {
82
- "type": "string",
83
- "enum": ["none", "low", "medium", "high"]
84
- },
85
- "autonomous": {
86
- "type": "string",
87
- "enum": ["none", "low", "medium", "high"]
88
- },
89
- "headless": {
90
- "type": "string",
91
- "enum": ["none", "low", "medium", "high"]
92
- }
93
- },
94
- "required": ["interactive", "autonomous", "headless"],
95
- "additionalProperties": false
96
- }
97
- }
98
- }
99
- }
100
- }
101
- }
102
- },
103
- "/v1/permissions/thresholds/conversations/{conversation_id}": {
104
- "get": {
105
- "operationId": "conversationThresholdGet",
106
- "summary": "Get a conversation's threshold override",
107
- "tags": ["permissions"],
108
- "description": "Returns { threshold: null } when no override exists. Gateways predating that behavior returned 404 for the same condition; clients tolerate both during rollout.",
109
- "parameters": [
110
- {
111
- "name": "conversation_id",
112
- "in": "path",
113
- "required": true,
114
- "schema": { "type": "string" },
115
- "description": "The conversation id"
116
- }
117
- ],
118
- "responses": {
119
- "200": {
120
- "description": "Successful response",
121
- "content": {
122
- "application/json": {
123
- "schema": {
124
- "type": "object",
125
- "properties": {
126
- "threshold": {
127
- "anyOf": [{ "type": "string" }, { "type": "null" }]
128
- }
129
- },
130
- "required": ["threshold"],
131
- "additionalProperties": false
132
- }
133
- }
134
- }
135
- }
136
- }
137
- },
138
- "put": {
139
- "operationId": "conversationThresholdPut",
140
- "summary": "Set a conversation's threshold override",
141
- "tags": ["permissions"],
142
- "parameters": [
143
- {
144
- "name": "conversation_id",
145
- "in": "path",
146
- "required": true,
147
- "schema": { "type": "string" },
148
- "description": "The conversation id"
149
- }
150
- ],
151
- "requestBody": {
152
- "required": true,
153
- "content": {
154
- "application/json": {
155
- "schema": {
156
- "type": "object",
157
- "properties": {
158
- "threshold": {
159
- "type": "string",
160
- "enum": ["none", "low", "medium", "high"]
161
- }
162
- },
163
- "required": ["threshold"]
164
- }
165
- }
166
- }
167
- },
168
- "responses": {
169
- "200": {
170
- "description": "Successful response",
171
- "content": {
172
- "application/json": {
173
- "schema": {
174
- "type": "object",
175
- "properties": {
176
- "conversationId": { "type": "string" },
177
- "threshold": {
178
- "type": "string",
179
- "enum": ["none", "low", "medium", "high"]
180
- }
181
- },
182
- "required": ["conversationId", "threshold"],
183
- "additionalProperties": false
184
- }
185
- }
186
- }
187
- }
188
- }
189
- },
190
- "delete": {
191
- "operationId": "conversationThresholdDelete",
192
- "summary": "Clear a conversation's threshold override",
193
- "tags": ["permissions"],
194
- "description": "Idempotent — succeeds even when no override exists.",
195
- "parameters": [
196
- {
197
- "name": "conversation_id",
198
- "in": "path",
199
- "required": true,
200
- "schema": { "type": "string" },
201
- "description": "The conversation id"
202
- }
203
- ],
204
- "responses": { "204": { "description": "Successful response" } }
205
- }
206
- },
207
- "/v1/channel-admission-policy": {
208
- "get": {
209
- "operationId": "channelAdmissionPolicyList",
210
- "summary": "List per-channel admission floors",
211
- "tags": ["channel-admission-policy"],
212
- "description": "Returns one entry per enforced channel, excluding exempt and hidden channels, seeded with defaults for channels without a stored row.",
213
- "responses": {
214
- "200": {
215
- "description": "Successful response",
216
- "content": {
217
- "application/json": {
218
- "schema": {
219
- "type": "object",
220
- "properties": {
221
- "policies": {
222
- "type": "array",
223
- "items": {
224
- "type": "object",
225
- "properties": {
226
- "channelType": { "type": "string" },
227
- "policy": {
228
- "type": "string",
229
- "enum": [
230
- "no_one",
231
- "guardian_only",
232
- "trusted_contacts",
233
- "any_contact",
234
- "strangers"
235
- ]
236
- },
237
- "note": {
238
- "anyOf": [{ "type": "string" }, { "type": "null" }]
239
- },
240
- "updatedAt": {
241
- "anyOf": [{ "type": "number" }, { "type": "null" }]
242
- }
243
- },
244
- "required": [
245
- "channelType",
246
- "policy",
247
- "note",
248
- "updatedAt"
249
- ],
250
- "additionalProperties": false
251
- }
252
- }
253
- },
254
- "required": ["policies"],
255
- "additionalProperties": false
256
- }
257
- }
258
- }
259
- }
260
- }
261
- }
262
- },
263
- "/v1/channel-admission-policy/{channel_type}": {
264
- "put": {
265
- "operationId": "channelAdmissionPolicySet",
266
- "summary": "Set a channel's admission floor",
267
- "tags": ["channel-admission-policy"],
268
- "description": "Upserts the channel's admission policy. Exempt and hidden channels return 403.",
269
- "parameters": [
270
- {
271
- "name": "channel_type",
272
- "in": "path",
273
- "required": true,
274
- "schema": { "type": "string" },
275
- "description": "The channel type, e.g. slack"
276
- }
277
- ],
278
- "requestBody": {
279
- "required": true,
280
- "content": {
281
- "application/json": {
282
- "schema": {
283
- "type": "object",
284
- "properties": {
285
- "policy": {
286
- "type": "string",
287
- "enum": [
288
- "no_one",
289
- "guardian_only",
290
- "trusted_contacts",
291
- "any_contact",
292
- "strangers"
293
- ]
294
- },
295
- "note": {
296
- "anyOf": [{ "type": "string" }, { "type": "null" }]
297
- }
298
- },
299
- "required": ["policy"]
300
- }
301
- }
302
- }
303
- },
304
- "responses": {
305
- "200": {
306
- "description": "Successful response",
307
- "content": {
308
- "application/json": {
309
- "schema": {
310
- "type": "object",
311
- "properties": {
312
- "policy": {
313
- "type": "object",
314
- "properties": {
315
- "channelType": { "type": "string" },
316
- "policy": {
317
- "type": "string",
318
- "enum": [
319
- "no_one",
320
- "guardian_only",
321
- "trusted_contacts",
322
- "any_contact",
323
- "strangers"
324
- ]
325
- },
326
- "note": {
327
- "anyOf": [{ "type": "string" }, { "type": "null" }]
328
- },
329
- "updatedAt": {
330
- "anyOf": [{ "type": "number" }, { "type": "null" }]
331
- }
332
- },
333
- "required": [
334
- "channelType",
335
- "policy",
336
- "note",
337
- "updatedAt"
338
- ],
339
- "additionalProperties": false
340
- }
341
- },
342
- "required": ["policy"],
343
- "additionalProperties": false
344
- }
345
- }
346
- }
347
- }
348
- }
349
- }
350
- },
351
- "/v1/channel-ingress": {
352
- "get": {
353
- "operationId": "channelIngressList",
354
- "summary": "List ingress declarations and their approval state",
355
- "tags": ["channel-ingress"],
356
- "description": "Every declaration the gateway can see, each with the digest a guardian would approve, the public paths it would open, and the credential its signatures are verified against. This is the only way to learn that a declaration is waiting: on the public surface a route held back by approval 404s exactly like one nobody declared.",
357
- "responses": {
358
- "200": {
359
- "description": "Successful response",
360
- "content": {
361
- "application/json": {
362
- "schema": {
363
- "type": "object",
364
- "properties": {
365
- "sources": {
366
- "type": "array",
367
- "items": {
368
- "type": "object",
369
- "properties": {
370
- "source": { "type": "string" },
371
- "state": {
372
- "type": "string",
373
- "enum": ["approved", "pending"]
374
- },
375
- "digest": { "type": "string" },
376
- "approvedAt": { "type": "number" },
377
- "approvedDigest": { "type": "string" },
378
- "routes": {
379
- "type": "array",
380
- "items": {
381
- "type": "object",
382
- "properties": {
383
- "path": { "type": "string" },
384
- "publicPath": { "type": "string" },
385
- "kind": { "type": "string" },
386
- "signer": { "type": "string" },
387
- "handshake": { "type": "string" },
388
- "description": { "type": "string" },
389
- "credential": { "type": "string" },
390
- "served": { "type": "boolean" },
391
- "deliversInbound": { "type": "boolean" },
392
- "verification": {
393
- "type": "object",
394
- "properties": {
395
- "algorithm": { "type": "string" },
396
- "signatureHeader": { "type": "string" }
397
- },
398
- "required": ["algorithm", "signatureHeader"],
399
- "additionalProperties": false
400
- }
401
- },
402
- "required": [
403
- "path",
404
- "publicPath",
405
- "kind",
406
- "signer",
407
- "handshake",
408
- "description",
409
- "credential",
410
- "served",
411
- "deliversInbound"
412
- ],
413
- "additionalProperties": false
414
- }
415
- }
416
- },
417
- "required": ["source", "state", "digest", "routes"],
418
- "additionalProperties": false
419
- }
420
- },
421
- "problems": {
422
- "type": "array",
423
- "items": {
424
- "type": "object",
425
- "properties": {
426
- "source": { "type": "string" },
427
- "reason": { "type": "string" }
428
- },
429
- "required": ["source", "reason"],
430
- "additionalProperties": false
431
- }
432
- }
433
- },
434
- "required": ["sources", "problems"],
435
- "additionalProperties": false
436
- }
437
- }
438
- }
439
- }
440
- }
441
- }
442
- },
443
- "/v1/channel-ingress/{source}/approve": {
444
- "post": {
445
- "operationId": "channelIngressApprove",
446
- "summary": "Approve an ingress declaration",
447
- "tags": ["channel-ingress"],
448
- "description": "Records the guardian's approval of the declaration identified by the body's digest, after which the gateway serves its routes. Returns 409 when the digest is not what the source currently declares, and 404 when it declares nothing servable.",
449
- "parameters": [
450
- {
451
- "name": "source",
452
- "in": "path",
453
- "required": true,
454
- "schema": { "type": "string" },
455
- "description": "The declaring ingress source, today a plugin name"
456
- }
457
- ],
458
- "requestBody": {
459
- "required": true,
460
- "content": {
461
- "application/json": {
462
- "schema": {
463
- "type": "object",
464
- "properties": {
465
- "digest": { "type": "string", "pattern": "^[0-9a-f]{32}$" }
466
- },
467
- "required": ["digest"]
468
- }
469
- }
470
- }
471
- },
472
- "responses": {
473
- "200": {
474
- "description": "Successful response",
475
- "content": {
476
- "application/json": {
477
- "schema": {
478
- "type": "object",
479
- "properties": {
480
- "source": { "type": "string" },
481
- "digest": { "type": "string" },
482
- "approvedAt": { "type": "number" }
483
- },
484
- "required": ["source", "digest", "approvedAt"],
485
- "additionalProperties": false
486
- }
487
- }
488
- }
489
- }
490
- }
491
- }
492
- },
493
- "/v1/channel-ingress/{source}/revoke": {
494
- "post": {
495
- "operationId": "channelIngressRevoke",
496
- "summary": "Revoke an ingress approval",
497
- "tags": ["channel-ingress"],
498
- "description": "Withdraws the source's grant, after which its routes stop being served. Reports whether there was a grant to withdraw. Succeeds even when the declaration itself has become unreadable.",
499
- "parameters": [
500
- {
501
- "name": "source",
502
- "in": "path",
503
- "required": true,
504
- "schema": { "type": "string" },
505
- "description": "The declaring ingress source, today a plugin name"
506
- }
507
- ],
508
- "responses": {
509
- "200": {
510
- "description": "Successful response",
511
- "content": {
512
- "application/json": {
513
- "schema": {
514
- "type": "object",
515
- "properties": {
516
- "source": { "type": "string" },
517
- "revoked": { "type": "boolean" }
518
- },
519
- "required": ["source", "revoked"],
520
- "additionalProperties": false
521
- }
522
- }
523
- }
524
- }
525
- }
526
- }
527
- },
528
- "/v1/channel-permission-overrides": {
529
- "get": {
530
- "operationId": "channelPermissionOverridesList",
531
- "summary": "List channel-permission matrix cells",
532
- "tags": ["channel-permission-overrides"],
533
- "description": "Returns every persisted cell in the cascade selector × contact-type → RiskThreshold map. Unset cells fall through the cascade; the list contains only explicit overrides.",
534
- "responses": {
535
- "200": {
536
- "description": "Successful response",
537
- "content": {
538
- "application/json": {
539
- "schema": {
540
- "type": "object",
541
- "properties": {
542
- "cells": {
543
- "type": "array",
544
- "items": {
545
- "type": "object",
546
- "properties": {
547
- "selector": {
548
- "oneOf": [
549
- {
550
- "type": "object",
551
- "properties": {
552
- "scope": {
553
- "type": "string",
554
- "const": "workspace"
555
- }
556
- },
557
- "required": ["scope"],
558
- "additionalProperties": false
559
- },
560
- {
561
- "type": "object",
562
- "properties": {
563
- "scope": {
564
- "type": "string",
565
- "const": "adapter"
566
- },
567
- "adapter": {
568
- "type": "string",
569
- "minLength": 1
570
- }
571
- },
572
- "required": ["scope", "adapter"],
573
- "additionalProperties": false
574
- },
575
- {
576
- "type": "object",
577
- "properties": {
578
- "scope": {
579
- "type": "string",
580
- "const": "channel_type"
581
- },
582
- "adapter": {
583
- "type": "string",
584
- "minLength": 1
585
- },
586
- "channelType": {
587
- "type": "string",
588
- "enum": ["dm", "private", "public"]
589
- }
590
- },
591
- "required": ["scope", "adapter", "channelType"],
592
- "additionalProperties": false
593
- },
594
- {
595
- "type": "object",
596
- "properties": {
597
- "scope": {
598
- "type": "string",
599
- "const": "channel"
600
- },
601
- "adapter": {
602
- "type": "string",
603
- "minLength": 1
604
- },
605
- "channelExternalId": {
606
- "type": "string",
607
- "minLength": 1
608
- }
609
- },
610
- "required": [
611
- "scope",
612
- "adapter",
613
- "channelExternalId"
614
- ],
615
- "additionalProperties": false
616
- }
617
- ],
618
- "type": "object"
619
- },
620
- "contactType": {
621
- "type": "string",
622
- "enum": [
623
- "guardian",
624
- "trusted_contact",
625
- "unverified_contact",
626
- "unknown"
627
- ]
628
- },
629
- "threshold": {
630
- "type": "string",
631
- "enum": ["none", "low", "medium", "high"]
632
- },
633
- "note": {
634
- "anyOf": [{ "type": "string" }, { "type": "null" }]
635
- },
636
- "updatedAt": { "type": "number" }
637
- },
638
- "required": [
639
- "selector",
640
- "contactType",
641
- "threshold",
642
- "updatedAt"
643
- ],
644
- "additionalProperties": false
645
- }
646
- }
647
- },
648
- "required": ["cells"],
649
- "additionalProperties": false
650
- }
651
- }
652
- }
653
- }
654
- }
655
- },
656
- "put": {
657
- "operationId": "channelPermissionOverrideSet",
658
- "summary": "Upsert a channel-permission matrix cell",
659
- "tags": ["channel-permission-overrides"],
660
- "description": "Upserts one cell, identified by the selector × contact-type in the body. The adapter must be a known channel id.",
661
- "requestBody": {
662
- "required": true,
663
- "content": {
664
- "application/json": {
665
- "schema": {
666
- "type": "object",
667
- "properties": {
668
- "selector": {
669
- "oneOf": [
670
- {
671
- "type": "object",
672
- "properties": {
673
- "scope": { "type": "string", "const": "workspace" }
674
- },
675
- "required": ["scope"],
676
- "additionalProperties": false
677
- },
678
- {
679
- "type": "object",
680
- "properties": {
681
- "scope": { "type": "string", "const": "adapter" },
682
- "adapter": { "type": "string", "minLength": 1 }
683
- },
684
- "required": ["scope", "adapter"],
685
- "additionalProperties": false
686
- },
687
- {
688
- "type": "object",
689
- "properties": {
690
- "scope": {
691
- "type": "string",
692
- "const": "channel_type"
693
- },
694
- "adapter": { "type": "string", "minLength": 1 },
695
- "channelType": {
696
- "type": "string",
697
- "enum": ["dm", "private", "public"]
698
- }
699
- },
700
- "required": ["scope", "adapter", "channelType"],
701
- "additionalProperties": false
702
- },
703
- {
704
- "type": "object",
705
- "properties": {
706
- "scope": { "type": "string", "const": "channel" },
707
- "adapter": { "type": "string", "minLength": 1 },
708
- "channelExternalId": {
709
- "type": "string",
710
- "minLength": 1
711
- }
712
- },
713
- "required": ["scope", "adapter", "channelExternalId"],
714
- "additionalProperties": false
715
- }
716
- ],
717
- "type": "object"
718
- },
719
- "contactType": {
720
- "type": "string",
721
- "enum": [
722
- "guardian",
723
- "trusted_contact",
724
- "unverified_contact",
725
- "unknown"
726
- ]
727
- },
728
- "threshold": {
729
- "type": "string",
730
- "enum": ["none", "low", "medium", "high"]
731
- },
732
- "note": {
733
- "anyOf": [{ "type": "string" }, { "type": "null" }]
734
- }
735
- },
736
- "required": ["selector", "contactType", "threshold"]
737
- }
738
- }
739
- }
740
- },
741
- "responses": {
742
- "200": {
743
- "description": "Successful response",
744
- "content": {
745
- "application/json": {
746
- "schema": {
747
- "type": "object",
748
- "properties": {
749
- "cell": {
750
- "type": "object",
751
- "properties": {
752
- "selector": {
753
- "oneOf": [
754
- {
755
- "type": "object",
756
- "properties": {
757
- "scope": {
758
- "type": "string",
759
- "const": "workspace"
760
- }
761
- },
762
- "required": ["scope"],
763
- "additionalProperties": false
764
- },
765
- {
766
- "type": "object",
767
- "properties": {
768
- "scope": {
769
- "type": "string",
770
- "const": "adapter"
771
- },
772
- "adapter": { "type": "string", "minLength": 1 }
773
- },
774
- "required": ["scope", "adapter"],
775
- "additionalProperties": false
776
- },
777
- {
778
- "type": "object",
779
- "properties": {
780
- "scope": {
781
- "type": "string",
782
- "const": "channel_type"
783
- },
784
- "adapter": { "type": "string", "minLength": 1 },
785
- "channelType": {
786
- "type": "string",
787
- "enum": ["dm", "private", "public"]
788
- }
789
- },
790
- "required": ["scope", "adapter", "channelType"],
791
- "additionalProperties": false
792
- },
793
- {
794
- "type": "object",
795
- "properties": {
796
- "scope": {
797
- "type": "string",
798
- "const": "channel"
799
- },
800
- "adapter": { "type": "string", "minLength": 1 },
801
- "channelExternalId": {
802
- "type": "string",
803
- "minLength": 1
804
- }
805
- },
806
- "required": [
807
- "scope",
808
- "adapter",
809
- "channelExternalId"
810
- ],
811
- "additionalProperties": false
812
- }
813
- ],
814
- "type": "object"
815
- },
816
- "contactType": {
817
- "type": "string",
818
- "enum": [
819
- "guardian",
820
- "trusted_contact",
821
- "unverified_contact",
822
- "unknown"
823
- ]
824
- },
825
- "threshold": {
826
- "type": "string",
827
- "enum": ["none", "low", "medium", "high"]
828
- },
829
- "note": {
830
- "anyOf": [{ "type": "string" }, { "type": "null" }]
831
- },
832
- "updatedAt": { "type": "number" }
833
- },
834
- "required": [
835
- "selector",
836
- "contactType",
837
- "threshold",
838
- "updatedAt"
839
- ],
840
- "additionalProperties": false
841
- }
842
- },
843
- "required": ["cell"],
844
- "additionalProperties": false
845
- }
846
- }
847
- }
848
- }
849
- }
850
- }
851
- },
852
- "/v1/channel-permission-overrides/resolve": {
853
- "post": {
854
- "operationId": "channelPermissionResolve",
855
- "summary": "Resolve the effective channel-permission threshold",
856
- "tags": ["channel-permission-overrides"],
857
- "description": "Read-only cascade resolution for one coordinate: walks channel → channel_type → adapter → workspace for the given selector keys and contact-type, returning the winning cell's threshold and scope, or null when no cell matches, in which case the caller falls through to the global thresholds. Same resolver the runtime evaluator uses over IPC.",
858
- "requestBody": {
859
- "required": true,
860
- "content": {
861
- "application/json": {
862
- "schema": {
863
- "type": "object",
864
- "properties": {
865
- "adapter": { "type": "string", "minLength": 1 },
866
- "channelType": {
867
- "type": "string",
868
- "enum": ["dm", "private", "public"]
869
- },
870
- "channelExternalId": { "type": "string", "minLength": 1 },
871
- "contactType": {
872
- "type": "string",
873
- "enum": [
874
- "guardian",
875
- "trusted_contact",
876
- "unverified_contact",
877
- "unknown"
878
- ]
879
- }
880
- },
881
- "required": ["adapter", "contactType"]
882
- }
883
- }
884
- }
885
- },
886
- "responses": {
887
- "200": {
888
- "description": "Successful response",
889
- "content": {
890
- "application/json": {
891
- "schema": {
892
- "type": "object",
893
- "properties": {
894
- "resolved": {
895
- "anyOf": [
896
- {
897
- "type": "object",
898
- "properties": {
899
- "threshold": {
900
- "type": "string",
901
- "enum": ["none", "low", "medium", "high"]
902
- },
903
- "scope": {
904
- "type": "string",
905
- "enum": [
906
- "workspace",
907
- "adapter",
908
- "channel_type",
909
- "channel"
910
- ]
911
- }
912
- },
913
- "required": ["threshold", "scope"],
914
- "additionalProperties": false
915
- },
916
- { "type": "null" }
917
- ]
918
- }
919
- },
920
- "required": ["resolved"],
921
- "additionalProperties": false
922
- }
923
- }
924
- }
925
- }
926
- }
927
- }
928
- },
929
- "/v1/channel-permission-overrides/delete": {
930
- "post": {
931
- "operationId": "channelPermissionOverrideDelete",
932
- "summary": "Delete a channel-permission matrix cell",
933
- "tags": ["channel-permission-overrides"],
934
- "description": "Removes one cell by its composite key, selector × contact-type, letting the next cascade tier up win. Returns whether a cell was removed.",
935
- "requestBody": {
936
- "required": true,
937
- "content": {
938
- "application/json": {
939
- "schema": {
940
- "type": "object",
941
- "properties": {
942
- "selector": {
943
- "oneOf": [
944
- {
945
- "type": "object",
946
- "properties": {
947
- "scope": { "type": "string", "const": "workspace" }
948
- },
949
- "required": ["scope"],
950
- "additionalProperties": false
951
- },
952
- {
953
- "type": "object",
954
- "properties": {
955
- "scope": { "type": "string", "const": "adapter" },
956
- "adapter": { "type": "string", "minLength": 1 }
957
- },
958
- "required": ["scope", "adapter"],
959
- "additionalProperties": false
960
- },
961
- {
962
- "type": "object",
963
- "properties": {
964
- "scope": {
965
- "type": "string",
966
- "const": "channel_type"
967
- },
968
- "adapter": { "type": "string", "minLength": 1 },
969
- "channelType": {
970
- "type": "string",
971
- "enum": ["dm", "private", "public"]
972
- }
973
- },
974
- "required": ["scope", "adapter", "channelType"],
975
- "additionalProperties": false
976
- },
977
- {
978
- "type": "object",
979
- "properties": {
980
- "scope": { "type": "string", "const": "channel" },
981
- "adapter": { "type": "string", "minLength": 1 },
982
- "channelExternalId": {
983
- "type": "string",
984
- "minLength": 1
985
- }
986
- },
987
- "required": ["scope", "adapter", "channelExternalId"],
988
- "additionalProperties": false
989
- }
990
- ],
991
- "type": "object"
992
- },
993
- "contactType": {
994
- "type": "string",
995
- "enum": [
996
- "guardian",
997
- "trusted_contact",
998
- "unverified_contact",
999
- "unknown"
1000
- ]
1001
- }
1002
- },
1003
- "required": ["selector", "contactType"]
1004
- }
1005
- }
1006
- }
1007
- },
1008
- "responses": {
1009
- "200": {
1010
- "description": "Successful response",
1011
- "content": {
1012
- "application/json": {
1013
- "schema": {
1014
- "type": "object",
1015
- "properties": { "removed": { "type": "boolean" } },
1016
- "required": ["removed"],
1017
- "additionalProperties": false
1018
- }
1019
- }
1020
- }
1021
- }
1022
- }
1023
- }
1024
- },
1025
- "/v1/contacts": {
1026
- "post": {
1027
- "operationId": "contactsUpsert",
1028
- "summary": "Create or update a contact",
1029
- "tags": ["contacts"],
1030
- "description": "Gateway-native contact upsert that dual-writes the gateway ACL store and the assistant info mirror. Matches by id, then by the provided type and address channel, else creates.",
1031
- "requestBody": {
1032
- "required": true,
1033
- "content": {
1034
- "application/json": {
1035
- "schema": {
1036
- "type": "object",
1037
- "properties": {
1038
- "id": {
1039
- "description": "Existing contact id to update; omit to create or match by channel",
1040
- "type": "string"
1041
- },
1042
- "displayName": {
1043
- "type": "string",
1044
- "minLength": 1,
1045
- "description": "Required on every upsert, including updates by id"
1046
- },
1047
- "notes": {
1048
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1049
- },
1050
- "autoApproveThreshold": {
1051
- "description": "Per-contact auto-approve ceiling. Omit to preserve; null clears.",
1052
- "anyOf": [
1053
- {
1054
- "type": "string",
1055
- "enum": ["none", "low", "medium", "high"]
1056
- },
1057
- { "type": "null" }
1058
- ]
1059
- },
1060
- "contactType": { "type": "string" },
1061
- "assistantMetadata": {
1062
- "description": "Required when contactType is 'assistant'",
1063
- "type": "object",
1064
- "properties": {
1065
- "species": { "type": "string" },
1066
- "metadata": {
1067
- "anyOf": [
1068
- {
1069
- "type": "object",
1070
- "propertyNames": { "type": "string" },
1071
- "additionalProperties": {}
1072
- },
1073
- { "type": "null" }
1074
- ]
1075
- }
1076
- },
1077
- "required": ["species"]
1078
- },
1079
- "channels": {
1080
- "type": "array",
1081
- "items": {
1082
- "type": "object",
1083
- "properties": {
1084
- "type": { "type": "string" },
1085
- "address": { "type": "string" },
1086
- "isPrimary": { "type": "boolean" },
1087
- "externalChatId": {
1088
- "description": "Delivery chat id. Omit to preserve the stored value. A legacy explicit null is accepted for compatibility and treated as omitted; clearing is not supported: a stored null is indistinguishable from never-learned, so no consumer could tell a clear from a gap.",
1089
- "type": "string"
1090
- },
1091
- "status": { "type": "string" },
1092
- "policy": { "type": "string" }
1093
- },
1094
- "required": ["type", "address"]
1095
- }
1096
- }
1097
- },
1098
- "required": ["displayName"]
1099
- }
1100
- }
1101
- }
1102
- },
1103
- "responses": {
1104
- "200": {
1105
- "description": "Successful response",
1106
- "content": {
1107
- "application/json": {
1108
- "schema": {
1109
- "type": "object",
1110
- "properties": {
1111
- "ok": { "type": "boolean" },
1112
- "contact": {
1113
- "type": "object",
1114
- "properties": {
1115
- "id": { "type": "string" },
1116
- "displayName": { "type": "string" },
1117
- "role": { "type": "string" },
1118
- "notes": {
1119
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1120
- },
1121
- "contactType": {
1122
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1123
- },
1124
- "principalId": {
1125
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1126
- },
1127
- "userFile": {
1128
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1129
- },
1130
- "createdAt": { "type": "number" },
1131
- "updatedAt": { "type": "number" },
1132
- "interactionCount": { "type": "number" },
1133
- "lastInteraction": {
1134
- "anyOf": [{ "type": "number" }, { "type": "null" }]
1135
- },
1136
- "autoApproveThreshold": {
1137
- "anyOf": [
1138
- {
1139
- "type": "string",
1140
- "enum": ["none", "low", "medium", "high"]
1141
- },
1142
- { "type": "null" }
1143
- ],
1144
- "description": "Per-contact auto-approve ceiling. Null means unset, inheriting the cascade."
1145
- },
1146
- "assistantMetadata": {
1147
- "anyOf": [
1148
- {
1149
- "type": "object",
1150
- "properties": {
1151
- "species": { "type": "string" },
1152
- "metadata": {
1153
- "anyOf": [
1154
- {
1155
- "type": "object",
1156
- "propertyNames": { "type": "string" },
1157
- "additionalProperties": {}
1158
- },
1159
- { "type": "null" }
1160
- ]
1161
- }
1162
- },
1163
- "required": ["species", "metadata"],
1164
- "additionalProperties": false
1165
- },
1166
- { "type": "null" }
1167
- ]
1168
- },
1169
- "channels": {
1170
- "type": "array",
1171
- "items": {
1172
- "type": "object",
1173
- "properties": {
1174
- "id": { "type": "string" },
1175
- "contactId": { "type": "string" },
1176
- "type": { "type": "string" },
1177
- "address": { "type": "string" },
1178
- "isPrimary": { "type": "boolean" },
1179
- "externalChatId": {
1180
- "anyOf": [
1181
- { "type": "string" },
1182
- { "type": "null" }
1183
- ]
1184
- },
1185
- "externalUserId": {
1186
- "type": "string",
1187
- "description": "Compat alias for address, for older macOS clients"
1188
- },
1189
- "status": {
1190
- "anyOf": [
1191
- { "type": "string" },
1192
- { "type": "null" }
1193
- ]
1194
- },
1195
- "policy": {
1196
- "anyOf": [
1197
- { "type": "string" },
1198
- { "type": "null" }
1199
- ]
1200
- },
1201
- "verifiedAt": {
1202
- "anyOf": [
1203
- { "type": "number" },
1204
- { "type": "null" }
1205
- ]
1206
- },
1207
- "verifiedVia": {
1208
- "anyOf": [
1209
- { "type": "string" },
1210
- { "type": "null" }
1211
- ]
1212
- },
1213
- "inviteId": {
1214
- "anyOf": [
1215
- { "type": "string" },
1216
- { "type": "null" }
1217
- ]
1218
- },
1219
- "revokedReason": {
1220
- "anyOf": [
1221
- { "type": "string" },
1222
- { "type": "null" }
1223
- ]
1224
- },
1225
- "blockedReason": {
1226
- "anyOf": [
1227
- { "type": "string" },
1228
- { "type": "null" }
1229
- ]
1230
- },
1231
- "lastSeenAt": {
1232
- "anyOf": [
1233
- { "type": "number" },
1234
- { "type": "null" }
1235
- ]
1236
- },
1237
- "interactionCount": { "type": "number" },
1238
- "lastInteraction": {
1239
- "anyOf": [
1240
- { "type": "number" },
1241
- { "type": "null" }
1242
- ]
1243
- },
1244
- "createdAt": {
1245
- "anyOf": [
1246
- { "type": "number" },
1247
- { "type": "null" }
1248
- ]
1249
- },
1250
- "updatedAt": {
1251
- "anyOf": [
1252
- { "type": "number" },
1253
- { "type": "null" }
1254
- ]
1255
- }
1256
- },
1257
- "required": [
1258
- "id",
1259
- "contactId",
1260
- "type",
1261
- "address",
1262
- "isPrimary",
1263
- "externalChatId",
1264
- "externalUserId",
1265
- "status",
1266
- "policy",
1267
- "verifiedAt",
1268
- "verifiedVia",
1269
- "inviteId",
1270
- "revokedReason",
1271
- "blockedReason",
1272
- "lastSeenAt",
1273
- "interactionCount",
1274
- "lastInteraction",
1275
- "createdAt",
1276
- "updatedAt"
1277
- ],
1278
- "additionalProperties": false
1279
- }
1280
- }
1281
- },
1282
- "required": [
1283
- "id",
1284
- "displayName",
1285
- "role",
1286
- "notes",
1287
- "contactType",
1288
- "principalId",
1289
- "userFile",
1290
- "createdAt",
1291
- "updatedAt",
1292
- "interactionCount",
1293
- "lastInteraction",
1294
- "autoApproveThreshold",
1295
- "assistantMetadata",
1296
- "channels"
1297
- ],
1298
- "additionalProperties": false
1299
- }
1300
- },
1301
- "required": ["ok", "contact"],
1302
- "additionalProperties": false
1303
- }
1304
- }
1305
- }
1306
- }
1307
- }
1308
- }
1309
- },
1310
- "/v1/contacts/{contact_id}": {
1311
- "delete": {
1312
- "operationId": "contactDelete",
1313
- "summary": "Delete a contact",
1314
- "tags": ["contacts"],
1315
- "description": "Deletes a non-guardian contact from the gateway ACL store and the assistant mirror. 404 when the contact exists in neither; 403 for guardian contacts.",
1316
- "parameters": [
1317
- {
1318
- "name": "contact_id",
1319
- "in": "path",
1320
- "required": true,
1321
- "schema": { "type": "string" },
1322
- "description": "The contact id"
1323
- }
1324
- ],
1325
- "responses": { "204": { "description": "Successful response" } }
1326
- }
1327
- },
1328
- "/v1/contacts/prompt/submit": {
1329
- "post": {
1330
- "operationId": "contactsPromptSubmit",
1331
- "summary": "Submit a contact-prompt address",
1332
- "tags": ["contacts"],
1333
- "description": "Completes a contact_request the assistant broadcast: writes the contact and channel gateway-first, then unblocks the waiting prompt.",
1334
- "requestBody": {
1335
- "required": true,
1336
- "content": {
1337
- "application/json": {
1338
- "schema": {
1339
- "type": "object",
1340
- "properties": {
1341
- "requestId": {
1342
- "type": "string",
1343
- "description": "The contact_request id broadcast by the assistant"
1344
- },
1345
- "address": {
1346
- "description": "Required unless cancelled is true",
1347
- "type": "string"
1348
- },
1349
- "channelType": {
1350
- "description": "Required unless cancelled is true",
1351
- "type": "string"
1352
- },
1353
- "role": { "type": "string" },
1354
- "displayName": { "type": "string" },
1355
- "contactId": {
1356
- "description": "The contact the parked form targets, echoed back from the broadcast. The parked form is authoritative.",
1357
- "type": "string"
1358
- },
1359
- "verify": {
1360
- "description": "The form's 'mark verified' checkbox as the guardian left it. Omit only from clients that predate the checkbox; the parked command's flag is then used instead.",
1361
- "type": "boolean"
1362
- },
1363
- "cancelled": {
1364
- "description": "The guardian dismissed the form. Unblocks the waiting command without writing.",
1365
- "type": "boolean"
1366
- }
1367
- },
1368
- "required": ["requestId"]
1369
- }
1370
- }
1371
- }
1372
- },
1373
- "responses": {
1374
- "200": {
1375
- "description": "Successful response",
1376
- "content": {
1377
- "application/json": {
1378
- "schema": {
1379
- "type": "object",
1380
- "properties": {
1381
- "accepted": { "type": "boolean" },
1382
- "error": { "type": "string" },
1383
- "duplicate": {
1384
- "description": "Another client answered this form first. Nothing is wrong, but none of this submission's values were written.",
1385
- "type": "boolean"
1386
- }
1387
- },
1388
- "required": ["accepted"],
1389
- "additionalProperties": false
1390
- }
1391
- }
1392
- }
1393
- }
1394
- }
1395
- }
1396
- },
1397
- "/v1/contacts/record/submit": {
1398
- "post": {
1399
- "operationId": "contactsRecordSubmit",
1400
- "summary": "Submit a contact-record form",
1401
- "tags": ["contacts"],
1402
- "description": "Completes a contact_record_request the assistant broadcast: writes the record the guardian confirmed, then unblocks the waiting command. A create or update writes display name and notes, never a channel; a merge moves the donor's channels to the survivor and deletes the donor. A cancelled submission unblocks the command without writing.",
1403
- "requestBody": {
1404
- "required": true,
1405
- "content": {
1406
- "application/json": {
1407
- "schema": {
1408
- "type": "object",
1409
- "properties": {
1410
- "requestId": {
1411
- "type": "string",
1412
- "description": "The contact_record_request id broadcast by the assistant"
1413
- },
1414
- "operation": {
1415
- "description": "Required unless cancelled is true",
1416
- "type": "string",
1417
- "enum": ["create", "update", "delete", "merge"]
1418
- },
1419
- "contactId": {
1420
- "description": "Required to update or delete, and the survivor of a merge",
1421
- "type": "string"
1422
- },
1423
- "donorContactId": {
1424
- "description": "The contact merged away. Required for a merge.",
1425
- "type": "string"
1426
- },
1427
- "displayName": { "type": "string" },
1428
- "notes": {
1429
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1430
- },
1431
- "expectedChannels": {
1432
- "description": "The channels the delete confirmation listed. The delete is refused if the contact's channels changed since.",
1433
- "type": "array",
1434
- "items": {
1435
- "type": "object",
1436
- "properties": {
1437
- "type": { "type": "string" },
1438
- "address": { "type": "string" }
1439
- },
1440
- "required": ["type", "address"]
1441
- }
1442
- },
1443
- "cancelled": {
1444
- "description": "The guardian dismissed the form. Unblocks the waiting command without writing.",
1445
- "type": "boolean"
1446
- }
1447
- },
1448
- "required": ["requestId"]
1449
- }
1450
- }
1451
- }
1452
- },
1453
- "responses": {
1454
- "200": {
1455
- "description": "Successful response",
1456
- "content": {
1457
- "application/json": {
1458
- "schema": {
1459
- "type": "object",
1460
- "properties": {
1461
- "accepted": { "type": "boolean" },
1462
- "error": { "type": "string" },
1463
- "duplicate": {
1464
- "description": "Another client answered this form first. Nothing is wrong, but none of this submission's values were written.",
1465
- "type": "boolean"
1466
- }
1467
- },
1468
- "required": ["accepted"],
1469
- "additionalProperties": false
1470
- }
1471
- }
1472
- }
1473
- }
1474
- }
1475
- }
1476
- },
1477
- "/v1/contact-channels/{channel_id}/verify": {
1478
- "post": {
1479
- "operationId": "contactChannelVerify",
1480
- "summary": "Manually verify a contact channel",
1481
- "tags": ["contacts"],
1482
- "description": "Guardian-only manual attestation: marks the channel active/verified in the gateway store, the source of truth, with a best-effort assistant mirror. Idempotent.",
1483
- "parameters": [
1484
- {
1485
- "name": "channel_id",
1486
- "in": "path",
1487
- "required": true,
1488
- "schema": { "type": "string" },
1489
- "description": "The contact-channel id"
1490
- }
1491
- ],
1492
- "responses": {
1493
- "200": {
1494
- "description": "Successful response",
1495
- "content": {
1496
- "application/json": {
1497
- "schema": {
1498
- "type": "object",
1499
- "properties": {
1500
- "ok": { "type": "boolean" },
1501
- "channel": {
1502
- "type": "object",
1503
- "properties": {
1504
- "id": { "type": "string" },
1505
- "contactId": { "type": "string" },
1506
- "type": { "type": "string" },
1507
- "address": { "type": "string" },
1508
- "isPrimary": { "type": "boolean" },
1509
- "externalChatId": {
1510
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1511
- },
1512
- "status": {
1513
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1514
- },
1515
- "policy": {
1516
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1517
- },
1518
- "verifiedAt": {
1519
- "anyOf": [{ "type": "number" }, { "type": "null" }]
1520
- },
1521
- "verifiedVia": {
1522
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1523
- },
1524
- "inviteId": {
1525
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1526
- },
1527
- "revokedReason": {
1528
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1529
- },
1530
- "blockedReason": {
1531
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1532
- },
1533
- "lastSeenAt": {
1534
- "anyOf": [{ "type": "number" }, { "type": "null" }]
1535
- },
1536
- "interactionCount": { "type": "number" },
1537
- "lastInteraction": {
1538
- "anyOf": [{ "type": "number" }, { "type": "null" }]
1539
- },
1540
- "createdAt": {
1541
- "anyOf": [{ "type": "number" }, { "type": "null" }]
1542
- },
1543
- "updatedAt": {
1544
- "anyOf": [{ "type": "number" }, { "type": "null" }]
1545
- }
1546
- },
1547
- "required": [
1548
- "id",
1549
- "contactId",
1550
- "type",
1551
- "address",
1552
- "isPrimary",
1553
- "externalChatId",
1554
- "status",
1555
- "policy",
1556
- "verifiedAt",
1557
- "verifiedVia",
1558
- "inviteId",
1559
- "revokedReason",
1560
- "blockedReason",
1561
- "lastSeenAt",
1562
- "interactionCount",
1563
- "lastInteraction",
1564
- "createdAt",
1565
- "updatedAt"
1566
- ],
1567
- "additionalProperties": false
1568
- }
1569
- },
1570
- "required": ["ok", "channel"],
1571
- "additionalProperties": false
1572
- }
1573
- }
1574
- }
1575
- }
1576
- }
1577
- }
1578
- },
1579
- "/v1/credential-requests/peek": {
1580
- "post": {
1581
- "operationId": "credential_requests_peek",
1582
- "summary": "Validate a credential-request token without consuming it",
1583
- "tags": ["credential-requests"],
1584
- "description": "Returns the service/field/label the link collects. The token travels in the body so it never appears in URLs or access logs.",
1585
- "requestBody": {
1586
- "required": true,
1587
- "content": {
1588
- "application/json": {
1589
- "schema": {
1590
- "type": "object",
1591
- "properties": {
1592
- "token": { "type": "string", "minLength": 20 }
1593
- },
1594
- "required": ["token"]
1595
- }
1596
- }
1597
- }
1598
- },
1599
- "responses": {
1600
- "200": {
1601
- "description": "Successful response",
1602
- "content": {
1603
- "application/json": {
1604
- "schema": {
1605
- "anyOf": [
1606
- {
1607
- "type": "object",
1608
- "properties": {
1609
- "service": { "type": "string" },
1610
- "field": { "type": "string" },
1611
- "label": {
1612
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1613
- },
1614
- "expiresAt": { "type": "number" }
1615
- },
1616
- "required": ["service", "field", "label", "expiresAt"],
1617
- "additionalProperties": false
1618
- },
1619
- {
1620
- "type": "object",
1621
- "properties": {
1622
- "error": {
1623
- "type": "object",
1624
- "properties": {
1625
- "code": {
1626
- "type": "string",
1627
- "enum": ["INVALID", "EXPIRED", "USED"]
1628
- },
1629
- "message": { "type": "string" }
1630
- },
1631
- "required": ["code", "message"],
1632
- "additionalProperties": false
1633
- }
1634
- },
1635
- "required": ["error"],
1636
- "additionalProperties": false
1637
- }
1638
- ]
1639
- }
1640
- }
1641
- }
1642
- }
1643
- }
1644
- }
1645
- },
1646
- "/v1/credential-requests/submit": {
1647
- "post": {
1648
- "operationId": "credential_requests_submit",
1649
- "summary": "Consume a credential-request token and store the value",
1650
- "tags": ["credential-requests"],
1651
- "description": "Single-use: atomically claims the link, forwards the value to the assistant's credential store, and marks the link redeemed.",
1652
- "requestBody": {
1653
- "required": true,
1654
- "content": {
1655
- "application/json": {
1656
- "schema": {
1657
- "type": "object",
1658
- "properties": {
1659
- "token": { "type": "string", "minLength": 20 },
1660
- "value": {
1661
- "type": "string",
1662
- "minLength": 1,
1663
- "maxLength": 32768
1664
- }
1665
- },
1666
- "required": ["token", "value"]
1667
- }
1668
- }
1669
- }
1670
- },
1671
- "responses": {
1672
- "200": {
1673
- "description": "Successful response",
1674
- "content": {
1675
- "application/json": {
1676
- "schema": {
1677
- "anyOf": [
1678
- {
1679
- "type": "object",
1680
- "properties": { "ok": { "type": "boolean" } },
1681
- "required": ["ok"],
1682
- "additionalProperties": false
1683
- },
1684
- {
1685
- "type": "object",
1686
- "properties": {
1687
- "error": {
1688
- "type": "object",
1689
- "properties": {
1690
- "code": {
1691
- "type": "string",
1692
- "enum": ["INVALID", "EXPIRED", "USED"]
1693
- },
1694
- "message": { "type": "string" }
1695
- },
1696
- "required": ["code", "message"],
1697
- "additionalProperties": false
1698
- }
1699
- },
1700
- "required": ["error"],
1701
- "additionalProperties": false
1702
- }
1703
- ]
1704
- }
1705
- }
1706
- }
1707
- }
1708
- }
1709
- }
1710
- },
1711
- "/v1/feature-flags": {
1712
- "get": {
1713
- "operationId": "featureFlagsGet",
1714
- "summary": "List all feature flags",
1715
- "tags": ["feature-flags"],
1716
- "description": "Returns all feature flags with their current values.",
1717
- "responses": {
1718
- "200": {
1719
- "description": "Successful response",
1720
- "content": {
1721
- "application/json": {
1722
- "schema": {
1723
- "type": "object",
1724
- "properties": {
1725
- "flags": {
1726
- "type": "array",
1727
- "items": {
1728
- "type": "object",
1729
- "properties": {
1730
- "key": { "type": "string" },
1731
- "label": { "type": "string" },
1732
- "enabled": {
1733
- "anyOf": [
1734
- { "type": "boolean" },
1735
- { "type": "string" }
1736
- ]
1737
- },
1738
- "defaultEnabled": {
1739
- "anyOf": [
1740
- { "type": "boolean" },
1741
- { "type": "string" }
1742
- ]
1743
- },
1744
- "description": { "type": "string" }
1745
- },
1746
- "required": [
1747
- "key",
1748
- "label",
1749
- "enabled",
1750
- "defaultEnabled",
1751
- "description"
1752
- ],
1753
- "additionalProperties": false
1754
- }
1755
- }
1756
- },
1757
- "required": ["flags"],
1758
- "additionalProperties": false
1759
- }
1760
- }
1761
- }
1762
- }
1763
- }
1764
- }
1765
- },
1766
- "/v1/feature-flags/{flag_key}": {
1767
- "patch": {
1768
- "operationId": "featureFlagsPatch",
1769
- "summary": "Update a feature flag",
1770
- "tags": ["feature-flags"],
1771
- "description": "Set the enabled state of a single feature flag.",
1772
- "parameters": [
1773
- {
1774
- "name": "flag_key",
1775
- "in": "path",
1776
- "required": true,
1777
- "schema": { "type": "string" },
1778
- "description": "The kebab-case flag identifier"
1779
- }
1780
- ],
1781
- "requestBody": {
1782
- "required": true,
1783
- "content": {
1784
- "application/json": {
1785
- "schema": {
1786
- "type": "object",
1787
- "properties": {
1788
- "enabled": {
1789
- "anyOf": [{ "type": "boolean" }, { "type": "string" }]
1790
- }
1791
- },
1792
- "required": ["enabled"]
1793
- }
1794
- }
1795
- }
1796
- },
1797
- "responses": {
1798
- "200": {
1799
- "description": "Successful response",
1800
- "content": {
1801
- "application/json": {
1802
- "schema": {
1803
- "type": "object",
1804
- "properties": {
1805
- "key": { "type": "string" },
1806
- "enabled": {
1807
- "anyOf": [{ "type": "boolean" }, { "type": "string" }]
1808
- }
1809
- },
1810
- "required": ["key", "enabled"],
1811
- "additionalProperties": false
1812
- }
1813
- }
1814
- }
1815
- }
1816
- }
1817
- }
1818
- },
1819
- "/v1/trust-rules": {
1820
- "get": {
1821
- "operationId": "trustRulesList",
1822
- "summary": "List trust rules",
1823
- "tags": ["trust-rules"],
1824
- "description": "Returns trust rules, filtered to user-relevant rules by default. Pass include_all=true for the full set or origin/tool to filter.",
1825
- "parameters": [
1826
- {
1827
- "name": "origin",
1828
- "in": "query",
1829
- "required": false,
1830
- "schema": { "type": "string" },
1831
- "description": "Filter by origin: default or user_defined"
1832
- },
1833
- {
1834
- "name": "tool",
1835
- "in": "query",
1836
- "required": false,
1837
- "schema": { "type": "string" },
1838
- "description": "Filter by tool name"
1839
- },
1840
- {
1841
- "name": "include_deleted",
1842
- "in": "query",
1843
- "required": false,
1844
- "schema": { "type": "string" },
1845
- "description": "\"true\" to include soft-deleted rules"
1846
- },
1847
- {
1848
- "name": "include_all",
1849
- "in": "query",
1850
- "required": false,
1851
- "schema": { "type": "string" },
1852
- "description": "\"true\" to disable the user-relevant filter"
1853
- }
1854
- ],
1855
- "responses": {
1856
- "200": {
1857
- "description": "Successful response",
1858
- "content": {
1859
- "application/json": {
1860
- "schema": {
1861
- "type": "object",
1862
- "properties": {
1863
- "rules": {
1864
- "type": "array",
1865
- "items": {
1866
- "type": "object",
1867
- "properties": {
1868
- "id": { "type": "string" },
1869
- "tool": { "type": "string" },
1870
- "pattern": { "type": "string" },
1871
- "risk": {
1872
- "type": "string",
1873
- "enum": ["low", "medium", "high"]
1874
- },
1875
- "description": { "type": "string" },
1876
- "origin": {
1877
- "type": "string",
1878
- "enum": ["default", "user_defined"]
1879
- },
1880
- "userModified": { "type": "boolean" },
1881
- "deleted": { "type": "boolean" },
1882
- "scope": {
1883
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1884
- },
1885
- "createdAt": { "type": "string" },
1886
- "updatedAt": { "type": "string" }
1887
- },
1888
- "required": [
1889
- "id",
1890
- "tool",
1891
- "pattern",
1892
- "risk",
1893
- "description",
1894
- "origin",
1895
- "userModified",
1896
- "deleted",
1897
- "scope",
1898
- "createdAt",
1899
- "updatedAt"
1900
- ],
1901
- "additionalProperties": false
1902
- }
1903
- }
1904
- },
1905
- "required": ["rules"],
1906
- "additionalProperties": false
1907
- }
1908
- }
1909
- }
1910
- }
1911
- }
1912
- },
1913
- "post": {
1914
- "operationId": "trustRuleCreate",
1915
- "summary": "Create a trust rule",
1916
- "tags": ["trust-rules"],
1917
- "requestBody": {
1918
- "required": true,
1919
- "content": {
1920
- "application/json": {
1921
- "schema": {
1922
- "type": "object",
1923
- "properties": {
1924
- "tool": { "type": "string", "minLength": 1 },
1925
- "pattern": { "type": "string", "minLength": 1 },
1926
- "risk": {
1927
- "type": "string",
1928
- "enum": ["low", "medium", "high"]
1929
- },
1930
- "description": { "type": "string", "minLength": 1 },
1931
- "scope": {
1932
- "description": "Compatibility field. Trust rules apply workspace-wide: the engine matches on tool and pattern only, so a narrower scope cannot be honored and any value other than \"everywhere\" is rejected rather than stored broader than the consent it records.",
1933
- "type": "string",
1934
- "const": "everywhere"
1935
- }
1936
- },
1937
- "required": ["tool", "pattern", "risk", "description"]
1938
- }
1939
- }
1940
- }
1941
- },
1942
- "responses": {
1943
- "201": {
1944
- "description": "Successful response",
1945
- "content": {
1946
- "application/json": {
1947
- "schema": {
1948
- "type": "object",
1949
- "properties": {
1950
- "rule": {
1951
- "type": "object",
1952
- "properties": {
1953
- "id": { "type": "string" },
1954
- "tool": { "type": "string" },
1955
- "pattern": { "type": "string" },
1956
- "risk": {
1957
- "type": "string",
1958
- "enum": ["low", "medium", "high"]
1959
- },
1960
- "description": { "type": "string" },
1961
- "origin": {
1962
- "type": "string",
1963
- "enum": ["default", "user_defined"]
1964
- },
1965
- "userModified": { "type": "boolean" },
1966
- "deleted": { "type": "boolean" },
1967
- "scope": {
1968
- "anyOf": [{ "type": "string" }, { "type": "null" }]
1969
- },
1970
- "createdAt": { "type": "string" },
1971
- "updatedAt": { "type": "string" }
1972
- },
1973
- "required": [
1974
- "id",
1975
- "tool",
1976
- "pattern",
1977
- "risk",
1978
- "description",
1979
- "origin",
1980
- "userModified",
1981
- "deleted",
1982
- "scope",
1983
- "createdAt",
1984
- "updatedAt"
1985
- ],
1986
- "additionalProperties": false
1987
- }
1988
- },
1989
- "required": ["rule"],
1990
- "additionalProperties": false
1991
- }
1992
- }
1993
- }
1994
- }
1995
- }
1996
- }
1997
- },
1998
- "/v1/trust-rules/suggest": {
1999
- "post": {
2000
- "operationId": "trustRuleSuggest",
2001
- "summary": "Generate a trust-rule suggestion",
2002
- "tags": ["trust-rules"],
2003
- "description": "LLM-backed suggestion for a rule matching the given tool invocation. Returns 503 when the daemon suggestion relay is unavailable.",
2004
- "requestBody": {
2005
- "required": true,
2006
- "content": {
2007
- "application/json": {
2008
- "schema": {
2009
- "type": "object",
2010
- "properties": {
2011
- "tool": { "type": "string", "minLength": 1 },
2012
- "command": { "type": "string", "minLength": 1 },
2013
- "riskAssessment": {
2014
- "type": "object",
2015
- "properties": {
2016
- "risk": { "type": "string" },
2017
- "reasoning": { "type": "string" },
2018
- "reasonDescription": { "type": "string" }
2019
- },
2020
- "required": ["risk", "reasoning", "reasonDescription"]
2021
- },
2022
- "scopeOptions": {
2023
- "type": "array",
2024
- "items": {
2025
- "type": "object",
2026
- "properties": {
2027
- "pattern": { "type": "string" },
2028
- "label": { "type": "string" }
2029
- },
2030
- "required": ["pattern", "label"]
2031
- }
2032
- },
2033
- "directoryScopeOptions": {
2034
- "type": "array",
2035
- "items": {
2036
- "type": "object",
2037
- "properties": {
2038
- "scope": { "type": "string" },
2039
- "label": { "type": "string" }
2040
- },
2041
- "required": ["scope", "label"]
2042
- }
2043
- },
2044
- "intent": {
2045
- "type": "string",
2046
- "enum": ["auto_approve", "escalate"]
2047
- },
2048
- "existingRule": {
2049
- "type": "object",
2050
- "properties": {
2051
- "id": { "type": "string" },
2052
- "pattern": { "type": "string" },
2053
- "risk": { "type": "string" }
2054
- },
2055
- "required": ["id", "pattern", "risk"]
2056
- }
2057
- },
2058
- "required": [
2059
- "tool",
2060
- "command",
2061
- "riskAssessment",
2062
- "scopeOptions",
2063
- "intent"
2064
- ]
2065
- }
2066
- }
2067
- }
2068
- },
2069
- "responses": {
2070
- "200": {
2071
- "description": "Successful response",
2072
- "content": {
2073
- "application/json": {
2074
- "schema": {
2075
- "type": "object",
2076
- "properties": {
2077
- "suggestion": {
2078
- "type": "object",
2079
- "properties": {
2080
- "pattern": { "type": "string" },
2081
- "risk": { "type": "string" },
2082
- "scope": {
2083
- "anyOf": [{ "type": "string" }, { "type": "null" }]
2084
- },
2085
- "description": { "type": "string" },
2086
- "scopeOptions": {
2087
- "type": "array",
2088
- "items": {
2089
- "type": "object",
2090
- "properties": {
2091
- "pattern": { "type": "string" },
2092
- "label": { "type": "string" }
2093
- },
2094
- "required": ["pattern", "label"],
2095
- "additionalProperties": false
2096
- }
2097
- },
2098
- "directoryScopeOptions": {
2099
- "anyOf": [
2100
- {
2101
- "type": "array",
2102
- "items": {
2103
- "type": "object",
2104
- "properties": {
2105
- "scope": { "type": "string" },
2106
- "label": { "type": "string" }
2107
- },
2108
- "required": ["scope", "label"],
2109
- "additionalProperties": false
2110
- }
2111
- },
2112
- { "type": "null" }
2113
- ]
2114
- }
2115
- },
2116
- "required": [
2117
- "pattern",
2118
- "risk",
2119
- "scope",
2120
- "description",
2121
- "scopeOptions"
2122
- ],
2123
- "additionalProperties": false
2124
- }
2125
- },
2126
- "required": ["suggestion"],
2127
- "additionalProperties": false
2128
- }
2129
- }
2130
- }
2131
- }
2132
- }
2133
- }
2134
- },
2135
- "/v1/trust-rules/{rule_id}": {
2136
- "patch": {
2137
- "operationId": "trustRuleUpdate",
2138
- "summary": "Update a trust rule",
2139
- "tags": ["trust-rules"],
2140
- "description": "Updates risk and/or description. Updating a default-origin rule marks it userModified.",
2141
- "parameters": [
2142
- {
2143
- "name": "rule_id",
2144
- "in": "path",
2145
- "required": true,
2146
- "schema": { "type": "string" },
2147
- "description": "The trust rule id"
2148
- }
2149
- ],
2150
- "requestBody": {
2151
- "required": true,
2152
- "content": {
2153
- "application/json": {
2154
- "schema": {
2155
- "type": "object",
2156
- "properties": {
2157
- "risk": {
2158
- "type": "string",
2159
- "enum": ["low", "medium", "high"]
2160
- },
2161
- "description": { "type": "string" }
2162
- }
2163
- }
2164
- }
2165
- }
2166
- },
2167
- "responses": {
2168
- "200": {
2169
- "description": "Successful response",
2170
- "content": {
2171
- "application/json": {
2172
- "schema": {
2173
- "type": "object",
2174
- "properties": {
2175
- "rule": {
2176
- "type": "object",
2177
- "properties": {
2178
- "id": { "type": "string" },
2179
- "tool": { "type": "string" },
2180
- "pattern": { "type": "string" },
2181
- "risk": {
2182
- "type": "string",
2183
- "enum": ["low", "medium", "high"]
2184
- },
2185
- "description": { "type": "string" },
2186
- "origin": {
2187
- "type": "string",
2188
- "enum": ["default", "user_defined"]
2189
- },
2190
- "userModified": { "type": "boolean" },
2191
- "deleted": { "type": "boolean" },
2192
- "scope": {
2193
- "anyOf": [{ "type": "string" }, { "type": "null" }]
2194
- },
2195
- "createdAt": { "type": "string" },
2196
- "updatedAt": { "type": "string" }
2197
- },
2198
- "required": [
2199
- "id",
2200
- "tool",
2201
- "pattern",
2202
- "risk",
2203
- "description",
2204
- "origin",
2205
- "userModified",
2206
- "deleted",
2207
- "scope",
2208
- "createdAt",
2209
- "updatedAt"
2210
- ],
2211
- "additionalProperties": false
2212
- }
2213
- },
2214
- "required": ["rule"],
2215
- "additionalProperties": false
2216
- }
2217
- }
2218
- }
2219
- }
2220
- }
2221
- },
2222
- "delete": {
2223
- "operationId": "trustRuleDelete",
2224
- "summary": "Delete a trust rule",
2225
- "tags": ["trust-rules"],
2226
- "description": "Soft-deletes the rule. Default-origin rules can be reset later.",
2227
- "parameters": [
2228
- {
2229
- "name": "rule_id",
2230
- "in": "path",
2231
- "required": true,
2232
- "schema": { "type": "string" },
2233
- "description": "The trust rule id"
2234
- }
2235
- ],
2236
- "responses": {
2237
- "200": {
2238
- "description": "Successful response",
2239
- "content": {
2240
- "application/json": {
2241
- "schema": {
2242
- "type": "object",
2243
- "properties": { "success": { "type": "boolean" } },
2244
- "required": ["success"],
2245
- "additionalProperties": false
2246
- }
2247
- }
2248
- }
2249
- }
2250
- }
2251
- }
2252
- },
2253
- "/v1/trust-rules/{rule_id}/reset": {
2254
- "post": {
2255
- "operationId": "trustRuleReset",
2256
- "summary": "Reset a default trust rule",
2257
- "tags": ["trust-rules"],
2258
- "description": "Restores a default-origin rule to its registry risk and description, clearing userModified and deleted.",
2259
- "parameters": [
2260
- {
2261
- "name": "rule_id",
2262
- "in": "path",
2263
- "required": true,
2264
- "schema": { "type": "string" },
2265
- "description": "The trust rule id"
2266
- }
2267
- ],
2268
- "responses": {
2269
- "200": {
2270
- "description": "Successful response",
2271
- "content": {
2272
- "application/json": {
2273
- "schema": {
2274
- "type": "object",
2275
- "properties": {
2276
- "rule": {
2277
- "type": "object",
2278
- "properties": {
2279
- "id": { "type": "string" },
2280
- "tool": { "type": "string" },
2281
- "pattern": { "type": "string" },
2282
- "risk": {
2283
- "type": "string",
2284
- "enum": ["low", "medium", "high"]
2285
- },
2286
- "description": { "type": "string" },
2287
- "origin": {
2288
- "type": "string",
2289
- "enum": ["default", "user_defined"]
2290
- },
2291
- "userModified": { "type": "boolean" },
2292
- "deleted": { "type": "boolean" },
2293
- "scope": {
2294
- "anyOf": [{ "type": "string" }, { "type": "null" }]
2295
- },
2296
- "createdAt": { "type": "string" },
2297
- "updatedAt": { "type": "string" }
2298
- },
2299
- "required": [
2300
- "id",
2301
- "tool",
2302
- "pattern",
2303
- "risk",
2304
- "description",
2305
- "origin",
2306
- "userModified",
2307
- "deleted",
2308
- "scope",
2309
- "createdAt",
2310
- "updatedAt"
2311
- ],
2312
- "additionalProperties": false
2313
- }
2314
- },
2315
- "required": ["rule"],
2316
- "additionalProperties": false
2317
- }
2318
- }
2319
- }
2320
- }
2321
- }
2322
- }
2323
- }
2324
- }
2325
- }