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,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools for AT Protocol operations
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive tools that enable LLMs to interact directly with the AT Protocol ecosystem
|
|
5
|
+
*/
|
|
6
|
+
import type { z } from 'zod';
|
|
7
|
+
import type { AtpClient } from '../utils/atp-client.js';
|
|
8
|
+
/**
|
|
9
|
+
* Tool interface for MCP tools
|
|
10
|
+
*/
|
|
11
|
+
export interface IMcpTool {
|
|
12
|
+
schema: {
|
|
13
|
+
method: string;
|
|
14
|
+
description: string;
|
|
15
|
+
params?: z.ZodSchema;
|
|
16
|
+
};
|
|
17
|
+
handler: (params: any) => Promise<any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create all MCP tools for AT Protocol operations
|
|
21
|
+
*/
|
|
22
|
+
export declare function createTools(atpClient: AtpClient): IMcpTool[];
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AA6CxD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;KACtB,CAAC;IACF,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,EAAE,CAsE5D"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tools for AT Protocol operations
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive tools that enable LLMs to interact directly with the AT Protocol ecosystem
|
|
5
|
+
*/
|
|
6
|
+
import { Logger } from '../utils/logger.js';
|
|
7
|
+
import { AddToListTool, BlockUserTool, CreateListTool, CreatePostTool, CreateRichTextPostTool, DeletePostTool, FollowUserTool, GenerateLinkPreviewTool, GetCustomFeedTool, GetFollowersTool, GetFollowsTool, GetListTool, GetNotificationsTool, GetRecentEventsTool, GetStreamingStatusTool, GetThreadTool, GetTimelineTool, GetUserProfileTool, HandleOAuthCallbackTool, LikePostTool, MuteUserTool, RefreshOAuthTokensTool, RemoveFromListTool, ReplyToPostTool, ReportContentTool, ReportUserTool, RepostTool, RevokeOAuthTokensTool, SearchPostsTool, StartOAuthFlowTool, StartStreamingTool, StopStreamingTool, UnblockUserTool, UnfollowUserTool, UnlikePostTool, UnmuteUserTool, UnrepostTool, UpdateProfileTool, UploadImageTool, UploadVideoTool, } from './implementations/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create all MCP tools for AT Protocol operations
|
|
10
|
+
*/
|
|
11
|
+
export function createTools(atpClient) {
|
|
12
|
+
const logger = new Logger('ToolsFactory');
|
|
13
|
+
try {
|
|
14
|
+
const tools = [
|
|
15
|
+
// Core social operations
|
|
16
|
+
new CreatePostTool(atpClient),
|
|
17
|
+
new ReplyToPostTool(atpClient),
|
|
18
|
+
new LikePostTool(atpClient),
|
|
19
|
+
new UnlikePostTool(atpClient),
|
|
20
|
+
new RepostTool(atpClient),
|
|
21
|
+
new UnrepostTool(atpClient),
|
|
22
|
+
// User operations
|
|
23
|
+
new FollowUserTool(atpClient),
|
|
24
|
+
new UnfollowUserTool(atpClient),
|
|
25
|
+
new GetUserProfileTool(atpClient),
|
|
26
|
+
// Data retrieval
|
|
27
|
+
new SearchPostsTool(atpClient),
|
|
28
|
+
new GetTimelineTool(atpClient),
|
|
29
|
+
new GetFollowersTool(atpClient),
|
|
30
|
+
new GetFollowsTool(atpClient),
|
|
31
|
+
new GetNotificationsTool(atpClient),
|
|
32
|
+
// Content management
|
|
33
|
+
new DeletePostTool(atpClient),
|
|
34
|
+
new UpdateProfileTool(atpClient),
|
|
35
|
+
// OAuth authentication
|
|
36
|
+
new StartOAuthFlowTool(atpClient),
|
|
37
|
+
new HandleOAuthCallbackTool(atpClient),
|
|
38
|
+
new RefreshOAuthTokensTool(atpClient),
|
|
39
|
+
new RevokeOAuthTokensTool(atpClient),
|
|
40
|
+
// Content moderation
|
|
41
|
+
new MuteUserTool(atpClient),
|
|
42
|
+
new UnmuteUserTool(atpClient),
|
|
43
|
+
new BlockUserTool(atpClient),
|
|
44
|
+
new UnblockUserTool(atpClient),
|
|
45
|
+
new ReportContentTool(atpClient),
|
|
46
|
+
new ReportUserTool(atpClient),
|
|
47
|
+
// Real-time streaming
|
|
48
|
+
new StartStreamingTool(atpClient),
|
|
49
|
+
new StopStreamingTool(atpClient),
|
|
50
|
+
new GetStreamingStatusTool(atpClient),
|
|
51
|
+
new GetRecentEventsTool(atpClient),
|
|
52
|
+
// Advanced social features
|
|
53
|
+
new CreateListTool(atpClient),
|
|
54
|
+
new AddToListTool(atpClient),
|
|
55
|
+
new RemoveFromListTool(atpClient),
|
|
56
|
+
new GetListTool(atpClient),
|
|
57
|
+
new GetThreadTool(atpClient),
|
|
58
|
+
new GetCustomFeedTool(atpClient),
|
|
59
|
+
// Enhanced media support
|
|
60
|
+
new UploadImageTool(atpClient),
|
|
61
|
+
new UploadVideoTool(atpClient),
|
|
62
|
+
new CreateRichTextPostTool(atpClient),
|
|
63
|
+
new GenerateLinkPreviewTool(atpClient),
|
|
64
|
+
];
|
|
65
|
+
logger.info(`Created ${tools.length} AT Protocol MCP tools`);
|
|
66
|
+
return tools;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
logger.error('Failed to create MCP tools', error);
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,4BAA4B,CAAC;AAcpC;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,SAAoB;IAC9C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1C,IAAI,CAAC;QACH,MAAM,K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mB,CAAC,SAAS,CAAC;YAElC,2BAA2B;YAC3B,IAAI,cAAc,CAAC,SAAS,CAAC;YAC7B,IAAI,aAAa,CAAC,SAAS,CAAC;YAC5B,IAAI,kBAAkB,CAAC,SAAS,CAAC;YACjC,IAAI,WAAW,CAAC,SAAS,CAAC;YAC1B,IAAI,aAAa,CAAC,SAAS,CAAC;YAC5B,IAAI,iBAAiB,CAAC,SAAS,CAAC;YAEhC,yBAAyB;YACzB,IAAI,eAAe,CAAC,SAAS,CAAC;YAC9B,IAAI,eAAe,CAAC,SAAS,CAAC;YAC9B,IAAI,sBAAsB,CAAC,SAAS,CAAC;YACrC,IAAI,uBAAuB,CAAC,SAAS,CAAC;SACvC,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,MAAM,wBAAwB,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the AT Protocol MCP Server
|
|
3
|
+
*/
|
|
4
|
+
export type DID = string & {
|
|
5
|
+
readonly __brand: 'DID';
|
|
6
|
+
};
|
|
7
|
+
export type ATURI = string & {
|
|
8
|
+
readonly __brand: 'ATURI';
|
|
9
|
+
};
|
|
10
|
+
export type NSID = string & {
|
|
11
|
+
readonly __brand: 'NSID';
|
|
12
|
+
};
|
|
13
|
+
export type CID = string & {
|
|
14
|
+
readonly __brand: 'CID';
|
|
15
|
+
};
|
|
16
|
+
export interface IAtpSession {
|
|
17
|
+
did: DID;
|
|
18
|
+
handle: string;
|
|
19
|
+
accessJwt: string;
|
|
20
|
+
refreshJwt: string;
|
|
21
|
+
active: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface IAtpProfile {
|
|
24
|
+
did: DID;
|
|
25
|
+
handle: string;
|
|
26
|
+
displayName?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
avatar?: string;
|
|
29
|
+
banner?: string;
|
|
30
|
+
followersCount?: number;
|
|
31
|
+
followsCount?: number;
|
|
32
|
+
postsCount?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface IAtpPost {
|
|
35
|
+
uri: ATURI;
|
|
36
|
+
cid: CID;
|
|
37
|
+
author: IAtpProfile;
|
|
38
|
+
record: {
|
|
39
|
+
text: string;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
reply?: {
|
|
42
|
+
root: {
|
|
43
|
+
uri: ATURI;
|
|
44
|
+
cid: CID;
|
|
45
|
+
};
|
|
46
|
+
parent: {
|
|
47
|
+
uri: ATURI;
|
|
48
|
+
cid: CID;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
embed?: unknown;
|
|
52
|
+
langs?: string[];
|
|
53
|
+
labels?: unknown;
|
|
54
|
+
tags?: string[];
|
|
55
|
+
};
|
|
56
|
+
replyCount?: number;
|
|
57
|
+
repostCount?: number;
|
|
58
|
+
likeCount?: number;
|
|
59
|
+
indexedAt: string;
|
|
60
|
+
viewer?: {
|
|
61
|
+
repost?: ATURI;
|
|
62
|
+
like?: ATURI;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export interface IMcpServerConfig {
|
|
66
|
+
port: number;
|
|
67
|
+
host: string;
|
|
68
|
+
name: string;
|
|
69
|
+
version: string;
|
|
70
|
+
description: string;
|
|
71
|
+
atproto: IAtpConfig;
|
|
72
|
+
}
|
|
73
|
+
export interface IAtpConfig {
|
|
74
|
+
service: string;
|
|
75
|
+
identifier?: string;
|
|
76
|
+
password?: string;
|
|
77
|
+
clientId?: string;
|
|
78
|
+
clientSecret?: string;
|
|
79
|
+
redirectUri?: string;
|
|
80
|
+
authMethod?: 'app-password' | 'oauth';
|
|
81
|
+
}
|
|
82
|
+
export interface ICreatePostParams {
|
|
83
|
+
text: string;
|
|
84
|
+
reply?: {
|
|
85
|
+
root: ATURI;
|
|
86
|
+
parent: ATURI;
|
|
87
|
+
};
|
|
88
|
+
embed?: {
|
|
89
|
+
images?: Array<{
|
|
90
|
+
alt: string;
|
|
91
|
+
image: Blob;
|
|
92
|
+
}>;
|
|
93
|
+
external?: {
|
|
94
|
+
uri: string;
|
|
95
|
+
title: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
langs?: string[];
|
|
100
|
+
}
|
|
101
|
+
export interface IReplyToPostParams {
|
|
102
|
+
text: string;
|
|
103
|
+
root: ATURI;
|
|
104
|
+
parent: ATURI;
|
|
105
|
+
langs?: string[];
|
|
106
|
+
}
|
|
107
|
+
export interface ILikePostParams {
|
|
108
|
+
uri: ATURI;
|
|
109
|
+
cid: CID;
|
|
110
|
+
}
|
|
111
|
+
export interface IUnlikePostParams {
|
|
112
|
+
likeUri: ATURI;
|
|
113
|
+
}
|
|
114
|
+
export interface IRepostParams {
|
|
115
|
+
uri: ATURI;
|
|
116
|
+
cid: CID;
|
|
117
|
+
text?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface IUnrepostParams {
|
|
120
|
+
repostUri: ATURI;
|
|
121
|
+
}
|
|
122
|
+
export interface IFollowUserParams {
|
|
123
|
+
actor: string;
|
|
124
|
+
}
|
|
125
|
+
export interface IUnfollowUserParams {
|
|
126
|
+
followUri: ATURI;
|
|
127
|
+
}
|
|
128
|
+
export interface IGetUserProfileParams {
|
|
129
|
+
actor: string;
|
|
130
|
+
}
|
|
131
|
+
export interface ISearchPostsParams {
|
|
132
|
+
q: string;
|
|
133
|
+
limit?: number;
|
|
134
|
+
cursor?: string;
|
|
135
|
+
sort?: 'top' | 'latest';
|
|
136
|
+
since?: string;
|
|
137
|
+
until?: string;
|
|
138
|
+
mentions?: string;
|
|
139
|
+
author?: string;
|
|
140
|
+
lang?: string;
|
|
141
|
+
domain?: string;
|
|
142
|
+
url?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface IGetTimelineParams {
|
|
145
|
+
algorithm?: string;
|
|
146
|
+
limit?: number;
|
|
147
|
+
cursor?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface IGetFollowersParams {
|
|
150
|
+
actor: string;
|
|
151
|
+
limit?: number;
|
|
152
|
+
cursor?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface IGetFollowsParams {
|
|
155
|
+
actor: string;
|
|
156
|
+
limit?: number;
|
|
157
|
+
cursor?: string;
|
|
158
|
+
}
|
|
159
|
+
export interface IGetNotificationsParams {
|
|
160
|
+
limit?: number;
|
|
161
|
+
cursor?: string;
|
|
162
|
+
seenAt?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface IDeletePostParams {
|
|
165
|
+
uri: ATURI;
|
|
166
|
+
}
|
|
167
|
+
export interface IUpdateProfileParams {
|
|
168
|
+
displayName?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
avatar?: Blob;
|
|
171
|
+
banner?: Blob;
|
|
172
|
+
}
|
|
173
|
+
export declare abstract class BaseError extends Error {
|
|
174
|
+
readonly code: string;
|
|
175
|
+
readonly timestamp: string;
|
|
176
|
+
readonly context: Record<string, unknown> | undefined;
|
|
177
|
+
constructor(message: string, code: string, context?: Record<string, unknown>);
|
|
178
|
+
toJSON(): Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
export declare class AtpError extends BaseError {
|
|
181
|
+
readonly statusCode?: number | undefined;
|
|
182
|
+
readonly details?: unknown | undefined;
|
|
183
|
+
constructor(message: string, code: string, statusCode?: number | undefined, details?: unknown | undefined, context?: Record<string, unknown>);
|
|
184
|
+
}
|
|
185
|
+
export declare class McpError extends BaseError {
|
|
186
|
+
readonly mcpCode: number;
|
|
187
|
+
readonly data?: unknown | undefined;
|
|
188
|
+
constructor(message: string, mcpCode: number, data?: unknown | undefined, context?: Record<string, unknown>);
|
|
189
|
+
}
|
|
190
|
+
export declare class AuthenticationError extends AtpError {
|
|
191
|
+
constructor(message: string, details?: unknown, context?: Record<string, unknown>);
|
|
192
|
+
}
|
|
193
|
+
export declare class RateLimitError extends AtpError {
|
|
194
|
+
readonly retryAfter?: number | undefined;
|
|
195
|
+
constructor(message: string, retryAfter?: number | undefined, context?: Record<string, unknown>);
|
|
196
|
+
}
|
|
197
|
+
export declare class ValidationError extends BaseError {
|
|
198
|
+
readonly field?: string | undefined;
|
|
199
|
+
readonly value?: unknown | undefined;
|
|
200
|
+
constructor(message: string, field?: string | undefined, value?: unknown | undefined, context?: Record<string, unknown>);
|
|
201
|
+
}
|
|
202
|
+
export declare class ConfigurationError extends BaseError {
|
|
203
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
204
|
+
}
|
|
205
|
+
export type Result<T, E = Error> = {
|
|
206
|
+
success: true;
|
|
207
|
+
data: T;
|
|
208
|
+
} | {
|
|
209
|
+
success: false;
|
|
210
|
+
error: E;
|
|
211
|
+
};
|
|
212
|
+
export interface IPaginatedResponse<T> {
|
|
213
|
+
data: T[];
|
|
214
|
+
cursor?: string;
|
|
215
|
+
hasMore: boolean;
|
|
216
|
+
}
|
|
217
|
+
export interface IResourceInfo {
|
|
218
|
+
uri: string;
|
|
219
|
+
name: string;
|
|
220
|
+
description: string;
|
|
221
|
+
mimeType?: string;
|
|
222
|
+
}
|
|
223
|
+
export interface IPromptTemplate {
|
|
224
|
+
name: string;
|
|
225
|
+
description: string;
|
|
226
|
+
arguments: Array<{
|
|
227
|
+
name: string;
|
|
228
|
+
description: string;
|
|
229
|
+
required: boolean;
|
|
230
|
+
}>;
|
|
231
|
+
}
|
|
232
|
+
export interface IOAuthConfig {
|
|
233
|
+
clientId: string;
|
|
234
|
+
clientSecret: string;
|
|
235
|
+
redirectUri: string;
|
|
236
|
+
scope: string[];
|
|
237
|
+
}
|
|
238
|
+
export interface IAppPasswordConfig {
|
|
239
|
+
identifier: string;
|
|
240
|
+
password: string;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 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handling
|
|
5
|
+
export class BaseError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
timestamp;
|
|
8
|
+
context;
|
|
9
|
+
constructor(message, code, context) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.name = this.constructor.name;
|
|
13
|
+
this.timestamp = new Date().toISOString();
|
|
14
|
+
this.context = context;
|
|
15
|
+
// Ensure proper prototype chain for instanceof checks
|
|
16
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
17
|
+
}
|
|
18
|
+
toJSON() {
|
|
19
|
+
return {
|
|
20
|
+
name: this.name,
|
|
21
|
+
message: this.message,
|
|
22
|
+
code: this.code,
|
|
23
|
+
timestamp: this.timestamp,
|
|
24
|
+
context: this.context,
|
|
25
|
+
stack: this.stack,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class AtpError extends BaseError {
|
|
30
|
+
statusCode;
|
|
31
|
+
details;
|
|
32
|
+
constructor(message, code, statusCode, details, context) {
|
|
33
|
+
super(message, code, context);
|
|
34
|
+
this.statusCode = statusCode;
|
|
35
|
+
this.details = details;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class McpError extends BaseError {
|
|
39
|
+
mcpCode;
|
|
40
|
+
data;
|
|
41
|
+
constructor(message, mcpCode, data, context) {
|
|
42
|
+
super(message, `MCP_${mcpCode}`, context);
|
|
43
|
+
this.mcpCode = mcpCode;
|
|
44
|
+
this.data = data;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class AuthenticationError extends AtpError {
|
|
48
|
+
constructor(message, details, context) {
|
|
49
|
+
super(message, 'AUTHENTICATION_FAILED', 401, details, context);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class RateLimitError extends AtpError {
|
|
53
|
+
retryAfter;
|
|
54
|
+
constructor(message, retryAfter, context) {
|
|
55
|
+
super(message, 'RATE_LIMIT_EXCEEDED', 429, { retryAfter }, context);
|
|
56
|
+
this.retryAfter = retryAfter;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export class ValidationError extends BaseError {
|
|
60
|
+
field;
|
|
61
|
+
value;
|
|
62
|
+
constructor(message, field, value, context) {
|
|
63
|
+
super(message, 'VALIDATION_ERROR', { ...context, field, value });
|
|
64
|
+
this.field = field;
|
|
65
|
+
this.value = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class ConfigurationError extends BaseError {
|
|
69
|
+
constructor(message, context) {
|
|
70
|
+
super(message, 'CONFIGURATION_ERROR', context);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuLH,gDAAgD;AAChD,MAAM,OAAgB,SAAU,SAAQ,KAAK;IAMzB;IALF,SAAS,CAAS;IAClB,OAAO,CAAsC;IAE7D,YACE,OAAe,EACC,IAAY,EAC5B,OAAiC;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QAI5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,sDAAsD;QACtD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAEM,MAAM;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK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QACd,UAAK,GAAL,KAAK,CAAU;IAIjC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AT Protocol client wrapper with authentication and session management
|
|
3
|
+
* Supports both authenticated and unauthenticated modes
|
|
4
|
+
*/
|
|
5
|
+
import { AtpAgent } from '@atproto/api';
|
|
6
|
+
import { AtpError, type IAtpConfig, type IAtpSession, type Result } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* AT Protocol client wrapper with comprehensive authentication and session management
|
|
9
|
+
* Supports both authenticated and unauthenticated modes for maximum flexibility
|
|
10
|
+
*/
|
|
11
|
+
export declare class AtpClient {
|
|
12
|
+
private agent;
|
|
13
|
+
private publicAgent;
|
|
14
|
+
private logger;
|
|
15
|
+
private session;
|
|
16
|
+
private config;
|
|
17
|
+
private sessionRefreshPromise;
|
|
18
|
+
private isAuthenticationRequired;
|
|
19
|
+
constructor(config: IAtpConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Check if authentication credentials are available
|
|
22
|
+
*/
|
|
23
|
+
private hasAuthenticationCredentials;
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the AT Protocol client
|
|
26
|
+
* In unauthenticated mode, this will skip authentication
|
|
27
|
+
* In authenticated mode, this will perform authentication
|
|
28
|
+
*/
|
|
29
|
+
initialize(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Authenticate with AT Protocol using configured method
|
|
32
|
+
*/
|
|
33
|
+
private authenticate;
|
|
34
|
+
/**
|
|
35
|
+
* Authenticate using app password
|
|
36
|
+
*/
|
|
37
|
+
private authenticateWithAppPassword;
|
|
38
|
+
/**
|
|
39
|
+
* Authenticate using OAuth
|
|
40
|
+
*/
|
|
41
|
+
private authenticateWithOAuth;
|
|
42
|
+
/**
|
|
43
|
+
* Handle session events from AtpAgent
|
|
44
|
+
*/
|
|
45
|
+
private handleSessionEvent;
|
|
46
|
+
/**
|
|
47
|
+
* Refresh the current session
|
|
48
|
+
*/
|
|
49
|
+
private refreshSession;
|
|
50
|
+
/**
|
|
51
|
+
* Perform the actual session refresh
|
|
52
|
+
*/
|
|
53
|
+
private performSessionRefresh;
|
|
54
|
+
/**
|
|
55
|
+
* Get the current session
|
|
56
|
+
*/
|
|
57
|
+
getSession(): IAtpSession | null;
|
|
58
|
+
/**
|
|
59
|
+
* Check if client is authenticated
|
|
60
|
+
*/
|
|
61
|
+
isAuthenticated(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Check if authentication is required for this client instance
|
|
64
|
+
*/
|
|
65
|
+
requiresAuthentication(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Get the underlying AtpAgent instance
|
|
68
|
+
* Returns the authenticated agent if available, otherwise the public agent
|
|
69
|
+
*/
|
|
70
|
+
getAgent(): AtpAgent;
|
|
71
|
+
/**
|
|
72
|
+
* Get the authenticated agent (for operations that require authentication)
|
|
73
|
+
*/
|
|
74
|
+
getAuthenticatedAgent(): AtpAgent;
|
|
75
|
+
/**
|
|
76
|
+
* Get the public agent (for operations that don't require authentication)
|
|
77
|
+
*/
|
|
78
|
+
getPublicAgent(): AtpAgent;
|
|
79
|
+
/**
|
|
80
|
+
* Execute a request with automatic retry and error handling
|
|
81
|
+
* Supports both authenticated and unauthenticated operations
|
|
82
|
+
*/
|
|
83
|
+
executeRequest<T>(operation: () => Promise<T>, context?: Record<string, unknown>, requiresAuth?: boolean): Promise<Result<T, AtpError>>;
|
|
84
|
+
/**
|
|
85
|
+
* Execute a public request that doesn't require authentication
|
|
86
|
+
*/
|
|
87
|
+
executePublicRequest<T>(operation: () => Promise<T>, context?: Record<string, unknown>): Promise<Result<T, AtpError>>;
|
|
88
|
+
/**
|
|
89
|
+
* Execute an authenticated request that requires authentication
|
|
90
|
+
*/
|
|
91
|
+
executeAuthenticatedRequest<T>(operation: () => Promise<T>, context?: Record<string, unknown>): Promise<Result<T, AtpError>>;
|
|
92
|
+
/**
|
|
93
|
+
* Handle and transform errors from AT Protocol operations
|
|
94
|
+
*/
|
|
95
|
+
private handleError;
|
|
96
|
+
/**
|
|
97
|
+
* Cleanup resources
|
|
98
|
+
*/
|
|
99
|
+
cleanup(): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Load stored OAuth session from secure storage
|
|
102
|
+
*/
|
|
103
|
+
private loadStoredOAuthSession;
|
|
104
|
+
/**
|
|
105
|
+
* Store OAuth session to secure storage
|
|
106
|
+
*/
|
|
107
|
+
private storeOAuthSession;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=atp-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atp-client.d.ts","sourceRoot":"","sources":["../../src/utils/atp-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAA6C,MAAM,cAAc,CAAC;AACnF,OAAO,EACL,QAAQ,EAGR,KAAK,UAAU,EACf,KAAK,WAAW,EAEhB,KAAK,MAAM,EAEZ,MAAM,mBAAmB,CAAC;AAI3B;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,WAAW,CAAW;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,qBAAqB,CAA8B;IAC3D,OAAO,CAAC,wBAAwB,CAAU;gBAE9B,MAAM,EAAE,UAAU;IAqB9B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IASpC;;;;OAIG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBxC;;OAEG;YACW,YAAY;IAc1B;;OAEG;YACW,2BAA2B;IAuCzC;;OAEG;YACW,qBAAqB;I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