@cortexkit/pi-magic-context 0.49.84 → 0.49.86

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 (32) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +5 -4
  3. package/dist/{embedding-backfill-yh10bmx5.js → embedding-backfill-7a01ns95.js} +6 -5
  4. package/dist/embedding-worker.js +14 -27
  5. package/dist/{index-e0zdn1p3.js → index-53fgdt6n.js} +1 -1
  6. package/dist/{index-47g3pgzk.js → index-5n3bqhp9.js} +9 -8
  7. package/dist/{index-xz5b9t4g.js → index-7yz95h83.js} +38 -736
  8. package/dist/{index-a7kcxjc4.js → index-8631kxcp.js} +25 -18
  9. package/dist/index-8x8wtn3t.js +1083 -0
  10. package/dist/{index-hna2sxy8.js → index-94z1xzmr.js} +3 -3
  11. package/dist/{index-0apatd37.js → index-bjr11ay6.js} +24 -26
  12. package/dist/{index-gdy08gn6.js → index-ex9te7tc.js} +1 -1
  13. package/dist/{index-qxwed9sk.js → index-fd57gfnn.js} +4 -4
  14. package/dist/{index-nmmge3j6.js → index-gbc29ysq.js} +1 -1
  15. package/dist/{index-txcs0vnj.js → index-rqdjb6j3.js} +461 -273
  16. package/dist/{index-k8xz22jc.js → index-sqp84q6s.js} +1 -1
  17. package/dist/{index-3g1wy4z9.js → index-wy6h2wn2.js} +22 -10
  18. package/dist/index.js +61 -57
  19. package/dist/migration-worker.js +5 -4
  20. package/dist/{project-embedding-registry-3sss39rx.js → project-embedding-registry-agkd7egh.js} +7 -4
  21. package/dist/raw-ordinal-warmup-worker.js +2 -2
  22. package/dist/{render-05gdzxc2.js → render-rphfegr8.js} +7 -6
  23. package/dist/{search-archive-32pv4687.js → search-archive-7p43e77j.js} +1 -1
  24. package/dist/{search-dh4ryftv.js → search-rdvsnxky.js} +9 -8
  25. package/dist/{store-mmd2tmm1.js → store-ekaexkvc.js} +1 -1
  26. package/dist/{store-reader-ypd6m0ke.js → store-reader-vwphd51b.js} +1 -1
  27. package/dist/subagent-entry.js +17 -17
  28. package/dist/tag-snapshot-worker-pi.js +5 -4
  29. package/dist/{v2-archive-reader-1ny52akc.js → v2-archive-reader-qc4c9wrp.js} +1 -1
  30. package/package.json +1 -1
  31. package/dist/index-81nthk8j.js +0 -193
  32. /package/dist/{index-2zre7sck.js → index-ddfjg278.js} +0 -0
@@ -2,15 +2,15 @@ import {
2
2
  getMagicContextStorageDir,
3
3
  log2
4
4
  } from "./index-tm11k42a.js";
5
+ import {
6
+ writeStorageFileAtomicSync
7
+ } from "./index-8x8wtn3t.js";
5
8
  import {
6
9
  inRootAsyncContext2
7
10
  } from "./index-2qtx0q6h.js";
8
11
  import {
9
12
  projectDirectoryKey
10
13
  } from "./index-wrr9rp9a.js";
11
- import {
12
- writeStorageFileAtomicSync
13
- } from "./index-81nthk8j.js";
14
14
 
15
15
  // ../plugin/src/features/magic-context/memory/project-identity.ts
16
16
  import { execFileSync } from "node:child_process";
@@ -60,8 +60,13 @@ import {
60
60
  } from "./index-2qtx0q6h.js";
