@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,315 @@
1
+ //#region ../protocol/src/core/media.ts
2
+ const MEDIA_HOSTS = /* @__PURE__ */ new Map([
3
+ ["router-files.neta.art", {
4
+ transform: "oss",
5
+ metaHeaders: true
6
+ }],
7
+ ["oss.talesofai.com", { transform: "oss" }],
8
+ ["public.cohub.live", {
9
+ transform: "oss",
10
+ metaHeaders: true
11
+ }],
12
+ ["public.cohub.run", { transform: "oss" }],
13
+ ["sessions.cohub.live", {
14
+ transform: "oss",
15
+ metaHeaders: true
16
+ }],
17
+ ["works.cohub.live", {
18
+ transform: "oss",
19
+ metaHeaders: true
20
+ }],
21
+ ["works.cohub.run", { transform: "oss" }],
22
+ ["cca.neta.art", { transform: "cloudflare" }],
23
+ ["static.neta.art", { transform: "cloudflare" }],
24
+ ["pages-r2.neta.art", { transform: "cloudflare" }]
25
+ ]);
26
+ const parseHttpsUrl = (url) => {
27
+ if (!/^https:\/\//i.test(url)) return null;
28
+ try {
29
+ return new URL(url);
30
+ } catch {
31
+ return null;
32
+ }
33
+ };
34
+ function mediaHost(url) {
35
+ const parsed = parseHttpsUrl(url);
36
+ return parsed ? MEDIA_HOSTS.get(parsed.hostname) : void 0;
37
+ }
38
+ /** Fixed variant edges keep CDN cache hits high; pick one with `mediaVariantSize`. */
39
+ const MEDIA_VARIANT_SIZES = [
40
+ 192,
41
+ 384,
42
+ 768,
43
+ 1536
44
+ ];
45
+ const MEDIA_VARIANT_MAX = 1536;
46
+ /** Smallest variant covering `pixels` device pixels, capped at the largest. */
47
+ function mediaVariantSize(pixels) {
48
+ return MEDIA_VARIANT_SIZES.find((size) => size >= pixels) ?? 1536;
49
+ }
50
+ const VARIANT_QUALITY = 82;
51
+ const FRAME_GUESS_MAX = 768;
52
+ function fitted(natural, edge, fit) {
53
+ const bound = fit === "cover" ? Math.min(natural.width, natural.height) : fit === "width" ? natural.width : Math.max(natural.width, natural.height);
54
+ const scale = Math.min(1, edge / bound);
55
+ return {
56
+ width: Math.max(1, Math.round(natural.width * scale)),
57
+ height: Math.max(1, Math.round(natural.height * scale))
58
+ };
59
+ }
60
+ const guessedBox = (edge, fit) => fit === "cover" ? edge * 2 : edge;
61
+ const aspectSize = (aspect, edge) => aspect >= 1 ? {
62
+ width: edge,
63
+ height: edge / aspect
64
+ } : {
65
+ width: edge * aspect,
66
+ height: edge
67
+ };
68
+ const OSS_PROCESS_PATTERN = /[?&]x-oss-process=/;
69
+ /** Append an OSS process to `url`, keeping its query and hash. */
70
+ function ossProcessUrl(url, process) {
71
+ if (/^(data|blob):/i.test(url) || OSS_PROCESS_PATTERN.test(url)) return url;
72
+ const hashIndex = url.indexOf("#");
73
+ const base = hashIndex >= 0 ? url.slice(0, hashIndex) : url;
74
+ const hash = hashIndex >= 0 ? url.slice(hashIndex) : "";
75
+ return `${base}${base.includes("?") ? "&" : "?"}x-oss-process=${process}${hash}`;
76
+ }
77
+ const ossProcess = (url, process) => OSS_PROCESS_PATTERN.test(url) ? null : ossProcessUrl(url, process);
78
+ const OSS_RESIZE = {
79
+ cover: (edge) => `m_mfit,w_${edge},h_${edge}`,
80
+ contain: (edge) => `m_lfit,w_${edge},h_${edge}`,
81
+ width: (edge) => `w_${edge}`
82
+ };
83
+ const oss = {
84
+ fitsFrames: false,
85
+ image: (url, edge, fit, quality) => ossProcess(url, `image/resize,${OSS_RESIZE[fit](edge)}/quality,q_${quality}/format,webp`),
86
+ frame: (url, { edge, fit, natural, aspect }) => {
87
+ const shape = natural ?? (aspect ? aspectSize(aspect, FRAME_GUESS_MAX) : null);
88
+ const width = shape ? fitted(shape, edge, fit).width : Math.min(guessedBox(edge, fit), FRAME_GUESS_MAX);
89
+ return ossProcess(url, `video/snapshot,t_0,f_jpg,w_${width},m_fast`);
90
+ },
91
+ sizeFrame: (url) => ossProcess(url, "video/snapshot,t_0,f_jpg,w_0,h_0,m_fast"),
92
+ frameLimit: Number.POSITIVE_INFINITY,
93
+ imageInfoUrl: (url) => ossProcess(url, "image/info"),
94
+ readImageInfo: (body) => {
95
+ const fields = body;
96
+ return {
97
+ width: positive(fields.ImageWidth?.value),
98
+ height: positive(fields.ImageHeight?.value),
99
+ bytes: positive(fields.FileSize?.value)
100
+ };
101
+ },
102
+ source: (url) => {
103
+ const match = /([?&])x-oss-process=([^&#]*)/.exec(url);
104
+ if (!match) return null;
105
+ const [segment, separator, process = ""] = match;
106
+ const head = url.slice(0, match.index);
107
+ const tail = url.slice(match.index + segment.length);
108
+ return {
109
+ url: separator === "?" && tail.startsWith("&") ? `${head}?${tail.slice(1)}` : head + tail,
110
+ type: process.startsWith("video/") ? "video" : "image"
111
+ };
112
+ }
113
+ };
114
+ const CLOUDFLARE_DERIVED = /^\/cdn-cgi\/(image|media)\/[^/]+(\/.*)$/;
115
+ function cdnCgi(url, kind, options) {
116
+ const { origin, pathname, search } = new URL(url);
117
+ return pathname.startsWith("/cdn-cgi/") ? null : `${origin}/cdn-cgi/${kind}/${options}${pathname}${search}`;
118
+ }
119
+ function cloudflareBox(edge, fit, natural, limit = Number.POSITIVE_INFINITY) {
120
+ if (natural) return `width=${Math.min(fitted(natural, edge, fit).width, limit)}`;
121
+ if (fit === "width") return `width=${Math.min(edge, limit)}`;
122
+ const box = Math.min(guessedBox(edge, fit), limit);
123
+ return `width=${box},height=${box}`;
124
+ }
125
+ const CLOUDFLARE_FRAME_MAX = 2e3;
126
+ const ADAPTERS = {
127
+ oss,
128
+ cloudflare: {
129
+ fitsFrames: true,
130
+ image: (url, edge, fit, quality, format) => cdnCgi(url, "image", `${cloudflareBox(edge, fit)},fit=scale-down,quality=${quality},format=${format},onerror=redirect`),
131
+ frame: (url, { edge, fit, natural }) => cdnCgi(url, "media", `mode=frame,time=0s,${cloudflareBox(edge, fit, natural, CLOUDFLARE_FRAME_MAX)},fit=scale-down,format=jpg`),
132
+ sizeFrame: (url) => cdnCgi(url, "media", `mode=frame,time=0s,width=${CLOUDFLARE_FRAME_MAX},height=${CLOUDFLARE_FRAME_MAX},fit=scale-down,format=jpg`),
133
+ frameLimit: CLOUDFLARE_FRAME_MAX,
134
+ imageInfoUrl: (url) => cdnCgi(url, "image", "format=json"),
135
+ readImageInfo: (body) => {
136
+ const original = body.original;
137
+ return {
138
+ width: positive(original?.width),
139
+ height: positive(original?.height),
140
+ bytes: positive(original?.file_size)
141
+ };
142
+ },
143
+ source: (url) => {
144
+ const parsed = new URL(url);
145
+ const match = CLOUDFLARE_DERIVED.exec(parsed.pathname);
146
+ return match ? {
147
+ url: `${parsed.origin}${match[2]}${parsed.search}${parsed.hash}`,
148
+ type: match[1] === "media" ? "video" : "image"
149
+ } : null;
150
+ }
151
+ }
152
+ };
153
+ function adapterFor(url) {
154
+ const host = mediaHost(url);
155
+ return host ? ADAPTERS[host.transform] : null;
156
+ }
157
+ const isGif = (url) => /\.gif$/i.test(new URL(url).pathname);
158
+ function resizedImageUrl(url, edge, fit, quality, format) {
159
+ const adapter = adapterFor(url);
160
+ return adapter && !isGif(url) ? adapter.image(url, edge, fit, quality, format) : null;
161
+ }
162
+ function imageVariantUrl(url, size, fit = "contain") {
163
+ return resizedImageUrl(url, size, fit, VARIANT_QUALITY, "auto");
164
+ }
165
+ function videoFrameUrl(url, size, options = {}) {
166
+ return adapterFor(url)?.frame(url, {
167
+ ...options,
168
+ edge: size,
169
+ fit: options.fit ?? "contain"
170
+ }) ?? null;
171
+ }
172
+ function positive(value) {
173
+ const number = typeof value === "string" ? Number(value) : value;
174
+ return typeof number === "number" && Number.isFinite(number) && number > 0 ? number : void 0;
175
+ }
176
+ function sameOriginUrl(value, origin) {
177
+ if (!value) return void 0;
178
+ try {
179
+ const url = new URL(value);
180
+ return url.protocol === "https:" && url.origin === origin ? url.href : void 0;
181
+ } catch {
182
+ return;
183
+ }
184
+ }
185
+ function compact(info) {
186
+ return Object.fromEntries(Object.entries(info).filter(([, value]) => value !== void 0));
187
+ }
188
+ const MEDIA_FACTS_LIMITS = {
189
+ edge: 65535,
190
+ durationMs: 6048e5
191
+ };
192
+ const within = (value, max) => Number.isInteger(value) && value > 0 && value <= max;
193
+ function mediaFacts(facts) {
194
+ const { width, height, durationMs } = facts ?? {};
195
+ if (!within(width, MEDIA_FACTS_LIMITS.edge) || !within(height, MEDIA_FACTS_LIMITS.edge)) return null;
196
+ return {
197
+ width,
198
+ height,
199
+ ...within(durationMs, MEDIA_FACTS_LIMITS.durationMs) ? { durationMs } : {}
200
+ };
201
+ }
202
+ /** Media facts from response headers; `x-oss-meta-*` need CORS exposure in browsers. */
203
+ function mediaInfoFromHeaders(headers, url) {
204
+ const origin = new URL(url).origin;
205
+ const meta = (name) => headers.get(`x-oss-meta-${name}`);
206
+ const seconds = positive(meta("duration"));
207
+ const frameCount = positive(meta("nb-frames"));
208
+ return compact({
209
+ width: positive(meta("width")),
210
+ height: positive(meta("height")),
211
+ durationMs: seconds ? Math.round(seconds * 1e3) : void 0,
212
+ frameCount: frameCount ? Math.round(frameCount) : void 0,
213
+ firstFrameUrl: sameOriginUrl(meta("first-frame"), origin),
214
+ lastFrameUrl: sameOriginUrl(meta("last-frame"), origin),
215
+ mimeType: headers.get("content-type")?.split(";")[0]?.trim() || void 0,
216
+ bytes: positive(headers.get("content-length"))
217
+ });
218
+ }
219
+ function mergeMediaInfo(primary, fallback) {
220
+ return compact({
221
+ ...fallback,
222
+ ...compact(primary)
223
+ });
224
+ }
225
+ function hasDimensions(info) {
226
+ return info.width !== void 0 && info.height !== void 0;
227
+ }
228
+ async function probeHeaders(url, options) {
229
+ const response = await (options.fetch ?? globalThis.fetch)(url, {
230
+ method: "HEAD",
231
+ signal: options.signal
232
+ });
233
+ return response.ok ? mediaInfoFromHeaders(response.headers, url) : {};
234
+ }
235
+ async function probeImageInfo(url, options) {
236
+ const adapter = adapterFor(url);
237
+ const infoUrl = adapter?.imageInfoUrl(url);
238
+ if (!adapter || !infoUrl) return {};
239
+ const response = await (options.fetch ?? globalThis.fetch)(infoUrl, { signal: options.signal });
240
+ return response.ok ? compact(adapter.readImageInfo(await response.json())) : {};
241
+ }
242
+ async function probeMediaInfo(url, options) {
243
+ const host = mediaHost(url);
244
+ if (!host) return {};
245
+ let info = {};
246
+ const attempt = async (strategy) => {
247
+ try {
248
+ info = mergeMediaInfo(info, await strategy());
249
+ } catch {}
250
+ };
251
+ if (host.metaHeaders) await attempt(() => probeHeaders(url, options));
252
+ if (options.type === "image" && !hasDimensions(info)) await attempt(() => probeImageInfo(url, options));
253
+ return info;
254
+ }
255
+ function jpegSize(bytes, length) {
256
+ if (length >= 2 && (bytes[0] !== 255 || bytes[1] !== 216)) return null;
257
+ let index = 2;
258
+ while (index + 9 <= length) {
259
+ if (bytes[index] !== 255) return null;
260
+ const marker = bytes[index + 1];
261
+ if (marker === 255) {
262
+ index += 1;
263
+ continue;
264
+ }
265
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
266
+ const height = bytes[index + 5] << 8 | bytes[index + 6];
267
+ const width = bytes[index + 7] << 8 | bytes[index + 8];
268
+ return width && height ? {
269
+ width,
270
+ height
271
+ } : null;
272
+ }
273
+ index += 2 + (bytes[index + 2] << 8 | bytes[index + 3]);
274
+ }
275
+ return length >= bytes.length ? null : void 0;
276
+ }
277
+ const FRAME_HEADER_BYTES = 65536;
278
+ async function probeVideoFrameSize(url, options = {}) {
279
+ const adapter = adapterFor(url);
280
+ const frame = adapter?.sizeFrame(url);
281
+ if (!adapter || !frame) return {};
282
+ const response = await (options.fetch ?? globalThis.fetch)(frame, {
283
+ headers: { Range: `bytes=0-65535` },
284
+ signal: options.signal
285
+ });
286
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
287
+ const header = new Uint8Array(FRAME_HEADER_BYTES);
288
+ let length = 0;
289
+ let size;
290
+ const reader = response.body?.getReader();
291
+ while (reader && size === void 0) {
292
+ const { done, value } = await reader.read();
293
+ if (done) break;
294
+ const take = Math.min(value.length, header.length - length);
295
+ header.set(value.subarray(0, take), length);
296
+ length += take;
297
+ size = jpegSize(header, length);
298
+ }
299
+ await reader?.cancel().catch(() => void 0);
300
+ if (!size || Math.max(size.width, size.height) >= adapter.frameLimit) return {};
301
+ return size;
302
+ }
303
+ async function probeMediaSize(url, type, options = {}) {
304
+ const info = await probeMediaInfo(url, {
305
+ ...options,
306
+ type
307
+ });
308
+ const { width, height } = info.width || type !== "video" ? info : await probeVideoFrameSize(url, options).catch(() => info);
309
+ return width && height ? {
310
+ width,
311
+ height
312
+ } : null;
313
+ }
314
+ //#endregion
315
+ export { probeMediaInfo as a, mediaVariantSize as i, imageVariantUrl as n, probeMediaSize as o, mediaFacts as r, videoFrameUrl as s, MEDIA_VARIANT_MAX as t };
@@ -0,0 +1,242 @@
1
+ import { C as error, D as json, E as handleHttp, O as jsonRequested, _ as failSpaceTarget, g as explicitSpace, j as table, t as createClient, x as resolveSpaceRef } from "./client.js";
2
+ import { a as parseGenerationPolicyFromEnv, i as getAllowedGenerationModelIds, r as filterGenerationDeclarationsByPolicy } from "./policy.js";
3
+ //#region ../protocol/src/generation/catalog.ts
4
+ function isGenerationModelHidden(model) {
5
+ return model.hidden === true;
6
+ }
7
+ function filterDiscoverableGenerationModels(models, options = {}) {
8
+ const includeModelIds = new Set(options.includeModelIds);
9
+ return models.filter((model) => !isGenerationModelHidden(model) || includeModelIds.has(model.model));
10
+ }
11
+ //#endregion
12
+ //#region src/commands/models.ts
13
+ function toMultimodalModelSummary(model) {
14
+ return {
15
+ model: model.model,
16
+ ...model.title ? { title: model.title } : {},
17
+ ...model.description ? { description: model.description } : {},
18
+ ...model.pricing ? { pricing: model.pricing } : {}
19
+ };
20
+ }
21
+ function printSection(title, lines) {
22
+ if (lines.length === 0) return;
23
+ console.log(`\n${title}`);
24
+ for (const line of lines) console.log(` ${line}`);
25
+ }
26
+ const PRICE_UNIT_LABELS = {
27
+ image: "image",
28
+ second: "second",
29
+ request: "request",
30
+ "1m_tokens": "1M tokens"
31
+ };
32
+ /** USD amounts stay compact while preserving the precision the value actually needs. */
33
+ function formatUsdAmount(value) {
34
+ const magnitude = Math.abs(value);
35
+ const fractionDigits = value === 0 || magnitude >= 1 && Number.isInteger(value) ? 0 : magnitude < .01 ? 4 : 2;
36
+ return `$${value.toLocaleString("en-US", {
37
+ minimumFractionDigits: fractionDigits,
38
+ maximumFractionDigits: fractionDigits
39
+ })}`;
40
+ }
41
+ /**
42
+ * Render a display-only unit price, e.g. `$0.04 / image` or `$0.10–$0.50 / second`,
43
+ * optionally suffixed with a qualifier note.
44
+ *
45
+ * The raw `pricing` object is preserved in `--json` for machines; this string
46
+ * targets humans and agents reading the table output.
47
+ */
48
+ function formatGenerationPrice(pricing) {
49
+ const unit = PRICE_UNIT_LABELS[pricing.unit];
50
+ const base = `${typeof pricing.amount === "number" ? formatUsdAmount(pricing.amount) : pricing.min === pricing.max ? formatUsdAmount(pricing.min) : `${formatUsdAmount(pricing.min)}\u2013${formatUsdAmount(pricing.max)}`} / ${unit}`;
51
+ return pricing.note ? `${base} \u00b7 ${pricing.note}` : base;
52
+ }
53
+ /** LLM catalog entries carry cost as an untyped `model.cost` bag; validate it before use. */
54
+ function readLlmModelCost(model) {
55
+ const cost = model.cost;
56
+ if (!cost || typeof cost !== "object") return null;
57
+ const { input, output, cacheRead, cacheWrite } = cost;
58
+ if (typeof input !== "number" || typeof output !== "number") return null;
59
+ return {
60
+ input,
61
+ output,
62
+ ...typeof cacheRead === "number" ? { cacheRead } : {},
63
+ ...typeof cacheWrite === "number" ? { cacheWrite } : {}
64
+ };
65
+ }
66
+ /** Zero or absent per-token components carry no signal, so they are omitted. */
67
+ function formatLlmCostValue(value) {
68
+ return typeof value === "number" && Number.isFinite(value) && value !== 0 ? formatUsdAmount(value) : null;
69
+ }
70
+ /**
71
+ * Render per-million-token LLM cost, e.g. `$3 /M input · $15 /M output`,
72
+ * appending cache rates only when the model declares them.
73
+ */
74
+ function formatLlmModelCost(model) {
75
+ const cost = readLlmModelCost(model);
76
+ if (!cost) return "";
77
+ return [
78
+ [cost.input, "input"],
79
+ [cost.output, "output"],
80
+ [cost.cacheRead, "cache read"],
81
+ [cost.cacheWrite, "cache write"]
82
+ ].flatMap(([value, label]) => {
83
+ const formatted = formatLlmCostValue(value);
84
+ return formatted ? [`${formatted} /M ${label}`] : [];
85
+ }).join(" · ");
86
+ }
87
+ /**
88
+ * Drop hidden models from LLM discovery, mirroring generation models and the web
89
+ * picker. Providers left with no visible model are removed so the catalog shape
90
+ * matches what is actually shown. Explicit `true` is the only hidden signal.
91
+ */
92
+ function filterHiddenLlmModels(catalog) {
93
+ const visible = {};
94
+ for (const [provider, entries] of Object.entries(catalog)) {
95
+ const models = entries.filter((entry) => entry.model.hidden !== true);
96
+ if (models.length > 0) visible[provider] = models;
97
+ }
98
+ return visible;
99
+ }
100
+ function formatContentSpec(spec) {
101
+ const details = [];
102
+ const roles = spec.roles;
103
+ details.push(spec.required === false ? "optional" : "required");
104
+ if (typeof spec.min === "number") details.push(`min ${spec.min}`);
105
+ if (typeof spec.max === "number") details.push(`max ${spec.max}`);
106
+ if (spec.sources?.length) details.push(`sources: ${spec.sources.join(", ")}`);
107
+ if (roles?.length) details.push(`roles: ${roles.join(", ")}`);
108
+ if (spec.merge) details.push(`merge: ${spec.merge}`);
109
+ if (spec.description) details.push(spec.description);
110
+ return `${spec.type}${details.length > 0 ? ` — ${details.join("; ")}` : ""}`;
111
+ }
112
+ function formatParameter(name, spec) {
113
+ const lines = [`${name}`];
114
+ const details = [`type: ${spec.type}`];
115
+ if (spec.optional) details.push("optional");
116
+ if ("default" in spec && spec.default !== void 0) details.push(`default: ${String(spec.default)}`);
117
+ if ("min" in spec && typeof spec.min === "number") details.push(`min: ${spec.min}`);
118
+ if ("max" in spec && typeof spec.max === "number") details.push(`max: ${spec.max}`);
119
+ if ("enum" in spec && spec.enum?.length) details.push(`values: ${spec.enum.join(", ")}`);
120
+ lines.push(` ${details.join("; ")}`);
121
+ if (spec.description) lines.push(` ${spec.description}`);
122
+ if ("examples" in spec && spec.examples?.length) lines.push(` examples: ${spec.examples.map(String).join(", ")}`);
123
+ return lines;
124
+ }
125
+ function printMultimodalModel(model) {
126
+ console.log(model.title ?? model.model);
127
+ printSection("Model", [model.model]);
128
+ if (model.description) printSection("Description", [model.description]);
129
+ if (model.pricing) printSection("Pricing", [formatGenerationPrice(model.pricing)]);
130
+ printSection("Input", model.content.input.map(formatContentSpec));
131
+ printSection("Parameters", Object.entries(model.parameters ?? {}).flatMap(([name, spec]) => formatParameter(name, spec)));
132
+ printSection("Examples", (model.examples ?? []).map((example, index) => {
133
+ const title = example.title ? `${example.title}: ` : "";
134
+ const prompt = example.request.content.find((block) => block.type === "text")?.text;
135
+ return `${index + 1}. ${title}${prompt ? `"${prompt}"` : example.request.model}`;
136
+ }));
137
+ }
138
+ function formatModelContext(model) {
139
+ const value = model.contextWindow;
140
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return "";
141
+ const source = typeof model.contextWindowSource === "string" ? model.contextWindowSource : null;
142
+ const ref = typeof model.contextWindowSourceRef === "string" ? `:${model.contextWindowSourceRef}` : "";
143
+ return source ? `${formatTokenCount(value)} (${source}${ref})` : formatTokenCount(value);
144
+ }
145
+ function formatTokenCount(value) {
146
+ if (value >= 1e6) return `${(value / 1e6).toFixed(1)}M`;
147
+ if (value >= 1e3) return `${(value / 1e3).toFixed(1)}k`;
148
+ return String(value);
149
+ }
150
+ function registerModels(program) {
151
+ const cmd = program.command("models").description("List available LLM and multimodal models").addHelpText("after", `
152
+
153
+ Examples:
154
+ cohub models ls
155
+ cohub models ls --space <spaceId>
156
+ cohub models ls --model-type multimodal
157
+ cohub models ls --model-type multimodal --json
158
+ cohub models show <model>
159
+ cohub models show <model> --json
160
+ `);
161
+ cmd.command("ls").alias("list").description("List available models").option("--model-type <type>", "Model type: llm | multimodal", "llm").option("--json", "Output as JSON").action(async (opts, command) => {
162
+ const client = createClient();
163
+ try {
164
+ if (opts.modelType === "multimodal") {
165
+ const response = await client.models.listMultimodal();
166
+ const policy = parseGenerationPolicyFromEnv(process.env);
167
+ const allowedModelIds = getAllowedGenerationModelIds(policy);
168
+ const models = filterDiscoverableGenerationModels(filterGenerationDeclarationsByPolicy(response.models, policy), { includeModelIds: allowedModelIds ?? void 0 }).map(toMultimodalModelSummary);
169
+ if (jsonRequested(opts)) return json({ models });
170
+ table(models, [
171
+ {
172
+ key: "model",
173
+ label: "Model"
174
+ },
175
+ {
176
+ key: "title",
177
+ label: "Title"
178
+ },
179
+ {
180
+ key: "pricing",
181
+ label: "Price",
182
+ format: (value) => value ? formatGenerationPrice(value) : ""
183
+ },
184
+ {
185
+ key: "description",
186
+ label: "Description"
187
+ }
188
+ ]);
189
+ return;
190
+ }
191
+ if (opts.modelType && opts.modelType !== "llm") return error("Invalid model type", "Use --model-type llm or --model-type multimodal");
192
+ const spaceRef = explicitSpace(command);
193
+ const spaceId = spaceRef ? await resolveSpaceRef(spaceRef).catch(failSpaceTarget) : void 0;
194
+ const visibleCatalog = filterHiddenLlmModels(await client.models.list({ spaceId }));
195
+ if (jsonRequested(opts)) return json(visibleCatalog);
196
+ if (Object.keys(visibleCatalog).length === 0) return console.log(" (empty)");
197
+ for (const [provider, entries] of Object.entries(visibleCatalog)) {
198
+ console.log(`\n ${provider}`);
199
+ console.log(` ${"─".repeat(provider.length)}`);
200
+ table(entries.map((entry) => ({
201
+ id: entry.id,
202
+ provider: entry.provider,
203
+ context: formatModelContext(entry.model),
204
+ cost: formatLlmModelCost(entry.model)
205
+ })), [
206
+ {
207
+ key: "id",
208
+ label: "ID"
209
+ },
210
+ {
211
+ key: "provider",
212
+ label: "Provider"
213
+ },
214
+ {
215
+ key: "context",
216
+ label: "Context"
217
+ },
218
+ {
219
+ key: "cost",
220
+ label: "Cost"
221
+ }
222
+ ]);
223
+ }
224
+ } catch (e) {
225
+ handleHttp(e);
226
+ }
227
+ });
228
+ cmd.command("show").description("Show full multimodal model details").argument("<model>", "Multimodal model ID").option("--json", "Output as JSON").action(async (modelId, opts) => {
229
+ const client = createClient();
230
+ try {
231
+ const response = await client.models.listMultimodal();
232
+ const model = filterGenerationDeclarationsByPolicy(response.models, parseGenerationPolicyFromEnv(process.env)).find((item) => item.model === modelId);
233
+ if (!model) return error("Model not found", `No multimodal model named ${modelId}`);
234
+ if (jsonRequested(opts)) return json(model);
235
+ printMultimodalModel(model);
236
+ } catch (e) {
237
+ handleHttp(e);
238
+ }
239
+ });
240
+ }
241
+ //#endregion
242
+ export { registerModels };
@@ -0,0 +1,46 @@
1
+ import { $ as parseSpaceRef } from "./client.js";
2
+ import { posix, resolve } from "node:path";
3
+ //#region src/space-files/operands.ts
4
+ var InvalidFileOperandError = class extends Error {
5
+ name = "InvalidFileOperandError";
6
+ };
7
+ const WORKSPACE_ROOT = "/workspace";
8
+ const isWorkspacePath = (path) => path === "/workspace" || path.startsWith(`/workspace/`);
9
+ function normalizeSpacePath(raw) {
10
+ let path = raw.trim();
11
+ if (isWorkspacePath(path)) path = path.slice(11);
12
+ else if (path.startsWith("/")) throw new InvalidFileOperandError(`'${raw}' is not a Space path`);
13
+ const normalized = posix.normalize(path || ".").replace(/\/+$/, "");
14
+ return normalized === "." ? "" : normalized;
15
+ }
16
+ function parseSpacePrefix(raw) {
17
+ const colon = raw.indexOf(":");
18
+ if (colon <= 0) return null;
19
+ const space = raw.slice(0, colon);
20
+ return parseSpaceRef(space) ? {
21
+ kind: "space",
22
+ space,
23
+ path: normalizeSpacePath(raw.slice(colon + 1))
24
+ } : null;
25
+ }
26
+ function parseSpaceFileOperand(raw) {
27
+ return parseSpacePrefix(raw) ?? {
28
+ kind: "space",
29
+ space: null,
30
+ path: normalizeSpacePath(raw)
31
+ };
32
+ }
33
+ function parseCopyOperand(raw, currentSpaceDeclared) {
34
+ const space = parseSpacePrefix(raw);
35
+ if (space) return space;
36
+ return !currentSpaceDeclared || raw.startsWith("/") && !isWorkspacePath(raw) ? {
37
+ kind: "local",
38
+ path: resolve(raw)
39
+ } : {
40
+ kind: "space",
41
+ space: null,
42
+ path: normalizeSpacePath(raw)
43
+ };
44
+ }
45
+ //#endregion
46
+ export { parseSpaceFileOperand as i, WORKSPACE_ROOT as n, parseCopyOperand as r, InvalidFileOperandError as t };
@@ -0,0 +1,13 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ //#region src/package-paths.ts
5
+ const root = (() => {
6
+ let dir = dirname(fileURLToPath(import.meta.url));
7
+ while (!existsSync(join(dir, "package.json")) && dirname(dir) !== dir) dir = dirname(dir);
8
+ return dir;
9
+ })();
10
+ const packagePath = (...segments) => join(root, ...segments);
11
+ const standaloneModule = (name) => import.meta.url.endsWith(".ts") ? packagePath("src", `${name}.ts`) : packagePath("dist", `${name}.js`);
12
+ //#endregion
13
+ export { standaloneModule as n, packagePath as t };