socialcrawl-mcp 2.2.0 → 2.3.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 (43) hide show
  1. package/README.md +42 -20
  2. package/dist/app.d.ts +3 -3
  3. package/dist/app.js +5 -1
  4. package/dist/client-tag.d.ts +13 -0
  5. package/dist/client-tag.js +17 -0
  6. package/dist/client.js +6 -4
  7. package/dist/constants.d.ts +1 -1
  8. package/dist/constants.js +1 -1
  9. package/dist/context.d.ts +6 -0
  10. package/dist/context.js +1 -0
  11. package/dist/data/docs-async.d.ts +2 -2
  12. package/dist/data/docs-async.js +137 -116
  13. package/dist/data/docs-handwritten.js +46 -5
  14. package/dist/data/docs.js +2 -0
  15. package/dist/data/endpoints.js +13111 -10305
  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 +324 -219
  20. package/dist/data/platforms.js +207 -48
  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/hydration.js +21 -3
  25. package/dist/oauth/config.d.ts +19 -4
  26. package/dist/oauth/config.js +31 -6
  27. package/dist/schemas/async.d.ts +37 -27
  28. package/dist/schemas/async.js +28 -9
  29. package/dist/schemas/outputs.d.ts +2 -2
  30. package/dist/schemas/tools.d.ts +18 -6
  31. package/dist/schemas/tools.js +24 -4
  32. package/dist/server.js +6 -5
  33. package/dist/tools/account.d.ts +4 -1
  34. package/dist/tools/account.js +1 -1
  35. package/dist/tools/async-common.js +3 -1
  36. package/dist/tools/check-balance.d.ts +4 -2
  37. package/dist/tools/check-balance.js +9 -0
  38. package/dist/tools/discover-runs.js +117 -11
  39. package/dist/tools/estimate.js +10 -1
  40. package/dist/tools/manage.js +2 -0
  41. package/dist/tools/monitors.d.ts +7 -1
  42. package/dist/tools/monitors.js +26 -2
  43. package/package.json +75 -75
@@ -10,21 +10,21 @@
10
10
  * same fingerprint accept exactly the same calls; the freshness check compares
11
11
  * it with the live API's.
12
12
  */
13
- export declare const REGISTRY_FINGERPRINT = "e1eecd2aeb103cf5b19dfe45db80fa3e26fe61dc44240813d0e1e5051abd7c62";
13
+ export declare const REGISTRY_FINGERPRINT = "270ffedde607a5bc95116cff6dc5db7f305609990af355fbb0787c9c6299a295";
14
14
  /** Live platform / endpoint / tier counts from the backend registry. */
15
15
  export declare const REGISTRY_STATS: {
16
- readonly totalEndpoints: 733;
17
- readonly totalPlatforms: 75;
18
- readonly socialPlatforms: 34;
16
+ readonly totalEndpoints: 802;
17
+ readonly totalPlatforms: 95;
18
+ readonly socialPlatforms: 35;
19
19
  readonly universalSearchPlatforms: 18;
20
20
  readonly universalSearchSources: 23;
21
- readonly standardEndpoints: 418;
22
- readonly advancedEndpoints: 269;
21
+ readonly standardEndpoints: 486;
22
+ readonly advancedEndpoints: 270;
23
23
  readonly premiumEndpoints: 46;
24
- readonly standardLadder: 267;
24
+ readonly standardLadder: 325;
25
25
  readonly advancedLadder: 182;
26
26
  readonly premiumLadder: 25;
27
- readonly customCount: 259;
27
+ readonly customCount: 270;
28
28
  };
29
29
  /** The credit-tier ladder. Endpoints may override it flat or meter per query. */
30
30
  export declare const CREDIT_LADDER: Record<string, number>;
@@ -10,21 +10,21 @@
10
10
  * same fingerprint accept exactly the same calls; the freshness check compares
11
11
  * it with the live API's.
12
12
  */
13
- export const REGISTRY_FINGERPRINT = "e1eecd2aeb103cf5b19dfe45db80fa3e26fe61dc44240813d0e1e5051abd7c62";
13
+ export const REGISTRY_FINGERPRINT = "270ffedde607a5bc95116cff6dc5db7f305609990af355fbb0787c9c6299a295";
14
14
  /** Live platform / endpoint / tier counts from the backend registry. */
15
15
  export const REGISTRY_STATS = {
16
- "totalEndpoints": 733,
17
- "totalPlatforms": 75,
18
- "socialPlatforms": 34,
16
+ "totalEndpoints": 802,
17
+ "totalPlatforms": 95,
18
+ "socialPlatforms": 35,
19
19
  "universalSearchPlatforms": 18,
20
20
  "universalSearchSources": 23,
21
- "standardEndpoints": 418,
22
- "advancedEndpoints": 269,
21
+ "standardEndpoints": 486,
22
+ "advancedEndpoints": 270,
23
23
  "premiumEndpoints": 46,
24
- "standardLadder": 267,
24
+ "standardLadder": 325,
25
25
  "advancedLadder": 182,
26
26
  "premiumLadder": 25,
27
- "customCount": 259
27
+ "customCount": 270
28
28
  };
29
29
  /** The credit-tier ladder. Endpoints may override it flat or meter per query. */
30
30
  export const CREDIT_LADDER = {
package/dist/hydration.js CHANGED
@@ -178,6 +178,9 @@ export function describeLane(lane) {
178
178
  ? `; defaults to the top ${lane.defaultRowLimit}`
179
179
  : ""})`
180
180
  : `up to ${lane.maxItems} row${lane.maxItems === 1 ? "" : "s"}`;
181
+ if (lane.creditsPerItem === 0) {
182
+ return `\`${lane.param}=${lane.token}\` → joins each row to ${siblingRef(lane, { alwaysMethod: true })} — free (no extra credit, nothing held), ${cap}.`;
183
+ }
181
184
  const rate = lane.batch
