posterly-mcp-server 0.43.8 → 0.45.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/README.md +310 -109
- package/dist/index.js +190 -874
- package/dist/lib/alias-transport.d.ts +84 -0
- package/dist/lib/alias-transport.js +193 -0
- package/dist/lib/api-client.d.ts +97 -0
- package/dist/lib/api-client.js +81 -0
- package/dist/lib/preview-token-core.d.ts +62 -0
- package/dist/lib/preview-token-core.js +131 -0
- package/dist/lib/preview-token.d.ts +23 -0
- package/dist/lib/preview-token.js +44 -0
- package/dist/lib/tool-registry.d.ts +246 -0
- package/dist/lib/tool-registry.js +394 -0
- package/dist/lib/tool-runtime.d.ts +68 -0
- package/dist/lib/tool-runtime.js +85 -0
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/tools/audit-google-business-profile.js +1 -1
- package/dist/tools/connect-account.d.ts +4 -4
- package/dist/tools/connect-account.js +2 -2
- package/dist/tools/create-api-key.js +1 -1
- package/dist/tools/create-connect-session.d.ts +2 -2
- package/dist/tools/create-connect-session.js +2 -2
- package/dist/tools/create-post.d.ts +6 -6
- package/dist/tools/create-post.js +3 -3
- package/dist/tools/create-posts-batch.d.ts +4 -4
- package/dist/tools/create-webhook.d.ts +4 -4
- package/dist/tools/delete-post.d.ts +34 -10
- package/dist/tools/delete-post.js +52 -16
- package/dist/tools/disconnect-account.d.ts +2 -2
- package/dist/tools/generate-captions.d.ts +2 -2
- package/dist/tools/generate-image.d.ts +4 -4
- package/dist/tools/generate-image.js +2 -2
- package/dist/tools/generate-video.d.ts +6 -6
- package/dist/tools/generate-video.js +1 -1
- package/dist/tools/get-agent-signup-info.js +2 -2
- package/dist/tools/get-post.d.ts +16 -1
- package/dist/tools/get-post.js +35 -19
- package/dist/tools/list-accounts.d.ts +49 -3
- package/dist/tools/list-accounts.js +148 -33
- package/dist/tools/list-analytics.d.ts +111 -0
- package/dist/tools/list-analytics.js +393 -0
- package/dist/tools/list-brands.d.ts +38 -3
- package/dist/tools/list-brands.js +138 -20
- package/dist/tools/list-comments.d.ts +29 -9
- package/dist/tools/list-comments.js +75 -34
- package/dist/tools/list-conversations.d.ts +32 -9
- package/dist/tools/list-conversations.js +63 -27
- package/dist/tools/list-google-business-media.js +1 -1
- package/dist/tools/list-google-business-reviews.d.ts +32 -9
- package/dist/tools/list-google-business-reviews.js +77 -52
- package/dist/tools/list-jobs.d.ts +60 -0
- package/dist/tools/list-jobs.js +81 -0
- package/dist/tools/list-platforms.d.ts +62 -3
- package/dist/tools/list-platforms.js +118 -9
- package/dist/tools/list-posts.d.ts +2 -2
- package/dist/tools/list-workspace-members.d.ts +17 -0
- package/dist/tools/list-workspace-members.js +51 -0
- package/dist/tools/manage-comment.d.ts +102 -0
- package/dist/tools/manage-comment.js +125 -0
- package/dist/tools/manage-conversation.d.ts +79 -0
- package/dist/tools/manage-conversation.js +75 -0
- package/dist/tools/manage-google-business-media.d.ts +103 -0
- package/dist/tools/manage-google-business-media.js +126 -0
- package/dist/tools/manage-google-business-review.d.ts +146 -0
- package/dist/tools/manage-google-business-review.js +115 -0
- package/dist/tools/manage-oauth-client.d.ts +121 -0
- package/dist/tools/manage-oauth-client.js +94 -0
- package/dist/tools/manage-webhook.d.ts +99 -0
- package/dist/tools/manage-webhook.js +87 -0
- package/dist/tools/manage-workspace-member.d.ts +57 -0
- package/dist/tools/manage-workspace-member.js +131 -0
- package/dist/tools/reply-to-comment.d.ts +2 -2
- package/dist/tools/send-message.d.ts +2 -2
- package/dist/tools/start-signup.d.ts +2 -2
- package/dist/tools/submit-agent-feedback.d.ts +4 -4
- package/dist/tools/submit-product-feedback.d.ts +4 -4
- package/dist/tools/trigger-platform-helper.d.ts +2 -2
- package/dist/tools/update-post-release-id.d.ts +2 -2
- package/dist/tools/update-post-status.d.ts +2 -2
- package/dist/tools/update-post.d.ts +64 -13
- package/dist/tools/update-post.js +79 -26
- package/dist/tools/upload-media.d.ts +32 -9
- package/dist/tools/upload-media.js +54 -18
- package/dist/tools/validate-post.d.ts +4 -4
- package/dist/tools/whoami.d.ts +15 -2
- package/dist/tools/whoami.js +221 -25
- package/package.json +5 -3
- package/scripts/test-alias-transport.mjs +368 -0
- package/scripts/test-client-header-sanitization.mjs +78 -0
- package/scripts/test-tool-annotations.mjs +38 -17
- package/server.json +9 -2
- package/src/index.ts +227 -1411
- package/src/lib/alias-transport.ts +233 -0
- package/src/lib/api-client.ts +168 -0
- package/src/lib/preview-token-core.ts +157 -0
- package/src/lib/preview-token.ts +54 -0
- package/src/lib/tool-registry.ts +538 -0
- package/src/lib/tool-runtime.ts +117 -0
- package/src/lib/version.ts +1 -1
- package/src/tools/audit-google-business-profile.ts +1 -1
- package/src/tools/connect-account.ts +2 -2
- package/src/tools/create-api-key.ts +1 -1
- package/src/tools/create-connect-session.ts +2 -2
- package/src/tools/create-post.ts +3 -3
- package/src/tools/delete-post.ts +60 -19
- package/src/tools/generate-image.ts +2 -2
- package/src/tools/generate-video.ts +1 -1
- package/src/tools/get-agent-signup-info.ts +2 -2
- package/src/tools/get-post.ts +35 -21
- package/src/tools/list-accounts.ts +187 -39
- package/src/tools/list-analytics.ts +444 -0
- package/src/tools/list-brands.ts +162 -26
- package/src/tools/list-comments.ts +86 -43
- package/src/tools/list-conversations.ts +81 -39
- package/src/tools/list-google-business-media.ts +1 -1
- package/src/tools/list-google-business-reviews.ts +93 -64
- package/src/tools/list-jobs.ts +91 -0
- package/src/tools/list-platforms.ts +135 -11
- package/src/tools/list-workspace-members.ts +61 -0
- package/src/tools/manage-comment.ts +142 -0
- package/src/tools/manage-conversation.ts +89 -0
- package/src/tools/manage-google-business-media.ts +147 -0
- package/src/tools/manage-google-business-review.ts +139 -0
- package/src/tools/manage-oauth-client.ts +116 -0
- package/src/tools/manage-webhook.ts +103 -0
- package/src/tools/manage-workspace-member.ts +151 -0
- package/src/tools/update-post.ts +106 -39
- package/src/tools/upload-media.ts +76 -28
- package/src/tools/whoami.ts +253 -30
- package/tool-annotations.json +76 -144
- package/tool-registry.json +2085 -0
- package/src/tools/add-google-business-media.ts +0 -50
- package/src/tools/create-oauth-client.ts +0 -36
- package/src/tools/delete-comment.ts +0 -29
- package/src/tools/delete-google-business-media.ts +0 -30
- package/src/tools/delete-google-business-review-reply.ts +0 -30
- package/src/tools/delete-oauth-client.ts +0 -23
- package/src/tools/delete-post-group.ts +0 -17
- package/src/tools/delete-webhook.ts +0 -17
- package/src/tools/get-account-analytics.ts +0 -171
- package/src/tools/get-brand-profile.ts +0 -86
- package/src/tools/get-brand.ts +0 -34
- package/src/tools/get-comment.ts +0 -47
- package/src/tools/get-connect-link.ts +0 -61
- package/src/tools/get-connect-session.ts +0 -63
- package/src/tools/get-conversation.ts +0 -44
- package/src/tools/get-google-business-review-link.ts +0 -30
- package/src/tools/get-image-job.ts +0 -36
- package/src/tools/get-learned-voice.ts +0 -31
- package/src/tools/get-mcp-status.ts +0 -212
- package/src/tools/get-performance-profile.ts +0 -47
- package/src/tools/get-platform-schema.ts +0 -56
- package/src/tools/get-post-analytics.ts +0 -243
- package/src/tools/get-post-insights.ts +0 -60
- package/src/tools/get-post-missing.ts +0 -16
- package/src/tools/get-video-job.ts +0 -36
- package/src/tools/list-brand-accounts.ts +0 -36
- package/src/tools/reply-google-business-review.ts +0 -32
- package/src/tools/reply-to-comment.ts +0 -30
- package/src/tools/send-message.ts +0 -28
- package/src/tools/suggest-google-business-review-reply.ts +0 -44
- package/src/tools/sync-inbox.ts +0 -28
- package/src/tools/test-webhook.ts +0 -18
- package/src/tools/update-comment.ts +0 -31
- package/src/tools/update-oauth-client.ts +0 -38
- package/src/tools/update-post-release-id.ts +0 -25
- package/src/tools/update-post-status.ts +0 -31
- package/src/tools/update-webhook.ts +0 -36
- package/src/tools/upload-media-from-url.ts +0 -33
|
@@ -1,16 +1,62 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { PosterlyClient } from '../lib/api-client.js';
|
|
3
|
+
import { type ToolContext } from '../lib/tool-runtime.js';
|
|
4
|
+
type ListAccountsInput = {
|
|
5
|
+
view?: 'accounts' | 'learned_voice' | 'performance_profile' | 'connect_session';
|
|
6
|
+
workspace_id?: string;
|
|
7
|
+
account_id?: string | number;
|
|
8
|
+
session_id?: string;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
};
|
|
3
11
|
export declare const listAccountsTool: {
|
|
4
12
|
name: string;
|
|
5
13
|
description: string;
|
|
6
14
|
inputSchema: z.ZodObject<{
|
|
15
|
+
view: z.ZodOptional<z.ZodEnum<["accounts", "learned_voice", "performance_profile", "connect_session"]>>;
|
|
7
16
|
workspace_id: z.ZodOptional<z.ZodString>;
|
|
17
|
+
account_id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
18
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
19
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
8
20
|
}, "strip", z.ZodTypeAny, {
|
|
9
21
|
workspace_id?: string | undefined;
|
|
22
|
+
account_id?: string | number | undefined;
|
|
23
|
+
view?: "accounts" | "learned_voice" | "performance_profile" | "connect_session" | undefined;
|
|
24
|
+
session_id?: string | undefined;
|
|
25
|
+
debug?: boolean | undefined;
|
|
10
26
|
}, {
|
|
11
27
|
workspace_id?: string | undefined;
|
|
28
|
+
account_id?: string | number | undefined;
|
|
29
|
+
view?: "accounts" | "learned_voice" | "performance_profile" | "connect_session" | undefined;
|
|
30
|
+
session_id?: string | undefined;
|
|
31
|
+
debug?: boolean | undefined;
|
|
12
32
|
}>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
/** The old tools' exact input schemas, for alias calls (see alias-transport.ts). */
|
|
34
|
+
legacySchemas: {
|
|
35
|
+
get_learned_voice: z.ZodObject<{
|
|
36
|
+
account_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
account_id: string | number;
|
|
39
|
+
}, {
|
|
40
|
+
account_id: string | number;
|
|
41
|
+
}>;
|
|
42
|
+
get_performance_profile: z.ZodObject<{
|
|
43
|
+
account_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
account_id: string | number;
|
|
46
|
+
}, {
|
|
47
|
+
account_id: string | number;
|
|
48
|
+
}>;
|
|
49
|
+
get_connect_session: z.ZodObject<{
|
|
50
|
+
session_id: z.ZodString;
|
|
51
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
session_id: string;
|
|
54
|
+
debug?: boolean | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
session_id: string;
|
|
57
|
+
debug?: boolean | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
execute(client: PosterlyClient, input: ListAccountsInput, ctx: ToolContext): Promise<string>;
|
|
16
61
|
};
|
|
62
|
+
export {};
|
|
@@ -1,44 +1,159 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { code, mdEmpty, mdTable, mdTitle } from '../lib/format.js';
|
|
2
|
+
import { DASHBOARD_CONNECT_URL, code, formatConnectedAccounts, formatDateTime, formatLocalDateTime, formatPercent, mdBullets, mdEmpty, mdKeyValue, mdLearnedVoice, mdQuote, mdSection, mdTable, mdTitle, } from '../lib/format.js';
|
|
3
|
+
import { validateArgs } from '../lib/tool-runtime.js';
|
|
3
4
|
export const listAccountsTool = {
|
|
4
5
|
name: 'list_accounts',
|
|
5
|
-
description:
|
|
6
|
+
description: "Connected social accounts and what posterly has learned about them. view=accounts (default): connected accounts, optionally one workspace_id or one account_id; Instagram rows identify direct-login versus Meta-linked connections and whether native media tags/collaborators are available, so check this before Instagram user_tags or collaborators. view=learned_voice (account_id): the voice learned from the account's real published captions (summary, traits, style guidelines, habits); read-only, never overwrites the saved brand profile. view=performance_profile (account_id): 90-day coaching stats, engagement-rate trend, and summary (Pro plan or higher; platforms without per-post analytics never get one). view=connect_session (session_id): poll a session from create_connect_session and keep the user updated in plain language; stop when status is connected, failed, cancelled, or expired.",
|
|
6
7
|
inputSchema: z.object({
|
|
8
|
+
view: z
|
|
9
|
+
.enum(['accounts', 'learned_voice', 'performance_profile', 'connect_session'])
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('accounts (default), learned_voice, performance_profile, or connect_session.'),
|
|
7
12
|
workspace_id: z
|
|
8
13
|
.string()
|
|
9
14
|
.optional()
|
|
10
|
-
.describe('
|
|
15
|
+
.describe('view=accounts: filter to accounts in a specific workspace (get IDs via whoami).'),
|
|
16
|
+
account_id: z
|
|
17
|
+
.union([z.string(), z.number()])
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Social account ID from list_accounts. Required for learned_voice and performance_profile; with view=accounts it returns just that account.'),
|
|
20
|
+
session_id: z.string().optional().describe('view=connect_session: connect session ID returned by create_connect_session.'),
|
|
21
|
+
debug: z
|
|
22
|
+
.boolean()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('view=connect_session: when true, include the raw connect session JSON for debugging. Keep false for normal user-facing agent flows.'),
|
|
11
25
|
}),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
/** The old tools' exact input schemas, for alias calls (see alias-transport.ts). */
|
|
27
|
+
legacySchemas: {
|
|
28
|
+
get_learned_voice: z.object({ account_id: z.union([z.string(), z.number()]) }),
|
|
29
|
+
get_performance_profile: z.object({ account_id: z.union([z.string(), z.number()]) }),
|
|
30
|
+
get_connect_session: z.object({ session_id: z.string(), debug: z.boolean().optional() }),
|
|
31
|
+
},
|
|
32
|
+
async execute(client, input, ctx) {
|
|
33
|
+
const { mode, args } = validateArgs(ctx, 'list_accounts', input);
|
|
34
|
+
if (mode === 'learned_voice')
|
|
35
|
+
return learnedVoice(client, args);
|
|
36
|
+
if (mode === 'performance_profile')
|
|
37
|
+
return performanceProfile(client, args);
|
|
38
|
+
if (mode === 'connect_session') {
|
|
39
|
+
const result = await client.getConnectSession(args.session_id);
|
|
40
|
+
return formatConnectSession(result.connect_session, Boolean(args.debug));
|
|
18
41
|
}
|
|
19
|
-
|
|
20
|
-
return [
|
|
21
|
-
mdTitle(`Connected accounts (${accounts.length})`),
|
|
22
|
-
mdTable(hasInstagram
|
|
23
|
-
? ['Platform', 'Account', 'Account ID', 'Workspace', 'Connection', 'Native tags', 'Collaborators']
|
|
24
|
-
: ['Platform', 'Account', 'Account ID', 'Workspace'], accounts.map((account) => [
|
|
25
|
-
account.platform,
|
|
26
|
-
`@${account.username}`,
|
|
27
|
-
code(account.id),
|
|
28
|
-
account.workspace_id ? code(account.workspace_id) : 'default',
|
|
29
|
-
...(hasInstagram
|
|
30
|
-
? account.platform === 'instagram'
|
|
31
|
-
? [
|
|
32
|
-
account.connection_mode === 'meta' ? 'Meta-linked' : account.connection_mode === 'instagram_direct' ? 'Direct login' : 'unknown',
|
|
33
|
-
account.instagram_tagging?.media_user_tags?.supported ? 'yes' : 'no',
|
|
34
|
-
account.instagram_tagging?.collaborators?.supported ? 'yes' : 'no',
|
|
35
|
-
]
|
|
36
|
-
: ['—', '—', '—']
|
|
37
|
-
: []),
|
|
38
|
-
])),
|
|
39
|
-
hasInstagram
|
|
40
|
-
? '_Instagram caption @mentions use @username in caption text. Native media tags work with eligible direct or Meta-linked accounts; collaborator invitations require an eligible Meta-linked account._'
|
|
41
|
-
: '',
|
|
42
|
-
].filter(Boolean).join('\n\n');
|
|
42
|
+
return accountsList(client, args);
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
|
+
async function accountsList(client, input) {
|
|
46
|
+
const listed = await client.listAccounts({ workspace_id: input.workspace_id });
|
|
47
|
+
// There is no GET /accounts/:id, so account_id filters the list here.
|
|
48
|
+
const accounts = input.account_id !== undefined
|
|
49
|
+
? listed.filter((account) => String(account.id) === String(input.account_id))
|
|
50
|
+
: listed;
|
|
51
|
+
if (input.account_id !== undefined && accounts.length === 0) {
|
|
52
|
+
return mdEmpty('connected account', `No connected account has the ID ${String(input.account_id)}.`);
|
|
53
|
+
}
|
|
54
|
+
if (accounts.length === 0) {
|
|
55
|
+
return input.workspace_id
|
|
56
|
+
? mdEmpty('connected accounts', 'This workspace does not have any social accounts connected yet.')
|
|
57
|
+
: mdEmpty('connected accounts', 'posterly does not see any connected social accounts yet.', 'Connect accounts in the posterly dashboard, then run this again.');
|
|
58
|
+
}
|
|
59
|
+
const hasInstagram = accounts.some((account) => account.platform === 'instagram');
|
|
60
|
+
return [
|
|
61
|
+
mdTitle(`Connected accounts (${accounts.length})`),
|
|
62
|
+
mdTable(hasInstagram
|
|
63
|
+
? ['Platform', 'Account', 'Account ID', 'Workspace', 'Connection', 'Native tags', 'Collaborators']
|
|
64
|
+
: ['Platform', 'Account', 'Account ID', 'Workspace'], accounts.map((account) => [
|
|
65
|
+
account.platform,
|
|
66
|
+
`@${account.username}`,
|
|
67
|
+
code(account.id),
|
|
68
|
+
account.workspace_id ? code(account.workspace_id) : 'default',
|
|
69
|
+
...(hasInstagram
|
|
70
|
+
? account.platform === 'instagram'
|
|
71
|
+
? [
|
|
72
|
+
account.connection_mode === 'meta' ? 'Meta-linked' : account.connection_mode === 'instagram_direct' ? 'Direct login' : 'unknown',
|
|
73
|
+
account.instagram_tagging?.media_user_tags?.supported ? 'yes' : 'no',
|
|
74
|
+
account.instagram_tagging?.collaborators?.supported ? 'yes' : 'no',
|
|
75
|
+
]
|
|
76
|
+
: ['n/a', 'n/a', 'n/a']
|
|
77
|
+
: []),
|
|
78
|
+
])),
|
|
79
|
+
hasInstagram
|
|
80
|
+
? '_Instagram caption @mentions use @username in caption text. Native media tags work with eligible direct or Meta-linked accounts; collaborator invitations require an eligible Meta-linked account._'
|
|
81
|
+
: '',
|
|
82
|
+
].filter(Boolean).join('\n\n');
|
|
83
|
+
}
|
|
84
|
+
async function learnedVoice(client, input) {
|
|
85
|
+
const { learned_voice } = await client.getAccountLearnedVoice(input.account_id);
|
|
86
|
+
const body = mdLearnedVoice(learned_voice);
|
|
87
|
+
if (!body) {
|
|
88
|
+
return [
|
|
89
|
+
mdTitle('No learned voice yet'),
|
|
90
|
+
'posterly has not learned a voice for this account yet. It learns automatically once the account has enough published posts (the captions are analyzed; the saved brand profile is never overwritten).',
|
|
91
|
+
].join('\n\n');
|
|
92
|
+
}
|
|
93
|
+
return [mdTitle('Learned voice (from published captions)'), body].join('\n\n');
|
|
94
|
+
}
|
|
95
|
+
async function performanceProfile(client, input) {
|
|
96
|
+
const { performance_profile, reason } = await client.getAccountPerformanceProfile(input.account_id);
|
|
97
|
+
if (!performance_profile) {
|
|
98
|
+
const detail = reason === 'platform_not_measurable'
|
|
99
|
+
? 'This platform does not produce per-post analytics, so posterly cannot build a performance profile for it.'
|
|
100
|
+
: reason === 'feature_not_available'
|
|
101
|
+
? 'Performance profiles require a Pro plan or higher.'
|
|
102
|
+
: 'posterly has not built a performance profile for this account yet. It needs about 90 days of tracked posts to learn from.';
|
|
103
|
+
return mdEmpty('performance profile yet', detail);
|
|
104
|
+
}
|
|
105
|
+
const label = performance_profile.username
|
|
106
|
+
? `@${performance_profile.username}${performance_profile.platform ? ` (${performance_profile.platform})` : ''}`
|
|
107
|
+
: `account ${performance_profile.social_account_id}`;
|
|
108
|
+
const rate = performance_profile.engagement_rate_avg != null
|
|
109
|
+
? formatPercent(performance_profile.engagement_rate_avg * 100)
|
|
110
|
+
: 'n/a';
|
|
111
|
+
return [
|
|
112
|
+
mdTitle('Account performance profile', `${label} · last ${performance_profile.window_days ?? 90} days`),
|
|
113
|
+
performance_profile.narrative_summary ? mdSection('Summary', mdQuote(performance_profile.narrative_summary)) : '',
|
|
114
|
+
performance_profile.bullets.length ? mdSection('What is working', mdBullets(performance_profile.bullets)) : '',
|
|
115
|
+
mdSection('Stats', mdKeyValue([
|
|
116
|
+
['Posts sampled', performance_profile.sample_size],
|
|
117
|
+
['Avg engagement rate', rate],
|
|
118
|
+
['Engagement trend', performance_profile.engagement_rate_trend],
|
|
119
|
+
['Derived at', formatDateTime(performance_profile.derived_at)],
|
|
120
|
+
])),
|
|
121
|
+
].filter(Boolean).join('\n\n');
|
|
122
|
+
}
|
|
123
|
+
function formatConnectSession(session, includeRaw) {
|
|
124
|
+
const connected = session.connected_count ?? session.connected_accounts?.length ?? 0;
|
|
125
|
+
return [
|
|
126
|
+
`posterly connect session: ${session.id}`,
|
|
127
|
+
`Platform: ${session.platform}`,
|
|
128
|
+
`Status: ${session.status}`,
|
|
129
|
+
`Message: ${session.status_message}`,
|
|
130
|
+
`Connected accounts: ${connected}`,
|
|
131
|
+
`Accounts: ${formatConnectedAccounts(session.connected_accounts)}`,
|
|
132
|
+
session.error_message ? `Error: ${session.error_message}` : '',
|
|
133
|
+
`Expires: ${formatLocalDateTime(session.expires_at)}`,
|
|
134
|
+
`Dashboard connect page: ${DASHBOARD_CONNECT_URL}`,
|
|
135
|
+
'',
|
|
136
|
+
guidanceForStatus(session),
|
|
137
|
+
includeRaw ? `\nRaw connect session:\n${JSON.stringify(session, null, 2)}` : '',
|
|
138
|
+
].filter(Boolean).join('\n');
|
|
139
|
+
}
|
|
140
|
+
function guidanceForStatus(session) {
|
|
141
|
+
switch (session.status) {
|
|
142
|
+
case 'created':
|
|
143
|
+
case 'opened':
|
|
144
|
+
case 'awaiting_provider':
|
|
145
|
+
return 'Next step for the AI agent: tell the user posterly is waiting for browser approval, then keep polling this session. Do not ask for social passwords or OAuth codes.';
|
|
146
|
+
case 'awaiting_credentials':
|
|
147
|
+
return 'Next step for the AI agent: tell the user posterly needs them to finish the browser credential step, then keep polling. Do not ask the user to paste credentials into chat.';
|
|
148
|
+
case 'connected':
|
|
149
|
+
return `Next step for the AI agent: tell the user ${formatConnectedAccounts(session.connected_accounts)} is connected, then ask what they want to schedule first or offer to create a test post.`;
|
|
150
|
+
case 'failed':
|
|
151
|
+
return 'Next step for the AI agent: tell the user the connection failed, share the error if present, and offer to create a fresh connect session.';
|
|
152
|
+
case 'cancelled':
|
|
153
|
+
return 'Next step for the AI agent: tell the user the connection was cancelled and offer to create a fresh connect session when they are ready.';
|
|
154
|
+
case 'expired':
|
|
155
|
+
return 'Next step for the AI agent: tell the user the connection link expired and create a fresh connect session if they still want to connect this account.';
|
|
156
|
+
default:
|
|
157
|
+
return 'Next step for the AI agent: explain the current connection status in plain language and keep polling unless the session is terminal.';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PosterlyClient } from '../lib/api-client.js';
|
|
3
|
+
import { type ToolContext } from '../lib/tool-runtime.js';
|
|
4
|
+
declare const presentationSchema: z.ZodOptional<z.ZodEnum<["compact", "table", "json"]>>;
|
|
5
|
+
type AnalyticsPresentation = z.infer<typeof presentationSchema>;
|
|
6
|
+
type Checkpoint = '1h' | '6h' | '24h' | '72h' | '7d';
|
|
7
|
+
type ListAnalyticsInput = {
|
|
8
|
+
view: 'accounts' | 'posts' | 'insights';
|
|
9
|
+
account_id?: number;
|
|
10
|
+
from?: string;
|
|
11
|
+
to?: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
offset?: number;
|
|
14
|
+
post_id?: number;
|
|
15
|
+
checkpoint?: Checkpoint;
|
|
16
|
+
presentation?: AnalyticsPresentation;
|
|
17
|
+
};
|
|
18
|
+
export declare const listAnalyticsTool: {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
inputSchema: z.ZodObject<{
|
|
22
|
+
view: z.ZodEnum<["accounts", "posts", "insights"]>;
|
|
23
|
+
account_id: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
24
|
+
from: z.ZodOptional<z.ZodString>;
|
|
25
|
+
to: z.ZodOptional<z.ZodString>;
|
|
26
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
post_id: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
checkpoint: z.ZodOptional<z.ZodEnum<["1h", "6h", "24h", "72h", "7d"]>>;
|
|
30
|
+
presentation: z.ZodOptional<z.ZodEnum<["compact", "table", "json"]>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
view: "accounts" | "posts" | "insights";
|
|
33
|
+
account_id?: string | number | undefined;
|
|
34
|
+
post_id?: number | undefined;
|
|
35
|
+
checkpoint?: "1h" | "6h" | "24h" | "72h" | "7d" | undefined;
|
|
36
|
+
limit?: number | undefined;
|
|
37
|
+
offset?: number | undefined;
|
|
38
|
+
from?: string | undefined;
|
|
39
|
+
to?: string | undefined;
|
|
40
|
+
presentation?: "compact" | "table" | "json" | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
view: "accounts" | "posts" | "insights";
|
|
43
|
+
account_id?: string | number | undefined;
|
|
44
|
+
post_id?: number | undefined;
|
|
45
|
+
checkpoint?: "1h" | "6h" | "24h" | "72h" | "7d" | undefined;
|
|
46
|
+
limit?: number | undefined;
|
|
47
|
+
offset?: number | undefined;
|
|
48
|
+
from?: string | undefined;
|
|
49
|
+
to?: string | undefined;
|
|
50
|
+
presentation?: "compact" | "table" | "json" | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
/** The old tools' exact input schemas, for alias calls (see alias-transport.ts). */
|
|
53
|
+
legacySchemas: {
|
|
54
|
+
get_account_analytics: z.ZodObject<{
|
|
55
|
+
account_id: z.ZodNumber;
|
|
56
|
+
from: z.ZodOptional<z.ZodString>;
|
|
57
|
+
to: z.ZodOptional<z.ZodString>;
|
|
58
|
+
presentation: z.ZodOptional<z.ZodEnum<["compact", "table", "json"]>>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
account_id: number;
|
|
61
|
+
from?: string | undefined;
|
|
62
|
+
to?: string | undefined;
|
|
63
|
+
presentation?: "compact" | "table" | "json" | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
account_id: number;
|
|
66
|
+
from?: string | undefined;
|
|
67
|
+
to?: string | undefined;
|
|
68
|
+
presentation?: "compact" | "table" | "json" | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
get_post_analytics: z.ZodObject<{
|
|
71
|
+
account_id: z.ZodNumber;
|
|
72
|
+
from: z.ZodOptional<z.ZodString>;
|
|
73
|
+
to: z.ZodOptional<z.ZodString>;
|
|
74
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
presentation: z.ZodOptional<z.ZodEnum<["compact", "table", "json"]>>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
account_id: number;
|
|
79
|
+
limit?: number | undefined;
|
|
80
|
+
offset?: number | undefined;
|
|
81
|
+
from?: string | undefined;
|
|
82
|
+
to?: string | undefined;
|
|
83
|
+
presentation?: "compact" | "table" | "json" | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
account_id: number;
|
|
86
|
+
limit?: number | undefined;
|
|
87
|
+
offset?: number | undefined;
|
|
88
|
+
from?: string | undefined;
|
|
89
|
+
to?: string | undefined;
|
|
90
|
+
presentation?: "compact" | "table" | "json" | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
get_post_insights: z.ZodObject<{
|
|
93
|
+
account_id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
94
|
+
post_id: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
checkpoint: z.ZodOptional<z.ZodEnum<["1h", "6h", "24h", "72h", "7d"]>>;
|
|
96
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
account_id?: string | number | undefined;
|
|
99
|
+
post_id?: number | undefined;
|
|
100
|
+
checkpoint?: "1h" | "6h" | "24h" | "72h" | "7d" | undefined;
|
|
101
|
+
limit?: number | undefined;
|
|
102
|
+
}, {
|
|
103
|
+
account_id?: string | number | undefined;
|
|
104
|
+
post_id?: number | undefined;
|
|
105
|
+
checkpoint?: "1h" | "6h" | "24h" | "72h" | "7d" | undefined;
|
|
106
|
+
limit?: number | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
};
|
|
109
|
+
execute(client: PosterlyClient, input: ListAnalyticsInput, ctx: ToolContext): Promise<string>;
|
|
110
|
+
};
|
|
111
|
+
export {};
|