@hanzo/dev 4.0.1 → 4.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 (371) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
  3. package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
  4. package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
  5. package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
  6. package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
  7. package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
  8. package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
  9. package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
  10. package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
  11. package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
  12. package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
  13. package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
  14. package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
  15. package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
  16. package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
  17. package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
  18. package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
  19. package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
  20. package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
  21. package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
  22. package/dist/builder/activity.d.ts +16 -0
  23. package/dist/builder/activity.js +51 -0
  24. package/dist/builder/address.d.ts +11 -0
  25. package/dist/builder/address.js +50 -0
  26. package/dist/builder/ago.d.ts +2 -0
  27. package/dist/builder/ago.js +18 -0
  28. package/dist/builder/api/agents.d.ts +139 -0
  29. package/dist/builder/api/agents.js +253 -0
  30. package/dist/builder/api/auto.d.ts +166 -0
  31. package/dist/builder/api/auto.js +300 -0
  32. package/dist/builder/api/billing.d.ts +263 -0
  33. package/dist/builder/api/billing.js +401 -0
  34. package/dist/builder/api/call.d.ts +53 -0
  35. package/dist/builder/api/call.js +123 -0
  36. package/dist/builder/api/capabilities.d.ts +14 -0
  37. package/dist/builder/api/capabilities.js +41 -0
  38. package/dist/builder/api/changes.d.ts +74 -0
  39. package/dist/builder/api/changes.js +75 -0
  40. package/dist/builder/api/chat.d.ts +12 -0
  41. package/dist/builder/api/chat.js +28 -0
  42. package/dist/builder/api/cli.d.ts +59 -0
  43. package/dist/builder/api/cli.js +133 -0
  44. package/dist/builder/api/codebases.d.ts +46 -0
  45. package/dist/builder/api/codebases.js +100 -0
  46. package/dist/builder/api/coding.d.ts +117 -0
  47. package/dist/builder/api/coding.js +222 -0
  48. package/dist/builder/api/connectors.d.ts +76 -0
  49. package/dist/builder/api/connectors.js +111 -0
  50. package/dist/builder/api/consent.d.ts +22 -0
  51. package/dist/builder/api/consent.js +28 -0
  52. package/dist/builder/api/conversations.d.ts +20 -0
  53. package/dist/builder/api/conversations.js +23 -0
  54. package/dist/builder/api/draft.d.ts +38 -0
  55. package/dist/builder/api/draft.js +87 -0
  56. package/dist/builder/api/environment.d.ts +55 -0
  57. package/dist/builder/api/environment.js +126 -0
  58. package/dist/builder/api/gallery.d.ts +32 -0
  59. package/dist/builder/api/gallery.js +85 -0
  60. package/dist/builder/api/git.d.ts +59 -0
  61. package/dist/builder/api/git.js +117 -0
  62. package/dist/builder/api/github.d.ts +230 -0
  63. package/dist/builder/api/github.js +373 -0
  64. package/dist/builder/api/keys.d.ts +35 -0
  65. package/dist/builder/api/keys.js +72 -0
  66. package/dist/builder/api/library.d.ts +116 -0
  67. package/dist/builder/api/library.js +214 -0
  68. package/dist/builder/api/limits.d.ts +69 -0
  69. package/dist/builder/api/limits.js +86 -0
  70. package/dist/builder/api/links.d.ts +51 -0
  71. package/dist/builder/api/links.js +75 -0
  72. package/dist/builder/api/machines.d.ts +122 -0
  73. package/dist/builder/api/machines.js +238 -0
  74. package/dist/builder/api/mcp.d.ts +10 -0
  75. package/dist/builder/api/mcp.js +47 -0
  76. package/dist/builder/api/members.d.ts +35 -0
  77. package/dist/builder/api/members.js +95 -0
  78. package/dist/builder/api/memory.d.ts +14 -0
  79. package/dist/builder/api/memory.js +35 -0
  80. package/dist/builder/api/models.d.ts +17 -0
  81. package/dist/builder/api/models.js +20 -0
  82. package/dist/builder/api/places.d.ts +32 -0
  83. package/dist/builder/api/places.js +29 -0
  84. package/dist/builder/api/platform.d.ts +68 -0
  85. package/dist/builder/api/platform.js +87 -0
  86. package/dist/builder/api/plugins.d.ts +42 -0
  87. package/dist/builder/api/plugins.js +175 -0
  88. package/dist/builder/api/pref.d.ts +77 -0
  89. package/dist/builder/api/pref.js +93 -0
  90. package/dist/builder/api/profile.d.ts +11 -0
  91. package/dist/builder/api/profile.js +41 -0
  92. package/dist/builder/api/projects.d.ts +99 -0
  93. package/dist/builder/api/projects.js +166 -0
  94. package/dist/builder/api/provider.d.ts +49 -0
  95. package/dist/builder/api/provider.js +96 -0
  96. package/dist/builder/api/sandbox.d.ts +90 -0
  97. package/dist/builder/api/sandbox.js +223 -0
  98. package/dist/builder/api/sessions.d.ts +123 -0
  99. package/dist/builder/api/sessions.js +255 -0
  100. package/dist/builder/api/skills.d.ts +82 -0
  101. package/dist/builder/api/skills.js +117 -0
  102. package/dist/builder/api/sse.d.ts +24 -0
  103. package/dist/builder/api/sse.js +68 -0
  104. package/dist/builder/api/studio.d.ts +59 -0
  105. package/dist/builder/api/studio.js +91 -0
  106. package/dist/builder/api/talk.d.ts +48 -0
  107. package/dist/builder/api/talk.js +81 -0
  108. package/dist/builder/api/tools.d.ts +34 -0
  109. package/dist/builder/api/tools.js +37 -0
  110. package/dist/builder/api/turn.d.ts +202 -0
  111. package/dist/builder/api/turn.js +772 -0
  112. package/dist/builder/api/verdict.d.ts +3 -0
  113. package/dist/builder/api/verdict.js +21 -0
  114. package/dist/builder/api/webhooks.d.ts +47 -0
  115. package/dist/builder/api/webhooks.js +82 -0
  116. package/dist/builder/api/work.d.ts +110 -0
  117. package/dist/builder/api/work.js +218 -0
  118. package/dist/builder/ask.d.ts +51 -0
  119. package/dist/builder/ask.js +147 -0
  120. package/dist/builder/automations.d.ts +33 -0
  121. package/dist/builder/automations.js +453 -0
  122. package/dist/builder/awake.d.ts +24 -0
  123. package/dist/builder/awake.js +68 -0
  124. package/dist/builder/back.d.ts +30 -0
  125. package/dist/builder/back.js +105 -0
  126. package/dist/builder/builder.d.ts +12 -0
  127. package/dist/builder/builder.js +162 -0
  128. package/dist/builder/carry.d.ts +48 -0
  129. package/dist/builder/carry.js +278 -0
  130. package/dist/builder/choice.d.ts +134 -0
  131. package/dist/builder/choice.js +152 -0
  132. package/dist/builder/claims.d.ts +13 -0
  133. package/dist/builder/claims.js +35 -0
  134. package/dist/builder/clipboard.d.ts +2 -0
  135. package/dist/builder/clipboard.js +10 -0
  136. package/dist/builder/customize/agents.d.ts +11 -0
  137. package/dist/builder/customize/agents.js +513 -0
  138. package/dist/builder/customize/connectors.d.ts +2 -0
  139. package/dist/builder/customize/connectors.js +319 -0
  140. package/dist/builder/customize/drafted.d.ts +4 -0
  141. package/dist/builder/customize/drafted.js +92 -0
  142. package/dist/builder/customize/index.d.ts +8 -0
  143. package/dist/builder/customize/index.js +127 -0
  144. package/dist/builder/customize/inventory.d.ts +14 -0
  145. package/dist/builder/customize/inventory.js +127 -0
  146. package/dist/builder/customize/load.d.ts +9 -0
  147. package/dist/builder/customize/load.js +22 -0
  148. package/dist/builder/customize/ocean.d.ts +41 -0
  149. package/dist/builder/customize/ocean.js +332 -0
  150. package/dist/builder/customize/plugins.d.ts +2 -0
  151. package/dist/builder/customize/plugins.js +136 -0
  152. package/dist/builder/customize/roles.d.ts +4 -0
  153. package/dist/builder/customize/roles.js +105 -0
  154. package/dist/builder/customize/say.d.ts +13 -0
  155. package/dist/builder/customize/say.js +32 -0
  156. package/dist/builder/customize/skills.d.ts +2 -0
  157. package/dist/builder/customize/skills.js +208 -0
  158. package/dist/builder/customize/ui.d.ts +152 -0
  159. package/dist/builder/customize/ui.js +208 -0
  160. package/dist/builder/data.d.ts +57 -0
  161. package/dist/builder/data.js +322 -0
  162. package/dist/builder/design.d.ts +140 -0
  163. package/dist/builder/design.js +175 -0
  164. package/dist/builder/desk.d.ts +48 -0
  165. package/dist/builder/desk.js +449 -0
  166. package/dist/builder/dev-mode.d.ts +43 -0
  167. package/dist/builder/dev-mode.js +120 -0
  168. package/dist/builder/door.d.ts +11 -0
  169. package/dist/builder/door.js +126 -0
  170. package/dist/builder/environment.d.ts +23 -0
  171. package/dist/builder/environment.js +193 -0
  172. package/dist/builder/files.d.ts +23 -0
  173. package/dist/builder/files.js +175 -0
  174. package/dist/builder/find.d.ts +7 -0
  175. package/dist/builder/find.js +80 -0
  176. package/dist/builder/foot.d.ts +30 -0
  177. package/dist/builder/foot.js +79 -0
  178. package/dist/builder/forge.d.ts +4 -0
  179. package/dist/builder/forge.js +639 -0
  180. package/dist/builder/gear.d.ts +60 -0
  181. package/dist/builder/gear.js +180 -0
  182. package/dist/builder/git.d.ts +21 -0
  183. package/dist/builder/git.js +118 -0
  184. package/dist/builder/github-sync.d.ts +70 -0
  185. package/dist/builder/github-sync.js +435 -0
  186. package/dist/builder/gutter.d.ts +17 -0
  187. package/dist/builder/gutter.js +25 -0
  188. package/dist/builder/handoff.d.ts +8 -0
  189. package/dist/builder/handoff.js +22 -0
  190. package/dist/builder/host.d.ts +189 -0
  191. package/dist/builder/host.js +46 -0
  192. package/dist/builder/index.d.ts +108 -0
  193. package/dist/builder/index.js +99 -0
  194. package/dist/builder/landing.d.ts +34 -0
  195. package/dist/builder/landing.js +725 -0
  196. package/dist/builder/library.d.ts +21 -0
  197. package/dist/builder/library.js +526 -0
  198. package/dist/builder/local.d.ts +80 -0
  199. package/dist/builder/local.js +124 -0
  200. package/dist/builder/make.d.ts +10 -0
  201. package/dist/builder/make.js +120 -0
  202. package/dist/builder/markdown.d.ts +49 -0
  203. package/dist/builder/markdown.js +125 -0
  204. package/dist/builder/marks.d.ts +15 -0
  205. package/dist/builder/marks.js +18 -0
  206. package/dist/builder/merge.d.ts +223 -0
  207. package/dist/builder/merge.js +380 -0
  208. package/dist/builder/meter.d.ts +31 -0
  209. package/dist/builder/meter.js +54 -0
  210. package/dist/builder/mind.d.ts +107 -0
  211. package/dist/builder/mind.js +335 -0
  212. package/dist/builder/names.d.ts +40 -0
  213. package/dist/builder/names.js +189 -0
  214. package/dist/builder/nav.d.ts +28 -0
  215. package/dist/builder/nav.js +218 -0
  216. package/dist/builder/out.d.ts +16 -0
  217. package/dist/builder/out.js +24 -0
  218. package/dist/builder/page.d.ts +55 -0
  219. package/dist/builder/page.js +217 -0
  220. package/dist/builder/pane.d.ts +30 -0
  221. package/dist/builder/pane.js +21 -0
  222. package/dist/builder/panel.d.ts +101 -0
  223. package/dist/builder/panel.js +408 -0
  224. package/dist/builder/pdf.d.ts +139 -0
  225. package/dist/builder/pdf.js +847 -0
  226. package/dist/builder/pick.d.ts +10 -0
  227. package/dist/builder/pick.js +38 -0
  228. package/dist/builder/plain.d.ts +59 -0
  229. package/dist/builder/plain.js +209 -0
  230. package/dist/builder/plan.d.ts +63 -0
  231. package/dist/builder/plan.js +155 -0
  232. package/dist/builder/plans.d.ts +1 -0
  233. package/dist/builder/plans.js +157 -0
  234. package/dist/builder/plugin.d.ts +60 -0
  235. package/dist/builder/plugin.js +1 -0
  236. package/dist/builder/plugins/design.d.ts +8 -0
  237. package/dist/builder/plugins/design.js +71 -0
  238. package/dist/builder/plugins/index.d.ts +46 -0
  239. package/dist/builder/plugins/index.js +117 -0
  240. package/dist/builder/plugins/pdf.d.ts +18 -0
  241. package/dist/builder/plugins/pdf.js +83 -0
  242. package/dist/builder/plugins/project.d.ts +5 -0
  243. package/dist/builder/plugins/project.js +68 -0
  244. package/dist/builder/plugins/research.d.ts +24 -0
  245. package/dist/builder/plugins/research.js +147 -0
  246. package/dist/builder/plugins/sketch.d.ts +9 -0
  247. package/dist/builder/plugins/sketch.js +101 -0
  248. package/dist/builder/plugins/slides.d.ts +14 -0
  249. package/dist/builder/plugins/slides.js +55 -0
  250. package/dist/builder/plugins/template.d.ts +13 -0
  251. package/dist/builder/plugins/template.js +95 -0
  252. package/dist/builder/prefs.d.ts +29 -0
  253. package/dist/builder/prefs.js +91 -0
  254. package/dist/builder/preview-url.d.ts +47 -0
  255. package/dist/builder/preview-url.js +107 -0
  256. package/dist/builder/project.d.ts +18 -0
  257. package/dist/builder/project.js +604 -0
  258. package/dist/builder/prose.d.ts +4 -0
  259. package/dist/builder/prose.js +57 -0
  260. package/dist/builder/publish.d.ts +18 -0
  261. package/dist/builder/publish.js +141 -0
  262. package/dist/builder/question.d.ts +33 -0
  263. package/dist/builder/question.js +64 -0
  264. package/dist/builder/redesign.d.ts +32 -0
  265. package/dist/builder/redesign.js +117 -0
  266. package/dist/builder/removal.d.ts +71 -0
  267. package/dist/builder/removal.js +73 -0
  268. package/dist/builder/reply.d.ts +50 -0
  269. package/dist/builder/reply.js +196 -0
  270. package/dist/builder/roles.d.ts +10 -0
  271. package/dist/builder/roles.js +28 -0
  272. package/dist/builder/route.d.ts +85 -0
  273. package/dist/builder/route.js +126 -0
  274. package/dist/builder/run.d.ts +4 -0
  275. package/dist/builder/run.js +804 -0
  276. package/dist/builder/runmeta.d.ts +16 -0
  277. package/dist/builder/runmeta.js +69 -0
  278. package/dist/builder/say.d.ts +2 -0
  279. package/dist/builder/say.js +7 -0
  280. package/dist/builder/scheduled.d.ts +3 -0
  281. package/dist/builder/scheduled.js +328 -0
  282. package/dist/builder/section.d.ts +27 -0
  283. package/dist/builder/section.js +60 -0
  284. package/dist/builder/settings/account.d.ts +1 -0
  285. package/dist/builder/settings/account.js +111 -0
  286. package/dist/builder/settings/billing.d.ts +1 -0
  287. package/dist/builder/settings/billing.js +210 -0
  288. package/dist/builder/settings/capabilities.d.ts +1 -0
  289. package/dist/builder/settings/capabilities.js +66 -0
  290. package/dist/builder/settings/card.d.ts +31 -0
  291. package/dist/builder/settings/card.js +140 -0
  292. package/dist/builder/settings/code.d.ts +1 -0
  293. package/dist/builder/settings/code.js +70 -0
  294. package/dist/builder/settings/credits.d.ts +10 -0
  295. package/dist/builder/settings/credits.js +123 -0
  296. package/dist/builder/settings/environments.d.ts +1 -0
  297. package/dist/builder/settings/environments.js +60 -0
  298. package/dist/builder/settings/general.d.ts +1 -0
  299. package/dist/builder/settings/general.js +58 -0
  300. package/dist/builder/settings/index.d.ts +4 -0
  301. package/dist/builder/settings/index.js +25 -0
  302. package/dist/builder/settings/integrations.d.ts +8 -0
  303. package/dist/builder/settings/integrations.js +138 -0
  304. package/dist/builder/settings/keys.d.ts +1 -0
  305. package/dist/builder/settings/keys.js +114 -0
  306. package/dist/builder/settings/list.d.ts +10 -0
  307. package/dist/builder/settings/list.js +28 -0
  308. package/dist/builder/settings/machines.d.ts +4 -0
  309. package/dist/builder/settings/machines.js +243 -0
  310. package/dist/builder/settings/members.d.ts +1 -0
  311. package/dist/builder/settings/members.js +77 -0
  312. package/dist/builder/settings/memory.d.ts +1 -0
  313. package/dist/builder/settings/memory.js +62 -0
  314. package/dist/builder/settings/notifications.d.ts +1 -0
  315. package/dist/builder/settings/notifications.js +111 -0
  316. package/dist/builder/settings/plan.d.ts +17 -0
  317. package/dist/builder/settings/plan.js +131 -0
  318. package/dist/builder/settings/privacy.d.ts +1 -0
  319. package/dist/builder/settings/privacy.js +76 -0
  320. package/dist/builder/settings/sections.d.ts +16 -0
  321. package/dist/builder/settings/sections.js +34 -0
  322. package/dist/builder/settings/shared.d.ts +6 -0
  323. package/dist/builder/settings/shared.js +58 -0
  324. package/dist/builder/settings/ui.d.ts +50 -0
  325. package/dist/builder/settings/ui.js +53 -0
  326. package/dist/builder/settings/usage.d.ts +1 -0
  327. package/dist/builder/settings/usage.js +24 -0
  328. package/dist/builder/shared.d.ts +26 -0
  329. package/dist/builder/shared.js +15 -0
  330. package/dist/builder/shelf.d.ts +16 -0
  331. package/dist/builder/shelf.js +219 -0
  332. package/dist/builder/side.d.ts +40 -0
  333. package/dist/builder/side.js +208 -0
  334. package/dist/builder/site.d.ts +75 -0
  335. package/dist/builder/site.js +138 -0
  336. package/dist/builder/spend.d.ts +21 -0
  337. package/dist/builder/spend.js +80 -0
  338. package/dist/builder/standing.d.ts +36 -0
  339. package/dist/builder/standing.js +66 -0
  340. package/dist/builder/suggest.d.ts +238 -0
  341. package/dist/builder/suggest.js +463 -0
  342. package/dist/builder/suggestions.d.ts +49 -0
  343. package/dist/builder/suggestions.js +260 -0
  344. package/dist/builder/summary.d.ts +60 -0
  345. package/dist/builder/summary.js +81 -0
  346. package/dist/builder/sync.d.ts +1 -0
  347. package/dist/builder/sync.js +187 -0
  348. package/dist/builder/tabs.d.ts +85 -0
  349. package/dist/builder/tabs.js +288 -0
  350. package/dist/builder/talk.d.ts +5 -0
  351. package/dist/builder/talk.js +108 -0
  352. package/dist/builder/thread.d.ts +60 -0
  353. package/dist/builder/thread.js +302 -0
  354. package/dist/builder/tools.d.ts +22 -0
  355. package/dist/builder/tools.js +52 -0
  356. package/dist/builder/transcript.d.ts +47 -0
  357. package/dist/builder/transcript.js +108 -0
  358. package/dist/builder/voice.d.ts +8 -0
  359. package/dist/builder/voice.js +24 -0
  360. package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
  361. package/dist/core.js +1 -0
  362. package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
  363. package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
  364. package/dist/index.d.ts +2 -0
  365. package/dist/index.js +2 -1
  366. package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
  367. package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
  368. package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
  369. package/package.json +101 -11
  370. /package/{index.d.ts → dist/core.d.ts} +0 -0
  371. /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
