skybridge 0.0.0-next.45dfd29 → 0.0.0-next.494efb5

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 (298) hide show
  1. package/README.md +8 -7
  2. package/dist/cli/build-helpers.d.ts +1 -1
  3. package/dist/cli/build-helpers.js +4 -4
  4. package/dist/cli/build-helpers.js.map +1 -1
  5. package/dist/cli/build-helpers.test.js +2 -2
  6. package/dist/cli/build-helpers.test.js.map +1 -1
  7. package/dist/cli/build-steps.js +1 -1
  8. package/dist/cli/build-steps.js.map +1 -1
  9. package/dist/cli/build-steps.test.js +3 -3
  10. package/dist/cli/build-steps.test.js.map +1 -1
  11. package/dist/cli/detect-port.js +0 -1
  12. package/dist/cli/detect-port.js.map +1 -1
  13. package/dist/cli/run-plain.js +2 -1
  14. package/dist/cli/run-plain.js.map +1 -1
  15. package/dist/cli/telemetry.js +2 -0
  16. package/dist/cli/telemetry.js.map +1 -1
  17. package/dist/cli/use-execute-steps.d.ts +1 -1
  18. package/dist/cli/use-nodemon.d.ts +11 -1
  19. package/dist/cli/use-nodemon.js +30 -8
  20. package/dist/cli/use-nodemon.js.map +1 -1
  21. package/dist/cli/use-typescript-check.js +1 -1
  22. package/dist/cli/use-typescript-check.js.map +1 -1
  23. package/dist/commands/dev.js +4 -4
  24. package/dist/commands/dev.js.map +1 -1
  25. package/dist/commands/start.js +2 -2
  26. package/dist/commands/start.js.map +1 -1
  27. package/dist/context-warnings.d.ts +5 -0
  28. package/dist/context-warnings.js +31 -0
  29. package/dist/context-warnings.js.map +1 -0
  30. package/dist/context-warnings.test.js +28 -0
  31. package/dist/context-warnings.test.js.map +1 -0
  32. package/dist/server/app.d.ts +194 -0
  33. package/dist/server/app.js +266 -0
  34. package/dist/server/app.js.map +1 -0
  35. package/dist/server/app.test.js +97 -0
  36. package/dist/server/app.test.js.map +1 -0
  37. package/dist/server/auth/discovery.d.ts +2 -1
  38. package/dist/server/auth/discovery.js +2 -2
  39. package/dist/server/auth/discovery.js.map +1 -1
  40. package/dist/server/auth/index.d.ts +35 -5
  41. package/dist/server/auth/index.js.map +1 -1
  42. package/dist/server/auth/providers/auth0.d.ts +25 -3
  43. package/dist/server/auth/providers/auth0.js +13 -8
  44. package/dist/server/auth/providers/auth0.js.map +1 -1
  45. package/dist/server/auth/providers/auth0.test.js +5 -3
  46. package/dist/server/auth/providers/auth0.test.js.map +1 -1
  47. package/dist/server/auth/providers/authplane.d.ts +4 -2
  48. package/dist/server/auth/providers/authplane.js.map +1 -1
  49. package/dist/server/auth/providers/authplane.test.js +23 -18
  50. package/dist/server/auth/providers/authplane.test.js.map +1 -1
  51. package/dist/server/auth/providers/clerk.d.ts +40 -3
  52. package/dist/server/auth/providers/clerk.js +4 -1
  53. package/dist/server/auth/providers/clerk.js.map +1 -1
  54. package/dist/server/auth/providers/clerk.test.js +5 -3
  55. package/dist/server/auth/providers/clerk.test.js.map +1 -1
  56. package/dist/server/auth/providers/custom.d.ts +16 -6
  57. package/dist/server/auth/providers/custom.js +14 -4
  58. package/dist/server/auth/providers/custom.js.map +1 -1
  59. package/dist/server/auth/providers/custom.test.js +24 -19
  60. package/dist/server/auth/providers/custom.test.js.map +1 -1
  61. package/dist/server/auth/providers/descope.d.ts +32 -3
  62. package/dist/server/auth/providers/descope.js.map +1 -1
  63. package/dist/server/auth/providers/descope.test.js +8 -6
  64. package/dist/server/auth/providers/descope.test.js.map +1 -1
  65. package/dist/server/auth/providers/stytch.d.ts +16 -3
  66. package/dist/server/auth/providers/stytch.js +4 -1
  67. package/dist/server/auth/providers/stytch.js.map +1 -1
  68. package/dist/server/auth/providers/verify-spy.d.ts +12 -0
  69. package/dist/server/auth/providers/verify-spy.js +21 -0
  70. package/dist/server/auth/providers/verify-spy.js.map +1 -0
  71. package/dist/server/auth/providers/workos.d.ts +28 -5
  72. package/dist/server/auth/providers/workos.js +6 -2
  73. package/dist/server/auth/providers/workos.js.map +1 -1
  74. package/dist/server/auth/setup.d.ts +1 -1
  75. package/dist/server/auth/setup.js +4 -5
  76. package/dist/server/auth/setup.js.map +1 -1
  77. package/dist/server/auth/setup.test.js +97 -57
  78. package/dist/server/auth/setup.test.js.map +1 -1
  79. package/dist/server/auth/verify.d.ts +42 -6
  80. package/dist/server/auth/verify.js +27 -3
  81. package/dist/server/auth/verify.js.map +1 -1
  82. package/dist/server/auth/verify.test.js +65 -0
  83. package/dist/server/auth/verify.test.js.map +1 -1
  84. package/dist/server/auth-extra.test-d.js +130 -0
  85. package/dist/server/auth-extra.test-d.js.map +1 -0
  86. package/dist/server/auth.d.ts +43 -6
  87. package/dist/server/auth.js +4 -5
  88. package/dist/server/auth.js.map +1 -1
  89. package/dist/server/build-manifest.test.js +7 -6
  90. package/dist/server/build-manifest.test.js.map +1 -1
  91. package/dist/server/content-helpers.d.ts +1 -1
  92. package/dist/server/content-helpers.js.map +1 -1
  93. package/dist/server/express.d.ts +23 -3
  94. package/dist/server/express.js +38 -32
  95. package/dist/server/express.js.map +1 -1
  96. package/dist/server/express.test.js +220 -103
  97. package/dist/server/express.test.js.map +1 -1
  98. package/dist/server/file-ref.d.ts +1 -1
  99. package/dist/server/file-ref.js +1 -1
  100. package/dist/server/file-ref.js.map +1 -1
  101. package/dist/server/index.d.ts +13 -8
  102. package/dist/server/index.js +6 -2
  103. package/dist/server/index.js.map +1 -1
  104. package/dist/server/mcp-errors.test.js +41 -0
  105. package/dist/server/mcp-errors.test.js.map +1 -0
  106. package/dist/server/middleware.d.ts +35 -10
  107. package/dist/server/middleware.js +33 -0
  108. package/dist/server/middleware.js.map +1 -1
  109. package/dist/server/middleware.test-d.js +1 -1
  110. package/dist/server/middleware.test-d.js.map +1 -1
  111. package/dist/server/middleware.test.js +242 -134
  112. package/dist/server/middleware.test.js.map +1 -1
  113. package/dist/server/register-tool.test.js +77 -0
  114. package/dist/server/register-tool.test.js.map +1 -0
  115. package/dist/server/server.d.ts +161 -120
  116. package/dist/server/server.js +155 -304
  117. package/dist/server/server.js.map +1 -1
  118. package/dist/server/skills-integration.test.js +19 -12
  119. package/dist/server/skills-integration.test.js.map +1 -1
  120. package/dist/server/skills.d.ts +3 -5
  121. package/dist/server/skills.js +17 -24
  122. package/dist/server/skills.js.map +1 -1
  123. package/dist/server/skills.test.js +8 -12
  124. package/dist/server/skills.test.js.map +1 -1
  125. package/dist/server/templateHelper.d.ts +0 -3
  126. package/dist/server/templateHelper.js.map +1 -1
  127. package/dist/server/templates.generated.js +4 -8
  128. package/dist/server/templates.generated.js.map +1 -1
  129. package/dist/server/tool-extra.test.js +88 -0
  130. package/dist/server/tool-extra.test.js.map +1 -0
  131. package/dist/server/view-resource-resolution.test.js +18 -13
  132. package/dist/server/view-resource-resolution.test.js.map +1 -1
  133. package/dist/test/utils.d.ts +9 -11
  134. package/dist/test/utils.js +220 -201
  135. package/dist/test/utils.js.map +1 -1
  136. package/dist/test/view.test.js +41 -37
  137. package/dist/test/view.test.js.map +1 -1
  138. package/dist/views/index.d.ts +10 -0
  139. package/dist/views/index.js +3 -0
  140. package/dist/views/index.js.map +1 -0
  141. package/dist/{web/plugin → views}/scan-views.js +1 -1
  142. package/dist/views/scan-views.js.map +1 -0
  143. package/dist/views/scan-views.test.js.map +1 -0
  144. package/dist/views/validate-view.d.ts +1 -0
  145. package/dist/{web/plugin → views}/validate-view.js +2 -2
  146. package/dist/views/validate-view.js.map +1 -0
  147. package/dist/views/validate-view.test.js.map +1 -0
  148. package/dist/web/bridges/adaptor.d.ts +6 -2
  149. package/dist/web/bridges/adaptor.js +64 -25
  150. package/dist/web/bridges/adaptor.js.map +1 -1
  151. package/dist/web/bridges/adaptor.test.js +12 -5
  152. package/dist/web/bridges/adaptor.test.js.map +1 -1
  153. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +1 -1
  154. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +1 -1
  155. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  156. package/dist/web/bridges/get-adaptor.test.js +2 -2
  157. package/dist/web/bridges/get-adaptor.test.js.map +1 -1
  158. package/dist/web/bridges/mcp-app/bridge.d.ts +1 -1
  159. package/dist/web/bridges/mcp-app/bridge.js +10 -3
  160. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  161. package/dist/web/bridges/mcp-app/bridge.test.js +2 -2
  162. package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -1
  163. package/dist/web/bridges/mcp-app/types.d.ts +18 -3
  164. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  165. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +2 -2
  166. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +1 -1
  167. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  168. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
  169. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  170. package/dist/web/bridges/mcp-app/view-tools.test.js +1 -1
  171. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -1
  172. package/dist/web/bridges/types.d.ts +31 -14
  173. package/dist/web/bridges/types.js.map +1 -1
  174. package/dist/web/create-store.test.js +2 -2
  175. package/dist/web/create-store.test.js.map +1 -1
  176. package/dist/web/data-llm.js +3 -2
  177. package/dist/web/data-llm.js.map +1 -1
  178. package/dist/web/data-llm.test.js +11 -4
  179. package/dist/web/data-llm.test.js.map +1 -1
  180. package/dist/web/generate-helpers.d.ts +23 -19
  181. package/dist/web/generate-helpers.js +21 -17
  182. package/dist/web/generate-helpers.js.map +1 -1
  183. package/dist/web/generate-helpers.test-d.js +3 -3
  184. package/dist/web/generate-helpers.test-d.js.map +1 -1
  185. package/dist/web/generate-helpers.test.js +2 -2
  186. package/dist/web/generate-helpers.test.js.map +1 -1
  187. package/dist/web/hooks/index.d.ts +4 -2
  188. package/dist/web/hooks/index.js +4 -2
  189. package/dist/web/hooks/index.js.map +1 -1
  190. package/dist/web/hooks/openai-extensions.test.d.ts +1 -0
  191. package/dist/web/hooks/openai-extensions.test.js +107 -0
  192. package/dist/web/hooks/openai-extensions.test.js.map +1 -0
  193. package/dist/web/hooks/use-call-tool.d.ts +2 -2
  194. package/dist/web/hooks/use-call-tool.js +15 -10
  195. package/dist/web/hooks/use-call-tool.js.map +1 -1
  196. package/dist/web/hooks/use-call-tool.test.js +15 -4
  197. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  198. package/dist/web/hooks/use-deep-link.d.ts +22 -0
  199. package/dist/web/hooks/use-deep-link.js +34 -0
  200. package/dist/web/hooks/use-deep-link.js.map +1 -0
  201. package/dist/web/hooks/use-display-mode.d.ts +1 -1
  202. package/dist/web/hooks/use-display-mode.js +1 -1
  203. package/dist/web/hooks/use-display-mode.js.map +1 -1
  204. package/dist/web/hooks/use-display-mode.test.js +1 -1
  205. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  206. package/dist/web/hooks/use-download.d.ts +1 -3
  207. package/dist/web/hooks/use-download.js +1 -2
  208. package/dist/web/hooks/use-download.js.map +1 -1
  209. package/dist/web/hooks/use-download.test.js +7 -7
  210. package/dist/web/hooks/use-download.test.js.map +1 -1
  211. package/dist/web/hooks/use-files.test.js +1 -1
  212. package/dist/web/hooks/use-files.test.js.map +1 -1
  213. package/dist/web/hooks/use-host.d.ts +44 -0
  214. package/dist/web/hooks/use-host.js +45 -0
  215. package/dist/web/hooks/use-host.js.map +1 -0
  216. package/dist/web/hooks/use-host.test.d.ts +1 -0
  217. package/dist/web/hooks/{use-host-info.test.js → use-host.test.js} +7 -7
  218. package/dist/web/hooks/use-host.test.js.map +1 -0
  219. package/dist/web/hooks/use-model-context.d.ts +44 -0
  220. package/dist/web/hooks/use-model-context.js +63 -0
  221. package/dist/web/hooks/use-model-context.js.map +1 -0
  222. package/dist/web/hooks/use-open-external.test.js +2 -2
  223. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  224. package/dist/web/hooks/use-register-view-tool.d.ts +2 -3
  225. package/dist/web/hooks/use-register-view-tool.js.map +1 -1
  226. package/dist/web/hooks/use-request-close.test.js +1 -1
  227. package/dist/web/hooks/use-request-close.test.js.map +1 -1
  228. package/dist/web/hooks/use-request-modal.test.js +1 -1
  229. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  230. package/dist/web/hooks/use-request-size.d.ts +1 -1
  231. package/dist/web/hooks/use-request-size.js +1 -1
  232. package/dist/web/hooks/use-request-size.js.map +1 -1
  233. package/dist/web/hooks/use-request-size.test.js +1 -1
  234. package/dist/web/hooks/use-request-size.test.js.map +1 -1
  235. package/dist/web/hooks/use-set-open-in-app-url.test.js +2 -8
  236. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  237. package/dist/web/hooks/use-tool-info.d.ts +1 -20
  238. package/dist/web/hooks/use-tool-info.js +0 -1
  239. package/dist/web/hooks/use-tool-info.js.map +1 -1
  240. package/dist/web/hooks/use-tool-info.test-d.js +0 -5
  241. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  242. package/dist/web/hooks/use-tool-info.test.js +2 -7
  243. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  244. package/dist/web/hooks/use-user.d.ts +3 -2
  245. package/dist/web/hooks/use-user.js +4 -3
  246. package/dist/web/hooks/use-user.js.map +1 -1
  247. package/dist/web/hooks/use-user.test.js +5 -3
  248. package/dist/web/hooks/use-user.test.js.map +1 -1
  249. package/dist/web/hooks/use-view-state.test.js +2 -2
  250. package/dist/web/hooks/use-view-state.test.js.map +1 -1
  251. package/dist/web/hooks/use-viewport.d.ts +20 -0
  252. package/dist/web/hooks/use-viewport.js +21 -0
  253. package/dist/web/hooks/use-viewport.js.map +1 -0
  254. package/dist/web/hooks/use-viewport.test.d.ts +1 -0
  255. package/dist/web/hooks/{use-layout.test.js → use-viewport.test.js} +12 -32
  256. package/dist/web/hooks/use-viewport.test.js.map +1 -0
  257. package/dist/web/mount-view.d.ts +3 -2
  258. package/dist/web/mount-view.js +5 -8
  259. package/dist/web/mount-view.js.map +1 -1
  260. package/package.json +14 -12
  261. package/dist/web/hooks/use-host-info.d.ts +0 -22
  262. package/dist/web/hooks/use-host-info.js +0 -30
  263. package/dist/web/hooks/use-host-info.js.map +0 -1
  264. package/dist/web/hooks/use-host-info.test.js.map +0 -1
  265. package/dist/web/hooks/use-layout.d.ts +0 -24
  266. package/dist/web/hooks/use-layout.js +0 -25
  267. package/dist/web/hooks/use-layout.js.map +0 -1
  268. package/dist/web/hooks/use-layout.test.js.map +0 -1
  269. package/dist/web/plugin/data-llm.test.js +0 -81
  270. package/dist/web/plugin/data-llm.test.js.map +0 -1
  271. package/dist/web/plugin/plugin-build.test.js +0 -54
  272. package/dist/web/plugin/plugin-build.test.js.map +0 -1
  273. package/dist/web/plugin/plugin.d.ts +0 -39
  274. package/dist/web/plugin/plugin.js +0 -200
  275. package/dist/web/plugin/plugin.js.map +0 -1
  276. package/dist/web/plugin/plugin.test.js +0 -61
  277. package/dist/web/plugin/plugin.test.js.map +0 -1
  278. package/dist/web/plugin/scan-views.js.map +0 -1
  279. package/dist/web/plugin/scan-views.test.js.map +0 -1
  280. package/dist/web/plugin/transform-data-llm.d.ts +0 -12
  281. package/dist/web/plugin/transform-data-llm.js +0 -96
  282. package/dist/web/plugin/transform-data-llm.js.map +0 -1
  283. package/dist/web/plugin/transform-data-llm.test.js +0 -81
  284. package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
  285. package/dist/web/plugin/validate-view.d.ts +0 -1
  286. package/dist/web/plugin/validate-view.js.map +0 -1
  287. package/dist/web/plugin/validate-view.test.js.map +0 -1
  288. /package/dist/{web/hooks/use-host-info.test.d.ts → context-warnings.test.d.ts} +0 -0
  289. /package/dist/{web/hooks/use-layout.test.d.ts → server/app.test.d.ts} +0 -0
  290. /package/dist/{web/plugin/data-llm.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
  291. /package/dist/{web/plugin/plugin-build.test.d.ts → server/mcp-errors.test.d.ts} +0 -0
  292. /package/dist/{web/plugin/plugin.test.d.ts → server/register-tool.test.d.ts} +0 -0
  293. /package/dist/{web/plugin/scan-views.test.d.ts → server/tool-extra.test.d.ts} +0 -0
  294. /package/dist/{web/plugin → views}/scan-views.d.ts +0 -0
  295. /package/dist/{web/plugin/transform-data-llm.test.d.ts → views/scan-views.test.d.ts} +0 -0
  296. /package/dist/{web/plugin → views}/scan-views.test.js +0 -0
  297. /package/dist/{web/plugin → views}/validate-view.test.d.ts +0 -0
  298. /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"use-nodemon.js","sourceRoot":"","sources":["../../src/cli/use-nodemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,eAAe,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,MAAM,OAAO,GAAG,eAAkC,CAAC;AAEnD,MAAM,iBAAiB,GAAG,qDAAqD,CAAC;AAWhF;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAsB,EACtB,QAAyB;IAEzB,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC;QACnC,CAAC,CAAC;YACE,UAAU;SACX;QACH,CAAC,CAAC;YACE,KAAK,EAAE,CAAC,KAAK,CAAC;YACd,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,mBAAmB;SAC1B,CAAC;IAEN,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAE3C,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAE,EAAE;QACzC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,MAAM,gBAAgB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CAAC,KAAK,CAAC,CAAC;QAC1B,mBAAmB,EAAE,CAAC;QACtB,mBAAmB,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,GAAsB,EACtB,WAAwB;IAExB,SAAS,CACP,GAAG,EAAE,CACH,YAAY,CAAC,GAAG,EAAE;QAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,IAAI,OAAO,EAAE,CAAC;gBACZ,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC;QACpD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,WAAW,CACT,yCAAyC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAC3D,SAAS,CACV;KACJ,CAAC,EACJ,CAAC,GAAG,EAAE,WAAW,CAAC,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport nodemonOriginal from \"nodemon\";\nimport { useEffect } from \"react\";\nimport type { ExtendedNodemon } from \"./nodemon.d.ts\";\nimport type { PushMessage } from \"./use-messages.js\";\n\nconst nodemon = nodemonOriginal as ExtendedNodemon;\n\nconst SOURCEMAP_WARNING = /^Sourcemap for \".*\" points to missing source files$/;\n\nexport interface NodemonHandlers {\n /** A raw chunk of server stdout, forwarded untouched. */\n onStdout: (chunk: Buffer) => void;\n /** A (filtered) chunk of server stderr. */\n onStderr: (message: string) => void;\n /** The server restarted because the listed files changed. */\n onRestart: (files: string[]) => void;\n}\n\n/**\n * Boot nodemon and wire its stdout/stderr to the provided handlers. Returns a\n * cleanup function that detaches the listeners and quits nodemon. Shared by the\n * Ink-based dev UI (via {@link useNodemon}) and the `--plain` runner.\n */\nexport function startNodemon(\n env: NodeJS.ProcessEnv,\n handlers: NodemonHandlers,\n): () => void {\n const configFile = resolve(process.cwd(), \"nodemon.json\");\n\n const config = existsSync(configFile)\n ? {\n configFile,\n }\n : {\n watch: [\"src\"],\n ext: \"ts,json,md\",\n exec: \"tsx src/server.ts\",\n };\n\n nodemon({ ...config, env, stdout: false });\n\n const handleStdoutData = (chunk: Buffer) => {\n handlers.onStdout(chunk);\n };\n\n const handleStderrData = (chunk: Buffer) => {\n const message = chunk.toString().trim();\n if (!message) {\n return;\n }\n // Node's source-map warnings for third-party deps (superjson, @mcp/sdk, …) — not actionable.\n const filtered = message\n .split(\"\\n\")\n .filter((line) => !SOURCEMAP_WARNING.test(line))\n .join(\"\\n\");\n if (filtered) {\n handlers.onStderr(filtered);\n }\n };\n\n const setupStdoutListener = () => {\n if (nodemon.stdout) {\n nodemon.stdout.off(\"data\", handleStdoutData);\n nodemon.stdout.on(\"data\", handleStdoutData);\n }\n };\n\n const setupStderrListener = () => {\n if (nodemon.stderr) {\n nodemon.stderr.off(\"data\", handleStderrData);\n nodemon.stderr.on(\"data\", handleStderrData);\n }\n };\n\n nodemon.on(\"readable\", () => {\n setupStdoutListener();\n setupStderrListener();\n });\n\n nodemon.on(\"restart\", (files: string[]) => {\n handlers.onRestart(files);\n setupStdoutListener();\n setupStderrListener();\n });\n\n return () => {\n if (nodemon.stdout) {\n nodemon.stdout.off(\"data\", handleStdoutData);\n }\n if (nodemon.stderr) {\n nodemon.stderr.off(\"data\", handleStderrData);\n }\n nodemon.emit(\"quit\");\n };\n}\n\nexport function useNodemon(\n env: NodeJS.ProcessEnv,\n pushMessage: PushMessage,\n): void {\n useEffect(\n () =>\n startNodemon(env, {\n onStdout: (chunk) => {\n const message = chunk.toString().trim();\n if (message) {\n pushMessage(message, \"log\");\n }\n },\n onStderr: (message) => pushMessage(message, \"error\"),\n onRestart: (files) =>\n pushMessage(\n `Server restarted due to file changes: ${files.join(\", \")}`,\n \"restart\",\n ),\n }),\n [env, pushMessage],\n );\n}\n"]}
