@neta-art/cohub-cli 10.29.1 → 10.31.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 (87) hide show
  1. package/dist/board-gpu/page.js +3011 -133
  2. package/dist/bootstrap.js +2 -4
  3. package/dist/build.json +1 -1
  4. package/dist/chunks/FilterPipe.js +145 -269
  5. package/dist/chunks/about.js +2 -3
  6. package/dist/chunks/app-realtime.js +113 -115
  7. package/dist/chunks/app-realtime2.js +1 -2
  8. package/dist/chunks/app-ref.js +4 -5
  9. package/dist/chunks/apps.js +8 -14
  10. package/dist/chunks/auth.js +1 -2
  11. package/dist/chunks/avatar.js +2 -4
  12. package/dist/chunks/binary-pins.js +1 -2
  13. package/dist/chunks/board-export-resources.js +55 -12
  14. package/dist/chunks/board-export.js +26 -21
  15. package/dist/chunks/board-export2.js +1 -2
  16. package/dist/chunks/board-kernel.js +2672 -1623
  17. package/dist/chunks/board-kernel2.js +2 -2
  18. package/dist/chunks/board-model.js +970 -0
  19. package/dist/chunks/board-profile.js +4 -5
  20. package/dist/chunks/board-simulate.js +6 -6
  21. package/dist/chunks/board-time.js +1 -2
  22. package/dist/chunks/boards.js +547 -23
  23. package/dist/chunks/browserAll.js +18 -35
  24. package/dist/chunks/channels.js +1 -2
  25. package/dist/chunks/client.js +637 -713
  26. package/dist/chunks/command-input.js +1 -2
  27. package/dist/chunks/commander.js +16 -22
  28. package/dist/chunks/cron-jobs.js +2 -3
  29. package/dist/chunks/daemon.js +18 -4
  30. package/dist/chunks/daemon2.js +1 -2
  31. package/dist/chunks/desktop.js +2 -3
  32. package/dist/chunks/endpoint-options.js +1 -2
  33. package/dist/chunks/env-proxy.js +4 -5
  34. package/dist/chunks/environment.js +2 -4
  35. package/dist/chunks/feedback.js +3 -4
  36. package/dist/chunks/generations.js +3 -4
  37. package/dist/chunks/host.js +1 -2
  38. package/dist/chunks/http-put.js +1 -2
  39. package/dist/chunks/id.js +77 -928
  40. package/dist/chunks/init.js +7 -12
  41. package/dist/chunks/install.js +142 -138
  42. package/dist/chunks/launch.js +4 -6
  43. package/dist/chunks/lexer.js +226 -66
  44. package/dist/chunks/local-media.js +1 -2
  45. package/dist/chunks/me.js +1 -2
  46. package/dist/chunks/media.js +1 -2
  47. package/dist/chunks/{themes.js → model-clips.js} +395 -43
  48. package/dist/chunks/models.js +3 -5
  49. package/dist/chunks/operands.js +1 -2
  50. package/dist/chunks/package-paths.js +1 -2
  51. package/dist/chunks/policy.js +1 -2
  52. package/dist/chunks/preferences.js +1 -2
  53. package/dist/chunks/profile.js +2 -3
  54. package/dist/chunks/prompts.js +1 -2
  55. package/dist/chunks/public.js +1 -2
  56. package/dist/chunks/public2.js +3 -4
  57. package/dist/chunks/references.js +3 -3
  58. package/dist/chunks/referrals.js +1 -2
  59. package/dist/chunks/rolldown-runtime.js +2 -3
  60. package/dist/chunks/rooms-connect.js +1 -2
  61. package/dist/chunks/rooms-connect2.js +1 -2
  62. package/dist/chunks/rooms-rtc.js +4 -6
  63. package/dist/chunks/rooms.js +2 -3
  64. package/dist/chunks/run.js +2 -3
  65. package/dist/chunks/runtime.js +6 -12
  66. package/dist/chunks/runtime2.js +2 -3
  67. package/dist/chunks/runtimes.js +1 -2
  68. package/dist/chunks/safe-remote-image.js +1 -2
  69. package/dist/chunks/schemas.js +58 -43
  70. package/dist/chunks/search.js +3 -3
  71. package/dist/chunks/self-update.js +4 -5
  72. package/dist/chunks/serve.js +11 -25
  73. package/dist/chunks/session-status.js +1 -2
  74. package/dist/chunks/skills.js +1 -2
  75. package/dist/chunks/spaces.js +26 -45
  76. package/dist/chunks/src.js +5 -9
  77. package/dist/chunks/supervisor.js +16 -28
  78. package/dist/chunks/supervisor2.js +1 -2
  79. package/dist/chunks/tasks.js +1 -2
  80. package/dist/chunks/user-lists.js +1 -2
  81. package/dist/chunks/version.js +1 -2
  82. package/dist/chunks/version2.js +1 -2
  83. package/dist/chunks/version3.js +3 -4
  84. package/dist/chunks/web.js +1 -2
  85. package/dist/runtime/native/pi-extension.js +1 -2
  86. package/dist/runtime/worker.js +2 -3
  87. package/package.json +11 -10