@@ -0,0 +1,57 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Markdown an agent writes, drawn as text (markdown.ts reads it).
4
+ *
5
+ * @hanzo/ui leaves the markdown pipeline to the surface, and the builder needs
6
+ * only the part agents use. Nothing here produces HTML from the text: every
7
+ * piece is a React element holding a string, and a link is drawn only for an
8
+ * http(s) address, opened in a new tab.
9
+ *
10
+ * Set at Chat's sizes (@hanzo/rooms `Prose`): running text at $2 on a $3 line,
11
+ * headings a rung apart from $6, code in @hanzo/ui's `Code`, blocks $2 apart,
12
+ * so an answer reads the same in Chat and in a run.
13
+ */
14
+ import { ScrollView, SizableText, XStack, YStack } from '@hanzo/gui';
15
+ import { Code } from '@hanzo/ui/chat';
16
+ import { blocks, spans } from './markdown.js';
17
+ import { Out } from './out.js';
18
+ const mono = { fontFamily: 'var(--f-mono, ui-monospace, monospace)' };
19
+ function Inline({ text }) {
20
+ return (_jsx(_Fragment, { children: spans(text).map((s, i) => {
21
+ switch (s.kind) {
22
+ case 'code':
23
+ return (_jsx(SizableText, { size: "$1", color: "$ink", bg: "$hover", px: "$1", rounded: "$1", style: mono, children: s.text }, i));
24
+ case 'strong':
25
+ return (_jsx(SizableText, { size: "$2", lineHeight: "$3", color: "$ink", fontWeight: "600", children: s.text }, i));
26
+ case 'em':
27
+ return (_jsx(SizableText, { size: "$2", lineHeight: "$3", color: "$ink", fontStyle: "italic", children: s.text }, i));
28
+ case 'link':
29
+ return (_jsx(Out, { href: s.href, children: _jsx(SizableText, { size: "$2", lineHeight: "$3", color: "$ink", textDecorationLine: "underline", children: s.text }) }, i));
30
+ default:
31
+ return s.text;
32
+ }
33
+ }) }));
34
+ }
35
+ const SIZES = ['$6', '$4', '$3', '$2', '$2', '$2'];
36
+ function Draw({ block }) {
37
+ switch (block.kind) {
38
+ case 'heading':
39
+ return (_jsx(SizableText, { size: SIZES[block.level - 1], color: "$ink", fontWeight: "600", children: _jsx(Inline, { text: block.text }) }));
40
+ case 'code':
41
+ return (_jsx(Code, { language: block.lang || 'text', value: block.text, children: block.text }));
42
+ case 'rule':
43
+ return _jsx(YStack, { height: 1, bg: "$borderColor", my: "$1" });
44
+ case 'quote':
45
+ return (_jsx(YStack, { borderLeftWidth: 2, borderColor: "$borderColor", pl: "$3", children: _jsx(SizableText, { size: "$2", lineHeight: "$3", color: "$soft", children: _jsx(Inline, { text: block.text }) }) }));
46
+ case 'list':
47
+ return (_jsx(YStack, { gap: "$1", role: "list", children: block.items.map((item, i) => (_jsxs(XStack, { gap: "$1", pl: item.depth * 16, role: "listitem", children: [_jsx(SizableText, { size: "$2", lineHeight: "$3", color: "$soft", minW: 14, style: { textAlign: 'right' }, children: block.ordered ? `${block.start + i}.` : '•' }), _jsx(SizableText, { flex: 1, minW: 0, size: "$2", lineHeight: "$3", color: "$ink", children: _jsx(Inline, { text: item.text }) })] }, i))) }));
48
+ case 'table':
49
+ return (_jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", minW: "100%", children: [block.head, ...block.rows].map((row, r) => (_jsx(XStack, { borderTopWidth: r ? 1 : 0, borderColor: "$borderColor", bg: r ? 'transparent' : '$hover', children: block.head.map((_, c) => (_jsx(SizableText, { flex: 1, minW: 96, px: "$2", py: "$1.5", size: "$2", color: "$ink", fontWeight: r ? '400' : '600', children: _jsx(Inline, { text: row[c] ?? '' }) }, c))) }, r))) }) }));
50
+ default:
51
+ return (_jsx(SizableText, { size: "$2", lineHeight: "$3", color: "$ink", children: _jsx(Inline, { text: block.text }) }));
52
+ }
53
+ }
54
+ /** A markdown text, drawn. */
55
+ export function Prose({ text }) {
56
+ return (_jsx(YStack, { "data-slot": "prose", gap: "$2", minW: 0, children: blocks(text).map((b, i) => (_jsx(Draw, { block: b }, i))) }));
57
+ }
@@ -0,0 +1,18 @@
1
+ export interface Source {
2
+ /** The https clone URL. */
3
+ repo: string;
4
+ /** What to call it: `owner/name` or a project's name. */
5
+ title: string;
6
+ ref: string;
7
+ /** The app name to declare. */
8
+ name: string;
9
+ /** The project to add it to, when there already is one. */
10
+ project?: string;
11
+ /** Current preview URL for this project, shown separately from the live site URL (#365). */
12
+ preview?: string;
13
+ }
14
+ export declare function Publish({ source, onClose, onLive }: {
15
+ source: Source | null;
16
+ onClose: () => void;
17
+ onLive?: () => void;
18
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,141 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Adding a repository to a project — the one publish path, from a repo row
4
+ * ("Add to project") and from a workspace's Publish.
5
+ *
6
+ * `POST /v1/platform/apps` builds the repository and writes its declaration.
7
+ * On a branch (everyone) that is a review: nothing deploys until it merges,
8
+ * and the review link is the thing to open. An org admin can take a green
9
+ * build to main, which CD applies: that is the second call, with the build's
10
+ * tag, because main refuses an image that is not built yet.
11
+ *
12
+ * A repository in the org's own code workspace answers `live` instead: its
13
+ * build puts it on the project's address when it finishes, so there is no
14
+ * review and nothing to take to main. Its build is followed on the board like
15
+ * any other, and `onLive` is told when it succeeds, so the host reads the
16
+ * project's address again.
17
+ *
18
+ * Every state shown is one the platform reported; a refusal shows the
19
+ * platform's own sentence. The dialog's own words are the reader's language
20
+ * (@hanzo/i18n `t`).
21
+ */
22
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
23
+ import { useI18n } from '@hanzo/i18n/react';
24
+ import { ExternalLink } from '@hanzogui/lucide-icons-2';
25
+ import { Button, Dialog, DialogContent, DialogDescription, DialogTitle, Input } from '@hanzo/ui';
26
+ import { useEffect, useRef, useState } from 'react';
27
+ import { builds, declare, label } from './api/platform.js';
28
+ import { useHost, useTarget } from './host.js';
29
+ import { Out } from './out.js';
30
+ const TERMINAL_FAIL = /^(failed|fail|error|errored|canceled|cancelled)$/i;
31
+ const TERMINAL_OK = /^(succeeded|success|done|complete|completed|ok)$/i;
32
+ export function Publish({ source, onClose, onLive }) {
33
+ const target = useTarget();
34
+ const host = useHost();
35
+ const { t } = useI18n();
36
+ const [project, setProject] = useState('');
37
+ const [appName, setAppName] = useState('');
38
+ const [phase, setPhase] = useState('ask');
39
+ const [out, setOut] = useState(null);
40
+ const [status, setStatus] = useState('');
41
+ const [error, setError] = useState('');
42
+ const told = useRef(onLive);
43
+ told.current = onLive;
44
+ useEffect(() => {
45
+ setProject(source?.project ?? source?.name ?? '');
46
+ setAppName(source?.name ?? '');
47
+ setPhase('ask');
48
+ setOut(null);
49
+ setStatus('');
50
+ setError('');
51
+ }, [source]);
52
+ const green = TERMINAL_OK.test(status);
53
+ const buildFailed = TERMINAL_FAIL.test(status);
54
+ // The build is asynchronous; stop polling once it reaches a terminal success or failure state.
55
+ useEffect(() => {
56
+ const id = out?.build?.id;
57
+ if (!id || phase !== 'declared' || green || buildFailed)
58
+ return;
59
+ let live = true;
60
+ const tick = async () => {
61
+ try {
62
+ const row = (await builds(target)).find((b) => b.id === id);
63
+ if (live && row)
64
+ setStatus(row.status);
65
+ }
66
+ catch {
67
+ /* the status stays as last read */
68
+ }
69
+ };
70
+ void tick();
71
+ const every = setInterval(tick, 5000);
72
+ return () => {
73
+ live = false;
74
+ clearInterval(every);
75
+ };
76
+ }, [target, out, phase, green, buildFailed]);
77
+ // A site's build going green is the site going live, at the project's address.
78
+ useEffect(() => {
79
+ if (out?.live && green)
80
+ told.current?.();
81
+ }, [out, green]);
82
+ if (!source)
83
+ return null;
84
+ const resolvedName = label(appName || source.name);
85
+ const resolvedProject = label(project || source.name);
86
+ const locked = phase === 'sending' || phase === 'shipping' || phase === 'shipped' || (phase === 'declared' && !buildFailed);
87
+ const previewHost = (() => {
88
+ if (!source.preview)
89
+ return '';
90
+ try {
91
+ return new URL(source.preview).hostname.toLowerCase();
92
+ }
93
+ catch {
94
+ return '';
95
+ }
96
+ })();
97
+ const sameAsPreview = Boolean(previewHost && previewHost.startsWith(`${resolvedName}.`));
98
+ const send = async () => {
99
+ setPhase('sending');
100
+ setOut(null);
101
+ setStatus('');
102
+ setError('');
103
+ try {
104
+ const d = await declare(target, { repo: source.repo, ref: source.ref, name: resolvedName, project: resolvedProject, mode: 'branch' });
105
+ setOut(d);
106
+ setStatus(d.build?.status ?? '');
107
+ setPhase('declared');
108
+ }
109
+ catch (e) {
110
+ setError(e.message);
111
+ setPhase('failed');
112
+ }
113
+ };
114
+ // The build this write started; its status is what the platform last said of it.
115
+ const built = out?.build?.id ?? '';
116
+ const liveUrl = out?.hosts?.[0] ?? '';
117
+ // Offered only once that build is green.
118
+ const ship = async () => {
119
+ setPhase('shipping');
120
+ setError('');
121
+ try {
122
+ await declare(target, { repo: source.repo, ref: source.ref, name: resolvedName, project: resolvedProject, mode: 'commit', tag: built });
123
+ setPhase('shipped');
124
+ }
125
+ catch (e) {
126
+ setError(e.message);
127
+ setPhase('declared');
128
+ }
129
+ };
130
+ return (_jsx(Dialog, { open: true, onOpenChange: (o) => !o && onClose(), children: _jsxs(DialogContent, { maxW: 480, children: [_jsx(DialogTitle, { children: t('Add to project') }), _jsx(DialogDescription, { children: out?.live
131
+ ? t('Build {repo} at {ref} and publish it at its project’s address.', { repo: source.title, ref: source.ref })
132
+ : `${t('Build {repo} at {ref} and declare it in a project.', { repo: source.title, ref: source.ref })} ${host.admin ? t('As an admin you can take a green build to main.') : t('It opens a review; merging it is what deploys.')}` }), source.preview ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", px: "$2.5", py: "$2", rounded: "$2", bg: "$panel", borderWidth: 1, borderColor: "$borderColor", minW: 0, children: [_jsx(SizableText, { size: "$1", color: "$soft", shrink: 0, children: t('Preview URL') }), _jsx(XStack, { flex: 1, minW: 0, justify: "flex-end", children: _jsx(Out, { href: source.preview, children: _jsxs(XStack, { items: "center", gap: "$1", minW: 0, 'data-i18n-ltr': '', children: [_jsx(SizableText, { size: "$1", color: "$ink", textDecorationLine: "underline", numberOfLines: 1, minW: 0, children: source.preview }), _jsx(ExternalLink, { size: 11, opacity: 0.6, shrink: 0 })] }) }) })] })) : null, _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: "publish-app-name", children: t('Live app name') }), _jsx(Input, { id: "publish-app-name", value: appName, onChangeText: (v) => setAppName(v), disabled: locked, placeholder: label(source.name), "aria-label": t('Live app name') }), _jsx(SizableText, { size: "$1", color: "$soft", children: sameAsPreview
133
+ ? t('Declared as {name} — change this if you want a separate name from the preview.', { name: resolvedName })
134
+ : t('Declared as {name}', { name: resolvedName }) })] }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: "publish-project", children: t('Project') }), _jsx(Input, { id: "publish-project", value: project, onChangeText: (v) => setProject(v), disabled: locked, placeholder: label(source.name), "aria-label": t('Project') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Saved as {name}', { name: resolvedProject }) })] }), out ? (_jsxs(YStack, { gap: "$2", role: buildFailed ? 'alert' : 'status', children: [out.notice ? (_jsx(SizableText, { size: "$2", color: "$soft", children: out.notice })) : null, _jsx(SizableText, { size: "$2", color: buildFailed ? '$red10' : '$ink', children: phase === 'shipped'
135
+ ? t('Declared on main — CD applies it on its next pass.')
136
+ : out.live && green
137
+ ? t('Build {id} succeeded — it is live at the project’s address.', { id: built })
138
+ : status
139
+ ? t('Build {id}: {status}', { id: built, status })
140
+ : t('Build {id}: building', { id: built }) }), liveUrl ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", px: "$2.5", py: "$2", rounded: "$2", bg: "$panel", borderWidth: 1, borderColor: "$borderColor", minW: 0, children: [_jsx(SizableText, { size: "$1", color: "$soft", shrink: 0, children: t('Live URL') }), _jsx(XStack, { flex: 1, minW: 0, justify: "flex-end", children: _jsx(Out, { href: liveUrl, children: _jsxs(XStack, { items: "center", gap: "$1", minW: 0, 'data-i18n-ltr': '', children: [_jsx(SizableText, { size: "$1", color: "$ink", textDecorationLine: "underline", numberOfLines: 1, minW: 0, children: liveUrl }), _jsx(ExternalLink, { size: 11, opacity: 0.6, shrink: 0 })] }) }) })] })) : null, out.review ? (_jsxs(Out, { href: out.review, children: [_jsx(SizableText, { size: "$2", color: "$ink", textDecorationLine: "underline", children: t('Open the review') }), _jsx(ExternalLink, { size: 12, opacity: 0.6, shrink: 0 })] })) : null] })) : null, error ? (_jsx(SizableText, { size: "$2", color: "$red10", role: "alert", children: error })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { variant: "outline", size: "sm", onPress: onClose, children: phase === 'shipped' || (phase === 'declared' && !buildFailed) ? t('Done') : t('Cancel') }), phase === 'ask' || phase === 'failed' || phase === 'sending' || buildFailed ? (_jsx(Button, { size: "sm", disabled: phase === 'sending', onPress: () => void send(), children: phase === 'sending' ? t('Adding…') : buildFailed ? t('Try again') : t('Add to project') })) : host.admin && !out?.live && (phase === 'declared' || phase === 'shipping') ? (_jsx(Button, { size: "sm", disabled: !green || phase === 'shipping', onPress: () => void ship(), children: phase === 'shipping' ? t('Shipping…') : green ? t('Ship to main') : t('Waiting for the build') })) : null] })] }) }));
141
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What a screen does with the spend questions it asks, apart from any dialog:
3
+ * the one rule for a yes. A yes counts only if it is strictly `true`, arrives
4
+ * while the screen that asked is still here, and answers the latest question it
5
+ * asked: a newer press supersedes one still waiting, so a host that never
6
+ * answers leaves nothing stuck, and two quick presses spend once. A throw is a no.
7
+ */
8
+ import type { Say } from '@hanzo/i18n/react';
9
+ import type { Ask, Spend } from './host.tsx';
10
+ /**
11
+ * Where a host may keep "Don't ask again" for a question: its kind and what it
12
+ * uses, so one yes covers only the same kind of spend on the same kind of thing.
13
+ * A 24/7 bot never: each has its own budget and period, so every one is asked.
14
+ */
15
+ export declare const spend: (a: Ask) => Spend;
16
+ /** A question's key alone. */
17
+ export declare const again: (a: Ask) => string | null;
18
+ export interface Asker {
19
+ ask: (a: Ask) => Promise<boolean>;
20
+ /** The screen is back (mounted). */
21
+ enter: () => void;
22
+ /** The screen has gone: every answer still on its way counts as a no. */
23
+ leave: () => void;
24
+ }
25
+ export declare function asker(confirm: (spend: Spend) => Promise<boolean>): Asker;
26
+ /** The question before Run now, in the list and in the editor alike: one run, billed, now. */
27
+ export declare const runNow: (name: string, t: Say) => Ask;
28
+ /** The question before a paused task is switched on: from then it runs, and is billed, by itself. */
29
+ export declare const switchOn: (name: string, t: Say) => Ask;
30
+ /** The question before a template is copied: in a code workspace the platform made, the copy is built and published at once. */
31
+ export declare const copying: (name: string, t: Say) => Ask;
32
+ /** The question before a project is published again: its repository is built again, in a cloud sandbox. */
33
+ export declare const republish: (name: string, t: Say) => Ask;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Where a host may keep "Don't ask again" for a question: its kind and what it
3
+ * uses, so one yes covers only the same kind of spend on the same kind of thing.
4
+ * A 24/7 bot never: each has its own budget and period, so every one is asked.
5
+ */
6
+ export const spend = (a) => (a.kind === 'bot' ? { ...a, kind: 'bot', again: null } : { ...a, kind: a.kind, again: `${a.kind}.${a.uses}` });
7
+ /** A question's key alone. */
8
+ export const again = (a) => spend(a).again;
9
+ export function asker(confirm) {
10
+ let turn = 0;
11
+ let here = true;
12
+ return {
13
+ ask: async (a) => {
14
+ const mine = ++turn;
15
+ let yes;
16
+ try {
17
+ yes = await confirm(spend(a));
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ return yes === true && here && mine === turn;
23
+ },
24
+ enter: () => {
25
+ here = true;
26
+ },
27
+ leave: () => {
28
+ here = false;
29
+ turn++;
30
+ },
31
+ };
32
+ }
33
+ /** The question before Run now, in the list and in the editor alike: one run, billed, now. */
34
+ export const runNow = (name, t) => ({
35
+ kind: 'task-run',
36
+ title: t('Run {name} now?', { name }),
37
+ what: t('This starts one run of {name} right away, apart from its schedule.', { name }),
38
+ yes: t('Run now'),
39
+ uses: 'credits',
40
+ });
41
+ /** The question before a paused task is switched on: from then it runs, and is billed, by itself. */
42
+ export const switchOn = (name, t) => ({
43
+ kind: 'task',
44
+ title: t('Turn {name} on?', { name }),
45
+ what: t('It runs by itself on its schedule until you pause or delete it.'),
46
+ yes: t('Turn on'),
47
+ uses: 'credits',
48
+ });
49
+ /** The question before a template is copied: in a code workspace the platform made, the copy is built and published at once. */
50
+ export const copying = (name, t) => ({
51
+ kind: 'publish',
52
+ title: t('Start from {template}?', { template: name }),
53
+ what: t('This copies {template} into a new project, then builds and publishes it.', { template: name }),
54
+ yes: t('Start'),
55
+ uses: 'computer',
56
+ });
57
+ /** The question before a project is published again: its repository is built again, in a cloud sandbox. */
58
+ export const republish = (name, t) => ({
59
+ kind: 'publish',
60
+ title: t('Publish {name} again?', { name }),
61
+ what: t('This builds {name} again from its repository and publishes it.', { name }),
62
+ yes: t('Publish again'),
63
+ uses: 'computer',
64
+ });
@@ -0,0 +1,32 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { Folder, Local } from './local.ts';
3
+ import { type Asked, type Site } from './site.ts';
4
+ export interface Redesign {
5
+ /** The site the draft asks for, when New is where a redesign can start. */
6
+ found: Asked | null;
7
+ /** Whether a step of one is under way. */
8
+ busy: boolean;
9
+ /** Start one. False when it could not begin. */
10
+ start: (asked: Asked) => Promise<boolean>;
11
+ /** Ask for an address in a dialog, then start. */
12
+ ask: () => void;
13
+ /** Whether this host can redesign a site at all. */
14
+ can: boolean;
15
+ /** The offer, the dialog and the card, to draw above the composer. */
16
+ view: ReactNode;
17
+ }
18
+ export declare function useRedesign({ local, site, here, draft, chosen, carried, devMode, started, }: {
19
+ local: Local | null;
20
+ site: Site | null;
21
+ /** New is on This computer. */
22
+ here: boolean;
23
+ draft: string;
24
+ /** The folder the person chose themselves, or null for Auto: a chosen folder is built in, Auto makes a new one. */
25
+ chosen: Folder | null;
26
+ /** What the run carries beside the ask: the skills and memory the person turned on. */
27
+ carried: string;
28
+ /** Developer mode: the process is drawn as well as the answer. */
29
+ devMode: boolean;
30
+ /** The ask was taken. */
31
+ started: () => void;
32
+ }): Redesign;
@@ -0,0 +1,117 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Redesign a site from its address, in New on This computer (hanzo-inc/app issue 312, hanzoai/desktop issue 15).
4
+ *
5
+ * An address pasted alone, or with a request to redesign it, is offered as a redesign and never taken for one on its
6
+ * own: the offer says what Hanzo will do and one press does it, and an ask that only holds a link is sent as it is
7
+ * (site.ts `urlOf`). The steps are the host's and the agent's (site.ts): the host opens the site and saves a copy
8
+ * into a folder, serves that folder's `redesign/` live and shows it in Chrome; the agent reads the copy, writes a
9
+ * critique as its answer and builds the new site there. The card says which step it is in, the live address, and how
10
+ * to open it again; the preview keeps following the folder, so every later run in it shows as it is saved.
11
+ */
12
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
13
+ import { useI18n } from '@hanzo/i18n/react';
14
+ import { ExternalLink, Globe } from '@hanzogui/lucide-icons-2';
15
+ import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
16
+ import { useId, useMemo, useRef, useState } from 'react';
17
+ import { plainAnswer } from './plain.js';
18
+ import { addressOf, brief, folderName, hostOf, stopped, urlOf } from './site.js';
19
+ export function useRedesign({ local, site, here, draft, chosen, carried, devMode, started, }) {
20
+ const { t } = useI18n();
21
+ const can = Boolean(site && local && here);
22
+ const found = useMemo(() => (can ? urlOf(draft) : null), [can, draft]);
23
+ const [going, setGoing] = useState(null);
24
+ const [asking, setAsking] = useState(false);
25
+ const busy = going?.stage === 'opening' || going?.stage === 'building';
26
+ // The folder being served, so a new redesign lets the last one go.
27
+ const served = useRef(null);
28
+ const start = async (asked) => {
29
+ if (!site || !local || busy)
30
+ return false;
31
+ started();
32
+ const host = hostOf(asked.url);
33
+ const update = (patch) => setGoing((g) => (g ? { ...g, ...patch } : g));
34
+ setGoing({ url: asked.url, host, folder: null, stage: 'opening', preview: null, output: '', process: '', setup: null, why: '' });
35
+ try {
36
+ if (served.current) {
37
+ const last = served.current;
38
+ served.current = null;
39
+ await site.stop(last).catch(() => undefined);
40
+ }
41
+ const folder = chosen ?? (await site.folder(folderName(asked.url)));
42
+ const saved = await site.capture(asked.url, folder.path);
43
+ // The folder exists now, and is the one Auto picks next: what is said after this goes to the redesign.
44
+ local.use(folder.path);
45
+ const preview = await site.preview(folder.path);
46
+ served.current = folder.path;
47
+ update({ folder, stage: 'building', preview: preview.url });
48
+ // The preview opens at once, on the page that says the design is being built; a browser that will not open it
49
+ // is no reason to stop, and the card has the address and the button.
50
+ void site.show(preview.url).catch(() => undefined);
51
+ const prompt = [carried, brief(saved, asked.note)].filter(Boolean).join('\n\n');
52
+ const done = await local.run(folder.path, prompt, (percent) => update({ setup: percent }));
53
+ const answer = { output: done.output.trim(), process: (done.process ?? '').trim() };
54
+ update(done.ok ? { stage: 'done', ...answer } : { stage: 'failed', ...answer, why: t('Hanzo Dev stopped before it finished. Try again.') });
55
+ return true;
56
+ }
57
+ catch (e) {
58
+ update({ stage: 'failed', why: stopped(e, t) });
59
+ return false;
60
+ }
61
+ };
62
+ const show = () => {
63
+ if (going?.preview)
64
+ void site?.show(going.preview).catch(() => undefined);
65
+ };
66
+ const view = (_jsxs(_Fragment, { children: [found && !busy ? _jsx(Offer, { host: hostOf(found.url), onStart: () => void start(found) }) : null, going ? _jsx(Card, { going: going, devMode: devMode, onShow: show }) : null, site ? _jsx(Asking, { open: asking, onOpenChange: setAsking, onStart: (url) => void start({ url, note: '' }) }) : null] }));
67
+ return { found, busy, start, ask: () => setAsking(true), can, view };
68
+ }
69
+ /** The offer: what Hanzo will do with the address, and the press that does it. */
70
+ function Offer({ host, onStart }) {
71
+ const { t } = useI18n();
72
+ return (_jsxs(XStack, { "data-slot": "redesign-offer", items: "center", justify: "space-between", gap: "$3", rowGap: "$2", mx: "$3", px: "$3", py: "$2", flexWrap: "wrap", children: [_jsxs(XStack, { items: "center", gap: "$2", flex: 1, minW: 180, children: [_jsx(Globe, { size: 14, color: "$soft" }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "500", children: t('Redesign {site}?', { site: host }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Hanzo opens it, reviews it, and builds a new version here while you watch it in Chrome.') })] })] }), _jsx(Button, { size: "sm", variant: "primary", onPress: onStart, children: t('Redesign this site') })] }));
73
+ }
74
+ /** Where a redesign is, step by step, with the live address and what the agent said. */
75
+ function Card({ going, devMode, onShow }) {
76
+ const { t } = useI18n();
77
+ const head = going.stage === 'opening'
78
+ ? t('Opening {site}…', { site: going.host })
79
+ : going.stage === 'building'
80
+ ? t('Redesigning {site}…', { site: going.host })
81
+ : going.stage === 'done'
82
+ ? t('Redesigned {site}', { site: going.host })
83
+ : t('Could not redesign {site}', { site: going.host });
84
+ const fetching = going.stage === 'building' && going.setup !== null && going.setup < 100;
85
+ const said = going.output && going.folder ? plainAnswer(going.output, going.folder, t) : going.output;
86
+ const step = going.stage === 'opening'
87
+ ? t('Opening the site and saving a copy to work from.')
88
+ : going.stage === 'building'
89
+ ? t('Reviewing the site and building the new design. The preview changes as the files are saved.')
90
+ : going.why;
91
+ return (_jsxs(YStack, { "data-slot": "redesign", role: "status", "aria-live": "polite", gap: "$1.5", mx: "$3", px: "$3", py: "$2.5", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$background", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, children: [_jsx(Globe, { size: 13, color: "$soft" }), _jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "500", numberOfLines: 1, flex: 1, minW: 0, children: head })] }), step ? (_jsx(SizableText, { size: "$1", color: "$soft", children: step })) : null, going.preview ? (_jsxs(XStack, { "data-slot": "redesign-preview", items: "center", justify: "space-between", gap: "$2", minW: 0, children: [_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, flex: 1, minW: 0, "data-i18n-ltr": "", children: t('Live preview: {address}', { address: going.preview }) }), _jsx(Button, { size: "sm", variant: "outline", onPress: onShow, children: _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(ExternalLink, { size: 13, color: "$soft" }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Open in Chrome') })] }) })] })) : null, going.folder ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, "data-i18n-ltr": "", children: going.folder.path })) : null, fetching ? (_jsx(SizableText, { "data-slot": "redesign-setup", size: "$1", color: "$soft", children: t('Setting up Hanzo Dev on this computer… {percent}%', { percent: going.setup }) })) : null, said ? (_jsx(YStack, { maxH: 320, overflowY: "auto", minW: 0, children: _jsx(SizableText, { "data-slot": "redesign-answer", size: "$2", color: "$ink", whiteSpace: "pre-wrap", wordWrap: "break-word", children: said }) })) : null, devMode && going.process ? (_jsxs(YStack, { "data-slot": "redesign-process", gap: "$1", minW: 0, children: [_jsx(SizableText, { size: "$1", color: "$soft", fontWeight: "500", children: t('What Hanzo ran') }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", whiteSpace: "pre-wrap", wordWrap: "break-word", maxH: 240, overflowY: "auto", "data-i18n-ltr": "", children: going.process })] })) : null] }));
92
+ }
93
+ /** Asking for an address, for a person who has not pasted one. */
94
+ function Asking({ open, onOpenChange, onStart }) {
95
+ const { t } = useI18n();
96
+ const id = useId();
97
+ const [value, setValue] = useState('');
98
+ const [note, setNote] = useState('');
99
+ const close = (o) => {
100
+ if (!o) {
101
+ setValue('');
102
+ setNote('');
103
+ }
104
+ onOpenChange(o);
105
+ };
106
+ const go = () => {
107
+ const url = addressOf(value);
108
+ if (!url)
109
+ return setNote(t('Paste a site’s address, like https://example.com.'));
110
+ close(false);
111
+ onStart(url);
112
+ };
113
+ return (_jsx(Dialog, { open: open, onOpenChange: close, children: _jsxs(DialogContent, { maxW: 480, showCloseButton: false, children: [_jsx(DialogTitle, { children: t('Redesign a site') }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Hanzo opens the site, reviews it, and builds a new version here while you watch it in Chrome.') }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { render: "label", size: "$2", color: "$soft", htmlFor: `${id}-site`, children: t('Site address') }), _jsx(Input, { id: `${id}-site`, autoFocus: true, value: value, onChangeText: setValue, placeholder: "https://example.com", "aria-label": t('Site address'), onKeyDown: (e) => {
114
+ if (e.key === 'Enter')
115
+ go();
116
+ } })] }), note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onPress: () => close(false), children: t('Cancel') }), _jsx(Button, { size: "sm", onPress: go, children: t('Redesign') })] })] }) }));
117
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * What removing one of the org's projects does, decided before anything is.
3
+ *
4
+ * A project on Projects is a repository the forge holds, and it is one of two
5
+ * things. Hanzo's COPY of a repository on GitHub: removing it drops the link
6
+ * that syncs into it, then the copy, then the project built from it — and the
7
+ * repository on GitHub is never touched. Or the forge's OWN repository, made
8
+ * from a template or created there: removing it deletes the repository and all
9
+ * of its history, which Hanzo knows of nowhere else. A repository GitHub grants
10
+ * that Hanzo never copied has nothing here to remove.
11
+ *
12
+ * Which one it is, is read off what the org's projects are made from (api/work.ts
13
+ * `sources`), and only off what says so of THIS copy: a link that writes into
14
+ * it, GitHub's listing naming it as a repository's forge name, or a project
15
+ * built from that repository on GitHub. A forge repository merely named like a
16
+ * GitHub one is the forge's own and is said to be, since deleting it may be
17
+ * deleting the only history there is.
18
+ *
19
+ * The calls go in that order — link, copy, project — and stop at the first
20
+ * refusal, so what a removal leaves is always the tail of its steps and is said.
21
+ *
22
+ * Pure: the screen asks and the tests ask the same question. Its words take the
23
+ * screen's @hanzo/i18n `t`, English when none is handed.
24
+ */
25
+ import type { Say } from '@hanzo/i18n/react';
26
+ import type { Link } from './api/links.ts';
27
+ import { type Granted, type Held, type Site } from './merge.ts';
28
+ /** One call a removal makes. */
29
+ export type Step =
30
+ /** DELETE /v1/sync/{id}: GitHub stops syncing into the copy, and the copy stops pushing back. */
31
+ {
32
+ kind: 'link';
33
+ id: string;
34
+ }
35
+ /** DELETE /v1/git/repos/{name}: the repository goes from the forge, history and all. */
36
+ | {
37
+ kind: 'mirror';
38
+ name: string;
39
+ }
40
+ /** DELETE /v1/project/{slug}: the project built from it goes, and its site stops answering. */
41
+ | {
42
+ kind: 'project';
43
+ slug: string;
44
+ };
45
+ export interface Removal {
46
+ /** `owner/name` as people know it: GitHub's address for a copy, the org's for the forge's own. */
47
+ repo: string;
48
+ /** `github` for Hanzo's copy of a repository on GitHub; `hanzo` for one whose only copy Hanzo knows of is its own. */
49
+ from: 'github' | 'hanzo';
50
+ /** The calls, in the order they are made. */
51
+ steps: Step[];
52
+ /** What removing it does, in full, for the one question asked before it is done. */
53
+ says: string;
54
+ }
55
+ /** What the org's projects are made from (api/work.ts `sources`), as far as removing one reads it. */
56
+ export interface Made {
57
+ granted: Pick<Granted, 'owner' | 'name' | 'codebase'>[];
58
+ linked: Pick<Link, 'id' | 'owner' | 'name' | 'forge'>[];
59
+ held: Pick<Held, 'org' | 'name'>[];
60
+ sites: Pick<Site, 'slug' | 'repo'>[];
61
+ }
62
+ /**
63
+ * What removing the forge repository `name` does, or null when the forge does
64
+ * not hold it: there is nothing of its own on Hanzo to remove.
65
+ */
66
+ export declare function removal(name: string, made: Made, t?: Say): Removal | null;
67
+ /**
68
+ * What is left when step `at` of `r` was refused, said with the refusal `why`:
69
+ * nothing gone when it was the first step, else what went and what is still here.
70
+ */
71
+ export declare function stopped(r: Removal, at: number, why: string, t?: Say): string;
@@ -0,0 +1,73 @@
1
+ import { addressOf, forgeHost } from './merge.js';
2
+ import { english } from './say.js';
3
+ /**
4
+ * The name a GitHub repository's copy has on the forge: its account and its name,
5
+ * folded (`hanzoai_cloud`; cloud forge.Imported). GET /v1/git/repos lists the copy
6
+ * by it and GitHub's listing gives it as `codebase`. A link is declared with the
7
+ * bare name (`cloud`), which a forge repository of the org's own can also have,
8
+ * so the bare name is never taken for the copy.
9
+ */
10
+ const imported = (owner, name) => (owner && name ? `${owner}_${name}`.toLowerCase() : '');
11
+ /**
12
+ * What removing the forge repository `name` does, or null when the forge does
13
+ * not hold it: there is nothing of its own on Hanzo to remove.
14
+ */
15
+ export function removal(name, made, t = english) {
16
+ const n = name.toLowerCase();
17
+ const held = made.held.find((h) => h.name.toLowerCase() === n);
18
+ if (!held)
19
+ return null;
20
+ const links = made.linked.filter((l) => imported(l.owner, l.forge) === n);
21
+ // A project is built from the copy itself, or from the repository on GitHub it is the copy of.
22
+ const sites = made.sites.filter((s) => {
23
+ const at = addressOf(s.repo);
24
+ if (!at)
25
+ return false;
26
+ return at.github ? imported(at.owner, at.name) === n : forgeHost(s.repo) && at.name.toLowerCase() === n;
27
+ });
28
+ // The repository on GitHub this is Hanzo's copy of, where anything says so of this copy.
29
+ const hub = links.at(0) ??
30
+ made.granted.find((g) => g.codebase.toLowerCase() === n) ??
31
+ sites.map((s) => addressOf(s.repo)).find((at) => at?.github);
32
+ const repo = hub ? `${hub.owner}/${hub.name}` : held.org ? `${held.org}/${held.name}` : held.name;
33
+ const steps = [
34
+ ...links.map((l) => ({ kind: 'link', id: l.id })),
35
+ { kind: 'mirror', name: held.name },
36
+ ...sites.map((s) => ({ kind: 'project', slug: s.slug })),
37
+ ];
38
+ const built = sites.length > 0;
39
+ if (hub) {
40
+ return {
41
+ repo,
42
+ from: 'github',
43
+ steps,
44
+ says: built
45
+ ? t('Hanzo stops syncing {repo} and deletes its copy here, with its project and any site published from it. Your repository on GitHub is not touched.', { repo })
46
+ : t('Hanzo stops syncing {repo} and deletes its copy here. Your repository on GitHub is not touched.', { repo }),
47
+ };
48
+ }
49
+ return {
50
+ repo,
51
+ from: 'hanzo',
52
+ steps,
53
+ says: built
54
+ ? t('This deletes {repo} and all of its history from Hanzo, with its project and any site published from it. This cannot be undone.', { repo })
55
+ : t('This deletes {repo} and all of its history from Hanzo. This cannot be undone.', { repo }),
56
+ };
57
+ }
58
+ /**
59
+ * What is left when step `at` of `r` was refused, said with the refusal `why`:
60
+ * nothing gone when it was the first step, else what went and what is still here.
61
+ */
62
+ export function stopped(r, at, why, t = english) {
63
+ const values = { repo: r.repo, why };
64
+ const step = r.steps[at];
65
+ // The links go first: one refused leaves the copy and its project as they were.
66
+ if (at === 0 || !step || step.kind === 'link')
67
+ return t('{repo} was not removed: {why}', values);
68
+ if (step.kind === 'mirror')
69
+ return t('{repo} no longer syncs from GitHub, but its copy is still on Hanzo: {why}', values);
70
+ return r.from === 'github'
71
+ ? t('Hanzo’s copy of {repo} is deleted, but its project is still on Hanzo: {why}', values)
72
+ : t('{repo} is deleted, but its project is still on Hanzo: {why}', values);
73
+ }