@pollinations/cli 0.1.91 → 0.1.93

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
@@ -30,7 +30,7 @@ Every command is agent-friendly:
30
30
 
31
31
  - `--json` — structured stdout, human messages to stderr. Safe to parse.
32
32
  - Exit code `0` on success, non-zero on error.
33
- - A 402 error links to your balance, Quests, and top-up options.
33
+ - A generation budget refusal explains which limit blocked the request and how to resolve it.
34
34
  - `polli auth status --json` (or `polli whoami --json`) exposes everything about the current session.
35
35
 
36
36
  ## Other ways to start
@@ -224,7 +224,7 @@ keeps its history while the editor runs.
224
224
 
225
225
  ## Sandboxes
226
226
 
227
- Linux VMs on E2B or Azure, paid from your wallet (alpha).
227
+ Linux VMs on E2B or Azure, billed to your Pollinations balance (alpha).
228
228
 
229
229
  ```bash
230
230
  polli sandbox create # prints the id and sets up ssh
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- export { }
2
+ export { };
package/dist/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __esm = (fn, res) => function __init() {
4
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
3
+ var __esm = (fn, res, err) => function __init() {
4
+ if (err) throw err[0];
5
+ try {
6
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
+ } catch (e) {
8
+ throw err = [e], e;
9
+ }
5
10
  };
6
11
  var __export = (target, all) => {
7
12
  for (var name in all)
@@ -14,7 +19,7 @@ var init_package = __esm({
14
19
  "package.json"() {
15
20
  package_default = {
16
21
  name: "@pollinations/cli",
17
- version: "0.1.91",
22
+ version: "0.1.93",
18
23
  description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
19
24
  type: "module",
20
25
  bin: {
@@ -89,7 +94,7 @@ var init_package = __esm({
89
94
  "@types/cross-spawn": "^6.0.6",
90
95
  "@types/node": "^22.20.1",
91
96
  "@types/update-notifier": "^6.0.8",
92
- tsup: "^8.4.0",
97
+ tsup: "^9.0.0",
93
98
  typescript: "^5.7.0",
94
99
  vitest: "^4.1.12"
95
100
  }
@@ -302,6 +307,18 @@ var init_output = __esm({
302
307
  });
303
308
 
304
309
  // src/lib/api.ts
310
+ function paymentHint(status4, body) {
311
+ if (status4 !== 402) return null;
312
+ try {
313
+ const result10 = JSON.parse(body);
314
+ const message = result10?.error?.message ?? result10?.message;
315
+ if (typeof message === "string" && message.trim())
316
+ return message.trim();
317
+ } catch {
318
+ if (body.trim()) return body.trim();
319
+ }
320
+ return `Payment required. Check your balance and key budget at ${ENTER_URL}`;
321
+ }
305
322
  var ApiError, requireKey, PERMISSION_HINTS, permissionHint, send, request, gen, genText, genResponse;
306
323
  var init_api = __esm({
307
324
  "src/lib/api.ts"() {
@@ -359,7 +376,7 @@ Or allow it for this login: ${grant}` : hint;
359
376
  const text = await res.text().catch(() => "Unknown error");
360
377
  throw new ApiError(
361
378
  res.status,
362
- permissionHint(res.status, text) ?? `${res.status} ${res.statusText}: ${text}`,
379
+ paymentHint(res.status, text) ?? permissionHint(res.status, text) ?? `${res.status} ${res.statusText}: ${text}`,
363
380
  text
364
381
  );
365
382
  }
@@ -1521,39 +1538,6 @@ init_client();
1521
1538
  init_config();
1522
1539
  init_output();
1523
1540
  import { createInterface } from "readline/promises";
1524
- async function budgetHint(status4, bodyText) {
1525
- if (status4 !== 402) return null;
1526
- let code;
1527
- try {
1528
- code = JSON.parse(bodyText)?.error?.code;
1529
- } catch {
1530
- }
1531
- if (code === "KEY_BUDGET_EXHAUSTED") {
1532
- return [
1533
- "API key budget exhausted. Topping up the wallet does not increase the key budget.",
1534
- "Manage key budget: https://enter.pollinations.ai/keys",
1535
- `Server said: ${bodyText}`
1536
- ].join("\n");
1537
- }
1538
- const balance = await gen(
1539
- "/account/balance",
1540
- {
1541
- apiKey: requireKey()
1542
- }
1543
- ).then((r) => r.accountBalance?.total).catch(() => null);
1544
- const lines = [
1545
- code === "INSUFFICIENT_BALANCE" ? "Balance too low." : "Check your balance and API key budget.",
1546
- "Balance: https://enter.pollinations.ai/pollen",
1547
- "Complete Quests to add to your balance: https://enter.pollinations.ai/quests",
1548
- "Top up: https://enter.pollinations.ai/pollen#buy-pollen",
1549
- ...code === "INSUFFICIENT_BALANCE" ? [] : ["Manage key budget: https://enter.pollinations.ai/keys"],
1550
- ""
1551
- ];
1552
- if (balance != null)
1553
- lines.push(`Account balance: ${formatDollars(balance)}`);
1554
- lines.push(`Server said: ${bodyText}`);
1555
- return lines.join("\n");
1556
- }
1557
1541
  async function generationKey() {
1558
1542
  const key = resolveApiKey();
1559
1543
  if (key) return key;
@@ -1586,7 +1570,7 @@ async function fetchGen(path, init = {}) {
1586
1570
  });
1587
1571
  if (response.ok) return response;
1588
1572
  const body = await response.text().catch(() => "");
1589
- const message = await budgetHint(response.status, body) ?? `${response.status} ${response.statusText}: ${body}`;
1573
+ const message = paymentHint(response.status, body) ?? `${response.status} ${response.statusText}: ${body}`;
1590
1574
  throw new ApiError(response.status, message);
1591
1575
  }
1592
1576
  function exitWithError(error) {
@@ -1864,7 +1848,7 @@ Chat session started (model: ${opts.model ?? "API default"})
1864
1848
  });
1865
1849
  if (!res.ok) {
1866
1850
  const errText = await res.text().catch(() => "");
1867
- const hint = await budgetHint(res.status, errText);
1851
+ const hint = paymentHint(res.status, errText);
1868
1852
  if (hint) {
1869
1853
  printError(hint);
1870
1854
  stopped = true;