@workel/mcp 0.1.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 +152 -0
- package/dist/api/client.d.ts +126 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +313 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/errors.d.ts +142 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +262 -0
- package/dist/api/errors.js.map +1 -0
- package/dist/api/mapping.d.ts +147 -0
- package/dist/api/mapping.d.ts.map +1 -0
- package/dist/api/mapping.js +248 -0
- package/dist/api/mapping.js.map +1 -0
- package/dist/api/redact.d.ts +54 -0
- package/dist/api/redact.d.ts.map +1 -0
- package/dist/api/redact.js +193 -0
- package/dist/api/redact.js.map +1 -0
- package/dist/api/types.d.ts +155 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +18 -0
- package/dist/api/types.js.map +1 -0
- package/dist/boot.d.ts +129 -0
- package/dist/boot.d.ts.map +1 -0
- package/dist/boot.js +245 -0
- package/dist/boot.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +77 -0
- package/dist/config.js.map +1 -0
- package/dist/doctor.d.ts +42 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +94 -0
- package/dist/doctor.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +48 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +73 -0
- package/dist/output.js.map +1 -0
- package/dist/remote.d.ts +164 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +456 -0
- package/dist/remote.js.map +1 -0
- package/dist/server.d.ts +34 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +59 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/conventions.d.ts +54 -0
- package/dist/tools/conventions.d.ts.map +1 -0
- package/dist/tools/conventions.js +71 -0
- package/dist/tools/conventions.js.map +1 -0
- package/dist/tools/createComment.d.ts +52 -0
- package/dist/tools/createComment.d.ts.map +1 -0
- package/dist/tools/createComment.js +99 -0
- package/dist/tools/createComment.js.map +1 -0
- package/dist/tools/createEvent.d.ts +63 -0
- package/dist/tools/createEvent.d.ts.map +1 -0
- package/dist/tools/createEvent.js +160 -0
- package/dist/tools/createEvent.js.map +1 -0
- package/dist/tools/createTask.d.ts +53 -0
- package/dist/tools/createTask.d.ts.map +1 -0
- package/dist/tools/createTask.js +136 -0
- package/dist/tools/createTask.js.map +1 -0
- package/dist/tools/defineTool.d.ts +76 -0
- package/dist/tools/defineTool.d.ts.map +1 -0
- package/dist/tools/defineTool.js +31 -0
- package/dist/tools/defineTool.js.map +1 -0
- package/dist/tools/index.d.ts +16 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +49 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registration.d.ts +63 -0
- package/dist/tools/registration.d.ts.map +1 -0
- package/dist/tools/registration.js +95 -0
- package/dist/tools/registration.js.map +1 -0
- package/dist/tools/updateTask.d.ts +53 -0
- package/dist/tools/updateTask.d.ts.map +1 -0
- package/dist/tools/updateTask.js +119 -0
- package/dist/tools/updateTask.js.map +1 -0
- package/dist/tools/workel_events.d.ts +23 -0
- package/dist/tools/workel_events.d.ts.map +1 -0
- package/dist/tools/workel_events.js +60 -0
- package/dist/tools/workel_events.js.map +1 -0
- package/dist/tools/workel_members.d.ts +17 -0
- package/dist/tools/workel_members.d.ts.map +1 -0
- package/dist/tools/workel_members.js +46 -0
- package/dist/tools/workel_members.js.map +1 -0
- package/dist/tools/workel_project_columns.d.ts +13 -0
- package/dist/tools/workel_project_columns.d.ts.map +1 -0
- package/dist/tools/workel_project_columns.js +45 -0
- package/dist/tools/workel_project_columns.js.map +1 -0
- package/dist/tools/workel_projects.d.ts +20 -0
- package/dist/tools/workel_projects.d.ts.map +1 -0
- package/dist/tools/workel_projects.js +74 -0
- package/dist/tools/workel_projects.js.map +1 -0
- package/dist/tools/workel_task_comments.d.ts +21 -0
- package/dist/tools/workel_task_comments.d.ts.map +1 -0
- package/dist/tools/workel_task_comments.js +55 -0
- package/dist/tools/workel_task_comments.js.map +1 -0
- package/dist/tools/workel_tasks.d.ts +23 -0
- package/dist/tools/workel_tasks.d.ts.map +1 -0
- package/dist/tools/workel_tasks.js +104 -0
- package/dist/tools/workel_tasks.js.map +1 -0
- package/dist/tools/workel_whoami.d.ts +16 -0
- package/dist/tools/workel_whoami.d.ts.map +1 -0
- package/dist/tools/workel_whoami.js +36 -0
- package/dist/tools/workel_whoami.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +28 -0
- package/dist/version.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAgBD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;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B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAcD,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,CAAC;CACH"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Wire response shapes for the Workel Public API v1, and the tool-facing
|
|
4
|
+
* shapes `mapping.ts` translates them into.
|
|
5
|
+
*
|
|
6
|
+
* `Wire*` types mirror `docs/openapi/public-api-v1.yaml` exactly — same
|
|
7
|
+
* field names, same required/nullable shape — because that file (plus the
|
|
8
|
+
* FormRequests under `app/Http/Requests/PublicApi/V1/` for the write side)
|
|
9
|
+
* is the authority for wire vocabulary, not this comment or any design doc.
|
|
10
|
+
* The tool-facing types (no `Wire` prefix) are what every MCP tool speaks;
|
|
11
|
+
* keeping the two families textually distinct means a `WireTask` leaking
|
|
12
|
+
* into code that expects a `Task` is a compile error, not a runtime bug.
|
|
13
|
+
*
|
|
14
|
+
* Types only — no runtime code, no functions. The translation itself lives
|
|
15
|
+
* in `mapping.ts`.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
package/dist/boot.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boots the Workel MCP server: loads config, probes `GET /me` to discover
|
|
3
|
+
* which scopes the configured key actually carries, registers only the
|
|
4
|
+
* tools those scopes permit, and reports the result in a single stderr
|
|
5
|
+
* line. Deliberately transport-agnostic — `boot` never touches stdio or any
|
|
6
|
+
* transport; it hands back a constructed, unconnected `McpServer` (from
|
|
7
|
+
* `server.ts`'s `buildServer`) and lets the entrypoint (`index.ts`) decide
|
|
8
|
+
* how to connect it.
|
|
9
|
+
*
|
|
10
|
+
* The one rule this whole module exists to enforce: on the stdio transport,
|
|
11
|
+
* stdout IS the protocol stream. A single human-readable byte on stdout
|
|
12
|
+
* corrupts every message after it. Every line this module ever writes goes
|
|
13
|
+
* to `deps.stderr` — never `deps.stdout`, which this module never calls at
|
|
14
|
+
* all (it is threaded through only so a caller/test can prove that).
|
|
15
|
+
*
|
|
16
|
+
* Order matters and is fixed: install crash handlers, THEN validate env,
|
|
17
|
+
* THEN probe `/me`, THEN build the server, THEN write the boot line. Crash
|
|
18
|
+
* handlers go first specifically so a crash during the probe itself is
|
|
19
|
+
* still caught and redacted rather than reaching Node's default handler.
|
|
20
|
+
*/
|
|
21
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
22
|
+
import { type FetchLike, type WorkelApiClient } from './api/client';
|
|
23
|
+
import { type ServerCaps } from './server';
|
|
24
|
+
import type { ToolDescriptor } from './tools/defineTool';
|
|
25
|
+
export interface BootDeps {
|
|
26
|
+
env: NodeJS.ProcessEnv;
|
|
27
|
+
fetch: FetchLike;
|
|
28
|
+
/** Never called by `boot` itself — threaded through only so a caller can prove nothing here ever writes to stdout. */
|
|
29
|
+
stdout: (chunk: string) => void;
|
|
30
|
+
stderr: (chunk: string) => void;
|
|
31
|
+
exit: (code: number) => void;
|
|
32
|
+
installCrashHandlers: (write: (text: string) => void) => () => void;
|
|
33
|
+
}
|
|
34
|
+
export interface BootResult {
|
|
35
|
+
server: McpServer;
|
|
36
|
+
toolNames: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Exported so `doctor.ts` (T12) can build its own client with the exact same
|
|
40
|
+
* retry-sleep behavior `boot` uses, without re-implementing this one-liner a
|
|
41
|
+
* second time.
|
|
42
|
+
*/
|
|
43
|
+
export declare function defaultSleep(ms: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Collapses newlines/control whitespace to a single space and trims. Applied
|
|
46
|
+
* to every string that reaches the boot line from outside this process's own
|
|
47
|
+
* source (a workspace name, a key name, a scope string from `/me`) — none of
|
|
48
|
+
* those are proven free of characters that would turn "one line" into many,
|
|
49
|
+
* or that could be used to forge a fake second log line.
|
|
50
|
+
*
|
|
51
|
+
* Exported for reuse by `doctor.ts` (T12) — a doctor run formats the exact
|
|
52
|
+
* same untrusted `/me` fields and must sanitize them identically.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sanitizeForLine(value: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* The shape this module actually reads off `GET /me`
|
|
57
|
+
* (`MeResource`/`MeController`, backend). Narrower than the full documented
|
|
58
|
+
* response — only the fields the boot line reports.
|
|
59
|
+
*
|
|
60
|
+
* Exported so `doctor.ts` (T12) can type the result of `probeMe` below
|
|
61
|
+
* without redeclaring this shape.
|
|
62
|
+
*/
|
|
63
|
+
export interface MeResponse {
|
|
64
|
+
workspace: {
|
|
65
|
+
name: string;
|
|
66
|
+
};
|
|
67
|
+
key: {
|
|
68
|
+
name: string;
|
|
69
|
+
scopes: string[];
|
|
70
|
+
};
|
|
71
|
+
rate_limit: {
|
|
72
|
+
write: {
|
|
73
|
+
limit: number;
|
|
74
|
+
remaining: number;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* One row per tool this server can ever register, with the scope gate its
|
|
80
|
+
* own descriptor declares — derived from `READ_TOOLS`' real descriptors
|
|
81
|
+
* (never hand-copied), so a tool's scope only has to be correct once, in its
|
|
82
|
+
* own module. `scope: undefined` means the tool needs no scope at all (only
|
|
83
|
+
* `workel_whoami` today) and is always included below regardless of `caps`.
|
|
84
|
+
*
|
|
85
|
+
* Exported so `doctor.ts` (T12) computes "which tools would register" through
|
|
86
|
+
* the exact same descriptors `boot` itself registers against — never a
|
|
87
|
+
* second, independently maintained list that could drift from `buildServer`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function toolScopeGates(client: WorkelApiClient): ToolDescriptor[];
|
|
90
|
+
/**
|
|
91
|
+
* The tool names permitted for `caps` — intentionally the same predicate
|
|
92
|
+
* `buildServer` (server.ts) applies internally, computed here independently
|
|
93
|
+
* purely to report what got registered. `buildServer` remains the sole
|
|
94
|
+
* authority for what is actually registered; this must never be allowed to
|
|
95
|
+
* diverge from it, which is why it is derived from the same descriptors
|
|
96
|
+
* rather than a separately maintained list.
|
|
97
|
+
*
|
|
98
|
+
* Exported for the same reason as `toolScopeGates` above — `doctor.ts` (T12)
|
|
99
|
+
* reports "tools that would register" through this identical predicate.
|
|
100
|
+
*/
|
|
101
|
+
export declare function permittedToolNames(gates: ToolDescriptor[], caps: ServerCaps): string[];
|
|
102
|
+
/**
|
|
103
|
+
* Turns a probe failure (network error, non-2xx `WorkelApiError`, or a
|
|
104
|
+
* malformed 200 body) into the one-line text both `boot`'s failure path and
|
|
105
|
+
* `doctor.ts` (T12) print. For a `WorkelApiError` this is exactly the T4
|
|
106
|
+
* terminal message (`WorkelApiError#message` already IS `mapApiError`'s
|
|
107
|
+
* `.message`, redacted) — `doctor` relies on that being the same text `boot`
|
|
108
|
+
* would have printed for the identical failure, not a re-derived paraphrase.
|
|
109
|
+
*
|
|
110
|
+
* Exported for `doctor.ts` (T12).
|
|
111
|
+
*/
|
|
112
|
+
export declare function describeFailure(err: unknown): string;
|
|
113
|
+
/**
|
|
114
|
+
* Issues the `GET /me` startup probe and parses the result, or throws
|
|
115
|
+
* (network error, non-2xx → `WorkelApiError`, or a malformed 200 body →
|
|
116
|
+
* `MalformedMeResponseError`). This is the ENTIRE probe both `boot`'s
|
|
117
|
+
* non-skip path and `doctor.ts` (T12) run — extracted so the two can never
|
|
118
|
+
* observe a different probe.
|
|
119
|
+
*/
|
|
120
|
+
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
|
+
export declare function boot(deps: BootDeps): Promise<BootResult | undefined>;
|
|
129
|
+
//# sourceMappingURL=boot.d.ts.map
|
|
@@ -0,0 +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,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;IACzB,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,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;AAuCD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,EAAE,CAExE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,CAEtF;AA8CD;;;;;;;;;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;AAED;;;;;;GAMG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAyE1E"}
|
package/dist/boot.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Boots the Workel MCP server: loads config, probes `GET /me` to discover
|
|
4
|
+
* which scopes the configured key actually carries, registers only the
|
|
5
|
+
* tools those scopes permit, and reports the result in a single stderr
|
|
6
|
+
* line. Deliberately transport-agnostic — `boot` never touches stdio or any
|
|
7
|
+
* transport; it hands back a constructed, unconnected `McpServer` (from
|
|
8
|
+
* `server.ts`'s `buildServer`) and lets the entrypoint (`index.ts`) decide
|
|
9
|
+
* how to connect it.
|
|
10
|
+
*
|
|
11
|
+
* The one rule this whole module exists to enforce: on the stdio transport,
|
|
12
|
+
* stdout IS the protocol stream. A single human-readable byte on stdout
|
|
13
|
+
* corrupts every message after it. Every line this module ever writes goes
|
|
14
|
+
* to `deps.stderr` — never `deps.stdout`, which this module never calls at
|
|
15
|
+
* all (it is threaded through only so a caller/test can prove that).
|
|
16
|
+
*
|
|
17
|
+
* Order matters and is fixed: install crash handlers, THEN validate env,
|
|
18
|
+
* THEN probe `/me`, THEN build the server, THEN write the boot line. Crash
|
|
19
|
+
* handlers go first specifically so a crash during the probe itself is
|
|
20
|
+
* still caught and redacted rather than reaching Node's default handler.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.defaultSleep = defaultSleep;
|
|
24
|
+
exports.sanitizeForLine = sanitizeForLine;
|
|
25
|
+
exports.toolScopeGates = toolScopeGates;
|
|
26
|
+
exports.permittedToolNames = permittedToolNames;
|
|
27
|
+
exports.describeFailure = describeFailure;
|
|
28
|
+
exports.probeMe = probeMe;
|
|
29
|
+
exports.boot = boot;
|
|
30
|
+
const config_1 = require("./config");
|
|
31
|
+
const client_1 = require("./api/client");
|
|
32
|
+
const redact_1 = require("./api/redact");
|
|
33
|
+
const server_1 = require("./server");
|
|
34
|
+
const tools_1 = require("./tools");
|
|
35
|
+
const SKIP_STARTUP_CHECK_HINT = 'Set WORKEL_SKIP_STARTUP_CHECK=true to start anyway.';
|
|
36
|
+
/**
|
|
37
|
+
* Exported so `doctor.ts` (T12) can build its own client with the exact same
|
|
38
|
+
* retry-sleep behavior `boot` uses, without re-implementing this one-liner a
|
|
39
|
+
* second time.
|
|
40
|
+
*/
|
|
41
|
+
function defaultSleep(ms) {
|
|
42
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Collapses newlines/control whitespace to a single space and trims. Applied
|
|
46
|
+
* to every string that reaches the boot line from outside this process's own
|
|
47
|
+
* source (a workspace name, a key name, a scope string from `/me`) — none of
|
|
48
|
+
* those are proven free of characters that would turn "one line" into many,
|
|
49
|
+
* or that could be used to forge a fake second log line.
|
|
50
|
+
*
|
|
51
|
+
* Exported for reuse by `doctor.ts` (T12) — a doctor run formats the exact
|
|
52
|
+
* same untrusted `/me` fields and must sanitize them identically.
|
|
53
|
+
*/
|
|
54
|
+
function sanitizeForLine(value) {
|
|
55
|
+
return value.replace(/\s+/g, ' ').trim();
|
|
56
|
+
}
|
|
57
|
+
class MalformedMeResponseError extends Error {
|
|
58
|
+
constructor() {
|
|
59
|
+
super('The server responded to GET /me, but not with the expected shape.');
|
|
60
|
+
this.name = 'MalformedMeResponseError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function isRecord(value) {
|
|
64
|
+
return typeof value === 'object' && value !== null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Minimal runtime validation of the `/me` body — just enough that a 200
|
|
68
|
+
* response with an unexpected shape (a proxy/gateway serving something else,
|
|
69
|
+
* a future incompatible server) fails the startup probe the same way a
|
|
70
|
+
* non-2xx response would, instead of throwing a raw `TypeError` out of a
|
|
71
|
+
* field access later in this module.
|
|
72
|
+
*/
|
|
73
|
+
function parseMeResponse(data) {
|
|
74
|
+
if (isRecord(data) &&
|
|
75
|
+
isRecord(data.workspace) &&
|
|
76
|
+
typeof data.workspace.name === 'string' &&
|
|
77
|
+
isRecord(data.key) &&
|
|
78
|
+
typeof data.key.name === 'string' &&
|
|
79
|
+
Array.isArray(data.key.scopes) &&
|
|
80
|
+
data.key.scopes.every((scope) => typeof scope === 'string') &&
|
|
81
|
+
isRecord(data.rate_limit) &&
|
|
82
|
+
isRecord(data.rate_limit.write) &&
|
|
83
|
+
typeof data.rate_limit.write.limit === 'number' &&
|
|
84
|
+
typeof data.rate_limit.write.remaining === 'number') {
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
throw new MalformedMeResponseError();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* One row per tool this server can ever register, with the scope gate its
|
|
91
|
+
* own descriptor declares — derived from `READ_TOOLS`' real descriptors
|
|
92
|
+
* (never hand-copied), so a tool's scope only has to be correct once, in its
|
|
93
|
+
* own module. `scope: undefined` means the tool needs no scope at all (only
|
|
94
|
+
* `workel_whoami` today) and is always included below regardless of `caps`.
|
|
95
|
+
*
|
|
96
|
+
* Exported so `doctor.ts` (T12) computes "which tools would register" through
|
|
97
|
+
* the exact same descriptors `boot` itself registers against — never a
|
|
98
|
+
* second, independently maintained list that could drift from `buildServer`.
|
|
99
|
+
*/
|
|
100
|
+
function toolScopeGates(client) {
|
|
101
|
+
return tools_1.READ_TOOLS.map((factory) => factory(client));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The tool names permitted for `caps` — intentionally the same predicate
|
|
105
|
+
* `buildServer` (server.ts) applies internally, computed here independently
|
|
106
|
+
* purely to report what got registered. `buildServer` remains the sole
|
|
107
|
+
* authority for what is actually registered; this must never be allowed to
|
|
108
|
+
* diverge from it, which is why it is derived from the same descriptors
|
|
109
|
+
* rather than a separately maintained list.
|
|
110
|
+
*
|
|
111
|
+
* Exported for the same reason as `toolScopeGates` above — `doctor.ts` (T12)
|
|
112
|
+
* reports "tools that would register" through this identical predicate.
|
|
113
|
+
*/
|
|
114
|
+
function permittedToolNames(gates, caps) {
|
|
115
|
+
return gates.filter((gate) => gate.scope === undefined || caps.scopes.includes(gate.scope)).map((gate) => gate.name);
|
|
116
|
+
}
|
|
117
|
+
function formatBootLine(params) {
|
|
118
|
+
const segments = [];
|
|
119
|
+
if (params.probed) {
|
|
120
|
+
const workspaceName = sanitizeForLine(params.workspaceName);
|
|
121
|
+
const keyName = sanitizeForLine(params.keyName);
|
|
122
|
+
const scopes = params.scopes.map(sanitizeForLine);
|
|
123
|
+
segments.push(`Workel MCP ready — workspace "${workspaceName}", key "${keyName}"`);
|
|
124
|
+
segments.push(`scopes: ${scopes.length > 0 ? scopes.join(', ') : 'none'}`);
|
|
125
|
+
segments.push(`${params.toolNames.length} tools registered: ${params.toolNames.join(', ')}`);
|
|
126
|
+
segments.push(`write budget: ${params.writeBudget.remaining}/${params.writeBudget.limit} remaining this minute`);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
segments.push('Workel MCP ready — scopes not probed (WORKEL_SKIP_STARTUP_CHECK=true)');
|
|
130
|
+
segments.push(`${params.toolNames.length} tools registered: ${params.toolNames.join(', ')}`);
|
|
131
|
+
}
|
|
132
|
+
// `isCustomBaseUrl` (config.ts) is already `baseUrl !== DEFAULT_API_BASE_URL`
|
|
133
|
+
// — reused here rather than re-comparing against a second, hand-typed copy
|
|
134
|
+
// of that same default string.
|
|
135
|
+
if (params.isCustomBaseUrl) {
|
|
136
|
+
segments.push(`base URL: ${params.baseUrl}`);
|
|
137
|
+
}
|
|
138
|
+
return `${(0, redact_1.redact)(segments.join(' — '))}\n`;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Turns a probe failure (network error, non-2xx `WorkelApiError`, or a
|
|
142
|
+
* malformed 200 body) into the one-line text both `boot`'s failure path and
|
|
143
|
+
* `doctor.ts` (T12) print. For a `WorkelApiError` this is exactly the T4
|
|
144
|
+
* terminal message (`WorkelApiError#message` already IS `mapApiError`'s
|
|
145
|
+
* `.message`, redacted) — `doctor` relies on that being the same text `boot`
|
|
146
|
+
* would have printed for the identical failure, not a re-derived paraphrase.
|
|
147
|
+
*
|
|
148
|
+
* Exported for `doctor.ts` (T12).
|
|
149
|
+
*/
|
|
150
|
+
function describeFailure(err) {
|
|
151
|
+
if (err instanceof client_1.WorkelApiError)
|
|
152
|
+
return err.message;
|
|
153
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
154
|
+
// undici reports every transport failure as the two-word message "fetch
|
|
155
|
+
// failed" and puts the only actionable detail (ECONNREFUSED, ENOTFOUND,
|
|
156
|
+
// ETIMEDOUT, a TLS reason) on `err.cause`. Dropping it made `doctor` —
|
|
157
|
+
// the command whose entire job is diagnosing these — useless.
|
|
158
|
+
const cause = err.cause;
|
|
159
|
+
const detail = typeof cause?.code === 'string'
|
|
160
|
+
? cause.code
|
|
161
|
+
: typeof cause?.message === 'string'
|
|
162
|
+
? cause.message
|
|
163
|
+
: null;
|
|
164
|
+
const described = detail === null ? raw : `${raw} (${detail})`;
|
|
165
|
+
return `Failed to reach the Workel API to verify this key: ${sanitizeForLine(described)}`;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Issues the `GET /me` startup probe and parses the result, or throws
|
|
169
|
+
* (network error, non-2xx → `WorkelApiError`, or a malformed 200 body →
|
|
170
|
+
* `MalformedMeResponseError`). This is the ENTIRE probe both `boot`'s
|
|
171
|
+
* non-skip path and `doctor.ts` (T12) run — extracted so the two can never
|
|
172
|
+
* observe a different probe.
|
|
173
|
+
*/
|
|
174
|
+
async function probeMe(client) {
|
|
175
|
+
const result = await client.get('/me');
|
|
176
|
+
return parseMeResponse(result.data);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Runs the full boot sequence and returns the built (but not yet connected)
|
|
180
|
+
* server plus the tool names it registered — or `undefined` when boot could
|
|
181
|
+
* not proceed (missing key, or a startup probe failure), in which case
|
|
182
|
+
* `deps.exit` has already been called and the caller should not attempt to
|
|
183
|
+
* connect any transport.
|
|
184
|
+
*/
|
|
185
|
+
async function boot(deps) {
|
|
186
|
+
const { env, fetch: injectedFetch, stderr, exit, installCrashHandlers } = deps;
|
|
187
|
+
installCrashHandlers(stderr);
|
|
188
|
+
let config;
|
|
189
|
+
try {
|
|
190
|
+
config = (0, config_1.loadConfig)(env);
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
stderr(`${(0, redact_1.redact)(err.message)}\n`);
|
|
194
|
+
exit(1);
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
(0, redact_1.registerSecret)(config.apiKey);
|
|
198
|
+
const client = (0, client_1.createWorkelApiClient)({
|
|
199
|
+
baseUrl: config.baseUrl,
|
|
200
|
+
apiKey: config.apiKey,
|
|
201
|
+
fetch: injectedFetch,
|
|
202
|
+
sleep: defaultSleep,
|
|
203
|
+
});
|
|
204
|
+
const gates = toolScopeGates(client);
|
|
205
|
+
if (config.skipStartupCheck) {
|
|
206
|
+
// Every scope any gate declares, deduped — permits every tool regardless
|
|
207
|
+
// of which real scopes the key would have turned out to carry, since the
|
|
208
|
+
// whole point of skipping the probe is to start anyway.
|
|
209
|
+
const allScopes = new Set(gates.map((gate) => gate.scope).filter((scope) => scope !== undefined));
|
|
210
|
+
const caps = { scopes: Array.from(allScopes) };
|
|
211
|
+
const server = (0, server_1.buildServer)(client, caps, tools_1.READ_TOOLS);
|
|
212
|
+
const toolNames = gates.map((gate) => gate.name);
|
|
213
|
+
stderr(formatBootLine({
|
|
214
|
+
probed: false,
|
|
215
|
+
toolNames,
|
|
216
|
+
baseUrl: config.baseUrl,
|
|
217
|
+
isCustomBaseUrl: config.isCustomBaseUrl,
|
|
218
|
+
}));
|
|
219
|
+
return { server, toolNames };
|
|
220
|
+
}
|
|
221
|
+
let me;
|
|
222
|
+
try {
|
|
223
|
+
me = await probeMe(client);
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
stderr(`${(0, redact_1.redact)(describeFailure(err))} ${SKIP_STARTUP_CHECK_HINT}\n`);
|
|
227
|
+
exit(1);
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
const caps = { scopes: me.key.scopes };
|
|
231
|
+
const server = (0, server_1.buildServer)(client, caps, tools_1.READ_TOOLS);
|
|
232
|
+
const toolNames = permittedToolNames(gates, caps);
|
|
233
|
+
stderr(formatBootLine({
|
|
234
|
+
probed: true,
|
|
235
|
+
workspaceName: me.workspace.name,
|
|
236
|
+
keyName: me.key.name,
|
|
237
|
+
scopes: me.key.scopes,
|
|
238
|
+
toolNames,
|
|
239
|
+
writeBudget: me.rate_limit.write,
|
|
240
|
+
baseUrl: config.baseUrl,
|
|
241
|
+
isCustomBaseUrl: config.isCustomBaseUrl,
|
|
242
|
+
}));
|
|
243
|
+
return { server, toolNames };
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=boot.js.map
|
package/dist/boot.js.map
ADDED
|
@@ -0,0 +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;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,IAAa;IACpC,IACE,QAAQ,CAAC,IAAI,CAAC;QACd,QAAQ,CAAC,IAAI,CAAC,S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+
* `loadConfig` performs no I/O — it only reads and validates `process.env`
|
|
5
|
+
* (or an injected map, for tests). Two security invariants live here:
|
|
6
|
+
*
|
|
7
|
+
* 1. The API key comes ONLY from `WORKEL_API_KEY`, never from command-line
|
|
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.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_API_BASE_URL = "https://api.workel.com/api/public/v1";
|
|
14
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
15
|
+
export interface Config {
|
|
16
|
+
apiKey: string;
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
isCustomBaseUrl: boolean;
|
|
19
|
+
enableWrites: boolean;
|
|
20
|
+
skipStartupCheck: boolean;
|
|
21
|
+
logLevel: LogLevel;
|
|
22
|
+
}
|
|
23
|
+
export declare function loadConfig(env?: NodeJS.ProcessEnv): Config;
|
|
24
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Environment-driven configuration for the Workel MCP server.
|
|
4
|
+
*
|
|
5
|
+
* `loadConfig` performs no I/O — it only reads and validates `process.env`
|
|
6
|
+
* (or an injected map, for tests). Two security invariants live here:
|
|
7
|
+
*
|
|
8
|
+
* 1. The API key comes ONLY from `WORKEL_API_KEY`, never from command-line
|
|
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.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DEFAULT_API_BASE_URL = void 0;
|
|
16
|
+
exports.loadConfig = loadConfig;
|
|
17
|
+
exports.DEFAULT_API_BASE_URL = 'https://api.workel.com/api/public/v1';
|
|
18
|
+
const LOOPBACK_HOSTNAMES = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
19
|
+
const LOG_LEVELS = new Set(['debug', 'info', 'warn', 'error']);
|
|
20
|
+
function stripTrailingSlashes(value) {
|
|
21
|
+
return value.replace(/\/+$/, '');
|
|
22
|
+
}
|
|
23
|
+
function parseBooleanFlag(value) {
|
|
24
|
+
return value !== undefined && value.toLowerCase() === 'true';
|
|
25
|
+
}
|
|
26
|
+
function parseLogLevel(value) {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return 'info';
|
|
29
|
+
const lowered = value.toLowerCase();
|
|
30
|
+
return LOG_LEVELS.has(lowered) ? lowered : 'info';
|
|
31
|
+
}
|
|
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.');
|
|
37
|
+
}
|
|
38
|
+
return apiKey;
|
|
39
|
+
}
|
|
40
|
+
function resolveBaseUrl(env) {
|
|
41
|
+
const override = env.WORKEL_API_BASE_URL;
|
|
42
|
+
if (override === undefined) {
|
|
43
|
+
return { baseUrl: exports.DEFAULT_API_BASE_URL, isCustomBaseUrl: false };
|
|
44
|
+
}
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = new URL(override);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
throw new Error(`WORKEL_API_BASE_URL is set to an invalid URL: "${override}". ` +
|
|
51
|
+
'It must be a valid absolute URL, e.g. https://api.workel.com/api/public/v1.');
|
|
52
|
+
}
|
|
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].');
|
|
58
|
+
}
|
|
59
|
+
const baseUrl = stripTrailingSlashes(override);
|
|
60
|
+
return { baseUrl, isCustomBaseUrl: baseUrl !== exports.DEFAULT_API_BASE_URL };
|
|
61
|
+
}
|
|
62
|
+
function loadConfig(env = process.env) {
|
|
63
|
+
const apiKey = resolveApiKey(env);
|
|
64
|
+
const { baseUrl, isCustomBaseUrl } = resolveBaseUrl(env);
|
|
65
|
+
const enableWrites = parseBooleanFlag(env.WORKEL_ENABLE_WRITES);
|
|
66
|
+
const skipStartupCheck = parseBooleanFlag(env.WORKEL_SKIP_STARTUP_CHECK);
|
|
67
|
+
const logLevel = parseLogLevel(env.WORKEL_LOG_LEVEL);
|
|
68
|
+
return {
|
|
69
|
+
apiKey,
|
|
70
|
+
baseUrl,
|
|
71
|
+
isCustomBaseUrl,
|
|
72
|
+
enableWrites,
|
|
73
|
+
skipStartupCheck,
|
|
74
|
+
logLevel,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +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,MAAM,GAAG,GAAG,CAAC,cAAc,CAAC;IAClC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;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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,MAAM;QACN,OAAO;QACP,eAAe;QACf,YAAY;QACZ,gBAAgB;QAChB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `workel-mcp doctor` — a one-shot diagnostic a customer can run when their
|
|
3
|
+
* MCP client says only "server failed to start" and gives no further detail.
|
|
4
|
+
*
|
|
5
|
+
* Runs the EXACT SAME `GET /me` startup probe `boot.ts` runs (`probeMe`),
|
|
6
|
+
* through the exact same scope→tool-selection seam (`toolScopeGates` /
|
|
7
|
+
* `permittedToolNames`) — reused, not re-implemented, so the two can never
|
|
8
|
+
* report a different answer for the same key/config. See `boot.ts` for the
|
|
9
|
+
* probe and selection logic itself; this module only formats the result.
|
|
10
|
+
*
|
|
11
|
+
* Unlike `boot`, this module runs no transport, so there is no stdout/stderr
|
|
12
|
+
* split to preserve — a stdio MCP session never gets far enough to start for
|
|
13
|
+
* a doctor run to interfere with. Every line, success or failure, goes to
|
|
14
|
+
* `deps.stdout`. `deps.stderr` is threaded through only so a caller/test can
|
|
15
|
+
* prove nothing here ever writes to it (mirrors `boot.ts`'s `deps.stdout`
|
|
16
|
+
* convention, inverted).
|
|
17
|
+
*
|
|
18
|
+
* `runDoctor` never calls `process.exit` — it returns a plain exit code
|
|
19
|
+
* (`0` success, `1` failure) and leaves the decision of when/how to exit to
|
|
20
|
+
* its caller (`index.ts`).
|
|
21
|
+
*
|
|
22
|
+
* D6 (the effective-base-URL defense) is surfaced a second time here,
|
|
23
|
+
* deliberately: the base URL prints UNCONDITIONALLY — default or
|
|
24
|
+
* overridden — with an inline `(override)` marker in the overridden case.
|
|
25
|
+
* A doctor run is exactly the moment a tampered `WORKEL_API_BASE_URL` must
|
|
26
|
+
* be visible, so unlike `boot`'s line (which omits the URL when it's the
|
|
27
|
+
* default, to keep the common case terse) doctor never omits it.
|
|
28
|
+
*/
|
|
29
|
+
import { type BootDeps } from './boot';
|
|
30
|
+
/**
|
|
31
|
+
* The subset of `BootDeps` (boot.ts) `runDoctor` actually needs — a `Pick`
|
|
32
|
+
* rather than a hand-copied interface, so the two can never silently drift
|
|
33
|
+
* apart on the shape of `env`/`fetch`/`stdout`/`stderr`.
|
|
34
|
+
*/
|
|
35
|
+
export type DoctorDeps = Pick<BootDeps, 'env' | 'fetch' | 'stdout' | 'stderr'>;
|
|
36
|
+
/**
|
|
37
|
+
* Runs the diagnostic and writes its report to `deps.stdout`. Returns `0`
|
|
38
|
+
* when the probe succeeded, `1` for any failure (bad config, network error,
|
|
39
|
+
* a non-2xx response, or a malformed 200 body) — never throws.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runDoctor(deps: DoctorDeps): Promise<number>;
|
|
42
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,OAAO,EAOL,KAAK,QAAQ,EAEd,MAAM,QAAQ,CAAC;AAGhB;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAoB/E;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA2CjE"}
|