@neta-art/cohub-cli 10.24.0 → 10.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/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/binary-pins.js +5 -0
  14. package/dist/chunks/board-export-resources.js +232 -0
  15. package/dist/chunks/board-export.js +874 -0
  16. package/dist/chunks/board-export2.js +2 -0
  17. package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
  18. package/dist/chunks/board-kernel2.js +4 -0
  19. package/dist/chunks/board-profile.js +69 -0
  20. package/dist/chunks/board-simulate.js +315 -0
  21. package/dist/chunks/board-time.js +34 -0
  22. package/dist/chunks/boards.js +1943 -0
  23. package/dist/{board-kernel → chunks}/browserAll.js +9 -8
  24. package/dist/chunks/channels.js +64 -0
  25. package/dist/chunks/client.js +12606 -0
  26. package/dist/chunks/command-input.js +17 -0
  27. package/dist/chunks/commander.js +2962 -0
  28. package/dist/chunks/cron-jobs.js +163 -0
  29. package/dist/chunks/daemon.js +545 -0
  30. package/dist/chunks/daemon2.js +2 -0
  31. package/dist/chunks/desktop.js +172 -0
  32. package/dist/chunks/endpoint-options.js +26 -0
  33. package/dist/chunks/env-proxy.js +35 -0
  34. package/dist/chunks/environment.js +154 -0
  35. package/dist/chunks/feedback.js +120 -0
  36. package/dist/chunks/generations.js +379 -0
  37. package/dist/chunks/host.js +9 -0
  38. package/dist/chunks/http-put.js +131 -0
  39. package/dist/chunks/id.js +2416 -0
  40. package/dist/{board-kernel → chunks}/init.js +1 -1
  41. package/dist/chunks/install.js +11959 -0
  42. package/dist/chunks/launch.js +374 -0
  43. package/dist/chunks/local-media.js +47 -0
  44. package/dist/chunks/me.js +134 -0
  45. package/dist/chunks/media.js +315 -0
  46. package/dist/chunks/models.js +242 -0
  47. package/dist/chunks/operands.js +46 -0
  48. package/dist/chunks/package-paths.js +13 -0
  49. package/dist/chunks/policy.js +221 -0
  50. package/dist/chunks/preferences.js +29 -0
  51. package/dist/chunks/profile.js +64 -0
  52. package/dist/chunks/prompts.js +41 -0
  53. package/dist/chunks/public.js +2 -0
  54. package/dist/chunks/public2.js +244 -0
  55. package/dist/chunks/references.js +197 -0
  56. package/dist/chunks/referrals.js +90 -0
  57. package/dist/chunks/rolldown-runtime.js +26 -0
  58. package/dist/chunks/rooms-connect.js +2 -0
  59. package/dist/chunks/rooms-connect2.js +151 -0
  60. package/dist/chunks/rooms-rtc.js +311 -0
  61. package/dist/chunks/rooms.js +211 -0
  62. package/dist/chunks/run.js +220 -0
  63. package/dist/chunks/runtime.js +638 -0
  64. package/dist/chunks/runtime2.js +286 -0
  65. package/dist/chunks/runtimes.js +48 -0
  66. package/dist/chunks/safe-remote-image.js +198 -0
  67. package/dist/chunks/schemas.js +6017 -0
  68. package/dist/chunks/search.js +113 -0
  69. package/dist/chunks/self-update.js +238 -0
  70. package/dist/chunks/serve.js +1246 -0
  71. package/dist/chunks/session-status.js +24 -0
  72. package/dist/chunks/skills.js +35 -0
  73. package/dist/chunks/spaces.js +5080 -0
  74. package/dist/chunks/src.js +405 -0
  75. package/dist/chunks/supervisor.js +2513 -0
  76. package/dist/chunks/supervisor2.js +2 -0
  77. package/dist/chunks/tasks.js +82 -0
  78. package/dist/chunks/themes.js +2898 -0
  79. package/dist/chunks/version.js +2 -0
  80. package/dist/chunks/version2.js +22 -0
  81. package/dist/chunks/version3.js +18 -0
  82. package/dist/chunks/web.js +7 -0
  83. package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
  84. package/dist/runtime/native/pi-extension.js +174 -166
  85. package/dist/runtime/worker.js +27 -16
  86. package/package.json +8 -9
  87. package/dist/about.d.ts +0 -2
  88. package/dist/about.js +0 -71
  89. package/dist/app-download.d.ts +0 -11
  90. package/dist/app-download.js +0 -252
  91. package/dist/app-ref.d.ts +0 -5
  92. package/dist/app-ref.js +0 -8
  93. package/dist/app-target.d.ts +0 -26
  94. package/dist/app-target.js +0 -55
  95. package/dist/auth.d.ts +0 -45
  96. package/dist/auth.js +0 -307
  97. package/dist/avatar.d.ts +0 -55
  98. package/dist/avatar.js +0 -104
  99. package/dist/board-command-support.d.ts +0 -6
  100. package/dist/board-command-support.js +0 -88
  101. package/dist/board-export-resources.d.ts +0 -12
  102. package/dist/board-export-resources.js +0 -51
  103. package/dist/board-export.d.ts +0 -110
  104. package/dist/board-export.js +0 -592
  105. package/dist/board-fonts.d.ts +0 -11
  106. package/dist/board-fonts.js +0 -10
  107. package/dist/board-gpu/daemon.d.ts +0 -11
  108. package/dist/board-gpu/daemon.js +0 -295
  109. package/dist/board-gpu/index.d.ts +0 -33
  110. package/dist/board-gpu/index.js +0 -189
  111. package/dist/board-gpu/protocol.d.ts +0 -77
  112. package/dist/board-gpu/protocol.js +0 -1
  113. package/dist/board-kernel.d.ts +0 -5
  114. package/dist/board-media-export.d.ts +0 -17
  115. package/dist/board-media-export.js +0 -164
  116. package/dist/board-media.d.ts +0 -5
  117. package/dist/board-media.js +0 -66
  118. package/dist/board-profile.d.ts +0 -21
  119. package/dist/board-profile.js +0 -67
  120. package/dist/board-simulate.d.ts +0 -67
  121. package/dist/board-simulate.js +0 -259
  122. package/dist/board-time.d.ts +0 -3
  123. package/dist/board-time.js +0 -34
  124. package/dist/bootstrap.d.ts +0 -2
  125. package/dist/client.d.ts +0 -5
  126. package/dist/client.js +0 -24
  127. package/dist/command-input.d.ts +0 -4
  128. package/dist/command-input.js +0 -16
  129. package/dist/commands/app-commerce.d.ts +0 -2
  130. package/dist/commands/app-commerce.js +0 -228
  131. package/dist/commands/app-domains.d.ts +0 -2
  132. package/dist/commands/app-domains.js +0 -133
  133. package/dist/commands/apps.d.ts +0 -4
  134. package/dist/commands/apps.js +0 -827
  135. package/dist/commands/auth.d.ts +0 -2
  136. package/dist/commands/auth.js +0 -186
  137. package/dist/commands/boards/authoring.d.ts +0 -2
  138. package/dist/commands/boards/authoring.js +0 -166
  139. package/dist/commands/boards/examples.d.ts +0 -10
  140. package/dist/commands/boards/examples.js +0 -118
  141. package/dist/commands/boards.d.ts +0 -13
  142. package/dist/commands/boards.js +0 -836
  143. package/dist/commands/channels.d.ts +0 -2
  144. package/dist/commands/channels.js +0 -74
  145. package/dist/commands/cron-jobs.d.ts +0 -2
  146. package/dist/commands/cron-jobs.js +0 -155
  147. package/dist/commands/decision.d.ts +0 -4
  148. package/dist/commands/decision.js +0 -113
  149. package/dist/commands/desktop.d.ts +0 -10
  150. package/dist/commands/desktop.js +0 -233
  151. package/dist/commands/feedback.d.ts +0 -2
  152. package/dist/commands/feedback.js +0 -131
  153. package/dist/commands/generations.d.ts +0 -2
  154. package/dist/commands/generations.js +0 -427
  155. package/dist/commands/host.d.ts +0 -2
  156. package/dist/commands/host.js +0 -11
  157. package/dist/commands/me.d.ts +0 -2
  158. package/dist/commands/me.js +0 -121
  159. package/dist/commands/models.d.ts +0 -28
  160. package/dist/commands/models.js +0 -271
  161. package/dist/commands/profile.d.ts +0 -2
  162. package/dist/commands/profile.js +0 -81
  163. package/dist/commands/prompts.d.ts +0 -2
  164. package/dist/commands/prompts.js +0 -37
  165. package/dist/commands/public.d.ts +0 -20
  166. package/dist/commands/public.js +0 -291
  167. package/dist/commands/references.d.ts +0 -2
  168. package/dist/commands/references.js +0 -193
  169. package/dist/commands/referrals.d.ts +0 -2
  170. package/dist/commands/referrals.js +0 -88
  171. package/dist/commands/rooms-connect.d.ts +0 -17
  172. package/dist/commands/rooms-connect.js +0 -140
  173. package/dist/commands/rooms-rtc-binary.d.ts +0 -2
  174. package/dist/commands/rooms-rtc-binary.js +0 -107
  175. package/dist/commands/rooms-rtc.d.ts +0 -21
  176. package/dist/commands/rooms-rtc.js +0 -171
  177. package/dist/commands/rooms.d.ts +0 -3
  178. package/dist/commands/rooms.js +0 -277
  179. package/dist/commands/run.d.ts +0 -13
  180. package/dist/commands/run.js +0 -246
  181. package/dist/commands/runtime.d.ts +0 -3
  182. package/dist/commands/runtime.js +0 -320
  183. package/dist/commands/sandboxd-binary.d.ts +0 -11
  184. package/dist/commands/sandboxd-binary.js +0 -238
  185. package/dist/commands/search.d.ts +0 -2
  186. package/dist/commands/search.js +0 -114
  187. package/dist/commands/session-access.d.ts +0 -2
  188. package/dist/commands/session-access.js +0 -70
  189. package/dist/commands/skills.d.ts +0 -2
  190. package/dist/commands/skills.js +0 -34
  191. package/dist/commands/space-activity.d.ts +0 -26
  192. package/dist/commands/space-activity.js +0 -147
  193. package/dist/commands/space-commerce.d.ts +0 -2
  194. package/dist/commands/space-commerce.js +0 -514
  195. package/dist/commands/space-displays.d.ts +0 -2
  196. package/dist/commands/space-displays.js +0 -620
  197. package/dist/commands/space-files.d.ts +0 -5
  198. package/dist/commands/space-files.js +0 -215
  199. package/dist/commands/space-invitations.d.ts +0 -29
  200. package/dist/commands/space-invitations.js +0 -189
  201. package/dist/commands/space-turns.d.ts +0 -49
  202. package/dist/commands/space-turns.js +0 -205
  203. package/dist/commands/space-wallet.d.ts +0 -2
  204. package/dist/commands/space-wallet.js +0 -141
  205. package/dist/commands/space-webhooks.d.ts +0 -7
  206. package/dist/commands/space-webhooks.js +0 -73
  207. package/dist/commands/spaces.d.ts +0 -25
  208. package/dist/commands/spaces.js +0 -2170
  209. package/dist/commands/tasks.d.ts +0 -8
  210. package/dist/commands/tasks.js +0 -80
  211. package/dist/commands/version.d.ts +0 -2
  212. package/dist/commands/version.js +0 -21
  213. package/dist/endpoint-options.d.ts +0 -4
  214. package/dist/endpoint-options.js +0 -26
  215. package/dist/env-proxy.d.ts +0 -5
  216. package/dist/env-proxy.js +0 -20
  217. package/dist/help-path.d.ts +0 -18
  218. package/dist/help-path.js +0 -223
  219. package/dist/host/auth.d.ts +0 -20
  220. package/dist/host/auth.js +0 -119
  221. package/dist/host/login-env.d.ts +0 -1
  222. package/dist/host/login-env.js +0 -31
  223. package/dist/host/runtime.d.ts +0 -35
  224. package/dist/host/runtime.js +0 -395
  225. package/dist/host/runtimes.d.ts +0 -9
  226. package/dist/host/runtimes.js +0 -42
  227. package/dist/host/serve.d.ts +0 -2
  228. package/dist/host/serve.js +0 -117
  229. package/dist/host/workspaces.d.ts +0 -2
  230. package/dist/host/workspaces.js +0 -18
  231. package/dist/http-put.d.ts +0 -25
  232. package/dist/http-put.js +0 -132
  233. package/dist/index.d.ts +0 -2
  234. package/dist/index.js +0 -129
  235. package/dist/launcher.d.ts +0 -4
  236. package/dist/launcher.js +0 -38
  237. package/dist/local-media.d.ts +0 -2
  238. package/dist/local-media.js +0 -30
  239. package/dist/network-error.d.ts +0 -3
  240. package/dist/network-error.js +0 -22
  241. package/dist/output.d.ts +0 -46
  242. package/dist/output.js +0 -244
  243. package/dist/runtime/archive-store.d.ts +0 -54
  244. package/dist/runtime/archive-store.js +0 -379
  245. package/dist/runtime/cli-path.d.ts +0 -5
  246. package/dist/runtime/cli-path.js +0 -27
  247. package/dist/runtime/codex-usage.d.ts +0 -7
  248. package/dist/runtime/codex-usage.js +0 -11
  249. package/dist/runtime/connection.d.ts +0 -42
  250. package/dist/runtime/connection.js +0 -789
  251. package/dist/runtime/diagnostics.d.ts +0 -107
  252. package/dist/runtime/diagnostics.js +0 -392
  253. package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
  254. package/dist/runtime/harnesses/chained-projection.js +0 -95
  255. package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
  256. package/dist/runtime/harnesses/chained-transcript.js +0 -62
  257. package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
  258. package/dist/runtime/harnesses/claude-approval.js +0 -124
  259. package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
  260. package/dist/runtime/harnesses/claude-transcript.js +0 -138
  261. package/dist/runtime/harnesses/claude.d.ts +0 -8
  262. package/dist/runtime/harnesses/claude.js +0 -225
  263. package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
  264. package/dist/runtime/harnesses/codex-approval.js +0 -69
  265. package/dist/runtime/harnesses/codex.d.ts +0 -4
  266. package/dist/runtime/harnesses/codex.js +0 -269
  267. package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
  268. package/dist/runtime/harnesses/cursor-transcript.js +0 -183
  269. package/dist/runtime/harnesses/cursor.d.ts +0 -24
  270. package/dist/runtime/harnesses/cursor.js +0 -620
  271. package/dist/runtime/harnesses/index.d.ts +0 -16
  272. package/dist/runtime/harnesses/index.js +0 -73
  273. package/dist/runtime/harnesses/pi.d.ts +0 -4
  274. package/dist/runtime/harnesses/pi.js +0 -247
  275. package/dist/runtime/harnesses/process.d.ts +0 -31
  276. package/dist/runtime/harnesses/process.js +0 -75
  277. package/dist/runtime/harnesses/stream-json.d.ts +0 -48
  278. package/dist/runtime/harnesses/stream-json.js +0 -336
  279. package/dist/runtime/harnesses/types.d.ts +0 -117
  280. package/dist/runtime/harnesses/types.js +0 -1
  281. package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
  282. package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
  283. package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
  284. package/dist/runtime/harnesses/workbuddy.js +0 -123
  285. package/dist/runtime/instance.d.ts +0 -20
  286. package/dist/runtime/instance.js +0 -247
  287. package/dist/runtime/json-rpc.d.ts +0 -53
  288. package/dist/runtime/json-rpc.js +0 -212
  289. package/dist/runtime/launch.d.ts +0 -25
  290. package/dist/runtime/launch.js +0 -247
  291. package/dist/runtime/local-workspace.d.ts +0 -15
  292. package/dist/runtime/local-workspace.js +0 -52
  293. package/dist/runtime/model-catalog.d.ts +0 -12
  294. package/dist/runtime/model-catalog.js +0 -84
  295. package/dist/runtime/native/adapters.d.ts +0 -15
  296. package/dist/runtime/native/adapters.js +0 -11
  297. package/dist/runtime/native/approvals.d.ts +0 -18
  298. package/dist/runtime/native/approvals.js +0 -54
  299. package/dist/runtime/native/archive.d.ts +0 -19
  300. package/dist/runtime/native/archive.js +0 -142
  301. package/dist/runtime/native/attach.d.ts +0 -36
  302. package/dist/runtime/native/attach.js +0 -128
  303. package/dist/runtime/native/codex-link.d.ts +0 -60
  304. package/dist/runtime/native/codex-link.js +0 -322
  305. package/dist/runtime/native/config.d.ts +0 -16
  306. package/dist/runtime/native/config.js +0 -24
  307. package/dist/runtime/native/daemon.d.ts +0 -92
  308. package/dist/runtime/native/daemon.js +0 -380
  309. package/dist/runtime/native/execution.d.ts +0 -26
  310. package/dist/runtime/native/execution.js +0 -34
  311. package/dist/runtime/native/identity.d.ts +0 -9
  312. package/dist/runtime/native/identity.js +0 -15
  313. package/dist/runtime/native/ingest.d.ts +0 -263
  314. package/dist/runtime/native/ingest.js +0 -884
  315. package/dist/runtime/native/install.d.ts +0 -9
  316. package/dist/runtime/native/install.js +0 -113
  317. package/dist/runtime/native/paths.d.ts +0 -2
  318. package/dist/runtime/native/paths.js +0 -7
  319. package/dist/runtime/native/pi-extension.d.ts +0 -36
  320. package/dist/runtime/native/pi-link.d.ts +0 -69
  321. package/dist/runtime/native/pi-link.js +0 -269
  322. package/dist/runtime/native/results.d.ts +0 -41
  323. package/dist/runtime/native/results.js +0 -128
  324. package/dist/runtime/native/sessions.d.ts +0 -45
  325. package/dist/runtime/native/sessions.js +0 -87
  326. package/dist/runtime/native/transcript.d.ts +0 -89
  327. package/dist/runtime/native/transcript.js +0 -656
  328. package/dist/runtime/native/translate.d.ts +0 -46
  329. package/dist/runtime/native/translate.js +0 -299
  330. package/dist/runtime/native/transport.d.ts +0 -7
  331. package/dist/runtime/native/transport.js +0 -16
  332. package/dist/runtime/native/version.d.ts +0 -5
  333. package/dist/runtime/native/version.js +0 -21
  334. package/dist/runtime/preferences.d.ts +0 -7
  335. package/dist/runtime/preferences.js +0 -22
  336. package/dist/runtime/presentation.d.ts +0 -32
  337. package/dist/runtime/presentation.js +0 -124
  338. package/dist/runtime/process-group.d.ts +0 -5
  339. package/dist/runtime/process-group.js +0 -161
  340. package/dist/runtime/projection-store.d.ts +0 -27
  341. package/dist/runtime/projection-store.js +0 -30
  342. package/dist/runtime/space-binding.d.ts +0 -48
  343. package/dist/runtime/space-binding.js +0 -342
  344. package/dist/runtime/supervisor.d.ts +0 -19
  345. package/dist/runtime/supervisor.js +0 -441
  346. package/dist/runtime/turn-projection.d.ts +0 -41
  347. package/dist/runtime/turn-projection.js +0 -120
  348. package/dist/runtime/worker.d.ts +0 -1
  349. package/dist/safe-remote-image.d.ts +0 -36
  350. package/dist/safe-remote-image.js +0 -191
  351. package/dist/self-update.d.ts +0 -7
  352. package/dist/self-update.js +0 -202
  353. package/dist/session-status.d.ts +0 -10
  354. package/dist/session-status.js +0 -25
  355. package/dist/space-files/limit.d.ts +0 -2
  356. package/dist/space-files/limit.js +0 -16
  357. package/dist/space-files/operands.d.ts +0 -17
  358. package/dist/space-files/operands.js +0 -33
  359. package/dist/space-files/transfer.d.ts +0 -53
  360. package/dist/space-files/transfer.js +0 -297
  361. package/dist/space-files/upload.d.ts +0 -17
  362. package/dist/space-files/upload.js +0 -76
  363. package/dist/space.d.ts +0 -44
  364. package/dist/space.js +0 -192
  365. package/dist/version.d.ts +0 -2
  366. package/dist/version.js +0 -17
  367. package/dist/web.d.ts +0 -1
  368. package/dist/web.js +0 -4
  369. /package/dist/{board-kernel → chunks}/lexer.js +0 -0
