@cortexkit/pi-magic-context 0.49.14 → 0.49.16

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 (42) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +8 -6
  3. package/dist/{embedding-backfill-7kj16fh9.js → embedding-backfill-c4bdw8pp.js} +10 -8
  4. package/dist/embedding-worker.js +2 -2
  5. package/dist/historian-calibration-extension.js +15 -103
  6. package/dist/index-1cvyaw9a.js +58 -0
  7. package/dist/{index-65kty5te.js → index-4178cbfw.js} +20 -69
  8. package/dist/{index-75ah9413.js → index-44h64qza.js} +3 -3
  9. package/dist/{index-9jvktm7k.js → index-657xh9w4.js} +1 -1
  10. package/dist/{index-7qc73yk5.js → index-afy3dzf9.js} +3 -3
  11. package/dist/{index-y29y2j2w.js → index-ajfpyk0x.js} +164 -11
  12. package/dist/{index-1k729e4f.js → index-bxmf4dhr.js} +6 -6
  13. package/dist/{index-j0n09wtp.js → index-dne4ja7a.js} +7 -5
  14. package/dist/{index-a4pk5yv9.js → index-fhyy4ave.js} +14 -14
  15. package/dist/index-ja1c33qa.js +62 -0
  16. package/dist/{index-1mrvw9en.js → index-mx59cve4.js} +1 -1
  17. package/dist/{index-nwbhe6qv.js → index-n3r2d2pr.js} +5 -5
  18. package/dist/{index-7wagp5jp.js → index-p3evwech.js} +3 -3
  19. package/dist/{index-he9s4qsj.js → index-qqxqwqhp.js} +22 -2
  20. package/dist/{index-djxc8w8c.js → index-s1xn8qfw.js} +21 -25
  21. package/dist/{index-bet4sd3e.js → index-tympym62.js} +1 -1
  22. package/dist/{index-ccsscaap.js → index-v8d4vgam.js} +37 -16
  23. package/dist/index-wrr9rp9a.js +16 -0
  24. package/dist/{index-1vw4f2pe.js → index-x3k1530z.js} +5 -7
  25. package/dist/{index-0awvkeb5.js → index-xmzhrht0.js} +10 -61
  26. package/dist/{index-6ex901g3.js → index-y5c73caa.js} +2 -2
  27. package/dist/index.js +787 -271
  28. package/dist/message-fts-rowid-map-mbanfkt1.js +22 -0
  29. package/dist/{message-index-bounded-z4d3x9ty.js → message-index-bounded-xzerjxmp.js} +7 -7
  30. package/dist/{message-index-dw4z9efj.js → message-index-easvmz22.js} +8 -8
  31. package/dist/{message-time-backfill-r2ar1qvk.js → message-time-backfill-3q4kemfc.js} +4 -4
  32. package/dist/migration-worker.js +6 -4
  33. package/dist/{project-embedding-registry-52zwmtbn.js → project-embedding-registry-xwnmqmx8.js} +9 -7
  34. package/dist/raw-ordinal-warmup-worker.js +37 -7
  35. package/dist/{read-session-chunk-0fsgg2k1.js → read-session-chunk-1sb5n7zs.js} +5 -5
  36. package/dist/{read-session-raw-azkqjgzg.js → read-session-raw-jz5e9jz0.js} +1 -1
  37. package/dist/search-archive-3ma5n0wr.js +20 -0
  38. package/dist/{search-ddbz6v60.js → search-x3fa0561.js} +16 -15
  39. package/dist/{storage-tags-3kb5tvgg.js → storage-tags-jtessrec.js} +1 -1
  40. package/dist/subagent-entry.js +19 -17
  41. package/dist/tag-snapshot-worker-pi.js +15 -18
  42. package/package.json +3 -1
