@neta-art/cohub-cli 10.29.0 → 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,8 +1,8 @@
1
1
  import { a as array, c as discriminatedUnion, d as literal, f as number, g as tuple, h as string, m as record, n as _enum, p as object, r as _null, s as boolean } from "./schemas.js";
2
- import { H as isBoardPath, U as parseBoardManifest, a as isTextMime, c as normalizeMime, i as isModelMime, l as applyBoardDelta, m as parseBoardDocument, o as mimeTypeForPath, r as sameJson, t as createBoardEntityId, u as applyBoardPatchToDocument } from "./id.js";
3
- import { C as normalizeRealtimeRooms, S as isRealtimeDomain, _ as WS_REALTIME_ROOM_HISTORY_CAPABILITY, a as statNumber, b as getRealtimeSpaceRoom, c as HttpTransport, f as readRequestSourceFromEnv, g as WS_REALTIME_ROOM_CAPABILITY, h as WS_COMPACT_STREAM_CAPABILITY, i as readRtcTransportStats, m as WS_BOARD_AWARENESS_CAPABILITY, o as waitForIceGathering, r as IceServerCache, s as HttpError, t as AppRealtimeApi, u as sanitizeAccessToken, v as WS_ROOM_SUBSCRIPTION_CAPABILITY, x as getSessionTurnPatchStreamKey, y as getRealtimeBoardRoom } from "./app-realtime.js";
2
+ import { U as isBoardPath, W as parseBoardManifest, a as isTextMime, c as normalizeMime, i as isModelMime, l as applyBoardDelta, m as parseBoardDocument, o as mimeTypeForPath, r as sameJson, t as createBoardEntityId, u as applyBoardPatchToDocument } from "./id.js";
3
+ import { C as getSessionTurnPatchStreamKey, S as getRealtimeSpaceRoom, T as normalizeRealtimeRooms, _ as WS_COMPACT_STREAM_CAPABILITY, a as statNumber, b as WS_ROOM_SUBSCRIPTION_CAPABILITY, c as HttpTransport, f as readRequestSourceFromEnv, g as WS_BOARD_AWARENESS_CAPABILITY, h as isUuidOrShortUuid, i as readRtcTransportStats, o as waitForIceGathering, r as IceServerCache, s as HttpError, t as AppRealtimeApi, u as sanitizeAccessToken, v as WS_REALTIME_ROOM_CAPABILITY, w as isRealtimeDomain, x as getRealtimeBoardRoom, y as WS_REALTIME_ROOM_HISTORY_CAPABILITY } from "./app-realtime.js";
4
4
  import { a as resolveApiBaseUrl, c as resolveExecutionToken, d as resolveWebsocketUrl, f as PERMISSIONS, i as normalizeBaseUrl, l as resolveVoiceInputWebsocketUrl, o as resolveCohubEnvironment, s as resolveExecutionAppId, t as COHUB_ENVIRONMENTS, u as resolveWebBaseUrl } from "./environment.js";
5
- import { Agent, request } from "node:http";
5
+ import { Agent, request as request$1 } from "node:http";
6
6
  import { homedir } from "node:os";
7
7
  import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
8
8
  import { dirname, isAbsolute, join, resolve } from "node:path";
@@ -10,9 +10,9 @@ import { createHash, randomUUID } from "node:crypto";
10
10
  import { createConnection, createServer as createServer$1 } from "node:net";
11
11
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
12
12
  import { Readable } from "node:stream";
13
- import { chmod, mkdir, open, readFile, readdir, realpath, rename, rm, rmdir, stat, utimes, writeFile } from "node:fs/promises";
13
+ import { chmod, mkdir, open as open$1, readFile, readdir, realpath, rename, rm, rmdir, stat, utimes, writeFile } from "node:fs/promises";
14
14
  import process$1 from "node:process";
