@neta-art/cohub-cli 10.24.0 → 10.25.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 (368) hide show
  1. package/bin/cohub.js +4 -1
  2. package/dist/board-gpu/page.js +1566 -71230
  3. package/dist/bootstrap.js +67 -27
  4. package/dist/build.json +1 -1
  5. package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
  6. package/dist/chunks/about.js +102 -0
  7. package/dist/chunks/app-realtime.js +2216 -0
  8. package/dist/chunks/app-realtime2.js +2 -0
  9. package/dist/chunks/app-ref.js +88 -0
  10. package/dist/chunks/apps.js +1423 -0
  11. package/dist/chunks/auth.js +175 -0
  12. package/dist/chunks/avatar.js +146 -0
  13. package/dist/chunks/board-export-resources.js +232 -0
  14. package/dist/chunks/board-export.js +874 -0
  15. package/dist/chunks/board-export2.js +2 -0
  16. package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
  17. package/dist/chunks/board-kernel2.js +4 -0
  18. package/dist/chunks/board-profile.js +69 -0
  19. package/dist/chunks/board-simulate.js +315 -0
  20. package/dist/chunks/board-time.js +34 -0
  21. package/dist/chunks/boards.js +1943 -0
  22. package/dist/{board-kernel → chunks}/browserAll.js +9 -8
  23. package/dist/chunks/channels.js +64 -0
  24. package/dist/chunks/client.js +12606 -0
  25. package/dist/chunks/command-input.js +17 -0
  26. package/dist/chunks/commander.js +2962 -0
  27. package/dist/chunks/cron-jobs.js +163 -0
  28. package/dist/chunks/daemon.js +545 -0
  29. package/dist/chunks/daemon2.js +2 -0
  30. package/dist/chunks/desktop.js +172 -0
  31. package/dist/chunks/endpoint-options.js +26 -0
  32. package/dist/chunks/env-proxy.js +35 -0
  33. package/dist/chunks/environment.js +154 -0
  34. package/dist/chunks/feedback.js +120 -0
  35. package/dist/chunks/generations.js +379 -0
  36. package/dist/chunks/host.js +9 -0
  37. package/dist/chunks/http-put.js +131 -0
  38. package/dist/chunks/id.js +2416 -0
  39. package/dist/{board-kernel → chunks}/init.js +1 -1
  40. package/dist/chunks/install.js +11959 -0
  41. package/dist/chunks/launch.js +374 -0
  42. package/dist/chunks/local-media.js +47 -0
  43. package/dist/chunks/me.js +134 -0
  44. package/dist/chunks/media.js +315 -0
  45. package/dist/chunks/models.js +242 -0
  46. package/dist/chunks/operands.js +46 -0
  47. package/dist/chunks/package-paths.js +13 -0
  48. package/dist/chunks/policy.js +221 -0
  49. package/dist/chunks/preferences.js +29 -0
  50. package/dist/chunks/profile.js +64 -0
  51. package/dist/chunks/prompts.js +41 -0
  52. package/dist/chunks/public.js +2 -0
  53. package/dist/chunks/public2.js +244 -0
  54. package/dist/chunks/references.js +197 -0
  55. package/dist/chunks/referrals.js +90 -0
  56. package/dist/chunks/rolldown-runtime.js +26 -0
  57. package/dist/chunks/rooms-connect.js +2 -0
  58. package/dist/chunks/rooms-connect2.js +151 -0
  59. package/dist/chunks/rooms-rtc.js +309 -0
  60. package/dist/chunks/rooms.js +211 -0
  61. package/dist/chunks/run.js +220 -0
  62. package/dist/chunks/runtime.js +638 -0
  63. package/dist/chunks/runtime2.js +286 -0
  64. package/dist/chunks/runtimes.js +48 -0
  65. package/dist/chunks/safe-remote-image.js +198 -0
  66. package/dist/chunks/schemas.js +6017 -0
  67. package/dist/chunks/search.js +113 -0
  68. package/dist/chunks/self-update.js +238 -0
  69. package/dist/chunks/serve.js +1246 -0
  70. package/dist/chunks/session-status.js +24 -0
  71. package/dist/chunks/skills.js +35 -0
  72. package/dist/chunks/spaces.js +5080 -0
  73. package/dist/chunks/src.js +405 -0
  74. package/dist/chunks/supervisor.js +2511 -0
  75. package/dist/chunks/supervisor2.js +2 -0
  76. package/dist/chunks/tasks.js +82 -0
  77. package/dist/chunks/themes.js +2898 -0
  78. package/dist/chunks/version.js +2 -0
  79. package/dist/chunks/version2.js +22 -0
  80. package/dist/chunks/version3.js +18 -0
  81. package/dist/chunks/web.js +7 -0
  82. package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
  83. package/dist/runtime/native/pi-extension.js +174 -166
  84. package/dist/runtime/worker.js +27 -16
  85. package/package.json +8 -9
  86. package/dist/about.d.ts +0 -2
  87. package/dist/about.js +0 -71
  88. package/dist/app-download.d.ts +0 -11
  89. package/dist/app-download.js +0 -252
  90. package/dist/app-ref.d.ts +0 -5
  91. package/dist/app-ref.js +0 -8
  92. package/dist/app-target.d.ts +0 -26
  93. package/dist/app-target.js +0 -55
  94. package/dist/auth.d.ts +0 -45
  95. package/dist/auth.js +0 -307
  96. package/dist/avatar.d.ts +0 -55
  97. package/dist/avatar.js +0 -104
  98. package/dist/board-command-support.d.ts +0 -6
  99. package/dist/board-command-support.js +0 -88
  100. package/dist/board-export-resources.d.ts +0 -12
  101. package/dist/board-export-resources.js +0 -51
  102. package/dist/board-export.d.ts +0 -110
  103. package/dist/board-export.js +0 -592
  104. package/dist/board-fonts.d.ts +0 -11
  105. package/dist/board-fonts.js +0 -10
  106. package/dist/board-gpu/daemon.d.ts +0 -11
  107. package/dist/board-gpu/daemon.js +0 -295
  108. package/dist/board-gpu/index.d.ts +0 -33
  109. package/dist/board-gpu/index.js +0 -189
  110. package/dist/board-gpu/protocol.d.ts +0 -77
  111. package/dist/board-gpu/protocol.js +0 -1
  112. package/dist/board-kernel.d.ts +0 -5
  113. package/dist/board-media-export.d.ts +0 -17
  114. package/dist/board-media-export.js +0 -164
  115. package/dist/board-media.d.ts +0 -5
  116. package/dist/board-media.js +0 -66
  117. package/dist/board-profile.d.ts +0 -21
  118. package/dist/board-profile.js +0 -67
  119. package/dist/board-simulate.d.ts +0 -67
  120. package/dist/board-simulate.js +0 -259
  121. package/dist/board-time.d.ts +0 -3
  122. package/dist/board-time.js +0 -34
  123. package/dist/bootstrap.d.ts +0 -2
  124. package/dist/client.d.ts +0 -5
  125. package/dist/client.js +0 -24
  126. package/dist/command-input.d.ts +0 -4
  127. package/dist/command-input.js +0 -16
  128. package/dist/commands/app-commerce.d.ts +0 -2
  129. package/dist/commands/app-commerce.js +0 -228
  130. package/dist/commands/app-domains.d.ts +0 -2
  131. package/dist/commands/app-domains.js +0 -133
  132. package/dist/commands/apps.d.ts +0 -4
  133. package/dist/commands/apps.js +0 -827
  134. package/dist/commands/auth.d.ts +0 -2
  135. package/dist/commands/auth.js +0 -186
  136. package/dist/commands/boards/authoring.d.ts +0 -2
  137. package/dist/commands/boards/authoring.js +0 -166
  138. package/dist/commands/boards/examples.d.ts +0 -10
  139. package/dist/commands/boards/examples.js +0 -118
  140. package/dist/commands/boards.d.ts +0 -13
  141. package/dist/commands/boards.js +0 -836
  142. package/dist/commands/channels.d.ts +0 -2
  143. package/dist/commands/channels.js +0 -74
  144. package/dist/commands/cron-jobs.d.ts +0 -2
  145. package/dist/commands/cron-jobs.js +0 -155
  146. package/dist/commands/decision.d.ts +0 -4
  147. package/dist/commands/decision.js +0 -113
  148. package/dist/commands/desktop.d.ts +0 -10
  149. package/dist/commands/desktop.js +0 -233
  150. package/dist/commands/feedback.d.ts +0 -2
  151. package/dist/commands/feedback.js +0 -131
  152. package/dist/commands/generations.d.ts +0 -2
  153. package/dist/commands/generations.js +0 -427
  154. package/dist/commands/host.d.ts +0 -2
  155. package/dist/commands/host.js +0 -11
  156. package/dist/commands/me.d.ts +0 -2
  157. package/dist/commands/me.js +0 -121
  158. package/dist/commands/models.d.ts +0 -28
  159. package/dist/commands/models.js +0 -271
  160. package/dist/commands/profile.d.ts +0 -2
  161. package/dist/commands/profile.js +0 -81
  162. package/dist/commands/prompts.d.ts +0 -2
  163. package/dist/commands/prompts.js +0 -37
  164. package/dist/commands/public.d.ts +0 -20
  165. package/dist/commands/public.js +0 -291
  166. package/dist/commands/references.d.ts +0 -2
  167. package/dist/commands/references.js +0 -193
  168. package/dist/commands/referrals.d.ts +0 -2
  169. package/dist/commands/referrals.js +0 -88
  170. package/dist/commands/rooms-connect.d.ts +0 -17
  171. package/dist/commands/rooms-connect.js +0 -140
  172. package/dist/commands/rooms-rtc-binary.d.ts +0 -2
  173. package/dist/commands/rooms-rtc-binary.js +0 -107
  174. package/dist/commands/rooms-rtc.d.ts +0 -21
  175. package/dist/commands/rooms-rtc.js +0 -171
  176. package/dist/commands/rooms.d.ts +0 -3
  177. package/dist/commands/rooms.js +0 -277
  178. package/dist/commands/run.d.ts +0 -13
  179. package/dist/commands/run.js +0 -246
  180. package/dist/commands/runtime.d.ts +0 -3
  181. package/dist/commands/runtime.js +0 -320
  182. package/dist/commands/sandboxd-binary.d.ts +0 -11
  183. package/dist/commands/sandboxd-binary.js +0 -238
  184. package/dist/commands/search.d.ts +0 -2
  185. package/dist/commands/search.js +0 -114
  186. package/dist/commands/session-access.d.ts +0 -2
  187. package/dist/commands/session-access.js +0 -70
  188. package/dist/commands/skills.d.ts +0 -2
  189. package/dist/commands/skills.js +0 -34
  190. package/dist/commands/space-activity.d.ts +0 -26
  191. package/dist/commands/space-activity.js +0 -147
  192. package/dist/commands/space-commerce.d.ts +0 -2
  193. package/dist/commands/space-commerce.js +0 -514
  194. package/dist/commands/space-displays.d.ts +0 -2
  195. package/dist/commands/space-displays.js +0 -620
  196. package/dist/commands/space-files.d.ts +0 -5
  197. package/dist/commands/space-files.js +0 -215
  198. package/dist/commands/space-invitations.d.ts +0 -29
  199. package/dist/commands/space-invitations.js +0 -189
  200. package/dist/commands/space-turns.d.ts +0 -49
  201. package/dist/commands/space-turns.js +0 -205
  202. package/dist/commands/space-wallet.d.ts +0 -2
  203. package/dist/commands/space-wallet.js +0 -141
  204. package/dist/commands/space-webhooks.d.ts +0 -7
  205. package/dist/commands/space-webhooks.js +0 -73
  206. package/dist/commands/spaces.d.ts +0 -25
  207. package/dist/commands/spaces.js +0 -2170
  208. package/dist/commands/tasks.d.ts +0 -8
  209. package/dist/commands/tasks.js +0 -80
  210. package/dist/commands/version.d.ts +0 -2
  211. package/dist/commands/version.js +0 -21
  212. package/dist/endpoint-options.d.ts +0 -4
  213. package/dist/endpoint-options.js +0 -26
  214. package/dist/env-proxy.d.ts +0 -5
  215. package/dist/env-proxy.js +0 -20
  216. package/dist/help-path.d.ts +0 -18
  217. package/dist/help-path.js +0 -223
  218. package/dist/host/auth.d.ts +0 -20
  219. package/dist/host/auth.js +0 -119
  220. package/dist/host/login-env.d.ts +0 -1
  221. package/dist/host/login-env.js +0 -31
  222. package/dist/host/runtime.d.ts +0 -35
  223. package/dist/host/runtime.js +0 -395
  224. package/dist/host/runtimes.d.ts +0 -9
  225. package/dist/host/runtimes.js +0 -42
  226. package/dist/host/serve.d.ts +0 -2
  227. package/dist/host/serve.js +0 -117
  228. package/dist/host/workspaces.d.ts +0 -2
  229. package/dist/host/workspaces.js +0 -18
  230. package/dist/http-put.d.ts +0 -25
  231. package/dist/http-put.js +0 -132
  232. package/dist/index.d.ts +0 -2
  233. package/dist/index.js +0 -129
  234. package/dist/launcher.d.ts +0 -4
  235. package/dist/launcher.js +0 -38
  236. package/dist/local-media.d.ts +0 -2
  237. package/dist/local-media.js +0 -30
  238. package/dist/network-error.d.ts +0 -3
  239. package/dist/network-error.js +0 -22
  240. package/dist/output.d.ts +0 -46
  241. package/dist/output.js +0 -244
  242. package/dist/runtime/archive-store.d.ts +0 -54
  243. package/dist/runtime/archive-store.js +0 -379
  244. package/dist/runtime/cli-path.d.ts +0 -5
  245. package/dist/runtime/cli-path.js +0 -27
  246. package/dist/runtime/codex-usage.d.ts +0 -7
  247. package/dist/runtime/codex-usage.js +0 -11
  248. package/dist/runtime/connection.d.ts +0 -42
  249. package/dist/runtime/connection.js +0 -789
  250. package/dist/runtime/diagnostics.d.ts +0 -107
  251. package/dist/runtime/diagnostics.js +0 -392
  252. package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
  253. package/dist/runtime/harnesses/chained-projection.js +0 -95
  254. package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
  255. package/dist/runtime/harnesses/chained-transcript.js +0 -62
  256. package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
  257. package/dist/runtime/harnesses/claude-approval.js +0 -124
  258. package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
  259. package/dist/runtime/harnesses/claude-transcript.js +0 -138
  260. package/dist/runtime/harnesses/claude.d.ts +0 -8
  261. package/dist/runtime/harnesses/claude.js +0 -225
  262. package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
  263. package/dist/runtime/harnesses/codex-approval.js +0 -69
  264. package/dist/runtime/harnesses/codex.d.ts +0 -4
  265. package/dist/runtime/harnesses/codex.js +0 -269
  266. package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
  267. package/dist/runtime/harnesses/cursor-transcript.js +0 -183
  268. package/dist/runtime/harnesses/cursor.d.ts +0 -24
  269. package/dist/runtime/harnesses/cursor.js +0 -620
  270. package/dist/runtime/harnesses/index.d.ts +0 -16
  271. package/dist/runtime/harnesses/index.js +0 -73
  272. package/dist/runtime/harnesses/pi.d.ts +0 -4
  273. package/dist/runtime/harnesses/pi.js +0 -247
  274. package/dist/runtime/harnesses/process.d.ts +0 -31
  275. package/dist/runtime/harnesses/process.js +0 -75
  276. package/dist/runtime/harnesses/stream-json.d.ts +0 -48
  277. package/dist/runtime/harnesses/stream-json.js +0 -336
  278. package/dist/runtime/harnesses/types.d.ts +0 -117
  279. package/dist/runtime/harnesses/types.js +0 -1
  280. package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
  281. package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
  282. package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
  283. package/dist/runtime/harnesses/workbuddy.js +0 -123
  284. package/dist/runtime/instance.d.ts +0 -20
  285. package/dist/runtime/instance.js +0 -247
  286. package/dist/runtime/json-rpc.d.ts +0 -53
  287. package/dist/runtime/json-rpc.js +0 -212
  288. package/dist/runtime/launch.d.ts +0 -25
  289. package/dist/runtime/launch.js +0 -247
  290. package/dist/runtime/local-workspace.d.ts +0 -15
  291. package/dist/runtime/local-workspace.js +0 -52
  292. package/dist/runtime/model-catalog.d.ts +0 -12
  293. package/dist/runtime/model-catalog.js +0 -84
  294. package/dist/runtime/native/adapters.d.ts +0 -15
  295. package/dist/runtime/native/adapters.js +0 -11
  296. package/dist/runtime/native/approvals.d.ts +0 -18
  297. package/dist/runtime/native/approvals.js +0 -54
  298. package/dist/runtime/native/archive.d.ts +0 -19
  299. package/dist/runtime/native/archive.js +0 -142
  300. package/dist/runtime/native/attach.d.ts +0 -36
  301. package/dist/runtime/native/attach.js +0 -128
  302. package/dist/runtime/native/codex-link.d.ts +0 -60
  303. package/dist/runtime/native/codex-link.js +0 -322
  304. package/dist/runtime/native/config.d.ts +0 -16
  305. package/dist/runtime/native/config.js +0 -24
  306. package/dist/runtime/native/daemon.d.ts +0 -92
  307. package/dist/runtime/native/daemon.js +0 -380
  308. package/dist/runtime/native/execution.d.ts +0 -26
  309. package/dist/runtime/native/execution.js +0 -34
  310. package/dist/runtime/native/identity.d.ts +0 -9
  311. package/dist/runtime/native/identity.js +0 -15
  312. package/dist/runtime/native/ingest.d.ts +0 -263
  313. package/dist/runtime/native/ingest.js +0 -884
  314. package/dist/runtime/native/install.d.ts +0 -9
  315. package/dist/runtime/native/install.js +0 -113
  316. package/dist/runtime/native/paths.d.ts +0 -2
  317. package/dist/runtime/native/paths.js +0 -7
  318. package/dist/runtime/native/pi-extension.d.ts +0 -36
  319. package/dist/runtime/native/pi-link.d.ts +0 -69
  320. package/dist/runtime/native/pi-link.js +0 -269
  321. package/dist/runtime/native/results.d.ts +0 -41
  322. package/dist/runtime/native/results.js +0 -128
  323. package/dist/runtime/native/sessions.d.ts +0 -45
  324. package/dist/runtime/native/sessions.js +0 -87
  325. package/dist/runtime/native/transcript.d.ts +0 -89
  326. package/dist/runtime/native/transcript.js +0 -656
  327. package/dist/runtime/native/translate.d.ts +0 -46
  328. package/dist/runtime/native/translate.js +0 -299
  329. package/dist/runtime/native/transport.d.ts +0 -7
  330. package/dist/runtime/native/transport.js +0 -16
  331. package/dist/runtime/native/version.d.ts +0 -5
  332. package/dist/runtime/native/version.js +0 -21
  333. package/dist/runtime/preferences.d.ts +0 -7
  334. package/dist/runtime/preferences.js +0 -22
  335. package/dist/runtime/presentation.d.ts +0 -32
  336. package/dist/runtime/presentation.js +0 -124
  337. package/dist/runtime/process-group.d.ts +0 -5
  338. package/dist/runtime/process-group.js +0 -161
  339. package/dist/runtime/projection-store.d.ts +0 -27
  340. package/dist/runtime/projection-store.js +0 -30
  341. package/dist/runtime/space-binding.d.ts +0 -48
  342. package/dist/runtime/space-binding.js +0 -342
  343. package/dist/runtime/supervisor.d.ts +0 -19
  344. package/dist/runtime/supervisor.js +0 -441
  345. package/dist/runtime/turn-projection.d.ts +0 -41
  346. package/dist/runtime/turn-projection.js +0 -120
  347. package/dist/runtime/worker.d.ts +0 -1
  348. package/dist/safe-remote-image.d.ts +0 -36
  349. package/dist/safe-remote-image.js +0 -191
  350. package/dist/self-update.d.ts +0 -7
  351. package/dist/self-update.js +0 -202
  352. package/dist/session-status.d.ts +0 -10
  353. package/dist/session-status.js +0 -25
  354. package/dist/space-files/limit.d.ts +0 -2
  355. package/dist/space-files/limit.js +0 -16
  356. package/dist/space-files/operands.d.ts +0 -17
  357. package/dist/space-files/operands.js +0 -33
  358. package/dist/space-files/transfer.d.ts +0 -53
  359. package/dist/space-files/transfer.js +0 -297
  360. package/dist/space-files/upload.d.ts +0 -17
  361. package/dist/space-files/upload.js +0 -76
  362. package/dist/space.d.ts +0 -44
  363. package/dist/space.js +0 -192
  364. package/dist/version.d.ts +0 -2
  365. package/dist/version.js +0 -17
  366. package/dist/web.d.ts +0 -1
  367. package/dist/web.js +0 -4
  368. /package/dist/{board-kernel → chunks}/lexer.js +0 -0
