@neta-art/cohub-cli 10.12.3 → 10.13.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.
@@ -1,4 +1,4 @@
1
- export { BOARD_SCRIPT_DRAWING_EXAMPLE, hasBoardScripts, boardAssetKey, boardAssetKeySource, boardDocumentAt, createBoardAnimationSampler, boardSequence, boardSequencePatch, boardPathTrack, boardTextureEdge, boardTexturePixels, buildBoardScene, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "@neta-art/cohub/board";
1
+ export { BOARD_SCRIPT_DRAWING_EXAMPLE, hasBoardScripts, boardAssetKey, boardAssetKeySource, boardDocumentAt, boardFrameRegions, boardRegionStep, createBoardAnimationSampler, boardSequence, boardSequencePatch, boardPathTrack, boardTextureEdge, boardTexturePixels, buildBoardScene, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "@neta-art/cohub/board";
2
2
  export { prepareBoardExport } from "@neta-art/cohub/board/export";
3
3
  export { boardRenderTheme, createBoardRenderSampler, inspectBoardScene, inspectBoardItems, measureBoardText } from "@neta-art/cohub/board/render";
4
4
  export { createNodeBoardRenderer, createNodeBoardScriptHost, exportBoardImageBytes } from "@neta-art/cohub/board/export/node";
@@ -9798,6 +9798,100 @@ function fileCategoryAccent(category, palette) {
9798
9798
  }
9799
9799
  }
9800
9800
  //#endregion
9801
+ //#region ../sdk/src/board/model/frames.ts
9802
+ const SAME_ROW = .5;
9803
+ const CROSS_WEIGHT = 2;
9804
+ const CENTER_WEIGHT = .1;
9805
+ function boardNavigableFrames(scene) {
9806
+ const frames = [];
9807
+ const visit = (ids) => {
9808
+ for (const id of ids) {
9809
+ const item = scene.get(id);
9810
+ if (item?.type !== "frame") continue;
9811
+ if (item.props.decoration === "none") visit(scene.children(id));
9812
+ else frames.push(item);
9813
+ }
9814
+ };
9815
+ visit(scene.children(void 0));
9816
+ return frames;
9817
+ }
9818
+ function boardFrameRegion(item) {
9819
+ const label = item.type === "frame" ? item.props.label.trim() : "";
9820
+ return {
9821
+ id: item.id,
9822
+ rect: itemBounds(item.frame),
9823
+ ...label ? { label } : {}
9824
+ };
9825
+ }
9826
+ function boardFrameRegions(scene) {
9827
+ return boardReadingOrder(boardNavigableFrames(scene).map(boardFrameRegion));
9828
+ }
9829
+ const byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
9830
+ function boardReadingOrder(regions) {
9831
+ const sorted = [...regions].sort((a, b) => a.rect.y - b.rect.y || a.rect.x - b.rect.x || byId(a, b));
9832
+ const rows = [];
9833
+ for (const region of sorted) {
9834
+ const { y, height } = region.rect;
9835
+ const row = rows.at(-1);
9836
+ const overlap = row ? Math.min(row.bottom, y + height) - Math.max(row.top, y) : -1;
9837
+ if (row && overlap >= SAME_ROW * Math.min(height, row.bottom - row.top)) row.regions.push(region);
9838
+ else rows.push({
9839
+ top: y,
9840
+ bottom: y + height,
9841
+ regions: [region]
9842
+ });
9843
+ }
9844
+ return rows.flatMap((row) => row.regions.sort((a, b) => a.rect.x - b.rect.x || a.rect.y - b.rect.y || byId(a, b)));
9845
+ }
9846
+ function axis(rect, horizontal) {
9847
+ return horizontal ? {
9848
+ start: rect.x,
9849
+ end: rect.x + rect.width,
9850
+ crossStart: rect.y,
9851
+ crossEnd: rect.y + rect.height
9852
+ } : {
9853
+ start: rect.y,
9854
+ end: rect.y + rect.height,
9855
+ crossStart: rect.x,
9856
+ crossEnd: rect.x + rect.width
9857
+ };
9858
+ }
9859
+ /** Left and right stay within regions sharing some height; up and down may reach regions offset sideways. */
9860
+ function boardRegionNeighbor(regions, from, direction) {
9861
+ const horizontal = direction === "left" || direction === "right";
9862
+ const sign = direction === "right" || direction === "down" ? 1 : -1;
9863
+ const origin = axis(from.rect, horizontal);
9864
+ const center = (origin.start + origin.end) / 2;
9865
+ const crossCenter = (origin.crossStart + origin.crossEnd) / 2;
9866
+ let best = null;
9867
+ let bestScore = Number.POSITIVE_INFINITY;
9868
+ for (const region of regions) {
9869
+ if (region.id === from.id) continue;
9870
+ const other = axis(region.rect, horizontal);
9871
+ if (!(sign > 0 ? other.end > origin.end && other.start + other.end > center * 2 : other.start < origin.start && other.start + other.end < center * 2)) continue;
9872
+ const gap = Math.max(0, sign > 0 ? other.start - origin.end : origin.start - other.end);
9873
+ const cross = Math.max(0, other.crossStart - origin.crossEnd, origin.crossStart - other.crossEnd);
9874
+ if (horizontal && cross > 0) continue;
9875
+ const drift = Math.abs((other.crossStart + other.crossEnd) / 2 - crossCenter);
9876
+ const score = gap + CROSS_WEIGHT * cross + CENTER_WEIGHT * drift;
9877
+ if (score < bestScore) {
9878
+ best = region;
9879
+ bestScore = score;
9880
+ }
9881
+ }
9882
+ return best;
9883
+ }
9884
+ function boardRegionStep(regions, from, step) {
9885
+ const index = regions.findIndex((region) => region.id === from.id);
9886
+ switch (step) {
9887
+ case "next": return index < 0 ? null : regions[index + 1] ?? null;
9888
+ case "previous": return index > 0 ? regions[index - 1] ?? null : null;
9889
+ case "first": return regions[0] ?? null;
9890
+ case "last": return regions.at(-1) ?? null;
9891
+ default: return boardRegionNeighbor(regions, from, step) ?? (step === "right" ? boardRegionStep(regions, from, "next") : step === "left" ? boardRegionStep(regions, from, "previous") : null);
9892
+ }
9893
+ }
9894
+ //#endregion
9801
9895
  //#region ../sdk/src/board/model/themes.ts
9802
9896
  const BOARD_THEME_DATA = {
9803
9897
  dark: {
@@ -38323,4 +38417,4 @@ function exportBoardImageBytes(renderer, document, options = {}) {
38323
38417
  }
38324
38418
  }
38325
38419
  //#endregion
38326
- export { BOARD_SCRIPT_DRAWING_EXAMPLE, boardAssetKey, boardAssetKeySource, boardDocumentAt, boardPathTrack, boardRenderTheme, boardSequence, boardSequencePatch, boardTextureEdge, boardTexturePixels, buildBoardScene, createBoardAnimationSampler, createBoardRenderSampler, createNodeBoardRenderer, createNodeBoardScriptHost, exportBoardImageBytes, hasBoardScripts, inspectBoardItems, inspectBoardScene, measureBoardText, parseBoardDocument, planBoardExport, prepareBoardExport, selectBoardExportAssets };
38420
+ export { BOARD_SCRIPT_DRAWING_EXAMPLE, boardAssetKey, boardAssetKeySource, boardDocumentAt, boardFrameRegions, boardPathTrack, boardRegionStep, boardRenderTheme, boardSequence, boardSequencePatch, boardTextureEdge, boardTexturePixels, buildBoardScene, createBoardAnimationSampler, createBoardRenderSampler, createNodeBoardRenderer, createNodeBoardScriptHost, exportBoardImageBytes, hasBoardScripts, inspectBoardItems, inspectBoardScene, measureBoardText, parseBoardDocument, planBoardExport, prepareBoardExport, selectBoardExportAssets };
@@ -1,10 +1,11 @@
1
1
  import { readBoardJsonObject } from "../../board-command-support.js";
2
2
  import { loadBoardDocument, resolveBundledFonts } from "../../board-export.js";
3
3
  import { settleBoardDocument } from "../../board-media.js";
4
- import { boardPathTrack, boardSequencePatch, buildBoardScene, createBoardAnimationSampler, createNodeBoardRenderer, inspectBoardItems, } from "../../board-kernel.js";
4
+ import { boardFrameRegions, boardPathTrack, boardRegionStep, boardSequencePatch, buildBoardScene, createBoardAnimationSampler, createNodeBoardRenderer, inspectBoardItems, } from "../../board-kernel.js";
5
5
  import { parseBoardTimes } from "../../board-time.js";
6
- import { handleHttp, json as outJson } from "../../output.js";
6
+ import { handleHttp, json as outJson, jsonRequested, table } from "../../output.js";
7
7
  import { resolveSpace } from "../../space.js";
8
+ const DIRECTIONS = ["left", "right", "up", "down"];
8
9
  export function registerBoardAuthoringCommands(boards) {
9
10
  boards
10
11
  .command("inspect <board>")
@@ -45,6 +46,39 @@ Example: cohub boards inspect lesson.board --animation lecture --at 0:20s:1s --j
45
46
  handleHttp(cause);
46
47
  }
47
48
  });
