@superblocksteam/vite-plugin-file-sync 2.0.177 → 2.0.178-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (782) hide show
  1. package/dist/agent-tool-executor/claude-drafts.d.ts +21 -0
  2. package/dist/agent-tool-executor/claude-drafts.d.ts.map +1 -0
  3. package/dist/agent-tool-executor/claude-drafts.js +35 -0
  4. package/dist/agent-tool-executor/claude-drafts.js.map +1 -0
  5. package/dist/agent-tool-executor/claude-file-tools.d.ts +133 -0
  6. package/dist/agent-tool-executor/claude-file-tools.d.ts.map +1 -0
  7. package/dist/agent-tool-executor/claude-file-tools.js +368 -0
  8. package/dist/agent-tool-executor/claude-file-tools.js.map +1 -0
  9. package/dist/agent-tool-executor/claude-protected-paths.d.ts +13 -0
  10. package/dist/agent-tool-executor/claude-protected-paths.d.ts.map +1 -0
  11. package/dist/agent-tool-executor/claude-protected-paths.js +100 -0
  12. package/dist/agent-tool-executor/claude-protected-paths.js.map +1 -0
  13. package/dist/agent-tool-executor/claude-sandbox-placeholders.d.ts +38 -0
  14. package/dist/agent-tool-executor/claude-sandbox-placeholders.d.ts.map +1 -0
  15. package/dist/agent-tool-executor/claude-sandbox-placeholders.js +132 -0
  16. package/dist/agent-tool-executor/claude-sandbox-placeholders.js.map +1 -0
  17. package/dist/agent-tool-executor/claude-sandbox.d.ts +59 -0
  18. package/dist/agent-tool-executor/claude-sandbox.d.ts.map +1 -0
  19. package/dist/agent-tool-executor/claude-sandbox.js +280 -0
  20. package/dist/agent-tool-executor/claude-sandbox.js.map +1 -0
  21. package/dist/agent-tool-executor/claude-shell.d.ts +139 -0
  22. package/dist/agent-tool-executor/claude-shell.d.ts.map +1 -0
  23. package/dist/agent-tool-executor/claude-shell.js +573 -0
  24. package/dist/agent-tool-executor/claude-shell.js.map +1 -0
  25. package/dist/agent-tool-executor/claude-tool-server.d.ts +27 -0
  26. package/dist/agent-tool-executor/claude-tool-server.d.ts.map +1 -0
  27. package/dist/agent-tool-executor/claude-tool-server.js +191 -0
  28. package/dist/agent-tool-executor/claude-tool-server.js.map +1 -0
  29. package/dist/agent-tool-executor/claude-tools.d.ts +29 -0
  30. package/dist/agent-tool-executor/claude-tools.d.ts.map +1 -0
  31. package/dist/agent-tool-executor/claude-tools.js +74 -0
  32. package/dist/agent-tool-executor/claude-tools.js.map +1 -0
  33. package/dist/agent-tool-executor/codex-drafts.d.ts +12 -0
  34. package/dist/agent-tool-executor/codex-drafts.d.ts.map +1 -0
  35. package/dist/agent-tool-executor/codex-drafts.js +48 -0
  36. package/dist/agent-tool-executor/codex-drafts.js.map +1 -0
  37. package/dist/agent-tool-executor/codex-exec-server.d.ts +42 -0
  38. package/dist/agent-tool-executor/codex-exec-server.d.ts.map +1 -0
  39. package/dist/agent-tool-executor/codex-exec-server.js +370 -0
  40. package/dist/agent-tool-executor/codex-exec-server.js.map +1 -0
  41. package/dist/agent-tool-executor/codex-execution-policy.d.ts +31 -0
  42. package/dist/agent-tool-executor/codex-execution-policy.d.ts.map +1 -0
  43. package/dist/agent-tool-executor/codex-execution-policy.js +230 -0
  44. package/dist/agent-tool-executor/codex-execution-policy.js.map +1 -0
  45. package/dist/agent-tool-executor/codex-instruction-files.d.ts +9 -0
  46. package/dist/agent-tool-executor/codex-instruction-files.d.ts.map +1 -0
  47. package/dist/agent-tool-executor/codex-instruction-files.js +37 -0
  48. package/dist/agent-tool-executor/codex-instruction-files.js.map +1 -0
  49. package/dist/agent-tool-executor/native-dotenv-watch-scope.d.ts +12 -0
  50. package/dist/agent-tool-executor/native-dotenv-watch-scope.d.ts.map +1 -0
  51. package/dist/agent-tool-executor/native-dotenv-watch-scope.js +74 -0
  52. package/dist/agent-tool-executor/native-dotenv-watch-scope.js.map +1 -0
  53. package/dist/agent-tool-executor/native-draft-service.d.ts +20 -0
  54. package/dist/agent-tool-executor/native-draft-service.d.ts.map +1 -0
  55. package/dist/agent-tool-executor/native-draft-service.js +2 -0
  56. package/dist/agent-tool-executor/native-draft-service.js.map +1 -0
  57. package/dist/agent-tool-executor/native-execution-sessions.d.ts +31 -0
  58. package/dist/agent-tool-executor/native-execution-sessions.d.ts.map +1 -0
  59. package/dist/agent-tool-executor/native-execution-sessions.js +86 -0
  60. package/dist/agent-tool-executor/native-execution-sessions.js.map +1 -0
  61. package/dist/agent-tool-executor/native-file-access.d.ts +17 -0
  62. package/dist/agent-tool-executor/native-file-access.d.ts.map +1 -0
  63. package/dist/agent-tool-executor/native-file-access.js +96 -0
  64. package/dist/agent-tool-executor/native-file-access.js.map +1 -0
  65. package/dist/agent-tool-executor/native-os-sandbox.d.ts +17 -0
  66. package/dist/agent-tool-executor/native-os-sandbox.d.ts.map +1 -0
  67. package/dist/agent-tool-executor/native-os-sandbox.js +16 -0
  68. package/dist/agent-tool-executor/native-os-sandbox.js.map +1 -0
  69. package/dist/agent-tool-executor/native-tool-environment.d.ts +16 -0
  70. package/dist/agent-tool-executor/native-tool-environment.d.ts.map +1 -0
  71. package/dist/agent-tool-executor/native-tool-environment.js +22 -0
  72. package/dist/agent-tool-executor/native-tool-environment.js.map +1 -0
  73. package/dist/agent-tool-executor/native-tool-servers.d.ts +42 -0
  74. package/dist/agent-tool-executor/native-tool-servers.d.ts.map +1 -0
  75. package/dist/agent-tool-executor/native-tool-servers.js +62 -0
  76. package/dist/agent-tool-executor/native-tool-servers.js.map +1 -0
  77. package/dist/ai-service/accepted-files-sync.d.ts +9 -0
  78. package/dist/ai-service/accepted-files-sync.d.ts.map +1 -0
  79. package/dist/ai-service/accepted-files-sync.js +10 -0
  80. package/dist/ai-service/accepted-files-sync.js.map +1 -0
  81. package/dist/ai-service/agent/middleware.js.map +1 -1
  82. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts +3 -2
  83. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  84. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +28 -11
  85. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  86. package/dist/ai-service/agent/security-scan-tools.d.ts +12 -0
  87. package/dist/ai-service/agent/security-scan-tools.d.ts.map +1 -0
  88. package/dist/ai-service/agent/security-scan-tools.js +44 -0
  89. package/dist/ai-service/agent/security-scan-tools.js.map +1 -0
  90. package/dist/ai-service/agent/subagents/apis/example-selector.js.map +1 -1
  91. package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -1
  92. package/dist/ai-service/agent/subagents/apis/static-analysis.d.ts.map +1 -1
  93. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.js.map +1 -1
  94. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  95. package/dist/ai-service/agent/tool-message-utils.js +6 -0
  96. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  97. package/dist/ai-service/agent/tool-permission-delivery.d.ts.map +1 -1
  98. package/dist/ai-service/agent/tool-permission-delivery.js.map +1 -1
  99. package/dist/ai-service/agent/tools/apis/analysis.d.ts.map +1 -1
  100. package/dist/ai-service/agent/tools/apis/analysis.js.map +1 -1
  101. package/dist/ai-service/agent/tools/apis/api-executor.d.ts.map +1 -1
  102. package/dist/ai-service/agent/tools/apis/api-executor.js.map +1 -1
  103. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts.map +1 -1
  104. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js.map +1 -1
  105. package/dist/ai-service/agent/tools/apis/build-api-artifact.d.ts.map +1 -1
  106. package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts +3 -3
  107. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.js.map +1 -1
  108. package/dist/ai-service/agent/tools/apis/integration-types.js.map +1 -1
  109. package/dist/ai-service/agent/tools/apis/sample-json.d.ts.map +1 -1
  110. package/dist/ai-service/agent/tools/apis/test-api.d.ts +87 -22
  111. package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
  112. package/dist/ai-service/agent/tools/apis/test-api.js +52 -50
  113. package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
  114. package/dist/ai-service/agent/tools/apis/write-api.d.ts +2 -2
  115. package/dist/ai-service/agent/tools/app-environment/update-app-environment.d.ts.map +1 -1
  116. package/dist/ai-service/agent/tools/branching/branch-tools.d.ts +211 -0
  117. package/dist/ai-service/agent/tools/branching/branch-tools.d.ts.map +1 -0
  118. package/dist/ai-service/agent/tools/branching/branch-tools.js +333 -0
  119. package/dist/ai-service/agent/tools/branching/branch-tools.js.map +1 -0
  120. package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts +15 -7
  121. package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts.map +1 -1
  122. package/dist/ai-service/agent/tools/build-capture-screenshot.js +13 -8
  123. package/dist/ai-service/agent/tools/build-capture-screenshot.js.map +1 -1
  124. package/dist/ai-service/agent/tools/build-copy-directory.d.ts +1 -1
  125. package/dist/ai-service/agent/tools/build-copy-file.d.ts +1 -1
  126. package/dist/ai-service/agent/tools/build-copy-utils.d.ts +10 -10
  127. package/dist/ai-service/agent/tools/build-debug.js.map +1 -1
  128. package/dist/ai-service/agent/tools/build-delete-file.d.ts +1 -1
  129. package/dist/ai-service/agent/tools/build-delete-file.d.ts.map +1 -1
  130. package/dist/ai-service/agent/tools/build-edit-file.d.ts +3 -3
  131. package/dist/ai-service/agent/tools/build-finalize.d.ts +1 -1
  132. package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
  133. package/dist/ai-service/agent/tools/build-install-packages.d.ts +1 -1
  134. package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
  135. package/dist/ai-service/agent/tools/build-install-packages.js +1 -1
  136. package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
  137. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +11 -11
  138. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
  139. package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -1
  140. package/dist/ai-service/agent/tools/build-manage-packages.d.ts +4 -2
  141. package/dist/ai-service/agent/tools/build-manage-packages.d.ts.map +1 -1
  142. package/dist/ai-service/agent/tools/build-manage-packages.js +9 -1
  143. package/dist/ai-service/agent/tools/build-manage-packages.js.map +1 -1
  144. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts +1 -1
  145. package/dist/ai-service/agent/tools/build-navigate-preview.d.ts +7 -1
  146. package/dist/ai-service/agent/tools/build-navigate-preview.d.ts.map +1 -1
  147. package/dist/ai-service/agent/tools/build-navigate-preview.js +5 -4
  148. package/dist/ai-service/agent/tools/build-navigate-preview.js.map +1 -1
  149. package/dist/ai-service/agent/tools/build-write-file.d.ts +1 -1
  150. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
  151. package/dist/ai-service/agent/tools/build-write-file.js +13 -5
  152. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
  153. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +42 -42
  154. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -1
  155. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +4 -3
  156. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -1
  157. package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts +6 -6
  158. package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts.map +1 -1
  159. package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -1
  160. package/dist/ai-service/agent/tools/get-logs.d.ts +13 -10
  161. package/dist/ai-service/agent/tools/get-logs.d.ts.map +1 -1
  162. package/dist/ai-service/agent/tools/get-logs.js +6 -3
  163. package/dist/ai-service/agent/tools/get-logs.js.map +1 -1
  164. package/dist/ai-service/agent/tools/get-runtime-errors.d.ts +2 -0
  165. package/dist/ai-service/agent/tools/get-runtime-errors.d.ts.map +1 -1
  166. package/dist/ai-service/agent/tools/get-runtime-errors.js +3 -2
  167. package/dist/ai-service/agent/tools/get-runtime-errors.js.map +1 -1
  168. package/dist/ai-service/agent/tools/get-security-findings.d.ts +8 -8
  169. package/dist/ai-service/agent/tools/get-security-findings.js +1 -1
  170. package/dist/ai-service/agent/tools/integrations/delete-integration.d.ts +5 -2
  171. package/dist/ai-service/agent/tools/integrations/delete-integration.d.ts.map +1 -1
  172. package/dist/ai-service/agent/tools/integrations/delete-integration.js +11 -18
  173. package/dist/ai-service/agent/tools/integrations/delete-integration.js.map +1 -1
  174. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +61 -61
  175. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
  176. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
  177. package/dist/ai-service/agent/tools/integrations/index.d.ts +1 -1
  178. package/dist/ai-service/agent/tools/integrations/index.d.ts.map +1 -1
  179. package/dist/ai-service/agent/tools/integrations/index.js +1 -1
  180. package/dist/ai-service/agent/tools/integrations/index.js.map +1 -1
  181. package/dist/ai-service/agent/tools/integrations/integration-setup.d.ts +38 -23
  182. package/dist/ai-service/agent/tools/integrations/integration-setup.d.ts.map +1 -1
  183. package/dist/ai-service/agent/tools/integrations/integration-setup.js +55 -50
  184. package/dist/ai-service/agent/tools/integrations/integration-setup.js.map +1 -1
  185. package/dist/ai-service/agent/tools/integrations/metadata.d.ts +6 -6
  186. package/dist/ai-service/agent/tools/integrations/metadata.js.map +1 -1
  187. package/dist/ai-service/agent/tools/mark-api-manually-verified.d.ts +1 -1
  188. package/dist/ai-service/agent/tools/migration/update-migration-write-policy.d.ts.map +1 -1
  189. package/dist/ai-service/agent/tools/migration/update-migration-write-policy.js +1 -1
  190. package/dist/ai-service/agent/tools/rbac/effective-permissions.d.ts.map +1 -1
  191. package/dist/ai-service/agent/tools/read-file-metrics.d.ts.map +1 -1
  192. package/dist/ai-service/agent/tools/report-security-findings.d.ts +58 -58
  193. package/dist/ai-service/agent/tools/shared-helpers.d.ts.map +1 -1
  194. package/dist/ai-service/agent/tools.d.ts +1 -5
  195. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  196. package/dist/ai-service/agent/tools.js +44 -61
  197. package/dist/ai-service/agent/tools.js.map +1 -1
  198. package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -1
  199. package/dist/ai-service/agent/tools2/access-control.js.map +1 -1
  200. package/dist/ai-service/agent/tools2/entity-permissions.d.ts.map +1 -1
  201. package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
  202. package/dist/ai-service/agent/tools2/registry.js.map +1 -1
  203. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts +4 -4
  204. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.d.ts +5 -5
  205. package/dist/ai-service/agent/tools2/tools/bash.d.ts +6 -6
  206. package/dist/ai-service/agent/tools2/tools/check-task.d.ts +1 -1
  207. package/dist/ai-service/agent/tools2/tools/deploy-service.js.map +1 -1
  208. package/dist/ai-service/agent/tools2/tools/download-attachments.d.ts +1 -1
  209. package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts +4 -4
  210. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +5 -5
  211. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  212. package/dist/ai-service/agent/tools2/tools/git-raw.d.ts +3 -3
  213. package/dist/ai-service/agent/tools2/tools/git.d.ts +11 -11
  214. package/dist/ai-service/agent/tools2/tools/git.d.ts.map +1 -1
  215. package/dist/ai-service/agent/tools2/tools/git.js.map +1 -1
  216. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js.map +1 -1
  217. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +8 -7
  218. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -1
  219. package/dist/ai-service/agent/tools2/tools/grep-metadata.js +4 -2
  220. package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -1
  221. package/dist/ai-service/agent/tools2/tools/grep.d.ts +3 -3
  222. package/dist/ai-service/agent/tools2/tools/grep.d.ts.map +1 -1
  223. package/dist/ai-service/agent/tools2/tools/grep.js +27 -5
  224. package/dist/ai-service/agent/tools2/tools/grep.js.map +1 -1
  225. package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts +2 -2
  226. package/dist/ai-service/agent/tools2/tools/read.d.ts +1 -1
  227. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts +2 -2
  228. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts.map +1 -1
  229. package/dist/ai-service/agent/tools2/tools/update-test-case-status.d.ts +3 -3
  230. package/dist/ai-service/agent/tools2/tools/wait-for-task.d.ts +4 -4
  231. package/dist/ai-service/agent/tools2/tools/write.d.ts +1 -1
  232. package/dist/ai-service/agent/tools2/types.d.ts.map +1 -1
  233. package/dist/ai-service/agent/utils.d.ts.map +1 -1
  234. package/dist/ai-service/agent/utils.js.map +1 -1
  235. package/dist/ai-service/app-interface/cancellable-exec.js.map +1 -1
  236. package/dist/ai-service/app-interface/constants.d.ts.map +1 -1
  237. package/dist/ai-service/app-interface/file-system-interface.d.ts +1 -1
  238. package/dist/ai-service/app-interface/file-system-interface.d.ts.map +1 -1
  239. package/dist/ai-service/app-interface/filesystem/draft-manager.d.ts.map +1 -1
  240. package/dist/ai-service/app-interface/filesystem/draft-manager.js.map +1 -1
  241. package/dist/ai-service/app-interface/filesystem/handlers/api-handler.d.ts.map +1 -1
  242. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.d.ts +2 -1
  243. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.d.ts.map +1 -1
  244. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.js +9 -2
  245. package/dist/ai-service/app-interface/filesystem/handlers/skill-handler.js.map +1 -1
  246. package/dist/ai-service/app-interface/filesystem/sdk-path-validator.d.ts.map +1 -1
  247. package/dist/ai-service/app-interface/filesystem/validation.d.ts.map +1 -1
  248. package/dist/ai-service/app-interface/filesystem/validation.js.map +1 -1
  249. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts +1 -0
  250. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts.map +1 -1
  251. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js +1 -1
  252. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js.map +1 -1
  253. package/dist/ai-service/app-interface/filesystem/yaml-path-validator.d.ts.map +1 -1
  254. package/dist/ai-service/app-interface/linter.d.ts.map +1 -1
  255. package/dist/ai-service/app-interface/npm-error-parser.js +1 -1
  256. package/dist/ai-service/app-interface/npm-error-parser.js.map +1 -1
  257. package/dist/ai-service/app-interface/npm-package-lookup.d.ts.map +1 -1
  258. package/dist/ai-service/app-interface/npm-package-lookup.js.map +1 -1
  259. package/dist/ai-service/app-interface/npm-registry.d.ts +1 -0
  260. package/dist/ai-service/app-interface/npm-registry.d.ts.map +1 -1
  261. package/dist/ai-service/app-interface/npm-registry.js +46 -7
  262. package/dist/ai-service/app-interface/npm-registry.js.map +1 -1
  263. package/dist/ai-service/app-interface/shell.d.ts +6 -1
  264. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  265. package/dist/ai-service/app-interface/shell.js +31 -9
  266. package/dist/ai-service/app-interface/shell.js.map +1 -1
  267. package/dist/ai-service/app-skills/manager.d.ts.map +1 -1
  268. package/dist/ai-service/app-skills/manager.js.map +1 -1
  269. package/dist/ai-service/attachments/store.d.ts.map +1 -1
  270. package/dist/ai-service/attachments/text-upload-artifacts.d.ts.map +1 -1
  271. package/dist/ai-service/attachments/uploaded-content-part.d.ts.map +1 -1
  272. package/dist/ai-service/attachments/uploaded-content-part.js.map +1 -1
  273. package/dist/ai-service/builder-conversation.d.ts +89 -0
  274. package/dist/ai-service/builder-conversation.d.ts.map +1 -0
  275. package/dist/ai-service/builder-conversation.js +756 -0
  276. package/dist/ai-service/builder-conversation.js.map +1 -0
  277. package/dist/ai-service/builder-inference-auth.d.ts +21 -0
  278. package/dist/ai-service/builder-inference-auth.d.ts.map +1 -0
  279. package/dist/ai-service/builder-inference-auth.js +95 -0
  280. package/dist/ai-service/builder-inference-auth.js.map +1 -0
  281. package/dist/ai-service/builder-runtime.d.ts +342 -0
  282. package/dist/ai-service/builder-runtime.d.ts.map +1 -0
  283. package/dist/ai-service/builder-runtime.js +630 -0
  284. package/dist/ai-service/builder-runtime.js.map +1 -0
  285. package/dist/ai-service/builder-session-store.d.ts +26 -0
  286. package/dist/ai-service/builder-session-store.d.ts.map +1 -0
  287. package/dist/ai-service/builder-session-store.js +66 -0
  288. package/dist/ai-service/builder-session-store.js.map +1 -0
  289. package/dist/ai-service/builder-tool-callbacks.d.ts +29 -0
  290. package/dist/ai-service/builder-tool-callbacks.d.ts.map +1 -0
  291. package/dist/ai-service/builder-tool-callbacks.js +135 -0
  292. package/dist/ai-service/builder-tool-callbacks.js.map +1 -0
  293. package/dist/ai-service/builder-tools.d.ts +70 -0
  294. package/dist/ai-service/builder-tools.d.ts.map +1 -0
  295. package/dist/ai-service/builder-tools.js +380 -0
  296. package/dist/ai-service/builder-tools.js.map +1 -0
  297. package/dist/ai-service/builder-workspace.d.ts +158 -0
  298. package/dist/ai-service/builder-workspace.d.ts.map +1 -0
  299. package/dist/ai-service/builder-workspace.js +389 -0
  300. package/dist/ai-service/builder-workspace.js.map +1 -0
  301. package/dist/ai-service/chat/chat-push-metrics.d.ts.map +1 -1
  302. package/dist/ai-service/chat/chat-session-store-metrics.d.ts.map +1 -1
  303. package/dist/ai-service/chat/chat-session-store.d.ts +10 -1
  304. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  305. package/dist/ai-service/chat/chat-session-store.js +30 -1
  306. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  307. package/dist/ai-service/chat/switch-chat-seed.d.ts +8 -0
  308. package/dist/ai-service/chat/switch-chat-seed.d.ts.map +1 -0
  309. package/dist/ai-service/chat/switch-chat-seed.js +47 -0
  310. package/dist/ai-service/chat/switch-chat-seed.js.map +1 -0
  311. package/dist/ai-service/chat/transcript-budget.d.ts.map +1 -1
  312. package/dist/ai-service/chat/transcript-metrics.d.ts.map +1 -1
  313. package/dist/ai-service/checklist/persisted-checklist-store.d.ts +2 -2
  314. package/dist/ai-service/checklist/persisted-checklist-store.d.ts.map +1 -1
  315. package/dist/ai-service/checklist/remediation-findings-client.d.ts +8 -8
  316. package/dist/ai-service/const.d.ts.map +1 -1
  317. package/dist/ai-service/context/app-context.d.ts.map +1 -1
  318. package/dist/ai-service/context/app-context.js.map +1 -1
  319. package/dist/ai-service/context-flush-scheduler.d.ts.map +1 -1
  320. package/dist/ai-service/dev-database-client.d.ts.map +1 -1
  321. package/dist/ai-service/dev-database-client.js.map +1 -1
  322. package/dist/ai-service/dev-database-file-sync.d.ts +3 -1
  323. package/dist/ai-service/dev-database-file-sync.d.ts.map +1 -1
  324. package/dist/ai-service/dev-database-file-sync.js.map +1 -1
  325. package/dist/ai-service/edit-after-clark.d.ts.map +1 -1
  326. package/dist/ai-service/edit-after-clark.js.map +1 -1
  327. package/dist/ai-service/features.d.ts +21 -8
  328. package/dist/ai-service/features.d.ts.map +1 -1
  329. package/dist/ai-service/features.js +21 -8
  330. package/dist/ai-service/features.js.map +1 -1
  331. package/dist/ai-service/index.d.ts +96 -20
  332. package/dist/ai-service/index.d.ts.map +1 -1
  333. package/dist/ai-service/index.js +705 -740
  334. package/dist/ai-service/index.js.map +1 -1
  335. package/dist/ai-service/integrations/gron.js.map +1 -1
  336. package/dist/ai-service/integrations/metadata-storage/local.d.ts.map +1 -1
  337. package/dist/ai-service/integrations/ripgrep-path.js.map +1 -1
  338. package/dist/ai-service/integrations/store.d.ts.map +1 -1
  339. package/dist/ai-service/integrations/store.js.map +1 -1
  340. package/dist/ai-service/judge/integration/playwright-bridge.d.ts.map +1 -1
  341. package/dist/ai-service/judge/integration/playwright-bridge.js.map +1 -1
  342. package/dist/ai-service/judge/judge-executor.d.ts.map +1 -1
  343. package/dist/ai-service/judge/judge-executor.js.map +1 -1
  344. package/dist/ai-service/judge/judge-service.d.ts.map +1 -1
  345. package/dist/ai-service/judge/judge-service.js.map +1 -1
  346. package/dist/ai-service/judge/prompts/system-prompt.js.map +1 -1
  347. package/dist/ai-service/judge/storage/csv-storage.d.ts.map +1 -1
  348. package/dist/ai-service/judge/storage/csv-storage.js.map +1 -1
  349. package/dist/ai-service/judge/tools/playwright-action.d.ts +16 -16
  350. package/dist/ai-service/judge/tools/submit-feedback.d.ts +6 -6
  351. package/dist/ai-service/knowledge/knowledge-manager.d.ts.map +1 -1
  352. package/dist/ai-service/knowledge/knowledge-metrics.d.ts.map +1 -1
  353. package/dist/ai-service/live-edit-events/forwarder.d.ts.map +1 -1
  354. package/dist/ai-service/live-edit-events/forwarder.js.map +1 -1
  355. package/dist/ai-service/llm/chaos-fetch.js.map +1 -1
  356. package/dist/ai-service/llm/clark-stream-telemetry-sink.js.map +1 -1
  357. package/dist/ai-service/llm/client.d.ts.map +1 -1
  358. package/dist/ai-service/llm/client.js.map +1 -1
  359. package/dist/ai-service/llm/context-v2/adapter.d.ts.map +1 -1
  360. package/dist/ai-service/llm/context-v2/adapter.js.map +1 -1
  361. package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts.map +1 -1
  362. package/dist/ai-service/llm/context-v2/compaction/server-side.d.ts.map +1 -1
  363. package/dist/ai-service/llm/context-v2/context-management.d.ts.map +1 -1
  364. package/dist/ai-service/llm/context-v2/context-metrics.d.ts.map +1 -1
  365. package/dist/ai-service/llm/context-v2/context-metrics.js +2 -2
  366. package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -1
  367. package/dist/ai-service/llm/context-v2/context.js.map +1 -1
  368. package/dist/ai-service/llm/context-v2/file-read-ledger.d.ts.map +1 -1
  369. package/dist/ai-service/llm/context-v2/manager.d.ts +3 -1
  370. package/dist/ai-service/llm/context-v2/manager.d.ts.map +1 -1
  371. package/dist/ai-service/llm/context-v2/manager.js +5 -0
  372. package/dist/ai-service/llm/context-v2/manager.js.map +1 -1
  373. package/dist/ai-service/llm/context-v2/operation-queue.d.ts.map +1 -1
  374. package/dist/ai-service/llm/context-v2/storage/event-types.d.ts +16 -16
  375. package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.d.ts.map +1 -1
  376. package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.js.map +1 -1
  377. package/dist/ai-service/llm/context-v2/storage/local.d.ts.map +1 -1
  378. package/dist/ai-service/llm/context-v2/storage/local.js.map +1 -1
  379. package/dist/ai-service/llm/context-v2/storage/migration.d.ts.map +1 -1
  380. package/dist/ai-service/llm/context-v2/storage/migration.js.map +1 -1
  381. package/dist/ai-service/llm/context-v2/truncation-fallback.js.map +1 -1
  382. package/dist/ai-service/llm/context-v2/types.d.ts +1 -1
  383. package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
  384. package/dist/ai-service/llm/context-v2/types.js.map +1 -1
  385. package/dist/ai-service/llm/error.d.ts.map +1 -1
  386. package/dist/ai-service/llm/impl/clark.d.ts.map +1 -1
  387. package/dist/ai-service/llm/interaction/adapters/vercel.d.ts.map +1 -1
  388. package/dist/ai-service/llm/provider.d.ts.map +1 -1
  389. package/dist/ai-service/llm/provider.js +7 -24
  390. package/dist/ai-service/llm/provider.js.map +1 -1
  391. package/dist/ai-service/llm/request-settings.d.ts +6 -0
  392. package/dist/ai-service/llm/request-settings.d.ts.map +1 -0
  393. package/dist/ai-service/llm/request-settings.js +21 -0
  394. package/dist/ai-service/llm/request-settings.js.map +1 -0
  395. package/dist/ai-service/llm/stream/config.d.ts +1 -1
  396. package/dist/ai-service/llm/stream/config.d.ts.map +1 -1
  397. package/dist/ai-service/llm/stream/config.js.map +1 -1
  398. package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts.map +1 -1
  399. package/dist/ai-service/llm/stream/errors.d.ts +4 -1
  400. package/dist/ai-service/llm/stream/errors.d.ts.map +1 -1
  401. package/dist/ai-service/llm/stream/errors.js +8 -2
  402. package/dist/ai-service/llm/stream/errors.js.map +1 -1
  403. package/dist/ai-service/llm/stream/event-bus.d.ts.map +1 -1
  404. package/dist/ai-service/llm/stream/idle-monitor.d.ts.map +1 -1
  405. package/dist/ai-service/llm/stream/observers/attempt-model.d.ts.map +1 -1
  406. package/dist/ai-service/llm/stream/observers/context.d.ts.map +1 -1
  407. package/dist/ai-service/llm/stream/observers/llmobs.d.ts.map +1 -1
  408. package/dist/ai-service/llm/stream/observers/llmobs.js.map +1 -1
  409. package/dist/ai-service/llm/stream/observers/logging.d.ts.map +1 -1
  410. package/dist/ai-service/llm/stream/observers/logging.js.map +1 -1
  411. package/dist/ai-service/llm/stream/observers/retry-notification.d.ts.map +1 -1
  412. package/dist/ai-service/llm/stream/observers/retry-notification.js.map +1 -1
  413. package/dist/ai-service/llm/stream/observers/step-token-usage.d.ts.map +1 -1
  414. package/dist/ai-service/llm/stream/observers/step-token-usage.js.map +1 -1
  415. package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -1
  416. package/dist/ai-service/llm/stream/orchestrator.js +3 -6
  417. package/dist/ai-service/llm/stream/orchestrator.js.map +1 -1
  418. package/dist/ai-service/llm/stream/retry-engine.d.ts.map +1 -1
  419. package/dist/ai-service/llm/stream/retry-engine.js.map +1 -1
  420. package/dist/ai-service/llm/stream/session.d.ts.map +1 -1
  421. package/dist/ai-service/llm/stream/tests/helpers/mock-provider.d.ts +1 -1
  422. package/dist/ai-service/llm/stream/tests/helpers/mock-provider.d.ts.map +1 -1
  423. package/dist/ai-service/llm/stream/tests/helpers/mock-provider.js.map +1 -1
  424. package/dist/ai-service/llm/stream/wait-state-tracker.d.ts.map +1 -1
  425. package/dist/ai-service/llm/tool-context-integrity.js.map +1 -1
  426. package/dist/ai-service/llmobs/constants.d.ts.map +1 -1
  427. package/dist/ai-service/llmobs/context-registry.d.ts.map +1 -1
  428. package/dist/ai-service/llmobs/helpers.js.map +1 -1
  429. package/dist/ai-service/llmobs/index.d.ts.map +1 -1
  430. package/dist/ai-service/llmobs/otel-exporter.d.ts.map +1 -1
  431. package/dist/ai-service/llmobs/otel-exporter.js +1 -1
  432. package/dist/ai-service/llmobs/tracer.d.ts.map +1 -1
  433. package/dist/ai-service/llmobs/tracer.js +4 -21
  434. package/dist/ai-service/llmobs/tracer.js.map +1 -1
  435. package/dist/ai-service/managed-native-db-availability.d.ts +1 -1
  436. package/dist/ai-service/managed-native-db-availability.d.ts.map +1 -1
  437. package/dist/ai-service/managed-native-db-availability.js +4 -2
  438. package/dist/ai-service/managed-native-db-availability.js.map +1 -1
  439. package/dist/ai-service/mcp/adapter/mcp-tool-adapter.d.ts.map +1 -1
  440. package/dist/ai-service/mcp/adapter/mcp-tool-adapter.js.map +1 -1
  441. package/dist/ai-service/mcp/embedded-playwright-mcp-server.js.map +1 -1
  442. package/dist/ai-service/mcp/playwright-server.d.ts.map +1 -1
  443. package/dist/ai-service/native-callback-order.d.ts +7 -0
  444. package/dist/ai-service/native-callback-order.d.ts.map +1 -0
  445. package/dist/ai-service/native-callback-order.js +39 -0
  446. package/dist/ai-service/native-callback-order.js.map +1 -0
  447. package/dist/ai-service/native-secret-redactor.d.ts +4 -0
  448. package/dist/ai-service/native-secret-redactor.d.ts.map +1 -0
  449. package/dist/ai-service/native-secret-redactor.js +38 -0
  450. package/dist/ai-service/native-secret-redactor.js.map +1 -0
  451. package/dist/ai-service/policy-agent-metrics.d.ts.map +1 -1
  452. package/dist/ai-service/policy-gate-remediation-usage.d.ts +2 -1
  453. package/dist/ai-service/policy-gate-remediation-usage.d.ts.map +1 -1
  454. package/dist/ai-service/policy-gate-remediation-usage.js +2 -1
  455. package/dist/ai-service/policy-gate-remediation-usage.js.map +1 -1
  456. package/dist/ai-service/policy-gate-review.d.ts +42 -0
  457. package/dist/ai-service/policy-gate-review.d.ts.map +1 -0
  458. package/dist/ai-service/policy-gate-review.js +664 -0
  459. package/dist/ai-service/policy-gate-review.js.map +1 -0
  460. package/dist/ai-service/profiler/clark-profiler.d.ts.map +1 -1
  461. package/dist/ai-service/profiler/perfetto-profiler.d.ts.map +1 -1
  462. package/dist/ai-service/profiler/perfetto-profiler.js.map +1 -1
  463. package/dist/ai-service/profiler/tool-profiler.d.ts.map +1 -1
  464. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.d.ts.map +1 -1
  465. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.js.map +1 -1
  466. package/dist/ai-service/recording/recorders/llm-recorder.js.map +1 -1
  467. package/dist/ai-service/recording/recording-manager.d.ts.map +1 -1
  468. package/dist/ai-service/recording/recording-manager.js.map +1 -1
  469. package/dist/ai-service/recording/snapshot-manager.d.ts.map +1 -1
  470. package/dist/ai-service/recording/snapshot-manager.js.map +1 -1
  471. package/dist/ai-service/recording/storage/session-recording-storage.d.ts.map +1 -1
  472. package/dist/ai-service/recording/storage/session-recording-storage.js.map +1 -1
  473. package/dist/ai-service/request-deduplicator.d.ts.map +1 -1
  474. package/dist/ai-service/request-deduplicator.js.map +1 -1
  475. package/dist/ai-service/security/secret-scanner-service.js.map +1 -1
  476. package/dist/ai-service/security/secret-scanner.d.ts.map +1 -1
  477. package/dist/ai-service/security/secret-scanner.js.map +1 -1
  478. package/dist/ai-service/security/vulnerability-triage.d.ts +5 -5
  479. package/dist/ai-service/skills/system/materialized.d.ts +3 -1
  480. package/dist/ai-service/skills/system/materialized.d.ts.map +1 -1
  481. package/dist/ai-service/skills/system/materialized.js +3 -3
  482. package/dist/ai-service/skills/system/materialized.js.map +1 -1
  483. package/dist/ai-service/skills/system/native.d.ts +15 -0
  484. package/dist/ai-service/skills/system/native.d.ts.map +1 -0
  485. package/dist/ai-service/skills/system/native.js +32 -0
  486. package/dist/ai-service/skills/system/native.js.map +1 -0
  487. package/dist/ai-service/skills/system/paths.d.ts +2 -0
  488. package/dist/ai-service/skills/system/paths.d.ts.map +1 -0
  489. package/dist/ai-service/skills/system/paths.js +3 -0
  490. package/dist/ai-service/skills/system/paths.js.map +1 -0
  491. package/dist/ai-service/skills/system/resolve.js.map +1 -1
  492. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts +1 -1
  493. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts.map +1 -1
  494. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js +11 -9
  495. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js.map +1 -1
  496. package/dist/ai-service/skills/types.d.ts.map +1 -1
  497. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  498. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  499. package/dist/ai-service/state-machine/fsm.d.ts.map +1 -1
  500. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  501. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  502. package/dist/ai-service/state-machine/handlers/awaiting-user.d.ts.map +1 -1
  503. package/dist/ai-service/state-machine/handlers/awaiting-user.js.map +1 -1
  504. package/dist/ai-service/state-machine/handlers/idle.d.ts.map +1 -1
  505. package/dist/ai-service/state-machine/handlers/idle.js.map +1 -1
  506. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  507. package/dist/ai-service/state-machine/handlers/llm-generating.js +10 -18
  508. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  509. package/dist/ai-service/state-machine/handlers/play-dead.d.ts.map +1 -1
  510. package/dist/ai-service/state-machine/handlers/play-dead.js.map +1 -1
  511. package/dist/ai-service/state-machine/handlers/post-processing.d.ts.map +1 -1
  512. package/dist/ai-service/state-machine/handlers/post-processing.js.map +1 -1
  513. package/dist/ai-service/state-machine/handlers/runtime-reviewing.d.ts.map +1 -1
  514. package/dist/ai-service/state-machine/helpers/change-info.d.ts.map +1 -1
  515. package/dist/ai-service/state-machine/helpers/change-info.js.map +1 -1
  516. package/dist/ai-service/state-machine/helpers/classification.d.ts.map +1 -1
  517. package/dist/ai-service/state-machine/helpers/context-id.js.map +1 -1
  518. package/dist/ai-service/state-machine/helpers/metadata.d.ts.map +1 -1
  519. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  520. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  521. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts +1 -1
  522. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts.map +1 -1
  523. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js +1 -1
  524. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js.map +1 -1
  525. package/dist/ai-service/state-machine/helpers/pre-session-metrics.d.ts.map +1 -1
  526. package/dist/ai-service/state-machine/helpers/prompt-degradation-cause.d.ts.map +1 -1
  527. package/dist/ai-service/state-machine/helpers/prompt-degradation-metrics.d.ts.map +1 -1
  528. package/dist/ai-service/state-machine/helpers/prompt-failure.d.ts.map +1 -1
  529. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts +16 -1
  530. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts.map +1 -1
  531. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js +65 -0
  532. package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js.map +1 -1
  533. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
  534. package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
  535. package/dist/ai-service/state-machine/helpers/transition.d.ts.map +1 -1
  536. package/dist/ai-service/state-machine/helpers/user-preferences.d.ts.map +1 -1
  537. package/dist/ai-service/state-machine/helpers/user-response-message.d.ts.map +1 -1
  538. package/dist/ai-service/state-machine/helpers/user-response-message.js +4 -2
  539. package/dist/ai-service/state-machine/helpers/user-response-message.js.map +1 -1
  540. package/dist/ai-service/state-machine/test-util.d.ts.map +1 -1
  541. package/dist/ai-service/state-machine/test-util.js.map +1 -1
  542. package/dist/ai-service/state-machine/traced-fsm.d.ts.map +1 -1
  543. package/dist/ai-service/state-machine/traced-fsm.js.map +1 -1
  544. package/dist/ai-service/tasks/task-store.d.ts.map +1 -1
  545. package/dist/ai-service/tasks/task-store.js.map +1 -1
  546. package/dist/ai-service/template-renderer.d.ts.map +1 -1
  547. package/dist/ai-service/template-renderer.js +3 -3
  548. package/dist/ai-service/template-renderer.js.map +1 -1
  549. package/dist/ai-service/test-utils/error-mocks.d.ts +2 -2
  550. package/dist/ai-service/test-utils/span-interceptor.d.ts.map +1 -1
  551. package/dist/ai-service/test-utils/span-interceptor.js +2 -2
  552. package/dist/ai-service/transform/api-builder/shared.d.ts.map +1 -1
  553. package/dist/ai-service/transform/api-builder/shared.js.map +1 -1
  554. package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts.map +1 -1
  555. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js.map +1 -1
  556. package/dist/ai-service/transform/api-builder/to-yaml-transformer.d.ts.map +1 -1
  557. package/dist/ai-service/transform/api-builder/to-yaml-transformer.js.map +1 -1
  558. package/dist/ai-service/transform/remove-api-builder-imports/transformer.d.ts.map +1 -1
  559. package/dist/ai-service/transform/shared.d.ts.map +1 -1
  560. package/dist/ai-service/transform/workaround-missing-sbapi/transformer.d.ts.map +1 -1
  561. package/dist/ai-service/types.d.ts +18 -0
  562. package/dist/ai-service/types.d.ts.map +1 -1
  563. package/dist/ai-service/types.js +1 -1
  564. package/dist/ai-service/types.js.map +1 -1
  565. package/dist/ai-service/util/archive-extractors.d.ts.map +1 -1
  566. package/dist/ai-service/util/call-peer.d.ts.map +1 -1
  567. package/dist/ai-service/util/llm-config-utils.js.map +1 -1
  568. package/dist/ai-service/util/peer-liveness.d.ts.map +1 -1
  569. package/dist/ai-service/util/peer-liveness.js.map +1 -1
  570. package/dist/ai-service/util/rpc-timeout.d.ts.map +1 -1
  571. package/dist/ai-service/util/rpc-timeout.js.map +1 -1
  572. package/dist/ai-service/util/stop-condition.d.ts +2 -0
  573. package/dist/ai-service/util/stop-condition.d.ts.map +1 -1
  574. package/dist/ai-service/util/stop-condition.js +3 -0
  575. package/dist/ai-service/util/stop-condition.js.map +1 -1
  576. package/dist/ai-service/workspace-edge-health.d.ts +11 -0
  577. package/dist/ai-service/workspace-edge-health.d.ts.map +1 -0
  578. package/dist/ai-service/workspace-edge-health.js +30 -0
  579. package/dist/ai-service/workspace-edge-health.js.map +1 -0
  580. package/dist/ai-service/workspace-endpoint-publisher.d.ts +27 -0
  581. package/dist/ai-service/workspace-endpoint-publisher.d.ts.map +1 -0
  582. package/dist/ai-service/workspace-endpoint-publisher.js +44 -0
  583. package/dist/ai-service/workspace-endpoint-publisher.js.map +1 -0
  584. package/dist/ai-service/workspace-metrics.d.ts +11 -0
  585. package/dist/ai-service/workspace-metrics.d.ts.map +1 -0
  586. package/dist/ai-service/workspace-metrics.js +53 -0
  587. package/dist/ai-service/workspace-metrics.js.map +1 -0
  588. package/dist/ai-service/workspace-mirror.d.ts +52 -0
  589. package/dist/ai-service/workspace-mirror.d.ts.map +1 -0
  590. package/dist/ai-service/workspace-mirror.js +100 -0
  591. package/dist/ai-service/workspace-mirror.js.map +1 -0
  592. package/dist/binding-extraction/extract-control-block-identifiers.d.ts.map +1 -1
  593. package/dist/binding-extraction/extract-control-block-identifiers.js.map +1 -1
  594. package/dist/binding-extraction/extract-embedded-identifiers.d.ts.map +1 -1
  595. package/dist/binding-extraction/extract-identifiers.js.map +1 -1
  596. package/dist/binding-extraction/js-identifiers.d.ts +2 -15
  597. package/dist/binding-extraction/js-identifiers.d.ts.map +1 -1
  598. package/dist/binding-extraction/js-identifiers.js +3 -6
  599. package/dist/binding-extraction/js-identifiers.js.map +1 -1
  600. package/dist/binding-extraction/python-identifiers.d.ts.map +1 -1
  601. package/dist/binding-extraction/python-identifiers.js.map +1 -1
  602. package/dist/build-errors.d.ts.map +1 -1
  603. package/dist/components-manager.d.ts.map +1 -1
  604. package/dist/dev-server-ws-smoke-client.js.map +1 -1
  605. package/dist/errors/make-server-error.d.ts.map +1 -1
  606. package/dist/errors/make-server-error.js.map +1 -1
  607. package/dist/extract-api-integrations.d.ts +52 -91
  608. package/dist/extract-api-integrations.d.ts.map +1 -1
  609. package/dist/extract-api-integrations.js +512 -487
  610. package/dist/extract-api-integrations.js.map +1 -1
  611. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  612. package/dist/file-sync-vite-plugin.js +124 -45
  613. package/dist/file-sync-vite-plugin.js.map +1 -1
  614. package/dist/file-system-helpers.d.ts +1 -34
  615. package/dist/file-system-helpers.d.ts.map +1 -1
  616. package/dist/file-system-helpers.js +9 -66
  617. package/dist/file-system-helpers.js.map +1 -1
  618. package/dist/file-system-manager.d.ts.map +1 -1
  619. package/dist/file-system-manager.js +1 -1
  620. package/dist/file-system-manager.js.map +1 -1
  621. package/dist/git-service/app-layout-guard.js.map +1 -1
  622. package/dist/git-service/credential-scope.d.ts +16 -0
  623. package/dist/git-service/credential-scope.d.ts.map +1 -0
  624. package/dist/git-service/credential-scope.js +94 -0
  625. package/dist/git-service/credential-scope.js.map +1 -0
  626. package/dist/git-service/errors.d.ts.map +1 -1
  627. package/dist/git-service/errors.js.map +1 -1
  628. package/dist/git-service/index.d.ts +1 -0
  629. package/dist/git-service/index.d.ts.map +1 -1
  630. package/dist/git-service/index.js +6 -38
  631. package/dist/git-service/index.js.map +1 -1
  632. package/dist/git-service/managed-excludes.d.ts.map +1 -1
  633. package/dist/git-service/managed-excludes.js +2 -0
  634. package/dist/git-service/managed-excludes.js.map +1 -1
  635. package/dist/ids.d.ts.map +1 -1
  636. package/dist/index.d.ts +4 -1
  637. package/dist/index.d.ts.map +1 -1
  638. package/dist/index.js +1 -0
  639. package/dist/index.js.map +1 -1
  640. package/dist/inject-index-vite-plugin.d.ts.map +1 -1
  641. package/dist/injected-index.d.ts +1 -3
  642. package/dist/injected-index.d.ts.map +1 -1
  643. package/dist/injected-index.js +3 -8
  644. package/dist/injected-index.js.map +1 -1
  645. package/dist/lock-service/activity-tracker.d.ts.map +1 -1
  646. package/dist/lock-service/index.d.ts +50 -5
  647. package/dist/lock-service/index.d.ts.map +1 -1
  648. package/dist/lock-service/index.js +143 -8
  649. package/dist/lock-service/index.js.map +1 -1
  650. package/dist/migration/get-fullstack-template-dir.d.ts +2 -5
  651. package/dist/migration/get-fullstack-template-dir.d.ts.map +1 -1
  652. package/dist/migration/get-fullstack-template-dir.js +5 -8
  653. package/dist/migration/get-fullstack-template-dir.js.map +1 -1
  654. package/dist/migration/integration-write-policy.js.map +1 -1
  655. package/dist/migration/mark-api-testing-denied.js.map +1 -1
  656. package/dist/migration/migration-routes.js.map +1 -1
  657. package/dist/migration/migration-verification.d.ts +16 -16
  658. package/dist/migration/migration-verification.d.ts.map +1 -1
  659. package/dist/migration/recommended-user-deps.d.ts.map +1 -1
  660. package/dist/migration/unsupported-integrations.js.map +1 -1
  661. package/dist/migration-templates/app-fullstack/eslint.config.js +7 -1
  662. package/dist/migration-templates/app-fullstack/package.json +3 -3
  663. package/dist/migration-templates/app-fullstack/vite.config.ts +5 -3
  664. package/dist/native-system-skills.d.ts +2 -0
  665. package/dist/native-system-skills.d.ts.map +1 -0
  666. package/dist/native-system-skills.js +4 -0
  667. package/dist/native-system-skills.js.map +1 -0
  668. package/dist/npm/prepare-package-json-for-cloud-npm.js.map +1 -1
  669. package/dist/operations/operation-processor.d.ts.map +1 -1
  670. package/dist/operations/operation-processor.js.map +1 -1
  671. package/dist/parsing/bindings.js.map +1 -1
  672. package/dist/parsing/jsx.d.ts +1 -1
  673. package/dist/parsing/jsx.js.map +1 -1
  674. package/dist/parsing/util.js.map +1 -1
  675. package/dist/plugin-options.d.ts +106 -1
  676. package/dist/plugin-options.d.ts.map +1 -1
  677. package/dist/plugin-options.js.map +1 -1
  678. package/dist/policy-gate-run-registry.d.ts.map +1 -1
  679. package/dist/policy-gate-runner.d.ts +32 -7
  680. package/dist/policy-gate-runner.d.ts.map +1 -1
  681. package/dist/policy-gate-runner.js +23 -6
  682. package/dist/policy-gate-runner.js.map +1 -1
  683. package/dist/reconnect-guard-plugin.d.ts.map +1 -1
  684. package/dist/reconnect-guard-plugin.js +9 -5
  685. package/dist/reconnect-guard-plugin.js.map +1 -1
  686. package/dist/refactor/blocks.d.ts.map +1 -1
  687. package/dist/refactor/blocks.js +2 -2
  688. package/dist/refactor/blocks.js.map +1 -1
  689. package/dist/resolver.d.ts.map +1 -1
  690. package/dist/resolver.js +8 -1
  691. package/dist/resolver.js.map +1 -1
  692. package/dist/review-runner.d.ts +25 -0
  693. package/dist/review-runner.d.ts.map +1 -0
  694. package/dist/review-runner.js +196 -0
  695. package/dist/review-runner.js.map +1 -0
  696. package/dist/router-parser.d.ts.map +1 -1
  697. package/dist/router-parser.js +16 -5
  698. package/dist/router-parser.js.map +1 -1
  699. package/dist/scan-scope-merge.d.ts +1 -1
  700. package/dist/server-rpc/index.d.ts.map +1 -1
  701. package/dist/server-rpc/index.js.map +1 -1
  702. package/dist/server-rpc/rpc-invalidate-metrics.d.ts.map +1 -1
  703. package/dist/socket-manager.d.ts +26 -3
  704. package/dist/socket-manager.d.ts.map +1 -1
  705. package/dist/socket-manager.js +245 -23
  706. package/dist/socket-manager.js.map +1 -1
  707. package/dist/source-tracker.d.ts.map +1 -1
  708. package/dist/split-edit-after-clark.d.ts.map +1 -1
  709. package/dist/split-edit-after-clark.js.map +1 -1
  710. package/dist/sync-service/download.d.ts +2 -53
  711. package/dist/sync-service/download.d.ts.map +1 -1
  712. package/dist/sync-service/download.js +3 -469
  713. package/dist/sync-service/download.js.map +1 -1
  714. package/dist/sync-service/draft-helpers.d.ts +1 -103
  715. package/dist/sync-service/draft-helpers.d.ts.map +1 -1
  716. package/dist/sync-service/draft-helpers.js +2 -579
  717. package/dist/sync-service/draft-helpers.js.map +1 -1
  718. package/dist/sync-service/draft-mutation.d.ts +11 -0
  719. package/dist/sync-service/draft-mutation.d.ts.map +1 -0
  720. package/dist/sync-service/draft-mutation.js +121 -0
  721. package/dist/sync-service/draft-mutation.js.map +1 -0
  722. package/dist/sync-service/draft-state-report-metrics.d.ts +1 -4
  723. package/dist/sync-service/draft-state-report-metrics.d.ts.map +1 -1
  724. package/dist/sync-service/draft-state-report-metrics.js +2 -35
  725. package/dist/sync-service/draft-state-report-metrics.js.map +1 -1
  726. package/dist/sync-service/hash-cache.d.ts +1 -15
  727. package/dist/sync-service/hash-cache.d.ts.map +1 -1
  728. package/dist/sync-service/hash-cache.js +2 -61
  729. package/dist/sync-service/hash-cache.js.map +1 -1
  730. package/dist/sync-service/index.d.ts +25 -2
  731. package/dist/sync-service/index.d.ts.map +1 -1
  732. package/dist/sync-service/index.js +205 -9
  733. package/dist/sync-service/index.js.map +1 -1
  734. package/dist/sync-service/list-dir.d.ts +2 -28
  735. package/dist/sync-service/list-dir.d.ts.map +1 -1
  736. package/dist/sync-service/list-dir.js +3 -149
  737. package/dist/sync-service/list-dir.js.map +1 -1
  738. package/dist/sync-service/native-draft-session.d.ts +3 -0
  739. package/dist/sync-service/native-draft-session.d.ts.map +1 -0
  740. package/dist/sync-service/native-draft-session.js +4 -0
  741. package/dist/sync-service/native-draft-session.js.map +1 -0
  742. package/dist/sync-service/safe-directory-reader.d.ts +2 -0
  743. package/dist/sync-service/safe-directory-reader.d.ts.map +1 -0
  744. package/dist/sync-service/safe-directory-reader.js +3 -0
  745. package/dist/sync-service/safe-directory-reader.js.map +1 -0
  746. package/dist/sync-service/snapshot/take-snapshot.d.ts +2 -40
  747. package/dist/sync-service/snapshot/take-snapshot.d.ts.map +1 -1
  748. package/dist/sync-service/snapshot/take-snapshot.js +3 -243
  749. package/dist/sync-service/snapshot/take-snapshot.js.map +1 -1
  750. package/dist/sync-service/snapshot/types.d.ts +1 -24
  751. package/dist/sync-service/snapshot/types.d.ts.map +1 -1
  752. package/dist/sync-service/snapshot/types.js +2 -2
  753. package/dist/sync-service/snapshot/types.js.map +1 -1
  754. package/dist/sync-service/snapshot/upload-snapshot.d.ts +1 -4
  755. package/dist/sync-service/snapshot/upload-snapshot.d.ts.map +1 -1
  756. package/dist/sync-service/snapshot/upload-snapshot.js +2 -82
  757. package/dist/sync-service/snapshot/upload-snapshot.js.map +1 -1
  758. package/dist/util/generation-number-sequence.d.ts.map +1 -1
  759. package/dist/util/generation-number-sequence.js.map +1 -1
  760. package/dist/util/generation-wait-timeout-error.d.ts.map +1 -1
  761. package/dist/util/generation-wait-timeout-error.js.map +1 -1
  762. package/dist/util/log-sanitizer.d.ts +4 -0
  763. package/dist/util/log-sanitizer.d.ts.map +1 -1
  764. package/dist/util/log-sanitizer.js +28 -5
  765. package/dist/util/log-sanitizer.js.map +1 -1
  766. package/dist/util/logger.d.ts.map +1 -1
  767. package/dist/util/logger.js +4 -0
  768. package/dist/util/logger.js.map +1 -1
  769. package/dist/util/operation-queue.d.ts.map +1 -1
  770. package/dist/util.d.ts.map +1 -1
  771. package/dist/vite-module-reload.d.ts.map +1 -1
  772. package/dist/vite-module-reload.js.map +1 -1
  773. package/dist/workspace-sync-methods.d.ts +37 -0
  774. package/dist/workspace-sync-methods.d.ts.map +1 -0
  775. package/dist/workspace-sync-methods.js +2 -0
  776. package/dist/workspace-sync-methods.js.map +1 -0
  777. package/package.json +75 -58
  778. package/dist/migration-templates/app-fullstack/.gitignore +0 -50
  779. package/dist/sync-service/hash-dir-tree.d.ts +0 -10
  780. package/dist/sync-service/hash-dir-tree.d.ts.map +0 -1
  781. package/dist/sync-service/hash-dir-tree.js +0 -53
  782. package/dist/sync-service/hash-dir-tree.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { posix as posixPath } from "node:path";
