@cortexkit/pi-magic-context 0.49.24 → 0.49.25

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.
@@ -28,7 +28,7 @@ var [
28
28
  import("./embedding-cache-7rp4gqzr.js"),
29
29
  import("./storage-memory-0ndn65fm.js"),
30
30
  import("./project-embedding-registry-9e82qsb6.js"),
31
- import("./search-n3yqng95.js"),
31
+ import("./search-2aa5kzyp.js"),
32
32
  import("./compartment-chunk-embedding-g9a977b8.js"),
33
33
  import("./embedding-activity-ew6dshfd.js"),
34
34
  import("./harness-9872e0ym.js"),
@@ -34,11 +34,11 @@ import"./index-n4wyxcgr.js";
34
34
  import {
35
35
  LATEST_SUPPORTED_VERSION,
36
36
  enforceSchemaFence
37
- } from "./index-3jde7hdr.js";
38
- import"./index-3c3ztwgc.js";
37
+ } from "./index-d53veb5e.js";
38
+ import"./index-0dr64gsy.js";
39
39
  import"./index-w1avzkdt.js";
40
40
  import"./index-135e8hvg.js";
41
- import"./index-8976mezv.js";
41
+ import"./index-23t8ryqw.js";
42
42
  import"./index-hqw0rt9k.js";
43
43
 
44
44
  // ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts
@@ -13,7 +13,7 @@ import {
13
13
  resolveOpenCodeDbPath,
14
14
  openCodeDbPathExists,
15
15
  getOpenCodeDbProbeDescriptions
16
- } from "./index-8976mezv.js";
16
+ } from "./index-23t8ryqw.js";
17
17
  import {
18
18
  Database2
19
19
  } from "./index-2qtx0q6h.js";
@@ -67,7 +67,7 @@ import {
67
67
  visitRawSessionMessages2,
68
68
  readRawSessionMessageById2,
69
69
  readSessionChunk2
70
- } from "./index-byh4rfe7.js";
70
+ } from "./index-cm9e52mb.js";
71
71
  import {
72
72
  isRecord,
73
73
  providerVisibleMessage,
@@ -101,7 +101,6 @@ import {
101
101
  isPidAlive
102
102
  } from "./index-n4wyxcgr.js";
103
103
  import {
104
- BoundedSessionMap,
105
104
  clearLkgFenceProcessState,
106
105
  commitLkgWithRecoveryFence,
107
106
  clearLkgRecoveryFence,
@@ -109,11 +108,12 @@ import {
109
108
  V2StoreReader,
110
109
  deleteSessionScopedRows,
111
110
  getLastIndexedOrdinal2
112
- } from "./index-hf01gtz7.js";
111
+ } from "./index-zmg1td73.js";
113
112
  import {
113
+ BoundedSessionMap,
114
114
  resolveOpenCodeDbPath,
115
115
  assertOpenCodeStoreGeneration
116
- } from "./index-8976mezv.js";
116
+ } from "./index-23t8ryqw.js";
117
117
  import {
118
118
  noteRawSessionSummaryRowWritten2
119
119
  } from "./index-8hmqdav2.js";
@@ -139,7 +139,7 @@ import {
139
139
  } from "./index-00c5a49f.js";
140
140
  import {
141
141
  getErrorMessage
142
- } from "./index-3jde7hdr.js";
142
+ } from "./index-d53veb5e.js";
143
143
  import {
144
144
  V2_MEMORY_CATEGORIES,
145
145
  CATEGORY_PRIORITY,
@@ -153,7 +153,7 @@ import {
153
153
  expandWorkspaceIdentitySetWithAliases,
154
154
  resolveStoredPathWorkspaceIdentity,
155
155
  storedPathBelongsToWorkspace
156
- } from "./index-3c3ztwgc.js";
156
+ } from "./index-0dr64gsy.js";
157
157
  import {
158
158
  directoryHasGitMetadata,
159
159
  resolveProjectIdentityForSession,
@@ -175,7 +175,7 @@ import {
175
175
  resolveMemoriesByIdsForSearch2,
176
176
  unifiedSearch2,
177
177
  formatSearchResults2
178
- } from "./index-rk8xef10.js";
178
+ } from "./index-zn2xdbjy.js";
179
179
  import {
180
180
  computeCueContentHash,
181
181
  getMuralCueState,
@@ -206,7 +206,7 @@ import {
206
206
  } from "./index-6wdwv3a6.js";
207
207
  import {
208
208
  renderSearchArchive2
209
- } from "./index-faz8bw8b.js";
209
+ } from "./index-cms6wfmd.js";
210
210
  import {
211
211
  computeNormalizedHash
212
212
  } from "./index-9x1f96r8.js";
