@pollinations/cli 0.1.68 → 0.1.69

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/index.js CHANGED
@@ -14,7 +14,7 @@ var init_package = __esm({
14
14
  "package.json"() {
15
15
  package_default = {
16
16
  name: "@pollinations/cli",
17
- version: "0.1.68",
17
+ version: "0.1.69",
18
18
  description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
19
19
  type: "module",
20
20
  bin: {
@@ -292,7 +292,7 @@ var init_output = __esm({
292
292
  });
293
293
 
294
294
  // src/lib/api.ts
295
- var ApiError, requireKey, send, request, gen, genText;
295
+ var ApiError, requireKey, PERMISSION_HINTS, permissionHint, send, request, gen, genText;
296
296
  var init_api = __esm({
297
297
  "src/lib/api.ts"() {
298
298
  "use strict";
@@ -319,6 +319,18 @@ var init_api = __esm({
319
319
  }
320
320
  return key;
321
321
  };
322
+ PERMISSION_HINTS = {
323
+ keys: 'Your login didn\'t allow managing keys, agents and models. Run `polli auth login` again and tick "Manage keys, agents and models".',
324
+ machines: 'Your login didn\'t allow sandboxes or sites. Run `polli auth login` again and tick "Run hosted sandboxes".'
325
+ };
326
+ permissionHint = (status4, text) => {
327
+ const permission = status4 === 403 && text.match(/'account:(keys|machines)'/)?.[1];
328
+ if (!permission) return void 0;
329
+ const grant = text.match(/https:\/\/[^\s"]+\/grant\?[^\s"]+/)?.[0];
330
+ const hint = PERMISSION_HINTS[permission];
331
+ return grant ? `${hint}
332
+ Or allow it for this login: ${grant}` : hint;
333
+ };
322
334
  send = async (baseUrl, path, options = {}) => {
323
335
  const { method = "GET", body, apiKey } = options;
324
336
  const key = resolveApiKey(apiKey);
@@ -336,7 +348,7 @@ var init_api = __esm({
336
348
  const text = await res.text().catch(() => "Unknown error");
337
349
  throw new ApiError(
338
350
  res.status,
339
- `${res.status} ${res.statusText}: ${text}`,
351
+ permissionHint(res.status, text) ?? `${res.status} ${res.statusText}: ${text}`,
340
352
  text
341
353
  );
342
354
  }