@neta-art/cohub-cli 10.19.0 → 10.21.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.
@@ -97,6 +97,26 @@ function showPlayback(playback) {
97
97
  { key: "timeScale", label: "Speed" },
98
98
  ]);
99
99
  }
100
+ const shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
101
+ async function runExportTask(boards, options) {
102
+ try {
103
+ const command = ["cohub", ...process.argv.slice(2).filter((arg) => arg !== "--async")].map(shellQuote).join(" ");
104
+ const { taskRunId } = await createClient().space(await resolveSpace(boards)).runCommand({ command });
105
+ if (jsonRequested(options))
106
+ return outJson({ taskRunId, command });
107
+ ok(`Exporting as Task ${taskRunId}`);
108
+ console.log(` Follow it with: cohub tasks get ${taskRunId}`);
109
+ }
110
+ catch (cause) {
111
+ handleHttp(cause);
112
+ }
113
+ }
114
+ function parseSize(value) {
115
+ const size = /^(\d+)x(\d+)$/.exec(value);
116
+ if (!size?.[1] || !size[2])
117
+ throw new Error("--size must be widthxheight, e.g. 1600x900.");
118
+ return { width: parseNumber(size[1], "width", { min: 1, max: 8192 }), height: parseNumber(size[2], "height", { min: 1, max: 8192 }) };
119
+ }
100
120
  /** One region flag at most: being told to pick beats guessing which one wins. */