1
+ {"version":3,"file":"use-nodemon.js","sourceRoot":"","sources":["../../src/cli/use-nodemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI5C,SAAS,WAAW;IAClB,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAoB,CAAC;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GACxB,4EAA4E,CAAC;AAE/E,MAAM,iBAAiB,GAAG,qDAAqD,CAAC;AAgBhF;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAsB,EACtB,QAAyB;IAEzB,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAG,UAA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E;YAClB,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,IAAI,OAAO,EAAE,CAAC;gBACZ,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC;QACpD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACnB,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,WAAW,CACT,yCAAyC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAC3D,SAAS,CACV,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;KAChC,CAAC,EACJ,CAAC,GAAG,EAAE,WAAW,CAAC,CACnB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { resolve } from \"node:path\";\nimport { useEffect, useState } from \"react\";\nimport type { ExtendedNodemon } from \"./nodemon.d.ts\";\nimport type { PushMessage } from \"./use-messages.js\";\n\nfunction loadNodemon(): ExtendedNodemon {\n try {\n return createRequire(import.meta.url)(\"nodemon\") as ExtendedNodemon;\n } catch {\n throw new Error(\n 'skybridge dev needs the \"nodemon\" peer dependency. Install it with `npm install -D nodemon`.',\n );\n }\n}\n\nexport const CRASH_MESSAGE =\n \"💥 Server crashed. Fix the error, then save a watched file to restart it.\";\n\nconst SOURCEMAP_WARNING = /^Sourcemap for \".*\" points to missing source files$/;\n\nexport interface NodemonHandlers {\n /** A raw chunk of server stdout, forwarded untouched. */\n onStdout: (chunk: Buffer) => void;\n /** A (filtered) chunk of server stderr. */\n onStderr: (message: string) => void;\n /** The server restarted because the listed files changed. */\n onRestart: (files: string[]) => void;\n /**\n * The server exited with a non-zero code. nodemon does not restart it on its\n * own: it waits for the next file change.\n */\n onCrash: () => void;\n}\n\n/**\n * Boot nodemon and wire its stdout/stderr to the provided handlers. Returns a\n * cleanup function that detaches the listeners and quits nodemon. Shared by the\n * Ink-based dev UI (via {@link useNodemon}) and the `--plain` runner.\n */\nexport function startNodemon(\n env: NodeJS.ProcessEnv,\n handlers: NodemonHandlers,\n): () => void {\n const nodemon = loadNodemon();\n const configFile = resolve(process.cwd(), \"nodemon.json\");\n\n const config = existsSync(configFile)\n ? {\n configFile,\n }\n : {\n watch: [\"src\"],\n ext: \"ts,json,md\",\n exec: \"tsx src/index.ts\",\n };\n\n nodemon({ ...config, env, stdout: false });\n\n const handleStdoutData = (chunk: Buffer) => {\n handlers.onStdout(chunk);\n };\n\n const handleStderrData = (chunk: Buffer) => {\n const message = chunk.toString().trim();\n if (!message) {\n return;\n }\n // Node's source-map warnings for third-party deps (superjson, @mcp/sdk, …) — not actionable.\n const filtered = message\n .split(\"\\n\")\n .filter((line) => !SOURCEMAP_WARNING.test(line))\n .join(\"\\n\");\n if (filtered) {\n handlers.onStderr(filtered);\n }\n };\n\n const setupStdoutListener = () => {\n if (nodemon.stdout) {\n nodemon.stdout.off(\"data\", handleStdoutData);\n nodemon.stdout.on(\"data\", handleStdoutData);\n }\n };\n\n const setupStderrListener = () => {\n if (nodemon.stderr) {\n nodemon.stderr.off(\"data\", handleStderrData);\n nodemon.stderr.on(\"data\", handleStderrData);\n }\n };\n\n const reattachListeners = () => {\n setupStdoutListener();\n setupStderrListener();\n };\n\n nodemon.on(\"readable\", reattachListeners);\n\n nodemon.on(\"crash\", () => {\n handlers.onCrash();\n });\n\n nodemon.on(\"restart\", (files: string[]) => {\n handlers.onRestart(files);\n reattachListeners();\n });\n\n return () => {\n if (nodemon.stdout) {\n nodemon.stdout.off(\"data\", handleStdoutData);\n }\n if (nodemon.stderr) {\n nodemon.stderr.off(\"data\", handleStderrData);\n }\n nodemon.emit(\"quit\");\n };\n}\n\n/**\n * Boot nodemon for the Ink dev UI. Returns whether the server is currently\n * down after a crash, so the UI can stop advertising a URL nothing listens on.\n */\nexport function useNodemon(\n env: NodeJS.ProcessEnv,\n pushMessage: PushMessage,\n): boolean {\n const [crashed, setCrashed] = useState(false);\n\n useEffect(\n () =>\n startNodemon(env, {\n onStdout: (chunk) => {\n const message = chunk.toString().trim();\n if (message) {\n pushMessage(message, \"log\");\n }\n },\n onStderr: (message) => pushMessage(message, \"error\"),\n onRestart: (files) => {\n setCrashed(false);\n pushMessage(\n `Server restarted due to file changes: ${files.join(\", \")}`,\n \"restart\",\n );\n },\n onCrash: () => setCrashed(true),\n }),\n [env, pushMessage],\n );\n\n return crashed;\n}\n"]}
@@ -26,7 +26,7 @@ function extractBestMessage(message, continuationLines) {
26
26
  * and the `--plain` runner.
27
27
  */
28
28
  export function startTypeScriptCheck(onErrors) {
29
- const tsProcess = spawn("npx", ["tsc", "--noEmit", "--watch", "--pretty", "false"], {
29
+ const tsProcess = spawn("npx tsc --noEmit --watch --pretty false", {
30
30
  stdio: ["ignore", "pipe", "pipe"],
31
31
  shell: true,
32
32
  });
@@ -1 +1 @@
1
- {"version":3,"file":"use-typescript-check.js","sourceRoot":"","sources":["../../src/cli/use-typescript-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU5C,kFAAkF;AAClF,SAAS,kBAAkB,CACzB,OAAe,EACf,iBAAgC;IAEhC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MA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AED,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3D,YAAY,EAAE,CAAC;gBACf,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;gBACnE,aAAa,GAAG,EAAE,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACrB,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACrB,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IAE7D,SAAS,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IAEvD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { isAbsolute, relative } from \"node:path\";\nimport spawn from \"cross-spawn\";\nimport { useEffect, useState } from \"react\";\n\nexport type TsError = {\n file: string;\n line: number;\n col: number;\n code: string;\n message: string;\n};\n\n// TypeScript nests from general to specific — the deepest line is the root cause.\nfunction extractBestMessage(\n message: string,\n continuationLines: Array<string>,\n): string {\n if (!continuationLines.length) {\n return message;\n }\n let maxIndent = 0;\n for (const line of continuationLines) {\n const indent = line.length - line.trimStart().length;\n if (indent > maxIndent) {\n maxIndent = indent;\n }\n }\n const deepest = continuationLines\n .filter((l) => l.length - l.trimStart().length === maxIndent)\n .map((l) => l.trim())\n .filter(Boolean)[0];\n return deepest ?? message;\n}\n\n/**\n * Spawn `tsc --noEmit --watch` and report each completed check via `onErrors`\n * (empty array when the check is clean). Returns a cleanup function that kills\n * the watcher. Shared by the Ink-based dev UI (via {@link useTypeScriptCheck})\n * and the `--plain` runner.\n */\nexport function startTypeScriptCheck(\n onErrors: (errors: Array<TsError>) => void,\n): () => void {\n const tsProcess = spawn(\n \"npx\",\n [\"tsc\", \"--noEmit\", \"--watch\", \"--pretty\", \"false\"],\n {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: true,\n },\n );\n\n let outputBuffer = \"\";\n let currentErrors: Array<TsError> = [];\n let pendingError: TsError | null = null;\n let continuationLines: Array<string> = [];\n\n const flushPending = () => {\n if (!pendingError) {\n return;\n }\n pendingError.message = extractBestMessage(\n pendingError.message,\n continuationLines,\n );\n currentErrors.push(pendingError);\n pendingError = null;\n continuationLines = [];\n };\n\n const processOutput = (data: Buffer) => {\n outputBuffer += data.toString();\n const lines = outputBuffer.split(\"\\n\");\n outputBuffer = lines.pop() || \"\";\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n const errorMatch = trimmed.match(\n /^(.+?)\\((\\d+),(\\d+)\\):\\s+error\\s+(TS\\d+)?\\s*:?\\s*(.+)$/,\n );\n if (errorMatch) {\n flushPending();\n const [, file, lineStr, colStr, code, message] = errorMatch;\n if (file && lineStr && colStr && message) {\n let cleanFile = file.trim();\n if (isAbsolute(cleanFile)) {\n cleanFile = relative(process.cwd(), cleanFile);\n }\n pendingError = {\n file: cleanFile,\n line: Number.parseInt(lineStr, 10),\n col: Number.parseInt(colStr, 10),\n code: code ?? \"\",\n message: message.trim(),\n };\n }\n continue;\n }\n\n if (pendingError && line.startsWith(\" \")) {\n continuationLines.push(line);\n continue;\n }\n\n if (trimmed.includes(\"Found\") && trimmed.includes(\"error\")) {\n flushPending();\n onErrors(trimmed.match(/Found 0 error/) ? [] : [...currentErrors]);\n currentErrors = [];\n }\n }\n };\n\n if (tsProcess.stdout) {\n tsProcess.stdout.on(\"data\", processOutput);\n }\n if (tsProcess.stderr) {\n tsProcess.stderr.on(\"data\", processOutput);\n }\n\n return () => {\n tsProcess.kill();\n };\n}\n\nexport function useTypeScriptCheck(): Array<TsError> {\n const [tsErrors, setTsErrors] = useState<Array<TsError>>([]);\n\n useEffect(() => startTypeScriptCheck(setTsErrors), []);\n\n return tsErrors;\n}\n"]}
1
+ {"version":3,"file":"use-typescript-check.js","sourceRoot":"","sources":["../../src/cli/use-typescript-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAU5C,kFAAkF;AAClF,SAAS,kBAAkB,CACzB,OAAe,EACf,iBAAgC;IAEhC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;QACrD,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;YACvB,SAAS,GAAG,MAAM,CAAC;QACrB,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,iBAAiB;SAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,MAAM,KAAK,SAAS,CAAC;SAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MA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MAAM,EAAE,aAAa,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACrB,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IAE7D,SAAS,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IAEvD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { isAbsolute, relative } from \"node:path\";\nimport spawn from \"cross-spawn\";\nimport { useEffect, useState } from \"react\";\n\nexport type TsError = {\n file: string;\n line: number;\n col: number;\n code: string;\n message: string;\n};\n\n// TypeScript nests from general to specific — the deepest line is the root cause.\nfunction extractBestMessage(\n message: string,\n continuationLines: Array<string>,\n): string {\n if (!continuationLines.length) {\n return message;\n }\n let maxIndent = 0;\n for (const line of continuationLines) {\n const indent = line.length - line.trimStart().length;\n if (indent > maxIndent) {\n maxIndent = indent;\n }\n }\n const deepest = continuationLines\n .filter((l) => l.length - l.trimStart().length === maxIndent)\n .map((l) => l.trim())\n .filter(Boolean)[0];\n return deepest ?? message;\n}\n\n/**\n * Spawn `tsc --noEmit --watch` and report each completed check via `onErrors`\n * (empty array when the check is clean). Returns a cleanup function that kills\n * the watcher. Shared by the Ink-based dev UI (via {@link useTypeScriptCheck})\n * and the `--plain` runner.\n */\nexport function startTypeScriptCheck(\n onErrors: (errors: Array<TsError>) => void,\n): () => void {\n const tsProcess = spawn(\"npx tsc --noEmit --watch --pretty false\", {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: true,\n });\n\n let outputBuffer = \"\";\n let currentErrors: Array<TsError> = [];\n let pendingError: TsError | null = null;\n let continuationLines: Array<string> = [];\n\n const flushPending = () => {\n if (!pendingError) {\n return;\n }\n pendingError.message = extractBestMessage(\n pendingError.message,\n continuationLines,\n );\n currentErrors.push(pendingError);\n pendingError = null;\n continuationLines = [];\n };\n\n const processOutput = (data: Buffer) => {\n outputBuffer += data.toString();\n const lines = outputBuffer.split(\"\\n\");\n outputBuffer = lines.pop() || \"\";\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n const errorMatch = trimmed.match(\n /^(.+?)\\((\\d+),(\\d+)\\):\\s+error\\s+(TS\\d+)?\\s*:?\\s*(.+)$/,\n );\n if (errorMatch) {\n flushPending();\n const [, file, lineStr, colStr, code, message] = errorMatch;\n if (file && lineStr && colStr && message) {\n let cleanFile = file.trim();\n if (isAbsolute(cleanFile)) {\n cleanFile = relative(process.cwd(), cleanFile);\n }\n pendingError = {\n file: cleanFile,\n line: Number.parseInt(lineStr, 10),\n col: Number.parseInt(colStr, 10),\n code: code ?? \"\",\n message: message.trim(),\n };\n }\n continue;\n }\n\n if (pendingError && line.startsWith(\" \")) {\n continuationLines.push(line);\n continue;\n }\n\n if (trimmed.includes(\"Found\") && trimmed.includes(\"error\")) {\n flushPending();\n onErrors(trimmed.match(/Found 0 error/) ? [] : [...currentErrors]);\n currentErrors = [];\n }\n }\n };\n\n if (tsProcess.stdout) {\n tsProcess.stdout.on(\"data\", processOutput);\n }\n if (tsProcess.stderr) {\n tsProcess.stderr.on(\"data\", processOutput);\n }\n\n return () => {\n tsProcess.kill();\n };\n}\n\nexport function useTypeScriptCheck(): Array<TsError> {\n const [tsErrors, setTsErrors] = useState<Array<TsError>>([]);\n\n useEffect(() => startTypeScriptCheck(setTsErrors), []);\n\n return tsErrors;\n}\n"]}
@@ -7,11 +7,11 @@ import { resolveSkybridgeConfig } from "../cli/resolve-skybridge-config.js";
7
7
  import { runPlain } from "../cli/run-plain.js";
8
8
  import { startTunnelControlServer } from "../cli/tunnel-control-server.js";
9
9
  import { useMessages } from "../cli/use-messages.js";
10
- import { useNodemon } from "../cli/use-nodemon.js";
10
+ import { CRASH_MESSAGE, useNodemon } from "../cli/use-nodemon.js";
11
11
  import { useOpenBrowser } from "../cli/use-open-browser.js";
12
12
  import { useTunnel } from "../cli/use-tunnel.js";
13
13
  import { useTypeScriptCheck } from "../cli/use-typescript-check.js";
14
- import { scanAndWriteViewsDts } from "../web/plugin/scan-views.js";
14
+ import { scanAndWriteViewsDts } from "../views/index.js";
15
15
  export default class Dev extends Command {
16
16
  static description = "Start development server";
17
17
  static examples = ["skybridge"];
@@ -96,10 +96,10 @@ export default class Dev extends Command {
96
96
  const App = () => {
97
97
  const tsErrors = useTypeScriptCheck();
98
98
  const [messages, pushMessage] = useMessages();
99
- useNodemon(env, pushMessage);
99
+ const crashed = useNodemon(env, pushMessage);
100
100
  useOpenBrowser(port, flags.open);
101
101
  const tunnelState = useTunnel(port, pushMessage, flags.verbose, flags.tunnel);
102
- return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDFE0", " "] }), fallback ? (_jsx(Text, { color: "yellow", children: "3000 in use, running on " })) : (_jsx(Text, { children: "Running on " })), _jsx(Text, { color: "green", children: `http://localhost:${port}/mcp` })] }), _jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test locally with DevTools:", " "] }), _jsx(Text, { color: "green", children: `http://localhost:${port}/` })] }), tunnelState.status === "idle" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Get a public URL and LLM Playground access with " }), _jsx(Text, { color: "cyan", bold: true, children: "--tunnel" }), _jsx(Text, { children: "." })] })), tunnelState.status === "starting" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { color: "yellow", children: tunnelState.message })] })), tunnelState.status === "connected" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Exposed on " }), _jsx(Text, { color: "green", children: `${tunnelState.url}/mcp` })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test with an LLM on Playground:", " "] }), _jsx(Text, { color: "green", children: `${tunnelState.url}/try` })] })] })), tunnelState.status === "error" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsxs(Text, { color: "red", children: ["Cannot open tunnel: ", tunnelState.message] })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "red", children: `Try manually: npx alpic tunnel --port ${port}` })] })] })), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83D\uDEDF", " "] }), _jsx(Text, { children: "Need help? Reach us on " }), _jsx(Text, { color: "white", underline: true, children: "https://discord.alpic.ai" })] }), tsErrors.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u26A0\uFE0F TypeScript errors found:" }), tsErrors.map((error) => (_jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "white", children: error.file }), _jsxs(Text, { color: "grey", children: ["(", error.line, ",", error.col, "):", " "] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: error.message }) })] }, `${error.file}:${error.line}:${error.col}`)))] })), messages.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Logs:" }), messages.map((message) => (_jsx(Box, { marginLeft: 2, children: message.type === "restart" ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: "green", children: ["\u2713", " "] }), _jsx(Text, { color: "white", children: message.text })] })) : message.type === "error" ? (_jsx(Text, { color: "red", children: message.text })) : (_jsx(Text, { children: message.text })) }, message.id)))] }))] }));
102
+ return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), crashed ? (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "red", children: CRASH_MESSAGE }) })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDFE0", " "] }), fallback ? (_jsx(Text, { color: "yellow", children: "3000 in use, running on " })) : (_jsx(Text, { children: "Running on " })), _jsx(Text, { color: "green", children: `http://localhost:${port}/mcp` })] }), _jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test locally with DevTools:", " "] }), _jsx(Text, { color: "green", children: `http://localhost:${port}/` })] })] })), tunnelState.status === "idle" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Get a public URL and LLM Playground access with " }), _jsx(Text, { color: "cyan", bold: true, children: "--tunnel" }), _jsx(Text, { children: "." })] })), tunnelState.status === "starting" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { color: "yellow", children: tunnelState.message })] })), tunnelState.status === "connected" && !crashed && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Exposed on " }), _jsx(Text, { color: "green", children: `${tunnelState.url}/mcp` })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test with an LLM on Playground:", " "] }), _jsx(Text, { color: "green", children: `${tunnelState.url}/try` })] })] })), tunnelState.status === "error" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsxs(Text, { color: "red", children: ["Cannot open tunnel: ", tunnelState.message] })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "red", children: `Try manually: npx alpic tunnel --port ${port}` })] })] })), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83D\uDEDF", " "] }), _jsx(Text, { children: "Need help? Reach us on " }), _jsx(Text, { color: "white", underline: true, children: "https://discord.alpic.ai" })] }), tsErrors.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u26A0\uFE0F TypeScript errors found:" }), tsErrors.map((error) => (_jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "white", children: error.file }), _jsxs(Text, { color: "grey", children: ["(", error.line, ",", error.col, "):", " "] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: error.message }) })] }, `${error.file}:${error.line}:${error.col}`)))] })), messages.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Logs:" }), messages.map((message) => (_jsx(Box, { marginLeft: 2, children: message.type === "restart" ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: "green", children: ["\u2713", " "] }), _jsx(Text, { color: "white", children: message.text })] })) : message.type === "error" ? (_jsx(Text, { color: "red", children: message.text })) : (_jsx(Text, { children: message.text })) }, message.id)))] }))] }));
103
103
  };
