@air-jam/devtools 0.0.0-stage → 0.9.3
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/LICENSE +21 -0
- package/README.md +52 -2
- package/dist/agent.d.ts +15 -0
- package/dist/agent.js +19 -0
- package/dist/agent.js.map +1 -0
- package/dist/chunk-5YAARMW5.js +36 -0
- package/dist/chunk-5YAARMW5.js.map +1 -0
- package/dist/chunk-6WQODT37.js +1019 -0
- package/dist/chunk-6WQODT37.js.map +1 -0
- package/dist/chunk-CKFT2ZJE.js +801 -0
- package/dist/chunk-CKFT2ZJE.js.map +1 -0
- package/dist/chunk-ER3Q2C4G.js +358 -0
- package/dist/chunk-ER3Q2C4G.js.map +1 -0
- package/dist/chunk-GUEZP773.js +851 -0
- package/dist/chunk-GUEZP773.js.map +1 -0
- package/dist/chunk-HIDNI56E.js +33 -0
- package/dist/chunk-HIDNI56E.js.map +1 -0
- package/dist/chunk-QKXS5D35.js +43 -0
- package/dist/chunk-QKXS5D35.js.map +1 -0
- package/dist/chunk-S4LSCEVE.js +261 -0
- package/dist/chunk-S4LSCEVE.js.map +1 -0
- package/dist/chunk-VKMJO6VN.js +360 -0
- package/dist/chunk-VKMJO6VN.js.map +1 -0
- package/dist/chunk-WFUR3MXY.js +67 -0
- package/dist/chunk-WFUR3MXY.js.map +1 -0
- package/dist/chunk-XEMR7KUE.js +361 -0
- package/dist/chunk-XEMR7KUE.js.map +1 -0
- package/dist/chunk-ZLPD7FY5.js +191 -0
- package/dist/chunk-ZLPD7FY5.js.map +1 -0
- package/dist/context.d.ts +13 -0
- package/dist/context.js +9 -0
- package/dist/context.js.map +1 -0
- package/dist/controller.d.ts +41 -0
- package/dist/controller.js +30 -0
- package/dist/controller.js.map +1 -0
- package/dist/dev.d.ts +15 -0
- package/dist/dev.js +20 -0
- package/dist/dev.js.map +1 -0
- package/dist/game-session-broker.d.ts +57 -0
- package/dist/game-session-broker.js +235 -0
- package/dist/game-session-broker.js.map +1 -0
- package/dist/game-session.d.ts +13 -0
- package/dist/game-session.js +24 -0
- package/dist/game-session.js.map +1 -0
- package/dist/games.d.ts +21 -0
- package/dist/games.js +14 -0
- package/dist/games.js.map +1 -0
- package/dist/harness/visual.d.ts +321 -0
- package/dist/harness/visual.js +41 -0
- package/dist/harness/visual.js.map +1 -0
- package/dist/logs.d.ts +9 -0
- package/dist/logs.js +58 -0
- package/dist/logs.js.map +1 -0
- package/dist/mcp-config.d.ts +63 -0
- package/dist/mcp-config.js +190 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/platform-auth.d.ts +112 -0
- package/dist/platform-auth.js +37 -0
- package/dist/platform-auth.js.map +1 -0
- package/dist/platform-game-media.d.ts +309 -0
- package/dist/platform-game-media.js +168 -0
- package/dist/platform-game-media.js.map +1 -0
- package/dist/platform-games.d.ts +65 -0
- package/dist/platform-games.js +251 -0
- package/dist/platform-games.js.map +1 -0
- package/dist/quality.d.ts +10 -0
- package/dist/quality.js +63 -0
- package/dist/quality.js.map +1 -0
- package/dist/release.d.ts +1094 -0
- package/dist/release.js +1347 -0
- package/dist/release.js.map +1 -0
- package/dist/tooling/agent-contract.d.ts +2 -0
- package/dist/tooling/agent-contract.js +193 -0
- package/dist/tooling/agent-contract.js.map +1 -0
- package/dist/tooling/hold-runtime-host.d.ts +2 -0
- package/dist/tooling/hold-runtime-host.js +229 -0
- package/dist/tooling/hold-runtime-host.js.map +1 -0
- package/dist/tooling/inspect-airjam-agent.d.ts +2 -0
- package/dist/tooling/inspect-airjam-agent.js +37 -0
- package/dist/tooling/inspect-airjam-agent.js.map +1 -0
- package/dist/tooling/list-visual-scenarios.d.ts +2 -0
- package/dist/tooling/list-visual-scenarios.js +62 -0
- package/dist/tooling/list-visual-scenarios.js.map +1 -0
- package/dist/tooling/managed-dev-supervisor.d.ts +2 -0
- package/dist/tooling/managed-dev-supervisor.js +51 -0
- package/dist/tooling/managed-dev-supervisor.js.map +1 -0
- package/dist/tooling/run-visual-capture.d.ts +2 -0
- package/dist/tooling/run-visual-capture.js +167 -0
- package/dist/tooling/run-visual-capture.js.map +1 -0
- package/dist/types-C6NrHt88.d.ts +775 -0
- package/dist/visual.d.ts +15 -0
- package/dist/visual.js +263 -0
- package/dist/visual.js.map +1 -0
- package/package.json +113 -3
- package/src/agent.ts +380 -0
- package/src/commands.ts +40 -0
- package/src/context.ts +229 -0
- package/src/controller.ts +1376 -0
- package/src/dev.ts +999 -0
- package/src/fs-utils.ts +93 -0
- package/src/game-action-observation.ts +96 -0
- package/src/game-session-broker.ts +301 -0
- package/src/game-session.ts +459 -0
- package/src/games.ts +266 -0
- package/src/harness/visual/prefab-contract.ts +29 -0
- package/src/harness/visual/prefab-runner.ts +178 -0
- package/src/harness/visual/runner.ts +546 -0
- package/src/harness/visual/scenario-contract.ts +9 -0
- package/src/harness/visual/scenario-helpers.ts +63 -0
- package/src/harness/visual/session.ts +369 -0
- package/src/harness/visual/types.ts +181 -0
- package/src/harness/visual.ts +7 -0
- package/src/helper-scripts.ts +49 -0
- package/src/logs.ts +67 -0
- package/src/mcp-config.ts +262 -0
- package/src/platform-auth.ts +455 -0
- package/src/platform-game-media.ts +209 -0
- package/src/platform-games.ts +315 -0
- package/src/quality.ts +82 -0
- package/src/release.ts +1697 -0
- package/src/runtime-owner-protocol.ts +130 -0
- package/src/tooling/agent-contract.ts +232 -0
- package/src/tooling/agent-declaration.ts +36 -0
- package/src/tooling/airjam-agent-inspection.ts +45 -0
- package/src/tooling/airjam-agent.ts +118 -0
- package/src/tooling/hold-runtime-host.ts +224 -0
- package/src/tooling/inspect-airjam-agent.ts +20 -0
- package/src/tooling/list-visual-scenarios.ts +64 -0
- package/src/tooling/managed-dev-supervisor.ts +71 -0
- package/src/tooling/run-visual-capture.ts +217 -0
- package/src/tooling/runtime-owner-actions.ts +42 -0
- package/src/tooling/visual-pack.ts +46 -0
- package/src/types.ts +951 -0
- package/src/visual.ts +304 -0
- package/src/workspace-contract.ts +32 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { h as AirJamRuntimeOwnerScreenshot, i as AirJamVirtualControllerSessionSummary, C as ConnectControllerOptions, j as AirJamVirtualControllerSession, S as SendControllerInputOptions, k as SendControllerInputResult, l as InvokeControllerActionOptions, m as InvokeControllerActionResult, n as ReadRuntimeSnapshotOptions, o as AirJamRuntimeSnapshotInspection, D as DisconnectControllerOptions, p as DisconnectControllerResult } from './types-C6NrHt88.js';
|
|
2
|
+
export { q as AirJamRuntimeStoreSnapshot } from './types-C6NrHt88.js';
|
|
3
|
+
import '@air-jam/sdk';
|
|
4
|
+
import '@air-jam/sdk/platform-machine';
|
|
5
|
+
|
|
6
|
+
declare const captureControllerSessionVisuals: ({ controllerSessionId, relativeDir, timeoutMs, }: {
|
|
7
|
+
controllerSessionId: string;
|
|
8
|
+
relativeDir: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
capturedAt: string;
|
|
12
|
+
screenshots: AirJamRuntimeOwnerScreenshot[];
|
|
13
|
+
}>;
|
|
14
|
+
declare const ownsControllerSessionHost: (controllerSessionId: string) => boolean;
|
|
15
|
+
declare const inspectControllerSessionContext: (controllerSessionId: string) => {
|
|
16
|
+
cwd: string;
|
|
17
|
+
gameId: string | null;
|
|
18
|
+
controllerId: string;
|
|
19
|
+
session: AirJamVirtualControllerSessionSummary;
|
|
20
|
+
};
|
|
21
|
+
declare const resolveControllerSessionGameRuntime: ({ controllerSessionId, timeoutMs, }: {
|
|
22
|
+
controllerSessionId: string;
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
gameId: string | null;
|
|
26
|
+
defaultStoreDomain: string;
|
|
27
|
+
}>;
|
|
28
|
+
declare const connectController: ({ cwd, gameId, mode, secure, roomId, controllerJoinUrl, controllerId, deviceId, nickname, avatarId, capabilityToken, timeoutMs, }?: ConnectControllerOptions) => Promise<AirJamVirtualControllerSession>;
|
|
29
|
+
declare const sendControllerInput: ({ controllerSessionId, input, }: SendControllerInputOptions) => Promise<SendControllerInputResult>;
|
|
30
|
+
declare const invokeControllerAction: ({ controllerSessionId, actionName, storeDomain, payload, }: InvokeControllerActionOptions) => Promise<InvokeControllerActionResult>;
|
|
31
|
+
declare const invokeHostAction: ({ controllerSessionId, actionName, storeDomain, payload, timeoutMs, }: {
|
|
32
|
+
controllerSessionId: string;
|
|
33
|
+
actionName: string;
|
|
34
|
+
storeDomain: string;
|
|
35
|
+
payload?: Record<string, unknown>;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
}) => Promise<InvokeControllerActionResult>;
|
|
38
|
+
declare const readRuntimeSnapshot: ({ controllerSessionId, storeDomains, requestSync, timeoutMs, }: ReadRuntimeSnapshotOptions) => Promise<AirJamRuntimeSnapshotInspection>;
|
|
39
|
+
declare const disconnectController: ({ controllerSessionId, }: DisconnectControllerOptions) => Promise<DisconnectControllerResult>;
|
|
40
|
+
|
|
41
|
+
export { AirJamRuntimeSnapshotInspection, AirJamVirtualControllerSession, AirJamVirtualControllerSessionSummary, ConnectControllerOptions, DisconnectControllerOptions, DisconnectControllerResult, InvokeControllerActionOptions, InvokeControllerActionResult, ReadRuntimeSnapshotOptions, SendControllerInputOptions, SendControllerInputResult, captureControllerSessionVisuals, connectController, disconnectController, inspectControllerSessionContext, invokeControllerAction, invokeHostAction, ownsControllerSessionHost, readRuntimeSnapshot, resolveControllerSessionGameRuntime, sendControllerInput };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
captureControllerSessionVisuals,
|
|
3
|
+
connectController,
|
|
4
|
+
disconnectController,
|
|
5
|
+
inspectControllerSessionContext,
|
|
6
|
+
invokeControllerAction,
|
|
7
|
+
invokeHostAction,
|
|
8
|
+
ownsControllerSessionHost,
|
|
9
|
+
readRuntimeSnapshot,
|
|
10
|
+
resolveControllerSessionGameRuntime,
|
|
11
|
+
sendControllerInput
|
|
12
|
+
} from "./chunk-6WQODT37.js";
|
|
13
|
+
import "./chunk-QKXS5D35.js";
|
|
14
|
+
import "./chunk-CKFT2ZJE.js";
|
|
15
|
+
import "./chunk-ZLPD7FY5.js";
|
|
16
|
+
import "./chunk-5YAARMW5.js";
|
|
17
|
+
import "./chunk-S4LSCEVE.js";
|
|
18
|
+
export {
|
|
19
|
+
captureControllerSessionVisuals,
|
|
20
|
+
connectController,
|
|
21
|
+
disconnectController,
|
|
22
|
+
inspectControllerSessionContext,
|
|
23
|
+
invokeControllerAction,
|
|
24
|
+
invokeHostAction,
|
|
25
|
+
ownsControllerSessionHost,
|
|
26
|
+
readRuntimeSnapshot,
|
|
27
|
+
resolveControllerSessionGameRuntime,
|
|
28
|
+
sendControllerInput
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { G as GetTopologyOptions, r as AirJamRuntimeTopology, s as GetDevStatusOptions, t as AirJamDevStatus, u as StartDevOptions, v as StartDevResult, w as StopDevOptions, x as StopDevResult, y as ResetLocalDevOptions, z as ResetLocalDevResult } from './types-C6NrHt88.js';
|
|
2
|
+
export { B as AirJamDevMode, E as AirJamManagedDevProcess, F as AirJamSurfaceUrlSummary } from './types-C6NrHt88.js';
|
|
3
|
+
import '@air-jam/sdk';
|
|
4
|
+
import '@air-jam/sdk/platform-machine';
|
|
5
|
+
|
|
6
|
+
declare const tryAttachToRunningDev: ({ cwd, gameId, mode, secure, timeoutMs, }?: GetTopologyOptions & {
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}) => Promise<AirJamRuntimeTopology | null>;
|
|
9
|
+
declare const getDevStatus: ({ cwd, }?: GetDevStatusOptions) => Promise<AirJamDevStatus>;
|
|
10
|
+
declare const getTopology: ({ cwd, gameId, mode, secure, }?: GetTopologyOptions) => Promise<AirJamRuntimeTopology>;
|
|
11
|
+
declare const startDev: ({ cwd, gameId, mode, secure, }?: StartDevOptions) => Promise<StartDevResult>;
|
|
12
|
+
declare const stopDev: ({ cwd, processId, mode, }?: StopDevOptions) => Promise<StopDevResult>;
|
|
13
|
+
declare const resetLocalDev: ({ cwd, }?: ResetLocalDevOptions) => Promise<ResetLocalDevResult>;
|
|
14
|
+
|
|
15
|
+
export { AirJamDevStatus, AirJamRuntimeTopology, GetDevStatusOptions, GetTopologyOptions, ResetLocalDevOptions, ResetLocalDevResult, StartDevOptions, StartDevResult, StopDevOptions, StopDevResult, getDevStatus, getTopology, resetLocalDev, startDev, stopDev, tryAttachToRunningDev };
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDevStatus,
|
|
3
|
+
getTopology,
|
|
4
|
+
resetLocalDev,
|
|
5
|
+
startDev,
|
|
6
|
+
stopDev,
|
|
7
|
+
tryAttachToRunningDev
|
|
8
|
+
} from "./chunk-CKFT2ZJE.js";
|
|
9
|
+
import "./chunk-ZLPD7FY5.js";
|
|
10
|
+
import "./chunk-5YAARMW5.js";
|
|
11
|
+
import "./chunk-S4LSCEVE.js";
|
|
12
|
+
export {
|
|
13
|
+
getDevStatus,
|
|
14
|
+
getTopology,
|
|
15
|
+
resetLocalDev,
|
|
16
|
+
startDev,
|
|
17
|
+
stopDev,
|
|
18
|
+
tryAttachToRunningDev
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { O as OpenGameSessionOptions, K as ReadGameSessionOptions, M as SendGameSessionInputOptions, P as InvokeGameSessionActionOptions, T as CaptureGameSessionVisualsOptions, V as CloseGameSessionOptions } from './types-C6NrHt88.js';
|
|
2
|
+
import '@air-jam/sdk';
|
|
3
|
+
import '@air-jam/sdk/platform-machine';
|
|
4
|
+
|
|
5
|
+
type AirJamGameSessionBrokerState = {
|
|
6
|
+
schemaVersion: 1;
|
|
7
|
+
instanceId: string;
|
|
8
|
+
pid: number;
|
|
9
|
+
projectDir: string;
|
|
10
|
+
origin: string;
|
|
11
|
+
secret: string;
|
|
12
|
+
startedAt: string;
|
|
13
|
+
};
|
|
14
|
+
type AirJamGameSessionBrokerOperation = {
|
|
15
|
+
operation: "health";
|
|
16
|
+
input?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
operation: "open";
|
|
19
|
+
input: OpenGameSessionOptions;
|
|
20
|
+
} | {
|
|
21
|
+
operation: "read";
|
|
22
|
+
input: ReadGameSessionOptions;
|
|
23
|
+
} | {
|
|
24
|
+
operation: "input";
|
|
25
|
+
input: SendGameSessionInputOptions;
|
|
26
|
+
} | {
|
|
27
|
+
operation: "invoke";
|
|
28
|
+
input: InvokeGameSessionActionOptions;
|
|
29
|
+
} | {
|
|
30
|
+
operation: "capture";
|
|
31
|
+
input: CaptureGameSessionVisualsOptions;
|
|
32
|
+
} | {
|
|
33
|
+
operation: "close";
|
|
34
|
+
input: CloseGameSessionOptions;
|
|
35
|
+
} | {
|
|
36
|
+
operation: "shutdown";
|
|
37
|
+
input?: undefined;
|
|
38
|
+
};
|
|
39
|
+
type AirJamGameSessionBrokerHealth = {
|
|
40
|
+
ok: true;
|
|
41
|
+
instanceId: string;
|
|
42
|
+
pid: number;
|
|
43
|
+
projectDir: string;
|
|
44
|
+
activeSessionCount: number;
|
|
45
|
+
startedAt: string;
|
|
46
|
+
};
|
|
47
|
+
declare const resolveGameSessionBrokerStatePath: (projectDir: string) => string;
|
|
48
|
+
declare const readGameSessionBrokerState: (projectDir: string) => Promise<AirJamGameSessionBrokerState | null>;
|
|
49
|
+
declare const requestGameSessionBroker: <TResult>({ state, request, }: {
|
|
50
|
+
state: AirJamGameSessionBrokerState;
|
|
51
|
+
request: AirJamGameSessionBrokerOperation;
|
|
52
|
+
}) => Promise<TResult>;
|
|
53
|
+
declare const runGameSessionBroker: ({ projectDir, }: {
|
|
54
|
+
projectDir: string;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
|
|
57
|
+
export { type AirJamGameSessionBrokerHealth, type AirJamGameSessionBrokerOperation, type AirJamGameSessionBrokerState, readGameSessionBrokerState, requestGameSessionBroker, resolveGameSessionBrokerStatePath, runGameSessionBroker };
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
captureGameSessionVisuals,
|
|
3
|
+
closeGameSession,
|
|
4
|
+
invokeGameSessionAction,
|
|
5
|
+
openGameSession,
|
|
6
|
+
readGameSession,
|
|
7
|
+
sendGameSessionInput
|
|
8
|
+
} from "./chunk-ER3Q2C4G.js";
|
|
9
|
+
import "./chunk-XEMR7KUE.js";
|
|
10
|
+
import "./chunk-6WQODT37.js";
|
|
11
|
+
import "./chunk-QKXS5D35.js";
|
|
12
|
+
import "./chunk-CKFT2ZJE.js";
|
|
13
|
+
import "./chunk-ZLPD7FY5.js";
|
|
14
|
+
import "./chunk-5YAARMW5.js";
|
|
15
|
+
import "./chunk-S4LSCEVE.js";
|
|
16
|
+
|
|
17
|
+
// src/game-session-broker.ts
|
|
18
|
+
import { randomBytes, randomUUID } from "crypto";
|
|
19
|
+
import { chmod, mkdir, readFile, unlink, writeFile } from "fs/promises";
|
|
20
|
+
import {
|
|
21
|
+
createServer
|
|
22
|
+
} from "http";
|
|
23
|
+
import path from "path";
|
|
24
|
+
var BROKER_STATE_RELATIVE_PATH = path.join(
|
|
25
|
+
".airjam",
|
|
26
|
+
"devtools",
|
|
27
|
+
"game-session-broker.json"
|
|
28
|
+
);
|
|
29
|
+
var REQUEST_BODY_LIMIT_BYTES = 1048576;
|
|
30
|
+
var resolveGameSessionBrokerStatePath = (projectDir) => path.join(projectDir, BROKER_STATE_RELATIVE_PATH);
|
|
31
|
+
var readGameSessionBrokerState = async (projectDir) => {
|
|
32
|
+
try {
|
|
33
|
+
const value = JSON.parse(
|
|
34
|
+
await readFile(resolveGameSessionBrokerStatePath(projectDir), "utf8")
|
|
35
|
+
);
|
|
36
|
+
if (value.schemaVersion !== 1 || typeof value.instanceId !== "string" || typeof value.pid !== "number" || typeof value.projectDir !== "string" || typeof value.origin !== "string" || typeof value.secret !== "string" || typeof value.startedAt !== "string") {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var readJsonBody = async (request) => {
|
|
45
|
+
const chunks = [];
|
|
46
|
+
let size = 0;
|
|
47
|
+
for await (const chunk of request) {
|
|
48
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
49
|
+
size += buffer.length;
|
|
50
|
+
if (size > REQUEST_BODY_LIMIT_BYTES) {
|
|
51
|
+
throw new Error("Game session broker request exceeds 1 MiB.");
|
|
52
|
+
}
|
|
53
|
+
chunks.push(buffer);
|
|
54
|
+
}
|
|
55
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
56
|
+
};
|
|
57
|
+
var writeJson = (response, statusCode, value) => {
|
|
58
|
+
response.writeHead(statusCode, {
|
|
59
|
+
"content-type": "application/json; charset=utf-8",
|
|
60
|
+
"cache-control": "no-store"
|
|
61
|
+
});
|
|
62
|
+
response.end(`${JSON.stringify(value)}
|
|
63
|
+
`);
|
|
64
|
+
};
|
|
65
|
+
var requestGameSessionBroker = async ({
|
|
66
|
+
state,
|
|
67
|
+
request
|
|
68
|
+
}) => {
|
|
69
|
+
const timeoutMs = request.operation === "open" ? Math.max(12e4, (request.input.timeoutMs ?? 0) + 6e4) : request.operation === "read" || request.operation === "invoke" || request.operation === "capture" ? Math.max(3e4, (request.input.timeoutMs ?? 0) + 1e4) : 3e4;
|
|
70
|
+
const response = await fetch(`${state.origin}/v1/game-session`, {
|
|
71
|
+
method: "POST",
|
|
72
|
+
headers: {
|
|
73
|
+
authorization: `Bearer ${state.secret}`,
|
|
74
|
+
"content-type": "application/json"
|
|
75
|
+
},
|
|
76
|
+
body: JSON.stringify(request),
|
|
77
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
78
|
+
});
|
|
79
|
+
const result = await response.json();
|
|
80
|
+
if (!response.ok || result.ok !== true) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
result.error?.message ?? `Game session broker request failed with HTTP ${response.status}.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return result.result;
|
|
86
|
+
};
|
|
87
|
+
var runGameSessionBroker = async ({
|
|
88
|
+
projectDir
|
|
89
|
+
}) => {
|
|
90
|
+
const resolvedProjectDir = path.resolve(projectDir);
|
|
91
|
+
const statePath = resolveGameSessionBrokerStatePath(resolvedProjectDir);
|
|
92
|
+
const instanceId = randomUUID();
|
|
93
|
+
const secret = randomBytes(32).toString("base64url");
|
|
94
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
95
|
+
const activeSessionIds = /* @__PURE__ */ new Set();
|
|
96
|
+
let shuttingDown = false;
|
|
97
|
+
let shutdownCleanup = Promise.resolve();
|
|
98
|
+
const closeActiveSessions = async () => {
|
|
99
|
+
await Promise.all(
|
|
100
|
+
[...activeSessionIds].map(
|
|
101
|
+
(gameSessionId) => closeGameSession({ gameSessionId }).catch(() => void 0)
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
activeSessionIds.clear();
|
|
105
|
+
};
|
|
106
|
+
const server = createServer(async (request, response) => {
|
|
107
|
+
if (request.method !== "POST" || request.url !== "/v1/game-session") {
|
|
108
|
+
writeJson(response, 404, { ok: false, error: { message: "Not found." } });
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (request.headers.authorization !== `Bearer ${secret}`) {
|
|
112
|
+
writeJson(response, 401, {
|
|
113
|
+
ok: false,
|
|
114
|
+
error: { message: "Invalid game session broker credentials." }
|
|
115
|
+
});
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const operation = await readJsonBody(
|
|
120
|
+
request
|
|
121
|
+
);
|
|
122
|
+
let result;
|
|
123
|
+
switch (operation.operation) {
|
|
124
|
+
case "health":
|
|
125
|
+
result = {
|
|
126
|
+
ok: true,
|
|
127
|
+
instanceId,
|
|
128
|
+
pid: process.pid,
|
|
129
|
+
projectDir: resolvedProjectDir,
|
|
130
|
+
activeSessionCount: activeSessionIds.size,
|
|
131
|
+
startedAt
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
case "open": {
|
|
135
|
+
const opened = await openGameSession({
|
|
136
|
+
...operation.input,
|
|
137
|
+
cwd: resolvedProjectDir
|
|
138
|
+
});
|
|
139
|
+
activeSessionIds.add(opened.gameSessionId);
|
|
140
|
+
result = opened;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "read":
|
|
144
|
+
result = await readGameSession(operation.input);
|
|
145
|
+
break;
|
|
146
|
+
case "input":
|
|
147
|
+
result = await sendGameSessionInput(operation.input);
|
|
148
|
+
break;
|
|
149
|
+
case "invoke":
|
|
150
|
+
result = await invokeGameSessionAction(operation.input);
|
|
151
|
+
break;
|
|
152
|
+
case "capture":
|
|
153
|
+
result = await captureGameSessionVisuals(operation.input);
|
|
154
|
+
break;
|
|
155
|
+
case "close":
|
|
156
|
+
result = await closeGameSession(operation.input);
|
|
157
|
+
activeSessionIds.delete(operation.input.gameSessionId);
|
|
158
|
+
break;
|
|
159
|
+
case "shutdown":
|
|
160
|
+
await closeActiveSessions();
|
|
161
|
+
result = { stopped: true, instanceId };
|
|
162
|
+
shuttingDown = true;
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
throw new Error("Unknown game session broker operation.");
|
|
166
|
+
}
|
|
167
|
+
writeJson(response, 200, { ok: true, result });
|
|
168
|
+
if (shuttingDown) {
|
|
169
|
+
server.close();
|
|
170
|
+
}
|
|
171
|
+
} catch (error) {
|
|
172
|
+
writeJson(response, 400, {
|
|
173
|
+
ok: false,
|
|
174
|
+
error: {
|
|
175
|
+
message: error instanceof Error ? error.message : String(error)
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
const cleanupState = async () => {
|
|
181
|
+
const current = await readGameSessionBrokerState(resolvedProjectDir);
|
|
182
|
+
if (current?.instanceId === instanceId) {
|
|
183
|
+
await unlink(statePath).catch(() => void 0);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const stop = () => {
|
|
187
|
+
if (!shuttingDown) {
|
|
188
|
+
shuttingDown = true;
|
|
189
|
+
server.close();
|
|
190
|
+
shutdownCleanup = closeActiveSessions();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
process.once("SIGTERM", stop);
|
|
194
|
+
process.once("SIGINT", stop);
|
|
195
|
+
await new Promise((resolve, reject) => {
|
|
196
|
+
server.once("error", reject);
|
|
197
|
+
server.listen(0, "127.0.0.1", async () => {
|
|
198
|
+
try {
|
|
199
|
+
const address = server.address();
|
|
200
|
+
if (!address || typeof address === "string") {
|
|
201
|
+
throw new Error("Game session broker did not bind a TCP port.");
|
|
202
|
+
}
|
|
203
|
+
const state = {
|
|
204
|
+
schemaVersion: 1,
|
|
205
|
+
instanceId,
|
|
206
|
+
pid: process.pid,
|
|
207
|
+
projectDir: resolvedProjectDir,
|
|
208
|
+
origin: `http://127.0.0.1:${address.port}`,
|
|
209
|
+
secret,
|
|
210
|
+
startedAt
|
|
211
|
+
};
|
|
212
|
+
await mkdir(path.dirname(statePath), { recursive: true });
|
|
213
|
+
await writeFile(statePath, `${JSON.stringify(state, null, 2)}
|
|
214
|
+
`, {
|
|
215
|
+
encoding: "utf8",
|
|
216
|
+
mode: 384
|
|
217
|
+
});
|
|
218
|
+
await chmod(statePath, 384);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
server.close();
|
|
221
|
+
reject(error);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
server.once("close", resolve);
|
|
225
|
+
});
|
|
226
|
+
await shutdownCleanup;
|
|
227
|
+
await cleanupState();
|
|
228
|
+
};
|
|
229
|
+
export {
|
|
230
|
+
readGameSessionBrokerState,
|
|
231
|
+
requestGameSessionBroker,
|
|
232
|
+
resolveGameSessionBrokerStatePath,
|
|
233
|
+
runGameSessionBroker
|
|
234
|
+
};
|
|
235
|
+
//# sourceMappingURL=game-session-broker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/game-session-broker.ts"],"sourcesContent":["import { randomBytes, randomUUID } from \"node:crypto\";\nimport { chmod, mkdir, readFile, unlink, writeFile } from \"node:fs/promises\";\nimport {\n createServer,\n type IncomingMessage,\n type ServerResponse,\n} from \"node:http\";\nimport path from \"node:path\";\nimport {\n captureGameSessionVisuals,\n closeGameSession,\n invokeGameSessionAction,\n openGameSession,\n readGameSession,\n sendGameSessionInput,\n} from \"./game-session.js\";\nimport type {\n CaptureGameSessionVisualsOptions,\n CloseGameSessionOptions,\n InvokeGameSessionActionOptions,\n OpenGameSessionOptions,\n ReadGameSessionOptions,\n SendGameSessionInputOptions,\n} from \"./types.js\";\n\nexport type AirJamGameSessionBrokerState = {\n schemaVersion: 1;\n instanceId: string;\n pid: number;\n projectDir: string;\n origin: string;\n secret: string;\n startedAt: string;\n};\n\nexport type AirJamGameSessionBrokerOperation =\n | { operation: \"health\"; input?: undefined }\n | { operation: \"open\"; input: OpenGameSessionOptions }\n | { operation: \"read\"; input: ReadGameSessionOptions }\n | { operation: \"input\"; input: SendGameSessionInputOptions }\n | { operation: \"invoke\"; input: InvokeGameSessionActionOptions }\n | { operation: \"capture\"; input: CaptureGameSessionVisualsOptions }\n | { operation: \"close\"; input: CloseGameSessionOptions }\n | { operation: \"shutdown\"; input?: undefined };\n\nexport type AirJamGameSessionBrokerHealth = {\n ok: true;\n instanceId: string;\n pid: number;\n projectDir: string;\n activeSessionCount: number;\n startedAt: string;\n};\n\nconst BROKER_STATE_RELATIVE_PATH = path.join(\n \".airjam\",\n \"devtools\",\n \"game-session-broker.json\",\n);\nconst REQUEST_BODY_LIMIT_BYTES = 1_048_576;\n\nexport const resolveGameSessionBrokerStatePath = (projectDir: string): string =>\n path.join(projectDir, BROKER_STATE_RELATIVE_PATH);\n\nexport const readGameSessionBrokerState = async (\n projectDir: string,\n): Promise<AirJamGameSessionBrokerState | null> => {\n try {\n const value = JSON.parse(\n await readFile(resolveGameSessionBrokerStatePath(projectDir), \"utf8\"),\n ) as Partial<AirJamGameSessionBrokerState>;\n if (\n value.schemaVersion !== 1 ||\n typeof value.instanceId !== \"string\" ||\n typeof value.pid !== \"number\" ||\n typeof value.projectDir !== \"string\" ||\n typeof value.origin !== \"string\" ||\n typeof value.secret !== \"string\" ||\n typeof value.startedAt !== \"string\"\n ) {\n return null;\n }\n return value as AirJamGameSessionBrokerState;\n } catch {\n return null;\n }\n};\n\nconst readJsonBody = async (request: IncomingMessage): Promise<unknown> => {\n const chunks: Buffer[] = [];\n let size = 0;\n for await (const chunk of request) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);\n size += buffer.length;\n if (size > REQUEST_BODY_LIMIT_BYTES) {\n throw new Error(\"Game session broker request exceeds 1 MiB.\");\n }\n chunks.push(buffer);\n }\n return JSON.parse(Buffer.concat(chunks).toString(\"utf8\"));\n};\n\nconst writeJson = (\n response: ServerResponse,\n statusCode: number,\n value: unknown,\n): void => {\n response.writeHead(statusCode, {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store\",\n });\n response.end(`${JSON.stringify(value)}\\n`);\n};\n\nexport const requestGameSessionBroker = async <TResult>({\n state,\n request,\n}: {\n state: AirJamGameSessionBrokerState;\n request: AirJamGameSessionBrokerOperation;\n}): Promise<TResult> => {\n const timeoutMs =\n request.operation === \"open\"\n ? Math.max(120_000, (request.input.timeoutMs ?? 0) + 60_000)\n : request.operation === \"read\" ||\n request.operation === \"invoke\" ||\n request.operation === \"capture\"\n ? Math.max(30_000, (request.input.timeoutMs ?? 0) + 10_000)\n : 30_000;\n const response = await fetch(`${state.origin}/v1/game-session`, {\n method: \"POST\",\n headers: {\n authorization: `Bearer ${state.secret}`,\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(request),\n signal: AbortSignal.timeout(timeoutMs),\n });\n const result = (await response.json()) as {\n ok?: boolean;\n result?: TResult;\n error?: { message?: string };\n };\n if (!response.ok || result.ok !== true) {\n throw new Error(\n result.error?.message ??\n `Game session broker request failed with HTTP ${response.status}.`,\n );\n }\n return result.result as TResult;\n};\n\nexport const runGameSessionBroker = async ({\n projectDir,\n}: {\n projectDir: string;\n}): Promise<void> => {\n const resolvedProjectDir = path.resolve(projectDir);\n const statePath = resolveGameSessionBrokerStatePath(resolvedProjectDir);\n const instanceId = randomUUID();\n const secret = randomBytes(32).toString(\"base64url\");\n const startedAt = new Date().toISOString();\n const activeSessionIds = new Set<string>();\n let shuttingDown = false;\n let shutdownCleanup: Promise<void> = Promise.resolve();\n\n const closeActiveSessions = async (): Promise<void> => {\n await Promise.all(\n [...activeSessionIds].map((gameSessionId) =>\n closeGameSession({ gameSessionId }).catch(() => undefined),\n ),\n );\n activeSessionIds.clear();\n };\n\n const server = createServer(async (request, response) => {\n if (request.method !== \"POST\" || request.url !== \"/v1/game-session\") {\n writeJson(response, 404, { ok: false, error: { message: \"Not found.\" } });\n return;\n }\n if (request.headers.authorization !== `Bearer ${secret}`) {\n writeJson(response, 401, {\n ok: false,\n error: { message: \"Invalid game session broker credentials.\" },\n });\n return;\n }\n\n try {\n const operation = (await readJsonBody(\n request,\n )) as AirJamGameSessionBrokerOperation;\n let result: unknown;\n switch (operation.operation) {\n case \"health\":\n result = {\n ok: true,\n instanceId,\n pid: process.pid,\n projectDir: resolvedProjectDir,\n activeSessionCount: activeSessionIds.size,\n startedAt,\n } satisfies AirJamGameSessionBrokerHealth;\n break;\n case \"open\": {\n const opened = await openGameSession({\n ...operation.input,\n cwd: resolvedProjectDir,\n });\n activeSessionIds.add(opened.gameSessionId);\n result = opened;\n break;\n }\n case \"read\":\n result = await readGameSession(operation.input);\n break;\n case \"input\":\n result = await sendGameSessionInput(operation.input);\n break;\n case \"invoke\":\n result = await invokeGameSessionAction(operation.input);\n break;\n case \"capture\":\n result = await captureGameSessionVisuals(operation.input);\n break;\n case \"close\":\n result = await closeGameSession(operation.input);\n activeSessionIds.delete(operation.input.gameSessionId);\n break;\n case \"shutdown\":\n await closeActiveSessions();\n result = { stopped: true, instanceId };\n shuttingDown = true;\n break;\n default:\n throw new Error(\"Unknown game session broker operation.\");\n }\n writeJson(response, 200, { ok: true, result });\n if (shuttingDown) {\n server.close();\n }\n } catch (error) {\n writeJson(response, 400, {\n ok: false,\n error: {\n message: error instanceof Error ? error.message : String(error),\n },\n });\n }\n });\n\n const cleanupState = async (): Promise<void> => {\n const current = await readGameSessionBrokerState(resolvedProjectDir);\n if (current?.instanceId === instanceId) {\n await unlink(statePath).catch(() => undefined);\n }\n };\n const stop = (): void => {\n if (!shuttingDown) {\n shuttingDown = true;\n server.close();\n shutdownCleanup = closeActiveSessions();\n }\n };\n process.once(\"SIGTERM\", stop);\n process.once(\"SIGINT\", stop);\n\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject);\n server.listen(0, \"127.0.0.1\", async () => {\n try {\n const address = server.address();\n if (!address || typeof address === \"string\") {\n throw new Error(\"Game session broker did not bind a TCP port.\");\n }\n const state: AirJamGameSessionBrokerState = {\n schemaVersion: 1,\n instanceId,\n pid: process.pid,\n projectDir: resolvedProjectDir,\n origin: `http://127.0.0.1:${address.port}`,\n secret,\n startedAt,\n };\n await mkdir(path.dirname(statePath), { recursive: true });\n await writeFile(statePath, `${JSON.stringify(state, null, 2)}\\n`, {\n encoding: \"utf8\",\n mode: 0o600,\n });\n await chmod(statePath, 0o600);\n } catch (error) {\n server.close();\n reject(error);\n }\n });\n server.once(\"close\", resolve);\n });\n\n await shutdownCleanup;\n await cleanupState();\n};\n"],"mappings":";;;;;;;;;;;;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,OAAO,MAAM,CAAC,CAAC;AAAA,GAAM;AAAA,UAChE,UAAU;AAAA,UACV,MAAM;AAAA,QACR,CAAC;AACD,cAAM,MAAM,WAAW,GAAK;AAAA,MAC9B,SAAS,OAAO;AACd,eAAO,MAAM;AACb,eAAO,KAAK;AAAA,MACd;AAAA,IACF,CAAC;AACD,WAAO,KAAK,SAAS,OAAO;AAAA,EAC9B,CAAC;AAED,QAAM;AACN,QAAM,aAAa;AACrB;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { O as OpenGameSessionOptions, H as AirJamGameSessionSummary, K as ReadGameSessionOptions, L as AirJamGameSessionInspection, M as SendGameSessionInputOptions, N as SendGameSessionInputResult, P as InvokeGameSessionActionOptions, Q as InvokeGameSessionActionResult, T as CaptureGameSessionVisualsOptions, U as AirJamGameSessionVisualCaptureResult, V as CloseGameSessionOptions, W as CloseGameSessionResult } from './types-C6NrHt88.js';
|
|
2
|
+
export { X as AirJamGameSessionActionDescriptor } from './types-C6NrHt88.js';
|
|
3
|
+
import '@air-jam/sdk';
|
|
4
|
+
import '@air-jam/sdk/platform-machine';
|
|
5
|
+
|
|
6
|
+
declare const openGameSession: (options?: OpenGameSessionOptions) => Promise<AirJamGameSessionSummary>;
|
|
7
|
+
declare const readGameSession: ({ gameSessionId, requestSync, timeoutMs, }: ReadGameSessionOptions) => Promise<AirJamGameSessionInspection>;
|
|
8
|
+
declare const sendGameSessionInput: ({ gameSessionId, input, }: SendGameSessionInputOptions) => Promise<SendGameSessionInputResult>;
|
|
9
|
+
declare const invokeGameSessionAction: (options: InvokeGameSessionActionOptions) => Promise<InvokeGameSessionActionResult>;
|
|
10
|
+
declare const captureGameSessionVisuals: ({ gameSessionId, timeoutMs, }: CaptureGameSessionVisualsOptions) => Promise<AirJamGameSessionVisualCaptureResult>;
|
|
11
|
+
declare const closeGameSession: ({ gameSessionId, }: CloseGameSessionOptions) => Promise<CloseGameSessionResult>;
|
|
12
|
+
|
|
13
|
+
export { AirJamGameSessionInspection, AirJamGameSessionSummary, AirJamGameSessionVisualCaptureResult, CaptureGameSessionVisualsOptions, CloseGameSessionOptions, CloseGameSessionResult, InvokeGameSessionActionOptions, InvokeGameSessionActionResult, OpenGameSessionOptions, ReadGameSessionOptions, SendGameSessionInputOptions, SendGameSessionInputResult, captureGameSessionVisuals, closeGameSession, invokeGameSessionAction, openGameSession, readGameSession, sendGameSessionInput };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
captureGameSessionVisuals,
|
|
3
|
+
closeGameSession,
|
|
4
|
+
invokeGameSessionAction,
|
|
5
|
+
openGameSession,
|
|
6
|
+
readGameSession,
|
|
7
|
+
sendGameSessionInput
|
|
8
|
+
} from "./chunk-ER3Q2C4G.js";
|
|
9
|
+
import "./chunk-XEMR7KUE.js";
|
|
10
|
+
import "./chunk-6WQODT37.js";
|
|
11
|
+
import "./chunk-QKXS5D35.js";
|
|
12
|
+
import "./chunk-CKFT2ZJE.js";
|
|
13
|
+
import "./chunk-ZLPD7FY5.js";
|
|
14
|
+
import "./chunk-5YAARMW5.js";
|
|
15
|
+
import "./chunk-S4LSCEVE.js";
|
|
16
|
+
export {
|
|
17
|
+
captureGameSessionVisuals,
|
|
18
|
+
closeGameSession,
|
|
19
|
+
invokeGameSessionAction,
|
|
20
|
+
openGameSession,
|
|
21
|
+
readGameSession,
|
|
22
|
+
sendGameSessionInput
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=game-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/games.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Y as AirJamGameSummary, Z as AirJamGameInspection, _ as AirJamVisualCaptureInspection } from './types-C6NrHt88.js';
|
|
2
|
+
export { $ as AirJamVisualCaptureSummary } from './types-C6NrHt88.js';
|
|
3
|
+
import '@air-jam/sdk';
|
|
4
|
+
import '@air-jam/sdk/platform-machine';
|
|
5
|
+
|
|
6
|
+
declare const listGames: ({ cwd, }?: {
|
|
7
|
+
cwd?: string;
|
|
8
|
+
}) => Promise<AirJamGameSummary[]>;
|
|
9
|
+
declare const inspectGame: ({ cwd, gameId, }?: {
|
|
10
|
+
cwd?: string;
|
|
11
|
+
gameId?: string;
|
|
12
|
+
}) => Promise<AirJamGameInspection>;
|
|
13
|
+
declare const readVisualCaptureSummary: ({ cwd, gameId, }?: {
|
|
14
|
+
cwd?: string;
|
|
15
|
+
gameId?: string;
|
|
16
|
+
}) => Promise<AirJamVisualCaptureInspection>;
|
|
17
|
+
declare const listVisualCaptureSummaries: ({ cwd, }?: {
|
|
18
|
+
cwd?: string;
|
|
19
|
+
}) => Promise<AirJamVisualCaptureInspection[]>;
|
|
20
|
+
|
|
21
|
+
export { AirJamGameInspection, AirJamGameSummary, AirJamVisualCaptureInspection, inspectGame, listGames, listVisualCaptureSummaries, readVisualCaptureSummary };
|
package/dist/games.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
inspectGame,
|
|
3
|
+
listGames,
|
|
4
|
+
listVisualCaptureSummaries,
|
|
5
|
+
readVisualCaptureSummary
|
|
6
|
+
} from "./chunk-ZLPD7FY5.js";
|
|
7
|
+
import "./chunk-S4LSCEVE.js";
|
|
8
|
+
export {
|
|
9
|
+
inspectGame,
|
|
10
|
+
listGames,
|
|
11
|
+
listVisualCaptureSummaries,
|
|
12
|
+
readVisualCaptureSummary
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=games.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|