socialcrawl-mcp 2.2.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.
- package/README.md +49 -21
- package/dist/app.d.ts +3 -3
- package/dist/app.js +75 -12
- package/dist/chatgpt-text.d.ts +23 -0
- package/dist/chatgpt-text.js +310 -0
- package/dist/client-tag.d.ts +13 -0
- package/dist/client-tag.js +17 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +14 -4
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/context.d.ts +13 -0
- package/dist/context.js +1 -0
- package/dist/cost-guard.d.ts +15 -3
- package/dist/cost-guard.js +39 -3
- package/dist/data/docs-async.d.ts +2 -2
- package/dist/data/docs-async.js +24 -3
- package/dist/data/docs-handwritten.js +968 -906
- package/dist/data/docs.js +7 -1
- package/dist/data/endpoints.js +11153 -7559
- package/dist/data/examples.js +2 -2
- package/dist/data/guide.d.ts +2 -2
- package/dist/data/guide.js +2 -2
- package/dist/data/outputs.js +425 -290
- package/dist/data/platforms.js +214 -55
- package/dist/data/recipes.js +1 -1
- package/dist/data/registry-meta.d.ts +10 -10
- package/dist/data/registry-meta.js +10 -10
- package/dist/endpoint-resolve.d.ts +1 -0
- package/dist/endpoint-resolve.js +10 -1
- package/dist/endpoint-surface.d.ts +64 -0
- package/dist/endpoint-surface.js +472 -0
- package/dist/hydration.js +28 -3
- package/dist/instructions.md +18 -18
- package/dist/listings.d.ts +24 -0
- package/dist/listings.js +55 -0
- package/dist/oauth/config.d.ts +39 -4
- package/dist/oauth/config.js +50 -6
- package/dist/oauth/resource-server.d.ts +12 -2
- package/dist/oauth/resource-server.js +5 -20
- package/dist/oauth/scopes.d.ts +2 -2
- package/dist/oauth/scopes.js +4 -4
- package/dist/param-aliases.d.ts +7 -0
- package/dist/param-aliases.js +15 -0
- package/dist/pricing.js +5 -1
- package/dist/resources/sample-gate.js +34 -1
- package/dist/resources/supplier-tokens.d.ts +1 -1
- package/dist/resources/supplier-tokens.js +2 -0
- package/dist/result.js +8 -0
- package/dist/schemas/async.d.ts +41 -31
- package/dist/schemas/async.js +28 -9
- package/dist/schemas/outputs.d.ts +4 -4
- package/dist/schemas/tools.d.ts +18 -6
- package/dist/schemas/tools.js +24 -4
- package/dist/server.js +6 -5
- package/dist/timeouts.d.ts +24 -1
- package/dist/timeouts.js +32 -0
- package/dist/tools/account.d.ts +4 -1
- package/dist/tools/account.js +1 -1
- package/dist/tools/async-common.js +3 -1
- package/dist/tools/check-balance.d.ts +4 -2
- package/dist/tools/check-balance.js +9 -0
- package/dist/tools/discover-runs.js +117 -11
- package/dist/tools/discover.js +3 -0
- package/dist/tools/estimate.js +10 -1
- package/dist/tools/list-endpoints.js +5 -3
- package/dist/tools/manage.js +2 -0
- package/dist/tools/monitors.d.ts +7 -1
- package/dist/tools/monitors.js +26 -2
- package/dist/tools/pricing.js +11 -1
- package/dist/tools/request.js +10 -2
- package/dist/types.d.ts +9 -1
- package/dist/value-prices.d.ts +18 -0
- package/dist/value-prices.js +79 -0
- package/package.json +75 -75
package/dist/schemas/async.d.ts
CHANGED
|
@@ -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,14 +84,16 @@ 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;
|
|
91
|
+
pages?: number | undefined;
|
|
85
92
|
tags?: Record<string, string> | undefined;
|
|
86
93
|
order?: "rank" | "arrival" | undefined;
|
|
87
94
|
group?: string | undefined;
|
|
88
|
-
state?: "all" | "kept" | "dropped" | undefined;
|
|
89
95
|
page_size?: number | undefined;
|
|
90
|
-
|
|
96
|
+
state?: "all" | "kept" | "dropped" | undefined;
|
|
91
97
|
run_id?: string | undefined;
|
|
92
98
|
schedule_id?: string | undefined;
|
|
93
99
|
created_after?: 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
|
-
|
|
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,14 +118,16 @@ 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;
|
|
125
|
+
pages?: number | undefined;
|
|
117
126
|
tags?: Record<string, string> | undefined;
|
|
118
127
|
order?: "rank" | "arrival" | undefined;
|
|
119
128
|
group?: string | undefined;
|
|
120
|
-
state?: "all" | "kept" | "dropped" | undefined;
|
|
121
129
|
page_size?: number | undefined;
|
|
122
|
-
|
|
130
|
+
state?: "all" | "kept" | "dropped" | undefined;
|
|
123
131
|
run_id?: string | undefined;
|
|
124
132
|
schedule_id?: string | undefined;
|
|
125
133
|
created_after?: 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
|
-
|
|
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<{
|
|
@@ -261,12 +269,12 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
|
|
|
261
269
|
max_credits?: number | undefined;
|
|
262
270
|
url?: string | undefined;
|
|
263
271
|
country?: string | undefined;
|
|
272
|
+
pages?: number | undefined;
|
|
264
273
|
order?: "rank" | "arrival" | undefined;
|
|
265
274
|
group?: string | undefined;
|
|
266
|
-
state?: "all" | "kept" | "dropped" | undefined;
|
|
267
|
-
page_size?: number | undefined;
|
|
268
275
|
account_kind?: string | undefined;
|
|
269
|
-
|
|
276
|
+
page_size?: number | undefined;
|
|
277
|
+
state?: "all" | "kept" | "dropped" | undefined;
|
|
270
278
|
run_id?: string | undefined;
|
|
271
279
|
created_after?: string | undefined;
|
|
272
280
|
wait_s?: number | undefined;
|
|
@@ -285,12 +293,12 @@ export declare const CreatorRunsInputSchema: z.ZodObject<{
|
|
|
285
293
|
max_credits?: number | undefined;
|
|
286
294
|
url?: string | undefined;
|
|
287
295
|
country?: string | undefined;
|
|
296
|
+
pages?: number | undefined;
|
|
288
297
|
order?: "rank" | "arrival" | undefined;
|
|
289
298
|
group?: string | undefined;
|
|
290
|
-
state?: "all" | "kept" | "dropped" | undefined;
|
|
291
|
-
page_size?: number | undefined;
|
|
292
299
|
account_kind?: string | undefined;
|
|
293
|
-
|
|
300
|
+
page_size?: number | undefined;
|
|
301
|
+
state?: "all" | "kept" | "dropped" | undefined;
|
|
294
302
|
run_id?: string | undefined;
|
|
295
303
|
created_after?: string | undefined;
|
|
296
304
|
wait_s?: number | 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;
|
package/dist/schemas/async.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
301
|
+
.describe("The job id (job_…); manage's `id`."),
|
|
283
302
|
platform: z
|
|
284
|
-
.enum(
|
|
303
|
+
.enum(REVIEW_HISTORY_PLATFORMS)
|
|
285
304
|
.optional()
|
|
286
|
-
.describe("
|
|
287
|
-
offset: z.number().int().min(0).optional().describe("First review
|
|
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
|
-
sample?: unknown[] | undefined;
|
|
441
|
-
pages?: number | undefined;
|
|
442
440
|
total?: number | undefined;
|
|
441
|
+
pages?: number | undefined;
|
|
442
|
+
sample?: unknown[] | 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
|
-
sample?: unknown[] | undefined;
|
|
477
|
-
pages?: number | undefined;
|
|
478
476
|
total?: number | undefined;
|
|
477
|
+
pages?: number | undefined;
|
|
478
|
+
sample?: unknown[] | undefined;
|
|
479
479
|
credits?: {
|
|
480
480
|
used?: number | undefined;
|
|
481
481
|
remaining?: number | undefined;
|
package/dist/schemas/tools.d.ts
CHANGED
|
@@ -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.
|
|
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?:
|
|
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?:
|
|
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"]>;
|
package/dist/schemas/tools.js
CHANGED
|
@@ -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
|
|
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
|
package/dist/server.js
CHANGED
|
@@ -66,7 +66,7 @@ export function createServer(baseCtx, options = {}) {
|
|
|
66
66
|
server.registerTool = (name, config, cb) => registerTool(name, config, async (...args) => withFreshness((await cb(...args))));
|
|
67
67
|
server.registerTool("socialcrawl_find", {
|
|
68
68
|
title: "Find the Endpoint for a Task",
|
|
69
|
-
description: `Start here: a task in plain words -> the best endpoints (3 by default) of ${ENDPOINTS.length}, each with the params the task supplies (URLs and @handles resolved), the params still missing, the credit cost and the exact call.
|
|
69
|
+
description: `Start here: a task in plain words -> the best endpoints (3 by default) of ${ENDPOINTS.length}, each with the params the task supplies (URLs and @handles resolved), the params still missing, the credit cost and the exact call. Free; no key needed.`,
|
|
70
70
|
inputSchema: withNormalizedArgs(FindInputSchema, "find"),
|
|
71
71
|
outputSchema: FindOutputShape,
|
|
72
72
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
@@ -76,7 +76,7 @@ export function createServer(baseCtx, options = {}) {
|
|
|
76
76
|
});
|
|
77
77
|
server.registerTool("socialcrawl_endpoint", {
|
|
78
78
|
title: "Endpoint Contract",
|
|
79
|
-
description: "Read before calling: one endpoint's purpose, params, where the rows are and up to 25 response fields, cost rule, paging, latency, timeout, next endpoints and a sample link. id
|
|
79
|
+
description: "Read before calling: one endpoint's purpose, params, where the rows are and up to 25 response fields, cost rule, paging, latency, timeout, next endpoints and a sample link. By id, platform+resource or path. Free.",
|
|
80
80
|
inputSchema: withNormalizedArgs(EndpointInputSchema, "endpoint"),
|
|
81
81
|
outputSchema: EndpointOutputShape,
|
|
82
82
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
@@ -86,7 +86,7 @@ export function createServer(baseCtx, options = {}) {
|
|
|
86
86
|
});
|
|
87
87
|
server.registerTool("socialcrawl_estimate", {
|
|
88
88
|
title: "Estimate Credit Cost",
|
|
89
|
-
description: "Exact credits before you spend: one call (id, platform+resource or path, plus the params you will send; calls for a job total; items for a walk) or a plan of several calls. Uses the API's estimator when available, else the bundled pricing.
|
|
89
|
+
description: "Exact credits before you spend: one call (id, platform+resource or path, plus the params you will send; calls for a job total; items for a walk) or a plan of several calls. Uses the API's estimator when available, else the bundled pricing. Free.",
|
|
90
90
|
inputSchema: withNormalizedArgs(EstimateInputSchema, "estimate"),
|
|
91
91
|
outputSchema: EstimateOutputShape,
|
|
92
92
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
@@ -134,7 +134,7 @@ export function createServer(baseCtx, options = {}) {
|
|
|
134
134
|
});
|
|
135
135
|
server.registerTool("socialcrawl_collect", {
|
|
136
136
|
title: "Collect Rows Across Pages",
|
|
137
|
-
description: "Walk a paged endpoint (id, platform+resource or path) to `items` unique rows, the last page or max_credits: cursors supplied, duplicates dropped, stops on a 402, refused free when one page exceeds max_credits. Small results come back whole.
|
|
137
|
+
description: "Walk a paged endpoint (id, platform+resource or path) to `items` unique rows, the last page or max_credits: cursors supplied, duplicates dropped, stops on a 402, refused free when one page exceeds max_credits. Small results come back whole. Spends credits.",
|
|
138
138
|
inputSchema: withNormalizedArgs(CollectInputSchema, "collect"),
|
|
139
139
|
outputSchema: CollectOutputShape,
|
|
140
140
|
annotations: {
|
|
@@ -161,7 +161,7 @@ export function createServer(baseCtx, options = {}) {
|
|
|
161
161
|
});
|
|
162
162
|
server.registerTool("socialcrawl_account", {
|
|
163
163
|
title: "Account and Service Status",
|
|
164
|
-
description: "Free: balance (default, with this session's spend), transactions (ledger), usage (
|
|
164
|
+
description: "Free: balance (default, with this session's spend), transactions (ledger), usage (by api_key, day, endpoint or tag; ≤92 days), status (health; check before retrying a 502/503), freshness (vs live catalogue), notifications (inbox).",
|
|
165
165
|
inputSchema: withNormalizedArgs(AccountInputSchema, "account"),
|
|
166
166
|
outputSchema: AccountOutputShape,
|
|
167
167
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
@@ -175,6 +175,7 @@ export function createServer(baseCtx, options = {}) {
|
|
|
175
175
|
to: params.to,
|
|
176
176
|
group_by: params.group_by,
|
|
177
177
|
api_key_id: params.api_key_id,
|
|
178
|
+
tag: params.tag,
|
|
178
179
|
unread: params.unread,
|
|
179
180
|
kind: params.kind,
|
|
180
181
|
});
|
package/dist/timeouts.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
package/dist/tools/account.d.ts
CHANGED
|
@@ -20,8 +20,11 @@ export interface AccountParams {
|
|
|
20
20
|
/** usage: first and last UTC day (YYYY-MM-DD), at most 92 days apart. */
|
|
21
21
|
from?: string;
|
|
22
22
|
to?: string;
|
|
23
|
-
|
|
23
|
+
/** usage: any comma-separated mix of api_key, day, endpoint, tag. */
|
|
24
|
+
group_by?: string;
|
|
24
25
|
api_key_id?: string;
|
|
26
|
+
/** transactions: only receipts with this x-client-tag. */
|
|
27
|
+
tag?: string;
|
|
25
28
|
}
|
|
26
29
|
export declare function accountStructured(ctx: ApiContext, params: AccountParams): Promise<ToolOutput>;
|
|
27
30
|
/** The kinds GET /v1/notifications filters on (packages/db notification-kinds.ts). */
|