@cortexkit/pi-magic-context 0.49.20 → 0.49.22

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 (48) hide show
  1. package/dist/auto-search-worker.js +6 -6
  2. package/dist/chunk-embedding-write-worker.js +9 -9
  3. package/dist/{compaction-marker-candidates-fnm47jat.js → compaction-marker-candidates-p1kqkqhq.js} +2 -2
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/{compartment-chunk-embedding-81qesfjs.js → compartment-chunk-embedding-y01m95c2.js} +5 -5
  6. package/dist/{embedding-backfill-56e871c6.js → embedding-backfill-2vh6m3bg.js} +11 -11
  7. package/dist/embedding-worker-process.js +1 -1
  8. package/dist/embedding-worker.js +4 -4
  9. package/dist/{index-dzem6gn9.js → index-29nw7n1r.js} +1 -1
  10. package/dist/{index-jt0g3hn0.js → index-2bx7ge3x.js} +60 -18
  11. package/dist/{index-hws5f0z9.js → index-2qtx0q6h.js} +213 -4
  12. package/dist/{index-5vgt1zeh.js → index-3c3ztwgc.js} +2 -2
  13. package/dist/{index-rgfb753z.js → index-579m1751.js} +2 -2
  14. package/dist/{index-kqb3d8bs.js → index-5j6vwg4z.js} +148 -11
  15. package/dist/{index-6kb2xpw7.js → index-6wdwv3a6.js} +1 -1
  16. package/dist/{index-rfyvax95.js → index-at6py2k3.js} +1 -1
  17. package/dist/{index-bxmf4dhr.js → index-ccanzg8p.js} +2367 -1243
  18. package/dist/{index-mtvvhcw4.js → index-dbgg6hsf.js} +24 -10
  19. package/dist/{index-af9t637y.js → index-ftvm2acc.js} +121 -38
  20. package/dist/{index-zhwwp8zz.js → index-gqjxy2p7.js} +14 -4
  21. package/dist/{index-jxjr7kz9.js → index-gwxaz0z5.js} +2 -4
  22. package/dist/{index-p63nwn5v.js → index-hxp6q5f8.js} +1 -1
  23. package/dist/{index-qerzchrs.js → index-j3pz3a1b.js} +1 -1
  24. package/dist/{index-bttctq07.js → index-n8e5e9fp.js} +6 -3
  25. package/dist/{index-b8am7tns.js → index-pe5gz5c4.js} +4 -4
  26. package/dist/{index-tb3d9trm.js → index-st4gwt64.js} +1 -1
  27. package/dist/{index-5n5zxs8e.js → index-vx6f7wff.js} +2 -2
  28. package/dist/{index-v2epyzbm.js → index-w1twp2kp.js} +9 -7
  29. package/dist/{index-vdy273xw.js → index-wgmhk91m.js} +10 -4
  30. package/dist/{index-e19qtjj0.js → index-wqpjhx1p.js} +35 -4
  31. package/dist/index.js +239 -209
  32. package/dist/{message-fts-rowid-map-bpexnsdj.js → message-fts-rowid-map-59y476bk.js} +3 -3
  33. package/dist/{message-index-mvag9crh.js → message-index-3snxf11x.js} +9 -9
  34. package/dist/{message-index-bounded-d4r3weh0.js → message-index-bounded-4ngt600v.js} +9 -9
  35. package/dist/{message-time-backfill-kc10yrcj.js → message-time-backfill-e3r8ddh1.js} +1 -1
  36. package/dist/migration-worker.js +6 -6
  37. package/dist/{project-embedding-registry-cfrg952x.js → project-embedding-registry-hfyzs654.js} +10 -10
  38. package/dist/raw-ordinal-warmup-worker.js +8 -8
  39. package/dist/{read-session-chunk-7g4zvpd8.js → read-session-chunk-5dmc77q2.js} +5 -5
  40. package/dist/{read-session-raw-0fsjh10f.js → read-session-raw-yxv2fv34.js} +2 -2
  41. package/dist/{search-archive-qbhp7e89.js → search-archive-3daj5ttc.js} +6 -6
  42. package/dist/{search-hp4g3g9v.js → search-jhfh3tsj.js} +17 -17
  43. package/dist/{sqlite-d67n6dtr.js → sqlite-v89bj0yy.js} +7 -1
  44. package/dist/{storage-memory-9g882j7a.js → storage-memory-0ndn65fm.js} +2 -2
  45. package/dist/{storage-tags-m2qcp1g2.js → storage-tags-r48vxthe.js} +2 -2
  46. package/dist/subagent-entry.js +22 -21
  47. package/dist/tag-snapshot-worker-pi.js +8 -8
  48. package/package.json +5 -2
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./index-bxmf4dhr.js";
3
+ } from "./index-ccanzg8p.js";
4
4
  import {
5
5
  getSynapseLaneIdentity
6
- } from "./index-jxjr7kz9.js";
6
+ } from "./index-gwxaz0z5.js";
7
7
  import {
8
8
  getHarness2
9
9
  } from "./index-0h2mkab2.js";