49
+ boards
50
+ .command("frames <board>")
51
+ .description("List the frames viewers step through, in order, and where each arrow leads")
52
+ .option("--json", "Output as JSON")
53
+ .addHelpText("after", `
54
+ Order follows placement: rows top to bottom, each left to right. Move a frame to
55
+ change where it falls. Frames inside plain (decoration: none) frames count; frames
56
+ inside other frames do not. Left and right continue in reading order past a row's end.
57
+ Viewers step with N, the arrow keys and swipes; #focus=<frame>&present presents.`)
58
+ .action(async (target, options) => {
59
+ try {
60
+ const { document } = await loadBoardDocument(await resolveSpace(boards), target);
61
+ const regions = boardFrameRegions(buildBoardScene(document));
62
+ const frames = regions.map((region, index) => ({
63
+ index: index + 1,
64
+ id: region.id,
65
+ label: region.label ?? null,
66
+ rect: region.rect,
67
+ ...Object.fromEntries(DIRECTIONS.map((direction) => [direction, boardRegionStep(regions, region, direction)?.id ?? null])),
68
+ }));
69
+ if (jsonRequested(options))
70
+ return outJson({ frames });
71
+ table(frames, [
72
+ { key: "index", label: "#" },
73
+ { key: "id", label: "ID" },
74
+ { key: "label", label: "Label", format: (value) => value ?? "" },
75
+ ...DIRECTIONS.map((direction) => ({ key: direction, label: direction[0]?.toUpperCase() + direction.slice(1), format: (value) => value ?? "–" })),
76
+ ]);
77
+ }
78
+ catch (cause) {
79
+ handleHttp(cause);
80
+ }
81
+ });
48
82
  boards