@@ -1,10 +1,10 @@
1
- import { r as cliCommit, t as CLI_VERSION } from "./version2.js";
2
1
  import { Y as readRuntimeSpaceBindings, s as controlRuntimeInstance, u as runtimeInstanceDirectory } from "./client.js";
2
+ import { r as cliCommit, t as CLI_VERSION } from "./version2.js";
3
3
  import { execFile } from "node:child_process";
4
4
  import { constants } from "node:fs";
5
5
  import { delimiter, join } from "node:path";
6
6
  import { access, realpath, stat } from "node:fs/promises";
7
- //#region src/about.ts
7
+ // src/about.ts
8
8
  const PROBE_TIMEOUT_MS = 5e3;
9
9
  const STATUS_TIMEOUT_MS = 1e3;
10
10
  const PROBE_TTL_MS = 3e5;
@@ -98,5 +98,4 @@ async function runningRuntimes(identity) {
98
98
  version: response.status.version ?? null
99
99
  }] : []);
100
100
  }
101
- //#endregion
102
101
  export { describeCli as t };
@@ -1,6 +1,6 @@
1
1
  import { _ as union, a as array, h as string, n as _enum, p as object, s as boolean } from "./schemas.js";
2
2
  import { a as resolveApiBaseUrl, n as decodeJwtPayload } from "./environment.js";
3
- //#region ../protocol/src/realtime/types.ts
3
+ // ../protocol/dist/realtime/types.js
4
4
  const WS_COMPACT_STREAM_CAPABILITY = "session.compact_stream.v1";
5
5
  const WS_ROOM_SUBSCRIPTION_CAPABILITY = "realtime.rooms.v1";
6
6
  const WS_BOARD_AWARENESS_CAPABILITY = "board.awareness.v1";
@@ -51,19 +51,119 @@ const getSessionTurnPatchStreamKey = (input, options = {}) => {
51
51
  if (streamKey) return streamKey;
52
52
  return options.includeSessionFallback ? getNonEmptyString(input.sessionId) : null;
53
53
  };
