@cortexkit/pi-magic-context 0.49.83 → 0.49.84

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.
@@ -71,7 +71,7 @@ import {
71
71
  import {
72
72
  gaDatabasePath2,
73
73
  V2StoreReader2
74
- } from "./index-qky62xze.js";
74
+ } from "./index-2zre7sck.js";
75
75
  import {
76
76
  deleteUnmappedMessageFtsRows2
77
77
  } from "./index-ghp32f9m.js";
@@ -736,6 +736,29 @@ class V2StoreReader2 {
736
736
  return null;
737
737
  }
738
738
  }
739
+ revertSuffix(sessionID, cutoff, limit) {
740
+ const rows = this.prepare(`WITH target AS (SELECT seq FROM session_message WHERE session_id = ? AND id = ?),
741
+ preceding AS (SELECT MAX(seq) AS seq FROM session_message
742
+ WHERE session_id = ? AND seq < (SELECT seq FROM target))
743
+ SELECT id, seq FROM session_message
744
+ WHERE session_id = ? AND seq >= (SELECT seq FROM preceding)
745
+ ORDER BY seq ASC LIMIT ?`).all(sessionID, cutoff, sessionID, sessionID, limit + 2);
746
+ const [predecessor, boundary] = rows;
747
+ if (!predecessor || boundary?.id !== cutoff || rows.length > limit + 1)
748
+ return;
749
+ return { predecessor, messageIDs: rows.slice(1).map(({ id }) => id) };
750
+ }
751
+ removedRevertMessages(sessionID, suffix) {
752
+ const { predecessor, messageIDs } = suffix;
753
+ const result = this.prepare(`SELECT CASE WHEN EXISTS (SELECT 1 FROM session_v2 WHERE id = ?)
754
+ AND EXISTS (SELECT 1 FROM session_message
755
+ WHERE session_id = ? AND id = ? AND seq = ?)
756
+ THEN (SELECT json_group_array(value) FROM json_each(?) AS staged
757
+ WHERE NOT EXISTS (SELECT 1 FROM session_message AS retained
758
+ WHERE retained.session_id = ? AND retained.id = staged.value))
759
+ END AS missing`).get(sessionID, sessionID, predecessor.id, predecessor.seq, JSON.stringify(messageIDs), sessionID);
760
+ return result.missing === null ? undefined : new Set(JSON.parse(result.missing));
761
+ }
739
762
  sessionExists(sessionID) {
740
763
  return this.prepare("SELECT 1 FROM session_v2 WHERE id = ?").get(sessionID) != null;
741
764
  }
@@ -70,7 +70,7 @@ import {
70
70
  renderMessageByOrdinal2,
71
71
  renderVerboseRange2,
72
72
  renderItemByTag2
73
- } from "./index-qz43gkqe.js";
73
+ } from "./index-0apatd37.js";
74
74
  import {
75
75
  getLastIndexedOrdinal
76
76
  } from "./index-0t9xfj3x.js";
