@nodetool-ai/cli 0.8.5 → 0.8.7
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/.nodetool-build-stamp +1 -1
- package/dist/commands/deploy-helpers.d.ts.map +1 -1
- package/dist/commands/deploy-helpers.js +5 -1
- package/dist/commands/deploy-helpers.js.map +1 -1
- package/dist/commands/game-benchmark.d.ts +12 -2
- package/dist/commands/game-benchmark.d.ts.map +1 -1
- package/dist/commands/game-benchmark.js +11 -6
- package/dist/commands/game-benchmark.js.map +1 -1
- package/dist/commands/game.d.ts.map +1 -1
- package/dist/commands/game.js +163 -20
- package/dist/commands/game.js.map +1 -1
- package/dist/commands/sketch-render.d.ts +46 -0
- package/dist/commands/sketch-render.d.ts.map +1 -0
- package/dist/commands/sketch-render.js +131 -0
- package/dist/commands/sketch-render.js.map +1 -0
- package/dist/commands/sketch.d.ts +4 -3
- package/dist/commands/sketch.d.ts.map +1 -1
- package/dist/commands/sketch.js +2 -0
- package/dist/commands/sketch.js.map +1 -1
- package/dist/harness/capability-table.d.ts.map +1 -1
- package/dist/harness/capability-table.js +21 -10
- package/dist/harness/capability-table.js.map +1 -1
- package/dist/harness/registry.d.ts.map +1 -1
- package/dist/harness/registry.js +54 -2
- package/dist/harness/registry.js.map +1 -1
- package/package.json +31 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
2026-10-
|
|
1
|
+
2026-10-23T10:52:15.609Z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-helpers.d.ts","sourceRoot":"","sources":["../../src/commands/deploy-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"deploy-helpers.d.ts","sourceRoot":"","sources":["../../src/commands/deploy-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,cAAc,EAKd,KAAK,aAA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AAmB,CACjC,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,GACX,aAAa,CAgBf;AAMD,wEAAwE;AACxE,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,oEAAoE;AACpE,wBAAgB,cAAc,IAAI,kBAAkB,CAiBnD;AAMD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,2BAgB9C;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkBlD;AAGD,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* prompt utilities, output formatters, and stubs used by `deploy add`.
|
|
6
6
|
*/
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { isIP } from "node:net";
|
|
8
9
|
import { AdminHTTPClient, APIUserManager, DeploymentManager, StateManager, WorkflowSyncer, dockerDeploymentGetServerUrl, loadDeploymentConfig, DockerDeployer, DockerDeploymentSchema } from "@nodetool-ai/deploy";
|
|
9
10
|
import { Workflow } from "@nodetool-ai/models";
|
|
10
11
|
// Pure output + prompt helpers live in ./output.js so lightweight command
|
|
@@ -83,7 +84,10 @@ export function isSafeTokenUrl(url, env = process.env) {
|
|
|
83
84
|
if (env["NODETOOL_ALLOW_INSECURE_HTTP"] === "1")
|
|
84
85
|
return true;
|
|
85
86
|
const host = parsed.hostname.replace(/^\[|\]$/g, "");
|
|
86
|
-
|
|
87
|
+
// `isIP`, not just the prefix: `127.example.com` is a DNS name.
|
|
88
|
+
return (host === "localhost" ||
|
|
89
|
+
host === "::1" ||
|
|
90
|
+
(isIP(host) === 4 && host.startsWith("127.")));
|
|
87
91
|
}
|
|
88
92
|
function requireServerUrl(deployment, name) {
|
|
89
93
|
const url = resolveServerUrl(deployment);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-helpers.js","sourceRoot":"","sources":["../../src/commands/deploy-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GA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AAI,CACL,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAED,gEAAgE;AAChE,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type GameSession3DOptions } from "@nodetool-ai/game-runtime";
|
|
2
|
+
import type { AnyGameDocument, GameInputFrame3D } from "@nodetool-ai/protocol";
|
|
3
|
+
import type { GameInputFrame } from "@nodetool-ai/protocol/game.js";
|
|
2
4
|
export interface GameBenchmarkPercentiles {
|
|
3
5
|
readonly p50: number;
|
|
4
6
|
readonly p95: number;
|
|
@@ -10,6 +12,8 @@ export interface GameBenchmarkReport {
|
|
|
10
12
|
readonly seed: number;
|
|
11
13
|
readonly ticks: number;
|
|
12
14
|
readonly warmupTicks: number;
|
|
15
|
+
/** Ticks driven by the recorded route. Later ticks receive empty input. */
|
|
16
|
+
readonly inputTicks: number;
|
|
13
17
|
readonly tickMs: GameBenchmarkPercentiles;
|
|
14
18
|
readonly scriptMs: GameBenchmarkPercentiles;
|
|
15
19
|
readonly scriptCalls: number;
|
|
@@ -33,6 +37,12 @@ export interface GameBenchmarkReport {
|
|
|
33
37
|
readonly node: string;
|
|
34
38
|
};
|
|
35
39
|
}
|
|
40
|
+
export interface GameBenchmarkOptions {
|
|
41
|
+
/** Tick-indexed input frames from tick 0, which includes the warmup. A route measures play instead of an idle game. */
|
|
42
|
+
readonly inputs?: readonly (GameInputFrame | GameInputFrame3D)[];
|
|
43
|
+
/** Loads the prepared collider assets of a 3D game. */
|
|
44
|
+
readonly resolveCollider?: GameSession3DOptions["resolveCollider"];
|
|
45
|
+
}
|
|
36
46
|
/** Measure the fixed simulation tick, including rendering-frame construction. */
|
|
37
|
-
export declare function benchmarkNativeGame(document: AnyGameDocument, ticks?: number, warmupTicks?: number, seed?: number): Promise<GameBenchmarkReport>;
|
|
47
|
+
export declare function benchmarkNativeGame(document: AnyGameDocument, ticks?: number, warmupTicks?: number, seed?: number, options?: GameBenchmarkOptions): Promise<GameBenchmarkReport>;
|
|
38
48
|
//# sourceMappingURL=game-benchmark.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-benchmark.d.ts","sourceRoot":"","sources":["../../src/commands/game-benchmark.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"game-benchmark.d.ts","sourceRoot":"","sources":["../../src/commands/game-benchmark.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmE,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACvI,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,wBAAwB,CAK7F;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;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Measure the fixed simulation tick, including rendering-frame construction. */
|
|
14
|
-
export async function benchmarkNativeGame(document, ticks = 1200, warmupTicks = 300, seed = 1) {
|
|
14
|
+
export async function benchmarkNativeGame(document, ticks = 1200, warmupTicks = 300, seed = 1, options = {}) {
|
|
15
15
|
if (![ticks, warmupTicks, seed].every(Number.isSafeInteger) || ticks < 1 || ticks > 100_000 || warmupTicks < 0 || warmupTicks > 100_000 || seed < 0 || seed > 0xffffffff) {
|
|
16
16
|
throw new Error("Invalid benchmark tick count, warmup or seed");
|
|
17
17
|
}
|
|
@@ -20,16 +20,20 @@ export async function benchmarkNativeGame(document, ticks = 1200, warmupTicks =
|
|
|
20
20
|
throw new Error(validation.diagnostics.map((issue) => issue.message).join(", "));
|
|
21
21
|
}
|
|
22
22
|
const session = document.schemaVersion === 3
|
|
23
|
-
? await createGameSession3D(document, seed, undefined, { recordTimings: true })
|
|
23
|
+
? await createGameSession3D(document, seed, undefined, { recordTimings: true, resolveCollider: options.resolveCollider })
|
|
24
24
|
: await createScriptedGameSession(document, seed, undefined, undefined, { recordTimings: true });
|
|
25
|
-
const
|
|
25
|
+
const idle = { pressed: [], justPressed: [], axes: {}, look: { x: 0, y: 0 } };
|
|
26
|
+
const inputs = options.inputs ?? [];
|
|
27
|
+
let tick = 0;
|
|
28
|
+
// The caller parses the route with the schema of the document's dimension, so each frame suits this session.
|
|
29
|
+
const nextInput = () => (inputs[tick++] ?? idle);
|
|
26
30
|
const profiler = new Session();
|
|
27
31
|
const samplingIntervalBytes = 32768;
|
|
28
32
|
let connected = false;
|
|
29
33
|
let sampling = false;
|
|
30
34
|
try {
|
|
31
35
|
for (let index = 0; index < warmupTicks; index++) {
|
|
32
|
-
session.step(
|
|
36
|
+
session.step(nextInput());
|
|
33
37
|
}
|
|
34
38
|
const heapBefore = process.memoryUsage().heapUsed;
|
|
35
39
|
const tickSamples = [];
|
|
@@ -39,6 +43,7 @@ export async function benchmarkNativeGame(document, ticks = 1200, warmupTicks =
|
|
|
39
43
|
const contactSamples = [];
|
|
40
44
|
let scriptCalls = 0;
|
|
41
45
|
for (let index = 0; index < ticks; index++) {
|
|
46
|
+
const input = nextInput();
|
|
42
47
|
const start = performance.now();
|
|
43
48
|
const result = session.step(input);
|
|
44
49
|
tickSamples.push(performance.now() - start);
|
|
@@ -70,7 +75,7 @@ export async function benchmarkNativeGame(document, ticks = 1200, warmupTicks =
|
|
|
70
75
|
sampling = true;
|
|
71
76
|
const allocationTicks = Math.min(ticks, 10);
|
|
72
77
|
for (let index = 0; index < allocationTicks; index++) {
|
|
73
|
-
session.step(
|
|
78
|
+
session.step(nextInput());
|
|
74
79
|
}
|
|
75
80
|
const { profile } = await profiler.post("HeapProfiler.stopSampling");
|
|
76
81
|
sampling = false;
|
|
@@ -80,7 +85,7 @@ export async function benchmarkNativeGame(document, ticks = 1200, warmupTicks =
|
|
|
80
85
|
sampledBytes += nodes[index].selfSize;
|
|
81
86
|
nodes.push(...nodes[index].children);
|
|
82
87
|
}
|
|
83
|
-
return { documentId: document.id, seed, ticks, warmupTicks, tickMs: gameBenchmarkPercentiles(tickSamples), scriptMs: gameBenchmarkPercentiles(scriptSamples), scriptCalls,
|
|
88
|
+
return { documentId: document.id, seed, ticks, warmupTicks, inputTicks: Math.min(inputs.length, warmupTicks + ticks), tickMs: gameBenchmarkPercentiles(tickSamples), scriptMs: gameBenchmarkPercentiles(scriptSamples), scriptCalls,
|
|
84
89
|
perSystemMs: Object.fromEntries([...systemSamples].map(([name, samples]) => [name, gameBenchmarkPercentiles(samples)])), perSystemUnavailableReason: null, heapDeltaBytes,
|
|
85
90
|
physicsCounts: { bodies: gameBenchmarkPercentiles(bodySamples), contacts: gameBenchmarkPercentiles(contactSamples) },
|
|
86
91
|
allocations: { sampledBytes, ticks: allocationTicks, samplingIntervalBytes, method: "V8 sampling heap profiler with collected allocations included. Statistical byte estimate, excludes WASM allocations" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-benchmark.js","sourceRoot":"","sources":["../../src/commands/game-benchmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"game-benchmark.js","sourceRoot":"","sources":["../../src/commands/game-benchmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,eAAe,EAA6B,MAAM,2BAA2B,CAAC;AAUvI,MAAM,UAAU,wBAAwB,CAAC,OAA0B;IACjE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAAC,CAAC;IAC7K,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACjG,OAAO,EAAE,GAAG,EAAE,UAA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AAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,0BAA0B,EAAE,IAAI,EAAE,cAAc;YACzK,aAAa,EAAE,EAAE,MAAM,EAAE,wBAAwB,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,wBAAwB,CAAC,cAAc,CAAC,EAAE;YACpH,WAAW,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,EAAE,qHAAqH,EAAE;YAC3M,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;IACzH,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,IAAI,QAAQ,EAAE,CAAC;gBAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAAC,CAAC;QACrE,CAAC;gBAAS,CAAC;YACT,IAAI,SAAS,EAAE,CAAC;gBAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YAAC,CAAC;YACzC,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/commands/game.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/commands/game.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuTzC,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2W3D"}
|
package/dist/commands/game.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { importPack } from "@nodetool-ai/node-catalog";
|
|
2
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
2
|
+
import { mkdtemp, readFile, realpath, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { extname, join, resolve, sep } from "node:path";
|
|
4
5
|
import { isDeepStrictEqual } from "node:util";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
import { gameEvent, gameInputFrame } from "@nodetool-ai/protocol/game.js";
|
|
7
|
-
import { gameEvent3D, gameInputFrame3D } from "@nodetool-ai/protocol";
|
|
8
|
+
import { gameEvent3D, gameInputFrame3D, parsePackageAssetUri } from "@nodetool-ai/protocol";
|
|
8
9
|
import { createMemoryGameSaveStorage, createScriptedGameSession, createGameSession3D, decodePreparedGameCollider3D, GamePlayerSaves, hashGameSnapshot3D, validateGame, validateAnyGame } from "@nodetool-ai/game-runtime";
|
|
9
10
|
import { benchmarkNativeGame } from "./game-benchmark.js";
|
|
10
11
|
import { printCommandError } from "../command-errors.js";
|
|
12
|
+
import { checkoutPackageAssetsDir } from "../package-assets.js";
|
|
11
13
|
import { registerGameSmokeCommand } from "./game-smoke.js";
|
|
12
14
|
const strictGameEvent = z.union(gameEvent.options.map((variant) => variant.strict()));
|
|
13
15
|
const jsonFields = z.record(z.string(), z.unknown());
|
|
@@ -38,9 +40,32 @@ const MEDIA_TYPES = {
|
|
|
38
40
|
glb: "model/gltf-binary",
|
|
39
41
|
json: "application/json"
|
|
40
42
|
};
|
|
43
|
+
/** Reads a shipped `package://` asset from the package asset directory of this checkout or of NODETOOL_PACKAGE_ASSETS_DIR. */
|
|
44
|
+
async function readPackageAsset(uri) {
|
|
45
|
+
const ref = parsePackageAssetUri(uri);
|
|
46
|
+
const root = process.env.NODETOOL_PACKAGE_ASSETS_DIR || checkoutPackageAssetsDir();
|
|
47
|
+
if (!ref || !root)
|
|
48
|
+
return null;
|
|
49
|
+
const base = await realpath(root);
|
|
50
|
+
let path;
|
|
51
|
+
try {
|
|
52
|
+
path = await realpath(join(base, ref.packageName, ref.path));
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.code === "ENOENT")
|
|
56
|
+
return null;
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
if (!path.startsWith(`${base}${sep}`)) {
|
|
60
|
+
throw new Error(`Package asset escapes the asset directory: ${uri}`);
|
|
61
|
+
} // key-boundary-ok: node:path sep anchors containment after realpath.
|
|
62
|
+
return { bytes: await readFile(path), mimeType: MEDIA_TYPES[extname(path).slice(1).toLowerCase()] ?? "application/octet-stream" };
|
|
63
|
+
}
|
|
41
64
|
async function readBuildAsset(directory, sourceAssetId) {
|
|
42
65
|
if (sourceAssetId.startsWith("builtin:"))
|
|
43
66
|
return null;
|
|
67
|
+
if (sourceAssetId.startsWith("package://"))
|
|
68
|
+
return readPackageAsset(sourceAssetId);
|
|
44
69
|
if (!directory)
|
|
45
70
|
return null;
|
|
46
71
|
if (!/^[a-f0-9]{32}$/.test(sourceAssetId)) {
|
|
@@ -67,6 +92,14 @@ function nonnegativeInteger(value, name) {
|
|
|
67
92
|
async function readDocument(path) {
|
|
68
93
|
return JSON.parse(await readFile(path, "utf8"));
|
|
69
94
|
}
|
|
95
|
+
/** A shipped example file. A game document never has `name` and `document` without `schemaVersion`. */
|
|
96
|
+
const exampleWrapper = z.object({ name: z.string(), document: z.record(z.string(), z.unknown()), schemaVersion: z.never().optional() });
|
|
97
|
+
/** Reads a game document, or the `document` of a shipped example file `{name, document, …}`. */
|
|
98
|
+
async function readGameDocument(path) {
|
|
99
|
+
const raw = await readDocument(path);
|
|
100
|
+
const wrapped = exampleWrapper.safeParse(raw);
|
|
101
|
+
return wrapped.success ? wrapped.data.document : raw;
|
|
102
|
+
}
|
|
70
103
|
async function readInputs(path, schema) {
|
|
71
104
|
if (!path)
|
|
72
105
|
return [];
|
|
@@ -225,7 +258,7 @@ export function registerGameCommands(program) {
|
|
|
225
258
|
.option("--json", "Print a machine-readable report")
|
|
226
259
|
.action(async (path, options) => {
|
|
227
260
|
try {
|
|
228
|
-
const report = validateCliDocument(await
|
|
261
|
+
const report = validateCliDocument(await readGameDocument(path));
|
|
229
262
|
if (options.json) {
|
|
230
263
|
process.stdout.write(`${JSON.stringify(report)}\n`);
|
|
231
264
|
}
|
|
@@ -249,15 +282,31 @@ export function registerGameCommands(program) {
|
|
|
249
282
|
.option("--ticks <count>", "Measured ticks", "1200")
|
|
250
283
|
.option("--warmup <count>", "Warmup ticks", "300")
|
|
251
284
|
.option("--seed <integer>", "Random seed", "1")
|
|
285
|
+
.option("--inputs <file>", "JSON array of tick-indexed input frames from tick 0 (warmup included), so the bench measures play")
|
|
286
|
+
.option("--assets-dir <directory>", "Prepared 3D collider files named <full-asset-id>.json. Shipped package:// assets resolve without it")
|
|
287
|
+
.option("--fail-on-budget", "Exit 1 when the tick p95 exceeds performance.budgets.tickMs (default 4 ms)")
|
|
252
288
|
.option("--json", "Print a machine-readable report")
|
|
253
289
|
.action(async (path, options) => {
|
|
254
290
|
try {
|
|
255
|
-
const validated = validateCliDocument(await
|
|
291
|
+
const validated = validateCliDocument(await readGameDocument(path));
|
|
256
292
|
if (!validated.valid || !validated.document) {
|
|
257
293
|
throw new Error(validated.errors.join("\n"));
|
|
258
294
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
295
|
+
const document = validated.document;
|
|
296
|
+
const inputs = document.schemaVersion === 3 ? await readInputs(options.inputs, gameInputFrame3D) : await readInputs(options.inputs, gameInputFrame);
|
|
297
|
+
const report = await benchmarkNativeGame(document, Number(options.ticks), Number(options.warmup), Number(options.seed), { inputs, resolveCollider: sessionAssetOptions3D(options.assetsDir).resolveCollider });
|
|
298
|
+
const { formatGameTimeBudgetOverrun, gameTimeBudgetOverruns, resolveGameTimeBudgets } = await importPack("game", "@nodetool-ai/game-renderer");
|
|
299
|
+
const limits = resolveGameTimeBudgets(document.schemaVersion === 3 ? document.performance?.budgets : undefined);
|
|
300
|
+
const overruns = gameTimeBudgetOverruns({ tickMs: report.tickMs.p95 }, limits);
|
|
301
|
+
process.stdout.write(`${JSON.stringify({ ...report, budget: { limits: { tickMs: limits.tickMs }, overruns } }, null, options.json ? undefined : 2)}\n`);
|
|
302
|
+
if (!options.json) {
|
|
303
|
+
for (const overrun of overruns) {
|
|
304
|
+
process.stderr.write(`${formatGameTimeBudgetOverrun(overrun)}\n`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (options.failOnBudget && overruns.length > 0) {
|
|
308
|
+
process.exitCode = 1;
|
|
309
|
+
}
|
|
261
310
|
}
|
|
262
311
|
catch (error) {
|
|
263
312
|
process.exitCode = printCommandError(error, options.json);
|
|
@@ -278,7 +327,7 @@ export function registerGameCommands(program) {
|
|
|
278
327
|
.option("--json", "Print a machine-readable report")
|
|
279
328
|
.action(async (path, options) => {
|
|
280
329
|
try {
|
|
281
|
-
const validated = validateCliDocument(await
|
|
330
|
+
const validated = validateCliDocument(await readGameDocument(path));
|
|
282
331
|
if (!validated.valid || !validated.document) {
|
|
283
332
|
throw new Error(validated.errors.join("\n"));
|
|
284
333
|
}
|
|
@@ -394,10 +443,11 @@ export function registerGameCommands(program) {
|
|
|
394
443
|
.option("--scale <factor>", "Output scale", "1")
|
|
395
444
|
.option("--backend <canvas2d|webgpu|webgl2>", "Capture backend. Defaults to WebGL2 for 3D", "canvas2d")
|
|
396
445
|
.option("--assets-dir <directory>", "Local media files named <full-asset-id>.<extension>")
|
|
446
|
+
.option("--fail-on-budget", "3D only. Exit 1 when the frame exceeds a performance.budgets count (draw calls, triangles, particles)")
|
|
397
447
|
.option("--json", "Print a machine-readable report")
|
|
398
448
|
.action(async (path, options, command) => {
|
|
399
449
|
try {
|
|
400
|
-
const validated = validateCliDocument(await
|
|
450
|
+
const validated = validateCliDocument(await readGameDocument(path));
|
|
401
451
|
if (!validated.valid || !validated.document) {
|
|
402
452
|
throw new Error(validated.errors.join("\n"));
|
|
403
453
|
}
|
|
@@ -406,6 +456,9 @@ export function registerGameCommands(program) {
|
|
|
406
456
|
await captureGame3D(validated.document, { ...options, backend });
|
|
407
457
|
return;
|
|
408
458
|
}
|
|
459
|
+
if (options.failOnBudget) {
|
|
460
|
+
throw new Error("--fail-on-budget applies to 3D games. 2D capture reports no frame counters");
|
|
461
|
+
}
|
|
409
462
|
const ticks = nonnegativeInteger(options.ticks, "ticks");
|
|
410
463
|
if (ticks === 0)
|
|
411
464
|
throw new Error("ticks must be at least 1 for capture");
|
|
@@ -457,29 +510,116 @@ export function registerGameCommands(program) {
|
|
|
457
510
|
process.exitCode = printCommandError(error, options.json);
|
|
458
511
|
}
|
|
459
512
|
});
|
|
513
|
+
game.command("perf <game_file>")
|
|
514
|
+
.description("Export a 3D game, play it in Chromium on the machine GPU and measure frame time, draw calls, triangles and shader program growth")
|
|
515
|
+
.option("--inputs <file>", "JSON array of input frames replayed with advance before live play")
|
|
516
|
+
.option("--seconds <seconds>", "Measured seconds of live play", "10")
|
|
517
|
+
.option("--warmup <seconds>", "Seconds of live play before the measurement", "2")
|
|
518
|
+
.option("--assets-dir <directory>", "Local media files named <full-asset-id>.<extension>. Shipped package:// assets resolve without it")
|
|
519
|
+
.option("--software", "Use SwiftShader instead of the machine GPU. Frame times then say nothing about real hardware")
|
|
520
|
+
.option("--vsync", "Keep vsync and Chromium's frame rate limit. By default frames are uncapped, so frame time shows the real cost")
|
|
521
|
+
.option("--keep-build <directory>", "Export into this directory and keep it, instead of a temporary directory")
|
|
522
|
+
.option("--profile <file>", "Write a Chrome CPU profile of the measured window and list its hottest functions. A source checkout keeps readable names")
|
|
523
|
+
.option("--fail-on-budget", "Exit 1 when frame p95 exceeds performance.budgets.frameMs (default 16.6), draw calls or triangles exceed their budgets, or shader programs grow during play")
|
|
524
|
+
.option("--json", "Print a machine-readable report")
|
|
525
|
+
.action(async (path, options) => {
|
|
526
|
+
let temporary;
|
|
527
|
+
try {
|
|
528
|
+
const validated = validateCliDocument(await readGameDocument(path));
|
|
529
|
+
if (!validated.valid || !validated.document) {
|
|
530
|
+
throw new Error(validated.errors.join("\n"));
|
|
531
|
+
}
|
|
532
|
+
const document = validated.document;
|
|
533
|
+
if (document.schemaVersion !== 3) {
|
|
534
|
+
throw new Error("game perf measures 3D games. Use game bench for 2D tick cost");
|
|
535
|
+
}
|
|
536
|
+
const inputs = await readInputs(options.inputs, gameInputFrame3D);
|
|
537
|
+
const outputDir = options.keepBuild ? resolve(options.keepBuild) : (temporary = await mkdtemp(join(tmpdir(), "nodetool-game-perf-")));
|
|
538
|
+
const { buildStandaloneGame3D } = await importPack("game", "@nodetool-ai/game-renderer/build3d");
|
|
539
|
+
await buildStandaloneGame3D({ document, outputDir, resolveAsset: (assetId) => readBuildAsset(options.assetsDir, assetId) });
|
|
540
|
+
const { measureStandaloneGame3D, formatGamePerfOverrun } = await importPack("game", "@nodetool-ai/game-renderer/perf");
|
|
541
|
+
// A recorded route never carries save loads, so the frames go to the page without them.
|
|
542
|
+
const report = await measureStandaloneGame3D(outputDir, { inputs: inputs.map(({ loaded: _loaded, ...frame }) => frame),
|
|
543
|
+
seconds: Number(options.seconds), warmupSeconds: Number(options.warmup), software: options.software, vsync: options.vsync,
|
|
544
|
+
profile: options.profile ? resolve(options.profile) : undefined });
|
|
545
|
+
if (options.json) {
|
|
546
|
+
process.stdout.write(`${JSON.stringify(report)}\n`);
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
550
|
+
process.stdout.write([
|
|
551
|
+
`GPU ${report.gpu.renderer} (${report.gpu.adapterType}), canvas ${report.canvas.width}x${report.canvas.height}, ${report.vsync ? "vsync" : "uncapped"}`,
|
|
552
|
+
`${report.renderedFrames} frames in ${report.seconds} s: ${round(report.fps)} fps`,
|
|
553
|
+
`Frame ms p50 ${round(report.frameMs.p50)}, p95 ${round(report.frameMs.p95)}, p99 ${round(report.frameMs.p99)}, max ${round(report.frameMs.max)}`,
|
|
554
|
+
`Draw calls p95 ${report.drawCalls.p95}, triangles p95 ${report.triangles.p95}`,
|
|
555
|
+
`Shader programs ${report.programs.start} -> ${report.programs.end} (growth ${report.programs.growth})`,
|
|
556
|
+
...report.profile ? [`Profile ${report.profile.path}, ${round(report.profile.sampledMs)} ms sampled. Hottest self time:`,
|
|
557
|
+
...report.profile.top.slice(0, 10).map((entry) => ` ${entry.percent}% ${entry.functionName} ${entry.url}:${entry.line}`),
|
|
558
|
+
...report.profile.suspects.map((entry) => `Suspect in steady play: ${entry.functionName} ${entry.percent}%`)] : [],
|
|
559
|
+
...report.warnings, ...report.errors
|
|
560
|
+
].join("\n") + "\n");
|
|
561
|
+
for (const overrun of report.budget.overruns) {
|
|
562
|
+
process.stderr.write(`${formatGamePerfOverrun(overrun)}\n`);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (!report.ok || (options.failOnBudget && report.budget.overruns.length > 0)) {
|
|
566
|
+
process.exitCode = 1;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
catch (error) {
|
|
570
|
+
process.exitCode = printCommandError(error, options.json);
|
|
571
|
+
}
|
|
572
|
+
finally {
|
|
573
|
+
if (temporary) {
|
|
574
|
+
await rm(temporary, { recursive: true, force: true });
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
});
|
|
460
578
|
game
|
|
461
579
|
.command("build <game_file>")
|
|
462
|
-
.description("Build a standalone web player,
|
|
580
|
+
.description("Build a standalone web player, a Tauri desktop app project or an Expo mobile app project, with local, content-addressed assets")
|
|
463
581
|
.requiredOption("--out <directory>", "Build output directory")
|
|
464
582
|
.option("--assets-dir <directory>", "Local media files named <full-asset-id>.<extension>")
|
|
465
|
-
.option("--target <target>", "web for a static web player, tauri for a desktop app project", "web")
|
|
466
|
-
.option("--name <name>", "
|
|
467
|
-
.option("--identifier <identifier>", "Reverse-DNS
|
|
468
|
-
.option("--app-version <version>", "
|
|
469
|
-
.option("--icon <file>", "PNG, JPEG or WebP image for the
|
|
583
|
+
.option("--target <target>", "web for a static web player, tauri for a desktop app project, expo for an iOS and Android app project", "web")
|
|
584
|
+
.option("--name <name>", "App name (tauri and expo targets)")
|
|
585
|
+
.option("--identifier <identifier>", "Reverse-DNS app identifier (tauri and expo targets)")
|
|
586
|
+
.option("--app-version <version>", "App version MAJOR.MINOR.PATCH (tauri and expo targets)")
|
|
587
|
+
.option("--icon <file>", "PNG, JPEG or WebP image for the app icon (tauri and expo targets)")
|
|
588
|
+
.option("--orientation <orientation>", "default, portrait or landscape screen lock (expo target)")
|
|
470
589
|
.option("--compile", "Also compile a release executable with cargo (tauri target)")
|
|
471
590
|
.option("--json", "Print a machine-readable report")
|
|
472
591
|
.action(async (path, options) => {
|
|
473
592
|
try {
|
|
474
|
-
const validated = validateCliDocument(await
|
|
593
|
+
const validated = validateCliDocument(await readGameDocument(path));
|
|
475
594
|
if (!validated.valid || !validated.document) {
|
|
476
595
|
throw new Error(validated.errors.join("\n"));
|
|
477
596
|
}
|
|
478
|
-
if (options.target !== "web" && options.target !== "tauri") {
|
|
479
|
-
throw new Error("--target must be web or
|
|
597
|
+
if (options.target !== "web" && options.target !== "tauri" && options.target !== "expo") {
|
|
598
|
+
throw new Error("--target must be web, tauri or expo");
|
|
599
|
+
}
|
|
600
|
+
if (options.target === "web" && (options.name || options.identifier || options.appVersion || options.icon || options.orientation || options.compile)) {
|
|
601
|
+
throw new Error("--name, --identifier, --app-version, --icon, --orientation and --compile apply to --target tauri or expo");
|
|
602
|
+
}
|
|
603
|
+
if (options.compile && options.target !== "tauri") {
|
|
604
|
+
throw new Error("--compile applies to --target tauri");
|
|
480
605
|
}
|
|
481
|
-
if (options.
|
|
482
|
-
throw new Error("--
|
|
606
|
+
if (options.orientation && options.target !== "expo") {
|
|
607
|
+
throw new Error("--orientation applies to --target expo");
|
|
608
|
+
}
|
|
609
|
+
if (options.target === "expo") {
|
|
610
|
+
const orientation = options.orientation;
|
|
611
|
+
if (orientation !== undefined && orientation !== "default" && orientation !== "portrait" && orientation !== "landscape") {
|
|
612
|
+
throw new Error("--orientation must be default, portrait or landscape");
|
|
613
|
+
}
|
|
614
|
+
const { buildExpoGameProject } = await importPack("game", "@nodetool-ai/game-renderer/build-expo");
|
|
615
|
+
const project = await buildExpoGameProject({
|
|
616
|
+
document: validated.document, outputDir: resolve(options.out), resolveAsset: (assetId) => readBuildAsset(options.assetsDir, assetId),
|
|
617
|
+
app: { name: options.name, identifier: options.identifier, version: options.appVersion, orientation,
|
|
618
|
+
icon: options.icon ? await readFile(options.icon) : undefined }
|
|
619
|
+
});
|
|
620
|
+
process.stdout.write(options.json ? `${JSON.stringify(project)}\n`
|
|
621
|
+
: `Built mobile app project in ${project.outputDir}\nRun npm install && npx expo start there to play it on a phone.\n`);
|
|
622
|
+
return;
|
|
483
623
|
}
|
|
484
624
|
if (options.target === "tauri") {
|
|
485
625
|
const { buildTauriGameProject, compileTauriGameProject } = await importPack("game", "@nodetool-ai/game-renderer/build-tauri");
|
|
@@ -705,6 +845,9 @@ async function captureGame3D(document, options) {
|
|
|
705
845
|
process.stderr.write(`${formatGameFrameBudgetOverrun(overrun)}\n`);
|
|
706
846
|
}
|
|
707
847
|
}
|
|
848
|
+
if (options.failOnBudget && overruns.length > 0) {
|
|
849
|
+
process.exitCode = 1;
|
|
850
|
+
}
|
|
708
851
|
}
|
|
709
852
|
finally {
|
|
710
853
|
session.dispose();
|