posterly-mcp-server 0.54.4 → 0.55.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 +48 -5
- 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 +152 -0
- package/dist/lib/api-client.js +88 -0
- package/dist/lib/claude-directory-profile.js +4 -2
- 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 +36 -0
- package/dist/lib/google-business-review-name.js +83 -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.d.ts +10 -0
- package/dist/tools/list-comments.js +54 -22
- package/dist/tools/list-conversations.d.ts +19 -4
- package/dist/tools/list-conversations.js +55 -15
- 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 +12 -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 +31 -5
- 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/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 +251 -8
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { validateArgs } from '../lib/tool-runtime.js';
|
|
2
3
|
export const listWebhooksTool = {
|
|
3
4
|
name: 'list_webhooks',
|
|
4
|
-
description: 'List API webhook subscriptions, their event filters, active state, and most recent delivery status.',
|
|
5
|
+
description: 'List API webhook subscriptions, their event filters, active state, and most recent delivery status. view=deliveries (webhook_id) reads recent delivery attempts for one webhook. That history stays off until it is switched on, and it does not include the signing secret or the request body.',
|
|
5
6
|
inputSchema: z.object({
|
|
7
|
+
view: z.enum(['webhooks', 'deliveries']).optional().describe('webhooks (default) or deliveries.'),
|
|
6
8
|
workspace_id: z.string().optional().describe('Filter to a workspace ID from whoami.'),
|
|
9
|
+
webhook_id: z.string().optional().describe('deliveries: webhook ID from view=webhooks.'),
|
|
10
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
11
|
+
offset: z.number().int().min(0).optional(),
|
|
7
12
|
}),
|
|
8
|
-
async execute(client, input) {
|
|
9
|
-
const {
|
|
13
|
+
async execute(client, input, ctx) {
|
|
14
|
+
const { mode, args } = validateArgs(ctx, 'list_webhooks', input);
|
|
15
|
+
if (mode === 'deliveries') {
|
|
16
|
+
const result = await client.listWebhookDeliveries(String(args.webhook_id), { limit: args.limit, offset: args.offset });
|
|
17
|
+
if (result.enabled !== true)
|
|
18
|
+
return 'Webhook delivery history is switched off. Nothing was read.';
|
|
19
|
+
const deliveries = Array.isArray(result.deliveries) ? result.deliveries : [];
|
|
20
|
+
if (deliveries.length === 0)
|
|
21
|
+
return 'No deliveries found for this webhook.';
|
|
22
|
+
const lines = [`Deliveries (${deliveries.length}):`];
|
|
23
|
+
for (const delivery of deliveries) {
|
|
24
|
+
lines.push(`- ${delivery.id} ${delivery.event_type || ''} ${delivery.status || ''} HTTP ${delivery.http_status ?? 'n/a'} at ${delivery.delivered_at || delivery.created_at || 'n/a'}`);
|
|
25
|
+
}
|
|
26
|
+
return lines.join('\n');
|
|
27
|
+
}
|
|
28
|
+
const { webhooks } = await client.listWebhooks({ workspace_id: args.workspace_id });
|
|
10
29
|
if (webhooks.length === 0) {
|
|
11
30
|
return 'No webhooks found.';
|
|
12
31
|
}
|
|
@@ -25,12 +25,14 @@ export function formatApiAccess(member) {
|
|
|
25
25
|
function formatWorkspaceMembers(result) {
|
|
26
26
|
const members = result.members || [];
|
|
27
27
|
const invites = result.invites || [];
|
|
28
|
+
const showUserId = members.some((member) => member.user_id);
|
|
28
29
|
return [
|
|
29
30
|
mdTitle(`Team (${members.length} members, ${invites.length} pending invites)`, `Workspace ${result.workspace_id}`),
|
|
30
31
|
mdSection('Members', members.length > 0
|
|
31
|
-
? mdTable(['Name', 'Member ID', 'Email', 'Role', 'Status', 'Brands', 'API access'], members.map((member) => [
|
|
32
|
+
? mdTable(['Name', 'Member ID', ...(showUserId ? ['User ID'] : []), 'Email', 'Role', 'Status', 'Brands', 'API access'], members.map((member) => [
|
|
32
33
|
member.name || member.email || member.id,
|
|
33
34
|
code(member.id),
|
|
35
|
+
...(showUserId ? [member.user_id ? code(String(member.user_id)) : 'n/a'] : []),
|
|
34
36
|
member.email,
|
|
35
37
|
member.role,
|
|
36
38
|
member.status,
|
|
@@ -0,0 +1,47 @@
|
|
|
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 ManageBrandsInput = {
|
|
5
|
+
action: 'create' | 'update' | 'archive';
|
|
6
|
+
brand_id?: string;
|
|
7
|
+
workspace_id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
timezone?: string;
|
|
10
|
+
website_url?: string | null;
|
|
11
|
+
confirm?: boolean;
|
|
12
|
+
preview_id?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const manageBrandsTool: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: z.ZodObject<{
|
|
18
|
+
action: z.ZodEnum<["create", "update", "archive"]>;
|
|
19
|
+
brand_id: z.ZodOptional<z.ZodString>;
|
|
20
|
+
workspace_id: z.ZodOptional<z.ZodString>;
|
|
21
|
+
name: z.ZodOptional<z.ZodString>;
|
|
22
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
23
|
+
website_url: z.ZodOptional<z.ZodString>;
|
|
24
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
preview_id: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
action: "update" | "create" | "archive";
|
|
28
|
+
workspace_id?: string | undefined;
|
|
29
|
+
brand_id?: string | undefined;
|
|
30
|
+
timezone?: string | undefined;
|
|
31
|
+
confirm?: boolean | undefined;
|
|
32
|
+
preview_id?: string | undefined;
|
|
33
|
+
name?: string | undefined;
|
|
34
|
+
website_url?: string | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
action: "update" | "create" | "archive";
|
|
37
|
+
workspace_id?: string | undefined;
|
|
38
|
+
brand_id?: string | undefined;
|
|
39
|
+
timezone?: string | undefined;
|
|
40
|
+
confirm?: boolean | undefined;
|
|
41
|
+
preview_id?: string | undefined;
|
|
42
|
+
name?: string | undefined;
|
|
43
|
+
website_url?: string | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
execute(client: PosterlyClient, input: ManageBrandsInput, ctx: ToolContext): Promise<string>;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { code, mdKeyValue, mdSection, mdTitle } from '../lib/format.js';
|
|
3
|
+
import { previewThenConfirm, validateArgs } from '../lib/tool-runtime.js';
|
|
4
|
+
const BRAND_WRITE_DESCRIPTION = 'Create, update, or archive a brand. action=create (admin only): name, and the workspace_id from whoami when the key is not already scoped to one workspace. Optional timezone and website_url. Pass confirm=true only after the user agrees. action=update (admin only): brand_id plus name, timezone, or website_url. Pass confirm=true only after the user agrees. action=archive (admin only): preview then confirm. Call without confirm to see the brand and what archiving does, show that to the user, then call again with confirm=true and the preview_id. Archiving removes the brand from the active list. Connected accounts stay connected, and its scheduled posts are not cancelled: they still publish. The preview counts both.';
|
|
5
|
+
function formatBrand(result) {
|
|
6
|
+
if (result.requires_confirmation && result.preview) {
|
|
7
|
+
const preview = result.preview;
|
|
8
|
+
return [
|
|
9
|
+
mdTitle('Preview only: the brand is not archived yet'),
|
|
10
|
+
preview.effect || '',
|
|
11
|
+
mdSection('Brand', mdKeyValue([
|
|
12
|
+
['Name', preview.name],
|
|
13
|
+
['Brand ID', preview.brand_id ? code(preview.brand_id) : ''],
|
|
14
|
+
['Accounts still connected', preview.account_count ?? 'could not be counted'],
|
|
15
|
+
['Scheduled posts that still publish', preview.scheduled_post_count ?? 'could not be counted'],
|
|
16
|
+
['Status', preview.status],
|
|
17
|
+
])),
|
|
18
|
+
].filter(Boolean).join('\n\n');
|
|
19
|
+
}
|
|
20
|
+
const brand = result.brand || {};
|
|
21
|
+
return [
|
|
22
|
+
mdTitle(result.already_archived ? `Brand already archived: ${brand.name || 'brand'}` : `Brand: ${brand.name || 'updated'}`),
|
|
23
|
+
mdKeyValue([
|
|
24
|
+
['Brand ID', brand.id ? code(brand.id) : ''],
|
|
25
|
+
['Status', brand.status],
|
|
26
|
+
['Timezone', brand.timezone],
|
|
27
|
+
['Website', brand.website_url],
|
|
28
|
+
['Workspace', brand.workspace_id ? code(brand.workspace_id) : ''],
|
|
29
|
+
]),
|
|
30
|
+
].join('\n\n');
|
|
31
|
+
}
|
|
32
|
+
export const manageBrandsTool = {
|
|
33
|
+
name: 'manage_brand',
|
|
34
|
+
description: BRAND_WRITE_DESCRIPTION,
|
|
35
|
+
inputSchema: z.object({
|
|
36
|
+
action: z.enum(['create', 'update', 'archive']).describe('create, update, or archive.'),
|
|
37
|
+
brand_id: z.string().optional().describe('update and archive: the brand ID from list_brands.'),
|
|
38
|
+
workspace_id: z.string().optional().describe('create: workspace ID from whoami, when the key is not already scoped.'),
|
|
39
|
+
name: z.string().optional().describe('create: required. update: the new name.'),
|
|
40
|
+
timezone: z.string().optional().describe('create or update: an IANA timezone such as Europe/London.'),
|
|
41
|
+
website_url: z.string().optional().describe('create or update: an http or https website. Pass an empty string on update to clear it.'),
|
|
42
|
+
confirm: z.boolean().optional().describe('create and update: true only after the user agrees. archive: true only with the preview_id from a preview call.'),
|
|
43
|
+
preview_id: z.string().optional().describe('archive: the preview_id from the preview call.'),
|
|
44
|
+
}),
|
|
45
|
+
async execute(client, input, ctx) {
|
|
46
|
+
const { mode, args } = validateArgs(ctx, 'manage_brand', input);
|
|
47
|
+
const parsed = args;
|
|
48
|
+
if (mode === 'update') {
|
|
49
|
+
if (parsed.confirm !== true)
|
|
50
|
+
throw new Error('Refusing to update a brand without confirm=true after the user agrees.');
|
|
51
|
+
if (!parsed.brand_id)
|
|
52
|
+
throw new Error('brand_id is required.');
|
|
53
|
+
const result = await client.updateBrand(parsed.brand_id, {
|
|
54
|
+
confirm: true,
|
|
55
|
+
...(parsed.name !== undefined ? { name: parsed.name } : {}),
|
|
56
|
+
...(parsed.timezone !== undefined ? { timezone: parsed.timezone } : {}),
|
|
57
|
+
...(parsed.website_url !== undefined ? { website_url: parsed.website_url } : {}),
|
|
58
|
+
});
|
|
59
|
+
return formatBrand(result);
|
|
60
|
+
}
|
|
61
|
+
if (mode === 'archive') {
|
|
62
|
+
if (!parsed.brand_id)
|
|
63
|
+
throw new Error('brand_id is required.');
|
|
64
|
+
const brandId = parsed.brand_id;
|
|
65
|
+
return previewThenConfirm({
|
|
66
|
+
tool: 'manage_brand',
|
|
67
|
+
action: 'archive',
|
|
68
|
+
args: parsed,
|
|
69
|
+
nonce: false,
|
|
70
|
+
legacyRefusal: 'Refusing to archive a brand without confirm=true after the user agrees.',
|
|
71
|
+
ctx,
|
|
72
|
+
describe: async () => formatBrand(await client.archiveBrand(brandId, { confirm: false })),
|
|
73
|
+
run: async () => formatBrand(await client.archiveBrand(brandId, { confirm: true })),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (parsed.confirm !== true)
|
|
77
|
+
throw new Error('Refusing to create a brand without confirm=true after the user agrees.');
|
|
78
|
+
if (!parsed.name?.trim())
|
|
79
|
+
throw new Error('name is required.');
|
|
80
|
+
const result = await client.createBrand({
|
|
81
|
+
name: parsed.name.trim(),
|
|
82
|
+
confirm: true,
|
|
83
|
+
...(parsed.workspace_id ? { workspace_id: parsed.workspace_id } : {}),
|
|
84
|
+
...(parsed.timezone ? { timezone: parsed.timezone } : {}),
|
|
85
|
+
...(parsed.website_url ? { website_url: parsed.website_url } : {}),
|
|
86
|
+
});
|
|
87
|
+
return formatBrand(result);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { code, mdKeyValue, mdQuote, mdSection } from '../lib/format.js';
|
|
2
|
+
import { code, inboxCommentContext, mdKeyValue, mdQuote, mdSection } from '../lib/format.js';
|
|
3
3
|
import { previewThenConfirm, readFailedNote, readForPreview, validateArgs } from '../lib/tool-runtime.js';
|
|
4
4
|
export const manageCommentTool = {
|
|
5
5
|
name: 'manage_comment',
|
|
@@ -77,10 +77,14 @@ async function describeComment(client, input) {
|
|
|
77
77
|
return [readFailedNote(read.error), mdKeyValue([['Comment ID', code(input.comment_id)], ['Workspace', input.workspace_id ? code(input.workspace_id) : undefined]])].join('\n\n');
|
|
78
78
|
}
|
|
79
79
|
const comment = read.data.comment;
|
|
80
|
+
const context = inboxCommentContext(comment);
|
|
80
81
|
return mdSection('Comment', mdKeyValue([
|
|
81
82
|
['Comment ID', code(String(comment.id))],
|
|
82
83
|
['Platform', typeof comment.platform === 'string' ? comment.platform : 'unknown'],
|
|
84
|
+
...(context.accountId ? [['Account ID', context.accountId]] : []),
|
|
83
85
|
['Author', typeof comment.author_username === 'string' ? `@${comment.author_username}` : 'unknown'],
|
|
86
|
+
...(context.caption ? [['Post', context.caption]] : []),
|
|
87
|
+
...(context.link ? [['Post link', context.link]] : []),
|
|
84
88
|
['Content', typeof comment.content === 'string' ? comment.content : '(empty)'],
|
|
85
89
|
]));
|
|
86
90
|
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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 ManageLocationInput = {
|
|
5
|
+
action: 'update_hours' | 'update_attributes';
|
|
6
|
+
workspace_id?: string;
|
|
7
|
+
account_id?: number;
|
|
8
|
+
location_id?: string;
|
|
9
|
+
regular_hours?: {
|
|
10
|
+
periods: Array<{
|
|
11
|
+
open_day: string;
|
|
12
|
+
open_time: string;
|
|
13
|
+
close_day: string;
|
|
14
|
+
close_time: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
attributes?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
value_type: 'BOOL' | 'URL' | 'ENUM';
|
|
20
|
+
values: Array<boolean | string>;
|
|
21
|
+
}>;
|
|
22
|
+
confirm?: boolean;
|
|
23
|
+
preview_id?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const manageGoogleBusinessLocationTool: {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
inputSchema: z.ZodObject<{
|
|
29
|
+
action: z.ZodEnum<["update_hours", "update_attributes"]>;
|
|
30
|
+
workspace_id: z.ZodOptional<z.ZodString>;
|
|
31
|
+
account_id: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
location_id: z.ZodOptional<z.ZodString>;
|
|
33
|
+
regular_hours: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
periods: z.ZodArray<z.ZodObject<{
|
|
35
|
+
open_day: z.ZodString;
|
|
36
|
+
open_time: z.ZodString;
|
|
37
|
+
close_day: z.ZodString;
|
|
38
|
+
close_time: z.ZodString;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
open_day: string;
|
|
41
|
+
open_time: string;
|
|
42
|
+
close_day: string;
|
|
43
|
+
close_time: string;
|
|
44
|
+
}, {
|
|
45
|
+
open_day: string;
|
|
46
|
+
open_time: string;
|
|
47
|
+
close_day: string;
|
|
48
|
+
close_time: string;
|
|
49
|
+
}>, "many">;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
periods: {
|
|
52
|
+
open_day: string;
|
|
53
|
+
open_time: string;
|
|
54
|
+
close_day: string;
|
|
55
|
+
close_time: string;
|
|
56
|
+
}[];
|
|
57
|
+
}, {
|
|
58
|
+
periods: {
|
|
59
|
+
open_day: string;
|
|
60
|
+
open_time: string;
|
|
61
|
+
close_day: string;
|
|
62
|
+
close_time: string;
|
|
63
|
+
}[];
|
|
64
|
+
}>>;
|
|
65
|
+
attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
66
|
+
name: z.ZodString;
|
|
67
|
+
value_type: z.ZodEnum<["BOOL", "URL", "ENUM"]>;
|
|
68
|
+
values: z.ZodArray<z.ZodUnion<[z.ZodBoolean, z.ZodString]>, "many">;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
values: (string | boolean)[];
|
|
71
|
+
name: string;
|
|
72
|
+
value_type: "URL" | "BOOL" | "ENUM";
|
|
73
|
+
}, {
|
|
74
|
+
values: (string | boolean)[];
|
|
75
|
+
name: string;
|
|
76
|
+
value_type: "URL" | "BOOL" | "ENUM";
|
|
77
|
+
}>, "many">>;
|
|
78
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
preview_id: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
action: "update_hours" | "update_attributes";
|
|
82
|
+
account_id?: number | undefined;
|
|
83
|
+
workspace_id?: string | undefined;
|
|
84
|
+
confirm?: boolean | undefined;
|
|
85
|
+
preview_id?: string | undefined;
|
|
86
|
+
location_id?: string | undefined;
|
|
87
|
+
regular_hours?: {
|
|
88
|
+
periods: {
|
|
89
|
+
open_day: string;
|
|
90
|
+
open_time: string;
|
|
91
|
+
close_day: string;
|
|
92
|
+
close_time: string;
|
|
93
|
+
}[];
|
|
94
|
+
} | undefined;
|
|
95
|
+
attributes?: {
|
|
96
|
+
values: (string | boolean)[];
|
|
97
|
+
name: string;
|
|
98
|
+
value_type: "URL" | "BOOL" | "ENUM";
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
action: "update_hours" | "update_attributes";
|
|
102
|
+
account_id?: number | undefined;
|
|
103
|
+
workspace_id?: string | undefined;
|
|
104
|
+
confirm?: boolean | undefined;
|
|
105
|
+
preview_id?: string | undefined;
|
|
106
|
+
location_id?: string | undefined;
|
|
107
|
+
regular_hours?: {
|
|
108
|
+
periods: {
|
|
109
|
+
open_day: string;
|
|
110
|
+
open_time: string;
|
|
111
|
+
close_day: string;
|
|
112
|
+
close_time: string;
|
|
113
|
+
}[];
|
|
114
|
+
} | undefined;
|
|
115
|
+
attributes?: {
|
|
116
|
+
values: (string | boolean)[];
|
|
117
|
+
name: string;
|
|
118
|
+
value_type: "URL" | "BOOL" | "ENUM";
|
|
119
|
+
}[] | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
execute(client: PosterlyClient, input: ManageLocationInput, ctx: ToolContext): Promise<string>;
|
|
122
|
+
};
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { code, mdKeyValue, mdSection } from '../lib/format.js';
|
|
3
|
+
import { omitKeys, previewThenConfirm, readFailedNote, readForPreview, validateArgs } from '../lib/tool-runtime.js';
|
|
4
|
+
import { GBP_CLOSED_DAYS_NOTE, gbpAttributeLines, gbpCurrentAttributesFor, gbpPeriodLines } from '../lib/gbp-location-preview.js';
|
|
5
|
+
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.';
|
|
6
|
+
const periodSchema = z.object({
|
|
7
|
+
open_day: z.string(),
|
|
8
|
+
open_time: z.string(),
|
|
9
|
+
close_day: z.string(),
|
|
10
|
+
close_time: z.string(),
|
|
11
|
+
});
|
|
12
|
+
const attributeSchema = z.object({
|
|
13
|
+
name: z.string(),
|
|
14
|
+
value_type: z.enum(['BOOL', 'URL', 'ENUM']),
|
|
15
|
+
values: z.array(z.union([z.boolean(), z.string()])).min(1).max(5),
|
|
16
|
+
});
|
|
17
|
+
function locationRows(input) {
|
|
18
|
+
return [
|
|
19
|
+
['Account ID', input.account_id !== undefined ? code(input.account_id) : undefined],
|
|
20
|
+
['Location ID', input.location_id ? code(input.location_id) : undefined],
|
|
21
|
+
['Workspace', input.workspace_id ? code(input.workspace_id) : undefined],
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
async function readCurrentLocation(client, input) {
|
|
25
|
+
return readForPreview(() => client.listGoogleBusinessLocation({
|
|
26
|
+
workspace_id: input.workspace_id,
|
|
27
|
+
account_id: input.account_id,
|
|
28
|
+
location_id: input.location_id,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function locationReadNote(error) {
|
|
32
|
+
return /switched off/i.test(error)
|
|
33
|
+
? '_Location edits are switched off, so the current values were not read and a confirm changes nothing._'
|
|
34
|
+
: readFailedNote(error);
|
|
35
|
+
}
|
|
36
|
+
export const manageGoogleBusinessLocationTool = {
|
|
37
|
+
name: 'manage_google_business_location',
|
|
38
|
+
description: 'Change regular opening hours or attributes on a Google Business location. action=update_hours sends regular_hours.periods with open_day, close_day, open_time, and close_time as HH:MM. action=update_attributes sends attributes with a name like attributes/has_wifi and value_type BOOL, URL, or ENUM. Both use preview then confirm: call without confirm to get a preview and preview_id, show it, then call again with confirm=true and that preview_id. Stays off until location edits are switched on. A confirm while it is off changes nothing and does not call Google. This uses the same business management connection as posting. It does not change the business name, address, phone, or website.',
|
|
39
|
+
inputSchema: z.object({
|
|
40
|
+
action: z.enum(['update_hours', 'update_attributes']).describe('update_hours or update_attributes.'),
|
|
41
|
+
workspace_id: z.string().optional().describe('Filter to a workspace ID from whoami.'),
|
|
42
|
+
account_id: z.number().int().positive().optional().describe('Google Business account ID from list_accounts.'),
|
|
43
|
+
location_id: z.string().optional().describe(LOCATION_ID_DESCRIPTION),
|
|
44
|
+
regular_hours: z.object({ periods: z.array(periodSchema).min(1).max(14) }).optional().describe('update_hours: opening periods. Days are MONDAY-SUNDAY. Times are HH:MM.'),
|
|
45
|
+
attributes: z.array(attributeSchema).min(1).max(20).optional().describe('update_attributes: attributes to set. URL values must be https. Names look like attributes/has_wifi.'),
|
|
46
|
+
confirm: z.boolean().optional().describe('Leave out to get a preview; true only with the preview_id after the user approved it.'),
|
|
47
|
+
preview_id: z.string().optional().describe('The preview_id from the preview call. Required with confirm: true.'),
|
|
48
|
+
}),
|
|
49
|
+
async execute(client, input, ctx) {
|
|
50
|
+
const { mode, args } = validateArgs(ctx, 'manage_google_business_location', input);
|
|
51
|
+
const call = args;
|
|
52
|
+
if (mode === 'update_attributes') {
|
|
53
|
+
return previewThenConfirm({
|
|
54
|
+
tool: 'manage_google_business_location',
|
|
55
|
+
action: 'update_attributes',
|
|
56
|
+
args,
|
|
57
|
+
nonce: true,
|
|
58
|
+
legacyRefusal: 'Refusing to change Google Business attributes without confirm=true after explicit user confirmation.',
|
|
59
|
+
ctx,
|
|
60
|
+
describe: async () => {
|
|
61
|
+
const read = await readCurrentLocation(client, call);
|
|
62
|
+
const current = read.ok && Array.isArray(read.data?.attributes) ? gbpCurrentAttributesFor(read.data.attributes, call.attributes) : null;
|
|
63
|
+
return [
|
|
64
|
+
mdSection('Current values', current ? gbpAttributeLines(current, 'None of these attributes is set now.') : locationReadNote(read.ok ? 'no attributes returned' : read.error)),
|
|
65
|
+
mdSection('Attributes to set', [gbpAttributeLines(call.attributes, 'No attributes were sent.'), '', mdKeyValue(locationRows(call))].join('\n')),
|
|
66
|
+
'This replaces those attributes on the public Google Business profile. Other attributes are left as they are. Nothing is sent until you confirm, and the edit stays off until location edits are switched on.',
|
|
67
|
+
].join('\n\n');
|
|
68
|
+
},
|
|
69
|
+
run: async () => {
|
|
70
|
+
const result = await client.updateGoogleBusinessAttributes(omitKeys(call, ['action', 'confirm', 'preview_id']));
|
|
71
|
+
return result.success ? 'Google Business attributes updated.' : (result.error || 'Google Business attributes were not updated.');
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return previewThenConfirm({
|
|
76
|
+
tool: 'manage_google_business_location',
|
|
77
|
+
action: 'update_hours',
|
|
78
|
+
args,
|
|
79
|
+
nonce: true,
|
|
80
|
+
legacyRefusal: 'Refusing to change Google Business hours without confirm=true after explicit user confirmation.',
|
|
81
|
+
ctx,
|
|
82
|
+
describe: async () => {
|
|
83
|
+
const read = await readCurrentLocation(client, call);
|
|
84
|
+
const current = read.ok && Array.isArray(read.data?.regular_hours?.periods) ? read.data.regular_hours.periods : null;
|
|
85
|
+
return [
|
|
86
|
+
mdSection('Current regular hours', current ? gbpPeriodLines(current, 'No regular hours are saved now.') : locationReadNote(read.ok ? 'no hours returned' : read.error)),
|
|
87
|
+
mdSection('Regular hours to set', [gbpPeriodLines(call.regular_hours?.periods, 'No opening periods were sent.'), '', GBP_CLOSED_DAYS_NOTE, '', mdKeyValue(locationRows(call))].join('\n')),
|
|
88
|
+
'This replaces the regular opening hours on the public Google Business profile. Nothing is sent until you confirm, and the edit stays off until location edits are switched on.',
|
|
89
|
+
].join('\n\n');
|
|
90
|
+
},
|
|
91
|
+
run: async () => {
|
|
92
|
+
const result = await client.updateGoogleBusinessHours(omitKeys(call, ['action', 'confirm', 'preview_id']));
|
|
93
|
+
return result.success ? 'Google Business hours updated.' : (result.error || 'Google Business hours were not updated.');
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -85,6 +85,8 @@ export const manageGoogleBusinessMediaTool = {
|
|
|
85
85
|
['Resource name', code(String(item.name))],
|
|
86
86
|
['Type', item.mediaFormat === 'VIDEO' ? 'video' : 'photo'],
|
|
87
87
|
['Category', item.category || 'uncategorised'],
|
|
88
|
+
['Image', item.googleUrl || item.thumbnailUrl || undefined],
|
|
89
|
+
['Added', item.createTime || undefined],
|
|
88
90
|
...locationRows(call),
|
|
89
91
|
]))
|
|
90
92
|
: [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { code, mdKeyValue, mdQuote, mdSection } from '../lib/format.js';
|
|
3
|
-
import {
|
|
3
|
+
import { reviewNameFromListItem, reviewReplyComment } from '../lib/google-business-review-name.js';
|
|
4
|
+
import { omitKeys, previewThenConfirm, readForPreview, validateArgs } from '../lib/tool-runtime.js';
|
|
4
5
|
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
6
|
const LEGACY_LOCATION = {
|
|
6
7
|
workspace_id: z.string().optional(),
|
|
@@ -11,6 +12,31 @@ const LEGACY_LOCATION = {
|
|
|
11
12
|
function payloadOf(input) {
|
|
12
13
|
return omitKeys(input, ['action', 'confirm', 'preview_id']);
|
|
13
14
|
}
|
|
15
|
+
async function lookupReview(client, call) {
|
|
16
|
+
const read = await readForPreview(() => client.listGoogleBusinessReviews({
|
|
17
|
+
workspace_id: call.workspace_id,
|
|
18
|
+
account_id: call.account_id,
|
|
19
|
+
location_id: call.location_id,
|
|
20
|
+
limit: 200,
|
|
21
|
+
}));
|
|
22
|
+
if (!read.ok || !Array.isArray(read.data?.reviews))
|
|
23
|
+
return null;
|
|
24
|
+
const wanted = String(call.review_name || '');
|
|
25
|
+
return read.data.reviews.find((review) => reviewNameFromListItem(review) === wanted || review?.name === wanted) || null;
|
|
26
|
+
}
|
|
27
|
+
function reviewPreviewRows(call, review) {
|
|
28
|
+
if (!review)
|
|
29
|
+
return [['Review', code(String(call.review_name))], ...locationRows(call)];
|
|
30
|
+
const existing = reviewReplyComment(review);
|
|
31
|
+
return [
|
|
32
|
+
['Reviewer', review.reviewer?.displayName || 'Anonymous'],
|
|
33
|
+
['Rating', review.starRating ? `${review.starRating} stars` : 'unrated'],
|
|
34
|
+
['Review', review.comment ? String(review.comment).replace(/\s+/g, ' ').trim() : '(rating only)'],
|
|
35
|
+
['Existing reply', existing || (review.reviewReply ? 'replied' : 'none')],
|
|
36
|
+
['Review', code(String(call.review_name))],
|
|
37
|
+
...locationRows(call),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
14
40
|
function locationRows(input) {
|
|
15
41
|
return [
|
|
16
42
|
['Account ID', input.account_id !== undefined ? code(input.account_id) : undefined],
|
|
@@ -20,13 +46,13 @@ function locationRows(input) {
|
|
|
20
46
|
}
|
|
21
47
|
export const manageGoogleBusinessReviewTool = {
|
|
22
48
|
name: 'manage_google_business_review',
|
|
23
|
-
description: 'Act on Google Business Profile reviews. action=suggest_reply (star_rating, optional review_text): short, brand-aware AI reply suggestions; uses the AI Caption Assist allowance and never posts. action=reply (review_name, comment): post or update the owner reply. action=delete_reply (review_name): delete the owner reply. reply and delete_reply use preview then confirm: call without confirm to get a preview and preview_id (it repeats the review name, location, and exact reply text; show the reviewer, rating, and review text
|
|
49
|
+
description: 'Act on Google Business Profile reviews. action=suggest_reply (star_rating, optional review_text): short, brand-aware AI reply suggestions; uses the AI Caption Assist allowance and never posts. action=reply (review_name, comment): post or update the owner reply. action=delete_reply (review_name): delete the owner reply. reply and delete_reply use preview then confirm: call without confirm to get a preview and preview_id (it repeats the review name, location, and exact reply text; show the reviewer, rating, and review text alongside it), then call again with confirm=true and that preview_id.',
|
|
24
50
|
inputSchema: z.object({
|
|
25
51
|
action: z.enum(['suggest_reply', 'reply', 'delete_reply']).describe('suggest_reply, reply, or delete_reply.'),
|
|
26
52
|
workspace_id: z.string().optional().describe('Filter to a workspace ID from whoami.'),
|
|
27
53
|
account_id: z.number().int().positive().optional().describe('Google Business account ID from list_accounts (optional brand voice context for suggest_reply).'),
|
|
28
54
|
location_id: z.string().optional().describe(LOCATION_ID_DESCRIPTION),
|
|
29
|
-
review_name: z.string().min(1).optional().describe('reply and delete_reply:
|
|
55
|
+
review_name: z.string().min(1).optional().describe('reply and delete_reply: review_name from list_google_business_reviews.'),
|
|
30
56
|
comment: z.string().min(1).max(4096).optional().describe('reply: exact owner reply text to post.'),
|
|
31
57
|
review_text: z.string().optional().describe('suggest_reply: review text. Leave empty for rating-only reviews.'),
|
|
32
58
|
star_rating: z.number().min(1).max(5).optional().describe('suggest_reply: review rating from 1 to 5.'),
|
|
@@ -74,7 +100,7 @@ export const manageGoogleBusinessReviewTool = {
|
|
|
74
100
|
legacyRefusal: 'Refusing to delete a Google review reply without confirm=true after explicit user confirmation.',
|
|
75
101
|
ctx,
|
|
76
102
|
describe: async () => [
|
|
77
|
-
mdSection('Review', mdKeyValue(
|
|
103
|
+
mdSection('Review', mdKeyValue(reviewPreviewRows(call, await lookupReview(client, call)))),
|
|
78
104
|
'This deletes the owner reply from this review on Google. The review itself stays.',
|
|
79
105
|
].join('\n\n'),
|
|
80
106
|
run: async () => {
|
|
@@ -91,7 +117,7 @@ export const manageGoogleBusinessReviewTool = {
|
|
|
91
117
|
legacyRefusal: 'Refusing to post a Google review reply without confirm=true after explicit user confirmation.',
|
|
92
118
|
ctx,
|
|
93
119
|
describe: async () => [
|
|
94
|
-
mdSection('Review', mdKeyValue(
|
|
120
|
+
mdSection('Review', mdKeyValue(reviewPreviewRows(call, await lookupReview(client, call)))),
|
|
95
121
|
mdSection('Owner reply to post', mdQuote(String(call.comment ?? ''))),
|
|
96
122
|
'This posts publicly on Google as the business owner and replaces any existing owner reply on this review.',
|
|
97
123
|
].join('\n\n'),
|
|
@@ -0,0 +1,74 @@
|
|
|
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 Place = {
|
|
5
|
+
place_id: string;
|
|
6
|
+
place_name: string;
|
|
7
|
+
};
|
|
8
|
+
type UpdateInput = {
|
|
9
|
+
action: 'update';
|
|
10
|
+
workspace_id?: string;
|
|
11
|
+
account_id?: number;
|
|
12
|
+
location_id?: string;
|
|
13
|
+
business_type?: 'CUSTOMER_LOCATION_ONLY' | 'CUSTOMER_AND_BUSINESS_LOCATION';
|
|
14
|
+
region_code?: string;
|
|
15
|
+
places?: Place[];
|
|
16
|
+
clear_storefront_address?: boolean;
|
|
17
|
+
confirm?: boolean;
|
|
18
|
+
preview_id?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const manageGoogleBusinessServiceAreaTool: {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: z.ZodObject<{
|
|
24
|
+
action: z.ZodEnum<["update"]>;
|
|
25
|
+
workspace_id: z.ZodOptional<z.ZodString>;
|
|
26
|
+
account_id: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
location_id: z.ZodOptional<z.ZodString>;
|
|
28
|
+
business_type: z.ZodOptional<z.ZodEnum<["CUSTOMER_LOCATION_ONLY", "CUSTOMER_AND_BUSINESS_LOCATION"]>>;
|
|
29
|
+
region_code: z.ZodOptional<z.ZodString>;
|
|
30
|
+
places: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
31
|
+
place_id: z.ZodString;
|
|
32
|
+
place_name: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
place_id: string;
|
|
35
|
+
place_name: string;
|
|
36
|
+
}, {
|
|
37
|
+
place_id: string;
|
|
38
|
+
place_name: string;
|
|
39
|
+
}>, "many">>;
|
|
40
|
+
clear_storefront_address: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
preview_id: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
action: "update";
|
|
45
|
+
account_id?: number | undefined;
|
|
46
|
+
workspace_id?: string | undefined;
|
|
47
|
+
confirm?: boolean | undefined;
|
|
48
|
+
preview_id?: string | undefined;
|
|
49
|
+
location_id?: string | undefined;
|
|
50
|
+
region_code?: string | undefined;
|
|
51
|
+
places?: {
|
|
52
|
+
place_id: string;
|
|
53
|
+
place_name: string;
|
|
54
|
+
}[] | undefined;
|
|
55
|
+
business_type?: "CUSTOMER_LOCATION_ONLY" | "CUSTOMER_AND_BUSINESS_LOCATION" | undefined;
|
|
56
|
+
clear_storefront_address?: boolean | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
action: "update";
|
|
59
|
+
account_id?: number | undefined;
|
|
60
|
+
workspace_id?: string | undefined;
|
|
61
|
+
confirm?: boolean | undefined;
|
|
62
|
+
preview_id?: string | undefined;
|
|
63
|
+
location_id?: string | undefined;
|
|
64
|
+
region_code?: string | undefined;
|
|
65
|
+
places?: {
|
|
66
|
+
place_id: string;
|
|
67
|
+
place_name: string;
|
|
68
|
+
}[] | undefined;
|
|
69
|
+
business_type?: "CUSTOMER_LOCATION_ONLY" | "CUSTOMER_AND_BUSINESS_LOCATION" | undefined;
|
|
70
|
+
clear_storefront_address?: boolean | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
execute(client: PosterlyClient, input: UpdateInput, ctx: ToolContext): Promise<string>;
|
|
73
|
+
};
|
|
74
|
+
export {};
|