@@ -18,11 +18,11 @@ var [
18
18
  { Database, registerSqliteDiagnosticSink },
19
19
  { log }
20
20
  ] = await Promise.all([
21
- import("./embedding-backfill-7kj16fh9.js"),
21
+ import("./embedding-backfill-c4bdw8pp.js"),
22
22
  import("./embedding-cache-7rp4gqzr.js"),
23
23
  import("./storage-memory-axnsk5t1.js"),
24
- import("./project-embedding-registry-52zwmtbn.js"),
25
- import("./search-ddbz6v60.js"),
24
+ import("./project-embedding-registry-xwnmqmx8.js"),
25
+ import("./search-x3fa0561.js"),
26
26
  import("./embedding-activity-ew6dshfd.js"),
27
27
  import("./harness-9872e0ym.js"),
28
28
  import("./sqlite-adjpy399.js"),
@@ -10,26 +10,28 @@ import {
10
10
  import"./index-g4jf772p.js";
11
11
  import"./index-7bqrfyny.js";
12
12
  import"./index-6dz2ed1v.js";
13
- import"./index-djxc8w8c.js";
13
+ import"./index-399p688g.js";
14
+ import"./index-qqxqwqhp.js";
15
+ import"./index-s1xn8qfw.js";
14
16
  import {
15
17
  replaceCompartmentChunkEmbeddings,
16
18
  recordChunkEmbedBackoff,
17
19
  loadUnembeddedSessionChunkCandidates,
18
20
  countUnembeddedSessionCompartments
19
- } from "./index-7qc73yk5.js";
21
+ } from "./index-afy3dzf9.js";
20
22
  import {
21
23
  recordSessionProjectIdentity,
22
24
  acquireGitSweepLease,
23
25
  renewGitSweepLease,
24
26
  releaseGitSweepLease
25
- } from "./index-1mrvw9en.js";
26
- import"./index-6ex901g3.js";
27
+ } from "./index-mx59cve4.js";
28
+ import"./index-y5c73caa.js";
27
29
  import"./index-apgwdby5.js";
28
30
  import {
29
31
  LATEST_SUPPORTED_VERSION,
30
32
  enforceSchemaFence
31
- } from "./index-ccsscaap.js";
32
- import"./index-bet4sd3e.js";
33
+ } from "./index-v8d4vgam.js";
34
+ import"./index-tympym62.js";
33
35
  import"./index-jrap43gc.js";
34
36
  import"./index-135e8hvg.js";
35
37
  import"./index-8976mezv.js";
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-7wagp5jp.js";
4
- import"./index-nwbhe6qv.js";
3
+ } from "./index-p3evwech.js";
4
+ import"./index-n3r2d2pr.js";
5
5
  import"./index-9p40dgkm.js";
6
6
  import"./index-yhzhdp3m.js";
7
- import"./index-1mrvw9en.js";
8
- import"./index-7qc73yk5.js";
9
- import"./index-9jvktm7k.js";
7
+ import"./index-mx59cve4.js";
8
+ import"./index-afy3dzf9.js";
9
+ import"./index-657xh9w4.js";
10
10
  import"./index-6dz2ed1v.js";
11
- import"./index-1k729e4f.js";
12
- import"./index-6ex901g3.js";
13
- import"./index-djxc8w8c.js";
11
+ import"./index-bxmf4dhr.js";
12
+ import"./index-y5c73caa.js";
13
+ import"./index-s1xn8qfw.js";
14
+ import"./index-qqxqwqhp.js";
15
+ import"./index-399p688g.js";
14
16
  import"./index-d4dt19md.js";
15
17
  import"./index-g4jf772p.js";
16
18
  import"./index-asrxgdt4.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  log2
6
6
  } from "./index-7bqrfyny.js";
7
- import"./index-1k729e4f.js";
7
+ import"./index-bxmf4dhr.js";
8
8
  import"./index-6dz2ed1v.js";
9
9
  import"./index-g4jf772p.js";
10
10
  import"./index-asrxgdt4.js";
@@ -12,7 +12,7 @@ import {
12
12
  resolveLocalEmbeddingWorkerRuntime,
13
13
  getLocalEmbeddingNativeMemoryStats,
14
14
  LocalEmbeddingProvider
15
- } from "./index-9jvktm7k.js";
15
+ } from "./index-657xh9w4.js";
16
16
  import {
17
17
  setStoragePrivatePermissionEnforcement
18
18
  } from "./index-81nthk8j.js";
@@ -1,109 +1,21 @@
1
1
  import {
2
- subagentTemperature,
3
- promptFingerprint,
4
- readHostSystemPrompt
5
- } from "./index-y29y2j2w.js";
2
+ HISTORIAN_TEMPERATURE_ENV2,
3
+ HISTORIAN_MAX_OUTPUT_TOKENS_ENV2,
4
+ SUBAGENT_OUTPUT_CEILING_ENV2,
5
+ calibrateHistorianProviderPayload2,
6
+ ceilProviderOutputTokens2,
7
+ withoutProviderTemperature2,
8
+ historianCalibrationExtension
9
+ } from "./index-ajfpyk0x.js";
6
10
  import"./index-6x556c2q.js";
