@dexto/agent-management 1.16.0 → 1.16.1
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/config/config-enrichment.cjs +2 -0
- package/dist/config/config-enrichment.d.ts +1 -1
- package/dist/config/config-enrichment.d.ts.map +1 -1
- package/dist/config/config-enrichment.js +2 -0
- package/dist/config/config-manager.cjs +19 -6
- package/dist/config/config-manager.d.ts.map +1 -1
- package/dist/config/config-manager.js +21 -7
- package/dist/config/loader.cjs +10 -5
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +10 -5
- package/package.json +6 -6
|
@@ -35,6 +35,7 @@ __export(config_enrichment_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(config_enrichment_exports);
|
|
37
37
|
var import_path = require("../utils/path.js");
|
|
38
|
+
var import_agent_config = require("@dexto/agent-config");
|
|
38
39
|
var path = __toESM(require("path"), 1);
|
|
39
40
|
var import_discover_prompts = require("./discover-prompts.js");
|
|
40
41
|
var import_execution_context = require("../utils/execution-context.js");
|
|
@@ -74,6 +75,7 @@ function resolveEnrichmentWorkspaceRoot(configPath, explicitWorkspaceRoot) {
|
|
|
74
75
|
return (0, import_execution_context.findDextoProjectRoot)() ?? process.cwd();
|
|
75
76
|
}
|
|
76
77
|
function enrichAgentConfig(config, configPath, options = {}) {
|
|
78
|
+
(0, import_agent_config.assertSafeConfigKeys)(config);
|
|
77
79
|
const opts = typeof options === "boolean" ? { isInteractiveCli: options } : options;
|
|
78
80
|
const {
|
|
79
81
|
isInteractiveCli = false,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Core services now require explicit paths - this enrichment layer provides them.
|
|
14
14
|
*/
|
|
15
|
-
import type
|
|
15
|
+
import { type AgentConfig } from '@dexto/agent-config';
|
|
16
16
|
export { discoverCommandPrompts, discoverAgentInstructionFile } from './discover-prompts.js';
|
|
17
17
|
/**
|
|
18
18
|
* Derives an agent ID from config or file path for per-agent isolation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-enrichment.d.ts","sourceRoot":"","sources":["../../src/config/config-enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"config-enrichment.d.ts","sourceRoot":"","sources":["../../src/config/config-enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAO7E,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAoC9E;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,mGAAmG;IACnG,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC/C,uFAAuF;IACvF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAuBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,WAAW,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GAAE,wBAAwB,GAAG,OAAY,GACjD,WAAW,CAoOb"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getDextoPath } from "../utils/path.js";
|
|
2
|
+
import { assertSafeConfigKeys } from "@dexto/agent-config";
|
|
2
3
|
import * as path from "path";
|
|
3
4
|
import { discoverCommandPrompts, discoverAgentInstructionFile } from "./discover-prompts.js";
|
|
4
5
|
import { findDextoProjectRoot } from "../utils/execution-context.js";
|
|
@@ -38,6 +39,7 @@ function resolveEnrichmentWorkspaceRoot(configPath, explicitWorkspaceRoot) {
|
|
|
38
39
|
return findDextoProjectRoot() ?? process.cwd();
|
|
39
40
|
}
|
|
40
41
|
function enrichAgentConfig(config, configPath, options = {}) {
|
|
42
|
+
assertSafeConfigKeys(config);
|
|
41
43
|
const opts = typeof options === "boolean" ? { isInteractiveCli: options } : options;
|
|
42
44
|
const {
|
|
43
45
|
isInteractiveCli = false,
|
|
@@ -39,6 +39,7 @@ __export(config_manager_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(config_manager_exports);
|
|
40
40
|
var import_fs = require("fs");
|
|
41
41
|
var path = __toESM(require("path"), 1);
|
|
42
|
+
var import_node_crypto = require("node:crypto");
|
|
42
43
|
var import_yaml = require("yaml");
|
|
43
44
|
var import_loader = require("./loader.js");
|
|
44
45
|
var import_config_enrichment = require("./config-enrichment.js");
|
|
@@ -46,9 +47,11 @@ var import_agent_config = require("@dexto/agent-config");
|
|
|
46
47
|
var import_core = require("@dexto/core");
|
|
47
48
|
var import_core2 = require("@dexto/core");
|
|
48
49
|
async function updateAgentConfigFile(configPath, updates) {
|
|
50
|
+
(0, import_agent_config.assertSafeConfigKeys)(updates);
|
|
49
51
|
const rawYaml = await import_fs.promises.readFile(configPath, "utf-8");
|
|
50
52
|
const doc = (0, import_yaml.parseDocument)(rawYaml);
|
|
51
53
|
const rawConfig = doc.toJSON();
|
|
54
|
+
(0, import_agent_config.assertSafeConfigKeys)(rawConfig);
|
|
52
55
|
const updatedRawConfig = { ...rawConfig, ...updates };
|
|
53
56
|
const enrichedConfig = (0, import_config_enrichment.enrichAgentConfig)(updatedRawConfig, configPath);
|
|
54
57
|
const parsed = import_agent_config.AgentConfigSchema.safeParse(enrichedConfig);
|
|
@@ -60,18 +63,28 @@ async function updateAgentConfigFile(configPath, updates) {
|
|
|
60
63
|
doc.set(key, value);
|
|
61
64
|
}
|
|
62
65
|
const yamlContent = String(doc);
|
|
63
|
-
|
|
64
|
-
await import_fs.promises.writeFile(tmpPath, yamlContent, "utf-8");
|
|
65
|
-
await import_fs.promises.rename(tmpPath, configPath);
|
|
66
|
+
await writeFileAtomic(configPath, yamlContent);
|
|
66
67
|
return parsed.data;
|
|
67
68
|
}
|
|
68
69
|
async function reloadAgentConfigFromFile(configPath) {
|
|
69
70
|
return await (0, import_loader.loadAgentConfig)(configPath);
|
|
70
71
|
}
|
|
71
72
|
async function writeFileAtomic(configPath, content) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
await import_fs.promises.
|
|
73
|
+
const mode = 384;
|
|
74
|
+
const tmpPath = `${configPath}.${(0, import_node_crypto.randomUUID)()}.tmp`;
|
|
75
|
+
const file = await import_fs.promises.open(tmpPath, "wx", mode);
|
|
76
|
+
try {
|
|
77
|
+
await file.writeFile(content, "utf-8");
|
|
78
|
+
await file.chmod(mode);
|
|
79
|
+
await file.close();
|
|
80
|
+
await import_fs.promises.rename(tmpPath, configPath);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
await file.close().catch(() => {
|
|
83
|
+
});
|
|
84
|
+
await import_fs.promises.unlink(tmpPath).catch(() => {
|
|
85
|
+
});
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
75
88
|
}
|
|
76
89
|
function findMcpServerRange(lines, serverName) {
|
|
77
90
|
let inMcpServersSection = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-manager.d.ts","sourceRoot":"","sources":["../../src/config/config-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-manager.d.ts","sourceRoot":"","sources":["../../src/config/config-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAGH,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAC5B,MAAM,qBAAqB,CAAC;AAI7B;;GAEG;AACH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AO,CAAC,IAAI,CAAC,CAwBf;AAmHD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,2BAA2B,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChF,OAAO,CAAC,IAAI,CAAC,CA2Cf;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACnC,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,sBAAsB,CACxC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,yBAAyB,EACjC,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAyB,GACzD,OAAO,CAAC,oBAAoB,CAAC,CAsD/B"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { promises as fs } from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
3
4
|
import { parseDocument, stringify } from "yaml";
|
|
4
5
|
import { loadAgentConfig } from "./loader.js";
|
|
5
6
|
import { enrichAgentConfig } from "./config-enrichment.js";
|
|
6
7
|
import {
|
|
7
|
-
AgentConfigSchema
|
|
8
|
+
AgentConfigSchema,
|
|
9
|
+
assertSafeConfigKeys
|
|
8
10
|
} from "@dexto/agent-config";
|
|
9
11
|
import { DextoValidationError } from "@dexto/core";
|
|
10
12
|
import { fail, zodToIssues } from "@dexto/core";
|
|
11
13
|
async function updateAgentConfigFile(configPath, updates) {
|
|
14
|
+
assertSafeConfigKeys(updates);
|
|
12
15
|
const rawYaml = await fs.readFile(configPath, "utf-8");
|
|
13
16
|
const doc = parseDocument(rawYaml);
|
|
14
17
|
const rawConfig = doc.toJSON();
|
|
18
|
+
assertSafeConfigKeys(rawConfig);
|
|
15
19
|
const updatedRawConfig = { ...rawConfig, ...updates };
|
|
16
20
|
const enrichedConfig = enrichAgentConfig(updatedRawConfig, configPath);
|
|
17
21
|
const parsed = AgentConfigSchema.safeParse(enrichedConfig);
|
|
@@ -23,18 +27,28 @@ async function updateAgentConfigFile(configPath, updates) {
|
|
|
23
27
|
doc.set(key, value);
|
|
24
28
|
}
|
|
25
29
|
const yamlContent = String(doc);
|
|
26
|
-
|
|
27
|
-
await fs.writeFile(tmpPath, yamlContent, "utf-8");
|
|
28
|
-
await fs.rename(tmpPath, configPath);
|
|
30
|
+
await writeFileAtomic(configPath, yamlContent);
|
|
29
31
|
return parsed.data;
|
|
30
32
|
}
|
|
31
33
|
async function reloadAgentConfigFromFile(configPath) {
|
|
32
34
|
return await loadAgentConfig(configPath);
|
|
33
35
|
}
|
|
34
36
|
async function writeFileAtomic(configPath, content) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
await fs.
|
|
37
|
+
const mode = 384;
|
|
38
|
+
const tmpPath = `${configPath}.${randomUUID()}.tmp`;
|
|
39
|
+
const file = await fs.open(tmpPath, "wx", mode);
|
|
40
|
+
try {
|
|
41
|
+
await file.writeFile(content, "utf-8");
|
|
42
|
+
await file.chmod(mode);
|
|
43
|
+
await file.close();
|
|
44
|
+
await fs.rename(tmpPath, configPath);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
await file.close().catch(() => {
|
|
47
|
+
});
|
|
48
|
+
await fs.unlink(tmpPath).catch(() => {
|
|
49
|
+
});
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
38
52
|
}
|
|
39
53
|
function findMcpServerRange(lines, serverName) {
|
|
40
54
|
let inMcpServersSection = false;
|
package/dist/config/loader.cjs
CHANGED
|
@@ -36,25 +36,30 @@ var import_path = __toESM(require("path"), 1);
|
|
|
36
36
|
var import_yaml = require("yaml");
|
|
37
37
|
var import_errors = require("./errors.js");
|
|
38
38
|
var import_path2 = require("../utils/path.js");
|
|
39
|
+
const FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
39
40
|
function expandTemplateVars(config, context) {
|
|
40
41
|
const result = JSON.parse(JSON.stringify(config));
|
|
41
|
-
function walk(obj) {
|
|
42
|
+
function walk(obj, currentPath) {
|
|
42
43
|
if (typeof obj === "string") {
|
|
43
44
|
return expandString(obj, context);
|
|
44
45
|
}
|
|
45
46
|
if (Array.isArray(obj)) {
|
|
46
|
-
return obj.map(walk);
|
|
47
|
+
return obj.map((value, index) => walk(value, `${currentPath}[${index}]`));
|
|
47
48
|
}
|
|
48
49
|
if (obj !== null && typeof obj === "object") {
|
|
49
|
-
const result2 =
|
|
50
|
+
const result2 = /* @__PURE__ */ Object.create(null);
|
|
50
51
|
for (const [key, value] of Object.entries(obj)) {
|
|
51
|
-
|
|
52
|
+
const keyPath = currentPath ? `${currentPath}.${key}` : key;
|
|
53
|
+
if (FORBIDDEN_KEYS.has(key)) {
|
|
54
|
+
throw new Error(`Forbidden configuration key: ${keyPath}`);
|
|
55
|
+
}
|
|
56
|
+
result2[key] = walk(value, keyPath);
|
|
52
57
|
}
|
|
53
58
|
return result2;
|
|
54
59
|
}
|
|
55
60
|
return obj;
|
|
56
61
|
}
|
|
57
|
-
return walk(result);
|
|
62
|
+
return walk(result, "");
|
|
58
63
|
}
|
|
59
64
|
function expandString(str, context) {
|
|
60
65
|
let result = str;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA4G1C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA6D/F"}
|
package/dist/config/loader.js
CHANGED
|
@@ -3,25 +3,30 @@ import path from "path";
|
|
|
3
3
|
import { parse as parseYaml } from "yaml";
|
|
4
4
|
import { ConfigError } from "./errors.js";
|
|
5
5
|
import { getDextoPath } from "../utils/path.js";
|
|
6
|
+
const FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
6
7
|
function expandTemplateVars(config, context) {
|
|
7
8
|
const result = JSON.parse(JSON.stringify(config));
|
|
8
|
-
function walk(obj) {
|
|
9
|
+
function walk(obj, currentPath) {
|
|
9
10
|
if (typeof obj === "string") {
|
|
10
11
|
return expandString(obj, context);
|
|
11
12
|
}
|
|
12
13
|
if (Array.isArray(obj)) {
|
|
13
|
-
return obj.map(walk);
|
|
14
|
+
return obj.map((value, index) => walk(value, `${currentPath}[${index}]`));
|
|
14
15
|
}
|
|
15
16
|
if (obj !== null && typeof obj === "object") {
|
|
16
|
-
const result2 =
|
|
17
|
+
const result2 = /* @__PURE__ */ Object.create(null);
|
|
17
18
|
for (const [key, value] of Object.entries(obj)) {
|
|
18
|
-
|
|
19
|
+
const keyPath = currentPath ? `${currentPath}.${key}` : key;
|
|
20
|
+
if (FORBIDDEN_KEYS.has(key)) {
|
|
21
|
+
throw new Error(`Forbidden configuration key: ${keyPath}`);
|
|
22
|
+
}
|
|
23
|
+
result2[key] = walk(value, keyPath);
|
|
19
24
|
}
|
|
20
25
|
return result2;
|
|
21
26
|
}
|
|
22
27
|
return obj;
|
|
23
28
|
}
|
|
24
|
-
return walk(result);
|
|
29
|
+
return walk(result, "");
|
|
25
30
|
}
|
|
26
31
|
function expandString(str, context) {
|
|
27
32
|
let result = str;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/agent-management",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"yaml": "^2.8.3",
|
|
24
24
|
"zod": "^4.3.6",
|
|
25
|
-
"@dexto/agent-config": "1.16.
|
|
26
|
-
"@dexto/core": "1.16.
|
|
27
|
-
"@dexto/llm": "1.16.
|
|
28
|
-
"@dexto/orchestration": "1.16.
|
|
29
|
-
"@dexto/tools-builtins": "1.16.
|
|
25
|
+
"@dexto/agent-config": "1.16.1",
|
|
26
|
+
"@dexto/core": "1.16.1",
|
|
27
|
+
"@dexto/llm": "1.16.1",
|
|
28
|
+
"@dexto/orchestration": "1.16.1",
|
|
29
|
+
"@dexto/tools-builtins": "1.16.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.13.5"
|