@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,26 @@
1
+ /**
2
+ * A folder on a linked machine, for a run started from the web (hanzo-inc/app issue 310).
3
+ *
4
+ * THE MACHINE'S OWNER SAYS WHICH FOLDERS. They grant one from Hanzo Desktop or with `hanzo link grant <folder>`, and
5
+ * the platform admits a run that names a folder only inside one (403 `folder_not_granted` otherwise; the machine checks
6
+ * the real path again). So the Folder pill on a machine lists the granted folders and nothing else.
7
+ *
8
+ * AUTO IS THE FOLDER THE LINKED SHELL IS OPEN IN, when it is granted: the shell reports where it is as it moves (the
9
+ * session's `cwd`), and that is where the person is working. A shell open anywhere else, or none, leaves Auto with no
10
+ * folder, and the run works in a new folder on the machine, as a run that names none always has.
11
+ */
12
+ import type { Session } from './api/sessions.ts';
13
+ /** The code the platform refuses a run under when its folder is not inside a grant. */
14
+ export declare const NOT_GRANTED = "folder_not_granted";
15
+ /** Whether `dir` is `grant` or lies under it: `/a/b` is under `/a`, `/ab` is not (apps/agents folders.go `within`). */
16
+ export declare const inside: (dir: string, grant: string) => boolean;
17
+ /** The folder the machine's linked shell is open in: the most recently active running shell there (a session no run tagged) that says, or ''. */
18
+ export declare function shell(sessions: readonly Session[], machine: {
19
+ id: string;
20
+ host?: string;
21
+ }): string;
22
+ /** The folder a run on the machine works in: the one chosen while it is still granted, else Auto's (the shell's, when granted), else '' (a new folder). */
23
+ export declare function aim(granted: readonly string[], kept: string, cwd: string): {
24
+ dir: string;
25
+ auto: boolean;
26
+ };
@@ -0,0 +1,15 @@
1
+ /** The code the platform refuses a run under when its folder is not inside a grant. */
2
+ export const NOT_GRANTED = 'folder_not_granted';
3
+ /** Whether `dir` is `grant` or lies under it: `/a/b` is under `/a`, `/ab` is not (apps/agents folders.go `within`). */
4
+ export const inside = (dir, grant) => dir === grant || dir.startsWith(`${grant.replace(/\/+$/, '')}/`);
5
+ /** The folder the machine's linked shell is open in: the most recently active running shell there (a session no run tagged) that says, or ''. */
6
+ export function shell(sessions, machine) {
7
+ const on = sessions.filter((s) => s.status === 'running' && !s.kind && s.cwd && (s.target === machine.id || (Boolean(machine.host) && s.host === machine.host)));
8
+ return [...on].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))[0]?.cwd ?? '';
9
+ }
10
+ /** The folder a run on the machine works in: the one chosen while it is still granted, else Auto's (the shell's, when granted), else '' (a new folder). */
11
+ export function aim(granted, kept, cwd) {
12
+ if (kept && granted.includes(kept))
13
+ return { dir: kept, auto: false };
14
+ return { dir: cwd && granted.some((g) => inside(cwd, g)) ? cwd : '', auto: true };
15
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * What this org has deployed: a few starters to make something new from, then
3
+ * every site under the month it was last edited, whether it is public or
4
+ * private, and its rename, repository, visibility and delete. A site belongs to
5
+ * the org and names no author, so the list does not split yours from a
6
+ * colleague's — which is why it is a section of its own under the Library's
7
+ * items, which are yours.
8
+ *
9
+ * Its repository is the one its builds are cut from, by a GitHub address in any
10
+ * form GitHub hands out (address.ts), with the branch whose pushes rebuild it.
11
+ */
12
+ export declare function Sites({ q, onMatch }?: {
13
+ q?: string;
14
+ onMatch?: (n: number) => void;
15
+ }): import("react").JSX.Element | null;
16
+ export declare function Templates(): import("react").JSX.Element;
@@ -0,0 +1,219 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Two shelves: the sites this org has deployed (Sites, drawn at the foot of the
4
+ * Library — library.tsx), and the public starters (Templates).
5
+ *
6
+ * A project is a real row — `/v1/project`, the same one a deployed site is
7
+ * served from — so opening one opens its workspace at its own address. A
8
+ * starter is taken as a COPY of its own repository (`POST /v1/project/fork`),
9
+ * so what opens is that template, not a model's imitation of it.
10
+ */
11
+ import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
12
+ import { useI18n } from '@hanzo/i18n/react';
13
+ import { Boxes, ExternalLink, GitBranch, Globe, Lock, MoreHorizontal, Pencil, Search, Trash2, X } from '@hanzogui/lucide-icons-2';
14
+ import { Button, DropdownMenu, Input, Skeleton } from '@hanzo/ui';
15
+ import { useEffect, useMemo, useState } from 'react';
16
+ import { RING, RING_INSET } from './pane.js';
17
+ import { clone } from './address.js';
18
+ import { address, change, fork, remove, templates } from './api/projects.js';
19
+ import { Address, Confirm, Rename } from './ask.js';
20
+ import { useProjects, useRead } from './data.js';
21
+ import { useHost, useTarget } from './host.js';
22
+ import { copying } from './question.js';
23
+ import { useSpend } from './spend.js';
24
+ import { Out } from './out.js';
25
+ const SHOTS = ['/templates', 'https://gallery.hanzo.ai/screenshots', 'https://hanzo.ai/templates'];
26
+ function Head({ title, says }) {
27
+ return (_jsxs(YStack, { gap: "$1", pb: "$4", children: [_jsx(SizableText, { render: "h1", size: "$6", color: "$ink", children: title }), _jsx(SizableText, { size: "$2", color: "$soft", children: says })] }));
28
+ }
29
+ function Card({ onPress, label, disabled = false, children }) {
30
+ return (_jsx(YStack, { render: "button", onPress: onPress, disabled: disabled, "aria-label": label, width: "100%", minW: 0, rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", overflow: "hidden", opacity: disabled ? 0.72 : 1, focusVisibleStyle: RING, "$platform-web": { textAlign: 'start' }, children: children }));
31
+ }
32
+ /** Copying a starter into a project of this org, then opening it: one copy at a time. */
33
+ function useFork() {
34
+ const t = useTarget();
35
+ const host = useHost();
36
+ const { t: say } = useI18n();
37
+ const spend = useSpend();
38
+ const [busy, setBusy] = useState('');
39
+ const [failed, setFailed] = useState('');
40
+ const take = async (slug, name) => {
41
+ if (busy)
42
+ return;
43
+ if (!host.person)
44
+ return host.signIn?.();
45
+ // The copy is built and published at once: asked first.
46
+ if (!(await spend.ask(copying(name, say))))
47
+ return;
48
+ setBusy(slug);
49
+ setFailed('');
50
+ try {
51
+ const made = await fork(t, slug);
52
+ host.go(made.slug || slug);
53
+ }
54
+ catch (e) {
55
+ setFailed(e.message);
56
+ }
57
+ finally {
58
+ setBusy('');
59
+ }
60
+ };
61
+ return { busy, failed, take, dialog: spend.dialog };
62
+ }
63
+ /** When a project was last edited, or made if it never was; Unix seconds. */
64
+ const when = (p) => p.updated || p.created;
65
+ /** The org's projects under the month each was last edited, newest first. */
66
+ function months(list, say) {
67
+ const out = new Map();
68
+ for (const p of [...list].sort((a, b) => when(b) - when(a))) {
69
+ const s = when(p);
70
+ const label = s ? new Date(s * 1000).toLocaleDateString(undefined, { month: 'long', year: 'numeric' }) : say('Earlier');
71
+ out.set(label, [...(out.get(label) ?? []), p]);
72
+ }
73
+ return [...out].map(([label, rows]) => ({ label, rows }));
74
+ }
75
+ function edited(s, say) {
76
+ if (!s)
77
+ return '';
78
+ const d = new Date(s * 1000);
79
+ const year = d.getFullYear() === new Date().getFullYear() ? undefined : 'numeric';
80
+ return say('Edited {date}', { date: d.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year }) });
81
+ }
82
+ /**
83
+ * What this org has deployed: a few starters to make something new from, then
84
+ * every site under the month it was last edited, whether it is public or
85
+ * private, and its rename, repository, visibility and delete. A site belongs to
86
+ * the org and names no author, so the list does not split yours from a
87
+ * colleague's — which is why it is a section of its own under the Library's
88
+ * items, which are yours.
89
+ *
90
+ * Its repository is the one its builds are cut from, by a GitHub address in any
91
+ * form GitHub hands out (address.ts), with the branch whose pushes rebuild it.
92
+ */
93
+ export function Sites({ q = '', onMatch } = {}) {
94
+ const { t: say } = useI18n();
95
+ const t = useTarget();
96
+ const host = useHost();
97
+ const list = useProjects(t, Boolean(host.person));
98
+ const starters = useRead(() => templates(t), [], [t.api]);
99
+ const { busy, failed, take, dialog } = useFork();
100
+ const [renaming, setRenaming] = useState(null);
101
+ const [relinking, setRelinking] = useState(null);
102
+ const [deleting, setDeleting] = useState(null);
103
+ const [note, setNote] = useState('');
104
+ const needle = q.trim().toLowerCase();
105
+ const filtered = useMemo(() => (needle ? list.value.filter((p) => `${p.name} ${p.slug} ${p.live ?? ''} ${p.repo ?? ''}`.toLowerCase().includes(needle)) : list.value), [list.value, needle]);
106
+ useEffect(() => {
107
+ onMatch?.(filtered.length);
108
+ }, [filtered.length, onMatch]);
109
+ const flip = async (p) => {
110
+ const visibility = p.visibility === 'private' ? 'public' : 'private';
111
+ setNote('');
112
+ try {
113
+ await change(t, p.slug, { visibility });
114
+ setNote(visibility === 'public' ? say('{name} is public now', { name: p.name }) : say('{name} is private now', { name: p.name }));
115
+ list.reload();
116
+ }
117
+ catch (e) {
118
+ setNote(e.message);
119
+ }
120
+ };
121
+ if (needle && filtered.length === 0)
122
+ return null;
123
+ const said = failed || note;
124
+ return (_jsxs(YStack, { width: "100%", role: "region", "aria-label": say('Sites'), children: [dialog, _jsxs(YStack, { width: "100%", children: [_jsxs(YStack, { gap: "$1", pb: "$4", children: [_jsx(SizableText, { render: "h2", size: "$5", color: "$ink", children: say('Sites') }), _jsx(SizableText, { size: "$2", color: "$soft", children: `${say('What this organization has built.')} ${say('Open one to keep building it.')}` })] }), said ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", pb: "$3", children: said })) : null, !needle && starters.value.length ? (_jsxs(YStack, { gap: "$3", pb: "$6", width: "100%", children: [_jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", children: say('Make something new') }), _jsx(YStack, { display: "grid", gridTemplateColumns: "repeat(4, minmax(0, 1fr))", gap: "$3", width: "100%", children: starters.value.slice(0, 4).map((x) => (_jsxs(Card, { label: say('Start from {template}', { template: x.title }), disabled: Boolean(busy) && busy !== x.slug, onPress: () => void take(x.slug, x.title), children: [_jsx(Shot, { slug: x.slug }), _jsx(YStack, { px: "$3", py: "$2.5", children: _jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: busy === x.slug ? say('Copying…') : x.title }) })] }, x.slug))) })] })) : null, list.error ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", bg: "$panel", px: "$5", py: "$7", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: "var(--state-error)", text: "center", children: say(list.error.message) }), _jsx(Button, { size: "sm", variant: "outline", onPress: list.reload, children: say('Try again') })] })) : !host.person ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", bg: "$panel", px: "$5", py: "$7", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: say('Sign in to see what your organization has built.') }), _jsx(Button, { size: "sm", variant: "primary", onPress: () => host.signIn?.(), children: say('Sign in') })] })) : list.loading && list.value.length === 0 ? (_jsxs(YStack, { gap: "$3", "aria-busy": true, children: [_jsx(SizableText, { size: "$2", color: "$soft", children: say('Reading your projects…') }), _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", bg: "$panel", overflow: "hidden", children: [0, 1, 2].map((i) => (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", py: "$3", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: [_jsx(Skeleton, { layout: "block", width: 16, height: 16, rounded: 999, shrink: 0 }), _jsxs(YStack, { flex: 1, gap: "$1.5", children: [_jsx(Skeleton, { layout: "block", width: "36%", height: 14, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "52%", height: 12, rounded: "$2" })] })] }, i))) })] })) : filtered.length === 0 ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", bg: "$panel", px: "$5", py: "$7", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: needle ? say('Nothing matches.') : `${say('Nothing built yet.')} ${say('Describe something on the New page and it lands here.')}` }), needle ? null : (_jsx(Button, { size: "sm", variant: "primary", onPress: () => host.go(''), children: say('New session') }))] })) : (_jsx(YStack, { gap: "$5", children: months(filtered, say).map((g) => (_jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: g.label }), _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", children: g.rows.map((p, i) => (_jsxs(XStack, { items: "center", pr: "$2", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", hoverStyle: { bg: '$hover' }, children: [_jsxs(XStack, { flex: 1, minW: 0, render: "button", "aria-label": say('Open {name}', { name: p.name }), onPress: () => host.go(p.slug), items: "center", gap: "$3", px: "$3", py: "$2.5", minH: 44, cursor: "pointer", "$platform-web": { textAlign: 'start' }, focusVisibleStyle: RING_INSET, children: [p.visibility === 'private' ? _jsx(Lock, { size: 16, opacity: 0.7 }) : _jsx(Globe, { size: 16, opacity: 0.7 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$3", color: "$ink", numberOfLines: 1, children: p.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: [p.visibility === 'private' ? say('Private') : say('Public'), edited(when(p), say), p.live ? new URL(p.live).host : say('Not deployed yet')]
125
+ .filter(Boolean)
126
+ .join(' · ') })] })] }), _jsx(DropdownMenu, { trigger: _jsx(XStack, { render: "button", "aria-label": say('Actions for {name}', { name: p.name }), px: "$1.5", py: "$1", rounded: "$2", hoverStyle: { bg: '$raised' }, children: _jsx(MoreHorizontal, { size: 16 }) }), items: [
127
+ ...(p.live
128
+ ? [{ key: 'live', label: say('Open live site'), icon: _jsx(ExternalLink, { size: 14 }), onSelect: () => window.open(p.live, '_blank', 'noopener,noreferrer') }]
129
+ : []),
130
+ { key: 'rename', label: say('Rename'), icon: _jsx(Pencil, { size: 14 }), onSelect: () => setRenaming(p) },
131
+ { key: 'repo', label: say('Change repository'), icon: _jsx(GitBranch, { size: 14 }), onSelect: () => setRelinking(p) },
132
+ {
133
+ key: 'visibility',
134
+ label: p.visibility === 'private' ? say('Make public') : say('Make private'),
135
+ icon: p.visibility === 'private' ? _jsx(Globe, { size: 14 }) : _jsx(Lock, { size: 14 }),
136
+ onSelect: () => void flip(p),
137
+ },
138
+ { type: 'separator' },
139
+ { key: 'delete', label: say('Delete'), icon: _jsx(Trash2, { size: 14 }), destructive: true, onSelect: () => setDeleting(p) },
140
+ ] })] }, p.slug))) })] }, g.label))) }))] }), renaming ? (_jsx(Rename, { open: true, onOpenChange: (o) => !o && setRenaming(null), title: say('Rename'), name: renaming.name, run: async (name) => {
141
+ await change(t, renaming.slug, { name });
142
+ setNote(say('Renamed to {name}', { name }));
143
+ list.reload();
144
+ } })) : null, relinking ? (_jsx(Address, { open: true, onOpenChange: (o) => !o && setRelinking(null), title: say('Change repository'), says: say('The GitHub repository {name} is built from. A push to its branch builds it again.', { name: relinking.name }), act: say('Save'), address: relinking.repo, branch: relinking.branch || 'main', run: async (at, branch) => {
145
+ const next = await change(t, relinking.slug, { repo: { url: clone(at), branch } });
146
+ setNote(say('{name} is built from {repo} now', { name: relinking.name, repo: address(next.repo) || `${at.owner}/${at.name}` }));
147
+ list.reload();
148
+ } })) : null, deleting ? (_jsx(Confirm, { open: true, onOpenChange: (o) => !o && setDeleting(null), title: say('Delete {name}?', { name: deleting.name }), says: `${say('Its site stops answering, its releases are dropped, and its address is released.')} ${say('This cannot be undone.')}`, act: say('Delete'), run: async () => {
149
+ await remove(t, deleting.slug);
150
+ setNote(say('{name} is deleted', { name: deleting.name }));
151
+ list.reload();
152
+ } })) : null] }));
153
+ }
154
+ /**
155
+ * A starter's picture: a capture of its page from the top, 16:10. The frame has
156
+ * the capture's own shape at every width the grid gives a card, and the image is
157
+ * anchored at its top edge, so nothing of the page's header is cropped away.
158
+ */
159
+ function Shot({ slug }) {
160
+ const [step, setStep] = useState(0);
161
+ const base = SHOTS[step];
162
+ return (_jsxs(YStack, { width: "100%", aspectRatio: 16 / 10, bg: "$hover", items: "center", justify: "center", position: "relative", overflow: "hidden", children: [_jsxs(YStack, { items: "center", gap: "$2", opacity: 0.7, children: [_jsx(Boxes, { size: 24, color: "$soft" }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: slug })] }), base ? (_jsx(YStack, { render: _jsx("img", { src: `${base}/${encodeURIComponent(slug)}.webp`, alt: "", loading: "lazy", onError: () => setStep((s) => s + 1) }), position: "absolute", t: 0, r: 0, b: 0, l: 0, width: "100%", height: "100%", "$platform-web": { objectFit: 'cover', objectPosition: 'top' } })) : null] }));
163
+ }
164
+ export function Templates() {
165
+ const { t: say } = useI18n();
166
+ const host = useHost();
167
+ const t = useTarget();
168
+ const desktop = Boolean(useMedia().sm);
169
+ const list = useRead(() => templates(t), [], [t.api]);
170
+ const { busy, failed, take, dialog } = useFork();
171
+ const [q, setQ] = useState('');
172
+ const [cat, setCat] = useState('');
173
+ const [moreCats, setMoreCats] = useState(false);
174
+ const categories = useMemo(() => {
175
+ const seen = new Set();
176
+ const out = [];
177
+ for (const x of list.value) {
178
+ if (x.category && !seen.has(x.category)) {
179
+ seen.add(x.category);
180
+ out.push(x.category);
181
+ }
182
+ }
183
+ return out;
184
+ }, [list.value]);
185
+ const allCategoryPills = useMemo(() => [{ id: '', label: say('All') }, ...categories.map((c) => ({ id: c, label: c }))], [categories, say]);
186
+ const catCap = desktop ? 6 : 4;
187
+ const catOverflow = allCategoryPills.length > catCap;
188
+ const visibleCategoryPills = !moreCats && catOverflow
189
+ ? (() => {
190
+ const base = allCategoryPills.slice(0, catCap);
191
+ if (base.some((p) => p.id === cat))
192
+ return base;
193
+ const active = allCategoryPills.find((p) => p.id === cat);
194
+ return active ? [...base.slice(0, Math.max(1, catCap - 1)), active] : base;
195
+ })()
196
+ : allCategoryPills;
197
+ const hiddenCatCount = allCategoryPills.length - visibleCategoryPills.length;
198
+ const filtered = useMemo(() => {
199
+ const needle = q.trim().toLowerCase();
200
+ return list.value.filter((x) => {
201
+ if (cat && x.category !== cat)
202
+ return false;
203
+ if (!needle)
204
+ return true;
205
+ return `${x.title} ${x.slug} ${x.framework} ${x.category} ${x.description}`.toLowerCase().includes(needle);
206
+ });
207
+ }, [list.value, cat, q]);
208
+ const narrowed = q.trim() !== '' || cat !== '';
209
+ return (_jsxs(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$6", py: "$6", items: "center", children: [dialog, _jsxs(YStack, { width: "100%", maxW: 1080, children: [_jsx(Head, { title: say('Templates'), says: `${say('Start from a working app.')} ${say('Picking one copies its repository into a project of yours.')}` }), failed ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", pb: "$3", children: failed })) : null, list.value.length > 0 ? (_jsxs(YStack, { gap: "$2.5", children: [_jsx(YStack, { maxW: 420, width: "100%", children: _jsx(Input, { value: q, onChangeText: setQ, placeholder: say('Search templates…'), "aria-label": say('Search templates'), startAdornment: _jsx(Search, { size: 14, color: "$soft" }), endAdornment: q ? (_jsx(XStack, { render: "button", "aria-label": say('Clear search'), onPress: () => setQ(''), minW: 24, minH: 24, items: "center", justify: "center", focusVisibleStyle: RING, children: _jsx(X, { size: 13, color: "$soft" }) })) : undefined, onKeyDown: (e) => {
210
+ if (e.key === 'Escape' && q)
211
+ setQ('');
212
+ } }) }), categories.length > 1 ? (_jsxs(XStack, { role: "group", "aria-label": say('Category'), gap: "$1.5", rowGap: "$1.5", flexWrap: "wrap", width: "100%", children: [visibleCategoryPills.map((c) => {
213
+ const on = cat === c.id;
214
+ return (_jsx(XStack, { render: "button", "aria-pressed": on, "aria-label": c.label, onPress: () => setCat(c.id), items: "center", px: "$3", py: "$1", minH: 32, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: on ? '500' : '400', color: on ? '$background' : '$soft', children: c.label }) }, c.id || 'all'));
215
+ }), catOverflow ? (_jsx(XStack, { render: "button", "aria-expanded": moreCats, "aria-label": moreCats ? say('Show fewer categories') : say('Show {n} more categories', { n: hiddenCatCount }), onPress: () => setMoreCats((v) => !v), items: "center", px: "$3", py: "$1", minH: 32, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: moreCats ? say('Show less') : say('+{n} more', { n: hiddenCatCount }) }) })) : null] })) : null] })) : null, list.error ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", bg: "$panel", px: "$5", py: "$8", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: "var(--state-error)", text: "center", children: say(list.error.message) }), _jsx(Button, { size: "sm", variant: "outline", onPress: list.reload, children: say('Try again') })] })) : list.loading && !list.value.length ? (_jsxs(YStack, { gap: "$3", "aria-busy": true, children: [_jsx(SizableText, { size: "$2", color: "$soft", children: say('Reading templates…') }), _jsx(YStack, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 260px), 1fr))", gap: "$3", width: "100%", children: [0, 1, 2, 3, 4, 5].map((i) => (_jsxs(YStack, { rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", overflow: "hidden", children: [_jsx(Skeleton, { layout: "block", width: "100%", aspectRatio: 16 / 10, rounded: 0 }), _jsxs(YStack, { p: "$3", gap: "$1.5", children: [_jsx(Skeleton, { layout: "block", width: "55%", height: 15, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "85%", height: 12, rounded: "$2" })] })] }, i))) })] })) : !list.value.length ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", bg: "$panel", px: "$5", py: "$8", gap: "$3", items: "center", children: [_jsxs(YStack, { items: "center", gap: "$1", maxW: 420, children: [_jsx(SizableText, { size: "$4", fontWeight: "500", color: "$ink", text: "center", children: say('No templates right now') }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: `${say('No templates here right now.')} ${say('The whole catalog has more.')}` })] }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", justify: "center", children: [_jsxs(Button, { size: "sm", variant: "outline", onPress: () => host.open('https://gallery.hanzo.ai'), children: [_jsx(ExternalLink, { size: 14 }), say('The whole catalog')] }), _jsx(Button, { size: "sm", variant: "primary", onPress: () => host.go(''), children: say('Start a new run') })] })] })) : !filtered.length ? (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", bg: "$panel", px: "$5", py: "$8", gap: "$3", items: "center", children: [_jsx(SizableText, { size: "$2", color: "$soft", text: "center", children: say('Nothing matches.') }), narrowed ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => {
216
+ setQ('');
217
+ setCat('');
218
+ }, children: say('Clear filters') })) : null] })) : (_jsx(YStack, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 260px), 1fr))", gap: "$3", width: "100%", children: filtered.map((x) => (_jsxs(Card, { label: say('Start from {template}', { template: x.title }), disabled: Boolean(busy) && busy !== x.slug, onPress: () => void take(x.slug, x.title), children: [_jsx(Shot, { slug: x.slug }), _jsxs(YStack, { p: "$3", gap: "$1", children: [_jsx(SizableText, { size: "$3", color: "$ink", numberOfLines: 1, children: busy === x.slug ? say('Copying…') : x.title }), x.framework ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: x.framework })) : null, _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: x.description })] })] }, x.slug))) })), _jsx(YStack, { pt: "$5", children: _jsxs(Out, { href: "https://gallery.hanzo.ai", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: say('The whole catalog') }), _jsx(ExternalLink, { size: 12, opacity: 0.6 })] }) })] })] }));
219
+ }
@@ -0,0 +1,40 @@
1
+ /** What the panel's strip reads of the column it stands in. */
2
+ export interface Side {
3
+ /** What the middle column is called, in the button that brings it back: "chat", "run". */
4
+ main: string;
5
+ /** The middle column is hidden and the panel has the room. */
6
+ hidden: boolean;
7
+ show: () => void;
8
+ /** The panel is over the whole window. */
9
+ full: boolean;
10
+ fill: (on: boolean) => void;
11
+ }
12
+ /** Around the middle column's room and the panel: the panel's strip reads it. */
13
+ export declare const SideProvider: import("react").Provider<Side | null>;
14
+ /** The column the panel stands in, or null where it stands in none (a phone's sheet, a host's own column). */
15
+ export declare const useSide: () => Side | null;
16
+ export interface Split {
17
+ /** For `SideProvider`, around the middle column and the panel. */
18
+ side: Side;
19
+ /** The middle column's element: its display is written on it. */
20
+ main: (el: unknown) => void;
21
+ /** The panel's column's element: its width, and full screen, are written on it. */
22
+ aside: (el: unknown) => void;
23
+ /** The kit `Grip`'s props, but its label and its place; none while the panel is full screen. */
24
+ grip: {
25
+ side: 'left' | 'right';
26
+ span: number;
27
+ floor: number;
28
+ ceil: number;
29
+ reset: number;
30
+ onSpan: (n: number) => void;
31
+ onKeep: (n: number) => void;
32
+ onShut: () => void;
33
+ } | null;
34
+ }
35
+ /**
36
+ * The column, for a host that draws it: `open` is whether the panel is drawn
37
+ * beside the middle column, `main` what that column is called, `onShut` puts
38
+ * the panel away (its edge pulled past its floor).
39
+ */
40
+ export declare function useSplit(open: boolean, main: string, onShut: () => void): Split;
@@ -0,0 +1,208 @@
1
+ /**
2
+ * The side panel's column beside a conversation or a run, once for Chat and
3
+ * Dev: how wide it is, the middle column it can take the room from, and full
4
+ * screen. The host draws the two columns and spreads what `useSplit` hands it
5
+ * on them and on the kit's `Grip`; the `Panel` inside reads `useSide` for its
6
+ * full-screen button and its way back to the middle column.
7
+ *
8
+ * width the person's, kept in their preferences (`side.width`, /v1/pref),
9
+ * so it follows them to every device and to both modes. Where no
10
+ * PrefsProvider holds them (hanzo.team's rooms) it lasts the page.
11
+ * Saved once a drag lets go, after a burst of keys has stopped.
12
+ * main the middle column keeps MAIN px. Pulled under half of that it is
13
+ * hidden, never unmounted, so the transcript and the composer keep
14
+ * their state, and the panel takes the room. Pulled back out, or the
15
+ * strip's Show button, brings it back at the width kept.
16
+ * full the panel over the whole window. Escape or the button returns.
17
+ *
18
+ * A DRAG NEVER DRAWS REACT. Each frame writes the panel's width and the middle
19
+ * column's display on the two elements (`paint`), and the settled state is
20
+ * written by the same hand once React commits it (`look`, after layout, before
21
+ * paint), so the two never disagree and the host spreads no style of its own;
22
+ * React learns the width once, when the drag lets go. The room the two share is
23
+ * measured by a ResizeObserver, after layout, so a frame never reads layout
24
+ * it has just dirtied. A window narrowed under the panel is painted the same
25
+ * way: the panel gives way, and the person's width comes back with the room.
26
+ *
27
+ * The panel stands at the line's end and the gutter is its inline-start margin,
28
+ * so a right-to-left page puts it on the left and its edge on its right
29
+ * (@hanzo/i18n `dir`), and the grip grows it rightwards.
30
+ */
31
+ import { useI18n } from '@hanzo/i18n/react';
32
+ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
33
+ import { usePrefs } from './prefs.js';
34
+ /** The panel's least width, px, and the width it opens at before the person has chosen one. */
35
+ const FLOOR = 240;
36
+ const WIDTH = 480;
37
+ /** The middle column's least width, px: under half of it, it is hidden and the panel takes the room. */
38
+ const MAIN = 360;
39
+ /** How long a burst of keys is waited out before its width is saved, ms. */
40
+ const QUIET = 400;
41
+ const Context = createContext(null);
42
+ /** Around the middle column's room and the panel: the panel's strip reads it. */
43
+ export const SideProvider = Context.Provider;
44
+ /** The column the panel stands in, or null where it stands in none (a phone's sheet, a host's own column). */
45
+ export const useSide = () => useContext(Context);
46
+ /** The panel's own properties, at a width or with the room. Every key every time, so React and a drag write one set. */
47
+ function look(width, hidden) {
48
+ return hidden
49
+ ? { width: 'auto', flexGrow: '1', flexShrink: '1', minWidth: '0px', maxWidth: 'none', marginInlineStart: '0px', gridColumnStart: 'pane' }
50
+ : { width: `${width}px`, flexGrow: '', flexShrink: '0', minWidth: `${FLOOR}px`, maxWidth: `calc(100vw - ${MAIN}px)`, marginInlineStart: '', gridColumnStart: '' };
51
+ }
52
+ /** Over the whole window, opaque, above the frame and under the kit's menus. */
53
+ const FULL = {
54
+ position: 'fixed',
55
+ inset: '0px',
56
+ zIndex: '60',
57
+ width: 'auto',
58
+ maxWidth: 'none',
59
+ minWidth: '0px',
60
+ marginInlineStart: '0px',
61
+ borderRadius: '0px',
62
+ backgroundColor: 'var(--background)',
63
+ backdropFilter: 'none',
64
+ };
65
+ const write = (el, style) => {
66
+ for (const [k, v] of Object.entries(style))
67
+ el?.style.setProperty(k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`), v);
68
+ };
69
+ /**
70
+ * The column, for a host that draws it: `open` is whether the panel is drawn
71
+ * beside the middle column, `main` what that column is called, `onShut` puts
72
+ * the panel away (its edge pulled past its floor).
73
+ */
74
+ export function useSplit(open, main, onShut) {
75
+ const { dir } = useI18n();
76
+ const prefs = usePrefs(false);
77
+ const kept = prefs?.prefs.side?.width;
78
+ const [width, setWidth] = useState(() => Math.max(FLOOR, kept ?? WIDTH));
79
+ const [hidden, setHidden] = useState(false);
80
+ const [full, setFull] = useState(false);
81
+ const [room, setRoom] = useState(0);
82
+ const [els, setEls] = useState({ main: null, aside: null });
83
+ // What a frame paints from, current without a render: the person's width,
84
+ // the room the two columns share, and the gutter between them.
85
+ const now = useRef({ width, room: 0, gap: 0, hidden });
86
+ now.current.width = width;
87
+ now.current.hidden = hidden;
88
+ const saving = useRef({ timer: undefined, width: 0 });
89
+ /**
90
+ * Draws the panel at `n`, or, for a person's pull (`pulled`), with the room;
91
+ * says which, and the width drawn. A window that narrows only squeezes it.
92
+ */
93
+ const paint = useCallback((n, pulled = true) => {
94
+ const { room, gap } = now.current;
95
+ if (!room)
96
+ return { hide: false, drawn: n };
97
+ const hide = pulled && room - gap - n < MAIN / 2;
98
+ const drawn = hide ? room : Math.max(FLOOR, Math.min(n, room - gap - MAIN));
99
+ write(els.aside, look(drawn, hide));
100
+ if (els.main)
101
+ els.main.style.display = hide ? 'none' : '';
102
+ return { hide, drawn };
103
+ }, [els]);
104
+ // The room, measured after layout: both columns' widths and the gutter, which
105
+ // a hidden middle column gives to the panel too. A change of window paints
106
+ // the person's width into it again.
107
+ useEffect(() => {
108
+ const { main, aside } = els;
109
+ if (!main || !aside || typeof ResizeObserver === 'undefined')
110
+ return;
111
+ const measure = () => {
112
+ // Full screen is the window's, not the room's.
113
+ if (aside.style.position === 'fixed')
114
+ return;
115
+ const shown = main.style.display !== 'none';
116
+ if (shown)
117
+ now.current.gap = parseFloat(getComputedStyle(aside).marginInlineStart) || 0;
118
+ const total = Math.round((shown ? main.getBoundingClientRect().width + now.current.gap : 0) + aside.getBoundingClientRect().width);
119
+ // A drag moves width between the two and leaves their sum; only a new window is news.
120
+ if (Math.abs(total - now.current.room) < 2)
121
+ return;
122
+ now.current.room = total;
123
+ setRoom(total);
124
+ if (shown)
125
+ paint(now.current.width, false);
126
+ };
127
+ const watch = new ResizeObserver(measure);
128
+ watch.observe(main);
129
+ watch.observe(aside);
130
+ return () => watch.disconnect();
131
+ }, [els, paint]);
132
+ // The person's width, once their preferences answer with one.
133
+ useEffect(() => {
134
+ if (kept && kept !== now.current.width)
135
+ setWidth(Math.max(FLOOR, kept));
136
+ }, [kept]);
137
+ // The preferences change with every save they answer; the save in waiting reads them current.
138
+ const held = useRef(prefs);
139
+ held.current = prefs;
140
+ const flush = useCallback(() => {
141
+ const s = saving.current;
142
+ if (s.timer === undefined)
143
+ return;
144
+ clearTimeout(s.timer);
145
+ s.timer = undefined;
146
+ // A refusal takes the width back (PrefsProvider), which is the answer.
147
+ held.current?.save({ side: { width: s.width } }).catch(() => { });
148
+ }, []);
149
+ const save = useCallback((n) => {
150
+ clearTimeout(saving.current.timer);
151
+ saving.current = { width: n, timer: held.current ? setTimeout(flush, QUIET) : undefined };
152
+ }, [flush]);
153
+ // A save still waiting goes now when the column goes.
154
+ useEffect(() => flush, [flush]);
155
+ const keep = useCallback((n) => {
156
+ const { hide, drawn } = paint(n);
157
+ setHidden(hide);
158
+ if (hide)
159
+ return;
160
+ setWidth(drawn);
161
+ save(drawn);
162
+ }, [paint, save]);
163
+ // Shut, the panel takes nothing with it: the middle column is back and the window is the frame's.
164
+ useEffect(() => {
165
+ if (open)
166
+ return;
167
+ setHidden(false);
168
+ setFull(false);
169
+ }, [open]);
170
+ // Escape leaves full screen, unless something open in it (a menu) took the key first.
171
+ useEffect(() => {
172
+ if (!full)
173
+ return;
174
+ const leave = (e) => {
175
+ if (e.key !== 'Escape' || e.defaultPrevented)
176
+ return;
177
+ setFull(false);
178
+ };
179
+ window.addEventListener('keydown', leave);
180
+ return () => window.removeEventListener('keydown', leave);
181
+ }, [full]);
182
+ const show = useCallback(() => {
183
+ setHidden(false);
184
+ const room = now.current.room;
185
+ if (room)
186
+ paint(Math.min(now.current.width, room - now.current.gap - MAIN));
187
+ }, [paint]);
188
+ const side = useMemo(() => ({ main, hidden: open && hidden, show, full: open && full, fill: setFull }), [main, open, hidden, full, show]);
189
+ const mainRef = useCallback((el) => setEls((was) => (was.main === el ? was : { ...was, main: el instanceof HTMLElement ? el : null })), []);
190
+ const asideRef = useCallback((el) => setEls((was) => (was.aside === el ? was : { ...was, aside: el instanceof HTMLElement ? el : null })), []);
191
+ const across = room ? Math.max(FLOOR, Math.min(width, room - now.current.gap - MAIN)) : width;
192
+ // The settled state, on the elements a drag paints. Leaving full screen
193
+ // clears what full screen set, so every key is written every time.
194
+ useLayoutEffect(() => {
195
+ const full = Object.fromEntries(Object.entries(FULL).map(([k, v]) => [k, side.full ? v : '']));
196
+ write(els.aside, { ...full, ...look(across, side.hidden), ...(side.full ? FULL : null) });
197
+ if (els.main)
198
+ els.main.style.display = side.hidden ? 'none' : '';
199
+ }, [els, across, side.hidden, side.full]);
200
+ return {
201
+ side,
202
+ main: mainRef,
203
+ aside: asideRef,
204
+ grip: side.full
205
+ ? null
206
+ : { side: dir === 'rtl' ? 'left' : 'right', span: side.hidden ? room : across, floor: FLOOR, ceil: Math.max(FLOOR, room), reset: WIDTH, onSpan: (n) => void paint(n), onKeep: keep, onShut },
207
+ };
208
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Redesigning a site from its address (hanzo-inc/app issue 312, hanzoai/desktop issue 15).
3
+ *
4
+ * A person pastes a site's address into New on This computer. Hanzo opens the site, reads it, critiques it, and
5
+ * builds a redesign in a folder here while a live preview of it runs in the person's browser.
6
+ *
7
+ * THE HOST DOES WHAT THE AGENT CANNOT. The agent that rebuilds the site works in its folder with no network, so the
8
+ * host (Hanzo Desktop) opens the site from the computer's own connection and saves a copy into the folder
9
+ * (`capture`: the page, its words, its stylesheets, and a picture when the person's browser can take one), serves the
10
+ * folder's `redesign/` live (`preview`), and shows it in Chrome (`show`). The agent reads the copy, writes its
11
+ * critique as its answer, and writes the new site as static files into `redesign/`; the preview follows each file it
12
+ * saves. A host that cannot do this (a browser page) supplies no `Site`, and New offers nothing of it.
13
+ *
14
+ * Nothing here chooses where a request may go: the host decides what it will open. What is here is the contract, and
15
+ * the pure parts of it: which words are a site's address, what the folder is called, and what the agent is told.
16
+ */
17
+ import type { Say } from '@hanzo/i18n/react';
18
+ import type { Folder } from './local.ts';
19
+ /** What a host saved of a site, as it says it. */
20
+ export interface Saved {
21
+ /** What the site calls itself, or its address. */
22
+ title: string;
23
+ /** Where the site ended, after any redirects: the address the copy is of. */
24
+ url: string;
25
+ /** The files saved under `.hanzo/reference/` in the folder, by name. */
26
+ files: readonly string[];
27
+ /** Whether one of them is a picture of the page. */
28
+ screenshot: boolean;
29
+ }
30
+ /** A live preview of a folder's `redesign/`. */
31
+ export interface Live {
32
+ /** The address that shows it, on this computer. */
33
+ url: string;
34
+ }
35
+ /** What a host that can redesign a site can do. Every answer is plain words when it refuses: they are said as they come. */
36
+ export interface Site {
37
+ /** The folder a redesign of `name` goes in: a new one, named for it. It is made when the site is saved. */
38
+ folder: (name: string) => Promise<Folder>;
39
+ /** Open the site and save a copy of it into `folder`, for the agent to read. */
40
+ capture: (url: string, folder: string) => Promise<Saved>;
41
+ /** Serve `folder`'s `redesign/` live; the same address for as long as it runs, reloading as its files change. */
42
+ preview: (folder: string) => Promise<Live>;
43
+ /** Stop serving it. */
44
+ stop: (folder: string) => Promise<void>;
45
+ /** Show a preview in the person's browser: Chrome where it is installed. */
46
+ show: (url: string) => Promise<void>;
47
+ }
48
+ /** One word as an address, or null. A scheme is taken as written; a bare name must end in a name people paste. */
49
+ export declare function addressOf(word: string): string | null;
50
+ /** A site named in the ask, and what the person said besides. */
51
+ export interface Asked {
52
+ /** The address, whole. */
53
+ url: string;
54
+ /** The rest of what they said, which goes to the agent as their direction; '' for an address alone. */
55
+ note: string;
56
+ }
57
+ /**
58
+ * The site an ask is about, or null when it is about none. An ask is a site's when it is an address alone, or has one
59
+ * address and asks to redesign, rebuild, restyle or critique: anything else is a message that happens to hold a link,
60
+ * and is sent as it is.
61
+ */
62
+ export declare function urlOf(ask: string): Asked | null;
63
+ /** The site's own name: its host without `www.` and its top-level name (`blog.example.com` is `blog-example`). */
64
+ export declare function siteName(url: string): string;
65
+ /** What the redesign's folder is called: `example-redesign`. */
66
+ export declare function folderName(url: string): string;
67
+ /** What a person reads for a site: its host, without `www.`. */
68
+ export declare function hostOf(url: string): string;
69
+ /**
70
+ * What the agent is told. It has no network and no browser: it reads the copy the host saved, answers with a plain
71
+ * critique, and writes the new site as static files into `redesign/`, which is already being shown.
72
+ */
73
+ export declare function brief(saved: Saved, note?: string): string;
74
+ /** Why a step stopped, in the reader's words: the host's own plain refusals as they come, else this. */
75
+ export declare function stopped(e: unknown, say?: Say): string;