7
- import"./index-0h2mkab2.js";
8
11
  import"./index-7bqrfyny.js";
9
-
10
- // src/historian-calibration-extension.ts
11
- import { readFileSync } from "node:fs";
12
- var HISTORIAN_TEMPERATURE_ENV = "MAGIC_CONTEXT_HISTORIAN_TEMPERATURE";
13
- var HISTORIAN_MAX_OUTPUT_TOKENS_ENV = "MAGIC_CONTEXT_HISTORIAN_MAX_OUTPUT_TOKENS";
14
- function finiteNumber(value) {
15
- if (value === undefined || value.trim().length === 0)
16
- return;
17
- const parsed = Number(value);
18
- return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;
19
- }
20
- function calibrateHistorianProviderPayload(payload, temperature, maxOutputTokens) {
21
- if (typeof payload !== "object" || payload === null || Array.isArray(payload))
22
- return payload;
23
- if (temperature === undefined && maxOutputTokens === undefined)
24
- return payload;
25
- const calibrated = { ...payload };
26
- const generationConfig = calibrated.generationConfig;
27
- if (typeof generationConfig === "object" && generationConfig !== null && !Array.isArray(generationConfig)) {
28
- calibrated.generationConfig = {
29
- ...generationConfig,
30
- ...temperature !== undefined ? { temperature } : {},
31
- ...maxOutputTokens !== undefined ? { maxOutputTokens } : {}
32
- };
33
- return calibrated;
34
- }
35
- const inferenceConfig = calibrated.inferenceConfig;
36
- if (typeof inferenceConfig === "object" && inferenceConfig !== null && !Array.isArray(inferenceConfig)) {
37
- calibrated.inferenceConfig = {
38
- ...inferenceConfig,
39
- ...temperature !== undefined ? { temperature } : {},
40
- ...maxOutputTokens !== undefined ? { maxTokens: maxOutputTokens } : {}
41
- };
42
- return calibrated;
43
- }
44
- if (temperature !== undefined) {
45
- calibrated.temperature = temperature;
46
- }
47
- if (maxOutputTokens !== undefined) {
48
- if ("max_output_tokens" in calibrated) {
49
- calibrated.max_output_tokens = maxOutputTokens;
50
- } else if ("max_completion_tokens" in calibrated) {
51
- calibrated.max_completion_tokens = maxOutputTokens;
52
- } else if ("max_tokens" in calibrated) {
53
- calibrated.max_tokens = maxOutputTokens;
54
- } else if ("maxTokens" in calibrated) {
55
- calibrated.maxTokens = maxOutputTokens;
56
- }
57
- }
58
- return calibrated;
59
- }
60
- function withoutProviderTemperature(payload) {
61
- if (!payload || typeof payload !== "object" || Array.isArray(payload))
62
- return payload;
63
- const clean = { ...payload };
64
- delete clean.temperature;
65
- for (const key of ["generationConfig", "inferenceConfig"]) {
66
- const nested = clean[key];
67
- if (nested && typeof nested === "object" && !Array.isArray(nested)) {
68
- const options = { ...nested };
69
- delete options.temperature;
70
- clean[key] = options;
71
- }
72
- }
73
- return clean;
74
- }
75
- function historianCalibrationExtension(pi) {
76
- const intendedPath = process.env.MAGIC_CONTEXT_SUBAGENT_PROMPT_FILE;
77
- if (intendedPath) {
78
- const intended = readFileSync(intendedPath, "utf8");
79
- pi.on("context", (_event, ctx) => {
80
- const effective = readHostSystemPrompt(ctx);
81
- if (effective === undefined)
82
- return;
83
- process.stdout.write(`${JSON.stringify({ type: "mc_system_prompt", ...promptFingerprint(effective), containsIntended: effective.includes(intended) })}
84
- `);
85
- });
86
- }
87
- if (process.env.MAGIC_CONTEXT_SUBAGENT_PROVENANCE_ONLY === "1")
88
- return;
89
- const temperature = finiteNumber(process.env[HISTORIAN_TEMPERATURE_ENV]);
90
- const maxOutputTokens = finiteNumber(process.env[HISTORIAN_MAX_OUTPUT_TOKENS_ENV]);
91
- if (temperature === undefined && maxOutputTokens === undefined)
92
- return;
93
- pi.on("before_provider_request", (event, ctx) => {
94
- const model = ctx.model;
95
- const key = `${model?.provider ?? "unknown"}/${model?.id ?? "unknown"}`;
96
- const sampling = subagentTemperature(key, model, temperature, (_message, decision) => {
97
- process.stdout.write(`${JSON.stringify({ type: "mc_temperature", model: key, supported: decision.supported ?? null, source: decision.source, ...decision.entry ? { entry: decision.entry } : {} })}
98
- `);
99
- });
100
- return calibrateHistorianProviderPayload(sampling === undefined ? withoutProviderTemperature(event.payload) : event.payload, sampling, maxOutputTokens);
101
- });
102
- }
12
+ import"./index-0h2mkab2.js";
103
13
  export {
104
- HISTORIAN_MAX_OUTPUT_TOKENS_ENV,
105
- HISTORIAN_TEMPERATURE_ENV,
106
- calibrateHistorianProviderPayload,
14
+ HISTORIAN_MAX_OUTPUT_TOKENS_ENV2 as HISTORIAN_MAX_OUTPUT_TOKENS_ENV,
15
+ HISTORIAN_TEMPERATURE_ENV2 as HISTORIAN_TEMPERATURE_ENV,
16
+ SUBAGENT_OUTPUT_CEILING_ENV2 as SUBAGENT_OUTPUT_CEILING_ENV,
17
+ calibrateHistorianProviderPayload2 as calibrateHistorianProviderPayload,
18
+ ceilProviderOutputTokens2 as ceilProviderOutputTokens,
107
19
  historianCalibrationExtension as default,
108
- withoutProviderTemperature
20
+ withoutProviderTemperature2 as withoutProviderTemperature
109
21
  };
