@cortexkit/pi-magic-context 0.22.3 → 0.22.4

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.
@@ -46,167 +46,6 @@ var __export = (target, all) => {
46
46
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
47
47
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
48
48
 
49
- // ../plugin/src/shared/harness.ts
50
- function setHarness(value) {
51
- if (harnessLocked && currentHarness !== value) {
52
- throw new Error(`Magic Context: harness already locked to "${currentHarness}"; cannot change to "${value}"`);
53
- }
54
- currentHarness = value;
55
- harnessLocked = true;
56
- }
57
- function getHarness() {
58
- return currentHarness;
59
- }
60
- var currentHarness = "opencode", harnessLocked = false;
61
-
62
- // ../plugin/src/shared/data-path.ts
63
- import * as os from "node:os";
64
- import * as path from "node:path";
65
- function getDataDir() {
66
- return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
67
- }
68
- function getMagicContextTempDir(harness = getHarness()) {
69
- return path.join(os.tmpdir(), harness, "magic-context");
70
- }
71
- function getMagicContextLogPath(harness = getHarness()) {
72
- return path.join(getMagicContextTempDir(harness), "magic-context.log");
73
- }
74
- function getProjectMagicContextDir(directory) {
75
- return path.join(directory, ".opencode", "magic-context");
76
- }
77
- function getProjectMagicContextHistorianDir(directory) {
78
- return path.join(getProjectMagicContextDir(directory), "historian");
79
- }
80
- function getOpenCodeStorageDir() {
81
- return path.join(getDataDir(), "opencode", "storage");
82
- }
83
- function getMagicContextStorageDir() {
84
- return path.join(getDataDir(), "cortexkit", "magic-context");
85
- }
86
- function getLegacyOpenCodeMagicContextStorageDir() {
87
- return path.join(getOpenCodeStorageDir(), "plugin", "magic-context");
88
- }
89
- var init_data_path = () => {};
90
-
91
- // ../plugin/src/shared/logger.ts
92
- import * as fs from "node:fs";
93
- import * as path2 from "node:path";
94
- function ensureDir(filePath) {
95
- const dir = path2.dirname(filePath);
96
- if (dir === lastEnsuredDir)
97
- return;
98
- try {
99
- fs.mkdirSync(dir, { recursive: true });
100
- lastEnsuredDir = dir;
101
- } catch {}
102
- }
103
- function flush() {
104
- if (flushTimer) {
105
- clearTimeout(flushTimer);
106
- flushTimer = null;
107
- }
108
- if (buffer.length === 0)
109
- return;
110
- const data = buffer.join("");
111
- buffer = [];
112
- try {
113
- const logFile = getMagicContextLogPath();
114
- ensureDir(logFile);
115
- fs.appendFileSync(logFile, data);
116
- } catch {}
117
- }
118
- function scheduleFlush() {
119
- if (flushTimer)
120
- return;
121
- flushTimer = setTimeout(() => {
122
- flushTimer = null;
123
- flush();
124
- }, FLUSH_INTERVAL_MS);
125
- }
126
- function log(message, data) {
127
- if (isTestEnv)
128
- return;
129
- try {
130
- const timestamp = new Date().toISOString();
131
- const serialized = data === undefined ? "" : data instanceof Error ? ` ${data.message}${data.stack ? `
132
- ${data.stack}` : ""}` : ` ${JSON.stringify(data)}`;
133
- buffer.push(`[${timestamp}] ${message}${serialized}
134
- `);
135
- if (buffer.length >= BUFFER_SIZE_LIMIT) {
136
- flush();
137
- } else {
138
- scheduleFlush();
139
- }
140
- } catch {}
141
- }
142
- function sessionLog(sessionId, message, data) {
143
- log(`[magic-context][${sessionId}] ${message}`, data);
144
- }
145
- var isTestEnv = false, buffer, flushTimer = null, FLUSH_INTERVAL_MS = 500, BUFFER_SIZE_LIMIT = 50, lastEnsuredDir = null;
146
- var init_logger = __esm(() => {
147
- init_data_path();
148
- buffer = [];
149
- if (!isTestEnv) {
150
- process.on("exit", flush);
151
- }
152
- });
153
-
154
- // ../plugin/src/shared/sqlite.ts
155
- function buildNodeSqliteDatabaseClass(DatabaseSync) {
156
- const SAVEPOINT = "mc_tx_sp";
157
-
158
- class NodeSqliteDatabase extends DatabaseSync {
159
- constructor(filename, options) {
160
- const translated = { ...options };
161
- if (options && "readonly" in options) {
162
- translated.readOnly = options.readonly;
163
- delete translated.readonly;
164
- }
165
- super(typeof filename === "string" ? filename : ":memory:", translated);
166
- }
167
- transaction(fn) {
168
- const self = this;
169
- const wrapped = function(...args) {
170
- const nested = self.isTransaction === true;
171
- self.exec(nested ? `SAVEPOINT ${SAVEPOINT}` : "BEGIN");
172
- try {
173
- const result = fn.apply(this, args);
174
- self.exec(nested ? `RELEASE ${SAVEPOINT}` : "COMMIT");
175
- return result;
176
- } catch (error) {
177
- if (nested) {
178
- self.exec(`ROLLBACK TO ${SAVEPOINT}`);
179
- self.exec(`RELEASE ${SAVEPOINT}`);
180
- } else {
181
- self.exec("ROLLBACK");
182
- }
183
- throw error;
184
- }
185
- };
186
- return wrapped;
187
- }
188
- }
189
- return NodeSqliteDatabase;
190
- }
191
- var isBun, bunSpec, nodeSpec, sqliteModule, DatabaseImpl, Database;
192
- var init_sqlite = __esm(async () => {
193
- isBun = typeof process !== "undefined" && typeof process.versions?.bun === "string";
194
- bunSpec = "bun:" + "sqlite";
195
- nodeSpec = "node:" + "sqlite";
196
- sqliteModule = isBun ? await import(bunSpec) : await import(nodeSpec);
197
- DatabaseImpl = isBun ? sqliteModule.Database : buildNodeSqliteDatabaseClass(sqliteModule.DatabaseSync);
198
- Database = DatabaseImpl;
199
- });
200
-
201
- // ../plugin/src/shared/sqlite-helpers.ts
202
- function closeQuietly(db) {
203
- if (!db)
204
- return;
205
- try {
206
- db.close();
207
- } catch {}
208
- }
209
-
210
49
  // ../../node_modules/.bun/esprima@4.0.1/node_modules/esprima/dist/esprima.js
211
50
  var require_esprima = __commonJS((exports, module) => {
212
51
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -7964,57 +7803,53 @@ var require_src2 = __commonJS((exports, module) => {
7964
7803
  };
7965
7804
  });
7966
7805
 
7967
- // ../plugin/src/hooks/magic-context/read-session-db.ts
7968
- import { existsSync as existsSync6 } from "node:fs";
7969
- import { join as join7 } from "node:path";
7970
- function getOpenCodeDbPath() {
7971
- return join7(getDataDir(), "opencode", "opencode.db");
7806
+ // ../plugin/src/features/magic-context/storage-db.ts
7807
+ import { copyFileSync, cpSync, existsSync as existsSync3, mkdirSync as mkdirSync2 } from "node:fs";
7808
+ import { dirname as dirname2, join as join4 } from "node:path";
7809
+
7810
+ // ../plugin/src/shared/data-path.ts
7811
+ import * as os from "node:os";
7812
+ import * as path from "node:path";
7813
+
7814
+ // ../plugin/src/shared/harness.ts
7815
+ var currentHarness = "opencode";
7816
+ var harnessLocked = false;
7817
+ function setHarness(value) {
7818
+ if (harnessLocked && currentHarness !== value) {
7819
+ throw new Error(`Magic Context: harness already locked to "${currentHarness}"; cannot change to "${value}"`);
7820
+ }
7821
+ currentHarness = value;
7822
+ harnessLocked = true;
7972
7823
  }
7973
- function openCodeDbExists() {
7974
- return existsSync6(getOpenCodeDbPath());
7824
+ function getHarness() {
7825
+ return currentHarness;
7975
7826
  }
7976
- function closeCachedReadOnlyDb() {
7977
- if (!cachedReadOnlyDb) {
7978
- return;
7979
- }
7980
- try {
7981
- closeQuietly(cachedReadOnlyDb.db);
7982
- } catch (error51) {
7983
- log("[magic-context] failed to close cached OpenCode read-only DB:", error51);
7984
- } finally {
7985
- cachedReadOnlyDb = null;
7986
- }
7827
+
7828
+ // ../plugin/src/shared/data-path.ts
7829
+ function getDataDir() {
7830
+ return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
7987
7831
  }
7988
- function getReadOnlySessionDb() {
7989
- const dbPath = getOpenCodeDbPath();
7990
- if (cachedReadOnlyDb?.path === dbPath) {
7991
- return cachedReadOnlyDb.db;
7992
- }
7993
- closeCachedReadOnlyDb();
7994
- const db = new Database(dbPath, { readonly: true });
7995
- cachedReadOnlyDb = { path: dbPath, db };
7996
- return db;
7832
+ function getMagicContextTempDir(harness = getHarness()) {
7833
+ return path.join(os.tmpdir(), harness, "magic-context");
7997
7834
  }
7998
- function withReadOnlySessionDb(fn) {
7999
- return fn(getReadOnlySessionDb());
7835
+ function getMagicContextLogPath(harness = getHarness()) {
7836
+ return path.join(getMagicContextTempDir(harness), "magic-context.log");
8000
7837
  }
8001
- function getRawSessionMessageCountFromDb(db, sessionId) {
8002
- const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
8003
- AND NOT (COALESCE(json_extract(data, '$.summary'), 0) = 1
8004
- AND COALESCE(json_extract(data, '$.finish'), '') = 'stop')`).get(sessionId);
8005
- return typeof row?.count === "number" ? row.count : 0;
7838
+ function getProjectMagicContextDir(directory) {
7839
+ return path.join(directory, ".opencode", "magic-context");
7840
+ }
7841
+ function getProjectMagicContextHistorianDir(directory) {
7842
+ return path.join(getProjectMagicContextDir(directory), "historian");
7843
+ }
7844
+ function getOpenCodeStorageDir() {
7845
+ return path.join(getDataDir(), "opencode", "storage");
7846
+ }
7847
+ function getMagicContextStorageDir() {
7848
+ return path.join(getDataDir(), "cortexkit", "magic-context");
7849
+ }
7850
+ function getLegacyOpenCodeMagicContextStorageDir() {
7851
+ return path.join(getOpenCodeStorageDir(), "plugin", "magic-context");
8006
7852
  }
8007
- var cachedReadOnlyDb = null;
8008
- var init_read_session_db = __esm(async () => {
8009
- init_data_path();
8010
- init_logger();
8011
- await init_sqlite();
8012
- });
8013
-
8014
- // ../plugin/src/features/magic-context/storage-db.ts
8015
- init_data_path();
8016
- import { copyFileSync, cpSync, existsSync as existsSync3, mkdirSync as mkdirSync2 } from "node:fs";
8017
- import { dirname as dirname2, join as join4 } from "node:path";
8018
7853
 
8019
7854
  // ../plugin/src/shared/error-message.ts
8020
7855
  function getErrorMessage(error) {
@@ -8092,12 +7927,124 @@ function safeString(value) {
8092
7927
  }
8093
7928
  }
8094
7929
 
8095
- // ../plugin/src/features/magic-context/storage-db.ts
8096
- init_logger();
8097
- await init_sqlite();
7930
+ // ../plugin/src/shared/logger.ts
7931
+ import * as fs from "node:fs";
7932
+ import * as path2 from "node:path";
7933
+ var isTestEnv = false;
7934
+ var buffer = [];
7935
+ var flushTimer = null;
7936
+ var FLUSH_INTERVAL_MS = 500;
7937
+ var BUFFER_SIZE_LIMIT = 50;
7938
+ var lastEnsuredDir = null;
7939
+ function ensureDir(filePath) {
7940
+ const dir = path2.dirname(filePath);
7941
+ if (dir === lastEnsuredDir)
7942
+ return;
7943
+ try {
7944
+ fs.mkdirSync(dir, { recursive: true });
7945
+ lastEnsuredDir = dir;
7946
+ } catch {}
7947
+ }
7948
+ function flush() {
7949
+ if (flushTimer) {
7950
+ clearTimeout(flushTimer);
7951
+ flushTimer = null;
7952
+ }
7953
+ if (buffer.length === 0)
7954
+ return;
7955
+ const data = buffer.join("");
7956
+ buffer = [];
7957
+ try {
7958
+ const logFile = getMagicContextLogPath();
7959
+ ensureDir(logFile);
7960
+ fs.appendFileSync(logFile, data);
7961
+ } catch {}
7962
+ }
7963
+ function scheduleFlush() {
7964
+ if (flushTimer)
7965
+ return;
7966
+ flushTimer = setTimeout(() => {
7967
+ flushTimer = null;
7968
+ flush();
7969
+ }, FLUSH_INTERVAL_MS);
7970
+ }
7971
+ function log(message, data) {
7972
+ if (isTestEnv)
7973
+ return;
7974
+ try {
7975
+ const timestamp = new Date().toISOString();
7976
+ const serialized = data === undefined ? "" : data instanceof Error ? ` ${data.message}${data.stack ? `
7977
+ ${data.stack}` : ""}` : ` ${JSON.stringify(data)}`;
7978
+ buffer.push(`[${timestamp}] ${message}${serialized}
7979
+ `);
7980
+ if (buffer.length >= BUFFER_SIZE_LIMIT) {
7981
+ flush();
7982
+ } else {
7983
+ scheduleFlush();
7984
+ }
7985
+ } catch {}
7986
+ }
7987
+ function sessionLog(sessionId, message, data) {
7988
+ log(`[magic-context][${sessionId}] ${message}`, data);
7989
+ }
7990
+ if (!isTestEnv) {
7991
+ process.on("exit", flush);
7992
+ }
7993
+
7994
+ // ../plugin/src/shared/sqlite.ts
7995
+ var isBun = typeof process !== "undefined" && typeof process.versions?.bun === "string";
7996
+ var bunSpec = "bun:" + "sqlite";
7997
+ var nodeSpec = "node:" + "sqlite";
7998
+ var sqliteModule = isBun ? await import(bunSpec) : await import(nodeSpec);
7999
+ var DatabaseImpl = isBun ? sqliteModule.Database : buildNodeSqliteDatabaseClass(sqliteModule.DatabaseSync);
8000
+ function buildNodeSqliteDatabaseClass(DatabaseSync) {
8001
+ const SAVEPOINT = "mc_tx_sp";
8002
+
8003
+ class NodeSqliteDatabase extends DatabaseSync {
8004
+ constructor(filename, options) {
8005
+ const translated = { ...options };
8006
+ if (options && "readonly" in options) {
8007
+ translated.readOnly = options.readonly;
8008
+ delete translated.readonly;
8009
+ }
8010
+ super(typeof filename === "string" ? filename : ":memory:", translated);
8011
+ }
8012
+ transaction(fn) {
8013
+ const self = this;
8014
+ const wrapped = function(...args) {
8015
+ const nested = self.isTransaction === true;
8016
+ self.exec(nested ? `SAVEPOINT ${SAVEPOINT}` : "BEGIN");
8017
+ try {
8018
+ const result = fn.apply(this, args);
8019
+ self.exec(nested ? `RELEASE ${SAVEPOINT}` : "COMMIT");
8020
+ return result;
8021
+ } catch (error) {
8022
+ if (nested) {
8023
+ self.exec(`ROLLBACK TO ${SAVEPOINT}`);
8024
+ self.exec(`RELEASE ${SAVEPOINT}`);
8025
+ } else {
8026
+ self.exec("ROLLBACK");
8027
+ }
8028
+ throw error;
8029
+ }
8030
+ };
8031
+ return wrapped;
8032
+ }
8033
+ }
8034
+ return NodeSqliteDatabase;
8035
+ }
8036
+ var Database = DatabaseImpl;
8037
+
8038
+ // ../plugin/src/shared/sqlite-helpers.ts
8039
+ function closeQuietly(db) {
8040
+ if (!db)
8041
+ return;
8042
+ try {
8043
+ db.close();
8044
+ } catch {}
8045
+ }
8098
8046
 
8099
8047
  // ../plugin/src/features/magic-context/key-files/project-key-files.ts
8100
- init_logger();
8101
8048
  import { createHash } from "node:crypto";
8102
8049
  import { existsSync, readFileSync, realpathSync } from "node:fs";
8103
8050
  import { join as join2, resolve, sep } from "node:path";
@@ -8214,7 +8161,6 @@ function isRelativeProjectFile(projectPath, relativePath) {
8214
8161
  }
8215
8162
 
8216
8163
  // ../plugin/src/features/magic-context/migrations.ts
8217
- init_logger();
8218
8164
  function tableExists(db, name) {
8219
8165
  return Boolean(db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = ?").get(name));
8220
8166
  }
@@ -8948,6 +8894,28 @@ var MIGRATIONS = [
8948
8894
  db.exec("ALTER TABLE notes ADD COLUMN anchor_ordinal INTEGER");
8949
8895
  }
8950
8896
  }
8897
+ },
8898
+ {
8899
+ version: 30,
8900
+ description: "HARD-bust m[0] markers: cached system/tool-set/model identity",
8901
+ up: (db) => {
8902
+ const hasSessionMeta = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_meta' LIMIT 1").get();
8903
+ if (!hasSessionMeta)
8904
+ return;
8905
+ ensureColumn(db, "session_meta", "cached_m0_system_hash", "TEXT");
8906
+ ensureColumn(db, "session_meta", "cached_m0_tool_set_hash", "TEXT");
8907
+ ensureColumn(db, "session_meta", "cached_m0_model_key", "TEXT");
8908
+ const columns = new Set(db.prepare("PRAGMA table_info(session_meta)").all().map((column) => column.name));
8909
+ if (columns.has("cached_m0_bytes")) {
8910
+ db.prepare(`UPDATE session_meta SET
8911
+ cached_m0_bytes = NULL,
8912
+ cached_m1_bytes = NULL,
8913
+ cached_m0_materialized_at = NULL,
8914
+ cached_m0_system_hash = NULL,
8915
+ cached_m0_tool_set_hash = NULL,
8916
+ cached_m0_model_key = NULL`).run();
8917
+ }
8918
+ }
8951
8919
  }
8952
8920
  ];
8953
8921
  var LATEST_MIGRATION_VERSION = MIGRATIONS.reduce((max, m) => Math.max(max, m.version), 0);
@@ -141663,8 +141631,6 @@ function loadToolDefinitionMeasurements(db) {
141663
141631
  }
141664
141632
 
141665
141633
  // ../plugin/src/features/magic-context/tool-owner-backfill.ts
141666
- init_data_path();
141667
- init_logger();
141668
141634
  import { existsSync as existsSync2 } from "node:fs";
141669
141635
  import { join as join3 } from "node:path";
141670
141636
  var LEASE_DURATION_MS = 5 * 60 * 1000;
@@ -141912,7 +141878,7 @@ var databases = new Map;
141912
141878
  var persistenceByDatabase = new WeakMap;
141913
141879
  var persistenceErrorByDatabase = new WeakMap;
141914
141880
  var lastSchemaFenceRejection = null;
141915
- var LATEST_SUPPORTED_VERSION = 29;
141881
+ var LATEST_SUPPORTED_VERSION = 30;
141916
141882
  function resolveDatabasePath(dbPathOverride) {
141917
141883
  if (dbPathOverride) {
141918
141884
  return { dbDir: dirname2(dbPathOverride), dbPath: dbPathOverride };
@@ -142377,6 +142343,9 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
142377
142343
  cached_m0_materialized_at INTEGER,
142378
142344
  cached_m0_session_facts_version INTEGER,
142379
142345
  cached_m0_upgrade_state TEXT,
142346
+ cached_m0_system_hash TEXT,
142347
+ cached_m0_tool_set_hash TEXT,
142348
+ cached_m0_model_key TEXT,
142380
142349
  cached_m0_last_baseline_end_message_id TEXT,
142381
142350
  upgrade_reminded_at INTEGER,
142382
142351
  pi_stable_id_scheme INTEGER
@@ -142568,6 +142537,9 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
142568
142537
  ensureColumn(db, "session_meta", "cached_m0_materialized_at", "INTEGER");
142569
142538
  ensureColumn(db, "session_meta", "cached_m0_session_facts_version", "INTEGER");
142570
142539
  ensureColumn(db, "session_meta", "cached_m0_upgrade_state", "TEXT");
142540
+ ensureColumn(db, "session_meta", "cached_m0_system_hash", "TEXT");
142541
+ ensureColumn(db, "session_meta", "cached_m0_tool_set_hash", "TEXT");
142542
+ ensureColumn(db, "session_meta", "cached_m0_model_key", "TEXT");
142571
142543
  ensureColumn(db, "session_meta", "cached_m0_last_baseline_end_message_id", "TEXT");
142572
142544
  ensureColumn(db, "session_meta", "upgrade_reminded_at", "INTEGER");
142573
142545
  db.exec(`
@@ -142763,9 +142735,6 @@ function openDatabase(dbPathOrOptions) {
142763
142735
  }
142764
142736
  }
142765
142737
 
142766
- // src/subagent-entry.ts
142767
- init_logger();
142768
-
142769
142738
  // src/config/index.ts
142770
142739
  import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
142771
142740
  import { homedir as homedir3 } from "node:os";
@@ -157347,6 +157316,7 @@ var MagicContextConfigSchema = exports_external.object({
157347
157316
  model: DEFAULT_LOCAL_EMBEDDING_MODEL
157348
157317
  }).describe("Embedding provider configuration"),
157349
157318
  temporal_awareness: exports_external.boolean().default(true).describe('Inject wall-clock gap markers (<!-- +Xm -->) between user messages where > 5 min elapsed since the previous message, and add start/end date attributes on compartments. Gives the agent a sense of session pacing and "how long ago" across multi-day sessions. Graduated from experimental.temporal_awareness; default: true (set false to opt out).'),
157319
+ keep_subagents: exports_external.boolean().default(false).describe("Debug: keep the child sessions Magic Context spawns for its own subagents (historian, dreamer, sidekick, memory-migration) instead of deleting them on success. Useful for short-term inspection/data collection — their full transcript (prompt, tool calls, token usage, output) stays in the host session store. Kept sessions accumulate until manually cleared; leave false for normal use. Requires a restart to take effect."),
157350
157320
  caveman_text_compression: exports_external.object({
157351
157321
  enabled: exports_external.boolean().default(false).describe("Apply deterministic caveman-style text compression to old conversation text. Only active when ctx_reduce_enabled=false. Compresses user/assistant text in oldest-first tiers: ultra (oldest 20%), full, lite, untouched (newest 40%)."),
157352
157322
  min_chars: exports_external.number().min(100).max(1e4).default(500).describe("Text parts shorter than this (characters) stay untouched. Min 100, max 10000. Default: 500.")
@@ -157756,9 +157726,6 @@ function loadPiConfigDetailed(opts = {}) {
157756
157726
  };
157757
157727
  }
157758
157728
 
157759
- // ../plugin/src/features/magic-context/memory/embedding.ts
157760
- init_logger();
157761
-
157762
157729
  // ../plugin/src/features/magic-context/memory/cosine-similarity.ts
157763
157730
  function cosineSimilarity(a, b) {
157764
157731
  if (a.length !== b.length) {
@@ -157814,8 +157781,6 @@ import { mkdirSync as mkdirSync3 } from "node:fs";
157814
157781
  import { open, stat, unlink, writeFile } from "node:fs/promises";
157815
157782
  import { dirname as dirname4, join as join6 } from "node:path";
157816
157783
  import { pathToFileURL } from "node:url";
157817
- init_data_path();
157818
- init_logger();
157819
157784
  var LOCK_POLL_MS = 150;
157820
157785
  var STALE_LOCK_MS = 3 * 60000;
157821
157786
  var MAX_LOCK_WAIT_MS = 5 * 60000;
@@ -158151,7 +158116,6 @@ class LocalEmbeddingProvider {
158151
158116
  }
158152
158117
 
158153
158118
  // ../plugin/src/features/magic-context/memory/embedding-openai.ts
158154
- init_logger();
158155
158119
  function normalizeEndpoint2(endpoint) {
158156
158120
  return endpoint?.trim().replace(/\/+$/, "") ?? "";
158157
158121
  }
@@ -158442,7 +158406,6 @@ function getDistinctStoredModelIds(db, projectPath) {
158442
158406
 
158443
158407
  // ../plugin/src/features/magic-context/project-embedding-registry.ts
158444
158408
  import { createHash as createHash3, randomUUID } from "node:crypto";
158445
- init_logger();
158446
158409
 
158447
158410
  // ../plugin/src/features/magic-context/git-commits/storage-git-commit-embeddings.ts
158448
158411
  var saveStatements = new WeakMap;
@@ -159180,7 +159143,6 @@ function hasGitDir(canonical) {
159180
159143
 
159181
159144
  // ../plugin/src/plugin/embedding-bootstrap-helpers.ts
159182
159145
  import { createHash as createHash5 } from "node:crypto";
159183
- init_logger();
159184
159146
  var EMBEDDING_AFFECTING_KEYS = new Set([
159185
159147
  "embedding.api_key",
159186
159148
  "embedding.endpoint",
@@ -159268,6 +159230,7 @@ async function ensureProjectRegisteredFromPiDirectory(directory, db) {
159268
159230
  };
159269
159231
  registerProjectEmbeddingAndMaybeWipe(db, projectIdentity, detailed.config.embedding, features, directory);
159270
159232
  }
159233
+
159271
159234
  // ../plugin/src/features/magic-context/compartment-lease.ts
159272
159235
  var COMPARTMENT_LEASE_TTL_MS = 5 * 60 * 1000;
159273
159236
  var COMPARTMENT_LEASE_RENEWAL_MS = 60 * 1000;
@@ -159361,6 +159324,9 @@ var SESSION_META_SELECT_COLUMNS = [
159361
159324
  "cached_m0_materialized_at",
159362
159325
  "cached_m0_session_facts_version",
159363
159326
  "cached_m0_upgrade_state",
159327
+ "cached_m0_system_hash",
159328
+ "cached_m0_tool_set_hash",
159329
+ "cached_m0_model_key",
159364
159330
  "last_observed_model_key",
159365
159331
  "upgrade_reminded_at",
159366
159332
  "pi_stable_id_scheme"
@@ -159397,6 +159363,9 @@ var META_COLUMNS = {
159397
159363
  cachedM0MaterializedAt: "cached_m0_materialized_at",
159398
159364
  cachedM0SessionFactsVersion: "cached_m0_session_facts_version",
159399
159365
  cachedM0UpgradeState: "cached_m0_upgrade_state",
159366
+ cachedM0SystemHash: "cached_m0_system_hash",
159367
+ cachedM0ToolSetHash: "cached_m0_tool_set_hash",
159368
+ cachedM0ModelKey: "cached_m0_model_key",
159400
159369
  lastObservedModelKey: "last_observed_model_key",
159401
159370
  upgradeRemindedAt: "upgrade_reminded_at",
159402
159371
  piStableIdScheme: "pi_stable_id_scheme"
@@ -159439,7 +159408,7 @@ function isSessionMetaRow(row) {
159439
159408
  if (row === null || typeof row !== "object")
159440
159409
  return false;
159441
159410
  const r = row;
159442
- return typeof r.session_id === "string" && typeof r.last_response_time === "number" && isStringOrNull(r.cache_ttl) && typeof r.counter === "number" && typeof r.last_nudge_tokens === "number" && isStringOrNull(r.last_nudge_band) && isStringOrNull(r.last_transform_error) && typeof r.is_subagent === "number" && typeof r.last_context_percentage === "number" && typeof r.last_input_tokens === "number" && isNumberOrNull(r.observed_safe_input_tokens) && isNumberOrNull(r.cache_alert_sent) && isNumberOrNull(r.times_execute_threshold_reached) && isNumberOrNull(r.compartment_in_progress) && (r.system_prompt_hash === null || typeof r.system_prompt_hash === "string" || typeof r.system_prompt_hash === "number") && isNumberOrNull(r.system_prompt_tokens) && isNumberOrNull(r.conversation_tokens) && isNumberOrNull(r.tool_call_tokens) && isNumberOrNull(r.cleared_reasoning_through_tag) && isStringOrNull(r.last_todo_state) && isBlobOrNull(r.cached_m0_bytes) && isBlobOrNull(r.cached_m1_bytes) && isNumberOrNull(r.cached_m0_project_memory_epoch) && isNumberOrNull(r.cached_m0_project_user_profile_version) && isNumberOrNull(r.cached_m0_max_compartment_seq) && isNumberOrNull(r.cached_m0_max_memory_id) && isNumberOrNull(r.cached_m0_max_mutation_id) && isNumberOrNull(r.cached_m0_max_memory_mutation_id) && isStringOrNull(r.cached_m0_project_docs_hash) && isNumberOrNull(r.cached_m0_materialized_at) && isNumberOrNull(r.cached_m0_session_facts_version) && isStringOrNull(r.cached_m0_upgrade_state) && isStringOrNull(r.last_observed_model_key) && isNumberOrNull(r.upgrade_reminded_at) && isNumberOrNull(r.pi_stable_id_scheme);
159411
+ return typeof r.session_id === "string" && typeof r.last_response_time === "number" && isStringOrNull(r.cache_ttl) && typeof r.counter === "number" && typeof r.last_nudge_tokens === "number" && isStringOrNull(r.last_nudge_band) && isStringOrNull(r.last_transform_error) && typeof r.is_subagent === "number" && typeof r.last_context_percentage === "number" && typeof r.last_input_tokens === "number" && isNumberOrNull(r.observed_safe_input_tokens) && isNumberOrNull(r.cache_alert_sent) && isNumberOrNull(r.times_execute_threshold_reached) && isNumberOrNull(r.compartment_in_progress) && (r.system_prompt_hash === null || typeof r.system_prompt_hash === "string" || typeof r.system_prompt_hash === "number") && isNumberOrNull(r.system_prompt_tokens) && isNumberOrNull(r.conversation_tokens) && isNumberOrNull(r.tool_call_tokens) && isNumberOrNull(r.cleared_reasoning_through_tag) && isStringOrNull(r.last_todo_state) && isBlobOrNull(r.cached_m0_bytes) && isBlobOrNull(r.cached_m1_bytes) && isNumberOrNull(r.cached_m0_project_memory_epoch) && isNumberOrNull(r.cached_m0_project_user_profile_version) && isNumberOrNull(r.cached_m0_max_compartment_seq) && isNumberOrNull(r.cached_m0_max_memory_id) && isNumberOrNull(r.cached_m0_max_mutation_id) && isNumberOrNull(r.cached_m0_max_memory_mutation_id) && isStringOrNull(r.cached_m0_project_docs_hash) && isNumberOrNull(r.cached_m0_materialized_at) && isNumberOrNull(r.cached_m0_session_facts_version) && isStringOrNull(r.cached_m0_upgrade_state) && isStringOrNull(r.cached_m0_system_hash) && isStringOrNull(r.cached_m0_tool_set_hash) && isStringOrNull(r.cached_m0_model_key) && isStringOrNull(r.last_observed_model_key) && isNumberOrNull(r.upgrade_reminded_at) && isNumberOrNull(r.pi_stable_id_scheme);
159443
159412
  }
159444
159413
  function getDefaultSessionMeta(sessionId) {
159445
159414
  return {
@@ -159475,6 +159444,9 @@ function getDefaultSessionMeta(sessionId) {
159475
159444
  cachedM0MaterializedAt: null,
159476
159445
  cachedM0SessionFactsVersion: null,
159477
159446
  cachedM0UpgradeState: null,
159447
+ cachedM0SystemHash: null,
159448
+ cachedM0ToolSetHash: null,
159449
+ cachedM0ModelKey: null,
159478
159450
  lastObservedModelKey: null,
159479
159451
  upgradeRemindedAt: null,
159480
159452
  piStableIdScheme: null
@@ -159526,6 +159498,9 @@ function toSessionMeta(row) {
159526
159498
  cachedM0MaterializedAt: numOrNull(row.cached_m0_materialized_at),
159527
159499
  cachedM0SessionFactsVersion: numOrNull(row.cached_m0_session_facts_version),
159528
159500
  cachedM0UpgradeState: stringOrNull(row.cached_m0_upgrade_state),
159501
+ cachedM0SystemHash: stringOrNull(row.cached_m0_system_hash),
159502
+ cachedM0ToolSetHash: stringOrNull(row.cached_m0_tool_set_hash),
159503
+ cachedM0ModelKey: stringOrNull(row.cached_m0_model_key),
159529
159504
  lastObservedModelKey: stringOrNull(row.last_observed_model_key),
159530
159505
  upgradeRemindedAt: numOrNull(row.upgrade_reminded_at),
159531
159506
  piStableIdScheme: numOrNull(row.pi_stable_id_scheme)
@@ -159545,8 +159520,11 @@ function persistCachedM0(db, sessionId, payload) {
159545
159520
  cached_m0_project_docs_hash = ?,
159546
159521
  cached_m0_materialized_at = ?,
159547
159522
  cached_m0_session_facts_version = ?,
159548
- cached_m0_upgrade_state = ?
159549
- WHERE session_id = ?`).run(Buffer2.from(payload.m0Bytes), payload.projectMemoryEpoch, payload.projectUserProfileVersion, payload.maxCompartmentSeq, payload.maxMemoryId, payload.maxMutationId, payload.maxMemoryMutationId ?? null, payload.m1Bytes ? Buffer2.from(payload.m1Bytes) : null, payload.projectDocsHash, payload.materializedAt, payload.sessionFactsVersion, payload.upgradeState, sessionId);
159523
+ cached_m0_upgrade_state = ?,
159524
+ cached_m0_system_hash = ?,
159525
+ cached_m0_tool_set_hash = ?,
159526
+ cached_m0_model_key = ?
159527
+ WHERE session_id = ?`).run(Buffer2.from(payload.m0Bytes), payload.projectMemoryEpoch, payload.projectUserProfileVersion, payload.maxCompartmentSeq, payload.maxMemoryId, payload.maxMutationId, payload.maxMemoryMutationId ?? null, payload.m1Bytes ? Buffer2.from(payload.m1Bytes) : null, payload.projectDocsHash, payload.materializedAt, payload.sessionFactsVersion, payload.upgradeState, payload.systemHash ?? "", payload.toolSetHash ?? "", payload.modelKey ?? "", sessionId);
159550
159528
  }
159551
159529
  function clearCachedM0M1(db, sessionId) {
159552
159530
  ensureSessionMetaRow(db, sessionId);
@@ -159564,6 +159542,9 @@ function clearCachedM0M1(db, sessionId) {
159564
159542
  ["cached_m0_materialized_at", null],
159565
159543
  ["cached_m0_session_facts_version", null],
159566
159544
  ["cached_m0_upgrade_state", null],
159545
+ ["cached_m0_system_hash", null],
159546
+ ["cached_m0_tool_set_hash", null],
159547
+ ["cached_m0_model_key", null],
159567
159548
  ["cached_m0_last_baseline_end_message_id", null],
159568
159549
  ["memory_block_cache", ""],
159569
159550
  ["memory_block_count", 0],
@@ -159770,8 +159751,47 @@ function escapeXmlContent(s) {
159770
159751
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
159771
159752
  }
159772
159753
 
159773
- // ../plugin/src/hooks/magic-context/read-session-chunk.ts
159774
- await init_read_session_db();
159754
+ // ../plugin/src/hooks/magic-context/read-session-db.ts
159755
+ import { existsSync as existsSync6 } from "node:fs";
159756
+ import { join as join7 } from "node:path";
159757
+ function getOpenCodeDbPath() {
159758
+ return join7(getDataDir(), "opencode", "opencode.db");
159759
+ }
159760
+ function openCodeDbExists() {
159761
+ return existsSync6(getOpenCodeDbPath());
159762
+ }
159763
+ var cachedReadOnlyDb = null;
159764
+ function closeCachedReadOnlyDb() {
159765
+ if (!cachedReadOnlyDb) {
159766
+ return;
159767
+ }
159768
+ try {
159769
+ closeQuietly(cachedReadOnlyDb.db);
159770
+ } catch (error51) {
159771
+ log("[magic-context] failed to close cached OpenCode read-only DB:", error51);
159772
+ } finally {
159773
+ cachedReadOnlyDb = null;
159774
+ }
159775
+ }
159776
+ function getReadOnlySessionDb() {
159777
+ const dbPath = getOpenCodeDbPath();
159778
+ if (cachedReadOnlyDb?.path === dbPath) {
159779
+ return cachedReadOnlyDb.db;
159780
+ }
159781
+ closeCachedReadOnlyDb();
159782
+ const db = new Database(dbPath, { readonly: true });
159783
+ cachedReadOnlyDb = { path: dbPath, db };
159784
+ return db;
159785
+ }
159786
+ function withReadOnlySessionDb(fn) {
159787
+ return fn(getReadOnlySessionDb());
159788
+ }
159789
+ function getRawSessionMessageCountFromDb(db, sessionId) {
159790
+ const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
159791
+ AND NOT (COALESCE(json_extract(data, '$.summary'), 0) = 1
159792
+ AND COALESCE(json_extract(data, '$.finish'), '') = 'stop')`).get(sessionId);
159793
+ return typeof row?.count === "number" ? row.count : 0;
159794
+ }
159775
159795
 
159776
159796
  // ../plugin/src/hooks/magic-context/read-session-raw.ts
159777
159797
  function isRawMessageRow(row) {
@@ -164666,7 +164686,6 @@ var CATEGORY_DEFAULT_TTL = {
164666
164686
  KNOWN_ISSUES: 30 * 24 * 60 * 60 * 1000
164667
164687
  };
164668
164688
  // ../plugin/src/features/magic-context/memory/embedding-backfill.ts
164669
- init_logger();
164670
164689
  async function ensureMemoryEmbeddings(args) {
164671
164690
  const snapshot = getProjectEmbeddingSnapshot(args.projectIdentity);
164672
164691
  if (!snapshot?.enabled) {
@@ -164704,9 +164723,6 @@ async function ensureMemoryEmbeddings(args) {
164704
164723
  }
164705
164724
  return args.existingEmbeddings;
164706
164725
  }
164707
- // ../plugin/src/features/magic-context/memory/promotion.ts
164708
- init_logger();
164709
-
164710
164726
  // ../plugin/src/features/magic-context/memory/storage-memory.ts
164711
164727
  var COLUMN_MAP = {
164712
164728
  id: "id",
@@ -165606,7 +165622,6 @@ function getMaxMemoryMutationId(db, projectPath) {
165606
165622
  return row?.max_id ?? null;
165607
165623
  }
165608
165624
  // ../plugin/src/features/magic-context/storage-meta-persisted.ts
165609
- init_logger();
165610
165625
  var CAS_RETRY_LIMIT = 5;
165611
165626
  var AUTO_SEARCH_NO_HINT_REASONS = new Set([
165612
165627
  "below-threshold",
@@ -166069,8 +166084,6 @@ function setSessionWorkMetrics(db, sessionId, newWorkTokens, totalInputTokens) {
166069
166084
  import { Buffer as Buffer3 } from "node:buffer";
166070
166085
 
166071
166086
  // ../plugin/src/features/magic-context/resolve-subagent-fallback.ts
166072
- init_logger();
166073
- await init_read_session_db();
166074
166087
  function resolveIsSubagentFromOpenCodeDb(sessionId) {
166075
166088
  try {
166076
166089
  return withReadOnlySessionDb((openCodeDb) => {
@@ -166104,6 +166117,9 @@ var SESSION_META_FALLBACK_SELECTS = {
166104
166117
  cached_m0_materialized_at: "NULL AS cached_m0_materialized_at",
166105
166118
  cached_m0_session_facts_version: "NULL AS cached_m0_session_facts_version",
166106
166119
  cached_m0_upgrade_state: "NULL AS cached_m0_upgrade_state",
166120
+ cached_m0_system_hash: "NULL AS cached_m0_system_hash",
166121
+ cached_m0_tool_set_hash: "NULL AS cached_m0_tool_set_hash",
166122
+ cached_m0_model_key: "NULL AS cached_m0_model_key",
166107
166123
  last_observed_model_key: "NULL AS last_observed_model_key",
166108
166124
  upgrade_reminded_at: "NULL AS upgrade_reminded_at"
166109
166125
  };
@@ -166336,7 +166352,6 @@ function markNoteChecked(db, noteId) {
166336
166352
  db.prepare("UPDATE notes SET last_checked_at = ?, updated_at = ? WHERE id = ? AND type = 'smart'").run(now, now, noteId);
166337
166353
  }
166338
166354
  // ../plugin/src/features/magic-context/storage-ops.ts
166339
- init_logger();
166340
166355
  var queuePendingOpStatements = new WeakMap;
166341
166356
  var getPendingOpsStatements = new WeakMap;
166342
166357
  var clearPendingOpsStatements = new WeakMap;
@@ -166738,7 +166753,6 @@ var ERROR_CLASSES = new Set([
166738
166753
  "unknown"
166739
166754
  ]);
166740
166755
  // src/tools/ctx-memory.ts
166741
- init_logger();
166742
166756
  var DEFAULT_LIST_LIMIT = 10;
166743
166757
  var VALID_CATEGORIES = new Set(CATEGORY_PRIORITY);
166744
166758
  function isMemoryCategory2(value) {
@@ -167455,11 +167469,7 @@ function createCtxReduceTool(deps) {
167455
167469
  };
167456
167470
  }
167457
167471
 
167458
- // ../plugin/src/features/magic-context/search.ts
167459
- init_logger();
167460
-
167461
167472
  // ../plugin/src/features/magic-context/git-commits/git-log-reader.ts
167462
- init_logger();
167463
167473
  import { execFile } from "node:child_process";
167464
167474
  import { promisify } from "node:util";
167465
167475
  var execFileAsync = promisify(execFile);
@@ -167543,11 +167553,7 @@ ${body}` : subject;
167543
167553
  }
167544
167554
  return commits;
167545
167555
  }
167546
- // ../plugin/src/features/magic-context/git-commits/indexer.ts
167547
- init_logger();
167548
-
167549
167556
  // ../plugin/src/features/magic-context/git-commits/storage-git-commits.ts
167550
- init_logger();
167551
167557
  var insertStatements = new WeakMap;
167552
167558
  var existingShasStatements = new WeakMap;
167553
167559
  var projectCountStatements = new WeakMap;
@@ -167760,7 +167766,6 @@ async function embedUnembeddedCommits(db, projectPath) {
167760
167766
  }
167761
167767
  }
167762
167768
  // ../plugin/src/features/magic-context/git-commits/search-git-commits.ts
167763
- init_logger();
167764
167769
  var ftsStatements = new WeakMap;
167765
167770
  var ftsPlainStatements = new WeakMap;
167766
167771
  var getBySHAStatements = new WeakMap;
@@ -168431,9 +168436,6 @@ class BoundedSessionMap {
168431
168436
  }
168432
168437
  }
168433
168438
 
168434
- // ../plugin/src/hooks/magic-context/inject-compartments.ts
168435
- init_logger();
168436
-
168437
168439
  // ../plugin/src/hooks/magic-context/decay-curve.ts
168438
168440
  var H50 = 24;
168439
168441
  var D = 25;
@@ -168608,26 +168610,58 @@ import { join as join9, sep as sep2 } from "node:path";
168608
168610
  var import_comment_json2 = __toESM(require_src2(), 1);
168609
168611
  import { existsSync as existsSync7, readFileSync as readFileSync5 } from "node:fs";
168610
168612
  import { homedir as homedir4 } from "node:os";
168611
- import { join as join8 } from "node:path";
168613
+ import { isAbsolute as isAbsolute2, join as join8, resolve as resolve3 } from "node:path";
168614
+ import { fileURLToPath } from "node:url";
168612
168615
  var overrideAvailability = null;
168613
168616
  function parseConfig(path5) {
168614
168617
  if (!existsSync7(path5))
168615
168618
  return null;
168616
168619
  return import_comment_json2.parse(readFileSync5(path5, "utf-8"));
168617
168620
  }
168618
- function entryMatchesAft(entry) {
168621
+ var AFT_NAME_NEEDLES = ["@cortexkit/aft", "aft-opencode", "aft-pi"];
168622
+ function stringMentionsAft(value) {
168623
+ return AFT_NAME_NEEDLES.some((needle) => value.includes(needle));
168624
+ }
168625
+ function resolveLocalEntryPackageName(value, configDir) {
168626
+ let dir = null;
168627
+ if (value.startsWith("file://")) {
168628
+ try {
168629
+ dir = fileURLToPath(value);
168630
+ } catch {
168631
+ return null;
168632
+ }
168633
+ } else if (value.startsWith("~/")) {
168634
+ dir = join8(homedir4(), value.slice(2));
168635
+ } else if (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) {
168636
+ dir = isAbsolute2(value) ? value : resolve3(configDir, value);
168637
+ } else {
168638
+ return null;
168639
+ }
168640
+ try {
168641
+ const pkg = JSON.parse(readFileSync5(join8(dir, "package.json"), "utf-8"));
168642
+ return typeof pkg.name === "string" ? pkg.name : null;
168643
+ } catch {
168644
+ return null;
168645
+ }
168646
+ }
168647
+ function entryMatchesAft(entry, configDir) {
168619
168648
  const value = Array.isArray(entry) ? entry[0] : entry;
168620
- return typeof value === "string" && (value.includes("@cortexkit/aft") || value.includes("aft-opencode") || value.includes("aft-pi"));
168649
+ if (typeof value !== "string")
168650
+ return false;
168651
+ if (stringMentionsAft(value))
168652
+ return true;
168653
+ const name2 = resolveLocalEntryPackageName(value, configDir);
168654
+ return name2 != null && stringMentionsAft(name2);
168621
168655
  }
168622
- function hasAftInArray(value) {
168623
- return Array.isArray(value) && value.some(entryMatchesAft);
168656
+ function hasAftInArray(value, configDir) {
168657
+ return Array.isArray(value) && value.some((entry) => entryMatchesAft(entry, configDir));
168624
168658
  }
168625
- function hasAftAtKeys(value, keys2) {
168659
+ function hasAftAtKeys(value, keys2, configDir) {
168626
168660
  if (!value || typeof value !== "object")
168627
168661
  return false;
168628
168662
  const record4 = value;
168629
168663
  for (const key of keys2) {
168630
- if (hasAftInArray(record4[key]))
168664
+ if (hasAftInArray(record4[key], configDir))
168631
168665
  return true;
168632
168666
  }
168633
168667
  return false;
@@ -168644,7 +168678,8 @@ function getAftAvailability() {
168644
168678
  for (const path5 of opencodePaths) {
168645
168679
  try {
168646
168680
  const config2 = parseConfig(path5);
168647
- if (hasAftAtKeys(config2, ["plugin", "plugins", "mcp", "mcp_servers"])) {
168681
+ const configDir = join8(path5, "..");
168682
+ if (hasAftAtKeys(config2, ["plugin", "plugins", "mcp", "mcp_servers"], configDir)) {
168648
168683
  opencode = true;
168649
168684
  break;
168650
168685
  }
@@ -168654,12 +168689,13 @@ function getAftAvailability() {
168654
168689
  for (const path5 of piPaths) {
168655
168690
  try {
168656
168691
  const config2 = parseConfig(path5);
168657
- if (hasAftAtKeys(config2, ["packages", "extensions"])) {
168692
+ const configDir = join8(path5, "..");
168693
+ if (hasAftAtKeys(config2, ["packages", "extensions"], configDir)) {
168658
168694
  pi = true;
168659
168695
  break;
168660
168696
  }
168661
168697
  const agent = config2?.agent;
168662
- if (hasAftAtKeys(agent, ["packages", "extensions"])) {
168698
+ if (hasAftAtKeys(agent, ["packages", "extensions"], configDir)) {
168663
168699
  pi = true;
168664
168700
  break;
168665
168701
  }
@@ -168678,7 +168714,6 @@ function isAftAvailable() {
168678
168714
  }
168679
168715
 
168680
168716
  // ../plugin/src/hooks/magic-context/key-files-block.ts
168681
- init_logger();
168682
168717
  var cachedKeyFilesBySession = new Map;
168683
168718
  var staleUpdates = new Map;
168684
168719
  function staleKey(update2) {
@@ -168776,9 +168811,6 @@ ${blocks.join(`
168776
168811
  return rendered;
168777
168812
  }
168778
168813
 
168779
- // ../plugin/src/hooks/magic-context/inject-compartments.ts
168780
- await init_read_session_db();
168781
-
168782
168814
  // ../plugin/src/hooks/magic-context/temporal-awareness.ts
168783
168815
  var TEMPORAL_AWARENESS_THRESHOLD_SECONDS = 300;
168784
168816
  var SECONDS_PER_MINUTE = 60;