@hanzo/dev 4.0.1 → 4.1.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 (369) 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 +31 -0
  61. package/dist/builder/api/git.js +47 -0
  62. package/dist/builder/api/github.d.ts +176 -0
  63. package/dist/builder/api/github.js +271 -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 +570 -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/gutter.d.ts +17 -0
  185. package/dist/builder/gutter.js +25 -0
  186. package/dist/builder/handoff.d.ts +8 -0
  187. package/dist/builder/handoff.js +22 -0
  188. package/dist/builder/host.d.ts +189 -0
  189. package/dist/builder/host.js +46 -0
  190. package/dist/builder/index.d.ts +108 -0
  191. package/dist/builder/index.js +99 -0
  192. package/dist/builder/landing.d.ts +34 -0
  193. package/dist/builder/landing.js +725 -0
  194. package/dist/builder/library.d.ts +21 -0
  195. package/dist/builder/library.js +526 -0
  196. package/dist/builder/local.d.ts +80 -0
  197. package/dist/builder/local.js +124 -0
  198. package/dist/builder/make.d.ts +10 -0
  199. package/dist/builder/make.js +120 -0
  200. package/dist/builder/markdown.d.ts +49 -0
  201. package/dist/builder/markdown.js +125 -0
  202. package/dist/builder/marks.d.ts +15 -0
  203. package/dist/builder/marks.js +18 -0
  204. package/dist/builder/merge.d.ts +223 -0
  205. package/dist/builder/merge.js +380 -0
  206. package/dist/builder/meter.d.ts +31 -0
  207. package/dist/builder/meter.js +54 -0
  208. package/dist/builder/mind.d.ts +107 -0
  209. package/dist/builder/mind.js +335 -0
  210. package/dist/builder/names.d.ts +40 -0
  211. package/dist/builder/names.js +189 -0
  212. package/dist/builder/nav.d.ts +28 -0
  213. package/dist/builder/nav.js +218 -0
  214. package/dist/builder/out.d.ts +16 -0
  215. package/dist/builder/out.js +24 -0
  216. package/dist/builder/page.d.ts +55 -0
  217. package/dist/builder/page.js +217 -0
  218. package/dist/builder/pane.d.ts +30 -0
  219. package/dist/builder/pane.js +21 -0
  220. package/dist/builder/panel.d.ts +101 -0
  221. package/dist/builder/panel.js +408 -0
  222. package/dist/builder/pdf.d.ts +139 -0
  223. package/dist/builder/pdf.js +847 -0
  224. package/dist/builder/pick.d.ts +10 -0
  225. package/dist/builder/pick.js +38 -0
  226. package/dist/builder/plain.d.ts +59 -0
  227. package/dist/builder/plain.js +209 -0
  228. package/dist/builder/plan.d.ts +63 -0
  229. package/dist/builder/plan.js +155 -0
  230. package/dist/builder/plans.d.ts +1 -0
  231. package/dist/builder/plans.js +157 -0
  232. package/dist/builder/plugin.d.ts +60 -0
  233. package/dist/builder/plugin.js +1 -0
  234. package/dist/builder/plugins/design.d.ts +8 -0
  235. package/dist/builder/plugins/design.js +71 -0
  236. package/dist/builder/plugins/index.d.ts +46 -0
  237. package/dist/builder/plugins/index.js +117 -0
  238. package/dist/builder/plugins/pdf.d.ts +18 -0
  239. package/dist/builder/plugins/pdf.js +83 -0
  240. package/dist/builder/plugins/project.d.ts +5 -0
  241. package/dist/builder/plugins/project.js +68 -0
  242. package/dist/builder/plugins/research.d.ts +24 -0
  243. package/dist/builder/plugins/research.js +147 -0
  244. package/dist/builder/plugins/sketch.d.ts +9 -0
  245. package/dist/builder/plugins/sketch.js +101 -0
  246. package/dist/builder/plugins/slides.d.ts +14 -0
  247. package/dist/builder/plugins/slides.js +55 -0
  248. package/dist/builder/plugins/template.d.ts +13 -0
  249. package/dist/builder/plugins/template.js +95 -0
  250. package/dist/builder/prefs.d.ts +29 -0
  251. package/dist/builder/prefs.js +91 -0
  252. package/dist/builder/preview-url.d.ts +47 -0
  253. package/dist/builder/preview-url.js +107 -0
  254. package/dist/builder/project.d.ts +18 -0
  255. package/dist/builder/project.js +591 -0
  256. package/dist/builder/prose.d.ts +4 -0
  257. package/dist/builder/prose.js +57 -0
  258. package/dist/builder/publish.d.ts +18 -0
  259. package/dist/builder/publish.js +141 -0
  260. package/dist/builder/question.d.ts +33 -0
  261. package/dist/builder/question.js +64 -0
  262. package/dist/builder/redesign.d.ts +32 -0
  263. package/dist/builder/redesign.js +117 -0
  264. package/dist/builder/removal.d.ts +71 -0
  265. package/dist/builder/removal.js +73 -0
  266. package/dist/builder/reply.d.ts +50 -0
  267. package/dist/builder/reply.js +196 -0
  268. package/dist/builder/roles.d.ts +10 -0
  269. package/dist/builder/roles.js +28 -0
  270. package/dist/builder/route.d.ts +85 -0
  271. package/dist/builder/route.js +126 -0
  272. package/dist/builder/run.d.ts +4 -0
  273. package/dist/builder/run.js +804 -0
  274. package/dist/builder/runmeta.d.ts +16 -0
  275. package/dist/builder/runmeta.js +69 -0
  276. package/dist/builder/say.d.ts +2 -0
  277. package/dist/builder/say.js +7 -0
  278. package/dist/builder/scheduled.d.ts +3 -0
  279. package/dist/builder/scheduled.js +328 -0
  280. package/dist/builder/section.d.ts +27 -0
  281. package/dist/builder/section.js +60 -0
  282. package/dist/builder/settings/account.d.ts +1 -0
  283. package/dist/builder/settings/account.js +111 -0
  284. package/dist/builder/settings/billing.d.ts +1 -0
  285. package/dist/builder/settings/billing.js +210 -0
  286. package/dist/builder/settings/capabilities.d.ts +1 -0
  287. package/dist/builder/settings/capabilities.js +66 -0
  288. package/dist/builder/settings/card.d.ts +31 -0
  289. package/dist/builder/settings/card.js +140 -0
  290. package/dist/builder/settings/code.d.ts +1 -0
  291. package/dist/builder/settings/code.js +70 -0
  292. package/dist/builder/settings/credits.d.ts +10 -0
  293. package/dist/builder/settings/credits.js +123 -0
  294. package/dist/builder/settings/environments.d.ts +1 -0
  295. package/dist/builder/settings/environments.js +60 -0
  296. package/dist/builder/settings/general.d.ts +1 -0
  297. package/dist/builder/settings/general.js +58 -0
  298. package/dist/builder/settings/index.d.ts +4 -0
  299. package/dist/builder/settings/index.js +25 -0
  300. package/dist/builder/settings/integrations.d.ts +8 -0
  301. package/dist/builder/settings/integrations.js +138 -0
  302. package/dist/builder/settings/keys.d.ts +1 -0
  303. package/dist/builder/settings/keys.js +114 -0
  304. package/dist/builder/settings/list.d.ts +10 -0
  305. package/dist/builder/settings/list.js +28 -0
  306. package/dist/builder/settings/machines.d.ts +4 -0
  307. package/dist/builder/settings/machines.js +243 -0
  308. package/dist/builder/settings/members.d.ts +1 -0
  309. package/dist/builder/settings/members.js +77 -0
  310. package/dist/builder/settings/memory.d.ts +1 -0
  311. package/dist/builder/settings/memory.js +62 -0
  312. package/dist/builder/settings/notifications.d.ts +1 -0
  313. package/dist/builder/settings/notifications.js +111 -0
  314. package/dist/builder/settings/plan.d.ts +17 -0
  315. package/dist/builder/settings/plan.js +131 -0
  316. package/dist/builder/settings/privacy.d.ts +1 -0
  317. package/dist/builder/settings/privacy.js +76 -0
  318. package/dist/builder/settings/sections.d.ts +16 -0
  319. package/dist/builder/settings/sections.js +34 -0
  320. package/dist/builder/settings/shared.d.ts +6 -0
  321. package/dist/builder/settings/shared.js +58 -0
  322. package/dist/builder/settings/ui.d.ts +50 -0
  323. package/dist/builder/settings/ui.js +53 -0
  324. package/dist/builder/settings/usage.d.ts +1 -0
  325. package/dist/builder/settings/usage.js +24 -0
  326. package/dist/builder/shared.d.ts +26 -0
  327. package/dist/builder/shared.js +15 -0
  328. package/dist/builder/shelf.d.ts +16 -0
  329. package/dist/builder/shelf.js +219 -0
  330. package/dist/builder/side.d.ts +40 -0
  331. package/dist/builder/side.js +208 -0
  332. package/dist/builder/site.d.ts +75 -0
  333. package/dist/builder/site.js +138 -0
  334. package/dist/builder/spend.d.ts +21 -0
  335. package/dist/builder/spend.js +80 -0
  336. package/dist/builder/standing.d.ts +36 -0
  337. package/dist/builder/standing.js +66 -0
  338. package/dist/builder/suggest.d.ts +238 -0
  339. package/dist/builder/suggest.js +463 -0
  340. package/dist/builder/suggestions.d.ts +49 -0
  341. package/dist/builder/suggestions.js +260 -0
  342. package/dist/builder/summary.d.ts +60 -0
  343. package/dist/builder/summary.js +81 -0
  344. package/dist/builder/sync.d.ts +1 -0
  345. package/dist/builder/sync.js +164 -0
  346. package/dist/builder/tabs.d.ts +85 -0
  347. package/dist/builder/tabs.js +288 -0
  348. package/dist/builder/talk.d.ts +5 -0
  349. package/dist/builder/talk.js +108 -0
  350. package/dist/builder/thread.d.ts +60 -0
  351. package/dist/builder/thread.js +302 -0
  352. package/dist/builder/tools.d.ts +22 -0
  353. package/dist/builder/tools.js +52 -0
  354. package/dist/builder/transcript.d.ts +47 -0
  355. package/dist/builder/transcript.js +108 -0
  356. package/dist/builder/voice.d.ts +8 -0
  357. package/dist/builder/voice.js +24 -0
  358. package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
  359. package/dist/core.js +1 -0
  360. package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
  361. package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
  362. package/dist/index.d.ts +2 -0
  363. package/dist/index.js +2 -1
  364. package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
  365. package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
  366. package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
  367. package/package.json +101 -11
  368. /package/{index.d.ts → dist/core.d.ts} +0 -0
  369. /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The plan, at the top of an account menu: what the account is on, and its
