@cortexkit/magic-context 0.49.27 → 0.49.29
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 +59 -11
- 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 = ?
|
|
@@ -36089,6 +36123,10 @@ function readSessionChunk(sessionId, tokenBudget, offset = 1, eligibleEndOrdinal
|
|
|
36089
36123
|
const meta = { ordinal: msg.ordinal, messageId: msg.id };
|
|
36090
36124
|
if (isHostUnservedRow(msg))
|
|
36091
36125
|
markHostUnservedRow(meta);
|
|
36126
|
+
if (msg.role === "system") {
|
|
36127
|
+
recordFilteredNoise(meta);
|
|
36128
|
+
continue;
|
|
36129
|
+
}
|
|
36092
36130
|
if (msg.role === "user" && !hasMeaningfulChunkUserText(msg.parts)) {
|
|
36093
36131
|
const tcSummaries = msg.parts.flatMap((part) => {
|
|
36094
36132
|
if (expandedResults.has(part))
|
|
@@ -47525,7 +47563,7 @@ function mergeRawConfigs(base, override) {
|
|
|
47525
47563
|
}
|
|
47526
47564
|
return merged;
|
|
47527
47565
|
}
|
|
47528
|
-
function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
47566
|
+
function parsePiConfig(rawConfig, recoveredTopLevelKeys = [], recoveredFieldPaths = []) {
|
|
47529
47567
|
const preMigrationWarnings = [];
|
|
47530
47568
|
if (Object.hasOwn(rawConfig, "clear_reasoning_age")) {
|
|
47531
47569
|
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 +47628,12 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
47590
47628
|
}
|
|
47591
47629
|
if (prunedLeaves.length === issuePaths.length) {
|
|
47592
47630
|
patched[key] = prunedBlock;
|
|
47631
|
+
recoveredFieldPaths.push(...prunedLeaves.map((leaf) => `${key}.${leaf}`));
|
|
47593
47632
|
warnings.push(`"${key}": invalid nested field(s) ${prunedLeaves.map((leaf) => `"${key}.${leaf}"`).join(", ")}, using defaults for those.`);
|
|
47594
47633
|
continue;
|
|
47595
47634
|
}
|
|
47596
47635
|
}
|
|
47636
|
+
recoveredFieldPaths.push(key);
|
|
47597
47637
|
if (isAgentConfig) {
|
|
47598
47638
|
delete patched[key];
|
|
47599
47639
|
warnings.push(`"${key}": invalid agent configuration, ignoring. Check your magic-context.jsonc.`);
|
|
@@ -47613,6 +47653,7 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
47613
47653
|
return { config: retryParsed.data, warnings };
|
|
47614
47654
|
}
|
|
47615
47655
|
warnings.push("Config recovery failed, using all defaults.");
|
|
47656
|
+
recoveredFieldPaths.push("embedding", "memory", "subc", "shadow_embedding", "allow_home_project");
|
|
47616
47657
|
return { config: defaults, warnings };
|
|
47617
47658
|
}
|
|
47618
47659
|
function collectPiSchemaIssuePaths(rawConfig) {
|
|
@@ -47743,6 +47784,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47743
47784
|
let rawConfig = trustedProfiledRaw;
|
|
47744
47785
|
const trustedBaseConfig = parsePiConfig(trustedProfiledRaw).config;
|
|
47745
47786
|
let projectRestoredTopLevelKeys = [];
|
|
47787
|
+
let projectRestoredFieldPaths = [];
|
|
47746
47788
|
if (projectLayer) {
|
|
47747
47789
|
rawConfig = mergeRawConfigs(rawConfig, profileResolution.projectBase);
|
|
47748
47790
|
for (const warning of dropInheritedEmbeddingKeyOnRedirect(projectRaw, rawConfig, profileResolution.userBase)) {
|
|
@@ -47765,11 +47807,14 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47765
47807
|
warnings.push(`[project config] ${warning}`);
|
|
47766
47808
|
}
|
|
47767
47809
|
projectRestoredTopLevelKeys = restoredOverProject.restoredTopLevelKeys;
|
|
47810
|
+
projectRestoredFieldPaths = restoredOverProject.restoredFieldPaths;
|
|
47768
47811
|
}
|
|
47769
47812
|
const hasDeprecatedProtectedTags = Object.hasOwn(userRaw, "protected_tags") || Object.hasOwn(projectRaw, "protected_tags") || Object.hasOwn(rawConfig, "protected_tags");
|
|
47770
47813
|
const recoveredTopLevelKeys = [];
|
|
47814
|
+
const recoveredFieldPaths = [];
|
|
47771
47815
|
const cacheTtlConfigured = Object.hasOwn(rawConfig, "cache_ttl");
|
|
47772
|
-
const parsed = parsePiConfig(rawConfig, recoveredTopLevelKeys);
|
|
47816
|
+
const parsed = parsePiConfig(rawConfig, recoveredTopLevelKeys, recoveredFieldPaths);
|
|
47817
|
+
recoveredFieldPaths.push(...projectRestoredFieldPaths);
|
|
47773
47818
|
Object.defineProperty(parsed.config, "cacheTtlConfigured", {
|
|
47774
47819
|
value: cacheTtlConfigured
|
|
47775
47820
|
});
|
|
@@ -47786,6 +47831,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47786
47831
|
if (applyRuntimeGlobals) {
|
|
47787
47832
|
setOutputReserveConfig(parsed.config.output_reserve);
|
|
47788
47833
|
}
|
|
47834
|
+
applyCommitRetentionRecovery(parsed.config, recoveredFieldPaths, parsed.warnings);
|
|
47789
47835
|
warnings.push(...parsed.warnings.map((warning) => `[merged config] ${warning}`));
|
|
47790
47836
|
const substitutionFailures = loadedFiles.flatMap(bindSubstitutionFailures2);
|
|
47791
47837
|
const userLoaded = loadedFiles.find((loaded) => loaded.scope === "user");
|
|
@@ -47815,6 +47861,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47815
47861
|
sources,
|
|
47816
47862
|
substitutionFailures,
|
|
47817
47863
|
recoveredTopLevelKeys,
|
|
47864
|
+
recoveredFieldPaths,
|
|
47818
47865
|
configParseFailures,
|
|
47819
47866
|
warningDetails,
|
|
47820
47867
|
cacheTtlConfigured,
|
|
@@ -47824,6 +47871,7 @@ function loadPiConfigDetailed(opts = {}, applyRuntimeGlobals = true) {
|
|
|
47824
47871
|
var init_config2 = __esm(() => {
|
|
47825
47872
|
init_migrate_config_location();
|
|
47826
47873
|
init_agent_disable();
|
|
47874
|
+
init_commit_retention_recovery();
|
|
47827
47875
|
init_migrate_dreamer_v2();
|
|
47828
47876
|
init_profiles();
|
|
47829
47877
|
init_project_security();
|