@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.
Files changed (114) hide show
  1. package/README.md +152 -0
  2. package/dist/api/client.d.ts +126 -0
  3. package/dist/api/client.d.ts.map +1 -0
  4. package/dist/api/client.js +313 -0
  5. package/dist/api/client.js.map +1 -0
  6. package/dist/api/errors.d.ts +142 -0
  7. package/dist/api/errors.d.ts.map +1 -0
  8. package/dist/api/errors.js +262 -0
  9. package/dist/api/errors.js.map +1 -0
  10. package/dist/api/mapping.d.ts +147 -0
  11. package/dist/api/mapping.d.ts.map +1 -0
  12. package/dist/api/mapping.js +248 -0
  13. package/dist/api/mapping.js.map +1 -0
  14. package/dist/api/redact.d.ts +54 -0
  15. package/dist/api/redact.d.ts.map +1 -0
  16. package/dist/api/redact.js +193 -0
  17. package/dist/api/redact.js.map +1 -0
  18. package/dist/api/types.d.ts +155 -0
  19. package/dist/api/types.d.ts.map +1 -0
  20. package/dist/api/types.js +18 -0
  21. package/dist/api/types.js.map +1 -0
  22. package/dist/boot.d.ts +129 -0
  23. package/dist/boot.d.ts.map +1 -0
  24. package/dist/boot.js +245 -0
  25. package/dist/boot.js.map +1 -0
  26. package/dist/config.d.ts +24 -0
  27. package/dist/config.d.ts.map +1 -0
  28. package/dist/config.js +77 -0
  29. package/dist/config.js.map +1 -0
  30. package/dist/doctor.d.ts +42 -0
  31. package/dist/doctor.d.ts.map +1 -0
  32. package/dist/doctor.js +94 -0
  33. package/dist/doctor.js.map +1 -0
  34. package/dist/index.d.ts +36 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +66 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/output.d.ts +48 -0
  39. package/dist/output.d.ts.map +1 -0
  40. package/dist/output.js +73 -0
  41. package/dist/output.js.map +1 -0
  42. package/dist/remote.d.ts +164 -0
  43. package/dist/remote.d.ts.map +1 -0
  44. package/dist/remote.js +456 -0
  45. package/dist/remote.js.map +1 -0
  46. package/dist/server.d.ts +34 -0
  47. package/dist/server.d.ts.map +1 -0
  48. package/dist/server.js +59 -0
  49. package/dist/server.js.map +1 -0
  50. package/dist/tools/conventions.d.ts +54 -0
  51. package/dist/tools/conventions.d.ts.map +1 -0
  52. package/dist/tools/conventions.js +71 -0
  53. package/dist/tools/conventions.js.map +1 -0
  54. package/dist/tools/createComment.d.ts +52 -0
  55. package/dist/tools/createComment.d.ts.map +1 -0
  56. package/dist/tools/createComment.js +99 -0
  57. package/dist/tools/createComment.js.map +1 -0
  58. package/dist/tools/createEvent.d.ts +63 -0
  59. package/dist/tools/createEvent.d.ts.map +1 -0
  60. package/dist/tools/createEvent.js +160 -0
  61. package/dist/tools/createEvent.js.map +1 -0
  62. package/dist/tools/createTask.d.ts +53 -0
  63. package/dist/tools/createTask.d.ts.map +1 -0
  64. package/dist/tools/createTask.js +136 -0
  65. package/dist/tools/createTask.js.map +1 -0
  66. package/dist/tools/defineTool.d.ts +76 -0
  67. package/dist/tools/defineTool.d.ts.map +1 -0
  68. package/dist/tools/defineTool.js +31 -0
  69. package/dist/tools/defineTool.js.map +1 -0
  70. package/dist/tools/index.d.ts +16 -0
  71. package/dist/tools/index.d.ts.map +1 -0
  72. package/dist/tools/index.js +49 -0
  73. package/dist/tools/index.js.map +1 -0
  74. package/dist/tools/registration.d.ts +63 -0
  75. package/dist/tools/registration.d.ts.map +1 -0
  76. package/dist/tools/registration.js +95 -0
  77. package/dist/tools/registration.js.map +1 -0
  78. package/dist/tools/updateTask.d.ts +53 -0
  79. package/dist/tools/updateTask.d.ts.map +1 -0
  80. package/dist/tools/updateTask.js +119 -0
  81. package/dist/tools/updateTask.js.map +1 -0
  82. package/dist/tools/workel_events.d.ts +23 -0
  83. package/dist/tools/workel_events.d.ts.map +1 -0
  84. package/dist/tools/workel_events.js +60 -0
  85. package/dist/tools/workel_events.js.map +1 -0
  86. package/dist/tools/workel_members.d.ts +17 -0
  87. package/dist/tools/workel_members.d.ts.map +1 -0
  88. package/dist/tools/workel_members.js +46 -0
  89. package/dist/tools/workel_members.js.map +1 -0
  90. package/dist/tools/workel_project_columns.d.ts +13 -0
  91. package/dist/tools/workel_project_columns.d.ts.map +1 -0
  92. package/dist/tools/workel_project_columns.js +45 -0
  93. package/dist/tools/workel_project_columns.js.map +1 -0
  94. package/dist/tools/workel_projects.d.ts +20 -0
  95. package/dist/tools/workel_projects.d.ts.map +1 -0
  96. package/dist/tools/workel_projects.js +74 -0
  97. package/dist/tools/workel_projects.js.map +1 -0
  98. package/dist/tools/workel_task_comments.d.ts +21 -0
  99. package/dist/tools/workel_task_comments.d.ts.map +1 -0
  100. package/dist/tools/workel_task_comments.js +55 -0
  101. package/dist/tools/workel_task_comments.js.map +1 -0
  102. package/dist/tools/workel_tasks.d.ts +23 -0
  103. package/dist/tools/workel_tasks.d.ts.map +1 -0
  104. package/dist/tools/workel_tasks.js +104 -0
  105. package/dist/tools/workel_tasks.js.map +1 -0
  106. package/dist/tools/workel_whoami.d.ts +16 -0
  107. package/dist/tools/workel_whoami.d.ts.map +1 -0
  108. package/dist/tools/workel_whoami.js +36 -0
  109. package/dist/tools/workel_whoami.js.map +1 -0
  110. package/dist/version.d.ts +2 -0
  111. package/dist/version.d.ts.map +1 -0
  112. package/dist/version.js +28 -0
  113. package/dist/version.js.map +1 -0
  114. package/package.json +42 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Turns a Public API v1 error response into text an LLM tool-caller can act