@@ -1,3 +1,48 @@
1
+ // ../plugin/src/shared/bounded-session-map.ts
2
+ class BoundedSessionMap {
3
+ maxEntries;
4
+ store = new Map;
5
+ constructor(maxEntries) {
6
+ if (!Number.isFinite(maxEntries) || maxEntries < 1) {
7
+ throw new Error(`BoundedSessionMap: maxEntries must be >= 1, got ${maxEntries}`);
8
+ }
9
+ this.maxEntries = maxEntries;
10
+ }
11
+ get(sessionId) {
12
+ const value = this.store.get(sessionId);
13
+ if (value === undefined)
14
+ return;
15
+ this.store.delete(sessionId);
16
+ this.store.set(sessionId, value);
17
+ return value;
18
+ }
19
+ peek(sessionId) {
20
+ return this.store.get(sessionId);
21
+ }
22
+ has(sessionId) {
23
+ return this.store.has(sessionId);
24
+ }
25
+ set(sessionId, value) {
26
+ if (this.store.has(sessionId)) {
27
+ this.store.delete(sessionId);
28
+ } else if (this.store.size >= this.maxEntries) {
29
+ const oldest = this.store.keys().next().value;
30
+ if (oldest !== undefined)
31
+ this.store.delete(oldest);
32
+ }
33
+ this.store.set(sessionId, value);
34
+ }
35
+ delete(sessionId) {
36
+ return this.store.delete(sessionId);
37
+ }
38
+ clear() {
39
+ this.store.clear();
40
+ }
41
+ get size() {
42
+ return this.store.size;
43
+ }
44
+ }
45
+
1
46
  // ../plugin/src/shared/opencode-db-path.ts
2
47
  import { existsSync, readdirSync, statSync } from "node:fs";
3
48
  import { homedir } from "node:os";
@@ -176,34 +221,125 @@ function claimOpenCodeDbDiagnosticOnce(surface, resolution) {
176
221
  }
177
222
 
178
223
  // ../plugin/src/features/magic-context/tool-definition-tokens.ts
179
- var measurements = new Map;
180
- var fingerprints = new Map;
224
+ var ACTIVITY_WINDOW_MS = 10 * 60000;
225
+ var MAX_ACTIVITY_GAP_MS = 60000;
226
+ var WINDOWED_SINCE_KEY = "tool_definition_measurements:windowed_since";
227
+ var routes = new Map;
228
+ var sessionFlights = new BoundedSessionMap(1000);
181
229
  var persistenceDb = null;
230
+ var windowedSince;
231
+ var boundAt = 0;
182
232
  var cachedInsertStmt = null;
233
+ var cachedDeleteStmt = null;
234
+ function agentKey(agentName) {
235
+ return agentName && agentName.length > 0 ? agentName : "default";
236
+ }
183
237
  function keyFor(providerID, modelID, agentName) {
184
- const agent = agentName && agentName.length > 0 ? agentName : "default";
185
- return `${providerID}/${modelID}/${agent}`;
238
+ return `${providerID}/${modelID}/${agentKey(agentName)}`;
239
+ }
240
+ function routeFor(providerID, modelID, agentName) {
241
+ const key = keyFor(providerID, modelID, agentName);
242
+ let route = routes.get(key);
243
+ if (!route) {
244
+ route = {
245
+ providerID,
246
+ modelID,
247
+ agentName: agentKey(agentName),
248
+ tools: new Map,
249
+ live: false,
250
+ clock: 0,
251
+ lastWallAt: Date.now(),
252
+ oldestFireAt: Number.POSITIVE_INFINITY,
253
+ retired: new Map,
254
+ legacyRows: new Set
255
+ };
256
+ routes.set(key, route);
257
+ }
258
+ return { key, route };
259
+ }
260
+ function advanceClock(route) {
261
+ const now = Date.now();
262
+ const gap = Math.min(Math.max(now - route.lastWallAt, 0), MAX_ACTIVITY_GAP_MS);
263
+ route.clock += gap;
264
+ route.lastWallAt = Math.max(route.lastWallAt, now);
265
+ return route.clock;
266
+ }
267
+ function readWindowedSince(db) {
268
+ try {
269
+ const row = db.prepare("SELECT value FROM schema_migrations_meta WHERE key = ?").get(WINDOWED_SINCE_KEY);
270
+ if (!row)
271
+ return;
272
+ const value = Number(row.value);
273
+ return Number.isFinite(value) ? value : undefined;
274
+ } catch {
275
+ return;
276
+ }
277
+ }
278
+ function markWindowed() {
279
+ if (windowedSince !== undefined || !persistenceDb)
280
+ return;
281
+ try {
282
+ persistenceDb.prepare("INSERT OR IGNORE INTO schema_migrations_meta (key, value) VALUES (?, ?)").run(WINDOWED_SINCE_KEY, String(boundAt));
283
+ windowedSince = readWindowedSince(persistenceDb);
284
+ } catch {}
186
285
  }
187
286
  function setDatabase(db) {
287
+ const rebound = persistenceDb !== null && persistenceDb !== db;
188
288
  persistenceDb = db;
289
+ boundAt = Date.now();
189
290
  cachedInsertStmt = null;
291
+ cachedDeleteStmt = null;
292
+ if (rebound) {
293
+ for (const route of routes.values()) {
294
+ for (const slot of route.tools.values()) {
295
+ slot.persisted = false;
296
+ slot.writeFailedAt = undefined;
297
+ }
298
+ for (const retired of route.retired.values())
299
+ retired.rowKept = false;
300
+ route.legacyRows.clear();
301
+ }
302
+ }
303
+ windowedSince = readWindowedSince(db);
304
+ if (windowedSince !== undefined)
305
+ return;
306
+ try {
307
+ if (!db.prepare("SELECT 1 FROM tool_definition_measurements LIMIT 1").get())
308
+ markWindowed();
309
+ } catch {}
190
310
  }
