@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,136 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Plugins: TypeScript connectors the org builds for the runtime to run.
4
+ *
5
+ * Browse offers building one, then lists what this deployment mounts, which is
6
+ * built in and read-only. Yours is what the org built, each with the source that
7
+ * runs. Building is the gate — the platform bundles and compiles the source and
8
+ * keeps it only if both succeed, and a failure says why in the bundler's words.
9
+ * Describe an API instead of writing the TypeScript and a model writes it; the
10
+ * result opens to be read. A plugin carries no credential: it names the
11
+ * connector whose credential it reads when it runs.
12
+ *
13
+ * Its words are the reader's language (@hanzo/i18n `t`); a plugin's name, its
14
+ * source and the bundler's reasons are drawn as given.
15
+ */
16
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
17
+ import { useI18n } from '@hanzo/i18n/react';
18
+ import { AlertCircle, Check, Code2, Puzzle, Trash2 } from '@hanzogui/lucide-icons-2';
19
+ import { Button, DropdownMenu, Input, Textarea } from '@hanzo/ui';
20
+ import { Code } from '@hanzo/ui/chat';
21
+ import { useState } from 'react';
22
+ import { authored, build, mounted, remove } from '../api/plugins.js';
23
+ import { useHost, useTarget } from '../host.js';
24
+ import { useLoad } from './load.js';
25
+ import { say } from './say.js';
26
+ import { Choice, day, Empty, Failed, Field, Grid, Mark, matches, MenuTrigger, Part, Sheet, Soft, Tile, TilesSkeleton, useCount, Visitor } from './ui.js';
27
+ import { Confirm } from '../ask.js';
28
+ const INITIAL_MOUNTS = 6;
29
+ const kb = (n) => (n < 1024 ? `${n} B` : `${(n / 1024).toFixed(1)} KB`);
30
+ function StatusBanner({ notice }) {
31
+ if (!notice?.text)
32
+ return null;
33
+ return (_jsxs(XStack, { items: "center", gap: "$1.5", role: notice.error ? 'alert' : 'status', children: [notice.error ? _jsx(AlertCircle, { size: 14, color: "var(--state-error)", "aria-hidden": true }) : _jsx(Check, { size: 14, color: "var(--state-success)", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: notice.error ? 'var(--state-error)' : '$soft', flex: 1, minW: 0, children: notice.text })] }));
34
+ }
35
+ export function Plugins({ view, q, adding, onAdding, onView, onCount }) {
36
+ const { t } = useI18n();
37
+ const host = useHost();
38
+ const target = useTarget();
39
+ const signed = Boolean(host.person);
40
+ const mine = useLoad(signed ? () => authored(target) : null, [], [target, signed]);
41
+ const mounts = useLoad(signed && view === 'discover' ? () => mounted(target) : null, [], [target, signed, view]);
42
+ const [opened, setOpened] = useState(null);
43
+ const [deleting, setDeleting] = useState(null);
44
+ const [mountDetail, setMountDetail] = useState(null);
45
+ const [showAllMounts, setShowAllMounts] = useState(false);
46
+ const [notice, setNotice] = useState(null);
47
+ useCount(mine.value.length, onCount);
48
+ const sheets = (_jsxs(_Fragment, { children: [adding ? (_jsx(Build, { onClose: () => onAdding(false), onBuilt: (p, said) => {
49
+ onAdding(false);
50
+ onView('yours');
51
+ mine.reload();
52
+ setNotice({ text: said });
53
+ setOpened(p);
54
+ } })) : null, opened ? (_jsx(Source, { plugin: opened, onClose: () => setOpened(null), onDeleted: () => {
55
+ setNotice({ text: t('{name} is deleted', { name: opened.name }) });
56
+ setOpened(null);
57
+ mine.reload();
58
+ } })) : null, deleting ? (_jsx(Confirm, { title: t('Delete {name}?', { name: deleting.name }), act: t('Delete'), says: t('The runtime can no longer load it.'), open: true, onOpenChange: (o) => !o && setDeleting(null), run: async () => {
59
+ const gone = deleting;
60
+ await remove(target, gone.id);
61
+ setDeleting(null);
62
+ setNotice({ text: t('{name} is deleted', { name: gone.name }) });
63
+ mine.reload();
64
+ } })) : null, mountDetail ? _jsx(MountSheet, { mount: mountDetail, onClose: () => setMountDetail(null) }) : null] }));
65
+ if (!signed) {
66
+ return _jsx(Visitor, { children: view === 'discover' ? t('Sign in to browse plugins.') : t('Sign in to see your plugins.') });
67
+ }
68
+ if (view === 'discover') {
69
+ const shown = mounts.value.filter((m) => matches(q, m.name, ...m.prefixes));
70
+ const searching = Boolean(q.trim());
71
+ const visible = searching || showAllMounts ? shown : shown.slice(0, INITIAL_MOUNTS);
72
+ return (_jsxs(YStack, { gap: "$6", children: [_jsx(StatusBanner, { notice: notice }), _jsxs(XStack, { items: "center", gap: "$3", p: "$4", children: [_jsx(Mark, { name: t('Build your own'), size: 36, icon: _jsx(Code2, { size: 16, color: "$soft", "aria-hidden": true }) }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", children: t('Build your own') }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Write a connector in TypeScript, or describe an API and Hanzo writes it.') })] }), _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", shrink: 0, onPress: () => onAdding(true), children: t('Build a plugin') })] }), _jsx(Part, { title: t('Built in'), detail: t('Part of Hanzo. Always on, nothing to add.'), children: mounts.error && !mounts.value.length ? (_jsx(Failed, { error: mounts.error, onRetry: mounts.reload })) : mounts.loading && !mounts.value.length ? (_jsx(TilesSkeleton, { label: t('Loading built-in plugins') })) : !shown.length ? (_jsx(Soft, { children: mounts.value.length ? t('Nothing built in matches “{q}”.', { q: q.trim() }) : t('Nothing built in is listed.') })) : (_jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{n} built in', { n: shown.length }) }), _jsx(Grid, { label: t('Mounted subsystems'), children: visible.map((m) => (_jsx(Tile, { title: m.name, detail: m.prefixes.join(' · '), meta: m.enabled ? t('On') : t('Off'), mark: _jsx(Mark, { name: m.name, icon: _jsx(Puzzle, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setMountDetail(m) }, m.name))) }), !searching && shown.length > INITIAL_MOUNTS ? (_jsx(XStack, { justify: "flex-start", children: _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setShowAllMounts((v) => !v), children: showAllMounts ? t('Show fewer') : t('Show all {n} built-in plugins', { n: shown.length }) }) })) : null] })) }), sheets] }));
73
+ }
74
+ const shown = mine.value.filter((p) => matches(q, p.name, p.provider));
75
+ return (_jsxs(YStack, { gap: "$3", children: [_jsx(StatusBanner, { notice: notice }), mine.error && !mine.value.length ? (_jsx(Failed, { error: mine.error, onRetry: mine.reload })) : mine.loading && !mine.value.length ? (_jsx(TilesSkeleton, { label: t('Loading your plugins'), count: 4 })) : !mine.value.length ? (_jsx(Empty, { title: t('No plugins yet'), detail: t('Write a connector in TypeScript, or describe an API and Hanzo writes it.'), children: _jsx(Button, { size: "sm", onPress: () => onAdding(true), children: t('Build a plugin') }) })) : !shown.length ? (_jsx(Soft, { children: t('No plugin of yours matches “{q}”.', { q: q.trim() }) })) : (_jsx(Grid, { label: t('Your plugins'), children: shown.map((p) => (_jsx(Tile, { title: p.name, detail: p.provider ? t('Reads the {provider} connector’s credential when it runs.', { provider: p.provider }) : t('Needs no credential.'), meta: day(p.built) ? t('Built {date}', { date: day(p.built) }) : undefined, mark: _jsx(Mark, { name: p.name, icon: _jsx(Code2, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setOpened(p), action: _jsx(DropdownMenu, { placement: "bottom-end", offset: 6, trigger: _jsx(MenuTrigger, { label: t('Actions for {name}', { name: p.name }) }), items: [
76
+ { key: 'source', label: t('View source'), icon: _jsx(Code2, { size: 15 }), onSelect: () => setOpened(p) },
77
+ { type: 'separator' },
78
+ { key: 'delete', label: t('Delete plugin'), icon: _jsx(Trash2, { size: 15 }), destructive: true, onSelect: () => setDeleting(p) },
79
+ ] }) }, p.id))) })), sheets] }));
80
+ }
81
+ /** Read-only inspection sheet for a built-in mounted subsystem. */
82
+ function MountSheet({ mount, onClose }) {
83
+ const { t } = useI18n();
84
+ return (_jsxs(Sheet, { title: mount.name, open: true, onOpenChange: (o) => !o && onClose(), width: 480, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(YStack, { width: 8, height: 8, rounded: 999, bg: mount.enabled ? 'var(--state-success)' : '$soft', shrink: 0, "aria-hidden": true }), _jsx(SizableText, { size: "$2", color: "$soft", children: mount.enabled ? t('Built in and always on for every run.') : t('Built in, currently off in this deployment.') })] }), _jsx(Field, { label: t('Route prefixes'), children: _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", bg: "$panel", rounded: "$3", overflow: "hidden", children: mount.prefixes.length ? (mount.prefixes.map((prefix, i) => (_jsx(XStack, { px: "$3", py: "$2", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: _jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", children: prefix }) }, prefix)))) : (_jsx(XStack, { px: "$3", py: "$2", children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('No route prefixes listed.') }) })) }) })] }));
85
+ }
86
+ /** Build a plugin from its TypeScript, or from a description of the API it calls. */
87
+ function Build({ onClose, onBuilt }) {
88
+ const { t } = useI18n();
89
+ const target = useTarget();
90
+ const [name, setName] = useState('');
91
+ const [provider, setProvider] = useState('');
92
+ const [way, setWay] = useState('source');
93
+ // Each way keeps its own text, so switching between them loses neither.
94
+ const [source, setSource] = useState('');
95
+ const [spec, setSpec] = useState('');
96
+ const [working, setWorking] = useState(false);
97
+ const [notice, setNotice] = useState(null);
98
+ const body = way === 'source' ? source : spec;
99
+ const canBuild = !working && Boolean(name.trim()) && Boolean(body.trim());
100
+ const go = async () => {
101
+ setWorking(true);
102
+ setNotice({ text: way === 'spec' ? t('Writing and building it…') : t('Building it…') });
103
+ try {
104
+ const out = await build(target, { name: name.trim(), provider, source: way === 'source' ? source : '', spec: way === 'spec' ? spec : '' });
105
+ const built = { name: out.plugin.name, size: kb(out.bytes) };
106
+ onBuilt(out.plugin, out.generated ? t('{name} built: {size}, written from your description — read it below.', built) : t('{name} built: {size}.', built));
107
+ }
108
+ catch (e) {
109
+ setNotice({ text: say(e, t), error: true });
110
+ }
111
+ finally {
112
+ setWorking(false);
113
+ }
114
+ };
115
+ return (_jsxs(Sheet, { title: t('Build a plugin'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [_jsx(Field, { label: t('Name'), hint: t('One lowercase word: letters, digits, _ or -.'), children: _jsx(Input, { value: name, onChangeText: setName, placeholder: "acme-crm", "aria-label": t('Name'), autoCapitalize: "none", borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: t('Connector'), hint: t('Optional. The connector whose key it uses when it runs; a plugin never holds a key itself.'), children: _jsx(Input, { value: provider, onChangeText: setProvider, placeholder: "acme", "aria-label": t('Connector'), autoCapitalize: "none", borderColor: "var(--border-strong)" }) }), _jsx(Choice, { label: t('Build from'), value: way, options: [
116
+ { id: 'source', label: 'TypeScript' },
117
+ { id: 'spec', label: t('Describe an API') },
118
+ ], onChange: setWay }), _jsx(Field, { label: way === 'source' ? t('Source') : t('The API'), hint: way === 'source'
119
+ ? t('Kept only if it builds. A failed build says why.')
120
+ : t('An OpenAPI document, or the endpoints in plain words. You read the TypeScript before it runs.'), children: _jsx(Textarea, { value: body, onChangeText: way === 'source' ? setSource : setSpec, "aria-label": way === 'source' ? t('Source') : t('The API'), placeholder: way === 'source' ? 'export const acme = createProvider({ … })' : t('POST /v1/things creates a thing…'), rows: 14, fontFamily: "$mono" }) }), notice ? (notice.error ? (_jsx(StatusBanner, { notice: notice })) : (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: notice.text }))) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onPress: onClose, children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "primary", disabled: !canBuild, onPress: () => void go(), children: working ? (way === 'spec' ? t('Writing & building…') : t('Building…')) : t('Build') })] })] }));
121
+ }
122
+ /** A built plugin's source, as the runtime will run it, and deleting it. */
123
+ function Source({ plugin, onClose, onDeleted }) {
124
+ const { t } = useI18n();
125
+ const target = useTarget();
126
+ const [asking, setAsking] = useState(false);
127
+ return (_jsxs(Sheet, { title: plugin.name, open: true, onOpenChange: (o) => !o && onClose(), width: 760, children: [_jsx(SizableText, { size: "$2", color: "$soft", children: [
128
+ plugin.provider ? t('Reads the {provider} connector’s credential when it runs.', { provider: plugin.provider }) : t('Needs no credential.'),
129
+ day(plugin.built) ? t('Built {date}.', { date: day(plugin.built) }) : '',
130
+ ]
131
+ .filter(Boolean)
132
+ .join(' ') }), _jsx(Code, { language: "TypeScript", value: plugin.source, children: _jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", "$platform-web": { whiteSpace: 'pre' }, children: plugin.source }) }), _jsx(YStack, { items: "flex-start", children: _jsxs(Button, { size: "sm", variant: "ghost", tone: "danger", onPress: () => setAsking(true), children: [_jsx(Trash2, { size: 14 }), " ", t('Delete plugin')] }) }), _jsx(Confirm, { title: t('Delete {name}?', { name: plugin.name }), act: t('Delete'), says: t('The runtime can no longer load it.'), open: asking, onOpenChange: setAsking, run: async () => {
133
+ await remove(target, plugin.id);
134
+ onDeleted();
135
+ } })] }));
136
+ }
@@ -0,0 +1,4 @@
1
+ /** Drawn only where the builder's host and settings are mounted, so a chat drawn without them draws nothing. */
2
+ export declare function Roles({ first }: {
3
+ first?: boolean;
4
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,105 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Skills for a person's work: pick what you do, see the skills that suit it, add them all in one
4
+ * click or leave some out first. In Customize > Skills it is always there; as the first run's card
5
+ * (`first`) it asks once, and the answer (`Prefs.work`, `Prefs.roles`) follows the account. Adding a
6
+ * skill switches it on for the org, which is an org admin's to do; a member reads what is recommended.
7
+ */
8
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
9
+ import { useI18n } from '@hanzo/i18n/react';
10
+ import { Check } from '@hanzogui/lucide-icons-2';
11
+ import { Button } from '@hanzo/ui';
12
+ import { useEffect, useMemo, useState } from 'react';
13
+ import { active, brand, tool } from '../api/skills.js';
14
+ import { toggle } from '../api/tools.js';
15
+ import { useHost, useHosted, useTarget } from '../host.js';
16
+ import { usePrefs } from '../prefs.js';
17
+ import { recommend, WORK } from '../roles.js';
18
+ import { useLoad } from './load.js';
19
+ import { say } from './say.js';
20
+ import { FilterPills, Part } from './ui.js';
21
+ /** Drawn only where the builder's host and settings are mounted, so a chat drawn without them draws nothing. */
22
+ export function Roles({ first = false }) {
23
+ const hosted = useHosted();
24
+ const state = usePrefs(false);
25
+ return hosted && state ? _jsx(Suggest, { first: first, state: state }) : null;
26
+ }
27
+ function Suggest({ first, state }) {
28
+ const { t } = useI18n();
29
+ const host = useHost();
30
+ const target = useTarget();
31
+ const signed = Boolean(host.person);
32
+ const may = signed && host.admin;
33
+ const kept = state?.prefs.work ?? '';
34
+ const [work, setWork] = useState(kept);
35
+ const shelf = useLoad(signed ? () => brand(target) : null, null, [target.api, signed]);
36
+ const on = useLoad(signed ? () => active(target) : null, [], [target, signed]);
37
+ const [left, setLeft] = useState(new Set());
38
+ const [busy, setBusy] = useState(false);
39
+ const [notice, setNotice] = useState(null);
40
+ // The card stays up with its word once the skills are added, and goes on the next visit.
41
+ const [said, setSaid] = useState(false);
42
+ // The account's work arrives after the first frame; take it up unless the person has already chosen another.
43
+ useEffect(() => {
44
+ if (kept)
45
+ setWork((now) => now || kept);
46
+ }, [kept]);
47
+ useEffect(() => setLeft(new Set()), [work]);
48
+ const lit = useMemo(() => new Set(on.value.map((x) => x.name)), [on.value]);
49
+ const suited = useMemo(() => recommend(work, shelf.value), [work, shelf.value]);
50
+ const fresh = suited.filter((e) => !lit.has(tool(e.name)));
51
+ const taken = fresh.filter((e) => !left.has(e.name));
52
+ // The first run's card: only a signed-in admin who has said nothing about their work and not put this off.
53
+ if (!signed)
54
+ return null;
55
+ if (first && !said && (!may || kept || state.prefs.roles || shelf.error))
56
+ return null;
57
+ const choose = (id) => {
58
+ setWork(id);
59
+ setNotice(null);
60
+ };
61
+ const add = async () => {
62
+ setBusy(true);
63
+ setNotice(null);
64
+ try {
65
+ await toggle(target, taken.map((e) => tool(e.name)));
66
+ await state.save({ work, roles: 'done' });
67
+ on.reload();
68
+ setSaid(true);
69
+ setNotice({ text: t('{n} skills are on', { n: taken.length }) });
70
+ }
71
+ catch (e) {
72
+ setNotice({ text: say(e, t), error: true });
73
+ }
74
+ finally {
75
+ setBusy(false);
76
+ }
77
+ };
78
+ const later = async () => {
79
+ try {
80
+ await state.save({ roles: 'skipped' });
81
+ }
82
+ catch (e) {
83
+ setNotice({ text: say(e, t), error: true });
84
+ }
85
+ };
86
+ // Put off, the card is gone; added, it is gone from the next visit.
87
+ if (first && state.prefs.roles === 'skipped')
88
+ return null;
89
+ return (_jsx(Part, { title: first ? t('What do you do?') : t('Recommended for your work'), detail: t('Pick your work and Hanzo suggests the skills that suit it. Add them all in one click, or leave some out first.'), children: _jsxs(YStack, { gap: "$3", "data-slot": "roles", "data-first": first || undefined, children: [_jsx(FilterPills, { label: t('Your work'), value: work, options: WORK.map((w) => ({ id: w.id, label: t(w.label) })), onChange: choose, maxVisibleDesktop: 11, mobileLimit: 5 }), work && !suited.length ? (_jsx(SizableText, { size: "$2", color: "$soft", "data-slot": "roles-none", children: t('Nothing is recommended for this yet. Browse the skills to add any you like.') })) : null, suited.length ? (_jsx(YStack, { gap: "$1.5", role: "group", "aria-label": t('Recommended skills'), children: suited.map((e) => {
90
+ const isOn = lit.has(tool(e.name));
91
+ const picked = !isOn && !left.has(e.name);
92
+ return (_jsxs(XStack, { render: "button", role: "checkbox", "aria-checked": isOn || picked, "aria-disabled": isOn || !may || undefined, "data-slot": "roles-skill", "data-skill": e.name, onClick: () => {
93
+ if (isOn || !may)
94
+ return;
95
+ setLeft((s) => {
96
+ const next = new Set(s);
97
+ if (next.has(e.name))
98
+ next.delete(e.name);
99
+ else
100
+ next.add(e.name);
101
+ return next;
102
+ });
103
+ }, items: "flex-start", gap: "$2.5", p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: picked ? 'var(--border-strong)' : '$borderColor', bg: picked ? '$panel' : 'transparent', cursor: isOn || !may ? 'default' : 'pointer', "$max-sm": { minH: 44 }, children: [_jsx(XStack, { width: 18, height: 18, rounded: 5, borderWidth: 1, borderColor: "var(--border-strong)", items: "center", justify: "center", bg: isOn || picked ? '$ink' : 'transparent', shrink: 0, mt: 1, children: isOn || picked ? _jsx(Check, { size: 12, color: "var(--background)", "aria-hidden": true }) : null }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", items: "flex-start", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: e.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, text: "start", children: e.description })] }), isOn ? (_jsx(SizableText, { size: "$1", color: "$soft", shrink: 0, children: t('Added') })) : null] }, e.name));
104
+ }) })) : null, suited.length && !may ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('An org admin adds skills. Ask them to add these.') })) : null, notice ? (_jsx(SizableText, { size: "$2", color: notice.error ? 'var(--state-error)' : '$soft', role: notice.error ? 'alert' : 'status', children: notice.text })) : null, _jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [suited.length ? (_jsx(Button, { "data-slot": "roles-add", size: "sm", disabled: !may || busy || !taken.length, onPress: () => void add(), children: taken.length ? t('Add {n} skills', { n: taken.length }) : t('All added') })) : null, first ? (_jsx(Button, { "data-slot": "roles-later", size: "sm", variant: "outline", borderColor: "var(--border-strong)", disabled: busy, onPress: () => void later(), children: t('Not now') })) : null] })] }) }));
105
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * What a read or a write that failed tells a person: plain words, never the
3
+ * platform's internals. A refusal is read by its status; only a 400, 409 or
4
+ * 422 carries the platform's own sentence, because those name what was wrong
5
+ * with what was sent (a name taken, a build that failed and why). A sentence
6
+ * this client wrote itself (a name that does not fit) is said as written.
7
+ *
8
+ * Said in the reader's language: the screen hands its `t` (English without
9
+ * one). A sentence a module wrote is English and marked, so it goes through
10
+ * `t`; the platform's own words are no key and come back from it as given.
11
+ */
12
+ import type { Say } from '@hanzo/i18n/react';
13
+ export declare function say(e: unknown, t?: Say): string;
@@ -0,0 +1,32 @@
1
+ import { Refusal, told } from '../api/call.js';
2
+ import { Slow } from '../data.js';
3
+ import { english } from '../say.js';
4
+ /** The line call.ts writes when the platform gave no reason: a method, a path and a status. */
5
+ const BARE = /^(GET|POST|PUT|PATCH|DELETE) \S* answered \d+$/;
6
+ export function say(e, t = english) {
7
+ if (e instanceof Slow)
8
+ return t('Hanzo is taking too long to answer. Try again.');
9
+ if (e instanceof Refusal) {
10
+ if (e.status === 401)
11
+ return t('Your sign-in has expired. Sign in again.');
12
+ if (e.status === 403)
13
+ return t('Your account can’t do this here. Ask an org admin.');
14
+ if (e.status === 404)
15
+ return t('Not found. It may have been removed.');
16
+ if (e.status === 429)
17
+ return t('Too many requests. Wait a moment and try again.');
18
+ if (e.status >= 500)
19
+ return t('Hanzo could not answer just now. Try again.');
20
+ if ((e.status === 400 || e.status === 409 || e.status === 422) && e.message && !BARE.test(e.message))
21
+ return t(e.message);
22
+ return t('Hanzo could not do that. Try again.');
23
+ }
24
+ // fetch rejects with a TypeError when the network does; a body that is not JSON is a SyntaxError.
25
+ if (e instanceof TypeError)
26
+ return t('Could not reach Hanzo. Check your connection and try again.');
27
+ if (e instanceof SyntaxError)
28
+ return t('Hanzo answered with something unreadable. Try again.');
29
+ if (e instanceof Error && e.message)
30
+ return told(e, t);
31
+ return t('Something went wrong. Try again.');
32
+ }
@@ -0,0 +1,2 @@
1
+ import { type Pane } from './ui.tsx';
2
+ export declare function Skills({ view, q, adding, onAdding, onView, onCount }: Pane): import("react").JSX.Element;
@@ -0,0 +1,208 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Skills: what the agent knows how to do, each a SKILL.md it reads when an agent
4
+ * names it.
5
+ *
6
+ * Browse is Hanzo's catalogue; adding one switches it on for the org, which is
7
+ * all adding is: the platform keeps no copy. Yours is the org's own skills —
8
+ * written here, each with its switch — and the catalogue's skills it has added.
9
+ * A skill written here is switched on when it is saved.
10
+ *
11
+ * Its words are the reader's language (@hanzo/i18n `t`); a skill's name,
12
+ * description and SKILL.md are the platform's or the org's, drawn as given.
13
+ */
14
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
15
+ import { useI18n } from '@hanzo/i18n/react';
16
+ import { AlertCircle, BookOpen, Check, Eye, Pencil, SlidersHorizontal, Trash2 } from '@hanzogui/lucide-icons-2';
17
+ import { Button, DropdownMenu, Input, Skeleton, Switch, Textarea } from '@hanzo/ui';
18
+ import { Code } from '@hanzo/ui/chat';
19
+ import { useEffect, useMemo, useState } from 'react';
20
+ import { active, authored, brand, document, nameOf, remove, tool, write } from '../api/skills.js';
21
+ import { toggle } from '../api/tools.js';
22
+ import { useHost, useTarget } from '../host.js';
23
+ import { useLoad } from './load.js';
24
+ import { Roles } from './roles.js';
25
+ import { say } from './say.js';
26
+ import { Add, day, Empty, Failed, Field, FilterPills, Grid, Mark, matches, MenuTrigger, Part, Sheet, Soft, Tile, TilesSkeleton, useCount, Visitor } from './ui.js';
27
+ import { Confirm } from '../ask.js';
28
+ const PAGE = 60;
29
+ const ANY = '';
30
+ function StatusBanner({ notice }) {
31
+ if (!notice?.text)
32
+ return null;
33
+ return (_jsxs(XStack, { items: "center", gap: "$1.5", role: notice.error ? 'alert' : 'status', children: [notice.error ? _jsx(AlertCircle, { size: 14, color: "var(--state-error)", "aria-hidden": true }) : _jsx(Check, { size: 14, color: "var(--state-success)", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: notice.error ? 'var(--state-error)' : '$soft', flex: 1, minW: 0, children: notice.text })] }));
34
+ }
35
+ function DocSkeleton({ label }) {
36
+ return (_jsxs(YStack, { role: "status", "aria-busy": true, "aria-label": label, p: "$3.5", gap: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsx(Skeleton, { layout: "block", width: "38%", height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "94%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "82%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "88%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "64%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "76%", height: 11, rounded: "$2" })] }));
37
+ }
38
+ export function Skills({ view, q, adding, onAdding, onView, onCount }) {
39
+ const { t } = useI18n();
40
+ const host = useHost();
41
+ const target = useTarget();
42
+ const signed = Boolean(host.person);
43
+ // What every run in the org loads is an org admin's to change; a member reads it.
44
+ const may = signed && host.admin;
45
+ const own = useLoad(signed ? () => authored(target) : null, [], [target, signed]);
46
+ const on = useLoad(signed ? () => active(target) : null, [], [target, signed]);
47
+ const shelf = useLoad(view === 'discover' ? () => brand(target) : null, null, [target.api, view]);
48
+ const [editing, setEditing] = useState(null);
49
+ const [reading, setReading] = useState(null);
50
+ const [deleting, setDeleting] = useState(null);
51
+ const [busy, setBusy] = useState('');
52
+ const [notice, setNotice] = useState(null);
53
+ const [product, setProduct] = useState(ANY);
54
+ const [shown, setShown] = useState(PAGE);
55
+ useEffect(() => setShown(PAGE), [q, product]);
56
+ const lit = useMemo(() => new Set(on.value.map((x) => x.name)), [on.value]);
57
+ const mine = useMemo(() => new Set(own.value.map((s) => s.name)), [own.value]);
58
+ const added = on.value.filter((x) => nameOf(x.name) && !mine.has(nameOf(x.name)));
59
+ useCount(own.value.length + added.length, onCount);
60
+ const productOptions = useMemo(() => {
61
+ const c = shelf.value;
62
+ if (!c)
63
+ return [];
64
+ const names = c.products.length
65
+ ? [...c.products].sort((a, b) => b.count - a.count || a.name.localeCompare(b.name)).map((p) => p.name)
66
+ : [...new Set(c.skills.map((e) => e.product).filter(Boolean))].sort((a, b) => a.localeCompare(b));
67
+ return names.length > 1 ? [{ id: ANY, label: t('All') }, ...names.map((name) => ({ id: name, label: name }))] : [];
68
+ }, [shelf.value, t]);
69
+ /** Switch one skill on or off, then read what is on again. */
70
+ const flip = async (name, next) => {
71
+ setBusy(name);
72
+ setNotice(null);
73
+ try {
74
+ await toggle(target, next ? [tool(name)] : [], next ? [] : [tool(name)]);
75
+ on.reload();
76
+ setNotice({ text: next ? t('{name} is on', { name }) : t('{name} is off', { name }) });
77
+ }
78
+ catch (e) {
79
+ setNotice({ text: say(e, t), error: true });
80
+ }
81
+ finally {
82
+ setBusy('');
83
+ }
84
+ };
85
+ const reader = reading ? (_jsx(Reader, { skill: reading, added: lit.has(tool(reading.name)), signed: may, busy: busy === reading.name, onFlip: (next) => void flip(reading.name, next), onClose: () => setReading(null) })) : null;
86
+ const editor = adding || editing ? (_jsx(Editor, { skill: editing, may: may, onClose: () => {
87
+ setEditing(null);
88
+ onAdding(false);
89
+ }, onSaved: (s, fresh) => {
90
+ setEditing(null);
91
+ onAdding(false);
92
+ own.reload();
93
+ on.reload();
94
+ onView('yours');
95
+ setNotice({ text: fresh ? t('{name} is saved and on', { name: s.name }) : t('{name} is saved', { name: s.name }) });
96
+ }, onDeleted: (name) => {
97
+ setEditing(null);
98
+ own.reload();
99
+ on.reload();
100
+ setNotice({ text: t('{name} is deleted', { name }) });
101
+ } })) : null;
102
+ const confirmDelete = deleting ? (_jsx(Confirm, { title: t('Delete {name}?', { name: deleting.name }), act: t('Delete'), says: t('The skill leaves your organization and every agent that names it.'), open: true, onOpenChange: (o) => !o && setDeleting(null), run: async () => {
103
+ const gone = deleting;
104
+ await remove(target, gone.id);
105
+ setDeleting(null);
106
+ own.reload();
107
+ on.reload();
108
+ setNotice({ text: t('{name} is deleted', { name: gone.name }) });
109
+ } })) : null;
110
+ if (view === 'discover') {
111
+ const all = shelf.value?.skills ?? [];
112
+ const found = all.filter((e) => (!product || e.product === product) && matches(q, e.name, e.description, e.product));
113
+ return (_jsxs(YStack, { gap: "$3", children: [_jsx(StatusBanner, { notice: notice }), signed && !q.trim() ? _jsx(Roles, {}) : null, _jsx(Part, { title: t('From Hanzo'), detail: t('Add one and every run in your organization can use it.'), children: shelf.error && !shelf.value ? (_jsx(Failed, { error: shelf.error, onRetry: shelf.reload })) : !shelf.value ? (_jsx(TilesSkeleton, { label: t('Loading skills') })) : (_jsxs(YStack, { gap: "$3", children: [productOptions.length > 1 ? (_jsx(FilterPills, { label: t('Product'), value: product, options: productOptions, onChange: setProduct, maxVisibleDesktop: 6, mobileLimit: 4 })) : null, !found.length ? (_jsx(Soft, { action: product ? (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setProduct(ANY), children: t('Show all products') })) : undefined, children: q.trim()
114
+ ? t('No skill matches “{q}”.', { q: q.trim() })
115
+ : product
116
+ ? t('No skills in {product}.', { product })
117
+ : t('There are no skills to add yet.') })) : (_jsxs(_Fragment, { children: [_jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: found.length === all.length ? t('{n} skills', { n: all.length }) : t('{found} of {n} skills', { found: found.length, n: all.length }) }), _jsx(Grid, { label: t('Skills to add'), children: found.slice(0, shown).map((e) => (_jsx(Tile, { title: e.name, detail: e.description, meta: e.product || undefined, mark: _jsx(Mark, { name: e.name, icon: _jsx(BookOpen, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setReading(e), action: may ? _jsx(Add, { name: e.name, added: lit.has(tool(e.name)), busy: busy === e.name, onPress: () => void flip(e.name, true) }) : undefined }, e.name))) }), found.length > shown ? (_jsx(XStack, { justify: "center", children: _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setShown(shown + PAGE), children: t('Show more') }) })) : null] }))] })) }), reader, editor] }));
118
+ }
119
+ if (!signed) {
120
+ return _jsx(Visitor, { children: t('Sign in to see your skills.') });
121
+ }
122
+ const ownShown = own.value.filter((s) => matches(q, s.name, s.description));
123
+ const addedShown = added.filter((x) => matches(q, nameOf(x.name), x.description));
124
+ const error = own.error ?? on.error;
125
+ return (_jsxs(YStack, { gap: "$5", children: [_jsx(StatusBanner, { notice: notice }), error && !own.value.length && !on.value.length ? (_jsx(Failed, { error: error, onRetry: () => {
126
+ own.reload();
127
+ on.reload();
128
+ } })) : (own.loading || on.loading) && !own.value.length && !on.value.length ? (_jsx(TilesSkeleton, { label: t('Loading your skills'), count: 4 })) : !own.value.length && !added.length ? (_jsxs(Empty, { title: t('No skills yet'), detail: may ? t('Add one from Hanzo, or write your own.') : t('An org admin adds skills. Browse what there is.'), children: [_jsx(Button, { size: "sm", variant: "outline", onPress: () => onView('discover'), children: t('Browse skills') }), may ? (_jsx(Button, { size: "sm", onPress: () => onAdding(true), children: t('Write a skill') })) : null] })) : !ownShown.length && !addedShown.length ? (_jsx(Soft, { children: t('No skill of yours matches “{q}”.', { q: q.trim() }) })) : (_jsxs(_Fragment, { children: [ownShown.length ? (_jsx(Part, { title: t('Made by your team'), detail: t('Off keeps a skill but leaves it out of every run.'), children: _jsx(Grid, { label: t('Your skills'), children: ownShown.map((s) => {
129
+ const activeNow = lit.has(tool(s.name));
130
+ return (_jsx(Tile, { title: s.name, detail: s.description || firstLine(s.content), meta: [s.source ? t('From {source}', { source: s.source }) : day(s.created) ? t('Saved {date}', { date: day(s.created) }) : '', s.admitted ? '' : t('Not in runs until an admin saves it')]
131
+ .filter(Boolean)
132
+ .join(' · ') || undefined, mark: _jsx(Mark, { name: s.name }), onOpen: () => setEditing(s), action: _jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [may ? (_jsx(Switch, { checked: activeNow, disabled: busy === s.name, onCheckedChange: (v) => void flip(s.name, v), "aria-label": t('{name} on', { name: s.name }) })) : (_jsx(SizableText, { size: "$1", color: "$soft", children: activeNow ? t('On') : t('Off') })), _jsx(DropdownMenu, { placement: "bottom-end", offset: 6, trigger: _jsx(MenuTrigger, { label: t('Actions for {name}', { name: s.name }) }), items: may
133
+ ? [
134
+ { key: 'edit', label: t('Edit skill'), icon: _jsx(Pencil, { size: 15 }), onSelect: () => setEditing(s) },
135
+ {
136
+ key: 'toggle',
137
+ label: activeNow ? t('Turn off') : t('Turn on'),
138
+ icon: _jsx(SlidersHorizontal, { size: 15 }),
139
+ disabled: busy === s.name,
140
+ onSelect: () => void flip(s.name, !activeNow),
141
+ },
142
+ { type: 'separator' },
143
+ { key: 'delete', label: t('Delete'), icon: _jsx(Trash2, { size: 15 }), destructive: true, onSelect: () => setDeleting(s) },
144
+ ]
145
+ : [{ key: 'view', label: t('View SKILL.md'), icon: _jsx(Eye, { size: 15 }), onSelect: () => setEditing(s) }] })] }) }, s.id));
146
+ }) }) })) : null, addedShown.length ? (_jsx(Part, { title: t('Added from Hanzo'), detail: t('On for every run in your organization.'), children: _jsx(Grid, { label: t('Added skills'), children: addedShown.map((x) => {
147
+ const name = nameOf(x.name);
148
+ return (_jsx(Tile, { title: name, detail: x.description, mark: _jsx(Mark, { name: name, icon: _jsx(BookOpen, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setReading({ name, description: x.description, product: '' }), action: _jsx(DropdownMenu, { placement: "bottom-end", offset: 6, trigger: _jsx(MenuTrigger, { label: t('Actions for {name}', { name }) }), items: [
149
+ { key: 'read', label: t('Read SKILL.md'), icon: _jsx(BookOpen, { size: 15 }), onSelect: () => setReading({ name, description: x.description, product: '' }) },
150
+ ...(may
151
+ ? [
152
+ { type: 'separator' },
153
+ {
154
+ key: 'remove',
155
+ label: t('Remove'),
156
+ icon: _jsx(Trash2, { size: 15 }),
157
+ destructive: true,
158
+ disabled: busy === name,
159
+ onSelect: () => void flip(name, false),
160
+ },
161
+ ]
162
+ : []),
163
+ ] }) }, x.name));
164
+ }) }) })) : null] })), reader, editor, confirmDelete] }));
165
+ }
166
+ const firstLine = (md) => md
167
+ .split('\n')
168
+ .map((l) => l.replace(/^#+\s*/, '').trim())
169
+ .find(Boolean) ?? '';
170
+ /** One catalogue skill: what it is, its SKILL.md, and adding or removing it. */
171
+ function Reader({ skill, added, signed, busy, onFlip, onClose, }) {
172
+ const { t } = useI18n();
173
+ const target = useTarget();
174
+ const doc = useLoad(() => document(target, skill.name), '', [target.api, skill.name]);
175
+ return (_jsxs(Sheet, { title: skill.name, open: true, onOpenChange: (o) => !o && onClose(), width: 720, children: [skill.product ? (_jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(BookOpen, { size: 13, color: "$soft", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$soft", children: skill.product })] })) : null, skill.description ? (_jsx(SizableText, { size: "$2", color: "$soft", children: skill.description })) : null, signed ? (_jsxs(XStack, { gap: "$2.5", items: "center", flexWrap: "wrap", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsx(Button, { size: "sm", variant: added ? 'outline' : 'primary', borderColor: added ? 'var(--border-strong)' : undefined, disabled: busy, onPress: () => onFlip(!added), children: busy ? t('Updating…') : added ? t('Remove') : t('Add to your skills') }), _jsx(SizableText, { size: "$1", color: "$soft", flex: 1, children: added ? t('On for your organization.') : t('Every run in your organization can use it once added.') })] })) : null, doc.error ? (_jsx(Failed, { error: doc.error, onRetry: doc.reload })) : doc.loading && !doc.value ? (_jsx(DocSkeleton, { label: t('Loading SKILL.md') })) : (_jsx(Code, { language: "SKILL.md", value: doc.value, children: _jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", "$platform-web": { whiteSpace: 'pre-wrap' }, children: doc.value }) }))] }));
176
+ }
177
+ /** Write a skill, or revise one of the org's own. Its name is its id, so a saved skill keeps its name. */
178
+ function Editor({ skill, may, onClose, onSaved, onDeleted, }) {
179
+ const { t } = useI18n();
180
+ const target = useTarget();
181
+ const [name, setName] = useState(skill?.name ?? '');
182
+ const [description, setDescription] = useState(skill?.description ?? '');
183
+ const [content, setContent] = useState(skill?.content ?? '');
184
+ const [working, setWorking] = useState(false);
185
+ const [error, setError] = useState('');
186
+ const [asking, setAsking] = useState(false);
187
+ const save = async () => {
188
+ setWorking(true);
189
+ setError('');
190
+ try {
191
+ const saved = await write(target, { name: name.trim(), description: description.trim(), content });
192
+ // A new skill is switched on as it is saved; a revised one keeps its switch.
193
+ if (!skill)
194
+ await toggle(target, [tool(saved.name)]);
195
+ onSaved(saved, !skill);
196
+ }
197
+ catch (e) {
198
+ setError(say(e, t));
199
+ }
200
+ finally {
201
+ setWorking(false);
202
+ }
203
+ };
204
+ return (_jsxs(Sheet, { title: skill ? skill.name : t('New skill'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [skill?.source ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('Read from {source}. The next push of that repository replaces what is saved here.', { source: skill.source }) })) : null, _jsx(Field, { label: t('Name'), hint: skill ? t('A skill keeps its name. Save under another name to make a new one.') : t('One lowercase word: letters, digits, _ or -.'), children: _jsx(Input, { value: name, onChangeText: setName, placeholder: "issue-triage", "aria-label": t('Name'), disabled: Boolean(skill) || !may, autoCapitalize: "none", borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: t('Description'), hint: t('One line. An agent reads it to decide whether it needs the skill.'), children: _jsx(Input, { value: description, onChangeText: setDescription, placeholder: t('How we triage an incoming issue'), "aria-label": t('Description'), disabled: !may, borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: "SKILL.md", hint: t('Markdown: what it is for, when to use it, and the steps.'), children: _jsx(Textarea, { value: content, onChangeText: setContent, placeholder: t('# Triage\n\n1. Read the issue…'), "aria-label": "SKILL.md", disabled: !may, rows: 14, fontFamily: "$mono", borderColor: "var(--border-strong)" }) }), error ? (_jsx(StatusBanner, { notice: { text: error, error: true } })) : !may ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: t('Only an org admin can write or delete skills.') })) : null, _jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [skill && may ? (_jsxs(Button, { size: "sm", variant: "ghost", tone: "danger", onPress: () => setAsking(true), children: [_jsx(Trash2, { size: 14 }), " ", t('Delete')] })) : null, _jsx(XStack, { flex: 1 }), _jsx(Button, { size: "sm", variant: "ghost", onPress: onClose, children: may ? t('Cancel') : t('Close') }), may ? (_jsx(Button, { size: "sm", variant: "primary", disabled: working || !name.trim() || !content.trim(), onPress: () => void save(), children: working ? t('Saving…') : t('Save') })) : null] }), skill ? (_jsx(Confirm, { title: t('Delete {name}?', { name: skill.name }), act: t('Delete'), says: t('The skill leaves your organization and every agent that names it.'), open: asking, onOpenChange: setAsking, run: async () => {
205
+ await remove(target, skill.id);
206
+ onDeleted(skill.name);
207
+ } })) : null] }));
208
+ }