@agnocon/piece-bluesky 0.1.6

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 (67) hide show
  1. package/LICENSE.MIT-AP +24 -0
  2. package/dist/index.d.ts +8 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +32 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions/create-post.d.ts +21 -0
  7. package/dist/lib/actions/create-post.d.ts.map +1 -0
  8. package/dist/lib/actions/create-post.js +379 -0
  9. package/dist/lib/actions/create-post.js.map +1 -0
  10. package/dist/lib/actions/find-post.d.ts +8 -0
  11. package/dist/lib/actions/find-post.d.ts.map +1 -0
  12. package/dist/lib/actions/find-post.js +77 -0
  13. package/dist/lib/actions/find-post.js.map +1 -0
  14. package/dist/lib/actions/find-thread.d.ts +10 -0
  15. package/dist/lib/actions/find-thread.d.ts.map +1 -0
  16. package/dist/lib/actions/find-thread.js +117 -0
  17. package/dist/lib/actions/find-thread.js.map +1 -0
  18. package/dist/lib/actions/like-post.d.ts +14 -0
  19. package/dist/lib/actions/like-post.d.ts.map +1 -0
  20. package/dist/lib/actions/like-post.js +129 -0
  21. package/dist/lib/actions/like-post.js.map +1 -0
  22. package/dist/lib/actions/repost.d.ts +14 -0
  23. package/dist/lib/actions/repost.d.ts.map +1 -0
  24. package/dist/lib/actions/repost.js +132 -0
  25. package/dist/lib/actions/repost.js.map +1 -0
  26. package/dist/lib/common/auth.d.ts +11 -0
  27. package/dist/lib/common/auth.d.ts.map +1 -0
  28. package/dist/lib/common/auth.js +75 -0
  29. package/dist/lib/common/auth.js.map +1 -0
  30. package/dist/lib/common/client.d.ts +8 -0
  31. package/dist/lib/common/client.d.ts.map +1 -0
  32. package/dist/lib/common/client.js +47 -0
  33. package/dist/lib/common/client.js.map +1 -0
  34. package/dist/lib/common/props.d.ts +45 -0
  35. package/dist/lib/common/props.d.ts.map +1 -0
  36. package/dist/lib/common/props.js +360 -0
  37. package/dist/lib/common/props.js.map +1 -0
  38. package/dist/lib/triggers/new-follower-on-account.d.ts +19 -0
  39. package/dist/lib/triggers/new-follower-on-account.d.ts.map +1 -0
  40. package/dist/lib/triggers/new-follower-on-account.js +116 -0
  41. package/dist/lib/triggers/new-follower-on-account.js.map +1 -0
  42. package/dist/lib/triggers/new-post.d.ts +75 -0
  43. package/dist/lib/triggers/new-post.d.ts.map +1 -0
  44. package/dist/lib/triggers/new-post.js +214 -0
  45. package/dist/lib/triggers/new-post.js.map +1 -0
  46. package/dist/lib/triggers/new-posts-by-author.d.ts +59 -0
  47. package/dist/lib/triggers/new-posts-by-author.d.ts.map +1 -0
  48. package/dist/lib/triggers/new-posts-by-author.js +243 -0
  49. package/dist/lib/triggers/new-posts-by-author.js.map +1 -0
  50. package/dist/lib/triggers/new-timeline-posts.d.ts +19 -0
  51. package/dist/lib/triggers/new-timeline-posts.d.ts.map +1 -0
  52. package/dist/lib/triggers/new-timeline-posts.js +143 -0
  53. package/dist/lib/triggers/new-timeline-posts.js.map +1 -0
  54. package/package.json +48 -0
  55. package/src/index.ts +25 -0
  56. package/src/lib/actions/create-post.ts +444 -0
  57. package/src/lib/actions/find-post.ts +76 -0
  58. package/src/lib/actions/find-thread.ts +121 -0
  59. package/src/lib/actions/like-post.ts +128 -0
  60. package/src/lib/actions/repost.ts +132 -0
  61. package/src/lib/common/auth.ts +74 -0
  62. package/src/lib/common/client.ts +42 -0
  63. package/src/lib/common/props.ts +392 -0
  64. package/src/lib/triggers/new-follower-on-account.ts +112 -0
  65. package/src/lib/triggers/new-post.ts +225 -0
  66. package/src/lib/triggers/new-posts-by-author.ts +252 -0
  67. package/src/lib/triggers/new-timeline-posts.ts +141 -0
