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.
- package/LICENSE +22 -0
- package/README.md +293 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +261 -0
- package/dist/cli.js.map +1 -0
- package/dist/health-check.d.ts +7 -0
- package/dist/health-check.d.ts.map +1 -0
- package/dist/health-check.js +57 -0
- package/dist/health-check.js.map +1 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +612 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/index.d.ts +77 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +186 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/resources/index.d.ts +75 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +218 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/test/setup.d.ts +78 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +138 -0
- package/dist/test/setup.js.map +1 -0
- package/dist/tools/implementations/advanced-social-tools.d.ts +250 -0
- package/dist/tools/implementations/advanced-social-tools.d.ts.map +1 -0
- package/dist/tools/implementations/advanced-social-tools.js +380 -0
- package/dist/tools/implementations/advanced-social-tools.js.map +1 -0
- package/dist/tools/implementations/base-tool.d.ts +73 -0
- package/dist/tools/implementations/base-tool.d.ts.map +1 -0
- package/dist/tools/implementations/base-tool.js +225 -0
- package/dist/tools/implementations/base-tool.js.map +1 -0
- package/dist/tools/implementations/content-management-tools.d.ts +81 -0
- package/dist/tools/implementations/content-management-tools.d.ts.map +1 -0
- package/dist/tools/implementations/content-management-tools.js +236 -0
- package/dist/tools/implementations/content-management-tools.js.map +1 -0
- package/dist/tools/implementations/create-post-tool.d.ts +131 -0
- package/dist/tools/implementations/create-post-tool.d.ts.map +1 -0
- package/dist/tools/implementations/create-post-tool.js +182 -0
- package/dist/tools/implementations/create-post-tool.js.map +1 -0
- package/dist/tools/implementations/follow-user-tool.d.ts +69 -0
- package/dist/tools/implementations/follow-user-tool.d.ts.map +1 -0
- package/dist/tools/implementations/follow-user-tool.js +200 -0
- package/dist/tools/implementations/follow-user-tool.js.map +1 -0
- package/dist/tools/implementations/get-user-profile-tool.d.ts +61 -0
- package/dist/tools/implementations/get-user-profile-tool.d.ts.map +1 -0
- package/dist/tools/implementations/get-user-profile-tool.js +139 -0
- package/dist/tools/implementations/get-user-profile-tool.js.map +1 -0
- package/dist/tools/implementations/index.d.ts +22 -0
- package/dist/tools/implementations/index.d.ts.map +1 -0
- package/dist/tools/implementations/index.js +32 -0
- package/dist/tools/implementations/index.js.map +1 -0
- package/dist/tools/implementations/like-post-tool.d.ts +68 -0
- package/dist/tools/implementations/like-post-tool.d.ts.map +1 -0
- package/dist/tools/implementations/like-post-tool.js +184 -0
- package/dist/tools/implementations/like-post-tool.js.map +1 -0
- package/dist/tools/implementations/media-tools.d.ts +360 -0
- package/dist/tools/implementations/media-tools.d.ts.map +1 -0
- package/dist/tools/implementations/media-tools.js +444 -0
- package/dist/tools/implementations/media-tools.js.map +1 -0
- package/dist/tools/implementations/moderation-tools.d.ts +189 -0
- package/dist/tools/implementations/moderation-tools.d.ts.map +1 -0
- package/dist/tools/implementations/moderation-tools.js +289 -0
- package/dist/tools/implementations/moderation-tools.js.map +1 -0
- package/dist/tools/implementations/oauth-tools.d.ts +108 -0
- package/dist/tools/implementations/oauth-tools.d.ts.map +1 -0
- package/dist/tools/implementations/oauth-tools.js +183 -0
- package/dist/tools/implementations/oauth-tools.js.map +1 -0
- package/dist/tools/implementations/reply-to-post-tool.d.ts +52 -0
- package/dist/tools/implementations/reply-to-post-tool.d.ts.map +1 -0
- package/dist/tools/implementations/reply-to-post-tool.js +167 -0
- package/dist/tools/implementations/reply-to-post-tool.js.map +1 -0
- package/dist/tools/implementations/repost-tool.d.ts +76 -0
- package/dist/tools/implementations/repost-tool.d.ts.map +1 -0
- package/dist/tools/implementations/repost-tool.js +181 -0
- package/dist/tools/implementations/repost-tool.js.map +1 -0
- package/dist/tools/implementations/search-posts-tool.d.ts +95 -0
- package/dist/tools/implementations/search-posts-tool.d.ts.map +1 -0
- package/dist/tools/implementations/search-posts-tool.js +208 -0
- package/dist/tools/implementations/search-posts-tool.js.map +1 -0
- package/dist/tools/implementations/social-graph-tools.d.ts +119 -0
- package/dist/tools/implementations/social-graph-tools.d.ts.map +1 -0
- package/dist/tools/implementations/social-graph-tools.js +262 -0
- package/dist/tools/implementations/social-graph-tools.js.map +1 -0
- package/dist/tools/implementations/streaming-tools.d.ts +130 -0
- package/dist/tools/implementations/streaming-tools.d.ts.map +1 -0
- package/dist/tools/implementations/streaming-tools.js +241 -0
- package/dist/tools/implementations/streaming-tools.js.map +1 -0
- package/dist/tools/implementations/timeline-tools.d.ts +69 -0
- package/dist/tools/implementations/timeline-tools.d.ts.map +1 -0
- package/dist/tools/implementations/timeline-tools.js +194 -0
- package/dist/tools/implementations/timeline-tools.js.map +1 -0
- package/dist/tools/index.d.ts +23 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +73 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/index.d.ts +242 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +73 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/atp-client.d.ts +109 -0
- package/dist/utils/atp-client.d.ts.map +1 -0
- package/dist/utils/atp-client.js +451 -0
- package/dist/utils/atp-client.js.map +1 -0
- package/dist/utils/config.d.ts +74 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +311 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/firehose-client.d.ts +96 -0
- package/dist/utils/firehose-client.d.ts.map +1 -0
- package/dist/utils/firehose-client.js +252 -0
- package/dist/utils/firehose-client.js.map +1 -0
- package/dist/utils/logger.d.ts +74 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +142 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/oauth-client.d.ts +61 -0
- package/dist/utils/oauth-client.d.ts.map +1 -0
- package/dist/utils/oauth-client.js +224 -0
- package/dist/utils/oauth-client.js.map +1 -0
- package/dist/utils/performance.d.ts +102 -0
- package/dist/utils/performance.d.ts.map +1 -0
- package/dist/utils/performance.js +302 -0
- package/dist/utils/performance.js.map +1 -0
- package/dist/utils/security.d.ts +154 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +358 -0
- package/dist/utils/security.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reply to Post Tool - Creates replies to existing posts on AT Protocol
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { BaseTool } from './base-tool.js';
|
|
6
|
+
/**
|
|
7
|
+
* Zod schema for reply to post parameters
|
|
8
|
+
*/
|
|
9
|
+
const ReplyToPostSchema = z.object({
|
|
10
|
+
text: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1, 'Reply text cannot be empty')
|
|
13
|
+
.max(300, 'Reply text cannot exceed 300 characters'),
|
|
14
|
+
root: z.string().min(1, 'Root post URI is required'),
|
|
15
|
+
parent: z.string().min(1, 'Parent post URI is required'),
|
|
16
|
+
langs: z.array(z.string().length(2, 'Language codes must be 2 characters')).optional(),
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Tool for replying to posts on AT Protocol
|
|
20
|
+
*/
|
|
21
|
+
export class ReplyToPostTool extends BaseTool {
|
|
22
|
+
schema = {
|
|
23
|
+
method: 'reply_to_post',
|
|
24
|
+
description: 'Reply to an existing post on AT Protocol. Creates a threaded reply with proper parent/root references.',
|
|
25
|
+
params: ReplyToPostSchema,
|
|
26
|
+
};
|
|
27
|
+
constructor(atpClient) {
|
|
28
|
+
super(atpClient, 'ReplyToPost');
|
|
29
|
+
}
|
|
30
|
+
async execute(params) {
|
|
31
|
+
try {
|
|
32
|
+
this.logger.info('Creating reply to post', {
|
|
33
|
+
textLength: params.text.length,
|
|
34
|
+
root: params.root,
|
|
35
|
+
parent: params.parent,
|
|
36
|
+
langs: params.langs,
|
|
37
|
+
});
|
|
38
|
+
// Validate the URIs
|
|
39
|
+
this.validateAtUri(params.root);
|
|
40
|
+
this.validateAtUri(params.parent);
|
|
41
|
+
// Get CIDs for the root and parent posts
|
|
42
|
+
const [rootCid, parentCid] = await Promise.all([
|
|
43
|
+
this.getCidFromUri(params.root),
|
|
44
|
+
this.getCidFromUri(params.parent),
|
|
45
|
+
]);
|
|
46
|
+
// Build the reply record
|
|
47
|
+
const replyRecord = {
|
|
48
|
+
$type: 'app.bsky.feed.post',
|
|
49
|
+
text: params.text,
|
|
50
|
+
createdAt: new Date().toISOString(),
|
|
51
|
+
reply: {
|
|
52
|
+
root: {
|
|
53
|
+
uri: params.root,
|
|
54
|
+
cid: rootCid,
|
|
55
|
+
},
|
|
56
|
+
parent: {
|
|
57
|
+
uri: params.parent,
|
|
58
|
+
cid: parentCid,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
// Add language tags if provided
|
|
63
|
+
if (params.langs && params.langs.length > 0) {
|
|
64
|
+
replyRecord.langs = params.langs;
|
|
65
|
+
}
|
|
66
|
+
// Create the reply using AT Protocol
|
|
67
|
+
const response = await this.executeAtpOperation(async () => {
|
|
68
|
+
const agent = this.atpClient.getAgent();
|
|
69
|
+
return await agent.post(replyRecord);
|
|
70
|
+
}, 'createReply', {
|
|
71
|
+
textLength: params.text.length,
|
|
72
|
+
root: params.root,
|
|
73
|
+
parent: params.parent,
|
|
74
|
+
});
|
|
75
|
+
this.logger.info('Reply created successfully', {
|
|
76
|
+
uri: response.uri,
|
|
77
|
+
cid: response.cid,
|
|
78
|
+
root: params.root,
|
|
79
|
+
parent: params.parent,
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
uri: response.uri,
|
|
83
|
+
cid: response.cid,
|
|
84
|
+
success: true,
|
|
85
|
+
message: 'Reply created successfully',
|
|
86
|
+
replyTo: {
|
|
87
|
+
root: params.root,
|
|
88
|
+
parent: params.parent,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.logger.error('Failed to create reply', error);
|
|
94
|
+
this.formatError(error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get CID from AT Protocol URI by fetching the record
|
|
99
|
+
*/
|
|
100
|
+
async getCidFromUri(uri) {
|
|
101
|
+
try {
|
|
102
|
+
this.logger.debug('Resolving CID from URI', { uri });
|
|
103
|
+
const response = await this.executeAtpOperation(async () => {
|
|
104
|
+
const agent = this.atpClient.getAgent();
|
|
105
|
+
// Parse the AT URI to extract components
|
|
106
|
+
const uriParts = uri.replace('at://', '').split('/');
|
|
107
|
+
if (uriParts.length < 3) {
|
|
108
|
+
throw new Error(`Invalid AT URI format: ${uri}`);
|
|
109
|
+
}
|
|
110
|
+
const did = uriParts[0];
|
|
111
|
+
const collection = uriParts[1];
|
|
112
|
+
const rkey = uriParts[2];
|
|
113
|
+
if (!did || !collection || !rkey) {
|
|
114
|
+
throw new Error(`Invalid AT URI components: ${uri}`);
|
|
115
|
+
}
|
|
116
|
+
// Get the record to obtain its CID
|
|
117
|
+
return await agent.com.atproto.repo.getRecord({
|
|
118
|
+
repo: did,
|
|
119
|
+
collection,
|
|
120
|
+
rkey,
|
|
121
|
+
});
|
|
122
|
+
}, 'getRecord', { uri });
|
|
123
|
+
const cid = response.data.cid;
|
|
124
|
+
if (!cid) {
|
|
125
|
+
throw new Error(`No CID found for URI: ${uri}`);
|
|
126
|
+
}
|
|
127
|
+
this.logger.debug('Resolved CID from URI', { uri, cid });
|
|
128
|
+
return cid;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
this.logger.error('Failed to resolve CID from URI', error);
|
|
132
|
+
// Fallback to extracting rkey as CID (not ideal but prevents failure)
|
|
133
|
+
const parts = uri.split('/');
|
|
134
|
+
const rkey = parts[parts.length - 1];
|
|
135
|
+
this.logger.warn('Using rkey as fallback CID', { uri, rkey });
|
|
136
|
+
return rkey || 'fallback-cid';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Validate that the parent and root posts exist and are accessible
|
|
141
|
+
*/
|
|
142
|
+
async validatePostExists(uri) {
|
|
143
|
+
try {
|
|
144
|
+
await this.executeAtpOperation(async () => {
|
|
145
|
+
const agent = this.atpClient.getAgent();
|
|
146
|
+
const uriParts = uri.replace('at://', '').split('/');
|
|
147
|
+
const did = uriParts[0];
|
|
148
|
+
const collection = uriParts[1];
|
|
149
|
+
const rkey = uriParts[2];
|
|
150
|
+
if (!did || !collection || !rkey) {
|
|
151
|
+
throw new Error(`Invalid AT URI components: ${uri}`);
|
|
152
|
+
}
|
|
153
|
+
return await agent.com.atproto.repo.getRecord({
|
|
154
|
+
repo: did,
|
|
155
|
+
collection,
|
|
156
|
+
rkey,
|
|
157
|
+
});
|
|
158
|
+
}, 'validatePost', { uri });
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
this.logger.warn('Post validation failed', error);
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=reply-to-post-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply-to-post-tool.js","sourceRoot":"","sources":["../../../src/tools/implementations/reply-to-post-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC;SACJ,M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;gBACxC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrD,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACxB,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAEzB,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,EAAE,CAAC;oBACjC,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;gBACvD,CAAC;gBAED,OAAO,MAAM,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;oBAC5C,IAAI,EAAE,GAAG;oBACT,UAAU;oBACV,IAAI;iBACL,CAAC,CAAC;YACL,CAAC,EACD,cAAc,EACd,EAAE,GAAG,EAAE,CACR,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YAClD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repost Tool - Reposts content on 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
|
+
import type { ATURI, CID, IRepostParams } from '../../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Tool for reposting content on AT Protocol
|
|
10
|
+
*/
|
|
11
|
+
export declare class RepostTool extends BaseTool {
|
|
12
|
+
readonly schema: {
|
|
13
|
+
method: string;
|
|
14
|
+
description: string;
|
|
15
|
+
params: z.ZodObject<{
|
|
16
|
+
uri: z.ZodString;
|
|
17
|
+
cid: z.ZodString;
|
|
18
|
+
text: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
uri: string;
|
|
21
|
+
cid: string;
|
|
22
|
+
text?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
uri: string;
|
|
25
|
+
cid: string;
|
|
26
|
+
text?: string | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
constructor(atpClient: AtpClient);
|
|
30
|
+
protected execute(params: IRepostParams): Promise<{
|
|
31
|
+
uri: ATURI;
|
|
32
|
+
cid: CID;
|
|
33
|
+
success: boolean;
|
|
34
|
+
message: string;
|
|
35
|
+
repostedPost: {
|
|
36
|
+
uri: ATURI;
|
|
37
|
+
cid: CID;
|
|
38
|
+
};
|
|
39
|
+
isQuotePost: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Create a simple repost record
|
|
43
|
+
*/
|
|
44
|
+
private createSimpleRepost;
|
|
45
|
+
/**
|
|
46
|
+
* Create a quote post (post with embedded repost)
|
|
47
|
+
*/
|
|
48
|
+
private createQuotePost;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Unrepost Tool - Removes reposts on AT Protocol
|
|
52
|
+
*/
|
|
53
|
+
export declare class UnrepostTool extends BaseTool {
|
|
54
|
+
readonly schema: {
|
|
55
|
+
method: string;
|
|
56
|
+
description: string;
|
|
57
|
+
params: z.ZodObject<{
|
|
58
|
+
repostUri: z.ZodString;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
repostUri: string;
|
|
61
|
+
}, {
|
|
62
|
+
repostUri: string;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
constructor(atpClient: AtpClient);
|
|
66
|
+
protected execute(params: {
|
|
67
|
+
repostUri: string;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
message: string;
|
|
71
|
+
deletedRepost: {
|
|
72
|
+
uri: ATURI;
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=repost-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repost-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/implementations/repost-tool.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;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAWtE;;GAEG;AACH,qBAAa,UAAW,SAAQ,QAAQ;IACtC,SAAgB,MAAM;;;;;;;;;;;;;;;;MAKpB;gBAEU,SAAS,EAAE,SAAS;cAIhB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC;QACtD,GAAG,EAAE,KAAK,CAAC;QACX,GAAG,EAAE,GAAG,CAAC;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE;YACZ,GAAG,EAAE,KAAK,CAAC;YACX,GAAG,EAAE,GAAG,CAAC;SACV,CAAC;QACF,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;IA2DF;;OAEG;YACW,kBAAkB;IA2BhC;;OAEG;YACW,eAAe;CA2B9B;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACxC,SAAgB,MAAM;;;;;;;;;;MAMpB;gBAEU,SAAS,EAAE,SAAS;cAIhB,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAC9D,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE;YACb,GAAG,EAAE,KAAK,CAAC;SACZ,CAAC;KACH,CAAC;CAgDH"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repost Tool - Reposts content on AT Protocol
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { BaseTool } from './base-tool.js';
|
|
6
|
+
/**
|
|
7
|
+
* Zod schema for repost parameters
|
|
8
|
+
*/
|
|
9
|
+
const RepostSchema = z.object({
|
|
10
|
+
uri: z.string().min(1, 'Post URI is required'),
|
|
11
|
+
cid: z.string().min(1, 'Post CID is required'),
|
|
12
|
+
text: z.string().max(300, 'Quote text cannot exceed 300 characters').optional(),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Tool for reposting content on AT Protocol
|
|
16
|
+
*/
|
|
17
|
+
export class RepostTool extends BaseTool {
|
|
18
|
+
schema = {
|
|
19
|
+
method: 'repost',
|
|
20
|
+
description: 'Repost content on AT Protocol. Can be a simple repost or a quote post with additional text.',
|
|
21
|
+
params: RepostSchema,
|
|
22
|
+
};
|
|
23
|
+
constructor(atpClient) {
|
|
24
|
+
super(atpClient, 'Repost');
|
|
25
|
+
}
|
|
26
|
+
async execute(params) {
|
|
27
|
+
try {
|
|
28
|
+
this.logger.info('Creating repost', {
|
|
29
|
+
postUri: params.uri,
|
|
30
|
+
postCid: params.cid,
|
|
31
|
+
hasQuoteText: params.text != null && params.text !== '',
|
|
32
|
+
quoteTextLength: params.text?.length ?? 0,
|
|
33
|
+
});
|
|
34
|
+
// Validate the post URI and CID
|
|
35
|
+
this.validateAtUri(params.uri);
|
|
36
|
+
this.validateCid(params.cid);
|
|
37
|
+
// Check if this is a quote post or simple repost
|
|
38
|
+
const isQuotePost = params.text != null && params.text !== '';
|
|
39
|
+
let response;
|
|
40
|
+
if (isQuotePost) {
|
|
41
|
+
// Create a quote post (post with embedded repost)
|
|
42
|
+
response = await this.createQuotePost(params);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Create a simple repost
|
|
46
|
+
response = await this.createSimpleRepost(params);
|
|
47
|
+
}
|
|
48
|
+
const responseUri = 'data' in response
|
|
49
|
+
? response.data.uri
|
|
50
|
+
: response.uri;
|
|
51
|
+
const responseCid = 'data' in response
|
|
52
|
+
? response.data.cid
|
|
53
|
+
: response.cid;
|
|
54
|
+
this.logger.info('Repost created successfully', {
|
|
55
|
+
repostUri: responseUri,
|
|
56
|
+
repostCid: responseCid,
|
|
57
|
+
postUri: params.uri,
|
|
58
|
+
isQuotePost,
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
uri: responseUri,
|
|
62
|
+
cid: responseCid,
|
|
63
|
+
success: true,
|
|
64
|
+
message: isQuotePost ? 'Quote post created successfully' : 'Repost created successfully',
|
|
65
|
+
repostedPost: {
|
|
66
|
+
uri: params.uri,
|
|
67
|
+
cid: params.cid,
|
|
68
|
+
},
|
|
69
|
+
isQuotePost,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
this.logger.error('Failed to create repost', error);
|
|
74
|
+
this.formatError(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create a simple repost record
|
|
79
|
+
*/
|
|
80
|
+
async createSimpleRepost(params) {
|
|
81
|
+
const repostRecord = {
|
|
82
|
+
$type: 'app.bsky.feed.repost',
|
|
83
|
+
subject: {
|
|
84
|
+
uri: params.uri,
|
|
85
|
+
cid: params.cid,
|
|
86
|
+
},
|
|
87
|
+
createdAt: new Date().toISOString(),
|
|
88
|
+
};
|
|
89
|
+
return await this.executeAtpOperation(async () => {
|
|
90
|
+
const agent = this.atpClient.getAgent();
|
|
91
|
+
return await agent.com.atproto.repo.createRecord({
|
|
92
|
+
repo: agent.session?.did || '',
|
|
93
|
+
collection: 'app.bsky.feed.repost',
|
|
94
|
+
record: repostRecord,
|
|
95
|
+
});
|
|
96
|
+
}, 'createRepost', {
|
|
97
|
+
postUri: params.uri,
|
|
98
|
+
postCid: params.cid,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create a quote post (post with embedded repost)
|
|
103
|
+
*/
|
|
104
|
+
async createQuotePost(params) {
|
|
105
|
+
const quotePostRecord = {
|
|
106
|
+
$type: 'app.bsky.feed.post',
|
|
107
|
+
text: params.text ?? '',
|
|
108
|
+
embed: {
|
|
109
|
+
$type: 'app.bsky.embed.record',
|
|
110
|
+
record: {
|
|
111
|
+
uri: params.uri,
|
|
112
|
+
cid: params.cid,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
createdAt: new Date().toISOString(),
|
|
116
|
+
};
|
|
117
|
+
return await this.executeAtpOperation(async () => {
|
|
118
|
+
const agent = this.atpClient.getAgent();
|
|
119
|
+
return await agent.post(quotePostRecord);
|
|
120
|
+
}, 'createQuotePost', {
|
|
121
|
+
postUri: params.uri,
|
|
122
|
+
postCid: params.cid,
|
|
123
|
+
quoteTextLength: params.text?.length || 0,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Unrepost Tool - Removes reposts on AT Protocol
|
|
129
|
+
*/
|
|
130
|
+
export class UnrepostTool extends BaseTool {
|
|
131
|
+
schema = {
|
|
132
|
+
method: 'unrepost',
|
|
133
|
+
description: 'Remove a repost on AT Protocol. Deletes the repost record.',
|
|
134
|
+
params: z.object({
|
|
135
|
+
repostUri: z.string().min(1, 'Repost URI is required'),
|
|
136
|
+
}),
|
|
137
|
+
};
|
|
138
|
+
constructor(atpClient) {
|
|
139
|
+
super(atpClient, 'Unrepost');
|
|
140
|
+
}
|
|
141
|
+
async execute(params) {
|
|
142
|
+
try {
|
|
143
|
+
this.logger.info('Removing repost', {
|
|
144
|
+
repostUri: params.repostUri,
|
|
145
|
+
});
|
|
146
|
+
// Validate the repost URI
|
|
147
|
+
this.validateAtUri(params.repostUri);
|
|
148
|
+
// Delete the repost record
|
|
149
|
+
await this.executeAtpOperation(async () => {
|
|
150
|
+
const agent = this.atpClient.getAgent();
|
|
151
|
+
const uriParts = params.repostUri.replace('at://', '').split('/');
|
|
152
|
+
const did = uriParts[0];
|
|
153
|
+
const collection = uriParts[1];
|
|
154
|
+
const rkey = uriParts[2];
|
|
155
|
+
if (!did || !collection || !rkey) {
|
|
156
|
+
throw new Error(`Invalid AT URI format: ${params.repostUri}`);
|
|
157
|
+
}
|
|
158
|
+
return await agent.com.atproto.repo.deleteRecord({
|
|
159
|
+
repo: did,
|
|
160
|
+
collection,
|
|
161
|
+
rkey,
|
|
162
|
+
});
|
|
163
|
+
}, 'deleteRepost', { repostUri: params.repostUri });
|
|
164
|
+
this.logger.info('Repost removed successfully', {
|
|
165
|
+
repostUri: params.repostUri,
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
success: true,
|
|
169
|
+
message: 'Repost removed successfully',
|
|
170
|
+
deletedRepost: {
|
|
171
|
+
uri: params.repostUri,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
this.logger.error('Failed to remove repost', error);
|
|
177
|
+
this.formatError(error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=repost-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repost-tool.js","sourceRoot":"","sources":["../../../src/tools/implementations/repost-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;IAC9C,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AAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;oBAC/C,IAAI,EAAE,GAAG;oBACT,UAAU;oBACV,IAAI;iBACL,CAAC,CAAC;YACL,CAAC,EACD,cAAc,EACd,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAChC,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE;gBAC9C,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,6BAA6B;gBACtC,aAAa,EAAE;oBACb,GAAG,EAAE,MAAM,CAAC,SAAkB;iBAC/B;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YACpD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Posts Tool - Searches for posts on 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
|
+
import type { IAtpPost, ISearchPostsParams } from '../../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Tool for searching posts on AT Protocol
|
|
10
|
+
*/
|
|
11
|
+
export declare class SearchPostsTool extends BaseTool {
|
|
12
|
+
readonly schema: {
|
|
13
|
+
method: string;
|
|
14
|
+
description: string;
|
|
15
|
+
params: z.ZodObject<{
|
|
16
|
+
q: z.ZodString;
|
|
17
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
18
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
19
|
+
sort: z.ZodDefault<z.ZodOptional<z.ZodEnum<["top", "latest"]>>>;
|
|
20
|
+
since: z.ZodOptional<z.ZodString>;
|
|
21
|
+
until: z.ZodOptional<z.ZodString>;
|
|
22
|
+
mentions: z.ZodOptional<z.ZodString>;
|
|
23
|
+
author: z.ZodOptional<z.ZodString>;
|
|
24
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
25
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
26
|
+
url: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
sort: "top" | "latest";
|
|
29
|
+
limit: number;
|
|
30
|
+
q: string;
|
|
31
|
+
cursor?: string | undefined;
|
|
32
|
+
since?: string | undefined;
|
|
33
|
+
until?: string | undefined;
|
|
34
|
+
mentions?: string | undefined;
|
|
35
|
+
author?: string | undefined;
|
|
36
|
+
lang?: string | undefined;
|
|
37
|
+
domain?: string | undefined;
|
|
38
|
+
url?: string | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
q: string;
|
|
41
|
+
sort?: "top" | "latest" | undefined;
|
|
42
|
+
limit?: number | undefined;
|
|
43
|
+
cursor?: string | undefined;
|
|
44
|
+
since?: string | undefined;
|
|
45
|
+
until?: string | undefined;
|
|
46
|
+
mentions?: string | undefined;
|
|
47
|
+
author?: string | undefined;
|
|
48
|
+
lang?: string | undefined;
|
|
49
|
+
domain?: string | undefined;
|
|
50
|
+
url?: string | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
constructor(atpClient: AtpClient);
|
|
54
|
+
protected execute(params: ISearchPostsParams): Promise<{
|
|
55
|
+
success: boolean;
|
|
56
|
+
posts: IAtpPost[];
|
|
57
|
+
cursor?: string;
|
|
58
|
+
hasMore: boolean;
|
|
59
|
+
searchQuery: string;
|
|
60
|
+
totalResults?: number;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Transform AT Protocol post data to our interface
|
|
64
|
+
*/
|
|
65
|
+
private transformPost;
|
|
66
|
+
/**
|
|
67
|
+
* Search posts by hashtag
|
|
68
|
+
*/
|
|
69
|
+
searchByHashtag(hashtag: string, options?: {
|
|
70
|
+
limit?: number;
|
|
71
|
+
cursor?: string;
|
|
72
|
+
sort?: 'top' | 'latest';
|
|
73
|
+
}): Promise<{
|
|
74
|
+
success: boolean;
|
|
75
|
+
posts: IAtpPost[];
|
|
76
|
+
cursor?: string;
|
|
77
|
+
hasMore: boolean;
|
|
78
|
+
hashtag: string;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Search posts by author
|
|
82
|
+
*/
|
|
83
|
+
searchByAuthor(author: string, query?: string, options?: {
|
|
84
|
+
limit?: number;
|
|
85
|
+
cursor?: string;
|
|
86
|
+
sort?: 'top' | 'latest';
|
|
87
|
+
}): Promise<{
|
|
88
|
+
success: boolean;
|
|
89
|
+
posts: IAtpPost[];
|
|
90
|
+
cursor?: string;
|
|
91
|
+
hasMore: boolean;
|
|
92
|
+
author: string;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=search-posts-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-posts-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/implementations/search-posts-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAsBzE;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,SAAgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAKpB;gBAEU,SAAS,EAAE,SAAS;cAIhB,OAAO,CAAC,MAAM,EAAE,kBA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