4
+ * meter. One block for every account menu — Dev's, the app's column, Chat's —
5
+ * so the plan reads the same wherever the menu opens.
6
+ *
7
+ * Max 20x Session 40% · Resets 5:00 PM / Today 12% / Month 62%
8
+ * Free 62% of today's free usage left · Upgrade
9
+ * Pay as you go $42.10 in credits · Add funds
10
+ *
11
+ * A plan's meter is its windows as shares and never money: credits are
12
+ * Billing's. Only an account with no plan and money in its balance sees the
13
+ * balance, because that balance is what it spends.
14
+ */
15
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
16
+ import { phrase } from '@hanzo/i18n';
17
+ import { useI18n } from '@hanzo/i18n/react';
18
+ import { money } from './api/billing.js';
19
+ import { left, rows } from './standing.js';
20
+ import { when } from './plan.js';
21
+ /** The ink a share is said in: quiet until it is close, and the one red when it is used. */
22
+ export const INK = { ok: '$soft', near: '$yellow10', limited: '$red10' };
23
+ /** A window's name, in English; drawn through `t`. */
24
+ const WINDOW = { Session: phrase('Session'), Today: phrase('Today'), Month: phrase('Month') };
25
+ /** A plan's name with its rung beside it, small: `Max` `20x`. A family's name is a name; Free and the like are words. */
26
+ export function Title({ label, size = '$3' }) {
27
+ const { t } = useI18n();
28
+ return (_jsxs(XStack, { items: "baseline", gap: "$1.5", minW: 0, "data-slot": "plan-name", children: [_jsx(SizableText, { size: size, color: "$ink", style: { fontWeight: 600 }, numberOfLines: 1, children: t(label.name) }), label.tag ? (_jsx(SizableText, { size: "$1", color: "$soft", px: "$1.5", rounded: "$2", borderWidth: 1, borderColor: "$borderColor", "data-slot": "plan-tag", children: t(label.tag) })) : null] }));
29
+ }
30
+ /** A quiet text button. */
31
+ function Act({ label, onPress }) {
32
+ return (_jsx(XStack, { render: "button", "aria-label": label, onPress: onPress, px: "$2", py: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, cursor: "pointer", shrink: 0, children: _jsx(SizableText, { size: "$1", color: "$ink", textDecorationLine: "underline", children: label }) }));
33
+ }
34
+ /** The standing, drawn: what `Meter` shows once it has read. */
35
+ export function Reading({ s, onPlans, onBilling, now }) {
36
+ const { t } = useI18n();
37
+ const windows = s.kind === 'plan' ? rows(s.limits, now, t) : [];
38
+ const share = s.kind === 'free' ? left(s.allowance) : null;
39
+ const resets = s.allowance ? when(s.allowance.resets, now) : '';
40
+ return (_jsxs(YStack, { px: "$2", py: "$1.5", gap: "$1", "data-slot": "meter", "data-kind": s.kind, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, children: [_jsx(XStack, { flex: 1, minW: 0, children: s.label ? _jsx(Title, { label: s.label }) : null }), s.kind === 'free' ? _jsx(Act, { label: t('Upgrade'), onPress: onPlans }) : s.kind === 'credits' ? _jsx(Act, { label: t('Add funds'), onPress: onBilling }) : null] }), windows.map((w) => (_jsxs(XStack, { items: "baseline", gap: "$2", "data-slot": "meter-window", "data-state": w.state, children: [_jsx(SizableText, { size: "$1", color: "$soft", width: 56, shrink: 0, children: t(WINDOW[w.name]) }), _jsxs(SizableText, { size: "$1", color: INK[w.state], style: { fontVariantNumeric: 'tabular-nums' }, shrink: 0, children: [w.percent, "%"] }), _jsx(SizableText, { size: "$1", color: "$soft", flex: 1, minW: 0, numberOfLines: 1, text: "right", children: w.resets })] }, w.name))), s.kind === 'free' && share !== null ? (_jsx(SizableText, { size: "$1", color: share === 0 ? '$red10' : '$soft', "data-slot": "meter-free", children: resets
41
+ ? `${t('{n}% of today’s free usage left', { n: share })} · ${t('Resets {time}', { time: resets })}`
42
+ : t('{n}% of today’s free usage left', { n: share }) })) : null, s.kind === 'credits' && s.balance !== null ? (_jsx(SizableText, { size: "$1", color: "$soft", "data-slot": "meter-balance", children: t('{amount} in credits', { amount: money(s.balance) }) })) : null] }));
43
+ }
44
+ /**
45
+ * The block an account menu leads with: `read` is `useStanding`, asked while
46
+ * the menu is open. `onPlans` opens the plans and `onBilling` the page credits
47
+ * live on; the host says where each is.
48
+ */
49
+ export function Meter({ read, onPlans, onBilling }) {
50
+ const { t } = useI18n();
51
+ if (read.value)
52
+ return _jsx(Reading, { s: read.value, onPlans: onPlans, onBilling: onBilling });
53
+ return (_jsx(SizableText, { size: "$1", color: "$soft", px: "$2", py: "$1.5", "data-slot": "meter", children: read.error ? t('Your plan could not be read.') : t('Reading your plan…') }));
54
+ }
@@ -0,0 +1,107 @@
1
+ import type { Modes } from '@hanzo/ui/chat';
2
+ import { type Target } from './api/call.ts';
3
+ import { type Model } from './api/models.ts';
4
+ export type Effort = 'auto' | 'low' | 'high' | 'max';
5
+ /** The efforts a Dev run offers, in order: Auto (medium), Fast (low), High, and Max. Marked English, drawn through `t`. */
6
+ export declare const EFFORTS: {
7
+ id: "auto" | "high" | "low" | "max";
8
+ label: string;
9
+ note: string;
10
+ }[];
11
+ /** The effort a coding run names (apps/coding takes low, medium or high): low for Fast, medium for Auto, high for High/Max. */
12
+ export declare const level: (effort: Effort) => 'low' | 'medium' | 'high';
13
+ /** What a person chose: the model (Enso routes) and the effort. */
14
+ export interface Choice {
15
+ model: string;
16
+ effort: Effort;
17
+ }
18
+ export declare const FIRST: Choice;
19
+ /** Whether a plan grants only Enso Auto. An unknown plan is not taken for Free. */
20
+ export declare const isFree: (plan: string | null | undefined) => boolean;
21
+ /** Whether third-party cloud models are enabled in Settings → Preferences (off by default). */
22
+ export declare function allowThirdPartyModels(): boolean;
23
+ /** The kept choice, Enso and Auto where nothing is kept. Stable while the stored text is. Low and Medium, offered once, read as Auto. */
24
+ export declare function kept(): Choice;
25
+ /** Keep a change, in this browser, for every surface that reads it. */
26
+ export declare function keep(patch: Partial<Choice>): void;
27
+ /** The kept choice and the way to change it. The server and the first render read the default. */
28
+ export declare function useChoice(): readonly [Choice, (patch: Partial<Choice>) => void];
29
+ /** A model's name as the catalog spells it; Enso Auto for the router. */
30
+ export declare function nameOf(model: string, catalog: readonly Model[]): string;
31
+ /** An id said as a name: its last path part, each word capitalised (`enso-flash` → Enso Flash). */
32
+ export declare function spelled(id: string): string;
33
+ /** The ids that are the router under another name: the picker's Enso row stands for all of them. */
34
+ export declare const ROUTER_IDS: ReadonlySet<string>;
35
+ /** `GET /v1/models` for a target, asked once and shared; a refusal is not kept, so the next ask goes again. */
36
+ export declare function catalog(t: Target): Promise<Model[]>;
37
+ /** The catalog as a chooser draws it, and the list a kept pick is judged against. */
38
+ export interface Catalog {
39
+ /** What the chooser offers: the list read, else the last one this browser kept, else Enso alone. */
40
+ models: Model[];
41
+ /** What was read, for a pick to stand on: empty when nothing was, so a kept pick stands. */
42
+ list: Model[];
43
+ loading: boolean;
44
+ /** Why there is no list to offer, in a reader's words; null when there is one. */
45
+ error: string | null;
46
+ /** A list shown from before, because this read failed. */
47
+ note: string;
48
+ }
49
+ /**
50
+ * The platform's catalog, as a hook: what was read already is there on the
51
+ * first render. The gateway answers 429 once the org's quota is spent, and a
52
+ * list that vanishes then leaves nothing to choose from, so a failed read shows
53
+ * the last list this browser kept, with a note; with none kept, Enso alone, and
54
+ * the reason in the chooser — never the platform's own words.
55
+ */
56
+ export declare function useCatalog(t: Target): Catalog;
57
+ /** Whether `model` is one this plan may send: on Free, Enso Auto alone (commerce's `allowedModels`). */
58
+ export declare function grants(free: boolean, model: string): boolean;
59
+ /**
60
+ * Whether the plan and the prepaid balance (cents, null where unknown) let `id` be
61
+ * sent: Hanzo's own models follow the plan; another maker's are paid from the balance
62
+ * on any plan, Free included.
63
+ */
64
+ export declare function sendable(free: boolean, models: readonly Model[], cents: number | null, id: string): boolean;
65
+ /** The effort as the composer reads it: the one in force, its list, and the way to change it. */
66
+ export declare const pacing: (m: Pick<Mind, 'effort' | 'pace'>) => Modes<Effort>;
67
+ /** The chip's whole state: the catalog, what answers next, and how to change either. */
68
+ export interface Mind {
69
+ model: string;
70
+ effort: Effort;
71
+ models: Model[];
72
+ loading: boolean;
73
+ error: string | null;
74
+ /** A list shown from before, because this read failed. */
75
+ note: string;
76
+ /** The plan grants only Enso Auto: anything else is an upgrade, never a pick. */
77
+ free: boolean;
78
+ /** A premium pick holds for this screen; any other is kept. */
79
+ pick: (id: string) => void;
80
+ pace: (effort: Effort) => void;
81
+ /**
82
+ * Another maker's models are paid from the prepaid balance on any plan, so on Free
83
+ * they are not an upgrade. Present where the host can send a person to the top-up
84
+ * and the balance was read: whether the balance can pay for a model.
85
+ */
86
+ funded?: (id: string) => boolean;
87
+ /** The balance, as the billing API states it, whole cents written as dollars. */
88
+ balance?: string;
89
+ /** The way to the top-up, given the model that was chosen if one was. */
90
+ topUp?: (id?: string) => void;
91
+ }
92
+ /** What a picker needs to sell another maker's models from the balance: whether it can pay, what it holds, and the way to top it up. */
93
+ export interface Funds {
94
+ /** The balance in cents; null until read, and where it could not be. */
95
+ cents: number | null;
96
+ funded?: (id: string) => boolean;
97
+ balance?: string;
98
+ topUp?: (id?: string) => void;
99
+ }
100
+ /** The prepaid balance for a picker, where the host offers a top-up (`Host.topUp`); with none, no funds are claimed. */
101
+ export declare function useFunds(t: Target, topUp?: (id?: string) => void): Funds;
102
+ /**
103
+ * The model and effort for the plan `plan` names (`GET /v1/ai/limits` `plan`).
104
+ * On Free the model is Enso Auto, and a kept pick of any other is set aside
105
+ * rather than sent — it comes back once the plan grants it.
106
+ */
107
+ export declare function useMind(t: Target, plan?: string | null, topUp?: (id?: string) => void): Mind;
@@ -0,0 +1,335 @@
1
+ /**
2
+ * Which model answers, and how hard it thinks: one store for Chat and Dev, and
3
+ * the catalog both offer. The composer (@hanzo/ui/chat) changes it.
4
+ *
5
+ * GET /v1/models the catalog, read once per platform and shared
6
+ * hanzo.mind the person's choice, in this browser: {model, effort}
7
+ *
8
+ * The effort is always under the composer; the model chip only where the person
9
+ * turned it on (Settings → Appearance › Model in composer). Enso
10
+ * routes every ask — a message in Chat, a step in Dev — so naming a model is an
11
+ * override, and the panel says so before it offers one. A premium model is
12
+ * picked for the screen it was picked on (`usePick`) and never kept, so the next
13
+ * conversation or run opens on what was kept, Enso until something else is.
14
+ *
15
+ * The efforts are Auto, High and Max, Chat's words (Hanzo's
16
+ * ThinkingEffort), Auto until another is chosen. A coding run takes low, medium
17
+ * or high (apps/coding `efforts`), so `level` is what a run names: medium for
18
+ * Auto, what a run took before anyone chose, and high for the rest, the most it
19
+ * takes. Auto names one rather than none, because a run that names none takes
20
+ * an effort the person saved to their account once (apps/coding start.go) and
21
+ * no screen shows any more.
22
+ */
23
+ import { phrase } from '@hanzo/i18n';
24
+ import { EFFORTS as EVERY } from '@hanzo/ui/chat/pure';
25
+ import { parseModels, thirdParty } from '@hanzo/ui/models/catalog';
26
+ import { useEffect, useState, useSyncExternalStore } from 'react';
27
+ import { prepaid as readPrepaid } from './api/billing.js';
28
+ import { Refusal } from './api/call.js';
29
+ import { ENSO, models as read } from './api/models.js';
30
+ import { usePick } from './pick.js';
31
+ const EFFORT_LABELS = {
32
+ low: phrase('Fast'),
33
+ };
34
+ const EFFORT_NOTES = {
35
+ auto: phrase('Matches thinking depth to the complexity of each prompt.'),
36
+ low: phrase('Fastest edits and replies for straightforward coding tasks.'),
37
+ high: phrase('Spends extra time reasoning through multi-step tasks and code.'),
38
+ max: phrase('Deepest reasoning and verification for complex architecture.'),
39
+ };
40
+ /** The efforts a Dev run offers, in order: Auto (medium), Fast (low), High, and Max. Marked English, drawn through `t`. */
41
+ export const EFFORTS = ['auto', 'low', 'high', 'max'].map((id) => {
42
+ const base = EVERY.find((e) => e.id === id);
43
+ return {
44
+ id,
45
+ label: EFFORT_LABELS[id] ?? base?.label ?? id,
46
+ note: EFFORT_NOTES[id] ?? base?.note ?? '',
47
+ };
48
+ });
49
+ /** The effort a coding run names (apps/coding takes low, medium or high): low for Fast, medium for Auto, high for High/Max. */
50
+ export const level = (effort) => effort === 'low' ? 'low' : effort === 'auto' ? 'medium' : 'high';
51
+ export const FIRST = { model: ENSO, effort: 'auto' };
52
+ /** Whether a plan grants only Enso Auto. An unknown plan is not taken for Free. */
53
+ export const isFree = (plan) => plan === 'free';
54
+ const KEY = 'hanzo.mind';
55
+ const CHANGE = 'hanzo:mind';
56
+ const PREFS_KEY = 'hanzo.chat.preferences';
57
+ const PREFS_EVENT = 'hanzo:chat:preferences';
58
+ /** Whether third-party cloud models are enabled in Settings → Preferences (off by default). */
59
+ export function allowThirdPartyModels() {
60
+ try {
61
+ const v = JSON.parse(store()?.getItem(PREFS_KEY) ?? 'null');
62
+ return v?.thirdPartyChosen ? Boolean(v.allowThirdPartyModels) : v?.allowThirdPartyModels === true;
63
+ }
64
+ catch {
65
+ return false;
66
+ }
67
+ }
68
+ function useAllowThirdPartyModels() {
69
+ const [allowed, setAllowed] = useState(allowThirdPartyModels);
70
+ useEffect(() => {
71
+ const sync = () => setAllowed(allowThirdPartyModels());
72
+ window.addEventListener(PREFS_EVENT, sync);
73
+ window.addEventListener('storage', sync);
74
+ return () => {
75
+ window.removeEventListener(PREFS_EVENT, sync);
76
+ window.removeEventListener('storage', sync);
77
+ };
78
+ }, []);
79
+ return allowed;
80
+ }
81
+ /** An effort kept, read back: one the ladder still offers, XHigh (which Max replaced) as Max, else Auto. */
82
+ const effortOf = (v) => (v === 'xhigh' ? 'max' : EFFORTS.some((e) => e.id === v) ? v : FIRST.effort);
83
+ /** The store, or null where the browser gives none (a server render, blocked site data). */
84
+ function store() {
85
+ try {
86
+ return typeof window === 'undefined' ? null : window.localStorage;
87
+ }
88
+ catch {
89
+ return null;
90
+ }
91
+ }
92
+ let raw;
93
+ let held = FIRST;
94
+ /** A choice the browser would not store, held for the page. */
95
+ let memo = null;
96
+ /** The kept choice, Enso and Auto where nothing is kept. Stable while the stored text is. Low and Medium, offered once, read as Auto. */
97
+ export function kept() {
98
+ if (memo)
99
+ return memo;
100
+ let now = null;
101
+ try {
102
+ now = store()?.getItem(KEY) ?? null;
103
+ }
104
+ catch {
105
+ now = null;
106
+ }
107
+ if (now === raw)
108
+ return held;
109
+ raw = now;
110
+ try {
111
+ const v = JSON.parse(now ?? 'null');
112
+ held = { model: typeof v?.model === 'string' && v.model.trim() ? v.model : FIRST.model, effort: effortOf(v?.effort) };
113
+ }
114
+ catch {
115
+ held = FIRST;
116
+ }
117
+ return held;
118
+ }
119
+ /** Keep a change, in this browser, for every surface that reads it. */
120
+ export function keep(patch) {
121
+ const was = kept();
122
+ const next = { ...was, ...patch, effort: patch.effort === undefined ? was.effort : effortOf(patch.effort) };
123
+ try {
124
+ store()?.setItem(KEY, JSON.stringify(next));
125
+ memo = null;
126
+ }
127
+ catch {
128
+ // A browser that refuses storage keeps the choice for this page.
129
+ memo = next;
130
+ }
131
+ if (typeof window !== 'undefined')
132
+ window.dispatchEvent(new Event(CHANGE));
133
+ }
134
+ function subscribe(change) {
135
+ window.addEventListener(CHANGE, change);
136
+ window.addEventListener('storage', change);
137
+ return () => {
138
+ window.removeEventListener(CHANGE, change);
139
+ window.removeEventListener('storage', change);
140
+ };
141
+ }
142
+ /** The kept choice and the way to change it. The server and the first render read the default. */
143
+ export function useChoice() {
144
+ return [useSyncExternalStore(subscribe, kept, () => FIRST), keep];
145
+ }
146
+ /** A model's name as the catalog spells it; Enso Auto for the router. */
147
+ export function nameOf(model, catalog) {
148
+ if (model === ENSO)
149
+ return 'Enso Auto';
150
+ const row = catalog.find((m) => m.id === model);
151
+ return row?.name ?? spelled(model);
152
+ }
153
+ /** An id said as a name: its last path part, each word capitalised (`enso-flash` → Enso Flash). */
154
+ export function spelled(id) {
155
+ const tail = id.split('/').pop() ?? id;
156
+ return tail
157
+ .split(/[-_]/)
158
+ .filter(Boolean)
159
+ .map((w) => w[0].toUpperCase() + w.slice(1))
160
+ .join(' ');
161
+ }
162
+ /** The ids that are the router under another name: the picker's Enso row stands for all of them. */
163
+ export const ROUTER_IDS = new Set([ENSO, 'enso', 'hanzo/enso']);
164
+ // The catalog, once per platform for the page: Chat and Dev read the same list.
165
+ const catalogs = new Map();
166
+ const settled = new Map();
167
+ /** Where this browser keeps the last list it read. */
168
+ const LAST = 'hanzo.build.models';
169
+ /** The router alone: what a chooser offers before any list was ever read, so it reads "Enso Auto" and not an id. */
170
+ const ROUTER = parseModels([{ id: ENSO, name: 'Enso Auto', family: 'enso', class: 'ours' }]);
171
+ /** The last list this browser read, or none. */
172
+ function last() {
173
+ try {
174
+ return parseModels(JSON.parse(store()?.getItem(LAST) ?? 'null'));
175
+ }
176
+ catch {
177
+ return [];
178
+ }
179
+ }
180
+ /** Which catalog a target reads: the platform, and whether anyone is signed in. */
181
+ const shelf = (t) => `${t.api}|${t.token() ? 'in' : 'out'}`;
182
+ /** `GET /v1/models` for a target, asked once and shared; a refusal is not kept, so the next ask goes again. */
183
+ export function catalog(t) {
184
+ const at = shelf(t);
185
+ let ask = catalogs.get(at);
186
+ if (!ask) {
187
+ ask = read(t).then((models) => {
188
+ settled.set(at, models);
189
+ try {
190
+ if (models.length)
191
+ store()?.setItem(LAST, JSON.stringify(models));
192
+ }
193
+ catch {
194
+ // The next page reads the list again.
195
+ }
196
+ return models;
197
+ });
198
+ catalogs.set(at, ask);
199
+ ask.catch(() => catalogs.delete(at));
200
+ }
201
+ return ask;
202
+ }
203
+ /**
204
+ * The platform's catalog, as a hook: what was read already is there on the
205
+ * first render. The gateway answers 429 once the org's quota is spent, and a
206
+ * list that vanishes then leaves nothing to choose from, so a failed read shows
207
+ * the last list this browser kept, with a note; with none kept, Enso alone, and
208
+ * the reason in the chooser — never the platform's own words.
209
+ */
210
+ export function useCatalog(t) {
211
+ const at = shelf(t);
212
+ const [state, setState] = useState(() => settled.has(at) ? { at, models: settled.get(at), error: null } : null);
213
+ useEffect(() => {
214
+ let live = true;
215
+ catalog(t).then((models) => live && setState({ at, models, error: null }), (e) => live && setState({ at, models: [], error: e }));
216
+ return () => {
217
+ live = false;
218
+ };
219
+ // The target is read through `at`: the origin and whether anyone is signed in.
220
+ // eslint-disable-next-line react-hooks/exhaustive-deps
221
+ }, [at]);
222
+ const now = state?.at === at ? state : settled.has(at) ? { at, models: settled.get(at), error: null } : null;
223
+ if (!now?.error)
224
+ return { models: now?.models ?? [], list: now?.models ?? [], loading: !now, error: null, note: '' };
225
+ const kept = last();
226
+ if (kept.length)
227
+ return { models: kept, list: kept, loading: false, error: null, note: 'The model list could not be refreshed; these are the models as last read.' };
228
+ const spent = now.error instanceof Refusal && now.error.status === 429;
229
+ return {
230
+ models: ROUTER,
231
+ list: [],
232
+ loading: false,
233
+ error: spent ? 'The model list is resting: this organization’s quota is spent.' : 'The model list could not be read right now.',
234
+ note: '',
235
+ };
236
+ }
237
+ /** Whether `model` is one this plan may send: on Free, Enso Auto alone (commerce's `allowedModels`). */
238
+ export function grants(free, model) {
239
+ return !free || model === ENSO;
240
+ }
241
+ /** Whole cents as dollars. */
242
+ const dollars = (cents) => `$${(cents / 100).toFixed(2)}`;
243
+ /**
244
+ * Whether the plan and the prepaid balance (cents, null where unknown) let `id` be
245
+ * sent: Hanzo's own models follow the plan; another maker's are paid from the balance
246
+ * on any plan, Free included.
247
+ */
248
+ export function sendable(free, models, cents, id) {
249
+ const row = models.find((m) => m.id === id);
250
+ return grants(free, id) || Boolean(row && thirdParty(row) && cents !== null && cents > 0);
251
+ }
252
+ /** The effort as the composer reads it: the one in force, its list, and the way to change it. */
253
+ export const pacing = (m) => ({ value: m.effort, set: m.pace, items: EFFORTS });
254
+ /** The prepaid balance in cents that can pay for another maker's models, for a signed-in target, read once; null until it is, and where the API does not say. */
255
+ function useBalance(t, on) {
256
+ const [cents, set] = useState(null);
257
+ useEffect(() => {
258
+ if (!on || !t.token())
259
+ return;
260
+ let live = true;
261
+ readPrepaid(t).then((n) => live && set(n), () => live && set(null));
262
+ return () => {
263
+ live = false;
264
+ };
265
+ // The target is rebuilt each render; what it names is the key.
266
+ }, [on, t.api, t.org]); // eslint-disable-line react-hooks/exhaustive-deps
267
+ return cents;
268
+ }
269
+ /** The prepaid balance for a picker, where the host offers a top-up (`Host.topUp`); with none, no funds are claimed. */
270
+ export function useFunds(t, topUp) {
271
+ const cents = useBalance(t, topUp !== undefined);
272
+ if (topUp === undefined || cents === null)
273
+ return { cents };
274
+ return { cents, funded: (_id) => cents > 0, balance: dollars(cents), topUp };
275
+ }
276
+ /** The model a top-up returned to, named in the address (`?model=`); read once, and left out of the address. */
277
+ function returned() {
278
+ if (typeof window === 'undefined' || !window.location)
279
+ return '';
280
+ const url = new URL(window.location.href);
281
+ return url.searchParams.get('model') ?? '';
282
+ }
283
+ function settleReturn() {
284
+ if (typeof window === 'undefined' || !window.location)
285
+ return;
286
+ const url = new URL(window.location.href);
287
+ if (!url.searchParams.has('model'))
288
+ return;
289
+ url.searchParams.delete('model');
290
+ window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`);
291
+ }
292
+ /**
293
+ * The model and effort for the plan `plan` names (`GET /v1/ai/limits` `plan`).
294
+ * On Free the model is Enso Auto, and a kept pick of any other is set aside
295
+ * rather than sent — it comes back once the plan grants it.
296
+ */
297
+ export function useMind(t, plan, topUp) {
298
+ const [choice, change] = useChoice();
299
+ const { models, list, loading, error, note } = useCatalog(t);
300
+ const allowThirdParty = useAllowThirdPartyModels();
301
+ const free = isFree(plan);
302
+ const [picked, pick] = usePick(choice.model, (id) => change({ model: id }), list);
303
+ // Another maker's model is paid from the balance on any plan; Hanzo's own follow the plan.
304
+ const funds = useFunds(t, topUp);
305
+ const cents = funds.cents;
306
+ const may = (id) => sendable(free, models, cents, id);
307
+ const model = may(picked) ? picked : ENSO;
308
+ const listed = allowThirdParty ? models : models.filter((m) => !thirdParty(m) || m.id === model);
309
+ // A top-up returns to this address with the model it was for: pick it once the balance can pay.
310
+ const [back] = useState(returned);
311
+ useEffect(() => {
312
+ if (!back || !models.length || cents === null)
313
+ return;
314
+ if (may(back))
315
+ pick(back);
316
+ settleReturn();
317
+ // Once, when the catalog and the balance are both here.
318
+ // eslint-disable-next-line react-hooks/exhaustive-deps
319
+ }, [models.length, cents]);
320
+ return {
321
+ model,
322
+ effort: choice.effort,
323
+ models: listed,
324
+ loading,
325
+ error,
326
+ note,
327
+ free,
328
+ pick: (id) => {
329
+ if (may(id))
330
+ pick(id);
331
+ },
332
+ pace: (effort) => change({ effort }),
333
+ ...(funds.funded ? { funded: funds.funded, balance: funds.balance, topUp: funds.topUp } : {}),
334
+ };
335
+ }
@@ -0,0 +1,40 @@
1
+ import type { Target } from './api/call.ts';
2
+ import { NAME_MAX, tidyName } from './api/pref.ts';
3
+ export { NAME_MAX, tidyName };
4
+ /** Where this browser keeps its copy of the names. */
5
+ export declare const NAMES_KEY = "hanzo.device.names";
6
+ export type Names = Readonly<Record<string, string>>;
7
+ /** The key a device's name is kept under: the first of its hostname, label and id that says something, without a local-network suffix, lowercased. */
8
+ export declare function deviceKey(...parts: (string | null | undefined)[]): string;
9
+ /** The key a shell's name is kept under: its device's key, then its own name. */
10
+ export declare function shellKey(device: string, shell: string): string;
11
+ /** The names from a stored value, dropping what is not a name. */
12
+ export declare function names(raw: unknown): Record<string, string>;
13
+ /**
14
+ * A hostname as a person says it.
15
+ *
16
+ * Alexs-MacBook-Pro.local → Alex's MacBook Pro (macOS drops the apostrophe from "Alex's MacBook Pro")
17
+ * alexs-mbp-2.local → Alex's MacBook Pro (a "-2" is macOS avoiding a name already on the network)
18
+ * MacBook-Air.local → MacBook Air
19
+ * studio-Mac-mini → Studio Mac mini
20
+ * DESKTOP-4F7K2QX → Windows PC (Windows' own made-up name)
21
+ * spark-dgx.lan → spark-dgx (a name someone chose stays theirs)
22
+ */
23
+ export declare function friendly(host: string): string;
24
+ /** The names as this page holds them now. */
25
+ export declare function heldNames(): Names;
26
+ /** The name a person gave the device or shell under `key`, if any. */
27
+ export declare function nameOf(key: string): string | undefined;
28
+ /**
29
+ * Name the device or shell under `key` (an empty name clears it, back to its own).
30
+ * With a `target`, the names are saved on the account too; that save failing
31
+ * keeps the name in this browser.
32
+ */
33
+ export declare function rename(key: string, name: string, target?: Target | null): Promise<void>;
34
+ /**
35
+ * The names a person gave their devices and shells, kept current: a rename on
36
+ * any surface of this page redraws every one that reads them. With a signed-in
37
+ * `target`, the account's names are read once per page and win over this
38
+ * browser's copy.
39
+ */
40
+ export declare function useDeviceNames(target?: Target | null): Names;