@cortexkit/magic-context 0.49.28 → 0.49.30
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 +65 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2577,6 +2577,23 @@ function migrateLegacyAgentEnabledInMemory(rawConfig, warnings) {
|
|
|
2577
2577
|
}
|
|
2578
2578
|
var init_agent_disable = () => {};
|
|
2579
2579
|
|
|
2580
|
+
// ../plugin/src/config/commit-retention-recovery.ts
|
|
2581
|
+
function applyCommitRetentionRecovery(config, recoveredFieldPaths, warnings) {
|
|
2582
|
+
if (!recoveredFieldPaths.some((path) => RETENTION_FIELD === path || RETENTION_FIELD.startsWith(`${path}.`)))
|
|
2583
|
+
return;
|
|
2584
|
+
pausedRetention.add(config.memory.git_commit_indexing);
|
|
2585
|
+
const message = `${RETENTION_FIELD}: retention eviction is paused until the invalid value is fixed.`;
|
|
2586
|
+
const index = warnings.findIndex((warning) => warning.includes(RETENTION_FIELD));
|
|
2587
|
+
if (index >= 0)
|
|
2588
|
+
warnings[index] = `${warnings[index]} ${message}`;
|
|
2589
|
+
else
|
|
2590
|
+
warnings.push(message);
|
|
2591
|
+
}
|
|
2592
|
+
var pausedRetention, RETENTION_FIELD = "memory.git_commit_indexing.max_commits";
|
|
2593
|
+
var init_commit_retention_recovery = __esm(() => {
|
|
2594
|
+
pausedRetention = new WeakSet;
|
|
2595
|
+
});
|
|
2596
|
+
|
|
2580
2597
|
// ../plugin/src/config/deprecated-config.ts
|
|
2581
2598
|
function warnDeprecatedMuralModel(config, warnings) {
|
|
2582
2599
|
const mural = config.mural;
|
|
@@ -11326,7 +11343,11 @@ function restoreTrustedValuesOverInvalidProjectValues(args) {
|
|
|
11326
11343
|
if (!changed)
|
|
11327
11344
|
break;
|
|
11328
11345
|
}
|
|
11329
|
-
return {
|
|
11346
|
+
return {
|
|
11347
|
+
warnings,
|
|
11348
|
+
restoredTopLevelKeys: [...restoredTopLevelKeys],
|
|
11349
|
+
restoredFieldPaths: [...restored]
|
|
11350
|
+
};
|
|
11330
11351
|
}
|
|
11331
11352
|
function wellFormedCommand(value) {
|
|
11332
11353
|
if (!isPlainObject2(value))
|
|
@@ -12130,7 +12151,7 @@ function warnProtectedTagsDeprecationOnce() {
|
|
|
12130
12151
|
log("[magic-context] protected_tags is deprecated and ignored; use protected_tokens instead.");
|
|
12131
12152
|
}
|
|
12132
12153
|
}
|
|
12133
|
-
function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
12154
|
+
function parsePluginConfig(rawConfig, recoveredTopLevelKeys = [], recoveredFieldPaths = []) {
|
|
12134
12155
|
const preMigrationWarnings = [];
|
|
12135
12156
|
const configWithoutRemovedAgent = stripRemovedAgentConfig(rawConfig, preMigrationWarnings);
|
|
12136
12157
|
if (Object.hasOwn(rawConfig, "clear_reasoning_age")) {
|
|
@@ -12212,11 +12233,13 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
12212
12233
|
}
|
|
12213
12234
|
if (prunedLeaves.length === issuePaths.length) {
|
|
12214
12235
|
patched[key] = prunedBlock;
|
|
12236
|
+
recoveredFieldPaths.push(...prunedLeaves.map((leaf) => `${key}.${leaf}`));
|
|
12215
12237
|
const reason = customMessagesByKey.get(key);
|
|
12216
12238
|
warnings.push(`"${key}": invalid nested field(s) ${prunedLeaves.map((leaf) => `"${key}.${leaf}"`).join(", ")}, using defaults for those.${reason ? ` ${reason}` : ""}`);
|
|
12217
12239
|
continue;
|
|
12218
12240
|
}
|
|
12219
12241
|
}
|
|
12242
|
+
recoveredFieldPaths.push(key);
|
|
12220
12243
|
if (isAgentConfig) {
|
|
12221
12244
|
delete patched[key];
|
|
12222
12245
|
warnings.push(`"${key}": invalid agent configuration, ignoring. Check your magic-context.jsonc.`);
|
|
@@ -12243,6 +12266,7 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
12243
12266
|
};
|
|
12244
12267
|
}
|
|
12245
12268
|
warnings.push("Config recovery failed, using all defaults.");
|
|
12269
|
+
recoveredFieldPaths.push("embedding", "memory", "subc", "shadow_embedding", "allow_home_project");
|
|
12246
12270
|
return {
|
|
12247
12271
|
...defaults,
|
|
12248
12272
|
disabled_hooks: disabledHooks,
|
|
@@ -12354,6 +12378,7 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
|
|
|
12354
12378
|
let mergedRaw = trustedProfiledRaw;
|
|
12355
12379
|
const trustedBaseConfig = parsePluginConfig(trustedProfiledRaw);
|
|
12356
12380
|
let projectRestoredTopLevelKeys = [];
|
|
12381
|
+
let projectRestoredFieldPaths = [];
|
|
12357
12382
|
if (projectLoaded) {
|
|
12358
12383
|
mergedRaw = deepMergeRawConfig(mergedRaw, profileResolution.projectBase);
|
|
12359
12384
|
for (const warning of dropInheritedEmbeddingKeyOnRedirect(projectRaw, mergedRaw, profileResolution.userBase)) {
|
|
@@ -12376,6 +12401,7 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
|
|
|
12376
12401
|
allWarnings.push(`[project config] ${warning}`);
|
|
12377
12402
|
}
|
|
12378
12403
|
projectRestoredTopLevelKeys = restoredOverProject.restoredTopLevelKeys;
|
|
12404
|
+
projectRestoredFieldPaths = restoredOverProject.restoredFieldPaths;
|
|
12379
12405
|
for (const warning of constrainProjectCommands({
|
|
12380
12406
|
mergedRaw,
|
|
12381
12407
|
trustedRaw: trustedProfiledRaw,
|
|
@@ -12386,8 +12412,10 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
|
|
|
12386
12412
|
}
|
|
12387
12413
|
}
|
|
12388
12414
|
const recoveredTopLevelKeys = [];
|
|
12415
|
+
const recoveredFieldPaths = [];
|
|
12389
12416
|
const cacheTtlConfigured = Object.hasOwn(mergedRaw, "cache_ttl");
|
|
12390
|
-
const config = parsePluginConfig(mergedRaw, recoveredTopLevelKeys);
|
|
12417
|
+
const config = parsePluginConfig(mergedRaw, recoveredTopLevelKeys, recoveredFieldPaths);
|
|
12418
|
+
recoveredFieldPaths.push(...projectRestoredFieldPaths);
|
|
12391
12419
|
for (const key of projectRestoredTopLevelKeys) {
|
|
12392
12420
|
if (!recoveredTopLevelKeys.includes(key))
|
|
12393
12421
|
recoveredTopLevelKeys.push(key);
|
|
@@ -12401,7 +12429,11 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
|
|
|
12401
12429
|
if (applyRuntimeGlobals) {
|
|
12402
12430
|
setOutputReserveConfig(config.output_reserve);
|
|
12403
12431
|
}
|
|
12404
|
-
const
|
|
12432
|
+
const recoveryWarnings = config.configWarnings ?? [];
|
|
12433
|
+
applyCommitRetentionRecovery(config, recoveredFieldPaths, recoveryWarnings);
|
|
12434
|
+
if (recoveryWarnings.length > 0)
|
|
12435
|
+
config.configWarnings = recoveryWarnings;
|
|
12436
|
+
const leafValidationWarnings = [...recoveryWarnings];
|
|
12405
12437
|
if (config.configWarnings?.length) {
|
|
12406
12438
|
allWarnings.push(...config.configWarnings.map((w) => {
|
|
12407
12439
|
if (userLoaded && projectLoaded)
|
|
@@ -12453,6 +12485,7 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
|
|
|
12453
12485
|
sources,
|
|
12454
12486
|
substitutionFailures,
|
|
12455
12487
|
recoveredTopLevelKeys,
|
|
12488
|
+
recoveredFieldPaths,
|
|
12456
12489
|
configParseFailures,
|
|
12457
12490
|
warningDetails,
|
|
12458
12491
|
cacheTtlConfigured
|
|
@@ -12466,6 +12499,7 @@ var init_config = __esm(() => {
|
|
|
12466
12499
|
init_logger();
|
|
12467
12500
|
init_models_dev_cache();
|
|
12468
12501
|
init_agent_disable();
|
|
12502
|
+
init_commit_retention_recovery();
|
|
12469
12503
|
init_migrate_config_location();
|
|
12470
12504
|
init_migrate_dreamer_v2();
|
|
12471
12505
|
init_profiles();
|
|
@@ -34676,8 +34710,8 @@ function isHostUnservedRow(value) {
|
|
|
34676
34710
|
var HOST_UNSERVED_ROW = "hostUnservedRow";
|
|
34677
34711
|
|
|
34678
34712
|
// ../plugin/src/hooks/magic-context/read-session-db.ts
|
|
34679
|
-
function openCodeDbExists() {
|
|
34680
|
-
return harnessOwnsOpenCodeStore() && openCodeDbPathExists(resolveOpenCodeDbPath());
|
|
34713
|
+
function openCodeDbExists(generation = "v1") {
|
|
34714
|
+
return harnessOwnsOpenCodeStore() && openCodeDbPathExists(resolveOpenCodeDbPath(generation));
|
|
34681
34715
|
}
|
|
34682
34716
|
function closeCachedReadOnlyDb(generation) {
|
|
34683
34717
|
const cached = cachedReadOnlyDbs[generation];
|
|
@@ -34696,7 +34730,7 @@ function getReadOnlySessionDb(generation = "v1") {
|
|
|
34696
34730
|
if (!harnessOwnsOpenCodeStore()) {
|
|
34697
34731
|
throw new Error("OpenCode session database is not readable from a Pi-compatible process; its history lives in Pi sessions");
|
|
34698
34732
|
}
|
|
34699
|
-
const resolution = resolveOpenCodeDbPath();
|
|
34733
|
+
const resolution = resolveOpenCodeDbPath(generation);
|
|
34700
34734
|
const dbPath = resolution.path;
|
|
34701
34735
|
if (!openCodeDbPathExists(resolution)) {
|
|
34702
34736
|
throw new Error(`OpenCode session database is unavailable at ${dbPath} (source=${resolution.source})`);
|
|
@@ -34717,8 +34751,8 @@ function getReadOnlySessionDb(generation = "v1") {
|
|
|
34717
34751
|
clearOpenCodeDbReadFailure();
|
|
34718
34752
|
return db;
|
|
34719
34753
|
}
|
|
34720
|
-
function withReadOnlySessionDb(fn) {
|
|
34721
|
-
return fn(getReadOnlySessionDb());
|
|
34754
|
+
function withReadOnlySessionDb(fn, generation = "v1") {
|
|
34755
|
+
return fn(getReadOnlySessionDb(generation));
|
|
34722
34756
|
}
|
|
34723
34757
|
function getRawSessionMessageCountFromDb(db, sessionId) {
|
|
34724
34758
|
const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
|
|
@@ -35123,6 +35157,9 @@ var init_sentinel = __esm(() => {
|
|
|
35123
35157
|
var init_active_anthropic_turn = __esm(() => {
|
|
35124
35158
|
init_sentinel();
|
|
35125
35159
|
});
|
|
35160
|
+
|
|
35161
|
+
// ../plugin/src/shared/marker-only-text.ts
|
|
35162
|
+
var init_marker_only_text = () => {};
|
|
35126
35163
|
// ../plugin/src/hooks/magic-context/served-shape-repair.ts
|
|
35127
35164
|
var sources;
|
|
35128
35165
|
var init_served_shape_repair = __esm(async () => {
|
|
@@ -35135,8 +35172,10 @@ var init_served_shape_repair = __esm(async () => {
|
|
|
35135
35172
|
var METADATA_PART_TYPES, CLEARED_REASONING_TYPES, REASONING_IGNORED_PART_TYPES, REASONING_PART_TYPES, emptyImageParts;
|
|
35136
35173
|
var init_strip_content = __esm(async () => {
|
|
35137
35174
|
init_merged_reasoning_decisions();
|
|
35175
|
+
init_marker_only_text();
|
|
35138
35176
|
init_sentinel();
|
|
35139
35177
|
init_tag_content_primitives();
|
|
35178
|
+
init_marker_only_text();
|
|
35140
35179
|
await init_served_shape_repair();
|
|
35141
35180
|
METADATA_PART_TYPES = new Set([
|
|
35142
35181
|
"step-start",
|
|
@@ -36089,6 +36128,10 @@ function readSessionChunk(sessionId, tokenBudget, offset = 1, eligibleEndOrdinal
|
|
|
36089
36128
|
const meta = { ordinal: msg.ordinal, messageId: msg.id };
|
|
36090
36129
|
if (isHostUnservedRow(msg))
|
|
36091
36130
|
markHostUnservedRow(meta);
|
|
36131
|
+
if (msg.role === "system") {
|
|
36132
|
+
recordFilteredNoise(meta);
|
|
36133
|
+
continue;
|
|
36134
|
+
}
|
|
36092
36135
|
if (msg.role === "user" && !hasMeaningfulChunkUserText(msg.parts)) {
|
|
36093
36136
|
const tcSummaries = msg.parts.flatMap((part) => {
|
|
36094
36137
|
if (expandedResults.has(part))
|
|
@@ -41105,7 +41148,7 @@ function runRecoverShell(sqliteExecutable, sourcePath, recoveredPath, dumpPath)
|
|
|
41105
41148
|
closeSync4(recoveredSeedFd);
|
|
41106
41149
|
const dumpReadFd = openSync4(dumpPath, "r");
|
|
41107
41150
|
try {
|
|
41108
|
-
const replayed = spawnSync4(sqliteExecutable, [recoveredPath], {
|
|
41151
|
+
const replayed = spawnSync4(sqliteExecutable, [recoveredPath, "-cmd", ".dbconfig defensive off"], {
|
|
41109
41152
|
stdio: [dumpReadFd, "ignore", "pipe"],
|
|
41110
41153
|
encoding: "utf8",
|
|
41111
41154
|
windowsHide: true
|
|
@@ -47525,7 +47568,7 @@ function mergeRawConfigs(base, override) {
|
|
|
47525
47568
|
}
|
|
47526
47569
|
return merged;
|
|
47527
47570
|
}
|
|
47528
|
-
function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
47571
|
+
function parsePiConfig(rawConfig, recoveredTopLevelKeys = [], recoveredFieldPaths = []) {
|
|
47529
47572
|
const preMigrationWarnings = [];
|
|
47530
47573
|
if (Object.hasOwn(rawConfig, "clear_reasoning_age")) {
|
|
47531
47574
|
preMigrationWarnings.push("clear_reasoning_age is deprecated and ignored. Magic Context now keeps reasoning up to a token budget, keep_reasoning_tokens (default 10,000). Remove the key, or set keep_reasoning_tokens to a token count.");
|
|
@@ -47590,10 +47633,12 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
47590
47633
|
}
|
|
47591
47634
|
if (prunedLeaves.length === issuePaths.length) {
|
|
47592
47635
|
patched[key] = prunedBlock;
|
|
47636
|
+
recoveredFieldPaths.push(...prunedLeaves.map((leaf) => `${key}.${leaf}`));
|
|
47593
47637
|
warnings.push(`"${key}": invalid nested field(s) ${prunedLeaves.map((leaf) => `"${key}.${leaf}"`).join(", ")}, using defaults for those.`);
|
|
47594
47638
|
continue;
|
|
47595
47639
|
}
|
|
47596
47640
|
}
|
|
47641
|
+
recoveredFieldPaths.push(key);
|
|
47597
47642
|
if (isAgentConfig) {
|
|
47598
47643
|
delete patched[key];
|
|
47599
47644
|
warnings.push(`"${key}": invalid agent configuration, ignoring. Check your magic-context.jsonc.`);
|
|
@@ -47613,6 +47658,7 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
47613
47658
|
return { config: retryParsed.data, warnings };
|
|
47614
47659
|
}
|
|
47615
47660
|
warnings.push("Config recovery failed, using all defaults.");
|
|
47661
|
+
recoveredFieldPaths.push("embedding", "memory", "subc", "shadow_embedding", "allow_home_project");
|
|
47616
47662
|
return { config: defaults, warnings };
|
|
47617
47663
|
}
|
|
47618
47664
|
function collectPiSchemaIssuePaths(rawConfig) {
|
|
@@ -47743,6 +47789,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47743
47789
|
let rawConfig = trustedProfiledRaw;
|
|
47744
47790
|
const trustedBaseConfig = parsePiConfig(trustedProfiledRaw).config;
|
|
47745
47791
|
let projectRestoredTopLevelKeys = [];
|
|
47792
|
+
let projectRestoredFieldPaths = [];
|
|
47746
47793
|
if (projectLayer) {
|
|
47747
47794
|
rawConfig = mergeRawConfigs(rawConfig, profileResolution.projectBase);
|
|
47748
47795
|
for (const warning of dropInheritedEmbeddingKeyOnRedirect(projectRaw, rawConfig, profileResolution.userBase)) {
|
|
@@ -47765,11 +47812,14 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47765
47812
|
warnings.push(`[project config] ${warning}`);
|
|
47766
47813
|
}
|
|
47767
47814
|
projectRestoredTopLevelKeys = restoredOverProject.restoredTopLevelKeys;
|
|
47815
|
+
projectRestoredFieldPaths = restoredOverProject.restoredFieldPaths;
|
|
47768
47816
|
}
|
|
47769
47817
|
const hasDeprecatedProtectedTags = Object.hasOwn(userRaw, "protected_tags") || Object.hasOwn(projectRaw, "protected_tags") || Object.hasOwn(rawConfig, "protected_tags");
|
|
47770
47818
|
const recoveredTopLevelKeys = [];
|
|
47819
|
+
const recoveredFieldPaths = [];
|
|
47771
47820
|
const cacheTtlConfigured = Object.hasOwn(rawConfig, "cache_ttl");
|
|
47772
|
-
const parsed = parsePiConfig(rawConfig, recoveredTopLevelKeys);
|
|
47821
|
+
const parsed = parsePiConfig(rawConfig, recoveredTopLevelKeys, recoveredFieldPaths);
|
|
47822
|
+
recoveredFieldPaths.push(...projectRestoredFieldPaths);
|
|
47773
47823
|
Object.defineProperty(parsed.config, "cacheTtlConfigured", {
|
|
47774
47824
|
value: cacheTtlConfigured
|
|
47775
47825
|
});
|
|
@@ -47786,6 +47836,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47786
47836
|
if (applyRuntimeGlobals) {
|
|
47787
47837
|
setOutputReserveConfig(parsed.config.output_reserve);
|
|
47788
47838
|
}
|
|
47839
|
+
applyCommitRetentionRecovery(parsed.config, recoveredFieldPaths, parsed.warnings);
|
|
47789
47840
|
warnings.push(...parsed.warnings.map((warning) => `[merged config] ${warning}`));
|
|
47790
47841
|
const substitutionFailures = loadedFiles.flatMap(bindSubstitutionFailures2);
|
|
47791
47842
|
const userLoaded = loadedFiles.find((loaded) => loaded.scope === "user");
|
|
@@ -47815,6 +47866,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47815
47866
|
sources,
|
|
47816
47867
|
substitutionFailures,
|
|
47817
47868
|
recoveredTopLevelKeys,
|
|
47869
|
+
recoveredFieldPaths,
|
|
47818
47870
|
configParseFailures,
|
|
47819
47871
|
warningDetails,
|
|
47820
47872
|
cacheTtlConfigured,
|
|
@@ -47824,6 +47876,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47824
47876
|
var init_config2 = __esm(() => {
|
|
47825
47877
|
init_migrate_config_location();
|
|
47826
47878
|
init_agent_disable();
|
|
47879
|
+
init_commit_retention_recovery();
|
|
47827
47880
|
init_migrate_dreamer_v2();
|
|
47828
47881
|
init_profiles();
|
|
47829
47882
|
init_project_security();
|