61
61
  import {
62
62
  isPidAlive,
63
- readProcessStartTime
64
- } from "./index-xz5b9t4g.js";
63
+ readProcessStartTime,
64
+ ensurePrivateStorageDirectorySync,
65
+ writeStorageFileSync,
66
+ writeStorageFileAtomicSync,
67
+ syncStorageDirectorySync,
68
+ writeStorageFileDurableAtomicSync
69
+ } from "./index-8x8wtn3t.js";
65
70
  import {
66
71
  withReadOnlySessionDb,
67
72
  expandToolPart,
@@ -71,7 +76,7 @@ import {
71
76
  import {
72
77
  gaDatabasePath2,
73
78
  V2StoreReader2
74
- } from "./index-2zre7sck.js";
79
+ } from "./index-ddfjg278.js";
75
80
  import {
76
81
  deleteUnmappedMessageFtsRows2
77
82
  } from "./index-ghp32f9m.js";
@@ -85,29 +90,22 @@ import {
85
90
  import {
86
91
  layoutLkgPrefix,
87
92
  assembleLkgPrefix
88
- } from "./index-e0zdn1p3.js";
93
+ } from "./index-53fgdt6n.js";
89
94
  import {
90
95
  logSlowWriteTransaction
91
96
  } from "./index-1ts77n1b.js";
92
- import {
93
- ensurePrivateStorageDirectorySync,
94
- writeStorageFileSync,
95
- writeStorageFileAtomicSync,
96
- syncStorageDirectorySync,
97
- writeStorageFileDurableAtomicSync
98
- } from "./index-81nthk8j.js";
99
97
  // ../plugin/src/features/magic-context/storage-meta-session.ts
100
98
  import { Buffer as Buffer2 } from "node:buffer";
101
99
 
102
100
  // ../plugin/src/hooks/magic-context/lkg-recovery-fence.ts
103
101
  import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
104
- import { lstatSync, readdirSync as readdirSync2, readFileSync as readFileSync2, rmdirSync, rmSync as rmSync2 } from "node:fs";
105
- import { basename, dirname, join as join2 } from "node:path";
102
+ import { lstatSync, readFileSync as readFileSync2, rmdirSync as rmdirSync2, rmSync as rmSync2 } from "node:fs";
103
+ import { dirname, join as join2 } from "node:path";
106
104
 
107
105
  // ../plugin/src/shared/storage-file-mutex.ts
108
106
  import { execFileSync } from "node:child_process";
109
107
  import { createHash, randomUUID } from "node:crypto";
110
- import { readdirSync, readFileSync, rmSync } from "node:fs";
108
+ import { readdirSync, readFileSync, rmdirSync, rmSync } from "node:fs";
111
109
  import { join } from "node:path";
112
110
  var ticketChecksum = (name, ticket) => createHash("sha256").update(JSON.stringify([name, ticket.choosing, ticket.number, ticket.birth])).digest("hex");
113
111
  function processBirth(pid) {
@@ -140,23 +138,23 @@ function processBirth(pid) {
140
138
  }
141
139
  var pause = new Int32Array(new SharedArrayBuffer(4));
142
140
  function withStorageFileMutex(directory, work, timeoutMs = 1000) {
143
- ensurePrivateStorageDirectorySync(directory);
141
+ const deadline = performance.now() + timeoutMs;
144
142
  const name = `${process.pid}-${randomUUID()}.lock`;
145
143
  const ownPath = join(directory, name);
146
144
  const birth = processBirth(process.pid);
147
145
  const ticket = { choosing: true, number: 0, birth, checksum: "" };
148
146
  const encodedTicket = () => JSON.stringify({ ...ticket, checksum: ticketChecksum(name, ticket) });
149
- for (let attempt = 0;; attempt++) {
147
+ for (;; ) {
150
148
  try {
149
+ ensurePrivateStorageDirectorySync(directory);
151
150
  writeStorageFileSync(ownPath, encodedTicket(), { flag: "wx", forcePrivate: true });
152
151
  break;
153
152
  } catch (error) {
154
- if (error.code !== "ENOENT" || attempt >= 2)
153
+ const code = error.code;
154
+ if (code !== "ENOENT" && code !== "EEXIST" && code !== "EINVAL" || performance.now() >= deadline)
155
155
  throw error;
156
- ensurePrivateStorageDirectorySync(directory);
157
156
  }
158
157
  }
159
- const deadline = performance.now() + timeoutMs;
160
158
  const peers = () => {
161
159
  const found = [];
162
160
  for (const other of readdirSync(directory)) {
@@ -198,6 +196,9 @@ function withStorageFileMutex(directory, work, timeoutMs = 1000) {
198
196
  return result;
199
197
  } finally {
200
198
  rmSync(ownPath, { force: true });
199
+ try {
200
+ rmdirSync(directory);
201
+ } catch {}
201
202
  }
202
203
  }
203
204
 
@@ -283,7 +284,7 @@ function publishRecord(record) {
283
284
  try {
284
285
  if (record.state === "clean")
285
286
  observer?.("clean");
286
- writeStorageFileDurableAtomicSync(lkgRecoveryFencePath(record.sessionId), JSON.stringify({ ...record, checksum: hash(JSON.stringify(payload(record))) }), () => observer?.("temp-synced"));
287
+ writeStorageFileDurableAtomicSync(lkgRecoveryFencePath(record.sessionId), JSON.stringify({ ...record, checksum: hash(JSON.stringify(payload(record))) }), () => observer?.("temp-synced"), `${lkgRecoveryFencePath(record.sessionId)}.tmp`);
287
288
  if (record.state === "dirty")
288
289
  observer?.("dirty");
289
290
  remember(record.sessionId, {
@@ -294,7 +295,7 @@ function publishRecord(record) {
294
295
  const visible = read(record.sessionId);
295
296
  if (record.state === "clean" && visible?.state === "clean" && visible.revision === record.revision && visible.slotKey === record.slotKey) {
296
297
  const dirty = { ...record, state: "dirty" };
297
- writeStorageFileDurableAtomicSync(lkgRecoveryFencePath(record.sessionId), JSON.stringify({ ...dirty, checksum: hash(JSON.stringify(payload(dirty))) }));
298
+ writeStorageFileDurableAtomicSync(lkgRecoveryFencePath(record.sessionId), JSON.stringify({ ...dirty, checksum: hash(JSON.stringify(payload(dirty))) }), undefined, `${lkgRecoveryFencePath(record.sessionId)}.tmp`);
298
299
  }
299
300
  remember(record.sessionId, { state: "invalid", record: null });
300
301
  throw error;
@@ -334,10 +335,7 @@ function locked(sessionId, work) {
334
335
  ioObserver?.("mutex");
335
336
  return withStorageFileMutex(`${lkgRecoveryFencePath(sessionId)}.locks`, () => {
336
337
  const path = lkgRecoveryFencePath(sessionId);
337
- for (const name of readdirSync2(dirname(path))) {
338
- if (name.startsWith(`${basename(path)}.`) && name.endsWith(".tmp"))
339
- rmSync2(join2(dirname(path), name), { force: true });
340
- }
338
+ rmSync2(`${path}.tmp`, { force: true });
341
339
  return work();
342
340
  });
343
341
  }
@@ -477,7 +475,7 @@ function clearLkgRecoveryFence(sessionId, remove, shouldClear) {
477
475
  });
478
476
  } finally {
479
477
  try {
480
- rmdirSync(`${path}.locks`);
478
+ rmdirSync2(`${path}.locks`);
481
479
  } catch {}
482
480
  }
483
481
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
5
  isUserHomeDirectory
6
- } from "./index-hna2sxy8.js";
6
+ } from "./index-94z1xzmr.js";
7
7
  import {
8
8
  logSlowWriteTransaction
9
9
  } from "./index-1ts77n1b.js";
@@ -137,11 +137,11 @@ async function serveV2ArchiveReads2(port, openConnections) {
137
137
  { createV2RecoveryAttachments }
138
138
  ] = await Promise.all([
139
139
  import("./sqlite-v89bj0yy.js"),
140
- import("./store-reader-ypd6m0ke.js"),
141
- import("./store-mmd2tmm1.js"),
140
+ import("./store-reader-vwphd51b.js"),
141
+ import("./store-ekaexkvc.js"),
142
142
  import("./read-session-chunk-wek7gb7j.js"),
143
- import("./render-05gdzxc2.js"),
144
- import("./search-archive-32pv4687.js"),
143
+ import("./render-rphfegr8.js"),
144
+ import("./search-archive-7p43e77j.js"),
145
145
  import("./expand-attachments-8sxeyj26.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-2qtx0q6h.js";
7
7
  import {
8
8
  managedAuthorityNoteRow
9
- } from "./index-e0zdn1p3.js";
9
+ } from "./index-53fgdt6n.js";
10
10
 
11
11
  // ../plugin/src/features/magic-context/storage-notes.ts
12
12
  var NOTE_TYPES = new Set(["session", "smart"]);