@shyftai/ranq 0.0.0-stage → 0.1.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.
@@ -0,0 +1,832 @@
1
+ const projectArg = {
2
+ type: 'object',
3
+ properties: { project: { type: 'string', description: 'project slug or uuid' } },
4
+ required: ['project'],
5
+ };
6
+ function str(args, name) {
7
+ const value = args[name];
8
+ if (typeof value !== 'string' || value.length === 0)
9
+ throw new Error(`${name} is required`);
10
+ // encodeURIComponent leaves "." and ".." intact and the URL parser normalises them away, so a
11
+ // path segment of ".." would reach another route (/v1/projects/p/approvals/.. is /v1/projects/p).
12
+ if (value === '.' || value === '..')
13
+ throw new Error(`${name} must not be '.' or '..'`);
14
+ return value;
15
+ }
16
+ function query(pairs) {
17
+ const params = new URLSearchParams();
18
+ for (const [key, value] of Object.entries(pairs)) {
19
+ if (value !== undefined && value !== null && value !== '')
20
+ params.set(key, String(value));
21
+ }
22
+ const text = params.toString();
23
+ return text ? `?${text}` : '';
24
+ }
25
+ export const TOOLS = [
26
+ {
27
+ name: 'list_projects',
28
+ description: 'List every project (brand) with its domain, category and competitor domains.',
29
+ inputSchema: { type: 'object', properties: {} },
30
+ path: () => '/v1/projects',
31
+ },
32
+ {
33
+ name: 'get_project',
34
+ description: 'Full state of one project, including its latest presence (visibility) snapshot and control_cluster (null = unset, so placements and approval sends fail closed; "config" = tenant zero, set in config/portfolio.json).',
35
+ inputSchema: projectArg,
36
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}`,
37
+ },
38
+ {
39
+ name: 'get_visibility',
40
+ description: 'Current visibility by engine and prompt type: succeeded runs, runs citing the brand domain, and the presence rate. Pass market (e.g. se-sv) to read one market; multi-market projects refuse without it (market_required) so markets never mix.',
41
+ inputSchema: {
42
+ type: 'object',
43
+ properties: {
44
+ project: { type: 'string' },
45
+ engine: { type: 'string' },
46
+ prompt_type: { type: 'string' },
47
+ market: { type: 'string', description: 'market key, e.g. se-sv' },
48
+ },
49
+ required: ['project'],
50
+ },
51
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/visibility${query({ engine: a['engine'], prompt_type: a['prompt_type'], market: a['market'] })}`,
52
+ },
53
+ {
54
+ name: 'get_visibility_history',
55
+ description: 'Weekly visibility time series by engine and prompt type. Pass market (e.g. se-sv) for one market; multi-market projects refuse without it (market_required).',
56
+ inputSchema: {
57
+ type: 'object',
58
+ properties: {
59
+ project: { type: 'string' },
60
+ engine: { type: 'string' },
61
+ prompt_type: { type: 'string' },
62
+ market: { type: 'string', description: 'market key, e.g. se-sv' },
63
+ },
64
+ required: ['project'],
65
+ },
66
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/visibility/history${query({ engine: a['engine'], prompt_type: a['prompt_type'], market: a['market'] })}`,
67
+ },
68
+ {
69
+ name: 'diff_visibility',
70
+ description: 'Period over period: citation URLs that appeared or disappeared versus the preceding equal-length period. Requires from and to as ISO instants in the exact format YYYY-MM-DDTHH:mm:ss[.fff](Z|+HH:MM|-HH:MM), for example 2026-01-01T00:00:00Z or 2026-01-01T00:00:00+01:00: seconds are required, fractional seconds (1 to 9 digits) are optional, and the instant ends in Z or a UTC offset with a colon. Date-only values, missing seconds and a space instead of T are refused (400 from_and_to_are_required_iso_instants). The span from from to to must not exceed 366 days.',
71
+ inputSchema: {
72
+ type: 'object',
73
+ properties: {
74
+ project: { type: 'string' },
75
+ from: {
76
+ type: 'string',
77
+ description: 'Start instant, format YYYY-MM-DDTHH:mm:ss[.fff](Z|+HH:MM|-HH:MM), e.g. 2026-01-01T00:00:00Z; seconds are required, the optional fraction takes 1 to 9 fraction digits.',
78
+ },
79
+ to: {
80
+ type: 'string',
81
+ description: 'End instant, format YYYY-MM-DDTHH:mm:ss[.fff](Z|+HH:MM|-HH:MM), e.g. 2026-01-01T00:00:00Z; seconds are required, the optional fraction takes 1 to 9 fraction digits. At most 366 days after from.',
82
+ },
83
+ market: { type: 'string', description: 'market key, e.g. se-sv' },
84
+ },
85
+ required: ['project', 'from', 'to'],
86
+ },
87
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/visibility/diff${query({ from: a['from'], to: a['to'], market: a['market'] })}`,
88
+ },
89
+ {
90
+ name: 'get_corpus',
91
+ description: 'The ranked corpus pages that decide this category, strongest citation evidence first.',
92
+ inputSchema: {
93
+ type: 'object',
94
+ properties: {
95
+ project: { type: 'string' },
96
+ state: { type: 'string', description: 'candidate | active | stale | removed' },
97
+ market: { type: 'string', description: 'market key, e.g. se-sv' },
98
+ },
99
+ required: ['project'],
100
+ },
101
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/corpus${query({ state: a['state'], market: a['market'] })}`,
102
+ },
103
+ {
104
+ name: 'get_presence_gap',
105
+ description: 'Corpus pages where the brand is checked absent, scored by citation frequency and page type. Unchecked pages are counted, never listed. Pass market (e.g. se-sv) for one market; multi-market projects refuse without it (market_required).',
106
+ inputSchema: {
107
+ type: 'object',
108
+ properties: { project: { type: 'string' }, limit: { type: 'number' }, market: { type: 'string', description: 'market key, e.g. se-sv' } },
109
+ required: ['project'],
110
+ },
111
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/presence-gap${query({ limit: a['limit'], market: a['market'] })}`,
112
+ },
113
+ {
114
+ name: 'get_competitor_presence',
115
+ description: 'Where competitors are cited and which of their corpus pages name (or omit) the brand. Pages are capped per competitor (default 100); pagesTruncated: true on a competitor means it has more pages than were returned. Pass market (e.g. se-sv) for one market; multi-market projects refuse without it (market_required).',
116
+ inputSchema: {
117
+ type: 'object',
118
+ properties: { project: { type: 'string' }, market: { type: 'string', description: 'market key, e.g. se-sv' } },
119
+ required: ['project'],
120
+ },
121
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/competitor-presence${query({ market: a['market'] })}`,
122
+ },
123
+ {
124
+ name: 'get_mentions',
125
+ description: 'Stored LLM mention snapshots for one market (platform, keyword, kind, target, mentionsCount, status). A null mentionsCount means the provider had no figure, never 0. Pass market (e.g. se-sv) for one market; multi-market projects refuse without it (market_required).',
126
+ inputSchema: {
127
+ type: 'object',
128
+ properties: {
129
+ project: { type: 'string' },
130
+ market: { type: 'string', description: 'market key, e.g. se-sv' },
131
+ },
132
+ required: ['project'],
133
+ },
134
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/mentions${query({ market: a['market'] })}`,
135
+ },
136
+ {
137
+ name: 'get_demand',
138
+ description: 'Stored per-prompt AI search volume readings for one market (promptId, collectedOn, aiSearchVolume, status). A null aiSearchVolume means the provider had no figure, never 0. Pass market (e.g. se-sv) for one market; multi-market projects refuse without it (market_required).',
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ project: { type: 'string' },
143
+ market: { type: 'string', description: 'market key, e.g. se-sv' },
144
+ },
145
+ required: ['project'],
146
+ },
147
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/demand${query({ market: a['market'] })}`,
148
+ },
149
+ {
150
+ name: 'check_page_presence',
151
+ description: 'Whether the brand is named on one URL, read from stored presence checks. Never fetches the page; an unknown URL reports found: false.',
152
+ inputSchema: {
153
+ type: 'object',
154
+ properties: { project: { type: 'string' }, url: { type: 'string' } },
155
+ required: ['project', 'url'],
156
+ },
157
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/page-presence${query({ url: a['url'] })}`,
158
+ },
159
+ {
160
+ name: 'list_placements',
161
+ description: 'List placement ledger rows for a project (status, route, page URL, public owner route, gap score, verification state, link attribution from the latest check, and timestamps), optionally filtered by status.',
162
+ inputSchema: {
163
+ type: 'object',
164
+ properties: {
165
+ project: { type: 'string', description: 'project slug or uuid' },
166
+ status: {
167
+ type: 'string',
168
+ description: 'target | contacted | following_up | needs_client | placed | verified | declined | abandoned',
169
+ },
170
+ limit: { type: 'number' },
171
+ offset: { type: 'number' },
172
+ },
173
+ required: ['project'],
174
+ },
175
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/placements${query({ status: a['status'], limit: a['limit'], offset: a['offset'] })}`,
176
+ },
177
+ {
178
+ name: 'add_placement',
179
+ description: 'Add a placement target for a checked-absent corpus page. This call is a dry run unless execute: true: without it nothing is written and the result describes what would be created.',
180
+ inputSchema: {
181
+ type: 'object',
182
+ properties: {
183
+ project: { type: 'string', description: 'project slug or uuid' },
184
+ url: { type: 'string' },
185
+ route: { type: 'string', description: 'listing | pr_to_list | outreach_editor | community_answer' },
186
+ owner_route: { type: 'string' },
187
+ next_action_at: { type: 'string', description: 'ISO instant' },
188
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
189
+ },
190
+ required: ['project', 'url', 'route'],
191
+ },
192
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/placements`,
193
+ method: 'POST',
194
+ body: (a) => ({
195
+ url: a['url'],
196
+ route: a['route'],
197
+ ...('owner_route' in a ? { owner_route: a['owner_route'] } : {}),
198
+ ...('next_action_at' in a ? { next_action_at: a['next_action_at'] } : {}),
199
+ execute: a['execute'] === true,
200
+ }),
201
+ },
202
+ {
203
+ name: 'set_placement_status',
204
+ description: 'Move a placement to a new status and record a status event. This call is a dry run unless execute: true: without it nothing is written and the result describes what would change.',
205
+ inputSchema: {
206
+ type: 'object',
207
+ properties: {
208
+ project: { type: 'string', description: 'project slug or uuid' },
209
+ url: { type: 'string' },
210
+ status: {
211
+ type: 'string',
212
+ description: 'target | contacted | following_up | needs_client | placed | verified | declined | abandoned',
213
+ },
214
+ note: { type: 'string' },
215
+ next_action_at: { type: 'string', description: 'ISO instant' },
216
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
217
+ },
218
+ required: ['project', 'url', 'status'],
219
+ },
220
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/placements/status`,
221
+ method: 'POST',
222
+ body: (a) => ({
223
+ url: a['url'],
224
+ status: a['status'],
225
+ note: a['note'] ?? null,
226
+ ...('next_action_at' in a ? { next_action_at: a['next_action_at'] } : {}),
227
+ execute: a['execute'] === true,
228
+ }),
229
+ },
230
+ {
231
+ name: 'verify_placements',
232
+ description: 'List the placed/verified placements that verification would recheck (plan mode). This call is a dry run unless execute: true, and execute: true is refused by the API (verify_execute_not_available_via_api) because page fetching stays CLI-only.',
233
+ inputSchema: {
234
+ type: 'object',
235
+ properties: {
236
+ project: { type: 'string', description: 'project slug or uuid' },
237
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run. Refused by the API for this tool.' },
238
+ },
239
+ required: ['project'],
240
+ },
241
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/placements/verify`,
242
+ method: 'POST',
243
+ body: (a) => ({ execute: a['execute'] === true }),
244
+ },
245
+ {
246
+ name: 'get_placement_events',
247
+ description: 'Read one placement target (including its latest link attribution) and its append-only status transition event history by placement uuid or target page URL.',
248
+ inputSchema: {
249
+ type: 'object',
250
+ properties: {
251
+ project: { type: 'string', description: 'project slug or uuid' },
252
+ placement: { type: 'string', description: 'placement uuid or target page URL' },
253
+ limit: { type: 'number' },
254
+ },
255
+ required: ['project', 'placement'],
256
+ },
257
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/placements/${encodeURIComponent(str(a, 'placement'))}/events${query({ limit: a['limit'] })}`,
258
+ },
259
+ {
260
+ name: 'record_action',
261
+ description: 'Record an action you took for a page (append-only action log), so get_report can show whether citations moved after it. action: listed | submitted | skipped | published | updated. This call is a dry run unless execute: true. Refused: contact data in any field, a page the control cluster cites, a future time.',
262
+ inputSchema: {
263
+ type: 'object',
264
+ properties: {
265
+ project: { type: 'string', description: 'project slug or uuid' },
266
+ action: { type: 'string', description: 'listed | submitted | skipped | published | updated' },
267
+ target: { type: 'string', description: 'the page acted on: an http or https URL' },
268
+ result: { type: 'string', description: 'short outcome text, no contact data' },
269
+ gap_pages: { type: 'array', items: { type: 'string' }, description: 'gap page URLs this action is meant to move' },
270
+ at: { type: 'string', description: 'ISO instant; now when omitted' },
271
+ ref: { type: 'string', description: 'id this action belongs to (brief, approval, placement event)' },
272
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
273
+ },
274
+ required: ['project', 'action', 'target', 'result'],
275
+ },
276
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/actions`,
277
+ method: 'POST',
278
+ body: (a) => ({
279
+ action: a['action'],
280
+ target: a['target'],
281
+ result: a['result'],
282
+ ...('gap_pages' in a ? { gap_pages: a['gap_pages'] } : {}),
283
+ ...('at' in a ? { at: a['at'] } : {}),
284
+ ...('ref' in a ? { ref: a['ref'] } : {}),
285
+ execute: a['execute'] === true,
286
+ }),
287
+ },
288
+ {
289
+ name: 'list_actions',
290
+ description: 'The project action log, oldest first: every recorded action and every placement status change, from since on when given.',
291
+ inputSchema: {
292
+ type: 'object',
293
+ properties: {
294
+ project: { type: 'string', description: 'project slug or uuid' },
295
+ since: { type: 'string', description: 'ISO instant' },
296
+ limit: { type: 'number' },
297
+ },
298
+ required: ['project'],
299
+ },
300
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/actions${query({ since: a['since'], limit: a['limit'] })}`,
301
+ },
302
+ {
303
+ name: 'get_report',
304
+ description: 'Outcome report since an instant: placements by status, verified mentions, presence-rate change, and each action in the window with its page presence before and after. A side with no check is null and missing says why; nothing is guessed.',
305
+ inputSchema: {
306
+ type: 'object',
307
+ properties: {
308
+ project: { type: 'string', description: 'project slug or uuid' },
309
+ since: { type: 'string', description: 'ISO instant: the start of the window' },
310
+ },
311
+ required: ['project', 'since'],
312
+ },
313
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/report${query({ since: str(a, 'since') })}`,
314
+ },
315
+ {
316
+ name: 'get_project_events',
317
+ description: 'What changed in one project since a cursor, oldest first: runs finished or failed, corpus pages added, removed or changed state, presence verdicts changed, placement status changes, weekly collection and presence jobs finished. Poll with since = the previous next_cursor (omit it to start from the beginning); has_more true means call again at once. Each event has a stable id, at, a type from a closed list (docs/EVENTS.md), subject, summary and ref (the REST path to read). limit defaults to 100, max 500. A cursor this feed did not issue is invalid_cursor.',
318
+ inputSchema: {
319
+ type: 'object',
320
+ properties: {
321
+ project: { type: 'string', description: 'project slug or uuid' },
322
+ since: { type: 'string', description: 'next_cursor from the previous call; omit to start from the beginning' },
323
+ limit: { type: 'number', description: 'default 100, max 500' },
324
+ },
325
+ required: ['project'],
326
+ },
327
+ path: (a) => {
328
+ const q = query({ since: a['since'], limit: a['limit'] });
329
+ // query() drops '', but an empty since must reach REST and be invalid_cursor there, not a page from the start
330
+ const since = a['since'] === '' ? `${q ? `${q}&` : '?'}since=` : q;
331
+ return `/v1/projects/${encodeURIComponent(str(a, 'project'))}/events${since}`;
332
+ },
333
+ },
334
+ {
335
+ name: 'list_prompts',
336
+ description: 'The prompts one project measures, each with its default-language text and every reviewed wording by language (translations). History and collection are per market; a non-English market sends its own language wording.',
337
+ inputSchema: projectArg,
338
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/prompts`,
339
+ },
340
+ {
341
+ name: 'add_prompts',
342
+ description: 'Add prompts to a project in bulk (at most 50 per call). This call is a dry run unless execute: true: without it nothing is written and the result shows the counts that would change. Each prompt is { type: unbranded | branded | comparative, text, comparator? }: a branded prompt must name the brand, an unbranded one must not, a comparative one names its comparator in the text. Each prompt may name a cluster; on a project with the automatic control (create_project: control_cluster C9 with C1 prompts) an untagged new prompt goes to treated cluster C1, and a reactivated one keeps its own cluster, so the control set never changes unless you tag a prompt C9. A prompt that already exists is left as is; a removed one with the same type and text is reactivated, keeping its history. Never removes another prompt. Refuses a set whose unbranded share would fall below 0.6 (unbranded_share_below_floor), and tenant-zero projects (prompts_tenant_zero: they are managed in config/portfolio.json). Starts no collection.',
343
+ inputSchema: {
344
+ type: 'object',
345
+ properties: {
346
+ project: { type: 'string', description: 'project slug or uuid' },
347
+ prompts: {
348
+ type: 'array',
349
+ description: 'prompts to add',
350
+ items: {
351
+ type: 'object',
352
+ properties: {
353
+ type: { type: 'string', enum: ['unbranded', 'branded', 'comparative'] },
354
+ text: { type: 'string' },
355
+ comparator: { type: 'string', description: 'competitor name; comparative only' },
356
+ cluster: { type: 'string', description: 'cluster id, e.g. C7; lets the control guard place pages this prompt cites' },
357
+ },
358
+ required: ['type', 'text'],
359
+ },
360
+ },
361
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
362
+ },
363
+ required: ['project', 'prompts'],
364
+ },
365
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/prompts`,
366
+ method: 'POST',
367
+ body: (a) => ({ prompts: a['prompts'], execute: a['execute'] === true }),
368
+ },
369
+ {
370
+ name: 'remove_prompt',
371
+ description: 'Stop measuring one prompt: it is deactivated, never deleted, so its runs and history stay. This call is a dry run unless execute: true. Removing an inactive prompt is a no-op (deactivated: false). Refuses a removal that drops the unbranded share below 0.6 (unbranded_share_below_floor), and tenant-zero projects (prompts_tenant_zero).',
372
+ inputSchema: {
373
+ type: 'object',
374
+ properties: {
375
+ project: { type: 'string', description: 'project slug or uuid' },
376
+ prompt: { type: 'string', description: 'prompt uuid (from list_prompts)' },
377
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
378
+ },
379
+ required: ['project', 'prompt'],
380
+ },
381
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/prompts/${encodeURIComponent(str(a, 'prompt'))}/remove`,
382
+ method: 'POST',
383
+ body: (a) => ({ execute: a['execute'] === true }),
384
+ },
385
+ {
386
+ name: 'list_keywords',
387
+ description: 'The classic SEO keywords one project tracks for rank position, each with locale and device.',
388
+ inputSchema: projectArg,
389
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/keywords`,
390
+ },
391
+ {
392
+ name: 'add_keywords',
393
+ description: 'Add classic SEO keywords to track for rank position (at most 100 per call). This call is a dry run unless execute: true. Each entry is a term, or { term, locale?, device? } with locale like en-US (default) and device desktop (default) or mobile. A keyword already tracked for that locale and device is reported under existing and left as is. Makes no paid call.',
394
+ inputSchema: {
395
+ type: 'object',
396
+ properties: {
397
+ project: { type: 'string', description: 'project slug or uuid' },
398
+ keywords: {
399
+ type: 'array',
400
+ description: 'terms, or { term, locale?, device? }',
401
+ items: {
402
+ oneOf: [
403
+ { type: 'string' },
404
+ {
405
+ type: 'object',
406
+ properties: { term: { type: 'string' }, locale: { type: 'string' }, device: { type: 'string', enum: ['desktop', 'mobile'] } },
407
+ required: ['term'],
408
+ },
409
+ ],
410
+ },
411
+ },
412
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
413
+ },
414
+ required: ['project', 'keywords'],
415
+ },
416
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/keywords`,
417
+ method: 'POST',
418
+ body: (a) => ({ keywords: a['keywords'], execute: a['execute'] === true }),
419
+ },
420
+ {
421
+ name: 'set_prompt_translation',
422
+ description: 'Set one prompt\'s human-reviewed wording for a language (ISO 639-1). This call is a dry run unless execute: true: without it nothing is written. Wordings are never machine-generated; add the wording before adding a market in that language (set_project_markets refuses with prompt_translation_missing otherwise).',
423
+ inputSchema: {
424
+ type: 'object',
425
+ properties: {
426
+ project: { type: 'string', description: 'project slug or uuid' },
427
+ prompt: { type: 'string', description: 'prompt uuid' },
428
+ language: { type: 'string', description: 'ISO 639-1 lowercase, e.g. es' },
429
+ text: { type: 'string', description: 'the reviewed wording in that language' },
430
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
431
+ },
432
+ required: ['project', 'prompt', 'language', 'text'],
433
+ },
434
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/prompts/${encodeURIComponent(str(a, 'prompt'))}/translations`,
435
+ method: 'POST',
436
+ body: (a) => ({ language: a['language'], text: a['text'], execute: a['execute'] === true }),
437
+ },
438
+ {
439
+ name: 'list_markets',
440
+ description: 'Supported market countries (with location codes), named regions, and per-engine market coverage. A market change takes effect at the next collection and does not rewrite history.',
441
+ inputSchema: { type: 'object', properties: {} },
442
+ path: () => '/v1/markets',
443
+ },
444
+ {
445
+ name: 'get_project_markets',
446
+ description: 'The concrete markets one project measures. History is per market. A market change takes effect at the next collection and does not rewrite history.',
447
+ inputSchema: projectArg,
448
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/markets`,
449
+ },
450
+ {
451
+ name: 'set_project_markets',
452
+ description: 'Replace a project\'s market list (concrete markets and/or regions with a language). This call is a dry run unless execute: true: without it nothing is written. Refuses with prompt_translation_missing (dry run included) when the new list introduces a language active prompts have no reviewed wording for. A market change takes effect at the next collection and does not rewrite history.',
453
+ inputSchema: {
454
+ type: 'object',
455
+ properties: {
456
+ project: { type: 'string', description: 'project slug or uuid' },
457
+ markets: {
458
+ type: 'array',
459
+ description: 'concrete markets, e.g. [{country: SE, language: sv}]',
460
+ items: { type: 'object', properties: { country: { type: 'string' }, language: { type: 'string' } } },
461
+ },
462
+ regions: {
463
+ type: 'array',
464
+ description: 'region rules, e.g. [{region: nordics, language: en}]',
465
+ items: { type: 'object', properties: { region: { type: 'string' }, language: { type: 'string' } } },
466
+ },
467
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
468
+ },
469
+ required: ['project'],
470
+ },
471
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/markets`,
472
+ method: 'POST',
473
+ body: (a) => ({
474
+ ...(Array.isArray(a['markets']) ? { markets: a['markets'] } : {}),
475
+ ...(Array.isArray(a['regions']) ? { regions: a['regions'] } : {}),
476
+ execute: a['execute'] === true,
477
+ }),
478
+ },
479
+ {
480
+ name: 'start_scan',
481
+ description: 'Start the USD 1 scan of a domain (operator only: any workspace key is refused with scan_operator_only). mode plan (default) returns the steps and the cost estimate and writes nothing (on a domain already scanned it also says what a request would do to that scan); draft reads the site and makes one drafting call, storing the draft; execute drafts if needed, then creates the scan project, collects 10 prompts x 3 engines under the per-scan ceiling, and builds the report. One scan per domain: a second one is refused with scan_exists and the existing id, except that a failed (or stale) scan gets one free retry of the same scan, redoing only what did not succeed; after that, scan_exists with retry_used. Poll get_scan for progress.',
482
+ inputSchema: {
483
+ type: 'object',
484
+ properties: {
485
+ domain: { type: 'string', description: 'the domain to scan, e.g. acme.com' },
486
+ market: { type: 'string', description: 'one English-language market, e.g. US-en (default)' },
487
+ mode: { type: 'string', description: 'plan | draft | execute (default plan)' },
488
+ max_usd: { type: 'number', description: 'lower the per-scan USD ceiling; never above the default' },
489
+ },
490
+ required: ['domain'],
491
+ },
492
+ path: () => '/v1/scans',
493
+ method: 'POST',
494
+ body: (a) => ({
495
+ domain: a['domain'],
496
+ ...('market' in a ? { market: a['market'] } : {}),
497
+ ...('mode' in a ? { mode: a['mode'] } : {}),
498
+ ...('max_usd' in a ? { max_usd: a['max_usd'] } : {}),
499
+ }),
500
+ },
501
+ {
502
+ name: 'get_scan',
503
+ description: 'One scan (operator only): status, each step with timestamps, the draft, the spend, and when it succeeded the report (visibility per engine, prompts lost, top 5 pages to get on).',
504
+ inputSchema: {
505
+ type: 'object',
506
+ properties: { scan: { type: 'string', description: 'scan uuid' } },
507
+ required: ['scan'],
508
+ },
509
+ path: (a) => `/v1/scans/${encodeURIComponent(str(a, 'scan'))}`,
510
+ },
511
+ {
512
+ name: 'create_checkout',
513
+ description: 'A Stripe Checkout URL to buy one credit pack for this key\'s workspace: pack 9 (500 credits), 49 (2,800), 199 (12,500) or 499 (37,000), USD, valid 12 months. Nothing is granted until Stripe confirms the payment. 1 credit = 1 answer (one prompt, one engine, one market). Tenant zero is not billed (not_billed); a frozen workspace is refused (workspace_frozen).',
514
+ inputSchema: {
515
+ type: 'object',
516
+ properties: { pack: { type: 'string', description: '9 | 49 | 199 | 499 (USD)' } },
517
+ required: ['pack'],
518
+ },
519
+ path: () => '/v1/billing/checkout',
520
+ method: 'POST',
521
+ body: (a) => ({ pack: a['pack'] }),
522
+ },
523
+ {
524
+ name: 'get_balance',
525
+ description: 'This workspace\'s credits: available (what a new paid call may reserve), balance, held, granted, settled, reversed, expired, adjusted, and whether spending is frozen. A paid call is refused with credits_exhausted when available is short.',
526
+ inputSchema: { type: 'object', properties: {} },
527
+ path: () => '/v1/billing/balance',
528
+ },
529
+ {
530
+ name: 'get_ledger',
531
+ description: 'This workspace\'s append-only credit ledger, newest first: grant, reserve, settle, release, reversal, expiry and adjustment rows. Paged with limit (1-500, default 100) and offset.',
532
+ inputSchema: {
533
+ type: 'object',
534
+ properties: { limit: { type: 'number' }, offset: { type: 'number' } },
535
+ },
536
+ path: (a) => `/v1/billing/ledger${query({ limit: a['limit'], offset: a['offset'] })}`,
537
+ },
538
+ {
539
+ name: 'create_scan_checkout',
540
+ description: 'A Stripe Checkout URL for the USD 1 scan of a domain (card, 3-D Secure). The scan starts when Stripe confirms the payment; read it with get_scan_by_session and the Checkout session id. One scan per domain (scan_exists); one paid scan per card per 24 hours (a second is refunded with card_scan_limit). Rate limited per client.',
541
+ inputSchema: {
542
+ type: 'object',
543
+ properties: { domain: { type: 'string', description: 'the domain to scan, e.g. acme.com' } },
544
+ required: ['domain'],
545
+ },
546
+ path: () => '/v1/public/scans/checkout',
547
+ method: 'POST',
548
+ body: (a) => ({ domain: a['domain'] }),
549
+ },
550
+ {
551
+ name: 'get_scan_by_session',
552
+ description: 'The paid scan bought with one Stripe Checkout session id (cs_...): payment state, the scan status per step, and when done the report. Only that session\'s scan.',
553
+ inputSchema: {
554
+ type: 'object',
555
+ properties: { session: { type: 'string', description: 'Stripe Checkout session id, cs_...' } },
556
+ required: ['session'],
557
+ },
558
+ path: (a) => `/v1/public/scans/by-session/${encodeURIComponent(str(a, 'session'))}`,
559
+ },
560
+ {
561
+ name: 'set_competitors',
562
+ description: 'Replace a project\'s competitor domains. This call is a dry run unless execute: true: without it nothing is written and the result shows the previous and would-be list. Each entry is a bare domain or URL, normalised to a lowercase host without www. Refuses an empty list, a duplicate after normalisation, the project\'s own domain, a non-domain, and more than 50 entries.',
563
+ inputSchema: {
564
+ type: 'object',
565
+ properties: {
566
+ project: { type: 'string', description: 'project slug or uuid' },
567
+ competitors: { type: 'array', description: 'the full competitor list, e.g. [rival.com]', items: { type: 'string' } },
568
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
569
+ },
570
+ required: ['project', 'competitors'],
571
+ },
572
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/competitors`,
573
+ method: 'POST',
574
+ body: (a) => ({ competitors: a['competitors'], execute: a['execute'] === true }),
575
+ },
576
+ {
577
+ name: 'set_prompt_cluster',
578
+ description: 'Tag one existing prompt of a project in your workspace with a cluster id (e.g. C7). The control guard refuses any page an untagged prompt cites (control_prompt_untagged), so tag the prompts that cite a page before placing it. This call is a dry run unless execute: true. Refuses tenant-zero projects (prompts_tenant_zero: clusters come from config/portfolio.json). 404 for a prompt not in the project.',
579
+ inputSchema: {
580
+ type: 'object',
581
+ properties: {
582
+ project: { type: 'string', description: 'project slug or uuid' },
583
+ prompt: { type: 'string', description: 'the prompt id' },
584
+ cluster: { type: 'string', description: 'the cluster id, e.g. C7' },
585
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
586
+ },
587
+ required: ['project', 'prompt', 'cluster'],
588
+ },
589
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/prompts/${encodeURIComponent(str(a, 'prompt'))}/cluster`,
590
+ method: 'POST',
591
+ body: (a) => ({ cluster: a['cluster'], execute: a['execute'] === true }),
592
+ },
593
+ {
594
+ name: 'set_control_cluster',
595
+ description: 'Name the held-out control cluster of a project in your workspace: the prompt cluster id (e.g. C7) whose prompts nobody treats. Placements, outreach and approval sends refuse any page those prompts cite, and fail closed with control_cluster_unconfigured until one is set. Pass cluster: null to clear it. This call is a dry run unless execute: true: without it nothing is written and the result shows the previous and would-be cluster. Refuses an id no prompt of the project carries, and tenant zero (its control cluster comes from config/portfolio.json).',
596
+ inputSchema: {
597
+ type: 'object',
598
+ properties: {
599
+ project: { type: 'string', description: 'project slug or uuid' },
600
+ cluster: { type: ['string', 'null'], description: 'the prompt cluster id, e.g. C7; null clears it (the guard fails closed again)' },
601
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
602
+ },
603
+ required: ['project', 'cluster'],
604
+ },
605
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/control-cluster`,
606
+ method: 'POST',
607
+ body: (a) => ({ cluster: a['cluster'], execute: a['execute'] === true }),
608
+ },
609
+ {
610
+ name: 'create_publish_brief',
611
+ description: 'The publish brief for one citation gap: what page to publish so the engines that skip this brand for a prompt have a page of the brand to cite. Takes a prompt (id or exact text), a market and optionally the engines, on which the brand domain must not be cited (not_a_gap otherwise). Reads the pages the engines cite, the top 10 Google Organic results and the brand\'s own pages, and returns keywords, entities, a section outline, questions, gaps, claims (each linked to a page on the brand\'s own domain) and a ready prompt for a coding agent. Costs a fixed number of credits per brief, settled on what was delivered. This call is a dry run unless execute: true: without it nothing is fetched, billed or written and the result shows the cost and the cited pages.',
612
+ inputSchema: {
613
+ type: 'object',
614
+ properties: {
615
+ project: { type: 'string', description: 'project slug or uuid' },
616
+ prompt: { type: 'string', description: 'the gap prompt: its id or its exact text' },
617
+ market: { type: 'string', description: 'market key, e.g. us-en; required on a multi-market project' },
618
+ engines: { type: 'array', items: { type: 'string' }, description: 'engine slugs; default every engine with an answer for the prompt' },
619
+ execute: { type: 'boolean', description: 'must be true to fetch and bill; otherwise dry run' },
620
+ },
621
+ required: ['project', 'prompt'],
622
+ },
623
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/briefs`,
624
+ method: 'POST',
625
+ body: (a) => ({
626
+ prompt: a['prompt'],
627
+ ...('market' in a ? { market: a['market'] } : {}),
628
+ ...('engines' in a ? { engines: a['engines'] } : {}),
629
+ execute: a['execute'] === true,
630
+ }),
631
+ },
632
+ {
633
+ name: 'run_visibility_check',
634
+ description: "Collect fresh answers now for one project on ONE engine (every active prompt x every project market), extract their citations, and return the project's visibility on that engine in get_visibility's shape, one entry per market. Paid in credits (1 per answer), held before the first provider call and settled on the answers delivered. max_usd may only lower the per-call ceiling, never raise it (max_usd_above_default). At most one executed check per project and engine per hour: a second is refused with visibility_check_rate_limited and retry_after_seconds; a dry run reports rate_limited instead. This call is a dry run unless execute: true: without it nothing is called, reserved or written and the result shows the prompt count, estimated cost, the ceiling in force and the credit cost.",
635
+ inputSchema: {
636
+ type: 'object',
637
+ properties: {
638
+ project: { type: 'string', description: 'project slug or uuid' },
639
+ engine: { type: 'string', description: 'one engine slug, e.g. chatgpt' },
640
+ max_usd: { type: 'number', description: 'lower the per-call USD ceiling; above the default is refused' },
641
+ execute: { type: 'boolean', description: 'must be true to collect and bill; otherwise dry run' },
642
+ },
643
+ required: ['project', 'engine'],
644
+ },
645
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/visibility-check`,
646
+ method: 'POST',
647
+ body: (a) => ({
648
+ engine: a['engine'],
649
+ ...('max_usd' in a ? { max_usd: a['max_usd'] } : {}),
650
+ execute: a['execute'] === true,
651
+ }),
652
+ },
653
+ {
654
+ name: 'get_page_evidence',
655
+ description: 'Read-only page evidence for a project URL, query, and market. It fetches no pages and calls no provider. Top results are not collected yet, so top is usually empty and the response has unpaid: true. That is a normal result, not an error.',
656
+ inputSchema: {
657
+ type: 'object',
658
+ properties: {
659
+ project: { type: 'string', description: 'project slug or uuid' },
660
+ url: { type: 'string', description: 'page URL to inspect' },
661
+ query: { type: 'string', description: 'search query' },
662
+ market: { type: 'string', description: 'market key, e.g. se-sv' },
663
+ },
664
+ required: ['project', 'url', 'query', 'market'],
665
+ },
666
+ path: (a) => {
667
+ const project = str(a, 'project');
668
+ // tools/call does not enforce inputSchema.required. The route answers 400
669
+ // without these, so refuse here and never fetch.
670
+ const url = str(a, 'url');
671
+ const searchQuery = str(a, 'query');
672
+ const market = str(a, 'market');
673
+ return `/v1/projects/${encodeURIComponent(project)}/page-evidence${query({
674
+ url,
675
+ query: searchQuery,
676
+ market,
677
+ })}`;
678
+ },
679
+ },
680
+ {
681
+ name: 'refresh_corpus',
682
+ description: 'Run the DB-only corpus staleness pass for a project: active pages past verify_interval become stale, stale pages past twice verify_interval become removed, and the result reports the due re-verification queue (due count and duePages). The RQ1-3 re-verification fetch pass is not run by this tool; it fetches no pages and makes no paid calls. This call is a dry run unless execute: true: without it nothing is written and the result describes what would change.',
683
+ inputSchema: {
684
+ type: 'object',
685
+ properties: {
686
+ project: { type: 'string', description: 'project slug or uuid' },
687
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
688
+ },
689
+ required: ['project'],
690
+ },
691
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/corpus/refresh`,
692
+ method: 'POST',
693
+ body: (a) => ({ execute: a['execute'] === true }),
694
+ },
695
+ {
696
+ name: 'process_project',
697
+ description: "Process a project's collected runs: extract citations from every run not yet extracted, build the corpus, then score the presence gap, so get_corpus, get_presence_gap and create_publish_brief have data. Scoped to the key's own workspace: another workspace's project is project_not_found. Zero provider spend: no paid search call and no page fetch; presence page fetches are check_presence's (paid, per page). This call is a dry run unless execute: true: without it nothing is written and the result lists the steps that would run and the current counts (collected and pending runs, corpus pages, opportunities, last build). Refusals: no_collections (nothing collected yet), process_running with running_id (one run per project at a time). With nothing new since the last build, execute is a no-op (noop: true) with the same result shape.",
698
+ inputSchema: {
699
+ type: 'object',
700
+ properties: {
701
+ project: { type: 'string', description: 'project slug or uuid' },
702
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
703
+ },
704
+ required: ['project'],
705
+ },
706
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/process`,
707
+ method: 'POST',
708
+ body: (a) => ({ execute: a['execute'] === true }),
709
+ },
710
+ {
711
+ name: 'check_presence',
712
+ description: "Check presence for a project's due corpus pages: fetch each page and record whether the brand appears, so get_presence_gap and create_publish_brief have data (run process_project afterwards to rescore the gap). Paid: billed in credits per page that got a verdict, reserved before the first fetch and settled after; a page that could not be read (blocked, js_required, auth_wall, an error status) gets no verdict and is not billed. max_pages is required (1 to 50, the hard cap: max_pages_above_cap); due pages past it stay due for the next call. This call is a dry run unless execute: true: without it nothing is fetched or billed and the result shows due, pages, credits and available. Refusals before any fetch: credits_exhausted, workspace_frozen, max_pages_required, invalid_max_pages, max_pages_above_cap. Scoped to the key's own workspace: another workspace's project is project_not_found. Tenant zero is refused with presence_tenant_zero.",
713
+ inputSchema: {
714
+ type: 'object',
715
+ properties: {
716
+ project: { type: 'string', description: 'project slug or uuid' },
717
+ max_pages: { type: 'number', description: 'required: at most this many due pages are fetched (1 to 50)' },
718
+ execute: { type: 'boolean', description: 'must be true to fetch and bill; otherwise dry run' },
719
+ },
720
+ required: ['project', 'max_pages'],
721
+ },
722
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/presence/check`,
723
+ method: 'POST',
724
+ body: (a) => ({ max_pages: a['max_pages'], execute: a['execute'] === true }),
725
+ },
726
+ {
727
+ name: 'get_collection_schedule',
728
+ description: "A project's weekly collection schedule, or schedule: null when it has none: engines, max_credits_per_run, enabled, who created it, and last_run (at, status ran|failed|refused|skipped, reason, job_id) once the weekly workspaces job has fired. Scoped to the key's own workspace: another workspace's project is project_not_found. Tenant zero is refused with schedule_tenant_zero (its cadence is the operator's config).",
729
+ inputSchema: projectArg,
730
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/schedule`,
731
+ },
732
+ {
733
+ name: 'set_collection_schedule',
734
+ description: "Create or update a project's weekly collection: every Monday the workspaces job collects the named engines for every active prompt and market, billed in credits, then processes the runs (as process_project). max_credits_per_run is the per-run cap: a run whose estimate exceeds it is refused and recorded in last_run, never cut down. A frozen workspace is skipped, a short one refused, both recorded. Omitted fields keep their value; a new schedule needs engines and max_credits_per_run. cadence is weekly only. This call is a dry run unless execute: true: without it nothing is written, and the result shows before, after and estimate (credits the next run needs now, and within_cap). Scoped to the key's own workspace; tenant zero is refused with schedule_tenant_zero.",
735
+ inputSchema: {
736
+ type: 'object',
737
+ properties: {
738
+ project: { type: 'string', description: 'project slug or uuid' },
739
+ engines: { type: 'array', items: { type: 'string' }, description: 'engine slugs, e.g. ["chatgpt","perplexity","google-ai-mode"]' },
740
+ max_credits_per_run: { type: 'number', description: 'integer >= 1: a run needing more is refused' },
741
+ enabled: { type: 'boolean', description: 'false pauses the schedule; default true' },
742
+ cadence: { type: 'string', description: 'weekly (the only cadence)' },
743
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
744
+ },
745
+ required: ['project'],
746
+ },
747
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/schedule`,
748
+ method: 'POST',
749
+ body: (a) => {
750
+ const out = { execute: a['execute'] === true };
751
+ for (const key of ['engines', 'max_credits_per_run', 'enabled', 'cadence'])
752
+ if (a[key] !== undefined)
753
+ out[key] = a[key];
754
+ return out;
755
+ },
756
+ },
757
+ {
758
+ name: 'create_project',
759
+ description: 'Create or update one project in a workspace. This call is a dry run unless execute: true: without it nothing is written and the result describes what would happen (create or update, and for an update the prompt count before and after, since the prompt set is replaced). A workspace key writes only its own workspace: omit workspace or name your own; any other workspace is refused with create_project_workspace_mismatch. The operator key must name the workspace (slug or uuid). Tenant zero is refused for every caller with create_project_tenant_zero. project is one project as in config/portfolio.json (slug, name, domain, category, entityDescription, brandAliases, competitors, source, prompts; active defaults to true), validated per field (invalid_project with issues). An existing slug in that workspace is updated, not duplicated, and its prompt set replaced; no other project is ever deactivated. If no prompt carries a cluster, placement gets a control group automatically: every prompt goes to treated cluster C1, round(10%) of them (at least 1; unbranded only, chosen by a stable hash of the text, so the same prompts give the same set) are held out in C9, and control_cluster is set to C9; the result shows control: {cluster, prompts, auto: true}. Under 3 prompts nothing is held out and control: {auto: false, reason} says how to tag prompts and call set_control_cluster. Tag any prompt (with clusters declared) and nothing is automatic; if the project had the automatic C9 and the new prompts no longer carry one, control_cluster is cleared (placement fails closed until set_control_cluster). Starts no collection and makes no paid call. Every refusal fires on a dry run too.',
760
+ inputSchema: {
761
+ type: 'object',
762
+ properties: {
763
+ workspace: { type: 'string', description: 'target workspace slug or uuid; a workspace key may omit it (its own) and may name no other; never tenant zero' },
764
+ project: { type: 'object', description: 'one project, same shape as a config/portfolio.json projects[] entry' },
765
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
766
+ },
767
+ required: ['project'],
768
+ },
769
+ path: () => '/v1/projects',
770
+ method: 'POST',
771
+ body: (a) => ({ workspace: a['workspace'], project: a['project'], execute: a['execute'] === true }),
772
+ },
773
+ // Approvals (G4). An agent requests and reads; it can never grant or reject: only the operator
774
+ // CLI (`ranq approvals grant|reject`) decides, so no tool here takes a decision (D3).
775
+ {
776
+ name: 'request_approval',
777
+ description: 'Stage an outreach send for human approval. This call is a dry run unless execute: true: without it nothing is written and the result is the payload sha256. kind is outreach_send; manifest is a filled outreach manifest (version 1, project, projectId, stagedAt, items with placementId, url, ownerRouteLabel and a draft subject/body, no contact data); account_id is the outreach inbox uuid; recipients maps exactly the manifest placement ids to addresses and is hashed, never stored. One item per approval (no approve-all): a manifest with more items is invalid_approval; a NUL byte or a stagedAt that is not a real instant is invalid_manifest. Returns the approval id and payload_sha256. A human grants it outside this API; poll get_approval for status granted.',
778
+ inputSchema: {
779
+ type: 'object',
780
+ properties: {
781
+ project: { type: 'string', description: 'project slug or uuid' },
782
+ kind: { type: 'string', description: 'outreach_send' },
783
+ manifest: { type: 'object' },
784
+ account_id: { type: 'string' },
785
+ recipients: { type: 'object', description: '{ "<placementId>": "<address>" }' },
786
+ execute: { type: 'boolean', description: 'must be true to write; otherwise dry run' },
787
+ },
788
+ required: ['project', 'kind', 'manifest', 'account_id', 'recipients'],
789
+ },
790
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/approvals`,
791
+ method: 'POST',
792
+ body: (a) => ({ kind: a['kind'], manifest: a['manifest'], account_id: a['account_id'], recipients: a['recipients'], execute: a['execute'] === true }),
793
+ },
794
+ {
795
+ name: 'list_approvals',
796
+ description: 'List this project\'s approval requests, newest first (at most 200). status filters: pending | granted | rejected | expired | consumed.',
797
+ inputSchema: {
798
+ type: 'object',
799
+ properties: { project: { type: 'string', description: 'project slug or uuid' }, status: { type: 'string' } },
800
+ required: ['project'],
801
+ },
802
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/approvals${query({ status: a['status'] })}`,
803
+ },
804
+ {
805
+ name: 'get_approval',
806
+ description: 'One approval request: status (pending | granted | rejected | expired | consumed), payload, payload_sha256, who decided and when. approval_not_found for an id outside this workspace.',
807
+ inputSchema: {
808
+ type: 'object',
809
+ properties: { project: { type: 'string', description: 'project slug or uuid' }, id: { type: 'string' } },
810
+ required: ['project', 'id'],
811
+ },
812
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/approvals/${encodeURIComponent(str(a, 'id'))}`,
813
+ },
814
+ {
815
+ name: 'send_approved',
816
+ description: 'Send a granted approval. This call is a dry run unless execute: true: without it every check runs and nothing is consumed or sent. sha256 must equal the approval payload_sha256 and recipients must hash to its recipients_sha256. Refused with approval_pending (not yet granted), approval_not_granted (rejected), approval_expired, approval_consumed (each approval sends at most once) or approval_sha_mismatch.',
817
+ inputSchema: {
818
+ type: 'object',
819
+ properties: {
820
+ project: { type: 'string', description: 'project slug or uuid' },
821
+ id: { type: 'string' },
822
+ sha256: { type: 'string' },
823
+ recipients: { type: 'object', description: '{ "<placementId>": "<address>" }' },
824
+ execute: { type: 'boolean', description: 'must be true to send; otherwise dry run' },
825
+ },
826
+ required: ['project', 'id', 'sha256', 'recipients'],
827
+ },
828
+ path: (a) => `/v1/projects/${encodeURIComponent(str(a, 'project'))}/approvals/${encodeURIComponent(str(a, 'id'))}/send`,
829
+ method: 'POST',
830
+ body: (a) => ({ sha256: a['sha256'], recipients: a['recipients'], execute: a['execute'] === true }),
831
+ },
832
+ ];