unity-agentic-tools 0.5.1 → 0.7.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/README.md +59 -97
- package/dist/animator-utils.d.ts +46 -0
- package/dist/animator-utils.d.ts.map +1 -0
- package/dist/animator-utils.js +161 -0
- package/dist/animator-utils.js.map +1 -0
- package/dist/bridge-install.d.ts +16 -0
- package/dist/bridge-install.d.ts.map +1 -0
- package/dist/bridge-install.js +94 -0
- package/dist/bridge-install.js.map +1 -0
- package/dist/build-settings.d.ts +43 -0
- package/dist/build-settings.d.ts.map +1 -0
- package/dist/build-settings.js +196 -0
- package/dist/build-settings.js.map +1 -0
- package/dist/build-version.d.ts +40 -0
- package/dist/build-version.d.ts.map +1 -0
- package/dist/build-version.js +114 -0
- package/dist/build-version.js.map +1 -0
- package/dist/class-ids.d.ts +30 -0
- package/dist/class-ids.d.ts.map +1 -0
- package/dist/class-ids.js +322 -0
- package/dist/class-ids.js.map +1 -0
- package/dist/cleanup.d.ts +21 -0
- package/dist/cleanup.d.ts.map +1 -0
- package/dist/cleanup.js +161 -0
- package/dist/cleanup.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1060 -8137
- package/dist/cli.js.map +1 -0
- package/dist/editor-client.d.ts +25 -0
- package/dist/editor-client.d.ts.map +1 -0
- package/dist/editor-client.js +458 -0
- package/dist/editor-client.js.map +1 -0
- package/dist/editor-discovery.d.ts +17 -0
- package/dist/editor-discovery.d.ts.map +1 -0
- package/dist/editor-discovery.js +248 -0
- package/dist/editor-discovery.js.map +1 -0
- package/dist/editor-transport.d.ts +30 -0
- package/dist/editor-transport.d.ts.map +1 -0
- package/dist/editor-transport.js +175 -0
- package/dist/editor-transport.js.map +1 -0
- package/dist/gitignore.d.ts +3 -0
- package/dist/gitignore.d.ts.map +1 -0
- package/dist/gitignore.js +40 -0
- package/dist/gitignore.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +116 -8346
- package/dist/index.js.map +1 -0
- package/dist/loaded-protection.d.ts +6 -0
- package/dist/loaded-protection.d.ts.map +1 -0
- package/dist/loaded-protection.js +95 -0
- package/dist/loaded-protection.js.map +1 -0
- package/dist/packages.d.ts +55 -0
- package/dist/packages.d.ts.map +1 -0
- package/dist/packages.js +102 -0
- package/dist/packages.js.map +1 -0
- package/dist/params.d.ts +54 -0
- package/dist/params.d.ts.map +1 -0
- package/dist/params.js +106 -0
- package/dist/params.js.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +7 -0
- package/dist/util.js.map +1 -0
- package/dist/utils.d.ts +82 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +291 -0
- package/dist/utils.js.map +1 -0
- package/package.json +10 -14
- package/dist/doc-indexer-cli.js +0 -3218
- package/native/index.d.ts +0 -335
- package/native/index.js +0 -330
- package/native/unity-file-tools.darwin-arm64.node +0 -0
- package/native/unity-file-tools.darwin-x64.node +0 -0
- package/native/unity-file-tools.linux-x64-gnu.node +0 -0
- package/native/unity-file-tools.win32-x64-msvc.node +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.read_editor_config = read_editor_config;
|
|
4
|
+
exports.discover_editor_config = discover_editor_config;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const gitignore_1 = require("./gitignore");
|
|
8
|
+
const editor_transport_1 = require("./editor-transport");
|
|
9
|
+
const util_1 = require("./util");
|
|
10
|
+
const BRIDGE_PORT_RANGE_START = 53782;
|
|
11
|
+
const BRIDGE_PORT_RANGE_END = 53791;
|
|
12
|
+
const LAST_KNOWN_CONFIG_FILE = 'editor.last.json';
|
|
13
|
+
const LAST_KNOWN_EDITOR_CONFIGS = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Read and validate the editor bridge lockfile.
|
|
16
|
+
* Returns the config if valid, or an object with an error string.
|
|
17
|
+
*/
|
|
18
|
+
function read_editor_config(project_path) {
|
|
19
|
+
const config_path = (0, path_1.join)(project_path, '.unity-agentic', 'editor.json');
|
|
20
|
+
if (!(0, fs_1.existsSync)(config_path)) {
|
|
21
|
+
return { error: `Editor bridge not found at ${config_path}. Is the Unity Editor running with the bridge package installed?` };
|
|
22
|
+
}
|
|
23
|
+
let config;
|
|
24
|
+
try {
|
|
25
|
+
const raw = (0, fs_1.readFileSync)(config_path, 'utf-8');
|
|
26
|
+
config = JSON.parse(raw);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return { error: `Failed to parse editor.json: ${err instanceof Error ? err.message : String(err)}` };
|
|
30
|
+
}
|
|
31
|
+
if (typeof config.port !== 'number' || typeof config.pid !== 'number') {
|
|
32
|
+
return { error: 'Invalid editor.json: missing port or pid' };
|
|
33
|
+
}
|
|
34
|
+
if (!is_pid_alive(config.pid)) {
|
|
35
|
+
return { error: `Unity Editor process (PID ${config.pid}) is not running. The editor may have been closed.` };
|
|
36
|
+
}
|
|
37
|
+
return config;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve a usable bridge config.
|
|
41
|
+
* Prefers the lockfile when valid, otherwise discovers a matching bridge by project identity.
|
|
42
|
+
* Manual port selection remains an explicit escape hatch rather than the default fallback.
|
|
43
|
+
*/
|
|
44
|
+
async function discover_editor_config(project_path, timeout_ms = 350) {
|
|
45
|
+
const normalized_project_path = normalize_project_path(project_path);
|
|
46
|
+
const lockfile_result = read_editor_config(project_path);
|
|
47
|
+
const preferred_ports = [];
|
|
48
|
+
let cached_config = read_cached_editor_config(project_path, normalized_project_path)
|
|
49
|
+
?? LAST_KNOWN_EDITOR_CONFIGS.get(normalized_project_path);
|
|
50
|
+
let stale_cached_port;
|
|
51
|
+
if (!('error' in lockfile_result)) {
|
|
52
|
+
preferred_ports.push(lockfile_result.port);
|
|
53
|
+
const direct_ping = await (0, editor_transport_1.ping_editor)(lockfile_result.port, timeout_ms);
|
|
54
|
+
if (direct_ping.reachable) {
|
|
55
|
+
const resolved_config = {
|
|
56
|
+
...lockfile_result,
|
|
57
|
+
project_path: normalized_project_path,
|
|
58
|
+
source: 'lockfile',
|
|
59
|
+
};
|
|
60
|
+
remember_editor_config(normalized_project_path, resolved_config);
|
|
61
|
+
return resolved_config;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (cached_config) {
|
|
65
|
+
preferred_ports.push(cached_config.port);
|
|
66
|
+
const cached_ping = await (0, editor_transport_1.ping_editor)(cached_config.port, timeout_ms);
|
|
67
|
+
if (cached_ping.reachable) {
|
|
68
|
+
const resolved_config = {
|
|
69
|
+
...cached_config,
|
|
70
|
+
project_path: normalized_project_path,
|
|
71
|
+
source: 'cached',
|
|
72
|
+
};
|
|
73
|
+
remember_editor_config(normalized_project_path, resolved_config);
|
|
74
|
+
return resolved_config;
|
|
75
|
+
}
|
|
76
|
+
stale_cached_port = cached_config.port;
|
|
77
|
+
forget_cached_editor_config(project_path, normalized_project_path);
|
|
78
|
+
cached_config = undefined;
|
|
79
|
+
}
|
|
80
|
+
const discovered_infos = await discover_bridge_infos(timeout_ms, preferred_ports);
|
|
81
|
+
const matching_bridge = discovered_infos.find((info) => normalize_project_path(info.project_path) === normalized_project_path);
|
|
82
|
+
if (matching_bridge) {
|
|
83
|
+
const resolved_config = {
|
|
84
|
+
port: matching_bridge.port,
|
|
85
|
+
pid: matching_bridge.pid,
|
|
86
|
+
version: matching_bridge.version,
|
|
87
|
+
project_path: matching_bridge.project_path,
|
|
88
|
+
source: 'discovered',
|
|
89
|
+
};
|
|
90
|
+
remember_editor_config(normalized_project_path, resolved_config);
|
|
91
|
+
return resolved_config;
|
|
92
|
+
}
|
|
93
|
+
const discovered_projects = discovered_infos.map((info) => `${info.project_name ?? '(unknown)'}:${info.project_path}@${info.port}`);
|
|
94
|
+
const discovered_clause = discovered_projects.length > 0
|
|
95
|
+
? ` Reachable bridges were found for different projects: ${discovered_projects.join(', ')}.`
|
|
96
|
+
: ` No reachable bridge in ports ${BRIDGE_PORT_RANGE_START}-${BRIDGE_PORT_RANGE_END} identified project ${normalized_project_path}.`;
|
|
97
|
+
const stale_cache_clause = stale_cached_port !== undefined
|
|
98
|
+
? ` Cached bridge port ${stale_cached_port} was also unreachable.`
|
|
99
|
+
: '';
|
|
100
|
+
const port_hint = ' Use --port <n> only if you need to target a specific bridge manually.';
|
|
101
|
+
if (!('error' in lockfile_result)) {
|
|
102
|
+
return {
|
|
103
|
+
error: `Editor bridge lockfile pointed to port ${lockfile_result.port}, but it was unreachable and autodiscovery could not find a matching Unity project bridge.${stale_cache_clause}${discovered_clause}${port_hint}`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
error: `${lockfile_result.error} Autodiscovery could not find a matching Unity project bridge.${stale_cache_clause}${discovered_clause}${port_hint}`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Read bridge identity directly from a known port.
|
|
112
|
+
*/
|
|
113
|
+
async function read_bridge_info(port, timeout_ms) {
|
|
114
|
+
const response = await (0, editor_transport_1.request_editor_at_port)({
|
|
115
|
+
port,
|
|
116
|
+
method: 'editor.bridge.getInfo',
|
|
117
|
+
timeout: timeout_ms,
|
|
118
|
+
});
|
|
119
|
+
if (response.error) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return parse_bridge_info(response.result, port);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Discover bridge identities by probing the known editor bridge port range.
|
|
126
|
+
* Only bridges that can identify their owning Unity project are returned.
|
|
127
|
+
*/
|
|
128
|
+
async function discover_bridge_infos(timeout_ms, preferred_ports = []) {
|
|
129
|
+
const ports = new Set();
|
|
130
|
+
for (const port of preferred_ports) {
|
|
131
|
+
if (Number.isInteger(port) && port >= BRIDGE_PORT_RANGE_START && port <= BRIDGE_PORT_RANGE_END) {
|
|
132
|
+
ports.add(port);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (let port = BRIDGE_PORT_RANGE_START; port <= BRIDGE_PORT_RANGE_END; port += 1) {
|
|
136
|
+
ports.add(port);
|
|
137
|
+
}
|
|
138
|
+
const results = await Promise.all([...ports].map((port) => read_bridge_info(port, timeout_ms)));
|
|
139
|
+
return results.filter((result) => result !== null);
|
|
140
|
+
}
|
|
141
|
+
function parse_bridge_info(result, port) {
|
|
142
|
+
if (!(0, util_1.is_record)(result)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const project_path = typeof result.project_path === 'string' ? result.project_path : null;
|
|
146
|
+
if (!project_path) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
port,
|
|
151
|
+
pid: typeof result.pid === 'number' ? result.pid : 0,
|
|
152
|
+
version: typeof result.version === 'string' ? result.version : 'unknown',
|
|
153
|
+
project_path,
|
|
154
|
+
...(typeof result.project_name === 'string' ? { project_name: result.project_name } : {}),
|
|
155
|
+
...(typeof result.unity_version === 'string' ? { unity_version: result.unity_version } : {}),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function remember_editor_config(project_path, config) {
|
|
159
|
+
const cached_config = {
|
|
160
|
+
port: config.port,
|
|
161
|
+
pid: config.pid,
|
|
162
|
+
version: config.version,
|
|
163
|
+
project_path: config.project_path ?? project_path,
|
|
164
|
+
source: config.source,
|
|
165
|
+
};
|
|
166
|
+
LAST_KNOWN_EDITOR_CONFIGS.set(project_path, cached_config);
|
|
167
|
+
write_cached_editor_config(project_path, cached_config);
|
|
168
|
+
}
|
|
169
|
+
function forget_cached_editor_config(project_path, normalized_project_path) {
|
|
170
|
+
LAST_KNOWN_EDITOR_CONFIGS.delete(normalized_project_path);
|
|
171
|
+
const config_path = (0, path_1.join)(project_path, '.unity-agentic', LAST_KNOWN_CONFIG_FILE);
|
|
172
|
+
try {
|
|
173
|
+
if ((0, fs_1.existsSync)(config_path)) {
|
|
174
|
+
(0, fs_1.unlinkSync)(config_path);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// Cache cleanup is best-effort. Discovery must still proceed without it.
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function read_cached_editor_config(project_path, normalized_project_path) {
|
|
182
|
+
const config_path = (0, path_1.join)(project_path, '.unity-agentic', LAST_KNOWN_CONFIG_FILE);
|
|
183
|
+
if (!(0, fs_1.existsSync)(config_path)) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const raw = (0, fs_1.readFileSync)(config_path, 'utf-8');
|
|
188
|
+
const parsed = JSON.parse(raw);
|
|
189
|
+
if (typeof parsed.port !== 'number' || typeof parsed.pid !== 'number' || typeof parsed.version !== 'string') {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
port: parsed.port,
|
|
194
|
+
pid: parsed.pid,
|
|
195
|
+
version: parsed.version,
|
|
196
|
+
project_path: parsed.project_path ?? normalized_project_path,
|
|
197
|
+
source: 'cached',
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function write_cached_editor_config(project_path, config) {
|
|
205
|
+
const config_dir = (0, path_1.join)(project_path, '.unity-agentic');
|
|
206
|
+
const config_path = (0, path_1.join)(config_dir, LAST_KNOWN_CONFIG_FILE);
|
|
207
|
+
try {
|
|
208
|
+
(0, fs_1.mkdirSync)(config_dir, { recursive: true });
|
|
209
|
+
(0, gitignore_1.ensure_gitignore_ignores_agentic_dir)(project_path);
|
|
210
|
+
(0, fs_1.writeFileSync)(config_path, JSON.stringify({
|
|
211
|
+
port: config.port,
|
|
212
|
+
pid: config.pid,
|
|
213
|
+
version: config.version,
|
|
214
|
+
project_path: config.project_path,
|
|
215
|
+
}, null, 2));
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// Cache writes are best-effort. Discovery must still work without them.
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function normalize_project_path(project_path) {
|
|
222
|
+
const resolved_path = (0, path_1.resolve)(project_path);
|
|
223
|
+
let normalized = resolved_path;
|
|
224
|
+
try {
|
|
225
|
+
normalized = typeof fs_1.realpathSync.native === 'function'
|
|
226
|
+
? fs_1.realpathSync.native(resolved_path)
|
|
227
|
+
: (0, fs_1.realpathSync)(resolved_path);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
normalized = resolved_path;
|
|
231
|
+
}
|
|
232
|
+
return process.platform === 'win32'
|
|
233
|
+
? normalized.toLowerCase()
|
|
234
|
+
: normalized;
|
|
235
|
+
}
|
|
236
|
+
function is_pid_alive(pid) {
|
|
237
|
+
try {
|
|
238
|
+
process.kill(pid, 0);
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
catch (err) {
|
|
242
|
+
if ((0, util_1.is_record)(err) && err.code === 'EPERM') {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=editor-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-discovery.js","sourceRoot":"","sources":["../src/editor-discovery.ts"],"names":[],"mappings":";;AAoBA,gDAwBC;AAOD,wDA6EC;AAhID,2BAAkG;AAClG,+BAAqC;AACrC,2CAAmE;AACnE,yDAAyE;AACzE,iCAAmC;AAMnC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AACtC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AA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G,aAAa,CAAC;IAC/B,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC/B,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE;QAC1B,CAAC,CAAC,UAAU,CAAC;AACrB,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC7B,IAAI,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,IAAA,gBAAS,EAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RpcResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default per-request timeout shared between the orchestration layer
|
|
4
|
+
* (`call_editor` in editor-client.ts) and the wire layer (`request_editor_at_port`).
|
|
5
|
+
* When a caller leaves the timeout at the default we omit the `_timeout` hint;
|
|
6
|
+
* any non-default value is forwarded so the server can honor it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_EDITOR_REQUEST_TIMEOUT_MS = 10000;
|
|
9
|
+
export interface EditorPortRequestOptions {
|
|
10
|
+
port: number;
|
|
11
|
+
method: string;
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
timeout: number;
|
|
14
|
+
no_wait?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface EditorPingResult {
|
|
17
|
+
reachable: boolean;
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send a JSON-RPC request directly to a known editor bridge port.
|
|
22
|
+
*/
|
|
23
|
+
export declare function request_editor_at_port(options: EditorPortRequestOptions): Promise<RpcResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Quick connectivity check: attempts a WebSocket handshake and immediately closes.
|
|
26
|
+
* Returns whether the bridge is reachable within the timeout.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ping_editor(port: number, timeout_ms?: number): Promise<EditorPingResult>;
|
|
29
|
+
export declare function generate_editor_request_id(): string;
|
|
30
|
+
//# sourceMappingURL=editor-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-transport.d.ts","sourceRoot":"","sources":["../src/editor-transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAER,WAAW,EACd,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,QAAQ,CAAC;AAEvD,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC,CAoGpG;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,MAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyBpG;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_EDITOR_REQUEST_TIMEOUT_MS = void 0;
|
|
4
|
+
exports.request_editor_at_port = request_editor_at_port;
|
|
5
|
+
exports.ping_editor = ping_editor;
|
|
6
|
+
exports.generate_editor_request_id = generate_editor_request_id;
|
|
7
|
+
const util_1 = require("./util");
|
|
8
|
+
/**
|
|
9
|
+
* Default per-request timeout shared between the orchestration layer
|
|
10
|
+
* (`call_editor` in editor-client.ts) and the wire layer (`request_editor_at_port`).
|
|
11
|
+
* When a caller leaves the timeout at the default we omit the `_timeout` hint;
|
|
12
|
+
* any non-default value is forwarded so the server can honor it.
|
|
13
|
+
*/
|
|
14
|
+
exports.DEFAULT_EDITOR_REQUEST_TIMEOUT_MS = 10000;
|
|
15
|
+
/**
|
|
16
|
+
* Send a JSON-RPC request directly to a known editor bridge port.
|
|
17
|
+
*/
|
|
18
|
+
async function request_editor_at_port(options) {
|
|
19
|
+
const { port, method, params, timeout, no_wait } = options;
|
|
20
|
+
const url = `ws://127.0.0.1:${port}/unity-agentic`;
|
|
21
|
+
const request_id = generate_editor_request_id();
|
|
22
|
+
const wire_params = { ...params };
|
|
23
|
+
if (timeout !== exports.DEFAULT_EDITOR_REQUEST_TIMEOUT_MS)
|
|
24
|
+
wire_params._timeout = timeout;
|
|
25
|
+
if (no_wait)
|
|
26
|
+
wire_params.no_wait = true;
|
|
27
|
+
const request = {
|
|
28
|
+
jsonrpc: "2.0",
|
|
29
|
+
id: request_id,
|
|
30
|
+
method,
|
|
31
|
+
...(Object.keys(wire_params).length > 0 ? { params: wire_params } : {}),
|
|
32
|
+
};
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
let resolved = false;
|
|
35
|
+
let ws;
|
|
36
|
+
const timer = setTimeout(() => {
|
|
37
|
+
if (!resolved) {
|
|
38
|
+
resolved = true;
|
|
39
|
+
try {
|
|
40
|
+
ws?.close();
|
|
41
|
+
}
|
|
42
|
+
catch { }
|
|
43
|
+
resolve({
|
|
44
|
+
jsonrpc: "2.0",
|
|
45
|
+
id: request_id,
|
|
46
|
+
error: { code: -32001, message: `Timeout after ${timeout}ms waiting for response to ${method}` },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}, timeout);
|
|
50
|
+
try {
|
|
51
|
+
ws = new WebSocket(url);
|
|
52
|
+
ws.onopen = () => {
|
|
53
|
+
ws.send(JSON.stringify(request));
|
|
54
|
+
if (no_wait && !resolved) {
|
|
55
|
+
resolved = true;
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
setTimeout(() => { try {
|
|
58
|
+
ws.close();
|
|
59
|
+
}
|
|
60
|
+
catch { } }, 200);
|
|
61
|
+
resolve({
|
|
62
|
+
jsonrpc: "2.0",
|
|
63
|
+
id: request_id,
|
|
64
|
+
result: { queued: true },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
ws.onmessage = (event) => {
|
|
69
|
+
// Ignore non-JSON or partial frames; the bridge may interleave event
|
|
70
|
+
// notifications with the response we are awaiting.
|
|
71
|
+
try {
|
|
72
|
+
const data = JSON.parse(String(event.data));
|
|
73
|
+
if (data.id === request_id) {
|
|
74
|
+
if (!resolved) {
|
|
75
|
+
resolved = true;
|
|
76
|
+
clearTimeout(timer);
|
|
77
|
+
ws.close();
|
|
78
|
+
resolve(data);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch { }
|
|
83
|
+
};
|
|
84
|
+
ws.onerror = () => {
|
|
85
|
+
if (!resolved) {
|
|
86
|
+
resolved = true;
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
resolve({
|
|
89
|
+
jsonrpc: "2.0",
|
|
90
|
+
id: request_id,
|
|
91
|
+
error: { code: -32002, message: `WebSocket connection failed to ${url}. Is the Unity Editor running?` },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
ws.onclose = () => {
|
|
96
|
+
if (!resolved) {
|
|
97
|
+
resolved = true;
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
resolve({
|
|
100
|
+
jsonrpc: "2.0",
|
|
101
|
+
id: request_id,
|
|
102
|
+
error: { code: -32003, message: 'WebSocket connection closed before response received' },
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
if (!resolved) {
|
|
109
|
+
resolved = true;
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
resolve({
|
|
112
|
+
jsonrpc: "2.0",
|
|
113
|
+
id: request_id,
|
|
114
|
+
error: { code: -32002, message: `Failed to connect: ${err instanceof Error ? err.message : String(err)}` },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Quick connectivity check: attempts a WebSocket handshake and immediately closes.
|
|
122
|
+
* Returns whether the bridge is reachable within the timeout.
|
|
123
|
+
*/
|
|
124
|
+
async function ping_editor(port, timeout_ms = 2000) {
|
|
125
|
+
const url = `ws://127.0.0.1:${port}/unity-agentic`;
|
|
126
|
+
return new Promise((resolve) => {
|
|
127
|
+
const timer = setTimeout(() => {
|
|
128
|
+
resolve({ reachable: false, error: `Timeout after ${timeout_ms}ms` });
|
|
129
|
+
}, timeout_ms);
|
|
130
|
+
try {
|
|
131
|
+
const ws = new WebSocket(url);
|
|
132
|
+
ws.onopen = () => {
|
|
133
|
+
clearTimeout(timer);
|
|
134
|
+
try {
|
|
135
|
+
ws.close();
|
|
136
|
+
}
|
|
137
|
+
catch { }
|
|
138
|
+
resolve({ reachable: true });
|
|
139
|
+
};
|
|
140
|
+
ws.onerror = (err) => {
|
|
141
|
+
clearTimeout(timer);
|
|
142
|
+
resolve({ reachable: false, error: describe_websocket_error(err, `WebSocket connection failed to ${url}`) });
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
resolve({ reachable: false, error: describe_websocket_error(err, `WebSocket connection failed to ${url}`) });
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function generate_editor_request_id() {
|
|
152
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
|
|
153
|
+
}
|
|
154
|
+
function describe_websocket_error(err, fallback) {
|
|
155
|
+
if (err instanceof Error && err.message.trim().length > 0) {
|
|
156
|
+
return err.message;
|
|
157
|
+
}
|
|
158
|
+
if ((0, util_1.is_record)(err)) {
|
|
159
|
+
if (typeof err.message === 'string' && err.message.trim().length > 0) {
|
|
160
|
+
return err.message;
|
|
161
|
+
}
|
|
162
|
+
if (err.error instanceof Error && err.error.message.trim().length > 0) {
|
|
163
|
+
return err.error.message;
|
|
164
|
+
}
|
|
165
|
+
if (typeof err.type === 'string' && err.type.trim().length > 0) {
|
|
166
|
+
return `${fallback} (${err.type})`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const stringified = String(err);
|
|
170
|
+
if (stringified && stringified !== '[object Event]' && stringified !== '[object ErrorEvent]') {
|
|
171
|
+
return stringified;
|
|
172
|
+
}
|
|
173
|
+
return fallback;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=editor-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-transport.js","sourceRoot":"","sources":["../src/editor-transport.ts"],"names":[],"mappings":";;;AA8BA,wDAoGC;AAMD,kCAyBC;AAED,gEAEC;AArKD,iCAAmC;AAMnC;;;;;GAKG;AACU,QAAA,iCAAiC,GAAG,KAAK,CAAC;AAevD;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAAC,OAAiC;IAC1E,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC3D,MAAM,GAAG,GAAG,kBAAkB,IAAI,gBAAgB,CAAC;IACnD,MAAM,UAAU,GAAG,0BAA0B,EAAE,CAAC;IAEhD,MAAM,WAAW,GAA4B,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3D,IAAI,OAAO,KAAK,yCAAiC;QAAE,WAAW,CAAC,QAAQ,GAAG,OAAO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,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnE,OAAO,GAAG,CAAC,OAAO,CAAC;QACvB,CAAC;QAED,IAAI,GAAG,CAAC,KAAK,YAAY,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpE,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;QAC7B,CAAC;QAED,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7D,OAAO,GAAG,QAAQ,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC;QACvC,CAAC;IACL,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,WAAW,IAAI,WAAW,KAAK,gBAAgB,IAAI,WAAW,KAAK,qBAAqB,EAAE,CAAC;QAC3F,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.d.ts","sourceRoot":"","sources":["../src/gitignore.ts"],"names":[],"mappings":"AAYA,wBAAgB,oCAAoC,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAe/E;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAatE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensure_gitignore_ignores_agentic_dir = ensure_gitignore_ignores_agentic_dir;
|
|
4
|
+
exports.gitignore_ignores_agentic_dir = gitignore_ignores_agentic_dir;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const AGENTIC_DIR = '.unity-agentic';
|
|
8
|
+
const GITIGNORE_ENTRY = `${AGENTIC_DIR}/`;
|
|
9
|
+
const ACCEPTED_AGENTIC_PATTERNS = new Set([
|
|
10
|
+
AGENTIC_DIR,
|
|
11
|
+
GITIGNORE_ENTRY,
|
|
12
|
+
`/${AGENTIC_DIR}`,
|
|
13
|
+
`/${GITIGNORE_ENTRY}`,
|
|
14
|
+
]);
|
|
15
|
+
function ensure_gitignore_ignores_agentic_dir(project_path) {
|
|
16
|
+
const gitignore_path = (0, path_1.join)(project_path, '.gitignore');
|
|
17
|
+
if (!(0, fs_1.existsSync)(gitignore_path)) {
|
|
18
|
+
(0, fs_1.writeFileSync)(gitignore_path, `${GITIGNORE_ENTRY}\n`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const content = (0, fs_1.readFileSync)(gitignore_path, 'utf-8');
|
|
22
|
+
if (gitignore_ignores_agentic_dir(content)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const separator = content.length === 0 || content.endsWith('\n') ? '' : '\n';
|
|
26
|
+
(0, fs_1.writeFileSync)(gitignore_path, `${content}${separator}${GITIGNORE_ENTRY}\n`);
|
|
27
|
+
}
|
|
28
|
+
function gitignore_ignores_agentic_dir(content) {
|
|
29
|
+
for (const raw_line of content.split(/\r?\n/)) {
|
|
30
|
+
const line = raw_line.trim();
|
|
31
|
+
if (line.length === 0 || line.startsWith('#')) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (ACCEPTED_AGENTIC_PATTERNS.has(line)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=gitignore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.js","sourceRoot":"","sources":["../src/gitignore.ts"],"names":[],"mappings":";;AAYA,o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