@bitmagic/cli 0.1.68-dev.2 → 0.1.68-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -218,6 +218,7 @@ browser reloads itself on every change and the assets panel shows each generatio
218
218
  | `bitmagic forge --prompt "..." [--city\|--dungeon\|--platformer\|--freeform] [--name <name>] [--resume <jobId>]` | Design and bake a whole playable level into `world.json`. Costs sparks, and takes many minutes — the bake alone can take twenty. `--resume <jobId>` picks a failed run back up from the last step that finished, rather than redoing the whole thing. |
219
219
  | `bitmagic forge --edit "..." [--level <id or name>]` | Change a detail of a level this project forged — a door style, the light fixtures, a prop — without re-forging it. The stored design is patched and only what the change touches is re-made; the level is replaced in place. See [Editing a forged level](#editing-a-forged-level). |
220
220
  | `bitmagic tools <list\|path\|install> [bundle]` | The script bundles the CLI ships for skills that drive Blender, Python or Node (`blender-level`, `unity-import`, `metahuman`): what they are, where this install keeps them, and `install` to copy one into the project's `tools/`. Local, no network, no sparks. |
221
+ | `bitmagic event <setup\|claude\|codex\|status\|env\|clear> ...` | **Sponsored events only.** `setup --key sk-…` stores the API key from your event card and checks it works; `claude` / `codex` start that agent pointed at the event endpoint; `status` shows what is left of your budget. Nothing you own is modified: Claude Code is configured purely through the environment of the process it starts, and Codex gets a separate profile of ours (your `~/.codex/config.toml` is untouched and still applies when you run `codex` yourself). `clear` removes both. Plain `claude` keeps using your own account — the event endpoint is only used when you start the agent through `bitmagic event`. |
221
222
  | `bitmagic levels <list\|add\|rename\|set-start\|remove> ...` | Manage the levels `forge` creates: which one boots, their names, registering a bake you already have, deleting one. Local, no network, no sparks. See **Managing levels** below. |
222
223
 
223
224
  Every command exits non-zero on failure with a single-line message (no stack trace) and, where a
package/dist/cli.d.ts CHANGED
@@ -306,6 +306,7 @@ declare const rawCommands: {
306
306
  readonly description: "Serve --mobile over http instead of a self-signed certificate (no WebGPU on the device).";
307
307
  };
308
308
  }>;