@@ -0,0 +1,58 @@
1
+ // ../plugin/src/features/magic-context/message-fts-session-filter.ts
2
+ var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
3
+ SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
4
+ ) AND `;
5
+ var coverageCaches = new WeakMap;
6
+ var coverageScansOnThisThread = 0;
7
+ function getCoverageCache(db) {
8
+ let cache = coverageCaches.get(db);
9
+ if (!cache) {
10
+ cache = {
11
+ pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
12
+ stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
13
+ missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
14
+ FROM message_history_fts WHERE rowid IN (
15
+ SELECT id FROM message_history_fts_docsize
16
+ EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
17
+ )`)
18
+ };
19
+ coverageCaches.set(db, cache);
20
+ }
21
+ return cache;
22
+ }
23
+ function withMessageFtsSessionFilter(db, sessionId, read) {
24
+ let cacheable = false;
25
+ try {
26
+ const transaction = db;
27
+ cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
28
+ if (!cacheable)
29
+ coverageCaches.delete(db);
30
+ } catch {
31
+ coverageCaches.delete(db);
32
+ }
33
+ return db.transaction(() => {
34
+ let sessionFirst = false;
35
+ try {
36
+ const cache = getCoverageCache(db);
37
+ cache.pin.get();
38
+ const stamp = cache.stamp.get();
39
+ let incomplete = cache.incompleteSessions;
40
+ if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
41
+ coverageScansOnThisThread += 1;
42
+ const rows = cache.missing.all();
43
+ incomplete = new Set(rows.map((row) => row.sessionId));
44
+ if (cacheable) {
45
+ cache.version = stamp.version;
46
+ cache.changes = stamp.changes;
47
+ cache.incompleteSessions = incomplete;
48
+ }
49
+ }
50
+ sessionFirst = !incomplete.has(sessionId);
51
+ } catch {
52
+ coverageCaches.delete(db);
53
+ }
54
+ return read(sessionFirst);
55
+ }).deferred();
56
+ }
57
+
58
+ export { MESSAGE_FTS_SESSION_FILTER_SQL, withMessageFtsSessionFilter };
@@ -20,7 +20,7 @@ import {
20
20
  PER_HARNESS_MODEL_KEYS,
21
21
  ConfigProfilesSchema,
22
22
  MagicContextConfigSchema
23
- } from "./index-1k729e4f.js";
23
+ } from "./index-bxmf4dhr.js";
24
24
  import {
25
25
  MERGED_REASONING_PARTS_PREFIX,
26
26
  decodeMergedReasoningParts,
@@ -53,10 +53,9 @@ import {
53
53
  hasRawMessageProvider2,
54
54
  setRawMessageProvider2,
55
55
  visitRawSessionMessages2,
56
- readRawSessionMessageIdOrdinalsForRange2,
57
56
  readRawSessionMessageById2,
58
57
  readSessionChunk2
59
- } from "./index-75ah9413.js";
58
+ } from "./index-44h64qza.js";
60
59
  import {
61
60
  isRecord,
62
61
  providerVisibleMessage,
@@ -70,7 +69,7 @@ import {
70
69
  getTagNumberByMessageId2,
71
70
  getTagsBySession2,
72
71
  getTagById2
73
- } from "./index-j0n09wtp.js";
72
+ } from "./index-dne4ja7a.js";
74
73
  import {
75
74
  estimateTokens
76
75
  } from "./index-g4jf772p.js";