15
- //#region ../protocol/src/app-authorization.ts
15
+ // ../protocol/dist/app-authorization.js
16
16
  const appAuthorizationTargetSchema = discriminatedUnion("kind", [
17
17
  object({ kind: literal("account") }),
18
18
  object({
@@ -76,8 +76,7 @@ const appAuthorizationResultSchema = discriminatedUnion("status", [
76
76
  code: string()
77
77
  })
78
78
  ]);
79
- //#endregion
80
- //#region ../protocol/src/model/metrics.ts
79
+ // ../protocol/dist/model/metrics.js
81
80
  const count = number().finite().nonnegative();
82
81
  const usageSchema = object({
83
82
  input: count.optional(),
@@ -226,8 +225,7 @@ function readSessionStats(meta) {
226
225
  const result = sessionStatsSchema.safeParse(normalized);
227
226
  return result.success ? result.data : null;
228
227
  }
229
- //#endregion
230
- //#region ../protocol/src/fs/sandbox.ts
228
+ // ../protocol/dist/fs/sandbox.js
231
229
  var SpaceFsError = class extends Error {
232
230
  status;
233
231
  code;
@@ -817,8 +815,7 @@ function createSandboxSpaceFs(options) {
817
815
  })
818
816
  };
819
817
  }
820
- //#endregion
821
- //#region ../protocol/src/fs/index.ts
818
+ // ../protocol/dist/fs/index.js
822
819
  function isSpaceFsSymlink(value) {
823
820
  return "kind" in value && value.kind === "symlink";
824
821
  }
@@ -840,8 +837,7 @@ function matchesSpaceFsVersion(actual, expected) {
840
837
  function spaceFsVersionMatches(current, expected) {
841
838
  return current?.exists === true && current.isDirectory !== true && matchesSpaceFsVersion(current, expected);
842
839
  }
843
- //#endregion
844
- //#region ../protocol/src/display/schema.ts
840
+ // ../protocol/dist/display/schema.js
845
841
  const unit = number().min(0).max(1);
846
842
  const displayIdSchema = string().regex(/^[A-Za-z0-9._-]{1,64}$/);
847
843
  const displayWindowIdSchema = string().regex(/^[A-Za-z0-9._:-]{1,64}$/);
@@ -1288,15 +1284,495 @@ const DISPLAY_TURNS_DIR = `${DISPLAY_CACHE_DIR}/turns`;
1288
1284
  const DISPLAY_RECORDINGS_DIR = `${DISPLAY_CACHE_DIR}/recordings`;
1289
1285
  const displayTurnLogPath = (turnId) => `${DISPLAY_TURNS_DIR}/${turnId}.ndjson`;
1290
1286
  const displayRecordingDir = (id) => `${DISPLAY_RECORDINGS_DIR}/${id}`;
1291
- //#endregion
1292
- //#region ../protocol/src/space-hooks.ts
1287
+ // ../protocol/dist/space-hooks.js
1293
1288
  const SPACE_HOOK_WEBHOOK_SECRET_HEADER = "x-cohub-webhook-secret";
1294
- //#endregion
1295
- //#region ../protocol/src/likes.ts
1289
+ const USERNAME_PATTERN = /^(?!.*--)[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/;
1290
+ const SPACE_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9_-]{0,78}[a-z0-9])?$/;
1291
+ /**
1292
+ * Platform-owned path segments that must not be newly assigned to public
1293
+ * identities. Existing stored values remain readable through parse helpers.
1294
+ */
1295
+ const RESERVED_PLATFORM_PATH_SEGMENTS = Object.freeze([
1296
+ "admin",
1297
+ "api",
1298
+ "assets",
1299
+ "auth",
1300
+ "callback",
1301
+ "changelog",
1302
+ "compare",
1303
+ "dev",
1304
+ "docs",
1305
+ "explore",
1306
+ "features",
1307
+ "guides",
1308
+ "invite",
1309
+ "landing",
1310
+ "legal",
1311
+ "login",
1312
+ "logout",
1313
+ "mobile",
1314
+ "new",
1315
+ "org",
1316
+ "pricing",
1317
+ "pwa",
1318
+ "referrals",
1319
+ "sessions",
1320
+ "settings",
1321
+ "spaces",
1322
+ "static",
1323
+ "teams",
1324
+ "trending",
1325
+ "u",
1326
+ "updates",
1327
+ "user",
1328
+ "users",
1329
+ "use-cases",
1330
+ "work-auth",
1331
+ "app-auth",
1332
+ "zh"
1333
+ ]);
1334
+ new Set(RESERVED_PLATFORM_PATH_SEGMENTS);
1335
+ [...RESERVED_PLATFORM_PATH_SEGMENTS];
1336
+ function parseUsername(value) {
1337
+ if (value === null || value === void 0) return null;
1338
+ const normalized = value.trim().toLowerCase();
1339
+ return USERNAME_PATTERN.test(normalized) ? normalized : null;
1340
+ }
1341
+ function parseSpaceSlug(value) {
1342
+ if (value === null || value === void 0) return null;
1343
+ const normalized = value.trim();
1344
+ return SPACE_SLUG_PATTERN.test(normalized) ? normalized : null;
1345
+ }
1346
+ // ../protocol/dist/navigation.js
1347
+ const NAVIGATION_ERROR_MESSAGE_MAX_LENGTH = 2e3;
1348
+ // ../protocol/dist/desktop-command.js
1349
+ /** A command nobody accepts within this window settles as `no_active_client`. */
1350
+ const DESKTOP_COMMAND_ACCEPT_TIMEOUT_MS = 1e4;
1351
+ const DESKTOP_COMMAND_OPEN_TIMEOUT_MS = 3e4;
1352
+ const DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS = 6e5;
1353
+ const DESKTOP_COMMAND_MAX_TIMEOUT_MS = 432e5;
1354
+ const DESKTOP_COMMAND_TERMINAL_STATUSES = [
1355
+ "applied",
1356
+ "no_active_client",
1357
+ "desktop_host_unavailable",
1358
+ "rejected",
1359
+ "unsupported",
1360
+ "timeout"
1361
+ ];
1362
+ const isTerminalDesktopCommandStatus = (status) => DESKTOP_COMMAND_TERMINAL_STATUSES.includes(status);
1363
+ /**
1364
+ * The surface a desktop open should use: an explicit request wins, then
1365
+ * whatever the App declared at publish time. `window` is the implicit
1366
+ * default and yields `undefined` so the command stays compact.
1367
+ */
1368
+ function resolveOpenSurface(requested, declared) {
1369
+ return (requested ?? declared) === "overlay" ? "overlay" : void 0;
1370
+ }
1371
+ const defaultDesktopCommandTimeoutMs = (command) => command.call ? DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS : DESKTOP_COMMAND_OPEN_TIMEOUT_MS;
1372
+ new RegExp(`^[A-Za-z][A-Za-z0-9_.:-]{0,63}$`);
1373
+ const DESKTOP_COMMAND_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
1374
+ const parseDesktopCommandId = (value) => {
1375
+ if (typeof value !== "string") return null;
1376
+ const trimmed = value.trim();
1377
+ return DESKTOP_COMMAND_ID_RE.test(trimmed) ? trimmed : null;
1378
+ };
1379
+ // ../protocol/dist/app-surface.js
1380
+ const APP_SURFACE_PROTOCOL = "cohub.app.surface";
1381
+ const isRecord$7 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
1382
+ const isSurfaceEnvelope = (value) => isRecord$7(value) && value.protocol === "cohub.app.surface" && value.version === 1;
1383
+ const parseComposerChipKey = (value) => {
1384
+ if (typeof value !== "string") return null;
1385
+ const key = value.trim();
1386
+ if (!key || key.length > 80) return null;
1387
+ return key;
1388
+ };
1389
+ const parseAppComposerChipSet = (value) => {
1390
+ if (!isSurfaceEnvelope(value) || value.type !== "composer.chip.set" || !isRecord$7(value.chip)) return null;
1391
+ const key = parseComposerChipKey(value.chip.key);
1392
+ if (!key || typeof value.chip.label !== "string" || typeof value.chip.content !== "string") return null;
1393
+ const label = value.chip.label.trim();
1394
+ if (!label || label.length > 120) return null;
1395
+ if (!value.chip.content.trim()) return null;
1396
+ if (new TextEncoder().encode(value.chip.content).length > 32768) return null;
1397
+ return {
1398
+ protocol: APP_SURFACE_PROTOCOL,
1399
+ version: 1,
1400
+ type: "composer.chip.set",
1401
+ chip: {
1402
+ key,
1403
+ label,
1404
+ content: value.chip.content
1405
+ }
1406
+ };
1407
+ };
1408
+ const parseAppComposerChipClear = (value) => {
1409
+ if (!isSurfaceEnvelope(value) || value.type !== "composer.chip.clear") return null;
1410
+ const key = parseComposerChipKey(value.key);
1411
+ return key ? {
1412
+ protocol: APP_SURFACE_PROTOCOL,
1413
+ version: 1,
1414
+ type: "composer.chip.clear",
1415
+ key
1416
+ } : null;
1417
+ };
1418
+ const parseAppSurfaceRequest = (value) => {
1419
+ if (!isSurfaceEnvelope(value) || value.type !== "request") return null;
1420
+ if (typeof value.requestId !== "string" || !value.requestId) return null;
1421
+ if (typeof value.method !== "string" || !value.method) return null;
1422
+ const commandId = parseDesktopCommandId(value.commandId);
1423
+ if (!commandId) return null;
1424
+ return {
1425
+ protocol: APP_SURFACE_PROTOCOL,
1426
+ version: 1,
1427
+ type: "request",
1428
+ requestId: value.requestId,
1429
+ method: value.method,
1430
+ ...value.input === void 0 ? {} : { input: value.input },
1431
+ commandId
1432
+ };
1433
+ };
1434
+ const buildAppSurfaceReady = (methods) => ({
1435
+ protocol: APP_SURFACE_PROTOCOL,
1436
+ version: 1,
1437
+ type: "ready",
1438
+ methods: [...methods]
1439
+ });
1440
+ const buildAppSurfaceResponse = (input) => ({
1441
+ protocol: APP_SURFACE_PROTOCOL,
1442
+ version: 1,
1443
+ type: "response",
1444
+ ...input
1445
+ });
1446
+ const buildAppComposerChipSet = (chip) => ({
1447
+ protocol: APP_SURFACE_PROTOCOL,
1448
+ version: 1,
1449
+ type: "composer.chip.set",
1450
+ chip
1451
+ });
1452
+ const buildAppComposerChipClear = (key) => ({
1453
+ protocol: APP_SURFACE_PROTOCOL,
1454
+ version: 1,
1455
+ type: "composer.chip.clear",
1456
+ key
1457
+ });
1458
+ // ../protocol/dist/app-runtime.js
1459
+ const APP_RUNTIME_PROTOCOL = "cohub.app.runtime";
1460
+ const isRecord$6 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
1461
+ const buildAppRuntimeReady = () => ({
1462
+ protocol: APP_RUNTIME_PROTOCOL,
1463
+ version: 1,
1464
+ type: "ready"
1465
+ });
1466
+ const buildAppRuntimeCloseRequest = () => ({
1467
+ protocol: APP_RUNTIME_PROTOCOL,
1468
+ version: 1,
1469
+ type: "close.request"
1470
+ });
1471
+ const finite = (value) => typeof value === "number" && Number.isFinite(value);
1472
+ const buildAppRuntimeConfigureRequest = (input) => ({
1473
+ protocol: APP_RUNTIME_PROTOCOL,
1474
+ version: 1,
1475
+ type: "configure.request",
1476
+ ...input
1477
+ });
1478
+ const buildAppRuntimePointer = (input) => ({
1479
+ protocol: APP_RUNTIME_PROTOCOL,
1480
+ version: 1,
1481
+ type: "pointer",
1482
+ x: input.x,
1483
+ y: input.y,
1484
+ down: input.down
1485
+ });
1486
+ const isRuntimeMessage = (value, type) => isRecord$6(value) && value.protocol === "cohub.app.runtime" && value.version === 1 && value.type === type;
1487
+ const envelope$1 = (type) => ({
1488
+ protocol: APP_RUNTIME_PROTOCOL,
1489
+ version: 1,
1490
+ type
1491
+ });
1492
+ const boundedText = (value, max) => {
1493
+ if (typeof value !== "string") return null;
1494
+ const text = value.replace(/\s+/g, " ").trim();
1495
+ return text ? text.slice(0, max) : null;
1496
+ };
1497
+ const APP_RUNTIME_HAPTICS = [
1498
+ "tick",
1499
+ "confirm",
1500
+ "reject",
1501
+ "longPress"
1502
+ ];
1503
+ const APP_RUNTIME_HAPTIC_VIBRATION = {
1504
+ tick: 8,
1505
+ confirm: [
1506
+ 12,
1507
+ 24,
1508
+ 12
1509
+ ],
1510
+ reject: [
1511
+ 24,
1512
+ 32,
1513
+ 24
1514
+ ],
1515
+ longPress: 14
1516
+ };
1517
+ const buildAppRuntimeHaptic = (kind) => ({
1518
+ ...envelope$1("haptic"),
1519
+ kind
1520
+ });
1521
+ const buildAppRuntimeAnnounce = () => envelope$1("announce");
1522
+ const parseAppRuntimeAnnounce = (value) => isRuntimeMessage(value, "announce") ? buildAppRuntimeAnnounce() : null;
1523
+ const buildAppRuntimeWindowState = (state) => ({
1524
+ ...envelope$1("window.state"),
1525
+ title: state.title,
1526
+ status: state.status,
1527
+ dirty: state.dirty
1528
+ });
1529
+ const requestIdOf = (value) => typeof value.requestId === "string" && value.requestId && value.requestId.length <= 128 ? value.requestId : null;
1530
+ const buildAppRuntimeClosePrepare = (requestId) => ({
1531
+ ...envelope$1("close.prepare"),
1532
+ requestId
1533
+ });
1534
+ const parseAppRuntimeClosePrepare = (value) => {
1535
+ if (!isRuntimeMessage(value, "close.prepare")) return null;
1536
+ const requestId = requestIdOf(value);
1537
+ return requestId ? buildAppRuntimeClosePrepare(requestId) : null;
1538
+ };
1539
+ const buildAppRuntimeClosePrepared = (input) => ({
1540
+ ...envelope$1("close.prepared"),
1541
+ requestId: input.requestId,
1542
+ ok: input.ok
1543
+ });
1544
+ /** Select all, copy, paste, cut, undo, redo: the browser's, and the App's. */
1545
+ const EDITING_CHORD_KEYS = /* @__PURE__ */ new Set([
1546
+ "a",
1547
+ "c",
1548
+ "v",
1549
+ "x",
1550
+ "y",
1551
+ "z"
1552
+ ]);
1553
+ /** Whether a Ctrl / Meta chord may reach the host; both sides apply this rule. */
1554
+ const isAppRuntimeHostChord = (input) => (input.ctrlKey || input.metaKey) && !EDITING_CHORD_KEYS.has(input.key.toLowerCase());
1555
+ const buildAppRuntimeKey = (input) => ({
1556
+ ...envelope$1("key"),
1557
+ key: input.key,
1558
+ code: input.code,
1559
+ altKey: input.altKey,
1560
+ ctrlKey: input.ctrlKey,
1561
+ metaKey: input.metaKey,
1562
+ shiftKey: input.shiftKey
1563
+ });
1564
+ /** Resource kinds the Cohub host can drop into an App. */
1565
+ const APP_DROP_RESOURCE_TYPES = [
1566
+ "file",
1567
+ "task",
1568
+ "app",
1569
+ "session",
1570
+ "checkpoint"
1571
+ ];
1572
+ const isDropResourceType = (value) => APP_DROP_RESOURCE_TYPES.includes(value);
1573
+ const MAX_DROP_RESOURCES = 100;
1574
+ const parseDropResource = (value) => {
1575
+ if (!isRecord$6(value) || !isDropResourceType(value.type)) return null;
1576
+ const ref = boundedText(value.ref, 4096);
1577
+ if (!ref) return null;
1578
+ const resource = {
1579
+ type: value.type,
1580
+ ref
1581
+ };
1582
+ for (const key of [
1583
+ "title",
1584
+ "path",
1585
+ "mimeType",
1586
+ "appId",
1587
+ "href",
1588
+ "taskRunId"
1589
+ ]) {
1590
+ const text = boundedText(value[key], 4096);
1591
+ if (text) resource[key] = text;
1592
+ }
1593
+ if (finite(value.size) && value.size >= 0) resource.size = value.size;
1594
+ if (finite(value.mtimeMs)) resource.mtimeMs = value.mtimeMs;
1595
+ if (isRecord$6(value.snapshot)) resource.snapshot = value.snapshot;
1596
+ return resource;
1597
+ };
1598
+ const parseDropTypes = (value) => Array.isArray(value) ? [...new Set(value.filter(isDropResourceType))] : [];
1599
+ const buildAppRuntimeDropConfig = (accept) => ({
1600
+ ...envelope$1("drop.config"),
1601
+ accept: [...accept]
1602
+ });
1603
+ const buildAppRuntimeDrag = (input) => ({
1604
+ ...envelope$1("drag"),
1605
+ phase: input.phase,
1606
+ x: input.x,
1607
+ y: input.y,
1608
+ types: [...input.types],
1609
+ ...input.phase === "drop" ? { resources: input.resources ?? [] } : {}
1610
+ });
1611
+ const parseAppRuntimeDrag = (value) => {
1612
+ if (!isRuntimeMessage(value, "drag")) return null;
1613
+ if (value.phase !== "over" && value.phase !== "leave" && value.phase !== "drop") return null;
1614
+ if (!finite(value.x) || !finite(value.y)) return null;
1615
+ const resources = value.phase === "drop" && Array.isArray(value.resources) ? value.resources.slice(0, MAX_DROP_RESOURCES).map(parseDropResource).filter((resource) => resource !== null) : void 0;
1616
+ return buildAppRuntimeDrag({
1617
+ phase: value.phase,
1618
+ x: value.x,
1619
+ y: value.y,
1620
+ types: parseDropTypes(value.types),
1621
+ ...resources ? { resources } : {}
1622
+ });
1623
+ };
1624
+ /** Public design tokens, sent as resolved CSS values. */
1625
+ const APP_APPEARANCE_TOKENS = [
1626
+ "bg-primary",
1627
+ "bg-content",
1628
+ "bg-surface",
1629
+ "bg-elevated",
1630
+ "bg-input",
1631
+ "bg-hover",
1632
+ "bg-active",
1633
+ "text-primary",
1634
+ "text-secondary",
1635
+ "text-tertiary",
1636
+ "text-placeholder",
1637
+ "text-disabled",
1638
+ "border-primary",
1639
+ "border-subtle",
1640
+ "brand",
1641
+ "brand-hover",
1642
+ "brand-soft",
1643
+ "brand-muted",
1644
+ "brand-border",
1645
+ "brand-ring",
1646
+ "brand-contrast-fg",
1647
+ "error-fg",
1648
+ "success",
1649
+ "warning",
1650
+ "error",
1651
+ "info",
1652
+ "status-running",
1653
+ "selection-bg",
1654
+ "overlay-scrim",
1655
+ "shadow-subtle",
1656
+ "shadow-medium",
1657
+ "shadow-strong",
1658
+ "font-sans",
1659
+ "font-mono"
1660
+ ];
1661
+ /** CSS custom property an App reads a shared token from, e.g. `--cohub-bg-primary`. */
1662
+ const appAppearanceVar = (token) => `--cohub-${token}`;
1663
+ // ../protocol/dist/app-navigation.js
1664
+ const APP_NAVIGATION_PROTOCOL = "cohub.app.navigation";
1665
+ const APP_NAVIGATION_MAX_ERROR_CODE_LENGTH = 64;
1666
+ const APP_NAVIGATION_MAX_ERROR_MESSAGE_LENGTH = NAVIGATION_ERROR_MESSAGE_MAX_LENGTH;
1667
+ const isRecord$5 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
1668
+ const text$1 = (value, max) => typeof value === "string" && value.trim() && value.length <= max ? value : null;
1669
+ const buildAppNavigationOpenMessage = (input) => ({
1670
+ protocol: APP_NAVIGATION_PROTOCOL,
1671
+ version: 1,
1672
+ type: "open",
1673
+ ...input
1674
+ });
1675
+ const NAVIGATION_REASONS = /* @__PURE__ */ new Set([
1676
+ "unsupported",
1677
+ "invalid_target",
1678
+ "inaccessible",
1679
+ "timeout"
1680
+ ]);
1681
+ function parseNavigationCall(value) {
1682
+ if (value === void 0) return void 0;
1683
+ if (!isRecord$5(value) || typeof value.ok !== "boolean") return null;
1684
+ if (value.ok) return {
1685
+ ok: true,
1686
+ ...value.result === void 0 ? {} : { result: value.result }
1687
+ };
1688
+ const code = text$1(value.code, APP_NAVIGATION_MAX_ERROR_CODE_LENGTH);
1689
+ const message = text$1(value.message, APP_NAVIGATION_MAX_ERROR_MESSAGE_LENGTH);
1690
+ if (!code || !message) return null;
1691
+ return {
1692
+ ok: false,
1693
+ code,
1694
+ message
1695
+ };
1696
+ }
1697
+ const parseAppNavigationOpenResponse = (value) => {
1698
+ if (!isRecord$5(value)) return null;
1699
+ if (value.protocol !== "cohub.app.navigation" || value.version !== 1 || value.type !== "open.result" || !text$1(value.requestId, 128) || typeof value.handled !== "boolean" || value.reason !== void 0 && !NAVIGATION_REASONS.has(value.reason)) return null;
1700
+ const call = parseNavigationCall(value.call);
1701
+ if (call === null) return null;
1702
+ return {
1703
+ protocol: APP_NAVIGATION_PROTOCOL,
1704
+ version: 1,
1705
+ type: "open.result",
1706
+ requestId: value.requestId,
1707
+ handled: value.handled,
1708
+ ...value.reason === void 0 ? {} : { reason: value.reason },
1709
+ ...call === void 0 ? {} : { call }
1710
+ };
1711
+ };
1712
+ const envelope = {
1713
+ protocol: "cohub.app.embed",
1714
+ version: 1
1715
+ };
1716
+ const isRecord$4 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
1717
+ const isEnvelope = (value) => isRecord$4(value) && value.protocol === "cohub.app.embed" && value.version === 1;
1718
+ const parseEmbedId = (value) => typeof value === "string" && value.trim() && value.length <= 128 ? value : null;
1719
+ function parseAppEmbedAttachRequest(value) {
1720
+ if (!isEnvelope(value) || value.type !== "attach.request") return null;
1721
+ return {
1722
+ ...envelope,
1723
+ type: "attach.request"
1724
+ };
1725
+ }
1726
+ function parseAppEmbedCloseRequest(value) {
1727
+ if (!isEnvelope(value) || value.type !== "close.request") return null;
1728
+ const embedId = parseEmbedId(value.embedId);
1729
+ return embedId ? {
1730
+ ...envelope,
1731
+ type: "close.request",
1732
+ embedId
1733
+ } : null;
1734
+ }
1735
+ const buildAppEmbedAttach = (input) => ({
1736
+ ...envelope,
1737
+ type: "attach",
1738
+ ...input
1739
+ });
1740
+ const buildAppEmbedShellChanged = (input) => ({
1741
+ ...envelope,
1742
+ type: "shell.changed",
1743
+ ...input
1744
+ });
1745
+ // ../protocol/dist/app-devices.js
1746
+ const APP_DEVICES = [
1747
+ "camera",
1748
+ "microphone",
1749
+ "screen",
1750
+ "location"
1751
+ ];
1752
+ const isAppDevice = (value) => typeof value === "string" && APP_DEVICES.includes(value);
1753
+ function parseAppDevices(value) {
1754
+ const items = typeof value === "string" ? value.split(/[\s,]+/) : Array.isArray(value) ? value : [];
1755
+ const wanted = new Set(items.map((item) => typeof item === "string" ? item.trim().toLowerCase() : item).filter(isAppDevice));
1756
+ return APP_DEVICES.filter((device) => wanted.has(device));
1757
+ }
1758
+ const APP_DEVICES_REQUEST_TYPE = "cohub.app.devices.request";
1759
+ const APP_DEVICES_RESULT_TYPE = "cohub.app.devices.result";
1760
+ function parseAppDevicesResult(value) {
1761
+ if (!value || typeof value !== "object") return null;
1762
+ const record = value;
1763
+ if (record.type !== "cohub.app.devices.result" || typeof record.requestId !== "string") return null;
1764
+ const status = record.status;
1765
+ if (status !== "granted" && status !== "denied" && status !== "unavailable") return null;
1766
+ return {
1767
+ type: APP_DEVICES_RESULT_TYPE,
1768
+ requestId: record.requestId,
1769
+ status
1770
+ };
1771
+ }
1772
+ // ../protocol/dist/likes.js
1296
1773
  const LIKED_LABEL_NAME = "Liked";
1297
1774
  const LIKED_LABEL_SYSTEM_KEY = "user:liked";
1298
- //#endregion
1299
- //#region ../sdk/src/apis/billing.ts
1775
+ // ../sdk/src/apis/billing.ts
1300
1776
  var BillingApi = class {
1301
1777
  transport;
1302
1778
  constructor(transport) {
@@ -1387,8 +1863,7 @@ var BillingApi = class {
1387
1863
  });
1388
1864
  }
1389
1865
  };
1390
- //#endregion
1391
- //#region ../sdk/src/apis/channels.ts
1866
+ // ../sdk/src/apis/channels.ts
1392
1867
  var ChannelsApi = class {
1393
1868
  transport;
1394
1869
  constructor(transport) {
@@ -1425,8 +1900,7 @@ var ChannelsApi = class {
1425
1900
  return this.transport.request(`/api/channels/${id}`, { method: "DELETE" });
1426
1901
  }
1427
1902
  };
1428
- //#endregion
1429
- //#region ../sdk/src/apis/cron-jobs.ts
1903
+ // ../sdk/src/apis/cron-jobs.ts
1430
1904
  const toQuery = (params) => {
1431
1905
  const query = new URLSearchParams();
1432
1906
  for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null && value !== "") query.set(key, String(value));
@@ -1466,8 +1940,7 @@ var CronJobsApi = class {
1466
1940
  return this.transport.request(`/api/cron-jobs/${cronJobId}/runs${query}`);
1467
1941
  }
1468
1942
  };
1469
- //#endregion
1470
- //#region ../sdk/src/apis/generations.ts
1943
+ // ../sdk/src/apis/generations.ts
1471
1944
  const DEFAULT_INTERVAL_MS = 1500;
1472
1945
  const DEFAULT_TIMEOUT_MS = 18e5;
1473
1946
  function sleep$2(ms, signal) {
@@ -1543,8 +2016,7 @@ var GenerationsApi = class {
1543
2016
  return this.wait(created.taskRunId, options);
1544
2017
  }
1545
2018
  };
1546
- //#endregion
1547
- //#region ../sdk/src/apis/models.ts
2019
+ // ../sdk/src/apis/models.ts
1548
2020
  const MULTIMODAL_MODEL_TYPE = "multimodal";
1549
2021
  var ModelsApi = class {
1550
2022
  transport;
@@ -1563,8 +2035,7 @@ var ModelsApi = class {
1563
2035
  return this.transport.request("/api/models/status");
1564
2036
  }
1565
2037
  };
1566
- //#endregion
1567
- //#region ../sdk/src/apis/prompts.ts
2038
+ // ../sdk/src/apis/prompts.ts
1568
2039
  var PromptsApi = class {
1569
2040
  transport;
1570
2041
  constructor(transport) {
@@ -1578,8 +2049,7 @@ var PromptsApi = class {
1578
2049
  return this.transport.request(path, { fetch: customFetch });
1579
2050
  }
1580
2051
  };
1581
- //#endregion
1582
- //#region ../sdk/src/apis/skills.ts
2052
+ // ../sdk/src/apis/skills.ts
1583
2053
  var SkillsApi = class {
1584
2054
  transport;
1585
2055
  constructor(transport) {
@@ -1593,8 +2063,7 @@ var SkillsApi = class {
1593
2063
  return this.transport.request(path, { fetch: customFetch });
1594
2064
  }
1595
2065
  };
1596
- //#endregion
1597
- //#region ../sdk/src/apis/public-assets.ts
2066
+ // ../sdk/src/apis/public-assets.ts
1598
2067
  function createAbortError() {
1599
2068
  if (typeof DOMException === "function") return new DOMException("The operation was aborted.", "AbortError");
1600
2069
  const error = /* @__PURE__ */ new Error("The operation was aborted.");
@@ -1744,8 +2213,7 @@ var PublicAssetsApi = class {
1744
2213
  return this.uploadChatAttachment(input);
1745
2214
  }
1746
2215
  };
1747
- //#endregion
1748
- //#region ../sdk/src/apis/search.ts
2216
+ // ../sdk/src/apis/search.ts
1749
2217
  var SearchApi = class {
1750
2218
  transport;
1751
2219
  constructor(transport) {
@@ -1772,8 +2240,7 @@ var SearchApi = class {
1772
2240
  return this.transport.request(`/api/palette/overview${query ? `?${query}` : ""}`, { fetch: customFetch });
1773
2241
  }
1774
2242
  };
1775
- //#endregion
1776
- //#region ../sdk/src/apis/references.ts
2243
+ // ../sdk/src/apis/references.ts
1777
2244
  const toSelector = (ref) => typeof ref === "string" ? ref : `${ref.type}:${ref.id}`;
1778
2245
  /**
1779
2246
  * Neutral access to the resource reference index. `query` lists references
@@ -1803,8 +2270,7 @@ var ReferencesApi = class {
1803
2270
  return this.transport.request(`/api/references/aggregate?${params.toString()}`, { fetch: customFetch });
1804
2271
  }
1805
2272
  };
1806
- //#endregion
1807
- //#region ../sdk/src/apis/session-access.ts
2273
+ // ../sdk/src/apis/session-access.ts
1808
2274
  var SessionAccessApi = class {
1809
2275
  transport;
1810
2276
  constructor(transport) {
@@ -1824,15 +2290,14 @@ var SessionAccessApi = class {
1824
2290
  return this.transport.request(`/api/sessions/${sessionId}/access`, { method: "DELETE" });
1825
2291
  }
1826
2292
  };
1827
- //#endregion
1828
- //#region ../sdk/src/http-error.ts
2293
+ // ../sdk/src/http-error.ts
1829
2294
  function isHttpErrorCode(error, code) {
1830
2295
  return error instanceof HttpError && error.code === code;
1831
2296
  }
1832
- const isRecord$7 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
2297
+ const isRecord$3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
1833
2298
  function isBillingConversionIntent(value) {
1834
- if (!isRecord$7(value)) return false;
1835
- return (value.level === "soft" || value.level === "hard") && typeof value.title === "string" && typeof value.message === "string" && isRecord$7(value.primaryAction) && value.primaryAction.action === "open_billing_conversion";
2299
+ if (!isRecord$3(value)) return false;
2300
+ return (value.level === "soft" || value.level === "hard") && typeof value.title === "string" && typeof value.message === "string" && isRecord$3(value.primaryAction) && value.primaryAction.action === "open_billing_conversion";
1836
2301
  }
1837
2302
  /**
1838
2303
  * Extracts the standard `billing` payload from a response body, an
@@ -1842,13 +2307,12 @@ function isBillingConversionIntent(value) {
1842
2307
  */
1843
2308
  function extractBillingPayload(source) {
1844
2309
  const root = source instanceof HttpError ? source.body : source;
1845
- if (!isRecord$7(root)) return null;
1846
- const billing = isRecord$7(root.billing) ? root.billing : root;
2310
+ if (!isRecord$3(root)) return null;
2311
+ const billing = isRecord$3(root.billing) ? root.billing : root;
1847
2312
  if (!isBillingConversionIntent(billing.conversion)) return null;
1848
2313
  return billing;
1849
2314
  }
1850
- //#endregion
1851
- //#region ../sdk/src/apis/file-list.ts
2315
+ // ../sdk/src/apis/file-list.ts
1852
2316
  const DIRECTORY_CHANGED_RETRY_DELAYS_MS = [
1853
2317
  100,
1854
2318
  250,
@@ -1907,22 +2371,19 @@ async function readAllPages(readPage, path) {
1907
2371
  entries: [...entries.values()].sort((a, b) => rank[a.type] - rank[b.type] || a.name.localeCompare(b.name))
1908
2372
  };
1909
2373
  }
1910
- //#endregion
1911
- //#region ../sdk/src/apis/session-context.ts
2374
+ // ../sdk/src/apis/session-context.ts
1912
2375
  function requireSessionContext(response, spaceId, sessionId) {
1913
2376
  if (response.session.spaceId !== spaceId || response.session.id !== sessionId) throw new HttpError("Session not found in this space", 404, { code: "session_context_mismatch" });
1914
2377
  return response;
1915
2378
  }
1916
- //#endregion
1917
- //#region ../sdk/src/realtime.ts
2379
+ // ../sdk/src/realtime.ts
1918
2380
  function ensureRealtimeConnected(websocketClient) {
1919
2381
  if (websocketClient.state === "open" || websocketClient.state === "connecting" || websocketClient.state === "reconnecting") return;
1920
2382
  websocketClient.connect().catch((error) => {
1921
2383
  console.error("[CohubClient] Failed to connect realtime websocket:", error);
1922
2384
  });
1923
2385
  }
1924
- //#endregion
1925
- //#region ../sdk/src/board/model/document-share.ts
2386
+ // ../sdk/src/board/model/document-share.ts
1926
2387
  function shareRecord(previous, next) {
1927
2388
  let same = Object.keys(previous).length === Object.keys(next).length;
1928
2389
  const shared = {};
@@ -1946,8 +2407,7 @@ function shareBoardDocument(previous, next) {
1946
2407
  animations
1947
2408
  };
1948
2409
  }
1949
- //#endregion
1950
- //#region ../sdk/src/board/model/read.ts
2410
+ // ../sdk/src/board/model/read.ts
1951
2411
  function readBoardDocument(result, base = null) {
1952
2412
  if (result.changes) {
1953
2413
  if (!base) throw new Error(`Board ${result.id} returned changes without a document to apply them to.`);
@@ -1961,11 +2421,10 @@ function readBoardDocument(result, base = null) {
1961
2421
  if (!parsed.ok) throw new Error(`Board ${result.id} could not be read.`);
1962
2422
  return shareBoardDocument(base, parsed.document);
1963
2423
  }
1964
- //#endregion
1965
- //#region ../sdk/src/board/model/version-diff.ts
1966
- const isRecord$6 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
2424
+ // ../sdk/src/board/model/version-diff.ts
2425
+ const isRecord$2 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
1967
2426
  function fieldChanges(before, after, path, out) {
1968
- if (isRecord$6(before) && isRecord$6(after)) {
2427
+ if (isRecord$2(before) && isRecord$2(after)) {
1969
2428
  for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) fieldChanges(before[key], after[key], path ? `${path}.${key}` : key, out);
1970
2429
  return;
1971
2430
  }
@@ -2026,8 +2485,7 @@ function diffBoardVersions(before, after) {
2026
2485
  ...compare("animation", before.animations, after.animations)
2027
2486
  ];
2028
2487
  }
2029
- //#endregion
2030
- //#region ../sdk/src/board/model/replay.ts
2488
+ // ../sdk/src/board/model/replay.ts
2031
2489
  function boardReplayActorKind(source) {
2032
2490
  if (!source) return "human";
2033
2491
  if (source.toolCallId) return "agent";
@@ -2129,11 +2587,10 @@ function createBoardReplayPlayer(live, page) {
2129
2587
  }
2130
2588
  };
2131
2589
  }
2132
- //#endregion
2133
- //#region ../sdk/src/indexeddb.ts
2590
+ // ../sdk/src/indexeddb.ts
2134
2591
  const OPEN_TIMEOUT_MS = 3e3;
2135
2592
  const connections = /* @__PURE__ */ new Map();
2136
- function open$1(name, version, upgrade) {
2593
+ function open(name, version, upgrade) {
2137
2594
  const existing = connections.get(name);
2138
2595
  if (existing) return existing;
2139
2596
  const opening = new Promise((resolve, reject) => {
@@ -2179,7 +2636,7 @@ function open$1(name, version, upgrade) {
2179
2636
  }
2180
2637
  function indexedDb(name, version, upgrade) {
2181
2638
  async function transact(stores, mode, work, retry = true) {
2182
- const db = await open$1(name, version, upgrade);
2639
+ const db = await open(name, version, upgrade);
2183
2640
  let tx;
2184
2641
  try {
2185
2642
  tx = db.transaction(stores, mode);
@@ -2198,8 +2655,7 @@ function indexedDb(name, version, upgrade) {
2198
2655
  }
2199
2656
  return { transact: (stores, mode, work) => transact(stores, mode, work) };
2200
2657
  }
2201
- //#endregion
2202
- //#region ../sdk/src/board/replica/indexeddb.ts
2658
+ // ../sdk/src/board/replica/indexeddb.ts
2203
2659
  const DATABASE$1 = "cohub-board";
2204
2660
  const VERSION = 1;
2205
2661
  function upgrade(db) {
@@ -2269,8 +2725,7 @@ function createIndexedDbBoardReplicaStorage(scope, options = {}) {
2269
2725
  })
2270
2726
  };
2271
2727
  }
2272
- //#endregion
2273
- //#region ../sdk/src/board/replica/index.ts
2728
+ // ../sdk/src/board/replica/index.ts
2274
2729
  function memoryStorage() {
2275
2730
  return {
2276
2731
  listPending: async () => [],
@@ -2567,8 +3022,7 @@ function createBoardReplica(options) {
2567
3022
  }
2568
3023
  };
2569
3024
  }
2570
- //#endregion
2571
- //#region ../sdk/src/apis/space-file-url-store.ts
3025
+ // ../sdk/src/apis/space-file-url-store.ts
2572
3026
  const DATABASE = "cohub-file-urls";
2573
3027
  const STORE = "urls";
2574
3028
  const MAX_ENTRIES = 2e4;
@@ -2635,8 +3089,7 @@ function trim() {
2635
3089
  return () => void 0;
2636
3090
  });
2637
3091
  }
2638
- //#endregion
2639
- //#region ../sdk/src/board/client/replicas.ts
3092
+ // ../sdk/src/board/client/replicas.ts
2640
3093
  const shared = /* @__PURE__ */ new WeakMap();
2641
3094
  function leaseBoardReplica(http, spaceId, boardId, remote, options) {
2642
3095
  const entries = shared.get(http) ?? /* @__PURE__ */ new Map();
@@ -2687,8 +3140,7 @@ function shareBoardPlayback(http, spaceId, boardId, playback) {
2687
3140
  const boardKey = `${spaceId}:${boardId}`;
2688
3141
  for (const entry of shared.get(http)?.values() ?? []) if (entry.boardKey === boardKey) entry.replica.receivePlayback(playback);
2689
3142
  }
2690
- //#endregion
2691
- //#region ../sdk/src/board/client/index.ts
3143
+ // ../sdk/src/board/client/index.ts
2692
3144
  var BoardRealtimeClient = class {
2693
3145
  websocketClient;
2694
3146
  spaceId;
@@ -2977,8 +3429,7 @@ var SpaceBoardsApi = class {
2977
3429
  });
2978
3430
  }
2979
3431
  };
2980
- //#endregion
2981
- //#region ../sdk/src/apis/space-wallet.ts
3432
+ // ../sdk/src/apis/space-wallet.ts
2982
3433
  var SpaceWalletApi = class {
2983
3434
  transport;
2984
3435
  spaceId;
@@ -3018,8 +3469,7 @@ var SpaceWalletApi = class {
3018
3469
  return this.transport.request(`/api/spaces/${this.spaceId}/wallet/transfers/${encodeURIComponent(id)}`);
3019
3470
  }
3020
3471
  };
3021
- //#endregion
3022
- //#region ../sdk/src/display-stats.ts
3472
+ // ../sdk/src/display-stats.ts
3023
3473
  function perFrame(seconds, previousSeconds, frames, previousFrames) {
3024
3474
  const count = frames - previousFrames;
3025
3475
  return count > 0 ? Math.round((seconds - previousSeconds) * 1e3 / count) : null;
@@ -3066,8 +3516,7 @@ function readDisplayStats(report, previous, fallbackRttMs = null) {
3066
3516
  counters
3067
3517
  };
3068
3518
  }
3069
- //#endregion
3070
- //#region ../sdk/src/display-session.ts
3519
+ // ../sdk/src/display-session.ts
3071
3520
  const DEFAULT_GATHER_TIMEOUT_MS = 2e3;
3072
3521
  const DEFAULT_CONNECT_TIMEOUT_MS = 2e4;
3073
3522
  const INPUT_BACKLOG_BYTES = 65536;
@@ -3306,8 +3755,7 @@ function sameFocus(a, b) {
3306
3755
  function connectDisplay(api, displayId, options) {
3307
3756
  return DisplayConnection.open(api, displayId, options);
3308
3757
  }
3309
- //#endregion
3310
- //#region ../sdk/src/local-workspace.ts
3758
+ // ../sdk/src/local-workspace.ts
3311
3759
  var LocalWorkspaceRpcError = class extends Error {
3312
3760
  name = "LocalWorkspaceRpcError";
3313
3761
  rpcErrorCode;
@@ -3449,8 +3897,7 @@ function loopbackWorkspace(endpoint, fetcher) {
3449
3897
  }
3450
3898
  };
3451
3899
  }
3452
- //#endregion
3453
- //#region ../sdk/src/apis/displays.ts
3900
+ // ../sdk/src/apis/displays.ts
3454
3901
  const READ_BATCH = 50;
3455
3902
  var SpaceDisplaysApi = class {
3456
3903
  transport;
@@ -3628,8 +4075,7 @@ function missing$1(fallback) {
3628
4075
  throw error;
3629
4076
  };
3630
4077
  }
3631
- //#endregion
3632
- //#region ../sdk/src/session-patch-reducer.ts
4078
+ // ../sdk/src/session-patch-reducer.ts
3633
4079
  const blockSubPathPattern = /^\/message\/content\/blocks\/(\d+)\/(.+)$/;
3634
4080
  const blockPathPattern = /^\/message\/content\/blocks\/(\d+)$/;
3635
4081
  const blockMetaPathPattern = /^\/message\/content\/blocks\/(\d+)\/_meta$/;
@@ -4002,12 +4448,11 @@ var SessionPatchReducer = class {
4002
4448
  };
4003
4449
  }
4004
4450
  };
4005
- //#endregion
4006
- //#region ../sdk/src/session-generation-stream.ts
4451
+ // ../sdk/src/session-generation-stream.ts
4007
4452
  const SNAPSHOT_RECOVERY_TIMEOUT_MS = 2500;
4008
4453
  const SNAPSHOT_RECOVERY_MAX_BUFFERED_EVENTS = 256;
4009
- const isRecord$5 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
4010
- const isContentBlockArray = (value) => Array.isArray(value) && value.every((item) => isRecord$5(item) && typeof item.type === "string");
4454
+ const isRecord$1 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
4455
+ const isContentBlockArray = (value) => Array.isArray(value) && value.every((item) => isRecord$1(item) && typeof item.type === "string");
4011
4456
  const getMessageKind = (message) => {
4012
4457
  const kind = message.meta?.messageKind;
4013
4458
  return typeof kind === "string" ? kind : null;
@@ -4047,7 +4492,7 @@ function parseAssistantMessageCommit(message) {
4047
4492
  }
4048
4493
  function messageRecordToIntermediate(message) {
4049
4494
  if (!isContentBlockArray(message.content) || message.content.length === 0) return null;
4050
- const meta = isRecord$5(message.meta) ? message.meta : {};
4495
+ const meta = isRecord$1(message.meta) ? message.meta : {};
4051
4496
  return {
4052
4497
  id: message.id,
4053
4498
  sessionId: message.sessionId,
@@ -4165,9 +4610,9 @@ function mergeMessagesSharingToolUseId(messages) {
4165
4610
  return merged;
4166
4611
  }
4167
4612
  function getCompactionPlacement(message) {
4168
- const meta = isRecord$5(message.meta) ? message.meta : null;
4169
- const compaction = isRecord$5(meta?.compaction) ? meta.compaction : null;
4170
- const placement = isRecord$5(compaction?.placement) ? compaction.placement : null;
4613
+ const meta = isRecord$1(message.meta) ? message.meta : null;
4614
+ const compaction = isRecord$1(meta?.compaction) ? meta.compaction : null;
4615
+ const placement = isRecord$1(compaction?.placement) ? compaction.placement : null;
4171
4616
  return meta?.messageKind === "compacted" ? {
4172
4617
  beforeMessageId: typeof placement?.beforeMessageId === "string" ? placement.beforeMessageId : null,
4173
4618
  sequence: typeof message.sequence === "number" ? message.sequence : null
@@ -4487,7 +4932,7 @@ var SessionGenerationStreamClient = class SessionGenerationStreamClient {
4487
4932
  }
4488
4933
  handlePersisted(event, handlers) {
4489
4934
  const message = event.payload.message;
4490
- if (!isRecord$5(message)) return;
4935
+ if (!isRecord$1(message)) return;
4491
4936
  const commit = parseAssistantMessageCommit(message);
4492
4937
  const turnId = getTurnIdFromMessage(commit.message);
4493
4938
  const key = {
@@ -4520,7 +4965,7 @@ var SessionGenerationStreamClient = class SessionGenerationStreamClient {
4520
4965
  }
4521
4966
  handleFinalized(event, handlers) {
4522
4967
  const turn = event.payload.turn;
4523
- if (!isRecord$5(turn)) return;
4968
+ if (!isRecord$1(turn)) return;
4524
4969
  const typedTurn = turn;
4525
4970
  if (!this.isForeignTurn(typedTurn.id)) {
4526
4971
  const key = {
@@ -4551,7 +4996,7 @@ var SessionGenerationStreamClient = class SessionGenerationStreamClient {
4551
4996
  return;
4552
4997
  case "session.turn.updated": {
4553
4998
  const turn = event.payload.turn;
4554
- if (!isRecord$5(turn)) return;
4999
+ if (!isRecord$1(turn)) return;
4555
5000
  this.emit(handlers, {
4556
5001
  type: "turn_updated",
4557
5002
  turn,
@@ -4593,8 +5038,7 @@ var SessionGenerationStreamClient = class SessionGenerationStreamClient {
4593
5038
  }
4594
5039
  }
4595
5040
  };
4596
- //#endregion
4597
- //#region ../sdk/src/apis/invitations.ts
5041
+ // ../sdk/src/apis/invitations.ts
4598
5042
  var SpaceInvitationsApi = class {
4599
5043
  transport;
4600
5044
  spaceId;
@@ -4648,8 +5092,7 @@ function buildSpaceInvitePath(input) {
4648
5092
  const inviteCode = requiredPathSegment(input.inviteCode, "inviteCode");
4649
5093
  return `${buildSpacePath(input)}/join/${inviteCode}`;
4650
5094
  }
4651
- //#endregion
4652
- //#region ../sdk/src/apis/space-file-reads.ts
5095
+ // ../sdk/src/apis/space-file-reads.ts
4653
5096
  /** For readers that need file bytes: a symlink fails the way it did before reads could describe one. */
4654
5097
  function symlinkReadError(file) {
4655
5098
  const message = `${file.path} is a symbolic link to ${file.target}.`;
@@ -4837,8 +5280,7 @@ function abortable(promise, signal) {
4837
5280
  promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
4838
5281
  });
4839
5282
  }
4840
- //#endregion
4841
- //#region ../sdk/src/apis/space-file-urls.ts
5283
+ // ../sdk/src/apis/space-file-urls.ts
4842
5284
  const MEMORY_LIMIT = 4096;
4843
5285
  const INLINE_MEMORY_MAX_CHARS = 262144;
4844
5286
  const PREPARING_CONCURRENCY = 4;
@@ -5139,8 +5581,7 @@ function settle(read, { timeoutMs = PREPARING_TIMEOUT_MS, signal }) {
5139
5581
  read.then((value) => finish(() => resolve(value)), (error) => finish(() => reject(error)));
5140
5582
  });
5141
5583
  }
5142
- //#endregion
5143
- //#region ../sdk/src/apis/spaces.ts
5584
+ // ../sdk/src/apis/spaces.ts
5144
5585
  async function fetchTurnObject(url, fetchImpl = globalThis.fetch, signal) {
5145
5586
  const response = await fetchImpl(url, { signal });
5146
5587
  if (!response.ok) throw new Error(`Failed to fetch turn object: HTTP ${response.status}`);
@@ -6867,8 +7308,7 @@ var SpaceClient = class {
6867
7308
  return new SpaceEventsApi(this.websocketClient, this.id).on(type, handler);
6868
7309
  }
6869
7310
  };
6870
- //#endregion
6871
- //#region ../sdk/src/apis/tasks.ts
7311
+ // ../sdk/src/apis/tasks.ts
6872
7312
  const isTerminal = (status) => status === "completed" || status === "failed";
6873
7313
  const MAX_WAIT_TIMEOUT_MS = 864e5;
6874
7314
  const MIN_POLL_INTERVAL_MS = 100;
@@ -7007,8 +7447,7 @@ var TasksApi = class {
7007
7447
  return this.transport.request(`/api/tasks${query ? `?${query}` : ""}`);
7008
7448
  }
7009
7449
  };
7010
- //#endregion
7011
- //#region ../sdk/src/apis/user.ts
7450
+ // ../sdk/src/apis/user.ts
7012
7451
  function userListQuery(options) {
7013
7452
  const params = new URLSearchParams();
7014
7453
  if (options.filter) params.set("filter", options.filter);
@@ -7175,8 +7614,7 @@ var UserLikesApi = class {
7175
7614
  return hasLike(await this.labels.patchResourceLabels(resourceType, resourceId, patch));
7176
7615
  }
7177
7616
  };
7178
- //#endregion
7179
- //#region ../sdk/src/apis/users.ts
7617
+ // ../sdk/src/apis/users.ts
7180
7618
  const MAX_BATCH_USER_PROFILES = 100;
7181
7619
  var UsersApi = class {
7182
7620
  transport;
@@ -7195,8 +7633,7 @@ var UsersApi = class {
7195
7633
  return this.transport.request(`/api/users/by-username/${encodeURIComponent(username)}`);
7196
7634
  }
7197
7635
  };
7198
- //#endregion
7199
- //#region ../sdk/src/apis/referrals.ts
7636
+ // ../sdk/src/apis/referrals.ts
7200
7637
  var ReferralsApi = class {
7201
7638
  transport;
7202
7639
  constructor(transport) {
@@ -7215,8 +7652,7 @@ var ReferralsApi = class {
7215
7652
  return this.transport.request("/api/me/referrals/code/rotate", { method: "POST" });
7216
7653
  }
7217
7654
  };
7218
- //#endregion
7219
- //#region ../sdk/src/apis/apps.ts
7655
+ // ../sdk/src/apis/apps.ts
7220
7656
  var AppsApi = class {
7221
7657
  transport;
7222
7658
  constructor(transport) {
@@ -7332,76 +7768,26 @@ var AppsApi = class {
7332
7768
  }
7333
7769
  /**
7334
7770
  * Grants scopes as the current user. Pass `silent: true` to only renew an
7335
- * existing live grant — the server rejects it instead of creating or
7336
- * reviving one, so revoked grants stay revoked.
7337
- */
7338
- authorize(appId, input) {
7339
- return this.transport.request(`/api/apps/${appId}/authorize`, {
7340
- method: "POST",
7341
- headers: { "Content-Type": "application/json" },
7342
- body: JSON.stringify(input)
7343
- });
7344
- }
7345
- /** Lists the caller's own grants for an app, one row per space. */
7346
- listMyGrants(appId) {
7347
- return this.transport.request(`/api/apps/${appId}/grants`);
7348
- }
7349
- /** Revokes one of the caller's own grants; tokens carrying it lose those scopes at once. */
7350
- revokeMyGrant(appId, grantId) {
7351
- return this.transport.request(`/api/apps/${appId}/grants/${grantId}`, { method: "DELETE" });
7352
- }
7353
- };
7354
- //#endregion
7355
- //#region ../protocol/dist/identifiers.js
7356
- 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}";
7357
- 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}";
7358
- const UUID_OR_SHORT_UUID_PATTERN = `^(?:${UUID_PATTERN}|[0-9a-fA-F]{32})$`;
7359
- new RegExp(`^${UUID_SHAPE_PATTERN}$`);
7360
- const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
7361
- const UUID_OR_SHORT_UUID_REGEX = new RegExp(UUID_OR_SHORT_UUID_PATTERN);
7362
- function isUuid(value) {
7363
- return typeof value === "string" && UUID_REGEX.test(value);
7364
- }
7365
- function isUuidOrShortUuid(value) {
7366
- return typeof value === "string" && UUID_OR_SHORT_UUID_REGEX.test(value);
7367
- }
7368
- //#endregion
7369
- //#region ../protocol/dist/navigation.js
7370
- const NAVIGATION_ERROR_MESSAGE_MAX_LENGTH = 2e3;
7371
- //#endregion
7372
- //#region ../protocol/dist/desktop-command.js
7373
- /** A command nobody accepts within this window settles as `no_active_client`. */
7374
- const DESKTOP_COMMAND_ACCEPT_TIMEOUT_MS = 1e4;
7375
- const DESKTOP_COMMAND_OPEN_TIMEOUT_MS = 3e4;
7376
- const DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS = 6e5;
7377
- const DESKTOP_COMMAND_MAX_TIMEOUT_MS = 432e5;
7378
- const DESKTOP_COMMAND_TERMINAL_STATUSES = [
7379
- "applied",
7380
- "no_active_client",
7381
- "desktop_host_unavailable",
7382
- "rejected",
7383
- "unsupported",
7384
- "timeout"
7385
- ];
7386
- const isTerminalDesktopCommandStatus = (status) => DESKTOP_COMMAND_TERMINAL_STATUSES.includes(status);
7387
- /**
7388
- * The surface a desktop open should use: an explicit request wins, then
7389
- * whatever the App declared at publish time. `window` is the implicit
7390
- * default and yields `undefined` so the command stays compact.
7391
- */
7392
- function resolveOpenSurface(requested, declared) {
7393
- return (requested ?? declared) === "overlay" ? "overlay" : void 0;
7394
- }
7395
- const defaultDesktopCommandTimeoutMs = (command) => command.call ? DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS : DESKTOP_COMMAND_OPEN_TIMEOUT_MS;
7396
- new RegExp(`^[A-Za-z][A-Za-z0-9_.:-]{0,63}$`);
7397
- const DESKTOP_COMMAND_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
7398
- const parseDesktopCommandId = (value) => {
7399
- if (typeof value !== "string") return null;
7400
- const trimmed = value.trim();
7401
- return DESKTOP_COMMAND_ID_RE.test(trimmed) ? trimmed : null;
7771
+ * existing live grant — the server rejects it instead of creating or
7772
+ * reviving one, so revoked grants stay revoked.
7773
+ */
7774
+ authorize(appId, input) {
7775
+ return this.transport.request(`/api/apps/${appId}/authorize`, {
7776
+ method: "POST",
7777
+ headers: { "Content-Type": "application/json" },
7778
+ body: JSON.stringify(input)
7779
+ });
7780
+ }
7781
+ /** Lists the caller's own grants for an app, one row per space. */
7782
+ listMyGrants(appId) {
7783
+ return this.transport.request(`/api/apps/${appId}/grants`);
7784
+ }
7785
+ /** Revokes one of the caller's own grants; tokens carrying it lose those scopes at once. */
7786
+ revokeMyGrant(appId, grantId) {
7787
+ return this.transport.request(`/api/apps/${appId}/grants/${grantId}`, { method: "DELETE" });
7788
+ }
7402
7789
  };
7403
- //#endregion
7404
- //#region ../sdk/src/apis/desktop-commands.ts
7790
+ // ../sdk/src/apis/desktop-commands.ts
7405
7791
  const DEFAULT_POLL_INTERVAL_MS = 300;
7406
7792
  const assertTimeoutMs = (timeoutMs) => {
7407
7793
  if (timeoutMs === void 0) return;
@@ -7478,8 +7864,7 @@ var DesktopCommandsApi = class {
7478
7864
  };
7479
7865
  }
7480
7866
  };
7481
- //#endregion
7482
- //#region ../sdk/src/apis/app-commerce.ts
7867
+ // ../sdk/src/apis/app-commerce.ts
7483
7868
  var AppCommerceApi = class {
7484
7869
  transport;
7485
7870
  constructor(transport) {
@@ -7513,8 +7898,7 @@ var AppCommerceApi = class {
7513
7898
  return this.transport.request(`/api/apps/${encodeURIComponent(appId)}/commerce/orders/${encodeURIComponent(orderId)}`);
7514
7899
  }
7515
7900
  };
7516
- //#endregion
7517
- //#region ../sdk/src/apis/rooms.ts
7901
+ // ../sdk/src/apis/rooms.ts
7518
7902
  const MAX_WAIT_PER_READ_MS = 25e3;
7519
7903
  var RoomsApi = class {
7520
7904
  transport;
@@ -7646,8 +8030,7 @@ var RoomsApi = class {
7646
8030
  });
7647
8031
  }
7648
8032
  };
7649
- //#endregion
7650
- //#region ../sdk/src/http.ts
8033
+ // ../sdk/src/http.ts
7651
8034
  var CohubHttpClient = class {
7652
8035
  spaces;
7653
8036
  channels;
@@ -7719,8 +8102,7 @@ var CohubHttpClient = class {
7719
8102
  return new SpaceClient(spaceId, this.transport, null, this.fileServices);
7720
8103
  }
7721
8104
  };
7722
- //#endregion
7723
- //#region ../sdk/src/websocket.ts
8105
+ // ../sdk/src/websocket.ts
7724
8106
  const createEventMap = () => ({
7725
8107
  connecting: /* @__PURE__ */ new Set(),
7726
8108
  reconnecting: /* @__PURE__ */ new Set(),
@@ -7764,9 +8146,9 @@ const isRetryableCloseCode = (code) => {
7764
8146
  };
7765
8147
  const PATCH_STREAM_BUFFER_MAX_PENDING = 128;
7766
8148
  const PATCH_STREAM_GAP_TIMEOUT_MS = 1500;
7767
- const isRecord$4 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
8149
+ const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
7768
8150
  const isRealtimeCompactFrame = (value) => {
7769
- if (!isRecord$4(value)) return false;
8151
+ if (!isRecord(value)) return false;
7770
8152
  if (value.t !== "d" && value.t !== "p") return false;
7771
8153
  if (typeof value.sid !== "string" || !value.sid) return false;
7772
8154
  if (typeof value.s !== "number" || !Number.isInteger(value.s) || value.s < 0) return false;
@@ -7775,12 +8157,12 @@ const isRealtimeCompactFrame = (value) => {
7775
8157
  return (value.o === "append" || value.o === "replace" || value.o === "add" || value.o === "merge" || value.o === "remove") && typeof value.p === "string" && value.p.length > 0;
7776
8158
  };
7777
8159
  const isRealtimeEnvelope = (value) => {
7778
- if (!isRecord$4(value)) return false;
8160
+ if (!isRecord(value)) return false;
7779
8161
  if (typeof value.id !== "string") return false;
7780
8162
  if (typeof value.timestamp !== "number") return false;
7781
8163
  if (!isRealtimeDomain(value.domain)) return false;
7782
8164
  if (typeof value.type !== "string") return false;
7783
- if (!isRecord$4(value.payload)) return false;
8165
+ if (!isRecord(value.payload)) return false;
7784
8166
  return true;
7785
8167
  };
7786
8168
  const compactFrameToPatchOperation = (frame) => {
@@ -7789,7 +8171,7 @@ const compactFrameToPatchOperation = (frame) => {
7789
8171
  o: "remove",
7790
8172
  p: frame.p
7791
8173
  };
7792
- if (frame.o === "merge") return isRecord$4(frame.v) ? {
8174
+ if (frame.o === "merge") return isRecord(frame.v) ? {
7793
8175
  o: "merge",
7794
8176
  p: frame.p,
7795
8177
  v: frame.v
@@ -8745,8 +9127,7 @@ var WebsocketClient = class {
8745
9127
  }
8746
9128
  };
8747
9129
  const createWebsocketClient = (options) => new WebsocketClient(options);
8748
- //#endregion
8749
- //#region ../sdk/src/voice-input.ts
9130
+ // ../sdk/src/voice-input.ts
8750
9131
  const TARGET_SAMPLE_RATE = 16e3;
8751
9132
  const CHUNK_SAMPLES = TARGET_SAMPLE_RATE * 200 / 1e3;
8752
9133
  const DEFAULT_CONNECTION_TIMEOUT_MS = 1e4;
@@ -8772,7 +9153,7 @@ const encodeBase64 = (bytes) => {
8772
9153
  throw new Error("Base64 encoding is not available in this environment");
8773
9154
  };
8774
9155
  const floatToPcm16 = (samples) => {
8775
- const buffer = /* @__PURE__ */ new ArrayBuffer(samples.length * 2);
9156
+ const buffer = new ArrayBuffer(samples.length * 2);
8776
9157
  const view = new DataView(buffer);
8777
9158
  for (let i = 0; i < samples.length; i += 1) {
8778
9159
  const sample = Math.max(-1, Math.min(1, samples[i] ?? 0));
@@ -9100,325 +9481,44 @@ var VoiceInputClient = class {
9100
9481
  this.audioContext = null;
9101
9482
  this.pendingSamples = [];
9102
9483
  this.pendingAudio = [];
9103
- this.asrStarted = false;
9104
- }
9105
- scheduleIdleClose() {
9106
- this.clearIdleCloseTimer();
9107
- if (!this.socket || this.idleConnectionTimeoutMs <= 0) return;
9108
- this.idleCloseTimer = globalThis.setTimeout(() => {
9109
- this.intentionalClose = true;
9110
- this.closeSocket();
9111
- }, this.idleConnectionTimeoutMs);
9112
- }
9113
- clearIdleCloseTimer() {
9114
- if (!this.idleCloseTimer) return;
9115
- globalThis.clearTimeout(this.idleCloseTimer);
9116
- this.idleCloseTimer = null;
9117
- }
9118
- closeSocket() {
9119
- this.rejectAuthWaiter(/* @__PURE__ */ new Error("Voice connection closed"));
9120
- this.rejectAsrStartWaiter(/* @__PURE__ */ new Error("Voice connection closed"));
9121
- this.authenticated = false;
9122
- this.socketOpenPromise = null;
9123
- this.socket?.close();
9124
- this.socket = null;
9125
- }
9126
- };
9127
- var VoiceApi = class {
9128
- defaults;
9129
- constructor(defaults = {}) {
9130
- this.defaults = defaults;
9131
- }
9132
- createInputClient(callbacks = {}, options = {}) {
9133
- return new VoiceInputClient({
9134
- ...this.defaults,
9135
- ...options,
9136
- callbacks
9137
- });
9138
- }
9139
- };
9140
- //#endregion
9141
- //#region ../protocol/dist/app-surface.js
9142
- const APP_SURFACE_PROTOCOL = "cohub.app.surface";
9143
- const isRecord$3 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
9144
- const isSurfaceEnvelope = (value) => isRecord$3(value) && value.protocol === "cohub.app.surface" && value.version === 1;
9145
- const parseComposerChipKey = (value) => {
9146
- if (typeof value !== "string") return null;
9147
- const key = value.trim();
9148
- if (!key || key.length > 80) return null;
9149
- return key;
9150
- };
9151
- const parseAppComposerChipSet = (value) => {
9152
- if (!isSurfaceEnvelope(value) || value.type !== "composer.chip.set" || !isRecord$3(value.chip)) return null;
9153
- const key = parseComposerChipKey(value.chip.key);
9154
- if (!key || typeof value.chip.label !== "string" || typeof value.chip.content !== "string") return null;
9155
- const label = value.chip.label.trim();
9156
- if (!label || label.length > 120) return null;
9157
- if (!value.chip.content.trim()) return null;
9158
- if (new TextEncoder().encode(value.chip.content).length > 32768) return null;
9159
- return {
9160
- protocol: APP_SURFACE_PROTOCOL,
9161
- version: 1,
9162
- type: "composer.chip.set",
9163
- chip: {
9164
- key,
9165
- label,
9166
- content: value.chip.content
9167
- }
9168
- };
9169
- };
9170
- const parseAppComposerChipClear = (value) => {
9171
- if (!isSurfaceEnvelope(value) || value.type !== "composer.chip.clear") return null;
9172
- const key = parseComposerChipKey(value.key);
9173
- return key ? {
9174
- protocol: APP_SURFACE_PROTOCOL,
9175
- version: 1,
9176
- type: "composer.chip.clear",
9177
- key
9178
- } : null;
9179
- };
9180
- const parseAppSurfaceRequest = (value) => {
9181
- if (!isSurfaceEnvelope(value) || value.type !== "request") return null;
9182
- if (typeof value.requestId !== "string" || !value.requestId) return null;
9183
- if (typeof value.method !== "string" || !value.method) return null;
9184
- const commandId = parseDesktopCommandId(value.commandId);
9185
- if (!commandId) return null;
9186
- return {
9187
- protocol: APP_SURFACE_PROTOCOL,
9188
- version: 1,
9189
- type: "request",
9190
- requestId: value.requestId,
9191
- method: value.method,
9192
- ...value.input === void 0 ? {} : { input: value.input },
9193
- commandId
9194
- };
9195
- };
9196
- const buildAppSurfaceReady = (methods) => ({
9197
- protocol: APP_SURFACE_PROTOCOL,
9198
- version: 1,
9199
- type: "ready",
9200
- methods: [...methods]
9201
- });
9202
- const buildAppSurfaceResponse = (input) => ({
9203
- protocol: APP_SURFACE_PROTOCOL,
9204
- version: 1,
9205
- type: "response",
9206
- ...input
9207
- });
9208
- const buildAppComposerChipSet = (chip) => ({
9209
- protocol: APP_SURFACE_PROTOCOL,
9210
- version: 1,
9211
- type: "composer.chip.set",
9212
- chip
9213
- });
9214
- const buildAppComposerChipClear = (key) => ({
9215
- protocol: APP_SURFACE_PROTOCOL,
9216
- version: 1,
9217
- type: "composer.chip.clear",
9218
- key
9219
- });
9220
- //#endregion
9221
- //#region ../protocol/dist/app-runtime.js
9222
- const APP_RUNTIME_PROTOCOL = "cohub.app.runtime";
9223
- const isRecord$2 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
9224
- const buildAppRuntimeReady = () => ({
9225
- protocol: APP_RUNTIME_PROTOCOL,
9226
- version: 1,
9227
- type: "ready"
9228
- });
9229
- const buildAppRuntimeCloseRequest = () => ({
9230
- protocol: APP_RUNTIME_PROTOCOL,
9231
- version: 1,
9232
- type: "close.request"
9233
- });
9234
- const finite = (value) => typeof value === "number" && Number.isFinite(value);
9235
- const buildAppRuntimeConfigureRequest = (input) => ({
9236
- protocol: APP_RUNTIME_PROTOCOL,
9237
- version: 1,
9238
- type: "configure.request",
9239
- ...input
9240
- });
9241
- const buildAppRuntimePointer = (input) => ({
9242
- protocol: APP_RUNTIME_PROTOCOL,
9243
- version: 1,
9244
- type: "pointer",
9245
- x: input.x,
9246
- y: input.y,
9247
- down: input.down
9248
- });
9249
- const isRuntimeMessage = (value, type) => isRecord$2(value) && value.protocol === "cohub.app.runtime" && value.version === 1 && value.type === type;
9250
- const envelope$1 = (type) => ({
9251
- protocol: APP_RUNTIME_PROTOCOL,
9252
- version: 1,
9253
- type
9254
- });
9255
- const boundedText = (value, max) => {
9256
- if (typeof value !== "string") return null;
9257
- const text = value.replace(/\s+/g, " ").trim();
9258
- return text ? text.slice(0, max) : null;
9259
- };
9260
- const APP_RUNTIME_HAPTIC_VIBRATION = {
9261
- tick: 8,
9262
- confirm: [
9263
- 12,
9264
- 24,
9265
- 12
9266
- ],
9267
- reject: [
9268
- 24,
9269
- 32,
9270
- 24
9271
- ],
9272
- longPress: 14
9273
- };
9274
- const buildAppRuntimeHaptic = (kind) => ({
9275
- ...envelope$1("haptic"),
9276
- kind
9277
- });
9278
- const buildAppRuntimeAnnounce = () => envelope$1("announce");
9279
- const parseAppRuntimeAnnounce = (value) => isRuntimeMessage(value, "announce") ? buildAppRuntimeAnnounce() : null;
9280
- const buildAppRuntimeWindowState = (state) => ({
9281
- ...envelope$1("window.state"),
9282
- title: state.title,
9283
- status: state.status,
9284
- dirty: state.dirty
9285
- });
9286
- const requestIdOf = (value) => typeof value.requestId === "string" && value.requestId && value.requestId.length <= 128 ? value.requestId : null;
9287
- const buildAppRuntimeClosePrepare = (requestId) => ({
9288
- ...envelope$1("close.prepare"),
9289
- requestId
9290
- });
9291
- const parseAppRuntimeClosePrepare = (value) => {
9292
- if (!isRuntimeMessage(value, "close.prepare")) return null;
9293
- const requestId = requestIdOf(value);
9294
- return requestId ? buildAppRuntimeClosePrepare(requestId) : null;
9295
- };
9296
- const buildAppRuntimeClosePrepared = (input) => ({
9297
- ...envelope$1("close.prepared"),
9298
- requestId: input.requestId,
9299
- ok: input.ok
9300
- });
9301
- /** Select all, copy, paste, cut, undo, redo: the browser's, and the App's. */
9302
- const EDITING_CHORD_KEYS = /* @__PURE__ */ new Set([
9303
- "a",
9304
- "c",
9305
- "v",
9306
- "x",
9307
- "y",
9308
- "z"
9309
- ]);
9310
- /** Whether a Ctrl / Meta chord may reach the host; both sides apply this rule. */
9311
- const isAppRuntimeHostChord = (input) => (input.ctrlKey || input.metaKey) && !EDITING_CHORD_KEYS.has(input.key.toLowerCase());
9312
- const buildAppRuntimeKey = (input) => ({
9313
- ...envelope$1("key"),
9314
- key: input.key,
9315
- code: input.code,
9316
- altKey: input.altKey,
9317
- ctrlKey: input.ctrlKey,
9318
- metaKey: input.metaKey,
9319
- shiftKey: input.shiftKey
9320
- });
9321
- /** Resource kinds the Cohub host can drop into an App. */
9322
- const APP_DROP_RESOURCE_TYPES = [
9323
- "file",
9324
- "task",
9325
- "app",
9326
- "session",
9327
- "checkpoint"
9328
- ];
9329
- const isDropResourceType = (value) => APP_DROP_RESOURCE_TYPES.includes(value);
9330
- const MAX_DROP_RESOURCES = 100;
9331
- const parseDropResource = (value) => {
9332
- if (!isRecord$2(value) || !isDropResourceType(value.type)) return null;
9333
- const ref = boundedText(value.ref, 4096);
9334
- if (!ref) return null;
9335
- const resource = {
9336
- type: value.type,
9337
- ref
9338
- };
9339
- for (const key of [
9340
- "title",
9341
- "path",
9342
- "mimeType",
9343
- "appId",
9344
- "href",
9345
- "taskRunId"
9346
- ]) {
9347
- const text = boundedText(value[key], 4096);
9348
- if (text) resource[key] = text;
9484
+ this.asrStarted = false;
9485
+ }
9486
+ scheduleIdleClose() {
9487
+ this.clearIdleCloseTimer();
9488
+ if (!this.socket || this.idleConnectionTimeoutMs <= 0) return;
9489
+ this.idleCloseTimer = globalThis.setTimeout(() => {
9490
+ this.intentionalClose = true;
9491
+ this.closeSocket();
9492
+ }, this.idleConnectionTimeoutMs);
9493
+ }
9494
+ clearIdleCloseTimer() {
9495
+ if (!this.idleCloseTimer) return;
9496
+ globalThis.clearTimeout(this.idleCloseTimer);
9497
+ this.idleCloseTimer = null;
9498
+ }
9499
+ closeSocket() {
9500
+ this.rejectAuthWaiter(/* @__PURE__ */ new Error("Voice connection closed"));
9501
+ this.rejectAsrStartWaiter(/* @__PURE__ */ new Error("Voice connection closed"));
9502
+ this.authenticated = false;
9503
+ this.socketOpenPromise = null;
9504
+ this.socket?.close();
9505
+ this.socket = null;
9349
9506
  }
9350
- if (finite(value.size) && value.size >= 0) resource.size = value.size;
9351
- if (finite(value.mtimeMs)) resource.mtimeMs = value.mtimeMs;
9352
- if (isRecord$2(value.snapshot)) resource.snapshot = value.snapshot;
9353
- return resource;
9354
9507
  };
9355
- const parseDropTypes = (value) => Array.isArray(value) ? [...new Set(value.filter(isDropResourceType))] : [];
9356
- const buildAppRuntimeDropConfig = (accept) => ({
9357
- ...envelope$1("drop.config"),
9358
- accept: [...accept]
9359
- });
9360
- const buildAppRuntimeDrag = (input) => ({
9361
- ...envelope$1("drag"),
9362
- phase: input.phase,
9363
- x: input.x,
9364
- y: input.y,
9365
- types: [...input.types],
9366
- ...input.phase === "drop" ? { resources: input.resources ?? [] } : {}
9367
- });
9368
- const parseAppRuntimeDrag = (value) => {
9369
- if (!isRuntimeMessage(value, "drag")) return null;
9370
- if (value.phase !== "over" && value.phase !== "leave" && value.phase !== "drop") return null;
9371
- if (!finite(value.x) || !finite(value.y)) return null;
9372
- const resources = value.phase === "drop" && Array.isArray(value.resources) ? value.resources.slice(0, MAX_DROP_RESOURCES).map(parseDropResource).filter((resource) => resource !== null) : void 0;
9373
- return buildAppRuntimeDrag({
9374
- phase: value.phase,
9375
- x: value.x,
9376
- y: value.y,
9377
- types: parseDropTypes(value.types),
9378
- ...resources ? { resources } : {}
9379
- });
9508
+ var VoiceApi = class {
9509
+ defaults;
9510
+ constructor(defaults = {}) {
9511
+ this.defaults = defaults;
9512
+ }
9513
+ createInputClient(callbacks = {}, options = {}) {
9514
+ return new VoiceInputClient({
9515
+ ...this.defaults,
9516
+ ...options,
9517
+ callbacks
9518
+ });
9519
+ }
9380
9520
  };
9381
- /** Public design tokens, sent as resolved CSS values. */
9382
- const APP_APPEARANCE_TOKENS = [
9383
- "bg-primary",
9384
- "bg-content",
9385
- "bg-surface",
9386
- "bg-elevated",
9387
- "bg-input",
9388
- "bg-hover",
9389
- "bg-active",
9390
- "text-primary",
9391
- "text-secondary",
9392
- "text-tertiary",
9393
- "text-placeholder",
9394
- "text-disabled",
9395
- "border-primary",
9396
- "border-subtle",
9397
- "brand",
9398
- "brand-hover",
9399
- "brand-soft",
9400
- "brand-muted",
9401
- "brand-border",
9402
- "brand-ring",
9403
- "brand-contrast-fg",
9404
- "error-fg",
9405
- "success",
9406
- "warning",
9407
- "error",
9408
- "info",
9409
- "status-running",
9410
- "selection-bg",
9411
- "overlay-scrim",
9412
- "shadow-subtle",
9413
- "shadow-medium",
9414
- "shadow-strong",
9415
- "font-sans",
9416
- "font-mono"
9417
- ];
9418
- /** CSS custom property an App reads a shared token from, e.g. `--cohub-bg-primary`. */
9419
- const appAppearanceVar = (token) => `--cohub-${token}`;
9420
- //#endregion
9421
- //#region ../sdk/src/app-surface.ts
9521
+ // ../sdk/src/app-surface.ts
9422
9522
  /**
9423
9523
  * Explicit app origins, not a Cohub suffix match: apps themselves are
9424
9524
  * served from Cohub subdomains, so a suffix match would let one app call into
@@ -9564,41 +9664,7 @@ var AppSurfaceApi = class {
9564
9664
  } catch {}
9565
9665
  }
9566
9666
  };
9567
- const envelope = {
9568
- protocol: "cohub.app.embed",
9569
- version: 1
9570
- };
9571
- const isRecord$1 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
9572
- const isEnvelope = (value) => isRecord$1(value) && value.protocol === "cohub.app.embed" && value.version === 1;
9573
- const parseEmbedId = (value) => typeof value === "string" && value.trim() && value.length <= 128 ? value : null;
9574
- function parseAppEmbedAttachRequest(value) {
9575
- if (!isEnvelope(value) || value.type !== "attach.request") return null;
9576
- return {
9577
- ...envelope,
9578
- type: "attach.request"
9579
- };
9580
- }
9581
- function parseAppEmbedCloseRequest(value) {
9582
- if (!isEnvelope(value) || value.type !== "close.request") return null;
9583
- const embedId = parseEmbedId(value.embedId);
9584
- return embedId ? {
9585
- ...envelope,
9586
- type: "close.request",
9587
- embedId
9588
- } : null;
9589
- }
9590
- const buildAppEmbedAttach = (input) => ({
9591
- ...envelope,
9592
- type: "attach",
9593
- ...input
9594
- });
9595
- const buildAppEmbedShellChanged = (input) => ({
9596
- ...envelope,
9597
- type: "shell.changed",
9598
- ...input
9599
- });
9600
- //#endregion
9601
- //#region ../sdk/src/app-embed.ts
9667
+ // ../sdk/src/app-embed.ts
9602
9668
  const generateEmbedId = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`;
9603
9669
  const frameOrigin = (frame) => {
9604
9670
  try {
@@ -9652,8 +9718,7 @@ function attachAppEmbed(frame, options) {
9652
9718
  }
9653
9719
  };
9654
9720
  }
9655
- //#endregion
9656
- //#region ../sdk/src/app-window.ts
9721
+ // ../sdk/src/app-window.ts
9657
9722
  /** One document listener for all clients, so a chord reaches the host once. */
9658
9723
  const keyTransports = /* @__PURE__ */ new Set();
9659
9724
  function forwardKey(event) {
@@ -9819,86 +9884,7 @@ function applyAppAppearance(root, context) {
9819
9884
  }
9820
9885
  if (context?.locale) root.lang = context.locale;
9821
9886
  }
9822
- //#endregion
9823
- //#region ../protocol/dist/app-navigation.js
9824
- const APP_NAVIGATION_PROTOCOL = "cohub.app.navigation";
9825
- const APP_NAVIGATION_MAX_ERROR_CODE_LENGTH = 64;
9826
- const APP_NAVIGATION_MAX_ERROR_MESSAGE_LENGTH = NAVIGATION_ERROR_MESSAGE_MAX_LENGTH;
9827
- const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
9828
- const text$1 = (value, max) => typeof value === "string" && value.trim() && value.length <= max ? value : null;
9829
- const buildAppNavigationOpenMessage = (input) => ({
9830
- protocol: APP_NAVIGATION_PROTOCOL,
9831
- version: 1,
9832
- type: "open",
9833
- ...input
9834
- });
9835
- const NAVIGATION_REASONS = /* @__PURE__ */ new Set([
9836
- "unsupported",
9837
- "invalid_target",
9838
- "inaccessible",
9839
- "timeout"
9840
- ]);
9841
- function parseNavigationCall(value) {
9842
- if (value === void 0) return void 0;
9843
- if (!isRecord(value) || typeof value.ok !== "boolean") return null;
9844
- if (value.ok) return {
9845
- ok: true,
9846
- ...value.result === void 0 ? {} : { result: value.result }
9847
- };
9848
- const code = text$1(value.code, APP_NAVIGATION_MAX_ERROR_CODE_LENGTH);
9849
- const message = text$1(value.message, APP_NAVIGATION_MAX_ERROR_MESSAGE_LENGTH);
9850
- if (!code || !message) return null;
9851
- return {
9852
- ok: false,
9853
- code,
9854
- message
9855
- };
9856
- }
9857
- const parseAppNavigationOpenResponse = (value) => {
9858
- if (!isRecord(value)) return null;
9859
- if (value.protocol !== "cohub.app.navigation" || value.version !== 1 || value.type !== "open.result" || !text$1(value.requestId, 128) || typeof value.handled !== "boolean" || value.reason !== void 0 && !NAVIGATION_REASONS.has(value.reason)) return null;
9860
- const call = parseNavigationCall(value.call);
9861
- if (call === null) return null;
9862
- return {
9863
- protocol: APP_NAVIGATION_PROTOCOL,
9864
- version: 1,
9865
- type: "open.result",
9866
- requestId: value.requestId,
9867
- handled: value.handled,
9868
- ...value.reason === void 0 ? {} : { reason: value.reason },
9869
- ...call === void 0 ? {} : { call }
9870
- };
9871
- };
9872
- //#endregion
9873
- //#region ../protocol/dist/app-devices.js
9874
- const APP_DEVICES = [
9875
- "camera",
9876
- "microphone",
9877
- "screen",
9878
- "location"
9879
- ];
9880
- const isAppDevice = (value) => typeof value === "string" && APP_DEVICES.includes(value);
9881
- function parseAppDevices(value) {
9882
- const items = typeof value === "string" ? value.split(/[\s,]+/) : Array.isArray(value) ? value : [];
9883
- const wanted = new Set(items.map((item) => typeof item === "string" ? item.trim().toLowerCase() : item).filter(isAppDevice));
9884
- return APP_DEVICES.filter((device) => wanted.has(device));
9885
- }
9886
- const APP_DEVICES_REQUEST_TYPE = "cohub.app.devices.request";
9887
- const APP_DEVICES_RESULT_TYPE = "cohub.app.devices.result";
9888
- function parseAppDevicesResult(value) {
9889
- if (!value || typeof value !== "object") return null;
9890
- const record = value;
9891
- if (record.type !== "cohub.app.devices.result" || typeof record.requestId !== "string") return null;
9892
- const status = record.status;
9893
- if (status !== "granted" && status !== "denied" && status !== "unavailable") return null;
9894
- return {
9895
- type: APP_DEVICES_RESULT_TYPE,
9896
- requestId: record.requestId,
9897
- status
9898
- };
9899
- }
9900
- //#endregion
9901
- //#region ../sdk/src/app-runtime.ts
9887
+ // ../sdk/src/app-runtime.ts
9902
9888
  var AppRuntimeError = class extends Error {
9903
9889
  code;
9904
9890
  requestId;
@@ -10970,8 +10956,7 @@ function resolveAppTransport(config, appIdResolver, originAppResolver, defaultBr
10970
10956
  return new ParentBridgeTransport();
10971
10957
  }
10972
10958
  const createAppRuntime = (transport, appId, appIdResolver) => new AppRuntimeApi(transport, appId, appIdResolver);
10973
- //#endregion
10974
- //#region ../sdk/src/client.ts
10959
+ // ../sdk/src/client.ts
10975
10960
  var CohubClient = class {
10976
10961
  spaces;
10977
10962
  channels;
@@ -11255,59 +11240,7 @@ attach: attachAppEmbed },
11255
11240
  };
11256
11241
  }
11257
11242
  };
11258
- const USERNAME_PATTERN = /^(?!.*--)[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/;
11259
- const SPACE_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9_-]{0,78}[a-z0-9])?$/;
11260
- /**
11261
- * Platform-owned path segments that must not be newly assigned to public
11262
- * identities. Existing stored values remain readable through parse helpers.
11263
- */
11264
- const RESERVED_PLATFORM_PATH_SEGMENTS = Object.freeze([
11265
- "admin",
11266
- "api",
11267
- "assets",
11268
- "auth",
11269
- "callback",
11270
- "changelog",
11271
- "dev",
11272
- "docs",
11273
- "explore",
11274
- "invite",
11275
- "landing",
11276
- "login",
11277
- "logout",
11278
- "mobile",
11279
- "new",
11280
- "org",
11281
- "pricing",
11282
- "pwa",
11283
- "referrals",
11284
- "sessions",
11285
- "settings",
11286
- "spaces",
11287
- "static",
11288
- "teams",
11289
- "trending",
11290
- "u",
11291
- "user",
11292
- "users",
11293
- "work-auth",
11294
- "app-auth",
11295
- "zh"
11296
- ]);
11297
- new Set(RESERVED_PLATFORM_PATH_SEGMENTS);
11298
- [...RESERVED_PLATFORM_PATH_SEGMENTS];
11299
- function parseUsername(value) {
11300
- if (value === null || value === void 0) return null;
11301
- const normalized = value.trim().toLowerCase();
11302
- return USERNAME_PATTERN.test(normalized) ? normalized : null;
11303
- }
11304
- function parseSpaceSlug(value) {
11305
- if (value === null || value === void 0) return null;
11306
- const normalized = value.trim();
11307
- return SPACE_SLUG_PATTERN.test(normalized) ? normalized : null;
11308
- }
11309
- //#endregion
11310
- //#region ../sdk/src/space-ref.ts
11243
+ // ../sdk/src/space-ref.ts
11311
11244
  const canonicalUuid = (value) => {
11312
11245
  const hex = value.replaceAll("-", "").toLowerCase();
11313
11246
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
@@ -11334,8 +11267,7 @@ function parseSpaceRef(value) {
11334
11267
  slug
11335
11268
  } : null;
11336
11269
  }
11337
- //#endregion
11338
- //#region src/runtime/space-binding.ts
11270
+ // src/runtime/space-binding.ts
11339
11271
  const CONFIG_DIR_NAME = ".config";
11340
11272
  const CONFIG_FILE_NAME = "runtime-spaces.json";
11341
11273
  const LOCK_STALE_MS = 3e5;
@@ -11450,7 +11382,7 @@ async function writeRuntimeJson(path, file) {
11450
11382
  });
11451
11383
  const temporary = `${path}.${randomUUID()}.tmp`;
11452
11384
  try {
11453
- const output = await open(temporary, "wx", 384);
11385
+ const output = await open$1(temporary, "wx", 384);
11454
11386
  try {
11455
11387
  await output.writeFile(`${JSON.stringify(file, null, 2)}\n`, "utf8");
11456
11388
  await output.sync();
@@ -11460,7 +11392,7 @@ async function writeRuntimeJson(path, file) {
11460
11392
  await rename(temporary, path);
11461
11393
  await chmod(path, 384);
11462
11394
  if (process.platform !== "win32") {
11463
- const directory = await open(dirname(path), "r");
11395
+ const directory = await open$1(dirname(path), "r");
11464
11396
  try {
11465
11397
  await directory.sync();
11466
11398
  } finally {
@@ -11684,8 +11616,7 @@ async function resolveRuntimeSpace(input) {
11684
11616
  lockPath
11685
11617
  });
11686
11618
  }
11687
- //#endregion
11688
- //#region src/auth.ts
11619
+ // src/auth.ts
11689
11620
  const CONFIG_DIR$1 = join(homedir(), ".config", "cohub");
11690
11621
  const EXPIRY_SKEW_MS = 3e5;
11691
11622
  const DEFAULT_SCOPE = "openid profile email offline_access";
@@ -11957,8 +11888,7 @@ function formatAuthError(data, status) {
11957
11888
  }
11958
11889
  return typeof data === "string" && data ? data : `Authentication failed: HTTP ${status}`;
11959
11890
  }
11960
- //#endregion
11961
- //#region src/network-error.ts
11891
+ // src/network-error.ts
11962
11892
  const text = (value) => typeof value === "string" && value ? value : null;
11963
11893
  const isFetchFailure = (error) => error instanceof Error && error.message === "fetch failed";
11964
11894
  function fetchFailureReason(error) {
@@ -11979,8 +11909,7 @@ function describeError(error) {
11979
11909
  const reason = fetchFailureReason(error);
11980
11910
  return reason ? `${error.message} (${reason})` : error.message;
11981
11911
  }
11982
- //#endregion
11983
- //#region src/output.ts
11912
+ // src/output.ts
11984
11913
  /**
11985
11914
  * Timestamp → local ISO-style date and time with the system's UTC offset.
11986
11915
  *
@@ -12181,8 +12110,7 @@ function spinner() {
12181
12110
  }
12182
12111
  };
12183
12112
  }
12184
- //#endregion
12185
- //#region src/space.ts
12113
+ // src/space.ts
12186
12114
  const CONFIG_DIR = join(homedir(), ".config", "cohub");
12187
12115
  const CACHE_PATH = join(CONFIG_DIR, "home-space.json");
12188
12116
  /** Legacy cache that may name another user's Home; never read. */
@@ -12343,8 +12271,7 @@ async function resolveSpaceTarget(target, options = {}) {
12343
12271
  function resolveSpace(command, options = {}) {
12344
12272
  return resolveSpaceTarget(explicitSpace(command), options);
12345
12273
  }
12346
- //#endregion
12347
- //#region src/runtime/instance.ts
12274
+ // src/runtime/instance.ts
12348
12275
  const MAX_WATCHERS = 16;
12349
12276
  function runtimeInstancesRoot() {
12350
12277
  return join(homedir(), ".local", "state", "cohub", "instances");
@@ -12372,7 +12299,7 @@ async function readRecord(directory) {
12372
12299
  throw error;
12373
12300
  }
12374
12301
  }
12375
- function request$1(record, action, payload, timeoutMs) {
12302
+ function request(record, action, payload, timeoutMs) {
12376
12303
  return new Promise((resolve, reject) => {
12377
12304
  const socket = createConnection(record.socket);
12378
12305
  const timer = setTimeout(() => {
@@ -12425,7 +12352,7 @@ async function controlRuntimeInstance(directory, action, payload = {}, timeoutMs
12425
12352
  const record = await readRecord(directory);
12426
12353
  if (!record || !alive(record.pid)) return null;
12427
12354
  try {
12428
- return await request$1(record, action, payload, timeoutMs);
12355
+ return await request(record, action, payload, timeoutMs);
12429
12356
  } catch (error) {
12430
12357
  if (["ENOENT", "ECONNREFUSED"].includes(error.code ?? "")) return null;
12431
12358
  throw error;
@@ -12585,14 +12512,13 @@ async function ownRuntimeInstance(directory, status, stop, control = async () =>
12585
12512
  };
12586
12513
  }, { path: join(directory, "owner.json") });
12587
12514
  }
12588
- //#endregion
12589
- //#region src/runtime/local-workspace.ts
12515
+ // src/runtime/local-workspace.ts
12590
12516
  const DISCOVERY_TIMEOUT_MS = 1500;
12591
12517
  const NULL_BODY_STATUS = /* @__PURE__ */ new Set([204, 304]);
12592
12518
  /** Its own agent keeps requests off the proxy `--use-env-proxy` gives global fetch and http: they carry the Runtime's token. */
12593
12519
  const direct = new Agent({ keepAlive: true });
12594
12520
  const loopbackFetch = (input, init = {}) => new Promise((resolve, reject) => {
12595
- const client = request(String(input), {
12521
+ const client = request$1(String(input), {
12596
12522
  agent: direct,
12597
12523
  method: init.method ?? "GET",
12598
12524
  headers: Object.fromEntries(new Headers(init.headers)),
@@ -12638,8 +12564,7 @@ const resolveLocalWorkspace = (spaceId) => {
12638
12564
  }
12639
12565
  return workspace;
12640
12566
  };
12641
- //#endregion
12642
- //#region src/client.ts
12567
+ // src/client.ts
12643
12568
  const clientOptions = () => ({
12644
12569
  getAccessToken: resolveAccessToken,
12645
12570
  localWorkspace: resolveLocalWorkspace,
@@ -12662,5 +12587,4 @@ function createClientWithAccessToken(token) {
12662
12587
  function createRealtimeClient() {
12663
12588
  return new CohubClient(clientOptions());
12664
12589
  }
12665
- //#endregion
12666
- export { parseSpaceRef as $, spinner as A, readAuthSession as B, error as C, splitDisplayText as Ct, json as D, handleHttp as E, AuthRequiredError as F, revokeAndClearAuthSession as G, requestDeviceCode as H, authSessionPath as I, getRuntimeSpaceBinding as J, verifyDeviceCode as K, authSource as L, truncateText as M, warn as N, jsonRequested as O, describeError as P, withRuntimeSpaceBindingsLock as Q, loginWithDeviceFlow as R, resolveSpaceTarget as S, normalizeDisplayPoint as St, formatLocalDateTime as T, requireAccessToken as U, refreshAccessToken as V, resolveAccessToken as W, resolveRuntimeSpace as X, readRuntimeSpaceBindings as Y, runtimeSpaceBindingsPath as Z, failSpaceTarget as _, displayActStepSchema as _t, findLocalWorkspace as a, DESKTOP_COMMAND_OPEN_TIMEOUT_MS as at, resolveSpace as b, DISPLAY_SYSTEM_ACTIONS as bt, ownRuntimeInstance as c, buildSpaceInvitePath as ct, runtimeInstancesRoot as d, localWorkspaceHttpError as dt, parseSpaceSlug as et, stopRuntimeInstance as f, isHttpErrorCode as ft, explicitSpace as g, DISPLAY_RECORDINGS_DIR as gt, currentIdentityKey as h, DISPLAY_HANDOVER_WAIT_MS as ht, connectLocalWorkspace as i, DESKTOP_COMMAND_MAX_TIMEOUT_MS as it, table as j, ok as k, requestRuntimeInstance as l, LocalWorkspaceRpcError as lt, clearHomeSpaceCache as m, DISPLAY_HANDOVER_MAX_MS as mt, createClientWithAccessToken as n, DESKTOP_COMMAND_ACCEPT_TIMEOUT_MS as nt, UNCONFIRMED_WORK as o, resolveOpenSurface as ot, watchRuntimeInstance as p, DISPLAY_HANDOVER_DEFAULT_MS as pt, canonicalRuntimeRoot as q, createRealtimeClient as r, DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS as rt, controlRuntimeInstance as s, isUuid as st, createClient as t, parseUsername as tt, runtimeInstanceDirectory as u, LocalWorkspaceUnavailableError as ut, jwtClaim as v, DISPLAY_ELEMENT_REF_PATTERN as vt, formatEpochMs as w, resolveSpaceRef as x, displayIdSchema as xt, resolveBoundSpace as y, DISPLAY_ELEMENT_ROLES as yt, pollDeviceCode as z };
12590
+ export { parseSpaceRef as $, spinner as A, readAuthSession as B, error as C, splitDisplayText as Ct, json as D, handleHttp as E, AuthRequiredError as F, revokeAndClearAuthSession as G, requestDeviceCode as H, authSessionPath as I, getRuntimeSpaceBinding as J, verifyDeviceCode as K, authSource as L, truncateText as M, warn as N, jsonRequested as O, describeError as P, withRuntimeSpaceBindingsLock as Q, loginWithDeviceFlow as R, resolveSpaceTarget as S, normalizeDisplayPoint as St, formatLocalDateTime as T, requireAccessToken as U, refreshAccessToken as V, resolveAccessToken as W, resolveRuntimeSpace as X, readRuntimeSpaceBindings as Y, runtimeSpaceBindingsPath as Z, failSpaceTarget as _, displayActStepSchema as _t, findLocalWorkspace as a, APP_RUNTIME_HAPTICS as at, resolveSpace as b, DISPLAY_SYSTEM_ACTIONS as bt, ownRuntimeInstance as c, DESKTOP_COMMAND_MAX_TIMEOUT_MS as ct, runtimeInstancesRoot as d, parseSpaceSlug as dt, buildSpaceInvitePath as et, stopRuntimeInstance as f, parseUsername as ft, explicitSpace as g, DISPLAY_RECORDINGS_DIR as gt, currentIdentityKey as h, DISPLAY_HANDOVER_WAIT_MS as ht, connectLocalWorkspace as i, isHttpErrorCode as it, table as j, ok as k, requestRuntimeInstance as l, DESKTOP_COMMAND_OPEN_TIMEOUT_MS as lt, clearHomeSpaceCache as m, DISPLAY_HANDOVER_MAX_MS as mt, createClientWithAccessToken as n, LocalWorkspaceUnavailableError as nt, UNCONFIRMED_WORK as o, DESKTOP_COMMAND_ACCEPT_TIMEOUT_MS as ot, watchRuntimeInstance as p, DISPLAY_HANDOVER_DEFAULT_MS as pt, canonicalRuntimeRoot as q, createRealtimeClient as r, localWorkspaceHttpError as rt, controlRuntimeInstance as s, DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS as st, createClient as t, LocalWorkspaceRpcError as tt, runtimeInstanceDirectory as u, resolveOpenSurface as ut, jwtClaim as v, DISPLAY_ELEMENT_REF_PATTERN as vt, formatEpochMs as w, resolveSpaceRef as x, displayIdSchema as xt, resolveBoundSpace as y, DISPLAY_ELEMENT_ROLES as yt, pollDeviceCode as z };