posterly-mcp-server 0.62.1 → 0.64.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 +15 -2
- package/dist/lib/api-client.d.ts +23 -1
- package/dist/lib/api-client.js +26 -1
- package/dist/lib/format.d.ts +13 -0
- package/dist/lib/format.js +42 -0
- package/dist/lib/gbp-location-preview.d.ts +39 -3
- package/dist/lib/gbp-location-preview.js +418 -3
- package/dist/lib/tool-registry.d.ts +1 -1
- package/dist/lib/tool-registry.js +1 -1
- package/dist/lib/tool-runtime.d.ts +3 -1
- package/dist/lib/tool-runtime.js +7 -2
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/tools/find-slot.js +14 -7
- package/dist/tools/list-brands.d.ts +2 -2
- package/dist/tools/list-comments.d.ts +2 -2
- package/dist/tools/list-conversations.d.ts +2 -2
- package/dist/tools/list-google-business-locations.d.ts +32 -0
- package/dist/tools/list-google-business-locations.js +31 -21
- package/dist/tools/manage-google-business-location.d.ts +193 -4
- package/dist/tools/manage-google-business-location.js +278 -20
- package/dist/tools/whoami.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/tool-registry.json +114 -6
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Preview text for Google Business location edits,
|
|
3
|
-
* npm MCP servers.
|
|
4
|
-
* profile, so the preview
|
|
2
|
+
* Preview and output text for Google Business location reads and edits,
|
|
3
|
+
* shared by the hosted and npm MCP servers. Every write replaces a field
|
|
4
|
+
* group on the public profile, so the preview shows what is on the listing
|
|
5
|
+
* now next to what will be sent.
|
|
5
6
|
*/
|
|
6
7
|
export const GBP_CLOSED_DAYS_NOTE = 'A day with no opening period shows as closed on Google.';
|
|
8
|
+
export const GBP_TITLE_SUSPENSION_WARNING = 'Warning: Google may hold a business name change for review, and a wrong or keyword-stuffed name can get the listing suspended. If Google rejects this edit, posterly will not retry it automatically.';
|
|
9
|
+
export const GBP_PRIMARY_CATEGORY_SUSPENSION_WARNING = 'Warning: Google may hold a primary category change for review, and a wrong primary category can get the listing suspended. If Google rejects this edit, posterly will not retry it automatically.';
|
|
10
|
+
export const GBP_CLEAR_SERVICES_WARNING = 'Warning: Sending an empty service_items list clears all saved services from the public Google Business profile.';
|
|
11
|
+
export const GBP_LIVE_LISTING_CHANGED_ERROR = 'The live Google Business listing changed since this preview was created (or the arguments do not match the preview), so nothing was changed. Call again without confirm to get a fresh preview.';
|
|
12
|
+
const GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES = 9;
|
|
13
|
+
const GBP_PREVIEW_MAX_ADDITIONAL_PHONES = 2;
|
|
14
|
+
function isRecord(value) {
|
|
15
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
16
|
+
}
|
|
7
17
|
export function gbpPeriodLines(periods, empty) {
|
|
8
18
|
const rows = Array.isArray(periods) ? periods : [];
|
|
9
19
|
if (!rows.length)
|
|
@@ -25,3 +35,408 @@ export function gbpCurrentAttributesFor(current, requested) {
|
|
|
25
35
|
const names = new Set((Array.isArray(requested) ? requested : []).map((attribute) => String(attribute?.name ?? '')));
|
|
26
36
|
return (Array.isArray(current) ? current : []).filter((attribute) => names.has(String(attribute?.name ?? '')));
|
|
27
37
|
}
|
|
38
|
+
export function gbpTextValueLine(value, empty) {
|
|
39
|
+
if (typeof value === 'string' && value.trim())
|
|
40
|
+
return value.trim();
|
|
41
|
+
return empty;
|
|
42
|
+
}
|
|
43
|
+
function extractCategoryName(item) {
|
|
44
|
+
if (typeof item === 'string')
|
|
45
|
+
return item.trim();
|
|
46
|
+
if (isRecord(item) && typeof item.name === 'string')
|
|
47
|
+
return item.name.trim();
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
function formatCategoryItem(item) {
|
|
51
|
+
if (typeof item === 'string' && item.trim())
|
|
52
|
+
return item.trim();
|
|
53
|
+
if (isRecord(item)) {
|
|
54
|
+
const name = typeof item.name === 'string' ? item.name.trim() : '';
|
|
55
|
+
const display = typeof item.display_name === 'string' && item.display_name.trim()
|
|
56
|
+
? item.display_name.trim()
|
|
57
|
+
: typeof item.displayName === 'string' && item.displayName.trim()
|
|
58
|
+
? item.displayName.trim()
|
|
59
|
+
: '';
|
|
60
|
+
if (display && name)
|
|
61
|
+
return `${display} (${name})`;
|
|
62
|
+
if (name)
|
|
63
|
+
return name;
|
|
64
|
+
if (display)
|
|
65
|
+
return display;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
export function hasExplicitAdditionalCategories(requested) {
|
|
70
|
+
if (!isRecord(requested))
|
|
71
|
+
return false;
|
|
72
|
+
const root = isRecord(requested.categories) ? requested.categories : requested;
|
|
73
|
+
const hasKey = Object.prototype.hasOwnProperty.call(root, 'additional_categories') ||
|
|
74
|
+
Object.prototype.hasOwnProperty.call(root, 'additionalCategories');
|
|
75
|
+
const raw = root.additional_categories ?? root.additionalCategories;
|
|
76
|
+
return hasKey && raw !== undefined;
|
|
77
|
+
}
|
|
78
|
+
export function resolveGbpCategoriesForWrite(requested, currentCategories) {
|
|
79
|
+
const root = isRecord(requested)
|
|
80
|
+
? (isRecord(requested.categories) ? requested.categories : requested)
|
|
81
|
+
: {};
|
|
82
|
+
const primary = extractCategoryName(root.primary_category ?? root.primaryCategory);
|
|
83
|
+
const explicitProvided = hasExplicitAdditionalCategories(requested);
|
|
84
|
+
if (!primary) {
|
|
85
|
+
throw new Error('primary_category is required (a category resource name such as categories/gcid:coffee_shop). Nothing was changed.');
|
|
86
|
+
}
|
|
87
|
+
const currentRoot = isRecord(currentCategories)
|
|
88
|
+
? (isRecord(currentCategories.categories) ? currentCategories.categories : currentCategories)
|
|
89
|
+
: null;
|
|
90
|
+
const currentAdditionalRaw = currentRoot && Array.isArray(currentRoot.additional_categories ?? currentRoot.additionalCategories)
|
|
91
|
+
? (currentRoot.additional_categories ?? currentRoot.additionalCategories)
|
|
92
|
+
: [];
|
|
93
|
+
const currentPrimaryRaw = currentRoot ? (currentRoot.primary_category ?? currentRoot.primaryCategory) : null;
|
|
94
|
+
const currentPrimaryName = extractCategoryName(currentPrimaryRaw);
|
|
95
|
+
const currentPrimaryLabel = currentPrimaryName ? (formatCategoryItem(currentPrimaryRaw) || currentPrimaryName) : null;
|
|
96
|
+
const currentAdditionalEntries = currentAdditionalRaw
|
|
97
|
+
.map((item) => ({
|
|
98
|
+
name: extractCategoryName(item),
|
|
99
|
+
label: formatCategoryItem(item) || extractCategoryName(item),
|
|
100
|
+
}))
|
|
101
|
+
.filter((entry) => Boolean(entry.name));
|
|
102
|
+
if (explicitProvided && Array.isArray(root.additional_categories ?? root.additionalCategories)) {
|
|
103
|
+
const rawExplicit = (root.additional_categories ?? root.additionalCategories);
|
|
104
|
+
if (rawExplicit.length > GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES) {
|
|
105
|
+
throw new Error(`additional_categories can contain at most ${GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES} categories (got ${rawExplicit.length}). Nothing was changed.`);
|
|
106
|
+
}
|
|
107
|
+
const explicit = rawExplicit.map((item) => extractCategoryName(item));
|
|
108
|
+
if (explicit.some((name) => !name)) {
|
|
109
|
+
throw new Error('Each item in additional_categories must be a category resource name such as categories/gcid:coffee_shop. Nothing was changed.');
|
|
110
|
+
}
|
|
111
|
+
const kept = new Set([primary, ...explicit]);
|
|
112
|
+
const removedEntries = currentAdditionalEntries.filter((entry) => !kept.has(entry.name));
|
|
113
|
+
const primaryRemoved = Boolean(currentPrimaryName) && !kept.has(currentPrimaryName);
|
|
114
|
+
return {
|
|
115
|
+
primary_category: primary,
|
|
116
|
+
additional_categories: explicit,
|
|
117
|
+
carried_over_additional_categories: Boolean(root.carried_over_additional_categories === true ||
|
|
118
|
+
root.carriedOverAdditionalCategories === true),
|
|
119
|
+
explicit_additional_categories: true,
|
|
120
|
+
removed_additional_categories: removedEntries.map((entry) => entry.name),
|
|
121
|
+
removed_additional_category_labels: removedEntries.map((entry) => entry.label),
|
|
122
|
+
removed_primary_category_label: primaryRemoved ? currentPrimaryLabel : null,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (explicitProvided) {
|
|
126
|
+
throw new Error('additional_categories must be a list of category resource names. Nothing was changed.');
|
|
127
|
+
}
|
|
128
|
+
const carried = currentAdditionalEntries
|
|
129
|
+
.map((entry) => entry.name)
|
|
130
|
+
.filter((name) => name !== primary)
|
|
131
|
+
.slice(0, GBP_PREVIEW_MAX_ADDITIONAL_CATEGORIES);
|
|
132
|
+
const primaryRemoved = Boolean(currentPrimaryName) && currentPrimaryName !== primary && !carried.includes(currentPrimaryName);
|
|
133
|
+
return {
|
|
134
|
+
primary_category: primary,
|
|
135
|
+
additional_categories: carried,
|
|
136
|
+
carried_over_additional_categories: carried.length > 0,
|
|
137
|
+
explicit_additional_categories: false,
|
|
138
|
+
removed_additional_categories: [],
|
|
139
|
+
removed_additional_category_labels: [],
|
|
140
|
+
removed_primary_category_label: primaryRemoved ? currentPrimaryLabel : null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function gbpCategoriesLines(categories, empty) {
|
|
144
|
+
if (!isRecord(categories))
|
|
145
|
+
return empty;
|
|
146
|
+
const root = isRecord(categories.categories) ? categories.categories : categories;
|
|
147
|
+
const primary = formatCategoryItem(root.primary_category ?? root.primaryCategory);
|
|
148
|
+
const additionalRaw = Array.isArray(root.additional_categories ?? root.additionalCategories)
|
|
149
|
+
? (root.additional_categories ?? root.additionalCategories)
|
|
150
|
+
: [];
|
|
151
|
+
const additional = additionalRaw
|
|
152
|
+
.map((item) => formatCategoryItem(item))
|
|
153
|
+
.filter((item) => Boolean(item));
|
|
154
|
+
if (!primary && additional.length === 0)
|
|
155
|
+
return empty;
|
|
156
|
+
return [
|
|
157
|
+
`- Primary category: ${primary || 'not set'}`,
|
|
158
|
+
`- Additional categories: ${additional.length > 0 ? additional.join(', ') : 'none'}`,
|
|
159
|
+
].join('\n');
|
|
160
|
+
}
|
|
161
|
+
export function gbpProposedCategoriesLines(requested, currentCategories) {
|
|
162
|
+
const resolved = resolveGbpCategoriesForWrite(requested, currentCategories);
|
|
163
|
+
const primary = resolved.primary_category || 'not set';
|
|
164
|
+
const additionalText = resolved.additional_categories.length > 0 ? resolved.additional_categories.join(', ') : 'none';
|
|
165
|
+
const lines = [
|
|
166
|
+
`- Primary category: ${primary}`,
|
|
167
|
+
resolved.explicit_additional_categories
|
|
168
|
+
? `- Additional categories: ${additionalText}`
|
|
169
|
+
: `- Additional categories: ${resolved.additional_categories.length > 0 ? `${additionalText} (carried over from current listing)` : 'none'}`,
|
|
170
|
+
];
|
|
171
|
+
const removed = [
|
|
172
|
+
...resolved.removed_additional_category_labels,
|
|
173
|
+
...(resolved.removed_primary_category_label ? [resolved.removed_primary_category_label] : []),
|
|
174
|
+
];
|
|
175
|
+
if (removed.length > 0) {
|
|
176
|
+
lines.push(`- Removed categories: ${removed.join(', ')}`);
|
|
177
|
+
}
|
|
178
|
+
return lines.join('\n');
|
|
179
|
+
}
|
|
180
|
+
export function gbpPhoneNumbersLines(phones, empty) {
|
|
181
|
+
if (!isRecord(phones))
|
|
182
|
+
return empty;
|
|
183
|
+
const root = isRecord(phones.phone_numbers ?? phones.phoneNumbers)
|
|
184
|
+
? (phones.phone_numbers ?? phones.phoneNumbers)
|
|
185
|
+
: phones;
|
|
186
|
+
const primary = typeof (root.primary_phone ?? root.primaryPhone) === 'string'
|
|
187
|
+
? String(root.primary_phone ?? root.primaryPhone).trim()
|
|
188
|
+
: '';
|
|
189
|
+
const additionalRaw = Array.isArray(root.additional_phones ?? root.additionalPhones)
|
|
190
|
+
? (root.additional_phones ?? root.additionalPhones)
|
|
191
|
+
: [];
|
|
192
|
+
const additional = additionalRaw
|
|
193
|
+
.filter((item) => typeof item === 'string' && item.trim().length > 0)
|
|
194
|
+
.map((item) => item.trim());
|
|
195
|
+
if (!primary && additional.length === 0)
|
|
196
|
+
return empty;
|
|
197
|
+
return [
|
|
198
|
+
`- Primary phone: ${primary || 'not set'}`,
|
|
199
|
+
`- Additional phones: ${additional.length > 0 ? additional.join(', ') : 'none'}`,
|
|
200
|
+
].join('\n');
|
|
201
|
+
}
|
|
202
|
+
export function hasExplicitAdditionalPhones(requested) {
|
|
203
|
+
if (!isRecord(requested))
|
|
204
|
+
return false;
|
|
205
|
+
const root = isRecord(requested.phone_numbers ?? requested.phoneNumbers)
|
|
206
|
+
? (requested.phone_numbers ?? requested.phoneNumbers)
|
|
207
|
+
: requested;
|
|
208
|
+
const hasKey = Object.prototype.hasOwnProperty.call(root, 'additional_phones') ||
|
|
209
|
+
Object.prototype.hasOwnProperty.call(root, 'additionalPhones');
|
|
210
|
+
const raw = root.additional_phones ?? root.additionalPhones;
|
|
211
|
+
return hasKey && raw !== undefined;
|
|
212
|
+
}
|
|
213
|
+
export function resolveGbpPhoneNumbersForWrite(requested, currentPhones) {
|
|
214
|
+
const root = isRecord(requested)
|
|
215
|
+
? (isRecord(requested.phone_numbers ?? requested.phoneNumbers)
|
|
216
|
+
? (requested.phone_numbers ?? requested.phoneNumbers)
|
|
217
|
+
: requested)
|
|
218
|
+
: {};
|
|
219
|
+
const primary = typeof (root.primary_phone ?? root.primaryPhone) === 'string'
|
|
220
|
+
? String(root.primary_phone ?? root.primaryPhone).trim()
|
|
221
|
+
: '';
|
|
222
|
+
const explicitProvided = hasExplicitAdditionalPhones(requested);
|
|
223
|
+
const currentRoot = isRecord(currentPhones)
|
|
224
|
+
? (isRecord(currentPhones.phone_numbers ?? currentPhones.phoneNumbers)
|
|
225
|
+
? (currentPhones.phone_numbers ?? currentPhones.phoneNumbers)
|
|
226
|
+
: currentPhones)
|
|
227
|
+
: null;
|
|
228
|
+
const currentAdditional = currentRoot && Array.isArray(currentRoot.additional_phones ?? currentRoot.additionalPhones)
|
|
229
|
+
? (currentRoot.additional_phones ?? currentRoot.additionalPhones)
|
|
230
|
+
.filter((item) => typeof item === 'string' && item.trim().length > 0)
|
|
231
|
+
.map((item) => item.trim())
|
|
232
|
+
: [];
|
|
233
|
+
if (explicitProvided && Array.isArray(root.additional_phones ?? root.additionalPhones)) {
|
|
234
|
+
const rawAdditional = (root.additional_phones ?? root.additionalPhones);
|
|
235
|
+
if (rawAdditional.length > GBP_PREVIEW_MAX_ADDITIONAL_PHONES) {
|
|
236
|
+
throw new Error(`additional_phones can contain at most ${GBP_PREVIEW_MAX_ADDITIONAL_PHONES} phone numbers (got ${rawAdditional.length}). Nothing was changed.`);
|
|
237
|
+
}
|
|
238
|
+
if (rawAdditional.some((item) => typeof item !== 'string' || !item.trim())) {
|
|
239
|
+
throw new Error('Each item in additional_phones must be a non-empty phone number string. Nothing was changed.');
|
|
240
|
+
}
|
|
241
|
+
const additional = rawAdditional.map((item) => item.trim());
|
|
242
|
+
const keptDigits = new Set([
|
|
243
|
+
primary.replace(/\D/g, ''),
|
|
244
|
+
...additional.map((phone) => phone.replace(/\D/g, '')),
|
|
245
|
+
]);
|
|
246
|
+
const removed = currentAdditional.filter((phone) => !keptDigits.has(phone.replace(/\D/g, '')));
|
|
247
|
+
return {
|
|
248
|
+
primary_phone: primary,
|
|
249
|
+
additional_phones: additional,
|
|
250
|
+
carried_over_additional_phones: Boolean(root.carried_over_additional_phones === true ||
|
|
251
|
+
root.carriedOverAdditionalPhones === true),
|
|
252
|
+
explicit_additional_phones: true,
|
|
253
|
+
removed_additional_phones: removed,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (explicitProvided) {
|
|
257
|
+
throw new Error('additional_phones must be a list of phone numbers. Nothing was changed.');
|
|
258
|
+
}
|
|
259
|
+
const primaryDigits = primary.replace(/\D/g, '');
|
|
260
|
+
const carried = currentAdditional
|
|
261
|
+
.filter((phone) => phone.replace(/\D/g, '') !== primaryDigits)
|
|
262
|
+
.slice(0, GBP_PREVIEW_MAX_ADDITIONAL_PHONES);
|
|
263
|
+
return {
|
|
264
|
+
primary_phone: primary,
|
|
265
|
+
additional_phones: carried,
|
|
266
|
+
carried_over_additional_phones: carried.length > 0,
|
|
267
|
+
explicit_additional_phones: false,
|
|
268
|
+
removed_additional_phones: [],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
export function gbpProposedPhoneNumbersLines(requested, currentPhones) {
|
|
272
|
+
const resolved = resolveGbpPhoneNumbersForWrite(requested, currentPhones);
|
|
273
|
+
const primary = resolved.primary_phone || 'not set';
|
|
274
|
+
if (!resolved.explicit_additional_phones) {
|
|
275
|
+
return [
|
|
276
|
+
`- Primary phone: ${primary}`,
|
|
277
|
+
`- Additional phones: ${resolved.additional_phones.length > 0 ? `${resolved.additional_phones.join(', ')} (carried over from current listing)` : 'none'}`,
|
|
278
|
+
].join('\n');
|
|
279
|
+
}
|
|
280
|
+
const lines = [
|
|
281
|
+
`- Primary phone: ${primary}`,
|
|
282
|
+
`- Additional phones: ${resolved.additional_phones.length > 0 ? resolved.additional_phones.join(', ') : 'none'}`,
|
|
283
|
+
];
|
|
284
|
+
if (resolved.removed_additional_phones.length > 0) {
|
|
285
|
+
lines.push(`- Removed phones: ${resolved.removed_additional_phones.join(', ')}`);
|
|
286
|
+
}
|
|
287
|
+
return lines.join('\n');
|
|
288
|
+
}
|
|
289
|
+
function formatMoney(price) {
|
|
290
|
+
if (!isRecord(price))
|
|
291
|
+
return null;
|
|
292
|
+
const currency = typeof (price.currency_code ?? price.currencyCode) === 'string'
|
|
293
|
+
? String(price.currency_code ?? price.currencyCode).trim().toUpperCase()
|
|
294
|
+
: '';
|
|
295
|
+
if (!currency)
|
|
296
|
+
return null;
|
|
297
|
+
const units = price.units !== undefined && price.units !== null ? String(price.units) : '0';
|
|
298
|
+
const nanos = typeof price.nanos === 'number' && price.nanos > 0
|
|
299
|
+
? `.${String(Math.round(price.nanos / 10_000_000)).padStart(2, '0')}`
|
|
300
|
+
: '';
|
|
301
|
+
return `${currency} ${units}${nanos}`;
|
|
302
|
+
}
|
|
303
|
+
export function gbpServiceItemLines(items, empty) {
|
|
304
|
+
const list = Array.isArray(items)
|
|
305
|
+
? items
|
|
306
|
+
: isRecord(items) && Array.isArray(items.service_items ?? items.serviceItems)
|
|
307
|
+
? (items.service_items ?? items.serviceItems)
|
|
308
|
+
: [];
|
|
309
|
+
if (!list.length)
|
|
310
|
+
return empty;
|
|
311
|
+
return list
|
|
312
|
+
.map((raw) => {
|
|
313
|
+
if (!isRecord(raw))
|
|
314
|
+
return '- ?';
|
|
315
|
+
const priceText = formatMoney(raw.price);
|
|
316
|
+
const priceSuffix = priceText ? ` [${priceText}]` : '';
|
|
317
|
+
const structured = isRecord(raw.structured_service_item ?? raw.structuredServiceItem)
|
|
318
|
+
? (raw.structured_service_item ?? raw.structuredServiceItem)
|
|
319
|
+
: null;
|
|
320
|
+
if (structured) {
|
|
321
|
+
const id = String(structured.service_type_id ?? structured.serviceTypeId ?? '?');
|
|
322
|
+
const desc = typeof structured.description === 'string' && structured.description.trim()
|
|
323
|
+
? ` (${structured.description.trim()})`
|
|
324
|
+
: '';
|
|
325
|
+
return `- Structured: ${id}${desc}${priceSuffix}`;
|
|
326
|
+
}
|
|
327
|
+
const freeForm = isRecord(raw.free_form_service_item ?? raw.freeFormServiceItem)
|
|
328
|
+
? (raw.free_form_service_item ?? raw.freeFormServiceItem)
|
|
329
|
+
: null;
|
|
330
|
+
if (freeForm) {
|
|
331
|
+
const category = String(freeForm.category ?? '?');
|
|
332
|
+
const label = isRecord(freeForm.label) ? freeForm.label : freeForm;
|
|
333
|
+
const name = String(label.display_name ?? label.displayName ?? '?');
|
|
334
|
+
const desc = typeof label.description === 'string' && label.description.trim()
|
|
335
|
+
? ` - ${label.description.trim()}`
|
|
336
|
+
: '';
|
|
337
|
+
return `- Free-form: ${name} (${category})${desc}${priceSuffix}`;
|
|
338
|
+
}
|
|
339
|
+
return '- ?';
|
|
340
|
+
})
|
|
341
|
+
.join('\n');
|
|
342
|
+
}
|
|
343
|
+
export function gbpProposedServiceItemLines(items, empty) {
|
|
344
|
+
const list = Array.isArray(items)
|
|
345
|
+
? items
|
|
346
|
+
: isRecord(items) && Array.isArray(items.service_items ?? items.serviceItems)
|
|
347
|
+
? (items.service_items ?? items.serviceItems)
|
|
348
|
+
: null;
|
|
349
|
+
if (list && list.length === 0) {
|
|
350
|
+
return 'Empty list (clears all saved services from the listing).';
|
|
351
|
+
}
|
|
352
|
+
return gbpServiceItemLines(items, empty);
|
|
353
|
+
}
|
|
354
|
+
export function formatGbpLocationProfile(result) {
|
|
355
|
+
if (result?.enabled !== true) {
|
|
356
|
+
return 'Google Business location edits are switched off. Nothing was read from Google.';
|
|
357
|
+
}
|
|
358
|
+
const periods = Array.isArray(result.regular_hours?.periods) ? result.regular_hours.periods : [];
|
|
359
|
+
const attributes = Array.isArray(result.attributes) ? result.attributes : [];
|
|
360
|
+
const description = typeof result.profile?.description === 'string'
|
|
361
|
+
? result.profile.description
|
|
362
|
+
: typeof result.description === 'string'
|
|
363
|
+
? result.description
|
|
364
|
+
: '';
|
|
365
|
+
const pendingNote = result.has_pending_edits === true || result.review_status === 'pending Google review'
|
|
366
|
+
? 'pending Google review'
|
|
367
|
+
: 'none';
|
|
368
|
+
return [
|
|
369
|
+
'## Google Business location',
|
|
370
|
+
[
|
|
371
|
+
'### Location',
|
|
372
|
+
[
|
|
373
|
+
result.account_id != null ? `- **Account ID**: \`${result.account_id}\`` : '',
|
|
374
|
+
result.location ? `- **Location**: \`${String(result.location)}\`` : '',
|
|
375
|
+
result.title ? `- **Title**: ${String(result.title)}` : '- **Title**: Not set.',
|
|
376
|
+
result.website_uri ? `- **Website**: ${String(result.website_uri)}` : '- **Website**: Not set.',
|
|
377
|
+
`- **Pending edits**: ${pendingNote}`,
|
|
378
|
+
result.google_updated_check === 'failed'
|
|
379
|
+
? '- **Google-suggested updates**: could not be checked right now. The rest of this profile is current. Retry with include_google_updated to see the Google error.'
|
|
380
|
+
: '',
|
|
381
|
+
].filter(Boolean).join('\n'),
|
|
382
|
+
].join('\n'),
|
|
383
|
+
['### Description', description ? description : 'No description saved.'].join('\n'),
|
|
384
|
+
['### Categories', gbpCategoriesLines(result.categories, 'No categories saved.')].join('\n'),
|
|
385
|
+
['### Phone numbers', gbpPhoneNumbersLines(result.phone_numbers, 'No phone numbers saved.')].join('\n'),
|
|
386
|
+
['### Services', gbpServiceItemLines(result.service_items, 'No services saved.')].join('\n'),
|
|
387
|
+
[
|
|
388
|
+
'### Regular hours',
|
|
389
|
+
periods.length
|
|
390
|
+
? periods
|
|
391
|
+
.map((period) => `- ${period.open_day} ${period.open_time} to ${period.close_day} ${period.close_time}`)
|
|
392
|
+
.join('\n')
|
|
393
|
+
: 'No regular hours saved.',
|
|
394
|
+
].join('\n'),
|
|
395
|
+
[
|
|
396
|
+
'### Attributes',
|
|
397
|
+
attributes.length
|
|
398
|
+
? attributes
|
|
399
|
+
.map((attribute) => `- ${attribute.name} (${attribute.value_type}): ${(attribute.values || []).join(', ')}`)
|
|
400
|
+
.join('\n')
|
|
401
|
+
: 'No attributes saved.',
|
|
402
|
+
].join('\n'),
|
|
403
|
+
].join('\n\n');
|
|
404
|
+
}
|
|
405
|
+
export function formatGbpCategoryCatalog(result) {
|
|
406
|
+
if (result?.enabled !== true) {
|
|
407
|
+
return 'Google Business location edits are switched off. Nothing was read from Google.';
|
|
408
|
+
}
|
|
409
|
+
const categories = Array.isArray(result.categories) ? result.categories : [];
|
|
410
|
+
const metaLines = [
|
|
411
|
+
result.region_code ? `- **Region**: \`${result.region_code}\`` : '',
|
|
412
|
+
result.language_code ? `- **Language**: \`${result.language_code}\`` : '',
|
|
413
|
+
result.view ? `- **View**: \`${result.view}\`` : '',
|
|
414
|
+
result.prefix ? `- **Prefix**: \`${result.prefix}\`` : '',
|
|
415
|
+
result.total_size != null ? `- **Total**: ${result.total_size}` : '',
|
|
416
|
+
result.next_page_token ? `- **Next page token**: \`${result.next_page_token}\`` : '',
|
|
417
|
+
].filter(Boolean);
|
|
418
|
+
const listText = categories.length
|
|
419
|
+
? categories
|
|
420
|
+
.map((cat) => {
|
|
421
|
+
const display = cat.display_name || cat.displayName || cat.name;
|
|
422
|
+
const serviceCount = Array.isArray(cat.service_types) ? cat.service_types.length : 0;
|
|
423
|
+
const extra = serviceCount > 0 ? ` (${serviceCount} structured service types)` : '';
|
|
424
|
+
return `- **${display}** (\`${cat.name}\`)${extra}`;
|
|
425
|
+
})
|
|
426
|
+
.join('\n')
|
|
427
|
+
: 'No matching Google Business categories found.';
|
|
428
|
+
return [
|
|
429
|
+
'## Google Business categories',
|
|
430
|
+
['### Query', metaLines.join('\n')].join('\n'),
|
|
431
|
+
['### Categories', listText].join('\n'),
|
|
432
|
+
].join('\n\n');
|
|
433
|
+
}
|
|
434
|
+
export function formatGbpLocationUpdateOutcome(fieldLabel, result) {
|
|
435
|
+
if (!result?.success) {
|
|
436
|
+
return result?.error || `Google Business ${fieldLabel} was not updated.`;
|
|
437
|
+
}
|
|
438
|
+
const pending = result.has_pending_edits === true || result.review_status === 'pending Google review';
|
|
439
|
+
return pending
|
|
440
|
+
? `Google Business ${fieldLabel} updated (pending Google review).`
|
|
441
|
+
: `Google Business ${fieldLabel} updated.`;
|
|
442
|
+
}
|
|
@@ -244,5 +244,5 @@ export declare function resolveCalledTool(registry: ToolRegistry, calledName: st
|
|
|
244
244
|
* all on by default, how to load fewer, and how preview then confirm works.
|
|
245
245
|
*/
|
|
246
246
|
/** Issue #1683: AI app signups onboard in the chat, and returning users are never asked again. */
|
|
247
|
-
export declare const ONBOARDING_INSTRUCTION = "Start each session with whoami. If onboarding.completed is false, run onboarding in this chat: ask what to call the user and their IANA timezone, save them with complete_onboarding, then offer create_connect_session for their first network (its link opens the network sign-in directly). Never send the user to /onboarding-v2, and never ask the onboarding questions again once onboarding.completed is true.";
|
|
247
|
+
export declare const ONBOARDING_INSTRUCTION = "Start each session with whoami. If onboarding.completed is false, run onboarding in this chat before scheduling anything: ask what to call the user and their IANA timezone (only the timezone when onboarding.instruction says so), save them with complete_onboarding, then offer create_connect_session for their first network (its link opens the network sign-in directly). Never send the user to /onboarding-v2, and never ask the onboarding questions again once onboarding.completed is true.";
|
|
248
248
|
export declare function toolsetInstructions(registry: ToolRegistry, surface: ToolSurface): string;
|
|
@@ -396,7 +396,7 @@ export function resolveCalledTool(registry, calledName) {
|
|
|
396
396
|
* all on by default, how to load fewer, and how preview then confirm works.
|
|
397
397
|
*/
|
|
398
398
|
/** Issue #1683: AI app signups onboard in the chat, and returning users are never asked again. */
|
|
399
|
-
export const ONBOARDING_INSTRUCTION = 'Start each session with whoami. If onboarding.completed is false, run onboarding in this chat: ask what to call the user and their IANA timezone, save them with complete_onboarding, then offer create_connect_session for their first network (its link opens the network sign-in directly). Never send the user to /onboarding-v2, and never ask the onboarding questions again once onboarding.completed is true.';
|
|
399
|
+
export const ONBOARDING_INSTRUCTION = 'Start each session with whoami. If onboarding.completed is false, run onboarding in this chat before scheduling anything: ask what to call the user and their IANA timezone (only the timezone when onboarding.instruction says so), save them with complete_onboarding, then offer create_connect_session for their first network (its link opens the network sign-in directly). Never send the user to /onboarding-v2, and never ask the onboarding questions again once onboarding.completed is true.';
|
|
400
400
|
export function toolsetInstructions(registry, surface) {
|
|
401
401
|
const sets = Object.entries(registry.toolsets)
|
|
402
402
|
.filter(([, set]) => !set.surfaces || set.surfaces.includes(surface))
|
|
@@ -45,8 +45,10 @@ export interface PreviewStep {
|
|
|
45
45
|
nonce: boolean;
|
|
46
46
|
/** The old tool's refusal when confirm is missing, for alias calls. */
|
|
47
47
|
legacyRefusal: string;
|
|
48
|
+
/** Optional custom refusal when verification fails with 'mismatch'. */
|
|
49
|
+
mismatchMessage?: string;
|
|
48
50
|
ctx: ToolContext;
|
|
49
|
-
/** What will change (may make one read request;
|
|
51
|
+
/** What will change (may make one read request; if it throws, no preview_id is issued). */
|
|
50
52
|
describe: () => Promise<string>;
|
|
51
53
|
run: () => Promise<string>;
|
|
52
54
|
}
|
package/dist/lib/tool-runtime.js
CHANGED
|
@@ -58,15 +58,20 @@ export async function previewThenConfirm(step) {
|
|
|
58
58
|
}
|
|
59
59
|
const binding = { userId: STDIO_PREVIEW_USER, tool: step.tool, action: step.action, args: canonicalArgs(args) };
|
|
60
60
|
if (args.confirm !== true) {
|
|
61
|
+
const body = await step.describe();
|
|
61
62
|
const previewId = ctx.previews.create(binding);
|
|
62
|
-
return formatPreview(
|
|
63
|
+
return formatPreview(body, previewId, step.tool);
|
|
63
64
|
}
|
|
64
65
|
const token = args.preview_id;
|
|
65
66
|
if (typeof token !== 'string' || !token)
|
|
66
67
|
throw new Error(previewFailureMessage('missing'));
|
|
67
68
|
const verified = ctx.previews.verify(token, binding);
|
|
68
|
-
if (!verified.ok)
|
|
69
|
+
if (!verified.ok) {
|
|
70
|
+
if (verified.reason === 'mismatch' && step.mismatchMessage) {
|
|
71
|
+
throw new Error(step.mismatchMessage);
|
|
72
|
+
}
|
|
69
73
|
throw new Error(previewFailureMessage(verified.reason));
|
|
74
|
+
}
|
|
70
75
|
if (step.nonce && !ctx.previews.claimOnce(token, verified.exp))
|
|
71
76
|
throw new Error(previewFailureMessage('used'));
|
|
72
77
|
return step.run();
|
package/dist/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const POSTERLY_MCP_VERSION = "0.
|
|
1
|
+
export declare const POSTERLY_MCP_VERSION = "0.64.0";
|
package/dist/lib/version.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
// tool set (minus the intentional pre-auth signup tools that only this stdio
|
|
6
6
|
// package exposes). `npm run check:mcp-parity` enforces both the version match
|
|
7
7
|
// and the tool-list match, and runs in the pre-commit hook.
|
|
8
|
-
export const POSTERLY_MCP_VERSION = '0.
|
|
8
|
+
export const POSTERLY_MCP_VERSION = '0.64.0';
|
package/dist/tools/find-slot.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { formatIsoTimestamp, mdEmpty, mdTable, mdTitle, slotLocalDate, slotTimeZoneNote, starGlyphs } from '../lib/format.js';
|
|
3
3
|
const SUGGESTED_BASIS_LABELS = {
|
|
4
4
|
yours: 'Based on your posts',
|
|
5
5
|
platform: 'Popular on this platform',
|
|
6
6
|
default: 'Good default',
|
|
7
7
|
};
|
|
8
|
+
const SLOT_SCHEDULE_HINT = 'Pass the UTC value to create_post as scheduled_at.';
|
|
9
|
+
const SLOT_UNKNOWN_TIMEZONE_HINT = 'Local time uses the timezone you passed, or, if you left it out, the saved timezone, then UTC.';
|
|
8
10
|
export const findSlotTool = {
|
|
9
11
|
name: 'find_available_slot',
|
|
10
|
-
description: 'Find available time slots for posting. Respects a 1-hour gap between posts and preferred hours (8am-10pm in the given timezone). Returns up to 10 slots.
|
|
12
|
+
description: 'Find available time slots for posting. Respects a 1-hour gap between posts and preferred hours (8am-10pm in the given timezone). Returns up to 10 slots. Without timezone it uses the saved user timezone (in a shared workspace, the timezone of that workspace first), then UTC; the result names the timezone used and where it came from, and says so when it fell back to UTC. Each slot includes the UTC instant to pass as scheduled_at. Pass workspace_id to only avoid collisions with posts in that workspace. strategy "best_engagement" (needs account_ids) ranks the next 7 days by when these accounts get the most engagement, with a 1-5 star rating and a reason per slot.',
|
|
11
13
|
inputSchema: z.object({
|
|
12
14
|
account_ids: z
|
|
13
15
|
.array(z.string())
|
|
@@ -16,7 +18,7 @@ export const findSlotTool = {
|
|
|
16
18
|
timezone: z
|
|
17
19
|
.string()
|
|
18
20
|
.optional()
|
|
19
|
-
.describe('IANA timezone (e.g. Asia/Dubai, Europe/London). Defaults to
|
|
21
|
+
.describe('IANA timezone (e.g. Asia/Dubai, Europe/London). Defaults to the saved user timezone (in a shared workspace, the timezone of that workspace first), then UTC.'),
|
|
20
22
|
count: z
|
|
21
23
|
.number()
|
|
22
24
|
.min(1)
|
|
@@ -48,10 +50,12 @@ export const findSlotTool = {
|
|
|
48
50
|
if (slots.length === 0) {
|
|
49
51
|
return mdEmpty('suggested slots', 'No suggested slots are free in the next 7 days.');
|
|
50
52
|
}
|
|
53
|
+
const timeZoneNote = slotTimeZoneNote(result);
|
|
51
54
|
const basis = result.basis_label || SUGGESTED_BASIS_LABELS[result.basis] || 'Good default';
|
|
52
55
|
return [
|
|
53
56
|
mdTitle(`Best times to post (${slots.length})`),
|
|
54
|
-
`Basis: ${basis}
|
|
57
|
+
`Basis: ${basis}`,
|
|
58
|
+
...(timeZoneNote ? [timeZoneNote] : []),
|
|
55
59
|
// local_time already carries the date in the requested timezone, so
|
|
56
60
|
// no separate Date column (a machine-local date could disagree).
|
|
57
61
|
mdTable(['Option', 'Local time', 'UTC', 'Rating', 'Why'], slots.map((slot, index) => [
|
|
@@ -63,19 +67,22 @@ export const findSlotTool = {
|
|
|
63
67
|
])),
|
|
64
68
|
].join('\n\n');
|
|
65
69
|
}
|
|
66
|
-
const
|
|
70
|
+
const result = await client.findAvailableSlots(input);
|
|
71
|
+
const slots = result.slots;
|
|
67
72
|
if (slots.length === 0) {
|
|
68
73
|
return mdEmpty('available slots', 'No available posting slots were found in the next 14 days.');
|
|
69
74
|
}
|
|
75
|
+
const timeZoneNote = slotTimeZoneNote(result);
|
|
70
76
|
return [
|
|
71
77
|
mdTitle(`Available posting slots (${slots.length})`),
|
|
78
|
+
...(timeZoneNote ? [timeZoneNote] : []),
|
|
72
79
|
mdTable(['Option', 'Local time', 'Date', 'UTC'], slots.map((slot, index) => [
|
|
73
80
|
index + 1,
|
|
74
81
|
slot.local_time,
|
|
75
|
-
|
|
82
|
+
slotLocalDate(slot.time, result.timezone),
|
|
76
83
|
formatIsoTimestamp(slot.time),
|
|
77
84
|
])),
|
|
78
|
-
|
|
85
|
+
timeZoneNote ? SLOT_SCHEDULE_HINT : `${SLOT_SCHEDULE_HINT} ${SLOT_UNKNOWN_TIMEZONE_HINT}`,
|
|
79
86
|
].join('\n\n');
|
|
80
87
|
},
|
|
81
88
|
};
|
|
@@ -16,11 +16,11 @@ export declare const listBrandsTool: {
|
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
17
|
workspace_id?: string | undefined;
|
|
18
18
|
brand_id?: string | undefined;
|
|
19
|
-
view?: "brand" | "
|
|
19
|
+
view?: "brand" | "profile" | "accounts" | "brands" | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
workspace_id?: string | undefined;
|
|
22
22
|
brand_id?: string | undefined;
|
|
23
|
-
view?: "brand" | "
|
|
23
|
+
view?: "brand" | "profile" | "accounts" | "brands" | undefined;
|
|
24
24
|
}>;
|
|
25
25
|
/** The old tools' exact input schemas, for alias calls (see alias-transport.ts). */
|
|
26
26
|
legacySchemas: {
|
|
@@ -35,8 +35,8 @@ export declare const listCommentsTool: {
|
|
|
35
35
|
workspace_id?: string | undefined;
|
|
36
36
|
limit?: number | undefined;
|
|
37
37
|
offset?: number | undefined;
|
|
38
|
-
since?: string | undefined;
|
|
39
38
|
filter?: "all" | "unread" | "flagged" | undefined;
|
|
39
|
+
since?: string | undefined;
|
|
40
40
|
search?: string | undefined;
|
|
41
41
|
until?: string | undefined;
|
|
42
42
|
comment_id?: string | undefined;
|
|
@@ -46,8 +46,8 @@ export declare const listCommentsTool: {
|
|
|
46
46
|
workspace_id?: string | undefined;
|
|
47
47
|
limit?: number | undefined;
|
|
48
48
|
offset?: number | undefined;
|
|
49
|
-
since?: string | undefined;
|
|
50
49
|
filter?: "all" | "unread" | "flagged" | undefined;
|
|
50
|
+
since?: string | undefined;
|
|
51
51
|
search?: string | undefined;
|
|
52
52
|
until?: string | undefined;
|
|
53
53
|
comment_id?: string | undefined;
|
|
@@ -40,8 +40,8 @@ export declare const listConversationsTool: {
|
|
|
40
40
|
workspace_id?: string | undefined;
|
|
41
41
|
limit?: number | undefined;
|
|
42
42
|
offset?: number | undefined;
|
|
43
|
-
since?: string | undefined;
|
|
44
43
|
filter?: "all" | "unread" | "starred" | "archived" | undefined;
|
|
44
|
+
since?: string | undefined;
|
|
45
45
|
search?: string | undefined;
|
|
46
46
|
until?: string | undefined;
|
|
47
47
|
conversation_id?: string | undefined;
|
|
@@ -51,8 +51,8 @@ export declare const listConversationsTool: {
|
|
|
51
51
|
workspace_id?: string | undefined;
|
|
52
52
|
limit?: number | undefined;
|
|
53
53
|
offset?: number | undefined;
|
|
54
|
-
since?: string | undefined;
|
|
55
54
|
filter?: "all" | "unread" | "starred" | "archived" | undefined;
|
|
55
|
+
since?: string | undefined;
|
|
56
56
|
search?: string | undefined;
|
|
57
57
|
until?: string | undefined;
|
|
58
58
|
conversation_id?: string | undefined;
|