104
104
  // Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee
105
105
  // alpic gets killed before we exit. If anything ever calls `useInput` or
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OA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,yEAAyE;QACzE,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAExE,uEAAuE;QACvE,2EAA2E;QAC3E,wDAAwD;QACxD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,EAAE;YACtC,aAAa,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,kBAAkB,EAAE;iBACtB,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAG,CAAC,CAAC;YAC9D,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACZ,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC","sourcesContent":["import { Command, Flags } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { Header } from \"../cli/header.js\";\nimport { resolveSkybridgeConfig } from \"../cli/resolve-skybridge-config.js\";\nimport { runPlain } from \"../cli/run-plain.js\";\nimport { startTunnelControlServer } from \"../cli/tunnel-control-server.js\";\nimport { useMessages } from \"../cli/use-messages.js\";\nimport { useNodemon } from \"../cli/use-nodemon.js\";\nimport { useOpenBrowser } from \"../cli/use-open-browser.js\";\nimport { useTunnel } from \"../cli/use-tunnel.js\";\nimport { useTypeScriptCheck } from \"../cli/use-typescript-check.js\";\nimport { scanAndWriteViewsDts } from \"../web/plugin/scan-views.js\";\n\nexport default class Dev extends Command {\n static override description = \"Start development server\";\n static override examples = [\"skybridge\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n tunnel: Flags.boolean({\n description: \"Open an Alpic tunnel for remote testing\",\n default: false,\n }),\n open: Flags.boolean({\n description: \"Open DevTools in the browser when the server is ready\",\n default: process.env.SKYBRIDGE_OPEN !== \"false\",\n allowNo: true,\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Show tunnel logs\",\n default: false,\n }),\n plain: Flags.boolean({\n description:\n \"Disable the interactive UI and stream raw server logs to stdout, so you can pipe them through a formatter (e.g. `skybridge dev --plain | bunyan`).\",\n default: false,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Dev);\n\n // Generate .skybridge/views.d.ts before render() spawns `tsc --noEmit\n // --watch`. Vite's plugin config hook writes the same file when nodemon\n // boots the server, but tsc starts in parallel — if .skybridge/ doesn't\n // exist at tsc startup, its watcher never picks up the late-created file\n // and the dev UI reports phantom TS errors forever.\n const root = process.cwd();\n try {\n scanAndWriteViewsDts(root, (await resolveSkybridgeConfig(root)).viewsDir);\n } catch {\n // Best-effort: if the scan fails (e.g. broken vite config, duplicate\n // view names) tsc may show phantom errors, but the dev server should\n // still start so the developer can fix the underlying issue.\n }\n\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n const {\n port: controlPort,\n manager: tunnelManager,\n close: closeTunnelControl,\n } = await startTunnelControlServer(() => port);\n\n const env = {\n ...process.env,\n __PORT: String(port),\n __TUNNEL_CONTROL_PORT: String(controlPort),\n };\n\n if (flags.plain) {\n const teardown = runPlain({\n env,\n port,\n fallback,\n version: this.config.version,\n tunnel: flags.tunnel,\n tunnelManager,\n });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g.\n // nodemon's) exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n teardown();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n return;\n }\n\n const App = () => {\n const tsErrors = useTypeScriptCheck();\n const [messages, pushMessage] = useMessages();\n useNodemon(env, pushMessage);\n useOpenBrowser(port, flags.open);\n const tunnelState = useTunnel(\n port,\n pushMessage,\n flags.verbose,\n flags.tunnel,\n );\n\n return (\n <Box flexDirection=\"column\" padding={1} marginLeft={1}>\n <Header version={this.config.version} />\n\n <Box>\n <Text>🏠{\" \"}</Text>\n {fallback ? (\n <Text color=\"yellow\">3000 in use, running on </Text>\n ) : (\n <Text>Running on </Text>\n )}\n <Text color=\"green\">{`http://localhost:${port}/mcp`}</Text>\n </Box>\n <Box marginBottom={1}>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test locally with DevTools:{\" \"}\n </Text>\n <Text color=\"green\">{`http://localhost:${port}/`}</Text>\n </Box>\n\n {tunnelState.status === \"idle\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Get a public URL and LLM Playground access with </Text>\n <Text color=\"cyan\" bold>\n --tunnel\n </Text>\n <Text>.</Text>\n </Box>\n )}\n {tunnelState.status === \"starting\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"yellow\">{tunnelState.message}</Text>\n </Box>\n )}\n {tunnelState.status === \"connected\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Exposed on </Text>\n <Text color=\"green\">{`${tunnelState.url}/mcp`}</Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test with an LLM on Playground:{\" \"}\n </Text>\n <Text color=\"green\">{`${tunnelState.url}/try`}</Text>\n </Box>\n </Box>\n )}\n {tunnelState.status === \"error\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"red\">\n Cannot open tunnel: {tunnelState.message}\n </Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"red\">{`Try manually: npx alpic tunnel --port ${port}`}</Text>\n </Box>\n </Box>\n )}\n\n <Box>\n <Text>🛟{\" \"}</Text>\n <Text>Need help? Reach us on </Text>\n <Text color=\"white\" underline>\n https://discord.alpic.ai\n </Text>\n </Box>\n\n {tsErrors.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"red\" bold>\n ⚠️ TypeScript errors found:\n </Text>\n {tsErrors.map((error) => (\n <Box\n key={`${error.file}:${error.line}:${error.col}`}\n marginLeft={2}\n flexDirection=\"column\"\n >\n <Box>\n <Text color=\"white\">{error.file}</Text>\n <Text color=\"grey\">\n ({error.line},{error.col}):{\" \"}\n </Text>\n </Box>\n <Box marginLeft={2}>\n <Text color=\"red\">{error.message}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )}\n {messages.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"white\" bold>\n Logs:\n </Text>\n {messages.map((message) => (\n <Box key={message.id} marginLeft={2}>\n {message.type === \"restart\" ? (\n <>\n <Text color=\"green\">✓{\" \"}</Text>\n <Text color=\"white\">{message.text}</Text>\n </>\n ) : message.type === \"error\" ? (\n <Text color=\"red\">{message.text}</Text>\n ) : (\n <Text>{message.text}</Text>\n )}\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n };\n\n // Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee\n // alpic gets killed before we exit. If anything ever calls `useInput` or\n // puts stdin into raw mode, also wire an explicit `\\x03` keypress to the\n // shutdown function — Ink will otherwise swallow Ctrl-C without ever\n // delivering SIGINT.\n const ink = render(<App />, { exitOnCtrlC: false, patchConsole: true });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g. nodemon's)\n // exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n ink.unmount();\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n }\n}\n"]}
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACtC,MAAM,CAAU,WAAW,GAAG,0BAA0B,CAAC;IACzD,MAAM,CAAU,QAAQ,GAAG,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,CAAU,KAAK,GAAG;Q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QACP,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC","sourcesContent":["import { Command, Flags } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { Header } from \"../cli/header.js\";\nimport { resolveSkybridgeConfig } from \"../cli/resolve-skybridge-config.js\";\nimport { runPlain } from \"../cli/run-plain.js\";\nimport { startTunnelControlServer } from \"../cli/tunnel-control-server.js\";\nimport { useMessages } from \"../cli/use-messages.js\";\nimport { CRASH_MESSAGE, useNodemon } from \"../cli/use-nodemon.js\";\nimport { useOpenBrowser } from \"../cli/use-open-browser.js\";\nimport { useTunnel } from \"../cli/use-tunnel.js\";\nimport { useTypeScriptCheck } from \"../cli/use-typescript-check.js\";\nimport { scanAndWriteViewsDts } from \"../views/index.js\";\n\nexport default class Dev extends Command {\n static override description = \"Start development server\";\n static override examples = [\"skybridge\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n tunnel: Flags.boolean({\n description: \"Open an Alpic tunnel for remote testing\",\n default: false,\n }),\n open: Flags.boolean({\n description: \"Open DevTools in the browser when the server is ready\",\n default: process.env.SKYBRIDGE_OPEN !== \"false\",\n allowNo: true,\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Show tunnel logs\",\n default: false,\n }),\n plain: Flags.boolean({\n description:\n \"Disable the interactive UI and stream raw server logs to stdout, so you can pipe them through a formatter (e.g. `skybridge dev --plain | bunyan`).\",\n default: false,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Dev);\n\n // Generate .skybridge/views.d.ts before render() spawns `tsc --noEmit\n // --watch`. Vite's plugin config hook writes the same file when nodemon\n // boots the server, but tsc starts in parallel — if .skybridge/ doesn't\n // exist at tsc startup, its watcher never picks up the late-created file\n // and the dev UI reports phantom TS errors forever.\n const root = process.cwd();\n try {\n scanAndWriteViewsDts(root, (await resolveSkybridgeConfig(root)).viewsDir);\n } catch {\n // Best-effort: if the scan fails (e.g. broken vite config, duplicate\n // view names) tsc may show phantom errors, but the dev server should\n // still start so the developer can fix the underlying issue.\n }\n\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n const {\n port: controlPort,\n manager: tunnelManager,\n close: closeTunnelControl,\n } = await startTunnelControlServer(() => port);\n\n const env = {\n ...process.env,\n __PORT: String(port),\n __TUNNEL_CONTROL_PORT: String(controlPort),\n };\n\n if (flags.plain) {\n const teardown = runPlain({\n env,\n port,\n fallback,\n version: this.config.version,\n tunnel: flags.tunnel,\n tunnelManager,\n });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g.\n // nodemon's) exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n teardown();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n return;\n }\n\n const App = () => {\n const tsErrors = useTypeScriptCheck();\n const [messages, pushMessage] = useMessages();\n const crashed = useNodemon(env, pushMessage);\n useOpenBrowser(port, flags.open);\n const tunnelState = useTunnel(\n port,\n pushMessage,\n flags.verbose,\n flags.tunnel,\n );\n\n return (\n <Box flexDirection=\"column\" padding={1} marginLeft={1}>\n <Header version={this.config.version} />\n\n {crashed ? (\n <Box marginBottom={1}>\n <Text color=\"red\">{CRASH_MESSAGE}</Text>\n </Box>\n ) : (\n <>\n <Box>\n <Text>🏠{\" \"}</Text>\n {fallback ? (\n <Text color=\"yellow\">3000 in use, running on </Text>\n ) : (\n <Text>Running on </Text>\n )}\n <Text color=\"green\">{`http://localhost:${port}/mcp`}</Text>\n </Box>\n <Box marginBottom={1}>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test locally with DevTools:{\" \"}\n </Text>\n <Text color=\"green\">{`http://localhost:${port}/`}</Text>\n </Box>\n </>\n )}\n\n {tunnelState.status === \"idle\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Get a public URL and LLM Playground access with </Text>\n <Text color=\"cyan\" bold>\n --tunnel\n </Text>\n <Text>.</Text>\n </Box>\n )}\n {tunnelState.status === \"starting\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"yellow\">{tunnelState.message}</Text>\n </Box>\n )}\n {tunnelState.status === \"connected\" && !crashed && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Exposed on </Text>\n <Text color=\"green\">{`${tunnelState.url}/mcp`}</Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test with an LLM on Playground:{\" \"}\n </Text>\n <Text color=\"green\">{`${tunnelState.url}/try`}</Text>\n </Box>\n </Box>\n )}\n {tunnelState.status === \"error\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"red\">\n Cannot open tunnel: {tunnelState.message}\n </Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"red\">{`Try manually: npx alpic tunnel --port ${port}`}</Text>\n </Box>\n </Box>\n )}\n\n <Box>\n <Text>🛟{\" \"}</Text>\n <Text>Need help? Reach us on </Text>\n <Text color=\"white\" underline>\n https://discord.alpic.ai\n </Text>\n </Box>\n\n {tsErrors.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"red\" bold>\n ⚠️ TypeScript errors found:\n </Text>\n {tsErrors.map((error) => (\n <Box\n key={`${error.file}:${error.line}:${error.col}`}\n marginLeft={2}\n flexDirection=\"column\"\n >\n <Box>\n <Text color=\"white\">{error.file}</Text>\n <Text color=\"grey\">\n ({error.line},{error.col}):{\" \"}\n </Text>\n </Box>\n <Box marginLeft={2}>\n <Text color=\"red\">{error.message}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )}\n {messages.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"white\" bold>\n Logs:\n </Text>\n {messages.map((message) => (\n <Box key={message.id} marginLeft={2}>\n {message.type === \"restart\" ? (\n <>\n <Text color=\"green\">✓{\" \"}</Text>\n <Text color=\"white\">{message.text}</Text>\n </>\n ) : message.type === \"error\" ? (\n <Text color=\"red\">{message.text}</Text>\n ) : (\n <Text>{message.text}</Text>\n )}\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n };\n\n // Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee\n // alpic gets killed before we exit. If anything ever calls `useInput` or\n // puts stdin into raw mode, also wire an explicit `\\x03` keypress to the\n // shutdown function — Ink will otherwise swallow Ctrl-C without ever\n // delivering SIGINT.\n const ink = render(<App />, { exitOnCtrlC: false, patchConsole: true });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g. nodemon's)\n // exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n ink.unmount();\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n }\n}\n"]}
@@ -20,12 +20,12 @@ export default class Start extends Command {
20
20
  this.warn(envWarning);
21
21
  }
