@doist/todoist-ai 4.16.0 → 4.16.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 (167) hide show
  1. package/dist/filter-helpers.d.ts +1 -1
  2. package/dist/index.d.ts +175 -175
  3. package/dist/index.js +61 -81
  4. package/dist/main.js +15 -23
  5. package/dist/mcp-helpers.d.ts +4 -4
  6. package/dist/mcp-server-6tm7Rhyz.js +2840 -0
  7. package/dist/todoist-tool.d.ts +2 -2
  8. package/dist/tool-helpers.d.ts +1 -1
  9. package/dist/tools/add-comments.d.ts +1 -1
  10. package/dist/tools/add-comments.d.ts.map +1 -1
  11. package/dist/tools/add-projects.d.ts +4 -4
  12. package/dist/tools/add-projects.d.ts.map +1 -1
  13. package/dist/tools/add-sections.d.ts +1 -1
  14. package/dist/tools/add-sections.d.ts.map +1 -1
  15. package/dist/tools/add-tasks.d.ts +4 -4
  16. package/dist/tools/add-tasks.d.ts.map +1 -1
  17. package/dist/tools/complete-tasks.d.ts +1 -1
  18. package/dist/tools/complete-tasks.d.ts.map +1 -1
  19. package/dist/tools/delete-object.d.ts +3 -3
  20. package/dist/tools/delete-object.d.ts.map +1 -1
  21. package/dist/tools/fetch.d.ts +1 -1
  22. package/dist/tools/find-activity.d.ts +5 -5
  23. package/dist/tools/find-activity.d.ts.map +1 -1
  24. package/dist/tools/find-comments.d.ts +2 -2
  25. package/dist/tools/find-comments.d.ts.map +1 -1
  26. package/dist/tools/find-completed-tasks.d.ts +3 -3
  27. package/dist/tools/find-completed-tasks.d.ts.map +1 -1
  28. package/dist/tools/find-project-collaborators.d.ts +2 -2
  29. package/dist/tools/find-projects.d.ts +1 -1
  30. package/dist/tools/find-projects.d.ts.map +1 -1
  31. package/dist/tools/find-sections.d.ts +1 -1
  32. package/dist/tools/find-sections.d.ts.map +1 -1
  33. package/dist/tools/find-tasks-by-date.d.ts +1 -1
  34. package/dist/tools/find-tasks-by-date.d.ts.map +1 -1
  35. package/dist/tools/find-tasks.d.ts +3 -3
  36. package/dist/tools/find-tasks.d.ts.map +1 -1
  37. package/dist/tools/get-overview.d.ts +1 -1
  38. package/dist/tools/manage-assignments.d.ts +1 -1
  39. package/dist/tools/search.d.ts +1 -1
  40. package/dist/tools/update-comments.d.ts +4 -4
  41. package/dist/tools/update-comments.d.ts.map +1 -1
  42. package/dist/tools/update-projects.d.ts +1 -1
  43. package/dist/tools/update-projects.d.ts.map +1 -1
  44. package/dist/tools/update-sections.d.ts +4 -4
  45. package/dist/tools/update-sections.d.ts.map +1 -1
  46. package/dist/tools/update-tasks.d.ts +7 -7
  47. package/dist/tools/update-tasks.d.ts.map +1 -1
  48. package/dist/tools/user-info.d.ts +1 -1
  49. package/dist/utils/assignment-validator.d.ts +2 -2
  50. package/dist/utils/response-builders.d.ts +1 -3
  51. package/dist/utils/response-builders.d.ts.map +1 -1
  52. package/dist/utils/test-helpers.d.ts +1 -1
  53. package/dist/utils/user-resolver.d.ts +1 -1
  54. package/package.json +10 -8
  55. package/dist/filter-helpers.js +0 -79
  56. package/dist/mcp-helpers.js +0 -71
  57. package/dist/mcp-server.js +0 -142
  58. package/dist/todoist-tool.js +0 -1
  59. package/dist/tool-helpers.js +0 -125
  60. package/dist/tool-helpers.test.d.ts +0 -2
  61. package/dist/tool-helpers.test.d.ts.map +0 -1
  62. package/dist/tool-helpers.test.js +0 -223
  63. package/dist/tools/__tests__/add-comments.test.d.ts +0 -2
  64. package/dist/tools/__tests__/add-comments.test.d.ts.map +0 -1
  65. package/dist/tools/__tests__/add-comments.test.js +0 -241
  66. package/dist/tools/__tests__/add-projects.test.d.ts +0 -2
  67. package/dist/tools/__tests__/add-projects.test.d.ts.map +0 -1
  68. package/dist/tools/__tests__/add-projects.test.js +0 -174
  69. package/dist/tools/__tests__/add-sections.test.d.ts +0 -2
  70. package/dist/tools/__tests__/add-sections.test.d.ts.map +0 -1
  71. package/dist/tools/__tests__/add-sections.test.js +0 -185
  72. package/dist/tools/__tests__/add-tasks.test.d.ts +0 -2
  73. package/dist/tools/__tests__/add-tasks.test.d.ts.map +0 -1
  74. package/dist/tools/__tests__/add-tasks.test.js +0 -606
  75. package/dist/tools/__tests__/assignment-integration.test.d.ts +0 -2
  76. package/dist/tools/__tests__/assignment-integration.test.d.ts.map +0 -1
  77. package/dist/tools/__tests__/assignment-integration.test.js +0 -428
  78. package/dist/tools/__tests__/complete-tasks.test.d.ts +0 -2
  79. package/dist/tools/__tests__/complete-tasks.test.d.ts.map +0 -1
  80. package/dist/tools/__tests__/complete-tasks.test.js +0 -206
  81. package/dist/tools/__tests__/delete-object.test.d.ts +0 -2
  82. package/dist/tools/__tests__/delete-object.test.d.ts.map +0 -1
  83. package/dist/tools/__tests__/delete-object.test.js +0 -110
  84. package/dist/tools/__tests__/fetch.test.d.ts +0 -2
  85. package/dist/tools/__tests__/fetch.test.d.ts.map +0 -1
  86. package/dist/tools/__tests__/fetch.test.js +0 -279
  87. package/dist/tools/__tests__/find-activity.test.d.ts +0 -2
  88. package/dist/tools/__tests__/find-activity.test.d.ts.map +0 -1
  89. package/dist/tools/__tests__/find-activity.test.js +0 -229
  90. package/dist/tools/__tests__/find-comments.test.d.ts +0 -2
  91. package/dist/tools/__tests__/find-comments.test.d.ts.map +0 -1
  92. package/dist/tools/__tests__/find-comments.test.js +0 -236
  93. package/dist/tools/__tests__/find-completed-tasks.test.d.ts +0 -2
  94. package/dist/tools/__tests__/find-completed-tasks.test.d.ts.map +0 -1
  95. package/dist/tools/__tests__/find-completed-tasks.test.js +0 -423
  96. package/dist/tools/__tests__/find-projects.test.d.ts +0 -2
  97. package/dist/tools/__tests__/find-projects.test.d.ts.map +0 -1
  98. package/dist/tools/__tests__/find-projects.test.js +0 -154
  99. package/dist/tools/__tests__/find-sections.test.d.ts +0 -2
  100. package/dist/tools/__tests__/find-sections.test.d.ts.map +0 -1
  101. package/dist/tools/__tests__/find-sections.test.js +0 -313
  102. package/dist/tools/__tests__/find-tasks-by-date.test.d.ts +0 -2
  103. package/dist/tools/__tests__/find-tasks-by-date.test.d.ts.map +0 -1
  104. package/dist/tools/__tests__/find-tasks-by-date.test.js +0 -528
  105. package/dist/tools/__tests__/find-tasks.test.d.ts +0 -2
  106. package/dist/tools/__tests__/find-tasks.test.d.ts.map +0 -1
  107. package/dist/tools/__tests__/find-tasks.test.js +0 -771
  108. package/dist/tools/__tests__/get-overview.test.d.ts +0 -2
  109. package/dist/tools/__tests__/get-overview.test.d.ts.map +0 -1
  110. package/dist/tools/__tests__/get-overview.test.js +0 -225
  111. package/dist/tools/__tests__/search.test.d.ts +0 -2
  112. package/dist/tools/__tests__/search.test.d.ts.map +0 -1
  113. package/dist/tools/__tests__/search.test.js +0 -206
  114. package/dist/tools/__tests__/update-comments.test.d.ts +0 -2
  115. package/dist/tools/__tests__/update-comments.test.d.ts.map +0 -1
  116. package/dist/tools/__tests__/update-comments.test.js +0 -294
  117. package/dist/tools/__tests__/update-projects.test.d.ts +0 -2
  118. package/dist/tools/__tests__/update-projects.test.d.ts.map +0 -1
  119. package/dist/tools/__tests__/update-projects.test.js +0 -217
  120. package/dist/tools/__tests__/update-sections.test.d.ts +0 -2
  121. package/dist/tools/__tests__/update-sections.test.d.ts.map +0 -1
  122. package/dist/tools/__tests__/update-sections.test.js +0 -169
  123. package/dist/tools/__tests__/update-tasks.test.d.ts +0 -2
  124. package/dist/tools/__tests__/update-tasks.test.d.ts.map +0 -1
  125. package/dist/tools/__tests__/update-tasks.test.js +0 -788
  126. package/dist/tools/__tests__/user-info.test.d.ts +0 -2
  127. package/dist/tools/__tests__/user-info.test.d.ts.map +0 -1
  128. package/dist/tools/__tests__/user-info.test.js +0 -139
  129. package/dist/tools/add-comments.js +0 -89
  130. package/dist/tools/add-projects.js +0 -63
  131. package/dist/tools/add-sections.js +0 -74
  132. package/dist/tools/add-tasks.js +0 -169
  133. package/dist/tools/complete-tasks.js +0 -68
  134. package/dist/tools/delete-object.js +0 -79
  135. package/dist/tools/fetch.js +0 -102
  136. package/dist/tools/find-activity.js +0 -221
  137. package/dist/tools/find-comments.js +0 -148
  138. package/dist/tools/find-completed-tasks.js +0 -168
  139. package/dist/tools/find-project-collaborators.js +0 -151
  140. package/dist/tools/find-projects.js +0 -101
  141. package/dist/tools/find-sections.js +0 -101
  142. package/dist/tools/find-tasks-by-date.js +0 -198
  143. package/dist/tools/find-tasks.js +0 -329
  144. package/dist/tools/get-overview.js +0 -249
  145. package/dist/tools/manage-assignments.js +0 -337
  146. package/dist/tools/search.js +0 -65
  147. package/dist/tools/update-comments.js +0 -82
  148. package/dist/tools/update-projects.js +0 -84
  149. package/dist/tools/update-sections.js +0 -70
  150. package/dist/tools/update-tasks.js +0 -179
  151. package/dist/tools/user-info.js +0 -142
  152. package/dist/utils/assignment-validator.js +0 -253
  153. package/dist/utils/constants.js +0 -45
  154. package/dist/utils/duration-parser.js +0 -96
  155. package/dist/utils/duration-parser.test.d.ts +0 -2
  156. package/dist/utils/duration-parser.test.d.ts.map +0 -1
  157. package/dist/utils/duration-parser.test.js +0 -147
  158. package/dist/utils/labels.js +0 -18
  159. package/dist/utils/priorities.js +0 -20
  160. package/dist/utils/response-builders.js +0 -210
  161. package/dist/utils/sanitize-data.js +0 -37
  162. package/dist/utils/sanitize-data.test.d.ts +0 -2
  163. package/dist/utils/sanitize-data.test.d.ts.map +0 -1
  164. package/dist/utils/sanitize-data.test.js +0 -93
  165. package/dist/utils/test-helpers.js +0 -237
  166. package/dist/utils/tool-names.js +0 -40
  167. package/dist/utils/user-resolver.js +0 -179
