socialcrawl-mcp 2.3.0 → 2.5.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.
Files changed (56) hide show
  1. package/README.md +9 -3
  2. package/dist/app.js +71 -12
  3. package/dist/chatgpt-text.d.ts +23 -0
  4. package/dist/chatgpt-text.js +310 -0
  5. package/dist/client.d.ts +5 -0
  6. package/dist/client.js +9 -1
  7. package/dist/constants.d.ts +1 -1
  8. package/dist/constants.js +1 -1
  9. package/dist/context.d.ts +7 -0
  10. package/dist/cost-guard.d.ts +15 -3
  11. package/dist/cost-guard.js +39 -3
  12. package/dist/data/docs-async.js +137 -137
  13. package/dist/data/docs-handwritten.js +968 -947
  14. package/dist/data/docs.js +5 -1
  15. package/dist/data/endpoints.js +1499 -711
  16. package/dist/data/examples.js +2 -2
  17. package/dist/data/guide.d.ts +2 -2
  18. package/dist/data/guide.js +2 -2
  19. package/dist/data/outputs.js +184 -154
  20. package/dist/data/platforms.js +11 -11
  21. package/dist/data/recipes.js +1 -1
  22. package/dist/data/registry-meta.d.ts +8 -8
  23. package/dist/data/registry-meta.js +8 -8
  24. package/dist/endpoint-resolve.d.ts +1 -0
  25. package/dist/endpoint-resolve.js +10 -1
  26. package/dist/endpoint-surface.d.ts +64 -0
  27. package/dist/endpoint-surface.js +472 -0
  28. package/dist/hydration.js +7 -0
  29. package/dist/instructions.md +18 -18
  30. package/dist/listings.d.ts +24 -0
  31. package/dist/listings.js +55 -0
  32. package/dist/oauth/config.d.ts +20 -0
  33. package/dist/oauth/config.js +19 -0
  34. package/dist/oauth/resource-server.d.ts +12 -2
  35. package/dist/oauth/resource-server.js +5 -20
  36. package/dist/oauth/scopes.d.ts +2 -2
  37. package/dist/oauth/scopes.js +4 -4
  38. package/dist/param-aliases.d.ts +7 -0
  39. package/dist/param-aliases.js +15 -0
  40. package/dist/pricing.js +5 -1
  41. package/dist/resources/sample-gate.js +34 -1
  42. package/dist/resources/supplier-tokens.d.ts +1 -1
  43. package/dist/resources/supplier-tokens.js +2 -0
  44. package/dist/result.js +8 -0
  45. package/dist/schemas/async.d.ts +4 -4
  46. package/dist/schemas/outputs.d.ts +2 -2
  47. package/dist/timeouts.d.ts +24 -1
  48. package/dist/timeouts.js +32 -0
  49. package/dist/tools/discover.js +3 -0
  50. package/dist/tools/list-endpoints.js +5 -3
  51. package/dist/tools/pricing.js +11 -1
  52. package/dist/tools/request.js +10 -2
  53. package/dist/types.d.ts +9 -1
  54. package/dist/value-prices.d.ts +18 -0
  55. package/dist/value-prices.js +79 -0
  56. package/package.json +3 -3
@@ -4,18 +4,50 @@ import { priceDrivingParams } from "./pricing.js";
4
4
  import { joinsCeiling, laneMaxCredits, quoteHydration } from "./hydration.js";
5
5
  import { judgmentHoldMax, quoteJudgments } from "./judgments.js";
6
6
  import { confirmThreshold } from "./session-spend.js";
7
+ import { valueAndAddOnCeiling, valueAndAddOnCredits } from "./value-prices.js";
7
8
  const present = (v) => v !== undefined && v !== null && v !== "";
8
9
  /**
9
- * Whether a metered band is fully explained by the page, its `include=` joins
10
- * and its metered judgments — then local arithmetic is exact. Any other meter
11
- * (per-row `limit`, page walks the rule describes) is not.
10
+ * The `pages` lever (API-280, API-281): `{platform}/profile/full` and
11
+ * `prism/format-lift` read up to `max` pages in one call, the first at the flat
12
+ * price and each further page at `step` credits (the posts endpoint's own page
13
+ * price), refunding pages not read. The step is the band's spread over the
14
+ * further pages; undefined when the band does not split into whole credits.
15
+ */
16
+ export function pagesLever(e) {
17
+ const param = e.optionalParams.find((o) => o.name === "pages");
18
+ if (!param || e.pricing.model !== "metered" || e.pricing.maxCost === undefined)
19
+ return undefined;
20
+ const fromText = /\b1-(\d+)\b/.exec(param.description ?? "");
21
+ const max = param.maximum ?? (fromText ? Number(fromText[1]) : undefined);
22
+ if (!max || max < 2)
23
+ return undefined;
24
+ const spread = e.pricing.maxCost - e.pricing.cost - joinsCeiling(e);
25
+ const step = spread / (max - 1);
26
+ return Number.isInteger(step) && step > 0 ? { max, step } : undefined;
27
+ }
28
+ /** Credits the further pages asked with `pages` add to the first page's price. */
29
+ function pagesCredits(e, params) {
30
+ const lever = pagesLever(e);
31
+ const pages = Number(params.pages);
32
+ if (!lever || !Number.isFinite(pages) || pages <= 1)
33
+ return 0;
34
+ return (Math.min(Math.floor(pages), lever.max) - 1) * lever.step;
35
+ }
36
+ /**
37
+ * Whether a metered band is fully explained by the page, its `include=` joins,
38
+ * its metered judgments, its `pages` lever, and the value prices and include
39
+ * add-ons its text states (`value-prices.ts`) — then local arithmetic is exact.
40
+ * Any other meter (per-row `limit`, page walks the rule describes) is not.
12
41
  */
