micro-models-agent 0.29.2 → 0.30.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 +195 -6
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2263,7 +2263,13 @@ var init_defaults = __esm(() => {
|
|
|
2263
2263
|
stableSystemPrompt: true,
|
|
2264
2264
|
maxParallelChunkQueries: 4
|
|
2265
2265
|
},
|
|
2266
|
-
lsp: DEFAULT_LSP_CONFIG
|
|
2266
|
+
lsp: DEFAULT_LSP_CONFIG,
|
|
2267
|
+
updater: {
|
|
2268
|
+
enabled: true,
|
|
2269
|
+
checkOnStart: true,
|
|
2270
|
+
autoInstall: true,
|
|
2271
|
+
intervalMs: 0
|
|
2272
|
+
}
|
|
2267
2273
|
};
|
|
2268
2274
|
});
|
|
2269
2275
|
|
|
@@ -2832,8 +2838,13 @@ Use this knowledge to answer the user's question.`,
|
|
|
2832
2838
|
"ctx.compactions": "compactions: {count}",
|
|
2833
2839
|
"ctx.quality": "quality: {percent}%",
|
|
2834
2840
|
"ctx.delta_pos": "ctx +{tokens}",
|
|
2835
|
-
"ctx.delta_neg": "ctx -{tokens}
|
|
2836
|
-
"ctx.delta_zero": "ctx
|
|
2841
|
+
"ctx.delta_neg": "ctx -{tokens} ",
|
|
2842
|
+
"ctx.delta_zero": "ctx +0",
|
|
2843
|
+
"updater.check_error": "[updater] update check failed: {error}",
|
|
2844
|
+
"updater.available": "[updater] Update available: {current} → {latest}. Run `npm install -g micro-models-agent` to upgrade.",
|
|
2845
|
+
"updater.installing": "[updater] Installing {latest} globally (current: {current})…",
|
|
2846
|
+
"updater.installed": "[updater] Installed {latest}. Restart MMA to use it (was {current}).",
|
|
2847
|
+
"updater.install_failed": "[updater] Failed to install {latest}: {error}. Update manually with `npm install -g micro-models-agent`."
|
|
2837
2848
|
};
|
|
2838
2849
|
});
|
|
2839
2850
|
|
|
@@ -3403,7 +3414,12 @@ var init_ru = __esm(() => {
|
|
|
3403
3414
|
"ctx.delta_neg": "контекст -{tokens} ↓",
|
|
3404
3415
|
"ctx.delta_zero": "контекст ±0",
|
|
3405
3416
|
"file.notfound_resolved": "Файл не найден: {path} (резолвится в {resolved})",
|
|
3406
|
-
"bash.echo_write_blocked": "Запись файлов через echo/printf ненадёжна в Windows cmd.exe (кавычки и многострочность ломаются). Используй инструмент write_file вместо этого (цель: {path})."
|
|
3417
|
+
"bash.echo_write_blocked": "Запись файлов через echo/printf ненадёжна в Windows cmd.exe (кавычки и многострочность ломаются). Используй инструмент write_file вместо этого (цель: {path}).",
|
|
3418
|
+
"updater.check_error": "[updater] Ошибка проверки обновления: {error}",
|
|
3419
|
+
"updater.available": "[updater] Доступно обновление: {current} → {latest}. Выполните `npm install -g micro-models-agent` для обновления.",
|
|
3420
|
+
"updater.installing": "[updater] Установка {latest} глобально (текущая: {current})…",
|
|
3421
|
+
"updater.installed": "[updater] Установлена {latest}. Перезапустите MMA для применения (была {current}).",
|
|
3422
|
+
"updater.install_failed": "[updater] Не удалось установить {latest}: {error}. Обновите вручную: `npm install -g micro-models-agent`."
|
|
3407
3423
|
};
|
|
3408
3424
|
});
|
|
3409
3425
|
|
|
@@ -29148,9 +29164,180 @@ init_setup();
|
|
|
29148
29164
|
init_config2();
|
|
29149
29165
|
init_i18n();
|
|
29150
29166
|
init_colors();
|
|
29151
|
-
import { existsSync as existsSync46 } from "fs";
|
|
29152
|
-
import { join as join40 } from "path";
|
|
29167
|
+
import { existsSync as existsSync46, readFileSync as readFileSync32 } from "fs";
|
|
29168
|
+
import { join as join40, dirname as dirname13 } from "path";
|
|
29153
29169
|
import { homedir as homedir18 } from "os";
|
|
29170
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
29171
|
+
|
|
29172
|
+
// src/modules/updater/checker.ts
|
|
29173
|
+
var defaultRunner2 = async (command, args, options) => {
|
|
29174
|
+
const { execFile } = await import("child_process");
|
|
29175
|
+
return new Promise((resolve23) => {
|
|
29176
|
+
execFile(command, args, options, (err) => resolve23({ error: err?.message }));
|
|
29177
|
+
});
|
|
29178
|
+
};
|
|
29179
|
+
|
|
29180
|
+
class Updater {
|
|
29181
|
+
currentVersion;
|
|
29182
|
+
packageName;
|
|
29183
|
+
runner;
|
|
29184
|
+
constructor(currentVersion, packageName, runner) {
|
|
29185
|
+
this.currentVersion = currentVersion;
|
|
29186
|
+
this.packageName = packageName;
|
|
29187
|
+
this.runner = runner ?? defaultRunner2;
|
|
29188
|
+
}
|
|
29189
|
+
getCurrentVersion() {
|
|
29190
|
+
return this.currentVersion;
|
|
29191
|
+
}
|
|
29192
|
+
getPackageName() {
|
|
29193
|
+
return this.packageName;
|
|
29194
|
+
}
|
|
29195
|
+
async check() {
|
|
29196
|
+
try {
|
|
29197
|
+
const response = await fetch(`https://registry.npmjs.org/${this.packageName}`, {
|
|
29198
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" },
|
|
29199
|
+
signal: AbortSignal.timeout(5000)
|
|
29200
|
+
});
|
|
29201
|
+
if (!response.ok) {
|
|
29202
|
+
return { updateAvailable: false, current: this.currentVersion, error: `HTTP ${response.status}` };
|
|
29203
|
+
}
|
|
29204
|
+
const data = await response.json();
|
|
29205
|
+
const latest = data["dist-tags"]?.latest;
|
|
29206
|
+
if (!latest) {
|
|
29207
|
+
return { updateAvailable: false, current: this.currentVersion, error: "No latest tag" };
|
|
29208
|
+
}
|
|
29209
|
+
const updateAvailable = latest !== this.currentVersion;
|
|
29210
|
+
return { updateAvailable, current: this.currentVersion, latest };
|
|
29211
|
+
} catch (e) {
|
|
29212
|
+
return { updateAvailable: false, current: this.currentVersion, error: e.message };
|
|
29213
|
+
}
|
|
29214
|
+
}
|
|
29215
|
+
async install(latest) {
|
|
29216
|
+
try {
|
|
29217
|
+
const res = await this.runner("npm", ["install", "-g", `${this.packageName}@${latest}`], {
|
|
29218
|
+
timeout: 120000,
|
|
29219
|
+
windowsHide: true
|
|
29220
|
+
});
|
|
29221
|
+
if (res.error)
|
|
29222
|
+
return { success: false, error: res.error };
|
|
29223
|
+
return { success: true, installed: latest };
|
|
29224
|
+
} catch (e) {
|
|
29225
|
+
const msg = e?.message ?? String(e);
|
|
29226
|
+
return { success: false, error: msg.split(`
|
|
29227
|
+
`)[0] };
|
|
29228
|
+
}
|
|
29229
|
+
}
|
|
29230
|
+
}
|
|
29231
|
+
// src/modules/updater/module.ts
|
|
29232
|
+
init_i18n();
|
|
29233
|
+
init_colors();
|
|
29234
|
+
|
|
29235
|
+
class UpdaterModule {
|
|
29236
|
+
name = "updater";
|
|
29237
|
+
updater;
|
|
29238
|
+
config;
|
|
29239
|
+
logger;
|
|
29240
|
+
started = false;
|
|
29241
|
+
timer = null;
|
|
29242
|
+
installEnabled = true;
|
|
29243
|
+
constructor(config, currentVersion, packageName, logger, installRunner) {
|
|
29244
|
+
this.config = config;
|
|
29245
|
+
this.updater = new Updater(currentVersion, packageName, installRunner);
|
|
29246
|
+
this.logger = logger ?? {
|
|
29247
|
+
info: () => {},
|
|
29248
|
+
warn: (m) => console.warn(pc2.yellow(m)),
|
|
29249
|
+
error: (m) => console.error(pc2.red(m))
|
|
29250
|
+
};
|
|
29251
|
+
}
|
|
29252
|
+
setInstallEnabled(enabled2) {
|
|
29253
|
+
this.installEnabled = enabled2;
|
|
29254
|
+
}
|
|
29255
|
+
getUpdater() {
|
|
29256
|
+
return this.updater;
|
|
29257
|
+
}
|
|
29258
|
+
isStarted() {
|
|
29259
|
+
return this.started;
|
|
29260
|
+
}
|
|
29261
|
+
start() {
|
|
29262
|
+
if (this.started || !this.config.enabled)
|
|
29263
|
+
return;
|
|
29264
|
+
this.started = true;
|
|
29265
|
+
this.runLoop();
|
|
29266
|
+
}
|
|
29267
|
+
stop() {
|
|
29268
|
+
this.started = false;
|
|
29269
|
+
if (this.timer) {
|
|
29270
|
+
clearTimeout(this.timer);
|
|
29271
|
+
this.timer = null;
|
|
29272
|
+
}
|
|
29273
|
+
}
|
|
29274
|
+
async runLoop() {
|
|
29275
|
+
while (this.started) {
|
|
29276
|
+
await this.checkOnce();
|
|
29277
|
+
if (!this.started)
|
|
29278
|
+
return;
|
|
29279
|
+
if (this.config.intervalMs > 0) {
|
|
29280
|
+
await new Promise((r) => this.timer = setTimeout(r, this.config.intervalMs));
|
|
29281
|
+
} else {
|
|
29282
|
+
this.started = false;
|
|
29283
|
+
}
|
|
29284
|
+
}
|
|
29285
|
+
}
|
|
29286
|
+
async runOnce() {
|
|
29287
|
+
const result = await this.updater.check();
|
|
29288
|
+
if (result.error) {
|
|
29289
|
+
this.logger.info(t("updater.check_error", { error: result.error }));
|
|
29290
|
+
return;
|
|
29291
|
+
}
|
|
29292
|
+
if (!result.updateAvailable || !result.latest)
|
|
29293
|
+
return;
|
|
29294
|
+
if (this.config.autoInstall && this.installEnabled) {
|
|
29295
|
+
this.logger.info(t("updater.installing", {
|
|
29296
|
+
current: result.current,
|
|
29297
|
+
latest: result.latest
|
|
29298
|
+
}));
|
|
29299
|
+
const install = await this.updater.install(result.latest);
|
|
29300
|
+
if (install.success) {
|
|
29301
|
+
this.logger.info(t("updater.installed", { current: result.current, latest: result.latest }));
|
|
29302
|
+
} else {
|
|
29303
|
+
this.logger.warn(t("updater.install_failed", {
|
|
29304
|
+
current: result.current,
|
|
29305
|
+
latest: result.latest,
|
|
29306
|
+
error: install.error ?? ""
|
|
29307
|
+
}));
|
|
29308
|
+
}
|
|
29309
|
+
} else {
|
|
29310
|
+
this.logger.info(t("updater.available", { current: result.current, latest: result.latest }));
|
|
29311
|
+
}
|
|
29312
|
+
}
|
|
29313
|
+
async checkOnce() {
|
|
29314
|
+
await this.runOnce();
|
|
29315
|
+
}
|
|
29316
|
+
}
|
|
29317
|
+
// src/cli/main.ts
|
|
29318
|
+
function readVersion5() {
|
|
29319
|
+
const here = dirname13(fileURLToPath5(import.meta.url));
|
|
29320
|
+
const candidates = [
|
|
29321
|
+
join40(here, "..", "..", "package.json"),
|
|
29322
|
+
join40(here, "..", "package.json")
|
|
29323
|
+
];
|
|
29324
|
+
for (const p of candidates) {
|
|
29325
|
+
if (existsSync46(p)) {
|
|
29326
|
+
try {
|
|
29327
|
+
const raw = JSON.parse(readFileSync32(p, "utf8"));
|
|
29328
|
+
if (raw.version)
|
|
29329
|
+
return raw.version;
|
|
29330
|
+
} catch {}
|
|
29331
|
+
}
|
|
29332
|
+
}
|
|
29333
|
+
return "0.0.0";
|
|
29334
|
+
}
|
|
29335
|
+
function startAutoUpdate(config) {
|
|
29336
|
+
try {
|
|
29337
|
+
const module = new UpdaterModule(config.updater, readVersion5(), "micro-models-agent");
|
|
29338
|
+
module.start();
|
|
29339
|
+
} catch {}
|
|
29340
|
+
}
|
|
29154
29341
|
async function main() {
|
|
29155
29342
|
const program2 = createProgram();
|
|
29156
29343
|
program2.parse(process.argv);
|
|
@@ -29167,6 +29354,7 @@ async function main() {
|
|
|
29167
29354
|
if (program2.args.length > 0) {
|
|
29168
29355
|
const prompt = program2.args.join(" ");
|
|
29169
29356
|
const { agent, config } = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
|
|
29357
|
+
startAutoUpdate(config);
|
|
29170
29358
|
if (jsonMode) {
|
|
29171
29359
|
const result2 = await agent.run(prompt);
|
|
29172
29360
|
agent.shutdown();
|
|
@@ -29276,6 +29464,7 @@ async function main() {
|
|
|
29276
29464
|
baseDir,
|
|
29277
29465
|
logger
|
|
29278
29466
|
} = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
|
|
29467
|
+
startAutoUpdate(config);
|
|
29279
29468
|
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger);
|
|
29280
29469
|
repl.start();
|
|
29281
29470
|
}
|