mcpmake 0.1.1 → 0.2.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 (385) hide show
  1. package/dist/commands/bundle.d.ts +1 -0
  2. package/dist/commands/bundle.d.ts.map +1 -0
  3. package/dist/commands/bundle.js +5 -4
  4. package/dist/commands/bundle.js.map +1 -0
  5. package/dist/commands/ci.d.ts +1 -0
  6. package/dist/commands/ci.d.ts.map +1 -0
  7. package/dist/commands/ci.js +3 -2
  8. package/dist/commands/ci.js.map +1 -0
  9. package/dist/commands/deploy.d.ts +1 -0
  10. package/dist/commands/deploy.d.ts.map +1 -0
  11. package/dist/commands/deploy.js +4 -3
  12. package/dist/commands/deploy.js.map +1 -0
  13. package/dist/commands/diff.d.ts +1 -0
  14. package/dist/commands/diff.d.ts.map +1 -0
  15. package/dist/commands/diff.js +5 -4
  16. package/dist/commands/diff.js.map +1 -0
  17. package/dist/commands/from/describe.d.ts +1 -0
  18. package/dist/commands/from/describe.d.ts.map +1 -0
  19. package/dist/commands/from/describe.js +11 -10
  20. package/dist/commands/from/describe.js.map +1 -0
  21. package/dist/commands/from/har.d.ts +1 -0
  22. package/dist/commands/from/har.d.ts.map +1 -0
  23. package/dist/commands/from/har.js +14 -13
  24. package/dist/commands/from/har.js.map +1 -0
  25. package/dist/commands/from/openapi.d.ts +1 -0
  26. package/dist/commands/from/openapi.d.ts.map +1 -0
  27. package/dist/commands/from/openapi.js +17 -16
  28. package/dist/commands/from/openapi.js.map +1 -0
  29. package/dist/commands/from/postman.d.ts +1 -0
  30. package/dist/commands/from/postman.d.ts.map +1 -0
  31. package/dist/commands/from/postman.js +13 -12
  32. package/dist/commands/from/postman.js.map +1 -0
  33. package/dist/commands/from/stainless.d.ts +110 -0
  34. package/dist/commands/from/stainless.d.ts.map +1 -0
  35. package/dist/commands/from/stainless.js +272 -0
  36. package/dist/commands/from/stainless.js.map +1 -0
  37. package/dist/commands/from/target-support.d.ts +1 -0
  38. package/dist/commands/from/target-support.d.ts.map +1 -0
  39. package/dist/commands/from/target-support.js +2 -1
  40. package/dist/commands/from/target-support.js.map +1 -0
  41. package/dist/commands/from/url.d.ts +1 -0
  42. package/dist/commands/from/url.d.ts.map +1 -0
  43. package/dist/commands/from/url.js +14 -13
  44. package/dist/commands/from/url.js.map +1 -0
  45. package/dist/commands/from/website.d.ts +1 -0
  46. package/dist/commands/from/website.d.ts.map +1 -0
  47. package/dist/commands/from/website.js +17 -16
  48. package/dist/commands/from/website.js.map +1 -0
  49. package/dist/commands/lint.d.ts +1 -0
  50. package/dist/commands/lint.d.ts.map +1 -0
  51. package/dist/commands/lint.js +6 -5
  52. package/dist/commands/lint.js.map +1 -0
  53. package/dist/commands/merge.d.ts +1 -0
  54. package/dist/commands/merge.d.ts.map +1 -0
  55. package/dist/commands/merge.js +3 -2
  56. package/dist/commands/merge.js.map +1 -0
  57. package/dist/commands/publish.d.ts +1 -0
  58. package/dist/commands/publish.d.ts.map +1 -0
  59. package/dist/commands/publish.js +4 -3
  60. package/dist/commands/publish.js.map +1 -0
  61. package/dist/commands/rescan.d.ts +1 -0
  62. package/dist/commands/rescan.d.ts.map +1 -0
  63. package/dist/commands/rescan.js +12 -11
  64. package/dist/commands/rescan.js.map +1 -0
  65. package/dist/commands/update.d.ts +1 -0
  66. package/dist/commands/update.d.ts.map +1 -0
  67. package/dist/commands/update.js +10 -9
  68. package/dist/commands/update.js.map +1 -0
  69. package/dist/commands/verify.d.ts +1 -0
  70. package/dist/commands/verify.d.ts.map +1 -0
  71. package/dist/commands/verify.js +7 -6
  72. package/dist/commands/verify.js.map +1 -0
  73. package/dist/index.d.ts +1 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +23 -2
  76. package/dist/index.js.map +1 -0
  77. package/dist/registry/official-registry.d.ts +1 -0
  78. package/dist/registry/official-registry.d.ts.map +1 -0
  79. package/dist/registry/official-registry.js +1 -0
  80. package/dist/registry/official-registry.js.map +1 -0
  81. package/package.json +20 -46
  82. package/README.md +0 -691
  83. package/dist/analyzer/auth-detector.d.ts +0 -12
  84. package/dist/analyzer/auth-detector.js +0 -142
  85. package/dist/analyzer/dom-parser.d.ts +0 -10
  86. package/dist/analyzer/dom-parser.js +0 -259
  87. package/dist/analyzer/goal-crawler.d.ts +0 -25
  88. package/dist/analyzer/goal-crawler.js +0 -177
  89. package/dist/analyzer/hybrid-detector.d.ts +0 -28
  90. package/dist/analyzer/hybrid-detector.js +0 -96
  91. package/dist/analyzer/index.d.ts +0 -12
  92. package/dist/analyzer/index.js +0 -8
  93. package/dist/analyzer/screenshot-capture.d.ts +0 -29
  94. package/dist/analyzer/screenshot-capture.js +0 -42
  95. package/dist/analyzer/selector-builder.d.ts +0 -19
  96. package/dist/analyzer/selector-builder.js +0 -199
  97. package/dist/analyzer/semantic-analyzer.d.ts +0 -13
  98. package/dist/analyzer/semantic-analyzer.js +0 -145
  99. package/dist/analyzer/site-crawler.d.ts +0 -38
  100. package/dist/analyzer/site-crawler.js +0 -235
  101. package/dist/cloud/billing/billing-engine.d.ts +0 -44
  102. package/dist/cloud/billing/billing-engine.js +0 -81
  103. package/dist/cloud/billing/credit-store.d.ts +0 -64
  104. package/dist/cloud/billing/credit-store.js +0 -168
  105. package/dist/cloud/billing/index.d.ts +0 -4
  106. package/dist/cloud/billing/index.js +0 -2
  107. package/dist/cloud/billing/usage-store.d.ts +0 -42
  108. package/dist/cloud/billing/usage-store.js +0 -85
  109. package/dist/cloud/billing/usage-tracker.d.ts +0 -38
  110. package/dist/cloud/billing/usage-tracker.js +0 -95
  111. package/dist/cloud/build-pipeline.d.ts +0 -39
  112. package/dist/cloud/build-pipeline.js +0 -310
  113. package/dist/cloud/build-queue.d.ts +0 -30
  114. package/dist/cloud/build-queue.js +0 -70
  115. package/dist/cloud/caddy-manager.d.ts +0 -18
  116. package/dist/cloud/caddy-manager.js +0 -97
  117. package/dist/cloud/container-backend.d.ts +0 -62
  118. package/dist/cloud/container-backend.js +0 -59
  119. package/dist/cloud/container-manager.d.ts +0 -64
  120. package/dist/cloud/container-manager.js +0 -301
  121. package/dist/cloud/crypto.d.ts +0 -27
  122. package/dist/cloud/crypto.js +0 -63
  123. package/dist/cloud/db/index.d.ts +0 -27
  124. package/dist/cloud/db/index.js +0 -53
  125. package/dist/cloud/db/migrations.d.ts +0 -12
  126. package/dist/cloud/db/migrations.js +0 -329
  127. package/dist/cloud/db/pg-store.d.ts +0 -45
  128. package/dist/cloud/db/pg-store.js +0 -336
  129. package/dist/cloud/failure-tracker.d.ts +0 -51
  130. package/dist/cloud/failure-tracker.js +0 -102
  131. package/dist/cloud/idle-monitor.d.ts +0 -30
  132. package/dist/cloud/idle-monitor.js +0 -70
  133. package/dist/cloud/mailer.d.ts +0 -21
  134. package/dist/cloud/mailer.js +0 -193
  135. package/dist/cloud/mcp-proxy.d.ts +0 -58
  136. package/dist/cloud/mcp-proxy.js +0 -203
  137. package/dist/cloud/metric-samples.d.ts +0 -43
  138. package/dist/cloud/metric-samples.js +0 -85
  139. package/dist/cloud/metrics.d.ts +0 -26
  140. package/dist/cloud/metrics.js +0 -59
  141. package/dist/cloud/multipart.d.ts +0 -26
  142. package/dist/cloud/multipart.js +0 -132
  143. package/dist/cloud/observability.d.ts +0 -27
  144. package/dist/cloud/observability.js +0 -98
  145. package/dist/cloud/rate-limiter.d.ts +0 -31
  146. package/dist/cloud/rate-limiter.js +0 -58
  147. package/dist/cloud/request-security.d.ts +0 -5
  148. package/dist/cloud/request-security.js +0 -74
  149. package/dist/cloud/resource-monitor.d.ts +0 -69
  150. package/dist/cloud/resource-monitor.js +0 -130
  151. package/dist/cloud/secret-store.d.ts +0 -38
  152. package/dist/cloud/secret-store.js +0 -103
  153. package/dist/cloud/security.d.ts +0 -26
  154. package/dist/cloud/security.js +0 -142
  155. package/dist/cloud/server.d.ts +0 -21
  156. package/dist/cloud/server.js +0 -1079
  157. package/dist/cloud/shared-state.d.ts +0 -72
  158. package/dist/cloud/shared-state.js +0 -159
  159. package/dist/cloud/ssrf.d.ts +0 -43
  160. package/dist/cloud/ssrf.js +0 -150
  161. package/dist/cloud/store.d.ts +0 -41
  162. package/dist/cloud/store.js +0 -75
  163. package/dist/cloud/stripe.d.ts +0 -78
  164. package/dist/cloud/stripe.js +0 -317
  165. package/dist/cloud/telemetry-store.d.ts +0 -53
  166. package/dist/cloud/telemetry-store.js +0 -108
  167. package/dist/cloud/web/auth.d.ts +0 -225
  168. package/dist/cloud/web/auth.js +0 -555
  169. package/dist/cloud/web/charts.d.ts +0 -70
  170. package/dist/cloud/web/charts.js +0 -178
  171. package/dist/cloud/web/csrf.d.ts +0 -14
  172. package/dist/cloud/web/csrf.js +0 -22
  173. package/dist/cloud/web/docs.d.ts +0 -40
  174. package/dist/cloud/web/docs.js +0 -174
  175. package/dist/cloud/web/router.d.ts +0 -25
  176. package/dist/cloud/web/router.js +0 -1921
  177. package/dist/cloud/web/static/alpine.min.js +0 -5
  178. package/dist/cloud/web/static/favicon.svg +0 -4
  179. package/dist/cloud/web/static/htmx-sse.js +0 -290
  180. package/dist/cloud/web/static/htmx.min.js +0 -1
  181. package/dist/cloud/web/static/style.css +0 -2683
  182. package/dist/cloud/web/static-server.d.ts +0 -13
  183. package/dist/cloud/web/static-server.js +0 -73
  184. package/dist/cloud/web/template-engine.d.ts +0 -27
  185. package/dist/cloud/web/template-engine.js +0 -146
  186. package/dist/cloud/web/templates/layouts/admin.hbs +0 -57
  187. package/dist/cloud/web/templates/layouts/auth.hbs +0 -138
  188. package/dist/cloud/web/templates/layouts/base.hbs +0 -16
  189. package/dist/cloud/web/templates/layouts/dashboard.hbs +0 -39
  190. package/dist/cloud/web/templates/layouts/landing.hbs +0 -82
  191. package/dist/cloud/web/templates/pages/admin/overview.hbs +0 -123
  192. package/dist/cloud/web/templates/pages/admin/servers.hbs +0 -129
  193. package/dist/cloud/web/templates/pages/admin/telemetry.hbs +0 -39
  194. package/dist/cloud/web/templates/pages/admin/user-edit.hbs +0 -91
  195. package/dist/cloud/web/templates/pages/admin/users.hbs +0 -179
  196. package/dist/cloud/web/templates/pages/auth/forgot-password.hbs +0 -25
  197. package/dist/cloud/web/templates/pages/auth/login.hbs +0 -33
  198. package/dist/cloud/web/templates/pages/auth/register.hbs +0 -32
  199. package/dist/cloud/web/templates/pages/auth/reset-password.hbs +0 -34
  200. package/dist/cloud/web/templates/pages/dashboard/billing.hbs +0 -140
  201. package/dist/cloud/web/templates/pages/dashboard/create.hbs +0 -173
  202. package/dist/cloud/web/templates/pages/dashboard/index.hbs +0 -8
  203. package/dist/cloud/web/templates/pages/dashboard/server-detail.hbs +0 -280
  204. package/dist/cloud/web/templates/pages/dashboard/server-logs.hbs +0 -35
  205. package/dist/cloud/web/templates/pages/dashboard/server-metrics.hbs +0 -63
  206. package/dist/cloud/web/templates/pages/dashboard/servers-partial.hbs +0 -21
  207. package/dist/cloud/web/templates/pages/dashboard/servers.hbs +0 -44
  208. package/dist/cloud/web/templates/pages/docs/show.hbs +0 -16
  209. package/dist/cloud/web/templates/pages/errors/404.hbs +0 -9
  210. package/dist/cloud/web/templates/pages/errors/500.hbs +0 -8
  211. package/dist/cloud/web/templates/pages/landing/index.hbs +0 -223
  212. package/dist/cloud/web/templates/pages/legal/privacy.hbs +0 -71
  213. package/dist/cloud/web/templates/pages/legal/terms.hbs +0 -73
  214. package/dist/cloud/web/templates/partials/admin-stats.hbs +0 -52
  215. package/dist/cloud/web/templates/partials/flash-message.hbs +0 -6
  216. package/dist/cloud/web/templates/partials/pricing-table.hbs +0 -103
  217. package/dist/cloud/web/templates/partials/server-card.hbs +0 -19
  218. package/dist/cloud/web/templates/partials/status-badge.hbs +0 -1
  219. package/dist/config/configurable-command.d.ts +0 -13
  220. package/dist/config/configurable-command.js +0 -70
  221. package/dist/config/mcpmake-config.d.ts +0 -68
  222. package/dist/config/mcpmake-config.js +0 -207
  223. package/dist/docs/cli.md +0 -400
  224. package/dist/docs/mcp-2026-07-28-migration.md +0 -78
  225. package/dist/docs/migrate-from-stainless.md +0 -94
  226. package/dist/docs/quickstart.md +0 -166
  227. package/dist/docs/show-hn.md +0 -26
  228. package/dist/docs/website-servers.md +0 -169
  229. package/dist/emitter/code-writer.d.ts +0 -8
  230. package/dist/emitter/code-writer.js +0 -25
  231. package/dist/emitter/index.d.ts +0 -32
  232. package/dist/emitter/index.js +0 -280
  233. package/dist/emitter/mcpb-bundler.d.ts +0 -31
  234. package/dist/emitter/mcpb-bundler.js +0 -172
  235. package/dist/emitter/project-scaffolder.d.ts +0 -4
  236. package/dist/emitter/project-scaffolder.js +0 -89
  237. package/dist/emitter/python-template-loader.d.ts +0 -4
  238. package/dist/emitter/python-template-loader.js +0 -30
  239. package/dist/emitter/python-templates/dockerfile.hbs +0 -14
  240. package/dist/emitter/python-templates/env.example.hbs +0 -6
  241. package/dist/emitter/python-templates/requirements.txt.hbs +0 -4
  242. package/dist/emitter/python-templates/server.py.hbs +0 -77
  243. package/dist/emitter/site-scaffolder.d.ts +0 -13
  244. package/dist/emitter/site-scaffolder.js +0 -70
  245. package/dist/emitter/site-template-loader.d.ts +0 -5
  246. package/dist/emitter/site-template-loader.js +0 -47
  247. package/dist/emitter/site-templates/browser-manager.ts.hbs +0 -233
  248. package/dist/emitter/site-templates/config.ts.hbs +0 -28
  249. package/dist/emitter/site-templates/dockerfile.hbs +0 -31
  250. package/dist/emitter/site-templates/env.example.hbs +0 -19
  251. package/dist/emitter/site-templates/package.json.hbs +0 -26
  252. package/dist/emitter/site-templates/server-main-http.ts.hbs +0 -108
  253. package/dist/emitter/site-templates/server-main.ts.hbs +0 -23
  254. package/dist/emitter/site-templates/tool-handler-action.ts.hbs +0 -86
  255. package/dist/emitter/site-templates/tool-handler-form.ts.hbs +0 -116
  256. package/dist/emitter/site-templates/tool-handler-lifecycle.ts.hbs +0 -146
  257. package/dist/emitter/site-templates/tool-index.ts.hbs +0 -11
  258. package/dist/emitter/template-loader.d.ts +0 -1
  259. package/dist/emitter/template-loader.js +0 -27
  260. package/dist/emitter/templates/auth-provider.ts.hbs +0 -57
  261. package/dist/emitter/templates/config.ts.hbs +0 -63
  262. package/dist/emitter/templates/discovery.ts.hbs +0 -301
  263. package/dist/emitter/templates/dockerfile.hbs +0 -34
  264. package/dist/emitter/templates/env.example.hbs +0 -28
  265. package/dist/emitter/templates/gitignore.hbs +0 -5
  266. package/dist/emitter/templates/http-executor.ts.hbs +0 -117
  267. package/dist/emitter/templates/oauth.ts.hbs +0 -188
  268. package/dist/emitter/templates/package.json.hbs +0 -25
  269. package/dist/emitter/templates/prompts.ts.hbs +0 -22
  270. package/dist/emitter/templates/readme.md.hbs +0 -123
  271. package/dist/emitter/templates/resources.ts.hbs +0 -63
  272. package/dist/emitter/templates/server-main-http.ts.hbs +0 -407
  273. package/dist/emitter/templates/server-main.ts.hbs +0 -40
  274. package/dist/emitter/templates/task-handlers.ts.hbs +0 -189
  275. package/dist/emitter/templates/task-manager.ts.hbs +0 -139
  276. package/dist/emitter/templates/task-sse.ts.hbs +0 -105
  277. package/dist/emitter/templates/tool-handler.ts.hbs +0 -124
  278. package/dist/emitter/templates/tool-index.ts.hbs +0 -11
  279. package/dist/emitter/templates/tool-test.ts.hbs +0 -57
  280. package/dist/emitter/templates/trace.ts.hbs +0 -79
  281. package/dist/emitter/templates/tsconfig.json.hbs +0 -16
  282. package/dist/emitter/templates/types.ts.hbs +0 -5
  283. package/dist/emitter/worker-template-loader.d.ts +0 -5
  284. package/dist/emitter/worker-template-loader.js +0 -33
  285. package/dist/emitter/worker-templates/config.ts.hbs +0 -54
  286. package/dist/emitter/worker-templates/dev-vars.example.hbs +0 -10
  287. package/dist/emitter/worker-templates/gitignore.hbs +0 -6
  288. package/dist/emitter/worker-templates/package.json.hbs +0 -24
  289. package/dist/emitter/worker-templates/readme.md.hbs +0 -53
  290. package/dist/emitter/worker-templates/server.test.ts.hbs +0 -20
  291. package/dist/emitter/worker-templates/tool-handler.ts.hbs +0 -85
  292. package/dist/emitter/worker-templates/tool-index.ts.hbs +0 -28
  293. package/dist/emitter/worker-templates/tsconfig.json.hbs +0 -17
  294. package/dist/emitter/worker-templates/worker.ts.hbs +0 -242
  295. package/dist/emitter/worker-templates/wrangler.toml.hbs +0 -19
  296. package/dist/generator/spec-generator.d.ts +0 -6
  297. package/dist/generator/spec-generator.js +0 -50
  298. package/dist/parser/har-filter.d.ts +0 -8
  299. package/dist/parser/har-filter.js +0 -71
  300. package/dist/parser/har-loader.d.ts +0 -2
  301. package/dist/parser/har-loader.js +0 -14
  302. package/dist/parser/har-normalizer.d.ts +0 -20
  303. package/dist/parser/har-normalizer.js +0 -78
  304. package/dist/parser/index.d.ts +0 -10
  305. package/dist/parser/index.js +0 -6
  306. package/dist/parser/openapi-loader.d.ts +0 -6
  307. package/dist/parser/openapi-loader.js +0 -308
  308. package/dist/parser/operation-extractor.d.ts +0 -13
  309. package/dist/parser/operation-extractor.js +0 -155
  310. package/dist/parser/overlay-loader.d.ts +0 -10
  311. package/dist/parser/overlay-loader.js +0 -184
  312. package/dist/parser/postman-loader.d.ts +0 -9
  313. package/dist/parser/postman-loader.js +0 -106
  314. package/dist/parser/schema-converter.d.ts +0 -12
  315. package/dist/parser/schema-converter.js +0 -117
  316. package/dist/plugins/adapter.d.ts +0 -40
  317. package/dist/plugins/adapter.js +0 -15
  318. package/dist/plugins/loader.d.ts +0 -25
  319. package/dist/plugins/loader.js +0 -58
  320. package/dist/pricing.d.ts +0 -55
  321. package/dist/pricing.js +0 -133
  322. package/dist/providers/index.d.ts +0 -15
  323. package/dist/providers/index.js +0 -56
  324. package/dist/recorder/browser-recorder.d.ts +0 -22
  325. package/dist/recorder/browser-recorder.js +0 -205
  326. package/dist/rescan/diff-engine.d.ts +0 -5
  327. package/dist/rescan/diff-engine.js +0 -312
  328. package/dist/rescan/index.d.ts +0 -3
  329. package/dist/rescan/index.js +0 -2
  330. package/dist/rescan/rescan-runner.d.ts +0 -42
  331. package/dist/rescan/rescan-runner.js +0 -69
  332. package/dist/rescan/rescan-scheduler.d.ts +0 -41
  333. package/dist/rescan/rescan-scheduler.js +0 -179
  334. package/dist/site-transformer/browser-tools.d.ts +0 -10
  335. package/dist/site-transformer/browser-tools.js +0 -59
  336. package/dist/site-transformer/index.d.ts +0 -2
  337. package/dist/site-transformer/index.js +0 -2
  338. package/dist/site-transformer/selector-healer.d.ts +0 -8
  339. package/dist/site-transformer/selector-healer.js +0 -106
  340. package/dist/site-transformer/tool-generator.d.ts +0 -13
  341. package/dist/site-transformer/tool-generator.js +0 -245
  342. package/dist/transformer/auth-detector.d.ts +0 -13
  343. package/dist/transformer/auth-detector.js +0 -90
  344. package/dist/transformer/catalog-builder.d.ts +0 -18
  345. package/dist/transformer/catalog-builder.js +0 -56
  346. package/dist/transformer/client-compat.d.ts +0 -6
  347. package/dist/transformer/client-compat.js +0 -44
  348. package/dist/transformer/har-clusterer.d.ts +0 -9
  349. package/dist/transformer/har-clusterer.js +0 -27
  350. package/dist/transformer/har-dedup.d.ts +0 -10
  351. package/dist/transformer/har-dedup.js +0 -81
  352. package/dist/transformer/har-schema-inferrer.d.ts +0 -15
  353. package/dist/transformer/har-schema-inferrer.js +0 -90
  354. package/dist/transformer/har-to-operations.d.ts +0 -13
  355. package/dist/transformer/har-to-operations.js +0 -192
  356. package/dist/transformer/index.d.ts +0 -8
  357. package/dist/transformer/index.js +0 -6
  358. package/dist/transformer/llm-namer.d.ts +0 -6
  359. package/dist/transformer/llm-namer.js +0 -59
  360. package/dist/transformer/naming.d.ts +0 -4
  361. package/dist/transformer/naming.js +0 -30
  362. package/dist/transformer/operation-filter.d.ts +0 -13
  363. package/dist/transformer/operation-filter.js +0 -52
  364. package/dist/transformer/resource-builder.d.ts +0 -12
  365. package/dist/transformer/resource-builder.js +0 -80
  366. package/dist/transformer/schema-merger.d.ts +0 -14
  367. package/dist/transformer/schema-merger.js +0 -65
  368. package/dist/transformer/tool-builder.d.ts +0 -3
  369. package/dist/transformer/tool-builder.js +0 -114
  370. package/dist/types/index.d.ts +0 -131
  371. package/dist/types/index.js +0 -1
  372. package/dist/types/site.d.ts +0 -284
  373. package/dist/types/site.js +0 -8
  374. package/dist/utils/fail.d.ts +0 -48
  375. package/dist/utils/fail.js +0 -204
  376. package/dist/utils/fs.d.ts +0 -5
  377. package/dist/utils/fs.js +0 -28
  378. package/dist/utils/interactive.d.ts +0 -6
  379. package/dist/utils/interactive.js +0 -30
  380. package/dist/utils/logger.d.ts +0 -1
  381. package/dist/utils/logger.js +0 -2
  382. package/dist/utils/sanitize.d.ts +0 -28
  383. package/dist/utils/sanitize.js +0 -44
  384. package/dist/utils/watcher.d.ts +0 -11
  385. package/dist/utils/watcher.js +0 -36
