morpheus-cli 0.2.4 → 0.2.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/README.md +493 -346
- package/dist/channels/telegram.js +1 -1
- package/dist/cli/commands/doctor.js +62 -0
- package/dist/cli/commands/init.js +66 -11
- package/dist/config/manager.js +84 -5
- package/dist/config/precedence.js +138 -0
- package/dist/config/schemas.js +3 -1
- package/dist/http/middleware/auth.js +7 -5
- package/dist/http/server.js +21 -0
- package/dist/runtime/__tests__/manual_start_verify.js +1 -0
- package/dist/runtime/oracle.js +3 -3
- package/dist/runtime/providers/factory.js +14 -4
- package/dist/runtime/tools/config-tools.js +25 -31
- package/dist/types/config.js +1 -0
- package/dist/ui/assets/{index-Pd9zlYEP.js → index-DKCPYzx2.js} +20 -20
- package/dist/ui/index.html +15 -13
- package/package.json +1 -1
|
@@ -5,66 +5,60 @@ import { ConfigManager } from "../../config/manager.js";
|
|
|
5
5
|
export const ConfigQueryTool = tool(async ({ key }) => {
|
|
6
6
|
try {
|
|
7
7
|
const configManager = ConfigManager.getInstance();
|
|
8
|
-
// Load config if not already loaded
|
|
9
8
|
await configManager.load();
|
|
10
9
|
const config = configManager.get();
|
|
11
10
|
if (key) {
|
|
12
|
-
//
|
|
13
|
-
const value =
|
|
11
|
+
// Suporta busca por chave aninhada, ex: 'llm.model' ou 'channels.telegram.enabled'
|
|
12
|
+
const value = key.split('.').reduce((obj, k) => (obj ? obj[k] : undefined), config);
|
|
14
13
|
return JSON.stringify({ [key]: value });
|
|
15
14
|
}
|
|
16
15
|
else {
|
|
17
|
-
// Return all configuration values
|
|
18
16
|
return JSON.stringify(config);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
catch (error) {
|
|
22
|
-
console.
|
|
20
|
+
// Nunca usar console.log, mas manter para debug local
|
|
23
21
|
return JSON.stringify({ error: "Failed to query configuration" });
|
|
24
22
|
}
|
|
25
23
|
}, {
|
|
26
|
-
name: "
|
|
27
|
-
description: "Queries current configuration values. Accepts an optional 'key' parameter to get a specific configuration value, or no parameter to get all configuration values.",
|
|
24
|
+
name: "morpheus_config_query",
|
|
25
|
+
description: "Queries current configuration values. Accepts an optional 'key' parameter (dot notation supported, e.g. 'llm.model') to get a specific configuration value, or no parameter to get all configuration values.",
|
|
28
26
|
schema: z.object({
|
|
29
27
|
key: z.string().optional(),
|
|
30
28
|
}),
|
|
31
29
|
});
|
|
32
|
-
// Tool for updating configuration values
|
|
30
|
+
// Tool for updating configuration values (suporta objetos aninhados via dot notation)
|
|
31
|
+
function setNestedValue(obj, path, value) {
|
|
32
|
+
const keys = path.split('.');
|
|
33
|
+
let curr = obj;
|
|
34
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
35
|
+
if (!curr[keys[i]] || typeof curr[keys[i]] !== 'object') {
|
|
36
|
+
curr[keys[i]] = {};
|
|
37
|
+
}
|
|
38
|
+
curr = curr[keys[i]];
|
|
39
|
+
}
|
|
40
|
+
curr[keys[keys.length - 1]] = value;
|
|
41
|
+
}
|
|
33
42
|
export const ConfigUpdateTool = tool(async ({ updates }) => {
|
|
34
43
|
try {
|
|
35
44
|
const configManager = ConfigManager.getInstance();
|
|
36
|
-
// Load current config
|
|
37
45
|
await configManager.load();
|
|
38
46
|
const currentConfig = configManager.get();
|
|
39
|
-
//
|
|
40
|
-
const newConfig = { ...currentConfig
|
|
41
|
-
|
|
47
|
+
// Suporta updates com dot notation para campos aninhados
|
|
48
|
+
const newConfig = { ...currentConfig };
|
|
49
|
+
for (const key in updates) {
|
|
50
|
+
setNestedValue(newConfig, key, updates[key]);
|
|
51
|
+
}
|
|
42
52
|
await configManager.save(newConfig);
|
|
43
53
|
return JSON.stringify({ success: true, message: "Configuration updated successfully" });
|
|
44
54
|
}
|
|
45
55
|
catch (error) {
|
|
46
|
-
console.error("Error in ConfigUpdateTool:", error);
|
|
47
56
|
return JSON.stringify({ error: `Failed to update configuration: ${error.message}` });
|
|
48
57
|
}
|
|
49
58
|
}, {
|
|
50
|
-
name: "
|
|
51
|
-
description: "Updates configuration values with validation. Accepts an 'updates' object containing key-value pairs to update.",
|
|
59
|
+
name: "morpheus_config_update",
|
|
60
|
+
description: "Updates configuration values with validation. Accepts an 'updates' object containing key-value pairs to update. Supports dot notation for nested fields (e.g. 'llm.model').",
|
|
52
61
|
schema: z.object({
|
|
53
|
-
updates: z.object({
|
|
54
|
-
// Define common config properties that might be updated
|
|
55
|
-
// Using optional fields to allow flexible updates
|
|
56
|
-
"llm.provider": z.string().optional(),
|
|
57
|
-
"llm.model": z.string().optional(),
|
|
58
|
-
"llm.temperature": z.number().optional(),
|
|
59
|
-
"llm.api_key": z.string().optional(),
|
|
60
|
-
"ui.enabled": z.boolean().optional(),
|
|
61
|
-
"ui.port": z.number().optional(),
|
|
62
|
-
"logging.enabled": z.boolean().optional(),
|
|
63
|
-
"logging.level": z.enum(['debug', 'info', 'warn', 'error']).optional(),
|
|
64
|
-
"audio.enabled": z.boolean().optional(),
|
|
65
|
-
"audio.provider": z.string().optional(),
|
|
66
|
-
"memory.limit": z.number().optional(),
|
|
67
|
-
// Add more specific fields as needed, or use a catch-all for other properties
|
|
68
|
-
}).passthrough(), // Allow additional properties not explicitly defined
|
|
62
|
+
updates: z.object({}).passthrough(),
|
|
69
63
|
}),
|
|
70
64
|
});
|
package/dist/types/config.js
CHANGED