@dexto/agent-management 1.4.0 → 1.5.0
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/AgentFactory.cjs +1 -2
- package/dist/AgentFactory.d.ts +1 -1
- package/dist/AgentFactory.d.ts.map +1 -1
- package/dist/AgentFactory.js +1 -2
- package/dist/config/config-enrichment.cjs +1 -1
- package/dist/config/config-enrichment.d.ts +1 -1
- package/dist/config/config-enrichment.js +1 -1
- package/dist/config/errors.cjs +2 -2
- package/dist/config/errors.js +2 -2
- package/dist/index.cjs +69 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -2
- package/dist/installation.cjs +0 -13
- package/dist/installation.d.ts +0 -2
- package/dist/installation.d.ts.map +1 -1
- package/dist/installation.js +0 -13
- package/dist/models/custom-models.cjs +43 -2
- package/dist/models/custom-models.d.ts +49 -6
- package/dist/models/custom-models.d.ts.map +1 -1
- package/dist/models/custom-models.js +42 -2
- package/dist/models/index.cjs +89 -0
- package/dist/models/index.d.ts +11 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +68 -0
- package/dist/models/path-resolver.cjs +154 -0
- package/dist/models/path-resolver.d.ts +77 -0
- package/dist/models/path-resolver.d.ts.map +1 -0
- package/dist/models/path-resolver.js +108 -0
- package/dist/models/state-manager.cjs +220 -0
- package/dist/models/state-manager.d.ts +138 -0
- package/dist/models/state-manager.d.ts.map +1 -0
- package/dist/models/state-manager.js +184 -0
- package/dist/preferences/error-codes.cjs +2 -0
- package/dist/preferences/error-codes.d.ts +3 -1
- package/dist/preferences/error-codes.d.ts.map +1 -1
- package/dist/preferences/error-codes.js +2 -0
- package/dist/preferences/index.d.ts +1 -1
- package/dist/preferences/index.d.ts.map +1 -1
- package/dist/preferences/loader.cjs +32 -6
- package/dist/preferences/loader.d.ts +23 -4
- package/dist/preferences/loader.d.ts.map +1 -1
- package/dist/preferences/loader.js +32 -6
- package/dist/preferences/schemas.cjs +21 -3
- package/dist/preferences/schemas.d.ts +52 -24
- package/dist/preferences/schemas.d.ts.map +1 -1
- package/dist/preferences/schemas.js +28 -4
- package/dist/registry/registry.cjs +7 -43
- package/dist/registry/registry.d.ts +3 -6
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +7 -43
- package/dist/registry/types.d.ts +2 -4
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/resolver.cjs +20 -20
- package/dist/resolver.d.ts +1 -2
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +20 -20
- package/dist/utils/api-key-resolver.cjs +19 -1
- package/dist/utils/api-key-resolver.d.ts.map +1 -1
- package/dist/utils/api-key-resolver.js +19 -1
- package/dist/utils/api-key-store.cjs +46 -0
- package/dist/utils/api-key-store.d.ts +27 -0
- package/dist/utils/api-key-store.d.ts.map +1 -1
- package/dist/utils/api-key-store.js +44 -0
- package/dist/utils/env-file.cjs +20 -68
- package/dist/utils/env-file.d.ts +2 -1
- package/dist/utils/env-file.d.ts.map +1 -1
- package/dist/utils/env-file.js +20 -68
- package/dist/writer.cjs +20 -2
- package/dist/writer.d.ts +1 -0
- package/dist/writer.d.ts.map +1 -1
- package/dist/writer.js +20 -2
- package/package.json +2 -2
package/dist/utils/env-file.js
CHANGED
|
@@ -1,83 +1,35 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { promises as fs } from "node:fs";
|
|
3
|
-
const DEXTO_ENV_KEYS = [
|
|
4
|
-
"OPENAI_API_KEY",
|
|
5
|
-
"ANTHROPIC_API_KEY",
|
|
6
|
-
"GOOGLE_GENERATIVE_AI_API_KEY",
|
|
7
|
-
"GROQ_API_KEY",
|
|
8
|
-
"COHERE_API_KEY",
|
|
9
|
-
"XAI_API_KEY",
|
|
10
|
-
"DEXTO_LOG_LEVEL"
|
|
11
|
-
];
|
|
12
|
-
function isDextoEnvKey(value) {
|
|
13
|
-
return DEXTO_ENV_KEYS.includes(value);
|
|
14
|
-
}
|
|
15
3
|
async function updateEnvFile(envFilePath, updates) {
|
|
16
4
|
await fs.mkdir(path.dirname(envFilePath), { recursive: true });
|
|
17
|
-
let
|
|
5
|
+
let content = "";
|
|
18
6
|
try {
|
|
19
|
-
|
|
20
|
-
envLines = existingEnv.split("\n");
|
|
7
|
+
content = await fs.readFile(envFilePath, "utf8");
|
|
21
8
|
} catch {
|
|
22
9
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
const lines = content.split("\n");
|
|
11
|
+
const updatedKeys = /* @__PURE__ */ new Set();
|
|
12
|
+
const updatedLines = lines.map((line) => {
|
|
13
|
+
const match = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
14
|
+
if (match && match[1] && match[1] in updates) {
|
|
15
|
+
const key = match[1];
|
|
16
|
+
updatedKeys.add(key);
|
|
17
|
+
return `${key}=${updates[key]}`;
|
|
29
18
|
}
|
|
19
|
+
return line;
|
|
30
20
|
});
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return [key, value];
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
const sectionHeader = "## Dexto env variables";
|
|
41
|
-
const headerIndex = envLines.findIndex((line) => line.trim() === sectionHeader);
|
|
42
|
-
let contentLines;
|
|
43
|
-
if (headerIndex !== -1) {
|
|
44
|
-
const beforeSection = envLines.slice(0, headerIndex);
|
|
45
|
-
let sectionEnd = headerIndex + 1;
|
|
46
|
-
while (sectionEnd < envLines.length && envLines[sectionEnd]?.trim() !== "") {
|
|
47
|
-
sectionEnd++;
|
|
48
|
-
}
|
|
49
|
-
if (sectionEnd < envLines.length && envLines[sectionEnd]?.trim() === "") {
|
|
50
|
-
sectionEnd++;
|
|
21
|
+
for (const [key, value] of Object.entries(updates)) {
|
|
22
|
+
if (!updatedKeys.has(key)) {
|
|
23
|
+
if (updatedLines.length > 0 && updatedLines[updatedLines.length - 1] !== "") {
|
|
24
|
+
updatedLines.push("");
|
|
25
|
+
}
|
|
26
|
+
updatedLines.push(`${key}=${value}`);
|
|
51
27
|
}
|
|
52
|
-
const afterSection = envLines.slice(sectionEnd);
|
|
53
|
-
contentLines = [...beforeSection, ...afterSection];
|
|
54
|
-
} else {
|
|
55
|
-
contentLines = envLines;
|
|
56
28
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const match = line.match(/^([A-Z0-9_]+)=(.*)$/);
|
|
60
|
-
if (match && match[1] && isDextoEnvKey(match[1])) {
|
|
61
|
-
const value = match[2] ?? "";
|
|
62
|
-
existingEnvVars[match[1]] = value;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
if (contentLines.length > 0) {
|
|
66
|
-
if (contentLines[contentLines.length - 1]?.trim() !== "") {
|
|
67
|
-
contentLines.push("");
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
contentLines.push("");
|
|
71
|
-
}
|
|
72
|
-
contentLines.push(sectionHeader);
|
|
73
|
-
for (const key of DEXTO_ENV_KEYS) {
|
|
74
|
-
if (key in existingEnvVars && !(key in updates)) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
contentLines.push(`${key}=${updatedValues[key]}`);
|
|
29
|
+
if (updatedLines[updatedLines.length - 1] !== "") {
|
|
30
|
+
updatedLines.push("");
|
|
78
31
|
}
|
|
79
|
-
|
|
80
|
-
await fs.writeFile(envFilePath, contentLines.join("\n"), "utf8");
|
|
32
|
+
await fs.writeFile(envFilePath, updatedLines.join("\n"), "utf8");
|
|
81
33
|
}
|
|
82
34
|
export {
|
|
83
35
|
updateEnvFile
|
package/dist/writer.cjs
CHANGED
|
@@ -92,19 +92,37 @@ async function writeLLMPreferences(configPath, preferences, overrides) {
|
|
|
92
92
|
const provider = overrides?.provider ?? preferences.llm.provider;
|
|
93
93
|
const model = overrides?.model ?? preferences.llm.model;
|
|
94
94
|
const apiKey = overrides?.apiKey ?? preferences.llm.apiKey;
|
|
95
|
+
const baseURL = overrides?.baseURL ?? preferences.llm.baseURL;
|
|
95
96
|
import_core.logger.debug(`Applying LLM preferences`, {
|
|
96
97
|
finalProvider: provider,
|
|
97
98
|
finalModel: model,
|
|
98
99
|
hasApiKey: Boolean(apiKey),
|
|
100
|
+
hasBaseURL: Boolean(baseURL),
|
|
99
101
|
source: overrides ? "CLI overrides + preferences" : "preferences only"
|
|
100
102
|
});
|
|
101
103
|
let llmNode = doc.get("llm");
|
|
102
104
|
if (!llmNode || typeof llmNode !== "object") {
|
|
103
|
-
|
|
105
|
+
const llmConfig = { provider, model };
|
|
106
|
+
if (apiKey) {
|
|
107
|
+
llmConfig.apiKey = apiKey;
|
|
108
|
+
}
|
|
109
|
+
if (baseURL) {
|
|
110
|
+
llmConfig.baseURL = baseURL;
|
|
111
|
+
}
|
|
112
|
+
doc.set("llm", llmConfig);
|
|
104
113
|
} else {
|
|
105
114
|
doc.setIn(["llm", "provider"], provider);
|
|
106
115
|
doc.setIn(["llm", "model"], model);
|
|
107
|
-
|
|
116
|
+
if (apiKey) {
|
|
117
|
+
doc.setIn(["llm", "apiKey"], apiKey);
|
|
118
|
+
} else {
|
|
119
|
+
doc.deleteIn(["llm", "apiKey"]);
|
|
120
|
+
}
|
|
121
|
+
if (baseURL) {
|
|
122
|
+
doc.setIn(["llm", "baseURL"], baseURL);
|
|
123
|
+
} else {
|
|
124
|
+
doc.deleteIn(["llm", "baseURL"]);
|
|
125
|
+
}
|
|
108
126
|
}
|
|
109
127
|
await import_fs.promises.writeFile(configPath, doc.toString(), "utf-8");
|
|
110
128
|
import_core.logger.info(`\u2713 Applied preferences to: ${path.basename(configPath)} (${provider}/${model})`);
|
package/dist/writer.d.ts
CHANGED
package/dist/writer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB5F;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CA6Ff;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CACzC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
package/dist/writer.js
CHANGED
|
@@ -57,19 +57,37 @@ async function writeLLMPreferences(configPath, preferences, overrides) {
|
|
|
57
57
|
const provider = overrides?.provider ?? preferences.llm.provider;
|
|
58
58
|
const model = overrides?.model ?? preferences.llm.model;
|
|
59
59
|
const apiKey = overrides?.apiKey ?? preferences.llm.apiKey;
|
|
60
|
+
const baseURL = overrides?.baseURL ?? preferences.llm.baseURL;
|
|
60
61
|
logger.debug(`Applying LLM preferences`, {
|
|
61
62
|
finalProvider: provider,
|
|
62
63
|
finalModel: model,
|
|
63
64
|
hasApiKey: Boolean(apiKey),
|
|
65
|
+
hasBaseURL: Boolean(baseURL),
|
|
64
66
|
source: overrides ? "CLI overrides + preferences" : "preferences only"
|
|
65
67
|
});
|
|
66
68
|
let llmNode = doc.get("llm");
|
|
67
69
|
if (!llmNode || typeof llmNode !== "object") {
|
|
68
|
-
|
|
70
|
+
const llmConfig = { provider, model };
|
|
71
|
+
if (apiKey) {
|
|
72
|
+
llmConfig.apiKey = apiKey;
|
|
73
|
+
}
|
|
74
|
+
if (baseURL) {
|
|
75
|
+
llmConfig.baseURL = baseURL;
|
|
76
|
+
}
|
|
77
|
+
doc.set("llm", llmConfig);
|
|
69
78
|
} else {
|
|
70
79
|
doc.setIn(["llm", "provider"], provider);
|
|
71
80
|
doc.setIn(["llm", "model"], model);
|
|
72
|
-
|
|
81
|
+
if (apiKey) {
|
|
82
|
+
doc.setIn(["llm", "apiKey"], apiKey);
|
|
83
|
+
} else {
|
|
84
|
+
doc.deleteIn(["llm", "apiKey"]);
|
|
85
|
+
}
|
|
86
|
+
if (baseURL) {
|
|
87
|
+
doc.setIn(["llm", "baseURL"], baseURL);
|
|
88
|
+
} else {
|
|
89
|
+
doc.deleteIn(["llm", "baseURL"]);
|
|
90
|
+
}
|
|
73
91
|
}
|
|
74
92
|
await fs.writeFile(configPath, doc.toString(), "utf-8");
|
|
75
93
|
logger.info(`\u2713 Applied preferences to: ${path.basename(configPath)} (${provider}/${model})`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/agent-management",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"yaml": "^2.7.1",
|
|
18
18
|
"zod": "^3.25.0",
|
|
19
|
-
"@dexto/core": "1.
|
|
19
|
+
"@dexto/core": "1.5.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^22.13.5"
|