atproto-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +293 -0
  3. package/dist/cli.d.ts +10 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +261 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/health-check.d.ts +7 -0
  8. package/dist/health-check.d.ts.map +1 -0
  9. package/dist/health-check.js +57 -0
  10. package/dist/health-check.js.map +1 -0
  11. package/dist/index.d.ts +122 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +612 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/prompts/index.d.ts +77 -0
  16. package/dist/prompts/index.d.ts.map +1 -0
  17. package/dist/prompts/index.js +186 -0
  18. package/dist/prompts/index.js.map +1 -0
  19. package/dist/resources/index.d.ts +75 -0
  20. package/dist/resources/index.d.ts.map +1 -0
  21. package/dist/resources/index.js +218 -0
  22. package/dist/resources/index.js.map +1 -0
  23. package/dist/test/setup.d.ts +78 -0
  24. package/dist/test/setup.d.ts.map +1 -0
  25. package/dist/test/setup.js +138 -0
  26. package/dist/test/setup.js.map +1 -0
  27. package/dist/tools/implementations/advanced-social-tools.d.ts +250 -0
  28. package/dist/tools/implementations/advanced-social-tools.d.ts.map +1 -0
  29. package/dist/tools/implementations/advanced-social-tools.js +380 -0
  30. package/dist/tools/implementations/advanced-social-tools.js.map +1 -0
  31. package/dist/tools/implementations/base-tool.d.ts +73 -0
  32. package/dist/tools/implementations/base-tool.d.ts.map +1 -0
  33. package/dist/tools/implementations/base-tool.js +225 -0
  34. package/dist/tools/implementations/base-tool.js.map +1 -0
  35. package/dist/tools/implementations/content-management-tools.d.ts +81 -0
  36. package/dist/tools/implementations/content-management-tools.d.ts.map +1 -0
  37. package/dist/tools/implementations/content-management-tools.js +236 -0
  38. package/dist/tools/implementations/content-management-tools.js.map +1 -0
  39. package/dist/tools/implementations/create-post-tool.d.ts +131 -0
  40. package/dist/tools/implementations/create-post-tool.d.ts.map +1 -0
  41. package/dist/tools/implementations/create-post-tool.js +182 -0
  42. package/dist/tools/implementations/create-post-tool.js.map +1 -0
  43. package/dist/tools/implementations/follow-user-tool.d.ts +69 -0
  44. package/dist/tools/implementations/follow-user-tool.d.ts.map +1 -0
  45. package/dist/tools/implementations/follow-user-tool.js +200 -0
  46. package/dist/tools/implementations/follow-user-tool.js.map +1 -0
  47. package/dist/tools/implementations/get-user-profile-tool.d.ts +61 -0
  48. package/dist/tools/implementations/get-user-profile-tool.d.ts.map +1 -0
  49. package/dist/tools/implementations/get-user-profile-tool.js +139 -0
  50. package/dist/tools/implementations/get-user-profile-tool.js.map +1 -0
  51. package/dist/tools/implementations/index.d.ts +22 -0
  52. package/dist/tools/implementations/index.d.ts.map +1 -0
  53. package/dist/tools/implementations/index.js +32 -0
  54. package/dist/tools/implementations/index.js.map +1 -0
  55. package/dist/tools/implementations/like-post-tool.d.ts +68 -0
  56. package/dist/tools/implementations/like-post-tool.d.ts.map +1 -0
  57. package/dist/tools/implementations/like-post-tool.js +184 -0
  58. package/dist/tools/implementations/like-post-tool.js.map +1 -0
  59. package/dist/tools/implementations/media-tools.d.ts +360 -0
  60. package/dist/tools/implementations/media-tools.d.ts.map +1 -0
  61. package/dist/tools/implementations/media-tools.js +444 -0
  62. package/dist/tools/implementations/media-tools.js.map +1 -0
  63. package/dist/tools/implementations/moderation-tools.d.ts +189 -0
  64. package/dist/tools/implementations/moderation-tools.d.ts.map +1 -0
  65. package/dist/tools/implementations/moderation-tools.js +289 -0
  66. package/dist/tools/implementations/moderation-tools.js.map +1 -0
  67. package/dist/tools/implementations/oauth-tools.d.ts +108 -0
  68. package/dist/tools/implementations/oauth-tools.d.ts.map +1 -0
  69. package/dist/tools/implementations/oauth-tools.js +183 -0
  70. package/dist/tools/implementations/oauth-tools.js.map +1 -0
  71. package/dist/tools/implementations/reply-to-post-tool.d.ts +52 -0
  72. package/dist/tools/implementations/reply-to-post-tool.d.ts.map +1 -0
  73. package/dist/tools/implementations/reply-to-post-tool.js +167 -0
  74. package/dist/tools/implementations/reply-to-post-tool.js.map +1 -0
  75. package/dist/tools/implementations/repost-tool.d.ts +76 -0
  76. package/dist/tools/implementations/repost-tool.d.ts.map +1 -0
  77. package/dist/tools/implementations/repost-tool.js +181 -0
  78. package/dist/tools/implementations/repost-tool.js.map +1 -0
  79. package/dist/tools/implementations/search-posts-tool.d.ts +95 -0
  80. package/dist/tools/implementations/search-posts-tool.d.ts.map +1 -0
  81. package/dist/tools/implementations/search-posts-tool.js +208 -0
  82. package/dist/tools/implementations/search-posts-tool.js.map +1 -0
  83. package/dist/tools/implementations/social-graph-tools.d.ts +119 -0
  84. package/dist/tools/implementations/social-graph-tools.d.ts.map +1 -0
  85. package/dist/tools/implementations/social-graph-tools.js +262 -0
  86. package/dist/tools/implementations/social-graph-tools.js.map +1 -0
  87. package/dist/tools/implementations/streaming-tools.d.ts +130 -0
  88. package/dist/tools/implementations/streaming-tools.d.ts.map +1 -0
  89. package/dist/tools/implementations/streaming-tools.js +241 -0
  90. package/dist/tools/implementations/streaming-tools.js.map +1 -0
  91. package/dist/tools/implementations/timeline-tools.d.ts +69 -0
  92. package/dist/tools/implementations/timeline-tools.d.ts.map +1 -0
  93. package/dist/tools/implementations/timeline-tools.js +194 -0
  94. package/dist/tools/implementations/timeline-tools.js.map +1 -0
  95. package/dist/tools/index.d.ts +23 -0
  96. package/dist/tools/index.d.ts.map +1 -0
  97. package/dist/tools/index.js +73 -0
  98. package/dist/tools/index.js.map +1 -0
  99. package/dist/types/index.d.ts +242 -0
  100. package/dist/types/index.d.ts.map +1 -0
  101. package/dist/types/index.js +73 -0
  102. package/dist/types/index.js.map +1 -0
  103. package/dist/utils/atp-client.d.ts +109 -0
  104. package/dist/utils/atp-client.d.ts.map +1 -0
  105. package/dist/utils/atp-client.js +451 -0
  106. package/dist/utils/atp-client.js.map +1 -0
  107. package/dist/utils/config.d.ts +74 -0
  108. package/dist/utils/config.d.ts.map +1 -0
  109. package/dist/utils/config.js +311 -0
  110. package/dist/utils/config.js.map +1 -0
  111. package/dist/utils/firehose-client.d.ts +96 -0
  112. package/dist/utils/firehose-client.d.ts.map +1 -0
  113. package/dist/utils/firehose-client.js +252 -0
  114. package/dist/utils/firehose-client.js.map +1 -0
  115. package/dist/utils/logger.d.ts +74 -0
  116. package/dist/utils/logger.d.ts.map +1 -0
  117. package/dist/utils/logger.js +142 -0
  118. package/dist/utils/logger.js.map +1 -0
  119. package/dist/utils/oauth-client.d.ts +61 -0
  120. package/dist/utils/oauth-client.d.ts.map +1 -0
  121. package/dist/utils/oauth-client.js +224 -0
  122. package/dist/utils/oauth-client.js.map +1 -0
  123. package/dist/utils/performance.d.ts +102 -0
  124. package/dist/utils/performance.d.ts.map +1 -0
  125. package/dist/utils/performance.js +302 -0
  126. package/dist/utils/performance.js.map +1 -0
  127. package/dist/utils/security.d.ts +154 -0
  128. package/dist/utils/security.d.ts.map +1 -0
  129. package/dist/utils/security.js +358 -0
  130. package/dist/utils/security.js.map +1 -0
  131. package/package.json +93 -0