182
185
  ? `${lane.creditsPerItem}cr per row filled, never more than ${lane.batch.creditCap} per ${lane.batch.size} rows`
183
186
  : `${lane.creditsPerItem}cr per row filled`;
@@ -207,9 +210,24 @@ export function explainHydration(e) {
207
210
  for (const c of withoutSubsumed(lanes).covered) {
208
211
  lines.push(`- Sending both \`${c.lane.token}\` and \`${c.by.token}\` is priced as \`${c.by.token}\` alone — its lookup already fills ${c.lane.fills.map((f) => `\`${f}\``).join(", ")}.`);
209
212
  }
210
- lines.push(`**What you are actually charged:** the ceiling (${e.pricing.cost}cr base + ${total}cr for every join = ${e.pricing.cost + total}cr) is held up front, then ` +
211
- `${lanes[0].creditsPerItem}cr is KEPT per row a fresh sibling lookup filled and every other slot is refunded. ` +
212
- `Rows served from the sibling's cache are free, rows it could not fill are refunded, and a page that joined in full is cached whole — an immediate repeat is 0 credits.`);
213
+ // Each lane's own rate: a free join (facebook/profile include=details) holds
214
+ // nothing, and on a mixed endpoint (linkedin/company) the paid lane's rate
215
+ // must not be read as applying to the free one.
216
+ const paid = lanes.filter((l) => l.creditsPerItem > 0);
217
+ const free = lanes.filter((l) => l.creditsPerItem === 0);
218
+ const freeNote = free.length > 0 ? ` ${free.map((l) => `\`${l.param}=${l.token}\``).join(", ")} ${free.length === 1 ? "is" : "are"} free: no extra credit is held or kept.` : "";
219
+ if (paid.length === 0) {
220
+ lines.push(`**What you are actually charged:** the base ${e.pricing.cost}cr only; every join here costs no extra credit.${freeNote}`);
221
+ }
222
+ else {
223
+ const rates = [...new Set(paid.map((l) => l.creditsPerItem))];
224
+ const kept = rates.length === 1
225
+ ? `${rates[0]}cr is KEPT per row a fresh sibling lookup filled`
226
+ : `each lane KEEPS its own rate per row a fresh sibling lookup filled (${paid.map((l) => `\`${l.token}\` ${l.creditsPerItem}cr`).join(", ")})`;
227
+ lines.push(`**What you are actually charged:** the ceiling (${e.pricing.cost}cr base + ${total}cr for every paid join = ${e.pricing.cost + total}cr) is held up front, then ` +
228
+ `${kept} and every other slot is refunded. ` +
229
+ `Rows served from the sibling's cache are free, rows it could not fill are refunded, and a page that joined in full is cached whole — an immediate repeat is 0 credits.${freeNote}`);
230
+ }
213
231
  lines.push(`**Reading the result:** \`data.hydration\` reports \`rows\`, \`looked_up\`, \`filled\`, \`cached\`, \`unfilled\`, \`credits_held\`, \`extra_credits\` (what was kept) and \`ms\`. ` +
214
232
  `If nothing filled you get \`_warnings: ["${lanes[0].warnings.unavailable}"]\`; if only some rows filled, \`["${lanes[0].warnings.partial}"]\`. The envelope's \`credits_used\` is always the real charge.`);
215
233
  return lines;
@@ -11,9 +11,24 @@ export interface OAuthResourceServerConfig {
11
11
  }
12
12
  type Env = Record<string, string | undefined>;
13
13
  /**
14
- * Build the OAuth config from env. `undefined` unless SOCIALCRAWL_OAUTH=1.
15
- * With the flag on, every setting is required and checked up front: a
16
- * half-configured resource server must fail at boot, not per request.
14
+ * Production values for everything that is public. Only the key-lookup
15
+ * secret is private, so it is the one value the owner sets, and setting it is
16
+ * what turns OAuth on. There is no separate on/off switch (owner rule: env
17
+ * holds secrets, never behaviour switches). Each default can be overridden
18
+ * for a local authorization server.
17
19
  */
18
- export declare function oauthConfigFromEnv(env: Env): OAuthResourceServerConfig | undefined;
20
+ export declare const OAUTH_DEFAULTS: {
21
+ readonly SOCIALCRAWL_OAUTH_RESOURCE: "https://mcp.socialcrawl.dev/mcp";
22
+ readonly SOCIALCRAWL_OAUTH_ISSUER: "https://www.socialcrawl.dev";
23
+ readonly SOCIALCRAWL_OAUTH_JWKS_URL: "https://www.socialcrawl.dev/api/auth/jwks";
24
+ readonly SOCIALCRAWL_OAUTH_KEY_LOOKUP_URL: "https://www.socialcrawl.dev/api/mcp/key-lookup";
25
+ };
26
+ /**
27
+ * Build the OAuth config from env. `undefined` when
28
+ * SOCIALCRAWL_OAUTH_KEY_LOOKUP_SECRET is unset: without it no token can be
29
+ * turned into an API key, so advertising sign-in would strand every client.
30
+ * Everything set is checked up front: a half-configured resource server must
31
+ * fail at boot, not per request.
32
+ */
33
+ export declare function oauthConfigFromEnv(input: Env): OAuthResourceServerConfig | undefined;
19
34
  export {};
@@ -4,13 +4,38 @@ const ALLOWED_ALGORITHMS = new Set([
4
4
  "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512",
5
5
  ]);
