micro-models-agent 0.31.0 → 0.32.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 CHANGED
@@ -2225,7 +2225,8 @@ var init_defaults = __esm(() => {
2225
2225
  headless: true,
2226
2226
  maxElements: 30,
2227
2227
  maxContentChars: 2500,
2228
- maxConsoleEntries: 20,
2228
+ maxConsoleEntries: 40,
2229
+ maxConsoleLineChars: 400,
2229
2230
  viewportWidth: 1280,
2230
2231
  viewportHeight: 720,
2231
2232
  navigationTimeout: 15000
@@ -13670,6 +13671,306 @@ var init_recall = __esm(() => {
13670
13671
  };
13671
13672
  });
13672
13673
 
13674
+ // src/modules/browser/bridge-client.ts
13675
+ var exports_bridge_client = {};
13676
+ __export(exports_bridge_client, {
13677
+ BridgeDriver: () => BridgeDriver
13678
+ });
13679
+ import { spawn as spawn4 } from "child_process";
13680
+ import { createInterface } from "readline";
13681
+ import { dirname as dirname6, join as join17 } from "path";
13682
+ import { fileURLToPath } from "url";
13683
+ function bridgeScriptPath() {
13684
+ return join17(dirname6(fileURLToPath(import.meta.url)), "bridge-server.mjs");
13685
+ }
13686
+
13687
+ class BridgeDriver {
13688
+ proc = null;
13689
+ rl = null;
13690
+ pending = new Map;
13691
+ nextId = 1;
13692
+ lastUrl = "";
13693
+ console = new ConsoleBuffer(500);
13694
+ network = [];
13695
+ maxConsoleLineChars;
13696
+ constructor(opts = {}) {
13697
+ this.maxConsoleLineChars = opts.maxConsoleLineChars ?? 400;
13698
+ }
13699
+ async send(cmd, params = {}) {
13700
+ if (!this.proc || !this.rl)
13701
+ throw new Error("Bridge is not running");
13702
+ const id = this.nextId++;
13703
+ const response = await new Promise((resolve15, reject) => {
13704
+ const timer = setTimeout(() => {
13705
+ this.pending.delete(id);
13706
+ reject(new Error(`Bridge timeout waiting for "${cmd}"`));
13707
+ }, BRIDGE_REQUEST_TIMEOUT_MS);
13708
+ this.pending.set(id, (resp) => {
13709
+ clearTimeout(timer);
13710
+ resolve15(resp);
13711
+ });
13712
+ this.proc.stdin.write(JSON.stringify({ id, cmd, params }) + `
13713
+ `);
13714
+ });
13715
+ this.drainEvents(response);
13716
+ if (!response.ok)
13717
+ throw new Error(response.error || `Bridge command failed: ${cmd}`);
13718
+ return response;
13719
+ }
13720
+ drainEvents(resp) {
13721
+ if (Array.isArray(resp.console)) {
13722
+ for (const entry of resp.console) {
13723
+ this.console.add(entry.type, entry.text);
13724
+ }
13725
+ }
13726
+ if (Array.isArray(resp.network)) {
13727
+ for (const err of resp.network)
13728
+ this.network.push(err);
13729
+ }
13730
+ if (resp.data && typeof resp.data.url === "string") {
13731
+ this.lastUrl = resp.data.url;
13732
+ }
13733
+ }
13734
+ async launch(cfg) {
13735
+ this.spawnBridge();
13736
+ await this.send("launch", {
13737
+ headless: cfg.headless,
13738
+ viewport: cfg.viewport,
13739
+ timeoutMs: cfg.timeoutMs,
13740
+ maxConsoleLineChars: this.maxConsoleLineChars
13741
+ });
13742
+ }
13743
+ spawnBridge() {
13744
+ const script = bridgeScriptPath();
13745
+ const proc = spawn4("node", [script], { stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
13746
+ this.proc = proc;
13747
+ proc.stderr.on("data", () => {});
13748
+ const rl = createInterface({ input: proc.stdout });
13749
+ this.rl = rl;
13750
+ rl.on("line", (line) => {
13751
+ let resp;
13752
+ try {
13753
+ resp = JSON.parse(line);
13754
+ } catch {
13755
+ return;
13756
+ }
13757
+ const resolver = this.pending.get(resp.id);
13758
+ if (resolver) {
13759
+ this.pending.delete(resp.id);
13760
+ resolver(resp);
13761
+ }
13762
+ });
13763
+ proc.on("exit", () => {
13764
+ for (const [, resolver] of this.pending) {
13765
+ resolver({ id: -1, ok: false, error: "Bridge process exited" });
13766
+ }
13767
+ this.pending.clear();
13768
+ this.proc = null;
13769
+ this.rl = null;
13770
+ });
13771
+ }
13772
+ async goto(url, timeoutMs) {
13773
+ await this.send("goto", { url, timeoutMs });
13774
+ }
13775
+ async evaluate(js) {
13776
+ const resp = await this.send("evaluate", { js });
13777
+ return resp.data?.result;
13778
+ }
13779
+ async content() {
13780
+ const resp = await this.send("content");
13781
+ return String(resp.data?.html ?? "");
13782
+ }
13783
+ async title() {
13784
+ const resp = await this.send("title");
13785
+ return String(resp.data?.title ?? "");
13786
+ }
13787
+ url() {
13788
+ return this.lastUrl;
13789
+ }
13790
+ async waitForLoad(timeoutMs) {
13791
+ await this.send("waitLoad", { timeoutMs });
13792
+ }
13793
+ async screenshot() {
13794
+ const resp = await this.send("screenshot");
13795
+ return Buffer.from(String(resp.data?.base64 ?? ""), "base64");
13796
+ }
13797
+ async cookies() {
13798
+ const resp = await this.send("cookies");
13799
+ return resp.data?.cookies ?? [];
13800
+ }
13801
+ async addCookies(cookies) {
13802
+ await this.send("setCookies", { cookies });
13803
+ }
13804
+ async goBack(timeoutMs) {
13805
+ await this.send("back", { timeoutMs });
13806
+ }
13807
+ async goForward(timeoutMs) {
13808
+ await this.send("forward", { timeoutMs });
13809
+ }
13810
+ resetEventLog() {
13811
+ this.console.clear();
13812
+ this.network = [];
13813
+ }
13814
+ getConsole() {
13815
+ return this.console.getAll();
13816
+ }
13817
+ getNetworkErrors() {
13818
+ return this.network.slice(-15);
13819
+ }
13820
+ async close() {
13821
+ try {
13822
+ if (this.proc)
13823
+ await this.send("close");
13824
+ } catch {}
13825
+ this.dispose();
13826
+ }
13827
+ dispose() {
13828
+ if (this.proc) {
13829
+ this.proc.kill();
13830
+ this.proc = null;
13831
+ }
13832
+ if (this.rl) {
13833
+ this.rl.close();
13834
+ this.rl = null;
13835
+ }
13836
+ }
13837
+ }
13838
+ var BRIDGE_REQUEST_TIMEOUT_MS = 30000;
13839
+ var init_bridge_client = __esm(() => {
13840
+ init_session();
13841
+ });
13842
+
13843
+ // src/modules/browser/driver.ts
13844
+ import { chromium } from "playwright";
13845
+
13846
+ class PlaywrightDriver {
13847
+ browser = null;
13848
+ context = null;
13849
+ page = null;
13850
+ console = new ConsoleBuffer;
13851
+ network = [];
13852
+ async launch(cfg) {
13853
+ if (this.browser)
13854
+ return;
13855
+ this.browser = await chromium.launch({
13856
+ headless: cfg.headless,
13857
+ timeout: cfg.timeoutMs
13858
+ });
13859
+ this.context = await this.browser.newContext({ viewport: cfg.viewport });
13860
+ this.page = await this.context.newPage();
13861
+ this.page.setDefaultTimeout(cfg.timeoutMs);
13862
+ this.page.on("console", (msg) => this.console.add(msg.type(), msg.text()));
13863
+ this.page.on("pageerror", (err) => this.console.add("pageerror", `Page error: ${err.message}`));
13864
+ this.page.on("requestfailed", (req) => {
13865
+ const failure = req.failure();
13866
+ this.network.push({
13867
+ method: req.method(),
13868
+ url: req.url(),
13869
+ error: failure?.errorText || "unknown"
13870
+ });
13871
+ });
13872
+ }
13873
+ async goto(url, timeoutMs) {
13874
+ this.requirePage();
13875
+ this.console.clear();
13876
+ this.network = [];
13877
+ await this.page.goto(url, { waitUntil: "domcontentloaded", timeout: timeoutMs });
13878
+ }
13879
+ async evaluate(js) {
13880
+ return this.requirePage().evaluate(js);
13881
+ }
13882
+ async content() {
13883
+ return this.requirePage().content();
13884
+ }
13885
+ async title() {
13886
+ return this.requirePage().title();
13887
+ }
13888
+ url() {
13889
+ return this.page?.url() || "";
13890
+ }
13891
+ async waitForLoad(timeoutMs) {
13892
+ await this.requirePage().waitForLoadState("domcontentloaded", { timeout: timeoutMs }).catch(() => {});
13893
+ }
13894
+ async screenshot() {
13895
+ return this.requirePage().screenshot({ type: "png", fullPage: false });
13896
+ }
13897
+ async cookies() {
13898
+ if (!this.context)
13899
+ return [];
13900
+ return this.context.cookies();
13901
+ }
13902
+ async addCookies(cookies) {
13903
+ if (!this.context || cookies.length === 0)
13904
+ return;
13905
+ await this.context.addCookies(cookies);
13906
+ }
13907
+ async goBack(timeoutMs) {
13908
+ await this.requirePage().goBack({ waitUntil: "domcontentloaded", timeout: timeoutMs }).catch(() => {});
13909
+ }
13910
+ async goForward(timeoutMs) {
13911
+ await this.requirePage().goForward({ waitUntil: "domcontentloaded", timeout: timeoutMs }).catch(() => {});
13912
+ }
13913
+ resetEventLog() {
13914
+ this.console.clear();
13915
+ this.network = [];
13916
+ }
13917
+ getConsole() {
13918
+ return this.console.getAll();
13919
+ }
13920
+ getNetworkErrors() {
13921
+ return this.network.slice(-15);
13922
+ }
13923
+ async close() {
13924
+ if (this.page)
13925
+ await this.page.close().catch(() => {});
13926
+ if (this.context)
13927
+ await this.context.close().catch(() => {});
13928
+ if (this.browser)
13929
+ await this.browser.close().catch(() => {});
13930
+ this.page = null;
13931
+ this.context = null;
13932
+ this.browser = null;
13933
+ }
13934
+ dispose() {
13935
+ this.close().catch(() => {});
13936
+ }
13937
+ requirePage() {
13938
+ if (!this.page)
13939
+ throw new Error("No page open");
13940
+ return this.page;
13941
+ }
13942
+ }
13943
+ function createBrowserDriver(config) {
13944
+ const common = {
13945
+ headless: config.headless,
13946
+ viewport: { width: config.viewportWidth, height: config.viewportHeight },
13947
+ timeoutMs: config.navigationTimeout
13948
+ };
13949
+ return (async () => {
13950
+ if (process.versions.bun) {
13951
+ return launchBridge(config, common);
13952
+ }
13953
+ const direct = new PlaywrightDriver;
13954
+ try {
13955
+ await direct.launch({ ...common, timeoutMs: DIRECT_LAUNCH_TIMEOUT_MS });
13956
+ return direct;
13957
+ } catch {
13958
+ direct.dispose();
13959
+ }
13960
+ return launchBridge(config, common);
13961
+ })();
13962
+ }
13963
+ async function launchBridge(config, common) {
13964
+ const { BridgeDriver: BridgeDriver2 } = await Promise.resolve().then(() => (init_bridge_client(), exports_bridge_client));
13965
+ const bridge = new BridgeDriver2({ maxConsoleLineChars: config.maxConsoleLineChars });
13966
+ await bridge.launch(common);
13967
+ return bridge;
13968
+ }
13969
+ var DIRECT_LAUNCH_TIMEOUT_MS = 8000;
13970
+ var init_driver = __esm(() => {
13971
+ init_session();
13972
+ });
13973
+
13673
13974
  // src/modules/browser/types.ts
13674
13975
  var DEFAULT_BROWSER_CONFIG;
13675
13976
  var init_types = __esm(() => {
@@ -13677,7 +13978,8 @@ var init_types = __esm(() => {
13677
13978
  headless: true,
13678
13979
  maxElements: 30,
13679
13980
  maxContentChars: 2500,
13680
- maxConsoleEntries: 20,
13981
+ maxConsoleEntries: 40,
13982
+ maxConsoleLineChars: 400,
13681
13983
  screenshotMaxWidth: 1280,
13682
13984
  cookieDir: "",
13683
13985
  viewportWidth: 1280,
@@ -13915,15 +14217,15 @@ function buildTextExtractionScript() {
13915
14217
 
13916
14218
  // src/modules/browser/cookie-store.ts
13917
14219
  import { readFile, writeFile, mkdir } from "fs/promises";
13918
- import { join as join17 } from "path";
14220
+ import { join as join18 } from "path";
13919
14221
 
13920
14222
  class CookieStore {
13921
14223
  filePath;
13922
14224
  constructor(cookieDir) {
13923
- this.filePath = join17(cookieDir, "cookies.json");
14225
+ this.filePath = join18(cookieDir, "cookies.json");
13924
14226
  }
13925
14227
  async save(cookies) {
13926
- await mkdir(join17(this.filePath, ".."), { recursive: true });
14228
+ await mkdir(join18(this.filePath, ".."), { recursive: true });
13927
14229
  await writeFile(this.filePath, JSON.stringify(cookies, null, 2), "utf-8");
13928
14230
  }
13929
14231
  async load() {
@@ -13941,10 +14243,6 @@ class CookieStore {
13941
14243
  var init_cookie_store = () => {};
13942
14244
 
13943
14245
  // src/modules/browser/session.ts
13944
- import {
13945
- chromium
13946
- } from "playwright";
13947
-
13948
14246
  class ConsoleBuffer {
13949
14247
  entries = [];
13950
14248
  maxEntries;
@@ -13998,9 +14296,7 @@ class BrowserActionTracker {
13998
14296
  }
13999
14297
 
14000
14298
  class BrowserSession {
14001
- browser = null;
14002
- context = null;
14003
- page = null;
14299
+ driver = null;
14004
14300
  config;
14005
14301
  cookieStore;
14006
14302
  state = {
@@ -14010,12 +14306,9 @@ class BrowserSession {
14010
14306
  elementCount: 0
14011
14307
  };
14012
14308
  actionTracker = new BrowserActionTracker(3);
14013
- consoleBuffer;
14014
- networkErrors = [];
14015
14309
  constructor(config) {
14016
14310
  this.config = config;
14017
14311
  this.cookieStore = new CookieStore(config.cookieDir);
14018
- this.consoleBuffer = new ConsoleBuffer(config.maxConsoleEntries);
14019
14312
  }
14020
14313
  getState() {
14021
14314
  return { ...this.state };
@@ -14061,7 +14354,7 @@ class BrowserSession {
14061
14354
  };
14062
14355
  }
14063
14356
  if (action !== "open") {
14064
- const warning = this.actionTracker.record(action, args, this.page?.url() || "");
14357
+ const warning = this.actionTracker.record(action, args, this.driver?.url() || "");
14065
14358
  if (warning && result.success) {
14066
14359
  result.output = result.output + `
14067
14360
 
@@ -14076,62 +14369,37 @@ class BrowserSession {
14076
14369
  };
14077
14370
  }
14078
14371
  }
14079
- async ensurePage() {
14080
- if (!this.page) {
14372
+ async ensureDriver() {
14373
+ if (!this.driver) {
14081
14374
  return { success: false, output: t("browser.no_page") };
14082
14375
  }
14083
14376
  return null;
14084
14377
  }
14085
14378
  async launch() {
14086
- if (this.browser)
14379
+ if (this.driver)
14087
14380
  return;
14088
- this.browser = await chromium.launch({ headless: this.config.headless });
14089
- this.context = await this.browser.newContext({
14090
- viewport: {
14091
- width: this.config.viewportWidth,
14092
- height: this.config.viewportHeight
14093
- }
14094
- });
14381
+ this.driver = await createBrowserDriver(this.config);
14095
14382
  const savedCookies = await this.cookieStore.load();
14096
14383
  if (savedCookies.length > 0) {
14097
- await this.context.addCookies(savedCookies.map((c) => ({
14098
- ...c,
14099
- sameSite: c.sameSite
14100
- })));
14384
+ await this.driver.addCookies(savedCookies);
14101
14385
  }
14102
- this.page = await this.context.newPage();
14103
- this.page.setDefaultTimeout(this.config.navigationTimeout);
14104
- this.page.on("console", (msg) => {
14105
- this.consoleBuffer.add(msg.type(), msg.text());
14106
- });
14107
- this.page.on("pageerror", (err) => {
14108
- this.consoleBuffer.add("pageerror", `Page error: ${err.message}`);
14109
- });
14110
- this.page.on("requestfailed", (req) => {
14111
- const failure = req.failure();
14112
- this.networkErrors.push({
14113
- method: req.method(),
14114
- url: req.url(),
14115
- error: failure?.errorText || "unknown"
14116
- });
14117
- });
14118
14386
  }
14119
14387
  async saveCookies() {
14120
- if (!this.context)
14388
+ if (!this.driver)
14121
14389
  return;
14122
- const cookies = await this.context.cookies();
14390
+ const cookies = await this.driver.cookies();
14123
14391
  await this.cookieStore.save(cookies);
14124
14392
  }
14125
14393
  async takeSnapshot() {
14126
- if (!this.page)
14394
+ if (!this.driver)
14127
14395
  return "No page open.";
14128
- await this.page.evaluate(buildIndexInjectionScript());
14129
- const html = await this.page.content();
14130
- const url = this.page.url();
14131
- const title = await this.page.title();
14396
+ await this.driver.evaluate(buildIndexInjectionScript());
14397
+ const html = await this.driver.content();
14398
+ const url = this.driver.url();
14399
+ const title = await this.driver.title();
14132
14400
  let content = "";
14133
14401
  try {
14134
- content = await this.page.evaluate(buildTextExtractionScript());
14402
+ content = String(await this.driver.evaluate(buildTextExtractionScript()));
14135
14403
  } catch {
14136
14404
  content = "";
14137
14405
  }
@@ -14149,8 +14417,8 @@ class BrowserSession {
14149
14417
  title,
14150
14418
  elements,
14151
14419
  content,
14152
- console: this.consoleBuffer.getAll(),
14153
- networkErrors: this.networkErrors.slice(-5),
14420
+ console: this.driver.getConsole(),
14421
+ networkErrors: this.driver.getNetworkErrors(),
14154
14422
  truncated
14155
14423
  });
14156
14424
  }
@@ -14162,16 +14430,12 @@ class BrowserSession {
14162
14430
  url = isLocalhost ? "http://" + url : "https://" + url;
14163
14431
  }
14164
14432
  await this.launch();
14165
- if (!this.page)
14433
+ if (!this.driver)
14166
14434
  return { success: false, output: t("browser.create_page_failed") };
14167
14435
  this.actionTracker.reset();
14168
- this.consoleBuffer.clear();
14169
- this.networkErrors = [];
14436
+ this.driver.resetEventLog();
14170
14437
  try {
14171
- await this.page.goto(url, {
14172
- waitUntil: "domcontentloaded",
14173
- timeout: this.config.navigationTimeout
14174
- });
14438
+ await this.driver.goto(url, this.config.navigationTimeout);
14175
14439
  } catch (err) {
14176
14440
  return {
14177
14441
  success: false,
@@ -14183,18 +14447,17 @@ class BrowserSession {
14183
14447
  return { success: true, output: snapshot };
14184
14448
  }
14185
14449
  async click(target) {
14186
- const err = await this.ensurePage();
14450
+ const err = await this.ensureDriver();
14187
14451
  if (err)
14188
14452
  return err;
14189
- if (!this.page)
14453
+ if (!this.driver)
14190
14454
  return { success: false, output: "No page" };
14191
14455
  if (!target || target < 1) {
14192
14456
  return { success: false, output: t("browser.invalid_target") };
14193
14457
  }
14194
14458
  try {
14195
- const script = buildClickScript(target);
14196
- await this.page.evaluate(script);
14197
- await this.page.waitForLoadState("domcontentloaded", { timeout: 5000 }).catch(() => {});
14459
+ await this.driver.evaluate(buildClickScript(target));
14460
+ await this.driver.waitForLoad(5000);
14198
14461
  await new Promise((r) => setTimeout(r, 500));
14199
14462
  const snapshot = await this.takeSnapshot();
14200
14463
  await this.saveCookies();
@@ -14207,10 +14470,10 @@ class BrowserSession {
14207
14470
  }
14208
14471
  }
14209
14472
  async type(target, text) {
14210
- const err = await this.ensurePage();
14473
+ const err = await this.ensureDriver();
14211
14474
  if (err)
14212
14475
  return err;
14213
- if (!this.page)
14476
+ if (!this.driver)
14214
14477
  return { success: false, output: "No page" };
14215
14478
  if (!target || target < 1) {
14216
14479
  return { success: false, output: t("browser.invalid_target_short") };
@@ -14219,8 +14482,7 @@ class BrowserSession {
14219
14482
  return { success: false, output: t("browser.text_required") };
14220
14483
  }
14221
14484
  try {
14222
- const script = buildTypeScript(target, text);
14223
- await this.page.evaluate(script);
14485
+ await this.driver.evaluate(buildTypeScript(target, text));
14224
14486
  const snapshot = await this.takeSnapshot();
14225
14487
  return { success: true, output: snapshot };
14226
14488
  } catch (err2) {
@@ -14231,17 +14493,17 @@ class BrowserSession {
14231
14493
  }
14232
14494
  }
14233
14495
  async scroll(direction) {
14234
- const err = await this.ensurePage();
14496
+ const err = await this.ensureDriver();
14235
14497
  if (err)
14236
14498
  return err;
14237
- if (!this.page)
14499
+ if (!this.driver)
14238
14500
  return { success: false, output: "No page" };
14239
14501
  const dir = direction;
14240
14502
  if (!["up", "down", "top", "bottom"].includes(dir)) {
14241
14503
  return { success: false, output: t("browser.direction_invalid") };
14242
14504
  }
14243
14505
  try {
14244
- await this.page.evaluate(buildScrollScript(dir));
14506
+ await this.driver.evaluate(buildScrollScript(dir));
14245
14507
  await new Promise((r) => setTimeout(r, 300));
14246
14508
  const snapshot = await this.takeSnapshot();
14247
14509
  return { success: true, output: snapshot };
@@ -14253,52 +14515,46 @@ class BrowserSession {
14253
14515
  }
14254
14516
  }
14255
14517
  async back() {
14256
- const err = await this.ensurePage();
14518
+ const err = await this.ensureDriver();
14257
14519
  if (err)
14258
14520
  return err;
14259
- if (!this.page)
14521
+ if (!this.driver)
14260
14522
  return { success: false, output: "No page" };
14261
- await this.page.goBack({
14262
- waitUntil: "domcontentloaded",
14263
- timeout: this.config.navigationTimeout
14264
- }).catch(() => {});
14523
+ await this.driver.goBack(this.config.navigationTimeout);
14265
14524
  await new Promise((r) => setTimeout(r, 300));
14266
14525
  const snapshot = await this.takeSnapshot();
14267
14526
  return { success: true, output: snapshot };
14268
14527
  }
14269
14528
  async forward() {
14270
- const err = await this.ensurePage();
14529
+ const err = await this.ensureDriver();
14271
14530
  if (err)
14272
14531
  return err;
14273
- if (!this.page)
14532
+ if (!this.driver)
14274
14533
  return { success: false, output: "No page" };
14275
- await this.page.goForward({
14276
- waitUntil: "domcontentloaded",
14277
- timeout: this.config.navigationTimeout
14278
- }).catch(() => {});
14534
+ await this.driver.goForward(this.config.navigationTimeout);
14279
14535
  await new Promise((r) => setTimeout(r, 300));
14280
14536
  const snapshot = await this.takeSnapshot();
14281
14537
  return { success: true, output: snapshot };
14282
14538
  }
14283
14539
  async screenshot() {
14284
- const err = await this.ensurePage();
14540
+ const err = await this.ensureDriver();
14285
14541
  if (err)
14286
14542
  return err;
14287
- if (!this.page)
14543
+ if (!this.driver)
14288
14544
  return { success: false, output: "No page" };
14289
- const buffer = await this.page.screenshot({ type: "png", fullPage: false });
14545
+ const buffer = await this.driver.screenshot();
14290
14546
  const snapshot = await this.takeSnapshot();
14291
14547
  return { success: true, output: snapshot, screenshot: buffer };
14292
14548
  }
14293
14549
  async snapshot() {
14294
- const err = await this.ensurePage();
14550
+ const err = await this.ensureDriver();
14295
14551
  if (err)
14296
14552
  return err;
14297
14553
  const snap = await this.takeSnapshot();
14298
14554
  return { success: true, output: snap };
14299
14555
  }
14300
14556
  async wait(ms) {
14301
- const err = await this.ensurePage();
14557
+ const err = await this.ensureDriver();
14302
14558
  if (err)
14303
14559
  return err;
14304
14560
  await new Promise((r) => setTimeout(r, Math.min(ms, 1e4)));
@@ -14307,40 +14563,34 @@ class BrowserSession {
14307
14563
  }
14308
14564
  async close() {
14309
14565
  await this.saveCookies();
14310
- if (this.page) {
14311
- await this.page.close().catch(() => {});
14312
- this.page = null;
14313
- }
14314
- if (this.context) {
14315
- await this.context.close().catch(() => {});
14316
- this.context = null;
14317
- }
14318
- if (this.browser) {
14319
- await this.browser.close().catch(() => {});
14320
- this.browser = null;
14566
+ if (this.driver) {
14567
+ await this.driver.close();
14568
+ this.driver = null;
14321
14569
  }
14322
14570
  this.state = { isOpen: false, url: null, title: null, elementCount: 0 };
14323
14571
  return { success: true, output: t("browser.closed") };
14324
14572
  }
14325
14573
  }
14326
- var CONSOLE_MAX_LINE = 200;
14574
+ var CONSOLE_MAX_LINE = 400;
14327
14575
  var init_session = __esm(() => {
14576
+ init_driver();
14328
14577
  init_snapshot();
14329
14578
  init_cookie_store();
14330
14579
  init_i18n();
14331
14580
  });
14332
14581
 
14333
14582
  // src/tools/browser.ts
14334
- import { join as join18 } from "path";
14583
+ import { join as join19 } from "path";
14335
14584
  function getSession(ctx) {
14336
14585
  if (!session) {
14337
- const cookieDir = join18(ctx.baseDir, ".mma", "browser");
14586
+ const cookieDir = join19(ctx.baseDir, ".mma", "browser");
14338
14587
  session = new BrowserSession({
14339
14588
  ...DEFAULT_BROWSER_CONFIG,
14340
14589
  headless: ctx.config.browser?.headless ?? true,
14341
14590
  maxElements: ctx.config.browser?.maxElements ?? 30,
14342
14591
  maxContentChars: ctx.config.browser?.maxContentChars ?? 2500,
14343
- maxConsoleEntries: ctx.config.browser?.maxConsoleEntries ?? 20,
14592
+ maxConsoleEntries: ctx.config.browser?.maxConsoleEntries ?? 40,
14593
+ maxConsoleLineChars: ctx.config.browser?.maxConsoleLineChars ?? 400,
14344
14594
  navigationTimeout: ctx.config.browser?.navigationTimeout ?? 15000,
14345
14595
  viewportWidth: ctx.config.browser?.viewportWidth ?? 1280,
14346
14596
  viewportHeight: ctx.config.browser?.viewportHeight ?? 720,
@@ -14467,8 +14717,8 @@ async function readClipboardFallback() {
14467
14717
  const { platform: platform3 } = await import("os");
14468
14718
  const { execSync } = await import("child_process");
14469
14719
  const { readFileSync: readFileSync15, unlinkSync: unlinkSync4 } = await import("fs");
14470
- const { join: join19 } = await import("path");
14471
- const tmpPath = join19(process.env.TEMP || process.env.TMP || "/tmp", `mma-clip-${Date.now()}.png`);
14720
+ const { join: join20 } = await import("path");
14721
+ const tmpPath = join20(process.env.TEMP || process.env.TMP || "/tmp", `mma-clip-${Date.now()}.png`);
14472
14722
  try {
14473
14723
  if (platform3() === "linux") {
14474
14724
  execSync(`xclip -selection clipboard -t image/png -o > "${tmpPath}" 2>/dev/null`, { timeout: 5000 });
@@ -14748,7 +14998,7 @@ class ModuleRegistry {
14748
14998
 
14749
14999
  // src/modules/plugins/loader.ts
14750
15000
  import { readdirSync as readdirSync7, existsSync as existsSync25, statSync as statSync5 } from "fs";
14751
- import { join as join19 } from "path";
15001
+ import { join as join20 } from "path";
14752
15002
 
14753
15003
  class PluginLoader {
14754
15004
  loadFromDir(dirPath, pluginManager, logger) {
@@ -14756,7 +15006,7 @@ class PluginLoader {
14756
15006
  return;
14757
15007
  const entries = readdirSync7(dirPath);
14758
15008
  for (const entry of entries) {
14759
- const fullPath = join19(dirPath, entry);
15009
+ const fullPath = join20(dirPath, entry);
14760
15010
  if (!statSync5(fullPath).isFile())
14761
15011
  continue;
14762
15012
  if (!entry.endsWith(".ts") && !entry.endsWith(".js"))
@@ -14779,9 +15029,9 @@ var init_loader = __esm(() => {
14779
15029
  });
14780
15030
 
14781
15031
  // src/modules/plugins/builtin/lint-on-write.ts
14782
- import { spawn as spawn4, execSync } from "child_process";
15032
+ import { spawn as spawn5, execSync } from "child_process";
14783
15033
  import { existsSync as existsSync26, readFileSync as readFileSync15 } from "fs";
14784
- import { resolve as resolve16, extname as extname4, join as join20 } from "path";
15034
+ import { resolve as resolve16, extname as extname4, join as join21 } from "path";
14785
15035
  import { platform as platform3 } from "os";
14786
15036
  function contentHash(content) {
14787
15037
  let h = 5381;
@@ -14883,7 +15133,7 @@ class LintOnWritePlugin {
14883
15133
  }
14884
15134
  async runProjectLint(ctx, result) {
14885
15135
  try {
14886
- const packageJsonPath = join20(ctx.baseDir, "package.json");
15136
+ const packageJsonPath = join21(ctx.baseDir, "package.json");
14887
15137
  if (!existsSync26(packageJsonPath)) {
14888
15138
  return;
14889
15139
  }
@@ -14903,7 +15153,7 @@ class LintOnWritePlugin {
14903
15153
  }
14904
15154
  }
14905
15155
  async runProjectTypeCheck(ctx, result) {
14906
- const tsconfigPath = join20(ctx.baseDir, "tsconfig.json");
15156
+ const tsconfigPath = join21(ctx.baseDir, "tsconfig.json");
14907
15157
  if (!existsSync26(tsconfigPath)) {
14908
15158
  return;
14909
15159
  }
@@ -14946,7 +15196,7 @@ class LintOnWritePlugin {
14946
15196
  }
14947
15197
  function runAsync(command, cwd, timeoutMs) {
14948
15198
  return new Promise((resolve17, reject) => {
14949
- const child = spawn4(command, {
15199
+ const child = spawn5(command, {
14950
15200
  cwd,
14951
15201
  shell: true,
14952
15202
  windowsHide: true,
@@ -15147,7 +15397,7 @@ var init_tracker = () => {};
15147
15397
 
15148
15398
  // src/modules/execution/auditor.ts
15149
15399
  import { existsSync as existsSync27, readdirSync as readdirSync8 } from "fs";
15150
- import { resolve as resolve17, join as join21 } from "path";
15400
+ import { resolve as resolve17, join as join22 } from "path";
15151
15401
  function findTestFile(dir, depth = 0) {
15152
15402
  if (depth > 5)
15153
15403
  return null;
@@ -15158,7 +15408,7 @@ function findTestFile(dir, depth = 0) {
15158
15408
  return null;
15159
15409
  }
15160
15410
  for (const e of entries) {
15161
- const full = join21(dir, e.name);
15411
+ const full = join22(dir, e.name);
15162
15412
  if (e.isDirectory()) {
15163
15413
  if (SKIP_DIRS.has(e.name))
15164
15414
  continue;
@@ -15318,7 +15568,7 @@ var init_auditor = __esm(() => {
15318
15568
 
15319
15569
  // src/modules/execution/plan-store.ts
15320
15570
  import { readFileSync as readFileSync16, writeFileSync as writeFileSync9, mkdirSync as mkdirSync13, existsSync as existsSync28, readdirSync as readdirSync9, rmSync } from "fs";
15321
- import { join as join22 } from "path";
15571
+ import { join as join23 } from "path";
15322
15572
  function readPlanFile(path, fallbackBaseDir) {
15323
15573
  try {
15324
15574
  const raw = readFileSync16(path, "utf-8");
@@ -15346,7 +15596,7 @@ function listDir(dir, baseDir) {
15346
15596
  if (!existsSync28(dir))
15347
15597
  return [];
15348
15598
  const files = readdirSync9(dir).filter((f) => f.endsWith(".json"));
15349
- return files.map((f) => readPlanFile(join22(dir, f), baseDir)).filter((p) => p !== null);
15599
+ return files.map((f) => readPlanFile(join23(dir, f), baseDir)).filter((p) => p !== null);
15350
15600
  }
15351
15601
  function toMeta(plan, status) {
15352
15602
  return {
@@ -15367,21 +15617,21 @@ class PlanStore {
15367
15617
  archiveDir;
15368
15618
  legacyPath;
15369
15619
  constructor(baseDir) {
15370
- const mmaDir = join22(baseDir, ".mma");
15620
+ const mmaDir = join23(baseDir, ".mma");
15371
15621
  if (!existsSync28(mmaDir))
15372
15622
  mkdirSync13(mmaDir, { recursive: true });
15373
15623
  this.baseDir = baseDir;
15374
- this.plansDir = join22(mmaDir, "plans");
15375
- this.draftsDir = join22(this.plansDir, "drafts");
15376
- this.archiveDir = join22(this.plansDir, "archive");
15377
- this.legacyPath = join22(mmaDir, LEGACY_FILE);
15624
+ this.plansDir = join23(mmaDir, "plans");
15625
+ this.draftsDir = join23(this.plansDir, "drafts");
15626
+ this.archiveDir = join23(this.plansDir, "archive");
15627
+ this.legacyPath = join23(mmaDir, LEGACY_FILE);
15378
15628
  for (const dir of [this.plansDir, this.draftsDir, this.archiveDir]) {
15379
15629
  if (!existsSync28(dir))
15380
15630
  mkdirSync13(dir, { recursive: true });
15381
15631
  }
15382
15632
  }
15383
15633
  activePath() {
15384
- return join22(this.plansDir, "active.json");
15634
+ return join23(this.plansDir, "active.json");
15385
15635
  }
15386
15636
  saveActive(plan) {
15387
15637
  writePlanFile(this.activePath(), plan);
@@ -15411,14 +15661,14 @@ class PlanStore {
15411
15661
  rmSync(p, { force: true });
15412
15662
  }
15413
15663
  saveDraft(plan) {
15414
- writePlanFile(join22(this.draftsDir, `${plan.id}.json`), plan);
15664
+ writePlanFile(join23(this.draftsDir, `${plan.id}.json`), plan);
15415
15665
  }
15416
15666
  loadDraft(id) {
15417
- const p = join22(this.draftsDir, `${id}.json`);
15667
+ const p = join23(this.draftsDir, `${id}.json`);
15418
15668
  return existsSync28(p) ? readPlanFile(p, this.baseDir) : null;
15419
15669
  }
15420
15670
  removeDraft(id) {
15421
- const p = join22(this.draftsDir, `${id}.json`);
15671
+ const p = join23(this.draftsDir, `${id}.json`);
15422
15672
  if (existsSync28(p))
15423
15673
  rmSync(p, { force: true });
15424
15674
  }
@@ -15426,7 +15676,7 @@ class PlanStore {
15426
15676
  return listDir(this.draftsDir, this.baseDir);
15427
15677
  }
15428
15678
  archivePlan(plan) {
15429
- writePlanFile(join22(this.archiveDir, `${plan.id}.json`), plan);
15679
+ writePlanFile(join23(this.archiveDir, `${plan.id}.json`), plan);
15430
15680
  this.removeDraft(plan.id);
15431
15681
  const active = this.loadActive();
15432
15682
  if (active && active.id === plan.id) {
@@ -15437,7 +15687,7 @@ class PlanStore {
15437
15687
  return listDir(this.archiveDir, this.baseDir);
15438
15688
  }
15439
15689
  removeArchived(id) {
15440
- const p = join22(this.archiveDir, `${id}.json`);
15690
+ const p = join23(this.archiveDir, `${id}.json`);
15441
15691
  if (existsSync28(p))
15442
15692
  rmSync(p, { force: true });
15443
15693
  }
@@ -16304,7 +16554,7 @@ import {
16304
16554
  readdirSync as readdirSync10,
16305
16555
  unlinkSync as unlinkSync4
16306
16556
  } from "fs";
16307
- import { join as join23 } from "path";
16557
+ import { join as join24 } from "path";
16308
16558
  import { homedir as homedir8 } from "os";
16309
16559
 
16310
16560
  class SessionFileEncryptor {
@@ -16313,7 +16563,7 @@ class SessionFileEncryptor {
16313
16563
  constructor(config) {
16314
16564
  this.config = { ...DEFAULT_SESSION_ENCRYPTION, ...config };
16315
16565
  this.encryptor = new ConfigEncryptor({
16316
- keyPath: config?.keyPath || join23(homedir8(), ".mma", ".session-encryption-key")
16566
+ keyPath: config?.keyPath || join24(homedir8(), ".mma", ".session-encryption-key")
16317
16567
  });
16318
16568
  }
16319
16569
  isEnabled() {
@@ -16399,7 +16649,7 @@ class SessionFileEncryptor {
16399
16649
  return;
16400
16650
  const files = readdirSync10(sessionDir);
16401
16651
  for (const file of files) {
16402
- const filePath = join23(sessionDir, file);
16652
+ const filePath = join24(sessionDir, file);
16403
16653
  if (existsSync30(filePath) && !file.endsWith(".enc")) {
16404
16654
  try {
16405
16655
  const content = readFileSync18(filePath, "utf8");
@@ -16416,7 +16666,7 @@ class SessionFileEncryptor {
16416
16666
  const files = readdirSync10(sessionDir);
16417
16667
  for (const file of files) {
16418
16668
  if (file.endsWith(".enc")) {
16419
- const encFilePath = join23(sessionDir, file);
16669
+ const encFilePath = join24(sessionDir, file);
16420
16670
  const decFilePath = encFilePath.slice(0, -4);
16421
16671
  try {
16422
16672
  const content = readFileSync18(encFilePath, "utf8");
@@ -16449,7 +16699,7 @@ import {
16449
16699
  writeFileSync as writeFileSync11,
16450
16700
  appendFileSync as appendFileSync6
16451
16701
  } from "fs";
16452
- import { join as join24 } from "path";
16702
+ import { join as join25 } from "path";
16453
16703
  import { gzipSync } from "zlib";
16454
16704
 
16455
16705
  class SessionStore {
@@ -16463,7 +16713,7 @@ class SessionStore {
16463
16713
  }
16464
16714
  }
16465
16715
  getSessionDir(id) {
16466
- return join24(this.baseDir, id);
16716
+ return join25(this.baseDir, id);
16467
16717
  }
16468
16718
  updateEncryption(config) {
16469
16719
  if (config?.enabled) {
@@ -16479,16 +16729,16 @@ class SessionStore {
16479
16729
  mkdirSync14(this.baseDir, { recursive: true });
16480
16730
  }
16481
16731
  sessionDir(id) {
16482
- return join24(this.baseDir, id);
16732
+ return join25(this.baseDir, id);
16483
16733
  }
16484
16734
  metaPath(id) {
16485
- return join24(this.sessionDir(id), "meta.json");
16735
+ return join25(this.sessionDir(id), "meta.json");
16486
16736
  }
16487
16737
  historyPath(id) {
16488
- return join24(this.sessionDir(id), "history.jsonl");
16738
+ return join25(this.sessionDir(id), "history.jsonl");
16489
16739
  }
16490
16740
  sessionLogPath(id) {
16491
- return join24(this.sessionDir(id), "session.jsonl");
16741
+ return join25(this.sessionDir(id), "session.jsonl");
16492
16742
  }
16493
16743
  sessionExists(id) {
16494
16744
  return existsSync31(this.metaPath(id));
@@ -16642,7 +16892,7 @@ class SessionStore {
16642
16892
  if (existsSync31(historyPath)) {
16643
16893
  const content = readFileSync19(historyPath, "utf-8");
16644
16894
  const compressed = gzipSync(content);
16645
- const gzPath = join24(this.baseDir, `${session2.id}.jsonl.gz`);
16895
+ const gzPath = join25(this.baseDir, `${session2.id}.jsonl.gz`);
16646
16896
  writeFileSync11(gzPath, compressed);
16647
16897
  rmSync2(historyPath);
16648
16898
  }
@@ -16853,7 +17103,7 @@ class ProfileCompressor {
16853
17103
 
16854
17104
  // src/modules/user-profile/profile.ts
16855
17105
  import { readFileSync as readFileSync20, writeFileSync as writeFileSync12, existsSync as existsSync32, mkdirSync as mkdirSync15 } from "fs";
16856
- import { join as join25 } from "path";
17106
+ import { join as join26 } from "path";
16857
17107
  import { homedir as homedir9, hostname, platform as platform4, type } from "os";
16858
17108
  import { env } from "process";
16859
17109
 
@@ -16880,10 +17130,10 @@ class UserProfile {
16880
17130
  if (!existsSync32(this.profileDir)) {
16881
17131
  mkdirSync15(this.profileDir, { recursive: true });
16882
17132
  }
16883
- writeFileSync12(join25(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
17133
+ writeFileSync12(join26(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
16884
17134
  }
16885
17135
  load() {
16886
- const path = join25(this.profileDir, "profile.json");
17136
+ const path = join26(this.profileDir, "profile.json");
16887
17137
  if (!existsSync32(path))
16888
17138
  return null;
16889
17139
  try {
@@ -16923,7 +17173,7 @@ var init_profile = () => {};
16923
17173
 
16924
17174
  // src/modules/skills/loader.ts
16925
17175
  import { readdirSync as readdirSync12, readFileSync as readFileSync21, existsSync as existsSync33, statSync as statSync6 } from "fs";
16926
- import { join as join26 } from "path";
17176
+ import { join as join27 } from "path";
16927
17177
 
16928
17178
  class SkillsLoader {
16929
17179
  loadFromDir(dirPath) {
@@ -16936,7 +17186,7 @@ class SkillsLoader {
16936
17186
  scanDir(dirPath, skills) {
16937
17187
  const entries = readdirSync12(dirPath);
16938
17188
  for (const entry of entries) {
16939
- const fullPath = join26(dirPath, entry);
17189
+ const fullPath = join27(dirPath, entry);
16940
17190
  const stat = statSync6(fullPath);
16941
17191
  if (stat.isDirectory()) {
16942
17192
  this.scanDir(fullPath, skills);
@@ -17173,12 +17423,14 @@ var init_browser2 = __esm(() => {
17173
17423
  init_module4();
17174
17424
  init_session();
17175
17425
  init_cookie_store();
17426
+ init_driver();
17427
+ init_bridge_client();
17176
17428
  init_snapshot();
17177
17429
  init_types();
17178
17430
  });
17179
17431
 
17180
17432
  // src/modules/lsp/client.ts
17181
- import { spawn as spawn5, execSync as execSync2 } from "child_process";
17433
+ import { spawn as spawn6, execSync as execSync2 } from "child_process";
17182
17434
  import { resolve as resolve19 } from "path";
17183
17435
 
17184
17436
  class LspClient {
@@ -17242,7 +17494,7 @@ class LspClient {
17242
17494
  }
17243
17495
  return new Promise((resolve20, reject) => {
17244
17496
  const args = config.args ?? [];
17245
- const proc = spawn5(config.command, args, {
17497
+ const proc = spawn6(config.command, args, {
17246
17498
  stdio: ["pipe", "pipe", "pipe"],
17247
17499
  env: { ...process.env, ...config.env },
17248
17500
  cwd: baseDir
@@ -17503,7 +17755,7 @@ var init_lsp = __esm(() => {
17503
17755
 
17504
17756
  // src/modules/indexer/walker.ts
17505
17757
  import { readdirSync as readdirSync13, readFileSync as readFileSync22, statSync as statSync7, existsSync as existsSync35, watch } from "fs";
17506
- import { join as join27, relative as relative2, extname as extname5 } from "path";
17758
+ import { join as join28, relative as relative2, extname as extname5 } from "path";
17507
17759
 
17508
17760
  class Indexer {
17509
17761
  baseDir;
@@ -17541,7 +17793,7 @@ class Indexer {
17541
17793
  for (const entry of entries) {
17542
17794
  if (count >= this.MAX_FILES)
17543
17795
  return;
17544
- const fullPath = join27(dir, entry);
17796
+ const fullPath = join28(dir, entry);
17545
17797
  const relPath = relative2(this.baseDir, fullPath);
17546
17798
  const stat = statSync7(fullPath);
17547
17799
  if (stat.isDirectory()) {
@@ -17605,13 +17857,13 @@ var init_walker = __esm(() => {
17605
17857
 
17606
17858
  // src/modules/indexer/cache.ts
17607
17859
  import { readFileSync as readFileSync23, writeFileSync as writeFileSync13, existsSync as existsSync36, mkdirSync as mkdirSync16, rmSync as rmSync3 } from "fs";
17608
- import { join as join28 } from "path";
17860
+ import { join as join29 } from "path";
17609
17861
 
17610
17862
  class IndexCache {
17611
17863
  cachePath;
17612
17864
  cache = null;
17613
17865
  constructor(cacheDir) {
17614
- this.cachePath = join28(cacheDir, "index-cache.json");
17866
+ this.cachePath = join29(cacheDir, "index-cache.json");
17615
17867
  }
17616
17868
  load() {
17617
17869
  if (this.cache)
@@ -17627,7 +17879,7 @@ class IndexCache {
17627
17879
  }
17628
17880
  save(result) {
17629
17881
  this.cache = result;
17630
- const dir = join28(this.cachePath, "..");
17882
+ const dir = join29(this.cachePath, "..");
17631
17883
  if (!existsSync36(dir))
17632
17884
  mkdirSync16(dir, { recursive: true });
17633
17885
  writeFileSync13(this.cachePath, JSON.stringify(result), "utf-8");
@@ -17644,7 +17896,7 @@ class IndexCache {
17644
17896
  var init_cache = () => {};
17645
17897
 
17646
17898
  // src/modules/indexer/module.ts
17647
- import { dirname as dirname7 } from "path";
17899
+ import { dirname as dirname8 } from "path";
17648
17900
 
17649
17901
  class IndexerModule {
17650
17902
  name = "indexer";
@@ -17761,7 +18013,7 @@ ${t("indexer.and_more", { count: result.files.length - 100 })}` : "";
17761
18013
  const counts = {};
17762
18014
  for (const f of result.files) {
17763
18015
  const normalized = f.path.replace(/\\/g, "/");
17764
- const dir = dirname7(normalized);
18016
+ const dir = dirname8(normalized);
17765
18017
  const key = dir === "." ? "(root)" : dir;
17766
18018
  counts[key] = (counts[key] || 0) + 1;
17767
18019
  }
@@ -17992,13 +18244,13 @@ var init_mcp = __esm(() => {
17992
18244
 
17993
18245
  // src/modules/memory/module.ts
17994
18246
  import { homedir as homedir10 } from "os";
17995
- import { join as join29 } from "path";
18247
+ import { join as join30 } from "path";
17996
18248
 
17997
18249
  class MemoryModule {
17998
18250
  name = "memory";
17999
18251
  store;
18000
18252
  constructor(memoryDir) {
18001
- const dir = memoryDir || join29(homedir10(), ".mma", "memory");
18253
+ const dir = memoryDir || join30(homedir10(), ".mma", "memory");
18002
18254
  this.store = new MemoryStore(dir);
18003
18255
  }
18004
18256
  getSystemPromptBlock() {
@@ -18046,7 +18298,7 @@ __export(exports_bootstrap, {
18046
18298
  bootstrap: () => bootstrap
18047
18299
  });
18048
18300
  import { homedir as homedir11 } from "os";
18049
- import { join as join30, resolve as resolve21 } from "path";
18301
+ import { join as join31, resolve as resolve21 } from "path";
18050
18302
  import { existsSync as existsSync37, readFileSync as readFileSync24, writeFileSync as writeFileSync14 } from "fs";
18051
18303
  function buildSystemInfo(config, baseDir, profileCompressed) {
18052
18304
  const now = new Date().toISOString().replace("T", " ").slice(0, 19);
@@ -18072,8 +18324,8 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
18072
18324
  `);
18073
18325
  }
18074
18326
  async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18075
- const dir = configDir || join30(homedir11(), ".mma");
18076
- const projectConfigPath = projectDir ? join30(projectDir, ".mmrc") : join30(process.cwd(), ".mmrc");
18327
+ const dir = configDir || join31(homedir11(), ".mma");
18328
+ const projectConfigPath = projectDir ? join31(projectDir, ".mmrc") : join31(process.cwd(), ".mmrc");
18077
18329
  const config = loadConfig({ configDir: dir, projectConfigPath });
18078
18330
  setLocale(config.locale);
18079
18331
  try {
@@ -18083,7 +18335,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18083
18335
  }
18084
18336
  } catch {}
18085
18337
  const logger = new Logger(config.logLevel);
18086
- logger.setLogDir(join30(dir, "logs"));
18338
+ logger.setLogDir(join31(dir, "logs"));
18087
18339
  logger.debug("MMA bootstrap", {
18088
18340
  version: config.version,
18089
18341
  model: config.model
@@ -18105,7 +18357,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18105
18357
  logger.info(`Model ${config.model} loaded in ${loadResult.loadTime}s`);
18106
18358
  }
18107
18359
  }
18108
- const profile = new UserProfile(join30(dir));
18360
+ const profile = new UserProfile(join31(dir));
18109
18361
  profile.load() || profile.collect();
18110
18362
  profile.save();
18111
18363
  const llmProvider = new OpenAICompatProvider({
@@ -18117,7 +18369,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18117
18369
  rateLimits: config.security?.rateLimits
18118
18370
  });
18119
18371
  const baseDir = projectDir ? resolve21(projectDir) : process.cwd();
18120
- const projectMapCacheDir = join30(baseDir, ".mma");
18372
+ const projectMapCacheDir = join31(baseDir, ".mma");
18121
18373
  const indexerModule = new IndexerModule({
18122
18374
  baseDir,
18123
18375
  cacheDir: projectMapCacheDir
@@ -18128,9 +18380,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18128
18380
  logger.warn(`Project indexing failed: ${err.message}`);
18129
18381
  }
18130
18382
  const skillsLoader = new SkillsLoader;
18131
- const builtinDir = join30(import.meta.dirname, "skills", "builtin");
18132
- const globalDir = join30(homedir11(), ".agents", "skills");
18133
- const projectSkillsDir = join30(baseDir, ".mma", "skills");
18383
+ const builtinDir = join31(import.meta.dirname, "skills", "builtin");
18384
+ const globalDir = join31(homedir11(), ".agents", "skills");
18385
+ const projectSkillsDir = join31(baseDir, ".mma", "skills");
18134
18386
  const availableSkills = skillsLoader.loadFromAllSources(builtinDir, globalDir, projectSkillsDir);
18135
18387
  const skillsBudget = Math.floor(config.contextWindow * config.skills.budget);
18136
18388
  const skillsModule = new SkillsModule(availableSkills, skillsBudget);
@@ -18144,11 +18396,11 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18144
18396
  essential: true,
18145
18397
  estimatedTokens: Math.ceil(systemInfoContent.length / 4)
18146
18398
  };
18147
- const agentsMdGlobal = join30(dir, "AGENTS.md");
18399
+ const agentsMdGlobal = join31(dir, "AGENTS.md");
18148
18400
  if (!existsSync37(agentsMdGlobal)) {
18149
18401
  writeFileSync14(agentsMdGlobal, "", "utf-8");
18150
18402
  }
18151
- const sessionDir = join30(dir, "sessions");
18403
+ const sessionDir = join31(dir, "sessions");
18152
18404
  const sessionStore = new SessionStore(sessionDir);
18153
18405
  sessionStore.init();
18154
18406
  const sessionManager = new SessionManager(sessionStore, {
@@ -18215,7 +18467,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18215
18467
  const mcpModule = new MCPModule(config);
18216
18468
  await mcpModule.initialize();
18217
18469
  moduleRegistry.register(mcpModule);
18218
- const memoryModule = new MemoryModule(join30(dir, "memory"));
18470
+ const memoryModule = new MemoryModule(join31(dir, "memory"));
18219
18471
  moduleRegistry.register(memoryModule);
18220
18472
  if (config.browser.enabled) {
18221
18473
  const browserModule = new BrowserModule;
@@ -18265,8 +18517,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18265
18517
  pluginManager.register(plugin);
18266
18518
  pluginManager.register(plugin2);
18267
18519
  const pluginLoader = new PluginLoader;
18268
- const globalPluginsDir = join30(homedir11(), ".mma", "plugins");
18269
- const projectPluginsDir = join30(baseDir, ".mma", "plugins");
18520
+ const globalPluginsDir = join31(homedir11(), ".mma", "plugins");
18521
+ const projectPluginsDir = join31(baseDir, ".mma", "plugins");
18270
18522
  pluginLoader.loadFromDir(globalPluginsDir, pluginManager, logger);
18271
18523
  pluginLoader.loadFromDir(projectPluginsDir, pluginManager, logger);
18272
18524
  contextManager.onCompact = (summary) => {
@@ -18284,9 +18536,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
18284
18536
  const skipAgentsMd = noAgentsMd === true;
18285
18537
  if (!skipAgentsMd) {
18286
18538
  const agentsMdCandidates = [
18287
- join30(baseDir, "AGENTS.md"),
18288
- join30(baseDir, ".mma", "AGENTS.md"),
18289
- join30(dir, "AGENTS.md")
18539
+ join31(baseDir, "AGENTS.md"),
18540
+ join31(baseDir, ".mma", "AGENTS.md"),
18541
+ join31(dir, "AGENTS.md")
18290
18542
  ];
18291
18543
  for (const p of agentsMdCandidates) {
18292
18544
  if (existsSync37(p)) {
@@ -19141,7 +19393,7 @@ __export(exports_manifest, {
19141
19393
  });
19142
19394
  import { existsSync as existsSync38, readFileSync as readFileSync25, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "fs";
19143
19395
  import { homedir as homedir13 } from "os";
19144
- import { join as join32 } from "path";
19396
+ import { join as join33 } from "path";
19145
19397
  function readManifest(path = MANIFEST_PATH) {
19146
19398
  try {
19147
19399
  if (existsSync38(path)) {
@@ -19152,7 +19404,7 @@ function readManifest(path = MANIFEST_PATH) {
19152
19404
  return { version: 1, certifications: [] };
19153
19405
  }
19154
19406
  function saveManifest(m, path = MANIFEST_PATH) {
19155
- mkdirSync17(join32(homedir13(), ".mma"), { recursive: true });
19407
+ mkdirSync17(join33(homedir13(), ".mma"), { recursive: true });
19156
19408
  writeFileSync15(path, JSON.stringify(m, null, 2), "utf-8");
19157
19409
  }
19158
19410
  function upsertCertification(entry, path = MANIFEST_PATH) {
@@ -19187,7 +19439,7 @@ function getCertMark(model, providerUrl, currentVersion, path = MANIFEST_PATH) {
19187
19439
  }
19188
19440
  var MANIFEST_PATH;
19189
19441
  var init_manifest = __esm(() => {
19190
- MANIFEST_PATH = join32(homedir13(), ".mma", "certifications.json");
19442
+ MANIFEST_PATH = join33(homedir13(), ".mma", "certifications.json");
19191
19443
  });
19192
19444
 
19193
19445
  // node_modules/yaml/dist/nodes/identity.js
@@ -26311,7 +26563,7 @@ var init_scenarios = __esm(() => {
26311
26563
 
26312
26564
  // src/modules/certification/loader.ts
26313
26565
  import { existsSync as existsSync39, readdirSync as readdirSync14, readFileSync as readFileSync26 } from "fs";
26314
- import { join as join33 } from "path";
26566
+ import { join as join34 } from "path";
26315
26567
  function validateScenario(s) {
26316
26568
  const errors2 = [];
26317
26569
  const isSkip = s.mode === "skip";
@@ -26365,7 +26617,7 @@ function loadScenarios(userDir) {
26365
26617
  if (!file.endsWith(".yaml") && !file.endsWith(".yml"))
26366
26618
  continue;
26367
26619
  try {
26368
- const raw = readFileSync26(join33(userDir, file), "utf-8");
26620
+ const raw = readFileSync26(join34(userDir, file), "utf-8");
26369
26621
  const data = $parse(raw);
26370
26622
  const parsed = normalizeScenario(data, file);
26371
26623
  const errs = validateScenario(parsed);
@@ -26419,7 +26671,7 @@ var init_loader3 = __esm(() => {
26419
26671
 
26420
26672
  // src/modules/certification/fact-checker.ts
26421
26673
  import { existsSync as existsSync40, readFileSync as readFileSync27, statSync as statSync8 } from "fs";
26422
- import { join as join34 } from "path";
26674
+ import { join as join35 } from "path";
26423
26675
  function checkSandbox(sandboxDir, checks, exitCode, output) {
26424
26676
  const failures = [];
26425
26677
  for (const check of checks) {
@@ -26436,13 +26688,13 @@ function runCheck(sandboxDir, check, exitCode, output) {
26436
26688
  case "outputContains":
26437
26689
  return output.includes(check.text);
26438
26690
  case "fileExists":
26439
- return isFile(join34(sandboxDir, check.path));
26691
+ return isFile(join35(sandboxDir, check.path));
26440
26692
  case "fileNotExists":
26441
- return !existsSync40(join34(sandboxDir, check.path));
26693
+ return !existsSync40(join35(sandboxDir, check.path));
26442
26694
  case "dirExists":
26443
- return isDir(join34(sandboxDir, check.path));
26695
+ return isDir(join35(sandboxDir, check.path));
26444
26696
  case "fileContent": {
26445
- const abs = join34(sandboxDir, check.path);
26697
+ const abs = join35(sandboxDir, check.path);
26446
26698
  if (!isFile(abs))
26447
26699
  return false;
26448
26700
  const content = readFileSync27(abs, "utf-8");
@@ -26453,7 +26705,7 @@ function runCheck(sandboxDir, check, exitCode, output) {
26453
26705
  return false;
26454
26706
  }
26455
26707
  case "fileRegex": {
26456
- const abs = join34(sandboxDir, check.path);
26708
+ const abs = join35(sandboxDir, check.path);
26457
26709
  if (!isFile(abs))
26458
26710
  return false;
26459
26711
  return new RegExp(check.pattern).test(readFileSync27(abs, "utf-8"));
@@ -26501,10 +26753,10 @@ function describe(check) {
26501
26753
  var init_fact_checker = () => {};
26502
26754
 
26503
26755
  // src/modules/certification/runner.ts
26504
- import { spawn as spawn6 } from "child_process";
26756
+ import { spawn as spawn7 } from "child_process";
26505
26757
  import { existsSync as existsSync41, mkdirSync as mkdirSync18, rmSync as rmSync4, cpSync as cpSync2 } from "fs";
26506
26758
  import { platform as platform5 } from "os";
26507
- import { join as join35, resolve as resolve22, dirname as dirname8 } from "path";
26759
+ import { join as join36, resolve as resolve22, dirname as dirname9 } from "path";
26508
26760
  async function runScenario(scenario, opts) {
26509
26761
  if (scenario.mode === "skip") {
26510
26762
  return {
@@ -26523,7 +26775,7 @@ async function runScenario(scenario, opts) {
26523
26775
  let passed = 0;
26524
26776
  let firstError;
26525
26777
  for (let i = 1;i <= reps; i++) {
26526
- const sandbox = join35(opts.sandboxBase, `run-${scenario.id}-${i}`);
26778
+ const sandbox = join36(opts.sandboxBase, `run-${scenario.id}-${i}`);
26527
26779
  let failures = [];
26528
26780
  let exitCode = -1;
26529
26781
  let output = "";
@@ -26584,20 +26836,20 @@ function prepareSandbox(sandbox, scenario, mmaRoot) {
26584
26836
  rmSync4(sandbox, { recursive: true, force: true });
26585
26837
  mkdirSync18(sandbox, { recursive: true });
26586
26838
  for (const f of scenario.fixtures ?? []) {
26587
- const src = join35(mmaRoot, f.source);
26839
+ const src = join36(mmaRoot, f.source);
26588
26840
  if (!existsSync41(src)) {
26589
26841
  throw new Error(`fixture missing: ${f.source}`);
26590
26842
  }
26591
- const dest = join35(sandbox, f.dest);
26592
- mkdirSync18(dirname8(dest), { recursive: true });
26843
+ const dest = join36(sandbox, f.dest);
26844
+ mkdirSync18(dirname9(dest), { recursive: true });
26593
26845
  cpSync2(src, dest);
26594
26846
  }
26595
26847
  }
26596
26848
  function resolveMmaEntry(mmaRoot) {
26597
- const dev = join35(mmaRoot, "src", "cli", "main.ts");
26849
+ const dev = join36(mmaRoot, "src", "cli", "main.ts");
26598
26850
  if (existsSync41(dev))
26599
26851
  return dev;
26600
- return join35(mmaRoot, "dist", "main.js");
26852
+ return join36(mmaRoot, "dist", "main.js");
26601
26853
  }
26602
26854
  function findMmaRoot(fromDir) {
26603
26855
  const candidates = [
@@ -26605,7 +26857,7 @@ function findMmaRoot(fromDir) {
26605
26857
  resolve22(fromDir, "..")
26606
26858
  ];
26607
26859
  for (const c of candidates) {
26608
- if (existsSync41(join35(c, "package.json")))
26860
+ if (existsSync41(join36(c, "package.json")))
26609
26861
  return c;
26610
26862
  }
26611
26863
  return process.cwd();
@@ -26615,7 +26867,7 @@ function killTree2(child) {
26615
26867
  if (!pid)
26616
26868
  return;
26617
26869
  if (platform5() === "win32") {
26618
- spawn6("taskkill", ["/pid", String(pid), "/T", "/F"], {
26870
+ spawn7("taskkill", ["/pid", String(pid), "/T", "/F"], {
26619
26871
  windowsHide: true,
26620
26872
  stdio: "ignore"
26621
26873
  });
@@ -26630,7 +26882,7 @@ function killTree2(child) {
26630
26882
  }
26631
26883
  }
26632
26884
  var defaultRunner = (env2, cwd, args, timeoutMs) => new Promise((resolvePromise) => {
26633
- const child = spawn6(process.execPath, args, {
26885
+ const child = spawn7(process.execPath, args, {
26634
26886
  cwd,
26635
26887
  env: env2,
26636
26888
  windowsHide: true,
@@ -26673,11 +26925,11 @@ __export(exports_cli, {
26673
26925
  });
26674
26926
  import { rmSync as rmSync5 } from "fs";
26675
26927
  import { homedir as homedir14 } from "os";
26676
- import { join as join36, dirname as dirname9 } from "path";
26677
- import { fileURLToPath } from "url";
26928
+ import { join as join37, dirname as dirname10 } from "path";
26929
+ import { fileURLToPath as fileURLToPath2 } from "url";
26678
26930
  import { existsSync as existsSync42, readFileSync as readFileSync28 } from "fs";
26679
26931
  function readVersion() {
26680
- const candidates = [join36(MMA_ROOT, "package.json")];
26932
+ const candidates = [join37(MMA_ROOT, "package.json")];
26681
26933
  for (const p of candidates) {
26682
26934
  if (existsSync42(p)) {
26683
26935
  try {
@@ -26717,7 +26969,7 @@ async function certify(opts) {
26717
26969
  return;
26718
26970
  }
26719
26971
  console.log(t("cli.cert_started", { model: opts.name, provider: providerUrl }));
26720
- const sandboxBase = join36(process.cwd(), ".mma", "certification");
26972
+ const sandboxBase = join37(process.cwd(), ".mma", "certification");
26721
26973
  const results = [];
26722
26974
  const total = selected.length;
26723
26975
  let idx = 0;
@@ -26829,9 +27081,9 @@ var init_cli = __esm(() => {
26829
27081
  init_loader3();
26830
27082
  init_runner2();
26831
27083
  init_manifest();
26832
- HERE = dirname9(fileURLToPath(import.meta.url));
27084
+ HERE = dirname10(fileURLToPath2(import.meta.url));
26833
27085
  MMA_ROOT = findMmaRoot(HERE);
26834
- USER_SCENARIO_DIR = join36(homedir14(), ".mma", "certification", "scenarios");
27086
+ USER_SCENARIO_DIR = join37(homedir14(), ".mma", "certification", "scenarios");
26835
27087
  });
26836
27088
 
26837
27089
  // src/cli/repl-commands.ts
@@ -26840,15 +27092,15 @@ __export(exports_repl_commands, {
26840
27092
  registerAllCommands: () => registerAllCommands,
26841
27093
  COMMAND_GROUPS: () => COMMAND_GROUPS
26842
27094
  });
26843
- import { join as join38, dirname as dirname11 } from "path";
27095
+ import { join as join39, dirname as dirname12 } from "path";
26844
27096
  import { homedir as homedir16 } from "os";
26845
27097
  import { existsSync as existsSync44, readFileSync as readFileSync30 } from "fs";
26846
- import { fileURLToPath as fileURLToPath3 } from "url";
27098
+ import { fileURLToPath as fileURLToPath4 } from "url";
26847
27099
  function readVersion3() {
26848
- const here = dirname11(fileURLToPath3(import.meta.url));
27100
+ const here = dirname12(fileURLToPath4(import.meta.url));
26849
27101
  const candidates = [
26850
- join38(here, "..", "..", "package.json"),
26851
- join38(here, "..", "package.json")
27102
+ join39(here, "..", "..", "package.json"),
27103
+ join39(here, "..", "package.json")
26852
27104
  ];
26853
27105
  for (const p of candidates) {
26854
27106
  if (existsSync44(p)) {
@@ -27016,7 +27268,7 @@ function registerMmaCommands(ctx) {
27016
27268
  console.log(pc2.yellow(t("repl.wizard_running")));
27017
27269
  await ctx.withExclusiveInput(async () => {
27018
27270
  const answers = await runSetup(ctx.rl);
27019
- const configPath = join38(homedir16(), ".mma", "config.json");
27271
+ const configPath = join39(homedir16(), ".mma", "config.json");
27020
27272
  ctx.config.provider.type = answers.provider;
27021
27273
  ctx.config.provider.baseUrl = answers.apiBase;
27022
27274
  ctx.config.provider.apiKey = answers.apiKey;
@@ -27070,7 +27322,7 @@ Excluded blocks: ${info.excluded.length}`));
27070
27322
  return;
27071
27323
  }
27072
27324
  ctx.config.provider.type = name;
27073
- const configPath = join38(homedir16(), ".mma", "config.json");
27325
+ const configPath = join39(homedir16(), ".mma", "config.json");
27074
27326
  saveConfig(ctx.config, configPath);
27075
27327
  await ctx.agent.reconfigure(ctx.config);
27076
27328
  console.log(pc2.green(t("repl.provider_set", { name })));
@@ -27126,7 +27378,7 @@ Excluded blocks: ${info.excluded.length}`));
27126
27378
  return;
27127
27379
  }
27128
27380
  ctx.config.model = name;
27129
- const configPath = join38(homedir16(), ".mma", "config.json");
27381
+ const configPath = join39(homedir16(), ".mma", "config.json");
27130
27382
  saveConfig(ctx.config, configPath);
27131
27383
  await ctx.agent.reconfigure(ctx.config);
27132
27384
  console.log(pc2.green(t("repl.model_set", { name })));
@@ -27151,7 +27403,7 @@ Excluded blocks: ${info.excluded.length}`));
27151
27403
  return;
27152
27404
  }
27153
27405
  ctx.config.contextWindow = size;
27154
- const configPath = join38(homedir16(), ".mma", "config.json");
27406
+ const configPath = join39(homedir16(), ".mma", "config.json");
27155
27407
  saveConfig(ctx.config, configPath);
27156
27408
  await ctx.agent.reconfigure(ctx.config);
27157
27409
  console.log(pc2.green(t("cli.context_set", { size })));
@@ -27170,10 +27422,10 @@ Excluded blocks: ${info.excluded.length}`));
27170
27422
  ctx.agent.shutdown();
27171
27423
  const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config2(), exports_config));
27172
27424
  const { homedir: homedir17 } = await import("os");
27173
- const { join: join39 } = await import("path");
27425
+ const { join: join40 } = await import("path");
27174
27426
  const configDir = ctx.configDir;
27175
27427
  const baseDir = ctx.baseDir;
27176
- const projectConfigPath = join39(baseDir, ".mmrc");
27428
+ const projectConfigPath = join40(baseDir, ".mmrc");
27177
27429
  const freshConfig = loadConfig2({ configDir, projectConfigPath });
27178
27430
  Object.assign(ctx.config, freshConfig);
27179
27431
  const { bootstrap: bootstrap2 } = await Promise.resolve().then(() => (init_bootstrap(), exports_bootstrap));
@@ -27473,14 +27725,14 @@ init_bootstrap();
27473
27725
  init_config2();
27474
27726
  init_setup();
27475
27727
  init_i18n();
27476
- import { join as join37, dirname as dirname10 } from "path";
27728
+ import { join as join38, dirname as dirname11 } from "path";
27477
27729
  import { homedir as homedir15 } from "os";
27478
27730
  import { existsSync as existsSync43, readFileSync as readFileSync29 } from "fs";
27479
27731
 
27480
27732
  // src/cli/security-commands.ts
27481
27733
  init_bootstrap();
27482
27734
  init_config2();
27483
- import { join as join31 } from "path";
27735
+ import { join as join32 } from "path";
27484
27736
  import { homedir as homedir12 } from "os";
27485
27737
 
27486
27738
  // src/modules/security/security-policies.ts
@@ -28010,7 +28262,7 @@ function createSecurityCommand(program2) {
28010
28262
  }
28011
28263
  });
28012
28264
  securityCmd.command("set-policy").argument("<preset>", t("cli.security.preset")).description(t("cli.security.set_policy")).action(async (preset) => {
28013
- const configPath = join31(homedir12(), ".mma", "config.json");
28265
+ const configPath = join32(homedir12(), ".mma", "config.json");
28014
28266
  const { config: appConfig } = await bootstrap();
28015
28267
  const validPresets = ["strict", "balanced", "permissive"];
28016
28268
  if (!validPresets.includes(preset)) {
@@ -28025,7 +28277,7 @@ function createSecurityCommand(program2) {
28025
28277
  console.log(t("cli.security.policy_description", { description: policy.description }));
28026
28278
  });
28027
28279
  securityCmd.command("enable-encryption").description(t("cli.security.enable_encryption")).action(async () => {
28028
- const configPath = join31(homedir12(), ".mma", "config.json");
28280
+ const configPath = join32(homedir12(), ".mma", "config.json");
28029
28281
  const { config: appConfig } = await bootstrap();
28030
28282
  appConfig.security = appConfig.security || {};
28031
28283
  appConfig.security.sessionEncryption = {
@@ -28037,7 +28289,7 @@ function createSecurityCommand(program2) {
28037
28289
  console.log(t("cli.security.encryption_enabled"));
28038
28290
  });
28039
28291
  securityCmd.command("disable-encryption").description(t("cli.security.disable_encryption")).action(async () => {
28040
- const configPath = join31(homedir12(), ".mma", "config.json");
28292
+ const configPath = join32(homedir12(), ".mma", "config.json");
28041
28293
  const { config: appConfig } = await bootstrap();
28042
28294
  appConfig.security = appConfig.security || {};
28043
28295
  appConfig.security.sessionEncryption = {
@@ -28049,7 +28301,7 @@ function createSecurityCommand(program2) {
28049
28301
  console.log(t("cli.security.encryption_disabled"));
28050
28302
  });
28051
28303
  securityCmd.command("enable-audit").description(t("cli.security.enable_audit")).action(async () => {
28052
- const configPath = join31(homedir12(), ".mma", "config.json");
28304
+ const configPath = join32(homedir12(), ".mma", "config.json");
28053
28305
  const { config: appConfig } = await bootstrap();
28054
28306
  appConfig.security = appConfig.security || {};
28055
28307
  appConfig.security.auditNotifier = {
@@ -28063,7 +28315,7 @@ function createSecurityCommand(program2) {
28063
28315
  console.log(t("cli.security.audit_enabled"));
28064
28316
  });
28065
28317
  securityCmd.command("disable-audit").description(t("cli.security.disable_audit")).action(async () => {
28066
- const configPath = join31(homedir12(), ".mma", "config.json");
28318
+ const configPath = join32(homedir12(), ".mma", "config.json");
28067
28319
  const { config: appConfig } = await bootstrap();
28068
28320
  appConfig.security = appConfig.security || {};
28069
28321
  appConfig.security.auditNotifier = {
@@ -28095,12 +28347,12 @@ function createSecurityCommand(program2) {
28095
28347
  }
28096
28348
 
28097
28349
  // src/cli/commands.ts
28098
- import { fileURLToPath as fileURLToPath2 } from "url";
28350
+ import { fileURLToPath as fileURLToPath3 } from "url";
28099
28351
  function readVersion2() {
28100
- const here = dirname10(fileURLToPath2(import.meta.url));
28352
+ const here = dirname11(fileURLToPath3(import.meta.url));
28101
28353
  const candidates = [
28102
- join37(here, "..", "..", "package.json"),
28103
- join37(here, "..", "package.json")
28354
+ join38(here, "..", "..", "package.json"),
28355
+ join38(here, "..", "package.json")
28104
28356
  ];
28105
28357
  for (const p of candidates) {
28106
28358
  if (existsSync43(p)) {
@@ -28118,7 +28370,7 @@ function createProgram() {
28118
28370
  const program2 = new Command().name("mma").description(t("cli.description")).version(version).option("--no-agents-md", t("cli.no_agents_md")).option("-d, --dir <path>", t("cli.dir")).option("-e, --exit-on-complete", t("cli.exit_on_complete")).option("-j, --json", t("cli.json"));
28119
28371
  program2.command("init").description(t("cli.init")).action(async () => {
28120
28372
  const answers = await runSetup();
28121
- const configPath = join37(homedir15(), ".mma", "config.json");
28373
+ const configPath = join38(homedir15(), ".mma", "config.json");
28122
28374
  const { config } = await bootstrap();
28123
28375
  config.provider.type = answers.provider;
28124
28376
  config.provider.baseUrl = answers.apiBase;
@@ -28163,7 +28415,7 @@ function createProgram() {
28163
28415
  });
28164
28416
  const configCmd = program2.command("config").description(t("cli.manage_config"));
28165
28417
  configCmd.command("set").argument("<key>", t("cli.config_key")).argument("<value>", "Config value").description(t("cli.set_value")).action(async (key, value) => {
28166
- const configPath = join37(homedir15(), ".mma", "config.json");
28418
+ const configPath = join38(homedir15(), ".mma", "config.json");
28167
28419
  const { config } = await bootstrap();
28168
28420
  const keys = key.split(".");
28169
28421
  let obj = config;
@@ -28226,7 +28478,7 @@ function createProgram() {
28226
28478
  console.log(t("cli.model_hint"));
28227
28479
  });
28228
28480
  model.command("use").argument("<name>", "Model name").description(t("cli.set_model")).action(async (name) => {
28229
- const configPath = join37(homedir15(), ".mma", "config.json");
28481
+ const configPath = join38(homedir15(), ".mma", "config.json");
28230
28482
  const { config } = await bootstrap();
28231
28483
  config.model = name;
28232
28484
  saveConfig(config, configPath);
@@ -28262,7 +28514,7 @@ function createProgram() {
28262
28514
  await uncertify2(name, config);
28263
28515
  });
28264
28516
  program2.command("context").description(t("cli.manage_context")).argument("<size>", "Context window size in tokens").action(async (size) => {
28265
- const configPath = join37(homedir15(), ".mma", "config.json");
28517
+ const configPath = join38(homedir15(), ".mma", "config.json");
28266
28518
  const { config } = await bootstrap();
28267
28519
  const contextWindow = parseInt(size, 10);
28268
28520
  if (isNaN(contextWindow) || contextWindow < 1024) {
@@ -28280,7 +28532,7 @@ function createProgram() {
28280
28532
  console.log(t("cli.base_url"), config.provider.baseUrl);
28281
28533
  });
28282
28534
  provider.command("use").argument("<name>", "Provider name").description(t("cli.set_provider")).action(async (name) => {
28283
- const configPath = join37(homedir15(), ".mma", "config.json");
28535
+ const configPath = join38(homedir15(), ".mma", "config.json");
28284
28536
  const { config } = await bootstrap();
28285
28537
  config.provider.type = name;
28286
28538
  saveConfig(config, configPath);
@@ -28333,9 +28585,9 @@ init_bootstrap();
28333
28585
  init_colors();
28334
28586
  import * as readline2 from "readline";
28335
28587
  import { existsSync as existsSync45, readFileSync as readFileSync31, writeFileSync as writeFileSync16 } from "fs";
28336
- import { join as join39, dirname as dirname12 } from "path";
28588
+ import { join as join40, dirname as dirname13 } from "path";
28337
28589
  import { homedir as homedir17 } from "os";
28338
- import { fileURLToPath as fileURLToPath4 } from "url";
28590
+ import { fileURLToPath as fileURLToPath5 } from "url";
28339
28591
 
28340
28592
  // src/cli/completer.ts
28341
28593
  class SlashCommandProvider {
@@ -28845,10 +29097,10 @@ init_box();
28845
29097
  init_i18n();
28846
29098
  init_repl_commands();
28847
29099
  function readVersion4() {
28848
- const here = dirname12(fileURLToPath4(import.meta.url));
29100
+ const here = dirname13(fileURLToPath5(import.meta.url));
28849
29101
  const candidates = [
28850
- join39(here, "..", "..", "package.json"),
28851
- join39(here, "..", "package.json")
29102
+ join40(here, "..", "..", "package.json"),
29103
+ join40(here, "..", "package.json")
28852
29104
  ];
28853
29105
  for (const p of candidates) {
28854
29106
  if (existsSync45(p)) {
@@ -28907,10 +29159,10 @@ class Repl {
28907
29159
  this.skillsModule = skillsModule;
28908
29160
  this.pluginManager = pluginManager;
28909
29161
  this.logger = logger;
28910
- this.configDir = configDir || join39(homedir17(), ".mma");
29162
+ this.configDir = configDir || join40(homedir17(), ".mma");
28911
29163
  this.baseDir = baseDir || process.cwd();
28912
29164
  this.noAgentsMd = noAgentsMd === true;
28913
- this.historyPath = join39(homedir17(), ".mma", "repl-history");
29165
+ this.historyPath = join40(homedir17(), ".mma", "repl-history");
28914
29166
  this.loadHistory();
28915
29167
  this.rl = readline2.createInterface({
28916
29168
  input: process.stdin,
@@ -29264,9 +29516,9 @@ ${t("image.clipboard_empty")}`));
29264
29516
  row(t("repl.agents_label"), pc2.red(t("repl.disabled")));
29265
29517
  } else {
29266
29518
  const agentsMdCandidates = [
29267
- join39(this.baseDir, "AGENTS.md"),
29268
- join39(this.baseDir, ".mma", "AGENTS.md"),
29269
- join39(this.configDir, "AGENTS.md")
29519
+ join40(this.baseDir, "AGENTS.md"),
29520
+ join40(this.baseDir, ".mma", "AGENTS.md"),
29521
+ join40(this.configDir, "AGENTS.md")
29270
29522
  ];
29271
29523
  const foundAgents = agentsMdCandidates.filter((p) => existsSync45(p));
29272
29524
  if (foundAgents.length > 0) {
@@ -29279,7 +29531,7 @@ ${t("image.clipboard_empty")}`));
29279
29531
  }
29280
29532
  const meta = this.sessionManager?.getActiveMeta();
29281
29533
  if (meta) {
29282
- const sessionPath = join39(this.configDir, "sessions", meta.id);
29534
+ const sessionPath = join40(this.configDir, "sessions", meta.id);
29283
29535
  row(t("repl.session_label"), `${pc2.cyan(meta.name)} ${pc2.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc2.dim(sessionPath)}`);
29284
29536
  }
29285
29537
  const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
@@ -29306,9 +29558,9 @@ init_config2();
29306
29558
  init_i18n();
29307
29559
  init_colors();
29308
29560
  import { existsSync as existsSync46, readFileSync as readFileSync32 } from "fs";
29309
- import { join as join40, dirname as dirname13 } from "path";
29561
+ import { join as join41, dirname as dirname14 } from "path";
29310
29562
  import { homedir as homedir18 } from "os";
29311
- import { fileURLToPath as fileURLToPath5 } from "url";
29563
+ import { fileURLToPath as fileURLToPath6 } from "url";
29312
29564
 
29313
29565
  // src/modules/updater/checker.ts
29314
29566
  var defaultRunner2 = async (command, args, options) => {
@@ -29457,10 +29709,10 @@ class UpdaterModule {
29457
29709
  }
29458
29710
  // src/cli/main.ts
29459
29711
  function readVersion5() {
29460
- const here = dirname13(fileURLToPath5(import.meta.url));
29712
+ const here = dirname14(fileURLToPath6(import.meta.url));
29461
29713
  const candidates = [
29462
- join40(here, "..", "..", "package.json"),
29463
- join40(here, "..", "package.json")
29714
+ join41(here, "..", "..", "package.json"),
29715
+ join41(here, "..", "package.json")
29464
29716
  ];
29465
29717
  for (const p of candidates) {
29466
29718
  if (existsSync46(p)) {
@@ -29545,15 +29797,15 @@ async function main() {
29545
29797
  }
29546
29798
  agent.shutdown();
29547
29799
  } else {
29548
- const configPath = join40(homedir18(), ".mma", "config.json");
29800
+ const configPath = join41(homedir18(), ".mma", "config.json");
29549
29801
  if (!existsSync46(configPath)) {
29550
29802
  console.log(pc2.yellow(`
29551
29803
  ` + t("cli.first_run") + `
29552
29804
  `));
29553
29805
  const answers = await runSetup();
29554
29806
  const config2 = loadConfig({
29555
- configDir: join40(homedir18(), ".mma"),
29556
- projectConfigPath: projectDir ? join40(projectDir, ".mmrc") : join40(process.cwd(), ".mmrc")
29807
+ configDir: join41(homedir18(), ".mma"),
29808
+ projectConfigPath: projectDir ? join41(projectDir, ".mmrc") : join41(process.cwd(), ".mmrc")
29557
29809
  });
29558
29810
  config2.provider.type = answers.provider;
29559
29811
  config2.provider.baseUrl = answers.apiBase;