@tiny-fish/cli 0.17.1-next.166 → 0.17.1-next.168

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
@@ -259,6 +259,16 @@ tinyfish agent run "..." --url https://example.com --use-vault \
259
259
 
260
260
  `--credential-item-id` requires `--use-vault`. Omit it to use all enabled items. The IDs are the `itemId` values from `tinyfish vault item list` (run `vault item sync` first if the list is empty after connecting). Credential items are sourced from the connected provider — the CLI has no freeform credential create/edit (mirrors the API).
261
261
 
262
+ ### Wallet
263
+
264
+ ```bash
265
+ # Check balance, auto-reload, pending top-up, and per-meter rates
266
+ tinyfish wallet status
267
+
268
+ # Human-readable output
269
+ tinyfish wallet status --pretty
270
+ ```
271
+
262
272
  ### Output format
263
273
 
264
274
  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 registerWallet(program: Command): void;
@@ -0,0 +1,57 @@
1
+ import { WalletAutoReloadState } from "@tiny-fish/sdk";
2
+ import { getApiKey } from "../lib/auth.js";
3
+ import { getWallet } from "../lib/client.js";
4
+ import { handleApiError, out, outLine } from "../lib/output.js";
5
+ function formatWallet(wallet) {
6
+ outLine(`Balance: ${wallet.available_balance} ${wallet.currency}`);
7
+ if (wallet.auto_reload === null) {
8
+ outLine("Auto-reload: unavailable");
9
+ }
10
+ else if (wallet.auto_reload.state === WalletAutoReloadState.UNCONFIGURED) {
11
+ outLine("Auto-reload: unconfigured");
12
+ }
13
+ else {
14
+ const { state, threshold, recharge_to } = wallet.auto_reload;
15
+ outLine(`Auto-reload: ${state} (threshold ${threshold}, recharge to ${recharge_to})`);
16
+ }
17
+ if (wallet.pending_top_up === null) {
18
+ outLine("Pending top-up: none");
19
+ }
20
+ else {
21
+ outLine(`Pending top-up: ${wallet.pending_top_up.amount} (started ${wallet.pending_top_up.started_at})`);
22
+ }
23
+ if (wallet.rates === null) {
24
+ outLine("Rates: unavailable");
25
+ }
26
+ else if (wallet.rates.meters.length === 0) {
27
+ outLine("Rates: none");
28
+ }
29
+ else {
30
+ for (const meter of wallet.rates.meters) {
31
+ const per = meter.per ? `/${meter.per}` : "";
32
+ outLine(`${meter.label}: ${meter.unit_amount} ${meter.currency}${per}`);
33
+ }
34
+ }
35
+ }
36
+ export function registerWallet(program) {
37
+ const wallet = program.command("wallet").description("View your TinyFish wallet");
38
+ wallet
39
+ .command("status")
40
+ .description("Show wallet balance, auto-reload, pending top-up, and rates")
41
+ .option("--pretty", "Human-readable output")
42
+ .action(async (opts) => {
43
+ const apiKey = getApiKey();
44
+ try {
45
+ const result = await getWallet(apiKey);
46
+ if (opts.pretty) {
47
+ formatWallet(result);
48
+ }
49
+ else {
50
+ out(result);
51
+ }
52
+ }
53
+ catch (e) {
54
+ handleApiError(e);
55
+ }
56
+ });
57
+ }
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ import { registerFetch } from "./commands/fetch.js";
7
7
  import { registerBrowser } from "./commands/browser.js";
8
8
  import { registerProfile } from "./commands/profile.js";
9
9
  import { registerVault } from "./commands/vault.js";
10
+ import { registerWallet } from "./commands/wallet.js";
10
11
  import { registerRun } from "./commands/run.js";
11
12
  import { registerRuns } from "./commands/runs.js";
12
13
  import { registerConfigureClaude } from "./commands/config-claude.js";
@@ -39,6 +40,7 @@ registerConfigureClaude(program);
39
40
  registerBrowser(program);
40
41
  registerProfile(program);
41
42
  registerVault(program);
43
+ registerWallet(program);
42
44
  const agentCmd = program
43
45
  .command("agent")
44
46
  .description("Agent automation commands")
@@ -1,4 +1,4 @@
1
- import { type AgentRunAsyncResponse, type AgentRunResponse, type AgentRunWithStreamingResponse, type FetchGetContentsParams, type FetchResponse, type BrowserSession, type Run, type RunListParams, type RunListResponse, type SearchQueryParams, type SearchQueryResponse } from "@tiny-fish/sdk";
1
+ import { type AgentRunAsyncResponse, type AgentRunResponse, type AgentRunWithStreamingResponse, type FetchGetContentsParams, type FetchResponse, type BrowserSession, type Run, type RunListParams, type RunListResponse, type SearchQueryParams, type SearchQueryResponse, type WalletResponse } from "@tiny-fish/sdk";
2
2
  import type { BatchCancelResponse, BatchGetResponse, BatchRunRequest, BatchRunResponse, CancelRunResponse, CliAgentRunParams, CliBrowserSessionCreateParams, CookieRecord, ProfileCreateResponse, ProfileUploadResponse, RunStepsResponse, VaultConnectRequest, VaultConnectResponse, VaultConnectionsListResponse, VaultDisconnectResponse, VaultItemsListResponse, VaultItemsSyncResponse } from "./types.js";
3
3
  type ConnectMap = Record<string, {
4
4
  attempt_id: string;
@@ -14,6 +14,7 @@ export declare function searchQuery(params: SearchQueryParams, apiKey: string):
14
14
  export declare function fetchContentGet(params: FetchGetContentsParams, apiKey: string): Promise<FetchResponse>;
15
15
  export declare function browserSessionCreate(params: CliBrowserSessionCreateParams, apiKey: string): Promise<BrowserSession>;
16
16
  export declare function cancelRun(runId: string, apiKey: string): Promise<CancelRunResponse>;
17
+ export declare function getWallet(apiKey: string): Promise<WalletResponse>;
17
18
  export declare function submitBatch(req: BatchRunRequest, apiKey: string): Promise<BatchRunResponse>;
18
19
  export declare function getBatchRuns(runIds: string[], apiKey: string): Promise<BatchGetResponse>;
19
20
  export declare function cancelBatchRuns(runIds: string[], apiKey: string): Promise<BatchCancelResponse>;
@@ -323,6 +323,15 @@ export async function cancelRun(runId, apiKey) {
323
323
  rethrowSdkError(error);
324
324
  }
325
325
  }
326
+ // ── Wallet ──────────────────────────────────────────────────────────────────
327
+ export async function getWallet(apiKey) {
328
+ try {
329
+ return await createSdkClient(apiKey).wallet.get();
330
+ }
331
+ catch (error) {
332
+ rethrowSdkError(error);
333
+ }
334
+ }
326
335
  export async function submitBatch(req, apiKey) {
327
336
  try {
328
337
  const response = await createSdkClient(apiKey).post("/v1/automation/run-batch", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-fish/cli",
3
- "version": "0.17.1-next.166",
3
+ "version": "0.17.1-next.168",
4
4
  "description": "TinyFish CLI — run web automations from your terminal",
5
5
  "type": "module",
6
6
  "bin": {