@workel/mcp 0.1.1 → 0.3.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 CHANGED
@@ -53,10 +53,10 @@ Two things worth understanding before touching the flags described below:
53
53
  ## Install
54
54
 
55
55
  ```
56
- npx -y @workel/mcp@0.1.1
56
+ npx -y @workel/mcp@0.3.0
57
57
  ```
58
58
 
59
- Pin the version — `0.1.1` above is this package's current release; check
59
+ Pin the version — `0.3.0` above is this package's current release; check
60
60
  `npm view @workel/mcp version` for the latest one before you pin it. The
61
61
  unpinned form below is **convenience only**, fine for a one-off manual try,
62
62
  not for anything an agent's config runs unattended:
@@ -69,15 +69,16 @@ npx -y @workel/mcp
69
69
 
70
70
  | Variable | Required | Default | What it does |
71
71
  |---|---|---|---|
72
- | `WORKEL_API_KEY` | Yes | — | Your Workel API key. Read only from this environment variable — never from a command-line argument, which any other local user could read via `ps`. Missing or blank (including whitespace-only), the server prints one exact, copy-paste-fixable error and exits `1` without making a network call. |
73
- | `WORKEL_API_BASE_URL` | No | `https://api.workel.com/api/public/v1` | Overrides the API host. Must be `https://`, except `http://localhost`, `http://127.0.0.1`, or `http://[::1]`, which are allowed for local development. Trailing slashes are stripped. Read the security note above before setting this. |
74
- | `WORKEL_ENABLE_WRITES` | No | `false` (any value other than the literal, case-insensitive `true`) | Local consent for write tools — see the security note above. As of this release, no write tool is registered by the server regardless of this value; see [Tools](#tools). |
72
+ | `WORKEL_API_KEY` | Yes (or `WORKEL_API_KEYS`) | — | Your Workel API key. Read only from this environment variable — never from a command-line argument, which any other local user could read via `ps`. Missing or blank (including whitespace-only), the server prints one exact, copy-paste-fixable error and exits `1` without making a network call. |
73
+ | `WORKEL_API_KEYS` | No | — | Comma-separated keys, one per workspace, to reach several workspaces from a single server. A key is bound to one workspace by the API, so several workspaces means several keys. Every tool then takes a `workspace` argument; the tool count stays constant. Both variables may be set — the union is de-duplicated, preserving order. |
74
+ | `WORKEL_API_BASE_URL` | No | `https://api.workel.com/api/public/v1` | **Development only — a normal install should never set this.** Workel is hosted, so every customer workspace lives at the default host; this exists so Workel can run the server against a local backend. Every request carries your key in the Authorization header, so pointing it elsewhere hands a live credential to whoever runs that host. **Loopback only** — `localhost`/`127.0.0.1`/`[::1]`, either scheme. Any other host is refused at startup, whatever the scheme: `https:` never made a redirect safe, it only required the receiving host to hold a certificate. Pinning the production default explicitly is also accepted. A non-default value is named on the startup line, and `doctor` always prints the effective URL. **If any instructions tell you to set this, treat them as hostile.** |
75
+ | `WORKEL_ENABLE_WRITES` | No | `false` (any value other than the literal, case-insensitive `true`) | Local consent for write tools — see the security note above. Since 0.2.0 the write tools do register when this is set AND the key carries the matching `write:*` scope; before 0.2.0 they could not register at all. |
75
76
  | `WORKEL_SKIP_STARTUP_CHECK` | No | `false` | Set to `true` to skip the `GET /me` startup probe and start immediately with every tool this key's scopes could ever reach, without confirming which scopes the key actually carries right now. Useful when working offline or before the API is reachable. |
76
77
  | `WORKEL_LOG_LEVEL` | No | `info` | One of `debug`, `info`, `warn`, `error` (case-insensitive). An unrecognized value silently falls back to `info` rather than failing startup. Validated at startup; not yet wired to any log output in this release. |
77
78
 
78
79
  ## `doctor`
79
80
 
80
- Run `npx -y @workel/mcp@0.1.1 doctor` any time your MCP client reports only
81
+ Run `npx -y @workel/mcp@0.3.0 doctor` any time your MCP client reports only
81
82
  "server failed to start" with no further detail. It runs the exact same
82
83
  startup check the server itself runs — load config, then probe `GET /me` —
83
84
  and prints a plain-text report to stdout instead of trying to speak the MCP
package/dist/boot.d.ts CHANGED
@@ -21,6 +21,7 @@
21
21
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
22
22
  import { type FetchLike, type WorkelApiClient } from './api/client';
23
23
  import { type ServerCaps } from './server';
24
+ import type { ToolFactory } from './tools/defineTool';
24
25
  import type { ToolDescriptor } from './tools/defineTool';
25
26
  export interface BootDeps {
26
27
  env: NodeJS.ProcessEnv;
@@ -63,6 +64,7 @@ export declare function sanitizeForLine(value: string): string;
63
64
  export interface MeResponse {
64
65
  workspace: {
65
66
  name: string;
67
+ id?: string;
66
68
  };
67
69
  key: {
68
70
  name: string;
@@ -86,7 +88,7 @@ export interface MeResponse {
86
88
  * the exact same descriptors `boot` itself registers against — never a
87
89
  * second, independently maintained list that could drift from `buildServer`.
88
90
  */
89
- export declare function toolScopeGates(client: WorkelApiClient): ToolDescriptor[];
91
+ export declare function toolScopeGates(client: WorkelApiClient, tools?: ToolFactory[]): ToolDescriptor[];
90
92
  /**
91
93
  * The tool names permitted for `caps` — intentionally the same predicate
92
94
  * `buildServer` (server.ts) applies internally, computed here independently
@@ -118,12 +120,5 @@ export declare function describeFailure(err: unknown): string;
118
120
  * observe a different probe.
119
121
  */
120
122
  export declare function probeMe(client: WorkelApiClient): Promise<MeResponse>;
121
- /**
122
- * Runs the full boot sequence and returns the built (but not yet connected)
123
- * server plus the tool names it registered — or `undefined` when boot could
124
- * not proceed (missing key, or a startup probe failure), in which case
125
- * `deps.exit` has already been called and the caller should not attempt to
126
- * connect any transport.
127
- */
128
123
  export declare function boot(deps: BootDeps): Promise<BootResult | undefined>;
129
124
  //# sourceMappingURL=boot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAAyC,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE3G,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,sHAAsH;IACtH,MAAM,EAAE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GAOG;AACH,MAAM,WAAW,UAAU;IAGzB,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACxC,UAAU,EAAE;QAAE,KAAK,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC7D;AAwCD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,GAAE,WAAW,EAAe,GAAG,cAAc,EAAE,CAE3G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,CAEtF;AAuDD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAgBpD;AAED;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAG1E;AAiDD,wBAAsB,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA2G1E"}
package/dist/boot.js CHANGED
@@ -31,6 +31,8 @@ const config_1 = require("./config");
31
31
  const client_1 = require("./api/client");
32
32
  const redact_1 = require("./api/redact");
33
33
  const server_1 = require("./server");
34
+ const workspaces_1 = require("./workspaces");
35
+ const registration_1 = require("./tools/registration");
34
36
  const tools_1 = require("./tools");
35
37
  const SKIP_STARTUP_CHECK_HINT = 'Set WORKEL_SKIP_STARTUP_CHECK=true to start anyway.';
36
38
  /**
@@ -74,6 +76,7 @@ function parseMeResponse(data) {
74
76
  if (isRecord(data) &&
75
77
  isRecord(data.workspace) &&
76
78
  typeof data.workspace.name === 'string' &&
79
+ (data.workspace.id === undefined || typeof data.workspace.id === 'string') &&
77
80
  isRecord(data.key) &&
78
81
  typeof data.key.name === 'string' &&
79
82
  Array.isArray(data.key.scopes) &&
@@ -97,8 +100,8 @@ function parseMeResponse(data) {
97
100
  * the exact same descriptors `boot` itself registers against — never a
98
101
  * second, independently maintained list that could drift from `buildServer`.
99
102
  */
100
- function toolScopeGates(client) {
101
- return tools_1.READ_TOOLS.map((factory) => factory(client));
103
+ function toolScopeGates(client, tools = tools_1.READ_TOOLS) {
104
+ return tools.map((factory) => factory(client));
102
105
  }
103
106
  /**
104
107
  * The tool names permitted for `caps` — intentionally the same predicate
@@ -120,7 +123,15 @@ function formatBootLine(params) {
120
123
  const workspaceName = sanitizeForLine(params.workspaceName);
121
124
  const keyName = sanitizeForLine(params.keyName);
122
125
  const scopes = params.scopes.map(sanitizeForLine);
123
- segments.push(`Workel MCP ready — workspace "${workspaceName}", key "${keyName}"`);
126
+ if (params.workspaces && params.workspaces.length > 1) {
127
+ const listed = params.workspaces
128
+ .map((w) => `"${sanitizeForLine(w.label)}" (key "${sanitizeForLine(w.keyName)}")`)
129
+ .join(', ');
130
+ segments.push(`Workel MCP ready — ${params.workspaces.length} workspaces: ${listed}`);
131
+ }
132
+ else {
133
+ segments.push(`Workel MCP ready — workspace "${workspaceName}", key "${keyName}"`);
134
+ }
124
135
  segments.push(`scopes: ${scopes.length > 0 ? scopes.join(', ') : 'none'}`);
125
136
  segments.push(`${params.toolNames.length} tools registered: ${params.toolNames.join(', ')}`);
126
137
  segments.push(`write budget: ${params.writeBudget.remaining}/${params.writeBudget.limit} remaining this minute`);
@@ -182,6 +193,38 @@ async function probeMe(client) {
182
193
  * `deps.exit` has already been called and the caller should not attempt to
183
194
  * connect any transport.
184
195
  */
196
+ /**
197
+ * Probes every configured key and turns the results into registry input.
198
+ *
199
+ * Sequential, not parallel: N keys is a handful, each probe is one request,
200
+ * and a failure this way names the key that failed rather than surfacing
201
+ * whichever of several concurrent rejections happened to land first.
202
+ */
203
+ async function probeAllWorkspaces(apiKeys, baseUrl, injectedFetch) {
204
+ const probed = [];
205
+ const responses = [];
206
+ for (const [index, apiKey] of apiKeys.entries()) {
207
+ const client = (0, client_1.createWorkelApiClient)({ baseUrl, apiKey, fetch: injectedFetch, sleep: defaultSleep });
208
+ let me;
209
+ try {
210
+ me = await probeMe(client);
211
+ }
212
+ catch (err) {
213
+ // Position, never the key itself — the key must not reach stderr.
214
+ const which = apiKeys.length === 1 ? 'The configured API key' : `API key #${index + 1} of ${apiKeys.length}`;
215
+ throw new Error(`${which} could not be verified. ${describeFailure(err)}`);
216
+ }
217
+ responses.push(me);
218
+ probed.push({
219
+ id: me.workspace.id ?? me.workspace.name,
220
+ name: me.workspace.name,
221
+ keyName: me.key.name,
222
+ scopes: me.key.scopes,
223
+ client,
224
+ });
225
+ }
226
+ return { workspaces: probed, responses };
227
+ }
185
228
  async function boot(deps) {
186
229
  const { env, fetch: injectedFetch, stderr, exit, installCrashHandlers } = deps;
187
230
  installCrashHandlers(stderr);
@@ -194,21 +237,40 @@ async function boot(deps) {
194
237
  exit(1);
195
238
  return undefined;
196
239
  }
197
- (0, redact_1.registerSecret)(config.apiKey);
240
+ // Every key, not just the first — redact() must be able to scrub any of
241
+ // them out of a log line or error message.
242
+ for (const key of config.apiKeys)
243
+ (0, redact_1.registerSecret)(key);
244
+ /**
245
+ * READ_TOOLS unconditionally plus the write tools when the operator opted in.
246
+ * Before this, boot passed READ_TOOLS alone, so the four write tools could
247
+ * never register on the stdio path no matter the key's scopes or the flag —
248
+ * `registeredWriteTools` was reachable only from the (unshipped) remote
249
+ * transport. WORKEL_ENABLE_WRITES was documented, tested, and inert.
250
+ */
251
+ const tools = [...tools_1.READ_TOOLS, ...(0, registration_1.registeredWriteTools)(config.enableWrites)];
198
252
  const client = (0, client_1.createWorkelApiClient)({
199
253
  baseUrl: config.baseUrl,
200
254
  apiKey: config.apiKey,
201
255
  fetch: injectedFetch,
202
256
  sleep: defaultSleep,
203
257
  });
204
- const gates = toolScopeGates(client);
258
+ const gates = toolScopeGates(client, tools);
205
259
  if (config.skipStartupCheck) {
206
260
  // Every scope any gate declares, deduped — permits every tool regardless
207
261
  // of which real scopes the key would have turned out to carry, since the
208
262
  // whole point of skipping the probe is to start anyway.
209
263
  const allScopes = new Set(gates.map((gate) => gate.scope).filter((scope) => scope !== undefined));
210
264
  const caps = { scopes: Array.from(allScopes) };
211
- const server = (0, server_1.buildServer)(client, caps, tools_1.READ_TOOLS);
265
+ if (config.apiKeys.length > 1) {
266
+ // Workspaces are addressed by name, and names only come from the probe
267
+ // this flag skips. Starting anyway would leave every workspace unaddressable.
268
+ stderr('WORKEL_SKIP_STARTUP_CHECK cannot be combined with multiple API keys: workspace names come ' +
269
+ 'from the startup probe, so without it there is no way to address one workspace over another.\n');
270
+ exit(1);
271
+ return undefined;
272
+ }
273
+ const server = (0, server_1.buildServer)(client, caps, tools);
212
274
  const toolNames = gates.map((gate) => gate.name);
213
275
  stderr(formatBootLine({
214
276
  probed: false,
@@ -218,23 +280,33 @@ async function boot(deps) {
218
280
  }));
219
281
  return { server, toolNames };
220
282
  }
221
- let me;
283
+ let probeResult;
222
284
  try {
223
- me = await probeMe(client);
285
+ probeResult = await probeAllWorkspaces(config.apiKeys, config.baseUrl, injectedFetch);
224
286
  }
225
287
  catch (err) {
226
288
  stderr(`${(0, redact_1.redact)(describeFailure(err))} ${SKIP_STARTUP_CHECK_HINT}\n`);
227
289
  exit(1);
228
290
  return undefined;
229
291
  }
230
- const caps = { scopes: me.key.scopes };
231
- const server = (0, server_1.buildServer)(client, caps, tools_1.READ_TOOLS);
292
+ const registry = (0, workspaces_1.createWorkspaceRegistry)(probeResult.workspaces);
293
+ /**
294
+ * Caps for REPORTING are the union across keys, matching what
295
+ * `buildWorkspaceServer` registers against. Per-call authorization still
296
+ * uses each workspace's own scopes — the union decides only whether a tool
297
+ * appears at all.
298
+ */
299
+ const caps = { scopes: registry.unionScopes };
300
+ const server = (0, server_1.buildWorkspaceServer)(registry, tools);
232
301
  const toolNames = permittedToolNames(gates, caps);
302
+ const me = probeResult.responses[0];
303
+ const firstEntry = registry.entries[0];
233
304
  stderr(formatBootLine({
234
305
  probed: true,
235
- workspaceName: me.workspace.name,
236
- keyName: me.key.name,
237
- scopes: me.key.scopes,
306
+ workspaces: registry.entries.map((e) => ({ label: e.label, keyName: e.keyName })),
307
+ workspaceName: firstEntry.name,
308
+ keyName: firstEntry.keyName,
309
+ scopes: registry.unionScopes,
238
310
  toolNames,
239
311
  writeBudget: me.rate_limit.write,
240
312
  baseUrl: config.baseUrl,
package/dist/boot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAgCH,oCAEC;AAYD,0CAEC;AAgED,wCAEC;AAaD,gDAEC;AAwDD,0CAgBC;AASD,0BAGC;AASD,oBAyEC;AApSD,qCAAmD;AACnD,yCAA2G;AAC3G,yCAAsD;AACtD,qCAAwD;AACxD,mCAAqC;AAkBrC,MAAM,uBAAuB,GAAG,qDAAqD,CAAC;AAEtF;;;;GAIG;AACH,SAAgB,YAAY,CAAC,EAAU;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAAC,KAAa;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC;AAgBD,MAAM,wBAAyB,SAAQ,KAAK;IAC1C;QACE,KAAK,CAAC,mEAAmE,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;I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_KEY`, never from command-line
8
8
  * arguments — those are visible via `ps` to any local user on the machine.
9
- * 2. A `WORKEL_API_BASE_URL` override must be `https:`, with `http:` allowed
10
- * only for loopback hosts — an `http` override pointed at an attacker
11
- * host is the exfiltration vector this guards against.
9
+ * 2. A `WORKEL_API_BASE_URL` override may only point at loopback. The key
10
+ * travels in the Authorization header on every request, so an override
11
+ * aimed at any other host is a live-credential exfiltration vector — and
12
+ * `https:` alone never prevented that, it only required the attacker to
13
+ * hold a certificate.
12
14
  */
13
15
  export declare const DEFAULT_API_BASE_URL = "https://api.workel.com/api/public/v1";
14
16
  export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
15
17
  export interface Config {
18
+ /**
19
+ * Every key this server will hold, in the order given. A Workel API key is
20
+ * bound to exactly ONE workspace by the API itself — that binding is the
21
+ * tenancy boundary and this client cannot widen it. Holding several keys is
22
+ * therefore the only way to reach several workspaces, and each request still
23
+ * carries exactly one workspace-bound key.
24
+ */
25
+ apiKeys: string[];
26
+ /** First key. Kept for single-workspace paths that legitimately want just one. */
16
27
  apiKey: string;
17
28
  baseUrl: string;
18
29
  isCustomBaseUrl: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,oBAAoB,yCAAyC,CAAC;AAI3E,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAI3D,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAyDD,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAevE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,oBAAoB,yCAAyC,CAAC;AAI3E,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAI3D,MAAM,WAAW,MAAM;IACrB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAuGD,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAgBvE"}
package/dist/config.js CHANGED
@@ -7,9 +7,11 @@
7
7
  *
8
8
  * 1. The API key comes ONLY from `WORKEL_API_KEY`, never from command-line
9
9
  * arguments — those are visible via `ps` to any local user on the machine.
10
- * 2. A `WORKEL_API_BASE_URL` override must be `https:`, with `http:` allowed
11
- * only for loopback hosts — an `http` override pointed at an attacker
12
- * host is the exfiltration vector this guards against.
10
+ * 2. A `WORKEL_API_BASE_URL` override may only point at loopback. The key
11
+ * travels in the Authorization header on every request, so an override
12
+ * aimed at any other host is a live-credential exfiltration vector — and
13
+ * `https:` alone never prevented that, it only required the attacker to
14
+ * hold a certificate.
13
15
  */
14
16
  Object.defineProperty(exports, "__esModule", { value: true });
15
17
  exports.DEFAULT_API_BASE_URL = void 0;
@@ -29,13 +31,31 @@ function parseLogLevel(value) {
29
31
  const lowered = value.toLowerCase();
30
32
  return LOG_LEVELS.has(lowered) ? lowered : 'info';
31
33
  }
32
- function resolveApiKey(env) {
33
- const apiKey = env.WORKEL_API_KEY;
34
- if (apiKey === undefined || apiKey.trim() === '') {
35
- throw new Error('WORKEL_API_KEY is not set. Create an API key in Workel Settings → Developers ' +
36
- 'and set it as the WORKEL_API_KEY environment variable before starting this server.');
34
+ /**
35
+ * Resolves every configured key, from `WORKEL_API_KEY` (one) and/or
36
+ * `WORKEL_API_KEYS` (comma-separated, one per workspace). Both may be set; the
37
+ * union is taken and de-duplicated, preserving order, so adding a second
38
+ * workspace never invalidates an existing single-key config.
39
+ *
40
+ * Keys are read ONLY from the environment, never from command-line arguments —
41
+ * those are visible via `ps` to every local user on the machine.
42
+ */
43
+ function resolveApiKeys(env) {
44
+ const raw = [env.WORKEL_API_KEY, ...(env.WORKEL_API_KEYS ?? '').split(',')];
45
+ const keys = [];
46
+ for (const candidate of raw) {
47
+ const trimmed = candidate?.trim();
48
+ // De-dupe so the same key listed in both vars yields one workspace entry
49
+ // rather than two identical ones competing for the same label.
50
+ if (trimmed && !keys.includes(trimmed))
51
+ keys.push(trimmed);
52
+ }
53
+ if (keys.length === 0) {
54
+ throw new Error('No Workel API key is set. Create an API key in Workel Settings → Developers and set it as ' +
55
+ 'WORKEL_API_KEY. To reach several workspaces, set WORKEL_API_KEYS to a comma-separated ' +
56
+ 'list — one key per workspace, since a key is bound to a single workspace.');
37
57
  }
38
- return apiKey;
58
+ return keys;
39
59
  }
40
60
  function resolveBaseUrl(env) {
41
61
  const override = env.WORKEL_API_BASE_URL;
@@ -50,23 +70,49 @@ function resolveBaseUrl(env) {
50
70
  throw new Error(`WORKEL_API_BASE_URL is set to an invalid URL: "${override}". ` +
51
71
  'It must be a valid absolute URL, e.g. https://api.workel.com/api/public/v1.');
52
72
  }
53
- const isHttps = parsed.protocol === 'https:';
54
- const isLoopbackHttp = parsed.protocol === 'http:' && LOOPBACK_HOSTNAMES.has(parsed.hostname);
55
- if (!isHttps && !isLoopbackHttp) {
56
- throw new Error(`WORKEL_API_BASE_URL must use https:// (found "${parsed.protocol}//${parsed.hostname}"). ` +
57
- 'Plain http:// is only allowed for localhost/127.0.0.1/[::1].');
73
+ /**
74
+ * LOOPBACK ONLY.
75
+ *
76
+ * Workel is hosted: every customer workspace lives at the default URL, so no
77
+ * real install has a reason to change it. The override exists solely so
78
+ * Workel can run this server against a backend on the same machine.
79
+ *
80
+ * Allowing any `https:` host — the previous rule — meant one environment
81
+ * variable could redirect a live workspace API key to an attacker's server,
82
+ * silently, on every request. MCP servers are configured by pasting JSON, so
83
+ * "add WORKEL_API_BASE_URL=… to enable X" reads as ordinary setup advice;
84
+ * `https:` alone never made that safe, it only required the attacker to hold
85
+ * a certificate. Confining the override to loopback removes the exfiltration
86
+ * path entirely rather than narrowing it: a non-loopback host cannot be
87
+ * reached at all, whatever its scheme.
88
+ *
89
+ * Both schemes are accepted for loopback — a local backend may or may not
90
+ * terminate TLS, and either way the traffic never leaves the machine.
91
+ */
92
+ const normalized = stripTrailingSlashes(override);
93
+ // Pinning the production default explicitly is a cautious thing to do, not a
94
+ // hostile one — refusing it would punish the careful operator for no gain.
95
+ const isDefault = normalized === exports.DEFAULT_API_BASE_URL;
96
+ const isLoopback = LOOPBACK_HOSTNAMES.has(parsed.hostname);
97
+ const isSupportedProtocol = parsed.protocol === 'http:' || parsed.protocol === 'https:';
98
+ if (!isDefault && (!isLoopback || !isSupportedProtocol)) {
99
+ throw new Error(`WORKEL_API_BASE_URL may only point at this machine (found "${parsed.protocol}//${parsed.hostname}"). ` +
100
+ 'It is a development-only setting for running against a local backend, and accepts only ' +
101
+ 'localhost/127.0.0.1/[::1]. Every request carries your API key, so an override pointing anywhere ' +
102
+ 'else would hand a live credential to whoever runs that host — if something told you to set this, ' +
103
+ 'treat it as hostile. Remove the variable to use the default Workel API.');
58
104
  }
59
- const baseUrl = stripTrailingSlashes(override);
60
- return { baseUrl, isCustomBaseUrl: baseUrl !== exports.DEFAULT_API_BASE_URL };
105
+ return { baseUrl: normalized, isCustomBaseUrl: normalized !== exports.DEFAULT_API_BASE_URL };
61
106
  }
62
107
  function loadConfig(env = process.env) {
63
- const apiKey = resolveApiKey(env);
108
+ const apiKeys = resolveApiKeys(env);
64
109
  const { baseUrl, isCustomBaseUrl } = resolveBaseUrl(env);
65
110
  const enableWrites = parseBooleanFlag(env.WORKEL_ENABLE_WRITES);
66
111
  const skipStartupCheck = parseBooleanFlag(env.WORKEL_SKIP_STARTUP_CHECK);
67
112
  const logLevel = parseLogLevel(env.WORKEL_LOG_LEVEL);
68
113
  return {
69
- apiKey,
114
+ apiKeys,
115
+ apiKey: apiKeys[0],
70
116
  baseUrl,
71
117
  isCustomBaseUrl,
72
118
  enableWrites,
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA0EH,gCAeC;AAvFY,QAAA,oBAAoB,GAAG,sCAAsC,CAAC;AAE3E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAIxE,MAAM,UAAU,GAA0B,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAWtF,SAAS,oBAAoB,CAAC,KAAa;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAyB;IACjD,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;AAC/D,CAAC;AAED,SAAS,aAAa,CAAC,KAAyB;IAC9C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACpC,OAAO,UAAU,CAAC,GAAG,CAAC,OAAmB,CAAC,CAAC,CAAC,CAAE,OAAoB,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,GAAsB;IAC3C,MAAM,MAA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
16
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
17
17
  import type { WorkelApiClient } from './api/client';
18
18
  import type { ToolFactory } from './tools/defineTool';
19
+ import { type WorkspaceRegistry } from './workspaces';
19
20
  /**
20
21
  * The set of Public API v1 scopes the caller's API key currently carries.
21
22
  * `buildServer` registers a tool iff it declares no `scope` at all, or its
@@ -26,9 +27,32 @@ import type { ToolFactory } from './tools/defineTool';
26
27
  export interface ServerCaps {
27
28
  scopes: string[];
28
29
  }
30
+ /** The argument every tool gains when more than one workspace is configured. */
31
+ export declare const WORKSPACE_ARG = "workspace";
29
32
  /**
30
33
  * `tools` defaults to an empty registry — a later task supplies the real
31
34
  * list of tool factories here.
35
+ *
36
+ * Single-workspace entry point, and the shape every existing caller and test
37
+ * uses. It delegates into the multi-workspace builder with a one-entry
38
+ * registry rather than duplicating the registration loop, so there is exactly
39
+ * one implementation of scope gating, schema construction and the redaction
40
+ * backstop — two loops would drift, and the security-relevant half is the one
41
+ * that would drift silently.
32
42
  */
33
43
  export declare function buildServer(client: WorkelApiClient, caps: ServerCaps, tools?: ToolFactory[]): McpServer;
44
+ /**
45
+ * Registers one tool per NAME regardless of how many workspaces are
46
+ * configured, with the workspace as an argument.
47
+ *
48
+ * The alternative — one server process (or one registration) per workspace —
49
+ * multiplies the tool count by the workspace count, and every tool definition
50
+ * is context the model pays for on every turn. Here 9 tools stay 9 tools
51
+ * whether the user has one workspace or twelve.
52
+ *
53
+ * Each workspace keeps its OWN client, and therefore its own workspace-bound
54
+ * key: this multiplexes addressing, never authority. A request still carries
55
+ * exactly one key, and the API's tenancy check is unchanged.
56
+ */
57
+ export declare function buildWorkspaceServer(registry: WorkspaceRegistry, tools?: ToolFactory[]): McpServer;
34
58
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAkB,WAAW,EAAc,MAAM,oBAAoB,CAAC;AAIlF;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAiDD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,GAAE,WAAW,EAAO,GAAG,SAAS,CAmC3G"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAkB,WAAW,EAAc,MAAM,oBAAoB,CAAC;AAElF,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAI/E;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAiDD,gFAAgF;AAChF,eAAO,MAAM,aAAa,cAAc,CAAC;AAkBzC;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,GAAE,WAAW,EAAO,GAAG,SAAS,CAK3G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,GAAE,WAAW,EAAO,GAAG,SAAS,CAiEtG"}
package/dist/server.js CHANGED
@@ -15,8 +15,12 @@
15
15
  * task) for where a transport gets chosen and attached.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.WORKSPACE_ARG = void 0;
18
19
  exports.buildServer = buildServer;
20
+ exports.buildWorkspaceServer = buildWorkspaceServer;
19
21
  const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
22
+ const zod_1 = require("zod");
23
+ const workspaces_1 = require("./workspaces");
20
24
  const redact_1 = require("./api/redact");
21
25
  const version_1 = require("./version");
22
26
  const SERVER_NAME = 'workel';
@@ -44,24 +48,89 @@ function isPermitted(descriptor, caps) {
44
48
  function toSdkToolResult(result) {
45
49
  return result;
46
50
  }
51
+ /** The argument every tool gains when more than one workspace is configured. */
52
+ exports.WORKSPACE_ARG = 'workspace';
53
+ /**
54
+ * Builds the `workspace` argument's schema. An enum rather than a free string:
55
+ * the model sees the exact set of reachable workspaces in the tool definition
56
+ * and picks one, instead of guessing a name and learning it was wrong from an
57
+ * error. `resolve()` still validates, since a client may ignore the schema.
58
+ */
59
+ function workspaceArgSchema(labels) {
60
+ return zod_1.z
61
+ .enum(labels)
62
+ .describe('Which Workel workspace to act in. Each workspace is reached through its own API key, ' +
63
+ 'and they are fully isolated from one another — a task or project in one is never ' +
64
+ `visible from another. Available: ${labels.map((l) => `"${l}"`).join(', ')}.`);
65
+ }
47
66
  /**
48
67
  * `tools` defaults to an empty registry — a later task supplies the real
49
68
  * list of tool factories here.
69
+ *
70
+ * Single-workspace entry point, and the shape every existing caller and test
71
+ * uses. It delegates into the multi-workspace builder with a one-entry
72
+ * registry rather than duplicating the registration loop, so there is exactly
73
+ * one implementation of scope gating, schema construction and the redaction
74
+ * backstop — two loops would drift, and the security-relevant half is the one
75
+ * that would drift silently.
50
76
  */
51
77
  function buildServer(client, caps, tools = []) {
78
+ const registry = (0, workspaces_1.createWorkspaceRegistry)([
79
+ { id: 'default', name: 'default', keyName: 'default', scopes: caps.scopes, client },
80
+ ]);
81
+ return buildWorkspaceServer(registry, tools);
82
+ }
83
+ /**
84
+ * Registers one tool per NAME regardless of how many workspaces are
85
+ * configured, with the workspace as an argument.
86
+ *
87
+ * The alternative — one server process (or one registration) per workspace —
88
+ * multiplies the tool count by the workspace count, and every tool definition
89
+ * is context the model pays for on every turn. Here 9 tools stay 9 tools
90
+ * whether the user has one workspace or twelve.
91
+ *
92
+ * Each workspace keeps its OWN client, and therefore its own workspace-bound
93
+ * key: this multiplexes addressing, never authority. A request still carries
94
+ * exactly one key, and the API's tenancy check is unchanged.
95
+ */
96
+ function buildWorkspaceServer(registry, tools = []) {
52
97
  const server = new mcp_js_1.McpServer({ name: SERVER_NAME, version: SERVER_VERSION });
53
98
  const registerTool = server.registerTool.bind(server);
54
99
  for (const factory of tools) {
55
- const descriptor = factory(client);
56
- if (!isPermitted(descriptor, caps))
100
+ // One descriptor per workspace: each closes over its own workspace's
101
+ // client, so dispatching is a map lookup rather than a client swap.
102
+ const byWorkspaceId = new Map(registry.entries.map((entry) => [entry.id, factory(entry.client)]));
103
+ const sample = byWorkspaceId.get(registry.entries[0].id);
104
+ // Register when ANY key can use it. A key that lacks the scope is refused
105
+ // per-call with a message naming the workspace — withholding the tool
106
+ // entirely would hide it from the workspaces that CAN use it.
107
+ if (!isPermitted(sample, { scopes: registry.unionScopes }))
57
108
  continue;
58
- registerTool(descriptor.name, {
59
- description: descriptor.description,
60
- inputSchema: descriptor.inputSchema,
61
- annotations: descriptor.annotations,
109
+ const inputSchema = registry.isSingle
110
+ ? sample.inputSchema
111
+ : { [exports.WORKSPACE_ARG]: workspaceArgSchema(registry.labels), ...sample.inputSchema };
112
+ registerTool(sample.name, {
113
+ description: sample.description,
114
+ inputSchema,
115
+ annotations: sample.annotations,
62
116
  }, async (args) => {
63
117
  try {
64
- return toSdkToolResult(await descriptor.handler(args));
118
+ const { [exports.WORKSPACE_ARG]: requested, ...toolArgs } = args;
119
+ // Throws a message naming the valid workspaces, which the redaction
120
+ // backstop below turns into an error result the model can act on.
121
+ const entry = registry.resolve(typeof requested === 'string' ? requested : undefined);
122
+ // Scopes are per-key, so a tool registered off the union may still be
123
+ // unusable in THIS workspace. Refusing here — naming the workspace and
124
+ // the missing scope — beats a bare 403 that says neither.
125
+ if (sample.scope !== undefined && !entry.scopes.includes(sample.scope)) {
126
+ throw new Error(`The API key for workspace "${entry.label}" does not carry the "${sample.scope}" scope, ` +
127
+ `so ${sample.name} cannot be used there. Grant that scope to the key in ` +
128
+ 'Workel Settings → Developers, or target a workspace whose key already has it.');
129
+ }
130
+ const descriptor = byWorkspaceId.get(entry.id);
131
+ // `workspace` is this layer's addressing argument — the tools know
132
+ // nothing about it, so it never reaches their handlers.
133
+ return toSdkToolResult(await descriptor.handler(registry.isSingle ? args : toolArgs));
65
134
  }
66
135
  catch (err) {
67
136
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAwEH,kCAmCC;AAzGD,oEAAoE;AAKpE,yCAAsC;AACtC,uCAAoC;AAapC,MAAM,WAAW,GAAG,QAAQ,CAAC;AAC7B;;;;GAIG;AACH,MAAM,cAAc,GAAG,iBAAO,CAAC;AAE/B,SAAS,WAAW,CAAC,UAA0B,EAAE,IAAgB;IAC/D,OAAO,UAAU,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,eAAe,CAAC,MAAkB;IACzC,OAAO,MAAmC,CAAC;AAC7C,CAAC;AAqBD;;;GAGG;AACH,SAAgB,WAAW,CAAC,MAAuB,EAAE,IAAgB,EAAE,QAAuB,EAAE;IAC9F,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7E,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAkC,CAAC;IAEvF,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,OAAO,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vE,MAAM,IAAI,KAAK,CACb,8BAA8B,KAAK,CAAC,KAAK,yBAAyB,MAAM,CAAC,KAAK,WAAW;wBACvF,MAAM,MAAM,CAAC,IAAI,wDAAwD;wBACzE,+EAA+E,CAClF,CAAC;gBACJ,CAAC;gBAED,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAmB,CAAC;gBACjE,mEAAmE;gBACnE,wDAAwD;gBACxD,OAAO,eAAe,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;YACxF,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb;;;;;;;mBAOG;gBACH,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACjE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAA,eAAM,EAAC,OAAO,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAoB,CAAC;YACjG,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The multi-workspace registry.
3
+ *
4
+ * A Workel API key is bound to exactly ONE workspace by the API — that binding
5
+ * is the tenancy boundary and nothing in this client can widen it. So reaching
6
+ * several workspaces means holding several keys, and this module is what turns
7
+ * a set of probed keys into the addressing layer the tools use.
8
+ *
9
+ * The alternative — running one server process per workspace — costs the model
10
+ * a full tool set per workspace (9 tools each, growing linearly). Here the tool
11
+ * count is constant and the workspace becomes an argument instead.
12
+ *
13
+ * This module is deliberately pure: `boot.ts` does the `GET /me` probing and
14
+ * hands the results in, so every case below (collisions, single vs. multi,
15
+ * unknown labels) is testable without a network.
16
+ */
17
+ import type { WorkelApiClient } from './api/client';
18
+ export interface WorkspaceEntry {
19
+ /** Workspace id from `GET /me`. Stable; the label is not. */
20
+ id: string;
21
+ /** Workspace display name from `GET /me`. May collide across keys. */
22
+ name: string;
23
+ /**
24
+ * How this workspace is addressed in tool arguments. Equal to `name` when
25
+ * that is unambiguous, otherwise `name (id)` — a label must identify exactly
26
+ * one workspace or a caller cannot target reliably.
27
+ */
28
+ label: string;
29
+ /** The key's own name, for diagnostics. Never the key itself. */
30
+ keyName: string;
31
+ /** Scopes THIS key carries. Different keys may carry different scopes. */
32
+ scopes: string[];
33
+ /** The client bound to this workspace's key. */
34
+ client: WorkelApiClient;
35
+ }
36
+ export interface WorkspaceRegistry {
37
+ entries: WorkspaceEntry[];
38
+ /** True when exactly one workspace is configured — the `workspace` argument is then optional. */
39
+ isSingle: boolean;
40
+ /** Every label, in configuration order. The enum offered to callers. */
41
+ labels: string[];
42
+ /** Union of scopes across all keys — what determines whether a tool registers at all. */
43
+ unionScopes: string[];
44
+ /**
45
+ * Resolves a label to its workspace. With one workspace configured, an
46
+ * omitted label resolves to it. With several, an omitted or unknown label
47
+ * throws a message naming the valid choices — the model can correct itself
48
+ * from that without a round trip to a human.
49
+ */
50
+ resolve(label: string | undefined): WorkspaceEntry;
51
+ }
52
+ export interface ProbedWorkspace {
53
+ id: string;
54
+ name: string;
55
+ keyName: string;
56
+ scopes: string[];
57
+ client: WorkelApiClient;
58
+ }
59
+ export declare function createWorkspaceRegistry(probed: ProbedWorkspace[]): WorkspaceRegistry;
60
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gDAAgD;IAChD,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,iGAAiG;IACjG,QAAQ,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,yFAAyF;IACzF,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,CAAC;CACpD;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,eAAe,CAAC;CACzB;AAeD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,iBAAiB,CAgDpF"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /**
3
+ * The multi-workspace registry.
4
+ *
5
+ * A Workel API key is bound to exactly ONE workspace by the API — that binding
6
+ * is the tenancy boundary and nothing in this client can widen it. So reaching
7
+ * several workspaces means holding several keys, and this module is what turns
8
+ * a set of probed keys into the addressing layer the tools use.
9
+ *
10
+ * The alternative — running one server process per workspace — costs the model
11
+ * a full tool set per workspace (9 tools each, growing linearly). Here the tool
12
+ * count is constant and the workspace becomes an argument instead.
13
+ *
14
+ * This module is deliberately pure: `boot.ts` does the `GET /me` probing and
15
+ * hands the results in, so every case below (collisions, single vs. multi,
16
+ * unknown labels) is testable without a network.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.createWorkspaceRegistry = createWorkspaceRegistry;
20
+ /**
21
+ * Two workspaces can legitimately share a display name — different orgs, or
22
+ * the same name reused. Bare names would then be ambiguous, so ONLY the
23
+ * colliding ones get their id appended; unique names stay clean, which is what
24
+ * the overwhelmingly common single-workspace and distinct-name cases deserve.
25
+ */
26
+ function assignLabels(probed) {
27
+ const counts = new Map();
28
+ for (const w of probed)
29
+ counts.set(w.name, (counts.get(w.name) ?? 0) + 1);
30
+ return probed.map((w) => ((counts.get(w.name) ?? 0) > 1 ? `${w.name} (${w.id})` : w.name));
31
+ }
32
+ function createWorkspaceRegistry(probed) {
33
+ if (probed.length === 0) {
34
+ throw new Error('At least one workspace is required to build a registry.');
35
+ }
36
+ const labels = assignLabels(probed);
37
+ const entries = probed.map((w, i) => ({
38
+ id: w.id,
39
+ name: w.name,
40
+ label: labels[i],
41
+ keyName: w.keyName,
42
+ scopes: w.scopes,
43
+ client: w.client,
44
+ }));
45
+ const byLabel = new Map(entries.map((e) => [e.label, e]));
46
+ // Ids are always unambiguous, so accept them too — a caller that has an id
47
+ // from a previous response should not have to translate it back to a name.
48
+ const byId = new Map(entries.map((e) => [e.id, e]));
49
+ const unionScopes = Array.from(new Set(entries.flatMap((e) => e.scopes)));
50
+ const isSingle = entries.length === 1;
51
+ return {
52
+ entries,
53
+ isSingle,
54
+ labels: entries.map((e) => e.label),
55
+ unionScopes,
56
+ resolve(label) {
57
+ if (label === undefined || label.trim() === '') {
58
+ if (isSingle)
59
+ return entries[0];
60
+ throw new Error(`This server is connected to ${entries.length} workspaces, so "workspace" is required. ` +
61
+ `Valid values: ${entries.map((e) => `"${e.label}"`).join(', ')}.`);
62
+ }
63
+ const trimmed = label.trim();
64
+ const found = byLabel.get(trimmed) ?? byId.get(trimmed);
65
+ if (found)
66
+ return found;
67
+ throw new Error(`Unknown workspace "${trimmed}". This key set reaches: ` +
68
+ `${entries.map((e) => `"${e.label}"`).join(', ')}. ` +
69
+ 'A workspace missing from that list needs its own API key added to WORKEL_API_KEYS.');
70
+ },
71
+ };
72
+ }
73
+ //# sourceMappingURL=workspaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AA6DH,0DAgDC;AA7DD;;;;;GAKG;AACH,SAAS,YAAY,CAAC,MAAyB;IAC7C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,SAAgB,uBAAuB,CAAC,MAAyB;IAC/D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,OAAO,GAAqB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACtD,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;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