@sapiom/harness 0.8.9 → 0.10.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 (85) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/README.md +11 -1
  3. package/dist/core/agent-project-discovery.d.ts +235 -1
  4. package/dist/core/agent-project-discovery.d.ts.map +1 -1
  5. package/dist/core/agent-project-discovery.js +303 -1
  6. package/dist/core/agent-project-discovery.js.map +1 -1
  7. package/dist/core/canvas-interconnections.d.ts +31 -0
  8. package/dist/core/canvas-interconnections.d.ts.map +1 -1
  9. package/dist/core/canvas-interconnections.js +294 -21
  10. package/dist/core/canvas-interconnections.js.map +1 -1
  11. package/dist/core/canvas-render.d.ts +32 -0
  12. package/dist/core/canvas-render.d.ts.map +1 -1
  13. package/dist/core/canvas-render.js +50 -41
  14. package/dist/core/canvas-render.js.map +1 -1
  15. package/dist/core/definition-name.d.ts +12 -0
  16. package/dist/core/definition-name.d.ts.map +1 -1
  17. package/dist/core/definition-name.js +14 -5
  18. package/dist/core/definition-name.js.map +1 -1
  19. package/dist/core/system-graph-inventory.d.ts +68 -0
  20. package/dist/core/system-graph-inventory.d.ts.map +1 -0
  21. package/dist/core/system-graph-inventory.js +312 -0
  22. package/dist/core/system-graph-inventory.js.map +1 -0
  23. package/dist/core/system-graph-relationships.d.ts +41 -0
  24. package/dist/core/system-graph-relationships.d.ts.map +1 -0
  25. package/dist/core/system-graph-relationships.js +98 -0
  26. package/dist/core/system-graph-relationships.js.map +1 -0
  27. package/dist/core/system-graph-store.d.ts +45 -0
  28. package/dist/core/system-graph-store.d.ts.map +1 -0
  29. package/dist/core/system-graph-store.js +222 -0
  30. package/dist/core/system-graph-store.js.map +1 -0
  31. package/dist/core/system-graph-watcher.d.ts +51 -0
  32. package/dist/core/system-graph-watcher.d.ts.map +1 -0
  33. package/dist/core/system-graph-watcher.js +448 -0
  34. package/dist/core/system-graph-watcher.js.map +1 -0
  35. package/dist/core/system-graph.d.ts +43 -0
  36. package/dist/core/system-graph.d.ts.map +1 -0
  37. package/dist/core/system-graph.js +321 -0
  38. package/dist/core/system-graph.js.map +1 -0
  39. package/dist/core/workflow-registry.d.ts +84 -6
  40. package/dist/core/workflow-registry.d.ts.map +1 -1
  41. package/dist/core/workflow-registry.js +191 -91
  42. package/dist/core/workflow-registry.js.map +1 -1
  43. package/dist/core/workspace-watcher.d.ts +21 -13
  44. package/dist/core/workspace-watcher.d.ts.map +1 -1
  45. package/dist/core/workspace-watcher.js +79 -81
  46. package/dist/core/workspace-watcher.js.map +1 -1
  47. package/dist/index.d.ts +1 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/server/agent-move.d.ts +134 -0
  51. package/dist/server/agent-move.d.ts.map +1 -0
  52. package/dist/server/agent-move.js +343 -0
  53. package/dist/server/agent-move.js.map +1 -0
  54. package/dist/server/index.d.ts.map +1 -1
  55. package/dist/server/index.js +275 -22
  56. package/dist/server/index.js.map +1 -1
  57. package/dist/server/rest.d.ts +3 -0
  58. package/dist/server/rest.d.ts.map +1 -1
  59. package/dist/server/rest.js +3 -0
  60. package/dist/server/rest.js.map +1 -1
  61. package/dist/server/studio-rail.d.ts +76 -0
  62. package/dist/server/studio-rail.d.ts.map +1 -0
  63. package/dist/server/studio-rail.js +234 -0
  64. package/dist/server/studio-rail.js.map +1 -0
  65. package/dist/server/system-graph.d.ts +14 -0
  66. package/dist/server/system-graph.d.ts.map +1 -0
  67. package/dist/server/system-graph.js +40 -0
  68. package/dist/server/system-graph.js.map +1 -0
  69. package/dist/server/workflow-graph.d.ts +43 -0
  70. package/dist/server/workflow-graph.d.ts.map +1 -0
  71. package/dist/server/workflow-graph.js +200 -0
  72. package/dist/server/workflow-graph.js.map +1 -0
  73. package/dist/shared/system-graph.d.ts +59 -0
  74. package/dist/shared/system-graph.d.ts.map +1 -0
  75. package/dist/shared/system-graph.js +76 -0
  76. package/dist/shared/system-graph.js.map +1 -0
  77. package/dist/shared/types.d.ts +45 -0
  78. package/dist/shared/types.d.ts.map +1 -1
  79. package/dist/shared/types.js.map +1 -1
  80. package/dist/web/assets/index-BLrCZ-6M.css +32 -0
  81. package/dist/web/assets/index-CzCPIbq9.js +513 -0
  82. package/dist/web/index.html +2 -2
  83. package/package.json +3 -3
  84. package/dist/web/assets/index-B18B2y5o.js +0 -494
  85. package/dist/web/assets/index-jGBbXx9R.css +0 -32