@@ -1,317 +0,0 @@
1
- /**
2
- * Stripe payment integration.
3
- *
4
- * Optional module — if STRIPE_SECRET_KEY is not set, all functions return
5
- * null or throw descriptive errors. Uses dynamic import for the `stripe`
6
- * package to avoid a hard dependency (same pattern as `pg`).
7
- *
8
- * Environment variables:
9
- * STRIPE_SECRET_KEY — Stripe secret API key
10
- * STRIPE_WEBHOOK_SECRET — Webhook endpoint signing secret
11
- * STRIPE_PRICE_HOBBYIST — Price ID for the Hobbyist plan
12
- * STRIPE_PRICE_PRO — Price ID for the Pro plan
13
- * STRIPE_PRICE_TEAM — Price ID for the Team plan
14
- */
15
- import { logger } from '../utils/logger.js';
16
- import { getUserById, getUserByStripeCustomerId, updateUser } from './web/auth.js';
17
- import { getDb } from './shared-state.js';
18
- // ---------------------------------------------------------------------------
19
- // Price ID mapping
20
- // ---------------------------------------------------------------------------
21
- export const PLAN_PRICE_IDS = {
22
- hobbyist: process.env.STRIPE_PRICE_HOBBYIST || '',
23
- pro: process.env.STRIPE_PRICE_PRO || '',
24
- team: process.env.STRIPE_PRICE_TEAM || '',
25
- };
26
- // ---------------------------------------------------------------------------
27
- // Client singleton
28
- // ---------------------------------------------------------------------------
29
- let _stripeClient;
30
- /**
31
- * Get a configured Stripe client. Returns `null` when STRIPE_SECRET_KEY
32
- * is not set. Caches the instance after first successful creation.
33
- */
34
- export async function getStripeClient() {
35
- if (_stripeClient !== undefined)
36
- return _stripeClient;
37
- const secretKey = process.env.STRIPE_SECRET_KEY;
38
- if (!secretKey) {
39
- _stripeClient = null;
40
- return null;
41
- }
42
- try {
43
- // Dynamic import — same indirection trick used for `pg` so TypeScript
44
- // doesn't try to resolve the module at compile time.
45
- let stripeMod;
46
- const mod = 'stripe';
47
- stripeMod = await Function('m', 'return import(m)')(mod);
48
- const Stripe = stripeMod.default ?? stripeMod.Stripe ?? stripeMod;
49
- _stripeClient = new Stripe(secretKey, { apiVersion: '2024-12-18.acacia' });
50
- return _stripeClient;
51
- }
52
- catch (err) {
53
- logger.warn(`Failed to load stripe package: ${err}`);
54
- _stripeClient = null;
55
- return null;
56
- }
57
- }
58
- /**
59
- * Returns true when Stripe is configured (secret key is present).
60
- * Does NOT load the Stripe SDK — just checks the env var.
61
- */
62
- export function isStripeConfigured() {
63
- return !!process.env.STRIPE_SECRET_KEY;
64
- }
65
- // ---------------------------------------------------------------------------
66
- // Checkout
67
- // ---------------------------------------------------------------------------
68
- /**
69
- * Create a Stripe Checkout session for a plan upgrade.
70
- *
71
- * @returns The checkout session URL to redirect the user to.
72
- * @throws If Stripe is not configured or the plan has no price ID.
73
- */
74
- export async function createCheckoutSession(opts) {
75
- const stripe = await getStripeClient();
76
- if (!stripe) {
77
- throw new Error('Stripe is not configured');
78
- }
79
- const priceId = PLAN_PRICE_IDS[opts.plan];
80
- if (!priceId) {
81
- throw new Error(`No Stripe price ID configured for plan "${opts.plan}"`);
82
- }
83
- const session = await stripe.checkout.sessions.create({
84
- mode: 'subscription',
85
- customer_email: opts.email,
86
- line_items: [{ price: priceId, quantity: 1 }],
87
- success_url: opts.successUrl,
88
- cancel_url: opts.cancelUrl,
89
- client_reference_id: opts.userId,
90
- metadata: {
91
- userId: opts.userId,
92
- plan: opts.plan,
93
- },
94
- // Propagate metadata onto the Subscription so that subscription.updated /
95
- // subscription.deleted webhooks can resolve the user (they read
96
- // subscription.metadata, not the checkout session's metadata).
97
- subscription_data: {
98
- metadata: {
99
- userId: opts.userId,
100
- plan: opts.plan,
101
- },
102
- },
103
- });
104
- if (!session.url) {
105
- throw new Error('Stripe did not return a checkout URL');
106
- }
107
- return session.url;
108
- }
109
- // ---------------------------------------------------------------------------
110
- // Billing portal
111
- // ---------------------------------------------------------------------------
112
- /**
113
- * Create a Stripe billing portal session so the customer can manage
114
- * their subscription (cancel, change payment method, view invoices).
115
- *
116
- * @returns The portal session URL to redirect the user to.
117
- */
118
- export async function createPortalSession(customerId, returnUrl) {
119
- const stripe = await getStripeClient();
120
- if (!stripe) {
121
- throw new Error('Stripe is not configured');
122
- }
123
- const session = await stripe.billingPortal.sessions.create({
124
- customer: customerId,
125
- return_url: returnUrl,
126
- });
127
- return session.url;
128
- }
129
- // ---------------------------------------------------------------------------
130
- // Webhook handler
131
- // ---------------------------------------------------------------------------
132
- // ---------------------------------------------------------------------------
133
- // Webhook idempotency
134
- // ---------------------------------------------------------------------------
135
- /** In-memory fallback ledger of processed event IDs (used when no DB). */
136
- const recentEventIds = new Set();
137
- const MAX_RECENT_EVENTS = 5_000;
138
- /** Whether this Stripe event has already been processed (replay protection). */
139
- async function alreadyProcessed(eventId) {
140
- const db = getDb();
141
- if (db) {
142
- const { rows } = await db.query('SELECT id FROM processed_stripe_events WHERE id = $1', [eventId]);
143
- return rows.length > 0;
144
- }
145
- return recentEventIds.has(eventId);
146
- }
147
- /** Record an event as processed. Called only after successful handling so a
148
- * failed delivery is re-tried by Stripe rather than silently dropped. */
149
- async function markProcessed(eventId) {
150
- const db = getDb();
151
- if (db) {
152
- await db.query('INSERT INTO processed_stripe_events (id) VALUES ($1) ON CONFLICT (id) DO NOTHING', [eventId]);
153
- return;
154
- }
155
- recentEventIds.add(eventId);
156
- if (recentEventIds.size > MAX_RECENT_EVENTS) {
157
- const keep = [...recentEventIds].slice(-Math.floor(MAX_RECENT_EVENTS / 2));
158
- recentEventIds.clear();
159
- for (const id of keep)
160
- recentEventIds.add(id);
161
- }
162
- }
163
- /** Map Stripe price IDs back to plan names. */
164
- function planFromPriceId(priceId) {
165
- for (const [plan, id] of Object.entries(PLAN_PRICE_IDS)) {
166
- if (id && id === priceId)
167
- return plan;
168
- }
169
- return undefined;
170
- }
171
- /**
172
- * Verify and handle an incoming Stripe webhook event.
173
- *
174
- * Handles:
175
- * - checkout.session.completed — activate subscription, store customer ID
176
- * - customer.subscription.updated — plan change / renewal
177
- * - customer.subscription.deleted — cancellation, downgrade to free
178
- *
179
- * @param payload - The raw request body as a Buffer (required for signature verification)
180
- * @param signature - The `stripe-signature` header value
181
- */
182
- export async function handleWebhookEvent(payload, signature) {
183
- const stripe = await getStripeClient();
184
- if (!stripe) {
185
- throw new Error('Stripe is not configured');
186
- }
187
- const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;
188
- if (!webhookSecret) {
189
- throw new Error('STRIPE_WEBHOOK_SECRET is not set');
190
- }
191
- // Verify signature — throws on invalid signature
192
- const event = stripe.webhooks.constructEvent(payload, signature, webhookSecret);
193
- // Idempotency: Stripe may deliver the same event more than once. Skip events
194
- // we've already applied so a replay can't double-apply a plan change.
195
- if (event.id && (await alreadyProcessed(event.id))) {
196
- logger.info(`[stripe] Duplicate webhook ${event.id} (${event.type}) ignored`);
197
- return;
198
- }
199
- switch (event.type) {
200
- case 'checkout.session.completed': {
201
- await handleCheckoutCompleted(event.data.object);
202
- break;
203
- }
204
- case 'customer.subscription.updated': {
205
- await handleSubscriptionUpdated(event.data.object);
206
- break;
207
- }
208
- case 'customer.subscription.deleted': {
209
- await handleSubscriptionDeleted(event.data.object);
210
- break;
211
- }
212
- default:
213
- logger.info(`[stripe] Unhandled webhook event type: ${event.type}`);
214
- }
215
- // Mark processed only after successful handling (above throws propagate to the
216
- // caller → 400 → Stripe retries, which is what we want on a transient failure).
217
- if (event.id)
218
- await markProcessed(event.id);
219
- }
220
- /**
221
- * Handle checkout.session.completed — the user just completed payment.
222
- * Save the Stripe customer ID on the user and upgrade their plan.
223
- */
224
- async function handleCheckoutCompleted(session) {
225
- const userId = session.client_reference_id ?? session.metadata?.userId;
226
- const plan = session.metadata?.plan;
227
- const customerId = session.customer;
228
- if (!userId) {
229
- logger.warn('[stripe] checkout.session.completed missing client_reference_id');
230
- return;
231
- }
232
- const user = await getUserById(userId);
233
- if (!user) {
234
- logger.warn(`[stripe] checkout.session.completed: user ${userId} not found`);
235
- return;
236
- }
237
- const updates = {
238
- stripeCustomerId: customerId,
239
- };
240
- if (plan && ['hobbyist', 'pro', 'team', 'enterprise'].includes(plan)) {
241
- updates.plan = plan;
242
- }
243
- await updateUser(userId, updates);
244
- logger.info(`[stripe] User ${userId} upgraded to ${plan ?? 'unknown'}, customer=${customerId}`);
245
- }
246
- /**
247
- * Resolve the local user for a Stripe subscription. Prefers the userId stored
248
- * in subscription metadata (set via subscription_data.metadata at checkout),
249
- * and falls back to looking up by the Stripe customer ID so that subscriptions
250
- * created without metadata (or before this fix) are still attributed.
251
- */
252
- async function resolveSubscriptionUserId(subscription) {
253
- const fromMetadata = subscription.metadata?.userId;
254
- if (fromMetadata)
255
- return fromMetadata;
256
- const customerId = subscription.customer;
257
- if (customerId && typeof customerId === 'string') {
258
- const user = await getUserByStripeCustomerId(customerId);
259
- if (user)
260
- return user.id;
261
- }
262
- return undefined;
263
- }
264
- /** Extract the current period end (epoch ms) from a subscription, if present. */
265
- function periodEndMs(subscription) {
266
- const seconds = subscription.current_period_end;
267
- return typeof seconds === 'number' ? seconds * 1000 : undefined;
268
- }
269
- /**
270
- * Handle customer.subscription.updated — plan change or renewal.
271
- * Look up the user by metadata or customer ID and update their plan + period.
272
- */
273
- async function handleSubscriptionUpdated(subscription) {
274
- const userId = await resolveSubscriptionUserId(subscription);
275
- if (!userId) {
276
- logger.warn('[stripe] subscription.updated: could not resolve user — skipping');
277
- return;
278
- }
279
- const user = await getUserById(userId);
280
- if (!user) {
281
- logger.warn(`[stripe] subscription.updated: user ${userId} not found`);
282
- return;
283
- }
284
- const updates = {};
285
- // Determine the new plan from the first subscription item's price.
286
- const items = subscription.items?.data;
287
- const priceId = items?.[0]?.price?.id;
288
- const plan = priceId ? planFromPriceId(priceId) : undefined;
289
- if (plan)
290
- updates.plan = plan;
291
- // Capture the billing period anchor so usage quotas align to the subscription.
292
- const end = periodEndMs(subscription);
293
- if (end)
294
- updates.subscriptionPeriodEnd = end;
295
- if (Object.keys(updates).length === 0)
296
- return;
297
- await updateUser(userId, updates);
298
- logger.info(`[stripe] User ${userId} subscription updated (plan: ${plan ?? 'unchanged'})`);
299
- }
300
- /**
301
- * Handle customer.subscription.deleted — cancellation.
302
- * Downgrade the user to the free plan.
303
- */
304
- async function handleSubscriptionDeleted(subscription) {
305
- const userId = await resolveSubscriptionUserId(subscription);
306
- if (!userId) {
307
- logger.warn('[stripe] subscription.deleted: could not resolve user — skipping');
308
- return;
309
- }
310
- const user = await getUserById(userId);
311
- if (!user) {
312
- logger.warn(`[stripe] subscription.deleted: user ${userId} not found`);
313
- return;
314
- }
315
- await updateUser(userId, { plan: 'free' });
316
- logger.info(`[stripe] User ${userId} subscription canceled — downgraded to free`);
317
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Storage for CLI crash/error reports received at POST /api/telemetry/report.
3
- *
4
- * Reports are already validated, whitelisted, truncated, and stripped of PII
5
- * (home-dir paths / tokens) by the time they reach here — the endpoint and the
6
- * CLI's `fail()` helper own that. This layer only persists and groups them.
7
- *
8
- * Backed by the `telemetry_reports` Postgres table when a database is
9
- * configured; otherwise a bounded in-memory ring (dev / single-process).
10
- */
11
- import type { Database } from './db/index.js';
12
- export interface TelemetryReport {
13
- receivedAt: string;
14
- /** Hashed client IP (never the raw address). */
15
- clientIp: string;
16
- cliVersion: string;
17
- platform: string;
18
- nodeVersion: string;
19
- command: string;
20
- errorMessage: string;
21
- stack: string;
22
- /** Hash of (command + normalized message) — groups duplicate failures. */
23
- fingerprint: string;
24
- }
25
- /** A group of reports sharing a fingerprint, for the admin view. */
26
- export interface TelemetryGroup {
27
- fingerprint: string;
28
- count: number;
29
- lastSeen: string;
30
- command: string;
31
- errorMessage: string;
32
- cliVersion: string;
33
- platform: string;
34
- }
35
- export interface TelemetryStore {
36
- save(report: TelemetryReport): Promise<void>;
37
- /** Most-recent reports grouped by fingerprint (most recent first). */
38
- recentGrouped(limit: number): Promise<TelemetryGroup[]>;
39
- prune(olderThanMs: number): Promise<void>;
40
- }
41
- export declare class InMemoryTelemetryStore implements TelemetryStore {
42
- private reports;
43
- save(report: TelemetryReport): Promise<void>;
44
- recentGrouped(limit: number): Promise<TelemetryGroup[]>;
45
- prune(olderThanMs: number): Promise<void>;
46
- }
47
- export declare class PgTelemetryStore implements TelemetryStore {
48
- private db;
49
- constructor(db: Database);
50
- save(report: TelemetryReport): Promise<void>;
51
- recentGrouped(limit: number): Promise<TelemetryGroup[]>;
52
- prune(olderThanMs: number): Promise<void>;
53
- }
@@ -1,108 +0,0 @@
1
- /**
2
- * Storage for CLI crash/error reports received at POST /api/telemetry/report.
3
- *
4
- * Reports are already validated, whitelisted, truncated, and stripped of PII
5
- * (home-dir paths / tokens) by the time they reach here — the endpoint and the
6
- * CLI's `fail()` helper own that. This layer only persists and groups them.
7
- *
8
- * Backed by the `telemetry_reports` Postgres table when a database is
9
- * configured; otherwise a bounded in-memory ring (dev / single-process).
10
- */
11
- import { randomBytes } from 'node:crypto';
12
- // ---------------------------------------------------------------------------
13
- // In-memory (dev / no database) — bounded ring
14
- // ---------------------------------------------------------------------------
15
- const MAX_INMEMORY_REPORTS = 1_000;
16
- export class InMemoryTelemetryStore {
17
- reports = [];
18
- async save(report) {
19
- this.reports.push(report);
20
- if (this.reports.length > MAX_INMEMORY_REPORTS) {
21
- this.reports.splice(0, this.reports.length - MAX_INMEMORY_REPORTS);
22
- }
23
- }
24
- async recentGrouped(limit) {
25
- const groups = new Map();
26
- // Iterate newest-first so each group keeps the latest sample fields.
27
- for (let i = this.reports.length - 1; i >= 0; i--) {
28
- const r = this.reports[i];
29
- const existing = groups.get(r.fingerprint);
30
- if (existing) {
31
- existing.count++;
32
- if (r.receivedAt > existing.lastSeen)
33
- existing.lastSeen = r.receivedAt;
34
- }
35
- else {
36
- groups.set(r.fingerprint, {
37
- fingerprint: r.fingerprint,
38
- count: 1,
39
- lastSeen: r.receivedAt,
40
- command: r.command,
41
- errorMessage: r.errorMessage,
42
- cliVersion: r.cliVersion,
43
- platform: r.platform,
44
- });
45
- }
46
- }
47
- return [...groups.values()].sort((a, b) => (a.lastSeen < b.lastSeen ? 1 : -1)).slice(0, limit);
48
- }
49
- async prune(olderThanMs) {
50
- const cutoff = Date.now() - olderThanMs;
51
- this.reports = this.reports.filter((r) => Date.parse(r.receivedAt) >= cutoff);
52
- }
53
- }
54
- // ---------------------------------------------------------------------------
55
- // Postgres
56
- // ---------------------------------------------------------------------------
57
- export class PgTelemetryStore {
58
- db;
59
- constructor(db) {
60
- this.db = db;
61
- }
62
- async save(report) {
63
- await this.db.query(`INSERT INTO telemetry_reports
64
- (id, received_at, client_ip, cli_version, platform, node_version,
65
- command, error_message, stack, fingerprint)
66
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`, [
67
- randomBytes(16).toString('hex'),
68
- report.receivedAt,
69
- report.clientIp,
70
- report.cliVersion,
71
- report.platform,
72
- report.nodeVersion,
73
- report.command,
74
- report.errorMessage,
75
- report.stack,
76
- report.fingerprint,
77
- ]);
78
- }
79
- async recentGrouped(limit) {
80
- const { rows } = await this.db.query(`SELECT fingerprint,
81
- count(*) AS count,
82
- max(received_at) AS last_seen,
83
- (array_agg(command ORDER BY received_at DESC))[1] AS command,
84
- (array_agg(error_message ORDER BY received_at DESC))[1] AS error_message,
85
- (array_agg(cli_version ORDER BY received_at DESC))[1] AS cli_version,
86
- (array_agg(platform ORDER BY received_at DESC))[1] AS platform
87
- FROM telemetry_reports
88
- GROUP BY fingerprint
89
- ORDER BY last_seen DESC
90
- LIMIT $1`, [limit]);
91
- return rows.map((row) => {
92
- const lastSeen = row.last_seen;
93
- return {
94
- fingerprint: String(row.fingerprint ?? ''),
95
- count: typeof row.count === 'number' ? row.count : Number(row.count ?? 0),
96
- lastSeen: typeof lastSeen === 'string' ? lastSeen : new Date(lastSeen).toISOString(),
97
- command: String(row.command ?? ''),
98
- errorMessage: String(row.error_message ?? ''),
99
- cliVersion: String(row.cli_version ?? ''),
100
- platform: String(row.platform ?? ''),
101
- };
102
- });
103
- }
104
- async prune(olderThanMs) {
105
- const cutoff = new Date(Date.now() - olderThanMs).toISOString();
106
- await this.db.query('DELETE FROM telemetry_reports WHERE received_at < $1', [cutoff]);
107
- }
108
- }