@cortexkit/opencode-openai-auth 1.23.1 → 1.23.3

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 (226) hide show
  1. package/dist/bin.js +7 -7
  2. package/dist/{index-7hy72nfy.js → index-9kges8jy.js} +2 -2
  3. package/dist/index-ekt6aq17.js +60 -0
  4. package/dist/index-nd2ks7er.js +2 -0
  5. package/dist/{index-p81hxfe6.js → index-vf4nn20q.js} +1 -1
  6. package/dist/{index-bd18sfjj.js → index-x00sxt2w.js} +10 -10
  7. package/dist/{index-3ya2s179.js → index-xkngfyvc.js} +1 -1
  8. package/dist/index.d.ts +3 -2
  9. package/dist/index.js +1 -1
  10. package/dist/{runtime-layout-B07ApQZL.d.ts → internal-DacVgEWs.d.ts} +86 -663
  11. package/dist/rpc/port-file.js +1 -1
  12. package/dist/runtime-layout-Dcbj_Rq3.d.ts +650 -0
  13. package/dist/{sidebar-state--OTpRzFd.d.ts → sidebar-state-L--CdbLi.d.ts} +4 -15
  14. package/dist/sidebar-state.d.ts +1 -1
  15. package/dist/sidebar-state.js +1 -1
  16. package/dist/tui.d.ts +5 -2
  17. package/dist/v2/server.d.ts +2 -1
  18. package/dist/v2/server.js +4 -4
  19. package/package.json +1 -1
  20. package/src/tui-compiled/raw/shared/054118b2705fdc20-ansi.js +98 -0
  21. package/src/tui-compiled/raw/shared/0895e780489c494d-window.js +33 -0
  22. package/src/tui-compiled/raw/shared/0b7d24474e2f33e9-credential-redaction.js +424 -0
  23. package/src/tui-compiled/raw/shared/0c9533222cb4380c-namespace.js +224 -0
  24. package/src/tui-compiled/raw/shared/112607e46a5b5f58-accounts.js +393 -0
  25. package/src/tui-compiled/raw/shared/136fa4abe48ad69d-cachekeep.js +411 -0
  26. package/src/tui-compiled/raw/shared/1547bd74f4214d2d-index.js +28 -0
  27. package/src/tui-compiled/raw/shared/1567207f323dc733-codex-http.js +44 -0
  28. package/src/tui-compiled/raw/shared/15f402885cbb2fb3-envelope-loss.js +151 -0
  29. package/src/tui-compiled/raw/shared/18df43cab4563acf-families.js +149 -0
  30. package/src/tui-compiled/raw/shared/1a4c289eec261e04-codex-instructions.js +59 -0
  31. package/src/tui-compiled/raw/shared/1afd446e190ef85c-vault-messages.js +12 -0
  32. package/src/tui-compiled/raw/shared/1b06ec96856ff8b9-codex-endpoint.js +17 -0
  33. package/src/tui-compiled/raw/shared/1e2f1a89bb34a773-vault-adapter.js +110 -0
  34. package/src/tui-compiled/raw/shared/2194fb8e8b42d7d5-insula-quota.js +73 -0
  35. package/src/tui-compiled/raw/shared/22b2bce42f2d6806-handle.js +10 -0
  36. package/src/tui-compiled/raw/shared/2577ec69f9973ae9-quota-normalize.js +13 -14
  37. package/src/tui-compiled/raw/shared/26055d4e5ad5e71f-codex-request.js +198 -0
  38. package/src/tui-compiled/raw/shared/26b57ac4c3b0c3f6-unconfirmed-retain-counter.js +41 -0
  39. package/src/tui-compiled/raw/shared/2bb681e99c2721d7-registry.js +538 -0
  40. package/src/tui-compiled/raw/shared/2dce6e9613993329-quota-manager.js +13 -20
  41. package/src/tui-compiled/raw/shared/2ec33b3e2b8ac38a-terminal.js +168 -0
  42. package/src/tui-compiled/raw/shared/30bcca1d1b4240a0-pool-session-pins.js +32 -0
  43. package/src/tui-compiled/raw/shared/3af9a210aa2ccdf2-codex-call-status.js +21 -0
  44. package/src/tui-compiled/raw/shared/3b31b36bf0877602-wording.js +120 -0
  45. package/src/tui-compiled/raw/shared/3c4c1a2d3fc92726-failure.js +59 -0
  46. package/src/tui-compiled/raw/shared/3dfe71eec6e0487d-presets.js +240 -0
  47. package/src/tui-compiled/raw/shared/43de3a5c4845cfc1-pool-adapter.js +149 -0
  48. package/src/tui-compiled/raw/shared/49353b63a833c8fb-session-cache-policy.js +60 -0
  49. package/src/tui-compiled/raw/shared/4adf46e07e025363-axes.js +7 -0
  50. package/src/tui-compiled/raw/shared/4ba847b77580b1eb-confirm.js +21 -0
  51. package/src/tui-compiled/raw/shared/4d05c2d7a531aece-oauth.js +48 -36
  52. package/src/tui-compiled/raw/shared/5018d4665e969588-limit-policy.js +159 -0
  53. package/src/tui-compiled/raw/shared/595bdf3fff13ba79-limit-identity.js +49 -0
  54. package/src/tui-compiled/raw/shared/59def9e82b61204a-session-cache-activity.js +35 -0
  55. package/src/tui-compiled/raw/shared/5d806e1a305d14f5-commands.js +879 -0
  56. package/src/tui-compiled/raw/shared/5fc39320fa8bd3a0-limit-registry.js +473 -0
  57. package/src/tui-compiled/raw/shared/63c1ee7e70e85e8d-vault.js +1 -0
  58. package/src/tui-compiled/raw/shared/6545ab7f757314b7-refresh-all-quota.js +237 -0
  59. package/src/tui-compiled/raw/shared/66937534c260d20b-stable-json.js +11 -0
  60. package/src/tui-compiled/raw/shared/7056acef1b021f19-bridge.js +10 -0
  61. package/src/tui-compiled/raw/shared/72d2ca42883809b4-marker.js +107 -0
  62. package/src/tui-compiled/raw/shared/775431e21f469203-record.js +3 -0
  63. package/src/tui-compiled/raw/shared/799f3ade4efbd1ea-opencode-v1.js +47 -0
  64. package/src/tui-compiled/raw/shared/7b2a0471b29e4f5e-wake.js +47 -0
  65. package/src/tui-compiled/raw/shared/7b5d6afff4ff32b9-select.js +159 -0
  66. package/src/tui-compiled/raw/shared/7bf96bf4d9249b3d-vault-billing.js +108 -0
  67. package/src/tui-compiled/raw/shared/7c98bde36aad4819-input-transformations.js +34 -0
  68. package/src/tui-compiled/raw/shared/7fb0418303f20a10-index.js +3 -0
  69. package/src/tui-compiled/raw/shared/806e12ccbad34388-pi-wait.js +51 -0
  70. package/src/tui-compiled/raw/shared/81ae201b724cac14-menu.js +73 -0
  71. package/src/tui-compiled/raw/shared/8349ed25dc629e97-scope.js +10 -0
  72. package/src/tui-compiled/raw/shared/86da3379973780b9-limit-provenance.js +60 -0
  73. package/src/tui-compiled/raw/shared/8aba66ed486d30a7-decide.js +425 -0
  74. package/src/tui-compiled/raw/shared/8c0c8df25a5dca1f-manager.js +735 -0
  75. package/src/tui-compiled/raw/shared/8c42bbec02f59636-vault-routing.js +212 -0
  76. package/src/tui-compiled/raw/shared/8ca6175bfae53e13-envelope.js +123 -0
  77. package/src/tui-compiled/raw/shared/8d0245e41049d83f-header-classifier.js +121 -0
  78. package/src/tui-compiled/raw/shared/9c162809179c7560-login.js +89 -0
  79. package/src/tui-compiled/raw/shared/a1f495296a4b756f-frame-turn.js +72 -0
  80. package/src/tui-compiled/raw/shared/a37138dcbd893f55-hold-bounds.js +5 -0
  81. package/src/tui-compiled/raw/shared/aa7fb10d77a2cccd-vault-account-menu.js +133 -0
  82. package/src/tui-compiled/raw/shared/adc5eeb5a8d28280-persistence.js +9 -0
  83. package/src/tui-compiled/raw/shared/b301c79e6378d1fb-vault.js +678 -0
  84. package/src/tui-compiled/raw/shared/b3c11de5f36e617a-reset.js +44 -0
  85. package/src/tui-compiled/raw/shared/ba6535c610d1edb3-pool-source-state.js +100 -0
  86. package/src/tui-compiled/raw/shared/bd4aef685681048c-duration.js +20 -0
  87. package/src/tui-compiled/raw/shared/bd5977eca210d2b8-index.js +662 -0
  88. package/src/tui-compiled/raw/shared/bfc46d34f4c9db33-limit-recovery.js +127 -0
  89. package/src/tui-compiled/raw/shared/c66495424ad84aee-hold.js +25 -0
  90. package/src/tui-compiled/raw/shared/c6a67b836bd5afcd-vault-command-menu.js +300 -0
  91. package/src/tui-compiled/raw/shared/c9340fb545c4e5de-internal.js +73 -0
  92. package/src/tui-compiled/raw/shared/c954c6447b7b9b64-activity.js +52 -0
  93. package/src/tui-compiled/raw/shared/cba8b0aee46b8526-codex-lite.js +85 -0
  94. package/src/tui-compiled/raw/shared/cec39ccddab4fe9c-labels.js +11 -0
  95. package/src/tui-compiled/raw/shared/cef0f2346957e83c-index.js +552 -0
  96. package/src/tui-compiled/raw/shared/cf7dedf24f902d68-dump-size.js +41 -0
  97. package/src/tui-compiled/raw/shared/d422d6dbc4e35199-background-quota-refresh.js +107 -0
  98. package/src/tui-compiled/raw/shared/d5b268767d330507-doctor.js +81 -0
  99. package/src/tui-compiled/raw/shared/d7ac5ca41f49121b-index.js +12 -0
  100. package/src/tui-compiled/raw/shared/d7fa77560855dee2-jitter.js +9 -0
  101. package/src/tui-compiled/raw/shared/de7f7d8803624369-path.js +31 -0
  102. package/src/tui-compiled/raw/shared/df0bdc74fb0c0db0-limit-mark.js +27 -0
  103. package/src/tui-compiled/raw/shared/e26c2bb5722ab047-routing-hold.js +23 -0
  104. package/src/tui-compiled/raw/shared/e2ae081583adfce3-dump.js +80 -0
  105. package/src/tui-compiled/raw/shared/e44ba1b3a9903f5d-reset-credits.js +483 -0
  106. package/src/tui-compiled/raw/shared/e5229952fc12f647-codex-models.js +34 -0
  107. package/src/tui-compiled/raw/shared/e8fda84e90176436-uuid-v7.js +13 -0
  108. package/src/tui-compiled/raw/shared/ea56007991dbf068-terminal.js +19 -0
  109. package/src/tui-compiled/raw/shared/ec6f1d96e7d70174-quota-refusal.js +145 -0
  110. package/src/tui-compiled/raw/shared/f03d7b43a214a4a1-canonical-input.js +42 -0
  111. package/src/tui-compiled/raw/shared/f1012265b3a768c7-merge-laws.js +31 -0
  112. package/src/tui-compiled/raw/shared/f2ca864fe967415a-cache-policy.js +198 -0
  113. package/src/tui-compiled/raw/shared/f317a4740f9d76f8-identity.js +21 -0
  114. package/src/tui-compiled/raw/shared/f607353c4126272a-routing-wait.js +19 -0
  115. package/src/tui-compiled/raw/shared/f6189f5c9aee31eb-decision.js +55 -0
  116. package/src/tui-compiled/raw/shared/f6d728f5e601f98b-request-history.js +120 -0
  117. package/src/tui-compiled/raw/shared/f981e6b15fb76cdb-codex-body.js +28 -0
  118. package/src/tui-compiled/raw/shared/fda579e5a0a54165-codex-effort.js +60 -0
  119. package/src/tui-compiled/raw/sidebar-state.js +54 -4
  120. package/src/tui-compiled/raw/tui/v2-dialog.js +1 -1
  121. package/src/tui-compiled/raw/tui.tsx +27 -5
  122. package/src/tui-compiled/runtime/shared/054118b2705fdc20-ansi.js +98 -0
  123. package/src/tui-compiled/runtime/shared/0895e780489c494d-window.js +33 -0
  124. package/src/tui-compiled/runtime/shared/0b7d24474e2f33e9-credential-redaction.js +424 -0
  125. package/src/tui-compiled/runtime/shared/0c9533222cb4380c-namespace.js +224 -0
  126. package/src/tui-compiled/runtime/shared/112607e46a5b5f58-accounts.js +393 -0
  127. package/src/tui-compiled/runtime/shared/136fa4abe48ad69d-cachekeep.js +411 -0
  128. package/src/tui-compiled/runtime/shared/1547bd74f4214d2d-index.js +28 -0
  129. package/src/tui-compiled/runtime/shared/1567207f323dc733-codex-http.js +44 -0
  130. package/src/tui-compiled/runtime/shared/15f402885cbb2fb3-envelope-loss.js +151 -0
  131. package/src/tui-compiled/runtime/shared/18df43cab4563acf-families.js +149 -0
  132. package/src/tui-compiled/runtime/shared/1a4c289eec261e04-codex-instructions.js +59 -0
  133. package/src/tui-compiled/runtime/shared/1afd446e190ef85c-vault-messages.js +12 -0
  134. package/src/tui-compiled/runtime/shared/1b06ec96856ff8b9-codex-endpoint.js +17 -0
  135. package/src/tui-compiled/runtime/shared/1e2f1a89bb34a773-vault-adapter.js +110 -0
  136. package/src/tui-compiled/runtime/shared/2194fb8e8b42d7d5-insula-quota.js +73 -0
  137. package/src/tui-compiled/runtime/shared/22b2bce42f2d6806-handle.js +10 -0
  138. package/src/tui-compiled/runtime/shared/2577ec69f9973ae9-quota-normalize.js +13 -14
  139. package/src/tui-compiled/runtime/shared/26055d4e5ad5e71f-codex-request.js +198 -0
  140. package/src/tui-compiled/runtime/shared/26b57ac4c3b0c3f6-unconfirmed-retain-counter.js +41 -0
  141. package/src/tui-compiled/runtime/shared/2bb681e99c2721d7-registry.js +538 -0
  142. package/src/tui-compiled/runtime/shared/2dce6e9613993329-quota-manager.js +13 -20
  143. package/src/tui-compiled/runtime/shared/2ec33b3e2b8ac38a-terminal.js +168 -0
  144. package/src/tui-compiled/runtime/shared/30bcca1d1b4240a0-pool-session-pins.js +32 -0
  145. package/src/tui-compiled/runtime/shared/3af9a210aa2ccdf2-codex-call-status.js +21 -0
  146. package/src/tui-compiled/runtime/shared/3b31b36bf0877602-wording.js +120 -0
  147. package/src/tui-compiled/runtime/shared/3c4c1a2d3fc92726-failure.js +59 -0
  148. package/src/tui-compiled/runtime/shared/3dfe71eec6e0487d-presets.js +240 -0
  149. package/src/tui-compiled/runtime/shared/43de3a5c4845cfc1-pool-adapter.js +149 -0
  150. package/src/tui-compiled/runtime/shared/49353b63a833c8fb-session-cache-policy.js +60 -0
  151. package/src/tui-compiled/runtime/shared/4adf46e07e025363-axes.js +7 -0
  152. package/src/tui-compiled/runtime/shared/4ba847b77580b1eb-confirm.js +21 -0
  153. package/src/tui-compiled/runtime/shared/4d05c2d7a531aece-oauth.js +48 -36
  154. package/src/tui-compiled/runtime/shared/5018d4665e969588-limit-policy.js +159 -0
  155. package/src/tui-compiled/runtime/shared/595bdf3fff13ba79-limit-identity.js +49 -0
  156. package/src/tui-compiled/runtime/shared/59def9e82b61204a-session-cache-activity.js +35 -0
  157. package/src/tui-compiled/runtime/shared/5d806e1a305d14f5-commands.js +879 -0
  158. package/src/tui-compiled/runtime/shared/5fc39320fa8bd3a0-limit-registry.js +473 -0
  159. package/src/tui-compiled/runtime/shared/63c1ee7e70e85e8d-vault.js +1 -0
  160. package/src/tui-compiled/runtime/shared/6545ab7f757314b7-refresh-all-quota.js +237 -0
  161. package/src/tui-compiled/runtime/shared/66937534c260d20b-stable-json.js +11 -0
  162. package/src/tui-compiled/runtime/shared/7056acef1b021f19-bridge.js +10 -0
  163. package/src/tui-compiled/runtime/shared/72d2ca42883809b4-marker.js +107 -0
  164. package/src/tui-compiled/runtime/shared/775431e21f469203-record.js +3 -0
  165. package/src/tui-compiled/runtime/shared/799f3ade4efbd1ea-opencode-v1.js +47 -0
  166. package/src/tui-compiled/runtime/shared/7b2a0471b29e4f5e-wake.js +47 -0
  167. package/src/tui-compiled/runtime/shared/7b5d6afff4ff32b9-select.js +159 -0
  168. package/src/tui-compiled/runtime/shared/7bf96bf4d9249b3d-vault-billing.js +108 -0
  169. package/src/tui-compiled/runtime/shared/7c98bde36aad4819-input-transformations.js +34 -0
  170. package/src/tui-compiled/runtime/shared/7fb0418303f20a10-index.js +3 -0
  171. package/src/tui-compiled/runtime/shared/806e12ccbad34388-pi-wait.js +51 -0
  172. package/src/tui-compiled/runtime/shared/81ae201b724cac14-menu.js +73 -0
  173. package/src/tui-compiled/runtime/shared/8349ed25dc629e97-scope.js +10 -0
  174. package/src/tui-compiled/runtime/shared/86da3379973780b9-limit-provenance.js +60 -0
  175. package/src/tui-compiled/runtime/shared/8aba66ed486d30a7-decide.js +425 -0
  176. package/src/tui-compiled/runtime/shared/8c0c8df25a5dca1f-manager.js +735 -0
  177. package/src/tui-compiled/runtime/shared/8c42bbec02f59636-vault-routing.js +212 -0
  178. package/src/tui-compiled/runtime/shared/8ca6175bfae53e13-envelope.js +123 -0
  179. package/src/tui-compiled/runtime/shared/8d0245e41049d83f-header-classifier.js +121 -0
  180. package/src/tui-compiled/runtime/shared/9c162809179c7560-login.js +89 -0
  181. package/src/tui-compiled/runtime/shared/a1f495296a4b756f-frame-turn.js +72 -0
  182. package/src/tui-compiled/runtime/shared/a37138dcbd893f55-hold-bounds.js +5 -0
  183. package/src/tui-compiled/runtime/shared/aa7fb10d77a2cccd-vault-account-menu.js +133 -0
  184. package/src/tui-compiled/runtime/shared/adc5eeb5a8d28280-persistence.js +9 -0
  185. package/src/tui-compiled/runtime/shared/b301c79e6378d1fb-vault.js +678 -0
  186. package/src/tui-compiled/runtime/shared/b3c11de5f36e617a-reset.js +44 -0
  187. package/src/tui-compiled/runtime/shared/ba6535c610d1edb3-pool-source-state.js +100 -0
  188. package/src/tui-compiled/runtime/shared/bd4aef685681048c-duration.js +20 -0
  189. package/src/tui-compiled/runtime/shared/bd5977eca210d2b8-index.js +662 -0
  190. package/src/tui-compiled/runtime/shared/bfc46d34f4c9db33-limit-recovery.js +127 -0
  191. package/src/tui-compiled/runtime/shared/c66495424ad84aee-hold.js +25 -0
  192. package/src/tui-compiled/runtime/shared/c6a67b836bd5afcd-vault-command-menu.js +300 -0
  193. package/src/tui-compiled/runtime/shared/c9340fb545c4e5de-internal.js +73 -0
  194. package/src/tui-compiled/runtime/shared/c954c6447b7b9b64-activity.js +52 -0
  195. package/src/tui-compiled/runtime/shared/cba8b0aee46b8526-codex-lite.js +85 -0
  196. package/src/tui-compiled/runtime/shared/cec39ccddab4fe9c-labels.js +11 -0
  197. package/src/tui-compiled/runtime/shared/cef0f2346957e83c-index.js +552 -0
  198. package/src/tui-compiled/runtime/shared/cf7dedf24f902d68-dump-size.js +41 -0
  199. package/src/tui-compiled/runtime/shared/d422d6dbc4e35199-background-quota-refresh.js +107 -0
  200. package/src/tui-compiled/runtime/shared/d5b268767d330507-doctor.js +81 -0
  201. package/src/tui-compiled/runtime/shared/d7ac5ca41f49121b-index.js +12 -0
  202. package/src/tui-compiled/runtime/shared/d7fa77560855dee2-jitter.js +9 -0
  203. package/src/tui-compiled/runtime/shared/de7f7d8803624369-path.js +31 -0
  204. package/src/tui-compiled/runtime/shared/df0bdc74fb0c0db0-limit-mark.js +27 -0
  205. package/src/tui-compiled/runtime/shared/e26c2bb5722ab047-routing-hold.js +23 -0
  206. package/src/tui-compiled/runtime/shared/e2ae081583adfce3-dump.js +80 -0
  207. package/src/tui-compiled/runtime/shared/e44ba1b3a9903f5d-reset-credits.js +483 -0
  208. package/src/tui-compiled/runtime/shared/e5229952fc12f647-codex-models.js +34 -0
  209. package/src/tui-compiled/runtime/shared/e8fda84e90176436-uuid-v7.js +13 -0
  210. package/src/tui-compiled/runtime/shared/ea56007991dbf068-terminal.js +19 -0
  211. package/src/tui-compiled/runtime/shared/ec6f1d96e7d70174-quota-refusal.js +145 -0
  212. package/src/tui-compiled/runtime/shared/f03d7b43a214a4a1-canonical-input.js +42 -0
  213. package/src/tui-compiled/runtime/shared/f1012265b3a768c7-merge-laws.js +31 -0
  214. package/src/tui-compiled/runtime/shared/f2ca864fe967415a-cache-policy.js +198 -0
  215. package/src/tui-compiled/runtime/shared/f317a4740f9d76f8-identity.js +21 -0
  216. package/src/tui-compiled/runtime/shared/f607353c4126272a-routing-wait.js +19 -0
  217. package/src/tui-compiled/runtime/shared/f6189f5c9aee31eb-decision.js +55 -0
  218. package/src/tui-compiled/runtime/shared/f6d728f5e601f98b-request-history.js +120 -0
  219. package/src/tui-compiled/runtime/shared/f981e6b15fb76cdb-codex-body.js +28 -0
  220. package/src/tui-compiled/runtime/shared/fda579e5a0a54165-codex-effort.js +60 -0
  221. package/src/tui-compiled/runtime/sidebar-state.js +54 -4
  222. package/src/tui-compiled/runtime/tui/v2-dialog.js +1 -1
  223. package/src/tui-compiled/runtime/tui.js +11 -4
  224. package/dist/index-0p8r7cpy.js +0 -60
  225. package/dist/index-px1t650b.js +0 -2
  226. package/dist/map-D5PHhv4z.d.ts +0 -72
