@cortexkit/magic-context 0.22.4 → 0.22.5
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 +204 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -145789,6 +145789,7 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
145789
145789
|
ensureColumn(db, "session_meta", "system_prompt_hash", "TEXT DEFAULT ''");
|
|
145790
145790
|
ensureColumn(db, "session_meta", "cleared_reasoning_through_tag", "INTEGER DEFAULT 0");
|
|
145791
145791
|
ensureColumn(db, "session_meta", "stripped_placeholder_ids", "TEXT DEFAULT ''");
|
|
145792
|
+
ensureColumn(db, "session_meta", "stale_reduce_stripped_ids", "TEXT DEFAULT ''");
|
|
145792
145793
|
ensureColumn(db, "compartments", "start_message_id", "TEXT DEFAULT ''");
|
|
145793
145794
|
ensureColumn(db, "compartments", "end_message_id", "TEXT DEFAULT ''");
|
|
145794
145795
|
ensureColumn(db, "memory_embeddings", "model_id", "TEXT");
|
|
@@ -145939,6 +145940,7 @@ function healNullTextColumns(db) {
|
|
|
145939
145940
|
["todo_synthetic_state_json", ""],
|
|
145940
145941
|
["system_prompt_hash", ""],
|
|
145941
145942
|
["stripped_placeholder_ids", ""],
|
|
145943
|
+
["stale_reduce_stripped_ids", ""],
|
|
145942
145944
|
["memory_block_cache", ""],
|
|
145943
145945
|
["memory_block_ids", ""],
|
|
145944
145946
|
["compaction_marker_state", ""],
|
|
@@ -146914,9 +146916,10 @@ var init_migrations = __esm(async () => {
|
|
|
146914
146916
|
});
|
|
146915
146917
|
|
|
146916
146918
|
// ../plugin/src/features/magic-context/project-docs-hash.ts
|
|
146917
|
-
var docsCache;
|
|
146919
|
+
var MAX_PROJECT_DOC_BYTES, docsCache;
|
|
146918
146920
|
var init_project_docs_hash = __esm(() => {
|
|
146919
146921
|
init_compartment_storage();
|
|
146922
|
+
MAX_PROJECT_DOC_BYTES = 256 * 1024;
|
|
146920
146923
|
docsCache = new Map;
|
|
146921
146924
|
});
|
|
146922
146925
|
|
|
@@ -147595,6 +147598,98 @@ function migrateLegacyExperimental(rawConfig, warnings) {
|
|
|
147595
147598
|
return patched;
|
|
147596
147599
|
}
|
|
147597
147600
|
|
|
147601
|
+
// ../plugin/src/config/project-security.ts
|
|
147602
|
+
function isPlainObject(value) {
|
|
147603
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
147604
|
+
}
|
|
147605
|
+
function stripUnsafeProjectConfigFields(projectRaw) {
|
|
147606
|
+
const warnings = [];
|
|
147607
|
+
if ("auto_update" in projectRaw) {
|
|
147608
|
+
delete projectRaw.auto_update;
|
|
147609
|
+
warnings.push("Ignoring auto_update from project config (security: this setting only honors user-level config).");
|
|
147610
|
+
}
|
|
147611
|
+
for (const agentKey of HIDDEN_AGENT_KEYS) {
|
|
147612
|
+
const block = projectRaw[agentKey];
|
|
147613
|
+
if (!isPlainObject(block))
|
|
147614
|
+
continue;
|
|
147615
|
+
const removed = [];
|
|
147616
|
+
for (const field of AGENT_ESCALATION_FIELDS) {
|
|
147617
|
+
if (field in block) {
|
|
147618
|
+
delete block[field];
|
|
147619
|
+
removed.push(field);
|
|
147620
|
+
}
|
|
147621
|
+
}
|
|
147622
|
+
if (removed.length > 0) {
|
|
147623
|
+
warnings.push(`Ignoring ${agentKey}.${removed.join("/")} from project config ` + "(security: a repository cannot reprogram or re-permission hidden agents).");
|
|
147624
|
+
}
|
|
147625
|
+
}
|
|
147626
|
+
return warnings;
|
|
147627
|
+
}
|
|
147628
|
+
function normalizeEndpoint(value) {
|
|
147629
|
+
if (typeof value !== "string")
|
|
147630
|
+
return;
|
|
147631
|
+
const trimmed = value.trim().replace(/\/+$/, "");
|
|
147632
|
+
return trimmed.length > 0 ? trimmed.toLowerCase() : undefined;
|
|
147633
|
+
}
|
|
147634
|
+
function dropInheritedEmbeddingKeyOnRedirect(projectRaw, mergedRaw, userRaw) {
|
|
147635
|
+
const projectEmbedding = projectRaw.embedding;
|
|
147636
|
+
if (!isPlainObject(projectEmbedding))
|
|
147637
|
+
return [];
|
|
147638
|
+
const redirectsEndpoint = "endpoint" in projectEmbedding;
|
|
147639
|
+
if (!redirectsEndpoint)
|
|
147640
|
+
return [];
|
|
147641
|
+
const userEmbedding = userRaw?.embedding;
|
|
147642
|
+
if (isPlainObject(userEmbedding)) {
|
|
147643
|
+
const projectEndpoint = normalizeEndpoint(projectEmbedding.endpoint);
|
|
147644
|
+
const userEndpoint = normalizeEndpoint(userEmbedding.endpoint);
|
|
147645
|
+
if (projectEndpoint !== undefined && projectEndpoint === userEndpoint) {
|
|
147646
|
+
return [];
|
|
147647
|
+
}
|
|
147648
|
+
}
|
|
147649
|
+
const providesOwnKey = typeof projectEmbedding.api_key === "string" && projectEmbedding.api_key.length > 0;
|
|
147650
|
+
if (providesOwnKey)
|
|
147651
|
+
return [];
|
|
147652
|
+
const mergedEmbedding = mergedRaw.embedding;
|
|
147653
|
+
if (!isPlainObject(mergedEmbedding))
|
|
147654
|
+
return [];
|
|
147655
|
+
if (!("api_key" in mergedEmbedding))
|
|
147656
|
+
return [];
|
|
147657
|
+
delete mergedEmbedding.api_key;
|
|
147658
|
+
return [
|
|
147659
|
+
"Dropped inherited user embedding api_key because project config redirected " + "embedding.endpoint without supplying its own key (security: prevents key " + "exfiltration to a repository-chosen endpoint)."
|
|
147660
|
+
];
|
|
147661
|
+
}
|
|
147662
|
+
var HIDDEN_AGENT_KEYS, AGENT_ESCALATION_FIELDS;
|
|
147663
|
+
var init_project_security = __esm(() => {
|
|
147664
|
+
HIDDEN_AGENT_KEYS = ["historian", "dreamer", "sidekick"];
|
|
147665
|
+
AGENT_ESCALATION_FIELDS = ["prompt", "permission", "tools", "system_prompt"];
|
|
147666
|
+
});
|
|
147667
|
+
|
|
147668
|
+
// ../plugin/src/config/prune-config-leaf.ts
|
|
147669
|
+
function isPlainObject2(value) {
|
|
147670
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
147671
|
+
}
|
|
147672
|
+
function pruneNestedConfigLeaf(block, relativePath) {
|
|
147673
|
+
if (relativePath.length === 0)
|
|
147674
|
+
return null;
|
|
147675
|
+
const result = { ...block };
|
|
147676
|
+
let cursor = result;
|
|
147677
|
+
for (let i = 0;i < relativePath.length - 1; i++) {
|
|
147678
|
+
const seg = String(relativePath[i]);
|
|
147679
|
+
const child = cursor[seg];
|
|
147680
|
+
if (!isPlainObject2(child))
|
|
147681
|
+
return null;
|
|
147682
|
+
const clonedChild = { ...child };
|
|
147683
|
+
cursor[seg] = clonedChild;
|
|
147684
|
+
cursor = clonedChild;
|
|
147685
|
+
}
|
|
147686
|
+
const leaf = String(relativePath[relativePath.length - 1]);
|
|
147687
|
+
if (!(leaf in cursor))
|
|
147688
|
+
return null;
|
|
147689
|
+
delete cursor[leaf];
|
|
147690
|
+
return { block: result, removed: relativePath.map(String).join(".") };
|
|
147691
|
+
}
|
|
147692
|
+
|
|
147598
147693
|
// ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
147599
147694
|
function $constructor(name2, initializer, params) {
|
|
147600
147695
|
function init(inst, def) {
|
|
@@ -147705,7 +147800,7 @@ __export(exports_util, {
|
|
|
147705
147800
|
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
147706
147801
|
joinValues: () => joinValues,
|
|
147707
147802
|
issue: () => issue,
|
|
147708
|
-
isPlainObject: () =>
|
|
147803
|
+
isPlainObject: () => isPlainObject3,
|
|
147709
147804
|
isObject: () => isObject,
|
|
147710
147805
|
hexToUint8Array: () => hexToUint8Array,
|
|
147711
147806
|
getSizableOrigin: () => getSizableOrigin,
|
|
@@ -147870,7 +147965,7 @@ function slugify(input) {
|
|
|
147870
147965
|
function isObject(data) {
|
|
147871
147966
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
147872
147967
|
}
|
|
147873
|
-
function
|
|
147968
|
+
function isPlainObject3(o) {
|
|
147874
147969
|
if (isObject(o) === false)
|
|
147875
147970
|
return false;
|
|
147876
147971
|
const ctor = o.constructor;
|
|
@@ -147887,7 +147982,7 @@ function isPlainObject(o) {
|
|
|
147887
147982
|
return true;
|
|
147888
147983
|
}
|
|
147889
147984
|
function shallowClone(o) {
|
|
147890
|
-
if (
|
|
147985
|
+
if (isPlainObject3(o))
|
|
147891
147986
|
return { ...o };
|
|
147892
147987
|
if (Array.isArray(o))
|
|
147893
147988
|
return [...o];
|
|
@@ -148027,7 +148122,7 @@ function omit(schema, mask) {
|
|
|
148027
148122
|
return clone(schema, def);
|
|
148028
148123
|
}
|
|
148029
148124
|
function extend(schema, shape) {
|
|
148030
|
-
if (!
|
|
148125
|
+
if (!isPlainObject3(shape)) {
|
|
148031
148126
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
148032
148127
|
}
|
|
148033
148128
|
const checks = schema._zod.def.checks;
|
|
@@ -148050,7 +148145,7 @@ function extend(schema, shape) {
|
|
|
148050
148145
|
return clone(schema, def);
|
|
148051
148146
|
}
|
|
148052
148147
|
function safeExtend(schema, shape) {
|
|
148053
|
-
if (!
|
|
148148
|
+
if (!isPlainObject3(shape)) {
|
|
148054
148149
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
148055
148150
|
}
|
|
148056
148151
|
const def = mergeDefs(schema._zod.def, {
|
|
@@ -149533,7 +149628,7 @@ function mergeValues(a, b2) {
|
|
|
149533
149628
|
if (a instanceof Date && b2 instanceof Date && +a === +b2) {
|
|
149534
149629
|
return { valid: true, data: a };
|
|
149535
149630
|
}
|
|
149536
|
-
if (
|
|
149631
|
+
if (isPlainObject3(a) && isPlainObject3(b2)) {
|
|
149537
149632
|
const bKeys = Object.keys(b2);
|
|
149538
149633
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
149539
149634
|
const newObj = { ...a, ...b2 };
|
|
@@ -150790,7 +150885,7 @@ var init_schemas = __esm(() => {
|
|
|
150790
150885
|
$ZodType.init(inst, def);
|
|
150791
150886
|
inst._zod.parse = (payload, ctx) => {
|
|
150792
150887
|
const input = payload.value;
|
|
150793
|
-
if (!
|
|
150888
|
+
if (!isPlainObject3(input)) {
|
|
150794
150889
|
payload.issues.push({
|
|
150795
150890
|
expected: "record",
|
|
150796
150891
|
code: "invalid_type",
|
|
@@ -162427,6 +162522,21 @@ var init_magic_context = __esm(() => {
|
|
|
162427
162522
|
import { existsSync as existsSync14, readFileSync as readFileSync8 } from "node:fs";
|
|
162428
162523
|
import { homedir as homedir7 } from "node:os";
|
|
162429
162524
|
import { dirname as dirname7, isAbsolute, resolve as resolve2 } from "node:path";
|
|
162525
|
+
function sensitiveFilePathReason(resolvedPath) {
|
|
162526
|
+
const home = homedir7();
|
|
162527
|
+
const sensitiveDirs = [
|
|
162528
|
+
{ dir: resolve2(home, ".ssh"), label: "SSH keys" },
|
|
162529
|
+
{ dir: resolve2(home, ".aws"), label: "AWS credentials" },
|
|
162530
|
+
{ dir: resolve2(home, ".gnupg"), label: "GnuPG keyring" },
|
|
162531
|
+
{ dir: resolve2(home, ".config", "gh"), label: "GitHub CLI auth" }
|
|
162532
|
+
];
|
|
162533
|
+
for (const { dir, label } of sensitiveDirs) {
|
|
162534
|
+
if (resolvedPath === dir || resolvedPath.startsWith(`${dir}/`)) {
|
|
162535
|
+
return label;
|
|
162536
|
+
}
|
|
162537
|
+
}
|
|
162538
|
+
return null;
|
|
162539
|
+
}
|
|
162430
162540
|
function substituteConfigVariables(input) {
|
|
162431
162541
|
const warnings = [];
|
|
162432
162542
|
let text2 = input.text;
|
|
@@ -162480,6 +162590,10 @@ function substituteConfigVariables(input) {
|
|
|
162480
162590
|
} else if (!isAbsolute(filePath)) {
|
|
162481
162591
|
filePath = resolve2(configDir, filePath);
|
|
162482
162592
|
}
|
|
162593
|
+
const sensitiveReason = sensitiveFilePathReason(filePath);
|
|
162594
|
+
if (sensitiveReason) {
|
|
162595
|
+
warnings.push(`${token} resolves to a sensitive path (${sensitiveReason}: ${filePath}); ` + "inlining its contents into config — make sure this is intentional.");
|
|
162596
|
+
}
|
|
162483
162597
|
if (!existsSync14(filePath)) {
|
|
162484
162598
|
warnings.push(`File not found for ${token} (resolved to ${filePath}); using empty string`);
|
|
162485
162599
|
continue;
|
|
@@ -162550,9 +162664,6 @@ function deepMergeRawConfig(base, override) {
|
|
|
162550
162664
|
}
|
|
162551
162665
|
return result;
|
|
162552
162666
|
}
|
|
162553
|
-
function getProjectUserOnlyFields(config2) {
|
|
162554
|
-
return "auto_update" in config2 ? ["auto_update"] : [];
|
|
162555
|
-
}
|
|
162556
162667
|
function redactConfigValue(value) {
|
|
162557
162668
|
if (value === undefined)
|
|
162558
162669
|
return "<missing>";
|
|
@@ -162591,12 +162702,16 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
162591
162702
|
const warnings = [];
|
|
162592
162703
|
const errorPaths = new Set;
|
|
162593
162704
|
const customMessagesByKey = new Map;
|
|
162705
|
+
const issuePathsByKey = new Map;
|
|
162594
162706
|
const GENERIC_ZOD_PREFIXES = ["Too big", "Too small", "Invalid input", "Invalid", "Expected"];
|
|
162595
162707
|
for (const issue2 of parsed.error.issues) {
|
|
162596
162708
|
const topKey = issue2.path[0];
|
|
162597
162709
|
if (topKey !== undefined) {
|
|
162598
162710
|
const key = String(topKey);
|
|
162599
162711
|
errorPaths.add(key);
|
|
162712
|
+
const paths = issuePathsByKey.get(key) ?? [];
|
|
162713
|
+
paths.push([...issue2.path]);
|
|
162714
|
+
issuePathsByKey.set(key, paths);
|
|
162600
162715
|
const msg = issue2.message;
|
|
162601
162716
|
if (msg && !GENERIC_ZOD_PREFIXES.some((p2) => msg.startsWith(p2))) {
|
|
162602
162717
|
if (!customMessagesByKey.has(key)) {
|
|
@@ -162612,12 +162727,33 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
162612
162727
|
if (isAgentConfig) {
|
|
162613
162728
|
delete patched[key];
|
|
162614
162729
|
warnings.push(`"${key}": invalid agent configuration, ignoring. Check your magic-context.jsonc.`);
|
|
162615
|
-
|
|
162616
|
-
|
|
162617
|
-
|
|
162618
|
-
|
|
162619
|
-
|
|
162730
|
+
continue;
|
|
162731
|
+
}
|
|
162732
|
+
const issuePaths = issuePathsByKey.get(key) ?? [];
|
|
162733
|
+
const rawValue = rawConfig[key];
|
|
162734
|
+
const allNested = issuePaths.length > 0 && issuePaths.every((p2) => p2.length >= 2) && typeof rawValue === "object" && rawValue !== null && !Array.isArray(rawValue);
|
|
162735
|
+
if (allNested) {
|
|
162736
|
+
let prunedBlock = {
|
|
162737
|
+
...rawValue
|
|
162738
|
+
};
|
|
162739
|
+
const prunedLeaves = [];
|
|
162740
|
+
for (const p2 of issuePaths) {
|
|
162741
|
+
const relative = p2.slice(1);
|
|
162742
|
+
const result = pruneNestedConfigLeaf(prunedBlock, relative);
|
|
162743
|
+
if (result) {
|
|
162744
|
+
prunedBlock = result.block;
|
|
162745
|
+
prunedLeaves.push(result.removed);
|
|
162746
|
+
}
|
|
162747
|
+
}
|
|
162748
|
+
patched[key] = prunedBlock;
|
|
162749
|
+
const reason2 = customMessagesByKey.get(key);
|
|
162750
|
+
warnings.push(`"${key}": invalid nested field(s) ${prunedLeaves.map((l) => `"${l}"`).join(", ")}, using defaults for those.${reason2 ? ` ${reason2}` : ""}`);
|
|
162751
|
+
continue;
|
|
162620
162752
|
}
|
|
162753
|
+
delete patched[key];
|
|
162754
|
+
const defaultVal = defaults[key];
|
|
162755
|
+
const reason = customMessagesByKey.get(key);
|
|
162756
|
+
warnings.push(`"${key}": invalid value (${redactConfigValue(rawConfig[key])}), using default ${JSON.stringify(defaultVal)}.${reason ? ` ${reason}` : ""}`);
|
|
162621
162757
|
}
|
|
162622
162758
|
const retryMigrated = migrateLegacyExperimental(patched, preMigrationWarnings);
|
|
162623
162759
|
const retryParsed = MagicContextConfigSchema.safeParse(retryMigrated);
|
|
@@ -162653,14 +162789,13 @@ function loadPluginConfig(directory) {
|
|
|
162653
162789
|
if (projectLoaded) {
|
|
162654
162790
|
allWarnings.push(...projectLoaded.warnings.map((w3) => `[project config] ${w3}`));
|
|
162655
162791
|
const projectRaw = { ...projectLoaded.config };
|
|
162656
|
-
const
|
|
162657
|
-
|
|
162658
|
-
for (const key of strippedUserOnlyFields) {
|
|
162659
|
-
delete projectRaw[key];
|
|
162660
|
-
}
|
|
162661
|
-
allWarnings.push(`[project config] Ignoring ${strippedUserOnlyFields.join(", ")} from project config (security: these settings only honor user-level config)`);
|
|
162792
|
+
for (const warning of stripUnsafeProjectConfigFields(projectRaw)) {
|
|
162793
|
+
allWarnings.push(`[project config] ${warning}`);
|
|
162662
162794
|
}
|
|
162663
162795
|
mergedRaw = deepMergeRawConfig(mergedRaw, projectRaw);
|
|
162796
|
+
for (const warning of dropInheritedEmbeddingKeyOnRedirect(projectRaw, mergedRaw, userLoaded?.config)) {
|
|
162797
|
+
allWarnings.push(`[project config] ${warning}`);
|
|
162798
|
+
}
|
|
162664
162799
|
}
|
|
162665
162800
|
const config2 = parsePluginConfig(mergedRaw);
|
|
162666
162801
|
if (config2.configWarnings?.length) {
|
|
@@ -162682,6 +162817,7 @@ function loadPluginConfig(directory) {
|
|
|
162682
162817
|
var CONFIG_FILE_BASENAME = "magic-context";
|
|
162683
162818
|
var init_config = __esm(() => {
|
|
162684
162819
|
init_jsonc_parser();
|
|
162820
|
+
init_project_security();
|
|
162685
162821
|
init_magic_context();
|
|
162686
162822
|
init_variable();
|
|
162687
162823
|
});
|
|
@@ -164775,7 +164911,8 @@ function loadConfigFile2(path5, scope) {
|
|
|
164775
164911
|
const rawText = readFileSync15(path5, "utf-8");
|
|
164776
164912
|
const substituted = substituteConfigVariables({
|
|
164777
164913
|
text: rawText,
|
|
164778
|
-
configPath: path5
|
|
164914
|
+
configPath: path5,
|
|
164915
|
+
isProjectConfig: scope === "project"
|
|
164779
164916
|
});
|
|
164780
164917
|
return {
|
|
164781
164918
|
path: path5,
|
|
@@ -164817,14 +164954,14 @@ function redactConfigValue2(value) {
|
|
|
164817
164954
|
}
|
|
164818
164955
|
return typeof value;
|
|
164819
164956
|
}
|
|
164820
|
-
function
|
|
164957
|
+
function isPlainObject4(value) {
|
|
164821
164958
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
164822
164959
|
}
|
|
164823
164960
|
function mergeRawConfigs(base, override) {
|
|
164824
164961
|
const merged = { ...base };
|
|
164825
164962
|
for (const [key, overrideValue] of Object.entries(override)) {
|
|
164826
164963
|
const baseValue = merged[key];
|
|
164827
|
-
merged[key] =
|
|
164964
|
+
merged[key] = isPlainObject4(baseValue) && isPlainObject4(overrideValue) ? mergeRawConfigs(baseValue, overrideValue) : overrideValue;
|
|
164828
164965
|
}
|
|
164829
164966
|
return merged;
|
|
164830
164967
|
}
|
|
@@ -164838,10 +164975,15 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
164838
164975
|
}
|
|
164839
164976
|
const defaults = MagicContextConfigSchema.parse({});
|
|
164840
164977
|
const errorPaths = new Set;
|
|
164978
|
+
const issuePathsByKey = new Map;
|
|
164841
164979
|
for (const issue2 of parsed.error.issues) {
|
|
164842
164980
|
const topKey = issue2.path[0];
|
|
164843
164981
|
if (topKey !== undefined) {
|
|
164844
|
-
|
|
164982
|
+
const key = String(topKey);
|
|
164983
|
+
errorPaths.add(key);
|
|
164984
|
+
const paths = issuePathsByKey.get(key) ?? [];
|
|
164985
|
+
paths.push([...issue2.path]);
|
|
164986
|
+
issuePathsByKey.set(key, paths);
|
|
164845
164987
|
}
|
|
164846
164988
|
}
|
|
164847
164989
|
const patched = { ...migrated };
|
|
@@ -164849,11 +164991,32 @@ function parsePiConfig(rawConfig, recoveredTopLevelKeys = []) {
|
|
|
164849
164991
|
for (const key of errorPaths) {
|
|
164850
164992
|
recoveredTopLevelKeys.push(key);
|
|
164851
164993
|
const isAgentConfig = key === "historian" || key === "dreamer" || key === "sidekick";
|
|
164852
|
-
delete patched[key];
|
|
164853
164994
|
if (isAgentConfig) {
|
|
164995
|
+
delete patched[key];
|
|
164854
164996
|
warnings.push(`"${key}": invalid agent configuration, ignoring. Check your magic-context.jsonc.`);
|
|
164855
164997
|
continue;
|
|
164856
164998
|
}
|
|
164999
|
+
const issuePaths = issuePathsByKey.get(key) ?? [];
|
|
165000
|
+
const rawValue = migrated[key];
|
|
165001
|
+
const allNested = issuePaths.length > 0 && issuePaths.every((p2) => p2.length >= 2) && typeof rawValue === "object" && rawValue !== null && !Array.isArray(rawValue);
|
|
165002
|
+
if (allNested) {
|
|
165003
|
+
let prunedBlock = {
|
|
165004
|
+
...rawValue
|
|
165005
|
+
};
|
|
165006
|
+
const prunedLeaves = [];
|
|
165007
|
+
for (const p2 of issuePaths) {
|
|
165008
|
+
const relative = p2.slice(1);
|
|
165009
|
+
const result = pruneNestedConfigLeaf(prunedBlock, relative);
|
|
165010
|
+
if (result) {
|
|
165011
|
+
prunedBlock = result.block;
|
|
165012
|
+
prunedLeaves.push(result.removed);
|
|
165013
|
+
}
|
|
165014
|
+
}
|
|
165015
|
+
patched[key] = prunedBlock;
|
|
165016
|
+
warnings.push(`"${key}": invalid nested field(s) ${prunedLeaves.map((l) => `"${l}"`).join(", ")}, using defaults for those.`);
|
|
165017
|
+
continue;
|
|
165018
|
+
}
|
|
165019
|
+
delete patched[key];
|
|
164857
165020
|
const defaultValue = defaults[key];
|
|
164858
165021
|
warnings.push(`"${key}": invalid value (${redactConfigValue2(rawConfig[key])}), using default ${JSON.stringify(defaultValue)}.`);
|
|
164859
165022
|
}
|
|
@@ -164886,10 +165049,22 @@ function loadPiConfig(opts = {}) {
|
|
|
164886
165049
|
return 0;
|
|
164887
165050
|
return a.scope === "user" ? -1 : 1;
|
|
164888
165051
|
});
|
|
165052
|
+
const userRaw = mergeFiles.find((f) => f.scope === "user")?.config;
|
|
164889
165053
|
for (const loaded of mergeFiles) {
|
|
164890
165054
|
const prefix = loaded.scope === "user" ? "[user config]" : "[project config]";
|
|
164891
165055
|
warnings.push(...loaded.warnings.map((warning) => `${prefix} ${warning}`));
|
|
164892
|
-
|
|
165056
|
+
if (loaded.scope === "project") {
|
|
165057
|
+
const projectRaw = { ...loaded.config };
|
|
165058
|
+
for (const warning of stripUnsafeProjectConfigFields(projectRaw)) {
|
|
165059
|
+
warnings.push(`${prefix} ${warning}`);
|
|
165060
|
+
}
|
|
165061
|
+
rawConfig = mergeRawConfigs(rawConfig, projectRaw);
|
|
165062
|
+
for (const warning of dropInheritedEmbeddingKeyOnRedirect(projectRaw, rawConfig, userRaw)) {
|
|
165063
|
+
warnings.push(`${prefix} ${warning}`);
|
|
165064
|
+
}
|
|
165065
|
+
} else {
|
|
165066
|
+
rawConfig = mergeRawConfigs(rawConfig, loaded.config);
|
|
165067
|
+
}
|
|
164893
165068
|
}
|
|
164894
165069
|
const parsed = parsePiConfig(rawConfig);
|
|
164895
165070
|
warnings.push(...parsed.warnings.map((warning) => `[merged config] ${warning}`));
|
|
@@ -164901,6 +165076,7 @@ function loadPiConfig(opts = {}) {
|
|
|
164901
165076
|
}
|
|
164902
165077
|
var import_comment_json10, CONFIG_FILE_NAME = "magic-context";
|
|
164903
165078
|
var init_config2 = __esm(() => {
|
|
165079
|
+
init_project_security();
|
|
164904
165080
|
init_magic_context();
|
|
164905
165081
|
init_variable();
|
|
164906
165082
|
import_comment_json10 = __toESM(require_src2(), 1);
|