consulti 0.0.1 → 0.2.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.
@@ -0,0 +1,558 @@
1
+ {
2
+ "source": "lib/api/endpoints-data.ts",
3
+ "endpoints": [
4
+ {
5
+ "id": "verify",
6
+ "method": "POST",
7
+ "path": "/verify",
8
+ "title": "Verify email",
9
+ "description": "Verify whether an email address is valid and deliverable. Uses SMTP checks.",
10
+ "tier": "any",
11
+ "credits": "Only successful verifications are billed — 1 verification credit each. Requests that fail validation (400) or auth (401), or hit insufficient credits (402), are never billed and return credits_used: 0. Results served from our cache cost the same as fresh ones. When the verifier does not answer in time or is temporarily unavailable, the call returns 503 with code verifier_unavailable, credits_used: 0 and a Retry-After header in seconds. The 503 is sent only after the reserved credit is confirmed refunded. Retry after Retry-After only when credits_used: 0 is present. If the refund cannot be confirmed, the call returns 500 with code refund_unconfirmed and no Retry-After. Reconcile with GET /credits before retrying, because a retry reserves another credit.",
12
+ "noAuth": false,
13
+ "billable": true,
14
+ "inMcp": true,
15
+ "pathParams": [],
16
+ "params": [
17
+ {
18
+ "name": "email",
19
+ "type": "string",
20
+ "required": true,
21
+ "desc": "Email address to verify. Leading/trailing whitespace is trimmed automatically before validation."
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "id": "verify-catchall",
27
+ "method": "POST",
28
+ "path": "/verify/catchall",
29
+ "title": "Verify catch-all mailbox",
30
+ "description": "Resolve whether a specific mailbox on a catch-all domain actually exists. Unlike /verify (SMTP), this uses Consulti’s ESP verification engine to probe mailbox existence, with an automatic fallback for providers the engine doesn’t cover. Use it on addresses that /verify reports as is_catch_all=true.",
31
+ "tier": "pro+",
32
+ "credits": "Only successful verifications are billed — 5 verification credits each. Requests that fail validation (400) or auth (401), or hit insufficient credits (402), are never billed and return credits_used: 0. That includes an address that passes the format check but is rejected as malformed during verification: it returns 400 \"Invalid email address.\" and the reserved credits are refunded. Results served from our cache cost the same as fresh ones. When the verification engine does not return a verdict in time, the call returns 503 with code verifier_unavailable and a Retry-After header in seconds. The reserved credits are refunded, but this 503 carries no credits_used, so check GET /credits before you retry.",
33
+ "noAuth": false,
34
+ "billable": true,
35
+ "inMcp": true,
36
+ "pathParams": [],
37
+ "params": [
38
+ {
39
+ "name": "email",
40
+ "type": "string",
41
+ "required": true,
42
+ "desc": "Email address on a catch-all domain to resolve. Leading/trailing whitespace is trimmed automatically before validation."
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "id": "credits",
48
+ "method": "GET",
49
+ "path": "/credits",
50
+ "title": "Get current credit balance",
51
+ "description": "Return the authenticated API user’s current lead and verification credit balances. Useful as a pre-flight check before running a large search/enrich batch.",
52
+ "tier": "any",
53
+ "credits": "Free — no deduction.",
54
+ "noAuth": false,
55
+ "billable": false,
56
+ "inMcp": true,
57
+ "pathParams": [],
58
+ "params": []
59
+ },
60
+ {
61
+ "id": "meta-filter",
62
+ "method": "GET",
63
+ "path": "/meta/{filter}",
64
+ "title": "Get canonical values for a filter",
65
+ "description": "Return the canonical list of values accepted by a given enum filter. No auth required. Snapshot-first with a 1-hour edge cache that revalidates against the live database. Use slug \"_all\" to fetch every filter in one snapshot-only payload.",
66
+ "tier": "any",
67
+ "credits": "Free. No auth required.",
68
+ "noAuth": true,
69
+ "billable": false,
70
+ "inMcp": false,
71
+ "pathParams": [
72
+ "filter"
73
+ ],
74
+ "params": []
75
+ },
76
+ {
77
+ "id": "enrich",
78
+ "method": "POST",
79
+ "path": "/leads/enrich",
80
+ "title": "Enrich lead by email",
81
+ "description": "Given an email address, return the full enriched B2B lead profile, including a company object (funding, traffic, HQ, followers, specialties) when the lead is linked to a company.",
82
+ "tier": "pro+",
83
+ "credits": "1 lead credit — only deducted on a successful match.",
84
+ "noAuth": false,
85
+ "billable": true,
86
+ "inMcp": true,
87
+ "pathParams": [],
88
+ "params": [
89
+ {
90
+ "name": "email",
91
+ "type": "string",
92
+ "required": true,
93
+ "desc": "Work email address"
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ "id": "enrich-linkedin",
99
+ "method": "POST",
100
+ "path": "/enrich/linkedin",
101
+ "title": "Enrich by LinkedIn URL (live)",
102
+ "description": "Enrich a person by their LinkedIn profile URL → a verified work email plus their US mobile phone as a free add-on. Cache-first: served instantly from our database when we already hold a verified email for that profile, otherwise enriched live via the provider and cached for next time.",
103
+ "tier": "pro+",
104
+ "credits": "1 lead credit — charged only when an email is returned. Phone is a free add-on; phone-only or no-email responses are free.",
105
+ "noAuth": false,
106
+ "billable": true,
107
+ "inMcp": true,
108
+ "pathParams": [],
109
+ "params": [
110
+ {
111
+ "name": "linkedin_url",
112
+ "type": "string",
113
+ "required": true,
114
+ "desc": "LinkedIn profile URL (e.g. https://linkedin.com/in/johndoe)"
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ "id": "leads-search",
120
+ "method": "POST",
121
+ "path": "/leads/search",
122
+ "title": "Search B2B leads",
123
+ "description": "Search the B2B lead database with filters on title, industry, location, company size, and more. Results are always restricted to leads carrying our verified email label — there is no option to include unverified leads.",
124
+ "tier": "pro+",
125
+ "credits": "1 lead credit per result returned. Reserved up to `size`, then refunded down to the actual row count. 0 results = 0 credits. A retried request is a new billable search. An `Idempotency-Key` header is accepted but has no effect at present, so de-duplicate on your side rather than relying on replay. A 503 means the search could not run right now: code search_unavailable when the database was busy or a connection dropped, and code search_timeout when the query ran too long, so narrow the filters. Both carry a Retry-After header in seconds. The reserved credits are refunded, but the body has no credits_used, so check GET /credits before you retry.",
126
+ "noAuth": false,
127
+ "billable": true,
128
+ "inMcp": true,
129
+ "pathParams": [],
130
+ "params": [
131
+ {
132
+ "name": "q",
133
+ "type": "string",
134
+ "required": false,
135
+ "desc": "Free-text search across job title, company name, and industry only. Does not match person names; use POST /leads/find-by-name for that (Beta, REST-only)."
136
+ },
137
+ {
138
+ "name": "titles",
139
+ "type": "string[]",
140
+ "required": false,
141
+ "desc": "Job titles to match (e.g. [\"CEO\", \"CTO\"])"
142
+ },
143
+ {
144
+ "name": "industries",
145
+ "type": "string[]",
146
+ "required": false,
147
+ "desc": "Industries (case-sensitive exact match). See GET /api/v1/meta/industries for the full canonical list."
148
+ },
149
+ {
150
+ "name": "technologies",
151
+ "type": "string[]",
152
+ "required": false,
153
+ "desc": "Technologies the company’s website uses, exact Wappalyzer-style names (e.g. [\"Shopify\", \"HubSpot\"]). OR-matched: a lead matches if it uses any listed technology. Max 25. See GET /api/v1/meta/technologies for the canonical list."
154
+ },
155
+ {
156
+ "name": "excludeTechnologies",
157
+ "type": "string[]",
158
+ "required": false,
159
+ "desc": "Technologies to exclude, same Wappalyzer-style names. A lead is dropped if its company uses any listed technology; leads with no technology data are kept. Max 25."
160
+ },
161
+ {
162
+ "name": "countries",
163
+ "type": "string[]",
164
+ "required": false,
165
+ "desc": "Countries. Alias-group members are equivalent (e.g. \"United States\" and \"US\"). See GET /api/v1/meta/countries."
166
+ },
167
+ {
168
+ "name": "states",
169
+ "type": "string[]",
170
+ "required": false,
171
+ "desc": "States/regions. Alias-group members are equivalent (e.g. \"Ontario\" and \"ON\"). See GET /api/v1/meta/states."
172
+ },
173
+ {
174
+ "name": "cities",
175
+ "type": "string[]",
176
+ "required": false,
177
+ "desc": "Cities to match"
178
+ },
179
+ {
180
+ "name": "company",
181
+ "type": "string",
182
+ "required": false,
183
+ "desc": "Company name substring"
184
+ },
185
+ {
186
+ "name": "empMin",
187
+ "type": "number",
188
+ "required": false,
189
+ "desc": "Minimum employee count"
190
+ },
191
+ {
192
+ "name": "empMax",
193
+ "type": "number",
194
+ "required": false,
195
+ "desc": "Maximum employee count"
196
+ },
197
+ {
198
+ "name": "revenueMin",
199
+ "type": "number",
200
+ "required": false,
201
+ "desc": "Minimum annual revenue in USD, whole dollars. Leads with no revenue data on file are excluded when either bound is set. Must be less than or equal to revenueMax when both are set."
202
+ },
203
+ {
204
+ "name": "revenueMax",
205
+ "type": "number",
206
+ "required": false,
207
+ "desc": "Maximum annual revenue in USD, whole dollars. Leads with no revenue data on file are excluded when either bound is set. Must be greater than or equal to revenueMin when both are set."
208
+ },
209
+ {
210
+ "name": "excludeTitles",
211
+ "type": "string[]",
212
+ "required": false,
213
+ "desc": "Job titles to exclude. A lead is dropped if its job title matches any listed value. Max 25."
214
+ },
215
+ {
216
+ "name": "excludeListId",
217
+ "type": "string",
218
+ "required": false,
219
+ "desc": "UUID of a saved list you own, and it must be a LEAD list (the kind created by POST /lists with kind \"lead\"). Business, podcast, YouTube and Instagram lists hold no lead emails; passing one returns 400 rather than silently excluding nothing. GET /lists reports the kind of each list. Leads whose email is on that list are removed from the result set before billing, so excluded leads never cost credits. Because exclusion is applied in the query, request `page: 1` on every call and add each batch you receive to the list with POST /lists/{id}/add-leads — paging forward while excluding skips leads. Returns 400 if the list does not exist or is not owned by the API key holder."
220
+ },
221
+ {
222
+ "name": "page",
223
+ "type": "number",
224
+ "required": false,
225
+ "desc": "Page number (default: 1). When using excludeListId, keep this at 1 and grow the list instead."
226
+ },
227
+ {
228
+ "name": "size",
229
+ "type": "number",
230
+ "required": false,
231
+ "desc": "Results per page, max 100 (default: 25)"
232
+ }
233
+ ]
234
+ },
235
+ {
236
+ "id": "placement-tests-create",
237
+ "method": "POST",
238
+ "path": "/placement-tests",
239
+ "title": "Create an inbox placement test",
240
+ "description": "Create an inbox placement test. Checking starts when the test is created, so there is no second call to make: send one email from the mailbox you want to test to every seed address within 15 minutes, with the test code anywhere in the subject or the body, then poll GET /placement-tests/{id}. Results usually arrive within about 2 minutes of sending. A test can complete before expires_at, 2 minutes after the last arrival, with the seeds still missing reported as not found. Until expires_at, such a seed is corrected if the email reaches it, and the score is rebuilt. Results are final at expires_at. If the test could not be started, the response says status \"draft\" with a next_step: call POST /placement-tests/{id}/sent after sending. If that draft already has a sent_at, its window runs from sent_at and closes at expires_at. At most 3 of your tests can be checking at once; another create is a 429 with code too_many_open_tests and a Retry-After header, is not charged, and is safe to retry.",
241
+ "tier": "pro+",
242
+ "credits": "1 lead credit per test, charged when the test is created. Refunded if creation fails. Not refunded for poor placement results. A retried request creates, and charges for, a new test. An `Idempotency-Key` header is accepted but has no effect at present, so de-duplicate on your side rather than relying on replay.",
243
+ "noAuth": false,
244
+ "billable": true,
245
+ "inMcp": true,
246
+ "pathParams": [],
247
+ "params": [
248
+ {
249
+ "name": "name",
250
+ "type": "string",
251
+ "required": false,
252
+ "desc": "Optional label for the test (max 120 characters). Defaults to the subject."
253
+ },
254
+ {
255
+ "name": "subject",
256
+ "type": "string",
257
+ "required": false,
258
+ "desc": "Optional subject of the email you will send (max 998 characters). Used for the content check when no seed returns a body."
259
+ },
260
+ {
261
+ "name": "body",
262
+ "type": "string",
263
+ "required": false,
264
+ "desc": "Optional body of the email you will send (max 100,000 characters), for the same purpose.",
265
+ "flag": "email-body"
266
+ }
267
+ ]
268
+ },
269
+ {
270
+ "id": "placement-tests-sent",
271
+ "method": "POST",
272
+ "path": "/placement-tests/{id}/sent",
273
+ "title": "Start checking a draft placement test",
274
+ "description": "Optional. A test created through the API is already checking, and calling this on a checking test changes nothing: it returns the current status and sent_at, so it can never extend the window. Call it when the create response said status \"draft\", once the email has gone out; checking then starts. A completed test is a 409 with code already_finished; create a new test to check again. A failed test is re-checked for free, but only while fewer than 3 of your tests are checking; otherwise it is the same 429 too_many_open_tests as a create, with Retry-After, and the test stays failed. A test whose creation failed and was refunded is a 409 with code not_charged and cannot be started. Another account's test, or an id that does not exist, is a 404.",
275
+ "tier": "pro+",
276
+ "credits": "Free. The test was charged when it was created.",
277
+ "noAuth": false,
278
+ "billable": false,
279
+ "inMcp": true,
280
+ "pathParams": [
281
+ "id"
282
+ ],
283
+ "params": []
284
+ },
285
+ {
286
+ "id": "placement-tests-get",
287
+ "method": "GET",
288
+ "path": "/placement-tests/{id}",
289
+ "title": "Get a placement test",
290
+ "description": "Status, per-seed placement, a summary of where the email landed, and the 0 to 10 score and full report once built. Each seed shows where the email landed (inbox, spam, promotions and other tabs, not_found), delivery times, and the SPF, DKIM and DMARC verdicts that seed recorded. report_status is pending while the report is being built, ready once it is stored, and unavailable when it could not be built. Another account's test, or an id that does not exist, is a 404.",
291
+ "tier": "pro+",
292
+ "credits": "Free.",
293
+ "noAuth": false,
294
+ "billable": false,
295
+ "inMcp": true,
296
+ "pathParams": [
297
+ "id"
298
+ ],
299
+ "params": []
300
+ },
301
+ {
302
+ "id": "placement-tests-list",
303
+ "method": "GET",
304
+ "path": "/placement-tests",
305
+ "title": "List placement tests",
306
+ "description": "Your placement tests, newest first. Only tests your account created are listed.",
307
+ "tier": "pro+",
308
+ "credits": "Free.",
309
+ "noAuth": false,
310
+ "billable": false,
311
+ "inMcp": true,
312
+ "pathParams": [],
313
+ "params": [
314
+ {
315
+ "name": "page",
316
+ "type": "number",
317
+ "required": false,
318
+ "desc": "Page number, from 1 (default 1)."
319
+ },
320
+ {
321
+ "name": "size",
322
+ "type": "number",
323
+ "required": false,
324
+ "desc": "Tests per page, 1 to 100 (default 25)."
325
+ }
326
+ ]
327
+ },
328
+ {
329
+ "id": "instagram-search",
330
+ "method": "POST",
331
+ "path": "/instagram/search",
332
+ "title": "Search Instagram profiles",
333
+ "description": "Search a database of Instagram profiles with filters on follower count, category, location, account type, and email data quality. Results can be filtered by verification status; all listed filters are optional. Pagination depth is capped at 100,000 results to prevent deep-offset performance issues.",
334
+ "tier": "pro+",
335
+ "credits": "1 lead credit per result returned. Reserved up to `size`, then refunded down to the actual row count. 0 results = 0 credits.",
336
+ "noAuth": false,
337
+ "billable": true,
338
+ "inMcp": true,
339
+ "pathParams": [],
340
+ "params": [
341
+ {
342
+ "name": "q",
343
+ "type": "string",
344
+ "required": false,
345
+ "desc": "Free-text search across username and bio"
346
+ },
347
+ {
348
+ "name": "bioKeywords",
349
+ "type": "string[]",
350
+ "required": false,
351
+ "desc": "Keywords to search for in profile bios"
352
+ },
353
+ {
354
+ "name": "excludeKeywords",
355
+ "type": "string[]",
356
+ "required": false,
357
+ "desc": "Exclude profiles whose bio contains any of these keywords"
358
+ },
359
+ {
360
+ "name": "excludeAdultContent",
361
+ "type": "boolean",
362
+ "required": false,
363
+ "desc": "Exclude profiles with adult/sexual content terms in their bio"
364
+ },
365
+ {
366
+ "name": "followerMin",
367
+ "type": "number",
368
+ "required": false,
369
+ "desc": "Minimum follower count"
370
+ },
371
+ {
372
+ "name": "followerMax",
373
+ "type": "number",
374
+ "required": false,
375
+ "desc": "Maximum follower count"
376
+ },
377
+ {
378
+ "name": "followingMin",
379
+ "type": "number",
380
+ "required": false,
381
+ "desc": "Minimum following count"
382
+ },
383
+ {
384
+ "name": "followingMax",
385
+ "type": "number",
386
+ "required": false,
387
+ "desc": "Maximum following count"
388
+ },
389
+ {
390
+ "name": "postsMin",
391
+ "type": "number",
392
+ "required": false,
393
+ "desc": "Minimum post count"
394
+ },
395
+ {
396
+ "name": "postsMax",
397
+ "type": "number",
398
+ "required": false,
399
+ "desc": "Maximum post count"
400
+ },
401
+ {
402
+ "name": "categories",
403
+ "type": "string[]",
404
+ "required": false,
405
+ "desc": "Categories to filter by. See GET /api/v1/meta/instagram-categories for the canonical list."
406
+ },
407
+ {
408
+ "name": "countries",
409
+ "type": "string[]",
410
+ "required": false,
411
+ "desc": "Countries to filter by (exact match). See GET /api/v1/meta/instagram-countries for the canonical list."
412
+ },
413
+ {
414
+ "name": "accountTypes",
415
+ "type": "string[]",
416
+ "required": false,
417
+ "desc": "Account types to filter by (e.g. [\"business\", \"personal\"]). See GET /api/v1/meta/instagram-account-types for valid values."
418
+ },
419
+ {
420
+ "name": "emailStatus",
421
+ "type": "string[]",
422
+ "required": false,
423
+ "desc": "Email verification status to filter by (e.g. [\"good\", \"risky\", \"bad\", \"catch_all\"]). See GET /api/v1/meta/instagram-email-statuses for valid values."
424
+ },
425
+ {
426
+ "name": "verified",
427
+ "type": "boolean",
428
+ "required": false,
429
+ "desc": "Filter to only verified accounts"
430
+ },
431
+ {
432
+ "name": "hasEmail",
433
+ "type": "boolean",
434
+ "required": false,
435
+ "desc": "Filter to only accounts with an email on file. Use emailStatus to filter by verification quality."
436
+ },
437
+ {
438
+ "name": "hasPhone",
439
+ "type": "boolean",
440
+ "required": false,
441
+ "desc": "Filter to only accounts with a phone number"
442
+ },
443
+ {
444
+ "name": "hasWebsite",
445
+ "type": "boolean",
446
+ "required": false,
447
+ "desc": "Filter to only accounts with a website"
448
+ },
449
+ {
450
+ "name": "excludeListId",
451
+ "type": "string",
452
+ "required": false,
453
+ "desc": "UUID of a saved list you own, and it must be an Instagram list (kind \"instagram\"). GET /lists reports the kind of each list. Profiles on that list are removed from the result set before billing, so excluded rows never cost credits. A blank or malformed id, a list that does not exist or is not yours, and a list of another kind each return 400. A list with more than 100,000 members returns 422 (code exclusion_too_large), and a temporary lookup failure returns 503 (code list_resolution_unavailable). All of these are returned before anything is reserved, with credits_used: 0."
454
+ },
455
+ {
456
+ "name": "sortBy",
457
+ "type": "string",
458
+ "required": false,
459
+ "desc": "Field to sort by (followers, posts, engagement, username)"
460
+ },
461
+ {
462
+ "name": "sortOrder",
463
+ "type": "string",
464
+ "required": false,
465
+ "desc": "Sort order (asc or desc)"
466
+ },
467
+ {
468
+ "name": "page",
469
+ "type": "number",
470
+ "required": false,
471
+ "desc": "Page number (default: 1). Keep (page - 1) * size ≤ 100,000 to avoid deep-offset performance issues."
472
+ },
473
+ {
474
+ "name": "size",
475
+ "type": "number",
476
+ "required": false,
477
+ "desc": "Results per page, max 100 (default: 25)"
478
+ }
479
+ ]
480
+ },
481
+ {
482
+ "id": "lists-get",
483
+ "method": "GET",
484
+ "path": "/lists",
485
+ "title": "Get saved lists",
486
+ "description": "Return all saved lead lists owned by the authenticated API user, with member counts.",
487
+ "tier": "pro+",
488
+ "credits": "Free.",
489
+ "noAuth": false,
490
+ "billable": false,
491
+ "inMcp": true,
492
+ "pathParams": [],
493
+ "params": []
494
+ },
495
+ {
496
+ "id": "lists-create",
497
+ "method": "POST",
498
+ "path": "/lists",
499
+ "title": "Create a list",
500
+ "description": "Create a new saved lead list.",
501
+ "tier": "pro+",
502
+ "credits": "Free.",
503
+ "noAuth": false,
504
+ "billable": false,
505
+ "inMcp": true,
506
+ "pathParams": [],
507
+ "params": [
508
+ {
509
+ "name": "name",
510
+ "type": "string",
511
+ "required": true,
512
+ "desc": "List name"
513
+ },
514
+ {
515
+ "name": "description",
516
+ "type": "string",
517
+ "required": false,
518
+ "desc": "Optional description"
519
+ },
520
+ {
521
+ "name": "kind",
522
+ "type": "string",
523
+ "required": false,
524
+ "desc": "List kind: lead (B2B), business (local), podcast, youtube, or instagram (default: lead)"
525
+ }
526
+ ]
527
+ },
528
+ {
529
+ "id": "lists-add-leads",
530
+ "method": "POST",
531
+ "path": "/lists/{id}/add-leads",
532
+ "title": "Add leads to a list",
533
+ "description": "Add members to a saved list by email (B2B leads) or business ID (local leads). Duplicates are ignored. The payload must match the list's kind: send emails to a kind=\"lead\" list and businessIds to a kind=\"business\" list. A mismatch on a list that already has members is rejected with 400 LIST_KIND_MISMATCH and nothing is written; an empty list takes the kind of its first payload. Create the list with the matching kind first. Send only one of the two arrays per call.",
534
+ "tier": "pro+",
535
+ "credits": "B2B email saves are free. Business IDs cost 1 lead credit per newly unlocked business with usable email data. IDs already unlocked by your account, including successful paid local searches, cost 0 additional credits. Duplicate IDs and businesses without email data do not cost credits.",
536
+ "noAuth": false,
537
+ "billable": true,
538
+ "inMcp": true,
539
+ "pathParams": [
540
+ "id"
541
+ ],
542
+ "params": [
543
+ {
544
+ "name": "emails",
545
+ "type": "string[]",
546
+ "required": false,
547
+ "desc": "Array of B2B lead emails. Requires a list with kind=\"lead\""
548
+ },
549
+ {
550
+ "name": "businessIds",
551
+ "type": "number[]",
552
+ "required": false,
553
+ "desc": "Up to 50,000 local business IDs. Requires a list with kind=\"business\". Unpurchased IDs can consume lead credits."
554
+ }
555
+ ]
556
+ }
557
+ ]
558
+ }
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { homedir } from "node:os";
4
+ import { packageVersion, run } from "./cli.js";
5
+ function readStdin() {
6
+ return new Promise((resolve, reject) => {
7
+ let data = "";
8
+ process.stdin.setEncoding("utf8");
9
+ process.stdin.on("data", (chunk) => (data += chunk));
10
+ process.stdin.on("end", () => resolve(data));
11
+ process.stdin.on("error", reject);
12
+ });
13
+ }
14
+ /** Reads a line from the terminal with echo off. */
15
+ function readSecret(prompt) {
16
+ return new Promise((resolve, reject) => {
17
+ const stdin = process.stdin;
18
+ process.stderr.write(prompt);
19
+ stdin.setRawMode(true);
20
+ stdin.resume();
21
+ stdin.setEncoding("utf8");
22
+ let value = "";
23
+ const finish = (err) => {
24
+ stdin.setRawMode(false);
25
+ stdin.pause();
26
+ stdin.removeListener("data", onData);
27
+ process.stderr.write("\n");
28
+ if (err)
29
+ reject(err);
30
+ else
31
+ resolve(value);
32
+ };
33
+ const onData = (chunk) => {
34
+ for (const ch of chunk) {
35
+ if (ch === "\r" || ch === "\n" || ch === "\u0004")
36
+ return finish();
37
+ if (ch === "\u0003")
38
+ return finish(new Error("Cancelled."));
39
+ if (ch === "\u007f" || ch === "\b")
40
+ value = value.slice(0, -1);
41
+ else
42
+ value += ch;
43
+ }
44
+ };
45
+ stdin.on("data", onData);
46
+ });
47
+ }
48
+ function openUrl(url) {
49
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : null;
50
+ if (!cmd)
51
+ return;
52
+ try {
53
+ const child = spawn(cmd, [url], { stdio: "ignore", detached: true });
54
+ child.on("error", () => { });
55
+ child.unref();
56
+ }
57
+ catch {
58
+ // Best effort: the URL is already printed.
59
+ }
60
+ }
61
+ // `consulti ... | head -1` closes the pipe early: that is not an error.
62
+ process.stdout.on("error", (e) => {
63
+ if (e.code === "EPIPE")
64
+ process.exit(0);
65
+ throw e;
66
+ });
67
+ const io = {
68
+ out: (text) => void process.stdout.write(text),
69
+ err: (text) => void process.stderr.write(text),
70
+ outIsTTY: process.stdout.isTTY === true,
71
+ inIsTTY: process.stdin.isTTY === true,
72
+ readStdin,
73
+ readSecret,
74
+ openUrl,
75
+ };
76
+ const ctx = { env: process.env, io, fetch, version: packageVersion(), homedir: homedir() };
77
+ process.exitCode = await run(process.argv.slice(2), ctx);
@@ -0,0 +1,19 @@
1
+ // Root tests import this module, and CI's root test shards do not install cli/ dependencies:
2
+ // keep its runtime imports to node built-ins (param.js holds only types).
3
+ import { readFileSync } from "node:fs";
4
+ /** Same relative location from src/ (tests) and dist/ (published): the build script copies the JSON. */
5
+ export function loadManifest() {
6
+ const raw = readFileSync(new URL("./generated/endpoints.json", import.meta.url), "utf8");
7
+ return JSON.parse(raw).endpoints;
8
+ }
9
+ export const ALIASES = {
10
+ search: "leads-search",
11
+ lists: "lists-get",
12
+ meta: "meta-filter",
13
+ };
14
+ export const JSONL_IDS = ["leads-search", "instagram-search"];
15
+ export const SEARCH_TIMEOUT_MS = 130_000; // leads-search maxDuration is 120 s
16
+ export const DEFAULT_TIMEOUT_MS = 310_000; // routes that export no maxDuration run under Vercel's 300 s default
17
+ export function timeoutFor(id) {
18
+ return id === "leads-search" ? SEARCH_TIMEOUT_MS : DEFAULT_TIMEOUT_MS;
19
+ }