@superblocksteam/vite-plugin-file-sync 2.0.158 → 2.0.159-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/dist/ai-service/agent/middleware.d.ts +1 -2
  2. package/dist/ai-service/agent/middleware.d.ts.map +1 -1
  3. package/dist/ai-service/agent/middleware.js +2 -3
  4. package/dist/ai-service/agent/middleware.js.map +1 -1
  5. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  6. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +5 -4
  7. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  8. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  9. package/dist/ai-service/agent/tool-message-utils.js +16 -1
  10. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  11. package/dist/ai-service/agent/tool-result-metrics.d.ts +29 -0
  12. package/dist/ai-service/agent/tool-result-metrics.d.ts.map +1 -0
  13. package/dist/ai-service/agent/tool-result-metrics.js +162 -0
  14. package/dist/ai-service/agent/tool-result-metrics.js.map +1 -0
  15. package/dist/ai-service/agent/tools/apis/test-api.d.ts +50 -1
  16. package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
  17. package/dist/ai-service/agent/tools/apis/test-api.js +132 -10
  18. package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
  19. package/dist/ai-service/agent/tools/build-delete-file.d.ts +1 -2
  20. package/dist/ai-service/agent/tools/build-delete-file.d.ts.map +1 -1
  21. package/dist/ai-service/agent/tools/build-delete-file.js +2 -0
  22. package/dist/ai-service/agent/tools/build-delete-file.js.map +1 -1
  23. package/dist/ai-service/agent/tools/build-edit-file.d.ts +1 -2
  24. package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
  25. package/dist/ai-service/agent/tools/build-edit-file.js +2 -0
  26. package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
  27. package/dist/ai-service/agent/tools/build-install-packages.d.ts +1 -0
  28. package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
  29. package/dist/ai-service/agent/tools/build-install-packages.js +123 -16
  30. package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
  31. package/dist/ai-service/agent/tools/build-lookup-npm-package.d.ts.map +1 -1
  32. package/dist/ai-service/agent/tools/build-lookup-npm-package.js +4 -16
  33. package/dist/ai-service/agent/tools/build-lookup-npm-package.js.map +1 -1
  34. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +11 -7
  35. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
  36. package/dist/ai-service/agent/tools/build-manage-checklist.js +18 -9
  37. package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -1
  38. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts +1 -2
  39. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
  40. package/dist/ai-service/agent/tools/build-multi-edit-file.js +2 -0
  41. package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
  42. package/dist/ai-service/agent/tools/build-read-file.d.ts.map +1 -1
  43. package/dist/ai-service/agent/tools/build-read-file.js +31 -18
  44. package/dist/ai-service/agent/tools/build-read-file.js.map +1 -1
  45. package/dist/ai-service/agent/tools/build-rename-file.d.ts +1 -2
  46. package/dist/ai-service/agent/tools/build-rename-file.d.ts.map +1 -1
  47. package/dist/ai-service/agent/tools/build-rename-file.js +2 -0
  48. package/dist/ai-service/agent/tools/build-rename-file.js.map +1 -1
  49. package/dist/ai-service/agent/tools/build-write-file.d.ts +1 -2
  50. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
  51. package/dist/ai-service/agent/tools/build-write-file.js +2 -0
  52. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
  53. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +3 -3
  54. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -1
  55. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +5 -7
  56. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -1
  57. package/dist/ai-service/agent/tools/debug-cache.d.ts +16 -14
  58. package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -1
  59. package/dist/ai-service/agent/tools/debug-cache.js +200 -42
  60. package/dist/ai-service/agent/tools/debug-cache.js.map +1 -1
  61. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +13 -13
  62. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
  63. package/dist/ai-service/agent/tools/integrations/execute-request.js +52 -20
  64. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
  65. package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts +7 -1
  66. package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts.map +1 -1
  67. package/dist/ai-service/agent/tools/integrations/sql-classification.js +229 -11
  68. package/dist/ai-service/agent/tools/integrations/sql-classification.js.map +1 -1
  69. package/dist/ai-service/agent/tools/page-edit-guidance.d.ts +2 -0
  70. package/dist/ai-service/agent/tools/page-edit-guidance.d.ts.map +1 -0
  71. package/dist/ai-service/agent/tools/page-edit-guidance.js +11 -0
  72. package/dist/ai-service/agent/tools/page-edit-guidance.js.map +1 -0
  73. package/dist/ai-service/agent/tools/report-security-findings.d.ts +5 -5
  74. package/dist/ai-service/agent/tools.d.ts +32 -0
  75. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  76. package/dist/ai-service/agent/tools.js +54 -33
  77. package/dist/ai-service/agent/tools.js.map +1 -1
  78. package/dist/ai-service/agent/tools2/registry.d.ts +1 -1
  79. package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
  80. package/dist/ai-service/agent/tools2/registry.js +21 -4
  81. package/dist/ai-service/agent/tools2/registry.js.map +1 -1
  82. package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts +2 -2
  83. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  84. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +20 -11
  85. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  86. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts +4 -0
  87. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts.map +1 -1
  88. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js +28 -8
  89. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js.map +1 -1
  90. package/dist/ai-service/agent/tools2/tools/update-test-case-status.d.ts +2 -2
  91. package/dist/ai-service/app-interface/cancellable-exec.d.ts +34 -0
  92. package/dist/ai-service/app-interface/cancellable-exec.d.ts.map +1 -0
  93. package/dist/ai-service/app-interface/cancellable-exec.js +98 -0
  94. package/dist/ai-service/app-interface/cancellable-exec.js.map +1 -0
  95. package/dist/ai-service/app-interface/shell.d.ts +20 -3
  96. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  97. package/dist/ai-service/app-interface/shell.js +139 -65
  98. package/dist/ai-service/app-interface/shell.js.map +1 -1
  99. package/dist/ai-service/attachment-upload.d.ts.map +1 -1
  100. package/dist/ai-service/attachment-upload.js +4 -1
  101. package/dist/ai-service/attachment-upload.js.map +1 -1
  102. package/dist/ai-service/attachments/parse-data-url.d.ts +5 -0
  103. package/dist/ai-service/attachments/parse-data-url.d.ts.map +1 -0
  104. package/dist/ai-service/attachments/parse-data-url.js +14 -0
  105. package/dist/ai-service/attachments/parse-data-url.js.map +1 -0
  106. package/dist/ai-service/chat/chat-session-store.d.ts +0 -8
  107. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  108. package/dist/ai-service/chat/chat-session-store.js +34 -611
  109. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  110. package/dist/ai-service/chat/utils.d.ts +2 -6
  111. package/dist/ai-service/chat/utils.d.ts.map +1 -1
  112. package/dist/ai-service/chat/utils.js +2 -95
  113. package/dist/ai-service/chat/utils.js.map +1 -1
  114. package/dist/ai-service/index.d.ts +3 -2
  115. package/dist/ai-service/index.d.ts.map +1 -1
  116. package/dist/ai-service/index.js +138 -48
  117. package/dist/ai-service/index.js.map +1 -1
  118. package/dist/ai-service/integrations/mention-safe-tag-name.d.ts +12 -0
  119. package/dist/ai-service/integrations/mention-safe-tag-name.d.ts.map +1 -0
  120. package/dist/ai-service/integrations/mention-safe-tag-name.js +18 -0
  121. package/dist/ai-service/integrations/mention-safe-tag-name.js.map +1 -0
  122. package/dist/ai-service/integrations/store.d.ts +9 -0
  123. package/dist/ai-service/integrations/store.d.ts.map +1 -1
  124. package/dist/ai-service/integrations/store.js +11 -1
  125. package/dist/ai-service/integrations/store.js.map +1 -1
  126. package/dist/ai-service/llm/client.d.ts.map +1 -1
  127. package/dist/ai-service/llm/client.js +67 -4
  128. package/dist/ai-service/llm/client.js.map +1 -1
  129. package/dist/ai-service/llm/context-v2/adapter.d.ts +1 -0
  130. package/dist/ai-service/llm/context-v2/adapter.d.ts.map +1 -1
  131. package/dist/ai-service/llm/context-v2/adapter.js +3 -0
  132. package/dist/ai-service/llm/context-v2/adapter.js.map +1 -1
  133. package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts +7 -0
  134. package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts.map +1 -1
  135. package/dist/ai-service/llm/context-v2/compaction/client-side.js +28 -6
  136. package/dist/ai-service/llm/context-v2/compaction/client-side.js.map +1 -1
  137. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts +12 -0
  138. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts.map +1 -1
  139. package/dist/ai-service/llm/context-v2/compactor.d.ts +8 -0
  140. package/dist/ai-service/llm/context-v2/compactor.d.ts.map +1 -1
  141. package/dist/ai-service/llm/context-v2/compactor.js +15 -3
  142. package/dist/ai-service/llm/context-v2/compactor.js.map +1 -1
  143. package/dist/ai-service/llm/context-v2/config.d.ts.map +1 -1
  144. package/dist/ai-service/llm/context-v2/config.js +1 -0
  145. package/dist/ai-service/llm/context-v2/config.js.map +1 -1
  146. package/dist/ai-service/llm/context-v2/context-metrics.d.ts +44 -1
  147. package/dist/ai-service/llm/context-v2/context-metrics.d.ts.map +1 -1
  148. package/dist/ai-service/llm/context-v2/context-metrics.js +97 -12
  149. package/dist/ai-service/llm/context-v2/context-metrics.js.map +1 -1
  150. package/dist/ai-service/llm/context-v2/context.d.ts +125 -0
  151. package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -1
  152. package/dist/ai-service/llm/context-v2/context.js +478 -14
  153. package/dist/ai-service/llm/context-v2/context.js.map +1 -1
  154. package/dist/ai-service/llm/context-v2/conversation-context.d.ts +12 -0
  155. package/dist/ai-service/llm/context-v2/conversation-context.d.ts.map +1 -1
  156. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.d.ts.map +1 -1
  157. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js +2 -1
  158. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js.map +1 -1
  159. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js +3 -3
  160. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js.map +1 -1
  161. package/dist/ai-service/llm/context-v2/token-tracker.d.ts +49 -1
  162. package/dist/ai-service/llm/context-v2/token-tracker.d.ts.map +1 -1
  163. package/dist/ai-service/llm/context-v2/token-tracker.js +119 -0
  164. package/dist/ai-service/llm/context-v2/token-tracker.js.map +1 -1
  165. package/dist/ai-service/llm/context-v2/truncation-fallback.d.ts.map +1 -1
  166. package/dist/ai-service/llm/context-v2/truncation-fallback.js +2 -1
  167. package/dist/ai-service/llm/context-v2/truncation-fallback.js.map +1 -1
  168. package/dist/ai-service/llm/context-v2/types.d.ts +9 -0
  169. package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
  170. package/dist/ai-service/llm/context-v2/types.js.map +1 -1
  171. package/dist/ai-service/llm/context-v2/well-formed-text.d.ts +24 -0
  172. package/dist/ai-service/llm/context-v2/well-formed-text.d.ts.map +1 -0
  173. package/dist/ai-service/llm/context-v2/well-formed-text.js +73 -0
  174. package/dist/ai-service/llm/context-v2/well-formed-text.js.map +1 -0
  175. package/dist/ai-service/llm/error.d.ts +22 -1
  176. package/dist/ai-service/llm/error.d.ts.map +1 -1
  177. package/dist/ai-service/llm/error.js +159 -22
  178. package/dist/ai-service/llm/error.js.map +1 -1
  179. package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts +4 -3
  180. package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts.map +1 -1
  181. package/dist/ai-service/llm/stream/empty-tool-call-tracker.js +5 -4
  182. package/dist/ai-service/llm/stream/empty-tool-call-tracker.js.map +1 -1
  183. package/dist/ai-service/llm/stream/idle-monitor.d.ts.map +1 -1
  184. package/dist/ai-service/llm/stream/idle-monitor.js +5 -0
  185. package/dist/ai-service/llm/stream/idle-monitor.js.map +1 -1
  186. package/dist/ai-service/llm/stream/observers/logging.d.ts +6 -0
  187. package/dist/ai-service/llm/stream/observers/logging.d.ts.map +1 -1
  188. package/dist/ai-service/llm/stream/observers/logging.js +44 -3
  189. package/dist/ai-service/llm/stream/observers/logging.js.map +1 -1
  190. package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -1
  191. package/dist/ai-service/llm/stream/orchestrator.js +28 -4
  192. package/dist/ai-service/llm/stream/orchestrator.js.map +1 -1
  193. package/dist/ai-service/llm/stream/retry-engine.d.ts +1 -1
  194. package/dist/ai-service/llm/stream/retry-engine.d.ts.map +1 -1
  195. package/dist/ai-service/llm/stream/retry-engine.js +9 -1
  196. package/dist/ai-service/llm/stream/retry-engine.js.map +1 -1
  197. package/dist/ai-service/llm/stream/session.d.ts +6 -0
  198. package/dist/ai-service/llm/stream/session.d.ts.map +1 -1
  199. package/dist/ai-service/llm/stream/session.js +6 -0
  200. package/dist/ai-service/llm/stream/session.js.map +1 -1
  201. package/dist/ai-service/llm/stream/terminal-reason.d.ts.map +1 -1
  202. package/dist/ai-service/llm/stream/terminal-reason.js +11 -1
  203. package/dist/ai-service/llm/stream/terminal-reason.js.map +1 -1
  204. package/dist/ai-service/llm/stream/wait-state-tracker.d.ts +4 -3
  205. package/dist/ai-service/llm/stream/wait-state-tracker.d.ts.map +1 -1
  206. package/dist/ai-service/llm/stream/wait-state-tracker.js +12 -8
  207. package/dist/ai-service/llm/stream/wait-state-tracker.js.map +1 -1
  208. package/dist/ai-service/policy-agent-metrics.d.ts +2 -1
  209. package/dist/ai-service/policy-agent-metrics.d.ts.map +1 -1
  210. package/dist/ai-service/policy-agent-metrics.js +11 -2
  211. package/dist/ai-service/policy-agent-metrics.js.map +1 -1
  212. package/dist/ai-service/policy-gate-error.d.ts +3 -0
  213. package/dist/ai-service/policy-gate-error.d.ts.map +1 -0
  214. package/dist/ai-service/policy-gate-error.js +33 -0
  215. package/dist/ai-service/policy-gate-error.js.map +1 -0
  216. package/dist/ai-service/resolve-generation-state-for-ui.js +1 -1
  217. package/dist/ai-service/resolve-generation-state-for-ui.js.map +1 -1
  218. package/dist/ai-service/security/secret-scanner-service.d.ts +3 -6
  219. package/dist/ai-service/security/secret-scanner-service.d.ts.map +1 -1
  220. package/dist/ai-service/security/secret-scanner-service.js +229 -97
  221. package/dist/ai-service/security/secret-scanner-service.js.map +1 -1
  222. package/dist/ai-service/security/secret-scanner.d.ts +28 -5
  223. package/dist/ai-service/security/secret-scanner.d.ts.map +1 -1
  224. package/dist/ai-service/security/secret-scanner.js +197 -42
  225. package/dist/ai-service/security/secret-scanner.js.map +1 -1
  226. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts +1 -1
  227. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts.map +1 -1
  228. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js +49 -0
  229. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js.map +1 -1
  230. package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts +1 -1
  231. package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts.map +1 -1
  232. package/dist/ai-service/skills/system/third-party-migration/skill.generated.js +1 -0
  233. package/dist/ai-service/skills/system/third-party-migration/skill.generated.js.map +1 -1
  234. package/dist/ai-service/state-machine/clark-fsm.d.ts +2 -0
  235. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  236. package/dist/ai-service/state-machine/clark-fsm.js +1 -1
  237. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  238. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts +1 -1
  239. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  240. package/dist/ai-service/state-machine/handlers/agent-planning.js +74 -3
  241. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  242. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  243. package/dist/ai-service/state-machine/handlers/llm-generating.js +1 -11
  244. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  245. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts +3 -2
  246. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts.map +1 -1
  247. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js +25 -5
  248. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js.map +1 -1
  249. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.d.ts.map +1 -1
  250. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js +1 -0
  251. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js.map +1 -1
  252. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +4 -0
  253. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
  254. package/dist/ai-service/state-machine/helpers/stable-peer.js +6 -1
  255. package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
  256. package/dist/ai-service/test-utils/metrics-harness.d.ts +6 -0
  257. package/dist/ai-service/test-utils/metrics-harness.d.ts.map +1 -1
  258. package/dist/ai-service/test-utils/metrics-harness.js.map +1 -1
  259. package/dist/ai-service/transform/api-builder/shared.d.ts.map +1 -1
  260. package/dist/ai-service/transform/api-builder/shared.js +2 -1
  261. package/dist/ai-service/transform/api-builder/shared.js.map +1 -1
  262. package/dist/dev-server-ws-smoke-client.d.ts.map +1 -1
  263. package/dist/dev-server-ws-smoke-client.js +1 -0
  264. package/dist/dev-server-ws-smoke-client.js.map +1 -1
  265. package/dist/file-sync-vite-plugin.d.ts +21 -0
  266. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  267. package/dist/file-sync-vite-plugin.js +131 -11
  268. package/dist/file-sync-vite-plugin.js.map +1 -1
  269. package/dist/file-system-helpers.d.ts +2 -2
  270. package/dist/file-system-helpers.d.ts.map +1 -1
  271. package/dist/file-system-helpers.js +2 -12
  272. package/dist/file-system-helpers.js.map +1 -1
  273. package/dist/migration-templates/app-fullstack/.gitignore +50 -0
  274. package/dist/parsing/jsx.d.ts +12 -0
  275. package/dist/parsing/jsx.d.ts.map +1 -1
  276. package/dist/parsing/jsx.js +30 -12
  277. package/dist/parsing/jsx.js.map +1 -1
  278. package/dist/parsing/page.d.ts.map +1 -1
  279. package/dist/parsing/page.js +16 -8
  280. package/dist/parsing/page.js.map +1 -1
  281. package/dist/parsing/parse-tsx-module.d.ts +4 -0
  282. package/dist/parsing/parse-tsx-module.d.ts.map +1 -0
  283. package/dist/parsing/parse-tsx-module.js +13 -0
  284. package/dist/parsing/parse-tsx-module.js.map +1 -0
  285. package/dist/plugin-options.d.ts +4 -0
  286. package/dist/plugin-options.d.ts.map +1 -1
  287. package/dist/plugin-options.js.map +1 -1
  288. package/dist/policy-gate-callback-mapper.d.ts +2 -1
  289. package/dist/policy-gate-callback-mapper.d.ts.map +1 -1
  290. package/dist/policy-gate-callback-mapper.js +3 -5
  291. package/dist/policy-gate-callback-mapper.js.map +1 -1
  292. package/dist/policy-gate-run-registry.d.ts +4 -2
  293. package/dist/policy-gate-run-registry.d.ts.map +1 -1
  294. package/dist/policy-gate-run-registry.js +17 -2
  295. package/dist/policy-gate-run-registry.js.map +1 -1
  296. package/dist/policy-gate-runner.d.ts +1 -1
  297. package/dist/policy-gate-runner.d.ts.map +1 -1
  298. package/dist/policy-gate-runner.js +41 -7
  299. package/dist/policy-gate-runner.js.map +1 -1
  300. package/dist/router-parser-metrics.d.ts +2 -0
  301. package/dist/router-parser-metrics.d.ts.map +1 -0
  302. package/dist/router-parser-metrics.js +13 -0
  303. package/dist/router-parser-metrics.js.map +1 -0
  304. package/dist/router-parser.d.ts +6 -1
  305. package/dist/router-parser.d.ts.map +1 -1
  306. package/dist/router-parser.js +72 -17
  307. package/dist/router-parser.js.map +1 -1
  308. package/dist/scan-scope-merge.d.ts +1 -1
  309. package/dist/scan-scope-merge.js +1 -1
  310. package/dist/source-tracker.d.ts.map +1 -1
  311. package/dist/source-tracker.js +2 -6
  312. package/dist/source-tracker.js.map +1 -1
  313. package/dist/sync-service/download.d.ts.map +1 -1
  314. package/dist/sync-service/download.js +10 -2
  315. package/dist/sync-service/download.js.map +1 -1
  316. package/dist/sync-service/index.d.ts +5 -0
  317. package/dist/sync-service/index.d.ts.map +1 -1
  318. package/dist/sync-service/index.js +66 -14
  319. package/dist/sync-service/index.js.map +1 -1
  320. package/dist/sync-service/list-dir.d.ts.map +1 -1
  321. package/dist/sync-service/list-dir.js +8 -4
  322. package/dist/sync-service/list-dir.js.map +1 -1
  323. package/dist/sync-service/snapshot/upload-snapshot.d.ts.map +1 -1
  324. package/dist/sync-service/snapshot/upload-snapshot.js +20 -0
  325. package/dist/sync-service/snapshot/upload-snapshot.js.map +1 -1
  326. package/dist/util/log-sanitizer.d.ts.map +1 -1
  327. package/dist/util/log-sanitizer.js +10 -8
  328. package/dist/util/log-sanitizer.js.map +1 -1
  329. package/dist/util/logger.d.ts +2 -0
  330. package/dist/util/logger.d.ts.map +1 -1
  331. package/dist/util/logger.js +357 -38
  332. package/dist/util/logger.js.map +1 -1
  333. package/dist/util.d.ts +3 -1
  334. package/dist/util.d.ts.map +1 -1
  335. package/dist/util.js +2 -2
  336. package/dist/util.js.map +1 -1
  337. package/package.json +9 -9
