@jini-ai/agent-plugins 0.6.17 → 0.6.22

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 (347) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/NOTICE +14 -0
  3. package/README.md +35 -14
  4. package/charts-echarts/plugin.json +39 -0
  5. package/charts-echarts/skills/charts-echarts/SKILL.md +110 -0
  6. package/charts-recharts/plugin.json +32 -0
  7. package/charts-recharts/skills/charts-recharts/SKILL.md +108 -0
  8. package/cloudflare/NOTES.md +16 -0
  9. package/cloudflare/form-destinations/cloudflare-d1.mjs +9 -0
  10. package/cloudflare/lib/api.mjs +96 -0
  11. package/cloudflare/lib/assets.mjs +65 -0
  12. package/cloudflare/lib/dns.mjs +32 -0
  13. package/cloudflare/lib/domain-inventory.mjs +61 -0
  14. package/cloudflare/lib/domain-status.mjs +48 -0
  15. package/cloudflare/lib/domains.mjs +95 -0
  16. package/cloudflare/lib/forms.mjs +278 -0
  17. package/cloudflare/lib/pages-upload.mjs +51 -0
  18. package/cloudflare/lib/target.mjs +165 -0
  19. package/cloudflare/lib/workers-upload.mjs +48 -0
  20. package/cloudflare/lib/zones.mjs +25 -0
  21. package/cloudflare/mcp.json +4 -0
  22. package/cloudflare/plugin.json +96 -0
  23. package/cloudflare/skills/cloudflare/SKILL.md +57 -0
  24. package/cloudflare/skills/cloudflare/references/domains.md +31 -0
  25. package/cloudflare/skills/cloudflare/references/pages.md +18 -0
  26. package/cloudflare/skills/cloudflare/references/permissions.md +29 -0
  27. package/cloudflare/skills/cloudflare/references/troubleshooting.md +20 -0
  28. package/cloudflare/skills/cloudflare/references/workers.md +42 -0
  29. package/cloudflare/targets/cloudflare-pages.mjs +12 -0
  30. package/cloudflare/targets/cloudflare-workers.mjs +17 -0
  31. package/cloudflare/tovu-consent.json +6 -0
  32. package/cloudflare/tovu-deploy-targets.json +630 -0
  33. package/cloudflare/tovu-form-destinations.json +12 -0
  34. package/cloudflare/worker/forms-receiver.mjs +285 -0
  35. package/composio/mcp.json +10 -0
  36. package/composio/plugin.json +68 -0
  37. package/composio/skills/composio/SKILL.md +85 -0
  38. package/dist/core/identity-namespace.d.ts +12 -0
  39. package/dist/core/identity-namespace.js +20 -0
  40. package/dist/folder-zip-node.js +29 -7
  41. package/dist/lifecycle/activation-reader.d.ts +24 -0
  42. package/dist/lifecycle/activation-reader.js +27 -0
  43. package/dist/lifecycle/automatic-use.js +14 -2
  44. package/dist/lifecycle/bundled-digests.js +4 -3
  45. package/dist/lifecycle/bundled-file-policy.d.ts +22 -0
  46. package/dist/lifecycle/bundled-file-policy.js +19 -0
  47. package/dist/lifecycle/enable-grants.d.ts +26 -0
  48. package/dist/lifecycle/enable-grants.js +28 -0
  49. package/dist/lifecycle/index.d.ts +4 -0
  50. package/dist/lifecycle/index.js +4 -0
  51. package/dist/lifecycle/install.d.ts +7 -0
  52. package/dist/lifecycle/install.js +45 -3
  53. package/dist/lifecycle/manifest.d.ts +2 -2
  54. package/dist/lifecycle/manifest.js +5 -3
  55. package/dist/lifecycle/node.js +2 -0
  56. package/dist/lifecycle/persistent-state.js +1 -1
  57. package/dist/lifecycle/ports.d.ts +8 -0
  58. package/dist/lifecycle/search-projection.d.ts +8 -0
  59. package/dist/lifecycle/search-projection.js +23 -5
  60. package/dist/lifecycle/search.js +7 -2
  61. package/dist/lifecycle/seed-bundled.js +4 -1
  62. package/dist/manifest.d.ts +1 -1
  63. package/dist/manifest.js +3 -2
  64. package/fly/deploy-configs/fly.mjs +115 -0
  65. package/fly/deploy-ops/fly.mjs +102 -0
  66. package/fly/mcp.json +4 -0
  67. package/fly/plugin.json +81 -0
  68. package/fly/scripts/render-deploy-workflow.mjs +150 -0
  69. package/fly/skills/fly/SKILL.md +43 -0
  70. package/fly/skills/fly/references/fly-deploy.template.yml +117 -0
  71. package/fly/skills/fly/references/fly.template.toml +81 -0
  72. package/fly/tovu-credential-schemes.json +11 -0
  73. package/fly/tovu-deploy-configs.json +21 -0
  74. package/fly/tovu-deploy-ops.json +14 -0
  75. package/github/deploy-ops/github-actions.mjs +164 -0
  76. package/github/deployments/github.mjs +415 -0
  77. package/github/mcp.json +4 -0
  78. package/github/plugin.json +105 -0
  79. package/github/skills/github/SKILL.md +249 -0
  80. package/github/skills/github/references/actions.md +224 -0
  81. package/github/skills/github/references/auth-and-tokens.md +140 -0
  82. package/github/skills/github/references/repo-files.md +135 -0
  83. package/github/skills/github/references/site-backup.md +159 -0
  84. package/github/skills/github/references/source-control.md +123 -0
  85. package/github/source-control/backup-push.mjs +242 -0
  86. package/github/source-control/commit-site.mjs +459 -0
  87. package/github/source-control/github.mjs +93 -0
  88. package/github/source-control/write-files.mjs +468 -0
  89. package/github/tovu-deploy-ops.json +13 -0
  90. package/github/tovu-source-control.json +117 -0
  91. package/github-pages/NOTES.md +19 -0
  92. package/github-pages/mcp.json +4 -0
  93. package/github-pages/plugin.json +48 -0
  94. package/github-pages/skills/github-pages/SKILL.md +44 -0
  95. package/github-pages/targets/github-pages.mjs +543 -0
  96. package/github-pages/tovu-deploy-targets.json +327 -0
  97. package/google-login/exports/google-g.svg +1 -0
  98. package/google-login/exports/sign-in-button.css +68 -0
  99. package/google-login/exports/sign-in-button.html +4 -0
  100. package/google-login/mcp.json +4 -0
  101. package/google-login/plugin.json +59 -0
  102. package/google-login/skills/google-login/SKILL.md +96 -0
  103. package/google-login/tovu-login-providers.json +21 -0
  104. package/google-workspace/README.md +132 -0
  105. package/google-workspace/form-destinations/README.md +87 -0
  106. package/google-workspace/form-destinations/dedupe.mjs +43 -0
  107. package/google-workspace/form-destinations/delivery-result.mjs +69 -0
  108. package/google-workspace/form-destinations/mapping.mjs +152 -0
  109. package/google-workspace/form-destinations/sheets.mjs +202 -0
  110. package/google-workspace/lib/auth.mjs +81 -0
  111. package/google-workspace/lib/drive-files.mjs +54 -0
  112. package/google-workspace/lib/form-destination-settings.mjs +72 -0
  113. package/google-workspace/lib/http.mjs +168 -0
  114. package/google-workspace/lib/picker-flow.mjs +171 -0
  115. package/google-workspace/lib/picker-selection.mjs +107 -0
  116. package/google-workspace/lib/product-state.mjs +93 -0
  117. package/google-workspace/lib/request-policy.mjs +163 -0
  118. package/google-workspace/lib/sheets-a1.mjs +79 -0
  119. package/google-workspace/lib/sheets-admin-csv.mjs +82 -0
  120. package/google-workspace/lib/sheets-admin-request-kinds.mjs +183 -0
  121. package/google-workspace/lib/sheets-client.mjs +286 -0
  122. package/google-workspace/lib/surface-actions.mjs +107 -0
  123. package/google-workspace/mcp.json +4 -0
  124. package/google-workspace/plugin.json +77 -0
  125. package/google-workspace/products.json +12 -0
  126. package/google-workspace/skills/google-workspace/SKILL.md +82 -0
  127. package/google-workspace/skills/google-workspace/references/connection.md +102 -0
  128. package/google-workspace/skills/google-workspace/references/form-delivery.md +50 -0
  129. package/google-workspace/skills/google-workspace/references/sheets.md +149 -0
  130. package/google-workspace/skills/google-workspace/references/troubleshooting.md +31 -0
  131. package/google-workspace/tools/account-info.mjs +18 -0
  132. package/google-workspace/tools/sheets/README.md +54 -0
  133. package/google-workspace/tools/sheets/copy-tab.mjs +23 -0
  134. package/google-workspace/tools/sheets/copy.mjs +23 -0
  135. package/google-workspace/tools/sheets/create.mjs +35 -0
  136. package/google-workspace/tools/sheets/find-replace.mjs +38 -0
  137. package/google-workspace/tools/sheets/find.mjs +52 -0
  138. package/google-workspace/tools/sheets/get-by-data-filter.mjs +23 -0
  139. package/google-workspace/tools/sheets/get.mjs +22 -0
  140. package/google-workspace/tools/sheets/values-append.mjs +27 -0
  141. package/google-workspace/tools/sheets/values-batch-clear.mjs +20 -0
  142. package/google-workspace/tools/sheets/values-batch-get.mjs +20 -0
  143. package/google-workspace/tools/sheets/values-batch-update.mjs +29 -0
  144. package/google-workspace/tools/sheets/values-by-data-filter.mjs +62 -0
  145. package/google-workspace/tools/sheets/values-clear.mjs +20 -0
  146. package/google-workspace/tools/sheets/values-get.mjs +21 -0
  147. package/google-workspace/tools/sheets/values-update.mjs +26 -0
  148. package/google-workspace/tools/sheets-admin/README.md +45 -0
  149. package/google-workspace/tools/sheets-admin/basic-filter.mjs +32 -0
  150. package/google-workspace/tools/sheets-admin/batch-update.mjs +25 -0
  151. package/google-workspace/tools/sheets-admin/developer-metadata.mjs +28 -0
  152. package/google-workspace/tools/sheets-admin/export-csv.mjs +67 -0
  153. package/google-workspace/tools/sheets-admin/filter-views.mjs +38 -0
  154. package/google-workspace/tools/sheets-admin/format.mjs +70 -0
  155. package/google-workspace/tools/sheets-admin/named-ranges.mjs +42 -0
  156. package/google-workspace/tools/sheets-admin/open-existing.mjs +34 -0
  157. package/google-workspace/tools/sheets-admin/protected-ranges-get.mjs +18 -0
  158. package/google-workspace/tools/sheets-admin/sort.mjs +18 -0
  159. package/google-workspace/tools/sheets-admin/tab-modify.mjs +36 -0
  160. package/google-workspace/tovu-admin-surfaces.json +63 -0
  161. package/google-workspace/tovu-agent-tools.json +1178 -0
  162. package/google-workspace/tovu-connections.json +35 -0
  163. package/google-workspace/tovu-form-destinations.json +10 -0
  164. package/google-workspace/ui/README.md +73 -0
  165. package/google-workspace/ui/connection-panel.handler.mjs +167 -0
  166. package/google-workspace/ui/connection-panel.html +17 -0
  167. package/google-workspace/ui/connection-panel.mjs +189 -0
  168. package/google-workspace/ui/connection-view.mjs +120 -0
  169. package/google-workspace/ui/destination-panel.handler.mjs +106 -0
  170. package/google-workspace/ui/destination-panel.html +17 -0
  171. package/google-workspace/ui/destination-panel.mjs +150 -0
  172. package/google-workspace/ui/dom.mjs +140 -0
  173. package/google-workspace/ui/panel.css +170 -0
  174. package/google-workspace/ui/picker-flow.mjs +87 -0
  175. package/google-workspace/ui/picker-view.mjs +44 -0
  176. package/google-workspace/ui/picker.handler.mjs +56 -0
  177. package/google-workspace/ui/picker.html +17 -0
  178. package/google-workspace/ui/picker.mjs +88 -0
  179. package/google-workspace/ui/surface-client.mjs +227 -0
  180. package/higgsfield-media/mcp.json +9 -0
  181. package/higgsfield-media/plugin.json +109 -0
  182. package/higgsfield-media/skills/higgsfield-media/SKILL.md +325 -0
  183. package/higgsfield-media/skills/higgsfield-media/references/failure-modes.md +116 -0
  184. package/higgsfield-media/skills/higgsfield-media/references/models-and-plan-gates.md +142 -0
  185. package/jev/mcp.json +4 -0
  186. package/jev/plugin.json +44 -0
  187. package/jev/skills/jev/SKILL.md +308 -0
  188. package/jev/skills/jev/references/cookbooks.md +197 -0
  189. package/jev/skills/jev/references/jaggedness.md +135 -0
  190. package/jev/skills/jev/references/javascript-sdk.md +146 -0
  191. package/jev/skills/jev/references/patterns.md +123 -0
  192. package/jev/skills/jev/references/primitives-reference.md +187 -0
  193. package/langfuse/plugin.json +22 -0
  194. package/meilisearch/mcp.json +4 -0
  195. package/meilisearch/plugin.json +54 -0
  196. package/meilisearch/providers/meilisearch.mjs +651 -0
  197. package/meilisearch/skills/meilisearch/SKILL.md +43 -0
  198. package/meilisearch/tovu-search-providers.json +10 -0
  199. package/netlify/NOTES.md +13 -0
  200. package/netlify/mcp.json +4 -0
  201. package/netlify/plugin.json +47 -0
  202. package/netlify/skills/netlify/SKILL.md +39 -0
  203. package/netlify/targets/netlify.mjs +384 -0
  204. package/netlify/tovu-consent.json +6 -0
  205. package/netlify/tovu-deploy-targets.json +163 -0
  206. package/opentelemetry/mcp.json +4 -0
  207. package/opentelemetry/plugin.json +52 -0
  208. package/opentelemetry/skills/opentelemetry/SKILL.md +39 -0
  209. package/package.json +161 -6
  210. package/posthog/mcp.json +4 -0
  211. package/posthog/plugin.json +46 -0
  212. package/posthog/skills/posthog/SKILL.md +36 -0
  213. package/railway/deploy-configs/railway.mjs +135 -0
  214. package/railway/deploy-ops/railway.mjs +167 -0
  215. package/railway/mcp.json +4 -0
  216. package/railway/plugin.json +45 -0
  217. package/railway/skills/railway/SKILL.md +66 -0
  218. package/railway/tovu-deploy-configs.json +16 -0
  219. package/railway/tovu-deploy-ops.json +11 -0
  220. package/render/deploy-configs/render.mjs +141 -0
  221. package/render/deploy-ops/render.mjs +152 -0
  222. package/render/mcp.json +4 -0
  223. package/render/plugin.json +47 -0
  224. package/render/skills/render/SKILL.md +63 -0
  225. package/render/tovu-deploy-configs.json +16 -0
  226. package/render/tovu-deploy-ops.json +11 -0
  227. package/resend/NOTES.md +52 -0
  228. package/resend/adapters/resend.mjs +161 -0
  229. package/resend/lib/domains.mjs +137 -0
  230. package/resend/lib/errors.mjs +25 -0
  231. package/resend/lib/feedback.mjs +118 -0
  232. package/resend/mcp.json +13 -0
  233. package/resend/plugin.json +192 -0
  234. package/resend/skills/resend/SKILL.md +107 -0
  235. package/resend/tovu-mail-adapters.json +22 -0
  236. package/s3-compatible/NOTES.md +11 -0
  237. package/s3-compatible/mcp.json +4 -0
  238. package/s3-compatible/object-stores/s3-compatible.mjs +287 -0
  239. package/s3-compatible/plugin.json +56 -0
  240. package/s3-compatible/skills/s3-compatible/SKILL.md +39 -0
  241. package/s3-compatible/targets/s3-compatible.mjs +1054 -0
  242. package/s3-compatible/tovu-deploy-targets.json +432 -0
  243. package/s3-compatible/tovu-object-stores.json +29 -0
  244. package/sentry/mcp.json +4 -0
  245. package/sentry/plugin.json +49 -0
  246. package/sentry/skills/sentry/SKILL.md +34 -0
  247. package/shopify/mcp.json +4 -0
  248. package/shopify/plugin.json +22 -0
  249. package/shopify/skills/shopify/SKILL.md +103 -0
  250. package/shopify/skills/shopify/references/catalog-sync.md +74 -0
  251. package/shopify/skills/shopify/references/domains.md +26 -0
  252. package/shopify/skills/shopify/references/live-storefront.md +34 -0
  253. package/shopify/skills/shopify/references/storefront-snippets.md +21 -0
  254. package/site-compliance/mcp.json +4 -0
  255. package/site-compliance/plugin.json +34 -0
  256. package/site-compliance/skills/site-compliance/SKILL.md +220 -0
  257. package/site-compliance/skills/site-compliance/references/ccpa-cpra.md +115 -0
  258. package/site-compliance/skills/site-compliance/references/gdpr-eu-uk.md +143 -0
  259. package/site-compliance/skills/site-compliance/references/wcag-2-2.md +129 -0
  260. package/site-import/mcp.json +4 -0
  261. package/site-import/plugin.json +41 -0
  262. package/site-import/skills/site-import/SKILL.md +232 -0
  263. package/site-import/skills/site-import/references/content-mapping.md +166 -0
  264. package/site-import/skills/site-import/references/discovery-and-classification.md +117 -0
  265. package/site-import/skills/site-import/references/theme-extraction.md +34 -0
  266. package/slide-design/com.anthropic.claude-code/hooks/hooks.json +4 -0
  267. package/slide-design/mcp.json +4 -0
  268. package/slide-design/plugin.json +26 -0
  269. package/slide-design/skills/slide-design/SKILL.md +103 -0
  270. package/slide-design/skills/slide-design/references/charts-and-exhibits.md +100 -0
  271. package/slide-design/skills/slide-design/references/html-deck.md +175 -0
  272. package/slide-design/skills/slide-design/references/layout-and-style.md +131 -0
  273. package/slide-design/skills/slide-design/references/review.md +93 -0
  274. package/slide-design/skills/slide-design/references/storyline.md +118 -0
  275. package/stripe/plugin.json +22 -0
  276. package/supabase/mcp.json +26 -0
  277. package/supabase/plugin.json +78 -0
  278. package/supabase/skills/supabase/SKILL.md +169 -0
  279. package/supabase/skills/supabase/references/failure-modes.md +101 -0
  280. package/ui-ux-design/CHANGELOG.md +28 -0
  281. package/ui-ux-design/LICENSE +201 -0
  282. package/ui-ux-design/NOTICE +14 -0
  283. package/ui-ux-design/README.md +62 -0
  284. package/ui-ux-design/com.anthropic.claude-code/hooks/hooks.json +4 -0
  285. package/ui-ux-design/mcp.json +4 -0
  286. package/ui-ux-design/plugin.json +26 -0
  287. package/ui-ux-design/skills/frontend-accessibility/SKILL.md +60 -0
  288. package/ui-ux-design/skills/gstack-design/SKILL.md +53 -0
  289. package/ui-ux-design/skills/gstack-design/references/consultation.md +30 -0
  290. package/ui-ux-design/skills/gstack-design/references/html.md +29 -0
  291. package/ui-ux-design/skills/gstack-design/references/review.md +28 -0
  292. package/ui-ux-design/skills/gstack-design/references/shotgun.md +33 -0
  293. package/ui-ux-design/skills/gstack-design/references/upstream-notes.md +23 -0
  294. package/ui-ux-design/skills/interface-design/ORIGINAL.md +16 -0
  295. package/ui-ux-design/skills/interface-design/SKILL.md +41 -0
  296. package/ui-ux-design/skills/interface-design/references/commands/audit.md +40 -0
  297. package/ui-ux-design/skills/interface-design/references/commands/critique.md +21 -0
  298. package/ui-ux-design/skills/interface-design/references/commands/extract.md +34 -0
  299. package/ui-ux-design/skills/interface-design/references/commands/init.md +31 -0
  300. package/ui-ux-design/skills/interface-design/references/commands/status.md +22 -0
  301. package/ui-ux-design/skills/interface-design/references/examples/system-precision.md +29 -0
  302. package/ui-ux-design/skills/interface-design/references/examples/system-warmth.md +29 -0
  303. package/ui-ux-design/skills/interface-design/references/system-template.md +57 -0
  304. package/ui-ux-design/skills/shadcn-ui/README.md +244 -0
  305. package/ui-ux-design/skills/shadcn-ui/SKILL.md +333 -0
  306. package/ui-ux-design/skills/shadcn-ui/examples/auth-layout.tsx +177 -0
  307. package/ui-ux-design/skills/shadcn-ui/examples/data-table.tsx +313 -0
  308. package/ui-ux-design/skills/shadcn-ui/examples/form-pattern.tsx +177 -0
  309. package/ui-ux-design/skills/shadcn-ui/resources/component-catalog.md +481 -0
  310. package/ui-ux-design/skills/shadcn-ui/resources/customization-guide.md +516 -0
  311. package/ui-ux-design/skills/shadcn-ui/resources/migration-guide.md +463 -0
  312. package/ui-ux-design/skills/shadcn-ui/resources/setup-guide.md +412 -0
  313. package/ui-ux-design/skills/shadcn-ui/scripts/verify-setup.sh +134 -0
  314. package/ui-ux-design/skills/ui-ux-design/SKILL.md +171 -0
  315. package/ui-ux-design/skills/ui-ux-design/references/brand-and-voice.md +78 -0
  316. package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +137 -0
  317. package/ui-ux-design/skills/ui-ux-design/references/components-and-states.md +112 -0
  318. package/ui-ux-design/skills/ui-ux-design/references/delight-and-motion.md +54 -0
  319. package/ui-ux-design/skills/ui-ux-design/references/foundations.md +145 -0
  320. package/ui-ux-design/skills/ui-ux-design/references/inclusive-ai-imagery.md +57 -0
  321. package/ui-ux-design/skills/ui-ux-design/references/kole-jain-uiux-concepts.md +104 -0
  322. package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +184 -0
  323. package/ui-ux-design/skills/ui-ux-design/references/openai-frontend-skill.md +139 -0
  324. package/ui-ux-design/skills/ui-ux-design/references/premium-ui.md +55 -0
  325. package/ui-ux-design/skills/ui-ux-design/references/research-and-validation.md +88 -0
  326. package/ui-ux-design/skills/ui-ux-design/references/sam-crawford-premium-websites.md +103 -0
  327. package/ui-ux-design/skills/ui-ux-design/references/self-made-web-designer-core-skills.md +119 -0
  328. package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +173 -0
  329. package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +234 -0
  330. package/ui-ux-design/skills/ui-ux-design/references/visual-storytelling.md +54 -0
  331. package/ui-ux-design/skills/vercel-web-design-guidelines/SKILL.md +39 -0
  332. package/ui-ux-design/skills/web-compliance/SKILL.md +134 -0
  333. package/ui-ux-design/skills/web-compliance/references/audit-evidence.md +59 -0
  334. package/vercel/NOTES.md +23 -0
  335. package/vercel/mcp.json +4 -0
  336. package/vercel/object-stores/vercel-blob.mjs +147 -0
  337. package/vercel/plugin.json +47 -0
  338. package/vercel/skills/vercel/SKILL.md +48 -0
  339. package/vercel/targets/vercel.mjs +644 -0
  340. package/vercel/tovu-consent.json +6 -0
  341. package/vercel/tovu-deploy-targets.json +219 -0
  342. package/vercel/tovu-object-stores.json +10 -0
  343. package/wordpress/NOTES.md +33 -0
  344. package/wordpress/plugin.json +30 -0
  345. package/wordpress/skills/wordpress/SKILL.md +43 -0
  346. package/wordpress/skills/wordpress/references/free-site-redirect.md +46 -0
  347. package/wordpress/skills/wordpress/references/subdomain.md +66 -0
