micro-models-agent 0.55.0 → 0.56.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.
Files changed (232) hide show
  1. package/README.md +358 -358
  2. package/dist/certification/certifications.json +493 -493
  3. package/dist/main.js +2301 -1213
  4. package/dist/modules/browser/bridge-server.mjs +219 -202
  5. package/dist/skills/builtin/git.md +36 -36
  6. package/dist/skills/builtin/typescript.md +35 -35
  7. package/package.json +1 -1
  8. package/dist/cli/commands.js +0 -447
  9. package/dist/cli/completer.js +0 -167
  10. package/dist/cli/index.js +0 -2
  11. package/dist/cli/main.js +0 -153
  12. package/dist/cli/plugin-commands.js +0 -36
  13. package/dist/cli/repl-commands.js +0 -761
  14. package/dist/cli/repl.js +0 -702
  15. package/dist/cli/run-result.js +0 -33
  16. package/dist/cli/security-commands.js +0 -164
  17. package/dist/cli/setup.js +0 -237
  18. package/dist/config/config.js +0 -276
  19. package/dist/config/defaults.js +0 -141
  20. package/dist/config/domains.js +0 -179
  21. package/dist/config/experts.js +0 -15
  22. package/dist/config/index.js +0 -4
  23. package/dist/config/security.js +0 -213
  24. package/dist/config/types.js +0 -1
  25. package/dist/core/agent-moe.js +0 -102
  26. package/dist/core/agent.js +0 -1018
  27. package/dist/core/bootstrap.js +0 -481
  28. package/dist/core/crash-handler.js +0 -51
  29. package/dist/core/environment.js +0 -199
  30. package/dist/core/index.js +0 -2
  31. package/dist/core/prompt-builder.js +0 -76
  32. package/dist/core/session-logger.js +0 -251
  33. package/dist/core/types.js +0 -1
  34. package/dist/core/version.js +0 -26
  35. package/dist/core/workspace.js +0 -76
  36. package/dist/i18n/en.json +0 -679
  37. package/dist/i18n/index.js +0 -46
  38. package/dist/i18n/ru.json +0 -679
  39. package/dist/index.js +0 -22
  40. package/dist/llm/image-utils.js +0 -143
  41. package/dist/llm/index.js +0 -4
  42. package/dist/llm/model-loader.js +0 -78
  43. package/dist/llm/openai-compat.js +0 -497
  44. package/dist/llm/orchestrator.js +0 -200
  45. package/dist/llm/provider.js +0 -10
  46. package/dist/llm/response.js +0 -39
  47. package/dist/llm/token-counter.js +0 -39
  48. package/dist/llm/types.js +0 -1
  49. package/dist/logger/app-logger.js +0 -189
  50. package/dist/logger/file-log.js +0 -151
  51. package/dist/logger/index.js +0 -1
  52. package/dist/migration/backup.js +0 -45
  53. package/dist/migration/detect.js +0 -50
  54. package/dist/migration/index.js +0 -2
  55. package/dist/modules/artifacts/store.js +0 -61
  56. package/dist/modules/browser/actions.js +0 -76
  57. package/dist/modules/browser/bridge-client.js +0 -199
  58. package/dist/modules/browser/bridge-path.js +0 -10
  59. package/dist/modules/browser/cookie-store.js +0 -24
  60. package/dist/modules/browser/driver.js +0 -136
  61. package/dist/modules/browser/index.js +0 -7
  62. package/dist/modules/browser/module.js +0 -29
  63. package/dist/modules/browser/session.js +0 -342
  64. package/dist/modules/browser/snapshot.js +0 -148
  65. package/dist/modules/browser/types.js +0 -12
  66. package/dist/modules/certification/cli.js +0 -213
  67. package/dist/modules/certification/fact-checker.js +0 -82
  68. package/dist/modules/certification/loader.js +0 -106
  69. package/dist/modules/certification/manifest.js +0 -58
  70. package/dist/modules/certification/runner.js +0 -245
  71. package/dist/modules/certification/scenarios.js +0 -407
  72. package/dist/modules/certification/types.js +0 -1
  73. package/dist/modules/context/chunk-query.js +0 -100
  74. package/dist/modules/context/fact-extractor.js +0 -168
  75. package/dist/modules/context/history.js +0 -15
  76. package/dist/modules/context/index.js +0 -1
  77. package/dist/modules/context/manager.js +0 -440
  78. package/dist/modules/execution/audit-runners.js +0 -206
  79. package/dist/modules/execution/auditor.js +0 -218
  80. package/dist/modules/execution/execution-plugin.js +0 -431
  81. package/dist/modules/execution/index.js +0 -8
  82. package/dist/modules/execution/module.js +0 -625
  83. package/dist/modules/execution/moe-executor.js +0 -304
  84. package/dist/modules/execution/plan-coverage.js +0 -68
  85. package/dist/modules/execution/plan-persister.js +0 -46
  86. package/dist/modules/execution/plan-store.js +0 -196
  87. package/dist/modules/execution/plan-tool.js +0 -677
  88. package/dist/modules/execution/plan-validator.js +0 -153
  89. package/dist/modules/execution/planner.js +0 -94
  90. package/dist/modules/execution/stuck-detector.js +0 -746
  91. package/dist/modules/execution/tracker.js +0 -69
  92. package/dist/modules/execution/types.js +0 -1
  93. package/dist/modules/execution/verifier.js +0 -235
  94. package/dist/modules/execution/windows-commands.js +0 -41
  95. package/dist/modules/hallucination/confidence.js +0 -66
  96. package/dist/modules/hallucination/consistency.js +0 -26
  97. package/dist/modules/hallucination/detector.js +0 -47
  98. package/dist/modules/hallucination/factual.js +0 -169
  99. package/dist/modules/hallucination/index.js +0 -5
  100. package/dist/modules/hallucination/js-identifiers.js +0 -262
  101. package/dist/modules/hallucination/llm-judge.js +0 -101
  102. package/dist/modules/index.js +0 -5
  103. package/dist/modules/indexer/cache.js +0 -40
  104. package/dist/modules/indexer/index.js +0 -3
  105. package/dist/modules/indexer/module.js +0 -246
  106. package/dist/modules/indexer/project-profile.js +0 -183
  107. package/dist/modules/indexer/walker.js +0 -101
  108. package/dist/modules/lsp/check-tool.js +0 -58
  109. package/dist/modules/lsp/client.js +0 -389
  110. package/dist/modules/lsp/command.js +0 -60
  111. package/dist/modules/lsp/config.js +0 -135
  112. package/dist/modules/lsp/index.js +0 -3
  113. package/dist/modules/lsp/module.js +0 -260
  114. package/dist/modules/lsp/probe.js +0 -86
  115. package/dist/modules/lsp/project-root.js +0 -32
  116. package/dist/modules/lsp/startup-check.js +0 -144
  117. package/dist/modules/lsp/types.js +0 -1
  118. package/dist/modules/mcp/client.js +0 -399
  119. package/dist/modules/mcp/index.js +0 -3
  120. package/dist/modules/mcp/module.js +0 -142
  121. package/dist/modules/mcp/registry.js +0 -15
  122. package/dist/modules/memory/index.js +0 -1
  123. package/dist/modules/memory/module.js +0 -96
  124. package/dist/modules/memory/search.js +0 -42
  125. package/dist/modules/memory/store.js +0 -69
  126. package/dist/modules/pipelines/engine.js +0 -60
  127. package/dist/modules/pipelines/index.js +0 -3
  128. package/dist/modules/pipelines/parser.js +0 -56
  129. package/dist/modules/pipelines/template.js +0 -14
  130. package/dist/modules/plugins/builtin/lint-on-write.js +0 -334
  131. package/dist/modules/plugins/builtin/notify.js +0 -9
  132. package/dist/modules/plugins/index.js +0 -1
  133. package/dist/modules/plugins/loader.js +0 -70
  134. package/dist/modules/plugins/manager.js +0 -261
  135. package/dist/modules/plugins/types.js +0 -1
  136. package/dist/modules/pricing/index.js +0 -61
  137. package/dist/modules/pricing/prices.js +0 -129
  138. package/dist/modules/processes/detect.js +0 -34
  139. package/dist/modules/processes/index.js +0 -2
  140. package/dist/modules/processes/registry.js +0 -327
  141. package/dist/modules/processes/runner.js +0 -23
  142. package/dist/modules/providers/create.js +0 -22
  143. package/dist/modules/providers/fallback.js +0 -79
  144. package/dist/modules/providers/health.js +0 -46
  145. package/dist/modules/providers/index.js +0 -5
  146. package/dist/modules/providers/manager.js +0 -161
  147. package/dist/modules/providers/presets.js +0 -128
  148. package/dist/modules/providers/registry.js +0 -22
  149. package/dist/modules/providers/types.js +0 -1
  150. package/dist/modules/registry.js +0 -48
  151. package/dist/modules/security/audit-log.js +0 -136
  152. package/dist/modules/security/audit-notifier.js +0 -292
  153. package/dist/modules/security/command-validator.js +0 -219
  154. package/dist/modules/security/content-scanner.js +0 -53
  155. package/dist/modules/security/data-sanitizer.js +0 -89
  156. package/dist/modules/security/encryption.js +0 -242
  157. package/dist/modules/security/index.js +0 -14
  158. package/dist/modules/security/network-validator.js +0 -88
  159. package/dist/modules/security/path-validator.js +0 -203
  160. package/dist/modules/security/rate-limiter.js +0 -119
  161. package/dist/modules/security/security-policies.js +0 -531
  162. package/dist/modules/security/session-encryption.js +0 -210
  163. package/dist/modules/security/session-isolation.js +0 -95
  164. package/dist/modules/session/index.js +0 -3
  165. package/dist/modules/session/manager.js +0 -172
  166. package/dist/modules/session/module.js +0 -24
  167. package/dist/modules/session/store.js +0 -222
  168. package/dist/modules/session/types.js +0 -1
  169. package/dist/modules/skills/index.js +0 -2
  170. package/dist/modules/skills/loader.js +0 -72
  171. package/dist/modules/skills/matcher.js +0 -27
  172. package/dist/modules/skills/module.js +0 -129
  173. package/dist/modules/types.js +0 -1
  174. package/dist/modules/updater/checker.js +0 -96
  175. package/dist/modules/updater/index.js +0 -2
  176. package/dist/modules/updater/module.js +0 -116
  177. package/dist/modules/user-profile/compressor.js +0 -16
  178. package/dist/modules/user-profile/index.js +0 -1
  179. package/dist/modules/user-profile/profile.js +0 -68
  180. package/dist/tools/approve.js +0 -33
  181. package/dist/tools/attach-image.js +0 -101
  182. package/dist/tools/bash.js +0 -519
  183. package/dist/tools/browser.js +0 -115
  184. package/dist/tools/chunk-query.js +0 -100
  185. package/dist/tools/create-dir.js +0 -56
  186. package/dist/tools/delete-file.js +0 -63
  187. package/dist/tools/download-file.js +0 -117
  188. package/dist/tools/edit-file.js +0 -80
  189. package/dist/tools/enable-tools.js +0 -59
  190. package/dist/tools/executor.js +0 -154
  191. package/dist/tools/file-info.js +0 -47
  192. package/dist/tools/filter-tools.js +0 -17
  193. package/dist/tools/glob-tool.js +0 -27
  194. package/dist/tools/grep-tool.js +0 -125
  195. package/dist/tools/hidden-tools-block.js +0 -37
  196. package/dist/tools/index.js +0 -78
  197. package/dist/tools/list-dir.js +0 -49
  198. package/dist/tools/load-skill.js +0 -43
  199. package/dist/tools/mcp-call.js +0 -69
  200. package/dist/tools/move-file.js +0 -86
  201. package/dist/tools/path-utils.js +0 -101
  202. package/dist/tools/pipeline-run.js +0 -145
  203. package/dist/tools/preview.js +0 -2
  204. package/dist/tools/process-kill.js +0 -40
  205. package/dist/tools/process-list.js +0 -37
  206. package/dist/tools/process-log.js +0 -54
  207. package/dist/tools/question.js +0 -141
  208. package/dist/tools/read-file.js +0 -179
  209. package/dist/tools/recall.js +0 -118
  210. package/dist/tools/registry.js +0 -47
  211. package/dist/tools/remember.js +0 -68
  212. package/dist/tools/scope-check.js +0 -32
  213. package/dist/tools/search-history.js +0 -85
  214. package/dist/tools/subagent.js +0 -196
  215. package/dist/tools/types.js +0 -1
  216. package/dist/tools/user-input.js +0 -123
  217. package/dist/tools/web-browse.js +0 -87
  218. package/dist/tools/web-fetch.js +0 -119
  219. package/dist/tools/web-search.js +0 -105
  220. package/dist/tools/write-file.js +0 -82
  221. package/dist/ui/box.js +0 -77
  222. package/dist/ui/colors.js +0 -4
  223. package/dist/ui/diff.js +0 -178
  224. package/dist/ui/index.js +0 -6
  225. package/dist/ui/line-editor.js +0 -822
  226. package/dist/ui/line-math.js +0 -73
  227. package/dist/ui/md-formatter.js +0 -212
  228. package/dist/ui/output.js +0 -13
  229. package/dist/ui/plan-view.js +0 -103
  230. package/dist/ui/renderer.js +0 -259
  231. package/dist/ui/spinner.js +0 -70
  232. package/dist/ui/table.js +0 -144
