socialcrawl-mcp 2.3.0 → 2.6.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 (69) 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 +28 -3
  11. package/dist/cost-guard.js +69 -6
  12. package/dist/data/docs-async.d.ts +1 -1
  13. package/dist/data/docs-async.js +147 -137
  14. package/dist/data/docs-handwritten.js +968 -947
  15. package/dist/data/docs.js +5 -1
  16. package/dist/data/endpoints.js +2050 -941
  17. package/dist/data/examples.js +2 -2
  18. package/dist/data/guide.d.ts +2 -2
  19. package/dist/data/guide.js +2 -2
  20. package/dist/data/outputs.js +196 -159
  21. package/dist/data/platforms.js +13 -13
  22. package/dist/data/recipes.js +1 -1
  23. package/dist/data/registry-meta.d.ts +9 -9
  24. package/dist/data/registry-meta.js +9 -9
  25. package/dist/endpoint-resolve.d.ts +1 -0
  26. package/dist/endpoint-resolve.js +10 -1
  27. package/dist/endpoint-surface.d.ts +64 -0
  28. package/dist/endpoint-surface.js +478 -0
  29. package/dist/held-surfaces.d.ts +13 -2
  30. package/dist/held-surfaces.js +16 -3
  31. package/dist/hydration.js +7 -0
  32. package/dist/instructions.md +18 -18
  33. package/dist/listings.d.ts +24 -0
  34. package/dist/listings.js +55 -0
  35. package/dist/oauth/config.d.ts +20 -0
  36. package/dist/oauth/config.js +19 -0
  37. package/dist/oauth/resource-server.d.ts +12 -2
  38. package/dist/oauth/resource-server.js +5 -20
  39. package/dist/oauth/scopes.d.ts +2 -2
  40. package/dist/oauth/scopes.js +4 -4
  41. package/dist/param-aliases.d.ts +7 -0
  42. package/dist/param-aliases.js +15 -0
  43. package/dist/pricing.js +5 -1
  44. package/dist/resources/sample-gate.js +34 -1
  45. package/dist/resources/supplier-tokens.d.ts +1 -1
  46. package/dist/resources/supplier-tokens.js +2 -0
  47. package/dist/result.js +8 -0
  48. package/dist/schemas/async.d.ts +39 -12
  49. package/dist/schemas/async.js +40 -4
  50. package/dist/schemas/outputs.d.ts +2 -2
  51. package/dist/server.js +1 -1
  52. package/dist/timeouts.d.ts +24 -1
  53. package/dist/timeouts.js +32 -0
  54. package/dist/tools/async-common.d.ts +4 -2
  55. package/dist/tools/async-common.js +10 -2
  56. package/dist/tools/discover-runs.d.ts +6 -3
  57. package/dist/tools/discover-runs.js +126 -7
  58. package/dist/tools/discover.js +3 -0
  59. package/dist/tools/list-endpoints.js +5 -3
  60. package/dist/tools/manage.js +5 -4
  61. package/dist/tools/pricing.js +41 -10
  62. package/dist/tools/request.js +10 -2
  63. package/dist/tools/search-runs.js +27 -3
  64. package/dist/types.d.ts +9 -1
  65. package/dist/unit-meters.d.ts +32 -0
  66. package/dist/unit-meters.js +137 -0
  67. package/dist/value-prices.d.ts +38 -0
  68. package/dist/value-prices.js +168 -0
  69. package/package.json +3 -3
@@ -33,9 +33,9 @@ export declare const CONSUMER_NAME_RE: RegExp;
33
33
  export declare const EVENT_TYPE_PATTERN_RE: RegExp;
34
34
  /** A concrete event type (no pattern), as `endpoint_test` takes. */
