staff-mcp 1.1.0 → 1.1.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.
@@ -1,18 +1,70 @@
1
- /** Redact credentials from a proxy URL for safe logging. */
2
- export declare function maskProxyUrl(proxyUrl: string): string;
3
- /** True when any proxy environment variable is present. */
1
+ import { Agent, Dispatcher } from "undici";
2
+ /**
3
+ * Whether proxy environment variables are present (NO_PROXY alone does not count).
4
+ */
4
5
  export declare function hasProxyEnv(env?: NodeJS.ProcessEnv): boolean;
6
+ export type NoProxyEntryKind = "wildcard" | "exact" | "suffix" | "cidr4" | "cidr6";
7
+ export interface NoProxyEntry {
8
+ kind: NoProxyEntryKind;
9
+ /** normalized host: lowercase, no trailing dot, no IPv6 brackets */
10
+ host: string;
11
+ /** optional port restriction; null = any port */
12
+ port: number | null;
13
+ /** network base for cidr4 (32-bit int) / cidr6 (128-bit bigint) */
14
+ network?: number | bigint;
15
+ /** prefix length for cidr kinds */
16
+ bits?: number;
17
+ }
18
+ /**
19
+ * Parse a NO_PROXY value into matchable entries.
20
+ * Supported: "*", exact hosts, ".example.com"/"*.example.com" suffixes,
21
+ * bare domains (exact + subdomains, curl semantics), "host:port",
22
+ * IPv4/IPv6 literals and CIDR ranges ("10.0.0.0/8", "fd00::/8").
23
+ */
24
+ export declare function parseNoProxy(value: string | undefined | null): NoProxyEntry[];
25
+ /** Whether a target host:port matches any NO_PROXY entry (i.e. should bypass the proxy). */
26
+ export declare function matchesNoProxy(hostname: string, port: number | null, entries: NoProxyEntry[]): boolean;
27
+ export interface EnvProxyConfig {
28
+ httpProxy?: string;
29
+ httpsProxy?: string;
30
+ noProxy?: string;
31
+ }
32
+ /**
33
+ * Pure routing decision used by EnvProxyDispatcher (exported for tests):
34
+ * returns the proxy URL to use for the given origin, or null for a direct connection.
35
+ */
36
+ export declare function selectProxyForOrigin(origin: string | URL, config: EnvProxyConfig): string | null;
37
+ export interface EnvProxyDispatcherOptions extends EnvProxyConfig {
38
+ agentOptions?: Agent.Options;
39
+ }
40
+ /**
41
+ * Dispatcher that routes traffic through HTTP(S)_PROXY unless the target
42
+ * matches NO_PROXY. Mirrors undici's EnvHttpProxyAgent fallback semantics
43
+ * (https targets fall back to HTTP_PROXY when HTTPS_PROXY is unset) but
44
+ * with full NO_PROXY support (CIDR, suffixes, ports, wildcard).
45
+ */
46
+ export declare class EnvProxyDispatcher extends Dispatcher {
47
+ private directAgent;
48
+ private httpAgent;
49
+ private httpsAgent;
50
+ private noProxyEntries;
51
+ private ownedAgents;
52
+ constructor(opts?: EnvProxyDispatcherOptions);
53
+ dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
54
+ close(): Promise<void>;
55
+ destroy(): Promise<void>;
56
+ }
5
57
  /**
6
- * Install a proxy-aware global dispatcher for fetch(). Intended to be called
7
- * once at startup, before any outbound request.
58
+ * Configure global proxy for all fetch/undici-based traffic.
8
59
  *
9
- * Priority:
10
- * 1. explicitProxyUrl (--proxy): routes ALL outbound traffic through it
11
- * (undici's ProxyAgent does not apply NO_PROXY).
12
- * 2. HTTP_PROXY / HTTPS_PROXY environment variables: EnvHttpProxyAgent
13
- * honors them per-request, including NO_PROXY bypass rules.
14
- * 3. Neither: leaves the default dispatcher untouched (no behavior change).
60
+ * - If explicitProxyUrl is provided (--proxy), it takes precedence and is
61
+ * used for ALL traffic (NO_PROXY is intentionally not applied).
62
+ * - Otherwise, standard HTTP_PROXY / HTTPS_PROXY / NO_PROXY environment
63
+ * variables are honored with full NO_PROXY support (exact hosts, domain
64
+ * suffixes, wildcards, ":port" qualifiers, IPv4/IPv6 CIDR ranges).
15
65
  *
16
- * @returns true when a proxy dispatcher was installed.
66
+ * Works on any supported Node.js version without NODE_USE_ENV_PROXY.
17
67
  */
