@cortexkit/magic-context 0.49.7 → 0.49.9
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 +638 -135
- 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
|
|
@@ -30142,32 +30175,32 @@ var init_read_session_formatting = __esm(() => {
|
|
|
30142
30175
|
// ../plugin/src/shared/stable-json.ts
|
|
30143
30176
|
function stableStringify(value, seen = new WeakSet) {
|
|
30144
30177
|
const pieces = [];
|
|
30145
|
-
writeStable(value, seen, pieces);
|
|
30178
|
+
writeStable(value, seen, (piece) => pieces.push(piece));
|
|
30146
30179
|
return pieces.join("");
|
|
30147
30180
|
}
|
|
30148
|
-
function writeStable(value, seen,
|
|
30181
|
+
function writeStable(value, seen, write) {
|
|
30149
30182
|
if (value === undefined) {
|
|
30150
|
-
|
|
30183
|
+
write("undefined");
|
|
30151
30184
|
return;
|
|
30152
30185
|
}
|
|
30153
30186
|
if (value === null || typeof value !== "object") {
|
|
30154
|
-
|
|
30187
|
+
write(JSON.stringify(value) ?? String(value));
|
|
30155
30188
|
return;
|
|
30156
30189
|
}
|
|
30157
30190
|
if (seen.has(value)) {
|
|
30158
|
-
|
|
30191
|
+
write('"[Circular]"');
|
|
30159
30192
|
return;
|
|
30160
30193
|
}
|
|
30161
30194
|
seen.add(value);
|
|
30162
30195
|
if (Array.isArray(value)) {
|
|
30163
|
-
|
|
30196
|
+
write("[");
|
|
30164
30197
|
for (let index = 0;index < value.length; index += 1) {
|
|
30165
30198
|
if (index > 0)
|
|
30166
|
-
|
|
30199
|
+
write(",");
|
|
30167
30200
|
if (index in value)
|
|
30168
|
-
writeStable(value[index], seen,
|
|
30201
|
+
writeStable(value[index], seen, write);
|
|
30169
30202
|
}
|
|
30170
|
-
|
|
30203
|
+
write("]");
|
|
30171
30204
|
return;
|
|
30172
30205
|
}
|
|
30173
30206
|
const entries = Object.entries(value).sort(([a], [b]) => {
|
|
@@ -30177,14 +30210,19 @@ function writeStable(value, seen, pieces) {
|
|
|
30177
30210
|
return 1;
|
|
30178
30211
|
return 0;
|
|
30179
30212
|
});
|
|
30180
|
-
|
|
30213
|
+
if (entries.length > 0 && entries.length <= 16 && entries.every(([key, child]) => key.length <= 4096 && !/^(0|[1-9]\d*)$/.test(key) && (child === null || typeof child === "number" || typeof child === "boolean" || typeof child === "string" && child.length <= 4096))) {
|
|
30214
|
+
write(JSON.stringify(Object.fromEntries(entries)));
|
|
30215
|
+
return;
|
|
30216
|
+
}
|
|
30217
|
+
write("{");
|
|
30181
30218
|
entries.forEach(([key, child], index) => {
|
|
30182
30219
|
if (index > 0)
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30220
|
+
write(",");
|
|
30221
|
+
write(JSON.stringify(key));
|
|
30222
|
+
write(":");
|
|
30223
|
+
writeStable(child, seen, write);
|
|
30186
30224
|
});
|
|
30187
|
-
|
|
30225
|
+
write("}");
|
|
30188
30226
|
}
|
|
30189
30227
|
|
|
30190
30228
|
// ../plugin/src/features/magic-context/tool-definition-tokens.ts
|
|
@@ -30856,6 +30894,12 @@ var init_tag_content_primitives = __esm(() => {
|
|
|
30856
30894
|
encoder = new TextEncoder;
|
|
30857
30895
|
});
|
|
30858
30896
|
|
|
30897
|
+
// ../plugin/src/hooks/magic-context/tail-hygiene-output-count.ts
|
|
30898
|
+
var CURRENT_OUTPUT_COUNT;
|
|
30899
|
+
var init_tail_hygiene_output_count = __esm(() => {
|
|
30900
|
+
CURRENT_OUTPUT_COUNT = Symbol.for("magic-context.current-reclaimable-tool-output-count");
|
|
30901
|
+
});
|
|
30902
|
+
|
|
30859
30903
|
// ../plugin/src/shared/record-type-guard.ts
|
|
30860
30904
|
function isRecord2(value) {
|
|
30861
30905
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -30867,6 +30911,128 @@ var init_tag_owner_id = __esm(() => {
|
|
|
30867
30911
|
PI_FALLBACK_PREFIXES_JSON = JSON.stringify([..."pi-msg-"].reduce((prefixes, char) => prefixes.flatMap((prefix) => /[a-z]/.test(char) ? [prefix + char, prefix + char.toUpperCase()] : [prefix + char]), [""]));
|
|
30868
30912
|
});
|
|
30869
30913
|
|
|
30914
|
+
// ../plugin/src/shared/tail-hygiene-json.ts
|
|
30915
|
+
class TailHygieneJsonMemo {
|
|
30916
|
+
entries = new Map;
|
|
30917
|
+
bytes = 0;
|
|
30918
|
+
passText = new WeakMap;
|
|
30919
|
+
passHash = new WeakMap;
|
|
30920
|
+
beginPass() {
|
|
30921
|
+
this.passText = new WeakMap;
|
|
30922
|
+
this.passHash = new WeakMap;
|
|
30923
|
+
}
|
|
30924
|
+
get(key, value, compute, fingerprint = false) {
|
|
30925
|
+
const pass = fingerprint ? this.passHash : this.passText;
|
|
30926
|
+
const object = value !== null && typeof value === "object" ? value : undefined;
|
|
30927
|
+
const local = object ? pass.get(object) : undefined;
|
|
30928
|
+
if (local !== undefined)
|
|
30929
|
+
return local;
|
|
30930
|
+
const previous = this.entries.get(key);
|
|
30931
|
+
if (previous && sameJson(previous.snapshot, value)) {
|
|
30932
|
+
if (object)
|
|
30933
|
+
pass.set(object, previous.result);
|
|
30934
|
+
return previous.result;
|
|
30935
|
+
}
|
|
30936
|
+
const result = compute();
|
|
30937
|
+
if (previous) {
|
|
30938
|
+
this.bytes -= previous.bytes;
|
|
30939
|
+
this.entries.delete(key);
|
|
30940
|
+
}
|
|
30941
|
+
try {
|
|
30942
|
+
const copy = copyJson(value);
|
|
30943
|
+
const bytes = copy.bytes + (key.length + result.length) * 2;
|
|
30944
|
+
if (bytes <= MAX_MEMO_BYTES) {
|
|
30945
|
+
this.entries.set(key, { snapshot: copy.value, result, bytes });
|
|
30946
|
+
this.bytes += bytes;
|
|
30947
|
+
if (object)
|
|
30948
|
+
pass.set(object, result);
|
|
30949
|
+
}
|
|
30950
|
+
} catch {}
|
|
30951
|
+
while (this.bytes > MAX_MEMO_BYTES || this.entries.size > MAX_MEMO_ENTRIES) {
|
|
30952
|
+
const oldest = this.entries.entries().next().value;
|
|
30953
|
+
if (!oldest)
|
|
30954
|
+
break;
|
|
30955
|
+
this.bytes -= oldest[1].bytes;
|
|
30956
|
+
this.entries.delete(oldest[0]);
|
|
30957
|
+
}
|
|
30958
|
+
return result;
|
|
30959
|
+
}
|
|
30960
|
+
}
|
|
30961
|
+
function copyJson(value) {
|
|
30962
|
+
const seen = new Map;
|
|
30963
|
+
let bytes = 0;
|
|
30964
|
+
const copy = (current) => {
|
|
30965
|
+
bytes += 16;
|
|
30966
|
+
if (typeof current === "string")
|
|
30967
|
+
bytes += current.length * 2;
|
|
30968
|
+
if (bytes > MAX_MEMO_BYTES)
|
|
30969
|
+
throw new Error("memo capacity");
|
|
30970
|
+
if (current === null || typeof current !== "object") {
|
|
30971
|
+
if (["function", "symbol", "bigint"].includes(typeof current))
|
|
30972
|
+
throw new Error("exotic");
|
|
30973
|
+
return current;
|
|
30974
|
+
}
|
|
30975
|
+
if (seen.has(current))
|
|
30976
|
+
return seen.get(current);
|
|
30977
|
+
const prototype = Object.getPrototypeOf(current);
|
|
30978
|
+
if (!Array.isArray(current) && prototype !== Object.prototype && prototype !== null)
|
|
30979
|
+
throw new Error("exotic");
|
|
30980
|
+
const result = Array.isArray(current) ? new Array(current.length) : Object.create(prototype);
|
|
30981
|
+
seen.set(current, result);
|
|
30982
|
+
for (const key of Object.keys(current)) {
|
|
30983
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
30984
|
+
if (!descriptor || !("value" in descriptor))
|
|
30985
|
+
throw new Error("accessor");
|
|
30986
|
+
bytes += key.length * 2 + 16;
|
|
30987
|
+
if (key === "__proto__") {
|
|
30988
|
+
Object.defineProperty(result, key, {
|
|
30989
|
+
value: copy(descriptor.value),
|
|
30990
|
+
enumerable: true,
|
|
30991
|
+
writable: true,
|
|
30992
|
+
configurable: true
|
|
30993
|
+
});
|
|
30994
|
+
} else
|
|
30995
|
+
result[key] = copy(descriptor.value);
|
|
30996
|
+
}
|
|
30997
|
+
return result;
|
|
30998
|
+
};
|
|
30999
|
+
return { value: copy(value), bytes };
|
|
31000
|
+
}
|
|
31001
|
+
function sameJson(before, after) {
|
|
31002
|
+
const forward = new Map;
|
|
31003
|
+
const reverse = new Set;
|
|
31004
|
+
const same = (left, right) => {
|
|
31005
|
+
if (left === null || right === null || typeof left !== "object" || typeof right !== "object")
|
|
31006
|
+
return Object.is(left, right);
|
|
31007
|
+
if (forward.has(left))
|
|
31008
|
+
return forward.get(left) === right;
|
|
31009
|
+
if (reverse.has(right) || Object.getPrototypeOf(left) !== Object.getPrototypeOf(right))
|
|
31010
|
+
return false;
|
|
31011
|
+
forward.set(left, right);
|
|
31012
|
+
reverse.add(right);
|
|
31013
|
+
if (Array.isArray(left) && (!Array.isArray(right) || left.length !== right.length))
|
|
31014
|
+
return false;
|
|
31015
|
+
const keys = Object.keys(left);
|
|
31016
|
+
const otherKeys = Object.keys(right);
|
|
31017
|
+
if (keys.length !== otherKeys.length)
|
|
31018
|
+
return false;
|
|
31019
|
+
for (let index = 0;index < keys.length; index++) {
|
|
31020
|
+
const key = keys[index];
|
|
31021
|
+
if (key !== otherKeys[index])
|
|
31022
|
+
return false;
|
|
31023
|
+
const descriptor = Object.getOwnPropertyDescriptor(right, key);
|
|
31024
|
+
if (!descriptor || !("value" in descriptor) || !same(left[key], descriptor.value))
|
|
31025
|
+
return false;
|
|
31026
|
+
}
|
|
31027
|
+
return true;
|
|
31028
|
+
};
|
|
31029
|
+
return same(before, after);
|
|
31030
|
+
}
|
|
31031
|
+
var MAX_MEMO_BYTES, MAX_MEMO_ENTRIES = 1e4;
|
|
31032
|
+
var init_tail_hygiene_json = __esm(() => {
|
|
31033
|
+
MAX_MEMO_BYTES = 64 * 1024 * 1024;
|
|
31034
|
+
});
|
|
31035
|
+
|
|
30870
31036
|
// ../plugin/src/hooks/magic-context/image-token-estimate.ts
|
|
30871
31037
|
var JPEG_SCAN_LIMIT_BYTES;
|
|
30872
31038
|
var init_image_token_estimate = __esm(() => {
|
|
@@ -30910,18 +31076,21 @@ var init_todo_view = __esm(() => {
|
|
|
30910
31076
|
});
|
|
30911
31077
|
|
|
30912
31078
|
// ../plugin/src/hooks/magic-context/tail-hygiene-walk.ts
|
|
30913
|
-
var MAX_CONTENT_MEMO_BYTES, contentMemo, contentMemoOrder, baselineMeasurementMemo, MAX_BASELINE_MEMO_SIZE;
|
|
31079
|
+
var MAX_CONTENT_MEMO_BYTES, contentMemo, contentMemoOrder, partJsonMemo, baselineMeasurementMemo, MAX_BASELINE_MEMO_SIZE;
|
|
30914
31080
|
var init_tail_hygiene_walk = __esm(() => {
|
|
30915
31081
|
init_reclaim_protection();
|
|
30916
31082
|
init_tag_owner_id();
|
|
31083
|
+
init_tail_hygiene_json();
|
|
30917
31084
|
init_image_token_estimate();
|
|
30918
31085
|
init_provider_visible_parts();
|
|
30919
31086
|
init_read_session_formatting();
|
|
31087
|
+
init_tail_hygiene_output_count();
|
|
30920
31088
|
init_todo_view();
|
|
30921
31089
|
init_reclaim_protection();
|
|
30922
31090
|
MAX_CONTENT_MEMO_BYTES = 256 * 1024 * 1024;
|
|
30923
31091
|
contentMemo = new Map;
|
|
30924
31092
|
contentMemoOrder = new Set;
|
|
31093
|
+
partJsonMemo = new TailHygieneJsonMemo;
|
|
30925
31094
|
baselineMeasurementMemo = new Map;
|
|
30926
31095
|
MAX_BASELINE_MEMO_SIZE = 128 * 1024 * 1024;
|
|
30927
31096
|
});
|
|
@@ -30930,7 +31099,9 @@ var init_tail_hygiene_walk = __esm(() => {
|
|
|
30930
31099
|
var init_ctx_reduce_nudge = __esm(() => {
|
|
30931
31100
|
init_read_session_formatting();
|
|
30932
31101
|
init_tag_content_primitives();
|
|
31102
|
+
init_tail_hygiene_output_count();
|
|
30933
31103
|
init_tail_hygiene_walk();
|
|
31104
|
+
init_tail_hygiene_output_count();
|
|
30934
31105
|
});
|
|
30935
31106
|
|
|
30936
31107
|
// ../plugin/src/hooks/magic-context/emergency-drop.ts
|
|
@@ -32212,7 +32383,7 @@ function runSessionWarmupWorker(input, options) {
|
|
|
32212
32383
|
deadline.unref?.();
|
|
32213
32384
|
};
|
|
32214
32385
|
try {
|
|
32215
|
-
worker = new Worker(options.entry ?? defaultEntry(), { workerData: input });
|
|
32386
|
+
worker = inRootAsyncContext(() => new Worker(options.entry ?? defaultEntry(), { workerData: input }));
|
|
32216
32387
|
} catch (error) {
|
|
32217
32388
|
finish({ failure: "start-failed", detail: String(error) });
|
|
32218
32389
|
return;
|
|
@@ -32302,7 +32473,8 @@ var init_raw_ordinal_warmup = __esm(async () => {
|
|
|
32302
32473
|
init_logger();
|
|
32303
32474
|
await __promiseAll([
|
|
32304
32475
|
init_sqlite(),
|
|
32305
|
-
init_read_session_raw()
|
|
32476
|
+
init_read_session_raw(),
|
|
32477
|
+
init_sqlite()
|
|
32306
32478
|
]);
|
|
32307
32479
|
RESULT_TIMEOUT_MS = 10 * 60000;
|
|
32308
32480
|
FAILURE_BACKOFF_MS = 5 * 60000;
|
|
@@ -32599,10 +32771,18 @@ var init_token_budget = __esm(() => {
|
|
|
32599
32771
|
finalizingChildren = new Map;
|
|
32600
32772
|
});
|
|
32601
32773
|
|
|
32774
|
+
// ../plugin/src/shared/hidden-zen-read.ts
|
|
32775
|
+
var blockedSessions, v1Runs;
|
|
32776
|
+
var init_hidden_zen_read = __esm(() => {
|
|
32777
|
+
blockedSessions = new Set;
|
|
32778
|
+
v1Runs = new Map;
|
|
32779
|
+
});
|
|
32780
|
+
|
|
32602
32781
|
// ../plugin/src/hooks/magic-context/dropped-input-guard.ts
|
|
32603
32782
|
var recordedToolParameters;
|
|
32604
32783
|
var init_dropped_input_guard = __esm(() => {
|
|
32605
32784
|
init_token_budget();
|
|
32785
|
+
init_hidden_zen_read();
|
|
32606
32786
|
init_logger();
|
|
32607
32787
|
recordedToolParameters = new Map;
|
|
32608
32788
|
});
|
|
@@ -33361,13 +33541,20 @@ function readRawSessionMessageOrdinalById(sessionId, messageId) {
|
|
|
33361
33541
|
return null;
|
|
33362
33542
|
return withReadOnlySessionDb((db) => readRawSessionMessageOrdinalByIdFromDb(db, sessionId, messageId));
|
|
33363
33543
|
}
|
|
33544
|
+
function readRawSessionMessageOrderPosition(sessionId, messageId) {
|
|
33545
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
33546
|
+
if (provider) {
|
|
33547
|
+
return provider.readMessageOrderById ? provider.readMessageOrderById(messageId) : provider.readMessageOrdinalById?.(messageId) ?? null;
|
|
33548
|
+
}
|
|
33549
|
+
return readRawSessionMessageOrdinalById(sessionId, messageId);
|
|
33550
|
+
}
|
|
33364
33551
|
function compareRawSessionMessageOrder(sessionId, leftId, rightId) {
|
|
33365
33552
|
const provider = sessionProviders.get(sessionId)?.provider;
|
|
33366
33553
|
if (provider) {
|
|
33367
|
-
if (!provider.readMessageOrdinalById)
|
|
33554
|
+
if (!provider.readMessageOrderById && !provider.readMessageOrdinalById)
|
|
33368
33555
|
return null;
|
|
33369
|
-
const left =
|
|
33370
|
-
const right =
|
|
33556
|
+
const left = readRawSessionMessageOrderPosition(sessionId, leftId);
|
|
33557
|
+
const right = readRawSessionMessageOrderPosition(sessionId, rightId);
|
|
33371
33558
|
return left === null || right === null ? null : left - right;
|
|
33372
33559
|
}
|
|
33373
33560
|
if (!openCodeDbExists())
|
|
@@ -35842,15 +36029,16 @@ var init_storage_db = __esm(async () => {
|
|
|
35842
36029
|
init_fail_closed_block();
|
|
35843
36030
|
init_migration_v94_write_split();
|
|
35844
36031
|
init_migration_v95_perf_indexes();
|
|
35845
|
-
init_migration_worker_client();
|
|
35846
36032
|
init_storage_schema_helpers();
|
|
35847
36033
|
init_storage_tag_identity_revision();
|
|
35848
36034
|
init_tool_definition_tokens();
|
|
35849
36035
|
init_tool_owner_backfill();
|
|
35850
36036
|
await __promiseAll([
|
|
36037
|
+
init_boot_quiet(),
|
|
35851
36038
|
init_sqlite(),
|
|
35852
36039
|
init_context_store_uuid(),
|
|
35853
36040
|
init_message_fts_rowid_map(),
|
|
36041
|
+
init_migration_worker_client(),
|
|
35854
36042
|
init_migrations()
|
|
35855
36043
|
]);
|
|
35856
36044
|
registerSlowWriteReporter(logSlowWriteTransaction);
|
|
@@ -37835,10 +38023,11 @@ function findPluginEntry(directory, surface = "server") {
|
|
|
37835
38023
|
};
|
|
37836
38024
|
}
|
|
37837
38025
|
var import_comment_json7;
|
|
37838
|
-
var init_checker = __esm(() => {
|
|
38026
|
+
var init_checker = __esm(async () => {
|
|
37839
38027
|
init_logger();
|
|
37840
38028
|
init_constants2();
|
|
37841
38029
|
init_types();
|
|
38030
|
+
await init_sqlite();
|
|
37842
38031
|
import_comment_json7 = __toESM(require_src3(), 1);
|
|
37843
38032
|
});
|
|
37844
38033
|
|
|
@@ -38045,10 +38234,10 @@ async function inspectPinnedOpenCodePluginSchemaFences(options, deps = {}) {
|
|
|
38045
38234
|
return findings;
|
|
38046
38235
|
}
|
|
38047
38236
|
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();
|
|
38237
|
+
var init_opencode_plugin_schema_fence = __esm(async () => {
|
|
38050
38238
|
init_opencode_plugin_cache();
|
|
38051
38239
|
init_paths();
|
|
38240
|
+
await init_checker();
|
|
38052
38241
|
PACKAGE_PATH_SEGMENTS = OPENCODE_PLUGIN_NAME.split("/");
|
|
38053
38242
|
MAX_TARBALL_BYTES = 25 * 1024 * 1024;
|
|
38054
38243
|
FENCE_PATTERN = /\bLATEST_SUPPORTED_VERSION\s*=\s*(\d+)\b/g;
|
|
@@ -38274,10 +38463,10 @@ function reportCachedPluginFences(findings, report) {
|
|
|
38274
38463
|
}
|
|
38275
38464
|
var init_doctor_cached_plugin_fence = __esm(async () => {
|
|
38276
38465
|
init_opencode_plugin_cache();
|
|
38277
|
-
init_opencode_plugin_schema_fence();
|
|
38278
38466
|
await __promiseAll([
|
|
38279
38467
|
init_storage_db(),
|
|
38280
38468
|
init_database_access(),
|
|
38469
|
+
init_opencode_plugin_schema_fence(),
|
|
38281
38470
|
init_doctor_opencode_cache(),
|
|
38282
38471
|
init_doctor_opencode2_cache()
|
|
38283
38472
|
]);
|
|
@@ -43247,8 +43436,8 @@ var init_user_facing_codes = __esm(() => {
|
|
|
43247
43436
|
},
|
|
43248
43437
|
history_boundary_unresolved: {
|
|
43249
43438
|
code: "MC-H04",
|
|
43250
|
-
sentence: "This request was not sent:
|
|
43251
|
-
action: "
|
|
43439
|
+
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.",
|
|
43440
|
+
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
43441
|
},
|
|
43253
43442
|
history_over_window_unmanaged: {
|
|
43254
43443
|
code: "MC-H06",
|
|
@@ -43594,6 +43783,9 @@ var init_store_ahead_refusal = __esm(() => {
|
|
|
43594
43783
|
// ../plugin/src/hooks/magic-context/module-transport.ts
|
|
43595
43784
|
import { realpathSync as realpathSync7 } from "node:fs";
|
|
43596
43785
|
import { join as join31 } from "node:path";
|
|
43786
|
+
function monotonicNow() {
|
|
43787
|
+
return monotonicClockForTests?.() ?? performance.now();
|
|
43788
|
+
}
|
|
43597
43789
|
function getDefaultSubcConnectionFile() {
|
|
43598
43790
|
return join31(getDataDir(), "cortexkit", "run", "subc-connection.json");
|
|
43599
43791
|
}
|
|
@@ -43838,7 +44030,7 @@ class SubcModuleTransport {
|
|
|
43838
44030
|
});
|
|
43839
44031
|
}
|
|
43840
44032
|
async call(args) {
|
|
43841
|
-
const callStartedAt =
|
|
44033
|
+
const callStartedAt = monotonicNow();
|
|
43842
44034
|
const timings = {
|
|
43843
44035
|
lane: 0,
|
|
43844
44036
|
route: 0,
|
|
@@ -43884,7 +44076,7 @@ class SubcModuleTransport {
|
|
|
43884
44076
|
}
|
|
43885
44077
|
throw error;
|
|
43886
44078
|
}
|
|
43887
|
-
timings.lane =
|
|
44079
|
+
timings.lane = monotonicNow() - callStartedAt;
|
|
43888
44080
|
let rejectAbort;
|
|
43889
44081
|
const aborted = new Promise((_resolve, reject) => {
|
|
43890
44082
|
rejectAbort = reject;
|
|
@@ -43901,25 +44093,25 @@ class SubcModuleTransport {
|
|
|
43901
44093
|
throw args.signal.reason ?? new Error("module transport call aborted");
|
|
43902
44094
|
}
|
|
43903
44095
|
const attemptDeadlineMs = Date.now() + attemptTimeoutMs;
|
|
43904
|
-
const routeStartedAt =
|
|
44096
|
+
const routeStartedAt = monotonicNow();
|
|
43905
44097
|
ensuredRoute = await this.ensureRoute(args.sessionId, args.projectRoot, attemptDeadlineMs, args.signal);
|
|
43906
44098
|
if (args.signal?.aborted) {
|
|
43907
44099
|
throw args.signal.reason ?? new Error("module transport call aborted");
|
|
43908
44100
|
}
|
|
43909
|
-
timings.route +=
|
|
43910
|
-
const encodeStartedAt =
|
|
44101
|
+
timings.route += monotonicNow() - routeStartedAt;
|
|
44102
|
+
const encodeStartedAt = monotonicNow();
|
|
43911
44103
|
const body = args.body instanceof Uint8Array ? args.body : Buffer.from(JSON.stringify(moduleRequestBody(args.body, args.method)));
|
|
43912
|
-
timings.encode +=
|
|
43913
|
-
const issueStartedAt =
|
|
44104
|
+
timings.encode += monotonicNow() - encodeStartedAt;
|
|
44105
|
+
const issueStartedAt = monotonicNow();
|
|
43914
44106
|
const request = ensuredRoute.client.request(ensuredRoute.route, body, {
|
|
43915
44107
|
priority: Priority.Background,
|
|
43916
44108
|
admissionClass: AdmissionClass.Normal,
|
|
43917
44109
|
timeoutMs: Math.max(1, attemptDeadlineMs - Date.now())
|
|
43918
44110
|
});
|
|
43919
|
-
timings.issue +=
|
|
43920
|
-
const waitStartedAt =
|
|
44111
|
+
timings.issue += monotonicNow() - issueStartedAt;
|
|
44112
|
+
const waitStartedAt = monotonicNow();
|
|
43921
44113
|
const response = await this.beforeDeadline(Promise.race([request, aborted]), attemptDeadlineMs, "waiting for the module response");
|
|
43922
|
-
timings.responseWait +=
|
|
44114
|
+
timings.responseWait += monotonicNow() - waitStartedAt;
|
|
43923
44115
|
initialResponseReceived = true;
|
|
43924
44116
|
if (this.client !== ensuredRoute.client || this.connectionGeneration !== ensuredRoute.generation) {
|
|
43925
44117
|
throw this.connectionChangedError("subc connection changed while awaiting the module response");
|
|
@@ -44004,7 +44196,7 @@ class SubcModuleTransport {
|
|
|
44004
44196
|
args.signal?.removeEventListener("abort", onAbort);
|
|
44005
44197
|
finishWrapupTracking();
|
|
44006
44198
|
releaseLane();
|
|
44007
|
-
timings.settle = Math.max(0,
|
|
44199
|
+
timings.settle = Math.max(0, monotonicNow() - callStartedAt - timings.lane - timings.route - timings.encode - timings.issue - timings.responseWait);
|
|
44008
44200
|
args.onTimings?.(timings);
|
|
44009
44201
|
}
|
|
44010
44202
|
}
|
|
@@ -44103,10 +44295,10 @@ class SubcModuleTransport {
|
|
|
44103
44295
|
return resolved;
|
|
44104
44296
|
}
|
|
44105
44297
|
connectClient() {
|
|
44106
|
-
return SubcClient.connect({
|
|
44298
|
+
return inRootAsyncContext(() => SubcClient.connect({
|
|
44107
44299
|
connectionFile: this.connectionFile,
|
|
44108
44300
|
handshakeTimeoutMs: HANDSHAKE_TIMEOUT_MS
|
|
44109
|
-
});
|
|
44301
|
+
}));
|
|
44110
44302
|
}
|
|
44111
44303
|
backoffActiveError() {
|
|
44112
44304
|
const error = new Error(`subc connection backoff active until ${this.nextProbeMs}`);
|
|
@@ -44193,13 +44385,14 @@ class SubcModuleTransport {
|
|
|
44193
44385
|
client?.close();
|
|
44194
44386
|
}
|
|
44195
44387
|
}
|
|
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(() => {
|
|
44388
|
+
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;
|
|
44389
|
+
var init_module_transport = __esm(async () => {
|
|
44198
44390
|
init_dist5();
|
|
44199
44391
|
init_data_path();
|
|
44200
44392
|
init_reply_pages();
|
|
44201
44393
|
init_single_store_refusal();
|
|
44202
44394
|
init_store_ahead_refusal();
|
|
44395
|
+
await init_sqlite();
|
|
44203
44396
|
});
|
|
44204
44397
|
|
|
44205
44398
|
// src/commands/migrate-session.ts
|
|
@@ -44607,12 +44800,14 @@ var init_migrate_session = __esm(async () => {
|
|
|
44607
44800
|
init_project_identity();
|
|
44608
44801
|
init_relocate_memory();
|
|
44609
44802
|
init_storage_project_state();
|
|
44610
|
-
init_module_transport();
|
|
44611
44803
|
init_data_path();
|
|
44612
44804
|
init_opencode_db_path();
|
|
44613
44805
|
init_migration_paths();
|
|
44614
44806
|
init_prompts();
|
|
44615
|
-
await
|
|
44807
|
+
await __promiseAll([
|
|
44808
|
+
init_module_transport(),
|
|
44809
|
+
init_database_access()
|
|
44810
|
+
]);
|
|
44616
44811
|
VALID_MEMORY_ACTIONS = new Set([
|
|
44617
44812
|
"move-all",
|
|
44618
44813
|
"move-originated",
|
|
@@ -45803,7 +45998,341 @@ var init_log_lines = __esm(() => {
|
|
|
45803
45998
|
LEVEL_DEFAULT = LEVEL_ORDER.INFO;
|
|
45804
45999
|
});
|
|
45805
46000
|
|
|
46001
|
+
// src/lib/redaction.ts
|
|
46002
|
+
function sanitizeDiagnosticEndpoint(value) {
|
|
46003
|
+
const trimmed = value.trim();
|
|
46004
|
+
if (!trimmed)
|
|
46005
|
+
return sanitizeDiagnosticText(value);
|
|
46006
|
+
try {
|
|
46007
|
+
const url = new URL(trimmed);
|
|
46008
|
+
url.username = "";
|
|
46009
|
+
url.password = "";
|
|
46010
|
+
url.search = "";
|
|
46011
|
+
url.hash = "";
|
|
46012
|
+
return sanitizeDiagnosticText(url.toString());
|
|
46013
|
+
} catch {
|
|
46014
|
+
const withoutQuery = trimmed.replace(/[?#].*$/, "");
|
|
46015
|
+
const withoutUserInfo = withoutQuery.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/i, "$1");
|
|
46016
|
+
return sanitizeDiagnosticText(withoutUserInfo);
|
|
46017
|
+
}
|
|
46018
|
+
}
|
|
46019
|
+
var init_redaction2 = __esm(() => {
|
|
46020
|
+
init_redaction();
|
|
46021
|
+
});
|
|
46022
|
+
|
|
46023
|
+
// src/lib/issue-privacy.ts
|
|
46024
|
+
class IssuePrivacy {
|
|
46025
|
+
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._";
|
|
46026
|
+
projects = new Map;
|
|
46027
|
+
sessions = new Map;
|
|
46028
|
+
paths = new Map;
|
|
46029
|
+
constructor(report, projectDirectories = []) {
|
|
46030
|
+
this.discover(report);
|
|
46031
|
+
for (const directory of projectDirectories) {
|
|
46032
|
+
this.alias(this.projects, this.normalize(directory), "project");
|
|
46033
|
+
}
|
|
46034
|
+
}
|
|
46035
|
+
normalize(value) {
|
|
46036
|
+
let path = value.replaceAll("\\", "/");
|
|
46037
|
+
const home = (process.env.HOME || process.env.USERPROFILE || "").replaceAll("\\", "/");
|
|
46038
|
+
if (home && (path === home || path.startsWith(`${home}/`)))
|
|
46039
|
+
path = `~${path.slice(home.length)}`;
|
|
46040
|
+
return path.replace(/^(?:\/Users\/[^/]+|\/home\/[^/]+|[A-Za-z]:\/Users\/[^/]+)(?=\/|$)/, "~").replace(/\/$/, "");
|
|
46041
|
+
}
|
|
46042
|
+
alias(map, value, prefix) {
|
|
46043
|
+
let alias = map.get(value);
|
|
46044
|
+
if (!alias) {
|
|
46045
|
+
alias = `${prefix}-${new Set(map.values()).size + 1}`;
|
|
46046
|
+
map.set(value, alias);
|
|
46047
|
+
}
|
|
46048
|
+
return alias;
|
|
46049
|
+
}
|
|
46050
|
+
discover(value) {
|
|
46051
|
+
if (Array.isArray(value)) {
|
|
46052
|
+
for (const item of value)
|
|
46053
|
+
this.discover(item);
|
|
46054
|
+
} else if (value && typeof value === "object") {
|
|
46055
|
+
const record = value;
|
|
46056
|
+
const directory = typeof record.directory === "string" ? this.normalize(record.directory) : null;
|
|
46057
|
+
if (directory) {
|
|
46058
|
+
const alias = this.alias(this.projects, directory, "project");
|
|
46059
|
+
for (const [key, item] of Object.entries(record)) {
|
|
46060
|
+
if (PROJECT_KEY.test(key) && typeof item === "string")
|
|
46061
|
+
this.projects.set(this.normalize(item), alias);
|
|
46062
|
+
}
|
|
46063
|
+
}
|
|
46064
|
+
for (const [key, item] of Object.entries(record)) {
|
|
46065
|
+
if (key !== "flags")
|
|
46066
|
+
this.discover(item);
|
|
46067
|
+
}
|
|
46068
|
+
}
|
|
46069
|
+
}
|
|
46070
|
+
path(value) {
|
|
46071
|
+
const normalized = this.normalize(value);
|
|
46072
|
+
if (!normalized || normalized === "~")
|
|
46073
|
+
return normalized;
|
|
46074
|
+
for (const [root, alias] of [...this.projects].sort(([a], [b]) => b.length - a.length)) {
|
|
46075
|
+
if (normalized === root || normalized.startsWith(`${root}/`)) {
|
|
46076
|
+
return `${normalized.startsWith("~/") ? "~/" : ""}${alias}${normalized === root ? "" : "/<path>"}`;
|
|
46077
|
+
}
|
|
46078
|
+
}
|
|
46079
|
+
return `${normalized.startsWith("~/") ? "~/" : ""}${this.alias(this.paths, normalized, "path")}`;
|
|
46080
|
+
}
|
|
46081
|
+
session(value) {
|
|
46082
|
+
return value === "none" || !value ? value : this.alias(this.sessions, value, "session");
|
|
46083
|
+
}
|
|
46084
|
+
project(value) {
|
|
46085
|
+
if (value.startsWith("dir:"))
|
|
46086
|
+
return this.path(value.slice(4));
|
|
46087
|
+
return this.alias(this.projects, this.normalize(value), "project");
|
|
46088
|
+
}
|
|
46089
|
+
summary(value) {
|
|
46090
|
+
const safe = sanitizeDiagnosticText(value);
|
|
46091
|
+
const errors = [
|
|
46092
|
+
...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) ?? [])
|
|
46093
|
+
];
|
|
46094
|
+
if (/generation mismatch/i.test(safe))
|
|
46095
|
+
errors.push("store generation mismatch");
|
|
46096
|
+
if (/no such table/i.test(safe))
|
|
46097
|
+
errors.push("SQLITE_ERROR");
|
|
46098
|
+
if (/could not safely prepare this turn|refused\s*\(/i.test(safe))
|
|
46099
|
+
errors.push("refused");
|
|
46100
|
+
if (/\bfailed:|\bexception\b|\bEMERGENCY\b/i.test(safe))
|
|
46101
|
+
errors.push("failed");
|
|
46102
|
+
return errors.length ? `${errors.join(" ")}: ${OMITTED}` : OMITTED;
|
|
46103
|
+
}
|
|
46104
|
+
userText(value) {
|
|
46105
|
+
return value === "Magic Context diagnostic report" || value === "Generated non-interactively by `doctor --issue --report`." ? value : OMITTED;
|
|
46106
|
+
}
|
|
46107
|
+
logLine(line) {
|
|
46108
|
+
const parsed = parseLogLine(line);
|
|
46109
|
+
const safe = sanitizeDiagnosticText(line);
|
|
46110
|
+
const component = parsed?.tags.find((tag) => COMPONENTS.has(tag)) ?? [...COMPONENTS].find((name) => new RegExp(`\\b${name}\\b`).test(parsed?.message ?? ""));
|
|
46111
|
+
const logger = component ? `magic-context.${component}` : "magic-context";
|
|
46112
|
+
const session = parsed?.session ? ` [${this.session(parsed.session)}]` : "";
|
|
46113
|
+
const fields = Object.entries(parsed?.kv ?? {}).filter(([key, value]) => NUMERIC_FIELD.test(key) && /^\d+(?:\.\d+)?$/.test(value)).map(([key, value]) => `${key}=${value}`);
|
|
46114
|
+
const timings = safe.match(/\b\d+(?:\.\d+)?(?:ms|µs|us|s)\b/g) ?? [];
|
|
46115
|
+
const identities = [
|
|
46116
|
+
...safe.matchAll(/\b(?:git:[a-f0-9]{16,64}|pj-[A-Za-z0-9_-]+|dir:[^\s"']+)/g)
|
|
46117
|
+
].map(([id]) => this.project(id));
|
|
46118
|
+
return [
|
|
46119
|
+
parsed?.ts && /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/.test(parsed.ts) ? parsed.ts : "",
|
|
46120
|
+
parsed?.level ?? line.match(/^(TRACE|DEBUG|INFO|WARN|ERROR)\b/)?.[1] ?? "LOG",
|
|
46121
|
+
`${logger}${session}`,
|
|
46122
|
+
this.summary(line),
|
|
46123
|
+
...fields,
|
|
46124
|
+
...timings,
|
|
46125
|
+
...identities
|
|
46126
|
+
].filter(Boolean).join(" ");
|
|
46127
|
+
}
|
|
46128
|
+
healthMessage(value) {
|
|
46129
|
+
const labels = [
|
|
46130
|
+
"compaction.enabled",
|
|
46131
|
+
"memory.backend",
|
|
46132
|
+
"@cortexkit/pi-magic-context",
|
|
46133
|
+
"native compaction",
|
|
46134
|
+
"memory backend",
|
|
46135
|
+
"agent directory",
|
|
46136
|
+
"config",
|
|
46137
|
+
"plugin",
|
|
46138
|
+
"manifest",
|
|
46139
|
+
"Shared storage",
|
|
46140
|
+
"context DB",
|
|
46141
|
+
"SQLite integrity_check",
|
|
46142
|
+
"Background maintenance",
|
|
46143
|
+
"runtime log",
|
|
46144
|
+
"sessions",
|
|
46145
|
+
"package override"
|
|
46146
|
+
];
|
|
46147
|
+
const label = labels.find((entry) => value.toLowerCase().includes(entry.toLowerCase())) ?? "host detection";
|
|
46148
|
+
const staticMessages = [
|
|
46149
|
+
"OMP native compaction is disabled",
|
|
46150
|
+
"OMP automatic memory backend is disabled",
|
|
46151
|
+
"SQLite integrity_check: ok",
|
|
46152
|
+
"Background maintenance completed its last pass",
|
|
46153
|
+
"Magic Context runtime config loads successfully",
|
|
46154
|
+
"Plugin exposes an OMP/Pi extension manifest",
|
|
46155
|
+
"Installed plugin has no OMP/Pi extension manifest"
|
|
46156
|
+
];
|
|
46157
|
+
if (staticMessages.includes(value))
|
|
46158
|
+
return value;
|
|
46159
|
+
const paths = [...value.matchAll(/(?:[A-Za-z]:[\\/]|~\/|\/)[^\s,;)]+/g)].map(([path]) => this.path(path));
|
|
46160
|
+
const versions = value.match(/\b\d+\.\d+\.\d+\b/g) ?? [];
|
|
46161
|
+
const fields = [
|
|
46162
|
+
...value.matchAll(/\b(grammar|lines|source)[=:]\s*(environment override|[\w-]+)/g)
|
|
46163
|
+
].map(([, key, item]) => `${key}=${/^\d+$/.test(item) || ENUMS.has(item) ? item : OMITTED}`);
|
|
46164
|
+
const measurements = value.match(/\b\d+(?:\.\d+)?\s?(?:KB|MB|GB|ms|s)\b/g) ?? [];
|
|
46165
|
+
return [label, ...versions, ...paths, ...fields, ...measurements, this.summary(value)].join(" ");
|
|
46166
|
+
}
|
|
46167
|
+
report(value, key = "", config = false) {
|
|
46168
|
+
if (value === null || typeof value === "number" || typeof value === "boolean")
|
|
46169
|
+
return value;
|
|
46170
|
+
if (isSecretKey(key))
|
|
46171
|
+
return sanitizeConfigValue(value, [key]);
|
|
46172
|
+
if (Array.isArray(value))
|
|
46173
|
+
return value.map((item) => this.report(item, key, config));
|
|
46174
|
+
if (value && typeof value === "object") {
|
|
46175
|
+
return Object.fromEntries(Object.entries(value).map(([childKey, item]) => [
|
|
46176
|
+
key === "factCountByCategory" ? `category-${Object.keys(value).indexOf(childKey) + 1}` : /[\s/@\\:]|[a-f0-9]{24,}/i.test(childKey) ? "<key omitted>" : childKey,
|
|
46177
|
+
this.report(item, childKey, config || key === "flags")
|
|
46178
|
+
]));
|
|
46179
|
+
}
|
|
46180
|
+
if (typeof value !== "string")
|
|
46181
|
+
return value;
|
|
46182
|
+
const safe = sanitizeDiagnosticText(value);
|
|
46183
|
+
if (/^<[^<>]*REDACTED[^<>]*>$/.test(safe))
|
|
46184
|
+
return safe;
|
|
46185
|
+
if (SESSION_KEY.test(key))
|
|
46186
|
+
return this.session(value);
|
|
46187
|
+
if (PROJECT_KEY.test(key) || /^(?:git:[a-f0-9]{16,64}|pj-)/.test(value))
|
|
46188
|
+
return this.project(value);
|
|
46189
|
+
if (PATH_KEY.test(key) || /^(?:~\/|\/|[A-Za-z]:[\\/]|file:)/.test(value))
|
|
46190
|
+
return this.path(value);
|
|
46191
|
+
if (VERSION_KEY.test(key) && VERSION.test(value))
|
|
46192
|
+
return value;
|
|
46193
|
+
if (/^(?:timestamp|lastActiveAt|lastFailureAt|lastRunAt|lastUpdatedAt)$/.test(key) && /^\d{4}-\d\d-\d\dT[\d:.]+Z$/.test(value))
|
|
46194
|
+
return value;
|
|
46195
|
+
if (MODEL_KEY.test(key) && /^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(safe) && !safe.includes("..") && !/^(?:git:|dir:|pj-)/.test(safe))
|
|
46196
|
+
return safe;
|
|
46197
|
+
if (ENUMS.has(value) || value === "")
|
|
46198
|
+
return value;
|
|
46199
|
+
if (config && (CONFIG_ENUMS.has(value) || key === "language" && /^[a-z]{2}$/.test(value)))
|
|
46200
|
+
return value;
|
|
46201
|
+
if (config)
|
|
46202
|
+
return OMITTED;
|
|
46203
|
+
return this.summary(value);
|
|
46204
|
+
}
|
|
46205
|
+
}
|
|
46206
|
+
var OMITTED = "<text omitted>", COMPONENTS, NUMERIC_FIELD, ENUMS, CONFIG_ENUMS, PATH_KEY, SESSION_KEY, PROJECT_KEY, VERSION_KEY, MODEL_KEY, VERSION;
|
|
46207
|
+
var init_issue_privacy = __esm(() => {
|
|
46208
|
+
init_log_lines();
|
|
46209
|
+
init_redaction2();
|
|
46210
|
+
COMPONENTS = new Set([
|
|
46211
|
+
"historian",
|
|
46212
|
+
"hist",
|
|
46213
|
+
"perf",
|
|
46214
|
+
"compaction",
|
|
46215
|
+
"dreamer",
|
|
46216
|
+
"janitor",
|
|
46217
|
+
"retina",
|
|
46218
|
+
"storage",
|
|
46219
|
+
"embedding",
|
|
46220
|
+
"transform",
|
|
46221
|
+
"session",
|
|
46222
|
+
"runtime",
|
|
46223
|
+
"config"
|
|
46224
|
+
]);
|
|
46225
|
+
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;
|
|
46226
|
+
ENUMS = new Set([
|
|
46227
|
+
"true",
|
|
46228
|
+
"false",
|
|
46229
|
+
"on",
|
|
46230
|
+
"off",
|
|
46231
|
+
"auto",
|
|
46232
|
+
"none",
|
|
46233
|
+
"unknown",
|
|
46234
|
+
"local",
|
|
46235
|
+
"remote",
|
|
46236
|
+
"disabled",
|
|
46237
|
+
"enabled",
|
|
46238
|
+
"default",
|
|
46239
|
+
"debug",
|
|
46240
|
+
"info",
|
|
46241
|
+
"warn",
|
|
46242
|
+
"error",
|
|
46243
|
+
"trace",
|
|
46244
|
+
"cli",
|
|
46245
|
+
"desktop",
|
|
46246
|
+
"darwin",
|
|
46247
|
+
"linux",
|
|
46248
|
+
"win32",
|
|
46249
|
+
"arm64",
|
|
46250
|
+
"x64",
|
|
46251
|
+
"ia32",
|
|
46252
|
+
"json",
|
|
46253
|
+
"jsonc",
|
|
46254
|
+
"opencode1",
|
|
46255
|
+
"opencode2",
|
|
46256
|
+
"fleet-r1",
|
|
46257
|
+
"fleet-r2",
|
|
46258
|
+
"legacy",
|
|
46259
|
+
"mixed",
|
|
46260
|
+
"PATH",
|
|
46261
|
+
"path",
|
|
46262
|
+
"app",
|
|
46263
|
+
"openchamber",
|
|
46264
|
+
"environment override",
|
|
46265
|
+
"OPENCODE_DB",
|
|
46266
|
+
"stable",
|
|
46267
|
+
"beta",
|
|
46268
|
+
"latest",
|
|
46269
|
+
"query error",
|
|
46270
|
+
"path missing",
|
|
46271
|
+
"schema too old"
|
|
46272
|
+
]);
|
|
46273
|
+
CONFIG_ENUMS = new Set([
|
|
46274
|
+
"ts",
|
|
46275
|
+
"rust",
|
|
46276
|
+
"broca",
|
|
46277
|
+
"host",
|
|
46278
|
+
"minimal",
|
|
46279
|
+
"low",
|
|
46280
|
+
"medium",
|
|
46281
|
+
"high",
|
|
46282
|
+
"xhigh",
|
|
46283
|
+
"max",
|
|
46284
|
+
"inherit",
|
|
46285
|
+
"full",
|
|
46286
|
+
"light",
|
|
46287
|
+
"synapse",
|
|
46288
|
+
"native",
|
|
46289
|
+
"wasm",
|
|
46290
|
+
"fp32",
|
|
46291
|
+
"fp16",
|
|
46292
|
+
"q8",
|
|
46293
|
+
"int8",
|
|
46294
|
+
"uint8",
|
|
46295
|
+
"q4",
|
|
46296
|
+
"bnb4",
|
|
46297
|
+
"q4f16",
|
|
46298
|
+
"q2",
|
|
46299
|
+
"q2f16",
|
|
46300
|
+
"q1",
|
|
46301
|
+
"q1f16",
|
|
46302
|
+
"*",
|
|
46303
|
+
"read",
|
|
46304
|
+
"aft_outline",
|
|
46305
|
+
"aft_zoom",
|
|
46306
|
+
"aft_search",
|
|
46307
|
+
"subagent",
|
|
46308
|
+
"primary",
|
|
46309
|
+
"all",
|
|
46310
|
+
"ask",
|
|
46311
|
+
"allow",
|
|
46312
|
+
"deny"
|
|
46313
|
+
]);
|
|
46314
|
+
PATH_KEY = /^(?:path|dir|directory|configDir|agentDir|opencodeConfig|magicContextConfig|tuiConfig|omoConfig|userConfig|projectConfig|loadedConfigPaths|piPath)$/;
|
|
46315
|
+
SESSION_KEY = /session_?ids?$/i;
|
|
46316
|
+
PROJECT_KEY = /^(?:project|project_?id|projectKey|rootCommit|root_commit|rootCommitHash)$/i;
|
|
46317
|
+
VERSION_KEY = /(?:version|cached|latest|spec)$/i;
|
|
46318
|
+
MODEL_KEY = /^(?:model|models|provider|providerID|modelID|fallback_provider|fallback_model|fallback_models|model_chain)$/i;
|
|
46319
|
+
VERSION = /^(?:(?:opencode|pi|omp)\s+)?v?\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/;
|
|
46320
|
+
});
|
|
46321
|
+
|
|
45806
46322
|
// src/lib/issue-body.ts
|
|
46323
|
+
function prepareIssueReport(report, lines, sessionFilter = null, projectDirectories = [process.cwd()]) {
|
|
46324
|
+
const privacy = new IssuePrivacy(report, projectDirectories);
|
|
46325
|
+
const logLines = filterLogLinesBySession(lines, sessionFilter);
|
|
46326
|
+
return {
|
|
46327
|
+
privacy,
|
|
46328
|
+
report: privacy.report(report),
|
|
46329
|
+
logLines,
|
|
46330
|
+
recentLog: logLines.slice(-400).map((line) => privacy.logLine(line)).join(`
|
|
46331
|
+
`).trim(),
|
|
46332
|
+
recentErrorLines: extractRecentErrors(logLines.slice(-4000).join(`
|
|
46333
|
+
`), 20).map((line) => privacy.logLine(line))
|
|
46334
|
+
};
|
|
46335
|
+
}
|
|
45807
46336
|
function isErrorLogLine(line) {
|
|
45808
46337
|
const parsed = parseLogLine(line);
|
|
45809
46338
|
if (parsed?.level !== null && parsed?.level !== undefined) {
|
|
@@ -45934,6 +46463,7 @@ var MAX_GITHUB_BODY_BYTES = 60000, LOG_TRUNCATION_MARKER = `[truncated for GitHu
|
|
|
45934
46463
|
[truncated for GitHub 64KB limit]
|
|
45935
46464
|
`, ERROR_LOG_PATTERNS;
|
|
45936
46465
|
var init_issue_body = __esm(() => {
|
|
46466
|
+
init_issue_privacy();
|
|
45937
46467
|
init_log_lines();
|
|
45938
46468
|
ERROR_LOG_PATTERNS = [
|
|
45939
46469
|
/\bfailed:/i,
|
|
@@ -45948,28 +46478,6 @@ var init_issue_body = __esm(() => {
|
|
|
45948
46478
|
];
|
|
45949
46479
|
});
|
|
45950
46480
|
|
|
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
46481
|
// src/commands/doctor-omp.ts
|
|
45974
46482
|
import { execFileSync as execFileSync8, spawnSync as spawnSync8 } from "node:child_process";
|
|
45975
46483
|
import { existsSync as existsSync42, readFileSync as readFileSync24 } from "node:fs";
|
|
@@ -46239,27 +46747,24 @@ async function repair(plan, deps, prompts, cwd) {
|
|
|
46239
46747
|
function timestamp2(date) {
|
|
46240
46748
|
return date.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
|
|
46241
46749
|
}
|
|
46242
|
-
function ompIssueBody(description, report, logLines, sessionFilter) {
|
|
46750
|
+
function ompIssueBody(description, report, logLines, sessionFilter, cwd) {
|
|
46243
46751
|
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);
|
|
46752
|
+
const { privacy, recentLog, recentErrorLines } = prepareIssueReport(report, logLines, sessionFilter, [cwd]);
|
|
46250
46753
|
return [
|
|
46251
46754
|
"## Description",
|
|
46252
|
-
|
|
46755
|
+
privacy.userText(description),
|
|
46756
|
+
"",
|
|
46757
|
+
privacy.notice,
|
|
46253
46758
|
"",
|
|
46254
46759
|
"## Environment",
|
|
46255
|
-
`- Magic Context plugin: ${report.pluginVersion ? `v${
|
|
46256
|
-
`- Oh My Pi: ${report.ompVersion ?
|
|
46760
|
+
`- Magic Context plugin: ${report.pluginVersion ? `v${privacy.report(report.pluginVersion, "pluginVersion")}` : "not installed"}`,
|
|
46761
|
+
`- Oh My Pi: ${report.ompVersion ? privacy.report(report.ompVersion, "ompVersion") : "not detected"}`,
|
|
46257
46762
|
`- OS: ${process.platform} ${process.arch}`,
|
|
46258
46763
|
`- Runtime: Node.js ${process.version}`,
|
|
46259
46764
|
"",
|
|
46260
46765
|
"## OMP diagnostics",
|
|
46261
46766
|
`- Magic Context CLI: v${selfVersion()}`,
|
|
46262
|
-
...report.results.map((result) => `- ${result.status.toUpperCase()}: ${
|
|
46767
|
+
...report.results.map((result) => `- ${result.status.toUpperCase()}: ${privacy.healthMessage(result.message)}`),
|
|
46263
46768
|
"",
|
|
46264
46769
|
"## Recent errors (last 20, sanitized)",
|
|
46265
46770
|
recentErrorLines.length === 0 ? "_No error-shaped log lines found in recent history._" : ["```", recentErrorLines.join(`
|
|
@@ -46317,7 +46822,7 @@ async function runIssueFlow(options) {
|
|
|
46317
46822
|
if (options.reportPath) {
|
|
46318
46823
|
const report = await runHealthChecks({ ...options, quiet: true });
|
|
46319
46824
|
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));
|
|
46825
|
+
const bundle = writeOmpIssueReport(path, ompIssueBody("Generated non-interactively by `doctor --issue --report`.", report, readLogLines(report.logFiles), null, options.cwd));
|
|
46321
46826
|
options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
|
|
46322
46827
|
return 0;
|
|
46323
46828
|
}
|
|
@@ -46344,7 +46849,7 @@ async function runIssueFlow(options) {
|
|
|
46344
46849
|
sessionFilter = choice === "__all__" ? null : choice;
|
|
46345
46850
|
}
|
|
46346
46851
|
const path = join34(options.cwd, `magic-context-omp-issue-${timestamp2(options.deps.now())}.md`);
|
|
46347
|
-
const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter));
|
|
46852
|
+
const bundle = writeOmpIssueReport(path, ompIssueBody(description, report, logLines, sessionFilter, options.cwd));
|
|
46348
46853
|
options.prompts.log.success(bundle.fullPath ? `Sanitized report written to ${bundle.path}; full report at ${bundle.fullPath}` : `Sanitized report written to ${bundle.path}`);
|
|
46349
46854
|
if (await options.prompts.confirm("Submit this issue on GitHub now?", false)) {
|
|
46350
46855
|
const result = submitGithubIssue(`[omp] ${title}`, bundle.path, (args) => runGhCommandWithDeps(options.deps, args));
|
|
@@ -46400,7 +46905,6 @@ var init_doctor_omp = __esm(async () => {
|
|
|
46400
46905
|
init_omp_helpers();
|
|
46401
46906
|
init_paths();
|
|
46402
46907
|
init_prompts();
|
|
46403
|
-
init_redaction2();
|
|
46404
46908
|
await init_database_access();
|
|
46405
46909
|
import_comment_json8 = __toESM(require_src3(), 1);
|
|
46406
46910
|
DEFAULT_DEPS4 = {
|
|
@@ -46822,7 +47326,7 @@ async function getSharedClient(options) {
|
|
|
46822
47326
|
if (sharedClientPromise && sharedClientFile === options.connectionFile)
|
|
46823
47327
|
return sharedClientPromise;
|
|
46824
47328
|
sharedClientFile = options.connectionFile;
|
|
46825
|
-
sharedClientPromise = SubcClient.connect({ connectionFile: options.connectionFile }).then((client) => {
|
|
47329
|
+
sharedClientPromise = inRootAsyncContext(() => SubcClient.connect({ connectionFile: options.connectionFile })).then((client) => {
|
|
46826
47330
|
sharedClient = client;
|
|
46827
47331
|
return client;
|
|
46828
47332
|
});
|
|
@@ -47207,10 +47711,11 @@ class SynapseEmbeddingProvider {
|
|
|
47207
47711
|
}
|
|
47208
47712
|
}
|
|
47209
47713
|
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(() => {
|
|
47714
|
+
var init_embedding_synapse = __esm(async () => {
|
|
47211
47715
|
init_dist5();
|
|
47212
47716
|
init_read_session_formatting();
|
|
47213
47717
|
init_logger();
|
|
47718
|
+
await init_sqlite();
|
|
47214
47719
|
SYNAPSE_CERTIFICATION_REFUSAL_REASONS = new Set([
|
|
47215
47720
|
"not_certified",
|
|
47216
47721
|
"probe_required",
|
|
@@ -48042,20 +48547,21 @@ var init_embedding_model_match = () => {};
|
|
|
48042
48547
|
var init_normalize_hash = () => {};
|
|
48043
48548
|
|
|
48044
48549
|
// ../plugin/src/features/magic-context/memory/embedding-identity.ts
|
|
48045
|
-
var init_embedding_identity = __esm(() => {
|
|
48550
|
+
var init_embedding_identity = __esm(async () => {
|
|
48046
48551
|
init_magic_context();
|
|
48047
48552
|
init_embedding_model_match();
|
|
48048
|
-
init_embedding_synapse();
|
|
48049
48553
|
init_normalize_hash();
|
|
48554
|
+
await init_embedding_synapse();
|
|
48050
48555
|
});
|
|
48051
48556
|
|
|
48052
48557
|
// ../plugin/src/features/magic-context/memory/onnx-telemetry.ts
|
|
48053
48558
|
var init_onnx_telemetry = () => {};
|
|
48054
48559
|
|
|
48055
48560
|
// ../plugin/src/features/magic-context/memory/embedding-worker-client.ts
|
|
48056
|
-
var init_embedding_worker_client = __esm(() => {
|
|
48561
|
+
var init_embedding_worker_client = __esm(async () => {
|
|
48057
48562
|
init_logger();
|
|
48058
48563
|
init_onnx_telemetry();
|
|
48564
|
+
await init_sqlite();
|
|
48059
48565
|
});
|
|
48060
48566
|
// ../plugin/src/features/magic-context/memory/embedding-local.ts
|
|
48061
48567
|
function currentLocalEmbeddingHost() {
|
|
@@ -48091,14 +48597,17 @@ function resolveLocalEmbeddingWorkerRuntime(preference = "auto", host = currentL
|
|
|
48091
48597
|
return resolveLocalEmbeddingRuntime(preference, host);
|
|
48092
48598
|
}
|
|
48093
48599
|
var BUN_NAPI_TEARDOWN_FIX_VERSION, STALE_LOCK_MS, MAX_LOCK_WAIT_MS, loadedLocalEmbeddingRuntimes;
|
|
48094
|
-
var init_embedding_local = __esm(() => {
|
|
48600
|
+
var init_embedding_local = __esm(async () => {
|
|
48095
48601
|
init_magic_context();
|
|
48096
48602
|
init_data_path();
|
|
48097
48603
|
init_logger();
|
|
48098
48604
|
init_stale_plugin_build();
|
|
48099
48605
|
init_storage_permissions();
|
|
48100
|
-
|
|
48101
|
-
|
|
48606
|
+
await __promiseAll([
|
|
48607
|
+
init_embedding_identity(),
|
|
48608
|
+
init_embedding_worker_client(),
|
|
48609
|
+
init_sqlite()
|
|
48610
|
+
]);
|
|
48102
48611
|
BUN_NAPI_TEARDOWN_FIX_VERSION = [1, 4, 0];
|
|
48103
48612
|
STALE_LOCK_MS = 3 * 60000;
|
|
48104
48613
|
MAX_LOCK_WAIT_MS = 5 * 60000;
|
|
@@ -48450,8 +48959,8 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
|
|
|
48450
48959
|
return withWasmFallback(native, () => probeWasmRuntimeByResolution(pluginDir));
|
|
48451
48960
|
}
|
|
48452
48961
|
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();
|
|
48962
|
+
var init_embedding_runtime = __esm(async () => {
|
|
48963
|
+
await init_embedding_local();
|
|
48455
48964
|
ONNX_RUNTIME_NODE_LOAD_PROBE_SCRIPT = [
|
|
48456
48965
|
'const { createRequire } = require("node:module");',
|
|
48457
48966
|
'const { join } = require("node:path");',
|
|
@@ -48477,9 +48986,6 @@ var init_embedding_runtime = __esm(() => {
|
|
|
48477
48986
|
// src/lib/logs-opencode.ts
|
|
48478
48987
|
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
48479
48988
|
import { dirname as dirname25, join as join38 } from "node:path";
|
|
48480
|
-
function sanitizeLogContent(content) {
|
|
48481
|
-
return sanitizeDiagnosticText(content);
|
|
48482
|
-
}
|
|
48483
48989
|
function formatTimestamp(date) {
|
|
48484
48990
|
const pad = (value) => String(value).padStart(2, "0");
|
|
48485
48991
|
return [
|
|
@@ -48509,20 +49015,17 @@ function extractHistorianFailureLines(sanitized, limit = 30) {
|
|
|
48509
49015
|
async function bundleIssueReport(report, description, title, sessionFilter = null, options = {}) {
|
|
48510
49016
|
const LOG_TAIL_LINES = 400;
|
|
48511
49017
|
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);
|
|
49018
|
+
const prepared = prepareIssueReport(report, allLogLines, sessionFilter);
|
|
49019
|
+
const { privacy, logLines, recentLog, recentErrorLines } = prepared;
|
|
49020
|
+
report = prepared.report;
|
|
49021
|
+
const historianScanWindow = logLines.slice(-4000).join(`
|
|
49022
|
+
`);
|
|
49023
|
+
const historianFailureLines = extractHistorianFailureLines(historianScanWindow, 30).map((line) => privacy.logLine(line));
|
|
48521
49024
|
const configBody = JSON.stringify(sanitizeConfigValue(report.magicContextConfig.flags), null, 2);
|
|
48522
49025
|
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;
|
|
49026
|
+
const sanitizedDescription = privacy.userText(description);
|
|
49027
|
+
const sanitizedTitle = privacy.userText(title).trim();
|
|
49028
|
+
const selectedSession = sessionFilter ? (report.recentSessions.available ? report.recentSessions.rows : []).find((session) => session.sessionId === privacy.session(sessionFilter)) : undefined;
|
|
48526
49029
|
const sessionContext = selectedSession ? [
|
|
48527
49030
|
"## Session context",
|
|
48528
49031
|
`- Selected session: ${sanitizeDiagnosticText(selectedSession.sessionId)}`,
|
|
@@ -48535,6 +49038,8 @@ async function bundleIssueReport(report, description, title, sessionFilter = nul
|
|
|
48535
49038
|
"## Description",
|
|
48536
49039
|
sanitizedDescription,
|
|
48537
49040
|
"",
|
|
49041
|
+
privacy.notice,
|
|
49042
|
+
"",
|
|
48538
49043
|
"## Environment",
|
|
48539
49044
|
`- Plugin: v${report.pluginVersion}`,
|
|
48540
49045
|
`- OS: ${report.platform} ${report.arch}`,
|
|
@@ -50738,7 +51243,6 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
50738
51243
|
init_removed_agent_config();
|
|
50739
51244
|
init_variable();
|
|
50740
51245
|
init_tick_failure();
|
|
50741
|
-
init_embedding_synapse();
|
|
50742
51246
|
init_auto_update_provenance();
|
|
50743
51247
|
init_conflict_detector();
|
|
50744
51248
|
init_conflict_fixer();
|
|
@@ -50748,7 +51252,6 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
50748
51252
|
init_tui_config();
|
|
50749
51253
|
init_atomic_write();
|
|
50750
51254
|
init_config_location_migration();
|
|
50751
|
-
init_embedding_runtime();
|
|
50752
51255
|
init_github_issue();
|
|
50753
51256
|
init_log_lines();
|
|
50754
51257
|
init_migrate_dreamer_v2_doctor();
|
|
@@ -50756,17 +51259,19 @@ var init_doctor_opencode = __esm(async () => {
|
|
|
50756
51259
|
init_opencode_helpers();
|
|
50757
51260
|
init_opencode_plugin_cache();
|
|
50758
51261
|
init_opencode_plugin_registration();
|
|
50759
|
-
init_opencode_plugin_schema_fence();
|
|
50760
51262
|
init_paths();
|
|
50761
51263
|
init_prompts();
|
|
50762
51264
|
init_redaction2();
|
|
50763
51265
|
await __promiseAll([
|
|
51266
|
+
init_embedding_synapse(),
|
|
50764
51267
|
init_storage_db(),
|
|
50765
51268
|
init_sqlite(),
|
|
50766
51269
|
init_opencode(),
|
|
50767
51270
|
init_database_access(),
|
|
50768
51271
|
init_diagnostics_opencode(),
|
|
51272
|
+
init_embedding_runtime(),
|
|
50769
51273
|
init_logs_opencode(),
|
|
51274
|
+
init_opencode_plugin_schema_fence(),
|
|
50770
51275
|
init_storage_versions(),
|
|
50771
51276
|
init_v22_backfill_commands(),
|
|
50772
51277
|
init_doctor_cached_plugin_fence(),
|
|
@@ -51374,9 +51879,6 @@ var init_diagnostics_pi = __esm(() => {
|
|
|
51374
51879
|
// src/lib/logs-pi.ts
|
|
51375
51880
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
51376
51881
|
import { dirname as dirname27, join as join41 } from "node:path";
|
|
51377
|
-
function sanitizeLogContent2(content) {
|
|
51378
|
-
return sanitizeString2(content);
|
|
51379
|
-
}
|
|
51380
51882
|
function formatTimestamp2(date) {
|
|
51381
51883
|
const pad = (value) => String(value).padStart(2, "0");
|
|
51382
51884
|
return [
|
|
@@ -51392,18 +51894,19 @@ function formatTimestamp2(date) {
|
|
|
51392
51894
|
async function bundleIssueReport2(report, description, title, options = {}) {
|
|
51393
51895
|
const LOG_TAIL_LINES = 400;
|
|
51394
51896
|
const allLogLines = readLogLines(report.logFiles ?? [report.logFile]);
|
|
51395
|
-
const
|
|
51396
|
-
|
|
51397
|
-
|
|
51398
|
-
const
|
|
51399
|
-
|
|
51400
|
-
const recentErrorLines = extractRecentErrors(errorScanWindow, 20);
|
|
51897
|
+
const prepared = prepareIssueReport(report, allLogLines, options.sessionFilter ?? null, [
|
|
51898
|
+
options.cwd ?? process.cwd()
|
|
51899
|
+
]);
|
|
51900
|
+
const { privacy, recentLog, recentErrorLines } = prepared;
|
|
51901
|
+
report = prepared.report;
|
|
51401
51902
|
const rawBodyMarkdown = [
|
|
51402
51903
|
"## Title",
|
|
51403
|
-
`[pi] ${
|
|
51904
|
+
`[pi] ${privacy.userText(title)}`,
|
|
51404
51905
|
"",
|
|
51405
51906
|
"## Description",
|
|
51406
|
-
|
|
51907
|
+
privacy.userText(description),
|
|
51908
|
+
"",
|
|
51909
|
+
privacy.notice,
|
|
51407
51910
|
"",
|
|
51408
51911
|
"## Environment",
|
|
51409
51912
|
`- Pi plugin: v${report.pluginVersion}`,
|
|
@@ -52352,7 +52855,6 @@ var init_doctor_pi = __esm(async () => {
|
|
|
52352
52855
|
init_raw_loader();
|
|
52353
52856
|
init_variable();
|
|
52354
52857
|
init_tick_failure();
|
|
52355
|
-
init_embedding_synapse();
|
|
52356
52858
|
init_data_path();
|
|
52357
52859
|
init_jsonc_edit();
|
|
52358
52860
|
init_jsonc_parser();
|
|
@@ -52361,7 +52863,6 @@ var init_doctor_pi = __esm(async () => {
|
|
|
52361
52863
|
init_atomic_write();
|
|
52362
52864
|
init_config_location_migration();
|
|
52363
52865
|
init_diagnostics_pi();
|
|
52364
|
-
init_embedding_runtime();
|
|
52365
52866
|
init_github_issue();
|
|
52366
52867
|
init_log_lines();
|
|
52367
52868
|
init_logs_pi();
|
|
@@ -52372,8 +52873,10 @@ var init_doctor_pi = __esm(async () => {
|
|
|
52372
52873
|
init_redaction2();
|
|
52373
52874
|
init_setup_pi();
|
|
52374
52875
|
await __promiseAll([
|
|
52876
|
+
init_embedding_synapse(),
|
|
52375
52877
|
init_storage_db(),
|
|
52376
52878
|
init_database_access(),
|
|
52879
|
+
init_embedding_runtime(),
|
|
52377
52880
|
init_storage_versions(),
|
|
52378
52881
|
init_v22_backfill_commands()
|
|
52379
52882
|
]);
|