54
- //#endregion
55
- //#region ../protocol/src/identifiers.ts
54
+ object({
55
+ urls: union([string().min(1).max(512), array(string().min(1).max(512)).min(1).max(16)]),
56
+ username: string().max(512).optional(),
57
+ credential: string().max(512).optional()
58
+ });
59
+ const sessionDescriptionSchema = object({
60
+ type: _enum(["offer", "answer"]),
61
+ sdp: string().min(1).max(65536)
62
+ });
63
+ const APP_RTC_DELIVERIES = ["reliable", "latest"];
64
+ const APP_RTC_PUBLICATION_KINDS = [
65
+ "data",
66
+ "audio",
67
+ "video"
68
+ ];
69
+ const APP_RTC_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/;
70
+ const isAppRtcName = (value) => typeof value === "string" && APP_RTC_NAME_PATTERN.test(value) && !value.toLowerCase().startsWith("cohub.");
71
+ const APP_RTC_LIMITS = {
72
+ channelsPerMember: 16,
73
+ tracksPerMember: 4,
74
+ dataSubscriptions: 512,
75
+ mediaSubscriptions: 16,
76
+ messageBytes: 65536,
77
+ operationsPerSecond: 10,
78
+ opensPerSecond: 2,
79
+ batch: 64
80
+ };
81
+ const APP_RTC_QUALITIES = [
82
+ "high",
83
+ "medium",
84
+ "low"
85
+ ];
86
+ const APP_RTC_SIMULCAST_LAYERS = [
87
+ {
88
+ rid: "f",
89
+ quality: "high",
90
+ scaleResolutionDownBy: 1
91
+ },
92
+ {
93
+ rid: "h",
94
+ quality: "medium",
95
+ scaleResolutionDownBy: 2
96
+ },
97
+ {
98
+ rid: "q",
99
+ quality: "low",
100
+ scaleResolutionDownBy: 4
101
+ }
102
+ ];
103
+ object({
104
+ id: string().min(1).max(32),
105
+ name: string().regex(APP_RTC_NAME_PATTERN),
106
+ kind: _enum(APP_RTC_PUBLICATION_KINDS),
107
+ delivery: _enum(APP_RTC_DELIVERIES).optional(),
108
+ simulcast: boolean().optional()
109
+ });
110
+ const nameSchema = string().refine(isAppRtcName, "invalid name");
111
+ const participantIdSchema = string().uuid();
112
+ object({
113
+ ticket: string().min(1).max(4096),
114
+ participantId: participantIdSchema
115
+ });
116
+ object({ answer: sessionDescriptionSchema.refine((value) => value.type === "answer", "expected an answer") });
117
+ union([object({ channels: array(object({
118
+ name: nameSchema,
119
+ delivery: _enum(APP_RTC_DELIVERIES)
120
+ })).min(1).max(APP_RTC_LIMITS.channelsPerMember) }), object({
121
+ offer: sessionDescriptionSchema.refine((value) => value.type === "offer", "expected an offer"),
122
+ tracks: array(object({
123
+ name: nameSchema,
124
+ kind: _enum(["audio", "video"]),
125
+ mid: string().min(1).max(32),
126
+ simulcast: boolean().optional()
127
+ })).min(1).max(APP_RTC_LIMITS.tracksPerMember)
128
+ })]);
129
+ object({
130
+ ids: array(string().min(1).max(32)).min(1).max(APP_RTC_LIMITS.channelsPerMember + APP_RTC_LIMITS.tracksPerMember),
131
+ offer: sessionDescriptionSchema.refine((value) => value.type === "offer", "expected an offer").optional()
132
+ });
133
+ const subscriptionRefSchema = object({
134
+ participantId: participantIdSchema,
135
+ publicationId: string().min(1).max(32)
136
+ });
137
+ const qualitySchema = _enum(APP_RTC_QUALITIES);
138
+ object({
139
+ kind: _enum(["data", "media"]),
140
+ items: array(subscriptionRefSchema.extend({ quality: qualitySchema.optional() })).min(1).max(APP_RTC_LIMITS.batch)
141
+ });
142
+ object({ items: array(subscriptionRefSchema.extend({
143
+ mid: string().min(1).max(32),
144
+ quality: qualitySchema.optional()
145
+ })).min(1).max(APP_RTC_LIMITS.mediaSubscriptions) });
146
+ object({
147
+ items: array(subscriptionRefSchema).min(1).max(APP_RTC_LIMITS.batch),
148
+ offer: sessionDescriptionSchema.refine((value) => value.type === "offer", "expected an offer").optional()
149
+ });
150
+ // ../protocol/dist/identifiers.js
56
151
  const UUID_SHAPE_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
57
152
  const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}";
58
153
  const UUID_OR_SHORT_UUID_PATTERN = `^(?:${UUID_PATTERN}|[0-9a-fA-F]{32})$`;
59
154
  const UUID_SHAPE_REGEX = new RegExp(`^${UUID_SHAPE_PATTERN}$`);
60
- new RegExp(`^${UUID_PATTERN}$`);
61
- new RegExp(UUID_OR_SHORT_UUID_PATTERN);
155
+ const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
156
+ const UUID_OR_SHORT_UUID_REGEX = new RegExp(UUID_OR_SHORT_UUID_PATTERN);
62
157
  function isUuidLike(value) {
63
158
  return typeof value === "string" && UUID_SHAPE_REGEX.test(value);
64
159
  }
65
- //#endregion
66
- //#region ../protocol/src/provenance.ts
160
+ function isUuid(value) {
161
+ return typeof value === "string" && UUID_REGEX.test(value);
162
+ }
163
+ function isUuidOrShortUuid(value) {
164
+ return typeof value === "string" && UUID_OR_SHORT_UUID_REGEX.test(value);
165
+ }
166
+ // ../protocol/dist/provenance.js
67
167
  /** Request provenance via X-Cohub-Source-* headers. Never used for authorization. */
68
168
  const COHUB_SOURCE_HEADER = {
69
169
  space: "X-Cohub-Source-Space",
@@ -157,8 +257,7 @@ const readRequestSourceFromEnv = (env = {}, defaults) => normalizeRequestSource(
157
257
  via: env.COHUB_SOURCE_VIA ?? defaults?.via
158
258
  });
159
259
  Object.values(COHUB_SOURCE_HEADER);