@@ -14,7 +14,7 @@ import {
14
14
  } from "./index-fgs78jyd.js";
15
15
  import {
16
16
  inRootAsyncContext2
17
- } from "./index-hws5f0z9.js";
17
+ } from "./index-2qtx0q6h.js";
18
18
  import {
19
19
  computeNormalizedHash
20
20
  } from "./index-9x1f96r8.js";
@@ -725,16 +725,20 @@ class EmbeddingWorkerClient {
725
725
  entry;
726
726
  timeoutMs;
727
727
  prepareTelemetry;
728
+ idleMs;
728
729
  worker = null;
729
730
  startPromise = null;
730
731
  nextId = 1;
731
732
  pending = new Map;
732
733
  disposed = false;
733
- 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) {
734
+ activeRequests = 0;
735
+ idleTimer = null;
736
+ 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) {
734
737
  this.data = data;
735
738
  this.entry = entry;
736
739
  this.timeoutMs = timeoutMs;
737
740
  this.prepareTelemetry = prepareTelemetry;
741
+ this.idleMs = idleMs;
738
742
  }
739
743
  start() {
740
744
  if (this.startPromise)
@@ -800,6 +804,7 @@ class EmbeddingWorkerClient {
800
804
  const fail = (error) => {
801
805
  if (this.worker !== worker)
802
806
  return;
807
+ this.clearIdleTimer();
803
808
  this.worker = null;
804
809
  for (const request of this.pending.values()) {
805
810
  clearTimeout(request.timer);
@@ -824,6 +829,31 @@ class EmbeddingWorkerClient {
824
829
  async request(texts, signal) {
825
830
  if (signal?.aborted)
826
831
  return Promise.reject(new Error("embedding request aborted"));
832
+ this.activeRequests++;
833
+ this.clearIdleTimer();
834
+ try {
835
+ return await this.requestOnWorker(texts, signal);
836
+ } finally {
837
+ this.activeRequests--;
838
+ this.armIdleTimer();
839
+ }
840
+ }
841
+ clearIdleTimer() {
842
+ if (this.idleTimer)
843
+ clearTimeout(this.idleTimer);
844
+ this.idleTimer = null;
845
+ }
846
+ armIdleTimer() {
847
+ if (this.disposed || this.activeRequests !== 0 || !this.worker)
848
+ return;
849
+ this.clearIdleTimer();
850
+ this.idleTimer = inRootAsyncContext2(() => setTimeout(() => {
851
+ this.idleTimer = null;
852
+ this.stop(new Error("embedding worker idle"));
853
+ }, this.idleMs));
854
+ this.idleTimer.unref();
855
+ }
856
+ async requestOnWorker(texts, signal) {
827
857
  const worker = await this.start();
828
858
  if (this.disposed)
829
859
  throw new Error("embedding worker disposed");
@@ -875,6 +905,7 @@ class EmbeddingWorkerClient {
875
905
  });
876
906
  }
877
907
  async stop(error) {
908
+ this.clearIdleTimer();
878
909
  const worker = this.worker;
879
910
  this.worker = null;
880
911
  for (const request of this.pending.values()) {