6
6
  /**
7
- * Build the OAuth config from env. `undefined` unless SOCIALCRAWL_OAUTH=1.
8
- * With the flag on, every setting is required and checked up front: a
9
- * half-configured resource server must fail at boot, not per request.
7
+ * Production values for everything that is public. Only the key-lookup
8
+ * secret is private, so it is the one value the owner sets, and setting it is
9
+ * what turns OAuth on. There is no separate on/off switch (owner rule: env
10
+ * holds secrets, never behaviour switches). Each default can be overridden
11
+ * for a local authorization server.
10
12
  */
11
- export function oauthConfigFromEnv(env) {
12
- if (env.SOCIALCRAWL_OAUTH?.trim() !== "1")
13
+ export const OAUTH_DEFAULTS = {
14
+ SOCIALCRAWL_OAUTH_RESOURCE: "https://mcp.socialcrawl.dev/mcp",
15
+ SOCIALCRAWL_OAUTH_ISSUER: "https://www.socialcrawl.dev",
16
+ SOCIALCRAWL_OAUTH_JWKS_URL: "https://www.socialcrawl.dev/api/auth/jwks",
17
+ SOCIALCRAWL_OAUTH_KEY_LOOKUP_URL: "https://www.socialcrawl.dev/api/mcp/key-lookup",
18
+ };
19
+ /**
20
+ * Build the OAuth config from env. `undefined` when
21
+ * SOCIALCRAWL_OAUTH_KEY_LOOKUP_SECRET is unset: without it no token can be
22
+ * turned into an API key, so advertising sign-in would strand every client.
23
+ * Everything set is checked up front: a half-configured resource server must
24
+ * fail at boot, not per request.
25
+ */
26
+ export function oauthConfigFromEnv(input) {
27
+ const hasSecret = Boolean(input.SOCIALCRAWL_OAUTH_KEY_LOOKUP_SECRET?.trim());
28
+ if (!hasSecret) {
29
+ // The retired switch, set without the secret, is a misconfiguration.
30
+ if (input.SOCIALCRAWL_OAUTH?.trim() === "1")
31
+ requireValue(input, "SOCIALCRAWL_OAUTH_KEY_LOOKUP_SECRET");
13
32
  return undefined;
33
+ }
34
+ const env = { ...input };
35
+ for (const [name, value] of Object.entries(OAUTH_DEFAULTS)) {
36
+ if (!env[name]?.trim())
37
+ env[name] = value;
38
+ }
14
39
  const resource = requireUrl(env, "SOCIALCRAWL_OAUTH_RESOURCE");
15
40
  if (resource.hash !== "" || env.SOCIALCRAWL_OAUTH_RESOURCE.includes("#")) {
16
41
  throw new Error("SOCIALCRAWL_OAUTH_RESOURCE must not contain a fragment");
@@ -39,7 +64,7 @@ export function oauthConfigFromEnv(env) {
39
64
  function requireValue(env, name) {
40
65
  const value = env[name]?.trim();
41
66
  if (!value)
42
- throw new Error(`SOCIALCRAWL_OAUTH=1 requires ${name}`);
67
+ throw new Error(`OAuth requires ${name}`);
43
68
  return value;
44
69
  }
45
70
  /** https only, except loopback hosts for local development. */
@@ -25,15 +25,17 @@ export declare const REVIEW_JOB_ID_RE: RegExp;
25
25
  export declare const RUN_ID_RE: RegExp;
26
26
  export declare const SCHEDULE_ID_RE: RegExp;
27
27
  export declare const WEBHOOK_ENDPOINT_ID_RE: RegExp;
28
+ /** Stored discover lists (`din_` + nanoid 21; db/schema/discover.ts). */
29
+ export declare const DISCOVER_INPUT_ID_RE: RegExp;
28
30
  /** events/feed.ts CONSUMER_RE. */
29
31
  export declare const CONSUMER_NAME_RE: RegExp;
30
32
  /** A type (`discover.completed`), a namespace pattern (`discover.*`) or `*`. */
31
33
  export declare const EVENT_TYPE_PATTERN_RE: RegExp;
32
34
  /** A concrete event type (no pattern), as `endpoint_test` takes. */
33
35
  export declare const EVENT_TYPE_RE: RegExp;
34
- export declare const DISCOVER_ACTIONS: readonly ["run_list", "run_get", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "schedule_list", "schedule_get", "schedule_pause", "schedule_resume", "schedule_delete", "follow"];
36
+ export declare const DISCOVER_ACTIONS: readonly ["run_list", "run_get", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "schedule_list", "schedule_get", "schedule_pause", "schedule_resume", "schedule_delete", "input_list", "input_append", "input_delete", "follow"];
35
37
  export declare const DiscoverInputSchema: z.ZodObject<{
36
- action: z.ZodEnum<["run_list", "run_get", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "schedule_list", "schedule_get", "schedule_pause", "schedule_resume", "schedule_delete", "follow"]>;
38
+ action: z.ZodEnum<["run_list", "run_get", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "schedule_list", "schedule_get", "schedule_pause", "schedule_resume", "schedule_delete", "input_list", "input_append", "input_delete", "follow"]>;
37
39
  run_id: z.ZodOptional<z.ZodString>;
38
40
  schedule_id: z.ZodOptional<z.ZodString>;
39
41
  cursor: z.ZodOptional<z.ZodString>;
@@ -70,8 +72,10 @@ export declare const DiscoverInputSchema: z.ZodObject<{
70
72
  max_credits_per_run: z.ZodOptional<z.ZodNumber>;
71
73
  max_credits_per_month: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
72
74
  url: z.ZodOptional<z.ZodString>;
75
+ list_id: z.ZodOptional<z.ZodString>;
76
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
77
  }, "strict", z.ZodTypeAny, {
74
- action: "follow" | "run_list" | "run_get" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "schedule_list" | "schedule_get" | "schedule_pause" | "schedule_resume" | "schedule_delete";
78
+ action: "follow" | "run_list" | "run_get" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "schedule_list" | "schedule_get" | "schedule_pause" | "schedule_resume" | "schedule_delete" | "input_list" | "input_append" | "input_delete";
75
79
  sort?: string | undefined;
76
80
  platform?: string | undefined;
77
81
  cursor?: string | undefined;
@@ -80,13 +84,15 @@ export declare const DiscoverInputSchema: z.ZodObject<{
80
84
  view?: "items" | "posts" | "accounts" | "communities" | undefined;
81
85
  kind?: "get" | "background" | "scheduled" | undefined;
82
86
  include?: "dropped" | undefined;
87
+ max_credits_per_month?: number | null | undefined;
83
88
  url?: string | undefined;
89
+ exclude?: string[] | undefined;
84
90
  keyword?: string | undefined;
85
91
  tags?: Record<string, string> | undefined;
86
92
  order?: "rank" | "arrival" | undefined;
87
93
  group?: string | undefined;
88
- state?: "all" | "kept" | "dropped" | undefined;
89
94
  page_size?: number | undefined;
95
+ state?: "all" | "kept" | "dropped" | undefined;
90
96
  pages?: number | undefined;
91
97
  run_id?: string | undefined;
92
98
  schedule_id?: string | undefined;
@@ -101,9 +107,9 @@ export declare const DiscoverInputSchema: z.ZodObject<{
101
107
  reject?: string[] | undefined;
102
108
  } | undefined;
103
109
  max_credits_per_run?: number | undefined;
104
- max_credits_per_month?: number | null | undefined;
110
+ list_id?: string | undefined;
105
111
  }, {
106
- action: "follow" | "run_list" | "run_get" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "schedule_list" | "schedule_get" | "schedule_pause" | "schedule_resume" | "schedule_delete";
112
+ action: "follow" | "run_list" | "run_get" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "schedule_list" | "schedule_get" | "schedule_pause" | "schedule_resume" | "schedule_delete" | "input_list" | "input_append" | "input_delete";
107
113
  sort?: string | undefined;
108
114
  platform?: string | undefined;
109
115
  cursor?: string | undefined;
@@ -112,13 +118,15 @@ export declare const DiscoverInputSchema: z.ZodObject<{
112
118
  view?: "items" | "posts" | "accounts" | "communities" | undefined;
113
119
  kind?: "get" | "background" | "scheduled" | undefined;
114
120
  include?: "dropped" | undefined;
121
+ max_credits_per_month?: number | null | undefined;
115
122
  url?: string | undefined;
123
+ exclude?: string[] | undefined;
116
124
  keyword?: string | undefined;
117
125
  tags?: Record<string, string> | undefined;
118
126
  order?: "rank" | "arrival" | undefined;
119
127
  group?: string | undefined;
120
- state?: "all" | "kept" | "dropped" | undefined;
121
128
  page_size?: number | undefined;
129
+ state?: "all" | "kept" | "dropped" | undefined;
122
130
  pages?: number | undefined;
123
131
  run_id?: string | undefined;
124
132
  schedule_id?: string | undefined;
@@ -133,7 +141,7 @@ export declare const DiscoverInputSchema: z.ZodObject<{
133
141
  reject?: string[] | undefined;
134
142
  } | undefined;
135
143
  max_credits_per_run?: number | undefined;
136
- max_credits_per_month?: number | null | undefined;
144
+ list_id?: string | undefined;
137
145
  }>;
138
146
  /**
139
147
  * A search watch id. Watches are built on discover schedules; the routes look
@@ -180,13 +188,14 @@ export declare const SearchRunsInputSchema: z.ZodObject<{
180
188
  format?: "compact" | "text" | "evidence" | undefined;
181
189
  max_credits?: number | undefined;
182
190
  include?: string | ("comments" | "body" | "authors")[] | undefined;
191
+ max_credits_per_month?: number | null | undefined;
183
192
  url?: string | undefined;
184
193
  ids?: string[] | undefined;
185
194
  group?: string | undefined;
186
- state?: "all" | "kept" | "dropped" | undefined;
187
- page_size?: number | undefined;
188
- max_per_platform?: number | undefined;
189
195
  "comments.per_post"?: number | undefined;
196
+ max_per_platform?: number | undefined;
197
+ page_size?: number | undefined;
198
+ state?: "all" | "kept" | "dropped" | undefined;
190
199
  "comments.replies"?: boolean | undefined;
191
200
  "authors.top"?: number | undefined;
192
201
  run_id?: string | undefined;
@@ -195,7 +204,6 @@ export declare const SearchRunsInputSchema: z.ZodObject<{
195
204
  changes_since?: number | undefined;
196
205
  retry_failed?: boolean | undefined;
197
206
  max_credits_per_run?: number | undefined;
198
- max_credits_per_month?: number | null | undefined;
199
207
  watch_id?: string | undefined;
200
208
  }, {
201
209
  action: "follow" | "run_list" | "run_get" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "run_include" | "watch_list" | "watch_get" | "watch_pause" | "watch_resume" | "watch_delete";
@@ -207,13 +215,14 @@ export declare const SearchRunsInputSchema: z.ZodObject<{
207
215
  format?: "compact" | "text" | "evidence" | undefined;
208
216
  max_credits?: number | undefined;
209
217
  include?: string | ("comments" | "body" | "authors")[] | undefined;
218
+ max_credits_per_month?: number | null | undefined;
210
219
  url?: string | undefined;
211
220
  ids?: string[] | undefined;
212
221
  group?: string | undefined;
213
- state?: "all" | "kept" | "dropped" | undefined;
214
- page_size?: number | undefined;
215
- max_per_platform?: number | undefined;
216
222
  "comments.per_post"?: number | undefined;
223
+ max_per_platform?: number | undefined;
224
+ page_size?: number | undefined;
225
+ state?: "all" | "kept" | "dropped" | undefined;
217
226
  "comments.replies"?: boolean | undefined;
218
227
  "authors.top"?: number | undefined;
219
228
  run_id?: string | undefined;
@@ -222,7 +231,6 @@ export declare const SearchRunsInputSchema: z.ZodObject<{
222
231
  changes_since?: number | undefined;
223
232
  retry_failed?: boolean | undefined;
224
233
  max_credits_per_run?: number | undefined;
225
- max_credits_per_month?: number | null | undefined;
226
234
  watch_id?: string | undefined;
227
235
  }>;
228
236
  export declare const CreatorRunsInputSchema: z.ZodObject<{
@@ -263,9 +271,9 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
263
271
  country?: string | undefined;
264
272
  order?: "rank" | "arrival" | undefined;
265
273
  group?: string | undefined;
266
- state?: "all" | "kept" | "dropped" | undefined;
267
- page_size?: number | undefined;
268
274
  account_kind?: string | undefined;
275
+ page_size?: number | undefined;
276
+ state?: "all" | "kept" | "dropped" | undefined;
269
277
  pages?: number | undefined;
270
278
  run_id?: string | undefined;
271
279
  created_after?: string | undefined;
@@ -287,9 +295,9 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
287
295
  country?: string | undefined;
288
296
  order?: "rank" | "arrival" | undefined;
289
297
  group?: string | undefined;
290
- state?: "all" | "kept" | "dropped" | undefined;
291
- page_size?: number | undefined;
292
298
  account_kind?: string | undefined;
299
+ page_size?: number | undefined;
300
+ state?: "all" | "kept" | "dropped" | undefined;
293
301
  pages?: number | undefined;
294
302
  run_id?: string | undefined;
295
303
  created_after?: string | undefined;
@@ -298,22 +306,24 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
298
306
  retry_failed?: boolean | undefined;
299
307
  new_searches?: boolean | undefined;
300
308
  }>;
301
- export declare const REVIEW_HISTORY_ACTIONS: readonly ["get"];
309
+ export declare const REVIEW_HISTORY_ACTIONS: readonly ["get", "bulk_get", "bulk_cancel"];
310
+ /** The platforms a review history job is started on, and the route each polls. */
311
+ export declare const REVIEW_HISTORY_PLATFORMS: readonly ["trustpilot", "tripadvisor", "google", "yelp"];
302
312
  export declare const ReviewHistoryInputSchema: z.ZodObject<{
303
- action: z.ZodEnum<["get"]>;
313
+ action: z.ZodEnum<["get", "bulk_get", "bulk_cancel"]>;
304
314
  job_id: z.ZodOptional<z.ZodString>;
305
- platform: z.ZodOptional<z.ZodEnum<["trustpilot", "tripadvisor"]>>;
315
+ platform: z.ZodOptional<z.ZodEnum<["trustpilot", "tripadvisor", "google", "yelp"]>>;
306
316
  offset: z.ZodOptional<z.ZodNumber>;
307
317
  limit: z.ZodOptional<z.ZodNumber>;
308
318
  }, "strict", z.ZodTypeAny, {
309
- action: "get";
310
- platform?: "trustpilot" | "tripadvisor" | undefined;
319
+ action: "get" | "bulk_get" | "bulk_cancel";
320
+ platform?: "google" | "trustpilot" | "yelp" | "tripadvisor" | undefined;
311
321
  offset?: number | undefined;
312
322
  limit?: number | undefined;
313
323
  job_id?: string | undefined;
314
324
  }, {
315
- action: "get";
316
- platform?: "trustpilot" | "tripadvisor" | undefined;
325
+ action: "get" | "bulk_get" | "bulk_cancel";
326
+ platform?: "google" | "trustpilot" | "yelp" | "tripadvisor" | undefined;
317
327
  offset?: number | undefined;
318
328
  limit?: number | undefined;
319
329
  job_id?: string | undefined;
@@ -25,6 +25,8 @@ export const REVIEW_JOB_ID_RE = /^job_[0-9A-Za-z]{8,64}$/;
25
25
  export const RUN_ID_RE = /^run_[0-9A-Za-z]{8,64}$/;
26
26
  export const SCHEDULE_ID_RE = /^dsch_[0-9A-Za-z]{8,64}$/;
27
27
  export const WEBHOOK_ENDPOINT_ID_RE = /^we_[0-9A-Za-z]{8,64}$/;
28
+ /** Stored discover lists (`din_` + nanoid 21; db/schema/discover.ts). */
29
+ export const DISCOVER_INPUT_ID_RE = /^din_[0-9A-Za-z]{8,64}$/;
28
30
  /** events/feed.ts CONSUMER_RE. */
29
31
  export const CONSUMER_NAME_RE = /^[a-z0-9_-]{1,64}$/;
30
32
  /** A type (`discover.completed`), a namespace pattern (`discover.*`) or `*`. */
@@ -44,13 +46,16 @@ export const DISCOVER_ACTIONS = [
44
46
  "schedule_pause",
45
47
  "schedule_resume",
46
48
  "schedule_delete",
49
+ "input_list",
50
+ "input_append",
51
+ "input_delete",
47
52
  "follow",
48
53
  ];
49
54
  export const DiscoverInputSchema = z
50
55
  .object({
51
56
  action: z
52
57
  .enum(DISCOVER_ACTIONS)
53
- .describe("DISCOVER RUNS (started with socialcrawl_request on prism/discover): 'run_list', 'run_get' (status + a page of rows; wait_s long-polls), 'run_export' (every row as JSONL), 'run_legs' (the search log), 'run_cancel', 'run_resume', 'run_more'. DISCOVER SCHEDULES (created by prism/discover with a schedule field): 'schedule_list', 'schedule_get', 'schedule_pause', 'schedule_resume', 'schedule_delete'. 'follow' GETs a data.next.* URL a previous answer returned (free reads on the SocialCrawl API only)."),
58
+ .describe("DISCOVER RUNS (started with socialcrawl_request on prism/discover): 'run_list', 'run_get' (status + a page of rows; wait_s long-polls), 'run_export' (every row as JSONL), 'run_legs' (the search log), 'run_cancel', 'run_resume', 'run_more'. DISCOVER SCHEDULES (created by prism/discover with a schedule field): 'schedule_list', 'schedule_get', 'schedule_pause', 'schedule_resume', 'schedule_delete'. STORED LISTS (made with socialcrawl_request on POST prism/discover/inputs): 'input_list', 'input_append' (exclude entries), 'input_delete'. 'follow' GETs a data.next.* URL a previous answer returned (free reads on the SocialCrawl API only)."),
54
59
  run_id: z
55
60
  .string()
56
61
  .regex(RUN_ID_RE, "run_id is run_ followed by letters and digits (data.run.run_id)")
@@ -150,6 +155,18 @@ export const DiscoverInputSchema = z
150
155
  .max(4096)
151
156
  .optional()
152
157
  .describe("follow (required): a data.next.* URL from a previous answer (status_url, results_url, changes_url, poll_url, a self or attempts URL). It must be on the configured SocialCrawl API and a free read; continue_url (which bills) and POST URLs (resume_url, more_url, ack_url) are refused with the action to use instead."),
158
+ // ── stored inputs (inputs-routes.ts) ─────────────────────────────────
159
+ list_id: z
160
+ .string()
161
+ .regex(DISCOVER_INPUT_ID_RE, "list_id is din_ followed by letters and digits (data.exclude_list_id or data.author_list_id)")
162
+ .optional()
163
+ .describe("Stored list id (din_…). manage's `id` on input_append and input_delete."),
164
+ exclude: z
165
+ .array(z.string().min(1).max(200))
166
+ .min(1)
167
+ .max(50_000)
168
+ .optional()
169
+ .describe("input_append (required): 1 to 50,000 entries to add to an exclude list (duplicates skipped; a list holds at most 50,000)."),
153
170
  })
154
171
  .strict();
155
172
  /**
@@ -269,23 +286,25 @@ export const CreatorRunsInputSchema = z
269
286
  .describe("run_save: creator keys (<platform>:<id>) to save; omit to save every delivered creator."),
270
287
  })
271
288
  .strict();
272
- export const REVIEW_HISTORY_ACTIONS = ["get"];
289
+ export const REVIEW_HISTORY_ACTIONS = ["get", "bulk_get", "bulk_cancel"];
290
+ /** The platforms a review history job is started on, and the route each polls. */
291
+ export const REVIEW_HISTORY_PLATFORMS = ["trustpilot", "tripadvisor", "google", "yelp"];
273
292
  export const ReviewHistoryInputSchema = z
274
293
  .object({
275
294
  action: z
276
295
  .enum(REVIEW_HISTORY_ACTIONS)
277
- .describe("'get' polls a review history job (started with socialcrawl_request on POST trustpilot/reviews/history) and pages its reviews once it succeeded. Free."),
296
+ .describe("'get' polls a review history job (started with socialcrawl_request on POST trustpilot/reviews/history, google/business/reviews/history or yelp/business/reviews/history) and pages its reviews. 'bulk_get' reads a POST prism/reviews/bulk job (progress, per-item status, signed file links); 'bulk_cancel' stops one. Free."),
278
297
  job_id: z
279
298
  .string()
280
- .regex(REVIEW_JOB_ID_RE, "job_id is job_ followed by letters and digits (data.job_id of POST trustpilot/reviews/history)")
299
+ .regex(REVIEW_JOB_ID_RE, "job_id is job_ followed by letters and digits (data.job_id of the POST that started it)")
281
300
  .optional()
282
- .describe("The review history job id (job_…); manage's `id`."),
301
+ .describe("The job id (job_…); manage's `id`."),
283
302
  platform: z
284
- .enum(["trustpilot", "tripadvisor"])
303
+ .enum(REVIEW_HISTORY_PLATFORMS)
285
304
  .optional()
286
- .describe("The platform the job was started on: 'trustpilot' (default) or 'tripadvisor'."),
287
- offset: z.number().int().min(0).optional().describe("First review to return once the job succeeded (default 0)."),
288
- limit: z.number().int().min(1).max(100).optional().describe("Reviews per page, 1-100 (default 100)."),
305
+ .describe("get: the platform the job was started on: 'trustpilot' (default), 'tripadvisor', 'google' (Google Maps) or 'yelp'."),
306
+ offset: z.number().int().min(0).optional().describe("First review (get) or item (bulk_get) to return (default 0)."),
307
+ limit: z.number().int().min(1).max(100).optional().describe("Reviews (get) or items (bulk_get) per page, 1-100 (default 100)."),
289
308
  })
290
309
  .strict();
291
310
  export const EVENTS_ACTIONS = [
@@ -437,9 +437,9 @@ export declare const CollectOutputSchema: z.ZodObject<{
437
437
  result_id?: string | undefined;
438
438
  rows?: unknown[] | undefined;
439
439
  endpoint?: string | undefined;
440
+ total?: number | undefined;
440
441
  sample?: unknown[] | undefined;
441
442
  pages?: number | undefined;
442
- total?: number | undefined;
443
443
  credits?: {
444
444
  used?: number | undefined;
445
445
  remaining?: number | undefined;
@@ -473,9 +473,9 @@ export declare const CollectOutputSchema: z.ZodObject<{
473
473
  result_id?: string | undefined;
474
474
  rows?: unknown[] | undefined;
475
475
  endpoint?: string | undefined;
476
+ total?: number | undefined;
476
477
  sample?: unknown[] | undefined;
477
478
  pages?: number | undefined;
478
- total?: number | undefined;
479
479
  credits?: {
480
480
  used?: number | undefined;
481
481
  remaining?: number | undefined;
@@ -186,8 +186,9 @@ export declare const AccountInputSchema: z.ZodObject<{
186
186
  request_id: z.ZodOptional<z.ZodString>;
187
187
  from: z.ZodOptional<z.ZodString>;
188
188
  to: z.ZodOptional<z.ZodString>;
189
- group_by: z.ZodOptional<z.ZodEnum<["api_key", "day", "api_key,day"]>>;
189
+ group_by: z.ZodOptional<z.ZodString>;
190
190
  api_key_id: z.ZodOptional<z.ZodString>;
191
+ tag: z.ZodOptional<z.ZodString>;
191
192
  }, "strict", z.ZodTypeAny, {
192
193
  request_id?: string | undefined;
193
194
  cursor?: string | undefined;
@@ -197,8 +198,9 @@ export declare const AccountInputSchema: z.ZodObject<{
197
198
  kind?: string | undefined;
198
199
  from?: string | undefined;
199
200
  to?: string | undefined;
200
- group_by?: "api_key" | "day" | "api_key,day" | undefined;
201
+ group_by?: string | undefined;
201
202
  api_key_id?: string | undefined;
203
+ tag?: string | undefined;
202
204
  }, {
203
205
  request_id?: string | undefined;
204
206
  cursor?: string | undefined;
@@ -208,8 +210,9 @@ export declare const AccountInputSchema: z.ZodObject<{
208
210
  kind?: string | undefined;
209
211
  from?: string | undefined;
210
212
  to?: string | undefined;
211
- group_by?: "api_key" | "day" | "api_key,day" | undefined;
213
+ group_by?: string | undefined;
212
214
  api_key_id?: string | undefined;
215
+ tag?: string | undefined;
213
216
  }>;
214
217
  export declare const ManageInputSchema: z.ZodObject<{
215
218
  area: z.ZodEnum<["monitors", "cohorts", "web", "jobs", "discover", "review_history", "events", "search_runs", "creator_runs"]>;
@@ -250,7 +253,7 @@ export declare const CheckBalanceInputSchema: z.ZodObject<{
250
253
  requestId?: string | undefined;
251
254
  }>;
252
255
  export declare const MonitorsInputSchema: z.ZodObject<{
253
- action: z.ZodEnum<["create", "list", "get", "runs", "timeseries", "export", "pause", "resume", "delete"]>;
256
+ action: z.ZodEnum<["create", "list", "get", "runs", "timeseries", "export", "pause", "resume", "update", "delete"]>;
254
257
  id: z.ZodOptional<z.ZodString>;
255
258
  recipe: z.ZodOptional<z.ZodString>;
256
259
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -300,8 +303,11 @@ export declare const MonitorsInputSchema: z.ZodObject<{
300
303
  metric: z.ZodOptional<z.ZodString>;
301
304
  row: z.ZodOptional<z.ZodString>;
302
305
  format: z.ZodOptional<z.ZodEnum<["csv", "ndjson"]>>;
306
+ shape: z.ZodOptional<z.ZodEnum<["long", "rows"]>>;
307
+ max_credits_per_month: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
308
+ email_digest: z.ZodOptional<z.ZodEnum<["off", "daily"]>>;
303
309
  }, "strict", z.ZodTypeAny, {
304
- action: "create" | "list" | "get" | "runs" | "timeseries" | "export" | "pause" | "resume" | "delete";
310
+ action: "create" | "list" | "get" | "runs" | "timeseries" | "export" | "pause" | "resume" | "update" | "delete";
305
311
  params?: Record<string, unknown> | undefined;
306
312
  cursor?: string | undefined;
307
313
  status?: string | undefined;
@@ -333,8 +339,11 @@ export declare const MonitorsInputSchema: z.ZodObject<{
333
339
  webhook_rows?: "all" | "new" | undefined;
334
340
  include?: string | undefined;
335
341
  row?: string | undefined;
342
+ shape?: "rows" | "long" | undefined;
343
+ max_credits_per_month?: number | null | undefined;
344
+ email_digest?: "off" | "daily" | undefined;
336
345
  }, {
337
- action: "create" | "list" | "get" | "runs" | "timeseries" | "export" | "pause" | "resume" | "delete";
346
+ action: "create" | "list" | "get" | "runs" | "timeseries" | "export" | "pause" | "resume" | "update" | "delete";
338
347
  params?: Record<string, unknown> | undefined;
339
348
  cursor?: string | undefined;
340
349
  status?: string | undefined;
@@ -366,6 +375,9 @@ export declare const MonitorsInputSchema: z.ZodObject<{
366
375
  webhook_rows?: "all" | "new" | undefined;
367
376
  include?: string | undefined;
368
377
  row?: string | undefined;
378
+ shape?: "rows" | "long" | undefined;
379
+ max_credits_per_month?: number | null | undefined;
380
+ email_digest?: "off" | "daily" | undefined;
369
381
  }>;
370
382
  export declare const WebInputSchema: z.ZodObject<{
371
383
  action: z.ZodEnum<["scrape", "search", "map", "extract", "crawl", "batch_scrape", "agent", "job_list", "job_get", "job_cancel", "job_errors", "crawl_preview", "monitor_create", "monitor_list", "monitor_get", "monitor_update", "monitor_delete", "monitor_checks", "session_create", "session_list", "session_get", "session_execute", "session_close"]>;
@@ -137,15 +137,19 @@ export const AccountInputSchema = z.object({
137
137
  request_id: z.string().optional().describe("One request's receipts."),
138
138
  from: z.string().optional(),
139
139
  to: z.string().optional(),
140
- group_by: z.enum(["api_key", "day", "api_key,day"]).optional(),
140
+ group_by: z
141
+ .string()
142
+ .regex(/^(api_key|day|endpoint|tag)(,(api_key|day|endpoint|tag))*$/, "group_by is a comma list of api_key, day, endpoint, tag")
143
+ .optional(),
141
144
  api_key_id: z.string().optional(),
145
+ tag: z.string().optional().describe("transactions: receipts with this x-client-tag."),
142
146
  }).strict();
143
147
  export const ManageInputSchema = z.object({
144
148
  area: z.enum(["monitors", "cohorts", "web", "jobs", "discover", "review_history", "events", "search_runs", "creator_runs"]),
145
149
  action: z
146
150
  .string()
147
151
  .min(1)
148
- .describe("monitors: create|list|get|runs|timeseries|export|pause|resume|delete. cohorts: create|add_members|estimate_cost|query|query_*|get|delete. web: scrape|search|map|extract|crawl|batch_scrape|agent|crawl_preview|job_*|monitor_*|session_*. jobs: submit|list|get. run_* = list|get|export|legs|cancel|resume|more. discover: run_*|schedule_*|follow. search_runs: run_*|run_include|watch_*|follow. creator_runs: run_*|run_save|follow. review_history: get. events: feed|ack|endpoint_*."),
152
+ .describe("monitors: create|list|get|runs|timeseries|export|pause|resume|update|delete. cohorts: create|add_members|estimate_cost|query|query_*|get|delete. web: scrape|search|map|extract|crawl|batch_scrape|agent|crawl_preview|job_*|monitor_*|session_*. jobs: submit|list|get. run_* = list|get|export|legs|cancel|resume|more. discover: run_*|schedule_*|input_*|follow. search_runs: run_*|run_include|watch_*|follow. creator_runs: run_*|run_save|follow. review_history: get|bulk_get|bulk_cancel. events: feed|ack|endpoint_*."),
149
153
  id: z.string().optional().describe("Resource id (events: consumer name)."),
150
154
  input: z
151
155
  .record(z.unknown())
@@ -177,8 +181,8 @@ export const CheckBalanceInputSchema = z.object({
177
181
  }).strict();
178
182
  export const MonitorsInputSchema = z.object({
179
183
  action: z
180
- .enum(["create", "list", "get", "runs", "timeseries", "export", "pause", "resume", "delete"])
181
- .describe("Monitor operation: 'create' a scheduled monitor, 'list' your monitors, 'get' one, 'runs' for its run history, 'timeseries' for its metric series, 'export' its stored numbers as CSV or NDJSON, 'pause'/'resume' it, or 'delete' it."),
184
+ .enum(["create", "list", "get", "runs", "timeseries", "export", "pause", "resume", "update", "delete"])
185
+ .describe("Monitor operation: 'create' a scheduled monitor, 'list' your monitors, 'get' one, 'runs' for its run history, 'timeseries' for its metric series, 'export' its stored numbers as CSV or NDJSON, 'pause'/'resume' it, 'update' its monthly cap or email digest, or 'delete' it."),
182
186
  id: z
183
187
  .string()
184
188
  .regex(/^[A-Za-z0-9_-]{1,64}$/, "Monitor id must be 1-64 characters of letters, digits, '_' or '-'")
@@ -266,6 +270,22 @@ export const MonitorsInputSchema = z.object({
266
270
  .describe("timeseries: comma-separated metric keys to project (defaults to all stable computed keys)."),
267
271
  row: z.string().optional().describe("timeseries (track monitors): comma-separated row ids to keep in the per-row series."),
268
272
  format: z.enum(["csv", "ndjson"]).optional().describe("export: 'csv' (default) or 'ndjson'."),
273
+ shape: z
274
+ .enum(["long", "rows"])
275
+ .optional()
276
+ .describe("export: 'long' (default: one line per run, row and metric) or 'rows' (one line per run and row, a column per metric, run_at_utc as DD/MM/YYYY HH:mm)."),
277
+ max_credits_per_month: z
278
+ .number()
279
+ .int()
280
+ .min(1)
281
+ .max(10_000_000)
282
+ .nullable()
283
+ .optional()
284
+ .describe("create/update/pause/resume: the most the monitor may bill in a calendar month (UTC); the run that would pass it is skipped unbilled and the monitor pauses with paused_because monthly_cap until the 1st. null (update) removes it. Refused below one run's price and on recipes whose sources bill themselves."),
285
+ email_digest: z
286
+ .enum(["off", "daily"])
287
+ .optional()
288
+ .describe("create/update/pause/resume: 'daily' emails a digest of the runs and keeps the monitor running when its webhook fails; 'off' (default)."),
269
289
  }).strict();
270
290
  export const WebInputSchema = z.object({
271
291
  action: z