postproxy-mcp 1.0.2 → 1.2.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/dist/api/client.d.ts +27 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +99 -0
- package/dist/api/client.js.map +1 -1
- package/dist/server.d.ts +192 -6
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +197 -6
- package/dist/server.js.map +1 -1
- package/dist/tools/history.d.ts.map +1 -1
- package/dist/tools/history.js +6 -2
- package/dist/tools/history.js.map +1 -1
- package/dist/tools/post.d.ts +6 -0
- package/dist/tools/post.d.ts.map +1 -1
- package/dist/tools/post.js +22 -8
- package/dist/tools/post.js.map +1 -1
- package/dist/tools/queue.d.ts +73 -0
- package/dist/tools/queue.d.ts.map +1 -0
- package/dist/tools/queue.js +167 -0
- package/dist/tools/queue.js.map +1 -0
- package/dist/types/index.d.ts +91 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +63 -2
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +12 -0
- package/dist/utils/validation.js.map +1 -1
- package/package.json +1 -1
- package/src/api/client.ts +112 -0
- package/src/server.ts +204 -6
- package/src/tools/history.ts +5 -2
- package/src/tools/post.ts +29 -14
- package/src/tools/queue.ts +230 -0
- package/src/types/index.ts +84 -11
- package/src/utils/validation.ts +13 -0
- package/worker/index.ts +366 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAChD,CAAC,IAAI,EAAE,EAAE;IACP,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;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IAAI,IAAI,EAAE,CAAC;IACvB,OAAO,YAAY,GAAG,GAAG,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
package/src/api/client.ts
CHANGED
|
@@ -14,6 +14,9 @@ import type {
|
|
|
14
14
|
Post,
|
|
15
15
|
Placement,
|
|
16
16
|
StatsResponse,
|
|
17
|
+
PostQueue,
|
|
18
|
+
CreateQueueParams,
|
|
19
|
+
UpdateQueueParams,
|
|
17
20
|
} from "../types/index.js";
|
|
18
21
|
import { createError, ErrorCodes, formatError, type ErrorCode } from "../utils/errors.js";
|
|
19
22
|
import { log, logError } from "../utils/logger.js";
|
|
@@ -144,6 +147,19 @@ export class PostProxyClient {
|
|
|
144
147
|
formData.append("platforms", JSON.stringify(params.platforms));
|
|
145
148
|
}
|
|
146
149
|
|
|
150
|
+
// Add thread children
|
|
151
|
+
if (params.thread && params.thread.length > 0) {
|
|
152
|
+
formData.append("thread", JSON.stringify(params.thread));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Add queue parameters
|
|
156
|
+
if (params.queue_id) {
|
|
157
|
+
formData.append("queue_id", params.queue_id);
|
|
158
|
+
if (params.queue_priority) {
|
|
159
|
+
formData.append("queue_priority", params.queue_priority);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
147
163
|
// Build headers (no Content-Type - fetch will set it with boundary for multipart)
|
|
148
164
|
const headers: Record<string, string> = {
|
|
149
165
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -387,6 +403,11 @@ export class PostProxyClient {
|
|
|
387
403
|
apiPayload.post.draft = params.draft;
|
|
388
404
|
}
|
|
389
405
|
|
|
406
|
+
// Thread children (X and Threads only)
|
|
407
|
+
if (params.thread && params.thread.length > 0) {
|
|
408
|
+
apiPayload.thread = params.thread;
|
|
409
|
+
}
|
|
410
|
+
|
|
390
411
|
// Platform-specific parameters
|
|
391
412
|
// Only include platforms if it's a non-empty object with at least one platform
|
|
392
413
|
// Supports all platform parameter types: strings, numbers, booleans, arrays (e.g., collaborators)
|
|
@@ -415,6 +436,14 @@ export class PostProxyClient {
|
|
|
415
436
|
}
|
|
416
437
|
}
|
|
417
438
|
|
|
439
|
+
// Queue parameters (top-level, not inside post object)
|
|
440
|
+
if (params.queue_id) {
|
|
441
|
+
apiPayload.queue_id = params.queue_id;
|
|
442
|
+
if (params.queue_priority) {
|
|
443
|
+
apiPayload.queue_priority = params.queue_priority;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
418
447
|
// Log payload in debug mode to troubleshoot draft issues
|
|
419
448
|
if (process.env.POSTPROXY_MCP_DEBUG === "1") {
|
|
420
449
|
log("Creating post with payload:", JSON.stringify(apiPayload, null, 2));
|
|
@@ -527,4 +556,87 @@ export class PostProxyClient {
|
|
|
527
556
|
}
|
|
528
557
|
return this.request<StatsResponse>("GET", `/posts/stats?${queryParams.toString()}`);
|
|
529
558
|
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* List all queues, optionally filtered by profile group
|
|
562
|
+
*/
|
|
563
|
+
async listQueues(profileGroupId?: string): Promise<PostQueue[]> {
|
|
564
|
+
const path = profileGroupId
|
|
565
|
+
? `/post_queues?profile_group_id=${profileGroupId}`
|
|
566
|
+
: "/post_queues";
|
|
567
|
+
const response = await this.request<any>("GET", path);
|
|
568
|
+
return this.extractArray<PostQueue>(response);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Get a single queue by ID
|
|
573
|
+
*/
|
|
574
|
+
async getQueue(queueId: string): Promise<PostQueue> {
|
|
575
|
+
return this.request<PostQueue>("GET", `/post_queues/${queueId}`);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Get the next available timeslot for a queue
|
|
580
|
+
*/
|
|
581
|
+
async getQueueNextSlot(queueId: string): Promise<{ next_slot: string }> {
|
|
582
|
+
return this.request<{ next_slot: string }>("GET", `/post_queues/${queueId}/next_slot`);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Create a new queue
|
|
587
|
+
*/
|
|
588
|
+
async createQueue(params: CreateQueueParams): Promise<PostQueue> {
|
|
589
|
+
const apiPayload: any = {
|
|
590
|
+
profile_group_id: params.profile_group_id,
|
|
591
|
+
post_queue: {
|
|
592
|
+
name: params.name,
|
|
593
|
+
},
|
|
594
|
+
};
|
|
595
|
+
if (params.description !== undefined) {
|
|
596
|
+
apiPayload.post_queue.description = params.description;
|
|
597
|
+
}
|
|
598
|
+
if (params.timezone) {
|
|
599
|
+
apiPayload.post_queue.timezone = params.timezone;
|
|
600
|
+
}
|
|
601
|
+
if (params.jitter !== undefined) {
|
|
602
|
+
apiPayload.post_queue.jitter = params.jitter;
|
|
603
|
+
}
|
|
604
|
+
if (params.timeslots && params.timeslots.length > 0) {
|
|
605
|
+
apiPayload.post_queue.queue_timeslots_attributes = params.timeslots;
|
|
606
|
+
}
|
|
607
|
+
return this.request<PostQueue>("POST", "/post_queues", apiPayload);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Update a queue
|
|
612
|
+
*/
|
|
613
|
+
async updateQueue(queueId: string, params: UpdateQueueParams): Promise<PostQueue> {
|
|
614
|
+
const apiPayload: any = { post_queue: {} };
|
|
615
|
+
if (params.name !== undefined) {
|
|
616
|
+
apiPayload.post_queue.name = params.name;
|
|
617
|
+
}
|
|
618
|
+
if (params.description !== undefined) {
|
|
619
|
+
apiPayload.post_queue.description = params.description;
|
|
620
|
+
}
|
|
621
|
+
if (params.timezone !== undefined) {
|
|
622
|
+
apiPayload.post_queue.timezone = params.timezone;
|
|
623
|
+
}
|
|
624
|
+
if (params.enabled !== undefined) {
|
|
625
|
+
apiPayload.post_queue.enabled = params.enabled;
|
|
626
|
+
}
|
|
627
|
+
if (params.jitter !== undefined) {
|
|
628
|
+
apiPayload.post_queue.jitter = params.jitter;
|
|
629
|
+
}
|
|
630
|
+
if (params.timeslots && params.timeslots.length > 0) {
|
|
631
|
+
apiPayload.post_queue.queue_timeslots_attributes = params.timeslots;
|
|
632
|
+
}
|
|
633
|
+
return this.request<PostQueue>("PATCH", `/post_queues/${queueId}`, apiPayload);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Delete a queue
|
|
638
|
+
*/
|
|
639
|
+
async deleteQueue(queueId: string): Promise<void> {
|
|
640
|
+
await this.request<void>("DELETE", `/post_queues/${queueId}`);
|
|
641
|
+
}
|
|
530
642
|
}
|
package/src/server.ts
CHANGED
|
@@ -15,6 +15,14 @@ import {
|
|
|
15
15
|
handlePostStats,
|
|
16
16
|
} from "./tools/post.js";
|
|
17
17
|
import { handleHistoryList } from "./tools/history.js";
|
|
18
|
+
import {
|
|
19
|
+
handleQueuesList,
|
|
20
|
+
handleQueuesGet,
|
|
21
|
+
handleQueuesCreate,
|
|
22
|
+
handleQueuesUpdate,
|
|
23
|
+
handleQueuesDelete,
|
|
24
|
+
handleQueuesNextSlot,
|
|
25
|
+
} from "./tools/queue.js";
|
|
18
26
|
import { createError, ErrorCodes } from "./utils/errors.js";
|
|
19
27
|
import { logToolCall } from "./utils/logger.js";
|
|
20
28
|
|
|
@@ -41,7 +49,7 @@ export const TOOL_DEFINITIONS = [
|
|
|
41
49
|
},
|
|
42
50
|
{
|
|
43
51
|
name: "post.publish",
|
|
44
|
-
description: "Publish a post to specified social media profiles. Supports text content, media attachments, scheduling, drafts, and platform-specific customization via the 'platforms' parameter.",
|
|
52
|
+
description: "Publish a post to specified social media profiles. Supports text content, media attachments, scheduling, drafts, threads (X and Threads only), and platform-specific customization via the 'platforms' parameter.",
|
|
45
53
|
inputSchema: {
|
|
46
54
|
type: "object",
|
|
47
55
|
properties: {
|
|
@@ -86,17 +94,17 @@ export const TOOL_DEFINITIONS = [
|
|
|
86
94
|
},
|
|
87
95
|
youtube: {
|
|
88
96
|
type: "object",
|
|
89
|
-
description: "YouTube: title (string), privacy_status (public|unlisted|private), cover_url (thumbnail URL)",
|
|
97
|
+
description: "YouTube: title (string), privacy_status (public|unlisted|private), cover_url (thumbnail URL), made_for_kids (bool)",
|
|
90
98
|
additionalProperties: true,
|
|
91
99
|
},
|
|
92
100
|
tiktok: {
|
|
93
101
|
type: "object",
|
|
94
|
-
description: "TikTok: privacy_status (PUBLIC_TO_EVERYONE|MUTUAL_FOLLOW_FRIENDS|FOLLOWER_OF_CREATOR|SELF_ONLY), photo_cover_index (integer), auto_add_music (bool), made_with_ai (bool), disable_comment (bool), disable_duet (bool), disable_stitch (bool), brand_content_toggle (bool), brand_organic_toggle (bool)",
|
|
102
|
+
description: "TikTok: format (video|image), privacy_status (PUBLIC_TO_EVERYONE|MUTUAL_FOLLOW_FRIENDS|FOLLOWER_OF_CREATOR|SELF_ONLY), photo_cover_index (integer, image only), auto_add_music (bool, image only), made_with_ai (bool, video only), disable_comment (bool), disable_duet (bool, video only), disable_stitch (bool, video only), brand_content_toggle (bool), brand_organic_toggle (bool)",
|
|
95
103
|
additionalProperties: true,
|
|
96
104
|
},
|
|
97
105
|
facebook: {
|
|
98
106
|
type: "object",
|
|
99
|
-
description: "Facebook: format (post|story), first_comment (string), page_id (string)",
|
|
107
|
+
description: "Facebook: format (post|story), first_comment (string), page_id (string, use profiles.placements to get available pages)",
|
|
100
108
|
additionalProperties: true,
|
|
101
109
|
},
|
|
102
110
|
linkedin: {
|
|
@@ -106,17 +114,45 @@ export const TOOL_DEFINITIONS = [
|
|
|
106
114
|
},
|
|
107
115
|
twitter: {
|
|
108
116
|
type: "object",
|
|
109
|
-
description: "Twitter/X: No platform-specific parameters available",
|
|
117
|
+
description: "Twitter/X: No platform-specific parameters available. Supports threads.",
|
|
110
118
|
additionalProperties: true,
|
|
111
119
|
},
|
|
112
120
|
threads: {
|
|
113
121
|
type: "object",
|
|
114
|
-
description: "Threads: No platform-specific parameters available",
|
|
122
|
+
description: "Threads: No platform-specific parameters available. Supports threads.",
|
|
115
123
|
additionalProperties: true,
|
|
116
124
|
},
|
|
117
125
|
},
|
|
118
126
|
additionalProperties: true,
|
|
119
127
|
},
|
|
128
|
+
thread: {
|
|
129
|
+
type: "array",
|
|
130
|
+
description: "Optional array of thread child posts (supported on X/Twitter and Threads only). The parent post is published first, then each child is published as a reply in order.",
|
|
131
|
+
items: {
|
|
132
|
+
type: "object",
|
|
133
|
+
properties: {
|
|
134
|
+
body: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "Text content for this thread post",
|
|
137
|
+
},
|
|
138
|
+
media: {
|
|
139
|
+
type: "array",
|
|
140
|
+
items: { type: "string" },
|
|
141
|
+
description: "Optional array of media URLs for this thread post",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
required: ["body"],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
queue_id: {
|
|
148
|
+
type: "string",
|
|
149
|
+
description: "Optional queue ID to add the post to. The queue will automatically assign a timeslot. Do not use together with 'schedule'.",
|
|
150
|
+
},
|
|
151
|
+
queue_priority: {
|
|
152
|
+
type: "string",
|
|
153
|
+
enum: ["high", "medium", "low"],
|
|
154
|
+
description: "Optional priority when adding to a queue (default: medium). Higher priority posts get earlier timeslots.",
|
|
155
|
+
},
|
|
120
156
|
},
|
|
121
157
|
required: ["content", "profiles"],
|
|
122
158
|
},
|
|
@@ -217,6 +253,156 @@ export const TOOL_DEFINITIONS = [
|
|
|
217
253
|
required: ["profile_id"],
|
|
218
254
|
},
|
|
219
255
|
},
|
|
256
|
+
{
|
|
257
|
+
name: "queues.list",
|
|
258
|
+
description: "List all posting queues. Queues automatically schedule posts into recurring weekly timeslots with priority-based ordering.",
|
|
259
|
+
inputSchema: {
|
|
260
|
+
type: "object",
|
|
261
|
+
properties: {
|
|
262
|
+
profile_group_id: {
|
|
263
|
+
type: "string",
|
|
264
|
+
description: "Optional profile group ID to filter queues",
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: "queues.get",
|
|
271
|
+
description: "Get details of a single posting queue including its timeslots and post count",
|
|
272
|
+
inputSchema: {
|
|
273
|
+
type: "object",
|
|
274
|
+
properties: {
|
|
275
|
+
queue_id: {
|
|
276
|
+
type: "string",
|
|
277
|
+
description: "Queue ID",
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
required: ["queue_id"],
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
name: "queues.create",
|
|
285
|
+
description: "Create a new posting queue with weekly timeslots. Use profiles.list to find the profile_group_id.",
|
|
286
|
+
inputSchema: {
|
|
287
|
+
type: "object",
|
|
288
|
+
properties: {
|
|
289
|
+
profile_group_id: {
|
|
290
|
+
type: "string",
|
|
291
|
+
description: "Profile group ID to connect the queue to",
|
|
292
|
+
},
|
|
293
|
+
name: {
|
|
294
|
+
type: "string",
|
|
295
|
+
description: "Queue name",
|
|
296
|
+
},
|
|
297
|
+
description: {
|
|
298
|
+
type: "string",
|
|
299
|
+
description: "Optional description",
|
|
300
|
+
},
|
|
301
|
+
timezone: {
|
|
302
|
+
type: "string",
|
|
303
|
+
description: "IANA timezone name (e.g. 'America/New_York'). Default: UTC",
|
|
304
|
+
},
|
|
305
|
+
jitter: {
|
|
306
|
+
type: "number",
|
|
307
|
+
description: "Random offset in minutes (0-60) applied to scheduled times for natural posting patterns. Default: 0",
|
|
308
|
+
},
|
|
309
|
+
timeslots: {
|
|
310
|
+
type: "array",
|
|
311
|
+
description: "Initial weekly timeslots",
|
|
312
|
+
items: {
|
|
313
|
+
type: "object",
|
|
314
|
+
properties: {
|
|
315
|
+
day: {
|
|
316
|
+
type: "number",
|
|
317
|
+
description: "Day of week: 0=Sunday, 1=Monday, ..., 6=Saturday",
|
|
318
|
+
},
|
|
319
|
+
time: {
|
|
320
|
+
type: "string",
|
|
321
|
+
description: "Time in 24-hour HH:MM format (e.g. '09:00', '14:30')",
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
required: ["day", "time"],
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
required: ["profile_group_id", "name"],
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: "queues.update",
|
|
333
|
+
description: "Update a queue's settings, timeslots, or pause/unpause it. Changes to timezone or timeslots trigger rearrangement of all queued posts.",
|
|
334
|
+
inputSchema: {
|
|
335
|
+
type: "object",
|
|
336
|
+
properties: {
|
|
337
|
+
queue_id: {
|
|
338
|
+
type: "string",
|
|
339
|
+
description: "Queue ID to update",
|
|
340
|
+
},
|
|
341
|
+
name: {
|
|
342
|
+
type: "string",
|
|
343
|
+
description: "New queue name",
|
|
344
|
+
},
|
|
345
|
+
description: {
|
|
346
|
+
type: "string",
|
|
347
|
+
description: "New description",
|
|
348
|
+
},
|
|
349
|
+
timezone: {
|
|
350
|
+
type: "string",
|
|
351
|
+
description: "IANA timezone name",
|
|
352
|
+
},
|
|
353
|
+
enabled: {
|
|
354
|
+
type: "boolean",
|
|
355
|
+
description: "Set to false to pause the queue, true to unpause",
|
|
356
|
+
},
|
|
357
|
+
jitter: {
|
|
358
|
+
type: "number",
|
|
359
|
+
description: "Random offset in minutes (0-60)",
|
|
360
|
+
},
|
|
361
|
+
timeslots: {
|
|
362
|
+
type: "array",
|
|
363
|
+
description: "Timeslots to add or remove. To add: {day, time}. To remove: {id, _destroy: true}.",
|
|
364
|
+
items: {
|
|
365
|
+
type: "object",
|
|
366
|
+
properties: {
|
|
367
|
+
day: { type: "number", description: "Day of week (0-6) — for adding" },
|
|
368
|
+
time: { type: "string", description: "Time HH:MM — for adding" },
|
|
369
|
+
id: { type: "number", description: "Timeslot ID — for removing" },
|
|
370
|
+
_destroy: { type: "boolean", description: "Set to true to remove a timeslot by id" },
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
required: ["queue_id"],
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "queues.delete",
|
|
380
|
+
description: "Delete a posting queue. Posts in the queue will have their queue reference removed but will not be deleted.",
|
|
381
|
+
inputSchema: {
|
|
382
|
+
type: "object",
|
|
383
|
+
properties: {
|
|
384
|
+
queue_id: {
|
|
385
|
+
type: "string",
|
|
386
|
+
description: "Queue ID to delete",
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
required: ["queue_id"],
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: "queues.next_slot",
|
|
394
|
+
description: "Get the next available timeslot for a queue",
|
|
395
|
+
inputSchema: {
|
|
396
|
+
type: "object",
|
|
397
|
+
properties: {
|
|
398
|
+
queue_id: {
|
|
399
|
+
type: "string",
|
|
400
|
+
description: "Queue ID",
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
required: ["queue_id"],
|
|
404
|
+
},
|
|
405
|
+
},
|
|
220
406
|
] as const;
|
|
221
407
|
|
|
222
408
|
export async function createMCPServer(client: PostProxyClient): Promise<Server> {
|
|
@@ -265,6 +451,18 @@ export async function createMCPServer(client: PostProxyClient): Promise<Server>
|
|
|
265
451
|
return await handlePostStats(client, args as any);
|
|
266
452
|
case "profiles.placements":
|
|
267
453
|
return await handleProfilesPlacements(client, args as any);
|
|
454
|
+
case "queues.list":
|
|
455
|
+
return await handleQueuesList(client, args as any);
|
|
456
|
+
case "queues.get":
|
|
457
|
+
return await handleQueuesGet(client, args as any);
|
|
458
|
+
case "queues.create":
|
|
459
|
+
return await handleQueuesCreate(client, args as any);
|
|
460
|
+
case "queues.update":
|
|
461
|
+
return await handleQueuesUpdate(client, args as any);
|
|
462
|
+
case "queues.delete":
|
|
463
|
+
return await handleQueuesDelete(client, args as any);
|
|
464
|
+
case "queues.next_slot":
|
|
465
|
+
return await handleQueuesNextSlot(client, args as any);
|
|
268
466
|
default:
|
|
269
467
|
throw createError(ErrorCodes.API_ERROR, `Unknown tool: ${name}`);
|
|
270
468
|
}
|
package/src/tools/history.ts
CHANGED
|
@@ -22,8 +22,10 @@ export async function handleHistoryList(
|
|
|
22
22
|
// Determine overall status from post status
|
|
23
23
|
let overallStatus = "unknown";
|
|
24
24
|
|
|
25
|
-
// Handle
|
|
26
|
-
if (post.status === "
|
|
25
|
+
// Handle special statuses first
|
|
26
|
+
if (post.status === "media_processing_failed") {
|
|
27
|
+
overallStatus = "media_processing_failed";
|
|
28
|
+
} else if (post.status === "draft" || post.draft === true) {
|
|
27
29
|
overallStatus = "draft";
|
|
28
30
|
} else if (post.status === "scheduled") {
|
|
29
31
|
overallStatus = "pending";
|
|
@@ -60,6 +62,7 @@ export async function handleHistoryList(
|
|
|
60
62
|
content_preview: content.substring(0, 100) + (content.length > 100 ? "..." : ""),
|
|
61
63
|
created_at: post.created_at,
|
|
62
64
|
overall_status: overallStatus,
|
|
65
|
+
scheduled_at: post.scheduled_at || null,
|
|
63
66
|
draft: post.draft || false,
|
|
64
67
|
platforms_count: post.platforms?.length || 0,
|
|
65
68
|
};
|
package/src/tools/post.ts
CHANGED
|
@@ -19,6 +19,9 @@ export async function handlePostPublish(
|
|
|
19
19
|
require_confirmation?: boolean;
|
|
20
20
|
draft?: boolean;
|
|
21
21
|
platforms?: Record<string, Record<string, any>>;
|
|
22
|
+
thread?: Array<{ body: string; media?: string[] }>;
|
|
23
|
+
queue_id?: string;
|
|
24
|
+
queue_priority?: "high" | "medium" | "low";
|
|
22
25
|
}
|
|
23
26
|
) {
|
|
24
27
|
// Validate input
|
|
@@ -43,6 +46,7 @@ export async function handlePostPublish(
|
|
|
43
46
|
schedule_time: args.schedule,
|
|
44
47
|
draft: args.draft || false,
|
|
45
48
|
platforms: args.platforms || {},
|
|
49
|
+
thread: args.thread || [],
|
|
46
50
|
},
|
|
47
51
|
},
|
|
48
52
|
null,
|
|
@@ -78,6 +82,9 @@ export async function handlePostPublish(
|
|
|
78
82
|
idempotency_key: idempotencyKey,
|
|
79
83
|
draft: draftValue, // Explicitly pass draft value (true, false, or undefined)
|
|
80
84
|
platforms: args.platforms, // Platform-specific parameters
|
|
85
|
+
thread: args.thread, // Thread children (X and Threads only)
|
|
86
|
+
queue_id: args.queue_id,
|
|
87
|
+
queue_priority: args.queue_priority,
|
|
81
88
|
});
|
|
82
89
|
|
|
83
90
|
// Check if draft was requested but API ignored it
|
|
@@ -157,10 +164,12 @@ export async function handlePostStatus(
|
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
// Determine overall status from post status and platform statuses
|
|
160
|
-
let overallStatus: "pending" | "processing" | "complete" | "failed" | "draft" = "pending";
|
|
161
|
-
|
|
167
|
+
let overallStatus: "pending" | "processing" | "complete" | "failed" | "draft" | "media_processing_failed" = "pending";
|
|
168
|
+
|
|
162
169
|
// Handle draft status first
|
|
163
|
-
if (postDetails.status === "
|
|
170
|
+
if (postDetails.status === "media_processing_failed") {
|
|
171
|
+
overallStatus = "media_processing_failed";
|
|
172
|
+
} else if (postDetails.status === "draft" || postDetails.draft === true) {
|
|
164
173
|
overallStatus = "draft";
|
|
165
174
|
} else if (postDetails.status === "scheduled") {
|
|
166
175
|
overallStatus = "pending";
|
|
@@ -191,21 +200,27 @@ export async function handlePostStatus(
|
|
|
191
200
|
overallStatus = "pending";
|
|
192
201
|
}
|
|
193
202
|
|
|
203
|
+
const result: any = {
|
|
204
|
+
job_id: args.job_id,
|
|
205
|
+
overall_status: overallStatus,
|
|
206
|
+
draft: postDetails.draft || false,
|
|
207
|
+
status: postDetails.status,
|
|
208
|
+
platforms,
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
if (postDetails.media && postDetails.media.length > 0) {
|
|
212
|
+
result.media = postDetails.media;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (postDetails.thread && postDetails.thread.length > 0) {
|
|
216
|
+
result.thread = postDetails.thread;
|
|
217
|
+
}
|
|
218
|
+
|
|
194
219
|
return {
|
|
195
220
|
content: [
|
|
196
221
|
{
|
|
197
222
|
type: "text",
|
|
198
|
-
text: JSON.stringify(
|
|
199
|
-
{
|
|
200
|
-
job_id: args.job_id,
|
|
201
|
-
overall_status: overallStatus,
|
|
202
|
-
draft: postDetails.draft || false,
|
|
203
|
-
status: postDetails.status,
|
|
204
|
-
platforms,
|
|
205
|
-
},
|
|
206
|
-
null,
|
|
207
|
-
2
|
|
208
|
-
),
|
|
223
|
+
text: JSON.stringify(result, null, 2),
|
|
209
224
|
},
|
|
210
225
|
],
|
|
211
226
|
};
|