@air-jam/devtools 0.9.3 → 1.0.0-beta.10
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 +60 -0
- package/dist/{chunk-VKMJO6VN.js → chunk-2O67AXCU.js} +150 -40
- package/dist/chunk-2O67AXCU.js.map +1 -0
- package/dist/chunk-AO3ZDXF6.js +142 -0
- package/dist/chunk-AO3ZDXF6.js.map +1 -0
- package/dist/chunk-ART5TEYT.js +472 -0
- package/dist/chunk-ART5TEYT.js.map +1 -0
- package/dist/chunk-ASC2CK2R.js +77 -0
- package/dist/chunk-ASC2CK2R.js.map +1 -0
- package/dist/chunk-E3UZZGAV.js +50 -0
- package/dist/chunk-E3UZZGAV.js.map +1 -0
- package/dist/chunk-EJTE7UKX.js +64 -0
- package/dist/chunk-EJTE7UKX.js.map +1 -0
- package/dist/chunk-ESFKNN75.js +110 -0
- package/dist/chunk-ESFKNN75.js.map +1 -0
- package/dist/chunk-EU7A6PXW.js +1339 -0
- package/dist/chunk-EU7A6PXW.js.map +1 -0
- package/dist/chunk-FN7E6EA7.js +549 -0
- package/dist/chunk-FN7E6EA7.js.map +1 -0
- package/dist/chunk-GDFAWHGA.js +190 -0
- package/dist/chunk-GDFAWHGA.js.map +1 -0
- package/dist/chunk-HZUGBH4Y.js +347 -0
- package/dist/chunk-HZUGBH4Y.js.map +1 -0
- package/dist/chunk-ITKAOEGX.js +93 -0
- package/dist/chunk-ITKAOEGX.js.map +1 -0
- package/dist/chunk-JBCUTWRI.js +897 -0
- package/dist/chunk-JBCUTWRI.js.map +1 -0
- package/dist/chunk-JSI5S4WP.js +1174 -0
- package/dist/chunk-JSI5S4WP.js.map +1 -0
- package/dist/chunk-L4D675BG.js +97 -0
- package/dist/chunk-L4D675BG.js.map +1 -0
- package/dist/{chunk-GUEZP773.js → chunk-LB3Y64P5.js} +206 -60
- package/dist/chunk-LB3Y64P5.js.map +1 -0
- package/dist/chunk-M6CJ7GQC.js +133 -0
- package/dist/chunk-M6CJ7GQC.js.map +1 -0
- package/dist/{chunk-CKFT2ZJE.js → chunk-MEIMOSZC.js} +53 -105
- package/dist/chunk-MEIMOSZC.js.map +1 -0
- package/dist/chunk-OM6SCJ7H.js +18 -0
- package/dist/chunk-OM6SCJ7H.js.map +1 -0
- package/dist/chunk-PKD4WVX5.js +63 -0
- package/dist/chunk-PKD4WVX5.js.map +1 -0
- package/dist/chunk-PMBLXGFM.js +3384 -0
- package/dist/chunk-PMBLXGFM.js.map +1 -0
- package/dist/chunk-PMNE5GIN.js +279 -0
- package/dist/chunk-PMNE5GIN.js.map +1 -0
- package/dist/chunk-QAWI64VR.js +148 -0
- package/dist/chunk-QAWI64VR.js.map +1 -0
- package/dist/chunk-QGADSPHZ.js +449 -0
- package/dist/chunk-QGADSPHZ.js.map +1 -0
- package/dist/chunk-SPYN66UV.js +338 -0
- package/dist/chunk-SPYN66UV.js.map +1 -0
- package/dist/context.d.ts +9 -3
- package/dist/context.js +2 -1
- package/dist/controller.d.ts +33 -7
- package/dist/controller.js +18 -8
- package/dist/dependencies.d.ts +44 -0
- package/dist/dependencies.js +10 -0
- package/dist/dev.d.ts +9 -3
- package/dist/dev.js +3 -4
- package/dist/game-builds.d.ts +200 -0
- package/dist/game-builds.js +16 -0
- package/dist/game-builds.js.map +1 -0
- package/dist/game-run-watch-CEd_SpAT.d.ts +84 -0
- package/dist/game-runs.d.ts +1452 -0
- package/dist/game-runs.js +76 -0
- package/dist/game-runs.js.map +1 -0
- package/dist/game-session-broker-CUvORfMd.d.ts +439 -0
- package/dist/game-session-broker.d.ts +4 -57
- package/dist/game-session-broker.js +33 -228
- package/dist/game-session-broker.js.map +1 -1
- package/dist/game-session.d.ts +3931 -10
- package/dist/game-session.js +186 -15
- package/dist/game-session.js.map +1 -1
- package/dist/game-settings.d.ts +16 -0
- package/dist/game-settings.js +237 -0
- package/dist/game-settings.js.map +1 -0
- package/dist/games.d.ts +11 -4
- package/dist/games.js +4 -2
- package/dist/harness/visual.d.ts +34 -151
- package/dist/harness/visual.js +6 -1
- package/dist/logs.d.ts +8 -2
- package/dist/logs.js +3 -4
- package/dist/logs.js.map +1 -1
- package/dist/managed-process-scope-BicYi_t9.d.ts +3 -0
- package/dist/mcp-config.js +2 -1
- package/dist/mcp-config.js.map +1 -1
- package/dist/platform-auth.d.ts +8 -111
- package/dist/platform-auth.js +9 -1
- package/dist/platform-game-analytics.d.ts +51 -0
- package/dist/platform-game-analytics.js +49 -0
- package/dist/platform-game-analytics.js.map +1 -0
- package/dist/platform-game-app-id.d.ts +46 -0
- package/dist/platform-game-app-id.js +93 -0
- package/dist/platform-game-app-id.js.map +1 -0
- package/dist/platform-game-media.d.ts +40 -2
- package/dist/platform-game-media.js +1 -1
- package/dist/platform-games.d.ts +24 -2
- package/dist/platform-games.js +16 -84
- package/dist/platform-games.js.map +1 -1
- package/dist/quality.d.ts +9 -3
- package/dist/quality.js +3 -4
- package/dist/quality.js.map +1 -1
- package/dist/release.d.ts +226 -16
- package/dist/release.js +18 -1331
- package/dist/release.js.map +1 -1
- package/dist/rooms-check.d.ts +90 -0
- package/dist/rooms-check.js +717 -0
- package/dist/rooms-check.js.map +1 -0
- package/dist/source-tree-contract.d.ts +16 -0
- package/dist/source-tree-contract.js +13 -0
- package/dist/source-tree-contract.js.map +1 -0
- package/dist/testing.d.ts +464 -0
- package/dist/testing.js +27 -0
- package/dist/testing.js.map +1 -0
- package/dist/tooling/describe-game.js +54 -0
- package/dist/tooling/describe-game.js.map +1 -0
- package/dist/tooling/game-session-broker.js +28 -0
- package/dist/tooling/game-session-broker.js.map +1 -0
- package/dist/tooling/hold-runtime-host.js +770 -68
- package/dist/tooling/hold-runtime-host.js.map +1 -1
- package/dist/tooling/list-visual-scenarios.js +18 -55
- package/dist/tooling/list-visual-scenarios.js.map +1 -1
- package/dist/tooling/process-scope-bootstrap.mjs +24 -0
- package/dist/tooling/process-scope-guard.d.ts +2 -0
- package/dist/tooling/process-scope-guard.js +388 -0
- package/dist/tooling/process-scope-guard.js.map +1 -0
- package/dist/tooling/process-scope-windows.ps1 +148 -0
- package/dist/tooling/rooms-check-device.d.ts +2 -0
- package/dist/tooling/rooms-check-device.js +498 -0
- package/dist/tooling/rooms-check-device.js.map +1 -0
- package/dist/tooling/run-headless-room.d.ts +2 -0
- package/dist/tooling/run-headless-room.js +288 -0
- package/dist/tooling/run-headless-room.js.map +1 -0
- package/dist/tooling/run-test-profile.d.ts +2 -0
- package/dist/tooling/run-test-profile.js +181 -0
- package/dist/tooling/run-test-profile.js.map +1 -0
- package/dist/tooling/run-visual-capture.js +70 -34
- package/dist/tooling/run-visual-capture.js.map +1 -1
- package/dist/tooling/seal-game-build.d.ts +2 -0
- package/dist/tooling/seal-game-build.js +120 -0
- package/dist/tooling/seal-game-build.js.map +1 -0
- package/dist/{types-C6NrHt88.d.ts → types-CdYrgrG_.d.ts} +337 -76
- package/dist/types-DyRD-ym1.d.ts +141 -0
- package/dist/visual.d.ts +9 -3
- package/dist/visual.js +24 -68
- package/dist/visual.js.map +1 -1
- package/package.json +51 -14
- package/src/bounded-response.ts +28 -0
- package/src/built-game-runtime.ts +152 -0
- package/src/context.ts +2 -13
- package/src/controller-protocol.ts +22 -0
- package/src/controller.ts +747 -597
- package/src/current-room-host.ts +166 -0
- package/src/decision-provider.ts +102 -0
- package/src/dependencies.ts +176 -0
- package/src/dependency-install-contract.ts +12 -0
- package/src/dev.ts +46 -50
- package/src/game-action-observation.ts +11 -1
- package/src/game-build-protocol.ts +72 -0
- package/src/game-build.ts +483 -0
- package/src/game-run-owner.ts +2358 -0
- package/src/game-run-protocol.ts +448 -0
- package/src/game-run-record.ts +92 -0
- package/src/game-run-replay.ts +95 -0
- package/src/game-run-watch.ts +155 -0
- package/src/game-session-broker.ts +689 -197
- package/src/game-session-operations.ts +61 -0
- package/src/game-session-protocol.ts +180 -0
- package/src/game-session-runtime.ts +861 -0
- package/src/game-session.ts +164 -417
- package/src/game-settings.ts +295 -0
- package/src/games.ts +88 -92
- package/src/harness/visual/browser.ts +100 -0
- package/src/harness/visual/controller-observation.ts +181 -0
- package/src/harness/visual/runner.ts +24 -21
- package/src/harness/visual/runtime-controller-observations.ts +151 -0
- package/src/harness/visual/scenario-contract.ts +1 -2
- package/src/harness/visual/scenario-helpers.ts +5 -1
- package/src/harness/visual/screencast.ts +155 -0
- package/src/harness/visual/session.ts +74 -69
- package/src/harness/visual/types.ts +8 -5
- package/src/headless-room-protocol.ts +112 -0
- package/src/headless-room.ts +222 -0
- package/src/helper-channel.ts +229 -0
- package/src/helper-scripts.ts +25 -5
- package/src/installed-dependencies.ts +74 -0
- package/src/managed-process-scope.ts +481 -0
- package/src/node-process-environment.ts +10 -0
- package/src/platform-auth.ts +194 -55
- package/src/platform-game-analytics.ts +50 -0
- package/src/platform-game-app-id.ts +99 -0
- package/src/platform-games.ts +13 -111
- package/src/policy-artifact-contract.ts +52 -0
- package/src/policy-artifacts.ts +134 -0
- package/src/process-scope-admission.ts +50 -0
- package/src/process-scope-protocol.ts +66 -0
- package/src/process-scope.ts +327 -0
- package/src/release.ts +28 -42
- package/src/rooms-check-fleet.ts +194 -0
- package/src/rooms-check-link.ts +138 -0
- package/src/rooms-check-protocol.ts +244 -0
- package/src/rooms-check.ts +797 -0
- package/src/runtime-owner-protocol.ts +106 -18
- package/src/source-tree-contract.ts +70 -0
- package/src/source-tree.ts +84 -0
- package/src/test-profile-process.ts +153 -0
- package/src/test-profile-protocol.ts +116 -0
- package/src/testing.ts +430 -0
- package/src/tooling/declaration-hook.ts +52 -0
- package/src/tooling/describe-game.ts +49 -0
- package/src/tooling/game-session-broker.ts +7 -0
- package/src/tooling/hold-runtime-host.ts +254 -42
- package/src/tooling/list-visual-scenarios.ts +19 -62
- package/src/tooling/load-game.ts +79 -0
- package/src/tooling/process-scope-bootstrap.mjs +24 -0
- package/src/tooling/process-scope-guard.ts +213 -0
- package/src/tooling/process-scope-windows.ps1 +148 -0
- package/src/tooling/rooms-check-device.ts +493 -0
- package/src/tooling/run-headless-room.ts +329 -0
- package/src/tooling/run-test-profile.ts +190 -0
- package/src/tooling/run-visual-capture.ts +37 -23
- package/src/tooling/runtime-owner-actions.ts +23 -0
- package/src/tooling/seal-game-build.ts +118 -0
- package/src/tooling/visual-pack.ts +10 -45
- package/src/types.ts +54 -77
- package/src/visual.ts +14 -22
- package/src/windows-process-scopes.ts +189 -0
- package/dist/agent.d.ts +0 -15
- package/dist/agent.js +0 -19
- package/dist/chunk-5YAARMW5.js +0 -36
- package/dist/chunk-5YAARMW5.js.map +0 -1
- package/dist/chunk-6WQODT37.js +0 -1019
- package/dist/chunk-6WQODT37.js.map +0 -1
- package/dist/chunk-CKFT2ZJE.js.map +0 -1
- package/dist/chunk-ER3Q2C4G.js +0 -358
- package/dist/chunk-ER3Q2C4G.js.map +0 -1
- package/dist/chunk-GUEZP773.js.map +0 -1
- package/dist/chunk-HIDNI56E.js +0 -33
- package/dist/chunk-HIDNI56E.js.map +0 -1
- package/dist/chunk-QKXS5D35.js +0 -43
- package/dist/chunk-QKXS5D35.js.map +0 -1
- package/dist/chunk-S4LSCEVE.js +0 -261
- package/dist/chunk-S4LSCEVE.js.map +0 -1
- package/dist/chunk-VKMJO6VN.js.map +0 -1
- package/dist/chunk-WFUR3MXY.js +0 -67
- package/dist/chunk-WFUR3MXY.js.map +0 -1
- package/dist/chunk-XEMR7KUE.js +0 -361
- package/dist/chunk-XEMR7KUE.js.map +0 -1
- package/dist/chunk-ZLPD7FY5.js +0 -191
- package/dist/chunk-ZLPD7FY5.js.map +0 -1
- package/dist/tooling/agent-contract.js +0 -193
- package/dist/tooling/agent-contract.js.map +0 -1
- package/dist/tooling/inspect-airjam-agent.js +0 -37
- package/dist/tooling/inspect-airjam-agent.js.map +0 -1
- package/src/agent.ts +0 -380
- package/src/tooling/agent-contract.ts +0 -232
- package/src/tooling/agent-declaration.ts +0 -36
- package/src/tooling/airjam-agent-inspection.ts +0 -45
- package/src/tooling/airjam-agent.ts +0 -118
- package/src/tooling/inspect-airjam-agent.ts +0 -20
- /package/dist/{agent.js.map → dependencies.js.map} +0 -0
- /package/dist/tooling/{agent-contract.d.ts → describe-game.d.ts} +0 -0
- /package/dist/tooling/{inspect-airjam-agent.d.ts → game-session-broker.d.ts} +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { aj as InvokeGameActionResult } from './types-CdYrgrG_.js';
|
|
2
|
+
import { AnyAirJamAgentContract, AirJamAgentContract } from '@air-jam/sdk/core';
|
|
3
|
+
import { AirJamGameInputModality } from '@air-jam/sdk/metadata';
|
|
4
|
+
import { Page } from 'playwright-core';
|
|
5
|
+
|
|
6
|
+
type VisualHarnessMode = "standalone-dev" | "arcade-built";
|
|
7
|
+
type VisualViewport = {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
type VisualScreenshotRecord = {
|
|
12
|
+
surface: "host" | "controller";
|
|
13
|
+
viewportName: string;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
fileName: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
};
|
|
19
|
+
type VisualHarnessUrls = {
|
|
20
|
+
appOrigin: string;
|
|
21
|
+
hostUrl: string;
|
|
22
|
+
controllerBaseUrl: string;
|
|
23
|
+
publicHost: string;
|
|
24
|
+
localBuildUrl: string | null;
|
|
25
|
+
browserBuildUrl: string | null;
|
|
26
|
+
controllerJoinUrl: string;
|
|
27
|
+
};
|
|
28
|
+
type VisualQuerySurface = {
|
|
29
|
+
getByLabel: Page["getByLabel"];
|
|
30
|
+
getByRole: Page["getByRole"];
|
|
31
|
+
getByTestId: Page["getByTestId"];
|
|
32
|
+
getByText: Page["getByText"];
|
|
33
|
+
locator: Page["locator"];
|
|
34
|
+
};
|
|
35
|
+
type VisualHarnessPageSurface = {
|
|
36
|
+
page: Page;
|
|
37
|
+
game: VisualQuerySurface;
|
|
38
|
+
embedded: boolean;
|
|
39
|
+
};
|
|
40
|
+
type InferVisualScenarioSnapshot<TAgent> = TAgent extends AirJamAgentContract<infer TSnapshot, infer _TStores> ? TSnapshot : never;
|
|
41
|
+
type VisualScenarioAgentActionDescriptor = {
|
|
42
|
+
actionId: string;
|
|
43
|
+
lane: "player" | "host";
|
|
44
|
+
source: "semantic-game";
|
|
45
|
+
description: string | null;
|
|
46
|
+
availability: string | null;
|
|
47
|
+
payload: {
|
|
48
|
+
kind: "none" | "boolean" | "number" | "string" | "enum" | "json";
|
|
49
|
+
description: string | null;
|
|
50
|
+
allowedValues?: string[];
|
|
51
|
+
};
|
|
52
|
+
resultDescription: string | null;
|
|
53
|
+
};
|
|
54
|
+
type VisualScenarioAgentInvocation<TSnapshot = Record<string, unknown>> = {
|
|
55
|
+
actionId: string;
|
|
56
|
+
lane: "player" | "host";
|
|
57
|
+
outcome: string | null;
|
|
58
|
+
acknowledgementObservation: string | null;
|
|
59
|
+
snapshotBefore: TSnapshot | null;
|
|
60
|
+
snapshotAfter: TSnapshot | null;
|
|
61
|
+
snapshotAfterStatus: InvokeGameActionResult["snapshotAfterStatus"] | null;
|
|
62
|
+
};
|
|
63
|
+
type VisualScenarioAgent<TSnapshot = Record<string, unknown>> = {
|
|
64
|
+
listActions: () => Promise<readonly VisualScenarioAgentActionDescriptor[]>;
|
|
65
|
+
read: () => Promise<TSnapshot>;
|
|
66
|
+
waitFor: (predicate: (snapshot: TSnapshot) => boolean | Promise<boolean>, description?: string, timeout?: number) => Promise<TSnapshot>;
|
|
67
|
+
invoke: (actionId: string, payload?: unknown, options?: {
|
|
68
|
+
timeoutMs?: number;
|
|
69
|
+
}) => Promise<VisualScenarioAgentInvocation<TSnapshot>>;
|
|
70
|
+
close: () => Promise<void>;
|
|
71
|
+
};
|
|
72
|
+
type VisualScenarioContext<TAgent extends AnyAirJamAgentContract = AnyAirJamAgentContract> = {
|
|
73
|
+
gameId: string;
|
|
74
|
+
scenario: VisualScenario<TAgent>;
|
|
75
|
+
scenarioDir: string;
|
|
76
|
+
inputModalities?: readonly AirJamGameInputModality[];
|
|
77
|
+
urls: VisualHarnessUrls;
|
|
78
|
+
host: VisualHarnessPageSurface;
|
|
79
|
+
controller: VisualHarnessPageSurface & {
|
|
80
|
+
fullscreenPromptDismissed: boolean;
|
|
81
|
+
};
|
|
82
|
+
note: (value: string) => void;
|
|
83
|
+
sleep: (ms: number) => Promise<void>;
|
|
84
|
+
ensureControllerInteractive: () => Promise<void>;
|
|
85
|
+
agent: VisualScenarioAgent<InferVisualScenarioSnapshot<TAgent>>;
|
|
86
|
+
captureHost: (viewportName: string, viewport: VisualViewport) => Promise<void>;
|
|
87
|
+
captureController: (viewportName: string, viewport: VisualViewport) => Promise<void>;
|
|
88
|
+
screenshotRecords: VisualScreenshotRecord[];
|
|
89
|
+
notes: string[];
|
|
90
|
+
close: () => Promise<void>;
|
|
91
|
+
};
|
|
92
|
+
type VisualScenario<TAgent extends AnyAirJamAgentContract = AnyAirJamAgentContract> = {
|
|
93
|
+
id: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
run: (context: VisualScenarioContext<TAgent>) => Promise<void>;
|
|
96
|
+
};
|
|
97
|
+
type VisualScenarioPack<TAgent extends AnyAirJamAgentContract = AnyAirJamAgentContract> = {
|
|
98
|
+
scenarios: ReadonlyArray<VisualScenario<TAgent>>;
|
|
99
|
+
};
|
|
100
|
+
type VisualCaptureScenarioMetadata = {
|
|
101
|
+
gameId: string;
|
|
102
|
+
scenarioId: string;
|
|
103
|
+
scenarioDescription: string | null;
|
|
104
|
+
runtimeMode: VisualHarnessMode;
|
|
105
|
+
capturedAt: string;
|
|
106
|
+
status: "captured" | "failed";
|
|
107
|
+
urls: Omit<VisualHarnessUrls, "controllerJoinUrl"> | VisualHarnessUrls;
|
|
108
|
+
screenshots: Array<{
|
|
109
|
+
surface: "host" | "controller";
|
|
110
|
+
viewportName: string;
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
fileName: string;
|
|
114
|
+
relativePath: string;
|
|
115
|
+
}>;
|
|
116
|
+
notes: string[];
|
|
117
|
+
error: {
|
|
118
|
+
message: string;
|
|
119
|
+
stack: string | null;
|
|
120
|
+
} | null;
|
|
121
|
+
};
|
|
122
|
+
type VisualCaptureSummary = {
|
|
123
|
+
gameId: string;
|
|
124
|
+
mode: VisualHarnessMode;
|
|
125
|
+
secure: boolean;
|
|
126
|
+
capturedAt: string;
|
|
127
|
+
scenarios: Array<{
|
|
128
|
+
scenarioId: string;
|
|
129
|
+
status: "captured" | "failed";
|
|
130
|
+
screenshotCount: number;
|
|
131
|
+
relativeDir: string;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
type RunVisualCaptureCommandOptions = {
|
|
135
|
+
gameId: string;
|
|
136
|
+
scenarioId?: string | null;
|
|
137
|
+
mode?: VisualHarnessMode;
|
|
138
|
+
secure?: boolean;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type { InferVisualScenarioSnapshot as I, RunVisualCaptureCommandOptions as R, VisualScenarioPack as V, VisualHarnessMode as a, VisualViewport as b, VisualHarnessUrls as c, VisualHarnessPageSurface as d, VisualScenarioAgent as e, VisualScenario as f, VisualCaptureSummary as g, VisualScenarioContext as h, VisualScreenshotRecord as i, VisualQuerySurface as j, VisualScenarioAgentActionDescriptor as k, VisualScenarioAgentInvocation as l, VisualCaptureScenarioMetadata as m };
|
package/dist/visual.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import '@air-jam/sdk';
|
|
1
|
+
import { ad as CaptureVisualsOptions, ae as AirJamVisualArtifactMode, x as AirJamSurfaceUrlSummary, af as ListVisualScenariosOptions, ag as AirJamVisualScenarioList, ah as CaptureVisualsResult } from './types-CdYrgrG_.js';
|
|
2
|
+
export { z as AirJamVisualCaptureInspection, B as AirJamVisualCaptureSummary, ai as AirJamVisualScenarioMetadata } from './types-CdYrgrG_.js';
|
|
4
3
|
import '@air-jam/sdk/platform-machine';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '@air-jam/sdk/agent-tooling';
|
|
6
|
+
import './game-session-broker-CUvORfMd.js';
|
|
7
|
+
import './game-run-watch-CEd_SpAT.js';
|
|
8
|
+
import 'node:stream';
|
|
9
|
+
import '@air-jam/sdk';
|
|
10
|
+
import '@air-jam/sdk/core';
|
|
5
11
|
|
|
6
12
|
type CaptureVisualsAtRuntimeOptions = Pick<CaptureVisualsOptions, "cwd" | "gameId" | "scenarioId" | "secure"> & {
|
|
7
13
|
mode: AirJamVisualArtifactMode;
|
package/dist/visual.js
CHANGED
|
@@ -1,59 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
resolveDevtoolsHelperArgs,
|
|
3
|
-
resolveDevtoolsHelperScript,
|
|
4
2
|
startDev,
|
|
5
3
|
stopDev,
|
|
6
4
|
tryAttachToRunningDev
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
inspectGame
|
|
10
|
-
} from "./chunk-ZLPD7FY5.js";
|
|
5
|
+
} from "./chunk-MEIMOSZC.js";
|
|
11
6
|
import {
|
|
7
|
+
inspectGame,
|
|
8
|
+
pathExists,
|
|
9
|
+
readJsonFile,
|
|
12
10
|
runCommandResult
|
|
13
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ART5TEYT.js";
|
|
14
12
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "./chunk-
|
|
13
|
+
resolveDevtoolsHelperArgs,
|
|
14
|
+
resolveDevtoolsHelperScript
|
|
15
|
+
} from "./chunk-PKD4WVX5.js";
|
|
18
16
|
|
|
19
17
|
// src/visual.ts
|
|
20
|
-
import path2 from "path";
|
|
21
|
-
import { z } from "zod";
|
|
22
|
-
|
|
23
|
-
// src/tooling/airjam-agent-inspection.ts
|
|
24
18
|
import path from "path";
|
|
25
|
-
|
|
26
|
-
const startIndex = output.indexOf("{");
|
|
27
|
-
const endIndex = output.lastIndexOf("}");
|
|
28
|
-
if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {
|
|
29
|
-
throw new Error(`Expected JSON helper output but received:
|
|
30
|
-
${output}`);
|
|
31
|
-
}
|
|
32
|
-
return JSON.parse(output.slice(startIndex, endIndex + 1));
|
|
33
|
-
};
|
|
34
|
-
var inspectAirJamAgentConfig = async (configPath) => {
|
|
35
|
-
const result = runCommandResult({
|
|
36
|
-
command: process.execPath,
|
|
37
|
-
args: [
|
|
38
|
-
...resolveDevtoolsHelperArgs(
|
|
39
|
-
resolveDevtoolsHelperScript("inspect-airjam-agent.ts")
|
|
40
|
-
),
|
|
41
|
-
"--config",
|
|
42
|
-
configPath
|
|
43
|
-
],
|
|
44
|
-
cwd: path.dirname(configPath)
|
|
45
|
-
});
|
|
46
|
-
if (!result.ok) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Air Jam agent config helper failed.
|
|
49
|
-
|
|
50
|
-
${result.stderr || result.stdout}`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
return parseHelperJson(result.stdout);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/visual.ts
|
|
19
|
+
import { z } from "zod";
|
|
57
20
|
var captureUrlsSchema = z.object({
|
|
58
21
|
appOrigin: z.url(),
|
|
59
22
|
hostUrl: z.url(),
|
|
@@ -62,8 +25,8 @@ var captureUrlsSchema = z.object({
|
|
|
62
25
|
localBuildUrl: z.url().nullable(),
|
|
63
26
|
browserBuildUrl: z.url().nullable()
|
|
64
27
|
});
|
|
65
|
-
var resolveVisualArtifactRoot = (rootDir) =>
|
|
66
|
-
var
|
|
28
|
+
var resolveVisualArtifactRoot = (rootDir) => path.join(rootDir, ".airjam", "artifacts", "visual");
|
|
29
|
+
var parseHelperJson = (output) => {
|
|
67
30
|
const startIndex = output.indexOf("{");
|
|
68
31
|
const endIndex = output.lastIndexOf("}");
|
|
69
32
|
if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {
|
|
@@ -89,24 +52,16 @@ var runTsxHelper = ({
|
|
|
89
52
|
${result.stderr || result.stdout}`
|
|
90
53
|
);
|
|
91
54
|
}
|
|
92
|
-
return
|
|
93
|
-
};
|
|
94
|
-
var resolveVisualSource = async (configPath) => {
|
|
95
|
-
if (!configPath) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
const scenarioModulePath = await inspectAirJamAgentConfig(configPath).then(
|
|
99
|
-
(inspection) => inspection.visualScenariosModulePath
|
|
100
|
-
);
|
|
101
|
-
return scenarioModulePath ? { configPath, scenarioModulePath } : null;
|
|
55
|
+
return parseHelperJson(result.stdout);
|
|
102
56
|
};
|
|
57
|
+
var resolveVisualSource = (game) => game.declaration.testing ? { configPath: game.configPath } : null;
|
|
103
58
|
var readScenarioMetadata = async ({
|
|
104
59
|
artifactRoot,
|
|
105
60
|
summary
|
|
106
61
|
}) => {
|
|
107
62
|
const entries = await Promise.all(
|
|
108
63
|
summary.scenarios.map(async (scenario) => {
|
|
109
|
-
const metadataPath =
|
|
64
|
+
const metadataPath = path.join(
|
|
110
65
|
artifactRoot,
|
|
111
66
|
scenario.relativeDir,
|
|
112
67
|
"metadata.json"
|
|
@@ -123,10 +78,10 @@ var listVisualScenarios = async ({
|
|
|
123
78
|
gameId
|
|
124
79
|
} = {}) => {
|
|
125
80
|
const game = await inspectGame({ cwd, gameId });
|
|
126
|
-
const source =
|
|
81
|
+
const source = resolveVisualSource(game);
|
|
127
82
|
if (!source) {
|
|
128
83
|
throw new Error(
|
|
129
|
-
`No visual scenarios
|
|
84
|
+
`No visual scenarios declared for "${game.id}" in ${game.rootDir}.`
|
|
130
85
|
);
|
|
131
86
|
}
|
|
132
87
|
const result = runTsxHelper({
|
|
@@ -134,9 +89,11 @@ var listVisualScenarios = async ({
|
|
|
134
89
|
cwd: game.rootDir,
|
|
135
90
|
args: [`--config=${source.configPath}`]
|
|
136
91
|
});
|
|
92
|
+
if (!result.hasVisualScenarios)
|
|
93
|
+
throw new Error(`No visual scenarios declared for "${game.id}".`);
|
|
137
94
|
return {
|
|
138
95
|
gameId: result.gameId,
|
|
139
|
-
|
|
96
|
+
configPath: source.configPath,
|
|
140
97
|
scenarios: result.scenarios
|
|
141
98
|
};
|
|
142
99
|
};
|
|
@@ -148,10 +105,10 @@ var withVisualSession = async ({
|
|
|
148
105
|
run
|
|
149
106
|
}) => {
|
|
150
107
|
const game = await inspectGame({ cwd, gameId });
|
|
151
|
-
const visualSource =
|
|
108
|
+
const visualSource = resolveVisualSource(game);
|
|
152
109
|
if (!visualSource) {
|
|
153
110
|
throw new Error(
|
|
154
|
-
`No visual scenarios
|
|
111
|
+
`No visual scenarios declared for "${game.id}" in ${game.rootDir}.`
|
|
155
112
|
);
|
|
156
113
|
}
|
|
157
114
|
const attachedTopology = await tryAttachToRunningDev({
|
|
@@ -195,7 +152,6 @@ var captureGameAtRuntime = async ({
|
|
|
195
152
|
args: [
|
|
196
153
|
`--game-id=${game.id}`,
|
|
197
154
|
`--config=${visualSource.configPath}`,
|
|
198
|
-
`--module-path=${visualSource.scenarioModulePath}`,
|
|
199
155
|
`--artifact-root=${artifactRoot}`,
|
|
200
156
|
`--mode=${mode === "arcade-built" ? "arcade-test" : "standalone-dev"}`,
|
|
201
157
|
`--app-origin=${resolvedUrls.appOrigin}`,
|
|
@@ -208,7 +164,7 @@ var captureGameAtRuntime = async ({
|
|
|
208
164
|
...secure ? ["--secure"] : []
|
|
209
165
|
]
|
|
210
166
|
});
|
|
211
|
-
const summaryPath =
|
|
167
|
+
const summaryPath = path.join(artifactRoot, game.id, "capture-summary.json");
|
|
212
168
|
const summary = await readJsonFile(summaryPath);
|
|
213
169
|
return {
|
|
214
170
|
gameId: game.id,
|
|
@@ -224,10 +180,10 @@ var captureVisualsAtRuntime = async ({
|
|
|
224
180
|
...runtime
|
|
225
181
|
}) => {
|
|
226
182
|
const game = await inspectGame({ cwd, gameId });
|
|
227
|
-
const visualSource =
|
|
183
|
+
const visualSource = resolveVisualSource(game);
|
|
228
184
|
if (!visualSource) {
|
|
229
185
|
throw new Error(
|
|
230
|
-
`No visual scenarios
|
|
186
|
+
`No visual scenarios declared for "${game.id}" in ${game.rootDir}.`
|
|
231
187
|
);
|
|
232
188
|
}
|
|
233
189
|
return captureGameAtRuntime({ game, visualSource, ...runtime });
|
package/dist/visual.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/visual.ts","../src/tooling/airjam-agent-inspection.ts"],"sourcesContent":["import path from \"node:path\";\nimport { z } from \"zod\";\nimport { runCommandResult } from \"./commands.js\";\nimport {\n getTopology,\n startDev,\n stopDev,\n tryAttachToRunningDev,\n} from \"./dev.js\";\nimport { pathExists, readJsonFile } from \"./fs-utils.js\";\nimport { inspectGame } from \"./games.js\";\nimport {\n resolveDevtoolsHelperArgs,\n resolveDevtoolsHelperScript,\n} from \"./helper-scripts.js\";\nimport { inspectAirJamAgentConfig } from \"./tooling/airjam-agent-inspection.js\";\nimport type {\n AirJamSurfaceUrlSummary,\n AirJamVisualArtifactMode,\n AirJamVisualCaptureInspection,\n AirJamVisualCaptureSummary,\n AirJamVisualScenarioList,\n AirJamVisualScenarioMetadata,\n CaptureVisualsOptions,\n CaptureVisualsResult,\n ListVisualScenariosOptions,\n} from \"./types.js\";\n\nexport type {\n AirJamVisualArtifactMode,\n AirJamVisualCaptureInspection,\n AirJamVisualCaptureSummary,\n AirJamVisualScenarioList,\n AirJamVisualScenarioMetadata,\n CaptureVisualsOptions,\n CaptureVisualsResult,\n ListVisualScenariosOptions,\n} from \"./types.js\";\n\ntype ResolvedVisualSource = {\n configPath: string;\n scenarioModulePath: string;\n};\n\nconst captureUrlsSchema = z.object({\n appOrigin: z.url(),\n hostUrl: z.url(),\n controllerBaseUrl: z.url(),\n publicHost: z.url(),\n localBuildUrl: z.url().nullable(),\n browserBuildUrl: z.url().nullable(),\n});\n\nexport type CaptureVisualsAtRuntimeOptions = Pick<\n CaptureVisualsOptions,\n \"cwd\" | \"gameId\" | \"scenarioId\" | \"secure\"\n> & {\n mode: AirJamVisualArtifactMode;\n urls: AirJamSurfaceUrlSummary;\n artifactRoot: string;\n};\n\nconst resolveVisualArtifactRoot = (rootDir: string): string =>\n path.join(rootDir, \".airjam\", \"artifacts\", \"visual\");\n\nconst parseHelperJson = <T>(output: string): T => {\n const startIndex = output.indexOf(\"{\");\n const endIndex = output.lastIndexOf(\"}\");\n if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n throw new Error(`Expected JSON helper output but received:\\n${output}`);\n }\n\n return JSON.parse(output.slice(startIndex, endIndex + 1)) as T;\n};\n\nconst runTsxHelper = <T>({\n helperFile,\n args,\n cwd,\n}: {\n helperFile: string;\n args: string[];\n cwd: string;\n}): T => {\n const result = runCommandResult({\n command: process.execPath,\n args: [...resolveDevtoolsHelperArgs(helperFile), ...args],\n cwd,\n });\n if (!result.ok) {\n throw new Error(\n `Air Jam visual helper failed.\\n\\n${result.stderr || result.stdout}`,\n );\n }\n\n return parseHelperJson<T>(result.stdout);\n};\n\nconst resolveVisualSource = async (\n configPath: string | null,\n): Promise<ResolvedVisualSource | null> => {\n if (!configPath) {\n return null;\n }\n\n const scenarioModulePath = await inspectAirJamAgentConfig(configPath).then(\n (inspection) => inspection.visualScenariosModulePath,\n );\n return scenarioModulePath ? { configPath, scenarioModulePath } : null;\n};\n\nconst readScenarioMetadata = async ({\n artifactRoot,\n summary,\n}: {\n artifactRoot: string;\n summary: AirJamVisualCaptureInspection[\"summary\"];\n}): Promise<AirJamVisualScenarioMetadata[]> => {\n const entries = await Promise.all(\n summary.scenarios.map(async (scenario) => {\n const metadataPath = path.join(\n artifactRoot,\n scenario.relativeDir,\n \"metadata.json\",\n );\n return (await pathExists(metadataPath))\n ? readJsonFile<AirJamVisualScenarioMetadata>(metadataPath)\n : null;\n }),\n );\n\n return entries.filter(\n (entry): entry is AirJamVisualScenarioMetadata => entry !== null,\n );\n};\n\nexport const listVisualScenarios = async ({\n cwd = process.cwd(),\n gameId,\n}: ListVisualScenariosOptions = {}): Promise<AirJamVisualScenarioList> => {\n const game = await inspectGame({ cwd, gameId });\n const source = await resolveVisualSource(game.configPath);\n if (!source) {\n throw new Error(\n `No visual scenarios published for \"${game.id}\" in ${game.rootDir}.`,\n );\n }\n\n const result = runTsxHelper<{\n gameId: string;\n scenarios: AirJamVisualScenarioList[\"scenarios\"];\n }>({\n helperFile: resolveDevtoolsHelperScript(\"list-visual-scenarios.ts\"),\n cwd: game.rootDir,\n args: [`--config=${source.configPath}`],\n });\n return {\n gameId: result.gameId,\n scenarioModulePath: source.scenarioModulePath,\n scenarios: result.scenarios,\n };\n};\n\nconst withVisualSession = async <T>({\n cwd = process.cwd(),\n gameId,\n mode = \"standalone-dev\",\n secure = false,\n run,\n}: {\n cwd?: string;\n gameId?: string;\n mode?: \"standalone-dev\" | \"arcade-dev\" | \"arcade-test\";\n secure?: boolean;\n run: (input: {\n game: Awaited<ReturnType<typeof inspectGame>>;\n visualSource: ResolvedVisualSource;\n topology: Awaited<ReturnType<typeof getTopology>>;\n }) => Promise<T>;\n}): Promise<T> => {\n const game = await inspectGame({ cwd, gameId });\n const visualSource = await resolveVisualSource(game.configPath);\n if (!visualSource) {\n throw new Error(\n `No visual scenarios published for \"${game.id}\" in ${game.rootDir}.`,\n );\n }\n\n const attachedTopology = await tryAttachToRunningDev({\n cwd,\n gameId: game.id,\n mode,\n secure,\n });\n const session = attachedTopology\n ? {\n topology: attachedTopology,\n reusedExistingProcess: true,\n managedProcessId: attachedTopology.process?.id ?? null,\n }\n : await startDev({ cwd, gameId: game.id, mode, secure }).then(\n (started) => ({\n topology: started.topology,\n reusedExistingProcess: started.reusedExistingProcess,\n managedProcessId: started.process.id,\n }),\n );\n\n try {\n return await run({ game, visualSource, topology: session.topology });\n } finally {\n if (!session.reusedExistingProcess && session.managedProcessId) {\n await stopDev({ cwd, processId: session.managedProcessId });\n }\n }\n};\n\nconst captureGameAtRuntime = async ({\n game,\n visualSource,\n scenarioId,\n mode,\n secure,\n urls,\n artifactRoot,\n}: Omit<CaptureVisualsAtRuntimeOptions, \"cwd\" | \"gameId\"> & {\n game: Awaited<ReturnType<typeof inspectGame>>;\n visualSource: ResolvedVisualSource;\n}): Promise<CaptureVisualsResult> => {\n const resolvedUrls = captureUrlsSchema.parse(urls);\n runTsxHelper<AirJamVisualCaptureSummary>({\n helperFile: resolveDevtoolsHelperScript(\"run-visual-capture.ts\"),\n cwd: game.rootDir,\n args: [\n `--game-id=${game.id}`,\n `--config=${visualSource.configPath}`,\n `--module-path=${visualSource.scenarioModulePath}`,\n `--artifact-root=${artifactRoot}`,\n `--mode=${mode === \"arcade-built\" ? \"arcade-test\" : \"standalone-dev\"}`,\n `--app-origin=${resolvedUrls.appOrigin}`,\n `--host-url=${resolvedUrls.hostUrl}`,\n `--controller-base-url=${resolvedUrls.controllerBaseUrl}`,\n `--public-host=${resolvedUrls.publicHost}`,\n ...(resolvedUrls.localBuildUrl\n ? [`--local-build-url=${resolvedUrls.localBuildUrl}`]\n : []),\n ...(resolvedUrls.browserBuildUrl\n ? [`--browser-build-url=${resolvedUrls.browserBuildUrl}`]\n : []),\n ...(scenarioId ? [`--scenario-id=${scenarioId}`] : []),\n ...(secure ? [\"--secure\"] : []),\n ],\n });\n const summaryPath = path.join(artifactRoot, game.id, \"capture-summary.json\");\n const summary = await readJsonFile<AirJamVisualCaptureSummary>(summaryPath);\n return {\n gameId: game.id,\n artifactRoot,\n summaryPath,\n summary,\n scenarios: await readScenarioMetadata({ artifactRoot, summary }),\n };\n};\n\nexport const captureVisualsAtRuntime = async ({\n cwd = process.cwd(),\n gameId,\n ...runtime\n}: CaptureVisualsAtRuntimeOptions): Promise<CaptureVisualsResult> => {\n const game = await inspectGame({ cwd, gameId });\n const visualSource = await resolveVisualSource(game.configPath);\n if (!visualSource) {\n throw new Error(\n `No visual scenarios published for \"${game.id}\" in ${game.rootDir}.`,\n );\n }\n return captureGameAtRuntime({ game, visualSource, ...runtime });\n};\n\nexport const captureVisuals = async ({\n cwd = process.cwd(),\n gameId,\n scenarioId,\n mode = \"standalone-dev\",\n secure = false,\n}: CaptureVisualsOptions = {}): Promise<CaptureVisualsResult> =>\n withVisualSession({\n cwd,\n gameId,\n mode,\n secure,\n run: ({ game, visualSource, topology }) =>\n captureGameAtRuntime({\n game,\n visualSource,\n scenarioId,\n mode: mode === \"arcade-test\" ? \"arcade-built\" : \"standalone-dev\",\n secure,\n urls: topology.urls,\n artifactRoot: resolveVisualArtifactRoot(\n topology.process?.cwd ?? game.rootDir,\n ),\n }),\n });\n","import path from \"node:path\";\nimport { runCommandResult } from \"../commands.js\";\nimport {\n resolveDevtoolsHelperArgs,\n resolveDevtoolsHelperScript,\n} from \"../helper-scripts.js\";\n\ntype AirJamAgentInspection = {\n hasAgent: boolean;\n visualScenariosModulePath: string | null;\n};\n\nconst parseHelperJson = <T>(output: string): T => {\n const startIndex = output.indexOf(\"{\");\n const endIndex = output.lastIndexOf(\"}\");\n if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n throw new Error(`Expected JSON helper output but received:\\n${output}`);\n }\n\n return JSON.parse(output.slice(startIndex, endIndex + 1)) as T;\n};\n\nexport const inspectAirJamAgentConfig = async (\n configPath: string,\n): Promise<AirJamAgentInspection> => {\n const result = runCommandResult({\n command: process.execPath,\n args: [\n ...resolveDevtoolsHelperArgs(\n resolveDevtoolsHelperScript(\"inspect-airjam-agent.ts\"),\n ),\n \"--config\",\n configPath,\n ],\n cwd: path.dirname(configPath),\n });\n\n if (!result.ok) {\n throw new Error(\n `Air Jam agent config helper failed.\\n\\n${result.stderr || result.stdout}`,\n );\n }\n\n return parseHelperJson<AirJamAgentInspection>(result.stdout);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAOA,WAAU;AACjB,SAAS,SAAS;;;ACDlB,OAAO,UAAU;AAYjB,IAAM,kBAAkB,CAAI,WAAsB;AAChD,QAAM,aAAa,OAAO,QAAQ,GAAG;AACrC,QAAM,WAAW,OAAO,YAAY,GAAG;AACvC,MAAI,eAAe,MAAM,aAAa,MAAM,WAAW,YAAY;AACj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,oBAAoB,KAAK,UAAU;AAC9D,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR,sCAAsC,KAAK,EAAE,QAAQ,KAAK,OAAO;AAAA,IACnE;AAAA,EACF;AACA,SAAO,qBAAqB,EAAE,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChE;AAEO,IAAM,iBAAiB,OAAO;AAAA,EACnC,MAAM,QAAQ,IAAI;AAAA,EAClB;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,SAAS;AACX,IAA2B,CAAC,MAC1B,kBAAkB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,KAAK,CAAC,EAAE,MAAM,cAAc,SAAS,MACnC,qBAAqB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,SAAS,gBAAgB,iBAAiB;AAAA,IAChD;AAAA,IACA,MAAM,SAAS;AAAA,IACf,cAAc;AAAA,MACZ,SAAS,SAAS,OAAO,KAAK;AAAA,IAChC;AAAA,EACF,CAAC;AACL,CAAC;","names":["path","path","parseHelperJson"]}
|
|
1
|
+
{"version":3,"sources":["../src/visual.ts"],"sourcesContent":["import path from \"node:path\";\nimport { z } from \"zod\";\nimport { runCommandResult } from \"./commands.js\";\nimport {\n getTopology,\n startDev,\n stopDev,\n tryAttachToRunningDev,\n} from \"./dev.js\";\nimport { pathExists, readJsonFile } from \"./fs-utils.js\";\nimport { inspectGame } from \"./games.js\";\nimport {\n resolveDevtoolsHelperArgs,\n resolveDevtoolsHelperScript,\n} from \"./helper-scripts.js\";\nimport type {\n AirJamSurfaceUrlSummary,\n AirJamVisualArtifactMode,\n AirJamVisualCaptureInspection,\n AirJamVisualCaptureSummary,\n AirJamVisualScenarioList,\n AirJamVisualScenarioMetadata,\n CaptureVisualsOptions,\n CaptureVisualsResult,\n ListVisualScenariosOptions,\n} from \"./types.js\";\n\nexport type {\n AirJamVisualArtifactMode,\n AirJamVisualCaptureInspection,\n AirJamVisualCaptureSummary,\n AirJamVisualScenarioList,\n AirJamVisualScenarioMetadata,\n CaptureVisualsOptions,\n CaptureVisualsResult,\n ListVisualScenariosOptions,\n} from \"./types.js\";\n\ntype ResolvedVisualSource = {\n configPath: string;\n};\n\nconst captureUrlsSchema = z.object({\n appOrigin: z.url(),\n hostUrl: z.url(),\n controllerBaseUrl: z.url(),\n publicHost: z.url(),\n localBuildUrl: z.url().nullable(),\n browserBuildUrl: z.url().nullable(),\n});\n\nexport type CaptureVisualsAtRuntimeOptions = Pick<\n CaptureVisualsOptions,\n \"cwd\" | \"gameId\" | \"scenarioId\" | \"secure\"\n> & {\n mode: AirJamVisualArtifactMode;\n urls: AirJamSurfaceUrlSummary;\n artifactRoot: string;\n};\n\nconst resolveVisualArtifactRoot = (rootDir: string): string =>\n path.join(rootDir, \".airjam\", \"artifacts\", \"visual\");\n\nconst parseHelperJson = <T>(output: string): T => {\n const startIndex = output.indexOf(\"{\");\n const endIndex = output.lastIndexOf(\"}\");\n if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {\n throw new Error(`Expected JSON helper output but received:\\n${output}`);\n }\n\n return JSON.parse(output.slice(startIndex, endIndex + 1)) as T;\n};\n\nconst runTsxHelper = <T>({\n helperFile,\n args,\n cwd,\n}: {\n helperFile: string;\n args: string[];\n cwd: string;\n}): T => {\n const result = runCommandResult({\n command: process.execPath,\n args: [...resolveDevtoolsHelperArgs(helperFile), ...args],\n cwd,\n });\n if (!result.ok) {\n throw new Error(\n `Air Jam visual helper failed.\\n\\n${result.stderr || result.stdout}`,\n );\n }\n\n return parseHelperJson<T>(result.stdout);\n};\n\nconst resolveVisualSource = (\n game: Awaited<ReturnType<typeof inspectGame>>,\n): ResolvedVisualSource | null =>\n game.declaration.testing ? { configPath: game.configPath } : null;\n\nconst readScenarioMetadata = async ({\n artifactRoot,\n summary,\n}: {\n artifactRoot: string;\n summary: AirJamVisualCaptureInspection[\"summary\"];\n}): Promise<AirJamVisualScenarioMetadata[]> => {\n const entries = await Promise.all(\n summary.scenarios.map(async (scenario) => {\n const metadataPath = path.join(\n artifactRoot,\n scenario.relativeDir,\n \"metadata.json\",\n );\n return (await pathExists(metadataPath))\n ? readJsonFile<AirJamVisualScenarioMetadata>(metadataPath)\n : null;\n }),\n );\n\n return entries.filter(\n (entry): entry is AirJamVisualScenarioMetadata => entry !== null,\n );\n};\n\nexport const listVisualScenarios = async ({\n cwd = process.cwd(),\n gameId,\n}: ListVisualScenariosOptions = {}): Promise<AirJamVisualScenarioList> => {\n const game = await inspectGame({ cwd, gameId });\n const source = resolveVisualSource(game);\n if (!source) {\n throw new Error(\n `No visual scenarios declared for \"${game.id}\" in ${game.rootDir}.`,\n );\n }\n\n const result = runTsxHelper<{\n hasVisualScenarios: boolean;\n gameId: string;\n scenarios: AirJamVisualScenarioList[\"scenarios\"];\n }>({\n helperFile: resolveDevtoolsHelperScript(\"list-visual-scenarios.ts\"),\n cwd: game.rootDir,\n args: [`--config=${source.configPath}`],\n });\n if (!result.hasVisualScenarios)\n throw new Error(`No visual scenarios declared for \"${game.id}\".`);\n return {\n gameId: result.gameId,\n configPath: source.configPath,\n scenarios: result.scenarios,\n };\n};\n\nconst withVisualSession = async <T>({\n cwd = process.cwd(),\n gameId,\n mode = \"standalone-dev\",\n secure = false,\n run,\n}: {\n cwd?: string;\n gameId?: string;\n mode?: \"standalone-dev\" | \"arcade-dev\" | \"arcade-test\";\n secure?: boolean;\n run: (input: {\n game: Awaited<ReturnType<typeof inspectGame>>;\n visualSource: ResolvedVisualSource;\n topology: Awaited<ReturnType<typeof getTopology>>;\n }) => Promise<T>;\n}): Promise<T> => {\n const game = await inspectGame({ cwd, gameId });\n const visualSource = resolveVisualSource(game);\n if (!visualSource) {\n throw new Error(\n `No visual scenarios declared for \"${game.id}\" in ${game.rootDir}.`,\n );\n }\n\n const attachedTopology = await tryAttachToRunningDev({\n cwd,\n gameId: game.id,\n mode,\n secure,\n });\n const session = attachedTopology\n ? {\n topology: attachedTopology,\n reusedExistingProcess: true,\n managedProcessId: attachedTopology.process?.id ?? null,\n }\n : await startDev({ cwd, gameId: game.id, mode, secure }).then(\n (started) => ({\n topology: started.topology,\n reusedExistingProcess: started.reusedExistingProcess,\n managedProcessId: started.process.id,\n }),\n );\n\n try {\n return await run({ game, visualSource, topology: session.topology });\n } finally {\n if (!session.reusedExistingProcess && session.managedProcessId) {\n await stopDev({ cwd, processId: session.managedProcessId });\n }\n }\n};\n\nconst captureGameAtRuntime = async ({\n game,\n visualSource,\n scenarioId,\n mode,\n secure,\n urls,\n artifactRoot,\n}: Omit<CaptureVisualsAtRuntimeOptions, \"cwd\" | \"gameId\"> & {\n game: Awaited<ReturnType<typeof inspectGame>>;\n visualSource: ResolvedVisualSource;\n}): Promise<CaptureVisualsResult> => {\n const resolvedUrls = captureUrlsSchema.parse(urls);\n runTsxHelper<AirJamVisualCaptureSummary>({\n helperFile: resolveDevtoolsHelperScript(\"run-visual-capture.ts\"),\n cwd: game.rootDir,\n args: [\n `--game-id=${game.id}`,\n `--config=${visualSource.configPath}`,\n `--artifact-root=${artifactRoot}`,\n `--mode=${mode === \"arcade-built\" ? \"arcade-test\" : \"standalone-dev\"}`,\n `--app-origin=${resolvedUrls.appOrigin}`,\n `--host-url=${resolvedUrls.hostUrl}`,\n `--controller-base-url=${resolvedUrls.controllerBaseUrl}`,\n `--public-host=${resolvedUrls.publicHost}`,\n ...(resolvedUrls.localBuildUrl\n ? [`--local-build-url=${resolvedUrls.localBuildUrl}`]\n : []),\n ...(resolvedUrls.browserBuildUrl\n ? [`--browser-build-url=${resolvedUrls.browserBuildUrl}`]\n : []),\n ...(scenarioId ? [`--scenario-id=${scenarioId}`] : []),\n ...(secure ? [\"--secure\"] : []),\n ],\n });\n const summaryPath = path.join(artifactRoot, game.id, \"capture-summary.json\");\n const summary = await readJsonFile<AirJamVisualCaptureSummary>(summaryPath);\n return {\n gameId: game.id,\n artifactRoot,\n summaryPath,\n summary,\n scenarios: await readScenarioMetadata({ artifactRoot, summary }),\n };\n};\n\nexport const captureVisualsAtRuntime = async ({\n cwd = process.cwd(),\n gameId,\n ...runtime\n}: CaptureVisualsAtRuntimeOptions): Promise<CaptureVisualsResult> => {\n const game = await inspectGame({ cwd, gameId });\n const visualSource = resolveVisualSource(game);\n if (!visualSource) {\n throw new Error(\n `No visual scenarios declared for \"${game.id}\" in ${game.rootDir}.`,\n );\n }\n return captureGameAtRuntime({ game, visualSource, ...runtime });\n};\n\nexport const captureVisuals = async ({\n cwd = process.cwd(),\n gameId,\n scenarioId,\n mode = \"standalone-dev\",\n secure = false,\n}: CaptureVisualsOptions = {}): Promise<CaptureVisualsResult> =>\n withVisualSession({\n cwd,\n gameId,\n mode,\n secure,\n run: ({ game, visualSource, topology }) =>\n captureGameAtRuntime({\n game,\n visualSource,\n scenarioId,\n mode: mode === \"arcade-test\" ? \"arcade-built\" : \"standalone-dev\",\n secure,\n urls: topology.urls,\n artifactRoot: resolveVisualArtifactRoot(\n topology.process?.cwd ?? game.rootDir,\n ),\n }),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAS,SAAS;AAyClB,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACjC,WAAW,EAAE,IAAI;AAAA,EACjB,SAAS,EAAE,IAAI;AAAA,EACf,mBAAmB,EAAE,IAAI;AAAA,EACzB,YAAY,EAAE,IAAI;AAAA,EAClB,eAAe,EAAE,IAAI,EAAE,SAAS;AAAA,EAChC,iBAAiB,EAAE,IAAI,EAAE,SAAS;AACpC,CAAC;AAWD,IAAM,4BAA4B,CAAC,YACjC,KAAK,KAAK,SAAS,WAAW,aAAa,QAAQ;AAErD,IAAM,kBAAkB,CAAI,WAAsB;AAChD,QAAM,aAAa,OAAO,QAAQ,GAAG;AACrC,QAAM,WAAW,OAAO,YAAY,GAAG;AACvC,MAAI,eAAe,MAAM,aAAa,MAAM,WAAW,YAAY;AACjE,UAAM,IAAI,MAAM;AAAA,EAA8C,MAAM,EAAE;AAAA,EACxE;AA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QAAM,eAAe,oBAAoB,IAAI;AAC7C,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI;AAAA,MACR,qCAAqC,KAAK,EAAE,QAAQ,KAAK,OAAO;AAAA,IAClE;AAAA,EACF;AACA,SAAO,qBAAqB,EAAE,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChE;AAEO,IAAM,iBAAiB,OAAO;AAAA,EACnC,MAAM,QAAQ,IAAI;AAAA,EAClB;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,SAAS;AACX,IAA2B,CAAC,MAC1B,kBAAkB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,KAAK,CAAC,EAAE,MAAM,cAAc,SAAS,MACnC,qBAAqB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,SAAS,gBAAgB,iBAAiB;AAAA,IAChD;AAAA,IACA,MAAM,SAAS;AAAA,IACf,cAAc;AAAA,MACZ,SAAS,SAAS,OAAO,KAAK;AAAA,IAChC;AAAA,EACF,CAAC;AACL,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@air-jam/devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"engines": {
|
|
5
|
-
"node": ">=22.
|
|
5
|
+
"node": ">=22.15.0"
|
|
6
6
|
},
|
|
7
7
|
"description": "Air Jam authoring, inspection and evaluation toolchain for CLI, MCP and Studio consumers",
|
|
8
8
|
"private": false,
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
"url": "https://github.com/vucinatim/air-jam/issues"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
|
+
"./game-runs": {
|
|
22
|
+
"types": "./dist/game-runs.d.ts",
|
|
23
|
+
"import": "./dist/game-runs.js"
|
|
24
|
+
},
|
|
25
|
+
"./testing": {
|
|
26
|
+
"types": "./dist/testing.d.ts",
|
|
27
|
+
"import": "./dist/testing.js"
|
|
28
|
+
},
|
|
21
29
|
"./harness/visual": {
|
|
22
30
|
"types": "./dist/harness/visual.d.ts",
|
|
23
31
|
"import": "./dist/harness/visual.js"
|
|
@@ -30,10 +38,6 @@
|
|
|
30
38
|
"types": "./dist/controller.d.ts",
|
|
31
39
|
"import": "./dist/controller.js"
|
|
32
40
|
},
|
|
33
|
-
"./agent": {
|
|
34
|
-
"types": "./dist/agent.d.ts",
|
|
35
|
-
"import": "./dist/agent.js"
|
|
36
|
-
},
|
|
37
41
|
"./context": {
|
|
38
42
|
"types": "./dist/context.d.ts",
|
|
39
43
|
"import": "./dist/context.js"
|
|
@@ -78,9 +82,38 @@
|
|
|
78
82
|
"types": "./dist/release.d.ts",
|
|
79
83
|
"import": "./dist/release.js"
|
|
80
84
|
},
|
|
85
|
+
"./rooms-check": {
|
|
86
|
+
"types": "./dist/rooms-check.d.ts",
|
|
87
|
+
"import": "./dist/rooms-check.js"
|
|
88
|
+
},
|
|
81
89
|
"./visual": {
|
|
82
90
|
"types": "./dist/visual.d.ts",
|
|
83
91
|
"import": "./dist/visual.js"
|
|
92
|
+
},
|
|
93
|
+
"./source-tree": {
|
|
94
|
+
"types": "./dist/source-tree-contract.d.ts",
|
|
95
|
+
"import": "./dist/source-tree-contract.js"
|
|
96
|
+
},
|
|
97
|
+
"./dependencies": {
|
|
98
|
+
"types": "./dist/dependencies.d.ts",
|
|
99
|
+
"import": "./dist/dependencies.js"
|
|
100
|
+
},
|
|
101
|
+
"./package.json": "./package.json",
|
|
102
|
+
"./game-builds": {
|
|
103
|
+
"types": "./dist/game-builds.d.ts",
|
|
104
|
+
"import": "./dist/game-builds.js"
|
|
105
|
+
},
|
|
106
|
+
"./platform-game-analytics": {
|
|
107
|
+
"types": "./dist/platform-game-analytics.d.ts",
|
|
108
|
+
"import": "./dist/platform-game-analytics.js"
|
|
109
|
+
},
|
|
110
|
+
"./platform-game-app-id": {
|
|
111
|
+
"types": "./dist/platform-game-app-id.d.ts",
|
|
112
|
+
"import": "./dist/platform-game-app-id.js"
|
|
113
|
+
},
|
|
114
|
+
"./game-settings": {
|
|
115
|
+
"types": "./dist/game-settings.d.ts",
|
|
116
|
+
"import": "./dist/game-settings.js"
|
|
84
117
|
}
|
|
85
118
|
},
|
|
86
119
|
"files": [
|
|
@@ -88,29 +121,33 @@
|
|
|
88
121
|
"src"
|
|
89
122
|
],
|
|
90
123
|
"dependencies": {
|
|
91
|
-
"@air-jam/sdk": "^0.
|
|
124
|
+
"@air-jam/sdk": "^1.0.0-beta.10",
|
|
125
|
+
"@air-jam/server": "^1.0.0-beta.10",
|
|
92
126
|
"cross-spawn": "^7.0.6",
|
|
93
127
|
"playwright-core": "^1.58.2",
|
|
94
|
-
"
|
|
95
|
-
"tsx": "
|
|
128
|
+
"proper-lockfile": "4.1.2",
|
|
129
|
+
"tsx": "4.20.6",
|
|
130
|
+
"ws": "^8.18.3",
|
|
96
131
|
"yauzl": "^3.2.1",
|
|
97
132
|
"yazl": "^3.3.1",
|
|
98
133
|
"zod": "^4.2.1"
|
|
99
134
|
},
|
|
100
135
|
"devDependencies": {
|
|
101
|
-
"@types/node": "^24.10.1",
|
|
102
136
|
"@types/cross-spawn": "^6.0.6",
|
|
137
|
+
"@types/node": "^24.10.1",
|
|
138
|
+
"@types/proper-lockfile": "4.1.4",
|
|
139
|
+
"@types/ws": "^8.18.1",
|
|
103
140
|
"@types/yauzl": "^2.10.3",
|
|
104
141
|
"@types/yazl": "^2.4.5",
|
|
105
|
-
"socket.io": "^4.8.1",
|
|
106
142
|
"tsup": "^8.5.1",
|
|
107
143
|
"typescript": "~5.9.3",
|
|
108
144
|
"vitest": "^3.2.4"
|
|
109
145
|
},
|
|
110
146
|
"scripts": {
|
|
111
|
-
"build": "node ../../scripts/ensure-workspace-package-build.mjs @air-jam/
|
|
112
|
-
"test": "node ../../scripts/ensure-workspace-package-build.mjs @air-jam/
|
|
147
|
+
"build": "node ../../scripts/ensure-workspace-package-build.mjs @air-jam/server && tsup",
|
|
148
|
+
"test": "node ../../scripts/ensure-workspace-package-build.mjs @air-jam/server && vitest run --config vitest.config.ts",
|
|
113
149
|
"test:watch": "vitest --config vitest.config.ts",
|
|
114
|
-
"
|
|
150
|
+
"perf:sanity": "tsx scripts/perf-sanity.ts",
|
|
151
|
+
"typecheck": "node ../../scripts/ensure-workspace-package-build.mjs @air-jam/devtools && tsc --noEmit && tsc -p tests/tsconfig.json --noEmit"
|
|
115
152
|
}
|
|
116
153
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** A response body exceeded its caller's transfer budget and was cancelled. */
|
|
2
|
+
export class BodyLimitError extends Error {}
|
|
3
|
+
|
|
4
|
+
/** Read a body as UTF-8 text, cancelling it on failure or beyond `maxBytes`. */
|
|
5
|
+
export async function readBoundedText(
|
|
6
|
+
body: ReadableStream<Uint8Array>,
|
|
7
|
+
maxBytes: number,
|
|
8
|
+
) {
|
|
9
|
+
const reader = body.getReader();
|
|
10
|
+
const chunks: Uint8Array[] = [];
|
|
11
|
+
let bytes = 0;
|
|
12
|
+
try {
|
|
13
|
+
while (true) {
|
|
14
|
+
const next = await reader.read();
|
|
15
|
+
if (next.done) break;
|
|
16
|
+
bytes += next.value.byteLength;
|
|
17
|
+
if (bytes > maxBytes)
|
|
18
|
+
throw new BodyLimitError(`Response exceeded ${maxBytes} bytes.`);
|
|
19
|
+
chunks.push(next.value);
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
await reader.cancel().catch(() => undefined);
|
|
23
|
+
throw error;
|
|
24
|
+
} finally {
|
|
25
|
+
reader.releaseLock();
|
|
26
|
+
}
|
|
27
|
+
return Buffer.concat(chunks, bytes).toString("utf8");
|
|
28
|
+
}
|