@workel/mcp 0.1.0 → 0.2.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/LICENSE +21 -0
- package/README.md +8 -7
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +56 -1
- package/dist/api/client.js.map +1 -1
- package/dist/boot.d.ts +3 -8
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js +85 -13
- package/dist/boot.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +27 -8
- package/dist/config.js.map +1 -1
- package/dist/server.d.ts +24 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +100 -8
- package/dist/server.js.map +1 -1
- package/dist/tools/workel_project_columns.js +1 -1
- package/dist/tools/workel_project_columns.js.map +1 -1
- package/dist/tools/workel_task_comments.d.ts +1 -1
- package/dist/tools/workel_task_comments.d.ts.map +1 -1
- package/dist/tools/workel_task_comments.js +10 -8
- package/dist/tools/workel_task_comments.js.map +1 -1
- package/dist/workspaces.d.ts +60 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +73 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +12 -3
- package/dist/remote.d.ts +0 -164
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -456
- package/dist/remote.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Workel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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.
|
|
56
|
+
npx -y @workel/mcp@0.2.0
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Pin the version — `0.
|
|
59
|
+
Pin the version — `0.2.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. |
|
|
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. |
|
|
73
74
|
| `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.
|
|
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.
|
|
81
|
+
Run `npx -y @workel/mcp@0.2.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
|
|
@@ -107,7 +108,7 @@ This release registers the following read-only tools. `workel_whoami` needs
|
|
|
107
108
|
no scope at all and works with any valid key; every other tool is only
|
|
108
109
|
registered when the key's scopes (discovered via the `GET /me` probe above)
|
|
109
110
|
include the scope listed. List tools return 25 results per call by default
|
|
110
|
-
(100
|
|
111
|
+
(50 max — this client caps below the API's own 100 deliberately, see src/tools/conventions.ts) and page via an opaque `cursor` / `next_cursor` pair.
|
|
111
112
|
|
|
112
113
|
| Tool | Scope | What it does |
|
|
113
114
|
|---|---|---|
|
|
@@ -117,7 +118,7 @@ include the scope listed. List tools return 25 results per call by default
|
|
|
117
118
|
| `workel_list_project_columns` | `read:projects` | List a project's board columns — its kanban lists such as "To Do" or "Done" — not the tasks inside them. |
|
|
118
119
|
| `workel_list_tasks` | `read:tasks` | List tasks, filterable by project, column, completion, and due-date/update-time. There is no text search on this endpoint. |
|
|
119
120
|
| `workel_get_task` | `read:tasks` | Fetch one task by id, including its full (possibly truncated) description. |
|
|
120
|
-
| `workel_list_task_comments` | `read:tasks` | List every comment on a task
|
|
121
|
+
| `workel_list_task_comments` | `read:tasks` | List every comment on a task — top-level comments and replies together. Order is unspecified; sort by `created_at`. |
|
|
121
122
|
| `workel_list_members` | `read:members` | List the workspace's active members — the only tool that returns email addresses. |
|
|
122
123
|
| `workel_list_events` | `read:events` | List events on the workspace and any of its visible projects. |
|
|
123
124
|
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAKH,OAAO,EAAe,KAAK,cAAc,EAAoB,MAAM,UAAU,CAAC;AAE9E,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AACrC,MAAM,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtD,sGAAsG;AACtG,eAAO,MAAM,0BAA0B,QAAS,CAAC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AAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9G,qEAAqE;IACrE,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/E;AASD;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEtB,MAAM,EAAE,cAAc;CAQnC;AA6ID,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,GAAG,eAAe,CAsKhF;AAMD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,eAAe,CAQlG"}
|
package/dist/api/client.js
CHANGED
|
@@ -150,6 +150,45 @@ async function readResponseBody(response) {
|
|
|
150
150
|
* once it reaches a tool. Throwing a mapped, retryable error instead means
|
|
151
151
|
* the failure reads the same as every other API failure.
|
|
152
152
|
*/
|
|
153
|
+
/** Hostname only — never the full URL, which can carry caller-supplied path segments. */
|
|
154
|
+
function extractHostname(url) {
|
|
155
|
+
try {
|
|
156
|
+
return new URL(url).hostname;
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return 'the Workel API';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Converts a rejected `fetch` into the same `WorkelApiError` shape every other
|
|
164
|
+
* failure produces. Always `terminal: false` — DNS, TLS, socket and deadline
|
|
165
|
+
* failures are transient by nature, and telling the model so is the difference
|
|
166
|
+
* between it retrying sensibly and it giving up or hammering.
|
|
167
|
+
*/
|
|
168
|
+
function transportError(err, host, timeoutMs) {
|
|
169
|
+
const name = err instanceof Error ? err.name : '';
|
|
170
|
+
const isTimeout = name === 'TimeoutError' || name === 'AbortError';
|
|
171
|
+
// `err.cause` is where undici puts the real reason (ENOTFOUND, ECONNREFUSED,
|
|
172
|
+
// CERT_HAS_EXPIRED); the top-level message is almost always just "fetch failed".
|
|
173
|
+
// `cause` is ES2022; this package targets lower, so read it structurally
|
|
174
|
+
// rather than widening the whole build's lib for one field.
|
|
175
|
+
const rawCause = err instanceof Error ? err.cause : undefined;
|
|
176
|
+
const cause = rawCause instanceof Error ? rawCause.message : '';
|
|
177
|
+
// Redact at construction, not just at the tool boundary: when the throwable
|
|
178
|
+
// has no `cause` we fall back to its own message, and undici puts the entire
|
|
179
|
+
// Authorization header value in that message for a header-illegal key.
|
|
180
|
+
const detail = (0, redact_1.redact)(cause || (err instanceof Error ? err.message : String(err)));
|
|
181
|
+
const message = isTimeout
|
|
182
|
+
? `The request to ${host} exceeded this client's ${Math.round(timeoutMs / 1000)}s timeout before a response arrived. This is a network or server-side delay, not a problem with your request — retrying shortly is reasonable.`
|
|
183
|
+
: `Could not reach ${host}: ${detail}. This is a network-level failure, not a problem with your request — check connectivity and retry shortly.`;
|
|
184
|
+
return new WorkelApiError({
|
|
185
|
+
code: errors_1.NO_ENVELOPE_CODE,
|
|
186
|
+
status: 0,
|
|
187
|
+
terminal: false,
|
|
188
|
+
requestId: null,
|
|
189
|
+
message,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
153
192
|
function assertParsedBody(body, requestId) {
|
|
154
193
|
if (body !== null)
|
|
155
194
|
return;
|
|
@@ -177,7 +216,18 @@ function createWorkelApiClient(deps) {
|
|
|
177
216
|
const timeoutMs = deps.timeoutMs ?? exports.DEFAULT_REQUEST_TIMEOUT_MS;
|
|
178
217
|
/** Wraps `doFetch` with a fresh per-attempt deadline (see `timeoutMs`). */
|
|
179
218
|
async function fetchWithDeadline(url, init) {
|
|
180
|
-
|
|
219
|
+
try {
|
|
220
|
+
return await doFetch(url, { ...init, signal: AbortSignal.timeout(timeoutMs) });
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
// A rejected fetch never reaches throwMappedError (that path needs a
|
|
224
|
+
// Response), so without this every transport failure arrived at the model
|
|
225
|
+
// as the bare string "fetch failed" — no cause, no context, and no signal
|
|
226
|
+
// that retrying is reasonable. Never let the raw throwable through: undici
|
|
227
|
+
// embeds the whole Authorization header value in a header-illegal-value
|
|
228
|
+
// TypeError.
|
|
229
|
+
throw transportError(err, extractHostname(url), timeoutMs);
|
|
230
|
+
}
|
|
181
231
|
}
|
|
182
232
|
const requestHeaders = {
|
|
183
233
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -271,6 +321,11 @@ function createWorkelApiClient(deps) {
|
|
|
271
321
|
return throwMappedError(response);
|
|
272
322
|
}
|
|
273
323
|
const responseBody = await readResponseBody(response);
|
|
324
|
+
// Same guard `get()` applies at its own seam: a 2xx with an empty or
|
|
325
|
+
// unparseable body is a broken response, not data. Without this the four
|
|
326
|
+
// write tools dereference null and throw a raw TypeError at the model
|
|
327
|
+
// instead of the uniform mapped error every other failure produces.
|
|
328
|
+
assertParsedBody(responseBody, extractRequestId(response));
|
|
274
329
|
const result = { data: responseBody, requestId: extractRequestId(response) };
|
|
275
330
|
if (method === 'POST') {
|
|
276
331
|
result.replayed = isReplayedResponse(response);
|
package/dist/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;;;
|
|
1
|
+
{"version":3,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
|
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
|
package/dist/boot.d.ts.map
CHANGED
|
@@ -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,
|
|
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,EAAqC,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAI9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,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,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,oBAAoB,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CACrE;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAID;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
283
|
+
let probeResult;
|
|
222
284
|
try {
|
|
223
|
-
|
|
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
|
|
231
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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;;
|
|
1
|
+
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAmCH,oCAEC;AAYD,0CAEC;AAmED,wCAEC;AAaD,gDAEC;AAiED,0CAgBC;AASD,0BAGC;AAiDD,oBA2GC;AA7XD,qCAAmD;AACnD,yCAA2G;AAC3G,yCAAsD;AACtD,qCAA8E;AAC9E,6CAA6E;AAC7E,uDAA4D;AAC5D,mCAAqC;AAmBrC,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;AAkBD,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;IAC9B,OAAO,OAAO,K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C,WAAW;QAC5B,SAAS;QACT,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK;QAChC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,eAAe,EAAE,MAAM,CAAC,eAAe;KACxC,CAAC,CACH,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
export declare const DEFAULT_API_BASE_URL = "https://api.workel.com/api/public/v1";
|
|
14
14
|
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
15
15
|
export interface Config {
|
|
16
|
+
/**
|
|
17
|
+
* Every key this server will hold, in the order given. A Workel API key is
|
|
18
|
+
* bound to exactly ONE workspace by the API itself — that binding is the
|
|
19
|
+
* tenancy boundary and this client cannot widen it. Holding several keys is
|
|
20
|
+
* therefore the only way to reach several workspaces, and each request still
|
|
21
|
+
* carries exactly one workspace-bound key.
|
|
22
|
+
*/
|
|
23
|
+
apiKeys: string[];
|
|
24
|
+
/** First key. Kept for single-workspace paths that legitimately want just one. */
|
|
16
25
|
apiKey: string;
|
|
17
26
|
baseUrl: string;
|
|
18
27
|
isCustomBaseUrl: boolean;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -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;
|
|
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;;;;;;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;AA6ED,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAgBvE"}
|
package/dist/config.js
CHANGED
|
@@ -29,13 +29,31 @@ function parseLogLevel(value) {
|
|
|
29
29
|
const lowered = value.toLowerCase();
|
|
30
30
|
return LOG_LEVELS.has(lowered) ? lowered : 'info';
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Resolves every configured key, from `WORKEL_API_KEY` (one) and/or
|
|
34
|
+
* `WORKEL_API_KEYS` (comma-separated, one per workspace). Both may be set; the
|
|
35
|
+
* union is taken and de-duplicated, preserving order, so adding a second
|
|
36
|
+
* workspace never invalidates an existing single-key config.
|
|
37
|
+
*
|
|
38
|
+
* Keys are read ONLY from the environment, never from command-line arguments —
|
|
39
|
+
* those are visible via `ps` to every local user on the machine.
|
|
40
|
+
*/
|
|
41
|
+
function resolveApiKeys(env) {
|
|
42
|
+
const raw = [env.WORKEL_API_KEY, ...(env.WORKEL_API_KEYS ?? '').split(',')];
|
|
43
|
+
const keys = [];
|
|
44
|
+
for (const candidate of raw) {
|
|
45
|
+
const trimmed = candidate?.trim();
|
|
46
|
+
// De-dupe so the same key listed in both vars yields one workspace entry
|
|
47
|
+
// rather than two identical ones competing for the same label.
|
|
48
|
+
if (trimmed && !keys.includes(trimmed))
|
|
49
|
+
keys.push(trimmed);
|
|
50
|
+
}
|
|
51
|
+
if (keys.length === 0) {
|
|
52
|
+
throw new Error('No Workel API key is set. Create an API key in Workel Settings → Developers and set it as ' +
|
|
53
|
+
'WORKEL_API_KEY. To reach several workspaces, set WORKEL_API_KEYS to a comma-separated ' +
|
|
54
|
+
'list — one key per workspace, since a key is bound to a single workspace.');
|
|
37
55
|
}
|
|
38
|
-
return
|
|
56
|
+
return keys;
|
|
39
57
|
}
|
|
40
58
|
function resolveBaseUrl(env) {
|
|
41
59
|
const override = env.WORKEL_API_BASE_URL;
|
|
@@ -60,13 +78,14 @@ function resolveBaseUrl(env) {
|
|
|
60
78
|
return { baseUrl, isCustomBaseUrl: baseUrl !== exports.DEFAULT_API_BASE_URL };
|
|
61
79
|
}
|
|
62
80
|
function loadConfig(env = process.env) {
|
|
63
|
-
const
|
|
81
|
+
const apiKeys = resolveApiKeys(env);
|
|
64
82
|
const { baseUrl, isCustomBaseUrl } = resolveBaseUrl(env);
|
|
65
83
|
const enableWrites = parseBooleanFlag(env.WORKEL_ENABLE_WRITES);
|
|
66
84
|
const skipStartupCheck = parseBooleanFlag(env.WORKEL_SKIP_STARTUP_CHECK);
|
|
67
85
|
const logLevel = parseLogLevel(env.WORKEL_LOG_LEVEL);
|
|
68
86
|
return {
|
|
69
|
-
|
|
87
|
+
apiKeys,
|
|
88
|
+
apiKey: apiKeys[0],
|
|
70
89
|
baseUrl,
|
|
71
90
|
isCustomBaseUrl,
|
|
72
91
|
enableWrites,
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;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AE,CAAC;AACxE,CAAC;AAED,SAAgB,UAAU,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC7D,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAChE,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACzE,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAErD,OAAO;QACL,OAAO;QACP,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClB,OAAO;QACP,eAAe;QACf,YAAY;QACZ,gBAAgB;QAChB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
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
|
package/dist/server.d.ts.map
CHANGED
|
@@ -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;AAElF;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;
|
|
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"}
|