@@ -4767,6 +4767,8 @@ function upsertMural(db, input) {
4767
4767
  var DETERMINISTIC_MURAL_MODEL = "deterministic";
4768
4768
  var MIN_MURAL_CUED_MEMORIES = 15;
4769
4769
  var MIN_MURAL_COVERAGE = 0.5;
4770
+ var visionSkipsLogged = new Set;
4771
+ var MAX_VISION_SKIP_LOG_KEYS = 4096;
4770
4772
  var renderCaches = new WeakMap;
4771
4773
  function rememberRender(db, project, key, image, result) {
4772
4774
  let cache = renderCaches.get(db);
@@ -4863,8 +4865,22 @@ function modelKeyAcceptsImages(modelKey) {
4863
4865
  return false;
4864
4866
  return modelSupportsVision(canonical.slice(0, separator), canonical.slice(separator + 1));
4865
4867
  }
4866
- function resolveMuralWire(db, projectIdentity, modelKey, enabled, budgetTokens = DEFAULT_MURAL_MEMORY_BUDGET, mode = "persist") {
4867
- if (!enabled || !projectIdentity || !modelKeyAcceptsImages(modelKey)) {
4868
+ function resolveMuralWire(db, projectIdentity, modelKey, enabled, budgetTokens = DEFAULT_MURAL_MEMORY_BUDGET, mode = "persist", sessionId) {
4869
+ if (!enabled || !projectIdentity)
4870
+ return { enabled, supportsVision: false };
4871
+ if (!modelKeyAcceptsImages(modelKey)) {
4872
+ if (sessionId && modelKey) {
4873
+ const key = JSON.stringify([sessionId, modelKey]);
4874
+ if (!visionSkipsLogged.has(key)) {
4875
+ visionSkipsLogged.add(key);
4876
+ if (visionSkipsLogged.size > MAX_VISION_SKIP_LOG_KEYS) {
4877
+ const oldest = visionSkipsLogged.values().next().value;
4878
+ if (oldest !== undefined)
4879
+ visionSkipsLogged.delete(oldest);
4880
+ }
4881
+ sessionLog2(sessionId, `[mural] skipped: model ${modelKey} does not accept images`);
4882
+ }
4883
+ }
4868
4884
  return { enabled, supportsVision: false };
4869
4885
  }
4870
4886
  const result = ensureMuralRendered(db, projectIdentity, budgetTokens, mode);
@@ -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-8j41p18c.js"),
141
- import("./store-xg9ez6jn.js"),
140
+ import("./store-reader-ypd6m0ke.js"),
141
+ import("./store-mmd2tmm1.js"),
142
142
  import("./read-session-chunk-wek7gb7j.js"),
143
- import("./render-9xgp0jka.js"),
144
- import("./search-archive-wr38qtkw.js"),
143
+ import("./render-05gdzxc2.js"),
144
+ import("./search-archive-32pv4687.js"),
145
145
  import("./expand-attachments-8sxeyj26.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
package/dist/index.js CHANGED
@@ -166,7 +166,7 @@ import {
166
166
  registerTodoStateLifecycle,
167
167
  syncCtxMemoryToolEnabled,
168
168
  registerMagicContextTools
169
- } from "./index-y573dt51.js";
169
+ } from "./index-a7kcxjc4.js";
170
170
  import"./index-4knyh1kt.js";
171
171
  import {
172
172
  canonicalModelIdentity,
@@ -600,7 +600,7 @@ import {
600
600
  getSourceContents,
601
601
  recordSubagentInvocation,
602
602
  getLatestHistorianInvocationId
603
- } from "./index-qz43gkqe.js";
603
+ } from "./index-0apatd37.js";
604
604
  import {
605
605
  resolveOpenCodeDbPath,
606
606
  assertOpenCodeStoreGeneration,
@@ -667,7 +667,7 @@ import {
667
667
  getLegacyProtectedTailStartOrdinal2,
668
668
  readSessionChunk2
669
669
  } from "./index-hpbdnbtf.js";
670
- import"./index-qky62xze.js";
670
+ import"./index-2zre7sck.js";
671
671
  import {
672
672
  formatSynapseLaneDescriptor
673
673
  } from "./index-5rcjs14a.js";
@@ -868,7 +868,7 @@ import {
868
868
  } from "./index-pdrberjp.js";
869
869
  import"./index-71rg8j43.js";
870
870
  import"./index-8d2z6503.js";
871
- import"./index-wtqv3vha.js";
871
+ import"./index-qxwed9sk.js";
872
872
  import"./index-fvfq9gva.js";
873
873
  import {
874
874
  __toESM
@@ -3622,7 +3622,7 @@ function startHostStallProfilerSwitch() {
3622
3622
  // package.json
3623
3623
  var package_default = {
3624
3624
  name: "@cortexkit/pi-magic-context",
3625
- version: "0.49.83",
3625
+ version: "0.49.84",
3626
3626
  type: "module",
3627
3627
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3628
3628
  main: "dist/index.js",
@@ -19,7 +19,7 @@ serveWorkerJobs(async (input, port) => {
19
19
  await main();
20
20
  async function main() {
21
21
  if (input.v2ArchiveReader) {
22
- const { serveV2ArchiveReads } = await import("./v2-archive-reader-8m9mw6sv.js");
22
+ const { serveV2ArchiveReads } = await import("./v2-archive-reader-1ny52akc.js");
23
23
  await serveV2ArchiveReads(port, openConnections);
24
24
  return;
25
25
  }
@@ -51,7 +51,7 @@ serveWorkerJobs(async (input, port) => {
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-wr38qtkw.js");
54
+ const { renderSearchArchive } = await import("./search-archive-32pv4687.js");
55
55
  const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-0tytrjye.js");
56
56
  const archive = input.searchArchive;
57
57
  let raw;
@@ -3,11 +3,11 @@ import {
3
3
  renderVerboseRange2,
4
4
  renderVerboseRangeForTool2,
5
5
  renderItemByTag2
6
- } from "./index-qz43gkqe.js";
6
+ } from "./index-0apatd37.js";
7
7
  import"./index-nmmge3j6.js";
8
8
  import"./index-0t9xfj3x.js";
9
9
  import"./index-hgd00nas.js";
10
- import"./index-qky62xze.js";
10
+ import"./index-2zre7sck.js";
11
11
  import"./index-cxczethe.js";
12
12
  import"./index-hpbdnbtf.js";
13
13
  import"./index-nh4srq1p.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  renderSearchArchive2
3
3
  } from "./index-fvfq9gva.js";
4
- import"./index-wtqv3vha.js";
4
+ import"./index-qxwed9sk.js";
5
5
  import"./index-8d2z6503.js";
6
6
  import"./index-hpbdnbtf.js";
7
7
  import"./index-nh4srq1p.js";
@@ -4,7 +4,7 @@ import"./index-n0zjvs3h.js";
4
4
  import"./index-2qtx0q6h.js";
5
5
  import {
6
6
  RAW_MESSAGE_TYPES2
7
- } from "./index-qky62xze.js";
7
+ } from "./index-2zre7sck.js";
8
8
  import {
9
9
  markHostUnservedRow
10
10
  } from "./index-by1bzjcd.js";
@@ -17,6 +17,9 @@ var STORAGE_NOTICE_PREFIX = "[Magic Context storage notice] ";
17
17
  function isStorageNoticeText(text) {
18
18
  return typeof text === "string" && text.startsWith(STORAGE_NOTICE_PREFIX);
19
19
  }
20
+ function isStoredStorageNotice(row) {
21
+ return row.type === "synthetic" && isStorageNoticeText(row.data.text);
22
+ }
20
23
 
21
24
  // ../plugin/src/v2/fold/host-media.ts
22
25
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -178,7 +181,7 @@ function restoreRow(row, model, media = HOST_RESTORE_MEDIA) {
178
181
  if (row.type === "system")
179
182
  return [{ role: "system", content: [{ type: "text", text: data.text ?? "" }] }];
180
183
  if (row.type === "synthetic") {
181
- if (isStorageNoticeText(data.text))
184
+ if (isStoredStorageNotice(row))
182
185
  return [];
183
186
  return [make("user", [{ type: "text", text: data.text ?? "", synthetic: true }])];
184
187
  }
@@ -3,7 +3,7 @@ import {
3
3
  RAW_MESSAGE_TYPES2,
4
4
  V2StoreReaderPool2,
5
5
  V2StoreReader2
6
- } from "./index-qky62xze.js";
6
+ } from "./index-2zre7sck.js";
7
7
  import"./index-n0zjvs3h.js";
8
8
  import"./index-2qtx0q6h.js";
9
9
  export {
@@ -34,7 +34,7 @@ import {
34
34
  resolvePiHarnessKind,
35
35
  reportSubagentStartupError,
36
36
  registerMagicContextTools
37
- } from "./index-y573dt51.js";
37
+ } from "./index-a7kcxjc4.js";
38
38
  import"./index-vcegxfwg.js";
39
39
  import"./index-5rcjs14a.js";
40
40
  import"./index-cxczethe.js";
@@ -45,14 +45,14 @@ import"./index-9p40dgkm.js";
45
45
  import"./index-gdy08gn6.js";
46
46
  import"./index-yhzhdp3m.js";
47
47
  import"./index-47g3pgzk.js";
48
- import"./index-qz43gkqe.js";
48
+ import"./index-0apatd37.js";
49
49
  import"./index-0t9xfj3x.js";
50
50
  import"./index-nh4srq1p.js";
51
51
  import"./index-6x556c2q.js";
52
- import"./index-qky62xze.js";
52
+ import"./index-2zre7sck.js";
53
53
  import"./index-nmmge3j6.js";
54
54
  import"./index-8d2z6503.js";
55
- import"./index-wtqv3vha.js";
55
+ import"./index-qxwed9sk.js";
56
56
  import"./index-fvfq9gva.js";
57
57
  import"./index-k8xz22jc.js";
58
58
  import"./index-29nw7n1r.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./index-wtqv3vha.js";
4
+ } from "./index-qxwed9sk.js";
5
5
  import"./index-8sqebjzk.js";
6
6
  import"./index-2qtx0q6h.js";
7
7
  import"./index-x2n261wp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.83",
3
+ "version": "0.49.84",
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",