@superblocksteam/vite-plugin-file-sync 1.99.99-next.3 → 2.0.0-SNAPSHOT.2143e2e95d0107ab

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 (2505) hide show
  1. package/dist/ai-service/agent/middleware.d.ts +66 -0
  2. package/dist/ai-service/agent/middleware.d.ts.map +1 -0
  3. package/dist/ai-service/agent/middleware.js +423 -0
  4. package/dist/ai-service/agent/middleware.js.map +1 -0
  5. package/dist/ai-service/agent/prompts/api-prompts.d.ts +39 -0
  6. package/dist/ai-service/agent/prompts/api-prompts.d.ts.map +1 -0
  7. package/dist/ai-service/agent/prompts/api-prompts.js +806 -0
  8. package/dist/ai-service/agent/prompts/api-prompts.js.map +1 -0
  9. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts +59 -0
  10. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -0
  11. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +1133 -0
  12. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -0
  13. package/dist/ai-service/agent/prompts/build-security-scan-prompt.d.ts +17 -0
  14. package/dist/ai-service/agent/prompts/build-security-scan-prompt.d.ts.map +1 -0
  15. package/dist/ai-service/agent/prompts/build-security-scan-prompt.js +285 -0
  16. package/dist/ai-service/agent/prompts/build-security-scan-prompt.js.map +1 -0
  17. package/dist/ai-service/agent/subagents/apis/example-selector.d.ts +24 -0
  18. package/dist/ai-service/agent/subagents/apis/example-selector.d.ts.map +1 -0
  19. package/dist/ai-service/agent/subagents/apis/example-selector.js +104 -0
  20. package/dist/ai-service/agent/subagents/apis/example-selector.js.map +1 -0
  21. package/dist/ai-service/agent/subagents/apis/examples.d.ts +38 -0
  22. package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -0
  23. package/dist/ai-service/agent/subagents/apis/examples.js +1355 -0
  24. package/dist/ai-service/agent/subagents/apis/examples.js.map +1 -0
  25. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +42 -0
  26. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts.map +1 -0
  27. package/dist/ai-service/agent/subagents/apis/prompt-builder.js +103 -0
  28. package/dist/ai-service/agent/subagents/apis/prompt-builder.js.map +1 -0
  29. package/dist/ai-service/agent/subagents/apis/static-analysis.d.ts +2 -0
  30. package/dist/ai-service/agent/subagents/apis/static-analysis.d.ts.map +1 -0
  31. package/dist/ai-service/agent/subagents/apis/static-analysis.js +779 -0
  32. package/dist/ai-service/agent/subagents/apis/static-analysis.js.map +1 -0
  33. package/dist/ai-service/agent/subagents/apis/types.d.ts +2 -0
  34. package/dist/ai-service/agent/subagents/apis/types.d.ts.map +1 -0
  35. package/dist/ai-service/agent/subagents/apis/types.js.map +1 -0
  36. package/dist/ai-service/agent/subagents/coding/prompt-builder.d.ts +16 -0
  37. package/dist/ai-service/agent/subagents/coding/prompt-builder.d.ts.map +1 -0
  38. package/dist/ai-service/agent/subagents/coding/prompt-builder.js +30 -0
  39. package/dist/ai-service/agent/subagents/coding/prompt-builder.js.map +1 -0
  40. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.d.ts +30 -0
  41. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.d.ts.map +1 -0
  42. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.js +134 -0
  43. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.js.map +1 -0
  44. package/dist/ai-service/agent/subagents/testing/index.d.ts +3 -0
  45. package/dist/ai-service/agent/subagents/testing/index.d.ts.map +1 -0
  46. package/dist/ai-service/agent/subagents/testing/index.js +2 -0
  47. package/dist/ai-service/agent/subagents/testing/index.js.map +1 -0
  48. package/dist/ai-service/agent/subagents/testing/prompt-builder.d.ts +10 -0
  49. package/dist/ai-service/agent/subagents/testing/prompt-builder.d.ts.map +1 -0
  50. package/dist/ai-service/agent/subagents/testing/prompt-builder.js +177 -0
  51. package/dist/ai-service/agent/subagents/testing/prompt-builder.js.map +1 -0
  52. package/dist/ai-service/agent/subagents/testing/types.d.ts +67 -0
  53. package/dist/ai-service/agent/subagents/testing/types.d.ts.map +1 -0
  54. package/dist/ai-service/agent/subagents/testing/types.js +2 -0
  55. package/dist/ai-service/agent/subagents/testing/types.js.map +1 -0
  56. package/dist/ai-service/agent/subagents/types.d.ts +48 -0
  57. package/dist/ai-service/agent/subagents/types.d.ts.map +1 -0
  58. package/dist/ai-service/agent/subagents/types.js +49 -0
  59. package/dist/ai-service/agent/subagents/types.js.map +1 -0
  60. package/dist/ai-service/agent/tool-message-utils.d.ts +26 -0
  61. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -0
  62. package/dist/ai-service/agent/tool-message-utils.js +356 -0
  63. package/dist/ai-service/agent/tool-message-utils.js.map +1 -0
  64. package/dist/ai-service/agent/tool-permission-delivery-metrics.d.ts +3 -0
  65. package/dist/ai-service/agent/tool-permission-delivery-metrics.d.ts.map +1 -0
  66. package/dist/ai-service/agent/tool-permission-delivery-metrics.js +23 -0
  67. package/dist/ai-service/agent/tool-permission-delivery-metrics.js.map +1 -0
  68. package/dist/ai-service/agent/tool-permission-delivery.d.ts +50 -0
  69. package/dist/ai-service/agent/tool-permission-delivery.d.ts.map +1 -0
  70. package/dist/ai-service/agent/tool-permission-delivery.js +434 -0
  71. package/dist/ai-service/agent/tool-permission-delivery.js.map +1 -0
  72. package/dist/ai-service/agent/tool-result-metrics.d.ts +29 -0
  73. package/dist/ai-service/agent/tool-result-metrics.d.ts.map +1 -0
  74. package/dist/ai-service/agent/tool-result-metrics.js +162 -0
  75. package/dist/ai-service/agent/tool-result-metrics.js.map +1 -0
  76. package/dist/ai-service/agent/tools/apis/analysis.d.ts +30 -0
  77. package/dist/ai-service/agent/tools/apis/analysis.d.ts.map +1 -0
  78. package/dist/ai-service/agent/tools/apis/analysis.js +1305 -0
  79. package/dist/ai-service/agent/tools/apis/analysis.js.map +1 -0
  80. package/dist/ai-service/agent/tools/apis/api-comparator.d.ts +36 -0
  81. package/dist/ai-service/agent/tools/apis/api-comparator.d.ts.map +1 -0
  82. package/dist/ai-service/agent/tools/apis/api-comparator.js +366 -0
  83. package/dist/ai-service/agent/tools/apis/api-comparator.js.map +1 -0
  84. package/dist/ai-service/agent/tools/apis/api-executor.d.ts +92 -0
  85. package/dist/ai-service/agent/tools/apis/api-executor.d.ts.map +1 -0
  86. package/dist/ai-service/agent/tools/apis/api-executor.js +480 -0
  87. package/dist/ai-service/agent/tools/apis/api-executor.js.map +1 -0
  88. package/dist/ai-service/agent/tools/apis/api-testing-state.d.ts +43 -0
  89. package/dist/ai-service/agent/tools/apis/api-testing-state.d.ts.map +1 -0
  90. package/dist/ai-service/agent/tools/apis/api-testing-state.js +259 -0
  91. package/dist/ai-service/agent/tools/apis/api-testing-state.js.map +1 -0
  92. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts +71 -0
  93. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts.map +1 -0
  94. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js +562 -0
  95. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js.map +1 -0
  96. package/dist/ai-service/agent/tools/apis/build-api-artifact.d.ts +51 -0
  97. package/dist/ai-service/agent/tools/apis/build-api-artifact.d.ts.map +1 -0
  98. package/dist/ai-service/agent/tools/apis/build-api-artifact.js +378 -0
  99. package/dist/ai-service/agent/tools/apis/build-api-artifact.js.map +1 -0
  100. package/dist/ai-service/agent/tools/apis/build-api.d.ts +15 -0
  101. package/dist/ai-service/agent/tools/apis/build-api.d.ts.map +1 -0
  102. package/dist/ai-service/agent/tools/apis/build-api.js +82 -0
  103. package/dist/ai-service/agent/tools/apis/build-api.js.map +1 -0
  104. package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts +66 -0
  105. package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts.map +1 -0
  106. package/dist/ai-service/agent/tools/apis/get-api-docs.js +2242 -0
  107. package/dist/ai-service/agent/tools/apis/get-api-docs.js.map +1 -0
  108. package/dist/ai-service/agent/tools/apis/get-integration-types.d.ts +12 -0
  109. package/dist/ai-service/agent/tools/apis/get-integration-types.d.ts.map +1 -0
  110. package/dist/ai-service/agent/tools/apis/get-integration-types.js +76 -0
  111. package/dist/ai-service/agent/tools/apis/get-integration-types.js.map +1 -0
  112. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.d.ts +32 -0
  113. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.d.ts.map +1 -0
  114. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.js +277 -0
  115. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.js.map +1 -0
  116. package/dist/ai-service/agent/tools/apis/integration-types.d.ts +59 -0
  117. package/dist/ai-service/agent/tools/apis/integration-types.d.ts.map +1 -0
  118. package/dist/ai-service/agent/tools/apis/integration-types.js +1677 -0
  119. package/dist/ai-service/agent/tools/apis/integration-types.js.map +1 -0
  120. package/dist/ai-service/agent/tools/apis/sample-json.d.ts +2 -0
  121. package/dist/ai-service/agent/tools/apis/sample-json.d.ts.map +1 -0
  122. package/dist/ai-service/agent/tools/apis/sample-json.js +16 -0
  123. package/dist/ai-service/agent/tools/apis/sample-json.js.map +1 -0
  124. package/dist/ai-service/agent/tools/apis/sdk-registry.d.ts +20 -0
  125. package/dist/ai-service/agent/tools/apis/sdk-registry.d.ts.map +1 -0
  126. package/dist/ai-service/agent/tools/apis/sdk-registry.js +78 -0
  127. package/dist/ai-service/agent/tools/apis/sdk-registry.js.map +1 -0
  128. package/dist/ai-service/agent/tools/apis/test-api.d.ts +66 -0
  129. package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -0
  130. package/dist/ai-service/agent/tools/apis/test-api.js +864 -0
  131. package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -0
  132. package/dist/ai-service/agent/tools/apis/write-api.d.ts +12 -0
  133. package/dist/ai-service/agent/tools/apis/write-api.d.ts.map +1 -0
  134. package/dist/ai-service/agent/tools/apis/write-api.js +47 -0
  135. package/dist/ai-service/agent/tools/apis/write-api.js.map +1 -0
  136. package/dist/ai-service/agent/tools/app-environment/update-app-environment.d.ts +29 -0
  137. package/dist/ai-service/agent/tools/app-environment/update-app-environment.d.ts.map +1 -0
  138. package/dist/ai-service/agent/tools/app-environment/update-app-environment.js +399 -0
  139. package/dist/ai-service/agent/tools/app-environment/update-app-environment.js.map +1 -0
  140. package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts +59 -0
  141. package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts.map +1 -0
  142. package/dist/ai-service/agent/tools/build-capture-screenshot.js +483 -0
  143. package/dist/ai-service/agent/tools/build-capture-screenshot.js.map +1 -0
  144. package/dist/ai-service/agent/tools/build-copy-directory.d.ts +12 -0
  145. package/dist/ai-service/agent/tools/build-copy-directory.d.ts.map +1 -0
  146. package/dist/ai-service/agent/tools/build-copy-directory.js +51 -0
  147. package/dist/ai-service/agent/tools/build-copy-directory.js.map +1 -0
  148. package/dist/ai-service/agent/tools/build-copy-file.d.ts +12 -0
  149. package/dist/ai-service/agent/tools/build-copy-file.d.ts.map +1 -0
  150. package/dist/ai-service/agent/tools/build-copy-file.js +52 -0
  151. package/dist/ai-service/agent/tools/build-copy-file.js.map +1 -0
  152. package/dist/ai-service/agent/tools/build-copy-utils.d.ts +57 -0
  153. package/dist/ai-service/agent/tools/build-copy-utils.d.ts.map +1 -0
  154. package/dist/ai-service/agent/tools/build-copy-utils.js +37 -0
  155. package/dist/ai-service/agent/tools/build-copy-utils.js.map +1 -0
  156. package/dist/ai-service/agent/tools/build-debug.d.ts +17 -0
  157. package/dist/ai-service/agent/tools/build-debug.d.ts.map +1 -0
  158. package/dist/ai-service/agent/tools/build-debug.js +244 -0
  159. package/dist/ai-service/agent/tools/build-debug.js.map +1 -0
  160. package/dist/ai-service/agent/tools/build-delete-file.d.ts +27 -0
  161. package/dist/ai-service/agent/tools/build-delete-file.d.ts.map +1 -0
  162. package/dist/ai-service/agent/tools/build-delete-file.js +217 -0
  163. package/dist/ai-service/agent/tools/build-delete-file.js.map +1 -0
  164. package/dist/ai-service/agent/tools/build-edit-file.d.ts +23 -0
  165. package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -0
  166. package/dist/ai-service/agent/tools/build-edit-file.js +509 -0
  167. package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -0
  168. package/dist/ai-service/agent/tools/build-finalize.d.ts +19 -0
  169. package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -0
  170. package/dist/ai-service/agent/tools/build-finalize.js +234 -0
  171. package/dist/ai-service/agent/tools/build-finalize.js.map +1 -0
  172. package/dist/ai-service/agent/tools/build-install-packages.d.ts +89 -0
  173. package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -0
  174. package/dist/ai-service/agent/tools/build-install-packages.js +727 -0
  175. package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -0
  176. package/dist/ai-service/agent/tools/build-list-files.d.ts +5 -0
  177. package/dist/ai-service/agent/tools/build-list-files.d.ts.map +1 -0
  178. package/dist/ai-service/agent/tools/build-list-files.js +26 -0
  179. package/dist/ai-service/agent/tools/build-list-files.js.map +1 -0
  180. package/dist/ai-service/agent/tools/build-lookup-npm-package.d.ts +29 -0
  181. package/dist/ai-service/agent/tools/build-lookup-npm-package.d.ts.map +1 -0
  182. package/dist/ai-service/agent/tools/build-lookup-npm-package.js +66 -0
  183. package/dist/ai-service/agent/tools/build-lookup-npm-package.js.map +1 -0
  184. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +89 -0
  185. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -0
  186. package/dist/ai-service/agent/tools/build-manage-checklist.js +276 -0
  187. package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -0
  188. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts +20 -0
  189. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -0
  190. package/dist/ai-service/agent/tools/build-multi-edit-file.js +209 -0
  191. package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -0
  192. package/dist/ai-service/agent/tools/build-navigate-preview.d.ts +17 -0
  193. package/dist/ai-service/agent/tools/build-navigate-preview.d.ts.map +1 -0
  194. package/dist/ai-service/agent/tools/build-navigate-preview.js +71 -0
  195. package/dist/ai-service/agent/tools/build-navigate-preview.js.map +1 -0
  196. package/dist/ai-service/agent/tools/build-read-file.d.ts +21 -0
  197. package/dist/ai-service/agent/tools/build-read-file.d.ts.map +1 -0
  198. package/dist/ai-service/agent/tools/build-read-file.js +148 -0
  199. package/dist/ai-service/agent/tools/build-read-file.js.map +1 -0
  200. package/dist/ai-service/agent/tools/build-reload-file.d.ts +14 -0
  201. package/dist/ai-service/agent/tools/build-reload-file.d.ts.map +1 -0
  202. package/dist/ai-service/agent/tools/build-reload-file.js +78 -0
  203. package/dist/ai-service/agent/tools/build-reload-file.js.map +1 -0
  204. package/dist/ai-service/agent/tools/build-rename-file.d.ts +13 -0
  205. package/dist/ai-service/agent/tools/build-rename-file.d.ts.map +1 -0
  206. package/dist/ai-service/agent/tools/build-rename-file.js +72 -0
  207. package/dist/ai-service/agent/tools/build-rename-file.js.map +1 -0
  208. package/dist/ai-service/agent/tools/build-write-file.d.ts +13 -0
  209. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -0
  210. package/dist/ai-service/agent/tools/build-write-file.js +82 -0
  211. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -0
  212. package/dist/ai-service/agent/tools/clear-error-cache.d.ts +10 -0
  213. package/dist/ai-service/agent/tools/clear-error-cache.d.ts.map +1 -0
  214. package/dist/ai-service/agent/tools/clear-error-cache.js +38 -0
  215. package/dist/ai-service/agent/tools/clear-error-cache.js.map +1 -0
  216. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.d.ts +58 -0
  217. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.d.ts.map +1 -0
  218. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.js +258 -0
  219. package/dist/ai-service/agent/tools/databases/destructive-migration-prompt.js.map +1 -0
  220. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +489 -0
  221. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -0
  222. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +1172 -0
  223. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -0
  224. package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts +65 -0
  225. package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts.map +1 -0
  226. package/dist/ai-service/agent/tools/databases/dev-database-tools.js +77 -0
  227. package/dist/ai-service/agent/tools/databases/dev-database-tools.js.map +1 -0
  228. package/dist/ai-service/agent/tools/debug-cache.d.ts +175 -0
  229. package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -0
  230. package/dist/ai-service/agent/tools/debug-cache.js +643 -0
  231. package/dist/ai-service/agent/tools/debug-cache.js.map +1 -0
  232. package/dist/ai-service/agent/tools/get-logs.d.ts +74 -0
  233. package/dist/ai-service/agent/tools/get-logs.d.ts.map +1 -0
  234. package/dist/ai-service/agent/tools/get-logs.js +357 -0
  235. package/dist/ai-service/agent/tools/get-logs.js.map +1 -0
  236. package/dist/ai-service/agent/tools/get-runtime-errors.d.ts +13 -0
  237. package/dist/ai-service/agent/tools/get-runtime-errors.d.ts.map +1 -0
  238. package/dist/ai-service/agent/tools/get-runtime-errors.js +63 -0
  239. package/dist/ai-service/agent/tools/get-runtime-errors.js.map +1 -0
  240. package/dist/ai-service/agent/tools/index.d.ts +36 -0
  241. package/dist/ai-service/agent/tools/index.d.ts.map +1 -0
  242. package/dist/ai-service/agent/tools/index.js +36 -0
  243. package/dist/ai-service/agent/tools/index.js.map +1 -0
  244. package/dist/ai-service/agent/tools/integrations/delete-integration.d.ts +18 -0
  245. package/dist/ai-service/agent/tools/integrations/delete-integration.d.ts.map +1 -0
  246. package/dist/ai-service/agent/tools/integrations/delete-integration.js +107 -0
  247. package/dist/ai-service/agent/tools/integrations/delete-integration.js.map +1 -0
  248. package/dist/ai-service/agent/tools/integrations/errors.d.ts +9 -0
  249. package/dist/ai-service/agent/tools/integrations/errors.d.ts.map +1 -0
  250. package/dist/ai-service/agent/tools/integrations/errors.js +35 -0
  251. package/dist/ai-service/agent/tools/integrations/errors.js.map +1 -0
  252. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +471 -0
  253. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -0
  254. package/dist/ai-service/agent/tools/integrations/execute-request.js +1179 -0
  255. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -0
  256. package/dist/ai-service/agent/tools/integrations/index.d.ts +6 -0
  257. package/dist/ai-service/agent/tools/integrations/index.d.ts.map +1 -0
  258. package/dist/ai-service/agent/tools/integrations/index.js +6 -0
  259. package/dist/ai-service/agent/tools/integrations/index.js.map +1 -0
  260. package/dist/ai-service/agent/tools/integrations/integration-setup.d.ts +98 -0
  261. package/dist/ai-service/agent/tools/integrations/integration-setup.d.ts.map +1 -0
  262. package/dist/ai-service/agent/tools/integrations/integration-setup.js +391 -0
  263. package/dist/ai-service/agent/tools/integrations/integration-setup.js.map +1 -0
  264. package/dist/ai-service/agent/tools/integrations/internal.d.ts +15 -0
  265. package/dist/ai-service/agent/tools/integrations/internal.d.ts.map +1 -0
  266. package/dist/ai-service/agent/tools/integrations/internal.js +95 -0
  267. package/dist/ai-service/agent/tools/integrations/internal.js.map +1 -0
  268. package/dist/ai-service/agent/tools/integrations/managed-app-database.d.ts +16 -0
  269. package/dist/ai-service/agent/tools/integrations/managed-app-database.d.ts.map +1 -0
  270. package/dist/ai-service/agent/tools/integrations/managed-app-database.js +31 -0
  271. package/dist/ai-service/agent/tools/integrations/managed-app-database.js.map +1 -0
  272. package/dist/ai-service/agent/tools/integrations/metadata.d.ts +15 -0
  273. package/dist/ai-service/agent/tools/integrations/metadata.d.ts.map +1 -0
  274. package/dist/ai-service/agent/tools/integrations/metadata.js +94 -0
  275. package/dist/ai-service/agent/tools/integrations/metadata.js.map +1 -0
  276. package/dist/ai-service/agent/tools/integrations/run-code.d.ts +9 -0
  277. package/dist/ai-service/agent/tools/integrations/run-code.d.ts.map +1 -0
  278. package/dist/ai-service/agent/tools/integrations/run-code.js +41 -0
  279. package/dist/ai-service/agent/tools/integrations/run-code.js.map +1 -0
  280. package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts +50 -0
  281. package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts.map +1 -0
  282. package/dist/ai-service/agent/tools/integrations/sql-classification.js +570 -0
  283. package/dist/ai-service/agent/tools/integrations/sql-classification.js.map +1 -0
  284. package/dist/ai-service/agent/tools/mark-api-manually-verified.d.ts +31 -0
  285. package/dist/ai-service/agent/tools/mark-api-manually-verified.d.ts.map +1 -0
  286. package/dist/ai-service/agent/tools/mark-api-manually-verified.js +94 -0
  287. package/dist/ai-service/agent/tools/mark-api-manually-verified.js.map +1 -0
  288. package/dist/ai-service/agent/tools/migration/update-migration-write-policy.d.ts +23 -0
  289. package/dist/ai-service/agent/tools/migration/update-migration-write-policy.d.ts.map +1 -0
  290. package/dist/ai-service/agent/tools/migration/update-migration-write-policy.js +94 -0
  291. package/dist/ai-service/agent/tools/migration/update-migration-write-policy.js.map +1 -0
  292. package/dist/ai-service/agent/tools/page-edit-guidance.d.ts +2 -0
  293. package/dist/ai-service/agent/tools/page-edit-guidance.d.ts.map +1 -0
  294. package/dist/ai-service/agent/tools/page-edit-guidance.js +11 -0
  295. package/dist/ai-service/agent/tools/page-edit-guidance.js.map +1 -0
  296. package/dist/ai-service/agent/tools/report-security-findings.d.ts +169 -0
  297. package/dist/ai-service/agent/tools/report-security-findings.d.ts.map +1 -0
  298. package/dist/ai-service/agent/tools/report-security-findings.js +53 -0
  299. package/dist/ai-service/agent/tools/report-security-findings.js.map +1 -0
  300. package/dist/ai-service/agent/tools/screenshot-selector.d.ts +23 -0
  301. package/dist/ai-service/agent/tools/screenshot-selector.d.ts.map +1 -0
  302. package/dist/ai-service/agent/tools/screenshot-selector.js +158 -0
  303. package/dist/ai-service/agent/tools/screenshot-selector.js.map +1 -0
  304. package/dist/ai-service/agent/tools/shared-helpers.d.ts +6 -0
  305. package/dist/ai-service/agent/tools/shared-helpers.d.ts.map +1 -0
  306. package/dist/ai-service/agent/tools/shared-helpers.js +26 -0
  307. package/dist/ai-service/agent/tools/shared-helpers.js.map +1 -0
  308. package/dist/ai-service/agent/tools.d.ts +65 -0
  309. package/dist/ai-service/agent/tools.d.ts.map +1 -0
  310. package/dist/ai-service/agent/tools.js +799 -0
  311. package/dist/ai-service/agent/tools.js.map +1 -0
  312. package/dist/ai-service/agent/tools2/access-control.d.ts +150 -0
  313. package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -0
  314. package/dist/ai-service/agent/tools2/access-control.js +310 -0
  315. package/dist/ai-service/agent/tools2/access-control.js.map +1 -0
  316. package/dist/ai-service/agent/tools2/entity-permissions.d.ts +201 -0
  317. package/dist/ai-service/agent/tools2/entity-permissions.d.ts.map +1 -0
  318. package/dist/ai-service/agent/tools2/entity-permissions.js +163 -0
  319. package/dist/ai-service/agent/tools2/entity-permissions.js.map +1 -0
  320. package/dist/ai-service/agent/tools2/example.d.ts +13 -0
  321. package/dist/ai-service/agent/tools2/example.d.ts.map +1 -0
  322. package/dist/ai-service/agent/tools2/example.js +151 -0
  323. package/dist/ai-service/agent/tools2/example.js.map +1 -0
  324. package/dist/ai-service/agent/tools2/index.d.ts +18 -0
  325. package/dist/ai-service/agent/tools2/index.d.ts.map +1 -0
  326. package/dist/ai-service/agent/tools2/index.js +19 -0
  327. package/dist/ai-service/agent/tools2/index.js.map +1 -0
  328. package/dist/ai-service/agent/tools2/registry.d.ts +231 -0
  329. package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -0
  330. package/dist/ai-service/agent/tools2/registry.js +602 -0
  331. package/dist/ai-service/agent/tools2/registry.js.map +1 -0
  332. package/dist/ai-service/agent/tools2/test-utils.d.ts +7 -0
  333. package/dist/ai-service/agent/tools2/test-utils.d.ts.map +1 -0
  334. package/dist/ai-service/agent/tools2/test-utils.js +10 -0
  335. package/dist/ai-service/agent/tools2/test-utils.js.map +1 -0
  336. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts +32 -0
  337. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts.map +1 -0
  338. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js +103 -0
  339. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js.map +1 -0
  340. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.d.ts +33 -0
  341. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.d.ts.map +1 -0
  342. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.js +92 -0
  343. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.js.map +1 -0
  344. package/dist/ai-service/agent/tools2/tools/bash.d.ts +34 -0
  345. package/dist/ai-service/agent/tools2/tools/bash.d.ts.map +1 -0
  346. package/dist/ai-service/agent/tools2/tools/bash.js +97 -0
  347. package/dist/ai-service/agent/tools2/tools/bash.js.map +1 -0
  348. package/dist/ai-service/agent/tools2/tools/cancel-task.d.ts +20 -0
  349. package/dist/ai-service/agent/tools2/tools/cancel-task.d.ts.map +1 -0
  350. package/dist/ai-service/agent/tools2/tools/cancel-task.js +39 -0
  351. package/dist/ai-service/agent/tools2/tools/cancel-task.js.map +1 -0
  352. package/dist/ai-service/agent/tools2/tools/check-task.d.ts +38 -0
  353. package/dist/ai-service/agent/tools2/tools/check-task.d.ts.map +1 -0
  354. package/dist/ai-service/agent/tools2/tools/check-task.js +59 -0
  355. package/dist/ai-service/agent/tools2/tools/check-task.js.map +1 -0
  356. package/dist/ai-service/agent/tools2/tools/deploy-service.d.ts +16 -0
  357. package/dist/ai-service/agent/tools2/tools/deploy-service.d.ts.map +1 -0
  358. package/dist/ai-service/agent/tools2/tools/deploy-service.js +167 -0
  359. package/dist/ai-service/agent/tools2/tools/deploy-service.js.map +1 -0
  360. package/dist/ai-service/agent/tools2/tools/download-attachments.d.ts +33 -0
  361. package/dist/ai-service/agent/tools2/tools/download-attachments.d.ts.map +1 -0
  362. package/dist/ai-service/agent/tools2/tools/download-attachments.js +309 -0
  363. package/dist/ai-service/agent/tools2/tools/download-attachments.js.map +1 -0
  364. package/dist/ai-service/agent/tools2/tools/edit.d.ts +17 -0
  365. package/dist/ai-service/agent/tools2/tools/edit.d.ts.map +1 -0
  366. package/dist/ai-service/agent/tools2/tools/edit.js +67 -0
  367. package/dist/ai-service/agent/tools2/tools/edit.js.map +1 -0
  368. package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts +31 -0
  369. package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts.map +1 -0
  370. package/dist/ai-service/agent/tools2/tools/end-test-run.js +112 -0
  371. package/dist/ai-service/agent/tools2/tools/end-test-run.js.map +1 -0
  372. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +58 -0
  373. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -0
  374. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +802 -0
  375. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -0
  376. package/dist/ai-service/agent/tools2/tools/git-raw.d.ts +25 -0
  377. package/dist/ai-service/agent/tools2/tools/git-raw.d.ts.map +1 -0
  378. package/dist/ai-service/agent/tools2/tools/git-raw.js +394 -0
  379. package/dist/ai-service/agent/tools2/tools/git-raw.js.map +1 -0
  380. package/dist/ai-service/agent/tools2/tools/git.d.ts +126 -0
  381. package/dist/ai-service/agent/tools2/tools/git.d.ts.map +1 -0
  382. package/dist/ai-service/agent/tools2/tools/git.js +898 -0
  383. package/dist/ai-service/agent/tools2/tools/git.js.map +1 -0
  384. package/dist/ai-service/agent/tools2/tools/glob.d.ts +14 -0
  385. package/dist/ai-service/agent/tools2/tools/glob.d.ts.map +1 -0
  386. package/dist/ai-service/agent/tools2/tools/glob.js +71 -0
  387. package/dist/ai-service/agent/tools2/tools/glob.js.map +1 -0
  388. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts +22 -0
  389. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts.map +1 -0
  390. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js +927 -0
  391. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js.map +1 -0
  392. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +123 -0
  393. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -0
  394. package/dist/ai-service/agent/tools2/tools/grep-metadata.js +534 -0
  395. package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -0
  396. package/dist/ai-service/agent/tools2/tools/grep.d.ts +26 -0
  397. package/dist/ai-service/agent/tools2/tools/grep.d.ts.map +1 -0
  398. package/dist/ai-service/agent/tools2/tools/grep.js +249 -0
  399. package/dist/ai-service/agent/tools2/tools/grep.js.map +1 -0
  400. package/dist/ai-service/agent/tools2/tools/index.d.ts +24 -0
  401. package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -0
  402. package/dist/ai-service/agent/tools2/tools/index.js +28 -0
  403. package/dist/ai-service/agent/tools2/tools/index.js.map +1 -0
  404. package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts +18 -0
  405. package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts.map +1 -0
  406. package/dist/ai-service/agent/tools2/tools/list-attachments.js +70 -0
  407. package/dist/ai-service/agent/tools2/tools/list-attachments.js.map +1 -0
  408. package/dist/ai-service/agent/tools2/tools/list-tasks.d.ts +21 -0
  409. package/dist/ai-service/agent/tools2/tools/list-tasks.d.ts.map +1 -0
  410. package/dist/ai-service/agent/tools2/tools/list-tasks.js +35 -0
  411. package/dist/ai-service/agent/tools2/tools/list-tasks.js.map +1 -0
  412. package/dist/ai-service/agent/tools2/tools/ls.d.ts +17 -0
  413. package/dist/ai-service/agent/tools2/tools/ls.d.ts.map +1 -0
  414. package/dist/ai-service/agent/tools2/tools/ls.js +141 -0
  415. package/dist/ai-service/agent/tools2/tools/ls.js.map +1 -0
  416. package/dist/ai-service/agent/tools2/tools/read.d.ts +12 -0
  417. package/dist/ai-service/agent/tools2/tools/read.d.ts.map +1 -0
  418. package/dist/ai-service/agent/tools2/tools/read.js +60 -0
  419. package/dist/ai-service/agent/tools2/tools/read.js.map +1 -0
  420. package/dist/ai-service/agent/tools2/tools/remember-knowledge.d.ts +31 -0
  421. package/dist/ai-service/agent/tools2/tools/remember-knowledge.d.ts.map +1 -0
  422. package/dist/ai-service/agent/tools2/tools/remember-knowledge.js +118 -0
  423. package/dist/ai-service/agent/tools2/tools/remember-knowledge.js.map +1 -0
  424. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts +50 -0
  425. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts.map +1 -0
  426. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.js +273 -0
  427. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.js.map +1 -0
  428. package/dist/ai-service/agent/tools2/tools/start-test-run.d.ts +24 -0
  429. package/dist/ai-service/agent/tools2/tools/start-test-run.d.ts.map +1 -0
  430. package/dist/ai-service/agent/tools2/tools/start-test-run.js +409 -0
  431. package/dist/ai-service/agent/tools2/tools/start-test-run.js.map +1 -0
  432. package/dist/ai-service/agent/tools2/tools/tool-timeout.d.ts +2 -0
  433. package/dist/ai-service/agent/tools2/tools/tool-timeout.d.ts.map +1 -0
  434. package/dist/ai-service/agent/tools2/tools/tool-timeout.js +2 -0
  435. package/dist/ai-service/agent/tools2/tools/tool-timeout.js.map +1 -0
  436. package/dist/ai-service/agent/tools2/tools/update-test-case-status.d.ts +29 -0
  437. package/dist/ai-service/agent/tools2/tools/update-test-case-status.d.ts.map +1 -0
  438. package/dist/ai-service/agent/tools2/tools/update-test-case-status.js +112 -0
  439. package/dist/ai-service/agent/tools2/tools/update-test-case-status.js.map +1 -0
  440. package/dist/ai-service/agent/tools2/tools/wait-for-task.d.ts +48 -0
  441. package/dist/ai-service/agent/tools2/tools/wait-for-task.d.ts.map +1 -0
  442. package/dist/ai-service/agent/tools2/tools/wait-for-task.js +101 -0
  443. package/dist/ai-service/agent/tools2/tools/wait-for-task.js.map +1 -0
  444. package/dist/ai-service/agent/tools2/tools/web-fetch.d.ts +30 -0
  445. package/dist/ai-service/agent/tools2/tools/web-fetch.d.ts.map +1 -0
  446. package/dist/ai-service/agent/tools2/tools/web-fetch.js +285 -0
  447. package/dist/ai-service/agent/tools2/tools/web-fetch.js.map +1 -0
  448. package/dist/ai-service/agent/tools2/tools/web-search.d.ts +25 -0
  449. package/dist/ai-service/agent/tools2/tools/web-search.d.ts.map +1 -0
  450. package/dist/ai-service/agent/tools2/tools/web-search.js +210 -0
  451. package/dist/ai-service/agent/tools2/tools/web-search.js.map +1 -0
  452. package/dist/ai-service/agent/tools2/tools/write.d.ts +14 -0
  453. package/dist/ai-service/agent/tools2/tools/write.d.ts.map +1 -0
  454. package/dist/ai-service/agent/tools2/tools/write.js +33 -0
  455. package/dist/ai-service/agent/tools2/tools/write.js.map +1 -0
  456. package/dist/ai-service/agent/tools2/types.d.ts +396 -0
  457. package/dist/ai-service/agent/tools2/types.d.ts.map +1 -0
  458. package/dist/ai-service/agent/tools2/types.js +204 -0
  459. package/dist/ai-service/agent/tools2/types.js.map +1 -0
  460. package/dist/ai-service/agent/tools2/utils.d.ts +9 -0
  461. package/dist/ai-service/agent/tools2/utils.d.ts.map +1 -0
  462. package/dist/ai-service/agent/tools2/utils.js +14 -0
  463. package/dist/ai-service/agent/tools2/utils.js.map +1 -0
  464. package/dist/ai-service/agent/utils.d.ts +15 -0
  465. package/dist/ai-service/agent/utils.d.ts.map +1 -0
  466. package/dist/ai-service/agent/utils.js +612 -0
  467. package/dist/ai-service/agent/utils.js.map +1 -0
  468. package/dist/ai-service/app-interface/cancellable-exec.d.ts +34 -0
  469. package/dist/ai-service/app-interface/cancellable-exec.d.ts.map +1 -0
  470. package/dist/ai-service/app-interface/cancellable-exec.js +98 -0
  471. package/dist/ai-service/app-interface/cancellable-exec.js.map +1 -0
  472. package/dist/ai-service/app-interface/constants.d.ts +60 -0
  473. package/dist/ai-service/app-interface/constants.d.ts.map +1 -0
  474. package/dist/ai-service/app-interface/constants.js +124 -0
  475. package/dist/ai-service/app-interface/constants.js.map +1 -0
  476. package/dist/ai-service/app-interface/file-system-interface.d.ts +22 -0
  477. package/dist/ai-service/app-interface/file-system-interface.d.ts.map +1 -0
  478. package/dist/ai-service/app-interface/file-system-interface.js +109 -0
  479. package/dist/ai-service/app-interface/file-system-interface.js.map +1 -0
  480. package/dist/ai-service/app-interface/filesystem/draft-manager.d.ts +87 -0
  481. package/dist/ai-service/app-interface/filesystem/draft-manager.d.ts.map +1 -0
  482. package/dist/ai-service/app-interface/filesystem/draft-manager.js +91 -0
  483. package/dist/ai-service/app-interface/filesystem/draft-manager.js.map +1 -0
  484. package/dist/ai-service/app-interface/filesystem/handlers/api-handler.d.ts +36 -0
  485. package/dist/ai-service/app-interface/filesystem/handlers/api-handler.d.ts.map +1 -0
  486. package/dist/ai-service/app-interface/filesystem/handlers/api-handler.js +250 -0
  487. package/dist/ai-service/app-interface/filesystem/handlers/api-handler.js.map +1 -0
  488. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.d.ts +95 -0
  489. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.d.ts.map +1 -0
  490. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.js +530 -0
  491. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.js.map +1 -0
  492. package/dist/ai-service/app-interface/filesystem/index.d.ts +12 -0
  493. package/dist/ai-service/app-interface/filesystem/index.d.ts.map +1 -0
  494. package/dist/ai-service/app-interface/filesystem/index.js +10 -0
  495. package/dist/ai-service/app-interface/filesystem/index.js.map +1 -0
  496. package/dist/ai-service/app-interface/filesystem/path-validator.d.ts +43 -0
  497. package/dist/ai-service/app-interface/filesystem/path-validator.d.ts.map +1 -0
  498. package/dist/ai-service/app-interface/filesystem/path-validator.js +9 -0
  499. package/dist/ai-service/app-interface/filesystem/path-validator.js.map +1 -0
  500. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.d.ts +50 -0
  501. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.d.ts.map +1 -0
  502. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.js +70 -0
  503. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.js.map +1 -0
  504. package/dist/ai-service/app-interface/filesystem/validation.d.ts +88 -0
  505. package/dist/ai-service/app-interface/filesystem/validation.d.ts.map +1 -0
  506. package/dist/ai-service/app-interface/filesystem/validation.js +197 -0
  507. package/dist/ai-service/app-interface/filesystem/validation.js.map +1 -0
  508. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts +144 -0
  509. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts.map +1 -0
  510. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js +238 -0
  511. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js.map +1 -0
  512. package/dist/ai-service/app-interface/filesystem/virtual-fs-types.d.ts +126 -0
  513. package/dist/ai-service/app-interface/filesystem/virtual-fs-types.d.ts.map +1 -0
  514. package/dist/ai-service/app-interface/filesystem/virtual-fs-types.js +9 -0
  515. package/dist/ai-service/app-interface/filesystem/virtual-fs-types.js.map +1 -0
  516. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.d.ts +49 -0
  517. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.d.ts.map +1 -0
  518. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.js +67 -0
  519. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.js.map +1 -0
  520. package/dist/ai-service/app-interface/linter.d.ts +11 -0
  521. package/dist/ai-service/app-interface/linter.d.ts.map +1 -0
  522. package/dist/ai-service/app-interface/linter.js +152 -0
  523. package/dist/ai-service/app-interface/linter.js.map +1 -0
  524. package/dist/ai-service/app-interface/npm-error-parser.d.ts +84 -0
  525. package/dist/ai-service/app-interface/npm-error-parser.d.ts.map +1 -0
  526. package/dist/ai-service/app-interface/npm-error-parser.js +510 -0
  527. package/dist/ai-service/app-interface/npm-error-parser.js.map +1 -0
  528. package/dist/ai-service/app-interface/npm-package-lookup.d.ts +338 -0
  529. package/dist/ai-service/app-interface/npm-package-lookup.d.ts.map +1 -0
  530. package/dist/ai-service/app-interface/npm-package-lookup.js +1043 -0
  531. package/dist/ai-service/app-interface/npm-package-lookup.js.map +1 -0
  532. package/dist/ai-service/app-interface/npm-registry.d.ts +913 -0
  533. package/dist/ai-service/app-interface/npm-registry.d.ts.map +1 -0
  534. package/dist/ai-service/app-interface/npm-registry.js +2461 -0
  535. package/dist/ai-service/app-interface/npm-registry.js.map +1 -0
  536. package/dist/ai-service/app-interface/shell.d.ts +575 -4
  537. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  538. package/dist/ai-service/app-interface/shell.js +2596 -70
  539. package/dist/ai-service/app-interface/shell.js.map +1 -1
  540. package/dist/ai-service/app-interface/vulnerability-gate.d.ts +83 -0
  541. package/dist/ai-service/app-interface/vulnerability-gate.d.ts.map +1 -0
  542. package/dist/ai-service/app-interface/vulnerability-gate.js +543 -0
  543. package/dist/ai-service/app-interface/vulnerability-gate.js.map +1 -0
  544. package/dist/ai-service/app-skills/build-knowledge-feedback-message.d.ts +3 -0
  545. package/dist/ai-service/app-skills/build-knowledge-feedback-message.d.ts.map +1 -0
  546. package/dist/ai-service/app-skills/build-knowledge-feedback-message.js +47 -0
  547. package/dist/ai-service/app-skills/build-knowledge-feedback-message.js.map +1 -0
  548. package/dist/ai-service/app-skills/helpers.d.ts +18 -0
  549. package/dist/ai-service/app-skills/helpers.d.ts.map +1 -0
  550. package/dist/ai-service/app-skills/helpers.js +441 -0
  551. package/dist/ai-service/app-skills/helpers.js.map +1 -0
  552. package/dist/ai-service/app-skills/manager.d.ts +68 -0
  553. package/dist/ai-service/app-skills/manager.d.ts.map +1 -0
  554. package/dist/ai-service/app-skills/manager.js +259 -0
  555. package/dist/ai-service/app-skills/manager.js.map +1 -0
  556. package/dist/ai-service/app-skills/parser.d.ts +53 -0
  557. package/dist/ai-service/app-skills/parser.d.ts.map +1 -0
  558. package/dist/ai-service/app-skills/parser.js +82 -0
  559. package/dist/ai-service/app-skills/parser.js.map +1 -0
  560. package/dist/ai-service/attachment-upload.d.ts +33 -0
  561. package/dist/ai-service/attachment-upload.d.ts.map +1 -0
  562. package/dist/ai-service/attachment-upload.js +98 -0
  563. package/dist/ai-service/attachment-upload.js.map +1 -0
  564. package/dist/ai-service/attachments/index.d.ts +2 -0
  565. package/dist/ai-service/attachments/index.d.ts.map +1 -0
  566. package/dist/ai-service/attachments/index.js +2 -0
  567. package/dist/ai-service/attachments/index.js.map +1 -0
  568. package/dist/ai-service/attachments/parse-data-url.d.ts +5 -0
  569. package/dist/ai-service/attachments/parse-data-url.d.ts.map +1 -0
  570. package/dist/ai-service/attachments/parse-data-url.js +14 -0
  571. package/dist/ai-service/attachments/parse-data-url.js.map +1 -0
  572. package/dist/ai-service/attachments/store.d.ts +96 -0
  573. package/dist/ai-service/attachments/store.d.ts.map +1 -0
  574. package/dist/ai-service/attachments/store.js +285 -0
  575. package/dist/ai-service/attachments/store.js.map +1 -0
  576. package/dist/ai-service/attachments/text-upload-artifacts.d.ts +37 -0
  577. package/dist/ai-service/attachments/text-upload-artifacts.d.ts.map +1 -0
  578. package/dist/ai-service/attachments/text-upload-artifacts.js +231 -0
  579. package/dist/ai-service/attachments/text-upload-artifacts.js.map +1 -0
  580. package/dist/ai-service/attachments/uploaded-content-part.d.ts +23 -0
  581. package/dist/ai-service/attachments/uploaded-content-part.d.ts.map +1 -0
  582. package/dist/ai-service/attachments/uploaded-content-part.js +137 -0
  583. package/dist/ai-service/attachments/uploaded-content-part.js.map +1 -0
  584. package/dist/ai-service/chat/chat-push-metrics.d.ts +13 -0
  585. package/dist/ai-service/chat/chat-push-metrics.d.ts.map +1 -0
  586. package/dist/ai-service/chat/chat-push-metrics.js +68 -0
  587. package/dist/ai-service/chat/chat-push-metrics.js.map +1 -0
  588. package/dist/ai-service/chat/chat-session-store-metrics.d.ts +13 -0
  589. package/dist/ai-service/chat/chat-session-store-metrics.d.ts.map +1 -0
  590. package/dist/ai-service/chat/chat-session-store-metrics.js +72 -0
  591. package/dist/ai-service/chat/chat-session-store-metrics.js.map +1 -0
  592. package/dist/ai-service/chat/chat-session-store.d.ts +170 -0
  593. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -0
  594. package/dist/ai-service/chat/chat-session-store.js +862 -0
  595. package/dist/ai-service/chat/chat-session-store.js.map +1 -0
  596. package/dist/ai-service/chat/extract-history.d.ts +3 -0
  597. package/dist/ai-service/chat/extract-history.d.ts.map +1 -0
  598. package/dist/ai-service/chat/extract-history.js +21 -0
  599. package/dist/ai-service/chat/extract-history.js.map +1 -0
  600. package/dist/ai-service/chat/transcript-budget.d.ts +106 -0
  601. package/dist/ai-service/chat/transcript-budget.d.ts.map +1 -0
  602. package/dist/ai-service/chat/transcript-budget.js +175 -0
  603. package/dist/ai-service/chat/transcript-budget.js.map +1 -0
  604. package/dist/ai-service/chat/transcript-metrics.d.ts +33 -0
  605. package/dist/ai-service/chat/transcript-metrics.d.ts.map +1 -0
  606. package/dist/ai-service/chat/transcript-metrics.js +169 -0
  607. package/dist/ai-service/chat/transcript-metrics.js.map +1 -0
  608. package/dist/ai-service/chat/utils.d.ts +16 -0
  609. package/dist/ai-service/chat/utils.d.ts.map +1 -0
  610. package/dist/ai-service/chat/utils.js +98 -0
  611. package/dist/ai-service/chat/utils.js.map +1 -0
  612. package/dist/ai-service/checklist/api-migration-checklist-gate.d.ts +11 -0
  613. package/dist/ai-service/checklist/api-migration-checklist-gate.d.ts.map +1 -0
  614. package/dist/ai-service/checklist/api-migration-checklist-gate.js +45 -0
  615. package/dist/ai-service/checklist/api-migration-checklist-gate.js.map +1 -0
  616. package/dist/ai-service/checklist/api-migration-origins.d.ts +4 -0
  617. package/dist/ai-service/checklist/api-migration-origins.d.ts.map +1 -0
  618. package/dist/ai-service/checklist/api-migration-origins.js +8 -0
  619. package/dist/ai-service/checklist/api-migration-origins.js.map +1 -0
  620. package/dist/ai-service/checklist/persisted-checklist-store.d.ts +108 -0
  621. package/dist/ai-service/checklist/persisted-checklist-store.d.ts.map +1 -0
  622. package/dist/ai-service/checklist/persisted-checklist-store.js +511 -0
  623. package/dist/ai-service/checklist/persisted-checklist-store.js.map +1 -0
  624. package/dist/ai-service/const.d.ts +86 -5
  625. package/dist/ai-service/const.d.ts.map +1 -1
  626. package/dist/ai-service/const.js +92 -5
  627. package/dist/ai-service/const.js.map +1 -1
  628. package/dist/ai-service/context/app-context.d.ts +78 -0
  629. package/dist/ai-service/context/app-context.d.ts.map +1 -0
  630. package/dist/ai-service/context/app-context.js +359 -0
  631. package/dist/ai-service/context/app-context.js.map +1 -0
  632. package/dist/ai-service/context-archive-paths.d.ts +11 -0
  633. package/dist/ai-service/context-archive-paths.d.ts.map +1 -0
  634. package/dist/ai-service/context-archive-paths.js +35 -0
  635. package/dist/ai-service/context-archive-paths.js.map +1 -0
  636. package/dist/ai-service/context-download.d.ts +56 -0
  637. package/dist/ai-service/context-download.d.ts.map +1 -0
  638. package/dist/ai-service/context-download.js +372 -0
  639. package/dist/ai-service/context-download.js.map +1 -0
  640. package/dist/ai-service/context-flush-scheduler.d.ts +76 -0
  641. package/dist/ai-service/context-flush-scheduler.d.ts.map +1 -0
  642. package/dist/ai-service/context-flush-scheduler.js +134 -0
  643. package/dist/ai-service/context-flush-scheduler.js.map +1 -0
  644. package/dist/ai-service/context-flush.d.ts +36 -0
  645. package/dist/ai-service/context-flush.d.ts.map +1 -0
  646. package/dist/ai-service/context-flush.js +90 -0
  647. package/dist/ai-service/context-flush.js.map +1 -0
  648. package/dist/ai-service/context-restore.d.ts +64 -0
  649. package/dist/ai-service/context-restore.d.ts.map +1 -0
  650. package/dist/ai-service/context-restore.js +136 -0
  651. package/dist/ai-service/context-restore.js.map +1 -0
  652. package/dist/ai-service/context-upload.d.ts +31 -0
  653. package/dist/ai-service/context-upload.d.ts.map +1 -0
  654. package/dist/ai-service/context-upload.js +180 -0
  655. package/dist/ai-service/context-upload.js.map +1 -0
  656. package/dist/ai-service/dev-database-client.d.ts +169 -0
  657. package/dist/ai-service/dev-database-client.d.ts.map +1 -0
  658. package/dist/ai-service/dev-database-client.js +180 -0
  659. package/dist/ai-service/dev-database-client.js.map +1 -0
  660. package/dist/ai-service/dev-database-file-sync.d.ts +41 -0
  661. package/dist/ai-service/dev-database-file-sync.d.ts.map +1 -0
  662. package/dist/ai-service/dev-database-file-sync.js +29 -0
  663. package/dist/ai-service/dev-database-file-sync.js.map +1 -0
  664. package/dist/ai-service/features.d.ts +237 -0
  665. package/dist/ai-service/features.d.ts.map +1 -0
  666. package/dist/ai-service/features.js +238 -0
  667. package/dist/ai-service/features.js.map +1 -0
  668. package/dist/ai-service/filter-disabled-tools-for-migration.d.ts +6 -0
  669. package/dist/ai-service/filter-disabled-tools-for-migration.d.ts.map +1 -0
  670. package/dist/ai-service/filter-disabled-tools-for-migration.js +42 -0
  671. package/dist/ai-service/filter-disabled-tools-for-migration.js.map +1 -0
  672. package/dist/ai-service/helper-system-ai-attributes.d.ts +19 -0
  673. package/dist/ai-service/helper-system-ai-attributes.d.ts.map +1 -0
  674. package/dist/ai-service/helper-system-ai-attributes.js +17 -0
  675. package/dist/ai-service/helper-system-ai-attributes.js.map +1 -0
  676. package/dist/ai-service/index.d.ts +693 -12
  677. package/dist/ai-service/index.d.ts.map +1 -1
  678. package/dist/ai-service/index.js +5021 -79
  679. package/dist/ai-service/index.js.map +1 -1
  680. package/dist/ai-service/integration-validator.d.ts +4 -0
  681. package/dist/ai-service/integration-validator.d.ts.map +1 -0
  682. package/dist/ai-service/integration-validator.js +58 -0
  683. package/dist/ai-service/integration-validator.js.map +1 -0
  684. package/dist/ai-service/integrations/gron.d.ts +18 -0
  685. package/dist/ai-service/integrations/gron.d.ts.map +1 -0
  686. package/dist/ai-service/integrations/gron.js +321 -0
  687. package/dist/ai-service/integrations/gron.js.map +1 -0
  688. package/dist/ai-service/integrations/mention-safe-tag-name.d.ts +12 -0
  689. package/dist/ai-service/integrations/mention-safe-tag-name.d.ts.map +1 -0
  690. package/dist/ai-service/integrations/mention-safe-tag-name.js +18 -0
  691. package/dist/ai-service/integrations/mention-safe-tag-name.js.map +1 -0
  692. package/dist/ai-service/integrations/metadata-binaries.d.ts +28 -0
  693. package/dist/ai-service/integrations/metadata-binaries.d.ts.map +1 -0
  694. package/dist/ai-service/integrations/metadata-binaries.js +48 -0
  695. package/dist/ai-service/integrations/metadata-binaries.js.map +1 -0
  696. package/dist/ai-service/integrations/metadata-storage/index.d.ts +35 -0
  697. package/dist/ai-service/integrations/metadata-storage/index.d.ts.map +1 -0
  698. package/dist/ai-service/integrations/metadata-storage/index.js +2 -0
  699. package/dist/ai-service/integrations/metadata-storage/index.js.map +1 -0
  700. package/dist/ai-service/integrations/metadata-storage/local.d.ts +56 -0
  701. package/dist/ai-service/integrations/metadata-storage/local.d.ts.map +1 -0
  702. package/dist/ai-service/integrations/metadata-storage/local.js +346 -0
  703. package/dist/ai-service/integrations/metadata-storage/local.js.map +1 -0
  704. package/dist/ai-service/integrations/ripgrep-path.d.ts +6 -0
  705. package/dist/ai-service/integrations/ripgrep-path.d.ts.map +1 -0
  706. package/dist/ai-service/integrations/ripgrep-path.js +56 -0
  707. package/dist/ai-service/integrations/ripgrep-path.js.map +1 -0
  708. package/dist/ai-service/integrations/store.d.ts +142 -0
  709. package/dist/ai-service/integrations/store.d.ts.map +1 -0
  710. package/dist/ai-service/integrations/store.js +574 -0
  711. package/dist/ai-service/integrations/store.js.map +1 -0
  712. package/dist/ai-service/judge/debug-browser.d.ts +8 -0
  713. package/dist/ai-service/judge/debug-browser.d.ts.map +1 -0
  714. package/dist/ai-service/judge/debug-browser.js +79 -0
  715. package/dist/ai-service/judge/debug-browser.js.map +1 -0
  716. package/dist/ai-service/judge/index.d.ts +12 -0
  717. package/dist/ai-service/judge/index.d.ts.map +1 -0
  718. package/dist/ai-service/judge/index.js +11 -0
  719. package/dist/ai-service/judge/index.js.map +1 -0
  720. package/dist/ai-service/judge/integration/playwright-bridge.d.ts +143 -0
  721. package/dist/ai-service/judge/integration/playwright-bridge.d.ts.map +1 -0
  722. package/dist/ai-service/judge/integration/playwright-bridge.js +209 -0
  723. package/dist/ai-service/judge/integration/playwright-bridge.js.map +1 -0
  724. package/dist/ai-service/judge/judge-eval-http.d.ts +3 -0
  725. package/dist/ai-service/judge/judge-eval-http.d.ts.map +1 -0
  726. package/dist/ai-service/judge/judge-eval-http.js +541 -0
  727. package/dist/ai-service/judge/judge-eval-http.js.map +1 -0
  728. package/dist/ai-service/judge/judge-eval-service-runner.d.ts +35 -0
  729. package/dist/ai-service/judge/judge-eval-service-runner.d.ts.map +1 -0
  730. package/dist/ai-service/judge/judge-eval-service-runner.js +129 -0
  731. package/dist/ai-service/judge/judge-eval-service-runner.js.map +1 -0
  732. package/dist/ai-service/judge/judge-executor.d.ts +65 -0
  733. package/dist/ai-service/judge/judge-executor.d.ts.map +1 -0
  734. package/dist/ai-service/judge/judge-executor.js +335 -0
  735. package/dist/ai-service/judge/judge-executor.js.map +1 -0
  736. package/dist/ai-service/judge/judge-service.d.ts +154 -0
  737. package/dist/ai-service/judge/judge-service.d.ts.map +1 -0
  738. package/dist/ai-service/judge/judge-service.js +220 -0
  739. package/dist/ai-service/judge/judge-service.js.map +1 -0
  740. package/dist/ai-service/judge/prompts/evaluation-criteria.d.ts +37 -0
  741. package/dist/ai-service/judge/prompts/evaluation-criteria.d.ts.map +1 -0
  742. package/dist/ai-service/judge/prompts/evaluation-criteria.js +283 -0
  743. package/dist/ai-service/judge/prompts/evaluation-criteria.js.map +1 -0
  744. package/dist/ai-service/judge/prompts/system-prompt.d.ts +30 -0
  745. package/dist/ai-service/judge/prompts/system-prompt.d.ts.map +1 -0
  746. package/dist/ai-service/judge/prompts/system-prompt.js +212 -0
  747. package/dist/ai-service/judge/prompts/system-prompt.js.map +1 -0
  748. package/dist/ai-service/judge/storage/csv-storage.d.ts +99 -0
  749. package/dist/ai-service/judge/storage/csv-storage.d.ts.map +1 -0
  750. package/dist/ai-service/judge/storage/csv-storage.js +274 -0
  751. package/dist/ai-service/judge/storage/csv-storage.js.map +1 -0
  752. package/dist/ai-service/judge/storage/index.d.ts +9 -0
  753. package/dist/ai-service/judge/storage/index.d.ts.map +1 -0
  754. package/dist/ai-service/judge/storage/index.js +7 -0
  755. package/dist/ai-service/judge/storage/index.js.map +1 -0
  756. package/dist/ai-service/judge/storage/interface.d.ts +51 -0
  757. package/dist/ai-service/judge/storage/interface.d.ts.map +1 -0
  758. package/dist/ai-service/judge/storage/interface.js +8 -0
  759. package/dist/ai-service/judge/storage/interface.js.map +1 -0
  760. package/dist/ai-service/judge/storage/types.d.ts +54 -0
  761. package/dist/ai-service/judge/storage/types.d.ts.map +1 -0
  762. package/dist/ai-service/judge/storage/types.js +7 -0
  763. package/dist/ai-service/judge/storage/types.js.map +1 -0
  764. package/dist/ai-service/judge/tools/index.d.ts +20 -0
  765. package/dist/ai-service/judge/tools/index.d.ts.map +1 -0
  766. package/dist/ai-service/judge/tools/index.js +27 -0
  767. package/dist/ai-service/judge/tools/index.js.map +1 -0
  768. package/dist/ai-service/judge/tools/playwright-action.d.ts +72 -0
  769. package/dist/ai-service/judge/tools/playwright-action.d.ts.map +1 -0
  770. package/dist/ai-service/judge/tools/playwright-action.js +171 -0
  771. package/dist/ai-service/judge/tools/playwright-action.js.map +1 -0
  772. package/dist/ai-service/judge/tools/submit-feedback.d.ts +34 -0
  773. package/dist/ai-service/judge/tools/submit-feedback.d.ts.map +1 -0
  774. package/dist/ai-service/judge/tools/submit-feedback.js +137 -0
  775. package/dist/ai-service/judge/tools/submit-feedback.js.map +1 -0
  776. package/dist/ai-service/judge/types.d.ts +169 -0
  777. package/dist/ai-service/judge/types.d.ts.map +1 -0
  778. package/dist/ai-service/judge/types.js +8 -0
  779. package/dist/ai-service/judge/types.js.map +1 -0
  780. package/dist/ai-service/knowledge/helpers.d.ts +17 -0
  781. package/dist/ai-service/knowledge/helpers.d.ts.map +1 -0
  782. package/dist/ai-service/knowledge/helpers.js +154 -0
  783. package/dist/ai-service/knowledge/helpers.js.map +1 -0
  784. package/dist/ai-service/knowledge/knowledge-manager.d.ts +85 -0
  785. package/dist/ai-service/knowledge/knowledge-manager.d.ts.map +1 -0
  786. package/dist/ai-service/knowledge/knowledge-manager.js +299 -0
  787. package/dist/ai-service/knowledge/knowledge-manager.js.map +1 -0
  788. package/dist/ai-service/knowledge/knowledge-metrics-emitters.d.ts +20 -0
  789. package/dist/ai-service/knowledge/knowledge-metrics-emitters.d.ts.map +1 -0
  790. package/dist/ai-service/knowledge/knowledge-metrics-emitters.js +77 -0
  791. package/dist/ai-service/knowledge/knowledge-metrics-emitters.js.map +1 -0
  792. package/dist/ai-service/knowledge/knowledge-metrics.d.ts +44 -0
  793. package/dist/ai-service/knowledge/knowledge-metrics.d.ts.map +1 -0
  794. package/dist/ai-service/knowledge/knowledge-metrics.js +217 -0
  795. package/dist/ai-service/knowledge/knowledge-metrics.js.map +1 -0
  796. package/dist/ai-service/live-edit-events/bridge.d.ts +21 -0
  797. package/dist/ai-service/live-edit-events/bridge.d.ts.map +1 -0
  798. package/dist/ai-service/live-edit-events/bridge.js +52 -0
  799. package/dist/ai-service/live-edit-events/bridge.js.map +1 -0
  800. package/dist/ai-service/live-edit-events/forwarder.d.ts +158 -0
  801. package/dist/ai-service/live-edit-events/forwarder.d.ts.map +1 -0
  802. package/dist/ai-service/live-edit-events/forwarder.js +403 -0
  803. package/dist/ai-service/live-edit-events/forwarder.js.map +1 -0
  804. package/dist/ai-service/llm/chaos-fetch.d.ts +90 -0
  805. package/dist/ai-service/llm/chaos-fetch.d.ts.map +1 -0
  806. package/dist/ai-service/llm/chaos-fetch.js +200 -0
  807. package/dist/ai-service/llm/chaos-fetch.js.map +1 -0
  808. package/dist/ai-service/llm/clark-stream-telemetry-sink.d.ts +4 -0
  809. package/dist/ai-service/llm/clark-stream-telemetry-sink.d.ts.map +1 -0
  810. package/dist/ai-service/llm/clark-stream-telemetry-sink.js +152 -0
  811. package/dist/ai-service/llm/clark-stream-telemetry-sink.js.map +1 -0
  812. package/dist/ai-service/llm/client.d.ts +315 -0
  813. package/dist/ai-service/llm/client.d.ts.map +1 -0
  814. package/dist/ai-service/llm/client.js +992 -0
  815. package/dist/ai-service/llm/client.js.map +1 -0
  816. package/dist/ai-service/llm/context-v2/adapter.d.ts +33 -0
  817. package/dist/ai-service/llm/context-v2/adapter.d.ts.map +1 -0
  818. package/dist/ai-service/llm/context-v2/adapter.js +103 -0
  819. package/dist/ai-service/llm/context-v2/adapter.js.map +1 -0
  820. package/dist/ai-service/llm/context-v2/caching.d.ts +40 -0
  821. package/dist/ai-service/llm/context-v2/caching.d.ts.map +1 -0
  822. package/dist/ai-service/llm/context-v2/caching.js +48 -0
  823. package/dist/ai-service/llm/context-v2/caching.js.map +1 -0
  824. package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts +100 -0
  825. package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts.map +1 -0
  826. package/dist/ai-service/llm/context-v2/compaction/client-side.js +298 -0
  827. package/dist/ai-service/llm/context-v2/compaction/client-side.js.map +1 -0
  828. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts +73 -0
  829. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts.map +1 -0
  830. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.js +9 -0
  831. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.js.map +1 -0
  832. package/dist/ai-service/llm/context-v2/compaction/server-side.d.ts +33 -0
  833. package/dist/ai-service/llm/context-v2/compaction/server-side.d.ts.map +1 -0
  834. package/dist/ai-service/llm/context-v2/compaction/server-side.js +137 -0
  835. package/dist/ai-service/llm/context-v2/compaction/server-side.js.map +1 -0
  836. package/dist/ai-service/llm/context-v2/compactor.d.ts +34 -0
  837. package/dist/ai-service/llm/context-v2/compactor.d.ts.map +1 -0
  838. package/dist/ai-service/llm/context-v2/compactor.js +243 -0
  839. package/dist/ai-service/llm/context-v2/compactor.js.map +1 -0
  840. package/dist/ai-service/llm/context-v2/config.d.ts +27 -0
  841. package/dist/ai-service/llm/context-v2/config.d.ts.map +1 -0
  842. package/dist/ai-service/llm/context-v2/config.js +59 -0
  843. package/dist/ai-service/llm/context-v2/config.js.map +1 -0
  844. package/dist/ai-service/llm/context-v2/context-management.d.ts +215 -0
  845. package/dist/ai-service/llm/context-v2/context-management.d.ts.map +1 -0
  846. package/dist/ai-service/llm/context-v2/context-management.js +207 -0
  847. package/dist/ai-service/llm/context-v2/context-management.js.map +1 -0
  848. package/dist/ai-service/llm/context-v2/context-metrics.d.ts +150 -0
  849. package/dist/ai-service/llm/context-v2/context-metrics.d.ts.map +1 -0
  850. package/dist/ai-service/llm/context-v2/context-metrics.js +602 -0
  851. package/dist/ai-service/llm/context-v2/context-metrics.js.map +1 -0
  852. package/dist/ai-service/llm/context-v2/context.d.ts +391 -0
  853. package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -0
  854. package/dist/ai-service/llm/context-v2/context.js +1666 -0
  855. package/dist/ai-service/llm/context-v2/context.js.map +1 -0
  856. package/dist/ai-service/llm/context-v2/conversation-context.d.ts +150 -0
  857. package/dist/ai-service/llm/context-v2/conversation-context.d.ts.map +1 -0
  858. package/dist/ai-service/llm/context-v2/conversation-context.js +10 -0
  859. package/dist/ai-service/llm/context-v2/conversation-context.js.map +1 -0
  860. package/dist/ai-service/llm/context-v2/index.d.ts +13 -0
  861. package/dist/ai-service/llm/context-v2/index.d.ts.map +1 -0
  862. package/dist/ai-service/llm/context-v2/index.js +13 -0
  863. package/dist/ai-service/llm/context-v2/index.js.map +1 -0
  864. package/dist/ai-service/llm/context-v2/manager.d.ts +188 -0
  865. package/dist/ai-service/llm/context-v2/manager.d.ts.map +1 -0
  866. package/dist/ai-service/llm/context-v2/manager.js +629 -0
  867. package/dist/ai-service/llm/context-v2/manager.js.map +1 -0
  868. package/dist/ai-service/llm/context-v2/migrations/index.d.ts +7 -0
  869. package/dist/ai-service/llm/context-v2/migrations/index.d.ts.map +1 -0
  870. package/dist/ai-service/llm/context-v2/migrations/index.js +7 -0
  871. package/dist/ai-service/llm/context-v2/migrations/index.js.map +1 -0
  872. package/dist/ai-service/llm/context-v2/migrations/registry.d.ts +19 -0
  873. package/dist/ai-service/llm/context-v2/migrations/registry.d.ts.map +1 -0
  874. package/dist/ai-service/llm/context-v2/migrations/registry.js +32 -0
  875. package/dist/ai-service/llm/context-v2/migrations/registry.js.map +1 -0
  876. package/dist/ai-service/llm/context-v2/migrations/runner.d.ts +3 -0
  877. package/dist/ai-service/llm/context-v2/migrations/runner.d.ts.map +1 -0
  878. package/dist/ai-service/llm/context-v2/migrations/runner.js +61 -0
  879. package/dist/ai-service/llm/context-v2/migrations/runner.js.map +1 -0
  880. package/dist/ai-service/llm/context-v2/migrations/types.d.ts +16 -0
  881. package/dist/ai-service/llm/context-v2/migrations/types.d.ts.map +1 -0
  882. package/dist/ai-service/llm/context-v2/migrations/types.js +26 -0
  883. package/dist/ai-service/llm/context-v2/migrations/types.js.map +1 -0
  884. package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.d.ts +25 -0
  885. package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.d.ts.map +1 -0
  886. package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.js +75 -0
  887. package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.js.map +1 -0
  888. package/dist/ai-service/llm/context-v2/operation-queue.d.ts +9 -0
  889. package/dist/ai-service/llm/context-v2/operation-queue.d.ts.map +1 -0
  890. package/dist/ai-service/llm/context-v2/operation-queue.js +13 -0
  891. package/dist/ai-service/llm/context-v2/operation-queue.js.map +1 -0
  892. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.d.ts +20 -0
  893. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.d.ts.map +1 -0
  894. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js +360 -0
  895. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js.map +1 -0
  896. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.d.ts +68 -0
  897. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.d.ts.map +1 -0
  898. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js +377 -0
  899. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js.map +1 -0
  900. package/dist/ai-service/llm/context-v2/prompts/compaction.d.ts +11 -0
  901. package/dist/ai-service/llm/context-v2/prompts/compaction.d.ts.map +1 -0
  902. package/dist/ai-service/llm/context-v2/prompts/compaction.js +63 -0
  903. package/dist/ai-service/llm/context-v2/prompts/compaction.js.map +1 -0
  904. package/dist/ai-service/llm/context-v2/session-capture.d.ts +18 -0
  905. package/dist/ai-service/llm/context-v2/session-capture.d.ts.map +1 -0
  906. package/dist/ai-service/llm/context-v2/session-capture.js +64 -0
  907. package/dist/ai-service/llm/context-v2/session-capture.js.map +1 -0
  908. package/dist/ai-service/llm/context-v2/storage/event-store.d.ts +83 -0
  909. package/dist/ai-service/llm/context-v2/storage/event-store.d.ts.map +1 -0
  910. package/dist/ai-service/llm/context-v2/storage/event-store.js +10 -0
  911. package/dist/ai-service/llm/context-v2/storage/event-store.js.map +1 -0
  912. package/dist/ai-service/llm/context-v2/storage/event-types.d.ts +59 -0
  913. package/dist/ai-service/llm/context-v2/storage/event-types.d.ts.map +1 -0
  914. package/dist/ai-service/llm/context-v2/storage/event-types.js +16 -0
  915. package/dist/ai-service/llm/context-v2/storage/event-types.js.map +1 -0
  916. package/dist/ai-service/llm/context-v2/storage/index.d.ts +14 -0
  917. package/dist/ai-service/llm/context-v2/storage/index.d.ts.map +1 -0
  918. package/dist/ai-service/llm/context-v2/storage/index.js +2 -0
  919. package/dist/ai-service/llm/context-v2/storage/index.js.map +1 -0
  920. package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.d.ts +108 -0
  921. package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.d.ts.map +1 -0
  922. package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.js +267 -0
  923. package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.js.map +1 -0
  924. package/dist/ai-service/llm/context-v2/storage/legacy-context-adoption.d.ts +46 -0
  925. package/dist/ai-service/llm/context-v2/storage/legacy-context-adoption.d.ts.map +1 -0
  926. package/dist/ai-service/llm/context-v2/storage/legacy-context-adoption.js +240 -0
  927. package/dist/ai-service/llm/context-v2/storage/legacy-context-adoption.js.map +1 -0
  928. package/dist/ai-service/llm/context-v2/storage/local.d.ts +25 -0
  929. package/dist/ai-service/llm/context-v2/storage/local.d.ts.map +1 -0
  930. package/dist/ai-service/llm/context-v2/storage/local.js +124 -0
  931. package/dist/ai-service/llm/context-v2/storage/local.js.map +1 -0
  932. package/dist/ai-service/llm/context-v2/storage/migration.d.ts +49 -0
  933. package/dist/ai-service/llm/context-v2/storage/migration.d.ts.map +1 -0
  934. package/dist/ai-service/llm/context-v2/storage/migration.js +126 -0
  935. package/dist/ai-service/llm/context-v2/storage/migration.js.map +1 -0
  936. package/dist/ai-service/llm/context-v2/storage/types.d.ts +2 -0
  937. package/dist/ai-service/llm/context-v2/storage/types.d.ts.map +1 -0
  938. package/dist/ai-service/llm/context-v2/storage/types.js +2 -0
  939. package/dist/ai-service/llm/context-v2/storage/types.js.map +1 -0
  940. package/dist/ai-service/llm/context-v2/token-tracker.d.ts +88 -0
  941. package/dist/ai-service/llm/context-v2/token-tracker.d.ts.map +1 -0
  942. package/dist/ai-service/llm/context-v2/token-tracker.js +193 -0
  943. package/dist/ai-service/llm/context-v2/token-tracker.js.map +1 -0
  944. package/dist/ai-service/llm/context-v2/truncation-fallback.d.ts +10 -0
  945. package/dist/ai-service/llm/context-v2/truncation-fallback.d.ts.map +1 -0
  946. package/dist/ai-service/llm/context-v2/truncation-fallback.js +124 -0
  947. package/dist/ai-service/llm/context-v2/truncation-fallback.js.map +1 -0
  948. package/dist/ai-service/llm/context-v2/turns.d.ts +24 -0
  949. package/dist/ai-service/llm/context-v2/turns.d.ts.map +1 -0
  950. package/dist/ai-service/llm/context-v2/turns.js +85 -0
  951. package/dist/ai-service/llm/context-v2/turns.js.map +1 -0
  952. package/dist/ai-service/llm/context-v2/types-v1.d.ts +36 -0
  953. package/dist/ai-service/llm/context-v2/types-v1.d.ts.map +1 -0
  954. package/dist/ai-service/llm/context-v2/types-v1.js +3 -0
  955. package/dist/ai-service/llm/context-v2/types-v1.js.map +1 -0
  956. package/dist/ai-service/llm/context-v2/types.d.ts +238 -0
  957. package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -0
  958. package/dist/ai-service/llm/context-v2/types.js +609 -0
  959. package/dist/ai-service/llm/context-v2/types.js.map +1 -0
  960. package/dist/ai-service/llm/context-v2/uniquify-filenames.d.ts +15 -0
  961. package/dist/ai-service/llm/context-v2/uniquify-filenames.d.ts.map +1 -0
  962. package/dist/ai-service/llm/context-v2/uniquify-filenames.js +194 -0
  963. package/dist/ai-service/llm/context-v2/uniquify-filenames.js.map +1 -0
  964. package/dist/ai-service/llm/context-v2/utils/get-loaded-context.d.ts +9 -0
  965. package/dist/ai-service/llm/context-v2/utils/get-loaded-context.d.ts.map +1 -0
  966. package/dist/ai-service/llm/context-v2/utils/get-loaded-context.js +6 -0
  967. package/dist/ai-service/llm/context-v2/utils/get-loaded-context.js.map +1 -0
  968. package/dist/ai-service/llm/context-v2/utils/index.d.ts +2 -0
  969. package/dist/ai-service/llm/context-v2/utils/index.d.ts.map +1 -0
  970. package/dist/ai-service/llm/context-v2/utils/index.js +2 -0
  971. package/dist/ai-service/llm/context-v2/utils/index.js.map +1 -0
  972. package/dist/ai-service/llm/context-v2/well-formed-text.d.ts +24 -0
  973. package/dist/ai-service/llm/context-v2/well-formed-text.d.ts.map +1 -0
  974. package/dist/ai-service/llm/context-v2/well-formed-text.js +73 -0
  975. package/dist/ai-service/llm/context-v2/well-formed-text.js.map +1 -0
  976. package/dist/ai-service/llm/error.d.ts +153 -0
  977. package/dist/ai-service/llm/error.d.ts.map +1 -0
  978. package/dist/ai-service/llm/error.js +539 -0
  979. package/dist/ai-service/llm/error.js.map +1 -0
  980. package/dist/ai-service/llm/impl/clark.d.ts +11 -0
  981. package/dist/ai-service/llm/impl/clark.d.ts.map +1 -0
  982. package/dist/ai-service/llm/impl/clark.js +22 -0
  983. package/dist/ai-service/llm/impl/clark.js.map +1 -0
  984. package/dist/ai-service/llm/interaction/adapters/vercel.d.ts +67 -0
  985. package/dist/ai-service/llm/interaction/adapters/vercel.d.ts.map +1 -0
  986. package/dist/ai-service/llm/interaction/adapters/vercel.js +190 -0
  987. package/dist/ai-service/llm/interaction/adapters/vercel.js.map +1 -0
  988. package/dist/ai-service/llm/interaction/index.d.ts +4 -0
  989. package/dist/ai-service/llm/interaction/index.d.ts.map +1 -0
  990. package/dist/ai-service/llm/interaction/index.js +5 -0
  991. package/dist/ai-service/llm/interaction/index.js.map +1 -0
  992. package/dist/ai-service/llm/interaction/provider.d.ts +189 -0
  993. package/dist/ai-service/llm/interaction/provider.d.ts.map +1 -0
  994. package/dist/ai-service/llm/interaction/provider.js +15 -0
  995. package/dist/ai-service/llm/interaction/provider.js.map +1 -0
  996. package/dist/ai-service/llm/interaction/stream-lifecycle.d.ts +48 -0
  997. package/dist/ai-service/llm/interaction/stream-lifecycle.d.ts.map +1 -0
  998. package/dist/ai-service/llm/interaction/stream-lifecycle.js +147 -0
  999. package/dist/ai-service/llm/interaction/stream-lifecycle.js.map +1 -0
  1000. package/dist/ai-service/llm/provider.d.ts +10 -0
  1001. package/dist/ai-service/llm/provider.d.ts.map +1 -0
  1002. package/dist/ai-service/llm/provider.js +370 -0
  1003. package/dist/ai-service/llm/provider.js.map +1 -0
  1004. package/dist/ai-service/llm/stream/compaction-text-block.d.ts +15 -0
  1005. package/dist/ai-service/llm/stream/compaction-text-block.d.ts.map +1 -0
  1006. package/dist/ai-service/llm/stream/compaction-text-block.js +29 -0
  1007. package/dist/ai-service/llm/stream/compaction-text-block.js.map +1 -0
  1008. package/dist/ai-service/llm/stream/config.d.ts +151 -0
  1009. package/dist/ai-service/llm/stream/config.d.ts.map +1 -0
  1010. package/dist/ai-service/llm/stream/config.js +108 -0
  1011. package/dist/ai-service/llm/stream/config.js.map +1 -0
  1012. package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts +48 -0
  1013. package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts.map +1 -0
  1014. package/dist/ai-service/llm/stream/empty-tool-call-tracker.js +123 -0
  1015. package/dist/ai-service/llm/stream/empty-tool-call-tracker.js.map +1 -0
  1016. package/dist/ai-service/llm/stream/errors.d.ts +62 -0
  1017. package/dist/ai-service/llm/stream/errors.d.ts.map +1 -0
  1018. package/dist/ai-service/llm/stream/errors.js +139 -0
  1019. package/dist/ai-service/llm/stream/errors.js.map +1 -0
  1020. package/dist/ai-service/llm/stream/event-bus.d.ts +75 -0
  1021. package/dist/ai-service/llm/stream/event-bus.d.ts.map +1 -0
  1022. package/dist/ai-service/llm/stream/event-bus.js +51 -0
  1023. package/dist/ai-service/llm/stream/event-bus.js.map +1 -0
  1024. package/dist/ai-service/llm/stream/idle-monitor.d.ts +167 -0
  1025. package/dist/ai-service/llm/stream/idle-monitor.d.ts.map +1 -0
  1026. package/dist/ai-service/llm/stream/idle-monitor.js +423 -0
  1027. package/dist/ai-service/llm/stream/idle-monitor.js.map +1 -0
  1028. package/dist/ai-service/llm/stream/index.d.ts +51 -0
  1029. package/dist/ai-service/llm/stream/index.d.ts.map +1 -0
  1030. package/dist/ai-service/llm/stream/index.js +48 -0
  1031. package/dist/ai-service/llm/stream/index.js.map +1 -0
  1032. package/dist/ai-service/llm/stream/managed-stream.d.ts +32 -0
  1033. package/dist/ai-service/llm/stream/managed-stream.d.ts.map +1 -0
  1034. package/dist/ai-service/llm/stream/managed-stream.js +219 -0
  1035. package/dist/ai-service/llm/stream/managed-stream.js.map +1 -0
  1036. package/dist/ai-service/llm/stream/observer.d.ts +34 -0
  1037. package/dist/ai-service/llm/stream/observer.d.ts.map +1 -0
  1038. package/dist/ai-service/llm/stream/observer.js +2 -0
  1039. package/dist/ai-service/llm/stream/observer.js.map +1 -0
  1040. package/dist/ai-service/llm/stream/observers/context.d.ts +63 -0
  1041. package/dist/ai-service/llm/stream/observers/context.d.ts.map +1 -0
  1042. package/dist/ai-service/llm/stream/observers/context.js +235 -0
  1043. package/dist/ai-service/llm/stream/observers/context.js.map +1 -0
  1044. package/dist/ai-service/llm/stream/observers/index.d.ts +8 -0
  1045. package/dist/ai-service/llm/stream/observers/index.d.ts.map +1 -0
  1046. package/dist/ai-service/llm/stream/observers/index.js +8 -0
  1047. package/dist/ai-service/llm/stream/observers/index.js.map +1 -0
  1048. package/dist/ai-service/llm/stream/observers/llmobs.d.ts +94 -0
  1049. package/dist/ai-service/llm/stream/observers/llmobs.d.ts.map +1 -0
  1050. package/dist/ai-service/llm/stream/observers/llmobs.js +796 -0
  1051. package/dist/ai-service/llm/stream/observers/llmobs.js.map +1 -0
  1052. package/dist/ai-service/llm/stream/observers/logging.d.ts +74 -0
  1053. package/dist/ai-service/llm/stream/observers/logging.d.ts.map +1 -0
  1054. package/dist/ai-service/llm/stream/observers/logging.js +509 -0
  1055. package/dist/ai-service/llm/stream/observers/logging.js.map +1 -0
  1056. package/dist/ai-service/llm/stream/observers/retry-notification.d.ts +21 -0
  1057. package/dist/ai-service/llm/stream/observers/retry-notification.d.ts.map +1 -0
  1058. package/dist/ai-service/llm/stream/observers/retry-notification.js +71 -0
  1059. package/dist/ai-service/llm/stream/observers/retry-notification.js.map +1 -0
  1060. package/dist/ai-service/llm/stream/observers/step-token-usage.d.ts +15 -0
  1061. package/dist/ai-service/llm/stream/observers/step-token-usage.d.ts.map +1 -0
  1062. package/dist/ai-service/llm/stream/observers/step-token-usage.js +88 -0
  1063. package/dist/ai-service/llm/stream/observers/step-token-usage.js.map +1 -0
  1064. package/dist/ai-service/llm/stream/observers/workflow-usage.d.ts +19 -0
  1065. package/dist/ai-service/llm/stream/observers/workflow-usage.d.ts.map +1 -0
  1066. package/dist/ai-service/llm/stream/observers/workflow-usage.js +112 -0
  1067. package/dist/ai-service/llm/stream/observers/workflow-usage.js.map +1 -0
  1068. package/dist/ai-service/llm/stream/orchestrator.d.ts +133 -0
  1069. package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -0
  1070. package/dist/ai-service/llm/stream/orchestrator.js +1297 -0
  1071. package/dist/ai-service/llm/stream/orchestrator.js.map +1 -0
  1072. package/dist/ai-service/llm/stream/retry-engine.d.ts +89 -0
  1073. package/dist/ai-service/llm/stream/retry-engine.d.ts.map +1 -0
  1074. package/dist/ai-service/llm/stream/retry-engine.js +367 -0
  1075. package/dist/ai-service/llm/stream/retry-engine.js.map +1 -0
  1076. package/dist/ai-service/llm/stream/session.d.ts +94 -0
  1077. package/dist/ai-service/llm/stream/session.d.ts.map +1 -0
  1078. package/dist/ai-service/llm/stream/session.js +173 -0
  1079. package/dist/ai-service/llm/stream/session.js.map +1 -0
  1080. package/dist/ai-service/llm/stream/structured-output-chunk.d.ts +16 -0
  1081. package/dist/ai-service/llm/stream/structured-output-chunk.d.ts.map +1 -0
  1082. package/dist/ai-service/llm/stream/structured-output-chunk.js +26 -0
  1083. package/dist/ai-service/llm/stream/structured-output-chunk.js.map +1 -0
  1084. package/dist/ai-service/llm/stream/terminal-reason.d.ts +6 -0
  1085. package/dist/ai-service/llm/stream/terminal-reason.d.ts.map +1 -0
  1086. package/dist/ai-service/llm/stream/terminal-reason.js +83 -0
  1087. package/dist/ai-service/llm/stream/terminal-reason.js.map +1 -0
  1088. package/dist/ai-service/llm/stream/tests/helpers/mock-provider.d.ts +98 -0
  1089. package/dist/ai-service/llm/stream/tests/helpers/mock-provider.d.ts.map +1 -0
  1090. package/dist/ai-service/llm/stream/tests/helpers/mock-provider.js +521 -0
  1091. package/dist/ai-service/llm/stream/tests/helpers/mock-provider.js.map +1 -0
  1092. package/dist/ai-service/llm/stream/types.d.ts +16 -0
  1093. package/dist/ai-service/llm/stream/types.d.ts.map +1 -0
  1094. package/dist/ai-service/llm/stream/types.js +2 -0
  1095. package/dist/ai-service/llm/stream/types.js.map +1 -0
  1096. package/dist/ai-service/llm/stream/wait-state-tracker.d.ts +55 -0
  1097. package/dist/ai-service/llm/stream/wait-state-tracker.d.ts.map +1 -0
  1098. package/dist/ai-service/llm/stream/wait-state-tracker.js +109 -0
  1099. package/dist/ai-service/llm/stream/wait-state-tracker.js.map +1 -0
  1100. package/dist/ai-service/llm/tool-context-integrity.d.ts +25 -0
  1101. package/dist/ai-service/llm/tool-context-integrity.d.ts.map +1 -0
  1102. package/dist/ai-service/llm/tool-context-integrity.js +141 -0
  1103. package/dist/ai-service/llm/tool-context-integrity.js.map +1 -0
  1104. package/dist/ai-service/llm/types.d.ts +44 -0
  1105. package/dist/ai-service/llm/types.d.ts.map +1 -0
  1106. package/dist/ai-service/llm/types.js +2 -0
  1107. package/dist/ai-service/llm/types.js.map +1 -0
  1108. package/dist/ai-service/llm/workflow-metrics.d.ts +14 -0
  1109. package/dist/ai-service/llm/workflow-metrics.d.ts.map +1 -0
  1110. package/dist/ai-service/llm/workflow-metrics.js +19 -0
  1111. package/dist/ai-service/llm/workflow-metrics.js.map +1 -0
  1112. package/dist/ai-service/llmobs/constants.d.ts +5 -0
  1113. package/dist/ai-service/llmobs/constants.d.ts.map +1 -0
  1114. package/dist/ai-service/llmobs/constants.js +5 -0
  1115. package/dist/ai-service/llmobs/constants.js.map +1 -0
  1116. package/dist/ai-service/llmobs/context-registry.d.ts +62 -0
  1117. package/dist/ai-service/llmobs/context-registry.d.ts.map +1 -0
  1118. package/dist/ai-service/llmobs/context-registry.js +115 -0
  1119. package/dist/ai-service/llmobs/context-registry.js.map +1 -0
  1120. package/dist/ai-service/llmobs/helpers.d.ts +5 -0
  1121. package/dist/ai-service/llmobs/helpers.d.ts.map +1 -0
  1122. package/dist/ai-service/llmobs/helpers.js +31 -0
  1123. package/dist/ai-service/llmobs/helpers.js.map +1 -0
  1124. package/dist/ai-service/llmobs/index.d.ts +8 -0
  1125. package/dist/ai-service/llmobs/index.d.ts.map +1 -0
  1126. package/dist/ai-service/llmobs/index.js +7 -0
  1127. package/dist/ai-service/llmobs/index.js.map +1 -0
  1128. package/dist/ai-service/llmobs/otel-exporter.d.ts +178 -0
  1129. package/dist/ai-service/llmobs/otel-exporter.d.ts.map +1 -0
  1130. package/dist/ai-service/llmobs/otel-exporter.js +660 -0
  1131. package/dist/ai-service/llmobs/otel-exporter.js.map +1 -0
  1132. package/dist/ai-service/llmobs/tracer.d.ts +130 -0
  1133. package/dist/ai-service/llmobs/tracer.d.ts.map +1 -0
  1134. package/dist/ai-service/llmobs/tracer.js +532 -0
  1135. package/dist/ai-service/llmobs/tracer.js.map +1 -0
  1136. package/dist/ai-service/llmobs/types.d.ts +71 -0
  1137. package/dist/ai-service/llmobs/types.d.ts.map +1 -0
  1138. package/dist/ai-service/llmobs/types.js +2 -0
  1139. package/dist/ai-service/llmobs/types.js.map +1 -0
  1140. package/dist/ai-service/llmobs/utils.d.ts +15 -0
  1141. package/dist/ai-service/llmobs/utils.d.ts.map +1 -0
  1142. package/dist/ai-service/llmobs/utils.js +82 -0
  1143. package/dist/ai-service/llmobs/utils.js.map +1 -0
  1144. package/dist/ai-service/managed-native-db-availability.d.ts +62 -0
  1145. package/dist/ai-service/managed-native-db-availability.d.ts.map +1 -0
  1146. package/dist/ai-service/managed-native-db-availability.js +37 -0
  1147. package/dist/ai-service/managed-native-db-availability.js.map +1 -0
  1148. package/dist/ai-service/mcp/adapter/index.d.ts +8 -0
  1149. package/dist/ai-service/mcp/adapter/index.d.ts.map +1 -0
  1150. package/dist/ai-service/mcp/adapter/index.js +10 -0
  1151. package/dist/ai-service/mcp/adapter/index.js.map +1 -0
  1152. package/dist/ai-service/mcp/adapter/json-schema-to-zod.d.ts +44 -0
  1153. package/dist/ai-service/mcp/adapter/json-schema-to-zod.d.ts.map +1 -0
  1154. package/dist/ai-service/mcp/adapter/json-schema-to-zod.js +231 -0
  1155. package/dist/ai-service/mcp/adapter/json-schema-to-zod.js.map +1 -0
  1156. package/dist/ai-service/mcp/adapter/mcp-tool-adapter.d.ts +126 -0
  1157. package/dist/ai-service/mcp/adapter/mcp-tool-adapter.d.ts.map +1 -0
  1158. package/dist/ai-service/mcp/adapter/mcp-tool-adapter.js +365 -0
  1159. package/dist/ai-service/mcp/adapter/mcp-tool-adapter.js.map +1 -0
  1160. package/dist/ai-service/mcp/embedded-playwright-mcp-server.d.ts +85 -0
  1161. package/dist/ai-service/mcp/embedded-playwright-mcp-server.d.ts.map +1 -0
  1162. package/dist/ai-service/mcp/embedded-playwright-mcp-server.js +1626 -0
  1163. package/dist/ai-service/mcp/embedded-playwright-mcp-server.js.map +1 -0
  1164. package/dist/ai-service/mcp/index.d.ts +11 -0
  1165. package/dist/ai-service/mcp/index.d.ts.map +1 -0
  1166. package/dist/ai-service/mcp/index.js +11 -0
  1167. package/dist/ai-service/mcp/index.js.map +1 -0
  1168. package/dist/ai-service/mcp/playwright-server.d.ts +153 -0
  1169. package/dist/ai-service/mcp/playwright-server.d.ts.map +1 -0
  1170. package/dist/ai-service/mcp/playwright-server.js +174 -0
  1171. package/dist/ai-service/mcp/playwright-server.js.map +1 -0
  1172. package/dist/ai-service/mcp/types.d.ts +101 -0
  1173. package/dist/ai-service/mcp/types.d.ts.map +1 -0
  1174. package/dist/ai-service/mcp/types.js +7 -0
  1175. package/dist/ai-service/mcp/types.js.map +1 -0
  1176. package/dist/ai-service/migration-auto-dispatch-readiness.d.ts +19 -0
  1177. package/dist/ai-service/migration-auto-dispatch-readiness.d.ts.map +1 -0
  1178. package/dist/ai-service/migration-auto-dispatch-readiness.js +17 -0
  1179. package/dist/ai-service/migration-auto-dispatch-readiness.js.map +1 -0
  1180. package/dist/ai-service/migration-autodispatch-metrics.d.ts +3 -0
  1181. package/dist/ai-service/migration-autodispatch-metrics.d.ts.map +1 -0
  1182. package/dist/ai-service/migration-autodispatch-metrics.js +52 -0
  1183. package/dist/ai-service/migration-autodispatch-metrics.js.map +1 -0
  1184. package/dist/ai-service/migration-llm-config.d.ts +12 -0
  1185. package/dist/ai-service/migration-llm-config.d.ts.map +1 -0
  1186. package/dist/ai-service/migration-llm-config.js +132 -0
  1187. package/dist/ai-service/migration-llm-config.js.map +1 -0
  1188. package/dist/ai-service/migration-prompt-gating.d.ts +21 -0
  1189. package/dist/ai-service/migration-prompt-gating.d.ts.map +1 -0
  1190. package/dist/ai-service/migration-prompt-gating.js +27 -0
  1191. package/dist/ai-service/migration-prompt-gating.js.map +1 -0
  1192. package/dist/ai-service/migration-session-active.d.ts +14 -0
  1193. package/dist/ai-service/migration-session-active.d.ts.map +1 -0
  1194. package/dist/ai-service/migration-session-active.js +29 -0
  1195. package/dist/ai-service/migration-session-active.js.map +1 -0
  1196. package/dist/ai-service/migration-turns-log.d.ts +36 -0
  1197. package/dist/ai-service/migration-turns-log.d.ts.map +1 -0
  1198. package/dist/ai-service/migration-turns-log.js +88 -0
  1199. package/dist/ai-service/migration-turns-log.js.map +1 -0
  1200. package/dist/ai-service/policy-agent-metrics.d.ts +29 -0
  1201. package/dist/ai-service/policy-agent-metrics.d.ts.map +1 -0
  1202. package/dist/ai-service/policy-agent-metrics.js +141 -0
  1203. package/dist/ai-service/policy-agent-metrics.js.map +1 -0
  1204. package/dist/ai-service/policy-gate-error.d.ts +3 -0
  1205. package/dist/ai-service/policy-gate-error.d.ts.map +1 -0
  1206. package/dist/ai-service/policy-gate-error.js +33 -0
  1207. package/dist/ai-service/policy-gate-error.js.map +1 -0
  1208. package/dist/ai-service/policy-gate-step.d.ts +17 -0
  1209. package/dist/ai-service/policy-gate-step.d.ts.map +1 -0
  1210. package/dist/ai-service/policy-gate-step.js +52 -0
  1211. package/dist/ai-service/policy-gate-step.js.map +1 -0
  1212. package/dist/ai-service/profiler/clark-profiler.d.ts +86 -0
  1213. package/dist/ai-service/profiler/clark-profiler.d.ts.map +1 -0
  1214. package/dist/ai-service/profiler/clark-profiler.js +209 -0
  1215. package/dist/ai-service/profiler/clark-profiler.js.map +1 -0
  1216. package/dist/ai-service/profiler/index.d.ts +4 -0
  1217. package/dist/ai-service/profiler/index.d.ts.map +1 -0
  1218. package/dist/ai-service/profiler/index.js +4 -0
  1219. package/dist/ai-service/profiler/index.js.map +1 -0
  1220. package/dist/ai-service/profiler/perfetto-profiler.d.ts +116 -0
  1221. package/dist/ai-service/profiler/perfetto-profiler.d.ts.map +1 -0
  1222. package/dist/ai-service/profiler/perfetto-profiler.js +240 -0
  1223. package/dist/ai-service/profiler/perfetto-profiler.js.map +1 -0
  1224. package/dist/ai-service/profiler/tool-profiler.d.ts +33 -0
  1225. package/dist/ai-service/profiler/tool-profiler.d.ts.map +1 -0
  1226. package/dist/ai-service/profiler/tool-profiler.js +157 -0
  1227. package/dist/ai-service/profiler/tool-profiler.js.map +1 -0
  1228. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.d.ts +27 -0
  1229. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.d.ts.map +1 -0
  1230. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.js +97 -0
  1231. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.js.map +1 -0
  1232. package/dist/ai-service/prompt-builder-service/types.d.ts +3 -0
  1233. package/dist/ai-service/prompt-builder-service/types.d.ts.map +1 -0
  1234. package/dist/ai-service/prompt-builder-service/types.js +6 -0
  1235. package/dist/ai-service/prompt-builder-service/types.js.map +1 -0
  1236. package/dist/ai-service/prompts/summarize-api-usage.d.ts +18 -0
  1237. package/dist/ai-service/prompts/summarize-api-usage.d.ts.map +1 -0
  1238. package/dist/ai-service/prompts/summarize-api-usage.js +30 -0
  1239. package/dist/ai-service/prompts/summarize-api-usage.js.map +1 -0
  1240. package/dist/ai-service/quota-client.d.ts +31 -0
  1241. package/dist/ai-service/quota-client.d.ts.map +1 -0
  1242. package/dist/ai-service/quota-client.js +72 -0
  1243. package/dist/ai-service/quota-client.js.map +1 -0
  1244. package/dist/ai-service/recording/block-traversal.d.ts +15 -0
  1245. package/dist/ai-service/recording/block-traversal.d.ts.map +1 -0
  1246. package/dist/ai-service/recording/block-traversal.js +104 -0
  1247. package/dist/ai-service/recording/block-traversal.js.map +1 -0
  1248. package/dist/ai-service/recording/index.d.ts +26 -0
  1249. package/dist/ai-service/recording/index.d.ts.map +1 -0
  1250. package/dist/ai-service/recording/index.js +29 -0
  1251. package/dist/ai-service/recording/index.js.map +1 -0
  1252. package/dist/ai-service/recording/recorders/llm-recorder.d.ts +35 -0
  1253. package/dist/ai-service/recording/recorders/llm-recorder.d.ts.map +1 -0
  1254. package/dist/ai-service/recording/recorders/llm-recorder.js +221 -0
  1255. package/dist/ai-service/recording/recorders/llm-recorder.js.map +1 -0
  1256. package/dist/ai-service/recording/recorders/socket-recorder.d.ts +38 -0
  1257. package/dist/ai-service/recording/recorders/socket-recorder.d.ts.map +1 -0
  1258. package/dist/ai-service/recording/recorders/socket-recorder.js +44 -0
  1259. package/dist/ai-service/recording/recorders/socket-recorder.js.map +1 -0
  1260. package/dist/ai-service/recording/recorders/tool-recorder.d.ts +25 -0
  1261. package/dist/ai-service/recording/recorders/tool-recorder.d.ts.map +1 -0
  1262. package/dist/ai-service/recording/recorders/tool-recorder.js +58 -0
  1263. package/dist/ai-service/recording/recorders/tool-recorder.js.map +1 -0
  1264. package/dist/ai-service/recording/recording-manager.d.ts +105 -0
  1265. package/dist/ai-service/recording/recording-manager.d.ts.map +1 -0
  1266. package/dist/ai-service/recording/recording-manager.js +308 -0
  1267. package/dist/ai-service/recording/recording-manager.js.map +1 -0
  1268. package/dist/ai-service/recording/snapshot-manager.d.ts +195 -0
  1269. package/dist/ai-service/recording/snapshot-manager.d.ts.map +1 -0
  1270. package/dist/ai-service/recording/snapshot-manager.js +708 -0
  1271. package/dist/ai-service/recording/snapshot-manager.js.map +1 -0
  1272. package/dist/ai-service/recording/storage/session-recording-storage.d.ts +148 -0
  1273. package/dist/ai-service/recording/storage/session-recording-storage.d.ts.map +1 -0
  1274. package/dist/ai-service/recording/storage/session-recording-storage.js +399 -0
  1275. package/dist/ai-service/recording/storage/session-recording-storage.js.map +1 -0
  1276. package/dist/ai-service/recording/types.d.ts +140 -0
  1277. package/dist/ai-service/recording/types.d.ts.map +1 -0
  1278. package/dist/ai-service/recording/types.js +8 -0
  1279. package/dist/ai-service/recording/types.js.map +1 -0
  1280. package/dist/ai-service/request-deduplicator.d.ts +35 -0
  1281. package/dist/ai-service/request-deduplicator.d.ts.map +1 -0
  1282. package/dist/ai-service/request-deduplicator.js +53 -0
  1283. package/dist/ai-service/request-deduplicator.js.map +1 -0
  1284. package/dist/ai-service/resolve-generation-state-for-ui.d.ts +9 -0
  1285. package/dist/ai-service/resolve-generation-state-for-ui.d.ts.map +1 -0
  1286. package/dist/ai-service/resolve-generation-state-for-ui.js +25 -0
  1287. package/dist/ai-service/resolve-generation-state-for-ui.js.map +1 -0
  1288. package/dist/ai-service/sdk-api-templates.d.ts +2 -0
  1289. package/dist/ai-service/sdk-api-templates.d.ts.map +1 -0
  1290. package/dist/ai-service/sdk-api-templates.js +2 -0
  1291. package/dist/ai-service/sdk-api-templates.js.map +1 -0
  1292. package/dist/ai-service/security/index.d.ts +9 -0
  1293. package/dist/ai-service/security/index.d.ts.map +1 -0
  1294. package/dist/ai-service/security/index.js +9 -0
  1295. package/dist/ai-service/security/index.js.map +1 -0
  1296. package/dist/ai-service/security/safety-classifier.d.ts +83 -0
  1297. package/dist/ai-service/security/safety-classifier.d.ts.map +1 -0
  1298. package/dist/ai-service/security/safety-classifier.js +189 -0
  1299. package/dist/ai-service/security/safety-classifier.js.map +1 -0
  1300. package/dist/ai-service/security/secret-scanner-service.d.ts +43 -0
  1301. package/dist/ai-service/security/secret-scanner-service.d.ts.map +1 -0
  1302. package/dist/ai-service/security/secret-scanner-service.js +422 -0
  1303. package/dist/ai-service/security/secret-scanner-service.js.map +1 -0
  1304. package/dist/ai-service/security/secret-scanner.d.ts +161 -0
  1305. package/dist/ai-service/security/secret-scanner.d.ts.map +1 -0
  1306. package/dist/ai-service/security/secret-scanner.js +459 -0
  1307. package/dist/ai-service/security/secret-scanner.js.map +1 -0
  1308. package/dist/ai-service/security/vulnerability-triage.d.ts +90 -0
  1309. package/dist/ai-service/security/vulnerability-triage.d.ts.map +1 -0
  1310. package/dist/ai-service/security/vulnerability-triage.js +113 -0
  1311. package/dist/ai-service/security/vulnerability-triage.js.map +1 -0
  1312. package/dist/ai-service/skills/index.d.ts +38 -0
  1313. package/dist/ai-service/skills/index.d.ts.map +1 -0
  1314. package/dist/ai-service/skills/index.js +104 -0
  1315. package/dist/ai-service/skills/index.js.map +1 -0
  1316. package/dist/ai-service/skills/system/_registry.generated.d.ts +6 -0
  1317. package/dist/ai-service/skills/system/_registry.generated.d.ts.map +1 -0
  1318. package/dist/ai-service/skills/system/_registry.generated.js +43 -0
  1319. package/dist/ai-service/skills/system/_registry.generated.js.map +1 -0
  1320. package/dist/ai-service/skills/system/common-import-issues/skill.generated.d.ts +2 -0
  1321. package/dist/ai-service/skills/system/common-import-issues/skill.generated.d.ts.map +1 -0
  1322. package/dist/ai-service/skills/system/common-import-issues/skill.generated.js +93 -0
  1323. package/dist/ai-service/skills/system/common-import-issues/skill.generated.js.map +1 -0
  1324. package/dist/ai-service/skills/system/materialized.d.ts +7 -0
  1325. package/dist/ai-service/skills/system/materialized.d.ts.map +1 -0
  1326. package/dist/ai-service/skills/system/materialized.js +33 -0
  1327. package/dist/ai-service/skills/system/materialized.js.map +1 -0
  1328. package/dist/ai-service/skills/system/migration-api-verification/skill.generated.d.ts +2 -0
  1329. package/dist/ai-service/skills/system/migration-api-verification/skill.generated.d.ts.map +1 -0
  1330. package/dist/ai-service/skills/system/migration-api-verification/skill.generated.js +119 -0
  1331. package/dist/ai-service/skills/system/migration-api-verification/skill.generated.js.map +1 -0
  1332. package/dist/ai-service/skills/system/superblocks-api/references/code-blocks.generated.d.ts +2 -0
  1333. package/dist/ai-service/skills/system/superblocks-api/references/code-blocks.generated.d.ts.map +1 -0
  1334. package/dist/ai-service/skills/system/superblocks-api/references/code-blocks.generated.js +274 -0
  1335. package/dist/ai-service/skills/system/superblocks-api/references/code-blocks.generated.js.map +1 -0
  1336. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.d.ts +2 -0
  1337. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.d.ts.map +1 -0
  1338. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.js +214 -0
  1339. package/dist/ai-service/skills/system/superblocks-api/references/graphql.generated.js.map +1 -0
  1340. package/dist/ai-service/skills/system/superblocks-api/references/rest-apis.generated.d.ts +2 -0
  1341. package/dist/ai-service/skills/system/superblocks-api/references/rest-apis.generated.d.ts.map +1 -0
  1342. package/dist/ai-service/skills/system/superblocks-api/references/rest-apis.generated.js +276 -0
  1343. package/dist/ai-service/skills/system/superblocks-api/references/rest-apis.generated.js.map +1 -0
  1344. package/dist/ai-service/skills/system/superblocks-api/references/sql-databases.generated.d.ts +2 -0
  1345. package/dist/ai-service/skills/system/superblocks-api/references/sql-databases.generated.d.ts.map +1 -0
  1346. package/dist/ai-service/skills/system/superblocks-api/references/sql-databases.generated.js +412 -0
  1347. package/dist/ai-service/skills/system/superblocks-api/references/sql-databases.generated.js.map +1 -0
  1348. package/dist/ai-service/skills/system/superblocks-api/skill.generated.d.ts +2 -0
  1349. package/dist/ai-service/skills/system/superblocks-api/skill.generated.d.ts.map +1 -0
  1350. package/dist/ai-service/skills/system/superblocks-api/skill.generated.js +891 -0
  1351. package/dist/ai-service/skills/system/superblocks-api/skill.generated.js.map +1 -0
  1352. package/dist/ai-service/skills/system/superblocks-frontend/references/embedding.generated.d.ts +2 -0
  1353. package/dist/ai-service/skills/system/superblocks-frontend/references/embedding.generated.d.ts.map +1 -0
  1354. package/dist/ai-service/skills/system/superblocks-frontend/references/embedding.generated.js +155 -0
  1355. package/dist/ai-service/skills/system/superblocks-frontend/references/embedding.generated.js.map +1 -0
  1356. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts +2 -0
  1357. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts.map +1 -0
  1358. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js +756 -0
  1359. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js.map +1 -0
  1360. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.d.ts +2 -0
  1361. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.d.ts.map +1 -0
  1362. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.js +60 -0
  1363. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.js.map +1 -0
  1364. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.d.ts +2 -0
  1365. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.d.ts.map +1 -0
  1366. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.js +136 -0
  1367. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.js.map +1 -0
  1368. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts +2 -0
  1369. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts.map +1 -0
  1370. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js +312 -0
  1371. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js.map +1 -0
  1372. package/dist/ai-service/skills/system/third-party-migration/claude-design.generated.d.ts +2 -0
  1373. package/dist/ai-service/skills/system/third-party-migration/claude-design.generated.d.ts.map +1 -0
  1374. package/dist/ai-service/skills/system/third-party-migration/claude-design.generated.js +124 -0
  1375. package/dist/ai-service/skills/system/third-party-migration/claude-design.generated.js.map +1 -0
  1376. package/dist/ai-service/skills/system/third-party-migration/lovable.generated.d.ts +2 -0
  1377. package/dist/ai-service/skills/system/third-party-migration/lovable.generated.d.ts.map +1 -0
  1378. package/dist/ai-service/skills/system/third-party-migration/lovable.generated.js +79 -0
  1379. package/dist/ai-service/skills/system/third-party-migration/lovable.generated.js.map +1 -0
  1380. package/dist/ai-service/skills/system/third-party-migration/replit.generated.d.ts +2 -0
  1381. package/dist/ai-service/skills/system/third-party-migration/replit.generated.d.ts.map +1 -0
  1382. package/dist/ai-service/skills/system/third-party-migration/replit.generated.js +65 -0
  1383. package/dist/ai-service/skills/system/third-party-migration/replit.generated.js.map +1 -0
  1384. package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts +2 -0
  1385. package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts.map +1 -0
  1386. package/dist/ai-service/skills/system/third-party-migration/skill.generated.js +171 -0
  1387. package/dist/ai-service/skills/system/third-party-migration/skill.generated.js.map +1 -0
  1388. package/dist/ai-service/skills/system/third-party-migration/v0.generated.d.ts +2 -0
  1389. package/dist/ai-service/skills/system/third-party-migration/v0.generated.d.ts.map +1 -0
  1390. package/dist/ai-service/skills/system/third-party-migration/v0.generated.js +118 -0
  1391. package/dist/ai-service/skills/system/third-party-migration/v0.generated.js.map +1 -0
  1392. package/dist/ai-service/skills/system/tool-paths.d.ts +3 -0
  1393. package/dist/ai-service/skills/system/tool-paths.d.ts.map +1 -0
  1394. package/dist/ai-service/skills/system/tool-paths.js +16 -0
  1395. package/dist/ai-service/skills/system/tool-paths.js.map +1 -0
  1396. package/dist/ai-service/skills/types.d.ts +69 -0
  1397. package/dist/ai-service/skills/types.d.ts.map +1 -0
  1398. package/dist/ai-service/skills/types.js +121 -0
  1399. package/dist/ai-service/skills/types.js.map +1 -0
  1400. package/dist/ai-service/state-machine/clark-fsm.d.ts +570 -22
  1401. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  1402. package/dist/ai-service/state-machine/clark-fsm.js +408 -0
  1403. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  1404. package/dist/ai-service/state-machine/fsm.d.ts +17 -16
  1405. package/dist/ai-service/state-machine/fsm.d.ts.map +1 -1
  1406. package/dist/ai-service/state-machine/fsm.js +2 -1
  1407. package/dist/ai-service/state-machine/fsm.js.map +1 -1
  1408. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts +12 -0
  1409. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  1410. package/dist/ai-service/state-machine/handlers/agent-planning.js +1088 -168
  1411. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  1412. package/dist/ai-service/state-machine/handlers/awaiting-user.d.ts +1 -1
  1413. package/dist/ai-service/state-machine/handlers/awaiting-user.d.ts.map +1 -1
  1414. package/dist/ai-service/state-machine/handlers/awaiting-user.js +335 -13
  1415. package/dist/ai-service/state-machine/handlers/awaiting-user.js.map +1 -1
  1416. package/dist/ai-service/state-machine/handlers/flush-pending-chat-pushes.d.ts +11 -0
  1417. package/dist/ai-service/state-machine/handlers/flush-pending-chat-pushes.d.ts.map +1 -0
  1418. package/dist/ai-service/state-machine/handlers/flush-pending-chat-pushes.js +11 -0
  1419. package/dist/ai-service/state-machine/handlers/flush-pending-chat-pushes.js.map +1 -0
  1420. package/dist/ai-service/state-machine/handlers/idle.d.ts +2 -2
  1421. package/dist/ai-service/state-machine/handlers/idle.d.ts.map +1 -1
  1422. package/dist/ai-service/state-machine/handlers/idle.js +138 -8
  1423. package/dist/ai-service/state-machine/handlers/idle.js.map +1 -1
  1424. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts +37 -2
  1425. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  1426. package/dist/ai-service/state-machine/handlers/llm-generating.js +1225 -136
  1427. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  1428. package/dist/ai-service/state-machine/handlers/next-steps.d.ts +22 -0
  1429. package/dist/ai-service/state-machine/handlers/next-steps.d.ts.map +1 -0
  1430. package/dist/ai-service/state-machine/handlers/next-steps.js +85 -0
  1431. package/dist/ai-service/state-machine/handlers/next-steps.js.map +1 -0
  1432. package/dist/ai-service/state-machine/handlers/persist-prompt-attachments.d.ts +25 -0
  1433. package/dist/ai-service/state-machine/handlers/persist-prompt-attachments.d.ts.map +1 -0
  1434. package/dist/ai-service/state-machine/handlers/persist-prompt-attachments.js +68 -0
  1435. package/dist/ai-service/state-machine/handlers/persist-prompt-attachments.js.map +1 -0
  1436. package/dist/ai-service/state-machine/handlers/play-dead.d.ts +2 -2
  1437. package/dist/ai-service/state-machine/handlers/play-dead.d.ts.map +1 -1
  1438. package/dist/ai-service/state-machine/handlers/play-dead.js +18 -4
  1439. package/dist/ai-service/state-machine/handlers/play-dead.js.map +1 -1
  1440. package/dist/ai-service/state-machine/handlers/post-processing.d.ts +6 -1
  1441. package/dist/ai-service/state-machine/handlers/post-processing.d.ts.map +1 -1
  1442. package/dist/ai-service/state-machine/handlers/post-processing.js +234 -43
  1443. package/dist/ai-service/state-machine/handlers/post-processing.js.map +1 -1
  1444. package/dist/ai-service/state-machine/handlers/runtime-reviewing.d.ts.map +1 -1
  1445. package/dist/ai-service/state-machine/handlers/runtime-reviewing.js +116 -6
  1446. package/dist/ai-service/state-machine/handlers/runtime-reviewing.js.map +1 -1
  1447. package/dist/ai-service/state-machine/helpers/background-chat-record-metrics.d.ts +7 -0
  1448. package/dist/ai-service/state-machine/helpers/background-chat-record-metrics.d.ts.map +1 -0
  1449. package/dist/ai-service/state-machine/helpers/background-chat-record-metrics.js +47 -0
  1450. package/dist/ai-service/state-machine/helpers/background-chat-record-metrics.js.map +1 -0
  1451. package/dist/ai-service/state-machine/helpers/background-chat-record.d.ts +33 -0
  1452. package/dist/ai-service/state-machine/helpers/background-chat-record.d.ts.map +1 -0
  1453. package/dist/ai-service/state-machine/helpers/background-chat-record.js +61 -0
  1454. package/dist/ai-service/state-machine/helpers/background-chat-record.js.map +1 -0
  1455. package/dist/ai-service/state-machine/helpers/change-info.d.ts +8 -0
  1456. package/dist/ai-service/state-machine/helpers/change-info.d.ts.map +1 -0
  1457. package/dist/ai-service/state-machine/helpers/change-info.js +100 -0
  1458. package/dist/ai-service/state-machine/helpers/change-info.js.map +1 -0
  1459. package/dist/ai-service/state-machine/helpers/classification.d.ts +5 -0
  1460. package/dist/ai-service/state-machine/helpers/classification.d.ts.map +1 -0
  1461. package/dist/ai-service/state-machine/helpers/classification.js +13 -0
  1462. package/dist/ai-service/state-machine/helpers/classification.js.map +1 -0
  1463. package/dist/ai-service/state-machine/helpers/context-id.d.ts +4 -0
  1464. package/dist/ai-service/state-machine/helpers/context-id.d.ts.map +1 -0
  1465. package/dist/ai-service/state-machine/helpers/context-id.js +18 -0
  1466. package/dist/ai-service/state-machine/helpers/context-id.js.map +1 -0
  1467. package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.d.ts +7 -0
  1468. package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.d.ts.map +1 -0
  1469. package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.js +38 -0
  1470. package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.js.map +1 -0
  1471. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.d.ts +27 -0
  1472. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.d.ts.map +1 -0
  1473. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.js +34 -0
  1474. package/dist/ai-service/state-machine/helpers/headless-turn-lifecycle.js.map +1 -0
  1475. package/dist/ai-service/state-machine/helpers/peer.d.ts +83 -3
  1476. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  1477. package/dist/ai-service/state-machine/helpers/peer.js +342 -4
  1478. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  1479. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts +21 -0
  1480. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts.map +1 -0
  1481. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js +71 -0
  1482. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js.map +1 -0
  1483. package/dist/ai-service/state-machine/helpers/pre-session-metrics.d.ts +38 -0
  1484. package/dist/ai-service/state-machine/helpers/pre-session-metrics.d.ts.map +1 -0
  1485. package/dist/ai-service/state-machine/helpers/pre-session-metrics.js +131 -0
  1486. package/dist/ai-service/state-machine/helpers/pre-session-metrics.js.map +1 -0
  1487. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.d.ts +26 -0
  1488. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.d.ts.map +1 -0
  1489. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js +128 -0
  1490. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js.map +1 -0
  1491. package/dist/ai-service/state-machine/helpers/prompt-degradation-metrics.d.ts +28 -0
  1492. package/dist/ai-service/state-machine/helpers/prompt-degradation-metrics.d.ts.map +1 -0
  1493. package/dist/ai-service/state-machine/helpers/prompt-degradation-metrics.js +254 -0
  1494. package/dist/ai-service/state-machine/helpers/prompt-degradation-metrics.js.map +1 -0
  1495. package/dist/ai-service/state-machine/helpers/prompt-failure.d.ts +59 -0
  1496. package/dist/ai-service/state-machine/helpers/prompt-failure.d.ts.map +1 -0
  1497. package/dist/ai-service/state-machine/helpers/prompt-failure.js +168 -0
  1498. package/dist/ai-service/state-machine/helpers/prompt-failure.js.map +1 -0
  1499. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts +229 -0
  1500. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts.map +1 -0
  1501. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js +675 -0
  1502. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js.map +1 -0
  1503. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +271 -0
  1504. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -0
  1505. package/dist/ai-service/state-machine/helpers/stable-peer.js +630 -0
  1506. package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -0
  1507. package/dist/ai-service/state-machine/helpers/transition.d.ts.map +1 -1
  1508. package/dist/ai-service/state-machine/helpers/transition.js +8 -3
  1509. package/dist/ai-service/state-machine/helpers/transition.js.map +1 -1
  1510. package/dist/ai-service/state-machine/helpers/user-preferences.d.ts +8 -0
  1511. package/dist/ai-service/state-machine/helpers/user-preferences.d.ts.map +1 -0
  1512. package/dist/ai-service/state-machine/helpers/user-preferences.js +11 -0
  1513. package/dist/ai-service/state-machine/helpers/user-preferences.js.map +1 -0
  1514. package/dist/ai-service/state-machine/mocks.d.ts +3 -3
  1515. package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
  1516. package/dist/ai-service/state-machine/mocks.js +125 -20
  1517. package/dist/ai-service/state-machine/mocks.js.map +1 -1
  1518. package/dist/ai-service/state-machine/traced-fsm.d.ts +89 -0
  1519. package/dist/ai-service/state-machine/traced-fsm.d.ts.map +1 -0
  1520. package/dist/ai-service/state-machine/traced-fsm.js +179 -0
  1521. package/dist/ai-service/state-machine/traced-fsm.js.map +1 -0
  1522. package/dist/ai-service/tasks/access.d.ts +23 -0
  1523. package/dist/ai-service/tasks/access.d.ts.map +1 -0
  1524. package/dist/ai-service/tasks/access.js +26 -0
  1525. package/dist/ai-service/tasks/access.js.map +1 -0
  1526. package/dist/ai-service/tasks/factory.d.ts +106 -0
  1527. package/dist/ai-service/tasks/factory.d.ts.map +1 -0
  1528. package/dist/ai-service/tasks/factory.js +71 -0
  1529. package/dist/ai-service/tasks/factory.js.map +1 -0
  1530. package/dist/ai-service/tasks/index.d.ts +6 -0
  1531. package/dist/ai-service/tasks/index.d.ts.map +1 -0
  1532. package/dist/ai-service/tasks/index.js +5 -0
  1533. package/dist/ai-service/tasks/index.js.map +1 -0
  1534. package/dist/ai-service/tasks/peer-push.d.ts +81 -0
  1535. package/dist/ai-service/tasks/peer-push.d.ts.map +1 -0
  1536. package/dist/ai-service/tasks/peer-push.js +84 -0
  1537. package/dist/ai-service/tasks/peer-push.js.map +1 -0
  1538. package/dist/ai-service/tasks/poll-loop.d.ts +56 -0
  1539. package/dist/ai-service/tasks/poll-loop.d.ts.map +1 -0
  1540. package/dist/ai-service/tasks/poll-loop.js +73 -0
  1541. package/dist/ai-service/tasks/poll-loop.js.map +1 -0
  1542. package/dist/ai-service/tasks/task-store.d.ts +116 -0
  1543. package/dist/ai-service/tasks/task-store.d.ts.map +1 -0
  1544. package/dist/ai-service/tasks/task-store.js +388 -0
  1545. package/dist/ai-service/tasks/task-store.js.map +1 -0
  1546. package/dist/ai-service/tasks/test-utils.d.ts +24 -0
  1547. package/dist/ai-service/tasks/test-utils.d.ts.map +1 -0
  1548. package/dist/ai-service/tasks/test-utils.js +53 -0
  1549. package/dist/ai-service/tasks/test-utils.js.map +1 -0
  1550. package/dist/ai-service/tasks/types.d.ts +143 -0
  1551. package/dist/ai-service/tasks/types.d.ts.map +1 -0
  1552. package/dist/ai-service/tasks/types.js +6 -0
  1553. package/dist/ai-service/tasks/types.js.map +1 -0
  1554. package/dist/ai-service/template-renderer.d.ts +45 -0
  1555. package/dist/ai-service/template-renderer.d.ts.map +1 -0
  1556. package/dist/ai-service/template-renderer.js +316 -0
  1557. package/dist/ai-service/template-renderer.js.map +1 -0
  1558. package/dist/ai-service/test-utils/dd-trace-helpers.d.ts +25 -0
  1559. package/dist/ai-service/test-utils/dd-trace-helpers.d.ts.map +1 -0
  1560. package/dist/ai-service/test-utils/dd-trace-helpers.js +9 -0
  1561. package/dist/ai-service/test-utils/dd-trace-helpers.js.map +1 -0
  1562. package/dist/ai-service/test-utils/error-mocks.d.ts +69 -0
  1563. package/dist/ai-service/test-utils/error-mocks.d.ts.map +1 -0
  1564. package/dist/ai-service/test-utils/error-mocks.js +334 -0
  1565. package/dist/ai-service/test-utils/error-mocks.js.map +1 -0
  1566. package/dist/ai-service/test-utils/metrics-harness.d.ts +38 -0
  1567. package/dist/ai-service/test-utils/metrics-harness.d.ts.map +1 -0
  1568. package/dist/ai-service/test-utils/metrics-harness.js +67 -0
  1569. package/dist/ai-service/test-utils/metrics-harness.js.map +1 -0
  1570. package/dist/ai-service/test-utils/span-interceptor.d.ts +74 -0
  1571. package/dist/ai-service/test-utils/span-interceptor.d.ts.map +1 -0
  1572. package/dist/ai-service/test-utils/span-interceptor.js +272 -0
  1573. package/dist/ai-service/test-utils/span-interceptor.js.map +1 -0
  1574. package/dist/ai-service/test-utils/tracer-harness.d.ts +8 -0
  1575. package/dist/ai-service/test-utils/tracer-harness.d.ts.map +1 -0
  1576. package/dist/ai-service/test-utils/tracer-harness.js +26 -0
  1577. package/dist/ai-service/test-utils/tracer-harness.js.map +1 -0
  1578. package/dist/ai-service/transform/api-builder/shared.d.ts +10 -2
  1579. package/dist/ai-service/transform/api-builder/shared.d.ts.map +1 -1
  1580. package/dist/ai-service/transform/api-builder/shared.js +34 -10
  1581. package/dist/ai-service/transform/api-builder/shared.js.map +1 -1
  1582. package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts +16 -2
  1583. package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts.map +1 -1
  1584. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js +181 -55
  1585. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js.map +1 -1
  1586. package/dist/ai-service/transform/api-builder/to-yaml-transformer.d.ts +6 -2
  1587. package/dist/ai-service/transform/api-builder/to-yaml-transformer.d.ts.map +1 -1
  1588. package/dist/ai-service/transform/api-builder/to-yaml-transformer.js +186 -49
  1589. package/dist/ai-service/transform/api-builder/to-yaml-transformer.js.map +1 -1
  1590. package/dist/ai-service/transform/lucide-dynamic-type-imports/transformer.d.ts +40 -0
  1591. package/dist/ai-service/transform/lucide-dynamic-type-imports/transformer.d.ts.map +1 -0
  1592. package/dist/ai-service/transform/lucide-dynamic-type-imports/transformer.js +118 -0
  1593. package/dist/ai-service/transform/lucide-dynamic-type-imports/transformer.js.map +1 -0
  1594. package/dist/ai-service/transform/remove-api-builder-imports/transformer.d.ts +1 -1
  1595. package/dist/ai-service/transform/remove-api-builder-imports/transformer.d.ts.map +1 -1
  1596. package/dist/ai-service/transform/remove-api-builder-imports/transformer.js +88 -37
  1597. package/dist/ai-service/transform/remove-api-builder-imports/transformer.js.map +1 -1
  1598. package/dist/ai-service/transform/shared.d.ts +9 -2
  1599. package/dist/ai-service/transform/shared.d.ts.map +1 -1
  1600. package/dist/ai-service/transform/shared.js +43 -13
  1601. package/dist/ai-service/transform/shared.js.map +1 -1
  1602. package/dist/ai-service/transform/workaround-missing-sbapi/transformer.d.ts +1 -1
  1603. package/dist/ai-service/transform/workaround-missing-sbapi/transformer.d.ts.map +1 -1
  1604. package/dist/ai-service/transform/workaround-missing-sbapi/transformer.js +77 -26
  1605. package/dist/ai-service/transform/workaround-missing-sbapi/transformer.js.map +1 -1
  1606. package/dist/ai-service/types.d.ts +301 -27
  1607. package/dist/ai-service/types.d.ts.map +1 -1
  1608. package/dist/ai-service/types.js +157 -0
  1609. package/dist/ai-service/types.js.map +1 -1
  1610. package/dist/ai-service/util/archive-extractors.d.ts +52 -0
  1611. package/dist/ai-service/util/archive-extractors.d.ts.map +1 -0
  1612. package/dist/ai-service/util/archive-extractors.js +305 -0
  1613. package/dist/ai-service/util/archive-extractors.js.map +1 -0
  1614. package/dist/ai-service/util/call-peer.d.ts +11 -0
  1615. package/dist/ai-service/util/call-peer.d.ts.map +1 -0
  1616. package/dist/ai-service/util/call-peer.js +47 -0
  1617. package/dist/ai-service/util/call-peer.js.map +1 -0
  1618. package/dist/ai-service/util/inference-jwt.d.ts +15 -0
  1619. package/dist/ai-service/util/inference-jwt.d.ts.map +1 -0
  1620. package/dist/ai-service/util/inference-jwt.js +56 -0
  1621. package/dist/ai-service/util/inference-jwt.js.map +1 -0
  1622. package/dist/ai-service/util/llm-config-utils.d.ts +54 -0
  1623. package/dist/ai-service/util/llm-config-utils.d.ts.map +1 -0
  1624. package/dist/ai-service/util/llm-config-utils.js +140 -0
  1625. package/dist/ai-service/util/llm-config-utils.js.map +1 -0
  1626. package/dist/ai-service/util/mode-message.d.ts +7 -0
  1627. package/dist/ai-service/util/mode-message.d.ts.map +1 -0
  1628. package/dist/ai-service/util/mode-message.js +15 -0
  1629. package/dist/ai-service/util/mode-message.js.map +1 -0
  1630. package/dist/ai-service/util/parse-jwt.d.ts +12 -0
  1631. package/dist/ai-service/util/parse-jwt.d.ts.map +1 -0
  1632. package/dist/ai-service/util/parse-jwt.js +30 -0
  1633. package/dist/ai-service/util/parse-jwt.js.map +1 -0
  1634. package/dist/ai-service/util/peer-liveness.d.ts +23 -0
  1635. package/dist/ai-service/util/peer-liveness.d.ts.map +1 -0
  1636. package/dist/ai-service/util/peer-liveness.js +42 -0
  1637. package/dist/ai-service/util/peer-liveness.js.map +1 -0
  1638. package/dist/ai-service/util/rpc-timeout.d.ts +89 -0
  1639. package/dist/ai-service/util/rpc-timeout.d.ts.map +1 -0
  1640. package/dist/ai-service/util/rpc-timeout.js +112 -0
  1641. package/dist/ai-service/util/rpc-timeout.js.map +1 -0
  1642. package/dist/ai-service/util/scoped-token-utils.d.ts +15 -0
  1643. package/dist/ai-service/util/scoped-token-utils.d.ts.map +1 -0
  1644. package/dist/ai-service/util/scoped-token-utils.js +137 -0
  1645. package/dist/ai-service/util/scoped-token-utils.js.map +1 -0
  1646. package/dist/ai-service/util/stop-condition.d.ts +17 -0
  1647. package/dist/ai-service/util/stop-condition.d.ts.map +1 -0
  1648. package/dist/ai-service/util/stop-condition.js +33 -0
  1649. package/dist/ai-service/util/stop-condition.js.map +1 -0
  1650. package/dist/ai-service/util/strip-content.d.ts +2 -0
  1651. package/dist/ai-service/util/strip-content.d.ts.map +1 -0
  1652. package/dist/ai-service/util/strip-content.js +31 -0
  1653. package/dist/ai-service/util/strip-content.js.map +1 -0
  1654. package/dist/ai-service/util/tool-signature.d.ts +13 -0
  1655. package/dist/ai-service/util/tool-signature.d.ts.map +1 -0
  1656. package/dist/ai-service/util/tool-signature.js +38 -0
  1657. package/dist/ai-service/util/tool-signature.js.map +1 -0
  1658. package/dist/binding-extraction/extract-control-block-identifiers.d.ts +1 -2
  1659. package/dist/binding-extraction/extract-control-block-identifiers.d.ts.map +1 -1
  1660. package/dist/binding-extraction/extract-control-block-identifiers.js +16 -14
  1661. package/dist/binding-extraction/extract-control-block-identifiers.js.map +1 -1
  1662. package/dist/binding-extraction/extract-embedded-identifiers.d.ts +2 -11
  1663. package/dist/binding-extraction/extract-embedded-identifiers.d.ts.map +1 -1
  1664. package/dist/binding-extraction/extract-embedded-identifiers.js +9 -91
  1665. package/dist/binding-extraction/extract-embedded-identifiers.js.map +1 -1
  1666. package/dist/binding-extraction/extract-identifiers.d.ts +16 -3
  1667. package/dist/binding-extraction/extract-identifiers.d.ts.map +1 -1
  1668. package/dist/binding-extraction/extract-identifiers.js +272 -64
  1669. package/dist/binding-extraction/extract-identifiers.js.map +1 -1
  1670. package/dist/binding-extraction/index.d.ts +2 -0
  1671. package/dist/binding-extraction/index.d.ts.map +1 -0
  1672. package/dist/binding-extraction/index.js +2 -0
  1673. package/dist/binding-extraction/index.js.map +1 -0
  1674. package/dist/binding-extraction/js-identifiers.d.ts +34 -0
  1675. package/dist/binding-extraction/js-identifiers.d.ts.map +1 -0
  1676. package/dist/binding-extraction/js-identifiers.js +409 -0
  1677. package/dist/binding-extraction/js-identifiers.js.map +1 -0
  1678. package/dist/binding-extraction/python-identifiers.d.ts +30 -0
  1679. package/dist/binding-extraction/python-identifiers.d.ts.map +1 -0
  1680. package/dist/binding-extraction/python-identifiers.js +657 -0
  1681. package/dist/binding-extraction/python-identifiers.js.map +1 -0
  1682. package/dist/binding-extraction/shared.d.ts +0 -203
  1683. package/dist/binding-extraction/shared.d.ts.map +1 -1
  1684. package/dist/binding-extraction/shared.js +1 -42
  1685. package/dist/binding-extraction/shared.js.map +1 -1
  1686. package/dist/binding-extraction/template-strings.d.ts +1 -2
  1687. package/dist/binding-extraction/template-strings.d.ts.map +1 -1
  1688. package/dist/build-errors.d.ts +10 -0
  1689. package/dist/build-errors.d.ts.map +1 -0
  1690. package/dist/build-errors.js +14 -0
  1691. package/dist/build-errors.js.map +1 -0
  1692. package/dist/clark-log-forwarder.d.ts +15 -0
  1693. package/dist/clark-log-forwarder.d.ts.map +1 -0
  1694. package/dist/clark-log-forwarder.js +32 -0
  1695. package/dist/clark-log-forwarder.js.map +1 -0
  1696. package/dist/client-error-overlay.d.ts +11 -0
  1697. package/dist/client-error-overlay.d.ts.map +1 -0
  1698. package/dist/client-error-overlay.js +90 -0
  1699. package/dist/client-error-overlay.js.map +1 -0
  1700. package/dist/codegen.d.ts +3 -25
  1701. package/dist/codegen.d.ts.map +1 -1
  1702. package/dist/codegen.js +64 -129
  1703. package/dist/codegen.js.map +1 -1
  1704. package/dist/components-manager.d.ts +12 -12
  1705. package/dist/components-manager.d.ts.map +1 -1
  1706. package/dist/components-manager.js +116 -90
  1707. package/dist/components-manager.js.map +1 -1
  1708. package/dist/custom-components.d.ts +1 -1
  1709. package/dist/custom-components.d.ts.map +1 -1
  1710. package/dist/custom-components.js +1 -1
  1711. package/dist/custom-components.js.map +1 -1
  1712. package/dist/dev-server-ws-smoke-client.d.ts +40 -0
  1713. package/dist/dev-server-ws-smoke-client.d.ts.map +1 -0
  1714. package/dist/dev-server-ws-smoke-client.js +316 -0
  1715. package/dist/dev-server-ws-smoke-client.js.map +1 -0
  1716. package/dist/download-filename.d.ts +6 -0
  1717. package/dist/download-filename.d.ts.map +1 -0
  1718. package/dist/download-filename.js +40 -0
  1719. package/dist/download-filename.js.map +1 -0
  1720. package/dist/draft-interface.d.ts +8 -1
  1721. package/dist/draft-interface.d.ts.map +1 -1
  1722. package/dist/early-error-relay.d.ts +31 -0
  1723. package/dist/early-error-relay.d.ts.map +1 -0
  1724. package/dist/early-error-relay.js +88 -0
  1725. package/dist/early-error-relay.js.map +1 -0
  1726. package/dist/ensure-app-provider.d.ts +2 -0
  1727. package/dist/ensure-app-provider.d.ts.map +1 -0
  1728. package/dist/ensure-app-provider.js +209 -0
  1729. package/dist/ensure-app-provider.js.map +1 -0
  1730. package/dist/errors/error-handler.d.ts +3 -13
  1731. package/dist/errors/error-handler.d.ts.map +1 -1
  1732. package/dist/errors/error-handler.js +1 -1
  1733. package/dist/errors/error-handler.js.map +1 -1
  1734. package/dist/extract-api-integrations.d.ts +99 -0
  1735. package/dist/extract-api-integrations.d.ts.map +1 -0
  1736. package/dist/extract-api-integrations.js +597 -0
  1737. package/dist/extract-api-integrations.js.map +1 -0
  1738. package/dist/file-sync-vite-plugin.d.ts +64 -2
  1739. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  1740. package/dist/file-sync-vite-plugin.js +1398 -469
  1741. package/dist/file-sync-vite-plugin.js.map +1 -1
  1742. package/dist/file-system-helpers.d.ts +55 -3
  1743. package/dist/file-system-helpers.d.ts.map +1 -1
  1744. package/dist/file-system-helpers.js +118 -5
  1745. package/dist/file-system-helpers.js.map +1 -1
  1746. package/dist/file-system-manager.d.ts +62 -69
  1747. package/dist/file-system-manager.d.ts.map +1 -1
  1748. package/dist/file-system-manager.js +695 -811
  1749. package/dist/file-system-manager.js.map +1 -1
  1750. package/dist/git-auth-state.d.ts +4 -0
  1751. package/dist/git-auth-state.d.ts.map +1 -0
  1752. package/dist/git-auth-state.js +25 -0
  1753. package/dist/git-auth-state.js.map +1 -0
  1754. package/dist/git-log.d.ts +11 -0
  1755. package/dist/git-log.d.ts.map +1 -0
  1756. package/dist/git-log.js +23 -0
  1757. package/dist/git-log.js.map +1 -0
  1758. package/dist/git-operation-lock.d.ts +22 -0
  1759. package/dist/git-operation-lock.d.ts.map +1 -0
  1760. package/dist/git-operation-lock.js +25 -0
  1761. package/dist/git-operation-lock.js.map +1 -0
  1762. package/dist/git-service/app-layout-guard.d.ts +25 -0
  1763. package/dist/git-service/app-layout-guard.d.ts.map +1 -0
  1764. package/dist/git-service/app-layout-guard.js +66 -0
  1765. package/dist/git-service/app-layout-guard.js.map +1 -0
  1766. package/dist/git-service/azure-devops-workflow.d.ts +6 -0
  1767. package/dist/git-service/azure-devops-workflow.d.ts.map +1 -0
  1768. package/dist/git-service/azure-devops-workflow.js +12 -0
  1769. package/dist/git-service/azure-devops-workflow.js.map +1 -0
  1770. package/dist/git-service/bitbucket-workflow.d.ts +5 -0
  1771. package/dist/git-service/bitbucket-workflow.d.ts.map +1 -0
  1772. package/dist/git-service/bitbucket-workflow.js +12 -0
  1773. package/dist/git-service/bitbucket-workflow.js.map +1 -0
  1774. package/dist/git-service/checkpoint-commit-metrics.d.ts +2 -0
  1775. package/dist/git-service/checkpoint-commit-metrics.d.ts.map +1 -0
  1776. package/dist/git-service/checkpoint-commit-metrics.js +15 -0
  1777. package/dist/git-service/checkpoint-commit-metrics.js.map +1 -0
  1778. package/dist/git-service/checkpoint-committer.d.ts +22 -0
  1779. package/dist/git-service/checkpoint-committer.d.ts.map +1 -0
  1780. package/dist/git-service/checkpoint-committer.js +91 -0
  1781. package/dist/git-service/checkpoint-committer.js.map +1 -0
  1782. package/dist/git-service/commit-live-branch.d.ts +17 -0
  1783. package/dist/git-service/commit-live-branch.d.ts.map +1 -0
  1784. package/dist/git-service/commit-live-branch.js +28 -0
  1785. package/dist/git-service/commit-live-branch.js.map +1 -0
  1786. package/dist/git-service/ensure-workflow-file.d.ts +20 -0
  1787. package/dist/git-service/ensure-workflow-file.d.ts.map +1 -0
  1788. package/dist/git-service/ensure-workflow-file.js +51 -0
  1789. package/dist/git-service/ensure-workflow-file.js.map +1 -0
  1790. package/dist/git-service/errors.d.ts +31 -0
  1791. package/dist/git-service/errors.d.ts.map +1 -0
  1792. package/dist/git-service/errors.js +49 -0
  1793. package/dist/git-service/errors.js.map +1 -0
  1794. package/dist/git-service/github-workflow.d.ts +6 -0
  1795. package/dist/git-service/github-workflow.d.ts.map +1 -0
  1796. package/dist/git-service/github-workflow.js +12 -0
  1797. package/dist/git-service/github-workflow.js.map +1 -0
  1798. package/dist/git-service/gitlab-workflow.d.ts +6 -0
  1799. package/dist/git-service/gitlab-workflow.d.ts.map +1 -0
  1800. package/dist/git-service/gitlab-workflow.js +12 -0
  1801. package/dist/git-service/gitlab-workflow.js.map +1 -0
  1802. package/dist/git-service/index.d.ts +30 -0
  1803. package/dist/git-service/index.d.ts.map +1 -0
  1804. package/dist/git-service/index.js +217 -0
  1805. package/dist/git-service/index.js.map +1 -0
  1806. package/dist/git-service/live-branch.d.ts +11 -0
  1807. package/dist/git-service/live-branch.d.ts.map +1 -0
  1808. package/dist/git-service/live-branch.js +171 -0
  1809. package/dist/git-service/live-branch.js.map +1 -0
  1810. package/dist/git-service/managed-excludes.d.ts +36 -0
  1811. package/dist/git-service/managed-excludes.d.ts.map +1 -0
  1812. package/dist/git-service/managed-excludes.js +124 -0
  1813. package/dist/git-service/managed-excludes.js.map +1 -0
  1814. package/dist/git-service/provider-workflow-files.d.ts +12 -0
  1815. package/dist/git-service/provider-workflow-files.d.ts.map +1 -0
  1816. package/dist/git-service/provider-workflow-files.js +36 -0
  1817. package/dist/git-service/provider-workflow-files.js.map +1 -0
  1818. package/dist/git-service/status-sync.d.ts +18 -0
  1819. package/dist/git-service/status-sync.d.ts.map +1 -0
  1820. package/dist/git-service/status-sync.js +32 -0
  1821. package/dist/git-service/status-sync.js.map +1 -0
  1822. package/dist/ids.d.ts +1 -0
  1823. package/dist/ids.d.ts.map +1 -1
  1824. package/dist/ids.js +3 -0
  1825. package/dist/ids.js.map +1 -1
  1826. package/dist/index.d.ts +5 -0
  1827. package/dist/index.d.ts.map +1 -1
  1828. package/dist/index.js +3 -0
  1829. package/dist/index.js.map +1 -1
  1830. package/dist/inject-index-vite-plugin.d.ts +21 -0
  1831. package/dist/inject-index-vite-plugin.d.ts.map +1 -0
  1832. package/dist/inject-index-vite-plugin.js +130 -0
  1833. package/dist/inject-index-vite-plugin.js.map +1 -0
  1834. package/dist/injected-index.d.ts +9 -2
  1835. package/dist/injected-index.d.ts.map +1 -1
  1836. package/dist/injected-index.js +153 -9
  1837. package/dist/injected-index.js.map +1 -1
  1838. package/dist/lock-service/activity-tracker.d.ts +46 -0
  1839. package/dist/lock-service/activity-tracker.d.ts.map +1 -0
  1840. package/dist/lock-service/activity-tracker.js +119 -0
  1841. package/dist/lock-service/activity-tracker.js.map +1 -0
  1842. package/dist/lock-service/index.d.ts +420 -24
  1843. package/dist/lock-service/index.d.ts.map +1 -1
  1844. package/dist/lock-service/index.js +1209 -131
  1845. package/dist/lock-service/index.js.map +1 -1
  1846. package/dist/migration/get-fullstack-template-dir.d.ts +37 -0
  1847. package/dist/migration/get-fullstack-template-dir.d.ts.map +1 -0
  1848. package/dist/migration/get-fullstack-template-dir.js +99 -0
  1849. package/dist/migration/get-fullstack-template-dir.js.map +1 -0
  1850. package/dist/migration/inline-v2-backup-source-files.d.ts +7 -0
  1851. package/dist/migration/inline-v2-backup-source-files.d.ts.map +1 -0
  1852. package/dist/migration/inline-v2-backup-source-files.js +110 -0
  1853. package/dist/migration/inline-v2-backup-source-files.js.map +1 -0
  1854. package/dist/migration/integration-write-policy.d.ts +24 -0
  1855. package/dist/migration/integration-write-policy.d.ts.map +1 -0
  1856. package/dist/migration/integration-write-policy.js +125 -0
  1857. package/dist/migration/integration-write-policy.js.map +1 -0
  1858. package/dist/migration/mark-api-testing-denied.d.ts +27 -0
  1859. package/dist/migration/mark-api-testing-denied.d.ts.map +1 -0
  1860. package/dist/migration/mark-api-testing-denied.js +80 -0
  1861. package/dist/migration/mark-api-testing-denied.js.map +1 -0
  1862. package/dist/migration/migration-checklist.d.ts +80 -0
  1863. package/dist/migration/migration-checklist.d.ts.map +1 -0
  1864. package/dist/migration/migration-checklist.js +150 -0
  1865. package/dist/migration/migration-checklist.js.map +1 -0
  1866. package/dist/migration/migration-classifier.d.ts +4 -0
  1867. package/dist/migration/migration-classifier.d.ts.map +1 -0
  1868. package/dist/migration/migration-classifier.js +87 -0
  1869. package/dist/migration/migration-classifier.js.map +1 -0
  1870. package/dist/migration/migration-metrics.d.ts +74 -0
  1871. package/dist/migration/migration-metrics.d.ts.map +1 -0
  1872. package/dist/migration/migration-metrics.js +124 -0
  1873. package/dist/migration/migration-metrics.js.map +1 -0
  1874. package/dist/migration/migration-routes.d.ts +47 -0
  1875. package/dist/migration/migration-routes.d.ts.map +1 -0
  1876. package/dist/migration/migration-routes.js +1233 -0
  1877. package/dist/migration/migration-routes.js.map +1 -0
  1878. package/dist/migration/migration-session-reconcile.d.ts +24 -0
  1879. package/dist/migration/migration-session-reconcile.d.ts.map +1 -0
  1880. package/dist/migration/migration-session-reconcile.js +139 -0
  1881. package/dist/migration/migration-session-reconcile.js.map +1 -0
  1882. package/dist/migration/migration-verification.d.ts +288 -0
  1883. package/dist/migration/migration-verification.d.ts.map +1 -0
  1884. package/dist/migration/migration-verification.js +1246 -0
  1885. package/dist/migration/migration-verification.js.map +1 -0
  1886. package/dist/migration/recommended-user-deps.d.ts +40 -0
  1887. package/dist/migration/recommended-user-deps.d.ts.map +1 -0
  1888. package/dist/migration/recommended-user-deps.js +209 -0
  1889. package/dist/migration/recommended-user-deps.js.map +1 -0
  1890. package/dist/migration/resolve-v2-backup-path.d.ts +7 -0
  1891. package/dist/migration/resolve-v2-backup-path.d.ts.map +1 -0
  1892. package/dist/migration/resolve-v2-backup-path.js +35 -0
  1893. package/dist/migration/resolve-v2-backup-path.js.map +1 -0
  1894. package/dist/migration/restructure.d.ts +125 -0
  1895. package/dist/migration/restructure.d.ts.map +1 -0
  1896. package/dist/migration/restructure.js +645 -0
  1897. package/dist/migration/restructure.js.map +1 -0
  1898. package/dist/migration/scan-imports.d.ts +7 -0
  1899. package/dist/migration/scan-imports.d.ts.map +1 -0
  1900. package/dist/migration/scan-imports.js +178 -0
  1901. package/dist/migration/scan-imports.js.map +1 -0
  1902. package/dist/migration/translation-prompt.d.ts +23 -0
  1903. package/dist/migration/translation-prompt.d.ts.map +1 -0
  1904. package/dist/migration/translation-prompt.js +36 -0
  1905. package/dist/migration/translation-prompt.js.map +1 -0
  1906. package/dist/migration/unsupported-integrations.d.ts +11 -0
  1907. package/dist/migration/unsupported-integrations.d.ts.map +1 -0
  1908. package/dist/migration/unsupported-integrations.js +206 -0
  1909. package/dist/migration/unsupported-integrations.js.map +1 -0
  1910. package/dist/migration/yaml-walk.d.ts +18 -0
  1911. package/dist/migration/yaml-walk.d.ts.map +1 -0
  1912. package/dist/migration/yaml-walk.js +45 -0
  1913. package/dist/migration/yaml-walk.js.map +1 -0
  1914. package/dist/migration-templates/app-fullstack/.gitignore +50 -0
  1915. package/dist/migration-templates/app-fullstack/client/App.tsx +17 -0
  1916. package/dist/migration-templates/app-fullstack/client/components/common/sonner.tsx +20 -0
  1917. package/dist/migration-templates/app-fullstack/client/components/hooks/use-active-page.ts +73 -0
  1918. package/dist/migration-templates/app-fullstack/client/components/hooks/use-mobile.ts +21 -0
  1919. package/dist/migration-templates/app-fullstack/client/components/ui/accordion.tsx +197 -0
  1920. package/dist/migration-templates/app-fullstack/client/components/ui/area-chart.tsx +432 -0
  1921. package/dist/migration-templates/app-fullstack/client/components/ui/aspect-ratio.tsx +45 -0
  1922. package/dist/migration-templates/app-fullstack/client/components/ui/avatar.tsx +117 -0
  1923. package/dist/migration-templates/app-fullstack/client/components/ui/badge.tsx +143 -0
  1924. package/dist/migration-templates/app-fullstack/client/components/ui/bar-chart.tsx +390 -0
  1925. package/dist/migration-templates/app-fullstack/client/components/ui/breadcrumb.tsx +259 -0
  1926. package/dist/migration-templates/app-fullstack/client/components/ui/button.tsx +182 -0
  1927. package/dist/migration-templates/app-fullstack/client/components/ui/calendar.tsx +300 -0
  1928. package/dist/migration-templates/app-fullstack/client/components/ui/card.tsx +129 -0
  1929. package/dist/migration-templates/app-fullstack/client/components/ui/chart.tsx +403 -0
  1930. package/dist/migration-templates/app-fullstack/client/components/ui/checkbox.tsx +97 -0
  1931. package/dist/migration-templates/app-fullstack/client/components/ui/code-block-content.tsx +66 -0
  1932. package/dist/migration-templates/app-fullstack/client/components/ui/date-range-picker.tsx +396 -0
  1933. package/dist/migration-templates/app-fullstack/client/components/ui/dialog.tsx +223 -0
  1934. package/dist/migration-templates/app-fullstack/client/components/ui/dropdown-menu.tsx +284 -0
  1935. package/dist/migration-templates/app-fullstack/client/components/ui/file-dropzone.tsx +395 -0
  1936. package/dist/migration-templates/app-fullstack/client/components/ui/file-input.tsx +166 -0
  1937. package/dist/migration-templates/app-fullstack/client/components/ui/hover-card.tsx +162 -0
  1938. package/dist/migration-templates/app-fullstack/client/components/ui/icon.tsx +133 -0
  1939. package/dist/migration-templates/app-fullstack/client/components/ui/image.tsx +68 -0
  1940. package/dist/migration-templates/app-fullstack/client/components/ui/input.tsx +219 -0
  1941. package/dist/migration-templates/app-fullstack/client/components/ui/label.tsx +55 -0
  1942. package/dist/migration-templates/app-fullstack/client/components/ui/line-chart.tsx +380 -0
  1943. package/dist/migration-templates/app-fullstack/client/components/ui/link.tsx +139 -0
  1944. package/dist/migration-templates/app-fullstack/client/components/ui/navigation-menu.tsx +345 -0
  1945. package/dist/migration-templates/app-fullstack/client/components/ui/pagination.tsx +192 -0
  1946. package/dist/migration-templates/app-fullstack/client/components/ui/pie-chart.tsx +295 -0
  1947. package/dist/migration-templates/app-fullstack/client/components/ui/popover.tsx +162 -0
  1948. package/dist/migration-templates/app-fullstack/client/components/ui/progress.tsx +69 -0
  1949. package/dist/migration-templates/app-fullstack/client/components/ui/radar-chart.tsx +386 -0
  1950. package/dist/migration-templates/app-fullstack/client/components/ui/radial-chart.tsx +402 -0
  1951. package/dist/migration-templates/app-fullstack/client/components/ui/scroll-area.tsx +86 -0
  1952. package/dist/migration-templates/app-fullstack/client/components/ui/select.tsx +229 -0
  1953. package/dist/migration-templates/app-fullstack/client/components/ui/separator.tsx +62 -0
  1954. package/dist/migration-templates/app-fullstack/client/components/ui/sheet.tsx +234 -0
  1955. package/dist/migration-templates/app-fullstack/client/components/ui/sidebar.tsx +974 -0
  1956. package/dist/migration-templates/app-fullstack/client/components/ui/skeleton.tsx +13 -0
  1957. package/dist/migration-templates/app-fullstack/client/components/ui/slider.tsx +198 -0
  1958. package/dist/migration-templates/app-fullstack/client/components/ui/switch.tsx +95 -0
  1959. package/dist/migration-templates/app-fullstack/client/components/ui/table.tsx +145 -0
  1960. package/dist/migration-templates/app-fullstack/client/components/ui/tabs.tsx +87 -0
  1961. package/dist/migration-templates/app-fullstack/client/components/ui/textarea.tsx +148 -0
  1962. package/dist/migration-templates/app-fullstack/client/components/ui/toggle-group.tsx +225 -0
  1963. package/dist/migration-templates/app-fullstack/client/components/ui/toggle.tsx +150 -0
  1964. package/dist/migration-templates/app-fullstack/client/components/ui/tooltip.tsx +175 -0
  1965. package/dist/migration-templates/app-fullstack/client/hooks/useApi.ts +25 -0
  1966. package/dist/migration-templates/app-fullstack/client/hooks/useApiData.ts +10 -0
  1967. package/dist/migration-templates/app-fullstack/client/index.css +131 -0
  1968. package/dist/migration-templates/app-fullstack/client/lib/executeApi.ts +9 -0
  1969. package/dist/migration-templates/app-fullstack/client/lib/utils.ts +6 -0
  1970. package/dist/migration-templates/app-fullstack/client/pages/Home/index.tsx +3 -0
  1971. package/dist/migration-templates/app-fullstack/client/root.tsx +17 -0
  1972. package/dist/migration-templates/app-fullstack/client/router.tsx +48 -0
  1973. package/dist/migration-templates/app-fullstack/client/types/node.d.ts +9 -0
  1974. package/dist/migration-templates/app-fullstack/components.json +21 -0
  1975. package/dist/migration-templates/app-fullstack/css.d.ts +3 -0
  1976. package/dist/migration-templates/app-fullstack/eslint.config.js +113 -0
  1977. package/dist/migration-templates/app-fullstack/package.json +84 -0
  1978. package/dist/migration-templates/app-fullstack/server/.gitkeep +0 -0
  1979. package/dist/migration-templates/app-fullstack/server/apis/index.ts +22 -0
  1980. package/dist/migration-templates/app-fullstack/server/index.ts +2 -0
  1981. package/dist/migration-templates/app-fullstack/tsconfig.client.json +27 -0
  1982. package/dist/migration-templates/app-fullstack/tsconfig.eslint.json +8 -0
  1983. package/dist/migration-templates/app-fullstack/tsconfig.json +25 -0
  1984. package/dist/migration-templates/app-fullstack/tsconfig.server.json +13 -0
  1985. package/dist/migration-templates/app-fullstack/vite.config.ts +17 -0
  1986. package/dist/npm/apply-package-json-substitutions.d.ts +19 -0
  1987. package/dist/npm/apply-package-json-substitutions.d.ts.map +1 -0
  1988. package/dist/npm/apply-package-json-substitutions.js +108 -0
  1989. package/dist/npm/apply-package-json-substitutions.js.map +1 -0
  1990. package/dist/npm/normalize-workspace-protocol-for-npm.d.ts +15 -0
  1991. package/dist/npm/normalize-workspace-protocol-for-npm.d.ts.map +1 -0
  1992. package/dist/npm/normalize-workspace-protocol-for-npm.js +36 -0
  1993. package/dist/npm/normalize-workspace-protocol-for-npm.js.map +1 -0
  1994. package/dist/npm/prepare-package-json-for-cloud-npm.d.ts +8 -0
  1995. package/dist/npm/prepare-package-json-for-cloud-npm.d.ts.map +1 -0
  1996. package/dist/npm/prepare-package-json-for-cloud-npm.js +44 -0
  1997. package/dist/npm/prepare-package-json-for-cloud-npm.js.map +1 -0
  1998. package/dist/npm/rewrite-platform-workspace-deps.d.ts +17 -0
  1999. package/dist/npm/rewrite-platform-workspace-deps.d.ts.map +1 -0
  2000. package/dist/npm/rewrite-platform-workspace-deps.js +37 -0
  2001. package/dist/npm/rewrite-platform-workspace-deps.js.map +1 -0
  2002. package/dist/operations/operation-processor.d.ts +24 -0
  2003. package/dist/operations/operation-processor.d.ts.map +1 -0
  2004. package/dist/operations/operation-processor.js +80 -0
  2005. package/dist/operations/operation-processor.js.map +1 -0
  2006. package/dist/operations/types.d.ts +8 -0
  2007. package/dist/operations/types.d.ts.map +1 -0
  2008. package/dist/operations/types.js +2 -0
  2009. package/dist/operations/types.js.map +1 -0
  2010. package/dist/parsing/bindings.d.ts +1 -1
  2011. package/dist/parsing/bindings.d.ts.map +1 -1
  2012. package/dist/parsing/bindings.js +14 -5
  2013. package/dist/parsing/bindings.js.map +1 -1
  2014. package/dist/parsing/computed/index.d.ts +1 -1
  2015. package/dist/parsing/computed/index.d.ts.map +1 -1
  2016. package/dist/parsing/computed/index.js +1 -1
  2017. package/dist/parsing/computed/index.js.map +1 -1
  2018. package/dist/parsing/computed/to-code-computed.d.ts +2 -1
  2019. package/dist/parsing/computed/to-code-computed.d.ts.map +1 -1
  2020. package/dist/parsing/computed/to-code-computed.js +22 -11
  2021. package/dist/parsing/computed/to-code-computed.js.map +1 -1
  2022. package/dist/parsing/computed/to-value-computed.d.ts +1 -1
  2023. package/dist/parsing/computed/to-value-computed.d.ts.map +1 -1
  2024. package/dist/parsing/computed/to-value-computed.js +19 -7
  2025. package/dist/parsing/computed/to-value-computed.js.map +1 -1
  2026. package/dist/parsing/dim/index.d.ts +1 -1
  2027. package/dist/parsing/dim/index.d.ts.map +1 -1
  2028. package/dist/parsing/dim/index.js +1 -1
  2029. package/dist/parsing/dim/index.js.map +1 -1
  2030. package/dist/parsing/dim/to-value-dimensions.d.ts +2 -1
  2031. package/dist/parsing/dim/to-value-dimensions.d.ts.map +1 -1
  2032. package/dist/parsing/dim/to-value-dimensions.js +4 -3
  2033. package/dist/parsing/dim/to-value-dimensions.js.map +1 -1
  2034. package/dist/parsing/function/index.d.ts +4 -0
  2035. package/dist/parsing/function/index.d.ts.map +1 -0
  2036. package/dist/parsing/function/index.js +7 -0
  2037. package/dist/parsing/function/index.js.map +1 -0
  2038. package/dist/parsing/function/to-code-function.d.ts +2 -0
  2039. package/dist/parsing/function/to-code-function.d.ts.map +1 -0
  2040. package/dist/parsing/function/to-code-function.js +4 -0
  2041. package/dist/parsing/function/to-code-function.js.map +1 -0
  2042. package/dist/parsing/function/to-value-function.d.ts +4 -0
  2043. package/dist/parsing/function/to-value-function.d.ts.map +1 -0
  2044. package/dist/parsing/function/to-value-function.js +33 -0
  2045. package/dist/parsing/function/to-value-function.js.map +1 -0
  2046. package/dist/parsing/ids.d.ts +0 -2
  2047. package/dist/parsing/ids.d.ts.map +1 -1
  2048. package/dist/parsing/ids.js +18 -21
  2049. package/dist/parsing/ids.js.map +1 -1
  2050. package/dist/parsing/imports.d.ts +5 -5
  2051. package/dist/parsing/imports.d.ts.map +1 -1
  2052. package/dist/parsing/imports.js +40 -30
  2053. package/dist/parsing/imports.js.map +1 -1
  2054. package/dist/parsing/index.d.ts +3 -0
  2055. package/dist/parsing/index.d.ts.map +1 -0
  2056. package/dist/parsing/index.js +3 -0
  2057. package/dist/parsing/index.js.map +1 -0
  2058. package/dist/parsing/jsx-utils.d.ts +4 -3
  2059. package/dist/parsing/jsx-utils.d.ts.map +1 -1
  2060. package/dist/parsing/jsx-utils.js +37 -25
  2061. package/dist/parsing/jsx-utils.js.map +1 -1
  2062. package/dist/parsing/jsx.d.ts +25 -11
  2063. package/dist/parsing/jsx.d.ts.map +1 -1
  2064. package/dist/parsing/jsx.js +210 -176
  2065. package/dist/parsing/jsx.js.map +1 -1
  2066. package/dist/parsing/page.d.ts +1 -2
  2067. package/dist/parsing/page.d.ts.map +1 -1
  2068. package/dist/parsing/page.js +297 -122
  2069. package/dist/parsing/page.js.map +1 -1
  2070. package/dist/parsing/parse-tsx-module.d.ts +4 -0
  2071. package/dist/parsing/parse-tsx-module.d.ts.map +1 -0
  2072. package/dist/parsing/parse-tsx-module.js +13 -0
  2073. package/dist/parsing/parse-tsx-module.js.map +1 -0
  2074. package/dist/parsing/properties.d.ts +2 -1
  2075. package/dist/parsing/properties.d.ts.map +1 -1
  2076. package/dist/parsing/properties.js +105 -28
  2077. package/dist/parsing/properties.js.map +1 -1
  2078. package/dist/parsing/sdk-registry.d.ts +17 -0
  2079. package/dist/parsing/sdk-registry.d.ts.map +1 -0
  2080. package/dist/parsing/sdk-registry.js +184 -0
  2081. package/dist/parsing/sdk-registry.js.map +1 -0
  2082. package/dist/parsing/template/index.d.ts +1 -1
  2083. package/dist/parsing/template/index.d.ts.map +1 -1
  2084. package/dist/parsing/template/index.js.map +1 -1
  2085. package/dist/parsing/template/to-code-template.d.ts.map +1 -1
  2086. package/dist/parsing/template/to-code-template.js +1 -2
  2087. package/dist/parsing/template/to-code-template.js.map +1 -1
  2088. package/dist/parsing/type-parsing-registry.d.ts +1 -1
  2089. package/dist/parsing/type-parsing-registry.d.ts.map +1 -1
  2090. package/dist/parsing/type-parsing-registry.js +2 -2
  2091. package/dist/parsing/type-parsing-registry.js.map +1 -1
  2092. package/dist/parsing/types.d.ts +3 -2
  2093. package/dist/parsing/types.d.ts.map +1 -1
  2094. package/dist/parsing/util.d.ts +7 -12
  2095. package/dist/parsing/util.d.ts.map +1 -1
  2096. package/dist/parsing/util.js +98 -81
  2097. package/dist/parsing/util.js.map +1 -1
  2098. package/dist/plugin-options.d.ts +67 -5
  2099. package/dist/plugin-options.d.ts.map +1 -1
  2100. package/dist/plugin-options.js +0 -3
  2101. package/dist/plugin-options.js.map +1 -1
  2102. package/dist/policy-gate-callback-mapper.d.ts +26 -0
  2103. package/dist/policy-gate-callback-mapper.d.ts.map +1 -0
  2104. package/dist/policy-gate-callback-mapper.js +58 -0
  2105. package/dist/policy-gate-callback-mapper.js.map +1 -0
  2106. package/dist/policy-gate-run-registry.d.ts +28 -0
  2107. package/dist/policy-gate-run-registry.d.ts.map +1 -0
  2108. package/dist/policy-gate-run-registry.js +40 -0
  2109. package/dist/policy-gate-run-registry.js.map +1 -0
  2110. package/dist/policy-gate-runner.d.ts +36 -0
  2111. package/dist/policy-gate-runner.d.ts.map +1 -0
  2112. package/dist/policy-gate-runner.js +250 -0
  2113. package/dist/policy-gate-runner.js.map +1 -0
  2114. package/dist/refactor/blocks.d.ts +1 -2
  2115. package/dist/refactor/blocks.d.ts.map +1 -1
  2116. package/dist/refactor/blocks.js +3 -70
  2117. package/dist/refactor/blocks.js.map +1 -1
  2118. package/dist/refactor/entities.d.ts +6 -0
  2119. package/dist/refactor/entities.d.ts.map +1 -0
  2120. package/dist/refactor/entities.js +65 -0
  2121. package/dist/refactor/entities.js.map +1 -0
  2122. package/dist/refactor/javascript.d.ts +1 -1
  2123. package/dist/refactor/javascript.d.ts.map +1 -1
  2124. package/dist/refactor/javascript.js +103 -2
  2125. package/dist/refactor/javascript.js.map +1 -1
  2126. package/dist/rename-manager.d.ts +3 -2
  2127. package/dist/rename-manager.d.ts.map +1 -1
  2128. package/dist/rename-manager.js +35 -14
  2129. package/dist/rename-manager.js.map +1 -1
  2130. package/dist/resolver.d.ts +4 -0
  2131. package/dist/resolver.d.ts.map +1 -0
  2132. package/dist/resolver.js +27 -0
  2133. package/dist/resolver.js.map +1 -0
  2134. package/dist/router-parser-metrics.d.ts +2 -0
  2135. package/dist/router-parser-metrics.d.ts.map +1 -0
  2136. package/dist/router-parser-metrics.js +13 -0
  2137. package/dist/router-parser-metrics.js.map +1 -0
  2138. package/dist/router-parser.d.ts +41 -0
  2139. package/dist/router-parser.d.ts.map +1 -0
  2140. package/dist/router-parser.js +894 -0
  2141. package/dist/router-parser.js.map +1 -0
  2142. package/dist/scan-scope-merge.d.ts +16 -0
  2143. package/dist/scan-scope-merge.d.ts.map +1 -0
  2144. package/dist/scan-scope-merge.js +90 -0
  2145. package/dist/scan-scope-merge.js.map +1 -0
  2146. package/dist/server-rpc/client.d.ts +11 -0
  2147. package/dist/server-rpc/client.d.ts.map +1 -0
  2148. package/dist/server-rpc/client.js +42 -0
  2149. package/dist/server-rpc/client.js.map +1 -0
  2150. package/dist/server-rpc/handlers.d.ts +3 -0
  2151. package/dist/server-rpc/handlers.d.ts.map +1 -0
  2152. package/dist/server-rpc/handlers.js.map +1 -0
  2153. package/dist/server-rpc/index.d.ts +77 -0
  2154. package/dist/server-rpc/index.d.ts.map +1 -0
  2155. package/dist/server-rpc/index.js +344 -0
  2156. package/dist/server-rpc/index.js.map +1 -0
  2157. package/dist/server-rpc/request-abort-context.d.ts +3 -0
  2158. package/dist/server-rpc/request-abort-context.d.ts.map +1 -0
  2159. package/dist/server-rpc/request-abort-context.js +23 -0
  2160. package/dist/server-rpc/request-abort-context.js.map +1 -0
  2161. package/dist/server-rpc/rpc-invalidate-metrics.d.ts +20 -0
  2162. package/dist/server-rpc/rpc-invalidate-metrics.d.ts.map +1 -0
  2163. package/dist/server-rpc/rpc-invalidate-metrics.js +86 -0
  2164. package/dist/server-rpc/rpc-invalidate-metrics.js.map +1 -0
  2165. package/dist/snapshot-routes.d.ts +18 -0
  2166. package/dist/snapshot-routes.d.ts.map +1 -0
  2167. package/dist/snapshot-routes.js +247 -0
  2168. package/dist/snapshot-routes.js.map +1 -0
  2169. package/dist/socket-manager.d.ts +145 -17
  2170. package/dist/socket-manager.d.ts.map +1 -1
  2171. package/dist/socket-manager.js +1730 -82
  2172. package/dist/socket-manager.js.map +1 -1
  2173. package/dist/source-tracker.d.ts +23 -158
  2174. package/dist/source-tracker.d.ts.map +1 -1
  2175. package/dist/source-tracker.js +78 -877
  2176. package/dist/source-tracker.js.map +1 -1
  2177. package/dist/sync-service/checkpoint-result.d.ts +22 -0
  2178. package/dist/sync-service/checkpoint-result.d.ts.map +1 -0
  2179. package/dist/sync-service/checkpoint-result.js +22 -0
  2180. package/dist/sync-service/checkpoint-result.js.map +1 -0
  2181. package/dist/sync-service/download.d.ts +23 -6
  2182. package/dist/sync-service/download.d.ts.map +1 -1
  2183. package/dist/sync-service/download.js +234 -33
  2184. package/dist/sync-service/download.js.map +1 -1
  2185. package/dist/sync-service/draft-helpers.d.ts +17 -1
  2186. package/dist/sync-service/draft-helpers.d.ts.map +1 -1
  2187. package/dist/sync-service/draft-helpers.js +193 -114
  2188. package/dist/sync-service/draft-helpers.js.map +1 -1
  2189. package/dist/sync-service/draft-reconcile.d.ts +22 -0
  2190. package/dist/sync-service/draft-reconcile.d.ts.map +1 -0
  2191. package/dist/sync-service/draft-reconcile.js +24 -0
  2192. package/dist/sync-service/draft-reconcile.js.map +1 -0
  2193. package/dist/sync-service/draft-state-report-metrics.d.ts +2 -0
  2194. package/dist/sync-service/draft-state-report-metrics.d.ts.map +1 -0
  2195. package/dist/sync-service/draft-state-report-metrics.js +27 -0
  2196. package/dist/sync-service/draft-state-report-metrics.js.map +1 -0
  2197. package/dist/sync-service/hash-cache.d.ts +1 -0
  2198. package/dist/sync-service/hash-cache.d.ts.map +1 -1
  2199. package/dist/sync-service/hash-cache.js +4 -0
  2200. package/dist/sync-service/hash-cache.js.map +1 -1
  2201. package/dist/sync-service/hash-dir-tree.d.ts +1 -1
  2202. package/dist/sync-service/hash-dir-tree.d.ts.map +1 -1
  2203. package/dist/sync-service/hash-dir-tree.js +3 -3
  2204. package/dist/sync-service/hash-dir-tree.js.map +1 -1
  2205. package/dist/sync-service/index.d.ts +250 -20
  2206. package/dist/sync-service/index.d.ts.map +1 -1
  2207. package/dist/sync-service/index.js +868 -123
  2208. package/dist/sync-service/index.js.map +1 -1
  2209. package/dist/sync-service/list-dir.d.ts +2 -2
  2210. package/dist/sync-service/list-dir.d.ts.map +1 -1
  2211. package/dist/sync-service/list-dir.js +93 -29
  2212. package/dist/sync-service/list-dir.js.map +1 -1
  2213. package/dist/sync-service/snapshot/take-snapshot.d.ts +1 -1
  2214. package/dist/sync-service/snapshot/take-snapshot.d.ts.map +1 -1
  2215. package/dist/sync-service/snapshot/take-snapshot.js +4 -8
  2216. package/dist/sync-service/snapshot/take-snapshot.js.map +1 -1
  2217. package/dist/sync-service/snapshot/upload-snapshot.d.ts +2 -2
  2218. package/dist/sync-service/snapshot/upload-snapshot.d.ts.map +1 -1
  2219. package/dist/sync-service/snapshot/upload-snapshot.js +21 -1
  2220. package/dist/sync-service/snapshot/upload-snapshot.js.map +1 -1
  2221. package/dist/test-setup.d.ts +2 -0
  2222. package/dist/test-setup.d.ts.map +1 -0
  2223. package/dist/test-setup.js +21 -0
  2224. package/dist/test-setup.js.map +1 -0
  2225. package/dist/util/ignore-patterns.d.ts +9 -0
  2226. package/dist/util/ignore-patterns.d.ts.map +1 -0
  2227. package/dist/util/ignore-patterns.js +53 -0
  2228. package/dist/util/ignore-patterns.js.map +1 -0
  2229. package/dist/util/log-sanitizer.d.ts +44 -0
  2230. package/dist/util/log-sanitizer.d.ts.map +1 -0
  2231. package/dist/util/log-sanitizer.js +209 -0
  2232. package/dist/util/log-sanitizer.js.map +1 -0
  2233. package/dist/util/logger.d.ts +58 -17
  2234. package/dist/util/logger.d.ts.map +1 -1
  2235. package/dist/util/logger.js +617 -40
  2236. package/dist/util/logger.js.map +1 -1
  2237. package/dist/util/open-api.d.ts +9 -0
  2238. package/dist/util/open-api.d.ts.map +1 -0
  2239. package/dist/util/open-api.js +2 -0
  2240. package/dist/util/open-api.js.map +1 -0
  2241. package/dist/util/operation-queue.d.ts +7 -1
  2242. package/dist/util/operation-queue.d.ts.map +1 -1
  2243. package/dist/util/operation-queue.js +5 -0
  2244. package/dist/util/operation-queue.js.map +1 -1
  2245. package/dist/util/summarize-for-logging.d.ts +14 -0
  2246. package/dist/util/summarize-for-logging.d.ts.map +1 -0
  2247. package/dist/util/summarize-for-logging.js +94 -0
  2248. package/dist/util/summarize-for-logging.js.map +1 -0
  2249. package/dist/util.d.ts +17 -18
  2250. package/dist/util.d.ts.map +1 -1
  2251. package/dist/util.js +46 -112
  2252. package/dist/util.js.map +1 -1
  2253. package/dist/virtual-modules.d.ts +5 -0
  2254. package/dist/virtual-modules.d.ts.map +1 -0
  2255. package/dist/virtual-modules.js +5 -0
  2256. package/dist/virtual-modules.js.map +1 -0
  2257. package/dist/vite-plugin-yaml-types.d.ts +15 -0
  2258. package/dist/vite-plugin-yaml-types.d.ts.map +1 -0
  2259. package/dist/vite-plugin-yaml-types.js +187 -0
  2260. package/dist/vite-plugin-yaml-types.js.map +1 -0
  2261. package/package.json +131 -65
  2262. package/dist/ai-service/artifacts/bolt.d.ts +0 -8
  2263. package/dist/ai-service/artifacts/bolt.d.ts.map +0 -1
  2264. package/dist/ai-service/artifacts/bolt.js +0 -34
  2265. package/dist/ai-service/artifacts/bolt.js.map +0 -1
  2266. package/dist/ai-service/eval/template-renderer.d.ts +0 -13
  2267. package/dist/ai-service/eval/template-renderer.d.ts.map +0 -1
  2268. package/dist/ai-service/eval/template-renderer.js +0 -67
  2269. package/dist/ai-service/eval/template-renderer.js.map +0 -1
  2270. package/dist/ai-service/integrations/const.d.ts +0 -41
  2271. package/dist/ai-service/integrations/const.d.ts.map +0 -1
  2272. package/dist/ai-service/integrations/const.js +0 -76
  2273. package/dist/ai-service/integrations/const.js.map +0 -1
  2274. package/dist/ai-service/integrations/from-prompt-context.d.ts +0 -4
  2275. package/dist/ai-service/integrations/from-prompt-context.d.ts.map +0 -1
  2276. package/dist/ai-service/integrations/from-prompt-context.js +0 -56
  2277. package/dist/ai-service/integrations/from-prompt-context.js.map +0 -1
  2278. package/dist/ai-service/integrations/to-sdk-prompt.d.ts +0 -3
  2279. package/dist/ai-service/integrations/to-sdk-prompt.d.ts.map +0 -1
  2280. package/dist/ai-service/integrations/to-sdk-prompt.js +0 -45
  2281. package/dist/ai-service/integrations/to-sdk-prompt.js.map +0 -1
  2282. package/dist/ai-service/integrations/types.d.ts +0 -31
  2283. package/dist/ai-service/integrations/types.d.ts.map +0 -1
  2284. package/dist/ai-service/integrations/types.js.map +0 -1
  2285. package/dist/ai-service/prompts/draft-subprompts/superblocks-api-draft.d.ts +0 -2
  2286. package/dist/ai-service/prompts/draft-subprompts/superblocks-api-draft.d.ts.map +0 -1
  2287. package/dist/ai-service/prompts/draft-subprompts/superblocks-api-draft.js +0 -386
  2288. package/dist/ai-service/prompts/draft-subprompts/superblocks-api-draft.js.map +0 -1
  2289. package/dist/ai-service/prompts/draft-subprompts/superblocks-layouts-with-grid-examples.d.ts +0 -2
  2290. package/dist/ai-service/prompts/draft-subprompts/superblocks-layouts-with-grid-examples.d.ts.map +0 -1
  2291. package/dist/ai-service/prompts/draft-subprompts/superblocks-layouts-with-grid-examples.js +0 -219
  2292. package/dist/ai-service/prompts/draft-subprompts/superblocks-layouts-with-grid-examples.js.map +0 -1
  2293. package/dist/ai-service/prompts/generated/index.d.ts +0 -4
  2294. package/dist/ai-service/prompts/generated/index.d.ts.map +0 -1
  2295. package/dist/ai-service/prompts/generated/index.js +0 -6
  2296. package/dist/ai-service/prompts/generated/index.js.map +0 -1
  2297. package/dist/ai-service/prompts/generated/library-components/SbButtonPropsDocs.d.ts +0 -2
  2298. package/dist/ai-service/prompts/generated/library-components/SbButtonPropsDocs.d.ts.map +0 -1
  2299. package/dist/ai-service/prompts/generated/library-components/SbButtonPropsDocs.js +0 -6
  2300. package/dist/ai-service/prompts/generated/library-components/SbButtonPropsDocs.js.map +0 -1
  2301. package/dist/ai-service/prompts/generated/library-components/SbCheckboxPropsDocs.d.ts +0 -2
  2302. package/dist/ai-service/prompts/generated/library-components/SbCheckboxPropsDocs.d.ts.map +0 -1
  2303. package/dist/ai-service/prompts/generated/library-components/SbCheckboxPropsDocs.js +0 -6
  2304. package/dist/ai-service/prompts/generated/library-components/SbCheckboxPropsDocs.js.map +0 -1
  2305. package/dist/ai-service/prompts/generated/library-components/SbColumnPropsDocs.d.ts +0 -2
  2306. package/dist/ai-service/prompts/generated/library-components/SbColumnPropsDocs.d.ts.map +0 -1
  2307. package/dist/ai-service/prompts/generated/library-components/SbColumnPropsDocs.js +0 -6
  2308. package/dist/ai-service/prompts/generated/library-components/SbColumnPropsDocs.js.map +0 -1
  2309. package/dist/ai-service/prompts/generated/library-components/SbContainerPropsDocs.d.ts +0 -2
  2310. package/dist/ai-service/prompts/generated/library-components/SbContainerPropsDocs.d.ts.map +0 -1
  2311. package/dist/ai-service/prompts/generated/library-components/SbContainerPropsDocs.js +0 -6
  2312. package/dist/ai-service/prompts/generated/library-components/SbContainerPropsDocs.js.map +0 -1
  2313. package/dist/ai-service/prompts/generated/library-components/SbDatePickerPropsDocs.d.ts +0 -2
  2314. package/dist/ai-service/prompts/generated/library-components/SbDatePickerPropsDocs.d.ts.map +0 -1
  2315. package/dist/ai-service/prompts/generated/library-components/SbDatePickerPropsDocs.js +0 -6
  2316. package/dist/ai-service/prompts/generated/library-components/SbDatePickerPropsDocs.js.map +0 -1
  2317. package/dist/ai-service/prompts/generated/library-components/SbDropdownPropsDocs.d.ts +0 -2
  2318. package/dist/ai-service/prompts/generated/library-components/SbDropdownPropsDocs.d.ts.map +0 -1
  2319. package/dist/ai-service/prompts/generated/library-components/SbDropdownPropsDocs.js +0 -6
  2320. package/dist/ai-service/prompts/generated/library-components/SbDropdownPropsDocs.js.map +0 -1
  2321. package/dist/ai-service/prompts/generated/library-components/SbIconPropsDocs.d.ts +0 -2
  2322. package/dist/ai-service/prompts/generated/library-components/SbIconPropsDocs.d.ts.map +0 -1
  2323. package/dist/ai-service/prompts/generated/library-components/SbIconPropsDocs.js +0 -6
  2324. package/dist/ai-service/prompts/generated/library-components/SbIconPropsDocs.js.map +0 -1
  2325. package/dist/ai-service/prompts/generated/library-components/SbImagePropsDocs.d.ts +0 -2
  2326. package/dist/ai-service/prompts/generated/library-components/SbImagePropsDocs.d.ts.map +0 -1
  2327. package/dist/ai-service/prompts/generated/library-components/SbImagePropsDocs.js +0 -6
  2328. package/dist/ai-service/prompts/generated/library-components/SbImagePropsDocs.js.map +0 -1
  2329. package/dist/ai-service/prompts/generated/library-components/SbInputPropsDocs.d.ts +0 -2
  2330. package/dist/ai-service/prompts/generated/library-components/SbInputPropsDocs.d.ts.map +0 -1
  2331. package/dist/ai-service/prompts/generated/library-components/SbInputPropsDocs.js +0 -6
  2332. package/dist/ai-service/prompts/generated/library-components/SbInputPropsDocs.js.map +0 -1
  2333. package/dist/ai-service/prompts/generated/library-components/SbModalPropsDocs.d.ts +0 -2
  2334. package/dist/ai-service/prompts/generated/library-components/SbModalPropsDocs.d.ts.map +0 -1
  2335. package/dist/ai-service/prompts/generated/library-components/SbModalPropsDocs.js +0 -6
  2336. package/dist/ai-service/prompts/generated/library-components/SbModalPropsDocs.js.map +0 -1
  2337. package/dist/ai-service/prompts/generated/library-components/SbPagePropsDocs.d.ts +0 -2
  2338. package/dist/ai-service/prompts/generated/library-components/SbPagePropsDocs.d.ts.map +0 -1
  2339. package/dist/ai-service/prompts/generated/library-components/SbPagePropsDocs.js +0 -6
  2340. package/dist/ai-service/prompts/generated/library-components/SbPagePropsDocs.js.map +0 -1
  2341. package/dist/ai-service/prompts/generated/library-components/SbSectionPropsDocs.d.ts +0 -2
  2342. package/dist/ai-service/prompts/generated/library-components/SbSectionPropsDocs.d.ts.map +0 -1
  2343. package/dist/ai-service/prompts/generated/library-components/SbSectionPropsDocs.js +0 -6
  2344. package/dist/ai-service/prompts/generated/library-components/SbSectionPropsDocs.js.map +0 -1
  2345. package/dist/ai-service/prompts/generated/library-components/SbSlideoutPropsDocs.d.ts +0 -2
  2346. package/dist/ai-service/prompts/generated/library-components/SbSlideoutPropsDocs.d.ts.map +0 -1
  2347. package/dist/ai-service/prompts/generated/library-components/SbSlideoutPropsDocs.js +0 -6
  2348. package/dist/ai-service/prompts/generated/library-components/SbSlideoutPropsDocs.js.map +0 -1
  2349. package/dist/ai-service/prompts/generated/library-components/SbSwitchPropsDocs.d.ts +0 -2
  2350. package/dist/ai-service/prompts/generated/library-components/SbSwitchPropsDocs.d.ts.map +0 -1
  2351. package/dist/ai-service/prompts/generated/library-components/SbSwitchPropsDocs.js +0 -6
  2352. package/dist/ai-service/prompts/generated/library-components/SbSwitchPropsDocs.js.map +0 -1
  2353. package/dist/ai-service/prompts/generated/library-components/SbTablePropsDocs.d.ts +0 -2
  2354. package/dist/ai-service/prompts/generated/library-components/SbTablePropsDocs.d.ts.map +0 -1
  2355. package/dist/ai-service/prompts/generated/library-components/SbTablePropsDocs.js +0 -6
  2356. package/dist/ai-service/prompts/generated/library-components/SbTablePropsDocs.js.map +0 -1
  2357. package/dist/ai-service/prompts/generated/library-components/SbTextPropsDocs.d.ts +0 -2
  2358. package/dist/ai-service/prompts/generated/library-components/SbTextPropsDocs.d.ts.map +0 -1
  2359. package/dist/ai-service/prompts/generated/library-components/SbTextPropsDocs.js +0 -6
  2360. package/dist/ai-service/prompts/generated/library-components/SbTextPropsDocs.js.map +0 -1
  2361. package/dist/ai-service/prompts/generated/library-components/index.d.ts +0 -17
  2362. package/dist/ai-service/prompts/generated/library-components/index.d.ts.map +0 -1
  2363. package/dist/ai-service/prompts/generated/library-components/index.js +0 -19
  2364. package/dist/ai-service/prompts/generated/library-components/index.js.map +0 -1
  2365. package/dist/ai-service/prompts/generated/library-typedefs/Dim.d.ts +0 -2
  2366. package/dist/ai-service/prompts/generated/library-typedefs/Dim.d.ts.map +0 -1
  2367. package/dist/ai-service/prompts/generated/library-typedefs/Dim.js +0 -6
  2368. package/dist/ai-service/prompts/generated/library-typedefs/Dim.js.map +0 -1
  2369. package/dist/ai-service/prompts/generated/library-typedefs/SbEventFlow.d.ts +0 -2
  2370. package/dist/ai-service/prompts/generated/library-typedefs/SbEventFlow.d.ts.map +0 -1
  2371. package/dist/ai-service/prompts/generated/library-typedefs/SbEventFlow.js +0 -6
  2372. package/dist/ai-service/prompts/generated/library-typedefs/SbEventFlow.js.map +0 -1
  2373. package/dist/ai-service/prompts/generated/library-typedefs/index.d.ts +0 -3
  2374. package/dist/ai-service/prompts/generated/library-typedefs/index.d.ts.map +0 -1
  2375. package/dist/ai-service/prompts/generated/library-typedefs/index.js +0 -5
  2376. package/dist/ai-service/prompts/generated/library-typedefs/index.js.map +0 -1
  2377. package/dist/ai-service/prompts/generated/subprompts/index.d.ts +0 -11
  2378. package/dist/ai-service/prompts/generated/subprompts/index.d.ts.map +0 -1
  2379. package/dist/ai-service/prompts/generated/subprompts/index.js +0 -13
  2380. package/dist/ai-service/prompts/generated/subprompts/index.js.map +0 -1
  2381. package/dist/ai-service/prompts/generated/subprompts/superblocks-api.d.ts +0 -2
  2382. package/dist/ai-service/prompts/generated/subprompts/superblocks-api.d.ts.map +0 -1
  2383. package/dist/ai-service/prompts/generated/subprompts/superblocks-api.js +0 -6
  2384. package/dist/ai-service/prompts/generated/subprompts/superblocks-api.js.map +0 -1
  2385. package/dist/ai-service/prompts/generated/subprompts/superblocks-components-rules.d.ts +0 -2
  2386. package/dist/ai-service/prompts/generated/subprompts/superblocks-components-rules.d.ts.map +0 -1
  2387. package/dist/ai-service/prompts/generated/subprompts/superblocks-components-rules.js +0 -6
  2388. package/dist/ai-service/prompts/generated/subprompts/superblocks-components-rules.js.map +0 -1
  2389. package/dist/ai-service/prompts/generated/subprompts/superblocks-custom-components.d.ts +0 -2
  2390. package/dist/ai-service/prompts/generated/subprompts/superblocks-custom-components.d.ts.map +0 -1
  2391. package/dist/ai-service/prompts/generated/subprompts/superblocks-custom-components.js +0 -6
  2392. package/dist/ai-service/prompts/generated/subprompts/superblocks-custom-components.js.map +0 -1
  2393. package/dist/ai-service/prompts/generated/subprompts/superblocks-event-flow.d.ts +0 -2
  2394. package/dist/ai-service/prompts/generated/subprompts/superblocks-event-flow.d.ts.map +0 -1
  2395. package/dist/ai-service/prompts/generated/subprompts/superblocks-event-flow.js +0 -6
  2396. package/dist/ai-service/prompts/generated/subprompts/superblocks-event-flow.js.map +0 -1
  2397. package/dist/ai-service/prompts/generated/subprompts/superblocks-layouts.d.ts +0 -2
  2398. package/dist/ai-service/prompts/generated/subprompts/superblocks-layouts.d.ts.map +0 -1
  2399. package/dist/ai-service/prompts/generated/subprompts/superblocks-layouts.js +0 -6
  2400. package/dist/ai-service/prompts/generated/subprompts/superblocks-layouts.js.map +0 -1
  2401. package/dist/ai-service/prompts/generated/subprompts/superblocks-page.d.ts +0 -2
  2402. package/dist/ai-service/prompts/generated/subprompts/superblocks-page.d.ts.map +0 -1
  2403. package/dist/ai-service/prompts/generated/subprompts/superblocks-page.js +0 -6
  2404. package/dist/ai-service/prompts/generated/subprompts/superblocks-page.js.map +0 -1
  2405. package/dist/ai-service/prompts/generated/subprompts/superblocks-routes.d.ts +0 -2
  2406. package/dist/ai-service/prompts/generated/subprompts/superblocks-routes.d.ts.map +0 -1
  2407. package/dist/ai-service/prompts/generated/subprompts/superblocks-routes.js +0 -6
  2408. package/dist/ai-service/prompts/generated/subprompts/superblocks-routes.js.map +0 -1
  2409. package/dist/ai-service/prompts/generated/subprompts/superblocks-state.d.ts +0 -2
  2410. package/dist/ai-service/prompts/generated/subprompts/superblocks-state.d.ts.map +0 -1
  2411. package/dist/ai-service/prompts/generated/subprompts/superblocks-state.js +0 -6
  2412. package/dist/ai-service/prompts/generated/subprompts/superblocks-state.js.map +0 -1
  2413. package/dist/ai-service/prompts/generated/subprompts/superblocks-theming.d.ts +0 -2
  2414. package/dist/ai-service/prompts/generated/subprompts/superblocks-theming.d.ts.map +0 -1
  2415. package/dist/ai-service/prompts/generated/subprompts/superblocks-theming.js +0 -6
  2416. package/dist/ai-service/prompts/generated/subprompts/superblocks-theming.js.map +0 -1
  2417. package/dist/ai-service/prompts/generated/subprompts/system.d.ts +0 -2
  2418. package/dist/ai-service/prompts/generated/subprompts/system.d.ts.map +0 -1
  2419. package/dist/ai-service/prompts/generated/subprompts/system.js +0 -6
  2420. package/dist/ai-service/prompts/generated/subprompts/system.js.map +0 -1
  2421. package/dist/ai-service/prompts/markdown-loader.d.ts +0 -10
  2422. package/dist/ai-service/prompts/markdown-loader.d.ts.map +0 -1
  2423. package/dist/ai-service/prompts/markdown-loader.js +0 -71
  2424. package/dist/ai-service/prompts/markdown-loader.js.map +0 -1
  2425. package/dist/ai-service/prompts/system.d.ts +0 -2
  2426. package/dist/ai-service/prompts/system.d.ts.map +0 -1
  2427. package/dist/ai-service/prompts/system.js +0 -152
  2428. package/dist/ai-service/prompts/system.js.map +0 -1
  2429. package/dist/ai-service/result-buffer/bolt.d.ts +0 -15
  2430. package/dist/ai-service/result-buffer/bolt.d.ts.map +0 -1
  2431. package/dist/ai-service/result-buffer/bolt.js +0 -73
  2432. package/dist/ai-service/result-buffer/bolt.js.map +0 -1
  2433. package/dist/ai-service/result-buffer/shared.d.ts +0 -13
  2434. package/dist/ai-service/result-buffer/shared.d.ts.map +0 -1
  2435. package/dist/ai-service/result-buffer/shared.js +0 -7
  2436. package/dist/ai-service/result-buffer/shared.js.map +0 -1
  2437. package/dist/ai-service/transform/add-metadata-to-api-yaml/transformer.d.ts +0 -21
  2438. package/dist/ai-service/transform/add-metadata-to-api-yaml/transformer.d.ts.map +0 -1
  2439. package/dist/ai-service/transform/add-metadata-to-api-yaml/transformer.js +0 -48
  2440. package/dist/ai-service/transform/add-metadata-to-api-yaml/transformer.js.map +0 -1
  2441. package/dist/binding-extraction/extract-js-identifiers.d.ts +0 -19
  2442. package/dist/binding-extraction/extract-js-identifiers.d.ts.map +0 -1
  2443. package/dist/binding-extraction/extract-js-identifiers.js +0 -161
  2444. package/dist/binding-extraction/extract-js-identifiers.js.map +0 -1
  2445. package/dist/binding-extraction/extract-py-identifiers.d.ts +0 -4
  2446. package/dist/binding-extraction/extract-py-identifiers.d.ts.map +0 -1
  2447. package/dist/binding-extraction/extract-py-identifiers.js +0 -161
  2448. package/dist/binding-extraction/extract-py-identifiers.js.map +0 -1
  2449. package/dist/parsing/entity/index.d.ts +0 -7
  2450. package/dist/parsing/entity/index.d.ts.map +0 -1
  2451. package/dist/parsing/entity/index.js +0 -7
  2452. package/dist/parsing/entity/index.js.map +0 -1
  2453. package/dist/parsing/entity/to-code-entity.d.ts +0 -3
  2454. package/dist/parsing/entity/to-code-entity.d.ts.map +0 -1
  2455. package/dist/parsing/entity/to-code-entity.js +0 -41
  2456. package/dist/parsing/entity/to-code-entity.js.map +0 -1
  2457. package/dist/parsing/entity/to-value-entity.d.ts +0 -8
  2458. package/dist/parsing/entity/to-value-entity.d.ts.map +0 -1
  2459. package/dist/parsing/entity/to-value-entity.js +0 -120
  2460. package/dist/parsing/entity/to-value-entity.js.map +0 -1
  2461. package/dist/parsing/events/index.d.ts +0 -5
  2462. package/dist/parsing/events/index.d.ts.map +0 -1
  2463. package/dist/parsing/events/index.js +0 -7
  2464. package/dist/parsing/events/index.js.map +0 -1
  2465. package/dist/parsing/events/to-code-events.d.ts +0 -3
  2466. package/dist/parsing/events/to-code-events.d.ts.map +0 -1
  2467. package/dist/parsing/events/to-code-events.js +0 -114
  2468. package/dist/parsing/events/to-code-events.js.map +0 -1
  2469. package/dist/parsing/events/to-value-events.d.ts +0 -6
  2470. package/dist/parsing/events/to-value-events.d.ts.map +0 -1
  2471. package/dist/parsing/events/to-value-events.js +0 -221
  2472. package/dist/parsing/events/to-value-events.js.map +0 -1
  2473. package/dist/parsing/scope.d.ts +0 -90
  2474. package/dist/parsing/scope.d.ts.map +0 -1
  2475. package/dist/parsing/scope.js +0 -669
  2476. package/dist/parsing/scope.js.map +0 -1
  2477. package/dist/parsing/theme.d.ts +0 -3
  2478. package/dist/parsing/theme.d.ts.map +0 -1
  2479. package/dist/parsing/theme.js +0 -87
  2480. package/dist/parsing/theme.js.map +0 -1
  2481. package/dist/refactor-jsx.d.ts +0 -28
  2482. package/dist/refactor-jsx.d.ts.map +0 -1
  2483. package/dist/refactor-jsx.js +0 -77
  2484. package/dist/refactor-jsx.js.map +0 -1
  2485. package/dist/routing.d.ts +0 -6
  2486. package/dist/routing.d.ts.map +0 -1
  2487. package/dist/routing.js +0 -76
  2488. package/dist/routing.js.map +0 -1
  2489. package/dist/sb-scope-manager.d.ts +0 -102
  2490. package/dist/sb-scope-manager.d.ts.map +0 -1
  2491. package/dist/sb-scope-manager.js +0 -507
  2492. package/dist/sb-scope-manager.js.map +0 -1
  2493. package/dist/sync-service/server-rpc/client.d.ts +0 -13
  2494. package/dist/sync-service/server-rpc/client.d.ts.map +0 -1
  2495. package/dist/sync-service/server-rpc/client.js +0 -65
  2496. package/dist/sync-service/server-rpc/client.js.map +0 -1
  2497. package/dist/sync-service/server-rpc/handlers.d.ts +0 -3
  2498. package/dist/sync-service/server-rpc/handlers.d.ts.map +0 -1
  2499. package/dist/sync-service/server-rpc/handlers.js.map +0 -1
  2500. package/dist/util/tracing.d.ts +0 -4
  2501. package/dist/util/tracing.d.ts.map +0 -1
  2502. package/dist/util/tracing.js +0 -56
  2503. package/dist/util/tracing.js.map +0 -1
  2504. /package/dist/ai-service/{integrations → agent/subagents/apis}/types.js +0 -0
  2505. /package/dist/{sync-service/server-rpc → server-rpc}/handlers.js +0 -0
@@ -0,0 +1,2461 @@
1
+ import { execFile } from "node:child_process";
2
+ import { constants as fsConstants } from "node:fs";
3
+ import { chmod, link, mkdir, open, readFile, rename, stat, unlink, writeFile, } from "node:fs/promises";
4
+ import * as path from "node:path";
5
+ import { promisify } from "node:util";
6
+ import ini from "ini";
7
+ import { z } from "zod";
8
+ import { bucketNpmRegistryHost, NPM_REGISTRY_SPAN, NPM_REGISTRY_SPAN_ATTR, npmRegistryEmitter, withNpmRegistrySpan, } from "@superblocksteam/telemetry";
9
+ import { getLogger } from "../../util/logger.js";
10
+ const execFileAsync = promisify(execFile);
11
+ /**
12
+ * Wire schema for the `{ registries: [...] }` envelope returned by
13
+ * `GET /api/v1/organizations/:orgId/npm-registry`. Used by the client's
14
+ * defensive parse so a malformed payload routes to `serveStale…` instead
15
+ * of crashing the install path.
16
+ *
17
+ * The refinements (no embedded C0 control chars in any string that flows
18
+ * into `.npmrc`, scope matches npm's grammar, registry URL is http(s)) are the
19
+ * CLI's last line of defense against a malicious admin or buggy server. The
20
+ * scheme is intentionally not pinned to https here: `isSuperblocksNpmProxyUrl`
21
+ * requires the row's origin to equal the client's own `baseUrl` before the
22
+ * login token is stamped, so an http proxy URL is only ever accepted when the
23
+ * client already reaches its server over http (cloud-prem's internal cluster
24
+ * service URL, local dev, the E2E fixture), never a foreign host.
25
+ * The server validates the same shape on write, but `.npmrc` synthesis is
26
+ * security-sensitive enough that we re-validate at read time too.
27
+ */
28
+ // eslint-disable-next-line no-control-regex
29
+ const noControlChars = (s) => !/[\x00-\x1f]/.test(s);
30
+ // Mirrors the server's npm scope grammar: must start with `@`, then a
31
+ // lowercase letter/digit, then up to 254 lowercase letters/digits/`._-`.
32
+ const NPM_SCOPE_RE = /^@[a-z0-9][a-z0-9._-]{0,254}$/;
33
+ const registryEntrySchema = z.object({
34
+ id: z.string().uuid(),
35
+ scope: z
36
+ .string()
37
+ .refine(noControlChars, "scope contains a C0 control character")
38
+ .refine((s) => NPM_SCOPE_RE.test(s), "scope is not a valid npm scope")
39
+ .nullable(),
40
+ registryUrl: z
41
+ .string()
42
+ .url()
43
+ .refine(noControlChars, "registryUrl contains a C0 control character")
44
+ .refine((s) => s.startsWith("https://") || s.startsWith("http://"), "registryUrl must be http(s)"),
45
+ // No token on the wire. `registryUrl` is the Superblocks npm proxy URL the
46
+ // server rewrites each row to (see the server's `/npm-registry/config`
47
+ // route); the CLI authenticates to the proxy with the machine's own login
48
+ // token, which it stamps in locally (see `registriesToConfig`). The
49
+ // customer's upstream registry password is held only on the server. Any
50
+ // `token` field an older server still emits is ignored: this schema strips
51
+ // unknown keys rather than rejecting them.
52
+ });
53
+ const registryListSchema = z.object({
54
+ registries: z.array(registryEntrySchema),
55
+ /**
56
+ * Org-level npm policy field from APPS-4250. Optional on the wire because
57
+ * the server only includes it when the `superblocks.npm-registry.enabled`
58
+ * LD flag is on; an older server or a flag-off response just omits the
59
+ * field. Treated as `undefined` everywhere downstream so consumers can
60
+ * default to "scripts allowed" (today's behaviour) without a special
61
+ * code path.
62
+ */
63
+ npmAllowInstallScripts: z.boolean().optional(),
64
+ });
65
+ /**
66
+ * Wire envelope every Superblocks server endpoint wraps its JSON response in
67
+ * (`ResponseDto` in `packages/server/src/dto/response.ts`). We only need
68
+ * `data` here; `responseMeta` is unused for this endpoint and intentionally
69
+ * passes through unparsed. The outer `passthrough()` lets future
70
+ * `responseMeta`-shape drift not break the npm-registry path.
71
+ */
72
+ const envelopeSchema = z
73
+ .object({
74
+ data: z.unknown(),
75
+ })
76
+ .passthrough();
77
+ /**
78
+ * Resolves the org `allow_install_scripts` policy from a `prepareForPrivateRegistry`
79
+ * (or `maybeWriteNpmrcForDir`) result. `false` means "the org has explicitly
80
+ * disabled npm install scripts" — install entrypoints append `--ignore-scripts`.
81
+ * `true` or `undefined` (server omitted the field, LD flag off, no client wired
82
+ * up) keeps today's behaviour.
83
+ *
84
+ * Shared by AppShell install entrypoints (shell.ts) and the dev-server startup
85
+ * install (sdk/cli-replacement/dev.mts) so both paths interpret the policy
86
+ * identically.
87
+ */
88
+ export function shouldIgnoreInstallScripts(result) {
89
+ return result?.config.allowInstallScripts === false;
90
+ }
91
+ /**
92
+ * Map a fresh `getConfig` fetch result to the `config.lookup_total` outcome: a
93
+ * populated `configured` result is a cache `miss`; an empty `not-configured`
94
+ * is `not_configured`; `stale` (still serving the cached registry during an
95
+ * outage) is its own `stale` result; `unreachable` (no usable cache during an
96
+ * outage) is `error`. Throws that hard-fail are recorded as `error` at the
97
+ * call site, and cache hits within the TTL as `hit`.
98
+ */
99
+ function configLookupFromFetch(result) {
100
+ switch (result.source) {
101
+ case "configured":
102
+ return "miss";
103
+ case "not-configured":
104
+ return "not_configured";
105
+ case "stale":
106
+ return "stale";
107
+ case "unreachable":
108
+ return "error";
109
+ default: {
110
+ // Exhaustiveness guard: adding a new `NpmRegistryFetchResult.source`
111
+ // variant makes this assignment a compile error, forcing it to be mapped
112
+ // above rather than silently returning `undefined` (which would fold to
113
+ // `error` and mask the real outcome — this package lacks
114
+ // `noImplicitReturns`).
115
+ const exhaustive = result;
116
+ return exhaustive;
117
+ }
118
+ }
119
+ }
120
+ /**
121
+ * Translates a list of server-shaped registry entries into the renderable
122
+ * `NpmRegistryConfig`. Centralised so `writeNpmrc`, tests, and any future
123
+ * consumer all interpret the wire shape the same way.
124
+ *
125
+ * `authToken` is the machine's own Superblocks login token. The server's
126
+ * `/config` route points every `registryUrl` at the Superblocks npm proxy and
127
+ * returns no upstream password, so the same login token authenticates every
128
+ * proxied registry. It is stamped onto each entry here (rather than threaded
129
+ * through `writeNpmrc` / the package-lookup path) so those consumers keep
130
+ * reading `config.*.token` unchanged. Omitted only in tests that render URLs
131
+ * without auth.
132
+ *
133
+ * Multiple `scope === null` entries should never happen — the server's
134
+ * UNIQUE (organization_id, scope) constraint forbids it — but we are
135
+ * defensive: the FIRST default wins, subsequent ones are logged and
136
+ * discarded so a server-side bug never silently rotates the default URL
137
+ * mid-fetch.
138
+ *
139
+ * Duplicate scoped entries (same `scope` string) follow the same rule:
140
+ * first wins.
141
+ */
142
+ /**
143
+ * Path the server mounts the npm proxy under for an org. Mirrors the server's
144
+ * `npmProxyUrlPrefix`
145
+ * (`packages/server/src/controllers/v1/orgNpmRegistry/proxy.ts`): every
146
+ * `registryUrl` the `/config` route returns lives at
147
+ * `<external server URL>/api/v1/organizations/<orgId>/npm-proxy` (default) or
148
+ * a `…/npm-proxy/_scope/<scope>` sub-path. A server-side path change is a
149
+ * coordinated server+client change; until then this is the one client-side
150
+ * source of truth for "is this URL our proxy?".
151
+ */
152
+ function superblocksNpmProxyPathPrefix(organizationId) {
153
+ return `/api/v1/organizations/${organizationId}/npm-proxy`;
154
+ }
155
+ /**
156
+ * True only when `registryUrl` is genuinely the Superblocks npm proxy for THIS
157
+ * org on THIS server (matching origin AND the org-scoped `/npm-proxy` path).
158
+ *
159
+ * The client stamps the machine's own Superblocks login token onto every row
160
+ * `/config` returns. That is only safe if every row really is our proxy: a
161
+ * version-skewed or misconfigured server could return a customer's upstream
162
+ * registry URL (or a broken one built from an empty external-server URL), and
163
+ * blindly stamping the login token onto that would leak a Superblocks
164
+ * credential to a third-party host. So the client proves the proxy invariant
165
+ * before stamping and fails closed when it does not hold.
166
+ *
167
+ * Compares parsed origin + pathname (not a raw string prefix) so trailing
168
+ * slashes and default ports can't cause a false negative, and requires a path
169
+ * boundary so a lookalike like `…/npm-proxyEVIL` can't slip through. Also
170
+ * rejects anything the canonical proxy URL never carries — embedded
171
+ * userinfo (`https://user:pass@host/…` shares the host's `origin` but is not
172
+ * our proxy URL) and any query/fragment — so a crafted URL can't satisfy the
173
+ * origin check while smuggling something else into `.npmrc`.
174
+ */
175
+ export function isSuperblocksNpmProxyUrl(registryUrl, baseUrl, organizationId) {
176
+ let registry;
177
+ let base;
178
+ try {
179
+ registry = new URL(registryUrl);
180
+ base = new URL(baseUrl);
181
+ }
182
+ catch {
183
+ return false;
184
+ }
185
+ if (registry.origin !== base.origin) {
186
+ return false;
187
+ }
188
+ if (registry.username || registry.password) {
189
+ return false;
190
+ }
191
+ if (registry.search || registry.hash) {
192
+ return false;
193
+ }
194
+ const prefix = superblocksNpmProxyPathPrefix(organizationId);
195
+ return (registry.pathname === prefix || registry.pathname.startsWith(`${prefix}/`));
196
+ }
197
+ /**
198
+ * True when on-disk `.npmrc` / `.npmrc.default` content routes installs
199
+ * through this org's Superblocks npm proxy.
200
+ *
201
+ * Origin is intentionally NOT required: live-edit pods write
202
+ * cluster-local hosts (`server.superblocks.svc.cluster.local`) while the
203
+ * client `baseUrl` is often the public URL. Path + org id is the durable
204
+ * ownership signal for both rewrite and delete. Path boundary required so
205
+ * a lookalike like `…/npm-proxyEVIL` cannot match.
206
+ *
207
+ * Scans every occurrence (a first lookalike must not hide a later genuine
208
+ * line). Requires the hit to sit on a non-comment `registry=` /
209
+ * `@scope:registry=` / `:_authToken=` line so a comment mentioning the
210
+ * path does not classify a customer file as ours.
211
+ *
212
+ * Used by `maybeWriteNpmrcForDir` to decide whether a project-dir file is
213
+ * safe to reconcile (stale PVC `.npmrc` after registry delete or expired
214
+ * JWT).
215
+ */
216
+ export function isSuperblocksAuthoredNpmrcContent(content, organizationId) {
217
+ const prefix = superblocksNpmProxyPathPrefix(organizationId);
218
+ let from = 0;
219
+ while (from < content.length) {
220
+ const idx = content.indexOf(prefix, from);
221
+ if (idx < 0) {
222
+ return false;
223
+ }
224
+ const next = content[idx + prefix.length];
225
+ const boundaryOk = next === undefined || next === "/" || next === ":" || /\s/.test(next);
226
+ if (boundaryOk && isSuperblocksProxyHitOnAuthLine(content, idx)) {
227
+ return true;
228
+ }
229
+ from = idx + 1;
230
+ }
231
+ return false;
232
+ }
233
+ function isSuperblocksProxyHitOnAuthLine(content, hitIndex) {
234
+ const lineStart = hitIndex === 0 ? 0 : content.lastIndexOf("\n", hitIndex - 1) + 1;
235
+ const lineEnd = content.indexOf("\n", hitIndex);
236
+ const line = content
237
+ .slice(lineStart, lineEnd < 0 ? undefined : lineEnd)
238
+ .trimStart();
239
+ if (line.startsWith(";") || line.startsWith("#")) {
240
+ return false;
241
+ }
242
+ return (/^registry\s*=/i.test(line) ||
243
+ /^@[^\s:]+:registry\s*=/i.test(line) ||
244
+ /^\/\/.+:_authToken\s*=/i.test(line));
245
+ }
246
+ export function registriesToConfig(entries, allowInstallScripts, authToken) {
247
+ if (entries.length === 0) {
248
+ return {
249
+ configured: false,
250
+ ...(allowInstallScripts !== undefined ? { allowInstallScripts } : {}),
251
+ };
252
+ }
253
+ let defaultReg;
254
+ const scopes = {};
255
+ for (const entry of entries) {
256
+ const value = {
257
+ url: entry.registryUrl,
258
+ ...(authToken ? { token: authToken } : {}),
259
+ };
260
+ if (entry.scope === null) {
261
+ if (defaultReg) {
262
+ getLogger().warn("[npm-registry] server returned multiple default registry entries; keeping the first", { ignoredId: entry.id });
263
+ continue;
264
+ }
265
+ defaultReg = value;
266
+ }
267
+ else {
268
+ if (scopes[entry.scope]) {
269
+ getLogger().warn("[npm-registry] server returned multiple entries for the same scope; keeping the first", { scope: entry.scope, ignoredId: entry.id });
270
+ continue;
271
+ }
272
+ scopes[entry.scope] = value;
273
+ }
274
+ }
275
+ return {
276
+ configured: true,
277
+ ...(defaultReg ? { default: defaultReg } : {}),
278
+ ...(Object.keys(scopes).length > 0 ? { scopes } : {}),
279
+ ...(allowInstallScripts !== undefined ? { allowInstallScripts } : {}),
280
+ };
281
+ }
282
+ const DEFAULT_TTL_MS = 5 * 60 * 1000;
283
+ // Deep-frozen so the `return NOT_CONFIGURED` sites can hand back the same
284
+ // reference without risking cross-caller contamination. Mutation attempts
285
+ // (e.g., a future caller doing `result.config.scopes = {...}` to "augment"
286
+ // before forwarding) throw a TypeError in strict mode rather than silently
287
+ // corrupting every subsequent caller for the process lifetime.
288
+ //
289
+ // Used only when the policy field is unknown (LD flag off on the client OR
290
+ // no cache to fall back to). When the policy IS known (e.g. server returned
291
+ // `npmAllowInstallScripts: false` alongside an empty `registries` list), the
292
+ // helper below builds a fresh result so the policy still reaches AppShell.
293
+ const NOT_CONFIGURED = Object.freeze({
294
+ source: "not-configured",
295
+ config: Object.freeze({ configured: false }),
296
+ });
297
+ // Same deep-freeze rationale as NOT_CONFIGURED. Returned only when the
298
+ // server is unreachable AND we have no usable cache, so the caller can
299
+ // distinguish "we don't know" from a deliberate `not-configured`
300
+ // observation.
301
+ const UNREACHABLE = Object.freeze({
302
+ source: "unreachable",
303
+ config: Object.freeze({ configured: false }),
304
+ });
305
+ /**
306
+ * Build a "not-configured" result that still carries the org policy when
307
+ * the server returned one. Falls back to the frozen `NOT_CONFIGURED`
308
+ * singleton when the policy is unknown so cold-path callers keep allocating
309
+ * zero objects.
310
+ *
311
+ * The result and its `config` are both frozen for the same reason as
312
+ * `NOT_CONFIGURED`: a downstream caller doing `result.config.scopes = {...}`
313
+ * to "augment before forwarding" throws a TypeError in strict mode rather
314
+ * than silently producing a result that doesn't match what we returned.
315
+ */
316
+ function notConfigured(allowInstallScripts) {
317
+ if (allowInstallScripts === undefined) {
318
+ return NOT_CONFIGURED;
319
+ }
320
+ return Object.freeze({
321
+ source: "not-configured",
322
+ config: Object.freeze({ configured: false, allowInstallScripts }),
323
+ });
324
+ }
325
+ /**
326
+ * Same shape as `notConfigured(policy)` but for the "unreachable" branch:
327
+ * server didn't respond AND we have no usable cache. Destructive cleanup
328
+ * paths (the home-npmrc writer in `cli-replacement/dev.mts`) branch on the
329
+ * `unreachable` discriminator to refuse acting on a transient outage. The
330
+ * optional `allowInstallScripts` mirrors the `notConfigured` policy
331
+ * preservation invariant so AppShell still honors a known `--ignore-scripts`
332
+ * policy during the outage.
333
+ */
334
+ function unreachable(allowInstallScripts) {
335
+ if (allowInstallScripts === undefined) {
336
+ return UNREACHABLE;
337
+ }
338
+ return Object.freeze({
339
+ source: "unreachable",
340
+ config: Object.freeze({ configured: false, allowInstallScripts }),
341
+ });
342
+ }
343
+ /**
344
+ * Fetches per-org npm registry configuration from the server, caching the
345
+ * result in-memory with a short TTL. Designed so callers do not have to
346
+ * think about the LaunchDarkly flag, JWT lifecycle, or transient server
347
+ * outages — they just `await client.getConfig()` and get back a renderable
348
+ * shape (or "not configured").
349
+ *
350
+ * Lifecycle invariants (see APPS-4230 scope):
351
+ *
352
+ * 1. **Flag off → short-circuit**: returns `{ configured: false }` with
353
+ * no network I/O. Lets us dark-ship LinkedIn first without hammering
354
+ * the API for the rest of the fleet.
355
+ * 2. **Cache hit within TTL → no fetch**: avoids per-install round-trips
356
+ * against the server.
357
+ * 3. **401 → await `refreshJwt` then retry once with a fresh
358
+ * `getJwt()` read**: any push-based JWT refresh (auth-hot-reload)
359
+ * that landed between the original request and the retry is picked
360
+ * up. The cache is preserved across the retry so a failed retry
361
+ * can still fall back to last-known-good. Two disjoint failure
362
+ * modes:
363
+ * - The retry itself returns 401 → hard throw. We deliberately do
364
+ * not keep retrying because the only way a freshly-read JWT also
365
+ * 401s is a true re-auth failure.
366
+ * - `refreshJwt` itself throws or times out (e.g. the push channel
367
+ * hung) → route through `serveStaleOrUnconfigured` (same as a 5xx
368
+ * / network outage). A flaky refresh channel must not crash the
369
+ * install path, and we never reach the second `attempt()`.
370
+ * 4. **Other 4xx (403/400/…) → clear the cache and throw**: these are
371
+ * deliberate denials (RBAC revocation, malformed request), not
372
+ * transient outages. Serving stale would extend the revocation
373
+ * window beyond the cache TTL. The error propagates to the caller
374
+ * (typically `AppShell` / `TemplateRenderer`), which decides
375
+ * whether to fail the install or fall back to public npm.
376
+ * 5. **5xx or network unreachable + cached value → return cache +
377
+ * `logger.warn`**: install workflows continue against the
378
+ * last-known-good registry while we surface the outage; strictly
379
+ * better than falling back to `registry.npmjs.org` mid-deploy.
380
+ * 6. **5xx or network unreachable + no usable cache → return
381
+ * `source: "unreachable"` with `{ configured: false }`**: cold start
382
+ * or only an empty-list cache. `config.configured: false` so
383
+ * write-side consumers continue to no-op, but the distinct source
384
+ * keeps destructive cleanup paths (home-npmrc unlink) from acting on
385
+ * a transient outage.
386
+ *
387
+ * The class is intentionally a thin wrapper around a single Map cell — the
388
+ * cache key is `(organizationId)` since one client serves one org. Sharing
389
+ * one client across orgs would require per-org cache keys; we don't do
390
+ * that today because the dev-server pod is single-tenant.
391
+ */
392
+ export class NpmRegistryClient {
393
+ deps;
394
+ /**
395
+ * Last successful fetch + when it landed. Source of both the TTL check
396
+ * and the last-known-good fallback. We deliberately store the entries as
397
+ * received (not the rendered `NpmRegistryConfig`) so future readers can
398
+ * apply different render policies without a re-fetch.
399
+ *
400
+ * `npmAllowInstallScripts` rides alongside because the server returns it
401
+ * on the same envelope and AppShell wants the same TTL/fallback semantics
402
+ * for both. `undefined` here means the server omitted the field (LD flag
403
+ * off on the server side, or older server); we propagate that as
404
+ * `allowInstallScripts: undefined` rather than defaulting to `true` so
405
+ * the consumer can distinguish "policy known, scripts allowed" from
406
+ * "policy unknown".
407
+ */
408
+ cache;
409
+ /**
410
+ * Inflight `fetchWithRefresh()` promise, if any. Used to deduplicate
411
+ * concurrent `getConfig()` callers during a cache miss (or stale-after-
412
+ * TTL re-fetch): rather than firing N network requests for N callers
413
+ * we share the single in-flight request. Cleared in a `.finally()` so a
414
+ * resolved or rejected fetch never sticks around.
415
+ *
416
+ * Without this, a burst of installs that all hit cold cache would race
417
+ * to the server, the first one's 401 would clear the cache for itself
418
+ * before the others observe their own 401s — and the others would
419
+ * then have no last-known-good to fall back to.
420
+ */
421
+ inflight;
422
+ /**
423
+ * Last `npmAllowInstallScripts` value observed from a successful server
424
+ * response, retained across hard-fail cache invalidations (refreshJwt
425
+ * rejection, double-401, other 4xx). Registry credentials and the
426
+ * security policy live on the same envelope but have different
427
+ * security semantics: serving stale credentials to a revoked caller
428
+ * extends a deliberate denial, but dropping a known `false` policy
429
+ * silently weakens `--ignore-scripts` enforcement — strictly the
430
+ * wrong direction. So `this.cache` is cleared on hard-fail (revoke
431
+ * stale credentials), but this field survives so the next call's
432
+ * fall-through `serveStaleOrUnconfigured` still propagates the
433
+ * org's policy to AppShell.
434
+ */
435
+ lastKnownPolicy;
436
+ constructor(deps) {
437
+ this.deps = {
438
+ isFlagEnabled: deps.isFlagEnabled,
439
+ getJwt: deps.getJwt,
440
+ refreshJwt: deps.refreshJwt,
441
+ organizationId: deps.organizationId,
442
+ baseUrl: deps.baseUrl,
443
+ fetch: deps.fetch ?? globalThis.fetch,
444
+ ttlMs: deps.ttlMs ?? DEFAULT_TTL_MS,
445
+ now: deps.now ?? Date.now,
446
+ lastKnownPolicyStore: deps.lastKnownPolicyStore,
447
+ };
448
+ }
449
+ /**
450
+ * Organization id this client serves. Read-only; surfaced so the
451
+ * `npm_registry.prepare_for_private_registry` span (APPS-4378) can carry
452
+ * `org_id` without the standalone `prepareForPrivateRegistry` helper having
453
+ * to thread it through its signature.
454
+ */
455
+ get organizationId() {
456
+ return this.deps.organizationId;
457
+ }
458
+ /**
459
+ * Clears the in-memory cache so the next `getConfig()` re-fetches from
460
+ * the server. Called by AppShell install retry when
461
+ * `registry_auth_failed` indicates a stale Artifactory token.
462
+ *
463
+ * `lastKnownPolicy` survives invalidation (same as the auth-failure
464
+ * branches in `fetchWithRefresh`) so `--ignore-scripts` enforcement
465
+ * is not weakened during the re-fetch.
466
+ */
467
+ invalidateCache() {
468
+ this.cache = undefined;
469
+ }
470
+ /**
471
+ * Persist the "ever configured" marker, AWAITED so the write is durable
472
+ * before the caller hands back a `configured` / `stale` resolution. Used
473
+ * on every such resolution so a subsequent server outage can fail closed
474
+ * instead of silently resolving through public npm.
475
+ *
476
+ * Awaited (not fire-and-forget) because the marker must be on disk before
477
+ * `getConfig()` returns: a crash in the gap between returning `configured`
478
+ * and an un-awaited write landing would lose the marker and silently break
479
+ * the "once configured, always fail-closed on unreachable" invariant. The
480
+ * write stays async (`fs/promises`, per the ai-service no-sync-fs rule);
481
+ * the disk store guards itself so the write happens at most once per
482
+ * process (see `createDiskRegistryPolicyStore`), keeping the awaited write
483
+ * off the hot path after the first configured resolution.
484
+ *
485
+ * Logs a warning on write failure but never propagates the error: a broken
486
+ * store is a strict superset of today's no-marker behaviour, and the
487
+ * install path must stay healthy when disk is full or the marker directory
488
+ * is unwritable.
489
+ */
490
+ async markPolicyConfigured() {
491
+ const store = this.deps.lastKnownPolicyStore;
492
+ if (!store) {
493
+ return;
494
+ }
495
+ try {
496
+ await store.markConfigured();
497
+ }
498
+ catch (err) {
499
+ getLogger().warn("[npm-registry] lastKnownPolicyStore.markConfigured() failed; ignoring", {
500
+ orgId: this.deps.organizationId,
501
+ error: err instanceof Error ? err.message : String(err),
502
+ });
503
+ }
504
+ }
505
+ /**
506
+ * Drop the marker when a fresh fetch proves the org has no registry rows.
507
+ * Mirrors `markPolicyConfigured`: best-effort, warns on failure, never
508
+ * propagates. A store that cannot clear leaves today's fail-closed
509
+ * behaviour in place.
510
+ */
511
+ async clearPolicyConfigured() {
512
+ const store = this.deps.lastKnownPolicyStore;
513
+ if (!store) {
514
+ return;
515
+ }
516
+ try {
517
+ await store.clearConfigured();
518
+ }
519
+ catch (err) {
520
+ getLogger().warn("[npm-registry] lastKnownPolicyStore.clearConfigured() failed; ignoring", {
521
+ orgId: this.deps.organizationId,
522
+ error: err instanceof Error ? err.message : String(err),
523
+ });
524
+ }
525
+ }
526
+ /**
527
+ * Read the disk-backed marker that AppShell uses to decide whether to
528
+ * fail closed on `unreachable`. Treats a read failure as `false` so a
529
+ * transient store IO error preserves current behaviour (proceed) rather
530
+ * than degrading to a fail-closed install.
531
+ */
532
+ async readEverConfigured() {
533
+ const store = this.deps.lastKnownPolicyStore;
534
+ if (!store) {
535
+ return undefined;
536
+ }
537
+ try {
538
+ return await store.hasEverBeenConfigured();
539
+ }
540
+ catch (err) {
541
+ getLogger().warn("[npm-registry] lastKnownPolicyStore.hasEverBeenConfigured() failed; treating as false", {
542
+ orgId: this.deps.organizationId,
543
+ error: err instanceof Error ? err.message : String(err),
544
+ });
545
+ return false;
546
+ }
547
+ }
548
+ /**
549
+ * Resolve the current npm registry configuration for the active org. See
550
+ * the class docstring for the full state machine.
551
+ *
552
+ * `forceRefresh` bypasses the TTL cache-hit return below so a just-in-time
553
+ * caller (the `.npmrc` writer before an install, a package lookup, the
554
+ * home-npmrc sync) observes an admin clearing or changing the registry
555
+ * immediately instead of waiting out the TTL. `forceRefreshMaxAgeMs` lets a
556
+ * high-frequency caller (the package lookup) keep a small freshness floor so
557
+ * a tight sequential batch collapses onto one fetch; left at 0 (install /
558
+ * home sync) a forced read always re-fetches. It does NOT touch the cache
559
+ * before fetching: `serveStaleOrUnconfigured` still needs the last-known-good
560
+ * entries to fall back to during a 5xx/network outage. The flag-off
561
+ * short-circuit, inflight dedup, and all hard-fail branches behave
562
+ * identically.
563
+ */
564
+ async getConfig(options = {}) {
565
+ // Captured up front so every config.lookup emit carries the time getConfig
566
+ // spent resolving (~0 for a cache hit, the network round-trip for a miss).
567
+ const start = this.deps.now();
568
+ const forceRefresh = options.forceRefresh === true;
569
+ if (!this.deps.isFlagEnabled()) {
570
+ // Short-circuit BEFORE inspecting the cache: a flag flip to "off"
571
+ // must not keep serving from a previously-fetched config. The
572
+ // ticket explicitly calls this out ("Flag off → return
573
+ // {configured: false} immediately, no server call"). `forceRefresh`
574
+ // does not change this: flag off means no config regardless.
575
+ npmRegistryEmitter.recordConfigLookup("not_configured", this.deps.now() - start, forceRefresh);
576
+ return NOT_CONFIGURED;
577
+ }
578
+ const now = this.deps.now();
579
+ // A forced read may still be served from the cache if it is younger than
580
+ // the caller's freshness floor (default 0 = always re-fetch). An unforced
581
+ // read uses the full TTL.
582
+ const maxAgeMs = forceRefresh
583
+ ? (options.forceRefreshMaxAgeMs ?? 0)
584
+ : this.deps.ttlMs;
585
+ if (this.cache && now - this.cache.fetchedAt < maxAgeMs) {
586
+ // A cached empty list (from a prior 404 or `registries: []` response)
587
+ // must surface as `not-configured` on every hit within the TTL, not
588
+ // `configured` with `config.configured: false`. The discriminator's
589
+ // "configured" branch is documented as "at least one registry row
590
+ // exists" — preserving that invariant matters for callers branching
591
+ // on `source` for observability. We still surface any cached policy
592
+ // alongside the not-configured result so AppShell can honor
593
+ // `--ignore-scripts` even when there are no registry rows.
594
+ if (this.cache.entries.length === 0) {
595
+ npmRegistryEmitter.recordConfigLookup("not_configured", this.deps.now() - start, forceRefresh);
596
+ return notConfigured(this.cache.npmAllowInstallScripts);
597
+ }
598
+ await this.markPolicyConfigured();
599
+ npmRegistryEmitter.recordConfigLookup("hit", this.deps.now() - start, forceRefresh);
600
+ return this.renderConfigured(this.cache.entries, this.cache.npmAllowInstallScripts);
601
+ }
602
+ // Deduplicate concurrent cache-miss callers onto a single network
603
+ // request so we don't multiply 401-refresh storms or lose last-known-
604
+ // good fallback for racing callers.
605
+ if (this.inflight) {
606
+ return this.inflight;
607
+ }
608
+ const pending = this.fetchWithRefresh()
609
+ .then((result) => {
610
+ // Cache miss → fresh fetch. configured ⇒ miss; empty/404 ⇒
611
+ // not_configured; stale/unreachable ⇒ error. Deduped concurrent
612
+ // callers share this single emit, so the counter tracks fetch rate.
613
+ npmRegistryEmitter.recordConfigLookup(configLookupFromFetch(result), this.deps.now() - start, forceRefresh);
614
+ return result;
615
+ })
616
+ .catch((err) => {
617
+ // Hard-fail throws (double-401, refresh reject, other-4xx, schema
618
+ // parse) surface as `error`.
619
+ npmRegistryEmitter.recordConfigLookup("error", this.deps.now() - start, forceRefresh);
620
+ throw err;
621
+ })
622
+ .finally(() => {
623
+ // Always clear inflight on resolve OR reject so a transient error
624
+ // doesn't pin the slot and starve subsequent callers.
625
+ if (this.inflight === pending) {
626
+ this.inflight = undefined;
627
+ }
628
+ });
629
+ this.inflight = pending;
630
+ return pending;
631
+ }
632
+ async fetchWithRefresh() {
633
+ let response;
634
+ try {
635
+ response = await this.attempt();
636
+ }
637
+ catch (err) {
638
+ return this.serveStaleOrUnconfigured(err);
639
+ }
640
+ if (response.status === 401) {
641
+ // Do NOT clear `this.cache` here: if the retry fails,
642
+ // `serveStaleOrUnconfigured` still needs the last-known-good
643
+ // entries to fall back to. Concurrent callers are serialised on
644
+ // `this.inflight`, so they won't observe a stale value during the
645
+ // retry window.
646
+ //
647
+ // Await `refreshJwt` (if wired) so the retry has a fair chance
648
+ // of seeing a freshly-rotated token. A refresh-channel error
649
+ // combined with a 401 from the registry endpoint is ambiguous —
650
+ // it can be a transient outage OR a terminal revocation
651
+ // (refresh token rejected, account disabled). We cannot tell
652
+ // from out here, and serving last-known-good in the revocation
653
+ // case would let a revoked caller continue installing from a
654
+ // private registry until TTL expiry. Treat refresh failure as a
655
+ // hard fail: clear the cache and surface the error, mirroring
656
+ // the deliberate-denial 4xx branch below.
657
+ if (this.deps.refreshJwt) {
658
+ try {
659
+ await this.deps.refreshJwt();
660
+ }
661
+ catch (err) {
662
+ this.cache = undefined;
663
+ const refreshFailError = new Error(`[npm-registry] refreshJwt failed after HTTP 401 from the npm registry endpoint: ${err instanceof Error ? err.message : String(err)}`);
664
+ getLogger().error(`[npm-registry] hard-fail: refreshJwt rejected after HTTP 401 (org ${this.deps.organizationId}); cache cleared`, {
665
+ error: {
666
+ kind: "NpmRegistryRefreshFail",
667
+ message: refreshFailError.message,
668
+ },
669
+ });
670
+ throw refreshFailError;
671
+ }
672
+ }
673
+ try {
674
+ response = await this.attempt();
675
+ }
676
+ catch (err) {
677
+ return this.serveStaleOrUnconfigured(err);
678
+ }
679
+ if (response.status === 401) {
680
+ // A second 401 after a successful refreshJwt is stronger evidence
681
+ // of revocation than either the refreshJwt-rejection branch above
682
+ // or the deliberate-denial 4xx branch below: the refresh channel
683
+ // worked, but the freshly-issued JWT is still rejected. Clear the
684
+ // cache so a subsequent 5xx/network error cannot fall back through
685
+ // `serveStaleOrUnconfigured` and serve last-known-good config to
686
+ // a potentially-revoked user until TTL expiry. We surface this
687
+ // rather than swallowing it because "silently fall back to public
688
+ // npm" is precisely the failure mode this whole feature exists
689
+ // to prevent.
690
+ this.cache = undefined;
691
+ const doubleAuthFailError = new Error("[npm-registry] re-authenticated and still received HTTP 401 from the npm registry endpoint");
692
+ getLogger().error(`[npm-registry] hard-fail: HTTP 401 persisted after refreshJwt (org ${this.deps.organizationId}); cache cleared`, {
693
+ error: {
694
+ kind: "NpmRegistryDoubleAuthFail",
695
+ message: doubleAuthFailError.message,
696
+ },
697
+ });
698
+ throw doubleAuthFailError;
699
+ }
700
+ }
701
+ if (response.status === 404) {
702
+ // The route exists but the org has no registry rows (or the
703
+ // sibling endpoint returned 404 for a transient reason — deploy
704
+ // window, route mis-mount, brief org-deactivation race). Treat
705
+ // the same as an empty list response — `{ configured: false }`.
706
+ // We still cache "empty" so we don't poll the 404 path on every
707
+ // install.
708
+ //
709
+ // We preserve any previously-observed `npmAllowInstallScripts`
710
+ // policy rather than overwriting it with `undefined`: a transient
711
+ // 404 against a freshly-deployed server (or an envoy mis-route)
712
+ // would otherwise silently disable an org's `--ignore-scripts`
713
+ // enforcement for the rest of the TTL window. The 404 payload
714
+ // doesn't carry a fresh policy, but a previously-observed policy
715
+ // is the best estimate we have until the next successful fetch.
716
+ //
717
+ // Fall back to `lastKnownPolicy` when `this.cache` itself was
718
+ // hard-cleared by an earlier auth-failure branch — the policy
719
+ // survives independently of the registry credentials it rode in
720
+ // with, and reading from cache alone would clobber it back to
721
+ // `undefined` here.
722
+ this.signalPolicyFallback(this.cache?.npmAllowInstallScripts, "not_configured_404");
723
+ const preservedPolicy = this.cache?.npmAllowInstallScripts ?? this.lastKnownPolicy;
724
+ this.cache = {
725
+ entries: [],
726
+ npmAllowInstallScripts: preservedPolicy,
727
+ fetchedAt: this.deps.now(),
728
+ };
729
+ this.lastKnownPolicy = preservedPolicy;
730
+ return notConfigured(preservedPolicy);
731
+ }
732
+ if (response.status >= 400 &&
733
+ response.status < 500 &&
734
+ response.status !== 401 &&
735
+ response.status !== 404) {
736
+ // Other 4xx ("the request is bad" or "you specifically can't do
737
+ // this") are deliberate denials, not transient outages. Examples:
738
+ // - 403 after org RBAC permission revocation
739
+ // - 400 from a malformed Authorization header
740
+ // Serving stale here would let a revoked-access install run with
741
+ // a cached registry token until TTL expiry — exactly the staleness
742
+ // window we want to avoid. Clear the cache and surface the error
743
+ // so the caller decides; the inflight slot is cleared by the
744
+ // outer `.finally()` so a subsequent call can re-attempt.
745
+ this.cache = undefined;
746
+ const hardFailError = new Error(`[npm-registry] server returned HTTP ${response.status} from the npm registry endpoint`);
747
+ getLogger().error(`[npm-registry] hard-fail HTTP ${response.status} from npm registry endpoint (org ${this.deps.organizationId}); cache cleared`, {
748
+ error: {
749
+ kind: "NpmRegistryHardFail",
750
+ message: hardFailError.message,
751
+ },
752
+ });
753
+ throw hardFailError;
754
+ }
755
+ if (!response.ok) {
756
+ // 5xx is treated as a transient outage. Last-known-good if we
757
+ // have one, otherwise `not-configured`.
758
+ return this.serveStaleOrUnconfigured(new Error(`[npm-registry] server returned HTTP ${response.status} from the npm registry endpoint`));
759
+ }
760
+ // Read the body AND unwrap the standard Superblocks `ResponseDto`
761
+ // envelope (`{ data, responseMeta }`) the server wraps every JSON
762
+ // response in. The UI client uses `callServer` (which delegates to
763
+ // `unwrapResponseDto` in `@superblocksteam/shared`) for the same shape;
764
+ // here we keep raw `fetch` (preserves the DI surface the test harness
765
+ // mocks) and unwrap inline so the registry-payload schema below mirrors
766
+ // the inner shape, not the wire envelope. JSON-parse failures and
767
+ // envelope-shape failures both route to `serveStale…` — single try.
768
+ let payload;
769
+ try {
770
+ const body = await response.json();
771
+ const envelopeParse = envelopeSchema.safeParse(body);
772
+ if (!envelopeParse.success) {
773
+ const envelopeError = new Error(`[npm-registry] server returned a payload that did not match the expected ResponseDto envelope (org ${this.deps.organizationId}): ${JSON.stringify(envelopeParse.error.issues)}`);
774
+ getLogger().error(envelopeError.message, {
775
+ error: {
776
+ kind: "NpmRegistryEnvelopeParseFailed",
777
+ message: envelopeError.message,
778
+ },
779
+ });
780
+ throw envelopeError;
781
+ }
782
+ payload = envelopeParse.data.data;
783
+ }
784
+ catch (err) {
785
+ return this.serveStaleOrUnconfigured(err);
786
+ }
787
+ const parsed = registryListSchema.safeParse(payload);
788
+ if (!parsed.success) {
789
+ // Log schema issues at error level (distinct from the generic
790
+ // serveStale warn) so a malformed payload is visible in the absence
791
+ // of a network outage — most likely a server-side validation bug
792
+ // or a hostile push. The Zod issue list is folded into the message
793
+ // because the `error` logger only accepts `ErrorMeta` shape.
794
+ const schemaError = new Error(`[npm-registry] server returned a payload that did not match the expected { registries: [...] } shape (org ${this.deps.organizationId}): ${JSON.stringify(parsed.error.issues)}`);
795
+ getLogger().error(schemaError.message, {
796
+ error: {
797
+ kind: "NpmRegistrySchemaParseFailed",
798
+ message: schemaError.message,
799
+ },
800
+ });
801
+ return this.serveStaleOrUnconfigured(schemaError);
802
+ }
803
+ const entries = parsed.data.registries;
804
+ const npmAllowInstallScripts = parsed.data.npmAllowInstallScripts;
805
+ // Prove every row is genuinely our proxy before trusting the payload.
806
+ // `renderConfig` stamps the machine's Superblocks login token onto each
807
+ // row's URL; if a version-skewed or misconfigured server returned a
808
+ // customer's upstream registry URL (or a broken one) we'd leak that login
809
+ // token to a third-party host. A row that fails the invariant means the
810
+ // payload is untrustworthy, so we treat it like a schema failure: don't
811
+ // cache it, and fail closed through `serveStaleOrUnconfigured` (serves
812
+ // last-known-good if we have it, else `unreachable`).
813
+ const nonProxyEntry = entries.find((entry) => !isSuperblocksNpmProxyUrl(entry.registryUrl, this.deps.baseUrl, this.deps.organizationId));
814
+ if (nonProxyEntry) {
815
+ const invariantError = new Error(`[npm-registry] server returned a registryUrl that is not the Superblocks npm proxy for this org (org ${this.deps.organizationId}); refusing to stamp the login token onto it`);
816
+ getLogger().error(invariantError.message, {
817
+ error: {
818
+ kind: "NpmRegistryProxyInvariantViolated",
819
+ message: invariantError.message,
820
+ },
821
+ });
822
+ return this.serveStaleOrUnconfigured(invariantError);
823
+ }
824
+ this.cache = {
825
+ entries,
826
+ npmAllowInstallScripts,
827
+ fetchedAt: this.deps.now(),
828
+ };
829
+ this.lastKnownPolicy = npmAllowInstallScripts;
830
+ if (entries.length === 0) {
831
+ // Drop the marker when a fresh fetch proves the org has no registry rows.
832
+ await this.clearPolicyConfigured();
833
+ return notConfigured(npmAllowInstallScripts);
834
+ }
835
+ await this.markPolicyConfigured();
836
+ return this.renderConfigured(entries, npmAllowInstallScripts);
837
+ }
838
+ /**
839
+ * One full fetch attempt with the current JWT. Throws on getJwt failure
840
+ * OR network failure so the caller's single try/catch handles both.
841
+ */
842
+ async attempt() {
843
+ const jwt = await this.deps.getJwt();
844
+ const base = this.deps.baseUrl.replace(/\/$/, "");
845
+ // `/config` returns each registry row with its `registryUrl` rewritten to
846
+ // the Superblocks npm proxy. No upstream tokens cross the wire anymore;
847
+ // the caller stamps the machine's own login token onto every row to auth
848
+ // against the proxy. Restricted to superblocks_jwt + access_token callers;
849
+ // the plain list route is redacted-only and serves the dashboard.
850
+ const url = `${base}/api/v1/organizations/${encodeURIComponent(this.deps.organizationId)}/npm-registry/config`;
851
+ return await this.deps.fetch(url, {
852
+ method: "GET",
853
+ headers: {
854
+ accept: "application/json",
855
+ authorization: `Bearer ${jwt}`,
856
+ },
857
+ });
858
+ }
859
+ /**
860
+ * Signal when `lastKnownPolicy` supplied the install-scripts policy that the
861
+ * in-memory cache could not (`cachePolicy == null && lastKnownPolicy !=
862
+ * null`). That combination means an earlier auth-failure or 4xx branch wiped
863
+ * the cache and we fell back to the surviving policy, which is a sign
864
+ * something went wrong. Emit a WARN (with `orgId` and which branch ran) plus
865
+ * a low-cardinality counter so it can be alerted on from a dashboard without
866
+ * digging through logs or traces. `cachePolicy` is passed in (not re-read)
867
+ * because the 404 branch overwrites `this.cache` before this runs.
868
+ */
869
+ signalPolicyFallback(cachePolicy, branch) {
870
+ if (cachePolicy == null && this.lastKnownPolicy != null) {
871
+ getLogger().warn("[npm-registry] fell back to the last known install-scripts policy because the cache had been cleared by an earlier auth or 4xx failure", { orgId: this.deps.organizationId, branch });
872
+ npmRegistryEmitter.recordPolicyFallback(branch);
873
+ }
874
+ }
875
+ /**
876
+ * Render cached/fetched entries into a config, stamping the machine's current
877
+ * Superblocks login token onto every proxied registry (`registryUrl` is the
878
+ * proxy URL the server rewrote each row to). Read fresh each call so the
879
+ * `.npmrc` the caller writes right after carries a current token. `getJwt()`
880
+ * resolves immediately when a token is already primed, so this stays cheap on
881
+ * the cache-hit fast path; it throws only when no token is available, in
882
+ * which case there is no way to build a working proxy `.npmrc`.
883
+ */
884
+ async renderConfig(entries, allowInstallScripts) {
885
+ const authToken = await this.deps.getJwt();
886
+ return registriesToConfig(entries, allowInstallScripts, authToken);
887
+ }
888
+ /**
889
+ * Build a `configured` result, but route a JWT-read failure through the same
890
+ * fail-closed path as `serveStaleOrUnconfigured`. `renderConfig` reads the
891
+ * login token via `getJwt()`, which can reject (no token primed). A missing
892
+ * token is the same "we can't build a working proxy `.npmrc`" condition the
893
+ * stale path already treats as `unreachable`, so both the cache-hit and the
894
+ * fresh-fetch success paths must resolve it the same way rather than throwing
895
+ * out of `getConfig()`. With a warm cache this serves last-known-good; with
896
+ * no usable cache it reports `unreachable`.
897
+ */
898
+ async renderConfigured(entries, allowInstallScripts) {
899
+ let config;
900
+ try {
901
+ config = await this.renderConfig(entries, allowInstallScripts);
902
+ }
903
+ catch (jwtError) {
904
+ return this.serveStaleOrUnconfigured(jwtError);
905
+ }
906
+ return { source: "configured", config };
907
+ }
908
+ async serveStaleOrUnconfigured(error) {
909
+ if (this.cache && this.cache.entries.length > 0) {
910
+ const ageMs = this.deps.now() - this.cache.fetchedAt;
911
+ // Render before logging "serving last-known-good": the proxy config
912
+ // needs the machine's login token stamped onto every row, and that
913
+ // read can fail (no JWT). A tokenless proxy `.npmrc` is useless —
914
+ // every install would 401 against the proxy — so on that failure we
915
+ // fail closed by falling through to the unreachable path below rather
916
+ // than handing back a config that can't authenticate.
917
+ let config;
918
+ try {
919
+ config = await this.renderConfig(this.cache.entries, this.cache.npmAllowInstallScripts);
920
+ }
921
+ catch (jwtError) {
922
+ getLogger().warn("[npm-registry] server unreachable and no login token available to render last-known-good config; treating as unreachable", {
923
+ ageMs,
924
+ error: jwtError instanceof Error ? jwtError.message : String(jwtError),
925
+ });
926
+ }
927
+ if (config) {
928
+ getLogger().warn("[npm-registry] server unreachable; serving last-known-good config", {
929
+ ageMs,
930
+ error: error instanceof Error ? error.message : String(error),
931
+ });
932
+ // APPS-4370: stale serves a known-configured org, so refresh the
933
+ // disk marker too. A long outage that spans a pod recycle would
934
+ // otherwise lose the signal: the next cold-boot would see `unreachable`
935
+ // with no marker and proceed instead of failing closed.
936
+ await this.markPolicyConfigured();
937
+ return {
938
+ source: "stale",
939
+ config,
940
+ };
941
+ }
942
+ }
943
+ // No usable cache: either nothing was ever fetched successfully (cold
944
+ // start) or the only successful fetch returned an empty list. Both
945
+ // mean we don't actually know the org's current registry state, so
946
+ // we surface `unreachable` rather than `not-configured`. Consumers
947
+ // with destructive cleanup paths (e.g. the home-npmrc writer
948
+ // unlinking a previously-written `~/.npmrc`) need that distinction to
949
+ // avoid acting on a transient outage; read-only consumers branch on
950
+ // `config.configured` and continue to no-op safely either way.
951
+ //
952
+ // A cached `npmAllowInstallScripts` policy IS useful and survives the
953
+ // outage: AppShell still honors a known `--ignore-scripts` policy
954
+ // when the server is down. Falls back to `lastKnownPolicy` when
955
+ // `this.cache` itself was hard-cleared by an auth-failure branch
956
+ // above — the policy survives independently of the registry
957
+ // credentials it rode in with.
958
+ getLogger().warn("[npm-registry] server unreachable and no usable cached config; treating as unreachable", { error: error instanceof Error ? error.message : String(error) });
959
+ this.signalPolicyFallback(this.cache?.npmAllowInstallScripts, "unreachable");
960
+ const base = unreachable(this.cache?.npmAllowInstallScripts ?? this.lastKnownPolicy);
961
+ // APPS-4370: consult the disk-backed marker so AppShell can decide
962
+ // whether to fail closed. Only attach the field when a store is
963
+ // wired in — `undefined` is the documented "no opinion" signal.
964
+ const everConfigured = await this.readEverConfigured();
965
+ if (everConfigured === undefined) {
966
+ return base;
967
+ }
968
+ // `base` may be the frozen UNREACHABLE singleton; build a fresh
969
+ // object so adding `everConfigured` doesn't try to mutate a frozen
970
+ // value (TypeError in strict mode).
971
+ return Object.freeze({
972
+ source: "unreachable",
973
+ config: base.config,
974
+ everConfigured,
975
+ });
976
+ }
977
+ }
978
+ /**
979
+ * Extracts the host portion of a registry URL for use in npm auth lines, e.g.
980
+ * `https://artifactory.example.com/api/npm/npm-virtual/` ->
981
+ * `//artifactory.example.com/api/npm/npm-virtual/`.
982
+ *
983
+ * npm matches `_authToken` lines by URL prefix (sans scheme), so we keep the
984
+ * full path. Trailing slash is normalized. Returns undefined for unparseable
985
+ * URLs OR URLs that carry userinfo (`user:pass@host`) — userinfo would make
986
+ * the `registry=` and `_authToken=` lines disagree under npm's URL-prefix
987
+ * matching rule and would also leak credentials into process logs.
988
+ */
989
+ function toNpmAuthOrigin(registryUrl) {
990
+ try {
991
+ const u = new URL(registryUrl);
992
+ if (u.username || u.password) {
993
+ return;
994
+ }
995
+ const pathname = u.pathname.endsWith("/") ? u.pathname : `${u.pathname}/`;
996
+ return `//${u.host}${pathname}`;
997
+ }
998
+ catch {
999
+ return;
1000
+ }
1001
+ }
1002
+ /**
1003
+ * Normalizes a registry URL to end in exactly one trailing slash so the
1004
+ * `registry=` line and the `_authToken=` host prefix line match exactly under
1005
+ * npm's URL-prefix matching rule. Mirrors the shell script behavior.
1006
+ */
1007
+ function normalizeRegistryUrl(registryUrl) {
1008
+ return registryUrl.endsWith("/") ? registryUrl : `${registryUrl}/`;
1009
+ }
1010
+ /**
1011
+ * Renders the npm registry config to an `.npmrc` file at `targetPath`.
1012
+ *
1013
+ * Uses `ini.stringify` (the same library `@npmcli/config` uses to read and
1014
+ * write `.npmrc`) so the file is guaranteed to round-trip through
1015
+ * `ini.parse`. This handles value-quoting for `=`, `\r`, `\n`, leading `[`,
1016
+ * leading/trailing whitespace, and escapes `;` / `#` so they're not treated
1017
+ * as comments.
1018
+ *
1019
+ * Validation NOT covered by `ini`:
1020
+ * - `noControlChars` Zod refinement: `ini.safe` JSON-quotes `\r`/`\n`
1021
+ * rather than rejecting them, and accepts other C0 control bytes
1022
+ * (`\x00..\x1f`) unchanged — so we reject the entire C0 range at the
1023
+ * wire-schema layer instead.
1024
+ * - Scope grammar (`@scope` must match npm's regex): `@npmcli/config`
1025
+ * does not validate scope names.
1026
+ * - https-only registry URLs: npm itself accepts http.
1027
+ *
1028
+ * Idempotent: rewrites the file in full each call. Writes are atomic (tmp +
1029
+ * rename) and the file mode is restricted to 0600 because the file may carry
1030
+ * an auth token.
1031
+ *
1032
+ * Requires `config.configured === true` OR `config.allowInstallScripts === false`
1033
+ * (so the writer can emit a policy-only `.npmrc` with just `ignore-scripts=true`
1034
+ * even when no registry rows are configured). A scoped-only config (no `default`
1035
+ * entry) is valid — only scope `:registry=` lines are emitted, and unscoped
1036
+ * packages fall through to public npm. This matches the server contract
1037
+ * (the `(org, scope)` unique constraint allows scoped-only rows) and is
1038
+ * the right shape for customers who only want to override one `@scope`
1039
+ * without redirecting the rest of npm.
1040
+ */
1041
+ export async function writeNpmrc(targetPath, config, options = {}) {
1042
+ const needsIgnoreScripts = config.allowInstallScripts === false;
1043
+ if (!config.configured && !needsIgnoreScripts) {
1044
+ throw new Error("[npm-registry] writeNpmrc requires a configured config");
1045
+ }
1046
+ const hasDefault = !!config.default;
1047
+ const hasScopes = !!config.scopes && Object.keys(config.scopes).length > 0;
1048
+ if (!hasDefault && !hasScopes && !needsIgnoreScripts) {
1049
+ throw new Error("[npm-registry] writeNpmrc requires at least one registry entry (default or scoped)");
1050
+ }
1051
+ // Flat key -> value map. `.npmrc` uses no `ini` sections at the registry
1052
+ // layer (all keys are top-level), so `ini.stringify` on a flat object
1053
+ // produces the exact wire format npm expects.
1054
+ const obj = {};
1055
+ if (config.default) {
1056
+ const normalizedDefaultUrl = normalizeRegistryUrl(config.default.url);
1057
+ obj["registry"] = normalizedDefaultUrl;
1058
+ const defaultAuthOrigin = toNpmAuthOrigin(normalizedDefaultUrl);
1059
+ if (config.default.token && defaultAuthOrigin) {
1060
+ obj[`${defaultAuthOrigin}:_authToken`] = config.default.token;
1061
+ }
1062
+ }
1063
+ if (config.scopes) {
1064
+ for (const [scope, scopedReg] of Object.entries(config.scopes)) {
1065
+ const normalizedScopeUrl = normalizeRegistryUrl(scopedReg.url);
1066
+ obj[`${scope}:registry`] = normalizedScopeUrl;
1067
+ const scopeAuthOrigin = toNpmAuthOrigin(normalizedScopeUrl);
1068
+ if (scopedReg.token && scopeAuthOrigin) {
1069
+ obj[`${scopeAuthOrigin}:_authToken`] = scopedReg.token;
1070
+ }
1071
+ }
1072
+ }
1073
+ // Bake the org's ignore-scripts policy into the rendered `.npmrc` so any
1074
+ // npm/pnpm invocation in this directory (or `$HOME`) honours the policy
1075
+ // regardless of whether it was launched by AppShell. Covers tools like
1076
+ // patch-package, husky, simple-git-hooks, and ad-hoc `bash npm install`.
1077
+ if (needsIgnoreScripts) {
1078
+ obj["ignore-scripts"] = "true";
1079
+ }
1080
+ // `ini.stringify` returns a trailing-newline-terminated string. Trim and
1081
+ // re-add a single `\n` so the file is normalised regardless of the
1082
+ // version of `ini`.
1083
+ const body = `${ini.stringify(obj).trim()}\n`;
1084
+ let content = body;
1085
+ if (options.header !== undefined) {
1086
+ if (/[\r\n]/.test(options.header)) {
1087
+ throw new Error("[npm-registry] writeNpmrc options.header must not contain newlines");
1088
+ }
1089
+ content = `; ${options.header}\n${body}`;
1090
+ }
1091
+ const mode = options.mode ?? 0o600;
1092
+ await mkdir(path.dirname(targetPath), { recursive: true });
1093
+ // Atomic write: render to a sibling tmp file with restrictive perms, then
1094
+ // rename. Avoids leaving a partial/empty .npmrc on crash mid-write, and
1095
+ // narrows the window where the token might be readable at the default umask.
1096
+ // The atomic rename replaces the target file's inode regardless of the
1097
+ // target's current mode (rename is governed by parent-dir perms), so callers
1098
+ // that pass a write-stripped `mode` (e.g. 0o400) can still rewrite the file
1099
+ // on subsequent syncs.
1100
+ //
1101
+ // We write the tmp file at 0o600 (owner-writable) first so any internal
1102
+ // mode-restricting steps work, then chmod to the requested `mode` right
1103
+ // before the rename so the final file lands with the requested bits set
1104
+ // atomically with the contents.
1105
+ const tmpPath = `${targetPath}.tmp-${process.pid}-${Date.now()}`;
1106
+ try {
1107
+ await writeFile(tmpPath, content, { encoding: "utf-8", mode: 0o600 });
1108
+ // `mode` only applies on creation; explicit chmod handles the case where the
1109
+ // tmp path was preexisting (e.g. crash recovery).
1110
+ await chmod(tmpPath, mode);
1111
+ await rename(tmpPath, targetPath);
1112
+ }
1113
+ catch (error) {
1114
+ // Clean up the tmp file on any failure of write/chmod/rename so we
1115
+ // don't leave `.npmrc.tmp-<pid>-<ts>` siblings accumulating across
1116
+ // boots (especially in `~/` for the home writer). Best-effort: if the
1117
+ // tmp file was never created (writeFile threw) or was already
1118
+ // consumed by the rename, the unlink is a no-op we swallow.
1119
+ await unlink(tmpPath).catch(() => undefined);
1120
+ throw error;
1121
+ }
1122
+ }
1123
+ /**
1124
+ * Filename of the on-disk backup of the baked-in `.npmrc` that ships with the
1125
+ * dev-server image. Captured once per pod boot by `maybeWriteNpmrcForDir`
1126
+ * before the first `writeNpmrc` rewrite, then used as the restore source when
1127
+ * the org transitions back to `not-configured` (e.g. the last
1128
+ * `org_npm_registry` row was deleted). Lives sibling to `.npmrc` in the same
1129
+ * directory writes target.
1130
+ */
1131
+ export const NPMRC_DEFAULT_FILENAME = ".npmrc.default";
1132
+ /**
1133
+ * Snapshot `targetPath` to `backupPath` exactly once if the backup does
1134
+ * not already exist. Lets a subsequent `writeNpmrc`-style rewrite of
1135
+ * `targetPath` happen non-destructively: a restore path has a baked-in
1136
+ * source to copy back when the org transitions to `not-configured`.
1137
+ *
1138
+ * Uses `link(2)` rather than read + write so the snapshot is concurrency-
1139
+ * safe. Two properties matter:
1140
+ *
1141
+ * - The kernel serializes hardlink creation: only one of N concurrent
1142
+ * callers wins; the rest see EEXIST. No read-then-write window where
1143
+ * a slow caller could observe a `writeNpmrc`-rewritten target and
1144
+ * poison the backup with the private registry content.
1145
+ * - `writeNpmrc` rewrites the target via tmp + rename, which gives it
1146
+ * a fresh inode. The hardlink at `backupPath` keeps the original
1147
+ * inode (with the baked-in content) alive — that's the whole point.
1148
+ *
1149
+ * Silently no-ops in two cases:
1150
+ * - `backupPath` is already present (subsequent boots, or a second
1151
+ * call in the same boot after the first capture landed). Important so
1152
+ * a later `writeNpmrc`-rewritten target is never mistaken for the
1153
+ * baked-in baseline.
1154
+ * - `targetPath` does not exist (image without a baked-in `.npmrc`,
1155
+ * or a brownfield app dir that never had one). The natural "restore"
1156
+ * state is "no file", which the restore path handles by treating an
1157
+ * absent backup as "no file" too — for that case `restoreInitialNpmrc`
1158
+ * unlinks the target if asked, otherwise leaves it alone.
1159
+ *
1160
+ * Other errors degrade to a warning + no-op rather than throwing — the
1161
+ * capture is a best-effort safety net for the restore path, not a
1162
+ * precondition for the install path itself.
1163
+ *
1164
+ * Returns a `SnapshotInitialNpmrcOutcome` so a caller can tell whether a
1165
+ * usable backup now exists. This matters for the destructive restore path:
1166
+ * a silent `failed` (e.g. EXDEV) leaves no backup behind, so a later
1167
+ * `not-configured` transition must NOT mistake the absent backup for
1168
+ * "nothing to preserve" and unlink a real baked-in userconfig (APPS-4428).
1169
+ * Still never throws — the outcome is advisory, not an error channel.
1170
+ *
1171
+ * Shared with the home-npmrc writer (CLI startup, target =
1172
+ * `~/.superblocks/npmrc`) so both project-dir and home flows agree on the
1173
+ * snapshot/restore semantics.
1174
+ */
1175
+ export async function snapshotInitialNpmrc(targetPath, backupPath) {
1176
+ try {
1177
+ await link(targetPath, backupPath);
1178
+ return "created";
1179
+ }
1180
+ catch (error) {
1181
+ const code = error?.code;
1182
+ if (code === "EEXIST") {
1183
+ // Snapshot already taken (prior boot or concurrent caller): a usable
1184
+ // backup exists even though this call didn't write it.
1185
+ return "exists";
1186
+ }
1187
+ if (code === "ENOENT") {
1188
+ // No baked-in target to snapshot; the restore baseline is "no file".
1189
+ return "no-source";
1190
+ }
1191
+ getLogger().warn("[npm-registry] failed to capture .npmrc backup; restore path will be unavailable until next pod boot", {
1192
+ target: targetPath,
1193
+ backup: backupPath,
1194
+ code,
1195
+ error: error instanceof Error ? error.message : String(error),
1196
+ });
1197
+ return "failed";
1198
+ }
1199
+ }
1200
+ /**
1201
+ * Restore `targetPath` from `backupPath` when the org has transitioned
1202
+ * back to `not-configured` (e.g. last `org_npm_registry` row deleted).
1203
+ * Without this, a file previously rewritten by `writeNpmrc` stays in
1204
+ * place pointing at a registry the customer just removed — the exact
1205
+ * case APPS-4320 closes for project `.npmrc`, and APPS-4328 closes for
1206
+ * the home-level userconfig.
1207
+ *
1208
+ * Best-effort, never throws. The project-dir caller
1209
+ * (`maybeWriteNpmrcForDir` → `prepareForPrivateRegistry`) needs to fall
1210
+ * through to `stripResolvedFromLockfile` even when the restore can't
1211
+ * run; the home-level caller (`syncHomeNpmrc`) needs to finish dev-server
1212
+ * startup. Any error here degrades to a warn + no-op so the surrounding
1213
+ * install path stays alive.
1214
+ *
1215
+ * Skips the rewrite (without a warning) in three harmless cases:
1216
+ * - `targetPath` does not exist. The baked-in baseline for this dir is
1217
+ * "no file"; there is nothing to restore to.
1218
+ * - `backupPath` is missing AND `options.unlinkTargetWhenBackupMissing`
1219
+ * is not set. Expected on pods that never had `org_npm_registry`
1220
+ * configured (snapshot is gated on the configured branch), AND on
1221
+ * older pods whose target was rewritten before this commit landed.
1222
+ * In both cases the running file is what the pod has lived with —
1223
+ * leave it alone.
1224
+ * - `targetPath` already byte-matches `backupPath`. Avoids a no-op
1225
+ * rewrite that would bump mtime for downstream watchers (e.g. Tilt /
1226
+ * Vite file-sync).
1227
+ *
1228
+ * When `options.unlinkTargetWhenBackupMissing` is true and the backup is
1229
+ * absent but the target exists, the target is unlinked — see the option
1230
+ * comment.
1231
+ */
1232
+ export async function restoreInitialNpmrc(targetPath, backupPath, options = {}) {
1233
+ let current;
1234
+ try {
1235
+ current = await readFile(targetPath, "utf-8");
1236
+ }
1237
+ catch (error) {
1238
+ const code = error?.code;
1239
+ if (code === "ENOENT") {
1240
+ return;
1241
+ }
1242
+ getLogger().warn("[npm-registry] failed to read target for restore comparison; skipping", {
1243
+ path: targetPath,
1244
+ code,
1245
+ error: error instanceof Error ? error.message : String(error),
1246
+ });
1247
+ return;
1248
+ }
1249
+ let baked;
1250
+ try {
1251
+ baked = await readFile(backupPath, "utf-8");
1252
+ }
1253
+ catch (error) {
1254
+ const code = error?.code;
1255
+ if (code === "ENOENT") {
1256
+ if (options.unlinkTargetWhenBackupMissing) {
1257
+ // The caller owns the target file and there is no image-baked
1258
+ // baseline to fall back to. Leaving a stale rewrite in place is
1259
+ // worse than removing the file: subsequent npm/pnpm invocations
1260
+ // pinned at this userconfig will fall through to public npm
1261
+ // rather than an old configured-org registry/token.
1262
+ try {
1263
+ await unlink(targetPath);
1264
+ getLogger().info("[npm-registry] removed Superblocks-owned userconfig after org transitioned to not-configured (no backup to restore)", { path: targetPath });
1265
+ }
1266
+ catch (unlinkError) {
1267
+ const unlinkCode = unlinkError
1268
+ ?.code;
1269
+ if (unlinkCode === "ENOENT") {
1270
+ return;
1271
+ }
1272
+ getLogger().warn("[npm-registry] failed to remove Superblocks-owned userconfig with no backup; leaving file in place", {
1273
+ path: targetPath,
1274
+ code: unlinkCode,
1275
+ error: unlinkError instanceof Error
1276
+ ? unlinkError.message
1277
+ : String(unlinkError),
1278
+ });
1279
+ }
1280
+ return;
1281
+ }
1282
+ // Two harmless overlapping cases produce this for project-dir
1283
+ // callers:
1284
+ // 1. Pod never had `org_npm_registry` rows, so capture (gated on
1285
+ // the configured branch) never fired. The target is still the
1286
+ // baked-in image content — nothing to restore.
1287
+ // 2. Pod was configured-then-deconfigured before this commit
1288
+ // landed, so the target is a stale rewrite with no companion
1289
+ // snapshot. A recycle is required to recover, but per-install
1290
+ // logging here would be noisy and not actionable.
1291
+ // Either way, no-op silently.
1292
+ return;
1293
+ }
1294
+ getLogger().warn("[npm-registry] failed to read .npmrc backup for restore; skipping", {
1295
+ path: backupPath,
1296
+ code,
1297
+ error: error instanceof Error ? error.message : String(error),
1298
+ });
1299
+ return;
1300
+ }
1301
+ if (current === baked) {
1302
+ return;
1303
+ }
1304
+ // Atomic copy: tmp + rename, mirroring `writeNpmrc`'s strategy so a
1305
+ // crash mid-restore cannot leave a half-written file that fails
1306
+ // `npm install` with a parse error.
1307
+ const tmpPath = `${targetPath}.tmp-${process.pid}-${Date.now()}`;
1308
+ try {
1309
+ await writeFile(tmpPath, baked, { encoding: "utf-8", mode: 0o600 });
1310
+ await chmod(tmpPath, 0o600);
1311
+ await rename(tmpPath, targetPath);
1312
+ }
1313
+ catch (error) {
1314
+ await unlink(tmpPath).catch(() => { });
1315
+ // Swallow + warn rather than rethrow: the project-dir caller chains
1316
+ // into `stripResolvedFromLockfile` (APPS-4300), which is the actual
1317
+ // durable safety net for poisoned lockfiles. Propagating the restore
1318
+ // failure would skip that strip and leave the install path worse off
1319
+ // than pre-APPS-4320.
1320
+ getLogger().warn("[npm-registry] failed to restore .npmrc from backup; leaving current file in place", {
1321
+ path: targetPath,
1322
+ error: error instanceof Error ? error.message : String(error),
1323
+ });
1324
+ return;
1325
+ }
1326
+ getLogger().info("[npm-registry] restored .npmrc from backup after org transitioned to not-configured", { path: targetPath });
1327
+ }
1328
+ /**
1329
+ * Marker on the appended ignore block so we can detect a prior append and
1330
+ * skip the work. Read-side checks are by exact-line match, not by this
1331
+ * marker, so a customer who hand-edits the file (deletes the marker, keeps
1332
+ * the `.npmrc` line) still gets the no-op behaviour they want.
1333
+ */
1334
+ const NPMRC_GITIGNORE_MARKER = "# Superblocks: prevent committing private npm registry credentials";
1335
+ /**
1336
+ * True iff `<dir>` looks like a native-git checkout. Detects both regular
1337
+ * repos (`.git/` directory) and worktrees / submodules (`.git` file containing
1338
+ * a `gitdir:` pointer). Any stat error other than ENOENT is logged and the
1339
+ * function returns true, so a permission glitch fails closed (we will then
1340
+ * refuse to write the token-bearing `.npmrc` rather than assume "safe,
1341
+ * not a git checkout").
1342
+ *
1343
+ * Note: this only checks for `<dir>/.git` literally. `isInsideGitWorkTree`
1344
+ * is the broader check that also catches nested-repo layouts where `<dir>`
1345
+ * has no `.git` but a parent does — we need both because the parent-repo
1346
+ * case is also a `git add .` leak path (cursor[bot] review on PR #19642).
1347
+ */
1348
+ async function dirHasNativeGit(dir) {
1349
+ const gitPath = path.join(dir, ".git");
1350
+ try {
1351
+ await stat(gitPath);
1352
+ return true;
1353
+ }
1354
+ catch (error) {
1355
+ const code = error?.code;
1356
+ if (code === "ENOENT") {
1357
+ return false;
1358
+ }
1359
+ getLogger().warn("[npm-registry] failed to stat .git; assuming native-git for safety", {
1360
+ path: gitPath,
1361
+ code,
1362
+ error: error instanceof Error ? error.message : String(error),
1363
+ });
1364
+ return true;
1365
+ }
1366
+ }
1367
+ /**
1368
+ * True iff `<dir>` is inside any git working tree — either because it has
1369
+ * its own `.git` (regular repo, worktree, submodule) OR because a parent
1370
+ * directory does. The nested-repo case is a real leak path: an app dir
1371
+ * with no local `.git` but a parent that does will be staged by
1372
+ * `git add .` run from the parent, and the `.npmrc` token would land in
1373
+ * the parent's commit history.
1374
+ *
1375
+ * Implementation: `git rev-parse --is-inside-work-tree` walks up from
1376
+ * `<dir>` and exits 0 inside a work tree, non-zero (128) outside. Uses
1377
+ * the same `runGit` scrubbed-env wrapper so a caller spawned by a git
1378
+ * hook can't poison the verdict via `GIT_*` env vars. If git itself is
1379
+ * missing or the invocation times out (`runGit` returns `code: null`),
1380
+ * returns false — there is no git to stage anything with, so the
1381
+ * non-native branch handles it via the proactively-created `.gitignore`.
1382
+ */
1383
+ async function isInsideGitWorkTree(dir) {
1384
+ if (await dirHasNativeGit(dir)) {
1385
+ return true;
1386
+ }
1387
+ const result = await runGit(dir, ["rev-parse", "--is-inside-work-tree"]);
1388
+ if (result.code === 0) {
1389
+ return true;
1390
+ }
1391
+ if (result.code === 128) {
1392
+ // Canonical "not a git repository" exit. Definitively outside any
1393
+ // work tree — the non-native-git branch is correct.
1394
+ return false;
1395
+ }
1396
+ if (result.code === null) {
1397
+ // git binary missing or invocation timed out (`runGit` returns
1398
+ // `code: null` for any non-exit failure: ENOENT for `git`, ETIMEDOUT
1399
+ // after `GIT_VERIFY_TIMEOUT_MS`, signal kills, etc.).
1400
+ //
1401
+ // Returning `false` here routes us into the non-native-git branch,
1402
+ // which is the SAFER choice in every realistic scenario:
1403
+ //
1404
+ // 1. Local-`.git` case is unreachable here: `dirHasNativeGit` short-
1405
+ // circuited above when `<dir>/.git` exists, so we never hit
1406
+ // `rev-parse` for a regular repo at `<dir>`.
1407
+ //
1408
+ // 2. Nested-parent-repo case (the cursor[bot] concern): the parent
1409
+ // has `.git` but the app dir doesn't. If git is missing, the
1410
+ // customer cannot run `git add .` from the parent either — there
1411
+ // is no git binary to stage anything with. The fail-closed
1412
+ // requirement only matters when a working git is present, and a
1413
+ // working git would have returned `0` (or `128`), not `null`.
1414
+ // For the timeout case, a hung `rev-parse --is-inside-work-tree`
1415
+ // on a real repo would be unprecedented (the command only walks
1416
+ // parent directories looking for `.git`); a timeout in practice
1417
+ // means a broken environment where `git add` would also fail.
1418
+ //
1419
+ // 3. The non-native-git branch we route into still calls
1420
+ // `appendNpmrcIgnore` on `<dir>/.gitignore`. If that succeeds,
1421
+ // a future `git init` (or `git` reappearing on PATH) finds the
1422
+ // ignore entry already in place and is future-safe. If
1423
+ // `appendNpmrcIgnore` fails, `ensureNpmrcGitignored` returns
1424
+ // `{ignored:false, hasGit:false}` and the caller refuses to write
1425
+ // the credential-bearing `.npmrc`.
1426
+ //
1427
+ // Returning `true` here instead would force the per-clone exclude
1428
+ // fallback, but that fallback also calls `verifyNpmrcIgnoredByGit`
1429
+ // (same `runGit`) which would also return `code: null` and fail —
1430
+ // ending in the same fail-closed state but with an extra useless
1431
+ // attempt and a misleading "inside-repo" log line.
1432
+ return false;
1433
+ }
1434
+ // Unexpected non-zero from git. Assume inside-a-repo for safety; the
1435
+ // downstream verification will either confirm or fail closed.
1436
+ getLogger().warn("[npm-registry] git rev-parse --is-inside-work-tree returned unexpected exit code; assuming inside-repo for safety", { dir, code: result.code, stderr: result.stderr });
1437
+ return true;
1438
+ }
1439
+ /**
1440
+ * Returns true if the LAST matching rule for `.npmrc` in `text` is a
1441
+ * positive ignore (vs. a `!.npmrc` negation). Gitignore semantics are
1442
+ * "last matching pattern wins": a file containing `.npmrc` followed later
1443
+ * by `!.npmrc` re-includes the file, so a naive "does any line match
1444
+ * `.npmrc`?" check is a false positive that would let the append be
1445
+ * skipped and the credential-bearing `.npmrc` later staged on `git add .`.
1446
+ * Walk the file in order and remember the most recent verdict; return true
1447
+ * only when that verdict is a positive ignore.
1448
+ *
1449
+ * Matches npm/git's own grammar for our specific filename: a line is the
1450
+ * literal `.npmrc` (anchored anywhere) or `/.npmrc` (anchored to repo
1451
+ * root), with optional `!` negation prefix. We do NOT try to interpret
1452
+ * glob patterns like `*.rc` — false negatives just append a redundant
1453
+ * line (always safe under last-match), false positives would leak
1454
+ * credentials.
1455
+ *
1456
+ * Leading whitespace is NOT trimmed: in gitignore grammar leading spaces
1457
+ * are significant, so ` .npmrc` matches a file literally named ` .npmrc`,
1458
+ * NOT `.npmrc`. Trimming here would be a false positive (we'd skip the
1459
+ * append, but git would still stage `.npmrc`). Only two normalisations
1460
+ * happen, both to match git's own pattern parser exactly:
1461
+ *
1462
+ * - Trailing CR from CRLF line endings is stripped (CR is not part of
1463
+ * the path).
1464
+ * - UNESCAPED trailing spaces are stripped (`trim_trailing_spaces` in
1465
+ * git's `dir.c`). `.npmrc ` is the pattern `.npmrc`; `!.npmrc `
1466
+ * is the negation `!.npmrc`. This is the gpoulios-sb PR #19642
1467
+ * re-re-review case: a stray trailing space on `!.npmrc` made git
1468
+ * treat the line as a negation while a naive textual check still
1469
+ * matched the earlier `.npmrc` positive, so the helper declared the
1470
+ * file "ignored" and `maybeWriteNpmrcForDir` proceeded to write
1471
+ * credentials that a later `git init && git add .` would stage.
1472
+ * Tabs are NOT trimmed (git only trims spaces); `\<space>` escapes
1473
+ * a literal trailing space and is preserved.
1474
+ *
1475
+ * Other gitignore exotica (globs, character classes, `**`, backslash
1476
+ * escapes, leading `\!`, UTF-8 BOM, etc.) are NOT interpreted. All of
1477
+ * those cases fail the exact-match comparison below, so the textual
1478
+ * verdict is "not ignored" — the helper then appends a fresh positive
1479
+ * `.npmrc` rule and last-match-wins semantics make the file genuinely
1480
+ * ignored. False negatives are safe (one redundant line); false
1481
+ * positives leak credentials, so we err on the side of appending.
1482
+ *
1483
+ * This is the authoritative non-native-git check (gpoulios-sb PR #19642
1484
+ * re-review): the non-git branch in `ensureNpmrcGitignored` has no
1485
+ * `git check-ignore` follow-up, so the textual verdict must itself be
1486
+ * future-safe against order-sensitive negations — otherwise a later
1487
+ * `git init && git add .` in the same dir would stage a token-bearing
1488
+ * `.npmrc` that the helper had blessed.
1489
+ *
1490
+ * For native-git checkouts textual presence is still necessary but NOT
1491
+ * sufficient — `verifyNpmrcIgnoredByGit` is the authoritative check
1492
+ * because:
1493
+ *
1494
+ * - A negation in a DESCENDANT `.gitignore` (not just this file) can
1495
+ * re-include `.npmrc`; the textual check sees only the current file.
1496
+ * - An already-tracked `.npmrc` is staged on every commit regardless of
1497
+ * ignore rules; the textual check has no view of the index.
1498
+ */
1499
+ function textIgnoresNpmrc(text) {
1500
+ let lastVerdict;
1501
+ for (const raw of text.split("\n")) {
1502
+ const line = trimTrailingGitignoreSpaces(raw.replace(/\r$/, ""));
1503
+ if (line === ".npmrc" || line === "/.npmrc") {
1504
+ lastVerdict = true;
1505
+ }
1506
+ else if (line === "!.npmrc" || line === "!/.npmrc") {
1507
+ lastVerdict = false;
1508
+ }
1509
+ }
1510
+ return lastVerdict === true;
1511
+ }
1512
+ /**
1513
+ * Strip trailing unescaped spaces from a gitignore pattern, matching
1514
+ * git's `trim_trailing_spaces` (in `dir.c`) exactly.
1515
+ *
1516
+ * Algorithm (mirrors git's left-to-right walk):
1517
+ * - Track the position of the first trailing space.
1518
+ * - A `\<space>` pair is an escaped space and resets the tracker
1519
+ * (the space is part of the pattern).
1520
+ * - Any non-space character resets the tracker.
1521
+ * - Truncate at the first tracked trailing space.
1522
+ *
1523
+ * Only ASCII spaces (0x20) are trimmed. Tabs, NBSP, and other
1524
+ * whitespace are preserved — that's what git does. The CR strip happens
1525
+ * separately in `textIgnoresNpmrc`'s split loop because git treats CR as
1526
+ * a line-ending artefact, not a pattern character.
1527
+ *
1528
+ * Examples (matching git's behaviour):
1529
+ * "!.npmrc " → "!.npmrc" (trailing space trimmed)
1530
+ * "!.npmrc " → "!.npmrc" (multiple trailing spaces trimmed)
1531
+ * "!.npmrc\\ " → "!.npmrc\\ " (escaped space preserved)
1532
+ * "!.npmrc\\t" → "!.npmrc\\t" (tab preserved; not a space)
1533
+ * " .npmrc" → " .npmrc" (leading whitespace preserved)
1534
+ */
1535
+ function trimTrailingGitignoreSpaces(line) {
1536
+ let lastSpace = -1;
1537
+ for (let i = 0; i < line.length; i++) {
1538
+ const ch = line[i];
1539
+ if (ch === "\\" && line[i + 1] === " ") {
1540
+ // Escaped space: skip the pair AND reset the tracker so the
1541
+ // escaped space cannot anchor a truncation.
1542
+ i++;
1543
+ lastSpace = -1;
1544
+ }
1545
+ else if (ch === " ") {
1546
+ if (lastSpace === -1) {
1547
+ lastSpace = i;
1548
+ }
1549
+ }
1550
+ else {
1551
+ lastSpace = -1;
1552
+ }
1553
+ }
1554
+ return lastSpace === -1 ? line : line.slice(0, lastSpace);
1555
+ }
1556
+ /**
1557
+ * Timeout (ms) for the `git` invocations in `verifyNpmrcIgnoredByGit`.
1558
+ * Generous enough for any realistic working tree (these commands scan only
1559
+ * the index and ignore rules, not the working tree), short enough that a
1560
+ * hung git invocation can't stall the install path.
1561
+ */
1562
+ const GIT_VERIFY_TIMEOUT_MS = 5000;
1563
+ /**
1564
+ * Build a `process.env` copy with every `GIT_*` variable removed. Used by
1565
+ * `runGit` to insulate the helper from outer-process git state. See the
1566
+ * comment in `runGit` for the leak path this guards against.
1567
+ */
1568
+ function scrubbedGitEnv() {
1569
+ const env = {};
1570
+ for (const [key, value] of Object.entries(process.env)) {
1571
+ if (!key.startsWith("GIT_")) {
1572
+ env[key] = value;
1573
+ }
1574
+ }
1575
+ return env;
1576
+ }
1577
+ /**
1578
+ * Run `git <args>` in `cwd`, returning the exit code without throwing. Any
1579
+ * non-spawn error (timeout, ENOENT for `git`, etc.) returns `{ code: null }`
1580
+ * so the caller fails closed. We use `execFile` (no shell) so the file
1581
+ * arguments cannot be reinterpreted as shell syntax.
1582
+ */
1583
+ async function runGit(cwd, args) {
1584
+ try {
1585
+ const { stderr } = await execFileAsync("git", args, {
1586
+ cwd,
1587
+ timeout: GIT_VERIFY_TIMEOUT_MS,
1588
+ // Even if git emits a lot of stderr (unlikely for these tiny
1589
+ // commands), bound the buffer so we don't OOM the install path.
1590
+ maxBuffer: 1024 * 1024,
1591
+ // Scrub `GIT_*` env vars before invoking git. If a caller's process
1592
+ // was itself spawned by git (e.g. a `pre-commit` hook), git will
1593
+ // have exported `GIT_DIR`, `GIT_INDEX_FILE`, `GIT_WORK_TREE`,
1594
+ // `GIT_PREFIX`, etc. pointing at the OUTER repo. Those would
1595
+ // override `cwd` discovery and make `check-ignore` / `ls-files`
1596
+ // query the wrong repository, producing wrong fail-closed
1597
+ // verdicts. The npm install path is not normally invoked from a
1598
+ // git hook, but stripping these is cheap insurance.
1599
+ env: scrubbedGitEnv(),
1600
+ });
1601
+ return { code: 0, stderr };
1602
+ }
1603
+ catch (error) {
1604
+ // Promisified `execFile` throws an ExecException for both non-zero
1605
+ // exits and spawn failures. Distinguish them via `code`:
1606
+ // - number → process exited with that code
1607
+ // - string ('ENOENT', 'ETIMEDOUT', etc.) → spawn / signal failure
1608
+ const err = error;
1609
+ const code = err?.code;
1610
+ const stderr = err?.stderr ?? "";
1611
+ if (typeof code === "number") {
1612
+ return { code, stderr };
1613
+ }
1614
+ return { code: null, stderr };
1615
+ }
1616
+ }
1617
+ /**
1618
+ * Use git itself to verify that `.npmrc` is BOTH effectively ignored AND
1619
+ * not already tracked from `dir`. Closes two leak paths that a textual
1620
+ * `.gitignore` check cannot:
1621
+ *
1622
+ * 1. Negated ignore rules. `.npmrc` followed later by `!.npmrc` (or by
1623
+ * `!.npmrc` in a descendant `.gitignore`) makes the file trackable.
1624
+ * `textIgnoresNpmrc` would still report true.
1625
+ * 2. Already-tracked `.npmrc`. Ignore rules do NOT protect files that
1626
+ * are already in the index — the next commit stages the rewrite. A
1627
+ * brownfield app that committed an empty `.npmrc` before the
1628
+ * private-registry feature is the canonical case.
1629
+ *
1630
+ * Returns true ONLY when both checks positively prove safety:
1631
+ * - `git check-ignore -q .npmrc` exits 0 (file is effectively ignored)
1632
+ * - `git ls-files --error-unmatch .npmrc` exits 1 (file is NOT tracked)
1633
+ *
1634
+ * Any other outcome — file not ignored, file tracked, git missing, not a
1635
+ * real repo, timeout, unexpected exit code — returns false. The caller
1636
+ * fails closed and refuses to write the credential-bearing `.npmrc`.
1637
+ */
1638
+ async function verifyNpmrcIgnoredByGit(dir) {
1639
+ const checkIgnore = await runGit(dir, ["check-ignore", "-q", "--", ".npmrc"]);
1640
+ if (checkIgnore.code !== 0) {
1641
+ if (checkIgnore.code === 1) {
1642
+ getLogger().warn("[npm-registry] git check-ignore reports .npmrc is NOT effectively ignored (likely a `!.npmrc` negation downstream); refusing to write credential-bearing .npmrc", { dir });
1643
+ }
1644
+ else {
1645
+ getLogger().warn("[npm-registry] git check-ignore failed (not a real git repo, git missing, or timeout); refusing to write credential-bearing .npmrc", { dir, code: checkIgnore.code, stderr: checkIgnore.stderr });
1646
+ }
1647
+ return false;
1648
+ }
1649
+ const lsFiles = await runGit(dir, [
1650
+ "ls-files",
1651
+ "--error-unmatch",
1652
+ "--",
1653
+ ".npmrc",
1654
+ ]);
1655
+ if (lsFiles.code === 0) {
1656
+ // File is in the index. Even with `.gitignore` containing `.npmrc`,
1657
+ // rewriting the file with `_authToken=…` will stage on the next
1658
+ // commit because git tracks file content for already-tracked files
1659
+ // regardless of the ignore list.
1660
+ getLogger().warn("[npm-registry] .npmrc is already tracked by git; refusing to write credentials (next commit would stage the token)", { dir });
1661
+ return false;
1662
+ }
1663
+ if (lsFiles.code !== 1) {
1664
+ // 1 is the canonical "not tracked" exit (`error: pathspec '.npmrc' did
1665
+ // not match any file(s) known to git`). Other non-zero codes mean
1666
+ // something is wrong with the repo / our invocation — fail closed.
1667
+ getLogger().warn("[npm-registry] git ls-files returned an unexpected exit code; refusing to write credential-bearing .npmrc", { dir, code: lsFiles.code, stderr: lsFiles.stderr });
1668
+ return false;
1669
+ }
1670
+ return true;
1671
+ }
1672
+ /**
1673
+ * Append (or create) an ignore file at `targetPath` so that `.npmrc` is
1674
+ * excluded. Returns true on success, false on any I/O failure. `createIfMissing`
1675
+ * controls whether an absent file is created. All `ensureNpmrcGitignored`
1676
+ * call sites pass `true` (so a missing `.gitignore` or `.git/info/exclude`
1677
+ * is materialised before the credential write); the parameter is preserved
1678
+ * so future callers can opt into a strict "only append, never create"
1679
+ * behaviour without touching the body.
1680
+ */
1681
+ async function appendNpmrcIgnore(targetPath, createIfMissing) {
1682
+ // Refuse to follow a symlink at the leaf path component on BOTH the read
1683
+ // and the write. `targetPath` is `<dir>/.gitignore` or
1684
+ // `<dir>/.git/info/exclude`; a crafted workspace could point either at a
1685
+ // file outside the app root. `readFile`/`writeFile` follow symlinks, so
1686
+ // without `O_NOFOLLOW` our ~70-byte ignore fragment could be written
1687
+ // through the link to an external target (cursor[bot] MEDIUM, colinhicks
1688
+ // review on PR #19642). Opening with `O_NOFOLLOW` fails with `ELOOP` when
1689
+ // the leaf is a symlink; we treat that as fail-closed (return false) so
1690
+ // `ensureNpmrcGitignored` refuses the credential write — same boundary
1691
+ // discipline as `persisted-checklist-store.ts` / PR #19495, but TOCTOU-free
1692
+ // because the kernel checks atomically at open time. `O_NOFOLLOW` is POSIX;
1693
+ // `?? 0` degrades to a plain open where it is absent (the dev-server runs
1694
+ // on Linux, where it is always defined).
1695
+ const noFollow = fsConstants.O_NOFOLLOW ?? 0;
1696
+ let existing;
1697
+ let readHandle;
1698
+ try {
1699
+ readHandle = await open(targetPath, fsConstants.O_RDONLY | noFollow);
1700
+ existing = await readHandle.readFile("utf-8");
1701
+ }
1702
+ catch (error) {
1703
+ const code = error?.code;
1704
+ if (code === "ELOOP") {
1705
+ getLogger().warn("[npm-registry] ignore file is a symlink; refusing to follow it for .npmrc enforcement", { path: targetPath });
1706
+ return false;
1707
+ }
1708
+ if (code !== "ENOENT") {
1709
+ getLogger().warn("[npm-registry] failed to read ignore file; skipping .npmrc enforcement", {
1710
+ path: targetPath,
1711
+ code,
1712
+ error: error instanceof Error ? error.message : String(error),
1713
+ });
1714
+ return false;
1715
+ }
1716
+ if (!createIfMissing) {
1717
+ return false;
1718
+ }
1719
+ existing = undefined;
1720
+ }
1721
+ finally {
1722
+ await readHandle?.close();
1723
+ }
1724
+ if (existing !== undefined && textIgnoresNpmrc(existing)) {
1725
+ return true;
1726
+ }
1727
+ // Separate the appended block from any existing content with a blank line.
1728
+ // For an empty / freshly-created file start at column 0 with no leading
1729
+ // blank line (cosmetic, colinhicks review on PR #19642). For non-empty
1730
+ // content the byte output is unchanged.
1731
+ const base = existing ?? "";
1732
+ const sep = base.length === 0 ? "" : base.endsWith("\n") ? "\n" : "\n\n";
1733
+ const appended = `${base}${sep}${NPMRC_GITIGNORE_MARKER}\n.npmrc\n`;
1734
+ let writeHandle;
1735
+ try {
1736
+ // `O_TRUNC` is safe: we re-serialise the full file (existing content +
1737
+ // appended block), so truncation never drops data. `O_NOFOLLOW` closes
1738
+ // the TOCTOU window where the leaf is swapped for a symlink between the
1739
+ // read above and this write. Mode 0o666 matches the previous `writeFile`
1740
+ // default (umask trims it to 0o644) and is ignored when the file already
1741
+ // exists.
1742
+ writeHandle = await open(targetPath, fsConstants.O_WRONLY |
1743
+ fsConstants.O_CREAT |
1744
+ fsConstants.O_TRUNC |
1745
+ noFollow, 0o666);
1746
+ await writeHandle.writeFile(appended, "utf-8");
1747
+ getLogger().info("[npm-registry] appended .npmrc to ignore file to prevent credential commit", { path: targetPath });
1748
+ return true;
1749
+ }
1750
+ catch (error) {
1751
+ const code = error?.code;
1752
+ if (code === "ELOOP") {
1753
+ getLogger().warn("[npm-registry] ignore file became a symlink before write; refusing to write through it", { path: targetPath });
1754
+ return false;
1755
+ }
1756
+ getLogger().warn("[npm-registry] failed to append .npmrc to ignore file", {
1757
+ path: targetPath,
1758
+ error: error instanceof Error ? error.message : String(error),
1759
+ });
1760
+ return false;
1761
+ }
1762
+ finally {
1763
+ await writeHandle?.close();
1764
+ }
1765
+ }
1766
+ /**
1767
+ * Ensure `.npmrc` is git-ignored from `<dir>` before any credential-bearing
1768
+ * `.npmrc` is written.
1769
+ *
1770
+ * Why this matters: `maybeWriteNpmrcForDir` writes a `.npmrc` containing
1771
+ * `//host/:_authToken=<the machine's Superblocks login token>` at the app
1772
+ * root. That token authenticates to the Superblocks npm proxy; the
1773
+ * customer's upstream registry password is held server-side and never
1774
+ * reaches disk. It is still a Superblocks credential, so it must not be
1775
+ * committed. The DBFS sync already excludes `.npmrc` from upload
1776
+ * (`codeModeExcludedFiles` in `file-system-helpers.ts`), but the native-git
1777
+ * path calls `git.add(".")` (socket-manager `gitCommitLocal`/`gitPull`,
1778
+ * agent `git`/`git_raw` tools) which stages everything not listed in the
1779
+ * app's on-disk ignore. Without this enforcement, a customer with a
1780
+ * configured private registry pushes that login `_authToken` to their
1781
+ * external git remote on the next commit. The
1782
+ * template `.gitignore` covers new apps; this helper covers the existing
1783
+ * fleet whose `.gitignore` predates the registry feature.
1784
+ *
1785
+ * Behaviour, in three layers:
1786
+ *
1787
+ * 1. Non-native-git (`<dir>/.git` does not exist):
1788
+ * - Append `.npmrc` to `<dir>/.gitignore`, or create the file if
1789
+ * it doesn't exist. We create `.gitignore` here (not just when
1790
+ * `.git` already exists) so a subsequent `git init` in the same
1791
+ * directory is future-safe: a customer who later turns on native
1792
+ * git for an app where a credential-bearing `.npmrc` already
1793
+ * sits on disk would otherwise stage the token on their first
1794
+ * `git add .` before any install path re-runs this helper.
1795
+ * - On success return `{ ignored: true, hasGit: false }`. On a
1796
+ * read or write failure (`.gitignore` is a directory, disk full,
1797
+ * permission denied) return `{ ignored: false, hasGit: false }`.
1798
+ * The caller MUST refuse to write the credential-bearing
1799
+ * `.npmrc` in that case: even though no native git checkout
1800
+ * exists today, a later `git init` (or wiring this dir into an
1801
+ * existing repo) would find the on-disk token and stage it on
1802
+ * the first `git add .` — exactly the future-git leak path
1803
+ * gpoulios-sb flagged in code review.
1804
+ *
1805
+ * 2. Native-git (`<dir>/.git` exists), `.gitignore` path:
1806
+ * - Read or create `.gitignore`, append `.npmrc` if missing. After
1807
+ * the append, verify with git itself (`verifyNpmrcIgnoredByGit`)
1808
+ * that the file is effectively ignored AND not already tracked.
1809
+ * Only then return `ignored: true`.
1810
+ *
1811
+ * 3. Native-git, `.git/info/exclude` fallback:
1812
+ * - Only attempted when the `.gitignore` write failed AND `.git` is a
1813
+ * directory (regular repo). `.git/info/exclude` is the per-clone
1814
+ * ignore file: not synced to remotes, but exactly as effective as
1815
+ * `.gitignore` at preventing `git add` from staging the file. The
1816
+ * fallback lets us still fail-closed when the working tree is
1817
+ * read-only but the local clone metadata is writable. After the
1818
+ * exclude append, the same `verifyNpmrcIgnoredByGit` check runs.
1819
+ *
1820
+ * Why git verification, not just text: a `.gitignore` containing `.npmrc`
1821
+ * is necessary but not sufficient. Two real leak paths bypass a naive
1822
+ * "any line matches" textual check:
1823
+ * - A later `!.npmrc` re-includes the file (gitignore is order-sensitive).
1824
+ * `textIgnoresNpmrc` is already negation-aware (returns true only when
1825
+ * the LAST matching rule is positive), so for this case the textual
1826
+ * check correctly reports "not ignored" and `appendNpmrcIgnore` writes
1827
+ * a fresh positive `.npmrc` line that becomes the new last-match.
1828
+ * This is the gpoulios-sb PR #19642 re-review "always append" remedy,
1829
+ * applied uniformly to both branches (non-native-git relies on it as
1830
+ * the authoritative check; native-git double-checks with git below).
1831
+ * - An already-tracked `.npmrc` stages on every commit regardless of
1832
+ * ignore rules. No textual check sees the index, so for native-git
1833
+ * `git ls-files --error-unmatch` is the only catch.
1834
+ *
1835
+ * Returns `{ ignored, hasGit }`. The caller's fail-closed signal is
1836
+ * `ignored === false` regardless of `hasGit`: any state in which we cannot
1837
+ * guarantee `.npmrc` is ignored from `<dir>` blocks the credential write,
1838
+ * because either the current native git checkout would stage the token on
1839
+ * the next `git add .`, or a future `git init` in the same dir would find
1840
+ * the token on disk and stage it on the first `git add .`. `hasGit` is
1841
+ * retained for logging only — it lets the warning distinguish the
1842
+ * "tomorrow's risk" case from the "today's risk" case.
1843
+ */
1844
+ export async function ensureNpmrcGitignored(dir) {
1845
+ // `hasGit` covers BOTH the local-`.git` and nested-repo (parent has
1846
+ // `.git`) cases. The nested-repo case was the cursor[bot] PR #19642
1847
+ // review concern: an app dir inside a parent git repo has no local
1848
+ // `.git`, so a bare `dirHasNativeGit` check would treat it as
1849
+ // non-native-git and let credentials through; `git add .` run from the
1850
+ // parent would then stage `<dir>/.npmrc`. The local-`.git`-only check
1851
+ // is still needed for the `.git/info/exclude` fallback below (that
1852
+ // path only exists for regular repos, not nested-only layouts).
1853
+ const hasGit = await isInsideGitWorkTree(dir);
1854
+ const hasLocalDotGit = await dirHasNativeGit(dir);
1855
+ const gitignorePath = path.join(dir, ".gitignore");
1856
+ // Always create `.gitignore` if missing — even when `!hasGit` — so a
1857
+ // later `git init` in this dir finds the `.npmrc` entry already in
1858
+ // place and the first `git add .` cannot stage a credential file that
1859
+ // was written between the two events. See the layer-1 comment in this
1860
+ // function's docstring for the future-safe rationale.
1861
+ if (await appendNpmrcIgnore(gitignorePath, true)) {
1862
+ if (!hasGit) {
1863
+ return { ignored: true, hasGit: false };
1864
+ }
1865
+ if (await verifyNpmrcIgnoredByGit(dir)) {
1866
+ return { ignored: true, hasGit: true };
1867
+ }
1868
+ // Textual append succeeded but git disagrees: a downstream `!.npmrc`
1869
+ // negation, an already-tracked `.npmrc`, or `git` is unable to verify
1870
+ // (missing, broken repo, timeout). Fall through to the per-clone
1871
+ // exclude fallback — it can override `.gitignore` negations (exclude
1872
+ // rules are evaluated last) AND covers the "no git binary / bad repo"
1873
+ // case in the same way (the fallback verifies too, and fails closed).
1874
+ }
1875
+ if (!hasGit) {
1876
+ // Non-native-git, no parent repo either: the `.gitignore` append/create
1877
+ // failed (rare — disk full, permission denied, or `.gitignore` was a
1878
+ // directory). Fail-closed: the future-git leak path is still open.
1879
+ return { ignored: false, hasGit: false };
1880
+ }
1881
+ // Inside a git work tree: `.gitignore` enforcement failed (or git
1882
+ // verification rejected it). Try the per-clone exclude file as a
1883
+ // fallback. Only valid when `<dir>/.git` is a directory (regular repo
1884
+ // rooted here); for a nested-repo case (`hasGit` but no local
1885
+ // `.git`) we have no path to the parent's `.git/info/exclude` without
1886
+ // a `git rev-parse --git-dir`, and the same exclude in the parent
1887
+ // won't anchor to `<dir>` anyway. Fail closed in those cases.
1888
+ const dotGit = path.join(dir, ".git");
1889
+ let dotGitIsDir = false;
1890
+ if (hasLocalDotGit) {
1891
+ try {
1892
+ const st = await stat(dotGit);
1893
+ dotGitIsDir = st.isDirectory();
1894
+ }
1895
+ catch {
1896
+ // Already covered by `dirHasNativeGit` — if we got here, the path
1897
+ // existed at the time of that check. A subsequent disappearance is
1898
+ // odd but we still fail closed.
1899
+ }
1900
+ }
1901
+ if (!dotGitIsDir) {
1902
+ getLogger().warn("[npm-registry] native-git checkout has no writable .gitignore and .git is not a regular directory; refusing to write .npmrc", { path: gitignorePath });
1903
+ return { ignored: false, hasGit: true };
1904
+ }
1905
+ const infoDir = path.join(dotGit, "info");
1906
+ try {
1907
+ await mkdir(infoDir, { recursive: true });
1908
+ }
1909
+ catch (error) {
1910
+ getLogger().warn("[npm-registry] failed to create .git/info directory for exclude fallback", {
1911
+ path: infoDir,
1912
+ error: error instanceof Error ? error.message : String(error),
1913
+ });
1914
+ return { ignored: false, hasGit: true };
1915
+ }
1916
+ const excludePath = path.join(infoDir, "exclude");
1917
+ if (await appendNpmrcIgnore(excludePath, true)) {
1918
+ // Verify with git again. The exclude file is evaluated LAST in git's
1919
+ // ignore precedence, so it overrides a `!.npmrc` negation in
1920
+ // `.gitignore`. But it still cannot un-track an already-tracked file,
1921
+ // so `ls-files --error-unmatch` is still the gate.
1922
+ if (await verifyNpmrcIgnoredByGit(dir)) {
1923
+ return { ignored: true, hasGit: true };
1924
+ }
1925
+ }
1926
+ return { ignored: false, hasGit: true };
1927
+ }
1928
+ /**
1929
+ * Convenience: invoke `writeNpmrc` against `<dir>/.npmrc` when the client
1930
+ * resolves to a configured (or stale) registry config. No-op when:
1931
+ *
1932
+ * - `client` is undefined (test-only opt-out — production code paths
1933
+ * always pass a client constructed by AiService); or
1934
+ * - the resolved config is `source: "unreachable"` (transient cold-cache
1935
+ * outage — we leave `.npmrc` whatever it currently is and reconcile on
1936
+ * the next successful fetch, rather than clobbering a last-known-good
1937
+ * private-registry `.npmrc` back to baseline during the outage window);
1938
+ * or
1939
+ * - the resolved config is `source: "not-configured"` (deliberate unset
1940
+ * observation). If a previously-written `.npmrc` exists that no longer
1941
+ * matches the baked-in `.npmrc.default`, restore it — see APPS-4320.
1942
+ *
1943
+ * On the first call per pod boot for `<dir>`, captures `<dir>/.npmrc` to
1944
+ * `<dir>/.npmrc.default` before any rewrite so the restore path above has
1945
+ * a source to copy back from.
1946
+ *
1947
+ * Returns the resolved fetch result so callers can branch on `source` for
1948
+ * observability, or `undefined` when no client was provided.
1949
+ */
1950
+ export async function maybeWriteNpmrcForDir(dir, client) {
1951
+ if (!client) {
1952
+ return undefined;
1953
+ }
1954
+ // Force-refresh: this is the `.npmrc` synthesis / install write boundary,
1955
+ // so it must observe an admin clearing or changing the registry
1956
+ // immediately rather than waiting out the TTL. A cleared
1957
+ // registry resolves fresh as `not-configured`, which the branch below
1958
+ // tears down the project `.npmrc` for. The last-known-good fallback on a
1959
+ // server outage still applies — only the cache-hit read is bypassed.
1960
+ const result = await client.getConfig({ forceRefresh: true });
1961
+ if (result.source === "unreachable") {
1962
+ // Transient cold-cache outage. We do NOT know the org's current
1963
+ // registry state, so we refuse to act on this signal — neither
1964
+ // rewrite (no config to render) nor restore (would clobber a
1965
+ // last-known-good private-registry `.npmrc` back to the baked-in
1966
+ // baseline exactly during the outage window where the customer
1967
+ // needs us to fail closed). Next successful fetch will reconcile.
1968
+ // Symmetric with `syncHomeNpmrc`'s `skipped-unreachable` branch in
1969
+ // `home-npmrc.mts`.
1970
+ getLogger().warn("[project-npmrc] server unreachable with no cached config; .npmrc left unchanged", { path: path.join(dir, ".npmrc") });
1971
+ npmRegistryEmitter.recordSyncProjectNpmrc("skipped-unreachable");
1972
+ return result;
1973
+ }
1974
+ const npmrcPath = path.join(dir, ".npmrc");
1975
+ const backupPath = path.join(dir, NPMRC_DEFAULT_FILENAME);
1976
+ const orgId = client.organizationId;
1977
+ if (!result.config.configured) {
1978
+ // A Superblocks-authored `.npmrc.default` is poisoned (blind snapshot
1979
+ // of our own rewrite), not a safe restore baseline. Drop it before
1980
+ // any restore so we do not re-apply the proxy URL + JWT.
1981
+ const backupRead = await readUtf8File(backupPath);
1982
+ const existingRead = await readUtf8File(npmrcPath);
1983
+ if (backupRead.status === "error" || existingRead.status === "error") {
1984
+ npmRegistryEmitter.recordSyncProjectNpmrc("error");
1985
+ return result;
1986
+ }
1987
+ const backup = backupRead.status === "ok" ? backupRead.content : undefined;
1988
+ const existing = existingRead.status === "ok" ? existingRead.content : undefined;
1989
+ const ours = existing !== undefined &&
1990
+ isSuperblocksAuthoredNpmrcContent(existing, orgId);
1991
+ const cleanBackup = backup !== undefined && !isSuperblocksAuthoredNpmrcContent(backup, orgId);
1992
+ await maybeUnlinkPoisonedNpmrcBackup(backupPath, orgId);
1993
+ // Only restore from a clean (non-Superblocks) backup. Never call restore
1994
+ // when the backup is missing or poisoned: a failed poison unlink would
1995
+ // otherwise re-apply proxy credentials onto ours OR overwrite a
1996
+ // customer-authored file (Bugbot).
1997
+ let outcome;
1998
+ if (ours && !cleanBackup) {
1999
+ await tryUnlinkPath(npmrcPath, "stale Superblocks-authored .npmrc");
2000
+ outcome = await outcomeAfterNotConfiguredMutation({
2001
+ npmrcPath,
2002
+ organizationId: orgId,
2003
+ successOutcome: "deleted-not-configured",
2004
+ });
2005
+ }
2006
+ else if (cleanBackup) {
2007
+ await restoreInitialNpmrc(npmrcPath, backupPath, {
2008
+ // Only unlink when the target is ours. A customer-authored file
2009
+ // without a backup must stay (template / artifactory cases).
2010
+ unlinkTargetWhenBackupMissing: ours,
2011
+ });
2012
+ if (ours) {
2013
+ outcome = await outcomeAfterNotConfiguredMutation({
2014
+ npmrcPath,
2015
+ organizationId: orgId,
2016
+ successOutcome: "restored-not-configured",
2017
+ });
2018
+ }
2019
+ else {
2020
+ outcome = "restored-not-configured";
2021
+ }
2022
+ }
2023
+ else {
2024
+ // !ours && !cleanBackup: leave customer file alone.
2025
+ outcome = "restored-not-configured";
2026
+ }
2027
+ if (result.config.allowInstallScripts === false) {
2028
+ // Even without registry rows the org policy disallows install
2029
+ // scripts. Bake `ignore-scripts=true` into the project `.npmrc`
2030
+ // so any npm/pnpm invocation (patch-package, husky, ad-hoc
2031
+ // `bash npm install`) honours the policy.
2032
+ //
2033
+ // Skip `snapshotInitialNpmrc`: on a repeated sync the target
2034
+ // already contains our policy file; snapshotting it would poison
2035
+ // the backup so a later flip to allowInstallScripts=true could
2036
+ // never restore the original baked content.
2037
+ await writeNpmrc(npmrcPath, result.config);
2038
+ }
2039
+ else {
2040
+ // Clean up a stale policy-only `.npmrc` left by a previous call
2041
+ // when the dir had no baked-in file to snapshot. In that case
2042
+ // `restoreInitialNpmrc` cannot restore the "no file" baseline
2043
+ // because `.npmrc.default` was never created. We detect the stale
2044
+ // file by checking that it contains only the policy line (no
2045
+ // registry entries) and remove it.
2046
+ try {
2047
+ const content = await readFile(npmrcPath, "utf-8");
2048
+ if (content.trim() === "ignore-scripts=true") {
2049
+ await unlink(npmrcPath);
2050
+ }
2051
+ }
2052
+ catch (e) {
2053
+ if (e?.code !== "ENOENT") {
2054
+ getLogger().warn("[npm-registry] failed to clean up stale policy-only .npmrc", {
2055
+ path: npmrcPath,
2056
+ error: e instanceof Error ? e.message : String(e),
2057
+ });
2058
+ }
2059
+ }
2060
+ }
2061
+ npmRegistryEmitter.recordSyncProjectNpmrc(outcome);
2062
+ return result;
2063
+ }
2064
+ // Ensure `.npmrc` is git-ignored from `<dir>` BEFORE we write the
2065
+ // credential-bearing file. Fail-closed in BOTH the native-git and
2066
+ // non-native-git cases:
2067
+ //
2068
+ // - Native-git, no writable ignore (neither `<dir>/.gitignore` nor
2069
+ // `<dir>/.git/info/exclude`): the next `git add .` would stage the
2070
+ // token and push it to the customer's external remote.
2071
+ //
2072
+ // - Non-native-git, `<dir>/.gitignore` could not be created (rare —
2073
+ // disk full, permission denied, or the path is a directory): no
2074
+ // immediate native-git leak, but a later `git init` in the same
2075
+ // dir would find the on-disk token with no ignore rule and stage
2076
+ // it on the first `git add .`. This is the exact future-git leak
2077
+ // path called out in PR #19642 code review.
2078
+ //
2079
+ // See `ensureNpmrcGitignored` for the full decision matrix.
2080
+ const ignoreResult = await ensureNpmrcGitignored(dir);
2081
+ if (!ignoreResult.ignored) {
2082
+ getLogger().warn(ignoreResult.hasGit
2083
+ ? "[npm-registry] refusing to write .npmrc with credentials: native-git checkout has no writable ignore (neither .gitignore nor .git/info/exclude); would leak token on next `git add .`"
2084
+ : "[npm-registry] refusing to write .npmrc with credentials: could not create or update .gitignore (write failed); a later `git init` in this dir would stage the token on first `git add .`", { path: npmrcPath, dir, hasGit: ignoreResult.hasGit });
2085
+ npmRegistryEmitter.recordSyncProjectNpmrc("error");
2086
+ return result;
2087
+ }
2088
+ // Snapshot the baked-in `.npmrc` before the first rewrite so the
2089
+ // not-configured branch above has a restore source. Gated on the
2090
+ // configured branch so a pod whose org was configured-then-deconfigured
2091
+ // before this commit landed (so `.npmrc` is already a rewritten value
2092
+ // with no companion `.npmrc.default`) does not snapshot the rewritten
2093
+ // file as the baked-in baseline. In that pre-existing-rewrite case
2094
+ // the restore path correctly no-ops; recovery requires a pod recycle.
2095
+ //
2096
+ // Snapshot AFTER the gitignore check (we don't need a backup if we're
2097
+ // refusing to write).
2098
+ //
2099
+ // Never snapshot a Superblocks-authored file as the baseline, and drop
2100
+ // a poisoned `.npmrc.default` left by a prior blind snapshot so a later
2101
+ // not-configured restore cannot re-apply credentials.
2102
+ await maybeUnlinkPoisonedNpmrcBackup(backupPath, orgId);
2103
+ const existingForSnapshot = await readUtf8File(npmrcPath);
2104
+ if (existingForSnapshot.status === "error") {
2105
+ npmRegistryEmitter.recordSyncProjectNpmrc("error");
2106
+ return result;
2107
+ }
2108
+ if (existingForSnapshot.status === "ok" &&
2109
+ isSuperblocksAuthoredNpmrcContent(existingForSnapshot.content, orgId)) {
2110
+ getLogger().info("[project-npmrc] refused to snapshot Superblocks-authored .npmrc as baseline", { path: npmrcPath });
2111
+ }
2112
+ else {
2113
+ await snapshotInitialNpmrc(npmrcPath, backupPath);
2114
+ }
2115
+ await writeNpmrc(npmrcPath, result.config);
2116
+ npmRegistryEmitter.recordSyncProjectNpmrc("written");
2117
+ return result;
2118
+ }
2119
+ /**
2120
+ * Classify on-disk state after a not-configured delete/restore. A non-ENOENT
2121
+ * re-read failure is `error`, not success: absent and "not ours" are the
2122
+ * only success shapes.
2123
+ */
2124
+ async function outcomeAfterNotConfiguredMutation(args) {
2125
+ const { npmrcPath, organizationId, successOutcome } = args;
2126
+ const after = await readUtf8File(npmrcPath);
2127
+ if (after.status === "error") {
2128
+ return "error";
2129
+ }
2130
+ if (after.status === "ok" &&
2131
+ isSuperblocksAuthoredNpmrcContent(after.content, organizationId)) {
2132
+ return "error";
2133
+ }
2134
+ return successOutcome;
2135
+ }
2136
+ async function readUtf8File(filePath) {
2137
+ try {
2138
+ return { status: "ok", content: await readFile(filePath, "utf-8") };
2139
+ }
2140
+ catch (error) {
2141
+ const code = error?.code;
2142
+ if (code === "ENOENT") {
2143
+ return { status: "absent" };
2144
+ }
2145
+ getLogger().warn("[project-npmrc] failed to read file; treating as unreadable", {
2146
+ path: filePath,
2147
+ code,
2148
+ error: error instanceof Error ? error.message : String(error),
2149
+ });
2150
+ return { status: "error" };
2151
+ }
2152
+ }
2153
+ async function tryUnlinkPath(filePath, label) {
2154
+ try {
2155
+ await unlink(filePath);
2156
+ }
2157
+ catch (error) {
2158
+ const code = error?.code;
2159
+ if (code === "ENOENT") {
2160
+ return;
2161
+ }
2162
+ getLogger().warn(`[project-npmrc] failed to remove ${label}`, {
2163
+ path: filePath,
2164
+ code,
2165
+ error: error instanceof Error ? error.message : String(error),
2166
+ });
2167
+ }
2168
+ }
2169
+ async function maybeUnlinkPoisonedNpmrcBackup(backupPath, organizationId) {
2170
+ const backup = await readUtf8File(backupPath);
2171
+ // Absent or unreadable: leave alone. Only unlink when we can confirm
2172
+ // Superblocks authorship.
2173
+ if (backup.status !== "ok" ||
2174
+ !isSuperblocksAuthoredNpmrcContent(backup.content, organizationId)) {
2175
+ return;
2176
+ }
2177
+ await tryUnlinkPath(backupPath, "poisoned Superblocks-authored .npmrc.default");
2178
+ }
2179
+ /**
2180
+ * Materializes the private-registry `.npmrc` AND unconditionally strips
2181
+ * `resolved` URLs from any lockfile present in `dir`, so a subsequent
2182
+ * `npm install` is guaranteed to re-resolve through the active registry.
2183
+ * The `.npmrc` write is gated on whether the client resolves to a configured
2184
+ * registry; the lockfile strip runs regardless.
2185
+ *
2186
+ * Why the strip is unconditional (decoupled from the `.npmrc` write):
2187
+ * - SaaS dev-server pods (staging/prod) often run without a configured
2188
+ * org npm registry, but their lockfiles can still be poisoned with
2189
+ * cross-registry `resolved` URLs via DBFS state (APPS-4300). Gating
2190
+ * the strip on the client's configured-ness meant the only safety net
2191
+ * never fired in the exact environment where it mattered. Always
2192
+ * stripping closes that read path.
2193
+ * - The mutation is transient: `npm install` rewrites `resolved` with
2194
+ * URLs from the active `.npmrc` registry on the very next line, so a
2195
+ * local dev whose lockfile pointed at npmjs.org sees the same URLs
2196
+ * restored after install.
2197
+ * - `integrity` is preserved (see `stripResolvedFromLockfile`), so any
2198
+ * cross-registry tarball drift surfaces as a clean `EINTEGRITY` failure
2199
+ * rather than silent corruption.
2200
+ *
2201
+ * The strip is per-boot, not persisted: a stripped lockfile only reaches DBFS
2202
+ * if the surrounding flow runs an upload. Pods that boot, strip, and exit
2203
+ * without uploading still find the same poisoned lockfile in DBFS on the
2204
+ * next boot. The CI fix in `build-db-migrations.yaml` and `build-dev-server.yaml`
2205
+ * (only configure GHPR scope for ephemeral builds) is the actual durable
2206
+ * fix; this strip is the runtime safety net for already-poisoned DBFS state.
2207
+ *
2208
+ * Returns the resolved fetch result when a client is provided (so callers
2209
+ * can branch on `source` for observability), or `undefined` when no client
2210
+ * was provided. The lockfile strip happens in both cases.
2211
+ */
2212
+ export async function prepareForPrivateRegistry(dir, client) {
2213
+ return withNpmRegistrySpan(NPM_REGISTRY_SPAN.PREPARE_FOR_PRIVATE_REGISTRY, client?.organizationId
2214
+ ? { [NPM_REGISTRY_SPAN_ATTR.ORG_ID]: client.organizationId }
2215
+ : {}, async (span) => {
2216
+ const result = await maybeWriteNpmrcForDir(dir, client);
2217
+ await stripResolvedFromLockfile(dir);
2218
+ if (result) {
2219
+ span.setAttributes({
2220
+ [NPM_REGISTRY_SPAN_ATTR.SOURCE]: result.source,
2221
+ [NPM_REGISTRY_SPAN_ATTR.REGISTRY_CONFIGURED]: result.config.configured,
2222
+ [NPM_REGISTRY_SPAN_ATTR.REGISTRY_HOST]: bucketNpmRegistryHost(result.config.default?.url),
2223
+ // Tri-valued: true | false | "unknown" (LD flag off / server omitted).
2224
+ [NPM_REGISTRY_SPAN_ATTR.ALLOW_INSTALL_SCRIPTS]: result.config.allowInstallScripts ?? "unknown",
2225
+ });
2226
+ }
2227
+ return result;
2228
+ });
2229
+ }
2230
+ /**
2231
+ * Removes the `resolved` field from every entry in `.packages` of an npm v2+
2232
+ * lockfile. TS-side counterpart to `scripts/strip-lockfile-resolved.sh`.
2233
+ *
2234
+ * Same goal: npm honors `resolved` URLs verbatim, so a lockfile whose entries
2235
+ * point at registry.npmjs.org keeps fetching from npmjs even after we've
2236
+ * written a private `registry=` line to `.npmrc`. Stripping forces npm to
2237
+ * re-resolve through the active registry.
2238
+ *
2239
+ * Use at runtime for *brownfield* apps — apps imported into Superblocks with
2240
+ * a lockfile baked at customer-side npm install time (typically against
2241
+ * npmjs.org). Greenfield template lockfiles are stripped at image-build time
2242
+ * by the bash script; this function handles the rest.
2243
+ *
2244
+ * Behavior:
2245
+ * - Strips both `<dir>/package-lock.json` and the hidden
2246
+ * `<dir>/node_modules/.package-lock.json` if present.
2247
+ * - No-op when neither file exists (brownfield apps may not have a
2248
+ * lockfile yet).
2249
+ * - Idempotent: a second call against an already-stripped file is a no-op.
2250
+ * - Malformed JSON or wrong shape -> logged warning, file left untouched.
2251
+ * We don't throw because the consuming `npm install` will surface a
2252
+ * clearer error on the same lockfile, and an unrelated parse bug here
2253
+ * should not block the user's install.
2254
+ * - Atomic: writes via tmp + rename to avoid leaving a partial lockfile on
2255
+ * crash mid-write.
2256
+ */
2257
+ export async function stripResolvedFromLockfile(dir) {
2258
+ await Promise.all([
2259
+ stripResolvedFromLockfilePath(path.join(dir, "package-lock.json")),
2260
+ stripResolvedFromLockfilePath(path.join(dir, "node_modules", ".package-lock.json")),
2261
+ ]);
2262
+ }
2263
+ export async function stripResolvedFromLockfilePath(lockfilePath) {
2264
+ let raw;
2265
+ try {
2266
+ raw = await readFile(lockfilePath, "utf-8");
2267
+ }
2268
+ catch (error) {
2269
+ const code = error?.code;
2270
+ if (code === "ENOENT") {
2271
+ return;
2272
+ }
2273
+ getLogger().warn("[npm-registry] failed to read lockfile for resolved-strip; skipping", {
2274
+ path: lockfilePath,
2275
+ code,
2276
+ error: error instanceof Error ? error.message : String(error),
2277
+ });
2278
+ return;
2279
+ }
2280
+ let parsed;
2281
+ try {
2282
+ parsed = JSON.parse(raw);
2283
+ }
2284
+ catch (error) {
2285
+ getLogger().warn("[npm-registry] lockfile is not valid JSON; skipping resolved-strip", {
2286
+ path: lockfilePath,
2287
+ error: error instanceof Error ? error.message : String(error),
2288
+ });
2289
+ return;
2290
+ }
2291
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
2292
+ getLogger().warn("[npm-registry] lockfile root is not a JSON object; skipping resolved-strip", { path: lockfilePath });
2293
+ return;
2294
+ }
2295
+ const lockfile = parsed;
2296
+ const packages = lockfile.packages;
2297
+ // npm v1 lockfiles have no .packages object; nothing to strip. Some custom
2298
+ // shapes may also omit it (e.g. fixture lockfiles). Skip silently.
2299
+ if (packages === undefined) {
2300
+ return;
2301
+ }
2302
+ if (!packages || typeof packages !== "object" || Array.isArray(packages)) {
2303
+ getLogger().warn("[npm-registry] lockfile .packages is not an object; skipping resolved-strip", { path: lockfilePath });
2304
+ return;
2305
+ }
2306
+ let mutated = false;
2307
+ for (const entry of Object.values(packages)) {
2308
+ if (entry &&
2309
+ typeof entry === "object" &&
2310
+ !Array.isArray(entry) &&
2311
+ "resolved" in entry) {
2312
+ delete entry.resolved;
2313
+ mutated = true;
2314
+ }
2315
+ }
2316
+ if (!mutated) {
2317
+ return;
2318
+ }
2319
+ // Preserve a trailing newline if the original had one (npm writes its
2320
+ // lockfiles with a trailing newline; matching it minimizes spurious diffs
2321
+ // when the file is later committed back from a customer-side workflow).
2322
+ const trailingNewline = raw.endsWith("\n") ? "\n" : "";
2323
+ const next = JSON.stringify(lockfile, null, 2) + trailingNewline;
2324
+ // Atomic write: tmp + rename. Inherit the original mode where possible so
2325
+ // we don't widen perms on a customer-owned lockfile (npm typically writes
2326
+ // 0644, but we don't assume). If `writeFile` succeeds but `chmod` or
2327
+ // `rename` fails (ENOSPC, EROFS, EXDEV, EACCES), the tmp file gets cleaned
2328
+ // up so successive boots don't accumulate orphans.
2329
+ const tmpPath = `${lockfilePath}.tmp-${process.pid}-${Date.now()}`;
2330
+ try {
2331
+ await writeFile(tmpPath, next, "utf-8");
2332
+ try {
2333
+ const original = await stat(lockfilePath);
2334
+ await chmod(tmpPath, original.mode & 0o777);
2335
+ }
2336
+ catch {
2337
+ // Best-effort mode parity only; the rewrite itself is what matters.
2338
+ }
2339
+ await rename(tmpPath, lockfilePath);
2340
+ }
2341
+ catch (error) {
2342
+ await unlink(tmpPath).catch(() => { });
2343
+ throw error;
2344
+ }
2345
+ }
2346
+ /**
2347
+ * APPS-4370. Build a disk-backed `LastKnownRegistryPolicyStore` rooted at
2348
+ * `<rootDir>/.superblocks/orgs/<orgId>/.registry-was-configured`.
2349
+ *
2350
+ * The marker's PRESENCE is the semantic signal; its content is informal
2351
+ * (an ISO timestamp for forensics — "when was this org first seen with a
2352
+ * configured registry"). Writes are best-effort: a write failure (EACCES
2353
+ * on a 0o500 parent, ENOSPC) is logged and swallowed. Reads return false
2354
+ * on any error so a transient IO problem doesn't degrade today's
2355
+ * "proceed" behaviour into a fail-closed install.
2356
+ *
2357
+ * APPS-4427: `markConfigured` is AWAITED by its caller
2358
+ * (`NpmRegistryClient.markPolicyConfigured`) before a `configured` / `stale`
2359
+ * resolution is handed back, so the marker is durably on disk before that
2360
+ * result is used — closing the crash window an un-awaited write would leave
2361
+ * open. The write stays async (`fs/promises`, per the ai-service no-sync-fs
2362
+ * rule) and is guarded to run at most once per process, so awaiting it stays
2363
+ * off the install hot path after the first configured resolution.
2364
+ *
2365
+ * The `rootDir` is injected (rather than hard-coded to `os.homedir()`)
2366
+ * so tests can isolate to a tmp directory and so the dev-server can
2367
+ * point the store at the same disk it already manages
2368
+ * (`~/.superblocks/...`). The per-org path keeps multiple orgs running
2369
+ * against the same machine from contaminating each other's marker state.
2370
+ */
2371
+ export function createDiskRegistryPolicyStore(opts) {
2372
+ const orgDir = path.join(opts.rootDir, ".superblocks", "orgs", opts.organizationId);
2373
+ const markerPath = path.join(orgDir, ".registry-was-configured");
2374
+ // APPS-4427: write at most once per process. The marker's PRESENCE is the
2375
+ // signal, so re-writing on every `configured`/`stale` resolution is pure
2376
+ // overhead — and since the caller now AWAITS the write, guarding here keeps
2377
+ // it off the install hot path after the first configured resolution. Only
2378
+ // set on a SUCCESSFUL write, so a transient failure is retried next call.
2379
+ let marked = false;
2380
+ return {
2381
+ async markConfigured() {
2382
+ if (marked) {
2383
+ return;
2384
+ }
2385
+ try {
2386
+ // Async (`fs/promises`) per the ai-service no-sync-fs rule. Durability
2387
+ // comes from the caller awaiting this before handing back the
2388
+ // `configured`/`stale` resolution (see `markPolicyConfigured`), not
2389
+ // from blocking the event loop with a sync write.
2390
+ await mkdir(orgDir, { recursive: true });
2391
+ // An ISO timestamp is enough to debug "when did we first see this
2392
+ // org configured" without growing the file's semantic surface
2393
+ // (presence is the signal).
2394
+ await writeFile(markerPath, new Date().toISOString() + "\n", "utf-8");
2395
+ marked = true;
2396
+ }
2397
+ catch (err) {
2398
+ getLogger().warn("[npm-registry] failed to write registry-policy marker; ignoring", {
2399
+ error: err instanceof Error ? err.message : String(err),
2400
+ orgId: opts.organizationId,
2401
+ path: markerPath,
2402
+ });
2403
+ }
2404
+ },
2405
+ async clearConfigured() {
2406
+ try {
2407
+ await unlink(markerPath);
2408
+ getLogger().info("[npm-registry] removed registry-policy marker", {
2409
+ orgId: opts.organizationId,
2410
+ path: markerPath,
2411
+ });
2412
+ }
2413
+ catch (err) {
2414
+ const code = err?.code;
2415
+ if (code !== "ENOENT") {
2416
+ // The marker may still be on disk, so leave the write guard set.
2417
+ getLogger().warn("[npm-registry] failed to remove registry-policy marker; ignoring", {
2418
+ code,
2419
+ error: err instanceof Error ? err.message : String(err),
2420
+ orgId: opts.organizationId,
2421
+ path: markerPath,
2422
+ });
2423
+ return;
2424
+ }
2425
+ }
2426
+ // Re-arm the once-per-process write guard so a later `configured`
2427
+ // resolution writes the marker again.
2428
+ marked = false;
2429
+ },
2430
+ async hasEverBeenConfigured() {
2431
+ try {
2432
+ await stat(markerPath);
2433
+ return true;
2434
+ }
2435
+ catch (err) {
2436
+ const code = err?.code;
2437
+ if (code === "ENOENT") {
2438
+ // No marker → never been configured. The common case; not a
2439
+ // log-worthy event.
2440
+ return false;
2441
+ }
2442
+ // Anything else (EACCES on a clamped-perms dir, EIO) gets
2443
+ // surfaced at warn level so a misconfigured deployment is
2444
+ // visible, but we still resolve to false so the install path
2445
+ // preserves current behaviour.
2446
+ getLogger().warn("[npm-registry] failed to read registry-policy marker; treating as not-configured", {
2447
+ path: markerPath,
2448
+ code,
2449
+ error: err instanceof Error ? err.message : String(err),
2450
+ });
2451
+ return false;
2452
+ }
2453
+ },
2454
+ };
2455
+ }
2456
+ // Re-export the npm/pnpm install-error classifier + structured error types so
2457
+ // consumers of the `/npm-registry` entry (e.g. the CLI dev server) can classify
2458
+ // installs without reaching into ai-service internals. APPS-4450.
2459
+ export { parseNpmJsonError, parseNpmJsonDiagnostic, classifyNpmExecStderr, } from "./npm-error-parser.js";
2460
+ export { NpmInstallBlocked, NpmInstallError, scrubSecrets } from "../types.js";
2461
+ //# sourceMappingURL=npm-registry.js.map