191
311
  function loadToolDefinitionMeasurements(db) {
192
312
  let rows = [];
193
313
  try {
194
- rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count FROM tool_definition_measurements").all();
314
+ rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count, recorded_at FROM tool_definition_measurements").all();
195
315
  } catch {
196
316
  return;
197
317
  }
318
+ const since = readWindowedSince(db);
319
+ const loadedAt = new Map;
198
320
  for (const row of rows) {
199
- const key = keyFor(row.provider_id, row.model_id, row.agent_name);
200
- let inner = measurements.get(key);
201
- if (!inner) {
202
- inner = new Map;
203
- measurements.set(key, inner);
321
+ const { route } = routeFor(row.provider_id, row.model_id, row.agent_name);
322
+ if (route.live)
323
+ continue;
324
+ let now = loadedAt.get(route);
325
+ if (now === undefined) {
326
+ now = advanceClock(route);
327
+ loadedAt.set(route, now);
204
328
  }
205
- inner.set(row.tool_id, row.token_count);
329
+ const legacy = since === undefined || !(Number(row.recorded_at) >= since);
330
+ route.tools.set(row.tool_id, {
331
+ tokens: row.token_count,
332
+ fingerprint: undefined,
333
+ lastFireAt: now,
334
+ legacy,
335
+ persisted: !legacy
336
+ });
337
+ route.oldestFireAt = Math.min(route.oldestFireAt, now);
338
+ if (legacy)
339
+ route.legacyRows.add(row.tool_id);
340
+ else
341
+ route.legacyRows.delete(row.tool_id);
206
342
  }
207
343
  }
208
344
 
209
- export { resolveOpenCodeDbPath, hasV1MessageTables, assertOpenCodeStoreGeneration, openCodeDbPathExists, getOpenCodeDbProbeDescriptions, recordOpenCodeDbReadFailure, clearOpenCodeDbReadFailure, claimOpenCodeDbDiagnosticOnce, setDatabase, loadToolDefinitionMeasurements };
345
+ export { BoundedSessionMap, resolveOpenCodeDbPath, hasV1MessageTables, assertOpenCodeStoreGeneration, openCodeDbPathExists, getOpenCodeDbProbeDescriptions, recordOpenCodeDbReadFailure, clearOpenCodeDbReadFailure, claimOpenCodeDbDiagnosticOnce, setDatabase, loadToolDefinitionMeasurements };
@@ -55,7 +55,7 @@ import {
55
55
  recordOpenCodeDbReadFailure,
56
56
  clearOpenCodeDbReadFailure,
57
57
  claimOpenCodeDbDiagnosticOnce
58
- } from "./index-8976mezv.js";
58
+ } from "./index-23t8ryqw.js";
59
59
  import {
60
60
  prewarmRawSessionOrdinalsForDb,
61
61
  readRawSessionMessagesFromDb2,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-my0dn413.js";
7
7
  import {
8
8
  readRawSessionMessageIdOrdinalsForRange2
9
- } from "./index-byh4rfe7.js";
9
+ } from "./index-cm9e52mb.js";
10
10
 
11
11
  // ../plugin/src/tools/ctx-expand/search-archive.ts
12
12
  var archiveReadsOnThisThread = 0;
@@ -52,7 +52,7 @@ import {
52
52
  hasPendingMigrations,
53
53
  getMainThreadMigrationBodyCount,
54
54
  runMigrations
55
- } from "./index-3c3ztwgc.js";
55
+ } from "./index-0dr64gsy.js";
56
56
  import {
57
57
  closeQuietly,
58
58
  ensureColumn,
@@ -64,7 +64,7 @@ import {
64
64
  hasV1MessageTables,
65
65
  setDatabase,
66
66
  loadToolDefinitionMeasurements
67
- } from "./index-8976mezv.js";
67
+ } from "./index-23t8ryqw.js";
68
68
  import {
69
69
  logSlowWriteTransaction
70
70
  } from "./index-hqw0rt9k.js";
@@ -1307,7 +1307,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1307
1307
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1308
1308
  if (signal.aborted || !readsOpenCodeStore)
1309
1309
  return;
1310
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-tzvv1kph.js"));
1310
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-rndwjfrx.js"));
1311
1311
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-e3r8ddh1.js"));
1312
1312
  if (signal.aborted)
1313
1313
  return;
@@ -15,7 +15,7 @@ import {
15
15
  } from "./index-2qtx0q6h.js";
16
16
  import {
17
17
  createFailClosedBlockingError
18
- } from "./index-3jde7hdr.js";
18
+ } from "./index-d53veb5e.js";
19
19
  import {
20
20
  createWorkerShutdown
21
21
  } from "./index-54wmg4rj.js";
@@ -9,9 +9,10 @@ import {
9
9
  readProcessStartTime
10
10
  } from "./index-n4wyxcgr.js";
