@superagnt/tiktok-data 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,21 +8,20 @@ Use one API key to pull TikTok data (short-form video and creator data) for agen
8
8
  openclaw plugins install @superagnt/tiktok-data
9
9
  ```
10
10
 
11
- This package is the official **OpenClaw** plugin for **TikTok** social and public data via [superagnt](https://superagnt.com). Pair it with the [documentation](https://superagnt.com) and your superagnt API key.
11
+ This package is the official **OpenClaw** plugin for **TikTok** social and public data via [superagnt](https://superagnt.com). Pair it with the [documentation](https://superagnt.com/docs) and your superagnt API key.
12
12
 
13
- ## Live MCP mode (recommended)
13
+ ## Want the live MCP surface instead?
14
14
 
15
- Set a workspace MCP token and the plugin upgrades itself at load: it fetches
16
- the live tool list from the scoped MCP endpoint and proxies calls through it —
17
- the tool surface then grows with `agnt_tools_enable`, no plugin update needed.
15
+ This plugin ships a fixed, baked-in toolset that only needs your
16
+ `SUPERAGNT_API_KEY`. For the live workspace tool surface — the full value
17
+ layer (data sources plus workspace Postgres, schedules, canvases,
18
+ enrichment), growing server-side with no plugin update — install the
19
+ primary superagnt plugin instead:
18
20
 
19
21
  ```bash