@@ -91,7 +90,7 @@ import {
91
90
  } from "./index-8976mezv.js";
92
91
  import {
93
92
  noteRawSessionSummaryRowWritten2
94
- } from "./index-he9s4qsj.js";
93
+ } from "./index-qqxqwqhp.js";
95
94
  import {
96
95
  piHarnessKindFromExecutable,
97
96
  isPidAlive
@@ -103,7 +102,7 @@ import {
103
102
  clearLkgRecoveryFence,
104
103
  deleteSessionScopedRows,
105
104
  getLastIndexedOrdinal2
106
- } from "./index-a4pk5yv9.js";
105
+ } from "./index-fhyy4ave.js";
107
106
  import {
108
107
  SubcClient,
109
108
  connectionFileExists,
@@ -111,9 +110,6 @@ import {
111
110
  toSynapseLaneDescriptor,
112
111
  SynapseEmbeddingProvider
113
112
  } from "./index-6dz2ed1v.js";
114
- import {
115
- sameProjectDirectory
116
- } from "./index-djxc8w8c.js";
117
113
  import {
118
114
  invalidateAutoEmbedSession,
119
115
  drainBackgroundBatches,
@@ -126,10 +122,10 @@ import {
126
122
  unregisterProjectEmbedding2,
127
123
  getProjectEmbeddingSnapshot2,
128
124
  embedTextForProject2
129
- } from "./index-nwbhe6qv.js";
125
+ } from "./index-n3r2d2pr.js";
130
126
  import {
131
127
  getErrorMessage
132
- } from "./index-ccsscaap.js";
128
+ } from "./index-v8d4vgam.js";
133
129
  import {
134
130
  V2_MEMORY_CATEGORIES,
135
131
  CATEGORY_PRIORITY,
@@ -143,13 +139,13 @@ import {
143
139
  expandWorkspaceIdentitySetWithAliases,
144
140
  resolveStoredPathWorkspaceIdentity,
145
141
  storedPathBelongsToWorkspace
146
- } from "./index-bet4sd3e.js";
142
+ } from "./index-tympym62.js";
147
143
  import {
148
144
  directoryHasGitMetadata,
149
145
  resolveProjectIdentityForSession,
150
146
  normalizeStoredProjectPath,
151
147
  storedPathBelongsToIdentity
152
- } from "./index-6ex901g3.js";
148
+ } from "./index-y5c73caa.js";
153
149
  import {
154
150
  getNoteByIdInScope,
155
151
  getNotes,
@@ -160,13 +156,12 @@ import {
160
156
  updateNote,
161
157
  dismissNotes,
162
158
  dismissNote,
163
- withMessageFtsSessionFilter,
164
159
  createUnifiedSearchDiagnostics2,
165
160
  parseIdShapedQuery2,
166
161
  resolveMemoriesByIdsForSearch2,
167
162
  unifiedSearch2,
168
163
  formatSearchResults2
169
- } from "./index-0awvkeb5.js";
164
+ } from "./index-xmzhrht0.js";
170
165
  import {
171
166
  computeCueContentHash,
172
167
  getMuralCueState,
@@ -192,9 +187,15 @@ import {
192
187
  invalidateMarkerCandidateBasis2,
193
188
  readMarkerCandidateBasis2
194
189
  } from "./index-46q4e104.js";
190
+ import {
191
+ renderSearchArchive2
192
+ } from "./index-ja1c33qa.js";
195
193
  import {
196
194
  computeNormalizedHash
197
195
  } from "./index-9x1f96r8.js";
196
+ import {
197
+ sameProjectDirectory
198
+ } from "./index-wrr9rp9a.js";
198
199
  import {
199
200
  logSlowWriteTransaction
200
201
  } from "./index-d4dt19md.js";
@@ -12648,56 +12649,6 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
12648
12649
  return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
12649
12650
  }