11
11
  import {
12
+ BoundedSessionMap,
12
13
  resolveOpenCodeDbPath,
13
14
  assertOpenCodeStoreGeneration
14
- } from "./index-8976mezv.js";
15
+ } from "./index-23t8ryqw.js";
15
16
  import {
16
17
  Database2,
17
18
  getSqliteDatabasePath2,
@@ -46,7 +47,7 @@ import {
46
47
  } from "./index-w1avzkdt.js";
47
48
  import {
48
49
  cleanUserText2
49
- } from "./index-byh4rfe7.js";
50
+ } from "./index-cm9e52mb.js";
50
51
  import {
51
52
  sameProjectDirectory
52
53
  } from "./index-wrr9rp9a.js";
@@ -73,51 +74,6 @@ import {
73
74
  } from "node:fs";
74
75
  import { basename, dirname, join as join2 } from "node:path";
75
76
 
76
- // ../plugin/src/shared/bounded-session-map.ts
77
- class BoundedSessionMap {
78
- maxEntries;
79
- store = new Map;
80
- constructor(maxEntries) {
81
- if (!Number.isFinite(maxEntries) || maxEntries < 1) {
82
- throw new Error(`BoundedSessionMap: maxEntries must be >= 1, got ${maxEntries}`);
83
- }
84
- this.maxEntries = maxEntries;
85
- }
86
- get(sessionId) {
87
- const value = this.store.get(sessionId);
88
- if (value === undefined)
89
- return;
90
- this.store.delete(sessionId);
91
- this.store.set(sessionId, value);
92
- return value;
93
- }
94
- peek(sessionId) {
95
- return this.store.get(sessionId);
96
- }
97
- has(sessionId) {
98
- return this.store.has(sessionId);
99
- }
100
- set(sessionId, value) {
101
- if (this.store.has(sessionId)) {
102
- this.store.delete(sessionId);
103
- } else if (this.store.size >= this.maxEntries) {
104
- const oldest = this.store.keys().next().value;
105
- if (oldest !== undefined)
106
- this.store.delete(oldest);
107
- }
108
- this.store.set(sessionId, value);
109
- }
110
- delete(sessionId) {
111
- return this.store.delete(sessionId);
112
- }
113
- clear() {
114
- this.store.clear();
115
- }
116
- get size() {
117
- return this.store.size;
118
- }
119
- }
120
-
121
77
  // ../plugin/src/shared/storage-file-mutex.ts
122
78
  import { execFileSync } from "node:child_process";
123
79
  import { createHash, randomUUID } from "node:crypto";
@@ -2141,4 +2097,4 @@ async function sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource,
2141
2097
  }));
2142
2098
  }
2143
2099
 
2144
- export { BoundedSessionMap, LkgRecoveryFenceError, clearLkgFenceProcessState, takeLkgRecoveryLockSweepPage, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, markLkgRecoveryDirty, commitLkgWithRecoveryFence, clearLkgRecoveryFence, gaDatabasePath, V2StoreReader, readSessionActivity, observeSessionActivity, backfillSessionActivity, deleteSessionScopedRows, clearCompressionDepth, clearCompressionDepthRange, cleanSearchText, keywordRelevance, matchedSearchSnippet, MESSAGE_INDEX_MAX_FTS_BYTES2, messageIndexSkipKey2, toMessageIndexSource2, getMessageIndexSourceIdentity2, isMessageIndexSourceCurrent2, getLastIndexedOrdinal2, getIndexedMessageCorpusSize2, markMessageIndexDirty2, getMessageIndexReconciliationStartOrdinal2, isMessageIndexReconciledThrough2, deleteIndexedMessage2, clearIndexedMessagesInTransaction2, clearIndexedMessages2, getIndexableContent2, indexSingleMessage2, indexMessagesAfterOrdinal2, indexSourcesAfterOrdinal2, sweepOrphanedOpenCodeMessageIndexesCooperatively2 };
2100
+ export { LkgRecoveryFenceError, clearLkgFenceProcessState, takeLkgRecoveryLockSweepPage, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, markLkgRecoveryDirty, commitLkgWithRecoveryFence, clearLkgRecoveryFence, gaDatabasePath, V2StoreReader, readSessionActivity, observeSessionActivity, backfillSessionActivity, deleteSessionScopedRows, clearCompressionDepth, clearCompressionDepthRange, cleanSearchText, keywordRelevance, matchedSearchSnippet, MESSAGE_INDEX_MAX_FTS_BYTES2, messageIndexSkipKey2, toMessageIndexSource2, getMessageIndexSourceIdentity2, isMessageIndexSourceCurrent2, getLastIndexedOrdinal2, getIndexedMessageCorpusSize2, markMessageIndexDirty2, getMessageIndexReconciliationStartOrdinal2, isMessageIndexReconciledThrough2, deleteIndexedMessage2, clearIndexedMessagesInTransaction2, clearIndexedMessages2, getIndexableContent2, indexSingleMessage2, indexMessagesAfterOrdinal2, indexSourcesAfterOrdinal2, sweepOrphanedOpenCodeMessageIndexesCooperatively2 };
@@ -22,7 +22,7 @@ import {
22
22
  resolveStoredPathWorkspaceIdentity,
23
23
  sourceNameForMemory,
24
24
  managedAuthorityNoteRow
25
- } from "./index-3c3ztwgc.js";
25
+ } from "./index-0dr64gsy.js";
26
26
  import {
27
27
  isKnownAutocommit
28
28
  } from "./index-w1avzkdt.js";
