@pollinations/cli 0.1.68 → 0.1.70
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 +22 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
17
|
+
version: "0.1.70",
|
|
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
|
}
|
|
@@ -2212,16 +2224,19 @@ var resolveHarnessKey = async (harness, options) => {
|
|
|
2212
2224
|
return existing;
|
|
2213
2225
|
}
|
|
2214
2226
|
const accountKey = resolveApiKey() ?? await loginWithDeviceFlow({ browser: options.browser });
|
|
2215
|
-
const login2 = await gen(
|
|
2216
|
-
"/account/key",
|
|
2217
|
-
{ apiKey: accountKey }
|
|
2218
|
-
);
|
|
2227
|
+
const login2 = await gen("/account/key", { apiKey: accountKey });
|
|
2219
2228
|
if (!login2.permissions.account?.includes("keys")) {
|
|
2220
2229
|
printInfo(
|
|
2221
2230
|
`${harness.label} uses the polli login, which can't create keys.`
|
|
2222
2231
|
);
|
|
2223
2232
|
return accountKey;
|
|
2224
2233
|
}
|
|
2234
|
+
if (login2.pollenBudget != null) {
|
|
2235
|
+
printInfo(
|
|
2236
|
+
`${harness.label} uses the polli login and its pollen budget.`
|
|
2237
|
+
);
|
|
2238
|
+
return accountKey;
|
|
2239
|
+
}
|
|
2225
2240
|
const name = `polli-harness-${harness.id}`;
|
|
2226
2241
|
const created = await gen("/account/keys", {
|
|
2227
2242
|
method: "POST",
|