@neta-art/cohub-cli 10.17.0 → 10.18.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.
- package/README.md +6 -0
- package/dist/board-export-resources.d.ts +2 -0
- package/dist/board-export-resources.js +1 -0
- package/dist/board-export.d.ts +4 -1
- package/dist/board-export.js +109 -23
- package/dist/board-gpu/index.d.ts +32 -0
- package/dist/board-gpu/index.js +188 -0
- package/dist/board-gpu/page.js +70178 -0
- package/dist/board-gpu/protocol.d.ts +37 -0
- package/dist/board-gpu/protocol.js +1 -0
- package/dist/board-kernel/{getPo2TextureFromSource.js → FilterPipe.js} +251 -1
- package/dist/board-kernel/browserAll.js +1 -1
- package/dist/board-kernel/init.js +1 -251
- package/dist/board-kernel/webworkerAll.js +1 -1
- package/dist/board-kernel.d.ts +3 -3
- package/dist/board-kernel.js +6642 -1466
- package/dist/board-simulate.d.ts +4 -0
- package/dist/board-simulate.js +34 -4
- package/dist/client.d.ts +1 -0
- package/dist/client.js +4 -1
- package/dist/commands/apps.js +25 -3
- package/dist/commands/boards/examples.js +21 -5
- package/dist/commands/boards.js +10 -2
- package/dist/commands/space-displays.js +301 -82
- package/dist/commands/spaces.js +11 -2
- package/dist/host/runtime.d.ts +12 -2
- package/dist/host/runtime.js +155 -10
- package/dist/host/serve.js +49 -11
- package/dist/host/workspaces.d.ts +2 -0
- package/dist/host/workspaces.js +18 -0
- package/dist/index.js +1 -0
- package/dist/runtime/cli-path.d.ts +5 -0
- package/dist/runtime/cli-path.js +27 -0
- package/dist/runtime/connection.d.ts +22 -4
- package/dist/runtime/connection.js +13 -3
- package/dist/runtime/harnesses/claude-approval.d.ts +31 -0
- package/dist/runtime/harnesses/claude-approval.js +119 -0
- package/dist/runtime/harnesses/claude.js +42 -3
- package/dist/runtime/harnesses/codex-approval.d.ts +25 -0
- package/dist/runtime/harnesses/codex-approval.js +69 -0
- package/dist/runtime/harnesses/codex.js +36 -5
- package/dist/runtime/harnesses/index.js +12 -3
- package/dist/runtime/harnesses/stream-json.d.ts +16 -2
- package/dist/runtime/harnesses/stream-json.js +26 -6
- package/dist/runtime/harnesses/types.d.ts +3 -1
- package/dist/runtime/instance.d.ts +1 -0
- package/dist/runtime/instance.js +1 -0
- package/dist/runtime/launch.js +2 -4
- package/dist/runtime/local-workspace.d.ts +15 -0
- package/dist/runtime/local-workspace.js +52 -0
- package/dist/runtime/model-catalog.js +7 -4
- package/dist/runtime/native/approvals.d.ts +18 -0
- package/dist/runtime/native/approvals.js +54 -0
- package/dist/runtime/native/codex-link.d.ts +7 -0
- package/dist/runtime/native/codex-link.js +40 -5
- package/dist/runtime/native/daemon.d.ts +5 -1
- package/dist/runtime/native/daemon.js +6 -1
- package/dist/runtime/native/execution.d.ts +2 -0
- package/dist/runtime/preferences.d.ts +7 -0
- package/dist/runtime/preferences.js +22 -0
- package/dist/runtime/presentation.d.ts +3 -0
- package/dist/runtime/presentation.js +2 -1
- package/dist/runtime/supervisor.js +92 -9
- package/dist/space-files/transfer.js +3 -2
- package/dist/space-files/upload.d.ts +5 -2
- package/dist/space-files/upload.js +41 -1
- package/package.json +3 -3
package/dist/board-simulate.d.ts
CHANGED
package/dist/board-simulate.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { diffMergePatch } from "@neta-art/cohub/board";
|
|
2
|
-
import { loadBoardDocument, readSpaceFileBytes, resolveBundledFonts, runBoardExport } from "./board-export.js";
|
|
3
|
-
import {
|
|
2
|
+
import { gpuResources, loadBoardDocument, readSpaceFileBytes, resolveBundledFonts, runBoardExport } from "./board-export.js";
|
|
3
|
+
import { findBoardGpuBrowser, launchBoardGpuExporter } from "./board-gpu/index.js";
|
|
4
|
+
import { boardScriptAttachments, boardShaderParameters, checkBoardShader, createBoardScriptHarness, createNodeBoardRenderer } from "./board-kernel.js";
|
|
4
5
|
import { settleBoardDocument } from "./board-media.js";
|
|
5
6
|
import { parseBoardTime } from "./board-time.js";
|
|
6
7
|
import { createClient } from "./client.js";
|
|
@@ -99,6 +100,28 @@ async function run(harness, steps) {
|
|
|
99
100
|
await harness.select(step.select);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
async function checkShaders(shaders, spaceId, document) {
|
|
104
|
+
const browser = findBoardGpuBrowser();
|
|
105
|
+
const exporter = browser ? await launchBoardGpuExporter(gpuResources(spaceId, document), { browser }).catch(() => null) : null;
|
|
106
|
+
if (exporter) {
|
|
107
|
+
try {
|
|
108
|
+
return { errors: await exporter.compile(shaders), compiled: true };
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
await exporter.close();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const errors = {};
|
|
115
|
+
for (const { id, shader, parameters } of shaders) {
|
|
116
|
+
try {
|
|
117
|
+
checkBoardShader(shader, boardShaderParameters(parameters), id);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
errors[id] = error instanceof Error ? error.message : String(error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return { errors, compiled: false };
|
|
124
|
+
}
|
|
102
125
|
export async function runBoardSimulation(options) {
|
|
103
126
|
const client = createClient();
|
|
104
127
|
const document = await settleBoardDocument(options.spaceId, (await loadBoardDocument(options.spaceId, options.target)).document);
|
|
@@ -114,16 +137,23 @@ export async function runBoardSimulation(options) {
|
|
|
114
137
|
await harness.flush();
|
|
115
138
|
const shown = options.image ? await harness.shown(options.image.scale) : null;
|
|
116
139
|
const errors = {};
|
|
117
|
-
|
|
118
|
-
|
|
140
|
+
const shaders = [];
|
|
141
|
+
for (const { id } of boardScriptAttachments(harness.document)) {
|
|
142
|
+
const message = harness.error(id);
|
|
143
|
+
const output = harness.output(id);
|
|
119
144
|
if (message)
|
|
120
145
|
errors[id] = message;
|
|
146
|
+
else if (output?.shader)
|
|
147
|
+
shaders.push({ id, shader: output.shader, ...(output.parameters ? { parameters: output.parameters } : {}) });
|
|
121
148
|
}
|
|
149
|
+
const checked = shaders.length ? await checkShaders(shaders, options.spaceId, harness.document) : null;
|
|
150
|
+
Object.assign(errors, checked?.errors);
|
|
122
151
|
const result = {
|
|
123
152
|
time: Math.round(harness.time),
|
|
124
153
|
commits: harness.commits.length,
|
|
125
154
|
changes: diffMergePatch(document, harness.document) ?? {},
|
|
126
155
|
errors,
|
|
156
|
+
...(checked ? { shaders: { count: shaders.length, compiled: checked.compiled } } : {}),
|
|
127
157
|
};
|
|
128
158
|
if (options.image && shown) {
|
|
129
159
|
const exported = await runBoardExport({
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CohubClient, CohubHttpClient } from "@neta-art/cohub";
|
|
2
2
|
export declare function createClient(): CohubHttpClient;
|
|
3
|
+
/** A scoped principal, so its requests stay on the API that enforces the scope. */
|
|
3
4
|
export declare function createClientWithAccessToken(token: string): CohubHttpClient;
|
|
4
5
|
export declare function createRealtimeClient(): CohubClient;
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CohubClient, CohubHttpClient, readRequestSourceFromEnv } from "@neta-art/cohub";
|
|
2
2
|
import { clearAuthSession, readAuthSession, resolveAccessToken } from "./auth.js";
|
|
3
|
+
import { resolveLocalWorkspace } from "./runtime/local-workspace.js";
|
|
3
4
|
const clientOptions = () => ({
|
|
4
5
|
getAccessToken: resolveAccessToken,
|
|
6
|
+
localWorkspace: resolveLocalWorkspace,
|
|
5
7
|
onUnauthorized: (context) => {
|
|
6
8
|
if (!process.env.COHUB_EXECUTION_TOKEN?.trim() && context.matchesRejectedToken(readAuthSession()?.accessToken ?? null))
|
|
7
9
|
clearAuthSession();
|
|
@@ -13,8 +15,9 @@ const clientOptions = () => ({
|
|
|
13
15
|
export function createClient() {
|
|
14
16
|
return new CohubHttpClient(clientOptions());
|
|
15
17
|
}
|
|
18
|
+
/** A scoped principal, so its requests stay on the API that enforces the scope. */
|
|
16
19
|
export function createClientWithAccessToken(token) {
|
|
17
|
-
return new CohubHttpClient({ ...clientOptions(), getAccessToken: () => token });
|
|
20
|
+
return new CohubHttpClient({ ...clientOptions(), getAccessToken: () => token, localWorkspace: undefined });
|
|
18
21
|
}
|
|
19
22
|
export function createRealtimeClient() {
|
|
20
23
|
return new CohubClient(clientOptions());
|
package/dist/commands/apps.js
CHANGED
|
@@ -191,10 +191,11 @@ function printApp(app) {
|
|
|
191
191
|
{ key: "publishedAt", label: "Published" },
|
|
192
192
|
]);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function printAppDetails(result) {
|
|
195
195
|
const lines = [
|
|
196
196
|
result.publicUrl ? `Public URL: ${result.publicUrl}` : null,
|
|
197
197
|
result.content?.url ? `Content URL: ${result.content.url}` : null,
|
|
198
|
+
typeof result.likeCount === "number" ? `Likes: ${result.likeCount}` : null,
|
|
198
199
|
].filter((line) => Boolean(line));
|
|
199
200
|
if (lines.length)
|
|
200
201
|
console.log(`\n${lines.join("\n")}`);
|
|
@@ -214,6 +215,7 @@ function printAppStats(stats) {
|
|
|
214
215
|
{ key: "views24h", label: "24h" },
|
|
215
216
|
{ key: "views7d", label: "7d" },
|
|
216
217
|
{ key: "views30d", label: "30d" },
|
|
218
|
+
...(stats.summary.totalLikes === undefined ? [] : [{ key: "totalLikes", label: "Likes" }]),
|
|
217
219
|
]);
|
|
218
220
|
if (stats.sources.length) {
|
|
219
221
|
console.log("");
|
|
@@ -308,7 +310,7 @@ export function registerApps(program) {
|
|
|
308
310
|
if (jsonRequested(opts))
|
|
309
311
|
return outJson(result);
|
|
310
312
|
printApp(result.app);
|
|
311
|
-
|
|
313
|
+
printAppDetails(result);
|
|
312
314
|
}
|
|
313
315
|
catch (e) {
|
|
314
316
|
handleHttp(e);
|
|
@@ -330,6 +332,26 @@ export function registerApps(program) {
|
|
|
330
332
|
handleHttp(e);
|
|
331
333
|
}
|
|
332
334
|
});
|
|
335
|
+
for (const liked of [true, false]) {
|
|
336
|
+
appsCmd
|
|
337
|
+
.command(`${liked ? "like" : "unlike"} <app>`)
|
|
338
|
+
.description(`${liked ? "Like" : "Unlike"} an app by id, URL, mention URI, or username/space/app`)
|
|
339
|
+
.option("--json", "Output as JSON")
|
|
340
|
+
.action(async (app, opts) => {
|
|
341
|
+
const client = createClient();
|
|
342
|
+
try {
|
|
343
|
+
const ref = parseAppRef(app);
|
|
344
|
+
const appId = "id" in ref ? ref.id : (await getAppByRef(client, app)).app.id;
|
|
345
|
+
const result = { appId, liked: await client.user.likes.set("app", appId, liked) };
|
|
346
|
+
if (jsonRequested(opts))
|
|
347
|
+
return outJson(result);
|
|
348
|
+
ok(result.liked ? "Liked" : "Unliked");
|
|
349
|
+
}
|
|
350
|
+
catch (e) {
|
|
351
|
+
handleHttp(e);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
333
355
|
appsCmd
|
|
334
356
|
.command("download <app>")
|
|
335
357
|
.description("Download a published file or directory app")
|
|
@@ -391,7 +413,7 @@ export function registerApps(program) {
|
|
|
391
413
|
if (jsonRequested(opts))
|
|
392
414
|
return outJson(result);
|
|
393
415
|
printApp(result.app);
|
|
394
|
-
|
|
416
|
+
printAppDetails(result);
|
|
395
417
|
}
|
|
396
418
|
catch (e) {
|
|
397
419
|
handleHttp(e);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { json } from "../../output.js";
|
|
2
|
-
import { BOARD_SCRIPT_DRAWING_EXAMPLE } from "../../board-kernel.js";
|
|
2
|
+
import { BOARD_SCRIPT_DRAWING_EXAMPLE, BOARD_SCRIPT_RAIN_EXAMPLE } from "../../board-kernel.js";
|
|
3
|
+
const MODULES = {
|
|
4
|
+
custom: BOARD_SCRIPT_DRAWING_EXAMPLE,
|
|
5
|
+
rain: BOARD_SCRIPT_RAIN_EXAMPLE,
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Starter documents for `boards create -i` and patches for `boards apply -i`.
|
|
5
9
|
* Every example is a valid Board patch; `boards.test.ts` checks that.
|
|
@@ -73,20 +77,32 @@ export const BOARD_EXAMPLES = {
|
|
|
73
77
|
},
|
|
74
78
|
},
|
|
75
79
|
},
|
|
80
|
+
rain: {
|
|
81
|
+
description: "A Board script whose shader rains over the view and splashes on cards; use --module to print scripts/rain.js.",
|
|
82
|
+
value: {
|
|
83
|
+
board: { scripts: { rain: { src: "scripts/rain.js", params: { density: 0.7 } } } },
|
|
84
|
+
items: {
|
|
85
|
+
title: { type: "text", position: { x: 80, y: 40 }, props: { text: "Rainy day", fontSize: 48 } },
|
|
86
|
+
left: { type: "shape", position: { x: 80, y: 180 }, size: { width: 320, height: 180 }, style: { fill: "blue", fillOpacity: 0.16, radius: 16 }, props: { text: "Drops land on top" } },
|
|
87
|
+
right: { type: "shape", position: { x: 480, y: 300 }, size: { width: 280, height: 160 }, rotation: -6, style: { fill: "green", fillOpacity: 0.16, radius: 16 }, props: { text: "and bounce off edges" } },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
76
91
|
};
|
|
77
92
|
export function registerBoardExampleCommands(boards) {
|
|
78
93
|
boards.command("examples [name]")
|
|
79
94
|
.description("Print a starter Board document or list the examples")
|
|
80
|
-
.option("--module",
|
|
95
|
+
.option("--module", `Print the example's JavaScript module (${Object.keys(MODULES).join(", ")})`)
|
|
81
96
|
.addHelpText("after", `
|
|
82
97
|
Examples are valid input for create and apply:
|
|
83
98
|
cohub boards examples lesson > lesson.json
|
|
84
99
|
cohub boards create lesson.board -i lesson.json`)
|
|
85
100
|
.action((name, options) => {
|
|
86
101
|
if (options.module) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
const module = name ? MODULES[name] : undefined;
|
|
103
|
+
if (!module)
|
|
104
|
+
throw new Error(`--module needs one of these examples: ${Object.keys(MODULES).join(", ")}.`);
|
|
105
|
+
process.stdout.write(module);
|
|
90
106
|
return;
|
|
91
107
|
}
|
|
92
108
|
if (!name) {
|
package/dist/commands/boards.js
CHANGED
|
@@ -4,7 +4,7 @@ import { mkdir } from "node:fs/promises";
|
|
|
4
4
|
import { dirname } from "node:path";
|
|
5
5
|
import { BOARD_PRESET_NAMES, BOARD_SCHEMA_TARGETS, BOARD_SCRIPT_API, BOARD_THEME_IDS, boardJsonSchema, boardPresetTracks, boardSchemaOverview, isBoardPresetName, listBoardPresets, } from "@neta-art/cohub/board";
|
|
6
6
|
import { BOARD_CREATE_INPUT_MAX_BYTES, BOARD_TRANSACTION_INPUT_MAX_BYTES, parseBoardJsonObject, readBoardJsonObject, writeBoardOutput, } from "../board-command-support.js";
|
|
7
|
-
import { BOARD_EXPORT_IMAGE_MEMORY_MIB } from "../board-export-resources.js";
|
|
7
|
+
import { BOARD_EXPORT_IMAGE_MEMORY_MIB, BOARD_EXPORT_RENDERERS } from "../board-export-resources.js";
|
|
8
8
|
import { settleBoardPatch } from "../board-media.js";
|
|
9
9
|
import { formatBoardTime, parseBoardTime, parseBoardTimes } from "../board-time.js";
|
|
10
10
|
import { createClient, createRealtimeClient } from "../client.js";
|
|
@@ -166,6 +166,7 @@ function registerExportCommand(boards) {
|
|
|
166
166
|
.option("--fps <rate>", "Video frame rate; defaults to the --at step")
|
|
167
167
|
.option("--image-memory <mib>", "Decoded image memory budget in MiB", String(BOARD_EXPORT_IMAGE_MEMORY_MIB))
|
|
168
168
|
.option("--no-images", "Draw placeholders instead of downloading images")
|
|
169
|
+
.option("--renderer <renderer>", "auto draws in Node and uses local Chrome for shaders; canvas or gpu forces one", "auto")
|
|
169
170
|
.option("--force", "Replace existing output files"))
|
|
170
171
|
.addHelpText("after", `
|
|
171
172
|
Examples:
|
|
@@ -238,6 +239,7 @@ Examples:
|
|
|
238
239
|
output: out,
|
|
239
240
|
quality: parseNumber(options.quality ?? "0.92", "--quality", { min: 0, max: 1 }),
|
|
240
241
|
withImages: options.images !== false,
|
|
242
|
+
renderer: parseChoice(options.renderer, "--renderer", BOARD_EXPORT_RENDERERS),
|
|
241
243
|
});
|
|
242
244
|
if (jsonRequested(options))
|
|
243
245
|
return outJson({ file: out, ...result });
|
|
@@ -277,6 +279,7 @@ Examples:
|
|
|
277
279
|
format: parseExportFormat(options, out),
|
|
278
280
|
quality: parseNumber(options.quality ?? "0.92", "--quality", { min: 0, max: 1 }),
|
|
279
281
|
withImages: options.images !== false,
|
|
282
|
+
renderer: parseChoice(options.renderer, "--renderer", BOARD_EXPORT_RENDERERS),
|
|
280
283
|
});
|
|
281
284
|
if (!result)
|
|
282
285
|
return error("Nothing to export: the region contains no items.");
|
|
@@ -316,6 +319,9 @@ Steps are {"steps": [...]}, points in board coordinates, run on a virtual clock:
|
|
|
316
319
|
{"wait": "500ms"} {"tool": "draw"} {"tap": [x, y]} {"drag": [[x, y], ...], "pointerType": "pen"}
|
|
317
320
|
{"pointer": "down", "at": [x, y]} {"key": "Enter"} {"select": ["id"]}
|
|
318
321
|
|
|
322
|
+
Shaders are compiled with a local Chrome, Chromium or Edge when one is found, and
|
|
323
|
+
their errors join the scripts' errors.
|
|
324
|
+
|
|
319
325
|
Examples:
|
|
320
326
|
cohub boards simulate farm.board '{"steps":[{"wait":"2s"}]}' -o farm.png
|
|
321
327
|
cohub boards simulate farm.board -i steps.json --json`)
|
|
@@ -355,6 +361,8 @@ Examples:
|
|
|
355
361
|
ok(`Simulated ${formatBoardTime(result.time)}: ${result.commits} commit${result.commits === 1 ? "" : "s"}, ${changed} item${changed === 1 ? "" : "s"} changed (not saved)`);
|
|
356
362
|
for (const [id, message] of Object.entries(result.errors))
|
|
357
363
|
console.log(` ! ${id}: ${message.split("\n")[0]}`);
|
|
364
|
+
if (result.shaders && !result.shaders.compiled)
|
|
365
|
+
console.log(" Shaders were checked but not compiled; install Chrome, Chromium or Edge, or set COHUB_CHROME, to compile them.");
|
|
358
366
|
if (out && image)
|
|
359
367
|
console.log(` Rendered ${image.width}×${image.height} to ${out}`);
|
|
360
368
|
else if (out)
|
|
@@ -474,7 +482,7 @@ Times are milliseconds; 500ms, 12.5s and 2m also work on the command line.`);
|
|
|
474
482
|
.description("Merge a patch into the Board: fields merge, null deletes")
|
|
475
483
|
.option("-i, --input <file>", "Patch JSON; - for stdin")
|
|
476
484
|
.option("--replace", "Make the document equal to the input instead of merging")
|
|
477
|
-
.option("--cascade", "Also delete children and tracks of deleted items")
|
|
485
|
+
.option("--cascade", "Also delete children and tracks of deleted items, and tracks of deleted Board scripts")
|
|
478
486
|
.option("--dry-run", "Validate without writing")
|
|
479
487
|
.option("--base-version <n>", "Fail if the Board moved past this version")
|
|
480
488
|
.option("--mutation-id <id>", "Stable id; retries never apply twice"))
|