@@ -0,0 +1,175 @@
1
+ import { A as spinner, B as readAuthSession, C as error, D as json, E as handleHttp, G as revokeAndClearAuthSession, H as requestDeviceCode, K as verifyDeviceCode, L as authSource, O as jsonRequested, R as loginWithDeviceFlow, U as requireAccessToken, V as refreshAccessToken, j as table, k as ok, m as clearHomeSpaceCache, t as createClient } from "./client.js";
2
+ //#region src/commands/auth.ts
3
+ function registerAuth(program) {
4
+ const auth = program.command("auth").description("Authentication management");
5
+ auth.command("login").description("Sign in with Logto device authorization").option("--request-code", "Request a device code without polling").option("--verify-code", "Exchange a previously requested device code").option("--json", "Output as JSON").action(async (opts) => {
6
+ const asJson = jsonRequested(opts);
7
+ if (opts.requestCode && opts.verifyCode) return error("Conflicting options", "Use only one of --request-code or --verify-code");
8
+ try {
9
+ if (opts.requestCode) {
10
+ const code = await requestDeviceCode();
11
+ if (asJson) return json(code);
12
+ printDeviceCode(code);
13
+ return;
14
+ }
15
+ if (opts.verifyCode) {
16
+ await verifyDeviceCode();
17
+ return showSignedIn(asJson);
18
+ }
19
+ const sp = spinner();
20
+ sp.start("Starting login");
21
+ await loginWithDeviceFlow((code) => {
22
+ sp.stop("Login started");
23
+ printDeviceCode(code);
24
+ process.stderr.write(" Waiting for authorization...\n");
25
+ });
26
+ return showSignedIn(asJson);
27
+ } catch (e) {
28
+ handleHttp(e);
29
+ }
30
+ });
31
+ auth.command("whoami").description("Show current user info").option("--json", "Output as JSON").action(async (opts) => {
32
+ return showSignedIn(jsonRequested(opts));
33
+ });
34
+ auth.command("token").description("Print a valid access token, refreshing it when needed").action(async () => {
35
+ try {
36
+ process.stdout.write(`${await requireAccessToken()}\n`);
37
+ } catch (e) {
38
+ handleHttp(e);
39
+ }
40
+ });
41
+ auth.command("refresh").description("Refresh the stored Logto access token").action(async () => {
42
+ try {
43
+ if (authSource() === "execution-token") return error("Cannot refresh COHUB_EXECUTION_TOKEN", "Run `cohub auth login` for long-lived Logto auth.");
44
+ await refreshAccessToken();
45
+ ok("Token refreshed");
46
+ } catch (e) {
47
+ handleHttp(e);
48
+ }
49
+ });
50
+ auth.command("logout").description("Clear stored Logto session").action(async () => {
51
+ await revokeAndClearAuthSession();
52
+ clearHomeSpaceCache();
53
+ if (process.env.COHUB_EXECUTION_TOKEN?.trim()) ok("Local session cleared. COHUB_EXECUTION_TOKEN is still set.");
54
+ else ok("Signed out");
55
+ });
56
+ }
57
+ async function showSignedIn(asJson) {
58
+ const source = authSource();
59
+ if (!source) return error("Not authenticated", "Run `cohub auth login`.");
60
+ const client = createClient();
61
+ const sp = asJson ? null : spinner();
62
+ sp?.start("Fetching user info");
63
+ try {
64
+ const user = await client.user.getMe();
65
+ sp?.stop("Done");
66
+ const session = readAuthSession();
67
+ const payload = {
68
+ source,
69
+ refreshable: source === "logto" && Boolean(session?.refreshToken),
70
+ user
71
+ };
72
+ if (asJson) return json(payload);
73
+ const u = flattenMeForTable(user);
74
+ console.log(` Auth source: ${source}`);
75
+ console.log(` Token: ${payload.refreshable ? "refreshable" : "ephemeral"}\n`);
76
+ table([u], [
77
+ {
78
+ key: "uuid",
79
+ label: "UUID"
80
+ },
81
+ {
82
+ key: "username",
83
+ label: "Username"
84
+ },
85
+ {
86
+ key: "displayName",
87
+ label: "Name"
88
+ },
89
+ {
90
+ key: "email",
91
+ label: "Email"
92
+ }
93
+ ]);
94
+ } catch (e) {
95
+ if (source === "execution-token") {
96
+ sp?.stop("Using local execution token");
97
+ return showExecutionTokenFallback(asJson);
98
+ }
99
+ sp?.stop("Failed");
100
+ handleHttp(e);
101
+ }
102
+ }
103
+ function flattenMeForTable(user) {
104
+ const profile = user.profile && typeof user.profile === "object" ? user.profile : {};
105
+ return {
106
+ uuid: user.uuid,
107
+ username: profile.username,
108
+ displayName: profile.displayName,
109
+ email: user.email
110
+ };
111
+ }
112
+ function decodeExecutionTokenPayload() {
113
+ const payload = (process.env.COHUB_EXECUTION_TOKEN?.trim())?.split(".")[1];
114
+ if (!payload) return null;
115
+ try {
116
+ const decoded = Buffer.from(payload, "base64url").toString("utf-8");
117
+ const parsed = JSON.parse(decoded);
118
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
119
+ } catch {
120
+ return null;
121
+ }
122
+ }
123
+ function showExecutionTokenFallback(asJson) {
124
+ const payload = decodeExecutionTokenPayload();
125
+ const execution = {
126
+ actorUserId: typeof payload?.actorUserId === "string" ? payload.actorUserId : null,
127
+ spaceId: typeof payload?.spaceId === "string" ? payload.spaceId : null,
128
+ sessionId: typeof payload?.sessionId === "string" ? payload.sessionId : null,
129
+ source: typeof payload?.source === "string" ? payload.source : null,
130
+ expiresAt: typeof payload?.exp === "number" ? (/* @__PURE__ */ new Date(payload.exp * 1e3)).toISOString() : null
131
+ };
132
+ const result = {
133
+ source: "execution-token",
134
+ refreshable: false,
135
+ user: execution.actorUserId ? { uuid: execution.actorUserId } : null,
136
+ execution
137
+ };
138
+ if (asJson) {
139
+ json(result);
140
+ return;
141
+ }
142
+ console.log(" Auth source: execution-token");
143
+ console.log(" Token: ephemeral\n");
144
+ table([execution], [
145
+ {
146
+ key: "actorUserId",
147
+ label: "Actor"
148
+ },
149
+ {
150
+ key: "spaceId",
151
+ label: "Space"
152
+ },
153
+ {
154
+ key: "sessionId",
155
+ label: "Session"
156
+ },
157
+ {
158
+ key: "source",
159
+ label: "Source"
160
+ },
161
+ {
162
+ key: "expiresAt",
163
+ label: "Expires"
164
+ }
165
+ ]);
166
+ }
167
+ function printDeviceCode(code) {
168
+ console.log("\nOpen this URL to sign in:\n");
169
+ console.log(` ${code.verificationUriComplete}\n`);
170
+ console.log("Or enter this code manually:\n");
171
+ console.log(` ${code.userCode}\n`);
172
+ console.log(`Code expires at ${new Date(code.expiresAt).toLocaleString()}.`);
173
+ }
174
+ //#endregion
175
+ export { registerAuth };
@@ -0,0 +1,146 @@
1
+ import { readFile } from "node:fs/promises";
2
+ //#region ../protocol/src/upload.ts
3
+ /**
4
+ * Upload limits — the single source of truth shared by api, gateway, worker,
5
+ * web and cli.
6
+ *
7
+ * Durable uploads (space files, public files, chat/app attachments, avatars,
8
+ * gateway attachments) differ only by object-key prefix and materialization
9
+ * destination, so they share one set of caps. Inline uploads never touch
10
+ * object storage and are bounded by process memory or websocket frames instead.
11
+ */
12
+ const MiB = 1048576;
13
+ const GiB = 1024 * MiB;
14
+ /** Maximum size of a single uploaded file. */
15
+ const UPLOAD_MAX_FILE_BYTES = 2 * GiB;
16
+ /** Maximum combined size of one upload batch. */
17
+ const UPLOAD_MAX_BATCH_BYTES = 2 * GiB;
18
+ /** Maximum file count of one upload batch. */
19
+ const UPLOAD_MAX_BATCH_FILES = 2e3;
20
+ const LIKE_STICKER_MAX_FILE_BYTES = 1 * MiB;
21
+ //#endregion
22
+ //#region src/avatar.ts
23
+ const loadSharp = async () => (await import("sharp")).default;
24
+ const AVATAR_SIZE = 1024;
25
+ const AVATAR_QUALITY = 86;
26
+ const detectAvatarFormat = (body) => {
27
+ if (body.subarray(0, 3).equals(Buffer.from([
28
+ 255,
29
+ 216,
30
+ 255
31
+ ]))) return {
32
+ mimeType: "image/jpeg",
33
+ extension: "jpg"
34
+ };
35
+ if (body.subarray(0, 8).equals(Buffer.from("89504e470d0a1a0a", "hex"))) return {
36
+ mimeType: "image/png",
37
+ extension: "png"
38
+ };
39
+ if (body.subarray(0, 6).toString("ascii") === "GIF87a" || body.subarray(0, 6).toString("ascii") === "GIF89a") return {
40
+ mimeType: "image/gif",
41
+ extension: "gif"
42
+ };
43
+ if (body.subarray(0, 4).toString("ascii") === "RIFF" && body.subarray(8, 12).toString("ascii") === "WEBP") return {
44
+ mimeType: "image/webp",
45
+ extension: "webp"
46
+ };
47
+ return null;
48
+ };
49
+ async function normalizeAvatarFile(path) {
50
+ const original = await readFile(path);
51
+ const originalFormat = detectAvatarFormat(original);
52
+ if (!originalFormat) throw new Error("Avatar must be a JPEG, PNG, GIF, or WebP image");
53
+ if (originalFormat.mimeType === "image/gif") return {
54
+ body: original,
55
+ ...originalFormat
56
+ };
57
+ try {
58
+ return {
59
+ body: await (await loadSharp())(original).rotate().resize(AVATAR_SIZE, AVATAR_SIZE, {
60
+ fit: "cover",
61
+ position: "centre"
62
+ }).webp({ quality: AVATAR_QUALITY }).toBuffer(),
63
+ mimeType: "image/webp",
64
+ extension: "webp"
65
+ };
66
+ } catch {
67
+ return {
68
+ body: original,
69
+ ...originalFormat
70
+ };
71
+ }
72
+ }
73
+ async function uploadAvatarAsset(input) {
74
+ const avatar = await normalizeAvatarFile(input.path);
75
+ return input.client.publicAssets.upload({
76
+ purpose: input.purpose,
77
+ spaceId: input.spaceId,
78
+ file: new Blob([new Uint8Array(avatar.body)], { type: avatar.mimeType }),
79
+ mimeType: avatar.mimeType,
80
+ filename: `avatar.${avatar.extension}`
81
+ });
82
+ }
83
+ async function normalizeLikeStickerFile(path) {
84
+ const original = await readFile(path);
85
+ const format = detectAvatarFormat(original);
86
+ if (!format) throw new Error("Like sticker must be a PNG, GIF, WebP, or JPEG image");
87
+ const sharp = await loadSharp().catch(() => null);
88
+ let prepared = {
89
+ body: original,
90
+ ...format
91
+ };
92
+ if (sharp) prepared = {
93
+ body: await sharp(original, { animated: true }).resize(256, 256, {
94
+ fit: "inside",
95
+ withoutEnlargement: true
96
+ }).webp({
97
+ quality: AVATAR_QUALITY,
98
+ effort: 5
99
+ }).toBuffer(),
100
+ mimeType: "image/webp",
101
+ extension: "webp"
102
+ };
103
+ else if (format.mimeType === "image/jpeg") throw new Error("Converting a JPEG like sticker needs sharp; use a PNG, GIF, or WebP image");
104
+ if (prepared.body.byteLength > 1048576) throw new Error(`Like sticker must be at most ${LIKE_STICKER_MAX_FILE_BYTES / 1024 / 1024} MiB after resizing`);
105
+ return prepared;
106
+ }
107
+ async function uploadLikeStickerAsset(input) {
108
+ const sticker = await normalizeLikeStickerFile(input.path);
109
+ return input.client.publicAssets.upload({
110
+ purpose: "space_like_sticker",
111
+ spaceId: input.spaceId,
112
+ file: new Blob([new Uint8Array(sticker.body)], { type: sticker.mimeType }),
113
+ mimeType: sticker.mimeType,
114
+ filename: `like-sticker.${sticker.extension}`
115
+ });
116
+ }
117
+ const CHAT_IMAGE_MAX_EDGE = 1984;
118
+ const CHAT_IMAGE_QUALITY = 86;
119
+ async function normalizeChatImageFile(path) {
120
+ const { data, info } = await (await loadSharp())(path).rotate().resize(CHAT_IMAGE_MAX_EDGE, CHAT_IMAGE_MAX_EDGE, {
121
+ fit: "inside",
122
+ withoutEnlargement: true
123
+ }).webp({ quality: CHAT_IMAGE_QUALITY }).toBuffer({ resolveWithObject: true });
124
+ return {
125
+ body: data,
126
+ width: info.width,
127
+ height: info.height
128
+ };
129
+ }
130
+ async function uploadChatImageAsset(input) {
131
+ const { body, width, height } = await normalizeChatImageFile(input.path);
132
+ return {
133
+ ...await input.client.publicAssets.uploadChatImageAttachment({
134
+ spaceId: input.spaceId,
135
+ sessionId: input.sessionId,
136
+ file: new Blob([new Uint8Array(body)], { type: "image/webp" }),
137
+ mimeType: "image/webp",
138
+ filename: "image.webp"
139
+ }),
140
+ size: body.byteLength,
141
+ width,
142
+ height
143
+ };
144
+ }
145
+ //#endregion
146
+ export { UPLOAD_MAX_BATCH_FILES as a, UPLOAD_MAX_BATCH_BYTES as i, uploadChatImageAsset as n, UPLOAD_MAX_FILE_BYTES as o, uploadLikeStickerAsset as r, uploadAvatarAsset as t };
@@ -0,0 +1,5 @@
1
+ //#region src/binary-pins.ts
2
+ const SANDBOXD_VERSION = "v2.96.0";
3
+ const RTC_HELPER_VERSION = "v2.96.0";
4
+ //#endregion
5
+ export { SANDBOXD_VERSION as n, RTC_HELPER_VERSION as t };
@@ -0,0 +1,232 @@
1
+ import { t as createClient } from "./client.js";
2
+ import { d as diffMergePatch, dt as parseBoardMediaSource, m as parseBoardDocument, p as mergePatch, ut as parseBoardItem, v as adoptBoardNaturalSize, z as featuredTaskArtifact } from "./id.js";
3
+ import { o as probeMediaSize } from "./media.js";
4
+ import { t as localMediaFacts } from "./local-media.js";
5
+ import { n as WORKSPACE_ROOT } from "./operands.js";
6
+ import { execFile } from "node:child_process";
7
+ import { resolve } from "node:path";
8
+ import { promisify } from "node:util";
9
+ //#region ../sdk/src/board/model/media-sizes.ts
10
+ function boardMediaTarget(id, item) {
11
+ if (item.type === "image" || item.type === "video") {
12
+ if (item.props.snapshot?.naturalWidth && item.props.snapshot.naturalHeight) return null;
13
+ const source = parseBoardMediaSource(item.props.src);
14
+ return source ? {
15
+ id,
16
+ type: item.type,
17
+ source
18
+ } : null;
19
+ }
20
+ if (item.type !== "task") return null;
21
+ const artifact = featuredTaskArtifact(item.props.snapshot.artifacts);
22
+ if (artifact?.type !== "image" && artifact?.type !== "video" || artifact.naturalWidth && artifact.naturalHeight) return null;
23
+ return {
24
+ id,
25
+ type: artifact.type,
26
+ source: {
27
+ kind: "url",
28
+ value: artifact.url
29
+ }
30
+ };
31
+ }
32
+ async function probeBoardMediaSize(target, options = {}) {
33
+ const { type, source } = target;
34
+ try {
35
+ const resolved = source.kind === "url" ? source.value : await options.resolveFile?.(source.value, type, options.signal);
36
+ if (typeof resolved !== "string") return resolved ?? null;
37
+ return await probeMediaSize(resolved, type, { signal: options.signal });
38
+ } catch {
39
+ return null;
40
+ }
41
+ }
42
+ const CONCURRENCY = 8;
43
+ /** Probes each unique media source once; unresolved items are left as is. */
44
+ async function settleBoardMediaSizes(items, options = {}) {
45
+ const targets = Object.entries(items).flatMap(([id, item]) => boardMediaTarget(id, item) ?? []);
46
+ const signal = AbortSignal.timeout(options.timeoutMs ?? 5e3);
47
+ const probes = /* @__PURE__ */ new Map();
48
+ const settled = {};
49
+ let next = 0;
50
+ const work = async () => {
51
+ for (let target = targets[next++]; target; target = targets[next++]) {
52
+ const key = `${target.type}:${target.source.kind}:${target.source.value}`;
53
+ const probe = probes.get(key) ?? probeBoardMediaSize(target, {
54
+ ...options,
55
+ signal
56
+ });
57
+ probes.set(key, probe);
58
+ const size = await probe;
59
+ const item = items[target.id];
60
+ const adopted = size && item && adoptBoardNaturalSize(item, size);
61
+ if (adopted) settled[target.id] = adopted;
62
+ }
63
+ };
64
+ await Promise.all(Array.from({ length: CONCURRENCY }, work));
65
+ return settled;
66
+ }
67
+ //#endregion
68
+ //#region src/board-document.ts
69
+ async function loadBoardDocument(spaceId, target) {
70
+ const board = await createClient().space(spaceId).boards.open(target);
71
+ let result = await board.get();
72
+ const snapshot = result;
73
+ const items = { ...result.items };
74
+ while (result.next) {
75
+ result = await board.get({
76
+ only: ["items"],
77
+ cursor: result.next
78
+ });
79
+ if (result.version !== snapshot.version) throw new Error("Board changed while reading. Retry the export.");
80
+ Object.assign(items, result.items);
81
+ }
82
+ const parsed = parseBoardDocument({
83
+ board: snapshot.board,
84
+ items,
85
+ animations: snapshot.animations ?? {}
86
+ }, { keepUnknown: true });
87
+ if (!parsed.ok) throw new Error(`Board ${result.id} could not be read: ${parsed.diagnostics[0]?.path}: ${parsed.diagnostics[0]?.message}`);
88
+ return {
89
+ document: parsed.document,
90
+ boardId: result.id,
91
+ title: result.title
92
+ };
93
+ }
94
+ //#endregion
95
+ //#region src/board-media.ts
96
+ const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
97
+ function boardMediaFileResolver(spaceId) {
98
+ const local = process.env.COHUB_SPACE_ID === spaceId;
99
+ return async (path, type, signal) => {
100
+ const file = resolve(WORKSPACE_ROOT, path);
101
+ const facts = local && file.startsWith(`/workspace/`) ? await localMediaFacts(file, type, signal) : null;
102
+ const resolved = facts ? null : await createClient().space(spaceId).files.resolve(path, {
103
+ purpose: "playback",
104
+ signal
105
+ }).catch(() => null);
106
+ const size = facts ?? resolved?.media;
107
+ return size ? {
108
+ width: size.width,
109
+ height: size.height
110
+ } : resolved?.url ?? null;
111
+ };
112
+ }
113
+ async function settleBoardDocument(spaceId, document) {
114
+ const settled = await settleBoardMediaSizes(document.items, { resolveFile: boardMediaFileResolver(spaceId) });
115
+ return Object.keys(settled).length ? {
116
+ ...document,
117
+ items: {
118
+ ...document.items,
119
+ ...settled
120
+ }
121
+ } : document;
122
+ }
123
+ async function settleBoardPatch(spaceId, patch, current) {
124
+ const items = isRecord(patch.items) ? patch.items : {};
125
+ const created = {};
126
+ for (const [id, value] of Object.entries(items)) {
127
+ if (!isRecord(value) || value.type !== "image" && value.type !== "video") continue;
128
+ const parsed = parseBoardItem(value, `items.${id}`);
129
+ if (parsed.ok) created[id] = parsed.item;
130
+ }
131
+ const existing = Object.keys(created).length ? await current(Object.keys(created)) : null;
132
+ if (!existing) return patch;
133
+ for (const [id, item] of Object.entries(existing)) if (isRecord(item) && item.type === created[id]?.type) delete created[id];
134
+ const settled = await settleBoardMediaSizes(created, { resolveFile: boardMediaFileResolver(spaceId) });
135
+ if (!Object.keys(settled).length) return patch;
136
+ const adopted = Object.entries(settled).map(([id, item]) => [id, mergePatch(items[id], diffMergePatch(created[id], item))]);
137
+ return {
138
+ ...patch,
139
+ items: {
140
+ ...items,
141
+ ...Object.fromEntries(adopted)
142
+ }
143
+ };
144
+ }
145
+ const run = promisify(execFile);
146
+ async function settleBoardMediaDurations(spaceId, document, ids) {
147
+ const local = process.env.COHUB_SPACE_ID === spaceId;
148
+ const settled = {};
149
+ for (const id of ids) {
150
+ const item = document.items[id];
151
+ if (item?.type !== "video" && item?.type !== "audio" || item.props.snapshot?.durationMs) continue;
152
+ const file = item.props.src.startsWith("http") ? null : resolve(WORKSPACE_ROOT, item.props.src);
153
+ const input = file && local && file.startsWith(`/workspace/`) ? file : file ? (await createClient().space(spaceId).files.resolve(item.props.src, { purpose: "playback" }).catch(() => null))?.url : null;
154
+ const seconds = input ? Number((await run("ffprobe", [
155
+ "-v",
156
+ "error",
157
+ "-show_entries",
158
+ "format=duration",
159
+ "-of",
160
+ "csv=p=0",
161
+ input
162
+ ], { timeout: 15e3 }).catch(() => ({ stdout: "" }))).stdout) : NaN;
163
+ if (!(seconds > 0)) throw new Error(`The length of ${id} is unknown; pass --duration.`);
164
+ settled[id] = {
165
+ ...item,
166
+ props: {
167
+ ...item.props,
168
+ snapshot: {
169
+ ...item.props.snapshot,
170
+ durationMs: Math.round(seconds * 1e3)
171
+ }
172
+ }
173
+ };
174
+ }
175
+ return settled;
176
+ }
177
+ //#endregion
178
+ //#region src/board-export-resources.ts
179
+ const BOARD_EXPORT_RENDERERS = [
180
+ "auto",
181
+ "canvas",
182
+ "gpu"
183
+ ];
184
+ var BoardExportResourceError = class extends Error {};
185
+ /** Decodes within `maxBytes`, first scaling images down to `maxEdge` on their long edge. */
186
+ function createBoardExportImageBudget(renderer, maxBytes) {
187
+ if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) throw new Error("Image memory budget must be a positive integer.");
188
+ let usedBytes = 0;
189
+ const decodeImage = async (input, mimeType, maxEdge = Number.POSITIVE_INFINITY) => {
190
+ const { default: sharp } = await import("sharp");
191
+ let bytes = input;
192
+ let { width, height } = await sharp(bytes, { limitInputPixels: false }).metadata();
193
+ if (Math.max(width ?? 0, height ?? 0) > maxEdge) {
194
+ const resized = await sharp(bytes, { limitInputPixels: false }).resize({
195
+ width: maxEdge,
196
+ height: maxEdge,
197
+ fit: "inside"
198
+ }).png({ compressionLevel: 0 }).toBuffer({ resolveWithObject: true });
199
+ ({width, height} = resized.info);
200
+ bytes = new Uint8Array(resized.data);
201
+ mimeType = "image/png";
202
+ }
203
+ const required = (width ?? 0) * (height ?? 0) * 4;
204
+ if (!Number.isSafeInteger(required) || required <= 0) throw new Error("Image dimensions could not be read.");
205
+ if (required > maxBytes - usedBytes) throw new BoardExportResourceError(`Image ${width}x${height} needs ${Math.ceil(required / 1024 ** 2)} MiB; ${Math.ceil(usedBytes / 1024 ** 2)} MiB is already reserved against the ${Math.floor(maxBytes / 1024 ** 2)} MiB image budget. Use smaller source images, export a smaller region, or increase --image-memory if enough memory is available.`);
206
+ usedBytes += required;
207
+ try {
208
+ const texture = await renderer.decodeImage(bytes, mimeType);
209
+ const destroy = texture.destroy.bind(texture);
210
+ let released = false;
211
+ texture.destroy = (destroySource) => {
212
+ if (destroySource && !released) {
213
+ released = true;
214
+ usedBytes -= required;
215
+ }
216
+ destroy(destroySource);
217
+ };
218
+ return texture;
219
+ } catch (error) {
220
+ usedBytes -= required;
221
+ throw error;
222
+ }
223
+ };
224
+ return {
225
+ decodeImage,
226
+ get usedBytes() {
227
+ return usedBytes;
228
+ }
229
+ };
230
+ }
231
+ //#endregion
232
+ export { settleBoardMediaDurations as a, settleBoardDocument as i, BoardExportResourceError as n, settleBoardPatch as o, createBoardExportImageBudget as r, loadBoardDocument as s, BOARD_EXPORT_RENDERERS as t };