@@ -82,7 +82,7 @@ import {
82
82
  keywordRelevance,
83
83
  matchedSearchSnippet,
84
84
  getIndexedMessageCorpusSize2
85
- } from "./index-hf01gtz7.js";
85
+ } from "./index-zmg1td73.js";
86
86
  import {
87
87
  MESSAGE_FTS_SESSION_FILTER_SQL,
88
88
  withMessageFtsSessionFilter
package/dist/index.js CHANGED
@@ -251,7 +251,7 @@ import {
251
251
  registerTodoStateLifecycle,
252
252
  syncCtxMemoryToolEnabled,
253
253
  registerMagicContextTools
254
- } from "./index-fbrxezw0.js";
254
+ } from "./index-1g0r4req.js";
255
255
  import"./index-4knyh1kt.js";
256
256
  import {
257
257
  canonicalModelIdentity,
@@ -292,7 +292,7 @@ import {
292
292
  openCurrentDatabase,
293
293
  openDatabaseAsync,
294
294
  closeDatabase
295
- } from "./index-3jde7hdr.js";
295
+ } from "./index-d53veb5e.js";
296
296
  import {
297
297
  pruneMissingProjectIdentities,
298
298
  setHomeProjectPermission,
@@ -466,7 +466,7 @@ import {
466
466
  getRawSessionTagKeysThrough2,
467
467
  getLegacyProtectedTailStartOrdinal2,
468
468
  readSessionChunk2
469
- } from "./index-byh4rfe7.js";
469
+ } from "./index-cm9e52mb.js";
470
470
  import {
471
471
  UNKNOWN_FIT_RATIO,
472
472
  hasMeasuredDecisionCalibration,
@@ -592,7 +592,6 @@ import {
592
592
  piHarnessKindFromExecutable
593
593
  } from "./index-n4wyxcgr.js";
594
594
  import {
595
- BoundedSessionMap,
596
595
  LkgRecoveryFenceError,
597
596
  clearLkgFenceProcessState,
598
597
  takeLkgRecoveryLockSweepPage,
@@ -617,15 +616,16 @@ import {
617
616
  indexSingleMessage2,
618
617
  indexMessagesAfterOrdinal2,
619
618
  sweepOrphanedOpenCodeMessageIndexesCooperatively2
620
- } from "./index-hf01gtz7.js";
619
+ } from "./index-zmg1td73.js";
621
620
  import {
621
+ BoundedSessionMap,
622
622
  resolveOpenCodeDbPath,
623
623
  assertOpenCodeStoreGeneration,
624
624
  openCodeDbPathExists,
625
625
  recordOpenCodeDbReadFailure,
626
626
  clearOpenCodeDbReadFailure,
627
627
  claimOpenCodeDbDiagnosticOnce
628
- } from "./index-8976mezv.js";
628
+ } from "./index-23t8ryqw.js";
629
629
  import"./index-399p688g.js";
630
630
  import {
631
631
  createWorkerShutdown
@@ -697,7 +697,7 @@ import {
697
697
  expandWorkspaceIdentitySetWithAliases,
698
698
  sourceNameForMemory,
699
699
  computeWorkspaceEpochFingerprint
700
- } from "./index-3c3ztwgc.js";
700
+ } from "./index-0dr64gsy.js";
701
701
  import {
702
702
  configureContextDatabasePragmas2
703
703
  } from "./index-fapenpch.js";
@@ -747,7 +747,7 @@ import {
747
747
  normalizeVerificationFiles,
748
748
  indexCommitsForProject,
749
749
  embedUnembeddedCommits
750
- } from "./index-rk8xef10.js";
750
+ } from "./index-zn2xdbjy.js";
751
751
  import {
752
752
  setEmbeddingSessionBusy2,
753
753
  isEmbeddingHostBusy2
@@ -811,10 +811,10 @@ import {
811
811
  drainPiTagSnapshotSession,
812
812
  assertPiTagSnapshotReady,
813
813
  ensurePiTagSnapshotReady
814
- } from "./index-ygzh9xdg.js";
814
+ } from "./index-fzfpq5bd.js";
815
815
  import"./index-jn44h81p.js";
816
816
  import"./index-1cvyaw9a.js";
817
- import"./index-faz8bw8b.js";
817
+ import"./index-cms6wfmd.js";
818
818
  import {
819
819
  __toESM
820
820
  } from "./index-22jkk6wg.js";