@@ -6,14 +6,14 @@ import { hasToolCall, stepCountIs, } from "ai";
6
6
  import { z } from "zod";
7
7
  import { AiGenerationState, AiMode, resolveAttachmentFileName, } from "@superblocksteam/library-shared/types";
8
8
  import { isToolPermissionClarification } from "@superblocksteam/library-shared/types/tool-permission-response";
9
- import { addTracingToMethods, AiSystemTriggerType, classifyAttachmentDelivery, FactAccessType, FactCreatedSource, FactEntityScope, TracedEventEmitter, getAiQuotaPaywallReasonFromMessage, } from "@superblocksteam/shared";
9
+ import { addTracingToMethods, AiSystemTriggerType, classifyAttachmentDelivery, FactAccessType, FactCreatedSource, FactEntityScope, TracedEventEmitter, getAiQuotaPaywallReasonFromMessage, POLICY_GATE_MAX_TOTAL_TIME_MS, POLICY_GATE_STREAM_IDLE_TIMEOUT_MS, } from "@superblocksteam/shared";
10
10
  import { npmRegistryEmitter } from "@superblocksteam/telemetry";
11
11
  import { applyTestApiDenialSideEffects, buildMigrationTestApiDenialContinuationPrompt, } from "../migration/mark-api-testing-denied.js";