package/LICENSE.MIT-AP ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) Activepieces AB
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
+ Derived helpers in this folder are adapted from Activepieces (MIT) for use
24
+ inside CX without depending on @activepieces/* packages at runtime.
@@ -0,0 +1,8 @@
1
+ export { blueskyAuth } from './lib/common/auth';
2
+ export { createBlueskyAgent } from './lib/common/client';
3
+ export declare const bluesky: import("@agnocon/pieces-framework").Piece<import("@agnocon/pieces-framework").CustomAuthProperty<{
4
+ pdsHost: import("@agnocon/pieces-framework").ShortTextProperty<false>;
5
+ identifier: import("@agnocon/pieces-framework").ShortTextProperty<true>;
6
+ password: import("@agnocon/pieces-framework").SecretTextProperty<true>;
7
+ }>>;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,OAAO;;;;GASlB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bluesky = exports.createBlueskyAgent = exports.blueskyAuth = void 0;
4
+ // Vendored from Activepieces packages/pieces/community/bluesky/src/index.ts (MIT).
5
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
6
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
7
+ const pieces_framework_2 = require("@agnocon/pieces-framework");
8
+ const auth_1 = require("./lib/common/auth");
9
+ const create_post_1 = require("./lib/actions/create-post");
10
+ const like_post_1 = require("./lib/actions/like-post");
11
+ const repost_1 = require("./lib/actions/repost");
12
+ const find_post_1 = require("./lib/actions/find-post");
13
+ const find_thread_1 = require("./lib/actions/find-thread");
14
+ const new_posts_by_author_1 = require("./lib/triggers/new-posts-by-author");
15
+ const new_follower_on_account_1 = require("./lib/triggers/new-follower-on-account");
16
+ const new_timeline_posts_1 = require("./lib/triggers/new-timeline-posts");
17
+ const new_post_1 = require("./lib/triggers/new-post");
18
+ var auth_2 = require("./lib/common/auth");
19
+ Object.defineProperty(exports, "blueskyAuth", { enumerable: true, get: function () { return auth_2.blueskyAuth; } });
20
+ var client_1 = require("./lib/common/client");
21
+ Object.defineProperty(exports, "createBlueskyAgent", { enumerable: true, get: function () { return client_1.createBlueskyAgent; } });
22
+ exports.bluesky = (0, pieces_framework_1.createPiece)({
23
+ displayName: 'Bluesky',
24
+ auth: auth_1.blueskyAuth,
25
+ minimumSupportedRelease: '0.36.1',
26
+ logoUrl: 'https://cdn.activepieces.com/pieces/bluesky.png',
27
+ authors: ['Sanket6652'],
28
+ categories: [pieces_framework_2.PieceCategory.COMMUNICATION],
29
+ actions: [create_post_1.createPost, like_post_1.likePost, repost_1.repostPost, find_post_1.findPost, find_thread_1.findThread],
30
+ triggers: [new_posts_by_author_1.newPostsByAuthor, new_follower_on_account_1.newFollowerOnAccount, new_timeline_posts_1.newTimelinePosts, new_post_1.newPost],
31
+ });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mFAAmF;AACnF,qEAAqE;AACrE,gEAAmE;AACnE,gEAA0D;AAC1D,4CAAgD;AAChD,2DAAuD;AACvD,uDAAmD;AACnD,iDAAkD;AAClD,uDAAmD;AACnD,2DAAuD;AACvD,4EAAsE;AACtE,oFAA8E;AAC9E,0EAAqE;AACrE,sDAAkD;AAClD,0CAAgD;AAAvC,mGAAA,WAAW,OAAA;AACpB,8CAAyD;AAAhD,4GAAA,kBAAkB,OAAA;AAEd,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,CAAC,YAAY,CAAC;IACvB,UAAU,EAAE,CAAC,gCAAa,CAAC,aAAa,CAAC;IACzC,OAAO,EAAE,CAAC,wBAAU,EAAE,oBAAQ,EAAE,mBAAU,EAAE,oBAAQ,EAAE,wBAAU,CAAC;IACjE,QAAQ,EAAE,CAAC,sCAAgB,EAAE,8CAAoB,EAAE,qCAAgB,EAAE,kBAAO,CAAC;CAC9E,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ export declare const createPost: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").CustomAuthProperty<{
2
+ pdsHost: import("@agnocon/pieces-framework").ShortTextProperty<false>;
3
+ identifier: import("@agnocon/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@agnocon/pieces-framework").SecretTextProperty<true>;
5
+ }>, {
6
+ postType: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
7
+ text: import("@agnocon/pieces-framework").LongTextProperty<true>;
8
+ language: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
9
+ imageUrls: import("@agnocon/pieces-framework").ArrayProperty<false>;
10
+ imageDescriptions: import("@agnocon/pieces-framework").ArrayProperty<false>;
11
+ videoUrl: import("@agnocon/pieces-framework").ShortTextProperty<false>;
12
+ videoAltText: import("@agnocon/pieces-framework").LongTextProperty<false>;
13
+ videoCaptions: import("@agnocon/pieces-framework").ArrayProperty<false>;
14
+ linkUrl: import("@agnocon/pieces-framework").ShortTextProperty<false>;
15
+ replyToPost: import("@agnocon/pieces-framework").ShortTextProperty<false>;
16
+ threadContent: import("@agnocon/pieces-framework").ArrayProperty<false>;
17
+ additionalHashtags: import("@agnocon/pieces-framework").ShortTextProperty<false>;
18
+ contentWarnings: import("@agnocon/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
19
+ audience: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
20
+ }>;
21
+ //# sourceMappingURL=create-post.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-post.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-post.ts"],"names":[],"mappings":"AA8JA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;EA+RrB,CAAC"}
@@ -0,0 +1,379 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPost = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/bluesky/src/lib/actions/create-post.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
8
+ const auth_1 = require("../common/auth");
9
+ const client_1 = require("../common/client");
10
+ const api_1 = require("@atproto/api");
11
+ const props_1 = require("../common/props");
12
+ const videoUrlProperty = pieces_framework_1.Property.ShortText({
13
+ displayName: 'Video URL',
14
+ description: 'Link to video file (MP4, max 100MB)',
15
+ required: false,
16
+ });
17
+ const videoAltTextProperty = pieces_framework_1.Property.LongText({
18
+ displayName: 'Video Description',
19
+ description: 'Describe the video for accessibility',
20
+ required: false,
21
+ });
22
+ const videoCaptionsProperty = pieces_framework_1.Property.Array({
23
+ displayName: 'Video Captions',
24
+ description: 'Caption file URLs (optional)',
25
+ required: false,
26
+ });
27
+ const threadContentProperty = pieces_framework_1.Property.Array({
28
+ displayName: 'Thread Posts',
29
+ description: 'Create additional connected posts',
30
+ required: false,
31
+ });
32
+ const additionalHashtagsProperty = pieces_framework_1.Property.ShortText({
33
+ displayName: 'Hashtags',
34
+ description: 'Add hashtags (e.g., tech,bluesky)',
35
+ required: false,
36
+ });
37
+ function parsePostUrl(url, agent) {
38
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
39
+ if (url.startsWith('at://')) {
40
+ return url;
41
+ }
42
+ const urlMatch = url.match(/https?:\/\/bsky\.app\/profile\/([^/]+)\/post\/([^/?]+)/);
43
+ if (urlMatch) {
44
+ const handle = urlMatch[1];
45
+ const postId = urlMatch[2];
46
+ const didDoc = yield agent.resolveHandle({ handle });
47
+ return `at://${didDoc.data.did}/app.bsky.feed.post/${postId}`;
48
+ }
49
+ throw new Error('Invalid post URL format. Please use a valid Bluesky post URL.');
50
+ });
51
+ }
52
+ function getReplyRefs(postUri, agent) {
53
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
54
+ try {
55
+ const postThread = yield agent.getPostThread({ uri: postUri });
56
+ const post = postThread.thread.post;
57
+ if (!post) {
58
+ throw new Error('Post not found');
59
+ }
60
+ const parentReply = post.record.reply;
61
+ return {
62
+ root: (parentReply === null || parentReply === void 0 ? void 0 : parentReply.root) || { uri: post.uri, cid: post.cid },
63
+ parent: { uri: post.uri, cid: post.cid },
64
+ };
65
+ }
66
+ catch (error) {
67
+ throw new Error(`Failed to resolve reply: ${error instanceof Error ? error.message : 'Unknown error'}`);
68
+ }
69
+ });
70
+ }
71
+ function createEnhancedLinkEmbed(url, agent) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ try {
74
+ const response = yield fetch(url, {
75
+ headers: {
76
+ 'User-Agent': 'Mozilla/5.0 (compatible; Activepieces-Bot/1.0)',
77
+ },
78
+ });
79
+ if (!response.ok) {
80
+ throw new Error(`HTTP ${response.status}`);
81
+ }
82
+ const html = yield response.text();
83
+ const titleMatch = html.match(/<meta\s+property="og:title"\s+content="([^"]*)"[^>]*>/i) ||
84
+ html.match(/<title[^>]*>([^<]*)<\/title>/i);
85
+ const title = titleMatch ? titleMatch[1].trim() : url;
86
+ const descMatch = html.match(/<meta\s+property="og:description"\s+content="([^"]*)"[^>]*>/i) ||
87
+ html.match(/<meta\s+name="description"\s+content="([^"]*)"[^>]*>/i);
88
+ const description = descMatch ? descMatch[1].trim() : '';
89
+ const imageMatch = html.match(/<meta\s+property="og:image"\s+content="([^"]*)"[^>]*>/i);
90
+ const external = {
91
+ uri: url,
92
+ title: title.length > 0 ? title : url,
93
+ description: description.length > 0 ? description : 'Shared link',
94
+ };
95
+ if (imageMatch && imageMatch[1]) {
96
+ try {
97
+ let imageUrl = imageMatch[1];
98
+ if (imageUrl.startsWith('/')) {
99
+ const urlObj = new URL(url);
100
+ imageUrl = `${urlObj.protocol}//${urlObj.host}${imageUrl}`;
101
+ }
102
+ else if (!imageUrl.startsWith('http')) {
103
+ imageUrl = new URL(imageUrl, url).href;
104
+ }
105
+ const imageResponse = yield fetch(imageUrl);
106
+ if (imageResponse.ok) {
107
+ const imageBlob = yield imageResponse.blob();
108
+ if (imageBlob.size <= 1000000 && imageBlob.type.startsWith('image/')) {
109
+ const thumbResponse = yield agent.uploadBlob(imageBlob, {
110
+ encoding: imageBlob.type,
111
+ });
112
+ external.thumb = thumbResponse.data.blob;
113
+ }
114
+ }
115
+ }
116
+ catch (thumbError) {
117
+ console.warn('Failed to upload link thumbnail:', thumbError);
118
+ }
119
+ }
120
+ return {
121
+ $type: 'app.bsky.embed.external',
122
+ external,
123
+ };
124
+ }
125
+ catch (error) {
126
+ return {
127
+ $type: 'app.bsky.embed.external',
128
+ external: {
129
+ uri: url,
130
+ title: url,
131
+ description: 'Shared link',
132
+ },
133
+ };
134
+ }
135
+ });
136
+ }
137
+ exports.createPost = (0, pieces_framework_1.createAction)({
138
+ auth: auth_1.blueskyAuth,
139
+ name: 'createPost',
140
+ displayName: 'Create Post',
141
+ description: 'Create a new post on Bluesky',
142
+ audience: 'both',
143
+ aiMetadata: {
144
+ description: 'Publishes a new post to the authenticated Bluesky account, with optional images, video, an external link card, content-warning labels, and chained thread replies. Use to broadcast content on Bluesky; provide the post text (max 300 characters after hashtags/links are expanded). Not idempotent — each call creates a brand-new post.',
145
+ idempotent: false,
146
+ },
147
+ props: {
148
+ postType: props_1.postTypeDropdown,
149
+ text: props_1.postTextProperty,
150
+ language: props_1.simpleLanguageDropdown,
151
+ imageUrls: props_1.imageUrlsProperty,
152
+ imageDescriptions: props_1.imageDescriptionsProperty,
153
+ videoUrl: videoUrlProperty,
154
+ videoAltText: videoAltTextProperty,
155
+ videoCaptions: videoCaptionsProperty,
156
+ linkUrl: props_1.linkUrlProperty,
157
+ replyToPost: props_1.replyToPostProperty,
158
+ threadContent: threadContentProperty,
159
+ additionalHashtags: additionalHashtagsProperty,
160
+ contentWarnings: props_1.contentWarningDropdown,
161
+ audience: props_1.audienceDropdown,
162
+ },
163
+ run(_a) {
164
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
165
+ const { text, language, imageUrls, imageDescriptions, videoUrl, videoAltText, videoCaptions, linkUrl, replyToPost, threadContent, additionalHashtags, contentWarnings, audience } = propsValue;
166
+ try {
167
+ const agent = yield (0, client_1.createBlueskyAgent)(auth.props);
168
+ let processedText = text;
169
+ if (additionalHashtags && additionalHashtags.trim()) {
170
+ const hashtags = additionalHashtags
171
+ .split(',')
172
+ .map(tag => tag.trim().startsWith('#') ? tag.trim() : `#${tag.trim()}`)
173
+ .filter(tag => tag.length > 1)
174
+ .join(' ');
175
+ if (hashtags) {
176
+ processedText += ` ${hashtags}`;
177
+ }
178
+ }
179
+ const richText = new api_1.RichText({ text: processedText });
180
+ yield richText.detectFacets(agent);
181
+ if (richText.length > 300) {
182
+ throw new Error('Post text cannot exceed 300 characters');
183
+ }
184
+ const postRecord = {
185
+ text: richText.text,
186
+ facets: richText.facets,
187
+ createdAt: new Date().toISOString(),
188
+ };
189
+ if (additionalHashtags && additionalHashtags.trim()) {
190
+ const tagList = additionalHashtags
191
+ .split(',')
192
+ .map(tag => tag.trim().replace(/^#/, ''))
193
+ .filter(tag => tag.length > 0);
194
+ if (tagList.length > 0) {
195
+ postRecord.tags = tagList;
196
+ }
197
+ }
198
+ if (contentWarnings && contentWarnings.length > 0) {
199
+ postRecord.labels = {
200
+ $type: 'com.atproto.label.defs#selfLabels',
201
+ values: contentWarnings.map((warning) => ({ val: warning })),
202
+ };
203
+ }
204
+ if (language && language !== 'other') {
205
+ postRecord.langs = [language];
206
+ }
207
+ if (replyToPost && replyToPost.trim()) {
208
+ const postUri = yield parsePostUrl(replyToPost, agent);
209
+ postRecord.reply = yield getReplyRefs(postUri, agent);
210
+ }
211
+ if (videoUrl && videoUrl.trim()) {
212
+ try {
213
+ const videoResponse = yield fetch(videoUrl);
214
+ if (!videoResponse.ok) {
215
+ throw new Error(`Failed to fetch video from ${videoUrl}`);
216
+ }
217
+ const videoBlob = yield videoResponse.blob();
218
+ if (!videoBlob.type.startsWith('video/')) {
219
+ throw new Error('File must be a video format');
220
+ }
221
+ if (videoBlob.size > 100000000) {
222
+ throw new Error(`Video is too large (max 100MB), got ${Math.round(videoBlob.size / 1000000)}MB`);
223
+ }
224
+ const videoBlobResponse = yield agent.uploadBlob(videoBlob, {
225
+ encoding: videoBlob.type,
226
+ });
227
+ const captionObjects = [];
228
+ if (videoCaptions && videoCaptions.length > 0) {
229
+ for (let i = 0; i < videoCaptions.length; i++) {
230
+ const captionUrl = videoCaptions[i];
231
+ try {
232
+ const captionResponse = yield fetch(captionUrl);
233
+ if (!captionResponse.ok)
234
+ continue;
235
+ const captionBlob = yield captionResponse.blob();
236
+ const captionBlobResponse = yield agent.uploadBlob(captionBlob, {
237
+ encoding: 'text/vtt',
238
+ });
239
+ captionObjects.push({
240
+ lang: 'en',
241
+ file: captionBlobResponse.data.blob,
242
+ });
243
+ }
244
+ catch (error) {
245
+ console.warn(`Failed to upload caption ${i + 1}:`, error);
246
+ }
247
+ }
248
+ }
249
+ const videoEmbed = {
250
+ $type: 'app.bsky.embed.video',
251
+ video: videoBlobResponse.data.blob,
252
+ };
253
+ if (videoAltText && videoAltText.trim()) {
254
+ videoEmbed.alt = videoAltText.trim();
255
+ }
256
+ if (captionObjects.length > 0) {
257
+ videoEmbed.captions = captionObjects;
258
+ }
259
+ postRecord.embed = videoEmbed;
260
+ }
261
+ catch (error) {
262
+ throw new Error(`Failed to process video: ${error instanceof Error ? error.message : 'Unknown error'}`);
263
+ }
264
+ }
265
+ else if (imageUrls && imageUrls.length > 0) {
266
+ if (imageUrls.length > 4) {
267
+ throw new Error('Maximum of 4 images allowed per post');
268
+ }
269
+ const images = [];
270
+ for (let i = 0; i < imageUrls.length; i++) {
271
+ const imageUrl = imageUrls[i];
272
+ const altText = (imageDescriptions === null || imageDescriptions === void 0 ? void 0 : imageDescriptions[i]) || '';
273
+ try {
274
+ const imageResponse = yield fetch(imageUrl);
275
+ if (!imageResponse.ok) {
276
+ throw new Error(`Failed to fetch image from ${imageUrl}`);
277
+ }
278
+ const imageBlob = yield imageResponse.blob();
279
+ if (imageBlob.size > 1000000) {
280
+ throw new Error(`Image at ${imageUrl} is too large (max 1MB)`);
281
+ }
282
+ const blobResponse = yield agent.uploadBlob(imageBlob, {
283
+ encoding: imageBlob.type,
284
+ });
285
+ images.push({
286
+ alt: altText,
287
+ image: blobResponse.data.blob,
288
+ });
289
+ }
290
+ catch (error) {
291
+ throw new Error(`Failed to upload image ${i + 1}: ${error instanceof Error ? error.message : 'Unknown error'}`);
292
+ }
293
+ }
294
+ postRecord.embed = {
295
+ $type: 'app.bsky.embed.images',
296
+ images,
297
+ };
298
+ }
299
+ else if (linkUrl && linkUrl.trim()) {
300
+ try {
301
+ const linkEmbed = yield createEnhancedLinkEmbed(linkUrl, agent);
302
+ postRecord.embed = linkEmbed;
303
+ }
304
+ catch (error) {
305
+ console.warn('Failed to fetch link metadata, using basic embed:', error);
306
+ postRecord.embed = {
307
+ $type: 'app.bsky.embed.external',
308
+ external: {
309
+ uri: linkUrl,
310
+ title: linkUrl,
311
+ description: 'Shared link',
312
+ },
313
+ };
314
+ }
315
+ }
316
+ const mainPostResponse = yield agent.post(postRecord);
317
+ const createdPosts = [mainPostResponse];
318
+ if (threadContent && threadContent.length > 0) {
319
+ let previousPost = mainPostResponse;
320
+ for (let i = 0; i < threadContent.length; i++) {
321
+ const threadText = threadContent[i];
322
+ if (!threadText || !threadText.trim())
323
+ continue;
324
+ try {
325
+ const threadRichText = new api_1.RichText({ text: threadText });
326
+ yield threadRichText.detectFacets(agent);
327
+ if (threadRichText.length > 300) {
328
+ console.warn(`Thread post ${i + 1} exceeds 300 characters, skipping`);
329
+ continue;
330
+ }
331
+ const threadPostRecord = {
332
+ text: threadRichText.text,
333
+ facets: threadRichText.facets,
334
+ createdAt: new Date().toISOString(),
335
+ reply: {
336
+ root: { uri: mainPostResponse.uri, cid: mainPostResponse.cid },
337
+ parent: { uri: previousPost.uri, cid: previousPost.cid },
338
+ },
339
+ };
340
+ if (language && language !== 'other') {
341
+ threadPostRecord.langs = [language];
342
+ }
343
+ if (contentWarnings && contentWarnings.length > 0) {
344
+ threadPostRecord.labels = {
345
+ $type: 'com.atproto.label.defs#selfLabels',
346
+ values: contentWarnings.map((warning) => ({ val: warning })),
347
+ };
348
+ }
349
+ const threadResponse = yield agent.post(threadPostRecord);
350
+ createdPosts.push(threadResponse);
351
+ previousPost = threadResponse;
352
+ yield new Promise(resolve => setTimeout(resolve, 100));
353
+ }
354
+ catch (threadError) {
355
+ console.warn(`Failed to create thread post ${i + 1}:`, threadError);
356
+ }
357
+ }
358
+ }
359
+ return {
360
+ success: true,
361
+ mainPost: {
362
+ uri: mainPostResponse.uri,
363
+ cid: mainPostResponse.cid,
364
+ },
365
+ threadPosts: createdPosts.slice(1).map(post => ({
366
+ uri: post.uri,
367
+ cid: post.cid,
368
+ })),
369
+ totalPosts: createdPosts.length,
370
+ record: postRecord,
371
+ };
372
+ }
373
+ catch (error) {
374
+ throw new Error(`Failed to create post: ${error instanceof Error ? error.message : 'Unknown error'}`);
375
+ }
376
+ });
377
+ },
378
+ });
379
+ //# sourceMappingURL=create-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-post.js","sourceRoot":"","sources":["../../../src/lib/actions/create-post.ts"],"names":[],"mappings":";;;;AAAA,qGAAqG;AACrG,qEAAqE;AACrE,gEAAmE;AACnE,yCAA6C;AAC7C,6CAAsD;AACtD,sCAAwC;AACxC,2CAUyB;AAEzB,MAAM,gBAAgB,GAAG,2BAAQ,CAAC,SAAS,CAAC;IAC1C,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,qCAAqC;IAClD,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAC7C,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,sCAAsC;IACnD,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,2BAAQ,CAAC,KAAK,CAAC;IAC3C,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,8BAA8B;IAC3C,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,2BAAQ,CAAC,KAAK,CAAC;IAC3C,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,mCAAmC;IAChD,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,2BAAQ,CAAC,SAAS,CAAC;IACpD,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,mCAAmC;IAChD,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAEH,SAAe,YAAY,CAAC,GAAW,EAAE,KAAU;;QACjD,IAAI,GAAG,CAAC,UAAU,C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AAW,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBAC9C,GAAG,EAAE,IAAI,CAAC,GAAG;wBACb,GAAG,EAAE,IAAI,CAAC,GAAG;qBACd,CAAC,CAAC;oBACH,UAAU,EAAE,YAAY,CAAC,MAAM;oBAC/B,MAAM,EAAE,UAAU;iBACnB,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;YACxG,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const findPost: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").CustomAuthProperty<{
2
+ pdsHost: import("@agnocon/pieces-framework").ShortTextProperty<false>;
3
+ identifier: import("@agnocon/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@agnocon/pieces-framework").SecretTextProperty<true>;
5
+ }>, {
6
+ postUrl: import("@agnocon/pieces-framework").ShortTextProperty<true>;
7
+ }>;
8
+ //# sourceMappingURL=find-post.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-post.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/find-post.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,QAAQ;;;;;;EAsEnB,CAAC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findPost = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/bluesky/src/lib/actions/find-post.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
8
+ const auth_1 = require("../common/auth");
9
+ const client_1 = require("../common/client");
10
+ const props_1 = require("../common/props");
11
+ exports.findPost = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.blueskyAuth,
13
+ name: 'findPost',
14
+ displayName: 'Find Post',
15
+ description: 'Get detailed information about a specific post',
16
+ audience: 'both',
17
+ aiMetadata: {
18
+ description: 'Retrieves a single Bluesky post with its content, author, and engagement counts (likes, reposts, replies, quotes), given a bsky.app post URL or AT-URI. Use to look up the current state or metadata of a known post. Read-only and idempotent.',
19
+ idempotent: true,
20
+ },
21
+ props: {
22
+ postUrl: props_1.postUrlProperty,
23
+ },
24
+ run(_a) {
25
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
26
+ var _b, _c;
27
+ const { postUrl } = propsValue;
28
+ try {
29
+ const agent = yield (0, client_1.createBlueskyAgent)(auth.props);
30
+ const postInfo = (0, props_1.extractPostInfoFromUrl)(postUrl);
31
+ let atUri = postInfo.uri;
32
+ if (!atUri && postInfo.handle && postInfo.postId) {
33
+ const didDoc = yield agent.resolveHandle({ handle: postInfo.handle });
34
+ if ((_b = didDoc.data) === null || _b === void 0 ? void 0 : _b.did) {
35
+ atUri = `at://${didDoc.data.did}/app.bsky.feed.post/${postInfo.postId}`;
36
+ }
37
+ else {
38
+ throw new Error(`Could not resolve handle: ${postInfo.handle}`);
39
+ }
40
+ }
41
+ if (!atUri) {
42
+ throw new Error('Could not parse the post URL. Please make sure you are using a valid Bluesky post URL like: https://bsky.app/profile/username.bsky.social/post/xxx');
43
+ }
44
+ if (!atUri.startsWith('at://')) {
45
+ throw new Error('Invalid URI format. Must be an AT-URI starting with "at://" or a valid Bluesky URL');
46
+ }
47
+ const response = yield agent.getPosts({ uris: [atUri] });
48
+ if (!((_c = response.data) === null || _c === void 0 ? void 0 : _c.posts) || response.data.posts.length === 0) {
49
+ throw new Error('Post not found or not accessible');
50
+ }
51
+ const post = response.data.posts[0];
52
+ return {
53
+ success: true,
54
+ uri: atUri,
55
+ cid: post.cid,
56
+ record: post.record,
57
+ author: post.author,
58
+ indexedAt: post.indexedAt,
59
+ replyCount: post.replyCount || 0,
60
+ repostCount: post.repostCount || 0,
61
+ likeCount: post.likeCount || 0,
62
+ quoteCount: post.quoteCount || 0,
63
+ embed: post.embed,
64
+ labels: post.labels,
65
+ threadgate: post.threadgate,
66
+ viewer: post.viewer,
67
+ retrievedAt: new Date().toISOString(),
68
+ };
69
+ }
70
+ catch (error) {
71
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
72
+ throw new Error(`Failed to find post: ${errorMessage}`);
73
+ }
74
+ });
75
+ },
76
+ });
77
+ //# sourceMappingURL=find-post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-post.js","sourceRoot":"","sources":["../../../src/lib/actions/find-post.ts"],"names":[],"mappings":";;;;AAAA,mGAAmG;AACnG,qEAAqE;AACrE,gEAAmE;AACnE,yCAA6C;AAC7C,6CAAsD;AACtD,2CAA0E;AAE7D,QAAA,QAAQ,GAAG,IAAA,+BAAY,EAAC;IACnC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,gDAAgD;IAC7D,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE;QACV,WAAW,EAAE,iPAAiP;QAC9P,UAAU,EAAE,IAAI;KACjB;IACD,KAAK,EAAE;QACL,OAAO,EAAE,uBAAe;KACzB;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;;YAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;YAE/B,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,IAAA,2BAAkB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAEnD,MAAM,QAAQ,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;gBACjD,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC;gBAEzB,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,MAA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,CAAC,MAAM;oBACnB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,CAAC;oBAChC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,CAAC;oBAClC,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC;oBAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,CAAC;oBAChC,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;iBACtC,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBAC9E,MAAM,IAAI,KAAK,CAAC,wBAAwB,YAAY,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const findThread: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").CustomAuthProperty<{
2
+ pdsHost: import("@agnocon/pieces-framework").ShortTextProperty<false>;
3
+ identifier: import("@agnocon/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@agnocon/pieces-framework").SecretTextProperty<true>;
5
+ }>, {
6
+ postUrl: import("@agnocon/pieces-framework").ShortTextProperty<true>;
7
+ depth: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
8
+ parentHeight: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
9
+ }>;
10
+ //# sourceMappingURL=find-thread.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-thread.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/find-thread.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU;;;;;;;;EAmHrB,CAAC"}