@@ -3556,7 +3556,7 @@ function startHostStallProfilerSwitch() {
3556
3556
  // package.json
3557
3557
  var package_default = {
3558
3558
  name: "@cortexkit/pi-magic-context",
3559
- version: "0.49.24",
3559
+ version: "0.49.25",
3560
3560
  type: "module",
3561
3561
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3562
3562
  main: "dist/index.js",
@@ -43004,6 +43004,7 @@ function observePipelineResultForTests(sessionId, result) {
43004
43004
  }
43005
43005
  var variantChangeLogObserverForTests;
43006
43006
  var beforePipelineForTests;
43007
+ var thinkingFitInputObserverForTests;
43007
43008
  function logPiLkgRecovery(sessionId, message) {
43008
43009
  lkgRecoveryLogObserverForTests?.(message);
43009
43010
  sessionLog2(sessionId, message);
@@ -45190,15 +45191,7 @@ function registerPiContextHandler(pi, baseOptions) {
45190
45191
  contextLimit: rawFallbackLimit,
45191
45192
  forcePercentage: forceMaterializationPercentage
45192
45193
  });
45193
- let inputForThinkingFit = (getHarness2() !== "pi" || nativeFitPossible) && isPrefixBoundThinkingModel(ctx.model?.provider, ctx.model?.id) ? structuredClone(event.messages) : null;
45194
- let inputForFitReclaim = nativeFitPossible ? inputForThinkingFit ?? structuredClone(event.messages) : undefined;
45195
- if (fitInputStart !== undefined)
45196
- recordPiTransformTiming({
45197
- sessionId,
45198
- stage: "fitInputPreparation",
45199
- elapsedMs: performance.now() - fitInputStart,
45200
- extra: inputForFitReclaim ? "snapshot" : "no-snapshot"
45201
- });
45194
+ const fitPredictionMs = fitInputStart === undefined ? undefined : performance.now() - fitInputStart;
45202
45195
  if (!options.compactionOff && !sessionMeta.isSubagent) {
45203
45196
  let promptId = null;
45204
45197
  for (let i = event.messages.length - 1;i >= 0; i--) {
@@ -45373,7 +45366,24 @@ function registerPiContextHandler(pi, baseOptions) {
45373
45366
  logTransformTiming(sessionId, "historianScheduling", tHistorianScheduling);
45374
45367
  };
45375
45368
  pipelineArgs.evaluateHistorianBeforeReclaim = scheduleHistorian;
45369
+ const fitCopyStart = fitPredictionMs === undefined ? undefined : performance.now();
45370
+ let inputForThinkingFit = (getHarness2() !== "pi" || nativeFitPossible) && isPrefixBoundThinkingModel(ctx.model?.provider, ctx.model?.id) && pipelineArgs.signedThinkingHold === true ? structuredClone(event.messages) : null;
45371
+ let inputForFitReclaim = nativeFitPossible ? inputForThinkingFit ?? structuredClone(event.messages) : undefined;
45372
+ if (fitPredictionMs !== undefined && fitCopyStart !== undefined)
45373
+ recordPiTransformTiming({
45374
+ sessionId,
45375
+ stage: "fitInputPreparation",
45376
+ elapsedMs: fitPredictionMs + (performance.now() - fitCopyStart),
45377
+ extra: inputForFitReclaim ? "snapshot" : "no-snapshot"
45378
+ });
45376
45379
  let result = await budget.waitMandatory(runPipeline(pipelineArgs));
45380
+ thinkingFitInputObserverForTests?.({
45381
+ sessionId,
45382
+ held: pipelineArgs.signedThinkingHold === true,
45383
+ strictThinkingKept: result.strictThinkingKept,
45384
+ thinkingCopy: inputForThinkingFit,
45385
+ fitReclaimCopy: inputForFitReclaim
45386
+ });
45377
45387
  observePipelineResultForTests(sessionId, result);
45378
45388
  logTransformTiming(sessionId, "runPipeline", tRunPipeline);
45379
45389
  if (result.identityRebuilt || result.lkgFrozenReleaseReason)
@@ -13,7 +13,7 @@ import {
13
13
  markMessageIndexDirty2,
14
14
  getIndexableContent2,
15
15
  indexSingleMessage2
16
- } from "./index-hf01gtz7.js";
16
+ } from "./index-zmg1td73.js";
17
17
  import"./index-n8e5e9fp.js";
18
18
  import"./index-my0dn413.js";
19
19
  import"./index-w1avzkdt.js";
@@ -21,8 +21,8 @@ import"./index-ccanzg8p.js";
21
21
  import"./index-399p688g.js";
22
22
  import"./index-54wmg4rj.js";
23
23
  import"./index-8hmqdav2.js";
24
- import"./index-8976mezv.js";
25
- import"./index-byh4rfe7.js";
24
+ import"./index-23t8ryqw.js";
25
+ import"./index-cm9e52mb.js";
26
26
  import"./index-6x556c2q.js";
27
27
  import"./index-8a2wvrda.js";
28
28
  import"./index-gwxaz0z5.js";
@@ -17,16 +17,16 @@ import {
17
17
  indexMessagesAfterOrdinal2,
18
18
  indexSourcesAfterOrdinal2,
19
19
  sweepOrphanedOpenCodeMessageIndexesCooperatively2
20
- } from "./index-hf01gtz7.js";
20
+ } from "./index-zmg1td73.js";
21
21
  import"./index-wb2t932e.js";
22
- import"./index-byh4rfe7.js";
22
+ import"./index-cm9e52mb.js";
23
23
  import"./index-n8e5e9fp.js";
24
24
  import"./index-6x556c2q.js";
25
25
  import"./index-gwxaz0z5.js";
26
26
  import"./index-ccanzg8p.js";
27
27
  import"./index-n4wyxcgr.js";
28
28
  import"./index-8a2wvrda.js";
29
- import"./index-8976mezv.js";
29
+ import"./index-23t8ryqw.js";
30
30
  import"./index-w1avzkdt.js";
31
31
  import"./index-8hmqdav2.js";
32
32
  import"./index-399p688g.js";
@@ -9,18 +9,18 @@ import {
9
9
  import"./index-135e8hvg.js";
10
10
  import {
11
11
  runMigrationsWithRetry
12
- } from "./index-3c3ztwgc.js";
12
+ } from "./index-0dr64gsy.js";
13
13
  import {
14
14
  closeQuietly
15
15
  } from "./index-w1avzkdt.js";
16
- import"./index-8976mezv.js";
16
+ import"./index-23t8ryqw.js";
17
17
  import"./index-hxp6q5f8.js";
18
18
  import"./index-n4wyxcgr.js";
19
19
  import"./index-fapenpch.js";
20
20
  import {
21
21
  setSqlitePragmaConfig,
22
22
  initializeDatabase
23
- } from "./index-3jde7hdr.js";
23
+ } from "./index-d53veb5e.js";
24
24
  import"./index-399p688g.js";
25
25
  import"./index-54wmg4rj.js";
26
26
  import"./index-8hmqdav2.js";
@@ -51,7 +51,7 @@ async function main() {
51
51
  await runMessageFtsRowidMapBackfill(db);
52
52
  reply = { kind: "fts-rowid-backfill" };
53
53
  } else if (input.searchArchive) {
54
- const { renderSearchArchive } = await import("./search-archive-enx1vd9n.js");
54
+ const { renderSearchArchive } = await import("./search-archive-qa1sf8hc.js");
55
55
  const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-napqv76k.js");
56
56
  const archive = input.searchArchive;
57
57
  let raw;
@@ -84,7 +84,7 @@ async function main() {
84
84
  { configureContextDatabasePragmas }
85
85
  ] = await Promise.all([
86
86
  import("./harness-9872e0ym.js"),
87
- import("./message-index-esykp965.js"),
87
+ import("./message-index-fedjhja5.js"),
88
88
  import("./sqlite-context-pragmas-gcgch6qz.js")
89
89
  ]);
90
90
  setHarness(input.harness ?? "opencode");
@@ -104,7 +104,7 @@ async function main() {
104
104
  const { setHarness } = await import("./harness-9872e0ym.js");
105
105
  setHarness(input.harness ?? "opencode");
106
106
  const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
107
- import("./message-index-bounded-hjat9176.js"),
107
+ import("./message-index-bounded-yj7s7cwz.js"),
108
108
  import("./sqlite-context-pragmas-gcgch6qz.js")
109
109
  ]);
110
110
  configureContextDatabasePragmas(db);
@@ -35,11 +35,11 @@ import {
35
35
  readSessionChunk2,
36
36
  getRawSessionMessageIdsThrough2,
37
37
  readRawSessionSeedTail2
38
- } from "./index-byh4rfe7.js";
38
+ } from "./index-cm9e52mb.js";
39
39
  import"./index-n8e5e9fp.js";