12650
12651
 
12651
- // ../plugin/src/tools/ctx-expand/search-archive.ts
12652
- function renderSearchArchive(db, sessionId, start, end, tokenBudget, archiveOnly = false) {
12653
- return withMessageFtsSessionFilter(db, sessionId, (sessionFirst) => {
12654
- let rawIds;
12655
- const rows = db.prepare(sessionFirst ? `SELECT f.message_ordinal AS ordinal, f.message_id AS id, f.role, f.content
12656
- FROM message_fts_rowid_map AS m
12657
- JOIN message_history_fts AS f ON f.rowid = m.fts_rowid
12658
- WHERE m.session_id = ?1 AND m.message_ordinal BETWEEN ?2 AND ?3
12659
- AND f.session_id = ?1 AND f.message_ordinal BETWEEN ?2 AND ?3
12660
- ORDER BY m.message_ordinal` : `SELECT message_ordinal AS ordinal, message_id AS id, role, content
12661
- FROM message_history_fts
12662
- WHERE session_id = ?1 AND message_ordinal BETWEEN ?2 AND ?3
12663
- ORDER BY CAST(message_ordinal AS INTEGER)`);
12664
- const blocks = [];
12665
- let tokens = 0;
12666
- let lastOrdinal = start - 1;
12667
- let truncated = false;
12668
- for (const row of rows.iterate(sessionId, start, end)) {
12669
- if (!row.content)
12670
- continue;
12671
- if (!archiveOnly) {
12672
- rawIds ??= readRawSessionMessageIdOrdinalsForRange2(sessionId, start, end);
12673
- if (rawIds.get(row.id) === row.ordinal)
12674
- continue;
12675
- }
12676
- const block = `[${row.ordinal}] ${row.role === "user" ? "U" : "A"}: ${row.content}`;
12677
- const cost = estimateTokens(block);
12678
- if (blocks.length > 0 && tokens + cost > tokenBudget) {
12679
- truncated = true;
12680
- break;
12681
- }
12682
- blocks.push(block);
12683
- tokens += cost;
12684
- lastOrdinal = row.ordinal;
12685
- }
12686
- if (blocks.length === 0)
12687
- return null;
12688
- const text = [
12689
- "From the search archive: indexed text only; no surrounding messages or tool output.",
12690
- "",
12691
- ...blocks
12692
- ];
12693
- if (truncated) {
12694
- text.push("", `Truncated at message ${lastOrdinal} (budget: ~${tokenBudget} tokens). Call ctx_expand(start=${lastOrdinal + 1}, end=${end}) for more archived text.`);
12695
- }
12696
- return text.join(`
12697
- `);
12698
- });
12699
- }
12700
-
12701
12652
  // ../plugin/src/tools/unwrap-imitated-reduced-args.ts
12702
12653
  var MAX_DECODED_STRING_LENGTH = 1024 * 1024;
12703
12654
  var MAX_DECODED_ARRAY_ITEMS = 100;
@@ -13142,7 +13093,7 @@ function createCtxExpandTool(deps) {
13142
13093
  }
13143
13094
  const alignment = resolvePiOrdinalAlignmentForContext(deps.db, sessionId, ctx);
