@usenaive-sdk/cli 0.2.0 → 0.2.2

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 (65) hide show
  1. package/README.md +25 -0
  2. package/dist/client.d.ts +10 -0
  3. package/dist/client.js +25 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/commands/billing.d.ts +2 -0
  6. package/dist/commands/billing.js +204 -0
  7. package/dist/commands/billing.js.map +1 -0
  8. package/dist/commands/companies.d.ts +2 -0
  9. package/dist/commands/companies.js +88 -0
  10. package/dist/commands/companies.js.map +1 -0
  11. package/dist/commands/domains.d.ts +2 -0
  12. package/dist/commands/domains.js +252 -0
  13. package/dist/commands/domains.js.map +1 -0
  14. package/dist/commands/email.d.ts +2 -0
  15. package/dist/commands/email.js +289 -0
  16. package/dist/commands/email.js.map +1 -0
  17. package/dist/commands/identity.d.ts +2 -0
  18. package/dist/commands/identity.js +109 -0
  19. package/dist/commands/identity.js.map +1 -0
  20. package/dist/commands/images.d.ts +2 -0
  21. package/dist/commands/images.js +291 -0
  22. package/dist/commands/images.js.map +1 -0
  23. package/dist/commands/jobs.d.ts +2 -0
  24. package/dist/commands/jobs.js +143 -0
  25. package/dist/commands/jobs.js.map +1 -0
  26. package/dist/commands/keys.d.ts +2 -0
  27. package/dist/commands/keys.js +133 -0
  28. package/dist/commands/keys.js.map +1 -0
  29. package/dist/commands/link.d.ts +3 -0
  30. package/dist/commands/link.js +91 -0
  31. package/dist/commands/link.js.map +1 -0
  32. package/dist/commands/login.d.ts +2 -0
  33. package/dist/commands/login.js +63 -0
  34. package/dist/commands/login.js.map +1 -0
  35. package/dist/commands/register.d.ts +2 -0
  36. package/dist/commands/register.js +68 -0
  37. package/dist/commands/register.js.map +1 -0
  38. package/dist/commands/search.d.ts +2 -0
  39. package/dist/commands/search.js +209 -0
  40. package/dist/commands/search.js.map +1 -0
  41. package/dist/commands/social.d.ts +2 -0
  42. package/dist/commands/social.js +402 -0
  43. package/dist/commands/social.js.map +1 -0
  44. package/dist/commands/status.d.ts +2 -0
  45. package/dist/commands/status.js +47 -0
  46. package/dist/commands/status.js.map +1 -0
  47. package/dist/commands/usage.d.ts +2 -0
  48. package/dist/commands/usage.js +62 -0
  49. package/dist/commands/usage.js.map +1 -0
  50. package/dist/commands/video.d.ts +2 -0
  51. package/dist/commands/video.js +243 -0
  52. package/dist/commands/video.js.map +1 -0
  53. package/dist/commands/whoami.d.ts +2 -0
  54. package/dist/commands/whoami.js +37 -0
  55. package/dist/commands/whoami.js.map +1 -0
  56. package/dist/config.d.ts +10 -0
  57. package/dist/config.js +40 -0
  58. package/dist/config.js.map +1 -0
  59. package/dist/index.d.ts +2 -0
  60. package/dist/index.js +83 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/output.d.ts +37 -0
  63. package/dist/output.js +84 -0
  64. package/dist/output.js.map +1 -0
  65. package/package.json +1 -1