40
40
  import"./index-6x556c2q.js";
41
41
  import"./index-ccanzg8p.js";
42
- import"./index-8976mezv.js";
42
+ import"./index-23t8ryqw.js";
43
43
  import"./index-w1avzkdt.js";
44
44
  import"./index-8hmqdav2.js";
45
45
  import"./index-399p688g.js";
@@ -5,9 +5,9 @@ import {
5
5
  resolveMemoriesByIdsForSearch2,
6
6
  unifiedSearch2,
7
7
  formatSearchResults2
8
- } from "./index-rk8xef10.js";
8
+ } from "./index-zn2xdbjy.js";
9
9
  import"./index-1cvyaw9a.js";
10
- import"./index-hf01gtz7.js";
10
+ import"./index-zmg1td73.js";
11
11
  import"./index-nxq2srg9.js";
12
12
  import"./index-00c5a49f.js";
13
13
  import"./index-9p40dgkm.js";
@@ -15,18 +15,18 @@ import"./index-29nw7n1r.js";
15
15
  import"./index-yhzhdp3m.js";
16
16
  import"./index-j3pz3a1b.js";
17
17
  import"./index-wb2t932e.js";
18
- import"./index-byh4rfe7.js";
18
+ import"./index-cm9e52mb.js";
19
19
  import"./index-n8e5e9fp.js";
20
20
  import"./index-6x556c2q.js";
21
21
  import"./index-wqpjhx1p.js";
22
22
  import"./index-gwxaz0z5.js";
23
23
  import"./index-ccanzg8p.js";
24
- import"./index-3c3ztwgc.js";
24
+ import"./index-0dr64gsy.js";
25
25
  import"./index-n4wyxcgr.js";
