@doist/todoist-ai 4.17.0 → 4.17.1

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 (63) hide show
  1. package/dist/filter-helpers.d.ts +1 -1
  2. package/dist/filter-helpers.d.ts.map +1 -1
  3. package/dist/index.d.ts +117 -386
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2 -2
  6. package/dist/main.js +1 -1
  7. package/dist/mcp-helpers.d.ts +1 -37
  8. package/dist/mcp-helpers.d.ts.map +1 -1
  9. package/dist/{mcp-server-BADReNAy.js → mcp-server-BMGcSL1c.js} +926 -960
  10. package/dist/todoist-tool.d.ts +6 -2
  11. package/dist/todoist-tool.d.ts.map +1 -1
  12. package/dist/tool-helpers.d.ts +20 -18
  13. package/dist/tool-helpers.d.ts.map +1 -1
  14. package/dist/tools/add-comments.d.ts +1 -15
  15. package/dist/tools/add-comments.d.ts.map +1 -1
  16. package/dist/tools/add-projects.d.ts +5 -17
  17. package/dist/tools/add-projects.d.ts.map +1 -1
  18. package/dist/tools/add-sections.d.ts +1 -15
  19. package/dist/tools/add-sections.d.ts.map +1 -1
  20. package/dist/tools/add-tasks.d.ts +7 -21
  21. package/dist/tools/add-tasks.d.ts.map +1 -1
  22. package/dist/tools/complete-tasks.d.ts +1 -15
  23. package/dist/tools/complete-tasks.d.ts.map +1 -1
  24. package/dist/tools/delete-object.d.ts +2 -16
  25. package/dist/tools/delete-object.d.ts.map +1 -1
  26. package/dist/tools/fetch.d.ts +3 -8
  27. package/dist/tools/fetch.d.ts.map +1 -1
  28. package/dist/tools/find-activity.d.ts +13 -27
  29. package/dist/tools/find-activity.d.ts.map +1 -1
  30. package/dist/tools/find-comments.d.ts +2 -16
  31. package/dist/tools/find-comments.d.ts.map +1 -1
  32. package/dist/tools/find-completed-tasks.d.ts +8 -22
  33. package/dist/tools/find-completed-tasks.d.ts.map +1 -1
  34. package/dist/tools/find-project-collaborators.d.ts +20 -20
  35. package/dist/tools/find-project-collaborators.d.ts.map +1 -1
  36. package/dist/tools/find-projects.d.ts +3 -17
  37. package/dist/tools/find-projects.d.ts.map +1 -1
  38. package/dist/tools/find-sections.d.ts +1 -15
  39. package/dist/tools/find-sections.d.ts.map +1 -1
  40. package/dist/tools/find-tasks-by-date.d.ts +8 -22
  41. package/dist/tools/find-tasks-by-date.d.ts.map +1 -1
  42. package/dist/tools/find-tasks.d.ts +8 -22
  43. package/dist/tools/find-tasks.d.ts.map +1 -1
  44. package/dist/tools/get-overview.d.ts +9 -16
  45. package/dist/tools/get-overview.d.ts.map +1 -1
  46. package/dist/tools/manage-assignments.d.ts +5 -19
  47. package/dist/tools/manage-assignments.d.ts.map +1 -1
  48. package/dist/tools/search.d.ts +11 -7
  49. package/dist/tools/search.d.ts.map +1 -1
  50. package/dist/tools/update-comments.d.ts +1 -15
  51. package/dist/tools/update-comments.d.ts.map +1 -1
  52. package/dist/tools/update-projects.d.ts +5 -17
  53. package/dist/tools/update-projects.d.ts.map +1 -1
  54. package/dist/tools/update-sections.d.ts +1 -15
  55. package/dist/tools/update-sections.d.ts.map +1 -1
  56. package/dist/tools/update-tasks.d.ts +7 -21
  57. package/dist/tools/update-tasks.d.ts.map +1 -1
  58. package/dist/tools/user-info.d.ts +1 -15
  59. package/dist/tools/user-info.d.ts.map +1 -1
  60. package/dist/utils/output-schemas.d.ts +6 -6
  61. package/dist/utils/test-helpers.d.ts +1 -33
  62. package/dist/utils/test-helpers.d.ts.map +1 -1
  63. package/package.json +13 -13
@@ -1,7 +1,7 @@
1
- import { getTaskUrl as he, getProjectUrl as me, TodoistApi as xe } from "@doist/todoist-api-typescript";
2
- import { McpServer as Ae } from "@modelcontextprotocol/sdk/server/mcp.js";
1
+ import { getTaskUrl as pe, getProjectUrl as he, TodoistApi as Se } from "@doist/todoist-api-typescript";
2
+ import { McpServer as De } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import F, { z as s } from "zod";
4
- import { addDays as fe, formatISO as Ue } from "date-fns";
4
+ import { addDays as me, formatISO as xe } from "date-fns";
5
5
  function X(e) {
6
6
  if (e == null)
7
7
  return e;
@@ -20,42 +20,40 @@ function X(e) {
20
20
  }
21
21
  return e;
22
22
  }