@@ -0,0 +1,448 @@
1
+ import * as fs from "node:fs";
2
+ import * as fsp from "node:fs/promises";
3
+ import * as path from "node:path";
4
+ import { isAgentProjectScanIgnoredDir } from "./agent-project-discovery.js";
5
+ import { normalizeWatchPath } from "./canvas-watcher.js";
6
+ import { snapshotWorkspaceWorkflowsAsync } from "./workspace-watcher.js";
7
+ const SOURCE_DEBOUNCE_MS = 150;
8
+ const INVENTORY_DEBOUNCE_MS = 250;
9
+ const INVENTORY_RETRY_BASE_MS = 500;
10
+ const MAX_INVENTORY_RETRIES = 3;
11
+ const POLL_INTERVAL_MS = 2000;
12
+ const SOURCE_EXTENSIONS = new Set([".ts", ".tsx"]);
13
+ const UNREADABLE_SOURCE_FINGERPRINT = "<unreadable>";
14
+ function ignoredRelativePath(relativePath) {
15
+ return relativePath
16
+ .split("/")
17
+ .filter(Boolean)
18
+ .some((segment) => isAgentProjectScanIgnoredDir(segment));
19
+ }
20
+ function sourceRelativePath(relativePath) {
21
+ return (!ignoredRelativePath(relativePath) &&
22
+ SOURCE_EXTENSIONS.has(path.extname(relativePath)));
23
+ }
24
+ function confinedSourcePath(root, relativePath) {
25
+ const absolute = path.resolve(root, relativePath);
26
+ const relative = path.relative(root, absolute);
27
+ if (relative === ".." ||
28
+ relative.startsWith(`..${path.sep}`) ||
29
+ path.isAbsolute(relative)) {
30
+ return null;
31
+ }
32
+ return absolute;
33
+ }
34
+ /**
35
+ * Async source fingerprint for the registered agent roots in one workspace.
36
+ *
37
+ * The graph watcher deliberately does not reuse Canvas's synchronous,
38
+ * 400-file project snapshot here: a workspace can contain many agent projects,
39
+ * and polling it on the server event loop would both stutter Studio and miss
40
+ * edits after that project-sized ceiling. Async directory reads yield between
41
+ * entries, while scoping the walk to registry roots keeps the unbounded file
42
+ * count honest without traversing unrelated workspace trees.
43
+ */
44
+ export async function snapshotWorkflowSourceRootsAsync(sourceRoots) {
45
+ const roots = [
46
+ ...new Set(sourceRoots.map((root) => path.resolve(root))),
47
+ ].sort();
48
+ const snapshots = new Map();
49
+ const walk = async (dir, parts) => {
50
+ let entries;
51
+ try {
52
+ entries = await fsp.readdir(dir, { withFileTypes: true });
53
+ }
54
+ catch {
55
+ parts.push(`${dir}\0${UNREADABLE_SOURCE_FINGERPRINT}`);
56
+ return;
57
+ }
58
+ for (const entry of entries) {
59
+ const full = path.join(dir, entry.name);
60
+ if (entry.isDirectory()) {
61
+ if (isAgentProjectScanIgnoredDir(entry.name))
62
+ continue;
63
+ await walk(full, parts);
64
+ continue;
65
+ }
66
+ if (!entry.isFile() || !SOURCE_EXTENSIONS.has(path.extname(entry.name))) {
67
+ continue;
68
+ }
69
+ try {
70
+ const stat = await fsp.stat(full);
71
+ parts.push(`${full}:${stat.mtimeMs}:${stat.size}`);
72
+ }
73
+ catch {
74
+ parts.push(`${full}:gone`);
75
+ }
76
+ }
77
+ };
78
+ for (const root of roots) {
79
+ const parts = [`root\0${root}`];
80
+ await walk(root, parts);
81
+ snapshots.set(root, parts.sort().join("|"));
82
+ }
83
+ return snapshots;
84
+ }
85
+ function isNestedSourceRoot(parent, candidate) {
86
+ const relative = path.relative(parent, candidate);
87
+ return (relative !== "" &&
88
+ relative !== ".." &&
89
+ !relative.startsWith(`..${path.sep}`) &&
90
+ !path.isAbsolute(relative));
91
+ }
92
+ function changedSourceRoots(previous, current) {
93
+ const changed = [...new Set([...previous.keys(), ...current.keys()])].filter((root) => previous.get(root) !== current.get(root));
94
+ // Nested registered projects appear in their parent's recursive snapshot.
95
+ // Attribute the edit only to the deepest changed caller(s).
96
+ return changed
97
+ .filter((root) => !changed.some((candidate) => candidate !== root && isNestedSourceRoot(root, candidate)))
98
+ .sort();
99
+ }
100
+ class WorkspaceSystemGraphWatcher {
101
+ constructor(scope, callbacks, options, initialInventorySnapshot) {
102
+ this.scope = scope;
103
+ this.callbacks = callbacks;
104
+ this.options = options;
105
+ this.watcher = null;
106
+ this.pollTimer = null;
107
+ this.sourceTimer = null;
108
+ this.inventoryTimer = null;
109
+ this.inventoryRetryTimer = null;
110
+ this.closed = false;
111
+ this.sourcePaths = new Set();
112
+ this.ambiguousSourceChange = false;
113
+ this.lastSourceSnapshots = null;
114
+ this.failedInventorySnapshot = null;
115
+ this.inventoryGeneration = 0;
116
+ this.inventoryCheckInFlight = false;
117
+ this.inventoryCheckPending = false;
118
+ this.pollInFlight = false;
119
+ this.callbackQueue = Promise.resolve();
120
+ this.lastInventorySnapshot = initialInventorySnapshot;
121
+ this.arm();
122
+ }
123
+ static async create(scope, callbacks, options) {
124
+ // Establish the native/polling watcher from an async baseline. The graph
125
+ // route awaits this factory, so no synchronous workspace walk runs on the
126
+ // server loop before the watcher starts.
127
+ const initialInventorySnapshot = await snapshotWorkspaceWorkflowsAsync(scope.root);
128
+ return new WorkspaceSystemGraphWatcher(scope, callbacks, options, initialInventorySnapshot);
129
+ }
130
+ enqueue(callback, onFailure) {
131
+ this.callbackQueue = this.callbackQueue.then(async () => {
132
+ if (this.closed)
133
+ return;
134
+ try {
135
+ await callback();
136
+ }
137
+ catch {
138
+ // Watch callbacks are refresh hints. A failed scan/build must not tear
139
+ // down the watcher or affect the rest of Studio.
140
+ try {
141
+ onFailure?.();
142
+ }
143
+ catch {
144
+ // Failure recovery is best-effort too.
145
+ }
146
+ }
147
+ });
148
+ }
149
+ scheduleSourceChange(sourcePath) {
150
+ if (this.closed)
151
+ return;
152
+ if (sourcePath === null)
153
+ this.ambiguousSourceChange = true;
154
+ else
155
+ this.sourcePaths.add(sourcePath);
156
+ if (this.sourceTimer)
157
+ clearTimeout(this.sourceTimer);
158
+ this.sourceTimer = setTimeout(() => {
159
+ this.sourceTimer = null;
160
+ const paths = this.ambiguousSourceChange
161
+ ? null
162
+ : [...this.sourcePaths].sort();
163
+ this.sourcePaths.clear();
164
+ this.ambiguousSourceChange = false;
165
+ this.enqueue(() => this.callbacks.onSourceChange(this.scope, paths));
166
+ }, this.options.sourceDebounceMs ?? SOURCE_DEBOUNCE_MS);
167
+ }
168
+ dispatchInventoryChange(snapshot, retryNumber = 0, retryGeneration) {
169
+ const generation = retryGeneration ?? this.inventoryGeneration + 1;
170
+ if (retryGeneration !== undefined &&
171
+ retryGeneration !== this.inventoryGeneration) {
172
+ return;
173
+ }
174
+ if (retryGeneration === undefined) {
175
+ this.inventoryGeneration = generation;
176
+ if (this.inventoryRetryTimer)
177
+ clearTimeout(this.inventoryRetryTimer);
178
+ this.inventoryRetryTimer = null;
179
+ }
180
+ this.lastInventorySnapshot = snapshot;
181
+ this.failedInventorySnapshot = null;
182
+ this.enqueue(() => {
183
+ if (generation !== this.inventoryGeneration)
184
+ return;
185
+ return this.callbacks.onInventoryChange(this.scope);
186
+ }, () => {
187
+ if (this.closed ||
188
+ generation !== this.inventoryGeneration ||
189
+ this.lastInventorySnapshot !== snapshot) {
190
+ return;
191
+ }
192
+ if (retryNumber >=
193
+ (this.options.maxInventoryRetries ?? MAX_INVENTORY_RETRIES)) {
194
+ // Consume the observed fingerprint after bounded recovery. This
195
+ // leaves the server snapshot stale without turning polling into a
196
+ // permanent registry-scan/event-bus loop. A later real source or
197
+ // inventory change clears this sentinel and starts a fresh series.
198
+ this.failedInventorySnapshot = snapshot;
199
+ return;
200
+ }
201
+ this.scheduleInventoryRetry(snapshot, retryNumber + 1, generation);
202
+ });
203
+ }
204
+ scheduleInventoryRetry(snapshot, retryNumber, generation) {
205
+ if (this.closed || generation !== this.inventoryGeneration)
206
+ return;
207
+ if (this.inventoryRetryTimer)
208
+ clearTimeout(this.inventoryRetryTimer);
209
+ const delay = (this.options.inventoryRetryBaseMs ?? INVENTORY_RETRY_BASE_MS) *
210
+ 2 ** (retryNumber - 1);
211
+ this.inventoryRetryTimer = setTimeout(() => {
212
+ this.inventoryRetryTimer = null;
213
+ if (this.closed || generation !== this.inventoryGeneration)
214
+ return;
215
+ void snapshotWorkspaceWorkflowsAsync(this.scope.root)
216
+ .then((currentSnapshot) => {
217
+ if (this.closed || generation !== this.inventoryGeneration)
218
+ return;
219
+ if (currentSnapshot !== snapshot) {
220
+ this.dispatchInventoryChange(currentSnapshot);
221
+ return;
222
+ }
223
+ this.dispatchInventoryChange(snapshot, retryNumber, generation);
224
+ })
225
+ .catch(() => {
226
+ if (this.closed || generation !== this.inventoryGeneration)
227
+ return;
228
+ this.dispatchInventoryChange(snapshot, retryNumber, generation);
229
+ });
230
+ }, delay);
231
+ }
232
+ scheduleInventoryCheck(delay = this.options.inventoryDebounceMs ?? INVENTORY_DEBOUNCE_MS) {
233
+ if (this.closed)
234
+ return;
235
+ if (this.inventoryTimer)
236
+ clearTimeout(this.inventoryTimer);
237
+ this.inventoryTimer = setTimeout(() => {
238
+ this.inventoryTimer = null;
239
+ this.checkInventoryAsync();
240
+ }, delay);
241
+ }
242
+ checkInventoryAsync() {
243
+ if (this.closed)
244
+ return;
245
+ if (this.inventoryCheckInFlight) {
246
+ // One more async pass after the current walk is enough to cover any
247
+ // number of native events that arrive while it yields between dirs.
248
+ this.inventoryCheckPending = true;
249
+ return;
250
+ }
251
+ this.inventoryCheckInFlight = true;
252
+ this.inventoryCheckPending = false;
253
+ void snapshotWorkspaceWorkflowsAsync(this.scope.root)
254
+ .then((snapshot) => {
255
+ if (this.closed)
256
+ return;
257
+ if (snapshot === this.lastInventorySnapshot &&
258
+ snapshot !== this.failedInventorySnapshot) {
259
+ return;
260
+ }
261
+ this.dispatchInventoryChange(snapshot);
262
+ })
263
+ .catch(() => {
264
+ // A later native event retries an unreadable workspace. Watch hints
265
+ // must never surface as an unhandled rejection or tear down Studio.
266
+ })
267
+ .finally(() => {
268
+ this.inventoryCheckInFlight = false;
269
+ if (this.closed || !this.inventoryCheckPending)
270
+ return;
271
+ this.inventoryCheckPending = false;
272
+ this.checkInventoryAsync();
273
+ });
274
+ }
275
+ arm() {
276
+ if (this.closed)
277
+ return;
278
+ if (this.options.forcePolling) {
279
+ this.fallBackToPolling();
280
+ return;
281
+ }
282
+ try {
283
+ const listener = (_event, rawFilename) => {
284
+ if (rawFilename === null) {
285
+ this.scheduleSourceChange(null);
286
+ this.scheduleInventoryCheck();
287
+ return;
288
+ }
289
+ const relativePath = normalizeWatchPath(rawFilename);
290
+ if (ignoredRelativePath(relativePath))
291
+ return;
292
+ if (sourceRelativePath(relativePath)) {
293
+ this.scheduleSourceChange(confinedSourcePath(this.scope.root, relativePath));
294
+ }
295
+ // Event kind is unreliable across editors/platforms. The marker
296
+ // fingerprint decides whether inventory really changed.
297
+ this.scheduleInventoryCheck();
298
+ };
299
+ this.watcher = this.options.watchFactory
300
+ ? this.options.watchFactory(this.scope.root, listener)
301
+ : fs.watch(this.scope.root, { recursive: true }, (_event, rawFilename) => {
302
+ listener(_event, rawFilename);
303
+ });
304
+ this.watcher.on("error", () => this.fallBackToPolling());
305
+ }
306
+ catch {
307
+ this.fallBackToPolling();
308
+ }
309
+ }
310
+ fallBackToPolling() {
311
+ if (this.closed || this.pollTimer)
312
+ return;
313
+ let refreshAfterInitialSnapshot = this.watcher !== null;
314
+ this.watcher?.close();
315
+ this.watcher = null;
316
+ const poll = () => {
317
+ if (this.closed || this.pollInFlight)
318
+ return;
319
+ this.pollInFlight = true;
320
+ let sourceRoots = [];
321
+ try {
322
+ sourceRoots = this.callbacks.listSourceRoots(this.scope);
323
+ }
324
+ catch {
325
+ // Registry reads are hints too. Inventory polling still proceeds.
326
+ }
327
+ void Promise.all([
328
+ snapshotWorkflowSourceRootsAsync(sourceRoots),
329
+ snapshotWorkspaceWorkflowsAsync(this.scope.root),
330
+ ])
331
+ .then(([sourceSnapshots, inventorySnapshot]) => {
332
+ if (this.closed)
333
+ return;
334
+ const changedRoots = this.lastSourceSnapshots
335
+ ? changedSourceRoots(this.lastSourceSnapshots, sourceSnapshots)
336
+ : [];
337
+ const ambiguousInitialChange = this.lastSourceSnapshots === null && refreshAfterInitialSnapshot;
338
+ const sourceChanged = ambiguousInitialChange || changedRoots.length > 0;
339
+ this.lastSourceSnapshots = sourceSnapshots;
340
+ refreshAfterInitialSnapshot = false;
341
+ if (ambiguousInitialChange)
342
+ this.scheduleSourceChange(null);
343
+ else {
344
+ for (const sourceRoot of changedRoots) {
345
+ this.scheduleSourceChange(sourceRoot);
346
+ }
347
+ }
348
+ if (inventorySnapshot !== this.lastInventorySnapshot) {
349
+ this.dispatchInventoryChange(inventorySnapshot);
350
+ }
351
+ else if (sourceChanged &&
352
+ inventorySnapshot === this.failedInventorySnapshot) {
353
+ // Polling has no raw filesystem event. A source-fingerprint change
354
+ // is its proof that a real edit occurred after bounded give-up.
355
+ this.dispatchInventoryChange(inventorySnapshot);
356
+ }
357
+ })
358
+ .catch(() => {
359
+ // The next poll retries an unreadable workspace.
360
+ })
361
+ .finally(() => {
362
+ this.pollInFlight = false;
363
+ });
364
+ };
365
+ poll();
366
+ this.pollTimer = setInterval(poll, this.options.pollIntervalMs ?? POLL_INTERVAL_MS);
367
+ }
368
+ close() {
369
+ this.closed = true;
370
+ if (this.sourceTimer)
371
+ clearTimeout(this.sourceTimer);
372
+ if (this.inventoryTimer)
373
+ clearTimeout(this.inventoryTimer);
374
+ if (this.inventoryRetryTimer)
375
+ clearTimeout(this.inventoryRetryTimer);
376
+ if (this.pollTimer)
377
+ clearInterval(this.pollTimer);
378
+ this.watcher?.close();
379
+ this.watcher = null;
380
+ }
381
+ }
382
+ /** One watcher per requested workspace, independent of harness sessions. */
383
+ export class SystemGraphWatcherManager {
384
+ constructor(callbacks, options = {}) {
385
+ this.callbacks = callbacks;
386
+ this.options = options;
387
+ this.watchers = new Map();
388
+ this.pendingStarts = new Map();
389
+ }
390
+ start(scope) {
391
+ const existing = this.watchers.get(scope.workspaceKey);
392
+ if (existing?.scope.root === scope.root)
393
+ return Promise.resolve();
394
+ const pending = this.pendingStarts.get(scope.workspaceKey);
395
+ if (pending?.root === scope.root)
396
+ return pending.promise;
397
+ this.stop(scope.workspaceKey);
398
+ const token = {};
399
+ const promise = WorkspaceSystemGraphWatcher.create(scope, this.callbacks, this.options)
400
+ .then((watcher) => {
401
+ const current = this.pendingStarts.get(scope.workspaceKey);
402
+ if (current?.token !== token) {
403
+ watcher.close();
404
+ return;
405
+ }
406
+ this.watchers.set(scope.workspaceKey, watcher);
407
+ })
408
+ .finally(() => {
409
+ if (this.pendingStarts.get(scope.workspaceKey)?.token === token) {
410
+ this.pendingStarts.delete(scope.workspaceKey);
411
+ }
412
+ });
413
+ this.pendingStarts.set(scope.workspaceKey, {
414
+ root: scope.root,
415
+ token,
416
+ promise,
417
+ });
418
+ return promise;
419
+ }
420
+ retain(workspaceKeys) {
421
+ const tracked = new Set([
422
+ ...this.watchers.keys(),
423
+ ...this.pendingStarts.keys(),
424
+ ]);
425
+ for (const workspaceKey of tracked) {
426
+ if (!workspaceKeys.has(workspaceKey))
427
+ this.stop(workspaceKey);
428
+ }
429
+ }
430
+ stop(workspaceKey) {
431
+ this.pendingStarts.delete(workspaceKey);
432
+ this.watchers.get(workspaceKey)?.close();
433
+ this.watchers.delete(workspaceKey);
434
+ }
435
+ stopAll() {
436
+ const tracked = new Set([
437
+ ...this.watchers.keys(),
438
+ ...this.pendingStarts.keys(),
439
+ ]);
440
+ for (const workspaceKey of tracked) {
441
+ this.stop(workspaceKey);
442
+ }
443
+ }
444
+ get size() {
445
+ return this.watchers.size;
446
+ }
447
+ }
448
+ //# sourceMappingURL=system-graph-watcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-graph-watcher.js","sourceRoot":"","sources":["../../src/core/system-graph-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC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AE,CAAC;YACnC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,IAAI,CAAC,YAA0B;QAC7B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACL,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC;YACtB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACvB,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;SAC7B,CAAC,CAAC;QACH,KAAK,MAAM,YAAY,IAAI,OAAO,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ import type { SystemGraph, WorkspaceKey, WorkspaceScopeSummary } from "../shared/system-graph.js";
2
+ import { type AgentInventoryProvider, type WorkspaceScope } from "./system-graph-inventory.js";
3
+ import { type AgentRelationshipProvider } from "./system-graph-relationships.js";
4
+ export { HarnessRegistryInventoryProvider } from "./system-graph-inventory.js";
5
+ export type { AgentInventoryItem, AgentInventoryProvider, AgentInventoryResult, AgentInventoryWarning, WorkspaceScope, } from "./system-graph-inventory.js";
6
+ export { CachedAgentRelationshipProvider, SourceAgentRelationshipProvider, } from "./system-graph-relationships.js";
7
+ export type { AgentRelationshipCandidate, AgentRelationshipProvider, AgentRelationshipProviderResult, AgentRelationshipWarning, } from "./system-graph-relationships.js";
8
+ export interface WorkspaceScopeResolver {
9
+ resolve(workspaceKey: WorkspaceKey): Promise<WorkspaceScope | null>;
10
+ }
11
+ export interface WorkspaceScopeCatalog extends WorkspaceScopeResolver {
12
+ list(): Promise<WorkspaceScopeSummary[]>;
13
+ }
14
+ export interface SystemGraphBuilder {
15
+ build(scope: WorkspaceScope): Promise<SystemGraphBuildResult>;
16
+ /** Optional lifecycle hook for builders with workspace-scoped caches. */
17
+ retainWorkspaces?(workspaceKeys: ReadonlySet<WorkspaceKey>): void;
18
+ }
19
+ export interface SystemGraphBuildResult {
20
+ /** Internal cache policy; only graph crosses the HTTP boundary. */
21
+ cacheable: boolean;
22
+ graph: SystemGraph;
23
+ }
24
+ /**
25
+ * Resolves only roots the running Studio already knows about. A caller cannot
26
+ * manufacture a key and turn the graph endpoint into an arbitrary path scan.
27
+ */
28
+ export declare class LocalWorkspaceScopeCatalog implements WorkspaceScopeCatalog {
29
+ private readonly listRoots;
30
+ constructor(listRoots: () => readonly string[] | Promise<readonly string[]>);
31
+ list(): Promise<WorkspaceScopeSummary[]>;
32
+ resolve(workspaceKey: WorkspaceKey): Promise<WorkspaceScope | null>;
33
+ }
34
+ export declare class StaticSystemGraphBuilder implements SystemGraphBuilder {
35
+ private readonly inventory;
36
+ private readonly relationships;
37
+ private readonly callersByWorkspace;
38
+ constructor(inventory: AgentInventoryProvider, relationships?: AgentRelationshipProvider);
39
+ build(scope: WorkspaceScope): Promise<SystemGraphBuildResult>;
40
+ retainWorkspaces(workspaceKeys: ReadonlySet<WorkspaceKey>): void;
41
+ private retainRelationshipCallers;
42
+ }
43
+ //# sourceMappingURL=system-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-graph.d.ts","sourceRoot":"","sources":["../../src/core/system-graph.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,WAAW,EAEX,YAAY,EACZ,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACpB,MAAM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