@cortexkit/opencode-magic-context 0.49.83 → 0.49.85
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/{announcement-p41dde4h.js → announcement-fnyxaahs.js} +3 -1
- package/dist/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +5 -4
- package/dist/{context-xmyke353.js → context-bjfwzbts.js} +314 -107
- package/dist/{derive-budgets-2z6xxm7e.js → derive-budgets-90869322.js} +3 -1
- package/dist/{embedding-backfill-k994xdas.js → embedding-backfill-v6sw58m8.js} +7 -5
- package/dist/embedding-worker.js +15 -27
- package/dist/features/magic-context/memory/embedding-worker-boundary.test-support.d.ts +24 -0
- package/dist/features/magic-context/memory/embedding-worker-boundary.test-support.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +35 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-loop.d.ts +57 -0
- package/dist/features/magic-context/memory/embedding-worker-loop.d.ts.map +1 -0
- package/dist/features/magic-context/mural/render-trigger.d.ts +3 -3
- package/dist/features/magic-context/mural/render-trigger.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +6 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/{index-zzvd4a9z.js → index-05bm2ndp.js} +1 -1
- package/dist/{index-93rezfvc.js → index-08jfpny9.js} +37 -6
- package/dist/{index-dg5jvh9r.js → index-0rge5rkh.js} +8 -8
- package/dist/{index-2xhzmwf6.js → index-1pf5qrx4.js} +5 -5
- package/dist/{index-e21n48yd.js → index-1y4y98r1.js} +23 -0
- package/dist/{index-98qy103c.js → index-2kf73btc.js} +1 -1
- package/dist/{index-vpw46557.js → index-3dtzyred.js} +1 -1
- package/dist/{index-bd34njzg.js → index-4ntnt8ee.js} +1 -1
- package/dist/{index-w2wpx7t5.js → index-4w5rx7de.js} +1 -1
- package/dist/{index-twmeey4h.js → index-70cv85b0.js} +2 -2
- package/dist/{index-rnyaa7cj.js → index-798s7c8s.js} +2 -2
- package/dist/{index-2q0t43fy.js → index-7j2zv9nm.js} +1 -1
- package/dist/{index-fpqdbb67.js → index-7svecf3m.js} +3 -3
- package/dist/{index-eptthgkw.js → index-9fsxmjs6.js} +5 -5
- package/dist/{v2/server-fvnzcnww.js → index-c5tmzym6.js} +192 -11
- package/dist/{index-w8dcjt7f.js → index-k0tb2z28.js} +1 -1
- package/dist/{index-zb4h9nrk.js → index-k50xhjw1.js} +202 -14
- package/dist/{index-hz1xdb15.js → index-kqnef2tg.js} +4 -4
- package/dist/{index-2ygw6q5s.js → index-nny4gm06.js} +2 -2
- package/dist/{index-fgy6hnr3.js → index-pw279hmt.js} +2 -2
- package/dist/{index-eyk7msgw.js → index-qvn3q9f1.js} +41 -41
- package/dist/{index-shpyv8gq.js → index-s8ks5nz4.js} +16 -9
- package/dist/{index-wxxcfpxh.js → index-sbr58jaf.js} +8 -8
- package/dist/{index-b2787fk6.js → index-tzbcb8yt.js} +36 -20
- package/dist/{index-x8qgqnym.js → index-w6v4dw5f.js} +25 -25
- package/dist/{index-zvane1rq.js → index-xccywqdj.js} +16 -16
- package/dist/{index-y208s7zx.js → index-xrnhxkz7.js} +6 -1
- package/dist/{index-tky3j43e.js → index-zmqx48vt.js} +58 -14
- package/dist/index.js +37 -37
- package/dist/{message-index-bounded-cfkeyf72.js → message-index-bounded-6fr624zf.js} +3 -3
- package/dist/migration-worker.js +4 -3
- package/dist/{project-embedding-registry-y3z36mjy.js → project-embedding-registry-q80scexh.js} +6 -4
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-s3qac56g.js → read-session-chunk-6wedfths.js} +2 -2
- package/dist/{recomp-orchestrator-fjdp3t1d.js → recomp-orchestrator-xzs0a455.js} +19 -18
- package/dist/{render-c9fjwrad.js → render-yqp7q79f.js} +12 -11
- package/dist/{search-archive-s2jas2jb.js → search-archive-r4h96j2z.js} +4 -4
- package/dist/{search-1jejx5cx.js → search-ztgy3ya6.js} +15 -13
- package/dist/shared/models-dev-cache.d.ts +6 -1
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/shared/storage-permissions.d.ts +5 -3
- package/dist/shared/storage-permissions.d.ts.map +1 -1
- package/dist/shared/test-git-env.d.ts +3 -0
- package/dist/shared/test-git-env.d.ts.map +1 -0
- package/dist/{storage-tags-6e83pvff.js → storage-tags-y2mrb8e6.js} +1 -1
- package/dist/{store-ggrq9e14.js → store-n4yz3n66.js} +2 -2
- package/dist/{store-reader-tr64nxyy.js → store-reader-nf8z86n9.js} +1 -1
- package/dist/{transform-postprocess-phase-p2egg02g.js → transform-postprocess-phase-39a5hm2a.js} +20 -19
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +6 -5
- package/dist/v2/{context-zn18k0yk.js → context-k2rrqzf4.js} +446 -248
- package/dist/v2/{derive-budgets-2eam671q.js → derive-budgets-ecjy1aqh.js} +4 -2
- package/dist/v2/{embedding-backfill-hjvjxp7d.js → embedding-backfill-k8kqnwfq.js} +7 -5
- package/dist/v2/embedding-worker.js +15 -27
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts +12 -0
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -0
- package/dist/v2/hooks/storage-notice.d.ts +12 -6
- package/dist/v2/hooks/storage-notice.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-0xy4dn04.js → message-index-bounded-jqy7283g.js} +4 -4
- package/dist/v2/migration-worker.js +5 -4
- package/dist/v2/{project-embedding-registry-mzsvyads.js → project-embedding-registry-2jp1antr.js} +6 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-6mt2t6dy.js → read-session-chunk-n3nhfvd7.js} +3 -3
- package/dist/v2/{recomp-orchestrator-jn39mxh0.js → recomp-orchestrator-jnbxbsc8.js} +21 -20
- package/dist/v2/{render-q2aj9bgy.js → render-fezgh7pa.js} +13 -12
- package/dist/v2/{search-archive-fj59gjv1.js → search-archive-zz1kza50.js} +5 -5
- package/dist/v2/{search-9xn6ds9x.js → search-h5w7510x.js} +15 -13
- package/dist/v2/{server-2gcfmd47.js → server-2k8tkbhz.js} +2 -2
- package/dist/v2/{server-4z964n1c.js → server-3p6b0qya.js} +1 -1
- package/dist/v2/{server-c8mqs0v5.js → server-4wwwm2ya.js} +32 -32
- package/dist/v2/{server-1cn3kryt.js → server-97w51d8n.js} +5 -5
- package/dist/v2/{server-gx1s06dx.js → server-98hsp35q.js} +2 -2
- package/dist/v2/{server-xepx8t43.js → server-a2f1bhyj.js} +1 -1
- package/dist/v2/{server-r00xyx66.js → server-ap81bk3c.js} +28 -28
- package/dist/v2/{server-d706s5xn.js → server-b93f0bqh.js} +205 -17
- package/dist/v2/{server-2w1rdttn.js → server-brgandk4.js} +2 -2
- package/dist/v2/{server-rp52f40v.js → server-cwtehwbb.js} +1 -1
- package/dist/v2/{server-bj779zmp.js → server-e2k9mt86.js} +1 -1
- package/dist/v2/{server-68q80y27.js → server-hn8b7sfe.js} +16 -9
- package/dist/v2/{server-pejjj0nv.js → server-mbkwcwgw.js} +1 -1
- package/dist/v2/{server-g1a0nhtk.js → server-n5zr7190.js} +18 -18
- package/dist/v2/{server-2ktxmtbd.js → server-ps6rz88g.js} +2 -2
- package/dist/v2/{server-5yfq912a.js → server-qyazxy92.js} +23 -0
- package/dist/{index-fvnzcnww.js → v2/server-r2es6zt7.js} +192 -11
- package/dist/v2/{server-bt546axy.js → server-rz4snd3x.js} +3 -3
- package/dist/v2/{server-xdh4r20h.js → server-s15knz0w.js} +642 -627
- package/dist/v2/{server-vt6nj2hn.js → server-s76ty4ws.js} +41 -25
- package/dist/v2/{server-0dmzr7f9.js → server-sxfbjdye.js} +2 -2
- package/dist/v2/{server-569he5mh.js → server-w7mpvkpj.js} +1 -1
- package/dist/v2/{server-53n8hv5q.js → server-x77hd658.js} +8 -8
- package/dist/v2/{server-nqdzv8b7.js → server-xa8fefhw.js} +58 -14
- package/dist/v2/{server-1efjj215.js → server-ytqps2xa.js} +37 -6
- package/dist/v2/server.js +6 -4
- package/dist/v2/{storage-tags-z8j8wq34.js → storage-tags-xq81zgt2.js} +2 -2
- package/dist/v2/{store-reader-83tka051.js → store-reader-2vhx33n6.js} +1 -1
- package/dist/v2/store-reader.d.ts +11 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{store-qdgzd38f.js → store-y56y034s.js} +2 -2
- package/dist/v2/{v2-archive-reader-9z8z97db.js → v2-archive-reader-e2w39c3p.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-vd5zfp3v.js → wrapup-orchestrator-mmje3etf.js} +20 -19
- package/dist/{v2-archive-reader-r0xpxsb1.js → v2-archive-reader-8dsngf2j.js} +1 -1
- package/dist/{wrapup-orchestrator-k29zqfp9.js → wrapup-orchestrator-sm6pwf3p.js} +20 -19
- package/package.json +1 -1
- package/src/shared/models-dev-cache.ts +90 -21
- package/src/shared/reusable-worker.test.ts +31 -29
- package/src/shared/sqlite.test.ts +19 -6
- package/src/shared/storage-file-mutex-review.test.ts +125 -2
- package/src/shared/storage-file-mutex.ts +17 -8
- package/src/shared/storage-permissions-creators.test.ts +194 -0
- package/src/shared/storage-permissions-startup.test.ts +476 -0
- package/src/shared/storage-permissions.ts +227 -12
- package/src/shared/test-db.test.ts +5 -3
- package/src/shared/test-git-env.test.ts +38 -0
- package/src/shared/test-git-env.ts +10 -0
|
@@ -10,21 +10,22 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
getMagicContextStorageDir,
|
|
12
12
|
importPluginModule,
|
|
13
|
-
log2
|
|
13
|
+
log2,
|
|
14
|
+
flushLogger2
|
|
14
15
|
} from "./index-ywrz4wy2.js";
|
|
15
16
|
import {
|
|
16
17
|
inRootAsyncContext2
|
|
17
18
|
} from "./index-gzy5w8ya.js";
|
|
18
|
-
import {
|
|
19
|
-
computeNormalizedHash
|
|
20
|
-
} from "./index-2bvekkfy.js";
|
|
21
19
|
import {
|
|
22
20
|
shouldEnforcePrivateStoragePermissions,
|
|
23
21
|
ensureStorageDirectorySync,
|
|
24
22
|
writeStorageFileAsync,
|
|
25
23
|
writeStorageFileHandleAsync,
|
|
26
24
|
createStorageFileHandleAsync
|
|
27
|
-
} from "./index-
|
|
25
|
+
} from "./index-c5tmzym6.js";
|
|
26
|
+
import {
|
|
27
|
+
computeNormalizedHash
|
|
28
|
+
} from "./index-2bvekkfy.js";
|
|
28
29
|
|
|
29
30
|
// src/features/magic-context/memory/embedding-model-match.ts
|
|
30
31
|
function parseEmbeddingModel(model) {
|
|
@@ -675,6 +676,80 @@ function dominantEmbeddingFailure(failures) {
|
|
|
675
676
|
import { fork } from "node:child_process";
|
|
676
677
|
import { Worker } from "node:worker_threads";
|
|
677
678
|
|
|
679
|
+
// src/features/magic-context/memory/embedding-worker-loop.ts
|
|
680
|
+
var EMBEDDING_WORKER_STOPPING_ERROR = "embedding worker stopping";
|
|
681
|
+
function isEmbeddingWorkerStopNotice(message) {
|
|
682
|
+
return typeof message === "object" && message !== null && "control" in message && (message.control === "stopping" || message.control === "stopped");
|
|
683
|
+
}
|
|
684
|
+
function serveEmbeddingWorker(port, model, options) {
|
|
685
|
+
const now = options.now ?? (() => performance.now());
|
|
686
|
+
let queue = Promise.resolve();
|
|
687
|
+
let stopping = false;
|
|
688
|
+
let busySince = null;
|
|
689
|
+
const refuse = (id) => port.postMessage({ id, loaded: false, error: EMBEDDING_WORKER_STOPPING_ERROR });
|
|
690
|
+
const handle = async (request) => {
|
|
691
|
+
if (stopping)
|
|
692
|
+
return refuse(request.id);
|
|
693
|
+
busySince = now();
|
|
694
|
+
try {
|
|
695
|
+
const loaded = await model.initialize();
|
|
696
|
+
let vectors;
|
|
697
|
+
if (loaded && request.texts) {
|
|
698
|
+
vectors = [];
|
|
699
|
+
for (let offset = 0;offset < request.texts.length; offset += options.batchSize) {
|
|
700
|
+
if (offset > 0)
|
|
701
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
702
|
+
if (stopping)
|
|
703
|
+
throw new Error(EMBEDDING_WORKER_STOPPING_ERROR);
|
|
704
|
+
vectors.push(...await model.embedBatch(request.texts.slice(offset, offset + options.batchSize)));
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
port.postMessage({
|
|
708
|
+
id: request.id,
|
|
709
|
+
loaded,
|
|
710
|
+
vectors,
|
|
711
|
+
failure: model.getLastFailureReason(),
|
|
712
|
+
stats: options.stats?.()
|
|
713
|
+
}, vectors?.flatMap((vector) => vector ? [vector.buffer] : []) ?? []);
|
|
714
|
+
} catch (error) {
|
|
715
|
+
port.postMessage({ id: request.id, loaded: false, error: String(error) });
|
|
716
|
+
} finally {
|
|
717
|
+
busySince = null;
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
const stop = async () => {
|
|
721
|
+
stopping = true;
|
|
722
|
+
const requestedAt = now();
|
|
723
|
+
const busy = busySince !== null;
|
|
724
|
+
port.postMessage({
|
|
725
|
+
control: "stopping",
|
|
726
|
+
busy,
|
|
727
|
+
busyMs: busySince === null ? 0 : requestedAt - busySince
|
|
728
|
+
});
|
|
729
|
+
await queue;
|
|
730
|
+
try {
|
|
731
|
+
await model.dispose();
|
|
732
|
+
} catch {}
|
|
733
|
+
port.postMessage({
|
|
734
|
+
control: "stopped",
|
|
735
|
+
busy,
|
|
736
|
+
waitedMs: now() - requestedAt
|
|
737
|
+
});
|
|
738
|
+
options.exit();
|
|
739
|
+
};
|
|
740
|
+
port.on("message", (message) => {
|
|
741
|
+
if (message?.stop === true) {
|
|
742
|
+
if (!stopping)
|
|
743
|
+
stop();
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
const request = message;
|
|
747
|
+
if (stopping)
|
|
748
|
+
return refuse(request.id);
|
|
749
|
+
queue = queue.then(() => handle(request));
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
|
|
678
753
|
// src/features/magic-context/memory/onnx-telemetry.ts
|
|
679
754
|
import { isMainThread } from "node:worker_threads";
|
|
680
755
|
var FFI_SPECIFIER = "bun:ffi";
|
|
@@ -721,6 +796,41 @@ async function prepareNativeOnnxTelemetry() {
|
|
|
721
796
|
|
|
722
797
|
// src/features/magic-context/memory/embedding-worker-client.ts
|
|
723
798
|
var warnedWindowsTelemetry = false;
|
|
799
|
+
var EMBEDDING_WORKER_STOP_GRACE_MS = 5000;
|
|
800
|
+
var EMBEDDING_WORKER_FORCED_EXIT_WAIT_MS = 2000;
|
|
801
|
+
var EMBEDDING_WORKER_SIGKILL_WAIT_MS = 200;
|
|
802
|
+
var EMBEDDING_WORKER_STOP_MAX_MS = EMBEDDING_WORKER_STOP_GRACE_MS + EMBEDDING_WORKER_FORCED_EXIT_WAIT_MS + EMBEDDING_WORKER_SIGKILL_WAIT_MS;
|
|
803
|
+
function busySince(state) {
|
|
804
|
+
let oldest = null;
|
|
805
|
+
for (const sentAt of state.dispatched.values()) {
|
|
806
|
+
if (oldest === null || sentAt < oldest)
|
|
807
|
+
oldest = sentAt;
|
|
808
|
+
}
|
|
809
|
+
return oldest;
|
|
810
|
+
}
|
|
811
|
+
async function exitsWithin(exit, ms) {
|
|
812
|
+
let timer;
|
|
813
|
+
try {
|
|
814
|
+
return await Promise.race([
|
|
815
|
+
exit.then(() => true),
|
|
816
|
+
new Promise((resolve) => {
|
|
817
|
+
timer = setTimeout(() => resolve(false), ms);
|
|
818
|
+
})
|
|
819
|
+
]);
|
|
820
|
+
} finally {
|
|
821
|
+
clearTimeout(timer);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
function describeRunning(since, at) {
|
|
825
|
+
return since === null ? "no" : `yes (for ${Math.max(0, Math.round(at - since))}ms)`;
|
|
826
|
+
}
|
|
827
|
+
function describeStuckWorker(state, stopSince) {
|
|
828
|
+
const notice = state.stopNotice;
|
|
829
|
+
const at = performance.now();
|
|
830
|
+
if (notice)
|
|
831
|
+
return describeRunning(notice.busy ? notice.receivedAt - notice.busyMs : null, at);
|
|
832
|
+
return `${describeRunning(stopSince, at)}, no answer to the stop request`;
|
|
833
|
+
}
|
|
724
834
|
|
|
725
835
|
class EmbeddingWorkerClient {
|
|
726
836
|
data;
|
|
@@ -728,19 +838,23 @@ class EmbeddingWorkerClient {
|
|
|
728
838
|
timeoutMs;
|
|
729
839
|
prepareTelemetry;
|
|
730
840
|
idleMs;
|
|
841
|
+
options;
|
|
731
842
|
worker = null;
|
|
732
843
|
startPromise = null;
|
|
844
|
+
states = new WeakMap;
|
|
845
|
+
stopping = new Set;
|
|
733
846
|
nextId = 1;
|
|
734
847
|
pending = new Map;
|
|
735
848
|
disposed = false;
|
|
736
849
|
activeRequests = 0;
|
|
737
850
|
idleTimer = null;
|
|
738
|
-
constructor(data, entry = new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./embedding-worker.ts" : "./embedding-worker.js", import.meta.url), timeoutMs = 5 * 60000, prepareTelemetry = prepareNativeOnnxTelemetry, idleMs = 10 * 60000) {
|
|
851
|
+
constructor(data, entry = new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./embedding-worker.ts" : "./embedding-worker.js", import.meta.url), timeoutMs = 5 * 60000, prepareTelemetry = prepareNativeOnnxTelemetry, idleMs = 10 * 60000, options = {}) {
|
|
739
852
|
this.data = data;
|
|
740
853
|
this.entry = entry;
|
|
741
854
|
this.timeoutMs = timeoutMs;
|
|
742
855
|
this.prepareTelemetry = prepareTelemetry;
|
|
743
856
|
this.idleMs = idleMs;
|
|
857
|
+
this.options = options;
|
|
744
858
|
}
|
|
745
859
|
start() {
|
|
746
860
|
if (this.startPromise)
|
|
@@ -778,14 +892,38 @@ class EmbeddingWorkerClient {
|
|
|
778
892
|
}
|
|
779
893
|
}
|
|
780
894
|
this.worker = worker;
|
|
895
|
+
let markExited;
|
|
896
|
+
const state = {
|
|
897
|
+
dispatched: new Map,
|
|
898
|
+
stopNotice: null,
|
|
899
|
+
exited: false,
|
|
900
|
+
exit: new Promise((resolve) => {
|
|
901
|
+
markExited = resolve;
|
|
902
|
+
})
|
|
903
|
+
};
|
|
904
|
+
this.states.set(worker, state);
|
|
905
|
+
worker.once("exit", () => {
|
|
906
|
+
state.exited = true;
|
|
907
|
+
markExited();
|
|
908
|
+
});
|
|
781
909
|
worker.unref();
|
|
782
910
|
if (!(worker instanceof Worker))
|
|
783
911
|
worker.channel?.unref?.();
|
|
784
912
|
worker.on("message", (wire) => {
|
|
913
|
+
if (isEmbeddingWorkerStopNotice(wire)) {
|
|
914
|
+
if (wire.control === "stopping")
|
|
915
|
+
state.stopNotice = {
|
|
916
|
+
busy: wire.busy,
|
|
917
|
+
busyMs: wire.busyMs,
|
|
918
|
+
receivedAt: performance.now()
|
|
919
|
+
};
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
785
922
|
const reply = worker instanceof Worker ? wire : {
|
|
786
923
|
...wire,
|
|
787
924
|
vectors: wire.vectors?.map((vector) => vector === null ? null : new Float32Array(Uint8Array.from(Buffer.from(vector, "base64")).buffer))
|
|
788
925
|
};
|
|
926
|
+
state.dispatched.delete(reply.id);
|
|
789
927
|
if (this.worker !== worker)
|
|
790
928
|
return;
|
|
791
929
|
const request = this.pending.get(reply.id);
|
|
@@ -893,6 +1031,7 @@ class EmbeddingWorkerClient {
|
|
|
893
1031
|
worker.ref();
|
|
894
1032
|
if (!(worker instanceof Worker))
|
|
895
1033
|
worker.channel?.ref?.();
|
|
1034
|
+
this.states.get(worker)?.dispatched.set(id, performance.now());
|
|
896
1035
|
try {
|
|
897
1036
|
if (worker instanceof Worker)
|
|
898
1037
|
worker.postMessage({ id, texts });
|
|
@@ -915,21 +1054,70 @@ class EmbeddingWorkerClient {
|
|
|
915
1054
|
request.reject(error);
|
|
916
1055
|
}
|
|
917
1056
|
this.pending.clear();
|
|
918
|
-
if (worker
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1057
|
+
if (!worker)
|
|
1058
|
+
return;
|
|
1059
|
+
const stopped = this.stopWorker(worker, error.message);
|
|
1060
|
+
this.stopping.add(stopped);
|
|
1061
|
+
try {
|
|
1062
|
+
await stopped;
|
|
1063
|
+
} finally {
|
|
1064
|
+
this.stopping.delete(stopped);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
async stopWorker(worker, reason) {
|
|
1068
|
+
const state = this.states.get(worker);
|
|
1069
|
+
if (!state || state.exited)
|
|
1070
|
+
return;
|
|
1071
|
+
const writeLog = this.options.log ?? log2;
|
|
1072
|
+
const graceMs = this.options.stopGraceMs ?? EMBEDDING_WORKER_STOP_GRACE_MS;
|
|
1073
|
+
const forcedExitWaitMs = this.options.forcedExitWaitMs ?? EMBEDDING_WORKER_FORCED_EXIT_WAIT_MS;
|
|
1074
|
+
const owner = worker instanceof Worker ? `pid ${process.pid}` : `pid ${process.pid}, worker pid ${worker.pid ?? "unknown"}`;
|
|
1075
|
+
const startedAt = performance.now();
|
|
1076
|
+
const stopSince = busySince(state);
|
|
1077
|
+
worker.ref();
|
|
1078
|
+
if (!(worker instanceof Worker))
|
|
922
1079
|
worker.channel?.ref?.();
|
|
923
|
-
|
|
924
|
-
|
|
1080
|
+
const request = { stop: true };
|
|
1081
|
+
try {
|
|
1082
|
+
if (worker instanceof Worker)
|
|
1083
|
+
worker.postMessage(request);
|
|
1084
|
+
else if (worker.connected)
|
|
1085
|
+
worker.send(request, () => {});
|
|
1086
|
+
} catch {}
|
|
1087
|
+
if (await exitsWithin(state.exit, graceMs)) {
|
|
1088
|
+
writeLog(`[magic-context] embedding worker stopped (${reason}; ${owner}; inference running: ${describeRunning(stopSince, startedAt)}; stop took ${Math.round(performance.now() - startedAt)}ms)`);
|
|
1089
|
+
flushLogger2();
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
writeLog(`[magic-context] embedding worker did not stop within ${graceMs}ms; terminating it (${reason}; ${owner}; inference running: ${describeStuckWorker(state, stopSince)})`);
|
|
1093
|
+
flushLogger2();
|
|
1094
|
+
try {
|
|
1095
|
+
if (worker instanceof Worker)
|
|
1096
|
+
worker.terminate().catch(() => {});
|
|
1097
|
+
else
|
|
925
1098
|
worker.kill();
|
|
926
|
-
|
|
1099
|
+
} catch {}
|
|
1100
|
+
if (await exitsWithin(state.exit, forcedExitWaitMs))
|
|
1101
|
+
return;
|
|
1102
|
+
let killed = false;
|
|
1103
|
+
if (!(worker instanceof Worker) && process.platform !== "win32") {
|
|
1104
|
+
try {
|
|
1105
|
+
killed = worker.kill("SIGKILL");
|
|
1106
|
+
} catch {}
|
|
1107
|
+
if (await exitsWithin(state.exit, EMBEDDING_WORKER_SIGKILL_WAIT_MS))
|
|
1108
|
+
return;
|
|
927
1109
|
}
|
|
1110
|
+
writeLog(`[magic-context] embedding worker has not exited ${forcedExitWaitMs}ms after it was terminated${killed ? " and sent SIGKILL" : ""}; no longer waiting for it (${reason}; ${owner})`);
|
|
1111
|
+
flushLogger2();
|
|
1112
|
+
worker.unref();
|
|
1113
|
+
if (!(worker instanceof Worker))
|
|
1114
|
+
worker.channel?.unref?.();
|
|
928
1115
|
}
|
|
929
1116
|
async dispose() {
|
|
930
1117
|
this.disposed = true;
|
|
931
1118
|
await this.startPromise?.catch(() => {});
|
|
932
1119
|
await this.stop(new Error("embedding worker disposed"));
|
|
1120
|
+
await Promise.all([...this.stopping]);
|
|
933
1121
|
}
|
|
934
1122
|
}
|
|
935
1123
|
|
|
@@ -1651,4 +1839,4 @@ class LocalEmbeddingProvider {
|
|
|
1651
1839
|
}
|
|
1652
1840
|
}
|
|
1653
1841
|
|
|
1654
|
-
export { embeddingModelsMatch, resolveEmbeddingTextPrefixes, getCachedLocalEmbeddingPooling, logLocalEmbeddingPoolingDecisionOnce, preflightLocalEmbeddingPooling, logLocalEmbeddingPoolingUnavailableOnce, getEmbeddingProviderIdentity, dominantEmbeddingFailure, resolveLocalEmbeddingWorkerRuntime, getLocalEmbeddingNativeMemoryStats, LocalEmbeddingProvider };
|
|
1842
|
+
export { embeddingModelsMatch, resolveEmbeddingTextPrefixes, getCachedLocalEmbeddingPooling, logLocalEmbeddingPoolingDecisionOnce, preflightLocalEmbeddingPooling, logLocalEmbeddingPoolingUnavailableOnce, getEmbeddingProviderIdentity, dominantEmbeddingFailure, serveEmbeddingWorker, resolveLocalEmbeddingWorkerRuntime, getLocalEmbeddingNativeMemoryStats, LocalEmbeddingProvider };
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
} from "./index-ywrz4wy2.js";
|
|
4
4
|
import {
|
|
5
5
|
clearEmergencyRecovery
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-xrnhxkz7.js";
|
|
7
7
|
import {
|
|
8
8
|
requestPendingMaterialization,
|
|
9
9
|
dropSlot
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-w6v4dw5f.js";
|
|
11
11
|
import {
|
|
12
12
|
executeContextRecomp
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-tzbcb8yt.js";
|
|
14
14
|
import {
|
|
15
15
|
renderUserFacingFailure,
|
|
16
16
|
userFacingFailureCode
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-pw279hmt.js";
|
|
18
18
|
|
|
19
19
|
// src/hooks/magic-context/recomp-orchestrator.ts
|
|
20
20
|
function resolveLiveModelKey(liveSessionState, sessionId) {
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
rawMessageWorkerSource2,
|
|
20
20
|
rawMessageOffThreadRangeReader2,
|
|
21
21
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-7j2zv9nm.js";
|
|
23
23
|
import {
|
|
24
24
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-1pf5qrx4.js";
|
|
26
26
|
|
|
27
27
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
28
|
var archiveReadsOnThisThread = 0;
|
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
} from "./index-pxnzyvjc.js";
|
|
18
18
|
import {
|
|
19
19
|
LocalEmbeddingProvider
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-k50xhjw1.js";
|
|
21
21
|
import {
|
|
22
22
|
OpenAICompatibleEmbeddingProvider,
|
|
23
23
|
embedTextForProject2
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-s8ks5nz4.js";
|
|
25
25
|
import {
|
|
26
26
|
saveEmbeddingIfHashMatches
|
|
27
27
|
} from "./index-4dhv7mqz.js";
|
|
@@ -57,6 +57,20 @@ import {
|
|
|
57
57
|
SqliteAcquisitionBusyError2,
|
|
58
58
|
withAsyncPrivilegedWriter2
|
|
59
59
|
} from "./index-gzy5w8ya.js";
|
|
60
|
+
import {
|
|
61
|
+
registerOwnRpcServerInstance,
|
|
62
|
+
rpcPortDir,
|
|
63
|
+
rpcPortFilePath,
|
|
64
|
+
parseRpcPortFile,
|
|
65
|
+
inspectProcessesAsync
|
|
66
|
+
} from "./index-gqf8r04r.js";
|
|
67
|
+
import {
|
|
68
|
+
shouldEnforcePrivateStoragePermissions,
|
|
69
|
+
ensureStorageDirectorySync,
|
|
70
|
+
writeStorageFileAtomicSync,
|
|
71
|
+
writeStorageFileAsync,
|
|
72
|
+
createStorageWriteStream
|
|
73
|
+
} from "./index-c5tmzym6.js";
|
|
60
74
|
import {
|
|
61
75
|
pruneMissingProjectIdentities,
|
|
62
76
|
shouldSkipHomeProjectMemory,
|
|
@@ -73,7 +87,7 @@ import {
|
|
|
73
87
|
storedPathBelongsToIdentity,
|
|
74
88
|
beginBootQuietPeriod,
|
|
75
89
|
scheduleAfterBootQuiet
|
|
76
|
-
} from "./index-
|
|
90
|
+
} from "./index-7svecf3m.js";
|
|
77
91
|
import {
|
|
78
92
|
recordSessionProjectIdentity,
|
|
79
93
|
hasRecordedSessionProjectIdentity,
|
|
@@ -83,7 +97,7 @@ import {
|
|
|
83
97
|
markGitSweepSuccessAndRelease,
|
|
84
98
|
parkGitSweepNonIndexable,
|
|
85
99
|
releaseGitSweepLease
|
|
86
|
-
} from "./index-
|
|
100
|
+
} from "./index-3dtzyred.js";
|
|
87
101
|
import {
|
|
88
102
|
getMagicContextBuiltinCommands,
|
|
89
103
|
formatConfigParseStatusLine,
|
|
@@ -198,7 +212,7 @@ import {
|
|
|
198
212
|
snapRangeToCompartments,
|
|
199
213
|
getActiveCompartmentRun,
|
|
200
214
|
startCompartmentAgent
|
|
201
|
-
} from "./index-
|
|
215
|
+
} from "./index-tzbcb8yt.js";
|
|
202
216
|
import {
|
|
203
217
|
hasTrustedAbsoluteWall,
|
|
204
218
|
applyProvenInputFloor,
|
|
@@ -210,7 +224,7 @@ import {
|
|
|
210
224
|
deriveTriggerBudget2,
|
|
211
225
|
resolveKnownHistorianContextLimit2,
|
|
212
226
|
resolveHistorianProducerLimits2
|
|
213
|
-
} from "./index-
|
|
227
|
+
} from "./index-zmqx48vt.js";
|
|
214
228
|
import {
|
|
215
229
|
resolveModelCalibration,
|
|
216
230
|
calibrateBuckets,
|
|
@@ -357,7 +371,7 @@ import {
|
|
|
357
371
|
getTagsByNumbers2,
|
|
358
372
|
getDroppedTagsByNumbers2,
|
|
359
373
|
getMaxDroppedTagNumber2
|
|
360
|
-
} from "./index-
|
|
374
|
+
} from "./index-xrnhxkz7.js";
|
|
361
375
|
import {
|
|
362
376
|
BoundedSessionMap,
|
|
363
377
|
observeTemporalDecisions,
|
|
@@ -429,19 +443,12 @@ import {
|
|
|
429
443
|
readRawSessionMessageById2,
|
|
430
444
|
readSessionChunk2,
|
|
431
445
|
readRawSessionSeedTail2
|
|
432
|
-
} from "./index-
|
|
446
|
+
} from "./index-7j2zv9nm.js";
|
|
433
447
|
import {
|
|
434
448
|
isFailClosedBlockingError,
|
|
435
449
|
shouldBypassFailClosedBlock,
|
|
436
450
|
resolveAgentNameFromMessages
|
|
437
451
|
} from "./index-wh9fxds5.js";
|
|
438
|
-
import {
|
|
439
|
-
registerOwnRpcServerInstance,
|
|
440
|
-
rpcPortDir,
|
|
441
|
-
rpcPortFilePath,
|
|
442
|
-
parseRpcPortFile,
|
|
443
|
-
inspectProcessesAsync
|
|
444
|
-
} from "./index-gqf8r04r.js";
|
|
445
452
|
import {
|
|
446
453
|
configureContextDatabasePragmas2
|
|
447
454
|
} from "./index-fb3zxn06.js";
|
|
@@ -455,7 +462,7 @@ import {
|
|
|
455
462
|
runSqliteOptimize,
|
|
456
463
|
openDatabase,
|
|
457
464
|
openCurrentDatabase
|
|
458
|
-
} from "./index-
|
|
465
|
+
} from "./index-xccywqdj.js";
|
|
459
466
|
import {
|
|
460
467
|
unescapeXml,
|
|
461
468
|
resolveWorkspaceShareCategories,
|
|
@@ -464,7 +471,7 @@ import {
|
|
|
464
471
|
resolveStoredPathWorkspaceIdentity,
|
|
465
472
|
storedPathBelongsToWorkspace,
|
|
466
473
|
computeWorkspaceEpochFingerprint
|
|
467
|
-
} from "./index-
|
|
474
|
+
} from "./index-4w5rx7de.js";
|
|
468
475
|
import {
|
|
469
476
|
V2_MEMORY_CATEGORIES,
|
|
470
477
|
CATEGORY_PRIORITY
|
|
@@ -571,10 +578,10 @@ import {
|
|
|
571
578
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
572
579
|
getProjectState,
|
|
573
580
|
bumpProjectUserProfileVersion
|
|
574
|
-
} from "./index-
|
|
581
|
+
} from "./index-w6v4dw5f.js";
|
|
575
582
|
import {
|
|
576
583
|
getLastIndexedOrdinal
|
|
577
|
-
} from "./index-
|
|
584
|
+
} from "./index-05bm2ndp.js";
|
|
578
585
|
import {
|
|
579
586
|
SESSION_NOTE_CONDITION_ERROR,
|
|
580
587
|
getNoteByIdInScope,
|
|
@@ -600,7 +607,7 @@ import {
|
|
|
600
607
|
createPrimer,
|
|
601
608
|
updatePrimerSupport,
|
|
602
609
|
updatePrimerAnswer
|
|
603
|
-
} from "./index-
|
|
610
|
+
} from "./index-4ntnt8ee.js";
|
|
604
611
|
import {
|
|
605
612
|
registerNotificationSink2,
|
|
606
613
|
pushNotification2,
|
|
@@ -612,7 +619,7 @@ import {
|
|
|
612
619
|
getCachedLocalEmbeddingPooling,
|
|
613
620
|
preflightLocalEmbeddingPooling,
|
|
614
621
|
getLocalEmbeddingNativeMemoryStats
|
|
615
|
-
} from "./index-
|
|
622
|
+
} from "./index-k50xhjw1.js";
|
|
616
623
|
import {
|
|
617
624
|
withQueryEmbeddingDeadline,
|
|
618
625
|
describeShadowBackfillWriteRefusal2,
|
|
@@ -633,7 +640,7 @@ import {
|
|
|
633
640
|
embedSessionCompartmentChunks2,
|
|
634
641
|
getEmbeddingCoverageStatus2,
|
|
635
642
|
getAutoEmbeddingSessionCoverage2
|
|
636
|
-
} from "./index-
|
|
643
|
+
} from "./index-s8ks5nz4.js";
|
|
637
644
|
import {
|
|
638
645
|
saveEmbeddingIfHashMatches,
|
|
639
646
|
invalidateProject2,
|
|
@@ -659,7 +666,7 @@ import {
|
|
|
659
666
|
readGitFileChangeTimesSince,
|
|
660
667
|
verificationFileExists,
|
|
661
668
|
normalizeVerificationFiles
|
|
662
|
-
} from "./index-
|
|
669
|
+
} from "./index-pw279hmt.js";
|
|
663
670
|
import {
|
|
664
671
|
computeCueContentHash,
|
|
665
672
|
hasMuralCueColumns,
|
|
@@ -707,13 +714,13 @@ import {
|
|
|
707
714
|
resolveMemoriesByIdsForSearch2,
|
|
708
715
|
unifiedSearch2,
|
|
709
716
|
formatSearchResults2
|
|
710
|
-
} from "./index-
|
|
717
|
+
} from "./index-0rge5rkh.js";
|
|
711
718
|
import {
|
|
712
719
|
scheduleReconciliation,
|
|
713
720
|
scheduleIncrementalIndex,
|
|
714
721
|
getMessageIndexQueueHeapStats,
|
|
715
722
|
clearSessionTracking
|
|
716
|
-
} from "./index-
|
|
723
|
+
} from "./index-798s7c8s.js";
|
|
717
724
|
import {
|
|
718
725
|
flushIgnoredMessages2,
|
|
719
726
|
clearIgnoredMessages2,
|
|
@@ -723,7 +730,7 @@ import {
|
|
|
723
730
|
import {
|
|
724
731
|
setRecompStarting2,
|
|
725
732
|
setRecompTerminal2
|
|
726
|
-
} from "./index-
|
|
733
|
+
} from "./index-kqnef2tg.js";
|
|
727
734
|
import {
|
|
728
735
|
makeToolCompositeKey,
|
|
729
736
|
searchMessageHistoryOffThread,
|
|
@@ -808,14 +815,14 @@ import {
|
|
|
808
815
|
abortSessionFailClosed2,
|
|
809
816
|
evaluateEmergencyFailClosed2,
|
|
810
817
|
runPostTransformPhase2
|
|
811
|
-
} from "./index-
|
|
818
|
+
} from "./index-sbr58jaf.js";
|
|
812
819
|
import {
|
|
813
820
|
ANNOUNCEMENT_VERSION2,
|
|
814
821
|
ANNOUNCEMENT_FEATURES2,
|
|
815
822
|
ANNOUNCEMENT_FOOTER2,
|
|
816
823
|
markAnnouncementSeen2,
|
|
817
824
|
shouldShowAnnouncement2
|
|
818
|
-
} from "./index-
|
|
825
|
+
} from "./index-2kf73btc.js";
|
|
819
826
|
import {
|
|
820
827
|
resolvePromptContext2
|
|
821
828
|
} from "./index-fmsr7v69.js";
|
|
@@ -823,13 +830,13 @@ import {
|
|
|
823
830
|
renderMessageByOrdinal2,
|
|
824
831
|
renderVerboseRangeForTool2,
|
|
825
832
|
renderItemByTag2
|
|
826
|
-
} from "./index-
|
|
833
|
+
} from "./index-70cv85b0.js";
|
|
827
834
|
import {
|
|
828
835
|
readV2ArchiveOffThread2
|
|
829
|
-
} from "./index-
|
|
836
|
+
} from "./index-1pf5qrx4.js";
|
|
830
837
|
import {
|
|
831
838
|
renderSearchArchiveOffThread2
|
|
832
|
-
} from "./index-
|
|
839
|
+
} from "./index-nny4gm06.js";
|
|
833
840
|
import {
|
|
834
841
|
COMPACTION_ENABLED_PATH,
|
|
835
842
|
isDreamerRunnable,
|
|
@@ -850,9 +857,6 @@ import {
|
|
|
850
857
|
piModelRefToCanonical,
|
|
851
858
|
modelRefLookupOrder
|
|
852
859
|
} from "./index-avwt563y.js";
|
|
853
|
-
import {
|
|
854
|
-
canonicalProjectDirectory
|
|
855
|
-
} from "./index-knvkbfvh.js";
|
|
856
860
|
import {
|
|
857
861
|
getErrorMessage,
|
|
858
862
|
describeError
|
|
@@ -865,12 +869,8 @@ import {
|
|
|
865
869
|
logSlowWriteTransaction
|
|
866
870
|
} from "./index-m0pwswv9.js";
|
|
867
871
|
import {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
writeStorageFileAtomicSync,
|
|
871
|
-
writeStorageFileAsync,
|
|
872
|
-
createStorageWriteStream
|
|
873
|
-
} from "./index-fvnzcnww.js";
|
|
872
|
+
canonicalProjectDirectory
|
|
873
|
+
} from "./index-knvkbfvh.js";
|
|
874
874
|
|
|
875
875
|
// src/config/dependency-notes.ts
|
|
876
876
|
function scheduledTasks(config) {
|
|
@@ -16735,7 +16735,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16735
16735
|
return { count: buildCompartmentCount(db, sessionId, moduleStatus) };
|
|
16736
16736
|
});
|
|
16737
16737
|
const buildManagedCtx = async (db) => {
|
|
16738
|
-
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-
|
|
16738
|
+
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-90869322.js"));
|
|
16739
16739
|
const { resolveHistorianModel } = await importPluginModule(() => import("./model-resolution-280gmqvd.js"));
|
|
16740
16740
|
const { userObservationCollectionEnabled, userObservationsRequested } = await importPluginModule(() => import("./task-config-qt6n4bxm.js"));
|
|
16741
16741
|
const DEFAULT_HISTORIAN_TIMEOUT_MS = 10 * 60 * 1000;
|
|
@@ -16787,7 +16787,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16787
16787
|
const db = readDatabase();
|
|
16788
16788
|
if (!db)
|
|
16789
16789
|
return { ok: false, error: "db unavailable" };
|
|
16790
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16790
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-xzs0a455.js"));
|
|
16791
16791
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-7x518gew.js"));
|
|
16792
16792
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16793
16793
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -16872,7 +16872,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16872
16872
|
const db = readDatabase();
|
|
16873
16873
|
if (!db)
|
|
16874
16874
|
return { ok: false, error: "db unavailable" };
|
|
16875
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16875
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-sm6pwf3p.js"));
|
|
16876
16876
|
const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
|
|
16877
16877
|
const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
|
|
16878
16878
|
if (!window)
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
getEmbeddingProviderIdentity,
|
|
57
57
|
dominantEmbeddingFailure,
|
|
58
58
|
LocalEmbeddingProvider
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-k50xhjw1.js";
|
|
60
60
|
import {
|
|
61
61
|
embedPauseBySession,
|
|
62
62
|
activeEmbeddingSessions,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
} from "./index-2amn2s73.js";
|
|
68
68
|
import {
|
|
69
69
|
setBootQuietPeriodForTests
|
|
70
|
-
} from "./index-
|
|
70
|
+
} from "./index-7svecf3m.js";
|
|
71
71
|
import {
|
|
72
72
|
isEmbeddingHostBusy2
|
|
73
73
|
} from "./index-qt1qqasc.js";
|
|
@@ -78,7 +78,7 @@ import {
|
|
|
78
78
|
acquireGitSweepLease,
|
|
79
79
|
renewGitSweepLease,
|
|
80
80
|
releaseGitSweepLease
|
|
81
|
-
} from "./index-
|
|
81
|
+
} from "./index-3dtzyred.js";
|
|
82
82
|
import {
|
|
83
83
|
saveEmbeddingIfHashMatches,
|
|
84
84
|
getMemoryEmbedCoverage,
|
|
@@ -1407,12 +1407,17 @@ function snapshotFor(registration) {
|
|
|
1407
1407
|
...synapseDescriptor ? { synapseDescriptor } : {}
|
|
1408
1408
|
};
|
|
1409
1409
|
}
|
|
1410
|
+
var pendingProviderDisposals = new Set;
|
|
1410
1411
|
function disposeProvider(provider) {
|
|
1411
1412
|
if (!provider)
|
|
1412
|
-
return;
|
|
1413
|
-
provider.dispose().catch((error) => {
|
|
1413
|
+
return Promise.resolve();
|
|
1414
|
+
const disposal = provider.dispose().catch((error) => {
|
|
1414
1415
|
log2("[magic-context] embedding provider dispose failed:", error);
|
|
1416
|
+
}).finally(() => {
|
|
1417
|
+
pendingProviderDisposals.delete(disposal);
|
|
1415
1418
|
});
|
|
1419
|
+
pendingProviderDisposals.add(disposal);
|
|
1420
|
+
return disposal;
|
|
1416
1421
|
}
|
|
1417
1422
|
function getUpsertActiveIdentityStatement(db) {
|
|
1418
1423
|
let stmt = upsertActiveIdentityStatements.get(db);
|
|
@@ -1775,7 +1780,7 @@ function registerProjectShadowEmbedding2(db, projectIdentity, config, sourceDire
|
|
|
1775
1780
|
return null;
|
|
1776
1781
|
const prior = shadowRegistrations.get(projectIdentity);
|
|
1777
1782
|
if (prior && prior.providerIdentity === providerIdentity) {
|
|
1778
|
-
provider
|
|
1783
|
+
disposeProvider(provider);
|
|
1779
1784
|
dbForShadowQueue.set(projectIdentity, db);
|
|
1780
1785
|
persistShadowDescriptor(db, prior);
|
|
1781
1786
|
const backfillAlreadyArmed = hasPendingShadowBackfill(projectIdentity) || shadowQueue.some((item) => item.projectIdentity === projectIdentity);
|
|
@@ -2428,13 +2433,15 @@ function unregisterProjectEmbedding2(projectIdentity) {
|
|
|
2428
2433
|
const prior = projectRegistrations.get(projectIdentity);
|
|
2429
2434
|
const shadow = shadowRegistrations.get(projectIdentity);
|
|
2430
2435
|
if (!prior && !shadow)
|
|
2431
|
-
return;
|
|
2436
|
+
return Promise.resolve();
|
|
2432
2437
|
projectRegistrations.delete(projectIdentity);
|
|
2433
2438
|
shadowRegistrations.delete(projectIdentity);
|
|
2434
2439
|
dbForShadowQueue.delete(projectIdentity);
|
|
2435
2440
|
globalRegistrationGeneration += 1;
|
|
2436
|
-
|
|
2437
|
-
|
|
2441
|
+
return Promise.all([
|
|
2442
|
+
disposeProvider(prior?.provider ?? null),
|
|
2443
|
+
disposeProvider(shadow?.provider ?? null)
|
|
2444
|
+
]).then(() => {});
|
|
2438
2445
|
}
|
|
2439
2446
|
function getProjectEmbeddingSnapshot2(projectIdentity) {
|
|
2440
2447
|
const registration = projectRegistrations.get(projectIdentity);
|