18
68
  export declare function configureGlobalProxy(explicitProxyUrl?: string): boolean;
69
+ export declare function maskProxyUrl(url: string): string;
70
+ export declare function logGlobalDispatcherDebug(): void;
@@ -1,66 +1,351 @@
1
+ import { Agent, Dispatcher, ProxyAgent, getGlobalDispatcher, setGlobalDispatcher } from "undici";
2
+ const ENV_HTTP_PROXY = ["HTTP_PROXY", "http_proxy"];
3
+ const ENV_HTTPS_PROXY = ["HTTPS_PROXY", "https_proxy"];
4
+ const ENV_NO_PROXY = ["NO_PROXY", "no_proxy"];
1
5
  /**
2
- * Global outbound proxy support for staff-mcp.
3
- *
4
- * Node's built-in env-proxy support (NODE_USE_ENV_PROXY / --use-env-proxy)
5
- * only exists in Node >= v22.21.0 / v24.0.0. Installing an undici global
6
- * dispatcher provides the same behavior on every supported Node (>= 20) and
7
- * covers every fetch() issued in-process: the mcp-reverse SSE connector, its
8
- * message POSTs, and the MCP SDK client transports (including EventSource,
9
- * which delegates to globalThis.fetch).
6
+ * Whether proxy environment variables are present (NO_PROXY alone does not count).
10
7
  */