@@ -1,276 +0,0 @@
1
- import { existsSync, readFileSync, unlinkSync, writeFileSync, mkdirSync } from "fs";
2
- import { join, dirname } from "path";
3
- import { homedir } from "os";
4
- import { DEFAULTS } from "./defaults";
5
- import { DEFAULT_SECURITY_CONFIG } from "./security";
6
- import { DEFAULT_LSP_CONFIG } from "../modules/lsp/config";
7
- import { t } from "../i18n/index";
8
- import { MigrationDetector } from "../migration/detect";
9
- import { BackupManager } from "../migration/backup";
10
- import { validateExpertConfig } from "./experts";
11
- import { ConfigEncryptor } from "../modules/security/encryption";
12
- import { loadDomainFiles, saveDomainFiles } from "./domains";
13
- // ── Centralized path constants ──────────────────────────────────────────
14
- export const CONFIG_DIR = join(homedir(), ".mma");
15
- export const CONFIG_FILE = join(CONFIG_DIR, "config.json");
16
- export const CONFIG_DOMAIN_DIR = join(CONFIG_DIR, "config");
17
- // ── Internal helpers ────────────────────────────────────────────────────
18
- /**
19
- * Restore RegExp instances in dangerousPatterns that were serialized as {}
20
- * (pre-0.8.0 configs) or as {__regex, source, flags} (new format).
21
- * Falls back to default patterns for any entry that is not a real RegExp.
22
- */
23
- function restoreDangerousPatterns(patterns, defaults) {
24
- const fallback = (Array.isArray(defaults) ? defaults : []);
25
- if (!Array.isArray(patterns) || patterns.length === 0) {
26
- return fallback;
27
- }
28
- return patterns.map((p, i) => {
29
- if (p instanceof RegExp)
30
- return p;
31
- if (p && typeof p === "object") {
32
- const { source, flags } = p;
33
- if (source && typeof source === "string") {
34
- try {
35
- return new RegExp(source, flags || "");
36
- }
37
- catch {
38
- // fall through
39
- }
40
- }
41
- }
42
- return fallback[i] || fallback[0] || p;
43
- });
44
- }
45
- function deepMerge(target, source) {
46
- const result = { ...target };
47
- for (const key of Object.keys(source)) {
48
- const srcVal = source[key];
49
- const tgtVal = target[key];
50
- if (srcVal !== null &&
51
- srcVal !== undefined &&
52
- typeof srcVal === "object" &&
53
- !Array.isArray(srcVal) &&
54
- typeof tgtVal === "object" &&
55
- !Array.isArray(tgtVal)) {
56
- result[key] = deepMerge(tgtVal, srcVal);
57
- }
58
- else if (srcVal !== undefined) {
59
- result[key] = srcVal;
60
- }
61
- }
62
- return result;
63
- }
64
- /**
65
- * JSON replacer that serializes RegExp objects as {__regex, source, flags}
66
- * so they survive JSON.stringify/parse round-trips.
67
- */
68
- function regexReplacer(_key, value) {
69
- if (value instanceof RegExp) {
70
- return { __regex: true, source: value.source, flags: value.flags };
71
- }
72
- return value;
73
- }
74
- /**
75
- * JSON reviver that restores RegExp objects serialized by regexReplacer.
76
- */
77
- function regexReviver(_key, value) {
78
- if (value && typeof value === "object" && value.__regex === true) {
79
- const { source, flags } = value;
80
- try {
81
- return new RegExp(source, flags);
82
- }
83
- catch {
84
- return value;
85
- }
86
- }
87
- return value;
88
- }
89
- /**
90
- * Legacy npx `args` for LSP servers that predate the fixed invocation.
91
- */
92
- const LEGACY_LSP_SERVER_ARGS = {
93
- typescript: { args: ["typescript-language-server", "--stdio"], timeout: 30000 },
94
- javascript: { args: ["typescript-language-server", "--stdio"], timeout: 30000 },
95
- json: { args: ["vscode-json-languageserver", "--stdio"], timeout: 30000 },
96
- html: { args: ["vscode-html-languageserver", "--stdio"], timeout: 60000 },
97
- css: { args: ["vscode-css-languageserver", "--stdio"], timeout: 60000 },
98
- };
99
- /**
100
- * Replace stale pre-0.41.1 LSP server invocations with current defaults.
101
- */
102
- function normalizeLspServerArgs(config) {
103
- const servers = config.lsp?.servers;
104
- if (!servers)
105
- return;
106
- for (const [lang, legacy] of Object.entries(LEGACY_LSP_SERVER_ARGS)) {
107
- const server = servers[lang];
108
- const def = DEFAULT_LSP_CONFIG.servers[lang];
109
- if (!server || server.command !== "npx" || !def)
110
- continue;
111
- const storedArgs = Array.isArray(server.args) ? server.args : null;
112
- const isLegacy = storedArgs === null || JSON.stringify(storedArgs) === JSON.stringify(legacy.args);
113
- if (isLegacy) {
114
- server.args = def.args;
115
- server.timeout = def.timeout;
116
- }
117
- }
118
- }
119
- function loadJSON(path) {
120
- try {
121
- if (existsSync(path)) {
122
- return JSON.parse(readFileSync(path, "utf-8"), regexReviver);
123
- }
124
- }
125
- catch {
126
- /* ignore malformed files */
127
- }
128
- return null;
129
- }
130
- function applyEnvVars(config) {
131
- const env = process.env;
132
- const result = { ...config };
133
- if (env.MMA_MODEL)
134
- result.model = env.MMA_MODEL;
135
- if (env.MMA_PROVIDER_TYPE)
136
- result.provider = { ...result.provider, type: env.MMA_PROVIDER_TYPE };
137
- if (env.MMA_PROVIDER_BASEURL)
138
- result.provider = { ...result.provider, baseUrl: env.MMA_PROVIDER_BASEURL };
139
- if (env.MMA_PROVIDER_APIKEY)
140
- result.provider = { ...result.provider, apiKey: env.MMA_PROVIDER_APIKEY };
141
- if (env.MMA_LOG_LEVEL)
142
- result.logLevel = env.MMA_LOG_LEVEL;
143
- if (env.MMA_LOCALE)
144
- result.locale = env.MMA_LOCALE;
145
- if (env.MMA_CONTEXT_WINDOW) {
146
- const v = parseInt(env.MMA_CONTEXT_WINDOW, 10);
147
- if (!isNaN(v))
148
- result.contextWindow = v;
149
- }
150
- if (env.MMA_MAX_TOOL_ITERATIONS) {
151
- const v = parseInt(env.MMA_MAX_TOOL_ITERATIONS, 10);
152
- if (!isNaN(v))
153
- result.maxToolIterations = v;
154
- }
155
- if (env.MMA_STUCK_THRESHOLD) {
156
- const v = parseInt(env.MMA_STUCK_THRESHOLD, 10);
157
- if (!isNaN(v))
158
- result.stuckThreshold = v;
159
- }
160
- if (env.MMA_AUTO_PLAN)
161
- result.autoPlan = env.MMA_AUTO_PLAN === "true";
162
- if (env.MMA_MOE_ENABLED)
163
- result.moe = { ...result.moe, enabled: env.MMA_MOE_ENABLED === "true" };
164
- return result;
165
- }
166
- /**
167
- * Load config from domain files (preferred) or legacy config.json (fallback).
168
- *
169
- * Pipeline:
170
- * 1. DEFAULTS
171
- * 2. deepMerge(legacy config.json) — if exists
172
- * 3. deepMerge(domain files) — if exist, override legacy
173
- * 4. deepMerge(project .mmrc) — overrides everything
174
- * 5. Post-load fixups (RegExp, LSP args)
175
- * 6. Env vars
176
- * 7. Decrypt
177
- *
178
- * On first run (no config.json, no domain files), auto-creates domain files.
179
- */
180
- export function loadConfig(options) {
181
- const globalPath = join(options.configDir, "config.json");
182
- mkdirSync(options.configDir, { recursive: true });
183
- // v1 → v2 migration check (reads config.json directly, before domain logic)
184
- const detector = new MigrationDetector(options.configDir);
185
- if (detector.needsMigration()) {
186
- const backup = new BackupManager(options.configDir);
187
- backup.backupConfig();
188
- const summary = backup.getBackupSummary();
189
- console.log(t("migration.detected", { summary }));
190
- try {
191
- unlinkSync(globalPath);
192
- }
193
- catch { }
194
- }
195
- let config = { ...DEFAULTS };
196
- let legacyDetected = false;
197
- // Step 1: legacy config.json (fallback)
198
- const globalData = loadJSON(globalPath);
199
- if (globalData) {
200
- config = deepMerge(config, globalData);
201
- legacyDetected = true;
202
- }
203
- // Step 2: domain files (override legacy)
204
- const domainConfig = loadDomainFiles(options.configDir);
205
- if (domainConfig) {
206
- config = deepMerge(config, domainConfig);
207
- legacyDetected = false;
208
- }
209
- // Step 3: first run — auto-create domain files instead of config.json
210
- if (!globalData && !domainConfig) {
211
- saveDomainFiles(config, options.configDir);
212
- }
213
- // Step 4: project .mmrc (overrides everything)
214
- const projectData = loadJSON(options.projectConfigPath);
215
- if (projectData) {
216
- config = deepMerge(config, projectData);
217
- }
218
- // Step 5: post-load fixups — AFTER all merges
219
- if (config.security?.contentScan?.dangerousPatterns) {
220
- config.security.contentScan.dangerousPatterns = restoreDangerousPatterns(config.security.contentScan.dangerousPatterns, DEFAULT_SECURITY_CONFIG.contentScan.dangerousPatterns);
221
- }
222
- normalizeLspServerArgs(config);
223
- // Step 6: env vars
224
- config = applyEnvVars(config);
225
- // Step 7: decrypt
226
- try {
227
- const encryptor = new ConfigEncryptor();
228
- const decrypted = encryptor.decrypt(config);
229
- for (const key of Object.keys(decrypted)) {
230
- config[key] = decrypted[key];
231
- }
232
- }
233
- catch (e) {
234
- console.warn(t("config.decryption_warning", { error: e.message }));
235
- }
236
- return { config, legacyDetected };
237
- }
238
- export function validateConfig(config, allToolTags) {
239
- const errors = validateExpertConfig(config, allToolTags);
240
- const knownTags = new Set(allToolTags);
241
- for (const tag of config.tools?.defaultTags ?? []) {
242
- if (!knownTags.has(tag)) {
243
- errors.push(`tools.defaultTags references unknown tag "${tag}". Known tags: ${Array.from(knownTags).join(", ")}`);
244
- }
245
- }
246
- if (errors.length > 0) {
247
- throw new Error(`Config validation failed:\n${errors.join("\n")}`);
248
- }
249
- }
250
- /**
251
- * Save config to domain files (preferred) or legacy single file (fallback).
252
- *
253
- * @param config Full AppConfig to save
254
- * @param configPath Legacy path (e.g. ~/.mma/config.json) — used when configDir is absent
255
- * @param configDir Optional config directory (e.g. ~/.mma). When provided, writes domain files.
256
- */
257
- export function saveConfig(config, configPath, configDir) {
258
- if (configDir) {
259
- saveDomainFiles(config, configDir);
260
- return;
261
- }
262
- // Legacy single-file write (backward compat for tests / edge cases)
263
- const dir = dirname(configPath);
264
- mkdirSync(dir, { recursive: true });
265
- try {
266
- const encryptor = new ConfigEncryptor();
267
- const encryptedConfig = encryptor.encrypt({
268
- ...config,
269
- });
270
- writeFileSync(configPath, JSON.stringify(encryptedConfig, regexReplacer, 2), "utf-8");
271
- }
272
- catch (e) {
273
- console.warn(t("config.encryption_warning", { error: e.message }));
274
- writeFileSync(configPath, JSON.stringify(config, regexReplacer, 2), "utf-8");
275
- }
276
- }
@@ -1,141 +0,0 @@
1
- import { DEFAULT_SECURITY_CONFIG } from "./security";
2
- import { DEFAULT_LSP_CONFIG } from "../modules/lsp/config";
3
- export const DEFAULTS = {
4
- version: "2.0.0",
5
- model: "qwen/qwen3.5-9b",
6
- provider: {
7
- type: "openai-compat",
8
- baseUrl: "http://localhost:1234/v1",
9
- apiKey: "not-needed",
10
- },
11
- orchestrator: {
12
- model: undefined,
13
- provider: undefined,
14
- },
15
- moe: {
16
- enabled: false,
17
- },
18
- tools: {
19
- defaultTags: ["file", "code"],
20
- enableOnDemand: true,
21
- },
22
- experts: {
23
- code: {
24
- model: "qwen/qwen3.5-9b",
25
- tool_tags: ["file", "code", "shell"],
26
- max_attempts: 3,
27
- },
28
- research: {
29
- model: "qwen/qwen3.5-9b",
30
- tool_tags: ["research"],
31
- max_attempts: 3,
32
- },
33
- browser: {
34
- model: "qwen/qwen3.5-9b",
35
- tool_tags: ["browser", "vision"],
36
- max_attempts: 3,
37
- },
38
- vision: {
39
- model: "qwen/qwen3.5-9b",
40
- tool_tags: ["browser", "vision", "file"],
41
- max_attempts: 2,
42
- },
43
- },
44
- contextWindow: 32768,
45
- contextBudget: {
46
- systemPrompt: 0.1,
47
- responseReserve: 0.15,
48
- compactionThreshold: 0.75,
49
- },
50
- modelLoad: {
51
- autoLoad: false,
52
- flashAttention: true,
53
- offloadKvCacheToGpu: true,
54
- },
55
- retry: {
56
- maxRetries: 3,
57
- baseDelay: 1000,
58
- maxDelay: 30000,
59
- maxStreamRetries: 2,
60
- noDataTimeoutMs: 180000,
61
- },
62
- maxToolIterations: 1000,
63
- stuckThreshold: 6,
64
- autoPlan: true,
65
- showReasoning: false,
66
- logLevel: "info",
67
- locale: "en",
68
- session: {
69
- autoSave: true,
70
- maxSessions: 50,
71
- isolateMemory: false,
72
- },
73
- browser: {
74
- enabled: true,
75
- headless: true,
76
- maxElements: 30,
77
- maxContentChars: 2500,
78
- maxConsoleEntries: 40,
79
- maxConsoleLineChars: 400,
80
- viewportWidth: 1280,
81
- viewportHeight: 720,
82
- navigationTimeout: 15000,
83
- },
84
- webSearch: {
85
- enabled: true,
86
- },
87
- errorWebSearch: {
88
- enabled: true,
89
- threshold: 5,
90
- maxResults: 5,
91
- maxQueryChars: 200,
92
- maxSearchesPerSession: 3,
93
- requestTimeoutMs: 10000,
94
- },
95
- pricing: {
96
- enabled: true,
97
- overrides: {},
98
- },
99
- ui: {
100
- spinner: true,
101
- toolStyle: "inline",
102
- toolComments: true,
103
- showContextStats: false,
104
- showCompaction: true,
105
- },
106
- mcpServers: {
107
- context7: {
108
- name: "context7",
109
- transport: "http",
110
- url: "https://mcp.context7.com/mcp",
111
- headers: {
112
- CONTEXT7_API_KEY: process.env.CONTEXT7_API_KEY || "",
113
- },
114
- enabled: true,
115
- timeout: 30000,
116
- },
117
- },
118
- security: DEFAULT_SECURITY_CONFIG,
119
- sessionIsolation: {
120
- enabled: false,
121
- isolatePlugins: true,
122
- isolateTempFiles: true,
123
- },
124
- skills: {
125
- budget: 0.15,
126
- },
127
- subagent: {
128
- resultMode: "text",
129
- maxSummaryChars: 2000,
130
- artifactsDir: ".mma/artifacts",
131
- stableSystemPrompt: true,
132
- maxParallelChunkQueries: 4,
133
- },
134
- lsp: DEFAULT_LSP_CONFIG,
135
- updater: {
136
- enabled: true,
137
- checkOnStart: true,
138
- autoInstall: true,
139
- intervalMs: 0,
140
- },
141
- };
@@ -1,179 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync } from "fs";
2
- import { join } from "path";
3
- /**
4
- * Mapping: domain name → AppConfig keys that belong to it.
5
- * Each domain becomes one JSON file in ~/.mma/config/<domain>.json.
6
- */
7
- export const CONFIG_DOMAINS = {
8
- core: [
9
- "version",
10
- "model",
11
- "contextWindow",
12
- "contextBudget",
13
- "modelLoad",
14
- "maxToolIterations",
15
- "stuckThreshold",
16
- "autoPlan",
17
- "showReasoning",
18
- "logLevel",
19
- "locale",
20
- ],
21
- provider: ["provider", "orchestrator", "retry", "pricing"],
22
- moe: ["moe", "experts"],
23
- security: ["security"],
24
- browser: ["browser"],
25
- search: ["webSearch", "errorWebSearch"],
26
- tools: ["tools", "subagent"],
27
- session: ["session", "sessionIsolation"],
28
- ui: ["ui"],
29
- mcp: ["mcpServers"],
30
- lsp: ["lsp"],
31
- skills: ["skills"],
32
- updater: ["updater"],
33
- };
34
- /**
35
- * JSON replacer that serializes RegExp objects as {__regex, source, flags}
36
- * so they survive JSON.stringify/parse round-trips.
37
- */
38
- function regexReplacer(_key, value) {
39
- if (value instanceof RegExp) {
40
- return { __regex: true, source: value.source, flags: value.flags };
41
- }
42
- return value;
43
- }
44
- /**
45
- * JSON reviver that restores RegExp objects serialized by regexReplacer.
46
- */
47
- function regexReviver(_key, value) {
48
- if (value &&
49
- typeof value === "object" &&
50
- value.__regex === true) {
51
- const { source, flags } = value;
52
- try {
53
- return new RegExp(source, flags);
54
- }
55
- catch {
56
- return value;
57
- }
58
- }
59
- return value;
60
- }
61
- /**
62
- * Deep merge two objects. Arrays and scalars in source replace target.
63
- */
64
- function deepMerge(target, source) {
65
- const result = { ...target };
66
- for (const key of Object.keys(source)) {
67
- const srcVal = source[key];
68
- const tgtVal = target[key];
69
- if (srcVal !== null &&
70
- srcVal !== undefined &&
71
- typeof srcVal === "object" &&
72
- !Array.isArray(srcVal) &&
73
- typeof tgtVal === "object" &&
74
- !Array.isArray(tgtVal)) {
75
- result[key] = deepMerge(tgtVal, srcVal);
76
- }
77
- else if (srcVal !== undefined) {
78
- result[key] = srcVal;
79
- }
80
- }
81
- return result;
82
- }
83
- /**
84
- * Extract a domain subset from a full AppConfig.
85
- */
86
- export function extractDomain(config, domain) {
87
- const keys = CONFIG_DOMAINS[domain];
88
- if (!keys)
89
- return {};
90
- const subset = {};
91
- for (const key of keys) {
92
- if (config[key] !== undefined) {
93
- subset[key] = config[key];
94
- }
95
- }
96
- return subset;
97
- }
98
- /**
99
- * Get the file path for a domain config file.
100
- */
101
- export function getDomainFilePath(configDir, domain) {
102
- return join(configDir, "config", `${domain}.json`);
103
- }
104
- /**
105
- * Check if domain files exist in config/ directory.
106
- */
107
- export function hasDomainFiles(configDir) {
108
- const configDirPath = join(configDir, "config");
109
- if (!existsSync(configDirPath))
110
- return false;
111
- try {
112
- const files = readdirSync(configDirPath);
113
- return files.some((f) => f.endsWith(".json"));
114
- }
115
- catch {
116
- return false;
117
- }
118
- }
119
- /**
120
- * Load all domain files from ~/.mma/config/ and merge into a partial AppConfig.
121
- * Each file is parsed with regexReviver to restore RegExp objects.
122
- * Returns null if no domain files exist.
123
- */
124
- export function loadDomainFiles(configDir) {
125
- const configDirPath = join(configDir, "config");
126
- if (!existsSync(configDirPath))
127
- return null;
128
- let result = {};
129
- let anyLoaded = false;
130
- for (const domain of Object.keys(CONFIG_DOMAINS)) {
131
- const filePath = getDomainFilePath(configDir, domain);
132
- if (!existsSync(filePath))
133
- continue;
134
- try {
135
- const raw = readFileSync(filePath, "utf-8");
136
- const data = JSON.parse(raw, regexReviver);
137
- result = deepMerge(result, data);
138
- anyLoaded = true;
139
- }
140
- catch {
141
- // Skip malformed domain files
142
- }
143
- }
144
- return anyLoaded ? result : null;
145
- }
146
- /**
147
- * Save a full AppConfig to domain files in ~/.mma/config/.
148
- * Each domain's keys are extracted and written to config/<domain>.json.
149
- * RegExp objects are serialized via regexReplacer.
150
- */
151
- export function saveDomainFiles(config, configDir) {
152
- const configDirPath = join(configDir, "config");
153
- mkdirSync(configDirPath, { recursive: true });
154
- for (const [domain, keys] of Object.entries(CONFIG_DOMAINS)) {
155
- const subset = {};
156
- let hasContent = false;
157
- for (const key of keys) {
158
- if (config[key] !== undefined) {
159
- subset[key] = config[key];
160
- hasContent = true;
161
- }
162
- }
163
- if (!hasContent)
164
- continue;
165
- const filePath = getDomainFilePath(configDir, domain);
166
- writeFileSync(filePath, JSON.stringify(subset, regexReplacer, 2), "utf-8");
167
- }
168
- }
169
- /**
170
- * Determine which domain a config key belongs to.
171
- * Returns the domain name or null if not found.
172
- */
173
- export function domainForKey(key) {
174
- for (const [domain, keys] of Object.entries(CONFIG_DOMAINS)) {
175
- if (keys.includes(key))
176
- return domain;
177
- }
178
- return null;
179
- }
@@ -1,15 +0,0 @@
1
- export function getExpertConfig(config, tag) {
2
- return config.experts?.[tag];
3
- }
4
- export function validateExpertConfig(config, allToolTags) {
5
- const errors = [];
6
- const knownTags = new Set(allToolTags);
7
- for (const [name, expert] of Object.entries(config.experts || {})) {
8
- for (const tag of expert.tool_tags) {
9
- if (!knownTags.has(tag)) {
10
- errors.push(`Expert "${name}" references unknown tool_tag "${tag}". Known tags: ${Array.from(knownTags).join(", ")}`);
11
- }
12
- }
13
- }
14
- return errors;
15
- }
@@ -1,4 +0,0 @@
1
- export { DEFAULTS } from "./defaults";
2
- export { loadConfig, saveConfig, validateConfig, CONFIG_DIR, CONFIG_FILE, CONFIG_DOMAIN_DIR } from "./config";
3
- export { getExpertConfig, validateExpertConfig } from "./experts";
4
- export { CONFIG_DOMAINS, extractDomain, hasDomainFiles, loadDomainFiles, saveDomainFiles, getDomainFilePath, domainForKey, } from "./domains";