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.
- package/LICENSE +21 -0
- package/README.md +127 -3
- package/dist/auth.js +69 -0
- package/dist/cli.js +50 -0
- package/dist/client.js +166 -0
- package/dist/commands.js +102 -0
- package/dist/config.js +120 -0
- package/dist/context.js +2 -0
- package/dist/errors.js +35 -0
- package/dist/exit-codes.js +31 -0
- package/dist/flags.js +57 -0
- package/dist/generated/endpoints.json +558 -0
- package/dist/index.js +77 -0
- package/dist/manifest.js +19 -0
- package/dist/output.js +41 -0
- package/dist/param.js +1 -0
- package/dist/skill.js +57 -0
- package/package.json +36 -6
- package/index.js +0 -7
package/dist/output.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Pretty on a terminal, compact when piped. */
|
|
2
|
+
export function printJson(ctx, value) {
|
|
3
|
+
ctx.io.out(JSON.stringify(value, null, ctx.io.outIsTTY ? 2 : undefined) + "\n");
|
|
4
|
+
}
|
|
5
|
+
export function printError(ctx, err) {
|
|
6
|
+
ctx.io.err(JSON.stringify(err.toJSON()) + "\n");
|
|
7
|
+
}
|
|
8
|
+
/** The result rows of a search response: `leads`, `data` (array), `data.results` or `results`. */
|
|
9
|
+
export function resultRows(body) {
|
|
10
|
+
if (Array.isArray(body.leads))
|
|
11
|
+
return body.leads;
|
|
12
|
+
if (Array.isArray(body.data))
|
|
13
|
+
return body.data;
|
|
14
|
+
const data = body.data;
|
|
15
|
+
if (data && typeof data === "object" && Array.isArray(data.results)) {
|
|
16
|
+
return data.results;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(body.results))
|
|
19
|
+
return body.results;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export function printJsonl(ctx, body) {
|
|
23
|
+
if (body.warning !== undefined)
|
|
24
|
+
ctx.io.err(JSON.stringify({ warning: body.warning }) + "\n");
|
|
25
|
+
const inner = body.data && typeof body.data === "object" && !Array.isArray(body.data) ? body.data : {};
|
|
26
|
+
const meta = {};
|
|
27
|
+
for (const key of ["credits_used", "has_more", "total"]) {
|
|
28
|
+
const v = body[key] ?? inner[key];
|
|
29
|
+
if (v !== undefined)
|
|
30
|
+
meta[key] = v;
|
|
31
|
+
}
|
|
32
|
+
if (Object.keys(meta).length > 0)
|
|
33
|
+
ctx.io.err(JSON.stringify({ meta }) + "\n");
|
|
34
|
+
const rows = resultRows(body);
|
|
35
|
+
if (!rows) {
|
|
36
|
+
ctx.io.out(JSON.stringify(body) + "\n");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const row of rows)
|
|
40
|
+
ctx.io.out(JSON.stringify(row) + "\n");
|
|
41
|
+
}
|
package/dist/param.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/skill.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { SETTINGS_URL } from "./context.js";
|
|
2
|
+
import { EXIT_TABLE } from "./exit-codes.js";
|
|
3
|
+
import { paramFlag } from "./flags.js";
|
|
4
|
+
import { ALIASES } from "./manifest.js";
|
|
5
|
+
export function buildSkill(endpoints) {
|
|
6
|
+
const commands = endpoints.map((ep) => {
|
|
7
|
+
const alias = Object.entries(ALIASES).find(([, target]) => target === ep.id)?.[0];
|
|
8
|
+
const positional = ep.pathParams.map((n) => ` <${n}>`).join("");
|
|
9
|
+
const required = ep.params.filter((p) => p.required).map((p) => ` --${paramFlag(p)} <${p.type}>`).join("");
|
|
10
|
+
const aka = alias ? ` Alias: \`${alias}\`.` : "";
|
|
11
|
+
return `- \`consulti ${ep.id}${positional}${required}\` ${ep.title}.${aka} ${ep.billable ? "Billed." : "Free."}`;
|
|
12
|
+
});
|
|
13
|
+
const exits = EXIT_TABLE.map(([code, meaning]) => `- ${code}: ${meaning}`);
|
|
14
|
+
return `---
|
|
15
|
+
name: consulti-cli
|
|
16
|
+
description: Use the consulti command line to verify emails, search and enrich B2B leads, search Instagram profiles, manage lists and check credits. Use when a task needs Consulti data from a shell.
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Consulti CLI
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
\`curl -fsSL https://consulti.ai/install.sh | bash\`, or \`npm install -g consulti\` (Node 20 or newer), or run one-off with \`npx consulti\`.
|
|
24
|
+
|
|
25
|
+
## Auth
|
|
26
|
+
|
|
27
|
+
Set \`CONSULTI_API_KEY\` in the environment. Keys are created at ${SETTINGS_URL}.
|
|
28
|
+
\`consulti login\` saves a key to a local file instead. Never paste a key into a command line.
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
Every command prints JSON on stdout. Run \`consulti <command> --help\` for flags.
|
|
33
|
+
|
|
34
|
+
${commands.join("\n")}
|
|
35
|
+
- \`consulti login\`, \`consulti logout\`, \`consulti whoami\`
|
|
36
|
+
|
|
37
|
+
List flags take repeated values or commas (\`--titles CEO,CTO\`). Use \`--body\` for a value that itself contains a comma. \`--body '{...}'\` (or \`@file\`, or \`-\`) passes a full JSON body on POST commands and explicit flags override it. \`--jsonl\` on search commands prints one result per line. It also writes a {"meta": {...}} line (credits_used, has_more, total) to stderr, and a {"warning": ...} line if a response carries a warning.
|
|
38
|
+
|
|
39
|
+
## Exit codes
|
|
40
|
+
|
|
41
|
+
${exits.join("\n")}
|
|
42
|
+
|
|
43
|
+
Errors are one JSON object on stderr with error, code, status, retry_after, credits_used and hint.
|
|
44
|
+
|
|
45
|
+
## Billing caution
|
|
46
|
+
|
|
47
|
+
The CLI never retries. A retried billable call bills again. After a timeout (exit 6) run \`consulti credits\` before trying again, and wait for retry_after seconds after exit 5.
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
export function registerSkill(program, ctx, endpoints) {
|
|
51
|
+
program
|
|
52
|
+
.command("skill")
|
|
53
|
+
.description("Print a SKILL.md that teaches an AI agent how to use this CLI.")
|
|
54
|
+
.action(() => {
|
|
55
|
+
ctx.io.out(buildSkill(endpoints));
|
|
56
|
+
});
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "consulti",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "Command-line
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Command-line client for the Consulti.ai API: email verification, B2B lead search and enrichment, Instagram search, lists and credits. JSON output and stable exit codes for scripts and AI agents.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"bin": {
|
|
6
|
-
"consulti": "index.js"
|
|
7
|
+
"consulti": "dist/index.js"
|
|
7
8
|
},
|
|
8
9
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"README.md"
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
11
13
|
],
|
|
12
14
|
"engines": {
|
|
13
15
|
"node": ">=20"
|
|
14
16
|
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc && node -e \"require('fs').cpSync('src/generated','dist/generated',{recursive:true})\"",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"test": "vitest run"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"consulti",
|
|
24
|
+
"cli",
|
|
25
|
+
"lead-enrichment",
|
|
26
|
+
"email-verification",
|
|
27
|
+
"b2b"
|
|
28
|
+
],
|
|
15
29
|
"homepage": "https://www.consulti.ai/api-docs",
|
|
16
|
-
"
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/Lead-Gen-Jay/consulti.git",
|
|
33
|
+
"directory": "cli"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/Lead-Gen-Jay/consulti/issues"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"commander": "14.0.3"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^20.19.0",
|
|
44
|
+
"typescript": "^5.8.3",
|
|
45
|
+
"vitest": "^4.1.11"
|
|
46
|
+
}
|
|
17
47
|
}
|