@iola_adm/iola-cli 0.1.66 → 0.1.67
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/package.json +1 -1
- package/src/cli.js +17 -4
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -8771,7 +8771,8 @@ async function saveConfig(value) {
|
|
|
8771
8771
|
}
|
|
8772
8772
|
|
|
8773
8773
|
async function writeConfig(value) {
|
|
8774
|
-
const
|
|
8774
|
+
const sanitized = sanitizeConfig(value);
|
|
8775
|
+
const errors = validateConfig(sanitized);
|
|
8775
8776
|
if (errors.length > 0) {
|
|
8776
8777
|
throw new Error(`Конфигурация не сохранена: ${errors.join("; ")}`);
|
|
8777
8778
|
}
|
|
@@ -8779,7 +8780,7 @@ async function writeConfig(value) {
|
|
|
8779
8780
|
if (existsSync(CONFIG_FILE)) {
|
|
8780
8781
|
await copyFile(CONFIG_FILE, LAST_GOOD_CONFIG_FILE).catch(() => {});
|
|
8781
8782
|
}
|
|
8782
|
-
await writeFile(CONFIG_FILE, `${JSON.stringify(
|
|
8783
|
+
await writeFile(CONFIG_FILE, `${JSON.stringify(sanitized, null, 2)}\n`, "utf8");
|
|
8783
8784
|
}
|
|
8784
8785
|
|
|
8785
8786
|
async function loadConfig() {
|
|
@@ -8788,7 +8789,7 @@ async function loadConfig() {
|
|
|
8788
8789
|
const value = await readConfigLayer(layer);
|
|
8789
8790
|
if (value) config = mergeConfig(config, value);
|
|
8790
8791
|
}
|
|
8791
|
-
return config;
|
|
8792
|
+
return sanitizeConfig(config);
|
|
8792
8793
|
}
|
|
8793
8794
|
|
|
8794
8795
|
async function loadConfigLayers() {
|
|
@@ -8805,7 +8806,7 @@ async function loadConfigLayers() {
|
|
|
8805
8806
|
continue;
|
|
8806
8807
|
}
|
|
8807
8808
|
const value = await readConfigLayer(layer.file);
|
|
8808
|
-
rows.push({ ...layer, exists: Boolean(value), value, errors: value ? validateConfig(mergeConfig(DEFAULT_AI_CONFIG, value)) : [] });
|
|
8809
|
+
rows.push({ ...layer, exists: Boolean(value), value, errors: value ? validateConfig(sanitizeConfig(mergeConfig(DEFAULT_AI_CONFIG, value))) : [] });
|
|
8809
8810
|
}
|
|
8810
8811
|
rows.push({ scope: "runtime", file: "process.env", exists: true, value: { IOLA_API_BASE_URL: process.env.IOLA_API_BASE_URL || "", IOLA_MCP_BASE_URL: process.env.IOLA_MCP_BASE_URL || "" }, errors: [] });
|
|
8811
8812
|
return rows;
|
|
@@ -8900,6 +8901,18 @@ function mergeConfig(base, override) {
|
|
|
8900
8901
|
};
|
|
8901
8902
|
}
|
|
8902
8903
|
|
|
8904
|
+
function sanitizeConfig(config) {
|
|
8905
|
+
const next = JSON.parse(JSON.stringify(config || {}));
|
|
8906
|
+
if (next.permissions?.localTools && typeof next.permissions.localTools === "object") {
|
|
8907
|
+
for (const tool of Object.keys(next.permissions.localTools)) {
|
|
8908
|
+
if (!ALL_TOOL_ALIASES.includes(tool)) {
|
|
8909
|
+
delete next.permissions.localTools[tool];
|
|
8910
|
+
}
|
|
8911
|
+
}
|
|
8912
|
+
}
|
|
8913
|
+
return next;
|
|
8914
|
+
}
|
|
8915
|
+
|
|
8903
8916
|
function validateConfig(config) {
|
|
8904
8917
|
const errors = [];
|
|
8905
8918
|
if (!config || typeof config !== "object") errors.push("config must be object");
|