micro-models-agent 0.41.0 → 0.41.2
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/bin/mma.mjs +41 -41
- package/dist/cli/commands.js +9 -19
- package/dist/cli/completer.js +36 -37
- package/dist/cli/index.js +2 -2
- package/dist/cli/main.js +48 -23
- package/dist/cli/plugin-commands.js +36 -0
- package/dist/cli/repl-commands.js +40 -12
- package/dist/cli/repl.js +217 -87
- package/dist/cli/run-result.js +22 -0
- package/dist/cli/security-commands.js +5 -7
- package/dist/cli/setup.js +8 -26
- package/dist/config/config.js +52 -5
- package/dist/config/defaults.js +29 -5
- package/dist/config/experts.js +1 -1
- package/dist/config/index.js +3 -3
- package/dist/config/security.js +3 -10
- package/dist/core/agent-moe.js +2 -10
- package/dist/core/agent.js +273 -82
- package/dist/core/bootstrap.js +80 -13
- package/dist/core/index.js +2 -2
- package/dist/core/prompt-builder.js +23 -2
- package/dist/core/session-logger.js +46 -4
- package/dist/core/version.js +24 -0
- package/dist/i18n/en.json +75 -2
- package/dist/i18n/ru.json +74 -1
- package/dist/index.js +1 -1
- package/dist/llm/image-utils.js +4 -5
- package/dist/llm/index.js +4 -4
- package/dist/llm/model-loader.js +6 -6
- package/dist/llm/openai-compat.js +40 -34
- package/dist/llm/orchestrator.js +33 -29
- package/dist/llm/response.js +9 -9
- package/dist/logger/app-logger.js +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/main.js +1111 -954
- package/dist/migration/backup.js +13 -13
- package/dist/migration/detect.js +11 -11
- package/dist/migration/index.js +2 -2
- package/dist/modules/artifacts/store.js +61 -0
- package/dist/modules/browser/actions.js +34 -4
- package/dist/modules/browser/bridge-client.js +199 -0
- package/dist/modules/browser/bridge-path.js +10 -0
- package/dist/modules/browser/bridge-server.mjs +202 -202
- package/dist/modules/browser/cookie-store.js +6 -6
- package/dist/modules/browser/driver.js +136 -0
- package/dist/modules/browser/index.js +7 -5
- package/dist/modules/browser/module.js +8 -7
- package/dist/modules/browser/session.js +87 -84
- package/dist/modules/browser/snapshot.js +92 -58
- package/dist/modules/browser/types.js +4 -1
- package/dist/modules/certification/cli.js +2 -4
- package/dist/modules/certification/fact-checker.js +1 -3
- package/dist/modules/certification/loader.js +3 -9
- package/dist/modules/certification/runner.js +1 -4
- package/dist/modules/context/chunk-query.js +100 -0
- package/dist/modules/context/fact-extractor.js +162 -0
- package/dist/modules/context/history.js +15 -0
- package/dist/modules/context/index.js +1 -1
- package/dist/modules/context/manager.js +160 -86
- package/dist/modules/execution/audit-runners.js +152 -0
- package/dist/modules/execution/auditor.js +177 -25
- package/dist/modules/execution/execution-plugin.js +272 -0
- package/dist/modules/execution/module.js +201 -544
- package/dist/modules/execution/moe-executor.js +25 -0
- package/dist/modules/execution/plan-store.js +1 -3
- package/dist/modules/execution/plan-tool.js +508 -0
- package/dist/modules/execution/plan-validator.js +10 -10
- package/dist/modules/execution/planner.js +6 -1
- package/dist/modules/execution/stuck-detector.js +173 -10
- package/dist/modules/execution/verifier.js +86 -42
- package/dist/modules/execution/windows-commands.js +41 -0
- package/dist/modules/hallucination/confidence.js +8 -1
- package/dist/modules/hallucination/detector.js +2 -5
- package/dist/modules/hallucination/factual.js +3 -64
- package/dist/modules/hallucination/index.js +1 -1
- package/dist/modules/hallucination/js-identifiers.js +190 -0
- package/dist/modules/hallucination/llm-judge.js +1 -3
- package/dist/modules/indexer/cache.js +9 -7
- package/dist/modules/indexer/index.js +3 -3
- package/dist/modules/indexer/module.js +95 -42
- package/dist/modules/indexer/project-profile.js +183 -0
- package/dist/modules/indexer/walker.js +17 -17
- package/dist/modules/lsp/check-tool.js +58 -0
- package/dist/modules/lsp/client.js +74 -31
- package/dist/modules/lsp/command.js +60 -0
- package/dist/modules/lsp/config.js +87 -33
- package/dist/modules/lsp/index.js +3 -3
- package/dist/modules/lsp/module.js +185 -21
- package/dist/modules/lsp/probe.js +76 -0
- package/dist/modules/lsp/project-root.js +32 -0
- package/dist/modules/lsp/startup-check.js +141 -0
- package/dist/modules/mcp/module.js +2 -6
- package/dist/modules/memory/index.js +1 -1
- package/dist/modules/memory/module.js +71 -23
- package/dist/modules/memory/search.js +11 -9
- package/dist/modules/memory/store.js +13 -13
- package/dist/modules/pipelines/engine.js +10 -10
- package/dist/modules/pipelines/index.js +3 -3
- package/dist/modules/pipelines/parser.js +17 -14
- package/dist/modules/pipelines/template.js +1 -1
- package/dist/modules/plugins/builtin/lint-on-write.js +21 -16
- package/dist/modules/plugins/builtin/notify.js +3 -2
- package/dist/modules/plugins/index.js +1 -1
- package/dist/modules/plugins/loader.js +59 -17
- package/dist/modules/plugins/manager.js +73 -17
- package/dist/modules/processes/detect.js +34 -0
- package/dist/modules/processes/index.js +1 -1
- package/dist/modules/processes/registry.js +135 -46
- package/dist/modules/registry.js +4 -2
- package/dist/modules/security/audit-notifier.js +39 -39
- package/dist/modules/security/command-validator.js +2 -8
- package/dist/modules/security/data-sanitizer.js +1 -9
- package/dist/modules/security/encryption.js +58 -56
- package/dist/modules/security/network-validator.js +1 -9
- package/dist/modules/security/path-validator.js +1 -3
- package/dist/modules/security/security-policies.js +3 -19
- package/dist/modules/security/session-encryption.js +1 -1
- package/dist/modules/security/session-isolation.js +8 -8
- package/dist/modules/session/index.js +3 -3
- package/dist/modules/session/module.js +5 -5
- package/dist/modules/session/store.js +3 -9
- package/dist/modules/skills/matcher.js +27 -0
- package/dist/modules/skills/module.js +1 -2
- package/dist/modules/updater/checker.js +70 -6
- package/dist/modules/updater/index.js +2 -1
- package/dist/modules/updater/module.js +116 -0
- package/dist/modules/user-profile/compressor.js +2 -2
- package/dist/modules/user-profile/index.js +1 -1
- package/dist/modules/user-profile/profile.js +9 -9
- package/dist/tools/attach-image.js +1 -1
- package/dist/tools/bash.js +178 -19
- package/dist/tools/browser.js +46 -29
- package/dist/tools/chunk-query.js +99 -0
- package/dist/tools/download-file.js +116 -0
- package/dist/tools/enable-tools.js +58 -0
- package/dist/tools/executor.js +4 -5
- package/dist/tools/file-info.js +13 -12
- package/dist/tools/filter-tools.js +9 -2
- package/dist/tools/glob-tool.js +11 -11
- package/dist/tools/grep-tool.js +1 -3
- package/dist/tools/hidden-tools-block.js +37 -0
- package/dist/tools/index.js +13 -2
- package/dist/tools/list-dir.js +18 -17
- package/dist/tools/load-skill.js +1 -3
- package/dist/tools/path-utils.js +4 -4
- package/dist/tools/pipeline-run.js +25 -25
- package/dist/tools/process-kill.js +11 -11
- package/dist/tools/process-list.js +20 -22
- package/dist/tools/process-log.js +22 -18
- package/dist/tools/question.js +1 -3
- package/dist/tools/read-file.js +10 -2
- package/dist/tools/recall.js +44 -37
- package/dist/tools/registry.js +15 -4
- package/dist/tools/remember.js +29 -29
- package/dist/tools/scope-check.js +9 -9
- package/dist/tools/subagent.js +54 -9
- package/dist/tools/user-input.js +1 -1
- package/dist/tools/web-browse.js +3 -3
- package/dist/tools/web-fetch.js +3 -3
- package/dist/tools/web-search.js +3 -3
- package/dist/tools/write-file.js +1 -3
- package/dist/ui/box.js +1 -5
- package/dist/ui/index.js +6 -6
- package/dist/ui/line-editor.js +703 -0
- package/dist/ui/line-math.js +69 -0
- package/dist/ui/md-formatter.js +33 -33
- package/dist/ui/output.js +5 -5
- package/dist/ui/plan-view.js +103 -0
- package/dist/ui/renderer.js +15 -10
- package/dist/ui/table.js +1 -1
- package/package.json +48 -48
package/dist/tools/subagent.js
CHANGED
|
@@ -5,6 +5,20 @@ import { HallucinationDetector } from "../modules/hallucination/detector";
|
|
|
5
5
|
import { PluginManager } from "../modules/plugins/manager";
|
|
6
6
|
import { logSecurityBlock } from "../modules/security/audit-log";
|
|
7
7
|
import { getSessionSecurityConfig } from "../modules/security/session-isolation";
|
|
8
|
+
import { ArtifactStore } from "../modules/artifacts/store";
|
|
9
|
+
/** Fixed system prompt (KV-cache friendly when stableSystemPrompt is on). */
|
|
10
|
+
export const SUBAGENT_SYSTEM_PROMPT_TEMPLATE = `You are a sub-agent working on a specific task. You have your own context window and tool set.
|
|
11
|
+
|
|
12
|
+
Workflow rules:
|
|
13
|
+
- Prefer small, focused steps. Verify your own work (typecheck/tests) before finishing.
|
|
14
|
+
- For large outputs, write the result to a file with write_file instead of reproducing it in your answer.
|
|
15
|
+
- If the task is big and decomposable, delegate parts to the subagent tool instead of doing everything in one context.
|
|
16
|
+
- When you finish, return a concise final answer; do not repeat file contents verbatim if you already wrote them to disk.`;
|
|
17
|
+
function buildSubagentSystemPrompt(context, stable) {
|
|
18
|
+
if (stable)
|
|
19
|
+
return SUBAGENT_SYSTEM_PROMPT_TEMPLATE;
|
|
20
|
+
return `You are a sub-agent working on a specific task. ${context ? `Context: ${context}` : ""}`;
|
|
21
|
+
}
|
|
8
22
|
export const subagentTool = {
|
|
9
23
|
name: "subagent",
|
|
10
24
|
description: "Spawn an isolated sub-agent to work on a task independently. The sub-agent has its own context and executes autonomously. Use for parallel work or complex sub-tasks.",
|
|
@@ -47,6 +61,15 @@ export const subagentTool = {
|
|
|
47
61
|
items: { type: "string" },
|
|
48
62
|
description: "Tool tags to expose to the sub-agent",
|
|
49
63
|
},
|
|
64
|
+
result_mode: {
|
|
65
|
+
type: "string",
|
|
66
|
+
enum: ["text", "file"],
|
|
67
|
+
description: '"file": persist the full result to an artifact and return a path + summary (pass-by-reference). "text" (default): return the full text into context.',
|
|
68
|
+
},
|
|
69
|
+
artifact_name: {
|
|
70
|
+
type: "string",
|
|
71
|
+
description: "Artifact file name (sanitized). Default: subagent-<timestamp>.",
|
|
72
|
+
},
|
|
50
73
|
},
|
|
51
74
|
required: ["task"],
|
|
52
75
|
},
|
|
@@ -86,8 +109,10 @@ export const subagentTool = {
|
|
|
86
109
|
// Defensive guard: if the caller requested specific tool tags but none of the
|
|
87
110
|
// registered tools match, the sub-agent would have zero tools and would
|
|
88
111
|
// hallucinate instead of acting. Warn the caller so it can correct the tags.
|
|
112
|
+
// Uses getByTags (not getAllForLLM) because alwaysOn tools always match the
|
|
113
|
+
// latter — the guard must test real tag coverage, not schema presence.
|
|
89
114
|
if (toolTags && toolTags.length > 0) {
|
|
90
|
-
const matched = ctx.toolExecutor.
|
|
115
|
+
const matched = ctx.toolExecutor.getRegistry().getByTags(toolTags);
|
|
91
116
|
if (matched.length === 0) {
|
|
92
117
|
return {
|
|
93
118
|
success: false,
|
|
@@ -104,10 +129,10 @@ export const subagentTool = {
|
|
|
104
129
|
const parentScope = ctx.scope;
|
|
105
130
|
ctx.toolExecutor.setScope(scope || { allowed_files: [], read_only_files: [] });
|
|
106
131
|
const systemPrompt = {
|
|
107
|
-
content:
|
|
132
|
+
content: buildSubagentSystemPrompt(context, ctx.config.subagent?.stableSystemPrompt !== false),
|
|
108
133
|
priority: "critical",
|
|
109
134
|
essential: true,
|
|
110
|
-
estimatedTokens:
|
|
135
|
+
estimatedTokens: 150,
|
|
111
136
|
};
|
|
112
137
|
const subDeps = {
|
|
113
138
|
config: ctx.config,
|
|
@@ -128,15 +153,35 @@ export const subagentTool = {
|
|
|
128
153
|
let scopeRestored = false;
|
|
129
154
|
try {
|
|
130
155
|
const result = await subAgent.run(fullTask);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
success: true,
|
|
134
|
-
output: `Sub-agent completed:\n${result.text}\n\nIterations: ${result.iterationCount}`,
|
|
135
|
-
}
|
|
136
|
-
: {
|
|
156
|
+
if (!result.success) {
|
|
157
|
+
return {
|
|
137
158
|
success: false,
|
|
138
159
|
output: `Sub-agent failed: ${result.error}\nPartial output: ${result.text}`,
|
|
139
160
|
};
|
|
161
|
+
}
|
|
162
|
+
const resultMode = args.result_mode || ctx.config.subagent?.resultMode || "text";
|
|
163
|
+
if (resultMode === "file") {
|
|
164
|
+
const store = new ArtifactStore({
|
|
165
|
+
baseDir: ctx.baseDir,
|
|
166
|
+
sessionId: ctx.sessionId || "default",
|
|
167
|
+
artifactsDir: ctx.config.subagent?.artifactsDir,
|
|
168
|
+
});
|
|
169
|
+
const abs = store.save(args.artifact_name || `subagent-${Date.now()}`, result.text, "md");
|
|
170
|
+
const summary = store.summary(result.text, ctx.config.subagent?.maxSummaryChars ?? 2000);
|
|
171
|
+
ctx.logger.debug(`subagent result persisted to artifact ${abs} (${result.text.length} chars, ${result.iterationCount} iterations)`);
|
|
172
|
+
return {
|
|
173
|
+
success: true,
|
|
174
|
+
output: t("tool.subagent_artifact", {
|
|
175
|
+
path: abs,
|
|
176
|
+
iterations: String(result.iterationCount),
|
|
177
|
+
summary,
|
|
178
|
+
}),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
success: true,
|
|
183
|
+
output: `Sub-agent completed:\n${result.text}\n\nIterations: ${result.iterationCount}`,
|
|
184
|
+
};
|
|
140
185
|
}
|
|
141
186
|
finally {
|
|
142
187
|
if (!scopeRestored) {
|
package/dist/tools/user-input.js
CHANGED
|
@@ -82,7 +82,7 @@ export async function askChoice(question, options, opts = {}) {
|
|
|
82
82
|
const answer = await promptLine(rl, choicePrompt(entryCount, multiple));
|
|
83
83
|
const parsed = parseSelection(answer, entryCount, multiple);
|
|
84
84
|
if (parsed) {
|
|
85
|
-
return parsed.map((i) => opts.allowCustom && i === customEntry ? CUSTOM_INDEX : i);
|
|
85
|
+
return parsed.map((i) => (opts.allowCustom && i === customEntry ? CUSTOM_INDEX : i));
|
|
86
86
|
}
|
|
87
87
|
console.log(t("tool.user_input.invalid"));
|
|
88
88
|
}
|
package/dist/tools/web-browse.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t } from "../i18n/index";
|
|
2
|
-
import { isUrlAllowed, sanitizeUrl
|
|
3
|
-
import { logNetworkRequest, logSecurityBlock
|
|
2
|
+
import { isUrlAllowed, sanitizeUrl } from "../modules/security/network-validator";
|
|
3
|
+
import { logNetworkRequest, logSecurityBlock } from "../modules/security/audit-log";
|
|
4
4
|
import { getSessionSecurityConfig } from "../modules/security/session-isolation";
|
|
5
5
|
import { MAX_PREVIEW_LINES } from "./preview";
|
|
6
6
|
const MAX_CHARS = 3000;
|
|
7
7
|
export const webBrowseTool = {
|
|
8
8
|
name: "web_browse",
|
|
9
|
-
description: `Fetch and read a web page. Returns the page content as plain text (max ${MAX_PREVIEW_LINES} lines / ${MAX_CHARS} chars).`,
|
|
9
|
+
description: `Fetch and read a web page. Returns the page content as plain text (max ${MAX_PREVIEW_LINES} lines / ${MAX_CHARS} chars). This is a plain HTTP request — it does NOT execute JavaScript, so JS-rendered single-page apps (weather sites, dashboards, modern SPAs) return empty or near-empty content. For such pages use the "browser" tool instead.`,
|
|
10
10
|
tags: ["research"],
|
|
11
11
|
parameters: {
|
|
12
12
|
type: "object",
|
package/dist/tools/web-fetch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t } from "../i18n/index";
|
|
2
|
-
import { isUrlAllowed, sanitizeUrl
|
|
3
|
-
import { logNetworkRequest, logSecurityBlock
|
|
2
|
+
import { isUrlAllowed, sanitizeUrl } from "../modules/security/network-validator";
|
|
3
|
+
import { logNetworkRequest, logSecurityBlock } from "../modules/security/audit-log";
|
|
4
4
|
import { getSessionSecurityConfig } from "../modules/security/session-isolation";
|
|
5
5
|
import { DEFAULT_SECURITY_CONFIG } from "../config/security";
|
|
6
6
|
import { MAX_PREVIEW_LINES } from "./preview";
|
|
@@ -16,7 +16,7 @@ function stripHtml(html) {
|
|
|
16
16
|
}
|
|
17
17
|
export const webFetchTool = {
|
|
18
18
|
name: "web_fetch",
|
|
19
|
-
description:
|
|
19
|
+
description: 'Fetch a URL and convert its content to markdown. Use for reading documentation, APIs, web pages. This is a plain HTTP request without a browser engine — it does NOT run JavaScript, so JS-rendered single-page apps (weather sites, dashboards, modern SPAs) return empty or near-empty content; use the "browser" tool for those.',
|
|
20
20
|
tags: ["research"],
|
|
21
21
|
parameters: {
|
|
22
22
|
type: "object",
|
package/dist/tools/web-search.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t } from "../i18n/index";
|
|
2
|
-
import { isUrlAllowed, sanitizeUrl
|
|
3
|
-
import { logNetworkRequest, logSecurityBlock
|
|
2
|
+
import { isUrlAllowed, sanitizeUrl } from "../modules/security/network-validator";
|
|
3
|
+
import { logNetworkRequest, logSecurityBlock } from "../modules/security/audit-log";
|
|
4
4
|
import { getSessionSecurityConfig } from "../modules/security/session-isolation";
|
|
5
5
|
export const webSearchTool = {
|
|
6
6
|
name: "web_search",
|
|
7
|
-
description: "Search the web for information. Returns search results with titles and snippets.",
|
|
7
|
+
description: "Search the web for information. Returns search results with titles and snippets. Use this for search queries instead of opening search engines (Google/Yandex/Bing) in the browser — they block headless browsers.",
|
|
8
8
|
tags: ["research"],
|
|
9
9
|
parameters: {
|
|
10
10
|
type: "object",
|
package/dist/tools/write-file.js
CHANGED
|
@@ -71,9 +71,7 @@ export const writeFileTool = {
|
|
|
71
71
|
oldContent = readFileSync(resolved, "utf-8");
|
|
72
72
|
}
|
|
73
73
|
writeFileSync(resolved, content, "utf-8");
|
|
74
|
-
const diff = fileExists
|
|
75
|
-
? generateDiff(oldContent, content)
|
|
76
|
-
: generateNewFileDiff(content);
|
|
74
|
+
const diff = fileExists ? generateDiff(oldContent, content) : generateNewFileDiff(content);
|
|
77
75
|
// Increment file operations counter
|
|
78
76
|
ctx.fileOperationsCount = currentCount + 1;
|
|
79
77
|
// Log successful file write
|
package/dist/ui/box.js
CHANGED
|
@@ -65,11 +65,7 @@ export function box(lines, opts = {}) {
|
|
|
65
65
|
out.push(pc.dim(`┌${"─".repeat(width - 2)}┐`));
|
|
66
66
|
}
|
|
67
67
|
for (const line of wrapped) {
|
|
68
|
-
out.push(pc.dim("│") +
|
|
69
|
-
" ".repeat(pad) +
|
|
70
|
-
padTo(line, inner) +
|
|
71
|
-
" ".repeat(pad) +
|
|
72
|
-
pc.dim("│"));
|
|
68
|
+
out.push(pc.dim("│") + " ".repeat(pad) + padTo(line, inner) + " ".repeat(pad) + pc.dim("│"));
|
|
73
69
|
}
|
|
74
70
|
out.push(pc.dim(`└${"─".repeat(width - 2)}┘`));
|
|
75
71
|
return out;
|
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { formatMarkdown, formatError, formatSuccess, formatWarning, FormattingStream } from
|
|
2
|
-
export { writeOutput, writeError, writeSuccess, writeWarning } from
|
|
3
|
-
export { formatTable, splitRow, isSeparatorRow, getTerminalWidth } from
|
|
4
|
-
export { box, divider, wrapText } from
|
|
5
|
-
export { Spinner, isSpinnerSupported } from
|
|
6
|
-
export { Renderer, isRichTerminal, summarizeArgs } from
|
|
1
|
+
export { formatMarkdown, formatError, formatSuccess, formatWarning, FormattingStream, } from "./md-formatter";
|
|
2
|
+
export { writeOutput, writeError, writeSuccess, writeWarning } from "./output";
|
|
3
|
+
export { formatTable, splitRow, isSeparatorRow, getTerminalWidth } from "./table";
|
|
4
|
+
export { box, divider, wrapText } from "./box";
|
|
5
|
+
export { Spinner, isSpinnerSupported } from "./spinner";
|
|
6
|
+
export { Renderer, isRichTerminal, summarizeArgs } from "./renderer";
|