@@ -0,0 +1,662 @@
1
+ /**
2
+ * Optional THALAMUS routing for vault mode, plugin wait reports and advisory turn
3
+ * notes for request shaping. Account ids are vault account ids, not local pool
4
+ * rows. Nothing is persisted here; plugins on routes the runner does not serve
5
+ * get no turn notes.
6
+ */
7
+ import { createHash, randomUUID } from "node:crypto";
8
+ import { isCacheWarmStopReason, } from "./f2ca864fe967415a-cache-policy.js";
9
+ import { routingHandle } from "./22b2bce42f2d6806-handle.js";
10
+ const REQUEST_ID_MAX_LENGTH = 128;
11
+ // Give the bridge time to abandon the ask without waiting forever on a broken bridge.
12
+ const ASK_JOIN_GRACE_MS = 500;
13
+ export { CACHE_WARM_STOP_REASONS, isCacheWarmStopReason, reportCacheTouch, reportCacheWarmStopped, sessionCachePolicy, sessionToolWait, } from "./f2ca864fe967415a-cache-policy.js";
14
+ /** Keep this closed list aligned with the routing contract when adding a reason. */
15
+ export const PLUGIN_WAIT_REASONS = [
16
+ 'account_limit',
17
+ 'account_free',
18
+ 'rate_limited',
19
+ 'server_busy',
20
+ 'quota_reading',
21
+ 'routing_hold',
22
+ ];
23
+ function isObject(value) {
24
+ return typeof value === 'object' && value !== null;
25
+ }
26
+ function isNonEmptyString(value) {
27
+ return typeof value === 'string' && value.length > 0;
28
+ }
29
+ function isBoundedControlFreeString(value, maxLength) {
30
+ return (isNonEmptyString(value) &&
31
+ value.length <= maxLength &&
32
+ !/\p{Cc}/u.test(value));
33
+ }
34
+ function isRoutingCode(value) {
35
+ return typeof value === 'string' && /^[a-z0-9._-]{1,64}$/.test(value);
36
+ }
37
+ function continueExhaustion(value) {
38
+ if (!isObject(value) || Array.isArray(value))
39
+ return undefined;
40
+ const { accountId, credentialId, limitWindow, observedAtMs } = value;
41
+ if (!isBoundedControlFreeString(accountId, 256) ||
42
+ !isBoundedControlFreeString(credentialId, 256) ||
43
+ typeof observedAtMs !== 'number' ||
44
+ !Number.isSafeInteger(observedAtMs) ||
45
+ observedAtMs <= 0 ||
46
+ (limitWindow !== 'five_hour' &&
47
+ limitWindow !== 'seven_day' &&
48
+ limitWindow !== 'signed_out'))
49
+ return undefined;
50
+ const exhausted = {
51
+ account: accountId,
52
+ credential_id: credentialId,
53
+ limit_window: limitWindow,
54
+ observed_at_ms: observedAtMs,
55
+ };
56
+ if (limitWindow === 'signed_out') {
57
+ if ('pool' in value || 'resetsAtMs' in value || 'retryAfterS' in value)
58
+ return undefined;
59
+ return exhausted;
60
+ }
61
+ const { pool, resetsAtMs, retryAfterS } = value;
62
+ if ((pool !== undefined && !isRoutingCode(pool)) ||
63
+ (resetsAtMs !== undefined &&
64
+ (typeof resetsAtMs !== 'number' ||
65
+ !Number.isSafeInteger(resetsAtMs) ||
66
+ resetsAtMs <= 0)) ||
67
+ (retryAfterS !== undefined &&
68
+ (typeof retryAfterS !== 'number' ||
69
+ !Number.isFinite(retryAfterS) ||
70
+ retryAfterS < 0)))
71
+ return undefined;
72
+ return {
73
+ ...exhausted,
74
+ ...(pool !== undefined ? { pool } : {}),
75
+ ...(resetsAtMs !== undefined ? { resets_at_ms: resetsAtMs } : {}),
76
+ ...(retryAfterS !== undefined
77
+ ? { retry_after_s: Math.floor(retryAfterS) }
78
+ : {}),
79
+ };
80
+ }
81
+ function billingCache(value) {
82
+ if (!isObject(value) || Array.isArray(value))
83
+ return;
84
+ const { ttlMs, implicit, warming } = value;
85
+ const cache = {};
86
+ // Conflicting lifetime claims cannot prove what the request cached.
87
+ if (!(ttlMs !== undefined && implicit !== undefined)) {
88
+ if (typeof ttlMs === 'number' && Number.isSafeInteger(ttlMs) && ttlMs > 0) {
89
+ cache.ttl_ms = ttlMs;
90
+ }
91
+ else if (implicit === true) {
92
+ cache.implicit = true;
93
+ }
94
+ }
95
+ if (isObject(warming) && !Array.isArray(warming)) {
96
+ const { on, stopReason } = warming;
97
+ if (typeof on === 'boolean') {
98
+ cache.warming = {
99
+ on,
100
+ ...(!on && isCacheWarmStopReason(stopReason)
101
+ ? { stop_reason: stopReason }
102
+ : {}),
103
+ };
104
+ }
105
+ }
106
+ return Object.keys(cache).length > 0 ? cache : undefined;
107
+ }
108
+ function billingUsage(value) {
109
+ if (!isObject(value) || Array.isArray(value))
110
+ return;
111
+ const usage = {};
112
+ for (const [inputKey, payloadKey] of [
113
+ ['input', 'input'],
114
+ ['output', 'output'],
115
+ ['cacheRead', 'cache_read'],
116
+ ['cacheWrite', 'cache_write'],
117
+ ['cacheWrite5m', 'cache_write_5m'],
118
+ ['cacheWrite1h', 'cache_write_1h'],
119
+ ['reasoning', 'reasoning'],
120
+ ]) {
121
+ const count = value[inputKey];
122
+ if (typeof count === 'number' &&
123
+ Number.isSafeInteger(count) &&
124
+ count >= 0) {
125
+ usage[payloadKey] = count;
126
+ }
127
+ }
128
+ const reasoningIncludedInOutput = value.reasoningIncludedInOutput;
129
+ if (typeof reasoningIncludedInOutput === 'boolean') {
130
+ usage.reasoning_included_in_output = reasoningIncludedInOutput;
131
+ }
132
+ return Object.keys(usage).length > 0 ? usage : undefined;
133
+ }
134
+ /**
135
+ * Read advisory input for request shaping, in landing order, without persisting
136
+ * it. If no routing handle is available or the runner does not serve the route,
137
+ * returns [].
138
+ */
139
+ export function turnNotes(sessionId) {
140
+ try {
141
+ const handle = routingHandle(sessionId);
142
+ if (!handle)
143
+ return [];
144
+ const read = handle.turn_notes;
145
+ if (typeof read !== 'function')
146
+ return [];
147
+ const answer = read.call(handle);
148
+ if (isObject(answer) && typeof answer.then === 'function') {
149
+ void Promise.resolve(answer).catch(() => { });
150
+ return [];
151
+ }
152
+ if (!Array.isArray(answer))
153
+ return [];
154
+ const notes = [];
155
+ const encoder = new TextEncoder();
156
+ for (const entry of answer) {
157
+ try {
158
+ if (!isObject(entry) || Array.isArray(entry))
159
+ continue;
160
+ const afterToolUseId = entry.after_tool_use_id;
161
+ const text = entry.text;
162
+ if (typeof afterToolUseId !== 'string' ||
163
+ afterToolUseId.length === 0 ||
164
+ typeof text !== 'string' ||
165
+ // A whitespace-only note says nothing and a provider may refuse it.
166
+ text.trim().length === 0 ||
167
+ encoder.encode(text).byteLength > 16_384)
168
+ continue;
169
+ notes.push({ afterToolUseId, text });
170
+ }
171
+ catch {
172
+ // One unreadable note entry must not hide its valid neighbours.
173
+ }
174
+ }
175
+ return notes;
176
+ }
177
+ catch {
178
+ // Turn notes are optional and must not break request shaping.
179
+ return [];
180
+ }
181
+ }
182
+ function candidateView(candidates) {
183
+ const accounts = [];
184
+ for (const { accountId, credentialId } of candidates) {
185
+ if (isNonEmptyString(accountId) &&
186
+ isBoundedControlFreeString(credentialId, 256)) {
187
+ accounts.push({ account_id: accountId, credential_id: credentialId });
188
+ }
189
+ }
190
+ const lines = accounts
191
+ .map(({ account_id, credential_id }) => Buffer.from(`${account_id}\t${credential_id}\n`, 'utf8'))
192
+ .sort(Buffer.compare);
193
+ const hash = createHash('sha256');
194
+ for (const line of lines)
195
+ hash.update(line);
196
+ return { view_digest: hash.digest('hex'), accounts };
197
+ }
198
+ function selectionFor(answer, candidates) {
199
+ if (!isObject(answer))
200
+ return undefined;
201
+ const accountId = answer.account_id;
202
+ const credentialId = answer.credential_id;
203
+ if (typeof accountId !== 'string')
204
+ return undefined;
205
+ if (credentialId !== undefined && typeof credentialId !== 'string') {
206
+ return undefined;
207
+ }
208
+ const candidate = candidates.find((route) => route.accountId === accountId &&
209
+ (credentialId === undefined || route.credentialId === credentialId));
210
+ if (!candidate)
211
+ return undefined;
212
+ const hold = answer.hold;
213
+ const retryAfterMs = isObject(hold) ? hold.retry_after_ms : undefined;
214
+ if (typeof retryAfterMs === 'number' &&
215
+ Number.isFinite(retryAfterMs) &&
216
+ retryAfterMs >= 0) {
217
+ return { candidate, hold: { retry_after_ms: retryAfterMs } };
218
+ }
219
+ return { candidate };
220
+ }
221
+ function refusalFor(value) {
222
+ if (!isObject(value))
223
+ return undefined;
224
+ const code = value.code;
225
+ if (code !== 'account_limit_exhausted' &&
226
+ code !== 'account_selection_refused' &&
227
+ code !== 'account_selection_final' &&
228
+ code !== 'concurrency_full') {
229
+ return undefined;
230
+ }
231
+ const refused = { code };
232
+ const { routing_code: routingCode, reason } = value;
233
+ if (isRoutingCode(routingCode))
234
+ refused.routingCode = routingCode;
235
+ if (isRoutingCode(reason))
236
+ refused.reason = reason;
237
+ const retryAfterSecs = value.retry_after_secs;
238
+ if (typeof retryAfterSecs === 'number' &&
239
+ Number.isFinite(retryAfterSecs) &&
240
+ retryAfterSecs >= 0) {
241
+ refused.retryAfterSecs = retryAfterSecs;
242
+ }
243
+ const resetsAtMs = value.resets_at_ms;
244
+ if (typeof resetsAtMs === 'number' &&
245
+ Number.isSafeInteger(resetsAtMs) &&
246
+ resetsAtMs > 0) {
247
+ refused.resetsAtMs = resetsAtMs;
248
+ }
249
+ else if (code === 'concurrency_full') {
250
+ return undefined;
251
+ }
252
+ return { refused };
253
+ }
254
+ export function askRouting(input) {
255
+ return askRoutingOnce(input, false);
256
+ }
257
+ async function askRoutingOnce(input, waitsForCapacity) {
258
+ const interrupted = Symbol();
259
+ let signal;
260
+ let timer;
261
+ let onAbort;
262
+ try {
263
+ signal = input.signal;
264
+ signal?.throwIfAborted();
265
+ const request = {
266
+ provider: input.provider,
267
+ modelId: input.modelId,
268
+ };
269
+ const { requestId } = input;
270
+ if (input.mode === 'continue') {
271
+ if (!isBoundedControlFreeString(requestId, REQUEST_ID_MAX_LENGTH))
272
+ return undefined;
273
+ const exhausted = continueExhaustion(input.exhausted);
274
+ if (!exhausted)
275
+ return undefined;
276
+ request.mode = 'continue';
277
+ request.request_id = requestId;
278
+ request.exhausted = exhausted;
279
+ }
280
+ else if (input.mode === undefined &&
281
+ isBoundedControlFreeString(requestId, REQUEST_ID_MAX_LENGTH)) {
282
+ request.request_id = requestId;
283
+ }
284
+ const handle = routingHandle(input.sessionId);
285
+ if (!handle)
286
+ return undefined;
287
+ const accountFor = handle.accountFor;
288
+ if (typeof accountFor !== 'function')
289
+ return undefined;
290
+ const requested = input.deadlineMs ?? 1500;
291
+ const deadlineMs = Number.isNaN(requested)
292
+ ? 1500
293
+ : Math.min(2000, Math.max(1, requested));
294
+ const stopped = new Promise((resolve) => {
295
+ const stop = () => resolve(interrupted);
296
+ if (signal) {
297
+ onAbort = stop;
298
+ signal.addEventListener('abort', onAbort, { once: true });
299
+ }
300
+ timer = setTimeout(stop, deadlineMs);
301
+ timer.unref();
302
+ });
303
+ const cap = input.holdWaitMaxS;
304
+ if (typeof cap === 'number' && Number.isFinite(cap)) {
305
+ request.hold_wait_max_s = Math.max(0, Math.floor(cap));
306
+ }
307
+ if (input.refusals === true)
308
+ request.refusals = true;
309
+ if (waitsForCapacity)
310
+ request.waits_for_capacity = true;
311
+ const warmCredentialId = input.warmCredentialId;
312
+ if (isBoundedControlFreeString(warmCredentialId, 256) &&
313
+ input.candidates.some((candidate) => candidate.credentialId === warmCredentialId)) {
314
+ request.warm_credential = warmCredentialId;
315
+ }
316
+ const candidates = candidateView(input.candidates);
317
+ // A first ask with nothing usable sends no view, so routing is unrestricted
318
+ // as before. A continue ask always sends one: an empty view after the only
319
+ // account was refused tells routing nothing is left to offer, where a
320
+ // missing view would let it hand back the refused account.
321
+ if (candidates.accounts.length > 0 || request.mode === 'continue')
322
+ request.candidates = candidates;
323
+ signal?.throwIfAborted();
324
+ const pending = accountFor.call(handle, request, signal ? { deadlineMs, signal } : { deadlineMs });
325
+ if (!isObject(pending) || typeof pending.then !== 'function')
326
+ return undefined;
327
+ const bridge = Promise.resolve(pending);
328
+ const answer = await Promise.race([bridge, stopped]);
329
+ if (answer === interrupted) {
330
+ clearTimeout(timer);
331
+ const grace = new Promise((resolve) => {
332
+ timer = setTimeout(resolve, ASK_JOIN_GRACE_MS);
333
+ timer.unref();
334
+ });
335
+ await Promise.race([bridge, grace]);
336
+ return undefined;
337
+ }
338
+ signal?.throwIfAborted();
339
+ if (input.refusals === true && isObject(answer) && 'refused' in answer) {
340
+ return refusalFor(answer.refused);
341
+ }
342
+ return selectionFor(answer, input.candidates);
343
+ }
344
+ catch {
345
+ // The process-global bridge is optional and must not break authentication.
346
+ return undefined;
347
+ }
348
+ finally {
349
+ clearTimeout(timer);
350
+ if (onAbort)
351
+ signal?.removeEventListener('abort', onAbort);
352
+ signal?.throwIfAborted();
353
+ }
354
+ }
355
+ async function sleepForCapacity(ms, signal) {
356
+ do {
357
+ signal?.throwIfAborted();
358
+ // A delay above the platform timer limit would fire almost immediately.
359
+ const delay = Math.min(ms, 2_147_483_647);
360
+ await new Promise((resolve, reject) => {
361
+ function onAbort() {
362
+ clearTimeout(timer);
363
+ reject(signal?.reason);
364
+ }
365
+ const timer = setTimeout(() => {
366
+ signal?.removeEventListener('abort', onAbort);
367
+ resolve();
368
+ }, delay);
369
+ timer.unref();
370
+ signal?.addEventListener('abort', onAbort, { once: true });
371
+ });
372
+ ms -= delay;
373
+ } while (ms > 0);
374
+ }
375
+ /**
376
+ * Retry the same routing question until capacity opens or routing gives a
377
+ * different answer. There is no overall deadline: a capacity wait is never
378
+ * terminal. Pass an AbortSignal when available; OpenCode 2's WebSocket
379
+ * handshake has no AbortSignal.
380
+ *
381
+ * Each ask sends `waits_for_capacity: true`. Without that flag, the relay
382
+ * maps a capacity refusal to `account_selection_final` so a caller that
383
+ * cannot wait does not send past the cap.
384
+ */
385
+ export async function askRoutingUntilCapacity(input, options) {
386
+ const { signal = input.signal, now = Date.now, sleep = sleepForCapacity, } = options;
387
+ signal?.throwIfAborted();
388
+ const request = input.mode === 'continue'
389
+ ? { ...input, refusals: true, signal }
390
+ : {
391
+ ...input,
392
+ refusals: true,
393
+ signal,
394
+ requestId: isBoundedControlFreeString(input.requestId, REQUEST_ID_MAX_LENGTH)
395
+ ? input.requestId
396
+ : randomUUID(),
397
+ };
398
+ while (true) {
399
+ signal?.throwIfAborted();
400
+ const answer = await askRoutingOnce(request, true);
401
+ signal?.throwIfAborted();
402
+ if (answer && 'refused' in answer) {
403
+ const { code, resetsAtMs } = answer.refused;
404
+ if (code === 'concurrency_full' && resetsAtMs !== undefined) {
405
+ const remainingMs = resetsAtMs - now();
406
+ signal?.throwIfAborted();
407
+ try {
408
+ await sleep(remainingMs < 0 ? 1000 : remainingMs, signal);
409
+ }
410
+ finally {
411
+ signal?.throwIfAborted();
412
+ }
413
+ continue;
414
+ }
415
+ }
416
+ return answer;
417
+ }
418
+ }
419
+ /**
420
+ * Report a vault request, account backoff, billing result, plugin wait or
421
+ * turn-note event without waiting for routing. Only contract fields are sent,
422
+ * and all accessor failures are ignored. Headers must already be limited to
423
+ * rate-limit headers by the caller; values are not filtered or redacted here.
424
+ */
425
+ export function reportRouting(input) {
426
+ try {
427
+ const sessionId = input.sessionId;
428
+ const handle = routingHandle(sessionId);
429
+ if (!handle)
430
+ return;
431
+ const report = handle.report;
432
+ if (typeof report !== 'function')
433
+ return;
434
+ let payload;
435
+ if ('kind' in input) {
436
+ switch (input.kind) {
437
+ case 'transient_backoff': {
438
+ const { accountId, credentialId, retryAtMs, providerCode } = input;
439
+ if (!isNonEmptyString(sessionId) ||
440
+ !isNonEmptyString(accountId) ||
441
+ !Number.isSafeInteger(retryAtMs) ||
442
+ retryAtMs <= 0 ||
443
+ (credentialId !== undefined &&
444
+ !isBoundedControlFreeString(credentialId, 256)) ||
445
+ (providerCode !== undefined &&
446
+ !isBoundedControlFreeString(providerCode, 128)))
447
+ return;
448
+ payload = {
449
+ kind: 'transient_backoff',
450
+ account_id: accountId,
451
+ ...(credentialId !== undefined
452
+ ? { credential_id: credentialId }
453
+ : {}),
454
+ retry_at_ms: retryAtMs,
455
+ ...(providerCode !== undefined
456
+ ? { provider_code: providerCode }
457
+ : {}),
458
+ };
459
+ break;
460
+ }
461
+ case 'wait': {
462
+ const { phase, waitId, reason, nextMs, attempt, message, outcome } = input;
463
+ if (!isNonEmptyString(sessionId) ||
464
+ (phase !== 'start' && phase !== 'end') ||
465
+ !isNonEmptyString(waitId) ||
466
+ waitId.length > 64 ||
467
+ /[^A-Za-z0-9._:-]/.test(waitId) ||
468
+ !PLUGIN_WAIT_REASONS.includes(reason))
469
+ return;
470
+ payload = {
471
+ kind: 'wait',
472
+ phase,
473
+ wait_id: waitId,
474
+ reason,
475
+ ...(typeof nextMs === 'number' &&
476
+ Number.isSafeInteger(nextMs) &&
477
+ nextMs > 0
478
+ ? { next_ms: nextMs }
479
+ : {}),
480
+ ...(typeof attempt === 'number' &&
481
+ Number.isInteger(attempt) &&
482
+ attempt >= 1
483
+ ? { attempt }
484
+ : {}),
485
+ ...(typeof message === 'string' &&
486
+ message.length >= 1 &&
487
+ message.length <= 160 &&
488
+ !/\p{Cc}/u.test(message)
489
+ ? { message }
490
+ : {}),
491
+ ...(phase === 'end' &&
492
+ (outcome === 'resumed' ||
493
+ outcome === 'cancelled' ||
494
+ outcome === 'abandoned')
495
+ ? { outcome }
496
+ : {}),
497
+ };
498
+ break;
499
+ }
500
+ case 'billing': {
501
+ const { attemptId, requestKind, credentialId, provider, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache, } = input;
502
+ if (!isNonEmptyString(attemptId) ||
503
+ !isNonEmptyString(credentialId) ||
504
+ !isNonEmptyString(provider) ||
505
+ !isNonEmptyString(model) ||
506
+ (requestKind !== 'primary' &&
507
+ requestKind !== 'title' &&
508
+ requestKind !== 'compaction' &&
509
+ requestKind !== 'generate' &&
510
+ requestKind !== 'keep_warm' &&
511
+ requestKind !== 'prime') ||
512
+ (outcome !== 'completed' &&
513
+ outcome !== 'cut' &&
514
+ outcome !== 'failed'))
515
+ return;
516
+ const usage = billingUsage(inputUsage);
517
+ const cache = billingCache(inputCache);
518
+ const usageByModel = [];
519
+ if (Array.isArray(inputUsageByModel)) {
520
+ for (const entry of inputUsageByModel) {
521
+ if (!isObject(entry) || Array.isArray(entry))
522
+ continue;
523
+ const modelUsed = entry.modelUsed;
524
+ if (!isNonEmptyString(modelUsed))
525
+ continue;
526
+ const modelUsage = billingUsage(entry.usage);
527
+ // Thalamus rejects the whole report when an entry has no usage
528
+ // object, so an entry without a valid reading is dropped.
529
+ if (!modelUsage)
530
+ continue;
531
+ usageByModel.push({ model_used: modelUsed, usage: modelUsage });
532
+ }
533
+ }
534
+ payload = {
535
+ kind: 'billing',
536
+ attempt_id: attemptId,
537
+ request_kind: requestKind,
538
+ credential_id: credentialId,
539
+ provider,
540
+ model,
541
+ outcome,
542
+ ...(isNonEmptyString(accountId) ? { account_id: accountId } : {}),
543
+ ...(isNonEmptyString(providerRequestId)
544
+ ? { provider_request_id: providerRequestId }
545
+ : {}),
546
+ ...(isNonEmptyString(providerResponseId)
547
+ ? { provider_response_id: providerResponseId }
548
+ : {}),
549
+ ...(isNonEmptyString(userMessageId)
550
+ ? { user_message_id: userMessageId }
551
+ : {}),
552
+ ...(typeof status === 'number' &&
553
+ Number.isInteger(status) &&
554
+ status >= 0
555
+ ? { status }
556
+ : {}),
557
+ ...(typeof attempt === 'number' &&
558
+ Number.isInteger(attempt) &&
559
+ attempt >= 1
560
+ ? { attempt }
561
+ : {}),
562
+ ...(chargeBasis === 'subscription_included' ||
563
+ chargeBasis === 'metered_api'
564
+ ? { charge_basis: chargeBasis }
565
+ : {}),
566
+ ...(usage ? { usage } : {}),
567
+ ...(usageByModel.length > 0
568
+ ? { usage_by_model: usageByModel }
569
+ : {}),
570
+ ...(cache ? { cache } : {}),
571
+ };
572
+ break;
573
+ }
574
+ case 'turn_notes_supported': {
575
+ const { model, supported } = input;
576
+ if (typeof model !== 'string' ||
577
+ model.length === 0 ||
578
+ typeof supported !== 'boolean')
579
+ return;
580
+ payload = {
581
+ kind: 'turn_notes_supported',
582
+ model,
583
+ supported,
584
+ };
585
+ break;
586
+ }
587
+ case 'turn_note_skipped': {
588
+ const { after_tool_use_id, reason } = input;
589
+ if (typeof after_tool_use_id !== 'string' ||
590
+ after_tool_use_id.length === 0 ||
591
+ (reason !== 'anchor_missing' &&
592
+ reason !== 'before_user_message' &&
593
+ reason !== 'unsupported_model' &&
594
+ reason !== 'not_oauth'))
595
+ return;
596
+ payload = {
597
+ kind: 'turn_note_skipped',
598
+ after_tool_use_id,
599
+ reason,
600
+ };
601
+ break;
602
+ }
603
+ default:
604
+ return;
605
+ }
606
+ }
607
+ else {
608
+ const identity = {
609
+ account_id: input.accountId,
610
+ ...(input.credentialId !== undefined
611
+ ? { credential_id: input.credentialId }
612
+ : {}),
613
+ };
614
+ switch (input.outcome) {
615
+ case 'served':
616
+ payload = { ...identity, outcome: 'served', headers: input.headers };
617
+ break;
618
+ case 'exhausted': {
619
+ const { window, pool } = input;
620
+ if (window !== '5h' && window !== '7d')
621
+ return;
622
+ // An undefined pool means the whole account, as an omitted one does.
623
+ if (pool !== undefined && !isRoutingCode(pool))
624
+ return;
625
+ payload = {
626
+ ...identity,
627
+ outcome: 'exhausted',
628
+ window,
629
+ ...(pool ? { pool } : {}),
630
+ ...(input.resetsAt !== undefined
631
+ ? { resets_at: input.resetsAt }
632
+ : {}),
633
+ };
634
+ break;
635
+ }
636
+ case 'credential_refused': {
637
+ const { credentialId, providerCode } = input;
638
+ if (!isNonEmptyString(credentialId) ||
639
+ typeof providerCode !== 'string' ||
640
+ !/^[a-z0-9._-]{1,64}$/.test(providerCode))
641
+ return;
642
+ payload = {
643
+ ...identity,
644
+ outcome: 'credential_refused',
645
+ provider_code: providerCode,
646
+ };
647
+ break;
648
+ }
649
+ default:
650
+ return;
651
+ }
652
+ }
653
+ // A broken bridge may return a rejected promise despite its void contract.
654
+ const pending = report.call(handle, payload);
655
+ if (isObject(pending) && typeof pending.then === 'function') {
656
+ void Promise.resolve(pending).catch(() => { });
657
+ }
658
+ }
659
+ catch {
660
+ // Reporting must never change the result of an auth request.
661
+ }
662
+ }