hermoso 0.1.160 → 0.1.161
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 +2 -2
- package/mcp/client.mjs +25 -0
- package/mcp/hermoso-mcp.mjs +9 -2
- package/mcp/http.mjs +20 -2
- package/mcp/roster-scope.mjs +125 -0
- package/mcp/tools.mjs +139 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ scripts. Research the ads already winning in a market, generate finished image &
|
|
|
5
5
|
composited in, copy + CTA included), publish them to your own social channels, and build & manage the ad
|
|
6
6
|
campaigns behind them — all over [MCP](https://modelcontextprotocol.io) tools, a CLI, or installable Claude skills.
|
|
7
7
|
|
|
8
|
-
**
|
|
8
|
+
**718 tools.** `tools/list` is always the authoritative set; `hermoso_capabilities` (free) returns the live model
|
|
9
9
|
catalog with exact per-render credit costs plus the full capability map.
|
|
10
10
|
|
|
11
11
|
**What it connects to.** Ad platforms: Meta, Google Ads, TikTok Ads, LinkedIn Ads, Reddit Ads, X Ads,
|
|
@@ -119,7 +119,7 @@ block entirely if you signed in above; it is there for CI, where the process can
|
|
|
119
119
|
|
|
120
120
|
Then ask your agent: *“Generate an image ad with Hermoso.”*
|
|
121
121
|
|
|
122
|
-
### What the
|
|
122
|
+
### What the 718 tools cover
|
|
123
123
|
|
|
124
124
|
**Ad spy / research** — `find_competitors`, `competitor_teardown`, `pull_competitor_ads`, `research_ads`; the
|
|
125
125
|
Meta / Google / LinkedIn ad libraries (`search_meta_ads`, `search_google_ads`, `search_linkedin_ads`); organic
|
package/mcp/client.mjs
CHANGED
|
@@ -177,6 +177,31 @@ export function forgetWorkspaceScope() {
|
|
|
177
177
|
const ctx = mcpCtx.getStore();
|
|
178
178
|
if (ctx) delete ctx._storeSuffix;
|
|
179
179
|
}
|
|
180
|
+
// ── WHICH PROVIDERS THIS WORKSPACE HAS ACTUALLY CONNECTED (2026-08-26) ───────────────────────────────────────────
|
|
181
|
+
// Read ONCE per session, at `initialize`, and handed to registerTools so the roster it advertises carries only
|
|
182
|
+
// tools the caller can actually use — see mcp/roster-scope.mjs for the law and applyToolGates for the seam.
|
|
183
|
+
//
|
|
184
|
+
// `/api/connectors/providers` and NOT `/api/connectors`: the full route does a live-token label backfill and a
|
|
185
|
+
// per-provider scope-drift read, i.e. outbound provider calls, and this sits on the handshake every client makes.
|
|
186
|
+
// The lean route answers from the store alone and resolves the workspace exactly the way the Studio's own
|
|
187
|
+
// connector read does (brand-shared from the owner's scope + personal from the caller's).
|
|
188
|
+
//
|
|
189
|
+
// NEVER THROWS, AND THAT IS THE WHOLE CONTRACT. A read that fails for any reason — an older server with no such
|
|
190
|
+
// route, a store blip, no bearer at all — returns `readOk:false`, which makes toolHeldBackByConnectors answer
|
|
191
|
+
// false for every tool and ships the FULL roster. A failed read must never be able to remove a paying customer's
|
|
192
|
+
// tools ([[failed-read-is-not-empty]]); the cost of being wrong in this direction is a slightly larger roster.
|
|
193
|
+
//
|
|
194
|
+
// DELIBERATELY NOT MEMOIZED. It is one call per session; caching it would be the one way a user who connects an
|
|
195
|
+
// account and reconnects their client still does not see the tools, and on the hosted twin a module-level cache
|
|
196
|
+
// would be a cross-tenant leak besides.
|
|
197
|
+
export async function connectedProviders() {
|
|
198
|
+
try {
|
|
199
|
+
const r = await apiGet('/api/connectors/providers');
|
|
200
|
+
const list = Array.isArray(r?.providers) ? r.providers : null;
|
|
201
|
+
if (!list) return { connected: new Set(), readOk: false }; // a shape we do not recognise is a failed read
|
|
202
|
+
return { connected: new Set(list.filter((p) => typeof p === 'string' && p)), readOk: true };
|
|
203
|
+
} catch { return { connected: new Set(), readOk: false }; }
|
|
204
|
+
}
|
|
180
205
|
// Upload raw file BYTES to /api/upload (150MB, persists → returns {url,kind,bytes}). Overrides the JSON content-type so
|
|
181
206
|
// the server reads the raw body. Lets an agent post ARBITRARY user files (not just Hermoso renders).
|
|
182
207
|
export async function apiUpload(p, buf, { contentType = 'application/octet-stream', fileName = '' } = {}) {
|
package/mcp/hermoso-mcp.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
10
10
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
11
11
|
import { registerTools, MCP_INSTRUCTIONS, parseToolScope } from './tools.mjs';
|
|
12
|
-
import { API_BASE } from './client.mjs';
|
|
12
|
+
import { API_BASE, connectedProviders } from './client.mjs';
|
|
13
13
|
|
|
14
14
|
// instructions = the full capability map (ad spy · create · raw model playground · account) — one source of truth
|
|
15
15
|
// in tools.mjs, shared with the hosted connector (http.mjs), so every surface tells agents the same breadth.
|
|
@@ -27,7 +27,14 @@ const server = new McpServer({ name: 'hermoso-mcp', version: '1.0.0' }, {
|
|
|
27
27
|
// people's configs today. Renaming a variable someone already set is how a working setup goes quiet.
|
|
28
28
|
const _scope = parseToolScope(process.env.HERMOSO_TOOLS || process.env.HEIST_TOOLS);
|
|
29
29
|
if (_scope.error) { console.error(`[hermoso-mcp] ${_scope.error}`); process.exit(1); }
|
|
30
|
-
|
|
30
|
+
// AND SCOPED TO WHAT THIS WORKSPACE HAS CONNECTED, not only to the groups asked for (2026-08-26). A tool bound to
|
|
31
|
+
// a provider nobody has connected can only answer `401 {connector:'<p>'}`, so listing it costs the caller context
|
|
32
|
+
// on every turn and buys them nothing — and a roster far past the 30-50 tool accuracy cliff is what makes a model
|
|
33
|
+
// pick the wrong tool. ONE read, here at startup; it NEVER throws and a failed read ships the FULL roster
|
|
34
|
+
// ([[failed-read-is-not-empty]]). Awaited before registerTools because the gate reads it at registration time —
|
|
35
|
+
// wiring it after would leave `readOk:false`, the gate would fail open, and the change would be silently inert.
|
|
36
|
+
const _conn = await connectedProviders();
|
|
37
|
+
registerTools(server, { only: _scope.groups, connectors: _conn });
|
|
31
38
|
|
|
32
39
|
const transport = new StdioServerTransport();
|
|
33
40
|
await server.connect(transport);
|
package/mcp/http.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
17
17
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
18
18
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
19
19
|
import { registerTools, MCP_INSTRUCTIONS, parseToolScope } from './tools.mjs';
|
|
20
|
-
import { mcpCtx } from './client.mjs';
|
|
20
|
+
import { mcpCtx, connectedProviders } from './client.mjs';
|
|
21
21
|
|
|
22
22
|
// Mount the remote connector onto the Express app. No-op unless explicitly enabled + auth-backed.
|
|
23
23
|
// `verifyBearer(token) -> {userId, accountId, email} | null` MUST be supplied by the caller (the real auth seam).
|
|
@@ -209,6 +209,10 @@ export function mountRemoteMcp(app, { verifyBearer, publicBaseUrl } = {}) {
|
|
|
209
209
|
// `widgetHost` withholds the two commerce tools from ChatGPT (see registerTools). It is passed HERE as well
|
|
210
210
|
// as on the session path because OpenAI's own tool scanner reads this anonymous discovery roster — gating
|
|
211
211
|
// only the authenticated path would leave both tools listed in the submission.
|
|
212
|
+
// NO `connectors` HERE, DELIBERATELY. There is no authorization on this request, so there is no workspace to
|
|
213
|
+
// scope to and nothing honest to read — and a registry crawler or an agent deciding whether to connect MUST
|
|
214
|
+
// see the real catalog, not a zero-connector one. registerTools treats an absent `connectors` exactly like a
|
|
215
|
+
// failed read: full roster. Do not "fix" this by reading the workspace off the request; it is forgeable.
|
|
212
216
|
registerTools(server, { only: scope?.groups, widgetHost: isWidgetHost(clientInfoOf(req.body), req) }); // metadata only — tools/list never invokes a handler, and tools/call can't reach here
|
|
213
217
|
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
|
|
214
218
|
res.on('close', () => { try { transport.close(); server.close(); } catch {} });
|
|
@@ -247,8 +251,22 @@ export function mountRemoteMcp(app, { verifyBearer, publicBaseUrl } = {}) {
|
|
|
247
251
|
const scope = scopeFor(req, res);
|
|
248
252
|
if (scope === false) return; // unknown group — already answered 400, and nothing was allocated
|
|
249
253
|
sweepSessions(); // make room before allocating, so the cap is a ceiling and not a suggestion
|
|
254
|
+
// ── WHAT THIS CALLER CAN ACTUALLY USE (2026-08-26) ────────────────────────────────────────────────────────
|
|
255
|
+
// One free store read, on the ONE request per session that mints the roster, so the tools we advertise are
|
|
256
|
+
// the tools their workspace can call. A connector-bound tool for an unconnected provider can only answer
|
|
257
|
+
// `401 {connector:'<p>'}`; carrying it costs the caller context every turn and pushes the roster further
|
|
258
|
+
// past the 30-50 tool accuracy cliff. The MCP spec permits exactly this and nothing looser — the tool set
|
|
259
|
+
// "MAY vary by the authorization presented on the request … since credentials are per-request input, not
|
|
260
|
+
// connection state" (rev 2026-07-28, Tools ▸ Capabilities) — which is why it is keyed to the BEARER and not
|
|
261
|
+
// to the connection or to a query parameter.
|
|
262
|
+
//
|
|
263
|
+
// INSIDE `mcpCtx.run`, because that store is what puts this caller's token on the outbound /api call. Read
|
|
264
|
+
// it outside and it would go out unauthenticated, answer 401, and — correctly, by its own contract — fail
|
|
265
|
+
// OPEN with the full roster, so the whole change would be silently inert. Never throws; see
|
|
266
|
+
// connectedProviders() ([[failed-read-is-not-empty]]).
|
|
267
|
+
const connectors = await mcpCtx.run({ token, remote: true, client: rememberedClient(req) }, () => connectedProviders());
|
|
250
268
|
const server = new McpServer({ name: 'hermoso', version: '1.0.0' }, { instructions: MCP_INSTRUCTIONS });
|
|
251
|
-
registerTools(server, { only: scope.groups, widgetHost: isWidgetHost(entry?.client || clientInfoOf(req.body), req) }); // the SAME tools as stdio (minus any the caller scoped out) — and every /api call they make carries this user's token
|
|
269
|
+
registerTools(server, { only: scope.groups, connectors, widgetHost: isWidgetHost(entry?.client || clientInfoOf(req.body), req) }); // the SAME tools as stdio (minus any the caller scoped out) — and every /api call they make carries this user's token
|
|
252
270
|
const transport = new StreamableHTTPServerTransport({
|
|
253
271
|
// CSPRNG, per the spec's SHOULD for session ids (Math.random() is not one).
|
|
254
272
|
sessionIdGenerator: () => 'sess_' + randomUUID().replace(/-/g, ''),
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// ── THE CONNECTOR SCOPE — ONE LAW, TWO SURFACES (2026-08-26) ─────────────────────────────────────────────────────
|
|
2
|
+
//
|
|
3
|
+
// WHICH CONNECTOR A TOOL NEEDS, and therefore whether carrying it in a roster buys the caller anything. Shipped
|
|
4
|
+
// first for the Studio chat (lib/studio-roster.mjs, which re-exports every symbol below), and lifted here so the
|
|
5
|
+
// MCP twins can apply the IDENTICAL decision. It lives in mcp/ rather than lib/ for one mechanical reason: the
|
|
6
|
+
// published npm package (cli/) ships `cli/mcp/**` and nothing else, so `./roster-scope.mjs` is the only path that
|
|
7
|
+
// resolves from BOTH mcp/tools.mjs and its byte-identical cli/mcp/tools.mjs twin.
|
|
8
|
+
//
|
|
9
|
+
// WHY GATE ON THE CONNECTION AT ALL. A connector-bound tool for a provider the account has not connected can only
|
|
10
|
+
// ever answer `401 {connector:'<p>'}` — "not connected has ONE shape". Carrying it buys the caller nothing, costs
|
|
11
|
+
// them context on every turn, and actively harms them: a roster many times past the 30–50 tool accuracy cliff is
|
|
12
|
+
// exactly what makes a model pick the wrong tool. The MCP spec (rev 2026-07-28, Tools ▸ Capabilities) blesses this
|
|
13
|
+
// precise shape and no other: the tool set "MUST NOT vary per-connection or as a side effect of other requests on
|
|
14
|
+
// the connection. The set MAY vary by the authorization presented on the request — for example, returning only the
|
|
15
|
+
// tools the caller's granted scopes permit — since credentials are per-request input, not connection state."
|
|
16
|
+
//
|
|
17
|
+
// FIVE SAFETY PROPERTIES, each mutation-tested, because the failure mode of getting this wrong is INVISIBLE — a
|
|
18
|
+
// silently missing tool reads as the model refusing, not as a bug:
|
|
19
|
+
//
|
|
20
|
+
// 1. **A failed connector read is never a refusal.** `readOk:false` holds back NOTHING. An unreadable store must
|
|
21
|
+
// never manufacture a capability loss ([[failed-read-is-not-empty]]).
|
|
22
|
+
// 2. **An UNMAPPED tool is never held back.** The rules below are an allow-list of things we can justify, not a
|
|
23
|
+
// classifier. Anything this module cannot confidently attribute to a connector stays in the roster — which is
|
|
24
|
+
// what makes adding a tool safe: tool N+1 keeps working, it just does not get the saving.
|
|
25
|
+
// 3. **Every provider named here must exist in the live connector registry.** A typo'd provider id would match
|
|
26
|
+
// nothing in `connected` and silently drop its whole family FOREVER, on every account. The check asserts the
|
|
27
|
+
// rule table against server.js's own CONNECTOR_INFO keys.
|
|
28
|
+
// 4. **Research is never gated** — see NEVER_GATE below, and note the measured result on the MCP roster: of the
|
|
29
|
+
// 18 tools in the `research` group, the `core` group and the `workspace` group, ZERO are connector-mapped.
|
|
30
|
+
// 5. **A tool we did not register is not ours to filter.** Both callers hand these functions OUR tool names only;
|
|
31
|
+
// a user's own MCP server may call something `search_youtube_transcripts` and it must never be touched.
|
|
32
|
+
//
|
|
33
|
+
// Pure by design so the checks RUN these functions rather than reading the source. NO IMPORTS: the cli twin is
|
|
34
|
+
// rsync'd into a published package that has no lib/ and no repo around it.
|
|
35
|
+
// RESEARCH IS NEVER GATED, AND THIS LIST IS THE REASON THE WHOLE CHANGE IS SAFE.
|
|
36
|
+
//
|
|
37
|
+
// The ad libraries and organic social search run on OUR ScrapeCreators key, not on the user's connection — a brand
|
|
38
|
+
// with nothing connected can and must still spy on its competitors' Meta ads. But their NAMES look exactly like
|
|
39
|
+
// connector tools: `search_meta_ads` contains `_meta_`, `search_youtube` contains `youtube`. Six of the nine would
|
|
40
|
+
// have been silently gated by the rules below, which would have broken the product's single most-used feature for
|
|
41
|
+
// every new account — the exact users this change exists to protect.
|
|
42
|
+
//
|
|
43
|
+
// DERIVED, NOT HAND-LISTED. `tools/studio-roster-check.mjs` asserts this set is a SUPERSET of server.js's own
|
|
44
|
+
// `SC_WINDOW_TOOLS` — the set the route already uses to decide which tools take a ScrapeCreators balance window.
|
|
45
|
+
// So a tenth SC-backed tool added there fails the suite rather than quietly losing research for zero-connector
|
|
46
|
+
// accounts. Anything ScrapeCreators pays for, the user reaches without connecting anything.
|
|
47
|
+
//
|
|
48
|
+
// NOTE what is deliberately NOT here: `search_instagram_hashtag`, `instagram_profile`, `search_threads_keyword`,
|
|
49
|
+
// `discover_tiktok_creators`, `tiktok_creator_info`. Those read the PLATFORM's data through the USER'S token
|
|
50
|
+
// (Business Discovery, the Threads API, TikTok's Creator Marketplace) — free to us, but impossible without the
|
|
51
|
+
// connection, so gating them is correct.
|
|
52
|
+
export const NEVER_GATE = new Set([
|
|
53
|
+
'search_meta_ads', 'search_google_ads', 'search_linkedin_ads', 'search_tiktok',
|
|
54
|
+
'search_instagram', 'search_youtube', 'search_reddit', 'search_threads', 'scrapecreators_fetch',
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
// Tool-name → connector provider. ORDERED: the first match wins, so the more specific pattern must come first.
|
|
58
|
+
//
|
|
59
|
+
// THE ORDER IS LOAD-BEARING AND IS THE EASIEST THING TO GET WRONG. Six platforms hold TWO independent connections —
|
|
60
|
+
// posting and ads are separate consents with separate tokens (CLAUDE.md records this explicitly for TikTok: "IT IS
|
|
61
|
+
// A SEPARATE CONNECTION FROM THE `tiktok` POSTING CONNECTOR", and the same split is real for X, Pinterest, Reddit,
|
|
62
|
+
// Snapchat and Microsoft). So `*_tiktok_ads_*` must be tested BEFORE the bare `tiktok` rule, or every ads tool
|
|
63
|
+
// would be gated on the posting connector and a user with TikTok Ads connected but not TikTok posting would lose
|
|
64
|
+
// the whole ads family they are paying for.
|
|
65
|
+
export const TOOL_PROVIDER_RULES = [
|
|
66
|
+
// ── ads platforms that are their OWN connection (must precede the posting rules below) ──
|
|
67
|
+
[/_tiktok_ads_|^tiktok_ads_/, 'tiktok_ads'],
|
|
68
|
+
[/_x_ads_|^x_ads_/, 'x_ads'],
|
|
69
|
+
[/_pinterest_ads_|^pinterest_ads_/, 'pinterest_ads'],
|
|
70
|
+
[/_reddit_ads_|^reddit_ads_/, 'reddit_ads'],
|
|
71
|
+
[/_snapchat_ads_|^snapchat_ads_/, 'snapchat_ads'],
|
|
72
|
+
[/_microsoft_ads_|^microsoft_ads_|_microsoft_merchant_/, 'microsoft_ads'],
|
|
73
|
+
[/_apple_ads_|^apple_ads_/, 'apple_ads'],
|
|
74
|
+
[/_openai_ads_|^openai_ads_/, 'openai_ads'],
|
|
75
|
+
// Google Ads owns Merchant Center + the Ads↔Analytics link (both are Google Ads API surfaces, not GA4 ones).
|
|
76
|
+
[/_google_ads_|^google_ads_|_merchant_|^merchant_|^list_merchant_|link_google_ads_to_analytics/, 'google_ads'],
|
|
77
|
+
// ── LinkedIn: ads and posting share ONE connection (the Advertising API grant carries w_organization_social —
|
|
78
|
+
// see [[linkedin-connector-live]]), so both families gate on the single `linkedin` provider. ──
|
|
79
|
+
[/linkedin/, 'linkedin'],
|
|
80
|
+
// ── Meta: ads management AND FB/IG posting are one connector ([[meta-integration]]). Threads is separate. ──
|
|
81
|
+
[/^threads_|_thread$|_threads_|^(list|search|reply_to|repost|delete|hide)_thread/, 'threads'],
|
|
82
|
+
[/_meta_|^meta_|_meta$|instagram|whatsapp/, 'meta'],
|
|
83
|
+
// ── analytics / measurement, each its own connection ──
|
|
84
|
+
[/_analytics_|^analytics_(realtime|report)$|analytics_compatibility|analytics_stream/, 'google_analytics'],
|
|
85
|
+
[/mixpanel/, 'mixpanel'],
|
|
86
|
+
[/tag_manager/, 'google_tag_manager'],
|
|
87
|
+
[/search_console/, 'google_search_console'],
|
|
88
|
+
[/bing_webmaster/, 'bing_webmaster'],
|
|
89
|
+
[/posthog/, 'posthog'],
|
|
90
|
+
[/amplitude/, 'amplitude'],
|
|
91
|
+
// ── posting-only channels ──
|
|
92
|
+
[/youtube/, 'youtube'],
|
|
93
|
+
[/google_business|business_location/, 'google_business'],
|
|
94
|
+
[/_drive_|^list_drive|^get_drive|^create_drive|^save_to_drive$|_doc$|^read_doc|^create_doc|^update_doc|^append_to_doc|sheet/, 'google_drive'],
|
|
95
|
+
[/onedrive/, 'microsoft_onedrive'],
|
|
96
|
+
[/bluesky/, 'bluesky'],
|
|
97
|
+
[/telegram/, 'telegram'],
|
|
98
|
+
[/^post_to_tiktok$|^tiktok_|_tiktok_/, 'tiktok'],
|
|
99
|
+
[/^post_to_x$|^delete_x_post$|^send_x_dm$|^list_x_dms$|^x_(mentions|post)/, 'x'],
|
|
100
|
+
[/pinterest/, 'pinterest'],
|
|
101
|
+
[/reddit/, 'reddit'],
|
|
102
|
+
[/snapchat/, 'snapchat'],
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
// The provider a tool needs, or null when this module cannot attribute it. null ⇒ NEVER dropped (property 2).
|
|
106
|
+
export function toolProvider(name) {
|
|
107
|
+
const n = String(name || '');
|
|
108
|
+
if (!n) return null;
|
|
109
|
+
if (NEVER_GATE.has(n)) return null; // research runs on our key — checked FIRST, before any pattern can claim it
|
|
110
|
+
for (const [re, provider] of TOOL_PROVIDER_RULES) if (re.test(n)) return provider;
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
// THE ONE DECISION, and the only one either surface is allowed to make. `conn` is `{connected, readOk}` — the
|
|
114
|
+
// shape both the Studio route's connector read and the MCP transports' `/api/connectors/providers` read produce.
|
|
115
|
+
//
|
|
116
|
+
// Returns TRUE only when we KNOW the read succeeded AND we can attribute the tool to a provider AND that provider
|
|
117
|
+
// is not connected. Every other answer is FALSE, i.e. keep it — which is properties 1 and 2 expressed as the
|
|
118
|
+
// default rather than as two branches somebody could forget to write.
|
|
119
|
+
export function toolHeldBackByConnectors(name, conn) {
|
|
120
|
+
if (!conn || !conn.readOk) return false; // property 1 — fail OPEN on an unreadable store
|
|
121
|
+
const p = toolProvider(name);
|
|
122
|
+
if (p === null) return false; // property 2 — unmapped is never held back
|
|
123
|
+
const on = conn.connected instanceof Set ? conn.connected : new Set(conn.connected || []);
|
|
124
|
+
return !on.has(p);
|
|
125
|
+
}
|
package/mcp/tools.mjs
CHANGED
|
@@ -11,6 +11,10 @@ import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
11
11
|
// The UTF-16 well-formedness law — see wellFormedServer() below for why it is applied here, and
|
|
12
12
|
// ./well-formed.mjs for why that specifier is the only one that can work in a byte-identical twin.
|
|
13
13
|
import { wellFormedValue, wellFormedString } from './well-formed.mjs';
|
|
14
|
+
// WHICH CONNECTOR A TOOL NEEDS — the same table and the same decision the Studio chat applies (lib/studio-roster.mjs
|
|
15
|
+
// re-exports every symbol from here). `./roster-scope.mjs` is the only specifier that resolves in a byte-identical
|
|
16
|
+
// twin, for the same reason ./well-formed.mjs is. See applyToolGates() for the seam and roster-scope.mjs for the law.
|
|
17
|
+
import { toolHeldBackByConnectors } from './roster-scope.mjs';
|
|
14
18
|
|
|
15
19
|
const JOB_TIMEOUT = +(process.env.HERMOSO_JOB_TIMEOUT_MS || process.env.HEIST_JOB_TIMEOUT_MS || 10 * 60 * 1000);
|
|
16
20
|
const abs = (u) => (u && u.startsWith('/') ? API_BASE + u : u); // /generated/x.mp4 → clickable absolute URL
|
|
@@ -189,6 +193,19 @@ export const MCP_INSTRUCTIONS = [
|
|
|
189
193
|
'• RAW MODELS, prompt only: generate_image / generate_video with useBrand:false, generate_voice, generate_text, upload_file (any local or external file becomes a URL every publish, schedule and ad tool accepts).',
|
|
190
194
|
'• PUBLISH & SCHEDULE to the user\'s OWN accounts: post_to_meta (+Threads), post_to_x, post_to_linkedin, post_to_tiktok, post_to_youtube, post_to_pinterest, post_to_reddit, post_to_bluesky, post_to_telegram, post_to_google_business; schedule_post, list_scheduled, reschedule_post, cancel_scheduled; list_connectors, list_connector_accounts, set_connector_accounts.',
|
|
191
195
|
'• ADS on eleven platforms, their accounts and their money: create_meta_campaign / _adset / _ad, create_google_ads_campaign / _ad_group / _ad and the TikTok, LinkedIn, Pinterest, Reddit, Microsoft and OpenAI equivalents; meta_insights, google_ads_report and the per-platform reports. Everything is created PAUSED and read back before it is described.',
|
|
196
|
+
// ── YOUR ROSTER IS NOT THE PRODUCT (2026-08-26) ──────────────────────────────────────────────────────────────
|
|
197
|
+
// The roster is scoped to the accounts this workspace has connected, because a tool for an unconnected provider
|
|
198
|
+
// can only answer 401. That is a saving, and it has ONE failure mode, which this line exists to prevent: an
|
|
199
|
+
// agent reads its roster as the boundary of what exists and tells the user we do not support their platform
|
|
200
|
+
// ([[prompt-rosters-go-stale]] — our own prose has already refused shipped capability on five surfaces).
|
|
201
|
+
//
|
|
202
|
+
// TWO CONSTRAINTS DECIDE ITS POSITION AND ITS LENGTH, and both are real budgets someone else is paying.
|
|
203
|
+
// POSITION: immediately AFTER the ADS bullet, because some hosts truncate this string to ~2KB and all five areas
|
|
204
|
+
// plus "ADS on eleven platforms" must stay inside that window — put it above and it evicts the ads bullet, which
|
|
205
|
+
// causes the exact failure it exists to stop. LENGTH: §2d of agent-surface-guidance-check caps the whole string,
|
|
206
|
+
// so it says only what is NEW and points at nothing already named below — `list_connectors`, `Workspace ▸
|
|
207
|
+
// Connectors`, `?connect=<provider>` and the CLI escape hatch are all already in here, further down.
|
|
208
|
+
'A tool NOT in your roster is filtered out — that account is not connected here. Never say Hermoso lacks a platform.',
|
|
192
209
|
// SECOND LINE, before the capability map: those four jobs read as four STAGES, and by the time an agent has
|
|
193
210
|
// scrolled the map it has already decided Hermoso is a funnel it must enter at the top. See INDEPENDENCE above.
|
|
194
211
|
// NOT REPEATED HERE ANY MORE: the head above states independence in its own first sentence, and every byte
|
|
@@ -1894,13 +1911,21 @@ const makeEnableToolsHandler = (ctx) => async ({ groups }) => {
|
|
|
1894
1911
|
if (unknown.length) return { content: [{ type: 'text', text: `Unknown tool group${unknown.length > 1 ? 's' : ''}: ${unknown.join(', ')}. Valid: ${TOOL_GROUP_NAMES.join(', ')} — or 'all'.` }], isError: true };
|
|
1895
1912
|
const active = ctx.enabledGroups, groupOf = ctx.groupOf, handles = ctx.handleOf;
|
|
1896
1913
|
const added = expand.filter((g) => !active.has(g));
|
|
1897
|
-
let n = 0;
|
|
1914
|
+
let n = 0, heldBack = 0;
|
|
1898
1915
|
for (const g of added) {
|
|
1899
1916
|
active.add(g);
|
|
1900
1917
|
for (const [name, grp] of Object.entries(groupOf)) {
|
|
1901
1918
|
if (grp !== g) continue;
|
|
1902
1919
|
const h = handles[name];
|
|
1903
|
-
if (h)
|
|
1920
|
+
if (!h) continue;
|
|
1921
|
+
// THE GROUP FLIP MUST NOT UNDO THE CONNECTOR GATE (2026-08-26). Enabling a group is a statement about SIZE —
|
|
1922
|
+
// "I am willing to carry these schemas" — not a claim that the workspace has connected eleven ad platforms.
|
|
1923
|
+
// A blind `h.enable()` here would have re-listed every tool applyToolGates had just held back, so the saving
|
|
1924
|
+
// would survive exactly until the first `enable_tools(['ads'])`. Counted, not silently skipped: the reply
|
|
1925
|
+
// says how many and why, because a group that turns on "8 tools" when the agent expected 240 with no
|
|
1926
|
+
// explanation is the [[prompt-rosters-go-stale]] failure — the agent concludes the capability is missing.
|
|
1927
|
+
if (toolHeldBackByConnectors(name, ctx.conn)) { heldBack++; continue; }
|
|
1928
|
+
try { h.enable(); n++; } catch {}
|
|
1904
1929
|
}
|
|
1905
1930
|
}
|
|
1906
1931
|
const enabled = TOOL_GROUP_NAMES.filter((g) => active.has(g));
|
|
@@ -1922,14 +1947,28 @@ const makeEnableToolsHandler = (ctx) => async ({ groups }) => {
|
|
|
1922
1947
|
// NOT DELETED, deliberately. It still works on stdio and in the CLI, where the client re-lists, and deleting it
|
|
1923
1948
|
// there would remove the only in-session route to the two opt-in groups. Made honest, not removed.
|
|
1924
1949
|
const fixedRoster = hostRendersWidgets();
|
|
1950
|
+
// NEVER "that platform is not supported". The tools exist, are built and are live; they are simply not listed for
|
|
1951
|
+
// an account that has not connected the platform yet, because they could only answer 401. Say that, and say where
|
|
1952
|
+
// the one-click fix is — the failure this sentence prevents is an agent telling a user we cannot run their ads.
|
|
1953
|
+
const held = heldBack
|
|
1954
|
+
? ` ${heldBack} more tool${heldBack === 1 ? ' is' : 's are'} built and ready but not listed because their account is not connected in this workspace yet — Hermoso supports them all; connect the account under Workspace ▸ Connectors (https://app.hermoso.ai/?connect=<provider>, or list_connectors to see what is linked) and they appear.`
|
|
1955
|
+
: '';
|
|
1925
1956
|
const route = 'reconnect with `?tools=all` on the server URL, or run the `hermoso` CLI, which reaches every'
|
|
1926
1957
|
+ ' tool with no roster at all.';
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1958
|
+
// A CACHED CLIENT AND AN UNCONNECTED ACCOUNT ARE DIFFERENT DIAGNOSES, AND ONLY ONE OF THEM IS EVER TRUE HERE
|
|
1959
|
+
// (2026-08-26). The two branches below tell an agent that if the tools do not appear, its client cached the
|
|
1960
|
+
// roster — correct when we really did enable something. When nothing was enabled BECAUSE nothing is connected,
|
|
1961
|
+
// that sentence sends the agent to reconnect its client, which provably cannot help, and the reconnect it is
|
|
1962
|
+
// told to try will produce the identical roster. So the zero-added case answers with the real cause and the
|
|
1963
|
+
// real fix instead, and says the platforms exist. Same law as the read-back rule: report the measurement.
|
|
1964
|
+
const note = !added.length
|
|
1965
|
+
? `Already on: ${expand.join(', ')}. Nothing changed. Active groups: ${enabled.join(', ')}.`
|
|
1966
|
+
: (n === 0 && heldBack
|
|
1967
|
+
? `Switched on ${added.join(', ')} server-side, but nothing new is listed:${held} Active groups: ${enabled.join(', ')}.`
|
|
1968
|
+
: fixedRoster
|
|
1969
|
+
? `Switched on ${added.join(', ')} server-side — but THIS host fixed its tool list when the connection was made and will not pick up the ${n} new tool${n === 1 ? '' : 's'} until it reconnects, so do not expect to see them in this conversation. To use them, ${route}${held} Active groups: ${enabled.join(', ')}.`
|
|
1970
|
+
: `Switched on ${added.join(', ')} — ${n} more tool${n === 1 ? '' : 's'} are callable now. If they do not appear your client has cached its tool list, in which case ${route}${held} Active groups: ${enabled.join(', ')}.`);
|
|
1971
|
+
return ok(note, { enabled, added, toolsAdded: n, toolsAwaitingConnection: heldBack, note, rosterFixedForThisConnection: fixedRoster });
|
|
1933
1972
|
};
|
|
1934
1973
|
|
|
1935
1974
|
// The per-session scope every roster needs, whether it was built or replayed. ONE builder so the two paths cannot
|
|
@@ -1937,13 +1976,33 @@ const makeEnableToolsHandler = (ctx) => async ({ groups }) => {
|
|
|
1937
1976
|
function newToolScope(opts) {
|
|
1938
1977
|
const asked = opts.only ? new Set(opts.only) : new Set(DEFAULT_TOOL_GROUPS);
|
|
1939
1978
|
asked.add('core'); // discovery/credits/billing/jobs must exist in EVERY roster or the connection is unusable
|
|
1940
|
-
|
|
1979
|
+
// `connectors` is `{connected:Set<provider>, readOk:boolean}` from the transport's own free read, or absent.
|
|
1980
|
+
// ABSENT AND `readOk:false` BEHAVE IDENTICALLY, and that is the fail-open law rather than a convenience:
|
|
1981
|
+
// toolHeldBackByConnectors answers false for both, so an unreadable store, an anonymous discovery handshake and
|
|
1982
|
+
// a transport that has not been taught to read yet all advertise the FULL roster ([[failed-read-is-not-empty]]).
|
|
1983
|
+
return {
|
|
1984
|
+
enabledGroups: asked, groupOf: Object.create(null), handleOf: Object.create(null),
|
|
1985
|
+
conn: opts.connectors || null,
|
|
1986
|
+
widgetHost: !!opts.widgetHost,
|
|
1987
|
+
};
|
|
1941
1988
|
}
|
|
1942
|
-
//
|
|
1989
|
+
// THE THREE REASONS A REGISTERED TOOL IS HELD BACK. Applied identically on the build path, the replay path and
|
|
1990
|
+
// `enable_tools`, from ONE function, because a gate applied at two of the three is a gate a group flip undoes.
|
|
1991
|
+
//
|
|
1992
|
+
// (3) IS THE CONNECTOR GATE (2026-08-26). A connector-bound tool for a provider this workspace has not connected
|
|
1993
|
+
// can only ever answer `401 {connector:'<p>'}`, so carrying it buys the caller nothing and costs them context on
|
|
1994
|
+
// every turn — and a roster many times past the 30–50 tool accuracy cliff is what makes a model pick the wrong
|
|
1995
|
+
// tool. The MCP spec (rev 2026-07-28, Tools ▸ Capabilities) permits exactly this and nothing looser: the set
|
|
1996
|
+
// "MUST NOT vary per-connection or as a side effect of other requests on the connection. The set MAY vary by the
|
|
1997
|
+
// authorization presented on the request … since credentials are per-request input, not connection state."
|
|
1998
|
+
// DISABLED, NEVER SKIPPED, like the other two — the handler still exists, so connecting the account and
|
|
1999
|
+
// reconnecting reveals it with no code path of its own, and `tools/call` on it still answers its real 401
|
|
2000
|
+
// rather than the SDK's "unknown tool".
|
|
1943
2001
|
function applyToolGates(h, name, group, ctx, opts) {
|
|
1944
2002
|
if (!h) return;
|
|
1945
2003
|
if (!ctx.enabledGroups.has(group)) { try { h.disable(); } catch {} }
|
|
1946
2004
|
if (WITHHELD_FROM_WIDGET_HOSTS.has(name) && opts.widgetHost) { try { h.disable(); } catch {} }
|
|
2005
|
+
if (toolHeldBackByConnectors(name, ctx.conn)) { try { h.disable(); } catch {} }
|
|
1947
2006
|
}
|
|
1948
2007
|
|
|
1949
2008
|
// Replay the cached canon onto a fresh server. This is the whole hot path for every session after the first.
|
|
@@ -2122,7 +2181,13 @@ function buildTools(rawServer, opts = {}, sink = null) {
|
|
|
2122
2181
|
const h = t.registerTool(name, defForHost(name, finalDef, opts.widgetHost), handler);
|
|
2123
2182
|
handleOf[name] = h;
|
|
2124
2183
|
// DISABLED, NOT SKIPPED — see (1) above. `disable()` is the SDK's own call and removes it from tools/list.
|
|
2125
|
-
|
|
2184
|
+
//
|
|
2185
|
+
// ONE GATE FUNCTION, NOT A SECOND COPY OF THE RULES (2026-08-26). This branch and the widget branch below
|
|
2186
|
+
// used to be spelled out here AND inside applyToolGates, which replayTools calls — two implementations of
|
|
2187
|
+
// the same law, on the two paths a session can take. That is how the build path and the replay path come to
|
|
2188
|
+
// disagree, and it is invisible when they do: the first session in a process takes one, every session after
|
|
2189
|
+
// it takes the other. The third (connector) gate would have had to be written twice for the same reason.
|
|
2190
|
+
applyToolGates(h, name, group, ctx, opts);
|
|
2126
2191
|
// WITHHELD FROM ONE HOST, for that host's rules rather than ours (2026-08-23).
|
|
2127
2192
|
// OpenAI's plugin policy permits commerce only in PHYSICAL goods: "selling digital products or services,
|
|
2128
2193
|
// including subscriptions, digital content, tokens, or credits, is not allowed." buy_credits hands back a
|
|
@@ -2141,7 +2206,9 @@ function buildTools(rawServer, opts = {}, sink = null) {
|
|
|
2141
2206
|
// rather than only its `enabled:true` branch, because a tool whose declared schema can arm a charge is what a
|
|
2142
2207
|
// commerce reviewer reads, not the branch it happens to take; turning auto-reload OFF stays available in the
|
|
2143
2208
|
// app and on every other surface.
|
|
2144
|
-
|
|
2209
|
+
// (The disable itself now lives in applyToolGates above, with the other two gates. This comment stays HERE
|
|
2210
|
+
// because it explains WHICH tools are in WITHHELD_FROM_WIDGET_HOSTS and why, which is the part that has to
|
|
2211
|
+
// be read next to the roster rather than next to the mechanism.)
|
|
2145
2212
|
return h;
|
|
2146
2213
|
};
|
|
2147
2214
|
const v = Reflect.get(t, p);
|
|
@@ -3597,6 +3664,12 @@ function buildTools(rawServer, opts = {}, sink = null) {
|
|
|
3597
3664
|
poll: z.object({ options: z.array(z.string()), durationMinutes: z.number().optional() }).optional().describe('X — attach a poll: {options:["…","…"], durationMinutes}. 2–4 options of at most 25 characters each; voting runs 5–10080 minutes (7 days), default 1440. X makes a poll MUTUALLY EXCLUSIVE with media, so an item carrying an image or video is refused — schedule the poll as its own X-only post.'),
|
|
3598
3665
|
replySettings: z.enum(['following', 'mentionedUsers', 'subscribers', 'verified']).optional().describe('X — who may reply. Omit for everyone, which is the right default for a brand post.'),
|
|
3599
3666
|
madeWithAi: z.boolean().optional().describe('X — X’s AI-media label on this post. Opt-in: X treats it as the poster’s own claim about their media, so it is never set on the user’s behalf.'),
|
|
3667
|
+
// THE THREE X FIELDS `xPost` HAS ACCEPTED SINCE THE DAY THEY LANDED AND NOTHING COULD SCHEDULE (2026-08-26).
|
|
3668
|
+
// Same publisher-can/scheduler-cannot shape as SCHED_ID_FIELDS and the five Threads options one channel over:
|
|
3669
|
+
// reachable when you publish NOW, unreachable when you schedule, and invisible until the parity sweep named it.
|
|
3670
|
+
xQuotePostId: z.string().optional().describe('X — the numeric id of an X post this one QUOTES: the last part of its URL. X renders that post inside yours and it stands alone on your own timeline, which is what makes a quote different from a reply. NAMED xQuotePostId, NOT quotePostId, because `quotePostId` on this same schedule belongs to THREADS — a schedule going to both channels would otherwise be silently ambiguous. Billed at X’s higher LINK rate, because X appends the quoted post’s t.co URL to yours.'),
|
|
3671
|
+
communityId: z.string().optional().describe('X — publish into an X COMMUNITY instead of the main timeline: the number in the community’s own URL (x.com/i/communities/<id>). The connected account must be a MEMBER of it; X answers a non-member and a non-existent id with the same refusal and does not separate them.'),
|
|
3672
|
+
paidPartnership: z.boolean().optional().describe('X — label the post a PAID PARTNERSHIP, the same disclosure Hermoso already ships for TikTok. OPT-IN ONLY: set it when the post is sponsored, gifted or otherwise paid for, and never assume it on the user’s behalf.'),
|
|
3600
3673
|
collaborators: z.array(z.string()).optional().describe('INSTAGRAM \u2014 a COLLAB post: up to 3 Instagram usernames invited to CO-AUTHOR it, so it appears on their profile too once they accept, with both handles in the header and the engagement shared. Handles only ("hermosoai"); a leading @ is fine. Instagram must be one of the `channels` \u2014 asking for collaborators on a schedule Instagram is not on is REFUSED now rather than discovered when it fires, and the other channels in a mixed schedule simply publish without co-authors. THE INVITE IS SENT WHEN THE POST FIRES, not when you schedule it, and it is PENDING until the other account accepts in their notifications; check with instagram_collaborators afterwards rather than telling the user it is live on both profiles.'),
|
|
3601
3674
|
trialReel: z.enum(['MANUAL', 'SS_PERFORMANCE']).optional().describe('INSTAGRAM TRIAL REEL \u2014 publish this Reel to NON-FOLLOWERS ONLY at first, so a hook can be tested on a cold audience without spending it on the people who already follow the brand; Instagram shows it to followers only if it graduates. MANUAL = the creator graduates it by hand in the Instagram app; SS_PERFORMANCE = Instagram graduates it automatically if it performs. REELS ONLY and INSTAGRAM ONLY: an image, a carousel, or a Facebook/Threads channel is REFUSED BY NAME rather than quietly published as an ordinary post \u2014 a trial that silently goes to every follower is the exact opposite of what was asked for, so Instagram must be one of the `channels` and the item must carry a video. Omit it for a normal Reel.'),
|
|
3602
3675
|
// ── WHICH ACCOUNT (server-side SCHED_ID_FIELDS). Every one of these is an answer the publish helper REFUSES
|
|
@@ -3687,6 +3760,9 @@ function buildTools(rawServer, opts = {}, sink = null) {
|
|
|
3687
3760
|
poll: z.object({ options: z.array(z.string()), durationMinutes: z.number().optional() }).optional().describe('X — replaces the poll; an empty options list removes it.'),
|
|
3688
3761
|
replySettings: z.enum(['following', 'mentionedUsers', 'subscribers', 'verified']).optional().describe('X — who may reply; "" goes back to everyone.'),
|
|
3689
3762
|
madeWithAi: z.boolean().optional().describe('X — the AI-media label; false turns it off.'),
|
|
3763
|
+
xQuotePostId: z.string().optional().describe('X — the post this one QUOTES; an empty string removes the quote. Named apart from the Threads `quotePostId` on this same schedule.'),
|
|
3764
|
+
communityId: z.string().optional().describe('X — the community to publish into; an empty string goes back to the main timeline.'),
|
|
3765
|
+
paidPartnership: z.boolean().optional().describe('X — the paid-partnership label; false turns it off.'),
|
|
3690
3766
|
collaborators: z.array(z.string()).optional().describe('INSTAGRAM \u2014 replaces the WHOLE collab list (up to 3 usernames); an explicit [] removes the co-authors and the post goes out as an ordinary single-author post. Only takes effect if the post has not fired yet \u2014 an invite already sent cannot be withdrawn from here.'),
|
|
3691
3767
|
trialReel: z.enum(['MANUAL', 'SS_PERFORMANCE', '']).optional().describe('INSTAGRAM \u2014 replaces the trial-reel setting on a queued Reel (MANUAL or SS_PERFORMANCE); an explicit "" turns the trial off and it goes out as an ordinary Reel. Only takes effect while the post is still queued \u2014 a Reel already published cannot be converted into a trial.'),
|
|
3692
3768
|
boardId: z.string().optional().describe('PINTEREST — move the Pin to a different board (list_pinterest_boards)'),
|
|
@@ -4042,14 +4118,18 @@ function buildTools(rawServer, opts = {}, sink = null) {
|
|
|
4042
4118
|
paginationToken: z.string().optional().describe('nextToken from a previous call, to page further back. There is no since/until filter at X — this is the only way to walk history.'),
|
|
4043
4119
|
eventTypes: z.array(z.string()).optional().describe('MessageCreate (default), ParticipantsJoin, ParticipantsLeave. The join/leave events carry no message and are billed like any other, so the default is messages only.'),
|
|
4044
4120
|
},
|
|
4045
|
-
outputSchema: { account: z.string().optional(), count: z.number().optional(), nextToken: z.string().nullable().optional(), costCredits: z.number().optional(), historyNote: z.string().optional(), events: z.array(z.any()).optional(), conversations: z.array(z.any()).optional() },
|
|
4121
|
+
outputSchema: { account: z.string().optional(), count: z.number().optional(), nextToken: z.string().nullable().optional(), costCredits: z.number().optional(), historyNote: z.string().optional(), events: z.array(z.any()).optional(), conversations: z.array(z.any()).optional(), emptyReason: z.string().optional(), emptyNote: z.string().optional(), xLooked: z.boolean().nullable().optional(), xErrors: z.array(z.any()).optional() },
|
|
4046
4122
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
4047
4123
|
}, wrap(async (a) => {
|
|
4048
4124
|
const d = await apiGet('/api/x/dms', { maxResults: a.maxResults, conversationId: a.conversationId, participantId: a.participantId, paginationToken: a.paginationToken, eventTypes: (a.eventTypes || []).join(',') });
|
|
4049
4125
|
const cost = `Cost ${d.costCredits ?? '?'} credits.`;
|
|
4050
4126
|
// AN EMPTY READ IS REPORTED WITH THE WINDOW, NOT AS SILENCE. "No DMs" and "no DMs in the 30 days X will serve"
|
|
4051
4127
|
// are different facts, and only one of them is something we actually know.
|
|
4052
|
-
|
|
4128
|
+
// AN EMPTY READ NOW SAYS WHICH KIND OF EMPTY IT WAS. X can answer 200 with a top-level errors[] and no data
|
|
4129
|
+
// \u2014 a resource this token may not see, an app whose X permission level excludes Direct Messages \u2014 and for a
|
|
4130
|
+
// day that was reported as an empty inbox on an account with a DM in it. `emptyNote` names the three cases
|
|
4131
|
+
// apart; it is absent when events came back, so a normal answer is unchanged.
|
|
4132
|
+
if (!d.count) return ok(`No direct messages came back for ${d.account || 'that account'}. ${d.emptyNote || ''} ${d.historyNote || ''} ${cost}`.replace(/\s+/g, ' ').trim(), d);
|
|
4053
4133
|
const rows = (d.conversations || []).map((c) => `${c.needsReply ? '•' : '✓'} ${c.with || 'someone'} (${c.conversationId}) — ${String(c.lastMessage || '').replace(/\s+/g, ' ').slice(0, 160)}${c.needsReply ? ' ← waiting on a reply' : ' (you replied last)'}`);
|
|
4054
4134
|
return ok(`${d.count} message${d.count === 1 ? '' : 's'} across ${rows.length} conversation${rows.length === 1 ? '' : 's'} for ${d.account}. ${cost}\n${rows.join('\n')}\n\n${d.historyNote || ''}`.trim(), d);
|
|
4055
4135
|
}));
|
|
@@ -5064,25 +5144,64 @@ function buildTools(rawServer, opts = {}, sink = null) {
|
|
|
5064
5144
|
to: z.string().optional().describe('the recipient\u2019s Bluesky handle, e.g. alice.bsky.social. Ignored when convoId is given.'),
|
|
5065
5145
|
text: z.string().describe('the message, up to 1000 characters'),
|
|
5066
5146
|
replyToMessageId: z.string().optional().describe('reply to a specific message in the conversation'),
|
|
5147
|
+
dryRun: z.boolean().optional().describe('CHECK FIRST, SEND NOTHING. Asks Bluesky whether a DM to `to` would be delivered at all and returns canChat plus the reason when it would not \u2014 that account has DMs off, only accepts them from people it follows, has blocked this one, is suspended, or does not exist. Free, and the message is NOT sent. Use it before writing a long DM to someone who has never been messaged, so a refusal costs nothing instead of arriving after the words were written. `text` is still validated for length so a dry run cannot pass on a message the real send would refuse.'),
|
|
5067
5148
|
},
|
|
5068
|
-
outputSchema: { convoId: z.string().optional(), messageId: z.string().optional(), sentAt: z.string().optional(), text: z.string().optional(), to: z.string().optional(), delivered: z.boolean().optional() },
|
|
5149
|
+
outputSchema: { convoId: z.string().optional(), messageId: z.string().optional(), sentAt: z.string().optional(), text: z.string().optional(), to: z.string().optional(), delivered: z.boolean().optional(), dryRun: z.boolean().optional(), sent: z.boolean().optional(), canChat: z.boolean().optional(), reason: z.string().optional(), note: z.string().optional() },
|
|
5069
5150
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
5070
5151
|
}, wrap(async (a) => {
|
|
5071
5152
|
const d = await apiPost('/api/bluesky/dm', a);
|
|
5153
|
+
// A DRY RUN MUST NEVER RENDER AS A SEND. The send sentence below reads "Sent the DM ..." and would be a
|
|
5154
|
+
// plain falsehood about a call that deliberately delivered nothing.
|
|
5155
|
+
if (d.dryRun) return ok(d.note || `Pre-flight only \u2014 nothing was sent. canChat: ${d.canChat === true}.`, d);
|
|
5072
5156
|
return ok(`${d.delivered ? 'Sent' : 'Bluesky accepted but returned no message id for'} the DM${d.to ? ` to ${d.to}` : ''} \u2014 conversation ${d.convoId}${d.sentAt ? `, recorded at ${d.sentAt}` : ''}.\n\u201c${d.text}\u201d`, d);
|
|
5073
5157
|
}));
|
|
5074
5158
|
server.registerTool('mark_bluesky_convo_read', {
|
|
5075
|
-
title: 'Mark
|
|
5076
|
-
description: 'Clear the unread count on
|
|
5159
|
+
title: 'Mark Bluesky conversations as read',
|
|
5160
|
+
description: 'Clear the unread count on Bluesky DMs \u2014 ONE conversation, or the WHOLE ACCOUNT when convoId is omitted (Bluesky\u2019s own mark-all, narrowable with status to just the message requests or just the accepted threads). Useful after triaging an inbox so the next list_bluesky_convos does not surface the same threads again. Reports the unread count \u2014 or the number of conversations \u2014 Bluesky reads back, not the one requested. Free.',
|
|
5077
5161
|
inputSchema: {
|
|
5078
|
-
convoId: z.string().describe('from list_bluesky_convos'),
|
|
5162
|
+
convoId: z.string().optional().describe('from list_bluesky_convos. OMIT to mark EVERY conversation on the account read.'),
|
|
5079
5163
|
messageId: z.string().optional().describe('mark read only up to this message; omit to clear the whole conversation'),
|
|
5164
|
+
status: z.enum(['request', 'accepted']).optional().describe('mark-all only: narrow it to just the message requests, or just the accepted conversations. Omit to clear both. An unknown value is refused rather than dropped \u2014 a dropped one would clear everything when you asked to clear only the requests.'),
|
|
5080
5165
|
},
|
|
5081
|
-
outputSchema: { convoId: z.string().optional(), unread: z.number().optional(), with: z.string().optional() },
|
|
5166
|
+
outputSchema: { convoId: z.string().optional(), unread: z.number().optional(), with: z.string().optional(), all: z.boolean().optional(), status: z.string().optional(), updatedCount: z.number().nullable().optional(), note: z.string().optional() },
|
|
5082
5167
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
5083
5168
|
}, wrap(async (a) => {
|
|
5084
5169
|
const d = await apiPost('/api/bluesky/mark-read', a);
|
|
5085
|
-
return ok(`Conversation with ${d.with || d.convoId} now reads ${d.unread} unread.`, d);
|
|
5170
|
+
return ok(d.all ? (d.note || 'Marked read.') : `Conversation with ${d.with || d.convoId} now reads ${d.unread} unread.`, d);
|
|
5171
|
+
}));
|
|
5172
|
+
// \u2500\u2500 THE CONVERSATION ACTIONS (2026-08-26) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
5173
|
+
// We LISTED a conversation as a message REQUEST and offered no way to accept it, and reported it as MUTED with
|
|
5174
|
+
// no way to mute or unmute it \u2014 a state drawn on the screen with no handle behind it. Seven lexicons behind
|
|
5175
|
+
// ONE tool rather than seven tools: this roster is past 700 and 30-50 is where instruction-following starts to
|
|
5176
|
+
// degrade, and the repo already spells this pattern manage_meta_post / manage_linkedin_post.
|
|
5177
|
+
server.registerTool('manage_bluesky_convo', {
|
|
5178
|
+
title: 'Accept, mute, lock, leave or prune a Bluesky DM conversation',
|
|
5179
|
+
description: 'Act on one Bluesky DM conversation. ACCEPT a message request \u2014 Bluesky holds DMs from people the account does not follow in a separate requests folder, and until one is accepted it stays there. MUTE / UNMUTE it. LOCK / UNLOCK it (no new messages). LEAVE it. Or DELETE one message from THIS account\u2019s view. TWO THINGS TO SAY OUT LOUD BEFORE USING THEM: deleting is FOR SELF ONLY \u2014 the other person still sees the message, because Bluesky offers no delete-for-everyone in chat \u2014 and leaving a conversation cannot be undone from here. Accepting a request that was already accepted is reported as such rather than as a change, because Bluesky says so by returning no revision. Free, and it needs the same PRIVILEGED app password as every other Bluesky DM tool. Get a convoId from list_bluesky_convos.',
|
|
5180
|
+
inputSchema: {
|
|
5181
|
+
action: z.enum(['accept', 'mute', 'unmute', 'lock', 'unlock', 'leave', 'deleteMessage']).describe('what to do to the conversation'),
|
|
5182
|
+
convoId: z.string().describe('from list_bluesky_convos'),
|
|
5183
|
+
messageId: z.string().optional().describe('required for deleteMessage \u2014 from read_bluesky_dm'),
|
|
5184
|
+
},
|
|
5185
|
+
outputSchema: { action: z.string().optional(), convoId: z.string().optional(), messageId: z.string().optional(), accepted: z.boolean().optional(), alreadyAccepted: z.boolean().optional(), left: z.boolean().optional(), deletedForSelf: z.boolean().optional(), muted: z.boolean().optional(), unread: z.number().optional(), with: z.string().optional(), status: z.string().optional(), note: z.string().optional() },
|
|
5186
|
+
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
5187
|
+
}, wrap(async (a) => {
|
|
5188
|
+
const d = await apiPost('/api/bluesky/convo-action', a);
|
|
5189
|
+
return ok(d.note || `${a.action} done on ${a.convoId}.`, d);
|
|
5190
|
+
}));
|
|
5191
|
+
server.registerTool('react_to_bluesky_dm', {
|
|
5192
|
+
title: 'React to a Bluesky direct message',
|
|
5193
|
+
description: 'Add or remove an emoji reaction on one message in a Bluesky DM \u2014 the light acknowledgement that does not need a written reply, and the thing to reach for when someone says \u201cthanks\u201d and a paragraph back would be worse than a thumbs-up. A REACTION IS EXACTLY ONE EMOJI: that is Bluesky\u2019s own rule, so a word or a phrase is refused here rather than by the service (where it comes back as an opaque ReactionInvalidValue). Reports the reactions Bluesky reads the message back carrying, not the one requested. Free.',
|
|
5194
|
+
inputSchema: {
|
|
5195
|
+
convoId: z.string().describe('from list_bluesky_convos'),
|
|
5196
|
+
messageId: z.string().describe('from read_bluesky_dm'),
|
|
5197
|
+
value: z.string().describe('exactly one emoji, e.g. \uD83D\uDC4D'),
|
|
5198
|
+
remove: z.boolean().optional().describe('true to take the reaction off instead of putting it on'),
|
|
5199
|
+
},
|
|
5200
|
+
outputSchema: { convoId: z.string().optional(), messageId: z.string().optional(), value: z.string().optional(), removed: z.boolean().optional(), reactions: z.array(z.string()).optional(), text: z.string().optional(), note: z.string().optional() },
|
|
5201
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
5202
|
+
}, wrap(async (a) => {
|
|
5203
|
+
const d = await apiPost('/api/bluesky/react', a);
|
|
5204
|
+
return ok(d.note || `Reaction ${a.value} ${a.remove ? 'removed' : 'added'}.`, d);
|
|
5086
5205
|
}));
|
|
5087
5206
|
server.registerTool('tiktok_creator_info', {
|
|
5088
5207
|
title: 'Read the connected TikTok creator’s posting options',
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermoso",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.161",
|
|
4
4
|
"mcpName": "io.github.hermoso-ai/hermoso",
|
|
5
|
-
"description": "AI ad studio and marketing MCP server with
|
|
5
|
+
"description": "AI ad studio and marketing MCP server with 718 tools. Research the ads already running in any market, generate finished image, video and UGC avatar ads, publish and schedule them to your own channels, build and manage the ad campaigns behind them, and read what they achieved. AD PLATFORMS: Meta, Google Ads, TikTok Ads, LinkedIn Ads, Reddit Ads, X Ads, Pinterest Ads, Snapchat Ads, Microsoft Advertising, Apple Search Ads and ChatGPT Ads, plus product feeds in Google Merchant Center. PUBLISHING AND SCHEDULING: Facebook, Instagram, Threads, TikTok, YouTube, X, LinkedIn, Pinterest, Bluesky and Telegram. AD RESEARCH: the Meta, Google and LinkedIn ad libraries plus organic TikTok, Instagram, YouTube, Threads and Reddit. ANALYTICS: Google Analytics 4, Google Search Console and every connected platform's own post and campaign insights. Also brand onboarding, 50+ image and video generation models, ad scoring, competitor teardowns, Google Drive and OneDrive, a CLI and installable Claude skills.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"hermoso": "bin/hermoso.mjs"
|