@air-jam/cli 0.9.3 → 1.0.0-beta.2

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.
Files changed (97) hide show
  1. package/README.md +128 -0
  2. package/dist/auth-profile.d.ts +5 -0
  3. package/dist/auth-profile.js +7 -0
  4. package/dist/auth-profile.js.map +1 -0
  5. package/dist/auth-sessions.d.ts +5 -0
  6. package/dist/auth-sessions.js +7 -0
  7. package/dist/auth-sessions.js.map +1 -0
  8. package/dist/chunk-7D4AYBAV.js +64 -0
  9. package/dist/chunk-7D4AYBAV.js.map +1 -0
  10. package/dist/chunk-LH7UO57C.js +23 -0
  11. package/dist/chunk-LH7UO57C.js.map +1 -0
  12. package/dist/chunk-PKTLVQXZ.js +82 -0
  13. package/dist/chunk-PKTLVQXZ.js.map +1 -0
  14. package/dist/chunk-SQE4NPZP.js +31 -0
  15. package/dist/chunk-SQE4NPZP.js.map +1 -0
  16. package/dist/{chunk-A4V2N4LX.js → chunk-U6V3HEBB.js} +6 -5
  17. package/dist/chunk-U6V3HEBB.js.map +1 -0
  18. package/dist/chunk-VEHNFPEO.js +224 -0
  19. package/dist/chunk-VEHNFPEO.js.map +1 -0
  20. package/dist/development.d.ts +4 -0
  21. package/dist/development.js +1 -1
  22. package/dist/game-analytics.d.ts +5 -0
  23. package/dist/game-analytics.js +7 -0
  24. package/dist/game-analytics.js.map +1 -0
  25. package/dist/game-app-id.d.ts +5 -0
  26. package/dist/game-app-id.js +7 -0
  27. package/dist/game-app-id.js.map +1 -0
  28. package/dist/game-media.d.ts +5 -0
  29. package/dist/game-media.js +7 -0
  30. package/dist/game-media.js.map +1 -0
  31. package/dist/index.js +688 -404
  32. package/dist/index.js.map +1 -1
  33. package/dist/scaffold.d.ts +8 -1
  34. package/dist/scaffold.js +6 -1
  35. package/dist/scaffold.js.map +1 -1
  36. package/package.json +8 -4
  37. package/runtime/local-network.d.mts +4 -6
  38. package/runtime/public-assets.mjs +62 -0
  39. package/runtime/source-fence.mjs +182 -0
  40. package/runtime/vite-config.d.mts +2 -1
  41. package/runtime/vite-config.mjs +6 -2
  42. package/runtime/vite-dev.mjs +18 -0
  43. package/runtime/vite-https.mjs +2 -3
  44. package/template-assets/bootstrap/AGENTS.md +56 -14
  45. package/template-assets/bootstrap/CLAUDE.md +0 -8
  46. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
  47. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
  48. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
  49. package/template-assets/bootstrap/skills/index.md +1 -1
  50. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
  51. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
  52. package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
  53. package/template-assets/documentation/for-agents/page.mdx +24 -2
  54. package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
  55. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +0 -2
  56. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  57. package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
  58. package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
  59. package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
  60. package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
  61. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
  62. package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
  63. package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
  64. package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
  65. package/template-assets/documentation/manifest.json +112 -42
  66. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  67. package/template-assets/documentation/sdk/hooks/page.mdx +106 -171
  68. package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
  69. package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
  70. package/template-assets/documentation/sdk/settings/page.mdx +155 -0
  71. package/template-assets/documentation/sdk/ui-components/page.mdx +45 -4
  72. package/template-assets/managed/.airjam/ai-pack.json +61 -43
  73. package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
  74. package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
  75. package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
  76. package/template-assets/managed/docs/airjam/docs-index.md +18 -12
  77. package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
  78. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  79. package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
  80. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
  81. package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
  82. package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
  83. package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
  84. package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
  85. package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
  86. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
  87. package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
  88. package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
  89. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +106 -166
  90. package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
  91. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  92. package/template-assets/managed/docs/airjam/generated/ui-components.md +45 -2
  93. package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
  94. package/template-assets/managed/docs/airjam/preview-controllers.md +4 -1
  95. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
  96. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
  97. package/dist/chunk-A4V2N4LX.js.map +0 -1
package/dist/index.js CHANGED
@@ -5,6 +5,12 @@ import {
5
5
  runAiPackStatus,
6
6
  runAiPackUpdate
7
7
  } from "./chunk-N7AI7HZK.js";
8
+ import {
9
+ registerAuthProfileCommand
10
+ } from "./chunk-LH7UO57C.js";
11
+ import {
12
+ registerAuthSessionsCommand
13
+ } from "./chunk-SQE4NPZP.js";
8
14
  import {
9
15
  DEFAULT_GAME_PORT,
10
16
  SECURE_MODE_LOCAL,
@@ -26,18 +32,51 @@ import {
26
32
  runSecureInitCli,
27
33
  serializeResolvedTopology,
28
34
  waitForPort
29
- } from "./chunk-A4V2N4LX.js";
35
+ } from "./chunk-U6V3HEBB.js";
30
36
  import {
31
37
  readDocumentationSnapshot
32
38
  } from "./chunk-J5MAU4QZ.js";
39
+ import {
40
+ registerGameAnalyticsCommand
41
+ } from "./chunk-7D4AYBAV.js";
42
+ import {
43
+ registerGameAppIdCommands
44
+ } from "./chunk-PKTLVQXZ.js";
45
+ import {
46
+ registerGameMediaCommands
47
+ } from "./chunk-VEHNFPEO.js";
33
48
 
34
49
  // src/index.ts
50
+ import { gameSessionOperationSchemas as gameSessionOperationSchemas2 } from "@air-jam/devtools/game-session";
51
+ import { airJamSettingsValuesSchema } from "@air-jam/sdk/core";
35
52
  import {
36
53
  getDevStatus,
37
54
  resetLocalDev,
38
55
  startDev,
39
56
  stopDev
40
57
  } from "@air-jam/devtools/dev";
