@elizaos/plugin-bluesky 2.0.0-alpha.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.
- package/LICENSE +28 -0
- package/dist/browser/index.browser.js +70 -0
- package/dist/browser/index.browser.js.map +10 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.node.cjs +741 -0
- package/dist/cjs/index.node.js.map +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.node.js +709 -0
- package/dist/node/index.node.js.map +18 -0
- package/package.json +180 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 elizaOS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// types/index.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var BLUESKY_SERVICE_URL = "https://bsky.social";
|
|
4
|
+
var BLUESKY_MAX_POST_LENGTH = 300;
|
|
5
|
+
var BLUESKY_POLL_INTERVAL = 60;
|
|
6
|
+
var BLUESKY_POST_INTERVAL_MIN = 1800;
|
|
7
|
+
var BLUESKY_POST_INTERVAL_MAX = 3600;
|
|
8
|
+
var BLUESKY_ACTION_INTERVAL = 120;
|
|
9
|
+
var BLUESKY_MAX_ACTIONS = 5;
|
|
10
|
+
var BLUESKY_CHAT_SERVICE_DID = "did:web:api.bsky.chat";
|
|
11
|
+
var BLUESKY_SERVICE_NAME = "bluesky";
|
|
12
|
+
var AT_PROTOCOL_HANDLE_REGEX = /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;
|
|
13
|
+
var CACHE_TTL = {
|
|
14
|
+
PROFILE: 3600000,
|
|
15
|
+
TIMELINE: 300000,
|
|
16
|
+
POST: 1800000,
|
|
17
|
+
NOTIFICATIONS: 300000,
|
|
18
|
+
CONVERSATIONS: 300000
|
|
19
|
+
};
|
|
20
|
+
var CACHE_SIZE = {
|
|
21
|
+
PROFILE: 1000,
|
|
22
|
+
TIMELINE: 500,
|
|
23
|
+
POST: 1e4,
|
|
24
|
+
NOTIFICATIONS: 1000,
|
|
25
|
+
CONVERSATIONS: 100
|
|
26
|
+
};
|
|
27
|
+
var BlueSkyConfigSchema = z.object({
|
|
28
|
+
handle: z.string().regex(AT_PROTOCOL_HANDLE_REGEX, "Invalid handle format"),
|
|
29
|
+
password: z.string().min(1),
|
|
30
|
+
service: z.string().url().default(BLUESKY_SERVICE_URL),
|
|
31
|
+
dryRun: z.boolean().default(false),
|
|
32
|
+
pollInterval: z.number().positive().default(BLUESKY_POLL_INTERVAL),
|
|
33
|
+
enablePost: z.boolean().default(true),
|
|
34
|
+
postIntervalMin: z.number().positive().default(BLUESKY_POST_INTERVAL_MIN),
|
|
35
|
+
postIntervalMax: z.number().positive().default(BLUESKY_POST_INTERVAL_MAX),
|
|
36
|
+
enableActionProcessing: z.boolean().default(true),
|
|
37
|
+
actionInterval: z.number().positive().default(BLUESKY_ACTION_INTERVAL),
|
|
38
|
+
postImmediately: z.boolean().default(false),
|
|
39
|
+
maxActionsProcessing: z.number().positive().default(BLUESKY_MAX_ACTIONS),
|
|
40
|
+
enableDMs: z.boolean().default(true)
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
class BlueSkyError extends Error {
|
|
44
|
+
code;
|
|
45
|
+
status;
|
|
46
|
+
constructor(message, code, status) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.code = code;
|
|
49
|
+
this.status = status;
|
|
50
|
+
this.name = "BlueSkyError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
CACHE_TTL,
|
|
55
|
+
CACHE_SIZE,
|
|
56
|
+
BlueSkyError,
|
|
57
|
+
BlueSkyConfigSchema,
|
|
58
|
+
BLUESKY_SERVICE_URL,
|
|
59
|
+
BLUESKY_SERVICE_NAME,
|
|
60
|
+
BLUESKY_POST_INTERVAL_MIN,
|
|
61
|
+
BLUESKY_POST_INTERVAL_MAX,
|
|
62
|
+
BLUESKY_POLL_INTERVAL,
|
|
63
|
+
BLUESKY_MAX_POST_LENGTH,
|
|
64
|
+
BLUESKY_MAX_ACTIONS,
|
|
65
|
+
BLUESKY_CHAT_SERVICE_DID,
|
|
66
|
+
BLUESKY_ACTION_INTERVAL,
|
|
67
|
+
AT_PROTOCOL_HANDLE_REGEX
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//# debugId=AB54F736CEC6763B64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../types/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { IAgentRuntime } from \"@elizaos/core\";\nimport { z } from \"zod\";\n\nexport const BLUESKY_SERVICE_URL = \"https://bsky.social\";\nexport const BLUESKY_MAX_POST_LENGTH = 300;\nexport const BLUESKY_POLL_INTERVAL = 60;\nexport const BLUESKY_POST_INTERVAL_MIN = 1800;\nexport const BLUESKY_POST_INTERVAL_MAX = 3600;\nexport const BLUESKY_ACTION_INTERVAL = 120;\nexport const BLUESKY_MAX_ACTIONS = 5;\nexport const BLUESKY_CHAT_SERVICE_DID = \"did:web:api.bsky.chat\";\nexport const BLUESKY_SERVICE_NAME = \"bluesky\";\n\nexport const AT_PROTOCOL_HANDLE_REGEX =\n /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;\n\nexport const CACHE_TTL = {\n PROFILE: 3600000,\n TIMELINE: 300000,\n POST: 1800000,\n NOTIFICATIONS: 300000,\n CONVERSATIONS: 300000,\n} as const;\n\nexport const CACHE_SIZE = {\n PROFILE: 1000,\n TIMELINE: 500,\n POST: 10000,\n NOTIFICATIONS: 1000,\n CONVERSATIONS: 100,\n} as const;\n\nexport const BlueSkyConfigSchema = z.object({\n handle: z.string().regex(AT_PROTOCOL_HANDLE_REGEX, \"Invalid handle format\"),\n password: z.string().min(1),\n service: z.string().url().default(BLUESKY_SERVICE_URL),\n dryRun: z.boolean().default(false),\n pollInterval: z.number().positive().default(BLUESKY_POLL_INTERVAL),\n enablePost: z.boolean().default(true),\n postIntervalMin: z.number().positive().default(BLUESKY_POST_INTERVAL_MIN),\n postIntervalMax: z.number().positive().default(BLUESKY_POST_INTERVAL_MAX),\n enableActionProcessing: z.boolean().default(true),\n actionInterval: z.number().positive().default(BLUESKY_ACTION_INTERVAL),\n postImmediately: z.boolean().default(false),\n maxActionsProcessing: z.number().positive().default(BLUESKY_MAX_ACTIONS),\n enableDMs: z.boolean().default(true),\n});\n\nexport type BlueSkyConfig = z.infer<typeof BlueSkyConfigSchema>;\n\nexport interface BlueSkyProfile {\n did: string;\n handle: string;\n displayName?: string;\n description?: string;\n avatar?: string;\n banner?: string;\n followersCount?: number;\n followsCount?: number;\n postsCount?: number;\n indexedAt?: string;\n createdAt?: string;\n}\n\nexport interface PostFacet {\n index: { byteStart: number; byteEnd: number };\n features: Array<{\n $type?: string;\n [key: string]: string | number | boolean | object | null | undefined;\n }>;\n}\n\nexport interface PostEmbed {\n $type: string;\n [key: string]: string | number | boolean | object | null | undefined;\n}\n\nexport interface PostRecord {\n $type: string;\n text: string;\n facets?: PostFacet[];\n embed?: PostEmbed;\n createdAt: string;\n}\n\nexport interface BlueSkyPost {\n uri: string;\n cid: string;\n author: BlueSkyProfile;\n record: PostRecord;\n embed?: PostEmbed;\n replyCount?: number;\n repostCount?: number;\n likeCount?: number;\n quoteCount?: number;\n indexedAt: string;\n}\n\nexport interface TimelineRequest {\n algorithm?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface TimelineFeedItem {\n post: BlueSkyPost;\n reply?: {\n root: BlueSkyPost;\n parent: BlueSkyPost;\n };\n reason?: Record<string, string | number | boolean | object | null | undefined>;\n}\n\nexport interface TimelineResponse {\n cursor?: string;\n feed: TimelineFeedItem[];\n}\n\nexport interface CreatePostRequest {\n content: {\n text: string;\n facets?: PostFacet[];\n embed?: PostEmbed;\n };\n replyTo?: { uri: string; cid: string };\n}\n\nexport type NotificationReason = \"mention\" | \"reply\" | \"follow\" | \"like\" | \"repost\" | \"quote\";\n\nexport interface BlueSkyNotification {\n uri: string;\n cid: string;\n author: BlueSkyProfile;\n reason: NotificationReason;\n reasonSubject?: string;\n record: Record<string, string | number | boolean | object | null | undefined>;\n isRead: boolean;\n indexedAt: string;\n}\n\nexport interface BlueSkyMessage {\n id: string;\n rev: string;\n text?: string;\n embed?: PostEmbed;\n sender: { did: string };\n sentAt: string;\n}\n\nexport interface BlueSkyConversation {\n id: string;\n rev: string;\n members: Array<{\n did: string;\n handle?: string;\n displayName?: string;\n avatar?: string;\n }>;\n lastMessage?: BlueSkyMessage;\n unreadCount: number;\n muted: boolean;\n}\n\nexport interface SendMessageRequest {\n convoId: string;\n message: { text?: string; embed?: PostEmbed };\n}\n\nexport interface BlueSkySession {\n did: string;\n handle: string;\n email?: string;\n accessJwt: string;\n refreshJwt: string;\n}\n\nexport class BlueSkyError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly status?: number\n ) {\n super(message);\n this.name = \"BlueSkyError\";\n }\n}\n\nexport interface ATProtocolPostRecord {\n $type: string;\n text: string;\n facets?: PostFacet[];\n embed?: PostEmbed;\n createdAt: string;\n [k: string]: string | PostFacet[] | PostEmbed | number | boolean | null | undefined;\n}\n\nexport interface ATProtocolProfileViewExtended {\n did: string;\n handle: string;\n displayName?: string;\n description?: string;\n avatar?: string;\n banner?: string;\n followersCount?: number;\n followsCount?: number;\n postsCount?: number;\n indexedAt?: string;\n createdAt?: string;\n [k: string]: string | number | undefined;\n}\n\nexport interface BlueSkyEventPayload {\n runtime: IAgentRuntime;\n source: \"bluesky\";\n}\n\nexport interface BlueSkyNotificationEventPayload extends BlueSkyEventPayload {\n notification: BlueSkyNotification;\n}\n\nexport interface BlueSkyCreatePostEventPayload extends BlueSkyEventPayload {\n automated: boolean;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AACA;AAEO,IAAM,sBAAsB;AAC5B,IAAM,0BAA0B;AAChC,IAAM,wBAAwB;AAC9B,IAAM,4BAA4B;AAClC,IAAM,4BAA4B;AAClC,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAC5B,IAAM,2BAA2B;AACjC,IAAM,uBAAuB;AAE7B,IAAM,2B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