@2kw/ai 6.3.0-dev.2 → 6.3.0-dev.3
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/commands/relays.d.ts +3 -0
- package/dist/commands/relays.js +135 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { getClient, runAction } from "../lib/client.js";
|
|
3
|
+
import { isJsonOutput } from "../lib/config.js";
|
|
4
|
+
import { formatDetail, formatPage, formatSuccess } from "../lib/output.js";
|
|
5
|
+
import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
|
|
6
|
+
/**
|
|
7
|
+
* Prints an enrolment response in text mode. The relay record comes first when the response
|
|
8
|
+
* carries one: `create` is the only place the new relay's id is ever shown, and every other
|
|
9
|
+
* subcommand takes that id as its argument.
|
|
10
|
+
*/
|
|
11
|
+
function printEnrolment(data, command) {
|
|
12
|
+
if (isJsonOutput(command)) {
|
|
13
|
+
console.log(JSON.stringify(data, null, 2));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (data.relay) {
|
|
17
|
+
formatDetail(data.relay, command);
|
|
18
|
+
console.log("");
|
|
19
|
+
}
|
|
20
|
+
console.log(data.enrolmentExpiresAt
|
|
21
|
+
? `Enrolment token (shown once, valid until ${data.enrolmentExpiresAt}):`
|
|
22
|
+
: "Enrolment token (shown once):");
|
|
23
|
+
console.log(` ${data.enrolmentToken ?? ""}`);
|
|
24
|
+
console.log("");
|
|
25
|
+
console.log("Run the relay inside your network:");
|
|
26
|
+
console.log(data.dockerRun ?? "");
|
|
27
|
+
}
|
|
28
|
+
export function makeRelaysCommand() {
|
|
29
|
+
const cmd = new Command("relays").description("Manage MCP relays that reach MCP servers on private networks");
|
|
30
|
+
const list = new Command("list").description("List MCP relays");
|
|
31
|
+
addPaginationOptions(list);
|
|
32
|
+
list.action(async (opts, command) => {
|
|
33
|
+
await runAction(command, async () => {
|
|
34
|
+
const client = getClient(command);
|
|
35
|
+
const { data } = await client.GET("/v1/mcp-relays", {
|
|
36
|
+
params: { query: { ...paginationParams(opts) } },
|
|
37
|
+
});
|
|
38
|
+
formatPage(data, command, [
|
|
39
|
+
"id",
|
|
40
|
+
"name",
|
|
41
|
+
"status",
|
|
42
|
+
"online",
|
|
43
|
+
"relayVersion",
|
|
44
|
+
"inventoryReportedAt",
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
cmd.addCommand(list);
|
|
49
|
+
cmd
|
|
50
|
+
.command("get")
|
|
51
|
+
.description("Show a relay with its inventory")
|
|
52
|
+
.argument("<id>", "Relay ID")
|
|
53
|
+
.action(async (id, _opts, command) => {
|
|
54
|
+
await runAction(command, async () => {
|
|
55
|
+
const client = getClient(command);
|
|
56
|
+
const { data } = await client.GET("/v1/mcp-relays/{id}", {
|
|
57
|
+
params: { path: { id } },
|
|
58
|
+
});
|
|
59
|
+
formatDetail(data, command);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
cmd
|
|
63
|
+
.command("create")
|
|
64
|
+
.description("Create a relay; prints a single-use enrolment token and a docker run snippet")
|
|
65
|
+
.requiredOption("--name <name>", 'Display name, e.g. "Office Berlin"')
|
|
66
|
+
.action(async (opts, command) => {
|
|
67
|
+
await runAction(command, async () => {
|
|
68
|
+
const client = getClient(command);
|
|
69
|
+
const { data } = await client.POST("/v1/mcp-relays", {
|
|
70
|
+
body: { name: opts.name },
|
|
71
|
+
});
|
|
72
|
+
printEnrolment(data ?? {}, command);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
cmd
|
|
76
|
+
.command("rename")
|
|
77
|
+
.description("Rename a relay")
|
|
78
|
+
.argument("<id>", "Relay ID")
|
|
79
|
+
.requiredOption("--name <name>", "New name")
|
|
80
|
+
.action(async (id, opts, command) => {
|
|
81
|
+
await runAction(command, async () => {
|
|
82
|
+
const client = getClient(command);
|
|
83
|
+
const { data } = await client.PATCH("/v1/mcp-relays/{id}", {
|
|
84
|
+
params: { path: { id } },
|
|
85
|
+
body: { name: opts.name },
|
|
86
|
+
});
|
|
87
|
+
formatDetail(data, command);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
for (const [name, disabled, description] of [
|
|
91
|
+
["disable", true, "Disable a relay: it gets no new work and its enrolment token is voided"],
|
|
92
|
+
["enable", false, "Enable a disabled relay"],
|
|
93
|
+
]) {
|
|
94
|
+
cmd
|
|
95
|
+
.command(name)
|
|
96
|
+
.description(description)
|
|
97
|
+
.argument("<id>", "Relay ID")
|
|
98
|
+
.action(async (id, _opts, command) => {
|
|
99
|
+
await runAction(command, async () => {
|
|
100
|
+
const client = getClient(command);
|
|
101
|
+
const { data } = await client.PATCH("/v1/mcp-relays/{id}", {
|
|
102
|
+
params: { path: { id } },
|
|
103
|
+
body: { disabled },
|
|
104
|
+
});
|
|
105
|
+
formatDetail(data, command);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
cmd
|
|
110
|
+
.command("re-enrol")
|
|
111
|
+
.description("Issue a new enrolment token; redeeming it replaces the relay's key")
|
|
112
|
+
.argument("<id>", "Relay ID")
|
|
113
|
+
.action(async (id, _opts, command) => {
|
|
114
|
+
await runAction(command, async () => {
|
|
115
|
+
const client = getClient(command);
|
|
116
|
+
const { data } = await client.POST("/v1/mcp-relays/{id}/enrolment-token", {
|
|
117
|
+
params: { path: { id } },
|
|
118
|
+
});
|
|
119
|
+
printEnrolment(data ?? {}, command);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
cmd
|
|
123
|
+
.command("delete")
|
|
124
|
+
.description("Revoke a relay for good")
|
|
125
|
+
.argument("<id>", "Relay ID")
|
|
126
|
+
.action(async (id, _opts, command) => {
|
|
127
|
+
await runAction(command, async () => {
|
|
128
|
+
const client = getClient(command);
|
|
129
|
+
await client.DELETE("/v1/mcp-relays/{id}", { params: { path: { id } } });
|
|
130
|
+
formatSuccess(`Relay ${id} revoked.`, command);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
return cmd;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=relays.js.map
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import { makeConversationsCommand } from "./commands/conversations.js";
|
|
|
29
29
|
import { makeKnowledgeCommand } from "./commands/knowledge.js";
|
|
30
30
|
import { makeFilesCommand } from "./commands/files.js";
|
|
31
31
|
import { makeInstallationsCommand } from "./commands/installations.js";
|
|
32
|
+
import { makeRelaysCommand } from "./commands/relays.js";
|
|
32
33
|
import { checkForUpdates } from "./lib/update-notifier.js";
|
|
33
34
|
const updater = checkForUpdates(pkg.version);
|
|
34
35
|
const program = new Command();
|
|
@@ -65,6 +66,7 @@ program.addCommand(makeConversationsCommand());
|
|
|
65
66
|
program.addCommand(makeKnowledgeCommand());
|
|
66
67
|
program.addCommand(makeFilesCommand());
|
|
67
68
|
program.addCommand(makeInstallationsCommand());
|
|
69
|
+
program.addCommand(makeRelaysCommand());
|
|
68
70
|
program.addCommand(makeDocsCommand());
|
|
69
71
|
program.parseAsync().then(() => updater.notify());
|
|
70
72
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai",
|
|
3
|
-
"version": "6.3.0-dev.
|
|
3
|
+
"version": "6.3.0-dev.3",
|
|
4
4
|
"description": "CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|