160
- //#endregion
161
- //#region ../sdk/src/revalidation-cache.ts
260
+ // ../sdk/src/revalidation-cache.ts
162
261
  const MAX_ENTRY_CHARS = 262144;
163
262
  const MAX_TOTAL_CHARS = 8388608;
164
263
  const entries = /* @__PURE__ */ new Map();
@@ -191,8 +290,7 @@ function writeRevalidationEntry(key, etag, body) {
191
290
  remove(oldest);
192
291
  }
193
292
  }
194
- //#endregion
195
- //#region ../sdk/src/transport.ts
293
+ // ../sdk/src/transport.ts
196
294
  const responseBodyForError = async (response) => {
197
295
  return (response.headers.get("content-type") ?? "").includes("application/json") ? await response.json().catch(() => null) : await response.text().catch(() => response.statusText);
198
296
  };
@@ -479,8 +577,7 @@ var HttpTransport = class {
479
577
  return (await this.raw(path, init)).blob();
480
578
  }
481
579
  };
482
- //#endregion
483
- //#region ../sdk/src/rtc/index.ts
580
+ // ../sdk/src/rtc/index.ts
484
581
  const ICE_REFRESH_MARGIN_MS = 3e5;
485
582
  var IceServerCache = class {
486
583
  load;
@@ -541,104 +638,7 @@ function readRtcTransportStats(report) {
541
638
  });
542
639
  return stats;
543
640
  }
