@ttsc/graph 0.19.0 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,15 @@ const typia_1 = __importDefault(require("typia"));
44
44
  const nativeExecutable_1 = require("../nativeExecutable");
45
45
  const resolveGraphBinary_1 = require("../resolveGraphBinary");
46
46
  const TtscGraphMemory_1 = require("./TtscGraphMemory");
47
+ /**
48
+ * The serve protocol version this client speaks.
49
+ *
50
+ * Keep it equal to `serveProtocolVersion` in
51
+ * `packages/ttsc/cmd/ttscgraph/serve.go`. The two are hand-synchronized, and
52
+ * `serve_protocol_version_matches_the_typescript_client_test.go` reads this
53
+ * constant out of this file and fails if the pair drifts.
54
+ */
55
+ const PROTOCOL_VERSION = 1;
47
56
  /**
48
57
  * Resident bridge to `ttscgraph serve`.
49
58
  *
@@ -108,23 +117,131 @@ class TtscGraphSession {
108
117
  this.failPending(new Error("@ttsc/graph: native session closed"));
109
118
  }
110
119
  async refresh() {
120
+ // The protocol version and the envelope shape were both settled in onLine,
121
+ // before this frame was ever routed here.
111
122
  const response = await this.request();
112
123
  if (response.error !== undefined) {
113
124
  throw new Error(`@ttsc/graph: ${response.error}`);
114
125
  }
115
126
  if (response.changed) {
116
127
  if (response.dump === undefined) {
117
- throw new Error(`@ttsc/graph: native ${response.mode ?? "changed"} response omitted its dump`);
128
+ throw new Error(`@ttsc/graph: native ${response.mode} response omitted its dump`);
118
129
  }
119
- const dump = (() => {
130
+ this.current = TtscGraphMemory_1.TtscGraphMemory.from(response.dump);
131
+ }
132
+ if (this.current === undefined) {
133
+ throw new Error("@ttsc/graph: native session returned no initial graph snapshot");
134
+ }
135
+ return this.current;
136
+ }
137
+ request() {
138
+ const child = this.ensureChild();
139
+ const id = ++this.nextId;
140
+ return new Promise((resolve, reject) => {
141
+ this.pending.set(id, { resolve, reject });
142
+ child.stdin.write(`${JSON.stringify({ id })}\n`, (error) => {
143
+ if (error === null || error === undefined)
144
+ return;
145
+ this.pending.delete(id);
146
+ reject(new Error(`@ttsc/graph: could not request native snapshot: ${error.message}`));
147
+ });
148
+ });
149
+ }
150
+ ensureChild() {
151
+ if (this.closed) {
152
+ // A request queued behind the close must not respawn the native
153
+ // process; an orphaned resident compiler would outlive the MCP server.
154
+ throw new Error("@ttsc/graph: native session is closed");
155
+ }
156
+ if (this.child !== undefined && this.child.exitCode === null) {
157
+ return this.child;
158
+ }
159
+ this.stderr = "";
160
+ const child = (0, node_child_process_1.spawn)(this.binary, ["serve", "--cwd", this.cwd, "--tsconfig", this.tsconfig], { stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
161
+ this.child = child;
162
+ child.stderr.setEncoding("utf8");
163
+ child.stderr.on("data", (chunk) => {
164
+ this.stderr = (this.stderr + chunk).slice(-64 * 1024);
165
+ });
166
+ const lines = node_readline_1.default.createInterface({ input: child.stdout });
167
+ lines.on("line", (line) => this.onLine(line));
168
+ child.on("error", (error) => this.failChild(child, error));
169
+ child.on("exit", (code, signal) => {
170
+ if (this.child !== child)
171
+ return;
172
+ this.child = undefined;
173
+ this.failPending(new Error(`@ttsc/graph: native session exited (code=${String(code)}, signal=${String(signal)})${this.stderr.trim() === "" ? "" : `: ${this.stderr.trim()}`}`));
174
+ });
175
+ return child;
176
+ }
177
+ onLine(line) {
178
+ let parsed;
179
+ try {
180
+ parsed = JSON.parse(line);
181
+ }
182
+ catch (error) {
183
+ this.failPending(new Error(`@ttsc/graph: native session returned invalid JSON: ${asError(error).message}`));
184
+ return;
185
+ }
186
+ // Read the version before the shape, because a server speaking another
187
+ // version is entitled to a different shape. Asserting first would report
188
+ // that mismatch as a field complaint — "expected string at $input.mode" —
189
+ // about a contract the other side never agreed to, which is the misparse
190
+ // this field exists to prevent. Ask what protocol it is first, then hold it
191
+ // to that protocol.
192
+ const version = (() => {
193
+ const _io0 = input => "number" === typeof input.protocolVersion;
194
+ return input => "object" === typeof input && null !== input && _io0(input);
195
+ })()(parsed) ? parsed.protocolVersion
196
+ : undefined;
197
+ if (version !== PROTOCOL_VERSION) {
198
+ // Session-wide: a version mismatch is not one bad frame, it is the wrong
199
+ // binary, and every request against it is equally doomed.
200
+ this.failPending(new Error(`@ttsc/graph: ttscgraph speaks serve protocol ${version === undefined ? "an unknown version" : `v${String(version)}`}, this client speaks v${String(PROTOCOL_VERSION)}. ` +
201
+ "Install a matching `ttsc` (the binary resolves from the target " +
202
+ "project, or from TTSC_GRAPH_BINARY)."));
203
+ return;
204
+ }
205
+ let response;
206
+ try {
207
+ // Validate the envelope, not just the dump it carries. The dump was
208
+ // typia-asserted while the envelope around it was a bare cast, so the
209
+ // fields the client actually branches on — the mode, and the id that
210
+ // routes the frame — were the unchecked ones. Anything added to the
211
+ // envelope belongs on this side of that line.
212
+ response = (() => {
213
+ const _ip0 = input => Array.isArray(input["capabilities"]) && input["capabilities"].every(elem => "string" === typeof elem);
214
+ const _ip1 = input => "string" === typeof input["file"];
120
215
  const _iv0 = new Set(["class", "enum", "external_symbol", "file", "function", "interface", "method", "module", "namespace", "package", "parameter", "property", "type", "variable"]);
121
- const _ip0 = input => "string" === typeof input["name"];
216
+ const _ip2 = input => "string" === typeof input["name"];
122
217
  const _iv1 = new Set(["abstract", "async", "const", "declare", "default", "export", "optional", "private", "protected", "public", "readonly", "static"]);
123
- const _ip1 = input => undefined === input["evidence"] || "object" === typeof input["evidence"] && null !== input["evidence"] && _io4(input["evidence"]);
218
+ const _ip3 = input => undefined === input["evidence"] || "object" === typeof input["evidence"] && null !== input["evidence"] && _io12(input["evidence"]);
124
219
  const _iv2 = new Set(["accesses", "calls", "contains", "decorates", "dispatches", "exports", "extends", "implements", "imports", "instantiates", "overrides", "renders", "tests", "type_ref"]);
220
+ const _ap0 = (input, _path, _exceptionable = true) => (Array.isArray(input["capabilities"]) || _assertGuard_1._assertGuard(_exceptionable, {
221
+ method: "typia.assert",
222
+ path: _path + ".capabilities",
223
+ expected: "Array<string>",
224
+ value: input["capabilities"]
225
+ }, _errorFactory)) && input["capabilities"].every((elem, _index11) => "string" === typeof elem || _assertGuard_1._assertGuard(_exceptionable, {
226
+ method: "typia.assert",
227
+ path: _path + ".capabilities[" + _index11 + "]",
228
+ expected: "string",
229
+ value: elem
230
+ }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
231
+ method: "typia.assert",
232
+ path: _path + ".capabilities",
233
+ expected: "Array<string>",
234
+ value: input["capabilities"]
235
+ }, _errorFactory);
236
+ const _ap1 = (input, _path, _exceptionable = true) => "string" === typeof input["file"] || _assertGuard_1._assertGuard(_exceptionable, {
237
+ method: "typia.assert",
238
+ path: _path + ".file",
239
+ expected: "string",
240
+ value: input["file"]
241
+ }, _errorFactory);
125
242
  const _av0 = new Set(["class", "enum", "external_symbol", "file", "function", "interface", "method", "module", "namespace", "package", "parameter", "property", "type", "variable"]);
126
243
  const _ae0 = "(\"class\" | \"enum\" | \"external_symbol\" | \"file\" | \"function\" | \"interface\" | \"method\" | \"module\" | \"namespace\" | \"package\" | \"parameter\" | \"property\" | \"type\" | \"variable\")";
127
- const _ap0 = (input, _path, _exceptionable = true) => "string" === typeof input["name"] || _assertGuard_1._assertGuard(_exceptionable, {
244
+ const _ap2 = (input, _path, _exceptionable = true) => "string" === typeof input["name"] || _assertGuard_1._assertGuard(_exceptionable, {
128
245
  method: "typia.assert",
129
246
  path: _path + ".name",
130
247
  expected: "string",
@@ -132,12 +249,12 @@ class TtscGraphSession {
132
249
  }, _errorFactory);
133
250
  const _av1 = new Set(["abstract", "async", "const", "declare", "default", "export", "optional", "private", "protected", "public", "readonly", "static"]);
134
251
  const _ae1 = "(\"abstract\" | \"async\" | \"const\" | \"declare\" | \"default\" | \"export\" | \"optional\" | \"private\" | \"protected\" | \"public\" | \"readonly\" | \"static\")";
135
- const _ap1 = (input, _path, _exceptionable = true) => undefined === input["evidence"] || ("object" === typeof input["evidence"] && null !== input["evidence"] || _assertGuard_1._assertGuard(_exceptionable, {
252
+ const _ap3 = (input, _path, _exceptionable = true) => undefined === input["evidence"] || ("object" === typeof input["evidence"] && null !== input["evidence"] || _assertGuard_1._assertGuard(_exceptionable, {
136
253
  method: "typia.assert",
137
254
  path: _path + ".evidence",
138
255
  expected: "(ITtscGraphSpan | undefined)",
139
256
  value: input["evidence"]
140
- }, _errorFactory)) && _ao4(input["evidence"], _path + ".evidence", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
257
+ }, _errorFactory)) && _ao12(input["evidence"], _path + ".evidence", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
141
258
  method: "typia.assert",
142
259
  path: _path + ".evidence",
143
260
  expected: "(ITtscGraphSpan | undefined)",
@@ -145,7 +262,43 @@ class TtscGraphSession {
145
262
  }, _errorFactory);
146
263
  const _av2 = new Set(["accesses", "calls", "contains", "decorates", "dispatches", "exports", "extends", "implements", "imports", "instantiates", "overrides", "renders", "tests", "type_ref"]);
147
264
  const _ae2 = "(\"accesses\" | \"calls\" | \"contains\" | \"decorates\" | \"dispatches\" | \"exports\" | \"extends\" | \"implements\" | \"imports\" | \"instantiates\" | \"overrides\" | \"renders\" | \"tests\" | \"type_ref\")";
148
- const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.project || _assertGuard_1._assertGuard(_exceptionable, {
265
+ const _ao0 = (input, _path, _exceptionable = true) => ("number" === typeof input.id || _assertGuard_1._assertGuard(_exceptionable, {
266
+ method: "typia.assert",
267
+ path: _path + ".id",
268
+ expected: "number",
269
+ value: input.id
270
+ }, _errorFactory)) && ("number" === typeof input.protocolVersion || _assertGuard_1._assertGuard(_exceptionable, {
271
+ method: "typia.assert",
272
+ path: _path + ".protocolVersion",
273
+ expected: "number",
274
+ value: input.protocolVersion
275
+ }, _errorFactory)) && ("error" === input.mode || "incremental" === input.mode || "initial" === input.mode || "rebuild" === input.mode || "reload" === input.mode || "unchanged" === input.mode || _assertGuard_1._assertGuard(_exceptionable, {
276
+ method: "typia.assert",
277
+ path: _path + ".mode",
278
+ expected: "(\"error\" | \"incremental\" | \"initial\" | \"rebuild\" | \"reload\" | \"unchanged\")",
279
+ value: input.mode
280
+ }, _errorFactory)) && _ap0(input, _path, true && _exceptionable) && ("boolean" === typeof input.changed || _assertGuard_1._assertGuard(_exceptionable, {
281
+ method: "typia.assert",
282
+ path: _path + ".changed",
283
+ expected: "boolean",
284
+ value: input.changed
285
+ }, _errorFactory)) && (undefined === input.dump || ("object" === typeof input.dump && null !== input.dump || _assertGuard_1._assertGuard(_exceptionable, {
286
+ method: "typia.assert",
287
+ path: _path + ".dump",
288
+ expected: "(ITtscGraphDump | undefined)",
289
+ value: input.dump
290
+ }, _errorFactory)) && _ao1(input.dump, _path + ".dump", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
291
+ method: "typia.assert",
292
+ path: _path + ".dump",
293
+ expected: "(ITtscGraphDump | undefined)",
294
+ value: input.dump
295
+ }, _errorFactory)) && (undefined === input.error || "string" === typeof input.error || _assertGuard_1._assertGuard(_exceptionable, {
296
+ method: "typia.assert",
297
+ path: _path + ".error",
298
+ expected: "(string | undefined)",
299
+ value: input.error
300
+ }, _errorFactory));
301
+ const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.project || _assertGuard_1._assertGuard(_exceptionable, {
149
302
  method: "typia.assert",
150
303
  path: _path + ".project",
151
304
  expected: "string",
@@ -155,19 +308,49 @@ class TtscGraphSession {
155
308
  path: _path + ".tsconfig",
156
309
  expected: "string",
157
310
  value: input.tsconfig
311
+ }, _errorFactory)) && (("object" === typeof input.provenance && null !== input.provenance || _assertGuard_1._assertGuard(_exceptionable, {
312
+ method: "typia.assert",
313
+ path: _path + ".provenance",
314
+ expected: "ITtscGraphDump.IProvenance",
315
+ value: input.provenance
316
+ }, _errorFactory)) && _ao2(input.provenance, _path + ".provenance", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
317
+ method: "typia.assert",
318
+ path: _path + ".provenance",
319
+ expected: "ITtscGraphDump.IProvenance",
320
+ value: input.provenance
321
+ }, _errorFactory)) && ((Array.isArray(input.diagnostics) || _assertGuard_1._assertGuard(_exceptionable, {
322
+ method: "typia.assert",
323
+ path: _path + ".diagnostics",
324
+ expected: "Array<ITtscGraphDump.IDiagnostic>",
325
+ value: input.diagnostics
326
+ }, _errorFactory)) && input.diagnostics.every((elem, _index12) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
327
+ method: "typia.assert",
328
+ path: _path + ".diagnostics[" + _index12 + "]",
329
+ expected: "ITtscGraphDump.IDiagnostic",
330
+ value: elem
331
+ }, _errorFactory)) && _ao8(elem, _path + ".diagnostics[" + _index12 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
332
+ method: "typia.assert",
333
+ path: _path + ".diagnostics[" + _index12 + "]",
334
+ expected: "ITtscGraphDump.IDiagnostic",
335
+ value: elem
336
+ }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
337
+ method: "typia.assert",
338
+ path: _path + ".diagnostics",
339
+ expected: "Array<ITtscGraphDump.IDiagnostic>",
340
+ value: input.diagnostics
158
341
  }, _errorFactory)) && ((Array.isArray(input.nodes) || _assertGuard_1._assertGuard(_exceptionable, {
159
342
  method: "typia.assert",
160
343
  path: _path + ".nodes",
161
344
  expected: "Array<ITtscGraphDump.INode>",
162
345
  value: input.nodes
163
- }, _errorFactory)) && input.nodes.every((elem, _index6) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
346
+ }, _errorFactory)) && input.nodes.every((elem, _index13) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
164
347
  method: "typia.assert",
165
- path: _path + ".nodes[" + _index6 + "]",
348
+ path: _path + ".nodes[" + _index13 + "]",
166
349
  expected: "ITtscGraphDump.INode",
167
350
  value: elem
168
- }, _errorFactory)) && _ao1(elem, _path + ".nodes[" + _index6 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
351
+ }, _errorFactory)) && _ao9(elem, _path + ".nodes[" + _index13 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
169
352
  method: "typia.assert",
170
- path: _path + ".nodes[" + _index6 + "]",
353
+ path: _path + ".nodes[" + _index13 + "]",
171
354
  expected: "ITtscGraphDump.INode",
172
355
  value: elem
173
356
  }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
@@ -180,14 +363,14 @@ class TtscGraphSession {
180
363
  path: _path + ".edges",
181
364
  expected: "Array<ITtscGraphDump.IEdge>",
182
365
  value: input.edges
183
- }, _errorFactory)) && input.edges.every((elem, _index7) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
366
+ }, _errorFactory)) && input.edges.every((elem, _index14) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
184
367
  method: "typia.assert",
185
- path: _path + ".edges[" + _index7 + "]",
368
+ path: _path + ".edges[" + _index14 + "]",
186
369
  expected: "ITtscGraphDump.IEdge",
187
370
  value: elem
188
- }, _errorFactory)) && _ao5(elem, _path + ".edges[" + _index7 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
371
+ }, _errorFactory)) && _ao13(elem, _path + ".edges[" + _index14 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
189
372
  method: "typia.assert",
190
- path: _path + ".edges[" + _index7 + "]",
373
+ path: _path + ".edges[" + _index14 + "]",
191
374
  expected: "ITtscGraphDump.IEdge",
192
375
  value: elem
193
376
  }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
@@ -196,7 +379,228 @@ class TtscGraphSession {
196
379
  expected: "Array<ITtscGraphDump.IEdge>",
197
380
  value: input.edges
198
381
  }, _errorFactory));
199
- const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.id || _assertGuard_1._assertGuard(_exceptionable, {
382
+ const _ao10 = (input, _path, _exceptionable = true) => _ap2(input, _path, true && _exceptionable) && ((Array.isArray(input.arguments) || _assertGuard_1._assertGuard(_exceptionable, {
383
+ method: "typia.assert",
384
+ path: _path + ".arguments",
385
+ expected: "Array<ITtscGraphDecorator.IArgument>",
386
+ value: input.arguments
387
+ }, _errorFactory)) && input.arguments.every((elem, _index20) => ("object" === typeof elem && null !== elem && false === Array.isArray(elem) || _assertGuard_1._assertGuard(_exceptionable, {
388
+ method: "typia.assert",
389
+ path: _path + ".arguments[" + _index20 + "]",
390
+ expected: "ITtscGraphDecorator.IArgument",
391
+ value: elem
392
+ }, _errorFactory)) && _ao11(elem, _path + ".arguments[" + _index20 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
393
+ method: "typia.assert",
394
+ path: _path + ".arguments[" + _index20 + "]",
395
+ expected: "ITtscGraphDecorator.IArgument",
396
+ value: elem
397
+ }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
398
+ method: "typia.assert",
399
+ path: _path + ".arguments",
400
+ expected: "Array<ITtscGraphDecorator.IArgument>",
401
+ value: input.arguments
402
+ }, _errorFactory));
403
+ const _ao11 = (input, _path, _exceptionable = true) => undefined === input.literal || "string" === typeof input.literal || "number" === typeof input.literal || "boolean" === typeof input.literal || _assertGuard_1._assertGuard(_exceptionable, {
404
+ method: "typia.assert",
405
+ path: _path + ".literal",
406
+ expected: "(boolean | number | string | undefined)",
407
+ value: input.literal
408
+ }, _errorFactory);
409
+ const _ao12 = (input, _path, _exceptionable = true) => (undefined === input.file || "string" === typeof input.file || _assertGuard_1._assertGuard(_exceptionable, {
410
+ method: "typia.assert",
411
+ path: _path + ".file",
412
+ expected: "(string | undefined)",
413
+ value: input.file
414
+ }, _errorFactory)) && ("number" === typeof input.startLine || _assertGuard_1._assertGuard(_exceptionable, {
415
+ method: "typia.assert",
416
+ path: _path + ".startLine",
417
+ expected: "number",
418
+ value: input.startLine
419
+ }, _errorFactory)) && (undefined === input.startCol || "number" === typeof input.startCol || _assertGuard_1._assertGuard(_exceptionable, {
420
+ method: "typia.assert",
421
+ path: _path + ".startCol",
422
+ expected: "(number | undefined)",
423
+ value: input.startCol
424
+ }, _errorFactory)) && (undefined === input.endLine || "number" === typeof input.endLine || _assertGuard_1._assertGuard(_exceptionable, {
425
+ method: "typia.assert",
426
+ path: _path + ".endLine",
427
+ expected: "(number | undefined)",
428
+ value: input.endLine
429
+ }, _errorFactory)) && (undefined === input.endCol || "number" === typeof input.endCol || _assertGuard_1._assertGuard(_exceptionable, {
430
+ method: "typia.assert",
431
+ path: _path + ".endCol",
432
+ expected: "(number | undefined)",
433
+ value: input.endCol
434
+ }, _errorFactory));
435
+ const _ao13 = (input, _path, _exceptionable = true) => ("string" === typeof input.from || _assertGuard_1._assertGuard(_exceptionable, {
436
+ method: "typia.assert",
437
+ path: _path + ".from",
438
+ expected: "string",
439
+ value: input.from
440
+ }, _errorFactory)) && ("string" === typeof input.to || _assertGuard_1._assertGuard(_exceptionable, {
441
+ method: "typia.assert",
442
+ path: _path + ".to",
443
+ expected: "string",
444
+ value: input.to
445
+ }, _errorFactory)) && (true === _av2.has(input.kind) || _assertGuard_1._assertGuard(_exceptionable, {
446
+ method: "typia.assert",
447
+ path: _path + ".kind",
448
+ expected: _ae2,
449
+ value: input.kind
450
+ }, _errorFactory)) && _ap3(input, _path, true && _exceptionable);
451
+ const _ao2 = (input, _path, _exceptionable = true) => ("number" === typeof input.schemaVersion || _assertGuard_1._assertGuard(_exceptionable, {
452
+ method: "typia.assert",
453
+ path: _path + ".schemaVersion",
454
+ expected: "number",
455
+ value: input.schemaVersion
456
+ }, _errorFactory)) && _ap0(input, _path, true && _exceptionable) && (("object" === typeof input.producer && null !== input.producer || _assertGuard_1._assertGuard(_exceptionable, {
457
+ method: "typia.assert",
458
+ path: _path + ".producer",
459
+ expected: "ITtscGraphDump.IProducer",
460
+ value: input.producer
461
+ }, _errorFactory)) && _ao3(input.producer, _path + ".producer", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
462
+ method: "typia.assert",
463
+ path: _path + ".producer",
464
+ expected: "ITtscGraphDump.IProducer",
465
+ value: input.producer
466
+ }, _errorFactory)) && (("object" === typeof input.universe && null !== input.universe || _assertGuard_1._assertGuard(_exceptionable, {
467
+ method: "typia.assert",
468
+ path: _path + ".universe",
469
+ expected: "ITtscGraphDump.IUniverse",
470
+ value: input.universe
471
+ }, _errorFactory)) && _ao4(input.universe, _path + ".universe", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
472
+ method: "typia.assert",
473
+ path: _path + ".universe",
474
+ expected: "ITtscGraphDump.IUniverse",
475
+ value: input.universe
476
+ }, _errorFactory)) && ((Array.isArray(input.sources) || _assertGuard_1._assertGuard(_exceptionable, {
477
+ method: "typia.assert",
478
+ path: _path + ".sources",
479
+ expected: "Array<ITtscGraphDump.ISourceDigest>",
480
+ value: input.sources
481
+ }, _errorFactory)) && input.sources.every((elem, _index15) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
482
+ method: "typia.assert",
483
+ path: _path + ".sources[" + _index15 + "]",
484
+ expected: "ITtscGraphDump.ISourceDigest",
485
+ value: elem
486
+ }, _errorFactory)) && _ao7(elem, _path + ".sources[" + _index15 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
487
+ method: "typia.assert",
488
+ path: _path + ".sources[" + _index15 + "]",
489
+ expected: "ITtscGraphDump.ISourceDigest",
490
+ value: elem
491
+ }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
492
+ method: "typia.assert",
493
+ path: _path + ".sources",
494
+ expected: "Array<ITtscGraphDump.ISourceDigest>",
495
+ value: input.sources
496
+ }, _errorFactory));
497
+ const _ao3 = (input, _path, _exceptionable = true) => ("string" === typeof input.tool || _assertGuard_1._assertGuard(_exceptionable, {
498
+ method: "typia.assert",
499
+ path: _path + ".tool",
500
+ expected: "string",
501
+ value: input.tool
502
+ }, _errorFactory)) && ("string" === typeof input.version || _assertGuard_1._assertGuard(_exceptionable, {
503
+ method: "typia.assert",
504
+ path: _path + ".version",
505
+ expected: "string",
506
+ value: input.version
507
+ }, _errorFactory)) && ("string" === typeof input.typescript || _assertGuard_1._assertGuard(_exceptionable, {
508
+ method: "typia.assert",
509
+ path: _path + ".typescript",
510
+ expected: "string",
511
+ value: input.typescript
512
+ }, _errorFactory));
513
+ const _ao4 = (input, _path, _exceptionable = true) => ((Array.isArray(input.configs) || _assertGuard_1._assertGuard(_exceptionable, {
514
+ method: "typia.assert",
515
+ path: _path + ".configs",
516
+ expected: "Array<ITtscGraphDump.IFileDigest>",
517
+ value: input.configs
518
+ }, _errorFactory)) && input.configs.every((elem, _index16) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
519
+ method: "typia.assert",
520
+ path: _path + ".configs[" + _index16 + "]",
521
+ expected: "ITtscGraphDump.IFileDigest",
522
+ value: elem
523
+ }, _errorFactory)) && _ao5(elem, _path + ".configs[" + _index16 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
524
+ method: "typia.assert",
525
+ path: _path + ".configs[" + _index16 + "]",
526
+ expected: "ITtscGraphDump.IFileDigest",
527
+ value: elem
528
+ }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
529
+ method: "typia.assert",
530
+ path: _path + ".configs",
531
+ expected: "Array<ITtscGraphDump.IFileDigest>",
532
+ value: input.configs
533
+ }, _errorFactory)) && ((Array.isArray(input.roots) || _assertGuard_1._assertGuard(_exceptionable, {
534
+ method: "typia.assert",
535
+ path: _path + ".roots",
536
+ expected: "Array<ITtscGraphDump.IRootFile>",
537
+ value: input.roots
538
+ }, _errorFactory)) && input.roots.every((elem, _index17) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
539
+ method: "typia.assert",
540
+ path: _path + ".roots[" + _index17 + "]",
541
+ expected: "ITtscGraphDump.IRootFile",
542
+ value: elem
543
+ }, _errorFactory)) && _ao6(elem, _path + ".roots[" + _index17 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
544
+ method: "typia.assert",
545
+ path: _path + ".roots[" + _index17 + "]",
546
+ expected: "ITtscGraphDump.IRootFile",
547
+ value: elem
548
+ }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
549
+ method: "typia.assert",
550
+ path: _path + ".roots",
551
+ expected: "Array<ITtscGraphDump.IRootFile>",
552
+ value: input.roots
553
+ }, _errorFactory));
554
+ const _ao5 = (input, _path, _exceptionable = true) => _ap1(input, _path, true && _exceptionable) && ("string" === typeof input.digest || _assertGuard_1._assertGuard(_exceptionable, {
555
+ method: "typia.assert",
556
+ path: _path + ".digest",
557
+ expected: "string",
558
+ value: input.digest
559
+ }, _errorFactory));
560
+ const _ao6 = (input, _path, _exceptionable = true) => ("string" === typeof input.config || _assertGuard_1._assertGuard(_exceptionable, {
561
+ method: "typia.assert",
562
+ path: _path + ".config",
563
+ expected: "string",
564
+ value: input.config
565
+ }, _errorFactory)) && _ap1(input, _path, true && _exceptionable);
566
+ const _ao7 = (input, _path, _exceptionable = true) => _ap1(input, _path, true && _exceptionable) && ("string" === typeof input.checkerDigest || _assertGuard_1._assertGuard(_exceptionable, {
567
+ method: "typia.assert",
568
+ path: _path + ".checkerDigest",
569
+ expected: "string",
570
+ value: input.checkerDigest
571
+ }, _errorFactory)) && ("string" === typeof input.diskDigest || _assertGuard_1._assertGuard(_exceptionable, {
572
+ method: "typia.assert",
573
+ path: _path + ".diskDigest",
574
+ expected: "string",
575
+ value: input.diskDigest
576
+ }, _errorFactory));
577
+ const _ao8 = (input, _path, _exceptionable = true) => _ap1(input, _path, true && _exceptionable) && ("number" === typeof input.line || _assertGuard_1._assertGuard(_exceptionable, {
578
+ method: "typia.assert",
579
+ path: _path + ".line",
580
+ expected: "number",
581
+ value: input.line
582
+ }, _errorFactory)) && ("number" === typeof input.column || _assertGuard_1._assertGuard(_exceptionable, {
583
+ method: "typia.assert",
584
+ path: _path + ".column",
585
+ expected: "number",
586
+ value: input.column
587
+ }, _errorFactory)) && ("number" === typeof input.code || _assertGuard_1._assertGuard(_exceptionable, {
588
+ method: "typia.assert",
589
+ path: _path + ".code",
590
+ expected: "number",
591
+ value: input.code
592
+ }, _errorFactory)) && ("error" === input.category || "warning" === input.category || _assertGuard_1._assertGuard(_exceptionable, {
593
+ method: "typia.assert",
594
+ path: _path + ".category",
595
+ expected: "(\"error\" | \"warning\")",
596
+ value: input.category
597
+ }, _errorFactory)) && ("string" === typeof input.message || _assertGuard_1._assertGuard(_exceptionable, {
598
+ method: "typia.assert",
599
+ path: _path + ".message",
600
+ expected: "string",
601
+ value: input.message
602
+ }, _errorFactory));
603
+ const _ao9 = (input, _path, _exceptionable = true) => ("string" === typeof input.id || _assertGuard_1._assertGuard(_exceptionable, {
200
604
  method: "typia.assert",
201
605
  path: _path + ".id",
202
606
  expected: "string",
@@ -206,17 +610,12 @@ class TtscGraphSession {
206
610
  path: _path + ".kind",
207
611
  expected: _ae0,
208
612
  value: input.kind
209
- }, _errorFactory)) && _ap0(input, _path, true && _exceptionable) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName || _assertGuard_1._assertGuard(_exceptionable, {
613
+ }, _errorFactory)) && _ap2(input, _path, true && _exceptionable) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName || _assertGuard_1._assertGuard(_exceptionable, {
210
614
  method: "typia.assert",
211
615
  path: _path + ".qualifiedName",
212
616
  expected: "(string | undefined)",
213
617
  value: input.qualifiedName
214
- }, _errorFactory)) && ("string" === typeof input.file || _assertGuard_1._assertGuard(_exceptionable, {
215
- method: "typia.assert",
216
- path: _path + ".file",
217
- expected: "string",
218
- value: input.file
219
- }, _errorFactory)) && ("boolean" === typeof input.external || _assertGuard_1._assertGuard(_exceptionable, {
618
+ }, _errorFactory)) && _ap1(input, _path, true && _exceptionable) && ("boolean" === typeof input.external || _assertGuard_1._assertGuard(_exceptionable, {
220
619
  method: "typia.assert",
221
620
  path: _path + ".external",
222
621
  expected: "boolean",
@@ -241,9 +640,9 @@ class TtscGraphSession {
241
640
  path: _path + ".modifiers",
242
641
  expected: "(Array<TtscGraphNodeModifier> | undefined)",
243
642
  value: input.modifiers
244
- }, _errorFactory)) && input.modifiers.every((elem, _index8) => true === _av1.has(elem) || _assertGuard_1._assertGuard(_exceptionable, {
643
+ }, _errorFactory)) && input.modifiers.every((elem, _index18) => true === _av1.has(elem) || _assertGuard_1._assertGuard(_exceptionable, {
245
644
  method: "typia.assert",
246
- path: _path + ".modifiers[" + _index8 + "]",
645
+ path: _path + ".modifiers[" + _index18 + "]",
247
646
  expected: _ae1,
248
647
  value: elem
249
648
  }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
@@ -256,14 +655,14 @@ class TtscGraphSession {
256
655
  path: _path + ".decorators",
257
656
  expected: "(Array<ITtscGraphDecorator> | undefined)",
258
657
  value: input.decorators
259
- }, _errorFactory)) && input.decorators.every((elem, _index9) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
658
+ }, _errorFactory)) && input.decorators.every((elem, _index19) => ("object" === typeof elem && null !== elem || _assertGuard_1._assertGuard(_exceptionable, {
260
659
  method: "typia.assert",
261
- path: _path + ".decorators[" + _index9 + "]",
660
+ path: _path + ".decorators[" + _index19 + "]",
262
661
  expected: "ITtscGraphDecorator",
263
662
  value: elem
264
- }, _errorFactory)) && _ao2(elem, _path + ".decorators[" + _index9 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
663
+ }, _errorFactory)) && _ao10(elem, _path + ".decorators[" + _index19 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
265
664
  method: "typia.assert",
266
- path: _path + ".decorators[" + _index9 + "]",
665
+ path: _path + ".decorators[" + _index19 + "]",
267
666
  expected: "ITtscGraphDecorator",
268
667
  value: elem
269
668
  }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
@@ -271,92 +670,31 @@ class TtscGraphSession {
271
670
  path: _path + ".decorators",
272
671
  expected: "(Array<ITtscGraphDecorator> | undefined)",
273
672
  value: input.decorators
274
- }, _errorFactory)) && _ap1(input, _path, true && _exceptionable) && (undefined === input.implementation || ("object" === typeof input.implementation && null !== input.implementation || _assertGuard_1._assertGuard(_exceptionable, {
673
+ }, _errorFactory)) && _ap3(input, _path, true && _exceptionable) && (undefined === input.implementation || ("object" === typeof input.implementation && null !== input.implementation || _assertGuard_1._assertGuard(_exceptionable, {
275
674
  method: "typia.assert",
276
675
  path: _path + ".implementation",
277
676
  expected: "(ITtscGraphSpan | undefined)",
278
677
  value: input.implementation
279
- }, _errorFactory)) && _ao4(input.implementation, _path + ".implementation", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
678
+ }, _errorFactory)) && _ao12(input.implementation, _path + ".implementation", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
280
679
  method: "typia.assert",
281
680
  path: _path + ".implementation",
282
681
  expected: "(ITtscGraphSpan | undefined)",
283
682
  value: input.implementation
284
683
  }, _errorFactory));
285
- const _ao2 = (input, _path, _exceptionable = true) => _ap0(input, _path, true && _exceptionable) && ((Array.isArray(input.arguments) || _assertGuard_1._assertGuard(_exceptionable, {
286
- method: "typia.assert",
287
- path: _path + ".arguments",
288
- expected: "Array<ITtscGraphDecorator.IArgument>",
289
- value: input.arguments
290
- }, _errorFactory)) && input.arguments.every((elem, _index10) => ("object" === typeof elem && null !== elem && false === Array.isArray(elem) || _assertGuard_1._assertGuard(_exceptionable, {
291
- method: "typia.assert",
292
- path: _path + ".arguments[" + _index10 + "]",
293
- expected: "ITtscGraphDecorator.IArgument",
294
- value: elem
295
- }, _errorFactory)) && _ao3(elem, _path + ".arguments[" + _index10 + "]", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
296
- method: "typia.assert",
297
- path: _path + ".arguments[" + _index10 + "]",
298
- expected: "ITtscGraphDecorator.IArgument",
299
- value: elem
300
- }, _errorFactory)) || _assertGuard_1._assertGuard(_exceptionable, {
301
- method: "typia.assert",
302
- path: _path + ".arguments",
303
- expected: "Array<ITtscGraphDecorator.IArgument>",
304
- value: input.arguments
305
- }, _errorFactory));
306
- const _ao3 = (input, _path, _exceptionable = true) => undefined === input.literal || "string" === typeof input.literal || "number" === typeof input.literal || "boolean" === typeof input.literal || _assertGuard_1._assertGuard(_exceptionable, {
307
- method: "typia.assert",
308
- path: _path + ".literal",
309
- expected: "(boolean | number | string | undefined)",
310
- value: input.literal
311
- }, _errorFactory);
312
- const _ao4 = (input, _path, _exceptionable = true) => (undefined === input.file || "string" === typeof input.file || _assertGuard_1._assertGuard(_exceptionable, {
313
- method: "typia.assert",
314
- path: _path + ".file",
315
- expected: "(string | undefined)",
316
- value: input.file
317
- }, _errorFactory)) && ("number" === typeof input.startLine || _assertGuard_1._assertGuard(_exceptionable, {
318
- method: "typia.assert",
319
- path: _path + ".startLine",
320
- expected: "number",
321
- value: input.startLine
322
- }, _errorFactory)) && (undefined === input.startCol || "number" === typeof input.startCol || _assertGuard_1._assertGuard(_exceptionable, {
323
- method: "typia.assert",
324
- path: _path + ".startCol",
325
- expected: "(number | undefined)",
326
- value: input.startCol
327
- }, _errorFactory)) && (undefined === input.endLine || "number" === typeof input.endLine || _assertGuard_1._assertGuard(_exceptionable, {
328
- method: "typia.assert",
329
- path: _path + ".endLine",
330
- expected: "(number | undefined)",
331
- value: input.endLine
332
- }, _errorFactory)) && (undefined === input.endCol || "number" === typeof input.endCol || _assertGuard_1._assertGuard(_exceptionable, {
333
- method: "typia.assert",
334
- path: _path + ".endCol",
335
- expected: "(number | undefined)",
336
- value: input.endCol
337
- }, _errorFactory));
338
- const _ao5 = (input, _path, _exceptionable = true) => ("string" === typeof input.from || _assertGuard_1._assertGuard(_exceptionable, {
339
- method: "typia.assert",
340
- path: _path + ".from",
341
- expected: "string",
342
- value: input.from
343
- }, _errorFactory)) && ("string" === typeof input.to || _assertGuard_1._assertGuard(_exceptionable, {
344
- method: "typia.assert",
345
- path: _path + ".to",
346
- expected: "string",
347
- value: input.to
348
- }, _errorFactory)) && (true === _av2.has(input.kind) || _assertGuard_1._assertGuard(_exceptionable, {
349
- method: "typia.assert",
350
- path: _path + ".kind",
351
- expected: _ae2,
352
- value: input.kind
353
- }, _errorFactory)) && _ap1(input, _path, true && _exceptionable);
354
- const _io0 = input => "string" === typeof input.project && "string" === typeof input.tsconfig && (Array.isArray(input.nodes) && input.nodes.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && (Array.isArray(input.edges) && input.edges.every(elem => "object" === typeof elem && null !== elem && _io5(elem)));
355
- const _io1 = input => "string" === typeof input.id && true === _iv0.has(input.kind) && _ip0(input) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName) && "string" === typeof input.file && "boolean" === typeof input.external && (undefined === input.ignored || "boolean" === typeof input.ignored) && (undefined === input.exported || "boolean" === typeof input.exported) && (undefined === input.closure || "boolean" === typeof input.closure) && (undefined === input.modifiers || Array.isArray(input.modifiers) && input.modifiers.every(elem => true === _iv1.has(elem))) && (undefined === input.decorators || Array.isArray(input.decorators) && input.decorators.every(elem => "object" === typeof elem && null !== elem && _io2(elem))) && _ip1(input) && (undefined === input.implementation || "object" === typeof input.implementation && null !== input.implementation && _io4(input.implementation));
356
- const _io2 = input => _ip0(input) && (Array.isArray(input.arguments) && input.arguments.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io3(elem)));
357
- const _io3 = input => undefined === input.literal || "string" === typeof input.literal || "number" === typeof input.literal || "boolean" === typeof input.literal;
358
- const _io4 = input => (undefined === input.file || "string" === typeof input.file) && "number" === typeof input.startLine && (undefined === input.startCol || "number" === typeof input.startCol) && (undefined === input.endLine || "number" === typeof input.endLine) && (undefined === input.endCol || "number" === typeof input.endCol);
359
- const _io5 = input => "string" === typeof input.from && "string" === typeof input.to && true === _iv2.has(input.kind) && _ip1(input);
684
+ const _io0 = input => "number" === typeof input.id && "number" === typeof input.protocolVersion && ("error" === input.mode || "incremental" === input.mode || "initial" === input.mode || "rebuild" === input.mode || "reload" === input.mode || "unchanged" === input.mode) && _ip0(input) && "boolean" === typeof input.changed && (undefined === input.dump || "object" === typeof input.dump && null !== input.dump && _io1(input.dump)) && (undefined === input.error || "string" === typeof input.error);
685
+ const _io1 = input => "string" === typeof input.project && "string" === typeof input.tsconfig && ("object" === typeof input.provenance && null !== input.provenance && _io2(input.provenance)) && (Array.isArray(input.diagnostics) && input.diagnostics.every(elem => "object" === typeof elem && null !== elem && _io8(elem))) && (Array.isArray(input.nodes) && input.nodes.every(elem => "object" === typeof elem && null !== elem && _io9(elem))) && (Array.isArray(input.edges) && input.edges.every(elem => "object" === typeof elem && null !== elem && _io13(elem)));
686
+ const _io10 = input => _ip2(input) && (Array.isArray(input.arguments) && input.arguments.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io11(elem)));
687
+ const _io11 = input => undefined === input.literal || "string" === typeof input.literal || "number" === typeof input.literal || "boolean" === typeof input.literal;
688
+ const _io12 = input => (undefined === input.file || "string" === typeof input.file) && "number" === typeof input.startLine && (undefined === input.startCol || "number" === typeof input.startCol) && (undefined === input.endLine || "number" === typeof input.endLine) && (undefined === input.endCol || "number" === typeof input.endCol);
689
+ const _io13 = input => "string" === typeof input.from && "string" === typeof input.to && true === _iv2.has(input.kind) && _ip3(input);
690
+ const _io2 = input => "number" === typeof input.schemaVersion && _ip0(input) && ("object" === typeof input.producer && null !== input.producer && _io3(input.producer)) && ("object" === typeof input.universe && null !== input.universe && _io4(input.universe)) && (Array.isArray(input.sources) && input.sources.every(elem => "object" === typeof elem && null !== elem && _io7(elem)));
691
+ const _io3 = input => "string" === typeof input.tool && "string" === typeof input.version && "string" === typeof input.typescript;
692
+ const _io4 = input => Array.isArray(input.configs) && input.configs.every(elem => "object" === typeof elem && null !== elem && _io5(elem)) && (Array.isArray(input.roots) && input.roots.every(elem => "object" === typeof elem && null !== elem && _io6(elem)));
693
+ const _io5 = input => _ip1(input) && "string" === typeof input.digest;
694
+ const _io6 = input => "string" === typeof input.config && _ip1(input);
695
+ const _io7 = input => _ip1(input) && "string" === typeof input.checkerDigest && "string" === typeof input.diskDigest;
696
+ const _io8 = input => _ip1(input) && "number" === typeof input.line && "number" === typeof input.column && "number" === typeof input.code && ("error" === input.category || "warning" === input.category) && "string" === typeof input.message;
697
+ const _io9 = input => "string" === typeof input.id && true === _iv0.has(input.kind) && _ip2(input) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName) && _ip1(input) && "boolean" === typeof input.external && (undefined === input.ignored || "boolean" === typeof input.ignored) && (undefined === input.exported || "boolean" === typeof input.exported) && (undefined === input.closure || "boolean" === typeof input.closure) && (undefined === input.modifiers || Array.isArray(input.modifiers) && input.modifiers.every(elem => true === _iv1.has(elem))) && (undefined === input.decorators || Array.isArray(input.decorators) && input.decorators.every(elem => "object" === typeof elem && null !== elem && _io10(elem))) && _ip3(input) && (undefined === input.implementation || "object" === typeof input.implementation && null !== input.implementation && _io12(input.implementation));
360
698
  const __is = input => "object" === typeof input && null !== input && _io0(input);
361
699
  let _errorFactory;
362
700
  return (input, errorFactory) => {
@@ -365,72 +703,21 @@ class TtscGraphSession {
365
703
  ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _assertGuard_1._assertGuard(true, {
366
704
  method: "typia.assert",
367
705
  path: _path + "",
368
- expected: "ITtscGraphDump",
706
+ expected: "ITtscGraphSnapshot",
369
707
  value: input
370
708
  }, _errorFactory)) && _ao0(input, _path + "", true) || _assertGuard_1._assertGuard(true, {
371
709
  method: "typia.assert",
372
710
  path: _path + "",
373
- expected: "ITtscGraphDump",
711
+ expected: "ITtscGraphSnapshot",
374
712
  value: input
375
713
  }, _errorFactory))(input, "$input", true);
376
714
  }
377
715
  return input;
378
716
  };
379
- })()(response.dump);
380
- this.current = TtscGraphMemory_1.TtscGraphMemory.from(dump);
381
- }
382
- if (this.current === undefined) {
383
- throw new Error("@ttsc/graph: native session returned no initial graph snapshot");
384
- }
385
- return this.current;
386
- }
387
- request() {
388
- const child = this.ensureChild();
389
- const id = ++this.nextId;
390
- return new Promise((resolve, reject) => {
391
- this.pending.set(id, { resolve, reject });
392
- child.stdin.write(`${JSON.stringify({ id })}\n`, (error) => {
393
- if (error === null || error === undefined)
394
- return;
395
- this.pending.delete(id);
396
- reject(new Error(`@ttsc/graph: could not request native snapshot: ${error.message}`));
397
- });
398
- });
399
- }
400
- ensureChild() {
401
- if (this.closed) {
402
- // A request queued behind the close must not respawn the native
403
- // process; an orphaned resident compiler would outlive the MCP server.
404
- throw new Error("@ttsc/graph: native session is closed");
405
- }
406
- if (this.child !== undefined && this.child.exitCode === null) {
407
- return this.child;
408
- }
409
- this.stderr = "";
410
- const child = (0, node_child_process_1.spawn)(this.binary, ["serve", "--cwd", this.cwd, "--tsconfig", this.tsconfig], { stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
411
- this.child = child;
412
- child.stderr.setEncoding("utf8");
413
- child.stderr.on("data", (chunk) => {
414
- this.stderr = (this.stderr + chunk).slice(-64 * 1024);
415
- });
416
- const lines = node_readline_1.default.createInterface({ input: child.stdout });
417
- lines.on("line", (line) => this.onLine(line));
418
- child.on("error", (error) => this.failChild(child, error));
419
- child.on("exit", (code, signal) => {
420
- if (this.child !== child)
421
- return;
422
- this.child = undefined;
423
- this.failPending(new Error(`@ttsc/graph: native session exited (code=${String(code)}, signal=${String(signal)})${this.stderr.trim() === "" ? "" : `: ${this.stderr.trim()}`}`));
424
- });
425
- return child;
426
- }
427
- onLine(line) {
428
- let response;
429
- try {
430
- response = JSON.parse(line);
717
+ })()(parsed);
431
718
  }
432
719
  catch (error) {
433
- this.failPending(new Error(`@ttsc/graph: native session returned invalid JSON: ${asError(error).message}`));
720
+ this.failPending(new Error(`@ttsc/graph: native session returned an unreadable response: ${asError(error).message}`));
434
721
  return;
435
722
  }
436
723
  const pending = this.pending.get(response.id);