@@ -0,0 +1,91 @@
1
+ import { Command } from "commander";
2
+ import { apiRequest, handleApiError } from "../client.js";
3
+ import { saveConfig } from "../config.js";
4
+ import { agentOutput } from "../output.js";
5
+ export const linkCmd = new Command("link")
6
+ .description("Link to an existing Naive account via email verification (passwordless)")
7
+ .requiredOption("--email <email>", "Account email address to link")
8
+ .addHelpText("after", `
9
+ Examples:
10
+ $ naive link --email alex@company.com
11
+ # Check your email for 6-digit code, then:
12
+ $ naive verify --email alex@company.com --code 123456
13
+
14
+ What this does:
15
+ 1. Sends a 6-digit verification code to the provided email
16
+ 2. After verifying, creates an API agent linked to your account
17
+ 3. Returns an API key for the linked account
18
+
19
+ When to use this:
20
+ - You have a Naive account but prefer passwordless login
21
+ - You created your account through a social provider (Google, etc.)
22
+ - You want to link a second machine/agent to an existing account
23
+
24
+ Flow:
25
+ naive link --email ... → check email → naive verify --email ... --code ...
26
+ `)
27
+ .action(async (opts) => {
28
+ const resp = await apiRequest("POST", "/v1/auth/link", { email: opts.email }, { noAuth: true });
29
+ handleApiError("link", resp);
30
+ agentOutput({
31
+ action: "link",
32
+ result: {
33
+ status: "verification_sent",
34
+ email: opts.email,
35
+ },
36
+ next_steps: [
37
+ { command: `naive verify --email ${opts.email} --code <6-digit-code>`, description: "Complete verification with the code from your email" },
38
+ ],
39
+ hints: [
40
+ "A 6-digit code has been sent to your email",
41
+ "The code expires in 10 minutes",
42
+ "Check spam folder if you don't see it",
43
+ ],
44
+ related_commands: ["naive verify", "naive login", "naive register"],
45
+ help_markdown: "### Verification Code Sent\n\nCheck the inbox for `" + opts.email + "` and use the 6-digit code to complete linking:\n\n```\nnaive verify --email " + opts.email + " --code <CODE>\n```",
46
+ });
47
+ });
48
+ export const verifyCmd = new Command("verify")
49
+ .description("Complete account linking with the emailed verification code")
50
+ .requiredOption("--email <email>", "Account email (same as used in 'naive link')")
51
+ .requiredOption("--code <code>", "6-digit verification code from email")
52
+ .addHelpText("after", `
53
+ Examples:
54
+ $ naive verify --email alex@company.com --code 482910
55
+
56
+ What this does:
57
+ 1. Validates the code against the pending verification
58
+ 2. Creates an API agent linked to the verified account
59
+ 3. Saves the API key to ~/.naive/config.json
60
+
61
+ Prerequisites:
62
+ - Must have run 'naive link --email ...' first
63
+ - Code must not be expired (10 minute window)
64
+ `)
65
+ .action(async (opts) => {
66
+ const resp = await apiRequest("POST", "/v1/auth/verify", {
67
+ email: opts.email,
68
+ code: opts.code,
69
+ }, { noAuth: true });
70
+ handleApiError("verify", resp);
71
+ const data = resp.data;
72
+ saveConfig({ api_key: data.api_key, agent_id: data.agent_id, company_id: data.company_id, company_name: data.company_name });
73
+ agentOutput({
74
+ action: "verify",
75
+ result: {
76
+ agent_id: data.agent_id,
77
+ companies: data.companies,
78
+ credentials_saved: "~/.naive/config.json",
79
+ },
80
+ next_steps: [
81
+ { command: "naive status", description: "Verify account and check credits" },
82
+ { command: "naive identity", description: "See resources available in this account" },
83
+ ...(data.companies?.length > 1
84
+ ? [{ command: "naive companies select <id>", description: "Choose which company to operate under" }]
85
+ : []),
86
+ ],
87
+ hints: ["Account linked successfully. All future commands use the saved API key."],
88
+ related_commands: ["naive whoami", "naive companies", "naive status"],
89
+ });
90
+ });
91
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../src/commands/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KACvC,WAAW,CAAC,yEAAyE,CAAC;KACtF,cAAc,CAAC,iBAAiB,EAAE,+BAA+B,CAAC;KAClE,WAAW,CAAC,OAAO,EAAE;;;;;;;;;;;;;;;;;;CAkBvB,CAAC;KACC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAChG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE7B,WAAW,CAAC;QACV,MAAM,EAAE,MAAM;QACd,MAAM,EAAE;YACN,MAAM,EAAE,mBAAmB;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB;QACD,UAAU,EAAE;YACV,EAAE,OAAO,EAAE,wBAAwB,IAAI,CAAC,KAAK,wBAAwB,EAAE,WAAW,EAAE,qDAAqD,EAAE;SAC5I;QACD,KAAK,EAAE;YACL,4CAA4C;YAC5C,gCAAgC;YAChC,uCAAuC;SACxC;QACD,gBAAgB,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,gBAAgB,CAAC;QACnE,aA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,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC;gBAC5B,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;gBACpG,CAAC,CAAC,EAAE,CAAC;SACR;QACD,KAAK,EAAE,CAAC,yEAAyE,CAAC;QAClF,gBAAgB,EAAE,CAAC,cAAc,EAAE,iBAAiB,EAAE,cAAc,CAAC;KACtE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const loginCmd: Command;
@@ -0,0 +1,63 @@
1
+ import { Command } from "commander";
2
+ import { apiRequest, handleApiError } from "../client.js";
3
+ import { saveConfig } from "../config.js";
4
+ import { agentOutput } from "../output.js";
5
+ export const loginCmd = new Command("login")
6
+ .description("Log in to an existing Naive account with email and password")
7
+ .requiredOption("--email <email>", "Account email address")
8
+ .requiredOption("--password <password>", "Account password")
9
+ .addHelpText("after", `
10
+ Examples:
11
+ $ naive login --email alex@company.com --password mypassword123
12
+
13
+ What this does:
14
+ 1. Authenticates with your email and password
15
+ 2. Issues a fresh API key for your default company
16
+ 3. Saves credentials to ~/.naive/config.json
17
+
18
+ Notes:
19
+ - If you have multiple companies, the first one is selected by default
20
+ - Use 'naive companies' then 'naive companies select <id>' to switch
21
+ - This uses the same credentials as the Naive dashboard (usenaive.ai)
22
+ - Each login creates a new API key (old keys remain valid)
23
+ `)
24
+ .action(async (opts) => {
25
+ const resp = await apiRequest("POST", "/v1/auth/login", {
26
+ email: opts.email,
27
+ password: opts.password,
28
+ }, { noAuth: true });
29
+ handleApiError("login", resp);
30
+ const data = resp.data;
31
+ saveConfig({
32
+ api_key: data.api_key,
33
+ agent_id: data.agent_id,
34
+ company_id: data.company_id,
35
+ company_name: data.company_name,
36
+ });
37
+ const hasMultipleCompanies = data.companies && data.companies.length > 1;
38
+ agentOutput({
39
+ action: "login",
40
+ result: {
41
+ agent_id: data.agent_id,
42
+ company_id: data.company_id,
43
+ company_name: data.company_name,
44
+ credentials_saved: "~/.naive/config.json",
45
+ companies: data.companies,
46
+ },
47
+ next_steps: [
48
+ { command: "naive status", description: "Check current credits and resources" },
49
+ { command: "naive identity", description: "View available resources for this company" },
50
+ ...(hasMultipleCompanies
51
+ ? [{ command: "naive companies select <id>", description: "Switch to a different company", when: "You want to operate under a different company" }]
52
+ : []),
53
+ ],
54
+ hints: [
55
+ "Logged in successfully — API key saved for automatic auth",
56
+ ...(hasMultipleCompanies
57
+ ? [`You have ${data.companies.length} companies. Currently using "${data.company_name}". Use 'naive companies' to see all.`]
58
+ : []),
59
+ ],
60
+ related_commands: ["naive whoami", "naive companies", "naive status", "naive keys list"],
61
+ });
62
+ });
63
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KACzC,WAAW,CAAC,6DAA6D,CAAC;KAC1E,cAAc,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;KAC1D,cAAc,CAAC,uBAAuB,EAAE,kBAAkB,CAAC;KAC3D,WAAW,CAAC,OAAO,EAAE;;;;;;;;;;;;;;CAcvB,CAAC;KACC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE;QACtD,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,QAA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c,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,CAAC;KACzF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const registerCmd: Command;
@@ -0,0 +1,68 @@
1
+ import { Command } from "commander";
2
+ import { apiRequest, handleApiError } from "../client.js";
3
+ import { saveConfig } from "../config.js";
4
+ import { agentOutput } from "../output.js";
5
+ export const registerCmd = new Command("register")
6
+ .description("Create a new Naive account with email and password")
7
+ .requiredOption("--name <name>", "Your name or agent identity name")
8
+ .requiredOption("--email <email>", "Email address for the account (must be unique)")
9
+ .requiredOption("--password <password>", "Account password (minimum 8 characters)")
10
+ .option("--company <name>", "Company name (defaults to \"<name>'s Company\")")
11
+ .addHelpText("after", `
12
+ Examples:
13
+ $ naive register --name "Alex" --email alex@company.com --password mypassword123
14
+ $ naive register --name "Build Agent" --email agent@acme.co --password s3cur3pw --company "Acme Corp"
15
+
16
+ What this does:
17
+ 1. Creates a user account (email + password)
18
+ 2. Creates a company workspace
19
+ 3. Provisions an API agent with 100 free credits
20
+ 4. Returns an API key saved to ~/.naive/config.json
21
+
22
+ After registration:
23
+ - Use 'naive status' to verify connectivity
24
+ - Use 'naive identity' to see provisioned resources
25
+ - Use 'naive email inboxes' to check available email addresses
26
+ - All subsequent commands authenticate automatically via the saved key
27
+ `)
28
+ .action(async (opts) => {
29
+ const resp = await apiRequest("POST", "/v1/auth/register", {
30
+ name: opts.name,
31
+ email: opts.email,
32
+ password: opts.password,
33
+ company_name: opts.company,
34
+ }, { noAuth: true });
35
+ handleApiError("register", resp);
36
+ const data = resp.data;
37
+ saveConfig({
38
+ api_key: data.api_key,
39
+ agent_id: data.agent_id,
40
+ company_id: data.company_id,
41
+ company_name: data.company_name,
42
+ });
43
+ agentOutput({
44
+ action: "register",
45
+ result: {
46
+ agent_id: data.agent_id,
47
+ company_id: data.company_id,
48
+ company_name: data.company_name,
49
+ credentials_saved: "~/.naive/config.json",
50
+ initial_credits: 100,
51
+ },
52
+ next_steps: [
53
+ { command: "naive status", description: "Verify account status and available credits" },
54
+ { command: "naive identity", description: "View provisioned resources (email inboxes, etc.)" },
55
+ { command: "naive email inboxes", description: "List email addresses available for sending" },
56
+ { command: "naive images generate \"a sunset over mountains\"", description: "Try generating an image" },
57
+ { command: "naive search \"latest AI news\"", description: "Try a web search" },
58
+ ],
59
+ hints: [
60
+ "Your API key is saved locally — all future commands authenticate automatically",
61
+ "You start with 100 free credits. Use 'naive usage' to track spending.",
62
+ "If you already have a Naive account from the dashboard, use 'naive login' instead",
63
+ ],
64
+ related_commands: ["naive login", "naive link", "naive whoami", "naive status"],
65
+ help_markdown: "### Account Created\n\nYour agent is ready. The API key has been saved to `~/.naive/config.json` and will be used automatically for all subsequent commands.\n\n**Credit System**: You start with 100 free credits. Operations cost:\n- Web search: 0.01 credits\n- Email send: 0.05 credits \n- Image generation: 0.5–2.0 credits (depends on model)\n- Video generation: 2.0–10.0 credits (depends on model/duration)\n- Deep research: 1.0–5.0 credits\n\nUse `naive usage` to monitor spending.",
66
+ });
67
+ });
68
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/commands/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KAC/C,WAAW,CAAC,oDAAoD,CAAC;KACjE,cAAc,CAAC,eAAe,EAAE,kCAAkC,CAAC;KACnE,cAAc,CAAC,iBAAiB,EAAE,gDAAgD,CAAC;KACnF,cAAc,CAAC,uBAAuB,EAAE,yCAAyC,C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OAAO,EAAE,iCAAiC,EAAE,WAAW,EAAE,kBAAkB,EAAE;SAChF;QACD,KAAK,EAAE;YACL,gFAAgF;YAChF,uEAAuE;YACvE,mFAAmF;SACpF;QACD,gBAAgB,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,CAAC;QAC/E,aAAa,EAAE,seAAse;KACtf,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const searchCmd: Command;
@@ -0,0 +1,209 @@
1
+ import { Command } from "commander";
2
+ import { apiRequest, handleApiError } from "../client.js";
3
+ import { agentOutput } from "../output.js";
4
+ export const searchCmd = new Command("search")
5
+ .description("Search the web, extract URLs, or run deep multi-source research")
6
+ .argument("[query]", "Search query (wrap in quotes if multi-word)")
7
+ .option("--count <n>", "Number of results to return (default: 5)", "5")
8
+ .addHelpText("after", `
9
+ Subcommands:
10
+ naive search <query> Quick web search (Tavily + Brave)
11
+ naive search url <url> Extract content from a specific URL
12
+ naive search research <query> Deep multi-source research (async)
13
+
14
+ Examples:
15
+ $ naive search "best project management tools 2025"
16
+ $ naive search "competitor analysis SaaS pricing" --count 10
17
+ $ naive search url https://example.com/pricing
18
+ $ naive search url https://news.ycombinator.com --extract "top 5 stories"
19
+ $ naive search research "market size for AI coding tools" --depth thorough
20
+
21
+ Quick Search:
22
+ Uses Tavily or Brave to return top web results with:
23
+ - Title, URL, snippet for each result
24
+ - Relevance scores (when available)
25
+ Cost: 1 credit
26
+
27
+ URL Extraction:
28
+ Fetches and extracts content from a single URL.
29
+ Optionally uses AI (Groq) to extract specific information.
30
+ Cost: 1 credit
31
+
32
+ Deep Research:
33
+ Multi-source, AI-synthesized research on a topic.
34
+ Returns a comprehensive report with citations.
35
+ Runs asynchronously for thorough/exhaustive — use --wait or check with 'naive jobs'.
36
+ Cost: 3 credits (quick), 5 credits (thorough), 8 credits (exhaustive)
37
+ `)
38
+ .action(async (query, opts) => {
39
+ if (!query) {
40
+ console.error(JSON.stringify({
41
+ success: false,
42
+ action: "search",
43
+ error: { code: "missing_argument", message: "Search query is required" },
44
+ recovery_steps: [
45
+ { command: 'naive search "your query here"', description: "Provide a search query" },
46
+ { command: "naive search --help", description: "See all search options and subcommands" },
47
+ ],
48
+ }, null, 2));
49
+ process.exit(1);
50
+ }
51
+ const resp = await apiRequest("POST", "/v1/search", { query, count: parseInt(opts.count) });
52
+ handleApiError("search", resp);
53
+ const data = resp.data;
54
+ const count = data.results?.length ?? 0;
55
+ agentOutput({
56
+ action: "search",
57
+ result: resp.data,
58
+ next_steps: [
59
+ ...(count > 0
60
+ ? [{ command: `naive search url ${data.results[0].url}`, description: "Extract full content from the top result" }]
61
+ : []),
62
+ { command: `naive search research "${query}"`, description: "Run deep research on this topic for a comprehensive report", when: "Quick results aren't sufficient" },
63
+ { command: `naive search "${query}" --count 10`, description: "Get more results" },
64
+ ],
65
+ hints: [
66
+ `Found ${count} results for "${query}"`,
67
+ "Use 'naive search url <url>' to extract full page content from any result",
68
+ "Use 'naive search research' for a synthesized multi-source report",
69
+ "Cost: 1 credit",
70
+ ],
71
+ related_commands: ["naive search url", "naive search research"],
72
+ });
73
+ });
74
+ searchCmd
75
+ .command("url <url>")
76
+ .description("Fetch and extract content from a specific URL")
77
+ .option("--extract <prompt>", "AI extraction prompt (e.g., 'pricing tiers', 'main features')")
78
+ .addHelpText("after", `
79
+ Examples:
80
+ $ naive search url https://example.com/pricing
81
+ $ naive search url https://news.ycombinator.com --extract "top 5 stories with links"
82
+ $ naive search url https://docs.example.com/api --extract "authentication methods"
83
+
84
+ What this does:
85
+ 1. Fetches the URL content (respects robots.txt)
86
+ 2. Extracts readable text from HTML
87
+ 3. If --extract is provided, uses AI (Groq) to extract specific information
88
+ 4. Returns the extracted content
89
+
90
+ Parameters:
91
+ url The URL to fetch and extract from
92
+ --extract Optional AI prompt for targeted extraction
93
+
94
+ Cost: 1 credit
95
+ `)
96
+ .action(async (url, opts) => {
97
+ const resp = await apiRequest("POST", "/v1/search/url", { url, extract: opts.extract });
98
+ handleApiError("search.url", resp);
99
+ agentOutput({
100
+ action: "search.url",
101
+ result: resp.data,
102
+ next_steps: [
103
+ { command: `naive search url ${url} --extract "<specific question>"`, description: "Re-extract with a more specific prompt", when: "You need different information from the same page" },
104
+ { command: 'naive search "related topic"', description: "Search for related information" },
105
+ { command: `naive search research "analysis of ${url}"`, description: "Run deep research incorporating this source" },
106
+ ],
107
+ hints: [
108
+ "Use --extract to focus on specific information from the page",
109
+ "Cost: 1 credit",
110
+ ],
111
+ related_commands: ["naive search", "naive search research"],
112
+ });
113
+ });
114
+ searchCmd
115
+ .command("research <query>")
116
+ .description("Run deep multi-source AI research (async — returns a job)")
117
+ .option("--depth <level>", "Research depth: quick | thorough | exhaustive (default: quick)", "quick")
118
+ .option("--wait", "Poll until research completes (otherwise returns job ID)")
119
+ .addHelpText("after", `
120
+ Examples:
121
+ $ naive search research "market size for AI developer tools" --depth thorough
122
+ $ naive search research "competitive analysis: Figma vs Canva" --depth exhaustive --wait
123
+ $ naive search research "best practices for microservice auth" --depth quick
124
+
125
+ What this does:
126
+ 1. Submits a research query to the async job system
127
+ 2. The system searches multiple sources, synthesizes with AI (Groq)
128
+ 3. Returns a comprehensive report with sections and citations
129
+
130
+ Depth levels:
131
+ quick - 5 sources, basic synthesis (sync, 3 credits)
132
+ thorough - 8 sources, detailed synthesis (async ~45s, 5 credits)
133
+ exhaustive - 15 sources, comprehensive report (async ~90s, 8 credits)
134
+
135
+ Without --wait:
136
+ Returns a job_id immediately. Check status with 'naive jobs get <id>'.
137
+
138
+ With --wait:
139
+ Blocks until completion, then outputs the full report.
140
+
141
+ Cost: 3–8 credits (deducted on completion, not submission)
142
+ `)
143
+ .action(async (query, opts) => {
144
+ const resp = await apiRequest("POST", "/v1/search/research", { query, depth: opts.depth });
145
+ handleApiError("search.research", resp);
146
+ if (resp.status === 202) {
147
+ const data = resp.data;
148
+ if (opts.wait) {
149
+ agentOutput({
150
+ action: "search.research.submitted",
151
+ result: { job_id: data.job_id, status: "polling" },
152
+ next_steps: [],
153
+ hints: ["Waiting for research to complete..."],
154
+ });
155
+ await pollJob(data.job_id);
156
+ }
157
+ else {
158
+ agentOutput({
159
+ action: "search.research.submitted",
160
+ result: { job_id: data.job_id, status: "queued", depth: opts.depth },
161
+ next_steps: [
162
+ { command: `naive jobs get ${data.job_id}`, description: "Check research progress" },
163
+ { command: "naive jobs --status processing", description: "List all active jobs" },
164
+ ],
165
+ hints: [
166
+ `Research job submitted (depth: ${opts.depth})`,
167
+ "Credits will be deducted only on successful completion",
168
+ `Expected completion: ${opts.depth === "quick" ? "~30s" : opts.depth === "thorough" ? "~60s" : "~120s"}`,
169
+ ],
170
+ related_commands: ["naive jobs get", "naive jobs", "naive jobs cancel"],
171
+ });
172
+ }
173
+ }
174
+ else {
175
+ agentOutput({
176
+ action: "search.research",
177
+ result: resp.data,
178
+ next_steps: [
179
+ { command: 'naive search "follow-up query"', description: "Quick search for additional context" },
180
+ ],
181
+ hints: ["Research completed synchronously (quick depth)"],
182
+ related_commands: ["naive search", "naive search url"],
183
+ });
184
+ }
185
+ });
186
+ async function pollJob(jobId) {
187
+ while (true) {
188
+ await new Promise((r) => setTimeout(r, 3000));
189
+ const resp = await apiRequest("GET", `/v1/jobs/${jobId}`);
190
+ const data = resp.data;
191
+ if (data.status === "completed" || data.status === "failed") {
192
+ agentOutput({
193
+ action: "search.research.completed",
194
+ result: resp.data,
195
+ next_steps: [
196
+ { command: 'naive search "related topic"', description: "Search for additional information" },
197
+ { command: "naive search url <url>", description: "Deep-dive into a specific source from the report" },
198
+ ],
199
+ hints: [
200
+ data.status === "completed" ? "Research completed successfully" : "Research failed — no credits deducted",
201
+ ],
202
+ related_commands: ["naive search", "naive search url", "naive jobs"],
203
+ });
204
+ return;
205
+ }
206
+ process.stderr.write(` Progress: ${data.progress ?? 0}% (${data.status})\n`);
207
+ }
208
+ }
209
+ //# sourceMappingURL=search.js.map
@@ -0,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