@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,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `workel_create_task` — `POST /tasks` (`write:tasks` scope).
|
|
4
|
+
*
|
|
5
|
+
* Registered only under the D5 double opt-in gate (`./registration.ts`):
|
|
6
|
+
* this module only declares `scope: 'write:tasks'` on its descriptor —
|
|
7
|
+
* `registration.ts` is the sole place that decides whether this factory is
|
|
8
|
+
* ever handed to `buildServer` at all.
|
|
9
|
+
*
|
|
10
|
+
* MCP-facing vocabulary matches every read tool's: `title`, `column_id`,
|
|
11
|
+
* `project_id`, `due_date`, `due_time`, `assignee_ids`. The wire rename to
|
|
12
|
+
* `title_text`/`card_id`/`end_date`/`end_time`/`user_ids` happens ONLY in
|
|
13
|
+
* `../api/mapping.ts`'s `mapCreateTaskToWire` — never re-implemented here.
|
|
14
|
+
*
|
|
15
|
+
* Three client-side rejections (zero fetch calls), each verified directly
|
|
16
|
+
* against `StorePublicTaskRequest`/`TasksController::store`
|
|
17
|
+
* (backend/services/laravel-backend/app/Http/{Requests,Controllers/Api/PublicApi/V1}/{StorePublicTaskRequest,TasksController}.php):
|
|
18
|
+
*
|
|
19
|
+
* 1. `column_id` AND `project_id` both given. `TasksController::store`
|
|
20
|
+
* reads `card_id` first and, when present, never even looks at
|
|
21
|
+
* `project_id` at all (TasksController.php:227-237) — silently honoring
|
|
22
|
+
* one and ignoring the other would be a worse experience than an
|
|
23
|
+
* explicit rejection naming which one wins.
|
|
24
|
+
* 2. Neither `column_id` nor `project_id` given. `project_id` is
|
|
25
|
+
* `required_without:card_id` on the wire (StorePublicTaskRequest.php:67);
|
|
26
|
+
* rejecting here with guidance toward `workel_list_project_columns` /
|
|
27
|
+
* `workel_list_projects` / `workel_get_project` is more useful than the
|
|
28
|
+
* wire's generic "the project id field is required" message.
|
|
29
|
+
* 3. `due_time` given without `due_date`. `TasksController::store` silently
|
|
30
|
+
* drops an orphan `end_time` when `end_date` is empty
|
|
31
|
+
* (TasksController.php:293-298 — "we never persist a floating HH:mm with
|
|
32
|
+
* no day"), so a caller who set only `due_time` would see the create
|
|
33
|
+
* succeed with NO time set at all and no indication why.
|
|
34
|
+
*
|
|
35
|
+
* Nothing else is pre-validated. A non-member `assignee_ids` entry (rejected
|
|
36
|
+
* whole-request with the `invalid_assignee` code, TasksController.php:273-286),
|
|
37
|
+
* an unknown `column_id`/`project_id`, or an archived/private/inbox project
|
|
38
|
+
* all go straight to the wire and come back as the mapped upstream error
|
|
39
|
+
* (`../api/errors.ts`) — this tool does not re-implement or anticipate any
|
|
40
|
+
* of those checks.
|
|
41
|
+
*
|
|
42
|
+
* `idempotency_key` (D7, docs/MCP_SERVER_PLAN.md): forwarded verbatim to
|
|
43
|
+
* `client.post`'s own `Idempotency-Key` header (`../api/client.ts`, T9). The
|
|
44
|
+
* client already auto-generates a fresh one for its OWN transport retries
|
|
45
|
+
* (a timeout re-sending the identical request); this field exists for the
|
|
46
|
+
* different case D7 names explicitly — a model unsure whether its own
|
|
47
|
+
* earlier tool call actually landed. Reusing the same `idempotency_key` on a
|
|
48
|
+
* retry returns the ORIGINAL task rather than creating a second one, and the
|
|
49
|
+
* result's `replayed: true` says so plainly rather than leaving the caller
|
|
50
|
+
* to guess from two visually-identical task objects.
|
|
51
|
+
*/
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.workelCreateTask = void 0;
|
|
54
|
+
const zod_1 = require("zod");
|
|
55
|
+
const mapping_1 = require("../api/mapping");
|
|
56
|
+
const defineTool_1 = require("./defineTool");
|
|
57
|
+
const conventions_1 = require("./conventions");
|
|
58
|
+
const SCOPE = 'write:tasks';
|
|
59
|
+
const PRIORITY_VALUES = ['low', 'medium', 'high', 'urgent', 'none'];
|
|
60
|
+
const DESCRIPTION = 'Create a new task. Provide EXACTLY ONE of column_id or project_id to place it: column_id puts it ' +
|
|
61
|
+
"directly in that board column (a column's `id`, from workel_list_project_columns), while " +
|
|
62
|
+
"project_id lets the server place it in that project's first open (not-done) column. Giving both " +
|
|
63
|
+
'is rejected by this tool — the server would silently honor column_id and ignore project_id, and ' +
|
|
64
|
+
'this tool refuses to do that quietly. Giving neither is also rejected; call ' +
|
|
65
|
+
'workel_list_project_columns, workel_list_projects, or workel_get_project first to get one of them. ' +
|
|
66
|
+
'due_time is only meaningful alongside due_date — the server silently drops a due_time given ' +
|
|
67
|
+
'without a due_date, so this tool rejects that combination instead of creating a task with no time ' +
|
|
68
|
+
'set and no explanation why. assignee_ids are validated against workspace membership on the ' +
|
|
69
|
+
'server: any id that is not a member of this workspace rejects the ENTIRE request (no partial ' +
|
|
70
|
+
'assignment) with a clear error — this tool does not pre-check membership itself, so that ' +
|
|
71
|
+
'rejection, like any other server-side validation failure, is returned as-is. An optional ' +
|
|
72
|
+
'idempotency_key, reused across a retry of the exact same call (e.g. when unsure whether a previous ' +
|
|
73
|
+
"call actually created a task), returns the ORIGINAL task instead of creating a second one — the " +
|
|
74
|
+
"result's `replayed` field is true when that happened, false for a freshly created task. " +
|
|
75
|
+
conventions_1.UNTRUSTED_CONTENT_NOTE;
|
|
76
|
+
function hasOwn(obj, key) {
|
|
77
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
78
|
+
}
|
|
79
|
+
/** A well-formed client-side rejection — never a thrown exception, so it never invents a fake protocol-level failure for what is, structurally, an ordinary tool result. */
|
|
80
|
+
function rejection(text) {
|
|
81
|
+
return { content: [{ type: 'text', text }], isError: true };
|
|
82
|
+
}
|
|
83
|
+
const workelCreateTask = (client) => (0, defineTool_1.defineTool)({
|
|
84
|
+
name: 'workel_create_task',
|
|
85
|
+
description: DESCRIPTION,
|
|
86
|
+
inputSchema: {
|
|
87
|
+
title: zod_1.z.string().min(1),
|
|
88
|
+
column_id: zod_1.z.string().optional(),
|
|
89
|
+
project_id: zod_1.z.string().optional(),
|
|
90
|
+
description: zod_1.z.string().optional(),
|
|
91
|
+
priority: zod_1.z.enum(PRIORITY_VALUES).optional(),
|
|
92
|
+
progress: zod_1.z.number().int().optional(),
|
|
93
|
+
due_date: zod_1.z.string().optional(),
|
|
94
|
+
due_time: zod_1.z.string().optional(),
|
|
95
|
+
assignee_ids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
96
|
+
idempotency_key: zod_1.z.string().optional(),
|
|
97
|
+
},
|
|
98
|
+
annotations: {
|
|
99
|
+
title: 'Create task',
|
|
100
|
+
readOnlyHint: false,
|
|
101
|
+
destructiveHint: false,
|
|
102
|
+
idempotentHint: false,
|
|
103
|
+
openWorldHint: false,
|
|
104
|
+
},
|
|
105
|
+
scope: SCOPE,
|
|
106
|
+
handler: async (args) => {
|
|
107
|
+
const input = args;
|
|
108
|
+
if (hasOwn(args, 'column_id') && hasOwn(args, 'project_id')) {
|
|
109
|
+
return rejection('Both column_id and project_id were given. The server only honors column_id when both are ' +
|
|
110
|
+
'present — project_id would be silently ignored. Supply exactly one: column_id to target a ' +
|
|
111
|
+
"specific board column, or project_id to let the server pick that project's first open column.");
|
|
112
|
+
}
|
|
113
|
+
if (!hasOwn(args, 'column_id') && !hasOwn(args, 'project_id')) {
|
|
114
|
+
return rejection('Neither column_id nor project_id was given — one is required to place the new task. Call ' +
|
|
115
|
+
'workel_list_project_columns (or workel_get_project / workel_list_projects) to find a ' +
|
|
116
|
+
'column_id or project_id first, then retry with one of them set.');
|
|
117
|
+
}
|
|
118
|
+
if (hasOwn(args, 'due_time') && !hasOwn(args, 'due_date')) {
|
|
119
|
+
return rejection('due_time was given without due_date. The server silently drops due_time when due_date is ' +
|
|
120
|
+
'absent, so this task would be created with no time set and no indication why. Supply ' +
|
|
121
|
+
'due_date alongside due_time, or omit due_time.');
|
|
122
|
+
}
|
|
123
|
+
// `input` still carries `idempotency_key` as an own property here, but
|
|
124
|
+
// `mapCreateTaskToWire` only ever reads the eight fields it explicitly
|
|
125
|
+
// checks (`../api/mapping.ts`) — an extra key is never copied onto the
|
|
126
|
+
// wire body, so no stripping step is needed before this call.
|
|
127
|
+
const wireBody = (0, mapping_1.mapCreateTaskToWire)(input);
|
|
128
|
+
const result = await client.post('/tasks', wireBody, {
|
|
129
|
+
idempotencyKey: input.idempotency_key,
|
|
130
|
+
});
|
|
131
|
+
const task = (0, mapping_1.mapTaskFromWire)(result.data);
|
|
132
|
+
return (0, conventions_1.jsonToolResult)({ ...task, replayed: result.replayed ?? false });
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
exports.workelCreateTask = workelCreateTask;
|
|
136
|
+
//# sourceMappingURL=createTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTask.js","sourceRoot":"","sources":["../../src/tools/createTask.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool-registration seam every MCP tool is declared through.
|
|
3
|
+
*
|
|
4
|
+
* This module knows nothing about any MCP SDK — deliberately, and that is
|
|
5
|
+
* the whole point of its existence. The SDK's tool-registration API wants a
|
|
6
|
+
* specific Zod-raw-shape/callback shape today; if that surface changes (an
|
|
7
|
+
* SDK major-version move, or a switch to a different transport library
|
|
8
|
+
* entirely), the fix is a change to `server.ts`'s adapter code only, never a
|
|
9
|
+
* rewrite of every individual tool file that calls `defineTool()`. Importing
|
|
10
|
+
* `zod` here is fine and expected — `inputSchema` genuinely IS a Zod raw
|
|
11
|
+
* shape; that is how a tool declares its own parameters, not an SDK detail.
|
|
12
|
+
*
|
|
13
|
+
* `ToolResult` and `ToolAnnotations` are defined structurally below rather
|
|
14
|
+
* than imported from an SDK package, for the same reason: they are the
|
|
15
|
+
* minimal shapes a tool handler / a tool's metadata need, not whatever an
|
|
16
|
+
* SDK's own richer internal type happens to look like today.
|
|
17
|
+
*/
|
|
18
|
+
import type { ZodTypeAny } from 'zod';
|
|
19
|
+
import type { WorkelApiClient } from '../api/client';
|
|
20
|
+
/**
|
|
21
|
+
* The minimal shape every tool handler resolves to. A `text` content block
|
|
22
|
+
* is all v1 tools need; `structuredContent` and `isError` are optional so a
|
|
23
|
+
* handler that has nothing more to say than a plain string doesn't have to
|
|
24
|
+
* populate them.
|
|
25
|
+
*/
|
|
26
|
+
export interface ToolResult {
|
|
27
|
+
content: {
|
|
28
|
+
type: 'text';
|
|
29
|
+
text: string;
|
|
30
|
+
}[];
|
|
31
|
+
structuredContent?: unknown;
|
|
32
|
+
isError?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Hints about a tool's behaviour (is it read-only, is it destructive, ...).
|
|
36
|
+
* All optional — a tool that doesn't set any of these is simply making no
|
|
37
|
+
* claim either way.
|
|
38
|
+
*/
|
|
39
|
+
export interface ToolAnnotations {
|
|
40
|
+
title?: string;
|
|
41
|
+
readOnlyHint?: boolean;
|
|
42
|
+
destructiveHint?: boolean;
|
|
43
|
+
idempotentHint?: boolean;
|
|
44
|
+
openWorldHint?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export type ToolHandler = (args: Record<string, unknown>) => Promise<ToolResult>;
|
|
47
|
+
export interface ToolDescriptor {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
inputSchema: Record<string, ZodTypeAny>;
|
|
51
|
+
annotations?: ToolAnnotations;
|
|
52
|
+
handler: ToolHandler;
|
|
53
|
+
/**
|
|
54
|
+
* The Public API v1 scope this tool requires (e.g. `read:tasks`), or
|
|
55
|
+
* absent for a tool that needs no per-key gate. `buildServer` (server.ts)
|
|
56
|
+
* is the only reader of this field — it decides, per API key, which
|
|
57
|
+
* descriptors actually get registered. A descriptor with no `scope`
|
|
58
|
+
* always registers.
|
|
59
|
+
*/
|
|
60
|
+
scope?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A tool module exports a factory, not a bare descriptor, so `buildServer`
|
|
64
|
+
* is the single place that decides which client a tool talks to — a tool
|
|
65
|
+
* module never constructs or imports a client of its own.
|
|
66
|
+
*/
|
|
67
|
+
export type ToolFactory = (client: WorkelApiClient) => ToolDescriptor;
|
|
68
|
+
/**
|
|
69
|
+
* Identity function with a name. Its only job is to give every tool module
|
|
70
|
+
* one, greppable, five-field shape (`name`, `description`, `inputSchema`,
|
|
71
|
+
* `annotations`, `handler`) to declare a tool through, plus the optional
|
|
72
|
+
* `scope` gate above — rather than every tool module hand-assembling a
|
|
73
|
+
* plain object and hoping it matches what `server.ts` expects.
|
|
74
|
+
*/
|
|
75
|
+
export declare function defineTool(descriptor: ToolDescriptor): ToolDescriptor;
|
|
76
|
+
//# sourceMappingURL=defineTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineTool.d.ts","sourceRoot":"","sources":["../../src/tools/defineTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEjF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,cAAc,CAAC;AAEtE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc,CAErE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The tool-registration seam every MCP tool is declared through.
|
|
4
|
+
*
|
|
5
|
+
* This module knows nothing about any MCP SDK — deliberately, and that is
|
|
6
|
+
* the whole point of its existence. The SDK's tool-registration API wants a
|
|
7
|
+
* specific Zod-raw-shape/callback shape today; if that surface changes (an
|
|
8
|
+
* SDK major-version move, or a switch to a different transport library
|
|
9
|
+
* entirely), the fix is a change to `server.ts`'s adapter code only, never a
|
|
10
|
+
* rewrite of every individual tool file that calls `defineTool()`. Importing
|
|
11
|
+
* `zod` here is fine and expected — `inputSchema` genuinely IS a Zod raw
|
|
12
|
+
* shape; that is how a tool declares its own parameters, not an SDK detail.
|
|
13
|
+
*
|
|
14
|
+
* `ToolResult` and `ToolAnnotations` are defined structurally below rather
|
|
15
|
+
* than imported from an SDK package, for the same reason: they are the
|
|
16
|
+
* minimal shapes a tool handler / a tool's metadata need, not whatever an
|
|
17
|
+
* SDK's own richer internal type happens to look like today.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.defineTool = defineTool;
|
|
21
|
+
/**
|
|
22
|
+
* Identity function with a name. Its only job is to give every tool module
|
|
23
|
+
* one, greppable, five-field shape (`name`, `description`, `inputSchema`,
|
|
24
|
+
* `annotations`, `handler`) to declare a tool through, plus the optional
|
|
25
|
+
* `scope` gate above — rather than every tool module hand-assembling a
|
|
26
|
+
* plain object and hoping it matches what `server.ts` expects.
|
|
27
|
+
*/
|
|
28
|
+
function defineTool(descriptor) {
|
|
29
|
+
return descriptor;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=defineTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineTool.js","sourceRoot":"","sources":["../../src/tools/defineTool.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AA8DH,gCAEC;AATD;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,UAA0B;IACnD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool registry: every read tool this server exposes, as an array of
|
|
3
|
+
* `ToolFactory` — ready to hand straight to `buildServer(client, caps,
|
|
4
|
+
* READ_TOOLS)` (server.ts). Nine tools across seven modules (`workel_projects`
|
|
5
|
+
* and `workel_tasks` each export two factories, one per read action their
|
|
6
|
+
* backend controller exposes — `ProjectsController`/`TasksController` bundle
|
|
7
|
+
* index+show the same way).
|
|
8
|
+
*
|
|
9
|
+
* `src/conventions.test.ts` treats this array as the live source of truth —
|
|
10
|
+
* it never hand-copies the tool list, so adding, removing, or renaming a
|
|
11
|
+
* tool here is exactly what that test's assertions react to.
|
|
12
|
+
*/
|
|
13
|
+
import type { ToolFactory } from './defineTool';
|
|
14
|
+
export declare const READ_TOOLS: ToolFactory[];
|
|
15
|
+
export * from './conventions';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAShD,eAAO,MAAM,UAAU,EAAE,WAAW,EAUnC,CAAC;AAEF,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The tool registry: every read tool this server exposes, as an array of
|
|
4
|
+
* `ToolFactory` — ready to hand straight to `buildServer(client, caps,
|
|
5
|
+
* READ_TOOLS)` (server.ts). Nine tools across seven modules (`workel_projects`
|
|
6
|
+
* and `workel_tasks` each export two factories, one per read action their
|
|
7
|
+
* backend controller exposes — `ProjectsController`/`TasksController` bundle
|
|
8
|
+
* index+show the same way).
|
|
9
|
+
*
|
|
10
|
+
* `src/conventions.test.ts` treats this array as the live source of truth —
|
|
11
|
+
* it never hand-copies the tool list, so adding, removing, or renaming a
|
|
12
|
+
* tool here is exactly what that test's assertions react to.
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.READ_TOOLS = void 0;
|
|
30
|
+
const workel_whoami_1 = require("./workel_whoami");
|
|
31
|
+
const workel_projects_1 = require("./workel_projects");
|
|
32
|
+
const workel_project_columns_1 = require("./workel_project_columns");
|
|
33
|
+
const workel_members_1 = require("./workel_members");
|
|
34
|
+
const workel_tasks_1 = require("./workel_tasks");
|
|
35
|
+
const workel_task_comments_1 = require("./workel_task_comments");
|
|
36
|
+
const workel_events_1 = require("./workel_events");
|
|
37
|
+
exports.READ_TOOLS = [
|
|
38
|
+
workel_whoami_1.workelWhoami,
|
|
39
|
+
workel_projects_1.workelListProjects,
|
|
40
|
+
workel_projects_1.workelGetProject,
|
|
41
|
+
workel_project_columns_1.workelListProjectColumns,
|
|
42
|
+
workel_members_1.workelListMembers,
|
|
43
|
+
workel_tasks_1.workelListTasks,
|
|
44
|
+
workel_tasks_1.workelGetTask,
|
|
45
|
+
workel_task_comments_1.workelListTaskComments,
|
|
46
|
+
workel_events_1.workelListEvents,
|
|
47
|
+
];
|
|
48
|
+
__exportStar(require("./conventions"), exports);
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;AAGH,mDAA+C;AAC/C,uDAAyE;AACzE,qEAAoE;AACpE,qDAAqD;AACrD,iDAAgE;AAChE,iEAAgE;AAChE,mDAAmD;AAEtC,QAAA,UAAU,GAAkB;IACvC,4BAAY;IACZ,oCAAkB;IAClB,kCAAgB;IAChB,iDAAwB;IACxB,kCAAiB;IACjB,8BAAe;IACf,4BAAa;IACb,6CAAsB;IACtB,gCAAgB;CACjB,CAAC;AAEF,gDAA8B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The D5 double opt-in gate for write tools (docs/MCP_SERVER_PLAN.md §3,
|
|
3
|
+
* "D5 — Read-only by default; writes are a double opt-in"):
|
|
4
|
+
*
|
|
5
|
+
* Write tools register only when (a) the key actually holds a write scope
|
|
6
|
+
* (discovered via `GET /me` at boot) AND (b) `WORKEL_ENABLE_WRITES=true` is
|
|
7
|
+
* set. Scope-gating is UX (don't offer tools that would 403); the env flag
|
|
8
|
+
* is the local operator's explicit consent; the API's scopes remain the
|
|
9
|
+
* real boundary.
|
|
10
|
+
*
|
|
11
|
+
* This module extends the existing registration seam rather than adding a
|
|
12
|
+
* parallel one: `buildServer` (`../server.ts`) already, unconditionally,
|
|
13
|
+
* filters every tool it's handed down to `descriptor.scope === undefined ||
|
|
14
|
+
* caps.scopes.includes(descriptor.scope)` — that is gate (a), and it applies
|
|
15
|
+
* identically to every tool, read or write, with no change needed here.
|
|
16
|
+
* Gate (b) has nowhere else to live: it is orthogonal to scope and
|
|
17
|
+
* `buildServer` is deliberately not editable to learn about it (`server.ts`
|
|
18
|
+
* doc: "no environment... access here"). So this module supplies gate (b) as
|
|
19
|
+
* a pure pre-filter on WHICH factories ever reach `buildServer` at all —
|
|
20
|
+
* `registeredWriteTools(false)` returns an empty array, so a write tool with
|
|
21
|
+
* the flag off is never even instantiated, let alone scope-checked. With the
|
|
22
|
+
* flag on, the write factories flow into `buildServer` exactly like any read
|
|
23
|
+
* tool, and gate (a) — already correct, already tested (`server.test.ts`) —
|
|
24
|
+
* decides the rest. The combined per-tool registration predicate is
|
|
25
|
+
* therefore exactly `scopes.includes(descriptor.scope) && writesEnabled`,
|
|
26
|
+
* split across the two gates rather than duplicated in one new function.
|
|
27
|
+
*
|
|
28
|
+
* `writesEnabledFromEnv` takes an env map (default `process.env`) rather
|
|
29
|
+
* than reading `WORKEL_ENABLE_WRITES` internally with no way to override it
|
|
30
|
+
* — the same injection shape `config.ts`'s own `loadConfig(env)` uses — so a
|
|
31
|
+
* caller with an already-resolved boolean (a future `boot.ts` wiring that
|
|
32
|
+
* already ran `loadConfig` and has `config.enableWrites` in hand) can pass
|
|
33
|
+
* that straight to `registeredWriteTools` instead, and every test here can
|
|
34
|
+
* exercise a synthetic env object without ever touching the real
|
|
35
|
+
* environment.
|
|
36
|
+
*/
|
|
37
|
+
import type { ToolFactory } from './defineTool';
|
|
38
|
+
/**
|
|
39
|
+
* Every write tool this server can ever expose — the write-side counterpart
|
|
40
|
+
* of `./index`'s `READ_TOOLS`. Not every entry shares one scope:
|
|
41
|
+
* `workelCreateTask`/`workelUpdateTask` declare `write:tasks`,
|
|
42
|
+
* `workelCreateTaskComment` declares `write:comments`, and `workelCreateEvent`
|
|
43
|
+
* declares `write:events` — each tool's own `scope` (not membership in this
|
|
44
|
+
* array) is what `buildServer`'s gate (a) checks per caller (`../server.ts`).
|
|
45
|
+
*/
|
|
46
|
+
export declare const WRITE_TOOLS: ToolFactory[];
|
|
47
|
+
export declare function writesEnabledFromEnv(env?: NodeJS.ProcessEnv): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Gate (b) of D5, applied. `writesEnabled` defaults to reading the real
|
|
50
|
+
* environment so a caller with nothing more specific in hand still gets
|
|
51
|
+
* correct behavior, but a caller that already has a resolved boolean (from
|
|
52
|
+
* `loadConfig`, or a test) should pass it explicitly rather than relying on
|
|
53
|
+
* this default re-deriving it from `process.env` a second time.
|
|
54
|
+
*
|
|
55
|
+
* Returns `WRITE_TOOLS` unchanged when `writesEnabled` is true — every
|
|
56
|
+
* factory still has to clear gate (a) (its own `scope` against the caller's
|
|
57
|
+
* `caps.scopes`) inside `buildServer` before it is actually registered.
|
|
58
|
+
* Returns an empty array when `writesEnabled` is false, regardless of what
|
|
59
|
+
* scopes the caller carries — a write tool is never even handed to
|
|
60
|
+
* `buildServer` in that case, so no scope on earth can register it.
|
|
61
|
+
*/
|
|
62
|
+
export declare function registeredWriteTools(writesEnabled?: boolean): ToolFactory[];
|
|
63
|
+
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../src/tools/registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,EAKpC,CAAC;AAkBF,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAElF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,GAAE,OAAgC,GAAG,WAAW,EAAE,CAEnG"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The D5 double opt-in gate for write tools (docs/MCP_SERVER_PLAN.md §3,
|
|
4
|
+
* "D5 — Read-only by default; writes are a double opt-in"):
|
|
5
|
+
*
|
|
6
|
+
* Write tools register only when (a) the key actually holds a write scope
|
|
7
|
+
* (discovered via `GET /me` at boot) AND (b) `WORKEL_ENABLE_WRITES=true` is
|
|
8
|
+
* set. Scope-gating is UX (don't offer tools that would 403); the env flag
|
|
9
|
+
* is the local operator's explicit consent; the API's scopes remain the
|
|
10
|
+
* real boundary.
|
|
11
|
+
*
|
|
12
|
+
* This module extends the existing registration seam rather than adding a
|
|
13
|
+
* parallel one: `buildServer` (`../server.ts`) already, unconditionally,
|
|
14
|
+
* filters every tool it's handed down to `descriptor.scope === undefined ||
|
|
15
|
+
* caps.scopes.includes(descriptor.scope)` — that is gate (a), and it applies
|
|
16
|
+
* identically to every tool, read or write, with no change needed here.
|
|
17
|
+
* Gate (b) has nowhere else to live: it is orthogonal to scope and
|
|
18
|
+
* `buildServer` is deliberately not editable to learn about it (`server.ts`
|
|
19
|
+
* doc: "no environment... access here"). So this module supplies gate (b) as
|
|
20
|
+
* a pure pre-filter on WHICH factories ever reach `buildServer` at all —
|
|
21
|
+
* `registeredWriteTools(false)` returns an empty array, so a write tool with
|
|
22
|
+
* the flag off is never even instantiated, let alone scope-checked. With the
|
|
23
|
+
* flag on, the write factories flow into `buildServer` exactly like any read
|
|
24
|
+
* tool, and gate (a) — already correct, already tested (`server.test.ts`) —
|
|
25
|
+
* decides the rest. The combined per-tool registration predicate is
|
|
26
|
+
* therefore exactly `scopes.includes(descriptor.scope) && writesEnabled`,
|
|
27
|
+
* split across the two gates rather than duplicated in one new function.
|
|
28
|
+
*
|
|
29
|
+
* `writesEnabledFromEnv` takes an env map (default `process.env`) rather
|
|
30
|
+
* than reading `WORKEL_ENABLE_WRITES` internally with no way to override it
|
|
31
|
+
* — the same injection shape `config.ts`'s own `loadConfig(env)` uses — so a
|
|
32
|
+
* caller with an already-resolved boolean (a future `boot.ts` wiring that
|
|
33
|
+
* already ran `loadConfig` and has `config.enableWrites` in hand) can pass
|
|
34
|
+
* that straight to `registeredWriteTools` instead, and every test here can
|
|
35
|
+
* exercise a synthetic env object without ever touching the real
|
|
36
|
+
* environment.
|
|
37
|
+
*/
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.WRITE_TOOLS = void 0;
|
|
40
|
+
exports.writesEnabledFromEnv = writesEnabledFromEnv;
|
|
41
|
+
exports.registeredWriteTools = registeredWriteTools;
|
|
42
|
+
const createTask_1 = require("./createTask");
|
|
43
|
+
const updateTask_1 = require("./updateTask");
|
|
44
|
+
const createComment_1 = require("./createComment");
|
|
45
|
+
const createEvent_1 = require("./createEvent");
|
|
46
|
+
/**
|
|
47
|
+
* Every write tool this server can ever expose — the write-side counterpart
|
|
48
|
+
* of `./index`'s `READ_TOOLS`. Not every entry shares one scope:
|
|
49
|
+
* `workelCreateTask`/`workelUpdateTask` declare `write:tasks`,
|
|
50
|
+
* `workelCreateTaskComment` declares `write:comments`, and `workelCreateEvent`
|
|
51
|
+
* declares `write:events` — each tool's own `scope` (not membership in this
|
|
52
|
+
* array) is what `buildServer`'s gate (a) checks per caller (`../server.ts`).
|
|
53
|
+
*/
|
|
54
|
+
exports.WRITE_TOOLS = [
|
|
55
|
+
createTask_1.workelCreateTask,
|
|
56
|
+
updateTask_1.workelUpdateTask,
|
|
57
|
+
createComment_1.workelCreateTaskComment,
|
|
58
|
+
createEvent_1.workelCreateEvent,
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* Parses `WORKEL_ENABLE_WRITES` with EXACTLY `config.ts`'s own (unexported)
|
|
62
|
+
* `parseBooleanFlag` semantics: case-insensitive match against the literal
|
|
63
|
+
* string `"true"`, no trimming. Duplicated rather than imported because
|
|
64
|
+
* `config.ts` does not export it — but the semantics must never drift from
|
|
65
|
+
* it regardless: `loadConfig(env).enableWrites` and
|
|
66
|
+
* `writesEnabledFromEnv(env)` are two readings of the SAME env var, and a
|
|
67
|
+
* value they disagreed on (e.g. `"TRUE "` with a trailing space — `false` in
|
|
68
|
+
* both, since neither trims) would mean this gate and `config.ts`'s own
|
|
69
|
+
* parsed `Config.enableWrites` field could tell two different stories about
|
|
70
|
+
* whether writes are enabled.
|
|
71
|
+
*/
|
|
72
|
+
function parseWritesEnabledFlag(value) {
|
|
73
|
+
return value !== undefined && value.toLowerCase() === 'true';
|
|
74
|
+
}
|
|
75
|
+
function writesEnabledFromEnv(env = process.env) {
|
|
76
|
+
return parseWritesEnabledFlag(env.WORKEL_ENABLE_WRITES);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gate (b) of D5, applied. `writesEnabled` defaults to reading the real
|
|
80
|
+
* environment so a caller with nothing more specific in hand still gets
|
|
81
|
+
* correct behavior, but a caller that already has a resolved boolean (from
|
|
82
|
+
* `loadConfig`, or a test) should pass it explicitly rather than relying on
|
|
83
|
+
* this default re-deriving it from `process.env` a second time.
|
|
84
|
+
*
|
|
85
|
+
* Returns `WRITE_TOOLS` unchanged when `writesEnabled` is true — every
|
|
86
|
+
* factory still has to clear gate (a) (its own `scope` against the caller's
|
|
87
|
+
* `caps.scopes`) inside `buildServer` before it is actually registered.
|
|
88
|
+
* Returns an empty array when `writesEnabled` is false, regardless of what
|
|
89
|
+
* scopes the caller carries — a write tool is never even handed to
|
|
90
|
+
* `buildServer` in that case, so no scope on earth can register it.
|
|
91
|
+
*/
|
|
92
|
+
function registeredWriteTools(writesEnabled = writesEnabledFromEnv()) {
|
|
93
|
+
return writesEnabled ? exports.WRITE_TOOLS : [];
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/tools/registration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAuCH,oDAEC;AAgBD,oDAEC;AAzDD,6CAAgD;AAChD,6CAAgD;AAChD,mDAA0D;AAC1D,+CAAkD;AAGlD;;;;;;;GAOG;AACU,QAAA,WAAW,GAAkB;IACxC,6BAAgB;IAChB,6BAAgB;IAChB,uCAAuB;IACvB,+BAAiB;CAClB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,SAAS,sBAAsB,CAAC,KAAyB;IACvD,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;AAC/D,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvE,OAAO,sBAAsB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,oBAAoB,CAAC,gBAAyB,oBAAoB,EAAE;IAClF,OAAO,aAAa,CAAC,CAAC,CAAC,mBAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `workel_update_task` — `PATCH /tasks/{id}` (`write:tasks` scope).
|
|
3
|
+
*
|
|
4
|
+
* Registered only under the D5 double opt-in gate (`./registration.ts`);
|
|
5
|
+
* this module only declares `scope: 'write:tasks'`.
|
|
6
|
+
*
|
|
7
|
+
* PATCH semantics (verified against `UpdatePublicTaskRequest` and
|
|
8
|
+
* `TaskUpdateService`, backend/services/laravel-backend/app/{Http/Requests/PublicApi/V1/UpdatePublicTaskRequest,Services/TaskUpdateService}.php):
|
|
9
|
+
* a field OMITTED from the call is left untouched on the server; a field
|
|
10
|
+
* EXPLICITLY given as `null` clears it (e.g. `due_date: null` clears the due
|
|
11
|
+
* date, and the server's own orphan cleanup then also clears `due_time` if
|
|
12
|
+
* it was set — TaskUpdateService.php:72-77 — since a time with no day makes
|
|
13
|
+
* no sense). This tool builds the PATCH body by explicit
|
|
14
|
+
* `hasOwnProperty`-based presence check, one field at a time, rather than by
|
|
15
|
+
* dot-accessing a possibly-absent field into a new object literal — the
|
|
16
|
+
* latter would fabricate an `undefined` value for every omitted field, which
|
|
17
|
+
* only looks correct by accident (JSON.stringify happens to drop `undefined`
|
|
18
|
+
* values) rather than because the field was ever actually treated as absent.
|
|
19
|
+
* The wire rename itself (`title` -> `title_text`, `due_date` -> `end_date`,
|
|
20
|
+
* `due_time` -> `end_time`) happens ONLY in `../api/mapping.ts`'s
|
|
21
|
+
* `mapUpdateTaskToWire` — never re-implemented here.
|
|
22
|
+
*
|
|
23
|
+
* This tool CANNOT move a task between columns or projects, and CANNOT
|
|
24
|
+
* change its assignees: `card_id`, `project_id`, and `user_ids` are not
|
|
25
|
+
* declared by `UpdatePublicTaskRequest::rules()` at all, so there is no wire
|
|
26
|
+
* field to forward them through even if this tool's input schema offered
|
|
27
|
+
* them — moving/reassigning a task is a different endpoint's job, not yet
|
|
28
|
+
* exposed as a tool. `reminder_date` is likewise never exposed here even
|
|
29
|
+
* though the wire endpoint accepts it — see `../api/mapping.ts`'s
|
|
30
|
+
* file-level docblock (it is write-only over this API; there is no read
|
|
31
|
+
* endpoint that ever returns it, so exposing a field a caller can set but
|
|
32
|
+
* never read back would break read/write symmetry).
|
|
33
|
+
*
|
|
34
|
+
* IMPORTANT capability note, verified directly against
|
|
35
|
+
* `TasksController::update` vs. `TasksController::store`
|
|
36
|
+
* (backend/services/laravel-backend/app/Http/Controllers/Api/PublicApi/V1/TasksController.php):
|
|
37
|
+
* unlike `POST /tasks` — which requires `Permission::TASK_CREATE` on the
|
|
38
|
+
* TARGET project before creating (TasksController.php:244-252) —
|
|
39
|
+
* `PATCH /tasks/{id}` (TasksController.php:120-154) performs NO per-project
|
|
40
|
+
* permission re-check at all. It only re-resolves the task through the same
|
|
41
|
+
* visible-project chain `GET /tasks/{id}` already uses (bound workspace, not
|
|
42
|
+
* archived, not private, not the inbox project — `ChecksProjectVisibility`)
|
|
43
|
+
* — visibility, not project membership or role. A `write:tasks` key can
|
|
44
|
+
* therefore update ANY task in ANY visible project in its own workspace,
|
|
45
|
+
* regardless of whether the key's creator has any role or membership on
|
|
46
|
+
* that specific project — a `write:tasks` key is workspace-wide for
|
|
47
|
+
* updates, unlike task creation, which is project-scoped by the
|
|
48
|
+
* `TASK_CREATE` permission check above. This is a real capability shape of
|
|
49
|
+
* the underlying API, not something this tool works around.
|
|
50
|
+
*/
|
|
51
|
+
import { type ToolFactory } from './defineTool';
|
|
52
|
+
export declare const workelUpdateTask: ToolFactory;
|
|
53
|
+
//# sourceMappingURL=updateTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateTask.d.ts","sourceRoot":"","sources":["../../src/tools/updateTask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAKH,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAiC5D,eAAO,MAAM,gBAAgB,EAAE,WA0C3B,CAAC"}
|