ftown-bridge 0.19.32 → 0.19.35
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/command-rpc.d.ts +1 -0
- package/dist/command-rpc.js +7 -0
- package/dist/command-rpc.js.map +1 -1
- package/dist/direct-shell.d.ts +1 -1
- package/dist/direct-shell.js +3 -3
- package/dist/direct-shell.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/local-api-server.d.ts +3 -0
- package/dist/local-api-server.js +31 -0
- package/dist/local-api-server.js.map +1 -1
- package/dist/mcp/fleet.d.ts +218 -0
- package/dist/mcp/fleet.js +268 -0
- package/dist/mcp/fleet.js.map +1 -0
- package/dist/mcp/http.d.ts +335 -0
- package/dist/mcp/http.js +210 -0
- package/dist/mcp/http.js.map +1 -0
- package/dist/mcp/legacy-relay.d.ts +3 -0
- package/dist/mcp/legacy-relay.js +45 -0
- package/dist/mcp/legacy-relay.js.map +1 -0
- package/dist/mcp/oauth-store.d.ts +17 -0
- package/dist/mcp/oauth-store.js +58 -0
- package/dist/mcp/oauth-store.js.map +1 -0
- package/dist/mcp/oauth.d.ts +79 -0
- package/dist/mcp/oauth.js +236 -0
- package/dist/mcp/oauth.js.map +1 -0
- package/dist/mcp/relay-handler.d.ts +1 -0
- package/dist/mcp/relay-handler.js +43 -0
- package/dist/mcp/relay-handler.js.map +1 -0
- package/dist/mcp/relay.d.ts +13 -0
- package/dist/mcp/relay.js +145 -0
- package/dist/mcp/relay.js.map +1 -0
- package/dist/mcp/server.d.ts +5 -0
- package/dist/mcp/server.js +546 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp-cli.d.ts +2 -0
- package/dist/mcp-cli.js +85 -0
- package/dist/mcp-cli.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/package.json +15 -4
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
3
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
4
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
machines: z.ZodArray<z.ZodDiscriminatedUnion<"transport", [z.ZodObject<{
|
|
6
|
+
transport: z.ZodLiteral<"relay">;
|
|
7
|
+
userId: z.ZodString;
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
label: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
id: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
transport: "relay";
|
|
14
|
+
label?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
id: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
transport: "relay";
|
|
19
|
+
label?: string | undefined;
|
|
20
|
+
}>, z.ZodObject<{
|
|
21
|
+
transport: z.ZodLiteral<"local">;
|
|
22
|
+
bridgeFile: z.ZodOptional<z.ZodString>;
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
label: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, "strict", z.ZodTypeAny, {
|
|
26
|
+
id: string;
|
|
27
|
+
transport: "local";
|
|
28
|
+
label?: string | undefined;
|
|
29
|
+
bridgeFile?: string | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
id: string;
|
|
32
|
+
transport: "local";
|
|
33
|
+
label?: string | undefined;
|
|
34
|
+
bridgeFile?: string | undefined;
|
|
35
|
+
}>, z.ZodObject<{
|
|
36
|
+
transport: z.ZodLiteral<"ssh">;
|
|
37
|
+
host: z.ZodString;
|
|
38
|
+
executable: z.ZodDefault<z.ZodString>;
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
label: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, "strict", z.ZodTypeAny, {
|
|
42
|
+
id: string;
|
|
43
|
+
transport: "ssh";
|
|
44
|
+
host: string;
|
|
45
|
+
executable: string;
|
|
46
|
+
label?: string | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
id: string;
|
|
49
|
+
transport: "ssh";
|
|
50
|
+
host: string;
|
|
51
|
+
label?: string | undefined;
|
|
52
|
+
executable?: string | undefined;
|
|
53
|
+
}>, z.ZodObject<{
|
|
54
|
+
transport: z.ZodLiteral<"http">;
|
|
55
|
+
url: z.ZodString;
|
|
56
|
+
tokenEnv: z.ZodString;
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
label: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, "strict", z.ZodTypeAny, {
|
|
60
|
+
id: string;
|
|
61
|
+
transport: "http";
|
|
62
|
+
url: string;
|
|
63
|
+
tokenEnv: string;
|
|
64
|
+
label?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
id: string;
|
|
67
|
+
transport: "http";
|
|
68
|
+
url: string;
|
|
69
|
+
tokenEnv: string;
|
|
70
|
+
label?: string | undefined;
|
|
71
|
+
}>]>, "many">;
|
|
72
|
+
}, "strict", z.ZodTypeAny, {
|
|
73
|
+
concurrency: number;
|
|
74
|
+
timeoutMs: number;
|
|
75
|
+
machines: ({
|
|
76
|
+
id: string;
|
|
77
|
+
userId: string;
|
|
78
|
+
transport: "relay";
|
|
79
|
+
label?: string | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
id: string;
|
|
82
|
+
transport: "local";
|
|
83
|
+
label?: string | undefined;
|
|
84
|
+
bridgeFile?: string | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
id: string;
|
|
87
|
+
transport: "ssh";
|
|
88
|
+
host: string;
|
|
89
|
+
executable: string;
|
|
90
|
+
label?: string | undefined;
|
|
91
|
+
} | {
|
|
92
|
+
id: string;
|
|
93
|
+
transport: "http";
|
|
94
|
+
url: string;
|
|
95
|
+
tokenEnv: string;
|
|
96
|
+
label?: string | undefined;
|
|
97
|
+
})[];
|
|
98
|
+
}, {
|
|
99
|
+
machines: ({
|
|
100
|
+
id: string;
|
|
101
|
+
userId: string;
|
|
102
|
+
transport: "relay";
|
|
103
|
+
label?: string | undefined;
|
|
104
|
+
} | {
|
|
105
|
+
id: string;
|
|
106
|
+
transport: "local";
|
|
107
|
+
label?: string | undefined;
|
|
108
|
+
bridgeFile?: string | undefined;
|
|
109
|
+
} | {
|
|
110
|
+
id: string;
|
|
111
|
+
transport: "ssh";
|
|
112
|
+
host: string;
|
|
113
|
+
label?: string | undefined;
|
|
114
|
+
executable?: string | undefined;
|
|
115
|
+
} | {
|
|
116
|
+
id: string;
|
|
117
|
+
transport: "http";
|
|
118
|
+
url: string;
|
|
119
|
+
tokenEnv: string;
|
|
120
|
+
label?: string | undefined;
|
|
121
|
+
})[];
|
|
122
|
+
concurrency?: number | undefined;
|
|
123
|
+
timeoutMs?: number | undefined;
|
|
124
|
+
}>, {
|
|
125
|
+
concurrency: number;
|
|
126
|
+
timeoutMs: number;
|
|
127
|
+
machines: ({
|
|
128
|
+
id: string;
|
|
129
|
+
userId: string;
|
|
130
|
+
transport: "relay";
|
|
131
|
+
label?: string | undefined;
|
|
132
|
+
} | {
|
|
133
|
+
id: string;
|
|
134
|
+
transport: "local";
|
|
135
|
+
label?: string | undefined;
|
|
136
|
+
bridgeFile?: string | undefined;
|
|
137
|
+
} | {
|
|
138
|
+
id: string;
|
|
139
|
+
transport: "ssh";
|
|
140
|
+
host: string;
|
|
141
|
+
executable: string;
|
|
142
|
+
label?: string | undefined;
|
|
143
|
+
} | {
|
|
144
|
+
id: string;
|
|
145
|
+
transport: "http";
|
|
146
|
+
url: string;
|
|
147
|
+
tokenEnv: string;
|
|
148
|
+
label?: string | undefined;
|
|
149
|
+
})[];
|
|
150
|
+
}, {
|
|
151
|
+
machines: ({
|
|
152
|
+
id: string;
|
|
153
|
+
userId: string;
|
|
154
|
+
transport: "relay";
|
|
155
|
+
label?: string | undefined;
|
|
156
|
+
} | {
|
|
157
|
+
id: string;
|
|
158
|
+
transport: "local";
|
|
159
|
+
label?: string | undefined;
|
|
160
|
+
bridgeFile?: string | undefined;
|
|
161
|
+
} | {
|
|
162
|
+
id: string;
|
|
163
|
+
transport: "ssh";
|
|
164
|
+
host: string;
|
|
165
|
+
label?: string | undefined;
|
|
166
|
+
executable?: string | undefined;
|
|
167
|
+
} | {
|
|
168
|
+
id: string;
|
|
169
|
+
transport: "http";
|
|
170
|
+
url: string;
|
|
171
|
+
tokenEnv: string;
|
|
172
|
+
label?: string | undefined;
|
|
173
|
+
})[];
|
|
174
|
+
concurrency?: number | undefined;
|
|
175
|
+
timeoutMs?: number | undefined;
|
|
176
|
+
}>;
|
|
177
|
+
export type FleetConfig = z.infer<typeof configSchema>;
|
|
178
|
+
export declare const requestSchema: z.ZodObject<{
|
|
179
|
+
method: z.ZodEnum<["GET", "POST", "PATCH", "DELETE"]>;
|
|
180
|
+
path: z.ZodString;
|
|
181
|
+
body: z.ZodOptional<z.ZodUnknown>;
|
|
182
|
+
timeoutMs: z.ZodNumber;
|
|
183
|
+
}, "strict", z.ZodTypeAny, {
|
|
184
|
+
method: "POST" | "GET" | "DELETE" | "PATCH";
|
|
185
|
+
path: string;
|
|
186
|
+
timeoutMs: number;
|
|
187
|
+
body?: unknown;
|
|
188
|
+
}, {
|
|
189
|
+
method: "POST" | "GET" | "DELETE" | "PATCH";
|
|
190
|
+
path: string;
|
|
191
|
+
timeoutMs: number;
|
|
192
|
+
body?: unknown;
|
|
193
|
+
}>;
|
|
194
|
+
export type BridgeRequest = z.infer<typeof requestSchema>;
|
|
195
|
+
export declare class FleetError extends Error {
|
|
196
|
+
readonly code: string;
|
|
197
|
+
readonly outcomeUnknown: boolean;
|
|
198
|
+
readonly status?: number | undefined;
|
|
199
|
+
constructor(code: string, message: string, outcomeUnknown?: boolean, status?: number | undefined);
|
|
200
|
+
}
|
|
201
|
+
export declare function errorResult(error: unknown): {
|
|
202
|
+
status?: number | undefined;
|
|
203
|
+
code: string;
|
|
204
|
+
message: string;
|
|
205
|
+
outcomeUnknown: boolean;
|
|
206
|
+
};
|
|
207
|
+
export declare function httpRequest(origin: string, token: string, request: BridgeRequest, signal?: AbortSignal): Promise<any>;
|
|
208
|
+
export declare function localRequest(request: BridgeRequest, bridgeFile?: string, signal?: AbortSignal): Promise<any>;
|
|
209
|
+
export declare function loadConfig(path?: string): Promise<FleetConfig>;
|
|
210
|
+
export declare function mapLimit<T, R>(items: T[], concurrency: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
211
|
+
export declare class Fleet {
|
|
212
|
+
readonly config: FleetConfig;
|
|
213
|
+
private relay?;
|
|
214
|
+
private active;
|
|
215
|
+
private waiters;
|
|
216
|
+
constructor(config: FleetConfig, relay?: ((userId: string, machineId: string, request: BridgeRequest, signal?: AbortSignal) => Promise<unknown>) | undefined);
|
|
217
|
+
request(machineId: string, method: BridgeRequest["method"], path: string, body?: unknown, signal?: AbortSignal, timeoutMs?: number): Promise<any>;
|
|
218
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const machineBase = {
|
|
7
|
+
id: z.string().regex(/^[a-zA-Z0-9_-]+$/),
|
|
8
|
+
label: z.string().optional(),
|
|
9
|
+
};
|
|
10
|
+
export const configSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
concurrency: z.number().int().min(1).max(32).default(8),
|
|
13
|
+
timeoutMs: z.number().int().min(1000).max(60000).default(15000),
|
|
14
|
+
machines: z
|
|
15
|
+
.array(z.discriminatedUnion("transport", [
|
|
16
|
+
z
|
|
17
|
+
.object({
|
|
18
|
+
...machineBase,
|
|
19
|
+
transport: z.literal("relay"),
|
|
20
|
+
userId: z.string().email(),
|
|
21
|
+
})
|
|
22
|
+
.strict(),
|
|
23
|
+
z
|
|
24
|
+
.object({
|
|
25
|
+
...machineBase,
|
|
26
|
+
transport: z.literal("local"),
|
|
27
|
+
bridgeFile: z.string().optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict(),
|
|
30
|
+
z
|
|
31
|
+
.object({
|
|
32
|
+
...machineBase,
|
|
33
|
+
transport: z.literal("ssh"),
|
|
34
|
+
host: z.string().regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.@:-]*$/),
|
|
35
|
+
executable: z.string().min(1).default("ftown-mcp"),
|
|
36
|
+
})
|
|
37
|
+
.strict(),
|
|
38
|
+
z
|
|
39
|
+
.object({
|
|
40
|
+
...machineBase,
|
|
41
|
+
transport: z.literal("http"),
|
|
42
|
+
url: z.string().url(),
|
|
43
|
+
tokenEnv: z.string().min(1),
|
|
44
|
+
})
|
|
45
|
+
.strict(),
|
|
46
|
+
]))
|
|
47
|
+
.min(1)
|
|
48
|
+
.max(1000),
|
|
49
|
+
})
|
|
50
|
+
.strict()
|
|
51
|
+
.superRefine((config, ctx) => {
|
|
52
|
+
if (new Set(config.machines.map((m) => m.id)).size !== config.machines.length)
|
|
53
|
+
ctx.addIssue({ code: "custom", message: "Machine IDs must be unique" });
|
|
54
|
+
for (const m of config.machines)
|
|
55
|
+
if (m.transport === "http") {
|
|
56
|
+
const u = new URL(m.url);
|
|
57
|
+
if (u.username ||
|
|
58
|
+
u.password ||
|
|
59
|
+
u.search ||
|
|
60
|
+
u.hash ||
|
|
61
|
+
u.pathname !== "/" ||
|
|
62
|
+
!(u.protocol === "https:" ||
|
|
63
|
+
(u.protocol === "http:" &&
|
|
64
|
+
["localhost", "127.0.0.1", "[::1]"].includes(u.hostname)))) {
|
|
65
|
+
ctx.addIssue({
|
|
66
|
+
code: "custom",
|
|
67
|
+
message: "HTTP machines require an HTTPS origin or loopback HTTP origin without embedded credentials",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
export const requestSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
method: z.enum(["GET", "POST", "PATCH", "DELETE"]),
|
|
75
|
+
path: z
|
|
76
|
+
.string()
|
|
77
|
+
.regex(/^\/api\/(?:archive|sessions(?:\/[a-zA-Z0-9_-]+(?:\/(?:screen|grep|keys|message|inbox|resize|usage|running|revive|stop|retry))?)?)(?:\?[^#]*)?$/),
|
|
78
|
+
body: z.unknown().optional(),
|
|
79
|
+
timeoutMs: z.number().int().min(1000).max(60000),
|
|
80
|
+
})
|
|
81
|
+
.strict();
|
|
82
|
+
export class FleetError extends Error {
|
|
83
|
+
code;
|
|
84
|
+
outcomeUnknown;
|
|
85
|
+
status;
|
|
86
|
+
constructor(code, message, outcomeUnknown = false, status) {
|
|
87
|
+
super(message);
|
|
88
|
+
this.code = code;
|
|
89
|
+
this.outcomeUnknown = outcomeUnknown;
|
|
90
|
+
this.status = status;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function errorResult(error) {
|
|
94
|
+
if (error instanceof FleetError)
|
|
95
|
+
return {
|
|
96
|
+
code: error.code,
|
|
97
|
+
message: error.message,
|
|
98
|
+
outcomeUnknown: error.outcomeUnknown,
|
|
99
|
+
...(error.status ? { status: error.status } : {}),
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
code: "internal_error",
|
|
103
|
+
message: "Operation failed",
|
|
104
|
+
outcomeUnknown: false,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const maxBytes = 4 * 1024 * 1024;
|
|
108
|
+
export async function httpRequest(origin, token, request, signal) {
|
|
109
|
+
const timeout = AbortSignal.timeout(request.timeoutMs);
|
|
110
|
+
try {
|
|
111
|
+
const res = await fetch(new URL(request.path, origin), {
|
|
112
|
+
method: request.method,
|
|
113
|
+
redirect: "error",
|
|
114
|
+
headers: {
|
|
115
|
+
Authorization: `Bearer ${token}`,
|
|
116
|
+
"Content-Type": "application/json",
|
|
117
|
+
},
|
|
118
|
+
body: request.body === undefined ? undefined : JSON.stringify(request.body),
|
|
119
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
120
|
+
});
|
|
121
|
+
const reader = res.body?.getReader();
|
|
122
|
+
let size = 0;
|
|
123
|
+
const chunks = [];
|
|
124
|
+
if (reader)
|
|
125
|
+
try {
|
|
126
|
+
while (true) {
|
|
127
|
+
const { done, value } = await reader.read();
|
|
128
|
+
if (done)
|
|
129
|
+
break;
|
|
130
|
+
size += value.byteLength;
|
|
131
|
+
if (size > maxBytes) {
|
|
132
|
+
await reader.cancel();
|
|
133
|
+
throw new FleetError("response_too_large", "Bridge response exceeds 4 MiB; narrow the request", request.method !== "GET");
|
|
134
|
+
}
|
|
135
|
+
chunks.push(value);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
reader.releaseLock();
|
|
140
|
+
}
|
|
141
|
+
const data = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
142
|
+
if (!res.ok) {
|
|
143
|
+
const detail = typeof data?.error === "string"
|
|
144
|
+
? data.error.replaceAll(token, "[redacted]").slice(0, 1000)
|
|
145
|
+
: "Bridge request rejected";
|
|
146
|
+
throw new FleetError("bridge_error", `${detail} (HTTP ${res.status})`, request.method !== "GET" && res.status >= 500, res.status);
|
|
147
|
+
}
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error instanceof FleetError)
|
|
152
|
+
throw error;
|
|
153
|
+
throw new FleetError(signal?.aborted
|
|
154
|
+
? "cancelled"
|
|
155
|
+
: timeout.aborted
|
|
156
|
+
? "timeout"
|
|
157
|
+
: "connection_error", "Bridge request failed; check machine connectivity and credentials", request.method !== "GET");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export async function localRequest(request, bridgeFile = join(homedir(), ".ftown", "bridge.json"), signal) {
|
|
161
|
+
let credentials;
|
|
162
|
+
try {
|
|
163
|
+
credentials = z
|
|
164
|
+
.object({
|
|
165
|
+
port: z.number().int().min(1).max(65535),
|
|
166
|
+
token: z.string().min(1),
|
|
167
|
+
})
|
|
168
|
+
.parse(JSON.parse(await readFile(bridgeFile, "utf8")));
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
throw new FleetError("configuration_error", "Cannot read bridge credentials; start ftown-bridge on this machine");
|
|
172
|
+
}
|
|
173
|
+
return httpRequest(`http://127.0.0.1:${credentials.port}`, credentials.token, requestSchema.parse(request), signal);
|
|
174
|
+
}
|
|
175
|
+
export async function loadConfig(path) {
|
|
176
|
+
return configSchema.parse(path
|
|
177
|
+
? JSON.parse(await readFile(path, "utf8"))
|
|
178
|
+
: { machines: [{ id: "local", transport: "local" }] });
|
|
179
|
+
}
|
|
180
|
+
export async function mapLimit(items, concurrency, fn) {
|
|
181
|
+
const results = new Array(items.length);
|
|
182
|
+
let next = 0;
|
|
183
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
184
|
+
while (next < items.length) {
|
|
185
|
+
const index = next++;
|
|
186
|
+
results[index] = await fn(items[index], index);
|
|
187
|
+
}
|
|
188
|
+
}));
|
|
189
|
+
return results;
|
|
190
|
+
}
|
|
191
|
+
export class Fleet {
|
|
192
|
+
config;
|
|
193
|
+
relay;
|
|
194
|
+
active = 0;
|
|
195
|
+
waiters = [];
|
|
196
|
+
constructor(config, relay) {
|
|
197
|
+
this.config = config;
|
|
198
|
+
this.relay = relay;
|
|
199
|
+
}
|
|
200
|
+
async request(machineId, method, path, body, signal, timeoutMs = this.config.timeoutMs) {
|
|
201
|
+
const machine = this.config.machines.find((m) => m.id === machineId);
|
|
202
|
+
if (!machine)
|
|
203
|
+
throw new FleetError("unknown_machine", `Unknown machine: ${machineId}`);
|
|
204
|
+
const request = requestSchema.parse({ method, path, body, timeoutMs });
|
|
205
|
+
if (this.active >= this.config.concurrency)
|
|
206
|
+
await new Promise((resolve) => this.waiters.push(resolve));
|
|
207
|
+
else
|
|
208
|
+
this.active++;
|
|
209
|
+
try {
|
|
210
|
+
if (signal?.aborted)
|
|
211
|
+
throw new FleetError("cancelled", "Request cancelled before dispatch");
|
|
212
|
+
if (machine.transport === "relay") {
|
|
213
|
+
if (!this.relay)
|
|
214
|
+
throw new FleetError("configuration_error", "Relay transport is not configured");
|
|
215
|
+
return await this.relay(machine.userId, machine.id, request, signal);
|
|
216
|
+
}
|
|
217
|
+
if (machine.transport === "local")
|
|
218
|
+
return await localRequest(request, machine.bridgeFile, signal);
|
|
219
|
+
if (machine.transport === "http") {
|
|
220
|
+
const token = process.env[machine.tokenEnv];
|
|
221
|
+
if (!token)
|
|
222
|
+
throw new FleetError("configuration_error", "Configured token environment variable is missing");
|
|
223
|
+
return await httpRequest(machine.url, token, request, signal);
|
|
224
|
+
}
|
|
225
|
+
// Only a trusted configured executable enters the remote shell. All tool arguments travel over stdin.
|
|
226
|
+
const command = `'${machine.executable.replaceAll("'", "'\\''")}' --proxy`;
|
|
227
|
+
return await new Promise((resolve, reject) => {
|
|
228
|
+
const child = execFile("ssh", [
|
|
229
|
+
"-T",
|
|
230
|
+
"-o",
|
|
231
|
+
"BatchMode=yes",
|
|
232
|
+
"-o",
|
|
233
|
+
"StrictHostKeyChecking=yes",
|
|
234
|
+
"-o",
|
|
235
|
+
"ConnectTimeout=10",
|
|
236
|
+
"--",
|
|
237
|
+
machine.host,
|
|
238
|
+
command,
|
|
239
|
+
], { timeout: timeoutMs + 1000, maxBuffer: maxBytes, signal }, (error, stdout) => {
|
|
240
|
+
if (error) {
|
|
241
|
+
reject(new FleetError("ssh_error", "SSH proxy failed; verify SSH access and remote ftown-mcp installation", method !== "GET"));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
const result = JSON.parse(stdout);
|
|
246
|
+
if (result.error)
|
|
247
|
+
reject(new FleetError(result.error.code, result.error.message, result.error.outcomeUnknown, result.error.status));
|
|
248
|
+
else
|
|
249
|
+
resolve(result.data);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
reject(new FleetError("protocol_error", "Invalid SSH proxy response", method !== "GET"));
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
child.stdin?.on("error", () => { });
|
|
256
|
+
child.stdin?.end(JSON.stringify(request));
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
const next = this.waiters.shift();
|
|
261
|
+
if (next)
|
|
262
|
+
next();
|
|
263
|
+
else
|
|
264
|
+
this.active--;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=fleet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet.js","sourceRoot":"","sources":["../../src/mcp/fleet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACxC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/D,QAAQ,EAAE,CAAC;SACR,KAAK,CACJ,CAAC,CAAC,kBAAkB,CAAC,WAAW,EAAE;QAChC,CAAC;aACE,MAAM,CAAC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