12
12
  import { buildTranslationPrompt } from "../migration/translation-prompt.js";
13
13
  import { POLICY_GATE_RUN_IN_PROGRESS_ERROR, policyGateRunRegistry, } from "../policy-gate-run-registry.js";
14
14
  import { getErrorMeta, getLogger, setDefaultLogger } from "../util/logger.js";
15
15
  import { composeSecurityAgentPrompt, } from "./agent/prompts/build-security-scan-prompt.js";
16
- import { getToolCallArguments, getToolErrorCode, getToolOutput, } from "./agent/tool-message-utils.js";
16
+ import { getToolCallArguments, getToolErrorCode, getToolErrorMessage, getToolOutput, } from "./agent/tool-message-utils.js";
17
17
  import { recordToolPermissionDeliveryOutcome } from "./agent/tool-permission-delivery-metrics.js";
18
18
  import { createExpiredPermissionPromptDeliveryError, flushPendingToolPermissionPrompt, inFlightToolPermissionReplay, } from "./agent/tool-permission-delivery.js";
19
19
  import { buildSecurityScanTools, isBackgroundTaskFrameworkEnabled, } from "./agent/tools.js";
@@ -31,6 +31,7 @@ import { NpmPackageLookup } from "./app-interface/npm-package-lookup.js";
31
31
  import { NpmRegistryClient, createDiskRegistryPolicyStore, } from "./app-interface/npm-registry.js";
