unity-mcp-cli 1.1.0 → 1.3.0
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/CHANGELOG.md +46 -0
- package/README.md +39 -1
- package/dist/commands/close.d.ts +1 -0
- package/dist/commands/close.js +52 -0
- package/dist/commands/close.js.map +1 -1
- package/dist/commands/exec.d.ts +2 -0
- package/dist/commands/exec.js +117 -0
- package/dist/commands/exec.js.map +1 -0
- package/dist/commands/open.js +26 -1
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/run-tool-builder.d.ts +10 -1
- package/dist/commands/run-tool-builder.js +6 -26
- package/dist/commands/run-tool-builder.js.map +1 -1
- package/dist/commands/wait-for-ready.js +18 -62
- package/dist/commands/wait-for-ready.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/editor-session.d.ts +73 -0
- package/dist/lib/editor-session.js +187 -0
- package/dist/lib/editor-session.js.map +1 -0
- package/dist/lib/exec.d.ts +82 -0
- package/dist/lib/exec.js +113 -0
- package/dist/lib/exec.js.map +1 -0
- package/dist/lib/open.d.ts +5 -0
- package/dist/lib/open.js +128 -44
- package/dist/lib/open.js.map +1 -1
- package/dist/lib/run-tool.js +1 -1
- package/dist/lib/run-tool.js.map +1 -1
- package/dist/lib/types.d.ts +34 -1
- package/dist/lib/wait-for-ready.d.ts +36 -0
- package/dist/lib/wait-for-ready.js +29 -0
- package/dist/lib/wait-for-ready.js.map +1 -0
- package/dist/lib.d.ts +4 -0
- package/dist/lib.js +2 -0
- package/dist/lib.js.map +1 -1
- package/dist/utils/connection.d.ts +5 -0
- package/dist/utils/connection.js +15 -0
- package/dist/utils/connection.js.map +1 -1
- package/dist/utils/server-version.d.ts +1 -1
- package/dist/utils/server-version.js +1 -1
- package/docs/README.es.md +33 -0
- package/docs/README.ja.md +33 -0
- package/docs/README.zh-CN.md +33 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,52 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- **Editor sessions (lease + start lock) for `exec` and `open --headless`**, on `@baizor/gamedev-cli-core`'s
|
|
13
|
+
`EditorSession` (dependency bumped to `^0.7.1`). An editor the CLI starts is recorded in
|
|
14
|
+
`<project>/.ai-game-dev/session.json` (PID, process start time, nonce) under the file lock
|
|
15
|
+
`.ai-game-dev/session.lock`, so parallel cold `exec` calls start exactly one editor and share it. A running editor
|
|
16
|
+
of the project (the user's GUI included) is still reused and never closed. The started editor gets the shared
|
|
17
|
+
session env `AIGD_SESSION_IDLE_SECONDS` / `AIGD_SESSION_OWNER=cli` / `AIGD_SESSION_NONCE`.
|
|
18
|
+
- **`close --owned-only`**, and `close` asks an editor the CLI started to save and quit through its plugin (the new
|
|
19
|
+
`editor-session-quit` system tool, checked against the lease nonce). This reaches a headless editor, which the
|
|
20
|
+
Windows polite quit (`WM_CLOSE`) never does; an editor opened by the user is never closed by `--owned-only`.
|
|
21
|
+
- **`open` with a window closes the CLI's own headless editor first** (it saves), so the window can open.
|
|
22
|
+
- **The lease records the server URL** the editor was started against (and its connection mode), so `close` asks
|
|
23
|
+
the plugin there without resolving the connection again (then at whichever resolved URL answers; the call's token
|
|
24
|
+
is never sent to a remote server it was not resolved for). A lease whose editor has exited no longer hides the
|
|
25
|
+
user's editor from `open --headless`. The session files are kept out of git by
|
|
26
|
+
`.ai-game-dev/.gitignore`.
|
|
27
|
+
- **`exec` fails fast on an editor it did not start that never answers** (default 60 s instead of the full
|
|
28
|
+
`--ready-timeout`): e.g. the user's editor whose plugin is disconnected or connected to the ai-game.dev cloud. The
|
|
29
|
+
message says what to do (connect the plugin, switch it to Custom, or pass `--url`); `ExecCodeFailure.editorSource`
|
|
30
|
+
is `foreign` then, and `ExecCodeOptions.foreignReadyTimeoutMs` sets the wait. If that editor exits while `exec`
|
|
31
|
+
waits, `exec` starts its own.
|
|
32
|
+
- **`open --headless` waits until the editor's MCP server answers** (`--ready-timeout`, default 300000 ms) and
|
|
33
|
+
reports the URL; its `--idle-timeout` is sent as `AIGD_SESSION_IDLE_SECONDS`. A windowed `open --idle-timeout`
|
|
34
|
+
still sets `UNITY_MCP_IDLE_TIMEOUT`.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- `exec` waits 310000 ms by default (was 180000; `--timeout` and `ExecCodeOptions.timeoutMs`; exported as
|
|
39
|
+
`DEFAULT_EXEC_TIMEOUT_MS`): longer than the MCP server's default `tool-timeout` (300000, McpPlugin 8.11.0+), so
|
|
40
|
+
the CLI never gives up on a call the server is still waiting for.
|
|
41
|
+
|
|
42
|
+
- `wait-for-ready` / `waitForReady` use cli-core's readiness probe: a 401/403 now counts as a server that is up (the
|
|
43
|
+
next call reports the auth problem). `WaitForReadyOptions.probeImpl` is replaced by `fetchImpl`.
|
|
44
|
+
- `execCode`'s test seam `deps` is now `{ session, invoke }`; failures carry `sessionReason`.
|
|
45
|
+
|
|
46
|
+
- **`exec` command.** `unity-mcp-cli exec '<C#>'` runs a snippet through the `script-execute` tool and prints the
|
|
47
|
+
result. It reuses an editor that is already open for the project (window or headless) and never closes it;
|
|
48
|
+
otherwise it starts a headless editor (`--window` for a windowed one) that stays warm and quits by itself after
|
|
49
|
+
`--idle` seconds (default 300) without tool calls. Code comes from the argument, `-f <file>` or stdin;
|
|
50
|
+
`--using` and `--include` are repeatable.
|
|
51
|
+
- **`open --headless` and `open --idle-timeout <seconds>`.** `--headless` launches with `-batchmode` (graphics stay
|
|
52
|
+
on, so cameras render) and implies `--keep-connected`; `--idle-timeout` sets `UNITY_MCP_IDLE_TIMEOUT`, which the
|
|
53
|
+
plugin uses to quit after that many idle seconds (it saves changed scenes and assets first).
|
|
54
|
+
- **`execCode` and `waitForReady` library functions** (exported from the package root), the code behind `exec` and
|
|
55
|
+
`wait-for-ready`. `runTool` accepts `tokenFromCloudStore` so a caller-resolved machine-store Bearer is refreshed once
|
|
56
|
+
on 401, as when the library resolves the connection itself.
|
|
57
|
+
|
|
12
58
|
- **`runTool` / `runSystemTool` library functions.** The HTTP-tool
|
|
13
59
|
invocation paths previously available only as the `run-tool` /
|
|
14
60
|
`run-system-tool` CLI commands are now first-class library exports:
|
package/README.md
CHANGED
|
@@ -100,6 +100,7 @@ npx unity-mcp-cli install-plugin /path/to/unity/project
|
|
|
100
100
|
- [`open`](#open)
|
|
101
101
|
- [`close`](#close)
|
|
102
102
|
- [`run-tool`](#run-tool)
|
|
103
|
+
- [`exec`](#exec)
|
|
103
104
|
- [`wait-for-ready`](#wait-for-ready)
|
|
104
105
|
- [`setup-mcp`](#setup-mcp)
|
|
105
106
|
- [`setup-skills`](#setup-skills)
|
|
@@ -356,10 +357,15 @@ cd ./MyGame && unity-mcp-cli open
|
|
|
356
357
|
| `--tools <names>` | `UNITY_MCP_TOOLS` | No | Comma-separated list of tools to enable |
|
|
357
358
|
| `--transport <method>` | `UNITY_MCP_TRANSPORT` | No | Transport method: `streamableHttp` or `stdio` |
|
|
358
359
|
| `--start-server <value>` | `UNITY_MCP_START_SERVER` | No | Set to `true` or `false` to control MCP server auto-start |
|
|
360
|
+
| `--headless` | — | No | Start the editor without a window (`-batchmode`; graphics stay on, so cameras still render) and wait until its MCP server answers. Implies `--keep-connected`. A running editor of the project is reused; one started here is the CLI's own (see [`close --owned-only`](#close)), and parallel calls start only one. |
|
|
361
|
+
| `--idle-timeout <seconds>` | `AIGD_SESSION_IDLE_SECONDS` (headless) / `UNITY_MCP_IDLE_TIMEOUT` (window) | No | Quit the editor after this many seconds without a tool call (saves changed scenes and assets first) |
|
|
362
|
+
| `--ready-timeout <ms>` | — | No | With `--headless`: how long to wait for the editor to become ready (default: `300000`) |
|
|
359
363
|
| `--no-auto-dismiss-launch-errors` | — | No | Disable auto-dismissal of the Unity Editor "compile errors at launch" dialog (default: enabled) |
|
|
360
364
|
| `--launch-dismiss-timeout-ms <ms>` | — | No | Overall timeout (milliseconds) for the launch-errors auto-dismiss polling loop (default: `30000`) |
|
|
361
365
|
| `--launch-dismiss-poll-interval-ms <ms>` | — | No | Polling tick interval (milliseconds) for the launch-errors auto-dismiss loop (default: `1500`) |
|
|
362
366
|
|
|
367
|
+
Without `--headless`, a headless editor that the CLI started for the project (`exec`, `open --headless`) is asked to save and quit first, so the window can open.
|
|
368
|
+
|
|
363
369
|
The editor process is spawned in detached mode. By default, after spawning the editor, `open` polls for Unity's "compile errors at launch" dialog (`"Enter Safe Mode?"` on Unity 2020.2+, `"Hold On" / "Compiler Errors"` on older releases) and clicks `Ignore` so the editor finishes initialising — without this, any in-Editor automation that needs to run after a state where Unity itself can't compile (e.g. the NuGet dependency resolver) cannot self-heal. The dialog is surfaced after Unity has booted, connected to Package Manager, and started compiling — empirically ~6s on a fast machine and longer on a slow one — so the polling loop has a grace window after which it exits early if no dialog has been seen. The grace window has to cover Unity's full startup phase or the loop bails out before the dialog ever appears (issue #737); it never runs the full `--launch-dismiss-timeout-ms` in the no-dialog case. If the dialog is observed (and successfully dismissed), polling continues until the overall timeout so a re-appearing dialog (resolver fixes one error → dialog re-surfaces with the next) is dismissed again. Library-mode callers can supply an `AbortSignal` (`launchDismissAbortSignal` on `OpenProjectOptions`) to abort the loop the instant their own readiness signal fires.
|
|
364
370
|
|
|
365
371
|
### Auto-dismiss platform requirements
|
|
@@ -411,9 +417,11 @@ unity-mcp-cli close ./MyGame
|
|
|
411
417
|
| `[path]` | No | Path to the Unity project (positional, defaults to current directory) |
|
|
412
418
|
| `--timeout <seconds>` | No | Polite-quit timeout in seconds (default: 30) |
|
|
413
419
|
| `--force` | No | Hard-kill the Editor if it does not exit within `--timeout` |
|
|
420
|
+
| `--owned-only` | No | Close only an Editor that the CLI started (`exec`, `open --headless`); an Editor opened by the user is never touched |
|
|
414
421
|
|
|
415
422
|
**How it works:**
|
|
416
423
|
|
|
424
|
+
0. An Editor the CLI started is recorded in the project's session lease (`.ai-game-dev/session.json`: PID, process start time, nonce). If the lease names a live Editor, `close` asks its plugin to save and quit (the `editor-session-quit` system tool, checked against the lease nonce, at the server URL the lease recorded when the Editor was started) — this also reaches a headless Editor, which `WM_CLOSE` cannot — and skips the steps below. With `--owned-only` it stops here: no lease, nothing is closed.
|
|
417
425
|
1. Resolves the running Editor's PID by reading `<project>/Temp/UnityLockfile` (4-byte little-endian uint32) and cross-checking against process enumeration to handle stale lock files.
|
|
418
426
|
2. Sends a polite-quit signal — `SIGTERM` on Linux/macOS, `taskkill` (no `/F`) on Windows — letting Unity finish autosave / asset-import.
|
|
419
427
|
3. Polls every 250ms until the process exits or `--timeout` elapses.
|
|
@@ -421,7 +429,7 @@ unity-mcp-cli close ./MyGame
|
|
|
421
429
|
5. Idempotent — closing an already-closed Editor (or a project whose Editor was never running) exits 0 with `no running Editor for project at <path>`.
|
|
422
430
|
6. Refuses to act on any path that is not a Unity project root (`ProjectSettings/ProjectVersion.txt` must exist) — protects against accidental kill-all-Unity-on-host invocations.
|
|
423
431
|
|
|
424
|
-
> **Windows headless caveat:** the polite-quit step uses `taskkill` (no `/F`), which delivers `WM_CLOSE`. That message only reaches processes owning a top-level window on the **same desktop/session** as the CLI. If Unity was launched by a Windows service in session 0 (or any other non-interactive desktop), the polite-quit will be silently dropped, the `--timeout` will elapse, and `--force` becomes the only path that brings the Editor down. Plan accordingly in headless CI runners.
|
|
432
|
+
> **Windows headless caveat:** the polite-quit step uses `taskkill` (no `/F`), which delivers `WM_CLOSE`. That message only reaches processes owning a top-level window on the **same desktop/session** as the CLI. If Unity was launched by a Windows service in session 0 (or any other non-interactive desktop), the polite-quit will be silently dropped, the `--timeout` will elapse, and `--force` becomes the only path that brings the Editor down. Plan accordingly in headless CI runners. An Editor started by the CLI (step 0) is not affected: it quits through its plugin.
|
|
425
433
|
|
|
426
434
|
**Example — close, fall back to force after 60s:**
|
|
427
435
|
|
|
@@ -486,6 +494,36 @@ unity-mcp-cli run-tool assets-list ./MyGame --raw | jq '.results'
|
|
|
486
494
|
|
|
487
495
|

|
|
488
496
|
|
|
497
|
+
## `exec`
|
|
498
|
+
|
|
499
|
+
Run C# in the Unity Editor and print the result. If the project is already open (with a window or headless) `exec` uses that editor and never closes it. Otherwise it starts a headless editor that stays warm for the next calls and quits by itself after `--idle` seconds without tool calls (saving changed scenes and assets). The editor it starts is recorded in the project's session lease (`.ai-game-dev/session.json`) and started under a file lock, so parallel `exec` calls share one editor; `close --owned-only` closes it, and `open` (with a window) closes it before opening the window. These session files are machine-local: `.ai-game-dev/.gitignore` keeps them out of git. If the project is open in an editor the CLI did not start and its plugin does not answer within 60 s (disconnected, or connected to the ai-game.dev cloud), `exec` stops with a hint instead of waiting: connect the plugin, switch its connection to Custom (a local server), or pass `--url`.
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
# The last expression is the result
|
|
503
|
+
unity-mcp-cli exec 'GameObject.FindObjectsOfType<Camera>().Length'
|
|
504
|
+
|
|
505
|
+
# From a file or stdin, with extra namespaces and helper files
|
|
506
|
+
unity-mcp-cli exec -f ./snippet.cs --using MyGame.Gameplay --include Helpers/
|
|
507
|
+
echo 'Application.unityVersion' | unity-mcp-cli exec
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
| Option | Required | Description |
|
|
511
|
+
|---|---|---|
|
|
512
|
+
| `[code]` | No | C# snippet: plain statements, the last expression is the result. Alternatively `-f` or stdin. |
|
|
513
|
+
| `--path <path>` | No | Unity project path (default: current directory) |
|
|
514
|
+
| `-f, --file <file>` | No | Read the code from a file (`-` for stdin) |
|
|
515
|
+
| `--using <namespace>` | No | Extra namespace, repeatable |
|
|
516
|
+
| `--include <path>` | No | Helper `.cs` file or folder (recursive), relative to `<Project>/.ai-game-dev/snippets`, repeatable |
|
|
517
|
+
| `--window` | No | Start the editor with a window instead of headless (only when it is not running yet) |
|
|
518
|
+
| `--idle <seconds>` | No | Quit an editor started by `exec` after this many idle seconds (default: 300) |
|
|
519
|
+
| `--ready-timeout <ms>` | No | How long to wait for the editor to become ready (default: 300000) |
|
|
520
|
+
| `--timeout <ms>` | No | Tool call timeout (default: 310000) |
|
|
521
|
+
| `--raw` | No | Print the raw tool response JSON |
|
|
522
|
+
| `--url <url>` | No | Server URL override; a local URL also makes a newly started editor start that server |
|
|
523
|
+
| `--token <token>` | No | Bearer token override |
|
|
524
|
+
|
|
525
|
+
`exec` calls the `script-execute` tool, so snippets, `usings` and `include` need a plugin version with Code-Exec support. A compile error exits with code 1 and points at your own lines.
|
|
526
|
+
|
|
489
527
|
## `wait-for-ready`
|
|
490
528
|
|
|
491
529
|
Wait until Unity Editor and MCP server are connected and ready to accept tool calls. Polls the server at a configurable interval until it responds successfully or the timeout is reached. Useful for automation scripts and AI agent orchestration where `open` launches Unity but the agent needs to know when it can start calling tools.
|
package/dist/commands/close.d.ts
CHANGED
package/dist/commands/close.js
CHANGED
|
@@ -5,6 +5,8 @@ import { platform as nodePlatform } from 'os';
|
|
|
5
5
|
import * as ui from '../utils/ui.js';
|
|
6
6
|
import { verbose } from '../utils/ui.js';
|
|
7
7
|
import { findUnityProcess } from '../utils/unity-process.js';
|
|
8
|
+
import { readSessionLease } from '@baizor/gamedev-cli-core';
|
|
9
|
+
import { createProjectSession } from '../lib/editor-session.js';
|
|
8
10
|
import { readLockfilePid, isProcessAlive, sendGracefulShutdown, sendForceKill, waitForExit, } from '../utils/unity-shutdown.js';
|
|
9
11
|
const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
10
12
|
/**
|
|
@@ -109,11 +111,49 @@ export function resolveEditorPid(projectPath, platform = nodePlatform()) {
|
|
|
109
111
|
}
|
|
110
112
|
return proc ? proc.pid : null;
|
|
111
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Close the editor the project's session lease names, if it is live: exits with the outcome. Returns (nothing done)
|
|
116
|
+
* when no editor of ours runs; a stale lease is removed, and no process is touched. `unverified`: a lease is left
|
|
117
|
+
* that names no editor provably ours (e.g. its process start time is unreadable), so it was not closed.
|
|
118
|
+
*/
|
|
119
|
+
async function closeOwnedEditor(projectPath, timeoutSeconds, force, ownedOnly) {
|
|
120
|
+
if (!readSessionLease(projectPath))
|
|
121
|
+
return 'none';
|
|
122
|
+
const spinner = ui.startSpinner('Asking the Unity Editor started by unity-mcp-cli to save and quit...');
|
|
123
|
+
let result;
|
|
124
|
+
try {
|
|
125
|
+
const session = await createProjectSession(projectPath, {});
|
|
126
|
+
result = await session.closeOwned({ timeoutMs: timeoutSeconds * 1000, force });
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
const message = `Could not close the Unity Editor started by unity-mcp-cli: ${err instanceof Error ? err.message : String(err)}`;
|
|
130
|
+
if (ownedOnly) {
|
|
131
|
+
spinner.error(message);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
// Without --owned-only the OS polite quit below still applies.
|
|
135
|
+
spinner.stop();
|
|
136
|
+
verbose(message);
|
|
137
|
+
return 'none';
|
|
138
|
+
}
|
|
139
|
+
if (result.kind === 'closed') {
|
|
140
|
+
spinner.success(`Unity Editor (PID ${result.pid}) started by unity-mcp-cli ${result.forced ? 'force-killed' : 'exited cleanly'}`);
|
|
141
|
+
process.exit(0);
|
|
142
|
+
}
|
|
143
|
+
if (result.kind === 'still-running') {
|
|
144
|
+
spinner.error(`Unity Editor (PID ${result.pid}) did not exit within ${timeoutSeconds}s.` +
|
|
145
|
+
(force ? '' : ' Re-run with --force to hard-kill.'));
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
spinner.stop();
|
|
149
|
+
return readSessionLease(projectPath) ? 'unverified' : 'none';
|
|
150
|
+
}
|
|
112
151
|
export const closeCommand = new Command('close')
|
|
113
152
|
.description('Gracefully terminate the Unity Editor instance running for a given project path')
|
|
114
153
|
.argument('[path]', 'Path to the Unity project (defaults to current directory)')
|
|
115
154
|
.option('--timeout <seconds>', `Polite-quit timeout in seconds (default: ${DEFAULT_TIMEOUT_SECONDS})`, String(DEFAULT_TIMEOUT_SECONDS))
|
|
116
155
|
.option('--force', 'Hard-kill the Editor if it does not exit within --timeout')
|
|
156
|
+
.option('--owned-only', 'Close only an Editor started by unity-mcp-cli (exec, open --headless); never one opened by the user')
|
|
117
157
|
.action(async (positionalPath, options) => {
|
|
118
158
|
const projectPath = resolveCloseProjectPath(positionalPath, process.cwd());
|
|
119
159
|
verbose(`close invoked for project: ${projectPath}`);
|
|
@@ -130,6 +170,18 @@ export const closeCommand = new Command('close')
|
|
|
130
170
|
ui.error(`Invalid --timeout value: "${options.timeout}". Must be a positive integer (seconds).`);
|
|
131
171
|
process.exit(1);
|
|
132
172
|
}
|
|
173
|
+
// An editor this CLI started (the session lease names it) is asked to quit through its plugin: it saves, and
|
|
174
|
+
// unlike WM_CLOSE this reaches a headless editor too.
|
|
175
|
+
const owned = await closeOwnedEditor(projectPath, timeoutSeconds, options.force === true, options.ownedOnly === true);
|
|
176
|
+
if (options.ownedOnly) {
|
|
177
|
+
if (owned === 'unverified') {
|
|
178
|
+
ui.warn(`the session lease of ${projectPath} names no Editor that is provably unity-mcp-cli's; nothing was closed`);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
ui.success(`no Editor started by unity-mcp-cli is running for project at ${projectPath}`);
|
|
182
|
+
}
|
|
183
|
+
process.exit(0);
|
|
184
|
+
}
|
|
133
185
|
const platform = nodePlatform();
|
|
134
186
|
const pid = resolveEditorPid(projectPath, platform);
|
|
135
187
|
if (pid === null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../src/commands/close.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACr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AC;IAE3D,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,OAAO,CAAC,qBAAqB,GAAG,kBAAkB,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CACX,qBAAqB,GAAG,yBAAyB,cAAc,KAAK;YAClE,yDAAyD,CAC5D,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,IAAI,GAAG,qBAAqB,GAAG,KAAK,CAAC;IAC7C,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,uEAAuE;IACvE,wEAAwE;IACxE,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACtD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,OAAO,CAAC,qBAAqB,GAAG,gBAAgB,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,qBAAqB,GAAG,mCAAmC,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import * as ui from '../utils/ui.js';
|
|
4
|
+
import { verbose } from '../utils/ui.js';
|
|
5
|
+
import { resolveAndValidateProjectPath, resolveConnection, resolveProbeUrls } from '../utils/connection.js';
|
|
6
|
+
import { DEFAULT_EXEC_TIMEOUT_MS, execCode, readToolResponse, SCRIPT_EXECUTE_TOOL } from '../lib/exec.js';
|
|
7
|
+
import { parsePositiveIntFlag } from './open.js';
|
|
8
|
+
import { handleFailure, stringifyForRaw } from './run-tool-builder.js';
|
|
9
|
+
/** `parsePositiveIntFlag` also accepts 0, which none of the exec timeouts can mean. */
|
|
10
|
+
function parseNonZeroIntFlag(raw, flagName, fallback) {
|
|
11
|
+
const value = parsePositiveIntFlag(raw, flagName, fallback);
|
|
12
|
+
if (value === 0) {
|
|
13
|
+
ui.error(`${flagName} must be greater than 0`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function collect(value, previous) {
|
|
19
|
+
return [...previous, value];
|
|
20
|
+
}
|
|
21
|
+
function readCode(code, file) {
|
|
22
|
+
if (code !== undefined && file !== undefined)
|
|
23
|
+
throw new Error('Pass the code either as an argument or with --file, not both.');
|
|
24
|
+
if (code !== undefined)
|
|
25
|
+
return code;
|
|
26
|
+
const fromStdin = file === '-' || (file === undefined && !process.stdin.isTTY);
|
|
27
|
+
if (!fromStdin && file === undefined)
|
|
28
|
+
throw new Error('No code given: pass it as an argument, with --file <file>, or on stdin.');
|
|
29
|
+
const text = fs.readFileSync(fromStdin ? 0 : file, 'utf-8');
|
|
30
|
+
if (text.trim() === '')
|
|
31
|
+
throw new Error(fromStdin ? 'No code received from stdin.' : `The file is empty: ${file}`);
|
|
32
|
+
return text;
|
|
33
|
+
}
|
|
34
|
+
export const execCommand = new Command('exec')
|
|
35
|
+
.description('Run C# in the Unity Editor; starts a headless editor when none is open and keeps it warm')
|
|
36
|
+
.argument('[code]', 'C# snippet: statements, the last expression is the result')
|
|
37
|
+
.option('--path <path>', 'Unity project path (default: current directory)')
|
|
38
|
+
.option('-f, --file <file>', 'Read the code from a file ("-" for stdin)')
|
|
39
|
+
.option('--using <namespace>', 'Extra namespace (repeatable)', collect, [])
|
|
40
|
+
.option('--include <path>', 'Helper .cs file or folder, relative to the project snippets folder (repeatable)', collect, [])
|
|
41
|
+
.option('--window', 'Start the editor with a window instead of headless (only when it is not running yet)')
|
|
42
|
+
.option('--idle <seconds>', 'Quit an editor started by exec after this many idle seconds (0: never)', '300')
|
|
43
|
+
.option('--ready-timeout <ms>', 'How long to wait for the editor to become ready', '300000')
|
|
44
|
+
.option('--timeout <ms>', 'Tool call timeout in milliseconds', String(DEFAULT_EXEC_TIMEOUT_MS))
|
|
45
|
+
.option('--raw', 'Print the raw tool response JSON')
|
|
46
|
+
.option('--url <url>', 'Direct server URL override (bypasses config)')
|
|
47
|
+
.option('--token <token>', 'Bearer token override (bypasses config)')
|
|
48
|
+
.action(async (codeArg, options) => {
|
|
49
|
+
const idleTimeoutSeconds = parsePositiveIntFlag(options.idle, '--idle', 300); // 0: never quit
|
|
50
|
+
const readyTimeoutMs = parseNonZeroIntFlag(options.readyTimeout, '--ready-timeout', 300000);
|
|
51
|
+
const timeoutMs = parseNonZeroIntFlag(options.timeout, '--timeout', DEFAULT_EXEC_TIMEOUT_MS);
|
|
52
|
+
let code;
|
|
53
|
+
try {
|
|
54
|
+
code = readCode(codeArg, options.file);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
ui.error(err instanceof Error ? err.message : String(err));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const projectPath = resolveAndValidateProjectPath(undefined, options);
|
|
61
|
+
const { url, token, cloudAuthMissing, tokenFromCloudStore } = await resolveConnection(projectPath, options);
|
|
62
|
+
if (cloudAuthMissing) {
|
|
63
|
+
ui.error('Not logged in to ai-game.dev. Run `unity-mcp-cli login` to sign in, then retry — or pass --token / --url.');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
const spinner = options.raw ? null : ui.startSpinner('Connecting...');
|
|
67
|
+
const result = await execCode({
|
|
68
|
+
projectPath,
|
|
69
|
+
code,
|
|
70
|
+
usings: options.using,
|
|
71
|
+
include: options.include,
|
|
72
|
+
window: options.window === true,
|
|
73
|
+
idleTimeoutSeconds,
|
|
74
|
+
readyTimeoutMs,
|
|
75
|
+
timeoutMs,
|
|
76
|
+
probeUrls: resolveProbeUrls(projectPath, url, options.url),
|
|
77
|
+
token,
|
|
78
|
+
tokenFromCloudStore,
|
|
79
|
+
overrideUrl: options.url,
|
|
80
|
+
overrideToken: options.token,
|
|
81
|
+
onStatus: message => {
|
|
82
|
+
verbose(message);
|
|
83
|
+
if (spinner)
|
|
84
|
+
spinner.text = message;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
if (result.kind === 'failure') {
|
|
88
|
+
if (result.toolFailure) {
|
|
89
|
+
spinner?.stop();
|
|
90
|
+
handleFailure(result.toolFailure, {
|
|
91
|
+
toolName: SCRIPT_EXECUTE_TOOL,
|
|
92
|
+
endpoint: result.toolFailure.endpoint,
|
|
93
|
+
raw: options.raw,
|
|
94
|
+
timeoutMs,
|
|
95
|
+
errorNoun: 'tool',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
spinner?.error(result.reason === 'launch-failed' ? 'Could not start the Unity Editor' : 'The MCP server did not answer');
|
|
99
|
+
ui.error(result.message);
|
|
100
|
+
if (result.reason === 'not-ready' && result.editorSource !== 'foreign') {
|
|
101
|
+
ui.info('If the project is open in a Unity Editor, check that its AI Game Developer plugin is connected.');
|
|
102
|
+
}
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
spinner?.stop();
|
|
106
|
+
if (options.raw) {
|
|
107
|
+
process.stdout.write(stringifyForRaw(result.data));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const response = readToolResponse(result.data);
|
|
111
|
+
if (!response.ok) {
|
|
112
|
+
ui.error(response.text);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
console.log(response.text);
|
|
116
|
+
});
|
|
117
|
+
//# sourceM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,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACvE,EAAE,CAAC,IAAI,CAAC,iGAAiG,CAAC,CAAC;QAC7G,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,CAAC;IAChB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,OAAO;IACT,CAAC;IACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC"}
|
package/dist/commands/open.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { DEFAULT_SESSION_READY_TIMEOUT_MS } from '@baizor/gamedev-cli-core';
|
|
2
3
|
import * as path from 'path';
|
|
3
4
|
import { findUnityHub, listInstalledEditors } from '../utils/unity-hub.js';
|
|
4
5
|
import { findUnityProcess } from '../utils/unity-process.js';
|
|
@@ -96,6 +97,9 @@ export const openCommand = new Command('open')
|
|
|
96
97
|
.option('--keep-connected', 'Force keep connected (sets UNITY_MCP_KEEP_CONNECTED=true)')
|
|
97
98
|
.option('--transport <method>', 'Transport method: streamableHttp or stdio (sets UNITY_MCP_TRANSPORT)')
|
|
98
99
|
.option('--start-server <value>', 'Set to true/false to control server auto-start (sets UNITY_MCP_START_SERVER)', undefined)
|
|
100
|
+
.option('--headless', 'Run the editor without a window (-batchmode, graphics kept) and wait until it is ready; implies --keep-connected')
|
|
101
|
+
.option('--idle-timeout <seconds>', 'Quit the editor after this many seconds without a tool call')
|
|
102
|
+
.option('--ready-timeout <ms>', 'With --headless: how long to wait for the editor to become ready', String(DEFAULT_SESSION_READY_TIMEOUT_MS))
|
|
99
103
|
.option('--no-auto-dismiss-launch-errors', 'Disable auto-dismissal of the Unity Editor "compile errors at launch" dialog (default: enabled). On macOS, requires Accessibility permission for the terminal / unity-mcp-cli binary. On Linux/X11, requires `xdotool` on PATH (Wayland not supported).')
|
|
100
104
|
.option('--launch-dismiss-timeout-ms <ms>', 'Overall timeout (milliseconds) for the launch-errors auto-dismiss polling loop (default: 30000)', '30000')
|
|
101
105
|
.option('--launch-dismiss-poll-interval-ms <ms>', 'Polling tick interval (milliseconds) for the launch-errors auto-dismiss loop (default: 1500)', '1500')
|
|
@@ -179,6 +183,9 @@ export const openCommand = new Command('open')
|
|
|
179
183
|
keepConnected: options.keepConnected,
|
|
180
184
|
transport: options.transport,
|
|
181
185
|
startServer: startServerBool,
|
|
186
|
+
headless: options.headless,
|
|
187
|
+
idleTimeoutSeconds: options.idleTimeout === undefined ? undefined : parsePositiveIntFlag(options.idleTimeout, '--idle-timeout', 0),
|
|
188
|
+
readyTimeoutMs: parsePositiveIntFlag(options.readyTimeout, '--ready-timeout', DEFAULT_SESSION_READY_TIMEOUT_MS),
|
|
182
189
|
autoDismissLaunchErrors: options.autoDismissLaunchErrors !== false,
|
|
183
190
|
launchDismissTimeoutMs,
|
|
184
191
|
launchDismissPollIntervalMs,
|
|
@@ -207,11 +214,17 @@ export const openCommand = new Command('open')
|
|
|
207
214
|
break;
|
|
208
215
|
}
|
|
209
216
|
case 'connection-details': {
|
|
217
|
+
// Headless emits no `editor-resolved` first: stop the spinner before printing below it.
|
|
218
|
+
if (spinner) {
|
|
219
|
+
spinner.stop();
|
|
220
|
+
spinner = undefined;
|
|
221
|
+
}
|
|
210
222
|
const envVars = event.envVars;
|
|
211
223
|
if (Object.keys(envVars).length > 0) {
|
|
212
224
|
ui.heading('Connection Details');
|
|
213
225
|
ui.label('Project', event.projectPath);
|
|
214
|
-
|
|
226
|
+
if (event.editorPath)
|
|
227
|
+
ui.label('Editor', event.editorPath);
|
|
215
228
|
ui.heading('Environment Variables');
|
|
216
229
|
for (const [key, value] of Object.entries(envVars)) {
|
|
217
230
|
const display = key === 'UNITY_MCP_TOKEN' ? '***' : value;
|
|
@@ -230,6 +243,14 @@ export const openCommand = new Command('open')
|
|
|
230
243
|
ui.label('Editor', event.editorPath);
|
|
231
244
|
break;
|
|
232
245
|
}
|
|
246
|
+
case 'session-status': {
|
|
247
|
+
if (spinner) {
|
|
248
|
+
spinner.stop();
|
|
249
|
+
spinner = undefined;
|
|
250
|
+
}
|
|
251
|
+
ui.info(event.message);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
233
254
|
case 'editor-launched': {
|
|
234
255
|
ui.success(`Launched Unity Editor (PID: ${event.pid ?? 'unknown'})`);
|
|
235
256
|
break;
|
|
@@ -277,6 +298,10 @@ export const openCommand = new Command('open')
|
|
|
277
298
|
ui.info('Skipping launch. Use the running instance or close it first.');
|
|
278
299
|
process.exit(0);
|
|
279
300
|
}
|
|
301
|
+
for (const warning of result.warnings)
|
|
302
|
+
verbose(warning);
|
|
303
|
+
if (result.baseUrl)
|
|
304
|
+
ui.success(`MCP server is ready at ${result.baseUrl}`);
|
|
280
305
|
// Path is normally absolute already; resolve defensively for
|
|
281
306
|
// verbose log parity with the legacy CLI.
|
|
282
307
|
verbose(`Resolved project path: ${path.resolve(result.projectPath)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/commands/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,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AAC;AACxE,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import type { RunToolOptions, RunToolResult } from '../lib/types.js';
|
|
2
|
+
import type { RunToolFailure, RunToolOptions, RunToolResult } from '../lib/types.js';
|
|
3
3
|
interface BuilderOptions {
|
|
4
4
|
/** CLI subcommand name, e.g. `'run-tool'`. */
|
|
5
5
|
name: string;
|
|
@@ -21,5 +21,14 @@ interface BuilderOptions {
|
|
|
21
21
|
/** Library function — `runTool` or `runSystemTool`. */
|
|
22
22
|
invoke: (opts: RunToolOptions) => Promise<RunToolResult>;
|
|
23
23
|
}
|
|
24
|
+
interface FailureContext {
|
|
25
|
+
toolName: string;
|
|
26
|
+
endpoint: string;
|
|
27
|
+
raw: boolean | undefined;
|
|
28
|
+
timeoutMs: number;
|
|
29
|
+
errorNoun: string;
|
|
30
|
+
}
|
|
24
31
|
export declare function buildRunToolCommand(cfg: BuilderOptions): Command;
|
|
32
|
+
export declare function stringifyForRaw(data: unknown): string;
|
|
33
|
+
export declare function handleFailure(failure: RunToolFailure, ctx: FailureContext): never;
|
|
25
34
|
export {};
|
|
@@ -2,7 +2,6 @@ import { Command } from 'commander';
|
|
|
2
2
|
import * as ui from '../utils/ui.js';
|
|
3
3
|
import { verbose } from '../utils/ui.js';
|
|
4
4
|
import { resolveAndValidateProjectPath, resolveConnection } from '../utils/connection.js';
|
|
5
|
-
import { refreshCloudAccessToken } from '../utils/cloud-credentials.js';
|
|
6
5
|
import { parseInput } from '../utils/input.js';
|
|
7
6
|
export function buildRunToolCommand(cfg) {
|
|
8
7
|
return new Command(cfg.name)
|
|
@@ -49,30 +48,11 @@ export function buildRunToolCommand(cfg) {
|
|
|
49
48
|
ui.divider();
|
|
50
49
|
}
|
|
51
50
|
const spinner = options.raw ? null : ui.startSpinner(`Calling ${toolName}...`);
|
|
52
|
-
// The CLI already resolved url/token, so passing them explicitly
|
|
53
|
-
//
|
|
54
|
-
const
|
|
55
|
-
toolName,
|
|
56
|
-
url: baseUrl,
|
|
57
|
-
...(bearer ? { token: bearer } : {}),
|
|
58
|
-
input: body,
|
|
59
|
-
timeoutMs,
|
|
51
|
+
// The CLI already resolved url/token, so passing them explicitly makes the lib's resolver a no-op; the lib
|
|
52
|
+
// still refreshes a machine-store Bearer once on 401.
|
|
53
|
+
const result = await cfg.invoke({
|
|
54
|
+
toolName, url: baseUrl, ...(token ? { token } : {}), input: body, timeoutMs, tokenFromCloudStore,
|
|
60
55
|
});
|
|
61
|
-
let result = await invokeOnce(token);
|
|
62
|
-
// Reactive refresh (unified-machine-auth 04 §3 rule 1): a 401 against a machine-store
|
|
63
|
-
// Bearer means revocation or clock skew the proactive check could not see — refresh the
|
|
64
|
-
// plugin family once under the cross-process lock and retry. Explicit --token/--url
|
|
65
|
-
// overrides are never refreshed.
|
|
66
|
-
if (result.kind === 'failure' &&
|
|
67
|
-
result.reason === 'http-error' &&
|
|
68
|
-
result.httpStatus === 401 &&
|
|
69
|
-
tokenFromCloudStore) {
|
|
70
|
-
const fresh = await refreshCloudAccessToken();
|
|
71
|
-
if (fresh) {
|
|
72
|
-
verbose('Server answered 401; retrying once with a refreshed cloud credential.');
|
|
73
|
-
result = await invokeOnce(fresh);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
56
|
if (result.kind === 'success') {
|
|
77
57
|
spinner?.success(`${toolName} completed`);
|
|
78
58
|
if (options.raw) {
|
|
@@ -96,14 +76,14 @@ export function buildRunToolCommand(cfg) {
|
|
|
96
76
|
});
|
|
97
77
|
});
|
|
98
78
|
}
|
|
99
|
-
function stringifyForRaw(data) {
|
|
79
|
+
export function stringifyForRaw(data) {
|
|
100
80
|
if (typeof data === 'string')
|
|
101
81
|
return data;
|
|
102
82
|
if (data === undefined)
|
|
103
83
|
return '';
|
|
104
84
|
return JSON.stringify(data);
|
|
105
85
|
}
|
|
106
|
-
function handleFailure(failure, ctx) {
|
|
86
|
+
export function handleFailure(failure, ctx) {
|
|
107
87
|
if (failure.reason === 'http-error') {
|
|
108
88
|
if (ctx.raw) {
|
|
109
89
|
process.stdout.write(stringifyForRaw(failure.data));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-tool-builder.js","sourceRoot":"","sources":["../../src/commands/run-tool-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"run-tool-builder.js","sourceRoot":"","sources":["../../src/commands/run-tool-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA2C/C,MAAM,UAAU,mBAAmB,CAAC,GAAmB;IACrD,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;SACzB,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC;SAC5B,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,cAAc,CAAC;SAC3C,QAAQ,CAAC,QAAQ,EAAE,8DAA8D,CAAC;SAClF,MAAM,CAAC,eAAe,EAAE,qDAAqD,CAAC;SAC9E,MAAM,CAAC,aAAa,EAAE,8CAA8C,CAAC;SACrE,MAAM,CAAC,iBAAiB,EAAE,yCAAyC,CAAC;SACpE,MAAM,CAAC,gBAAgB,EAAE,+BAA+B,CAAC;SACzD,MAAM,CAAC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