@marifold/core 0.60.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/LICENSE +674 -0
- package/dist/agent/AgentEvents.d.ts +106 -0
- package/dist/agent/AgentEvents.d.ts.map +1 -0
- package/dist/agent/AgentEvents.js +3 -0
- package/dist/agent/AgentEvents.js.map +1 -0
- package/dist/agent/AgentHistory.d.ts +27 -0
- package/dist/agent/AgentHistory.d.ts.map +1 -0
- package/dist/agent/AgentHistory.js +42 -0
- package/dist/agent/AgentHistory.js.map +1 -0
- package/dist/agent/AgentRunner.d.ts +149 -0
- package/dist/agent/AgentRunner.d.ts.map +1 -0
- package/dist/agent/AgentRunner.js +727 -0
- package/dist/agent/AgentRunner.js.map +1 -0
- package/dist/agent/ApprovalPolicy.d.ts +71 -0
- package/dist/agent/ApprovalPolicy.d.ts.map +1 -0
- package/dist/agent/ApprovalPolicy.js +29 -0
- package/dist/agent/ApprovalPolicy.js.map +1 -0
- package/dist/agent/ControlBlockTools.d.ts +9 -0
- package/dist/agent/ControlBlockTools.d.ts.map +1 -0
- package/dist/agent/ControlBlockTools.js +49 -0
- package/dist/agent/ControlBlockTools.js.map +1 -0
- package/dist/agent/RunWorkspace.d.ts +92 -0
- package/dist/agent/RunWorkspace.d.ts.map +1 -0
- package/dist/agent/RunWorkspace.js +328 -0
- package/dist/agent/RunWorkspace.js.map +1 -0
- package/dist/agent/ScopedProcess.d.ts +35 -0
- package/dist/agent/ScopedProcess.d.ts.map +1 -0
- package/dist/agent/ScopedProcess.js +280 -0
- package/dist/agent/ScopedProcess.js.map +1 -0
- package/dist/agent/ToolRegistry.d.ts +80 -0
- package/dist/agent/ToolRegistry.d.ts.map +1 -0
- package/dist/agent/ToolRegistry.js +45 -0
- package/dist/agent/ToolRegistry.js.map +1 -0
- package/dist/agent/UserInput.d.ts +59 -0
- package/dist/agent/UserInput.d.ts.map +1 -0
- package/dist/agent/UserInput.js +203 -0
- package/dist/agent/UserInput.js.map +1 -0
- package/dist/agent/tools/AskUserTool.d.ts +71 -0
- package/dist/agent/tools/AskUserTool.d.ts.map +1 -0
- package/dist/agent/tools/AskUserTool.js +70 -0
- package/dist/agent/tools/AskUserTool.js.map +1 -0
- package/dist/agent/tools/DelegateTool.d.ts +49 -0
- package/dist/agent/tools/DelegateTool.d.ts.map +1 -0
- package/dist/agent/tools/DelegateTool.js +62 -0
- package/dist/agent/tools/DelegateTool.js.map +1 -0
- package/dist/agent/tools/InspectAttachmentTool.d.ts +25 -0
- package/dist/agent/tools/InspectAttachmentTool.d.ts.map +1 -0
- package/dist/agent/tools/InspectAttachmentTool.js +129 -0
- package/dist/agent/tools/InspectAttachmentTool.js.map +1 -0
- package/dist/agent/tools/PythonPackageTool.d.ts +26 -0
- package/dist/agent/tools/PythonPackageTool.d.ts.map +1 -0
- package/dist/agent/tools/PythonPackageTool.js +105 -0
- package/dist/agent/tools/PythonPackageTool.js.map +1 -0
- package/dist/agent/tools/ReadFileTool.d.ts +24 -0
- package/dist/agent/tools/ReadFileTool.d.ts.map +1 -0
- package/dist/agent/tools/ReadFileTool.js +112 -0
- package/dist/agent/tools/ReadFileTool.js.map +1 -0
- package/dist/agent/tools/ShellExecTool.d.ts +23 -0
- package/dist/agent/tools/ShellExecTool.d.ts.map +1 -0
- package/dist/agent/tools/ShellExecTool.js +75 -0
- package/dist/agent/tools/ShellExecTool.js.map +1 -0
- package/dist/agent/tools/WebSearchTool.d.ts +26 -0
- package/dist/agent/tools/WebSearchTool.d.ts.map +1 -0
- package/dist/agent/tools/WebSearchTool.js +52 -0
- package/dist/agent/tools/WebSearchTool.js.map +1 -0
- package/dist/agent/tools/WriteFileTool.d.ts +30 -0
- package/dist/agent/tools/WriteFileTool.d.ts.map +1 -0
- package/dist/agent/tools/WriteFileTool.js +155 -0
- package/dist/agent/tools/WriteFileTool.js.map +1 -0
- package/dist/app/AppActionResolver.d.ts +15 -0
- package/dist/app/AppActionResolver.d.ts.map +1 -0
- package/dist/app/AppActionResolver.js +98 -0
- package/dist/app/AppActionResolver.js.map +1 -0
- package/dist/app/AppSchema.d.ts +83 -0
- package/dist/app/AppSchema.d.ts.map +1 -0
- package/dist/app/AppSchema.js +17 -0
- package/dist/app/AppSchema.js.map +1 -0
- package/dist/app/AppStore.d.ts +14 -0
- package/dist/app/AppStore.d.ts.map +1 -0
- package/dist/app/AppStore.js +146 -0
- package/dist/app/AppStore.js.map +1 -0
- package/dist/app/AppValidator.d.ts +10 -0
- package/dist/app/AppValidator.d.ts.map +1 -0
- package/dist/app/AppValidator.js +503 -0
- package/dist/app/AppValidator.js.map +1 -0
- package/dist/app/SkillAppCompiler.d.ts +5 -0
- package/dist/app/SkillAppCompiler.d.ts.map +1 -0
- package/dist/app/SkillAppCompiler.js +632 -0
- package/dist/app/SkillAppCompiler.js.map +1 -0
- package/dist/app/SkillAppDsl.d.ts +93 -0
- package/dist/app/SkillAppDsl.d.ts.map +1 -0
- package/dist/app/SkillAppDsl.js +72 -0
- package/dist/app/SkillAppDsl.js.map +1 -0
- package/dist/app/SkillAppInstanceRegistry.d.ts +25 -0
- package/dist/app/SkillAppInstanceRegistry.d.ts.map +1 -0
- package/dist/app/SkillAppInstanceRegistry.js +218 -0
- package/dist/app/SkillAppInstanceRegistry.js.map +1 -0
- package/dist/app/SkillAppResolver.d.ts +12 -0
- package/dist/app/SkillAppResolver.d.ts.map +1 -0
- package/dist/app/SkillAppResolver.js +89 -0
- package/dist/app/SkillAppResolver.js.map +1 -0
- package/dist/app/SkillAppSchema.d.ts +116 -0
- package/dist/app/SkillAppSchema.d.ts.map +1 -0
- package/dist/app/SkillAppSchema.js +5 -0
- package/dist/app/SkillAppSchema.js.map +1 -0
- package/dist/channels/TelegramBridge.d.ts +103 -0
- package/dist/channels/TelegramBridge.d.ts.map +1 -0
- package/dist/channels/TelegramBridge.js +565 -0
- package/dist/channels/TelegramBridge.js.map +1 -0
- package/dist/channels/respond.d.ts +46 -0
- package/dist/channels/respond.d.ts.map +1 -0
- package/dist/channels/respond.js +41 -0
- package/dist/channels/respond.js.map +1 -0
- package/dist/config/ChatGptTokenRefresh.d.ts +18 -0
- package/dist/config/ChatGptTokenRefresh.d.ts.map +1 -0
- package/dist/config/ChatGptTokenRefresh.js +63 -0
- package/dist/config/ChatGptTokenRefresh.js.map +1 -0
- package/dist/config/ConfigBackup.d.ts +20 -0
- package/dist/config/ConfigBackup.d.ts.map +1 -0
- package/dist/config/ConfigBackup.js +197 -0
- package/dist/config/ConfigBackup.js.map +1 -0
- package/dist/config/ConfigLoader.d.ts +28 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +335 -0
- package/dist/config/ConfigLoader.js.map +1 -0
- package/dist/config/ConfigManager.d.ts +55 -0
- package/dist/config/ConfigManager.d.ts.map +1 -0
- package/dist/config/ConfigManager.js +707 -0
- package/dist/config/ConfigManager.js.map +1 -0
- package/dist/config/ConfigSchema.d.ts +231 -0
- package/dist/config/ConfigSchema.d.ts.map +1 -0
- package/dist/config/ConfigSchema.js +15 -0
- package/dist/config/ConfigSchema.js.map +1 -0
- package/dist/config/GitHubCopilotAuth.d.ts +7 -0
- package/dist/config/GitHubCopilotAuth.d.ts.map +1 -0
- package/dist/config/GitHubCopilotAuth.js +40 -0
- package/dist/config/GitHubCopilotAuth.js.map +1 -0
- package/dist/config/MarifoldOpenAICompatProvider.d.ts +39 -0
- package/dist/config/MarifoldOpenAICompatProvider.d.ts.map +1 -0
- package/dist/config/MarifoldOpenAICompatProvider.js +158 -0
- package/dist/config/MarifoldOpenAICompatProvider.js.map +1 -0
- package/dist/config/OpenAICompatUrls.d.ts +7 -0
- package/dist/config/OpenAICompatUrls.d.ts.map +1 -0
- package/dist/config/OpenAICompatUrls.js +47 -0
- package/dist/config/OpenAICompatUrls.js.map +1 -0
- package/dist/config/ProviderFactory.d.ts +12 -0
- package/dist/config/ProviderFactory.d.ts.map +1 -0
- package/dist/config/ProviderFactory.js +61 -0
- package/dist/config/ProviderFactory.js.map +1 -0
- package/dist/config/ProviderInspector.d.ts +46 -0
- package/dist/config/ProviderInspector.d.ts.map +1 -0
- package/dist/config/ProviderInspector.js +356 -0
- package/dist/config/ProviderInspector.js.map +1 -0
- package/dist/config/ProviderRegistry.d.ts +19 -0
- package/dist/config/ProviderRegistry.d.ts.map +1 -0
- package/dist/config/ProviderRegistry.js +301 -0
- package/dist/config/ProviderRegistry.js.map +1 -0
- package/dist/config/XaiTokenRefresh.d.ts +15 -0
- package/dist/config/XaiTokenRefresh.d.ts.map +1 -0
- package/dist/config/XaiTokenRefresh.js +73 -0
- package/dist/config/XaiTokenRefresh.js.map +1 -0
- package/dist/errors/MarifoldError.d.ts +34 -0
- package/dist/errors/MarifoldError.d.ts.map +1 -0
- package/dist/errors/MarifoldError.js +100 -0
- package/dist/errors/MarifoldError.js.map +1 -0
- package/dist/images/ImageOptimizer.d.ts +34 -0
- package/dist/images/ImageOptimizer.d.ts.map +1 -0
- package/dist/images/ImageOptimizer.js +225 -0
- package/dist/images/ImageOptimizer.js.map +1 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/MemoryControls.d.ts +26 -0
- package/dist/memory/MemoryControls.d.ts.map +1 -0
- package/dist/memory/MemoryControls.js +388 -0
- package/dist/memory/MemoryControls.js.map +1 -0
- package/dist/memory/MemoryStore.d.ts +122 -0
- package/dist/memory/MemoryStore.d.ts.map +1 -0
- package/dist/memory/MemoryStore.js +1096 -0
- package/dist/memory/MemoryStore.js.map +1 -0
- package/dist/profiles/ProfileManager.d.ts +139 -0
- package/dist/profiles/ProfileManager.d.ts.map +1 -0
- package/dist/profiles/ProfileManager.js +475 -0
- package/dist/profiles/ProfileManager.js.map +1 -0
- package/dist/profiles/ProfileResolver.d.ts +18 -0
- package/dist/profiles/ProfileResolver.d.ts.map +1 -0
- package/dist/profiles/ProfileResolver.js +280 -0
- package/dist/profiles/ProfileResolver.js.map +1 -0
- package/dist/runs/RunRegistry.d.ts +140 -0
- package/dist/runs/RunRegistry.d.ts.map +1 -0
- package/dist/runs/RunRegistry.js +432 -0
- package/dist/runs/RunRegistry.js.map +1 -0
- package/dist/runtime/MarifoldRuntime.d.ts +244 -0
- package/dist/runtime/MarifoldRuntime.d.ts.map +1 -0
- package/dist/runtime/MarifoldRuntime.js +1099 -0
- package/dist/runtime/MarifoldRuntime.js.map +1 -0
- package/dist/runtime/MarifoldTypes.d.ts +70 -0
- package/dist/runtime/MarifoldTypes.d.ts.map +1 -0
- package/dist/runtime/MarifoldTypes.js +3 -0
- package/dist/runtime/MarifoldTypes.js.map +1 -0
- package/dist/schedule/ScheduleStore.d.ts +60 -0
- package/dist/schedule/ScheduleStore.d.ts.map +1 -0
- package/dist/schedule/ScheduleStore.js +212 -0
- package/dist/schedule/ScheduleStore.js.map +1 -0
- package/dist/schedule/Scheduler.d.ts +28 -0
- package/dist/schedule/Scheduler.d.ts.map +1 -0
- package/dist/schedule/Scheduler.js +65 -0
- package/dist/schedule/Scheduler.js.map +1 -0
- package/dist/search/DuckDuckGoBackend.d.ts +18 -0
- package/dist/search/DuckDuckGoBackend.d.ts.map +1 -0
- package/dist/search/DuckDuckGoBackend.js +37 -0
- package/dist/search/DuckDuckGoBackend.js.map +1 -0
- package/dist/search/FirecrawlBackend.d.ts +28 -0
- package/dist/search/FirecrawlBackend.d.ts.map +1 -0
- package/dist/search/FirecrawlBackend.js +76 -0
- package/dist/search/FirecrawlBackend.js.map +1 -0
- package/dist/search/SearchBackend.d.ts +18 -0
- package/dist/search/SearchBackend.d.ts.map +1 -0
- package/dist/search/SearchBackend.js +24 -0
- package/dist/search/SearchBackend.js.map +1 -0
- package/dist/search/createSearchBackend.d.ts +16 -0
- package/dist/search/createSearchBackend.d.ts.map +1 -0
- package/dist/search/createSearchBackend.js +30 -0
- package/dist/search/createSearchBackend.js.map +1 -0
- package/dist/sessions/ResponseMetrics.d.ts +17 -0
- package/dist/sessions/ResponseMetrics.d.ts.map +1 -0
- package/dist/sessions/ResponseMetrics.js +3 -0
- package/dist/sessions/ResponseMetrics.js.map +1 -0
- package/dist/sessions/SessionResolver.d.ts +135 -0
- package/dist/sessions/SessionResolver.d.ts.map +1 -0
- package/dist/sessions/SessionResolver.js +1173 -0
- package/dist/sessions/SessionResolver.js.map +1 -0
- package/dist/skill/BuiltInSkillManager.d.ts +11 -0
- package/dist/skill/BuiltInSkillManager.d.ts.map +1 -0
- package/dist/skill/BuiltInSkillManager.js +98 -0
- package/dist/skill/BuiltInSkillManager.js.map +1 -0
- package/dist/skill/SkillInvocation.d.ts +30 -0
- package/dist/skill/SkillInvocation.d.ts.map +1 -0
- package/dist/skill/SkillInvocation.js +135 -0
- package/dist/skill/SkillInvocation.js.map +1 -0
- package/dist/skill/SkillSchema.d.ts +37 -0
- package/dist/skill/SkillSchema.d.ts.map +1 -0
- package/dist/skill/SkillSchema.js +26 -0
- package/dist/skill/SkillSchema.js.map +1 -0
- package/dist/skill/SkillStore.d.ts +41 -0
- package/dist/skill/SkillStore.d.ts.map +1 -0
- package/dist/skill/SkillStore.js +184 -0
- package/dist/skill/SkillStore.js.map +1 -0
- package/dist/skill/SkillTemplater.d.ts +19 -0
- package/dist/skill/SkillTemplater.d.ts.map +1 -0
- package/dist/skill/SkillTemplater.js +36 -0
- package/dist/skill/SkillTemplater.js.map +1 -0
- package/dist/skill/SkillValidator.d.ts +10 -0
- package/dist/skill/SkillValidator.d.ts.map +1 -0
- package/dist/skill/SkillValidator.js +131 -0
- package/dist/skill/SkillValidator.js.map +1 -0
- package/dist/skill/SkillVars.d.ts +10 -0
- package/dist/skill/SkillVars.d.ts.map +1 -0
- package/dist/skill/SkillVars.js +65 -0
- package/dist/skill/SkillVars.js.map +1 -0
- package/dist/skill/index.d.ts +10 -0
- package/dist/skill/index.d.ts.map +1 -0
- package/dist/skill/index.js +22 -0
- package/dist/skill/index.js.map +1 -0
- package/dist/skillapp/SkillAppActionResolver.d.ts +13 -0
- package/dist/skillapp/SkillAppActionResolver.d.ts.map +1 -0
- package/dist/skillapp/SkillAppActionResolver.js +95 -0
- package/dist/skillapp/SkillAppActionResolver.js.map +1 -0
- package/dist/skillapp/SkillAppSchema.d.ts +79 -0
- package/dist/skillapp/SkillAppSchema.d.ts.map +1 -0
- package/dist/skillapp/SkillAppSchema.js +20 -0
- package/dist/skillapp/SkillAppSchema.js.map +1 -0
- package/dist/skillapp/SkillAppStore.d.ts +11 -0
- package/dist/skillapp/SkillAppStore.d.ts.map +1 -0
- package/dist/skillapp/SkillAppStore.js +98 -0
- package/dist/skillapp/SkillAppStore.js.map +1 -0
- package/dist/skillapp/SkillAppValidator.d.ts +10 -0
- package/dist/skillapp/SkillAppValidator.d.ts.map +1 -0
- package/dist/skillapp/SkillAppValidator.js +522 -0
- package/dist/skillapp/SkillAppValidator.js.map +1 -0
- package/dist/tasks/TaskStore.d.ts +110 -0
- package/dist/tasks/TaskStore.d.ts.map +1 -0
- package/dist/tasks/TaskStore.js +371 -0
- package/dist/tasks/TaskStore.js.map +1 -0
- package/dist/util/fetchRetry.d.ts +11 -0
- package/dist/util/fetchRetry.d.ts.map +1 -0
- package/dist/util/fetchRetry.js +48 -0
- package/dist/util/fetchRetry.js.map +1 -0
- package/dist/util/idToken.d.ts +12 -0
- package/dist/util/idToken.d.ts.map +1 -0
- package/dist/util/idToken.js +32 -0
- package/dist/util/idToken.js.map +1 -0
- package/dist/util/proxy.d.ts +18 -0
- package/dist/util/proxy.d.ts.map +1 -0
- package/dist/util/proxy.js +28 -0
- package/dist/util/proxy.js.map +1 -0
- package/dist/workspace/Workspace.d.ts +9 -0
- package/dist/workspace/Workspace.d.ts.map +1 -0
- package/dist/workspace/Workspace.js +55 -0
- package/dist/workspace/Workspace.js.map +1 -0
- package/dist/workspace/WorkspaceInitializer.d.ts +40 -0
- package/dist/workspace/WorkspaceInitializer.d.ts.map +1 -0
- package/dist/workspace/WorkspaceInitializer.js +212 -0
- package/dist/workspace/WorkspaceInitializer.js.map +1 -0
- package/dist/workspace/WorkspacePaths.d.ts +11 -0
- package/dist/workspace/WorkspacePaths.d.ts.map +1 -0
- package/dist/workspace/WorkspacePaths.js +82 -0
- package/dist/workspace/WorkspacePaths.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConfigManager = void 0;
|
|
37
|
+
exports.renderMarifoldConfig = renderMarifoldConfig;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const ConfigSchema_1 = require("./ConfigSchema");
|
|
41
|
+
const MarifoldError_1 = require("../errors/MarifoldError");
|
|
42
|
+
const ApprovalPolicy_1 = require("../agent/ApprovalPolicy");
|
|
43
|
+
const WorkspacePaths_1 = require("../workspace/WorkspacePaths");
|
|
44
|
+
const ProviderRegistry_1 = require("./ProviderRegistry");
|
|
45
|
+
class ConfigManager {
|
|
46
|
+
loadedConfig;
|
|
47
|
+
constructor(loadedConfig) {
|
|
48
|
+
this.loadedConfig = loadedConfig;
|
|
49
|
+
}
|
|
50
|
+
get config() {
|
|
51
|
+
return this.loadedConfig.config;
|
|
52
|
+
}
|
|
53
|
+
get configPath() {
|
|
54
|
+
return this.loadedConfig.configPath;
|
|
55
|
+
}
|
|
56
|
+
save() {
|
|
57
|
+
fs.mkdirSync(path.dirname(this.configPath), { recursive: true });
|
|
58
|
+
fs.writeFileSync(this.configPath, renderMarifoldConfig(this.config));
|
|
59
|
+
return this.configPath;
|
|
60
|
+
}
|
|
61
|
+
setValue(key, value) {
|
|
62
|
+
const parts = key.split('.');
|
|
63
|
+
if (parts.length < 2)
|
|
64
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: ${key}`);
|
|
65
|
+
if (parts[0] === 'default' && parts.length === 2) {
|
|
66
|
+
this.setDefaultValue(parts[1], value);
|
|
67
|
+
}
|
|
68
|
+
else if (parts[0] === 'paths' && parts.length === 2) {
|
|
69
|
+
this.setPathValue(parts[1], value);
|
|
70
|
+
}
|
|
71
|
+
else if (parts[0] === 'memory' && parts.length === 2) {
|
|
72
|
+
this.setMemoryValue(parts[1], value);
|
|
73
|
+
}
|
|
74
|
+
else if (parts[0] === 'service' && parts.length === 2) {
|
|
75
|
+
this.setServiceValue(parts[1], value);
|
|
76
|
+
}
|
|
77
|
+
else if (parts[0] === 'agent' && parts.length === 2) {
|
|
78
|
+
this.setAgentValue(parts[1], value);
|
|
79
|
+
}
|
|
80
|
+
else if (parts[0] === 'agent' && parts[1] === 'approval' && parts.length === 3) {
|
|
81
|
+
this.setAgentApprovalValue(parts[2], value);
|
|
82
|
+
}
|
|
83
|
+
else if (parts[0] === 'web_search' && parts.length === 2) {
|
|
84
|
+
this.setWebSearchValue(parts[1], value);
|
|
85
|
+
}
|
|
86
|
+
else if (parts[0] === 'providers' && parts.length === 3) {
|
|
87
|
+
this.setProviderValue(parts[1], parts[2], value);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: ${key}`);
|
|
91
|
+
}
|
|
92
|
+
this.save();
|
|
93
|
+
return { configPath: this.configPath, key, value };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Read a config value by the same dotted keys `setValue` accepts.
|
|
97
|
+
* Returns undefined for known-but-unset keys; throws on unknown keys.
|
|
98
|
+
* Arrays render comma-separated. Secrets return as stored — this is the
|
|
99
|
+
* CLI's `config get`; the HTTP view stays sanitized.
|
|
100
|
+
*/
|
|
101
|
+
getValue(key) {
|
|
102
|
+
const parts = key.split('.');
|
|
103
|
+
if (parts.length < 2)
|
|
104
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: ${key}`);
|
|
105
|
+
const raw = this.readValue(parts, key);
|
|
106
|
+
if (raw === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
return Array.isArray(raw) ? raw.join(', ') : String(raw);
|
|
109
|
+
}
|
|
110
|
+
readValue(parts, key) {
|
|
111
|
+
const pick = (section, map, field) => {
|
|
112
|
+
if (!(field in map))
|
|
113
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: ${section}.${field}`);
|
|
114
|
+
return map[field];
|
|
115
|
+
};
|
|
116
|
+
if (parts[0] === 'default' && parts.length === 2) {
|
|
117
|
+
const d = this.config.default;
|
|
118
|
+
return pick('default', {
|
|
119
|
+
provider: d.provider,
|
|
120
|
+
model: d.model,
|
|
121
|
+
profile: d.profile,
|
|
122
|
+
timeout_seconds: d.timeoutSeconds,
|
|
123
|
+
max_output_tokens: d.maxOutputTokens,
|
|
124
|
+
max_system_chars: d.maxSystemChars,
|
|
125
|
+
max_context_tokens: d.maxContextTokens,
|
|
126
|
+
compaction_keep_turns: d.compactionKeepTurns,
|
|
127
|
+
session_context_turns: d.sessionContextTurns,
|
|
128
|
+
think: d.think,
|
|
129
|
+
}, parts[1]);
|
|
130
|
+
}
|
|
131
|
+
if (parts[0] === 'paths' && parts.length === 2) {
|
|
132
|
+
const p = this.config.paths;
|
|
133
|
+
return pick('paths', {
|
|
134
|
+
profiles_dir: p.profilesDir,
|
|
135
|
+
sessions_db: p.sessionsDb,
|
|
136
|
+
tasks_dir: p.tasksDir,
|
|
137
|
+
schedules_dir: p.schedulesDir,
|
|
138
|
+
skills_dir: p.skillsDir,
|
|
139
|
+
apps_dir: p.appsDir,
|
|
140
|
+
}, parts[1]);
|
|
141
|
+
}
|
|
142
|
+
if (parts[0] === 'memory' && parts.length === 2) {
|
|
143
|
+
const m = this.config.memory;
|
|
144
|
+
return pick('memory', { size_limit: m.sizeLimit, context_limit: m.contextLimit }, parts[1]);
|
|
145
|
+
}
|
|
146
|
+
if (parts[0] === 'service' && parts.length === 2) {
|
|
147
|
+
const svc = this.config.service;
|
|
148
|
+
return pick('service', {
|
|
149
|
+
token_env: svc?.tokenEnv,
|
|
150
|
+
token: svc?.token,
|
|
151
|
+
cors_origins: svc?.corsOrigins,
|
|
152
|
+
web_dir: svc?.webDir,
|
|
153
|
+
}, parts[1]);
|
|
154
|
+
}
|
|
155
|
+
if (parts[0] === 'agent' && parts.length === 2) {
|
|
156
|
+
const agent = (0, ApprovalPolicy_1.resolveAgentConfig)(this.config.agent);
|
|
157
|
+
return pick('agent', {
|
|
158
|
+
max_iterations: agent.maxIterations,
|
|
159
|
+
tool_output_limit: agent.toolOutputLimit,
|
|
160
|
+
tool_mode: agent.toolMode,
|
|
161
|
+
trusted_folders: agent.trustedFolders,
|
|
162
|
+
}, parts[1]);
|
|
163
|
+
}
|
|
164
|
+
if (parts[0] === 'agent' && parts[1] === 'approval' && parts.length === 3) {
|
|
165
|
+
const approval = (0, ApprovalPolicy_1.resolveAgentConfig)(this.config.agent).approval;
|
|
166
|
+
return pick('agent.approval', {
|
|
167
|
+
read: approval.read,
|
|
168
|
+
write: approval.write,
|
|
169
|
+
shell: approval.shell,
|
|
170
|
+
network: approval.network,
|
|
171
|
+
delegate: approval.delegate,
|
|
172
|
+
}, parts[2]);
|
|
173
|
+
}
|
|
174
|
+
if (parts[0] === 'web_search' && parts.length === 2) {
|
|
175
|
+
const search = (0, ConfigSchema_1.resolveWebSearchConfig)(this.config.webSearch);
|
|
176
|
+
return pick('web_search', {
|
|
177
|
+
enabled: search.enabled,
|
|
178
|
+
max_results: search.maxResults,
|
|
179
|
+
provider: search.provider,
|
|
180
|
+
api_key_env: search.apiKeyEnv,
|
|
181
|
+
api_key: search.apiKey,
|
|
182
|
+
scrape: search.scrape,
|
|
183
|
+
proxy: search.proxy,
|
|
184
|
+
}, parts[1]);
|
|
185
|
+
}
|
|
186
|
+
if (parts[0] === 'providers' && parts.length === 3) {
|
|
187
|
+
const provider = this.config.providers[parts[1]];
|
|
188
|
+
return pick(`providers.${parts[1]}`, {
|
|
189
|
+
type: provider?.type,
|
|
190
|
+
base_url: provider?.baseUrl,
|
|
191
|
+
api_key_env: provider?.apiKeyEnv,
|
|
192
|
+
api_key: provider?.apiKey,
|
|
193
|
+
oauth_token: provider?.oauthToken,
|
|
194
|
+
api_key_expires_at: provider?.apiKeyExpiresAt,
|
|
195
|
+
account_id: provider?.accountId,
|
|
196
|
+
proxy: provider?.proxy,
|
|
197
|
+
}, parts[2]);
|
|
198
|
+
}
|
|
199
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: ${key}`);
|
|
200
|
+
}
|
|
201
|
+
setDefaultModel(model, provider) {
|
|
202
|
+
if (!model)
|
|
203
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Model cannot be empty.');
|
|
204
|
+
if (provider)
|
|
205
|
+
this.config.default.provider = provider;
|
|
206
|
+
this.config.default.model = model;
|
|
207
|
+
this.registerModelOption(this.config.default.provider, model);
|
|
208
|
+
this.save();
|
|
209
|
+
return {
|
|
210
|
+
configPath: this.configPath,
|
|
211
|
+
key: provider ? 'default.provider/default.model' : 'default.model',
|
|
212
|
+
value: provider ? `${provider}/${model}` : model,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
addModel(provider, model, options = {}) {
|
|
216
|
+
if (!provider)
|
|
217
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Provider cannot be empty.');
|
|
218
|
+
if (!model)
|
|
219
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Model cannot be empty.');
|
|
220
|
+
const providerConfig = this.config.providers[provider] ?? this.createProvider(provider);
|
|
221
|
+
const registry = (0, ProviderRegistry_1.getProviderRegistryEntry)(provider);
|
|
222
|
+
if (registry) {
|
|
223
|
+
const defaults = (0, ProviderRegistry_1.providerConfigFromRegistry)(registry);
|
|
224
|
+
if (defaults.type)
|
|
225
|
+
providerConfig.type = defaults.type;
|
|
226
|
+
if (defaults.baseUrl && !providerConfig.baseUrl)
|
|
227
|
+
providerConfig.baseUrl = defaults.baseUrl;
|
|
228
|
+
if (defaults.apiKeyEnv && !providerConfig.apiKeyEnv)
|
|
229
|
+
providerConfig.apiKeyEnv = defaults.apiKeyEnv;
|
|
230
|
+
}
|
|
231
|
+
if (options.type)
|
|
232
|
+
providerConfig.type = options.type;
|
|
233
|
+
if (options.baseUrl)
|
|
234
|
+
providerConfig.baseUrl = options.baseUrl.replace(/\/+$/, '');
|
|
235
|
+
if (options.apiKeyEnv)
|
|
236
|
+
providerConfig.apiKeyEnv = options.apiKeyEnv;
|
|
237
|
+
if (options.apiKey)
|
|
238
|
+
providerConfig.apiKey = options.apiKey;
|
|
239
|
+
if (options.oauthToken)
|
|
240
|
+
providerConfig.oauthToken = options.oauthToken;
|
|
241
|
+
if (options.apiKeyExpiresAt !== undefined)
|
|
242
|
+
providerConfig.apiKeyExpiresAt = options.apiKeyExpiresAt;
|
|
243
|
+
if (options.accountId)
|
|
244
|
+
providerConfig.accountId = options.accountId;
|
|
245
|
+
this.registerModelOption(provider, model);
|
|
246
|
+
this.save();
|
|
247
|
+
return { configPath: this.configPath, key: 'models.options', value: `${provider}/${model}` };
|
|
248
|
+
}
|
|
249
|
+
/** Merge changes into the [web_search] section (undefined keys are left as-is)
|
|
250
|
+
* and persist. Used by `marifold config search`. */
|
|
251
|
+
updateWebSearch(partial) {
|
|
252
|
+
const defined = Object.fromEntries(Object.entries(partial).filter(([, value]) => value !== undefined));
|
|
253
|
+
this.config.webSearch = { ...(0, ConfigSchema_1.resolveWebSearchConfig)(this.config.webSearch), ...defined };
|
|
254
|
+
this.save();
|
|
255
|
+
return { configPath: this.configPath, key: 'web_search.provider', value: this.config.webSearch.provider };
|
|
256
|
+
}
|
|
257
|
+
removeModel(provider, model) {
|
|
258
|
+
if (!provider)
|
|
259
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Provider cannot be empty.');
|
|
260
|
+
if (!model)
|
|
261
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Model cannot be empty.');
|
|
262
|
+
const option = `${provider}/${model}`;
|
|
263
|
+
const index = this.config.models.options.indexOf(option);
|
|
264
|
+
const wasDefault = this.config.default.provider === provider && this.config.default.model === model;
|
|
265
|
+
if (index === -1) {
|
|
266
|
+
return {
|
|
267
|
+
configPath: this.configPath,
|
|
268
|
+
key: 'models.options',
|
|
269
|
+
value: option,
|
|
270
|
+
removed: false,
|
|
271
|
+
wasDefault,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
this.config.models.options.splice(index, 1);
|
|
275
|
+
this.save();
|
|
276
|
+
return {
|
|
277
|
+
configPath: this.configPath,
|
|
278
|
+
key: 'models.options',
|
|
279
|
+
value: option,
|
|
280
|
+
removed: true,
|
|
281
|
+
wasDefault,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/** Remove one provider's local configuration, credentials, and saved model
|
|
285
|
+
* options. Refuse the global default so the config cannot be left unusable. */
|
|
286
|
+
removeProvider(provider) {
|
|
287
|
+
if (!provider)
|
|
288
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Provider cannot be empty.');
|
|
289
|
+
if (this.config.default.provider === provider) {
|
|
290
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Cannot remove the current default provider '${provider}'. Choose another default model first.`);
|
|
291
|
+
}
|
|
292
|
+
const key = `providers.${provider}`;
|
|
293
|
+
if (!this.config.providers[provider]) {
|
|
294
|
+
return {
|
|
295
|
+
configPath: this.configPath,
|
|
296
|
+
key,
|
|
297
|
+
value: provider,
|
|
298
|
+
removed: false,
|
|
299
|
+
removedModels: [],
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
const prefix = `${provider}/`;
|
|
303
|
+
const removedModels = this.config.models.options.filter(option => option.startsWith(prefix));
|
|
304
|
+
this.config.models.options = this.config.models.options.filter(option => !option.startsWith(prefix));
|
|
305
|
+
delete this.config.providers[provider];
|
|
306
|
+
this.save();
|
|
307
|
+
return {
|
|
308
|
+
configPath: this.configPath,
|
|
309
|
+
key,
|
|
310
|
+
value: provider,
|
|
311
|
+
removed: true,
|
|
312
|
+
removedModels,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
registerModelOption(provider, model) {
|
|
316
|
+
if (!provider || !model)
|
|
317
|
+
return;
|
|
318
|
+
const option = `${provider}/${model}`;
|
|
319
|
+
if (!this.config.models.options.includes(option)) {
|
|
320
|
+
this.config.models.options.push(option);
|
|
321
|
+
this.config.models.options.sort();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
setDefaultProfile(profile) {
|
|
325
|
+
if (!profile)
|
|
326
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Profile cannot be empty.');
|
|
327
|
+
this.config.default.profile = profile;
|
|
328
|
+
this.save();
|
|
329
|
+
return { configPath: this.configPath, key: 'default.profile', value: profile };
|
|
330
|
+
}
|
|
331
|
+
setDefaultValue(key, value) {
|
|
332
|
+
switch (key) {
|
|
333
|
+
case 'provider':
|
|
334
|
+
this.config.default.provider = value;
|
|
335
|
+
return;
|
|
336
|
+
case 'model':
|
|
337
|
+
this.config.default.model = value;
|
|
338
|
+
return;
|
|
339
|
+
case 'profile':
|
|
340
|
+
this.config.default.profile = value;
|
|
341
|
+
return;
|
|
342
|
+
case 'timeout_seconds':
|
|
343
|
+
this.config.default.timeoutSeconds = parseNumber(value, 'default.timeout_seconds');
|
|
344
|
+
return;
|
|
345
|
+
case 'max_output_tokens':
|
|
346
|
+
this.config.default.maxOutputTokens = parseNumber(value, 'default.max_output_tokens');
|
|
347
|
+
return;
|
|
348
|
+
case 'max_system_chars':
|
|
349
|
+
this.config.default.maxSystemChars = parseNumber(value, 'default.max_system_chars');
|
|
350
|
+
return;
|
|
351
|
+
case 'max_context_tokens':
|
|
352
|
+
this.config.default.maxContextTokens = parseNumber(value, 'default.max_context_tokens');
|
|
353
|
+
return;
|
|
354
|
+
case 'compaction_keep_turns':
|
|
355
|
+
this.config.default.compactionKeepTurns = parseNumber(value, 'default.compaction_keep_turns');
|
|
356
|
+
return;
|
|
357
|
+
case 'session_context_turns': {
|
|
358
|
+
const trimmed = value.trim().toLowerCase();
|
|
359
|
+
if (trimmed === 'all' || trimmed === '') {
|
|
360
|
+
this.config.default.sessionContextTurns = undefined;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
const turns = parseNumber(value, 'default.session_context_turns');
|
|
364
|
+
if (!Number.isInteger(turns) || turns < 0) {
|
|
365
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Expected default.session_context_turns to be a non-negative integer or "all".');
|
|
366
|
+
}
|
|
367
|
+
this.config.default.sessionContextTurns = turns;
|
|
368
|
+
}
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
case 'think':
|
|
372
|
+
this.config.default.think = parseBoolean(value, 'default.think');
|
|
373
|
+
return;
|
|
374
|
+
default:
|
|
375
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: default.${key}`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
setPathValue(key, value) {
|
|
379
|
+
switch (key) {
|
|
380
|
+
case 'profiles_dir':
|
|
381
|
+
this.config.paths.profilesDir = (0, WorkspacePaths_1.resolveUserPath)(value);
|
|
382
|
+
return;
|
|
383
|
+
case 'sessions_db':
|
|
384
|
+
this.config.paths.sessionsDb = (0, WorkspacePaths_1.resolveUserPath)(value);
|
|
385
|
+
return;
|
|
386
|
+
case 'tasks_dir':
|
|
387
|
+
this.config.paths.tasksDir = (0, WorkspacePaths_1.resolveUserPath)(value);
|
|
388
|
+
return;
|
|
389
|
+
case 'schedules_dir':
|
|
390
|
+
this.config.paths.schedulesDir = (0, WorkspacePaths_1.resolveUserPath)(value);
|
|
391
|
+
return;
|
|
392
|
+
case 'skills_dir':
|
|
393
|
+
this.config.paths.skillsDir = (0, WorkspacePaths_1.resolveUserPath)(value);
|
|
394
|
+
return;
|
|
395
|
+
case 'apps_dir':
|
|
396
|
+
this.config.paths.appsDir = (0, WorkspacePaths_1.resolveUserPath)(value);
|
|
397
|
+
return;
|
|
398
|
+
default:
|
|
399
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: paths.${key}`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
setMemoryValue(key, value) {
|
|
403
|
+
switch (key) {
|
|
404
|
+
case 'size_limit':
|
|
405
|
+
this.config.memory.sizeLimit = parseNonNegativeNumber(value, 'memory.size_limit');
|
|
406
|
+
return;
|
|
407
|
+
case 'context_limit':
|
|
408
|
+
this.config.memory.contextLimit = parseNonNegativeNumber(value, 'memory.context_limit');
|
|
409
|
+
return;
|
|
410
|
+
default:
|
|
411
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: memory.${key}`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/** Write a [service] key, creating the section on first write. Empty string
|
|
415
|
+
* clears optional keys (token_env/token/web_dir) and empties cors_origins —
|
|
416
|
+
* so `config set service.token ""` revokes rather than storing "". */
|
|
417
|
+
setServiceValue(key, value) {
|
|
418
|
+
const service = this.config.service ?? (this.config.service = { corsOrigins: [] });
|
|
419
|
+
const cleared = value.trim() === '' ? undefined : value.trim();
|
|
420
|
+
switch (key) {
|
|
421
|
+
case 'token_env':
|
|
422
|
+
service.tokenEnv = cleared;
|
|
423
|
+
return;
|
|
424
|
+
case 'token':
|
|
425
|
+
service.token = cleared;
|
|
426
|
+
return;
|
|
427
|
+
case 'web_dir':
|
|
428
|
+
service.webDir = cleared === undefined ? undefined : (0, WorkspacePaths_1.resolveUserPath)(cleared);
|
|
429
|
+
return;
|
|
430
|
+
case 'cors_origins':
|
|
431
|
+
service.corsOrigins = value.split(',').map(origin => origin.trim()).filter(Boolean);
|
|
432
|
+
return;
|
|
433
|
+
default:
|
|
434
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: service.${key}`);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
setAgentValue(key, value) {
|
|
438
|
+
const agent = this.config.agent ?? (this.config.agent = (0, ApprovalPolicy_1.resolveAgentConfig)());
|
|
439
|
+
switch (key) {
|
|
440
|
+
case 'max_iterations':
|
|
441
|
+
agent.maxIterations = parsePositiveInteger(value, 'agent.max_iterations');
|
|
442
|
+
return;
|
|
443
|
+
case 'tool_output_limit':
|
|
444
|
+
agent.toolOutputLimit = parsePositiveInteger(value, 'agent.tool_output_limit');
|
|
445
|
+
return;
|
|
446
|
+
case 'tool_mode':
|
|
447
|
+
agent.toolMode = parseAgentToolMode(value);
|
|
448
|
+
return;
|
|
449
|
+
case 'trusted_folders':
|
|
450
|
+
agent.trustedFolders = value.split(',').map(folder => folder.trim()).filter(Boolean).map(WorkspacePaths_1.resolveUserPath);
|
|
451
|
+
return;
|
|
452
|
+
default:
|
|
453
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: agent.${key}`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
setAgentApprovalValue(key, value) {
|
|
457
|
+
const kind = parseToolKind(key);
|
|
458
|
+
const agent = this.config.agent ?? (this.config.agent = (0, ApprovalPolicy_1.resolveAgentConfig)());
|
|
459
|
+
agent.approval[kind] = parseApprovalMode(value);
|
|
460
|
+
}
|
|
461
|
+
setWebSearchValue(key, value) {
|
|
462
|
+
const search = this.config.webSearch ?? (this.config.webSearch = (0, ConfigSchema_1.resolveWebSearchConfig)());
|
|
463
|
+
const cleared = value.trim() === '' ? undefined : value.trim();
|
|
464
|
+
switch (key) {
|
|
465
|
+
case 'enabled':
|
|
466
|
+
search.enabled = parseBoolean(value, 'web_search.enabled');
|
|
467
|
+
return;
|
|
468
|
+
case 'max_results':
|
|
469
|
+
search.maxResults = parsePositiveInteger(value, 'web_search.max_results');
|
|
470
|
+
return;
|
|
471
|
+
case 'provider':
|
|
472
|
+
if (value !== 'duckduckgo' && value !== 'firecrawl') {
|
|
473
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Expected web_search.provider to be duckduckgo or firecrawl.');
|
|
474
|
+
}
|
|
475
|
+
search.provider = value;
|
|
476
|
+
return;
|
|
477
|
+
case 'api_key_env':
|
|
478
|
+
search.apiKeyEnv = cleared;
|
|
479
|
+
return;
|
|
480
|
+
case 'api_key':
|
|
481
|
+
search.apiKey = cleared;
|
|
482
|
+
return;
|
|
483
|
+
case 'scrape':
|
|
484
|
+
search.scrape = parseBoolean(value, 'web_search.scrape');
|
|
485
|
+
return;
|
|
486
|
+
case 'proxy':
|
|
487
|
+
search.proxy = cleared;
|
|
488
|
+
return;
|
|
489
|
+
default:
|
|
490
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: web_search.${key}`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
setProviderValue(providerName, key, value) {
|
|
494
|
+
const provider = this.config.providers[providerName] ?? this.createProvider(providerName);
|
|
495
|
+
switch (key) {
|
|
496
|
+
case 'type':
|
|
497
|
+
provider.type = parseProviderType(value);
|
|
498
|
+
return;
|
|
499
|
+
case 'base_url':
|
|
500
|
+
provider.baseUrl = value.replace(/\/+$/, '');
|
|
501
|
+
return;
|
|
502
|
+
case 'api_key_env':
|
|
503
|
+
provider.apiKeyEnv = value;
|
|
504
|
+
return;
|
|
505
|
+
case 'api_key':
|
|
506
|
+
provider.apiKey = value;
|
|
507
|
+
return;
|
|
508
|
+
case 'oauth_token':
|
|
509
|
+
provider.oauthToken = value;
|
|
510
|
+
return;
|
|
511
|
+
case 'api_key_expires_at':
|
|
512
|
+
provider.apiKeyExpiresAt = parseNumber(value, `providers.${providerName}.api_key_expires_at`);
|
|
513
|
+
return;
|
|
514
|
+
case 'account_id':
|
|
515
|
+
provider.accountId = value;
|
|
516
|
+
return;
|
|
517
|
+
case 'proxy':
|
|
518
|
+
if (value.trim())
|
|
519
|
+
provider.proxy = value.trim();
|
|
520
|
+
else
|
|
521
|
+
delete provider.proxy;
|
|
522
|
+
return;
|
|
523
|
+
default:
|
|
524
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown config key: providers.${providerName}.${key}`);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
createProvider(providerName) {
|
|
528
|
+
const registry = (0, ProviderRegistry_1.getProviderRegistryEntry)(providerName);
|
|
529
|
+
const provider = registry
|
|
530
|
+
? { type: registry.type, ...(0, ProviderRegistry_1.providerConfigFromRegistry)(registry) }
|
|
531
|
+
: { type: providerName === 'ollama' ? 'ollama' : 'openai-compatible' };
|
|
532
|
+
this.config.providers[providerName] = provider;
|
|
533
|
+
return provider;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
exports.ConfigManager = ConfigManager;
|
|
537
|
+
function renderMarifoldConfig(config) {
|
|
538
|
+
const defaultLines = [
|
|
539
|
+
'[default]',
|
|
540
|
+
optionalStringLine('provider', config.default.provider),
|
|
541
|
+
optionalStringLine('model', config.default.model),
|
|
542
|
+
`profile = ${tomlString(config.default.profile)}`,
|
|
543
|
+
optionalNumberLine('timeout_seconds', config.default.timeoutSeconds),
|
|
544
|
+
optionalNumberLine('max_output_tokens', config.default.maxOutputTokens),
|
|
545
|
+
optionalNumberLine('max_system_chars', config.default.maxSystemChars),
|
|
546
|
+
optionalNumberLine('max_context_tokens', config.default.maxContextTokens),
|
|
547
|
+
optionalNumberLine('compaction_keep_turns', config.default.compactionKeepTurns),
|
|
548
|
+
optionalNumberLine('session_context_turns', config.default.sessionContextTurns),
|
|
549
|
+
`think = ${config.default.think}`,
|
|
550
|
+
].filter(Boolean);
|
|
551
|
+
const pathLines = [
|
|
552
|
+
'[paths]',
|
|
553
|
+
`profiles_dir = ${tomlString(config.paths.profilesDir)}`,
|
|
554
|
+
`sessions_db = ${tomlString(config.paths.sessionsDb)}`,
|
|
555
|
+
`tasks_dir = ${tomlString(config.paths.tasksDir)}`,
|
|
556
|
+
...(config.paths.schedulesDir ? [`schedules_dir = ${tomlString(config.paths.schedulesDir)}`] : []),
|
|
557
|
+
...(config.paths.skillsDir ? [`skills_dir = ${tomlString(config.paths.skillsDir)}`] : []),
|
|
558
|
+
...(config.paths.appsDir ? [`apps_dir = ${tomlString(config.paths.appsDir)}`] : []),
|
|
559
|
+
];
|
|
560
|
+
const modelLines = [
|
|
561
|
+
'[models]',
|
|
562
|
+
`options = ${tomlStringArray(config.models.options)}`,
|
|
563
|
+
];
|
|
564
|
+
const memoryLines = [
|
|
565
|
+
'[memory]',
|
|
566
|
+
`size_limit = ${config.memory.sizeLimit}`,
|
|
567
|
+
`context_limit = ${config.memory.contextLimit}`,
|
|
568
|
+
];
|
|
569
|
+
const agentSection = config.agent === undefined ? undefined : [
|
|
570
|
+
'[agent]',
|
|
571
|
+
`max_iterations = ${config.agent.maxIterations}`,
|
|
572
|
+
`tool_output_limit = ${config.agent.toolOutputLimit}`,
|
|
573
|
+
`tool_mode = ${tomlString(config.agent.toolMode)}`,
|
|
574
|
+
'',
|
|
575
|
+
'[agent.approval]',
|
|
576
|
+
`read = ${tomlString(config.agent.approval.read)}`,
|
|
577
|
+
`write = ${tomlString(config.agent.approval.write)}`,
|
|
578
|
+
`shell = ${tomlString(config.agent.approval.shell)}`,
|
|
579
|
+
`network = ${tomlString(config.agent.approval.network)}`,
|
|
580
|
+
`delegate = ${tomlString(config.agent.approval.delegate)}`,
|
|
581
|
+
...(config.agent.unattended ? [
|
|
582
|
+
'',
|
|
583
|
+
'[agent.unattended]',
|
|
584
|
+
...Object.entries(config.agent.unattended).map(([kind, mode]) => `${kind} = ${tomlString(mode)}`),
|
|
585
|
+
] : []),
|
|
586
|
+
].join('\n');
|
|
587
|
+
const webSearchSection = config.webSearch === undefined ? undefined : [
|
|
588
|
+
'[web_search]',
|
|
589
|
+
`enabled = ${config.webSearch.enabled}`,
|
|
590
|
+
`max_results = ${config.webSearch.maxResults}`,
|
|
591
|
+
`provider = ${tomlString(config.webSearch.provider)}`,
|
|
592
|
+
optionalStringLine('api_key_env', config.webSearch.apiKeyEnv),
|
|
593
|
+
optionalStringLine('api_key', config.webSearch.apiKey),
|
|
594
|
+
...(config.webSearch.scrape ? ['scrape = true'] : []),
|
|
595
|
+
...(config.webSearch.proxy ? [`proxy = ${tomlString(config.webSearch.proxy)}`] : []),
|
|
596
|
+
].filter(Boolean).join('\n');
|
|
597
|
+
const tg = config.channels?.telegram;
|
|
598
|
+
const telegramSection = tg === undefined ? undefined : [
|
|
599
|
+
'[channel.telegram]',
|
|
600
|
+
...(tg.enabled === false ? ['enabled = false'] : []),
|
|
601
|
+
optionalStringLine('bot_token_env', tg.botTokenEnv),
|
|
602
|
+
optionalStringLine('bot_token', tg.botToken),
|
|
603
|
+
`allowlist = [${tg.allowlist.join(', ')}]`,
|
|
604
|
+
`profile = ${tomlString(tg.profile)}`,
|
|
605
|
+
`default_mode = ${tomlString(tg.defaultMode)}`,
|
|
606
|
+
].filter(Boolean).join('\n');
|
|
607
|
+
const svc = config.service;
|
|
608
|
+
const serviceSection = svc === undefined ? undefined : [
|
|
609
|
+
'[service]',
|
|
610
|
+
optionalStringLine('token_env', svc.tokenEnv),
|
|
611
|
+
optionalStringLine('token', svc.token),
|
|
612
|
+
`cors_origins = [${svc.corsOrigins.map(origin => tomlString(origin)).join(', ')}]`,
|
|
613
|
+
optionalStringLine('web_dir', svc.webDir),
|
|
614
|
+
].filter(Boolean).join('\n');
|
|
615
|
+
const providerTables = Object.entries(config.providers)
|
|
616
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
617
|
+
.map(([name, provider]) => renderProvider(name, provider));
|
|
618
|
+
const sections = [
|
|
619
|
+
defaultLines.join('\n'),
|
|
620
|
+
modelLines.join('\n'),
|
|
621
|
+
memoryLines.join('\n'),
|
|
622
|
+
...(agentSection ? [agentSection] : []),
|
|
623
|
+
...(webSearchSection ? [webSearchSection] : []),
|
|
624
|
+
...(telegramSection ? [telegramSection] : []),
|
|
625
|
+
...(serviceSection ? [serviceSection] : []),
|
|
626
|
+
pathLines.join('\n'),
|
|
627
|
+
...providerTables,
|
|
628
|
+
];
|
|
629
|
+
return `${sections.join('\n\n')}\n`;
|
|
630
|
+
}
|
|
631
|
+
function renderProvider(name, provider) {
|
|
632
|
+
const lines = [
|
|
633
|
+
`[providers.${name}]`,
|
|
634
|
+
`type = ${tomlString(provider.type)}`,
|
|
635
|
+
optionalStringLine('base_url', provider.baseUrl),
|
|
636
|
+
optionalStringLine('api_key_env', provider.apiKeyEnv),
|
|
637
|
+
optionalStringLine('api_key', provider.apiKey),
|
|
638
|
+
optionalStringLine('oauth_token', provider.oauthToken),
|
|
639
|
+
optionalNumberLine('api_key_expires_at', provider.apiKeyExpiresAt),
|
|
640
|
+
optionalStringLine('account_id', provider.accountId),
|
|
641
|
+
optionalStringLine('proxy', provider.proxy),
|
|
642
|
+
].filter(Boolean);
|
|
643
|
+
return lines.join('\n');
|
|
644
|
+
}
|
|
645
|
+
function optionalStringLine(key, value) {
|
|
646
|
+
return value === undefined ? undefined : `${key} = ${tomlString(value)}`;
|
|
647
|
+
}
|
|
648
|
+
function optionalNumberLine(key, value) {
|
|
649
|
+
return value === undefined ? undefined : `${key} = ${value}`;
|
|
650
|
+
}
|
|
651
|
+
function parseNumber(value, label) {
|
|
652
|
+
const parsed = Number(value);
|
|
653
|
+
if (!Number.isFinite(parsed))
|
|
654
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Expected ${label} to be a number.`);
|
|
655
|
+
return parsed;
|
|
656
|
+
}
|
|
657
|
+
function parseNonNegativeNumber(value, label) {
|
|
658
|
+
const parsed = parseNumber(value, label);
|
|
659
|
+
if (parsed < 0)
|
|
660
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Expected ${label} to be a non-negative number.`);
|
|
661
|
+
return parsed;
|
|
662
|
+
}
|
|
663
|
+
function parsePositiveInteger(value, label) {
|
|
664
|
+
const parsed = parseNumber(value, label);
|
|
665
|
+
if (!Number.isInteger(parsed) || parsed < 1) {
|
|
666
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Expected ${label} to be a positive integer.`);
|
|
667
|
+
}
|
|
668
|
+
return parsed;
|
|
669
|
+
}
|
|
670
|
+
function parseAgentToolMode(value) {
|
|
671
|
+
if (value === 'auto' || value === 'native' || value === 'control-block')
|
|
672
|
+
return value;
|
|
673
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Expected agent.tool_mode to be auto, native, or control-block.');
|
|
674
|
+
}
|
|
675
|
+
function parseApprovalMode(value) {
|
|
676
|
+
if (value === 'allow' || value === 'ask' || value === 'deny')
|
|
677
|
+
return value;
|
|
678
|
+
throw MarifoldError_1.MarifoldError.configInvalid('Expected an approval mode of allow, ask, or deny.');
|
|
679
|
+
}
|
|
680
|
+
function parseToolKind(value) {
|
|
681
|
+
if (value === 'read' || value === 'write' || value === 'shell' || value === 'network' || value === 'delegate') {
|
|
682
|
+
return value;
|
|
683
|
+
}
|
|
684
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Unknown agent approval kind: ${value}.`);
|
|
685
|
+
}
|
|
686
|
+
function parseProviderType(value) {
|
|
687
|
+
if (value === 'ollama' || value === 'openai-compatible' || value === 'anthropic')
|
|
688
|
+
return value;
|
|
689
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Expected provider type to be "ollama", "openai-compatible", or "anthropic".`);
|
|
690
|
+
}
|
|
691
|
+
function parseBoolean(value, label) {
|
|
692
|
+
const normalized = value.trim().toLowerCase();
|
|
693
|
+
if (normalized === 'true' || normalized === 'on' || normalized === '1')
|
|
694
|
+
return true;
|
|
695
|
+
if (normalized === 'false' || normalized === 'off' || normalized === '0')
|
|
696
|
+
return false;
|
|
697
|
+
throw MarifoldError_1.MarifoldError.configInvalid(`Expected ${label} to be true or false.`);
|
|
698
|
+
}
|
|
699
|
+
function tomlString(value) {
|
|
700
|
+
return JSON.stringify(value);
|
|
701
|
+
}
|
|
702
|
+
function tomlStringArray(values) {
|
|
703
|
+
if (values.length === 0)
|
|
704
|
+
return '[]';
|
|
705
|
+
return `[\n${values.map(value => ` ${tomlString(value)},`).join('\n')}\n]`;
|
|
706
|
+
}
|
|
707
|
+
//# sourceMappingURL=ConfigManager.js.map
|