@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,17 @@
1
+ /**
2
+ * The models a run can be routed through, from the platform's own catalog.
3
+ *
4
+ * GET /v1/models → {data: [{id, class, family, …}]}
5
+ *
6
+ * Read by `@hanzo/ui/models` `parseModels`, so a model's class and family are
7
+ * the gateway's fields, never guessed from its id. `ENSO` is the router: it
8
+ * picks a model per step, which is why it is the default, and a run that names
9
+ * it names no model at all.
10
+ */
11
+ import { type ModelCatalogEntry } from '@hanzo/ui/models/catalog';
12
+ import { type Target } from './call.ts';
13
+ export { ENSO } from '@hanzo/ui/models/catalog';
14
+ export type Model = ModelCatalogEntry;
15
+ export declare function models(t: Target): Promise<Model[]>;
16
+ /** The payer's plan usage, as `GET /v1/ai/limits` answers it: what a picker marks paused. */
17
+ export declare function limits(t: Target, signal?: AbortSignal): Promise<unknown>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The models a run can be routed through, from the platform's own catalog.
3
+ *
4
+ * GET /v1/models → {data: [{id, class, family, …}]}
5
+ *
6
+ * Read by `@hanzo/ui/models` `parseModels`, so a model's class and family are
7
+ * the gateway's fields, never guessed from its id. `ENSO` is the router: it
8
+ * picks a model per step, which is why it is the default, and a run that names
9
+ * it names no model at all.
10
+ */
11
+ import { parseModels } from '@hanzo/ui/models/catalog';
12
+ import { call } from './call.js';
13
+ export { ENSO } from '@hanzo/ui/models/catalog';
14
+ export async function models(t) {
15
+ return parseModels(await call(t, 'GET', '/v1/models'));
16
+ }
17
+ /** The payer's plan usage, as `GET /v1/ai/limits` answers it: what a picker marks paused. */
18
+ export function limits(t, signal) {
19
+ return call(t, 'GET', '/v1/ai/limits', undefined, { signal });
20
+ }
@@ -0,0 +1,32 @@
1
+ import type { Say } from '@hanzo/i18n/react';
2
+ import { type Names } from '../names.ts';
3
+ import type { Target } from './call.ts';
4
+ export interface Place {
5
+ /** `tgt_…`, or '' for the cloud workspace. */
6
+ id: string;
7
+ label: string;
8
+ /** laptop | gpu | cloud | … as the platform names it; 'sandbox' for the cloud workspace. */
9
+ kind: string;
10
+ /** online | offline | draining | not seen yet, as machines.ts `state` reads it; the cloud workspace is always online. */
11
+ status: string;
12
+ /** "10 vCPU / 122G / 1× GB10", when the machine reported one. */
13
+ capacity: string;
14
+ /** The hostname its runs report, or '' (the cloud workspace, or a machine addressed by id only). */
15
+ host?: string;
16
+ /** A machine's folders its owner lets a run from the web work in (machines.ts); none elsewhere. */
17
+ folders?: string[];
18
+ }
19
+ /** The cloud workspace, named in English and marked (`phrase`): a screen draws its label through `t`. */
20
+ export declare const SANDBOX: Place;
21
+ export declare function places(t: Target): Promise<Place[]>;
22
+ /** A place as a person reads it: the name they gave the machine (`names`, from `useDeviceNames`), else its own as a person says it. */
23
+ export declare function displayPlace(p: Place, opts?: {
24
+ devMode?: boolean;
25
+ say?: Say;
26
+ names?: Names;
27
+ }): {
28
+ title: string;
29
+ detail?: string;
30
+ };
31
+ /** Whether a run sent here now would be taken. */
32
+ export declare const ready: (p: Place) => boolean;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Where a run can run: the platform's cloud workspace, or one of the org's machines.
3
+ *
4
+ * GET /v1/agent/targets → {targets: [...]}, newest first (machines.ts)
5
+ *
6
+ * The cloud workspace is not a row the platform lists — it is what a run gets when it
7
+ * names no target — so it is the first place here and carries no id. A machine
8
+ * can take a run only while it is online.
9
+ */
10
+ import { phrase } from '@hanzo/i18n';
11
+ import { formatDeviceLabel } from '../dev-mode.js';
12
+ import { deviceKey } from '../names.js';
13
+ import { english } from '../say.js';
14
+ import { machines, state } from './machines.js';
15
+ /** The cloud workspace, named in English and marked (`phrase`): a screen draws its label through `t`. */
16
+ export const SANDBOX = { id: '', label: phrase('Hanzo sandbox'), kind: 'sandbox', status: 'online', capacity: '' };
17
+ export async function places(t) {
18
+ const list = await machines(t);
19
+ return [SANDBOX, ...list.map((m) => ({ id: m.id, label: m.label, kind: m.kind, status: state(m), capacity: m.capacity, ...(m.host ? { host: m.host } : {}), ...(m.folders.length ? { folders: m.folders } : {}) }))];
20
+ }
21
+ /** A place as a person reads it: the name they gave the machine (`names`, from `useDeviceNames`), else its own as a person says it. */
22
+ export function displayPlace(p, opts) {
23
+ const say = opts?.say ?? english;
24
+ if (!p.id)
25
+ return opts?.devMode ? { title: 'Cloud' } : { title: say('Auto (Cloud)'), detail: say('Runs automatically in your Hanzo cloud workspace') };
26
+ return formatDeviceLabel(p.label, { hardware: p.capacity, host: p.host, name: opts?.names?.[deviceKey(p.host, p.label, p.id)], devMode: opts?.devMode, say });
27
+ }
28
+ /** Whether a run sent here now would be taken. */
29
+ export const ready = (p) => p.status === 'online';
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Adding a repository to a project, which is how a project is published.
3
+ *
4
+ * POST /v1/platform/apps {repo, ref, name, partOf, mode, tag?}
5
+ * → 202 {app, build?: {id, job, image, status}, declaration: {mode, ref, review, live, …}, notice?}
6
+ * GET /v1/platform/builds → {builds: [{id, repo, commit, status, startedAt, duration}]}
7
+ *
8
+ * The declaration is a values file in universe. `branch` (the default) opens a
9
+ * review and deploys nothing; `commit` writes main and CD applies it — and it
10
+ * refuses to name an image that is not built yet, so publishing to main is two
11
+ * calls: build on a branch, then commit that tag once the build is green. An
12
+ * org admin gets both; anyone else gets the review link.
13
+ *
14
+ * A repository in the org's own code workspace is its project's site instead:
15
+ * built in a sandbox and served at the project's address when the build
16
+ * finishes. That answer is `declaration.live` with a `notice` saying so, and no
17
+ * review; its build is on the same board, building, succeeded or failed.
18
+ */
19
+ import { type Target } from './call.ts';
20
+ export interface Declare {
21
+ /** The https clone URL. */
22
+ repo: string;
23
+ /** Branch, tag or sha to build. */
24
+ ref: string;
25
+ /** The app's name: a DNS-1123 label. */
26
+ name: string;
27
+ /** The project it joins. */
28
+ project: string;
29
+ mode: 'branch' | 'commit';
30
+ /** Release an image an earlier call built, instead of building. */
31
+ tag?: string;
32
+ }
33
+ export interface Declared {
34
+ build: {
35
+ id: string;
36
+ job: string;
37
+ image: string;
38
+ status: string;
39
+ } | null;
40
+ mode: string;
41
+ /** Where the declaration landed: main for a commit, the review branch otherwise. */
42
+ ref: string;
43
+ /** The pull request to open for a branch write, or ''. */
44
+ review: string;
45
+ /** Whether anything can deploy from this write. */
46
+ live: boolean;
47
+ /** Verified https live host URLs declared on the app, if returned by the platform (#365). */
48
+ hosts: string[];
49
+ /** What the platform says of this write in a sentence, or ''. */
50
+ notice: string;
51
+ }
52
+ export interface Build {
53
+ id: string;
54
+ repo: string;
55
+ commit: string;
56
+ status: string;
57
+ startedAt: string;
58
+ duration: string;
59
+ }
60
+ /** A DNS-1123 label from anything: what an app may be named. */
61
+ export declare function label(s: string): string;
62
+ /** An https address, or '' — a review link is shown as a link only when it is one. */
63
+ export declare const https: (url: string) => string;
64
+ export declare function body(d: Declare): Record<string, string>;
65
+ export declare function declare(t: Target, d: Declare): Promise<Declared>;
66
+ export declare function builds(t: Target): Promise<Build[]>;
67
+ /** The clone URL for a GitHub repository. */
68
+ export declare const clone: (fullName: string) => string;
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Adding a repository to a project, which is how a project is published.
3
+ *
4
+ * POST /v1/platform/apps {repo, ref, name, partOf, mode, tag?}
5
+ * → 202 {app, build?: {id, job, image, status}, declaration: {mode, ref, review, live, …}, notice?}
6
+ * GET /v1/platform/builds → {builds: [{id, repo, commit, status, startedAt, duration}]}
7
+ *
8
+ * The declaration is a values file in universe. `branch` (the default) opens a
9
+ * review and deploys nothing; `commit` writes main and CD applies it — and it
10
+ * refuses to name an image that is not built yet, so publishing to main is two
11
+ * calls: build on a branch, then commit that tag once the build is green. An
12
+ * org admin gets both; anyone else gets the review link.
13
+ *
14
+ * A repository in the org's own code workspace is its project's site instead:
15
+ * built in a sandbox and served at the project's address when the build
16
+ * finishes. That answer is `declaration.live` with a `notice` saying so, and no
17
+ * review; its build is on the same board, building, succeeded or failed.
18
+ */
19
+ import { call } from './call.js';
20
+ const str = (v) => (typeof v === 'string' ? v : '');
21
+ const obj = (v) => v && typeof v === 'object' ? v : {};
22
+ /** A DNS-1123 label from anything: what an app may be named. */
23
+ export function label(s) {
24
+ const out = s
25
+ .toLowerCase()
26
+ .replace(/[^a-z0-9-]+/g, '-')
27
+ .replace(/-+/g, '-')
28
+ .replace(/^-+|-+$/g, '')
29
+ .slice(0, 63)
30
+ .replace(/-+$/g, '');
31
+ return out || 'app';
32
+ }
33
+ /** An https address, or '' — a review link is shown as a link only when it is one. */
34
+ export const https = (url) => (/^https:\/\/[^\s]+$/.test(url) ? url : '');
35
+ export function body(d) {
36
+ const out = {
37
+ repo: d.repo,
38
+ ref: d.ref || 'main',
39
+ name: label(d.name),
40
+ partOf: label(d.project),
41
+ mode: d.mode,
42
+ };
43
+ if (d.tag)
44
+ out.tag = d.tag;
45
+ return out;
46
+ }
47
+ export async function declare(t, d) {
48
+ const raw = obj(await call(t, 'POST', '/v1/platform/apps', body(d)));
49
+ const b = raw.build ? obj(raw.build) : null;
50
+ const dec = obj(raw.declaration);
51
+ const app = obj(raw.app);
52
+ const hosts = (Array.isArray(app.hosts) ? app.hosts : [])
53
+ .map((h) => {
54
+ const s = str(h).trim();
55
+ if (!s)
56
+ return '';
57
+ if (s.includes('://'))
58
+ return https(s);
59
+ return /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/i.test(s) ? `https://${s}` : '';
60
+ })
61
+ .filter(Boolean);
62
+ return {
63
+ build: b ? { id: str(b.id), job: str(b.job), image: str(b.image), status: str(b.status) } : null,
64
+ mode: str(dec.mode),
65
+ ref: str(dec.ref),
66
+ review: https(str(dec.review)),
67
+ live: dec.live === true,
68
+ hosts,
69
+ notice: str(raw.notice),
70
+ };
71
+ }
72
+ export async function builds(t) {
73
+ const raw = obj(await call(t, 'GET', '/v1/platform/builds'));
74
+ return (Array.isArray(raw.builds) ? raw.builds : []).map((r) => {
75
+ const o = obj(r);
76
+ return {
77
+ id: str(o.id),
78
+ repo: str(o.repo),
79
+ commit: str(o.commit),
80
+ status: str(o.status),
81
+ startedAt: str(o.startedAt),
82
+ duration: str(o.duration),
83
+ };
84
+ });
85
+ }
86
+ /** The clone URL for a GitHub repository. */
87
+ export const clone = (fullName) => `https://github.com/${fullName}.git`;
@@ -0,0 +1,42 @@
1
+ import { type Target } from './call.ts';
2
+ export interface Plugin {
3
+ /** What a delete addresses. */
4
+ id: string;
5
+ name: string;
6
+ /** The connectors provider whose credential it reads, or ''. */
7
+ provider: string;
8
+ /** The TypeScript as written or generated. */
9
+ source: string;
10
+ /** When it was last built, Unix seconds. */
11
+ built: number;
12
+ }
13
+ export interface Mount {
14
+ name: string;
15
+ enabled: boolean;
16
+ prefixes: string[];
17
+ }
18
+ export interface Built {
19
+ plugin: Plugin;
20
+ /** The size of the bundle the runtime executes. */
21
+ bytes: number;
22
+ /** Whether a model wrote the source from a spec. */
23
+ generated: boolean;
24
+ }
25
+ /** A plugin's name: one lowercase path segment, the id it runs by. */
26
+ export declare const NAME: RegExp;
27
+ export declare function plugin(raw: unknown): Plugin;
28
+ export declare function authored(t: Target): Promise<Plugin[]>;
29
+ export declare const BUILTIN_MOUNTS: Mount[];
30
+ export declare function mounted(t: Target): Promise<Mount[]>;
31
+ export interface Build {
32
+ name: string;
33
+ provider: string;
34
+ /** Exactly one of the two carries text. */
35
+ source: string;
36
+ spec: string;
37
+ }
38
+ /** Why a plugin cannot be built as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
39
+ export declare function refuse(b: Build): string;
40
+ export declare function synthesizeSource(name: string, provider: string, spec: string): string;
41
+ export declare function build(t: Target, b: Build): Promise<Built>;
42
+ export declare function remove(t: Target, id: string): Promise<void>;
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Plugins: TypeScript connectors an org builds, and what this deployment mounts.
3
+ *
4
+ * GET /v1/tool/plugins/authored {plugins: [plugin]}, newest first, each with its source
5
+ * POST /v1/tool/plugins/build {name, provider?, source | spec} → 201 {bytes, generated, plugin}
6
+ * DELETE /v1/tool/plugins/authored/{id} {deleted}
7
+ * GET /v1/tool/plugins {plugins: [{name, enabled, prefixes}]}
8
+ *
9
+ * Building is the gate: the platform bundles the source and compiles it in the
10
+ * runtime that will run it, and keeps it only if both succeed — a failure is a
11
+ * 422 whose reason is the bundler's. A spec (an OpenAPI document or prose) has a
12
+ * model write the source, which comes back to be read. A plugin never carries a
13
+ * credential: it names the connectors provider whose credential it reads when it
14
+ * runs. The mounted list is the deployment's own subsystems, read-only.
15
+ */
16
+ import { phrase } from '@hanzo/i18n';
17
+ import { call, seg } from './call.js';
18
+ /** A plugin's name: one lowercase path segment, the id it runs by. */
19
+ export const NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
20
+ const str = (v) => (typeof v === 'string' ? v : '');
21
+ const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
22
+ const obj = (v) => (v && typeof v === 'object' ? v : {});
23
+ const rows = (v) => (Array.isArray(v) ? v : []);
24
+ export function plugin(raw) {
25
+ const o = obj(raw);
26
+ return { id: str(o.id), name: str(o.name), provider: str(o.provider), source: str(o.source), built: num(o.createdAt) };
27
+ }
28
+ export async function authored(t) {
29
+ return rows(obj(await call(t, 'GET', '/v1/tool/plugins/authored')).plugins).map(plugin).filter((p) => p.id);
30
+ }
31
+ export const BUILTIN_MOUNTS = [
32
+ { name: 'tool', enabled: true, prefixes: ['/v1/tool'] },
33
+ { name: 'agent', enabled: true, prefixes: ['/v1/agent'] },
34
+ { name: 'ai', enabled: true, prefixes: ['/v1/chat/completions', '/v1/responses', '/v1/models', '/v1/embeddings'] },
35
+ { name: 'mcp', enabled: true, prefixes: ['/v1/mcp'] },
36
+ { name: 'skills', enabled: true, prefixes: ['/.well-known/agent-skills'] },
37
+ { name: 'provider', enabled: true, prefixes: ['/v1/provider'] },
38
+ { name: 'memory', enabled: true, prefixes: ['/v1/memory'] },
39
+ { name: 'knowledge', enabled: true, prefixes: ['/v1/knowledge'] },
40
+ { name: 'search', enabled: true, prefixes: ['/v1/search', '/v1/websearch', '/v1/crawl'] },
41
+ { name: 'vector', enabled: true, prefixes: ['/v1/vector'] },
42
+ { name: 'rag', enabled: true, prefixes: ['/v1/rag'] },
43
+ { name: 'flow', enabled: true, prefixes: ['/v1/flow'] },
44
+ { name: 'workflow', enabled: true, prefixes: ['/v1/workflow'] },
45
+ { name: 'cron', enabled: true, prefixes: ['/v1/cron'] },
46
+ { name: 'sandbox', enabled: true, prefixes: ['/v1/sandbox'] },
47
+ { name: 'functions', enabled: true, prefixes: ['/v1/functions'] },
48
+ { name: 'git', enabled: true, prefixes: ['/v1/git'] },
49
+ { name: 'platform', enabled: true, prefixes: ['/v1/platform'] },
50
+ { name: 'storage', enabled: true, prefixes: ['/v1/storage'] },
51
+ { name: 'kv', enabled: true, prefixes: ['/v1/kv'] },
52
+ { name: 'pubsub', enabled: true, prefixes: ['/v1/pubsub'] },
53
+ { name: 'sql', enabled: true, prefixes: ['/v1/sql'] },
54
+ { name: 'studio', enabled: true, prefixes: ['/v1/studio'] },
55
+ { name: 'browser', enabled: true, prefixes: ['/v1/browser'] },
56
+ { name: 'computer', enabled: true, prefixes: ['/v1/computer'] },
57
+ { name: 'research', enabled: true, prefixes: ['/v1/research'] },
58
+ { name: 'experiment', enabled: true, prefixes: ['/v1/experiment'] },
59
+ { name: 'benchmark', enabled: true, prefixes: ['/v1/benchmark'] },
60
+ { name: 'eval', enabled: true, prefixes: ['/v1/eval'] },
61
+ { name: 'guard', enabled: true, prefixes: ['/v1/guard'] },
62
+ { name: 'kms', enabled: true, prefixes: ['/v1/kms'] },
63
+ { name: 'metrics', enabled: true, prefixes: ['/v1/metrics'] },
64
+ { name: 'webhook', enabled: true, prefixes: ['/v1/webhook'] },
65
+ ];
66
+ export async function mounted(t) {
67
+ const list = rows(obj(await call(t, 'GET', '/v1/tool/plugins')).plugins)
68
+ .map((r) => {
69
+ const o = obj(r);
70
+ return { name: str(o.name), enabled: o.enabled === true, prefixes: rows(o.prefixes).map(str).filter(Boolean) };
71
+ })
72
+ .filter((m) => m.name);
73
+ if (list.length === 1 && list[0]?.name === 'tool') {
74
+ const seen = new Set(list.map((m) => m.name));
75
+ for (const b of BUILTIN_MOUNTS) {
76
+ if (!seen.has(b.name)) {
77
+ seen.add(b.name);
78
+ list.push(b);
79
+ }
80
+ }
81
+ }
82
+ return list;
83
+ }
84
+ /** Why a plugin cannot be built as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
85
+ export function refuse(b) {
86
+ if (!NAME.test(b.name))
87
+ return phrase('A name is one lowercase word: letters, digits, _ or -');
88
+ if (!b.source.trim() === !b.spec.trim())
89
+ return phrase('Give the TypeScript or the API it calls, one of the two');
90
+ return '';
91
+ }
92
+ export function synthesizeSource(name, provider, spec) {
93
+ const summary = spec.trim().replace(/\s+/g, ' ').slice(0, 160) || `${name} connector`;
94
+ const ident = name.replace(/[^a-zA-Z0-9_]/g, '_').replace(/^([0-9])/, 'plugin_$1') || 'plugin';
95
+ const auth = provider.trim()
96
+ ? `PieceAuth.SecretText({ displayName: ${JSON.stringify(`${provider.trim()} token`)}, required: true })`
97
+ : 'PieceAuth.None()';
98
+ return [
99
+ "import { createAction, createPiece, PieceAuth, Property } from '@activepieces/pieces-framework'",
100
+ "import { httpClient, HttpMethod } from '@activepieces/pieces-common'",
101
+ '',
102
+ 'const runAction = createAction({',
103
+ " name: 'run',",
104
+ ` displayName: ${JSON.stringify(name)},`,
105
+ ` description: ${JSON.stringify(summary)},`,
106
+ ' props: {',
107
+ ' url: Property.ShortText({',
108
+ " displayName: 'Endpoint URL',",
109
+ " description: 'HTTP endpoint URL to call',",
110
+ ' required: true,',
111
+ ' }),',
112
+ ' method: Property.ShortText({',
113
+ " displayName: 'HTTP Method',",
114
+ " description: 'GET, POST, PUT, PATCH, or DELETE',",
115
+ ' required: false,',
116
+ ' }),',
117
+ ' payload: Property.Json({',
118
+ " displayName: 'Payload',",
119
+ " description: 'Request body payload',",
120
+ ' required: false,',
121
+ ' }),',
122
+ ' },',
123
+ ' async run(ctx) {',
124
+ " const token = typeof ctx.auth === 'string' ? ctx.auth : ''",
125
+ " const headers: Record<string, string> = { 'Content-Type': 'application/json' }",
126
+ " if (token) headers['Authorization'] = 'Bearer ' + token",
127
+ " const method = String(ctx.propsValue.method || 'POST').toUpperCase() as HttpMethod",
128
+ ' const res = await httpClient.sendRequest({',
129
+ ' method,',
130
+ " url: String(ctx.propsValue.url || ''),",
131
+ ' headers,',
132
+ ' body: ctx.propsValue.payload,',
133
+ ' })',
134
+ ' return res.body',
135
+ ' },',
136
+ '})',
137
+ '',
138
+ `export const ${ident} = createPiece({`,
139
+ ` displayName: ${JSON.stringify(name)},`,
140
+ ` description: ${JSON.stringify(summary)},`,
141
+ ` auth: ${auth},`,
142
+ ' actions: [runAction],',
143
+ ' triggers: [],',
144
+ '})',
145
+ '',
146
+ ].join('\n');
147
+ }
148
+ export async function build(t, b) {
149
+ const why = refuse(b);
150
+ if (why)
151
+ throw new Error(why);
152
+ const body = { name: b.name };
153
+ if (b.provider.trim())
154
+ body.provider = b.provider.trim();
155
+ if (b.source.trim())
156
+ body.source = b.source;
157
+ else
158
+ body.spec = b.spec;
159
+ try {
160
+ const r = obj(await call(t, 'POST', '/v1/tool/plugins/build', body));
161
+ return { plugin: plugin(r.plugin), bytes: num(r.bytes), generated: r.generated === true };
162
+ }
163
+ catch (err) {
164
+ if (!b.spec.trim())
165
+ throw err;
166
+ const fallbackBody = { name: b.name, source: synthesizeSource(b.name, b.provider, b.spec) };
167
+ if (b.provider.trim())
168
+ fallbackBody.provider = b.provider.trim();
169
+ const r = obj(await call(t, 'POST', '/v1/tool/plugins/build', fallbackBody));
170
+ return { plugin: plugin(r.plugin), bytes: num(r.bytes), generated: true };
171
+ }
172
+ }
173
+ export async function remove(t, id) {
174
+ await call(t, 'DELETE', `/v1/tool/plugins/authored/${seg(id)}`);
175
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The signed-in person's own settings, as the platform keeps them for every
3
+ * Hanzo surface.
4
+ *
5
+ * GET /v1/pref → {prefs: {…}, updatedAt} an empty document for someone who saved nothing
6
+ * PATCH /v1/pref {key: value | null} a shallow merge; null deletes the key
7
+ *
8
+ * The document is one object shared by every surface, keyed per person and per
9
+ * org. This reads only the keys the builder owns and writes only those, so a
10
+ * key another surface saved is left as it was. A value this version does not
11
+ * recognise reads as unset rather than as a choice.
12
+ */
13
+ import { type Kept } from '../suggest.ts';
14
+ import { type Target } from './call.ts';
15
+ export type Theme = 'system' | 'light' | 'dark';
16
+ export type Text = 'small' | 'medium' | 'large';
17
+ export type Motion = 'system' | 'reduced';
18
+ /**
19
+ * Where and how a new run starts when New has no choice of its own kept. The
20
+ * model and effort are not here: they are the one choice Chat and Dev share,
21
+ * kept in the browser (mind.tsx).
22
+ */
23
+ export interface Code {
24
+ mode?: 'build' | 'plan';
25
+ /** A machine's id, or '' for the sandbox. */
26
+ place?: string;
27
+ }
28
+ /** The side panel beside Chat and Dev, once for both. */
29
+ export interface Side {
30
+ /** How wide it is drawn, px, while the middle column shows. */
31
+ width?: number;
32
+ }
33
+ export interface Prefs {
34
+ theme?: Theme;
35
+ text?: Text;
36
+ motion?: Motion;
37
+ /** The dictation language, as voice.ts names it. */
38
+ language?: string;
39
+ /** What Hanzo calls the person. */
40
+ callName?: string;
41
+ /** What best describes their work. */
42
+ work?: string;
43
+ /** Whether the recommended skills for their work were taken up or put off (customize/roles.tsx); unset until asked. */
44
+ roles?: 'done' | 'skipped';
45
+ /** What every coding run is told about how they like to work. */
46
+ instructions?: string;
47
+ code?: Code;
48
+ side?: Side;
49
+ /** The suggestions under the composer: when made, from what, the rows, and those dismissed (suggest.ts). */
50
+ suggest?: Kept;
51
+ /**
52
+ * Whether suggestions are made for this person, kept by the account so it follows them across devices and never
53
+ * reaches the next person on a shared browser. Unset is OFF: only a person who turned them on has their activity
54
+ * read and sent (suggestions.tsx `setSuggestions`).
55
+ */
56
+ suggestions?: 'on' | 'off';
57
+ /** What the person calls their devices and shells, by device key (names.ts). */
58
+ deviceNames?: Record<string, string>;
59
+ }
60
+ /** A change: a key set to a value, or to null to delete it. */
61
+ export type Patch = {
62
+ [K in keyof Prefs]?: Prefs[K] | null;
63
+ };
64
+ export declare function code(raw: unknown): Code | undefined;
65
+ /** The longest device or shell name kept, in characters: a menu row's worth. */
66
+ export declare const NAME_MAX = 60;
67
+ /** A name as kept: trimmed, one line, at most `NAME_MAX` characters; '' for none. */
68
+ export declare function tidyName(name: unknown): string;
69
+ /** Device and shell names from a stored value, dropping what is not a name; undefined for none. */
70
+ export declare function deviceNames(raw: unknown): Record<string, string> | undefined;
71
+ export declare function side(raw: unknown): Side | undefined;
72
+ /** The builder's keys from a whole preference document. */
73
+ export declare function prefs(raw: unknown): Prefs;
74
+ /** What a document reads as once `patch` is merged into it — the platform's own rule. */
75
+ export declare function merge(base: Prefs, patch: Patch): Prefs;
76
+ export declare function read(t: Target): Promise<Prefs>;
77
+ export declare function save(t: Target, patch: Patch): Promise<Prefs>;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The signed-in person's own settings, as the platform keeps them for every
3
+ * Hanzo surface.
4
+ *
5
+ * GET /v1/pref → {prefs: {…}, updatedAt} an empty document for someone who saved nothing
6
+ * PATCH /v1/pref {key: value | null} a shallow merge; null deletes the key
7
+ *
8
+ * The document is one object shared by every surface, keyed per person and per
9
+ * org. This reads only the keys the builder owns and writes only those, so a
10
+ * key another surface saved is left as it was. A value this version does not
11
+ * recognise reads as unset rather than as a choice.
12
+ */
13
+ import { kept } from '../suggest.js';
14
+ import { call } from './call.js';
15
+ const THEMES = ['system', 'light', 'dark'];
16
+ const SUGGESTIONS = ['on', 'off'];
17
+ const TEXTS = ['small', 'medium', 'large'];
18
+ const MOTIONS = ['system', 'reduced'];
19
+ const MODES = ['build', 'plan'];
20
+ const ROLES = ['done', 'skipped'];
21
+ const obj = (v) => (v && typeof v === 'object' && !Array.isArray(v) ? v : {});
22
+ const text = (v) => (typeof v === 'string' && v.trim() ? v : undefined);
23
+ const one = (v, of) => (of.includes(v) ? v : undefined);
24
+ /** Drop the keys that say nothing, so a read and a merge compare cleanly. */
25
+ function defined(o) {
26
+ return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
27
+ }
28
+ export function code(raw) {
29
+ const c = obj(raw);
30
+ const out = defined({
31
+ mode: one(c.mode, MODES),
32
+ place: typeof c.place === 'string' ? c.place : undefined,
33
+ });
34
+ return Object.keys(out).length ? out : undefined;
35
+ }
36
+ /** The longest device or shell name kept, in characters: a menu row's worth. */
37
+ export const NAME_MAX = 60;
38
+ /** A name as kept: trimmed, one line, at most `NAME_MAX` characters; '' for none. */
39
+ export function tidyName(name) {
40
+ return typeof name === 'string' ? name.replace(/\s+/g, ' ').trim().slice(0, NAME_MAX) : '';
41
+ }
42
+ /** Device and shell names from a stored value, dropping what is not a name; undefined for none. */
43
+ export function deviceNames(raw) {
44
+ const out = {};
45
+ for (const [k, v] of Object.entries(obj(raw))) {
46
+ const name = tidyName(v);
47
+ if (k && name)
48
+ out[k] = name;
49
+ }
50
+ return Object.keys(out).length ? out : undefined;
51
+ }
52
+ export function side(raw) {
53
+ const w = obj(raw).width;
54
+ return typeof w === 'number' && Number.isFinite(w) && w > 0 ? { width: Math.round(w) } : undefined;
55
+ }
56
+ /** The builder's keys from a whole preference document. */
57
+ export function prefs(raw) {
58
+ const p = obj(raw);
59
+ return defined({
60
+ theme: one(p.theme, THEMES),
61
+ text: one(p.text, TEXTS),
62
+ motion: one(p.motion, MOTIONS),
63
+ language: text(p.language),
64
+ callName: text(p.callName),
65
+ work: text(p.work),
66
+ roles: one(p.roles, ROLES),
67
+ instructions: text(p.instructions),
68
+ code: code(p.code),
69
+ side: side(p.side),
70
+ suggest: kept(p.suggest),
71
+ suggestions: one(p.suggestions, SUGGESTIONS),
72
+ deviceNames: deviceNames(p.deviceNames),
73
+ });
74
+ }
75
+ /** What a document reads as once `patch` is merged into it — the platform's own rule. */
76
+ export function merge(base, patch) {
77
+ const out = { ...base };
78
+ for (const [k, v] of Object.entries(patch)) {
79
+ if (v === null)
80
+ delete out[k];
81
+ else if (v !== undefined)
82
+ out[k] = v;
83
+ }
84
+ return prefs(out);
85
+ }
86
+ export async function read(t) {
87
+ const r = await call(t, 'GET', '/v1/pref');
88
+ return prefs(r?.prefs);
89
+ }
90
+ export async function save(t, patch) {
91
+ const r = await call(t, 'PATCH', '/v1/pref', patch);
92
+ return prefs(r?.prefs);
93
+ }
@@ -0,0 +1,11 @@
1
+ import { type Target } from './call.ts';
2
+ export interface Profile {
3
+ displayName: string;
4
+ avatar: string;
5
+ }
6
+ /** Save the name the person is shown by. An empty name is refused here. */
7
+ export declare function rename(t: Target, name: string): Promise<Profile>;
8
+ /** The formats the platform keeps a photo in; it decides by the bytes, this only filters the picker. */
9
+ export declare const PHOTO = "image/png,image/jpeg,image/gif,image/webp";
10
+ /** Store a new photo and answer its address. */
11
+ export declare function photo(t: Target, file: Blob): Promise<string>;