@getmikie/cli 1.1.72
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/README.md +18 -0
- package/bin/mikie.mjs +36 -0
- package/lib/launcher.mjs +124 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Mikie
|
|
2
|
+
|
|
3
|
+
This package is a thin launcher for Mikie's compiled native relay.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx -y @getmikie/cli mcp
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
For a persistent command path:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install --global @getmikie/cli
|
|
13
|
+
mikie mcp
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The launcher contains no relay, pricing, receipt, or model logic. npm installs
|
|
17
|
+
the matching `@getmikie/*` optional platform package and the launcher executes that
|
|
18
|
+
binary with inherited stdio.
|
package/bin/mikie.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
launchNative,
|
|
7
|
+
resolveNativeBinary,
|
|
8
|
+
translateArguments,
|
|
9
|
+
} from "../lib/launcher.mjs";
|
|
10
|
+
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const packageMetadata = require("../package.json");
|
|
13
|
+
const arguments_ = process.argv.slice(2);
|
|
14
|
+
|
|
15
|
+
if (arguments_.length === 1 && ["--version", "-v"].includes(arguments_[0])) {
|
|
16
|
+
console.log(packageMetadata.version);
|
|
17
|
+
} else if (arguments_.length === 1 && ["--help", "-h"].includes(arguments_[0])) {
|
|
18
|
+
console.log(`Mikie ${packageMetadata.version}
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
mikie mcp [--adapter codex|claude_code]
|
|
22
|
+
mikie login
|
|
23
|
+
mikie connect .
|
|
24
|
+
mikie doctor
|
|
25
|
+
|
|
26
|
+
All commands execute the compiled Mikie native engine.`);
|
|
27
|
+
} else {
|
|
28
|
+
try {
|
|
29
|
+
const binary = await resolveNativeBinary();
|
|
30
|
+
process.exitCode = await launchNative(binary, translateArguments(arguments_));
|
|
31
|
+
} catch (error) {
|
|
32
|
+
const message = error instanceof Error ? error.message : "Mikie is unavailable";
|
|
33
|
+
console.error(`mikie: ${message}`);
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/lib/launcher.mjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { access, stat } from "node:fs/promises";
|
|
3
|
+
import { constants as fsConstants } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
const PLATFORM_PACKAGES = new Map([
|
|
8
|
+
["win32-x64", { packageName: "@getmikie/win32-x64", binaryPath: "bin/mikie.exe" }],
|
|
9
|
+
["darwin-arm64", { packageName: "@getmikie/darwin-arm64", binaryPath: "bin/mikie" }],
|
|
10
|
+
["darwin-x64", { packageName: "@getmikie/darwin-x64", binaryPath: "bin/mikie" }],
|
|
11
|
+
["linux-x64-gnu", { packageName: "@getmikie/linux-x64-gnu", binaryPath: "bin/mikie" }],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const SIGNAL_EXIT_CODES = new Map([
|
|
15
|
+
["SIGHUP", 129],
|
|
16
|
+
["SIGINT", 130],
|
|
17
|
+
["SIGTERM", 143],
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
function currentRuntimeUsesGlibc() {
|
|
21
|
+
try {
|
|
22
|
+
const report = process.report?.getReport();
|
|
23
|
+
return Boolean(report?.header?.glibcVersionRuntime);
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function selectPlatformPackage({
|
|
30
|
+
platform = process.platform,
|
|
31
|
+
arch = process.arch,
|
|
32
|
+
glibc = platform === "linux" ? currentRuntimeUsesGlibc() : undefined,
|
|
33
|
+
} = {}) {
|
|
34
|
+
const key = platform === "linux" && glibc ? `${platform}-${arch}-gnu` : `${platform}-${arch}`;
|
|
35
|
+
const selected = PLATFORM_PACKAGES.get(key);
|
|
36
|
+
if (!selected) {
|
|
37
|
+
throw new Error("Mikie does not publish a native npm engine for this platform");
|
|
38
|
+
}
|
|
39
|
+
return { ...selected };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function translateArguments(arguments_) {
|
|
43
|
+
if (arguments_[0] !== "mcp") {
|
|
44
|
+
return [...arguments_];
|
|
45
|
+
}
|
|
46
|
+
return ["serve", ...arguments_.slice(1)];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function resolveNativeBinary({
|
|
50
|
+
platform = process.platform,
|
|
51
|
+
arch = process.arch,
|
|
52
|
+
glibc,
|
|
53
|
+
resolvePackage,
|
|
54
|
+
} = {}) {
|
|
55
|
+
const selected = selectPlatformPackage({ platform, arch, glibc });
|
|
56
|
+
const require = createRequire(import.meta.url);
|
|
57
|
+
let packageJson;
|
|
58
|
+
try {
|
|
59
|
+
packageJson = (resolvePackage ?? ((name) => require.resolve(name)))(
|
|
60
|
+
`${selected.packageName}/package.json`,
|
|
61
|
+
);
|
|
62
|
+
} catch {
|
|
63
|
+
throw new Error(`Required Mikie native package ${selected.packageName} is unavailable`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const binary = path.join(path.dirname(packageJson), ...selected.binaryPath.split("/"));
|
|
67
|
+
try {
|
|
68
|
+
const metadata = await stat(binary);
|
|
69
|
+
if (!metadata.isFile() || metadata.size === 0) {
|
|
70
|
+
throw new Error("invalid binary");
|
|
71
|
+
}
|
|
72
|
+
if (platform !== "win32") {
|
|
73
|
+
await access(binary, fsConstants.X_OK);
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
throw new Error(`Required Mikie native package ${selected.packageName} is invalid`);
|
|
77
|
+
}
|
|
78
|
+
return binary;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function launchNative(
|
|
82
|
+
binary,
|
|
83
|
+
arguments_,
|
|
84
|
+
{ spawnProcess = spawn, parentProcess = process, environment = process.env } = {},
|
|
85
|
+
) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
let settled = false;
|
|
88
|
+
const child = spawnProcess(binary, arguments_, {
|
|
89
|
+
shell: false,
|
|
90
|
+
stdio: "inherit",
|
|
91
|
+
windowsHide: true,
|
|
92
|
+
env: { ...environment, MIKIE_DISTRIBUTION_MODE: "npm" },
|
|
93
|
+
});
|
|
94
|
+
const handlers = new Map();
|
|
95
|
+
const cleanup = () => {
|
|
96
|
+
for (const [signal, handler] of handlers) {
|
|
97
|
+
parentProcess.off(signal, handler);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
101
|
+
const handler = () => {
|
|
102
|
+
try {
|
|
103
|
+
child.kill(signal);
|
|
104
|
+
} catch {
|
|
105
|
+
// The native process may already have exited.
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
handlers.set(signal, handler);
|
|
109
|
+
parentProcess.on(signal, handler);
|
|
110
|
+
}
|
|
111
|
+
child.once("error", (error) => {
|
|
112
|
+
if (settled) return;
|
|
113
|
+
settled = true;
|
|
114
|
+
cleanup();
|
|
115
|
+
reject(new Error("Mikie native engine could not be started", { cause: error }));
|
|
116
|
+
});
|
|
117
|
+
child.once("exit", (code, signal) => {
|
|
118
|
+
if (settled) return;
|
|
119
|
+
settled = true;
|
|
120
|
+
cleanup();
|
|
121
|
+
resolve(Number.isInteger(code) ? code : (SIGNAL_EXIT_CODES.get(signal) ?? 1));
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getmikie/cli",
|
|
3
|
+
"version": "1.1.72",
|
|
4
|
+
"description": "Native Mikie relay launcher for MCP clients",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mikie": "bin/mikie.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"lib",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"@getmikie/darwin-arm64": "1.1.72",
|
|
20
|
+
"@getmikie/darwin-x64": "1.1.72",
|
|
21
|
+
"@getmikie/linux-x64-gnu": "1.1.72",
|
|
22
|
+
"@getmikie/win32-x64": "1.1.72"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
}
|
|
27
|
+
}
|