20
- export SUPERAGNT_MCP_TOKEN=... # from the MCP server card in the dashboard
22
+ openclaw plugins install @superagnt/superagnt
21
23
  ```
22
24
 
23
- Without the token the plugin uses its built-in toolset with your
24
- `SUPERAGNT_API_KEY` — no behavior change from previous versions.
25
-
26
25
  ## Overview
27
26
 
28
27
  Unified access to video details, creator profiles, and search across accounts and videos. Built for LLMs and automation — not one-off scraping.
@@ -58,8 +57,8 @@ Use a single **superagnt API key** (Bearer token). Set `SUPERAGNT_API_KEY` in yo
58
57
 
59
58
  ## Documentation
60
59
 
61
- - [Documentation](https://superagnt.com) — getting started and concepts
62
- - [API reference (TikTok)](https://superagnt.com/apis/social/tiktok) — endpoints and schemas
60
+ - [Documentation](https://superagnt.com/docs) — getting started and concepts
61
+ - [API reference (TikTok)](https://superagnt.com/docs/apis/social/tiktok) — endpoints and schemas
63
62
  - [Dashboard](https://app.superagnt.com/dashboard) — API keys and usage
64
63
 
65
64
  ## Related
package/index.js CHANGED
@@ -28,194 +28,6 @@ function readAgntConfig() {
28
28
 
29
29
  // ── End Auth Module ──────────────────────────────────────────────────────────
30
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 TikTok API (tiktok)."
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/tiktok'
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
31
  function parseToolInput(input) {
220
32
  if (input == null) return {}
221
33
  if (typeof input === 'object' && !Array.isArray(input)) return input
@@ -267,9 +79,8 @@ async function callSuperagnt(apiKey, method, path, query, body) {
267
79
  return res.json()
268
80
  }
269
81
 
270
- export default async function register(api) {
82
+ export default function register(api) {
271
83
  const apiKey = api.pluginConfig.apiKey || process.env.SUPERAGNT_API_KEY || readAgntConfig()?.apiKey
272
- const mcpToken = api.pluginConfig.mcpToken || process.env.SUPERAGNT_MCP_TOKEN
273
84
 
274
85
  function ensureApiKey() {
275
86
  if (apiKey) return apiKey
@@ -281,30 +92,10 @@ export default async function register(api) {
281
92
  )
282
93
  }
283
94
 
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
95
  api.registerTool({
305
96
  name: 'superagnt_tiktok_Video_Details_get',
306
97
  description: "Video Details",
307
- inputSchema: {
98
+ parameters: {
308
99
  "type": "object",
309
100
  "properties": {
310
101
  "video_id": {
@@ -317,7 +108,7 @@ export default async function register(api) {
317
108
  ]
318
109
  },
319
110
  execute: async (input) => {
320
- const key = await ensureApiKey()
111
+ const key = ensureApiKey()
321
112
  const params = parseToolInput(input)
322
113
  return callSuperagnt(key, 'GET', '/video/details', params)
323
114
  },
@@ -326,7 +117,7 @@ export default async function register(api) {
326
117
  api.registerTool({
327
118
  name: 'superagnt_tiktok_Video_Details_post',
328
119
  description: "Video Details",
329
- inputSchema: {
120
+ parameters: {
330
121
  "type": "object",
331
122
  "properties": {
332
123
  "video_id": {
@@ -339,7 +130,7 @@ export default async function register(api) {
339
130
  ]
340
131
  },
341
132
  execute: async (input) => {
342
- const key = await ensureApiKey()
133
+ const key = ensureApiKey()
343
134
  const params = parseToolInput(input)
344
135
  return callSuperagnt(key, 'POST', '/video/details', undefined, params)
345
136
  },
@@ -348,7 +139,7 @@ export default async function register(api) {
348
139
  api.registerTool({
349
140
  name: 'superagnt_tiktok_User_s_Videos_get',
350
141
  description: "User's Videos",
351
- inputSchema: {
142
+ parameters: {
352
143
  "type": "object",
353
144
  "properties": {
354
145
  "username": {
@@ -361,7 +152,7 @@ export default async function register(api) {
361
152
  ]
362
153
  },
363
154
  execute: async (input) => {
364
- const key = await ensureApiKey()
155
+ const key = ensureApiKey()
365
156
  const params = parseToolInput(input)
366
157
  return callSuperagnt(key, 'GET', '/user/videos', params)
367
158
  },
@@ -370,7 +161,7 @@ export default async function register(api) {
370
161
  api.registerTool({
371
162
  name: 'superagnt_tiktok_User_s_Videos_post',
372
163
  description: "User's Videos",
373
- inputSchema: {
164
+ parameters: {
374
165
  "type": "object",
375
166
  "properties": {
376
167
  "username": {
@@ -383,7 +174,7 @@ export default async function register(api) {
383
174
  ]
384
175
  },
385
176
  execute: async (input) => {
386
- const key = await ensureApiKey()
177
+ const key = ensureApiKey()
387
178
  const params = parseToolInput(input)
388
179
  return callSuperagnt(key, 'POST', '/user/videos', undefined, params)
389
180
  },
@@ -392,7 +183,7 @@ export default async function register(api) {
392
183
  api.registerTool({
393
184
  name: 'superagnt_tiktok_Collection_Videos_Details',
394
185
  description: "Collection Videos/Details",
395
- inputSchema: {
186
+ parameters: {
396
187
  "type": "object",
397
188
  "properties": {
398
189
  "collection_id": {
@@ -410,7 +201,7 @@ export default async function register(api) {
410
201
  ]
411
202
  },
412
203
  execute: async (input) => {
413
- const key = await ensureApiKey()
204
+ const key = ensureApiKey()
414
205
  const params = parseToolInput(input)
415
206
  return callSuperagnt(key, 'GET', '/collection/', params)
416
207
  },
@@ -419,7 +210,7 @@ export default async function register(api) {
419
210
  api.registerTool({
420
211
  name: 'superagnt_tiktok_User_s_Videos_Continuation',
421
212
  description: "User's Videos Continuation",
422
- inputSchema: {
213
+ parameters: {
423
214
  "type": "object",
424
215
  "properties": {
425
216
  "continuation_token": {
@@ -442,7 +233,7 @@ export default async function register(api) {
442
233
  ]
443
234
  },
444
235
  execute: async (input) => {
445
- const key = await ensureApiKey()
236
+ const key = ensureApiKey()
446
237
  const params = parseToolInput(input)
447
238
  return callSuperagnt(key, 'GET', '/user/videos/continuation', params)
448
239
  },
@@ -451,7 +242,7 @@ export default async function register(api) {
451
242
  api.registerTool({
452
243
  name: 'superagnt_tiktok_User_s_Details_get',
453
244
  description: "User's Details",
454
- inputSchema: {
245
+ parameters: {
455
246
  "type": "object",
456
247
  "properties": {
457
248
  "username": {
@@ -464,7 +255,7 @@ export default async function register(api) {
464
255
  ]
465
256
  },
466
257
  execute: async (input) => {
467
- const key = await ensureApiKey()
258
+ const key = ensureApiKey()
468
259
  const params = parseToolInput(input)
469
260
  return callSuperagnt(key, 'GET', '/user/details', params)
470
261
  },
@@ -473,7 +264,7 @@ export default async function register(api) {
473
264
  api.registerTool({
474
265
  name: 'superagnt_tiktok_User_s_Details_post',
475
266
  description: "User's Details",
476
- inputSchema: {
267
+ parameters: {
477
268
  "type": "object",
478
269
  "properties": {
479
270
  "username": {
@@ -486,7 +277,7 @@ export default async function register(api) {
486
277
  ]
487
278
  },
488
279
  execute: async (input) => {
489
- const key = await ensureApiKey()
280
+ const key = ensureApiKey()
490
281
  const params = parseToolInput(input)
491
282
  return callSuperagnt(key, 'POST', '/user/details', undefined, params)
492
283
  },
@@ -495,7 +286,7 @@ export default async function register(api) {
495
286
  api.registerTool({
496
287
  name: 'superagnt_tiktok_Search_Accounts_get',
497
288
  description: "Search Accounts",
498
- inputSchema: {
289
+ parameters: {
499
290
  "type": "object",
500
291
  "properties": {
501
292
  "query": {
@@ -508,7 +299,7 @@ export default async function register(api) {
508
299
  ]
509
300
  },
510
301
  execute: async (input) => {
511
- const key = await ensureApiKey()
302
+ const key = ensureApiKey()
512
303
  const params = parseToolInput(input)
513
304
  return callSuperagnt(key, 'GET', '/search/accounts/query', params)
514
305
  },
@@ -517,7 +308,7 @@ export default async function register(api) {
517
308
  api.registerTool({
518
309
  name: 'superagnt_tiktok_Search_Accounts_post',
519
310
  description: "Search Accounts",
520
- inputSchema: {
311
+ parameters: {
521
312
  "type": "object",
522
313
  "properties": {
523
314
  "query": {
@@ -530,7 +321,7 @@ export default async function register(api) {
530
321
  ]
531
322
  },
532
323
  execute: async (input) => {
533
- const key = await ensureApiKey()
324
+ const key = ensureApiKey()
534
325
  const params = parseToolInput(input)
535
326
  return callSuperagnt(key, 'POST', '/search/accounts/query', undefined, params)
536
327
  },
@@ -539,7 +330,7 @@ export default async function register(api) {
539
330
  api.registerTool({
540
331
  name: 'superagnt_tiktok_Search_Videos_get',
541
332
  description: "Search Videos",
542
- inputSchema: {
333
+ parameters: {
543
334
  "type": "object",
544
335
  "properties": {
545
336
  "query": {
@@ -552,7 +343,7 @@ export default async function register(api) {
552
343
  ]
553
344
  },
554
345
  execute: async (input) => {
555
- const key = await ensureApiKey()
346
+ const key = ensureApiKey()
556
347
  const params = parseToolInput(input)
557
348
  return callSuperagnt(key, 'GET', '/search/general/query', params)
558
349
  },
@@ -561,7 +352,7 @@ export default async function register(api) {
561
352
  api.registerTool({
562
353
  name: 'superagnt_tiktok_Search_Videos_post',
563
354
  description: "Search Videos",
564
- inputSchema: {
355
+ parameters: {
565
356
  "type": "object",
566
357
  "properties": {
567
358
  "query": {
@@ -574,12 +365,9 @@ export default async function register(api) {
574
365
  ]
575
366
  },
576
367
  execute: async (input) => {
577
- const key = await ensureApiKey()
368
+ const key = ensureApiKey()
578
369
  const params = parseToolInput(input)
579
370
  return callSuperagnt(key, 'POST', '/search/general/query', undefined, params)
580
371
  },
581
372
  })
582
-
583
- promptState.toolCount = 12
584
- promptState.ready = true
585
373
  }
@@ -2,7 +2,23 @@
2
2
  "id": "tiktok-data",
3
3
  "name": "TikTok Data",
4
4
  "description": "Unified access to video details, creator profiles, and search across accounts and videos. Built for LLMs and automation — not one-off scraping.",
5
- "version": "2.0.2",
5
+ "version": "2.0.4",
6
+ "contracts": {
7
+ "tools": [
8
+ "superagnt_tiktok_Video_Details_get",
9
+ "superagnt_tiktok_Video_Details_post",
10
+ "superagnt_tiktok_User_s_Videos_get",
11
+ "superagnt_tiktok_User_s_Videos_post",
12
+ "superagnt_tiktok_Collection_Videos_Details",
13
+ "superagnt_tiktok_User_s_Videos_Continuation",
14
+ "superagnt_tiktok_User_s_Details_get",
15
+ "superagnt_tiktok_User_s_Details_post",
16
+ "superagnt_tiktok_Search_Accounts_get",
17
+ "superagnt_tiktok_Search_Accounts_post",
18
+ "superagnt_tiktok_Search_Videos_get",
19
+ "superagnt_tiktok_Search_Videos_post"
20
+ ]
21
+ },
6
22
  "configSchema": {
7
23
  "type": "object",
8
24
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superagnt/tiktok-data",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "type": "module",
5
5
  "description": "Unified access to video details, creator profiles, and search across accounts and videos. Built for LLMs and automation — not one-off scraping.",
6
6
  "main": "index.js",