@cortexkit/magic-context 0.49.7 → 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.
- package/dist/index.js +477 -120
- 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-
|
|
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,8 +12839,11 @@ __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
|
}
|
|
@@ -12988,7 +12997,7 @@ function installTransactionRouting(db, readonly) {
|
|
|
12988
12997
|
return endWriterTransaction(db, () => nativeExec(sql), sql);
|
|
12989
12998
|
if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
|
|
12990
12999
|
try {
|
|
12991
|
-
return withAutocommitTimeout(db, () => nativeExec(sql));
|
|
13000
|
+
return withAutocommitTimeout(db, () => nativeExec(sql), false);
|
|
12992
13001
|
} finally {
|
|
12993
13002
|
if (mayChangeTagIdentity(sql))
|
|
12994
13003
|
tagIdentityWriteGeneration += 1;
|
|
@@ -13349,29 +13358,48 @@ function foregroundWaitLease() {
|
|
|
13349
13358
|
const lease = transformPassScope.getStore();
|
|
13350
13359
|
return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
|
|
13351
13360
|
}
|
|
13352
|
-
function withAutocommitTimeout(db, operation) {
|
|
13361
|
+
function withAutocommitTimeout(db, operation, singleStatement = true) {
|
|
13353
13362
|
assertTransformWrite();
|
|
13354
13363
|
const lease = foregroundWaitLease();
|
|
13355
13364
|
if (isInTransaction(db))
|
|
13356
13365
|
return operation();
|
|
13357
13366
|
const scoped = lease || backgroundWriterScope.getStore();
|
|
13358
13367
|
const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
|
|
13359
|
-
if (scoped)
|
|
13360
|
-
db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
|
|
13361
13368
|
const started = performance.now();
|
|
13362
13369
|
let completed = false;
|
|
13363
|
-
|
|
13370
|
+
const execute = () => {
|
|
13364
13371
|
const result = operation();
|
|
13365
13372
|
completed = true;
|
|
13366
13373
|
return result;
|
|
13374
|
+
};
|
|
13375
|
+
try {
|
|
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
|
+
}
|
|
13367
13397
|
} catch (error) {
|
|
13368
13398
|
if (lease && isTransientSqliteError(error))
|
|
13369
13399
|
throw new SqliteAcquisitionBusyError(error, "autocommit");
|
|
13370
13400
|
throw error;
|
|
13371
13401
|
} finally {
|
|
13372
13402
|
const elapsed = performance.now() - started;
|
|
13373
|
-
if (lease)
|
|
13374
|
-
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
|
|
13375
13403
|
if (previous !== null)
|
|
13376
13404
|
db.exec(`PRAGMA busy_timeout=${previous}`);
|
|
13377
13405
|
if (elapsed >= SLOW_WRITER_LOG_MS)
|
|
@@ -13624,8 +13652,9 @@ async function withIndexChunk(input, operation) {
|
|
|
13624
13652
|
async function yieldIndexChunk() {
|
|
13625
13653
|
await yieldIndexTurn();
|
|
13626
13654
|
}
|
|
13627
|
-
var 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));
|
|
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));
|
|
13628
13656
|
var init_sqlite = __esm(async () => {
|
|
13657
|
+
resourceRoot = new AsyncResource("magic-context:root");
|
|
13629
13658
|
bunSpec = "bun:" + "sqlite";
|
|
13630
13659
|
nodeSpec = "node:" + "sqlite";
|
|
13631
13660
|
SqliteRuntimeUnavailableError = class SqliteRuntimeUnavailableError extends Error {
|
|
@@ -13659,7 +13688,7 @@ var init_sqlite = __esm(async () => {
|
|
|
13659
13688
|
]);
|
|
13660
13689
|
TrackedDatabase = new Proxy(DatabaseImpl, {
|
|
13661
13690
|
construct(target, args) {
|
|
13662
|
-
const db = Reflect.construct(target, args, target);
|
|
13691
|
+
const db = inRootAsyncContext(() => Reflect.construct(target, args, target));
|
|
13663
13692
|
return trackSqliteConnection(db, args[0], args[1]);
|
|
13664
13693
|
}
|
|
13665
13694
|
});
|
|
@@ -25099,11 +25128,14 @@ function bootQuietRemainingMs(now = Date.now()) {
|
|
|
25099
25128
|
return Math.max(0, bootQuietUntilMs - now);
|
|
25100
25129
|
}
|
|
25101
25130
|
function scheduleAfterBootQuiet(task, additionalDelayMs = 0) {
|
|
25102
|
-
const timer = setTimeout(task, bootQuietRemainingMs() + Math.max(0, additionalDelayMs));
|
|
25131
|
+
const timer = inRootAsyncContext(() => setTimeout(task, bootQuietRemainingMs() + Math.max(0, additionalDelayMs)));
|
|
25103
25132
|
timer.unref?.();
|
|
25104
25133
|
return timer;
|
|
25105
25134
|
}
|
|
25106
25135
|
var bootQuietUntilMs = 0;
|
|
25136
|
+
var init_boot_quiet = __esm(async () => {
|
|
25137
|
+
await init_sqlite();
|
|
25138
|
+
});
|
|
25107
25139
|
|
|
25108
25140
|
// ../plugin/src/shared/error-message.ts
|
|
25109
25141
|
function getErrorMessage(error) {
|
|
@@ -25888,9 +25920,10 @@ END`
|
|
|
25888
25920
|
var init_off_thread_migration_clock = () => {};
|
|
25889
25921
|
|
|
25890
25922
|
// ../plugin/src/features/magic-context/migration-worker-client.ts
|
|
25891
|
-
var init_migration_worker_client = __esm(() => {
|
|
25923
|
+
var init_migration_worker_client = __esm(async () => {
|
|
25892
25924
|
init_logger();
|
|
25893
25925
|
init_off_thread_migration_clock();
|
|
25926
|
+
await init_sqlite();
|
|
25894
25927
|
});
|
|
25895
25928
|
|
|
25896
25929
|
// ../plugin/src/features/magic-context/memory/constants.ts
|
|
@@ -32212,7 +32245,7 @@ function runSessionWarmupWorker(input, options) {
|
|
|
32212
32245
|
deadline.unref?.();
|
|
32213
32246
|
};
|
|
32214
32247
|
try {
|
|
32215
|
-
worker = new Worker(options.entry ?? defaultEntry(), { workerData: input });
|
|
32248
|
+
worker = inRootAsyncContext(() => new Worker(options.entry ?? defaultEntry(), { workerData: input }));
|
|
32216
32249
|
} catch (error) {
|
|
32217
32250
|
finish({ failure: "start-failed", detail: String(error) });
|
|
32218
32251
|
return;
|
|
@@ -32302,7 +32335,8 @@ var init_raw_ordinal_warmup = __esm(async () => {
|
|
|
32302
32335
|
init_logger();
|
|
32303
32336
|
await __promiseAll([
|
|
32304
32337
|
init_sqlite(),
|
|
32305
|
-
init_read_session_raw()
|
|
32338
|
+
init_read_session_raw(),
|
|
32339
|
+
init_sqlite()
|
|
32306
32340
|
]);
|
|
32307
32341
|
RESULT_TIMEOUT_MS = 10 * 60000;
|
|
32308
32342
|
FAILURE_BACKOFF_MS = 5 * 60000;
|
|
@@ -33361,13 +33395,20 @@ function readRawSessionMessageOrdinalById(sessionId, messageId) {
|
|
|
33361
33395
|
return null;
|
|
33362
33396
|
return withReadOnlySessionDb((db) => readRawSessionMessageOrdinalByIdFromDb(db, sessionId, messageId));
|
|
33363
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
|
+
}
|
|
33364
33405
|
function compareRawSessionMessageOrder(sessionId, leftId, rightId) {
|
|
33365
33406
|
const provider = sessionProviders.get(sessionId)?.provider;
|
|
33366
33407
|
if (provider) {
|
|
33367
|
-
if (!provider.readMessageOrdinalById)
|
|
33408
|
+
if (!provider.readMessageOrderById && !provider.readMessageOrdinalById)
|
|
33368
33409
|
return null;
|
|
33369
|
-
const left =
|
|
33370
|
-
const right =
|
|
33410
|
+
const left = readRawSessionMessageOrderPosition(sessionId, leftId);
|
|
33411
|
+
const right = readRawSessionMessageOrderPosition(sessionId, rightId);
|
|
33371
33412
|
return left === null || right === null ? null : left - right;
|
|
33372
33413
|
}
|
|
33373
33414
|
if (!openCodeDbExists())
|
|
@@ -35842,15 +35883,16 @@ var init_storage_db = __esm(async () => {
|
|
|
35842
35883
|
init_fail_closed_block();
|
|
35843
35884
|
init_migration_v94_write_split();
|
|
35844
35885
|
init_migration_v95_perf_indexes();
|
|
35845
|
-
init_migration_worker_client();
|
|
35846
35886
|
init_storage_schema_helpers();
|
|
35847
35887
|
init_storage_tag_identity_revision();
|
|
35848
35888
|
init_tool_definition_tokens();
|
|
35849
35889
|
init_tool_owner_backfill();
|
|
35850
35890
|
await __promiseAll([
|
|
35891
|
+
init_boot_quiet(),
|
|
35851
35892
|
init_sqlite(),
|
|
35852
35893
|
init_context_store_uuid(),
|
|
35853
35894
|
init_message_fts_rowid_map(),
|
|
35895
|
+
init_migration_worker_client(),
|
|
35854
35896
|
init_migrations()
|
|
35855
35897
|
]);
|
|
35856
35898
|
registerSlowWriteReporter(logSlowWriteTransaction);
|
|
@@ -37835,10 +37877,11 @@ function findPluginEntry(directory, surface = "server") {
|
|
|
37835
37877
|
};
|
|
37836
37878
|
}
|
|
37837
37879
|
var import_comment_json7;
|
|
37838
|
-
var init_checker = __esm(() => {
|
|
37880
|
+
var init_checker = __esm(async () => {
|
|
37839
37881
|
init_logger();
|
|
37840
37882
|
init_constants2();
|
|
37841
37883
|
init_types();
|
|
37884
|
+
await init_sqlite();
|
|
37842
37885
|
import_comment_json7 = __toESM(require_src3(), 1);
|
|
37843
37886
|
});
|
|
37844
37887
|
|
|
@@ -38045,10 +38088,10 @@ async function inspectPinnedOpenCodePluginSchemaFences(options, deps = {}) {
|
|
|
38045
38088
|
return findings;
|
|
38046
38089
|
}
|
|
38047
38090
|
var PACKAGE_PATH_SEGMENTS, MAX_TARBALL_BYTES, NPM_TIMEOUT_MS = 5000, FENCE_PATTERN, EXACT_VERSION_PATTERN;
|
|
38048
|
-
var init_opencode_plugin_schema_fence = __esm(() => {
|
|
38049
|
-
init_checker();
|
|
38091
|
+
var init_opencode_plugin_schema_fence = __esm(async () => {
|
|
38050
38092
|
init_opencode_plugin_cache();
|
|
38051
38093
|
init_paths();
|
|
38094
|
+
await init_checker();
|
|
38052
38095
|
PACKAGE_PATH_SEGMENTS = OPENCODE_PLUGIN_NAME.split("/");
|
|
38053
38096
|
MAX_TARBALL_BYTES = 25 * 1024 * 1024;
|
|
38054
38097
|
FENCE_PATTERN = /\bLATEST_SUPPORTED_VERSION\s*=\s*(\d+)\b/g;
|
|
@@ -38274,10 +38317,10 @@ function reportCachedPluginFences(findings, report) {
|
|
|
38274
38317
|
}
|
|
38275
38318
|
var init_doctor_cached_plugin_fence = __esm(async () => {
|
|
38276
38319
|
init_opencode_plugin_cache();
|
|
38277
|
-
init_opencode_plugin_schema_fence();
|
|
38278
38320
|
await __promiseAll([
|
|
38279
38321
|
init_storage_db(),
|
|
38280
38322
|
init_database_access(),
|
|
38323
|
+
init_opencode_plugin_schema_fence(),
|
|
38281
38324
|
init_doctor_opencode_cache(),
|
|
38282
38325
|
init_doctor_opencode2_cache()
|
|
38283
38326
|
]);
|
|
@@ -43247,8 +43290,8 @@ var init_user_facing_codes = __esm(() => {
|
|
|
43247
43290
|
},
|
|
43248
43291
|
history_boundary_unresolved: {
|
|
43249
43292
|
code: "MC-H04",
|
|
43250
|
-
sentence: "This request was not sent:
|
|
43251
|
-
action: "
|
|
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."
|
|
43252
43295
|
},
|
|
43253
43296
|
history_over_window_unmanaged: {
|
|
43254
43297
|
code: "MC-H06",
|
|
@@ -43594,6 +43637,9 @@ var init_store_ahead_refusal = __esm(() => {
|
|
|
43594
43637
|
// ../plugin/src/hooks/magic-context/module-transport.ts
|
|
43595
43638
|
import { realpathSync as realpathSync7 } from "node:fs";
|
|
43596
43639
|
import { join as join31 } from "node:path";
|
|
43640
|
+
function monotonicNow() {
|
|
43641
|
+
return monotonicClockForTests?.() ?? performance.now();
|
|
43642
|
+
}
|
|
43597
43643
|
function getDefaultSubcConnectionFile() {
|
|
43598
43644
|
return join31(getDataDir(), "cortexkit", "run", "subc-connection.json");
|
|
43599
43645
|
}
|
|
@@ -43838,7 +43884,7 @@ class SubcModuleTransport {
|
|
|
43838
43884
|
});
|
|
43839
43885
|
}
|
|
43840
43886
|
async call(args) {
|
|
43841
|
-
const callStartedAt =
|
|
43887
|
+
const callStartedAt = monotonicNow();
|
|
43842
43888
|
const timings = {
|
|
43843
43889
|
lane: 0,
|
|
43844
43890
|
route: 0,
|
|
@@ -43884,7 +43930,7 @@ class SubcModuleTransport {
|
|
|
43884
43930
|
}
|
|
43885
43931
|
throw error;
|
|
43886
43932
|
}
|
|
43887
|
-
timings.lane =
|
|
43933
|
+
timings.lane = monotonicNow() - callStartedAt;
|
|
43888
43934
|
let rejectAbort;
|
|
43889
43935
|
const aborted = new Promise((_resolve, reject) => {
|
|
43890
43936
|
rejectAbort = reject;
|
|
@@ -43901,25 +43947,25 @@ class SubcModuleTransport {
|
|
|
43901
43947
|
throw args.signal.reason ?? new Error("module transport call aborted");
|
|
43902
43948
|
}
|
|
43903
43949
|
const attemptDeadlineMs = Date.now() + attemptTimeoutMs;
|
|
43904
|
-
const routeStartedAt =
|
|
43950
|
+
const routeStartedAt = monotonicNow();
|
|
43905
43951
|
ensuredRoute = await this.ensureRoute(args.sessionId, args.projectRoot, attemptDeadlineMs, args.signal);
|
|
43906
43952
|
if (args.signal?.aborted) {
|
|
43907
43953
|
throw args.signal.reason ?? new Error("module transport call aborted");
|
|
43908
43954
|
}
|
|
43909
|
-
timings.route +=
|
|
43910
|
-
const encodeStartedAt =
|
|
43955
|
+
timings.route += monotonicNow() - routeStartedAt;
|
|
43956
|
+
const encodeStartedAt = monotonicNow();
|
|
43911
43957
|
const body = args.body instanceof Uint8Array ? args.body : Buffer.from(JSON.stringify(moduleRequestBody(args.body, args.method)));
|
|
43912
|
-
timings.encode +=
|
|
43913
|
-
const issueStartedAt =
|
|
43958
|
+
timings.encode += monotonicNow() - encodeStartedAt;
|
|
43959
|
+
const issueStartedAt = monotonicNow();
|
|
43914
43960
|
const request = ensuredRoute.client.request(ensuredRoute.route, body, {
|
|
43915
43961
|
priority: Priority.Background,
|
|
43916
43962
|
admissionClass: AdmissionClass.Normal,
|
|
43917
43963
|
timeoutMs: Math.max(1, attemptDeadlineMs - Date.now())
|
|
43918
43964
|
});
|
|
43919
|
-
timings.issue +=
|
|
43920
|
-
const waitStartedAt =
|
|
43965
|
+
timings.issue += monotonicNow() - issueStartedAt;
|
|
43966
|
+
const waitStartedAt = monotonicNow();
|
|
43921
43967
|
const response = await this.beforeDeadline(Promise.race([request, aborted]), attemptDeadlineMs, "waiting for the module response");
|
|
43922
|
-
timings.responseWait +=
|
|
43968
|
+
timings.responseWait += monotonicNow() - waitStartedAt;
|
|
43923
43969
|
initialResponseReceived = true;
|
|
43924
43970
|
if (this.client !== ensuredRoute.client || this.connectionGeneration !== ensuredRoute.generation) {
|
|
43925
43971
|
throw this.connectionChangedError("subc connection changed while awaiting the module response");
|
|
@@ -44004,7 +44050,7 @@ class SubcModuleTransport {
|
|
|
44004
44050
|
args.signal?.removeEventListener("abort", onAbort);
|
|
44005
44051
|
finishWrapupTracking();
|
|
44006
44052
|
releaseLane();
|
|
44007
|
-
timings.settle = Math.max(0,
|
|
44053
|
+
timings.settle = Math.max(0, monotonicNow() - callStartedAt - timings.lane - timings.route - timings.encode - timings.issue - timings.responseWait);
|
|
44008
44054
|
args.onTimings?.(timings);
|
|
44009
44055
|
}
|
|
44010
44056
|
}
|
|
@@ -44103,10 +44149,10 @@ class SubcModuleTransport {
|
|
|
44103
44149
|
return resolved;
|
|
44104
44150
|
}
|
|
44105
44151
|
connectClient() {
|
|
44106
|
-
return SubcClient.connect({
|
|
44152
|
+
return inRootAsyncContext(() => SubcClient.connect({
|
|
44107
44153
|
connectionFile: this.connectionFile,
|
|
44108
44154
|
handshakeTimeoutMs: HANDSHAKE_TIMEOUT_MS
|
|
44109
|
-
});
|
|
44155
|
+
}));
|
|
44110
44156
|
}
|
|
44111
44157
|
backoffActiveError() {
|
|
44112
44158
|
const error = new Error(`subc connection backoff active until ${this.nextProbeMs}`);
|
|
@@ -44193,13 +44239,14 @@ class SubcModuleTransport {
|
|
|
44193
44239
|
client?.close();
|
|
44194
44240
|
}
|
|
44195
44241
|
}
|
|
44196
|
-
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;
|
|
44197
|
-
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 () => {
|
|
44198
44244
|
init_dist5();
|
|
44199
44245
|
init_data_path();
|
|
44200
44246
|
init_reply_pages();
|
|
44201
44247
|
init_single_store_refusal();
|
|
44202
44248
|
init_store_ahead_refusal();
|
|
44249
|
+
await init_sqlite();
|
|
44203
44250
|
});
|
|
44204
44251
|
|
|
44205
44252
|
// src/commands/migrate-session.ts
|
|
@@ -44607,12 +44654,14 @@ var init_migrate_session = __esm(async () => {
|
|
|
44607
44654
|
init_project_identity();
|
|
44608
44655
|
init_relocate_memory();
|
|
44609
44656
|
init_storage_project_state();
|
|
44610
|
-
init_module_transport();
|
|
44611
44657
|
init_data_path();
|
|
44612
44658
|
init_opencode_db_path();
|
|
44613
44659
|
init_migration_paths();
|
|
44614
44660
|
init_prompts();
|
|
44615
|
-
await
|
|
44661
|
+
await __promiseAll([
|
|
44662
|
+
init_module_transport(),
|
|
44663
|
+
init_database_access()
|
|
44664
|
+
]);
|
|
44616
44665
|
VALID_MEMORY_ACTIONS = new Set([
|
|
44617
44666
|
"move-all",
|
|
44618
44667
|
"move-originated",
|
|
@@ -45803,7 +45852,341 @@ var init_log_lines = __esm(() => {
|
|
|
45803
45852
|
LEVEL_DEFAULT = LEVEL_ORDER.INFO;
|
|
45804
45853
|
});
|
|
45805
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
|
+
|
|
45806
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
|
+
}
|
|
45807
46190
|
function isErrorLogLine(line) {
|
|
45808
46191
|
const parsed = parseLogLine(line);
|
|
45809
46192
|
if (parsed?.level !== null && parsed?.level !== undefined) {
|
|
@@ -45934,6 +46317,7 @@ var MAX_GITHUB_BODY_BYTES = 60000, LOG_TRUNCATION_MARKER = `[truncated for GitHu
|
|
|
45934
46317
|
[truncated for GitHub 64KB limit]
|
|
45935
46318
|
`, ERROR_LOG_PATTERNS;
|
|
45936
46319
|
var init_issue_body = __esm(() => {
|
|
46320
|
+
init_issue_privacy();
|
|
45937
46321
|
init_log_lines();
|
|
45938
46322
|
ERROR_LOG_PATTERNS = [
|
|
45939
46323
|
/\bfailed:/i,
|
|
@@ -45948,28 +46332,6 @@ var init_issue_body = __esm(() => {
|
|
|
45948
46332
|
];
|
|
45949
46333
|
});
|
|
45950
46334
|
|
|
45951
|
-
// src/lib/redaction.ts
|
|
45952
|
-
function sanitizeDiagnosticEndpoint(value) {
|
|
45953
|
-
const trimmed = value.trim();
|
|
45954
|
-
if (!trimmed)
|
|
45955
|
-
return sanitizeDiagnosticText(value);
|
|
45956
|
-
try {
|
|
45957
|
-
const url = new URL(trimmed);
|
|
45958
|
-
url.username = "";
|
|
45959
|
-
url.password = "";
|
|
45960
|
-
url.search = "";
|
|
45961
|
-
url.hash = "";
|
|
45962
|
-
return sanitizeDiagnosticText(url.toString());
|
|
45963
|
-
} catch {
|
|
45964
|
-
const withoutQuery = trimmed.replace(/[?#].*$/, "");
|
|
45965
|
-
const withoutUserInfo = withoutQuery.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/i, "$1");
|
|
45966
|
-
return sanitizeDiagnosticText(withoutUserInfo);
|
|
45967
|
-
}
|
|
45968
|
-
}
|
|
45969
|
-
var init_redaction2 = __esm(() => {
|
|
45970
|
-
init_redaction();
|
|
45971
|
-
});
|
|
45972
|
-
|
|
45973
46335
|
// src/commands/doctor-omp.ts
|
|
45974
46336
|
import { execFileSync as execFileSync8, spawnSync as spawnSync8 } from "node:child_process";
|
|
45975
46337
|
import { existsSync as existsSync42, readFileSync as readFileSync24 } from "node:fs";
|
|
@@ -46239,27 +46601,24 @@ async function repair(plan, deps, prompts, cwd) {
|
|
|
46239
46601
|
function timestamp2(date) {
|
|
46240
46602
|
return date.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
|
|
46241
46603
|
}
|
|
46242
|
-
function ompIssueBody(description, report, logLines, sessionFilter) {
|
|
46604
|
+
function ompIssueBody(description, report, logLines, sessionFilter, cwd) {
|
|
46243
46605
|
const LOG_TAIL_LINES = 400;
|
|
46244
|
-
const
|
|
46245
|
-
const recentLog = sanitizeDiagnosticText(filteredLogLines.slice(-LOG_TAIL_LINES).join(`
|
|
46246
|
-
`)).trim();
|
|
46247
|
-
const errorScanWindow = sanitizeDiagnosticText(filteredLogLines.slice(-4000).join(`
|
|
46248
|
-
`));
|
|
46249
|
-
const recentErrorLines = extractRecentErrors(errorScanWindow, 20);
|
|
46606
|
+
const { privacy, recentLog, recentErrorLines } = prepareIssueReport(report, logLines, sessionFilter, [cwd]);
|
|
46250
46607
|
return [
|
|
46251
46608
|
"## Description",
|
|
46252
|
-
|
|
46609
|
+
privacy.userText(description),
|
|
46610
|
+
"",
|
|
46611
|
+
privacy.notice,
|
|
46253
46612
|
"",
|
|
46254
46613
|
"## Environment",
|
|
46255
|
-
`- Magic Context plugin: ${report.pluginVersion ? `v${
|
|
46256
|
-
`- Oh My Pi: ${report.ompVersion ?
|
|
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"}`,
|
|
46257
46616
|
`- OS: ${process.platform} ${process.arch}`,
|
|
46258
46617
|
`- Runtime: Node.js ${process.version}`,
|
|
46259
46618
|
"",
|
|
46260
46619
|
"## OMP diagnostics",
|
|
46261
46620
|
`- Magic Context CLI: v${selfVersion()}`,
|
|
46262
|
-
...report.results.map((result) => `- ${result.status.toUpperCase()}: ${
|
|
46621
|
+
...report.results.map((result) => `- ${result.status.toUpperCase()}: ${privacy.healthMessage(result.message)}`),
|
|
46263
46622
|
"",
|
|
46264
46623
|
"## Recent errors (last 20, sanitized)",
|
|
46265
46624
|
recentErrorLines.length === 0 ? "_No error-shaped log lines found in recent history._" : ["```", recentErrorLines.join(`
|
|
@@ -46317,7 +46676,7 @@ async function runIssueFlow(options) {
|
|
|
46317
46676
|
if (options.reportPath) {
|
|
46318
46677
|
const report = await runHealthChecks({ ...options, quiet: true });
|
|
46319
46678
|
const path = isAbsolute8(options.reportPath) ? options.reportPath : join34(options.cwd, options.reportPath);
|
|
46320
|
-
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));
|
|
46321
46680
|
options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
|
|
46322
46681
|
return 0;
|
|
46323
46682
|
}
|
|
@@ -46344,7 +46703,7 @@ async function runIssueFlow(options) {
|
|
|
46344
46703
|
sessionFilter = choice === "__all__" ? null : choice;
|
|
46345
46704
|
}
|
|
46346
46705
|
const path = join34(options.cwd, `magic-context-omp-issue-${timestamp2(options.deps.now())}.md`);
|
|
46347
|
-
const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter));
|
|
46706
|
+
const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter, options.cwd));
|
|
46348
46707
|
options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
|
|
46349
46708
|
if (await options.prompts.confirm("Submit this issue on GitHub now?", false)) {
|
|
46350
46709
|
const result = submitGithubIssue(`[omp] ${title}`, bundle.path, (args) => runGhCommandWithDeps(options.deps, args));
|
|
@@ -46400,7 +46759,6 @@ var init_doctor_omp = __esm(async () => {
|
|
|
46400
46759
|
init_omp_helpers();
|
|
46401
46760
|
init_paths();
|
|
46402
46761
|
init_prompts();
|
|
46403
|
-
init_redaction2();
|
|
46404
46762
|
await init_database_access();
|
|
46405
46763
|
import_comment_json8 = __toESM(require_src3(), 1);
|
|
46406
46764
|
DEFAULT_DEPS4 = {
|
|
@@ -46822,7 +47180,7 @@ async function getSharedClient(options) {
|
|
|
46822
47180
|
if (sharedClientPromise && sharedClientFile === options.connectionFile)
|
|
46823
47181
|
return sharedClientPromise;
|
|
46824
47182
|
sharedClientFile = options.connectionFile;
|
|
46825
|
-
sharedClientPromise = SubcClient.connect({ connectionFile: options.connectionFile }).then((client) => {
|
|
47183
|
+
sharedClientPromise = inRootAsyncContext(() => SubcClient.connect({ connectionFile: options.connectionFile })).then((client) => {
|
|
46826
47184
|
sharedClient = client;
|
|
46827
47185
|
return client;
|
|
46828
47186
|
});
|
|
@@ -47207,10 +47565,11 @@ class SynapseEmbeddingProvider {
|
|
|
47207
47565
|
}
|
|
47208
47566
|
}
|
|
47209
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;
|
|
47210
|
-
var init_embedding_synapse = __esm(() => {
|
|
47568
|
+
var init_embedding_synapse = __esm(async () => {
|
|
47211
47569
|
init_dist5();
|
|
47212
47570
|
init_read_session_formatting();
|
|
47213
47571
|
init_logger();
|
|
47572
|
+
await init_sqlite();
|
|
47214
47573
|
SYNAPSE_CERTIFICATION_REFUSAL_REASONS = new Set([
|
|
47215
47574
|
"not_certified",
|
|
47216
47575
|
"probe_required",
|
|
@@ -48042,20 +48401,21 @@ var init_embedding_model_match = () => {};
|
|
|
48042
48401
|
var init_normalize_hash = () => {};
|
|
48043
48402
|
|
|
48044
48403
|
// ../plugin/src/features/magic-context/memory/embedding-identity.ts
|
|
48045
|
-
var init_embedding_identity = __esm(() => {
|
|
48404
|
+
var init_embedding_identity = __esm(async () => {
|
|
48046
48405
|
init_magic_context();
|
|
48047
48406
|
init_embedding_model_match();
|
|
48048
|
-
init_embedding_synapse();
|
|
48049
48407
|
init_normalize_hash();
|
|
48408
|
+
await init_embedding_synapse();
|
|
48050
48409
|
});
|
|
48051
48410
|
|
|
48052
48411
|
// ../plugin/src/features/magic-context/memory/onnx-telemetry.ts
|
|
48053
48412
|
var init_onnx_telemetry = () => {};
|
|
48054
48413
|
|
|
48055
48414
|
// ../plugin/src/features/magic-context/memory/embedding-worker-client.ts
|
|
48056
|
-
var init_embedding_worker_client = __esm(() => {
|
|
48415
|
+
var init_embedding_worker_client = __esm(async () => {
|
|
48057
48416
|
init_logger();
|
|
48058
48417
|
init_onnx_telemetry();
|
|
48418
|
+
await init_sqlite();
|
|
48059
48419
|
});
|
|
48060
48420
|
// ../plugin/src/features/magic-context/memory/embedding-local.ts
|
|
48061
48421
|
function currentLocalEmbeddingHost() {
|
|
@@ -48091,14 +48451,17 @@ function resolveLocalEmbeddingWorkerRuntime(preference = "auto", host = currentL
|
|
|
48091
48451
|
return resolveLocalEmbeddingRuntime(preference, host);
|
|
48092
48452
|
}
|
|
48093
48453
|
var BUN_NAPI_TEARDOWN_FIX_VERSION, STALE_LOCK_MS, MAX_LOCK_WAIT_MS, loadedLocalEmbeddingRuntimes;
|
|
48094
|
-
var init_embedding_local = __esm(() => {
|
|
48454
|
+
var init_embedding_local = __esm(async () => {
|
|
48095
48455
|
init_magic_context();
|
|
48096
48456
|
init_data_path();
|
|
48097
48457
|
init_logger();
|
|
48098
48458
|
init_stale_plugin_build();
|
|
48099
48459
|
init_storage_permissions();
|
|
48100
|
-
|
|
48101
|
-
|
|
48460
|
+
await __promiseAll([
|
|
48461
|
+
init_embedding_identity(),
|
|
48462
|
+
init_embedding_worker_client(),
|
|
48463
|
+
init_sqlite()
|
|
48464
|
+
]);
|
|
48102
48465
|
BUN_NAPI_TEARDOWN_FIX_VERSION = [1, 4, 0];
|
|
48103
48466
|
STALE_LOCK_MS = 3 * 60000;
|
|
48104
48467
|
MAX_LOCK_WAIT_MS = 5 * 60000;
|
|
@@ -48450,8 +48813,8 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
|
|
|
48450
48813
|
return withWasmFallback(native, () => probeWasmRuntimeByResolution(pluginDir));
|
|
48451
48814
|
}
|
|
48452
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.";
|
|
48453
|
-
var init_embedding_runtime = __esm(() => {
|
|
48454
|
-
init_embedding_local();
|
|
48816
|
+
var init_embedding_runtime = __esm(async () => {
|
|
48817
|
+
await init_embedding_local();
|
|
48455
48818
|
ONNX_RUNTIME_NODE_LOAD_PROBE_SCRIPT = [
|
|
48456
48819
|
'const { createRequire } = require("node:module");',
|
|
48457
48820
|
'const { join } = require("node:path");',
|
|
@@ -48477,9 +48840,6 @@ var init_embedding_runtime = __esm(() => {
|
|
|
48477
48840
|
// src/lib/logs-opencode.ts
|
|
48478
48841
|
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
48479
48842
|
import { dirname as dirname25, join as join38 } from "node:path";
|
|
48480
|
-
function sanitizeLogContent(content) {
|
|
48481
|
-
return sanitizeDiagnosticText(content);
|
|
48482
|
-
}
|
|
48483
48843
|
function formatTimestamp(date) {
|
|
48484
48844
|
const pad = (value) => String(value).padStart(2, "0");
|
|
48485
48845
|
return [
|
|
@@ -48509,20 +48869,17 @@ function extractHistorianFailureLines(sanitized, limit = 30) {
|
|
|
48509
48869
|
async function bundleIssueReport(report, description, title, sessionFilter = null, options = {}) {
|
|
48510
48870
|
const LOG_TAIL_LINES = 400;
|
|
48511
48871
|
const allLogLines = readLogLines(report.logFiles ?? [report.logFile]);
|
|
48512
|
-
const
|
|
48513
|
-
const recentLog =
|
|
48514
|
-
|
|
48515
|
-
const historianScanWindow =
|
|
48516
|
-
`)
|
|
48517
|
-
const historianFailureLines = extractHistorianFailureLines(historianScanWindow, 30);
|
|
48518
|
-
const errorScanWindow = sanitizeLogContent(logLines.slice(-4000).join(`
|
|
48519
|
-
`));
|
|
48520
|
-
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));
|
|
48521
48878
|
const configBody = JSON.stringify(sanitizeConfigValue(report.magicContextConfig.flags), null, 2);
|
|
48522
48879
|
const sanitizedConfigPath = sanitizeDiagnosticText(report.configPaths.magicContextConfig);
|
|
48523
|
-
const sanitizedDescription =
|
|
48524
|
-
const sanitizedTitle =
|
|
48525
|
-
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;
|
|
48526
48883
|
const sessionContext = selectedSession ? [
|
|
48527
48884
|
"## Session context",
|
|
48528
48885
|
`- Selected session: ${sanitizeDiagnosticText(selectedSession.sessionId)}`,
|
|
@@ -48535,6 +48892,8 @@ async function bundleIssueReport(report, description, title, sessionFilter = nul
|
|
|
48535
48892
|
"## Description",
|
|
48536
48893
|
sanitizedDescription,
|
|
48537
48894
|
"",
|
|
48895
|
+
privacy.notice,
|
|
48896
|
+
"",
|
|
48538
48897
|
"## Environment",
|
|
48539
48898
|
`- Plugin: v${report.pluginVersion}`,
|
|
48540
48899
|
`- OS: ${report.platform} ${report.arch}`,
|
|
@@ -50738,7 +51097,6 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
50738
51097
|
init_removed_agent_config();
|
|
50739
51098
|
init_variable();
|
|
50740
51099
|
init_tick_failure();
|
|
50741
|
-
init_embedding_synapse();
|
|
50742
51100
|
init_auto_update_provenance();
|
|
50743
51101
|
init_conflict_detector();
|
|
50744
51102
|
init_conflict_fixer();
|
|
@@ -50748,7 +51106,6 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
50748
51106
|
init_tui_config();
|
|
50749
51107
|
init_atomic_write();
|
|
50750
51108
|
init_config_location_migration();
|
|
50751
|
-
init_embedding_runtime();
|
|
50752
51109
|
init_github_issue();
|
|
50753
51110
|
init_log_lines();
|
|
50754
51111
|
init_migrate_dreamer_v2_doctor();
|
|
@@ -50756,17 +51113,19 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
50756
51113
|
init_opencode_helpers();
|
|
50757
51114
|
init_opencode_plugin_cache();
|
|
50758
51115
|
init_opencode_plugin_registration();
|
|
50759
|
-
init_opencode_plugin_schema_fence();
|
|
50760
51116
|
init_paths();
|
|
50761
51117
|
init_prompts();
|
|
50762
51118
|
init_redaction2();
|
|
50763
51119
|
await __promiseAll([
|
|
51120
|
+
init_embedding_synapse(),
|
|
50764
51121
|
init_storage_db(),
|
|
50765
51122
|
init_sqlite(),
|
|
50766
51123
|
init_opencode(),
|
|
50767
51124
|
init_database_access(),
|
|
50768
51125
|
init_diagnostics_opencode(),
|
|
51126
|
+
init_embedding_runtime(),
|
|
50769
51127
|
init_logs_opencode(),
|
|
51128
|
+
init_opencode_plugin_schema_fence(),
|
|
50770
51129
|
init_storage_versions(),
|
|
50771
51130
|
init_v22_backfill_commands(),
|
|
50772
51131
|
init_doctor_cached_plugin_fence(),
|
|
@@ -51374,9 +51733,6 @@ var init_diagnostics_pi = __esm(() => {
|
|
|
51374
51733
|
// src/lib/logs-pi.ts
|
|
51375
51734
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
51376
51735
|
import { dirname as dirname27, join as join41 } from "node:path";
|
|
51377
|
-
function sanitizeLogContent2(content) {
|
|
51378
|
-
return sanitizeString2(content);
|
|
51379
|
-
}
|
|
51380
51736
|
function formatTimestamp2(date) {
|
|
51381
51737
|
const pad = (value) => String(value).padStart(2, "0");
|
|
51382
51738
|
return [
|
|
@@ -51392,18 +51748,19 @@ function formatTimestamp2(date) {
|
|
|
51392
51748
|
async function bundleIssueReport2(report, description, title, options = {}) {
|
|
51393
51749
|
const LOG_TAIL_LINES = 400;
|
|
51394
51750
|
const allLogLines = readLogLines(report.logFiles ?? [report.logFile]);
|
|
51395
|
-
const
|
|
51396
|
-
|
|
51397
|
-
|
|
51398
|
-
const
|
|
51399
|
-
|
|
51400
|
-
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;
|
|
51401
51756
|
const rawBodyMarkdown = [
|
|
51402
51757
|
"## Title",
|
|
51403
|
-
`[pi] ${
|
|
51758
|
+
`[pi] ${privacy.userText(title)}`,
|
|
51404
51759
|
"",
|
|
51405
51760
|
"## Description",
|
|
51406
|
-
|
|
51761
|
+
privacy.userText(description),
|
|
51762
|
+
"",
|
|
51763
|
+
privacy.notice,
|
|
51407
51764
|
"",
|
|
51408
51765
|
"## Environment",
|
|
51409
51766
|
`- Pi plugin: v${report.pluginVersion}`,
|
|
@@ -52352,7 +52709,6 @@ var init_doctor_pi = __esm(async () => {
|
|
|
52352
52709
|
init_raw_loader();
|
|
52353
52710
|
init_variable();
|
|
52354
52711
|
init_tick_failure();
|
|
52355
|
-
init_embedding_synapse();
|
|
52356
52712
|
init_data_path();
|
|
52357
52713
|
init_jsonc_edit();
|
|
52358
52714
|
init_jsonc_parser();
|
|
@@ -52361,7 +52717,6 @@ var init_doctor_pi = __esm(async () => {
|
|
|
52361
52717
|
init_atomic_write();
|
|
52362
52718
|
init_config_location_migration();
|
|
52363
52719
|
init_diagnostics_pi();
|
|
52364
|
-
init_embedding_runtime();
|
|
52365
52720
|
init_github_issue();
|
|
52366
52721
|
init_log_lines();
|
|
52367
52722
|
init_logs_pi();
|
|
@@ -52372,8 +52727,10 @@ var init_doctor_pi = __esm(async () => {
|
|
|
52372
52727
|
init_redaction2();
|
|
52373
52728
|
init_setup_pi();
|
|
52374
52729
|
await __promiseAll([
|
|
52730
|
+
init_embedding_synapse(),
|
|
52375
52731
|
init_storage_db(),
|
|
52376
52732
|
init_database_access(),
|
|
52733
|
+
init_embedding_runtime(),
|
|
52377
52734
|
init_storage_versions(),
|
|
52378
52735
|
init_v22_backfill_commands()
|
|
52379
52736
|
]);
|