32
32
  import { AppShell } from "./app-interface/shell.js";
33
33
  import { AppSkillsManager } from "./app-skills/manager.js";
34
+ import { parseDataUrl } from "./attachments/parse-data-url.js";
34
35
  import { isUploadedAttachment, toUploadedAttachmentContentPart, } from "./attachments/uploaded-content-part.js";
35
36
  import { ChatSessionStore } from "./chat/chat-session-store.js";
36
37
  import { normalizeTextAttachmentForModel } from "./chat/utils.js";
@@ -69,6 +70,7 @@ import { buildServerMigrationLlmConfig, isMigrationAutoDispatchEnabled, } from "
69
70
  import { isMigrationSessionActive } from "./migration-session-active.js";
70
71
  import { hasSettledNormalMigrationTurn, recordMigrationTurnDispatched, recordMigrationTurnSettled, } from "./migration-turns-log.js";
71
72
  import { recordPolicyAgentExecution, } from "./policy-agent-metrics.js";
73
+ import { classifyPolicyGateError } from "./policy-gate-error.js";
72
74
  import { policyGateStreamPartToAgentStep } from "./policy-gate-step.js";
73
75
  import { ClarkProfiler } from "./profiler/clark-profiler.js";
74
76
  import { buildSummarizeApiUsagePrompt } from "./prompts/summarize-api-usage.js";
