@graphty/graphty-element 2.3.0 → 2.4.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.
Files changed (90) hide show
  1. package/AGENTS.md +4 -3
  2. package/dist/ai.js +115 -222
  3. package/dist/catalog.js +46 -44
  4. package/dist/chunks/{AiManager-Bd_r1Hei.js → AiManager-BD9XK30e.js} +793 -654
  5. package/dist/chunks/{DataSource-bt0DhBjG.js → DataSource-B8vf2uhW.js} +3 -3
  6. package/dist/chunks/{GraphSession-iNyKm7Ds.js → GraphSession-dcwOjGJh.js} +3028 -2918
  7. package/dist/chunks/{GraphStyle-D0PXnZKu.js → GraphStyle-Cwr55SAE.js} +5 -2
  8. package/dist/chunks/{GraphtyError-BwcnblTH.js → GraphtyError-B93WRH3e.js} +8 -6
  9. package/dist/chunks/{GraphtyLogger-5KEttFUo.js → GraphtyLogger-CqOVV13Y.js} +2 -2
  10. package/dist/chunks/{NodeStyle-DKj7HjMJ.js → NodeStyle-CtmA7dXi.js} +16 -14
  11. package/dist/chunks/{VoiceInputAdapter-DszYl6Ha.js → VoiceInputAdapter-D0tHHi9G.js} +1 -1
  12. package/dist/chunks/{XRPivotCameraController-XtxbbZ-D.js → XRPivotCameraController-DTfhvhHz.js} +2 -2
  13. package/dist/chunks/algorithms-BF0X6RPw.js +3627 -0
  14. package/dist/chunks/{capability-check-BqIEXcun.js → capability-check-BJzlK4oL.js} +1 -1
  15. package/dist/chunks/{detect-DM29BEaB.js → detect-vJxK7n0D.js} +2 -2
  16. package/dist/chunks/{format-detection-BEdmtvsy.js → format-detection-C80TLQ2e.js} +1 -1
  17. package/dist/chunks/{index-CD0_RJv-.js → index-2xkq7wyD.js} +11482 -10971
  18. package/dist/chunks/optionsFromZod-BuTOFgVM.js +2572 -0
  19. package/dist/chunks/paletteRegistry-A63C71Gn.js +1155 -0
  20. package/dist/chunks/{registry-CSba5QGJ.js → registry-jB46Gmeb.js} +1 -1
  21. package/dist/chunks/scales-B2d-7Bf0.js +3220 -0
  22. package/dist/chunks/{types-B7bX5c0K.js → types-C_c53VgR.js} +31 -26
  23. package/dist/commands.d.ts +4 -0
  24. package/dist/custom-elements.json +1 -1
  25. package/dist/extend.js +45 -45
  26. package/dist/graphty-catalog.json +245 -12
  27. package/dist/graphty.bundle.js +40762 -39403
  28. package/dist/graphty.js +33 -33
  29. package/dist/logging.js +2 -2
  30. package/dist/schema.d.ts +1 -1
  31. package/dist/schema.js +42 -40
  32. package/dist/session.d.ts +1 -1
  33. package/dist/session.js +29 -30
  34. package/dist/src/Graph.d.ts +112 -10
  35. package/dist/src/acceleration/AccelerationController.d.ts +14 -3
  36. package/dist/src/acceleration/types.d.ts +78 -0
  37. package/dist/src/algorithms/KCoreAlgorithm.d.ts +26 -0
  38. package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +41 -0
  39. package/dist/src/camera/builtins.d.ts +14 -1
  40. package/dist/src/camera/types.d.ts +7 -0
  41. package/dist/src/cameras/CameraManager.d.ts +13 -0
  42. package/dist/src/cameras/OrbitCameraController.d.ts +9 -0
  43. package/dist/src/catalog/algorithms.d.ts +5 -5
  44. package/dist/src/catalog/index.d.ts +2 -2
  45. package/dist/src/catalog/layouts.d.ts +7 -6
  46. package/dist/src/catalog/types.d.ts +87 -6
  47. package/dist/src/config/EdgeStyle.d.ts +35 -0
  48. package/dist/src/config/GraphStyle.d.ts +5 -1
  49. package/dist/src/config/StyleTemplate.d.ts +2 -2
  50. package/dist/src/config/index.d.ts +1 -1
  51. package/dist/src/data/GEXFDataSource.d.ts +23 -0
  52. package/dist/src/errors/codes.d.ts +14 -0
  53. package/dist/src/events.d.ts +30 -0
  54. package/dist/src/graphty-element.d.ts +77 -32
  55. package/dist/src/layout/GridLayoutEngine.d.ts +37 -0
  56. package/dist/src/layout/LayoutEngine.d.ts +7 -7
  57. package/dist/src/layout/NGraphLayoutEngine.d.ts +2 -0
  58. package/dist/src/layout/RadialLayoutEngine.d.ts +37 -0
  59. package/dist/src/layout/SimulationLayoutEngine.d.ts +12 -0
  60. package/dist/src/managers/DataManager.d.ts +69 -2
  61. package/dist/src/managers/EventManager.d.ts +10 -4
  62. package/dist/src/managers/GraphContext.d.ts +2 -1
  63. package/dist/src/managers/LayoutManager.d.ts +30 -3
  64. package/dist/src/managers/StylePainter.d.ts +9 -0
  65. package/dist/src/managers/UpdateManager.d.ts +5 -0
  66. package/dist/src/meshes/MeshCache.d.ts +18 -0
  67. package/dist/src/meshes/NodeEffects.d.ts +16 -11
  68. package/dist/src/meshes/NodeMesh.d.ts +2 -2
  69. package/dist/src/meshes/RichTextParser.d.ts +26 -0
  70. package/dist/src/meshes/RichTextRenderer.d.ts +0 -1
  71. package/dist/src/session/cost/estimate.d.ts +1 -1
  72. package/dist/src/session/layout.d.ts +3 -3
  73. package/dist/src/session/results/index.d.ts +1 -1
  74. package/dist/src/session/results/statistics.d.ts +8 -1
  75. package/dist/src/session/results/types.d.ts +33 -0
  76. package/dist/src/session/runs/RunsApi.d.ts +1 -1
  77. package/dist/src/session/selection/targets.d.ts +4 -1
  78. package/dist/src/session/styles/StylesApi.d.ts +6 -0
  79. package/dist/src/session/styles/intern.d.ts +26 -5
  80. package/dist/src/session/styles/predicate.d.ts +26 -1
  81. package/dist/src/session/styles/repaint.d.ts +13 -1
  82. package/dist/src/session/styles/selector.d.ts +13 -1
  83. package/dist/src/session/styles/sources.d.ts +9 -0
  84. package/dist/src/session/types.d.ts +6 -6
  85. package/dist/webgpu.js +2 -2
  86. package/package.json +6 -6
  87. package/dist/chunks/Algorithm-RQ629NLb.js +0 -494
  88. package/dist/chunks/cameras-ii4vngYY.js +0 -435
  89. package/dist/chunks/paletteRegistry-DnWHQsAD.js +0 -3166
  90. package/dist/chunks/scales-DyuwlJKI.js +0 -6087