@@ -0,0 +1,644 @@
1
+ /**
2
+ * @file Vercel deploy target of the `vercel` Agent Plugin.
3
+ *
4
+ * Ported from `@jini-ai/devops` `src/deploy/vercel.ts` at Jini commit 28f67f9a: the body of
5
+ * {@link bindVercel} is that source with its TypeScript types stripped, same Vercel calls, error texts,
6
+ * redirect guard and Deployment Protection detector (`isVercelProtectedResponse`). Changes:
7
+ *
8
+ * - Network, timeouts, poll delay, reachability, naming, the redirect guard and `DeployError` come
9
+ * from the host kit the host injects (see {@link bindVercel}),
10
+ * bound once per target by {@link bindVercel}: an installed plugin has no npm dependencies.
11
+ * - `responseHeaders` (the host's security header set) is rendered into a root `vercel.json` here,
12
+ * which the first host (Tovu) used to add in its core.
13
+ * - Files are uploaded one per request to `POST /v2/files` (by SHA-1) and the deployment references
14
+ * them as `{ file, sha, size }`, the way Vercel's CLI does (2026-10-11). The devops source sent every
15
+ * file inline, base64, in the one `/v13/deployments` body, which Vercel refuses past 10 MB
16
+ * ("Request body too large"): any real site with photos.
17
+ *
18
+ * Plain JS by owner decision (2026-09-29).
19
+ */
20
+
21
+ import { createHash, randomInt } from "node:crypto";
22
+
23
+ export const VERCEL_TARGET_ID = "vercel";
24
+
25
+ /** `/v2/files` uploads in flight at once per publish: a few hundred files finish in reasonable time
26
+ * without tripping Vercel's rate limit. */
27
+ const VERCEL_UPLOAD_CONCURRENCY = 5;
28
+ /** Tries per file upload; a 429, a 5xx or a dropped connection is retried, anything else fails the
29
+ * publish at once. */
30
+ const VERCEL_UPLOAD_ATTEMPTS = 3;
31
+
32
+ /** The root file Vercel reads response-header rules from. */
33
+ const VERCEL_CONFIG_FILE = "vercel.json";
34
+
35
+ /**
36
+ * Renders a header set as a `vercel.json` with one catch-all header rule. Byte-identical to what
37
+ * the first host (Tovu) rendered in its core before this moved here.
38
+ *
39
+ * @param {Readonly<Record<string, string>>} headers
40
+ * @returns {string}
41
+ */
42
+ function renderVercelConfig(headers) {
43
+ const rule = { source: "/(.*)", headers: Object.entries(headers).map(([key, value]) => ({ key, value })) };
44
+ return `${JSON.stringify({ headers: [rule] }, null, 2)}\n`;
45
+ }
46
+
47
+ /**
48
+ * The file set actually deployed: `files`, plus a root `vercel.json` rendered from
49
+ * `responseHeaders`, which REPLACES a site-supplied one (the header set is the host's policy).
50
+ *
51
+ * @param {Array<{ file: string, data: string | Uint8Array, contentType?: string }>} files
52
+ * @param {Readonly<Record<string, string>> | undefined} responseHeaders
53
+ */
54
+ function withVercelConfigFile(files, responseHeaders) {
55
+ if (!responseHeaders || Object.keys(responseHeaders).length === 0) return files;
56
+ return [...files.filter((file) => file.file !== VERCEL_CONFIG_FILE), { file: VERCEL_CONFIG_FILE, data: renderVercelConfig(responseHeaders) }];
57
+ }
58
+
59
+ /**
60
+ * Content-addresses a file set for Vercel: the deployment's `files` entries (`{ file, sha, size }`,
61
+ * no data) and one upload body per distinct SHA-1, so identical files upload once.
62
+ *
63
+ * @param {Array<{ file: string, data: string | Uint8Array }>} files
64
+ * @returns {{ refs: Array<{ file: string, sha: string, size: number }>, blobs: Map<string, Buffer> }}
65
+ */
66
+ function vercelFileManifest(files) {
67
+ const blobs = new Map();
68
+ const refs = files.map((f) => {
69
+ const data = Buffer.from(f.data);
70
+ // Vercel requires SHA-1 in file references and x-vercel-digest upload headers.
71
+ // This is a wire-format requirement; substituting SHA-256 would break uploads.
72
+ const sha = createHash("sha1").update(data).digest("hex");
73
+ blobs.set(sha, data);
74
+ return { file: f.file, sha, size: data.length };
75
+ });
76
+ return { refs, blobs };
77
+ }
78
+
79
+ /**
80
+ * Binds the ported Vercel code to one host kit.
81
+ *
82
+ * @param {{ fetch(url: string, init: RequestInit, options: { timeoutMs: number }): Promise<Response>,
83
+ * timeouts: { QUICK: number, DEPLOY: number, UPLOAD: number }, sleep(ms: number): Promise<void> } & Record<string, any>} kit
84
+ * The host's deploy kit in the positional ABI installed modules are written against (devops'
85
+ * `DeployHostKit` helpers, called positionally; `DeployError` is `new (message, status?, details?)`).
86
+ * @returns The target class (constructed with `{ token, teamId?, teamSlug? }`, as in devops) and the
87
+ * protected-response detector.
88
+ */
89
+ export function bindVercel(kit) {
90
+ const { fetch: fetchWithTimeout, timeouts: FETCH_TIMEOUT_MS, sleep, DeployError, checkDeploymentUrl, normalizeDeploymentUrl, waitForReachableDeploymentUrl, safeProjectLabel, assertNotRedirected, redirectGuardInit } = kit;
91
+ const VERCEL_TARGET_ID = 'vercel';
92
+ const VERCEL_API = 'https://api.vercel.com';
93
+ const VERCEL_PROTECTED_MESSAGE = 'Deployment is protected by Vercel. Disable Deployment Protection or use a custom domain to make this link public.';
94
+ /**
95
+ * Heuristically detects Vercel's own Deployment Protection auth wall from a
96
+ * 401 response, so `checkReachability` can report `status: 'protected'`
97
+ * (an actionable, non-error outcome) instead of `reachable: false` with a
98
+ * generic message.
99
+ *
100
+ * @param resp - The HTTP response received from probing a deployment URL.
101
+ * @param body - The response body (only read for 401s by the caller).
102
+ * @returns `true` if the response looks like Vercel's SSO/auth gate.
103
+ * @complexity O(1) — a handful of regex tests over already-fetched strings.
104
+ * @overallScore 100/100
105
+ */
106
+ function isVercelProtectedResponse(resp, body = '') {
107
+ const { server, setCookie } = protectionHeaders({ resp });
108
+ const text = String(body || '');
109
+ if (/vercel/i.test(server) || /_vercel_sso_nonce/i.test(setCookie)) return true;
110
+ return /Authentication Required|Vercel Authentication|vercel\.com\/sso-api/i.test(text);
111
+ }
112
+ function protectionHeaders({ resp }, _options = {}) {
113
+ return { server: resp.headers?.get?.('server') || '', setCookie: resp.headers?.get?.('set-cookie') || '' };
114
+ }
115
+ /**
116
+ * `DeployTarget` adapter for Vercel's v13 deployments API. Publishes a
117
+ * caller-supplied file set as a single deployment, polls until Vercel
118
+ * reports a terminal `readyState`, then waits for the resulting URL to
119
+ * become publicly reachable.
120
+ *
121
+ * Genericized from the origin product's daemon deploy module's
122
+ * `deployToVercel`: the origin's product-specific deployment-name
123
+ * convention is replaced by `input.projectName` (sanitized the same way);
124
+ * token/team config is supplied by the caller instead of being read from a
125
+ * product-owned local config file — persistence of that config is now the
126
+ * caller's concern, not this package's.
127
+ */
128
+ class VercelDeployTarget {
129
+ config;
130
+ id = VERCEL_TARGET_ID;
131
+ resolvedProjectName;
132
+ resolvedPublicUrl;
133
+ constructor(config) {
134
+ this.config = config;
135
+ }
136
+ /** Resolve the host-assigned production domain before rendering. A first publish creates
137
+ * the same project publish() would create, then reads its actual alias (names may collide).
138
+ * @complexity At most three bounded API calls, at most 100 domain records; no file uploads.
139
+ * @throws DeployError for refused/ambiguous inventories; never fabricates a public URL.
140
+ */
141
+ async resolvePublicUrl({ projectName }, _options = {}) {
142
+ this.resolvedProjectName = safeVercelProjectName(projectName);
143
+ this.resolvedPublicUrl = await resolveVercelPublicUrl({ config: this.config, name: this.resolvedProjectName });
144
+ return this.resolvedPublicUrl;
145
+ }
146
+ /**
147
+ * Publishes `input.files`, asking Vercel for missing hashes before uploading. The optional
148
+ * synchronous `input.onProgress` receives credential-free counts and deployment facts.
149
+ *
150
+ * @param input - File set, project name, optional security headers and progress observer.
151
+ * @returns The verified URL/status, or a partial result retaining the accepted deployment's
152
+ * ID/URL and next steps when readiness cannot be confirmed.
153
+ * @throws {DeployError} For a failed build or before a deployment is known to exist; includes confirmed
154
+ * upload counts, whether creation is false/unknown, and how to safely continue.
155
+ * @complexity O(files) to hash and upload them, plus a bounded poll loop
156
+ * (`pollVercelDeployment`) and the reachability wait's own bound.
157
+ * @overallScore 100/100
158
+ */
159
+ async publish(input) {
160
+ if (!this.config.token) {
161
+ throw new DeployError('Vercel token is required.', 400);
162
+ }
163
+ const { refs, blobs } = vercelFileManifest(withVercelConfigFile(input.files, input.responseHeaders));
164
+ const name = this.resolvedProjectName ?? safeVercelProjectName(input.projectName);
165
+ const progress = { phase: 'creating', totalFiles: blobs.size, uploadedFiles: 0, reusedFiles: 0, deploymentCreated: false };
166
+ const report = patch => { Object.assign(progress, patch); input.onProgress?.({ ...progress }); };
167
+ try {
168
+ const created = await createUploadedVercelDeployment({ config: this.config, name, refs, blobs, report });
169
+ const deploymentId = typeof created.id === 'string' ? created.id : created.uid;
170
+ const initialUrl = deploymentUrl(created);
171
+ report({ phase: 'polling', deploymentCreated: true, deploymentId, url: initialUrl, providerStatus: created.readyState ?? 'unknown' });
172
+ const ready = await readyVercelDeployment({ config: this.config, deploymentId, created, report });
173
+ if (ready?.readyState !== 'READY') return unfinishedDeployment({ progress, name });
174
+ report({ phase: 'checking', providerStatus: 'READY' });
175
+ const link = await publicVercelLink({ name, ready, created, initialUrl, publicUrl: this.resolvedPublicUrl });
176
+ return publishedResult({ link, ready, initialUrl, deploymentId });
177
+ } catch (error) {
178
+ return publishFailure({ progress, name, error, token: this.config.token });
179
+ }
180
+ }
181
+ /** Probes `url`, recognizing Vercel's own Deployment Protection auth wall. */
182
+ async checkReachability(url) {
183
+ return checkDeploymentUrl(url, {
184
+ detectProtected: isVercelProtectedResponse,
185
+ protectedMessage: VERCEL_PROTECTED_MESSAGE,
186
+ });
187
+ }
188
+ }
189
+ /** Preserve accepted deployment facts on verification failures; known build errors still reject.
190
+ * @complexity O(message bytes), no I/O; reuses the confirmed progress snapshot.
191
+ */
192
+ function publishFailure({ progress, name, error, token }, _options = {}) {
193
+ // An existing deployment remains a real provider fact even if polling/reachability fails.
194
+ if (progress.deploymentCreated === true && progress.providerStatus !== 'ERROR') return unfinishedDeployment({ progress, name, error, token });
195
+ const detail = safeFailureMessage({ error, token });
196
+ throw new DeployError(`${detail} ${publishFacts({ progress })} ${retryGuidance({ progress, name })}`, error?.status ?? 502);
197
+ }
198
+ /** Map a verified public link without changing the provider's deployment identity. */
199
+ function publishedResult({ link, ready, initialUrl, deploymentId }, _options = {}) {
200
+ return { targetId: VERCEL_TARGET_ID, url: link.url || deploymentUrl(ready) || initialUrl,
201
+ ...(deploymentId ? { deploymentId } : {}), status: link.status, statusMessage: link.statusMessage,
202
+ ...(link.reachableAt !== undefined ? { reachableAt: link.reachableAt } : {}) };
203
+ }
204
+ /** Read the provider's production-only, verified, nonredirecting domains. Refuse a partial
205
+ * inventory rather than select a different canonical URL on different pages of the result.
206
+ * @complexity One bounded request; response limited to 100 records by the provider.
207
+ */
208
+ async function readPublicDomains({ config, name }, _options = {}) {
209
+ const url = new URL(`${VERCEL_API}/v9/projects/${encodeURIComponent(name)}/domains${vercelTeamQuery(config)}`);
210
+ for (const [key, value] of Object.entries({ production: 'true', redirects: 'false', verified: 'true', limit: '100' })) url.searchParams.set(key, value);
211
+ return fetchWithTimeout(url.href, redirectGuardInit({ method: 'GET', headers: { Authorization: `Bearer ${config.token}` } }), { timeoutMs: FETCH_TIMEOUT_MS.QUICK });
212
+ }
213
+ /** Provision only after an authoritative not-found response; permission/network failures never create.
214
+ * @complexity One POST with the same project name and framework as the existing publish request.
215
+ */
216
+ async function createPublicProject({ config, name }, _options = {}) {
217
+ const response = await fetchWithTimeout(`${VERCEL_API}/v11/projects${vercelTeamQuery(config)}`, redirectGuardInit({
218
+ method: 'POST', headers: { Authorization: `Bearer ${config.token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ name, framework: null }),
219
+ }), { timeoutMs: FETCH_TIMEOUT_MS.QUICK });
220
+ assertNotRedirected(response, 'Vercel project creation');
221
+ const body = await readVercelJson(response);
222
+ if (!response.ok) throw vercelError(body, response.status);
223
+ }
224
+ /** Actual domain evidence, never a name-derived hostname; preparation stays inside this provider.
225
+ * @complexity At most three API requests and O(domains), capped at 100; errors propagate.
226
+ */
227
+ async function resolveVercelPublicUrl({ config, name }, _options = {}) {
228
+ if (!config.token) throw new DeployError('Vercel token is required.', 400);
229
+ let response = await readPublicDomains({ config, name });
230
+ if (response.status === 404) {
231
+ await response.body?.cancel();
232
+ await createPublicProject({ config, name });
233
+ response = await readPublicDomains({ config, name });
234
+ }
235
+ assertNotRedirected(response, 'Vercel public domain lookup');
236
+ const body = await readVercelJson(response);
237
+ if (!response.ok) throw vercelError(body, response.status);
238
+ return publicDomainUrl({ body, name });
239
+ }
240
+ /** Select a complete, bounded inventory. Missing evidence is a refusal, never a guessed alias.
241
+ * @complexity O(domains), capped at 100 records; pure, throws DeployError for missing evidence.
242
+ */
243
+ function publicDomainUrl({ body, name }, _options = {}) {
244
+ const entries = Array.isArray(body.domains) ? body.domains : [];
245
+ if (body.pagination?.next != null || entries.length > 100) throw new DeployError('Public domain inventory exceeds 100 domains; choose a smaller destination.', 400);
246
+ const domains = entries.filter(domain => domain.verified === true && !domain.redirect && !domain.gitBranch && typeof domain.name === 'string');
247
+ const domain = domains.find(domain => domain.name === `${name}.vercel.app`) ?? domains[0];
248
+ if (!domain) throw new DeployError('Vercel did not report a verified public domain for this project.', 400);
249
+ return `https://${domain.name}`;
250
+ }
251
+ /** Let the provider's content store select missing hashes before sending bytes. A retry on
252
+ * another target/process reuses provider acknowledgements, including a prior partial upload.
253
+ * @complexity At most two O(file references) create requests plus one upload per missing hash.
254
+ */
255
+ async function createUploadedVercelDeployment({ config, name, refs, blobs, report }, _options = {}) {
256
+ // `target: "production"`: without it Vercel makes a preview deployment, and only a project's
257
+ // FIRST deployment takes the production alias, so every later publish never reached the
258
+ // public address (2026-10-11). A publish is meant to update the live site.
259
+ const body = JSON.stringify({ name, files: refs, target: 'production', projectSettings: { framework: null } });
260
+ report({ phase: 'creating', deploymentCreated: 'unknown' });
261
+ let createResp = await createVercelDeployment(config, body);
262
+ let created = await readVercelJson(createResp);
263
+ const missing = created?.error?.code === 'missing_files' ? created.error.missing : undefined;
264
+ if (!createResp.ok && Array.isArray(missing)) {
265
+ const shas = [...new Set(missing.filter(sha => blobs.has(sha)))];
266
+ report({ phase: 'uploading', deploymentCreated: false, reusedFiles: blobs.size - shas.length });
267
+ // Vercel did not keep (or never got) some uploads: send exactly what it names, then create
268
+ // once more. A second `missing_files` is reported like any other create failure.
269
+ let uploadedFiles = 0;
270
+ await uploadVercelFiles(config, blobs, shas, () => report({ uploadedFiles: ++uploadedFiles }));
271
+ report({ phase: 'creating', deploymentCreated: 'unknown' });
272
+ createResp = await createVercelDeployment(config, body);
273
+ created = await readVercelJson(createResp);
274
+ } else if (createResp.ok) {
275
+ report({ reusedFiles: blobs.size });
276
+ }
277
+ if (!createResp.ok) {
278
+ report({ deploymentCreated: false });
279
+ throw vercelError(created, createResp.status);
280
+ }
281
+ return created;
282
+ }
283
+ /** Only confirmed, value-free facts cross the failure boundary; no raw upstream body.
284
+ * @complexity O(1) formatting, independent of export bytes.
285
+ */
286
+ function publishFacts({ progress }, _options = {}) {
287
+ const created = progress.deploymentCreated === true ? 'created' : progress.deploymentCreated === false ? 'not created' : 'unknown';
288
+ return `Deployment: ${created}. ${progress.uploadedFiles} of ${progress.totalFiles} distinct files uploaded this attempt; ${progress.reusedFiles} already stored. Deployment ID: ${progress.deploymentId ?? 'unknown'}; URL: ${progress.url || 'unknown'}; provider status: ${progress.providerStatus ?? 'unknown'}.`;
289
+ }
290
+ function retryGuidance({ progress, name }, _options = {}) {
291
+ if (progress.deploymentCreated !== false) return `Check deployment ${progress.deploymentId ?? ''} in the Vercel dashboard for project '${name}' before publishing again. A public site's 200 can belong to the previous deployment.`;
292
+ return 'Retry the publish to upload only missing hashes; acknowledged files are reused.';
293
+ }
294
+ function safeFailureMessage({ error, token }, _options = {}) {
295
+ return String(error?.message ?? 'Vercel did not finish the request.').split(token).join('[redacted]');
296
+ }
297
+ /** Accepted deployment with incomplete verification: retain its own URL, never prove it with
298
+ * an old production alias. Known provider errors remain failed rather than becoming a timeout.
299
+ */
300
+ function unfinishedDeployment({ progress, name, error, token }, _options = {}) {
301
+ const fallback = progress.providerStatus === 'ERROR' ? 'Vercel deployment failed.' : 'Vercel has not confirmed this deployment is ready yet.';
302
+ const detail = error ? safeFailureMessage({ error, token }) : fallback;
303
+ return { targetId: VERCEL_TARGET_ID, url: progress.url || '', deploymentId: progress.deploymentId,
304
+ status: progress.providerStatus === 'ERROR' ? 'failed' : 'link-delayed',
305
+ statusMessage: `${detail} ${publishFacts({ progress })} ${retryGuidance({ progress, name })}` };
306
+ }
307
+ async function readyVercelDeployment({ config, deploymentId, created, report }, _options = {}) {
308
+ const ready = deploymentId ? await pollVercelDeployment(config, deploymentId, report) : created;
309
+ if (ready?.readyState === 'ERROR') {
310
+ const readyError = ready.error;
311
+ // `ready ?? undefined` — the `undefined` side is unreachable: this line
312
+ // only runs when `ready?.readyState === 'ERROR'` just matched, which
313
+ // requires `ready` itself to already be a real object (optional
314
+ // chaining on a null/undefined `ready` would make the whole comparison
315
+ // `undefined === 'ERROR'`, i.e. false, skipping this block entirely).
316
+ // So by the time `ready ?? undefined` evaluates, `ready` is always
317
+ // truthy and the `??` is a no-op at runtime. Kept (not simplified to
318
+ // just `ready`) purely for type-level reasons: `ready`'s static type is
319
+ // `JsonObject | null` (from `pollVercelDeployment`'s return type /
320
+ // `created`'s), and `DeployError`'s `details` parameter accepts
321
+ // `JsonObject | string | undefined` — not `null` — so this coalesce is
322
+ // a compile-time-required null-to-undefined conversion that TypeScript's
323
+ // control-flow analysis cannot narrow away just from the optional-chained
324
+ // comparison above. See packages/devops/source-map.md's 2026-07-22
325
+ // addition for the full re-derivation.
326
+ throw new DeployError(readyError?.message || 'Vercel deployment failed.', 502, ready ?? undefined);
327
+ }
328
+ return ready;
329
+ }
330
+ async function publicVercelLink({ name, ready, created, initialUrl, publicUrl }, _options = {}) {
331
+ const aliases = deploymentUrlCandidates(`${name}.vercel.app`, ready, created);
332
+ const candidates = publicUrl ? [publicUrl, ...aliases.filter(alias => alias !== publicUrl)] : aliases;
333
+ let link = await waitForReachableDeploymentUrl(candidates.length ? candidates : [initialUrl], {
334
+ providerLabel: 'Vercel',
335
+ detectProtected: isVercelProtectedResponse,
336
+ protectedMessage: VERCEL_PROTECTED_MESSAGE,
337
+ });
338
+ // The kit counts any 3xx as reachable, but Deployment Protection answers a per-deployment
339
+ // URL with a redirect to Vercel's login, which is not a public link.
340
+ if (link.status === 'ready' && await redirectsToVercelLogin(link.url)) {
341
+ link = { status: 'protected', url: link.url, statusMessage: VERCEL_PROTECTED_MESSAGE };
342
+ }
343
+ return link;
344
+ }
345
+ /** One HEAD, redirects not followed: does `url` send visitors to Vercel's SSO/login wall? Any
346
+ * failure answers `false`, leaving the reachability result as it was. */
347
+ async function redirectsToVercelLogin(url) {
348
+ try {
349
+ const resp = await fetchWithTimeout(url, { method: 'HEAD', redirect: 'manual' }, { timeoutMs: FETCH_TIMEOUT_MS.QUICK });
350
+ await resp.arrayBuffer().catch(() => undefined);
351
+ return resp.status >= 300 && resp.status < 400 && /vercel\.com\/(sso-api|login)/i.test(resp.headers.get('location') || '');
352
+ }
353
+ catch {
354
+ return false;
355
+ }
356
+ }
357
+ async function createVercelDeployment(config, body) {
358
+ const resp = await fetchWithTimeout(`${VERCEL_API}/v13/deployments${vercelTeamQuery(config)}`, redirectGuardInit({
359
+ method: 'POST',
360
+ headers: {
361
+ Authorization: `Bearer ${config.token}`,
362
+ 'Content-Type': 'application/json',
363
+ },
364
+ body,
365
+ }), { timeoutMs: FETCH_TIMEOUT_MS.UPLOAD });
366
+ assertNotRedirected(resp, 'Vercel deployment creation');
367
+ return resp;
368
+ }
369
+ /**
370
+ * Uploads `shas` (keys of `blobs`) to `POST /v2/files`, {@link VERCEL_UPLOAD_CONCURRENCY} at a
371
+ * time. The first failure stops the remaining queue; active sends drain before rejection.
372
+ *
373
+ * @complexity O(n) requests, plus at most `VERCEL_UPLOAD_ATTEMPTS - 1` retries each.
374
+ */
375
+ async function uploadVercelFiles(config, blobs, shas, onUploaded) {
376
+ let cursor = 0;
377
+ let stopped = false;
378
+ const worker = async () => {
379
+ while (!stopped && cursor < shas.length) {
380
+ const sha = shas[cursor++];
381
+ try {
382
+ await uploadVercelFile(config, sha, blobs.get(sha));
383
+ onUploaded();
384
+ } catch (err) {
385
+ stopped = true;
386
+ throw err;
387
+ }
388
+ }
389
+ };
390
+ // Drain already-started sends before reporting a failure, so acknowledged counts are final
391
+ // and no upload from this attempt can race a retry and charge the same bytes twice.
392
+ const results = await Promise.allSettled(Array.from({ length: Math.min(VERCEL_UPLOAD_CONCURRENCY, shas.length) }, worker));
393
+ const failure = results.find(result => result.status === 'rejected');
394
+ if (failure) throw failure.reason;
395
+ }
396
+ function vercelUploadTransportError({ err }, _options = {}) {
397
+ // Node's fetch reports every transport failure as a bare "fetch failed"; the cause (a
398
+ // reset socket, a TLS or DNS error) is the only part that says what happened.
399
+ const cause = err?.cause?.message || err?.cause?.code;
400
+ const detail = cause ? ` (${cause})` : '';
401
+ return new DeployError(`Vercel file upload failed: ${err?.message ?? err}${detail}`, 502);
402
+ }
403
+ async function tryVercelFileUpload({ config, sha, data, attempt }, _options = {}) {
404
+ try {
405
+ return await fetchWithTimeout(`${VERCEL_API}/v2/files${vercelTeamQuery(config)}`, redirectGuardInit({
406
+ method: 'POST',
407
+ headers: {
408
+ Authorization: `Bearer ${config.token}`,
409
+ 'Content-Type': 'application/octet-stream',
410
+ 'Content-Length': String(data.length),
411
+ 'x-vercel-digest': sha,
412
+ },
413
+ body: data,
414
+ }), { timeoutMs: FETCH_TIMEOUT_MS.UPLOAD });
415
+ }
416
+ catch (err) {
417
+ // A dropped connection is retried like a 5xx (the first real plannie publish lost one of
418
+ // ~200 uploads that way); a timeout is not, since each try already waited the full bound.
419
+ if (attempt < VERCEL_UPLOAD_ATTEMPTS && !/timed out/i.test(String(err?.message))) {
420
+ await sleep(1000 * attempt);
421
+ return undefined;
422
+ }
423
+ throw vercelUploadTransportError({ err });
424
+ }
425
+ }
426
+ async function uploadVercelFile(config, sha, data) {
427
+ for (let attempt = 1; ; attempt += 1) {
428
+ const resp = await tryVercelFileUpload({ config, sha, data, attempt });
429
+ if (resp === undefined) continue;
430
+ assertNotRedirected(resp, 'Vercel file upload');
431
+ if (resp.ok) {
432
+ // Drain the small JSON ack so the connection goes back to the pool.
433
+ await resp.arrayBuffer().catch(() => undefined);
434
+ return;
435
+ }
436
+ if (attempt < VERCEL_UPLOAD_ATTEMPTS && (resp.status === 429 || resp.status >= 500)) {
437
+ await resp.arrayBuffer().catch(() => undefined);
438
+ await sleep(1000 * attempt);
439
+ } else {
440
+ throw vercelError(await readVercelJson(resp), resp.status);
441
+ }
442
+ }
443
+ }
444
+ /**
445
+ * Polls a just-created Vercel deployment until it reaches a terminal
446
+ * `readyState` (`READY`/`ERROR`) or the fixed 30-attempt budget is spent
447
+ * (~1s for the first 5 attempts, 2s thereafter — roughly a minute).
448
+ *
449
+ * A response this file cannot parse as JSON is treated as "keep polling,"
450
+ * not an error — same reasoning as `github-pages.ts`'s `pollGitHubPagesBuild`
451
+ * (fixed 2026-08-16 for the identical bug class): the deployment already
452
+ * exists server-side by the time this loop runs (the create call above
453
+ * already succeeded), so a transient/edge/empty poll response is exactly as
454
+ * uninformative as a stuck in-progress state, never a reason to report an
455
+ * already-created deployment as failed. Any other non-2xx response whose
456
+ * body DID parse still fails fast, unchanged.
457
+ *
458
+ * @complexity O(30) network round-trips, bounded and fixed regardless of input size.
459
+ * @overallScore 90/100
460
+ * @tradeoffs Fixed attempt/backoff constants (lifted verbatim from the OD
461
+ * origin) rather than caller-configurable ones — acceptable for now since
462
+ * `publish` has no caller-facing timeout knob yet either; flagged as a
463
+ * minor extensibility gap rather than a correctness issue.
464
+ */
465
+ async function pollVercelDeployment(config, id, report) {
466
+ let last = null;
467
+ for (let i = 0; i < 30; i += 1) {
468
+ await sleep(i < 5 ? 1000 : 2000);
469
+ const resp = await fetchWithTimeout(`${VERCEL_API}/v13/deployments/${encodeURIComponent(id)}${vercelTeamQuery(config)}`, redirectGuardInit({ headers: { Authorization: `Bearer ${config.token}` } }), { timeoutMs: FETCH_TIMEOUT_MS.DEPLOY });
470
+ assertNotRedirected(resp, 'Vercel deployment status poll');
471
+ let json;
472
+ try {
473
+ json = await readVercelJson(resp);
474
+ }
475
+ catch {
476
+ // Nothing usable to report yet — keep polling within the same fixed budget
477
+ // rather than turning an ambiguous mid-poll hiccup into a reported failure.
478
+ continue;
479
+ }
480
+ if (!resp.ok)
481
+ throw vercelError(json, resp.status);
482
+ last = json;
483
+ report({ providerStatus: json.readyState ?? 'unknown' });
484
+ if (json.readyState === 'READY' || json.readyState === 'ERROR')
485
+ return json;
486
+ }
487
+ return last;
488
+ }
489
+ function vercelTeamQuery(config) {
490
+ const params = new URLSearchParams();
491
+ if (config.teamId)
492
+ params.set('teamId', config.teamId);
493
+ else if (config.teamSlug)
494
+ params.set('slug', config.teamSlug);
495
+ else {
496
+ // Personal deployments need no team query parameter.
497
+ }
498
+ const s = params.toString();
499
+ return s ? `?${s}` : '';
500
+ }
501
+ /**
502
+ * Derives a Vercel-safe project name from a caller-supplied label, falling
503
+ * back to a random id if the label sanitizes to nothing. Replaces the OD
504
+ * origin's hardcoded `od-${projectId}` convention.
505
+ */
506
+ function safeVercelProjectName(projectName) {
507
+ return safeProjectLabel(projectName, 80) || `deploy-${randomInt(36 ** 8).toString(36).padStart(8, '0')}`;
508
+ }
509
+ async function readVercelJson(resp) {
510
+ try {
511
+ return (await resp.json());
512
+ }
513
+ catch {
514
+ throw new DeployError('Vercel returned a non-JSON response.', resp.status || 502);
515
+ }
516
+ }
517
+ function vercelErrorField({ json, field }, _options = {}) {
518
+ return json?.error && typeof json.error === 'object' ? json.error[field] : undefined;
519
+ }
520
+ function vercelError(json, status) {
521
+ const code = vercelErrorField({ json, field: 'code' });
522
+ const message = vercelErrorField({ json, field: 'message' }) ||
523
+ json?.message ||
524
+ `Vercel request failed (${status}).`;
525
+ if (code === 'forbidden' || /permission/i.test(String(message))) {
526
+ return new DeployError("You don't have permission to create a project.", status, json);
527
+ }
528
+ return new DeployError(String(message), status, json);
529
+ }
530
+ function deploymentUrl(json) {
531
+ const url = json?.url || json?.alias?.[0] || '';
532
+ if (!url)
533
+ return '';
534
+ return /^https?:\/\//i.test(url) ? url : `https://${url}`;
535
+ }
536
+ function appendDeploymentAlias({ alias, urls }, _options = {}) {
537
+ if (typeof alias === 'string') {
538
+ urls.push(alias);
539
+ return;
540
+ }
541
+ if (alias && typeof alias === 'object') {
542
+ const a = alias;
543
+ if (typeof a.domain === 'string')
544
+ urls.push(a.domain);
545
+ else if (typeof a.url === 'string')
546
+ urls.push(a.url);
547
+ else {
548
+ // Objects without a domain or URL are not deployment aliases.
549
+ }
550
+ }
551
+ }
552
+ function appendDeploymentAliases({ json, urls }, _options = {}) {
553
+ for (const alias of json.alias ?? []) {
554
+ if (typeof alias === 'string')
555
+ urls.push(alias);
556
+ }
557
+ for (const alias of json.aliases ?? []) {
558
+ appendDeploymentAlias({ alias, urls });
559
+ }
560
+ }
561
+ /**
562
+ * `if (!json) continue` skips a response that is not there. Of this file's one call site,
563
+ * `deploymentUrlCandidates(publicHost, ready, created)` in `publish()`, `created` is always a parsed
564
+ * `JsonObject` (`readVercelJson` returns one or throws), but `ready` is `null` when every one of
565
+ * `pollVercelDeployment`'s 30 status reads was unparseable (each such read is skipped with
566
+ * `continue`, so `last` is never assigned) — then only `created` supplies candidates. Same guard
567
+ * `netlify.ts`'s own `netlifyUrlCandidates` keeps for the same reason.
568
+ */
569
+ function deploymentUrlCandidates(publicHost, ...responses) {
570
+ // Aliases (the production `<project>.vercel.app` among them) are tried before `url`: `url` is the
571
+ // per-deployment address, which Deployment Protection puts behind Vercel's login by default.
572
+ const urls = [];
573
+ const deploymentUrls = [];
574
+ for (const json of responses) {
575
+ if (!json)
576
+ continue;
577
+ if (typeof json.url === 'string')
578
+ deploymentUrls.push(json.url);
579
+ appendDeploymentAliases({ json, urls });
580
+ }
581
+ const candidates = [...new Set([...urls, ...deploymentUrls].map(normalizeDeploymentUrl).filter(Boolean))];
582
+ // The public `<project>.vercel.app` alias goes first when Vercel lists it. Vercel orders aliases
583
+ // its own way, so the team-scoped `<project>-<team>.vercel.app` (behind Deployment Protection)
584
+ // can come first, and the reachability wait stops at the first `protected` answer: a publish
585
+ // whose public alias served 200 was reported `protected` (2026-10-11).
586
+ const publicUrl = normalizeDeploymentUrl(publicHost);
587
+ return candidates.includes(publicUrl) ? [publicUrl, ...candidates.filter((url) => url !== publicUrl)] : candidates;
588
+ }
589
+
590
+ return { VercelDeployTarget, isVercelProtectedResponse };
591
+ }
592
+
593
+ /**
594
+ * Reads one credential-check response WITHOUT touching its body: 401/403 means the host refused the
595
+ * credential, any other failure says nothing about it (a 5xx, a rate limit).
596
+ *
597
+ * @param {Response} response
598
+ * @returns {{ ok: true } | { ok: false, reason: "rejected" | "unreachable", statusCode: number }}
599
+ */
600
+ function classifyCredentialResponse(response) {
601
+ if (response.ok) return { ok: true };
602
+ return { ok: false, reason: response.status === 401 || response.status === 403 ? "rejected" : "unreachable", statusCode: response.status };
603
+ }
604
+
605
+ /**
606
+ * The token's account `user.username` from a `GET /v2/user` body, or `undefined`. Reads no other field.
607
+ * @param {unknown} body
608
+ * @returns {string | undefined}
609
+ */
610
+ function readVercelUsername(body) {
611
+ const user = typeof body === "object" && body !== null ? /** @type {Record<string, unknown>} */ (body).user : undefined;
612
+ const username = typeof user === "object" && user !== null ? /** @type {Record<string, unknown>} */ (user).username : undefined;
613
+ return typeof username === "string" && username !== "" ? username : undefined;
614
+ }
615
+
616
+ /** The module contract a host's deploy-target registry loads (`DeployTargetModule`). The one config
617
+ * field is the optional Vercel `teamId`. */
618
+ export default {
619
+ /** @param {{ credential: { token: string }, config: { teamId?: string }, kit: any }} context */
620
+ create({ credential, config, kit }) {
621
+ const { VercelDeployTarget } = bindVercel(kit);
622
+ return new VercelDeployTarget({ token: credential.token, ...(typeof config.teamId === "string" ? { teamId: config.teamId } : {}) });
623
+ },
624
+ /**
625
+ * `GET /v2/user`: 401/403 for a bad token. Reads back only `user.username`, required on both body
626
+ * shapes Vercel's OpenAPI schema declares and public (`vercel.com/<username>`), never email,
627
+ * billing or `defaultTeamId`.
628
+ * @param {{ credential: { token: string }, kit: any }} context
629
+ */
630
+ async verifyCredential({ credential, kit }) {
631
+ const response = await kit.fetch("https://api.vercel.com/v2/user", { headers: { Authorization: `Bearer ${credential.token}` } }, { timeoutMs: kit.timeouts.QUICK });
632
+ const check = classifyCredentialResponse(response);
633
+ if (!check.ok) return check;
634
+ return { ok: true, accountLabel: readVercelUsername(await response.json().catch(() => undefined)) };
635
+ },
636
+ /** @param {{ teamId?: unknown }} config */
637
+ validateConfig(config) {
638
+ if (typeof config.teamId === "string" && config.teamId.trim() === "") return "teamId must not be blank when provided";
639
+ return null;
640
+ },
641
+ basePath() {
642
+ return undefined;
643
+ },
644
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "contributions": [
4
+ { "kind": "region-resolver", "id": "vercel", "header": "x-vercel-ip-country" }
5
+ ]
6
+ }