23
- const Pe = process.env.USE_STRUCTURED_CONTENT === "true" || process.env.NODE_ENV === "test";
24
- function T({
23
+ const Ae = process.env.USE_STRUCTURED_CONTENT === "true" || process.env.NODE_ENV === "test";
24
+ function Ue({
25
25
  textContent: e,
26
26
  structuredContent: t
27
27
  }) {
28
- const o = X(t);
29
- if (Pe)
30
- return {
31
- content: [{ type: "text", text: e }],
32
- structuredContent: o
33
- };
34
- const n = JSON.stringify(o);
35
- return {
36
- content: [
37
- { type: "text", text: e },
38
- { type: "text", mimeType: "application/json", text: n }
39
- ]
40
- };
28
+ const o = X(t), n = {};
29
+ if (e && (n.content = [{ type: "text", text: e }]), t && (n.structuredContent = o), !Ae && t) {
30
+ const r = JSON.stringify(o);
31
+ n.content || (n.content = []), n.content.push({
32
+ type: "text",
33
+ mimeType: "application/json",
34
+ text: r
35
+ });
36
+ }
37
+ return n;
41
38
  }
42
- function Q(e) {
39
+ function Pe(e) {
43
40
  return {
44
41
  content: [{ type: "text", text: e }],
45
42
  isError: !0
46
43
  };
47
44
  }
48
- function w(e, t, o) {
45
+ function I(e, t, o) {
49
46
  const n = async (r, i) => {
50
47
  try {
51
- return await e.execute(r, o);
52
- } catch (a) {
53
- console.error(`Error executing tool ${e.name}:`, {
54
- args: r,
55
- error: a
56
- });
57
- const c = a instanceof Error ? a.message : "An unknown error occurred";
58
- return Q(c);
48
+ const { textContent: c, structuredContent: a } = await e.execute(
49
+ r,
50
+ o
51
+ );
52
+ return Ue({ textContent: c, structuredContent: a });
53
+ } catch (c) {
54
+ console.error(`Error executing tool ${e.name}:`, { args: r, error: c });
55
+ const a = c instanceof Error ? c.message : "An unknown error occurred";
56
+ return Pe(a);
59
57
  }
60
58
  };
61
59
  t.registerTool(
@@ -85,7 +83,7 @@ const W = s.object({
85
83
  assignedByUid: s.string().optional().describe("The UID of the user who assigned this task."),
86
84
  checked: s.boolean().describe("Whether the task is checked/completed."),
87
85
  completedAt: s.string().optional().describe("When the task was completed (ISO 8601 format).")
88
- }), ee = s.object({
86
+ }), Q = s.object({
89
87
  id: s.string().describe("The unique ID of the project."),
90
88
  name: s.string().describe("The name of the project."),
91
89
  color: s.string().describe("The color of the project."),
@@ -94,7 +92,7 @@ const W = s.object({
94
92
  parentId: s.string().optional().describe("The ID of the parent project (for sub-projects)."),
95
93
  inboxProject: s.boolean().describe("Whether this is the inbox project."),
96
94
  viewStyle: s.string().describe("The view style of the project (list, board, calendar).")
97
- }), te = s.object({
95
+ }), ee = s.object({
98
96
  id: s.string().describe("The unique ID of the section."),
99
97
  name: s.string().describe("The name of the section.")
100
98
  }), Ee = s.object({
@@ -105,7 +103,7 @@ const W = s.object({
105
103
  fileUrl: s.string().optional().describe("The URL to access the file."),
106
104
  fileDuration: s.number().optional().describe("The duration in milliseconds (for audio/video files)."),
107
105
  uploadState: s.enum(["pending", "completed"]).optional().describe("The upload state of the file.")
108
- }), se = s.object({
106
+ }), te = s.object({
109
107
  id: s.string().describe("The unique ID of the comment."),
110
108
  taskId: s.string().optional().describe("The ID of the task this comment belongs to."),
111
109
  projectId: s.string().optional().describe("The ID of the project this comment belongs to."),
@@ -113,7 +111,7 @@ const W = s.object({
113
111
  postedAt: s.string().describe("When the comment was posted (ISO 8601 format)."),
114
112
  attachment: Ee.optional().describe("File attachment information, if any.")
115
113
  }), Oe = s.object({
116
- id: s.string().describe("The unique ID of the activity event."),
114
+ id: s.string().optional().describe("The unique ID of the activity event."),
117
115
  objectType: s.string().describe("The type of object this event relates to (task, project, etc)."),
118
116
  objectId: s.string().describe("The ID of the object this event relates to."),
119
117
  eventType: s.string().describe("The type of event (added, updated, deleted, completed, etc)."),
@@ -121,7 +119,7 @@ const W = s.object({
121
119
  parentProjectId: s.string().optional().describe("The ID of the parent project."),
122
120
  parentItemId: s.string().optional().describe("The ID of the parent item."),
123
121
  initiatorId: s.string().optional().describe("The ID of the user who initiated this event."),
124
- extraData: s.record(s.unknown()).describe("Additional event data.")
122
+ extraData: s.record(s.unknown()).optional().describe("Additional event data.")
125
123
  }), _e = s.object({
126
124
  id: s.string().describe("The unique ID of the user."),
127
125
  name: s.string().describe("The full name of the user."),
@@ -130,7 +128,7 @@ const W = s.object({
130
128
  item: s.string().describe("The item that failed (usually an ID or identifier)."),
131
129
  error: s.string().describe("The error message."),
132
130
  code: s.string().optional().describe("The error code, if available.")
133
- }), y = {
131
+ }), g = {
134
132
  // Task management tools
135
133
  ADD_TASKS: "add-tasks",
136
134
  COMPLETE_TASKS: "complete-tasks",
@@ -171,11 +169,11 @@ const W = s.object({
171
169
  }), Fe = {
172
170
  comments: s.array(Me).min(1).describe("The array of comments to add.")
173
171
  }, Re = {
174
- comments: s.array(se).describe("The created comments."),
172
+ comments: s.array(te).describe("The created comments."),
175
173
  totalCount: s.number().describe("The total number of comments created."),
176
174
  addedCommentIds: s.array(s.string()).describe("The IDs of the added comments.")
177
175
  }, Le = {
178
- name: y.ADD_COMMENTS,
176
+ name: g.ADD_COMMENTS,
179
177
  description: "Add multiple comments to tasks or projects. Each comment must specify either taskId or projectId.",
180
178
  parameters: Fe,
181
179
  outputSchema: Re,
@@ -197,15 +195,15 @@ const W = s.object({
197
195
  content: d,
198
196
  ...l ? { taskId: l } : { projectId: p }
199
197
  });
200
- }), a = await Promise.all(i), c = Be({ comments: a });
201
- return T({
202
- textContent: c,
198
+ }), c = await Promise.all(i);
199
+ return {
200
+ textContent: Be({ comments: c }),
203
201
  structuredContent: {
204
- comments: a,
205
- totalCount: a.length,
206
- addedCommentIds: a.map((d) => d.id)
202
+ comments: c,
203
+ totalCount: c.length,
204
+ addedCommentIds: c.map((d) => d.id)
207
205
  }
208
- });
206
+ };
209
207
  }
210
208
  };
211
209
  function Be({ comments: e }) {
@@ -228,22 +226,26 @@ const We = s.object({
228
226
  }), Ye = {
229
227
  projects: s.array(We).min(1).describe("The array of projects to add.")
230
228
  }, Ke = {
231
- projects: s.array(ee).describe("The created projects."),
229
+ projects: s.array(Q).describe("The created projects."),
232
230
  totalCount: s.number().describe("The total number of projects created.")
233
231
  }, ze = {
234
- name: y.ADD_PROJECTS,
232
+ name: g.ADD_PROJECTS,
235
233
  description: "Add one or more new projects.",
236
234
  parameters: Ye,
237
235
  outputSchema: Ke,
238
236
  async execute({ projects: e }, t) {
239
- const o = await Promise.all(e.map((r) => t.addProject(r))), n = Ve({ projects: o });
240
- return T({
237
+ const o = await Promise.all(e.map((i) => t.addProject(i))), n = Ve({ projects: o }), r = o.map((i) => ({
238
+ ...i,
239
+ parentId: "parentId" in i ? i.parentId ?? void 0 : void 0,
240
+ inboxProject: "inboxProject" in i ? i.inboxProject : !1
241
+ }));
242
+ return {
241
243
  textContent: n,
242
244
  structuredContent: {
243
- projects: o,
244
- totalCount: o.length
245
+ projects: r,
246
+ totalCount: r.length
245
247
  }
246
- });
248
+ };
247
249
  }
248
250
  };
249
251
  function Ve({ projects: e }) {
@@ -260,27 +262,27 @@ const He = s.object({
260
262
  }), Ge = {
261
263
  sections: s.array(He).min(1).describe("The array of sections to add.")
262
264
  }, qe = {
263
- sections: s.array(te).describe("The created sections."),
265
+ sections: s.array(ee).describe("The created sections."),
264
266
  totalCount: s.number().describe("The total number of sections created.")
265
267
  }, Je = {
266
- name: y.ADD_SECTIONS,
268
+ name: g.ADD_SECTIONS,
267
269
  description: "Add one or more new sections to projects.",
268
270
  parameters: Ge,
269
271
  outputSchema: qe,
270
272
  async execute({ sections: e }, t) {
271
- const n = e.some((c) => c.projectId === "inbox") ? await t.getUser() : null, r = e.map((c) => ({
272
- ...c,
273
- projectId: c.projectId === "inbox" && n ? n.inboxProjectId : c.projectId
273
+ const n = e.some((a) => a.projectId === "inbox") ? await t.getUser() : null, r = e.map((a) => ({
274
+ ...a,
275
+ projectId: a.projectId === "inbox" && n ? n.inboxProjectId : a.projectId
274
276
  })), i = await Promise.all(
275
- r.map((c) => t.addSection(c))
276
- ), a = Xe({ sections: i });
277
- return T({
278
- textContent: a,
277
+ r.map((a) => t.addSection(a))
278
+ );
279
+ return {
280
+ textContent: Xe({ sections: i }),
279
281
  structuredContent: {
280
282
  sections: i,
281
283
  totalCount: i.length
282
284
  }
283
- });
285
+ };
284
286
  }
285
287
  };
286
288
  function Xe({ sections: e }) {
@@ -289,43 +291,43 @@ function Xe({ sections: e }) {
289
291
  return `Added ${t} section${t === 1 ? "" : "s"}:
290
292
  ${o}`;
291
293
  }
292
- class P extends Error {
294
+ class U extends Error {
293
295
  constructor(t, o) {
294
296
  super(`Invalid duration format "${t}": ${o}`), this.name = "DurationParseError";
295
297
  }
296
298
  }
297
- function be(e) {
299
+ function fe(e) {
298
300
  if (!e || typeof e != "string")
299
- throw new P(e, "Duration must be a non-empty string");
301
+ throw new U(e, "Duration must be a non-empty string");
300
302
  const t = e.trim().toLowerCase().replace(/\s+/g, "");
301
303
  if (!t)
302
- throw new P(e, "Duration must be a non-empty string");
304
+ throw new U(e, "Duration must be a non-empty string");
303
305
  const o = t.match(/^(?:(\d+(?:\.\d+)?)h)?(?:(\d+(?:\.\d+)?)m)?$/);
304
306
  if (!o || !o[1] && !o[2])
305
- throw new P(e, 'Use format like "2h", "30m", "2h30m", or "1.5h"');
307
+ throw new U(e, 'Use format like "2h", "30m", "2h30m", or "1.5h"');
306
308
  let n = 0;
307
309
  const [, r, i] = o;
308
310
  if (r) {
309
- const a = Number.parseFloat(r);
310
- if (Number.isNaN(a) || a < 0)
311
- throw new P(e, "Hours must be a positive number");
312
- n += a * 60;
311
+ const c = Number.parseFloat(r);
312
+ if (Number.isNaN(c) || c < 0)
313
+ throw new U(e, "Hours must be a positive number");
314
+ n += c * 60;
313
315
  }
314
316
  if (i) {
315
- const a = Number.parseFloat(i);
316
- if (Number.isNaN(a) || a < 0)
317
- throw new P(e, "Minutes must be a positive number");
318
- if (a % 1 !== 0)
319
- throw new P(
317
+ const c = Number.parseFloat(i);
318
+ if (Number.isNaN(c) || c < 0)
319
+ throw new U(e, "Minutes must be a positive number");
320
+ if (c % 1 !== 0)
321
+ throw new U(
320
322
  e,
321
323
  "Minutes must be a whole number (use decimal hours instead)"
322
324
  );
323
- n += a;
325
+ n += c;
324
326
  }
325
327
  if (n = Math.round(n), n === 0)
326
- throw new P(e, "Duration must be greater than 0 minutes");
328
+ throw new U(e, "Duration must be greater than 0 minutes");
327
329
  if (n > 1440)
328
- throw new P(e, "Duration cannot exceed 24 hours (1440 minutes)");
330
+ throw new U(e, "Duration cannot exceed 24 hours (1440 minutes)");
329
331
  return { minutes: n };
330
332
  }
331
333
  function Ze(e) {
@@ -333,7 +335,7 @@ function Ze(e) {
333
335
  const t = Math.floor(e / 60), o = e % 60;
334
336
  return t === 0 ? `${o}m` : o === 0 ? `${t}h` : `${t}h${o}m`;
335
337
  }
336
- const U = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map(), G = 300 * 1e3;
338
+ const A = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map(), G = 300 * 1e3;
337
339
  class Qe {
338
340
  /**
339
341
  * Resolve a user name or ID to a user ID by looking up collaborators across all shared projects.
@@ -342,39 +344,39 @@ class Qe {
342
344
  async resolveUser(t, o) {
343
345
  if (!o || o.trim().length === 0)
344
346
  return null;
345
- const n = o.trim(), r = U.get(n);
347
+ const n = o.trim(), r = A.get(n);
346
348
  if (r && Date.now() - r.timestamp < G)
347
349
  return r.result;
348
350
  if (/^[0-9]+$/.test(n) || /^[a-f0-9-]{8,}$/i.test(n) && n.includes("-") || /^[a-z0-9_]{6,}$/i.test(n) && !/^[a-z]+[\s-]/.test(n) && /[0-9_]/.test(n)) {
349
351
  const i = { userId: n, displayName: n, email: n };
350
- return U.set(n, { result: i, timestamp: Date.now() }), i;
352
+ return A.set(n, { result: i, timestamp: Date.now() }), i;
351
353
  }
352
354
  try {
353
355
  const i = await this.getAllCollaborators(t);
354
356
  if (i.length === 0)
355
- return U.set(n, { result: null, timestamp: Date.now() }), null;
356
- const a = o.toLowerCase().trim();
357
- let c = i.find((l) => l.name.toLowerCase() === a);
358
- if (c) {
359
- const l = { userId: c.id, displayName: c.name, email: c.email };
360
- return U.set(n, { result: l, timestamp: Date.now() }), l;
357
+ return A.set(n, { result: null, timestamp: Date.now() }), null;
358
+ const c = o.toLowerCase().trim();
359
+ let a = i.find((l) => l.name.toLowerCase() === c);
360
+ if (a) {
361
+ const l = { userId: a.id, displayName: a.name, email: a.email };
362
+ return A.set(n, { result: l, timestamp: Date.now() }), l;
361
363
  }
362
- if (c = i.find((l) => l.email.toLowerCase() === a), c) {
363
- const l = { userId: c.id, displayName: c.name, email: c.email };
364
- return U.set(n, { result: l, timestamp: Date.now() }), l;
364
+ if (a = i.find((l) => l.email.toLowerCase() === c), a) {
365
+ const l = { userId: a.id, displayName: a.name, email: a.email };
366
+ return A.set(n, { result: l, timestamp: Date.now() }), l;
365
367
  }
366
- if (c = i.find((l) => l.name.toLowerCase().includes(a)), c) {
367
- const l = { userId: c.id, displayName: c.name, email: c.email };
368
- return U.set(n, { result: l, timestamp: Date.now() }), l;
368
+ if (a = i.find((l) => l.name.toLowerCase().includes(c)), a) {
369
+ const l = { userId: a.id, displayName: a.name, email: a.email };
370
+ return A.set(n, { result: l, timestamp: Date.now() }), l;
369
371
  }
370
- if (c = i.find((l) => l.email.toLowerCase().includes(a)), c) {
371
- const l = { userId: c.id, displayName: c.name, email: c.email };
372
- return U.set(n, { result: l, timestamp: Date.now() }), l;
372
+ if (a = i.find((l) => l.email.toLowerCase().includes(c)), a) {
373
+ const l = { userId: a.id, displayName: a.name, email: a.email };
374
+ return A.set(n, { result: l, timestamp: Date.now() }), l;
373
375
  }
374
376
  const d = null;
375
- return U.set(n, { result: d, timestamp: Date.now() }), d;
377
+ return A.set(n, { result: d, timestamp: Date.now() }), d;
376
378
  } catch {
377
- return U.set(n, { result: null, timestamp: Date.now() }), null;
379
+ return A.set(n, { result: null, timestamp: Date.now() }), null;
378
380
  }
379
381
  }
380
382
  /**
@@ -395,11 +397,11 @@ class Qe {
395
397
  if (r && Date.now() - r.timestamp < G)
396
398
  return r.result;
397
399
  try {
398
- const i = await t.getProjectCollaborators(o), c = (Array.isArray(i) ? i : i.results || []).filter((d) => d?.id && d.name && d.email);
400
+ const i = await t.getProjectCollaborators(o), a = (Array.isArray(i) ? i : i.results || []).filter((d) => d?.id && d.name && d.email);
399
401
  return R.set(n, {
400
- result: c,
402
+ result: a,
401
403
  timestamp: Date.now()
402
- }), c;
404
+ }), a;
403
405
  } catch {
404
406
  return [];
405
407
  }
@@ -417,17 +419,17 @@ class Qe {
417
419
  const u = [];
418
420
  return R.set(o, { result: u, timestamp: Date.now() }), u;
419
421
  }
420
- const a = [], c = /* @__PURE__ */ new Set(), d = i.map(
422
+ const c = [], a = /* @__PURE__ */ new Set(), d = i.map(
421
423
  (u) => this.getProjectCollaborators(t, u.id)
422
424
  ), l = await Promise.allSettled(d);
423
425
  for (const u of l)
424
426
  if (u.status === "fulfilled")
425
427
  for (const p of u.value)
426
- p && !c.has(p.id) && (a.push(p), c.add(p.id));
428
+ p && !a.has(p.id) && (c.push(p), a.add(p.id));
427
429
  return R.set(o, {
428
- result: a,
430
+ result: c,
429
431
  timestamp: Date.now()
430
- }), a;
432
+ }), c;
431
433
  } catch {
432
434
  return [];
433
435
  }
@@ -436,15 +438,15 @@ class Qe {
436
438
  * Clear all caches - useful for testing
437
439
  */
438
440
  clearCache() {
439
- U.clear(), R.clear();
441
+ A.clear(), R.clear();
440
442
  }
441
443
  }
442
444
  const _ = new Qe();
443
445
  async function et(e, t) {
444
446
  return _.resolveUser(e, t);
445
447
  }
446
- const ge = ["assigned", "unassignedOrMe", "all"];
447
- async function oe(e, t) {
448
+ const be = ["assigned", "unassignedOrMe", "all"];
449
+ async function se(e, t) {
448
450
  if (!t)
449
451
  return;
450
452
  const o = await et(e, t);
@@ -464,7 +466,7 @@ function tt({
464
466
  }) {
465
467
  return e && t ? `assigned to: ${t}` : o === "unassignedOrMe" ? "!assigned to: others" : o === "assigned" ? "assigned to: others" : "";
466
468
  }
467
- function ce({
469
+ function ae({
468
470
  tasks: e,
469
471
  resolvedAssigneeId: t,
470
472
  currentUserId: o,
@@ -500,39 +502,39 @@ function O(e) {
500
502
  deadlineDate: e.deadline?.date,
501
503
  priority: e.priority,
502
504
  projectId: e.projectId,
503
- sectionId: e.sectionId,
504
- parentId: e.parentId,
505
+ sectionId: e.sectionId ?? void 0,
506
+ parentId: e.parentId ?? void 0,
505
507
  labels: e.labels,
506
- duration: e.duration ? Ze(e.duration.amount) : null,
507
- responsibleUid: e.responsibleUid,
508
- assignedByUid: e.assignedByUid,
508
+ duration: e.duration ? Ze(e.duration.amount) : void 0,
509
+ responsibleUid: e.responsibleUid ?? void 0,
510
+ assignedByUid: e.assignedByUid ?? void 0,
509
511
  checked: e.checked,
510
- completedAt: e.completedAt
512
+ completedAt: e.completedAt ?? void 0
511
513
  };
512
514
  }
513
- function Te(e) {
515
+ function ge(e) {
514
516
  return {
515
517
  id: e.id,
516
518
  name: e.name,
517
519
  color: e.color,
518
520
  isFavorite: e.isFavorite,
519
521
  isShared: e.isShared,
520
- parentId: B(e) ? e.parentId ?? null : null,
522
+ parentId: B(e) ? e.parentId ?? void 0 : void 0,
521
523
  inboxProject: B(e) ? e.inboxProject ?? !1 : !1,
522
524
  viewStyle: e.viewStyle
523
525
  };
524
526
  }
525
527
  function ot(e) {
526
528
  return {
527
- id: e.id,
529
+ id: e.id ?? void 0,
528
530
  objectType: e.objectType,
529
531
  objectId: e.objectId,
530
532
  eventType: e.eventType,
531
533
  eventDate: e.eventDate,
532
- parentProjectId: e.parentProjectId,
533
- parentItemId: e.parentItemId,
534
- initiatorId: e.initiatorId,
535
- extraData: e.extraData
534
+ parentProjectId: e.parentProjectId ?? void 0,
535
+ parentItemId: e.parentItemId ?? void 0,
536
+ initiatorId: e.initiatorId ?? void 0,
537
+ extraData: e.extraData ?? void 0
536
538
  };
537
539
  }
538
540
  const nt = F.object({
@@ -543,7 +545,7 @@ const nt = F.object({
543
545
  errorTag: F.string()
544
546
  })
545
547
  });
546
- async function ne({
548
+ async function oe({
547
549
  client: e,
548
550
  query: t,
549
551
  limit: o,
@@ -556,9 +558,9 @@ async function ne({
556
558
  const i = nt.safeParse(r);
557
559
  if (!i.success)
558
560
  throw r;
559
- const { responseData: a } = i.data;
560
- throw a.errorTag === "INVALID_SEARCH_QUERY" ? new Error(`Invalid filter query: ${t}`) : new Error(
561
- `${a.error} (tag: ${a.errorTag}, code: ${a.errorCode})`
561
+ const { responseData: c } = i.data;
562
+ throw c.errorTag === "INVALID_SEARCH_QUERY" ? new Error(`Invalid filter query: ${t}`) : new Error(
563
+ `${c.error} (tag: ${c.errorTag}, code: ${c.errorCode})`
562
564
  );
563
565
  }
564
566
  }
@@ -576,8 +578,8 @@ class rt {
576
578
  * Validate a single assignment operation
577
579
  */
578
580
  async validateAssignment(t, o) {
579
- const { taskId: n, projectId: r, responsibleUid: i } = o, a = await _.resolveUser(t, i);
580
- if (!a)
581
+ const { taskId: n, projectId: r, responsibleUid: i } = o, c = await _.resolveUser(t, i);
582
+ if (!c)
581
583
  return {
582
584
  isValid: !1,
583
585
  taskId: n,
@@ -593,16 +595,16 @@ class rt {
593
595
  }
594
596
  };
595
597
  try {
596
- const c = await t.getProject(r);
597
- if (!c.isShared)
598
+ const a = await t.getProject(r);
599
+ if (!a.isShared)
598
600
  return {
599
601
  isValid: !1,
600
602
  taskId: n,
601
603
  projectId: r,
602
- resolvedUser: a,
604
+ resolvedUser: c,
603
605
  error: {
604
606
  type: L.PROJECT_NOT_SHARED,
605
- message: `Project "${c.name}" is not shared`,
607
+ message: `Project "${a.name}" is not shared`,
606
608
  suggestions: [
607
609
  "Share the project with collaborators before assigning tasks",
608
610
  "Only shared projects support task assignments"
@@ -612,16 +614,16 @@ class rt {
612
614
  if (!await _.validateProjectCollaborator(
613
615
  t,
614
616
  r,
615
- a.userId
617
+ c.userId
616
618
  ))
617
619
  return {
618
620
  isValid: !1,
619
621
  taskId: n,
620
622
  projectId: r,
621
- resolvedUser: a,
623
+ resolvedUser: c,
622
624
  error: {
623
625
  type: L.USER_NOT_COLLABORATOR,
624
- message: `User "${a.displayName}" is not a collaborator on project "${c.name}"`,
626
+ message: `User "${c.displayName}" is not a collaborator on project "${a.name}"`,
625
627
  suggestions: [
626
628
  "Invite the user to collaborate on this project first",
627
629
  "Check if the user has been removed from the project",
@@ -637,7 +639,7 @@ class rt {
637
639
  isValid: !1,
638
640
  taskId: n,
639
641
  projectId: r,
640
- resolvedUser: a,
642
+ resolvedUser: c,
641
643
  error: {
642
644
  type: L.TASK_NOT_FOUND,
643
645
  message: `Task "${n}" not found or not accessible`,
@@ -653,14 +655,14 @@ class rt {
653
655
  isValid: !0,
654
656
  taskId: n,
655
657
  projectId: r,
656
- resolvedUser: a
658
+ resolvedUser: c
657
659
  };
658
660
  } catch {
659
661
  return {
660
662
  isValid: !1,
661
663
  taskId: n,
662
664
  projectId: r,
663
- resolvedUser: a,
665
+ resolvedUser: c,
664
666
  error: {
665
667
  type: L.PERMISSION_DENIED,
666
668
  message: "Permission denied or API error occurred",
@@ -728,9 +730,9 @@ class rt {
728
730
  */
729
731
  async getAssignmentEligibility(t, o, n, r) {
730
732
  const i = [];
731
- let a = !1, c;
733
+ let c = !1, a;
732
734
  try {
733
- c = await t.getProject(o);
735
+ a = await t.getProject(o);
734
736
  } catch {
735
737
  return {
736
738
  canAssign: !1,
@@ -743,36 +745,36 @@ class rt {
743
745
  };
744
746
  }
745
747
  const d = await _.getProjectCollaborators(t, o), l = {
746
- name: c.name,
747
- isShared: c.isShared,
748
+ name: a.name,
749
+ isShared: a.isShared,
748
750
  collaboratorCount: d.length
749
751
  };
750
- if (!c.isShared)
752
+ if (!a.isShared)
751
753
  return i.push("Share this project to enable task assignments"), { canAssign: !1, projectInfo: l, recommendations: i };
752
754
  const u = await _.resolveUser(t, n);
753
755
  if (!u)
754
756
  return i.push("User not found - check spelling or invite to a shared project"), { canAssign: !1, projectInfo: l, recommendations: i };
755
- const p = d.some((k) => k.id === u.userId), b = {
757
+ const p = d.some((y) => y.id === u.userId), b = {
756
758
  resolvedName: u.displayName,
757
759
  isCollaborator: p
758
760
  };
759
761
  if (!p)
760
762
  return i.push(
761
- `Invite ${u.displayName} to collaborate on project "${c.name}"`
763
+ `Invite ${u.displayName} to collaborate on project "${a.name}"`
762
764
  ), { canAssign: !1, projectInfo: l, userInfo: b, recommendations: i };
763
765
  let m;
764
766
  if (r && r.length > 0) {
765
- let k = 0, j = 0;
766
- for (const S of r)
767
+ let y = 0, k = 0;
768
+ for (const w of r)
767
769
  try {
768
- await t.getTask(S), k++;
770
+ await t.getTask(w), y++;
769
771
  } catch {
770
- j++;
772
+ k++;
771
773
  }
772
- m = { accessibleTasks: k, inaccessibleTasks: j }, j > 0 && i.push(`${j} task(s) are not accessible`);
774
+ m = { accessibleTasks: y, inaccessibleTasks: k }, k > 0 && i.push(`${k} task(s) are not accessible`);
773
775
  }
774
- return a = !0, i.push(`Ready to assign tasks to ${u.displayName}`), {
775
- canAssign: a,
776
+ return c = !0, i.push(`Ready to assign tasks to ${u.displayName}`), {
777
+ canAssign: c,
776
778
  projectInfo: l,
777
779
  userInfo: b,
778
780
  taskInfo: m,
@@ -780,16 +782,16 @@ class rt {
780
782
  };
781
783
  }
782
784
  }
783
- const re = new rt(), it = ["p1", "p2", "p3", "p4"], ye = s.enum(it, {
785
+ const ne = new rt(), it = ["p1", "p2", "p3", "p4"], Te = s.enum(it, {
784
786
  description: "Task priority: p1 (highest), p2 (high), p3 (medium), p4 (lowest/default)"
785
787
  });
786
- function Ie(e) {
788
+ function ye(e) {
787
789
  return { p1: 4, p2: 3, p3: 2, p4: 1 }[e];
788
790
  }
789
791
  function at(e) {
790
792
  return { 4: "P1", 3: "P2", 2: "P3", 1: "P4" }[e] || "";
791
793
  }
792
- const v = {
794
+ const S = {
793
795
  /** Default limit for task listings */
794
796
  TASKS_DEFAULT: 10,
795
797
  /** Maximum limit for task search and list operations */
@@ -819,24 +821,24 @@ const v = {
819
821
  function ct(e = /* @__PURE__ */ new Date()) {
820
822
  return e.toISOString().split("T")[0] ?? "";
821
823
  }
822
- function ke(e, t, o = {}) {
823
- const { context: n, showDetails: r = !1 } = o, i = t.length, a = [], d = `${e} ${i} ${i === 1 ? "task" : "tasks"}${n ? ` ${n}` : ""}.`;
824
- a.push(d);
824
+ function Ie(e, t, o = {}) {
825
+ const { context: n, showDetails: r = !1 } = o, i = t.length, c = [], d = `${e} ${i} ${i === 1 ? "task" : "tasks"}${n ? ` ${n}` : ""}.`;
826
+ c.push(d);
825
827
  const l = 5;
826
828
  if (r || i <= l) {
827
829
  const u = V(t, l);
828
830
  if (u.length > 0) {
829
831
  const p = i > l ? `, +${i - l} more` : "";
830
- a.push(`Tasks:
832
+ c.push(`Tasks:
831
833
  ${u}${p}.`);
832
834
  }
833
835
  }
834
- return a.join(`
836
+ return c.join(`
835
837
  `);
836
838
  }
837
839
  function dt(e) {
838
- const { action: t, success: o, total: n, successItems: r, failures: i } = e, a = [], c = `${t}: ${o}/${n} successful.`;
839
- if (a.push(c), r?.length && r.length <= 5 && a.push(`Completed:
840
+ const { action: t, success: o, total: n, successItems: r, failures: i } = e, c = [], a = `${t}: ${o}/${n} successful.`;
841
+ if (c.push(a), r?.length && r.length <= 5 && c.push(`Completed:
840
842
  ${r.map((d) => ` ${d}`).join(`
841
843
  `)}.`), i?.length) {
842
844
  const d = i.length, l = `Failed (${d}):
@@ -844,9 +846,9 @@ ${i.slice(0, q.MAX_FAILURES_SHOWN).map((u) => ` ${u.item} (Error: ${u.error}$
844
846
  `
845
847
  `
846
848
  )}${d > q.MAX_FAILURES_SHOWN ? `, +${d - q.MAX_FAILURES_SHOWN} more` : ""}.`;
847
- a.push(l);
849
+ c.push(l);
848
850
  }
849
- return a.join(`
851
+ return c.join(`
850
852
  `);
851
853
  }
852
854
  function lt(e) {
@@ -874,15 +876,15 @@ function N({
874
876
  nextCursor: n,
875
877
  filterHints: r,
876
878
  previewLines: i,
877
- zeroReasonHints: a,
878
- nextSteps: c
879
+ zeroReasonHints: c,
880
+ nextSteps: a
879
881
  }) {
880
882
  const d = [], l = `${e}: ${t}${typeof o == "number" ? ` (limit ${o})` : ""}${n ? ", more available" : ""}.`;
881
883
  return d.push(l), r?.length && d.push(`Filter: ${r.join("; ")}.`), i?.length && d.push(`Preview:
882
- ${i}`), !t && a?.length && d.push(`No results. ${a.join("; ")}.`), (c?.length || n) && d.push(we(c || [], n)), d.join(`
884
+ ${i}`), !t && c?.length && d.push(`No results. ${c.join("; ")}.`), (a?.length || n) && d.push(ke(a || [], n)), d.join(`
883
885
  `);
884
886
  }
885
- function we(e, t) {
887
+ function ke(e, t) {
886
888
  const o = [...e];
887
889
  return t && o.push(`Pass cursor '${t}' to fetch more results.`), `${o.length === 1 ? "Possible suggested next step:" : "Possible suggested next steps:"}
888
890
  ${o.map((r) => `- ${r}`).join(`
@@ -895,7 +897,7 @@ const pt = s.object({
895
897
  description: s.string().optional().describe(
896
898
  "Additional details, notes, or context for the task. Use this for longer content rather than putting it in the task name. Supports Markdown."
897
899
  ),
898
- priority: ye.optional().describe(
900
+ priority: Te.optional().describe(
899
901
  "The priority of the task: p1 (highest), p2 (high), p3 (medium), p4 (lowest/default)."
900
902
  ),
901
903
  dueString: s.string().optional().describe("The due date for the task, in natural language."),
@@ -920,22 +922,22 @@ const pt = s.object({
920
922
  tasks: s.array(W).describe("The created tasks."),
921
923
  totalCount: s.number().describe("The total number of tasks created.")
922
924
  }, ft = {
923
- name: y.ADD_TASKS,
925
+ name: g.ADD_TASKS,
924
926
  description: "Add one or more tasks to a project, section, or parent. Supports assignment to project collaborators.",
925
927
  parameters: ht,
926
928
  outputSchema: mt,
927
929
  async execute({ tasks: e }, t) {
928
- const o = e.map((a) => bt(a, t)), r = (await Promise.all(o)).map(O), i = gt({
929
- tasks: r,
930
- args: { tasks: e }
931
- });
932
- return T({
933
- textContent: i,
930
+ const o = e.map((c) => bt(c, t)), r = (await Promise.all(o)).map(O);
931
+ return {
932
+ textContent: gt({
933
+ tasks: r,
934
+ args: { tasks: e }
935
+ }),
934
936
  structuredContent: {
935
937
  tasks: r,
936
938
  totalCount: r.length
937
939
  }
938
- });
940
+ };
939
941
  }
940
942
  };
941
943
  async function bt(e, t) {
@@ -944,8 +946,8 @@ async function bt(e, t) {
944
946
  projectId: n,
945
947
  sectionId: r,
946
948
  parentId: i,
947
- responsibleUser: a,
948
- priority: c,
949
+ responsibleUser: c,
950
+ priority: a,
949
951
  labels: d,
950
952
  deadlineDate: l,
951
953
  ...u
@@ -960,22 +962,22 @@ async function bt(e, t) {
960
962
  labels: d,
961
963
  deadlineDate: l
962
964
  };
963
- if (c && (b.priority = Ie(c)), a && !p && !r && !i)
965
+ if (a && (b.priority = ye(a)), c && !p && !r && !i)
964
966
  throw new Error(
965
967
  `Task "${e.content}": Cannot assign tasks without specifying project context. Please specify a projectId, sectionId, or parentId.`
966
968
  );
967
969
  if (o)
968
970
  try {
969
- const { minutes: m } = be(o);
971
+ const { minutes: m } = fe(o);
970
972
  b = {
971
973
  ...b,
972
974
  duration: m,
973
975
  durationUnit: "minute"
974
976
  };
975
977
  } catch (m) {
976
- throw m instanceof P ? new Error(`Task "${e.content}": ${m.message}`) : m;
978
+ throw m instanceof U ? new Error(`Task "${e.content}": ${m.message}`) : m;
977
979
  }
978
- if (a) {
980
+ if (c) {
979
981
  let m = p;
980
982
  if (!m && i)
981
983
  try {
@@ -991,18 +993,18 @@ async function bt(e, t) {
991
993
  throw new Error(
992
994
  `Task "${e.content}": Cannot determine target project for assignment validation`
993
995
  );
994
- const k = await re.validateTaskCreationAssignment(
996
+ const y = await ne.validateTaskCreationAssignment(
995
997
  t,
996
998
  m,
997
- a
999
+ c
998
1000
  );
999
- if (!k.isValid) {
1000
- const j = k.error?.message || "Assignment validation failed", S = k.error?.suggestions?.join(". ") || "";
1001
+ if (!y.isValid) {
1002
+ const k = y.error?.message || "Assignment validation failed", w = y.error?.suggestions?.join(". ") || "";
1001
1003
  throw new Error(
1002
- `Task "${e.content}": ${j}${S ? `. ${S}` : ""}`
1004
+ `Task "${e.content}": ${k}${w ? `. ${w}` : ""}`
1003
1005
  );
1004
1006
  }
1005
- b.assigneeId = k.resolvedUser?.userId;
1007
+ b.assigneeId = y.resolvedUser?.userId;
1006
1008
  }
1007
1009
  return await t.addTask(b);
1008
1010
  }
@@ -1018,7 +1020,7 @@ function gt({
1018
1020
  const r = Array.from(o)[0];
1019
1021
  n = r === "inbox" ? "" : `to ${r}`;
1020
1022
  } else o.size > 1 && (n = "to multiple contexts");
1021
- return ke("Added", e, {
1023
+ return Ie("Added", e, {
1022
1024
  context: n,
1023
1025
  showDetails: !0
1024
1026
  });
@@ -1032,7 +1034,7 @@ const Tt = {
1032
1034
  successCount: s.number().describe("The number of successfully completed tasks."),
1033
1035
  failureCount: s.number().describe("The number of failed task completions.")
1034
1036
  }, It = {
1035
- name: y.COMPLETE_TASKS,
1037
+ name: g.COMPLETE_TASKS,
1036
1038
  description: "Complete one or more tasks by their IDs.",
1037
1039
  parameters: Tt,
1038
1040
  outputSchema: yt,
@@ -1041,20 +1043,19 @@ const Tt = {
1041
1043
  for (const i of e.ids)
1042
1044
  try {
1043
1045
  await t.closeTask(i), o.push(i);
1044
- } catch (a) {
1045
- const c = a instanceof Error ? a.message : "Unknown error";
1046
+ } catch (c) {
1047
+ const a = c instanceof Error ? c.message : "Unknown error";
1046
1048
  n.push({
1047
1049
  item: i,
1048
- error: c
1050
+ error: a
1049
1051
  });
1050
1052
  }
1051
- const r = kt({
1052
- completed: o,
1053
- failures: n,
1054
- args: e
1055
- });
1056
- return T({
1057
- textContent: r,
1053
+ return {
1054
+ textContent: kt({
1055
+ completed: o,
1056
+ failures: n,
1057
+ args: e
1058
+ }),
1058
1059
  structuredContent: {
1059
1060
  completed: o,
1060
1061
  failures: n,
@@ -1062,7 +1063,7 @@ const Tt = {
1062
1063
  successCount: o.length,
1063
1064
  failureCount: n.length
1064
1065
  }
1065
- });
1066
+ };
1066
1067
  }
1067
1068
  };
1068
1069
  function kt({
@@ -1087,8 +1088,8 @@ const wt = {
1087
1088
  id: s.string().describe("The ID of the deleted entity.")
1088
1089
  }).describe("Information about the deleted entity."),
1089
1090
  success: s.boolean().describe("Whether the deletion was successful.")
1090
- }, $t = {
1091
- name: y.DELETE_OBJECT,
1091
+ }, vt = {
1092
+ name: g.DELETE_OBJECT,
1092
1093
  description: "Delete a project, section, task, or comment by its ID.",
1093
1094
  parameters: wt,
1094
1095
  outputSchema: jt,
@@ -1107,102 +1108,83 @@ const wt = {
1107
1108
  await t.deleteComment(e.id);
1108
1109
  break;
1109
1110
  }
1110
- const o = St({
1111
- type: e.type,
1112
- id: e.id
1113
- });
1114
- return T({
1115
- textContent: o,
1111
+ return {
1112
+ textContent: `Deleted ${e.type}: id=${e.id}`,
1116
1113
  structuredContent: {
1117
- deletedEntity: {
1118
- type: e.type,
1119
- id: e.id
1120
- },
1114
+ deletedEntity: { type: e.type, id: e.id },
1121
1115
  success: !0
1122
1116
  }
1123
- });
1117
+ };
1124
1118
  }
1125
- };
1126
- function St({
1127
- type: e,
1128
- id: t
1129
- }) {
1130
- return `Deleted ${e}: id=${t}`;
1131
- }
1132
- const Ct = {
1119
+ }, Ct = {
1133
1120
  id: s.string().min(1).describe(
1134
1121
  'A unique identifier for the document in the format "task:{id}" or "project:{id}".'
1135
1122
  )
1136
- }, vt = {
1123
+ }, $t = {
1137
1124
  id: s.string().describe("The ID of the fetched document."),
1138
1125
  title: s.string().describe("The title of the document."),
1139
1126
  text: s.string().describe("The text content of the document."),
1140
1127
  url: s.string().describe("The URL of the document."),
1141
1128
  metadata: s.record(s.unknown()).optional().describe("Additional metadata about the document.")
1142
- }, Dt = {
1143
- name: y.FETCH,
1129
+ }, St = {
1130
+ name: g.FETCH,
1144
1131
  description: 'Fetch the full contents of a task or project by its ID. The ID should be in the format "task:{id}" or "project:{id}".',
1145
1132
  parameters: Ct,
1146
- outputSchema: vt,
1133
+ outputSchema: $t,
1147
1134
  async execute(e, t) {
1148
- try {
1149
- const { id: o } = e, [n, r] = o.split(":", 2);
1150
- if (!r || n !== "task" && n !== "project")
1151
- throw new Error(
1152
- 'Invalid ID format. Expected "task:{id}" or "project:{id}". Example: "task:8485093748" or "project:6cfCcrrCFg2xP94Q"'
1153
- );
1154
- let i;
1155
- if (n === "task") {
1156
- const c = await t.getTask(r), d = O(c), l = [d.content];
1157
- d.description && l.push(`
1135
+ const { id: o } = e, [n, r] = o.split(":", 2);
1136
+ if (!r || n !== "task" && n !== "project")
1137
+ throw new Error(
1138
+ 'Invalid ID format. Expected "task:{id}" or "project:{id}". Example: "task:8485093748" or "project:6cfCcrrCFg2xP94Q"'
1139
+ );
1140
+ let i;
1141
+ if (n === "task") {
1142
+ const c = await t.getTask(r), a = O(c), d = [a.content];
1143
+ a.description && d.push(`
1158
1144
 
1159
- Description: ${d.description}`), d.dueDate && l.push(`
1160
- Due: ${d.dueDate}`), d.labels.length > 0 && l.push(`
1161
- Labels: ${d.labels.join(", ")}`), i = {
1162
- id: `task:${d.id}`,
1163
- title: d.content,
1164
- text: l.join(""),
1165
- url: he(d.id),
1166
- metadata: {
1167
- priority: d.priority,
1168
- projectId: d.projectId,
1169
- sectionId: d.sectionId,
1170
- parentId: d.parentId,
1171
- recurring: d.recurring,
1172
- duration: d.duration,
1173
- responsibleUid: d.responsibleUid,
1174
- assignedByUid: d.assignedByUid,
1175
- checked: d.checked,
1176
- completedAt: d.completedAt
1177
- }
1178
- };
1179
- } else {
1180
- const c = await t.getProject(r), d = Te(c), l = [d.name];
1181
- d.isShared && l.push(`
1145
+ Description: ${a.description}`), a.dueDate && d.push(`
1146
+ Due: ${a.dueDate}`), a.labels.length > 0 && d.push(`
1147
+ Labels: ${a.labels.join(", ")}`), i = {
1148
+ id: `task:${a.id}`,
1149
+ title: a.content,
1150
+ text: d.join(""),
1151
+ url: pe(a.id),
1152
+ metadata: {
1153
+ priority: a.priority,
1154
+ projectId: a.projectId,
1155
+ sectionId: a.sectionId,
1156
+ parentId: a.parentId,
1157
+ recurring: a.recurring,
1158
+ duration: a.duration,
1159
+ responsibleUid: a.responsibleUid,
1160
+ assignedByUid: a.assignedByUid,
1161
+ checked: a.checked,
1162
+ completedAt: a.completedAt
1163
+ }
1164
+ };
1165
+ } else {
1166
+ const c = await t.getProject(r), a = ge(c), d = [a.name];
1167
+ a.isShared && d.push(`
1182
1168
 
1183
- Shared project`), d.isFavorite && l.push(`
1169
+ Shared project`), a.isFavorite && d.push(`
1184
1170
  Favorite: Yes`), i = {
1185
- id: `project:${d.id}`,
1186
- title: d.name,
1187
- text: l.join(""),
1188
- url: me(d.id),
1189
- metadata: {
1190
- color: d.color,
1191
- isFavorite: d.isFavorite,
1192
- isShared: d.isShared,
1193
- parentId: d.parentId,
1194
- inboxProject: d.inboxProject,
1195
- viewStyle: d.viewStyle
1196
- }
1197
- };
1198
- }
1199
- return { content: [{ type: "text", text: JSON.stringify(i) }] };
1200
- } catch (o) {
1201
- const n = o instanceof Error ? o.message : "An unknown error occurred";
1202
- return Q(n);
1171
+ id: `project:${a.id}`,
1172
+ title: a.name,
1173
+ text: d.join(""),
1174
+ url: he(a.id),
1175
+ metadata: {
1176
+ color: a.color,
1177
+ isFavorite: a.isFavorite,
1178
+ isShared: a.isShared,
1179
+ parentId: a.parentId,
1180
+ inboxProject: a.inboxProject,
1181
+ viewStyle: a.viewStyle
1182
+ }
1183
+ };
1203
1184
  }
1185
+ return { textContent: JSON.stringify(i) };
1204
1186
  }
1205
- }, xt = {
1187
+ }, Dt = {
1206
1188
  objectType: s.enum(["task", "project", "comment"]).optional().describe("Type of object to filter by."),
1207
1189
  objectId: s.string().optional().describe("Filter by specific object ID (task, project, or comment)."),
1208
1190
  eventType: s.enum([
@@ -1219,43 +1201,39 @@ Favorite: Yes`), i = {
1219
1201
  projectId: s.string().optional().describe("Filter events by parent project ID."),
1220
1202
  taskId: s.string().optional().describe("Filter events by parent task ID (for subtask events)."),
1221
1203
  initiatorId: s.string().optional().describe("Filter by the user ID who initiated the event."),
1222
- limit: s.number().int().min(1).max(v.ACTIVITY_MAX).default(v.ACTIVITY_DEFAULT).describe("Maximum number of activity events to return."),
1204
+ limit: s.number().int().min(1).max(S.ACTIVITY_MAX).default(S.ACTIVITY_DEFAULT).describe("Maximum number of activity events to return."),
1223
1205
  cursor: s.string().optional().describe("Pagination cursor for retrieving the next page of results.")
1224
- }, At = {
1206
+ }, xt = {
1225
1207
  events: s.array(Oe).describe("The activity events."),
1226
1208
  nextCursor: s.string().optional().describe("Cursor for the next page of results."),
1227
1209
  totalCount: s.number().describe("The total number of events in this page."),
1228
1210
  hasMore: s.boolean().describe("Whether there are more results available."),
1229
1211
  appliedFilters: s.record(s.unknown()).describe("The filters that were applied to the search.")
1230
- }, Ut = {
1231
- name: y.FIND_ACTIVITY,
1212
+ }, At = {
1213
+ name: g.FIND_ACTIVITY,
1232
1214
  description: "Retrieve recent activity logs to monitor and audit changes in Todoist. Shows events from all users by default (use initiatorId to filter by specific user). Track task completions, updates, deletions, project changes, and more with flexible filtering. Note: Date-based filtering is not supported by the Todoist API.",
1233
- parameters: xt,
1234
- outputSchema: At,
1215
+ parameters: Dt,
1216
+ outputSchema: xt,
1235
1217
  async execute(e, t) {
1236
- const { objectType: o, objectId: n, eventType: r, projectId: i, taskId: a, initiatorId: c, limit: d, cursor: l } = e, u = {
1218
+ const { objectType: o, objectId: n, eventType: r, projectId: i, taskId: c, initiatorId: a, limit: d, cursor: l } = e, u = {
1237
1219
  limit: d,
1238
1220
  cursor: l ?? null
1239
1221
  };
1240
- o && (u.objectType = o), n && n !== "remove" && (u.objectId = n), r && (u.eventType = r), i && (u.parentProjectId = i), a && (u.parentItemId = a), c && (u.initiatorId = c);
1241
- const { results: p, nextCursor: b } = await t.getActivityLogs(u), m = p.map(ot), k = Pt({
1242
- events: m,
1243
- args: e,
1244
- nextCursor: b
1245
- });
1246
- return T({
1247
- textContent: k,
1222
+ o && (u.objectType = o), n && n !== "remove" && (u.objectId = n), r && (u.eventType = r), i && (u.parentProjectId = i), c && (u.parentItemId = c), a && (u.initiatorId = a);
1223
+ const { results: p, nextCursor: b } = await t.getActivityLogs(u), m = p.map(ot);
1224
+ return {
1225
+ textContent: Ut({ events: m, args: e, nextCursor: b }),
1248
1226
  structuredContent: {
1249
1227
  events: m,
1250
- nextCursor: b,
1228
+ nextCursor: b ?? void 0,
1251
1229
  totalCount: m.length,
1252
1230
  hasMore: !!b,
1253
1231
  appliedFilters: e
1254
1232
  }
1255
- });
1233
+ };
1256
1234
  }
1257
1235
  };
1258
- function Pt({
1236
+ function Ut({
1259
1237
  events: e,
1260
1238
  args: t,
1261
1239
  nextCursor: o
@@ -1263,25 +1241,25 @@ function Pt({
1263
1241
  let n = "Activity events";
1264
1242
  const r = [];
1265
1243
  if (t.eventType && r.push(`${t.eventType}`), t.objectType) {
1266
- const c = t.objectType === "task" ? "tasks" : `${t.objectType}s`;
1267
- r.push(c);
1244
+ const a = t.objectType === "task" ? "tasks" : `${t.objectType}s`;
1245
+ r.push(a);
1268
1246
  }
1269
1247
  r.length > 0 && (n = `Activity: ${r.join(" ")}`);
1270
1248
  const i = [];
1271
1249
  t.objectId && i.push(`object ID: ${t.objectId}`), t.projectId && i.push(`project: ${t.projectId}`), t.taskId && i.push(`task: ${t.taskId}`), t.initiatorId && i.push(`initiator: ${t.initiatorId}`);
1272
- const a = [];
1273
- return e.length === 0 && (a.push("No activity events match the specified filters"), a.push("Note: Activity logs only show recent events"), t.eventType && a.push(`Try removing the eventType filter (${t.eventType})`), t.objectType && a.push(`Try removing the objectType filter (${t.objectType})`), (t.objectId || t.projectId || t.taskId) && a.push("Verify the object ID is correct")), N({
1250
+ const c = [];
1251
+ return e.length === 0 && (c.push("No activity events match the specified filters"), c.push("Note: Activity logs only show recent events"), t.eventType && c.push(`Try removing the eventType filter (${t.eventType})`), t.objectType && c.push(`Try removing the objectType filter (${t.objectType})`), (t.objectId || t.projectId || t.taskId) && c.push("Verify the object ID is correct")), N({
1274
1252
  subject: n,
1275
1253
  count: e.length,
1276
1254
  limit: t.limit,
1277
1255
  nextCursor: o ?? void 0,
1278
1256
  filterHints: i,
1279
- previewLines: Et(e, Math.min(e.length, t.limit)),
1280
- zeroReasonHints: a
1257
+ previewLines: Pt(e, Math.min(e.length, t.limit)),
1258
+ zeroReasonHints: c
1281
1259
  });
1282
1260
  }
1283
- function Et(e, t = 10) {
1284
- const n = e.slice(0, t).map(Ot).join(`
1261
+ function Pt(e, t = 10) {
1262
+ const n = e.slice(0, t).map(Et).join(`
1285
1263
  `);
1286
1264
  if (e.length > t) {
1287
1265
  const r = e.length - t;
@@ -1290,17 +1268,17 @@ function Et(e, t = 10) {
1290
1268
  }
1291
1269
  return n;
1292
1270
  }
1293
- function Ot(e) {
1294
- const t = _t(e.eventDate), o = `${e.eventType} ${e.objectType}`;
1271
+ function Et(e) {
1272
+ const t = Ot(e.eventDate), o = `${e.eventType} ${e.objectType}`;
1295
1273
  let n = "";
1296
1274
  if (e.extraData) {
1297
- const c = e.extraData.content || e.extraData.name || e.extraData.last_content;
1298
- c && typeof c == "string" && (n = ` • "${c.length > 50 ? `${c.substring(0, 47)}...` : c}"`);
1275
+ const a = e.extraData.content || e.extraData.name || e.extraData.last_content;
1276
+ a && typeof a == "string" && (n = ` • "${a.length > 50 ? `${a.substring(0, 47)}...` : a}"`);
1299
1277
  }
1300
- const r = e.objectId ? ` • id=${e.objectId}` : "", i = e.initiatorId ? ` • by=${e.initiatorId}` : " • system", a = e.parentProjectId ? ` • project=${e.parentProjectId}` : "";
1301
- return ` [${t}] ${o}${n}${r}${i}${a}`;
1278
+ const r = e.objectId ? ` • id=${e.objectId}` : "", i = e.initiatorId ? ` • by=${e.initiatorId}` : " • system", c = e.parentProjectId ? ` • project=${e.parentProjectId}` : "";
1279
+ return ` [${t}] ${o}${n}${r}${i}${c}`;
1302
1280
  }
1303
- function _t(e) {
1281
+ function Ot(e) {
1304
1282
  try {
1305
1283
  const t = new Date(e), o = t.toLocaleDateString("en-US", { month: "short", timeZone: "UTC" }), n = t.toLocaleDateString("en-US", { day: "numeric", timeZone: "UTC" }), r = t.toLocaleTimeString("en-US", {
1306
1284
  hour: "2-digit",
@@ -1313,23 +1291,23 @@ function _t(e) {
1313
1291
  return e;
1314
1292
  }
1315
1293
  }
1316
- const Nt = {
1294
+ const _t = {
1317
1295
  taskId: s.string().optional().describe("Find comments for a specific task."),
1318
1296
  projectId: s.string().optional().describe(
1319
1297
  'Find comments for a specific project. Project ID should be an ID string, or the text "inbox", for inbox tasks.'
1320
1298
  ),
1321
1299
  commentId: s.string().optional().describe("Get a specific comment by ID."),
1322
1300
  cursor: s.string().optional().describe("Pagination cursor for retrieving more results."),
1323
- limit: s.number().int().min(1).max(v.COMMENTS_MAX).optional().describe("Maximum number of comments to return")
1324
- }, Mt = {
1325
- comments: s.array(se).describe("The found comments."),
1301
+ limit: s.number().int().min(1).max(S.COMMENTS_MAX).optional().describe("Maximum number of comments to return")
1302
+ }, Nt = {
1303
+ comments: s.array(te).describe("The found comments."),
1326
1304
  nextCursor: s.string().optional().describe("Cursor for the next page of results."),
1327
1305
  totalCount: s.number().describe("The total number of comments in this page.")
1328
- }, Ft = {
1329
- name: y.FIND_COMMENTS,
1306
+ }, Mt = {
1307
+ name: g.FIND_COMMENTS,
1330
1308
  description: "Find comments by task, project, or get a specific comment by ID. Exactly one of taskId, projectId, or commentId must be provided.",
1331
- parameters: Nt,
1332
- outputSchema: Mt,
1309
+ parameters: _t,
1310
+ outputSchema: Nt,
1333
1311
  async execute(e, t) {
1334
1312
  const o = [e.taskId, e.projectId, e.commentId].filter(Boolean);
1335
1313
  if (o.length === 0)
@@ -1339,46 +1317,45 @@ const Nt = {
1339
1317
  "Cannot provide multiple search parameters. Choose one of: taskId, projectId, or commentId."
1340
1318
  );
1341
1319
  const n = e.projectId === "inbox" ? (await t.getUser()).inboxProjectId : e.projectId;
1342
- let r, i = !1, a = null;
1320
+ let r, i = !1, c = null;
1343
1321
  if (e.commentId)
1344
1322
  r = [await t.getComment(e.commentId)];
1345
1323
  else if (e.taskId) {
1346
1324
  const d = await t.getComments({
1347
1325
  taskId: e.taskId,
1348
1326
  cursor: e.cursor || null,
1349
- limit: e.limit || v.COMMENTS_DEFAULT
1327
+ limit: e.limit || S.COMMENTS_DEFAULT
1350
1328
  });
1351
- r = d.results, i = d.nextCursor !== null, a = d.nextCursor;
1329
+ r = d.results, i = d.nextCursor !== null, c = d.nextCursor;
1352
1330
  } else if (n) {
1353
1331
  const d = await t.getComments({
1354
1332
  projectId: n,
1355
1333
  cursor: e.cursor || null,
1356
- limit: e.limit || v.COMMENTS_DEFAULT
1334
+ limit: e.limit || S.COMMENTS_DEFAULT
1357
1335
  });
1358
- r = d.results, i = d.nextCursor !== null, a = d.nextCursor;
1336
+ r = d.results, i = d.nextCursor !== null, c = d.nextCursor;
1359
1337
  } else
1360
1338
  throw new Error("Invalid state: no search parameter provided");
1361
- const c = Rt({
1362
- comments: r,
1363
- searchType: e.commentId ? "single" : e.taskId ? "task" : "project",
1364
- searchId: e.commentId || e.taskId || e.projectId || "",
1365
- hasMore: i,
1366
- nextCursor: a
1367
- });
1368
- return T({
1369
- textContent: c,
1339
+ return {
1340
+ textContent: Ft({
1341
+ comments: r,
1342
+ searchType: e.commentId ? "single" : e.taskId ? "task" : "project",
1343
+ searchId: e.commentId || e.taskId || e.projectId || "",
1344
+ hasMore: i,
1345
+ nextCursor: c
1346
+ }),
1370
1347
  structuredContent: {
1371
1348
  comments: r,
1372
1349
  searchType: e.commentId ? "single" : e.taskId ? "task" : "project",
1373
1350
  searchId: e.commentId || e.taskId || e.projectId || "",
1374
1351
  hasMore: i,
1375
- nextCursor: a,
1352
+ nextCursor: c ?? void 0,
1376
1353
  totalCount: r.length
1377
1354
  }
1378
- });
1355
+ };
1379
1356
  }
1380
1357
  };
1381
- function Rt({
1358
+ function Ft({
1382
1359
  comments: e,
1383
1360
  searchType: t,
1384
1361
  searchId: o,
@@ -1389,33 +1366,33 @@ function Rt({
1389
1366
  return `No comments found for ${t}${t !== "single" ? ` ${o}` : ""}`;
1390
1367
  let i;
1391
1368
  if (t === "single") {
1392
- const a = e[0];
1393
- if (!a)
1369
+ const c = e[0];
1370
+ if (!c)
1394
1371
  return "Comment not found";
1395
- i = `Found comment${a.fileAttachment !== null ? ` • Has attachment: ${a.fileAttachment?.fileName || "file"}` : ""} • id=${a.id}`;
1372
+ i = `Found comment${c.fileAttachment !== null ? ` • Has attachment: ${c.fileAttachment?.fileName || "file"}` : ""} • id=${c.id}`;
1396
1373
  } else {
1397
- const a = e.filter((l) => l.fileAttachment !== null).length, c = a > 0 ? ` (${a} with attachments)` : "", d = e.length === 1 ? "comment" : "comments";
1398
- i = `Found ${e.length} ${d} for ${t} ${o}${c}`, n && (i += " • More available");
1374
+ const c = e.filter((l) => l.fileAttachment !== null).length, a = c > 0 ? ` (${c} with attachments)` : "", d = e.length === 1 ? "comment" : "comments";
1375
+ i = `Found ${e.length} ${d} for ${t} ${o}${a}`, n && (i += " • More available");
1399
1376
  }
1400
1377
  if (r) {
1401
- const a = we([], r);
1378
+ const c = ke([], r);
1402
1379
  return `${i}
1403
- ${a}`;
1380
+ ${c}`;
1404
1381
  }
1405
1382
  return i;
1406
1383
  }
1407
- const Lt = ["and", "or"], ie = {
1384
+ const Rt = ["and", "or"], re = {
1408
1385
  labels: s.string().array().optional().describe("The labels to filter the tasks by"),
1409
- labelsOperator: s.enum(Lt).optional().describe(
1386
+ labelsOperator: s.enum(Rt).optional().describe(
1410
1387
  'The operator to use when filtering by labels. This will dictate whether a task has all labels, or some of them. Default is "or".'
1411
1388
  )
1412
1389
  };
1413
- function ae(e = [], t = "or") {
1390
+ function ie(e = [], t = "or") {
1414
1391
  if (e.length === 0) return "";
1415
1392
  const o = t === "and" ? " & " : " | ";
1416
1393
  return `(${e.map((i) => i.startsWith("@") ? i : `@${i}`).join(` ${o} `)})`;
1417
1394
  }
1418
- const Bt = {
1395
+ const Lt = {
1419
1396
  getBy: s.enum(["completion", "due"]).default("completion").describe(
1420
1397
  'The method to use to get the tasks: "completion" to get tasks by completion date (ie, when the task was actually completed), "due" to get tasks by due date (ie, when the task was due to be completed by).'
1421
1398
  ),
@@ -1430,88 +1407,88 @@ const Bt = {
1430
1407
  responsibleUser: s.string().optional().describe(
1431
1408
  "Find tasks assigned to this user. Can be a user ID, name, or email address. Defaults to all collaborators when omitted."
1432
1409
  ),
1433
- limit: s.number().int().min(1).max(v.COMPLETED_TASKS_MAX).default(v.COMPLETED_TASKS_DEFAULT).describe("The maximum number of tasks to return."),
1410
+ limit: s.number().int().min(1).max(S.COMPLETED_TASKS_MAX).default(S.COMPLETED_TASKS_DEFAULT).describe("The maximum number of tasks to return."),
1434
1411
  cursor: s.string().optional().describe(
1435
1412
  "The cursor to get the next page of tasks (cursor is obtained from the previous call to this tool, with the same parameters)."
1436
1413
  ),
1437
- ...ie
1438
- }, Wt = {
1414
+ ...re
1415
+ }, Bt = {
1439
1416
  tasks: s.array(W).describe("The found completed tasks."),
1440
1417
  nextCursor: s.string().optional().describe("Cursor for the next page of results."),
1441
1418
  totalCount: s.number().describe("The total number of tasks in this page."),
1442
1419
  hasMore: s.boolean().describe("Whether there are more results available."),
1443
1420
  appliedFilters: s.record(s.unknown()).describe("The filters that were applied to the search.")
1444
- }, Yt = {
1445
- name: y.FIND_COMPLETED_TASKS,
1421
+ }, Wt = {
1422
+ name: g.FIND_COMPLETED_TASKS,
1446
1423
  description: "Get completed tasks (includes all collaborators by default—use responsibleUser to narrow).",
1447
- parameters: Bt,
1448
- outputSchema: Wt,
1424
+ parameters: Lt,
1425
+ outputSchema: Bt,
1449
1426
  async execute(e, t) {
1450
- const { getBy: o, labels: n, labelsOperator: r, since: i, until: a, responsibleUser: c, projectId: d, ...l } = e, u = await oe(t, c), p = u?.email;
1451
- let m = ae(n, r);
1427
+ const { getBy: o, labels: n, labelsOperator: r, since: i, until: c, responsibleUser: a, projectId: d, ...l } = e, u = await se(t, a), p = u?.email;
1428
+ let m = ie(n, r);
1452
1429
  u && p && (m = z(m, `assigned to: ${p}`));
1453
- const k = await t.getUser(), j = k.tzInfo?.gmtString || "+00:00", S = d === "inbox" ? k.inboxProjectId : d, x = `${i}T00:00:00${j}`, E = `${a}T23:59:59${j}`, h = new Date(x).toISOString(), I = new Date(E).toISOString(), { items: C, nextCursor: g } = o === "completion" ? await t.getCompletedTasksByCompletionDate({
1430
+ const y = await t.getUser(), k = y.tzInfo?.gmtString || "+00:00", w = d === "inbox" ? y.inboxProjectId : d, D = `${i}T00:00:00${k}`, P = `${c}T23:59:59${k}`, h = new Date(D).toISOString(), T = new Date(P).toISOString(), { items: C, nextCursor: v } = o === "completion" ? await t.getCompletedTasksByCompletionDate({
1454
1431
  ...l,
1455
- projectId: S,
1432
+ projectId: w,
1456
1433
  since: h,
1457
- until: I,
1434
+ until: T,
1458
1435
  ...m ? { filterQuery: m, filterLang: "en" } : {}
1459
1436
  }) : await t.getCompletedTasksByDueDate({
1460
1437
  ...l,
1461
- projectId: S,
1438
+ projectId: w,
1462
1439
  since: h,
1463
- until: I,
1440
+ until: T,
1464
1441
  ...m ? { filterQuery: m, filterLang: "en" } : {}
1465
- }), f = C.map(O), $ = Kt({
1466
- tasks: f,
1467
- args: e,
1468
- nextCursor: g,
1469
- assigneeEmail: p
1470
- });
1471
- return T({
1472
- textContent: $,
1442
+ }), f = C.map(O);
1443
+ return {
1444
+ textContent: Yt({
1445
+ tasks: f,
1446
+ args: e,
1447
+ nextCursor: v,
1448
+ assigneeEmail: p
1449
+ }),
1473
1450
  structuredContent: {
1474
1451
  tasks: f,
1475
- nextCursor: g,
1452
+ nextCursor: v ?? void 0,
1476
1453
  totalCount: f.length,
1477
- hasMore: !!g,
1454
+ hasMore: !!v,
1478
1455
  appliedFilters: e
1479
1456
  }
1480
- });
1457
+ };
1481
1458
  }
1482
1459
  };
1483
- function Kt({
1460
+ function Yt({
1484
1461
  tasks: e,
1485
1462
  args: t,
1486
1463
  nextCursor: o,
1487
1464
  assigneeEmail: n
1488
1465
  }) {
1489
- const r = t.getBy === "completion" ? "completed" : "due", i = `Completed tasks (by ${r} date)`, a = [];
1490
- if (a.push(`${r} date: ${t.since} to ${t.until}`), t.projectId && a.push(`project: ${t.projectId}`), t.sectionId && a.push(`section: ${t.sectionId}`), t.parentId && a.push(`parent: ${t.parentId}`), t.workspaceId && a.push(`workspace: ${t.workspaceId}`), t.labels && t.labels.length > 0) {
1466
+ const r = t.getBy === "completion" ? "completed" : "due", i = `Completed tasks (by ${r} date)`, c = [];
1467
+ if (c.push(`${r} date: ${t.since} to ${t.until}`), t.projectId && c.push(`project: ${t.projectId}`), t.sectionId && c.push(`section: ${t.sectionId}`), t.parentId && c.push(`parent: ${t.parentId}`), t.workspaceId && c.push(`workspace: ${t.workspaceId}`), t.labels && t.labels.length > 0) {
1491
1468
  const d = t.labels.map((l) => `@${l}`).join(t.labelsOperator === "and" ? " & " : " | ");
1492
- a.push(`labels: ${d}`);
1469
+ c.push(`labels: ${d}`);
1493
1470
  }
1494
1471
  if (t.responsibleUser) {
1495
1472
  const d = n || t.responsibleUser;
1496
- a.push(`assigned to: ${d}`);
1473
+ c.push(`assigned to: ${d}`);
1497
1474
  }
1498
- const c = [];
1499
- return e.length === 0 && (c.push("No tasks completed in this date range"), c.push("Try expanding the date range"), (t.projectId || t.sectionId || t.parentId) && c.push("Try removing project/section/parent filters"), t.getBy === "due" && c.push('Try switching to "completion" date instead')), N({
1475
+ const a = [];
1476
+ return e.length === 0 && (a.push("No tasks completed in this date range"), a.push("Try expanding the date range"), (t.projectId || t.sectionId || t.parentId) && a.push("Try removing project/section/parent filters"), t.getBy === "due" && a.push('Try switching to "completion" date instead')), N({
1500
1477
  subject: i,
1501
1478
  count: e.length,
1502
1479
  limit: t.limit,
1503
1480
  nextCursor: o ?? void 0,
1504
- filterHints: a,
1481
+ filterHints: c,
1505
1482
  previewLines: V(e, Math.min(e.length, t.limit)),
1506
- zeroReasonHints: c
1483
+ zeroReasonHints: a
1507
1484
  });
1508
1485
  }
1509
- const { FIND_PROJECTS: zt, ADD_TASKS: je, UPDATE_TASKS: $e } = y, Vt = {
1486
+ const { FIND_PROJECTS: Kt, ADD_TASKS: we, UPDATE_TASKS: je } = g, zt = {
1510
1487
  projectId: s.string().min(1).describe("The ID of the project to search for collaborators in."),
1511
1488
  searchTerm: s.string().optional().describe(
1512
1489
  "Search for a collaborator by name or email (partial and case insensitive match). If omitted, all collaborators in the project are returned."
1513
1490
  )
1514
- }, Ht = {
1491
+ }, Vt = {
1515
1492
  collaborators: s.array(_e).describe("The found collaborators."),
1516
1493
  projectInfo: s.object({
1517
1494
  id: s.string().describe("The project ID."),
@@ -1521,25 +1498,24 @@ const { FIND_PROJECTS: zt, ADD_TASKS: je, UPDATE_TASKS: $e } = y, Vt = {
1521
1498
  totalCount: s.number().describe("The total number of collaborators found."),
1522
1499
  totalAvailable: s.number().optional().describe("The total number of available collaborators in the project."),
1523
1500
  appliedFilters: s.record(s.unknown()).describe("The filters that were applied to the search.")
1524
- }, Gt = {
1525
- name: y.FIND_PROJECT_COLLABORATORS,
1501
+ }, Ht = {
1502
+ name: g.FIND_PROJECT_COLLABORATORS,
1526
1503
  description: "Search for collaborators by name or other criteria in a project.",
1527
- parameters: Vt,
1528
- outputSchema: Ht,
1504
+ parameters: zt,
1505
+ outputSchema: Vt,
1529
1506
  async execute(e, t) {
1530
1507
  const { projectId: o, searchTerm: n } = e;
1531
1508
  let r = o, i;
1532
1509
  try {
1533
1510
  if (i = await t.getProject(o), !i)
1534
1511
  throw new Error(`Project with ID "${o}" not found or not accessible`);
1535
- if (r = i.name, !i.isShared) {
1536
- const l = `Project "${r}" is not shared and has no collaborators.
1512
+ if (r = i.name, !i.isShared)
1513
+ return {
1514
+ textContent: `Project "${r}" is not shared and has no collaborators.
1537
1515
 
1538
1516
  **Next steps:**
1539
1517
  • Share the project to enable collaboration
1540
- • Use ${je} and ${$e} for assignment features once shared`;
1541
- return T({
1542
- textContent: l,
1518
+ • Use ${we} and ${je} for assignment features once shared`,
1543
1519
  structuredContent: {
1544
1520
  collaborators: [],
1545
1521
  projectInfo: {
@@ -1550,23 +1526,21 @@ const { FIND_PROJECTS: zt, ADD_TASKS: je, UPDATE_TASKS: $e } = y, Vt = {
1550
1526
  totalCount: 0,
1551
1527
  appliedFilters: e
1552
1528
  }
1553
- });
1554
- }
1529
+ };
1555
1530
  } catch (l) {
1556
1531
  throw new Error(
1557
1532
  `Failed to access project "${o}": ${l instanceof Error ? l.message : "Unknown error"}`
1558
1533
  );
1559
1534
  }
1560
- const a = await _.getProjectCollaborators(t, o);
1561
- if (a.length === 0) {
1562
- const l = `Project "${r}" has no collaborators or collaborator data is not accessible.
1535
+ const c = await _.getProjectCollaborators(t, o);
1536
+ if (c.length === 0)
1537
+ return {
1538
+ textContent: `Project "${r}" has no collaborators or collaborator data is not accessible.
1563
1539
 
1564
1540
  **Next steps:**
1565
1541
  • Check project sharing settings
1566
1542
  • Ensure you have permission to view collaborators
1567
- • Try refreshing or re-sharing the project`;
1568
- return T({
1569
- textContent: l,
1543
+ • Try refreshing or re-sharing the project`,
1570
1544
  structuredContent: {
1571
1545
  collaborators: [],
1572
1546
  projectInfo: {
@@ -1577,38 +1551,36 @@ const { FIND_PROJECTS: zt, ADD_TASKS: je, UPDATE_TASKS: $e } = y, Vt = {
1577
1551
  totalCount: 0,
1578
1552
  appliedFilters: e
1579
1553
  }
1580
- });
1581
- }
1582
- let c = a;
1554
+ };
1555
+ let a = c;
1583
1556
  if (n) {
1584
1557
  const l = n.toLowerCase().trim();
1585
- c = a.filter(
1558
+ a = c.filter(
1586
1559
  (u) => u.name.toLowerCase().includes(l) || u.email.toLowerCase().includes(l)
1587
1560
  );
1588
1561
  }
1589
- const d = qt({
1590
- collaborators: c,
1591
- projectName: r,
1592
- searchTerm: n,
1593
- totalAvailable: a.length
1594
- });
1595
- return T({
1596
- textContent: d,
1562
+ return {
1563
+ textContent: Gt({
1564
+ collaborators: a,
1565
+ projectName: r,
1566
+ searchTerm: n,
1567
+ totalAvailable: c.length
1568
+ }),
1597
1569
  structuredContent: {
1598
- collaborators: c,
1570
+ collaborators: a,
1599
1571
  projectInfo: {
1600
1572
  id: o,
1601
1573
  name: r,
1602
1574
  isShared: !0
1603
1575
  },
1604
- totalCount: c.length,
1605
- totalAvailable: a.length,
1576
+ totalCount: a.length,
1577
+ totalAvailable: c.length,
1606
1578
  appliedFilters: e
1607
1579
  }
1608
- });
1580
+ };
1609
1581
  }
1610
1582
  };
1611
- function qt({
1583
+ function Gt({
1612
1584
  collaborators: e,
1613
1585
  projectName: t,
1614
1586
  searchTerm: o,
@@ -1616,75 +1588,71 @@ function qt({
1616
1588
  }) {
1617
1589
  const r = o ? `Project collaborators matching "${o}"` : "Project collaborators", i = [];
1618
1590
  o && i.push(`matching "${o}"`), i.push(`in project "${t}"`);
1619
- let a = [];
1620
- e.length > 0 && (a = e.slice(0, 10).map((l) => {
1591
+ let c = [];
1592
+ e.length > 0 && (c = e.slice(0, 10).map((l) => {
1621
1593
  const u = l.name || "Unknown Name", p = l.email || "No email";
1622
1594
  return `• ${u} (${p}) - ID: ${l.id}`;
1623
- }), e.length > 10 && a.push(`... and ${e.length - 10} more`));
1624
- const c = [];
1625
- e.length === 0 && (o ? (c.push(`No collaborators match "${o}"`), c.push("Try a broader search term or check spelling"), n > 0 && c.push(`${n} collaborators available without filter`)) : (c.push("Project has no collaborators"), c.push("Share the project to add collaborators")));
1595
+ }), e.length > 10 && c.push(`... and ${e.length - 10} more`));
1596
+ const a = [];
1597
+ e.length === 0 && (o ? (a.push(`No collaborators match "${o}"`), a.push("Try a broader search term or check spelling"), n > 0 && a.push(`${n} collaborators available without filter`)) : (a.push("Project has no collaborators"), a.push("Share the project to add collaborators")));
1626
1598
  const d = [];
1627
- return e.length > 0 ? (d.push(`Use ${je} with responsibleUser to assign new tasks`), d.push(`Use ${$e} with responsibleUser to reassign existing tasks`), d.push("Use collaborator names, emails, or IDs for assignments")) : (d.push(`Use ${zt} to find other projects`), o && n > 0 && d.push("Try searching without filters to see all collaborators")), N({
1599
+ return e.length > 0 ? (d.push(`Use ${we} with responsibleUser to assign new tasks`), d.push(`Use ${je} with responsibleUser to reassign existing tasks`), d.push("Use collaborator names, emails, or IDs for assignments")) : (d.push(`Use ${Kt} to find other projects`), o && n > 0 && d.push("Try searching without filters to see all collaborators")), N({
1628
1600
  subject: r,
1629
1601
  count: e.length,
1630
1602
  filterHints: i,
1631
- previewLines: a.join(`
1603
+ previewLines: c.join(`
1632
1604
  `),
1633
- zeroReasonHints: c,
1605
+ zeroReasonHints: a,
1634
1606
  nextSteps: d
1635
1607
  });
1636
1608
  }
1637
- const { ADD_PROJECTS: Jt } = y, Xt = {
1609
+ const { ADD_PROJECTS: qt } = g, Jt = {
1638
1610
  search: s.string().optional().describe(
1639
1611
  "Search for a project by name (partial and case insensitive match). If omitted, all projects are returned."
1640
1612
  ),
1641
- limit: s.number().int().min(1).max(v.PROJECTS_MAX).default(v.PROJECTS_DEFAULT).describe("The maximum number of projects to return."),
1613
+ limit: s.number().int().min(1).max(S.PROJECTS_MAX).default(S.PROJECTS_DEFAULT).describe("The maximum number of projects to return."),
1642
1614
  cursor: s.string().optional().describe(
1643
1615
  "The cursor to get the next page of projects (cursor is obtained from the previous call to this tool, with the same parameters)."
1644
1616
  )
1645
- }, Zt = {
1646
- projects: s.array(ee).describe("The found projects."),
1617
+ }, Xt = {
1618
+ projects: s.array(Q).describe("The found projects."),
1647
1619
  nextCursor: s.string().optional().describe("Cursor for the next page of results."),
1648
1620
  totalCount: s.number().describe("The total number of projects in this page."),
1649
1621
  hasMore: s.boolean().describe("Whether there are more results available."),
1650
1622
  appliedFilters: s.record(s.unknown()).describe("The filters that were applied to the search.")
1651
- }, Qt = {
1652
- name: y.FIND_PROJECTS,
1623
+ }, Zt = {
1624
+ name: g.FIND_PROJECTS,
1653
1625
  description: "List all projects or search for projects by name. If search parameter is omitted, all projects are returned.",
1654
- parameters: Xt,
1655
- outputSchema: Zt,
1626
+ parameters: Jt,
1627
+ outputSchema: Xt,
1656
1628
  async execute(e, t) {
1657
1629
  const { results: o, nextCursor: n } = await t.getProjects({
1658
1630
  limit: e.limit,
1659
1631
  cursor: e.cursor ?? null
1660
- }), r = e.search ? e.search.toLowerCase() : void 0, a = (r ? o.filter((c) => c.name.toLowerCase().includes(r)) : o).map(Te);
1661
- return T({
1662
- textContent: es({
1663
- projects: a,
1664
- args: e,
1665
- nextCursor: n
1666
- }),
1632
+ }), r = e.search ? e.search.toLowerCase() : void 0, c = (r ? o.filter((a) => a.name.toLowerCase().includes(r)) : o).map(ge);
1633
+ return {
1634
+ textContent: Qt({ projects: c, args: e, nextCursor: n }),
1667
1635
  structuredContent: {
1668
- projects: a,
1669
- nextCursor: n,
1670
- totalCount: a.length,
1636
+ projects: c,
1637
+ nextCursor: n ?? void 0,
1638
+ totalCount: c.length,
1671
1639
  hasMore: !!n,
1672
1640
  appliedFilters: e
1673
1641
  }
1674
- });
1642
+ };
1675
1643
  }
1676
1644
  };
1677
- function es({
1645
+ function Qt({
1678
1646
  projects: e,
1679
1647
  args: t,
1680
1648
  nextCursor: o
1681
1649
  }) {
1682
1650
  const n = t.search ? `Projects matching "${t.search}"` : "Projects", r = [];
1683
1651
  t.search && r.push(`search: "${t.search}"`);
1684
- const i = 10, c = e.slice(0, i).map(ut).join(`
1685
- `), d = e.length - i, l = d > 0 ? `${c}
1686
- …and ${d} more` : c, u = [];
1687
- return e.length === 0 && (t.search ? (u.push("Try broader search terms"), u.push("Check spelling"), u.push("Remove search to see all projects")) : (u.push("No projects created yet"), u.push(`Use ${Jt} to create a project`))), N({
1652
+ const i = 10, a = e.slice(0, i).map(ut).join(`
1653
+ `), d = e.length - i, l = d > 0 ? `${a}
1654
+ …and ${d} more` : a, u = [];
1655
+ return e.length === 0 && (t.search ? (u.push("Try broader search terms"), u.push("Check spelling"), u.push("Remove search to see all projects")) : (u.push("No projects created yet"), u.push(`Use ${qt} to create a project`))), N({
1688
1656
  subject: n,
1689
1657
  count: e.length,
1690
1658
  limit: t.limit,
@@ -1694,51 +1662,48 @@ function es({
1694
1662
  zeroReasonHints: u
1695
1663
  });
1696
1664
  }
1697
- const { ADD_SECTIONS: ts } = y, ss = {
1665
+ const { ADD_SECTIONS: es } = g, ts = {
1698
1666
  projectId: s.string().min(1).describe(
1699
1667
  'The ID of the project to search sections in. Project ID should be an ID string, or the text "inbox", for inbox tasks.'
1700
1668
  ),
1701
1669
  search: s.string().optional().describe(
1702
1670
  "Search for a section by name (partial and case insensitive match). If omitted, all sections in the project are returned."
1703
1671
  )
1704
- }, os = {
1705
- sections: s.array(te).describe("The found sections."),
1672
+ }, ss = {
1673
+ sections: s.array(ee).describe("The found sections."),
1706
1674
  totalCount: s.number().describe("The total number of sections found."),
1707
1675
  appliedFilters: s.record(s.unknown()).describe("The filters that were applied to the search.")
1708
- }, ns = {
1709
- name: y.FIND_SECTIONS,
1676
+ }, os = {
1677
+ name: g.FIND_SECTIONS,
1710
1678
  description: "Search for sections by name or other criteria in a project.",
1711
- parameters: ss,
1712
- outputSchema: os,
1679
+ parameters: ts,
1680
+ outputSchema: ss,
1713
1681
  async execute(e, t) {
1714
1682
  const o = e.projectId === "inbox" ? (await t.getUser()).inboxProjectId : e.projectId, { results: n } = await t.getSections({
1715
1683
  projectId: o
1716
- }), r = e.search ? e.search.toLowerCase() : void 0, a = (r ? n.filter((d) => d.name.toLowerCase().includes(r)) : n).map((d) => ({
1717
- id: d.id,
1718
- name: d.name
1719
- })), c = rs({
1720
- sections: a,
1721
- projectId: e.projectId,
1722
- search: e.search
1723
- });
1724
- return T({
1725
- textContent: c,
1684
+ }), r = e.search ? e.search.toLowerCase() : void 0, c = (r ? n.filter((d) => d.name.toLowerCase().includes(r)) : n).map(({ id: d, name: l }) => ({ id: d, name: l }));
1685
+ return {
1686
+ textContent: ns({
1687
+ sections: c,
1688
+ projectId: e.projectId,
1689
+ search: e.search
1690
+ }),
1726
1691
  structuredContent: {
1727
- sections: a,
1728
- totalCount: a.length,
1692
+ sections: c,
1693
+ totalCount: c.length,
1729
1694
  appliedFilters: e
1730
1695
  }
1731
- });
1696
+ };
1732
1697
  }
1733
1698
  };
1734
- function rs({
1699
+ function ns({
1735
1700
  sections: e,
1736
1701
  projectId: t,
1737
1702
  search: o
1738
1703
  }) {
1739
1704
  const n = [];
1740
- o ? (n.push("Try broader search terms"), n.push("Check spelling"), n.push("Remove search to see all sections")) : (n.push("Project has no sections yet"), n.push(`Use ${ts} to create sections`));
1741
- const r = o ? `Sections in project ${t} matching "${o}"` : `Sections in project ${t}`, i = e.length > 0 ? e.map((a) => ` ${a.name} • id=${a.id}`).join(`
1705
+ o ? (n.push("Try broader search terms"), n.push("Check spelling"), n.push("Remove search to see all sections")) : (n.push("Project has no sections yet"), n.push(`Use ${es} to create sections`));
1706
+ const r = o ? `Sections in project ${t} matching "${o}"` : `Sections in project ${t}`, i = e.length > 0 ? e.map((c) => ` ${c.name} • id=${c.id}`).join(`
1742
1707
  `) : void 0;
1743
1708
  return N({
1744
1709
  subject: r,
@@ -1747,7 +1712,7 @@ function rs({
1747
1712
  zeroReasonHints: n
1748
1713
  });
1749
1714
  }
1750
- const { FIND_COMPLETED_TASKS: de, ADD_TASKS: le } = y, is = {
1715
+ const { FIND_COMPLETED_TASKS: ce, ADD_TASKS: de } = g, rs = {
1751
1716
  searchText: s.string().optional().describe("The text to search for in tasks."),
1752
1717
  projectId: s.string().optional().describe(
1753
1718
  'Find tasks in this project. Project ID should be an ID string, or the text "inbox", for inbox tasks.'
@@ -1755,144 +1720,142 @@ const { FIND_COMPLETED_TASKS: de, ADD_TASKS: le } = y, is = {
1755
1720
  sectionId: s.string().optional().describe("Find tasks in this section."),
1756
1721
  parentId: s.string().optional().describe("Find subtasks of this parent task."),
1757
1722
  responsibleUser: s.string().optional().describe("Find tasks assigned to this user. Can be a user ID, name, or email address."),
1758
- responsibleUserFiltering: s.enum(ge).optional().describe(
1723
+ responsibleUserFiltering: s.enum(be).optional().describe(
1759
1724
  'How to filter by responsible user when responsibleUser is not provided. "assigned" = only tasks assigned to others; "unassignedOrMe" = only unassigned tasks or tasks assigned to me; "all" = all tasks regardless of assignment. Default value will be `unassignedOrMe`.'
1760
1725
  ),
1761
- limit: s.number().int().min(1).max(v.TASKS_MAX).default(v.TASKS_DEFAULT).describe("The maximum number of tasks to return."),
1726
+ limit: s.number().int().min(1).max(S.TASKS_MAX).default(S.TASKS_DEFAULT).describe("The maximum number of tasks to return."),
1762
1727
  cursor: s.string().optional().describe(
1763
1728
  "The cursor to get the next page of tasks (cursor is obtained from the previous call to this tool, with the same parameters)."
1764
1729
  ),
1765
- ...ie
1766
- }, as = {
1730
+ ...re
1731
+ }, is = {
1767
1732
  tasks: s.array(W).describe("The found tasks."),
1768
1733
  nextCursor: s.string().optional().describe("Cursor for the next page of results."),
1769
1734
  totalCount: s.number().describe("The total number of tasks in this page."),
1770
1735
  hasMore: s.boolean().describe("Whether there are more results available."),
1771
1736
  appliedFilters: s.record(s.unknown()).describe("The filters that were applied to the search.")
1772
- }, cs = {
1773
- name: y.FIND_TASKS,
1737
+ }, as = {
1738
+ name: g.FIND_TASKS,
1774
1739
  description: "Find tasks by text search, or by project/section/parent container/responsible user. At least one filter must be provided.",
1775
- parameters: is,
1776
- outputSchema: as,
1740
+ parameters: rs,
1741
+ outputSchema: is,
1777
1742
  async execute(e, t) {
1778
1743
  const {
1779
1744
  searchText: o,
1780
1745
  projectId: n,
1781
1746
  sectionId: r,
1782
1747
  parentId: i,
1783
- responsibleUser: a,
1784
- responsibleUserFiltering: c,
1748
+ responsibleUser: c,
1749
+ responsibleUserFiltering: a,
1785
1750
  limit: d,
1786
1751
  cursor: l,
1787
1752
  labels: u,
1788
1753
  labelsOperator: p
1789
1754
  } = e, b = await t.getUser(), m = u && u.length > 0;
1790
- if (!o && !n && !r && !i && !a && !m)
1755
+ if (!o && !n && !r && !i && !c && !m)
1791
1756
  throw new Error(
1792
1757
  "At least one filter must be provided: searchText, projectId, sectionId, parentId, responsibleUser, or labels"
1793
1758
  );
1794
- const k = await oe(t, a), j = k?.userId, S = k?.email;
1759
+ const y = await se(t, c), k = y?.userId, w = y?.email;
1795
1760
  if (n || r || i) {
1796
- const g = {
1761
+ const f = {
1797
1762
  limit: d,
1798
1763
  cursor: l ?? null
1799
1764
  };
1800
- n && (g.projectId = n === "inbox" ? b.inboxProjectId : n), r && (g.sectionId = r), i && (g.parentId = i);
1801
- const { results: f, nextCursor: $ } = await t.getTasks(g), A = f.map(O);
1802
- let D = o ? A.filter(
1765
+ n && (f.projectId = n === "inbox" ? b.inboxProjectId : n), r && (f.sectionId = r), i && (f.parentId = i);
1766
+ const { results: j, nextCursor: $ } = await t.getTasks(f), x = j.map(O);
1767
+ let E = o ? x.filter(
1803
1768
  (M) => M.content.toLowerCase().includes(o.toLowerCase()) || M.description?.toLowerCase().includes(o.toLowerCase())
1804
- ) : A;
1805
- D = ce({
1806
- tasks: D,
1807
- resolvedAssigneeId: j,
1769
+ ) : x;
1770
+ return E = ae({
1771
+ tasks: E,
1772
+ resolvedAssigneeId: k,
1808
1773
  currentUserId: b.id,
1809
- responsibleUserFiltering: c
1810
- }), u && u.length > 0 && (D = p === "and" ? D.filter(
1774
+ responsibleUserFiltering: a
1775
+ }), u && u.length > 0 && (E = p === "and" ? E.filter(
1811
1776
  (M) => u.every((H) => M.labels.includes(H))
1812
- ) : D.filter(
1777
+ ) : E.filter(
1813
1778
  (M) => u.some((H) => M.labels.includes(H))
1814
- ));
1815
- const De = J({
1816
- tasks: D,
1817
- args: e,
1818
- nextCursor: $,
1819
- isContainerSearch: !0,
1820
- assigneeEmail: S
1821
- });
1822
- return T({
1823
- textContent: De,
1824
- structuredContent: {
1825
- tasks: D,
1779
+ )), {
1780
+ textContent: J({
1781
+ tasks: E,
1782
+ args: e,
1826
1783
  nextCursor: $,
1827
- totalCount: D.length,
1784
+ isContainerSearch: !0,
1785
+ assigneeEmail: w
1786
+ }),
1787
+ structuredContent: {
1788
+ tasks: E,
1789
+ nextCursor: $ ?? void 0,
1790
+ totalCount: E.length,
1828
1791
  hasMore: !!$,
1829
1792
  appliedFilters: e
1830
1793
  }
1831
- });
1794
+ };
1832
1795
  }
1833
- if (j && !o && !m) {
1834
- const g = await t.getTasksByFilter({
1835
- query: `assigned to: ${S}`,
1796
+ if (k && !o && !m) {
1797
+ const { results: f, nextCursor: j } = await t.getTasksByFilter({
1798
+ query: `assigned to: ${w}`,
1836
1799
  lang: "en",
1837
1800
  limit: d,
1838
1801
  cursor: l ?? null
1839
- }), f = g.results.map(O), $ = J({
1840
- tasks: f,
1841
- args: e,
1842
- nextCursor: g.nextCursor,
1843
- isContainerSearch: !1,
1844
- assigneeEmail: S
1845
- });
1846
- return T({
1847
- textContent: $,
1802
+ }), $ = f.map(O);
1803
+ return {
1804
+ textContent: J({
1805
+ tasks: $,
1806
+ args: e,
1807
+ nextCursor: j,
1808
+ isContainerSearch: !1,
1809
+ assigneeEmail: w
1810
+ }),
1848
1811
  structuredContent: {
1849
- tasks: f,
1850
- nextCursor: g.nextCursor,
1851
- totalCount: f.length,
1852
- hasMore: !!g.nextCursor,
1812
+ tasks: $,
1813
+ nextCursor: j ?? void 0,
1814
+ totalCount: $.length,
1815
+ hasMore: !!j,
1853
1816
  appliedFilters: e
1854
1817
  }
1855
- });
1818
+ };
1856
1819
  }
1857
- let x = "";
1858
- o && (x = `search: ${o}`);
1859
- const E = ae(u, p);
1860
- x = z(x, E);
1861
- const h = await ne({
1820
+ let D = "";
1821
+ o && (D = `search: ${o}`);
1822
+ const P = ie(u, p);
1823
+ D = z(D, P);
1824
+ const { tasks: h, nextCursor: T } = await oe({
1862
1825
  client: t,
1863
- query: x,
1826
+ query: D,
1864
1827
  cursor: e.cursor,
1865
1828
  limit: e.limit
1866
- }), I = ce({
1867
- tasks: h.tasks,
1868
- resolvedAssigneeId: j,
1829
+ }), C = ae({
1830
+ tasks: h,
1831
+ resolvedAssigneeId: k,
1869
1832
  currentUserId: b.id,
1870
- responsibleUserFiltering: c
1871
- }), C = J({
1872
- tasks: I,
1873
- args: e,
1874
- nextCursor: h.nextCursor,
1875
- isContainerSearch: !1,
1876
- assigneeEmail: S
1833
+ responsibleUserFiltering: a
1877
1834
  });
1878
- return T({
1879
- textContent: C,
1835
+ return {
1836
+ textContent: J({
1837
+ tasks: C,
1838
+ args: e,
1839
+ nextCursor: T,
1840
+ isContainerSearch: !1,
1841
+ assigneeEmail: w
1842
+ }),
1880
1843
  structuredContent: {
1881
- tasks: I,
1882
- nextCursor: h.nextCursor,
1883
- totalCount: I.length,
1884
- hasMore: !!h.nextCursor,
1844
+ tasks: C,
1845
+ nextCursor: T ?? void 0,
1846
+ totalCount: h.length,
1847
+ hasMore: !!T,
1885
1848
  appliedFilters: e
1886
1849
  }
1887
- });
1850
+ };
1888
1851
  }
1889
1852
  };
1890
- function ds(e) {
1853
+ function cs(e) {
1891
1854
  if (e.projectId) {
1892
1855
  const t = [
1893
1856
  e.searchText ? "No tasks in project match search" : "Project has no tasks yet"
1894
1857
  ];
1895
- return e.searchText || t.push(`Use ${le} to create tasks`), t;
1858
+ return e.searchText || t.push(`Use ${de} to create tasks`), t;
1896
1859
  }
1897
1860
  if (e.sectionId) {
1898
1861
  const t = [e.searchText ? "No tasks in section match search" : "Section is empty"];
@@ -1900,7 +1863,7 @@ function ds(e) {
1900
1863
  }
1901
1864
  if (e.parentId) {
1902
1865
  const t = [e.searchText ? "No subtasks match search" : "No subtasks created yet"];
1903
- return e.searchText || t.push(`Use ${le} with parentId to add subtasks`), t;
1866
+ return e.searchText || t.push(`Use ${de} with parentId to add subtasks`), t;
1904
1867
  }
1905
1868
  return [];
1906
1869
  }
@@ -1912,33 +1875,33 @@ function J({
1912
1875
  assigneeEmail: r
1913
1876
  }) {
1914
1877
  let i = "Tasks";
1915
- const a = [], c = [];
1878
+ const c = [], a = [];
1916
1879
  if (n) {
1917
- if (t.projectId ? (i = "Tasks in project", a.push(`in project ${t.projectId}`)) : t.sectionId ? (i = "Tasks in section", a.push(`in section ${t.sectionId}`)) : t.parentId ? (i = "Subtasks", a.push(`subtasks of ${t.parentId}`)) : i = "Tasks", t.searchText && (i += ` matching "${t.searchText}"`, a.push(`containing "${t.searchText}"`)), t.responsibleUser) {
1880
+ if (t.projectId ? (i = "Tasks in project", c.push(`in project ${t.projectId}`)) : t.sectionId ? (i = "Tasks in section", c.push(`in section ${t.sectionId}`)) : t.parentId ? (i = "Subtasks", c.push(`subtasks of ${t.parentId}`)) : i = "Tasks", t.searchText && (i += ` matching "${t.searchText}"`, c.push(`containing "${t.searchText}"`)), t.responsibleUser) {
1918
1881
  const d = r || t.responsibleUser;
1919
- i += ` assigned to ${d}`, a.push(`assigned to ${d}`);
1882
+ i += ` assigned to ${d}`, c.push(`assigned to ${d}`);
1920
1883
  }
1921
1884
  if (t.labels && t.labels.length > 0) {
1922
1885
  const d = t.labels.map((l) => `@${l}`).join(t.labelsOperator === "and" ? " & " : " | ");
1923
- a.push(`labels: ${d}`);
1886
+ c.push(`labels: ${d}`);
1924
1887
  }
1925
- e.length === 0 && c.push(...ds(t));
1888
+ e.length === 0 && a.push(...cs(t));
1926
1889
  } else {
1927
1890
  const d = r || t.responsibleUser, l = [];
1928
1891
  if (t.searchText && l.push(`"${t.searchText}"`), t.responsibleUser && l.push(`assigned to ${d}`), t.labels && t.labels.length > 0) {
1929
1892
  const u = t.labels.map((p) => `@${p}`).join(t.labelsOperator === "and" ? " & " : " | ");
1930
1893
  l.push(`with labels: ${u}`);
1931
1894
  }
1932
- if (t.searchText ? (i = `Search results for ${l.join(" ")}`, a.push(`matching "${t.searchText}"`)) : t.responsibleUser && (!t.labels || t.labels.length === 0) ? i = `Tasks assigned to ${d}` : t.labels && t.labels.length > 0 && !t.responsibleUser ? i = `Tasks with labels: ${t.labels.map((p) => `@${p}`).join(t.labelsOperator === "and" ? " & " : " | ")}` : i = `Tasks ${l.join(" ")}`, t.responsibleUser && a.push(`assigned to ${d}`), t.labels && t.labels.length > 0) {
1895
+ if (t.searchText ? (i = `Search results for ${l.join(" ")}`, c.push(`matching "${t.searchText}"`)) : t.responsibleUser && (!t.labels || t.labels.length === 0) ? i = `Tasks assigned to ${d}` : t.labels && t.labels.length > 0 && !t.responsibleUser ? i = `Tasks with labels: ${t.labels.map((p) => `@${p}`).join(t.labelsOperator === "and" ? " & " : " | ")}` : i = `Tasks ${l.join(" ")}`, t.responsibleUser && c.push(`assigned to ${d}`), t.labels && t.labels.length > 0) {
1933
1896
  const u = t.labels.map((p) => `@${p}`).join(t.labelsOperator === "and" ? " & " : " | ");
1934
- a.push(`labels: ${u}`);
1897
+ c.push(`labels: ${u}`);
1935
1898
  }
1936
1899
  if (e.length === 0) {
1937
1900
  if (t.responsibleUser) {
1938
1901
  const u = r || t.responsibleUser;
1939
- c.push(`No tasks assigned to ${u}`), c.push("Check if the user name is correct"), c.push(`Check completed tasks with ${de}`);
1902
+ a.push(`No tasks assigned to ${u}`), a.push("Check if the user name is correct"), a.push(`Check completed tasks with ${ce}`);
1940
1903
  }
1941
- t.searchText && (c.push("Try broader search terms"), c.push("Verify spelling and try partial words"), t.responsibleUser || c.push(`Check completed tasks with ${de}`));
1904
+ t.searchText && (a.push("Try broader search terms"), a.push("Verify spelling and try partial words"), t.responsibleUser || a.push(`Check completed tasks with ${ce}`));
1942
1905
  }
1943
1906
  }
1944
1907
  return N({
@@ -1946,12 +1909,12 @@ function J({
1946
1909
  count: e.length,
1947
1910
  limit: t.limit,
1948
1911
  nextCursor: o ?? void 0,
1949
- filterHints: a,
1912
+ filterHints: c,
1950
1913
  previewLines: V(e, Math.min(e.length, t.limit)),
1951
- zeroReasonHints: c
1914
+ zeroReasonHints: a
1952
1915
  });
1953
1916
  }
1954
- const ls = {
1917
+ const ds = {
1955
1918
  startDate: s.string().regex(/^(\d{4}-\d{2}-\d{2}|today)$/).optional().describe("The start date to get the tasks for. Format: YYYY-MM-DD or 'today'."),
1956
1919
  overdueOption: s.enum(["overdue-only", "include-overdue", "exclude-overdue"]).optional().describe(
1957
1920
  "How to handle overdue tasks. 'overdue-only' to get only overdue tasks, 'include-overdue' to include overdue tasks along with tasks for the specified date(s), and 'exclude-overdue' to exclude overdue tasks. Default is 'include-overdue'."
@@ -1959,73 +1922,68 @@ const ls = {
1959
1922
  daysCount: s.number().int().min(1).max(30).default(1).describe(
1960
1923
  "The number of days to get the tasks for, starting from the start date. Default is 1 which means only tasks for the start date."
1961
1924
  ),
1962
- limit: s.number().int().min(1).max(v.TASKS_MAX).default(v.TASKS_DEFAULT).describe("The maximum number of tasks to return."),
1925
+ limit: s.number().int().min(1).max(S.TASKS_MAX).default(S.TASKS_DEFAULT).describe("The maximum number of tasks to return."),
1963
1926
  cursor: s.string().optional().describe(
1964
1927
  "The cursor to get the next page of tasks (cursor is obtained from the previous call to this tool, with the same parameters)."
1965
1928
  ),
1966
1929
  responsibleUser: s.string().optional().describe("Find tasks assigned to this user. Can be a user ID, name, or email address."),
1967
- responsibleUserFiltering: s.enum(ge).optional().describe(
1930
+ responsibleUserFiltering: s.enum(be).optional().describe(
1968
1931
  'How to filter by responsible user when responsibleUser is not provided. "assigned" = only tasks assigned to others; "unassignedOrMe" = only unassigned tasks or tasks assigned to me; "all" = all tasks regardless of assignment. Default is "unassignedOrMe".'
1969
1932
  ),
1970
- ...ie
1971
- }, us = {
1933
+ ...re
1934
+ }, ls = {
1972
1935
  tasks: s.array(W).describe("The found tasks."),
1973
1936
  nextCursor: s.string().optional().describe("Cursor for the next page of results."),
1974
1937
  totalCount: s.number().describe("The total number of tasks in this page."),
1975
1938
  hasMore: s.boolean().describe("Whether there are more results available."),
1976
1939
  appliedFilters: s.record(s.unknown()).describe("The filters that were applied to the search.")
1977
- }, ps = {
1978
- name: y.FIND_TASKS_BY_DATE,
1940
+ }, us = {
1941
+ name: g.FIND_TASKS_BY_DATE,
1979
1942
  description: "Get tasks by date range. Use startDate 'today' to get today's tasks including overdue items, or provide a specific date/date range.",
1980
- parameters: ls,
1981
- outputSchema: us,
1943
+ parameters: ds,
1944
+ outputSchema: ls,
1982
1945
  async execute(e, t) {
1983
1946
  if (!e.startDate && e.overdueOption !== "overdue-only")
1984
1947
  throw new Error(
1985
1948
  "Either startDate must be provided or overdueOption must be set to overdue-only"
1986
1949
  );
1987
- const o = await oe(t, e.responsibleUser), n = o?.userId, r = o?.email;
1950
+ const o = await se(t, e.responsibleUser), n = o?.userId, r = o?.email;
1988
1951
  let i = "";
1989
1952
  if (e.overdueOption === "overdue-only")
1990
1953
  i = "overdue";
1991
1954
  else if (e.startDate === "today")
1992
1955
  i = e.overdueOption === "exclude-overdue" ? "today" : "(today | overdue)";
1993
1956
  else if (e.startDate) {
1994
- const p = e.startDate, b = fe(p, e.daysCount), m = Ue(b, { representation: "date" });
1957
+ const p = e.startDate, b = me(p, e.daysCount), m = xe(b, { representation: "date" });
1995
1958
  i = `(due after: ${p} | due: ${p}) & due before: ${m}`;
1996
1959
  }
1997
- const a = ae(e.labels, e.labelsOperator);
1998
- a.length > 0 && (i = z(i, `(${a})`));
1999
- const c = tt({
1960
+ const c = ie(e.labels, e.labelsOperator);
1961
+ c.length > 0 && (i = z(i, `(${c})`));
1962
+ const a = tt({
2000
1963
  resolvedAssigneeId: n,
2001
1964
  assigneeEmail: r,
2002
1965
  responsibleUserFiltering: e.responsibleUserFiltering
2003
1966
  });
2004
- i = z(i, c);
2005
- const d = await ne({
1967
+ i = z(i, a);
1968
+ const { tasks: d, nextCursor: l } = await oe({
2006
1969
  client: t,
2007
1970
  query: i,
2008
1971
  cursor: e.cursor,
2009
1972
  limit: e.limit
2010
- }), l = d.tasks, u = hs({
2011
- tasks: l,
2012
- args: e,
2013
- nextCursor: d.nextCursor,
2014
- assigneeEmail: r
2015
1973
  });
2016
- return T({
2017
- textContent: u,
1974
+ return {
1975
+ textContent: ps({ tasks: d, args: e, nextCursor: l, assigneeEmail: r }),
2018
1976
  structuredContent: {
2019
- tasks: l,
2020
- nextCursor: d.nextCursor,
2021
- totalCount: l.length,
2022
- hasMore: !!d.nextCursor,
1977
+ tasks: d,
1978
+ nextCursor: l ?? void 0,
1979
+ totalCount: d.length,
1980
+ hasMore: !!l,
2023
1981
  appliedFilters: e
2024
1982
  }
2025
- });
1983
+ };
2026
1984
  }
2027
1985
  };
2028
- function hs({
1986
+ function ps({
2029
1987
  tasks: e,
2030
1988
  args: t,
2031
1989
  nextCursor: o,
@@ -2035,36 +1993,36 @@ function hs({
2035
1993
  if (t.overdueOption === "overdue-only")
2036
1994
  r.push("overdue tasks only");
2037
1995
  else if (t.startDate === "today") {
2038
- const c = t.overdueOption === "exclude-overdue" ? "" : " + overdue tasks";
1996
+ const a = t.overdueOption === "exclude-overdue" ? "" : " + overdue tasks";
2039
1997
  r.push(
2040
- `today${c}${t.daysCount > 1 ? ` + ${t.daysCount - 1} more days` : ""}`
1998
+ `today${a}${t.daysCount > 1 ? ` + ${t.daysCount - 1} more days` : ""}`
2041
1999
  );
2042
2000
  } else if (t.startDate) {
2043
- const c = t.daysCount > 1 ? ` to ${ct(fe(t.startDate, t.daysCount))}` : "";
2044
- r.push(`${t.startDate}${c}`);
2001
+ const a = t.daysCount > 1 ? ` to ${ct(me(t.startDate, t.daysCount))}` : "";
2002
+ r.push(`${t.startDate}${a}`);
2045
2003
  }
2046
2004
  if (t.labels && t.labels.length > 0) {
2047
- const c = t.labels.map((d) => `@${d}`).join(t.labelsOperator === "and" ? " & " : " | ");
2048
- r.push(`labels: ${c}`);
2005
+ const a = t.labels.map((d) => `@${d}`).join(t.labelsOperator === "and" ? " & " : " | ");
2006
+ r.push(`labels: ${a}`);
2049
2007
  }
2050
2008
  if (t.responsibleUser) {
2051
- const c = n || t.responsibleUser;
2052
- r.push(`assigned to: ${c}`);
2009
+ const a = n || t.responsibleUser;
2010
+ r.push(`assigned to: ${a}`);
2053
2011
  }
2054
2012
  let i = "";
2055
2013
  if (t.overdueOption === "overdue-only" ? i = "Overdue tasks" : t.startDate === "today" ? i = t.overdueOption === "exclude-overdue" ? "Today's tasks" : "Today's tasks + overdue" : t.startDate ? i = `Tasks for ${t.startDate}` : i = "Tasks", t.responsibleUser) {
2056
- const c = n || t.responsibleUser;
2057
- i += ` assigned to ${c}`;
2014
+ const a = n || t.responsibleUser;
2015
+ i += ` assigned to ${a}`;
2058
2016
  }
2059
- const a = [];
2017
+ const c = [];
2060
2018
  if (e.length === 0)
2061
2019
  if (t.overdueOption === "overdue-only")
2062
- a.push("Great job! No overdue tasks");
2020
+ c.push("Great job! No overdue tasks");
2063
2021
  else if (t.startDate === "today") {
2064
- const c = t.overdueOption === "exclude-overdue" ? "" : " or overdue";
2065
- a.push(`Great job! No tasks for today${c}`);
2022
+ const a = t.overdueOption === "exclude-overdue" ? "" : " or overdue";
2023
+ c.push(`Great job! No tasks for today${a}`);
2066
2024
  } else
2067
- a.push("Expand date range with larger 'daysCount'"), a.push("Check today's tasks with startDate='today'");
2025
+ c.push("Expand date range with larger 'daysCount'"), c.push("Check today's tasks with startDate='today'");
2068
2026
  return N({
2069
2027
  subject: i,
2070
2028
  count: e.length,
@@ -2072,17 +2030,17 @@ function hs({
2072
2030
  nextCursor: o ?? void 0,
2073
2031
  filterHints: r,
2074
2032
  previewLines: V(e, Math.min(e.length, t.limit)),
2075
- zeroReasonHints: a
2033
+ zeroReasonHints: c
2076
2034
  });
2077
2035
  }
2078
- const ms = {
2036
+ const hs = {
2079
2037
  projectId: s.string().min(1).optional().describe(
2080
2038
  "Optional project ID. If provided, shows detailed overview of that project. If omitted, shows overview of all projects."
2081
2039
  )
2082
- }, fs = {
2040
+ }, ms = {
2083
2041
  type: s.enum(["account_overview", "project_overview"]).describe("The type of overview returned."),
2084
2042
  totalProjects: s.number().optional().describe("Total number of projects (account overview only)."),
2085
- totalTasks: s.number().describe("Total number of tasks."),
2043
+ totalTasks: s.number().optional().describe("Total number of tasks."),
2086
2044
  totalSections: s.number().optional().describe("Total number of sections (project overview only)."),
2087
2045
  tasksWithoutSection: s.number().optional().describe("Number of tasks not in any section (project overview only)."),
2088
2046
  projectInfo: s.object({
@@ -2090,9 +2048,17 @@ const ms = {
2090
2048
  name: s.string(),
2091
2049
  isShared: s.boolean(),
2092
2050
  isFavorite: s.boolean()
2093
- }).optional().describe("Project information (project overview only).")
2051
+ }).optional().describe("Project information (project overview only)."),
2052
+ // Additional fields that exist in structured outputs
2053
+ hasNestedProjects: s.boolean().optional().describe("Whether account has nested projects (account overview only)."),
2054
+ inbox: s.any().optional().describe("Inbox information (account overview only)."),
2055
+ projects: s.array(s.any()).optional().describe("List of projects (account overview only)."),
2056
+ project: s.any().optional().describe("Project details (project overview only)."),
2057
+ sections: s.array(s.any()).optional().describe("List of sections (project overview only)."),
2058
+ tasks: s.array(s.any()).optional().describe("List of tasks (project overview only)."),
2059
+ stats: s.any().optional().describe("Statistics object (project overview only).")
2094
2060
  };
2095
- function bs(e) {
2061
+ function fs(e) {
2096
2062
  const t = {};
2097
2063
  for (const r of e)
2098
2064
  t[r.id] = {
@@ -2105,19 +2071,19 @@ function bs(e) {
2105
2071
  const i = t[r.id];
2106
2072
  if (i)
2107
2073
  if (B(r) && r.parentId) {
2108
- const a = t[r.parentId];
2109
- a ? a.children.push(i) : o.push(i);
2074
+ const c = t[r.parentId];
2075
+ c ? c.children.push(i) : o.push(i);
2110
2076
  } else
2111
2077
  o.push(i);
2112
2078
  }
2113
2079
  function n(r) {
2114
- r.sort((i, a) => i.childOrder - a.childOrder);
2080
+ r.sort((i, c) => i.childOrder - c.childOrder);
2115
2081
  for (const i of r)
2116
2082
  n(i.children);
2117
2083
  }
2118
2084
  return n(o), o;
2119
2085
  }
2120
- async function gs(e, t) {
2086
+ async function bs(e, t) {
2121
2087
  const o = {};
2122
2088
  return await Promise.all(
2123
2089
  t.map(async (n) => {
@@ -2126,17 +2092,17 @@ async function gs(e, t) {
2126
2092
  })
2127
2093
  ), o;
2128
2094
  }
2129
- function Se(e, t, o = "") {
2095
+ function ve(e, t, o = "") {
2130
2096
  const n = [];
2131
2097
  n.push(`${o}- Project: ${e.name} (id=${e.id})`);
2132
2098
  const r = t[e.id] || [];
2133
2099
  for (const i of r)
2134
2100
  n.push(`${o} - Section: ${i.name} (id=${i.id})`);
2135
2101
  for (const i of e.children)
2136
- n.push(...Se(i, t, `${o} `));
2102
+ n.push(...ve(i, t, `${o} `));
2137
2103
  return n;
2138
2104
  }
2139
- function ue(e) {
2105
+ function le(e) {
2140
2106
  const t = {};
2141
2107
  for (const n of e)
2142
2108
  t[n.id] = { ...n, children: [] };
@@ -2156,8 +2122,8 @@ function ue(e) {
2156
2122
  function Z(e, t = "") {
2157
2123
  const o = [];
2158
2124
  for (const n of e) {
2159
- const r = `id=${n.id}`, i = n.dueDate ? `; due=${n.dueDate}` : "", a = `; content=${n.content}`;
2160
- o.push(`${t}- ${r}${i}${a}`), n.children.length > 0 && o.push(...Z(n.children, `${t} `));
2125
+ const r = `id=${n.id}`, i = n.dueDate ? `; due=${n.dueDate}` : "", c = `; content=${n.content}`;
2126
+ o.push(`${t}- ${r}${i}${c}`), n.children.length > 0 && o.push(...Z(n.children, `${t} `));
2161
2127
  }
2162
2128
  return o;
2163
2129
  }
@@ -2170,82 +2136,82 @@ function Ce(e, t) {
2170
2136
  children: e.children.map((o) => Ce(o, t))
2171
2137
  };
2172
2138
  }
2173
- async function Ts(e, t) {
2139
+ async function gs(e, t) {
2174
2140
  let o = [], n;
2175
2141
  do {
2176
2142
  const { results: r, nextCursor: i } = await e.getTasks({
2177
2143
  projectId: t,
2178
- limit: v.TASKS_BATCH_SIZE,
2144
+ limit: S.TASKS_BATCH_SIZE,
2179
2145
  cursor: n ?? void 0
2180
2146
  });
2181
2147
  o = o.concat(r.map(O)), n = i ?? void 0;
2182
2148
  } while (n);
2183
2149
  return o;
2184
2150
  }
2185
- async function ys(e, t) {
2151
+ async function Ts(e, t) {
2186
2152
  const { results: o } = await e.getSections({ projectId: t });
2187
2153
  return o;
2188
2154
  }
2189
- async function Is(e) {
2190
- const { results: t } = await e.getProjects({}), o = t.find((p) => B(p) && p.inboxProject === !0), n = t.filter((p) => !B(p) || p.inboxProject !== !0), r = bs(n), i = t.map((p) => p.id), a = await gs(e, i), c = ["# Personal Projects", ""];
2155
+ async function ys(e) {
2156
+ const { results: t } = await e.getProjects({}), o = t.find((p) => B(p) && p.inboxProject === !0), n = t.filter((p) => !B(p) || p.inboxProject !== !0), r = fs(n), i = t.map((p) => p.id), c = await bs(e, i), a = ["# Personal Projects", ""];
2191
2157
  if (o) {
2192
- c.push(`- Inbox Project: ${o.name} (id=${o.id})`);
2193
- for (const p of a[o.id] || [])
2194
- c.push(` - Section: ${p.name} (id=${p.id})`);
2158
+ a.push(`- Inbox Project: ${o.name} (id=${o.id})`);
2159
+ for (const p of c[o.id] || [])
2160
+ a.push(` - Section: ${p.name} (id=${p.id})`);
2195
2161
  }
2196
2162
  if (r.length)
2197
2163
  for (const p of r)
2198
- c.push(...Se(p, a));
2164
+ a.push(...ve(p, c));
2199
2165
  else
2200
- c.push("_No projects found._");
2201
- c.push("");
2166
+ a.push("_No projects found._");
2167
+ a.push("");
2202
2168
  const d = r.some((p) => p.children.length > 0);
2203
- d && c.push(
2169
+ d && a.push(
2204
2170
  "_Note: Indentation indicates that a project is a sub-project of the one above it. This allows for organizing projects hierarchically, with parent projects containing related sub-projects._",
2205
2171
  ""
2206
2172
  );
2207
- const l = c.join(`
2173
+ const l = a.join(`
2208
2174
  `), u = {
2209
2175
  type: "account_overview",
2210
2176
  inbox: o ? {
2211
2177
  id: o.id,
2212
2178
  name: o.name,
2213
- sections: a[o.id] || []
2179
+ sections: c[o.id] || []
2214
2180
  } : null,
2215
2181
  projects: r.map(
2216
- (p) => Ce(p, a)
2182
+ (p) => Ce(p, c)
2217
2183
  ),
2218
2184
  totalProjects: t.length,
2219
2185
  totalSections: i.reduce(
2220
- (p, b) => p + (a[b]?.length || 0),
2186
+ (p, b) => p + (c[b]?.length || 0),
2221
2187
  0
2222
2188
  ),
2223
2189
  hasNestedProjects: d
2224
2190
  };
2225
2191
  return { textContent: l, structuredContent: u };
2226
2192
  }
2227
- async function ks(e, t) {
2228
- const o = await e.getProject(t), n = await ys(e, t), r = await Ts(e, t), i = {};
2193
+ async function Is(e, t) {
2194
+ const o = await e.getProject(t), n = await Ts(e, t), r = await gs(e, t), i = {};
2229
2195
  for (const u of n)
2230
2196
  i[u.id] = [];
2231
- const a = [];
2197
+ const c = [];
2232
2198
  for (const u of r)
2233
- (u.sectionId ? i[u.sectionId] ?? a : a).push(u);
2234
- const c = [`# ${o.name}`];
2235
- if (a.length > 0) {
2236
- c.push("");
2237
- const u = ue(a);
2238
- c.push(...Z(u));
2199
+ (u.sectionId ? i[u.sectionId] ?? c : c).push(u);
2200
+ const a = [`# ${o.name}`];
2201
+ if (c.length > 0) {
2202
+ a.push("");
2203
+ const u = le(c);
2204
+ a.push(...Z(u));
2239
2205
  }
2240
2206
  for (const u of n) {
2241
- c.push(""), c.push(`## ${u.name}`);
2207
+ a.push(""), a.push(`## ${u.name}`);
2242
2208
  const p = i[u.id];
2243
2209
  if (!p?.length)
2244
2210
  continue;
2245
- const b = ue(p);
2246
- c.push(...Z(b));
2211
+ const b = le(p);
2212
+ a.push(...Z(b));
2247
2213
  }
2248
- const d = c.join(`
2214
+ const d = a.join(`
2249
2215
  `), l = {
2250
2216
  type: "project_overview",
2251
2217
  project: {
@@ -2261,26 +2227,26 @@ async function ks(e, t) {
2261
2227
  stats: {
2262
2228
  totalTasks: r.length,
2263
2229
  totalSections: n.length,
2264
- tasksWithoutSection: a.length
2230
+ tasksWithoutSection: c.length
2265
2231
  }
2266
2232
  };
2267
2233
  return { textContent: d, structuredContent: l };
2268
2234
  }
2269
- const ws = {
2270
- name: y.GET_OVERVIEW,
2235
+ const ks = {
2236
+ name: g.GET_OVERVIEW,
2271
2237
  description: "Get a Markdown overview. If no projectId is provided, shows all projects with hierarchy and sections (useful for navigation). If projectId is provided, shows detailed overview of that specific project including all tasks grouped by sections.",
2272
- parameters: ms,
2273
- outputSchema: fs,
2238
+ parameters: hs,
2239
+ outputSchema: ms,
2274
2240
  async execute(e, t) {
2275
- const o = e.projectId ? await ks(t, e.projectId) : await Is(t);
2276
- return T({
2241
+ const o = e.projectId ? await Is(t, e.projectId) : await ys(t);
2242
+ return {
2277
2243
  textContent: o.textContent,
2278
2244
  structuredContent: o.structuredContent
2279
- });
2245
+ };
2280
2246
  }
2281
- }, { FIND_TASKS: js, FIND_PROJECT_COLLABORATORS: pe, UPDATE_TASKS: $s } = y, Ss = 50, Cs = {
2247
+ }, { FIND_TASKS: ws, FIND_PROJECT_COLLABORATORS: ue, UPDATE_TASKS: js } = g, vs = 50, Cs = {
2282
2248
  operation: s.enum(["assign", "unassign", "reassign"]).describe("The assignment operation to perform."),
2283
- taskIds: s.array(s.string()).min(1).max(Ss).describe("The IDs of the tasks to operate on (max 50)."),
2249
+ taskIds: s.array(s.string()).min(1).max(vs).describe("The IDs of the tasks to operate on (max 50)."),
2284
2250
  responsibleUser: s.string().optional().describe(
2285
2251
  "The user to assign tasks to. Can be user ID, name, or email. Required for assign and reassign operations."
2286
2252
  ),
@@ -2288,7 +2254,7 @@ const ws = {
2288
2254
  "For reassign operations: the current assignee to reassign from. Can be user ID, name, or email. Optional - if not provided, reassigns from any current assignee."
2289
2255
  ),
2290
2256
  dryRun: s.boolean().optional().default(!1).describe("If true, validates operations without executing them.")
2291
- }, vs = {
2257
+ }, $s = {
2292
2258
  results: s.array(
2293
2259
  s.object({
2294
2260
  taskId: s.string().describe("The ID of the task."),
@@ -2303,17 +2269,17 @@ const ws = {
2303
2269
  succeeded: s.number().describe("Number of successful operations."),
2304
2270
  failed: s.number().describe("Number of failed operations."),
2305
2271
  dryRun: s.boolean().describe("Whether this was a dry run.")
2306
- }).describe("Summary of the operation.")
2307
- }, Ds = {
2308
- name: y.MANAGE_ASSIGNMENTS,
2272
+ }).optional().describe("Summary of the operation.")
2273
+ }, Ss = {
2274
+ name: g.MANAGE_ASSIGNMENTS,
2309
2275
  description: "Bulk assignment operations for multiple tasks. Supports assign, unassign, and reassign operations with atomic rollback on failures.",
2310
2276
  parameters: Cs,
2311
- outputSchema: vs,
2277
+ outputSchema: $s,
2312
2278
  async execute(e, t) {
2313
- const { operation: o, taskIds: n, responsibleUser: r, fromAssigneeUser: i, dryRun: a } = e;
2279
+ const { operation: o, taskIds: n, responsibleUser: r, fromAssigneeUser: i, dryRun: c } = e;
2314
2280
  if ((o === "assign" || o === "reassign") && !r)
2315
2281
  throw new Error(`${o} operation requires responsibleUser parameter`);
2316
- const c = await Promise.allSettled(
2282
+ const a = await Promise.allSettled(
2317
2283
  n.map(async (h) => {
2318
2284
  try {
2319
2285
  return await t.getTask(h);
@@ -2322,36 +2288,34 @@ const ws = {
2322
2288
  }
2323
2289
  })
2324
2290
  ), d = [], l = [];
2325
- for (let h = 0; h < c.length; h++) {
2326
- const I = c[h];
2327
- I && I.status === "fulfilled" ? d.push(I.value) : I && I.status === "rejected" ? l.push({
2291
+ for (let h = 0; h < a.length; h++) {
2292
+ const T = a[h];
2293
+ T && T.status === "fulfilled" ? d.push(T.value) : T && T.status === "rejected" ? l.push({
2328
2294
  taskId: n[h] || "invalid-task-id",
2329
2295
  success: !1,
2330
- error: I.reason?.message || "Task not accessible"
2296
+ error: T.reason?.message || "Task not accessible"
2331
2297
  }) : l.push({
2332
2298
  taskId: n[h] || "invalid-task-id",
2333
2299
  success: !1,
2334
2300
  error: "Task not accessible"
2335
2301
  });
2336
2302
  }
2337
- if (d.length === 0) {
2338
- const h = Y({
2339
- operation: o,
2340
- results: l,
2341
- dryRun: a
2342
- });
2343
- return T({
2344
- textContent: h,
2303
+ if (d.length === 0)
2304
+ return {
2305
+ textContent: Y({
2306
+ operation: o,
2307
+ results: l,
2308
+ dryRun: c
2309
+ }),
2345
2310
  structuredContent: {
2346
2311
  operation: o,
2347
2312
  results: l,
2348
2313
  totalRequested: n.length,
2349
2314
  successful: 0,
2350
2315
  failed: l.length,
2351
- dryRun: a
2316
+ dryRun: c
2352
2317
  }
2353
- });
2354
- }
2318
+ };
2355
2319
  let u;
2356
2320
  o === "reassign" && i && (u = (await _.resolveUser(t, i))?.userId || i);
2357
2321
  const p = [];
@@ -2363,19 +2327,19 @@ const ws = {
2363
2327
  // Will be validated appropriately
2364
2328
  });
2365
2329
  if (o === "unassign") {
2366
- if (a) {
2367
- const f = d.map((A) => ({
2368
- taskId: A.id,
2330
+ if (c) {
2331
+ const f = d.map(($) => ({
2332
+ taskId: $.id,
2369
2333
  success: !0,
2370
- originalAssigneeId: A.responsibleUid,
2371
- newAssigneeId: null
2372
- })), $ = Y({
2373
- operation: o,
2374
- results: f,
2375
- dryRun: !0
2376
- });
2377
- return T({
2378
- textContent: $,
2334
+ originalAssigneeId: $.responsibleUid ?? void 0,
2335
+ newAssigneeId: void 0
2336
+ }));
2337
+ return {
2338
+ textContent: Y({
2339
+ operation: o,
2340
+ results: f,
2341
+ dryRun: !0
2342
+ }),
2379
2343
  structuredContent: {
2380
2344
  operation: o,
2381
2345
  results: f,
@@ -2384,118 +2348,118 @@ const ws = {
2384
2348
  failed: l.length,
2385
2349
  dryRun: !0
2386
2350
  }
2387
- });
2351
+ };
2388
2352
  }
2389
2353
  const h = d.map(async (f) => {
2390
2354
  try {
2391
2355
  return await t.updateTask(f.id, { assigneeId: null }), {
2392
2356
  taskId: f.id,
2393
2357
  success: !0,
2394
- originalAssigneeId: f.responsibleUid,
2395
- newAssigneeId: null
2358
+ originalAssigneeId: f.responsibleUid ?? void 0,
2359
+ newAssigneeId: void 0
2396
2360
  };
2397
- } catch ($) {
2361
+ } catch (j) {
2398
2362
  return {
2399
2363
  taskId: f.id,
2400
2364
  success: !1,
2401
- error: $ instanceof Error ? $.message : "Update failed",
2402
- originalAssigneeId: f.responsibleUid
2365
+ error: j instanceof Error ? j.message : "Update failed",
2366
+ originalAssigneeId: f.responsibleUid ?? void 0
2403
2367
  };
2404
2368
  }
2405
- }), I = await Promise.all(h), C = [...I, ...l], g = Y({
2406
- operation: o,
2407
- results: C,
2408
- dryRun: !1
2409
- });
2410
- return T({
2411
- textContent: g,
2369
+ }), T = await Promise.all(h), C = [...T, ...l];
2370
+ return {
2371
+ textContent: Y({
2372
+ operation: o,
2373
+ results: C,
2374
+ dryRun: !1
2375
+ }),
2412
2376
  structuredContent: {
2413
2377
  operation: o,
2414
2378
  results: C,
2415
2379
  totalRequested: n.length,
2416
- successful: I.filter((f) => f.success).length,
2380
+ successful: T.filter((f) => f.success).length,
2417
2381
  failed: C.filter((f) => !f.success).length,
2418
2382
  dryRun: !1
2419
2383
  }
2420
- });
2384
+ };
2421
2385
  }
2422
- const b = await re.validateBulkAssignment(
2386
+ const b = await ne.validateBulkAssignment(
2423
2387
  t,
2424
2388
  p
2425
- ), m = [], k = [];
2389
+ ), m = [], y = [];
2426
2390
  for (let h = 0; h < p.length; h++) {
2427
- const I = p[h], C = b[h];
2428
- I && C && C.isValid ? m.push({ assignment: I, validation: C }) : I?.taskId && k.push({
2429
- taskId: I.taskId,
2391
+ const T = p[h], C = b[h];
2392
+ T && C && C.isValid ? m.push({ assignment: T, validation: C }) : T?.taskId && y.push({
2393
+ taskId: T.taskId,
2430
2394
  success: !1,
2431
2395
  error: C?.error?.message || "Validation failed"
2432
2396
  });
2433
2397
  }
2434
- async function j(h, I) {
2398
+ async function k(h, T) {
2435
2399
  const C = h.filter(
2436
2400
  (f) => f.assignment != null && f.validation != null
2437
2401
  );
2438
- if (!I)
2439
- return C.map(({ assignment: f, validation: $ }) => {
2440
- const A = d.find((D) => D.id === f.taskId);
2441
- if (!f.taskId || !$.resolvedUser?.userId)
2402
+ if (!T)
2403
+ return C.map(({ assignment: f, validation: j }) => {
2404
+ const $ = d.find((x) => x.id === f.taskId);
2405
+ if (!f.taskId || !j.resolvedUser?.userId)
2442
2406
  throw new Error(
2443
2407
  "Invalid assignment or validation data - this should not happen"
2444
2408
  );
2445
2409
  return {
2446
2410
  taskId: f.taskId,
2447
2411
  success: !0,
2448
- originalAssigneeId: A?.responsibleUid || null,
2449
- newAssigneeId: $.resolvedUser.userId
2412
+ originalAssigneeId: $?.responsibleUid ?? void 0,
2413
+ newAssigneeId: j.resolvedUser.userId
2450
2414
  };
2451
2415
  });
2452
- const g = C.map(
2453
- async ({ assignment: f, validation: $ }) => {
2454
- const A = d.find((D) => D.id === f.taskId);
2455
- if (!f.taskId || !$.resolvedUser?.userId)
2416
+ const v = C.map(
2417
+ async ({ assignment: f, validation: j }) => {
2418
+ const $ = d.find((x) => x.id === f.taskId);
2419
+ if (!f.taskId || !j.resolvedUser?.userId)
2456
2420
  return {
2457
2421
  taskId: f.taskId || "unknown-task",
2458
2422
  success: !1,
2459
2423
  error: "Invalid assignment data - missing task ID or resolved user",
2460
- originalAssigneeId: A?.responsibleUid || null
2424
+ originalAssigneeId: $?.responsibleUid ?? void 0
2461
2425
  };
2462
2426
  try {
2463
2427
  return await t.updateTask(f.taskId, {
2464
- assigneeId: $.resolvedUser.userId
2428
+ assigneeId: j.resolvedUser.userId
2465
2429
  }), {
2466
2430
  taskId: f.taskId,
2467
2431
  success: !0,
2468
- originalAssigneeId: A?.responsibleUid || null,
2469
- newAssigneeId: $.resolvedUser.userId
2432
+ originalAssigneeId: $?.responsibleUid ?? void 0,
2433
+ newAssigneeId: j.resolvedUser.userId
2470
2434
  };
2471
- } catch (D) {
2435
+ } catch (x) {
2472
2436
  return {
2473
2437
  taskId: f.taskId,
2474
2438
  success: !1,
2475
- error: D instanceof Error ? D.message : "Update failed",
2476
- originalAssigneeId: A?.responsibleUid || null
2439
+ error: x instanceof Error ? x.message : "Update failed",
2440
+ originalAssigneeId: $?.responsibleUid ?? void 0
2477
2441
  };
2478
2442
  }
2479
2443
  }
2480
2444
  );
2481
- return Promise.all(g);
2445
+ return Promise.all(v);
2482
2446
  }
2483
- const S = await j(m, !a), x = [...S, ...k, ...l], E = Y({
2484
- operation: o,
2485
- results: x,
2486
- dryRun: a
2487
- });
2488
- return T({
2489
- textContent: E,
2447
+ const w = await k(m, !c), D = [...w, ...y, ...l];
2448
+ return {
2449
+ textContent: Y({
2450
+ operation: o,
2451
+ results: D,
2452
+ dryRun: c
2453
+ }),
2490
2454
  structuredContent: {
2491
2455
  operation: o,
2492
- results: x,
2456
+ results: D,
2493
2457
  totalRequested: n.length,
2494
- successful: S.filter((h) => h.success).length,
2495
- failed: x.filter((h) => !h.success).length,
2496
- dryRun: a
2458
+ successful: w.filter((h) => h.success).length,
2459
+ failed: D.filter((h) => !h.success).length,
2460
+ dryRun: c
2497
2461
  }
2498
- });
2462
+ };
2499
2463
  }
2500
2464
  };
2501
2465
  function Y({
@@ -2503,55 +2467,55 @@ function Y({
2503
2467
  results: t,
2504
2468
  dryRun: o
2505
2469
  }) {
2506
- const n = t.filter((d) => d.success), r = t.filter((d) => !d.success), i = o ? "would be" : "were", a = {
2470
+ const n = t.filter((d) => d.success), r = t.filter((d) => !d.success), i = o ? "would be" : "were", c = {
2507
2471
  assign: "assigned",
2508
2472
  unassign: "unassigned",
2509
2473
  reassign: "reassigned"
2510
2474
  }[e];
2511
- let c = `**${o ? "Dry Run: " : ""}Bulk ${e} operation**
2475
+ let a = `**${o ? "Dry Run: " : ""}Bulk ${e} operation**
2512
2476
 
2513
2477
  `;
2514
2478
  if (n.length > 0) {
2515
- c += `**${n.length} task${n.length === 1 ? "" : "s"} ${i} successfully ${a}**
2479
+ a += `**${n.length} task${n.length === 1 ? "" : "s"} ${i} successfully ${c}**
2516
2480
  `;
2517
2481
  const d = n.slice(0, 5);
2518
2482
  for (const l of d) {
2519
2483
  let u = "";
2520
- e === "unassign" ? u = " (unassigned from previous assignee)" : l.newAssigneeId && (u = ` → ${l.newAssigneeId}`), c += ` • Task ${l.taskId}${u}
2484
+ e === "unassign" ? u = " (unassigned from previous assignee)" : l.newAssigneeId && (u = ` → ${l.newAssigneeId}`), a += ` • Task ${l.taskId}${u}
2521
2485
  `;
2522
2486
  }
2523
- n.length > 5 && (c += ` • ... and ${n.length - 5} more
2524
- `), c += `
2487
+ n.length > 5 && (a += ` • ... and ${n.length - 5} more
2488
+ `), a += `
2525
2489
  `;
2526
2490
  }
2527
2491
  if (r.length > 0) {
2528
- c += `**${r.length} task${r.length === 1 ? "" : "s"} failed**
2492
+ a += `**${r.length} task${r.length === 1 ? "" : "s"} failed**
2529
2493
  `;
2530
2494
  const d = r.slice(0, 5);
2531
2495
  for (const l of d)
2532
- c += ` • Task ${l.taskId}: ${l.error}
2496
+ a += ` • Task ${l.taskId}: ${l.error}
2533
2497
  `;
2534
- r.length > 5 && (c += ` • ... and ${r.length - 5} more failures
2535
- `), c += `
2498
+ r.length > 5 && (a += ` • ... and ${r.length - 5} more failures
2499
+ `), a += `
2536
2500
  `;
2537
2501
  }
2538
- return !o && n.length > 0 ? (c += `**Next steps:**
2539
- `, c += `• Use ${js} with responsibleUser to see ${e === "unassign" ? "unassigned" : "newly assigned"} tasks
2540
- `, c += `• Use ${$s} for individual assignment changes
2541
- `, r.length > 0 && (c += `• Check failed tasks and use ${pe} to verify collaborator access
2542
- `)) : o ? (c += `**To execute:**
2543
- `, c += `• Remove dryRun parameter and run again to execute changes
2544
- `, n.length > 0 && (c += `• ${n.length} task${n.length === 1 ? "" : "s"} ready for ${e} operation
2545
- `), r.length > 0 && (c += `• Fix ${r.length} validation error${r.length === 1 ? "" : "s"} before executing
2546
- `)) : n.length === 0 && (c += `**Suggestions:**
2547
- `, c += `• Use ${pe} to find valid assignees
2548
- `, c += `• Check task IDs and assignee permissions
2549
- `, c += `• Use dryRun=true to validate before executing
2550
- `), c;
2551
- }
2552
- const xs = {
2502
+ return !o && n.length > 0 ? (a += `**Next steps:**
2503
+ `, a += `• Use ${ws} with responsibleUser to see ${e === "unassign" ? "unassigned" : "newly assigned"} tasks
2504
+ `, a += `• Use ${js} for individual assignment changes
2505
+ `, r.length > 0 && (a += `• Check failed tasks and use ${ue} to verify collaborator access
2506
+ `)) : o ? (a += `**To execute:**
2507
+ `, a += `• Remove dryRun parameter and run again to execute changes
2508
+ `, n.length > 0 && (a += `• ${n.length} task${n.length === 1 ? "" : "s"} ready for ${e} operation
2509
+ `), r.length > 0 && (a += `• Fix ${r.length} validation error${r.length === 1 ? "" : "s"} before executing
2510
+ `)) : n.length === 0 && (a += `**Suggestions:**
2511
+ `, a += `• Use ${ue} to find valid assignees
2512
+ `, a += `• Check task IDs and assignee permissions
2513
+ `, a += `• Use dryRun=true to validate before executing
2514
+ `), a;
2515
+ }
2516
+ const Ds = {
2553
2517
  query: s.string().min(1).describe("The search query string to find tasks and projects.")
2554
- }, As = {
2518
+ }, xs = {
2555
2519
  results: s.array(
2556
2520
  s.object({
2557
2521
  id: s.string().describe("The ID of the result."),
@@ -2560,77 +2524,75 @@ const xs = {
2560
2524
  })
2561
2525
  ).describe("The search results."),
2562
2526
  totalCount: s.number().describe("Total number of results found.")
2563
- }, Us = {
2564
- name: y.SEARCH,
2527
+ }, As = {
2528
+ name: g.SEARCH,
2565
2529
  description: "Search across tasks and projects in Todoist. Returns a list of relevant results with IDs, titles, and URLs.",
2566
- parameters: xs,
2567
- outputSchema: As,
2530
+ parameters: Ds,
2531
+ outputSchema: xs,
2568
2532
  async execute(e, t) {
2569
- try {
2570
- const { query: o } = e, [n, r] = await Promise.all([
2571
- ne({
2572
- client: t,
2573
- query: `search: ${o}`,
2574
- limit: v.TASKS_MAX,
2575
- cursor: void 0
2576
- }),
2577
- t.getProjects({ limit: v.PROJECTS_MAX })
2578
- ]), i = o.toLowerCase(), a = r.results.filter(
2579
- (l) => l.name.toLowerCase().includes(i)
2580
- ), c = [];
2581
- for (const l of n.tasks)
2582
- c.push({
2583
- id: `task:${l.id}`,
2584
- title: l.content,
2585
- url: he(l.id)
2586
- });
2587
- for (const l of a)
2588
- c.push({
2589
- id: `project:${l.id}`,
2590
- title: l.name,
2591
- url: me(l.id)
2592
- });
2593
- return { content: [{ type: "text", text: JSON.stringify({ results: c }) }] };
2594
- } catch (o) {
2595
- const n = o instanceof Error ? o.message : "An unknown error occurred";
2596
- return Q(n);
2597
- }
2533
+ const { query: o } = e, [n, r] = await Promise.all([
2534
+ oe({
2535
+ client: t,
2536
+ query: `search: ${o}`,
2537
+ limit: S.TASKS_MAX,
2538
+ cursor: void 0
2539
+ }),
2540
+ t.getProjects({ limit: S.PROJECTS_MAX })
2541
+ ]), i = o.toLowerCase(), c = r.results.filter(
2542
+ (d) => d.name.toLowerCase().includes(i)
2543
+ ), a = [];
2544
+ for (const d of n.tasks)
2545
+ a.push({
2546
+ id: `task:${d.id}`,
2547
+ title: d.content,
2548
+ url: pe(d.id)
2549
+ });
2550
+ for (const d of c)
2551
+ a.push({
2552
+ id: `project:${d.id}`,
2553
+ title: d.name,
2554
+ url: he(d.id)
2555
+ });
2556
+ return {
2557
+ textContent: JSON.stringify({ results: a }),
2558
+ structuredContent: { results: a, totalCount: a.length }
2559
+ };
2598
2560
  }
2599
- }, Ps = s.object({
2561
+ }, Us = s.object({
2600
2562
  id: s.string().min(1).describe("The ID of the comment to update."),
2601
2563
  content: s.string().min(1).describe("The new content for the comment.")
2602
- }), Es = {
2603
- comments: s.array(Ps).min(1).describe("The comments to update.")
2604
- }, Os = {
2605
- comments: s.array(se).describe("The updated comments."),
2564
+ }), Ps = {
2565
+ comments: s.array(Us).min(1).describe("The comments to update.")
2566
+ }, Es = {
2567
+ comments: s.array(te).describe("The updated comments."),
2606
2568
  totalCount: s.number().describe("The total number of comments updated."),
2607
2569
  updatedCommentIds: s.array(s.string()).describe("The IDs of the updated comments."),
2608
2570
  appliedOperations: s.object({
2609
2571
  updateCount: s.number().describe("The number of comments updated.")
2610
2572
  }).describe("Summary of operations performed.")
2611
- }, _s = {
2612
- name: y.UPDATE_COMMENTS,
2573
+ }, Os = {
2574
+ name: g.UPDATE_COMMENTS,
2613
2575
  description: "Update multiple existing comments with new content.",
2614
- parameters: Es,
2615
- outputSchema: Os,
2576
+ parameters: Ps,
2577
+ outputSchema: Es,
2616
2578
  async execute(e, t) {
2617
- const { comments: o } = e, n = o.map(async (a) => await t.updateComment(a.id, { content: a.content })), r = await Promise.all(n), i = Ns({
2618
- comments: r
2619
- });
2620
- return T({
2621
- textContent: i,
2579
+ const { comments: o } = e, n = o.map(async (c) => await t.updateComment(c.id, { content: c.content })), r = await Promise.all(n);
2580
+ return {
2581
+ textContent: _s({
2582
+ comments: r
2583
+ }),
2622
2584
  structuredContent: {
2623
2585
  comments: r,
2624
2586
  totalCount: r.length,
2625
- updatedCommentIds: r.map((a) => a.id),
2587
+ updatedCommentIds: r.map((c) => c.id),
2626
2588
  appliedOperations: {
2627
2589
  updateCount: r.length
2628
2590
  }
2629
2591
  }
2630
- });
2592
+ };
2631
2593
  }
2632
2594
  };
2633
- function Ns({ comments: e }) {
2595
+ function _s({ comments: e }) {
2634
2596
  const t = e.filter((i) => i.taskId).length, o = e.filter((i) => i.projectId).length, n = [];
2635
2597
  if (t > 0) {
2636
2598
  const i = t > 1 ? "comments" : "comment";
@@ -2642,102 +2604,106 @@ function Ns({ comments: e }) {
2642
2604
  }
2643
2605
  return n.length > 0 ? `Updated ${n.join(" and ")}` : "No comments updated";
2644
2606
  }
2645
- const Ms = s.object({
2607
+ const Ns = s.object({
2646
2608
  id: s.string().min(1).describe("The ID of the project to update."),
2647
2609
  name: s.string().min(1).optional().describe("The new name of the project."),
2648
2610
  isFavorite: s.boolean().optional().describe("Whether the project is a favorite."),
2649
2611
  viewStyle: s.enum(["list", "board", "calendar"]).optional().describe("The project view style.")
2650
- }), Fs = {
2651
- projects: s.array(Ms).min(1).describe("The projects to update.")
2652
- }, Rs = {
2653
- projects: s.array(ee).describe("The updated projects."),
2612
+ }), Ms = {
2613
+ projects: s.array(Ns).min(1).describe("The projects to update.")
2614
+ }, Fs = {
2615
+ projects: s.array(Q).describe("The updated projects."),
2654
2616
  totalCount: s.number().describe("The total number of projects updated."),
2655
2617
  updatedProjectIds: s.array(s.string()).describe("The IDs of the updated projects."),
2656
2618
  appliedOperations: s.object({
2657
2619
  updateCount: s.number().describe("The number of projects actually updated."),
2658
2620
  skippedCount: s.number().describe("The number of projects skipped (no changes).")
2659
2621
  }).describe("Summary of operations performed.")
2660
- }, Ls = {
2661
- name: y.UPDATE_PROJECTS,
2622
+ }, Rs = {
2623
+ name: g.UPDATE_PROJECTS,
2662
2624
  description: "Update multiple existing projects with new values.",
2663
- parameters: Fs,
2664
- outputSchema: Rs,
2625
+ parameters: Ms,
2626
+ outputSchema: Fs,
2665
2627
  async execute(e, t) {
2666
- const { projects: o } = e, n = o.map(async (a) => {
2667
- if (!Ws(a))
2628
+ const { projects: o } = e, n = o.map(async (c) => {
2629
+ if (!Bs(c))
2668
2630
  return;
2669
- const { id: c, ...d } = a;
2670
- return await t.updateProject(c, d);
2631
+ const { id: a, ...d } = c;
2632
+ return await t.updateProject(a, d);
2671
2633
  }), r = (await Promise.all(n)).filter(
2672
- (a) => a !== void 0
2673
- ), i = Bs({
2674
- projects: r,
2675
- args: e
2676
- });
2677
- return T({
2678
- textContent: i,
2634
+ (c) => c !== void 0
2635
+ ).map((c) => ({
2636
+ ...c,
2637
+ parentId: "parentId" in c ? c.parentId ?? void 0 : void 0,
2638
+ inboxProject: "inboxProject" in c ? c.inboxProject : !1
2639
+ }));
2640
+ return {
2641
+ textContent: Ls({
2642
+ projects: r,
2643
+ args: e
2644
+ }),
2679
2645
  structuredContent: {
2680
2646
  projects: r,
2681
2647
  totalCount: r.length,
2682
- updatedProjectIds: r.map((a) => a.id),
2648
+ updatedProjectIds: r.map((c) => c.id),
2683
2649
  appliedOperations: {
2684
2650
  updateCount: r.length,
2685
2651
  skippedCount: o.length - r.length
2686
2652
  }
2687
2653
  }
2688
- });
2654
+ };
2689
2655
  }
2690
2656
  };
2691
- function Bs({
2657
+ function Ls({
2692
2658
  projects: e,
2693
2659
  args: t
2694
2660
  }) {
2695
- const o = t.projects.length, n = e.length, r = o - n, i = e.length, a = e.map((d) => `• ${d.name} (id=${d.id})`).join(`
2661
+ const o = t.projects.length, n = e.length, r = o - n, i = e.length, c = e.map((d) => `• ${d.name} (id=${d.id})`).join(`
2696
2662
  `);
2697
- let c = `Updated ${i} project${i === 1 ? "" : "s"}`;
2698
- return r > 0 && (c += ` (${r} skipped - no changes)`), i > 0 && (c += `:
2699
- ${a}`), c;
2663
+ let a = `Updated ${i} project${i === 1 ? "" : "s"}`;
2664
+ return r > 0 && (a += ` (${r} skipped - no changes)`), i > 0 && (a += `:
2665
+ ${c}`), a;
2700
2666
  }
2701
- function Ws({ id: e, ...t }) {
2667
+ function Bs({ id: e, ...t }) {
2702
2668
  return Object.keys(t).length > 0;
2703
2669
  }
2704
- const Ys = s.object({
2670
+ const Ws = s.object({
2705
2671
  id: s.string().min(1).describe("The ID of the section to update."),
2706
2672
  name: s.string().min(1).describe("The new name of the section.")
2707
- }), Ks = {
2708
- sections: s.array(Ys).min(1).describe("The sections to update.")
2709
- }, zs = {
2710
- sections: s.array(te).describe("The updated sections."),
2673
+ }), Ys = {
2674
+ sections: s.array(Ws).min(1).describe("The sections to update.")
2675
+ }, Ks = {
2676
+ sections: s.array(ee).describe("The updated sections."),
2711
2677
  totalCount: s.number().describe("The total number of sections updated."),
2712
2678
  updatedSectionIds: s.array(s.string()).describe("The IDs of the updated sections.")
2713
- }, Vs = {
2714
- name: y.UPDATE_SECTIONS,
2679
+ }, zs = {
2680
+ name: g.UPDATE_SECTIONS,
2715
2681
  description: "Update multiple existing sections with new values.",
2716
- parameters: Ks,
2717
- outputSchema: zs,
2682
+ parameters: Ys,
2683
+ outputSchema: Ks,
2718
2684
  async execute({ sections: e }, t) {
2719
2685
  const o = await Promise.all(
2720
2686
  e.map((r) => t.updateSection(r.id, { name: r.name }))
2721
- ), n = Hs({
2722
- sections: o
2723
- });
2724
- return T({
2725
- textContent: n,
2687
+ );
2688
+ return {
2689
+ textContent: Vs({
2690
+ sections: o
2691
+ }),
2726
2692
  structuredContent: {
2727
2693
  sections: o,
2728
2694
  totalCount: o.length,
2729
2695
  updatedSectionIds: o.map((r) => r.id)
2730
2696
  }
2731
- });
2697
+ };
2732
2698
  }
2733
2699
  };
2734
- function Hs({ sections: e }) {
2700
+ function Vs({ sections: e }) {
2735
2701
  const t = e.length, o = e.map((r) => `• ${r.name} (id=${r.id}, projectId=${r.projectId})`).join(`
2736
2702
  `);
2737
2703
  return `Updated ${t} section${t === 1 ? "" : "s"}:
2738
2704
  ${o}`;
2739
2705
  }
2740
- const Gs = s.object({
2706
+ const Hs = s.object({
2741
2707
  id: s.string().min(1).describe("The ID of the task to update."),
2742
2708
  content: s.string().optional().describe(
2743
2709
  'The new task name/title. Should be concise and actionable (e.g., "Review PR #123", "Call dentist"). For longer content, use the description field instead. Supports Markdown.'
@@ -2751,7 +2717,7 @@ const Gs = s.object({
2751
2717
  sectionId: s.string().optional().describe("The new section ID for the task."),
2752
2718
  parentId: s.string().optional().describe("The new parent task ID (for subtasks)."),
2753
2719
  order: s.number().optional().describe("The new order of the task within its parent/section."),
2754
- priority: ye.optional().describe(
2720
+ priority: Te.optional().describe(
2755
2721
  "The new priority of the task: p1 (highest), p2 (high), p3 (medium), p4 (lowest/default)."
2756
2722
  ),
2757
2723
  dueString: s.string().optional().describe("The new due date for the task, in natural language (e.g., 'tomorrow at 5pm')."),
@@ -2765,9 +2731,9 @@ const Gs = s.object({
2765
2731
  'Change task assignment. Use "unassign" to remove assignment. Can be user ID, name, or email. User must be a project collaborator.'
2766
2732
  ),
2767
2733
  labels: s.array(s.string()).optional().describe("The new labels for the task. Replaces all existing labels.")
2768
- }), qs = {
2769
- tasks: s.array(Gs).min(1).describe("The tasks to update.")
2770
- }, Js = {
2734
+ }), Gs = {
2735
+ tasks: s.array(Hs).min(1).describe("The tasks to update.")
2736
+ }, qs = {
2771
2737
  tasks: s.array(W).describe("The updated tasks."),
2772
2738
  totalCount: s.number().describe("The total number of tasks updated."),
2773
2739
  updatedTaskIds: s.array(s.string()).describe("The IDs of the updated tasks."),
@@ -2775,14 +2741,14 @@ const Gs = s.object({
2775
2741
  updateCount: s.number().describe("The number of tasks actually updated."),
2776
2742
  skippedCount: s.number().describe("The number of tasks skipped (no changes).")
2777
2743
  }).describe("Summary of operations performed.")
2778
- }, Xs = {
2779
- name: y.UPDATE_TASKS,
2744
+ }, Js = {
2745
+ name: g.UPDATE_TASKS,
2780
2746
  description: "Update existing tasks including content, dates, priorities, and assignments.",
2781
- parameters: qs,
2782
- outputSchema: Js,
2747
+ parameters: Gs,
2748
+ outputSchema: qs,
2783
2749
  async execute(e, t) {
2784
- const { tasks: o } = e, n = o.map(async (c) => {
2785
- if (!Qs(c))
2750
+ const { tasks: o } = e, n = o.map(async (a) => {
2751
+ if (!Zs(a))
2786
2752
  return;
2787
2753
  const {
2788
2754
  id: d,
@@ -2791,84 +2757,84 @@ const Gs = s.object({
2791
2757
  parentId: p,
2792
2758
  duration: b,
2793
2759
  responsibleUser: m,
2794
- priority: k,
2795
- labels: j,
2796
- deadlineDate: S,
2797
- ...x
2798
- } = c;
2799
- let E = l;
2800
- l === "inbox" && (E = (await t.getUser()).inboxProjectId);
2760
+ priority: y,
2761
+ labels: k,
2762
+ deadlineDate: w,
2763
+ ...D
2764
+ } = a;
2765
+ let P = l;
2766
+ l === "inbox" && (P = (await t.getUser()).inboxProjectId);
2801
2767
  let h = {
2802
- ...x,
2803
- ...j !== void 0 && { labels: j }
2768
+ ...D,
2769
+ ...k !== void 0 && { labels: k }
2804
2770
  };
2805
- if (k && (h.priority = Ie(k)), S !== void 0 && (S === null || S === "remove" ? h = { ...h, deadlineDate: null } : h = { ...h, deadlineDate: S }), b)
2771
+ if (y && (h.priority = ye(y)), w !== void 0 && (w === null || w === "remove" ? h = { ...h, deadlineDate: null } : h = { ...h, deadlineDate: w }), b)
2806
2772
  try {
2807
- const { minutes: g } = be(b);
2773
+ const { minutes: v } = fe(b);
2808
2774
  h = {
2809
2775
  ...h,
2810
- duration: g,
2776
+ duration: v,
2811
2777
  durationUnit: "minute"
2812
2778
  };
2813
- } catch (g) {
2814
- throw g instanceof P ? new Error(`Task ${d}: ${g.message}`) : g;
2779
+ } catch (v) {
2780
+ throw v instanceof U ? new Error(`Task ${d}: ${v.message}`) : v;
2815
2781
  }
2816
2782
  if (m !== void 0)
2817
2783
  if (m === null || m === "unassign")
2818
2784
  h = { ...h, assigneeId: null };
2819
2785
  else {
2820
- const g = await re.validateTaskUpdateAssignment(
2786
+ const v = await ne.validateTaskUpdateAssignment(
2821
2787
  t,
2822
2788
  d,
2823
2789
  m
2824
2790
  );
2825
- if (!g.isValid) {
2826
- const f = g.error?.message || "Assignment validation failed", $ = g.error?.suggestions?.join(". ") || "";
2791
+ if (!v.isValid) {
2792
+ const f = v.error?.message || "Assignment validation failed", j = v.error?.suggestions?.join(". ") || "";
2827
2793
  throw new Error(
2828
- `Task ${d}: ${f}${$ ? `. ${$}` : ""}`
2794
+ `Task ${d}: ${f}${j ? `. ${j}` : ""}`
2829
2795
  );
2830
2796
  }
2831
- h = { ...h, assigneeId: g.resolvedUser?.userId };
2797
+ h = { ...h, assigneeId: v.resolvedUser?.userId };
2832
2798
  }
2833
- if (!E && !u && !p)
2799
+ if (!P && !u && !p)
2834
2800
  return await t.updateTask(d, h);
2835
- const I = st(d, E, u, p), C = await t.moveTask(d, I);
2801
+ const T = st(d, P, u, p), C = await t.moveTask(d, T);
2836
2802
  return Object.keys(h).length > 0 ? await t.updateTask(d, h) : C;
2837
2803
  }), r = (await Promise.all(n)).filter(
2838
- (c) => c !== void 0
2839
- ), i = r.map(O), a = Zs({
2840
- tasks: i,
2841
- args: e
2842
- });
2843
- return T({
2844
- textContent: a,
2804
+ (a) => a !== void 0
2805
+ ), i = r.map(O);
2806
+ return {
2807
+ textContent: Xs({
2808
+ tasks: i,
2809
+ args: e
2810
+ }),
2845
2811
  structuredContent: {
2846
2812
  tasks: i,
2847
2813
  totalCount: i.length,
2848
- updatedTaskIds: r.map((c) => c.id),
2814
+ updatedTaskIds: r.map((a) => a.id),
2849
2815
  appliedOperations: {
2850
2816
  updateCount: i.length,
2851
2817
  skippedCount: o.length - i.length
2852
2818
  }
2853
2819
  }
2854
- });
2820
+ };
2855
2821
  }
2856
2822
  };
2857
- function Zs({
2823
+ function Xs({
2858
2824
  tasks: e,
2859
2825
  args: t
2860
2826
  }) {
2861
2827
  const o = t.tasks.length, n = e.length, r = o - n;
2862
2828
  let i = "";
2863
- return r > 0 && (i = ` (${r} skipped - no changes)`), ke("Updated", e, {
2829
+ return r > 0 && (i = ` (${r} skipped - no changes)`), Ie("Updated", e, {
2864
2830
  context: i,
2865
2831
  showDetails: e.length <= 5
2866
2832
  });
2867
2833
  }
2868
- function Qs({ id: e, ...t }) {
2834
+ function Zs({ id: e, ...t }) {
2869
2835
  return Object.keys(t).length > 0;
2870
2836
  }
2871
- const eo = {}, to = {
2837
+ const Qs = {}, eo = {
2872
2838
  type: s.literal("user_info").describe("The type of the response."),
2873
2839
  userId: s.string().describe("The user ID."),
2874
2840
  fullName: s.string().describe("The full name of the user."),
@@ -2885,39 +2851,39 @@ const eo = {}, to = {
2885
2851
  email: s.string().describe("The email address of the user."),
2886
2852
  plan: s.enum(["Todoist Free", "Todoist Pro", "Todoist Business"]).describe("The user plan.")
2887
2853
  };
2888
- function so(e) {
2854
+ function to(e) {
2889
2855
  return e.businessAccountId ? "Todoist Business" : e.isPremium ? "Todoist Pro" : "Todoist Free";
2890
2856
  }
2891
- function oo(e, t) {
2857
+ function so(e, t) {
2892
2858
  const n = ((e.getDay() || 7) - t + 7) % 7, r = new Date(e);
2893
2859
  return r.setDate(e.getDate() - n), r;
2894
2860
  }
2895
- function no(e) {
2861
+ function oo(e) {
2896
2862
  const t = new Date(e);
2897
2863
  return t.setDate(e.getDate() + 6), t;
2898
2864
  }
2899
- function ro(e) {
2865
+ function no(e) {
2900
2866
  const t = new Date(e.getFullYear(), 0, 1), o = (e.getTime() - t.getTime()) / 864e5;
2901
2867
  return Math.ceil((o + t.getDay() + 1) / 7);
2902
2868
  }
2903
- function io(e) {
2869
+ function ro(e) {
2904
2870
  return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][e === 7 ? 0 : e] ?? "Unknown";
2905
2871
  }
2906
2872
  function K(e) {
2907
2873
  return e.toISOString().split("T")[0] ?? "";
2908
2874
  }
2909
- function ao(e) {
2875
+ function io(e) {
2910
2876
  try {
2911
2877
  return new Intl.DateTimeFormat("en-US", { timeZone: e }), !0;
2912
2878
  } catch {
2913
2879
  return !1;
2914
2880
  }
2915
2881
  }
2916
- function ve(e) {
2917
- return ao(e) ? e : "UTC";
2882
+ function $e(e) {
2883
+ return io(e) ? e : "UTC";
2918
2884
  }
2919
- function co(e, t) {
2920
- const o = ve(t);
2885
+ function ao(e, t) {
2886
+ const o = $e(t);
2921
2887
  return e.toLocaleString("en-US", {
2922
2888
  timeZone: o,
2923
2889
  year: "numeric",
@@ -2929,8 +2895,8 @@ function co(e, t) {
2929
2895
  hour12: !1
2930
2896
  });
2931
2897
  }
2932
- async function lo(e) {
2933
- const t = await e.getUser(), o = t.tzInfo?.timezone ?? "UTC", n = ve(o), r = /* @__PURE__ */ new Date(), i = co(r, n), a = t.startDay ?? 1, c = io(a), d = so(t), l = new Date(r.toLocaleString("en-US", { timeZone: n })), u = oo(l, a), p = no(u), b = ro(l), k = [
2898
+ async function co(e) {
2899
+ const t = await e.getUser(), o = t.tzInfo?.timezone ?? "UTC", n = $e(o), r = /* @__PURE__ */ new Date(), i = ao(r, n), c = t.startDay ?? 1, a = ro(c), d = to(t), l = new Date(r.toLocaleString("en-US", { timeZone: n })), u = so(l, c), p = oo(u), b = no(l), y = [
2934
2900
  "# User Information",
2935
2901
  "",
2936
2902
  `**User ID:** ${t.id}`,
@@ -2940,7 +2906,7 @@ async function lo(e) {
2940
2906
  `**Current Local Time:** ${i}`,
2941
2907
  "",
2942
2908
  "## Week Settings",
2943
- `**Week Start Day:** ${c} (${a})`,
2909
+ `**Week Start Day:** ${a} (${c})`,
2944
2910
  `**Current Week:** Week ${b}`,
2945
2911
  `**Week Start Date:** ${K(u)}`,
2946
2912
  `**Week End Date:** ${K(p)}`,
@@ -2953,14 +2919,14 @@ async function lo(e) {
2953
2919
  "## Account Info",
2954
2920
  `**Plan:** ${d}`
2955
2921
  ].join(`
2956
- `), j = {
2922
+ `), k = {
2957
2923
  type: "user_info",
2958
2924
  userId: t.id,
2959
2925
  fullName: t.fullName,
2960
2926
  timezone: n,
2961
2927
  currentLocalTime: i,
2962
- startDay: a,
2963
- startDayName: c,
2928
+ startDay: c,
2929
+ startDayName: a,
2964
2930
  weekStartDate: K(u),
2965
2931
  weekEndDate: K(p),
2966
2932
  currentWeekNumber: b,
@@ -2970,21 +2936,21 @@ async function lo(e) {
2970
2936
  email: t.email,
2971
2937
  plan: d
2972
2938
  };
2973
- return { textContent: k, structuredContent: j };
2939
+ return { textContent: y, structuredContent: k };
2974
2940
  }
2975
- const uo = {
2976
- name: y.USER_INFO,
2941
+ const lo = {
2942
+ name: g.USER_INFO,
2977
2943
  description: "Get comprehensive user information including user ID, full name, email, timezone with current local time, week start day preferences, current week dates, daily/weekly goal progress, and user plan (Free/Pro/Business).",
2978
- parameters: eo,
2979
- outputSchema: to,
2944
+ parameters: Qs,
2945
+ outputSchema: eo,
2980
2946
  async execute(e, t) {
2981
- const o = await lo(t);
2982
- return T({
2947
+ const o = await co(t);
2948
+ return {
2983
2949
  textContent: o.textContent,
2984
2950
  structuredContent: o.structuredContent
2985
- });
2951
+ };
2986
2952
  }
2987
- }, po = `
2953
+ }, uo = `
2988
2954
  ## Todoist Task and Project Management Tools
2989
2955
 
2990
2956
  You have access to comprehensive Todoist management tools for personal productivity and team collaboration. Use these tools to help users manage tasks, projects, sections, comments, and assignments effectively.
@@ -3053,40 +3019,40 @@ You have access to comprehensive Todoist management tools for personal productiv
3053
3019
  Always provide clear, actionable task titles and descriptions. Use the overview tools to give users context about their workload and project status.
3054
3020
  `;
3055
3021
  function go({ todoistApiKey: e, baseUrl: t }) {
3056
- const o = new Ae(
3022
+ const o = new De(
3057
3023
  { name: "todoist-mcp-server", version: "0.1.0" },
3058
3024
  {
3059
3025
  capabilities: {
3060
3026
  tools: { listChanged: !0 }
3061
3027
  },
3062
- instructions: po
3028
+ instructions: uo
3063
3029
  }
3064
- ), n = new xe(e, t);
3065
- return w(ft, o, n), w(It, o, n), w(Xs, o, n), w(cs, o, n), w(ps, o, n), w(Yt, o, n), w(ze, o, n), w(Ls, o, n), w(Qt, o, n), w(Je, o, n), w(Vs, o, n), w(ns, o, n), w(Le, o, n), w(Ft, o, n), w(_s, o, n), w(Ut, o, n), w(ws, o, n), w($t, o, n), w(uo, o, n), w(Gt, o, n), w(Ds, o, n), w(Us, o, n), w(Dt, o, n), o;
3030
+ ), n = new Se(e, t);
3031
+ return I(ft, o, n), I(It, o, n), I(Js, o, n), I(as, o, n), I(us, o, n), I(Wt, o, n), I(ze, o, n), I(Rs, o, n), I(Zt, o, n), I(Je, o, n), I(zs, o, n), I(os, o, n), I(Le, o, n), I(Mt, o, n), I(Os, o, n), I(At, o, n), I(ks, o, n), I(vt, o, n), I(lo, o, n), I(Ht, o, n), I(Ss, o, n), I(As, o, n), I(St, o, n), o;
3066
3032
  }
3067
3033
  export {
3068
- Gt as a,
3069
- ws as b,
3070
- Ut as c,
3071
- $t as d,
3072
- Ft as e,
3073
- Dt as f,
3034
+ Ht as a,
3035
+ ks as b,
3036
+ At as c,
3037
+ vt as d,
3038
+ Mt as e,
3039
+ St as f,
3074
3040
  go as g,
3075
- _s as h,
3041
+ Os as h,
3076
3042
  Le as i,
3077
- ns as j,
3078
- Vs as k,
3043
+ os as j,
3044
+ zs as k,
3079
3045
  Je as l,
3080
- Ds as m,
3081
- Qt as n,
3082
- Ls as o,
3046
+ Ss as m,
3047
+ Zt as n,
3048
+ Rs as o,
3083
3049
  ze as p,
3084
- Yt as q,
3085
- ps as r,
3086
- Us as s,
3087
- cs as t,
3088
- uo as u,
3089
- Xs as v,
3050
+ Wt as q,
3051
+ us as r,
3052
+ As as s,
3053
+ as as t,
3054
+ lo as u,
3055
+ Js as v,
3090
3056
  It as w,
3091
3057
  ft as x
3092
3058
  };