@neta-art/cohub-cli 8.4.0 → 8.4.1
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/dist/avatar.js +3 -1
- package/dist/board-export.d.ts +4 -8
- package/dist/board-export.js +18 -30
- package/dist/board-fonts.d.ts +7 -0
- package/dist/board-fonts.js +10 -0
- package/dist/board-kernel/browserAll.js +2760 -0
- package/dist/board-kernel/getPo2TextureFromSource.js +13138 -0
- package/dist/board-kernel/init.js +867 -0
- package/dist/board-kernel/webworkerAll.js +3 -0
- package/dist/board-kernel.d.ts +3 -0
- package/dist/board-kernel.js +29154 -0
- package/dist/commands/boards.js +11 -1
- package/dist/commands/desktop.js +5 -3
- package/dist/fonts/geist-latin-400-normal.woff2 +0 -0
- package/dist/fonts/geist-latin-500-normal.woff2 +0 -0
- package/dist/fonts/geist-latin-600-normal.woff2 +0 -0
- package/dist/fonts/geist-latin-700-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-500-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-600-normal.woff2 +0 -0
- package/dist/fonts/geist-mono-latin-700-normal.woff2 +0 -0
- package/dist/self-update.d.ts +1 -0
- package/dist/self-update.js +52 -16
- package/package.json +8 -4
package/dist/commands/boards.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { BOARD_CREATE_INPUT_MAX_BYTES, parseBoardJsonObject, readBoardJsonObject, resolveBoardId, writeBoardOutput, } from "../board-command-support.js";
|
|
3
|
-
import { BOARD_EXPORT_FORMATS, formatFromPath, runBoardExport } from "../board-export.js";
|
|
4
3
|
import { registerBoardDomainCommands } from "./board-domain.js";
|
|
5
4
|
import { createClient, createRealtimeClient } from "../client.js";
|
|
6
5
|
import { error, handleHttp, json as outJson, jsonRequested, ok, table } from "../output.js";
|
|
@@ -127,6 +126,16 @@ function parseExportRegion(options) {
|
|
|
127
126
|
}
|
|
128
127
|
return { kind: "all" };
|
|
129
128
|
}
|
|
129
|
+
const BOARD_EXPORT_FORMATS = ["png", "jpeg", "webp"];
|
|
130
|
+
/** Infer the output format from the file extension, defaulting to PNG. */
|
|
131
|
+
function formatFromPath(path) {
|
|
132
|
+
const lower = path.toLowerCase();
|
|
133
|
+
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg"))
|
|
134
|
+
return "jpeg";
|
|
135
|
+
if (lower.endsWith(".webp"))
|
|
136
|
+
return "webp";
|
|
137
|
+
return "png";
|
|
138
|
+
}
|
|
130
139
|
function parseExportFormat(options, outPath) {
|
|
131
140
|
if (!options.format)
|
|
132
141
|
return formatFromPath(outPath);
|
|
@@ -170,6 +179,7 @@ function registerExportCommand(boards) {
|
|
|
170
179
|
const out = options.out;
|
|
171
180
|
if (!out)
|
|
172
181
|
throw new Error("--out is required");
|
|
182
|
+
const { runBoardExport } = await import("../board-export.js");
|
|
173
183
|
const result = await runBoardExport({
|
|
174
184
|
spaceId: await resolveSpace(boards),
|
|
175
185
|
target: board,
|
package/dist/commands/desktop.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import { HttpError, parseAppRef, resolveOpenSurface, DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS, DESKTOP_COMMAND_MAX_TIMEOUT_MS, } from "@neta-art/cohub";
|
|
2
|
+
import { HttpError, parseAppRef, resolveOpenSurface, DESKTOP_COMMAND_ACCEPT_TIMEOUT_MS, DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS, DESKTOP_COMMAND_MAX_TIMEOUT_MS, DESKTOP_COMMAND_OPEN_TIMEOUT_MS, } from "@neta-art/cohub";
|
|
3
3
|
import { createClient } from "../client.js";
|
|
4
4
|
import { error, handleHttp, json as outJson, jsonRequested, ok } from "../output.js";
|
|
5
5
|
import { resolveBoundSpace } from "../space.js";
|
|
@@ -66,7 +66,7 @@ function readCallInput(opts) {
|
|
|
66
66
|
}
|
|
67
67
|
function parseTimeout(value) {
|
|
68
68
|
if (!value)
|
|
69
|
-
return
|
|
69
|
+
return undefined;
|
|
70
70
|
const parsed = Math.floor(Number(value));
|
|
71
71
|
if (!Number.isFinite(parsed) || parsed <= 0 || parsed > DESKTOP_COMMAND_MAX_TIMEOUT_MS) {
|
|
72
72
|
return error("Invalid timeout", `--timeout-ms must be between 1 and ${DESKTOP_COMMAND_MAX_TIMEOUT_MS} milliseconds.`);
|
|
@@ -200,6 +200,8 @@ Notes:
|
|
|
200
200
|
scheme is still accepted.
|
|
201
201
|
- A plain target checks the explicit Space or current directory Runtime binding for a file before resolving an app; it does not fall back to Home.
|
|
202
202
|
- Opening a window is idempotent; repeating it re-activates the same tab.
|
|
203
|
+
- A desktop that does not respond within ${DESKTOP_COMMAND_ACCEPT_TIMEOUT_MS / 1_000} seconds (closed, asleep, or
|
|
204
|
+
offline) fails fast with no_active_client instead of waiting out the timeout.
|
|
203
205
|
- --as picks the surface: window (a preview tab) or overlay (a transparent
|
|
204
206
|
layer above the workspace). Without it, an App published with
|
|
205
207
|
<meta name="cohub:surface" content="overlay"> opens as an overlay.
|
|
@@ -217,7 +219,7 @@ function registerOpen(parent, deprecated) {
|
|
|
217
219
|
.option("--command-id <id>", "Stable id so retries never dispatch twice")
|
|
218
220
|
.option("--no-wait", "Dispatch the command and exit without waiting for a result")
|
|
219
221
|
.option("--as <surface>", "Surface role for app targets: window (default) or overlay")
|
|
220
|
-
.option("--timeout-ms <ms>", `How long to wait for the desktop (default: ${DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS}; max: ${DESKTOP_COMMAND_MAX_TIMEOUT_MS})`)
|
|
222
|
+
.option("--timeout-ms <ms>", `How long to wait for the desktop (default: ${DESKTOP_COMMAND_OPEN_TIMEOUT_MS}, or ${DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS} with --call; max: ${DESKTOP_COMMAND_MAX_TIMEOUT_MS})`)
|
|
221
223
|
.option("--json", "Output as JSON")
|
|
222
224
|
.action(async (target, opts, thisCommand) => {
|
|
223
225
|
if (deprecated) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/self-update.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const SELF_UPDATE_WORKER_ENV = "COHUB_CLI_SELF_UPDATE_WORKER";
|
|
2
2
|
export type CliSelfUpdateResult = "current" | "updated" | "updated-by-peer";
|
|
3
|
+
export declare function isNewerVersion(candidate: string, installed: string | undefined): boolean;
|
|
3
4
|
export declare function resolveSelfUpdateResult(beforeVersion: string | undefined, afterVersion: string | undefined, updatedByPeer: boolean): CliSelfUpdateResult;
|
|
4
5
|
export declare const isCliSelfUpdateDue: () => boolean;
|
|
5
6
|
export declare function startCliSelfUpdate(entrypoint: string): void;
|
package/dist/self-update.js
CHANGED
|
@@ -38,9 +38,9 @@ const readState = () => {
|
|
|
38
38
|
return {};
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
const writeState = () => {
|
|
41
|
+
const writeState = (state) => {
|
|
42
42
|
mkdirSync(dirname(STATE_PATH), { recursive: true });
|
|
43
|
-
writeFileSync(STATE_PATH, `${JSON.stringify({
|
|
43
|
+
writeFileSync(STATE_PATH, `${JSON.stringify({ checkedAt: new Date().toISOString(), ...state }, null, 2)}\n`);
|
|
44
44
|
};
|
|
45
45
|
const readInstalledVersion = () => {
|
|
46
46
|
try {
|
|
@@ -51,19 +51,35 @@ const readInstalledVersion = () => {
|
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
+
const parseVersion = (value) => {
|
|
55
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(value.trim());
|
|
56
|
+
if (!match)
|
|
57
|
+
return null;
|
|
58
|
+
const core = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
59
|
+
return { core, prerelease: Boolean(match[4]) };
|
|
60
|
+
};
|
|
61
|
+
export function isNewerVersion(candidate, installed) {
|
|
62
|
+
const next = parseVersion(candidate);
|
|
63
|
+
if (!next)
|
|
64
|
+
return false;
|
|
65
|
+
const current = installed === undefined ? null : parseVersion(installed);
|
|
66
|
+
if (!current)
|
|
67
|
+
return true;
|
|
68
|
+
const [major, minor, patch] = next.core;
|
|
69
|
+
const [installedMajor, installedMinor, installedPatch] = current.core;
|
|
70
|
+
const delta = major - installedMajor || minor - installedMinor || patch - installedPatch;
|
|
71
|
+
return delta === 0 ? current.prerelease && !next.prerelease : delta > 0;
|
|
72
|
+
}
|
|
54
73
|
export function resolveSelfUpdateResult(beforeVersion, afterVersion, updatedByPeer) {
|
|
55
74
|
if (beforeVersion !== undefined && beforeVersion === afterVersion)
|
|
56
75
|
return "current";
|
|
57
76
|
return updatedByPeer ? "updated-by-peer" : "updated";
|
|
58
77
|
}
|
|
59
78
|
export const isCliSelfUpdateDue = () => {
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
79
|
+
const checkedAt = Date.parse(readState().checkedAt ?? "");
|
|
80
|
+
if (!Number.isFinite(checkedAt))
|
|
62
81
|
return true;
|
|
63
|
-
|
|
64
|
-
if (!Number.isFinite(lastUpdatedAt))
|
|
65
|
-
return true;
|
|
66
|
-
return Date.now() - lastUpdatedAt >= getIntervalMs();
|
|
82
|
+
return Date.now() - checkedAt >= getIntervalMs();
|
|
67
83
|
};
|
|
68
84
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
69
85
|
const acquireLock = async (timeoutMs) => {
|
|
@@ -96,9 +112,9 @@ const acquireLock = async (timeoutMs) => {
|
|
|
96
112
|
const releaseLock = () => {
|
|
97
113
|
rmSync(LOCK_PATH, { recursive: true, force: true });
|
|
98
114
|
};
|
|
99
|
-
const
|
|
115
|
+
const runNpm = (args, timeoutMs) => {
|
|
100
116
|
return new Promise((resolve, reject) => {
|
|
101
|
-
const child = spawn("npm",
|
|
117
|
+
const child = spawn("npm", args, {
|
|
102
118
|
stdio: ["ignore", "pipe", "pipe"],
|
|
103
119
|
env: process.env,
|
|
104
120
|
});
|
|
@@ -117,14 +133,14 @@ const runNpmUpdate = (timeoutMs) => {
|
|
|
117
133
|
});
|
|
118
134
|
child.on("close", (code, signal) => {
|
|
119
135
|
clearTimeout(timer);
|
|
136
|
+
const stdout = Buffer.concat(stdoutChunks).toString().trim();
|
|
120
137
|
if (code === 0) {
|
|
121
|
-
resolve();
|
|
138
|
+
resolve(stdout);
|
|
122
139
|
return;
|
|
123
140
|
}
|
|
124
|
-
const stdout = Buffer.concat(stdoutChunks).toString().trim();
|
|
125
141
|
const stderr = Buffer.concat(stderrChunks).toString().trim();
|
|
126
142
|
const detail = [stderr, stdout].filter(Boolean).join("\n");
|
|
127
|
-
reject(new Error(`npm
|
|
143
|
+
reject(new Error(`npm ${args.join(" ")} failed${signal ? ` (${signal})` : code !== null ? ` (exit ${code})` : ""}${detail ? `:\n${detail}` : ""}`));
|
|
128
144
|
});
|
|
129
145
|
});
|
|
130
146
|
};
|
|
@@ -156,9 +172,29 @@ export async function ensureCliSelfUpdated() {
|
|
|
156
172
|
if (!isCliSelfUpdateDue()) {
|
|
157
173
|
return resolveSelfUpdateResult(beforeVersion, readInstalledVersion(), true);
|
|
158
174
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
175
|
+
// Reinstalling briefly removes the `cohub` bin, so only do it for a newer release.
|
|
176
|
+
let latestVersion;
|
|
177
|
+
try {
|
|
178
|
+
latestVersion = await runNpm(["view", `${PACKAGE_NAME}@latest`, "version"], timeoutMs);
|
|
179
|
+
if (!isNewerVersion(latestVersion, beforeVersion)) {
|
|
180
|
+
writeState({ installedVersion: beforeVersion, latestVersion, result: "current" });
|
|
181
|
+
return "current";
|
|
182
|
+
}
|
|
183
|
+
await runNpm(["install", "-g", `${PACKAGE_NAME}@${latestVersion}`, "--silent"], timeoutMs);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
writeState({
|
|
187
|
+
installedVersion: beforeVersion,
|
|
188
|
+
latestVersion,
|
|
189
|
+
result: "failed",
|
|
190
|
+
error: (error instanceof Error ? error.message : String(error)).slice(0, 500),
|
|
191
|
+
});
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
const afterVersion = readInstalledVersion();
|
|
195
|
+
const result = resolveSelfUpdateResult(beforeVersion, afterVersion, false);
|
|
196
|
+
writeState({ installedVersion: afterVersion, latestVersion, result });
|
|
197
|
+
return result;
|
|
162
198
|
}
|
|
163
199
|
finally {
|
|
164
200
|
releaseLock();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub-cli",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.1",
|
|
4
4
|
"description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -20,25 +20,29 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@neta-art/generation": "^0.1.30",
|
|
22
22
|
"commander": "^15.0.0",
|
|
23
|
-
"pixi.js": "^8.20.1",
|
|
24
23
|
"sharp": "^0.35.4",
|
|
25
24
|
"ws": "^8.21.3",
|
|
26
|
-
"@neta-art/cohub": "8.
|
|
25
|
+
"@neta-art/cohub": "8.24.0"
|
|
27
26
|
},
|
|
28
27
|
"publishConfig": {
|
|
29
28
|
"access": "public"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
31
|
+
"@fontsource/geist": "^5.3.0",
|
|
32
|
+
"@fontsource/geist-mono": "^5.3.0",
|
|
32
33
|
"@types/node": "^26.4.0",
|
|
33
34
|
"@types/ws": "^8.18.1",
|
|
35
|
+
"pixi.js": "^8.20.1",
|
|
36
|
+
"tsdown": "^0.22.14",
|
|
34
37
|
"typescript": "^7.0.2"
|
|
35
38
|
},
|
|
36
39
|
"optionalDependencies": {
|
|
37
40
|
"@napi-rs/canvas": "^1.0.8"
|
|
38
41
|
},
|
|
39
42
|
"scripts": {
|
|
40
|
-
"build": "tsc -p tsconfig.build.json",
|
|
43
|
+
"build": "tsc -p tsconfig.build.json && tsdown",
|
|
41
44
|
"verify:sandboxd": "node --import tsx scripts/verify-sandboxd-release.ts",
|
|
45
|
+
"verify:board-kernel": "node --import tsx scripts/verify-board-kernel.ts",
|
|
42
46
|
"test": "node ../../scripts/test/run.mjs 'tests/**/*.test.ts'",
|
|
43
47
|
"test:runtime": "node --import tsx --test tests/runtime-*.integration.ts",
|
|
44
48
|
"test:runtime:native": "node --import tsx tests/runtime-native.smoke.ts",
|