micro-models-agent 0.48.3 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +35 -68
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -19139,6 +19139,9 @@ class ExecutionModule {
|
|
|
19139
19139
|
getTracker() {
|
|
19140
19140
|
return this.tracker;
|
|
19141
19141
|
}
|
|
19142
|
+
getActivePlan() {
|
|
19143
|
+
return this.tracker?.getPlan() ?? null;
|
|
19144
|
+
}
|
|
19142
19145
|
getStore() {
|
|
19143
19146
|
return this.store;
|
|
19144
19147
|
}
|
|
@@ -22533,6 +22536,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
22533
22536
|
sessionManager,
|
|
22534
22537
|
skillsModule,
|
|
22535
22538
|
pluginManager,
|
|
22539
|
+
execModule,
|
|
22536
22540
|
toolCtx,
|
|
22537
22541
|
configDir: dir,
|
|
22538
22542
|
baseDir,
|
|
@@ -33368,8 +33372,8 @@ class LineEditor {
|
|
|
33368
33372
|
}
|
|
33369
33373
|
|
|
33370
33374
|
// src/cli/repl.ts
|
|
33371
|
-
import { existsSync as
|
|
33372
|
-
import { join as
|
|
33375
|
+
import { existsSync as existsSync52, readFileSync as readFileSync34, writeFileSync as writeFileSync17 } from "fs";
|
|
33376
|
+
import { join as join48 } from "path";
|
|
33373
33377
|
import { homedir as homedir18 } from "os";
|
|
33374
33378
|
|
|
33375
33379
|
// src/cli/completer.ts
|
|
@@ -33981,31 +33985,6 @@ init_session_logger();
|
|
|
33981
33985
|
init_colors();
|
|
33982
33986
|
init_js_identifiers();
|
|
33983
33987
|
init_i18n();
|
|
33984
|
-
import { existsSync as existsSync52, readFileSync as readFileSync34 } from "fs";
|
|
33985
|
-
import { join as join48 } from "path";
|
|
33986
|
-
function readActivePlan(baseDir) {
|
|
33987
|
-
const p = join48(baseDir, ".mma", "plans", "active.json");
|
|
33988
|
-
if (!existsSync52(p))
|
|
33989
|
-
return null;
|
|
33990
|
-
try {
|
|
33991
|
-
const raw = readFileSync34(p, "utf-8");
|
|
33992
|
-
if (!raw.trim())
|
|
33993
|
-
return null;
|
|
33994
|
-
const parsed = JSON.parse(raw);
|
|
33995
|
-
if (!parsed || !Array.isArray(parsed.steps))
|
|
33996
|
-
return null;
|
|
33997
|
-
return {
|
|
33998
|
-
id: parsed.id || "plan",
|
|
33999
|
-
title: parsed.title || "Plan",
|
|
34000
|
-
steps: parsed.steps,
|
|
34001
|
-
createdAt: parsed.createdAt || new Date().toISOString(),
|
|
34002
|
-
baseDir: parsed.baseDir || baseDir,
|
|
34003
|
-
name: parsed.name
|
|
34004
|
-
};
|
|
34005
|
-
} catch {
|
|
34006
|
-
return null;
|
|
34007
|
-
}
|
|
34008
|
-
}
|
|
34009
33988
|
function currentStepIndex(plan) {
|
|
34010
33989
|
const idx = plan.steps.findIndex((s) => s.status !== "done" && s.status !== "skipped");
|
|
34011
33990
|
return idx === -1 ? 0 : idx;
|
|
@@ -34114,8 +34093,7 @@ class Repl {
|
|
|
34114
34093
|
noAgentsMd;
|
|
34115
34094
|
pendingClipboardImage = null;
|
|
34116
34095
|
exitOnClose = false;
|
|
34117
|
-
|
|
34118
|
-
lastPlanSig = null;
|
|
34096
|
+
execModule;
|
|
34119
34097
|
rl;
|
|
34120
34098
|
agent;
|
|
34121
34099
|
config;
|
|
@@ -34125,7 +34103,7 @@ class Repl {
|
|
|
34125
34103
|
logger;
|
|
34126
34104
|
slog;
|
|
34127
34105
|
envReport;
|
|
34128
|
-
constructor(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, exitOnClose, envReport, historyPath) {
|
|
34106
|
+
constructor(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, exitOnClose, envReport, historyPath, execModule) {
|
|
34129
34107
|
this.agent = agent;
|
|
34130
34108
|
this.config = config;
|
|
34131
34109
|
this.exitOnClose = exitOnClose === true;
|
|
@@ -34134,11 +34112,12 @@ class Repl {
|
|
|
34134
34112
|
this.pluginManager = pluginManager;
|
|
34135
34113
|
this.logger = logger;
|
|
34136
34114
|
this.envReport = envReport;
|
|
34115
|
+
this.execModule = execModule;
|
|
34137
34116
|
this.slog = new SessionLogger(sessionManager, logger);
|
|
34138
|
-
this.configDir = configDir ||
|
|
34117
|
+
this.configDir = configDir || join48(homedir18(), ".mma");
|
|
34139
34118
|
this.baseDir = baseDir || process.cwd();
|
|
34140
34119
|
this.noAgentsMd = noAgentsMd === true;
|
|
34141
|
-
this.historyPath = historyPath ??
|
|
34120
|
+
this.historyPath = historyPath ?? join48(homedir18(), ".mma", "repl-history");
|
|
34142
34121
|
this.loadHistory();
|
|
34143
34122
|
this.rl = process.stdin.isTTY ? new LineEditor({
|
|
34144
34123
|
input: process.stdin,
|
|
@@ -34171,9 +34150,9 @@ class Repl {
|
|
|
34171
34150
|
this.setupListeners();
|
|
34172
34151
|
}
|
|
34173
34152
|
loadHistory() {
|
|
34174
|
-
if (
|
|
34153
|
+
if (existsSync52(this.historyPath)) {
|
|
34175
34154
|
try {
|
|
34176
|
-
const raw =
|
|
34155
|
+
const raw = readFileSync34(this.historyPath, "utf-8");
|
|
34177
34156
|
this.history = raw.split(`
|
|
34178
34157
|
`).filter(Boolean).slice(-this.maxHistory);
|
|
34179
34158
|
} catch {
|
|
@@ -34375,14 +34354,13 @@ ${t("image.clipboard_empty")}`));
|
|
|
34375
34354
|
spinner: this.config.ui?.spinner ?? true,
|
|
34376
34355
|
toolStyle: this.config.ui?.toolStyle ?? "inline"
|
|
34377
34356
|
});
|
|
34378
|
-
this.refreshActivePlan(renderer);
|
|
34379
34357
|
const result = await this.agent.run(input, (c) => renderer.text(c), (m) => renderer.meta(m), (ev) => {
|
|
34380
34358
|
if (ev.type === "start") {
|
|
34381
|
-
renderer.toolStart(ev.tool, ev.args, stepContextForTool(this.
|
|
34359
|
+
renderer.toolStart(ev.tool, ev.args, stepContextForTool(this.execModule?.getActivePlan() ?? null, ev.tool, ev.args), ev.icon);
|
|
34382
34360
|
} else {
|
|
34383
34361
|
renderer.toolEnd(ev.tool, ev.duration ?? 0, ev.error, ev.ctxDelta, ev.costUsd);
|
|
34384
34362
|
if (ev.tool === "plan" || ev.tool === "todo") {
|
|
34385
|
-
this.
|
|
34363
|
+
this.renderPlan(renderer);
|
|
34386
34364
|
}
|
|
34387
34365
|
}
|
|
34388
34366
|
}, (phase) => {
|
|
@@ -34407,23 +34385,11 @@ ${t("image.clipboard_empty")}`));
|
|
|
34407
34385
|
this.agentRunning = false;
|
|
34408
34386
|
}
|
|
34409
34387
|
}
|
|
34410
|
-
|
|
34411
|
-
const plan =
|
|
34412
|
-
|
|
34413
|
-
if (!plan) {
|
|
34414
|
-
this.activePlan = null;
|
|
34415
|
-
this.lastPlanSig = "";
|
|
34416
|
-
return;
|
|
34417
|
-
}
|
|
34418
|
-
this.activePlan = plan;
|
|
34419
|
-
if (this.lastPlanSig === null) {
|
|
34420
|
-
this.lastPlanSig = sig;
|
|
34388
|
+
renderPlan(renderer) {
|
|
34389
|
+
const plan = this.execModule?.getActivePlan();
|
|
34390
|
+
if (!plan)
|
|
34421
34391
|
return;
|
|
34422
|
-
|
|
34423
|
-
if (sig !== this.lastPlanSig) {
|
|
34424
|
-
this.lastPlanSig = sig;
|
|
34425
|
-
renderer.planBlock(formatPlanChecklist(plan));
|
|
34426
|
-
}
|
|
34392
|
+
renderer.planBlock(formatPlanChecklist(plan));
|
|
34427
34393
|
}
|
|
34428
34394
|
commands = new Map;
|
|
34429
34395
|
registerCommand(cmd) {
|
|
@@ -34556,11 +34522,11 @@ ${t("image.clipboard_empty")}`));
|
|
|
34556
34522
|
row(t("repl.agents_label"), pc2.red(t("repl.disabled")));
|
|
34557
34523
|
} else {
|
|
34558
34524
|
const agentsMdCandidates = [
|
|
34559
|
-
|
|
34560
|
-
|
|
34561
|
-
|
|
34525
|
+
join48(this.baseDir, "AGENTS.md"),
|
|
34526
|
+
join48(this.baseDir, ".mma", "AGENTS.md"),
|
|
34527
|
+
join48(this.configDir, "AGENTS.md")
|
|
34562
34528
|
];
|
|
34563
|
-
const foundAgents = agentsMdCandidates.filter((p) =>
|
|
34529
|
+
const foundAgents = agentsMdCandidates.filter((p) => existsSync52(p));
|
|
34564
34530
|
if (foundAgents.length > 0) {
|
|
34565
34531
|
for (const p of foundAgents) {
|
|
34566
34532
|
row(t("repl.agents_label"), pc2.dim(p));
|
|
@@ -34571,7 +34537,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
34571
34537
|
}
|
|
34572
34538
|
const meta = this.sessionManager?.getActiveMeta();
|
|
34573
34539
|
if (meta) {
|
|
34574
|
-
const sessionPath =
|
|
34540
|
+
const sessionPath = join48(this.configDir, "sessions", meta.id);
|
|
34575
34541
|
row(t("repl.session_label"), `${pc2.cyan(meta.name)} ${pc2.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc2.dim(sessionPath)}`);
|
|
34576
34542
|
}
|
|
34577
34543
|
const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
|
|
@@ -34670,8 +34636,8 @@ init_setup();
|
|
|
34670
34636
|
init_config2();
|
|
34671
34637
|
init_i18n();
|
|
34672
34638
|
init_colors();
|
|
34673
|
-
import { existsSync as
|
|
34674
|
-
import { join as
|
|
34639
|
+
import { existsSync as existsSync53 } from "fs";
|
|
34640
|
+
import { join as join50 } from "path";
|
|
34675
34641
|
import { homedir as homedir20 } from "os";
|
|
34676
34642
|
|
|
34677
34643
|
// src/modules/updater/index.ts
|
|
@@ -34776,9 +34742,9 @@ init_environment();
|
|
|
34776
34742
|
init_data_sanitizer();
|
|
34777
34743
|
init_i18n();
|
|
34778
34744
|
import { appendFileSync as appendFileSync7, mkdirSync as mkdirSync20 } from "fs";
|
|
34779
|
-
import { join as
|
|
34745
|
+
import { join as join49 } from "path";
|
|
34780
34746
|
import { homedir as homedir19 } from "os";
|
|
34781
|
-
var CRASH_LOG_DIR =
|
|
34747
|
+
var CRASH_LOG_DIR = join49(homedir19(), ".mma", "logs");
|
|
34782
34748
|
var CRASH_LOG_FILE = "crash.jsonl";
|
|
34783
34749
|
function formatCrashEntry(type2, err) {
|
|
34784
34750
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -34794,7 +34760,7 @@ function formatCrashEntry(type2, err) {
|
|
|
34794
34760
|
function writeCrashEntry(dir, entry) {
|
|
34795
34761
|
try {
|
|
34796
34762
|
mkdirSync20(dir, { recursive: true });
|
|
34797
|
-
appendFileSync7(
|
|
34763
|
+
appendFileSync7(join49(dir, CRASH_LOG_FILE), JSON.stringify(entry) + `
|
|
34798
34764
|
`, "utf-8");
|
|
34799
34765
|
} catch {}
|
|
34800
34766
|
}
|
|
@@ -34897,15 +34863,15 @@ async function main() {
|
|
|
34897
34863
|
await updater?.waitForIdle();
|
|
34898
34864
|
process.exit(exitCode);
|
|
34899
34865
|
} else {
|
|
34900
|
-
const configPath =
|
|
34901
|
-
if (!
|
|
34866
|
+
const configPath = join50(homedir20(), ".mma", "config.json");
|
|
34867
|
+
if (!existsSync53(configPath)) {
|
|
34902
34868
|
console.log(pc2.yellow(`
|
|
34903
34869
|
` + t("cli.first_run") + `
|
|
34904
34870
|
`));
|
|
34905
34871
|
const answers = await runSetup();
|
|
34906
34872
|
const config2 = loadConfig({
|
|
34907
|
-
configDir:
|
|
34908
|
-
projectConfigPath: projectDir ?
|
|
34873
|
+
configDir: join50(homedir20(), ".mma"),
|
|
34874
|
+
projectConfigPath: projectDir ? join50(projectDir, ".mmrc") : join50(process.cwd(), ".mmrc")
|
|
34909
34875
|
});
|
|
34910
34876
|
config2.provider.type = answers.provider;
|
|
34911
34877
|
config2.provider.baseUrl = answers.apiBase;
|
|
@@ -34953,13 +34919,14 @@ async function main() {
|
|
|
34953
34919
|
sessionManager,
|
|
34954
34920
|
skillsModule,
|
|
34955
34921
|
pluginManager,
|
|
34922
|
+
execModule,
|
|
34956
34923
|
configDir,
|
|
34957
34924
|
baseDir,
|
|
34958
34925
|
logger,
|
|
34959
34926
|
envReport
|
|
34960
34927
|
} = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
|
|
34961
34928
|
startAutoUpdate(config);
|
|
34962
|
-
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true, envReport);
|
|
34929
|
+
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true, envReport, undefined, execModule);
|
|
34963
34930
|
await repl.start();
|
|
34964
34931
|
}
|
|
34965
34932
|
}
|