35
35
  export declare const EVENT_TYPE_RE: RegExp;
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"];
36
+ export declare const DISCOVER_ACTIONS: readonly ["run_list", "run_get", "run_status", "run_export", "run_results_csv", "run_comments_csv", "run_legs", "run_cancel", "run_resume", "run_more", "run_comments", "schedule_list", "schedule_get", "schedule_pause", "schedule_resume", "schedule_delete", "input_list", "input_append", "input_delete", "follow"];
37
37
  export declare const DiscoverInputSchema: z.ZodObject<{
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"]>;
38
+ action: z.ZodEnum<["run_list", "run_get", "run_status", "run_export", "run_results_csv", "run_comments_csv", "run_legs", "run_cancel", "run_resume", "run_more", "run_comments", "schedule_list", "schedule_get", "schedule_pause", "schedule_resume", "schedule_delete", "input_list", "input_append", "input_delete", "follow"]>;
39
39
  run_id: z.ZodOptional<z.ZodString>;
40
40
  schedule_id: z.ZodOptional<z.ZodString>;
41
41
  cursor: z.ZodOptional<z.ZodString>;
@@ -55,8 +55,17 @@ export declare const DiscoverInputSchema: z.ZodObject<{
55
55
  state: z.ZodOptional<z.ZodEnum<["kept", "dropped", "all"]>>;
56
56
  include: z.ZodOptional<z.ZodLiteral<"dropped">>;
57
57
  tags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
58
+ format: z.ZodOptional<z.ZodEnum<["evidence", "compact", "text"]>>;
59
+ fields: z.ZodOptional<z.ZodString>;
60
+ summary: z.ZodOptional<z.ZodEnum<["full", "kept", "none"]>>;
61
+ summary_extra: z.ZodOptional<z.ZodString>;
58
62
  max_credits: z.ZodOptional<z.ZodNumber>;
59
63
  retry_failed: z.ZodOptional<z.ZodBoolean>;
64
+ attach_stored_only: z.ZodOptional<z.ZodBoolean>;
65
+ top_posts: z.ZodOptional<z.ZodNumber>;
66
+ per_post: z.ZodOptional<z.ZodNumber>;
67
+ platforms: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
68
+ labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
60
69
  new_searches: z.ZodOptional<z.ZodBoolean>;
61
70
  feedback: z.ZodOptional<z.ZodObject<{
62
71
  accept: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -75,32 +84,41 @@ export declare const DiscoverInputSchema: z.ZodObject<{
75
84
  list_id: z.ZodOptional<z.ZodString>;
76
85
  exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
77
86
  }, "strict", z.ZodTypeAny, {
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";
87
+ action: "follow" | "run_list" | "run_get" | "run_status" | "run_export" | "run_results_csv" | "run_comments_csv" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "run_comments" | "schedule_list" | "schedule_get" | "schedule_pause" | "schedule_resume" | "schedule_delete" | "input_list" | "input_append" | "input_delete";
88
+ summary?: "full" | "none" | "kept" | undefined;
79
89
  sort?: string | undefined;
80
90
  platform?: string | undefined;
81
91
  cursor?: string | undefined;
82
92
  status?: string | undefined;
93
+ fields?: string | undefined;
94
+ format?: "compact" | "text" | "evidence" | undefined;
83
95
  max_credits?: number | undefined;
84
96
  view?: "items" | "posts" | "accounts" | "communities" | undefined;
85
97
  kind?: "get" | "background" | "scheduled" | undefined;
86
98
  include?: "dropped" | undefined;
87
99
  max_credits_per_month?: number | null | undefined;
100
+ platforms?: string[] | undefined;
88
101
  url?: string | undefined;
89
102
  exclude?: string[] | undefined;
90
103
  keyword?: string | undefined;
104
+ pages?: number | undefined;
91
105
  tags?: Record<string, string> | undefined;
92
106
  order?: "rank" | "arrival" | undefined;
93
107
  group?: string | undefined;
108
+ per_post?: number | undefined;
94
109
  page_size?: number | undefined;
95
110
  state?: "all" | "kept" | "dropped" | undefined;
96
- pages?: number | undefined;
111
+ labels?: string[] | undefined;
97
112
  run_id?: string | undefined;
98
113
  schedule_id?: string | undefined;
99
114
  created_after?: string | undefined;
100
115
  wait_s?: number | undefined;
101
116
  include_pending?: boolean | undefined;
102
117
  changes_since?: number | undefined;
118
+ summary_extra?: string | undefined;
103
119
  retry_failed?: boolean | undefined;
120
+ attach_stored_only?: boolean | undefined;
121
+ top_posts?: number | undefined;
104
122
  new_searches?: boolean | undefined;
105
123
  feedback?: {
106
124
  accept?: string[] | undefined;
@@ -109,32 +127,41 @@ export declare const DiscoverInputSchema: z.ZodObject<{
109
127
  max_credits_per_run?: number | undefined;
110
128
  list_id?: string | undefined;
111
129
  }, {
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";
130
+ action: "follow" | "run_list" | "run_get" | "run_status" | "run_export" | "run_results_csv" | "run_comments_csv" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "run_comments" | "schedule_list" | "schedule_get" | "schedule_pause" | "schedule_resume" | "schedule_delete" | "input_list" | "input_append" | "input_delete";
131
+ summary?: "full" | "none" | "kept" | undefined;
113
132
  sort?: string | undefined;
114
133
  platform?: string | undefined;
115
134
  cursor?: string | undefined;
116
135
  status?: string | undefined;
136
+ fields?: string | undefined;
137
+ format?: "compact" | "text" | "evidence" | undefined;
117
138
  max_credits?: number | undefined;
118
139
  view?: "items" | "posts" | "accounts" | "communities" | undefined;
119
140
  kind?: "get" | "background" | "scheduled" | undefined;
120
141
  include?: "dropped" | undefined;
121
142
  max_credits_per_month?: number | null | undefined;
143
+ platforms?: string[] | undefined;
122
144
  url?: string | undefined;
123
145
  exclude?: string[] | undefined;
124
146
  keyword?: string | undefined;
147
+ pages?: number | undefined;
125
148
  tags?: Record<string, string> | undefined;
126
149
  order?: "rank" | "arrival" | undefined;
127
150
  group?: string | undefined;
151
+ per_post?: number | undefined;
128
152
  page_size?: number | undefined;
129
153
  state?: "all" | "kept" | "dropped" | undefined;
130
- pages?: number | undefined;
154
+ labels?: string[] | undefined;
131
155
  run_id?: string | undefined;
132
156
  schedule_id?: string | undefined;
133
157
  created_after?: string | undefined;
134
158
  wait_s?: number | undefined;
135
159
  include_pending?: boolean | undefined;
136
160
  changes_since?: number | undefined;
161
+ summary_extra?: string | undefined;
137
162
  retry_failed?: boolean | undefined;
163
+ attach_stored_only?: boolean | undefined;
164
+ top_posts?: number | undefined;
138
165
  new_searches?: boolean | undefined;
139
166
  feedback?: {
140
167
  accept?: string[] | undefined;
@@ -150,7 +177,7 @@ export declare const DiscoverInputSchema: z.ZodObject<{
150
177
  */
151
178
  export declare const WATCH_ID_RE: RegExp;
152
179
  export declare const SEARCH_RUN_ACTIONS: readonly ["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", "follow"];
153
- export declare const CREATOR_RUN_ACTIONS: readonly ["run_list", "run_get", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "run_save", "follow"];
180
+ export declare const CREATOR_RUN_ACTIONS: readonly ["run_list", "run_get", "run_status", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "run_save", "follow"];
154
181
  export declare const SearchRunsInputSchema: z.ZodObject<{
155
182
  sort: z.ZodOptional<z.ZodEnum<["relevance", "recent", "engagement"]>>;
156
183
  max_per_platform: z.ZodOptional<z.ZodNumber>;
@@ -255,10 +282,10 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
255
282
  max_credits: z.ZodOptional<z.ZodNumber>;
256
283
  retry_failed: z.ZodOptional<z.ZodBoolean>;
257
284
  url: z.ZodOptional<z.ZodString>;
258
- action: z.ZodEnum<["run_list", "run_get", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "run_save", "follow"]>;
285
+ action: z.ZodEnum<["run_list", "run_get", "run_status", "run_export", "run_legs", "run_cancel", "run_resume", "run_more", "run_save", "follow"]>;
259
286
  run_id: z.ZodOptional<z.ZodString>;
260
287
  }, "strict", z.ZodTypeAny, {
261
- action: "follow" | "run_list" | "run_get" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "run_save";
288
+ action: "follow" | "run_list" | "run_get" | "run_status" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "run_save";
262
289
  sort?: string | undefined;
263
290
  keys?: string[] | undefined;
264
291
  platform?: string | undefined;
@@ -269,12 +296,12 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
269
296
  max_credits?: number | undefined;
270
297
  url?: string | undefined;
271
298
  country?: string | undefined;
299
+ pages?: number | undefined;
272
300
  order?: "rank" | "arrival" | undefined;
273
301
  group?: string | undefined;
274
302
  account_kind?: string | undefined;
275
303
  page_size?: number | undefined;
276
304
  state?: "all" | "kept" | "dropped" | undefined;
277
- pages?: number | undefined;
278
305
  run_id?: string | undefined;
279
306
  created_after?: string | undefined;
280
307
  wait_s?: number | undefined;
@@ -282,7 +309,7 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
282
309
  retry_failed?: boolean | undefined;
283
310
  new_searches?: boolean | undefined;
284
311
  }, {
285
- action: "follow" | "run_list" | "run_get" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "run_save";
312
+ action: "follow" | "run_list" | "run_get" | "run_status" | "run_export" | "run_legs" | "run_cancel" | "run_resume" | "run_more" | "run_save";
286
313
  sort?: string | undefined;
287
314
  keys?: string[] | undefined;
288
315
  platform?: string | undefined;
@@ -293,12 +320,12 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
293
320
  max_credits?: number | undefined;
294
321
  url?: string | undefined;
295
322
  country?: string | undefined;
323
+ pages?: number | undefined;
296
324
  order?: "rank" | "arrival" | undefined;
297
325
  group?: string | undefined;
298
326
  account_kind?: string | undefined;
299
327
  page_size?: number | undefined;
300
328
  state?: "all" | "kept" | "dropped" | undefined;
301
- pages?: number | undefined;
302
329
  run_id?: string | undefined;
303
330
  created_after?: string | undefined;
304
331
  wait_s?: number | undefined;
@@ -36,11 +36,15 @@ export const EVENT_TYPE_RE = /^[a-z0-9_]+(\.[a-z0-9_]+)+$/;
36
36
  export const DISCOVER_ACTIONS = [
37
37
  "run_list",
38
38
  "run_get",
39
+ "run_status",
39
40
  "run_export",
41
+ "run_results_csv",
42
+ "run_comments_csv",
40
43
  "run_legs",
41
44
  "run_cancel",
42
45
  "run_resume",
43
46
  "run_more",
47
+ "run_comments",
44
48
  "schedule_list",
45
49
  "schedule_get",
46
50
  "schedule_pause",
@@ -55,7 +59,7 @@ export const DiscoverInputSchema = z
55
59
  .object({
56
60
  action: z
57
61
  .enum(DISCOVER_ACTIONS)
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)."),
62
+ .describe("DISCOVER RUNS (started with socialcrawl_request on prism/discover): 'run_list', 'run_get' (status + a page of rows; wait_s long-polls), 'run_status' (status only, about 2 KB: the read to poll), 'run_export' (every row as JSONL), 'run_results_csv' / 'run_comments_csv' (the kept rows or their comments as CSV), 'run_legs' (the search log), 'run_cancel', 'run_resume', 'run_more', 'run_comments' (a comments pass over a finished posts run; bills; dry_run quotes it). 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)."),
59
63
  run_id: z
60
64
  .string()
61
65
  .regex(RUN_ID_RE, "run_id is run_ followed by letters and digits (data.run.run_id)")
@@ -95,7 +99,7 @@ export const DiscoverInputSchema = z
95
99
  .min(0)
96
100
  .max(25)
97
101
  .optional()
98
- .describe("run_get: long-poll up to this many seconds; answers early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key at once (a 6th answers immediately). Free."),
102
+ .describe("run_get / run_status: long-poll up to this many seconds; answers early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key at once (a 6th answers immediately). Free."),
99
103
  view: z.enum(["posts", "accounts", "communities", "items"]).optional().describe("run_get/run_export: a view the run computed."),
100
104
  order: z
101
105
  .enum(["arrival", "rank"])
@@ -121,6 +125,20 @@ export const DiscoverInputSchema = z
121
125
  .record(z.string())
122
126
  .optional()
123
127
  .describe("run_get/run_export: group tags, sent as tag.<key>=<value> (e.g. { region: 'eu' })."),
128
+ format: z
129
+ .enum(["evidence", "compact", "text"])
130
+ .optional()
131
+ .describe("run_get/run_export: the row shape for this read, overriding the run's own: evidence (default), compact (about 80 to 130 tokens a row) or text."),
132
+ fields: z.string().max(2000).optional().describe("run_get/run_export: comma list of row paths to keep, overriding the run's own."),
133
+ summary: z
134
+ .enum(["full", "kept", "none"])
135
+ .optional()
136
+ .describe("run_get: how much of data.summary comes back: full (default), kept (the kept rows' counts only) or none."),
137
+ summary_extra: z
138
+ .string()
139
+ .regex(/^(by_week|top_terms)(,(by_week|top_terms))*$/, "summary_extra is by_week and/or top_terms, comma-separated")
140
+ .optional()
141
+ .describe("run_get: by_week (kept rows per week with the stance split and mean sentiment) and/or top_terms (top hashtags and words per group), comma-separated."),
124
142
  // ── run_resume / run_more ────────────────────────────────────────────
125
143
  max_credits: z
126
144
  .number()
@@ -128,8 +146,25 @@ export const DiscoverInputSchema = z
128
146
  .min(1)
129
147
  .max(10_000_000)
130
148
  .optional()
131
- .describe("run_resume: the run's new cap (required to resume a run paused at its cap; it must be higher). run_more: the run's cap from now on, counting what it already spent."),
149
+ .describe("run_resume: the run's new cap (required to resume a run paused at its cap; it must be higher). run_more: the run's cap from now on, counting what it already spent. run_comments: the most this pass may spend (default the quote's max)."),
132
150
  retry_failed: z.boolean().optional().describe("run_resume: true fetches the failed and skipped searches again."),
151
+ attach_stored_only: z
152
+ .boolean()
153
+ .optional()
154
+ .describe("run_resume: true only attaches comment pages the run stored but no row shows (data.attached); bills nothing, keeps the status, and takes no max_credits or retry_failed."),
155
+ top_posts: z.number().int().min(1).max(50).optional().describe("run_comments: posts read per group, 1-50 (default the run's own, else 3)."),
156
+ per_post: z.number().int().min(1).max(200).optional().describe("run_comments: comments read per post, 1-200 (default the run's own, else 20)."),
157
+ platforms: z
158
+ .array(z.string().min(1).max(64))
159
+ .min(1)
160
+ .max(50)
161
+ .optional()
162
+ .describe("run_comments: only these of the platforms the run searched (default all of them that have comments)."),
163
+ labels: z
164
+ .array(z.string().min(1).max(64))
165
+ .max(10)
166
+ .optional()
167
+ .describe("run_comments: up to 10 comment labels (sentiment, spam, question, purchase_intent, complaint, toxic, low_quality, ...)."),
133
168
  new_searches: z.boolean().optional().describe("run_more: true plans new searches over the run's keywords, steered by feedback."),
134
169
  feedback: z
135
170
  .object({
@@ -194,6 +229,7 @@ export const SEARCH_RUN_ACTIONS = [
194
229
  export const CREATOR_RUN_ACTIONS = [
195
230
  "run_list",
196
231
  "run_get",
232
+ "run_status",
197
233
  "run_export",
198
234
  "run_legs",
199
235
  "run_cancel",
@@ -269,7 +305,7 @@ export const CreatorRunsInputSchema = z
269
305
  .object({
270
306
  action: z
271
307
  .enum(CREATOR_RUN_ACTIONS)
272
- .describe("CREATOR SEARCH RUNS (started by prism/creators via socialcrawl_request): 'run_list', 'run_get' (creators + status; wait_s long-polls), 'run_export' (JSONL), 'run_legs', 'run_cancel', 'run_resume', 'run_more', 'run_save' (stores the creators as author lists, free, and returns data.next.follow — a POST prism/discover schedule body that watches them for new posts). 'follow' GETs a data.next.* read URL."),
308
+ .describe("CREATOR SEARCH RUNS (started by prism/creators via socialcrawl_request): 'run_list', 'run_get' (creators + status; wait_s long-polls), 'run_status' (status only: the read to poll), 'run_export' (JSONL), 'run_legs', 'run_cancel', 'run_resume', 'run_more', 'run_save' (stores the creators as author lists, free, and returns data.next.follow — a POST prism/discover schedule body that watches them for new posts). 'follow' GETs a data.next.* read URL."),
273
309
  run_id: runIdField,
274
310
  ...runReadFields,
275
311
  sort: z.string().max(64).optional().describe("run_get/run_export: any sort the creator search accepts."),
@@ -438,8 +438,8 @@ export declare const CollectOutputSchema: z.ZodObject<{
438
438
  rows?: unknown[] | undefined;
439
439
  endpoint?: string | undefined;
440
440
  total?: number | undefined;
441
- sample?: unknown[] | undefined;
442
441
  pages?: number | undefined;
442
+ sample?: unknown[] | undefined;
443
443
  credits?: {
444
444
  used?: number | undefined;
445
445
  remaining?: number | undefined;
@@ -474,8 +474,8 @@ export declare const CollectOutputSchema: z.ZodObject<{
474
474
  rows?: unknown[] | undefined;
475
475
  endpoint?: string | undefined;
476
476
  total?: number | undefined;
477
- sample?: unknown[] | undefined;
478
477
  pages?: number | undefined;
478
+ sample?: unknown[] | undefined;
479
479
  credits?: {
480
480
  used?: number | undefined;
481
481
  remaining?: number | undefined;
package/dist/server.js CHANGED
@@ -183,7 +183,7 @@ export function createServer(baseCtx, options = {}) {
183
183
  });
184
184
  server.registerTool("socialcrawl_manage", {
185
185
  title: "Manage Stateful and Background Work",
186
- description: "By area + action: monitors, cohorts, web (scrape, crawl, agents, page monitors, sessions), jobs, discover, search_runs (search lists, watches), creator_runs, review_history, events (feed, webhooks). Wrong fields refused free. Managing is free; scrapes, jobs, queries, run_more/include, monitor runs bill.\ndry_run: true quotes, creating nothing. rows_new alerts need track. Docs: discover-runs, search-runs.",
186
+ description: "By area + action: monitors, cohorts, web (scrape, crawl, agents, page monitors, sessions), jobs, discover, search_runs (search lists, watches), creator_runs, review_history, events (feed, webhooks). Wrong fields refused free. Managing is free; scrapes, jobs, queries, run_more/include/comments, monitor runs bill.\ndry_run: true quotes, creating nothing. rows_new alerts need track. Docs: discover-runs, search-runs.",
187
187
  inputSchema: withNormalizedArgs(ManageInputSchema, "manage"),
188
188
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
189
189
  }, async (params) => {
@@ -8,20 +8,43 @@ import type { Endpoint } from "./types.js";
8
8
  */
9
9
  export declare const DEFAULT_TIMEOUT_S = 60;
10
10
  export declare const MAX_TIMEOUT_S = 120;
11
- type TimeoutFields = Pick<Endpoint, "recommended_timeout_s" | "budget_ms" | "streaming" | "execution">;
11
+ /**
12
+ * Most a call on a route with its own budget may wait. The longest own routes
13
+ * (transcripts of long videos) run 270 s on a 300 s function.
14
+ */
15
+ export declare const MAX_ROUTE_TIMEOUT_S = 290;
16
+ type TimeoutFields = Pick<Endpoint, "recommended_timeout_s" | "budget_ms" | "streaming" | "execution"> & Partial<Pick<Endpoint, "route_budget_ms">>;
12
17
  /**
13
18
  * Client timeout for one endpoint, in seconds, read from the registry data in
14
19
  * priority order: `recommended_timeout_s` plus a margin, then `budget_ms` plus a
15
20
  * margin, then the execution-mode default (a streaming endpoint with no
16
21
  * measured latency may run for minutes). Never below the 60s floor the API
17
22
  * recommends (a measured p99 is not a deadline), never above 120.
23
+ *
24
+ * A route with its own budget (`route_budget_ms`: transcripts, review
25
+ * histories, discover and the universal search run 70 to 270 s on their own
26
+ * function) is waited for past that budget, up to MAX_ROUTE_TIMEOUT_S: a client
27
+ * that gives up first still pays for the answer, because the server call runs,
28
+ * bills and caches.
18
29
  */
19
30
  export declare function timeoutSecondsFor(endpoint: TimeoutFields | undefined): number;
31
+ /** The streaming mode of an endpoint that streams unless the request asks for JSON (prism/answers, API-238). */
32
+ export declare const SSE_DEFAULT = "sse-default";
20
33
  /**
21
34
  * Whether this call is answered as an SSE stream, so the client should ask for
22
35
  * one. `always` streams unconditionally; `"<param>=<value>"` streams when that
23
36
  * param's CSV carries the value. `accept-header` endpoints stay on JSON: the
24
37
  * assembled result is the same and the JSON path supports idempotent replay.
38
+ * `sse-default` endpoints are called for JSON the same way (see
39
+ * `wantsJsonEnvelope`) unless the caller sends `stream=true`.
25
40
  */
26
41
  export declare function wantsStream(endpoint: Pick<Endpoint, "streaming"> | undefined, params: Record<string, unknown>): boolean;
42
+ /**
43
+ * Whether the request must ask for one JSON envelope (`Accept:
44
+ * application/json`): an `sse-default` endpoint answers a plain request, or one
45
+ * that accepts anything, with a stream (the API's `requestsJsonEnvelope`). The
46
+ * JSON answer is cached and honours `Idempotency-Key`, so a retry cannot bill
47
+ * twice.
48
+ */
49
+ export declare function wantsJsonEnvelope(endpoint: Pick<Endpoint, "streaming"> | undefined, params: Record<string, unknown>): boolean;
27
50
  export {};
package/dist/timeouts.js CHANGED
@@ -7,6 +7,11 @@
7
7
  */
8
8
  export const DEFAULT_TIMEOUT_S = 60;
9
9
  export const MAX_TIMEOUT_S = 120;
10
+ /**
11
+ * Most a call on a route with its own budget may wait. The longest own routes
12
+ * (transcripts of long videos) run 270 s on a 300 s function.
13
+ */
14
+ export const MAX_ROUTE_TIMEOUT_S = 290;
10
15
  /** Headroom added to a server-side latency budget so the client does not give up first. */
11
16
  const BUDGET_MARGIN_S = 5;
12
17
  const positive = (n) => typeof n === "number" && Number.isFinite(n) && n > 0;
@@ -16,8 +21,18 @@ const positive = (n) => typeof n === "number" && Number.isFinite(n) && n > 0;
16
21
  * margin, then the execution-mode default (a streaming endpoint with no
17
22
  * measured latency may run for minutes). Never below the 60s floor the API
18
23
  * recommends (a measured p99 is not a deadline), never above 120.
24
+ *
25
+ * A route with its own budget (`route_budget_ms`: transcripts, review
26
+ * histories, discover and the universal search run 70 to 270 s on their own
27
+ * function) is waited for past that budget, up to MAX_ROUTE_TIMEOUT_S: a client
28
+ * that gives up first still pays for the answer, because the server call runs,
29
+ * bills and caches.
19
30
  */
20
31
  export function timeoutSecondsFor(endpoint) {
32
+ if (endpoint && positive(endpoint.route_budget_ms)) {
33
+ const own = Math.ceil(endpoint.route_budget_ms / 1000) + BUDGET_MARGIN_S;
34
+ return Math.min(MAX_ROUTE_TIMEOUT_S, Math.max(DEFAULT_TIMEOUT_S, own));
35
+ }
21
36
  let s = DEFAULT_TIMEOUT_S;
22
37
  if (endpoint) {
23
38
  if (positive(endpoint.recommended_timeout_s))
@@ -29,11 +44,16 @@ export function timeoutSecondsFor(endpoint) {
29
44
  }
30
45
  return Math.min(MAX_TIMEOUT_S, Math.max(DEFAULT_TIMEOUT_S, s));
31
46
  }
47
+ /** The streaming mode of an endpoint that streams unless the request asks for JSON (prism/answers, API-238). */
48
+ export const SSE_DEFAULT = "sse-default";
49
+ const isTrue = (v) => v === true || (typeof v === "string" && ["true", "1"].includes(v.trim().toLowerCase()));
32
50
  /**
33
51
  * Whether this call is answered as an SSE stream, so the client should ask for
34
52
  * one. `always` streams unconditionally; `"<param>=<value>"` streams when that
35
53
  * param's CSV carries the value. `accept-header` endpoints stay on JSON: the
36
54
  * assembled result is the same and the JSON path supports idempotent replay.
55
+ * `sse-default` endpoints are called for JSON the same way (see
56
+ * `wantsJsonEnvelope`) unless the caller sends `stream=true`.
37
57
  */
38
58
  export function wantsStream(endpoint, params) {
39
59
  const mode = endpoint?.streaming;
@@ -41,6 +61,8 @@ export function wantsStream(endpoint, params) {
41
61
  return false;
42
62
  if (mode === "always")
43
63
  return true;
64
+ if (mode === SSE_DEFAULT)
65
+ return isTrue(params.stream);
44
66
  const eq = mode.indexOf("=");
45
67
  if (eq < 0)
46
68
  return false;
@@ -50,4 +72,14 @@ export function wantsStream(endpoint, params) {
50
72
  const want = mode.slice(eq + 1);
51
73
  return value.split(",").some((m) => m.trim() === want);
52
74
  }
75
+ /**
76
+ * Whether the request must ask for one JSON envelope (`Accept:
77
+ * application/json`): an `sse-default` endpoint answers a plain request, or one
78
+ * that accepts anything, with a stream (the API's `requestsJsonEnvelope`). The
79
+ * JSON answer is cached and honours `Idempotency-Key`, so a retry cannot bill
80
+ * twice.
81
+ */
82
+ export function wantsJsonEnvelope(endpoint, params) {
83
+ return endpoint?.streaming === SSE_DEFAULT && !wantsStream(endpoint, params);
84
+ }
53
85
  //# sourceMappingURL=timeouts.js.map
@@ -25,14 +25,16 @@ export interface RenderInput {
25
25
  idempotencyNote?: string;
26
26
  notes?: string[];
27
27
  response: string;
28
- /** "jsonl" renders a non-JSON body in a jsonl fence. */
29
- format?: "json" | "jsonl";
28
+ /** "jsonl" / "csv" render a non-JSON body in a jsonl / csv fence. */
29
+ format?: "json" | "jsonl" | "csv";
30
30
  /** Extra guidance appended to an error, keyed by a substring of it. */
31
31
  errorHints?: Record<string, string>;
32
32
  /** Built from the parsed success body. */
33
33
  successNotes?: (parsed: Record<string, unknown>) => string[];
34
34
  }
35
35
  export declare function render(input: RenderInput): string;
36
+ /** How a followed read renders: an export by its extension, anything else as JSON. */
37
+ export declare function followFormat(path: string): "json" | "jsonl" | "csv";
36
38
  /** `data` of a success envelope, or the body itself. */
37
39
  export declare function dataOf(parsed: Record<string, unknown>): Record<string, unknown>;
38
40
  /** What to do on a 410 from the events feed. */
@@ -58,10 +58,15 @@ export function render(input) {
58
58
  return `${[...lines, ...extra].join("\n")}\n\n\`\`\`json\n${JSON.stringify(parsed)}\n\`\`\``;
59
59
  }
60
60
  catch {
61
- const fence = input.format === "jsonl" ? "jsonl" : "";
61
+ const fence = input.format === "jsonl" || input.format === "csv" ? input.format : "";
62
62
  return `${lines.join("\n")}\n\n\`\`\`${fence}\n${response.replace(/\n+$/, "")}\n\`\`\``;
63
63
  }
64
64
  }
65
+ /** How a followed read renders: an export by its extension, anything else as JSON. */
66
+ export function followFormat(path) {
67
+ const bare = path.split("?")[0];
68
+ return bare.endsWith(".jsonl") ? "jsonl" : bare.endsWith(".csv") ? "csv" : "json";
69
+ }
65
70
  /** `data` of a success envelope, or the body itself. */
66
71
  export function dataOf(parsed) {
67
72
  const data = parsed.data;
@@ -76,12 +81,14 @@ const FOLLOWABLE = [
76
81
  /^\/v1\/prism\/jobs$/,
77
82
  new RegExp(`^/v1/prism/jobs/bj_${ID}$`),
78
83
  /^\/v1\/prism\/discover\/runs$/,
79
- new RegExp(`^/v1/prism/discover/runs/run_${ID}(/legs|/results\\.jsonl)?$`),
84
+ // API-455, API-460: the light status read and the CSV exports.
85
+ new RegExp(`^/v1/prism/discover/runs/run_${ID}(/legs|/results\\.jsonl|/status|/results\\.csv|/comments\\.csv)?$`),
80
86
  /^\/v1\/prism\/discover\/schedules$/,
81
87
  new RegExp(`^/v1/prism/discover/schedules/dsch_${ID}$`),
82
88
  // Universal search runs and watches; creator search runs (outside the registry).
83
89
  /^\/v1\/(search\/everywhere|prism\/creators)\/runs$/,
84
90
  new RegExp(`^/v1/(search/everywhere|prism/creators)/runs/run_${ID}(/legs|/results\\.jsonl)?$`),
91
+ new RegExp(`^/v1/prism/creators/runs/run_${ID}(/status|/results\\.csv|/comments\\.csv)$`),
85
92
  /^\/v1\/search\/everywhere\/watches$/,
86
93
  /^\/v1\/search\/everywhere\/watches\/[A-Za-z0-9_-]{1,80}$/,
87
94
  new RegExp(`^/v1/(trustpilot|tripadvisor|google/business|yelp/business)/reviews/history/job_${ID}$`),
@@ -99,6 +106,7 @@ const REFUSED = [
99
106
  ],
100
107
  [/^\/v1\/prism\/discover\/runs\/[^/]+\/resume$/, 'This is a resume_url (a POST). Use area "discover" action "run_resume" with the run id.'],
101
108
  [/^\/v1\/prism\/discover\/runs\/[^/]+\/more$/, 'This is a more_url (a POST that bills new searches). Use area "discover" action "run_more" with the run id.'],
109
+ [/^\/v1\/prism\/discover\/runs\/[^/]+\/comments$/, 'This is a comments pass (a POST that bills comment pages). Use area "discover" action "run_comments" with the run id (dry_run quotes it).'],
102
110
  [/^\/v1\/search\/everywhere\/runs\/[^/]+\/more$/, 'This is a more_url (a POST that bills 20 credits per search). Use area "search_runs" action "run_more" with the run id (dry_run quotes it).'],
103
111
  [/^\/v1\/search\/everywhere\/runs\/[^/]+\/include$/, 'This is an include_url (a POST that bills per read). Use area "search_runs" action "run_include" with the run id (dry_run quotes it).'],
104
112
  [/^\/v1\/search\/everywhere\/runs\/[^/]+\/resume$/, 'This is a resume_url (a POST). Use area "search_runs" action "run_resume" with the run id.'],
@@ -17,10 +17,13 @@ import type { DiscoverInput, ReviewHistoryInput } from "../schemas/async.js";
17
17
  * on a free read route of the configured SocialCrawl API only — never a
18
18
  * billable `continue_url`, a POST, or another host.
19
19
  *
20
- * None of these routes honours `dry_run` (resume/more refuse any query
21
- * parameter), so the area takes no dry run.
20
+ * Only the comments pass (`run_comments`, `POST …/runs/{run_id}/comments`)
21
+ * takes a dry run, as `dry_run: true` in its body (a free quote); no other
22
+ * run or schedule route reads one (resume/more refuse any query parameter).
22
23
  */
23
- export type DiscoverParams = DiscoverInput;
24
+ export type DiscoverParams = DiscoverInput & {
25
+ dryRun?: boolean;
26
+ };
24
27
  export type ReviewHistoryParams = ReviewHistoryInput;
25
28
  export declare function discoverRuns(ctx: ApiContext, input: DiscoverParams): Promise<string>;
26
29
  export declare function reviewHistory(ctx: ApiContext, input: ReviewHistoryParams): Promise<string>;