@tiny-fish/cli 0.1.4-next.40 → 0.1.4-next.43

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 CHANGED
@@ -88,6 +88,19 @@ tinyfish fetch content get https://agentql.com --links --image-links
88
88
  tinyfish fetch content get https://agentql.com --pretty
89
89
  ```
90
90
 
91
+ ### Browser
92
+
93
+ ```bash
94
+ # Create a remote browser session
95
+ tinyfish browser session create
96
+
97
+ # Open a URL when the session starts
98
+ tinyfish browser session create --url https://agentql.com
99
+
100
+ # Human-readable output
101
+ tinyfish browser session create --pretty
102
+ ```
103
+
91
104
  ### Output format
92
105
 
93
106
  By default all commands output newline-delimited JSON to stdout — pipe-friendly for agents and scripts. Add `--pretty` for human-readable output.
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerBrowser(program: Command): void;
@@ -0,0 +1,41 @@
1
+ import { getApiKey } from "../lib/auth.js";
2
+ import { browserSessionCreate } from "../lib/client.js";
3
+ import { handleApiError, out, outLine } from "../lib/output.js";
4
+ function printPrettyBrowserSession(session) {
5
+ outLine("Browser session created");
6
+ outLine(`Session ID: ${session.session_id}`);
7
+ outLine(`CDP URL: ${session.cdp_url}`);
8
+ outLine(`Base URL: ${session.base_url}`);
9
+ }
10
+ export function registerBrowser(program) {
11
+ const browserCmd = program
12
+ .command("browser")
13
+ .description("Browser commands")
14
+ .enablePositionalOptions();
15
+ const sessionCmd = browserCmd
16
+ .command("session")
17
+ .description("Manage browser sessions")
18
+ .enablePositionalOptions();
19
+ sessionCmd
20
+ .command("create")
21
+ .description("Create a remote browser session")
22
+ .option("--url <value>", "Open a URL after session creation")
23
+ .option("--pretty", "Human-readable output")
24
+ .action(async (opts) => {
25
+ const apiKey = getApiKey();
26
+ try {
27
+ const response = await browserSessionCreate({
28
+ ...(opts.url !== undefined ? { url: opts.url } : {}),
29
+ }, apiKey);
30
+ if (opts.pretty) {
31
+ printPrettyBrowserSession(response);
32
+ }
33
+ else {
34
+ out(response);
35
+ }
36
+ }
37
+ catch (error) {
38
+ handleApiError(error);
39
+ }
40
+ });
41
+ }
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { Command } from "commander";
4
4
  import { registerAuth } from "./commands/auth.js";
5
5
  import { registerBatch } from "./commands/batch.js";
6
6
  import { registerFetch } from "./commands/fetch.js";
7
+ import { registerBrowser } from "./commands/browser.js";
7
8
  import { registerRun } from "./commands/run.js";
8
9
  import { registerRuns } from "./commands/runs.js";
9
10
  import { registerSearch } from "./commands/search.js";
@@ -23,6 +24,7 @@ program
23
24
  }
24
25
  });
25
26
  registerAuth(program);
27
+ registerBrowser(program);
26
28
  const agentCmd = program
27
29
  .command("agent")
28
30
  .description("Agent automation commands")
@@ -1,4 +1,4 @@
1
- import { type AgentRunAsyncResponse, type AgentRunParams, type AgentRunResponse, type AgentRunWithStreamingResponse, type FetchGetContentsParams, type FetchResponse, type Run, type RunListParams, type RunListResponse, type SearchQueryParams, type SearchQueryResponse } from "@tiny-fish/sdk";
1
+ import { type AgentRunAsyncResponse, type AgentRunParams, type AgentRunResponse, type AgentRunWithStreamingResponse, type FetchGetContentsParams, type FetchResponse, type BrowserSession, type BrowserSessionCreateParams, type Run, type RunListParams, type RunListResponse, type SearchQueryParams, type SearchQueryResponse } from "@tiny-fish/sdk";
2
2
  import type { BatchCancelResponse, BatchGetResponse, BatchRunRequest, BatchRunResponse, CancelRunResponse } from "./types.js";
3
3
  export declare function runSync(req: AgentRunParams, apiKey: string): Promise<AgentRunResponse>;
4
4
  export declare function runAsync(req: AgentRunParams, apiKey: string): Promise<AgentRunAsyncResponse>;
@@ -7,6 +7,7 @@ export declare function listRuns(opts: RunListParams, apiKey: string): Promise<R
7
7
  export declare function getRun(runId: string, apiKey: string): Promise<Run>;
8
8
  export declare function searchQuery(params: SearchQueryParams, apiKey: string): Promise<SearchQueryResponse>;
9
9
  export declare function fetchContentGet(params: FetchGetContentsParams, apiKey: string): Promise<FetchResponse>;
10
+ export declare function browserSessionCreate(params: BrowserSessionCreateParams, apiKey: string): Promise<BrowserSession>;
10
11
  export declare function cancelRun(runId: string, apiKey: string): Promise<CancelRunResponse>;
11
12
  export declare function submitBatch(req: BatchRunRequest, apiKey: string): Promise<BatchRunResponse>;
12
13
  export declare function getBatchRuns(runIds: string[], apiKey: string): Promise<BatchGetResponse>;
@@ -1,4 +1,4 @@
1
- import { APIStatusError, fetchResponseSchema, searchQueryResponseSchema, TinyFish, runSchema, } from "@tiny-fish/sdk";
1
+ import { APIStatusError, fetchResponseSchema, browserSessionSchema, searchQueryResponseSchema, TinyFish, runSchema, } from "@tiny-fish/sdk";
2
2
  import { BASE_URL } from "./constants.js";
3
3
  import { ApiError } from "./output.js";
4
4
  import { z } from "zod";
@@ -133,6 +133,15 @@ export async function fetchContentGet(params, apiKey) {
133
133
  rethrowSdkError(error);
134
134
  }
135
135
  }
136
+ export async function browserSessionCreate(params, apiKey) {
137
+ try {
138
+ const response = await createSdkClient(apiKey).browser.sessions.create(params);
139
+ return browserSessionSchema.parse(response);
140
+ }
141
+ catch (error) {
142
+ rethrowSdkError(error);
143
+ }
144
+ }
136
145
  export async function cancelRun(runId, apiKey) {
137
146
  try {
138
147
  const response = await createSdkClient(apiKey).post(`/v1/runs/${encodeURIComponent(runId)}/cancel`, { json: {} });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-fish/cli",
3
- "version": "0.1.4-next.40",
3
+ "version": "0.1.4-next.43",
4
4
  "description": "TinyFish CLI — run web automations from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,13 +18,14 @@
18
18
  "test:watch": "vitest",
19
19
  "test:integration:auth": "vitest --run --config vitest.integration.config.ts tests/auth.integration.test.ts",
20
20
  "test:integration:api:fetch": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"fetch content get|skips real API coverage when TINYFISH_API_KEY is not set\"",
21
+ "test:integration:api:browser": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"browser session create|skips real API coverage when TINYFISH_API_KEY is not set\"",
21
22
  "test:integration:api:search": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"search query|skips real API coverage when TINYFISH_API_KEY is not set\"",
22
23
  "test:integration:api:sync": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"agent run --sync|skips real API coverage when TINYFISH_API_KEY is not set\"",
23
24
  "test:integration:api:stream": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"agent run streaming exits cleanly after COMPLETE|skips real API coverage when TINYFISH_API_KEY is not set\"",
24
25
  "test:integration:api:async": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"agent run --async returns a run id that can be fetched and listed|skips real API coverage when TINYFISH_API_KEY is not set\"",
25
26
  "test:integration:api:cancel": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"agent run cancel cancels an in-flight run|skips real API coverage when TINYFISH_API_KEY is not set\"",
26
27
  "test:integration:api:batch": "vitest --run --passWithNoTests --config vitest.integration.config.ts tests/api.integration.test.ts --testNamePattern \"batch commands work end-to-end against the real API|skips real API coverage when TINYFISH_API_KEY is not set\"",
27
- "test:integration": "npm run test:integration:auth && npm run test:integration:api:fetch && npm run test:integration:api:search && npm run test:integration:api:sync && npm run test:integration:api:stream && npm run test:integration:api:async && npm run test:integration:api:cancel && npm run test:integration:api:batch",
28
+ "test:integration": "npm run test:integration:auth && npm run test:integration:api:fetch && npm run test:integration:api:browser && npm run test:integration:api:search && npm run test:integration:api:sync && npm run test:integration:api:stream && npm run test:integration:api:async && npm run test:integration:api:cancel && npm run test:integration:api:batch",
28
29
  "lint": "eslint src tests",
29
30
  "format": "prettier --write src tests",
30
31
  "type-check": "tsc --noEmit --project tsconfig.all.json",
@@ -47,6 +48,7 @@
47
48
  "vitest": "^3.0.0"
48
49
  },
49
50
  "overrides": {
51
+ "vite": "7.3.2",
50
52
  "brace-expansion": "5.0.5"
51
53
  },
52
54
  "engines": {