58
+ import {
59
+ GameRunWatchWriter,
60
+ currentRoomAttachmentSchema,
61
+ parseGameRunWatchSurface,
62
+ startGameRunSchema
63
+ } from "@air-jam/devtools/game-runs";
64
+ import {
65
+ cancelGameRun,
66
+ listGameRuns,
67
+ listGameTestProfiles,
68
+ readGameRun,
69
+ readGameSettings as readGameSettings2,
70
+ replayGameRun,
71
+ startGameRun,
72
+ steerGameRun,
73
+ stopAllGameRuns,
74
+ stopGameRun,
75
+ updateGameSettings as updateGameSettings2,
76
+ waitGameRun,
77
+ watchGameRun
78
+ } from "@air-jam/devtools/game-session";
79
+ import { AIRJAM_PROJECT_MCP_FILE as AIRJAM_PROJECT_MCP_FILE2 } from "@air-jam/devtools/mcp-config";
41
80
  import {
42
81
  AirJamPlatformApiError,
43
82
  AirJamStoredPlatformSessionError,
@@ -48,11 +87,6 @@ import {
48
87
  logoutPlatformMachineSession,
49
88
  readStoredPlatformMachineSession
50
89
  } from "@air-jam/devtools/platform-auth";
51
- import {
52
- archivePlatformGameMediaAsset,
53
- inspectPlatformGameMedia,
54
- uploadPlatformGameMediaFile
55
- } from "@air-jam/devtools/platform-game-media";
56
90
  import {
57
91
  createPlatformGame,
58
92
  inspectPlatformGame,
@@ -62,6 +96,7 @@ import {
62
96
  } from "@air-jam/devtools/platform-games";
63
97
  import { runCompleteEvaluation } from "@air-jam/devtools/quality";
64
98
  import {
99
+ archivePlatformRelease,
65
100
  bundleLocalRelease,
66
101
  exportPlatformReleaseGeneration,
67
102
  finalizePlatformReleaseGeneration,
@@ -74,17 +109,20 @@ import {
74
109
  uploadPlatformReleaseGeneration,
75
110
  validateLocalRelease
76
111
  } from "@air-jam/devtools/release";
77
- import { AIRJAM_PROJECT_MCP_FILE as AIRJAM_PROJECT_MCP_FILE2 } from "@air-jam/devtools/mcp-config";
78
112
  import { Command } from "commander";
79
- import kleur2 from "kleur";
80
- import path4 from "path";
113
+ import kleur3 from "kleur";
114
+ import path3 from "path";
81
115
 
82
116
  // runtime/game-dev.mjs
83
117
  import crossSpawn from "cross-spawn";
84
118
  import { execFileSync } from "child_process";
85
119
  import fs from "fs";
86
120
  import path from "path";
121
+ import { fileURLToPath } from "url";
87
122
  var START_TIMEOUT_MS = 2e4;
123
+ var viteLauncher = fileURLToPath(
124
+ new URL("../runtime/vite-dev.mjs", import.meta.url)
125
+ );
88
126
  var PREVIEW_MANAGED_SERVER_LOG_RELATIVE_PATH = path.join(
89
127
  ".airjam",
90
128
  "preview-managed-server.log"
@@ -123,7 +161,12 @@ var usage = () => {
123
161
  console.log("");
124
162
  console.log("Network isolation:");
125
163
  console.log(" VITE_PORT Game app port (default: 5173)");
126
- console.log(" AIR_JAM_SERVER_PORT Local server port (default: 4000)");
164
+ console.log(
165
+ " AIR_JAM_SERVER_PORT Local server port (default: 4000)"
166
+ );
167
+ console.log(
168
+ " AIR_JAM_BIND_HOST Bind address (default: all interfaces)"
169
+ );
127
170
  console.log(" VITE_AIR_JAM_PUBLIC_HOST Explicit host/controller origin");
128
171
  };
129
172
  var getDefaultPublicHost = (env, gamePort) => {
@@ -224,7 +267,7 @@ var startGameIfNeeded = async (processGroup, { gamePort, env, allowExistingGame
224
267
  `Port ${gamePort} is already in use. Stop the existing Vite dev server and retry.`
225
268
  );
226
269
  }
227
- processGroup.run("game", "pnpm", ["exec", "vite"], {
270
+ processGroup.run("game", process.execPath, [viteLauncher], {
228
271
  env: {
229
272
  ...process.env,
230
273
  ...env
@@ -281,7 +324,7 @@ var ensurePreviewManagedServer = async ({ cwd, serverPort, env }) => {
281
324
  return true;
282
325
  };
283
326
  var runForegroundGame = ({ cwd, env }) => new Promise((resolve, reject) => {
284
- const child = crossSpawn("pnpm", ["exec", "vite"], {
327
+ const child = crossSpawn(process.execPath, [viteLauncher], {
285
328
  cwd,
286
329
  stdio: "inherit",
287
330
  env: {
@@ -414,7 +457,7 @@ var runGameDevCli = async ({
414
457
  secureState = loadSecureDevState({
415
458
  cwd: secureRootDir,
416
459
  mode: args.secureMode,
417
- env: runtimeEnv,
460
+ runtimeEnv,
418
461
  gamePort: args.port
419
462
  });
420
463
  console.log(`[dev] Secure mode: ${secureState.mode}`);
@@ -442,6 +485,7 @@ var runGameDevCli = async ({
442
485
  VITE_AIR_JAM_SERVER_URL: runtimeEnv.VITE_AIR_JAM_SERVER_URL
443
486
  } : {}
444
487
  };
488
+ gameEnv.AIR_JAM_BIND_HOST = runtimeEnv.AIR_JAM_BIND_HOST;
445
489
  if (args.previewManaged) {
446
490
  await ensurePreviewManagedServer({
447
491
  cwd,
@@ -541,7 +585,7 @@ var resolveProjectSurfaceTopology = ({
541
585
  const secureState = secure ? loadSecureDevState({
542
586
  cwd,
543
587
  mode: SECURE_MODE_LOCAL,
544
- env,
588
+ runtimeEnv: env,
545
589
  gamePort
546
590
  }) : null;
547
591
  const publicHost = secure ? secureState.publicHost : getDefaultStandalonePublicHost(env, gamePort);
@@ -627,6 +671,45 @@ var runProjectTopologyCli = async ({
627
671
  );
628
672
  };
629
673
 
674
+ // src/game-settings.ts
675
+ import { keepGameSettings } from "@air-jam/devtools/game-settings";
676
+ import { inspectGame } from "@air-jam/devtools/games";
677
+ function registerGameSettingsCommand(game) {
678
+ game.command("settings").description("Keep local game settings in source").command("keep").description("Rewrite declared default literals with chosen values").requiredOption(
679
+ "--set <name=value>",
680
+ "Setting to keep; repeat for multiple settings",
681
+ (value, previous = []) => [...previous, value]
682
+ ).option("--dir <path>", "Game project directory", process.cwd()).option("--json", "Print one machine-readable JSON document", false).action(async (input) => {
683
+ const { declaration } = await inspectGame({ cwd: input.dir });
684
+ const values = {};
685
+ for (const assignment of input.set) {
686
+ const split = assignment.indexOf("=");
687
+ if (split < 1)
688
+ throw new Error("AJ_SETTING_INVALID: Use --set name=value.");
689
+ const key = assignment.slice(0, split);
690
+ const raw = assignment.slice(split + 1);
691
+ if (Object.hasOwn(values, key))
692
+ throw new Error(
693
+ `AJ_SETTING_INVALID: ${key} was provided more than once.`
694
+ );
695
+ const setting = declaration.settings && Object.hasOwn(declaration.settings, key) ? declaration.settings[key] : void 0;
696
+ if (!setting)
697
+ throw new Error(
698
+ `AJ_SETTING_UNKNOWN: ${key} is not declared by this game.`
699
+ );
700
+ values[key] = setting.kind === "number" && raw.trim() !== "" ? Number(raw) : setting.kind === "boolean" && ["true", "false"].includes(raw) ? raw === "true" : raw;
701
+ }
702
+ const result = await keepGameSettings({ cwd: input.dir, values });
703
+ if (input.json) process.stdout.write(`${JSON.stringify(result)}
704
+ `);
705
+ else
706
+ for (const entry of result.kept)
707
+ console.log(
708
+ `${entry.key}: ${entry.from} -> ${entry.to}${entry.from === entry.to ? " (unchanged)" : ""} (${result.file})`
709
+ );
710
+ });
711
+ }
712
+
630
713
  // src/mcp.ts
631
714
  import { inspectProject } from "@air-jam/devtools/context";
632
715
  import {
@@ -715,79 +798,158 @@ var runMcpConfig = async ({
715
798
  );
716
799
  };
717
800
 
801
+ // src/rooms.ts
802
+ import {
803
+ describeLinkProblem,
804
+ ROOMS_CHECK_SCENARIOS,
805
+ runRoomsCheck
806
+ } from "@air-jam/devtools/rooms-check";
807
+ import kleur2 from "kleur";
808
+ import { z } from "zod";
809
+ var positive = z.coerce.number().int().positive();
810
+ var optionsSchema = z.object({
811
+ scenario: z.array(z.enum(ROOMS_CHECK_SCENARIOS)).optional(),
812
+ json: z.boolean(),
813
+ origin: z.url().optional(),
814
+ hostCredentialCommand: z.string().min(1).optional(),
815
+ connectionsPerMinute: positive.optional(),
816
+ briefFreezeMs: positive.optional(),
817
+ stallMs: positive.optional(),
818
+ idleMs: positive.optional(),
819
+ crowdDurationMs: positive.optional(),
820
+ loadRooms: positive.optional(),
821
+ loadPhones: z.coerce.number().int().min(1).max(16).optional(),
822
+ loadDurationMs: positive.optional(),
823
+ loadWorkers: positive.optional()
824
+ });
825
+ var describeProblems = (result) => {
826
+ const byCause = /* @__PURE__ */ new Map();
827
+ for (const { device, problem } of result.connectionProblems) {
828
+ const cause = describeLinkProblem(problem);
829
+ const entry = byCause.get(cause) ?? { count: 0, devices: /* @__PURE__ */ new Set() };
830
+ entry.count += 1;
831
+ entry.devices.add(device);
832
+ byCause.set(cause, entry);
833
+ }
834
+ return [...byCause].map(
835
+ ([cause, { count, devices }]) => ` connection ${cause}: ${count} on ${[...devices].join(", ")}`
836
+ );
837
+ };
838
+ var describeResult = (result) => [
839
+ `${result.passed ? kleur2.green("pass") : kleur2.red("FAIL")} ${result.scenario} (${result.durationMs} ms)${result.failure ? `: ${result.failure}` : ""}`,
840
+ ...result.passed ? [` ${JSON.stringify(result.measurements)}`] : [],
841
+ ...describeProblems(result)
842
+ ].join("\n");
843
+ function registerRoomsCommand(program) {
844
+ program.command("rooms").description("Check room servers").command("check <url>").description(
845
+ "Run the room acceptance scenarios against a rooms origin, with the host and each phone as separate processes that are frozen, killed and replaced. Every scenario but load runs by default; load opens 100 rooms and 400 phones from this machine, so the target must allow that many connections from one address or the check must pace them (--connections-per-minute)."
846
+ ).option(
847
+ "--scenario <name>",
848
+ `Scenario to run; repeat for more (${ROOMS_CHECK_SCENARIOS.join(", ")})`,
849
+ (value, previous = []) => [...previous, value]
850
+ ).option("--json", "Print one machine-readable JSON document", false).option(
851
+ "--origin <origin>",
852
+ "The page origin every connection sends as its Origin header"
853
+ ).option(
854
+ "--host-credential-command <command>",
855
+ "A shell command printing one fresh host credential, run for every host that opens a room"
856
+ ).option(
857
+ "--connections-per-minute <count>",
858
+ "At most this many connection opens in any minute, across every device (default unpaced)"
859
+ ).option(
860
+ "--brief-freeze-ms <ms>",
861
+ "A phone lock shorter than the server's liveness window (default 5000)"
862
+ ).option(
863
+ "--stall-ms <ms>",
864
+ "How long a phone's network stalls while it keeps pressing (default 10000)"
865
+ ).option(
866
+ "--idle-ms <ms>",
867
+ "How long the background-host room idles (default 60000)"
868
+ ).option(
869
+ "--crowd-duration-ms <ms>",
870
+ "How long sixteen phones play (default 10000)"
871
+ ).option(
872
+ "--load-rooms <count>",
873
+ "Rooms the load scenario opens (default 100)"
874
+ ).option("--load-phones <count>", "Phones per load room (default 4)").option(
875
+ "--load-duration-ms <ms>",
876
+ "How long the load scenario measures (default 60000)"
877
+ ).option("--load-workers <count>", "Processes the load rooms run in").action(async (url, raw) => {
878
+ const parsed = optionsSchema.safeParse(raw);
879
+ if (!parsed.success) throw new Error(z.prettifyError(parsed.error));
880
+ const options = parsed.data;
881
+ const report = await runRoomsCheck({
882
+ url,
883
+ origin: options.origin,
884
+ hostCredentialCommand: options.hostCredentialCommand,
885
+ connectionsPerMinute: options.connectionsPerMinute,
886
+ scenarios: options.scenario,
887
+ briefFreezeMs: options.briefFreezeMs,
888
+ stallMs: options.stallMs,
889
+ idleMs: options.idleMs,
890
+ crowdDurationMs: options.crowdDurationMs,
891
+ load: {
892
+ rooms: options.loadRooms,
893
+ phonesPerRoom: options.loadPhones,
894
+ durationMs: options.loadDurationMs,
895
+ workers: options.loadWorkers
896
+ },
897
+ onResult: options.json ? void 0 : (result) => console.log(describeResult(result))
898
+ });
899
+ if (options.json) process.stdout.write(`${JSON.stringify(report)}
900
+ `);
901
+ if (!report.passed) process.exitCode = 1;
902
+ });
903
+ }
904
+
718
905
  // src/session.ts
719
906
  import { inspectProject as inspectProject2 } from "@air-jam/devtools/context";
720
907
  import {
721
- readGameSessionBrokerState,
722
- requestGameSessionBroker,
723
- resolveGameSessionBrokerStatePath,
724
- runGameSessionBroker
908
+ captureGameSessionVisuals,
909
+ closeGameSession,
910
+ controlGameSessionParticipant,
911
+ gameSessionOperationSchemas,
912
+ invokeGameSessionAction,
913
+ observeGameSession,
914
+ openGameSession,
915
+ readGameSession,
916
+ readGameSettings,
917
+ sendGameSessionInput,
918
+ updateGameSettings
919
+ } from "@air-jam/devtools/game-session";
920
+ import {
921
+ getGameSessionBrokerStatus,
922
+ stopGameSessionBroker
725
923
  } from "@air-jam/devtools/game-session-broker";
726
- import { spawn } from "child_process";
727
- import { closeSync, mkdirSync, openSync } from "fs";
728
- import { unlink } from "fs/promises";
729
- import path3 from "path";
730
- var BROKER_START_TIMEOUT_MS = 1e4;
731
- var resolveProjectDir = async (dir) => {
732
- const project = await inspectProject2({ cwd: dir });
733
- return project.context.rootDir;
734
- };
735
- var readHealth = async (state) => requestGameSessionBroker({
736
- state,
737
- request: { operation: "health" }
738
- }).catch(() => null);
739
- var ensureBroker = async (projectDir) => {
740
- const existing = await readGameSessionBrokerState(projectDir);
741
- if (existing && await readHealth(existing)) {
742
- return existing;
743
- }
744
- await unlink(resolveGameSessionBrokerStatePath(projectDir)).catch(
745
- () => void 0
746
- );
747
- const entryPath = process.argv[1];
748
- if (!entryPath) {
749
- throw new Error("Cannot resolve the current airjam CLI entrypoint.");
750
- }
751
- const logDir = path3.join(projectDir, ".airjam", "logs");
752
- mkdirSync(logDir, { recursive: true });
753
- const logFd = openSync(
754
- path3.join(logDir, "game-session-broker.log"),
755
- "a",
756
- 384
757
- );
758
- try {
759
- const child = spawn(
760
- process.execPath,
761
- [entryPath, "__session-broker", "--dir", projectDir],
762
- {
763
- cwd: projectDir,
764
- detached: true,
765
- stdio: ["ignore", logFd, logFd]
766
- }
767
- );
768
- child.unref();
769
- } finally {
770
- closeSync(logFd);
771
- }
772
- const startedAt = Date.now();
773
- while (Date.now() - startedAt < BROKER_START_TIMEOUT_MS) {
774
- const state = await readGameSessionBrokerState(projectDir);
775
- if (state && await readHealth(state)) {
776
- return state;
777
- }
778
- await new Promise((resolve) => setTimeout(resolve, 50));
779
- }
780
- throw new Error(
781
- `Air Jam game session broker did not start. Inspect ${path3.join(logDir, "game-session-broker.log")}.`
782
- );
783
- };
924
+ var resolveProjectDir = async (dir) => (await inspectProject2({ cwd: dir })).context.rootDir;
784
925
  var request = async ({
785
926
  dir,
786
927
  operation
787
928
  }) => {
788
- const projectDir = await resolveProjectDir(dir);
789
- const state = await ensureBroker(projectDir);
790
- return requestGameSessionBroker({ state, request: operation });
929
+ switch (operation.operation) {
930
+ case "open":
931
+ return openGameSession({ ...operation.input, cwd: dir });
932
+ case "read":
933
+ return readGameSession({ ...operation.input, cwd: dir });
934
+ case "observe":
935
+ return observeGameSession({ ...operation.input, cwd: dir });
936
+ case "settings-read":
937
+ return readGameSettings({ ...operation.input, cwd: dir });
938
+ case "settings-update":
939
+ return updateGameSettings({ ...operation.input, cwd: dir });
940
+ case "control":
941
+ return controlGameSessionParticipant({ ...operation.input, cwd: dir });
942
+ case "input":
943
+ return sendGameSessionInput({ ...operation.input, cwd: dir });
944
+ case "invoke":
945
+ return invokeGameSessionAction({ ...operation.input, cwd: dir });
946
+ case "capture":
947
+ return captureGameSessionVisuals({ ...operation.input, cwd: dir });
948
+ case "close":
949
+ return closeGameSession({ ...operation.input, cwd: dir });
950
+ default:
951
+ throw new Error("Unsupported session operation.");
952
+ }
791
953
  };
792
954
  var parseJsonValue = (value) => {
793
955
  try {
@@ -803,36 +965,14 @@ var parseJsonObject = (value) => {
803
965
  }
804
966
  return parsed;
805
967
  };
806
- var runSessionBrokerProcess = async (dir) => {
807
- await runGameSessionBroker({ projectDir: path3.resolve(dir) });
808
- };
809
968
  var runSessionBrokerStatus = async ({
810
969
  dir
811
970
  }) => {
812
- const projectDir = await resolveProjectDir(dir);
813
- const state = await readGameSessionBrokerState(projectDir);
814
- if (!state) {
815
- return { running: false, projectDir };
816
- }
817
- const health = await readHealth(state);
818
- return health ? { running: true, ...health } : { running: false, projectDir, staleState: true, pid: state.pid };
971
+ return getGameSessionBrokerStatus(await resolveProjectDir(dir));
819
972
  };
820
973
  var runSessionBrokerStop = async ({
821
974
  dir
822
- }) => {
823
- const projectDir = await resolveProjectDir(dir);
824
- const state = await readGameSessionBrokerState(projectDir);
825
- if (!state || !await readHealth(state)) {
826
- await unlink(resolveGameSessionBrokerStatePath(projectDir)).catch(
827
- () => void 0
828
- );
829
- return { stopped: false, running: false, projectDir };
830
- }
831
- return requestGameSessionBroker({
832
- state,
833
- request: { operation: "shutdown" }
834
- });
835
- };
975
+ }) => stopGameSessionBroker(await resolveProjectDir(dir));
836
976
  var openSession = async ({
837
977
  dir,
838
978
  ...input
@@ -840,13 +980,12 @@ var openSession = async ({
840
980
  var readSession = async ({
841
981
  dir,
842
982
  gameSessionId,
843
- requestSync = true,
844
983
  timeoutMs
845
984
  }) => request({
846
985
  dir,
847
986
  operation: {
848
987
  operation: "read",
849
- input: { gameSessionId, requestSync, timeoutMs }
988
+ input: { gameSessionId, timeoutMs }
850
989
  }
851
990
  });
852
991
  var sendSessionInput = async ({
@@ -855,7 +994,10 @@ var sendSessionInput = async ({
855
994
  input
856
995
  }) => request({
857
996
  dir,
858
- operation: { operation: "input", input: { gameSessionId, input } }
997
+ operation: {
998
+ operation: "input",
999
+ input: gameSessionOperationSchemas.input.parse({ gameSessionId, input })
1000
+ }
859
1001
  });
860
1002
  var invokeSessionAction = async ({
861
1003
  dir,
@@ -867,7 +1009,12 @@ var invokeSessionAction = async ({
867
1009
  dir,
868
1010
  operation: {
869
1011
  operation: "invoke",
870
- input: { gameSessionId, actionId, payload, timeoutMs }
1012
+ input: gameSessionOperationSchemas.invoke.parse({
1013
+ gameSessionId,
1014
+ actionId,
1015
+ payload,
1016
+ timeoutMs
1017
+ })
871
1018
  }
872
1019
  });
873
1020
  var captureSessionVisuals = async ({
@@ -888,6 +1035,20 @@ var closeSession = async ({
888
1035
  dir,
889
1036
  operation: { operation: "close", input: { gameSessionId } }
890
1037
  });
1038
+ var controlSessionParticipant = async ({
1039
+ dir,
1040
+ gameSessionId,
1041
+ command
1042
+ }) => request({
1043
+ dir,
1044
+ operation: {
1045
+ operation: "control",
1046
+ input: gameSessionOperationSchemas.control.parse({
1047
+ ...command,
1048
+ gameSessionId
1049
+ })
1050
+ }
1051
+ });
891
1052
 
892
1053
  // src/version.ts
893
1054
  import fs2 from "fs";
@@ -909,11 +1070,11 @@ var resolveActionOptions = (value) => {
909
1070
  };
910
1071
  var printReleaseIssues = (issues) => {
911
1072
  for (const issue of issues) {
912
- const color = issue.severity === "error" ? kleur2.red : kleur2.yellow;
1073
+ const color = issue.severity === "error" ? kleur3.red : kleur3.yellow;
913
1074
  const prefix = issue.severity === "error" ? "error" : "warning";
914
1075
  console.log(color(`- ${prefix}: ${issue.message}`));
915
1076
  if (issue.path) {
916
- console.log(kleur2.dim(` path: ${issue.path}`));
1077
+ console.log(kleur3.dim(` path: ${issue.path}`));
917
1078
  }
918
1079
  }
919
1080
  };
@@ -922,22 +1083,22 @@ var printReleaseDoctor = async ({
922
1083
  distDir
923
1084
  }) => {
924
1085
  const doctor = await inspectLocalRelease({
925
- cwd: path4.resolve(dir || process.cwd()),
1086
+ cwd: path3.resolve(dir || process.cwd()),
926
1087
  distDir
927
1088
  });
928
1089
  console.log(
929
- doctor.canBundle ? kleur2.green("\n\u2713 Hosted release doctor passed\n") : kleur2.red("\n\u2717 Hosted release doctor failed\n")
1090
+ doctor.canBundle ? kleur3.green("\n\u2713 Hosted release doctor passed\n") : kleur3.red("\n\u2717 Hosted release doctor failed\n")
930
1091
  );
931
- console.log(`Project: ${kleur2.cyan(doctor.projectDir)}`);
932
- console.log(`Dist: ${kleur2.cyan(doctor.distDir)}`);
1092
+ console.log(`Project: ${kleur3.cyan(doctor.projectDir)}`);
1093
+ console.log(`Dist: ${kleur3.cyan(doctor.distDir)}`);
933
1094
  console.log(
934
- `Build script: ${doctor.buildScript ? kleur2.cyan("present") : kleur2.red("missing")}`
1095
+ `Build script: ${doctor.buildScript ? kleur3.cyan("present") : kleur3.red("missing")}`
935
1096
  );
936
1097
  console.log(
937
- `Metadata export: ${doctor.metadataExportLikely ? kleur2.cyan("present") : kleur2.yellow("missing")}`
1098
+ `Metadata export: ${doctor.gameSlug ? kleur3.cyan("present") : kleur3.yellow("missing")}`
938
1099
  );
939
1100
  console.log(
940
- `Hosted contract: ${kleur2.dim(
1101
+ `Hosted contract: ${kleur3.dim(
941
1102
  `${doctor.hostedContract.hostPath} (host), ${doctor.hostedContract.controllerPath} (controller), ${doctor.hostedContract.manifestPath} manifest`
942
1103
  )}`
943
1104
  );
@@ -956,7 +1117,7 @@ var runReleaseBundleCommand = async ({
956
1117
  skipBuild = false
957
1118
  }) => {
958
1119
  const result = await bundleLocalRelease({
959
- cwd: path4.resolve(dir || process.cwd()),
1120
+ cwd: path3.resolve(dir || process.cwd()),
960
1121
  distDir,
961
1122
  out,
962
1123
  skipBuild
@@ -967,15 +1128,15 @@ var runReleaseBundleCommand = async ({
967
1128
  if (result.buildResult?.stderr.trim()) {
968
1129
  console.error(result.buildResult.stderr.trimEnd());
969
1130
  }
970
- console.log(kleur2.green("\n\u2713 Hosted release bundle created\n"));
971
- console.log(`Artifact: ${kleur2.cyan(result.outputFile)}`);
1131
+ console.log(kleur3.green("\n\u2713 Hosted release bundle created\n"));
1132
+ console.log(`Artifact: ${kleur3.cyan(result.outputFile)}`);
972
1133
  console.log(
973
- kleur2.dim(
1134
+ kleur3.dim(
974
1135
  `Hosted contract: / (host), /controller (controller), .airjam/release-manifest.json manifest`
975
1136
  )
976
1137
  );
977
1138
  console.log(
978
- kleur2.dim(
1139
+ kleur3.dim(
979
1140
  `Validated ${result.validation.fileCount} files (${result.validation.extractedSizeBytes} bytes extracted)`
980
1141
  )
981
1142
  );
@@ -987,22 +1148,22 @@ var runReleaseValidateCommand = async ({
987
1148
  skipBuild = false
988
1149
  }) => {
989
1150
  const validation = await validateLocalRelease({
990
- cwd: path4.resolve(dir || process.cwd()),
1151
+ cwd: path3.resolve(dir || process.cwd()),
991
1152
  distDir,
992
1153
  bundlePath: bundle,
993
1154
  skipBuild
994
1155
  });
995
1156
  console.log(
996
- validation.ok ? kleur2.green("\n\u2713 Hosted release validation passed\n") : kleur2.red("\n\u2717 Hosted release validation failed\n")
1157
+ validation.ok ? kleur3.green("\n\u2713 Hosted release validation passed\n") : kleur3.red("\n\u2717 Hosted release validation failed\n")
997
1158
  );
998
1159
  if (validation.source.kind === "bundle") {
999
- console.log(`Bundle: ${kleur2.cyan(validation.source.bundlePath)}`);
1160
+ console.log(`Bundle: ${kleur3.cyan(validation.source.bundlePath)}`);
1000
1161
  } else {
1001
- console.log(`Project: ${kleur2.cyan(validation.source.projectDir)}`);
1002
- console.log(`Dist: ${kleur2.cyan(validation.source.distDir)}`);
1162
+ console.log(`Project: ${kleur3.cyan(validation.source.projectDir)}`);
1163
+ console.log(`Dist: ${kleur3.cyan(validation.source.distDir)}`);
1003
1164
  }
1004
1165
  console.log(
1005
- kleur2.dim(
1166
+ kleur3.dim(
1006
1167
  `Validated ${validation.fileCount} files (${validation.extractedSizeBytes} bytes extracted)`
1007
1168
  )
1008
1169
  );
@@ -1024,108 +1185,67 @@ var runReleaseListCommand = async ({
1024
1185
  slugOrId: game.trim()
1025
1186
  });
1026
1187
  console.log(
1027
- kleur2.green(
1188
+ kleur3.green(
1028
1189
  `
1029
1190
  \u2713 Hosted releases for ${result2.game.name}${result2.game.slug ? ` (${result2.game.slug})` : ""}
1030
1191
  `
1031
1192
  )
1032
1193
  );
1033
1194
  if (result2.releases.length === 0) {
1034
- console.log(kleur2.dim("No hosted releases found."));
1195
+ console.log(kleur3.dim("No hosted releases found."));
1035
1196
  return;
1036
1197
  }
1037
1198
  for (const release of result2.releases) {
1038
1199
  console.log(
1039
- `${kleur2.cyan(release.id)} ${kleur2.yellow(release.status)} ${release.versionLabel ?? "(untitled)"} ${kleur2.dim(release.createdAt)}`
1200
+ `${kleur3.cyan(release.id)} ${kleur3.yellow(release.status)} ${release.versionLabel ?? "(untitled)"} ${kleur3.dim(release.createdAt)} ${kleur3.cyan(release.playUrl)}`
1040
1201
  );
1041
1202
  }
1042
1203
  return;
1043
1204
  }
1044
1205
  const result = await listPlatformReleaseTargets({ platformUrl });
1045
- console.log(kleur2.green("\n\u2713 Hosted release targets\n"));
1206
+ console.log(kleur3.green("\n\u2713 Hosted release targets\n"));
1046
1207
  if (result.games.length === 0) {
1047
- console.log(kleur2.dim("No owned hosted games found."));
1208
+ console.log(kleur3.dim("No owned hosted games found."));
1048
1209
  return;
1049
1210
  }
1050
1211
  for (const ownedGame of result.games) {
1051
1212
  console.log(
1052
- `${kleur2.cyan(ownedGame.id)} ${ownedGame.slug ? kleur2.yellow(ownedGame.slug) : kleur2.dim("(no slug)")} ${ownedGame.name}`
1213
+ `${kleur3.cyan(ownedGame.id)} ${ownedGame.slug ? kleur3.yellow(ownedGame.slug) : kleur3.dim("(no slug)")} ${ownedGame.name}`
1053
1214
  );
1054
1215
  }
1055
1216
  };
1217
+ var formatArcadeListing = ({
1218
+ status,
1219
+ reason
1220
+ }) => {
1221
+ const labels = {
1222
+ not_requested: "Not requested",
1223
+ awaiting_approval: "Waiting for approval",
1224
+ approved: "Listed in Arcade",
1225
+ rejected: "Not approved"
1226
+ };
1227
+ return status === "rejected" && reason ? `${labels[status]}: ${reason}` : labels[status];
1228
+ };
1056
1229
  var printHostedGame = ({
1057
1230
  game,
1058
1231
  heading
1059
1232
  }) => {
1060
- console.log(kleur2.green(`
1233
+ console.log(kleur3.green(`
1061
1234
  \u2713 ${heading}
1062
1235
  `));
1063
- console.log(`ID: ${kleur2.cyan(game.id)}`);
1064
- console.log(`Name: ${kleur2.cyan(game.name)}`);
1065
- console.log(`Slug: ${kleur2.cyan(game.slug ?? "(none)")}`);
1066
- console.log(`Arcade visibility: ${kleur2.cyan(game.arcadeVisibility)}`);
1067
- console.log(`Description: ${kleur2.cyan(game.description ?? "(none)")}`);
1068
- console.log(`Preview URL: ${kleur2.cyan(game.url ?? "(none)")}`);
1069
- console.log(`Source URL: ${kleur2.cyan(game.sourceUrl ?? "(none)")}`);
1070
- console.log(`Template ID: ${kleur2.cyan(game.templateId ?? "(none)")}`);
1071
- console.log(`Created: ${kleur2.cyan(game.createdAt)}`);
1072
- console.log(`Updated: ${kleur2.cyan(game.updatedAt)}`);
1073
- };
1074
- var GAME_MEDIA_KIND_LABEL = {
1075
- thumbnail: "Thumbnail",
1076
- cover: "Cover",
1077
- preview_video: "Preview Video"
1078
- };
1079
- var formatBytes = (value) => {
1080
- const units = ["B", "KB", "MB", "GB"];
1081
- let size = value;
1082
- let unitIndex = 0;
1083
- while (size >= 1024 && unitIndex < units.length - 1) {
1084
- size /= 1024;
1085
- unitIndex += 1;
1086
- }
1087
- return `${size.toFixed(unitIndex === 0 ? 0 : 1)} ${units[unitIndex]}`;
1088
- };
1089
- var normalizeGameMediaKind = (value) => {
1090
- const normalized = value.trim();
1091
- if (normalized === "thumbnail" || normalized === "cover") {
1092
- return normalized;
1093
- }
1094
- if (normalized === "preview_video" || normalized === "preview-video") {
1095
- return "preview_video";
1096
- }
1097
- throw new Error(
1098
- `Unsupported media kind "${value}". Use thumbnail, cover, or preview_video.`
1236
+ console.log(`ID: ${kleur3.cyan(game.id)}`);
1237
+ console.log(`Name: ${kleur3.cyan(game.name)}`);
1238
+ console.log(`Slug: ${kleur3.cyan(game.slug ?? "(none)")}`);
1239
+ console.log(`Arcade visibility: ${kleur3.cyan(game.arcadeVisibility)}`);
1240
+ console.log(
1241
+ `Arcade listing: ${kleur3.cyan(formatArcadeListing(game.arcadeListing))}`
1099
1242
  );
1100
- };
1101
- var printHostedGameMedia = ({
1102
- result,
1103
- heading
1104
- }) => {
1105
- console.log(kleur2.green(`
1106
- \u2713 ${heading}
1107
- `));
1108
- console.log(`Game: ${kleur2.cyan(result.game.name)}`);
1109
- console.log(`ID: ${kleur2.cyan(result.game.id)}`);
1110
- console.log(`Slug: ${kleur2.cyan(result.game.slug ?? "(none)")}`);
1111
- for (const kind of ["thumbnail", "cover", "preview_video"]) {
1112
- const assets = result.assets.filter((asset) => asset.kind === kind);
1113
- const activeAsset = assets.find((asset) => asset.isActive) ?? null;
1114
- console.log("");
1115
- console.log(kleur2.bold(GAME_MEDIA_KIND_LABEL[kind]));
1116
- console.log(
1117
- `Active: ${kleur2.cyan(activeAsset?.id ?? "(none)")}${activeAsset?.publicUrl ? ` ${kleur2.dim(activeAsset.publicUrl)}` : ""}`
1118
- );
1119
- if (assets.length === 0) {
1120
- console.log(kleur2.dim(" No uploaded assets."));
1121
- continue;
1122
- }
1123
- for (const asset of assets) {
1124
- console.log(
1125
- ` ${asset.isActive ? kleur2.green("\u25CF") : kleur2.dim("\u25CB")} ${kleur2.cyan(asset.id)} ${kleur2.yellow(asset.status)} ${asset.originalFilename} ${kleur2.dim(formatBytes(asset.sizeBytes))}`
1126
- );
1127
- }
1128
- }
1243
+ console.log(`Description: ${kleur3.cyan(game.description ?? "(none)")}`);
1244
+ console.log(`Preview URL: ${kleur3.cyan(game.url ?? "(none)")}`);
1245
+ console.log(`Source URL: ${kleur3.cyan(game.sourceUrl ?? "(none)")}`);
1246
+ console.log(`Template ID: ${kleur3.cyan(game.templateId ?? "(none)")}`);
1247
+ console.log(`Created: ${kleur3.cyan(game.createdAt)}`);
1248
+ console.log(`Updated: ${kleur3.cyan(game.updatedAt)}`);
1129
1249
  };
1130
1250
  var resolveCreateGameInput = async ({
1131
1251
  dir,
@@ -1138,7 +1258,7 @@ var resolveCreateGameInput = async ({
1138
1258
  arcadeVisibility
1139
1259
  }) => {
1140
1260
  const localDefaults = dir ? await readLocalHostedGameDefaults({
1141
- cwd: path4.resolve(dir)
1261
+ cwd: path3.resolve(dir)
1142
1262
  }) : null;
1143
1263
  const resolvedName = name?.trim() || localDefaults?.metadata.name || localDefaults?.template.name || null;
1144
1264
  if (!resolvedName) {
@@ -1164,28 +1284,40 @@ var resolveCreateGameInput = async ({
1164
1284
  };
1165
1285
  };
1166
1286
  var runGameListCommand = async ({
1167
- platformUrl
1287
+ platformUrl,
1288
+ json
1168
1289
  }) => {
1169
1290
  const result = await listPlatformGames({ platformUrl });
1170
- console.log(kleur2.green("\n\u2713 Hosted games\n"));
1291
+ if (json) {
1292
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
1293
+ `);
1294
+ return;
1295
+ }
1296
+ console.log(kleur3.green("\n\u2713 Hosted games\n"));
1171
1297
  if (result.games.length === 0) {
1172
- console.log(kleur2.dim("No owned hosted games found."));
1298
+ console.log(kleur3.dim("No owned hosted games found."));
1173
1299
  return;
1174
1300
  }
1175
1301
  for (const game of result.games) {
1176
1302
  console.log(
1177
- `${kleur2.cyan(game.id)} ${game.slug ? kleur2.yellow(game.slug) : kleur2.dim("(no slug)")} ${game.name} ${kleur2.dim(game.arcadeVisibility)}`
1303
+ `${kleur3.cyan(game.id)} ${game.slug ? kleur3.yellow(game.slug) : kleur3.dim("(no slug)")} ${game.name} ${kleur3.dim(game.arcadeVisibility)} ${formatArcadeListing(game.arcadeListing)}`
1178
1304
  );
1179
1305
  }
1180
1306
  };
1181
1307
  var runGameInspectCommand = async ({
1182
1308
  platformUrl,
1183
- game
1309
+ game,
1310
+ json
1184
1311
  }) => {
1185
1312
  const result = await inspectPlatformGame({
1186
1313
  platformUrl,
1187
1314
  slugOrId: game
1188
1315
  });
1316
+ if (json) {
1317
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
1318
+ `);
1319
+ return;
1320
+ }
1189
1321
  printHostedGame({
1190
1322
  game: result.game,
1191
1323
  heading: "Hosted game"
@@ -1303,93 +1435,6 @@ var runGameUpdateCommand = async ({
1303
1435
  heading: "Hosted game updated"
1304
1436
  });
1305
1437
  };
1306
- var runGameMediaInspectCommand = async ({
1307
- platformUrl,
1308
- game
1309
- }) => {
1310
- const result = await inspectPlatformGameMedia({
1311
- platformUrl,
1312
- slugOrId: game
1313
- });
1314
- printHostedGameMedia({
1315
- result,
1316
- heading: "Hosted game media"
1317
- });
1318
- };
1319
- var runGameMediaUploadCommand = async ({
1320
- platformUrl,
1321
- game,
1322
- thumbnail,
1323
- cover,
1324
- previewVideo
1325
- }) => {
1326
- const uploads = [
1327
- ...thumbnail ? [{ kind: "thumbnail", filePath: thumbnail }] : [],
1328
- ...cover ? [{ kind: "cover", filePath: cover }] : [],
1329
- ...previewVideo ? [{ kind: "preview_video", filePath: previewVideo }] : []
1330
- ];
1331
- if (uploads.length === 0) {
1332
- throw new Error(
1333
- "No media files were provided. Pass at least one of --thumbnail, --cover, or --preview-video."
1334
- );
1335
- }
1336
- console.log(kleur2.green("\n\u2713 Uploading hosted game media\n"));
1337
- for (const upload of uploads) {
1338
- const result = await uploadPlatformGameMediaFile({
1339
- platformUrl,
1340
- slugOrId: game,
1341
- kind: upload.kind,
1342
- filePath: upload.filePath
1343
- });
1344
- console.log(
1345
- `${kleur2.cyan(GAME_MEDIA_KIND_LABEL[upload.kind])}: ${kleur2.cyan(result.assigned.asset.id)} ${kleur2.dim(result.filePath)}`
1346
- );
1347
- }
1348
- const inspected = await inspectPlatformGameMedia({
1349
- platformUrl,
1350
- slugOrId: game
1351
- });
1352
- printHostedGameMedia({
1353
- result: inspected,
1354
- heading: "Hosted game media updated"
1355
- });
1356
- };
1357
- var runGameMediaClearCommand = async ({
1358
- platformUrl,
1359
- game,
1360
- kind
1361
- }) => {
1362
- const current = await inspectPlatformGameMedia({
1363
- platformUrl,
1364
- slugOrId: game
1365
- });
1366
- const activeAsset = current.assets.find(
1367
- (asset) => asset.kind === kind && asset.isActive
1368
- );
1369
- if (!activeAsset) {
1370
- console.log(
1371
- kleur2.yellow(
1372
- `
1373
- No active ${GAME_MEDIA_KIND_LABEL[kind].toLowerCase()} to clear.
1374
- `
1375
- )
1376
- );
1377
- return;
1378
- }
1379
- await archivePlatformGameMediaAsset({
1380
- platformUrl,
1381
- slugOrId: game,
1382
- assetId: activeAsset.id
1383
- });
1384
- const inspected = await inspectPlatformGameMedia({
1385
- platformUrl,
1386
- slugOrId: game
1387
- });
1388
- printHostedGameMedia({
1389
- result: inspected,
1390
- heading: `${GAME_MEDIA_KIND_LABEL[kind]} cleared`
1391
- });
1392
- };
1393
1438
  var runReleaseInspectCommand = async ({
1394
1439
  platformUrl,
1395
1440
  releaseId
@@ -1399,28 +1444,29 @@ var runReleaseInspectCommand = async ({
1399
1444
  releaseId
1400
1445
  });
1401
1446
  const release = result.release;
1402
- console.log(kleur2.green("\n\u2713 Hosted release\n"));
1403
- console.log(`Release: ${kleur2.cyan(release.id)}`);
1404
- console.log(`Game: ${kleur2.cyan(release.game.name)}`);
1405
- console.log(`Status: ${kleur2.cyan(release.status)}`);
1406
- console.log(`Version: ${kleur2.cyan(release.versionLabel ?? "(untitled)")}`);
1407
- console.log(`Created: ${kleur2.cyan(release.createdAt)}`);
1447
+ console.log(kleur3.green("\n\u2713 Hosted release\n"));
1448
+ console.log(`Release: ${kleur3.cyan(release.id)}`);
1449
+ console.log(`Game: ${kleur3.cyan(release.game.name)}`);
1450
+ console.log(`Status: ${kleur3.cyan(release.status)}`);
1451
+ console.log(`Version: ${kleur3.cyan(release.versionLabel ?? "(untitled)")}`);
1452
+ console.log(`Created: ${kleur3.cyan(release.createdAt)}`);
1453
+ console.log(`Play URL: ${kleur3.cyan(release.playUrl)}`);
1408
1454
  if (release.hostUrl) {
1409
- console.log(`Host URL: ${kleur2.cyan(release.hostUrl)}`);
1455
+ console.log(`Host URL: ${kleur3.cyan(release.hostUrl)}`);
1410
1456
  }
1411
1457
  if (release.controllerUrl) {
1412
- console.log(`Controller URL: ${kleur2.cyan(release.controllerUrl)}`);
1458
+ console.log(`Controller URL: ${kleur3.cyan(release.controllerUrl)}`);
1413
1459
  }
1414
- const formatGeneration = (generation) => `${kleur2.cyan(generation.id)} (#${generation.sequence}, ${kleur2.yellow(generation.status)})`;
1460
+ const formatGeneration = (generation) => `${kleur3.cyan(generation.id)} (#${generation.sequence}, ${kleur3.yellow(generation.status)})`;
1415
1461
  console.log(
1416
- `Candidate generation: ${release.candidateGeneration ? formatGeneration(release.candidateGeneration) : kleur2.dim("none")}`
1462
+ `Candidate generation: ${release.candidateGeneration ? formatGeneration(release.candidateGeneration) : kleur3.dim("none")}`
1417
1463
  );
1418
1464
  console.log(
1419
- `Promoted generation: ${release.promotedGeneration ? formatGeneration(release.promotedGeneration) : kleur2.dim("none")}`
1465
+ `Promoted generation: ${release.promotedGeneration ? formatGeneration(release.promotedGeneration) : kleur3.dim("none")}`
1420
1466
  );
1421
1467
  if (release.generations.length > 0) {
1422
1468
  console.log("");
1423
- console.log(kleur2.dim("Generation history:"));
1469
+ console.log(kleur3.dim("Generation history:"));
1424
1470
  for (const generation of release.generations) {
1425
1471
  const observedSize = generation.observedSizeBytes ? `, ${generation.observedSizeBytes} bytes observed` : "";
1426
1472
  console.log(
@@ -1430,7 +1476,7 @@ var runReleaseInspectCommand = async ({
1430
1476
  }
1431
1477
  if (release.checks.length > 0) {
1432
1478
  console.log("");
1433
- console.log(kleur2.dim("Checks:"));
1479
+ console.log(kleur3.dim("Checks:"));
1434
1480
  for (const check of release.checks) {
1435
1481
  console.log(
1436
1482
  `- ${check.kind}: ${check.status} [generation ${check.generationId}]${check.summary ? ` (${check.summary})` : ""}`
@@ -1450,7 +1496,7 @@ var runReleaseSubmitCommand = async ({
1450
1496
  processingTimeoutSeconds,
1451
1497
  publish = false
1452
1498
  }) => {
1453
- const resolvedCwd = path4.resolve(dir || process.cwd());
1499
+ const resolvedCwd = path3.resolve(dir || process.cwd());
1454
1500
  if (processingTimeoutSeconds !== void 0 && (!Number.isSafeInteger(processingTimeoutSeconds) || processingTimeoutSeconds < 1)) {
1455
1501
  throw new Error("--processing-timeout must be a positive integer.");
1456
1502
  }
@@ -1483,35 +1529,35 @@ var runReleaseSubmitCommand = async ({
1483
1529
  }
1484
1530
  throw error;
1485
1531
  }
1486
- console.log(kleur2.green("\n\u2713 Hosted release submitted\n"));
1487
- console.log(`Bundle: ${kleur2.cyan(result.bundlePath)}`);
1488
- console.log(`Draft: ${kleur2.cyan(result.createdRelease.id)}`);
1532
+ console.log(kleur3.green("\n\u2713 Hosted release submitted\n"));
1533
+ console.log(`Bundle: ${kleur3.cyan(result.bundlePath)}`);
1534
+ console.log(`Draft: ${kleur3.cyan(result.createdRelease.id)}`);
1489
1535
  console.log(
1490
- `Created generation: ${kleur2.cyan(result.createdGeneration.id)} (#${result.createdGeneration.sequence})`
1536
+ `Created generation: ${kleur3.cyan(result.createdGeneration.id)} (#${result.createdGeneration.sequence})`
1491
1537
  );
1492
1538
  console.log(
1493
- `Submitted generation: ${kleur2.cyan(result.submittedGeneration.id)} (${kleur2.yellow(result.submittedGeneration.status)})`
1539
+ `Submitted generation: ${kleur3.cyan(result.submittedGeneration.id)} (${kleur3.yellow(result.submittedGeneration.status)})`
1494
1540
  );
1495
1541
  console.log(
1496
- `Processing job: ${kleur2.cyan(result.processingJob.id)} (${kleur2.yellow(result.processingJob.status)})`
1542
+ `Processing job: ${kleur3.cyan(result.processingJob.id)} (${kleur3.yellow(result.processingJob.status)})`
1497
1543
  );
1498
1544
  console.log(
1499
- `Release status: ${kleur2.yellow(result.submittedRelease.status)}`
1545
+ `Release status: ${kleur3.yellow(result.submittedRelease.status)}`
1500
1546
  );
1501
1547
  if (result.processedRelease) {
1502
1548
  console.log(
1503
- `Processing complete: ${kleur2.cyan(result.processedRelease.id)} (${kleur2.yellow(result.processedRelease.status)})`
1549
+ `Processing complete: ${kleur3.cyan(result.processedRelease.id)} (${kleur3.yellow(result.processedRelease.status)})`
1504
1550
  );
1505
1551
  } else {
1506
1552
  console.log(
1507
- kleur2.dim(
1553
+ kleur3.dim(
1508
1554
  `Inspect with: airjam release inspect --release ${result.submittedRelease.id}`
1509
1555
  )
1510
1556
  );
1511
1557
  }
1512
1558
  if (result.publishedRelease) {
1513
1559
  console.log(
1514
- `Published: ${kleur2.cyan(result.publishedRelease.id)} (${kleur2.yellow(result.publishedRelease.status)})`
1560
+ `Published: ${kleur3.cyan(result.publishedRelease.id)} (${kleur3.yellow(result.publishedRelease.status)})`
1515
1561
  );
1516
1562
  }
1517
1563
  };
@@ -1524,17 +1570,17 @@ var runReleaseUploadCommand = async ({
1524
1570
  const result = await uploadPlatformReleaseGeneration({
1525
1571
  platformUrl,
1526
1572
  releaseId,
1527
- cwd: path4.resolve(dir || process.cwd()),
1573
+ cwd: path3.resolve(dir || process.cwd()),
1528
1574
  bundlePath: bundle
1529
1575
  });
1530
- console.log(kleur2.green("\n\u2713 Hosted release generation uploaded\n"));
1531
- console.log(`Bundle: ${kleur2.cyan(result.bundlePath)}`);
1532
- console.log(`Release: ${kleur2.cyan(result.release.id)}`);
1576
+ console.log(kleur3.green("\n\u2713 Hosted release generation uploaded\n"));
1577
+ console.log(`Bundle: ${kleur3.cyan(result.bundlePath)}`);
1578
+ console.log(`Release: ${kleur3.cyan(result.release.id)}`);
1533
1579
  console.log(
1534
- `Generation: ${kleur2.cyan(result.generation.id)} (#${result.generation.sequence}, ${kleur2.yellow(result.generation.status)})`
1580
+ `Generation: ${kleur3.cyan(result.generation.id)} (#${result.generation.sequence}, ${kleur3.yellow(result.generation.status)})`
1535
1581
  );
1536
1582
  console.log(
1537
- kleur2.dim(
1583
+ kleur3.dim(
1538
1584
  `Resume with: airjam release finalize --release ${result.release.id} --generation ${result.generation.id}`
1539
1585
  )
1540
1586
  );
@@ -1549,17 +1595,17 @@ var runReleaseFinalizeCommand = async ({
1549
1595
  releaseId,
1550
1596
  generationId
1551
1597
  });
1552
- console.log(kleur2.green("\n\u2713 Hosted release processing queued\n"));
1553
- console.log(`Release: ${kleur2.cyan(result.release.id)}`);
1554
- console.log(`Release status: ${kleur2.yellow(result.release.status)}`);
1598
+ console.log(kleur3.green("\n\u2713 Hosted release processing queued\n"));
1599
+ console.log(`Release: ${kleur3.cyan(result.release.id)}`);
1600
+ console.log(`Release status: ${kleur3.yellow(result.release.status)}`);
1555
1601
  console.log(
1556
- `Generation: ${kleur2.cyan(result.generation.id)} (${kleur2.yellow(result.generation.status)})`
1602
+ `Generation: ${kleur3.cyan(result.generation.id)} (${kleur3.yellow(result.generation.status)})`
1557
1603
  );
1558
1604
  console.log(
1559
- `Processing job: ${kleur2.cyan(result.job.id)} (${kleur2.yellow(result.job.status)})`
1605
+ `Processing job: ${kleur3.cyan(result.job.id)} (${kleur3.yellow(result.job.status)})`
1560
1606
  );
1561
1607
  console.log(
1562
- kleur2.dim(
1608
+ kleur3.dim(
1563
1609
  `Inspect with: airjam release inspect --release ${result.release.id}`
1564
1610
  )
1565
1611
  );
@@ -1575,16 +1621,16 @@ var runReleaseExportCommand = async ({
1575
1621
  platformUrl,
1576
1622
  releaseId,
1577
1623
  generationId,
1578
- cwd: path4.resolve(dir || process.cwd()),
1624
+ cwd: path3.resolve(dir || process.cwd()),
1579
1625
  out
1580
1626
  });
1581
- console.log(kleur2.green("\n\u2713 Hosted release generation exported\n"));
1582
- console.log(`Release: ${kleur2.cyan(releaseId)}`);
1627
+ console.log(kleur3.green("\n\u2713 Hosted release generation exported\n"));
1628
+ console.log(`Release: ${kleur3.cyan(releaseId)}`);
1583
1629
  console.log(
1584
- `Generation: ${kleur2.cyan(result.generation.id)} (#${result.generation.sequence})`
1630
+ `Generation: ${kleur3.cyan(result.generation.id)} (#${result.generation.sequence})`
1585
1631
  );
1586
- console.log(`Archive: ${kleur2.cyan(result.outputFile)}`);
1587
- console.log(`Size: ${kleur2.cyan(`${result.sizeBytes} bytes`)}`);
1632
+ console.log(`Archive: ${kleur3.cyan(result.outputFile)}`);
1633
+ console.log(`Size: ${kleur3.cyan(`${result.sizeBytes} bytes`)}`);
1588
1634
  };
1589
1635
  var runReleasePublishCommand = async ({
1590
1636
  platformUrl,
@@ -1594,57 +1640,58 @@ var runReleasePublishCommand = async ({
1594
1640
  platformUrl,
1595
1641
  releaseId
1596
1642
  });
1597
- console.log(kleur2.green("\n\u2713 Hosted release published\n"));
1598
- console.log(`Release: ${kleur2.cyan(result.release.id)}`);
1599
- console.log(`Status: ${kleur2.cyan(result.release.status)}`);
1643
+ console.log(kleur3.green("\n\u2713 Hosted release published\n"));
1644
+ console.log(`Release: ${kleur3.cyan(result.release.id)}`);
1645
+ console.log(`Status: ${kleur3.cyan(result.release.status)}`);
1646
+ console.log(`Play URL: ${kleur3.cyan(result.release.playUrl)}`);
1600
1647
  if (result.release.hostUrl) {
1601
- console.log(`Host URL: ${kleur2.cyan(result.release.hostUrl)}`);
1648
+ console.log(`Host URL: ${kleur3.cyan(result.release.hostUrl)}`);
1602
1649
  }
1603
1650
  };
1604
1651
  var runAuthLoginCommand = async ({
1605
1652
  platformUrl,
1606
1653
  clientName
1607
1654
  }) => {
1608
- console.log(kleur2.cyan("\nStarting Air Jam platform login...\n"));
1655
+ console.log(kleur3.cyan("\nStarting Air Jam platform login...\n"));
1609
1656
  const result = await loginPlatformWithDeviceFlow({
1610
1657
  platformUrl,
1611
1658
  clientName,
1612
1659
  onPrompt: async (authorization) => {
1613
1660
  console.log(
1614
- `Verification URL: ${kleur2.cyan(authorization.verificationUrl)}`
1661
+ `Verification URL: ${kleur3.cyan(authorization.verificationUrl)}`
1615
1662
  );
1616
- console.log(`Approval code: ${kleur2.cyan(authorization.userCode)}`);
1663
+ console.log(`Approval code: ${kleur3.cyan(authorization.userCode)}`);
1617
1664
  console.log(
1618
- kleur2.dim(
1665
+ kleur3.dim(
1619
1666
  "Sign in on the dashboard, approve the CLI request, and this command will finish automatically.\n"
1620
1667
  )
1621
1668
  );
1622
1669
  }
1623
1670
  });
1624
- console.log(kleur2.green("\n\u2713 Logged in to the Air Jam platform\n"));
1625
- console.log(`Platform: ${kleur2.cyan(result.authenticated.platformBaseUrl)}`);
1626
- console.log(`User: ${kleur2.cyan(result.authenticated.user.name)}`);
1627
- console.log(`Email: ${kleur2.cyan(result.authenticated.user.email)}`);
1628
- console.log(`Session file: ${kleur2.dim(getPlatformAuthStoragePath())}`);
1671
+ console.log(kleur3.green("\n\u2713 Logged in to the Air Jam platform\n"));
1672
+ console.log(`Platform: ${kleur3.cyan(result.authenticated.platformBaseUrl)}`);
1673
+ console.log(`User: ${kleur3.cyan(result.authenticated.user.name)}`);
1674
+ console.log(`Email: ${kleur3.cyan(result.authenticated.user.email)}`);
1675
+ console.log(`Session file: ${kleur3.dim(getPlatformAuthStoragePath())}`);
1629
1676
  };
1630
1677
  var runAuthWhoAmICommand = async ({
1631
1678
  platformUrl
1632
1679
  }) => {
1633
1680
  const storedSession = await readStoredPlatformMachineSession();
1634
1681
  if (!storedSession) {
1635
- console.log(kleur2.red("No stored Air Jam platform session was found."));
1636
- console.log(kleur2.dim(`Expected at ${getPlatformAuthStoragePath()}`));
1682
+ console.log(kleur3.red("No stored Air Jam platform session was found."));
1683
+ console.log(kleur3.dim(`Expected at ${getPlatformAuthStoragePath()}`));
1637
1684
  process.exitCode = 1;
1638
1685
  return;
1639
1686
  }
1640
1687
  const profile = await getPlatformMachineProfile({ platformUrl });
1641
- console.log(kleur2.green("\n\u2713 Air Jam platform session is valid\n"));
1642
- console.log(`Platform: ${kleur2.cyan(profile.platformBaseUrl)}`);
1643
- console.log(`User: ${kleur2.cyan(profile.user.name)}`);
1644
- console.log(`Email: ${kleur2.cyan(profile.user.email)}`);
1645
- console.log(`Role: ${kleur2.cyan(profile.user.role)}`);
1646
- console.log(`Expires: ${kleur2.cyan(profile.session.expiresAt)}`);
1647
- console.log(`Session file: ${kleur2.dim(getPlatformAuthStoragePath())}`);
1688
+ console.log(kleur3.green("\n\u2713 Air Jam platform session is valid\n"));
1689
+ console.log(`Platform: ${kleur3.cyan(profile.platformBaseUrl)}`);
1690
+ console.log(`User: ${kleur3.cyan(profile.user.name)}`);
1691
+ console.log(`Email: ${kleur3.cyan(profile.user.email)}`);
1692
+ console.log(`Role: ${kleur3.cyan(profile.user.role)}`);
1693
+ console.log(`Expires: ${kleur3.cyan(profile.session.expiresAt)}`);
1694
+ console.log(`Session file: ${kleur3.dim(getPlatformAuthStoragePath())}`);
1648
1695
  };
1649
1696
  var runAuthLogoutCommand = async ({
1650
1697
  platformUrl
@@ -1656,18 +1703,18 @@ var runAuthLogoutCommand = async ({
1656
1703
  if (!(error instanceof AirJamStoredPlatformSessionError)) throw error;
1657
1704
  await clearStoredPlatformMachineSession();
1658
1705
  console.log(
1659
- kleur2.yellow(
1706
+ kleur3.yellow(
1660
1707
  "Removed an unreadable local Air Jam session. Its remote token could not be revoked."
1661
1708
  )
1662
1709
  );
1663
1710
  return;
1664
1711
  }
1665
1712
  if (!storedSession) {
1666
- console.log(kleur2.yellow("No stored Air Jam platform session was found."));
1713
+ console.log(kleur3.yellow("No stored Air Jam platform session was found."));
1667
1714
  return;
1668
1715
  }
1669
1716
  await logoutPlatformMachineSession({ platformUrl });
1670
- console.log(kleur2.green("\n\u2713 Logged out of the Air Jam platform\n"));
1717
+ console.log(kleur3.green("\n\u2713 Logged out of the Air Jam platform\n"));
1671
1718
  };
1672
1719
  var buildProgram = () => {
1673
1720
  const program = new Command();
@@ -1738,17 +1785,18 @@ var buildProgram = () => {
1738
1785
  process.exitCode = 1;
1739
1786
  }
1740
1787
  });
1741
- const gameCommand = program.command("game").description("Manage hosted Air Jam game records on the platform");
1742
- gameCommand.command("list").description("List owned hosted games").option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1788
+ const gameCommand = program.command("game").description("Manage hosted games and local game source");
1789
+ gameCommand.command("list").description("List owned hosted games").option("--json", "Print one machine-readable JSON document", false).option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1743
1790
  await runGameListCommand(
1744
1791
  resolveActionOptions(options)
1745
1792
  );
1746
1793
  });
1747
- gameCommand.command("inspect").description("Inspect one owned hosted game").requiredOption("--game <slug-or-id>", "Owned hosted game slug or ID").option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1794
+ gameCommand.command("inspect").description("Inspect one owned hosted game").option("--json", "Print one machine-readable JSON document", false).requiredOption("--game <slug-or-id>", "Owned hosted game slug or ID").option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1748
1795
  const resolved = resolveActionOptions(options);
1749
1796
  await runGameInspectCommand({
1750
1797
  platformUrl: resolved.platformUrl,
1751
- game: resolved.game
1798
+ game: resolved.game,
1799
+ json: resolved.json
1752
1800
  });
1753
1801
  });
1754
1802
  gameCommand.command("create").description("Create a hosted game record for release publishing").option("--platform-url <url>", "Hosted Air Jam platform base URL").option(
@@ -1792,38 +1840,10 @@ var buildProgram = () => {
1792
1840
  arcadeVisibility: resolved.arcadeVisibility
1793
1841
  });
1794
1842
  });
1795
- const gameMediaCommand = gameCommand.command("media").description("Manage hosted game media assets");
1796
- gameMediaCommand.command("inspect").description("Inspect hosted media for one owned game").requiredOption("--game <slug-or-id>", "Owned hosted game slug or ID").option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1797
- const resolved = resolveActionOptions(options);
1798
- await runGameMediaInspectCommand({
1799
- platformUrl: resolved.platformUrl,
1800
- game: resolved.game
1801
- });
1802
- });
1803
- gameMediaCommand.command("upload").description("Upload and assign hosted media for one owned game").requiredOption("--game <slug-or-id>", "Owned hosted game slug or ID").option("--platform-url <url>", "Hosted Air Jam platform base URL").option("--thumbnail <path>", "Thumbnail image file").option("--cover <path>", "Cover image file").option("--preview-video <path>", "Preview video file").action(async (options) => {
1804
- const resolved = resolveActionOptions(options);
1805
- await runGameMediaUploadCommand({
1806
- platformUrl: resolved.platformUrl,
1807
- game: resolved.game,
1808
- thumbnail: resolved.thumbnail,
1809
- cover: resolved.cover,
1810
- previewVideo: resolved.previewVideo
1811
- });
1812
- });
1813
- gameMediaCommand.command("clear").description("Archive the currently active hosted media asset for one slot").requiredOption("--game <slug-or-id>", "Owned hosted game slug or ID").requiredOption(
1814
- "--kind <kind>",
1815
- "Media slot to clear (thumbnail, cover, or preview_video)"
1816
- ).option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1817
- const resolved = resolveActionOptions(options);
1818
- await runGameMediaClearCommand({
1819
- platformUrl: resolved.platformUrl,
1820
- game: resolved.game,
1821
- kind: normalizeGameMediaKind(resolved.kind)
1822
- });
1823
- });
1824
- gameMediaCommand.action(() => {
1825
- gameMediaCommand.outputHelp();
1826
- });
1843
+ registerGameSettingsCommand(gameCommand);
1844
+ registerGameAppIdCommands(gameCommand);
1845
+ registerGameAnalyticsCommand(gameCommand);
1846
+ registerGameMediaCommands(gameCommand);
1827
1847
  gameCommand.action(() => {
1828
1848
  gameCommand.outputHelp();
1829
1849
  });
@@ -1922,6 +1942,17 @@ var buildProgram = () => {
1922
1942
  releaseId: resolved.release
1923
1943
  });
1924
1944
  });
1945
+ releaseCommand.command("archive").description(
1946
+ "Retire one owned hosted release so it can no longer be played"
1947
+ ).requiredOption("--release <id>", "Exact hosted release ID to archive").option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1948
+ const resolved = resolveActionOptions(options);
1949
+ const result = await archivePlatformRelease({
1950
+ platformUrl: resolved.platformUrl,
1951
+ releaseId: resolved.release
1952
+ });
1953
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
1954
+ `);
1955
+ });
1925
1956
  releaseCommand.command("export").description("Download one exact immutable hosted release generation").requiredOption("--release <id>", "Hosted release ID").requiredOption("--generation <id>", "Immutable generation ID").option("--dir <path>", "Directory used to resolve the output path").option("--out <path>", "Output archive path; refuses to overwrite").option("--platform-url <url>", "Hosted Air Jam platform base URL").action(async (options) => {
1926
1957
  const resolved = resolveActionOptions(options);
1927
1958
  await runReleaseExportCommand({
@@ -1951,6 +1982,8 @@ var buildProgram = () => {
1951
1982
  resolveActionOptions(options)
1952
1983
  );
1953
1984
  });
1985
+ registerAuthProfileCommand(authCommand);
1986
+ registerAuthSessionsCommand(authCommand);
1954
1987
  authCommand.action(() => {
1955
1988
  authCommand.outputHelp();
1956
1989
  });
@@ -1967,7 +2000,7 @@ var buildProgram = () => {
1967
2000
  });
1968
2001
  mcpCommand.command("config").description("Render a portable, Codex, or Claude Desktop MCP profile").option("--dir <path>", "Project directory to inspect").option(
1969
2002
  "--profile <profile>",
1970
- "Profile to render (portable, codex, or claude-desktop)",
2003
+ "Profile to render (portable, codex, or claude-desktop); Codex supports CLI, IDE and app",
1971
2004
  "portable"
1972
2005
  ).option("--json", "Print the rendered profile metadata as JSON", false).action(async (options) => {
1973
2006
  const resolved = resolveActionOptions(options);
@@ -1979,6 +2012,219 @@ var buildProgram = () => {
1979
2012
  const sessionCommand = program.command("session").description(
1980
2013
  "Operate persistent semantic game sessions through stable JSON contracts"
1981
2014
  );
2015
+ const runCommand = sessionCommand.command("run").description("Discover, start, inspect and stop bounded agent play runs");
2016
+ runCommand.command("profiles").option("--dir <path>", "Project directory").option("--game <id>", "Game ID in a monorepo").action(async (options) => {
2017
+ const input = resolveActionOptions(
2018
+ options
2019
+ );
2020
+ process.stdout.write(
2021
+ `${JSON.stringify(await listGameTestProfiles({ cwd: input.dir, gameId: input.game }), null, 2)}
2022
+ `
2023
+ );
2024
+ });
2025
+ runCommand.command("start").description(
2026
+ "Start an authored test or join the current room as a model player"
2027
+ ).requiredOption("--run-id <uuid>", "Stable caller-generated operation UUID").option("--kind <kind>", "test or play", "test").option("--profile <id>", "Authored scenario ID (test only)").option("--policy <id>", "Scenario policy ID (test only)").option(
2028
+ "--current",
2029
+ "Join the delegated current room; receive its private attachment through stdin"
2030
+ ).option(
2031
+ "--headless",
2032
+ "Play in a room with no page, on game time, as fast as the host runs"
2033
+ ).option("--dir <path>", "Project directory").option("--game <id>", "Game ID in a monorepo").option(
2034
+ "--duration-ms <ms>",
2035
+ "Maximum play time (game time when headless) and wall lifetime",
2036
+ Number
2037
+ ).option("--settings <json>", "Initial game settings JSON object").option("--steps <count>", "Maximum policy decisions (test only)", Number).option(
2038
+ "--seed <number>",
2039
+ "Policy random seed; a headless room also seeds the game with it",
2040
+ Number,
2041
+ 0
2042
+ ).option(
2043
+ "--intent <seat=text>",
2044
+ "Play intent text, or <seat=text> for each test seat",
2045
+ (value, previous = []) => [...previous, value]
2046
+ ).action(async (options) => {
2047
+ const input = resolveActionOptions(options);
2048
+ if (input.current && input.headless)
2049
+ throw new Error("Choose either --current or --headless.");
2050
+ if (input.kind !== "test" && input.kind !== "play")
2051
+ throw new Error("Choose --kind test or play.");
2052
+ if (input.kind === "play" && (!input.current || input.profile || input.policy || input.settings || input.durationMs !== void 0 || input.steps !== void 0 || (input.intent?.length ?? 0) > 1))
2053
+ throw new Error(
2054
+ "Play requires --current, at most one intent, and no test profile, policy, settings or budget."
2055
+ );
2056
+ const testPolicy = input.kind === "test" ? (() => {
2057
+ if (!input.profile || !input.policy)
2058
+ throw new Error("Tests require --profile and --policy.");
2059
+ return { profileId: input.profile, policyId: input.policy };
2060
+ })() : void 0;
2061
+ const intents = input.kind === "test" && input.intent?.length ? Object.fromEntries(
2062
+ input.intent.map((entry) => {
2063
+ const separator = entry.indexOf("=");
2064
+ if (separator < 1)
2065
+ throw new Error("Write each intent as <seat-id>=<text>.");
2066
+ return [entry.slice(0, separator), entry.slice(separator + 1)];
2067
+ })
2068
+ ) : void 0;
2069
+ let attachment;
2070
+ if (input.current) {
2071
+ if (process.stdin.isTTY)
2072
+ throw new Error(
2073
+ "Current-room play requires a private stdin attachment."
2074
+ );
2075
+ const chunks = [];
2076
+ let bytes = 0;
2077
+ for await (const chunk of process.stdin) {
2078
+ const buffer = Buffer.from(chunk);
2079
+ bytes += buffer.byteLength;
2080
+ if (bytes > 16384)
2081
+ throw new Error(
2082
+ "Current-room attachment exceeds its transfer allowance."
2083
+ );
2084
+ chunks.push(buffer);
2085
+ }
2086
+ try {
2087
+ attachment = currentRoomAttachmentSchema.parse(
2088
+ JSON.parse(Buffer.concat(chunks).toString("utf8"))
2089
+ );
2090
+ } catch {
2091
+ throw new Error("Current-room attachment failed validation.");
2092
+ }
2093
+ }
2094
+ const result = await startGameRun(
2095
+ startGameRunSchema.parse({
2096
+ cwd: input.dir,
2097
+ runId: input.runId,
2098
+ gameId: input.game,
2099
+ seed: input.seed,
2100
+ ...input.kind === "play" ? {
2101
+ kind: "play",
2102
+ target: { kind: "current" },
2103
+ ...input.intent?.[0] ? { intent: input.intent[0] } : {}
2104
+ } : {
2105
+ kind: "test",
2106
+ target: {
2107
+ kind: input.current ? "current" : input.headless ? "headless" : "owned"
2108
+ },
2109
+ ...testPolicy,
2110
+ ...input.settings ? {
2111
+ settings: airJamSettingsValuesSchema.parse(
2112
+ parseJsonObject(input.settings)
2113
+ )
2114
+ } : {},
2115
+ budget: {
2116
+ durationMs: input.durationMs ?? 3e4,
2117
+ steps: input.steps ?? 3e3
2118
+ },
2119
+ ...intents ? { intents } : {}
2120
+ }
2121
+ }),
2122
+ attachment
2123
+ );
2124
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
2125
+ `);
2126
+ });
2127
+ for (const [name, operation] of [
2128
+ ["read", readGameRun],
2129
+ ["stop", stopGameRun],
2130
+ ["cancel", cancelGameRun]
2131
+ ]) {
2132
+ runCommand.command(`${name} <run-id>`).option("--dir <path>", "Project directory").action(async (runId, options) => {
2133
+ const input = resolveActionOptions(options);
2134
+ process.stdout.write(
2135
+ `${JSON.stringify(await operation({ cwd: input.dir, runId }), null, 2)}
2136
+ `
2137
+ );
2138
+ });
2139
+ }
2140
+ runCommand.command("replay <run-id>").description(
2141
+ "Replay an ended headless run from its input log and compare where it ends"
2142
+ ).option("--dir <path>", "Project directory").action(async (runId, options) => {
2143
+ const input = resolveActionOptions(options);
2144
+ process.stdout.write(
2145
+ `${JSON.stringify(await replayGameRun({ cwd: input.dir, runId }), null, 2)}
2146
+ `
2147
+ );
2148
+ });
2149
+ runCommand.command("steer <run-id>").description(
2150
+ "Change what one seat of an active run is trying to do; never sends a control"
2151
+ ).requiredOption("--seat <id>", "Seat to steer").option("--intent <text>", "The seat's new goal in plain words").option("--clear", "Remove the seat's goal").option("--source <source>", "creator, agent or operator", "operator").option("--dir <path>", "Project directory").action(async (runId, options) => {
2152
+ const input = resolveActionOptions(options);
2153
+ if (Boolean(input.clear) === (input.intent !== void 0))
2154
+ throw new Error("Give either --intent <text> or --clear.");
2155
+ process.stdout.write(
2156
+ `${JSON.stringify(
2157
+ await steerGameRun({
2158
+ cwd: input.dir,
2159
+ runId,
2160
+ seatId: input.seat,
2161
+ intent: input.clear ? null : input.intent ?? null,
2162
+ source: input.source
2163
+ }),
2164
+ null,
2165
+ 2
2166
+ )}
2167
+ `
2168
+ );
2169
+ });
2170
+ runCommand.command("watch <run-id>").description(
2171
+ "Stream live JPEG frames and producer heartbeats as NDJSON; disconnecting never stops the run"
2172
+ ).option("--dir <path>", "Project directory").option("--surface <surface>", "host or controller:<seat-id>", "host").action(async (runId, options) => {
2173
+ const input = resolveActionOptions(
2174
+ options
2175
+ );
2176
+ const surface = parseGameRunWatchSurface(input.surface);
2177
+ const cancellation = new AbortController();
2178
+ const writer = new GameRunWatchWriter(process.stdout);
2179
+ const stop = () => {
2180
+ writer.close();
2181
+ cancellation.abort();
2182
+ };
2183
+ process.once("SIGTERM", stop);
2184
+ process.once("SIGINT", stop);
2185
+ process.stdout.on("error", stop);
2186
+ try {
2187
+ await watchGameRun(
2188
+ { cwd: input.dir, runId, surface },
2189
+ (event) => writer.send(event),
2190
+ cancellation.signal
2191
+ );
2192
+ } catch (error) {
2193
+ if (!cancellation.signal.aborted) throw error;
2194
+ } finally {
2195
+ writer.close();
2196
+ process.off("SIGTERM", stop);
2197
+ process.off("SIGINT", stop);
2198
+ process.stdout.off("error", stop);
2199
+ }
2200
+ });
2201
+ runCommand.command("wait <run-id>").description(
2202
+ "Wait for completion or a bounded timeout; disconnecting never stops the run"
2203
+ ).option("--dir <path>", "Project directory").option("--timeout-ms <ms>", "Wait at most 30000 ms", Number, 25e3).action(async (runId, options) => {
2204
+ const input = resolveActionOptions(
2205
+ options
2206
+ );
2207
+ process.stdout.write(
2208
+ `${JSON.stringify(await waitGameRun({ cwd: input.dir, runId, timeoutMs: input.timeoutMs }), null, 2)}
2209
+ `
2210
+ );
2211
+ });
2212
+ runCommand.command("stop-all").description(
2213
+ "Stop every active run in this project without starting an owner"
2214
+ ).option("--dir <path>", "Project directory").action(async (options) => {
2215
+ const input = resolveActionOptions(options);
2216
+ process.stdout.write(
2217
+ `${JSON.stringify(await stopAllGameRuns({ cwd: input.dir }), null, 2)}
2218
+ `
2219
+ );
2220
+ });
2221
+ runCommand.command("list").option("--dir <path>", "Project directory").action(async (options) => {
2222
+ const input = resolveActionOptions(options);
2223
+ process.stdout.write(
2224
+ `${JSON.stringify(await listGameRuns({ cwd: input.dir }), null, 2)}
2225
+ `
2226
+ );
2227
+ });
1982
2228
  sessionCommand.command("open").description("Open a persistent semantic game session").option("--dir <path>", "Project directory").option("--game <id>", "Game ID in a monorepo").option(
1983
2229
  "--mode <mode>",
1984
2230
  "Dev mode (standalone-dev, arcade-dev, or arcade-test)"
@@ -1996,15 +2242,55 @@ var buildProgram = () => {
1996
2242
  process.stdout.write(`${JSON.stringify(result, null, 2)}
1997
2243
  `);
1998
2244
  });
1999
- sessionCommand.command("read").description("Read runtime and semantic state from a persistent session").argument("<session-id>", "Game session ID").option("--dir <path>", "Project directory").option("--no-sync", "Read without requesting a fresh semantic snapshot").option("--timeout-ms <ms>", "Snapshot timeout in milliseconds", Number).action(async (sessionId, options) => {
2245
+ sessionCommand.command("read").description("Read runtime and semantic state from a persistent session").argument("<session-id>", "Game session ID").option("--dir <path>", "Project directory").option("--timeout-ms <ms>", "Snapshot timeout in milliseconds", Number).action(async (sessionId, options) => {
2000
2246
  const input = resolveActionOptions(options);
2001
2247
  const result = await readSession({
2002
2248
  dir: input.dir,
2003
2249
  gameSessionId: sessionId,
2004
- requestSync: input.sync,
2005
2250
  timeoutMs: input.timeoutMs
2006
2251
  });
2007
2252
  process.stdout.write(`${JSON.stringify(result, null, 2)}
2253
+ `);
2254
+ });
2255
+ sessionCommand.command("settings-read <session-id>").description("Read this host's settings values and revision").option("--dir <path>", "Project directory").action(async (gameSessionId, options) => {
2256
+ const { dir } = resolveActionOptions(options);
2257
+ process.stdout.write(
2258
+ `${JSON.stringify(await readGameSettings2({ gameSessionId, cwd: dir }), null, 2)}
2259
+ `
2260
+ );
2261
+ });
2262
+ sessionCommand.command("settings-update <session-id>").description("Change live settings at an expected revision").requiredOption("--patch <json>", "Settings patch JSON object").requiredOption(
2263
+ "--expected-revision <number>",
2264
+ "Revision from settings-read",
2265
+ Number
2266
+ ).option("--dir <path>", "Project directory").action(async (gameSessionId, options) => {
2267
+ const input = resolveActionOptions(options);
2268
+ const parsed = gameSessionOperationSchemas2["settings-update"].parse({
2269
+ gameSessionId,
2270
+ cwd: input.dir,
2271
+ patch: parseJsonObject(input.patch),
2272
+ expectedRevision: input.expectedRevision
2273
+ });
2274
+ process.stdout.write(
2275
+ `${JSON.stringify(await updateGameSettings2(parsed), null, 2)}
2276
+ `
2277
+ );
2278
+ });
2279
+ sessionCommand.command("control").description(
2280
+ "Send a fenced participant operation with an explicit lease and receipt"
2281
+ ).argument("<session-id>", "Game session ID").requiredOption(
2282
+ "--command <json>",
2283
+ "JSON containing expected identity, lease and operation (input/action/release)"
2284
+ ).option("--dir <path>", "Project directory").action(async (sessionId, options) => {
2285
+ const input = resolveActionOptions(
2286
+ options
2287
+ );
2288
+ const result = await controlSessionParticipant({
2289
+ dir: input.dir,
2290
+ gameSessionId: sessionId,
2291
+ command: parseJsonObject(input.command)
2292
+ });
2293
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
2008
2294
  `);
2009
2295
  });
2010
2296
  sessionCommand.command("input").description("Send validated controller input through a persistent session").argument("<session-id>", "Game session ID").requiredOption("--input <json>", "Controller input JSON object").option("--dir <path>", "Project directory").action(async (sessionId, options) => {
@@ -2068,10 +2354,7 @@ var buildProgram = () => {
2068
2354
  `);
2069
2355
  });
2070
2356
  sessionCommand.action(() => sessionCommand.outputHelp());
2071
- program.command("__session-broker", { hidden: true }).requiredOption("--dir <path>", "Project directory").action(async (options) => {
2072
- const input = resolveActionOptions(options);
2073
- await runSessionBrokerProcess(input.dir);
2074
- });
2357
+ registerRoomsCommand(program);
2075
2358
  program.command("status").description("Show local Air Jam dev process and known-port status").option("--dir <path>", "Project directory to inspect").action(async (options) => {
2076
2359
  const input = resolveActionOptions(options);
2077
2360
  const status = await getDevStatus({ cwd: input.dir });
@@ -2103,9 +2386,10 @@ var buildProgram = () => {
2103
2386
  "Network isolation:",
2104
2387
  " VITE_PORT=<port> Game app port (default: 5173)",
2105
2388
  " AIR_JAM_SERVER_PORT=<port> Local server port (default: 4000)",
2389
+ " AIR_JAM_BIND_HOST=<address> Bind address (default: all interfaces)",
2106
2390
  " VITE_AIR_JAM_PUBLIC_HOST=<url> Explicit host/controller origin",
2107
2391
  "",
2108
- "Set all three when parallel agents or local projects need isolated dev stacks."
2392
+ "Set ports and the public origin when parallel agents or local projects need isolated dev stacks."
2109
2393
  ].join("\n")
2110
2394
  ).action(async () => {
2111
2395
  await runGameDevCli({
@@ -2178,7 +2462,7 @@ main().catch((err) => {
2178
2462
  process.exit(1);
2179
2463
  return;
2180
2464
  }
2181
- console.error(kleur2.red("Error:"), err);
2465
+ console.error(kleur3.red("Error:"), err);
2182
2466
  process.exit(1);
2183
2467
  });
2184
2468
  //# sourceMappingURL=index.js.map