11
- import { EnvHttpProxyAgent, ProxyAgent, setGlobalDispatcher } from "undici";
12
- /** Redact credentials from a proxy URL for safe logging. */
13
- export function maskProxyUrl(proxyUrl) {
8
+ export function hasProxyEnv(env = process.env) {
9
+ return [...ENV_HTTP_PROXY, ...ENV_HTTPS_PROXY].some((key) => Boolean(env[key]));
10
+ }
11
+ /** Parse an IPv4 literal into a 32-bit number (using multiplication to avoid sign issues). */
12
+ function parseIpv4ToInt(ip) {
13
+ const m = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(ip);
14
+ if (!m)
15
+ return null;
16
+ let result = 0;
17
+ for (let i = 1; i <= 4; i++) {
18
+ const octet = Number(m[i]);
19
+ if (octet > 255)
20
+ return null;
21
+ result = result * 256 + octet;
22
+ }
23
+ return result;
24
+ }
25
+ function matchIpv4Cidr(ip, base, bits) {
26
+ if (bits <= 0)
27
+ return true;
28
+ if (bits >= 32)
29
+ return ip === base;
30
+ const shift = 32 - bits;
31
+ return Math.floor(ip / 2 ** shift) === Math.floor(base / 2 ** shift);
32
+ }
33
+ /** Parse an IPv6 literal (with "::" compression and optional embedded IPv4 tail) into a 128-bit bigint. */
34
+ function parseIpv6ToBigInt(ipInput) {
35
+ let ip = ipInput;
36
+ const zoneIdx = ip.indexOf("%"); // strip zone id, e.g. fe80::1%eth0
37
+ if (zoneIdx >= 0)
38
+ ip = ip.slice(0, zoneIdx);
39
+ ip = ip.toLowerCase();
40
+ if (!/^[0-9a-f:.]+$/.test(ip))
41
+ return null;
42
+ const expandV4Tail = (groups) => {
43
+ const last = groups[groups.length - 1];
44
+ if (last && last.includes(".")) {
45
+ const v4 = parseIpv4ToInt(last);
46
+ if (v4 === null)
47
+ return null;
48
+ groups[groups.length - 1] = Math.floor(v4 / 65536).toString(16);
49
+ groups.push((v4 % 65536).toString(16));
50
+ }
51
+ return groups;
52
+ };
53
+ let groups;
54
+ if (ip.includes("::")) {
55
+ const halves = ip.split("::");
56
+ if (halves.length !== 2)
57
+ return null; // at most one "::"
58
+ const head = halves[0] ? halves[0].split(":") : [];
59
+ const tail = halves[1] ? halves[1].split(":") : [];
60
+ const expandedTail = expandV4Tail(tail);
61
+ if (expandedTail === null)
62
+ return null;
63
+ const missing = 8 - (head.length + expandedTail.length);
64
+ if (missing < 1)
65
+ return null;
66
+ groups = [...head, ...Array(missing).fill("0"), ...expandedTail];
67
+ }
68
+ else {
69
+ const expanded = expandV4Tail(ip.split(":"));
70
+ if (expanded === null)
71
+ return null;
72
+ groups = expanded;
73
+ }
74
+ if (groups.length !== 8)
75
+ return null;
76
+ let result = 0n;
77
+ for (const g of groups) {
78
+ if (!/^[0-9a-f]{1,4}$/.test(g))
79
+ return null;
80
+ result = (result << 16n) | BigInt(parseInt(g, 16));
81
+ }
82
+ return result;
83
+ }
84
+ function matchIpv6Cidr(ip, base, bits) {
85
+ if (bits <= 0)
86
+ return true;
87
+ if (bits >= 128)
88
+ return ip === base;
89
+ const shift = BigInt(128 - bits);
90
+ return ip >> shift === base >> shift;
91
+ }
92
+ function parsePort(value) {
93
+ if (!/^\d{1,5}$/.test(value))
94
+ return null;
95
+ const port = Number(value);
96
+ return port >= 0 && port <= 65535 ? port : null;
97
+ }
98
+ function makeEntry(hostInput, port) {
99
+ let host = hostInput.toLowerCase();
100
+ if (host.endsWith("."))
101
+ host = host.slice(0, -1); // strip FQDN trailing dot
102
+ if (host.includes("/")) {
103
+ let [base, bitsStr] = host.split("/", 2);
104
+ // Optional port after the prefix length: "10.0.0.0/8:8080"
105
+ if (bitsStr.includes(":")) {
106
+ const [bitsPart, portPart] = bitsStr.split(":", 2);
107
+ const parsed = parsePort(portPart);
108
+ if (parsed !== null) {
109
+ bitsStr = bitsPart;
110
+ port = port ?? parsed;
111
+ }
112
+ }
113
+ const bits = Number(bitsStr);
114
+ const v4 = parseIpv4ToInt(base);
115
+ if (v4 !== null && Number.isInteger(bits) && bits >= 0 && bits <= 32) {
116
+ return { kind: "cidr4", host, port, network: v4, bits };
117
+ }
118
+ const v6 = parseIpv6ToBigInt(base);
119
+ if (v6 !== null && Number.isInteger(bits) && bits >= 0 && bits <= 128) {
120
+ return { kind: "cidr6", host, port, network: v6, bits };
121
+ }
122
+ // Unparseable CIDR: never matches (fail closed toward proxying, like undici).
123
+ return { kind: "exact", host: "invalid", port };
124
+ }
125
+ if (host.startsWith("*."))
126
+ return { kind: "suffix", host: host.slice(2), port };
127
+ if (host.startsWith("."))
128
+ return { kind: "suffix", host: host.slice(1), port };
129
+ return { kind: "exact", host, port };
130
+ }
131
+ /**
132
+ * Parse a NO_PROXY value into matchable entries.
133
+ * Supported: "*", exact hosts, ".example.com"/"*.example.com" suffixes,
134
+ * bare domains (exact + subdomains, curl semantics), "host:port",
135
+ * IPv4/IPv6 literals and CIDR ranges ("10.0.0.0/8", "fd00::/8").
136
+ */
137
+ export function parseNoProxy(value) {
138
+ if (!value)
139
+ return [];
140
+ const entries = [];
141
+ for (const raw of value.split(",")) {
142
+ const token0 = raw.trim();
143
+ if (!token0)
144
+ continue;
145
+ if (token0 === "*") {
146
+ entries.push({ kind: "wildcard", host: "*", port: null });
147
+ continue;
148
+ }
149
+ // Bracketed IPv6, optionally with port: "[::1]" / "[::1]:8080"
150
+ if (token0.startsWith("[")) {
151
+ const close = token0.indexOf("]");
152
+ if (close > 0) {
153
+ const inner = token0.slice(1, close);
154
+ const rest = token0.slice(close + 1);
155
+ const port = rest.startsWith(":") ? parsePort(rest.slice(1)) : null;
156
+ entries.push(makeEntry(inner, port));
157
+ continue;
158
+ }
159
+ }
160
+ // "host:port" — only when there is exactly one colon (otherwise it is IPv6)
161
+ let host = token0;
162
+ let port = null;
163
+ if (!token0.includes("/")) {
164
+ const colonCount = (token0.match(/:/g) || []).length;
165
+ if (colonCount === 1) {
166
+ const [h, p] = token0.split(":");
167
+ const parsed = parsePort(p);
168
+ if (parsed !== null) {
169
+ host = h;
170
+ port = parsed;
171
+ }
172
+ }
173
+ }
174
+ entries.push(makeEntry(host, port));
175
+ }
176
+ return entries;
177
+ }
178
+ function isIpLiteral(host) {
179
+ return parseIpv4ToInt(host) !== null || host.includes(":");
180
+ }
181
+ /** Whether a target host:port matches any NO_PROXY entry (i.e. should bypass the proxy). */
182
+ export function matchesNoProxy(hostname, port, entries) {
183
+ if (!hostname)
184
+ return false;
185
+ let host = hostname.toLowerCase();
186
+ if (host.startsWith("[") && host.endsWith("]"))
187
+ host = host.slice(1, -1);
188
+ if (host.endsWith("."))
189
+ host = host.slice(0, -1);
190
+ for (const entry of entries) {
191
+ if (entry.kind === "wildcard")
192
+ return true;
193
+ if (entry.port !== null && entry.port !== port)
194
+ continue;
195
+ switch (entry.kind) {
196
+ case "exact":
197
+ if (host === entry.host)
198
+ return true;
199
+ // Bare-domain entries also cover subdomains (curl/wget semantics).
200
+ if (!isIpLiteral(entry.host) && host.endsWith(`.${entry.host}`))
201
+ return true;
202
+ break;
203
+ case "suffix":
204
+ if (host === entry.host || host.endsWith(`.${entry.host}`))
205
+ return true;
206
+ break;
207
+ case "cidr4": {
208
+ const v4 = parseIpv4ToInt(host);
209
+ if (v4 !== null && matchIpv4Cidr(v4, entry.network, entry.bits))
210
+ return true;
211
+ break;
212
+ }
213
+ case "cidr6": {
214
+ const v6 = parseIpv6ToBigInt(host);
215
+ if (v6 !== null && matchIpv6Cidr(v6, entry.network, entry.bits))
216
+ return true;
217
+ break;
218
+ }
219
+ }
220
+ }
221
+ return false;
222
+ }
223
+ /**
224
+ * Pure routing decision used by EnvProxyDispatcher (exported for tests):
225
+ * returns the proxy URL to use for the given origin, or null for a direct connection.
226
+ */
227
+ export function selectProxyForOrigin(origin, config) {
228
+ let url;
14
229
  try {
15
- const url = new URL(proxyUrl);
16
- if (url.username)
17
- url.username = "***";
18
- if (url.password)
19
- url.password = "***";
20
- return url.toString();
230
+ url = typeof origin === "string" ? new URL(origin) : origin;
21
231
  }
22
232
  catch {
23
- return "<invalid proxy URL>";
233
+ return null;
24
234
  }
235
+ const protocol = url.protocol.toLowerCase();
236
+ if (protocol !== "http:" && protocol !== "https:")
237
+ return null;
238
+ const port = url.port ? Number(url.port) : protocol === "https:" ? 443 : 80;
239
+ if (matchesNoProxy(url.hostname, port, parseNoProxy(config.noProxy)))
240
+ return null;
241
+ if (protocol === "https:")
242
+ return config.httpsProxy ?? config.httpProxy ?? null;
243
+ return config.httpProxy ?? null;
25
244
  }
26
- /** True when any proxy environment variable is present. */
27
- export function hasProxyEnv(env = process.env) {
28
- return Boolean(env.HTTPS_PROXY ||
29
- env.https_proxy ||
30
- env.HTTP_PROXY ||
31
- env.http_proxy);
245
+ /**
246
+ * Dispatcher that routes traffic through HTTP(S)_PROXY unless the target
247
+ * matches NO_PROXY. Mirrors undici's EnvHttpProxyAgent fallback semantics
248
+ * (https targets fall back to HTTP_PROXY when HTTPS_PROXY is unset) but
249
+ * with full NO_PROXY support (CIDR, suffixes, ports, wildcard).
250
+ */
251
+ export class EnvProxyDispatcher extends Dispatcher {
252
+ directAgent;
253
+ httpAgent;
254
+ httpsAgent;
255
+ noProxyEntries;
256
+ ownedAgents;
257
+ constructor(opts = {}) {
258
+ super();
259
+ const agentOpts = opts.agentOptions ?? {};
260
+ this.directAgent = new Agent(agentOpts);
261
+ this.ownedAgents = [this.directAgent];
262
+ this.noProxyEntries = parseNoProxy(opts.noProxy);
263
+ const mkProxy = (uri) => {
264
+ const agent = new ProxyAgent({ ...agentOpts, uri });
265
+ this.ownedAgents.push(agent);
266
+ return agent;
267
+ };
268
+ this.httpAgent = opts.httpProxy ? mkProxy(opts.httpProxy) : this.directAgent;
269
+ this.httpsAgent = opts.httpsProxy ? mkProxy(opts.httpsProxy) : this.httpAgent;
270
+ }
271
+ dispatch(options, handler) {
272
+ let agent = this.directAgent;
273
+ try {
274
+ const url = new URL(options.origin);
275
+ const protocol = url.protocol.toLowerCase();
276
+ const port = url.port ? Number(url.port) : protocol === "https:" ? 443 : 80;
277
+ if (!matchesNoProxy(url.hostname, port, this.noProxyEntries)) {
278
+ agent = protocol === "https:" ? this.httpsAgent : this.httpAgent;
279
+ }
280
+ }
281
+ catch {
282
+ // Unparseable origin: fall back to direct.
283
+ }
284
+ return agent.dispatch(options, handler);
285
+ }
286
+ async close() {
287
+ await Promise.all(this.ownedAgents.map((agent) => agent.close()));
288
+ }
289
+ async destroy() {
290
+ await Promise.all(this.ownedAgents.map((agent) => agent.destroy()));
291
+ }
32
292
  }
293
+ // ============================================================
294
+ // Global installation
295
+ // ============================================================
33
296
  /**
34
- * Install a proxy-aware global dispatcher for fetch(). Intended to be called
35
- * once at startup, before any outbound request.
297
+ * Configure global proxy for all fetch/undici-based traffic.
36
298
  *
37
- * Priority:
38
- * 1. explicitProxyUrl (--proxy): routes ALL outbound traffic through it
39
- * (undici's ProxyAgent does not apply NO_PROXY).
40
- * 2. HTTP_PROXY / HTTPS_PROXY environment variables: EnvHttpProxyAgent
41
- * honors them per-request, including NO_PROXY bypass rules.
42
- * 3. Neither: leaves the default dispatcher untouched (no behavior change).
299
+ * - If explicitProxyUrl is provided (--proxy), it takes precedence and is
300
+ * used for ALL traffic (NO_PROXY is intentionally not applied).
301
+ * - Otherwise, standard HTTP_PROXY / HTTPS_PROXY / NO_PROXY environment
302
+ * variables are honored with full NO_PROXY support (exact hosts, domain
303
+ * suffixes, wildcards, ":port" qualifiers, IPv4/IPv6 CIDR ranges).
43
304
  *
44
- * @returns true when a proxy dispatcher was installed.
305
+ * Works on any supported Node.js version without NODE_USE_ENV_PROXY.
45
306
  */
46
307
  export function configureGlobalProxy(explicitProxyUrl) {
47
- try {
48
- if (explicitProxyUrl) {
308
+ if (explicitProxyUrl) {
309
+ try {
49
310
  setGlobalDispatcher(new ProxyAgent(explicitProxyUrl));
50
- console.error(`[staff-mcp] Outbound proxy: ${maskProxyUrl(explicitProxyUrl)} ` +
51
- `(applies to all requests; NO_PROXY is not applied for --proxy)`);
311
+ console.error(`[staff-mcp] Outbound proxy: using ${explicitProxyUrl} for all traffic (NO_PROXY not applied)`);
52
312
  return true;
53
313
  }
54
- if (hasProxyEnv()) {
55
- setGlobalDispatcher(new EnvHttpProxyAgent());
56
- console.error("[staff-mcp] Outbound proxy: honoring HTTP_PROXY/HTTPS_PROXY/NO_PROXY environment variables");
57
- return true;
314
+ catch (err) {
315
+ console.error(`[staff-mcp] Outbound proxy: failed to configure explicit proxy "${explicitProxyUrl}": ${err?.message ?? err}`);
316
+ return false;
58
317
  }
59
318
  }
60
- catch (error) {
61
- console.error(`[staff-mcp] Failed to configure outbound proxy: ` +
62
- (error instanceof Error ? error.message : String(error)));
319
+ const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
320
+ const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
321
+ const noProxy = process.env.NO_PROXY || process.env.no_proxy;
322
+ if (httpProxy || httpsProxy) {
323
+ setGlobalDispatcher(new EnvProxyDispatcher({ httpProxy, httpsProxy, noProxy }));
324
+ const proxiesFound = [httpProxy && "HTTP_PROXY", httpsProxy && "HTTPS_PROXY"].filter(Boolean).join("/");
325
+ console.error(`[staff-mcp] Outbound proxy: honoring ${proxiesFound}${noProxy ? "/NO_PROXY" : ""} environment variables`);
326
+ return true;
63
327
  }
64
328
  return false;
65
329
  }
330
+ export function maskProxyUrl(url) {
331
+ try {
332
+ const u = new URL(url);
333
+ if (u.username || u.password) {
334
+ u.username = "***";
335
+ u.password = "***";
336
+ }
337
+ return u.toString();
338
+ }
339
+ catch {
340
+ return "<invalid proxy URL>";
341
+ }
342
+ }
343
+ export function logGlobalDispatcherDebug() {
344
+ const d = getGlobalDispatcher();
345
+ const name = d?.constructor?.name ?? "unknown";
346
+ const proxyKeys = Object.getOwnPropertySymbols(d)
347
+ .map((s) => s.toString())
348
+ .filter((s) => s.includes("proxy") || s.includes("Proxy"));
349
+ console.error(`[staff-mcp][debug] global dispatcher: ${name} symbols: ${proxyKeys.join(", ") || "none"}`);
350
+ }
66
351
  //# sourceMappingURL=proxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/utils/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE5E,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAAC,QAAgB;IACzC,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,GAAG,CAAC,QAAQ;YAAE,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;QACvC,IAAI,GAAG,CAAC,QAAQ;YAAE,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;QACvC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,qBAAqB,CAAC;IACjC,CAAC;AACL,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,WAAW,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC5D,OAAO,OAAO,CACV,GAAG,CAAC,WAAW;QACf,GAAG,CAAC,WAAW;QACf,GAAG,CAAC,UAAU;QACd,GAAG,C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SAAS,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;SAC9C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,KAAK,CAAC,yCAAyC,IAAI,aAAa,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;AAC5G,CAAC"}
@@ -5,7 +5,7 @@ import * as os from "node:os";
5
5
  import * as path from "node:path";
6
6
  import { PassThrough } from "node:stream";
7
7
  import { test } from "node:test";
8
- import { runDockerProxy, validateAdditionalDockerArgs } from "../src/docker-proxy.js";
8
+ import { buildDockerNameHint, runDockerProxy, sanitizeNameSegment, validateAdditionalDockerArgs } from "../src/docker-proxy.js";
9
9
  const FIXTURE_CONTAINER_ID = "a".repeat(64);
10
10
  const FIXTURE_SOURCE = String.raw `
11
11
  import * as fs from "node:fs";
@@ -122,7 +122,7 @@ function createFixture(t) {
122
122
  t.after(() => fs.rmSync(fixtureDir, { recursive: true, force: true }));
123
123
  return { fixtureDir, fixturePath, eventsPath, capturePath };
124
124
  }
125
- function runFixture(fixturePath, eventsPath, capturePath, mode, transport, input, signals, timeoutOverrides = {}) {
125
+ function runFixture(fixturePath, eventsPath, capturePath, mode, transport, input, signals, timeoutOverrides = {}, proxyOptions = {}) {
126
126
  return runDockerProxy(["run", "fake-image"], transport, {
127
127
  command: process.execPath,
128
128
  commandPrefixArgs: [fixturePath, mode, eventsPath, capturePath],
@@ -133,6 +133,7 @@ function runFixture(fixturePath, eventsPath, capturePath, mode, transport, input
133
133
  containerCleanupTimeoutMs: 500,
134
134
  forceKillTimeoutMs: 200,
135
135
  ...timeoutOverrides,
136
+ ...proxyOptions,
136
137
  });
137
138
  }
138
139
  test("reverse Docker proxy ignores closed host stdin and shuts down through its private lifecycle pipe", async (t) => {
@@ -226,7 +227,7 @@ test("a Docker CLI killed before writing its cidfile falls back to the unique ge
226
227
  assert.ok(createdEvent, "fixture should expose the generated container name");
227
228
  assert.equal(await resultPromise, 137);
228
229
  const containerName = createdEvent.slice("created:".length);
229
- assert.match(containerName, /^staff-mcp-\d+-[0-9a-f-]{36}$/);
230
+ assert.match(containerName, /^staff-mcp-session-[0-9a-f]{6}$/);
230
231
  assert.ok(readEvents(eventsPath).includes(`rm:${containerName}`));
231
232
  });
232
233
  test("shutdown before cidfile creation stops the CLI before cleaning up by name", async (t) => {
@@ -354,4 +355,41 @@ test("Docker proxy refuses a pre-existing user cidfile to avoid cleaning a stale
354
355
  assert.equal(fs.readFileSync(cidFilePath, "utf8"), "unrelated-container\n");
355
356
  assert.equal(signals.listenerCount("SIGTERM"), 0);
356
357
  });
358
+ test("sanitizeNameSegment folds Docker-invalid characters and trims decorations", () => {
359
+ assert.equal(sanitizeNameSegment("Chat Poc!"), "chat-poc");
360
+ assert.equal(sanitizeNameSegment("--Weird__Name--"), "weird__name");
361
+ assert.equal(sanitizeNameSegment("my_app.v2"), "my_app.v2");
362
+ assert.equal(sanitizeNameSegment("工作 目录"), "");
363
+ assert.equal(sanitizeNameSegment(""), "");
364
+ assert.equal(sanitizeNameSegment("abc-def", 4), "abc");
365
+ assert.equal(sanitizeNameSegment("a".repeat(50)), "a".repeat(24));
366
+ });
367
+ test("buildDockerNameHint derives transport-aware hints from launch context", () => {
368
+ assert.equal(buildDockerNameHint({ workspaceDir: "/data/projs/chat-poc", transport: "stdio" }), "chat-poc");
369
+ assert.equal(buildDockerNameHint({ workspaceDir: "/data/projs/test", transport: "http", port: "18000" }), "test-18000");
370
+ assert.equal(buildDockerNameHint({ workspaceDir: "/data/projs/app", transport: "http" }), "app");
371
+ // reverseName identical to the workspace is redundant and therefore omitted
372
+ assert.equal(buildDockerNameHint({ workspaceDir: "/data/projs/chat-poc", transport: "reverse", reverseName: "chat-poc" }), "chat-poc");
373
+ assert.equal(buildDockerNameHint({ workspaceDir: "/data/projs/myapp", transport: "reverse", reverseName: "android-dev" }), "myapp-android-dev");
374
+ });
375
+ test("container name embeds a sanitized hint and a short random suffix", async (t) => {
376
+ const { fixturePath, eventsPath, capturePath } = createFixture(t);
377
+ const hostInput = new PassThrough();
378
+ const signals = new EventEmitter();
379
+ const resultPromise = runFixture(fixturePath, eventsPath, capturePath, "crash-before-cidfile", "reverse", hostInput, signals, {}, { nameHint: "My Proj_18000" });
380
+ const deadline = Date.now() + 3_000;
381
+ let createdEvent;
382
+ while (!createdEvent && Date.now() < deadline) {
383
+ createdEvent = readEvents(eventsPath).find((event) => event.startsWith("created:"));
384
+ if (!createdEvent) {
385
+ await delay(10);
386
+ }
387
+ }
388
+ assert.ok(createdEvent, "fixture should expose the generated container name");
389
+ assert.equal(await resultPromise, 137);
390
+ const containerName = createdEvent.slice("created:".length);
391
+ assert.match(containerName, /^staff-mcp-my-proj_18000-[0-9a-f]{6}$/);
392
+ assert.ok(containerName.length <= 63, "container name should stay within 63 characters");
393
+ assert.ok(readEvents(eventsPath).includes(`rm:${containerName}`));
394
+ });
357
395
  //# sourceMappingURL=docker-proxy.test.js.map