13144
13095
  if (isPiOrdinalAlignmentUnanchored(alignment)) {
13145
- const archived = renderSearchArchive(deps.db, sessionId, mode.kind === "message" ? mode.message : mode.start, mode.kind === "message" ? mode.message : mode.end, CTX_EXPAND_TOKEN_BUDGET, true);
13096
+ const archived = renderSearchArchive2(deps.db, sessionId, mode.kind === "message" ? mode.message : mode.start, mode.kind === "message" ? mode.message : mode.end, CTX_EXPAND_TOKEN_BUDGET, true);
13146
13097
  if (archived)
13147
13098
  return ok(archived);
13148
13099
  return err("This session's history numbering can't be verified right now, so message ordinals can't be expanded. Tags (ctx_expand tag=N) still work.");
@@ -13150,7 +13101,7 @@ function createCtxExpandTool(deps) {
13150
13101
  const lostThrough = alignment.offset;
13151
13102
  const firstAvailable = lostThrough + 1;
13152
13103
  if (mode.kind === "message") {
13153
- const archived = renderSearchArchive(deps.db, sessionId, mode.message, mode.message, CTX_EXPAND_TOKEN_BUDGET);
13104
+ const archived = renderSearchArchive2(deps.db, sessionId, mode.message, mode.message, CTX_EXPAND_TOKEN_BUDGET);
13154
13105
  if (archived)
13155
13106
  return ok(archived);
13156
13107
  if (mode.message <= lostThrough) {
@@ -13165,7 +13116,7 @@ function createCtxExpandTool(deps) {
13165
13116
  return ok(`Range ${requestedStart}-${end} is entirely within the live tail (after the last compacted message ${lastCompartmentEnd}); those messages are already visible in context.`);
13166
13117
  }
13167
13118
  const effectiveEnd = lastCompartmentEnd >= 0 ? Math.min(end, lastCompartmentEnd) : end;
13168
- const archived = renderSearchArchive(deps.db, sessionId, requestedStart, effectiveEnd, CTX_EXPAND_TOKEN_BUDGET);
13119
+ const archived = renderSearchArchive2(deps.db, sessionId, requestedStart, effectiveEnd, CTX_EXPAND_TOKEN_BUDGET);
13169
13120
  if (archived)
13170
13121
  return ok(archived);
13171
13122
  if (effectiveEnd <= lostThrough) {
@@ -15554,4 +15505,4 @@ function registerMagicContextTools(pi, opts) {
15554
15505
  }
15555
15506
  }
15556
15507
 
15557
- export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
15508
+ export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, OPENCODE_OUTPUT_CAP, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
@@ -4,7 +4,7 @@ import {
4
4
  renderToolTemplate,
5
5
  resolveModelConfigValue,
6
6
  deriveDefaultProtectedTokens
7
- } from "./index-1k729e4f.js";
7
+ } from "./index-bxmf4dhr.js";
8
8
  import {
9
9
  getHarness2,
10
10
  harnessOwnsOpenCodeStore2
@@ -23,7 +23,7 @@ import {
23
23
  TAG_SELECT_COLUMNS2,
24
24
  getCandidateToolOwners2,
25
25
  pickNearestPriorOwner2
26
- } from "./index-j0n09wtp.js";
26
+ } from "./index-dne4ja7a.js";
27
27
  import {
28
28
  OMO_INTERNAL_INITIATOR_MARKER,
29
29
  isSystemDirective,
@@ -71,7 +71,7 @@ import {
71
71
  hasRawSessionMessageByIdFromDb2,
72
72
  readRawSeedTailFromDb2,
73
73
  readRawSessionBoundaryEndpointsFromDb2
74
- } from "./index-he9s4qsj.js";
74
+ } from "./index-qqxqwqhp.js";
75
75
  import {
76
76
  logSlowWriteTransaction
77
77
  } from "./index-d4dt19md.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./index-1k729e4f.js";
3
+ } from "./index-bxmf4dhr.js";
4
4
  import {
5
5
  getSynapseLaneIdentity
6
6
  } from "./index-6dz2ed1v.js";
@@ -12,8 +12,8 @@ import {
12
12
  isSynapseEmbeddingTruncated
13
13
  } from "./index-6dz2ed1v.js";
14
14
  import {
15
- messageFtsOrdinalRangeIsMapped
16
- } from "./index-djxc8w8c.js";
15
+ messageFtsOrdinalRangeIsMapped2
16
+ } from "./index-s1xn8qfw.js";
17
17
 
18
18
  // ../plugin/src/features/magic-context/compartment-chunk-embedding.ts
19
19
  import { createHash } from "node:crypto";
@@ -514,7 +514,7 @@ function toFloat32Array(blob) {
514
514
  function buildCanonicalChunkTextFromFts(db, sessionId, startOrdinal, endOrdinal) {
515
515
  if (endOrdinal < startOrdinal)
516
516
  return "";
517
- if (!messageFtsOrdinalRangeIsMapped(db, sessionId, startOrdinal, endOrdinal))
517
+ if (!messageFtsOrdinalRangeIsMapped2(db, sessionId, startOrdinal, endOrdinal))
518
518
  return null;
519
519
  const rows = getLoadFtsRowsStatement(db).all(sessionId, startOrdinal, endOrdinal).map((row) => row);
520
520
  const lines = [];