2
2
  import { parse } from "@babel/parser";
3
+ import * as t from "@babel/types";
3
4
  function isNode(value) {
4
5
  return !!value && typeof value === "object";
5
6
  }
@@ -76,164 +77,48 @@ function unwrapExpression(node) {
76
77
  }
77
78
  return node;
78
79
  }
80
+ function specifiersOf(statement) {
81
+ return Array.isArray(statement.specifiers)
82
+ ? statement.specifiers.filter(isNode)
83
+ : [];
84
+ }
79
85
  function isTypeOnly(node) {
80
86
  return (node.importKind === "type" ||
81
87
  node.importKind === "typeof" ||
82
88
  node.exportKind === "type");
83
89
  }
84
90
  function valueSpecifiersOf(statement) {
85
- if (isTypeOnly(statement) || !Array.isArray(statement.specifiers)) {
86
- return [];
87
- }
88
- return statement.specifiers.filter((specifier) => isNode(specifier) && !isTypeOnly(specifier));
91
+ return isTypeOnly(statement)
92
+ ? []
93
+ : specifiersOf(statement).filter((specifier) => !isTypeOnly(specifier));
89
94
  }
90
95
  /**
91
- * Walks top-level variable declarations in a program body, calling `visitor`
92
- * for each individual declarator of a binding `bindings` trusts. Unwraps
93
- * `export const x = ...` (`ExportNamedDeclaration` whose `.declaration` is
94
- * a `VariableDeclaration`) to its inner `VariableDeclaration` so exported
95
- * declarations are visited the same as bare ones. A `declare` statement has
96
- * no runtime value, so it is never visited.
96
+ * The declarators of a top-level `const`, `let`, or `var` statement,
97
+ * including an exported one, and none for a `declare` statement, which has
98
+ * no runtime value.
97
99
  */