@@ -144,7 +146,6 @@ const MAX_POLICY_GATE_STREAM_ERROR_ARRAY_LENGTH = 10;
144
146
  const MAX_POLICY_GATE_STREAM_ERROR_FIELD_LENGTH = 500;
145
147
  const MAX_POLICY_GATE_STREAM_ERROR_OBJECT_DEPTH = 3;
146
148
  const MAX_POLICY_GATE_STREAM_ERROR_OBJECT_KEYS = 20;
147
- const POLICY_GATE_MAX_TOTAL_TIME_MS = 15 * 60 * 1000;
148
149
  // Ceiling above the historical 30-step cap; 100 is an existing policy-agent
149
150
  // histogram bucket. Tighten from production p99 if scans complete far below this.
150
151
  const POLICY_GATE_MAX_STEPS = 100;
@@ -161,6 +162,54 @@ const POLICY_GATE_STREAM_ERROR_SECRET_VALUE_PATTERN_SOURCES = [
161
162
  String.raw `\bsk-[a-z0-9_-]{8,}\b`,
162
163
  String.raw `\bxox[baprs]-[a-z0-9-]{10,}\b`,
163
164
  ];
165
+ /**
166
+ * Fails a policy gate stream that goes idle, independent of whatever
167
+ * abort/timeout wiring the stream itself does or doesn't honor. A dropped
168
+ * dev-server connection can stall the stream without ever rejecting it
169
+ * (APPS-5642), which leaves the run "running" forever since nothing throws
170
+ * for the existing catch/classification logic to act on.
171
+ */
172
+ async function* withPolicyGateIdleTimeout(stream, idleTimeoutMs) {
173
+ const iterator = stream[Symbol.asyncIterator]();
174
+ try {
175
+ while (true) {
176
+ const nextResult = iterator.next();
177
+ // If the idle timeout wins the race below, this promise is abandoned
178
+ // mid-flight; attach a handler now so its eventual settlement (once the
179
+ // dead connection is cleaned up, if ever) never surfaces as an
180
+ // unhandled rejection. Promise.race still gets its own notification
181
+ // from this same promise independently.
182
+ nextResult.catch(() => { });
183
+ let timer;
184
+ const idleTimeout = new Promise((_, reject) => {
185
+ timer = setTimeout(() => {
186
+ reject(Object.assign(new Error("Policy gate stream went idle"), {
187
+ name: "TimeoutError",
188
+ }));
189
+ }, idleTimeoutMs);
190
+ });
191
+ let result;
192
+ try {
193
+ result = await Promise.race([nextResult, idleTimeout]);
194
+ }
195
+ finally {
196
+ clearTimeout(timer);
197
+ }
198
+ if (result.done) {
199
+ return;
200
+ }
201
+ yield result.value;
202
+ }
203
+ }
204
+ finally {
205
+ // Best-effort only: never await this. On the exact connection this
206
+ // wrapper exists to fail past — one that stopped responding without
207
+ // erroring or closing — iterator.return() can hang the same way
208
+ // .next() did, and blocking cleanup on it here would defeat the whole
209
+ // point of a timeout that's supposed to guarantee termination.
210
+ void iterator.return?.()?.catch(() => { });
211
+ }
212
+ }
164
213
  function truncatePolicyGateStreamErrorField(value) {
165
214
  if (value.length <= MAX_POLICY_GATE_STREAM_ERROR_FIELD_LENGTH) {
166
215
  return value;
@@ -771,6 +820,19 @@ export class AiService extends TracedEventEmitter {
771
820
  this.getLogger().debug("[ai-service] Failed to report npm-install-blocked audit event", getErrorMeta(error));
772
821
  });
773
822
  },
