micro-models-agent 0.35.1 → 0.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mma.mjs +41 -8
- package/package.json +1 -1
package/bin/mma.mjs
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
|
|
6
|
+
// MMA is designed to run under Bun: clipboard image paste relies on
|
|
7
|
+
// `Bun.Image.fromClipboard()` (Node has no clipboard API), and on Windows a
|
|
8
|
+
// bare `npx.cmd` shim can only be spawned reliably through Bun's child_process
|
|
9
|
+
// (under Node it throws `spawn EINVAL`). The global npm shim (`mma` /
|
|
10
|
+
// `mma.cmd`) launches this file under Node, so re-execute ourselves under Bun
|
|
11
|
+
// when it is available. The `bun run mma` path already runs under Bun and
|
|
12
|
+
// skips the respawn.
|
|
13
|
+
const runningUnderBun =
|
|
14
|
+
typeof globalThis.Bun !== "undefined" &&
|
|
15
|
+
typeof globalThis.Bun?.version !== "undefined";
|
|
16
|
+
|
|
17
|
+
if (process.env.MMA_DEBUG_RUNTIME) {
|
|
18
|
+
console.error(
|
|
19
|
+
"[mma] runtime=" +
|
|
20
|
+
(runningUnderBun ? "bun " + globalThis.Bun.version : "node " + process.version),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!runningUnderBun) {
|
|
25
|
+
try {
|
|
26
|
+
const res = spawnSync("bun", [process.argv[1], ...process.argv.slice(2)], {
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
windowsHide: true,
|
|
29
|
+
});
|
|
30
|
+
if (res.error) throw res.error;
|
|
31
|
+
process.exit(res.status ?? 0);
|
|
32
|
+
} catch {
|
|
33
|
+
// `bun` is not on PATH — fall back to the Node import path (clipboard
|
|
34
|
+
// paste and LSP will degrade, but the agent still works).
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
39
|
+
const main = join(__dirname, "..", "dist", "main.js");
|
|
40
|
+
|
|
41
|
+
await import(pathToFileURL(main).href);
|