98
- function visitVariableDeclarations(programBody, bindings, visitor) {
99
- for (const statement of programBody) {
100
- if (!isNode(statement)) {
101
- continue;
102
- }
103
- const declarationNode = statement.type === "ExportNamedDeclaration" &&
104
- isNode(statement.declaration)
105
- ? statement.declaration
106
- : statement;
107
- if (declarationNode.type !== "VariableDeclaration" ||
108
- declarationNode.declare === true ||
109
- (bindings === "const-only" && declarationNode.kind !== "const") ||
110
- !Array.isArray(declarationNode.declarations)) {
111
- continue;
112
- }
113
- for (const declaration of declarationNode.declarations) {
114
- if (isNode(declaration)) {
115
- visitor(declaration);
116
- }
117
- }
118
- }
119
- }
120
- function buildVariableInitializerMap(programBody, bindings) {
121
- const initializers = new Map();
122
- visitVariableDeclarations(programBody, bindings, (declaration) => {
123
- const identifier = declaration.id;
124
- if (!isNode(identifier) ||
125
- identifier.type !== "Identifier" ||
126
- typeof identifier.name !== "string") {
127
- return;
128
- }
129
- initializers.set(identifier.name, declaration.init);
130
- });
131
- return initializers;
132
- }
133
- function resolveApiConfigObject(expression, variableInitializers) {
134
- const resolvedExpression = unwrapExpression(expression);
135
- if (!resolvedExpression) {
136
- return undefined;
137
- }
138
- if (resolvedExpression.type === "Identifier" &&
139
- typeof resolvedExpression.name === "string") {
140
- return resolveApiConfigObject(variableInitializers.get(resolvedExpression.name), variableInitializers);
141
- }
142
- if (resolvedExpression.type !== "CallExpression" ||
143
- getCalleeName(resolvedExpression.callee) !== "api" ||
144
- !Array.isArray(resolvedExpression.arguments)) {
145
- return undefined;
146
- }
147
- const config = unwrapExpression(resolvedExpression.arguments[0]);
148
- if (!config || config.type !== "ObjectExpression") {
149
- return undefined;
150
- }
151
- return config;
152
- }
153
- function findExportedApiConfigObject(programBody, bindings, exportName) {
154
- const variableInitializers = buildVariableInitializerMap(programBody, bindings);
155
- for (const statement of programBody) {
156
- if (!isNode(statement)) {
157
- continue;
158
- }
159
- if (exportName === "default" &&
160
- statement.type === "ExportDefaultDeclaration") {
161
- return resolveApiConfigObject(statement.declaration, variableInitializers);
162
- }
163
- if (statement.type === "ExportNamedDeclaration" &&
164
- !isNode(statement.source)) {
165
- if (exportName !== "default" &&
166
- isNode(statement.declaration) &&
167
- statement.declaration.type === "VariableDeclaration" &&
168
- statement.declaration.declare !== true &&
169
- Array.isArray(statement.declaration.declarations) &&
170
- statement.declaration.declarations.some((declaration) => isNode(declaration) &&
171
- getPropertyName(declaration.id) === exportName)) {
172
- return resolveApiConfigObject(variableInitializers.get(exportName), variableInitializers);
173
- }
174
- for (const specifier of valueSpecifiersOf(statement)) {
175
- if (specifier.type !== "ExportSpecifier" ||
176
- getPropertyName(specifier.exported) !== exportName) {
177
- continue;
178
- }
179
- return resolveApiConfigObject(specifier.local, variableInitializers);
180
- }
181
- }
100
+ function variableDeclaratorsOf(statement) {
101
+ const declaration = statement.type === "ExportNamedDeclaration" && isNode(statement.declaration)
102
+ ? statement.declaration
103
+ : statement;
104
+ if (declaration.type !== "VariableDeclaration" ||
105
+ declaration.declare === true ||
106
+ !Array.isArray(declaration.declarations)) {
107
+ return [];
182
108
  }
183
- return undefined;
184
- }
185
- function buildVariableReferenceMap(programBody, stringLiterals, bindings) {
186
- const refs = new Map();
187
- visitVariableDeclarations(programBody, bindings, (declaration) => {
188
- const identifier = declaration.id;
189
- const init = declaration.init;
190
- if (!isNode(identifier) ||
191
- identifier.type !== "Identifier" ||
192
- typeof identifier.name !== "string") {
193
- return;
194
- }
195
- if (!isNode(init) ||
196
- init.type !== "CallExpression" ||
197
- !Array.isArray(init.arguments)) {
198
- return;
199
- }
200
- const pluginId = getCalleeName(init.callee);
201
- const id = resolveStringArgument(init.arguments[0], stringLiterals);
202
- if (!pluginId || !id) {
203
- return;
204
- }
205
- refs.set(identifier.name, { pluginId, id });
206
- });
207
- return refs;
109
+ return declaration.declarations
110
+ .filter(isNode)
111
+ .map((declarator) => ({ kind: declaration.kind, declarator }));
208
112
  }
209
- function buildStringLiteralMap(programBody, bindings) {
210
- const literals = new Map();
211
- visitVariableDeclarations(programBody, bindings, (declaration) => {
212
- const identifier = declaration.id;
213
- if (!isNode(identifier) ||
214
- identifier.type !== "Identifier" ||
215
- typeof identifier.name !== "string") {
216
- return;
217
- }
218
- const value = getLiteralString(declaration.init);
219
- if (value !== undefined) {
220
- literals.set(identifier.name, value);
221
- }
222
- });
223
- return literals;
224
- }
225
- function resolveStringArgument(node, stringLiterals) {
226
- const literal = getLiteralString(node);
227
- if (literal !== undefined) {
228
- return literal;
229
- }
230
- if (isNode(node) &&
231
- node.type === "Identifier" &&
232
- typeof node.name === "string") {
233
- return stringLiterals.get(node.name);
113
+ function declaredNames(declaration) {
114
+ if (!t.isNode(declaration)) {
115
+ return [];
234
116
  }
235
- return undefined;
117
+ const names = Object.keys(t.getOuterBindingIdentifiers(declaration));
118
+ const declaredName = "id" in declaration ? getPropertyName(declaration.id) : undefined;
119
+ return declaredName ? [...names, declaredName] : names;
236
120
  }
121
+ const UNRESOLVED_EXPORT = { kind: "unresolved" };
237
122
  /**
238
123
  * The object literals an `api()` config declares its integrations in, and
239
124
  * whether they are all it declares. A spread, a computed key, an
@@ -255,220 +140,97 @@ function readIntegrationsObjects(apiConfig) {
255
140
  members.every((member) => getMemberKeyName(member) !== undefined),
256
141
  };
257
142
  }
258
- function extractFromProgram(programBody, importedRefs, bindings, exportName) {
259
- const stringLiterals = buildStringLiteralMap(programBody, bindings);
260
- // Seed with imported id constants (e.g. `import { SHEETS_ID } from
261
- // "../lib/constants.js"`) so a same-file declaration like
262
- // `const sheets = restApiIntegration(SHEETS_ID)` can resolve them. Only
263
- // fill in names the same-file scan didn't already find, so a same-file
264
- // literal always wins over an imported one of the same name. In practice
265
- // this `!stringLiterals.has(name)` check is defensive and unreachable for
266
- // valid input: a same-file `const X` and an `import { X }` of the same
267
- // name is a duplicate lexical binding, which is a parse/type error in
268
- // real TS/ESM and can't occur in a file that actually compiles.
269
- for (const [name, ref] of importedRefs) {
270
- if (ref.kind === "id" && !stringLiterals.has(name)) {
271
- stringLiterals.set(name, ref.id);
272
- }
273
- }
274
- const variableRefs = buildVariableReferenceMap(programBody, stringLiterals, bindings);
275
- const apiConfig = findExportedApiConfigObject(programBody, bindings, exportName);
276
- if (!apiConfig) {
277
- return { integrations: [], unresolvedKeys: [] };
278
- }
279
- const { objects, isDefinitive } = readIntegrationsObjects(apiConfig);
280
- const integrations = [];
281
- const unresolvedKeys = isDefinitive ? [] : ["*"];
282
- for (const property of objects.flatMap(membersOf)) {
283
- if (property.type !== "ObjectProperty") {
284
- // Not a key/value property at all (e.g. a spread element or a method),
285
- // so there is no key to report as unresolved.
286
- unresolvedKeys.push("(dynamic)");
287
- continue;
288
- }
289
- const key = getMemberKeyName(property);
290
- if (!key) {
291
- unresolvedKeys.push("(unknown)");
292
- continue;
293
- }
294
- if (isNode(property.value) &&
295
- property.value.type === "CallExpression" &&
296
- Array.isArray(property.value.arguments)) {
297
- const pluginId = getCalleeName(property.value.callee);
298
- const arg = property.value.arguments[0];
299
- let id = resolveStringArgument(arg, stringLiterals);
300
- if (!id &&
301
- isNode(arg) &&
302
- arg.type === "Identifier" &&
303
- typeof arg.name === "string") {
304
- const imported = importedRefs.get(arg.name);
305
- if (imported?.kind === "id") {
306
- id = imported.id;
307
- }
308
- }
309
- if (pluginId && id) {
310
- integrations.push({ key, pluginId, id });
311
- }
312
- else {
313
- unresolvedKeys.push(key);
314
- }
315
- continue;
316
- }
317
- if (isNode(property.value) &&
318
- property.value.type === "Identifier" &&
319
- typeof property.value.name === "string") {
320
- const resolved = variableRefs.get(property.value.name);
321
- if (resolved) {
322
- integrations.push({ key, ...resolved });
323
- continue;
324
- }
325
- const imported = importedRefs.get(property.value.name);
326
- if (imported?.kind === "declaration") {
327
- integrations.push({
328
- key,
329
- pluginId: imported.pluginId,
330
- id: imported.id,
331
- });
332
- continue;
333
- }
334
- unresolvedKeys.push(key);
335
- continue;
336
- }
337
- unresolvedKeys.push(key);
143
+ function unresolvedKeyOf(member) {
144
+ if (member.type !== "ObjectProperty") {
145
+ return "(dynamic)";
338
146
  }
339
- return { integrations, unresolvedKeys };
147
+ return getMemberKeyName(member) ?? "(unknown)";
340
148
  }
341
149
  /**
342
- * Extract integration declarations from an SDK API source file.
343
- *
344
- * Anchors on the exported `api({ ... })` config object and extracts
345
- * integrations from its `integrations` property.
346
- *
347
- * Supports inline declarations:
348
- * `integrations: { db: postgres("uuid") }`
349
- *
350
- * Top-level variable references:
351
- * `const DB = postgres("uuid"); integrations: { db: DB }`
352
- *
353
- * And string variable indirection:
354
- * `const ID = "uuid"; integrations: { db: postgres(ID) }`
355
- *
356
- * Also resolves top-level `export const` declarations and `as const`
357
- * literals in the same file (e.g. `export const ID = "uuid" as const;`) —
358
- * a deliberate, additive improvement over the previous bare-declaration-only
359
- * behavior. This is still single-file scope: only same-file declarations
360
- * (exported or not) are considered, imports are never followed.
361
- *
362
- * Single-file only: does not follow imports, so an integration declared via
363
- * an imported constant or an imported `integrations` object cannot be
364
- * resolved here — it is silently dropped (its key is simply absent from the
365
- * returned array, with no signal that it was seen but unresolved). Callers
366
- * that need imported declarations resolved, or that need to know about
367
- * unresolved keys instead of silently losing them, must use
368
- * {@link extractApiIntegrations} instead.
150
+ * Extracts the integrations a file's default `api()` export declares from the
151
+ * file alone. A `let` or `var` reads as its initializer, since callers use
152
+ * the result to list every integration an API may touch, such as the
153
+ * migration write policy, which must not drop one. A declaration whose ID
154
+ * comes from an import is left out without a trace;
155
+ * {@link extractApiIntegrations} follows imports and reports the keys it
156
+ * cannot resolve.
369
157
  */
370
158
  export function extractIntegrationsFromSource(source) {
371
- let ast;
159
+ let body;
372
160
  try {
373
- ast = parse(source, {
374
- sourceType: "module",
375
- plugins: ["typescript"],
376
- });
161
+ body = parseProgramBody(source, "");
377
162
  }
378
163
  catch {
379
164
  return [];
380
165
  }
381
- return extractFromProgram(ast.program.body, new Map(), "any", "default")
382
- .integrations;
166
+ const module = new SourceModule("", body);
167
+ return new ApiModule(module, new ModuleScope(module, new Map(), "any")).integrationsOf("default").integrations;
383
168
  }
384
- /**
385
- * Single-file only: does not follow imports, so an integration declared via
386
- * an imported constant or an imported `integrations` object cannot be
387
- * resolved here — it is silently dropped (its `id` is simply absent from the
388
- * returned array, with no signal that it was seen but unresolved). Callers
389
- * that need imported declarations resolved, or that need to know about
390
- * unresolved keys instead of silently losing them, must use
391
- * {@link extractApiIntegrations} instead.
392
- */
169
+ /** The IDs {@link extractIntegrationsFromSource} finds, in declaration order. */
393
170
  export function extractIntegrationIdsFromSource(source) {
394
171
  return extractIntegrationsFromSource(source).map((integration) => integration.id);
395
172
  }
396
173
  /**
397
- * Async variant of {@link extractIntegrationsFromSource} that also resolves
398
- * integrations declared via imports from other files, and reports which
399
- * `integrations` object keys could not be resolved to a complete
400
- * `{ key, pluginId, id }` triple.
401
- *
402
- * Import resolution supports one-hop relative imports (e.g., `../lib/integrations.js`).
403
- * For each imported name, resolves it in the imported module via:
404
- * 1. Imported string-literal constants: `export const SHEETS_ID = "sheets-uuid"`
405
- * (including `as const`/type-assertion wrapping and re-exports via
406
- * `export { name }` specifiers).
407
- * 2. Imported integration declarations: `export const jira = restApiIntegration("jira-uuid")`
408
- * including string-literal indirection within the imported module, and
409
- * the same `export { name }` specifier form.
174
+ * Extracts the integrations an SDK API module's `api()` export declares,
175
+ * following relative imports, and reports the `integrations` keys it could
176
+ * not resolve.
410
177
  *
411
- * Non-relative imports (package imports), type-only imports and exports,
412
- * `declare` bindings, re-exports from another module
413
- * (`export { name } from "..."`), and imports that more than one candidate
414
- * file could satisfy are not followed.
178
+ * `exportName` selects the default export when omitted or `"default"`,
179
+ * otherwise a named one: `export const <name> = api({...})`,
180
+ * `export const <name> = someApi`, or `export { someApi as <name> }`.
415
181
  *
416
- * `bindings` defaults to `"any"`, which reads `let` and `var` bindings as
417
- * their initializer. A caller that skips an approval based on the result
418
- * passes `"const-only"`, since a `let` or `var` can be reassigned before
419
- * `api()` reads it.
182
+ * A declaration resolves when its ID is a string literal, or a binding,
183
+ * alias, or integration declaration that leads to one, in the entry file or
184
+ * in a module it reaches within {@link MAX_IMPORT_HOPS} imports or
185
+ * re-exports. Package imports, type-only imports and exports, `declare`
186
+ * bindings, and imports that more than one candidate file could satisfy are
187
+ * not followed. `bindings` defaults to `"any"`; a caller that skips an
188
+ * approval based on the result passes `"const-only"`.
420
189
  *
421
- * `params.exportName` picks which exported `api()` to read: `"default"` (the
422
- * default), or the name of an `export const X = api(...)` or `export { X }`.
423
- *
424
- * `params.entryPoint` MUST be an app-root-relative posix path (e.g.
425
- * `server/apis/get-rows.ts`), never an absolute path or one containing a
426
- * backslash — an entry point that violates this contract skips import
427
- * resolution entirely (see the guard at the top of
428
- * `buildImportedIntegrationRefs`). Within that contract, resolved relative
429
- * import candidates that would escape the app root (e.g. `../../../secrets.ts`)
430
- * are skipped without reading them, but that `..`-prefix skip is only a
431
- * best-effort guard against traversal *relative to entryPoint's own
432
- * directory* — it is not a substitute for real containment enforcement.
433
- * Authoritative containment against the actual filesystem root lives in the
434
- * caller's `readSource` implementation (see `resolveContainedPath` in
435
- * `collect-sdk-apis.mts`), which re-resolves every candidate against the app
436
- * root before touching disk.
190
+ * `entryPoint` must be an app-root-relative posix path such as
191
+ * `server/apis/get-rows.ts`; imports of an absolute or backslashed one are
192
+ * not followed. Candidates above the app root are skipped without being
193
+ * read, but containment is enforced by `readSource`, as
194
+ * `createContainedSourceReader` does for testApi and
195
+ * `resolveContainedRealPath` does for the CLI build manifest.
437
196
  *
438
197
  * `unresolvedKeys` entries are one of:
439
- * - a specific `integrations` object key that could not be resolved
440
- * - `"(unknown)"` for an `ObjectProperty` whose key itself couldn't be read
441
- * (e.g. a computed key)
442
- * - `"(dynamic)"` for a non-`ObjectProperty` member of the integrations
443
- * object (spread elements, methods)
444
- * - `"*"` as a sentinel meaning the config may declare integrations other
445
- * than the ones read: `api({ integrations })` shorthand,
446
- * `api({ integrations: sharedObject })` referencing a non-literal value, a
447
- * spread or computed key in the config, an `integrations` accessor or
448
- * method, a second `integrations` property, or the entry file itself
449
- * failing to parse. `integrations` then lists only the declarations that
450
- * could be read.
198
+ * - an `integrations` key whose declaration could not be resolved
199
+ * - `"(unknown)"` for a declaration whose key is not static
200
+ * - `"(dynamic)"` for a spread or method inside `integrations`
201
+ * - `"*"` when the export may declare integrations other than the ones read:
202
+ * the entry file has no local export by that name, which includes one it
203
+ * re-exports from another module, its value is not an `api({...})` call,
204
+ * its config has a spread, a computed key, an `integrations` accessor or
205
+ * method, a second or non-literal `integrations` property, or the entry
206
+ * file does not parse. `integrations` then lists only the declarations
207
+ * that could be read.
451
208
  */
452
209
  export async function extractApiIntegrations(params) {
453
- let ast;
210
+ let body;
454
211
  try {
455
- ast = parse(params.source, {
456
- sourceType: "module",
457
- plugins: ["typescript"],
458
- });
212
+ body = parseProgramBody(params.source, params.entryPoint);
459
213
  }
460
214
  catch {
461
- // The entry file itself failed to parse (e.g. parser-config drift: a
462
- // real build compiles syntax our @babel/parser config rejects, such as
463
- // decorators or import attributes). Report the "*" sentinel instead of
464
- // silently returning an empty result — this is maximal uncertainty
465
- // about the whole integrations surface, exactly what "*" means below.
466
215
  return { integrations: [], unresolvedKeys: ["*"] };
467
216
  }
468
- const bindings = params.bindings ?? "any";
469
- const importedRefs = await buildImportedIntegrationRefs(ast.program.body, params.entryPoint, params.readSource, bindings);
470
- return extractFromProgram(ast.program.body, importedRefs, bindings, params.exportName ?? "default");
217
+ const exportName = params.exportName ?? "default";
218
+ const entry = new SourceModule(params.entryPoint, body);
219
+ const scope = await new ImportedIntegrationResolver(params.readSource, params.bindings ?? "any").entryScope(entry, (probe) => new ApiModule(entry, probe).integrationsOf(exportName));
220
+ return new ApiModule(entry, scope).integrationsOf(exportName);
221
+ }
222
+ /**
223
+ * Parses a module as TypeScript, and as JSX too when its path is a `.tsx` or
224
+ * `.jsx` file. A `.ts` file cannot also be read as JSX, since `<T>value` is a
225
+ * type assertion there.
226
+ */
227
+ function parseProgramBody(source, path) {
228
+ const plugins = JSX_EXTENSIONS.includes(posixPath.extname(path))
229
+ ? ["typescript", "jsx"]
230
+ : ["typescript"];
231
+ return parse(source, { sourceType: "module", plugins }).program.body;
471
232
  }
233
+ const JSX_EXTENSIONS = [".tsx", ".jsx"];
472
234
  const TS_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
473
235
  const SCRIPT_EXTENSIONS = [...TS_EXTENSIONS, ".js", ".jsx", ".mjs", ".cjs"];
474
236
  const JS_TO_TS_EXTENSIONS = {
@@ -495,185 +257,448 @@ export function resolveRelativeImportPath(fromPath, importPath) {
495
257
  }
496
258
  return SCRIPT_EXTENSIONS.map((ext) => resolved + ext);
497
259
  }
498
- /** A file whose read throws counts as existing, since the bundler may load it. */
499
- async function readCandidate(path, readSource) {
500
- let source;
501
- try {
502
- source = await readSource(path);
260
+ /**
261
+ * One parsed module, addressed by its app-root-relative posix path, and the
262
+ * statements that matter for resolving integrations. Type-only and `declare`
263
+ * statements have no runtime value, so only `explicitExportNames` sees them.
264
+ */
265
+ class SourceModule {
266
+ path;
267
+ body;
268
+ constructor(path, body) {
269
+ this.path = path;
270
+ this.body = body;
271
+ }
272
+ /**
273
+ * The app-root-relative paths an import or re-export source of this module
274
+ * may name, or none when it must not be followed: package imports, and any
275
+ * specifier containing a backslash, which `posixPath.join` would treat as
276
+ * a filename character so the `..`-prefix skip could not catch a traversal
277
+ * spelled with it. Candidates above the app root are dropped unread.
278
+ */
279
+ candidatePathsFor(sourceNode) {
280
+ const specifier = isNode(sourceNode) ? sourceNode.value : undefined;
281
+ if (typeof specifier !== "string" ||
282
+ !specifier.startsWith(".") ||
283
+ specifier.includes("\\")) {
284
+ return [];
285
+ }
286
+ return resolveRelativeImportPath(this.path, specifier).filter((candidate) => !candidate.startsWith(".."));
287
+ }
288
+ variableDeclarators() {
289
+ return this.statements().flatMap(variableDeclaratorsOf);
290
+ }
291
+ /** `import { a, b as c } from "..."` statements. */
292
+ namedImports() {
293
+ return this.references("ImportDeclaration", "ImportSpecifier");
294
+ }
295
+ /**
296
+ * The source and source-side name of an `export { a as name } from "..."`
297
+ * that exports `name`.
298
+ */
299
+ namedReExportOf(name) {
300
+ for (const { source, specifiers } of this.references("ExportNamedDeclaration", "ExportSpecifier")) {
301
+ for (const specifier of specifiers) {
302
+ const localName = getPropertyName(specifier.local);
303
+ if (localName && getPropertyName(specifier.exported) === name) {
304
+ return { source, localName };
305
+ }
306
+ }
307
+ }
308
+ return undefined;
503
309
  }
504
- catch {
505
- return { exists: true };
310
+ /** The sources of `export * from "..."` statements. */
311
+ starReExportSources() {
312
+ return this.statementsOfType("ExportAllDeclaration")
313
+ .filter((statement) => !isTypeOnly(statement))
314
+ .map((statement) => statement.source);
315
+ }
316
+ /**
317
+ * The expression behind each value the module exports from its own scope:
318
+ * `export default <expr>`, the binding of `export const <name>`, and the
319
+ * local of `export { <local> as <name> }`.
320
+ */
321
+ localExports() {
322
+ const exports = new Map();
323
+ for (const statement of this.statementsOfType("ExportDefaultDeclaration")) {
324
+ if (isNode(statement.declaration)) {
325
+ exports.set("default", statement.declaration);
326
+ }
327
+ }
328
+ for (const statement of this.statementsOfType("ExportNamedDeclaration")) {
329
+ if (isNode(statement.source)) {
330
+ continue;
331
+ }
332
+ for (const { declarator } of variableDeclaratorsOf(statement)) {
333
+ const name = getPropertyName(declarator.id);
334
+ if (name && isNode(declarator.id)) {
335
+ exports.set(name, declarator.id);
336
+ }
337
+ }
338
+ for (const specifier of valueSpecifiersOf(statement)) {
339
+ const exportedName = getPropertyName(specifier.exported);
340
+ if (exportedName && isNode(specifier.local)) {
341
+ exports.set(exportedName, specifier.local);
342
+ }
343
+ }
344
+ }
345
+ return exports;
346
+ }
347
+ /**
348
+ * Every name the module exports other than through `export *`, which ESM
349
+ * shadows with them and which never provides `default`. Type-only and
350
+ * `declare` exports count: TypeScript resolves the name to them while the
351
+ * runtime would take a star source's value, so the name stays unresolved.
352
+ */
353
+ explicitExportNames() {
354
+ const names = new Set(["default"]);
355
+ for (const statement of this.statementsOfType("TSImportEqualsDeclaration")) {
356
+ const name = statement.isExport
357
+ ? getPropertyName(statement.id)
358
+ : undefined;
359
+ if (name) {
360
+ names.add(name);
361
+ }
362
+ }
363
+ for (const statement of this.statementsOfType("ExportNamedDeclaration")) {
364
+ for (const name of declaredNames(statement.declaration)) {
365
+ names.add(name);
366
+ }
367
+ for (const specifier of specifiersOf(statement)) {
368
+ const exportedName = getPropertyName(specifier.exported);
369
+ if (exportedName) {
370
+ names.add(exportedName);
371
+ }
372
+ }
373
+ }
374
+ return names;
506
375
  }
507
- if (source === undefined) {
508
- return { exists: false };
376
+ references(statementType, specifierType) {
377
+ return this.statementsOfType(statementType)
378
+ .filter((statement) => isNode(statement.source))
379
+ .map((statement) => ({
380
+ source: statement.source,
381
+ specifiers: valueSpecifiersOf(statement).filter((specifier) => specifier.type === specifierType),
382
+ }))
383
+ .filter(({ specifiers }) => specifiers.length > 0);
509
384
  }
510
- try {
511
- return {
512
- exists: true,
513
- body: parse(source, {
514
- sourceType: "module",
515
- plugins: ["typescript"],
516
- }).program.body,
517
- };
385
+ statementsOfType(type) {
386
+ return this.statements().filter((statement) => statement.type === type);
518
387
  }
519
- catch {
520
- return { exists: true };
388
+ statements() {
389
+ return this.body.filter(isNode);
521
390
  }
522
391
  }
523
392
  /**
524
- * The program body of the file an import loads when exactly one of its
525
- * candidate files exists. With more than one, which the bundler loads depends
526
- * on its resolution order, so the import is left unresolved.
393
+ * What the top-level bindings of one module and the names it imports refer
394
+ * to: string IDs, integration declarations, aliases of either, and `api()`
395
+ * configs.
527
396
  */
528
- async function readUnambiguous(candidatePaths, readSource, cache) {
529
- const existing = [];
530
- for (const candidate of candidatePaths) {
531
- let file = cache.get(candidate);
532
- if (!file) {
533
- file = await readCandidate(candidate, readSource);
534
- cache.set(candidate, file);
535
- }
536
- if (file.exists) {
537
- existing.push(file);
397
+ class ModuleScope {
398
+ importedRefs;
399
+ initializers = new Map();
400
+ constructor(module, importedRefs, bindings) {
401
+ this.importedRefs = importedRefs;
402
+ for (const { kind, declarator } of module.variableDeclarators()) {
403
+ const name = getPropertyName(declarator.id);
404
+ if (name && (bindings === "any" || kind === "const")) {
405
+ this.initializers.set(name, declarator.init);
406
+ }
538
407
  }
539
408
  }
540
- return existing.length === 1 ? existing[0]?.body : undefined;
541
- }
542
- function buildExportedIntegrationRefMap(programBody, bindings) {
543
- const refs = new Map();
544
- const stringLiterals = buildStringLiteralMap(programBody, bindings);
545
- // Resolves specifier-based exports (`const jira = ...; export { jira };`)
546
- // against the module's bare top-level variable declarations.
547
- const variableRefs = buildVariableReferenceMap(programBody, stringLiterals, bindings);
548
- // Resolve `export const x = ...` declarations directly. Filtering to only
549
- // `ExportNamedDeclaration` statements before delegating to the shared
550
- // walker means bare (non-exported) top-level consts are correctly excluded
551
- // here, even though they're visible for same-file indirection above.
552
- const exportedDeclarationStatements = programBody.filter((statement) => isNode(statement) && statement.type === "ExportNamedDeclaration");
553
- visitVariableDeclarations(exportedDeclarationStatements, bindings, (declaration) => {
554
- const identifier = declaration.id;
555
- if (!isNode(identifier) ||
556
- identifier.type !== "Identifier" ||
557
- typeof identifier.name !== "string") {
558
- return;
559
- }
560
- const literal = getLiteralString(declaration.init);
409
+ resolveExpression(node, followedNames = new Set()) {
410
+ const literal = getLiteralString(node);
561
411
  if (literal !== undefined) {
562
- refs.set(identifier.name, { kind: "id", id: literal });
563
- return;
564
- }
565
- const init = declaration.init;
566
- if (isNode(init) &&
567
- init.type === "CallExpression" &&
568
- Array.isArray(init.arguments)) {
569
- const pluginId = getCalleeName(init.callee);
570
- const id = resolveStringArgument(init.arguments[0], stringLiterals);
571
- if (pluginId && id) {
572
- refs.set(identifier.name, { kind: "declaration", pluginId, id });
573
- }
412
+ return { kind: "id", id: literal };
574
413
  }
575
- });
576
- // A specifier of `export { name } from "..."` names a binding of that
577
- // other module, which is not followed, never a same-named local one.
578
- for (const statement of programBody) {
579
- if (!isNode(statement) ||
580
- statement.type !== "ExportNamedDeclaration" ||
581
- isNode(statement.source)) {
582
- continue;
583
- }
584
- for (const specifier of valueSpecifiersOf(statement)) {
585
- if (specifier.type !== "ExportSpecifier") {
586
- continue;
587
- }
588
- const localName = getPropertyName(specifier.local);
589
- const exportedName = getPropertyName(specifier.exported);
590
- if (!localName || !exportedName) {
591
- continue;
414
+ const expression = unwrapExpression(node);
415
+ if (expression?.type === "Identifier" &&
416
+ typeof expression.name === "string") {
417
+ return this.resolveName(expression.name, followedNames);
418
+ }
419
+ if (expression?.type === "CallExpression" &&
420
+ Array.isArray(expression.arguments)) {
421
+ const pluginId = getCalleeName(expression.callee);
422
+ const argument = this.resolveExpression(expression.arguments[0], followedNames);
423
+ return pluginId && argument?.kind === "id"
424
+ ? { kind: "declaration", pluginId, id: argument.id }
425
+ : undefined;
426
+ }
427
+ return undefined;
428
+ }
429
+ resolveDeclaration(node) {
430
+ const ref = this.resolveExpression(node);
431
+ return ref?.kind === "declaration"
432
+ ? { pluginId: ref.pluginId, id: ref.id }
433
+ : undefined;
434
+ }
435
+ /** The config object of the `api({...})` call an expression evaluates to. */
436
+ resolveApiConfig(node, followedNames = new Set()) {
437
+ const expression = unwrapExpression(node);
438
+ if (expression?.type === "Identifier" &&
439
+ typeof expression.name === "string") {
440
+ const name = expression.name;
441
+ if (followedNames.has(name) || !this.initializers.has(name)) {
442
+ return undefined;
592
443
  }
593
- const literal = stringLiterals.get(localName);
594
- if (literal !== undefined) {
595
- refs.set(exportedName, { kind: "id", id: literal });
596
- continue;
444
+ followedNames.add(name);
445
+ return this.resolveApiConfig(this.initializers.get(name), followedNames);
446
+ }
447
+ if (expression?.type !== "CallExpression" ||
448
+ getCalleeName(expression.callee) !== "api" ||
449
+ !Array.isArray(expression.arguments)) {
450
+ return undefined;
451
+ }
452
+ const config = unwrapExpression(expression.arguments[0]);
453
+ return config?.type === "ObjectExpression" ? config : undefined;
454
+ }
455
+ resolveName(name, followedNames) {
456
+ if (!this.initializers.has(name)) {
457
+ return this.importedRefs.get(name);
458
+ }
459
+ if (followedNames.has(name)) {
460
+ return undefined;
461
+ }
462
+ followedNames.add(name);
463
+ return this.resolveExpression(this.initializers.get(name), followedNames);
464
+ }
465
+ }
466
+ /** An API module's `api()` export and the integrations its config declares. */
467
+ class ApiModule {
468
+ module;
469
+ scope;
470
+ constructor(module, scope) {
471
+ this.module = module;
472
+ this.scope = scope;
473
+ }
474
+ integrationsOf(exportName) {
475
+ const exported = this.module.localExports().get(exportName);
476
+ const apiConfig = exported && this.scope.resolveApiConfig(exported);
477
+ if (!apiConfig) {
478
+ return { integrations: [], unresolvedKeys: ["*"] };
479
+ }
480
+ return this.readDeclarations(apiConfig);
481
+ }
482
+ readDeclarations(apiConfig) {
483
+ const { objects, isDefinitive } = readIntegrationsObjects(apiConfig);
484
+ const integrations = [];
485
+ const unresolvedKeys = isDefinitive ? [] : ["*"];
486
+ for (const member of objects.flatMap(membersOf)) {
487
+ const key = member.type === "ObjectProperty" ? getMemberKeyName(member) : undefined;
488
+ const declaration = key === undefined
489
+ ? undefined
490
+ : this.scope.resolveDeclaration(member.value);
491
+ if (key !== undefined && declaration) {
492
+ integrations.push({ key, ...declaration });
597
493
  }
598
- const varRef = variableRefs.get(localName);
599
- if (varRef) {
600
- refs.set(exportedName, {
601
- kind: "declaration",
602
- pluginId: varRef.pluginId,
603
- id: varRef.id,
604
- });
494
+ else {
495
+ unresolvedKeys.push(unresolvedKeyOf(member));
605
496
  }
606
497
  }
498
+ return { integrations, unresolvedKeys };
607
499
  }
608
- return refs;
609
500
  }
610
- async function buildImportedIntegrationRefs(programBody, entryPoint, readSource, bindings) {
611
- const refs = new Map();
612
- // entryPoint is contractually an app-root-relative posix path (see the
613
- // JSDoc on extractApiIntegrations). An absolute path or one containing a
614
- // backslash is out-of-contract input: resolveRelativeImportPath's
615
- // `..`-prefix skip only guards against traversal relative to entryPoint's
616
- // own directory, so a malformed entryPoint (e.g. an absolute path) could
617
- // still let a resolved candidate land outside the app root even though it
618
- // doesn't start with "..". Refuse to resolve any imports at all for such
619
- // input rather than rely on that guard holding — callers that violate the
620
- // contract get unresolved keys instead of a potential traversal.
621
- if (entryPoint.startsWith("/") || entryPoint.includes("\\")) {
501
+ function isSameRef(left, right) {
502
+ const pluginIdOf = (ref) => ref.kind === "declaration" ? ref.pluginId : undefined;
503
+ return (left.kind === right.kind &&
504
+ left.id === right.id &&
505
+ pluginIdOf(left) === pluginIdOf(right));
506
+ }
507
+ /**
508
+ * The most modules an imported name is followed through, counting the module
509
+ * the entry point imports it from as the first.
510
+ */
511
+ const MAX_IMPORT_HOPS = 5;
512
+ /**
513
+ * The most candidate files one call reads, so an app whose modules import
514
+ * widely cannot make one lookup read it whole. Every candidate of an import
515
+ * counts, whether or not it exists. An import that needs more is left
516
+ * unresolved.
517
+ */
518
+ export const MAX_SOURCE_READS = 256;
519
+ /**
520
+ * Resolves the names an API entry point imports, following relative imports
521
+ * and re-exports through at most {@link MAX_IMPORT_HOPS} modules. It follows
522
+ * only the names a lookup reaches: one export of a module at a time, and of
523
+ * that export only the imports its value refers to. One instance serves one
524
+ * entry point: it reads and parses each file at most once, and cuts an
525
+ * import cycle where it closes, leaving the names that depend on the cycle
526
+ * unresolved.
527
+ */
528
+ class ImportedIntegrationResolver {
529
+ readSource;
530
+ bindings;
531
+ files = new Map();
532
+ exportRefs = new Map();
533
+ exportsInProgress = new Set();
534
+ sourceReadsLeft = MAX_SOURCE_READS;
535
+ constructor(readSource, bindings) {
536
+ this.readSource = readSource;
537
+ this.bindings = bindings;
538
+ }
539
+ /** A scope of the entry point with the imports `use` looks up resolved. */
540
+ async entryScope(entry, use) {
541
+ // The `..`-prefix skip only guards against traversal relative to the
542
+ // entry point's own directory, so an absolute or backslashed entry point
543
+ // could still resolve candidates outside the app root.
544
+ if (entry.path.startsWith("/") || entry.path.includes("\\")) {
545
+ return new ModuleScope(entry, new Map(), this.bindings);
546
+ }
547
+ this.files.set(entry.path, { exists: true, module: entry });
548
+ return this.scopeFor(entry, 1, use);
549
+ }
550
+ /**
551
+ * Run `use` once with no imports to find which imported names it reads,
552
+ * then resolve only those. An imported name resolves to an ID or a
553
+ * declaration, never to another name, so the second run reads the same
554
+ * names.
555
+ */
556
+ async scopeFor(module, hop, use) {
557
+ const lookedUp = new Set();
558
+ use(new ModuleScope(module, {
559
+ get: (name) => {
560
+ lookedUp.add(name);
561
+ return undefined;
562
+ },
563
+ }, this.bindings));
564
+ return new ModuleScope(module, await this.resolveImports(module, lookedUp, hop), this.bindings);
565
+ }
566
+ async resolveImports(importer, localNames, hop) {
567
+ const refs = new Map();
568
+ for (const { source, specifiers } of importer.namedImports()) {
569
+ for (const specifier of specifiers) {
570
+ const importedName = getPropertyName(specifier.imported);
571
+ const localName = getPropertyName(specifier.local);
572
+ if (!importedName || !localName || !localNames.has(localName)) {
573
+ continue;
574
+ }
575
+ const ref = await this.exportOfImport(importer, source, importedName, hop);
576
+ if (ref && ref.kind !== "unresolved") {
577
+ refs.set(localName, ref);
578
+ }
579
+ }
580
+ }
622
581
  return refs;
623
582
  }
624
- // Deliberately scoped to this call (one per entry point), not shared/module
625
- // -level: each call to extractApiIntegrations gets its own cache, so
626
- // repeated imports of the same relative path within a single entry point's
627
- // import graph are only read and parsed once, without leaking parsed
628
- // bodies across unrelated entry points or app roots.
629
- const candidateFiles = new Map();
630
- for (const statement of programBody) {
631
- if (!isNode(statement) || statement.type !== "ImportDeclaration") {
632
- continue;
633
- }
634
- const importSource = statement.source;
635
- const importPath = isNode(importSource) ? importSource.value : undefined;
636
- const specifiers = valueSpecifiersOf(statement);
637
- if (typeof importPath !== "string" ||
638
- !importPath.startsWith(".") ||
639
- specifiers.length === 0) {
640
- continue;
641
- }
642
- // Real ESM/TS import specifiers always use forward slashes, and no
643
- // bundler resolves a backslash as a path separator either — a backslash
644
- // here only ever comes from hostile or broken input (e.g.
645
- // `..\\..\\..\\secret.js`). `posixPath.join` treats `\` as an ordinary
646
- // filename character rather than a separator, so the `..`-prefix guard
647
- // below cannot catch a traversal spelled with backslashes. Treat the
648
- // specifier as unresolvable, the same as a bare package import, and
649
- // never attempt to read it.
650
- if (importPath.includes("\\")) {
651
- continue;
652
- }
653
- // Skip candidates that resolve outside the app root (e.g.
654
- // `../../../secrets.ts` escaping above the entry point's directory) —
655
- // never read files outside the app being built.
656
- const candidatePaths = resolveRelativeImportPath(entryPoint, importPath).filter((candidate) => !candidate.startsWith(".."));
657
- if (candidatePaths.length === 0) {
658
- continue;
659
- }
660
- const importedBody = await readUnambiguous(candidatePaths, readSource, candidateFiles);
661
- if (!importedBody) {
662
- continue;
663
- }
664
- const exportedRefs = buildExportedIntegrationRefMap(importedBody, bindings);
665
- for (const specifier of specifiers) {
666
- if (specifier.type !== "ImportSpecifier") {
667
- continue;
583
+ async exportOfImport(importer, sourceNode, name, hop) {
584
+ if (hop > MAX_IMPORT_HOPS) {
585
+ return UNRESOLVED_EXPORT;
586
+ }
587
+ const imported = await this.readUnambiguous(importer.candidatePathsFor(sourceNode));
588
+ return imported ? this.exportOf(imported, name, hop) : UNRESOLVED_EXPORT;
589
+ }
590
+ async exportOf(module, name, hop) {
591
+ const exportKey = JSON.stringify([module.path, name]);
592
+ if (this.exportsInProgress.has(exportKey)) {
593
+ return UNRESOLVED_EXPORT;
594
+ }
595
+ const cacheKey = JSON.stringify([hop, module.path, name]);
596
+ if (this.exportRefs.has(cacheKey)) {
597
+ return this.exportRefs.get(cacheKey);
598
+ }
599
+ this.exportsInProgress.add(exportKey);
600
+ try {
601
+ const ref = await this.resolveExport(module, name, hop);
602
+ if (ref?.kind !== "unresolved") {
603
+ this.exportRefs.set(cacheKey, ref);
668
604
  }
669
- const importedName = getPropertyName(specifier.imported);
670
- const localName = getPropertyName(specifier.local);
671
- const ref = importedName ? exportedRefs.get(importedName) : undefined;
672
- if (localName && ref) {
673
- refs.set(localName, ref);
605
+ return ref;
606
+ }
607
+ finally {
608
+ this.exportsInProgress.delete(exportKey);
609
+ }
610
+ }
611
+ /**
612
+ * What `module` exports as `name`. A name the module exports explicitly,
613
+ * even as a type, a `declare`, or a namespace, shadows `export *`.
614
+ */
615
+ async resolveExport(module, name, hop) {
616
+ const local = module.localExports().get(name);
617
+ if (local) {
618
+ const scope = await this.scopeFor(module, hop + 1, (probe) => probe.resolveExpression(local));
619
+ return scope.resolveExpression(local) ?? UNRESOLVED_EXPORT;
620
+ }
621
+ const reExport = module.namedReExportOf(name);
622
+ if (reExport) {
623
+ return ((await this.exportOfImport(module, reExport.source, reExport.localName, hop + 1)) ?? UNRESOLVED_EXPORT);
624
+ }
625
+ return module.explicitExportNames().has(name)
626
+ ? UNRESOLVED_EXPORT
627
+ : this.starExportOf(module, name, hop);
628
+ }
629
+ /**
630
+ * What the `export *` sources of `module` provide as `name`, when they
631
+ * agree. A name two sources disagree on is ambiguous in ESM.
632
+ */
633
+ async starExportOf(module, name, hop) {
634
+ const refs = [];
635
+ for (const sourceNode of module.starReExportSources()) {
636
+ const ref = await this.exportOfImport(module, sourceNode, name, hop + 1);
637
+ if (ref?.kind === "unresolved") {
638
+ return UNRESOLVED_EXPORT;
639
+ }
640
+ if (ref) {
641
+ refs.push(ref);
642
+ }
643
+ }
644
+ const [first] = refs;
645
+ if (first && refs.some((ref) => !isSameRef(ref, first))) {
646
+ return UNRESOLVED_EXPORT;
647
+ }
648
+ return first;
649
+ }
650
+ /**
651
+ * The module a specifier loads when exactly one of its candidate files
652
+ * exists. With more than one, which the bundler loads depends on its
653
+ * resolution order, so the import is left unresolved.
654
+ */
655
+ async readUnambiguous(candidatePaths) {
656
+ const existing = [];
657
+ for (const path of candidatePaths) {
658
+ const file = await this.read(path);
659
+ if (file.exists) {
660
+ existing.push(file);
674
661
  }
675
662
  }
663
+ return existing.length === 1 ? existing[0]?.module : undefined;
664
+ }
665
+ async read(path) {
666
+ const cached = this.files.get(path);
667
+ if (cached) {
668
+ return cached;
669
+ }
670
+ const file = await this.readAndParse(path);
671
+ this.files.set(path, file);
672
+ return file;
673
+ }
674
+ /**
675
+ * A file whose read throws counts as existing, since the bundler may load
676
+ * it, and so does one past {@link MAX_SOURCE_READS}, which is not read.
677
+ */
678
+ async readAndParse(path) {
679
+ if (this.sourceReadsLeft === 0) {
680
+ return { exists: true };
681
+ }
682
+ this.sourceReadsLeft -= 1;
683
+ let source;
684
+ try {
685
+ source = await this.readSource(path);
686
+ }
687
+ catch {
688
+ return { exists: true };
689
+ }
690
+ if (source === undefined) {
691
+ return { exists: false };
692
+ }
693
+ try {
694
+ return {
695
+ exists: true,
696
+ module: new SourceModule(path, parseProgramBody(source, path)),
697
+ };
698
+ }
699
+ catch {
700
+ return { exists: true };
701
+ }
676
702
  }
677
- return refs;
678
703
  }
679
704
  //# sourceMappingURL=extract-api-integrations.js.map