309
+ event: CommandDef<ArgsDef>;
309
310
  reload: CommandDef<{
310
311
  readonly 'original-prompt': {
311
312
  readonly type: "string";
package/dist/cli.js CHANGED
@@ -18,6 +18,7 @@ import { upgradeCommand } from './commands/upgrade.js';
18
18
  import { selfUpdateCommand } from './commands/self-update.js';
19
19
  import { checkCommand } from './commands/check.js';
20
20
  import { devCommand } from './commands/dev.js';
21
+ import { eventCommand } from './commands/event.js';
21
22
  import { reloadCommand } from './commands/reload.js';
22
23
  import { verifyCommand } from './commands/verify.js';
23
24
  import { buildCommand } from './commands/build.js';
@@ -211,6 +212,7 @@ const rawCommands = {
211
212
  'self-update': selfUpdateCommand,
212
213
  check: checkCommand,
213
214
  dev: devCommand,
215
+ event: eventCommand,
214
216
  reload: reloadCommand,
215
217
  verify: verifyCommand,
216
218
  build: buildCommand,
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,YAAY,EAA0B,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAsB,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;A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ENV };
@@ -0,0 +1,211 @@
1
+ /**
2
+ * `bitmagic event` — the sponsored-event lane.
3
+ *
4
+ * bitmagic event setup --key sk-… store the key, prove it works, report the budget
5
+ * bitmagic event claude [args…] launch Claude Code against the event proxy
6
+ * bitmagic event codex [args…] launch Codex against the event proxy
7
+ * bitmagic event status spend and remaining budget
8
+ * bitmagic event env the exports, for wiring it up by hand
9
+ * bitmagic event clear forget the key
10
+ *
11
+ * This exists because the manual setup — six exports in the right terminal, plus a hand-edited
12
+ * ~/.codex/config.toml — is the biggest source of "it doesn't work" across a room of fifty
13
+ * people, and its failures are quiet: exports run in a different tab than the agent, or only the
14
+ * first two of six lines copied.
15
+ *
16
+ * Neither launcher touches configuration the participant owns. Claude Code is configured purely
17
+ * through the environment (event/launch.ts); Codex gets an isolated CODEX_HOME we generate and
18
+ * own (event/codex-home.ts), because its built-in apps otherwise contribute tool names longer
19
+ * than Bedrock accepts. Both are removed by `bitmagic event clear`, so nothing of ours outlives
20
+ * the event — which matters, because the keys stop working when the proxy is torn down.
21
+ *
22
+ * Event-scoped on purpose: the endpoint is the event proxy, and this command is expected to be
23
+ * deleted along with it. No general model-provider concept enters the shipped CLI.
24
+ */
25
+ import { defineCommand } from 'citty';
26
+ import { spawn } from 'node:child_process';
27
+ import { CliError, errnoCode } from '../errors.js';
28
+ import { createOutput } from '../output.js';
29
+ import { fetchBudget, usd } from '../event/budget.js';
30
+ import { CODEX_KEY_ENV, exportLines, launchSpec } from '../event/launch.js';
31
+ import { codexHomePath, ensureCodexHome, removeCodexHome } from '../event/codex-home.js';
32
+ import { preflight } from '../event/preflight.js';
33
+ import { clearEventKey, eventKeyPath, readEventKey, writeEventKey } from '../event/store.js';
34
+ /** The event proxy. Hard-coded because this command is scoped to one event. */
35
+ const EVENT_PROXY_URL = 'https://event-proxy.bitmagic.ai';
36
+ const JSON_ARG = {
37
+ json: { type: 'boolean', description: 'Print the result as JSON on stdout; all progress goes to stderr.' },
38
+ };
39
+ const INSTALL_HINT = {
40
+ claude: 'npm install -g @anthropic-ai/claude-code',
41
+ codex: 'npm install -g @openai/codex',
42
+ };
43
+ function requireKey() {
44
+ const stored = readEventKey();
45
+ if (stored === null) {
46
+ throw new CliError('No event key stored yet.\nRun: bitmagic event setup --key sk-… (the key is on your card)', 1, 'event_key_missing');
47
+ }
48
+ return { key: stored.key, baseUrl: stored.baseUrl };
49
+ }
50
+ /** Spend line shared by `setup` and `status`, so both phrase the budget the same way. */
51
+ function budgetLine(spend, maxBudget) {
52
+ if (maxBudget === undefined)
53
+ return `Spent ${usd(spend)}.`;
54
+ const remaining = Math.max(0, maxBudget - spend);
55
+ return `Spent ${usd(spend)} of ${usd(maxBudget)} — ${usd(remaining)} left.`;
56
+ }
57
+ const setupCommand = defineCommand({
58
+ meta: { name: 'setup', description: 'Store your event API key and check it works.' },
59
+ args: {
60
+ ...JSON_ARG,
61
+ key: { type: 'string', description: 'The sk-… key from your event card.', required: true },
62
+ },
63
+ async run({ args }) {
64
+ const output = createOutput(args.json === true);
65
+ const key = String(args.key).trim();
66
+ if (!key.startsWith('sk-')) {
67
+ throw new CliError('That does not look like an event key — it should start with "sk-".', 1, 'event_key_malformed');
68
+ }
69
+ output.info('Checking the key against the event proxy…');
70
+ const check = await preflight(key, EVENT_PROXY_URL);
71
+ writeEventKey({ baseUrl: EVENT_PROXY_URL, key, savedAt: Date.now() });
72
+ const budget = await fetchBudget(key, EVENT_PROXY_URL);
73
+ output.info(`Key stored in ${eventKeyPath()} (readable only by you).`);
74
+ output.info(budgetLine(budget.spend, budget.maxBudget));
75
+ output.info('');
76
+ output.info('Start your agent with:');
77
+ output.info(' bitmagic event claude (or: bitmagic event codex)');
78
+ output.info('');
79
+ output.info('Both run against the event proxy. Codex uses a separate Codex profile for the');
80
+ output.info('event, so your own ~/.codex settings are untouched and still apply elsewhere.');
81
+ output.result({
82
+ ok: true,
83
+ servedModel: check.servedModel,
84
+ spend: budget.spend,
85
+ maxBudget: budget.maxBudget,
86
+ keyPath: eventKeyPath(),
87
+ });
88
+ },
89
+ });
90
+ const statusCommand = defineCommand({
91
+ meta: { name: 'status', description: 'Show how much of your event budget is left.' },
92
+ args: JSON_ARG,
93
+ async run({ args }) {
94
+ const output = createOutput(args.json === true);
95
+ const { key, baseUrl } = requireKey();
96
+ const budget = await fetchBudget(key, baseUrl);
97
+ output.info(budgetLine(budget.spend, budget.maxBudget));
98
+ if (budget.expires !== undefined)
99
+ output.info(`Key expires: ${budget.expires}`);
100
+ output.result({
101
+ spend: budget.spend,
102
+ maxBudget: budget.maxBudget,
103
+ remaining: budget.maxBudget === undefined ? undefined : Math.max(0, budget.maxBudget - budget.spend),
104
+ expires: budget.expires,
105
+ alias: budget.alias,
106
+ });
107
+ },
108
+ });
109
+ const envCommand = defineCommand({
110
+ meta: { name: 'env', description: 'Print the environment variables, for setting up an agent by hand.' },
111
+ args: JSON_ARG,
112
+ run({ args }) {
113
+ const output = createOutput(args.json === true);
114
+ const { key, baseUrl } = requireKey();
115
+ const lines = exportLines(key, baseUrl);
116
+ // Deliberately stdout even in human mode: this output is meant to be piped or eval'd.
117
+ for (const line of lines)
118
+ console.log(line);
119
+ output.result({ exports: lines });
120
+ },
121
+ });
122
+ const clearCommand = defineCommand({
123
+ meta: { name: 'clear', description: 'Forget the stored event key.' },
124
+ args: JSON_ARG,
125
+ run({ args }) {
126
+ const output = createOutput(args.json === true);
127
+ const removed = clearEventKey();
128
+ const codexRemoved = removeCodexHome();
129
+ output.info(removed ? `Removed ${eventKeyPath()}.` : 'No event key was stored.');
130
+ if (codexRemoved)
131
+ output.info(`Removed ${codexHomePath()}.`);
132
+ output.result({ removed, codexHomeRemoved: codexRemoved });
133
+ },
134
+ });
135
+ /**
136
+ * Spawns the agent with the event environment and exits with its code.
137
+ *
138
+ * stdio is inherited so the agent owns the terminal exactly as if it had been started directly —
139
+ * the point of this command is that everything after it feels normal.
140
+ */
141
+ async function runAgent(agent, passthrough, skipCheck) {
142
+ const { key, baseUrl } = requireKey();
143
+ if (!skipCheck) {
144
+ // Before handing the terminal over: a broken key or a degraded proxy is far cheaper to learn
145
+ // about here than as a wall of agent errors thirty seconds in.
146
+ await preflight(key, baseUrl);
147
+ }
148
+ // Codex runs against a Codex home we own, rewritten here so it can never be stale. Claude
149
+ // Code needs no equivalent: its whole configuration is the environment.
150
+ const codexHome = agent === 'codex' ? ensureCodexHome(baseUrl) : codexHomePath();
151
+ const spec = launchSpec(agent, key, baseUrl, codexHome, passthrough);
152
+ return new Promise((_resolve, reject) => {
153
+ const child = spawn(spec.bin, spec.argv, { stdio: 'inherit', env: spec.env });
154
+ child.on('error', (error) => {
155
+ if (errnoCode(error) === 'ENOENT') {
156
+ reject(new CliError(`${spec.bin} is not installed, or not on your PATH.\nInstall it with: ${INSTALL_HINT[agent]}`, 1, 'event_agent_missing'));
157
+ return;
158
+ }
159
+ reject(new CliError(`Could not start ${spec.bin}: ${error instanceof Error ? error.message : String(error)}`));
160
+ });
161
+ // The agent's exit code is the command's exit code; a signal is reported as the conventional
162
+ // 128+n so a Ctrl-C inside the agent does not look like a clean exit.
163
+ child.on('close', (code, signal) => {
164
+ process.exit(signal !== null ? 128 : (code ?? 0));
165
+ });
166
+ });
167
+ }
168
+ const AGENT_ARGS = {
169
+ 'skip-check': {
170
+ type: 'boolean',
171
+ description: 'Skip the proxy check before starting (use only if the check is being a nuisance).',
172
+ },
173
+ _: { type: 'positional', required: false, description: 'Arguments passed through to the agent.' },
174
+ };
175
+ const claudeCommand = defineCommand({
176
+ meta: { name: 'claude', description: 'Start Claude Code using your event key.' },
177
+ args: AGENT_ARGS,
178
+ async run({ args, rawArgs }) {
179
+ await runAgent('claude', passthroughArgs(rawArgs), args['skip-check'] === true);
180
+ },
181
+ });
182
+ const codexCommand = defineCommand({
183
+ meta: { name: 'codex', description: 'Start Codex using your event key.' },
184
+ args: AGENT_ARGS,
185
+ async run({ args, rawArgs }) {
186
+ await runAgent('codex', passthroughArgs(rawArgs), args['skip-check'] === true);
187
+ },
188
+ });
189
+ /**
190
+ * Everything the participant typed after the subcommand, minus our own flags, handed to the
191
+ * agent untouched — so `bitmagic event claude --resume` behaves like `claude --resume`.
192
+ */
193
+ function passthroughArgs(rawArgs) {
194
+ return rawArgs.filter((arg) => arg !== '--skip-check');
195
+ }
196
+ export const eventCommand = defineCommand({
197
+ meta: {
198
+ name: 'event',
199
+ description: 'Sponsored-event lane: store your event key and start your agent with it.',
200
+ },
201
+ subCommands: {
202
+ setup: setupCommand,
203
+ claude: claudeCommand,
204
+ codex: codexCommand,
205
+ status: statusCommand,
206
+ env: envCommand,
207
+ clear: clearCommand,
208
+ },
209
+ });
210
+ export { CODEX_KEY_ENV };
211
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/commands/event.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE7F,+EAA+E;AAC/E,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAE1D,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE,EAAE,IAAI,EAAE,S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AAE,OAAO;QACb,WAAW,EAAE,0EAA0E;KACxF;IACD,WAAW,EAAE;QACX,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,aAAa;QACrB,GAAG,EAAE,UAAU;QACf,KAAK,EAAE,YAAY;KACpB;CACF,CAAC,CAAC;AAEH,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface EventBudget {
2
+ alias: string | undefined;
3
+ spend: number;
4
+ maxBudget: number | undefined;
5
+ /** ISO timestamp at which the key stops working, when the key carries one. */
6
+ expires: string | undefined;
7
+ }
8
+ export declare function fetchBudget(key: string, baseUrl: string): Promise<EventBudget>;
9
+ /** `$12.34` — the one place the CLI formats event dollars, so every surface agrees. */
10
+ export declare function usd(value: number): string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * What a participant's own key can tell them about their budget.
3
+ *
4
+ * A LiteLLM key may read its own `/key/info` — verified against the live event proxy — so the
5
+ * CLI can show spend and remaining budget without the master key ever leaving the organisers'
6
+ * hands. That matters: the master key mints keys, and nothing that ships to a laptop may hold it.
7
+ */
8
+ import { CliError } from '../errors.js';
9
+ import { anthropicBaseUrl } from './launch.js';
10
+ function isRecord(value) {
11
+ return typeof value === 'object' && value !== null;
12
+ }
13
+ function optionalNumber(value) {
14
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
15
+ }
16
+ function optionalString(value) {
17
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
18
+ }
19
+ export async function fetchBudget(key, baseUrl) {
20
+ let response;
21
+ try {
22
+ response = await fetch(`${anthropicBaseUrl(baseUrl)}/key/info`, {
23
+ headers: { Authorization: `Bearer ${key}` },
24
+ signal: AbortSignal.timeout(15_000),
25
+ });
26
+ }
27
+ catch (error) {
28
+ throw new CliError(`Cannot reach the event proxy: ${error instanceof Error ? error.message : String(error)}`, 1, 'event_proxy_unreachable');
29
+ }
30
+ if (!response.ok) {
31
+ throw new CliError(`The event proxy returned HTTP ${response.status} for /key/info.`, 1, 'event_proxy_error');
32
+ }
33
+ const body = await response.json();
34
+ // The payload is either the info object itself or wrapped in `info`, depending on version.
35
+ const info = isRecord(body) && isRecord(body.info) ? body.info : isRecord(body) ? body : {};
36
+ return {
37
+ alias: optionalString(info.key_alias),
38
+ spend: optionalNumber(info.spend) ?? 0,
39
+ maxBudget: optionalNumber(info.max_budget),
40
+ expires: optionalString(info.expires),
41
+ };
42
+ }
43
+ /** `$12.34` — the one place the CLI formats event dollars, so every surface agrees. */
44
+ export function usd(value) {
45
+ return `$${value.toFixed(2)}`;
46
+ }
47
+ //# sourceMappingURL=budget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget.js","sourceRoot":"","sources":["../../src/event/budget.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU/C,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW,EAAE,OAAe;IAC5D,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,gBAAg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,CAAC,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export declare function codexHomePath(baseDir?: string): string;
2
+ /** The whole config, generated from the endpoint. No merge, no parse — we own every line. */
3
+ export declare function renderCodexConfig(baseUrl: string): string;
4
+ /**
5
+ * Writes the config and returns the directory to use as CODEX_HOME.
6
+ *
7
+ * Rewritten every launch rather than only when missing: the endpoint could change between event
8
+ * days, and a stale file would point at a proxy that no longer answers while looking fine.
9
+ */
10
+ export declare function ensureCodexHome(baseUrl: string, baseDir?: string): string;
11
+ /** Removed by `bitmagic event clear`, so nothing of ours outlives the event. */
12
+ export declare function removeCodexHome(baseDir?: string): boolean;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * A Codex home of our own, for the duration of the event.
3
+ *
4
+ * Codex is not configured with `-c` overrides here, the way cli/lab/drivers/codex.ts does it,
5
+ * because overrides layer ON TOP of the participant's `~/.codex/config.toml` and cannot remove
6
+ * what is already there. Two things in a real installation then break the event lane:
7
+ *
8
+ * - Codex's built-in apps contribute tool names like
9
+ * `mcp__codex_apps__codex_document_control___execute_document_command`, and **Bedrock
10
+ * rejects any tool name over 64 characters**. Every request 400s with a validation error
11
+ * naming four tools. Observed on a stock install; `-c mcp_servers={}` does not clear them,
12
+ * because apps are a separate subsystem from `mcp_servers`.
13
+ * - Any MCP server the participant has configured is dragged into the event's budget, and may
14
+ * hit the same limit.
15
+ *
16
+ * Pointing `CODEX_HOME` at a directory we own makes the lane deterministic: the same clean
17
+ * environment on every laptop, whatever the participant has installed. This is the isolation the
18
+ * original Codex spike used, which is why the spike never saw the tool-name failure.
19
+ *
20
+ * Note this DOES write a TOML file — but one we generate whole and own outright, in our own
21
+ * directory. That is a different act from merging into the participant's `~/.codex/config.toml`,
22
+ * which would need a TOML parser the repo does not have and would outlive the event.
23
+ *
24
+ * The participant's own Codex settings, MCP servers and login do not apply inside the event lane.
25
+ * For a sponsored event that is the intent, not a limitation.
26
+ */
27
+ import * as fs from 'fs';
28
+ import * as path from 'path';
29
+ import { CliError } from '../errors.js';
30
+ import { CODEX_KEY_ENV, openAiBaseUrl } from './launch.js';
31
+ import { defaultBaseDir } from './store.js';
32
+ const DIR_MODE = 0o700;
33
+ export function codexHomePath(baseDir = defaultBaseDir()) {
34
+ return path.join(baseDir, 'codex-event');
35
+ }
36
+ /** The whole config, generated from the endpoint. No merge, no parse — we own every line. */
37
+ export function renderCodexConfig(baseUrl) {
38
+ return `# Generated by \`bitmagic event\`. Rewritten on every launch — edits here are lost.
39
+ # This is a Codex home owned by Bitmagic for the duration of the event; your own
40
+ # ~/.codex/config.toml is untouched and still applies when you run codex directly.
41
+ model = "claude-5-opus"
42
+ model_provider = "bitmagic"
43
+
44
+ [model_providers.bitmagic]
45
+ name = "bitmagic event proxy"
46
+ base_url = "${openAiBaseUrl(baseUrl)}"
47
+ env_key = "${CODEX_KEY_ENV}"
48
+ wire_api = "responses"
49
+ request_max_retries = 2
50
+ `;
51
+ }
52
+ /**
53
+ * Writes the config and returns the directory to use as CODEX_HOME.
54
+ *
55
+ * Rewritten every launch rather than only when missing: the endpoint could change between event
56
+ * days, and a stale file would point at a proxy that no longer answers while looking fine.
57
+ */
58
+ export function ensureCodexHome(baseUrl, baseDir = defaultBaseDir()) {
59
+ const home = codexHomePath(baseDir);
60
+ try {
61
+ fs.mkdirSync(home, { recursive: true, mode: DIR_MODE });
62
+ fs.writeFileSync(path.join(home, 'config.toml'), renderCodexConfig(baseUrl), 'utf-8');
63
+ }
64
+ catch (error) {
65
+ throw new CliError(`Could not prepare the Codex configuration at ${home}: ${error instanceof Error ? error.message : String(error)}`, 1, 'event_codex_home_failed');
66
+ }
67
+ return home;
68
+ }
69
+ /** Removed by `bitmagic event clear`, so nothing of ours outlives the event. */
70
+ export function removeCodexHome(baseDir = defaultBaseDir()) {
71
+ const home = codexHomePath(baseDir);
72
+ if (!fs.existsSync(home))
73
+ return false;
74
+ fs.rmSync(home, { recursive: true, force: true });
75
+ return true;
76
+ }
77
+ //# sourceMapp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C,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACjH,CAAC,EACD,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,UAAkB,cAAc,EAAE;IAChE,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * How each agent is pointed at the event proxy.
3
+ *
4
+ * Nothing here writes a config file. The participant's agent is spawned with the environment
5
+ * already set, which is the only approach that works for both agents and leaves nothing behind
6
+ * when the proxy is torn down and the keys stop working:
7
+ *
8
+ * - The CLI has never written to ~/.claude/ or ~/.codex/, and editing a participant's global
9
+ * Codex config is not something a game SDK should do.
10
+ * - A `.claude/settings.json` env block only takes effect once the directory is trusted, which
11
+ * a freshly scaffolded project is not (cli/lab/drivers/claude-code.ts documents the same
12
+ * trap and sidesteps it the same way).
13
+ * - Codex config is TOML, and this repo has no TOML writer, dependency or merge precedent.
14
+ *
15
+ * The shape of "spawn an agent with a modified environment" is taken from cli/lab/drivers/ —
16
+ * `baseEnv()` in types.ts and the `-c key=value` overrides in codex.ts. That code is the lab
17
+ * harness and is never built into dist/, so this is a copied pattern rather than an import.
18
+ */
19
+ /** The env var Codex is told to read the key from, via `env_key`. */
20
+ export declare const CODEX_KEY_ENV = "BITMAGIC_EVENT_KEY";
21
+ export type EventAgent = 'claude' | 'codex';
22
+ export interface LaunchSpec {
23
+ bin: string;
24
+ argv: string[];
25
+ env: Record<string, string | undefined>;
26
+ }
27
+ /**
28
+ * The two clients want DIFFERENT forms of the same URL, and swapping them produces a 404 that
29
+ * reads like the proxy is down:
30
+ *
31
+ * Claude Code the bare host — it appends /v1/messages itself
32
+ * Codex host + /v1 — an OpenAI-compatible base, no trailing slash
33
+ *
34
+ * docs/ci-ai-credentials.md warns about exactly this (and about reusing getLiteLLMProxyUrl(),
35
+ * which already ends in /v1). Both forms are derived here so no caller has to remember which.
36
+ */
37
+ export declare function anthropicBaseUrl(baseUrl: string): string;
38
+ export declare function openAiBaseUrl(baseUrl: string): string;
39
+ /**
40
+ * Claude Code's environment: the block docs/ci-ai-credentials.md records and every Claude Code
41
+ * workflow proves daily.
42
+ *
43
+ * All three model pins are required, not just Opus. Claude Code makes background calls of its
44
+ * own with Anthropic-native model ids, and the proxy serves only its own aliases — so naming
45
+ * only the Opus default leaves those background calls 400ing. There is no Sonnet on the proxy,
46
+ * which is why Sonnet is pinned to Opus rather than to a Sonnet alias.
47
+ */
48
+ export declare function claudeEnv(key: string, baseUrl: string, parentEnv?: Record<string, string | undefined>): Record<string, string | undefined>;
49
+ /**
50
+ * Codex is configured through an isolated CODEX_HOME rather than `-c` overrides — see
51
+ * event/codex-home.ts for why overrides cannot work against a real installation.
52
+ */
53
+ export declare function codexEnv(key: string, codexHome: string, parentEnv?: Record<string, string | undefined>): Record<string, string | undefined>;
54
+ /**
55
+ * Everything needed to spawn one agent. Pure — the caller does the spawning, and for Codex the
56
+ * caller has already materialised `codexHome` (ensureCodexHome).
57
+ */
58
+ export declare function launchSpec(agent: EventAgent, key: string, baseUrl: string, codexHome: string, passthrough?: string[], parentEnv?: Record<string, string | undefined>): LaunchSpec;
59
+ /** The exports `bitmagic event env` prints, for anyone wiring it up by hand. */
60
+ export declare function exportLines(key: string, baseUrl: string): string[];
@@ -0,0 +1,122 @@
1
+ /**
2
+ * How each agent is pointed at the event proxy.
3
+ *
4
+ * Nothing here writes a config file. The participant's agent is spawned with the environment
5
+ * already set, which is the only approach that works for both agents and leaves nothing behind
6
+ * when the proxy is torn down and the keys stop working:
7
+ *
8
+ * - The CLI has never written to ~/.claude/ or ~/.codex/, and editing a participant's global
9
+ * Codex config is not something a game SDK should do.
10
+ * - A `.claude/settings.json` env block only takes effect once the directory is trusted, which
11
+ * a freshly scaffolded project is not (cli/lab/drivers/claude-code.ts documents the same
12
+ * trap and sidesteps it the same way).
13
+ * - Codex config is TOML, and this repo has no TOML writer, dependency or merge precedent.
14
+ *
15
+ * The shape of "spawn an agent with a modified environment" is taken from cli/lab/drivers/ —
16
+ * `baseEnv()` in types.ts and the `-c key=value` overrides in codex.ts. That code is the lab
17
+ * harness and is never built into dist/, so this is a copied pattern rather than an import.
18
+ */
19
+ /** Model aliases the event proxy serves. Anything else is a 400 — it knows only its own names. */
20
+ const OPUS_ALIAS = 'claude-5-opus';
21
+ const HAIKU_ALIAS = 'claude-4.5-haiku';
22
+ /** The env var Codex is told to read the key from, via `env_key`. */
23
+ export const CODEX_KEY_ENV = 'BITMAGIC_EVENT_KEY';
24
+ /** Session-scoped variables a spawning Claude Code exports, which must not reach a fresh agent. */
25
+ const CLAUDE_SESSION_MARKERS = [
26
+ 'CLAUDECODE',
27
+ 'CLAUDE_CODE_ENTRYPOINT',
28
+ 'CLAUDE_CODE_SESSION_ID',
29
+ 'CLAUDE_CODE_CHILD_SESSION',
30
+ 'CLAUDE_CODE_SESSION_ATTENDED',
31
+ 'CLAUDE_CODE_MESSAGING_SOCKET',
32
+ 'CLAUDE_CODE_MESSAGING_TOKEN',
33
+ 'CLAUDE_CODE_EXECPATH',
34
+ 'CLAUDE_PID',
35
+ ];
36
+ /**
37
+ * The two clients want DIFFERENT forms of the same URL, and swapping them produces a 404 that
38
+ * reads like the proxy is down:
39
+ *
40
+ * Claude Code the bare host — it appends /v1/messages itself
41
+ * Codex host + /v1 — an OpenAI-compatible base, no trailing slash
42
+ *
43
+ * docs/ci-ai-credentials.md warns about exactly this (and about reusing getLiteLLMProxyUrl(),
44
+ * which already ends in /v1). Both forms are derived here so no caller has to remember which.
45
+ */
46
+ export function anthropicBaseUrl(baseUrl) {
47
+ return baseUrl.replace(/\/+$/, '').replace(/\/v1$/, '');
48
+ }
49
+ export function openAiBaseUrl(baseUrl) {
50
+ return `${anthropicBaseUrl(baseUrl)}/v1`;
51
+ }
52
+ /**
53
+ * Claude Code's environment: the block docs/ci-ai-credentials.md records and every Claude Code
54
+ * workflow proves daily.
55
+ *
56
+ * All three model pins are required, not just Opus. Claude Code makes background calls of its
57
+ * own with Anthropic-native model ids, and the proxy serves only its own aliases — so naming
58
+ * only the Opus default leaves those background calls 400ing. There is no Sonnet on the proxy,
59
+ * which is why Sonnet is pinned to Opus rather than to a Sonnet alias.
60
+ */
61
+ export function claudeEnv(key, baseUrl, parentEnv = process.env) {
62
+ const env = { ...parentEnv };
63
+ // Setting ANTHROPIC_API_KEY alongside ANTHROPIC_AUTH_TOKEN is explicitly forbidden, and a
64
+ // participant who already uses Claude Code on their own key will have one exported. Removing
65
+ // it is the main thing this launcher can do that a copied export block cannot.
66
+ delete env.ANTHROPIC_API_KEY;
67
+ // ANTHROPIC_MODEL, if the participant has pinned one for their own use, wins over the
68
+ // DEFAULT_* vars below and names a model the proxy does not serve — a 400 on every call.
69
+ delete env.ANTHROPIC_MODEL;
70
+ // Session markers from a Claude Code that spawned us — participants really do ask their agent
71
+ // to run the setup for them. cli/lab/drivers/types.ts drops the first two so a nested agent
72
+ // does not think it is inside another session; the rest are handles (sockets, tokens, pids)
73
+ // that name a process this one is not. CLAUDE_CONFIG_DIR is deliberately left alone: that one
74
+ // is a standing preference rather than session state.
75
+ //
76
+ // Note this is NOT what causes Claude Code's `unrecognized_model: claude-5-opus[1m]` line —
77
+ // that appears with a clean environment and no launcher at all, because Claude Code's own
78
+ // model registry does not know the proxy's aliases. It is cosmetic; the call succeeds.
79
+ for (const marker of CLAUDE_SESSION_MARKERS)
80
+ delete env[marker];
81
+ env.ANTHROPIC_BASE_URL = anthropicBaseUrl(baseUrl);
82
+ env.ANTHROPIC_AUTH_TOKEN = key;
83
+ env.ANTHROPIC_DEFAULT_OPUS_MODEL = OPUS_ALIAS;
84
+ env.ANTHROPIC_DEFAULT_SONNET_MODEL = OPUS_ALIAS;
85
+ env.ANTHROPIC_DEFAULT_HAIKU_MODEL = HAIKU_ALIAS;
86
+ env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = '1';
87
+ return env;
88
+ }
89
+ /**
90
+ * Codex is configured through an isolated CODEX_HOME rather than `-c` overrides — see
91
+ * event/codex-home.ts for why overrides cannot work against a real installation.
92
+ */
93
+ export function codexEnv(key, codexHome, parentEnv = process.env) {
94
+ const env = { ...parentEnv };
95
+ env[CODEX_KEY_ENV] = key;
96
+ env.CODEX_HOME = codexHome;
97
+ return env;
98
+ }
99
+ /**
100
+ * Everything needed to spawn one agent. Pure — the caller does the spawning, and for Codex the
101
+ * caller has already materialised `codexHome` (ensureCodexHome).
102
+ */
103
+ export function launchSpec(agent, key, baseUrl, codexHome, passthrough = [], parentEnv = process.env) {
104
+ if (agent === 'claude') {
105
+ return { bin: 'claude', argv: [...passthrough], env: claudeEnv(key, baseUrl, parentEnv) };
106
+ }
107
+ // No argv configuration at all: the generated config.toml in CODEX_HOME carries the provider.
108
+ return { bin: 'codex', argv: [...passthrough], env: codexEnv(key, codexHome, parentEnv) };
109
+ }
110
+ /** The exports `bitmagic event env` prints, for anyone wiring it up by hand. */
111
+ export function exportLines(key, baseUrl) {
112
+ return [
113
+ `export ANTHROPIC_BASE_URL=${anthropicBaseUrl(baseUrl)}`,
114
+ `export ANTHROPIC_AUTH_TOKEN=${key}`,
115
+ `export ANTHROPIC_DEFAULT_OPUS_MODEL=${OPUS_ALIAS}`,
116
+ `export ANTHROPIC_DEFAULT_SONNET_MODEL=${OPUS_ALIAS}`,
117
+ `export ANTHROPIC_DEFAULT_HAIKU_MODEL=${HAIKU_ALIAS}`,
118
+ `export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`,
119
+ `export ${CODEX_KEY_ENV}=${key}`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,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAAe;IACtD,OAAO;QACL,6BAA6B,gBAAgB,CAAC,OAAO,CAAC,EAAE;QACxD,+BAA+B,GAAG,EAAE;QACpC,uCAAuC,UAAU,EAAE;QACnD,yCAAyC,UAAU,EAAE;QACrD,wCAAwC,WAAW,EAAE;QACrD,iDAAiD;QACjD,UAAU,aAAa,IAAI,GAAG,EAAE;KACjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface PreflightResult {
2
+ /** What the proxy actually served, from `x-litellm-model-name`. */
3
+ servedModel: string;
4
+ /** Cost of this call in USD, from `x-litellm-response-cost`. Present once pricing resolves. */
5
+ cost: number | undefined;
6
+ /** Cumulative spend on this key in USD, from `x-litellm-key-spend`. */
7
+ keySpend: number | undefined;
8
+ }
9
+ export declare function preflight(key: string, baseUrl: string): Promise<PreflightResult>;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * One tiny call against the event proxy, before the participant starts working.
3
+ *
4
+ * This is the same assertion every Claude Code workflow makes before it runs
5
+ * (.github/workflows/code-simplifier.yml, the "Verify Bedrock gateway" step): a 200 is not
6
+ * enough, because the proxy can serve a different model behind a perfectly healthy response.
7
+ * The only tell is the `x-litellm-model-name` header.
8
+ *
9
+ * The point is timing. Every failure here — dead proxy, mistyped key, exhausted budget, silent
10
+ * downgrade — otherwise shows up ten minutes into a session as something that reads like the
11
+ * agent being broken. Catching it at `setup` and at each launch costs one token and turns it
12
+ * into a sentence the participant can act on.
13
+ */
14
+ import { CliError } from '../errors.js';
15
+ import { anthropicBaseUrl } from './launch.js';
16
+ const PREFLIGHT_TIMEOUT_MS = 15_000;
17
+ function numberHeader(headers, name) {
18
+ const raw = headers.get(name);
19
+ if (raw === null)
20
+ return undefined;
21
+ const value = Number(raw);
22
+ return Number.isFinite(value) ? value : undefined;
23
+ }
24
+ /**
25
+ * Maps the proxy's refusals onto advice. Anything unmapped keeps its status and body so a new
26
+ * failure mode is never silently rephrased as one of these.
27
+ */
28
+ function refusal(status, body) {
29
+ if (status === 401 || status === 403) {
30
+ return new CliError('The event proxy rejected this key.\n' +
31
+ 'Check it matches the card exactly — it starts with "sk-" and has no spaces.\n' +
32
+ 'Re-run: bitmagic event setup --key sk-…', 1, 'event_key_rejected');
33
+ }
34
+ if (status === 429 && body.includes('budget')) {
35
+ return new CliError('This key has reached its spending limit.\n' +
36
+ 'Your work is safe. Find one of the organisers — raising it takes a minute.', 1, 'event_budget_exceeded');
37
+ }
38
+ if (status === 429) {
39
+ return new CliError('The event proxy is rate-limiting this key. Wait a moment and try again.', 1, 'event_rate_limited');
40
+ }
41
+ return new CliError(`The event proxy returned HTTP ${status}.\n${body.slice(0, 300)}`, 1, 'event_proxy_error');
42
+ }
43
+ export async function preflight(key, baseUrl) {
44
+ const url = `${anthropicBaseUrl(baseUrl)}/v1/messages`;
45
+ let response;
46
+ try {
47
+ response = await fetch(url, {
48
+ method: 'POST',
49
+ headers: {
50
+ Authorization: `Bearer ${key}`,
51
+ 'anthropic-version': '2023-06-01',
52
+ 'content-type': 'application/json',
53
+ },
54
+ // One token: enough to prove the whole path works, cheap enough to run on every launch.
55
+ body: JSON.stringify({ model: 'claude-5-opus', max_tokens: 1, messages: [{ role: 'user', content: 'hi' }] }),
56
+ signal: AbortSignal.timeout(PREFLIGHT_TIMEOUT_MS),
57
+ });
58
+ }
59
+ catch (error) {
60
+ throw new CliError(`Cannot reach the event proxy at ${anthropicBaseUrl(baseUrl)}.\n` +
61
+ 'Check your network connection. If you are on event wifi, ask an organiser.\n' +
62
+ `(${error instanceof Error ? error.message : String(error)})`, 1, 'event_proxy_unreachable');
63
+ }
64
+ if (!response.ok) {
65
+ throw refusal(response.status, await response.text().catch(() => ''));
66
+ }
67
+ const servedModel = response.headers.get('x-litellm-model-name') ?? '';
68
+ if (!servedModel.includes('opus')) {
69
+ // A 200 that did not come from Opus means a fallback served it. Refusing here rather than
70
+ // warning is deliberate: the participant would otherwise spend their budget on a weaker
71
+ // model without ever being told, and the spend accounting would be wrong too.
72
+ throw new CliError(`The event proxy answered with "${servedModel || 'an unknown model'}" instead of Opus.\n` +
73
+ 'That usually means the proxy is degraded. Tell an organiser before continuing.', 1, 'event_model_downgrade');
74
+ }
75
+ return {
76
+ servedModel,
77
+ cost: numberHeader(response.headers, 'x-litellm-response-cost'),
78
+ keySpend: numberHeader(response.headers, 'x-litellm-key-spend'),
79
+ };
80
+ }
81
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/event/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAW/C,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAEpC,SAAS,YAAY,CAAC,OAAgB,EAAE,IAAY;IAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,OAAO,CAAC,MAAc,EAAE,IAAY;IAC3C,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACrC,OAAO,IAAI,QAAQ,CACjB,sCAAsC;YACpC,+EAA+E;YAC/E,yCAAyC,EAC3C,CAAC,EACD,oBAAoB,CACrB,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,OAAO,IAAI,QAAQ,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KAAK,CAAC,GAAG,EAC/D,CAAC,EACD,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;IACvE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,0FAA0F;QAC1F,wFAAwF;QACxF,8EAA8E;QAC9E,MAAM,IAAI,QAAQ,CAChB,kCAAkC,WAAW,IAAI,kBAAkB,sBAAsB;YACvF,gFAAgF,EAClF,CAAC,EACD,uBAAuB,CACxB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,WAAW;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC;QAC/D,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;KAChE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface EventKey {
2
+ /** Host root of the event proxy, no trailing slash and no `/v1`. See launch.ts. */
3
+ baseUrl: string;
4
+ key: string;
5
+ /** Epoch ms, for `bitmagic event status` to report when the key was stored. */
6
+ savedAt: number;
7
+ }
8
+ export declare function defaultBaseDir(): string;
9
+ export declare function eventKeyPath(baseDir?: string): string;
10
+ export declare function readEventKey(baseDir?: string): EventKey | null;
11
+ export declare function writeEventKey(entry: EventKey, baseDir?: string): void;
12
+ /** Returns false when there was nothing to forget, so `clear` can say so rather than imply it acted. */
13
+ export declare function clearEventKey(baseDir?: string): boolean;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Where the sponsored-event API key lives on a participant's machine.
3
+ *
4
+ * Deliberately a SEPARATE file from credentials.json rather than another field in it. This is
5
+ * disposable state that stops working when the event proxy is torn down, and a participant
6
+ * deleting it afterwards — or us telling them to — must carry no risk to their login.
7
+ *
8
+ * File discipline is copied from config/credentials.ts: 0600 inside a 0700 directory, written
9
+ * through a temp file and renamed, chmod'd before and after because writeFileSync's `mode` only
10
+ * applies when it creates the file. A corrupt file is treated as absent, not as an error: the fix
11
+ * is always `bitmagic event setup` again, and a parse failure must not wedge the command that
12
+ * would repair it.
13
+ */
14
+ import * as fs from 'fs';
15
+ import * as os from 'os';
16
+ import * as path from 'path';
17
+ import { CliError } from '../errors.js';
18
+ const DIR_MODE = 0o700;
19
+ const FILE_MODE = 0o600;
20
+ export function defaultBaseDir() {
21
+ return path.join(os.homedir(), '.bitmagic');
22
+ }
23
+ export function eventKeyPath(baseDir = defaultBaseDir()) {
24
+ return path.join(baseDir, 'event.json');
25
+ }
26
+ function isEventKey(value) {
27
+ if (typeof value !== 'object' || value === null)
28
+ return false;
29
+ const v = value;
30
+ return (typeof v.baseUrl === 'string' &&
31
+ v.baseUrl.length > 0 &&
32
+ typeof v.key === 'string' &&
33
+ v.key.length > 0 &&
34
+ typeof v.savedAt === 'number' &&
35
+ Number.isFinite(v.savedAt));
36
+ }
37
+ export function readEventKey(baseDir = defaultBaseDir()) {
38
+ const filePath = eventKeyPath(baseDir);
39
+ let raw;
40
+ try {
41
+ raw = fs.readFileSync(filePath, 'utf-8');
42
+ }
43
+ catch (err) {
44
+ const code = err.code;
45
+ if (code === 'ENOENT' || code === 'ENOTDIR')
46
+ return null;
47
+ // A real filesystem problem must not be reported as "no key" — that sends the participant
48
+ // through setup again, which cannot fix a permissions error.
49
+ throw new CliError(`Cannot read ${filePath}: ${code ?? String(err)}`);
50
+ }
51
+ try {
52
+ const parsed = JSON.parse(raw);
53
+ return isEventKey(parsed) ? parsed : null;
54
+ }
55
+ catch {
56
+ return null;
57
+ }
58
+ }
59
+ export function writeEventKey(entry, baseDir = defaultBaseDir()) {
60
+ fs.mkdirSync(baseDir, { recursive: true, mode: DIR_MODE });
61
+ const filePath = eventKeyPath(baseDir);
62
+ const tmpPath = path.join(baseDir, `.event.json.${process.pid}.${Date.now()}.tmp`);
63
+ fs.writeFileSync(tmpPath, `${JSON.stringify(entry, null, 2)}\n`, { mode: FILE_MODE });
64
+ fs.chmodSync(tmpPath, FILE_MODE);
65
+ fs.renameSync(tmpPath, filePath);
66
+ fs.chmodSync(filePath, FILE_MODE);
67
+ fs.chmodSync(baseDir, DIR_MODE);
68
+ }
69
+ /** Returns false when there was nothing to forget, so `clear` can say so rather than imply it acted. */
70
+ export function clearEventKey(baseDir = defaultBaseDir()) {
71
+ try {
72
+ fs.unlinkSync(eventKeyPath(baseDir));
73
+ return true;
74
+ }
75
+ catch (err) {
76
+ const code = err.code;
77
+ if (code === 'ENOENT' || code === 'ENOTDIR')
78
+ return false;
79
+ throw new CliError(`Cannot remove ${eventKeyPath(baseDir)}: ${code ?? String(err)}`);
80
+ }
81
+ }
82
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/event/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUxC,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,UAAkB,cAAc,EAAE;IAC7D,OAAO,IAAI,CAAC,IAAI,CA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iB,YAAY,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvF,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitmagic/cli",
3
- "version": "0.1.68-dev.2",
3
+ "version": "0.1.68-dev.4",
4
4
  "description": "Build Bitmagic games from your own agent tool",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Bitmagic Oy",
@@ -25,9 +25,9 @@
25
25
  "playwright-core": "^1.59.1",
26
26
  "tar": "^7.4.3",
27
27
  "ws": "^8.21.3",
28
- "@bitmagic/animation-forger": "0.1.23-dev.2",
29
- "@bitmagic/world-forger": "0.1.28-dev.2",
30
- "@bitmagic/asset-core": "0.2.23-dev.2"
28
+ "@bitmagic/animation-forger": "0.1.23-dev.4",
29
+ "@bitmagic/world-forger": "0.1.28-dev.4",
30
+ "@bitmagic/asset-core": "0.2.23-dev.4"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@eslint/js": "^9.38.0",