823
+ // Privacy-safe install-gate USER_EVENT: outcome + runner only. Same
824
+ // fire-and-forget socket path; not gated by audit-v2 or the blocked-
825
+ // install throttle. Prefetch/uninstall never call this reporter.
826
+ reportNpmInstallOutcome: (report) => {
827
+ void this.config.rpcClient
828
+ .call(async (client) => {
829
+ const rpcClient = client;
830
+ return await rpcClient.call.v1.audit.npmInstallOutcome(report);
831
+ })
832
+ .catch((error) => {
833
+ this.getLogger().debug("[ai-service] Failed to report npm-install-outcome user event", getErrorMeta(error));
834
+ });
835
+ },
774
836
  virtualFileSystem: createDefaultVirtualFileSystem({
775
837
  useSystemSkills: config.features.useSystemSkills,
776
838
  knowledgeManager: this.knowledgeManager,
@@ -2123,7 +2185,9 @@ export class AiService extends TracedEventEmitter {
2123
2185
  // logged so we can audit if this ever fires in prod.
2124
2186
  let promptForContext = request.prompt;
2125
2187
  try {
2126
- const scanResult = await scanContentForSecrets(request.prompt);
2188
+ const scanResult = await scanContentForSecrets(request.prompt, {
2189
+ consumer: "context_persistence",
2190
+ });
2127
2191
  if (scanResult.success && scanResult.hasSecrets) {
2128
2192
  this.getLogger().warn(`[secret-scan] Redacting ${scanResult.findings.length} secret(s) from pre-call paywall prompt before ContextV2 persist`, {
2129
2193
  findingCount: scanResult.findings.length,
@@ -2133,15 +2197,6 @@ export class AiService extends TracedEventEmitter {
2133
2197
  const redactor = new SecretRedactor(scanResult.findings);
2134
2198
  promptForContext = redactor.redact(request.prompt);
2135
2199
  }
2136
- else if (!scanResult.success) {
2137
- // Do NOT log `scanResult.error` directly — it can contain
2138
- // raw TruffleHog stdout/stderr payloads, which on some
2139
- // failure paths include excerpts of the scanned prompt
2140
- // (i.e. unredacted user secret material). Log only that the
2141
- // scan failed; operators can correlate via timestamp +
2142
- // peerId. (APPS-4080 security review)
2143
- this.getLogger().warn("[secret-scan] Secret scan failed on pre-call paywall prompt; persisting unredacted (fail-open, matches mainline)");
2144
- }
2145
2200
  }
2146
2201
  catch (scanErr) {
2147
2202
  // Same reason — don't pipe raw scanner error meta to logs.
@@ -2674,12 +2729,12 @@ export class AiService extends TracedEventEmitter {
2674
2729
  };
2675
2730
  }
2676
2731
  else if (attachment.type === "pdf" || attachment.type === "archive") {
2677
- const match = attachment.data.match(/^data:([^;]+);base64,(.+)$/);
2678
- const data = match?.[2] ?? attachment.data;
2732
+ const parsed = parseDataUrl(attachment.data);
2733
+ const data = parsed?.data ?? attachment.data;
2679
2734
  const defaultMediaType = attachment.type === "pdf"
2680
2735
  ? "application/pdf"
2681
2736
  : "application/octet-stream";
2682
- const mediaType = match?.[1] ?? defaultMediaType;
2737
+ const mediaType = parsed?.mediaType ?? defaultMediaType;
2683
2738
  return {
2684
2739
  type: "file",
2685
2740
  data,
@@ -3303,7 +3358,7 @@ export class AiService extends TracedEventEmitter {
3303
3358
  type: "tool-error",
3304
3359
  toolCallId,
3305
3360
  toolName,
3306
- error: result.error.message,
3361
+ error: getToolErrorMessage(result.error.cause ?? result.error),
3307
3362
  errorCode,
3308
3363
  });
3309
3364
  }
@@ -3970,13 +4025,16 @@ export class AiService extends TracedEventEmitter {
3970
4025
  // Invalidate context errors cache since runtime errors changed
3971
4026
  debugCache.invalidateContextErrors();
3972
4027
  }
3973
- handleClearBuildSystemErrors() {
4028
+ handleClearBuildSystemErrors(source) {
3974
4029
  this.clark.updateContext((context) => ({
3975
4030
  ...context,
3976
- buildSystemErrors: [],
4031
+ buildSystemErrors: source
4032
+ ? (context.buildSystemErrors ?? []).filter((error) => error.source !== source)
4033
+ : [],
3977
4034
  }));
3978
- this.getLogger().info(`[ai-service] Cleared all build system errors`);
3979
- // Invalidate context errors cache since build system errors changed
4035
+ this.getLogger().info(source
4036
+ ? `[ai-service] Cleared ${source} build system errors`
4037
+ : `[ai-service] Cleared all build system errors`);
3980
4038
  debugCache.invalidateContextErrors();
3981
4039
  }
3982
4040
  async handlePromptInterpretation(request) {
@@ -4089,8 +4147,11 @@ export class AiService extends TracedEventEmitter {
4089
4147
  const streamPartTypeCounts = {};
4090
4148
  let stepCount = 0;
4091
4149
  let textDeltaChars = 0;
4150
+ let failureErrorCode;
4151
+ let maxOutputTokens;
4092
4152
  let modelName;
4093
4153
  let promptHash;
4154
+ let quotaReason;
4094
4155
  // Hoisted so the outer catch can attribute a failed run to the same model as
4095
4156
  // the attempt it belongs to. Usage arrives from the client's usage observer,
4096
4157
  // which also flushes on abort, on error, and for compaction calls.
@@ -4127,8 +4188,10 @@ export class AiService extends TracedEventEmitter {
4127
4188
  finishReasons,
4128
4189
  grepMatchCounts,
4129
4190
  grepPatterns,
4191
+ maxOutputTokens,
4130
4192
  model: modelName,
4131
4193
  promptHash,
4194
+ quotaReason,
4132
4195
  reportToolCalled: Boolean(scanResult),
4133
4196
  scanComplete: scanResult?.scanComplete === true,
4134
4197
  scanRoot,
@@ -4138,13 +4201,26 @@ export class AiService extends TracedEventEmitter {
4138
4201
  textDeltaChars,
4139
4202
  toolCallCounts,
4140
4203
  });
4141
- const failPolicyGateExecution = (message, outcome) => {
4142
- recordExecutionMetrics(outcome);
4143
- const error = new Error(message);
4144
- error.runtimeMetadataJson = buildRuntimeMetadata(message);
4145
- throw error;
4204
+ const failPolicyGateExecution = (message, errorCode) => {
4205
+ failureErrorCode = errorCode;
4206
+ recordExecutionMetrics(errorCode);
4207
+ throw Object.assign(new Error(message), {
4208
+ errorCode,
4209
+ runtimeMetadataJson: buildRuntimeMetadata(message),
4210
+ });
4146
4211
  };
4147
4212
  try {
4213
+ try {
4214
+ await this.ensureAiQuotaAvailable(request.jwt);
4215
+ }
4216
+ catch (error) {
4217
+ const message = error instanceof Error ? error.message : "AI quota unavailable";
4218
+ const errorCode = classifyPolicyGateError(error);
4219
+ if (errorCode === "out_of_credits") {
4220
+ quotaReason = getAiQuotaPaywallReasonFromMessage(message);
4221
+ }
4222
+ failPolicyGateExecution(message, errorCode);
4223
+ }
4148
4224
  const requestLlmConfig = request.llmConfig;
4149
4225
  const contextLlmConfig = this.clark.context.llmConfig;
4150
4226
  const llmConfig = requestLlmConfig ?? contextLlmConfig;
@@ -4173,16 +4249,13 @@ export class AiService extends TracedEventEmitter {
4173
4249
  let scanScopeJson = request.scanScopeJson;
4174
4250
  if (scanScopeJson?.unifiedDiff) {
4175
4251
  try {
4176
- const scanResult = await scanContentForSecrets(scanScopeJson.unifiedDiff);
4252
+ const scanResult = await scanContentForSecrets(scanScopeJson.unifiedDiff, { consumer: "policy_gate" });
4177
4253
  if (scanResult.success && scanResult.hasSecrets) {
4178
4254
  scanScopeJson = {
4179
4255
  ...scanScopeJson,
4180
4256
  unifiedDiff: new SecretRedactor(scanResult.findings).redact(scanScopeJson.unifiedDiff),
4181
4257
  };
4182
4258
  }
4183
- else if (!scanResult.success) {
4184
- logger.warn("[secret-scan] Secret scan failed on policy gate diff; using the original diff");
4185
- }
4186
4259
  }
4187
4260
  catch {
4188
4261
  logger.warn("[secret-scan] Secret scan threw on policy gate diff; using the original diff");
@@ -4192,7 +4265,8 @@ export class AiService extends TracedEventEmitter {
4192
4265
  const systemPrompt = composeSecurityAgentPrompt(appContext, request.adminPrompt, scanScopeJson);
4193
4266
  promptHash = createHash("sha256").update(systemPrompt).digest("hex");
4194
4267
  const scanContext = {};
4195
- const { headers, interleavedThinking, maxOutputTokens, providerOptions, thinkingBudgetTokens, thinkingEnabled, } = processLLMConfig(llmConfig);
4268
+ const { headers, interleavedThinking, maxOutputTokens: configuredMaxOutputTokens, providerOptions, thinkingBudgetTokens, thinkingEnabled, } = processLLMConfig(llmConfig);
4269
+ maxOutputTokens = configuredMaxOutputTokens;
4196
4270
  // Scan-owned client: gate JWT, own usage sink, built first so scan tools
4197
4271
  // (webFetch generateObject) use this client instead of Clark's.
4198
4272
  const policyGateLlmClient = new LLMClient({
@@ -4226,8 +4300,11 @@ export class AiService extends TracedEventEmitter {
4226
4300
  },
4227
4301
  };
4228
4302
  const tools = await buildSecurityScanTools(this.clark, scanToolsDeps);
4303
+ const timeoutSignal = AbortSignal.timeout(POLICY_GATE_MAX_TOTAL_TIME_MS);
4229
4304
  const result = await policyGateLlmClient.streamText({
4230
- abortSignal: AbortSignal.timeout(POLICY_GATE_MAX_TOTAL_TIME_MS),
4305
+ abortSignal: request.abortSignal
4306
+ ? AbortSignal.any([request.abortSignal, timeoutSignal])
4307
+ : timeoutSignal,
4231
4308
  context: {
4232
4309
  contextManagement: {
4233
4310
  summarizationModel,
@@ -4242,7 +4319,7 @@ export class AiService extends TracedEventEmitter {
4242
4319
  headers,
4243
4320
  logging: false,
4244
4321
  // processLLMConfig returns the same MAX_OUTPUT_TOKENS cap Clark uses.
4245
- maxOutputTokens,
4322
+ maxOutputTokens: configuredMaxOutputTokens,
4246
4323
  model,
4247
4324
  onContextReady: (ctx) => {
4248
4325
  scanContext.current = ctx;
@@ -4292,7 +4369,7 @@ export class AiService extends TracedEventEmitter {
4292
4369
  });
4293
4370
  };
4294
4371
  try {
4295
- for await (const part of result.fullStream) {
4372
+ for await (const part of withPolicyGateIdleTimeout(result.fullStream, POLICY_GATE_STREAM_IDLE_TIMEOUT_MS)) {
4296
4373
  emitAgentStep(part);
4297
4374
  const partType = typeof part.type === "string"
4298
4375
  ? part.type
@@ -4410,6 +4487,9 @@ export class AiService extends TracedEventEmitter {
4410
4487
  }
4411
4488
  }
4412
4489
  catch (error) {
4490
+ if (failureErrorCode !== undefined) {
4491
+ throw error;
4492
+ }
4413
4493
  if (error instanceof Error &&
4414
4494
  (error.name === "AbortError" ||
4415
4495
  error.name === "AbortedError" ||
@@ -4424,7 +4504,7 @@ export class AiService extends TracedEventEmitter {
4424
4504
  ...getErrorMeta(error),
4425
4505
  elapsedMs,
4426
4506
  });
4427
- failPolicyGateExecution("Policy gate agent timed out", "timeout");
4507
+ failPolicyGateExecution("Policy gate agent timed out", "llm_timeout");
4428
4508
  }
4429
4509
  logger.warn("[ai-service] Policy gate agent aborted", {
4430
4510
  ...policyRunLogContext,
@@ -4433,22 +4513,32 @@ export class AiService extends TracedEventEmitter {
4433
4513
  });
4434
4514
  failPolicyGateExecution("Policy gate agent aborted", "aborted");
4435
4515
  }
4436
- if (error instanceof Error &&
4437
- (error.name === "LLMProviderError" ||
4438
- error.name === "RetriesExhaustedError")) {
4439
- const streamError = serializePolicyGateStreamError(error);
4440
- if (streamErrors.length < MAX_POLICY_GATE_STREAM_ERRORS) {
4441
- streamErrors.push(streamError);
4442
- }
4443
- logger.warn("[ai-service] Policy gate stream error", {
4444
- ...policyRunLogContext,
4445
- streamError,
4446
- });
4516
+ const streamError = serializePolicyGateStreamError(error);
4517
+ if (streamErrors.length < MAX_POLICY_GATE_STREAM_ERRORS) {
4518
+ streamErrors.push(streamError);
4447
4519
  }
4448
- throw error;
4520
+ logger.warn("[ai-service] Policy gate stream error", {
4521
+ ...policyRunLogContext,
4522
+ streamError,
4523
+ });
4524
+ const errorCode = classifyPolicyGateError(error);
4525
+ if (errorCode === "out_of_credits") {
4526
+ quotaReason =
4527
+ error instanceof Error
4528
+ ? getAiQuotaPaywallReasonFromMessage(error.message)
4529
+ : undefined;
4530
+ }
4531
+ failPolicyGateExecution(error instanceof Error ? error.message : "Policy gate stream failed", errorCode);
4449
4532
  }
4450
4533
  if (!scanResult) {
4451
4534
  logger.warn("[ai-service] Policy gate agent did not call reportReviewRun", policyRunLogContext);
4535
+ if (finishReasons.includes("length")) {
4536
+ const outputTokens = llmUsage.at(-1)?.outputTokens ?? 0;
4537
+ failPolicyGateExecution(`Policy gate agent reached the output token limit of ${maxOutputTokens ?? 0} after producing ${outputTokens} output tokens`, "output_token_limit");
4538
+ }
4539
+ if (finishReasons.includes("content-filter")) {
4540
+ failPolicyGateExecution("Policy gate agent output was refused by the provider content filter", "llm_refusal");
4541
+ }
4452
4542
  failPolicyGateExecution("Policy gate agent did not complete a report", "missing_report");
4453
4543
  }
4454
4544
  const completedScanResult = scanResult;
@@ -4489,7 +4579,7 @@ export class AiService extends TracedEventEmitter {
4489
4579
  aiAgentRunId: request.aiAgentRunId,
4490
4580
  chatSessionStore: this.chatSessionStore,
4491
4581
  coreModel,
4492
- failure: policyGateFailureFromStream(streamErrors),
4582
+ failure: policyGateFailureFromStream(failureErrorCode, quotaReason),
4493
4583
  hadFallback,
4494
4584
  llmUsage,
4495
4585
  logger,