@browserbasehq/cli 0.2.0 → 0.3.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/dist/cli.js CHANGED
@@ -1,10 +1,14 @@
1
+ import { createRequire } from "node:module";
1
2
  import { Command, CommanderError } from "commander";
2
3
  import { attachBrowseCommand } from "./commands/browse.js";
4
+ const require = createRequire(import.meta.url);
5
+ const { version } = require("../package.json");
3
6
  import { attachContextsCommand } from "./commands/contexts.js";
4
7
  import { attachDashboardCommand } from "./commands/dashboard.js";
5
8
  import { attachExtensionsCommand } from "./commands/extensions.js";
6
9
  import { attachFetchCommand } from "./commands/fetch.js";
7
10
  import { attachFunctionsCommand } from "./commands/functions.js";
11
+ import { attachSearchCommand } from "./commands/search.js";
8
12
  import { attachProjectsCommand } from "./commands/projects.js";
9
13
  import { attachSessionsCommand } from "./commands/sessions.js";
10
14
  import { attachSkillsCommand } from "./commands/skills.js";
@@ -13,7 +17,7 @@ export function buildProgram() {
13
17
  program
14
18
  .name("bb")
15
19
  .description("Browserbase CLI for platform APIs, functions, and browse passthrough.")
16
- .version("0.1.0")
20
+ .version(version)
17
21
  .helpCommand(false)
18
22
  .showHelpAfterError()
19
23
  .showSuggestionAfterError()
@@ -21,6 +25,7 @@ export function buildProgram() {
21
25
  .exitOverride();
22
26
  attachBrowseCommand(program);
23
27
  attachFetchCommand(program);
28
+ attachSearchCommand(program);
24
29
  attachSessionsCommand(program);
25
30
  attachDashboardCommand(program);
26
31
  attachFunctionsCommand(program);
@@ -0,0 +1,42 @@
1
+ import { addCommonApiOptions, outputJson, requestBrowserbaseJson, writeOutputFile, } from "../lib/command.js";
2
+ export function attachSearchCommand(program) {
3
+ addCommonApiOptions(program
4
+ .command("search <query>")
5
+ .description("Search the web using the Browserbase Search API.")
6
+ .option("--num-results <count>", "Number of results to return (1-25, default 10).")
7
+ .option("--output <output>", "Write the search results as JSON to a file.")).action(async (query, options) => {
8
+ const numResults = options.numResults ? parseInt(options.numResults, 10) : undefined;
9
+ const result = await requestBrowserbaseJson(options, "/v1/search", {
10
+ method: "POST",
11
+ headers: { "Content-Type": "application/json" },
12
+ body: JSON.stringify({ query, numResults }),
13
+ });
14
+ if (options.output) {
15
+ await writeOutputFile(options.output, JSON.stringify(result, null, 2));
16
+ if (options.json) {
17
+ outputJson({ ...result, outputPath: options.output });
18
+ return;
19
+ }
20
+ console.log(`Saved search results to ${options.output}`);
21
+ return;
22
+ }
23
+ if (options.json) {
24
+ outputJson(result);
25
+ return;
26
+ }
27
+ for (const [i, r] of result.results.entries()) {
28
+ const num = i + 1;
29
+ console.log(`${String(num)}. ${r.title}`);
30
+ console.log(` ${r.url}`);
31
+ const meta = [];
32
+ if (r.author)
33
+ meta.push(r.author);
34
+ if (r.publishedDate)
35
+ meta.push(r.publishedDate);
36
+ if (meta.length > 0) {
37
+ console.log(` ${meta.join(" · ")}`);
38
+ }
39
+ console.log();
40
+ }
41
+ });
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserbasehq/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Browserbase CLI for platform APIs, functions, and browse passthrough.",
5
5
  "type": "module",
6
6
  "private": false,