@cortexkit/pi-magic-context 0.49.23 → 0.49.24
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/dist/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +4 -4
- package/dist/{compartment-chunk-embedding-y01m95c2.js → compartment-chunk-embedding-g9a977b8.js} +3 -3
- package/dist/{embedding-backfill-2vh6m3bg.js → embedding-backfill-qxzjy5v2.js} +5 -5
- package/dist/{index-w1twp2kp.js → index-00c5a49f.js} +1 -1
- package/dist/{index-dbgg6hsf.js → index-3jde7hdr.js} +2 -2
- package/dist/{index-579m1751.js → index-8a2wvrda.js} +1 -1
- package/dist/{index-at6py2k3.js → index-8hmqdav2.js} +5 -1
- package/dist/{index-gqjxy2p7.js → index-byh4rfe7.js} +77 -5
- package/dist/{index-st4gwt64.js → index-faz8bw8b.js} +1 -1
- package/dist/{index-2bx7ge3x.js → index-fbrxezw0.js} +32 -32
- package/dist/{index-wgmhk91m.js → index-hf01gtz7.js} +3 -3
- package/dist/{index-pe5gz5c4.js → index-nxq2srg9.js} +1 -1
- package/dist/{index-ftvm2acc.js → index-rk8xef10.js} +4 -4
- package/dist/{index-vx6f7wff.js → index-wb2t932e.js} +1 -1
- package/dist/{index-5j6vwg4z.js → index-ygzh9xdg.js} +32 -22
- package/dist/index.js +515 -146
- package/dist/{message-fts-rowid-map-59y476bk.js → message-fts-rowid-map-1tb3qjtc.js} +2 -2
- package/dist/{message-index-bounded-4ngt600v.js → message-index-bounded-hjat9176.js} +5 -5
- package/dist/{message-index-3snxf11x.js → message-index-esykp965.js} +5 -5
- package/dist/migration-worker.js +3 -3
- package/dist/{project-embedding-registry-hfyzs654.js → project-embedding-registry-9e82qsb6.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-5dmc77q2.js → read-session-chunk-tzvv1kph.js} +2 -2
- package/dist/{read-session-raw-yxv2fv34.js → read-session-raw-napqv76k.js} +3 -1
- package/dist/{search-archive-3daj5ttc.js → search-archive-enx1vd9n.js} +3 -3
- package/dist/{search-jhfh3tsj.js → search-n3yqng95.js} +8 -8
- package/dist/subagent-entry.js +11 -11
- package/dist/tag-snapshot-worker-pi.js +4 -4
- package/package.json +4 -3
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./index-2qtx0q6h.js";
|
|
16
16
|
import {
|
|
17
17
|
createFailClosedBlockingError
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-3jde7hdr.js";
|
|
19
19
|
import {
|
|
20
20
|
createWorkerShutdown
|
|
21
21
|
} from "./index-54wmg4rj.js";
|
|
@@ -407,7 +407,7 @@ function startPiTagSnapshotWorker(request, options = {}) {
|
|
|
407
407
|
reject(new PiTagHydrationError(`worker exited with code ${code} before a clean complete result`));
|
|
408
408
|
});
|
|
409
409
|
});
|
|
410
|
-
function abort(error = new PiTagHydrationError("cancelled")) {
|
|
410
|
+
function abort(error = new PiTagHydrationError("cancelled", "cancelled")) {
|
|
411
411
|
if (settled)
|
|
412
412
|
return;
|
|
413
413
|
settled = true;
|
|
@@ -535,9 +535,9 @@ function createPiTagSnapshotReader(db) {
|
|
|
535
535
|
const managed = new Set;
|
|
536
536
|
const epoch = ++connectionEpoch;
|
|
537
537
|
const sessionEpochs = new Map;
|
|
538
|
+
let closed = false;
|
|
538
539
|
let jobId = 0;
|
|
539
540
|
let current;
|
|
540
|
-
let desiredSession;
|
|
541
541
|
let failedUntil = 0;
|
|
542
542
|
let lastFailure;
|
|
543
543
|
let failedSession;
|
|
@@ -580,24 +580,30 @@ function createPiTagSnapshotReader(db) {
|
|
|
580
580
|
};
|
|
581
581
|
const cancel = (sessionId) => {
|
|
582
582
|
sessionEpochs.set(sessionId, (sessionEpochs.get(sessionId) ?? 0) + 1);
|
|
583
|
-
if (desiredSession === sessionId)
|
|
584
|
-
desiredSession = undefined;
|
|
585
583
|
if (current?.sessionId === sessionId)
|
|
586
584
|
current.cancel();
|
|
587
585
|
};
|
|
588
|
-
const load = (sessionId) => inSnapshotRoot(async () => {
|
|
586
|
+
const load = (sessionId, kind) => inSnapshotRoot(async () => {
|
|
587
|
+
if (closed)
|
|
588
|
+
throw new PiTagHydrationError("connection closed");
|
|
589
589
|
managed.add(sessionId);
|
|
590
590
|
if (ready(sessionId))
|
|
591
591
|
return;
|
|
592
|
-
desiredSession = sessionId;
|
|
593
592
|
if (current) {
|
|
594
|
-
if (current.sessionId === sessionId && !current.
|
|
593
|
+
if (current.sessionId === sessionId && !current.retryable && !current.preempted) {
|
|
594
|
+
if (kind === "turn")
|
|
595
|
+
current.kind = "turn";
|
|
595
596
|
return current.result;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
597
|
+
}
|
|
598
|
+
if (kind === "turn" && current.kind === "prewarm" && current.sessionId !== sessionId && !current.preempted) {
|
|
599
|
+
current.preempted = true;
|
|
600
|
+
current.cancel();
|
|
601
|
+
}
|
|
602
|
+
const epoch = sessionEpochs.get(sessionId) ?? 0;
|
|
603
|
+
await Promise.allSettled([current.result, current.released]);
|
|
604
|
+
if (epoch !== (sessionEpochs.get(sessionId) ?? 0))
|
|
605
|
+
throw new PiTagHydrationError("session hydration cancelled while queued", "cancelled");
|
|
606
|
+
return load(sessionId, kind);
|
|
601
607
|
}
|
|
602
608
|
if (failedSession === sessionId && performance.now() < failedUntil)
|
|
603
609
|
throw lastFailure;
|
|
@@ -620,6 +626,7 @@ function createPiTagSnapshotReader(db) {
|
|
|
620
626
|
}, previous?.tags ?? []);
|
|
621
627
|
const destination = {
|
|
622
628
|
sessionId,
|
|
629
|
+
kind,
|
|
623
630
|
result: Promise.resolve(),
|
|
624
631
|
released: worker.released,
|
|
625
632
|
cancel: worker.cancel
|
|
@@ -639,8 +646,10 @@ function createPiTagSnapshotReader(db) {
|
|
|
639
646
|
};
|
|
640
647
|
jobs.add(lifetime);
|
|
641
648
|
destination.result = worker.result.then(({ candidate, generation }) => {
|
|
649
|
+
if (destination.preempted)
|
|
650
|
+
throw new PiTagHydrationError("prewarm yielded to a turn", "cancelled");
|
|
642
651
|
const live = stamps(sessionId, token.jobId);
|
|
643
|
-
if (
|
|
652
|
+
if (closed || current !== destination || !samePiTagSnapshotToken(token, live) || token.totalRevision !== live.totalRevision || generation.revision !== token.totalRevision || generation.durable !== token.durableVersion)
|
|
644
653
|
throw new PiTagHydrationError("owner generation or lifetime changed", "stale");
|
|
645
654
|
const snapshot = {
|
|
646
655
|
firstAllocationPending: live.revisionPresent ? undefined : candidate.tags.length === 0 && !db.prepare("SELECT 1 FROM tags WHERE session_id = ? LIMIT 1").get(sessionId) ? "empty" : "legacy",
|
|
@@ -669,12 +678,13 @@ function createPiTagSnapshotReader(db) {
|
|
|
669
678
|
}
|
|
670
679
|
cache.set(sessionId, snapshot);
|
|
671
680
|
}).catch((error) => {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
681
|
+
const retryable = error instanceof PiTagHydrationError && (error.code === "stale" || error.code === "cancelled");
|
|
682
|
+
if (retryable)
|
|
683
|
+
destination.retryable = true;
|
|
684
|
+
if (!destination.preempted && current === destination && token.sessionEpoch === (sessionEpochs.get(sessionId) ?? 0)) {
|
|
675
685
|
failedSession = sessionId;
|
|
676
686
|
lastFailure = error;
|
|
677
|
-
failedUntil = performance.now() + (
|
|
687
|
+
failedUntil = performance.now() + (retryable ? 0 : 500);
|
|
678
688
|
}
|
|
679
689
|
throw error;
|
|
680
690
|
});
|
|
@@ -795,7 +805,7 @@ function createPiTagSnapshotReader(db) {
|
|
|
795
805
|
configurable: true,
|
|
796
806
|
writable: true,
|
|
797
807
|
value: (...args) => {
|
|
798
|
-
|
|
808
|
+
closed = true;
|
|
799
809
|
nativeWaiters.clear();
|
|
800
810
|
current?.cancel();
|
|
801
811
|
cache.clear();
|
|
@@ -979,7 +989,7 @@ var activeJobs = new Map;
|
|
|
979
989
|
var waitDeadlines = new WeakMap;
|
|
980
990
|
function prewarmPiTagSnapshot(db, sessionId) {
|
|
981
991
|
createPiTagSnapshotReader(db);
|
|
982
|
-
owners.get(db)?.load(sessionId).catch(() => {});
|
|
992
|
+
owners.get(db)?.load(sessionId, "prewarm").catch(() => {});
|
|
983
993
|
}
|
|
984
994
|
function cancelPiTagSnapshotSession(sessionId) {
|
|
985
995
|
for (const job of activeJobs.get(sessionId) ?? [])
|
|
@@ -1023,7 +1033,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
1023
1033
|
const releaseNativeWaiter = owner.addNativeWaiter(() => budget.remainingOutcome() - PI_CONTEXT_BUDGET.completionReserveMs);
|
|
1024
1034
|
try {
|
|
1025
1035
|
await budget.wait(Promise.race([
|
|
1026
|
-
owner.load(sessionId),
|
|
1036
|
+
owner.load(sessionId, "turn"),
|
|
1027
1037
|
new Promise((_, reject) => {
|
|
1028
1038
|
timer = setTimeout(() => reject(new PiTagHydrationError("remaining pass budget exhausted waiting for tag snapshot; turn not sent, retry", "deadline")), allowance);
|
|
1029
1039
|
})
|
|
@@ -1033,7 +1043,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
1033
1043
|
return;
|
|
1034
1044
|
} catch (error) {
|
|
1035
1045
|
budget.assert();
|
|
1036
|
-
if (!(error instanceof PiTagHydrationError && error.code === "stale"))
|
|
1046
|
+
if (!(error instanceof PiTagHydrationError && (error.code === "stale" || error.code === "cancelled")))
|
|
1037
1047
|
throw error;
|
|
1038
1048
|
} finally {
|
|
1039
1049
|
clearTimeout(timer);
|