omp-fabric 1.25.31 → 1.25.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/actors/manager.d.ts.map +1 -1
- package/dist/chunks/{chunk-KW6EUFD2.js → chunk-53ZZTYHQ.js} +244 -68
- package/dist/chunks/chunk-53ZZTYHQ.js.map +7 -0
- package/dist/chunks/{chunk-TRM76YFF.js → chunk-CEDP5WMR.js} +11 -3
- package/dist/chunks/chunk-CEDP5WMR.js.map +7 -0
- package/dist/chunks/{chunk-TDO2BRZM.js → chunk-I2GBVR67.js} +2 -2
- package/dist/chunks/{chunk-5CW2S6EB.js → chunk-Q2LRXHPR.js} +2 -2
- package/dist/chunks/{chunk-OLFP7R5J.js → chunk-Z3KAY6S7.js} +2 -2
- package/dist/compaction/hook.js +1 -1
- package/dist/compaction/lcm-maintenance.d.ts +6 -3
- package/dist/compaction/lcm-maintenance.d.ts.map +1 -1
- package/dist/compaction/lcm-runtime.d.ts +7 -1
- package/dist/compaction/lcm-runtime.d.ts.map +1 -1
- package/dist/compaction/lcm-runtime.js +251 -58
- package/dist/compaction/lcm-runtime.js.map +4 -4
- package/dist/core/event-loop-slice.d.ts +11 -0
- package/dist/core/event-loop-slice.d.ts.map +1 -0
- package/dist/core/session-context.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +68 -16
- package/dist/fabric-runtime-state.js.map +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -12
- package/dist/index.js.map +2 -2
- package/dist/mesh/store.d.ts +3 -0
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/providers/omp-tools-provider.d.ts +11 -1
- package/dist/providers/omp-tools-provider.d.ts.map +1 -1
- package/dist/residency/host.js +4 -4
- package/dist/residency/omp-entry.js +4 -4
- package/dist/storage/lcm-ledger.d.ts +9 -1
- package/dist/storage/lcm-ledger.d.ts.map +1 -1
- package/dist/storage/lcm-migration.d.ts +6 -2
- package/dist/storage/lcm-migration.d.ts.map +1 -1
- package/dist/storage/lcm-offthread.d.ts +9 -0
- package/dist/storage/lcm-offthread.d.ts.map +1 -0
- package/dist/topology/control-plane.d.ts.map +1 -1
- package/dist/topology/participant-directory.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunks/chunk-KW6EUFD2.js.map +0 -7
- package/dist/chunks/chunk-TRM76YFF.js.map +0 -7
- /package/dist/chunks/{chunk-TDO2BRZM.js.map → chunk-I2GBVR67.js.map} +0 -0
- /package/dist/chunks/{chunk-5CW2S6EB.js.map → chunk-Q2LRXHPR.js.map} +0 -0
- /package/dist/chunks/{chunk-OLFP7R5J.js.map → chunk-Z3KAY6S7.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.25.35
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- OMP 18.12.5 compatibility. The host renamed the transcript projection option `keepDanglingToolCalls` to `inFlightToolCallIds`, so a single-entry projection built for token estimates stripped every in-flight `toolCall` and undercounted the compaction budget. Fabric now passes both names: `inFlightToolCallIds` on 18.12.5 and `keepDanglingToolCalls` on 18.4.4 through 18.11.x, so the declared host floor keeps working.
|
|
8
|
+
- `omp.wait` with no running job resolves with the host's `Nothing to wait for` result on 18.12.5 instead of rejecting, matching the host contract.
|
|
9
|
+
- Development and test pins move from 18.11.0 to 18.12.5.
|
|
10
|
+
|
|
11
|
+
## 1.25.34
|
|
12
|
+
|
|
13
|
+
### Notes
|
|
14
|
+
|
|
15
|
+
- Test-only fix for the windows-latest job: the sliced-import test in `tests/compaction/lcm-yielding.test.ts` forced a 0 ms slice budget over a 600-entry session, so every entry became its own SQLite commit and Windows fsync pushed it past the 30 s test timeout. It now imports 60 entries, which still forces more than 60 slices and is compared against one synchronous run.
|
|
16
|
+
- 1.25.33 failed the windows-latest Test job and never published; every change listed under 1.25.32 and 1.25.33 ships in this release. The `v1.25.32` and `v1.25.33` tags stay where they are.
|
|
17
|
+
|
|
18
|
+
## 1.25.33
|
|
19
|
+
|
|
20
|
+
### Notes
|
|
21
|
+
|
|
22
|
+
- Test-only fix for the windows-latest job: the LCM concurrency dispatch tests stepped the runtime one event-loop turn at a time, so on a slow runner the new 20 ms maintenance slices added turns and one test hung. Those tests now pin `sliceMs` so they stay deterministic; slicing itself is covered by `tests/compaction/lcm-yielding.test.ts`. The full suite also passes with the slice budget forced to 0 ms.
|
|
23
|
+
- 1.25.32 failed the windows-latest Test job and never published; every change listed under 1.25.32 ships in this release. Its `v1.25.32` tag stays where it is.
|
|
24
|
+
|
|
25
|
+
## 1.25.32
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Mesh polling does less work per tick. Every periodic poll first compares a stat fingerprint of the files it reads and skips the read and parse when nothing changed; the control-plane poll backs off from 100 ms to at most 1 s while idle and snaps back on any request or change; `get` is a direct lookup, and `list`/`listAll` reuse one key-sorted snapshot per state revision instead of filtering, sorting and deep-cloning every entry on every call.
|
|
30
|
+
- LCM no longer blocks the host event loop for seconds. Startup counts and `PRAGMA integrity_check` run on a worker thread, and session import, readback, node loading and maintenance yield every ~20 ms. On a 2 GB ledger the integrity check used to block 27 s; the longest slice is now under 50 ms in most phases (maintenance with model summaries off peaks around 100 ms).
|
|
31
|
+
- `selectCondensation` and the ancestor lookup scanned every node pair; rewriting the summary-edge joins brings them from 6.9 s to 19 ms on a real ledger with identical results.
|
|
32
|
+
- Subagent sessions no longer open, migrate, reconcile or maintain the LCM ledger; only the top-level session owns it, and subagents compact with OMP core.
|
|
33
|
+
- `omp.write` to `agent://<id>` inside `fabric_exec` now reaches live peers through the host agent registry instead of always failing with `Peer messaging is unavailable in this session.`; sessions where the host disables messaging still get that error.
|
|
34
|
+
|
|
3
35
|
## 1.25.31
|
|
4
36
|
|
|
5
37
|
### Notes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/actors/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAKpD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAkB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKpD,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EAEnB,0BAA0B,EAE1B,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAElB,qBAAqB,EAGtB,MAAM,YAAY,CAAC;AAMpB,MAAM,WAAW,0BAA0B;IACzC,yDAAyD;IACzD,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAmND,qBAAa,2BAA4B,SAAQ,KAAK;;CAKrD;AAED,qBAAa,YAAY;;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/actors/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAKpD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAA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,IAAI;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;IAkCvB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAejD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0pC5B,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;CA0M5D"}
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
peerLabelPrefix,
|
|
23
23
|
writeHandoffSession
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-Q2LRXHPR.js";
|
|
25
25
|
import {
|
|
26
26
|
DEFAULT_FABRIC_CONFIG,
|
|
27
27
|
MAX_AGENT_TIMEOUT_MS,
|
|
@@ -166,6 +166,15 @@ var atomicWrite = (filePath, value, maxBytes = Number.POSITIVE_INFINITY) => {
|
|
|
166
166
|
}
|
|
167
167
|
writeFileAtomic(filePath, serialized);
|
|
168
168
|
};
|
|
169
|
+
var fileFingerprint = (filePath) => {
|
|
170
|
+
try {
|
|
171
|
+
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
172
|
+
return stat ? `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeMs}` : "missing";
|
|
173
|
+
} catch {
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
var MAX_IDLE_TAIL_CURSORS = 64;
|
|
169
178
|
var compactStateTombstones = (state, maxTombstones) => {
|
|
170
179
|
state.versions ??= {};
|
|
171
180
|
const orderedKeys = [];
|
|
@@ -232,6 +241,9 @@ var MeshStore = class {
|
|
|
232
241
|
#lockTimeoutMs;
|
|
233
242
|
#staleLockMs;
|
|
234
243
|
#stateCache;
|
|
244
|
+
#stateRevision = 0;
|
|
245
|
+
#generationCache;
|
|
246
|
+
#idleTail;
|
|
235
247
|
async publish(input) {
|
|
236
248
|
this.#validateTopic(input.topic);
|
|
237
249
|
if (input.to !== void 0 && !input.to.trim()) throw new Error("Mesh recipient is empty");
|
|
@@ -299,7 +311,24 @@ var MeshStore = class {
|
|
|
299
311
|
}
|
|
300
312
|
tail(cursor, limit = 100) {
|
|
301
313
|
const boundedLimit = Math.max(1, Math.min(Math.floor(limit), this.maxReadEvents));
|
|
302
|
-
const
|
|
314
|
+
const generationFingerprint = fileFingerprint(this.#generationPath);
|
|
315
|
+
const eventsFingerprint = fileFingerprint(this.#eventsPath);
|
|
316
|
+
const fingerprint = generationFingerprint !== void 0 && eventsFingerprint !== void 0 ? `${eventsFingerprint}|${generationFingerprint}` : void 0;
|
|
317
|
+
const idle = this.#idleTail;
|
|
318
|
+
if (fingerprint !== void 0 && idle?.fingerprint === fingerprint && idle.cursors.has(cursor)) {
|
|
319
|
+
return { events: [], nextOffset: cursor };
|
|
320
|
+
}
|
|
321
|
+
const result = this.#readTail(cursor, boundedLimit, generationFingerprint);
|
|
322
|
+
if (fingerprint !== void 0 && result.events.length === 0 && result.nextOffset === cursor) {
|
|
323
|
+
if (this.#idleTail?.fingerprint !== fingerprint) {
|
|
324
|
+
this.#idleTail = { fingerprint, cursors: /* @__PURE__ */ new Set() };
|
|
325
|
+
}
|
|
326
|
+
if (this.#idleTail.cursors.size < MAX_IDLE_TAIL_CURSORS) this.#idleTail.cursors.add(cursor);
|
|
327
|
+
}
|
|
328
|
+
return result;
|
|
329
|
+
}
|
|
330
|
+
#readTail(cursor, boundedLimit, generationFingerprint) {
|
|
331
|
+
const generation = this.#readGeneration(generationFingerprint);
|
|
303
332
|
const decoded = this.#decodeCursor(cursor);
|
|
304
333
|
let descriptor;
|
|
305
334
|
try {
|
|
@@ -450,12 +479,30 @@ var MeshStore = class {
|
|
|
450
479
|
}
|
|
451
480
|
list(prefix = "", limit = 100) {
|
|
452
481
|
const boundedLimit = Math.max(1, Math.min(Math.floor(limit), this.maxReadEvents));
|
|
453
|
-
return this.
|
|
482
|
+
return this.scan(prefix).slice(0, boundedLimit).map((entry) => jsonClone(entry));
|
|
454
483
|
}
|
|
455
484
|
/** Internal project-state scan for host-managed indexes that must reconcile every key. */
|
|
456
485
|
listAll(prefix = "") {
|
|
486
|
+
return this.scan(prefix).map((entry) => jsonClone(entry));
|
|
487
|
+
}
|
|
488
|
+
/** Shared key-sorted entries of the current state revision; callers must not mutate them. */
|
|
489
|
+
scan(prefix = "") {
|
|
457
490
|
if (prefix) this.#validateKey(prefix);
|
|
458
|
-
|
|
491
|
+
const cache = this.#currentStateCache();
|
|
492
|
+
cache.sorted ??= Object.values(cache.state.entries).sort(
|
|
493
|
+
(left, right) => left.key.localeCompare(right.key)
|
|
494
|
+
);
|
|
495
|
+
if (!prefix) return cache.sorted;
|
|
496
|
+
cache.byPrefix ??= /* @__PURE__ */ new Map();
|
|
497
|
+
let matched = cache.byPrefix.get(prefix);
|
|
498
|
+
if (!matched) {
|
|
499
|
+
matched = cache.sorted.filter((entry) => entry.key.startsWith(prefix));
|
|
500
|
+
cache.byPrefix.set(prefix, matched);
|
|
501
|
+
}
|
|
502
|
+
return matched;
|
|
503
|
+
}
|
|
504
|
+
stateRevision() {
|
|
505
|
+
return this.#currentStateCache().revision;
|
|
459
506
|
}
|
|
460
507
|
async put(input) {
|
|
461
508
|
this.#validateKey(input.key);
|
|
@@ -527,35 +574,48 @@ var MeshStore = class {
|
|
|
527
574
|
});
|
|
528
575
|
}
|
|
529
576
|
#readCachedState() {
|
|
577
|
+
return this.#currentStateCache().state;
|
|
578
|
+
}
|
|
579
|
+
#currentStateCache() {
|
|
580
|
+
let stat;
|
|
530
581
|
try {
|
|
531
|
-
|
|
532
|
-
const cached = this.#stateCache;
|
|
533
|
-
if (cached && cached.device === stat.dev && cached.inode === stat.ino && cached.size === stat.size && cached.modifiedAt === stat.mtimeMs) {
|
|
534
|
-
return cached.state;
|
|
535
|
-
}
|
|
582
|
+
stat = fs.statSync(this.#statePath, { throwIfNoEntry: false });
|
|
536
583
|
} catch (error) {
|
|
537
584
|
this.#stateCache = void 0;
|
|
538
|
-
if (errorCode(error) === "ENOENT") return { format: 1, entries: {} };
|
|
539
585
|
throw error;
|
|
540
586
|
}
|
|
587
|
+
const cached = this.#stateCache;
|
|
588
|
+
if (!stat) {
|
|
589
|
+
if (cached && cached.inode === -1) return cached;
|
|
590
|
+
return this.#storeStateCache({ format: 1, entries: {} }, -1, -1, -1, -1);
|
|
591
|
+
}
|
|
592
|
+
if (cached && cached.device === stat.dev && cached.inode === stat.ino && cached.size === stat.size && cached.modifiedAt === stat.mtimeMs) {
|
|
593
|
+
return cached;
|
|
594
|
+
}
|
|
541
595
|
const state = readState(this.#statePath, this.#maxStateBytes);
|
|
542
|
-
this.#
|
|
543
|
-
return state;
|
|
596
|
+
return this.#storeStateCache(state, stat.dev, stat.ino, stat.size, stat.mtimeMs);
|
|
544
597
|
}
|
|
545
598
|
#cacheState(state) {
|
|
546
599
|
try {
|
|
547
600
|
const stat = fs.statSync(this.#statePath);
|
|
548
|
-
this.#
|
|
549
|
-
device: stat.dev,
|
|
550
|
-
inode: stat.ino,
|
|
551
|
-
size: stat.size,
|
|
552
|
-
modifiedAt: stat.mtimeMs,
|
|
553
|
-
state
|
|
554
|
-
};
|
|
601
|
+
this.#storeStateCache(state, stat.dev, stat.ino, stat.size, stat.mtimeMs);
|
|
555
602
|
} catch {
|
|
556
603
|
this.#stateCache = void 0;
|
|
557
604
|
}
|
|
558
605
|
}
|
|
606
|
+
#storeStateCache(state, device, inode, size, modifiedAt) {
|
|
607
|
+
this.#stateRevision += 1;
|
|
608
|
+
const cache = {
|
|
609
|
+
device,
|
|
610
|
+
inode,
|
|
611
|
+
size,
|
|
612
|
+
modifiedAt,
|
|
613
|
+
state,
|
|
614
|
+
revision: this.#stateRevision
|
|
615
|
+
};
|
|
616
|
+
this.#stateCache = cache;
|
|
617
|
+
return cache;
|
|
618
|
+
}
|
|
559
619
|
async #withLock(operation) {
|
|
560
620
|
fs.mkdirSync(this.root, { recursive: true, mode: 448 });
|
|
561
621
|
const deadline = Date.now() + this.#lockTimeoutMs;
|
|
@@ -635,13 +695,20 @@ ${Date.now()}
|
|
|
635
695
|
return false;
|
|
636
696
|
}
|
|
637
697
|
}
|
|
638
|
-
#readGeneration() {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
698
|
+
#readGeneration(fingerprint = fileFingerprint(this.#generationPath)) {
|
|
699
|
+
const cached = this.#generationCache;
|
|
700
|
+
if (fingerprint !== void 0 && cached?.fingerprint === fingerprint) return cached.value;
|
|
701
|
+
let value = 0;
|
|
702
|
+
if (fingerprint !== "missing") {
|
|
703
|
+
try {
|
|
704
|
+
const parsed = JSON.parse(fs.readFileSync(this.#generationPath, "utf8"));
|
|
705
|
+
if (typeof parsed === "number" && Number.isSafeInteger(parsed) && parsed >= 0) value = parsed;
|
|
706
|
+
} catch {
|
|
707
|
+
value = 0;
|
|
708
|
+
}
|
|
644
709
|
}
|
|
710
|
+
if (fingerprint !== void 0) this.#generationCache = { fingerprint, value };
|
|
711
|
+
return value;
|
|
645
712
|
}
|
|
646
713
|
#encodeCursor(generation, offset) {
|
|
647
714
|
const cursor = generation * CURSOR_OFFSET_BASE + offset;
|
|
@@ -3521,6 +3588,7 @@ var ActorManager = class {
|
|
|
3521
3588
|
#claimResidency;
|
|
3522
3589
|
#rootId;
|
|
3523
3590
|
#meshCursorPath;
|
|
3591
|
+
#writtenMeshCursor;
|
|
3524
3592
|
#relayParticipantSteering;
|
|
3525
3593
|
#retention;
|
|
3526
3594
|
#acquireCapabilityView;
|
|
@@ -4108,9 +4176,10 @@ var ActorManager = class {
|
|
|
4108
4176
|
}
|
|
4109
4177
|
}
|
|
4110
4178
|
#writeMeshCursor() {
|
|
4111
|
-
if (!this.#meshCursorPath) return;
|
|
4179
|
+
if (!this.#meshCursorPath || this.#writtenMeshCursor === this.#meshOffset) return;
|
|
4112
4180
|
try {
|
|
4113
4181
|
atomicWrite2(this.#meshCursorPath, { format: 1, cursor: this.#meshOffset });
|
|
4182
|
+
this.#writtenMeshCursor = this.#meshOffset;
|
|
4114
4183
|
} catch {
|
|
4115
4184
|
}
|
|
4116
4185
|
}
|
|
@@ -5766,10 +5835,14 @@ var LifecycleBroker = class {
|
|
|
5766
5835
|
|
|
5767
5836
|
// src/topology/control-plane.ts
|
|
5768
5837
|
import { createHash as createHash2, randomUUID as randomUUID8 } from "node:crypto";
|
|
5838
|
+
import fs13 from "node:fs";
|
|
5839
|
+
import path14 from "node:path";
|
|
5769
5840
|
var CONTROL_TOPIC = "fabric.control.command";
|
|
5770
5841
|
var ACK_TOPIC = "fabric.control.ack";
|
|
5771
5842
|
var CONTROL_SEEN_PREFIX = "topology/control-seen/";
|
|
5772
5843
|
var DEFAULT_POLL_MS = 100;
|
|
5844
|
+
var MAX_IDLE_POLL_MS = 1e3;
|
|
5845
|
+
var ACTIVE_WINDOW_MS = 3e3;
|
|
5773
5846
|
var DEFAULT_ACK_TIMEOUT_MS = 5e3;
|
|
5774
5847
|
var DEFAULT_RESULT_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
5775
5848
|
var MAX_CONTROL_TIMEOUT_MS = 24 * 60 * 60 * 1e3 + 6e4;
|
|
@@ -5798,6 +5871,10 @@ var FabricControlPlane = class {
|
|
|
5798
5871
|
this.options = options;
|
|
5799
5872
|
this.#pollMs = Math.max(20, options.pollMs ?? DEFAULT_POLL_MS);
|
|
5800
5873
|
this.#ackTimeoutMs = Math.max(this.#pollMs * 4, options.acknowledgementTimeoutMs ?? DEFAULT_ACK_TIMEOUT_MS);
|
|
5874
|
+
this.#idlePollMs = Math.max(
|
|
5875
|
+
this.#pollMs,
|
|
5876
|
+
Math.min(MAX_IDLE_POLL_MS, Math.floor(this.#ackTimeoutMs / 4))
|
|
5877
|
+
);
|
|
5801
5878
|
this.#offset = 0;
|
|
5802
5879
|
this.#lastSequence = 0;
|
|
5803
5880
|
}
|
|
@@ -5805,10 +5882,14 @@ var FabricControlPlane = class {
|
|
|
5805
5882
|
#activeCommands = /* @__PURE__ */ new Map();
|
|
5806
5883
|
#activeHandlers = /* @__PURE__ */ new Set();
|
|
5807
5884
|
#pollMs;
|
|
5885
|
+
#idlePollMs;
|
|
5808
5886
|
#ackTimeoutMs;
|
|
5809
5887
|
#offset;
|
|
5810
5888
|
#lastSequence;
|
|
5811
5889
|
#timer;
|
|
5890
|
+
#delay = 0;
|
|
5891
|
+
#lastActivityAt = 0;
|
|
5892
|
+
#watcher;
|
|
5812
5893
|
#polling;
|
|
5813
5894
|
#closed = false;
|
|
5814
5895
|
#handler;
|
|
@@ -5817,8 +5898,47 @@ var FabricControlPlane = class {
|
|
|
5817
5898
|
this.#handler = handler;
|
|
5818
5899
|
if (!this.options.enabled || this.#timer) return;
|
|
5819
5900
|
this.#closed = false;
|
|
5820
|
-
this.#
|
|
5821
|
-
this.#
|
|
5901
|
+
this.#lastActivityAt = Date.now();
|
|
5902
|
+
this.#watch();
|
|
5903
|
+
this.#schedule(this.#pollMs);
|
|
5904
|
+
}
|
|
5905
|
+
#schedule(delay5) {
|
|
5906
|
+
if (this.#timer) clearTimeout(this.#timer);
|
|
5907
|
+
this.#delay = delay5;
|
|
5908
|
+
const timer = setTimeout(() => {
|
|
5909
|
+
void this.#poll().catch(() => void 0).finally(() => {
|
|
5910
|
+
if (this.#timer === timer && !this.#closed) this.#schedule(this.#nextDelay());
|
|
5911
|
+
});
|
|
5912
|
+
}, delay5);
|
|
5913
|
+
timer.unref();
|
|
5914
|
+
this.#timer = timer;
|
|
5915
|
+
}
|
|
5916
|
+
#nextDelay() {
|
|
5917
|
+
if (this.#pending.size > 0 || this.#activeCommands.size > 0 || Date.now() - this.#lastActivityAt < ACTIVE_WINDOW_MS) {
|
|
5918
|
+
return this.#pollMs;
|
|
5919
|
+
}
|
|
5920
|
+
return Math.min(this.#idlePollMs, Math.max(this.#pollMs, this.#delay * 2));
|
|
5921
|
+
}
|
|
5922
|
+
#wake() {
|
|
5923
|
+
this.#lastActivityAt = Date.now();
|
|
5924
|
+
if (!this.#timer || this.#closed || this.#delay <= this.#pollMs) return;
|
|
5925
|
+
this.#schedule(this.#pollMs);
|
|
5926
|
+
}
|
|
5927
|
+
#watch() {
|
|
5928
|
+
if (process.platform === "win32" || this.#watcher) return;
|
|
5929
|
+
try {
|
|
5930
|
+
const watcher = fs13.watch(this.mesh.root, { persistent: false }, (_event, filename) => {
|
|
5931
|
+
if (filename !== null && path14.basename(filename.toString()) !== "events.jsonl") return;
|
|
5932
|
+
this.#wake();
|
|
5933
|
+
});
|
|
5934
|
+
watcher.on("error", () => {
|
|
5935
|
+
watcher.close();
|
|
5936
|
+
if (this.#watcher === watcher) this.#watcher = void 0;
|
|
5937
|
+
});
|
|
5938
|
+
this.#watcher = watcher;
|
|
5939
|
+
} catch {
|
|
5940
|
+
this.#watcher = void 0;
|
|
5941
|
+
}
|
|
5822
5942
|
}
|
|
5823
5943
|
async request(ownerHostId, targetId, operation, input = {}, ownerIdentityId = ownerHostId) {
|
|
5824
5944
|
const { commandId, acceptance } = await this.#requestAcceptance(
|
|
@@ -5881,6 +6001,7 @@ var FabricControlPlane = class {
|
|
|
5881
6001
|
};
|
|
5882
6002
|
pendingRequest = pending;
|
|
5883
6003
|
this.#pending.set(commandId, pending);
|
|
6004
|
+
this.#wake();
|
|
5884
6005
|
if (options.signal) {
|
|
5885
6006
|
const onAbort = () => {
|
|
5886
6007
|
const cancelled = this.#clearPending(commandId);
|
|
@@ -5964,8 +6085,10 @@ var FabricControlPlane = class {
|
|
|
5964
6085
|
}
|
|
5965
6086
|
async close() {
|
|
5966
6087
|
if (this.#closed) return;
|
|
5967
|
-
if (this.#timer)
|
|
6088
|
+
if (this.#timer) clearTimeout(this.#timer);
|
|
5968
6089
|
this.#timer = void 0;
|
|
6090
|
+
this.#watcher?.close();
|
|
6091
|
+
this.#watcher = void 0;
|
|
5969
6092
|
await this.#polling?.catch(() => void 0);
|
|
5970
6093
|
await this.#drain().catch(() => void 0);
|
|
5971
6094
|
this.#closed = true;
|
|
@@ -5996,6 +6119,7 @@ var FabricControlPlane = class {
|
|
|
5996
6119
|
while (true) {
|
|
5997
6120
|
const tail = this.mesh.tail(this.#offset, 100);
|
|
5998
6121
|
this.#offset = tail.nextOffset;
|
|
6122
|
+
if (tail.events.length > 0) this.#lastActivityAt = Date.now();
|
|
5999
6123
|
for (const event of tail.events) {
|
|
6000
6124
|
if (event.sequence <= this.#lastSequence) continue;
|
|
6001
6125
|
this.#lastSequence = event.sequence;
|
|
@@ -6164,7 +6288,7 @@ var FabricControlPlane = class {
|
|
|
6164
6288
|
async #cleanupSeen(now) {
|
|
6165
6289
|
if (now - this.#seenCleanupAt < this.#ackTimeoutMs) return;
|
|
6166
6290
|
this.#seenCleanupAt = now;
|
|
6167
|
-
const candidates = this.mesh.
|
|
6291
|
+
const candidates = this.mesh.scan(CONTROL_SEEN_PREFIX).flatMap((entry) => {
|
|
6168
6292
|
const record = controlSeenRecord(entry.value);
|
|
6169
6293
|
return !record || record.expiresAt < now ? [{ entry, record }] : [];
|
|
6170
6294
|
});
|
|
@@ -6361,6 +6485,8 @@ var ParticipantDirectory = class {
|
|
|
6361
6485
|
#refreshScheduled = false;
|
|
6362
6486
|
#refreshAgain = false;
|
|
6363
6487
|
#quiescing = false;
|
|
6488
|
+
#index;
|
|
6489
|
+
#projectMemo;
|
|
6364
6490
|
registerSource(source) {
|
|
6365
6491
|
this.#sources.add(source);
|
|
6366
6492
|
if (this.#timer) this.scheduleRefresh();
|
|
@@ -6424,16 +6550,76 @@ var ParticipantDirectory = class {
|
|
|
6424
6550
|
if (!options.kinds || options.kinds.includes(self2.kind)) byId2.set(self2.id, self2);
|
|
6425
6551
|
return [...byId2.values()];
|
|
6426
6552
|
}
|
|
6427
|
-
const
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6553
|
+
const byId = this.#collect(options, now, this.#currentIndex());
|
|
6554
|
+
const self = this.self(now);
|
|
6555
|
+
if ((!options.kinds || options.kinds.includes(self.kind)) && options.scope !== "project" && !byId.has(self.id)) {
|
|
6556
|
+
byId.set(self.id, self);
|
|
6557
|
+
}
|
|
6558
|
+
return structuredClone(
|
|
6559
|
+
[...byId.values()].sort(
|
|
6560
|
+
(left, right) => left.startedAt - right.startedAt || left.name.localeCompare(right.name) || left.id.localeCompare(right.id)
|
|
6561
|
+
)
|
|
6432
6562
|
);
|
|
6433
|
-
|
|
6434
|
-
|
|
6563
|
+
}
|
|
6564
|
+
get(id, now = Date.now()) {
|
|
6565
|
+
const target = id === "main" ? this.options.rootId : id;
|
|
6566
|
+
if (!this.options.enabled) {
|
|
6567
|
+
return this.list({ scope: "project" }, now).find((participant) => participant.id === target);
|
|
6568
|
+
}
|
|
6569
|
+
const found = this.#projectParticipants(now).get(target);
|
|
6570
|
+
return found ? structuredClone(found) : void 0;
|
|
6571
|
+
}
|
|
6572
|
+
#currentIndex() {
|
|
6573
|
+
const revision = this.mesh.stateRevision();
|
|
6574
|
+
if (this.#index?.revision === revision) return this.#index;
|
|
6575
|
+
const hosts = /* @__PURE__ */ new Map();
|
|
6576
|
+
for (const entry of this.mesh.scan(HOST_PREFIX)) {
|
|
6577
|
+
const host = hostFromEntry(entry);
|
|
6578
|
+
if (host) hosts.set(host.id, host);
|
|
6579
|
+
}
|
|
6580
|
+
const participants = [];
|
|
6581
|
+
const participantsById = /* @__PURE__ */ new Map();
|
|
6582
|
+
for (const entry of this.mesh.scan(PARTICIPANT_PREFIX)) {
|
|
6435
6583
|
const participant = participantFromEntry(entry);
|
|
6436
6584
|
if (!participant) continue;
|
|
6585
|
+
participants.push({ entry, participant });
|
|
6586
|
+
if (!participantsById.has(participant.id)) participantsById.set(participant.id, participant);
|
|
6587
|
+
}
|
|
6588
|
+
this.#index = {
|
|
6589
|
+
revision,
|
|
6590
|
+
hosts,
|
|
6591
|
+
participants,
|
|
6592
|
+
participantsById,
|
|
6593
|
+
legacySessions: this.mesh.scan(LEGACY_SESSION_PREFIX),
|
|
6594
|
+
legacyActors: this.mesh.scan(LEGACY_ACTOR_PREFIX)
|
|
6595
|
+
};
|
|
6596
|
+
return this.#index;
|
|
6597
|
+
}
|
|
6598
|
+
#projectParticipants(now) {
|
|
6599
|
+
const index = this.#currentIndex();
|
|
6600
|
+
const memo = this.#projectMemo;
|
|
6601
|
+
if (memo && memo.revision === index.revision && memo.after < now && now <= memo.until) {
|
|
6602
|
+
return memo.byId;
|
|
6603
|
+
}
|
|
6604
|
+
let after = Number.NEGATIVE_INFINITY;
|
|
6605
|
+
let until = Number.POSITIVE_INFINITY;
|
|
6606
|
+
const boundary = (threshold) => {
|
|
6607
|
+
if (threshold < now) after = Math.max(after, threshold);
|
|
6608
|
+
else until = Math.min(until, threshold);
|
|
6609
|
+
};
|
|
6610
|
+
for (const { participant } of index.participants) {
|
|
6611
|
+
const owner = index.hosts.get(participant.ownerHostId);
|
|
6612
|
+
if (owner) boundary(owner.expiresAt);
|
|
6613
|
+
}
|
|
6614
|
+
for (const entry of index.legacySessions) boundary(entry.updatedAt + PARTICIPANT_LEASE_MS);
|
|
6615
|
+
const byId = this.#collect({ scope: "project" }, now, index);
|
|
6616
|
+
this.#projectMemo = { revision: index.revision, after, until, byId };
|
|
6617
|
+
return byId;
|
|
6618
|
+
}
|
|
6619
|
+
#collect(options, now, index) {
|
|
6620
|
+
const hosts = index.hosts;
|
|
6621
|
+
const byId = /* @__PURE__ */ new Map();
|
|
6622
|
+
for (const { participant } of index.participants) {
|
|
6437
6623
|
const owner = hosts.get(participant.ownerHostId);
|
|
6438
6624
|
const stale = !owner || owner.expiresAt < now || owner.identity.id !== participant.ownerIdentityId || owner.rootId !== participant.rootId;
|
|
6439
6625
|
if (stale && !options.includeStale) continue;
|
|
@@ -6446,39 +6632,34 @@ var ParticipantDirectory = class {
|
|
|
6446
6632
|
stale
|
|
6447
6633
|
});
|
|
6448
6634
|
}
|
|
6449
|
-
const legacyRoots = new Map(
|
|
6450
|
-
this.mesh.listAll(LEGACY_SESSION_PREFIX).flatMap((entry) => {
|
|
6451
|
-
const root = legacyRootFromEntry(entry, this.options.rootId, now);
|
|
6452
|
-
return root ? [[root.id, root]] : [];
|
|
6453
|
-
})
|
|
6454
|
-
);
|
|
6455
6635
|
if (options.scope !== "local" && options.scope !== "lineage") {
|
|
6636
|
+
const legacyRoots = this.#legacyRoots(index, now);
|
|
6456
6637
|
if (!options.kinds || options.kinds.includes("root")) {
|
|
6457
6638
|
for (const root of legacyRoots.values()) {
|
|
6458
6639
|
if (!byId.has(root.id)) byId.set(root.id, root);
|
|
6459
6640
|
}
|
|
6460
6641
|
}
|
|
6461
6642
|
if (!options.kinds || options.kinds.includes("actor")) {
|
|
6462
|
-
for (const entry of
|
|
6643
|
+
for (const entry of index.legacyActors) {
|
|
6463
6644
|
const actor = legacyActorFromEntry(entry, legacyRoots);
|
|
6464
6645
|
if (actor && !byId.has(actor.id)) byId.set(actor.id, actor);
|
|
6465
6646
|
}
|
|
6466
6647
|
}
|
|
6467
6648
|
}
|
|
6468
|
-
|
|
6469
|
-
if ((!options.kinds || options.kinds.includes(self.kind)) && options.scope !== "project" && !byId.has(self.id)) {
|
|
6470
|
-
byId.set(self.id, self);
|
|
6471
|
-
}
|
|
6472
|
-
return [...byId.values()].sort(
|
|
6473
|
-
(left, right) => left.startedAt - right.startedAt || left.name.localeCompare(right.name) || left.id.localeCompare(right.id)
|
|
6474
|
-
);
|
|
6649
|
+
return byId;
|
|
6475
6650
|
}
|
|
6476
|
-
|
|
6477
|
-
const
|
|
6478
|
-
|
|
6651
|
+
#legacyRoots(index, now) {
|
|
6652
|
+
const roots = /* @__PURE__ */ new Map();
|
|
6653
|
+
for (const entry of index.legacySessions) {
|
|
6654
|
+
const root = legacyRootFromEntry(entry, this.options.rootId, now);
|
|
6655
|
+
if (root) roots.set(root.id, root);
|
|
6656
|
+
}
|
|
6657
|
+
return roots;
|
|
6479
6658
|
}
|
|
6480
6659
|
self(now = Date.now()) {
|
|
6481
|
-
const
|
|
6660
|
+
const local = this.#localRecords.get(this.options.identity.id);
|
|
6661
|
+
const indexed = local ? void 0 : this.#currentIndex().participantsById.get(this.options.identity.id);
|
|
6662
|
+
const existing = local ?? (indexed ? structuredClone(indexed) : void 0);
|
|
6482
6663
|
if (existing) {
|
|
6483
6664
|
return {
|
|
6484
6665
|
...existing,
|
|
@@ -6552,7 +6733,7 @@ var ParticipantDirectory = class {
|
|
|
6552
6733
|
this.#timer = void 0;
|
|
6553
6734
|
await this.#refreshing?.catch(() => void 0);
|
|
6554
6735
|
if (!this.options.enabled) return;
|
|
6555
|
-
const owned = this.mesh.
|
|
6736
|
+
const owned = this.mesh.scan(PARTICIPANT_PREFIX).filter((entry) => participantFromEntry(entry)?.ownerHostId === this.options.hostId);
|
|
6556
6737
|
await Promise.allSettled(owned.map((entry) => this.mesh.delete({ key: entry.key, ifVersion: entry.version })));
|
|
6557
6738
|
const legacySessionKey = this.#legacySessionKey();
|
|
6558
6739
|
if (legacySessionKey) {
|
|
@@ -6631,19 +6812,14 @@ var ParticipantDirectory = class {
|
|
|
6631
6812
|
identity: this.options.identity
|
|
6632
6813
|
});
|
|
6633
6814
|
}
|
|
6634
|
-
const
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
});
|
|
6638
|
-
const existingById = new Map(existing.map((item) => [item.participant.id, item]));
|
|
6639
|
-
const legacyRoots = new Map(
|
|
6640
|
-
this.mesh.listAll(LEGACY_SESSION_PREFIX).flatMap((entry) => {
|
|
6641
|
-
const root2 = legacyRootFromEntry(entry, this.options.rootId, now);
|
|
6642
|
-
return root2 ? [[root2.id, root2]] : [];
|
|
6643
|
-
})
|
|
6815
|
+
const index = this.#currentIndex();
|
|
6816
|
+
const existing = index.participants.filter(
|
|
6817
|
+
({ participant }) => participant.ownerHostId === this.options.hostId
|
|
6644
6818
|
);
|
|
6819
|
+
const existingById = new Map(existing.map((item) => [item.participant.id, item]));
|
|
6820
|
+
const legacyRoots = this.#legacyRoots(index, now);
|
|
6645
6821
|
const legacyActorOwners = new Map(
|
|
6646
|
-
|
|
6822
|
+
index.legacyActors.flatMap((entry) => {
|
|
6647
6823
|
const actor = legacyActorFromEntry(entry, legacyRoots);
|
|
6648
6824
|
return actor ? [[actor.id, actor.ownerIdentityId]] : [];
|
|
6649
6825
|
})
|
|
@@ -6825,4 +7001,4 @@ export {
|
|
|
6825
7001
|
agentParticipantRecords,
|
|
6826
7002
|
actorParticipantRecord
|
|
6827
7003
|
};
|
|
6828
|
-
//# sourceMappingURL=chunk-
|
|
7004
|
+
//# sourceMappingURL=chunk-53ZZTYHQ.js.map
|