@@ -1,179 +0,0 @@
1
- // User resolution cache for performance with TTL
2
- const userResolutionCache = new Map();
3
- // Project collaborators cache
4
- const collaboratorsCache = new Map();
5
- const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
6
- export class UserResolver {
7
- /**
8
- * Resolve a user name or ID to a user ID by looking up collaborators across all shared projects.
9
- * Supports exact name matches, partial matches, and email matches.
10
- */
11
- async resolveUser(client, nameOrId) {
12
- // Input validation
13
- if (!nameOrId || nameOrId.trim().length === 0) {
14
- return null;
15
- }
16
- const trimmedInput = nameOrId.trim();
17
- // Check cache first
18
- const cached = userResolutionCache.get(trimmedInput);
19
- if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
20
- return cached.result;
21
- }
22
- // If it looks like a user ID already, return as-is
23
- // Support numeric IDs and alphanumeric IDs but avoid obvious user names
24
- if (/^[0-9]+$/.test(trimmedInput) ||
25
- (/^[a-f0-9-]{8,}$/i.test(trimmedInput) && trimmedInput.includes('-')) ||
26
- (/^[a-z0-9_]{6,}$/i.test(trimmedInput) &&
27
- !/^[a-z]+[\s-]/.test(trimmedInput) &&
28
- /[0-9_]/.test(trimmedInput))) {
29
- const result = { userId: trimmedInput, displayName: trimmedInput, email: trimmedInput };
30
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
31
- return result;
32
- }
33
- try {
34
- // Get all collaborators from shared projects
35
- const allCollaborators = await this.getAllCollaborators(client);
36
- if (allCollaborators.length === 0) {
37
- const result = null; // No shared projects, can't resolve collaborators
38
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
39
- return result;
40
- }
41
- const searchTerm = nameOrId.toLowerCase().trim();
42
- // Try exact name match first
43
- let match = allCollaborators.find((c) => c.name.toLowerCase() === searchTerm);
44
- if (match) {
45
- const result = { userId: match.id, displayName: match.name, email: match.email };
46
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
47
- return result;
48
- }
49
- // Try exact email match
50
- match = allCollaborators.find((c) => c.email.toLowerCase() === searchTerm);
51
- if (match) {
52
- const result = { userId: match.id, displayName: match.name, email: match.email };
53
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
54
- return result;
55
- }
56
- // Try partial name match (contains)
57
- match = allCollaborators.find((c) => c.name.toLowerCase().includes(searchTerm));
58
- if (match) {
59
- const result = { userId: match.id, displayName: match.name, email: match.email };
60
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
61
- return result;
62
- }
63
- // Try partial email match
64
- match = allCollaborators.find((c) => c.email.toLowerCase().includes(searchTerm));
65
- if (match) {
66
- const result = { userId: match.id, displayName: match.name, email: match.email };
67
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
68
- return result;
69
- }
70
- // No match found
71
- const result = null;
72
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
73
- return result;
74
- }
75
- catch (_error) {
76
- // If we can't fetch collaborators, return null instead of dangerous fallback
77
- const result = null;
78
- userResolutionCache.set(trimmedInput, { result, timestamp: Date.now() });
79
- return result;
80
- }
81
- }
82
- /**
83
- * Validate that a user is a collaborator on a specific project
84
- */
85
- async validateProjectCollaborator(client, projectId, userId) {
86
- try {
87
- const collaborators = await this.getProjectCollaborators(client, projectId);
88
- return collaborators.some((collaborator) => collaborator.id === userId);
89
- }
90
- catch (_error) {
91
- return false;
92
- }
93
- }
94
- /**
95
- * Get collaborators for a specific project
96
- */
97
- async getProjectCollaborators(client, projectId) {
98
- // Check cache first
99
- const cacheKey = `project_${projectId}`;
100
- const cached = collaboratorsCache.get(cacheKey);
101
- if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
102
- return cached.result;
103
- }
104
- try {
105
- const response = await client.getProjectCollaborators(projectId);
106
- // API returns { results: [...], nextCursor: null } or just array
107
- const collaborators = Array.isArray(response) ? response : response.results || [];
108
- const validCollaborators = collaborators.filter((c) => c?.id && c.name && c.email);
109
- collaboratorsCache.set(cacheKey, {
110
- result: validCollaborators,
111
- timestamp: Date.now(),
112
- });
113
- return validCollaborators;
114
- }
115
- catch (_error) {
116
- // Return empty array on error, don't cache failed requests
117
- return [];
118
- }
119
- }
120
- /**
121
- * Get all collaborators from all shared projects
122
- */
123
- async getAllCollaborators(client) {
124
- // Check cache first
125
- const cacheKey = 'all_collaborators';
126
- const cached = collaboratorsCache.get(cacheKey);
127
- if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
128
- return cached.result;
129
- }
130
- try {
131
- // Get all projects to find shared ones
132
- const { results: projects } = await client.getProjects({});
133
- const sharedProjects = projects.filter((p) => p.isShared);
134
- if (sharedProjects.length === 0) {
135
- const result = [];
136
- collaboratorsCache.set(cacheKey, { result, timestamp: Date.now() });
137
- return result;
138
- }
139
- // Collect all collaborators from shared projects in parallel
140
- const allCollaborators = [];
141
- const seenIds = new Set();
142
- const collaboratorPromises = sharedProjects.map((project) => this.getProjectCollaborators(client, project.id));
143
- const collaboratorResults = await Promise.allSettled(collaboratorPromises);
144
- for (const result of collaboratorResults) {
145
- if (result.status === 'fulfilled') {
146
- for (const collaborator of result.value) {
147
- if (collaborator && !seenIds.has(collaborator.id)) {
148
- allCollaborators.push(collaborator);
149
- seenIds.add(collaborator.id);
150
- }
151
- }
152
- }
153
- // Skip failed projects, continue with others
154
- }
155
- collaboratorsCache.set(cacheKey, {
156
- result: allCollaborators,
157
- timestamp: Date.now(),
158
- });
159
- return allCollaborators;
160
- }
161
- catch (_error) {
162
- // Return empty array on error, don't cache failed requests
163
- return [];
164
- }
165
- }
166
- /**
167
- * Clear all caches - useful for testing
168
- */
169
- clearCache() {
170
- userResolutionCache.clear();
171
- collaboratorsCache.clear();
172
- }
173
- }
174
- // Export singleton instance
175
- export const userResolver = new UserResolver();
176
- // Legacy function for backwards compatibility
177
- export async function resolveUserNameToId(client, nameOrId) {
178
- return userResolver.resolveUser(client, nameOrId);
179
- }