3
+ * on. Pure and network-free — it only inspects the `status`/`body` a caller
4
+ * already received; it never makes a request.
5
+ *
6
+ * Matches on `error.code` ONLY, never on `error.message`. The upstream
7
+ * `message` is documented as "not intended for stable string matching —
8
+ * match on `code`" (OpenAPI spec, ErrorEnvelope.code description) and is
9
+ * never read by this module for ANY purpose — not for matching, and not
10
+ * for interpolation into the text this module produces. `message` (and any
11
+ * unrecognized `code`, which is untrusted input the same way) could contain
12
+ * attacker- or record-controlled text (e.g. a workspace name laundered into
13
+ * a validation message); the tool-facing text this module emits never
14
+ * repeats it back verbatim (D8).
15
+ *
16
+ * `API_ERROR_CODES` below is a hand-derived snapshot of every
17
+ * `ErrorEnvelope::make(...)` call site in
18
+ * `backend/services/laravel-backend/app/` as of the commit this file was
19
+ * written against (grepped directly, then cross-checked against the `code`
20
+ * enum documented in
21
+ * `backend/services/laravel-backend/docs/openapi/public-api-v1.yaml:445-457`,
22
+ * which itself is explicitly "non-exhaustive — new codes may be added
23
+ * without a version bump"). The test suite proves every code in that array
24
+ * has a message mapped — it proves internal consistency of this file, NOT
25
+ * that the array still matches the live API. Re-derive it by re-running the
26
+ * grep in this file's header the next time this module is touched.
27
+ *
28
+ * The one response shape this module must also tolerate is NOT the
29
+ * envelope at all: an uncaught `\Throwable` inside the Laravel app never
30
+ * reaches `ErrorEnvelope::make()` (`app/Exceptions/Handler.php:429-432`
31
+ * returns `null` for anything that isn't a `ValidationException` or an
32
+ * `HttpException`, which is Laravel's signal to fall through to its own
33
+ * default JSON rendering — `{"message":"Server Error"}` in production, with
34
+ * no `error` key and, because `AttachRequestId`'s post-`$next()` header
35
+ * write never runs on an exception-unwound path either, typically no
36
+ * `X-Request-Id` header). `mapApiError` must produce a sane result for that
37
+ * shape too, without throwing.
38
+ */
39
+ export declare const API_ERROR_CODES: readonly [{
40
+ readonly code: "invalid_api_key";
41
+ readonly status: 401;
42
+ readonly type: "authentication_error";
43
+ }, {
44
+ readonly code: "api_key_required";
45
+ readonly status: 401;
46
+ readonly type: "authentication_error";
47
+ }, {
48
+ readonly code: "api_key_disabled";
49
+ readonly status: 403;
50
+ readonly type: "permission_error";
51
+ }, {
52
+ readonly code: "scope_required";
53
+ readonly status: 403;
54
+ readonly type: "permission_error";
55
+ }, {
56
+ readonly code: "scope_not_asserted";
57
+ readonly status: 403;
58
+ readonly type: "permission_error";
59
+ }, {
60
+ readonly code: "forbidden";
61
+ readonly status: 403;
62
+ readonly type: "permission_error";
63
+ }, {
64
+ readonly code: "validation_error";
65
+ readonly status: 422;
66
+ readonly type: "invalid_request_error";
67
+ }, {
68
+ readonly code: "no_open_column";
69
+ readonly status: 422;
70
+ readonly type: "invalid_request_error";
71
+ }, {
72
+ readonly code: "invalid_assignee";
73
+ readonly status: 422;
74
+ readonly type: "invalid_request_error";
75
+ }, {
76
+ readonly code: "inbox_project";
77
+ readonly status: 422;
78
+ readonly type: "invalid_request_error";
79
+ }, {
80
+ readonly code: "invalid_date";
81
+ readonly status: 422;
82
+ readonly type: "invalid_request_error";
83
+ }, {
84
+ readonly code: "window_too_large";
85
+ readonly status: 422;
86
+ readonly type: "invalid_request_error";
87
+ }, {
88
+ readonly code: "not_found";
89
+ readonly status: 404;
90
+ readonly type: "invalid_request_error";
91
+ }, {
92
+ readonly code: "idempotency_key_reuse";
93
+ readonly status: 409;
94
+ readonly type: "idempotency_error";
95
+ }, {
96
+ readonly code: "key_rate_limited";
97
+ readonly status: 429;
98
+ readonly type: "rate_limit_error";
99
+ }, {
100
+ readonly code: "workspace_rate_limited";
101
+ readonly status: 429;
102
+ readonly type: "rate_limit_error";
103
+ }, {
104
+ readonly code: "write_rate_limited";
105
+ readonly status: 429;
106
+ readonly type: "rate_limit_error";
107
+ }, {
108
+ readonly code: "anonymous_rate_limited";
109
+ readonly status: 429;
110
+ readonly type: "rate_limit_error";
111
+ }];
112
+ export type KnownApiErrorCode = (typeof API_ERROR_CODES)[number]['code'];
113
+ /** Sentinel `code` this module reports when the body wasn't the error envelope at all. */
114
+ /** Also used by client.ts when a 2xx body is empty/unparseable — same "no usable envelope" situation. */
115
+ export declare const NO_ENVELOPE_CODE = "no_error_envelope";
116
+ export interface MappedApiError {
117
+ /** The wire `error.code` (known or, sanitized, unrecognized), or `NO_ENVELOPE_CODE` when the body wasn't the envelope shape at all. */
118
+ code: string;
119
+ status: number;
120
+ /** `true` when retrying this exact request is not expected to help — i.e. every status except 429 and 5xx. */
121
+ terminal: boolean;
122
+ /** The request id to hand back to a human for support, sanitized. `null` when none was available anywhere. */
123
+ requestId: string | null;
124
+ /** Model-actionable text. Never contains upstream `error.message` or any other unsanitized wire content. */
125
+ message: string;
126
+ }
127
+ /**
128
+ * Maps a Public API v1 HTTP response into text an LLM tool-caller can act
129
+ * on. Pure — makes no network call, and never throws regardless of what
130
+ * `body` turns out to be.
131
+ *
132
+ * `requestId`, when given, should be the response's `X-Request-Id` header —
133
+ * it takes priority over any `request_id` found inside `body.error`, since
134
+ * the header is set directly by `ErrorEnvelope::make()` on every envelope
135
+ * response and, unlike the body, is also present on responses that bypass
136
+ * `AttachRequestId`'s own header-write step (an exception-converted 401 —
137
+ * see the file-level docblock). Falls back to `body.error.request_id`, then
138
+ * to `null` when neither is available (the uncaught-`\Throwable` fallback
139
+ * body has neither).
140
+ */
141
+ export declare function mapApiError(status: number, body: unknown, requestId?: string | null): MappedApiError;
142
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAmCH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8ClB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AA8IzE,0FAA0F;AAC1F,yGAAyG;AACzG,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,uIAAuI;IACvI,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,8GAA8G;IAC9G,QAAQ,EAAE,OAAO,CAAC;IAClB,8GAA8G;IAC9G,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,4GAA4G;IAC5G,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,cAAc,CAkDhB"}
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ /**
3
+ * Turns a Public API v1 error response into text an LLM tool-caller can act
4
+ * on. Pure and network-free — it only inspects the `status`/`body` a caller
5
+ * already received; it never makes a request.
6
+ *
7
+ * Matches on `error.code` ONLY, never on `error.message`. The upstream
8
+ * `message` is documented as "not intended for stable string matching —
9
+ * match on `code`" (OpenAPI spec, ErrorEnvelope.code description) and is
10
+ * never read by this module for ANY purpose — not for matching, and not
11
+ * for interpolation into the text this module produces. `message` (and any
12
+ * unrecognized `code`, which is untrusted input the same way) could contain
13
+ * attacker- or record-controlled text (e.g. a workspace name laundered into
14
+ * a validation message); the tool-facing text this module emits never
15
+ * repeats it back verbatim (D8).
16
+ *
17
+ * `API_ERROR_CODES` below is a hand-derived snapshot of every
18
+ * `ErrorEnvelope::make(...)` call site in
19
+ * `backend/services/laravel-backend/app/` as of the commit this file was
20
+ * written against (grepped directly, then cross-checked against the `code`
21
+ * enum documented in
22
+ * `backend/services/laravel-backend/docs/openapi/public-api-v1.yaml:445-457`,
23
+ * which itself is explicitly "non-exhaustive — new codes may be added
24
+ * without a version bump"). The test suite proves every code in that array
25
+ * has a message mapped — it proves internal consistency of this file, NOT
26
+ * that the array still matches the live API. Re-derive it by re-running the
27
+ * grep in this file's header the next time this module is touched.
28
+ *
29
+ * The one response shape this module must also tolerate is NOT the
30
+ * envelope at all: an uncaught `\Throwable` inside the Laravel app never
31
+ * reaches `ErrorEnvelope::make()` (`app/Exceptions/Handler.php:429-432`
32
+ * returns `null` for anything that isn't a `ValidationException` or an
33
+ * `HttpException`, which is Laravel's signal to fall through to its own
34
+ * default JSON rendering — `{"message":"Server Error"}` in production, with
35
+ * no `error` key and, because `AttachRequestId`'s post-`$next()` header
36
+ * write never runs on an exception-unwound path either, typically no
37
+ * `X-Request-Id` header). `mapApiError` must produce a sane result for that
38
+ * shape too, without throwing.
39
+ */
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.NO_ENVELOPE_CODE = exports.API_ERROR_CODES = void 0;
42
+ exports.mapApiError = mapApiError;
43
+ /** Character class an untrusted string is reduced to before ever appearing in output text. */
44
+ const SAFE_TOKEN_PATTERN = /[^A-Za-z0-9_.:-]/g;
45
+ /** Shared cap for both an unrecognized `code` and a `request_id` — see `sanitizeUntrustedToken`. */
46
+ const MAX_TOKEN_LENGTH = 64;
47
+ /**
48
+ * Strips `value` to `SAFE_TOKEN_PATTERN` and truncates to `MAX_TOKEN_LENGTH`.
49
+ * Used for anything that reaches this module from the wire and is destined
50
+ * to be interpolated into a tool-facing message: an unrecognized `code`, and
51
+ * a `request_id` (caller-supplied header OR envelope body — both are just as
52
+ * untrusted as any other wire value, regardless of how well-behaved the
53
+ * server that is supposed to have generated them is meant to be).
54
+ * Returns `null` when `value` isn't a non-empty string, or when nothing
55
+ * survives stripping (e.g. a value made entirely of disallowed characters).
56
+ */
57
+ function sanitizeUntrustedToken(value) {
58
+ if (typeof value !== 'string' || value.length === 0)
59
+ return null;
60
+ const stripped = value.replace(SAFE_TOKEN_PATTERN, '');
61
+ if (stripped.length === 0)
62
+ return null;
63
+ return stripped.length > MAX_TOKEN_LENGTH ? stripped.slice(0, MAX_TOKEN_LENGTH) : stripped;
64
+ }
65
+ // ---------------------------------------------------------------------------
66
+ // The code inventory. One entry per distinct `code` string passed to
67
+ // `ErrorEnvelope::make(...)` anywhere under `backend/services/laravel-backend/app/`.
68
+ // `status`/`type` are read from the same call site as the code (`type` is
69
+ // the envelope's broad category — `authentication_error` / `permission_error`
70
+ // / `invalid_request_error` / `rate_limit_error` / `idempotency_error` — per
71
+ // the OpenAPI ErrorEnvelope.type description, cross-checked against every
72
+ // citation below and consistent in every case).
73
+ // ---------------------------------------------------------------------------
74
+ exports.API_ERROR_CODES = [
75
+ // auth:api-key guard itself has no token / an unparseable one — the ONLY
76
+ // interception point for that failure on /api/public/v1/* per the
77
+ // docblock on Authenticate::unauthenticated() (Laravel's exception
78
+ // Handler special-cases HttpResponseException and returns this verbatim
79
+ // before Handler.php is ever consulted).
80
+ { code: 'invalid_api_key', status: 401, type: 'authentication_error' }, // app/Http/Middleware/Authenticate.php:44-52
81
+ // A key resolved by the guard, but it isn't a WorkspaceApiKey instance —
82
+ // i.e. no usable key at all. Two independent middleware emit the same code.
83
+ { code: 'api_key_required', status: 401, type: 'authentication_error' }, // app/Http/Middleware/PublicApi/RequireAnyApiKey.php:31-39, app/Http/Middleware/EnsureApiKeyScope.php:34-36
84
+ // The key resolved fine but WorkspaceApiKey::isActive() is false (revoked/disabled).
85
+ { code: 'api_key_disabled', status: 403, type: 'permission_error' }, // app/Http/Middleware/PublicApi/RequireAnyApiKey.php:41-49, app/Http/Middleware/EnsureApiKeyScope.php:38-40
86
+ // Per-route scope assertion: the key's token doesn't carry the ability this route requires.
87
+ { code: 'scope_required', status: 403, type: 'permission_error' }, // app/Http/Middleware/EnsureApiKeyScope.php:48-50
88
+ // Default-deny terminal: a route that asserted no scope middleware at all.
89
+ { code: 'scope_not_asserted', status: 403, type: 'permission_error' }, // app/Http/Middleware/RequireAssertedApiKeyScope.php:26-29
90
+ // Authenticated + correctly scoped, but denied at the per-project permission layer.
91
+ { code: 'forbidden', status: 403, type: 'permission_error' }, // app/Http/Controllers/Api/PublicApi/V1/TasksController.php:243-252
92
+ // FormRequest field validation failure. Emitted from every write FormRequest's failedValidation().
93
+ { code: 'validation_error', status: 422, type: 'invalid_request_error' }, // app/Http/Requests/PublicApi/V1/StorePublicTaskRequest.php:88-91, UpdatePublicTaskRequest.php:82-85, StorePublicTaskCommentRequest.php:58-61, StorePublicEventRequest.php:125-128
94
+ { code: 'no_open_column', status: 422, type: 'invalid_request_error' }, // app/Http/Controllers/Api/PublicApi/V1/TasksController.php:254-270
95
+ { code: 'invalid_assignee', status: 422, type: 'invalid_request_error' }, // app/Http/Controllers/Api/PublicApi/V1/TasksController.php:273-286
96
+ { code: 'inbox_project', status: 422, type: 'invalid_request_error' }, // app/Http/Controllers/Api/PublicApi/V1/TasksController.php:345-356
97
+ { code: 'invalid_date', status: 422, type: 'invalid_request_error' }, // app/Http/Controllers/Api/PublicApi/V1/EventsController.php:183-195
98
+ { code: 'window_too_large', status: 422, type: 'invalid_request_error' }, // app/Http/Controllers/Api/PublicApi/V1/EventsController.php:198-207
99
+ // Resource lookup miss OR the caller's key can't see it — no existence oracle by design.
100
+ { code: 'not_found', status: 404, type: 'invalid_request_error' }, // app/Http/Controllers/Api/PublicApi/V1/TasksController.php:466-469, TaskCommentsController.php:135-138, ProjectsController.php:95-98
101
+ { code: 'idempotency_key_reuse', status: 409, type: 'idempotency_error' }, // app/Http/Middleware/PublicApi/PublicApiIdempotency.php:86-95
102
+ { code: 'key_rate_limited', status: 429, type: 'rate_limit_error' }, // app/Providers/RouteServiceProvider.php:179-184
103
+ { code: 'workspace_rate_limited', status: 429, type: 'rate_limit_error' }, // app/Providers/RouteServiceProvider.php:185-190
104
+ { code: 'write_rate_limited', status: 429, type: 'rate_limit_error' }, // app/Providers/RouteServiceProvider.php:206-214
105
+ { code: 'anonymous_rate_limited', status: 429, type: 'rate_limit_error' }, // app/Providers/RouteServiceProvider.php:236-243
106
+ ];
107
+ /**
108
+ * One model-actionable message per known code. Deliberately never reads
109
+ * `error.message` from the wire — every string below is fully static,
110
+ * written from the code's own call site, so a compromised or merely
111
+ * confusing upstream message can never reach this module's output even for
112
+ * a code we recognize.
113
+ *
114
+ * `Record<KnownApiErrorCode, string>` makes an entry missing for any member
115
+ * of `API_ERROR_CODES` a TypeScript compile error (belt) in addition to the
116
+ * runtime totality test in errors.test.ts (suspenders).
117
+ */
118
+ const ERROR_CODE_MESSAGES = {
119
+ invalid_api_key: 'The API key was rejected — it is missing, malformed, or not recognized by the server. ' +
120
+ 'This will not succeed by retrying the same request: the configured API key needs to be replaced ' +
121
+ 'with a valid, current workspace API key before this tool can be used again.',
122
+ api_key_required: 'No usable API key was presented with this request. This will not succeed by retrying: ' +
123
+ "check that the server's API key configuration is actually set before trying again.",
124
+ api_key_disabled: 'This API key has been disabled and can no longer authenticate requests. This will not succeed ' +
125
+ 'by retrying — a new or re-enabled API key is required before this tool can be used again.',
126
+ scope_required: "The current API key does not carry the scope this operation requires. A key's scopes can be " +
127
+ 'narrowed after the key was issued, so this can appear even for a key that used to work. ' +
128
+ "Restarting the MCP server re-probes the key's currently available scopes; if the scope is " +
129
+ 'still missing after a restart, a key with the necessary scope is required — this is not something ' +
130
+ 'retrying the same request can fix on its own.',
131
+ scope_not_asserted: 'This route requires an explicitly asserted API key scope, and the server found none asserted for ' +
132
+ 'it. This points at a server-side routing or tool-definition problem rather than anything the caller ' +
133
+ 'did wrong, and should not occur through the tools this MCP server exposes.',
134
+ forbidden: "The request was authenticated and the API key's scope was sufficient, but access to this specific " +
135
+ 'project or resource was denied. This is a per-project authorization failure, not a problem with the ' +
136
+ 'API key itself — the same key may still work for other projects in this workspace.',
137
+ validation_error: 'The request was rejected because one or more fields failed validation. Retrying the exact same ' +
138
+ 'request will fail the same way — the offending field(s) need to be corrected first.',
139
+ no_open_column: 'This project has no open (not-done) column to receive a new task. Either specify an existing ' +
140
+ 'column explicitly, or create/open one in the project before creating a task without one.',
141
+ invalid_assignee: 'One or more of the requested assignees are not members of this workspace. Confirm the assignee ' +
142
+ "id(s) against the workspace's member list before retrying.",
143
+ inbox_project: 'This project is an inbox project and cannot receive tasks created through the API. Choose a ' +
144
+ 'different, non-inbox project and retry.',
145
+ invalid_date: 'One of the date parameters supplied could not be parsed as a valid date. Check its format and ' +
146
+ 'value before retrying.',
147
+ window_too_large: 'The requested date window is larger than the server allows. Narrow the from/to range and retry.',
148
+ not_found: 'No matching resource was found for this request — OR it exists but is not visible to this API key ' +
149
+ '(a project in a different workspace, a private or archived project, or an inbox project all produce ' +
150
+ 'this exact same response, by design, so that a caller cannot use this response to distinguish "does ' +
151
+ 'not exist" from "not yours" from "not visible right now"). A 404 here does NOT prove the resource ' +
152
+ 'does not exist, and its absence should not be treated or cached as permanent nonexistence — it may ' +
153
+ 'become reachable later (e.g. if workspace access changes) with no change on the caller\'s side at all.',
154
+ idempotency_key_reuse: 'The Idempotency-Key supplied for this request was already used with a different request body. Use ' +
155
+ 'a fresh Idempotency-Key for a genuinely new request, or resend the exact original request body to ' +
156
+ 'get back the original result.',
157
+ key_rate_limited: "This API key has exceeded its per-minute request budget. This is transient — it's reasonable to " +
158
+ 'wait and retry with backoff.',
159
+ workspace_rate_limited: "This workspace has exceeded its per-minute request budget across all of its API keys. This is " +
160
+ "transient — it's reasonable to wait and retry with backoff.",
161
+ write_rate_limited: "This API key has exceeded its per-minute WRITE-request budget specifically. This is transient — " +
162
+ "it's reasonable to wait and retry with backoff, and to prefer fewer, larger write requests where " +
163
+ 'possible.',
164
+ anonymous_rate_limited: 'Too many requests have been made from this network address without a valid API key being ' +
165
+ "recognized. If a key is configured, verify it; if it's valid, this is transient and it's " +
166
+ 'reasonable to wait and retry with backoff.',
167
+ };
168
+ /** True for status codes worth an automatic retry (rate limits, server errors) — false for everything else. */
169
+ function isTransientStatus(status) {
170
+ return status === 429 || status >= 500;
171
+ }
172
+ function withRequestIdSuffix(message, requestId) {
173
+ const suffix = requestId ? `(request_id: ${requestId})` : '(no request_id available)';
174
+ return `${message} ${suffix}`;
175
+ }
176
+ /**
177
+ * Recognizes the `{error:{code, request_id, ...}}` envelope shape and pulls
178
+ * out only `code`/`request_id` — never `message` or `type` (this module has
179
+ * no use for either, and touching `message` here would be exactly the
180
+ * interpolation this module exists to avoid). Returns `null` for anything
181
+ * that isn't that shape: a string, `null`, an array, a plain object with no
182
+ * `error` key (the uncaught-`\Throwable` `{"message":"Server Error"}` body),
183
+ * or an `error` object whose `code` isn't a non-empty string. Never throws —
184
+ * `body` is `unknown` and may be genuinely anything a JSON.parse (or a
185
+ * JSON.parse failure represented as raw text) could hand back.
186
+ */
187
+ function extractEnvelopeError(body) {
188
+ if (typeof body !== 'object' || body === null || Array.isArray(body))
189
+ return null;
190
+ const maybeError = body.error;
191
+ if (typeof maybeError !== 'object' || maybeError === null || Array.isArray(maybeError))
192
+ return null;
193
+ const errorObj = maybeError;
194
+ const code = typeof errorObj.code === 'string' && errorObj.code.length > 0 ? errorObj.code : null;
195
+ if (code === null)
196
+ return null;
197
+ const requestId = typeof errorObj.request_id === 'string' && errorObj.request_id.length > 0
198
+ ? errorObj.request_id
199
+ : null;
200
+ return { code, requestId };
201
+ }
202
+ /** Sentinel `code` this module reports when the body wasn't the error envelope at all. */
203
+ /** Also used by client.ts when a 2xx body is empty/unparseable — same "no usable envelope" situation. */
204
+ exports.NO_ENVELOPE_CODE = 'no_error_envelope';
205
+ /**
206
+ * Maps a Public API v1 HTTP response into text an LLM tool-caller can act
207
+ * on. Pure — makes no network call, and never throws regardless of what
208
+ * `body` turns out to be.
209
+ *
210
+ * `requestId`, when given, should be the response's `X-Request-Id` header —
211
+ * it takes priority over any `request_id` found inside `body.error`, since
212
+ * the header is set directly by `ErrorEnvelope::make()` on every envelope
213
+ * response and, unlike the body, is also present on responses that bypass
214
+ * `AttachRequestId`'s own header-write step (an exception-converted 401 —
215
+ * see the file-level docblock). Falls back to `body.error.request_id`, then
216
+ * to `null` when neither is available (the uncaught-`\Throwable` fallback
217
+ * body has neither).
218
+ */
219
+ function mapApiError(status, body, requestId) {
220
+ const envelope = extractEnvelopeError(body);
221
+ const suppliedRequestId = typeof requestId === 'string' && requestId.length > 0 ? requestId : null;
222
+ const rawRequestId = suppliedRequestId ?? envelope?.requestId ?? null;
223
+ const sanitizedRequestId = sanitizeUntrustedToken(rawRequestId);
224
+ const terminal = !isTransientStatus(status);
225
+ if (envelope) {
226
+ const known = ERROR_CODE_MESSAGES[envelope.code];
227
+ if (known) {
228
+ return {
229
+ code: envelope.code,
230
+ status,
231
+ terminal,
232
+ requestId: sanitizedRequestId,
233
+ message: withRequestIdSuffix(known, sanitizedRequestId),
234
+ };
235
+ }
236
+ const safeCode = sanitizeUntrustedToken(envelope.code) ?? 'unknown';
237
+ const message = `The server returned an error with code \`${safeCode}\` (HTTP ${status}), which this tool has ` +
238
+ 'no specific guidance for. Treat this as a failure and do not assume it is safe to retry without ' +
239
+ 'understanding the cause first.';
240
+ return {
241
+ code: safeCode,
242
+ status,
243
+ terminal,
244
+ requestId: sanitizedRequestId,
245
+ message: withRequestIdSuffix(message, sanitizedRequestId),
246
+ };
247
+ }
248
+ const retryGuidance = terminal
249
+ ? 'Given the HTTP status, retrying this exact request unchanged is unlikely to succeed.'
250
+ : 'This looks transient; it is reasonable to wait and retry with backoff.';
251
+ const message = `The server returned an error (HTTP ${status}) without the API's usual structured error body — ` +
252
+ 'most consistent with an unexpected server-side failure rather than a problem with the request ' +
253
+ `itself. ${retryGuidance}`;
254
+ return {
255
+ code: exports.NO_ENVELOPE_CODE,
256
+ status,
257
+ terminal,
258
+ requestId: sanitizedRequestId,
259
+ message: withRequestIdSuffix(message, sanitizedRequestId),
260
+ };
261
+ }
262
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/api/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;;;AA+PH,kCAsDC;AAnTD,8FAA8F;AAC9F,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C,oGAAoG;AACpG,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;;;;;;GASG;AACH,SAAS,sBAAsB,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACjE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACvD,IAAI,QAAQ,CAAC,MAAM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C,OAAO,EAAE,kBAAkB,CAAC;KAC1D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The single place that translates between the MCP tool vocabulary and the
3
+ * Workel Public API v1 wire vocabulary. Everything downstream (the HTTP
4
+ * client, the tools themselves) speaks tool vocabulary only — if a field
5
+ * pair is missing here it is silently wrong everywhere it's used, not just
6
+ * here, so this module intentionally does the renaming explicitly per
7
+ * endpoint rather than through a generic `renameKeys(obj, map)` helper: an
8
+ * explicit mapper is what a reviewer can read directly against the spec.
9
+ *
10
+ * Write direction (tool input -> wire request body): the request-side
11
+ * "Wire*" types live here rather than in `types.ts`, since `types.ts` is
12
+ * scoped to wire *response* shapes. Authority for every field name and
13
+ * nullability below is `docs/openapi/public-api-v1.yaml` PLUS the actual
14
+ * FormRequest under `app/Http/Requests/PublicApi/V1/` (the FormRequest
15
+ * wins on any disagreement — it's what the server actually validates).
16
+ *
17
+ * Read direction (wire response -> tool object): uses the `Wire*` response
18
+ * types from `./types`.
19
+ *
20
+ * Deliberately NOT exposed in either direction: `reminder_date` on task
21
+ * update. The wire endpoint (`UpdatePublicTaskRequest`) accepts it, but it
22
+ * is write-only over this API (no read endpoint ever returns it) — exposing
23
+ * a field a caller can set but never read back breaks the read/write
24
+ * symmetry this seam exists to guarantee, so it is left out of the tool
25
+ * vocabulary entirely rather than passed through.
26
+ *
27
+ * Also deliberately NOT exposed: `mention_user_ids` on task comments. The
28
+ * FormRequest declares it `prohibited` (not silently ignored) — no
29
+ * @-mention syntax is parsed in v1 — so the tool-facing comment input has
30
+ * no such field to begin with, and `mapCreateCommentToWire` cannot forward
31
+ * one even if a caller forces it in via a type cast.
32
+ */
33
+ import type { Column, Event, Member, Project, ProjectColumn, Task, TaskComment, TaskCommentAuthor, WireCard, WireEvent, WireMember, WireProject, WireProjectColumn, WireTask, WireTaskComment, WireTaskCommentAuthor } from './types';
34
+ export interface CreateTaskInput {
35
+ column_id?: string | null;
36
+ project_id?: string | null;
37
+ title: string;
38
+ description?: string | null;
39
+ priority?: 'low' | 'medium' | 'high' | 'urgent' | 'none' | null;
40
+ progress?: number | null;
41
+ due_date?: string | null;
42
+ due_time?: string | null;
43
+ assignee_ids?: string[] | null;
44
+ }
45
+ export interface WireCreateTaskRequest {
46
+ card_id?: string | null;
47
+ project_id?: string | null;
48
+ title_text: string;
49
+ description?: string | null;
50
+ priority?: 'low' | 'medium' | 'high' | 'urgent' | 'none' | null;
51
+ progress?: number | null;
52
+ end_date?: string | null;
53
+ end_time?: string | null;
54
+ user_ids?: string[] | null;
55
+ }
56
+ export declare function mapCreateTaskToWire(input: CreateTaskInput): WireCreateTaskRequest;
57
+ export interface UpdateTaskInput {
58
+ title?: string | null;
59
+ description?: string | null;
60
+ priority?: 'low' | 'medium' | 'high' | 'urgent' | 'none' | null;
61
+ progress?: number | null;
62
+ due_date?: string | null;
63
+ due_time?: string | null;
64
+ }
65
+ export interface WireUpdateTaskRequest {
66
+ title_text?: string | null;
67
+ description?: string | null;
68
+ priority?: 'low' | 'medium' | 'high' | 'urgent' | 'none' | null;
69
+ progress?: number | null;
70
+ end_date?: string | null;
71
+ end_time?: string | null;
72
+ reminder_date?: string | null;
73
+ }
74
+ export declare function mapUpdateTaskToWire(input: UpdateTaskInput): WireUpdateTaskRequest;
75
+ export interface CreateEventInput {
76
+ title: string;
77
+ description?: string | null;
78
+ date: string;
79
+ start_time: string;
80
+ end_time: string;
81
+ reminder_at?: string | null;
82
+ timezone?: string | null;
83
+ reminder_minutes_before?: number | null;
84
+ repeat: 'none' | 'daily' | 'weekly' | 'monthly' | 'yearly';
85
+ repeat_interval?: number | null;
86
+ location?: string | null;
87
+ meet_link?: string | null;
88
+ color?: string | null;
89
+ order?: number | null;
90
+ project_id?: string | null;
91
+ invited_user_ids?: string[] | null;
92
+ }
93
+ export interface WireCreateEventRequest {
94
+ title: string;
95
+ description?: string | null;
96
+ date: string;
97
+ start_time: string;
98
+ end_time: string;
99
+ reminder_at?: string | null;
100
+ timezone?: string | null;
101
+ reminder_minutes_before?: number | null;
102
+ repeat: 'none' | 'daily' | 'weekly' | 'monthly' | 'yearly';
103
+ repeat_interval?: number | null;
104
+ location?: string | null;
105
+ meet_link?: string | null;
106
+ color?: string | null;
107
+ order?: number | null;
108
+ project_id?: string | null;
109
+ invited_users?: string[] | null;
110
+ }
111
+ export declare function mapCreateEventToWire(input: CreateEventInput): WireCreateEventRequest;
112
+ export interface CreateCommentInput {
113
+ body: string;
114
+ }
115
+ export interface WireCreateCommentRequest {
116
+ body: string;
117
+ }
118
+ export declare function mapCreateCommentToWire(input: CreateCommentInput): WireCreateCommentRequest;
119
+ /**
120
+ * Maps a task's embedded board-column ("card") to the tool vocabulary's
121
+ * `column`. Field-for-field, no rename among {id, name, is_done} — only the
122
+ * container's own name (`card` -> `column`) and the derived `column_id`
123
+ * (built by `mapTaskFromWire`, not here) change.
124
+ */
125
+ export declare function mapColumnFromWire(card: WireCard): Column;
126
+ /**
127
+ * Maps a wire Task response to the tool vocabulary. The nested `card`
128
+ * object becomes `column`, plus a derived `column_id` equal to the card's
129
+ * own id (both null when the task has no card). Every other field keeps
130
+ * its wire name — the OpenAPI Task schema already uses tool-natural names
131
+ * on read. Built field-by-field (never via object spread) so an unknown
132
+ * key on the wire response is silently dropped rather than leaking through,
133
+ * and so the literal key `card` can never appear anywhere in the output.
134
+ */
135
+ export declare function mapTaskFromWire(task: WireTask): Task;
136
+ export declare function mapProjectFromWire(project: WireProject): Project;
137
+ export declare function mapMemberFromWire(member: WireMember): Member;
138
+ /**
139
+ * The FULL board-column listing shape (`GET /projects/{id}/cards`) — see
140
+ * `ProjectColumn`'s own docblock in `./types` for why this is a distinct
141
+ * type/mapper from `mapColumnFromWire`'s narrower, Task-embedded `Column`.
142
+ */
143
+ export declare function mapProjectColumnFromWire(card: WireProjectColumn): ProjectColumn;
144
+ export declare function mapTaskCommentAuthorFromWire(author: WireTaskCommentAuthor): TaskCommentAuthor;
145
+ export declare function mapTaskCommentFromWire(comment: WireTaskComment): TaskComment;
146
+ export declare function mapEventFromWire(event: WireEvent): Event;
147
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/api/mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,aAAa,EACb,IAAI,EACJ,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAqBjB,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;IAChE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,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