posterly-mcp-server 0.54.6 → 0.55.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/README.md +45 -4
- package/dist/generated/platform-manifest.d.ts +4 -4
- package/dist/generated/platform-manifest.js +9 -4
- package/dist/index.js +15 -2
- package/dist/lib/alias-transport.js +4 -0
- package/dist/lib/api-client.d.ts +148 -0
- package/dist/lib/api-client.js +84 -0
- package/dist/lib/claude-directory-profile.js +3 -1
- package/dist/lib/format.d.ts +44 -0
- package/dist/lib/format.js +125 -5
- package/dist/lib/gbp-location-preview.d.ts +21 -0
- package/dist/lib/gbp-location-preview.js +27 -0
- package/dist/lib/google-business-review-name.d.ts +4 -0
- package/dist/lib/google-business-review-name.js +11 -0
- package/dist/lib/id-schema.d.ts +14 -0
- package/dist/lib/id-schema.js +82 -0
- package/dist/lib/id-text.d.ts +26 -0
- package/dist/lib/id-text.js +63 -0
- package/dist/lib/reply-window.d.ts +5 -0
- package/dist/lib/reply-window.js +14 -0
- package/dist/lib/service-area-text.d.ts +27 -0
- package/dist/lib/service-area-text.js +41 -0
- package/dist/lib/suggestion-accept-note.d.ts +10 -0
- package/dist/lib/suggestion-accept-note.js +17 -0
- package/dist/lib/tool-registry.js +19 -2
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/tools/audit-google-business-profile.js +7 -3
- package/dist/tools/connect-account.d.ts +2 -2
- package/dist/tools/create-connect-session.d.ts +2 -2
- package/dist/tools/create-post.d.ts +6 -6
- package/dist/tools/create-posts-batch.d.ts +4 -4
- package/dist/tools/create-webhook.d.ts +3 -3
- package/dist/tools/delete-post.d.ts +4 -4
- package/dist/tools/dismiss-suggestion.d.ts +7 -0
- package/dist/tools/dismiss-suggestion.js +21 -2
- package/dist/tools/find-slot.js +7 -4
- package/dist/tools/get-post.js +56 -5
- package/dist/tools/list-accounts.d.ts +4 -0
- package/dist/tools/list-accounts.js +25 -6
- package/dist/tools/list-analytics.d.ts +4 -0
- package/dist/tools/list-analytics.js +29 -7
- package/dist/tools/list-comments.js +13 -3
- package/dist/tools/list-conversations.d.ts +4 -4
- package/dist/tools/list-conversations.js +10 -5
- package/dist/tools/list-google-business-locations.d.ts +27 -0
- package/dist/tools/list-google-business-locations.js +35 -0
- package/dist/tools/list-google-business-media.d.ts +8 -0
- package/dist/tools/list-google-business-media.js +19 -5
- package/dist/tools/list-google-business-reviews.js +3 -2
- package/dist/tools/list-google-business-service-areas.d.ts +37 -0
- package/dist/tools/list-google-business-service-areas.js +33 -0
- package/dist/tools/list-media.js +3 -2
- package/dist/tools/list-platforms.d.ts +10 -10
- package/dist/tools/list-post-suggestions.js +5 -4
- package/dist/tools/list-posts.d.ts +8 -2
- package/dist/tools/list-posts.js +12 -2
- package/dist/tools/list-webhooks.d.ts +18 -1
- package/dist/tools/list-webhooks.js +22 -3
- package/dist/tools/list-workspace-members.js +3 -1
- package/dist/tools/manage-brands.d.ts +47 -0
- package/dist/tools/manage-brands.js +89 -0
- package/dist/tools/manage-comment.js +5 -1
- package/dist/tools/manage-google-business-location.d.ts +123 -0
- package/dist/tools/manage-google-business-location.js +97 -0
- package/dist/tools/manage-google-business-media.js +2 -0
- package/dist/tools/manage-google-business-review.js +29 -3
- package/dist/tools/manage-google-business-service-area.d.ts +74 -0
- package/dist/tools/manage-google-business-service-area.js +79 -0
- package/dist/tools/manage-webhook.d.ts +6 -6
- package/dist/tools/manage-x-posting-addon.d.ts +47 -0
- package/dist/tools/manage-x-posting-addon.js +92 -0
- package/dist/tools/trigger-platform-helper.d.ts +5 -5
- package/dist/tools/trigger-platform-helper.js +4 -1
- package/dist/tools/update-post.d.ts +14 -6
- package/dist/tools/update-post.js +23 -2
- package/dist/tools/upload-media.d.ts +12 -0
- package/dist/tools/upload-media.js +39 -3
- package/dist/tools/validate-post.d.ts +4 -4
- package/dist/tools/webhook-events.d.ts +2 -2
- package/dist/tools/webhook-events.js +2 -0
- package/dist/tools/whoami.d.ts +4 -0
- package/dist/tools/whoami.js +14 -6
- package/package.json +1 -1
- package/server.json +2 -2
- package/tool-annotations.json +21 -2
- package/tool-registry.json +239 -8
package/dist/tools/get-post.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { dashboardUrlForPost, formatIsoTimestamp, formatLocalDateTime, formatPostCreator } from '../lib/format.js';
|
|
2
|
+
import { dashboardUrlForPost, formatIsoTimestamp, formatLocalDateTime, formatPostCreator, groupReleaseIds, isStructuredMissingReport, platformPostIdText, platformText, postFailureText } from '../lib/format.js';
|
|
3
3
|
import { validateArgs } from '../lib/tool-runtime.js';
|
|
4
4
|
export const getPostTool = {
|
|
5
5
|
name: 'get_post',
|
|
6
|
-
description: 'One post by ID. view=post (default): caption, status, scheduled time, when it was created and by whom (account and channel, such as dashboard, API, or MCP), media, and
|
|
6
|
+
description: 'One post by ID. view=post (default): caption, status, platform, account, scheduled time, when it was created and by whom (account and channel, such as dashboard, API, or MCP), media, a link back to the post in posterly, and the failure reason when a publish failed. view=missing: each missing field (content, media, account, platform settings, or metadata) and how to fix it before the post can publish.',
|
|
7
7
|
inputSchema: z.object({
|
|
8
8
|
post_id: z.number().describe('The post ID to look up'),
|
|
9
9
|
view: z.enum(['post', 'missing']).optional().describe('post (default) or missing.'),
|
|
@@ -22,13 +22,30 @@ export const getPostTool = {
|
|
|
22
22
|
async function post(client, input) {
|
|
23
23
|
const result = await client.getPost(input.post_id);
|
|
24
24
|
const p = result.post;
|
|
25
|
+
const accountId = p.social_account_id ?? p.account_id;
|
|
26
|
+
const failure = postFailureText(p);
|
|
27
|
+
const platformPostId = platformPostIdText(p);
|
|
28
|
+
const groups = groupReleaseIds(p);
|
|
25
29
|
const lines = [
|
|
26
30
|
`Post #${p.id}`,
|
|
27
31
|
`• Status: ${p.status}`,
|
|
28
|
-
`• Caption: ${p.content || '(empty)'}`,
|
|
29
|
-
`• Type: ${p.post_type || 'unknown'}`,
|
|
30
|
-
`• Scheduled: ${formatLocalDateTime(p.scheduled_at)}`,
|
|
31
32
|
];
|
|
33
|
+
const platform = platformText(p.platform);
|
|
34
|
+
if (platform)
|
|
35
|
+
lines.push(`• Platform: ${platform}`);
|
|
36
|
+
if (accountId != null && accountId !== '')
|
|
37
|
+
lines.push(`• Account ID: ${accountId}`);
|
|
38
|
+
if (p.workspace_id)
|
|
39
|
+
lines.push(`• Workspace: ${p.workspace_id}`);
|
|
40
|
+
lines.push(`• Caption: ${p.content || '(empty)'}`);
|
|
41
|
+
lines.push(`• Type: ${p.post_type || 'unknown'}`);
|
|
42
|
+
lines.push(`• Scheduled: ${formatLocalDateTime(p.scheduled_at)}`);
|
|
43
|
+
if (failure)
|
|
44
|
+
lines.push(`• Failure: ${failure}`);
|
|
45
|
+
if (platformPostId)
|
|
46
|
+
lines.push(`• Platform post ID: ${platformPostId}`);
|
|
47
|
+
if (groups.length)
|
|
48
|
+
lines.push(`• Group: ${groups.join(', ')}`);
|
|
32
49
|
if ('created_at' in p)
|
|
33
50
|
lines.push(`• Created: ${formatIsoTimestamp(p.created_at)}`);
|
|
34
51
|
if ('created_by' in p)
|
|
@@ -46,5 +63,39 @@ async function post(client, input) {
|
|
|
46
63
|
}
|
|
47
64
|
async function postMissing(client, input) {
|
|
48
65
|
const result = await client.getPostMissing(input.post_id);
|
|
66
|
+
if (isStructuredMissingReport(result))
|
|
67
|
+
return formatMissingReport(result);
|
|
49
68
|
return JSON.stringify(result, null, 2);
|
|
50
69
|
}
|
|
70
|
+
function formatMissingReport(data) {
|
|
71
|
+
const post = data.post && typeof data.post === 'object' ? data.post : null;
|
|
72
|
+
const missing = Array.isArray(data.missing) ? data.missing : [];
|
|
73
|
+
const items = missing.map((item) => {
|
|
74
|
+
if (item && typeof item === 'object') {
|
|
75
|
+
const field = item.field ? String(item.field) : 'item';
|
|
76
|
+
const message = item.message ? String(item.message) : (item.code ? String(item.code) : 'Missing');
|
|
77
|
+
return `${field}: ${message}`;
|
|
78
|
+
}
|
|
79
|
+
return String(item);
|
|
80
|
+
});
|
|
81
|
+
const lines = [
|
|
82
|
+
data.ready ? 'Post is ready to publish' : 'Post is not ready to publish',
|
|
83
|
+
];
|
|
84
|
+
if (post?.id != null)
|
|
85
|
+
lines.push(`Post #${post.id}`);
|
|
86
|
+
const platform = post ? platformText(post.platform) : undefined;
|
|
87
|
+
if (platform)
|
|
88
|
+
lines.push(`• Platform: ${platform}`);
|
|
89
|
+
const accountId = post ? (post.account_id ?? post.social_account_id) : undefined;
|
|
90
|
+
if (accountId != null && accountId !== '')
|
|
91
|
+
lines.push(`• Account ID: ${accountId}`);
|
|
92
|
+
if (post?.status)
|
|
93
|
+
lines.push(`• Status: ${post.status}`);
|
|
94
|
+
if (post?.post_type)
|
|
95
|
+
lines.push(`• Type: ${post.post_type}`);
|
|
96
|
+
lines.push(items.length ? `Missing:\n${items.map((item) => `• ${item}`).join('\n')}` : 'Nothing required is missing.');
|
|
97
|
+
if (Array.isArray(data.next_actions) && data.next_actions.length) {
|
|
98
|
+
lines.push(`How to fix:\n${data.next_actions.map((action) => `• ${String(action)}`).join('\n')}`);
|
|
99
|
+
}
|
|
100
|
+
return lines.join('\n');
|
|
101
|
+
}
|
|
@@ -5,6 +5,7 @@ type ListAccountsInput = {
|
|
|
5
5
|
view?: 'accounts' | 'learned_voice' | 'performance_profile' | 'connect_session';
|
|
6
6
|
workspace_id?: string;
|
|
7
7
|
account_id?: string | number;
|
|
8
|
+
connection?: 'ok' | 'needs_reconnect';
|
|
8
9
|
session_id?: string;
|
|
9
10
|
debug?: boolean;
|
|
10
11
|
};
|
|
@@ -15,17 +16,20 @@ export declare const listAccountsTool: {
|
|
|
15
16
|
view: z.ZodOptional<z.ZodEnum<["accounts", "learned_voice", "performance_profile", "connect_session"]>>;
|
|
16
17
|
workspace_id: z.ZodOptional<z.ZodString>;
|
|
17
18
|
account_id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
19
|
+
connection: z.ZodOptional<z.ZodEnum<["ok", "needs_reconnect"]>>;
|
|
18
20
|
session_id: z.ZodOptional<z.ZodString>;
|
|
19
21
|
debug: z.ZodOptional<z.ZodBoolean>;
|
|
20
22
|
}, "strip", z.ZodTypeAny, {
|
|
21
23
|
account_id?: string | number | undefined;
|
|
22
24
|
workspace_id?: string | undefined;
|
|
25
|
+
connection?: "ok" | "needs_reconnect" | undefined;
|
|
23
26
|
view?: "accounts" | "learned_voice" | "performance_profile" | "connect_session" | undefined;
|
|
24
27
|
session_id?: string | undefined;
|
|
25
28
|
debug?: boolean | undefined;
|
|
26
29
|
}, {
|
|
27
30
|
account_id?: string | number | undefined;
|
|
28
31
|
workspace_id?: string | undefined;
|
|
32
|
+
connection?: "ok" | "needs_reconnect" | undefined;
|
|
29
33
|
view?: "accounts" | "learned_voice" | "performance_profile" | "connect_session" | undefined;
|
|
30
34
|
session_id?: string | undefined;
|
|
31
35
|
debug?: boolean | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { DASHBOARD_CONNECT_URL, code, formatConnectedAccounts, formatDateTime, formatLocalDateTime, formatPercent, mdBullets, mdEmpty, mdKeyValue, mdLearnedVoice, mdQuote, mdSection, mdTable, mdTitle, } from '../lib/format.js';
|
|
2
|
+
import { DASHBOARD_CONNECT_URL, code, connectionHealthLabel, formatConnectedAccounts, formatDateTime, formatLocalDateTime, formatPercent, mdBullets, mdEmpty, mdKeyValue, mdLearnedVoice, mdQuote, mdSection, mdTable, mdTitle, } from '../lib/format.js';
|
|
3
3
|
import { validateArgs } from '../lib/tool-runtime.js';
|
|
4
4
|
export const listAccountsTool = {
|
|
5
5
|
name: 'list_accounts',
|
|
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
|
|
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. Each row has connection_status ok or needs_reconnect (reason and date, never a token). Pass connection needs_reconnect to list only accounts that need a reconnect. 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.",
|
|
7
7
|
inputSchema: z.object({
|
|
8
8
|
view: z
|
|
9
9
|
.enum(['accounts', 'learned_voice', 'performance_profile', 'connect_session'])
|
|
@@ -17,6 +17,10 @@ export const listAccountsTool = {
|
|
|
17
17
|
.union([z.string(), z.number()])
|
|
18
18
|
.optional()
|
|
19
19
|
.describe('Social account ID from list_accounts. Required for learned_voice and performance_profile; with view=accounts it returns just that account.'),
|
|
20
|
+
connection: z
|
|
21
|
+
.enum(['ok', 'needs_reconnect'])
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('view=accounts: ok, or needs_reconnect to list only accounts that need a reconnect.'),
|
|
20
24
|
session_id: z.string().optional().describe('view=connect_session: connect session ID returned by create_connect_session.'),
|
|
21
25
|
debug: z
|
|
22
26
|
.boolean()
|
|
@@ -43,7 +47,7 @@ export const listAccountsTool = {
|
|
|
43
47
|
},
|
|
44
48
|
};
|
|
45
49
|
async function accountsList(client, input) {
|
|
46
|
-
const listed = await client.listAccounts({ workspace_id: input.workspace_id });
|
|
50
|
+
const listed = await client.listAccounts({ workspace_id: input.workspace_id, connection: input.connection });
|
|
47
51
|
// There is no GET /accounts/:id, so account_id filters the list here.
|
|
48
52
|
const accounts = input.account_id !== undefined
|
|
49
53
|
? listed.filter((account) => String(account.id) === String(input.account_id))
|
|
@@ -57,15 +61,30 @@ async function accountsList(client, input) {
|
|
|
57
61
|
: mdEmpty('connected accounts', 'posterly does not see any connected social accounts yet.', 'Connect accounts in the posterly dashboard, then run this again.');
|
|
58
62
|
}
|
|
59
63
|
const hasInstagram = accounts.some((account) => account.platform === 'instagram');
|
|
64
|
+
// Only when the API sent them, so older fixtures without these fields stay unchanged.
|
|
65
|
+
const hasHealth = accounts.some((account) => connectionHealthLabel(account));
|
|
66
|
+
const showType = accounts.some((account) => account.account_type);
|
|
67
|
+
const showLocation = accounts.some((account) => account.location_id);
|
|
68
|
+
const headers = [
|
|
69
|
+
'Platform',
|
|
70
|
+
'Account',
|
|
71
|
+
'Account ID',
|
|
72
|
+
...(showType ? ['Type'] : []),
|
|
73
|
+
'Workspace',
|
|
74
|
+
...(showLocation ? ['Location ID'] : []),
|
|
75
|
+
...(hasHealth ? ['Health'] : []),
|
|
76
|
+
...(hasInstagram ? ['Connection', 'Native tags', 'Collaborators'] : []),
|
|
77
|
+
];
|
|
60
78
|
return [
|
|
61
79
|
mdTitle(`Connected accounts (${accounts.length})`),
|
|
62
|
-
mdTable(
|
|
63
|
-
? ['Platform', 'Account', 'Account ID', 'Workspace', 'Connection', 'Native tags', 'Collaborators']
|
|
64
|
-
: ['Platform', 'Account', 'Account ID', 'Workspace'], accounts.map((account) => [
|
|
80
|
+
mdTable(headers, accounts.map((account) => [
|
|
65
81
|
account.platform,
|
|
66
82
|
`@${account.username}`,
|
|
67
83
|
code(account.id),
|
|
84
|
+
...(showType ? [account.account_type || 'n/a'] : []),
|
|
68
85
|
account.workspace_id ? code(account.workspace_id) : 'default',
|
|
86
|
+
...(showLocation ? [account.location_id ? code(String(account.location_id)) : 'n/a'] : []),
|
|
87
|
+
...(hasHealth ? [connectionHealthLabel(account) || 'n/a'] : []),
|
|
69
88
|
...(hasInstagram
|
|
70
89
|
? account.platform === 'instagram'
|
|
71
90
|
? [
|
|
@@ -14,6 +14,7 @@ type ListAnalyticsInput = {
|
|
|
14
14
|
post_id?: number;
|
|
15
15
|
checkpoint?: Checkpoint;
|
|
16
16
|
presentation?: AnalyticsPresentation;
|
|
17
|
+
include_extras?: boolean;
|
|
17
18
|
};
|
|
18
19
|
export declare const listAnalyticsTool: {
|
|
19
20
|
name: string;
|
|
@@ -28,6 +29,7 @@ export declare const listAnalyticsTool: {
|
|
|
28
29
|
post_id: z.ZodOptional<z.ZodNumber>;
|
|
29
30
|
checkpoint: z.ZodOptional<z.ZodEnum<["1h", "6h", "24h", "72h", "7d"]>>;
|
|
30
31
|
presentation: z.ZodOptional<z.ZodEnum<["compact", "table", "json"]>>;
|
|
32
|
+
include_extras: z.ZodOptional<z.ZodBoolean>;
|
|
31
33
|
}, "strip", z.ZodTypeAny, {
|
|
32
34
|
view: "posts" | "accounts" | "insights";
|
|
33
35
|
account_id?: string | number | undefined;
|
|
@@ -38,6 +40,7 @@ export declare const listAnalyticsTool: {
|
|
|
38
40
|
from?: string | undefined;
|
|
39
41
|
to?: string | undefined;
|
|
40
42
|
presentation?: "compact" | "table" | "json" | undefined;
|
|
43
|
+
include_extras?: boolean | undefined;
|
|
41
44
|
}, {
|
|
42
45
|
view: "posts" | "accounts" | "insights";
|
|
43
46
|
account_id?: string | number | undefined;
|
|
@@ -48,6 +51,7 @@ export declare const listAnalyticsTool: {
|
|
|
48
51
|
from?: string | undefined;
|
|
49
52
|
to?: string | undefined;
|
|
50
53
|
presentation?: "compact" | "table" | "json" | undefined;
|
|
54
|
+
include_extras?: boolean | undefined;
|
|
51
55
|
}>;
|
|
52
56
|
/** The old tools' exact input schemas, for alias calls (see alias-transport.ts). */
|
|
53
57
|
legacySchemas: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { formatDateTime, mdEmpty, mdKeyValue, mdSection, mdTitle, truncateText } from '../lib/format.js';
|
|
2
|
+
import { formatDateTime, formatIsoTimestamp, mdEmpty, mdKeyValue, mdSection, mdTitle, truncateText } from '../lib/format.js';
|
|
3
3
|
import { validateArgs } from '../lib/tool-runtime.js';
|
|
4
4
|
const presentationSchema = z.enum(['compact', 'table', 'json']).optional();
|
|
5
5
|
export const listAnalyticsTool = {
|
|
6
6
|
name: 'list_analytics',
|
|
7
|
-
description: 'Analytics for connected social accounts (Instagram, X, Facebook, LinkedIn, Google Business Profile, Pinterest, YouTube, and Threads). view=accounts (account_id): daily snapshots and a period summary with platform-native display_metrics labels. Google Business Profile account analytics includes Calls, Website clicks, and Directions along with Profile Views, Search Views, Maps Views, Customer Actions, and Posts. view=posts (account_id): per-post likes, comments/replies, reach, impressions/views, saves, shares, reposts, quotes, plays, clicks, and watch time, most recent first, with limit/offset. view=insights: per-post feedback insights with a performance tier (great/good/mixed/poor), diagnosis, next action, and baseline, filtered by account_id, post_id, or checkpoint (1h, 6h, 24h, 72h, 7d); read-only, Pro plan or higher. presentation (accounts and posts): compact for Telegram/mobile, table for Markdown clients, json for custom chart/card renderers.',
|
|
7
|
+
description: 'Analytics for connected social accounts (Instagram, X, Facebook, LinkedIn, Google Business Profile, Pinterest, YouTube, and Threads). view=accounts (account_id): daily snapshots and a period summary with platform-native display_metrics labels. Google Business Profile account analytics includes Calls, Website clicks, and Directions along with Profile Views, Search Views, Maps Views, Customer Actions, and Posts. view=posts (account_id): per-post likes, comments/replies, reach, impressions/views, saves, shares, reposts, quotes, plays, clicks, and watch time, most recent first, with limit/offset. Google Business has no per-post rows; its totals are on view=accounts. view=insights: per-post feedback insights with a performance tier (great/good/mixed/poor), diagnosis, next action, and baseline, filtered by account_id, post_id, or checkpoint (1h, 6h, 24h, 72h, 7d); read-only, Pro plan or higher. presentation (accounts and posts): compact for Telegram/mobile, table for Markdown clients, json for custom chart/card renderers. include_extras on accounts asks for saved audience breakdowns, the last analytics sync, and entity snapshots. Those stay off until snapshot extras are switched on, and this does not start a new sync.',
|
|
8
8
|
inputSchema: z.object({
|
|
9
9
|
view: z.enum(['accounts', 'posts', 'insights']).describe('accounts, posts, or insights.'),
|
|
10
10
|
account_id: z
|
|
@@ -32,6 +32,7 @@ export const listAnalyticsTool = {
|
|
|
32
32
|
.optional()
|
|
33
33
|
.describe('insights: filter to one checkpoint after publish.'),
|
|
34
34
|
presentation: presentationSchema.describe('accounts and posts: compact, table, or json.'),
|
|
35
|
+
include_extras: z.boolean().optional().describe('accounts: also return saved audience breakdowns, sync status, and entity snapshots when that read is switched on.'),
|
|
35
36
|
}),
|
|
36
37
|
/** The old tools' exact input schemas, for alias calls (see alias-transport.ts). */
|
|
37
38
|
legacySchemas: {
|
|
@@ -77,7 +78,7 @@ async function postInsights(client, input) {
|
|
|
77
78
|
const blocks = insights.map((insight) => {
|
|
78
79
|
const heading = `${insight.title || 'Insight'} (${insight.performance_tier}, ${insight.checkpoint})`;
|
|
79
80
|
return mdSection(heading, mdKeyValue([
|
|
80
|
-
['Post ID', insight.post_id],
|
|
81
|
+
['Post ID', insight.post_id != null ? String(insight.post_id) : undefined],
|
|
81
82
|
['Platform', insight.platform],
|
|
82
83
|
['Account', insight.username ? `@${insight.username}` : String(insight.social_account_id)],
|
|
83
84
|
['Diagnosis', truncateText(insight.diagnosis, 220)],
|
|
@@ -91,9 +92,10 @@ async function postInsights(client, input) {
|
|
|
91
92
|
return [mdTitle(`Post feedback insights (${insights.length})`), ...blocks].join('\n\n');
|
|
92
93
|
}
|
|
93
94
|
function formatAccountAnalytics(result, presentation) {
|
|
94
|
-
const { account, range, summary, snapshots } = result;
|
|
95
|
+
const { account, range, summary, snapshots, extras } = result;
|
|
95
96
|
const rows = accountMetricRows(summary, account.platform);
|
|
96
97
|
const insights = analyticsInsights(summary, account.platform);
|
|
98
|
+
const saved = formatAccountExtras(extras);
|
|
97
99
|
if (presentation === 'json') {
|
|
98
100
|
return JSON.stringify({
|
|
99
101
|
type: 'account_analytics',
|
|
@@ -104,6 +106,7 @@ function formatAccountAnalytics(result, presentation) {
|
|
|
104
106
|
insights,
|
|
105
107
|
summary,
|
|
106
108
|
snapshots,
|
|
109
|
+
...(extras ? { extras } : {}),
|
|
107
110
|
}, null, 2);
|
|
108
111
|
}
|
|
109
112
|
if (presentation === 'table') {
|
|
@@ -122,6 +125,7 @@ function formatAccountAnalytics(result, presentation) {
|
|
|
122
125
|
'',
|
|
123
126
|
'**Quick read**',
|
|
124
127
|
insights.map((insight) => `- ${insight}`).join('\n'),
|
|
128
|
+
...(saved ? [saved] : []),
|
|
125
129
|
].join('\n');
|
|
126
130
|
}
|
|
127
131
|
return [
|
|
@@ -137,8 +141,22 @@ function formatAccountAnalytics(result, presentation) {
|
|
|
137
141
|
'',
|
|
138
142
|
'**Quick read**',
|
|
139
143
|
insights.map((insight) => `- ${insight}`).join('\n'),
|
|
144
|
+
...(saved ? [saved] : []),
|
|
140
145
|
].join('\n');
|
|
141
146
|
}
|
|
147
|
+
function formatAccountExtras(extras) {
|
|
148
|
+
if (!extras)
|
|
149
|
+
return '';
|
|
150
|
+
if (extras.enabled !== true)
|
|
151
|
+
return '\n**Saved detail**\nSaved audience breakdowns are switched off.';
|
|
152
|
+
const days = Array.isArray(extras.demographics) ? extras.demographics.length : 0;
|
|
153
|
+
const entities = Array.isArray(extras.entity_snapshots) ? extras.entity_snapshots.length : 0;
|
|
154
|
+
const sync = extras.sync_status;
|
|
155
|
+
const syncLine = sync
|
|
156
|
+
? `Last sync ${sync.last_synced_at || 'unknown'} (${sync.status || 'unknown'}), ${sync.posts_synced ?? 'n/a'} posts.`
|
|
157
|
+
: 'No sync status saved.';
|
|
158
|
+
return `\n**Saved detail**\n- Audience days: ${days}\n- ${syncLine}\n- Entity snapshots: ${entities}`;
|
|
159
|
+
}
|
|
142
160
|
function accountMetricRows(summary, platform) {
|
|
143
161
|
const nativeRows = nativeMetricRows(summary);
|
|
144
162
|
if (nativeRows.length > 0)
|
|
@@ -224,7 +242,12 @@ function escapeCell(value) {
|
|
|
224
242
|
function formatPostAnalytics(result, presentation) {
|
|
225
243
|
const { account, range, posts, total } = result;
|
|
226
244
|
if (posts.length === 0) {
|
|
227
|
-
|
|
245
|
+
const who = `${accountLabel(account.username)} (${account.platform})`;
|
|
246
|
+
const window = `between ${range.from} and ${range.to}`;
|
|
247
|
+
if (account.platform === 'google_business') {
|
|
248
|
+
return `Google Business analytics cover the location (profile views, searches, and customer actions), not each post. No per-post rows were found for ${who} ${window}. Ask for the account view to see those totals.`;
|
|
249
|
+
}
|
|
250
|
+
return `No analytics found for ${who} ${window}.`;
|
|
228
251
|
}
|
|
229
252
|
const totals = posts.reduce((acc, post) => {
|
|
230
253
|
acc.likes += post.likes || 0;
|
|
@@ -387,8 +410,7 @@ function postExtras(platform, post) {
|
|
|
387
410
|
function dateTime(value) {
|
|
388
411
|
if (!value)
|
|
389
412
|
return 'n/a';
|
|
390
|
-
|
|
391
|
-
return Number.isNaN(date.getTime()) ? value : date.toLocaleString();
|
|
413
|
+
return formatIsoTimestamp(value);
|
|
392
414
|
}
|
|
393
415
|
function compact(value, maxLength) {
|
|
394
416
|
const text = String(value || '').replace(/\s+/g, ' ').trim();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { formatLocalDateTime, truncateText } from '../lib/format.js';
|
|
2
|
+
import { formatLocalDateTime, inboxCommentContext, truncateText } from '../lib/format.js';
|
|
3
3
|
import { validateArgs } from '../lib/tool-runtime.js';
|
|
4
4
|
const INBOX_PLATFORMS = ['instagram', 'facebook', 'threads', 'linkedin'];
|
|
5
5
|
/**
|
|
@@ -49,11 +49,14 @@ export function formatCommentListLine(comment) {
|
|
|
49
49
|
const replies = Array.isArray(comment.replies) ? comment.replies.length : 0;
|
|
50
50
|
const when = typeof comment.posted_at === 'string' && comment.posted_at ? `[${formatLocalDateTime(comment.posted_at)}]` : null;
|
|
51
51
|
const owner = ownerLabel(comment);
|
|
52
|
-
|
|
52
|
+
const context = inboxCommentContext(comment);
|
|
53
|
+
const account = context.accountId ? `account ${context.accountId}` : null;
|
|
54
|
+
const post = context.caption ? `post: ${truncateText(context.caption, 80)}` : context.link ? `post: ${context.link}` : null;
|
|
55
|
+
return `- ${[String(comment.id), when].filter(Boolean).join(' ')} (${[platform, owner, account, author].filter(Boolean).join(', ')}${flagLabel}${replies ? `, ${replies} replies` : ''}): ${text}${post ? ` (${post})` : ''}`;
|
|
53
56
|
}
|
|
54
57
|
export const listCommentsTool = {
|
|
55
58
|
name: 'list_comments',
|
|
56
|
-
description: 'Social inbox comments and replies for Instagram, Facebook Pages, Threads, and LinkedIn Pages (Pro plan or higher plus posts:read). Without comment_id: list comments filtered by account, platform, unread/flagged, search, or since/until dates, with limit/offset paging. With comment_id: one comment and its replies; only workspace_id may be added.',
|
|
59
|
+
description: 'Social inbox comments and replies for Instagram, Facebook Pages, Threads, and LinkedIn Pages (Pro plan or higher plus posts:read). Without comment_id: list comments filtered by account, platform, unread/flagged, search, or since/until dates, with limit/offset paging. With comment_id: one comment and its replies; only workspace_id may be added. YouTube and TikTok are refused rather than returned as an empty list. They stay off until each platform is reviewed and an inbox provider exists.',
|
|
57
60
|
inputSchema: z.object({
|
|
58
61
|
comment_id: z.string().min(1).optional().describe('One comment and its replies.'),
|
|
59
62
|
workspace_id: z.string().optional().describe('Omit to search all your workspaces, or pass an ID from whoami.'),
|
|
@@ -114,6 +117,13 @@ async function oneComment(client, input) {
|
|
|
114
117
|
`• Posted: ${formatLocalDateTime(typeof comment.posted_at === 'string' ? comment.posted_at : null)}`,
|
|
115
118
|
`• Content: ${typeof comment.content === 'string' ? comment.content : '(empty)'}`,
|
|
116
119
|
];
|
|
120
|
+
const context = inboxCommentContext(comment);
|
|
121
|
+
if (context.accountId)
|
|
122
|
+
lines.push(`• Account ID: ${context.accountId}`);
|
|
123
|
+
if (context.caption)
|
|
124
|
+
lines.push(`• Post: ${context.caption}`);
|
|
125
|
+
if (context.link)
|
|
126
|
+
lines.push(`• Post link: ${context.link}`);
|
|
117
127
|
if (typeof comment.media_permalink === 'string')
|
|
118
128
|
lines.push(`• Media: ${comment.media_permalink}`);
|
|
119
129
|
const replies = Array.isArray(comment.replies) ? comment.replies : [];
|
|
@@ -5,7 +5,7 @@ type ConversationsInput = {
|
|
|
5
5
|
conversation_id?: string;
|
|
6
6
|
workspace_id?: string;
|
|
7
7
|
account_id?: number;
|
|
8
|
-
platform?: 'instagram' | 'facebook'
|
|
8
|
+
platform?: 'instagram' | 'facebook';
|
|
9
9
|
filter?: 'all' | 'unread' | 'starred' | 'archived';
|
|
10
10
|
search?: string;
|
|
11
11
|
limit?: number;
|
|
@@ -27,7 +27,7 @@ export declare const listConversationsTool: {
|
|
|
27
27
|
conversation_id: z.ZodOptional<z.ZodString>;
|
|
28
28
|
workspace_id: z.ZodOptional<z.ZodString>;
|
|
29
29
|
account_id: z.ZodOptional<z.ZodNumber>;
|
|
30
|
-
platform: z.ZodOptional<z.ZodEnum<["instagram", "facebook"
|
|
30
|
+
platform: z.ZodOptional<z.ZodEnum<["instagram", "facebook"]>>;
|
|
31
31
|
filter: z.ZodOptional<z.ZodEnum<["all", "unread", "starred", "archived"]>>;
|
|
32
32
|
search: z.ZodOptional<z.ZodString>;
|
|
33
33
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
@@ -35,7 +35,7 @@ export declare const listConversationsTool: {
|
|
|
35
35
|
since: z.ZodOptional<z.ZodString>;
|
|
36
36
|
until: z.ZodOptional<z.ZodString>;
|
|
37
37
|
}, "strip", z.ZodTypeAny, {
|
|
38
|
-
platform?: "instagram" | "facebook" |
|
|
38
|
+
platform?: "instagram" | "facebook" | undefined;
|
|
39
39
|
account_id?: number | undefined;
|
|
40
40
|
workspace_id?: string | undefined;
|
|
41
41
|
limit?: number | undefined;
|
|
@@ -46,7 +46,7 @@ export declare const listConversationsTool: {
|
|
|
46
46
|
until?: string | undefined;
|
|
47
47
|
conversation_id?: string | undefined;
|
|
48
48
|
}, {
|
|
49
|
-
platform?: "instagram" | "facebook" |
|
|
49
|
+
platform?: "instagram" | "facebook" | undefined;
|
|
50
50
|
account_id?: number | undefined;
|
|
51
51
|
workspace_id?: string | undefined;
|
|
52
52
|
limit?: number | undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { formatLocalDateTime, truncateText } from '../lib/format.js';
|
|
3
|
+
import { replyWindowPhrase } from '../lib/reply-window.js';
|
|
3
4
|
import { validateArgs } from '../lib/tool-runtime.js';
|
|
4
|
-
const INBOX_PLATFORMS = ['instagram', 'facebook'
|
|
5
|
+
const INBOX_PLATFORMS = ['instagram', 'facebook'];
|
|
5
6
|
/**
|
|
6
7
|
* The shared `InboxConversationsResponse`/`InboxCommentsResponse` types
|
|
7
8
|
* don't declare `workspaces_skipped` (a plain pass-through field from the
|
|
@@ -54,16 +55,18 @@ export function formatConversationListLine(conversation) {
|
|
|
54
55
|
preview = `you: ${preview}`;
|
|
55
56
|
const when = typeof conversation.last_message_at === 'string' && conversation.last_message_at ? `[${formatLocalDateTime(conversation.last_message_at)}]` : null;
|
|
56
57
|
const owner = ownerLabel(conversation);
|
|
57
|
-
|
|
58
|
+
const window = replyWindowPhrase(conversation.window_expires_at);
|
|
59
|
+
const line = `- ${[String(conversation.id), when].filter(Boolean).join(' ')} (${[platform, owner, username, unread].filter(Boolean).join(', ')}): ${preview}`;
|
|
60
|
+
return window ? `${line} (${window})` : line;
|
|
58
61
|
}
|
|
59
62
|
export const listConversationsTool = {
|
|
60
63
|
name: 'list_conversations',
|
|
61
|
-
description: 'Social inbox DM conversations for Instagram and Facebook Page inboxes (Threads has no DMs; Pro plan or higher plus posts:read). Without conversation_id: list conversations filtered by account, platform, unread/starred/archived, search, or since/until dates, with limit/offset paging. With conversation_id: one conversation and its messages; there limit is the number of messages (default 50, max 100) and only workspace_id may be added.',
|
|
64
|
+
description: 'Social inbox DM conversations for Instagram and Facebook Page inboxes (Threads has no DMs; Pro plan or higher plus posts:read). Without conversation_id: list conversations filtered by account, platform, unread/starred/archived, search, or since/until dates, with limit/offset paging. With conversation_id: one conversation and its messages; there limit is the number of messages (default 50, max 100) and only workspace_id may be added. When a sync has stored it, each conversation includes the Meta reply window (open until a UTC time, or closed). A reply does not extend that window, and it is not guessed from the messages loaded in the thread.',
|
|
62
65
|
inputSchema: z.object({
|
|
63
66
|
conversation_id: z.string().min(1).optional().describe('One conversation and its messages.'),
|
|
64
67
|
workspace_id: z.string().optional().describe('Omit to search all your workspaces, or pass an ID from whoami.'),
|
|
65
68
|
account_id: z.number().int().positive().optional().describe('From list_accounts.'),
|
|
66
|
-
platform: z.enum(INBOX_PLATFORMS).optional(),
|
|
69
|
+
platform: z.enum(INBOX_PLATFORMS).optional().describe('Instagram or Facebook. Threads has comments, not DMs.'),
|
|
67
70
|
filter: z.enum(['all', 'unread', 'starred', 'archived']).optional().describe('Default all (excludes archived).'),
|
|
68
71
|
search: z.string().optional().describe('Search participant username or last message preview.'),
|
|
69
72
|
limit: z.number().int().min(1).max(100).optional().describe('Rows (messages with conversation_id). Default 50.'),
|
|
@@ -111,14 +114,16 @@ async function oneConversation(client, input) {
|
|
|
111
114
|
const result = await client.getConversation(input);
|
|
112
115
|
const conversation = result.conversation;
|
|
113
116
|
const username = typeof conversation.participant_username === 'string' ? `@${conversation.participant_username}` : 'unknown';
|
|
117
|
+
const window = replyWindowPhrase(conversation.window_expires_at);
|
|
114
118
|
const lines = [
|
|
115
119
|
`Conversation ${String(conversation.id)}`,
|
|
116
120
|
`• Platform: ${typeof conversation.platform === 'string' ? conversation.platform : 'unknown'}`,
|
|
117
121
|
`• Participant: ${username}`,
|
|
118
122
|
`• Read: ${conversation.is_read === false ? 'no' : 'yes'}`,
|
|
123
|
+
window ? `• Reply window: ${window}` : null,
|
|
119
124
|
`• Messages: ${result.messages.length}`,
|
|
120
125
|
'',
|
|
121
|
-
];
|
|
126
|
+
].filter((line) => line !== null);
|
|
122
127
|
for (const message of result.messages) {
|
|
123
128
|
const who = message.sender_is_business ? 'you' : (typeof message.sender_username === 'string' ? message.sender_username : 'them');
|
|
124
129
|
const when = formatLocalDateTime(typeof message.sent_at === 'string' ? message.sent_at : null);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PosterlyClient } from '../lib/api-client.js';
|
|
3
|
+
import { type ToolContext } from '../lib/tool-runtime.js';
|
|
4
|
+
type ListLocationInput = {
|
|
5
|
+
workspace_id?: string;
|
|
6
|
+
account_id?: number;
|
|
7
|
+
location_id?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const listGoogleBusinessLocationsTool: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
inputSchema: z.ZodObject<{
|
|
13
|
+
workspace_id: z.ZodOptional<z.ZodString>;
|
|
14
|
+
account_id: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
location_id: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
account_id?: number | undefined;
|
|
18
|
+
workspace_id?: string | undefined;
|
|
19
|
+
location_id?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
account_id?: number | undefined;
|
|
22
|
+
workspace_id?: string | undefined;
|
|
23
|
+
location_id?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
execute(client: PosterlyClient, input: ListLocationInput, ctx: ToolContext): Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { code, mdKeyValue, mdSection, mdTitle } from '../lib/format.js';
|
|
3
|
+
import { validateArgs } from '../lib/tool-runtime.js';
|
|
4
|
+
const LOCATION_ID_DESCRIPTION = 'Google Business numeric location id (the location_id/platform_user_id from list_accounts, e.g. "197940849675145390"). NOT the ChIJ... Place ID from list_google_business_reviews view=review_link. Prefer account_id.';
|
|
5
|
+
export const listGoogleBusinessLocationsTool = {
|
|
6
|
+
name: 'list_google_business_locations',
|
|
7
|
+
description: 'Read regular opening hours and attributes for one Google Business location. Stays off until location edits are switched on, and does not call Google while it is off. Pass account_id or location_id. Does not return the business name, address, phone, or website.',
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
workspace_id: z.string().optional().describe('Filter to a workspace ID from whoami.'),
|
|
10
|
+
account_id: z.number().int().positive().optional().describe('Google Business account ID from list_accounts.'),
|
|
11
|
+
location_id: z.string().optional().describe(LOCATION_ID_DESCRIPTION),
|
|
12
|
+
}),
|
|
13
|
+
async execute(client, input, ctx) {
|
|
14
|
+
const { args } = validateArgs(ctx, 'list_google_business_locations', input);
|
|
15
|
+
const result = await client.listGoogleBusinessLocation(args);
|
|
16
|
+
if (result.enabled !== true) {
|
|
17
|
+
return 'Google Business location edits are switched off. Nothing was read from Google.';
|
|
18
|
+
}
|
|
19
|
+
const periods = Array.isArray(result.regular_hours?.periods) ? result.regular_hours.periods : [];
|
|
20
|
+
const attributes = Array.isArray(result.attributes) ? result.attributes : [];
|
|
21
|
+
return [
|
|
22
|
+
mdTitle('Google Business location'),
|
|
23
|
+
mdSection('Location', mdKeyValue([
|
|
24
|
+
['Account ID', result.account_id != null ? code(result.account_id) : undefined],
|
|
25
|
+
['Location', result.location ? code(String(result.location)) : undefined],
|
|
26
|
+
])),
|
|
27
|
+
mdSection('Regular hours', periods.length
|
|
28
|
+
? periods.map((period) => `- ${period.open_day} ${period.open_time} to ${period.close_day} ${period.close_time}`).join('\n')
|
|
29
|
+
: 'No regular hours saved.'),
|
|
30
|
+
mdSection('Attributes', attributes.length
|
|
31
|
+
? attributes.map((attribute) => `- ${attribute.name} (${attribute.value_type}): ${(attribute.values || []).join(', ')}`).join('\n')
|
|
32
|
+
: 'No attributes saved.'),
|
|
33
|
+
].join('\n\n');
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -7,18 +7,26 @@ export declare const listGoogleBusinessMediaTool: {
|
|
|
7
7
|
workspace_id: z.ZodOptional<z.ZodString>;
|
|
8
8
|
account_id: z.ZodOptional<z.ZodNumber>;
|
|
9
9
|
location_id: z.ZodOptional<z.ZodString>;
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
10
12
|
}, "strip", z.ZodTypeAny, {
|
|
11
13
|
account_id?: number | undefined;
|
|
12
14
|
workspace_id?: string | undefined;
|
|
15
|
+
limit?: number | undefined;
|
|
16
|
+
offset?: number | undefined;
|
|
13
17
|
location_id?: string | undefined;
|
|
14
18
|
}, {
|
|
15
19
|
account_id?: number | undefined;
|
|
16
20
|
workspace_id?: string | undefined;
|
|
21
|
+
limit?: number | undefined;
|
|
22
|
+
offset?: number | undefined;
|
|
17
23
|
location_id?: string | undefined;
|
|
18
24
|
}>;
|
|
19
25
|
execute(client: PosterlyClient, input: {
|
|
20
26
|
workspace_id?: string;
|
|
21
27
|
account_id?: number;
|
|
22
28
|
location_id?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
offset?: number;
|
|
23
31
|
}): Promise<string>;
|
|
24
32
|
};
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export const listGoogleBusinessMediaTool = {
|
|
3
3
|
name: 'list_google_business_media',
|
|
4
|
-
description: 'List the photos and videos on a Google Business Profile gallery (the media shown on Maps and Search) for one location/account or every accessible GBP location. This is separate from media attached to a post. Returns each item\'s resource name, category, format, and
|
|
4
|
+
description: 'List the photos and videos on a Google Business Profile gallery (the media shown on Maps and Search) for one location/account or every accessible GBP location. This is separate from media attached to a post. Returns each item\'s resource name, category, format, image URL, and date. Pages the gallery already fetched from Google: limit defaults to 50 (max 200) and offset skips that many items.',
|
|
5
5
|
inputSchema: z.object({
|
|
6
6
|
workspace_id: z.string().optional().describe('Filter to a workspace ID from whoami.'),
|
|
7
7
|
account_id: z.number().int().positive().optional().describe('Google Business account ID from list_accounts.'),
|
|
8
8
|
location_id: z.string().optional().describe('Google Business numeric location id (the location_id/platform_user_id from list_accounts, e.g. "197940849675145390"). NOT the ChIJ... Place ID from list_google_business_reviews view=review_link. Prefer account_id.'),
|
|
9
|
+
limit: z.number().int().min(1).max(200).optional().describe('Items per page. Default 50, max 200. This pages the gallery already fetched; it does not ask Google for a smaller page.'),
|
|
10
|
+
offset: z.number().int().min(0).optional().describe('Items to skip. Use the offset the previous page gives.'),
|
|
9
11
|
}),
|
|
10
12
|
async execute(client, input) {
|
|
11
13
|
const result = await client.listGoogleBusinessMedia(input);
|
|
12
|
-
|
|
14
|
+
const media = result.media || [];
|
|
15
|
+
if (media.length === 0) {
|
|
13
16
|
return 'No photos or videos found on the Google Business profile for your filters.';
|
|
14
17
|
}
|
|
15
|
-
const
|
|
16
|
-
|
|
18
|
+
const offset = Math.max(0, Math.trunc(input.offset ?? 0) || 0);
|
|
19
|
+
const limit = Math.min(200, Math.max(1, Math.trunc(input.limit ?? 50) || 50));
|
|
20
|
+
const slice = media.slice(offset, offset + limit);
|
|
21
|
+
if (slice.length === 0) {
|
|
22
|
+
return `No Google Business media on this page: offset ${offset} is past the last of the ${media.length} items.`;
|
|
23
|
+
}
|
|
24
|
+
const lines = [`Google Business profile media (showing ${slice.length} of ${media.length}):`];
|
|
25
|
+
for (const item of slice) {
|
|
17
26
|
const kind = item.mediaFormat === 'VIDEO' ? 'video' : 'photo';
|
|
18
27
|
const category = item.category || 'uncategorised';
|
|
19
28
|
const attribution = item.attribution?.profileName ? ` by ${item.attribution.profileName}` : '';
|
|
20
|
-
|
|
29
|
+
const image = item.googleUrl || item.thumbnailUrl;
|
|
30
|
+
const when = item.createTime ? ` added ${item.createTime}` : '';
|
|
31
|
+
lines.push(`- [${kind}] ${category}${attribution}${when}${image ? ` ${image}` : ''} :: ${item.name}`);
|
|
32
|
+
}
|
|
33
|
+
if (offset + slice.length < media.length) {
|
|
34
|
+
lines.push('', `More items available. Call again with offset: ${offset + slice.length} to continue.`);
|
|
21
35
|
}
|
|
22
36
|
lines.push('', 'Use the resource name (after ::) as media_name to delete an item.');
|
|
23
37
|
return lines.join('\n');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { formatDate } from '../lib/format.js';
|
|
3
|
-
import { reviewNameFromListItem } from '../lib/google-business-review-name.js';
|
|
3
|
+
import { reviewNameFromListItem, reviewReplyComment } from '../lib/google-business-review-name.js';
|
|
4
4
|
import { validateArgs } from '../lib/tool-runtime.js';
|
|
5
5
|
/** Matches GOOGLE_BUSINESS_REVIEWS_MAX_LIMIT in lib/api-v1-google-business.ts. */
|
|
6
6
|
const MAX_LIMIT = 1000;
|
|
@@ -76,7 +76,8 @@ async function reviews(client, input) {
|
|
|
76
76
|
const rating = review.starRating ? `${review.starRating} stars` : 'unrated';
|
|
77
77
|
const location = review.businessName || review.locationName || review.locationId || 'location';
|
|
78
78
|
const date = formatReviewDate(review);
|
|
79
|
-
const
|
|
79
|
+
const replyComment = reviewReplyComment(review);
|
|
80
|
+
const replied = replyComment ? `reply: ${replyComment}` : (review.reviewReply ? 'replied' : 'unanswered');
|
|
80
81
|
lines.push(`- ${name} (${rating}, ${date}, ${location}, ${replied})`);
|
|
81
82
|
const reviewName = reviewNameFromListItem(review);
|
|
82
83
|
if (reviewName)
|