49
83
  .command("sequence <board>")
50
84
  .description("Compile chapters to an apply-ready animation patch; does not write")
@@ -313,6 +313,7 @@ A Board is one JSON document: { board, items, animations }.
313
313
  sequence join chapter animations into one timeline
314
314
  path sample a polyline into a position track
315
315
  inspect measure items and report layout hints
316
+ frames the frames viewers step through, in order
316
317
  export render an image, a frame sequence or a video
317
318
  play shared playback; also pause, resume, next, seek, stop
318
319
  watch stream changes and playback
@@ -167,12 +167,14 @@ export function registerSpaceDisplays(spacesCmd) {
167
167
  table(result.displays.map((display) => ({
168
168
  ...display,
169
169
  size: `${display.width}x${display.height}`,
170
+ platform: display.platform ?? "—",
170
171
  abilities: [display.stream && "view", display.capture && "capture", display.input && "control", display.tree && "tree", display.desktop && "desktop"].filter(Boolean).join(", "),
171
172
  watching: display.viewers?.length ? `${display.viewers.length}${display.viewers.some((viewer) => viewer.control) ? " (controlling)" : ""}` : "—",
172
173
  })), [
173
174
  { key: "id", label: "ID" },
174
175
  { key: "name", label: "Name" },
175
176
  { key: "size", label: "Size" },
177
+ { key: "platform", label: "Platform" },
176
178
  { key: "abilities", label: "Abilities" },
177
179
  { key: "watching", label: "Watching" },
178
180
  ]);
@@ -1617,6 +1617,8 @@ function registerTurns(sessionsCmd) {
1617
1617
  { key: "stopReason", label: "Stop" },
1618
1618
  { key: "errorMessage", label: "Error" },
1619
1619
  ]);
1620
+ if (result.turn.summary?.reason === "billing")
1621
+ console.log("\nStopped: insufficient balance. Manage billing at your Cohub account settings.");
1620
1622
  const origin = readSessionTurnOrigin(result.turn.meta, spaceId);
1621
1623
  if (origin)
1622
1624
  console.log(`\nOrigin (${origin.kind}): space=${origin.spaceId} session=${origin.sessionId} turn=${origin.turnId}${origin.toolCallId ? ` toolCall=${origin.toolCallId}` : ""}`);
@@ -5,6 +5,8 @@ export function sessionStatusText(session) {
5
5
  const issue = session.lastTurnIssue;
6
6
  if (issue?.status === "failed")
7
7
  return "failed";
8
+ if (issue?.reason === "billing")
9
+ return "stopped: insufficient balance";
8
10
  return issue?.reason === "stale_active_recovered" ? "interrupted" : "";
9
11
  }
10
12
  export const SESSION_STATUS_COLUMN = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "10.12.3",
3
+ "version": "10.13.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -18,7 +18,7 @@
18
18
  "NOTICE"
19
19
  ],
20
20
  "dependencies": {
21
- "@neta-art/cohub": "13.1.0",
21
+ "@neta-art/cohub": "13.2.0",
22
22
  "@neta-art/generation": "^0.1.41",
23
23
  "commander": "^15.0.0",
24
24
  "sharp": "^0.35.4",