@@ -0,0 +1,444 @@
1
+ /**
2
+ * Enhanced media support tools for AT Protocol
3
+ */
4
+ import { z } from 'zod';
5
+ import { BaseTool } from './base-tool.js';
6
+ import { readFile } from 'fs/promises';
7
+ import { extname } from 'path';
8
+ const UploadImageSchema = z.object({
9
+ filePath: z.string().min(1, 'File path is required'),
10
+ altText: z.string().max(1000, 'Alt text cannot exceed 1000 characters').optional(),
11
+ });
12
+ const UploadVideoSchema = z.object({
13
+ filePath: z.string().min(1, 'File path is required'),
14
+ altText: z.string().max(1000, 'Alt text cannot exceed 1000 characters').optional(),
15
+ captions: z
16
+ .array(z.object({
17
+ lang: z.string().min(2, 'Language code must be at least 2 characters'),
18
+ file: z.string().min(1, 'Caption file path is required'),
19
+ }))
20
+ .optional(),
21
+ });
22
+ const CreateRichTextPostSchema = z.object({
23
+ text: z.string().min(1, 'Post text is required').max(300, 'Post cannot exceed 300 characters'),
24
+ facets: z
25
+ .array(z.object({
26
+ index: z.object({
27
+ byteStart: z.number().min(0),
28
+ byteEnd: z.number().min(0),
29
+ }),
30
+ features: z.array(z.object({
31
+ type: z.enum(['mention', 'link', 'hashtag']),
32
+ value: z.string(),
33
+ })),
34
+ }))
35
+ .optional(),
36
+ embed: z
37
+ .object({
38
+ type: z.enum(['images', 'external', 'record']),
39
+ images: z
40
+ .array(z.object({
41
+ image: z.string(),
42
+ alt: z.string(),
43
+ }))
44
+ .optional(),
45
+ external: z
46
+ .object({
47
+ uri: z.string().url(),
48
+ title: z.string(),
49
+ description: z.string(),
50
+ thumb: z.string().optional(),
51
+ })
52
+ .optional(),
53
+ record: z
54
+ .object({
55
+ uri: z.string(),
56
+ cid: z.string(),
57
+ })
58
+ .optional(),
59
+ })
60
+ .optional(),
61
+ });
62
+ const GenerateLinkPreviewSchema = z.object({
63
+ url: z.string().url('Must be a valid URL'),
64
+ });
65
+ export class UploadImageTool extends BaseTool {
66
+ schema = {
67
+ method: 'upload_image',
68
+ description: 'Upload an image file to AT Protocol for use in posts. Supports JPEG, PNG, GIF, and WebP formats.',
69
+ params: UploadImageSchema,
70
+ };
71
+ constructor(atpClient) {
72
+ super(atpClient, 'UploadImage');
73
+ }
74
+ async execute(params) {
75
+ try {
76
+ this.logger.info('Uploading image', {
77
+ filePath: params.filePath,
78
+ hasAltText: !!params.altText,
79
+ });
80
+ // Read the image file
81
+ const imageData = await readFile(params.filePath);
82
+ const fileExtension = extname(params.filePath).toLowerCase();
83
+ // Determine MIME type
84
+ const mimeTypeMap = {
85
+ '.jpg': 'image/jpeg',
86
+ '.jpeg': 'image/jpeg',
87
+ '.png': 'image/png',
88
+ '.gif': 'image/gif',
89
+ '.webp': 'image/webp',
90
+ };
91
+ const mimeType = mimeTypeMap[fileExtension];
92
+ if (!mimeType) {
93
+ throw new Error(`Unsupported image format: ${fileExtension}`);
94
+ }
95
+ // Check file size (max 1MB for images)
96
+ if (imageData.length > 1024 * 1024) {
97
+ throw new Error('Image file size cannot exceed 1MB');
98
+ }
99
+ const response = await this.executeAtpOperation(async () => {
100
+ const agent = this.atpClient.getAgent();
101
+ return await agent.uploadBlob(imageData, {
102
+ encoding: mimeType,
103
+ });
104
+ }, 'uploadImage', { filePath: params.filePath, size: imageData.length });
105
+ this.logger.info('Image uploaded successfully', {
106
+ filePath: params.filePath,
107
+ blobRef: response.data.blob.ref,
108
+ size: response.data.blob.size,
109
+ });
110
+ return {
111
+ success: true,
112
+ message: `Image uploaded successfully from ${params.filePath}`,
113
+ image: {
114
+ blob: {
115
+ type: 'blob',
116
+ ref: response.data?.blob?.ref || '',
117
+ mimeType: response.data?.blob?.mimeType || mimeType,
118
+ size: response.data?.blob?.size || imageData.length,
119
+ },
120
+ alt: params.altText || '',
121
+ aspectRatio: {
122
+ width: 1,
123
+ height: 1, // Default aspect ratio, would need image processing to get actual dimensions
124
+ },
125
+ },
126
+ };
127
+ }
128
+ catch (error) {
129
+ this.logger.error('Failed to upload image', error);
130
+ this.formatError(error);
131
+ }
132
+ }
133
+ }
134
+ export class UploadVideoTool extends BaseTool {
135
+ schema = {
136
+ method: 'upload_video',
137
+ description: 'Upload a video file to AT Protocol for use in posts. Supports MP4, MOV, and WebM formats.',
138
+ params: UploadVideoSchema,
139
+ };
140
+ constructor(atpClient) {
141
+ super(atpClient, 'UploadVideo');
142
+ }
143
+ async execute(params) {
144
+ try {
145
+ this.logger.info('Uploading video', {
146
+ filePath: params.filePath,
147
+ hasAltText: !!params.altText,
148
+ captionCount: params.captions?.length || 0,
149
+ });
150
+ // Read the video file
151
+ const videoData = await readFile(params.filePath);
152
+ const fileExtension = extname(params.filePath).toLowerCase();
153
+ // Determine MIME type
154
+ const mimeTypeMap = {
155
+ '.mp4': 'video/mp4',
156
+ '.mov': 'video/quicktime',
157
+ '.webm': 'video/webm',
158
+ };
159
+ const mimeType = mimeTypeMap[fileExtension];
160
+ if (!mimeType) {
161
+ throw new Error(`Unsupported video format: ${fileExtension}`);
162
+ }
163
+ // Check file size (max 50MB for videos)
164
+ if (videoData.length > 50 * 1024 * 1024) {
165
+ throw new Error('Video file size cannot exceed 50MB');
166
+ }
167
+ const response = await this.executeAtpOperation(async () => {
168
+ const agent = this.atpClient.getAgent();
169
+ return await agent.uploadBlob(videoData, {
170
+ encoding: mimeType,
171
+ });
172
+ }, 'uploadVideo', { filePath: params.filePath, size: videoData.length });
173
+ // Upload captions if provided
174
+ let processedCaptions;
175
+ if (params.captions && params.captions.length > 0) {
176
+ processedCaptions = [];
177
+ for (const caption of params.captions) {
178
+ try {
179
+ const captionData = await readFile(caption.file);
180
+ const captionResponse = await this.executeAtpOperation(async () => {
181
+ const agent = this.atpClient.getAgent();
182
+ return await agent.uploadBlob(captionData, {
183
+ encoding: 'text/vtt',
184
+ });
185
+ }, 'uploadCaption', { file: caption.file, lang: caption.lang });
186
+ processedCaptions.push({
187
+ lang: caption.lang,
188
+ file: captionResponse.data?.blob?.ref || '',
189
+ });
190
+ }
191
+ catch (captionError) {
192
+ this.logger.warn('Failed to upload caption', captionError);
193
+ }
194
+ }
195
+ }
196
+ this.logger.info('Video uploaded successfully', {
197
+ filePath: params.filePath,
198
+ blobRef: response.data.blob.ref,
199
+ size: response.data.blob.size,
200
+ captionCount: processedCaptions?.length || 0,
201
+ });
202
+ return {
203
+ success: true,
204
+ message: `Video uploaded successfully from ${params.filePath}`,
205
+ video: {
206
+ blob: {
207
+ type: 'blob',
208
+ ref: response.data?.blob?.ref || '',
209
+ mimeType: response.data?.blob?.mimeType || mimeType,
210
+ size: response.data?.blob?.size || videoData.length,
211
+ },
212
+ alt: params.altText || '',
213
+ aspectRatio: {
214
+ width: 16,
215
+ height: 9, // Default aspect ratio, would need video processing to get actual dimensions
216
+ },
217
+ captions: processedCaptions,
218
+ },
219
+ };
220
+ }
221
+ catch (error) {
222
+ this.logger.error('Failed to upload video', error);
223
+ this.formatError(error);
224
+ }
225
+ }
226
+ }
227
+ export class CreateRichTextPostTool extends BaseTool {
228
+ schema = {
229
+ method: 'create_rich_text_post',
230
+ description: 'Create a post with rich text formatting, including mentions, links, hashtags, and media embeds.',
231
+ params: CreateRichTextPostSchema,
232
+ };
233
+ constructor(atpClient) {
234
+ super(atpClient, 'CreateRichTextPost');
235
+ }
236
+ async execute(params) {
237
+ try {
238
+ this.logger.info('Creating rich text post', {
239
+ textLength: params.text.length,
240
+ hasFacets: !!params.facets?.length,
241
+ hasEmbed: !!params.embed,
242
+ });
243
+ // Build the post record
244
+ const postRecord = {
245
+ text: params.text,
246
+ createdAt: new Date().toISOString(),
247
+ };
248
+ // Add facets if provided
249
+ if (params.facets && params.facets.length > 0) {
250
+ postRecord.facets = params.facets.map(facet => ({
251
+ index: facet.index,
252
+ features: facet.features.map(feature => {
253
+ switch (feature.type) {
254
+ case 'mention':
255
+ return {
256
+ $type: 'app.bsky.richtext.facet#mention',
257
+ did: feature.value,
258
+ };
259
+ case 'link':
260
+ return {
261
+ $type: 'app.bsky.richtext.facet#link',
262
+ uri: feature.value,
263
+ };
264
+ case 'hashtag':
265
+ return {
266
+ $type: 'app.bsky.richtext.facet#tag',
267
+ tag: feature.value,
268
+ };
269
+ default:
270
+ return feature;
271
+ }
272
+ }),
273
+ }));
274
+ }
275
+ // Add embed if provided
276
+ if (params.embed) {
277
+ switch (params.embed.type) {
278
+ case 'images':
279
+ if (params.embed.images) {
280
+ postRecord.embed = {
281
+ $type: 'app.bsky.embed.images',
282
+ images: params.embed.images.map(img => ({
283
+ image: { $type: 'blob', ref: img.image },
284
+ alt: img.alt,
285
+ })),
286
+ };
287
+ }
288
+ break;
289
+ case 'external':
290
+ if (params.embed.external) {
291
+ postRecord.embed = {
292
+ $type: 'app.bsky.embed.external',
293
+ external: {
294
+ uri: params.embed.external.uri,
295
+ title: params.embed.external.title,
296
+ description: params.embed.external.description,
297
+ thumb: params.embed.external.thumb
298
+ ? { $type: 'blob', ref: params.embed.external.thumb }
299
+ : undefined,
300
+ },
301
+ };
302
+ }
303
+ break;
304
+ case 'record':
305
+ if (params.embed.record) {
306
+ postRecord.embed = {
307
+ $type: 'app.bsky.embed.record',
308
+ record: {
309
+ uri: params.embed.record.uri,
310
+ cid: params.embed.record.cid,
311
+ },
312
+ };
313
+ }
314
+ break;
315
+ }
316
+ }
317
+ const response = await this.executeAtpOperation(async () => {
318
+ const agent = this.atpClient.getAgent();
319
+ return await agent.post(postRecord);
320
+ }, 'createRichTextPost', { textLength: params.text.length, hasEmbed: !!params.embed });
321
+ this.logger.info('Rich text post created successfully', {
322
+ uri: response.uri,
323
+ cid: response.cid,
324
+ });
325
+ return {
326
+ success: true,
327
+ message: 'Rich text post created successfully',
328
+ post: {
329
+ uri: response.uri,
330
+ cid: response.cid,
331
+ text: params.text,
332
+ facets: postRecord.facets,
333
+ embed: postRecord.embed,
334
+ createdAt: postRecord.createdAt,
335
+ },
336
+ };
337
+ }
338
+ catch (error) {
339
+ this.logger.error('Failed to create rich text post', error);
340
+ this.formatError(error);
341
+ }
342
+ }
343
+ }
344
+ export class GenerateLinkPreviewTool extends BaseTool {
345
+ schema = {
346
+ method: 'generate_link_preview',
347
+ description: 'Generate a link preview with title, description, and thumbnail for a given URL.',
348
+ params: GenerateLinkPreviewSchema,
349
+ };
350
+ constructor(atpClient) {
351
+ super(atpClient, 'GenerateLinkPreview');
352
+ }
353
+ async execute(params) {
354
+ try {
355
+ this.logger.info('Generating link preview', {
356
+ url: params.url,
357
+ });
358
+ // Validate URL
359
+ try {
360
+ new URL(params.url);
361
+ }
362
+ catch {
363
+ throw new Error('Invalid URL provided');
364
+ }
365
+ // Fetch the webpage content
366
+ const response = await fetch(params.url, {
367
+ headers: {
368
+ 'User-Agent': 'AT Protocol MCP Server/1.0',
369
+ },
370
+ });
371
+ if (!response.ok) {
372
+ throw new Error(`Failed to fetch URL: ${response.status} ${response.statusText}`);
373
+ }
374
+ const html = await response.text();
375
+ // Extract metadata using simple regex patterns
376
+ // In production, use a proper HTML parser like cheerio
377
+ const titleMatch = html.match(/<title[^>]*>([^<]+)<\/title>/i) ||
378
+ html.match(/<meta[^>]*property="og:title"[^>]*content="([^"]*)"[^>]*>/i);
379
+ const descriptionMatch = html.match(/<meta[^>]*name="description"[^>]*content="([^"]*)"[^>]*>/i) ||
380
+ html.match(/<meta[^>]*property="og:description"[^>]*content="([^"]*)"[^>]*>/i);
381
+ const imageMatch = html.match(/<meta[^>]*property="og:image"[^>]*content="([^"]*)"[^>]*>/i);
382
+ const title = titleMatch?.[1]?.trim() || new URL(params.url).hostname;
383
+ const description = descriptionMatch?.[1]?.trim() || '';
384
+ const imageUrl = imageMatch?.[1]?.trim() || null;
385
+ let thumbBlob;
386
+ if (imageUrl) {
387
+ try {
388
+ // Download and upload the thumbnail image
389
+ const imageResponse = await fetch(imageUrl, {
390
+ headers: {
391
+ 'User-Agent': 'AT Protocol MCP Server/1.0',
392
+ },
393
+ });
394
+ if (imageResponse.ok) {
395
+ const imageData = await imageResponse.arrayBuffer();
396
+ const imageBuffer = Buffer.from(imageData);
397
+ // Check image size (max 1MB)
398
+ if (imageBuffer.length <= 1024 * 1024) {
399
+ const contentType = imageResponse.headers.get('content-type') || 'image/jpeg';
400
+ const uploadResponse = await this.executeAtpOperation(async () => {
401
+ const agent = this.atpClient.getAgent();
402
+ return await agent.uploadBlob(imageBuffer, {
403
+ encoding: contentType,
404
+ });
405
+ }, 'uploadThumbnail', { imageUrl, size: imageBuffer.length });
406
+ thumbBlob = {
407
+ blob: {
408
+ type: 'blob',
409
+ ref: uploadResponse.data?.blob?.ref || '',
410
+ mimeType: uploadResponse.data?.blob?.mimeType || contentType,
411
+ size: uploadResponse.data?.blob?.size || imageBuffer.length,
412
+ },
413
+ };
414
+ }
415
+ }
416
+ }
417
+ catch (imageError) {
418
+ this.logger.warn('Failed to download thumbnail image', imageError);
419
+ }
420
+ }
421
+ this.logger.info('Link preview generated successfully', {
422
+ url: params.url,
423
+ title: `${title.substring(0, 50)}...`,
424
+ hasDescription: !!description,
425
+ hasThumb: !!thumbBlob,
426
+ });
427
+ return {
428
+ success: true,
429
+ message: `Link preview generated for ${params.url}`,
430
+ preview: {
431
+ uri: params.url,
432
+ title: title.substring(0, 300), // Limit title length
433
+ description: description.substring(0, 1000), // Limit description length
434
+ thumb: thumbBlob,
435
+ },
436
+ };
437
+ }
438
+ catch (error) {
439
+ this.logger.error('Failed to generate link preview', error);
440
+ this.formatError(error);
441
+ }
442
+ }
443
+ }
444
+ //# sourceMappingURL=media-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-tools.js","sourceRoot":"","sources":["../../../src/tools/implementations/media-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;IACpD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,wCAAwC,CAAC,CAAC,QAAQ,EAAE;CACnF,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;IACpD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,wCAAwC,CAAC,CAAC,QAAQ,EAAE;IAClF,QAAQ,EAAE,CAAC;SACR,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,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C;gBAC9E,CAAC;YACH,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE;gBACtD,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,KAAK,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK;gBACrC,cAAc,EAAE,CAAC,CAAC,WAAW;gBAC7B,QAAQ,EAAE,CAAC,CAAC,SAAS;aACtB,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,8BAA8B,MAAM,CAAC,GAAG,EAAE;gBACnD,OAAO,EAAE;oBACP,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,qBAAqB;oBACrD,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,2BAA2B;oBACxE,KAAK,EAAE,SAAS;iBACjB;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;YAC5D,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Content moderation tools for AT Protocol
3
+ */
4
+ import { z } from 'zod';
5
+ import { BaseTool } from './base-tool.js';
6
+ import type { AtpClient } from '../../utils/atp-client.js';
7
+ export declare class MuteUserTool extends BaseTool {
8
+ readonly schema: {
9
+ method: string;
10
+ description: string;
11
+ params: z.ZodObject<{
12
+ actor: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ actor: string;
15
+ }, {
16
+ actor: string;
17
+ }>;
18
+ };
19
+ constructor(atpClient: AtpClient);
20
+ protected execute(params: {
21
+ actor: string;
22
+ }): Promise<{
23
+ success: boolean;
24
+ message: string;
25
+ mutedUser: {
26
+ actor: string;
27
+ did?: string;
28
+ };
29
+ }>;
30
+ }
31
+ export declare class UnmuteUserTool extends BaseTool {
32
+ readonly schema: {
33
+ method: string;
34
+ description: string;
35
+ params: z.ZodObject<{
36
+ actor: z.ZodString;
37
+ }, "strip", z.ZodTypeAny, {
38
+ actor: string;
39
+ }, {
40
+ actor: string;
41
+ }>;
42
+ };
43
+ constructor(atpClient: AtpClient);
44
+ protected execute(params: {
45
+ actor: string;
46
+ }): Promise<{
47
+ success: boolean;
48
+ message: string;
49
+ unmutedUser: {
50
+ actor: string;
51
+ did?: string;
52
+ };
53
+ }>;
54
+ }
55
+ export declare class BlockUserTool extends BaseTool {
56
+ readonly schema: {
57
+ method: string;
58
+ description: string;
59
+ params: z.ZodObject<{
60
+ actor: z.ZodString;
61
+ }, "strip", z.ZodTypeAny, {
62
+ actor: string;
63
+ }, {
64
+ actor: string;
65
+ }>;
66
+ };
67
+ constructor(atpClient: AtpClient);
68
+ protected execute(params: {
69
+ actor: string;
70
+ }): Promise<{
71
+ success: boolean;
72
+ message: string;
73
+ blockedUser: {
74
+ actor: string;
75
+ did?: string;
76
+ uri?: string;
77
+ };
78
+ }>;
79
+ }
80
+ export declare class UnblockUserTool extends BaseTool {
81
+ readonly schema: {
82
+ method: string;
83
+ description: string;
84
+ params: z.ZodObject<{
85
+ actor: z.ZodString;
86
+ }, "strip", z.ZodTypeAny, {
87
+ actor: string;
88
+ }, {
89
+ actor: string;
90
+ }>;
91
+ };
92
+ constructor(atpClient: AtpClient);
93
+ protected execute(params: {
94
+ actor: string;
95
+ }): Promise<{
96
+ success: boolean;
97
+ message: string;
98
+ unblockedUser: {
99
+ actor: string;
100
+ };
101
+ }>;
102
+ }
103
+ export declare class ReportContentTool extends BaseTool {
104
+ readonly schema: {
105
+ method: string;
106
+ description: string;
107
+ params: z.ZodObject<{
108
+ subject: z.ZodObject<{
109
+ uri: z.ZodString;
110
+ cid: z.ZodString;
111
+ }, "strip", z.ZodTypeAny, {
112
+ uri: string;
113
+ cid: string;
114
+ }, {
115
+ uri: string;
116
+ cid: string;
117
+ }>;
118
+ reasonType: z.ZodEnum<["spam", "violation", "misleading", "sexual", "rude", "other"]>;
119
+ reason: z.ZodOptional<z.ZodString>;
120
+ }, "strip", z.ZodTypeAny, {
121
+ subject: {
122
+ uri: string;
123
+ cid: string;
124
+ };
125
+ reasonType: "spam" | "violation" | "misleading" | "sexual" | "rude" | "other";
126
+ reason?: string | undefined;
127
+ }, {
128
+ subject: {
129
+ uri: string;
130
+ cid: string;
131
+ };
132
+ reasonType: "spam" | "violation" | "misleading" | "sexual" | "rude" | "other";
133
+ reason?: string | undefined;
134
+ }>;
135
+ };
136
+ constructor(atpClient: AtpClient);
137
+ protected execute(params: {
138
+ subject: {
139
+ uri: string;
140
+ cid: string;
141
+ };
142
+ reasonType: string;
143
+ reason?: string;
144
+ }): Promise<{
145
+ success: boolean;
146
+ message: string;
147
+ reportId: string;
148
+ reportDetails: {
149
+ subject: string;
150
+ reasonType: string;
151
+ reason?: string;
152
+ };
153
+ }>;
154
+ }
155
+ export declare class ReportUserTool extends BaseTool {
156
+ readonly schema: {
157
+ method: string;
158
+ description: string;
159
+ params: z.ZodObject<{
160
+ actor: z.ZodString;
161
+ reasonType: z.ZodEnum<["spam", "violation", "misleading", "sexual", "rude", "other"]>;
162
+ reason: z.ZodOptional<z.ZodString>;
163
+ }, "strip", z.ZodTypeAny, {
164
+ actor: string;
165
+ reasonType: "spam" | "violation" | "misleading" | "sexual" | "rude" | "other";
166
+ reason?: string | undefined;
167
+ }, {
168
+ actor: string;
169
+ reasonType: "spam" | "violation" | "misleading" | "sexual" | "rude" | "other";
170
+ reason?: string | undefined;
171
+ }>;
172
+ };
173
+ constructor(atpClient: AtpClient);
174
+ protected execute(params: {
175
+ actor: string;
176
+ reasonType: string;
177
+ reason?: string;
178
+ }): Promise<{
179
+ success: boolean;
180
+ message: string;
181
+ reportId: string;
182
+ reportDetails: {
183
+ actor: string;
184
+ reasonType: string;
185
+ reason?: string;
186
+ };
187
+ }>;
188
+ }
189
+ //# sourceMappingURL=moderation-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moderation-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/implementations/moderation-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAiC3D,qBAAa,YAAa,SAAQ,QAAQ;IACxC,SAAgB,MAAM;;;;;;;;;;MAKpB;gBAEU,SAAS,EAAE,SAAS;cAIhB,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAC1D,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC;YACd,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CA8BH;AAED,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,SAAgB,MAAM;;;;;;;;;;MAIpB;gBAEU,SAAS,EAAE,SAAS;cAIhB,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAC1D,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE;YACX,KAAK,EAAE,MAAM,CAAC;YACd,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CA8BH;AAED,qBAAa,aAAc,SAAQ,QAAQ;IACzC,SAAgB,MAAM;;;;;;;;;;MAIpB;gBAEU,SAAS,EAAE,SAAS;cAIhB,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,C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