@cortexkit/magic-context 0.49.6 → 0.49.8

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 (2) hide show
  1. package/dist/index.js +535 -135
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1949,7 +1949,7 @@ var init_redaction = __esm(() => {
1949
1949
  replacement: "<GITHUB_PAT_REDACTED>"
1950
1950
  },
1951
1951
  {
1952
- pattern: /\b(?:gh[opsu]|ghr)_[A-Za-z0-9]{30,}/g,
1952
+ pattern: /\b(?:gh[opsu]|ghr)_[A-Za-z0-9_-]{30,}/g,
1953
1953
  replacement: "<GITHUB_TOKEN_REDACTED>"
1954
1954
  },
1955
1955
  {
@@ -1980,6 +1980,10 @@ var init_redaction = __esm(() => {
1980
1980
  pattern: /\b((?:x-)?(?:api-?key|api-?token|auth-?token|access-?token)\s*:\s*)([^\s'"`,;<>]{6,})/gi,
1981
1981
  replacement: (full, prefix, value) => isNonSecretScalarValue(value) ? full : `${prefix}<REDACTED:api_key>`
1982
1982
  },
1983
+ {
1984
+ pattern: /\b((?:api[_-]?key|client[_-]?secret|access[_-]?token|token|secret|password|passwd|pwd)\s*:\s*)([^\s'"`,;<>]{6,})/gi,
1985
+ replacement: (full, prefix, value) => isNonSecretScalarValue(value) ? full : `${prefix}<REDACTED:credential>`
1986
+ },
1983
1987
  {
1984
1988
  pattern: /\b([a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:)([^\s/@]+)(@)/gi,
1985
1989
  replacement: (_full, prefix, _password, at) => `${prefix}<REDACTED:password>${at}`
@@ -8572,6 +8576,7 @@ function nextOccurrence(cron, after, excludeCivilMinute, maxSearchMs = MAX_SEARC
8572
8576
  let cursorMs = Math.floor(afterMs / MINUTE_MS) * MINUTE_MS + MINUTE_MS;
8573
8577
  const capMs = afterMs + Math.max(0, Math.min(MAX_SEARCH_MS, maxSearchMs));
8574
8578
  while (cursorMs <= capMs) {
8579
+ candidateVisitsForTests?.();
8575
8580
  const candidate = new Date(cursorMs);
8576
8581
  if (matchesCron(cron, candidate)) {
8577
8582
  if (!excludeCivilMinute || civilMinuteKey(candidate) !== excludeCivilMinute) {
@@ -8592,7 +8597,7 @@ function nextDueAtMs(expression, afterMs, consumedScheduledAtMs, maxSearchMs = M
8592
8597
  const next = nextOccurrence(parsed.cron, new Date(afterMs), exclude, maxSearchMs);
8593
8598
  return next ? next.getTime() : null;
8594
8599
  }
8595
- var FIELDS, MINUTE_MS = 60000, MAX_SEARCH_MS, MAX_DAYS_IN_MONTH;
8600
+ var FIELDS, MINUTE_MS = 60000, MAX_SEARCH_MS, candidateVisitsForTests, MAX_DAYS_IN_MONTH;
8596
8601
  var init_cron = __esm(() => {
8597
8602
  FIELDS = [
8598
8603
  { name: "minute", min: 0, max: 59 },
@@ -12817,6 +12822,7 @@ __export(exports_sqlite, {
12817
12822
  getSqliteMemoryStats: () => getSqliteMemoryStats,
12818
12823
  getTagIdentityWriteGeneration: () => getTagIdentityWriteGeneration,
12819
12824
  guardSqliteTransformPass: () => guardSqliteTransformPass,
12825
+ inRootAsyncContext: () => inRootAsyncContext,
12820
12826
  indexCoordinationInput: () => indexCoordinationInput,
12821
12827
  isTransientSqliteError: () => isTransientSqliteError,
12822
12828
  loadSqliteModule: () => loadSqliteModule,
@@ -12833,17 +12839,22 @@ __export(exports_sqlite, {
12833
12839
  withoutSqliteTransformPass: () => withoutSqliteTransformPass,
12834
12840
  yieldIndexChunk: () => yieldIndexChunk
12835
12841
  });
12836
- import { AsyncLocalStorage } from "node:async_hooks";
12842
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
12837
12843
  import { statSync as statSync4 } from "node:fs";
12844
+ function inRootAsyncContext(operation) {
12845
+ return resourceRoot.runInAsyncScope(operation);
12846
+ }
12838
12847
  function registerSlowWriteReporter(reporter) {
12839
12848
  reportSlowPrivilegedWrite = reporter;
12840
12849
  }
12841
- function registerSqliteDiagnosticSink(sink) {
12850
+ function registerSqliteDiagnosticSink(sink, host) {
12842
12851
  sqliteDiagnosticSink = sink;
12852
+ if (host)
12853
+ sqliteDiagnosticHost = host;
12843
12854
  }
12844
12855
  function reportSqliteDiagnostic(message) {
12845
12856
  try {
12846
- sqliteDiagnosticSink?.(`[magic-context] ${message}`);
12857
+ sqliteDiagnosticSink?.(`[magic-context] ${message} pid=${process.pid} host=${sqliteDiagnosticHost()}`);
12847
12858
  } catch {}
12848
12859
  }
12849
12860
  function detectSqliteRuntime() {
@@ -12968,17 +12979,25 @@ function installTransactionRouting(db, readonly) {
12968
12979
  assertTransformWrite();
12969
12980
  if (/^\s*BEGIN\s+(?:IMMEDIATE|EXCLUSIVE)(?:\s+TRANSACTION)?\s*;?\s*$/i.test(sql)) {
12970
12981
  openWriterTransactions.delete(db);
12971
- if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore())
12982
+ if (transformPassScope.getStore()?.active || backgroundWriterScope.getStore()) {
12972
12983
  acquireShort(db, () => nativeExec(sql), sql.trim());
12973
- else
12984
+ } else {
12974
12985
  nativeExec(sql);
12986
+ openWriterTransactions.set(db, {
12987
+ site: sql.trim(),
12988
+ lane: "background",
12989
+ acquireMs: 0,
12990
+ attempts: 1,
12991
+ acquiredAt: performance.now()
12992
+ });
12993
+ }
12975
12994
  return db;
12976
12995
  }
12977
12996
  if (WRITER_TRANSACTION_END.test(sql) && openWriterTransactions.has(db))
12978
12997
  return endWriterTransaction(db, () => nativeExec(sql), sql);
12979
12998
  if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
12980
12999
  try {
12981
- return withAutocommitTimeout(db, () => nativeExec(sql));
13000
+ return withAutocommitTimeout(db, () => nativeExec(sql), false);
12982
13001
  } finally {
12983
13002
  if (mayChangeTagIdentity(sql))
12984
13003
  tagIdentityWriteGeneration += 1;
@@ -13339,25 +13358,52 @@ function foregroundWaitLease() {
13339
13358
  const lease = transformPassScope.getStore();
13340
13359
  return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
13341
13360
  }
13342
- function withAutocommitTimeout(db, operation) {
13361
+ function withAutocommitTimeout(db, operation, singleStatement = true) {
13343
13362
  assertTransformWrite();
13344
13363
  const lease = foregroundWaitLease();
13345
- if (isInTransaction(db) || !lease && !backgroundWriterScope.getStore())
13364
+ if (isInTransaction(db))
13346
13365
  return operation();
13347
- const previous = pragmaNumber(db, "busy_timeout");
13348
- db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
13366
+ const scoped = lease || backgroundWriterScope.getStore();
13367
+ const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
13349
13368
  const started = performance.now();
13369
+ let completed = false;
13370
+ const execute = () => {
13371
+ const result = operation();
13372
+ completed = true;
13373
+ return result;
13374
+ };
13350
13375
  try {
13351
- return operation();
13376
+ if (!scoped)
13377
+ return execute();
13378
+ if (singleStatement) {
13379
+ db.exec("PRAGMA busy_timeout=0");
13380
+ try {
13381
+ return execute();
13382
+ } catch (error) {
13383
+ if (!isTransientSqliteError(error) || isInTransaction(db))
13384
+ throw error;
13385
+ }
13386
+ assertTransformWrite();
13387
+ }
13388
+ const timeout = Math.floor(Math.min(lease?.remainingWaitMs ?? SHORT_BUSY_TIMEOUT_MS, lease?.guard?.remainingMs() ?? Infinity));
13389
+ db.exec(`PRAGMA busy_timeout=${timeout}`);
13390
+ const waitStarted = performance.now();
13391
+ try {
13392
+ return execute();
13393
+ } finally {
13394
+ if (lease)
13395
+ lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - waitStarted));
13396
+ }
13352
13397
  } catch (error) {
13353
13398
  if (lease && isTransientSqliteError(error))
13354
13399
  throw new SqliteAcquisitionBusyError(error, "autocommit");
13355
13400
  throw error;
13356
13401
  } finally {
13357
- if (lease)
13358
- lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - started));
13402
+ const elapsed = performance.now() - started;
13359
13403
  if (previous !== null)
13360
13404
  db.exec(`PRAGMA busy_timeout=${previous}`);
13405
+ if (elapsed >= SLOW_WRITER_LOG_MS)
13406
+ reportSqliteDiagnostic(`sqlite writer site=autocommit lane=${lease ? "foreground" : "background"} elapsed_ms=${Math.round(elapsed)} timing=statement_including_acquisition outcome=${completed ? "completed" : "failed"} caller=${writerCaller()}`);
13361
13407
  }
13362
13408
  }
13363
13409
  function acquireShort(db, acquire, site) {
@@ -13403,24 +13449,26 @@ function acquireShort(db, acquire, site) {
13403
13449
  }
13404
13450
  function endWriterTransaction(db, end, sql) {
13405
13451
  let ended = false;
13406
- const endStarted = performance.now();
13407
13452
  try {
13408
13453
  const result = end();
13409
13454
  ended = true;
13410
13455
  return result;
13411
13456
  } finally {
13412
13457
  const open = openWriterTransactions.get(db);
13413
- const endMs = performance.now() - endStarted;
13414
13458
  if (open && !isInTransaction(db)) {
13415
13459
  openWriterTransactions.delete(db);
13416
13460
  const holdMs = performance.now() - open.acquiredAt;
13417
13461
  if (open.acquireMs >= SLOW_WRITER_LOG_MS || holdMs >= SLOW_WRITER_LOG_MS) {
13418
13462
  const outcome = /^\s*ROLLBACK/i.test(sql) ? "rolled_back" : ended ? "committed" : "failed";
13419
- reportSqliteDiagnostic(`sqlite writer site=${open.site} lane=${open.lane} acquire_ms=${Math.round(open.acquireMs)} hold_ms=${Math.round(holdMs)} end_ms=${Math.round(endMs)} attempts=${open.attempts} outcome=${outcome}`);
13463
+ reportSqliteDiagnostic(`sqlite writer site=${open.site} lane=${open.lane} acquire_ms=${Math.round(open.acquireMs)} hold_ms=${Math.round(holdMs)} attempts=${open.attempts} outcome=${outcome} timing=through_commit_upper_bound caller=${writerCaller()}`);
13420
13464
  }
13421
13465
  }
13422
13466
  }
13423
13467
  }
13468
+ function writerCaller() {
13469
+ return new Error().stack?.split(`
13470
+ `).find((line) => line.includes(" at ") && !/[/\\]sqlite\.[tj]s[:)]/.test(line) && !/\b(?:writerCaller|endWriterTransaction|withAutocommitTimeout|value)\b/.test(line))?.trim().replace(/\s+/g, "_") ?? "unknown";
13471
+ }
13424
13472
  async function beginSqliteWriterAsync(db, site) {
13425
13473
  const started = performance.now();
13426
13474
  let attempts = 0;
@@ -13604,8 +13652,9 @@ async function withIndexChunk(input, operation) {
13604
13652
  async function yieldIndexChunk() {
13605
13653
  await yieldIndexTurn();
13606
13654
  }
13607
- var reportSlowPrivilegedWrite, sqliteDiagnosticSink, bunSpec, nodeSpec, SqliteRuntimeUnavailableError, detectedRuntime, isBun, sqliteModule, DatabaseImpl, trackedSqliteConnections, nextSqliteConnectionSequence = 1, TAG_COLUMNS_OUTSIDE_IDENTITY, tagIdentityWriteGeneration = 0, TrackedDatabase, Database, statementOwners, FIRST_PRUNE_AT = 256, privilegeDepth, transformPassScope, admissionScope, backgroundWriterScope, SqliteAcquisitionBusyError, SHORT_BUSY_TIMEOUT_MS = 25, FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS = 2000, FOREGROUND_ACQUISITION_BUDGET_MS = 16500, SLOW_WRITER_LOG_MS = 250, WRITER_TRANSACTION_END, writerAcquisitionScope, openWriterTransactions, indexCoordinationKey, indexCoordinationHeap, indexCoordinationBuffer, indexCoordinationState, yieldIndexTurn = () => new Promise((resolve) => setTimeout(resolve, 1));
13655
+ var resourceRoot, reportSlowPrivilegedWrite, sqliteDiagnosticSink, sqliteDiagnosticHost = () => "unknown", bunSpec, nodeSpec, SqliteRuntimeUnavailableError, detectedRuntime, isBun, sqliteModule, DatabaseImpl, trackedSqliteConnections, nextSqliteConnectionSequence = 1, TAG_COLUMNS_OUTSIDE_IDENTITY, tagIdentityWriteGeneration = 0, TrackedDatabase, Database, statementOwners, FIRST_PRUNE_AT = 256, privilegeDepth, transformPassScope, admissionScope, backgroundWriterScope, SqliteAcquisitionBusyError, SHORT_BUSY_TIMEOUT_MS = 25, FOREGROUND_IN_PASS_BUSY_TIMEOUT_MS = 2000, FOREGROUND_ACQUISITION_BUDGET_MS = 16500, SLOW_WRITER_LOG_MS = 100, WRITER_TRANSACTION_END, writerAcquisitionScope, openWriterTransactions, indexCoordinationKey, indexCoordinationHeap, indexCoordinationBuffer, indexCoordinationState, yieldIndexTurn = () => new Promise((resolve) => setTimeout(resolve, 1));
13608
13656
  var init_sqlite = __esm(async () => {
13657
+ resourceRoot = new AsyncResource("magic-context:root");
13609
13658
  bunSpec = "bun:" + "sqlite";
13610
13659
  nodeSpec = "node:" + "sqlite";
13611
13660
  SqliteRuntimeUnavailableError = class SqliteRuntimeUnavailableError extends Error {
@@ -13639,7 +13688,7 @@ var init_sqlite = __esm(async () => {
13639
13688
  ]);
13640
13689
  TrackedDatabase = new Proxy(DatabaseImpl, {
13641
13690
  construct(target, args) {
13642
- const db = Reflect.construct(target, args, target);
13691
+ const db = inRootAsyncContext(() => Reflect.construct(target, args, target));
13643
13692
  return trackSqliteConnection(db, args[0], args[1]);
13644
13693
  }
13645
13694
  });
@@ -25079,11 +25128,14 @@ function bootQuietRemainingMs(now = Date.now()) {
25079
25128
  return Math.max(0, bootQuietUntilMs - now);
25080
25129
  }
25081
25130
  function scheduleAfterBootQuiet(task, additionalDelayMs = 0) {
25082
- const timer = setTimeout(task, bootQuietRemainingMs() + Math.max(0, additionalDelayMs));
25131
+ const timer = inRootAsyncContext(() => setTimeout(task, bootQuietRemainingMs() + Math.max(0, additionalDelayMs)));
25083
25132
  timer.unref?.();
25084
25133
  return timer;
25085
25134
  }
25086
25135
  var bootQuietUntilMs = 0;
25136
+ var init_boot_quiet = __esm(async () => {
25137
+ await init_sqlite();
25138
+ });
25087
25139
 
25088
25140
  // ../plugin/src/shared/error-message.ts
25089
25141
  function getErrorMessage(error) {
@@ -25868,9 +25920,10 @@ END`
25868
25920
  var init_off_thread_migration_clock = () => {};
25869
25921
 
25870
25922
  // ../plugin/src/features/magic-context/migration-worker-client.ts
25871
- var init_migration_worker_client = __esm(() => {
25923
+ var init_migration_worker_client = __esm(async () => {
25872
25924
  init_logger();
25873
25925
  init_off_thread_migration_clock();
25926
+ await init_sqlite();
25874
25927
  });
25875
25928
 
25876
25929
  // ../plugin/src/features/magic-context/memory/constants.ts
@@ -32192,7 +32245,7 @@ function runSessionWarmupWorker(input, options) {
32192
32245
  deadline.unref?.();
32193
32246
  };
32194
32247
  try {
32195
- worker = new Worker(options.entry ?? defaultEntry(), { workerData: input });
32248
+ worker = inRootAsyncContext(() => new Worker(options.entry ?? defaultEntry(), { workerData: input }));
32196
32249
  } catch (error) {
32197
32250
  finish({ failure: "start-failed", detail: String(error) });
32198
32251
  return;
@@ -32282,7 +32335,8 @@ var init_raw_ordinal_warmup = __esm(async () => {
32282
32335
  init_logger();
32283
32336
  await __promiseAll([
32284
32337
  init_sqlite(),
32285
- init_read_session_raw()
32338
+ init_read_session_raw(),
32339
+ init_sqlite()
32286
32340
  ]);
32287
32341
  RESULT_TIMEOUT_MS = 10 * 60000;
32288
32342
  FAILURE_BACKOFF_MS = 5 * 60000;
@@ -32644,11 +32698,13 @@ var init_storage_meta_shared = __esm(async () => {
32644
32698
  });
32645
32699
 
32646
32700
  // ../plugin/src/features/magic-context/storage-replay-document.ts
32647
- var MISSING_REPLAY_DOCUMENT_COLUMN, decisionTablePresent, trailingBlankReadCache, TRAILING_BLANK_CACHE_MAX_CHARS, DECISION_CONFLICT;
32701
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
32702
+ var MISSING_REPLAY_DOCUMENT_COLUMN, replaySnapshots, decisionTablePresent, trailingBlankReadCache, TRAILING_BLANK_CACHE_MAX_CHARS, DECISION_CONFLICT;
32648
32703
  var init_storage_replay_document = __esm(async () => {
32649
32704
  init_logger();
32650
32705
  await init_storage_meta_shared();
32651
32706
  MISSING_REPLAY_DOCUMENT_COLUMN = Symbol("missing replay document column");
32707
+ replaySnapshots = new AsyncLocalStorage2;
32652
32708
  decisionTablePresent = new WeakMap;
32653
32709
  trailingBlankReadCache = new WeakMap;
32654
32710
  TRAILING_BLANK_CACHE_MAX_CHARS = 4 * 1024 * 1024;
@@ -32726,9 +32782,8 @@ var init_sentinel = __esm(() => {
32726
32782
  var init_active_anthropic_turn = __esm(() => {
32727
32783
  init_sentinel();
32728
32784
  });
32729
-
32730
32785
  // ../plugin/src/hooks/magic-context/strip-content.ts
32731
- var METADATA_PART_TYPES, CLEARED_REASONING_TYPES, REASONING_IGNORED_PART_TYPES, REASONING_PART_TYPES;
32786
+ var METADATA_PART_TYPES, CLEARED_REASONING_TYPES, REASONING_IGNORED_PART_TYPES, REASONING_PART_TYPES, emptyImageParts;
32732
32787
  var init_strip_content = __esm(() => {
32733
32788
  init_merged_reasoning_decisions();
32734
32789
  init_sentinel();
@@ -32755,6 +32810,7 @@ var init_strip_content = __esm(() => {
32755
32810
  "compaction"
32756
32811
  ]);
32757
32812
  REASONING_PART_TYPES = new Set(["reasoning", "thinking", "redacted_thinking"]);
32813
+ emptyImageParts = new WeakMap;
32758
32814
  });
32759
32815
 
32760
32816
  // ../plugin/src/hooks/magic-context/reasoning-budget.ts
@@ -32874,6 +32930,7 @@ __export(exports_read_session_chunk, {
32874
32930
  setBoundedRawMessageProvider: () => setBoundedRawMessageProvider,
32875
32931
  setRawMessageProvider: () => setRawMessageProvider,
32876
32932
  visitRawSessionMessages: () => visitRawSessionMessages,
32933
+ visitRawSessionMessagesAsync: () => visitRawSessionMessagesAsync,
32877
32934
  withRawMessageProvider: () => withRawMessageProvider,
32878
32935
  withRawSessionMessageCache: () => withRawSessionMessageCache
32879
32936
  });
@@ -33103,6 +33160,21 @@ function visitRawSessionMessages(sessionId, fromOrdinal, toOrdinal, visit, optio
33103
33160
  after = last ? { timeCreated: last.createdAt ?? 0, id: last.id } : undefined;
33104
33161
  }
33105
33162
  }
33163
+ async function visitRawSessionMessagesAsync(sessionId, fromOrdinal, toOrdinal, visit, options = {}) {
33164
+ const from = Math.max(1, Math.floor(fromOrdinal));
33165
+ const to = Math.floor(toOrdinal);
33166
+ if (to < from)
33167
+ return;
33168
+ const provider = sessionProviders.get(sessionId)?.provider;
33169
+ if (!provider?.iterateMessageRangeAsync) {
33170
+ visitRawSessionMessages(sessionId, from, to, visit, options);
33171
+ return;
33172
+ }
33173
+ for await (const message of provider.iterateMessageRangeAsync(from, to)) {
33174
+ if (!visit(message))
33175
+ return;
33176
+ }
33177
+ }
33106
33178
  function readRawSessionMessageRange(sessionId, fromOrdinal, toOrdinal) {
33107
33179
  const from = Math.max(1, Math.floor(fromOrdinal));
33108
33180
  const to = Math.floor(toOrdinal);
@@ -33323,13 +33395,20 @@ function readRawSessionMessageOrdinalById(sessionId, messageId) {
33323
33395
  return null;
33324
33396
  return withReadOnlySessionDb((db) => readRawSessionMessageOrdinalByIdFromDb(db, sessionId, messageId));
33325
33397
  }
33398
+ function readRawSessionMessageOrderPosition(sessionId, messageId) {
33399
+ const provider = sessionProviders.get(sessionId)?.provider;
33400
+ if (provider) {
33401
+ return provider.readMessageOrderById ? provider.readMessageOrderById(messageId) : provider.readMessageOrdinalById?.(messageId) ?? null;
33402
+ }
33403
+ return readRawSessionMessageOrdinalById(sessionId, messageId);
33404
+ }
33326
33405
  function compareRawSessionMessageOrder(sessionId, leftId, rightId) {
33327
33406
  const provider = sessionProviders.get(sessionId)?.provider;
33328
33407
  if (provider) {
33329
- if (!provider.readMessageOrdinalById)
33408
+ if (!provider.readMessageOrderById && !provider.readMessageOrdinalById)
33330
33409
  return null;
33331
- const left = provider.readMessageOrdinalById(leftId);
33332
- const right = provider.readMessageOrdinalById(rightId);
33410
+ const left = readRawSessionMessageOrderPosition(sessionId, leftId);
33411
+ const right = readRawSessionMessageOrderPosition(sessionId, rightId);
33333
33412
  return left === null || right === null ? null : left - right;
33334
33413
  }
33335
33414
  if (!openCodeDbExists())
@@ -33522,7 +33601,10 @@ function readSessionChunk(sessionId, tokenBudget, offset = 1, eligibleEndOrdinal
33522
33601
  if (state?.input === undefined && state?.output !== undefined && typeof p.callID === "string") {
33523
33602
  const call = calls.get(p.callID);
33524
33603
  if (call) {
33525
- const expansion = expandToolPart({ ...call, state: { ...call.state, output: state.output } }, options.expandTools);
33604
+ const expansion = expandToolPart({
33605
+ ...call,
33606
+ state: { ...call.state, output: state.output }
33607
+ }, options.expandTools);
33526
33608
  if (expansion !== null) {
33527
33609
  expandedParts.set(call, expansion);
33528
33610
  expandedResults.add(part);
@@ -35801,19 +35883,20 @@ var init_storage_db = __esm(async () => {
35801
35883
  init_fail_closed_block();
35802
35884
  init_migration_v94_write_split();
35803
35885
  init_migration_v95_perf_indexes();
35804
- init_migration_worker_client();
35805
35886
  init_storage_schema_helpers();
35806
35887
  init_storage_tag_identity_revision();
35807
35888
  init_tool_definition_tokens();
35808
35889
  init_tool_owner_backfill();
35809
35890
  await __promiseAll([
35891
+ init_boot_quiet(),
35810
35892
  init_sqlite(),
35811
35893
  init_context_store_uuid(),
35812
35894
  init_message_fts_rowid_map(),
35895
+ init_migration_worker_client(),
35813
35896
  init_migrations()
35814
35897
  ]);
35815
35898
  registerSlowWriteReporter(logSlowWriteTransaction);
35816
- registerSqliteDiagnosticSink((message) => log(message));
35899
+ registerSqliteDiagnosticSink((message) => log(message), getHarness);
35817
35900
  databases = new Map;
35818
35901
  pendingAsyncOpens = new Map;
35819
35902
  persistenceByDatabase = new WeakMap;
@@ -37794,10 +37877,11 @@ function findPluginEntry(directory, surface = "server") {
37794
37877
  };
37795
37878
  }
37796
37879
  var import_comment_json7;
37797
- var init_checker = __esm(() => {
37880
+ var init_checker = __esm(async () => {
37798
37881
  init_logger();
37799
37882
  init_constants2();
37800
37883
  init_types();
37884
+ await init_sqlite();
37801
37885
  import_comment_json7 = __toESM(require_src3(), 1);
37802
37886
  });
37803
37887
 
@@ -38004,10 +38088,10 @@ async function inspectPinnedOpenCodePluginSchemaFences(options, deps = {}) {
38004
38088
  return findings;
38005
38089
  }
38006
38090
  var PACKAGE_PATH_SEGMENTS, MAX_TARBALL_BYTES, NPM_TIMEOUT_MS = 5000, FENCE_PATTERN, EXACT_VERSION_PATTERN;
38007
- var init_opencode_plugin_schema_fence = __esm(() => {
38008
- init_checker();
38091
+ var init_opencode_plugin_schema_fence = __esm(async () => {
38009
38092
  init_opencode_plugin_cache();
38010
38093
  init_paths();
38094
+ await init_checker();
38011
38095
  PACKAGE_PATH_SEGMENTS = OPENCODE_PLUGIN_NAME.split("/");
38012
38096
  MAX_TARBALL_BYTES = 25 * 1024 * 1024;
38013
38097
  FENCE_PATTERN = /\bLATEST_SUPPORTED_VERSION\s*=\s*(\d+)\b/g;
@@ -38233,10 +38317,10 @@ function reportCachedPluginFences(findings, report) {
38233
38317
  }
38234
38318
  var init_doctor_cached_plugin_fence = __esm(async () => {
38235
38319
  init_opencode_plugin_cache();
38236
- init_opencode_plugin_schema_fence();
38237
38320
  await __promiseAll([
38238
38321
  init_storage_db(),
38239
38322
  init_database_access(),
38323
+ init_opencode_plugin_schema_fence(),
38240
38324
  init_doctor_opencode_cache(),
38241
38325
  init_doctor_opencode2_cache()
38242
38326
  ]);
@@ -43206,8 +43290,8 @@ var init_user_facing_codes = __esm(() => {
43206
43290
  },
43207
43291
  history_boundary_unresolved: {
43208
43292
  code: "MC-H04",
43209
- sentence: "This request was not sent: the message that marks where this session's history summary ends is missing from the OpenCode store, and without it the request is larger than the model's context window.",
43210
- action: "Run /ctx-recomp to rebuild the history summary."
43293
+ sentence: "This request was not sent: Magic Context could not safely place the history summary boundary in the loaded conversation, and the untrimmed request is larger than the model's context window.",
43294
+ action: "Reopen this session in its current project directory, then run /ctx-recomp to rebuild the history summary. A model with a larger context window can also help."
43211
43295
  },
43212
43296
  history_over_window_unmanaged: {
43213
43297
  code: "MC-H06",
@@ -43553,6 +43637,9 @@ var init_store_ahead_refusal = __esm(() => {
43553
43637
  // ../plugin/src/hooks/magic-context/module-transport.ts
43554
43638
  import { realpathSync as realpathSync7 } from "node:fs";
43555
43639
  import { join as join31 } from "node:path";
43640
+ function monotonicNow() {
43641
+ return monotonicClockForTests?.() ?? performance.now();
43642
+ }
43556
43643
  function getDefaultSubcConnectionFile() {
43557
43644
  return join31(getDataDir(), "cortexkit", "run", "subc-connection.json");
43558
43645
  }
@@ -43797,7 +43884,7 @@ class SubcModuleTransport {
43797
43884
  });
43798
43885
  }
43799
43886
  async call(args) {
43800
- const callStartedAt = performance.now();
43887
+ const callStartedAt = monotonicNow();
43801
43888
  const timings = {
43802
43889
  lane: 0,
43803
43890
  route: 0,
@@ -43843,7 +43930,7 @@ class SubcModuleTransport {
43843
43930
  }
43844
43931
  throw error;
43845
43932
  }
43846
- timings.lane = performance.now() - callStartedAt;
43933
+ timings.lane = monotonicNow() - callStartedAt;
43847
43934
  let rejectAbort;
43848
43935
  const aborted = new Promise((_resolve, reject) => {
43849
43936
  rejectAbort = reject;
@@ -43860,25 +43947,25 @@ class SubcModuleTransport {
43860
43947
  throw args.signal.reason ?? new Error("module transport call aborted");
43861
43948
  }
43862
43949
  const attemptDeadlineMs = Date.now() + attemptTimeoutMs;
43863
- const routeStartedAt = performance.now();
43950
+ const routeStartedAt = monotonicNow();
43864
43951
  ensuredRoute = await this.ensureRoute(args.sessionId, args.projectRoot, attemptDeadlineMs, args.signal);
43865
43952
  if (args.signal?.aborted) {
43866
43953
  throw args.signal.reason ?? new Error("module transport call aborted");
43867
43954
  }
43868
- timings.route += performance.now() - routeStartedAt;
43869
- const encodeStartedAt = performance.now();
43955
+ timings.route += monotonicNow() - routeStartedAt;
43956
+ const encodeStartedAt = monotonicNow();
43870
43957
  const body = args.body instanceof Uint8Array ? args.body : Buffer.from(JSON.stringify(moduleRequestBody(args.body, args.method)));
43871
- timings.encode += performance.now() - encodeStartedAt;
43872
- const issueStartedAt = performance.now();
43958
+ timings.encode += monotonicNow() - encodeStartedAt;
43959
+ const issueStartedAt = monotonicNow();
43873
43960
  const request = ensuredRoute.client.request(ensuredRoute.route, body, {
43874
43961
  priority: Priority.Background,
43875
43962
  admissionClass: AdmissionClass.Normal,
43876
43963
  timeoutMs: Math.max(1, attemptDeadlineMs - Date.now())
43877
43964
  });
43878
- timings.issue += performance.now() - issueStartedAt;
43879
- const waitStartedAt = performance.now();
43965
+ timings.issue += monotonicNow() - issueStartedAt;
43966
+ const waitStartedAt = monotonicNow();
43880
43967
  const response = await this.beforeDeadline(Promise.race([request, aborted]), attemptDeadlineMs, "waiting for the module response");
43881
- timings.responseWait += performance.now() - waitStartedAt;
43968
+ timings.responseWait += monotonicNow() - waitStartedAt;
43882
43969
  initialResponseReceived = true;
43883
43970
  if (this.client !== ensuredRoute.client || this.connectionGeneration !== ensuredRoute.generation) {
43884
43971
  throw this.connectionChangedError("subc connection changed while awaiting the module response");
@@ -43963,7 +44050,7 @@ class SubcModuleTransport {
43963
44050
  args.signal?.removeEventListener("abort", onAbort);
43964
44051
  finishWrapupTracking();
43965
44052
  releaseLane();
43966
- timings.settle = Math.max(0, performance.now() - callStartedAt - timings.lane - timings.route - timings.encode - timings.issue - timings.responseWait);
44053
+ timings.settle = Math.max(0, monotonicNow() - callStartedAt - timings.lane - timings.route - timings.encode - timings.issue - timings.responseWait);
43967
44054
  args.onTimings?.(timings);
43968
44055
  }
43969
44056
  }
@@ -44062,10 +44149,10 @@ class SubcModuleTransport {
44062
44149
  return resolved;
44063
44150
  }
44064
44151
  connectClient() {
44065
- return SubcClient.connect({
44152
+ return inRootAsyncContext(() => SubcClient.connect({
44066
44153
  connectionFile: this.connectionFile,
44067
44154
  handshakeTimeoutMs: HANDSHAKE_TIMEOUT_MS
44068
- });
44155
+ }));
44069
44156
  }
44070
44157
  backoffActiveError() {
44071
44158
  const error = new Error(`subc connection backoff active until ${this.nextProbeMs}`);
@@ -44152,13 +44239,14 @@ class SubcModuleTransport {
44152
44239
  client?.close();
44153
44240
  }
44154
44241
  }
44155
- var DEFAULT_MODULE_ID = "magic-context", CONNECT_BACKOFF_INITIAL_MS = 1000, CONNECT_BACKOFF_MAX_MS = 30000, CONNECT_BACKOFF_WAIT_BUDGET_MS = 12000, CONNECT_BACKOFF_WAIT_JITTER_MS = 100, HANDSHAKE_TIMEOUT_MS = 2000, MODULE_SEND_TIMEOUT_MS = 15000, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS = 5000, TRANSFORM_COLD_START_EXECUTE_TIMEOUT_MS = 15000, MAX_WRAPUP_REQUEST_BUDGET_MS = 3800000, SERIAL_LANE_MAX_WAITERS = 16, SERIAL_LANE_MAX_WAITERS_PER_SESSION = 8, SERIAL_LANE_MIN_REMAINING_MS = 25, CANONICAL_ROOT_CACHE_MAX_ENTRIES = 256;
44156
- var init_module_transport = __esm(() => {
44242
+ var DEFAULT_MODULE_ID = "magic-context", CONNECT_BACKOFF_INITIAL_MS = 1000, CONNECT_BACKOFF_MAX_MS = 30000, CONNECT_BACKOFF_WAIT_BUDGET_MS = 12000, CONNECT_BACKOFF_WAIT_JITTER_MS = 100, HANDSHAKE_TIMEOUT_MS = 2000, MODULE_SEND_TIMEOUT_MS = 15000, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS = 5000, TRANSFORM_COLD_START_EXECUTE_TIMEOUT_MS = 15000, MAX_WRAPUP_REQUEST_BUDGET_MS = 3800000, SERIAL_LANE_MAX_WAITERS = 16, SERIAL_LANE_MAX_WAITERS_PER_SESSION = 8, SERIAL_LANE_MIN_REMAINING_MS = 25, CANONICAL_ROOT_CACHE_MAX_ENTRIES = 256, monotonicClockForTests;
44243
+ var init_module_transport = __esm(async () => {
44157
44244
  init_dist5();
44158
44245
  init_data_path();
44159
44246
  init_reply_pages();
44160
44247
  init_single_store_refusal();
44161
44248
  init_store_ahead_refusal();
44249
+ await init_sqlite();
44162
44250
  });
44163
44251
 
44164
44252
  // src/commands/migrate-session.ts
@@ -44566,12 +44654,14 @@ var init_migrate_session = __esm(async () => {
44566
44654
  init_project_identity();
44567
44655
  init_relocate_memory();
44568
44656
  init_storage_project_state();
44569
- init_module_transport();
44570
44657
  init_data_path();
44571
44658
  init_opencode_db_path();
44572
44659
  init_migration_paths();
44573
44660
  init_prompts();
44574
- await init_database_access();
44661
+ await __promiseAll([
44662
+ init_module_transport(),
44663
+ init_database_access()
44664
+ ]);
44575
44665
  VALID_MEMORY_ACTIONS = new Set([
44576
44666
  "move-all",
44577
44667
  "move-originated",
@@ -45762,7 +45852,341 @@ var init_log_lines = __esm(() => {
45762
45852
  LEVEL_DEFAULT = LEVEL_ORDER.INFO;
45763
45853
  });
45764
45854
 
45855
+ // src/lib/redaction.ts
45856
+ function sanitizeDiagnosticEndpoint(value) {
45857
+ const trimmed = value.trim();
45858
+ if (!trimmed)
45859
+ return sanitizeDiagnosticText(value);
45860
+ try {
45861
+ const url = new URL(trimmed);
45862
+ url.username = "";
45863
+ url.password = "";
45864
+ url.search = "";
45865
+ url.hash = "";
45866
+ return sanitizeDiagnosticText(url.toString());
45867
+ } catch {
45868
+ const withoutQuery = trimmed.replace(/[?#].*$/, "");
45869
+ const withoutUserInfo = withoutQuery.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/i, "$1");
45870
+ return sanitizeDiagnosticText(withoutUserInfo);
45871
+ }
45872
+ }
45873
+ var init_redaction2 = __esm(() => {
45874
+ init_redaction();
45875
+ });
45876
+
45877
+ // src/lib/issue-privacy.ts
45878
+ class IssuePrivacy {
45879
+ notice = "_Paths and IDs use per-report aliases. Free text, private package names, and source/tool content are omitted; add reproduction steps directly to the issue after reviewing it._";
45880
+ projects = new Map;
45881
+ sessions = new Map;
45882
+ paths = new Map;
45883
+ constructor(report, projectDirectories = []) {
45884
+ this.discover(report);
45885
+ for (const directory of projectDirectories) {
45886
+ this.alias(this.projects, this.normalize(directory), "project");
45887
+ }
45888
+ }
45889
+ normalize(value) {
45890
+ let path = value.replaceAll("\\", "/");
45891
+ const home = (process.env.HOME || process.env.USERPROFILE || "").replaceAll("\\", "/");
45892
+ if (home && (path === home || path.startsWith(`${home}/`)))
45893
+ path = `~${path.slice(home.length)}`;
45894
+ return path.replace(/^(?:\/Users\/[^/]+|\/home\/[^/]+|[A-Za-z]:\/Users\/[^/]+)(?=\/|$)/, "~").replace(/\/$/, "");
45895
+ }
45896
+ alias(map, value, prefix) {
45897
+ let alias = map.get(value);
45898
+ if (!alias) {
45899
+ alias = `${prefix}-${new Set(map.values()).size + 1}`;
45900
+ map.set(value, alias);
45901
+ }
45902
+ return alias;
45903
+ }
45904
+ discover(value) {
45905
+ if (Array.isArray(value)) {
45906
+ for (const item of value)
45907
+ this.discover(item);
45908
+ } else if (value && typeof value === "object") {
45909
+ const record = value;
45910
+ const directory = typeof record.directory === "string" ? this.normalize(record.directory) : null;
45911
+ if (directory) {
45912
+ const alias = this.alias(this.projects, directory, "project");
45913
+ for (const [key, item] of Object.entries(record)) {
45914
+ if (PROJECT_KEY.test(key) && typeof item === "string")
45915
+ this.projects.set(this.normalize(item), alias);
45916
+ }
45917
+ }
45918
+ for (const [key, item] of Object.entries(record)) {
45919
+ if (key !== "flags")
45920
+ this.discover(item);
45921
+ }
45922
+ }
45923
+ }
45924
+ path(value) {
45925
+ const normalized = this.normalize(value);
45926
+ if (!normalized || normalized === "~")
45927
+ return normalized;
45928
+ for (const [root, alias] of [...this.projects].sort(([a], [b]) => b.length - a.length)) {
45929
+ if (normalized === root || normalized.startsWith(`${root}/`)) {
45930
+ return `${normalized.startsWith("~/") ? "~/" : ""}${alias}${normalized === root ? "" : "/<path>"}`;
45931
+ }
45932
+ }
45933
+ return `${normalized.startsWith("~/") ? "~/" : ""}${this.alias(this.paths, normalized, "path")}`;
45934
+ }
45935
+ session(value) {
45936
+ return value === "none" || !value ? value : this.alias(this.sessions, value, "session");
45937
+ }
45938
+ project(value) {
45939
+ if (value.startsWith("dir:"))
45940
+ return this.path(value.slice(4));
45941
+ return this.alias(this.projects, this.normalize(value), "project");
45942
+ }
45943
+ summary(value) {
45944
+ const safe = sanitizeDiagnosticText(value);
45945
+ const errors = [
45946
+ ...new Set(safe.match(/\b(?:[A-Z][A-Za-z]*Error|Error|SQLITE_[A-Z_]+|EACCES|EPERM|ENOENT|ENOSPC|ECONNRESET|ETIMEDOUT|MC-H[A-Z0-9-]+)\b/g) ?? [])
45947
+ ];
45948
+ if (/generation mismatch/i.test(safe))
45949
+ errors.push("store generation mismatch");
45950
+ if (/no such table/i.test(safe))
45951
+ errors.push("SQLITE_ERROR");
45952
+ if (/could not safely prepare this turn|refused\s*\(/i.test(safe))
45953
+ errors.push("refused");
45954
+ if (/\bfailed:|\bexception\b|\bEMERGENCY\b/i.test(safe))
45955
+ errors.push("failed");
45956
+ return errors.length ? `${errors.join(" ")}: ${OMITTED}` : OMITTED;
45957
+ }
45958
+ userText(value) {
45959
+ return value === "Magic Context diagnostic report" || value === "Generated non-interactively by `doctor --issue --report`." ? value : OMITTED;
45960
+ }
45961
+ logLine(line) {
45962
+ const parsed = parseLogLine(line);
45963
+ const safe = sanitizeDiagnosticText(line);
45964
+ const component = parsed?.tags.find((tag) => COMPONENTS.has(tag)) ?? [...COMPONENTS].find((name) => new RegExp(`\\b${name}\\b`).test(parsed?.message ?? ""));
45965
+ const logger = component ? `magic-context.${component}` : "magic-context";
45966
+ const session = parsed?.session ? ` [${this.session(parsed.session)}]` : "";
45967
+ const fields = Object.entries(parsed?.kv ?? {}).filter(([key, value]) => NUMERIC_FIELD.test(key) && /^\d+(?:\.\d+)?$/.test(value)).map(([key, value]) => `${key}=${value}`);
45968
+ const timings = safe.match(/\b\d+(?:\.\d+)?(?:ms|µs|us|s)\b/g) ?? [];
45969
+ const identities = [
45970
+ ...safe.matchAll(/\b(?:git:[a-f0-9]{16,64}|pj-[A-Za-z0-9_-]+|dir:[^\s"']+)/g)
45971
+ ].map(([id]) => this.project(id));
45972
+ return [
45973
+ parsed?.ts && /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/.test(parsed.ts) ? parsed.ts : "",
45974
+ parsed?.level ?? line.match(/^(TRACE|DEBUG|INFO|WARN|ERROR)\b/)?.[1] ?? "LOG",
45975
+ `${logger}${session}`,
45976
+ this.summary(line),
45977
+ ...fields,
45978
+ ...timings,
45979
+ ...identities
45980
+ ].filter(Boolean).join(" ");
45981
+ }
45982
+ healthMessage(value) {
45983
+ const labels = [
45984
+ "compaction.enabled",
45985
+ "memory.backend",
45986
+ "@cortexkit/pi-magic-context",
45987
+ "native compaction",
45988
+ "memory backend",
45989
+ "agent directory",
45990
+ "config",
45991
+ "plugin",
45992
+ "manifest",
45993
+ "Shared storage",
45994
+ "context DB",
45995
+ "SQLite integrity_check",
45996
+ "Background maintenance",
45997
+ "runtime log",
45998
+ "sessions",
45999
+ "package override"
46000
+ ];
46001
+ const label = labels.find((entry) => value.toLowerCase().includes(entry.toLowerCase())) ?? "host detection";
46002
+ const staticMessages = [
46003
+ "OMP native compaction is disabled",
46004
+ "OMP automatic memory backend is disabled",
46005
+ "SQLite integrity_check: ok",
46006
+ "Background maintenance completed its last pass",
46007
+ "Magic Context runtime config loads successfully",
46008
+ "Plugin exposes an OMP/Pi extension manifest",
46009
+ "Installed plugin has no OMP/Pi extension manifest"
46010
+ ];
46011
+ if (staticMessages.includes(value))
46012
+ return value;
46013
+ const paths = [...value.matchAll(/(?:[A-Za-z]:[\\/]|~\/|\/)[^\s,;)]+/g)].map(([path]) => this.path(path));
46014
+ const versions = value.match(/\b\d+\.\d+\.\d+\b/g) ?? [];
46015
+ const fields = [
46016
+ ...value.matchAll(/\b(grammar|lines|source)[=:]\s*(environment override|[\w-]+)/g)
46017
+ ].map(([, key, item]) => `${key}=${/^\d+$/.test(item) || ENUMS.has(item) ? item : OMITTED}`);
46018
+ const measurements = value.match(/\b\d+(?:\.\d+)?\s?(?:KB|MB|GB|ms|s)\b/g) ?? [];
46019
+ return [label, ...versions, ...paths, ...fields, ...measurements, this.summary(value)].join(" ");
46020
+ }
46021
+ report(value, key = "", config = false) {
46022
+ if (value === null || typeof value === "number" || typeof value === "boolean")
46023
+ return value;
46024
+ if (isSecretKey(key))
46025
+ return sanitizeConfigValue(value, [key]);
46026
+ if (Array.isArray(value))
46027
+ return value.map((item) => this.report(item, key, config));
46028
+ if (value && typeof value === "object") {
46029
+ return Object.fromEntries(Object.entries(value).map(([childKey, item]) => [
46030
+ key === "factCountByCategory" ? `category-${Object.keys(value).indexOf(childKey) + 1}` : /[\s/@\\:]|[a-f0-9]{24,}/i.test(childKey) ? "<key omitted>" : childKey,
46031
+ this.report(item, childKey, config || key === "flags")
46032
+ ]));
46033
+ }
46034
+ if (typeof value !== "string")
46035
+ return value;
46036
+ const safe = sanitizeDiagnosticText(value);
46037
+ if (/^<[^<>]*REDACTED[^<>]*>$/.test(safe))
46038
+ return safe;
46039
+ if (SESSION_KEY.test(key))
46040
+ return this.session(value);
46041
+ if (PROJECT_KEY.test(key) || /^(?:git:[a-f0-9]{16,64}|pj-)/.test(value))
46042
+ return this.project(value);
46043
+ if (PATH_KEY.test(key) || /^(?:~\/|\/|[A-Za-z]:[\\/]|file:)/.test(value))
46044
+ return this.path(value);
46045
+ if (VERSION_KEY.test(key) && VERSION.test(value))
46046
+ return value;
46047
+ if (/^(?:timestamp|lastActiveAt|lastFailureAt|lastRunAt|lastUpdatedAt)$/.test(key) && /^\d{4}-\d\d-\d\dT[\d:.]+Z$/.test(value))
46048
+ return value;
46049
+ if (MODEL_KEY.test(key) && /^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(safe) && !safe.includes("..") && !/^(?:git:|dir:|pj-)/.test(safe))
46050
+ return safe;
46051
+ if (ENUMS.has(value) || value === "")
46052
+ return value;
46053
+ if (config && (CONFIG_ENUMS.has(value) || key === "language" && /^[a-z]{2}$/.test(value)))
46054
+ return value;
46055
+ if (config)
46056
+ return OMITTED;
46057
+ return this.summary(value);
46058
+ }
46059
+ }
46060
+ var OMITTED = "<text omitted>", COMPONENTS, NUMERIC_FIELD, ENUMS, CONFIG_ENUMS, PATH_KEY, SESSION_KEY, PROJECT_KEY, VERSION_KEY, MODEL_KEY, VERSION;
46061
+ var init_issue_privacy = __esm(() => {
46062
+ init_log_lines();
46063
+ init_redaction2();
46064
+ COMPONENTS = new Set([
46065
+ "historian",
46066
+ "hist",
46067
+ "perf",
46068
+ "compaction",
46069
+ "dreamer",
46070
+ "janitor",
46071
+ "retina",
46072
+ "storage",
46073
+ "embedding",
46074
+ "transform",
46075
+ "session",
46076
+ "runtime",
46077
+ "config"
46078
+ ]);
46079
+ NUMERIC_FIELD = /^(?:duration_?ms|elapsed_?ms|latency_?ms|timeout_?ms|retry|retries|attempt|count|total|success|failed|noop|tokens|input_?tokens|output_?tokens|prompt_?tokens|completion_?tokens|bytes|size_?kb|lines|turns|messages|compartments|pruned|kept)$/i;
46080
+ ENUMS = new Set([
46081
+ "true",
46082
+ "false",
46083
+ "on",
46084
+ "off",
46085
+ "auto",
46086
+ "none",
46087
+ "unknown",
46088
+ "local",
46089
+ "remote",
46090
+ "disabled",
46091
+ "enabled",
46092
+ "default",
46093
+ "debug",
46094
+ "info",
46095
+ "warn",
46096
+ "error",
46097
+ "trace",
46098
+ "cli",
46099
+ "desktop",
46100
+ "darwin",
46101
+ "linux",
46102
+ "win32",
46103
+ "arm64",
46104
+ "x64",
46105
+ "ia32",
46106
+ "json",
46107
+ "jsonc",
46108
+ "opencode1",
46109
+ "opencode2",
46110
+ "fleet-r1",
46111
+ "fleet-r2",
46112
+ "legacy",
46113
+ "mixed",
46114
+ "PATH",
46115
+ "path",
46116
+ "app",
46117
+ "openchamber",
46118
+ "environment override",
46119
+ "OPENCODE_DB",
46120
+ "stable",
46121
+ "beta",
46122
+ "latest",
46123
+ "query error",
46124
+ "path missing",
46125
+ "schema too old"
46126
+ ]);
46127
+ CONFIG_ENUMS = new Set([
46128
+ "ts",
46129
+ "rust",
46130
+ "broca",
46131
+ "host",
46132
+ "minimal",
46133
+ "low",
46134
+ "medium",
46135
+ "high",
46136
+ "xhigh",
46137
+ "max",
46138
+ "inherit",
46139
+ "full",
46140
+ "light",
46141
+ "synapse",
46142
+ "native",
46143
+ "wasm",
46144
+ "fp32",
46145
+ "fp16",
46146
+ "q8",
46147
+ "int8",
46148
+ "uint8",
46149
+ "q4",
46150
+ "bnb4",
46151
+ "q4f16",
46152
+ "q2",
46153
+ "q2f16",
46154
+ "q1",
46155
+ "q1f16",
46156
+ "*",
46157
+ "read",
46158
+ "aft_outline",
46159
+ "aft_zoom",
46160
+ "aft_search",
46161
+ "subagent",
46162
+ "primary",
46163
+ "all",
46164
+ "ask",
46165
+ "allow",
46166
+ "deny"
46167
+ ]);
46168
+ PATH_KEY = /^(?:path|dir|directory|configDir|agentDir|opencodeConfig|magicContextConfig|tuiConfig|omoConfig|userConfig|projectConfig|loadedConfigPaths|piPath)$/;
46169
+ SESSION_KEY = /session_?ids?$/i;
46170
+ PROJECT_KEY = /^(?:project|project_?id|projectKey|rootCommit|root_commit|rootCommitHash)$/i;
46171
+ VERSION_KEY = /(?:version|cached|latest|spec)$/i;
46172
+ MODEL_KEY = /^(?:model|models|provider|providerID|modelID|fallback_provider|fallback_model|fallback_models|model_chain)$/i;
46173
+ VERSION = /^(?:(?:opencode|pi|omp)\s+)?v?\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/;
46174
+ });
46175
+
45765
46176
  // src/lib/issue-body.ts
46177
+ function prepareIssueReport(report, lines, sessionFilter = null, projectDirectories = [process.cwd()]) {
46178
+ const privacy = new IssuePrivacy(report, projectDirectories);
46179
+ const logLines = filterLogLinesBySession(lines, sessionFilter);
46180
+ return {
46181
+ privacy,
46182
+ report: privacy.report(report),
46183
+ logLines,
46184
+ recentLog: logLines.slice(-400).map((line) => privacy.logLine(line)).join(`
46185
+ `).trim(),
46186
+ recentErrorLines: extractRecentErrors(logLines.slice(-4000).join(`
46187
+ `), 20).map((line) => privacy.logLine(line))
46188
+ };
46189
+ }
45766
46190
  function isErrorLogLine(line) {
45767
46191
  const parsed = parseLogLine(line);
45768
46192
  if (parsed?.level !== null && parsed?.level !== undefined) {
@@ -45893,6 +46317,7 @@ var MAX_GITHUB_BODY_BYTES = 60000, LOG_TRUNCATION_MARKER = `[truncated for GitHu
45893
46317
  [truncated for GitHub 64KB limit]
45894
46318
  `, ERROR_LOG_PATTERNS;
45895
46319
  var init_issue_body = __esm(() => {
46320
+ init_issue_privacy();
45896
46321
  init_log_lines();
45897
46322
  ERROR_LOG_PATTERNS = [
45898
46323
  /\bfailed:/i,
@@ -45907,28 +46332,6 @@ var init_issue_body = __esm(() => {
45907
46332
  ];
45908
46333
  });
45909
46334
 
45910
- // src/lib/redaction.ts
45911
- function sanitizeDiagnosticEndpoint(value) {
45912
- const trimmed = value.trim();
45913
- if (!trimmed)
45914
- return sanitizeDiagnosticText(value);
45915
- try {
45916
- const url = new URL(trimmed);
45917
- url.username = "";
45918
- url.password = "";
45919
- url.search = "";
45920
- url.hash = "";
45921
- return sanitizeDiagnosticText(url.toString());
45922
- } catch {
45923
- const withoutQuery = trimmed.replace(/[?#].*$/, "");
45924
- const withoutUserInfo = withoutQuery.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/i, "$1");
45925
- return sanitizeDiagnosticText(withoutUserInfo);
45926
- }
45927
- }
45928
- var init_redaction2 = __esm(() => {
45929
- init_redaction();
45930
- });
45931
-
45932
46335
  // src/commands/doctor-omp.ts
45933
46336
  import { execFileSync as execFileSync8, spawnSync as spawnSync8 } from "node:child_process";
45934
46337
  import { existsSync as existsSync42, readFileSync as readFileSync24 } from "node:fs";
@@ -46198,27 +46601,24 @@ async function repair(plan, deps, prompts, cwd) {
46198
46601
  function timestamp2(date) {
46199
46602
  return date.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
46200
46603
  }
46201
- function ompIssueBody(description, report, logLines, sessionFilter) {
46604
+ function ompIssueBody(description, report, logLines, sessionFilter, cwd) {
46202
46605
  const LOG_TAIL_LINES = 400;
46203
- const filteredLogLines = filterLogLinesBySession(logLines, sessionFilter);
46204
- const recentLog = sanitizeDiagnosticText(filteredLogLines.slice(-LOG_TAIL_LINES).join(`
46205
- `)).trim();
46206
- const errorScanWindow = sanitizeDiagnosticText(filteredLogLines.slice(-4000).join(`
46207
- `));
46208
- const recentErrorLines = extractRecentErrors(errorScanWindow, 20);
46606
+ const { privacy, recentLog, recentErrorLines } = prepareIssueReport(report, logLines, sessionFilter, [cwd]);
46209
46607
  return [
46210
46608
  "## Description",
46211
- sanitizeDiagnosticText(description),
46609
+ privacy.userText(description),
46610
+ "",
46611
+ privacy.notice,
46212
46612
  "",
46213
46613
  "## Environment",
46214
- `- Magic Context plugin: ${report.pluginVersion ? `v${sanitizeDiagnosticText(report.pluginVersion)}` : "not installed"}`,
46215
- `- Oh My Pi: ${report.ompVersion ? sanitizeDiagnosticText(report.ompVersion) : "not detected"}`,
46614
+ `- Magic Context plugin: ${report.pluginVersion ? `v${privacy.report(report.pluginVersion, "pluginVersion")}` : "not installed"}`,
46615
+ `- Oh My Pi: ${report.ompVersion ? privacy.report(report.ompVersion, "ompVersion") : "not detected"}`,
46216
46616
  `- OS: ${process.platform} ${process.arch}`,
46217
46617
  `- Runtime: Node.js ${process.version}`,
46218
46618
  "",
46219
46619
  "## OMP diagnostics",
46220
46620
  `- Magic Context CLI: v${selfVersion()}`,
46221
- ...report.results.map((result) => `- ${result.status.toUpperCase()}: ${sanitizeDiagnosticText(result.message)}`),
46621
+ ...report.results.map((result) => `- ${result.status.toUpperCase()}: ${privacy.healthMessage(result.message)}`),
46222
46622
  "",
46223
46623
  "## Recent errors (last 20, sanitized)",
46224
46624
  recentErrorLines.length === 0 ? "_No error-shaped log lines found in recent history._" : ["```", recentErrorLines.join(`
@@ -46276,7 +46676,7 @@ async function runIssueFlow(options) {
46276
46676
  if (options.reportPath) {
46277
46677
  const report = await runHealthChecks({ ...options, quiet: true });
46278
46678
  const path = isAbsolute8(options.reportPath) ? options.reportPath : join34(options.cwd, options.reportPath);
46279
- const bundle = writeOmpIssueReport(path, ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report, readLogLines(report.logFiles), null));
46679
+ const bundle = writeOmpIssueReport(path, ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report, readLogLines(report.logFiles), null, options.cwd));
46280
46680
  options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
46281
46681
  return 0;
46282
46682
  }
@@ -46303,7 +46703,7 @@ async function runIssueFlow(options) {
46303
46703
  sessionFilter = choice === "__all__" ? null : choice;
46304
46704
  }
46305
46705
  const path = join34(options.cwd, `magic-context-omp-issue-${timestamp2(options.deps.now())}.md`);
46306
- const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter));
46706
+ const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter, options.cwd));
46307
46707
  options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
46308
46708
  if (await options.prompts.confirm("Submit this issue on GitHub now?", false)) {
46309
46709
  const result = submitGithubIssue(`[omp] ${title}`, bundle.path, (args) => runGhCommandWithDeps(options.deps, args));
@@ -46359,7 +46759,6 @@ var init_doctor_omp = __esm(async () => {
46359
46759
  init_omp_helpers();
46360
46760
  init_paths();
46361
46761
  init_prompts();
46362
- init_redaction2();
46363
46762
  await init_database_access();
46364
46763
  import_comment_json8 = __toESM(require_src3(), 1);
46365
46764
  DEFAULT_DEPS4 = {
@@ -46781,7 +47180,7 @@ async function getSharedClient(options) {
46781
47180
  if (sharedClientPromise && sharedClientFile === options.connectionFile)
46782
47181
  return sharedClientPromise;
46783
47182
  sharedClientFile = options.connectionFile;
46784
- sharedClientPromise = SubcClient.connect({ connectionFile: options.connectionFile }).then((client) => {
47183
+ sharedClientPromise = inRootAsyncContext(() => SubcClient.connect({ connectionFile: options.connectionFile })).then((client) => {
46785
47184
  sharedClient = client;
46786
47185
  return client;
46787
47186
  });
@@ -47166,10 +47565,11 @@ class SynapseEmbeddingProvider {
47166
47565
  }
47167
47566
  }
47168
47567
  var SYNAPSE_DEFAULT_MODEL = "gte-modernbert-base-f16", SYNAPSE_DEFAULT_QUERY_TIMEOUT_MS = 3000, SYNAPSE_DEFAULT_BATCH_TIMEOUT_MS = 120000, SYNAPSE_CERTIFICATION_REFUSAL_REASONS, embeddingRowMetadata, SynapseEmbeddingError, sharedClient = null, sharedClientFile = null, sharedClientPromise = null, factoryClients;
47169
- var init_embedding_synapse = __esm(() => {
47568
+ var init_embedding_synapse = __esm(async () => {
47170
47569
  init_dist5();
47171
47570
  init_read_session_formatting();
47172
47571
  init_logger();
47572
+ await init_sqlite();
47173
47573
  SYNAPSE_CERTIFICATION_REFUSAL_REASONS = new Set([
47174
47574
  "not_certified",
47175
47575
  "probe_required",
@@ -48001,20 +48401,21 @@ var init_embedding_model_match = () => {};
48001
48401
  var init_normalize_hash = () => {};
48002
48402
 
48003
48403
  // ../plugin/src/features/magic-context/memory/embedding-identity.ts
48004
- var init_embedding_identity = __esm(() => {
48404
+ var init_embedding_identity = __esm(async () => {
48005
48405
  init_magic_context();
48006
48406
  init_embedding_model_match();
48007
- init_embedding_synapse();
48008
48407
  init_normalize_hash();
48408
+ await init_embedding_synapse();
48009
48409
  });
48010
48410
 
48011
48411
  // ../plugin/src/features/magic-context/memory/onnx-telemetry.ts
48012
48412
  var init_onnx_telemetry = () => {};
48013
48413
 
48014
48414
  // ../plugin/src/features/magic-context/memory/embedding-worker-client.ts
48015
- var init_embedding_worker_client = __esm(() => {
48415
+ var init_embedding_worker_client = __esm(async () => {
48016
48416
  init_logger();
48017
48417
  init_onnx_telemetry();
48418
+ await init_sqlite();
48018
48419
  });
48019
48420
  // ../plugin/src/features/magic-context/memory/embedding-local.ts
48020
48421
  function currentLocalEmbeddingHost() {
@@ -48050,14 +48451,17 @@ function resolveLocalEmbeddingWorkerRuntime(preference = "auto", host = currentL
48050
48451
  return resolveLocalEmbeddingRuntime(preference, host);
48051
48452
  }
48052
48453
  var BUN_NAPI_TEARDOWN_FIX_VERSION, STALE_LOCK_MS, MAX_LOCK_WAIT_MS, loadedLocalEmbeddingRuntimes;
48053
- var init_embedding_local = __esm(() => {
48454
+ var init_embedding_local = __esm(async () => {
48054
48455
  init_magic_context();
48055
48456
  init_data_path();
48056
48457
  init_logger();
48057
48458
  init_stale_plugin_build();
48058
48459
  init_storage_permissions();
48059
- init_embedding_identity();
48060
- init_embedding_worker_client();
48460
+ await __promiseAll([
48461
+ init_embedding_identity(),
48462
+ init_embedding_worker_client(),
48463
+ init_sqlite()
48464
+ ]);
48061
48465
  BUN_NAPI_TEARDOWN_FIX_VERSION = [1, 4, 0];
48062
48466
  STALE_LOCK_MS = 3 * 60000;
48063
48467
  MAX_LOCK_WAIT_MS = 5 * 60000;
@@ -48409,8 +48813,8 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
48409
48813
  return withWasmFallback(native, () => probeWasmRuntimeByResolution(pluginDir));
48410
48814
  }
48411
48815
  var ONNX_LOAD_PROBE_TIMEOUT_MS = 1e4, ONNX_LOAD_PROBE_OUTPUT_LIMIT = 800, ONNX_LOAD_PROBE_PACKAGE_DIR_ENV = "MAGIC_CONTEXT_ONNX_RUNTIME_NODE_PACKAGE_DIR", ONNX_RUNTIME_NODE_LOAD_PROBE_SCRIPT, runOnnxRuntimeNodeLoadProbeChildForRuntime, HUGGING_FACE_DOWNLOAD_MIRROR_HINT = " If a Hugging Face model download fails because huggingface.co is unreachable, set HF_ENDPOINT to a compatible mirror.";
48412
- var init_embedding_runtime = __esm(() => {
48413
- init_embedding_local();
48816
+ var init_embedding_runtime = __esm(async () => {
48817
+ await init_embedding_local();
48414
48818
  ONNX_RUNTIME_NODE_LOAD_PROBE_SCRIPT = [
48415
48819
  'const { createRequire } = require("node:module");',
48416
48820
  'const { join } = require("node:path");',
@@ -48436,9 +48840,6 @@ var init_embedding_runtime = __esm(() => {
48436
48840
  // src/lib/logs-opencode.ts
48437
48841
  import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
48438
48842
  import { dirname as dirname25, join as join38 } from "node:path";
48439
- function sanitizeLogContent(content) {
48440
- return sanitizeDiagnosticText(content);
48441
- }
48442
48843
  function formatTimestamp(date) {
48443
48844
  const pad = (value) => String(value).padStart(2, "0");
48444
48845
  return [
@@ -48468,20 +48869,17 @@ function extractHistorianFailureLines(sanitized, limit = 30) {
48468
48869
  async function bundleIssueReport(report, description, title, sessionFilter = null, options = {}) {
48469
48870
  const LOG_TAIL_LINES = 400;
48470
48871
  const allLogLines = readLogLines(report.logFiles ?? [report.logFile]);
48471
- const logLines = filterLogLinesBySession(allLogLines, sessionFilter);
48472
- const recentLog = sanitizeLogContent(logLines.slice(-LOG_TAIL_LINES).join(`
48473
- `)).trim();
48474
- const historianScanWindow = sanitizeLogContent(logLines.slice(-4000).join(`
48475
- `));
48476
- const historianFailureLines = extractHistorianFailureLines(historianScanWindow, 30);
48477
- const errorScanWindow = sanitizeLogContent(logLines.slice(-4000).join(`
48478
- `));
48479
- const recentErrorLines = extractRecentErrors(errorScanWindow, 20);
48872
+ const prepared = prepareIssueReport(report, allLogLines, sessionFilter);
48873
+ const { privacy, logLines, recentLog, recentErrorLines } = prepared;
48874
+ report = prepared.report;
48875
+ const historianScanWindow = logLines.slice(-4000).join(`
48876
+ `);
48877
+ const historianFailureLines = extractHistorianFailureLines(historianScanWindow, 30).map((line) => privacy.logLine(line));
48480
48878
  const configBody = JSON.stringify(sanitizeConfigValue(report.magicContextConfig.flags), null, 2);
48481
48879
  const sanitizedConfigPath = sanitizeDiagnosticText(report.configPaths.magicContextConfig);
48482
- const sanitizedDescription = sanitizeDiagnosticText(description);
48483
- const sanitizedTitle = sanitizeDiagnosticText(title).trim();
48484
- const selectedSession = sessionFilter ? (report.recentSessions.available ? report.recentSessions.rows : []).find((session) => session.sessionId === sessionFilter) : undefined;
48880
+ const sanitizedDescription = privacy.userText(description);
48881
+ const sanitizedTitle = privacy.userText(title).trim();
48882
+ const selectedSession = sessionFilter ? (report.recentSessions.available ? report.recentSessions.rows : []).find((session) => session.sessionId === privacy.session(sessionFilter)) : undefined;
48485
48883
  const sessionContext = selectedSession ? [
48486
48884
  "## Session context",
48487
48885
  `- Selected session: ${sanitizeDiagnosticText(selectedSession.sessionId)}`,
@@ -48494,6 +48892,8 @@ async function bundleIssueReport(report, description, title, sessionFilter = nul
48494
48892
  "## Description",
48495
48893
  sanitizedDescription,
48496
48894
  "",
48895
+ privacy.notice,
48896
+ "",
48497
48897
  "## Environment",
48498
48898
  `- Plugin: v${report.pluginVersion}`,
48499
48899
  `- OS: ${report.platform} ${report.arch}`,
@@ -49362,14 +49762,16 @@ function formatSharedDbRowCounts(db) {
49362
49762
  }
49363
49763
  function findUndeclaredConfiguredVariants(configured, catalog) {
49364
49764
  return configured.filter((entry) => {
49365
- const [providerID, id] = entry.model.split("/", 2);
49765
+ const [providerID, ...modelParts] = entry.model.split("/");
49766
+ const id = modelParts.join("/");
49366
49767
  const model = catalog.find((item) => item.providerID === providerID && item.id === id);
49367
49768
  return model !== undefined && !Object.hasOwn(model.variants, entry.variant);
49368
49769
  });
49369
49770
  }
49370
49771
  function findUnknownConfiguredModels(configured, catalog) {
49371
49772
  return configured.flatMap((entry) => {
49372
- const [providerID, id] = entry.model.split("/", 2);
49773
+ const [providerID, ...modelParts] = entry.model.split("/");
49774
+ const id = modelParts.join("/");
49373
49775
  if (!catalog.some((item) => item.providerID === providerID)) {
49374
49776
  return [{ ...entry, unknown: "provider" }];
49375
49777
  }
@@ -50695,7 +51097,6 @@ var init_doctor_opencode = __esm(async () => {
50695
51097
  init_removed_agent_config();
50696
51098
  init_variable();
50697
51099
  init_tick_failure();
50698
- init_embedding_synapse();
50699
51100
  init_auto_update_provenance();
50700
51101
  init_conflict_detector();
50701
51102
  init_conflict_fixer();
@@ -50705,7 +51106,6 @@ var init_doctor_opencode = __esm(async () => {
50705
51106
  init_tui_config();
50706
51107
  init_atomic_write();
50707
51108
  init_config_location_migration();
50708
- init_embedding_runtime();
50709
51109
  init_github_issue();
50710
51110
  init_log_lines();
50711
51111
  init_migrate_dreamer_v2_doctor();
@@ -50713,17 +51113,19 @@ var init_doctor_opencode = __esm(async () => {
50713
51113
  init_opencode_helpers();
50714
51114
  init_opencode_plugin_cache();
50715
51115
  init_opencode_plugin_registration();
50716
- init_opencode_plugin_schema_fence();
50717
51116
  init_paths();
50718
51117
  init_prompts();
50719
51118
  init_redaction2();
50720
51119
  await __promiseAll([
51120
+ init_embedding_synapse(),
50721
51121
  init_storage_db(),
50722
51122
  init_sqlite(),
50723
51123
  init_opencode(),
50724
51124
  init_database_access(),
50725
51125
  init_diagnostics_opencode(),
51126
+ init_embedding_runtime(),
50726
51127
  init_logs_opencode(),
51128
+ init_opencode_plugin_schema_fence(),
50727
51129
  init_storage_versions(),
50728
51130
  init_v22_backfill_commands(),
50729
51131
  init_doctor_cached_plugin_fence(),
@@ -51331,9 +51733,6 @@ var init_diagnostics_pi = __esm(() => {
51331
51733
  // src/lib/logs-pi.ts
51332
51734
  import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
51333
51735
  import { dirname as dirname27, join as join41 } from "node:path";
51334
- function sanitizeLogContent2(content) {
51335
- return sanitizeString2(content);
51336
- }
51337
51736
  function formatTimestamp2(date) {
51338
51737
  const pad = (value) => String(value).padStart(2, "0");
51339
51738
  return [
@@ -51349,18 +51748,19 @@ function formatTimestamp2(date) {
51349
51748
  async function bundleIssueReport2(report, description, title, options = {}) {
51350
51749
  const LOG_TAIL_LINES = 400;
51351
51750
  const allLogLines = readLogLines(report.logFiles ?? [report.logFile]);
51352
- const logLines = filterLogLinesBySession(allLogLines, options.sessionFilter ?? null);
51353
- const recentLog = sanitizeLogContent2(logLines.slice(-LOG_TAIL_LINES).join(`
51354
- `)).trim();
51355
- const errorScanWindow = sanitizeLogContent2(logLines.slice(-4000).join(`
51356
- `));
51357
- const recentErrorLines = extractRecentErrors(errorScanWindow, 20);
51751
+ const prepared = prepareIssueReport(report, allLogLines, options.sessionFilter ?? null, [
51752
+ options.cwd ?? process.cwd()
51753
+ ]);
51754
+ const { privacy, recentLog, recentErrorLines } = prepared;
51755
+ report = prepared.report;
51358
51756
  const rawBodyMarkdown = [
51359
51757
  "## Title",
51360
- `[pi] ${sanitizeString2(title)}`,
51758
+ `[pi] ${privacy.userText(title)}`,
51361
51759
  "",
51362
51760
  "## Description",
51363
- sanitizeString2(description),
51761
+ privacy.userText(description),
51762
+ "",
51763
+ privacy.notice,
51364
51764
  "",
51365
51765
  "## Environment",
51366
51766
  `- Pi plugin: v${report.pluginVersion}`,
@@ -52309,7 +52709,6 @@ var init_doctor_pi = __esm(async () => {
52309
52709
  init_raw_loader();
52310
52710
  init_variable();
52311
52711
  init_tick_failure();
52312
- init_embedding_synapse();
52313
52712
  init_data_path();
52314
52713
  init_jsonc_edit();
52315
52714
  init_jsonc_parser();
@@ -52318,7 +52717,6 @@ var init_doctor_pi = __esm(async () => {
52318
52717
  init_atomic_write();
52319
52718
  init_config_location_migration();
52320
52719
  init_diagnostics_pi();
52321
- init_embedding_runtime();
52322
52720
  init_github_issue();
52323
52721
  init_log_lines();
52324
52722
  init_logs_pi();
@@ -52329,8 +52727,10 @@ var init_doctor_pi = __esm(async () => {
52329
52727
  init_redaction2();
52330
52728
  init_setup_pi();
52331
52729
  await __promiseAll([
52730
+ init_embedding_synapse(),
52332
52731
  init_storage_db(),
52333
52732
  init_database_access(),
52733
+ init_embedding_runtime(),
52334
52734
  init_storage_versions(),
52335
52735
  init_v22_backfill_commands()
52336
52736
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/magic-context",
3
- "version": "0.49.6",
3
+ "version": "0.49.8",
4
4
  "description": "Unified CLI for Magic Context — setup, doctor, and migration across OpenCode, Pi, and OMP",
5
5
  "keywords": [
6
6
  "opencode",