@agimon-ai/po-workflow 0.0.0-alpha.46 → 0.0.0-alpha.48
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.
|
@@ -4447,6 +4447,40 @@ const DEFAULT_DEBOUNCE_MS = 150;
|
|
|
4447
4447
|
*/
|
|
4448
4448
|
const DEFAULT_RECONCILE_INTERVAL_MS = 3e4;
|
|
4449
4449
|
const RUNNING_STAGE = "running";
|
|
4450
|
+
/** Every session observes the same registry tree, so the process keeps one recursive watch per directory. */
|
|
4451
|
+
const sharedWatches = /* @__PURE__ */ new Map();
|
|
4452
|
+
async function watchShared(runtime, directory, onChange) {
|
|
4453
|
+
let entry = sharedWatches.get(directory);
|
|
4454
|
+
if (!entry) {
|
|
4455
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4456
|
+
const watcher = runtime.fs.watch([{
|
|
4457
|
+
path: directory,
|
|
4458
|
+
recursive: true
|
|
4459
|
+
}], () => listeners.forEach((listener) => listener()), runtime.ioContext).then((result) => (0, _agimon_ai_po_core_platform.getOrThrow)(result));
|
|
4460
|
+
const created = {
|
|
4461
|
+
listeners,
|
|
4462
|
+
watcher
|
|
4463
|
+
};
|
|
4464
|
+
sharedWatches.set(directory, created);
|
|
4465
|
+
watcher.catch(() => {
|
|
4466
|
+
if (sharedWatches.get(directory) === created) sharedWatches.delete(directory);
|
|
4467
|
+
});
|
|
4468
|
+
entry = created;
|
|
4469
|
+
}
|
|
4470
|
+
const shared = entry;
|
|
4471
|
+
shared.listeners.add(onChange);
|
|
4472
|
+
try {
|
|
4473
|
+
await shared.watcher;
|
|
4474
|
+
} catch (error) {
|
|
4475
|
+
shared.listeners.delete(onChange);
|
|
4476
|
+
throw error;
|
|
4477
|
+
}
|
|
4478
|
+
return { close: () => {
|
|
4479
|
+
if (!shared.listeners.delete(onChange) || shared.listeners.size > 0) return;
|
|
4480
|
+
if (sharedWatches.get(directory) === shared) sharedWatches.delete(directory);
|
|
4481
|
+
shared.watcher.then((watcher) => watcher.close(runtime.ioContext));
|
|
4482
|
+
} };
|
|
4483
|
+
}
|
|
4450
4484
|
/**
|
|
4451
4485
|
* Watch a run directory tree and report what changes.
|
|
4452
4486
|
*
|
|
@@ -4522,15 +4556,9 @@ var WorkflowRunObserverService = class {
|
|
|
4522
4556
|
try {
|
|
4523
4557
|
if (this.options.watch) this.watcher = this.options.watch(this.registry.workspacesDirectory(), () => this.scheduleSweep());
|
|
4524
4558
|
else {
|
|
4525
|
-
const
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
recursive: true
|
|
4529
|
-
}], () => this.scheduleSweep(), runtime.ioContext));
|
|
4530
|
-
if (this.disposed) await watcher.close(runtime.ioContext);
|
|
4531
|
-
else this.watcher = { close: () => {
|
|
4532
|
-
watcher.close(runtime.ioContext);
|
|
4533
|
-
} };
|
|
4559
|
+
const watcher = await watchShared(this.registry.runtime, this.registry.workspacesDirectory(), () => this.scheduleSweep());
|
|
4560
|
+
if (this.disposed) watcher.close();
|
|
4561
|
+
else this.watcher = watcher;
|
|
4534
4562
|
}
|
|
4535
4563
|
} catch {} finally {
|
|
4536
4564
|
this.watching = false;
|