@@ -0,0 +1,221 @@
1
+ //#region ../protocol/src/generation/policy.ts
2
+ const GENERATION_POLICY_ENV_KEY = "COHUB_GENERATION_POLICY_B64";
3
+ var GenerationPolicyError = class extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = "GenerationPolicyError";
7
+ }
8
+ };
9
+ function isRecord(value) {
10
+ return !!value && typeof value === "object" && !Array.isArray(value);
11
+ }
12
+ function isPrimitiveEnumValue(value) {
13
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
14
+ }
15
+ function normalizeConstraint(value) {
16
+ if (!isRecord(value) || typeof value.kind !== "string") return null;
17
+ if (value.kind === "enum") {
18
+ if (!Array.isArray(value.values) || value.values.length === 0 || !value.values.every(isPrimitiveEnumValue)) return null;
19
+ return {
20
+ kind: "enum",
21
+ values: value.values
22
+ };
23
+ }
24
+ if (value.kind === "number" || value.kind === "integer") {
25
+ const result = { kind: value.kind };
26
+ if (typeof value.min === "number" && Number.isFinite(value.min)) result.min = value.min;
27
+ if (typeof value.max === "number" && Number.isFinite(value.max)) result.max = value.max;
28
+ if (result.min !== void 0 && result.max !== void 0 && result.min > result.max) return null;
29
+ if (Array.isArray(value.values) && value.values.every((item) => typeof item === "number" && Number.isFinite(item))) {
30
+ if (value.kind === "integer" && !value.values.every(Number.isInteger)) return null;
31
+ const min = result.min;
32
+ const max = result.max;
33
+ if (min !== void 0 && value.values.some((item) => item < min)) return null;
34
+ if (max !== void 0 && value.values.some((item) => item > max)) return null;
35
+ result.values = value.values;
36
+ }
37
+ return result;
38
+ }
39
+ if (value.kind === "boolean") return typeof value.value === "boolean" ? {
40
+ kind: "boolean",
41
+ value: value.value
42
+ } : { kind: "boolean" };
43
+ return null;
44
+ }
45
+ function normalizeGenerationPolicy(value) {
46
+ if (!isRecord(value) || value.version !== 1) return null;
47
+ if (value.mode === "auto") return {
48
+ version: 1,
49
+ mode: "auto"
50
+ };
51
+ if (value.mode !== "limited" || !Array.isArray(value.models) || value.models.length === 0) return null;
52
+ const models = [];
53
+ for (const item of value.models) {
54
+ if (!isRecord(item) || typeof item.model !== "string" || !item.model.trim()) return null;
55
+ const modelPolicy = { model: item.model.trim() };
56
+ if (item.parameters !== void 0) {
57
+ if (!isRecord(item.parameters)) return null;
58
+ const parameters = {};
59
+ for (const [key, rawConstraint] of Object.entries(item.parameters)) {
60
+ if (!key.trim()) return null;
61
+ const constraint = normalizeConstraint(rawConstraint);
62
+ if (!constraint) return null;
63
+ parameters[key] = constraint;
64
+ }
65
+ if (Object.keys(parameters).length > 0) modelPolicy.parameters = parameters;
66
+ }
67
+ models.push(modelPolicy);
68
+ }
69
+ return {
70
+ version: 1,
71
+ mode: "limited",
72
+ models
73
+ };
74
+ }
75
+ function base64ToBytes(value) {
76
+ const binary = atob(value);
77
+ const bytes = new Uint8Array(binary.length);
78
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
79
+ return bytes;
80
+ }
81
+ function fromBase64Url(value) {
82
+ const base64 = value.replaceAll("-", "+").replaceAll("_", "/");
83
+ const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
84
+ return new TextDecoder().decode(base64ToBytes(padded));
85
+ }
86
+ function decodeGenerationPolicy(value) {
87
+ try {
88
+ return normalizeGenerationPolicy(JSON.parse(fromBase64Url(value)));
89
+ } catch {
90
+ return null;
91
+ }
92
+ }
93
+ function parseGenerationPolicyFromEnv(env) {
94
+ const value = env[GENERATION_POLICY_ENV_KEY]?.trim();
95
+ return value ? decodeGenerationPolicy(value) : null;
96
+ }
97
+ function getAllowedGenerationModelIds(policy) {
98
+ if (!policy || policy.mode === "auto") return null;
99
+ return [...new Set((policy.models ?? []).map((item) => item.model))];
100
+ }
101
+ function findGenerationModelPolicy(policy, model) {
102
+ if (!policy || policy.mode === "auto") return null;
103
+ return policy.models?.find((item) => item.model === model) ?? null;
104
+ }
105
+ function formatList(values) {
106
+ return values.map((value) => `- ${String(value)}`).join("\n");
107
+ }
108
+ function modelNotSupportedMessage(allowedModels) {
109
+ return [
110
+ "This turn supports the following generation models:",
111
+ "",
112
+ formatList(allowedModels),
113
+ "",
114
+ "Choose one of these models or update Generation settings in the Models panel."
115
+ ].join("\n");
116
+ }
117
+ function valuesNotSupportedMessage(model, name, values, received) {
118
+ return [
119
+ `This turn supports selected values for ${model}.${name}:`,
120
+ "",
121
+ formatList(values),
122
+ "",
123
+ "Received:",
124
+ `- ${String(received)}`
125
+ ].join("\n");
126
+ }
127
+ function rangeNotSupportedMessage(model, name, min, max, received) {
128
+ return [
129
+ `This turn supports ${model}.${name} in the range ${min !== void 0 && max !== void 0 ? `${min}–${max}` : min !== void 0 ? `at least ${min}` : `at most ${max}`}.`,
130
+ "",
131
+ "Received:",
132
+ `- ${String(received)}`
133
+ ].join("\n");
134
+ }
135
+ function booleanNotSupportedMessage(model, name, expected, received) {
136
+ return [
137
+ `This turn supports ${model}.${name}=${String(expected)}.`,
138
+ "",
139
+ "Received:",
140
+ `- ${String(received)}`
141
+ ].join("\n");
142
+ }
143
+ function sameEnumValue(a, b) {
144
+ return typeof a === typeof b && a === b;
145
+ }
146
+ function validateConstraint(input) {
147
+ const { model, name, value, constraint } = input;
148
+ if (constraint.kind === "enum") {
149
+ if (!constraint.values.some((item) => sameEnumValue(item, value))) throw new GenerationPolicyError(valuesNotSupportedMessage(model, name, constraint.values, value));
150
+ return;
151
+ }
152
+ if (constraint.kind === "number" || constraint.kind === "integer") {
153
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
154
+ if (constraint.kind === "integer" && !Number.isInteger(value)) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
155
+ if (constraint.values?.length && !constraint.values.includes(value)) throw new GenerationPolicyError(valuesNotSupportedMessage(model, name, constraint.values, value));
156
+ if (constraint.min !== void 0 && value < constraint.min) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
157
+ if (constraint.max !== void 0 && value > constraint.max) throw new GenerationPolicyError(rangeNotSupportedMessage(model, name, constraint.min, constraint.max, value));
158
+ return;
159
+ }
160
+ if (constraint.kind === "boolean" && constraint.value !== void 0 && value !== constraint.value) throw new GenerationPolicyError(booleanNotSupportedMessage(model, name, constraint.value, value));
161
+ }
162
+ function assertGenerationRequestAllowedByPolicy(input) {
163
+ const allowedModels = getAllowedGenerationModelIds(input.policy);
164
+ if (!allowedModels) return;
165
+ const modelPolicy = findGenerationModelPolicy(input.policy, input.model);
166
+ if (!modelPolicy) throw new GenerationPolicyError(modelNotSupportedMessage(allowedModels));
167
+ const parameters = input.parameters ?? {};
168
+ for (const [name, value] of Object.entries(parameters)) {
169
+ const constraint = modelPolicy.parameters?.[name];
170
+ if (!constraint) continue;
171
+ validateConstraint({
172
+ model: input.model,
173
+ name,
174
+ value,
175
+ constraint
176
+ });
177
+ }
178
+ }
179
+ function cloneDeclaration(declaration) {
180
+ return {
181
+ ...declaration,
182
+ content: {
183
+ ...declaration.content,
184
+ input: [...declaration.content.input]
185
+ },
186
+ parameters: declaration.parameters ? Object.fromEntries(Object.entries(declaration.parameters).map(([key, value]) => [key, { ...value }])) : declaration.parameters,
187
+ examples: declaration.examples ? [...declaration.examples] : declaration.examples
188
+ };
189
+ }
190
+ function narrowParameterSpec(spec, constraint) {
191
+ const next = { ...spec };
192
+ if (constraint.kind === "enum") {
193
+ if ("enum" in next && Array.isArray(next.enum)) next.enum = next.enum.filter((value) => constraint.values.some((allowed) => sameEnumValue(allowed, value)));
194
+ return next;
195
+ }
196
+ if (constraint.kind === "number" || constraint.kind === "integer") {
197
+ if ("min" in next && typeof next.min === "number" && constraint.min !== void 0) next.min = Math.max(next.min, constraint.min);
198
+ else if ("min" in next && constraint.min !== void 0) next.min = constraint.min;
199
+ if ("max" in next && typeof next.max === "number" && constraint.max !== void 0) next.max = Math.min(next.max, constraint.max);
200
+ else if ("max" in next && constraint.max !== void 0) next.max = constraint.max;
201
+ if (constraint.values?.length && "enum" in next && Array.isArray(next.enum)) next.enum = next.enum.filter((value) => constraint.values?.some((allowed) => sameEnumValue(allowed, value)));
202
+ }
203
+ return next;
204
+ }
205
+ function filterGenerationDeclarationsByPolicy(declarations, policy) {
206
+ const allowedModels = getAllowedGenerationModelIds(policy);
207
+ if (!allowedModels) return declarations;
208
+ const allowedSet = new Set(allowedModels);
209
+ return declarations.filter((declaration) => allowedSet.has(declaration.model)).map((declaration) => {
210
+ const cloned = cloneDeclaration(declaration);
211
+ const modelPolicy = findGenerationModelPolicy(policy, declaration.model);
212
+ if (!modelPolicy?.parameters || !cloned.parameters) return cloned;
213
+ for (const [name, constraint] of Object.entries(modelPolicy.parameters)) {
214
+ const spec = cloned.parameters[name];
215
+ if (spec) cloned.parameters[name] = narrowParameterSpec(spec, constraint);
216
+ }
217
+ return cloned;
218
+ });
219
+ }
220
+ //#endregion
221
+ export { parseGenerationPolicyFromEnv as a, getAllowedGenerationModelIds as i, assertGenerationRequestAllowedByPolicy as n, filterGenerationDeclarationsByPolicy as r, GenerationPolicyError as t };
@@ -0,0 +1,29 @@
1
+ import { homedir } from "node:os";
2
+ import { dirname, join } from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
5
+ //#region src/runtime/preferences.ts
6
+ const DEFAULTS = { keepAwake: true };
7
+ const runtimePreferencesPath = () => join(homedir(), ".config", "cohub", "runtime-preferences.json");
8
+ async function readRuntimePreferences(path = runtimePreferencesPath()) {
9
+ const keepAwake = (await readFile(path, "utf8").then(JSON.parse).catch(() => null))?.keepAwake;
10
+ return { keepAwake: typeof keepAwake === "boolean" ? keepAwake : DEFAULTS.keepAwake };
11
+ }
12
+ async function writeRuntimePreferences(preferences, path = runtimePreferencesPath()) {
13
+ await mkdir(dirname(path), {
14
+ recursive: true,
15
+ mode: 448
16
+ });
17
+ const temporary = `${path}.${randomUUID()}.tmp`;
18
+ try {
19
+ await writeFile(temporary, `${JSON.stringify(preferences, null, 2)}\n`, {
20
+ mode: 384,
21
+ flag: "wx"
22
+ });
23
+ await rename(temporary, path);
24
+ } finally {
25
+ await rm(temporary, { force: true });
26
+ }
27
+ }
28
+ //#endregion
29
+ export { writeRuntimePreferences as n, readRuntimePreferences as t };
@@ -0,0 +1,64 @@
1
+ import { C as error, D as json, E as handleHttp, O as jsonRequested, k as ok, t as createClient } from "./client.js";
2
+ import { t as uploadAvatarAsset } from "./avatar.js";
3
+ //#region src/commands/profile.ts
4
+ function registerProfile(program) {
5
+ const profileCmd = program.command("profile").description("Manage your profile");
6
+ profileCmd.command("get <username>").description("Show a public user profile").option("--json", "Output as JSON").action(async (username, opts) => {
7
+ const client = createClient();
8
+ try {
9
+ const result = await client.users.getByUsername(username);
10
+ if (jsonRequested(opts)) return json(result);
11
+ const handle = result.profile.username ? `@${result.profile.username}` : result.profile.userUuid;
12
+ console.log(`\n ${result.profile.displayName} (${handle})`);
13
+ console.log(` Spaces: ${result.spaces.length}`);
14
+ console.log(` Apps: ${result.apps.length}\n`);
15
+ if (result.spaces.length > 0) {
16
+ console.log(" Spaces:");
17
+ for (const space of result.spaces) console.log(` - ${space.name} [${space.accessLabel}] ${space.spaceUrl}`);
18
+ console.log("");
19
+ }
20
+ if (result.apps.length > 0) {
21
+ console.log(" Apps:");
22
+ for (const app of result.apps) console.log(` - ${app.title} ${app.publicUrl}`);
23
+ console.log("");
24
+ }
25
+ } catch (e) {
26
+ handleHttp(e);
27
+ }
28
+ });
29
+ profileCmd.command("update").description("Update your profile").option("--username <username>", "Public username").option("--display-name <name>", "Display name").option("--json", "Output as JSON").action(async (opts) => {
30
+ const input = {
31
+ username: opts.username,
32
+ displayName: opts.displayName
33
+ };
34
+ if (input.username === void 0 && input.displayName === void 0) return error("Nothing to update", "Pass --username or --display-name.");
35
+ const client = createClient();
36
+ try {
37
+ const result = await client.user.updateProfile(input);
38
+ if (jsonRequested(opts)) return json(result);
39
+ ok("Profile updated");
40
+ } catch (e) {
41
+ handleHttp(e);
42
+ }
43
+ });
44
+ profileCmd.command("avatar <path>").description("Upload your avatar").option("--json", "Output as JSON").action(async (path, opts) => {
45
+ const client = createClient();
46
+ try {
47
+ const asset = await uploadAvatarAsset({
48
+ client,
49
+ purpose: "user_avatar",
50
+ path
51
+ });
52
+ const result = await client.user.updateProfile({ avatarUrl: asset.publicUrl });
53
+ if (jsonRequested(opts)) return json({
54
+ ...result,
55
+ asset
56
+ });
57
+ ok("Avatar updated");
58
+ } catch (e) {
59
+ handleHttp(e);
60
+ }
61
+ });
62
+ }
63
+ //#endregion
64
+ export { registerProfile };
@@ -0,0 +1,41 @@
1
+ import { D as json, E as handleHttp, O as jsonRequested, j as table, t as createClient } from "./client.js";
2
+ //#region src/commands/prompts.ts
3
+ function registerPrompts(program) {
4
+ program.command("prompts").description("Prompt template management").command("ls").alias("list").description("List prompt templates").option("--space <id>", "Filter by space").option("--json", "Output as JSON").action(async (opts) => {
5
+ const client = createClient();
6
+ try {
7
+ const spaceId = opts.space ?? program.opts().space;
8
+ const result = await client.prompts.list({ spaceId });
9
+ if (jsonRequested(opts)) return json(result);
10
+ if (result.prompts.length === 0) return console.log(" (empty)");
11
+ table(result.prompts.map((prompt) => ({
12
+ command: `/${prompt.name}`,
13
+ name: prompt.name,
14
+ scope: prompt.scope,
15
+ category: prompt.category ?? "",
16
+ description: prompt.description
17
+ })), [
18
+ {
19
+ key: "command",
20
+ label: "Command"
21
+ },
22
+ {
23
+ key: "scope",
24
+ label: "Scope"
25
+ },
26
+ {
27
+ key: "category",
28
+ label: "Category"
29
+ },
30
+ {
31
+ key: "description",
32
+ label: "Description"
33
+ }
34
+ ]);
35
+ } catch (e) {
36
+ handleHttp(e);
37
+ }
38
+ });
39
+ }
40
+ //#endregion
41
+ export { registerPrompts };
@@ -0,0 +1,2 @@
1
+ import { n as registerPublic } from "./public2.js";
2
+ export { registerPublic };
@@ -0,0 +1,244 @@
1
+ import { C as error, D as json, E as handleHttp, O as jsonRequested, b as resolveSpace, t as createClient } from "./client.js";
2
+ import { a as isTextMime, o as mimeTypeForPath } from "./id.js";
3
+ import { r as mediaFacts } from "./media.js";
4
+ import { t as localMediaFacts } from "./local-media.js";
5
+ import { r as putLocalFile, t as HttpPutError } from "./http-put.js";
6
+ import { basename, relative, resolve } from "node:path";
7
+ import { randomUUID } from "node:crypto";
8
+ import { lstat, readdir } from "node:fs/promises";
9
+ //#region src/commands/public.ts
10
+ const UPLOAD_CONCURRENCY = 4;
11
+ function hasControlCharacters(value) {
12
+ return [...value].some((char) => {
13
+ const code = char.charCodeAt(0);
14
+ return code <= 31 || code >= 127 && code <= 159;
15
+ });
16
+ }
17
+ function terminalText(value) {
18
+ return [...value].map((char) => {
19
+ const code = char.charCodeAt(0);
20
+ return code <= 31 || code >= 127 && code <= 159 ? `\\u${code.toString(16).padStart(4, "0")}` : char;
21
+ }).join("");
22
+ }
23
+ function normalizePublicPath(input) {
24
+ const value = input.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
25
+ if (!value || value.startsWith("/") || hasControlCharacters(value)) return error("Invalid public path");
26
+ const parts = value.split("/");
27
+ if (parts.some((part) => !part || part === "." || part === "..")) return error("Invalid public path");
28
+ return parts.join("/");
29
+ }
30
+ function contentTypeForPath(path) {
31
+ const mimeType = mimeTypeForPath(path);
32
+ if (!mimeType) return "application/octet-stream";
33
+ return isTextMime(mimeType) ? `${mimeType}; charset=utf-8` : mimeType;
34
+ }
35
+ async function walkDirectory(root, directory, destination) {
36
+ const names = await readdir(directory);
37
+ names.sort((left, right) => left.localeCompare(right));
38
+ const files = [];
39
+ for (const name of names) {
40
+ const localPath = resolve(directory, name);
41
+ const info = await lstat(localPath);
42
+ if (info.isSymbolicLink()) return error("Symlinks are not supported", relative(root, localPath));
43
+ if (info.isDirectory()) {
44
+ files.push(...await walkDirectory(root, localPath, destination));
45
+ continue;
46
+ }
47
+ if (!info.isFile()) continue;
48
+ const publicPath = normalizePublicPath(`${destination}/${relative(root, localPath).replace(/\\/g, "/")}`);
49
+ files.push({
50
+ id: randomUUID(),
51
+ localPath,
52
+ publicPath,
53
+ size: info.size,
54
+ mimeType: contentTypeForPath(localPath)
55
+ });
56
+ }
57
+ return files;
58
+ }
59
+ async function collectPublicUpload(source, destination) {
60
+ const localPath = resolve(source);
61
+ const info = await lstat(localPath).catch(() => null);
62
+ if (!info) return error("Source not found", source);
63
+ if (info.isSymbolicLink()) return error("Symlinks are not supported", source);
64
+ if (info.isFile()) {
65
+ const publicPath = normalizePublicPath(destination ? destination.endsWith("/") ? `${destination}${basename(localPath)}` : destination : basename(localPath));
66
+ return {
67
+ destination: publicPath,
68
+ entryPath: publicPath,
69
+ files: [{
70
+ id: randomUUID(),
71
+ localPath,
72
+ publicPath,
73
+ size: info.size,
74
+ mimeType: contentTypeForPath(localPath)
75
+ }]
76
+ };
77
+ }
78
+ if (!info.isDirectory()) return error("Source must be a file or directory", source);
79
+ const target = normalizePublicPath(destination ?? basename(localPath));
80
+ const files = await walkDirectory(localPath, localPath, target);
81
+ if (files.length === 0) return error("Directory contains no files", source);
82
+ const indexPath = `${target}/index.html`;
83
+ return {
84
+ files,
85
+ destination: `${target}/`,
86
+ entryPath: files.some((file) => file.publicPath === indexPath) ? indexPath : null
87
+ };
88
+ }
89
+ async function mapSettledWithConcurrency(items, concurrency, mapper) {
90
+ const errors = [];
91
+ let nextIndex = 0;
92
+ const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
93
+ while (nextIndex < items.length) {
94
+ const index = nextIndex++;
95
+ try {
96
+ await mapper(items[index]);
97
+ } catch (cause) {
98
+ errors.push(cause instanceof Error ? cause : new Error(String(cause)));
99
+ }
100
+ }
101
+ });
102
+ await Promise.all(workers);
103
+ return errors;
104
+ }
105
+ async function putPublicFile(file, plan, fetchImpl) {
106
+ try {
107
+ await putLocalFile({
108
+ url: plan.uploadUrl,
109
+ filePath: file.localPath,
110
+ size: file.size,
111
+ headers: plan.headers,
112
+ label: file.publicPath,
113
+ fetch: fetchImpl
114
+ });
115
+ } catch (error) {
116
+ if (error instanceof HttpPutError && (error.status === 409 || error.status === 412)) throw new Error(`${file.publicPath} already exists. Use --overwrite.`);
117
+ throw error;
118
+ }
119
+ }
120
+ async function publicMediaFacts(files) {
121
+ const facts = /* @__PURE__ */ new Map();
122
+ await mapSettledWithConcurrency(files.flatMap((file) => {
123
+ const type = file.mimeType.split("/")[0];
124
+ return type === "image" || type === "video" ? [{
125
+ file,
126
+ type
127
+ }] : [];
128
+ }), UPLOAD_CONCURRENCY, async ({ file, type }) => {
129
+ const found = mediaFacts(await localMediaFacts(file.localPath, type));
130
+ if (found) facts.set(file.id, found);
131
+ });
132
+ return facts;
133
+ }
134
+ function uploadFailure(errors) {
135
+ if (errors.length === 1) return errors[0];
136
+ const first = errors[0]?.message ?? "Upload failed";
137
+ return /* @__PURE__ */ new Error(`${first} (${errors.length} files failed)`);
138
+ }
139
+ function publicUrlPrefix(destination, entry) {
140
+ const encodedPath = entry.path.split("/").map(encodeURIComponent).join("/");
141
+ if (!entry.publicUrl.endsWith(encodedPath)) throw new Error(`Invalid public URL for ${entry.path}`);
142
+ const encodedDestination = destination.split("/").map(encodeURIComponent).join("/");
143
+ return `${entry.publicUrl.slice(0, -encodedPath.length)}${encodedDestination}`;
144
+ }
145
+ async function uploadPublic(command, source, destination, opts, deps) {
146
+ const client = deps.createClient?.() ?? createClient();
147
+ const spaceId = await resolveSpace(command, { home: true });
148
+ try {
149
+ const upload = await collectPublicUpload(source, destination);
150
+ const media = await publicMediaFacts(upload.files);
151
+ const plan = await client.space(spaceId).publicFiles.createUpload({
152
+ overwrite: Boolean(opts.overwrite),
153
+ entries: upload.files.map((file) => ({
154
+ id: file.id,
155
+ relativePath: file.publicPath,
156
+ size: file.size,
157
+ mimeType: file.mimeType,
158
+ ...media.has(file.id) ? { media: media.get(file.id) } : {}
159
+ }))
160
+ });
161
+ if (opts.overwrite && !jsonRequested(opts)) process.stderr.write(`Overwrite enabled for ${upload.destination}\n`);
162
+ const filesById = new Map(upload.files.map((file) => [file.id, file]));
163
+ const plansByPath = new Map(plan.entries.map((entry) => [entry.path, entry]));
164
+ const entryPlan = upload.entryPath ? plansByPath.get(upload.entryPath) : void 0;
165
+ const assetPlans = entryPlan ? plan.entries.filter((entry) => entry.id !== entryPlan.id) : plan.entries;
166
+ const uploadPlans = async (entries) => mapSettledWithConcurrency(entries, UPLOAD_CONCURRENCY, async (entry) => {
167
+ const file = filesById.get(entry.id);
168
+ if (!file) throw new Error(`Missing local file for ${entry.path}`);
169
+ await putPublicFile(file, entry, deps.fetch ?? fetch);
170
+ });
171
+ const assetErrors = await uploadPlans(assetPlans);
172
+ if (assetErrors.length > 0) throw uploadFailure(assetErrors);
173
+ if (entryPlan) {
174
+ const entryErrors = await uploadPlans([entryPlan]);
175
+ if (entryErrors.length > 0) throw uploadFailure(entryErrors);
176
+ }
177
+ const firstPlan = plan.entries[0];
178
+ if (!firstPlan) throw new Error("Upload plan contains no files");
179
+ if (jsonRequested(opts)) {
180
+ json({
181
+ destination: upload.destination,
182
+ urlPrefix: publicUrlPrefix("", firstPlan),
183
+ files: upload.files.map((file) => ({
184
+ path: file.publicPath,
185
+ size: file.size,
186
+ mimeType: file.mimeType
187
+ }))
188
+ });
189
+ return;
190
+ }
191
+ if (entryPlan) {
192
+ console.log(entryPlan.publicUrl);
193
+ return;
194
+ }
195
+ const fileLabel = upload.files.length === 1 ? "file" : "files";
196
+ console.log(`Uploaded ${upload.files.length} ${fileLabel} to ${upload.destination}`);
197
+ console.log(`URL prefix: ${publicUrlPrefix(upload.destination, firstPlan)}`);
198
+ } catch (exception) {
199
+ handleHttp(exception);
200
+ }
201
+ }
202
+ async function listPublic(command, path, opts, deps) {
203
+ const client = deps.createClient?.() ?? createClient();
204
+ try {
205
+ const publicFiles = client.space(await resolveSpace(command, { home: true })).publicFiles;
206
+ const entries = [];
207
+ let cursor;
208
+ do {
209
+ const page = await publicFiles.list(path ?? "", {
210
+ recursive: opts.recursive,
211
+ limit: 1e3,
212
+ cursor
213
+ });
214
+ if (jsonRequested(opts)) entries.push(...page.entries);
215
+ else for (const entry of page.entries) console.log(`${terminalText(entry.name)}${entry.kind === "directory" ? "/" : ""}`);
216
+ cursor = page.nextCursor ?? void 0;
217
+ } while (cursor);
218
+ if (jsonRequested(opts)) return json({
219
+ path: path ?? "",
220
+ entries,
221
+ nextCursor: null
222
+ });
223
+ } catch (exception) {
224
+ handleHttp(exception);
225
+ }
226
+ }
227
+ async function printPublicUrl(command, path, deps) {
228
+ const client = deps.createClient?.() ?? createClient();
229
+ try {
230
+ const result = await client.space(await resolveSpace(command, { home: true })).publicFiles.url(path);
231
+ console.log(result.url);
232
+ } catch (exception) {
233
+ handleHttp(exception);
234
+ }
235
+ }
236
+ function registerPublic(program, deps = {}) {
237
+ const publicCommand = program.command("public").description("Upload and manage public Space files");
238
+ publicCommand.command("upload <source> [destination]").description("Upload a file or directory").option("--overwrite", "Replace existing public files").action((source, destination, opts, command) => uploadPublic(command, source, destination, opts, deps));
239
+ publicCommand.command("ls [path]").description("List public files").option("-r, --recursive", "List files recursively").action((path, opts, command) => listPublic(command, path, opts, deps));
240
+ publicCommand.command("url <path>").description("Print a public file URL").action((path, _opts, command) => printPublicUrl(command, path, deps));
241
+ return publicCommand;
242
+ }
243
+ //#endregion
244
+ export { registerPublic as n, collectPublicUpload as t };