@@ -1,17 +1,17 @@
1
- import { l as _ } from "./VoiceInputAdapter-DszYl6Ha.js";
2
- import { G as K } from "./GraphtyLogger-5KEttFUo.js";
3
- import W from "jmespath";
4
- import { z as m } from "zod";
5
- import { e as G } from "./Algorithm-RQ629NLb.js";
6
- import { N as H, c as B, C as X } from "./cameras-ii4vngYY.js";
7
- import { inferSchema as C } from "@jsonhero/schema-infer";
8
- import { i as Z } from "./GraphtyError-BwcnblTH.js";
9
- import { createAnthropic as Y } from "@ai-sdk/anthropic";
10
- import { createGoogleGenerativeAI as J } from "@ai-sdk/google";
11
- import { createOpenAI as Q } from "@ai-sdk/openai";
12
- import { generateText as ee, streamText as te } from "ai";
13
- import { A as se } from "./ApiKeyManager-C0ac91dE.js";
14
- class I {
1
+ import { l as Y } from "./VoiceInputAdapter-D0tHHi9G.js";
2
+ import { G as J } from "./GraphtyLogger-CqOVV13Y.js";
3
+ import { z as c } from "zod";
4
+ import { k as Q, A as x, B as P } from "./optionsFromZod-BuTOFgVM.js";
5
+ import { N as ee, e as te, C as se, d as re } from "./algorithms-BF0X6RPw.js";
6
+ import ae from "jmespath";
7
+ import { inferSchema as A } from "@jsonhero/schema-infer";
8
+ import { i as oe } from "./GraphtyError-B93WRH3e.js";
9
+ import { createAnthropic as ne } from "@ai-sdk/anthropic";
10
+ import { createGoogleGenerativeAI as ie } from "@ai-sdk/google";
11
+ import { createOpenAI as le } from "@ai-sdk/openai";
12
+ import { generateText as ce, streamText as ue } from "ai";
13
+ import { A as de } from "./ApiKeyManager-C0ac91dE.js";
14
+ class F {
15
15
  /**
16
16
  * Creates a new AiStatusManager instance.
17
17
  */
@@ -111,18 +111,18 @@ class I {
111
111
  * @param status - New status for the tool call
112
112
  * @param result - Optional result data
113
113
  */
114
- updateToolCallStatus(e, t, r) {
115
- const { toolCalls: a } = this.status;
116
- if (!a)
114
+ updateToolCallStatus(e, t, s) {
115
+ const { toolCalls: r } = this.status;
116
+ if (!r)
117
117
  return;
118
- const o = a.findIndex((l) => l.name === e);
118
+ const o = r.findIndex((l) => l.name === e);
119
119
  if (o === -1)
120
120
  return;
121
- const n = [...a];
121
+ const n = [...r];
122
122
  n[o] = {
123
123
  ...n[o],
124
124
  status: t,
125
- result: r
125
+ result: s
126
126
  }, this.status = {
127
127
  ...this.status,
128
128
  toolCalls: n
@@ -186,14 +186,14 @@ class I {
186
186
  };
187
187
  }
188
188
  }
189
- const f = K.getLogger(["graphty", "ai"]);
190
- class re {
189
+ const f = J.getLogger(["graphty", "ai"]);
190
+ class me {
191
191
  /**
192
192
  * Creates a new AiController instance.
193
193
  * @param options - Configuration options for the controller
194
194
  */
195
195
  constructor(e) {
196
- this.abortController = null, this.disposed = !1, this.currentInput = null, this.startTime = null, this.lastInput = null, this.lastError = null, this.provider = e.provider, this.commandRegistry = e.commandRegistry, this.graph = e.graph, this.statusManager = new I(), this.schemaManager = e.schemaManager ?? null, this.emitEvent = e.emitEvent, this.statusManager.subscribe((t) => {
196
+ this.abortController = null, this.disposed = !1, this.currentInput = null, this.startTime = null, this.lastInput = null, this.lastError = null, this.provider = e.provider, this.commandRegistry = e.commandRegistry, this.graph = e.graph, this.statusManager = new F(), this.schemaManager = e.schemaManager ?? null, this.emitEvent = e.emitEvent, this.statusManager.subscribe((t) => {
197
197
  this.emitAiEvent({
198
198
  type: "ai-status-change",
199
199
  status: t
@@ -224,22 +224,22 @@ class re {
224
224
  timestamp: this.startTime
225
225
  }), this.statusManager.submit();
226
226
  try {
227
- const t = this.buildMessages(e), r = this.commandRegistry.toToolDefinitions();
228
- f.debug("Request", { messages: t, tools: r.map((n) => n.name) }), this.statusManager.startStreaming();
229
- const a = await this.provider.generate(t, r, { signal: this.abortController.signal });
227
+ const t = this.buildMessages(e), s = this.commandRegistry.toToolDefinitions();
228
+ f.debug("Request", { messages: t, tools: s.map((n) => n.name) }), this.statusManager.startStreaming();
229
+ const r = await this.provider.generate(t, s, { signal: this.abortController.signal });
230
230
  if (f.debug("Response", {
231
- text: a.text || "(no text)",
232
- toolCalls: a.toolCalls.map((n) => ({ name: n.name, arguments: n.arguments }))
233
- }), a.text && (this.statusManager.appendStreamedText(a.text), this.emitAiEvent({
231
+ text: r.text || "(no text)",
232
+ toolCalls: r.toolCalls.map((n) => ({ name: n.name, arguments: n.arguments }))
233
+ }), r.text && (this.statusManager.appendStreamedText(r.text), this.emitAiEvent({
234
234
  type: "ai-stream-chunk",
235
- text: a.text,
236
- accumulated: a.text
237
- })), a.toolCalls.length === 0) {
235
+ text: r.text,
236
+ accumulated: r.text
237
+ })), r.toolCalls.length === 0) {
238
238
  this.statusManager.complete();
239
239
  const n = {
240
240
  success: !0,
241
- message: a.text || "No response from AI",
242
- llmText: a.text
241
+ message: r.text || "No response from AI",
242
+ llmText: r.text
243
243
  };
244
244
  return this.emitAiEvent({
245
245
  type: "ai-command-complete",
@@ -248,22 +248,22 @@ class re {
248
248
  }), n;
249
249
  }
250
250
  this.statusManager.startExecuting();
251
- const o = await this.executeToolCalls(a.toolCalls, a.text);
251
+ const o = await this.executeToolCalls(r.toolCalls, r.text);
252
252
  return this.statusManager.complete(), this.emitAiEvent({
253
253
  type: "ai-command-complete",
254
254
  result: o,
255
255
  duration: Date.now() - this.startTime
256
256
  }), o;
257
257
  } catch (t) {
258
- const r = t instanceof Error ? t.message : String(t), a = t instanceof Error ? t : new Error(r);
259
- return this.lastError = a, this.statusManager.setError(a, !0), this.emitAiEvent({
258
+ const s = t instanceof Error ? t.message : String(t), r = t instanceof Error ? t : new Error(s);
259
+ return this.lastError = r, this.statusManager.setError(r, !0), this.emitAiEvent({
260
260
  type: "ai-command-error",
261
- error: a,
261
+ error: r,
262
262
  input: e,
263
263
  canRetry: !0
264
264
  }), {
265
265
  success: !1,
266
- message: `Error: ${r}`
266
+ message: `Error: ${s}`
267
267
  };
268
268
  } finally {
269
269
  this.abortController = null, this.currentInput = null;
@@ -327,22 +327,22 @@ ${this.schemaManager.getFormattedSchema()}
327
327
  * @returns Combined execution result
328
328
  */
329
329
  async executeToolCalls(e, t) {
330
- const r = [];
331
- for (const a of e) {
332
- this.statusManager.addToolCall(a.name), this.statusManager.updateToolCallStatus(a.name, "executing"), this.emitAiEvent({
330
+ const s = [];
331
+ for (const r of e) {
332
+ this.statusManager.addToolCall(r.name), this.statusManager.updateToolCallStatus(r.name, "executing"), this.emitAiEvent({
333
333
  type: "ai-stream-tool-call",
334
- name: a.name,
335
- params: a.arguments
334
+ name: r.name,
335
+ params: r.arguments
336
336
  });
337
337
  try {
338
- const o = await this.executeToolCall(a);
339
- if (r.push(o), this.statusManager.updateToolCallStatus(
340
- a.name,
338
+ const o = await this.executeToolCall(r);
339
+ if (s.push(o), this.statusManager.updateToolCallStatus(
340
+ r.name,
341
341
  o.success ? "complete" : "error",
342
342
  o.data ?? { message: o.message }
343
343
  ), this.emitAiEvent({
344
344
  type: "ai-stream-tool-result",
345
- name: a.name,
345
+ name: r.name,
346
346
  result: o.data ?? { message: o.message },
347
347
  success: o.success
348
348
  }), !o.success)
@@ -350,18 +350,18 @@ ${this.schemaManager.getFormattedSchema()}
350
350
  } catch (o) {
351
351
  const n = o instanceof Error ? o.message : String(o), l = {
352
352
  success: !1,
353
- message: `Error executing ${a.name}: ${n}`
353
+ message: `Error executing ${r.name}: ${n}`
354
354
  };
355
- r.push(l), this.statusManager.updateToolCallStatus(a.name, "error", { error: n }), this.emitAiEvent({
355
+ s.push(l), this.statusManager.updateToolCallStatus(r.name, "error", { error: n }), this.emitAiEvent({
356
356
  type: "ai-stream-tool-result",
357
- name: a.name,
357
+ name: r.name,
358
358
  result: { error: n },
359
359
  success: !1
360
360
  });
361
361
  break;
362
362
  }
363
363
  }
364
- return this.combineResults(r, t);
364
+ return this.combineResults(s, t);
365
365
  }
366
366
  /**
367
367
  * Execute a single tool call.
@@ -376,9 +376,9 @@ ${this.schemaManager.getFormattedSchema()}
376
376
  success: !1,
377
377
  message: `Unknown command: ${e.name}. Command not found in registry.`
378
378
  };
379
- let r;
379
+ let s;
380
380
  try {
381
- r = t.parameters.parse(e.arguments), f.debug("Validated arguments", { arguments: r });
381
+ s = t.parameters.parse(e.arguments), f.debug("Validated arguments", { arguments: s });
382
382
  } catch (n) {
383
383
  const l = n instanceof Error ? n.message : String(n);
384
384
  return f.debug("Command result: FAILED - Invalid arguments", { error: l }), {
@@ -386,7 +386,7 @@ ${this.schemaManager.getFormattedSchema()}
386
386
  message: `Invalid arguments for ${e.name}: ${l}`
387
387
  };
388
388
  }
389
- const a = {
389
+ const r = {
390
390
  graph: this.graph,
391
391
  abortSignal: this.abortController?.signal ?? new AbortController().signal,
392
392
  emitEvent: (n, l) => {
@@ -395,7 +395,7 @@ ${this.schemaManager.getFormattedSchema()}
395
395
  updateStatus: (n) => {
396
396
  n.stageMessage && this.statusManager.setStage("executing", n.stageMessage);
397
397
  }
398
- }, o = await t.execute(this.graph, r, a);
398
+ }, o = await t.execute(this.graph, s, r);
399
399
  return f.debug("Command result", {
400
400
  success: o.success,
401
401
  message: o.message,
@@ -415,12 +415,12 @@ ${this.schemaManager.getFormattedSchema()}
415
415
  message: t ?? "No commands executed",
416
416
  llmText: t
417
417
  };
418
- const r = e.every((i) => i.success), a = e.map((i) => i.message);
419
- t && a.unshift(t);
420
- const o = e.flatMap((i) => i.affectedNodes ?? []).filter((i, u, c) => c.indexOf(i) === u), n = e.flatMap((i) => i.affectedEdges ?? []).filter((i, u, c) => c.indexOf(i) === u), l = e.filter((i) => i.success).pop() ?? e[e.length - 1];
418
+ const s = e.every((i) => i.success), r = e.map((i) => i.message);
419
+ t && r.unshift(t);
420
+ const o = [...new Set(e.flatMap((i) => i.affectedNodes ?? []))], n = [...new Set(e.flatMap((i) => i.affectedEdges ?? []))], l = e.filter((i) => i.success).pop() ?? e[e.length - 1];
421
421
  return {
422
- success: r,
423
- message: a.join(`
422
+ success: s,
423
+ message: r.join(`
424
424
  `),
425
425
  data: l.data,
426
426
  affectedNodes: o.length > 0 ? o : void 0,
@@ -460,7 +460,7 @@ ${this.schemaManager.getFormattedSchema()}
460
460
  this.disposed = !0, this.cancel(), this.statusManager.reset();
461
461
  }
462
462
  }
463
- class ae {
463
+ class pe {
464
464
  constructor() {
465
465
  this.commands = /* @__PURE__ */ new Map();
466
466
  }
@@ -529,7 +529,7 @@ class ae {
529
529
  }));
530
530
  }
531
531
  }
532
- const oe = {
532
+ const he = {
533
533
  maxSampleSize: 1e3,
534
534
  maxDepth: 3,
535
535
  enumMaxAbsoluteUnique: 10,
@@ -537,7 +537,7 @@ const oe = {
537
537
  enumMaxStringLength: 64,
538
538
  enumMinSampleSize: 25
539
539
  };
540
- class ne {
540
+ class ge {
541
541
  constructor(e) {
542
542
  this.values = /* @__PURE__ */ new Map(), this.options = e;
543
543
  }
@@ -548,8 +548,8 @@ class ne {
548
548
  */
549
549
  trackValue(e, t) {
550
550
  this.values.has(e) || this.values.set(e, []);
551
- const r = this.values.get(e);
552
- r && r.push(t);
551
+ const s = this.values.get(e);
552
+ s && s.push(t);
553
553
  }
554
554
  /**
555
555
  * Recursively track string values from an object.
@@ -557,13 +557,13 @@ class ne {
557
557
  * @param prefix - Property path prefix
558
558
  * @param depth - Current recursion depth
559
559
  */
560
- trackObject(e, t = "", r = 0) {
561
- if (!(r >= this.options.maxDepth))
562
- for (const [a, o] of Object.entries(e)) {
563
- if (t === "" && a === "id")
560
+ trackObject(e, t = "", s = 0) {
561
+ if (!(s >= this.options.maxDepth))
562
+ for (const [r, o] of Object.entries(e)) {
563
+ if (t === "" && r === "id")
564
564
  continue;
565
- const n = t ? `${t}.${a}` : a;
566
- typeof o == "string" ? this.trackValue(n, o) : o !== null && typeof o == "object" && !Array.isArray(o) && this.trackObject(o, n, r + 1);
565
+ const n = t ? `${t}.${r}` : r;
566
+ typeof o == "string" ? this.trackValue(n, o) : o !== null && typeof o == "object" && !Array.isArray(o) && this.trackObject(o, n, s + 1);
567
567
  }
568
568
  }
569
569
  /**
@@ -581,30 +581,30 @@ class ne {
581
581
  const t = this.values.get(e);
582
582
  if (!t || t.length < this.options.enumMinSampleSize)
583
583
  return { isEnum: !1 };
584
- const r = [...new Set(t)], a = r.length / t.length, o = r.length <= this.options.enumMaxAbsoluteUnique || a <= this.options.enumMaxUniqueRatio, n = r.every((l) => l.length <= this.options.enumMaxStringLength);
585
- return o && n ? { isEnum: !0, values: r.sort() } : { isEnum: !1 };
584
+ const s = [...new Set(t)], r = s.length / t.length, o = s.length <= this.options.enumMaxAbsoluteUnique || r <= this.options.enumMaxUniqueRatio, n = s.every((l) => l.length <= this.options.enumMaxStringLength);
585
+ return o && n ? { isEnum: !0, values: s.sort() } : { isEnum: !1 };
586
586
  }
587
587
  }
588
- class D {
588
+ class O {
589
589
  /**
590
590
  * Creates a new SchemaExtractor instance.
591
591
  * @param graph - The graph to extract schema from
592
592
  * @param options - Optional extraction options
593
593
  */
594
594
  constructor(e, t = {}) {
595
- this.graph = e, this.options = { ...oe, ...t };
595
+ this.graph = e, this.options = { ...he, ...t };
596
596
  }
597
597
  /**
598
598
  * Extract schema from the graph.
599
599
  * @returns SchemaSummary with node and edge property information
600
600
  */
601
601
  extract() {
602
- const e = this.graph.getDataManager(), t = this.graph.getNodeCount(), r = this.graph.getEdgeCount(), a = Array.from(e.nodes.values()).map((n) => n.data).filter((n) => n !== void 0), o = Array.from(e.edges.values()).map((n) => n.data).filter((n) => n !== void 0);
602
+ const e = this.graph.getDataManager(), t = this.graph.getNodeCount(), s = this.graph.getEdgeCount(), r = Array.from(e.nodes.values()).map((n) => n.data).filter((n) => n !== void 0), o = Array.from(e.edges.values()).map((n) => n.data).filter((n) => n !== void 0);
603
603
  return {
604
- nodeProperties: this.extractFromCollection(a),
604
+ nodeProperties: this.extractFromCollection(r),
605
605
  edgeProperties: this.extractFromCollection(o),
606
606
  nodeCount: t,
607
- edgeCount: r
607
+ edgeCount: s
608
608
  };
609
609
  }
610
610
  /**
@@ -615,14 +615,14 @@ class D {
615
615
  extractFromCollection(e) {
616
616
  if (e.length === 0)
617
617
  return [];
618
- const t = e.length <= this.options.maxSampleSize ? e : this.sampleEvenly(e, this.options.maxSampleSize), [r, ...a] = t;
619
- let o = C(r);
620
- for (const i of a)
621
- o = C(
618
+ const t = e.length <= this.options.maxSampleSize ? e : this.sampleEvenly(e, this.options.maxSampleSize), [s, ...r] = t;
619
+ let o = A(s);
620
+ for (const i of r)
621
+ o = A(
622
622
  i,
623
623
  o
624
624
  );
625
- const n = o.toSnapshot(), l = new ne(this.options);
625
+ const n = o.toSnapshot(), l = new ge(this.options);
626
626
  for (const i of t)
627
627
  l.trackObject(i, "", 0);
628
628
  return this.mergeResults(n, l);
@@ -634,14 +634,14 @@ class D {
634
634
  * @returns Array of merged property summaries
635
635
  */
636
636
  mergeResults(e, t) {
637
- const r = [];
637
+ const s = [];
638
638
  if (e.type === "object" && e.properties) {
639
- for (const [a, o] of Object.entries(e.properties.required))
640
- this.extractProperties(a, o, t, "", !1, r);
641
- for (const [a, o] of Object.entries(e.properties.optional))
642
- this.extractProperties(a, o, t, "", !0, r);
639
+ for (const [r, o] of Object.entries(e.properties.required))
640
+ this.extractProperties(r, o, t, "", !1, s);
641
+ for (const [r, o] of Object.entries(e.properties.optional))
642
+ this.extractProperties(r, o, t, "", !0, s);
643
643
  }
644
- return r.sort((a, o) => a.name.localeCompare(o.name));
644
+ return s.sort((r, o) => r.name.localeCompare(o.name));
645
645
  }
646
646
  /**
647
647
  * Recursively extract properties, handling nested objects with dot notation.
@@ -653,19 +653,19 @@ class D {
653
653
  * @param properties - Array to accumulate property summaries
654
654
  * @param depth - Current recursion depth
655
655
  */
656
- extractProperties(e, t, r, a, o, n, l = 0) {
657
- const i = a ? `${a}.${e}` : e;
658
- if (a === "" && e === "id" || l >= this.options.maxDepth)
656
+ extractProperties(e, t, s, r, o, n, l = 0) {
657
+ const i = r ? `${r}.${e}` : e;
658
+ if (r === "" && e === "id" || l >= this.options.maxDepth)
659
659
  return;
660
- let u = o, c = t;
661
- if (t.type === "nullable" && t.schema && (u = !0, c = t.schema), c.type === "object" && c.properties) {
662
- for (const [d, h] of Object.entries(c.properties.required))
663
- this.extractProperties(d, h, r, i, !1, n, l + 1);
664
- for (const [d, h] of Object.entries(c.properties.optional))
665
- this.extractProperties(d, h, r, i, !0, n, l + 1);
660
+ let u = o, d = t;
661
+ if (t.type === "nullable" && t.schema && (u = !0, d = t.schema), d.type === "object" && d.properties) {
662
+ for (const [m, h] of Object.entries(d.properties.required))
663
+ this.extractProperties(m, h, s, i, !1, n, l + 1);
664
+ for (const [m, h] of Object.entries(d.properties.optional))
665
+ this.extractProperties(m, h, s, i, !0, n, l + 1);
666
666
  return;
667
667
  }
668
- const p = this.schemaToSummary(i, c, r, u);
668
+ const p = this.schemaToSummary(i, d, s, u);
669
669
  p && n.push(p);
670
670
  }
671
671
  /**
@@ -676,16 +676,16 @@ class D {
676
676
  * @param nullable - Whether the property can be null
677
677
  * @returns Property summary or null if not convertible
678
678
  */
679
- schemaToSummary(e, t, r, a) {
679
+ schemaToSummary(e, t, s, r) {
680
680
  const o = {
681
681
  name: e,
682
682
  type: this.inferredTypeToPropertyType(t),
683
- nullable: a
683
+ nullable: r
684
684
  };
685
685
  switch (t.type) {
686
686
  case "string": {
687
687
  t.format?.name && (o.format = t.format.name);
688
- const n = r.getEnumAnalysis(e);
688
+ const n = s.getEnumAnalysis(e);
689
689
  n.isEnum && n.values && (o.enumValues = n.values);
690
690
  break;
691
691
  }
@@ -735,19 +735,19 @@ class D {
735
735
  * @returns Array of evenly distributed samples
736
736
  */
737
737
  sampleEvenly(e, t) {
738
- const r = [], a = e.length / t;
738
+ const s = [], r = e.length / t;
739
739
  for (let o = 0; o < t; o++) {
740
- const n = Math.floor(o * a);
741
- r.push(e[n]);
740
+ const n = Math.floor(o * r);
741
+ s.push(e[n]);
742
742
  }
743
- return r;
743
+ return s;
744
744
  }
745
745
  }
746
- const ie = m.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"]).describe("Type of information to query about the graph"), le = {
746
+ const fe = c.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"]).describe("Type of information to query about the graph"), ye = {
747
747
  name: "queryGraph",
748
748
  description: "Query information about the graph structure, including node count, edge count, current layout, and overall statistics.",
749
- parameters: m.object({
750
- query: ie
749
+ parameters: c.object({
750
+ query: fe
751
751
  }),
752
752
  examples: [
753
753
  { input: "How many nodes are there?", params: { query: "nodeCount" } },
@@ -756,106 +756,106 @@ const ie = m.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"])
756
756
  { input: "Show me the graph summary", params: { query: "summary" } },
757
757
  { input: "Give me all the graph stats", params: { query: "all" } }
758
758
  ],
759
- execute(s, e) {
759
+ execute(a, e) {
760
760
  const { query: t } = e;
761
761
  try {
762
762
  switch (t) {
763
763
  case "nodeCount": {
764
- const r = s.getNodeCount();
764
+ const s = a.getNodeCount();
765
765
  return Promise.resolve({
766
766
  success: !0,
767
- message: `The graph has ${r} node${r !== 1 ? "s" : ""}.`,
768
- data: { nodeCount: r }
767
+ message: `The graph has ${s} node${s !== 1 ? "s" : ""}.`,
768
+ data: { nodeCount: s }
769
769
  });
770
770
  }
771
771
  case "edgeCount": {
772
- const r = s.getEdgeCount();
772
+ const s = a.getEdgeCount();
773
773
  return Promise.resolve({
774
774
  success: !0,
775
- message: `The graph has ${r} edge${r !== 1 ? "s" : ""}.`,
776
- data: { edgeCount: r }
775
+ message: `The graph has ${s} edge${s !== 1 ? "s" : ""}.`,
776
+ data: { edgeCount: s }
777
777
  });
778
778
  }
779
779
  case "currentLayout": {
780
- const a = s.getLayoutManager().layoutEngine?.type ?? "unknown";
780
+ const r = a.getLayoutManager().layoutEngine?.type ?? "unknown";
781
781
  return Promise.resolve({
782
782
  success: !0,
783
- message: `The current layout is "${a}".`,
784
- data: { layout: a }
783
+ message: `The current layout is "${r}".`,
784
+ data: { layout: r }
785
785
  });
786
786
  }
787
787
  case "all":
788
788
  case "summary": {
789
- const r = s.getNodeCount(), a = s.getEdgeCount(), n = s.getLayoutManager().layoutEngine?.type ?? "unknown", l = s.getViewMode() === "2d";
789
+ const s = a.getNodeCount(), r = a.getEdgeCount(), n = a.getLayoutManager().layoutEngine?.type ?? "unknown", l = a.getViewMode() === "2d";
790
790
  return Promise.resolve({
791
791
  success: !0,
792
792
  message: `Graph Summary:
793
- - Nodes: ${r}
794
- - Edges: ${a}
793
+ - Nodes: ${s}
794
+ - Edges: ${r}
795
795
  - Layout: ${n}
796
796
  - Mode: ${l ? "2D" : "3D"}`,
797
797
  data: {
798
- nodeCount: r,
799
- edgeCount: a,
798
+ nodeCount: s,
799
+ edgeCount: r,
800
800
  layout: n,
801
801
  is2D: l
802
802
  }
803
803
  });
804
804
  }
805
805
  default: {
806
- const r = s.getNodeCount(), a = s.getEdgeCount();
806
+ const s = a.getNodeCount(), r = a.getEdgeCount();
807
807
  return Promise.resolve({
808
808
  success: !0,
809
- message: `Unknown query type "${String(t)}". The graph has ${r} nodes and ${a} edges.`,
810
- data: { nodeCount: r, edgeCount: a }
809
+ message: `Unknown query type "${String(t)}". The graph has ${s} nodes and ${r} edges.`,
810
+ data: { nodeCount: s, edgeCount: r }
811
811
  });
812
812
  }
813
813
  }
814
- } catch (r) {
814
+ } catch (s) {
815
815
  return Promise.resolve({
816
816
  success: !1,
817
- message: `Failed to query graph: ${r.message}`
817
+ message: `Failed to query graph: ${s.message}`
818
818
  });
819
819
  }
820
820
  }
821
- }, ce = {
821
+ }, ve = 50, be = {
822
822
  name: "findNodes",
823
- description: "Find nodes in the graph that match specific criteria. Returns matching node IDs and counts. Note: selectors search within node data directly, so use 'type' not 'data.type'.",
824
- parameters: m.object({
825
- selector: m.string().describe(
823
+ description: "Find nodes in the graph that match specific criteria. Returns the total number of matches and at most `limit` matching node IDs (50 when no limit is given), with `truncated` true when the list was cut. Note: selectors search within node data directly, so use 'type' not 'data.type'.",
824
+ parameters: c.object({
825
+ selector: c.string().describe(
826
826
  `Simple selector to match nodes (e.g., 'type == "server"'). Search is performed on node data directly, so use property names like 'type' not 'data.type'.`
827
827
  ),
828
- limit: m.number().optional().describe("Maximum number of results to return")
828
+ limit: c.number().optional().describe("Maximum number of node IDs to return (default 50)")
829
829
  }),
830
830
  examples: [
831
831
  { input: "Find all server nodes", params: { selector: "type == 'server'" } },
832
832
  { input: "Find nodes with high degree", params: { selector: "degree > 5" } },
833
833
  { input: "Get first 10 nodes", params: { selector: "", limit: 10 } }
834
834
  ],
835
- execute(s, e) {
836
- const { selector: t, limit: r } = e;
835
+ execute(a, e) {
836
+ const { selector: t, limit: s } = e;
837
837
  try {
838
- const a = s.getDataManager(), o = Array.from(a.nodes.values());
838
+ const r = a.getDataManager(), o = Array.from(r.nodes.values());
839
839
  let n;
840
- !t || t === "" || t === "*" ? n = o : n = o.filter((i) => {
840
+ !t || t === "" || t === "*" ? n = o : n = o.filter((p) => {
841
841
  try {
842
- const u = /^(\w+)\s*==\s*['"](.+)['"]$/.exec(t);
843
- if (u) {
844
- const [, p, d] = u, h = i.data[p];
845
- return typeof h == "boolean" ? h === (d === "true") : h === d;
842
+ const m = /^(\w+)\s*==\s*['"](.+)['"]$/.exec(t);
843
+ if (m) {
844
+ const [, g, b] = m, v = p.data[g];
845
+ return typeof v == "boolean" ? v === (b === "true") : v === b;
846
846
  }
847
- const c = /^(\w+)\s*(>|<|>=|<=)\s*(\d+)$/.exec(t);
848
- if (c) {
849
- const [, p, d, h] = c, g = Number(i.data[p]), v = Number(h);
850
- switch (d) {
847
+ const h = /^(\w+)\s*(>|<|>=|<=)\s*(\d+)$/.exec(t);
848
+ if (h) {
849
+ const [, g, b, v] = h, w = Number(p.data[g]), S = Number(v);
850
+ switch (b) {
851
851
  case ">":
852
- return g > v;
852
+ return w > S;
853
853
  case "<":
854
- return g < v;
854
+ return w < S;
855
855
  case ">=":
856
- return g >= v;
856
+ return w >= S;
857
857
  case "<=":
858
- return g <= v;
858
+ return w <= S;
859
859
  default:
860
860
  return !1;
861
861
  }
@@ -864,29 +864,32 @@ const ie = m.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"])
864
864
  } catch {
865
865
  return !1;
866
866
  }
867
- }), r !== void 0 && r > 0 && (n = n.slice(0, r));
868
- const l = n.map((i) => String(i.id));
867
+ });
868
+ const l = n.length, i = n.slice(0, s !== void 0 && s > 0 ? s : ve).map((p) => String(p.id)), u = i.length, d = l > u;
869
869
  return Promise.resolve({
870
870
  success: !0,
871
- message: `Found ${l.length} matching node${l.length !== 1 ? "s" : ""}.`,
871
+ message: `Found ${l} matching node${l !== 1 ? "s" : ""}${d ? ` (showing ${u})` : ""}.`,
872
872
  data: {
873
- count: l.length,
874
- nodeIds: l
873
+ total: l,
874
+ returned: u,
875
+ count: u,
876
+ truncated: d,
877
+ nodeIds: i
875
878
  },
876
- affectedNodes: l
879
+ affectedNodes: i
877
880
  });
878
- } catch (a) {
881
+ } catch (r) {
879
882
  return Promise.resolve({
880
883
  success: !1,
881
- message: `Failed to find nodes: ${a.message}`
884
+ message: `Failed to find nodes: ${r.message}`
882
885
  });
883
886
  }
884
887
  }
885
- }, ue = m.enum(["nodeTypes", "edgeTypes", "nodeProperties", "edgeProperties", "all"]).describe("Type of schema information to retrieve"), de = {
888
+ }, we = c.enum(["nodeTypes", "edgeTypes", "nodeProperties", "edgeProperties", "all"]).describe("Type of schema information to retrieve"), Se = {
886
889
  name: "getSchema",
887
890
  description: "Get schema information about the graph data including node types, edge types, and available properties. Use this to discover what types of nodes exist or what properties are available for filtering.",
888
- parameters: m.object({
889
- query: ue
891
+ parameters: c.object({
892
+ query: we
890
893
  }),
891
894
  examples: [
892
895
  { input: "What types of nodes are there?", params: { query: "nodeTypes" } },
@@ -895,21 +898,21 @@ const ie = m.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"])
895
898
  { input: "What edge properties are available?", params: { query: "edgeProperties" } },
896
899
  { input: "Show me the data schema", params: { query: "all" } }
897
900
  ],
898
- execute(s, e) {
901
+ execute(a, e) {
899
902
  const { query: t } = e;
900
903
  try {
901
- const a = new D(s).extract(), o = s.getDataManager(), n = (l, i, u = 20) => {
902
- const c = /* @__PURE__ */ new Set();
904
+ const r = new O(a).extract(), o = a.getDataManager(), n = (l, i, u = 20) => {
905
+ const d = /* @__PURE__ */ new Set();
903
906
  for (const p of l) {
904
- const d = p.data?.[i];
905
- if (typeof d == "string" && (c.add(d), c.size > u))
907
+ const m = p.data?.[i];
908
+ if (typeof m == "string" && (d.add(m), d.size > u))
906
909
  return [];
907
910
  }
908
- return Array.from(c).sort();
911
+ return Array.from(d).sort();
909
912
  };
910
913
  switch (t) {
911
914
  case "nodeTypes": {
912
- let i = a.nodeProperties.find((u) => u.name === "type")?.enumValues ?? [];
915
+ let i = r.nodeProperties.find((u) => u.name === "type")?.enumValues ?? [];
913
916
  return i.length === 0 && (i = n(o.nodes.values(), "type")), i.length === 0 ? Promise.resolve({
914
917
  success: !0,
915
918
  message: "No distinct node types found. Nodes may not have a 'type' property, or there are too many unique values to categorize.",
@@ -921,7 +924,7 @@ const ie = m.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"])
921
924
  });
922
925
  }
923
926
  case "edgeTypes": {
924
- let i = a.edgeProperties.find((u) => u.name === "type")?.enumValues ?? [];
927
+ let i = r.edgeProperties.find((u) => u.name === "type")?.enumValues ?? [];
925
928
  return i.length === 0 && (i = n(o.edges.values(), "type")), i.length === 0 ? Promise.resolve({
926
929
  success: !0,
927
930
  message: "No distinct edge types found. Edges may not have a 'type' property, or there are too many unique values to categorize.",
@@ -933,7 +936,7 @@ const ie = m.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"])
933
936
  });
934
937
  }
935
938
  case "nodeProperties": {
936
- const l = a.nodeProperties.map((i) => {
939
+ const l = r.nodeProperties.map((i) => {
937
940
  let u = `${i.name}: ${i.type}`;
938
941
  return i.enumValues && i.enumValues.length > 0 && (u += ` (values: ${i.enumValues.join(", ")})`), i.range && (u += ` (range: ${i.range.min}-${i.range.max})`), u;
939
942
  });
@@ -942,11 +945,11 @@ const ie = m.enum(["nodeCount", "edgeCount", "currentLayout", "all", "summary"])
942
945
  message: `Node properties:
943
946
  ${l.map((i) => `- ${i}`).join(`
944
947
  `)}`,
945
- data: { nodeProperties: a.nodeProperties }
948
+ data: { nodeProperties: r.nodeProperties }
946
949
  });
947
950
  }
948
951
  case "edgeProperties": {
949
- const l = a.edgeProperties.map((i) => {
952
+ const l = r.edgeProperties.map((i) => {
950
953
  let u = `${i.name}: ${i.type}`;
951
954
  return i.enumValues && i.enumValues.length > 0 && (u += ` (values: ${i.enumValues.join(", ")})`), i.range && (u += ` (range: ${i.range.min}-${i.range.max})`), u;
952
955
  });
@@ -959,36 +962,36 @@ ${l.map((i) => `- ${i}`).join(`
959
962
  message: `Edge properties:
960
963
  ${l.map((i) => `- ${i}`).join(`
961
964
  `)}`,
962
- data: { edgeProperties: a.edgeProperties }
965
+ data: { edgeProperties: r.edgeProperties }
963
966
  });
964
967
  }
965
968
  case "all": {
966
- let i = a.nodeProperties.find((g) => g.name === "type")?.enumValues ?? [];
969
+ let i = r.nodeProperties.find((g) => g.name === "type")?.enumValues ?? [];
967
970
  i.length === 0 && (i = n(o.nodes.values(), "type"));
968
- let c = a.edgeProperties.find((g) => g.name === "type")?.enumValues ?? [];
969
- c.length === 0 && (c = n(o.edges.values(), "type"));
970
- const p = a.nodeProperties.map((g) => g.name), d = a.edgeProperties.map((g) => g.name);
971
+ let d = r.edgeProperties.find((g) => g.name === "type")?.enumValues ?? [];
972
+ d.length === 0 && (d = n(o.edges.values(), "type"));
973
+ const p = r.nodeProperties.map((g) => g.name), m = r.edgeProperties.map((g) => g.name);
971
974
  let h = `Graph Schema Summary:
972
- - ${a.nodeCount} nodes with ${a.nodeProperties.length} properties
973
- - ${a.edgeCount} edges with ${a.edgeProperties.length} properties`;
975
+ - ${r.nodeCount} nodes with ${r.nodeProperties.length} properties
976
+ - ${r.edgeCount} edges with ${r.edgeProperties.length} properties`;
974
977
  return i.length > 0 && (h += `
975
978
 
976
- Node types: ${i.join(", ")}`), c.length > 0 && (h += `
979
+ Node types: ${i.join(", ")}`), d.length > 0 && (h += `
977
980
 
978
- Edge types: ${c.join(", ")}`), p.length > 0 && (h += `
981
+ Edge types: ${d.join(", ")}`), p.length > 0 && (h += `
979
982
 
980
- Node properties: ${p.join(", ")}`), d.length > 0 && (h += `
983
+ Node properties: ${p.join(", ")}`), m.length > 0 && (h += `
981
984
 
982
- Edge properties: ${d.join(", ")}`), Promise.resolve({
985
+ Edge properties: ${m.join(", ")}`), Promise.resolve({
983
986
  success: !0,
984
987
  message: h,
985
988
  data: {
986
- nodeCount: a.nodeCount,
987
- edgeCount: a.edgeCount,
989
+ nodeCount: r.nodeCount,
990
+ edgeCount: r.edgeCount,
988
991
  nodeTypes: i,
989
- edgeTypes: c,
990
- nodeProperties: a.nodeProperties,
991
- edgeProperties: a.edgeProperties
992
+ edgeTypes: d,
993
+ nodeProperties: r.nodeProperties,
994
+ edgeProperties: r.edgeProperties
992
995
  }
993
996
  });
994
997
  }
@@ -998,19 +1001,19 @@ Edge properties: ${d.join(", ")}`), Promise.resolve({
998
1001
  message: `Unknown schema query type: ${String(t)}`
999
1002
  });
1000
1003
  }
1001
- } catch (r) {
1004
+ } catch (s) {
1002
1005
  return Promise.resolve({
1003
1006
  success: !1,
1004
- message: `Failed to get schema: ${r.message}`
1007
+ message: `Failed to get schema: ${s.message}`
1005
1008
  });
1006
1009
  }
1007
1010
  }
1008
- }, me = m.string().describe("Layout algorithm type (e.g., 'circular', 'ngraph', 'random', 'spiral', 'd3')"), pe = m.enum(["2d", "3d"]).describe("Dimension mode: '2d' or '3d'"), he = {
1011
+ }, Ce = c.string().describe("Layout algorithm type (e.g., 'circular', 'ngraph', 'random', 'spiral', 'd3')"), $e = c.enum(["2d", "3d"]).describe("Dimension mode: '2d' or '3d'"), xe = {
1009
1012
  name: "setLayout",
1010
1013
  description: "Change the graph layout algorithm. Common layouts include 'circular' (nodes in a circle), 'ngraph' (force-directed physics), 'random', 'spiral', 'shell', 'd3' (D3 force simulation), 'spring', 'planar', 'spectral', and 'forceatlas2'.",
1011
- parameters: m.object({
1012
- type: me,
1013
- options: m.record(m.unknown()).optional().describe("Additional layout-specific options")
1014
+ parameters: c.object({
1015
+ type: Ce,
1016
+ options: c.record(c.unknown()).optional().describe("Additional layout-specific options")
1014
1017
  }),
1015
1018
  examples: [
1016
1019
  { input: "Use circular layout", params: { type: "circular" } },
@@ -1020,16 +1023,16 @@ Edge properties: ${d.join(", ")}`), Promise.resolve({
1020
1023
  { input: "Use D3 force layout", params: { type: "d3" } },
1021
1024
  { input: "Shell layout", params: { type: "shell" } }
1022
1025
  ],
1023
- async execute(s, e) {
1024
- const { type: t, options: r = {} } = e;
1026
+ async execute(a, e) {
1027
+ const { type: t, options: s = {} } = e;
1025
1028
  try {
1026
- return await s.setLayout(t, r), {
1029
+ return await a.setLayout(t, s), {
1027
1030
  success: !0,
1028
1031
  message: `Layout changed to "${t}". The graph is now being rearranged.`,
1029
1032
  data: { layoutType: t }
1030
1033
  };
1031
- } catch (a) {
1032
- const o = a.message;
1034
+ } catch (r) {
1035
+ const o = r.message;
1033
1036
  return o.includes("not found") || o.includes("unknown") || o.includes("invalid") ? {
1034
1037
  success: !1,
1035
1038
  message: `Invalid layout type "${t}". Try 'circular', 'ngraph', 'random', 'spiral', 'shell', or 'd3'.`
@@ -1039,11 +1042,11 @@ Edge properties: ${d.join(", ")}`), Promise.resolve({
1039
1042
  };
1040
1043
  }
1041
1044
  }
1042
- }, ge = {
1045
+ }, Me = {
1043
1046
  name: "setDimension",
1044
1047
  description: "Switch between 2D and 3D graph visualization modes. In 2D mode, nodes are arranged on a flat plane. In 3D mode, nodes can be positioned in three-dimensional space.",
1045
- parameters: m.object({
1046
- dimension: pe
1048
+ parameters: c.object({
1049
+ dimension: $e
1047
1050
  }),
1048
1051
  examples: [
1049
1052
  { input: "Switch to 2D view", params: { dimension: "2d" } },
@@ -1051,27 +1054,27 @@ Edge properties: ${d.join(", ")}`), Promise.resolve({
1051
1054
  { input: "Make it flat", params: { dimension: "2d" } },
1052
1055
  { input: "Enable 3D mode", params: { dimension: "3d" } }
1053
1056
  ],
1054
- async execute(s, e) {
1057
+ async execute(a, e) {
1055
1058
  const { dimension: t } = e;
1056
1059
  try {
1057
- const r = t === "2d", a = r ? "2D" : "3D";
1058
- return await s.setViewMode(r ? "2d" : "3d"), {
1060
+ const s = t === "2d", r = s ? "2D" : "3D";
1061
+ return await a.setViewMode(s ? "2d" : "3d"), {
1059
1062
  success: !0,
1060
- message: `Switched to ${a} mode. The graph will now be displayed ${r ? "on a flat plane" : "in three-dimensional space"}.`,
1061
- data: { dimension: a, is2D: r }
1063
+ message: `Switched to ${r} mode. The graph will now be displayed ${s ? "on a flat plane" : "in three-dimensional space"}.`,
1064
+ data: { dimension: r, is2D: s }
1062
1065
  };
1063
- } catch (r) {
1066
+ } catch (s) {
1064
1067
  return {
1065
1068
  success: !1,
1066
- message: `Failed to change dimension: ${r.message}`
1069
+ message: `Failed to change dimension: ${s.message}`
1067
1070
  };
1068
1071
  }
1069
1072
  }
1070
- }, fe = m.enum(["vr", "ar", "exit"]).describe("VR for virtual reality, AR for augmented reality, exit to return to normal view"), ye = {
1073
+ }, Pe = c.enum(["vr", "ar", "exit"]).describe("VR for virtual reality, AR for augmented reality, exit to return to normal view"), Ae = {
1071
1074
  name: "setImmersiveMode",
1072
1075
  description: "Enter or exit VR/AR immersive modes using WebXR. Use 'vr' for virtual reality (headset), 'ar' for augmented reality (pass-through or mobile AR), or 'exit' to return to normal desktop view.",
1073
- parameters: m.object({
1074
- mode: fe
1076
+ parameters: c.object({
1077
+ mode: Pe
1075
1078
  }),
1076
1079
  examples: [
1077
1080
  { input: "Enter VR mode", params: { mode: "vr" } },
@@ -1082,25 +1085,25 @@ Edge properties: ${d.join(", ")}`), Promise.resolve({
1082
1085
  { input: "Show augmented reality view", params: { mode: "ar" } },
1083
1086
  { input: "Go back to normal view", params: { mode: "exit" } }
1084
1087
  ],
1085
- async execute(s, e) {
1088
+ async execute(a, e) {
1086
1089
  const { mode: t } = e;
1087
1090
  try {
1088
1091
  if (t === "exit") {
1089
- const n = s.exitImmersiveMode;
1090
- return n && await n.call(s), {
1092
+ const n = a.exitImmersiveMode;
1093
+ return n && await n.call(a), {
1091
1094
  success: !0,
1092
1095
  message: "Exited immersive mode, returned to normal view."
1093
1096
  };
1094
1097
  }
1095
- const { getXRHelper: r } = s, a = r?.call(s);
1096
- if (!a)
1098
+ const { getXRHelper: s } = a, r = s?.call(a);
1099
+ if (!r)
1097
1100
  return {
1098
1101
  success: !1,
1099
1102
  message: `WebXR is not available. ${t.toUpperCase()} mode requires a WebXR-capable browser and device.`
1100
1103
  };
1101
1104
  if (t === "vr") {
1102
- const { enterVR: n } = a;
1103
- return n ? (await n.call(a), {
1105
+ const { enterVR: n } = r;
1106
+ return n ? (await n.call(r), {
1104
1107
  success: !0,
1105
1108
  message: "Entering VR mode. Put on your headset to view the graph in virtual reality."
1106
1109
  }) : {
@@ -1108,96 +1111,96 @@ Edge properties: ${d.join(", ")}`), Promise.resolve({
1108
1111
  message: "VR mode is not supported on this device or browser."
1109
1112
  };
1110
1113
  }
1111
- const { enterAR: o } = a;
1112
- return o ? (await o.call(a), {
1114
+ const { enterAR: o } = r;
1115
+ return o ? (await o.call(r), {
1113
1116
  success: !0,
1114
1117
  message: "Entering AR mode. Point your device to see the graph in augmented reality."
1115
1118
  }) : {
1116
1119
  success: !1,
1117
1120
  message: "AR mode is not supported on this device or browser."
1118
1121
  };
1119
- } catch (r) {
1122
+ } catch (s) {
1120
1123
  return {
1121
1124
  success: !1,
1122
- message: `Failed to enter ${t.toUpperCase()} mode: ${r.message}`
1125
+ message: `Failed to enter ${t.toUpperCase()} mode: ${s.message}`
1123
1126
  };
1124
1127
  }
1125
1128
  }
1126
- }, ve = m.object({
1127
- color: m.string().optional().describe("Color for the node (e.g., '#ff0000', 'red')"),
1128
- size: m.number().positive().optional().describe("Size of the node (default is 1)"),
1129
- shape: m.string().optional().describe("Shape type (e.g., 'sphere', 'box', 'cylinder')"),
1130
- glowColor: m.string().optional().describe("Glow effect color"),
1131
- glowStrength: m.number().positive().optional().describe("Glow effect strength. One strength is drawn at a time for the whole scene"),
1132
- outlineColor: m.string().optional().describe("Outline color"),
1133
- outlineWidth: m.number().positive().optional().describe(
1129
+ }, Ee = c.object({
1130
+ color: c.string().optional().describe("Color for the node (e.g., '#ff0000', 'red')"),
1131
+ size: c.number().positive().optional().describe("Size of the node (default is 1)"),
1132
+ shape: c.string().optional().describe("Shape type (e.g., 'sphere', 'box', 'cylinder')"),
1133
+ glowColor: c.string().optional().describe("Glow effect color"),
1134
+ glowStrength: c.number().positive().optional().describe("Glow effect strength. One strength is drawn at a time for the whole scene"),
1135
+ outlineColor: c.string().optional().describe("Outline color"),
1136
+ outlineWidth: c.number().positive().optional().describe(
1134
1137
  "Outline width. Not drawn: every outline in the scene is stroked at one width, so asking for this is answered with the reason rather than applied"
1135
1138
  ),
1136
- enabled: m.boolean().optional().describe("Whether the node is visible")
1137
- }).describe("Style properties for nodes"), be = m.object({
1138
- color: m.string().optional().describe("Color for the edge line (e.g., '#00ff00', 'green')"),
1139
- width: m.number().positive().optional().describe("Width of the edge line"),
1140
- lineType: m.string().optional().describe("Line pattern (e.g., 'solid', 'dash', 'dot')"),
1141
- arrowColor: m.string().optional().describe("Color for the arrow head"),
1142
- arrowSize: m.number().positive().optional().describe("Size of the arrow head"),
1143
- arrowOpacity: m.number().min(0).max(1).optional().describe("Opacity of the arrow head, 0 to 1"),
1144
- enabled: m.boolean().optional().describe("Whether the edge is visible")
1145
- }).describe("Style properties for edges"), we = { by: "plugin", name: "graphty-ai" };
1146
- function Se(s) {
1139
+ enabled: c.boolean().optional().describe("Whether the node is visible")
1140
+ }).describe("Style properties for nodes"), Te = c.object({
1141
+ color: c.string().optional().describe("Color for the edge line (e.g., '#00ff00', 'green')"),
1142
+ width: c.number().positive().optional().describe("Width of the edge line"),
1143
+ lineType: c.string().optional().describe("Line pattern (e.g., 'solid', 'dash', 'dot')"),
1144
+ arrowColor: c.string().optional().describe("Color for the arrow head"),
1145
+ arrowSize: c.number().positive().optional().describe("Size of the arrow head"),
1146
+ arrowOpacity: c.number().min(0).max(1).optional().describe("Opacity of the arrow head, 0 to 1"),
1147
+ enabled: c.boolean().optional().describe("Whether the edge is visible")
1148
+ }).describe("Style properties for edges"), Ne = { by: "plugin", name: "graphty-ai" };
1149
+ function ke(a) {
1147
1150
  const e = {}, t = [];
1148
- return s.color !== void 0 && (e["node.color"] = s.color), s.size !== void 0 && (e["node.size"] = s.size), s.shape !== void 0 && (e["node.shape"] = s.shape), s.glowColor !== void 0 && (e["node.glow"] = s.glowColor), s.glowStrength !== void 0 && (e["node.glowStrength"] = s.glowStrength), s.outlineColor !== void 0 && (e["node.outline"] = s.outlineColor), s.enabled === !1 && (e["node.opacity"] = 0), s.outlineWidth !== void 0 && t.push({ property: "outlineWidth", reason: H }), { set: e, unsupported: t };
1151
+ return a.color !== void 0 && (e["node.color"] = a.color), a.size !== void 0 && (e["node.size"] = a.size), a.shape !== void 0 && (e["node.shape"] = a.shape), a.glowColor !== void 0 && (e["node.glow"] = a.glowColor), a.glowStrength !== void 0 && (e["node.glowStrength"] = a.glowStrength), a.outlineColor !== void 0 && (e["node.outline"] = a.outlineColor), a.enabled === !1 && (e["node.opacity"] = 0), a.outlineWidth !== void 0 && t.push({ property: "outlineWidth", reason: ee }), { set: e, unsupported: t };
1149
1152
  }
1150
- function Ce(s) {
1153
+ function Ie(a) {
1151
1154
  const e = {};
1152
- return s.color !== void 0 && (e["edge.color"] = s.color), s.width !== void 0 && (e["edge.width"] = s.width), s.lineType !== void 0 && (e["edge.style"] = s.lineType), s.enabled === !1 && (e["edge.opacity"] = 0), s.arrowColor !== void 0 && (e["edge.arrowHeadColor"] = s.arrowColor), s.arrowSize !== void 0 && (e["edge.arrowHeadSize"] = s.arrowSize), s.arrowOpacity !== void 0 && (e["edge.arrowHeadOpacity"] = s.arrowOpacity), { set: e, unsupported: [] };
1155
+ return a.color !== void 0 && (e["edge.color"] = a.color), a.width !== void 0 && (e["edge.width"] = a.width), a.lineType !== void 0 && (e["edge.style"] = a.lineType), a.enabled === !1 && (e["edge.opacity"] = 0), a.arrowColor !== void 0 && (e["edge.arrowHeadColor"] = a.arrowColor), a.arrowSize !== void 0 && (e["edge.arrowHeadSize"] = a.arrowSize), a.arrowOpacity !== void 0 && (e["edge.arrowHeadOpacity"] = a.arrowOpacity), { set: e, unsupported: [] };
1153
1156
  }
1154
- const xe = /* @__PURE__ */ new Set(["", "*", "all", "*.*", "true"]);
1155
- function $e(s) {
1156
- return !s || xe.has(s.toLowerCase().trim());
1157
+ const Re = /* @__PURE__ */ new Set(["", "*", "all", "*.*", "true"]);
1158
+ function De(a) {
1159
+ return !a || Re.has(a.toLowerCase().trim());
1157
1160
  }
1158
- function L(s, e, t, r) {
1161
+ function _(a, e, t, s) {
1159
1162
  return {
1160
- name: s,
1163
+ name: a,
1161
1164
  target: e,
1162
1165
  kind: "custom",
1163
- source: we,
1164
- selector: $e(t) ? { match: "everything" } : { match: "expression", where: t.replace(/"/g, "'") },
1165
- set: r
1166
+ source: Ne,
1167
+ selector: De(t) ? { match: "everything" } : { match: "expression", where: t.replace(/"/g, "'") },
1168
+ set: s
1166
1169
  };
1167
1170
  }
1168
- function z(s) {
1169
- return Z(s) ? `${s.message} (${s.code})` : s instanceof Error ? s.message : String(s);
1171
+ function K(a) {
1172
+ return oe(a) ? `${a.message} (${a.code})` : a instanceof Error ? a.message : String(a);
1170
1173
  }
1171
- async function j(s, e, t, r) {
1172
- const { styles: a } = s.getSession(), o = a.validate(e);
1174
+ async function W(a, e, t, s) {
1175
+ const { styles: r } = a.getSession(), o = r.validate(e);
1173
1176
  if (!o.ok)
1174
1177
  return {
1175
1178
  success: !1,
1176
- message: `That ${r} style could not be applied: ${o.errors.map((n) => n.message).join(" ")}`
1179
+ message: `That ${s} style could not be applied: ${o.errors.map((n) => n.message).join(" ")}`
1177
1180
  };
1178
1181
  try {
1179
- const n = await a.add(e), l = t.map(({ property: u, reason: c }) => ` ${u} was not applied: ${c}`).join(""), i = o.unresolvedPaths.length === 0 ? "" : ` Nothing in this graph answers ${o.unresolvedPaths.join(", ")} yet, so the layer may paint nothing until it does.`;
1182
+ const n = await r.add(e), l = t.map(({ property: u, reason: d }) => ` ${u} was not applied: ${d}`).join(""), i = o.unresolvedPaths.length === 0 ? "" : ` Nothing in this graph answers ${o.unresolvedPaths.join(", ")} yet, so the layer may paint nothing until it does.`;
1180
1183
  return {
1181
1184
  success: !0,
1182
- message: `Added the ${r} style layer "${n.name}".${l}${i}`,
1185
+ message: `Added the ${s} style layer "${n.name}".${l}${i}`,
1183
1186
  data: { layerId: n.id, layerName: n.name }
1184
1187
  };
1185
1188
  } catch (n) {
1186
1189
  return {
1187
1190
  success: !1,
1188
- message: `That ${r} style could not be applied: ${z(n)}`
1191
+ message: `That ${s} style could not be applied: ${K(n)}`
1189
1192
  };
1190
1193
  }
1191
1194
  }
1192
- const Me = {
1195
+ const Le = {
1193
1196
  name: "findAndStyleNodes",
1194
1197
  description: `Style the nodes matching a selector by adding a style layer. Use an empty selector to match every node. A node's own fields are published under 'data.', so write 'data.type == "server"'. Styles include color, size, shape, glow color and outline color.`,
1195
- parameters: m.object({
1196
- selector: m.string().describe(
1198
+ parameters: c.object({
1199
+ selector: c.string().describe(
1197
1200
  `Expression matching nodes (empty string matches all). A record's own fields live under 'data.', so write 'data.type == "server"'.`
1198
1201
  ),
1199
- style: ve,
1200
- layerName: m.string().optional().describe("Name for this style layer (for later removal)")
1202
+ style: Ee,
1203
+ layerName: c.string().optional().describe("Name for this style layer (for later removal)")
1201
1204
  }),
1202
1205
  examples: [
1203
1206
  {
@@ -1221,23 +1224,23 @@ const Me = {
1221
1224
  params: { selector: "", style: { shape: "box" }, layerName: "box-shapes" }
1222
1225
  }
1223
1226
  ],
1224
- async execute(s, e) {
1227
+ async execute(a, e) {
1225
1228
  const {
1226
1229
  selector: t,
1227
- style: r,
1228
- layerName: a = `ai-node-style-${Date.now()}`
1229
- } = e, { set: o, unsupported: n } = Se(r);
1230
- return j(s, L(a, "node", t, o), n, "node");
1230
+ style: s,
1231
+ layerName: r = `ai-node-style-${Date.now()}`
1232
+ } = e, { set: o, unsupported: n } = ke(s);
1233
+ return W(a, _(r, "node", t, o), n, "node");
1231
1234
  }
1232
- }, Pe = {
1235
+ }, je = {
1233
1236
  name: "findAndStyleEdges",
1234
1237
  description: "Style the edges matching a selector by adding a style layer. Use an empty selector to match every edge. An edge's own fields are published under 'data.', so write 'data.weight > `0.5`'. Styles include color, width and line pattern.",
1235
- parameters: m.object({
1236
- selector: m.string().describe(
1238
+ parameters: c.object({
1239
+ selector: c.string().describe(
1237
1240
  "Expression matching edges (empty string matches all). A record's own fields live under 'data.', so write 'data.weight > `0.5`'."
1238
1241
  ),
1239
- style: be,
1240
- layerName: m.string().optional().describe("Name for this style layer (for later removal)")
1242
+ style: Te,
1243
+ layerName: c.string().optional().describe("Name for this style layer (for later removal)")
1241
1244
  }),
1242
1245
  examples: [
1243
1246
  {
@@ -1257,29 +1260,29 @@ const Me = {
1257
1260
  params: { selector: "", style: { lineType: "dash" }, layerName: "dashed" }
1258
1261
  }
1259
1262
  ],
1260
- async execute(s, e) {
1263
+ async execute(a, e) {
1261
1264
  const {
1262
1265
  selector: t,
1263
- style: r,
1264
- layerName: a = `ai-edge-style-${Date.now()}`
1265
- } = e, { set: o, unsupported: n } = Ce(r);
1266
- return j(s, L(a, "edge", t, o), n, "edge");
1266
+ style: s,
1267
+ layerName: r = `ai-edge-style-${Date.now()}`
1268
+ } = e, { set: o, unsupported: n } = Ie(s);
1269
+ return W(a, _(r, "edge", t, o), n, "edge");
1267
1270
  }
1268
- }, Ee = {
1271
+ }, ze = {
1269
1272
  name: "clearStyles",
1270
1273
  description: "Clear styles added by AI commands. Specify a layerName to clear a specific style, or leave empty to clear all AI-added styles.",
1271
- parameters: m.object({
1272
- layerName: m.string().optional().describe("Name of the style layer to clear (clears all if not specified)")
1274
+ parameters: c.object({
1275
+ layerName: c.string().optional().describe("Name of the style layer to clear (clears all if not specified)")
1273
1276
  }),
1274
1277
  examples: [
1275
1278
  { input: "Clear all styling", params: {} },
1276
1279
  { input: "Remove red node styling", params: { layerName: "red-nodes" } }
1277
1280
  ],
1278
- async execute(s, e) {
1279
- const { layerName: t } = e, { styles: r } = s.getSession();
1281
+ async execute(a, e) {
1282
+ const { layerName: t } = e, { styles: s } = a.getSession();
1280
1283
  try {
1281
1284
  if (t === void 0) {
1282
- const o = await r.removeBySource(
1285
+ const o = await s.removeBySource(
1283
1286
  (n) => n.by === "plugin" && n.name === "graphty-ai"
1284
1287
  );
1285
1288
  return {
@@ -1288,42 +1291,42 @@ const Me = {
1288
1291
  data: { clearedCount: o.length }
1289
1292
  };
1290
1293
  }
1291
- const a = r.list().filter(
1294
+ const r = s.list().filter(
1292
1295
  (o) => o.name === t && o.source.by === "plugin" && o.source.name === "graphty-ai"
1293
1296
  );
1294
- if (a.length === 0)
1297
+ if (r.length === 0)
1295
1298
  return {
1296
1299
  success: !0,
1297
1300
  message: `Style layer "${t}" not found (may already be cleared).`
1298
1301
  };
1299
- for (const o of a)
1300
- await r.remove(o.id);
1302
+ for (const o of r)
1303
+ await s.remove(o.id);
1301
1304
  return {
1302
1305
  success: !0,
1303
1306
  message: `Cleared style layer "${t}".`,
1304
- data: { clearedCount: a.length }
1307
+ data: { clearedCount: r.length }
1305
1308
  };
1306
- } catch (a) {
1309
+ } catch (r) {
1307
1310
  return {
1308
1311
  success: !1,
1309
- message: `Failed to clear styles: ${z(a)}`
1312
+ message: `Failed to clear styles: ${K(r)}`
1310
1313
  };
1311
1314
  }
1312
1315
  }
1313
1316
  };
1314
- function x() {
1317
+ function E() {
1315
1318
  return [
1316
- ...X.map((s) => s.id),
1317
- ...G().map((s) => s.id)
1319
+ ...se.map((a) => a.id),
1320
+ ...Q().map((a) => a.id)
1318
1321
  ];
1319
1322
  }
1320
- const Te = m.string().describe(
1323
+ const qe = c.string().describe(
1321
1324
  "Named camera view. The element ships 'fitToGraph', 'topView', 'sideView', 'frontView' and 'isometric'; an application may have registered others."
1322
- ), $ = m.object({
1323
- x: m.number(),
1324
- y: m.number(),
1325
- z: m.number()
1326
- }).describe("3D position coordinates"), Ae = {
1325
+ ), T = c.object({
1326
+ x: c.number(),
1327
+ y: c.number(),
1328
+ z: c.number()
1329
+ }).describe("3D position coordinates"), Ue = {
1327
1330
  name: "setCameraPosition",
1328
1331
  /*
1329
1332
  * READ AT PROMPT TIME, NOT AT IMPORT TIME. The description is what the system prompt shows
@@ -1334,13 +1337,13 @@ const Te = m.string().describe(
1334
1337
  * registered.
1335
1338
  */
1336
1339
  get description() {
1337
- return `Set the camera position using a preset (${x().join(", ")}) or specific coordinates. Presets automatically calculate the best view for the current graph. Animation can be enabled for smooth transitions.`;
1340
+ return `Set the camera position using a preset (${E().join(", ")}) or specific coordinates. Presets automatically calculate the best view for the current graph. Animation can be enabled for smooth transitions.`;
1338
1341
  },
1339
- parameters: m.object({
1340
- preset: Te.optional().describe("Named camera preset to apply"),
1341
- position: $.optional().describe("Custom camera position (3D only)"),
1342
- target: $.optional().describe("Point the camera should look at (3D only)"),
1343
- animate: m.boolean().optional().describe("Whether to animate the camera transition (default: true)")
1342
+ parameters: c.object({
1343
+ preset: qe.optional().describe("Named camera preset to apply"),
1344
+ position: T.optional().describe("Custom camera position (3D only)"),
1345
+ target: T.optional().describe("Point the camera should look at (3D only)"),
1346
+ animate: c.boolean().optional().describe("Whether to animate the camera transition (default: true)")
1344
1347
  }),
1345
1348
  examples: [
1346
1349
  { input: "Show from top", params: { preset: "topView", animate: !0 } },
@@ -1353,37 +1356,37 @@ const Te = m.string().describe(
1353
1356
  params: { position: { x: 10, y: 20, z: 30 }, target: { x: 0, y: 0, z: 0 } }
1354
1357
  }
1355
1358
  ],
1356
- async execute(s, e) {
1359
+ async execute(a, e) {
1357
1360
  const {
1358
1361
  preset: t,
1359
- position: r,
1360
- target: a,
1362
+ position: s,
1363
+ target: r,
1361
1364
  animate: o = !0
1362
1365
  } = e;
1363
1366
  try {
1364
- if (!t && !r)
1367
+ if (!t && !s)
1365
1368
  return {
1366
1369
  success: !1,
1367
1370
  message: "Either 'preset' or 'position' must be provided."
1368
1371
  };
1369
1372
  if (t)
1370
- return B(t) ? (await s.setCameraState({ preset: t }, { animate: o, description: `Setting camera to ${t} view` }), {
1373
+ return te(t) ? (await a.setCameraState({ preset: t }, { animate: o, description: `Setting camera to ${t} view` }), {
1371
1374
  success: !0,
1372
1375
  message: `Camera moved to ${t} view${o ? " (animated)" : ""}.`,
1373
1376
  data: { preset: t, animated: o }
1374
1377
  }) : {
1375
1378
  success: !1,
1376
- message: `Unknown camera view "${t}". Available views: ${x().join(", ")}.`
1379
+ message: `Unknown camera view "${t}". Available views: ${E().join(", ")}.`
1377
1380
  };
1378
- if (r) {
1379
- const n = { position: r };
1380
- return a && (n.target = a), await s.setCameraState(n, {
1381
+ if (s) {
1382
+ const n = { position: s };
1383
+ return r && (n.target = r), await a.setCameraState(n, {
1381
1384
  animate: o,
1382
1385
  description: "Moving camera to specified position"
1383
1386
  }), {
1384
1387
  success: !0,
1385
- message: `Camera moved to position (${r.x}, ${r.y}, ${r.z})${o ? " (animated)" : ""}.`,
1386
- data: { position: r, target: a, animated: o }
1388
+ message: `Camera moved to position (${s.x}, ${s.y}, ${s.z})${o ? " (animated)" : ""}.`,
1389
+ data: { position: s, target: r, animated: o }
1387
1390
  };
1388
1391
  }
1389
1392
  return {
@@ -1398,227 +1401,361 @@ const Te = m.string().describe(
1398
1401
  }
1399
1402
  }
1400
1403
  };
1401
- function Ne(s, e) {
1402
- const t = s.getDataManager(), { nodes: r } = t, a = [];
1404
+ function Ve(a, e) {
1405
+ const t = a.getDataManager(), { nodes: s } = t, r = [];
1403
1406
  if (!e || e.length === 0) {
1404
- for (const [o] of r)
1405
- a.push(String(o));
1406
- return a;
1407
+ for (const [o] of s)
1408
+ r.push(String(o));
1409
+ return r;
1407
1410
  }
1408
1411
  try {
1409
1412
  const n = `[?${e.replace(/"/g, "'")}]`;
1410
- for (const [l, i] of r) {
1411
- const { data: u } = i, c = W.search([u], n);
1412
- Array.isArray(c) && c.length > 0 && a.push(String(l));
1413
+ for (const [l, i] of s) {
1414
+ const { data: u } = i, d = ae.search([u], n);
1415
+ Array.isArray(d) && d.length > 0 && r.push(String(l));
1413
1416
  }
1414
1417
  } catch {
1415
1418
  return [];
1416
1419
  }
1417
- return a;
1420
+ return r;
1418
1421
  }
1419
- const ke = {
1422
+ const Fe = {
1420
1423
  name: "zoomToNodes",
1421
1424
  description: "Zoom the camera to fit specific nodes in view. Use a JMESPath selector to choose which nodes to focus on, or leave empty to fit all nodes. Optionally add padding around the nodes.",
1422
- parameters: m.object({
1423
- selector: m.string().optional().describe("JMESPath expression to match nodes (empty matches all)"),
1424
- animate: m.boolean().optional().describe("Whether to animate the zoom (default: true)"),
1425
- padding: m.number().optional().describe("Extra padding around nodes (default: 1.2 = 20% padding)")
1425
+ parameters: c.object({
1426
+ selector: c.string().optional().describe("JMESPath expression to match nodes (empty matches all)"),
1427
+ animate: c.boolean().optional().describe("Whether to animate the zoom (default: true)"),
1428
+ padding: c.number().optional().describe("Extra padding around nodes (default: 1.2 = 20% padding)")
1426
1429
  }),
1427
1430
  examples: [
1428
1431
  { input: "Zoom to fit all nodes", params: { selector: "" } },
1429
1432
  { input: "Zoom to server nodes", params: { selector: "type == 'server'" } },
1430
1433
  { input: "Fit graph with more padding", params: { selector: "", padding: 1.5 } }
1431
1434
  ],
1432
- async execute(s, e) {
1433
- const { selector: t = "", animate: r = !0 } = e;
1435
+ async execute(a, e) {
1436
+ const { selector: t = "", animate: s = !0 } = e;
1434
1437
  try {
1435
- const a = Ne(s, t);
1436
- if (a.length === 0 && t && t.length > 0)
1438
+ const r = Ve(a, t);
1439
+ if (r.length === 0 && t && t.length > 0)
1437
1440
  return {
1438
1441
  success: !0,
1439
1442
  message: `No nodes matched the selector "${t}".`,
1440
1443
  affectedNodes: []
1441
1444
  };
1442
- await s.applyCameraView("fitToGraph", {
1443
- ...t && t.length > 0 ? { scope: { nodes: a } } : {},
1444
- animate: r,
1445
+ await a.applyCameraView("fitToGraph", {
1446
+ ...t && t.length > 0 ? { scope: { nodes: r } } : {},
1447
+ animate: s,
1445
1448
  description: `Zooming to fit ${t ? "matching nodes" : "all nodes"}`
1446
1449
  });
1447
- const o = t ? a.length : s.getNodeCount();
1450
+ const o = t ? r.length : a.getNodeCount();
1448
1451
  return {
1449
1452
  success: !0,
1450
1453
  message: `Zoomed to fit ${o} node(s)${t ? ` matching "${t}"` : ""}.`,
1451
- affectedNodes: a,
1452
- data: { nodeCount: o, animated: r }
1454
+ affectedNodes: r,
1455
+ data: { nodeCount: o, animated: s }
1456
+ };
1457
+ } catch (r) {
1458
+ return {
1459
+ success: !1,
1460
+ message: `Failed to zoom to nodes: ${r.message}`
1461
+ };
1462
+ }
1463
+ }
1464
+ }, N = c.object({
1465
+ namespace: c.string().describe("The namespace of the algorithm (e.g., 'graphty')"),
1466
+ type: c.string().describe("The type of algorithm to run (e.g., 'degree', 'pagerank')"),
1467
+ options: c.record(c.string(), c.unknown()).optional().describe(
1468
+ "The algorithm's options, by name (e.g., { source: 'a', target: 'b' } for dijkstra, { dampingFactor: 0.9 } for pagerank). An unknown name or an out-of-range value is refused."
1469
+ )
1470
+ }), k = 50, I = c.object({
1471
+ namespace: c.string().optional().describe("Optional namespace to filter algorithms by")
1472
+ }), Oe = {
1473
+ name: "runAlgorithm",
1474
+ description: "Run a graph algorithm to analyze the graph structure, optionally with options such as a source and target. Returns a bounded summary: the top 10 elements and the value range for a metric, the group sizes for a partition, the route for a path, plus any graph-level values.",
1475
+ parameters: N,
1476
+ examples: [
1477
+ {
1478
+ input: "Calculate the degree of each node",
1479
+ params: { namespace: "graphty", type: "degree" }
1480
+ },
1481
+ {
1482
+ input: "Run pagerank algorithm",
1483
+ params: { namespace: "graphty", type: "pagerank" }
1484
+ },
1485
+ {
1486
+ input: "Compute centrality metrics",
1487
+ params: { namespace: "graphty", type: "degree" }
1488
+ },
1489
+ {
1490
+ input: "Find the shortest path from node A to node B",
1491
+ params: { namespace: "graphty", type: "dijkstra", options: { source: "A", target: "B" } }
1492
+ }
1493
+ ],
1494
+ async execute(a, e) {
1495
+ const t = N.safeParse(e);
1496
+ if (!t.success)
1497
+ return {
1498
+ success: !1,
1499
+ message: `Invalid parameters: ${t.error.message}`
1500
+ };
1501
+ const { namespace: s, type: r, options: o } = t.data;
1502
+ try {
1503
+ if (!x.get(a, s, r)) {
1504
+ const m = x.getRegisteredAlgorithms(s), h = m.length > 0 ? `Available in namespace '${s}': ${m.map((g) => g.split(":")[1]).join(", ")}` : `No algorithms found in namespace '${s}'. Use listAlgorithms to see available options.`;
1505
+ return {
1506
+ success: !1,
1507
+ message: `Algorithm not found: ${s}:${r}. ${h}`
1508
+ };
1509
+ }
1510
+ const l = (s === "graphty" ? re(r) : void 0) ?? P(`${s}:${r}`) ?? P(r);
1511
+ if (l === void 0)
1512
+ return await a.runAlgorithm(s, r, { algorithmOptions: o }), {
1513
+ success: !0,
1514
+ message: `Successfully ran ${s}:${r} algorithm. Results are now available in node data.`,
1515
+ data: { namespace: s, type: r, nodeCount: a.getNodeCount() }
1516
+ };
1517
+ const i = "params" in l ? l.params : {}, u = await a.run(l.descriptor.key, { ...i, ...o }), d = {
1518
+ namespace: s,
1519
+ type: r,
1520
+ algorithm: l.descriptor.key,
1521
+ shape: u.shape,
1522
+ summary: u.summary(),
1523
+ graph: u.graph
1453
1524
  };
1454
- } catch (a) {
1525
+ let p;
1526
+ if (u.shape === "path") {
1527
+ const m = u.ranking("order").map((h) => String(h.id)).reverse();
1528
+ p = m.slice(0, k), d.path = {
1529
+ nodeIds: p,
1530
+ total: m.length,
1531
+ truncated: m.length > k
1532
+ };
1533
+ }
1534
+ return {
1535
+ success: !0,
1536
+ message: `Successfully ran ${s}:${r} algorithm. ${u.reading()}`,
1537
+ data: d,
1538
+ ...p === void 0 ? {} : { affectedNodes: p }
1539
+ };
1540
+ } catch (n) {
1541
+ return {
1542
+ success: !1,
1543
+ message: `Failed to run algorithm ${s}:${r}: ${n instanceof Error ? n.message : String(n)}`
1544
+ };
1545
+ }
1546
+ }
1547
+ }, _e = {
1548
+ name: "listAlgorithms",
1549
+ description: "List all available graph algorithms that can be run on the graph. Optionally filter by namespace.",
1550
+ parameters: I,
1551
+ examples: [
1552
+ {
1553
+ input: "What algorithms are available?",
1554
+ params: {}
1555
+ },
1556
+ {
1557
+ input: "List graphty algorithms",
1558
+ params: { namespace: "graphty" }
1559
+ },
1560
+ {
1561
+ input: "Show me the available analysis tools",
1562
+ params: {}
1563
+ }
1564
+ ],
1565
+ // eslint-disable-next-line @typescript-eslint/require-await
1566
+ async execute(a, e) {
1567
+ const t = I.safeParse(e);
1568
+ if (!t.success)
1569
+ return {
1570
+ success: !1,
1571
+ message: `Invalid parameters: ${t.error.message}`
1572
+ };
1573
+ const { namespace: s } = t.data;
1574
+ try {
1575
+ const r = x.getRegisteredAlgorithms(s);
1576
+ return r.length === 0 ? {
1577
+ success: !0,
1578
+ message: s ? `No algorithms found in namespace '${s}'.` : "No algorithms are currently registered.",
1579
+ data: {
1580
+ algorithms: [],
1581
+ count: 0
1582
+ }
1583
+ } : {
1584
+ success: !0,
1585
+ message: s ? `Found ${r.length} algorithm(s) in namespace '${s}': ${r.join(", ")}` : `Found ${r.length} available algorithm(s): ${r.join(", ")}`,
1586
+ data: {
1587
+ algorithms: r,
1588
+ count: r.length
1589
+ }
1590
+ };
1591
+ } catch (r) {
1455
1592
  return {
1456
1593
  success: !1,
1457
- message: `Failed to zoom to nodes: ${a.message}`
1594
+ message: `Failed to list algorithms: ${r instanceof Error ? r.message : String(r)}`
1458
1595
  };
1459
1596
  }
1460
1597
  }
1461
1598
  };
1462
- function Re(s, e = 100) {
1463
- return s.length <= e ? s : `${s.slice(0, e)}...`;
1599
+ function Ke(a, e = 100) {
1600
+ return a.length <= e ? a : `${a.slice(0, e)}...`;
1464
1601
  }
1465
- function S(s, e) {
1466
- if (s == null)
1602
+ function M(a, e) {
1603
+ if (a == null)
1467
1604
  return;
1468
1605
  const t = e.split(".");
1469
- let r = s;
1470
- for (const a of t) {
1471
- if (r == null || typeof r != "object")
1606
+ let s = a;
1607
+ for (const r of t) {
1608
+ if (s == null || typeof s != "object")
1472
1609
  return;
1473
- r = r[a];
1610
+ s = s[r];
1474
1611
  }
1475
- return r;
1612
+ return s;
1476
1613
  }
1477
- function b(s, e = 100) {
1478
- if (s == null)
1479
- return s;
1480
- if (typeof s == "string")
1481
- return Re(s, e);
1482
- if (Array.isArray(s))
1483
- return s.map((t) => b(t, e));
1484
- if (typeof s == "object") {
1614
+ function C(a, e = 100) {
1615
+ if (a == null)
1616
+ return a;
1617
+ if (typeof a == "string")
1618
+ return Ke(a, e);
1619
+ if (Array.isArray(a))
1620
+ return a.map((t) => C(t, e));
1621
+ if (typeof a == "object") {
1485
1622
  const t = {};
1486
- for (const [r, a] of Object.entries(s))
1487
- t[r] = b(a, e);
1623
+ for (const [s, r] of Object.entries(a))
1624
+ t[s] = C(r, e);
1488
1625
  return t;
1489
1626
  }
1490
- return s;
1627
+ return a;
1491
1628
  }
1492
- function q(s) {
1493
- if (s.length === 0)
1629
+ function G(a) {
1630
+ if (a.length === 0)
1494
1631
  return { min: 0, max: 0, avg: 0, median: 0, count: 0 };
1495
- const e = [...s].sort((i, u) => i - u), t = s.reduce((i, u) => i + u, 0), r = e[0], a = e[e.length - 1], o = t / s.length, n = Math.floor(e.length / 2), l = e.length % 2 === 0 ? (e[n - 1] + e[n]) / 2 : e[n];
1496
- return { min: r, max: a, avg: o, median: l, count: s.length };
1632
+ const e = [...a].sort((i, u) => i - u), t = a.reduce((i, u) => i + u, 0), s = e[0], r = e[e.length - 1], o = t / a.length, n = Math.floor(e.length / 2), l = e.length % 2 === 0 ? (e[n - 1] + e[n]) / 2 : e[n];
1633
+ return { min: s, max: r, avg: o, median: l, count: a.length };
1497
1634
  }
1498
- function Ie(s, e = 5) {
1499
- if (s.length === 0)
1635
+ function We(a, e = 5) {
1636
+ if (a.length === 0)
1500
1637
  return [];
1501
- const t = Math.min(...s), r = Math.max(...s);
1502
- if (t === r)
1638
+ const t = Math.min(...a), s = Math.max(...a);
1639
+ if (t === s)
1503
1640
  return [
1504
1641
  {
1505
- range: M(t, r),
1506
- count: s.length,
1642
+ range: R(t, s),
1643
+ count: a.length,
1507
1644
  min: t,
1508
- max: r
1645
+ max: s
1509
1646
  }
1510
1647
  ];
1511
- const a = (r - t) / e, o = [];
1648
+ const r = (s - t) / e, o = [];
1512
1649
  for (let n = 0; n < e; n++) {
1513
- const l = t + n * a, i = n === e - 1 ? r : t + (n + 1) * a;
1650
+ const l = t + n * r, i = n === e - 1 ? s : t + (n + 1) * r;
1514
1651
  o.push({
1515
- range: M(l, i),
1652
+ range: R(l, i),
1516
1653
  count: 0,
1517
1654
  min: l,
1518
1655
  max: i
1519
1656
  });
1520
1657
  }
1521
- for (const n of s) {
1522
- let l = Math.floor((n - t) / a);
1658
+ for (const n of a) {
1659
+ let l = Math.floor((n - t) / r);
1523
1660
  l >= e && (l = e - 1), o[l].count++;
1524
1661
  }
1525
1662
  return o;
1526
1663
  }
1527
- function M(s, e) {
1528
- const t = (r) => Number.isInteger(r) ? r.toString() : r.toFixed(2);
1529
- return `${t(s)} - ${t(e)}`;
1664
+ function R(a, e) {
1665
+ const t = (s) => Number.isInteger(s) ? s.toString() : s.toFixed(2);
1666
+ return `${t(a)} - ${t(e)}`;
1530
1667
  }
1531
- function De(s) {
1532
- if (s == null)
1668
+ function Ge(a) {
1669
+ if (a == null)
1533
1670
  return "null";
1534
- if (Array.isArray(s))
1671
+ if (Array.isArray(a))
1535
1672
  return "array";
1536
- const e = typeof s;
1673
+ const e = typeof a;
1537
1674
  return e === "string" || e === "number" || e === "boolean" ? e : e === "object" ? "object" : "null";
1538
1675
  }
1539
- function Le(s, e) {
1676
+ function He(a, e) {
1540
1677
  const t = [];
1541
- let r = 0;
1542
- for (const a of s) {
1543
- const o = S(a.data, e);
1544
- o == null ? r++ : t.push(o);
1678
+ let s = 0;
1679
+ for (const r of a) {
1680
+ const o = M(r.data, e);
1681
+ o == null ? s++ : t.push(o);
1545
1682
  }
1546
- return { values: t, nullCount: r };
1683
+ return { values: t, nullCount: s };
1547
1684
  }
1548
- function V(s) {
1549
- if (s.length === 0)
1685
+ function H(a) {
1686
+ if (a.length === 0)
1550
1687
  return "null";
1551
1688
  const e = /* @__PURE__ */ new Map();
1552
- for (const t of s) {
1553
- const r = De(t);
1554
- e.set(r, (e.get(r) ?? 0) + 1);
1689
+ for (const t of a) {
1690
+ const s = Ge(t);
1691
+ e.set(s, (e.get(s) ?? 0) + 1);
1555
1692
  }
1556
1693
  return e.delete("null"), e.size === 0 ? "null" : e.size > 1 ? "mixed" : e.keys().next().value;
1557
1694
  }
1558
- function ze(s, e = 3) {
1695
+ function Be(a, e = 3) {
1559
1696
  const t = /* @__PURE__ */ new Set();
1560
- for (const r of s)
1561
- U(r.data, "", t, 0, e);
1697
+ for (const s of a)
1698
+ B(s.data, "", t, 0, e);
1562
1699
  return Array.from(t).sort();
1563
1700
  }
1564
- function U(s, e, t, r, a) {
1565
- if (!(r >= a || s === null || s === void 0 || typeof s != "object" || Array.isArray(s)))
1566
- for (const o of Object.keys(s)) {
1701
+ function B(a, e, t, s, r) {
1702
+ if (!(s >= r || a === null || a === void 0 || typeof a != "object" || Array.isArray(a)))
1703
+ for (const o of Object.keys(a)) {
1567
1704
  const n = e ? `${e}.${o}` : o;
1568
1705
  t.add(n);
1569
- const l = s[o];
1570
- l !== null && typeof l == "object" && !Array.isArray(l) && U(l, n, t, r + 1, a);
1706
+ const l = a[o];
1707
+ l !== null && typeof l == "object" && !Array.isArray(l) && B(l, n, t, s + 1, r);
1571
1708
  }
1572
1709
  }
1573
- const je = m.enum(["nodes", "edges", "both"]).optional().describe("What to sample: 'nodes', 'edges', or 'both' (default)"), P = 3, E = 10, T = 100;
1574
- function y(s, e) {
1575
- if (s.length <= e)
1576
- return [...s];
1577
- const t = [...s];
1578
- for (let r = 0; r < e; r++) {
1579
- const a = r + Math.floor(Math.random() * (t.length - r));
1580
- [t[r], t[a]] = [t[a], t[r]];
1710
+ const Xe = c.enum(["nodes", "edges", "both"]).optional().describe("What to sample: 'nodes', 'edges', or 'both' (default)"), D = 3, L = 10, j = 100;
1711
+ function y(a, e) {
1712
+ if (a.length <= e)
1713
+ return [...a];
1714
+ const t = [...a];
1715
+ for (let s = 0; s < e; s++) {
1716
+ const r = s + Math.floor(Math.random() * (t.length - s));
1717
+ [t[s], t[r]] = [t[r], t[s]];
1581
1718
  }
1582
1719
  return t.slice(0, e);
1583
1720
  }
1584
- function A(s, e, t) {
1585
- if (s.length <= e)
1586
- return [...s];
1587
- const r = /* @__PURE__ */ new Map(), a = [];
1588
- for (const i of s) {
1721
+ function z(a, e, t) {
1722
+ if (a.length <= e)
1723
+ return [...a];
1724
+ const s = /* @__PURE__ */ new Map(), r = [];
1725
+ for (const i of a) {
1589
1726
  const u = t(i);
1590
1727
  if (u === void 0)
1591
- a.push(i);
1728
+ r.push(i);
1592
1729
  else {
1593
- const c = r.get(u) ?? [];
1594
- c.push(i), r.set(u, c);
1730
+ const d = s.get(u) ?? [];
1731
+ d.push(i), s.set(u, d);
1595
1732
  }
1596
1733
  }
1597
- const o = r.size + (a.length > 0 ? 1 : 0);
1734
+ const o = s.size + (r.length > 0 ? 1 : 0);
1598
1735
  if (o === 0)
1599
- return y(s, e);
1736
+ return y(a, e);
1600
1737
  const n = Math.max(1, Math.floor(e / o)), l = [];
1601
- for (const i of r.values()) {
1738
+ for (const i of s.values()) {
1602
1739
  const u = y(i, n);
1603
1740
  l.push(...u);
1604
1741
  }
1605
- if (a.length > 0) {
1606
- const i = y(a, n);
1742
+ if (r.length > 0) {
1743
+ const i = y(r, n);
1607
1744
  l.push(...i);
1608
1745
  }
1609
1746
  if (l.length < e) {
1610
- const i = s.filter((c) => !l.includes(c)), u = y(i, e - l.length);
1747
+ const i = a.filter((d) => !l.includes(d)), u = y(i, e - l.length);
1611
1748
  l.push(...u);
1612
1749
  }
1613
1750
  return l.slice(0, e);
1614
1751
  }
1615
- const qe = {
1752
+ const Ze = {
1616
1753
  name: "sampleData",
1617
1754
  description: "Get sample nodes and/or edges from the graph to inspect actual data structures. Useful for understanding what properties exist and what values they contain before writing selectors.",
1618
- parameters: m.object({
1619
- target: je,
1620
- count: m.number().min(1).max(E).optional().describe(`Number of samples to return per type (1-${E}, default ${P})`),
1621
- stratifyBy: m.string().optional().describe("Property path to stratify sampling by (e.g., 'data.type' to sample from each type)")
1755
+ parameters: c.object({
1756
+ target: Xe,
1757
+ count: c.number().min(1).max(L).optional().describe(`Number of samples to return per type (1-${L}, default ${D})`),
1758
+ stratifyBy: c.string().optional().describe("Property path to stratify sampling by (e.g., 'data.type' to sample from each type)")
1622
1759
  }),
1623
1760
  examples: [
1624
1761
  { input: "Show me some example nodes", params: { target: "nodes" } },
@@ -1629,36 +1766,36 @@ const qe = {
1629
1766
  params: { target: "nodes", count: 6, stratifyBy: "data.type" }
1630
1767
  }
1631
1768
  ],
1632
- execute(s, e) {
1769
+ execute(a, e) {
1633
1770
  const {
1634
1771
  target: t = "both",
1635
- count: r = P,
1636
- stratifyBy: a
1772
+ count: s = D,
1773
+ stratifyBy: r
1637
1774
  } = e;
1638
1775
  try {
1639
- const o = s.getDataManager(), n = {};
1776
+ const o = a.getDataManager(), n = {};
1640
1777
  if (t === "nodes" || t === "both") {
1641
1778
  const i = Array.from(o.nodes.values());
1642
1779
  let u;
1643
- a ? u = A(i, r, (c) => {
1644
- const p = S(c.data, a);
1780
+ r ? u = z(i, s, (d) => {
1781
+ const p = M(d.data, r);
1645
1782
  return typeof p == "string" ? p : void 0;
1646
- }) : u = y(i, r), n.nodes = u.map((c) => ({
1647
- id: String(c.id),
1648
- data: b(c.data, T)
1783
+ }) : u = y(i, s), n.nodes = u.map((d) => ({
1784
+ id: String(d.id),
1785
+ data: C(d.data, j)
1649
1786
  }));
1650
1787
  }
1651
1788
  if (t === "edges" || t === "both") {
1652
1789
  const i = Array.from(o.edges.values());
1653
1790
  let u;
1654
- a ? u = A(i, r, (c) => {
1655
- const p = S(c.data, a);
1791
+ r ? u = z(i, s, (d) => {
1792
+ const p = M(d.data, r);
1656
1793
  return typeof p == "string" ? p : void 0;
1657
- }) : u = y(i, r), n.edges = u.map((c) => ({
1658
- id: c.id,
1659
- source: String(c.srcId),
1660
- target: String(c.dstId),
1661
- data: b(c.data, T)
1794
+ }) : u = y(i, s), n.edges = u.map((d) => ({
1795
+ id: d.id,
1796
+ source: String(d.srcId),
1797
+ target: String(d.dstId),
1798
+ data: C(d.data, j)
1662
1799
  }));
1663
1800
  }
1664
1801
  const l = [];
@@ -1674,36 +1811,36 @@ const qe = {
1674
1811
  });
1675
1812
  }
1676
1813
  }
1677
- }, N = 20, k = 50, Ve = 5;
1678
- function Ue(s, e, t, r, a) {
1814
+ }, q = 20, U = 50, Ye = 5;
1815
+ function Je(a, e, t, s, r) {
1679
1816
  const o = t.filter((p) => typeof p == "string"), n = /* @__PURE__ */ new Map();
1680
1817
  for (const p of o)
1681
1818
  n.set(p, (n.get(p) ?? 0) + 1);
1682
- const l = Array.from(n.entries()).sort((p, d) => d[1] - p[1]), i = l.length > a, u = l.slice(0, a), c = {};
1683
- for (const [p, d] of u)
1684
- c[p] = {
1685
- count: d,
1686
- percentage: d / o.length * 100
1819
+ const l = Array.from(n.entries()).sort((p, m) => m[1] - p[1]), i = l.length > r, u = l.slice(0, r), d = {};
1820
+ for (const [p, m] of u)
1821
+ d[p] = {
1822
+ count: m,
1823
+ percentage: m / o.length * 100
1687
1824
  };
1688
1825
  return {
1689
- property: s,
1826
+ property: a,
1690
1827
  target: e,
1691
1828
  type: "string",
1692
- totalCount: o.length + r,
1693
- nullCount: r,
1829
+ totalCount: o.length + s,
1830
+ nullCount: s,
1694
1831
  uniqueCount: n.size,
1695
- distribution: c,
1832
+ distribution: d,
1696
1833
  truncated: i
1697
1834
  };
1698
1835
  }
1699
- function Oe(s, e, t, r) {
1700
- const a = t.filter((l) => typeof l == "number"), o = q(a), n = Ie(a, Ve);
1836
+ function Qe(a, e, t, s) {
1837
+ const r = t.filter((l) => typeof l == "number"), o = G(r), n = We(r, Ye);
1701
1838
  return {
1702
- property: s,
1839
+ property: a,
1703
1840
  target: e,
1704
1841
  type: "number",
1705
- totalCount: a.length + r,
1706
- nullCount: r,
1842
+ totalCount: r.length + s,
1843
+ nullCount: s,
1707
1844
  statistics: {
1708
1845
  min: o.min,
1709
1846
  max: o.max,
@@ -1716,73 +1853,73 @@ function Oe(s, e, t, r) {
1716
1853
  }))
1717
1854
  };
1718
1855
  }
1719
- function Fe(s, e, t, r) {
1720
- const a = t.filter((l) => typeof l == "boolean"), o = a.filter((l) => l).length, n = a.length - o;
1856
+ function et(a, e, t, s) {
1857
+ const r = t.filter((l) => typeof l == "boolean"), o = r.filter((l) => l).length, n = r.length - o;
1721
1858
  return {
1722
- property: s,
1859
+ property: a,
1723
1860
  target: e,
1724
1861
  type: "boolean",
1725
- totalCount: a.length + r,
1726
- nullCount: r,
1862
+ totalCount: r.length + s,
1863
+ nullCount: s,
1727
1864
  distribution: {
1728
1865
  true: {
1729
1866
  count: o,
1730
- percentage: a.length > 0 ? o / a.length * 100 : 0
1867
+ percentage: r.length > 0 ? o / r.length * 100 : 0
1731
1868
  },
1732
1869
  false: {
1733
1870
  count: n,
1734
- percentage: a.length > 0 ? n / a.length * 100 : 0
1871
+ percentage: r.length > 0 ? n / r.length * 100 : 0
1735
1872
  }
1736
1873
  }
1737
1874
  };
1738
1875
  }
1739
- function _e(s, e, t, r, a) {
1876
+ function tt(a, e, t, s, r) {
1740
1877
  const o = t.filter((h) => Array.isArray(h)), n = [], l = [];
1741
1878
  for (const h of o)
1742
1879
  l.push(h.length), n.push(...h);
1743
- const i = V(n), u = /* @__PURE__ */ new Set();
1880
+ const i = H(n), u = /* @__PURE__ */ new Set();
1744
1881
  for (const h of n)
1745
1882
  typeof h == "string" ? u.add(h) : typeof h == "number" || typeof h == "boolean" ? u.add(String(h)) : h != null && u.add(JSON.stringify(h));
1746
- const c = Array.from(u), p = c.length > a, d = q(l);
1883
+ const d = Array.from(u), p = d.length > r, m = G(l);
1747
1884
  return {
1748
- property: s,
1885
+ property: a,
1749
1886
  target: e,
1750
1887
  type: "array",
1751
- totalCount: o.length + r,
1752
- nullCount: r,
1888
+ totalCount: o.length + s,
1889
+ nullCount: s,
1753
1890
  itemType: i,
1754
- uniqueItems: c.slice(0, a),
1755
- uniqueItemCount: c.length,
1891
+ uniqueItems: d.slice(0, r),
1892
+ uniqueItemCount: d.length,
1756
1893
  lengthStatistics: {
1757
- min: d.min,
1758
- max: d.max,
1759
- avg: d.avg
1894
+ min: m.min,
1895
+ max: m.max,
1896
+ avg: m.avg
1760
1897
  },
1761
1898
  truncated: p
1762
1899
  };
1763
1900
  }
1764
- function Ke(s, e, t, r) {
1765
- const a = {};
1901
+ function st(a, e, t, s) {
1902
+ const r = {};
1766
1903
  for (const o of t) {
1767
1904
  const n = typeof o;
1768
- Array.isArray(o) ? a.array = (a.array || 0) + 1 : n === "object" && o !== null ? a.object = (a.object || 0) + 1 : (n === "string" || n === "number" || n === "boolean") && (a[n] = (a[n] || 0) + 1);
1905
+ Array.isArray(o) ? r.array = (r.array || 0) + 1 : n === "object" && o !== null ? r.object = (r.object || 0) + 1 : (n === "string" || n === "number" || n === "boolean") && (r[n] = (r[n] || 0) + 1);
1769
1906
  }
1770
1907
  return {
1771
- property: s,
1908
+ property: a,
1772
1909
  target: e,
1773
1910
  type: "mixed",
1774
- totalCount: t.length + r,
1775
- nullCount: r,
1776
- typeCounts: a
1911
+ totalCount: t.length + s,
1912
+ nullCount: s,
1913
+ typeCounts: r
1777
1914
  };
1778
1915
  }
1779
- const We = {
1916
+ const rt = {
1780
1917
  name: "describeProperty",
1781
1918
  description: "Get detailed information about a specific property in node or edge data. Returns value distributions for strings, statistics for numbers, counts for booleans, and unique items for arrays.",
1782
- parameters: m.object({
1783
- property: m.string().describe("Property path to analyze (e.g., 'type', 'data.category', 'weight')"),
1784
- target: m.enum(["nodes", "edges"]).optional().describe("Whether to analyze node or edge properties (default: 'nodes')"),
1785
- limit: m.number().min(1).max(k).optional().describe(`Maximum number of unique values to show (1-${k}, default ${N})`)
1919
+ parameters: c.object({
1920
+ property: c.string().describe("Property path to analyze (e.g., 'type', 'data.category', 'weight')"),
1921
+ target: c.enum(["nodes", "edges"]).optional().describe("Whether to analyze node or edge properties (default: 'nodes')"),
1922
+ limit: c.number().min(1).max(U).optional().describe(`Maximum number of unique values to show (1-${U}, default ${q})`)
1786
1923
  }),
1787
1924
  examples: [
1788
1925
  { input: "Describe the type property on nodes", params: { property: "type", target: "nodes" } },
@@ -1793,47 +1930,47 @@ const We = {
1793
1930
  { input: "Show me the distribution of data.category", params: { property: "data.category" } },
1794
1931
  { input: "Analyze the tags property", params: { property: "tags", limit: 10 } }
1795
1932
  ],
1796
- execute(s, e) {
1933
+ execute(a, e) {
1797
1934
  const {
1798
1935
  property: t,
1799
- target: r = "nodes",
1800
- limit: a = N
1936
+ target: s = "nodes",
1937
+ limit: r = q
1801
1938
  } = e;
1802
1939
  try {
1803
- const o = s.getDataManager(), n = Array.from(r === "nodes" ? o.nodes.values() : o.edges.values());
1940
+ const o = a.getDataManager(), n = Array.from(s === "nodes" ? o.nodes.values() : o.edges.values());
1804
1941
  if (n.length === 0)
1805
1942
  return Promise.resolve({
1806
1943
  success: !1,
1807
- message: `No ${r} found in the graph.`
1944
+ message: `No ${s} found in the graph.`
1808
1945
  });
1809
- const { values: l, nullCount: i } = Le(n, t);
1946
+ const { values: l, nullCount: i } = He(n, t);
1810
1947
  if (l.length === 0 && i === n.length) {
1811
- const d = ze(n);
1948
+ const m = Be(n);
1812
1949
  return Promise.resolve({
1813
1950
  success: !1,
1814
- message: `Property "${t}" not found on ${r}. Available properties: ${d.slice(0, 10).join(", ")}${d.length > 10 ? "..." : ""}`,
1951
+ message: `Property "${t}" not found on ${s}. Available properties: ${m.slice(0, 10).join(", ")}${m.length > 10 ? "..." : ""}`,
1815
1952
  data: {
1816
- availableProperties: d.slice(0, 20)
1953
+ availableProperties: m.slice(0, 20)
1817
1954
  }
1818
1955
  });
1819
1956
  }
1820
- const u = V(l);
1821
- let c;
1957
+ const u = H(l);
1958
+ let d;
1822
1959
  switch (u) {
1823
1960
  case "string":
1824
- c = Ue(t, r, l, i, a);
1961
+ d = Je(t, s, l, i, r);
1825
1962
  break;
1826
1963
  case "number":
1827
- c = Oe(t, r, l, i);
1964
+ d = Qe(t, s, l, i);
1828
1965
  break;
1829
1966
  case "boolean":
1830
- c = Fe(t, r, l, i);
1967
+ d = et(t, s, l, i);
1831
1968
  break;
1832
1969
  case "array":
1833
- c = _e(t, r, l, i, a);
1970
+ d = tt(t, s, l, i, r);
1834
1971
  break;
1835
1972
  case "mixed":
1836
- c = Ke(t, r, l, i);
1973
+ d = st(t, s, l, i);
1837
1974
  break;
1838
1975
  default:
1839
1976
  return Promise.resolve({
@@ -1844,27 +1981,27 @@ const We = {
1844
1981
  let p;
1845
1982
  switch (u) {
1846
1983
  case "string": {
1847
- const d = c;
1848
- p = `Property "${t}" is a string with ${d.uniqueCount} unique value${d.uniqueCount !== 1 ? "s" : ""}.`;
1984
+ const m = d;
1985
+ p = `Property "${t}" is a string with ${m.uniqueCount} unique value${m.uniqueCount !== 1 ? "s" : ""}.`;
1849
1986
  break;
1850
1987
  }
1851
1988
  case "number": {
1852
- const d = c;
1853
- p = `Property "${t}" is a number (min: ${d.statistics.min.toFixed(2)}, max: ${d.statistics.max.toFixed(2)}, avg: ${d.statistics.avg.toFixed(2)}).`;
1989
+ const m = d;
1990
+ p = `Property "${t}" is a number (min: ${m.statistics.min.toFixed(2)}, max: ${m.statistics.max.toFixed(2)}, avg: ${m.statistics.avg.toFixed(2)}).`;
1854
1991
  break;
1855
1992
  }
1856
1993
  case "boolean": {
1857
- const d = c;
1858
- p = `Property "${t}" is a boolean (true: ${d.distribution.true.percentage.toFixed(1)}%, false: ${d.distribution.false.percentage.toFixed(1)}%).`;
1994
+ const m = d;
1995
+ p = `Property "${t}" is a boolean (true: ${m.distribution.true.percentage.toFixed(1)}%, false: ${m.distribution.false.percentage.toFixed(1)}%).`;
1859
1996
  break;
1860
1997
  }
1861
1998
  case "array": {
1862
- const d = c;
1863
- p = `Property "${t}" is an array of ${d.itemType} values with ${d.uniqueItemCount} unique item${d.uniqueItemCount !== 1 ? "s" : ""}.`;
1999
+ const m = d;
2000
+ p = `Property "${t}" is an array of ${m.itemType} values with ${m.uniqueItemCount} unique item${m.uniqueItemCount !== 1 ? "s" : ""}.`;
1864
2001
  break;
1865
2002
  }
1866
2003
  case "mixed": {
1867
- const h = Object.keys(c.typeCounts).join(", ");
2004
+ const h = Object.keys(d.typeCounts).join(", ");
1868
2005
  p = `Property "${t}" has mixed types: ${h}.`;
1869
2006
  break;
1870
2007
  }
@@ -1874,7 +2011,7 @@ const We = {
1874
2011
  return Promise.resolve({
1875
2012
  success: !0,
1876
2013
  message: p,
1877
- data: c
2014
+ data: d
1878
2015
  });
1879
2016
  } catch (o) {
1880
2017
  return Promise.resolve({
@@ -1884,7 +2021,7 @@ const We = {
1884
2021
  }
1885
2022
  }
1886
2023
  };
1887
- class Ge {
2024
+ class at {
1888
2025
  constructor() {
1889
2026
  this.name = "mock", this.supportsStreaming = !0, this.supportsTools = !0, this.responses = /* @__PURE__ */ new Map(), this.defaultResponse = {
1890
2027
  text: "This is a mock response.",
@@ -1951,12 +2088,12 @@ class Ge {
1951
2088
  * @returns Matching response or default response
1952
2089
  */
1953
2090
  findResponse(e) {
1954
- const t = [...e].reverse().find((a) => a.role === "user");
2091
+ const t = [...e].reverse().find((r) => r.role === "user");
1955
2092
  if (!t)
1956
2093
  return this.defaultResponse;
1957
- const r = t.content.toLowerCase();
1958
- for (const [a, o] of this.responses)
1959
- if (r.includes(a))
2094
+ const s = t.content.toLowerCase();
2095
+ for (const [r, o] of this.responses)
2096
+ if (s.includes(r))
1960
2097
  return o;
1961
2098
  return this.defaultResponse;
1962
2099
  }
@@ -1968,17 +2105,17 @@ class Ge {
1968
2105
  * @param options.signal - Optional abort signal
1969
2106
  * @returns Promise resolving to LLM response
1970
2107
  */
1971
- async generate(e, t, r) {
2108
+ async generate(e, t, s) {
1972
2109
  if (this.callHistory.push({
1973
2110
  messages: e,
1974
2111
  tools: t,
1975
2112
  streaming: !1,
1976
2113
  timestamp: Date.now()
1977
- }), r?.signal?.aborted)
2114
+ }), s?.signal?.aborted)
1978
2115
  throw new Error("Request was aborted");
1979
2116
  if (this.configuredError)
1980
2117
  throw this.configuredError;
1981
- if (this.delay > 0 && await new Promise((a) => setTimeout(a, this.delay)), r?.signal?.aborted)
2118
+ if (this.delay > 0 && await new Promise((r) => setTimeout(r, this.delay)), s?.signal?.aborted)
1982
2119
  throw new Error("Request was aborted");
1983
2120
  return this.findResponse(e);
1984
2121
  }
@@ -1990,28 +2127,28 @@ class Ge {
1990
2127
  * @param callbacks - Streaming callbacks for text and tool calls
1991
2128
  * @param signal - Optional abort signal
1992
2129
  */
1993
- async generateStream(e, t, r, a) {
2130
+ async generateStream(e, t, s, r) {
1994
2131
  if (this.callHistory.push({
1995
2132
  messages: e,
1996
2133
  tools: t,
1997
2134
  streaming: !0,
1998
2135
  timestamp: Date.now()
1999
- }), a?.aborted)
2136
+ }), r?.aborted)
2000
2137
  throw new Error("Request was aborted");
2001
2138
  if (this.configuredError)
2002
- throw r.onError(this.configuredError), this.configuredError;
2139
+ throw s.onError(this.configuredError), this.configuredError;
2003
2140
  const o = this.findResponse(e), { text: n } = o;
2004
2141
  for (const l of n) {
2005
- if (a?.aborted)
2142
+ if (r?.aborted)
2006
2143
  throw new Error("Request was aborted");
2007
- r.onChunk(l), this.delay > 0 && await new Promise((i) => setTimeout(i, this.delay / n.length));
2144
+ s.onChunk(l), this.delay > 0 && await new Promise((i) => setTimeout(i, this.delay / n.length));
2008
2145
  }
2009
2146
  for (const l of o.toolCalls) {
2010
- if (a?.aborted)
2147
+ if (r?.aborted)
2011
2148
  throw new Error("Request was aborted");
2012
- r.onToolCall(l.name, l.arguments);
2149
+ s.onToolCall(l.name, l.arguments);
2013
2150
  }
2014
- r.onComplete(o);
2151
+ s.onComplete(o);
2015
2152
  }
2016
2153
  /**
2017
2154
  * Validate the API key.
@@ -2026,7 +2163,7 @@ class Ge {
2026
2163
  return Promise.resolve(!0);
2027
2164
  }
2028
2165
  }
2029
- class He {
2166
+ class ot {
2030
2167
  /**
2031
2168
  * Creates a new VercelAiProvider instance.
2032
2169
  * @param providerType - Type of provider (openai, anthropic, or google)
@@ -2050,9 +2187,9 @@ class He {
2050
2187
  throw new Error(`API key not configured for ${this.name}`);
2051
2188
  switch (this.providerType) {
2052
2189
  case "openai":
2053
- return Q({ apiKey: this.apiKey, baseURL: this.baseUrl })(this.model ?? "gpt-4o");
2190
+ return le({ apiKey: this.apiKey, baseURL: this.baseUrl })(this.model ?? "gpt-4o");
2054
2191
  case "anthropic":
2055
- return Y({
2192
+ return ne({
2056
2193
  apiKey: this.apiKey,
2057
2194
  baseURL: this.baseUrl,
2058
2195
  // Enable browser support - Anthropic requires this header for CORS
@@ -2061,7 +2198,7 @@ class He {
2061
2198
  }
2062
2199
  })(this.model ?? "claude-3-haiku-20240307");
2063
2200
  default:
2064
- return J({ apiKey: this.apiKey, baseURL: this.baseUrl })(this.model ?? "gemini-2.0-flash");
2201
+ return ie({ apiKey: this.apiKey, baseURL: this.baseUrl })(this.model ?? "gemini-2.0-flash");
2065
2202
  }
2066
2203
  }
2067
2204
  /**
@@ -2072,14 +2209,14 @@ class He {
2072
2209
  * @param options.signal - Optional abort signal
2073
2210
  * @returns Promise resolving to LLM response
2074
2211
  */
2075
- async generate(e, t, r) {
2076
- const a = this.getModel(), o = this.convertMessages(e), n = this.convertTools(t), l = await ee({
2077
- model: a,
2212
+ async generate(e, t, s) {
2213
+ const r = this.getModel(), o = this.convertMessages(e), n = this.convertTools(t), l = await ce({
2214
+ model: r,
2078
2215
  messages: o,
2079
2216
  tools: n,
2080
2217
  maxOutputTokens: this.maxTokens,
2081
2218
  temperature: this.temperature,
2082
- abortSignal: r?.signal
2219
+ abortSignal: s?.signal
2083
2220
  }), { usage: i } = l;
2084
2221
  return {
2085
2222
  text: l.text,
@@ -2094,53 +2231,53 @@ class He {
2094
2231
  * @param callbacks - Streaming callbacks for text and tool calls
2095
2232
  * @param signal - Optional abort signal
2096
2233
  */
2097
- async generateStream(e, t, r, a) {
2098
- const o = this.getModel(), n = this.convertMessages(e), l = this.convertTools(t), i = te({
2234
+ async generateStream(e, t, s, r) {
2235
+ const o = this.getModel(), n = this.convertMessages(e), l = this.convertTools(t), i = ue({
2099
2236
  model: o,
2100
2237
  messages: n,
2101
2238
  tools: l,
2102
2239
  maxOutputTokens: this.maxTokens,
2103
2240
  temperature: this.temperature,
2104
- abortSignal: a
2241
+ abortSignal: r
2105
2242
  });
2106
2243
  let u = "";
2107
- const c = [];
2244
+ const d = [];
2108
2245
  try {
2109
- for await (const d of i.fullStream)
2110
- switch (d.type) {
2246
+ for await (const m of i.fullStream)
2247
+ switch (m.type) {
2111
2248
  case "text-delta":
2112
- u += d.text, r.onChunk(d.text);
2249
+ u += m.text, s.onChunk(m.text);
2113
2250
  break;
2114
2251
  case "tool-call": {
2115
2252
  let h = {};
2116
- "input" in d ? { input: h } = d : "args" in d && ({ args: h } = d);
2253
+ "input" in m ? { input: h } = m : "args" in m && ({ args: h } = m);
2117
2254
  const g = {
2118
- id: d.toolCallId,
2119
- name: d.toolName,
2255
+ id: m.toolCallId,
2256
+ name: m.toolName,
2120
2257
  arguments: h
2121
2258
  };
2122
- c.push(g), r.onToolCall(d.toolName, h);
2259
+ d.push(g), s.onToolCall(m.toolName, h);
2123
2260
  break;
2124
2261
  }
2125
2262
  case "tool-result": {
2126
2263
  let h;
2127
- "output" in d ? { output: h } = d : "result" in d && ({ result: h } = d), r.onToolResult(d.toolName, h);
2264
+ "output" in m ? { output: h } = m : "result" in m && ({ result: h } = m), s.onToolResult(m.toolName, h);
2128
2265
  break;
2129
2266
  }
2130
2267
  case "error":
2131
- r.onError(new Error(String(d.error)));
2268
+ s.onError(new Error(String(m.error)));
2132
2269
  break;
2133
2270
  default:
2134
2271
  break;
2135
2272
  }
2136
2273
  const p = await i.usage;
2137
- r.onComplete({
2274
+ s.onComplete({
2138
2275
  text: u,
2139
- toolCalls: c,
2276
+ toolCalls: d,
2140
2277
  usage: p.inputTokens !== void 0 && p.outputTokens !== void 0 ? { promptTokens: p.inputTokens, completionTokens: p.outputTokens } : void 0
2141
2278
  });
2142
2279
  } catch (p) {
2143
- throw r.onError(p instanceof Error ? p : new Error(String(p))), p;
2280
+ throw s.onError(p instanceof Error ? p : new Error(String(p))), p;
2144
2281
  }
2145
2282
  }
2146
2283
  /**
@@ -2160,11 +2297,11 @@ class He {
2160
2297
  role: "assistant",
2161
2298
  content: [
2162
2299
  ...t.content ? [{ type: "text", text: t.content }] : [],
2163
- ...t.toolCalls.map((r) => ({
2300
+ ...t.toolCalls.map((s) => ({
2164
2301
  type: "tool-call",
2165
- toolCallId: r.id,
2166
- toolName: r.name,
2167
- input: r.arguments
2302
+ toolCallId: s.id,
2303
+ toolName: s.name,
2304
+ input: s.arguments
2168
2305
  }))
2169
2306
  ]
2170
2307
  } : { role: "assistant", content: t.content };
@@ -2193,10 +2330,10 @@ class He {
2193
2330
  */
2194
2331
  convertTools(e) {
2195
2332
  const t = {};
2196
- for (const r of e)
2197
- t[r.name] = {
2198
- description: r.description,
2199
- inputSchema: r.parameters
2333
+ for (const s of e)
2334
+ t[s.name] = {
2335
+ description: s.description,
2336
+ inputSchema: s.parameters
2200
2337
  };
2201
2338
  return t;
2202
2339
  }
@@ -2229,75 +2366,75 @@ class He {
2229
2366
  }
2230
2367
  }
2231
2368
  }
2232
- async function Be() {
2369
+ async function nt() {
2233
2370
  return (await import("./WebLlmProvider-BEFvNcC5.js")).WebLlmProvider;
2234
2371
  }
2235
- function Xe(s) {
2236
- if (s === "mock")
2237
- return new Ge();
2238
- if (s === "webllm")
2372
+ function it(a) {
2373
+ if (a === "mock")
2374
+ return new at();
2375
+ if (a === "webllm")
2239
2376
  throw new Error(
2240
2377
  "WebLlmProvider cannot be created synchronously. Use createWebLlmProvider() or getWebLlmProviderClass() instead."
2241
2378
  );
2242
- return new He(s);
2379
+ return new ot(a);
2243
2380
  }
2244
- async function wt() {
2245
- const s = await Be();
2246
- return new s();
2381
+ async function It() {
2382
+ const a = await nt();
2383
+ return new a();
2247
2384
  }
2248
- const w = 10, R = 50;
2249
- function Ze(s) {
2385
+ const $ = 10, V = 50;
2386
+ function lt(a) {
2250
2387
  const e = [];
2251
- return e.push(Ye(s)), s.nodeProperties.length > 0 ? e.push(Je(s.nodeProperties)) : s.nodeCount > 0 && e.push(`### Node Properties
2252
- No custom properties on node data.`), s.edgeProperties.length > 0 ? e.push(Qe(s.edgeProperties)) : s.edgeCount > 0 && e.push(`### Edge Properties
2388
+ return e.push(ct(a)), a.nodeProperties.length > 0 ? e.push(ut(a.nodeProperties)) : a.nodeCount > 0 && e.push(`### Node Properties
2389
+ No custom properties on node data.`), a.edgeProperties.length > 0 ? e.push(dt(a.edgeProperties)) : a.edgeCount > 0 && e.push(`### Edge Properties
2253
2390
  No custom properties on edge data.`), e.join(`
2254
2391
 
2255
2392
  `);
2256
2393
  }
2257
- function Ye(s) {
2394
+ function ct(a) {
2258
2395
  return `## Data Schema
2259
- - Nodes: ${s.nodeCount}
2260
- - Edges: ${s.edgeCount}`;
2396
+ - Nodes: ${a.nodeCount}
2397
+ - Edges: ${a.edgeCount}`;
2261
2398
  }
2262
- function Je(s) {
2399
+ function ut(a) {
2263
2400
  const e = ["### Node Properties"];
2264
- for (const t of s)
2265
- e.push(O(t));
2401
+ for (const t of a)
2402
+ e.push(X(t));
2266
2403
  return e.join(`
2267
2404
  `);
2268
2405
  }
2269
- function Qe(s) {
2406
+ function dt(a) {
2270
2407
  const e = ["### Edge Properties"];
2271
- for (const t of s)
2272
- e.push(O(t));
2408
+ for (const t of a)
2409
+ e.push(X(t));
2273
2410
  return e.join(`
2274
2411
  `);
2275
2412
  }
2276
- function O(s) {
2277
- const e = rt(s.name), t = s.nullable ? "?" : "", r = et(s), a = tt(s);
2278
- return `- \`${e}\`: ${r}${t}${a}`;
2413
+ function X(a) {
2414
+ const e = gt(a.name), t = a.nullable ? "?" : "", s = mt(a), r = pt(a);
2415
+ return `- \`${e}\`: ${s}${t}${r}`;
2279
2416
  }
2280
- function et(s) {
2281
- return s.type === "array" && s.itemType ? `${s.itemType}[]` : s.type;
2417
+ function mt(a) {
2418
+ return a.type === "array" && a.itemType ? `${a.itemType}[]` : a.type;
2282
2419
  }
2283
- function tt(s) {
2420
+ function pt(a) {
2284
2421
  const e = [];
2285
- if (s.format && e.push(`format: ${s.format}`), s.enumValues && s.enumValues.length > 0) {
2286
- const t = st(s.enumValues);
2422
+ if (a.format && e.push(`format: ${a.format}`), a.enumValues && a.enumValues.length > 0) {
2423
+ const t = ht(a.enumValues);
2287
2424
  e.push(`values: [${t}]`);
2288
2425
  }
2289
- return s.range && e.push(`range: ${s.range.min}..${s.range.max}`), e.length === 0 ? "" : ` (${e.join(", ")})`;
2426
+ return a.range && e.push(`range: ${a.range.min}..${a.range.max}`), e.length === 0 ? "" : ` (${e.join(", ")})`;
2290
2427
  }
2291
- function st(s) {
2292
- if (s.length <= w)
2293
- return s.map((r) => `"${r}"`).join(", ");
2294
- const e = s.slice(0, w), t = s.length - w;
2295
- return `${e.map((r) => `"${r}"`).join(", ")}, ... +${t} more`;
2428
+ function ht(a) {
2429
+ if (a.length <= $)
2430
+ return a.map((s) => `"${s}"`).join(", ");
2431
+ const e = a.slice(0, $), t = a.length - $;
2432
+ return `${e.map((s) => `"${s}"`).join(", ")}, ... +${t} more`;
2296
2433
  }
2297
- function rt(s) {
2298
- return s.length <= R ? s : `${s.slice(0, R - 3)}...`;
2434
+ function gt(a) {
2435
+ return a.length <= V ? a : `${a.slice(0, V - 3)}...`;
2299
2436
  }
2300
- class at {
2437
+ class ft {
2301
2438
  /**
2302
2439
  * Create a new SchemaManager.
2303
2440
  * @param graph - The graph to extract schema from
@@ -2314,7 +2451,7 @@ class at {
2314
2451
  */
2315
2452
  extract() {
2316
2453
  if (this.cachedSchema === null) {
2317
- const e = new D(this.graph, this.options);
2454
+ const e = new O(this.graph, this.options);
2318
2455
  this.cachedSchema = e.extract();
2319
2456
  }
2320
2457
  return this.cachedSchema;
@@ -2335,7 +2472,7 @@ class at {
2335
2472
  getFormattedSchema() {
2336
2473
  if (this.cachedFormattedSchema === null) {
2337
2474
  const e = this.extract();
2338
- this.cachedFormattedSchema = Ze(e);
2475
+ this.cachedFormattedSchema = lt(e);
2339
2476
  }
2340
2477
  return this.cachedFormattedSchema;
2341
2478
  }
@@ -2349,13 +2486,13 @@ class at {
2349
2486
  this.cachedSchema = null, this.cachedFormattedSchema = null;
2350
2487
  }
2351
2488
  }
2352
- const ot = 300;
2353
- class F {
2489
+ const yt = 300;
2490
+ class Z {
2354
2491
  /**
2355
2492
  * Creates a new AiManager instance.
2356
2493
  */
2357
2494
  constructor() {
2358
- this.graph = null, this.controller = null, this.provider = null, this.schemaManager = null, this.dataAddedListenerId = null, this.debouncedSchemaUpdate = null, this.disposed = !1, this.initialized = !1, this.commandRegistry = new ae(), this.apiKeyManager = new se(), this.statusManager = new I();
2495
+ this.graph = null, this.controller = null, this.provider = null, this.schemaManager = null, this.dataAddedListenerId = null, this.debouncedSchemaUpdate = null, this.disposed = !1, this.initialized = !1, this.commandRegistry = new pe(), this.apiKeyManager = new de(), this.statusManager = new F();
2359
2496
  }
2360
2497
  /**
2361
2498
  * Initialize the AI Manager with a graph and configuration.
@@ -2367,18 +2504,18 @@ class F {
2367
2504
  encryptionKey: t.keyPersistence.encryptionKey,
2368
2505
  storage: t.keyPersistence.storage ?? "localStorage",
2369
2506
  prefix: t.keyPersistence.prefix
2370
- }), t.providerInstance ? this.provider = t.providerInstance : (this.provider = Xe(t.provider), t.apiKey && (this.apiKeyManager.setKey(t.provider, t.apiKey), this.provider.configure({
2507
+ }), t.providerInstance ? this.provider = t.providerInstance : (this.provider = it(t.provider), t.apiKey && (this.apiKeyManager.setKey(t.provider, t.apiKey), this.provider.configure({
2371
2508
  apiKey: t.apiKey,
2372
2509
  model: t.model
2373
- }))), t.registerBuiltinCommands !== !1 && this.registerBuiltinCommands(), this.initializeSchemaManager(), this.controller = new re({
2510
+ }))), t.registerBuiltinCommands !== !1 && this.registerBuiltinCommands(), this.initializeSchemaManager(), this.controller = new me({
2374
2511
  provider: this.provider,
2375
2512
  commandRegistry: this.commandRegistry,
2376
2513
  graph: this.graph,
2377
2514
  schemaManager: this.schemaManager,
2378
2515
  // Onto the graph's own event channel, so `addListener` and the element's DOM
2379
2516
  // forwarder both deliver every AI event.
2380
- emitEvent: (r) => {
2381
- e.eventManager.emitGraphEvent(r.type, { ...r });
2517
+ emitEvent: (s) => {
2518
+ e.eventManager.emitGraphEvent(s.type, { ...s });
2382
2519
  }
2383
2520
  }), this.initialized = !0);
2384
2521
  }
@@ -2387,9 +2524,9 @@ class F {
2387
2524
  */
2388
2525
  initializeSchemaManager() {
2389
2526
  if (this.graph) {
2390
- this.schemaManager = new at(this.graph), this.schemaManager.extract(), this.debouncedSchemaUpdate = _.debounce(() => {
2527
+ this.schemaManager = new ft(this.graph), this.schemaManager.extract(), this.debouncedSchemaUpdate = Y.debounce(() => {
2391
2528
  this.schemaManager && this.schemaManager.invalidateCache();
2392
- }, ot);
2529
+ }, yt);
2393
2530
  try {
2394
2531
  const { eventManager: e } = this.graph;
2395
2532
  this.dataAddedListenerId = e.addListener("data-added", () => {
@@ -2403,7 +2540,7 @@ class F {
2403
2540
  * Register built-in commands for graph control.
2404
2541
  */
2405
2542
  registerBuiltinCommands() {
2406
- this.registerCommand(le), this.registerCommand(ce), this.registerCommand(de), this.registerCommand(qe), this.registerCommand(We), this.registerCommand(he), this.registerCommand(ge), this.registerCommand(ye), this.registerCommand(Me), this.registerCommand(Pe), this.registerCommand(Ee), this.registerCommand(Ae), this.registerCommand(ke);
2543
+ this.registerCommand(ye), this.registerCommand(be), this.registerCommand(Se), this.registerCommand(Ze), this.registerCommand(rt), this.registerCommand(_e), this.registerCommand(Oe), this.registerCommand(xe), this.registerCommand(Me), this.registerCommand(Ae), this.registerCommand(Le), this.registerCommand(je), this.registerCommand(ze), this.registerCommand(Ue), this.registerCommand(Fe);
2407
2544
  }
2408
2545
  /**
2409
2546
  * Register a custom command.
@@ -2531,39 +2668,41 @@ class F {
2531
2668
  }
2532
2669
  }
2533
2670
  }
2534
- function nt() {
2535
- return new F();
2671
+ function vt() {
2672
+ return new Z();
2536
2673
  }
2537
- const St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2674
+ const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2538
2675
  __proto__: null,
2539
- AiManager: F,
2540
- createAiManager: nt
2676
+ AiManager: Z,
2677
+ createAiManager: vt
2541
2678
  }, Symbol.toStringTag, { value: "Module" }));
2542
2679
  export {
2543
- re as A,
2544
- ae as C,
2545
- Ge as M,
2546
- D as S,
2547
- He as V,
2548
- F as a,
2549
- I as b,
2550
- at as c,
2551
- Ee as d,
2552
- nt as e,
2553
- Ze as f,
2554
- Xe as g,
2555
- wt as h,
2556
- We as i,
2557
- Pe as j,
2558
- Me as k,
2559
- ce as l,
2560
- Be as m,
2561
- Ae as n,
2562
- ge as o,
2563
- ye as p,
2564
- le as q,
2565
- he as r,
2566
- qe as s,
2567
- St as t,
2568
- ke as z
2680
+ me as A,
2681
+ pe as C,
2682
+ at as M,
2683
+ O as S,
2684
+ ot as V,
2685
+ Z as a,
2686
+ F as b,
2687
+ ft as c,
2688
+ ze as d,
2689
+ vt as e,
2690
+ lt as f,
2691
+ it as g,
2692
+ It as h,
2693
+ rt as i,
2694
+ je as j,
2695
+ Le as k,
2696
+ be as l,
2697
+ nt as m,
2698
+ _e as n,
2699
+ Ue as o,
2700
+ Me as p,
2701
+ ye as q,
2702
+ Oe as r,
2703
+ Ze as s,
2704
+ Ae as t,
2705
+ xe as u,
2706
+ Rt as v,
2707
+ Fe as z
2569
2708
  };