26
26
  import"./index-hxp6q5f8.js";
27
27
  import"./index-8a2wvrda.js";
28
28
  import"./index-135e8hvg.js";
29
- import"./index-8976mezv.js";
29
+ import"./index-23t8ryqw.js";
30
30
  import"./index-w1avzkdt.js";
31
31
  import"./index-8hmqdav2.js";
32
32
  import"./index-399p688g.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  renderSearchArchive2
3
- } from "./index-faz8bw8b.js";
3
+ } from "./index-cms6wfmd.js";
4
4
  import"./index-1cvyaw9a.js";
5
- import"./index-byh4rfe7.js";
5
+ import"./index-cm9e52mb.js";
6
6
  import"./index-n8e5e9fp.js";
7
7
  import"./index-6x556c2q.js";
8
8
  import"./index-ccanzg8p.js";
9
- import"./index-8976mezv.js";
9
+ import"./index-23t8ryqw.js";
10
10
  import"./index-w1avzkdt.js";
11
11
  import"./index-8hmqdav2.js";
12
12
  import"./index-399p688g.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TOKEN_BUDGET_TOOL_REFUSAL
3
- } from "./index-byh4rfe7.js";
3
+ } from "./index-cm9e52mb.js";
4
4
  import {
5
5
  setHarness2
6
6
  } from "./index-0h2mkab2.js";
@@ -15,15 +15,15 @@ import"./index-n4wyxcgr.js";
15
15
  import"./index-fapenpch.js";
16
16
  import {
17
17
  openDatabase
18
- } from "./index-3jde7hdr.js";
18
+ } from "./index-d53veb5e.js";
19
19
  import"./index-399p688g.js";
20
20
  import"./index-54wmg4rj.js";
21
21
  import"./index-8hmqdav2.js";
22
22
  import"./index-8a2wvrda.js";
23
- import"./index-3c3ztwgc.js";
23
+ import"./index-0dr64gsy.js";
24
24
  import"./index-w1avzkdt.js";
25
25
  import"./index-135e8hvg.js";
26
- import"./index-8976mezv.js";
26
+ import"./index-23t8ryqw.js";
27
27
  import"./index-my0dn413.js";
28
28
  import"./index-4knyh1kt.js";
29
29
  import {
@@ -31,7 +31,7 @@ import {
31
31
  ensureProjectRegisteredFromPiDirectory,
32
32
  resolvePiHarnessKind,
33
33
  registerMagicContextTools
34
- } from "./index-fbrxezw0.js";
34
+ } from "./index-1g0r4req.js";
35
35
  import"./index-ccanzg8p.js";
36
36
  import"./index-gwxaz0z5.js";
37
37
  import"./index-wb2t932e.js";
@@ -41,12 +41,12 @@ import"./index-9p40dgkm.js";
41
41
  import"./index-j3pz3a1b.js";
42
42
  import"./index-yhzhdp3m.js";
43
43
  import"./index-nxq2srg9.js";
44
- import"./index-hf01gtz7.js";
44
+ import"./index-zmg1td73.js";
45
45
  import"./index-n8e5e9fp.js";
46
46
  import"./index-6x556c2q.js";
47
- import"./index-rk8xef10.js";
47
+ import"./index-zn2xdbjy.js";
48
48
  import"./index-1cvyaw9a.js";
49
- import"./index-faz8bw8b.js";
49
+ import"./index-cms6wfmd.js";
50
50
  import"./index-29nw7n1r.js";
51
51
  import"./index-6wdwv3a6.js";
52
52
  import"./index-hqw0rt9k.js";
@@ -9,19 +9,19 @@ import"./index-fapenpch.js";
9
9
  import {
10
10
  LATEST_SUPPORTED_VERSION,
11
11
  getPersistedSchemaVersion
12
- } from "./index-3jde7hdr.js";
12
+ } from "./index-d53veb5e.js";
13
13
  import"./index-399p688g.js";
14
14
  import {
15
15
  exitOnWorkerClose
16
16
  } from "./index-54wmg4rj.js";
17
17
  import"./index-8hmqdav2.js";
18
18
  import"./index-8a2wvrda.js";
19
- import"./index-3c3ztwgc.js";
19
+ import"./index-0dr64gsy.js";
20
20
  import {
21
21
  tagRevisionKey
22
22
  } from "./index-w1avzkdt.js";
23
23
  import"./index-135e8hvg.js";
24
- import"./index-8976mezv.js";
24
+ import"./index-23t8ryqw.js";
25
25
  import"./index-my0dn413.js";
26
26
  import {
27
27
  normalizeTagSnapshotRow2,
@@ -31,7 +31,7 @@ import {
31
31
  encodePiHydrationOperation,
32
32
  PI_FALLBACK_ROW_COLUMNS,
33
33
  PI_FALLBACK_ROW_PREDICATE
34
- } from "./index-ygzh9xdg.js";
34
+ } from "./index-fzfpq5bd.js";
35
35
  import"./index-hqw0rt9k.js";
36
36
 
37
37
  // src/tag-snapshot-worker-pi.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.24",
3
+ "version": "0.49.25",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",