101
121
  function parseExportRegion(options) {
102
122
  const chosen = [options.camera && "--camera", options.frame && "--frame", options.items && "--items", options.rect && "--rect"].filter(Boolean);
@@ -167,14 +187,26 @@ function registerExportCommand(boards) {
167
187
  .option("--image-memory <mib>", "Decoded image memory budget in MiB", String(BOARD_EXPORT_IMAGE_MEMORY_MIB))
168
188
  .option("--no-images", "Draw placeholders instead of downloading images")
169
189
  .option("--renderer <renderer>", "auto draws in Node and uses local Chrome for shaders; canvas or gpu forces one", "auto")
170
- .option("--force", "Replace existing output files"))
190
+ .option("--force", "Replace existing output files")
191
+ .option("--timeout <time>", "Fail a frame that takes longer, naming the scripts still running", "2m")
192
+ .option("--async", "Run as a Task in the Space's sandbox and return at once; paths are Space paths"))
171
193
  .addHelpText("after", `
194
+ Shaders draw in a shared headless Chrome that stays up a few minutes between calls;
195
+ Boards without shaders never start it. Set COHUB_BOARD_GPU_DAEMON=0 to start one per call.
196
+
172
197
  Examples:
173
198
  cohub boards export plan.board -o plan.png
199
+ cohub boards export plan.board --animation intro --at 0:20s:40ms -o intro.mp4 --async
174
200
  cohub boards export plan.board --frame s2 -o slide-2.png
175
201
  cohub boards export plan.board --animation lecture --at 4.5s -o moment.png
176
- cohub boards export plan.board --animation lecture --at 0:6s:40ms -o frames/%04d.png`)
202
+ cohub boards export plan.board --animation lecture --at 0:6s:40ms -o frames/%04d.png
203
+
204
+ Scripts see the exported area as their view (viewchange), and emit() between them is
205
+ delivered within the same moment, in document order. --frame draws the frame as a
206
+ page: its fill and shaders, without its outline and label.`)
177
207
  .action(async (target, options) => {
208
+ if (options.async)
209
+ return runExportTask(boards, options);
178
210
  const controller = new AbortController();
179
211
  const cancel = () => controller.abort(new Error("Export cancelled."));
180
212
  process.once("SIGINT", cancel);
@@ -185,10 +217,7 @@ Examples:
185
217
  if (options.camera) {
186
218
  if (!options.animation || !times)
187
219
  throw new Error("--camera needs --animation and --at.");
188
- const size = /^(\d+)x(\d+)$/.exec(options.size ?? "1600x900");
189
- if (!size?.[1] || !size[2])
190
- throw new Error("--size must be widthxheight, e.g. 1600x900.");
191
- camera = { width: parseNumber(size[1], "width", { min: 1, max: 8192 }), height: parseNumber(size[2], "height", { min: 1, max: 8192 }) };
220
+ camera = parseSize(options.size ?? "1600x900");
192
221
  }
193
222
  const progress = (completed, total) => {
194
223
  if (!jsonRequested(options) && (completed === total || completed % 30 === 0))
@@ -222,6 +251,7 @@ Examples:
222
251
  spaceId: await resolveSpace(boards),
223
252
  target,
224
253
  camera,
254
+ timeoutMs: parseBoardTime(options.timeout ?? "2m", "--timeout"),
225
255
  onProgress: progress,
226
256
  onPlan,
227
257
  imageMemoryMiB,
@@ -259,6 +289,7 @@ Examples:
259
289
  spaceId: await resolveSpace(boards),
260
290
  target,
261
291
  camera,
292
+ timeoutMs: parseBoardTime(options.timeout ?? "2m", "--timeout"),
262
293
  onProgress: progress,
263
294
  onPlan,
264
295
  imageMemoryMiB,
@@ -307,6 +338,7 @@ function registerSimulateCommand(boards) {
307
338
  .option("-i, --input <file>", "Steps JSON; - for stdin")
308
339
  .option("-o, --out <file>", "Also render the result, screen UI included; the extension picks the format")
309
340
  .option("--follower", "Simulate an editor that does not write autonomous commits")
341
+ .option("--timeout <time>", "Give up after this long and report what is still running", "2m")
310
342
  .option("--frame <item-id>", "Render one frame")
311
343
  .option("--items <ids>", "Render comma-separated item ids")
312
344
  .option("--rect <rect>", "Render a world rect as x,y,width,height")
@@ -319,8 +351,10 @@ Steps are {"steps": [...]}, points in board coordinates, run on a virtual clock:
319
351
  {"wait": "500ms"} {"tool": "draw"} {"tap": [x, y]} {"drag": [[x, y], ...], "pointerType": "pen"}
320
352
  {"pointer": "down", "at": [x, y]} {"key": "Enter"} {"select": ["id"]}
321
353
 
322
- Shaders are compiled with a local Chrome, Chromium or Edge when one is found, and
323
- their errors join the scripts' errors.
354
+ Shaders are compiled with a local Chrome, Chromium or Edge when one is found, before
355
+ the steps run; their errors join the scripts' errors and stop the run.
356
+ Each tap and drag reports where it landed (a script's hit region, a selection handle,
357
+ an item, or empty board) and what took it (a script, move, resize, rotate, select box).
324
358
 
325
359
  Examples:
326
360
  cohub boards simulate farm.board '{"steps":[{"wait":"2s"}]}' -o farm.png
@@ -342,6 +376,7 @@ Examples:
342
376
  target,
343
377
  steps,
344
378
  leader: !options.follower,
379
+ timeoutMs: parseBoardTime(options.timeout ?? "2m", "--timeout"),
345
380
  ...(out ? { image: {
346
381
  region: parseExportRegion(options),
347
382
  scale: parseNumber(options.scale ?? "2", "--scale", { min: 0.01, max: 16 }),
@@ -359,8 +394,12 @@ Examples:
359
394
  return outJson({ ...summary, ...(out && image ? { file: out, width: image.width, height: image.height } : {}) });
360
395
  const changed = Object.keys(result.changes.items ?? {}).length;
361
396
  ok(`Simulated ${formatBoardTime(result.time)}: ${result.commits} commit${result.commits === 1 ? "" : "s"}, ${changed} item${changed === 1 ? "" : "s"} changed (not saved)`);
397
+ for (const press of result.presses)
398
+ console.log(` step ${press.step + 1}: ${describePress(press)}`);
362
399
  for (const [id, message] of Object.entries(result.errors))
363
400
  console.log(` ! ${id}: ${message.split("\n")[0]}`);
401
+ for (const warning of result.warnings)
402
+ console.log(` ! ${warning}`);
364
403
  if (result.shaders && !result.shaders.compiled)
365
404
  console.log(" Shaders were checked but not compiled; install Chrome, Chromium or Edge, or set COHUB_CHROME, to compile them.");
366
405
  if (out && image)
@@ -373,6 +412,75 @@ Examples:
373
412
  }
374
413
  });
375
414
  }
415
+ function describePress({ down, taken }) {
416
+ const where = down.on === "script" ? `script ${down.owner}/${down.target}`
417
+ : down.on === "handle" ? `${down.handle} handle`
418
+ : down.on === "item" ? `${down.type} ${down.id}`
419
+ : `empty board${down.under ? ` over ${down.under}` : ""}`;
420
+ return `pressed on ${where}, taken by ${taken}`;
421
+ }
422
+ function registerProfileCommand(boards) {
423
+ withJson(boards.command("profile <board>")
424
+ .description("Measure what a Board costs to draw, shader by shader, and say what to change")
425
+ .option("--at <time>", "A moment of --animation, or a script time without one", "2s")
426
+ .option("--animation <id>", "Animation --at refers to")
427
+ .option("--frame <item-id>", "Profile one frame")
428
+ .option("--items <ids>", "Profile comma-separated item ids")
429
+ .option("--rect <rect>", "Profile a world rect as x,y,width,height")
430
+ .option("--size <widthxheight>", "Fit the region into this many pixels, like a screen", "1600x900")
431
+ .option("--frames <count>", "Frames to time per measurement", "5")
432
+ .option("--rounds <count>", "Measurements per shader owner; reports their median and range", "3")
433
+ .option("--budget <time>", "Time the measurements may take; past it, size and frames go down", "60s")
434
+ .option("--no-images", "Draw placeholders instead of downloading images"))
435
+ .addHelpText("after", `
436
+ Draws in a headless Chrome; without a GPU it uses software WebGL (reported as
437
+ "software"), so compare the numbers with each other rather than with a real display.
438
+ Scripts receive the profiled view as viewchange, as on a screen of --size.
439
+
440
+ Examples:
441
+ cohub boards profile demo.board
442
+ cohub boards profile demo.board --rect 0,0,1600,900 --at 8s --json`)
443
+ .action(async (target, options) => {
444
+ try {
445
+ const { profileBoard } = await import("../board-profile.js");
446
+ const profile = await profileBoard({
447
+ spaceId: await resolveSpace(boards),
448
+ target,
449
+ time: parseBoardTime(options.at ?? "2s", "--at"),
450
+ ...(options.animation ? { animation: options.animation } : {}),
451
+ region: parseExportRegion(options),
452
+ size: parseSize(options.size ?? "1600x900"),
453
+ frames: parseNumber(options.frames ?? "5", "--frames", { min: 3, max: 240, integer: true }),
454
+ rounds: parseNumber(options.rounds ?? "3", "--rounds", { min: 1, max: 20, integer: true }),
455
+ budgetMs: parseBoardTime(options.budget ?? "60s", "--budget"),
456
+ withImages: options.images !== false,
457
+ });
458
+ if (jsonRequested(options))
459
+ return outJson(profile);
460
+ const ms = (value) => `${value.toFixed(1)} ms`;
461
+ ok(`${profile.width}×${profile.height} on ${profile.gpu} WebGL (${profile.renderer}): ${ms(profile.frame.p50)} a frame (p95 ${ms(profile.frame.p95)}), ${profile.items} items`);
462
+ if (profile.reduced)
463
+ console.log(` ! ${profile.reduced.width}×${profile.reduced.height} × ${profile.reduced.frames} frames took ${ms(profile.reduced.frameMs)} a frame, past the budget; measured ${profile.width}×${profile.height} × ${profile.frames} frames instead.`);
464
+ console.log(` ${profile.rounds} round${profile.rounds === 1 ? "" : "s"} × ${profile.frames} frames in ${(profile.elapsedMs / 1000).toFixed(1)} s; owner cost is the median, with the range across rounds`);
465
+ for (const owner of profile.owners) {
466
+ const traits = [owner.filter !== "none" && `filter ${owner.filter}`, owner.sprites && `${owner.sprites} sprites`, owner.state && `state ${owner.state.width}×${owner.state.height}`].filter(Boolean);
467
+ const range = profile.rounds > 1 ? ` (${owner.range[0].toFixed(0)}–${owner.range[1].toFixed(0)})` : "";
468
+ console.log(` ${owner.id.padEnd(24)} ${ms(owner.ms).padStart(9)}${range.padEnd(12)}${traits.length ? ` ${traits.join(", ")}` : ""}`);
469
+ }
470
+ for (const hint of profile.hints)
471
+ console.log(` ! ${hint}`);
472
+ }
473
+ catch (cause) {
474
+ handleHttp(cause);
475
+ }
476
+ });
477
+ boards.command("gpu-daemon", { hidden: true })
478
+ .requiredOption("--browser <path>")
479
+ .action(async (options) => {
480
+ const { serveBoardGpu } = await import("../board-gpu/daemon.js");
481
+ await serveBoardGpu(options.browser);
482
+ });
483
+ }
376
484
  // ─── Commands ────────────────────────────────────────────────────────────────
377
485
  export function registerBoards(program) {
378
486
  const boards = program
@@ -393,6 +501,7 @@ A Board is one JSON document: { board, items, animations }.
393
501
  play shared playback; also pause, resume, next, seek, stop
394
502
  watch stream changes and playback
395
503
  history list versions, or restore one
504
+ diff what changed between two versions
396
505
  Times are milliseconds; 500ms, 12.5s and 2m also work on the command line.`);