22
22
  console.clear();
23
- // `dist/server.js` is the natural entry (the user's `await server.run()`
23
+ // `dist/index.js` is the natural entry (the user's `await app.run()`
24
24
  // binds the port). Prefer `dist/__entry.js` when present because it
25
25
  // primes the Vite manifest first — without it, hashed asset URLs in
26
26
  // views won't resolve.
27
27
  const entryPath = resolve(process.cwd(), "dist/__entry.js");
28
- const fallbackPath = resolve(process.cwd(), "dist/server.js");
28
+ const fallbackPath = resolve(process.cwd(), "dist/index.js");
29
29
  const indexPath = existsSync(entryPath) ? entryPath : fallbackPath;
30
30
  if (!existsSync(indexPath)) {
31
31
  console.error("❌ Error: No build output found");
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,MAAM,CAAU,WAAW,GAAG,yBAAyB,CAAC;IACxD,MAAM,CAAU,QAAQ,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/C,MAAM,CAAU,KAAK,GAAG;QACtB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC;YAClB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,2BAA2B;YACxC,GAAG,EAAE,CAAC;SACP,CAAC;KACH,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrE,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,yEAAyE;QAC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ync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { Command, Flags } from \"@oclif/core\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { runCommand } from \"../cli/run-command.js\";\n\nexport default class Start extends Command {\n static override description = \"Start production server\";\n static override examples = [\"skybridge start\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Start);\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n console.clear();\n\n // `dist/server.js` is the natural entry (the user's `await server.run()`\n // binds the port). Prefer `dist/__entry.js` when present because it\n // primes the Vite manifest first — without it, hashed asset URLs in\n // views won't resolve.\n const entryPath = resolve(process.cwd(), \"dist/__entry.js\");\n const fallbackPath = resolve(process.cwd(), \"dist/server.js\");\n const indexPath = existsSync(entryPath) ? entryPath : fallbackPath;\n\n if (!existsSync(indexPath)) {\n console.error(\"❌ Error: No build output found\");\n console.error(\"\");\n console.error(\"Please build your project first:\");\n console.error(\" skybridge build\");\n console.error(\"\");\n process.exit(1);\n }\n\n console.log(\n `\\x1b[36m\\x1b[1m⛰ Skybridge\\x1b[0m \\x1b[36mv${this.config.version}\\x1b[0m`,\n );\n if (fallback) {\n console.log(\n `\\x1b[33m3000 in use, running on\\x1b[0m \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`,\n );\n } else {\n console.log(`Running on \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`);\n }\n\n await runCommand(`node ${indexPath}`, {\n stdio: [\"ignore\", \"inherit\", \"inherit\"],\n env: {\n ...process.env,\n NODE_ENV: \"production\",\n __PORT: String(port),\n },\n });\n }\n}\n"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,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B,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;YAChD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAClD,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CACT,8CAA8C,IAAI,CAAC,MAAM,CAAC,OAAO,SAAS,CAC3E,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CACT,mEAAmE,IAAI,aAAa,CACrF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,uCAAuC,IAAI,aAAa,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,UAAU,CAAC,QAAQ,SAAS,EAAE,EAAE;YACpC,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;YACvC,GAAG,EAAE;gBACH,GAAG,OAAO,CAAC,GAAG;gBACd,QAAQ,EAAE,YAAY;gBACtB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;aACrB;SACF,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { Command, Flags } from \"@oclif/core\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { runCommand } from \"../cli/run-command.js\";\n\nexport default class Start extends Command {\n static override description = \"Start production server\";\n static override examples = [\"skybridge start\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Start);\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n console.clear();\n\n // `dist/index.js` is the natural entry (the user's `await app.run()`\n // binds the port). Prefer `dist/__entry.js` when present because it\n // primes the Vite manifest first — without it, hashed asset URLs in\n // views won't resolve.\n const entryPath = resolve(process.cwd(), \"dist/__entry.js\");\n const fallbackPath = resolve(process.cwd(), \"dist/index.js\");\n const indexPath = existsSync(entryPath) ? entryPath : fallbackPath;\n\n if (!existsSync(indexPath)) {\n console.error(\"❌ Error: No build output found\");\n console.error(\"\");\n console.error(\"Please build your project first:\");\n console.error(\" skybridge build\");\n console.error(\"\");\n process.exit(1);\n }\n\n console.log(\n `\\x1b[36m\\x1b[1m⛰ Skybridge\\x1b[0m \\x1b[36mv${this.config.version}\\x1b[0m`,\n );\n if (fallback) {\n console.log(\n `\\x1b[33m3000 in use, running on\\x1b[0m \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`,\n );\n } else {\n console.log(`Running on \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`);\n }\n\n await runCommand(`node ${indexPath}`, {\n stdio: [\"ignore\", \"inherit\", \"inherit\"],\n env: {\n ...process.env,\n NODE_ENV: \"production\",\n __PORT: String(port),\n },\n });\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export declare const TOOL_OUTPUT_WARNING_TOKENS = 5000;
2
+ export declare const VIEW_STATE_WARNING_TOKENS = 20000;
3
+ export declare function estimateContextTokens(value: unknown): number;
4
+ export declare function warnOnLargeToolOutput(result: unknown, toolName: string): void;
5
+ export declare function warnOnLargeViewState(value: unknown, source: string): void;
@@ -0,0 +1,31 @@
1
+ export const TOOL_OUTPUT_WARNING_TOKENS = 5_000;
2
+ export const VIEW_STATE_WARNING_TOKENS = 20_000;
3
+ export function estimateContextTokens(value) {
4
+ try {
5
+ const serialized = JSON.stringify(value);
6
+ if (!serialized) {
7
+ return 0;
8
+ }
9
+ return Math.ceil(new TextEncoder().encode(serialized).length / 4);
10
+ }
11
+ catch {
12
+ return 0;
13
+ }
14
+ }
15
+ export function warnOnLargeToolOutput(result, toolName) {
16
+ if (!result || typeof result !== "object" || Array.isArray(result)) {
17
+ return;
18
+ }
19
+ const { _meta, ...modelVisibleResult } = result;
20
+ const tokenCount = estimateContextTokens(modelVisibleResult);
21
+ if (tokenCount >= TOOL_OUTPUT_WARNING_TOKENS) {
22
+ console.warn(`[skybridge] Tool "${toolName}" returned ${tokenCount} estimated model-visible tokens; this reaches the ${TOOL_OUTPUT_WARNING_TOKENS}-token warning threshold and may overload model context. Content and structured content are included in this estimate.`);
23
+ }
24
+ }
25
+ export function warnOnLargeViewState(value, source) {
26
+ const tokenCount = estimateContextTokens(value);
27
+ if (tokenCount >= VIEW_STATE_WARNING_TOKENS) {
28
+ console.warn(`[skybridge] ${source} is persisting ${tokenCount} estimated tokens in model-visible view state; this reaches the ${VIEW_STATE_WARNING_TOKENS}-token warning threshold and may overload model context. Persisted view state and data-llm context are included in this estimate.`);
29
+ }
30
+ }
31
+ //# sourceMappingURL=context-warnings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-warnings.js","sourceRoot":"","sources":["../src/context-warnings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEhD,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAe,EAAE,QAAgB;IACrE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,OAAO;IACT,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAiC,CAAC;IAC3E,MAAM,UAAU,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC7D,IAAI,UAAU,IAAI,0BAA0B,EAAE,CAAC;QAC7C,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ,cAAc,UAAU,qDAAqD,0BAA0B,wHAAwH,CAC7P,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,MAAc;IACjE,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,UAAU,IAAI,yBAAyB,EAAE,CAAC;QAC5C,OAAO,CAAC,IAAI,CACV,eAAe,MAAM,kBAAkB,UAAU,mEAAmE,yBAAyB,mIAAmI,CACjR,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["export const TOOL_OUTPUT_WARNING_TOKENS = 5_000;\nexport const VIEW_STATE_WARNING_TOKENS = 20_000;\n\nexport function estimateContextTokens(value: unknown): number {\n try {\n const serialized = JSON.stringify(value);\n if (!serialized) {\n return 0;\n }\n return Math.ceil(new TextEncoder().encode(serialized).length / 4);\n } catch {\n return 0;\n }\n}\n\nexport function warnOnLargeToolOutput(result: unknown, toolName: string): void {\n if (!result || typeof result !== \"object\" || Array.isArray(result)) {\n return;\n }\n const { _meta, ...modelVisibleResult } = result as Record<string, unknown>;\n const tokenCount = estimateContextTokens(modelVisibleResult);\n if (tokenCount >= TOOL_OUTPUT_WARNING_TOKENS) {\n console.warn(\n `[skybridge] Tool \"${toolName}\" returned ${tokenCount} estimated model-visible tokens; this reaches the ${TOOL_OUTPUT_WARNING_TOKENS}-token warning threshold and may overload model context. Content and structured content are included in this estimate.`,\n );\n }\n}\n\nexport function warnOnLargeViewState(value: unknown, source: string): void {\n const tokenCount = estimateContextTokens(value);\n if (tokenCount >= VIEW_STATE_WARNING_TOKENS) {\n console.warn(\n `[skybridge] ${source} is persisting ${tokenCount} estimated tokens in model-visible view state; this reaches the ${VIEW_STATE_WARNING_TOKENS}-token warning threshold and may overload model context. Persisted view state and data-llm context are included in this estimate.`,\n );\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { estimateContextTokens, TOOL_OUTPUT_WARNING_TOKENS, warnOnLargeToolOutput, } from "./context-warnings.js";
3
+ describe("context warnings", () => {
4
+ it("estimates UTF-8 bytes and returns zero for no content", () => {
5
+ expect(estimateContextTokens("é")).toBe(1);
6
+ expect(estimateContextTokens(undefined)).toBe(0);
7
+ });
8
+ it("warns when model-visible tool output reaches the threshold", () => {
9
+ const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
10
+ warnOnLargeToolOutput({
11
+ content: [
12
+ {
13
+ type: "text",
14
+ text: "x".repeat(TOOL_OUTPUT_WARNING_TOKENS * 4),
15
+ },
16
+ ],
17
+ }, "large-output");
18
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Tool "large-output" returned'));
19
+ warnSpy.mockRestore();
20
+ });
21
+ it("does not warn for large metadata", () => {
22
+ const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
23
+ warnOnLargeToolOutput({ content: [], _meta: { private: "x".repeat(100_000) } }, "large-meta");
24
+ expect(warnSpy).not.toHaveBeenCalled();
25
+ warnSpy.mockRestore();
26
+ });
27
+ });
28
+ //# sourceMappingURL=context-warnings.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-warnings.test.js","sourceRoot":"","sources":["../src/context-warnings.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1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AAC;QACvC,OAAO,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it, vi } from \"vitest\";\nimport {\n estimateContextTokens,\n TOOL_OUTPUT_WARNING_TOKENS,\n warnOnLargeToolOutput,\n} from \"./context-warnings.js\";\n\ndescribe(\"context warnings\", () => {\n it(\"estimates UTF-8 bytes and returns zero for no content\", () => {\n expect(estimateContextTokens(\"é\")).toBe(1);\n expect(estimateContextTokens(undefined)).toBe(0);\n });\n\n it(\"warns when model-visible tool output reaches the threshold\", () => {\n const warnSpy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n\n warnOnLargeToolOutput(\n {\n content: [\n {\n type: \"text\",\n text: \"x\".repeat(TOOL_OUTPUT_WARNING_TOKENS * 4),\n },\n ],\n },\n \"large-output\",\n );\n\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Tool \"large-output\" returned'),\n );\n warnSpy.mockRestore();\n });\n\n it(\"does not warn for large metadata\", () => {\n const warnSpy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n\n warnOnLargeToolOutput(\n { content: [], _meta: { private: \"x\".repeat(100_000) } },\n \"large-meta\",\n );\n\n expect(warnSpy).not.toHaveBeenCalled();\n warnSpy.mockRestore();\n });\n});\n"]}
@@ -0,0 +1,194 @@
1
+ import type { Implementation, Server as SdkServer, ServerOptions } from "@modelcontextprotocol/server";
2
+ import type { ErrorRequestHandler, Express, RequestHandler } from "express";
3
+ import type { OAuthConfig, OAuthProvider } from "./auth/index.js";
4
+ import type { ExtraClaims } from "./auth.js";
5
+ import { type JsonOptions, McpServer, type McpServerTypes, type ToolDef } from "./server.js";
6
+ /**
7
+ * The `handler` field of {@link SkybridgeConfig}: builds the app's MCP
8
+ * surface. Runs again for **every incoming request**, on a fresh
9
+ * {@link McpServer}, so keep it to registration: pools, clients and any other
10
+ * one-time work belong in `setup`, whose result is the second argument. It
11
+ * must **return** the chained server so `typeof app` carries the registered
12
+ * tool types.
13
+ *
14
+ * @typeParam TConfig - What `setup` resolved to, passed as the second argument.
15
+ */
16
+ export type SkybridgeHandler<TTools extends Record<string, ToolDef>, TConfig, TAuthExtra extends ExtraClaims> = (server: McpServer<Record<never, ToolDef>, TAuthExtra>, config: TConfig) => McpServer<TTools, TAuthExtra>;
17
+ /**
18
+ * What the `oauth` field accepts: an {@link OAuthConfig}, a provider
19
+ * (`oauth: auth0Provider(...)`), or a function of the `setup` result returning
20
+ * either. Providers and functions resolve once, at {@link Skybridge.run} or on
21
+ * the first request, never at module import. Anything asynchronous belongs in
22
+ * a provider's `resolve`.
23
+ */
24
+ export type SkybridgeOAuthInput<TConfig, TExtra extends ExtraClaims> = OAuthConfig<TExtra> | OAuthProvider<TExtra> | ((config: TConfig) => OAuthConfig<TExtra> | OAuthProvider<TExtra>);
25
+ /**
26
+ * Everything a Skybridge app needs in one bag: the MCP implementation info
27
+ * (`name`, `version`, …), the SDK's {@link ServerOptions} (`capabilities`,
28
+ * `instructions`, …), the Express and skills options, and the app's behavior
29
+ * (`setup`, `oauth`, `handler`).
30
+ *
31
+ * All type parameters are inferred from the value: the config from `setup`,
32
+ * the auth claims from `oauth`, and the tool registry from the server
33
+ * `handler` returns.
34
+ */
35
+ export type SkybridgeConfig<TTools extends Record<string, ToolDef> = Record<never, ToolDef>, TConfig = undefined, TAuthExtra extends ExtraClaims = ExtraClaims> = Implementation & ServerOptions & {
36
+ /** Options for the built-in `express.json()` middleware, e.g. `{ limit: "10mb" }`. */
37
+ json?: JsonOptions;
38
+ /**
39
+ * @experimental Serve Agent Skills from `src/skills` over MCP (SEP-2640).
40
+ * API may change.
41
+ */
42
+ skills?: boolean;
43
+ /**
44
+ * Loads whatever the app needs up front (remote config, secrets, datasets,
45
+ * …). Runs **once** — at {@link Skybridge.run} or on the first request,
46
+ * never at module import — and its awaited return value is passed to an
47
+ * `oauth` function and to `handler` as the second argument.
48
+ */
49
+ setup?: () => TConfig;
50
+ /**
51
+ * Resource-server OAuth. When set, mounts the well-known metadata routes
52
+ * and bearer auth on `/mcp`, and the verifier's claims type
53
+ * `extra.http.authInfo.extra` in tool handlers.
54
+ */
55
+ oauth?: SkybridgeOAuthInput<Awaited<TConfig>, TAuthExtra>;
56
+ /** Registers the MCP surface, per request. See {@link SkybridgeHandler}. */
57
+ handler: SkybridgeHandler<TTools, Awaited<TConfig>, TAuthExtra>;
58
+ };
59
+ /**
60
+ * A Skybridge app: the HTTP surface (Express, OAuth metadata, the `/mcp`
61
+ * route) plus a handler that builds the MCP server for each request.
62
+ *
63
+ * The handler runs for every request, so tools, resources, prompts and views
64
+ * are always registered on the instance that serves the request. Anything in
65
+ * the handler body other than registration therefore runs per request too.
66
+ * Anything asynchronous the app needs (remote config, secrets, …) goes in
67
+ * `setup`, which runs once and feeds the handler's second argument.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * export const app = new Skybridge({
72
+ * name: "my-app",
73
+ * version: "1.0.0",
74
+ * setup: async () => loadConfig(),
75
+ * oauth: (config) => descopeProvider({ url: config.mcpServerUrl }),
76
+ * handler: (server, config) =>
77
+ * server.registerTool(
78
+ * {
79
+ * name: "search",
80
+ * inputSchema: { query: z.string() },
81
+ * view: { component: "search" },
82
+ * },
83
+ * async ({ query }) => ({ content: `Results for ${query}` }),
84
+ * ),
85
+ * });
86
+ *
87
+ * export type AppType = typeof app;
88
+ * ```
89
+ *
90
+ * @see https://docs.skybridge.tech/api-reference/mcp-server
91
+ */
92
+ export declare class Skybridge<TTools extends Record<string, ToolDef> = Record<never, ToolDef>, TConfig = undefined, TAuthExtra extends ExtraClaims = ExtraClaims> {
93
+ readonly $types: McpServerTypes<TTools>;
94
+ private readonly serverInfo;
95
+ private readonly serverOptions;
96
+ private readonly skills?;
97
+ private oauthEnabled;
98
+ private readonly handler;
99
+ private readonly setup?;
100
+ private readonly oauthInput?;
101
+ private config?;
102
+ private readonly expressApp;
103
+ private readonly errorMiddleware;
104
+ private readonly monitoringEntry;
105
+ private resolveResourceMetadataUrl?;
106
+ private readyPromise?;
107
+ private slowHandlerWarned;
108
+ constructor({ name, title, version, description, icons, websiteUrl, json, skills, setup, oauth, handler, ...serverOptions }: SkybridgeConfig<TTools, TConfig, TAuthExtra>);
109
+ /**
110
+ * Resolve `setup` and `oauth`, then wire OAuth onto the Express app. Runs
111
+ * once; every entry point that needs a built server awaits it, and a failed
112
+ * attempt is retried on the next call.
113
+ *
114
+ * @internal
115
+ */
116
+ ready(): Promise<void>;
117
+ /**
118
+ * The underlying Express app. Use this to extend the HTTP server with
119
+ * custom routes, middleware, or settings — e.g.
120
+ * `app.express.get("/health", ...)`.
121
+ *
122
+ * `express.json()` is pre-applied — tune it via the `json` config field,
123
+ * e.g. `new Skybridge({ name, version, json: { limit: "10mb" }, handler })`.
124
+ * Register your handlers before `run()`; after `run()`, dev-mode middleware,
125
+ * the `/mcp` route, and the default error handler are appended in that order.
126
+ *
127
+ * Note: Alpic Cloud only routes traffic to `/mcp` — custom routes work
128
+ * locally and on self-hosted deployments.
129
+ */
130
+ get express(): Express;
131
+ /**
132
+ * Build a fresh server for one stateless HTTP request, as
133
+ * `createMcpHandler`'s factory contract requires: the handler runs again so
134
+ * the SDK's handler closures belong to the instance whose protocol era it
135
+ * stamps. Sharing one instance's handler maps instead would bind them to an
136
+ * instance that is never marked, pinning every request to the 2025 codec and
137
+ * letting concurrent callers overwrite each other's negotiated version.
138
+ *
139
+ * Awaits `setup` and the `oauth` input on first use.
140
+ */
141
+ createServerInstance(): Promise<SdkServer>;
142
+ /**
143
+ * Connect a Skybridge app to an MCP transport. Use this when you're
144
+ * embedding Skybridge in a host that already manages its own transport
145
+ * (e.g. stdio for desktop apps); for HTTP, prefer {@link Skybridge.run}
146
+ * which sets the transport up for you.
147
+ */
148
+ connect(transport: Parameters<SdkServer["connect"]>[0]): Promise<void>;
149
+ /**
150
+ * Register Express middleware on the underlying app. Mirrors `app.use` —
151
+ * pass handlers directly or a path-prefixed handler list. Register before
152
+ * {@link Skybridge.run}; ordering matches Express.
153
+ *
154
+ * Note: Alpic Cloud only routes traffic to `/mcp`. Custom paths work
155
+ * locally and on self-hosted deployments.
156
+ */
157
+ use(...handlers: RequestHandler[]): this;
158
+ use(path: string, ...handlers: RequestHandler[]): this;
159
+ /**
160
+ * Register Express error-handling middleware to run after the built-in
161
+ * `/mcp` route (or your custom route). Use this to log or transform errors
162
+ * thrown by tool handlers before the default error handler responds.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * app.useOnError((err, _req, _res, next) => {
167
+ * logger.error(err);
168
+ * next(err);
169
+ * });
170
+ * ```
171
+ */
172
+ useOnError(...handlers: ErrorRequestHandler[]): this;
173
+ useOnError(path: string, ...handlers: ErrorRequestHandler[]): this;
174
+ /**
175
+ * Start the HTTP server. Listens on `process.env.__PORT` (default `3000`),
176
+ * mounts the `/mcp` route, and applies any custom Express middleware
177
+ * registered via {@link Skybridge.use} / {@link Skybridge.useOnError}.
178
+ *
179
+ * On Cloudflare Workers / workerd, returns an object exposing `fetch` so
180
+ * the runtime can bridge incoming requests to the Node HTTP server. On
181
+ * Vercel (`VERCEL === "1"`), returns the Express app directly so the
182
+ * serverless function entry can call it as a `(req, res)` handler. On
183
+ * Node, returns `undefined` once listening. When the process was spawned
184
+ * with an IPC channel, the bound port is reported to the parent as
185
+ * `{ type: "skybridge:listening", port }`, the readiness signal test runners
186
+ * wait on instead of polling.
187
+ */
188
+ run(): Promise<{
189
+ fetch: (...args: unknown[]) => unknown;
190
+ } | Express | undefined>;
191
+ private buildServer;
192
+ private middlewareEntries;
193
+ private instrumentHandlers;
194
+ }