544
- object({
545
- urls: union([string().min(1).max(512), array(string().min(1).max(512)).min(1).max(16)]),
546
- username: string().max(512).optional(),
547
- credential: string().max(512).optional()
548
- });
549
- const sessionDescriptionSchema = object({
550
- type: _enum(["offer", "answer"]),
551
- sdp: string().min(1).max(65536)
552
- });
553
- const APP_RTC_DELIVERIES = ["reliable", "latest"];
554
- const APP_RTC_PUBLICATION_KINDS = [
555
- "data",
556
- "audio",
557
- "video"
558
- ];
559
- const APP_RTC_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/;
560
- const isAppRtcName = (value) => typeof value === "string" && APP_RTC_NAME_PATTERN.test(value) && !value.toLowerCase().startsWith("cohub.");
561
- const APP_RTC_LIMITS = {
562
- channelsPerMember: 16,
563
- tracksPerMember: 4,
564
- dataSubscriptions: 512,
565
- mediaSubscriptions: 16,
566
- messageBytes: 65536,
567
- operationsPerSecond: 10,
568
- opensPerSecond: 2,
569
- batch: 64
570
- };
571
- const APP_RTC_QUALITIES = [
572
- "high",
573
- "medium",
574
- "low"
575
- ];
576
- const APP_RTC_SIMULCAST_LAYERS = [
577
- {
578
- rid: "f",
579
- quality: "high",
580
- scaleResolutionDownBy: 1
581
- },
582
- {
583
- rid: "h",
584
- quality: "medium",
585
- scaleResolutionDownBy: 2
586
- },
587
- {
588
- rid: "q",
589
- quality: "low",
590
- scaleResolutionDownBy: 4
591
- }
592
- ];
593
- object({
594
- id: string().min(1).max(32),
595
- name: string().regex(APP_RTC_NAME_PATTERN),
596
- kind: _enum(APP_RTC_PUBLICATION_KINDS),
597
- delivery: _enum(APP_RTC_DELIVERIES).optional(),
598
- simulcast: boolean().optional()
599
- });
600
- const nameSchema = string().refine(isAppRtcName, "invalid name");
601
- const participantIdSchema = string().uuid();
602
- object({
603
- ticket: string().min(1).max(4096),
604
- participantId: participantIdSchema
605
- });
606
- object({ answer: sessionDescriptionSchema.refine((value) => value.type === "answer", "expected an answer") });
607
- union([object({ channels: array(object({
608
- name: nameSchema,
609
- delivery: _enum(APP_RTC_DELIVERIES)
610
- })).min(1).max(APP_RTC_LIMITS.channelsPerMember) }), object({
611
- offer: sessionDescriptionSchema.refine((value) => value.type === "offer", "expected an offer"),
612
- tracks: array(object({
613
- name: nameSchema,
614
- kind: _enum(["audio", "video"]),
615
- mid: string().min(1).max(32),
616
- simulcast: boolean().optional()
617
- })).min(1).max(APP_RTC_LIMITS.tracksPerMember)
618
- })]);
619
- object({
620
- ids: array(string().min(1).max(32)).min(1).max(APP_RTC_LIMITS.channelsPerMember + APP_RTC_LIMITS.tracksPerMember),
621
- offer: sessionDescriptionSchema.refine((value) => value.type === "offer", "expected an offer").optional()
622
- });
623
- const subscriptionRefSchema = object({
624
- participantId: participantIdSchema,
625
- publicationId: string().min(1).max(32)
626
- });
627
- const qualitySchema = _enum(APP_RTC_QUALITIES);
628
- object({
629
- kind: _enum(["data", "media"]),
630
- items: array(subscriptionRefSchema.extend({ quality: qualitySchema.optional() })).min(1).max(APP_RTC_LIMITS.batch)
631
- });
632
- object({ items: array(subscriptionRefSchema.extend({
633
- mid: string().min(1).max(32),
634
- quality: qualitySchema.optional()
635
- })).min(1).max(APP_RTC_LIMITS.mediaSubscriptions) });
636
- object({
637
- items: array(subscriptionRefSchema).min(1).max(APP_RTC_LIMITS.batch),
638
- offer: sessionDescriptionSchema.refine((value) => value.type === "offer", "expected an offer").optional()
639
- });
640
- //#endregion
641
- //#region ../sdk/src/apis/app-room-rtc.ts
641
+ // ../sdk/src/apis/app-room-rtc.ts
642
642
  var AppRtcError = class extends Error {
643
643
  code;
644
644
  constructor(code, message) {
@@ -1625,8 +1625,7 @@ var AppRoomRtc = class {
1625
1625
  for (const handler of this.stateHandlers) handler(state);
1626
1626
  }
1627
1627
  };
1628
- //#endregion
1629
- //#region ../sdk/src/apis/app-realtime.ts
1628
+ // ../sdk/src/apis/app-realtime.ts
1630
1629
  const randomId = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`;
1631
1630
  const textEncoder = new TextEncoder();
1632
1631
  const byteLength = (text) => textEncoder.encode(text).byteLength;
@@ -2212,5 +2211,4 @@ var AppRealtimeApi = class {
2212
2211
  }
2213
2212
  }
2214
2213
  };
2215
- //#endregion
2216
- export { normalizeRealtimeRooms as C, isRealtimeDomain as S, WS_REALTIME_ROOM_HISTORY_CAPABILITY as _, statNumber as a, getRealtimeSpaceRoom as b, HttpTransport as c, normalizeRequestSource as d, readRequestSourceFromEnv as f, WS_REALTIME_ROOM_CAPABILITY as g, WS_COMPACT_STREAM_CAPABILITY as h, readRtcTransportStats as i, joinApiUrl as l, WS_BOARD_AWARENESS_CAPABILITY as m, AppRoom as n, waitForIceGathering as o, isUuidLike as p, IceServerCache as r, HttpError as s, AppRealtimeApi as t, sanitizeAccessToken as u, WS_ROOM_SUBSCRIPTION_CAPABILITY as v, getSessionTurnPatchStreamKey as x, getRealtimeBoardRoom as y };
2214
+ export { getSessionTurnPatchStreamKey as C, getRealtimeSpaceRoom as S, normalizeRealtimeRooms as T, WS_COMPACT_STREAM_CAPABILITY as _, statNumber as a, WS_ROOM_SUBSCRIPTION_CAPABILITY as b, HttpTransport as c, normalizeRequestSource as d, readRequestSourceFromEnv as f, WS_BOARD_AWARENESS_CAPABILITY as g, isUuidOrShortUuid as h, readRtcTransportStats as i, joinApiUrl as l, isUuidLike as m, AppRoom as n, waitForIceGathering as o, isUuid as p, IceServerCache as r, HttpError as s, AppRealtimeApi as t, sanitizeAccessToken as u, WS_REALTIME_ROOM_CAPABILITY as v, isRealtimeDomain as w, getRealtimeBoardRoom as x, WS_REALTIME_ROOM_HISTORY_CAPABILITY as y };
@@ -1,2 +1 @@
1
- import { n as AppRoom } from "./app-realtime.js";
2
- export { AppRoom };
1
+ export { n as AppRoom } from "./app-realtime.js";
@@ -1,5 +1,6 @@
1
- import { et as parseSpaceSlug, st as isUuid, tt as parseUsername } from "./client.js";
2
- //#region ../sdk/src/app-ref.ts
1
+ import { p as isUuid } from "./app-realtime.js";
2
+ import { dt as parseSpaceSlug, ft as parseUsername } from "./client.js";
3
+ // ../sdk/src/app-ref.ts
3
4
  function decodePart(value) {
4
5
  try {
5
6
  return decodeURIComponent(value).trim();
@@ -78,11 +79,9 @@ function parseAppRef(input) {
78
79
  if (parsedPublic) return parsedPublic;
79
80
  throw new AppRefParseError();
80
81
  }
81
- //#endregion
82
- //#region src/app-ref.ts
82
+ // src/app-ref.ts
83
83
  function getAppByRef(client, input) {
84
84
  const ref = parseAppRef(input);
85
85
  return "id" in ref ? client.apps.get(ref.id) : client.apps.getBySlug(ref.username, ref.spaceSlug, ref.appSlug);
86
86
  }
87
- //#endregion
88
87
  export { parseAppRef as n, getAppByRef as t };
@@ -1,7 +1,7 @@
1
- import { C as error, D as json, E as handleHttp, O as jsonRequested, T as formatLocalDateTime, b as resolveSpace, ft as isHttpErrorCode, j as table, k as ok, n as createClientWithAccessToken, t as createClient } from "./client.js";
1
+ import { r as getCohubContext, s as resolveExecutionAppId } from "./environment.js";
2
2
  import { s as HttpError } from "./app-realtime.js";
3
3
  import { t as isUserAppFilter } from "./user-lists.js";
4
- import { r as getCohubContext, s as resolveExecutionAppId } from "./environment.js";
4
+ import { C as error, D as json, E as handleHttp, O as jsonRequested, T as formatLocalDateTime, b as resolveSpace, it as isHttpErrorCode, j as table, k as ok, n as createClientWithAccessToken, t as createClient } from "./client.js";
5
5
  import { n as parseAppRef, t as getAppByRef } from "./app-ref.js";
6
6
  import { n as putBytes, r as putLocalFile } from "./http-put.js";
7
7
  import { t as collectOption$1 } from "./command-input.js";
@@ -12,7 +12,7 @@ import { createHash, randomUUID } from "node:crypto";
12
12
  import { Readable, Transform } from "node:stream";
13
13
  import { link, lstat, mkdir, mkdtemp, rename, rm, rmdir } from "node:fs/promises";
14
14
  import { pipeline } from "node:stream/promises";
15
- //#region ../protocol/src/app-domains.ts
15
+ // ../protocol/dist/app-domains.js
16
16
  const LABEL_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
17
17
  const IPV4_RE = /^\d{1,3}(?:\.\d{1,3}){3}$/;
18
18
  /**
@@ -36,8 +36,7 @@ function normalizeAppDomainHostname(input) {
36
36
  if (/^\d+$/.test(labels.at(-1) ?? "")) return null;
37
37
  return hostname;
38
38
  }
39
- //#endregion
40
- //#region src/app-download.ts
39
+ // src/app-download.ts
41
40
  const MANIFEST_MAX_BYTES = 4194304;
42
41
  const MAX_CONTENT_FILE_BYTES = 1073741824;
43
42
  const DOWNLOAD_CONCURRENCY = 4;
@@ -225,8 +224,7 @@ async function downloadApp(detail, outputOption, fetcher = fetch) {
225
224
  throw cause;
226
225
  }
227
226
  }
228
- //#endregion
229
- //#region src/app-target.ts
227
+ // src/app-target.ts
230
228
  /** Normalize a user-supplied Space path for comparison with fs entries. */
231
229
  function normalizeSpacePath(path) {
232
230
  return path.replace(/^\.\//, "").replace(/\/+$/, "");
@@ -271,8 +269,7 @@ async function checkAppTarget(client, spaceId, target) {
271
269
  return null;
272
270
  }
273
271
  }
274
- //#endregion
275
- //#region src/commands/app-commerce.ts
272
+ // src/commands/app-commerce.ts
276
273
  function requireText(value, label, flag) {
277
274
  const text = value?.trim();
278
275
  if (text) return text;
@@ -525,8 +522,7 @@ Examples:
525
522
  }
526
523
  });
527
524
  }
528
- //#endregion
529
- //#region src/commands/app-domains.ts
525
+ // src/commands/app-domains.ts
530
526
  async function confirm(question, opts, hint) {
531
527
  if (opts.yes) return;
532
528
  if (!process.stdin.isTTY || !process.stdout.isTTY) return error("Confirmation required", hint);
@@ -647,8 +643,7 @@ function registerAppDomains(appsCmd) {
647
643
  }
648
644
  });
649
645
  }
650
- //#endregion
651
- //#region src/commands/apps.ts
646
+ // src/commands/apps.ts
652
647
  const APP_STATUSES = ["published", "disabled"];
653
648
  const APP_VISIBILITIES = ["public", "space"];
654
649
  const collectOption = (value, previous = []) => [...previous, value];
@@ -1468,5 +1463,4 @@ function registerApps(program) {
1468
1463
  }
1469
1464
  });
1470
1465
  }
1471
- //#endregion
1472
1466
  export { registerApps };
@@ -1,5 +1,5 @@
1
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
2
+ // src/commands/auth.ts
3
3
  function registerAuth(program) {
4
4
  const auth = program.command("auth").description("Authentication management");
5
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) => {
@@ -171,5 +171,4 @@ function printDeviceCode(code) {
171
171
  console.log(` ${code.userCode}\n`);
172
172
  console.log(`Code expires at ${new Date(code.expiresAt).toLocaleString()}.`);
173
173
  }
174
- //#endregion
175
174
  export { registerAuth };
@@ -1,5 +1,5 @@
1
1
  import { readFile } from "node:fs/promises";
2
- //#region ../protocol/src/upload.ts
2
+ // ../protocol/dist/upload.js
3
3
  /**
4
4
  * Upload limits — the single source of truth shared by api, gateway, worker,
5
5
  * web and cli.
@@ -18,8 +18,7 @@ const UPLOAD_MAX_BATCH_BYTES = 2 * GiB;
18
18
  /** Maximum file count of one upload batch. */
19
19
  const UPLOAD_MAX_BATCH_FILES = 2e3;
20
20
  const LIKE_STICKER_MAX_FILE_BYTES = 1 * MiB;
21
- //#endregion
22
- //#region src/avatar.ts
21
+ // src/avatar.ts
23
22
  const loadSharp = async () => (await import("sharp")).default;
24
23
  const AVATAR_SIZE = 1024;
25
24
  const AVATAR_QUALITY = 86;
@@ -142,5 +141,4 @@ async function uploadChatImageAsset(input) {
142
141
  height
143
142
  };
144
143
  }
145
- //#endregion
146
144
  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 };
@@ -1,5 +1,4 @@
1
- //#region src/binary-pins.ts
1
+ // src/binary-pins.ts
2
2
  const SANDBOXD_VERSION = "v2.98.0";
3
3
  const RTC_HELPER_VERSION = "v2.96.0";
4
- //#endregion
5
4
  export { SANDBOXD_VERSION as n, RTC_HELPER_VERSION as t };
@@ -1,12 +1,15 @@
1
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";
2
+ import { A as parseBoardMediaSource, k as parseBoardItem } from "./board-model.js";
3
+ import { B as featuredTaskArtifact, d as diffMergePatch, m as parseBoardDocument, p as mergePatch, v as adoptBoardNaturalSize } from "./id.js";
4
+ import { f as boardModelFormat, i as withBoardModelFacts, r as readBoardModelFacts, t as boardModelJsonLength } from "./model-clips.js";
3
5
  import { o as probeMediaSize } from "./media.js";
4
6
  import { t as localMediaFacts } from "./local-media.js";
5
7
  import { n as WORKSPACE_ROOT } from "./operands.js";
6
8
  import { execFile } from "node:child_process";
7
9
  import { resolve } from "node:path";
10
+ import { open } from "node:fs/promises";
8
11
  import { promisify } from "node:util";
9
- //#region ../sdk/src/board/model/media-sizes.ts
12
+ // ../sdk/src/board/model/media-sizes.ts
10
13
  function boardMediaTarget(id, item) {
11
14
  if (item.type === "image" || item.type === "video") {
12
15
  if (item.props.snapshot?.naturalWidth && item.props.snapshot.naturalHeight) return null;
@@ -64,8 +67,7 @@ async function settleBoardMediaSizes(items, options = {}) {
64
67
  await Promise.all(Array.from({ length: CONCURRENCY }, work));
65
68
  return settled;
66
69
  }
67
- //#endregion
68
- //#region src/board-document.ts
70
+ // src/board-document.ts
69
71
  async function loadBoardDocument(spaceId, target) {
70
72
  const board = await createClient().space(spaceId).boards.open(target);
71
73
  let result = await board.get();
@@ -91,8 +93,7 @@ async function loadBoardDocument(spaceId, target) {
91
93
  title: result.title
92
94
  };
93
95
  }
94
- //#endregion
95
- //#region src/board-media.ts
96
+ // src/board-media.ts
96
97
  const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
97
98
  function boardMediaFileResolver(spaceId) {
98
99
  const local = process.env.COHUB_SPACE_ID === spaceId;
@@ -110,8 +111,52 @@ function boardMediaFileResolver(spaceId) {
110
111
  } : resolved?.url ?? null;
111
112
  };
112
113
  }
114
+ const GLTF_JSON_MAX_BYTES = 16777216;
115
+ async function localModelFacts(file) {
116
+ const handle = await open(file, "r").catch(() => null);
117
+ if (!handle) return null;
118
+ try {
119
+ const head = /* @__PURE__ */ new Uint8Array(20);
120
+ const { bytesRead } = await handle.read(head, 0, head.byteLength, 0);
121
+ const length = Math.min(boardModelJsonLength(head.subarray(0, bytesRead)) ?? (await handle.stat()).size, GLTF_JSON_MAX_BYTES);
122
+ const bytes = new Uint8Array(length);
123
+ await handle.read(bytes, 0, length, 0);
124
+ return readBoardModelFacts(bytes);
125
+ } catch {
126
+ return null;
127
+ } finally {
128
+ await handle.close();
129
+ }
130
+ }
131
+ async function settleBoardModelFacts(spaceId, items) {
132
+ if (process.env.COHUB_SPACE_ID !== spaceId) return {};
133
+ const settled = {};
134
+ await Promise.all(Object.entries(items).map(async ([id, item]) => {
135
+ if (item.type !== "file" || item.props.snapshot?.clips || item.props.snapshot?.nodes) return;
136
+ const format = boardModelFormat(item.props.src, item.props.snapshot?.mimeType);
137
+ if (format !== "glb" && format !== "gltf") return;
138
+ const source = parseBoardMediaSource(item.props.src);
139
+ const file = source?.kind === "file" ? resolve(WORKSPACE_ROOT, source.value) : null;
140
+ const facts = file?.startsWith(`/workspace/`) ? await localModelFacts(file) : null;
141
+ const snapshot = facts && withBoardModelFacts(item.props.snapshot, facts);
142
+ if (snapshot) settled[id] = {
143
+ ...item,
144
+ props: {
145
+ ...item.props,
146
+ snapshot
147
+ }
148
+ };
149
+ }));
150
+ return settled;
151
+ }
152
+ async function settleItems(spaceId, items) {
153
+ return {
154
+ ...await settleBoardMediaSizes(items, { resolveFile: boardMediaFileResolver(spaceId) }),
155
+ ...await settleBoardModelFacts(spaceId, items)
156
+ };
157
+ }
113
158
  async function settleBoardDocument(spaceId, document) {
114
- const settled = await settleBoardMediaSizes(document.items, { resolveFile: boardMediaFileResolver(spaceId) });
159
+ const settled = await settleItems(spaceId, document.items);
115
160
  return Object.keys(settled).length ? {
116
161
  ...document,
117
162
  items: {
@@ -124,14 +169,14 @@ async function settleBoardPatch(spaceId, patch, current) {
124
169
  const items = isRecord(patch.items) ? patch.items : {};
125
170
  const created = {};
126
171
  for (const [id, value] of Object.entries(items)) {
127
- if (!isRecord(value) || value.type !== "image" && value.type !== "video") continue;
172
+ if (!isRecord(value) || value.type !== "image" && value.type !== "video" && value.type !== "file") continue;
128
173
  const parsed = parseBoardItem(value, `items.${id}`);
129
174
  if (parsed.ok) created[id] = parsed.item;
130
175
  }
131
176
  const existing = Object.keys(created).length ? await current(Object.keys(created)) : null;
132
177
  if (!existing) return patch;
133
178
  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) });
179
+ const settled = await settleItems(spaceId, created);
135
180
  if (!Object.keys(settled).length) return patch;
136
181
  const adopted = Object.entries(settled).map(([id, item]) => [id, mergePatch(items[id], diffMergePatch(created[id], item))]);
137
182
  return {
@@ -174,8 +219,7 @@ async function settleBoardMediaDurations(spaceId, document, ids) {
174
219
  }
175
220
  return settled;
176
221
  }
177
- //#endregion
178
- //#region src/board-export-resources.ts
222
+ // src/board-export-resources.ts
179
223
  const BOARD_EXPORT_RENDERERS = [
180
224
  "auto",
181
225
  "canvas",
@@ -228,5 +272,4 @@ function createBoardExportImageBudget(renderer, maxBytes) {
228
272
  }
229
273
  };
230
274
  }
231
- //#endregion
232
275
  export { settleBoardMediaDurations as a, settleBoardDocument as i, BoardExportResourceError as n, settleBoardPatch as o, createBoardExportImageBudget as r, loadBoardDocument as s, BOARD_EXPORT_RENDERERS as t };