@superagnt/dub-links 2.0.2

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/index.js ADDED
@@ -0,0 +1,1971 @@
1
+ /**
2
+ * Dub Integration — OpenClaw plugin
3
+ * Auto-generated by @superagnt/clawhub. Do not edit by hand.
4
+ */
5
+
6
+ import { homedir as _homedir } from 'node:os'
7
+ import { join as _join } from 'node:path'
8
+ import { existsSync as _existsSync, readFileSync as _readFileSync } from 'node:fs'
9
+
10
+ const BASE_URL = 'https://api.superagnt.com/v1/connections/dub'
11
+
12
+
13
+ // ── Auth Module (inlined) ────────────────────────────────────────────────────
14
+
15
+ function getConfigPath() {
16
+ return _join(_homedir(), '.superagnt', 'config.json')
17
+ }
18
+
19
+ function readAgntConfig() {
20
+ const configFile = getConfigPath()
21
+ if (!_existsSync(configFile)) return null
22
+ try {
23
+ return JSON.parse(_readFileSync(configFile, 'utf-8'))
24
+ } catch {
25
+ return null
26
+ }
27
+ }
28
+
29
+ // ── End Auth Module ──────────────────────────────────────────────────────────
30
+
31
+
32
+ // ── CLI Module (inlined) ─────────────────────────────────────────────────────
33
+
34
+ function maskApiKey(key) {
35
+ if (!key || typeof key !== 'string') return '(none)'
36
+ const k = key.trim()
37
+ if (k.length <= 8) return k.slice(0, 2) + '…'
38
+ return k.slice(0, 6) + '…' + k.slice(-4)
39
+ }
40
+
41
+ function registerAgntCli(api) {
42
+ api.registerCli(
43
+ ({ program }) => {
44
+ const cmd = program
45
+ .command('superagnt')
46
+ .description('superagnt social data API (status, doctor)')
47
+
48
+ cmd
49
+ .command('status')
50
+ .description('Show whether an API key is configured (masked)')
51
+ .action(async () => {
52
+ const cfg = readAgntConfig()
53
+ const key = cfg?.apiKey
54
+
55
+ console.log('\nsuperagnt status\n')
56
+ if (!key) {
57
+ console.log(' API key: not configured')
58
+ console.log(' Workspace: —')
59
+ console.log('\n Get your API key at: https://app.superagnt.com/dashboard\n')
60
+ return
61
+ }
62
+ console.log(' API key: ' + maskApiKey(key) + ' (from ~/.superagnt/config.json)')
63
+ console.log(' Workspace: ' + (cfg?.workspaceId ?? '—'))
64
+ console.log('')
65
+ })
66
+
67
+ cmd
68
+ .command('doctor')
69
+ .description('Check connectivity and validate API key against api.superagnt.dev')
70
+ .action(async () => {
71
+ console.log('\nsuperagnt doctor\n')
72
+
73
+ try {
74
+ const publicRes = await fetch('https://api.superagnt.com/v1/platforms')
75
+ console.log(' Public API: ' + (publicRes.ok ? 'OK (' + publicRes.status + ')' : 'HTTP ' + publicRes.status))
76
+ } catch (err) {
77
+ const msg = err instanceof Error ? err.message : String(err)
78
+ console.log(' Public API: failed — ' + msg)
79
+ }
80
+
81
+ const cfg = readAgntConfig()
82
+ const key = cfg?.apiKey
83
+
84
+ if (!key) {
85
+ console.log('\n Authenticated: skipped (no API key)')
86
+ console.log(' Get your API key at: https://app.superagnt.com/dashboard\n')
87
+ return
88
+ }
89
+
90
+ try {
91
+ const res = await fetch('https://api.superagnt.com/v1/platforms', {
92
+ headers: { Authorization: 'Bearer ' + key },
93
+ })
94
+ const text = await res.text()
95
+ let summary = 'HTTP ' + res.status
96
+ if (res.ok) {
97
+ try {
98
+ const json = JSON.parse(text)
99
+ const n = Array.isArray(json?.data) ? json.data.length : (json?.data ? Object.keys(json.data).length : 'ok')
100
+ summary = 'OK — platforms payload received (' + (typeof n === 'number' ? n + ' entries' : String(n)) + ')'
101
+ } catch {
102
+ summary = 'OK (' + res.status + ')'
103
+ }
104
+ }
105
+ console.log(' Authenticated: ' + summary)
106
+ if (!res.ok) {
107
+ console.log(' If 401, get a new key at: https://app.superagnt.com/dashboard')
108
+ }
109
+ } catch (err) {
110
+ const msg = err instanceof Error ? err.message : String(err)
111
+ console.log(' Authenticated: failed — ' + msg)
112
+ }
113
+ console.log('')
114
+ })
115
+ },
116
+ { commands: ['superagnt'] },
117
+ )
118
+ }
119
+
120
+ // ── End CLI Module ───────────────────────────────────────────────────────────
121
+
122
+
123
+ // ── System prompt (inlined) ─────────────────────────────────────────────────
124
+
125
+ function getSystemPrompt(state) {
126
+ const scope = "Only the Dub integration (dub)."
127
+ if (state.ready && state.toolCount > 0) {
128
+ return (
129
+ '<superagnt>\n' +
130
+ 'Ignore pretrained knowledge about superagnt tool names — use only tools that exist in this session.\n' +
131
+ '\n' +
132
+ '## What superagnt is\n' +
133
+ 'superagnt exposes **structured social-data HTTP APIs** behind OpenClaw tools. Scope for this plugin: **' + scope + '**.\n' +
134
+ '\n' +
135
+ '## When to use superagnt tools\n' +
136
+ '- Use superagnt when the user needs **live social/network data** (profiles, posts, companies, comments, etc.) from supported platforms.\n' +
137
+ '- Prefer **discovery** when unsure which endpoint fits: call public discovery (GET /v1/platforms and GET /v1/platforms/{slug}) or read tool descriptions; do not invent endpoints or parameters.\n' +
138
+ '\n' +
139
+ '## Platform selection (high level)\n' +
140
+ '- **linkedin** — B2B enrichment, org/person research, hiring/sales workflows\n' +
141
+ '- **youtube** / **tiktok** — video/creator/channel metadata and content signals\n' +
142
+ '- **x** / **reddit** — short-form social and community threads\n' +
143
+ '- **instagram** — visual/creator discovery where Instagram is the source of truth\n' +
144
+ '- **facebook** — pages/groups/marketplace/adjacent Facebook surface areas exposed by the API\n' +
145
+ '\n' +
146
+ '## Rules\n' +
147
+ '- Do **not** fabricate tool names — pick from the registered superagnt_* tools only.\n' +
148
+ '- If authentication fails (401), tell the user to get a new key at https://app.superagnt.com/dashboard\n' +
149
+ '</superagnt>'
150
+ )
151
+ }
152
+
153
+ if (state.ready && state.toolCount === 0) {
154
+ return (
155
+ '<superagnt>\n' +
156
+ 'The superagnt plugin loaded but registered **zero** API tools. Check your OpenClaw plugin packaging and regenerate the plugin from @superagnt/clawhub.\n' +
157
+ '</superagnt>'
158
+ )
159
+ }
160
+
161
+ if (state.error) {
162
+ return (
163
+ '<superagnt>\n' +
164
+ 'superagnt plugin diagnostic: ' + state.error + '\n' +
165
+ 'Do not pretend superagnt tools exist. Ask the user to fix configuration and restart the gateway.\n' +
166
+ '</superagnt>'
167
+ )
168
+ }
169
+
170
+ return (
171
+ '<superagnt>\n' +
172
+ 'superagnt tools are still loading. If the user asks for social data right now, ask them to wait a moment and retry.\n' +
173
+ '</superagnt>'
174
+ )
175
+ }
176
+
177
+ // ── End System prompt ────────────────────────────────────────────────────────
178
+
179
+ const MCP_URL = 'https://mcp.superagnt.com/mcp'
180
+
181
+ async function mcpRpc(token, method, params) {
182
+ const res = await fetch(MCP_URL, {
183
+ method: 'POST',
184
+ headers: {
185
+ Authorization: `Bearer ${token}`,
186
+ 'Content-Type': 'application/json',
187
+ Accept: 'application/json, text/event-stream',
188
+ },
189
+ body: JSON.stringify({ jsonrpc: '2.0', id: Date.now(), method, params }),
190
+ })
191
+ if (!res.ok) throw new Error(`MCP ${method} failed: HTTP ${res.status}`)
192
+ const data = await res.json()
193
+ if (data.error) throw new Error(`MCP ${method} error: ${data.error.message}`)
194
+ return data.result
195
+ }
196
+
197
+ async function registerLiveMcpTools(api, token) {
198
+ const result = await mcpRpc(token, 'tools/list', {})
199
+ const tools = Array.isArray(result?.tools) ? result.tools : []
200
+ if (tools.length === 0) throw new Error('MCP tools/list returned no tools')
201
+ for (const t of tools) {
202
+ api.registerTool({
203
+ name: t.name,
204
+ description: t.description,
205
+ inputSchema: t.inputSchema,
206
+ execute: async (input) => {
207
+ const args = parseToolInput(input)
208
+ const r = await mcpRpc(token, 'tools/call', { name: t.name, arguments: args })
209
+ if (r && r.structuredContent !== undefined) return r.structuredContent
210
+ const text = Array.isArray(r?.content) ? r.content.find((c) => c.type === 'text')?.text : undefined
211
+ if (text === undefined) return r
212
+ try { return JSON.parse(text) } catch { return text }
213
+ },
214
+ })
215
+ }
216
+ return tools.length
217
+ }
218
+
219
+ function parseToolInput(input) {
220
+ if (input == null) return {}
221
+ if (typeof input === 'object' && !Array.isArray(input)) return input
222
+ if (typeof input === 'string') {
223
+ const trimmed = input.trim()
224
+ if (trimmed.startsWith('{')) {
225
+ try { const parsed = JSON.parse(trimmed); if (typeof parsed === 'object' && parsed && !Array.isArray(parsed)) return parsed } catch {}
226
+ }
227
+ throw new Error('Invalid tool input: expected a JSON object with named parameters, got string: ' + trimmed.slice(0, 80))
228
+ }
229
+ throw new Error('Invalid tool input: expected a JSON object, got ' + typeof input)
230
+ }
231
+
232
+ function substitutePathParams(path, source) {
233
+ if (!source || typeof source !== 'object' || Array.isArray(source)) {
234
+ return { path, consumed: new Set() }
235
+ }
236
+ const consumed = new Set()
237
+ const next = path.replace(/\{([^/{}]+)\}/g, (_, name) => {
238
+ const v = source[name]
239
+ if (v === undefined || v === null || v === '') return `{${name}}`
240
+ consumed.add(name)
241
+ return encodeURIComponent(String(v))
242
+ })
243
+ return { path: next, consumed }
244
+ }
245
+
246
+ async function callSuperagnt(apiKey, method, path, query, body) {
247
+ const params = (query && typeof query === 'object' && !Array.isArray(query)) ? query : body
248
+ const { path: resolvedPath, consumed } = substitutePathParams(path, params)
249
+ const url = new URL(`${BASE_URL}${resolvedPath}`)
250
+ if (query && typeof query === 'object' && !Array.isArray(query)) {
251
+ for (const [k, v] of Object.entries(query)) {
252
+ if (consumed.has(k)) continue
253
+ if (v !== undefined && v !== '') url.searchParams.set(k, String(v))
254
+ }
255
+ }
256
+ const filteredBody = body && typeof body === 'object' && !Array.isArray(body)
257
+ ? Object.fromEntries(Object.entries(body).filter(([k]) => !consumed.has(k)))
258
+ : body
259
+ const res = await fetch(url.toString(), {
260
+ method,
261
+ headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
262
+ body: filteredBody ? JSON.stringify(filteredBody) : undefined,
263
+ })
264
+ if (res.status === 401) {
265
+ return { error: 'Invalid or expired API key. Get a new key at https://app.superagnt.com/dashboard' }
266
+ }
267
+ return res.json()
268
+ }
269
+
270
+ export default async function register(api) {
271
+ const apiKey = api.pluginConfig.apiKey || process.env.SUPERAGNT_API_KEY || readAgntConfig()?.apiKey
272
+ const mcpToken = api.pluginConfig.mcpToken || process.env.SUPERAGNT_MCP_TOKEN
273
+
274
+ function ensureApiKey() {
275
+ if (apiKey) return apiKey
276
+ throw new Error(
277
+ '[dub-links] No API key configured. ' +
278
+ 'Get your key at https://app.superagnt.com/dashboard and either:\n' +
279
+ ' 1. Export it as SUPERAGNT_API_KEY, or\n' +
280
+ ' 2. Add apiKey to your plugin config'
281
+ )
282
+ }
283
+
284
+ registerAgntCli(api)
285
+
286
+ const promptState = { toolCount: 0, error: '', ready: false }
287
+ api.on('before_prompt_build', () => ({
288
+ prependSystemContext: getSystemPrompt(promptState),
289
+ }))
290
+
291
+ // Live MCP mode: a workspace MCP token upgrades this plugin to the server's
292
+ // own tool surface, fetched fresh at load — it grows with agnt_tools_enable
293
+ // and never goes stale. Any failure falls back to the baked toolset below.
294
+ if (mcpToken) {
295
+ try {
296
+ promptState.toolCount = await registerLiveMcpTools(api, mcpToken)
297
+ promptState.ready = true
298
+ return
299
+ } catch (err) {
300
+ promptState.error = 'Live MCP connect failed (' + (err && err.message ? err.message : err) + '); using the built-in toolset.'
301
+ }
302
+ }
303
+
304
+ api.registerTool({
305
+ name: 'superagnt_connection_dub_getLinks',
306
+ description: "Retrieve a list of links",
307
+ inputSchema: {
308
+ "type": "object",
309
+ "properties": {
310
+ "domain": {
311
+ "type": "string",
312
+ "description": "The domain to filter the links by (e.g. `ac.me`). If not provided, all links for the workspace will be returned."
313
+ },
314
+ "tagIds": {
315
+ "type": "string",
316
+ "description": "The tag IDs to filter the links by."
317
+ },
318
+ "tagNames": {
319
+ "type": "string",
320
+ "description": "The unique name of the tags assigned to the short link (case insensitive)."
321
+ },
322
+ "folderId": {
323
+ "type": "string",
324
+ "description": "The folder ID to filter the links by."
325
+ },
326
+ "search": {
327
+ "type": "string",
328
+ "description": "Free-text search applied to the short link slug and destination URL."
329
+ },
330
+ "userId": {
331
+ "type": "string",
332
+ "description": "The user ID to filter the links by."
333
+ },
334
+ "tenantId": {
335
+ "type": "string",
336
+ "description": "The tenant ID (from your system) to filter the links by."
337
+ },
338
+ "showArchived": {
339
+ "type": "boolean",
340
+ "description": "Whether to include archived links in the response."
341
+ },
342
+ "sortBy": {
343
+ "type": "string",
344
+ "description": "The field to sort the links by."
345
+ },
346
+ "sortOrder": {
347
+ "type": "string",
348
+ "description": "The sort order."
349
+ },
350
+ "endingBefore": {
351
+ "type": "string",
352
+ "description": "Cursor pagination — only return results before this cursor. Mutually exclusive with `startingAfter`."
353
+ },
354
+ "startingAfter": {
355
+ "type": "string",
356
+ "description": "Cursor pagination — only return results after this cursor. Mutually exclusive with `endingBefore`."
357
+ },
358
+ "page": {
359
+ "type": "number",
360
+ "description": "Page number for pagination (deprecated — prefer cursor pagination)."
361
+ },
362
+ "pageSize": {
363
+ "type": "number",
364
+ "description": "Number of items per page (max 100)."
365
+ }
366
+ }
367
+ },
368
+ execute: async (input) => {
369
+ const key = await ensureApiKey()
370
+ const params = parseToolInput(input)
371
+ return callSuperagnt(key, 'GET', '/links', params)
372
+ },
373
+ })
374
+
375
+ api.registerTool({
376
+ name: 'superagnt_connection_dub_createLink',
377
+ description: "Create a link",
378
+ inputSchema: {
379
+ "type": "object",
380
+ "properties": {}
381
+ },
382
+ execute: async (input) => {
383
+ const key = await ensureApiKey()
384
+ const params = parseToolInput(input)
385
+ return callSuperagnt(key, 'POST', '/links', undefined, params)
386
+ },
387
+ })
388
+
389
+ api.registerTool({
390
+ name: 'superagnt_connection_dub_upsertLink',
391
+ description: "Upsert a link",
392
+ inputSchema: {
393
+ "type": "object",
394
+ "properties": {}
395
+ },
396
+ execute: async (input) => {
397
+ const key = await ensureApiKey()
398
+ const params = parseToolInput(input)
399
+ return callSuperagnt(key, 'PUT', '/links', undefined, params)
400
+ },
401
+ })
402
+
403
+ api.registerTool({
404
+ name: 'superagnt_connection_dub_getLinkInfo',
405
+ description: "Retrieve a link",
406
+ inputSchema: {
407
+ "type": "object",
408
+ "properties": {
409
+ "domain": {
410
+ "type": "string",
411
+ "description": "The domain of the link to retrieve. E.g. for `d.to/github`, the domain is `d.to`."
412
+ },
413
+ "key": {
414
+ "type": "string",
415
+ "description": "The key of the link to retrieve. E.g. for `d.to/github`, the key is `github`."
416
+ },
417
+ "linkId": {
418
+ "type": "string",
419
+ "description": "The unique ID of the short link."
420
+ },
421
+ "externalId": {
422
+ "type": "string",
423
+ "description": "The external ID of the link in your database."
424
+ }
425
+ }
426
+ },
427
+ execute: async (input) => {
428
+ const key = await ensureApiKey()
429
+ const params = parseToolInput(input)
430
+ return callSuperagnt(key, 'GET', '/links/info', params)
431
+ },
432
+ })
433
+
434
+ api.registerTool({
435
+ name: 'superagnt_connection_dub_getLinksCount',
436
+ description: "Retrieve links count",
437
+ inputSchema: {
438
+ "type": "object",
439
+ "properties": {
440
+ "domain": {
441
+ "type": "string",
442
+ "description": "Filter links by domain."
443
+ },
444
+ "tagIds": {
445
+ "type": "string",
446
+ "description": "The tag IDs to filter the links by."
447
+ },
448
+ "folderId": {
449
+ "type": "string",
450
+ "description": "The folder ID to filter the links by."
451
+ },
452
+ "search": {
453
+ "type": "string",
454
+ "description": "Free-text search applied to the short link slug and destination URL."
455
+ },
456
+ "userId": {
457
+ "type": "string",
458
+ "description": "Filter links by the creator's user ID."
459
+ },
460
+ "tenantId": {
461
+ "type": "string",
462
+ "description": "Filter links by tenant ID."
463
+ },
464
+ "showArchived": {
465
+ "type": "boolean",
466
+ "description": "Whether to include archived links."
467
+ },
468
+ "groupBy": {
469
+ "type": "string",
470
+ "description": "Group the count by a dimension."
471
+ }
472
+ }
473
+ },
474
+ execute: async (input) => {
475
+ const key = await ensureApiKey()
476
+ const params = parseToolInput(input)
477
+ return callSuperagnt(key, 'GET', '/links/count', params)
478
+ },
479
+ })
480
+
481
+ api.registerTool({
482
+ name: 'superagnt_connection_dub_updateLink',
483
+ description: "Update a link",
484
+ inputSchema: {
485
+ "type": "object",
486
+ "properties": {
487
+ "linkId": {
488
+ "type": "string",
489
+ "description": "The id of the link to update. You may use either `linkId` (obtained via `/links/info`) or `externalId` prefixed with `ext_`."
490
+ }
491
+ },
492
+ "required": [
493
+ "linkId"
494
+ ]
495
+ },
496
+ execute: async (input) => {
497
+ const key = await ensureApiKey()
498
+ const params = parseToolInput(input)
499
+ return callSuperagnt(key, 'PATCH', '/links/{linkId}', undefined, params)
500
+ },
501
+ })
502
+
503
+ api.registerTool({
504
+ name: 'superagnt_connection_dub_deleteLink',
505
+ description: "Delete a link",
506
+ inputSchema: {
507
+ "type": "object",
508
+ "properties": {
509
+ "linkId": {
510
+ "type": "string",
511
+ "description": "The id of the link to delete. You may use either `linkId` or `externalId` prefixed with `ext_`."
512
+ }
513
+ },
514
+ "required": [
515
+ "linkId"
516
+ ]
517
+ },
518
+ execute: async (input) => {
519
+ const key = await ensureApiKey()
520
+ const params = parseToolInput(input)
521
+ return callSuperagnt(key, 'DELETE', '/links/{linkId}', undefined, params)
522
+ },
523
+ })
524
+
525
+ api.registerTool({
526
+ name: 'superagnt_connection_dub_bulkCreateLinks',
527
+ description: "Bulk create links",
528
+ inputSchema: {
529
+ "type": "object",
530
+ "properties": {}
531
+ },
532
+ execute: async (input) => {
533
+ const key = await ensureApiKey()
534
+ const params = parseToolInput(input)
535
+ return callSuperagnt(key, 'POST', '/links/bulk', undefined, params)
536
+ },
537
+ })
538
+
539
+ api.registerTool({
540
+ name: 'superagnt_connection_dub_bulkUpdateLinks',
541
+ description: "Bulk update links",
542
+ inputSchema: {
543
+ "type": "object",
544
+ "properties": {
545
+ "linkIds": {
546
+ "type": "array",
547
+ "description": "The IDs of the links to update. Takes precedence over `externalIds`."
548
+ },
549
+ "externalIds": {
550
+ "type": "array",
551
+ "description": "The external IDs of the links to update (as stored in your database)."
552
+ },
553
+ "data": {
554
+ "type": "string",
555
+ "description": "Partial link properties to apply to every targeted link. `domain`, `key`, `prefix`, and `keyLength` are ignored."
556
+ }
557
+ },
558
+ "required": [
559
+ "data"
560
+ ]
561
+ },
562
+ execute: async (input) => {
563
+ const key = await ensureApiKey()
564
+ const params = parseToolInput(input)
565
+ return callSuperagnt(key, 'PATCH', '/links/bulk', undefined, params)
566
+ },
567
+ })
568
+
569
+ api.registerTool({
570
+ name: 'superagnt_connection_dub_bulkDeleteLinks',
571
+ description: "Bulk delete links",
572
+ inputSchema: {
573
+ "type": "object",
574
+ "properties": {
575
+ "linkIds": {
576
+ "type": "array",
577
+ "description": "Comma-separated list of link IDs to delete (max 100). Non-existing IDs are ignored."
578
+ }
579
+ },
580
+ "required": [
581
+ "linkIds"
582
+ ]
583
+ },
584
+ execute: async (input) => {
585
+ const key = await ensureApiKey()
586
+ const params = parseToolInput(input)
587
+ return callSuperagnt(key, 'DELETE', '/links/bulk', undefined, params)
588
+ },
589
+ })
590
+
591
+ api.registerTool({
592
+ name: 'superagnt_connection_dub_retrieveAnalytics',
593
+ description: "Retrieve analytics",
594
+ inputSchema: {
595
+ "type": "object",
596
+ "properties": {
597
+ "event": {
598
+ "type": "string",
599
+ "description": "The type of event to retrieve analytics for."
600
+ },
601
+ "groupBy": {
602
+ "type": "string",
603
+ "description": "The dimension to group the analytics data points by."
604
+ },
605
+ "domain": {
606
+ "type": "string",
607
+ "description": "The domain to filter analytics for. Supports advanced filtering: comma-separated values or `-` exclusion prefix."
608
+ },
609
+ "key": {
610
+ "type": "string",
611
+ "description": "The slug of the short link to retrieve analytics for. Must be used with `domain`."
612
+ },
613
+ "linkId": {
614
+ "type": "string",
615
+ "description": "The unique ID of the link to retrieve analytics for."
616
+ },
617
+ "externalId": {
618
+ "type": "string",
619
+ "description": "The external ID (your DB ID) of the link, prefixed with `ext_`."
620
+ },
621
+ "tenantId": {
622
+ "type": "string",
623
+ "description": "The tenant ID to filter analytics by."
624
+ },
625
+ "tagId": {
626
+ "type": "string",
627
+ "description": "The tag ID to filter analytics by."
628
+ },
629
+ "folderId": {
630
+ "type": "string",
631
+ "description": "The folder ID to filter analytics by."
632
+ },
633
+ "groupId": {
634
+ "type": "string",
635
+ "description": "The partner-group ID to filter analytics by."
636
+ },
637
+ "partnerId": {
638
+ "type": "string",
639
+ "description": "The partner ID to filter analytics by."
640
+ },
641
+ "customerId": {
642
+ "type": "string",
643
+ "description": "The customer ID to filter analytics by."
644
+ },
645
+ "interval": {
646
+ "type": "string",
647
+ "description": "The interval to retrieve analytics for. Defaults to `24h`."
648
+ },
649
+ "start": {
650
+ "type": "string",
651
+ "description": "The start date and time. If set, takes precedence over `interval`."
652
+ },
653
+ "end": {
654
+ "type": "string",
655
+ "description": "The end date and time. If set with `start`, takes precedence over `interval`."
656
+ },
657
+ "timezone": {
658
+ "type": "string",
659
+ "description": "IANA time zone code (e.g. `America/New_York`) used to align timeseries granularity."
660
+ },
661
+ "country": {
662
+ "type": "string",
663
+ "description": "Filter by 2-letter ISO 3166-1 country code."
664
+ },
665
+ "city": {
666
+ "type": "string",
667
+ "description": "Filter by city."
668
+ },
669
+ "region": {
670
+ "type": "string",
671
+ "description": "Filter by ISO 3166-2 region code."
672
+ },
673
+ "continent": {
674
+ "type": "string",
675
+ "description": "Filter by continent (`AF`, `AN`, `AS`, `EU`, `NA`, `OC`, `SA`)."
676
+ },
677
+ "device": {
678
+ "type": "string",
679
+ "description": "Filter by device (e.g. `Desktop`, `Mobile`, `Tablet`)."
680
+ },
681
+ "browser": {
682
+ "type": "string",
683
+ "description": "Filter by browser (e.g. `Chrome`, `Firefox`)."
684
+ },
685
+ "os": {
686
+ "type": "string",
687
+ "description": "Filter by OS (e.g. `Mac`, `Windows`, `Linux`)."
688
+ },
689
+ "trigger": {
690
+ "type": "string",
691
+ "description": "Filter by trigger type (`qr`, `link`, `pageview`)."
692
+ },
693
+ "referer": {
694
+ "type": "string",
695
+ "description": "Filter by referer hostname (e.g. `google.com`)."
696
+ },
697
+ "refererUrl": {
698
+ "type": "string",
699
+ "description": "Filter by full referer URL."
700
+ },
701
+ "url": {
702
+ "type": "string",
703
+ "description": "Filter by destination URL."
704
+ },
705
+ "utm_source": {
706
+ "type": "string",
707
+ "description": "Filter by UTM source."
708
+ },
709
+ "utm_medium": {
710
+ "type": "string",
711
+ "description": "Filter by UTM medium."
712
+ },
713
+ "utm_campaign": {
714
+ "type": "string",
715
+ "description": "Filter by UTM campaign."
716
+ },
717
+ "utm_term": {
718
+ "type": "string",
719
+ "description": "Filter by UTM term."
720
+ },
721
+ "utm_content": {
722
+ "type": "string",
723
+ "description": "Filter by UTM content."
724
+ },
725
+ "root": {
726
+ "type": "boolean",
727
+ "description": "If `true`, filter for root domains; if `false`, links only; if undefined, return both."
728
+ },
729
+ "saleType": {
730
+ "type": "string",
731
+ "description": "Filter sales by type. Only applies to sale events."
732
+ },
733
+ "query": {
734
+ "type": "string",
735
+ "description": "Search events by a custom metadata value. Only available for lead and sale events. Examples: `metadata['key']:'value'`."
736
+ }
737
+ }
738
+ },
739
+ execute: async (input) => {
740
+ const key = await ensureApiKey()
741
+ const params = parseToolInput(input)
742
+ return callSuperagnt(key, 'GET', '/analytics', params)
743
+ },
744
+ })
745
+
746
+ api.registerTool({
747
+ name: 'superagnt_connection_dub_listEvents',
748
+ description: "Retrieve a list of events",
749
+ inputSchema: {
750
+ "type": "object",
751
+ "properties": {
752
+ "event": {
753
+ "type": "string",
754
+ "description": "The type of event to retrieve."
755
+ },
756
+ "domain": {
757
+ "type": "string",
758
+ "description": "Filter by domain."
759
+ },
760
+ "key": {
761
+ "type": "string",
762
+ "description": "The slug of the short link. Must be used with `domain`."
763
+ },
764
+ "linkId": {
765
+ "type": "string",
766
+ "description": "Filter by link ID."
767
+ },
768
+ "externalId": {
769
+ "type": "string",
770
+ "description": "Filter by external ID (prefixed with `ext_`)."
771
+ },
772
+ "tenantId": {
773
+ "type": "string",
774
+ "description": "Filter by tenant ID."
775
+ },
776
+ "tagId": {
777
+ "type": "string",
778
+ "description": "Filter by tag ID."
779
+ },
780
+ "folderId": {
781
+ "type": "string",
782
+ "description": "Filter by folder ID."
783
+ },
784
+ "partnerId": {
785
+ "type": "string",
786
+ "description": "Filter by partner ID."
787
+ },
788
+ "customerId": {
789
+ "type": "string",
790
+ "description": "Filter by customer ID."
791
+ },
792
+ "interval": {
793
+ "type": "string",
794
+ "description": "The interval to retrieve events for."
795
+ },
796
+ "start": {
797
+ "type": "string",
798
+ "description": "The start date and time."
799
+ },
800
+ "end": {
801
+ "type": "string",
802
+ "description": "The end date and time."
803
+ },
804
+ "timezone": {
805
+ "type": "string",
806
+ "description": "IANA time zone code."
807
+ },
808
+ "country": {
809
+ "type": "string",
810
+ "description": "Filter by 2-letter ISO 3166-1 country code."
811
+ },
812
+ "city": {
813
+ "type": "string",
814
+ "description": "Filter by city."
815
+ },
816
+ "region": {
817
+ "type": "string",
818
+ "description": "Filter by region."
819
+ },
820
+ "continent": {
821
+ "type": "string",
822
+ "description": "Filter by continent."
823
+ },
824
+ "device": {
825
+ "type": "string",
826
+ "description": "Filter by device."
827
+ },
828
+ "browser": {
829
+ "type": "string",
830
+ "description": "Filter by browser."
831
+ },
832
+ "os": {
833
+ "type": "string",
834
+ "description": "Filter by OS."
835
+ },
836
+ "trigger": {
837
+ "type": "string",
838
+ "description": "Filter by trigger."
839
+ },
840
+ "referer": {
841
+ "type": "string",
842
+ "description": "Filter by referer hostname."
843
+ },
844
+ "refererUrl": {
845
+ "type": "string",
846
+ "description": "Filter by full referer URL."
847
+ },
848
+ "url": {
849
+ "type": "string",
850
+ "description": "Filter by destination URL."
851
+ },
852
+ "utm_source": {
853
+ "type": "string",
854
+ "description": "utm_source"
855
+ },
856
+ "utm_medium": {
857
+ "type": "string",
858
+ "description": "utm_medium"
859
+ },
860
+ "utm_campaign": {
861
+ "type": "string",
862
+ "description": "utm_campaign"
863
+ },
864
+ "utm_term": {
865
+ "type": "string",
866
+ "description": "utm_term"
867
+ },
868
+ "utm_content": {
869
+ "type": "string",
870
+ "description": "utm_content"
871
+ },
872
+ "saleType": {
873
+ "type": "string",
874
+ "description": "saleType"
875
+ },
876
+ "sortOrder": {
877
+ "type": "string",
878
+ "description": "The sort order."
879
+ },
880
+ "sortBy": {
881
+ "type": "string",
882
+ "description": "The field to sort the events by."
883
+ },
884
+ "page": {
885
+ "type": "number",
886
+ "description": "Page number for pagination."
887
+ },
888
+ "limit": {
889
+ "type": "number",
890
+ "description": "Number of items per page (max 100)."
891
+ }
892
+ }
893
+ },
894
+ execute: async (input) => {
895
+ const key = await ensureApiKey()
896
+ const params = parseToolInput(input)
897
+ return callSuperagnt(key, 'GET', '/events', params)
898
+ },
899
+ })
900
+
901
+ api.registerTool({
902
+ name: 'superagnt_connection_dub_getTags',
903
+ description: "Retrieve a list of tags",
904
+ inputSchema: {
905
+ "type": "object",
906
+ "properties": {
907
+ "sortBy": {
908
+ "type": "string",
909
+ "description": "The field to sort the tags by."
910
+ },
911
+ "sortOrder": {
912
+ "type": "string",
913
+ "description": "The order to sort the tags by."
914
+ },
915
+ "search": {
916
+ "type": "string",
917
+ "description": "The search term to filter the tags by."
918
+ },
919
+ "ids": {
920
+ "type": "string",
921
+ "description": "IDs of tags to filter by."
922
+ },
923
+ "page": {
924
+ "type": "number",
925
+ "description": "The page number for pagination."
926
+ },
927
+ "pageSize": {
928
+ "type": "number",
929
+ "description": "The number of items per page."
930
+ }
931
+ }
932
+ },
933
+ execute: async (input) => {
934
+ const key = await ensureApiKey()
935
+ const params = parseToolInput(input)
936
+ return callSuperagnt(key, 'GET', '/tags', params)
937
+ },
938
+ })
939
+
940
+ api.registerTool({
941
+ name: 'superagnt_connection_dub_createTag',
942
+ description: "Create a tag",
943
+ inputSchema: {
944
+ "type": "object",
945
+ "properties": {
946
+ "name": {
947
+ "type": "string",
948
+ "description": "The name of the tag to create."
949
+ },
950
+ "color": {
951
+ "type": "string",
952
+ "description": "The color of the tag. If not provided, a random color will be assigned."
953
+ }
954
+ }
955
+ },
956
+ execute: async (input) => {
957
+ const key = await ensureApiKey()
958
+ const params = parseToolInput(input)
959
+ return callSuperagnt(key, 'POST', '/tags', undefined, params)
960
+ },
961
+ })
962
+
963
+ api.registerTool({
964
+ name: 'superagnt_connection_dub_updateTag',
965
+ description: "Update a tag",
966
+ inputSchema: {
967
+ "type": "object",
968
+ "properties": {
969
+ "id": {
970
+ "type": "string",
971
+ "description": "The ID of the tag to update."
972
+ },
973
+ "name": {
974
+ "type": "string",
975
+ "description": "The new name of the tag."
976
+ },
977
+ "color": {
978
+ "type": "string",
979
+ "description": "The new color of the tag."
980
+ }
981
+ },
982
+ "required": [
983
+ "id"
984
+ ]
985
+ },
986
+ execute: async (input) => {
987
+ const key = await ensureApiKey()
988
+ const params = parseToolInput(input)
989
+ return callSuperagnt(key, 'PATCH', '/tags/{id}', undefined, params)
990
+ },
991
+ })
992
+
993
+ api.registerTool({
994
+ name: 'superagnt_connection_dub_listFolders',
995
+ description: "Retrieve a list of folders",
996
+ inputSchema: {
997
+ "type": "object",
998
+ "properties": {
999
+ "search": {
1000
+ "type": "string",
1001
+ "description": "Free-text search applied to folder names."
1002
+ },
1003
+ "page": {
1004
+ "type": "number",
1005
+ "description": "Page number for pagination."
1006
+ },
1007
+ "pageSize": {
1008
+ "type": "number",
1009
+ "description": "Number of items per page."
1010
+ }
1011
+ }
1012
+ },
1013
+ execute: async (input) => {
1014
+ const key = await ensureApiKey()
1015
+ const params = parseToolInput(input)
1016
+ return callSuperagnt(key, 'GET', '/folders', params)
1017
+ },
1018
+ })
1019
+
1020
+ api.registerTool({
1021
+ name: 'superagnt_connection_dub_createFolder',
1022
+ description: "Create a folder",
1023
+ inputSchema: {
1024
+ "type": "object",
1025
+ "properties": {
1026
+ "name": {
1027
+ "type": "string",
1028
+ "description": "The name of the folder."
1029
+ },
1030
+ "accessLevel": {
1031
+ "type": "string",
1032
+ "description": "Workspace access level for the folder. `null` makes the folder private to its creator."
1033
+ }
1034
+ },
1035
+ "required": [
1036
+ "name"
1037
+ ]
1038
+ },
1039
+ execute: async (input) => {
1040
+ const key = await ensureApiKey()
1041
+ const params = parseToolInput(input)
1042
+ return callSuperagnt(key, 'POST', '/folders', undefined, params)
1043
+ },
1044
+ })
1045
+
1046
+ api.registerTool({
1047
+ name: 'superagnt_connection_dub_updateFolder',
1048
+ description: "Update a folder",
1049
+ inputSchema: {
1050
+ "type": "object",
1051
+ "properties": {
1052
+ "id": {
1053
+ "type": "string",
1054
+ "description": "The ID of the folder to update."
1055
+ },
1056
+ "name": {
1057
+ "type": "string",
1058
+ "description": "The new name of the folder."
1059
+ },
1060
+ "accessLevel": {
1061
+ "type": "string",
1062
+ "description": "Workspace access level for the folder."
1063
+ }
1064
+ },
1065
+ "required": [
1066
+ "id"
1067
+ ]
1068
+ },
1069
+ execute: async (input) => {
1070
+ const key = await ensureApiKey()
1071
+ const params = parseToolInput(input)
1072
+ return callSuperagnt(key, 'PATCH', '/folders/{id}', undefined, params)
1073
+ },
1074
+ })
1075
+
1076
+ api.registerTool({
1077
+ name: 'superagnt_connection_dub_deleteFolder',
1078
+ description: "Delete a folder",
1079
+ inputSchema: {
1080
+ "type": "object",
1081
+ "properties": {
1082
+ "id": {
1083
+ "type": "string",
1084
+ "description": "The ID of the folder to delete."
1085
+ }
1086
+ },
1087
+ "required": [
1088
+ "id"
1089
+ ]
1090
+ },
1091
+ execute: async (input) => {
1092
+ const key = await ensureApiKey()
1093
+ const params = parseToolInput(input)
1094
+ return callSuperagnt(key, 'DELETE', '/folders/{id}', undefined, params)
1095
+ },
1096
+ })
1097
+
1098
+ api.registerTool({
1099
+ name: 'superagnt_connection_dub_listCustomers',
1100
+ description: "Retrieve a list of customers",
1101
+ inputSchema: {
1102
+ "type": "object",
1103
+ "properties": {
1104
+ "email": {
1105
+ "type": "string",
1106
+ "description": "Filter customers by email address."
1107
+ },
1108
+ "externalId": {
1109
+ "type": "string",
1110
+ "description": "Filter customers by external ID (your DB ID)."
1111
+ },
1112
+ "search": {
1113
+ "type": "string",
1114
+ "description": "Free-text search applied to customer email and name."
1115
+ },
1116
+ "country": {
1117
+ "type": "string",
1118
+ "description": "Filter customers by 2-letter ISO 3166-1 country code."
1119
+ },
1120
+ "includeExpandedFields": {
1121
+ "type": "boolean",
1122
+ "description": "Whether to expand related fields like the customer's link, partner, and discount."
1123
+ },
1124
+ "sortBy": {
1125
+ "type": "string",
1126
+ "description": "The field to sort the customers by."
1127
+ },
1128
+ "sortOrder": {
1129
+ "type": "string",
1130
+ "description": "The sort order."
1131
+ },
1132
+ "page": {
1133
+ "type": "number",
1134
+ "description": "Page number for pagination."
1135
+ },
1136
+ "pageSize": {
1137
+ "type": "number",
1138
+ "description": "Number of items per page."
1139
+ }
1140
+ }
1141
+ },
1142
+ execute: async (input) => {
1143
+ const key = await ensureApiKey()
1144
+ const params = parseToolInput(input)
1145
+ return callSuperagnt(key, 'GET', '/customers', params)
1146
+ },
1147
+ })
1148
+
1149
+ api.registerTool({
1150
+ name: 'superagnt_connection_dub_getCustomer',
1151
+ description: "Retrieve a customer",
1152
+ inputSchema: {
1153
+ "type": "object",
1154
+ "properties": {
1155
+ "id": {
1156
+ "type": "string",
1157
+ "description": "The customer ID. May be the Dub customer ID or the external ID prefixed with `ext_`."
1158
+ },
1159
+ "includeExpandedFields": {
1160
+ "type": "boolean",
1161
+ "description": "Whether to expand related fields."
1162
+ }
1163
+ },
1164
+ "required": [
1165
+ "id"
1166
+ ]
1167
+ },
1168
+ execute: async (input) => {
1169
+ const key = await ensureApiKey()
1170
+ const params = parseToolInput(input)
1171
+ return callSuperagnt(key, 'GET', '/customers/{id}', params)
1172
+ },
1173
+ })
1174
+
1175
+ api.registerTool({
1176
+ name: 'superagnt_connection_dub_updateCustomer',
1177
+ description: "Update a customer",
1178
+ inputSchema: {
1179
+ "type": "object",
1180
+ "properties": {
1181
+ "id": {
1182
+ "type": "string",
1183
+ "description": "The customer ID."
1184
+ },
1185
+ "externalId": {
1186
+ "type": "string",
1187
+ "description": "The external ID of the customer in your system."
1188
+ },
1189
+ "name": {
1190
+ "type": "string",
1191
+ "description": "The customer's display name."
1192
+ },
1193
+ "email": {
1194
+ "type": "string",
1195
+ "description": "The customer's email address."
1196
+ },
1197
+ "avatar": {
1198
+ "type": "string",
1199
+ "description": "URL to the customer's avatar image."
1200
+ }
1201
+ },
1202
+ "required": [
1203
+ "id"
1204
+ ]
1205
+ },
1206
+ execute: async (input) => {
1207
+ const key = await ensureApiKey()
1208
+ const params = parseToolInput(input)
1209
+ return callSuperagnt(key, 'PATCH', '/customers/{id}', undefined, params)
1210
+ },
1211
+ })
1212
+
1213
+ api.registerTool({
1214
+ name: 'superagnt_connection_dub_deleteCustomer',
1215
+ description: "Delete a customer",
1216
+ inputSchema: {
1217
+ "type": "object",
1218
+ "properties": {
1219
+ "id": {
1220
+ "type": "string",
1221
+ "description": "The customer ID."
1222
+ }
1223
+ },
1224
+ "required": [
1225
+ "id"
1226
+ ]
1227
+ },
1228
+ execute: async (input) => {
1229
+ const key = await ensureApiKey()
1230
+ const params = parseToolInput(input)
1231
+ return callSuperagnt(key, 'DELETE', '/customers/{id}', undefined, params)
1232
+ },
1233
+ })
1234
+
1235
+ api.registerTool({
1236
+ name: 'superagnt_connection_dub_createDomain',
1237
+ description: "Create a domain",
1238
+ inputSchema: {
1239
+ "type": "object",
1240
+ "properties": {
1241
+ "slug": {
1242
+ "type": "string",
1243
+ "description": "The custom domain name (e.g. `acme.link`)."
1244
+ },
1245
+ "expiredUrl": {
1246
+ "type": "string",
1247
+ "description": "The URL to redirect to when a link on this domain has expired."
1248
+ },
1249
+ "notFoundUrl": {
1250
+ "type": "string",
1251
+ "description": "The URL to redirect to when a link on this domain is not found."
1252
+ },
1253
+ "placeholder": {
1254
+ "type": "string",
1255
+ "description": "Placeholder URL shown in the link builder."
1256
+ },
1257
+ "logo": {
1258
+ "type": "string",
1259
+ "description": "Logo URL displayed on the domain's landing page."
1260
+ }
1261
+ },
1262
+ "required": [
1263
+ "slug"
1264
+ ]
1265
+ },
1266
+ execute: async (input) => {
1267
+ const key = await ensureApiKey()
1268
+ const params = parseToolInput(input)
1269
+ return callSuperagnt(key, 'POST', '/domains', undefined, params)
1270
+ },
1271
+ })
1272
+
1273
+ api.registerTool({
1274
+ name: 'superagnt_connection_dub_updateDomain',
1275
+ description: "Update a domain",
1276
+ inputSchema: {
1277
+ "type": "object",
1278
+ "properties": {
1279
+ "slug": {
1280
+ "type": "string",
1281
+ "description": "The domain slug to update (e.g. `acme.link`)."
1282
+ },
1283
+ "expiredUrl": {
1284
+ "type": "string",
1285
+ "description": "expiredUrl"
1286
+ },
1287
+ "notFoundUrl": {
1288
+ "type": "string",
1289
+ "description": "notFoundUrl"
1290
+ },
1291
+ "placeholder": {
1292
+ "type": "string",
1293
+ "description": "placeholder"
1294
+ },
1295
+ "logo": {
1296
+ "type": "string",
1297
+ "description": "logo"
1298
+ }
1299
+ },
1300
+ "required": [
1301
+ "slug"
1302
+ ]
1303
+ },
1304
+ execute: async (input) => {
1305
+ const key = await ensureApiKey()
1306
+ const params = parseToolInput(input)
1307
+ return callSuperagnt(key, 'PATCH', '/domains/{slug}', undefined, params)
1308
+ },
1309
+ })
1310
+
1311
+ api.registerTool({
1312
+ name: 'superagnt_connection_dub_deleteDomain',
1313
+ description: "Delete a domain",
1314
+ inputSchema: {
1315
+ "type": "object",
1316
+ "properties": {
1317
+ "slug": {
1318
+ "type": "string",
1319
+ "description": "The domain slug to delete."
1320
+ }
1321
+ },
1322
+ "required": [
1323
+ "slug"
1324
+ ]
1325
+ },
1326
+ execute: async (input) => {
1327
+ const key = await ensureApiKey()
1328
+ const params = parseToolInput(input)
1329
+ return callSuperagnt(key, 'DELETE', '/domains/{slug}', undefined, params)
1330
+ },
1331
+ })
1332
+
1333
+ api.registerTool({
1334
+ name: 'superagnt_connection_dub_trackLead',
1335
+ description: "Track a lead",
1336
+ inputSchema: {
1337
+ "type": "object",
1338
+ "properties": {
1339
+ "clickId": {
1340
+ "type": "string",
1341
+ "description": "The unique ID of the click that the lead conversion event is attributed to. Read this from the `dub_id` cookie. For deferred lead tracking, an empty string lets Dub look up the click ID from the existing customer."
1342
+ },
1343
+ "eventName": {
1344
+ "type": "string",
1345
+ "description": "The name of the lead event to track. Doubles as a unique identifier when associating subsequent sale events."
1346
+ },
1347
+ "customerExternalId": {
1348
+ "type": "string",
1349
+ "description": "The unique ID of the customer in your system. Used to attribute all future events to this customer."
1350
+ },
1351
+ "customerName": {
1352
+ "type": "string",
1353
+ "description": "The customer's display name. If not passed, a random name will be generated."
1354
+ },
1355
+ "customerEmail": {
1356
+ "type": "string",
1357
+ "description": "The customer's email address."
1358
+ },
1359
+ "customerAvatar": {
1360
+ "type": "string",
1361
+ "description": "URL to the customer's avatar."
1362
+ },
1363
+ "mode": {
1364
+ "type": "string",
1365
+ "description": "`async` does not block; `wait` blocks until the event is recorded; `deferred` defers creation to a subsequent request."
1366
+ },
1367
+ "eventQuantity": {
1368
+ "type": "number",
1369
+ "description": "Numerical value associated with the lead event. If defined as N, the lead event will be tracked N times."
1370
+ },
1371
+ "metadata": {
1372
+ "type": "object",
1373
+ "description": "Additional metadata to be stored with the lead event. Max 10,000 characters when stringified."
1374
+ }
1375
+ },
1376
+ "required": [
1377
+ "clickId",
1378
+ "eventName",
1379
+ "customerExternalId"
1380
+ ]
1381
+ },
1382
+ execute: async (input) => {
1383
+ const key = await ensureApiKey()
1384
+ const params = parseToolInput(input)
1385
+ return callSuperagnt(key, 'POST', '/track/lead', undefined, params)
1386
+ },
1387
+ })
1388
+
1389
+ api.registerTool({
1390
+ name: 'superagnt_connection_dub_trackSale',
1391
+ description: "Track a sale",
1392
+ inputSchema: {
1393
+ "type": "object",
1394
+ "properties": {
1395
+ "customerExternalId": {
1396
+ "type": "string",
1397
+ "description": "The unique ID of the customer in your system."
1398
+ },
1399
+ "amount": {
1400
+ "type": "integer",
1401
+ "description": "The amount of the sale in cents (for two-decimal currencies). For zero-decimal currencies (e.g. JPY), pass the full integer value."
1402
+ },
1403
+ "currency": {
1404
+ "type": "string",
1405
+ "description": "ISO 4217 currency code. Sales are stored as USD using the latest exchange rate."
1406
+ },
1407
+ "eventName": {
1408
+ "type": "string",
1409
+ "description": "The name of the sale event (e.g. `Invoice paid` or `Subscription created`)."
1410
+ },
1411
+ "paymentProcessor": {
1412
+ "type": "string",
1413
+ "description": "The payment processor via which the sale was made."
1414
+ },
1415
+ "invoiceId": {
1416
+ "type": "string",
1417
+ "description": "Invoice ID, used as an idempotency key — only one sale event can be recorded per invoice ID."
1418
+ },
1419
+ "metadata": {
1420
+ "type": "object",
1421
+ "description": "Additional metadata to be stored with the sale event. Max 10,000 characters."
1422
+ },
1423
+ "leadEventName": {
1424
+ "type": "string",
1425
+ "description": "Name of the lead event that occurred before the sale (case-sensitive). Used to associate the sale with a particular lead."
1426
+ },
1427
+ "clickId": {
1428
+ "type": "string",
1429
+ "description": "[For direct sale tracking] The unique click ID. Read from the `dub_id` cookie."
1430
+ },
1431
+ "customerName": {
1432
+ "type": "string",
1433
+ "description": "[For direct sale tracking] The customer's display name."
1434
+ },
1435
+ "customerEmail": {
1436
+ "type": "string",
1437
+ "description": "[For direct sale tracking] The customer's email address."
1438
+ },
1439
+ "customerAvatar": {
1440
+ "type": "string",
1441
+ "description": "[For direct sale tracking] URL to the customer's avatar."
1442
+ }
1443
+ },
1444
+ "required": [
1445
+ "customerExternalId",
1446
+ "amount"
1447
+ ]
1448
+ },
1449
+ execute: async (input) => {
1450
+ const key = await ensureApiKey()
1451
+ const params = parseToolInput(input)
1452
+ return callSuperagnt(key, 'POST', '/track/sale', undefined, params)
1453
+ },
1454
+ })
1455
+
1456
+ api.registerTool({
1457
+ name: 'superagnt_connection_dub_listPartners',
1458
+ description: "List partners",
1459
+ inputSchema: {
1460
+ "type": "object",
1461
+ "properties": {
1462
+ "groupId": {
1463
+ "type": "string",
1464
+ "description": "Filter partners by their `groupId`."
1465
+ },
1466
+ "status": {
1467
+ "type": "string",
1468
+ "description": "Filter partners by enrollment status."
1469
+ },
1470
+ "country": {
1471
+ "type": "string",
1472
+ "description": "Filter partners by ISO 3166-1 alpha-2 country code."
1473
+ },
1474
+ "sortBy": {
1475
+ "type": "string",
1476
+ "description": "Field to sort the partners by."
1477
+ },
1478
+ "sortOrder": {
1479
+ "type": "string",
1480
+ "description": "Sort order."
1481
+ },
1482
+ "email": {
1483
+ "type": "string",
1484
+ "description": "Filter by partner email (takes precedence over `search`)."
1485
+ },
1486
+ "tenantId": {
1487
+ "type": "string",
1488
+ "description": "Filter by the partner's `tenantId` in your system (takes precedence over `email` and `search`)."
1489
+ },
1490
+ "search": {
1491
+ "type": "string",
1492
+ "description": "Free-text search applied to partner ID, name, email, or link."
1493
+ },
1494
+ "page": {
1495
+ "type": "number",
1496
+ "description": "Page number for pagination."
1497
+ },
1498
+ "pageSize": {
1499
+ "type": "number",
1500
+ "description": "Number of items per page (max 100)."
1501
+ }
1502
+ }
1503
+ },
1504
+ execute: async (input) => {
1505
+ const key = await ensureApiKey()
1506
+ const params = parseToolInput(input)
1507
+ return callSuperagnt(key, 'GET', '/partners', params)
1508
+ },
1509
+ })
1510
+
1511
+ api.registerTool({
1512
+ name: 'superagnt_connection_dub_createPartner',
1513
+ description: "Create or update a partner",
1514
+ inputSchema: {
1515
+ "type": "object",
1516
+ "properties": {
1517
+ "email": {
1518
+ "type": "string",
1519
+ "description": "The partner's email address. They can claim their profile at `partners.dub.co` with this email."
1520
+ },
1521
+ "name": {
1522
+ "type": "string",
1523
+ "description": "The partner's full name. Defaults to their email if omitted."
1524
+ },
1525
+ "username": {
1526
+ "type": "string",
1527
+ "description": "The partner's unique username in your system. Used to build their default short link."
1528
+ },
1529
+ "image": {
1530
+ "type": "string",
1531
+ "description": "The partner's avatar image URL."
1532
+ },
1533
+ "tenantId": {
1534
+ "type": "string",
1535
+ "description": "The partner's unique ID in your system. Used to retrieve their links and stats later."
1536
+ },
1537
+ "groupId": {
1538
+ "type": "string",
1539
+ "description": "The group ID to add the partner to. Defaults to the program's default group."
1540
+ },
1541
+ "country": {
1542
+ "type": "string",
1543
+ "description": "The partner's country (ISO 3166-1 alpha-2)."
1544
+ },
1545
+ "description": {
1546
+ "type": "string",
1547
+ "description": "Brief description of the partner and their background."
1548
+ },
1549
+ "linkProps": {
1550
+ "type": "string",
1551
+ "description": "linkProps"
1552
+ }
1553
+ },
1554
+ "required": [
1555
+ "email"
1556
+ ]
1557
+ },
1558
+ execute: async (input) => {
1559
+ const key = await ensureApiKey()
1560
+ const params = parseToolInput(input)
1561
+ return callSuperagnt(key, 'POST', '/partners', undefined, params)
1562
+ },
1563
+ })
1564
+
1565
+ api.registerTool({
1566
+ name: 'superagnt_connection_dub_retrievePartnerLinks',
1567
+ description: "Retrieve a partner's links",
1568
+ inputSchema: {
1569
+ "type": "object",
1570
+ "properties": {
1571
+ "partnerId": {
1572
+ "type": "string",
1573
+ "description": "The Dub partner ID. Takes precedence over `tenantId` if both are provided."
1574
+ },
1575
+ "tenantId": {
1576
+ "type": "string",
1577
+ "description": "The partner's ID in your system. At least one of `partnerId` or `tenantId` is required."
1578
+ }
1579
+ }
1580
+ },
1581
+ execute: async (input) => {
1582
+ const key = await ensureApiKey()
1583
+ const params = parseToolInput(input)
1584
+ return callSuperagnt(key, 'GET', '/partners/links', params)
1585
+ },
1586
+ })
1587
+
1588
+ api.registerTool({
1589
+ name: 'superagnt_connection_dub_createPartnerLink',
1590
+ description: "Create a partner link",
1591
+ inputSchema: {
1592
+ "type": "object",
1593
+ "properties": {}
1594
+ },
1595
+ execute: async (input) => {
1596
+ const key = await ensureApiKey()
1597
+ const params = parseToolInput(input)
1598
+ return callSuperagnt(key, 'POST', '/partners/links', undefined, params)
1599
+ },
1600
+ })
1601
+
1602
+ api.registerTool({
1603
+ name: 'superagnt_connection_dub_upsertPartnerLink',
1604
+ description: "Upsert a partner link",
1605
+ inputSchema: {
1606
+ "type": "object",
1607
+ "properties": {}
1608
+ },
1609
+ execute: async (input) => {
1610
+ const key = await ensureApiKey()
1611
+ const params = parseToolInput(input)
1612
+ return callSuperagnt(key, 'PUT', '/partners/links/upsert', undefined, params)
1613
+ },
1614
+ })
1615
+
1616
+ api.registerTool({
1617
+ name: 'superagnt_connection_dub_banPartner',
1618
+ description: "Ban a partner",
1619
+ inputSchema: {
1620
+ "type": "object",
1621
+ "properties": {
1622
+ "partnerId": {
1623
+ "type": "string",
1624
+ "description": "The Dub partner ID. Takes precedence over `tenantId` if both are provided."
1625
+ },
1626
+ "tenantId": {
1627
+ "type": "string",
1628
+ "description": "The partner's ID in your system. At least one of `partnerId` or `tenantId` is required."
1629
+ },
1630
+ "reason": {
1631
+ "type": "string",
1632
+ "description": "The reason for the ban."
1633
+ }
1634
+ },
1635
+ "required": [
1636
+ "reason"
1637
+ ]
1638
+ },
1639
+ execute: async (input) => {
1640
+ const key = await ensureApiKey()
1641
+ const params = parseToolInput(input)
1642
+ return callSuperagnt(key, 'POST', '/partners/ban', undefined, params)
1643
+ },
1644
+ })
1645
+
1646
+ api.registerTool({
1647
+ name: 'superagnt_connection_dub_deactivatePartner',
1648
+ description: "Deactivate a partner",
1649
+ inputSchema: {
1650
+ "type": "object",
1651
+ "properties": {
1652
+ "partnerId": {
1653
+ "type": "string",
1654
+ "description": "The Dub partner ID. Takes precedence over `tenantId` if both are provided."
1655
+ },
1656
+ "tenantId": {
1657
+ "type": "string",
1658
+ "description": "The partner's ID in your system. At least one of `partnerId` or `tenantId` is required."
1659
+ }
1660
+ }
1661
+ },
1662
+ execute: async (input) => {
1663
+ const key = await ensureApiKey()
1664
+ const params = parseToolInput(input)
1665
+ return callSuperagnt(key, 'POST', '/partners/deactivate', undefined, params)
1666
+ },
1667
+ })
1668
+
1669
+ api.registerTool({
1670
+ name: 'superagnt_connection_dub_listBountySubmissions',
1671
+ description: "List bounty submissions",
1672
+ inputSchema: {
1673
+ "type": "object",
1674
+ "properties": {
1675
+ "bountyId": {
1676
+ "type": "string",
1677
+ "description": "The bounty ID on Dub (prefixed with `bnty_`). Found in the URL of the bounty page."
1678
+ },
1679
+ "status": {
1680
+ "type": "string",
1681
+ "description": "Filter submissions by status."
1682
+ },
1683
+ "groupId": {
1684
+ "type": "string",
1685
+ "description": "Filter submissions by partner group."
1686
+ },
1687
+ "partnerId": {
1688
+ "type": "string",
1689
+ "description": "Filter submissions by partner."
1690
+ },
1691
+ "sortBy": {
1692
+ "type": "string",
1693
+ "description": "Field to sort the submissions by."
1694
+ },
1695
+ "sortOrder": {
1696
+ "type": "string",
1697
+ "description": "Sort order."
1698
+ },
1699
+ "page": {
1700
+ "type": "number",
1701
+ "description": "Page number for pagination."
1702
+ },
1703
+ "pageSize": {
1704
+ "type": "number",
1705
+ "description": "Number of items per page (max 100)."
1706
+ }
1707
+ },
1708
+ "required": [
1709
+ "bountyId"
1710
+ ]
1711
+ },
1712
+ execute: async (input) => {
1713
+ const key = await ensureApiKey()
1714
+ const params = parseToolInput(input)
1715
+ return callSuperagnt(key, 'GET', '/bounties/{bountyId}/submissions', params)
1716
+ },
1717
+ })
1718
+
1719
+ api.registerTool({
1720
+ name: 'superagnt_connection_dub_approveBountySubmission',
1721
+ description: "Approve a bounty submission",
1722
+ inputSchema: {
1723
+ "type": "object",
1724
+ "properties": {
1725
+ "bountyId": {
1726
+ "type": "string",
1727
+ "description": "The ID of the bounty."
1728
+ },
1729
+ "submissionId": {
1730
+ "type": "string",
1731
+ "description": "The ID of the bounty submission."
1732
+ },
1733
+ "rewardAmount": {
1734
+ "type": "number",
1735
+ "description": "Custom reward amount (in cents). Only applicable to performance-based bounties whose reward amount is not preset."
1736
+ }
1737
+ },
1738
+ "required": [
1739
+ "bountyId",
1740
+ "submissionId"
1741
+ ]
1742
+ },
1743
+ execute: async (input) => {
1744
+ const key = await ensureApiKey()
1745
+ const params = parseToolInput(input)
1746
+ return callSuperagnt(key, 'POST', '/bounties/{bountyId}/submissions/{submissionId}/approve', undefined, params)
1747
+ },
1748
+ })
1749
+
1750
+ api.registerTool({
1751
+ name: 'superagnt_connection_dub_rejectBountySubmission',
1752
+ description: "Reject a bounty submission",
1753
+ inputSchema: {
1754
+ "type": "object",
1755
+ "properties": {
1756
+ "bountyId": {
1757
+ "type": "string",
1758
+ "description": "The ID of the bounty."
1759
+ },
1760
+ "submissionId": {
1761
+ "type": "string",
1762
+ "description": "The ID of the bounty submission."
1763
+ },
1764
+ "rejectionReason": {
1765
+ "type": "string",
1766
+ "description": "The reason for rejecting the submission."
1767
+ },
1768
+ "rejectionNote": {
1769
+ "type": "string",
1770
+ "description": "Optional free-form note explaining the rejection (visible to the partner)."
1771
+ }
1772
+ },
1773
+ "required": [
1774
+ "bountyId",
1775
+ "submissionId"
1776
+ ]
1777
+ },
1778
+ execute: async (input) => {
1779
+ const key = await ensureApiKey()
1780
+ const params = parseToolInput(input)
1781
+ return callSuperagnt(key, 'POST', '/bounties/{bountyId}/submissions/{submissionId}/reject', undefined, params)
1782
+ },
1783
+ })
1784
+
1785
+ api.registerTool({
1786
+ name: 'superagnt_connection_dub_listCommissions',
1787
+ description: "List commissions",
1788
+ inputSchema: {
1789
+ "type": "object",
1790
+ "properties": {
1791
+ "type": {
1792
+ "type": "string",
1793
+ "description": "Filter by commission type."
1794
+ },
1795
+ "customerId": {
1796
+ "type": "string",
1797
+ "description": "Filter by associated customer."
1798
+ },
1799
+ "payoutId": {
1800
+ "type": "string",
1801
+ "description": "Filter by associated payout."
1802
+ },
1803
+ "partnerId": {
1804
+ "type": "string",
1805
+ "description": "Filter by associated partner. Takes precedence over `tenantId`."
1806
+ },
1807
+ "tenantId": {
1808
+ "type": "string",
1809
+ "description": "Filter by the partner's `tenantId` in your system."
1810
+ },
1811
+ "groupId": {
1812
+ "type": "string",
1813
+ "description": "Filter by partner group."
1814
+ },
1815
+ "invoiceId": {
1816
+ "type": "string",
1817
+ "description": "Filter by associated invoice. Returns at most one commission per invoice."
1818
+ },
1819
+ "status": {
1820
+ "type": "string",
1821
+ "description": "Filter by commission status."
1822
+ },
1823
+ "sortBy": {
1824
+ "type": "string",
1825
+ "description": "Field to sort by."
1826
+ },
1827
+ "sortOrder": {
1828
+ "type": "string",
1829
+ "description": "Sort order."
1830
+ },
1831
+ "interval": {
1832
+ "type": "string",
1833
+ "description": "Convenience time range filter."
1834
+ },
1835
+ "start": {
1836
+ "type": "string",
1837
+ "description": "Start of the date range (ISO-8601). Use with `end` to override `interval`."
1838
+ },
1839
+ "end": {
1840
+ "type": "string",
1841
+ "description": "End of the date range (ISO-8601)."
1842
+ },
1843
+ "timezone": {
1844
+ "type": "string",
1845
+ "description": "IANA timezone (e.g. `America/New_York`) used to interpret `start`/`end` and `interval`."
1846
+ },
1847
+ "endingBefore": {
1848
+ "type": "string",
1849
+ "description": "Cursor pagination — only return results before this commission ID."
1850
+ },
1851
+ "startingAfter": {
1852
+ "type": "string",
1853
+ "description": "Cursor pagination — only return results after this commission ID."
1854
+ },
1855
+ "page": {
1856
+ "type": "number",
1857
+ "description": "Deprecated. Use `startingAfter` instead."
1858
+ },
1859
+ "pageSize": {
1860
+ "type": "number",
1861
+ "description": "Number of items per page (max 100)."
1862
+ }
1863
+ }
1864
+ },
1865
+ execute: async (input) => {
1866
+ const key = await ensureApiKey()
1867
+ const params = parseToolInput(input)
1868
+ return callSuperagnt(key, 'GET', '/commissions', params)
1869
+ },
1870
+ })
1871
+
1872
+ api.registerTool({
1873
+ name: 'superagnt_connection_dub_updateCommission',
1874
+ description: "Update a commission",
1875
+ inputSchema: {
1876
+ "type": "object",
1877
+ "properties": {
1878
+ "id": {
1879
+ "type": "string",
1880
+ "description": "The commission's unique ID on Dub (e.g. `cm_1JVR7XRCSR0EDBAF39FZ4PMYE`)."
1881
+ },
1882
+ "saleAmount": {
1883
+ "type": "number",
1884
+ "description": "New absolute sale amount (in cents). Paid commissions cannot be updated."
1885
+ },
1886
+ "modifySaleAmount": {
1887
+ "type": "number",
1888
+ "description": "Delta to apply to the current sale amount (positive to increase, negative to decrease). Takes precedence over `saleAmount`."
1889
+ },
1890
+ "earnings": {
1891
+ "type": "number",
1892
+ "description": "New absolute earnings (for `custom` commissions)."
1893
+ },
1894
+ "currency": {
1895
+ "type": "string",
1896
+ "description": "ISO 4217 currency code for the sale amount."
1897
+ },
1898
+ "status": {
1899
+ "type": "string",
1900
+ "description": "New status. Takes precedence over `saleAmount`/`modifySaleAmount`. Marking as anything other than `pending` removes the commission from its payout and recalculates the payout amount."
1901
+ },
1902
+ "amount": {
1903
+ "type": "number",
1904
+ "description": "Deprecated — use `saleAmount`."
1905
+ },
1906
+ "modifyAmount": {
1907
+ "type": "number",
1908
+ "description": "Deprecated — use `modifySaleAmount`."
1909
+ }
1910
+ },
1911
+ "required": [
1912
+ "id"
1913
+ ]
1914
+ },
1915
+ execute: async (input) => {
1916
+ const key = await ensureApiKey()
1917
+ const params = parseToolInput(input)
1918
+ return callSuperagnt(key, 'PATCH', '/commissions/{id}', undefined, params)
1919
+ },
1920
+ })
1921
+
1922
+ api.registerTool({
1923
+ name: 'superagnt_connection_dub_listPayouts',
1924
+ description: "List payouts",
1925
+ inputSchema: {
1926
+ "type": "object",
1927
+ "properties": {
1928
+ "status": {
1929
+ "type": "string",
1930
+ "description": "Filter payouts by status."
1931
+ },
1932
+ "partnerId": {
1933
+ "type": "string",
1934
+ "description": "Filter by associated partner. Takes precedence over `tenantId`."
1935
+ },
1936
+ "tenantId": {
1937
+ "type": "string",
1938
+ "description": "Filter by the partner's `tenantId` in your system."
1939
+ },
1940
+ "invoiceId": {
1941
+ "type": "string",
1942
+ "description": "Filter by invoice ID. Pending payouts do not have an invoice ID."
1943
+ },
1944
+ "sortBy": {
1945
+ "type": "string",
1946
+ "description": "Field to sort by."
1947
+ },
1948
+ "sortOrder": {
1949
+ "type": "string",
1950
+ "description": "Sort order."
1951
+ },
1952
+ "page": {
1953
+ "type": "number",
1954
+ "description": "Page number for pagination."
1955
+ },
1956
+ "pageSize": {
1957
+ "type": "number",
1958
+ "description": "Number of items per page (max 100)."
1959
+ }
1960
+ }
1961
+ },
1962
+ execute: async (input) => {
1963
+ const key = await ensureApiKey()
1964
+ const params = parseToolInput(input)
1965
+ return callSuperagnt(key, 'GET', '/payouts', params)
1966
+ },
1967
+ })
1968
+
1969
+ promptState.toolCount = 41
1970
+ promptState.ready = true
1971
+ }