@zenlayer/lune-mcp 0.0.0-stage → 1.1.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/README.md +253 -2
- package/dist/chunk-2UUMFH2N.js +357 -0
- package/dist/chunk-3OSHCYWX.js +97 -0
- package/dist/chunk-4UMZU6R2.js +11 -0
- package/dist/chunk-6CLUCGIJ.js +125 -0
- package/dist/chunk-JFOGRJQA.js +289 -0
- package/dist/chunk-MC3S3YL6.js +11 -0
- package/dist/chunk-NBO4ZVRK.js +403 -0
- package/dist/chunk-PQYX44KQ.js +28 -0
- package/dist/chunk-QASEPHOI.js +158 -0
- package/dist/cli.js +61 -0
- package/dist/doctor-M5AXEIYG.js +371 -0
- package/dist/index.js +10243 -0
- package/dist/install-7XAHE2K6.js +277 -0
- package/dist/login-FNMGXSJT.js +54 -0
- package/dist/logout-4ICTJPUQ.js +36 -0
- package/dist/main-47XGXIDD.js +9180 -0
- package/dist/oauth-login-47OUBG5B.js +23 -0
- package/dist/remote.js +10150 -0
- package/package.json +66 -4
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
allAdapters,
|
|
4
|
+
findAdapter,
|
|
5
|
+
stdioCommand
|
|
6
|
+
} from "./chunk-NBO4ZVRK.js";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_REMOTE_URL
|
|
9
|
+
} from "./chunk-PQYX44KQ.js";
|
|
10
|
+
import {
|
|
11
|
+
CLI_INVOKE
|
|
12
|
+
} from "./chunk-4UMZU6R2.js";
|
|
13
|
+
import {
|
|
14
|
+
BRAND_NAME,
|
|
15
|
+
SERVER_NAME
|
|
16
|
+
} from "./chunk-3OSHCYWX.js";
|
|
17
|
+
|
|
18
|
+
// src/cli/install/multi-select.ts
|
|
19
|
+
import { emitKeypressEvents } from "readline";
|
|
20
|
+
var HINT = "\u2191\u2193 move \xB7 space toggle \xB7 enter confirm \xB7 a all \xB7 q cancel";
|
|
21
|
+
async function multiSelect(title, items, streams = {}) {
|
|
22
|
+
const input = streams.input ?? process.stdin;
|
|
23
|
+
const output = streams.output ?? process.stderr;
|
|
24
|
+
const checked = items.map((i) => i.disabled ? false : i.checked);
|
|
25
|
+
const selectable = items.flatMap((it, i) => it.disabled ? [] : [i]);
|
|
26
|
+
if (selectable.length === 0) return null;
|
|
27
|
+
let cursor = selectable[0];
|
|
28
|
+
let rendered = 0;
|
|
29
|
+
let notice = "";
|
|
30
|
+
const render = () => {
|
|
31
|
+
if (rendered > 0) output.write(`\x1B[${rendered}A\x1B[J`);
|
|
32
|
+
const lines = [
|
|
33
|
+
`${title} (${HINT})`,
|
|
34
|
+
...items.map((item, i) => {
|
|
35
|
+
if (item.disabled) return ` ${item.label}`;
|
|
36
|
+
return `${i === cursor ? ">" : " "} ${checked[i] ? "[\u2713]" : "[ ]"} ${item.label}`;
|
|
37
|
+
})
|
|
38
|
+
];
|
|
39
|
+
if (notice) lines.push(notice);
|
|
40
|
+
output.write(`${lines.join("\n")}
|
|
41
|
+
`);
|
|
42
|
+
rendered = lines.length;
|
|
43
|
+
};
|
|
44
|
+
const move = (dir) => {
|
|
45
|
+
const pos = selectable.indexOf(cursor);
|
|
46
|
+
cursor = selectable[(pos + dir + selectable.length) % selectable.length];
|
|
47
|
+
};
|
|
48
|
+
emitKeypressEvents(input);
|
|
49
|
+
const wasRaw = input.isRaw === true;
|
|
50
|
+
if (input.isTTY && !wasRaw) input.setRawMode(true);
|
|
51
|
+
input.resume();
|
|
52
|
+
output.write("\x1B[?25l");
|
|
53
|
+
render();
|
|
54
|
+
return await new Promise((resolve) => {
|
|
55
|
+
const cleanup = () => {
|
|
56
|
+
input.off("keypress", onKey);
|
|
57
|
+
if (input.isTTY && !wasRaw) input.setRawMode(false);
|
|
58
|
+
input.pause();
|
|
59
|
+
output.write("\x1B[?25h");
|
|
60
|
+
};
|
|
61
|
+
const onKey = (_str, key) => {
|
|
62
|
+
const name = key?.name ?? "";
|
|
63
|
+
notice = "";
|
|
64
|
+
if (key?.ctrl && name === "c" || name === "q" || name === "escape") {
|
|
65
|
+
cleanup();
|
|
66
|
+
resolve(null);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (name === "up" || name === "k") {
|
|
70
|
+
move(-1);
|
|
71
|
+
} else if (name === "down" || name === "j") {
|
|
72
|
+
move(1);
|
|
73
|
+
} else if (name === "space") {
|
|
74
|
+
checked[cursor] = !checked[cursor];
|
|
75
|
+
} else if (name === "a") {
|
|
76
|
+
const all = selectable.every((i) => checked[i]);
|
|
77
|
+
for (const i of selectable) checked[i] = !all;
|
|
78
|
+
} else if (name === "return" || name === "enter") {
|
|
79
|
+
const picked = checked.flatMap((c, i) => c ? [i] : []);
|
|
80
|
+
if (picked.length === 0) {
|
|
81
|
+
notice = "Select at least one (space to toggle), or press q to cancel.";
|
|
82
|
+
render();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
cleanup();
|
|
86
|
+
resolve(picked);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
render();
|
|
90
|
+
};
|
|
91
|
+
input.on("keypress", onKey);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
var SINGLE_HINT = "\u2191\u2193 move \xB7 enter confirm \xB7 q cancel";
|
|
95
|
+
async function singleSelect(title, labels, streams = {}) {
|
|
96
|
+
const input = streams.input ?? process.stdin;
|
|
97
|
+
const output = streams.output ?? process.stderr;
|
|
98
|
+
if (labels.length === 0) return null;
|
|
99
|
+
let cursor = 0;
|
|
100
|
+
let rendered = 0;
|
|
101
|
+
const render = () => {
|
|
102
|
+
if (rendered > 0) output.write(`\x1B[${rendered}A\x1B[J`);
|
|
103
|
+
const lines = [
|
|
104
|
+
`${title} (${SINGLE_HINT})`,
|
|
105
|
+
...labels.map((label, i) => `${i === cursor ? ">" : " "} ${label}`)
|
|
106
|
+
];
|
|
107
|
+
output.write(`${lines.join("\n")}
|
|
108
|
+
`);
|
|
109
|
+
rendered = lines.length;
|
|
110
|
+
};
|
|
111
|
+
emitKeypressEvents(input);
|
|
112
|
+
const wasRaw = input.isRaw === true;
|
|
113
|
+
if (input.isTTY && !wasRaw) input.setRawMode(true);
|
|
114
|
+
input.resume();
|
|
115
|
+
output.write("\x1B[?25l");
|
|
116
|
+
render();
|
|
117
|
+
return await new Promise((resolve) => {
|
|
118
|
+
const cleanup = () => {
|
|
119
|
+
input.off("keypress", onKey);
|
|
120
|
+
if (input.isTTY && !wasRaw) input.setRawMode(false);
|
|
121
|
+
input.pause();
|
|
122
|
+
output.write("\x1B[?25h");
|
|
123
|
+
};
|
|
124
|
+
const onKey = (_str, key) => {
|
|
125
|
+
const name = key?.name ?? "";
|
|
126
|
+
if (key?.ctrl && name === "c" || name === "q" || name === "escape") {
|
|
127
|
+
cleanup();
|
|
128
|
+
resolve(null);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (name === "up" || name === "k") cursor = (cursor + labels.length - 1) % labels.length;
|
|
132
|
+
else if (name === "down" || name === "j") cursor = (cursor + 1) % labels.length;
|
|
133
|
+
else if (name === "return" || name === "enter") {
|
|
134
|
+
cleanup();
|
|
135
|
+
resolve(cursor);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
render();
|
|
139
|
+
};
|
|
140
|
+
input.on("keypress", onKey);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/cli/commands/install.ts
|
|
145
|
+
var SCOPE_LABELS = [
|
|
146
|
+
{ value: "user", label: "user \u2014 global, applies to all projects" },
|
|
147
|
+
{ value: "project", label: "project \u2014 this project only (current directory)" }
|
|
148
|
+
];
|
|
149
|
+
async function installCommand(clients, opts, deps = {}) {
|
|
150
|
+
const print = deps.print ?? ((line) => void process.stderr.write(`${line}
|
|
151
|
+
`));
|
|
152
|
+
const interactive = deps.isTTY ?? process.stdin.isTTY === true;
|
|
153
|
+
if (opts.stdio && opts.url !== void 0) {
|
|
154
|
+
print(
|
|
155
|
+
"--url only applies to the remote mode (the default); --stdio writes a local launch command. The two cannot be combined."
|
|
156
|
+
);
|
|
157
|
+
return 1;
|
|
158
|
+
}
|
|
159
|
+
if (opts.scope !== void 0 && opts.scope !== "user" && opts.scope !== "project") {
|
|
160
|
+
print(`--scope must be user or project: '${opts.scope}'`);
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
let chosen;
|
|
164
|
+
if (opts.all) {
|
|
165
|
+
const targets = [];
|
|
166
|
+
for (const adapter of allAdapters(deps)) {
|
|
167
|
+
if (await adapter.detect()) targets.push(adapter);
|
|
168
|
+
else print(`\u26A0\uFE0F ${adapter.label}: not detected, skipped`);
|
|
169
|
+
}
|
|
170
|
+
if (targets.length === 0) return 0;
|
|
171
|
+
chosen = targets;
|
|
172
|
+
} else if (clients.length > 0) {
|
|
173
|
+
const targets = [];
|
|
174
|
+
for (const id of clients) {
|
|
175
|
+
const adapter = findAdapter(id, deps);
|
|
176
|
+
if (!adapter) {
|
|
177
|
+
print(`Unknown client '${id}'. Available: ${ids(deps).join(", ")}`);
|
|
178
|
+
return 1;
|
|
179
|
+
}
|
|
180
|
+
targets.push(adapter);
|
|
181
|
+
}
|
|
182
|
+
for (const adapter of targets) {
|
|
183
|
+
if (!await adapter.detect()) print(`\u26A0\uFE0F ${adapter.label}: not detected (writing config anyway)`);
|
|
184
|
+
}
|
|
185
|
+
chosen = targets;
|
|
186
|
+
} else {
|
|
187
|
+
if (!interactive) {
|
|
188
|
+
print(
|
|
189
|
+
`Usage: ${CLI_INVOKE} install <client...> [--scope user|project] or install --all. Available clients: ${ids(deps).join(", ")}`
|
|
190
|
+
);
|
|
191
|
+
return 1;
|
|
192
|
+
}
|
|
193
|
+
const picked = await pickClients(deps, print);
|
|
194
|
+
if (picked === null) return 1;
|
|
195
|
+
chosen = picked;
|
|
196
|
+
}
|
|
197
|
+
let scope;
|
|
198
|
+
if (opts.scope === "user" || opts.scope === "project") {
|
|
199
|
+
scope = opts.scope;
|
|
200
|
+
} else {
|
|
201
|
+
if (!interactive) {
|
|
202
|
+
print(
|
|
203
|
+
"Missing --scope (user = global / project = current directory). Non-interactive runs must pass --scope explicitly."
|
|
204
|
+
);
|
|
205
|
+
return 1;
|
|
206
|
+
}
|
|
207
|
+
const selectOne = deps.selectOne ?? ((title, labels) => singleSelect(title, labels));
|
|
208
|
+
const idx = await selectOne(
|
|
209
|
+
"Select install scope",
|
|
210
|
+
SCOPE_LABELS.map((s) => s.label)
|
|
211
|
+
);
|
|
212
|
+
const entry = idx === null ? void 0 : SCOPE_LABELS[idx];
|
|
213
|
+
if (!entry) {
|
|
214
|
+
print("Canceled.");
|
|
215
|
+
return 1;
|
|
216
|
+
}
|
|
217
|
+
scope = entry.value;
|
|
218
|
+
}
|
|
219
|
+
const spec = opts.stdio ? { serverName: SERVER_NAME, scope, transport: "stdio", ...stdioCommand(deps.platform) } : { serverName: SERVER_NAME, scope, transport: "remote", url: opts.url ?? DEFAULT_REMOTE_URL };
|
|
220
|
+
let failed = 0;
|
|
221
|
+
for (const adapter of chosen) {
|
|
222
|
+
failed += await installOne(adapter, spec, print) ? 0 : 1;
|
|
223
|
+
}
|
|
224
|
+
return failed > 0 ? 1 : 0;
|
|
225
|
+
}
|
|
226
|
+
async function pickClients(deps, print) {
|
|
227
|
+
const adapters = allAdapters(deps);
|
|
228
|
+
const detected = await Promise.all(adapters.map((a) => a.detect()));
|
|
229
|
+
const items = adapters.map((a, i) => ({
|
|
230
|
+
label: `${detected[i] ? "\u2705 detected" : "\u274C not detected"} ${a.label} (${a.id})`,
|
|
231
|
+
checked: detected[i] === true,
|
|
232
|
+
// 默认勾选全部已检测到的,回车即装
|
|
233
|
+
disabled: detected[i] !== true
|
|
234
|
+
// 未检测到不可勾选;要装它得点名 install <client>
|
|
235
|
+
}));
|
|
236
|
+
if (items.every((it) => it.disabled)) {
|
|
237
|
+
print(
|
|
238
|
+
`No MCP clients detected. Use ${CLI_INVOKE} install <client> to target one explicitly (it will try even if not detected).`
|
|
239
|
+
);
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const selectMulti = deps.selectMulti ?? ((title, its) => multiSelect(title, its));
|
|
243
|
+
const picked = await selectMulti(`Select MCP clients to write the ${BRAND_NAME} config to`, items);
|
|
244
|
+
if (picked === null) {
|
|
245
|
+
print("Canceled.");
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
return picked.map((i) => adapters[i]).filter((a) => a !== void 0);
|
|
249
|
+
}
|
|
250
|
+
function unsupported(adapter, spec) {
|
|
251
|
+
const manual = (fallback) => ({
|
|
252
|
+
ok: false,
|
|
253
|
+
manual: true,
|
|
254
|
+
detail: adapter.manualHint?.(spec) ?? fallback
|
|
255
|
+
});
|
|
256
|
+
if (spec.transport === "remote" && !adapter.capabilities.remote) {
|
|
257
|
+
return manual(
|
|
258
|
+
`${adapter.label} does not support writing a remote MCP config \u2014 use --stdio to install the local mode instead.`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
if (spec.scope === "project" && !adapter.capabilities.projectScope) {
|
|
262
|
+
return manual(`${adapter.label} only has a global config (no project scope) \u2014 use --scope user instead.`);
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
async function installOne(adapter, spec, print) {
|
|
267
|
+
const result = unsupported(adapter, spec) ?? await adapter.install(spec);
|
|
268
|
+
const icon = result.ok ? "\u2705" : result.manual ? "\u26A0\uFE0F" : "\u274C";
|
|
269
|
+
print(`${icon} ${adapter.label}: ${result.detail}`);
|
|
270
|
+
return result.ok || result.manual === true;
|
|
271
|
+
}
|
|
272
|
+
function ids(deps) {
|
|
273
|
+
return allAdapters(deps).map((a) => a.id);
|
|
274
|
+
}
|
|
275
|
+
export {
|
|
276
|
+
installCommand
|
|
277
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runLoginFlow
|
|
4
|
+
} from "./chunk-JFOGRJQA.js";
|
|
5
|
+
import {
|
|
6
|
+
NO_STORE_HINT,
|
|
7
|
+
openCredentialStore
|
|
8
|
+
} from "./chunk-6CLUCGIJ.js";
|
|
9
|
+
import "./chunk-MC3S3YL6.js";
|
|
10
|
+
import "./chunk-2UUMFH2N.js";
|
|
11
|
+
import {
|
|
12
|
+
apiBase,
|
|
13
|
+
asIssuer
|
|
14
|
+
} from "./chunk-PQYX44KQ.js";
|
|
15
|
+
import "./chunk-4UMZU6R2.js";
|
|
16
|
+
import {
|
|
17
|
+
BRAND_NAME
|
|
18
|
+
} from "./chunk-3OSHCYWX.js";
|
|
19
|
+
|
|
20
|
+
// src/cli/commands/login.ts
|
|
21
|
+
async function loginCommand(opts) {
|
|
22
|
+
const print = (msg) => void process.stderr.write(`${msg}
|
|
23
|
+
`);
|
|
24
|
+
const store = await openCredentialStore();
|
|
25
|
+
if (!store) {
|
|
26
|
+
print(NO_STORE_HINT);
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
if (store.kind === "file") {
|
|
30
|
+
print("Note: using plaintext file storage (LUNE_MCP_ALLOW_FILE_CREDENTIALS=1).");
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const result = await runLoginFlow({
|
|
34
|
+
asIssuer: asIssuer(),
|
|
35
|
+
apiBase: apiBase(),
|
|
36
|
+
store,
|
|
37
|
+
noBrowser: opts.noBrowser === true,
|
|
38
|
+
print
|
|
39
|
+
});
|
|
40
|
+
print(
|
|
41
|
+
`Signed in: ${result.userId}${result.isSupplier ? " (supplier account; supplier toolset enabled)" : ""}${result.scopes ? ` scopes=${result.scopes}` : ""}`
|
|
42
|
+
);
|
|
43
|
+
print(
|
|
44
|
+
"Credentials stored in " + (store.kind === "keychain" ? "the system keychain" : "a local file") + `. The ${BRAND_NAME} tools in your MCP client are ready to use (the client launches stdio automatically).`
|
|
45
|
+
);
|
|
46
|
+
return 0;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
print(`Sign-in failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
loginCommand
|
|
54
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runLogout
|
|
4
|
+
} from "./chunk-JFOGRJQA.js";
|
|
5
|
+
import {
|
|
6
|
+
NO_STORE_HINT,
|
|
7
|
+
openCredentialStore
|
|
8
|
+
} from "./chunk-6CLUCGIJ.js";
|
|
9
|
+
import "./chunk-MC3S3YL6.js";
|
|
10
|
+
import "./chunk-2UUMFH2N.js";
|
|
11
|
+
import {
|
|
12
|
+
apiBase
|
|
13
|
+
} from "./chunk-PQYX44KQ.js";
|
|
14
|
+
import "./chunk-4UMZU6R2.js";
|
|
15
|
+
import "./chunk-3OSHCYWX.js";
|
|
16
|
+
|
|
17
|
+
// src/cli/commands/logout.ts
|
|
18
|
+
async function logoutCommand() {
|
|
19
|
+
const print = (msg) => void process.stderr.write(`${msg}
|
|
20
|
+
`);
|
|
21
|
+
const store = await openCredentialStore();
|
|
22
|
+
if (!store) {
|
|
23
|
+
print(NO_STORE_HINT);
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
await runLogout({ store, apiBase: apiBase(), print });
|
|
28
|
+
return 0;
|
|
29
|
+
} catch (err) {
|
|
30
|
+
print(`Sign-out failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
logoutCommand
|
|
36
|
+
};
|