397
506
  withJson(boards.command("create <path>")
398
507
  .description("Create a Board file, optionally with an initial document")
@@ -552,6 +661,42 @@ Times are milliseconds; 500ms, 12.5s and 2m also work on the command line.`);
552
661
  handleHttp(cause);
553
662
  }
554
663
  });
664
+ withJson(boards.command("diff <board>")
665
+ .description("List what changed between two versions, element by element")
666
+ .requiredOption("--from <version>", "The version to compare from")
667
+ .option("--to <version>", "The version to compare to; the latest by default"))
668
+ .addHelpText("after", `
669
+ Before rewriting a Board with apply --replace, see what others changed since the version you read:
670
+ cohub boards diff plan.board --from 41
671
+ cohub boards diff plan.board --from 41 --to 44 --json`)
672
+ .action(async (target, options) => {
673
+ try {
674
+ const board = await boardClient(boards, target);
675
+ const result = await board.diff(parseNumber(options.from, "--from", { min: 0, integer: true }), options.to === undefined ? undefined : parseNumber(options.to, "--to", { min: 1, integer: true }));
676
+ if (jsonRequested(options))
677
+ return outJson(result);
678
+ const by = new Map();
679
+ for (const { kind } of result.versions)
680
+ by.set(kind, (by.get(kind) ?? 0) + 1);
681
+ ok(`v${result.from} → v${result.to}: ${result.changes.length} element${result.changes.length === 1 ? "" : "s"} changed in ${result.versions.length} version${result.versions.length === 1 ? "" : "s"}${by.size ? ` (${[...by].map(([kind, count]) => `${count} by ${kind}`).join(", ")})` : ""}`);
682
+ const show = (value) => {
683
+ const text = value === undefined ? "∅" : JSON.stringify(value);
684
+ return text.length > 60 ? `${text.slice(0, 57)}…` : text;
685
+ };
686
+ for (const change of result.changes) {
687
+ const sign = change.change === "added" ? "+" : change.change === "removed" ? "-" : "~";
688
+ const name = change.kind === "board" ? "board" : `${change.kind} ${change.id}${change.type ? ` (${change.type})` : ""}`;
689
+ console.log(` ${sign} ${name}`);
690
+ for (const field of change.fields.slice(0, 12))
691
+ console.log(` ${field.path}: ${show(field.from)} → ${show(field.to)}`);
692
+ if (change.fields.length > 12)
693
+ console.log(` … ${change.fields.length - 12} more fields; --json lists them all`);
694
+ }
695
+ }
696
+ catch (cause) {
697
+ handleHttp(cause);
698
+ }
699
+ });
555
700
  boards.command("schema [target]")
556
701
  .description("Print JSON Schema for a part of a Board")
557
702
  .option("--field <path>", "Print one field, e.g. props.decoration or props.geometry")
@@ -611,6 +756,7 @@ Presets: ${BOARD_PRESET_NAMES.join(", ")}
611
756
  registerBoardExampleCommands(boards);
612
757
  registerExportCommand(boards);
613
758
  registerSimulateCommand(boards);
759
+ registerProfileCommand(boards);
614
760
  registerBoardAuthoringCommands(boards);
615
761
  registerPlaybackCommands(boards);
616
762
  withJson(boards.command("watch <board>")
@@ -2,6 +2,7 @@ import { openAsBlob } from "node:fs";
2
2
  import { stat } from "node:fs/promises";
3
3
  import { arch, platform, release } from "node:os";
4
4
  import { basename, resolve } from "node:path";
5
+ import { cliCommit } from "../version.js";
5
6
  import { mimeTypeForPath, readRequestSourceFromEnv, resolveApiBaseUrl, resolveCohubEnvironment } from "@neta-art/cohub";
6
7
  import { authSource } from "../auth.js";
7
8
  import { createClient } from "../client.js";
@@ -100,6 +101,7 @@ Examples:
100
101
  const extra = {
101
102
  user_uuid: userUuid,
102
103
  cli_version: program.version() ?? null,
104
+ cli_commit: cliCommit(),
103
105
  node: process.versions.node,
104
106
  os: `${platform()} ${release()}`,
105
107
  arch: arch(),
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerVersion(program: Command): void;
@@ -0,0 +1,21 @@
1
+ import { describeCli } from "../about.js";
2
+ import { json, jsonRequested } from "../output.js";
3
+ import { isNewerVersion } from "../self-update.js";
4
+ import { currentIdentityKey } from "../space.js";
5
+ export function registerVersion(program) {
6
+ program
7
+ .command("version")
8
+ .description("This CLI, the cohub on PATH, and the versions running Runtimes serve")
9
+ .option("--json", "JSON output")
10
+ .action(async (options) => {
11
+ const about = await describeCli(process.env, currentIdentityKey());
12
+ if (jsonRequested(options))
13
+ return json(about);
14
+ const rows = [
15
+ `cohub ${about.version}${about.commit ? ` (${about.commit})` : ""} · Node ${about.node}`,
16
+ `PATH ${about.path ? `${about.path.path} · ${about.path.version ?? "unknown"}` : "No cohub on PATH"}`,
17
+ ...about.runtimes.map((runtime, index) => `${index ? " " : "Runtimes "} ${runtime.version ?? "older"} · ${runtime.root}${isNewerVersion(about.version, runtime.version ?? undefined) ? " (reconnect to update)" : ""}`),
18
+ ];
19
+ process.stdout.write(`${rows.join("\n")}\n`);
20
+ });
21
+ }
@@ -1,6 +1,7 @@
1
1
  import { createInterface } from "node:readline";
2
2
  import { fileURLToPath } from "node:url";
3
- import { HOST_BRIDGE_ERROR, HOST_BRIDGE_METHODS, HOST_SERVICE_VERSION, HOST_SERVICE_WORKSPACE_ENDPOINT, HostBridgeErrorClass, hostBridgeRequestSchema, } from "@neta-art/cohub/host-bridge";
3
+ import { HOST_BRIDGE_ERROR, HOST_BRIDGE_METHODS, HOST_SERVICE_CLI_ABOUT, HOST_SERVICE_VERSION, HOST_SERVICE_WORKSPACE_ENDPOINT, HostBridgeErrorClass, hostBridgeRequestSchema, } from "@neta-art/cohub/host-bridge";
4
+ import { describeCli } from "../about.js";
4
5
  import { findLocalWorkspace } from "../runtime/local-workspace.js";
5
6
  import { currentIdentityKey } from "../space.js";
6
7
  import { HostAuth } from "./auth.js";
@@ -16,9 +17,11 @@ const write = (message) => process.stdout.write(`${JSON.stringify(message)}\n`);
16
17
  export async function serveHost(entry = fileURLToPath(new URL("../../bin/cohub.js", import.meta.url))) {
17
18
  const emit = (name, payload) => write({ type: "event", name, ...(payload === undefined ? {} : { payload }) });
18
19
  let environment = null;
20
+ const env = () => (environment ??= loginShellEnv());
21
+ const about = async () => describeCli(await env(), currentIdentityKey());
19
22
  const runtime = new DeviceRuntimeHost(emit, {
20
23
  cli: entry,
21
- env: () => (environment ??= loginShellEnv()),
24
+ env,
22
25
  account: currentIdentityKey,
23
26
  });
24
27
  const auth = new HostAuth(emit, () => {
@@ -47,8 +50,9 @@ export async function serveHost(entry = fileURLToPath(new URL("../../bin/cohub.j
47
50
  } : {}),
48
51
  "workspace.call": (params) => callLocalWorkspace(String(params.spaceId), String(params.method), params.params),
49
52
  };
50
- // Asked by the shell itself to proxy file URLs; absent from hello, so a page can never reach it.
53
+ // Asked by the shell itself; absent from hello, so a page can never reach them.
51
54
  const shellHandlers = {
55
+ [HOST_SERVICE_CLI_ABOUT]: about,
52
56
  [HOST_SERVICE_WORKSPACE_ENDPOINT]: (params) => {
53
57
  const spaceId = String(params.spaceId ?? "");
54
58
  if (!SPACE_ID.test(spaceId))
@@ -101,6 +105,8 @@ export async function serveHost(entry = fileURLToPath(new URL("../../bin/cohub.j
101
105
  write(hello);
102
106
  auth.watch();
103
107
  runtime.watch();
108
+ // Probed once off the start-up path, so an About panel opens with its answer ready.
109
+ setTimeout(() => void about().catch(() => undefined), 3_000).unref();
104
110
  const input = createInterface({ input: process.stdin, crlfDelay: Infinity });
105
111
  input.on("line", (line) => { if (line.length <= MAX_LINE)
106
112
  void answer(line); });
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
- import { readFileSync } from "node:fs";
4
3
  import { registerEndpointOptions } from "./endpoint-options.js";
5
4
  import { registerAuth } from "./commands/auth.js";
6
5
  import { registerBoards } from "./commands/boards.js";
@@ -23,24 +22,17 @@ import { registerRuntime } from "./commands/runtime.js";
23
22
  import { registerTasks } from "./commands/tasks.js";
24
23
  import { registerDesktop, registerLegacyUi } from "./commands/desktop.js";
25
24
  import { registerHost } from "./commands/host.js";
25
+ import { registerVersion } from "./commands/version.js";
26
26
  import { registerApps } from "./commands/apps.js";
27
27
  import { registerRooms } from "./commands/rooms.js";
28
28
  import { formatUnknownCommandError, resolveHelpPath } from "./help-path.js";
29
- const VERSION = (() => {
30
- try {
31
- const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
32
- return pkg.version;
33
- }
34
- catch {
35
- return "1.0.0";
36
- }
37
- })();
29
+ import { CLI_VERSION } from "./version.js";
38
30
  const program = registerEndpointOptions(new Command("cohub"));
39
31
  program
40
32
  .name("cohub")
41
33
  .summary("Work with Cohub from your terminal")
42
34
  .description("Send prompts, manage Space files, and publish public output.")
43
- .version(VERSION, "-v, --version", "Show version")
35
+ .version(CLI_VERSION, "-v, --version", "Show version")
44
36
  .option("-s, --space <space>", "Target Space: ID, slug, or username/slug")
45
37
  .option("--json", "Print machine-readable JSON when supported")
46
38
  .helpOption("-h, --help", "Show help")
@@ -116,6 +108,7 @@ registerFeedback(program);
116
108
  registerDesktop(program);
117
109
  registerLegacyUi(program);
118
110
  registerHost(program);
111
+ registerVersion(program);
119
112
  const argv = process.argv.slice(2);
120
113
  const help = resolveHelpPath(program, argv);
121
114
  if (help.kind === "help") {
@@ -3,6 +3,7 @@ import { setTimeout as delay } from "node:timers/promises";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  import { RUNTIME_MAX_FRAME_BYTES, RUNTIME_PROTOCOL_VERSION, runtimeCapabilitiesSchema, runtimeCommandSchema, runtimeHelloCapabilities, runtimeReadySchema, runtimeNativeStopSchema, runtimeApprovalDecisionSchema, } from "@neta-art/cohub";
5
5
  import { describeError } from "../network-error.js";
6
+ import { CLI_VERSION } from "../version.js";
6
7
  import { executeTurn } from "./native/execution.js";
7
8
  import { ContextRequiredError } from "./native/results.js";
8
9
  import { SizeLimitError } from "./native/transcript.js";
@@ -413,6 +414,7 @@ async function connect(options) {
413
414
  spaceId: options.spaceId,
414
415
  token: currentToken,
415
416
  capabilities: registered,
417
+ client: { name: "cli", version: CLI_VERSION },
416
418
  });
417
419
  }
418
420
  catch (error) {
@@ -13,6 +13,7 @@ export type RuntimeSummary = {
13
13
  root: string;
14
14
  harnesses: string[];
15
15
  pid: number;
16
+ version?: string;
16
17
  state: "starting" | "ready" | "reconnecting" | "attention" | "stopping";
17
18
  harnessConnected: boolean;
18
19
  workspaceConnected: boolean;
@@ -69,6 +69,7 @@ export function printRuntimeSummary(summary, json = false, reused = false) {
69
69
  ["URL", value.url],
70
70
  ["Directory", summary.root],
71
71
  ["Harness", summary.harnesses.join(" · ") || "Cohub"],
72
+ ...(summary.version ? [["CLI", summary.version]] : []),
72
73
  ["Mode", summary.background ? "Background" : "Foreground"],
73
74
  ...(summary.display ? [["Screen", summary.display === "auto" ? "This computer" : summary.display]] : []),
74
75
  ...(summary.direct ? [["Direct", "Files and screens on this machine skip the network"]] : []),
@@ -8,6 +8,7 @@ import { resolveWebsocketUrl } from "@neta-art/cohub";
8
8
  import { AuthRequiredError, resolveAccessToken } from "../auth.js";
9
9
  import { createClient } from "../client.js";
10
10
  import { currentIdentityKey } from "../space.js";
11
+ import { CLI_VERSION } from "../version.js";
11
12
  import { ensureSandboxdBinary } from "../commands/sandboxd-binary.js";
12
13
  import { serveRuntime } from "./connection.js";
13
14
  import { discoverHarnesses, refreshHarnesses } from "./harnesses/index.js";
@@ -72,7 +73,7 @@ export async function runRuntime(config, onState, externalSignal, onDiagnostic)
72
73
  });
73
74
  let status = {
74
75
  spaceId: config.spaceId, root: config.root, runtimeId: diagnostics.runtimeId,
75
- pid: process.pid, harnesses: config.harnesses, background: config.background,
76
+ pid: process.pid, version: CLI_VERSION, harnesses: config.harnesses, background: config.background,
76
77
  ...(config.display ? { display: config.display } : {}),
77
78
  state: "starting", harnessConnected: false, workspaceConnected: false,
78
79
  diagnosticsPath: diagnostics.directory,
@@ -0,0 +1,2 @@
1
+ export declare const CLI_VERSION: string;
2
+ export declare function cliCommit(): string | null;
@@ -0,0 +1,17 @@
1
+ import { readFileSync } from "node:fs";
2
+ export const CLI_VERSION = (() => {
3
+ try {
4
+ return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
5
+ }
6
+ catch {
7
+ return "0.0.0";
8
+ }
9
+ })();
10
+ export function cliCommit() {
11
+ try {
12
+ return JSON.parse(readFileSync(new URL("./build.json", import.meta.url), "utf8")).commit ?? null;
13
+ }
14
+ catch {
15
+ return null;
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "10.19.0",
3
+ "version": "10.21.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=24"
8
8
  },
9
9
  "license": "Apache-2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/netaart/cohub.git",
13
+ "directory": "packages/cli"
14
+ },
15
+ "homepage": "https://github.com/netaart/cohub",
10
16
  "bin": {
11
17
  "cohub": "./bin/cohub.js"
12
18
  },
@@ -18,7 +24,7 @@
18
24
  "NOTICE"
19
25
  ],
20
26
  "dependencies": {
21
- "@neta-art/cohub": "13.10.0",
27
+ "@neta-art/cohub": "13.12.0",
22
28
  "@neta-art/generation": "0.2.15",
23
29
  "commander": "^15.0.0",
24
30
  "sharp": "^0.35.4",
@@ -41,7 +47,7 @@
41
47
  "@napi-rs/canvas": "^1.0.13"
42
48
  },
43
49
  "scripts": {
44
- "build": "tsc -p tsconfig.build.json && tsdown",
50
+ "build": "tsc -p tsconfig.build.json && tsdown && node scripts/stamp-build.mjs",
45
51
  "verify:sandboxd": "node --import tsx scripts/verify-sandboxd-release.ts",
46
52
  "verify:rtc": "node --import tsx scripts/verify-rtc-release.ts",
47
53
  "verify:board-kernel": "node --import tsx scripts/verify-board-kernel.ts",