13
42
  export function bandExplained(e) {
14
43
  if (e.pricing.model !== "metered" || e.pricing.maxCost === undefined)
15
44
  return true;
16
45
  const labels = e.judgments?.labels;
46
+ const lever = pagesLever(e);
17
47
  const explained = e.pricing.cost +
48
+ (lever ? (lever.max - 1) * lever.step : 0) +
18
49
  joinsCeiling(e) +
50
+ valueAndAddOnCeiling(e) +
19
51
  (labels && (labels.metered.length > 0 || labels.free.includes("intent")) ? judgmentHoldMax(e) : 0) +
20
52
  (e.judgments?.relevance ? judgmentHoldMax(e) : 0);
21
53
  return e.pricing.maxCost <= explained;
@@ -41,6 +73,10 @@ export function localQuote(endpoint, params) {
41
73
  }
42
74
  if (endpoint.judgments)
43
75
  hold += quoteJudgments(endpoint, params).held;
76
+ hold += pagesCredits(endpoint, params);
77
+ // A value that sets the page price (sort=likes) and a fixed include add-on
78
+ // (include=segments, description, stats), as the rule states them.
79
+ hold += valueAndAddOnCredits(endpoint, params);
44
80
  // A band that is nothing but the page, its joins and its judgments is
45
81
  // quoted exactly above; only a band that meters on something else is
46
82
  // budgeted at its ceiling — less the joins this call does not turn on.
@@ -6,100 +6,100 @@
6
6
  * {routes,resume,more,schedule-routes}.ts, platforms/review-history/
7
7
  * {http,engine}.ts, events/{feed,routes}.ts, webhooks/{http,limits}.ts.
8
8
  */
9
- export const DISCOVER_RUNS_DOC = `# SocialCrawl API — Discover runs, schedules and review history
10
-
11
- Work that keeps running after the call that started it. Start it with \`socialcrawl_request\`; read, export, steer and stop it with \`socialcrawl_manage\` (areas \`discover\` and \`review_history\`). Every read here is free; only the searches a run goes on to make are billed.
12
-
13
- ## Discover runs (\`/v1/prism/discover/runs\`)
14
-
15
- Start a run with \`socialcrawl_request\` on \`prism/discover\` (\`max_credits\` is required; \`async\` runs it in the background). Manage it with \`socialcrawl_manage\` \`area: "discover"\`; \`id\` is the run id (\`run_…\`, \`data.run.run_id\`). Runs created since 14/11/2026 are kept 30 days by default (was 7); \`retention_days\` is 1 to 30.
16
-
17
- | Action | Route | Cost |
18
- |--------|-------|------|
19
- | \`run_list\` | \`GET /runs\` (status, kind, created_after, cursor, page_size ≤100; \`id\` = a schedule id lists that schedule's runs) | 0 |
20
- | \`run_get\` | \`GET /runs/{run_id}\` | 0 |
21
- | \`run_export\` | \`GET /runs/{run_id}/results.jsonl\` | 0 |
22
- | \`run_legs\` | \`GET /runs/{run_id}/legs\` (page_size ≤500) | 0 |
23
- | \`run_cancel\` | \`DELETE /runs/{run_id}\` | 0 — rows kept, resume continues |
24
- | \`run_resume\` | \`POST /runs/{run_id}/resume\` \`{ max_credits?, retry_failed? }\` | 0 itself; continued searches bill as they run |
25
- | \`run_more\` | \`POST /runs/{run_id}/more\` \`{ new_searches?, feedback?, max_credits?, pages? }\` | each new search bills at its lane price |
26
-
27
- - **Long-poll:** \`run_get\` with \`wait_s\` (0-25) answers early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key; a sixth answers at once.
28
- - **Filters** (run_get and run_export): view, order (arrival | rank; rank on a running run is a free 400), include_pending, changes_since, group, platform, keyword, sort, state (kept | dropped | all), include=dropped, and \`tags\` sent as \`tag.<key>=<value>\`. Any parameter the route does not take is a free 400. A cursor is signed with the filters it was issued for: send the SAME filters with it.
29
- - **run_export** streams every matching row; the last line is \`{"complete":true}\` or \`{"next_cursor":"…"}\` (stopped after about 45 s; send it back with the same filters).
30
- - **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER \`max_credits\`. Searches already paid for are never paid twice.
31
- - **run_more** works on completed runs only: \`pages\` 1-10, \`feedback.accept\`/\`feedback.reject\` up to 100 ids each (\`accept\` needs \`new_searches: true\`). Read only the new rows with \`changes_since\` = \`data.more.since_version\`. \`data.more.nothing_more\` (200) charged nothing. The route takes no Idempotency-Key, so check the run before repeating a more.
32
- - **No dry_run** on any run or schedule route (resume and more refuse any query parameter).
33
- - **Errors:** 404 RUN_NOT_FOUND (not your run), 409 RUN_STATE_CONFLICT, 410 RUN_EXPIRED (retention passed), 503 store_unavailable (retryable, nothing charged).
34
-
35
- ## Discover schedules (\`/v1/prism/discover/schedules\`)
36
-
37
- Created by \`prism/discover\` with a \`schedule\` field. All free; each scheduled run bills like a run within \`max_credits_per_run\` and \`max_credits_per_month\`. \`id\` is the schedule id (\`dsch_…\`).
38
-
39
- \`schedule_list\` (status active | paused | stopped, cursor, page_size ≤100), \`schedule_get\` (its recent runs, this month's spend, next fire), \`schedule_pause\`, \`schedule_resume\` (\`{ max_credits_per_run?, max_credits_per_month? }\`, null clears the month cap), \`schedule_delete\` (runs keep their rows). \`run_list\` with the schedule id lists one schedule's runs.
40
-
41
- ## Stored lists (\`/v1/prism/discover/inputs\`)
42
-
43
- Make one with \`socialcrawl_request\` on \`POST prism/discover/inputs\` (\`{ kind: "authors", authors: [...] }\` up to 10,000 handles, or \`{ kind: "exclude", exclude: [...] }\` up to 50,000 entries); the answer's \`author_list_id\` / \`exclude_list_id\` (\`din_…\`) goes into a discover call. Then, free: \`input_list\` (every live list with \`item_count\` and \`expires_at\`, plus \`live\` of \`limit\` 500 per account), \`input_append\` (\`id\` + \`{ exclude: [...] }\`, 1 to 50,000 entries; duplicates skipped, the expiry moves to 31 days; past 50,000 in all it is a free 400 \`exclude_list_full\`), \`input_delete\`. An unknown, expired or foreign id, or an author list sent to append, is a 404 \`input_not_found\`. Lists live 30 days.
44
-
45
- ## Review history (\`/v1/{platform}/reviews/history/{job_id}\`)
46
-
47
- Start a job with \`socialcrawl_request\` on the POST for the platform — it holds the price and answers 202 with \`job_id\` (\`job_…\`):
48
-
49
- | Start (POST) | Poll with \`platform\` | Price |
50
- |---|---|---|
51
- | \`trustpilot/reviews/history\` | \`trustpilot\` (default) | holds \`depth\` + 5 |
52
- | \`tripadvisor/reviews/history\` | \`tripadvisor\` | holds \`depth\` |
53
- | \`google/business/reviews/history\` (exactly one of \`place_id\` or \`cid\`, \`depth\` 1-10,000) | \`google\` | 5 per started 100 reviews collected; none collected is refunded in full |
54
- | \`yelp/business/reviews/history\` | \`yelp\` | 1 per started 4 pages (held at 52 a language; \`languages=all\` holds 154); honours \`Idempotency-Key\` |
55
-
56
- Poll with \`socialcrawl_manage\` \`area: "review_history"\`, \`action: "get"\`, \`id\` = the job id, free. Trustpilot, Tripadvisor and Google: status queued → running → polling → succeeded | failed; once settled each page carries \`data.items\` and \`data.job\` (\`credits_hold\`, the settled \`credits_charged\`, \`expires_at\`); page with \`offset\` and \`limit\` (1-100) until a page is shorter than \`limit\`. Yelp: rows are readable while the job runs, each page carries \`data.job\` (\`pages_read\`, \`reviews_collected\`, per-language progress), \`total\` and \`next_offset\` (null on the last page). Jobs live 7 days.
57
-
58
- ## Bulk review history (\`POST /v1/prism/reviews/bulk\`)
59
-
60
- One background job over up to 20,000 businesses or apps: \`platform\` (\`yelp\`, \`tripadvisor\`, \`app_store\`, \`google_play\`), \`items\`, optional \`since\` / \`until\`, \`languages\` (not Tripadvisor or App Store), \`max_reviews_per_item\`, \`format\` (\`jsonl\` | \`csv\`), \`include\` (\`business\`, \`business_full\` on Yelp, \`none\`), \`country\` (App Store, Google Play), \`webhook_url\` (https; the 202 shows its \`webhook_secret\` once) and \`refresh_of\` (an earlier job of this key: reuses its items and starts from the day it settled). Start it with \`socialcrawl_request\`. It bills 1 credit per started 4 pages over the whole job, reserved 25 credits at a time; a business that cannot be read costs nothing. When the next block cannot be held the job pauses as \`paused_insufficient_credits\` and resumes after a top-up (webhook events \`reviews_bulk.paused\`, \`resumed\`, \`completed\`, signed \`x-socialcrawl-signature\`). \`Idempotency-Key\` replays the job at 0 credits.
61
-
62
- Then, free: \`action: "bulk_get"\` (progress, each item's \`status\` pending | walking | waiting | done | unavailable, and signed links to the combined file, the manifest and each item's file, valid 1 hour; page items with \`offset\`/\`limit\`) and \`action: "bulk_cancel"\` (keeps and bills what was read; the job can still read \`running\` until it settles as \`cancelled\`). There is no list route: keep the job id.
63
-
64
- ## follow
65
-
66
- Answers carry ready next-step URLs in \`data.next.*\`. \`socialcrawl_manage\` \`area: "discover"\`, \`action: "follow"\`, \`input: { url }\` GETs one only when it is on the configured SocialCrawl API AND one of the free read routes above (batch jobs, discover runs and schedules, review history, the events feed, webhook endpoints). \`status_url\`, \`results_url\`, \`changes_url\` and \`poll_url\` are free reads. \`continue_url\` STARTS a billable continuation and is never followed (call \`socialcrawl_request\` after checking \`continue_estimate\`); \`resume_url\`/\`more_url\` are POSTs: use \`run_resume\`/\`run_more\`.
9
+ export const DISCOVER_RUNS_DOC = `# SocialCrawl API — Discover runs, schedules and review history
10
+
11
+ Work that keeps running after the call that started it. Start it with \`socialcrawl_request\`; read, export, steer and stop it with \`socialcrawl_manage\` (areas \`discover\` and \`review_history\`). Every read here is free; only the searches a run goes on to make are billed.
12
+
13
+ ## Discover runs (\`/v1/prism/discover/runs\`)
14
+
15
+ Start a run with \`socialcrawl_request\` on \`prism/discover\` (\`max_credits\` is required; \`async\` runs it in the background). Manage it with \`socialcrawl_manage\` \`area: "discover"\`; \`id\` is the run id (\`run_…\`, \`data.run.run_id\`). Runs created since 14/11/2026 are kept 30 days by default (was 7); \`retention_days\` is 1 to 30.
16
+
17
+ | Action | Route | Cost |
18
+ |--------|-------|------|
19
+ | \`run_list\` | \`GET /runs\` (status, kind, created_after, cursor, page_size ≤100; \`id\` = a schedule id lists that schedule's runs) | 0 |
20
+ | \`run_get\` | \`GET /runs/{run_id}\` | 0 |
21
+ | \`run_export\` | \`GET /runs/{run_id}/results.jsonl\` | 0 |
22
+ | \`run_legs\` | \`GET /runs/{run_id}/legs\` (page_size ≤500) | 0 |
23
+ | \`run_cancel\` | \`DELETE /runs/{run_id}\` | 0 — rows kept, resume continues |
24
+ | \`run_resume\` | \`POST /runs/{run_id}/resume\` \`{ max_credits?, retry_failed? }\` | 0 itself; continued searches bill as they run |
25
+ | \`run_more\` | \`POST /runs/{run_id}/more\` \`{ new_searches?, feedback?, max_credits?, pages? }\` | each new search bills at its lane price |
26
+
27
+ - **Long-poll:** \`run_get\` with \`wait_s\` (0-25) answers early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key; a sixth answers at once.
28
+ - **Filters** (run_get and run_export): view, order (arrival | rank; rank on a running run is a free 400), include_pending, changes_since, group, platform, keyword, sort, state (kept | dropped | all), include=dropped, and \`tags\` sent as \`tag.<key>=<value>\`. Any parameter the route does not take is a free 400. A cursor is signed with the filters it was issued for: send the SAME filters with it.
29
+ - **run_export** streams every matching row; the last line is \`{"complete":true}\` or \`{"next_cursor":"…"}\` (stopped after about 45 s; send it back with the same filters).
30
+ - **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER \`max_credits\`. Searches already paid for are never paid twice.
31
+ - **run_more** works on completed runs only: \`pages\` 1-10, \`feedback.accept\`/\`feedback.reject\` up to 100 ids each (\`accept\` needs \`new_searches: true\`). Read only the new rows with \`changes_since\` = \`data.more.since_version\`. \`data.more.nothing_more\` (200) charged nothing. The route takes no Idempotency-Key, so check the run before repeating a more.
32
+ - **No dry_run** on any run or schedule route (resume and more refuse any query parameter).
33
+ - **Errors:** 404 RUN_NOT_FOUND (not your run), 409 RUN_STATE_CONFLICT, 410 RUN_EXPIRED (retention passed), 503 store_unavailable (retryable, nothing charged).
34
+
35
+ ## Discover schedules (\`/v1/prism/discover/schedules\`)
36
+
37
+ Created by \`prism/discover\` with a \`schedule\` field. All free; each scheduled run bills like a run within \`max_credits_per_run\` and \`max_credits_per_month\`. \`id\` is the schedule id (\`dsch_…\`).
38
+
39
+ \`schedule_list\` (status active | paused | stopped, cursor, page_size ≤100), \`schedule_get\` (its recent runs, this month's spend, next fire), \`schedule_pause\`, \`schedule_resume\` (\`{ max_credits_per_run?, max_credits_per_month? }\`, null clears the month cap), \`schedule_delete\` (runs keep their rows). \`run_list\` with the schedule id lists one schedule's runs.
40
+
41
+ ## Stored lists (\`/v1/prism/discover/inputs\`)
42
+
43
+ Make one with \`socialcrawl_request\` on \`POST prism/discover/inputs\` (\`{ kind: "authors", authors: [...] }\` up to 10,000 handles, or \`{ kind: "exclude", exclude: [...] }\` up to 50,000 entries); the answer's \`author_list_id\` / \`exclude_list_id\` (\`din_…\`) goes into a discover call. Then, free: \`input_list\` (every live list with \`item_count\` and \`expires_at\`, plus \`live\` of \`limit\` 500 per account), \`input_append\` (\`id\` + \`{ exclude: [...] }\`, 1 to 50,000 entries; duplicates skipped, the expiry moves to 31 days; past 50,000 in all it is a free 400 \`exclude_list_full\`), \`input_delete\`. An unknown, expired or foreign id, or an author list sent to append, is a 404 \`input_not_found\`. Lists live 30 days.
44
+
45
+ ## Review history (\`/v1/{platform}/reviews/history/{job_id}\`)
46
+
47
+ Start a job with \`socialcrawl_request\` on the POST for the platform — it holds the price and answers 202 with \`job_id\` (\`job_…\`):
48
+
49
+ | Start (POST) | Poll with \`platform\` | Price |
50
+ |---|---|---|
51
+ | \`trustpilot/reviews/history\` | \`trustpilot\` (default) | holds \`depth\` + 5 |
52
+ | \`tripadvisor/reviews/history\` | \`tripadvisor\` | holds \`depth\` |
53
+ | \`google/business/reviews/history\` (exactly one of \`place_id\` or \`cid\`, \`depth\` 1-10,000) | \`google\` | 5 per started 100 reviews collected; none collected is refunded in full |
54
+ | \`yelp/business/reviews/history\` | \`yelp\` | 1 per started 4 pages (held at 52 a language; \`languages=all\` holds 154); honours \`Idempotency-Key\` |
55
+
56
+ Poll with \`socialcrawl_manage\` \`area: "review_history"\`, \`action: "get"\`, \`id\` = the job id, free. Trustpilot, Tripadvisor and Google: status queued → running → polling → succeeded | failed; once settled each page carries \`data.items\` and \`data.job\` (\`credits_hold\`, the settled \`credits_charged\`, \`expires_at\`); page with \`offset\` and \`limit\` (1-100) until a page is shorter than \`limit\`. Yelp: rows are readable while the job runs, each page carries \`data.job\` (\`pages_read\`, \`reviews_collected\`, per-language progress), \`total\` and \`next_offset\` (null on the last page). Jobs live 7 days.
57
+
58
+ ## Bulk review history (\`POST /v1/prism/reviews/bulk\`)
59
+
60
+ One background job over up to 20,000 businesses or apps: \`platform\` (\`yelp\`, \`tripadvisor\`, \`app_store\`, \`google_play\`), \`items\`, optional \`since\` / \`until\`, \`languages\` (not Tripadvisor or App Store), \`max_reviews_per_item\`, \`format\` (\`jsonl\` | \`csv\`), \`include\` (\`business\`, \`business_full\` on Yelp, \`none\`), \`country\` (App Store, Google Play), \`webhook_url\` (https; the 202 shows its \`webhook_secret\` once) and \`refresh_of\` (an earlier job of this key: reuses its items and starts from the day it settled). Start it with \`socialcrawl_request\`. It bills 1 credit per started 4 pages over the whole job, reserved 25 credits at a time; a business that cannot be read costs nothing. When the next block cannot be held the job pauses as \`paused_insufficient_credits\` and resumes after a top-up (webhook events \`reviews_bulk.paused\`, \`resumed\`, \`completed\`, signed \`x-socialcrawl-signature\`). \`Idempotency-Key\` replays the job at 0 credits.
61
+
62
+ Then, free: \`action: "bulk_get"\` (progress, each item's \`status\` pending | walking | waiting | done | unavailable, and signed links to the combined file, the manifest and each item's file, valid 1 hour; page items with \`offset\`/\`limit\`) and \`action: "bulk_cancel"\` (keeps and bills what was read; the job can still read \`running\` until it settles as \`cancelled\`). There is no list route: keep the job id.
63
+
64
+ ## follow
65
+
66
+ Answers carry ready next-step URLs in \`data.next.*\`. \`socialcrawl_manage\` \`area: "discover"\`, \`action: "follow"\`, \`input: { url }\` GETs one only when it is on the configured SocialCrawl API AND one of the free read routes above (batch jobs, discover runs and schedules, review history, the events feed, webhook endpoints). \`status_url\`, \`results_url\`, \`changes_url\` and \`poll_url\` are free reads. \`continue_url\` STARTS a billable continuation and is never followed (call \`socialcrawl_request\` after checking \`continue_estimate\`); \`resume_url\`/\`more_url\` are POSTs: use \`run_resume\`/\`run_more\`.
67
67
  `;
68
- export const EVENTS_DOC = `# SocialCrawl API — Account events feed and webhook endpoints
69
-
70
- The account event log records what happens to this key's background work: discover runs (\`discover.completed\`, \`discover.partial\`, \`discover.paused\`, \`discover.failed\`, \`discover.progress\`, \`discover.accounts_ready\`, \`discover.new_rows\`, \`discover.new_accounts\`, \`discover.new_items\`), schedules (\`discover.run_skipped\`, \`discover.run_failed\`) and webhook endpoint health (\`endpoint.disabled\`). Pull it with the feed or have it pushed to a webhook endpoint. Use \`socialcrawl_manage\` \`area: "events"\`. Everything here costs **0 credits**, and no route here takes \`dry_run\`.
71
-
72
- ## Feed (\`GET /v1/events\`)
73
-
74
- - **Your own cursor:** \`cursor\` = \`oldest\` (start of the 30-day retention), \`now\` (only new events), an event id (\`evt_…\`) or \`pagination.next_cursor\` exactly as returned. Save \`next_cursor\` after each page.
75
- - **Named consumer:** \`id\` = a consumer name (a-z, 0-9, _ and -, up to 64). The server keeps its position; \`start\` (now | oldest) sets where a new consumer begins; its \`types\`/\`subject_ids\` filters bind at first use. A read commits nothing: process the page, then \`ack\` its \`pagination.next_cursor\` (\`POST /v1/events/consumers/{name}/ack\`, same \`id\`, \`input: { cursor }\`). Until you ack, the read returns the same page.
76
- - Not both \`cursor\` and a consumer (a free 400).
77
- - **Filters:** \`types\` (up to 50 types or patterns: \`discover.completed\`, \`discover.*\`, \`*\`) and \`subject_ids\` (up to 100 run_… or dsch_… ids). \`limit\` 1-500 (default 100).
78
- - **Long-poll:** \`wait_s\` (0-25) holds an empty read until an event arrives. At most 5 long-polls per key; a sixth answers at once.
79
- - **410 CURSOR_EXPIRED:** the position is older than the 30-day retention, so events were missed. Restart from \`oldest\` (a consumer restarts there on its next read and says \`restarted_from\` once) and tell the user which window was missed.
80
- - \`data.next.poll_url\` is a free read: \`area: "discover"\` action \`follow\` can GET it.
81
-
82
- ## Webhook endpoints (\`/v1/webhook-endpoints\`)
83
-
84
- At most **20 per API key**; an endpoint answers only to the key that created it. \`id\` is the endpoint id (\`we_…\`, \`data.endpoint.id\`).
85
-
86
- | Action | Route |
87
- |--------|-------|
88
- | \`endpoint_create\` | \`POST /\` \`{ url, types?, description?, subject_ids? }\` (201) |
89
- | \`endpoint_list\` | \`GET /\` (limit ≤100, cursor, status) |
90
- | \`endpoint_get\` | \`GET /{id}\` |
91
- | \`endpoint_update\` | \`PATCH /{id}\` (url, types, description, subject_ids, status enabled/disabled) |
92
- | \`endpoint_delete\` | \`DELETE /{id}\` |
93
- | \`endpoint_rotate_secret\` | \`POST /{id}/rotate-secret\` |
94
- | \`endpoint_test\` | \`POST /{id}/test\` \`{ type? }\` |
95
- | \`endpoint_attempts\` | \`GET /{id}/attempts\` (limit ≤100, cursor) |
96
-
97
- - **The secret is shown ONCE.** \`endpoint_create\` and \`endpoint_rotate_secret\` return a \`whsec_\` secret in \`data.secret\`; store it immediately. Both send an Idempotency-Key (generated when you omit it, and echoed): a replay never creates a second endpoint and never shows the secret again. If it is lost, rotate with a NEW key.
98
- - **Rotation:** for 24 hours every delivery is signed with both the old and the new secret, so deploy the new one before then.
99
- - **URL rules:** a public HTTPS receiver. Private hosts and chat-app incoming webhooks are refused (400 invalid_webhook_url).
100
- - **Types** default to \`["*"]\`. \`endpoint_test\` sends one signed sample of a subscribed type; the receiver has 15 s to answer 2xx. Answering 410 to a real delivery disables the endpoint.
101
- - **Retries:** a failing delivery gets 8 attempts in all, backing off over roughly 41 hours; \`endpoint_attempts\` shows the log. Setting \`status: "enabled"\` on a disabled endpoint resumes its parked deliveries at once.
102
- - **Links are full URLs.** An event's \`links\` (\`run\`, \`results\`, \`changes\`) start with the API's https origin; pass any of them to action \`follow\` (areas \`discover\`, \`search_runs\`, \`creator_runs\`).
68
+ export const EVENTS_DOC = `# SocialCrawl API — Account events feed and webhook endpoints
69
+
70
+ The account event log records what happens to this key's background work: discover runs (\`discover.completed\`, \`discover.partial\`, \`discover.paused\`, \`discover.failed\`, \`discover.progress\`, \`discover.accounts_ready\`, \`discover.new_rows\`, \`discover.new_accounts\`, \`discover.new_items\`), schedules (\`discover.run_skipped\`, \`discover.run_failed\`) and webhook endpoint health (\`endpoint.disabled\`). Pull it with the feed or have it pushed to a webhook endpoint. Use \`socialcrawl_manage\` \`area: "events"\`. Everything here costs **0 credits**, and no route here takes \`dry_run\`.
71
+
72
+ ## Feed (\`GET /v1/events\`)
73
+
74
+ - **Your own cursor:** \`cursor\` = \`oldest\` (start of the 30-day retention), \`now\` (only new events), an event id (\`evt_…\`) or \`pagination.next_cursor\` exactly as returned. Save \`next_cursor\` after each page.
75
+ - **Named consumer:** \`id\` = a consumer name (a-z, 0-9, _ and -, up to 64). The server keeps its position; \`start\` (now | oldest) sets where a new consumer begins; its \`types\`/\`subject_ids\` filters bind at first use. A read commits nothing: process the page, then \`ack\` its \`pagination.next_cursor\` (\`POST /v1/events/consumers/{name}/ack\`, same \`id\`, \`input: { cursor }\`). Until you ack, the read returns the same page.
76
+ - Not both \`cursor\` and a consumer (a free 400).
77
+ - **Filters:** \`types\` (up to 50 types or patterns: \`discover.completed\`, \`discover.*\`, \`*\`) and \`subject_ids\` (up to 100 run_… or dsch_… ids). \`limit\` 1-500 (default 100).
78
+ - **Long-poll:** \`wait_s\` (0-25) holds an empty read until an event arrives. At most 5 long-polls per key; a sixth answers at once.
79
+ - **410 CURSOR_EXPIRED:** the position is older than the 30-day retention, so events were missed. Restart from \`oldest\` (a consumer restarts there on its next read and says \`restarted_from\` once) and tell the user which window was missed.
80
+ - \`data.next.poll_url\` is a free read: \`area: "discover"\` action \`follow\` can GET it.
81
+
82
+ ## Webhook endpoints (\`/v1/webhook-endpoints\`)
83
+
84
+ At most **20 per API key**; an endpoint answers only to the key that created it. \`id\` is the endpoint id (\`we_…\`, \`data.endpoint.id\`).
85
+
86
+ | Action | Route |
87
+ |--------|-------|
88
+ | \`endpoint_create\` | \`POST /\` \`{ url, types?, description?, subject_ids? }\` (201) |
89
+ | \`endpoint_list\` | \`GET /\` (limit ≤100, cursor, status) |
90
+ | \`endpoint_get\` | \`GET /{id}\` |
91
+ | \`endpoint_update\` | \`PATCH /{id}\` (url, types, description, subject_ids, status enabled/disabled) |
92
+ | \`endpoint_delete\` | \`DELETE /{id}\` |
93
+ | \`endpoint_rotate_secret\` | \`POST /{id}/rotate-secret\` |
94
+ | \`endpoint_test\` | \`POST /{id}/test\` \`{ type? }\` |
95
+ | \`endpoint_attempts\` | \`GET /{id}/attempts\` (limit ≤100, cursor) |
96
+
97
+ - **The secret is shown ONCE.** \`endpoint_create\` and \`endpoint_rotate_secret\` return a \`whsec_\` secret in \`data.secret\`; store it immediately. Both send an Idempotency-Key (generated when you omit it, and echoed): a replay never creates a second endpoint and never shows the secret again. If it is lost, rotate with a NEW key.
98
+ - **Rotation:** for 24 hours every delivery is signed with both the old and the new secret, so deploy the new one before then.
99
+ - **URL rules:** a public HTTPS receiver. Private hosts and chat-app incoming webhooks are refused (400 invalid_webhook_url).
100
+ - **Types** default to \`["*"]\`. \`endpoint_test\` sends one signed sample of a subscribed type; the receiver has 15 s to answer 2xx. Answering 410 to a real delivery disables the endpoint.
101
+ - **Retries:** a failing delivery gets 8 attempts in all, backing off over roughly 41 hours; \`endpoint_attempts\` shows the log. Setting \`status: "enabled"\` on a disabled endpoint resumes its parked deliveries at once.
102
+ - **Links are full URLs.** An event's \`links\` (\`run\`, \`results\`, \`changes\`) start with the API's https origin; pass any of them to action \`follow\` (areas \`discover\`, \`search_runs\`, \`creator_runs\`).
103
103
  `;
104
104
  /**
105
105
  * Universal search runs, lists and watches (UPGRADE-LOG API-073, API-077,
@@ -108,49 +108,49 @@ At most **20 per API key**; an endpoint answers only to the key that created it.
108
108
  * meta-search/{list-http,list-start,list-actions,list-more,list-followups,
109
109
  * list-watch,list-watch-routes,stored-runs}.ts and prism/creators/follow.ts.
110
110
  */
111
- export const SEARCH_RUNS_DOC = `# SocialCrawl API — Universal search runs, lists, watches and creator runs
112
-
113
- \`GET /v1/search/everywhere\` answers one search in the call (20 credits, flat). Everything that keeps working after the call — a list of searches, a scheduled watch, the next page, follow-up reads — is a **run**, read and steered with \`socialcrawl_manage\` area \`search_runs\`. Every read is free.
114
-
115
- ## Start one (socialcrawl_request, \`POST /v1/search/everywhere\`)
116
-
117
- The JSON body takes every search field of the GET (\`query\` or \`keywords\`, \`context\`, \`platforms\`, \`exclude_platforms\`, \`period\`/\`since\`/\`until\`, \`languages\`, \`country\`, \`depth\`, \`label\`, …) plus exactly one of:
118
-
119
- - **\`queries\`** — up to 100 search strings (≤512 chars each). One background run; each search is a job that reserves its own **20 credits**.
120
- - **\`groups\`** — 1-100 \`{id, query | keywords, context?, platforms?, exclude_platforms?, period?, since?, until?, tags?}\`. A group's rows keep their own order; one de-duplication runs across the list, and a row several groups found lists them in \`also_in_groups\`.
121
- - **\`schedule\`** — \`{every: 1h|6h|12h|1d|7d|30d, max_credits_per_run, max_credits_per_month?, name, start_at?}\` turns the search (or list) into a **watch**: each fire returns only rows that watch never delivered (the first fire marks its rows \`baseline: true\`).
122
-
123
- **Price:** 20 credits per search plus any extras' ceilings (\`comments.*\`, \`authors.*\`). A list needs \`max_credits\` at or above that estimate; nothing is held at submit, each search charges as it runs, and the run **pauses** at \`max_credits\`, the key budget or the balance with \`data.next.resume_url\` — nothing is paid twice. A watch needs \`max_credits_per_run\` at least one fire's estimate; each fire bills like the list (no surcharge, no refund when nothing is new). \`dry_run: true\` answers the plan and estimate for free — on a watch, the price of a fire (\`credits_per_fire\`) and of 30 days (\`credits_per_30_days\`). The answer is **202** with \`data.run\` and \`data.next.status_url\` (a watch adds \`data.watch\`). \`Idempotency-Key\` replays the first answer; the same request sent again while its run is live returns that run (\`run.deduplicated\`).
124
-
125
- ## Runs (area \`search_runs\`)
126
-
127
- Universal-search runs created since 14/11/2026 are kept 30 days by default (was 7); \`retention_days\` is 1 to 30.
128
-
129
- | Action | Route | Cost |
130
- |---|---|---|
131
- | \`run_list\` | \`GET /v1/search/everywhere/runs\` — status, created_after, cursor, page_size 1-100; a watch id as \`id\` lists its fires | 0 |
132
- | \`run_get\` | \`GET …/runs/{run_id}\` — \`wait_s\` 0-25 long-polls; format evidence\\|compact\\|text, fields, sort relevance\\|recent\\|engagement, max_per_platform, platform, group, state kept\\|dropped\\|all, changes_since, cursor, page_size | 0 |
133
- | \`run_export\` | \`GET …/runs/{run_id}/results.jsonl\` — the same filters, no paging; ends with \`{"complete":true,"changes_url":…}\` | 0 |
134
- | \`run_legs\` | \`GET …/runs/{run_id}/legs\` — every search with its outcome and credits | 0 |
135
- | \`run_cancel\` | \`DELETE …/runs/{run_id}\` — a list only (409 \`run_not_a_list\` on a one-off) | 0 |
136
- | \`run_resume\` | \`POST …/runs/{run_id}/resume\` — \`max_credits\` (higher, if it paused at its cap), \`retry_failed\` | 0 + the searches it runs |
137
- | \`run_more\` | \`POST …/runs/{run_id}/more\` — the next page of every search that has one; \`max_credits\` is the run's new total cap | **20 credits per search** with another page; \`nothing_more\` is free; dry_run quotes it |
138
- | \`run_include\` | \`POST …/runs/{run_id}/include\` — \`include\` comments\\|authors\\|body, \`ids\` (1-200 rows), \`comments.per_post\` 5-50, \`comments.replies\`, \`authors.top\` 1-100, \`max_credits\` | metered per read, capped by max_credits (default: the quote); dry_run answers \`estimate.credits {min, expected, max}\` |
139
-
140
- \`run_more\` and \`run_include\` take \`Idempotency-Key\` and \`dry_run\`. Read only what a step added with \`run_get\` + \`changes_since\`, or follow \`data.next.changes_url\` — the page that serves a run's last row names it.
141
-
142
- ## Watches (area \`search_runs\`)
143
-
144
- \`watch_list\` (status active\\|paused\\|stopped), \`watch_get\` (with its 10 latest fires), \`watch_delete\` — all free on \`/v1/search/everywhere/watches\`. \`watch_pause\` / \`watch_resume\` (new \`max_credits_per_run\` / \`max_credits_per_month\`) use the discover schedule routes a watch is built on. A watch view carries \`caps\`, \`spend.month\`, \`next_fire_at\`, \`last_fire {run_id, new_rows, results_url}\`.
145
-
146
- ## Creator runs (area \`creator_runs\`)
147
-
148
- \`prism/creators\` (GET or POST, socialcrawl_request) works toward \`limit\` until it has the creators, runs dry or reaches \`max_credits\`, and says which (\`stopped_because\`, \`short_reason\`). Its run is read like a search run on \`/v1/prism/creators/runs\` (\`run_list\`, \`run_get\` with country / account_kind / platform / sort / order filters, \`run_export\`, \`run_legs\`, \`run_cancel\`, \`run_resume\`, \`run_more\`) — reads free.
149
-
150
- \`run_save\` (\`POST …/runs/{run_id}/save\`, \`keys\` optional, Idempotency-Key) stores the creators as author lists — **free**, kept 30 days, counted in the 500 live stored lists per account (see Stored lists in the \`discover-runs\` topic), 10,000 handles each — and answers \`data.next.follow\`: a ready \`POST prism/discover\` schedule body (daily, event \`discover.new_rows\`) that watches those creators for new posts. It costs what its runs cost, with no premium.
151
-
152
- ## follow
153
-
154
- Any \`data.next.*\` read URL (status_url, results_url, legs_url, changes_url, a watch's links) goes to action \`follow\` — absolute or relative, on the configured API only. POST links are refused with the action to use: more_url → \`run_more\`, include_url → \`run_include\`, resume_url → \`run_resume\`, a creator save → \`run_save\`.
111
+ export const SEARCH_RUNS_DOC = `# SocialCrawl API — Universal search runs, lists, watches and creator runs
112
+
113
+ \`GET /v1/search/everywhere\` answers one search in the call (20 credits, flat). Everything that keeps working after the call — a list of searches, a scheduled watch, the next page, follow-up reads — is a **run**, read and steered with \`socialcrawl_manage\` area \`search_runs\`. Every read is free.
114
+
115
+ ## Start one (socialcrawl_request, \`POST /v1/search/everywhere\`)
116
+
117
+ The JSON body takes every search field of the GET (\`query\` or \`keywords\`, \`context\`, \`platforms\`, \`exclude_platforms\`, \`period\`/\`since\`/\`until\`, \`languages\`, \`country\`, \`depth\`, \`label\`, …) plus exactly one of:
118
+
119
+ - **\`queries\`** — up to 100 search strings (≤512 chars each). One background run; each search is a job that reserves its own **20 credits**.
120
+ - **\`groups\`** — 1-100 \`{id, query | keywords, context?, platforms?, exclude_platforms?, period?, since?, until?, tags?}\`. A group's rows keep their own order; one de-duplication runs across the list, and a row several groups found lists them in \`also_in_groups\`.
121
+ - **\`schedule\`** — \`{every: 1h|6h|12h|1d|7d|30d, max_credits_per_run, max_credits_per_month?, name, start_at?}\` turns the search (or list) into a **watch**: each fire returns only rows that watch never delivered (the first fire marks its rows \`baseline: true\`).
122
+
123
+ **Price:** 20 credits per search plus any extras' ceilings (\`comments.*\`, \`authors.*\`). A list needs \`max_credits\` at or above that estimate; nothing is held at submit, each search charges as it runs, and the run **pauses** at \`max_credits\`, the key budget or the balance with \`data.next.resume_url\` — nothing is paid twice. A watch needs \`max_credits_per_run\` at least one fire's estimate; each fire bills like the list (no surcharge, no refund when nothing is new). \`dry_run: true\` answers the plan and estimate for free — on a watch, the price of a fire (\`credits_per_fire\`) and of 30 days (\`credits_per_30_days\`). The answer is **202** with \`data.run\` and \`data.next.status_url\` (a watch adds \`data.watch\`). \`Idempotency-Key\` replays the first answer; the same request sent again while its run is live returns that run (\`run.deduplicated\`).
124
+
125
+ ## Runs (area \`search_runs\`)
126
+
127
+ Universal-search runs created since 14/11/2026 are kept 30 days by default (was 7); \`retention_days\` is 1 to 30.
128
+
129
+ | Action | Route | Cost |
130
+ |---|---|---|
131
+ | \`run_list\` | \`GET /v1/search/everywhere/runs\` — status, created_after, cursor, page_size 1-100; a watch id as \`id\` lists its fires | 0 |
132
+ | \`run_get\` | \`GET …/runs/{run_id}\` — \`wait_s\` 0-25 long-polls; format evidence\\|compact\\|text, fields, sort relevance\\|recent\\|engagement, max_per_platform, platform, group, state kept\\|dropped\\|all, changes_since, cursor, page_size | 0 |
133
+ | \`run_export\` | \`GET …/runs/{run_id}/results.jsonl\` — the same filters, no paging; ends with \`{"complete":true,"changes_url":…}\` | 0 |
134
+ | \`run_legs\` | \`GET …/runs/{run_id}/legs\` — every search with its outcome and credits | 0 |
135
+ | \`run_cancel\` | \`DELETE …/runs/{run_id}\` — a list only (409 \`run_not_a_list\` on a one-off) | 0 |
136
+ | \`run_resume\` | \`POST …/runs/{run_id}/resume\` — \`max_credits\` (higher, if it paused at its cap), \`retry_failed\` | 0 + the searches it runs |
137
+ | \`run_more\` | \`POST …/runs/{run_id}/more\` — the next page of every search that has one; \`max_credits\` is the run's new total cap | **20 credits per search** with another page; \`nothing_more\` is free; dry_run quotes it |
138
+ | \`run_include\` | \`POST …/runs/{run_id}/include\` — \`include\` comments\\|authors\\|body, \`ids\` (1-200 rows), \`comments.per_post\` 5-50, \`comments.replies\`, \`authors.top\` 1-100, \`max_credits\` | metered per read, capped by max_credits (default: the quote); dry_run answers \`estimate.credits {min, expected, max}\` |
139
+
140
+ \`run_more\` and \`run_include\` take \`Idempotency-Key\` and \`dry_run\`. Read only what a step added with \`run_get\` + \`changes_since\`, or follow \`data.next.changes_url\` — the page that serves a run's last row names it.
141
+
142
+ ## Watches (area \`search_runs\`)
143
+
144
+ \`watch_list\` (status active\\|paused\\|stopped), \`watch_get\` (with its 10 latest fires), \`watch_delete\` — all free on \`/v1/search/everywhere/watches\`. \`watch_pause\` / \`watch_resume\` (new \`max_credits_per_run\` / \`max_credits_per_month\`) use the discover schedule routes a watch is built on. A watch view carries \`caps\`, \`spend.month\`, \`next_fire_at\`, \`last_fire {run_id, new_rows, results_url}\`.
145
+
146
+ ## Creator runs (area \`creator_runs\`)
147
+
148
+ \`prism/creators\` (GET or POST, socialcrawl_request) works toward \`limit\` until it has the creators, runs dry or reaches \`max_credits\`, and says which (\`stopped_because\`, \`short_reason\`). Its run is read like a search run on \`/v1/prism/creators/runs\` (\`run_list\`, \`run_get\` with country / account_kind / platform / sort / order filters, \`run_export\`, \`run_legs\`, \`run_cancel\`, \`run_resume\`, \`run_more\`) — reads free.
149
+
150
+ \`run_save\` (\`POST …/runs/{run_id}/save\`, \`keys\` optional, Idempotency-Key) stores the creators as author lists — **free**, kept 30 days, counted in the 500 live stored lists per account (see Stored lists in the \`discover-runs\` topic), 10,000 handles each — and answers \`data.next.follow\`: a ready \`POST prism/discover\` schedule body (daily, event \`discover.new_rows\`) that watches those creators for new posts. It costs what its runs cost, with no premium.
151
+
152
+ ## follow
153
+
154
+ Any \`data.next.*\` read URL (status_url, results_url, legs_url, changes_url, a watch's links) goes to action \`follow\` — absolute or relative, on the configured API only. POST links are refused with the action to use: more_url → \`run_more\`, include_url → \`run_include\`, resume_url → \`run_resume\`, a creator save → \`run_save\`.
155
155
  `;
156
156
  //# sourceMappingURL=docs-async.js.map