@pollinations/cli 0.1.80 → 0.1.82
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 +30 -28
- 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.82",
|
|
18
18
|
description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
|
|
19
19
|
type: "module",
|
|
20
20
|
bin: {
|
|
@@ -547,14 +547,23 @@ async function showAuthStatus() {
|
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
549
|
const masked = `${key.slice(0, 5)}...${key.slice(-6)}`;
|
|
550
|
+
const rejectedKey = (error) => error instanceof ApiError && error.status === 401 ? error : null;
|
|
550
551
|
const [profile, balance] = await Promise.all([
|
|
551
552
|
gen("/account/profile", { apiKey: key }).catch(
|
|
552
|
-
|
|
553
|
+
rejectedKey
|
|
553
554
|
),
|
|
554
555
|
gen("/account/balance", { apiKey: key }).catch(
|
|
555
|
-
|
|
556
|
+
rejectedKey
|
|
556
557
|
)
|
|
557
558
|
]);
|
|
559
|
+
if (profile instanceof ApiError || balance instanceof ApiError) {
|
|
560
|
+
printResult({
|
|
561
|
+
authenticated: false,
|
|
562
|
+
key: masked,
|
|
563
|
+
status: "API key rejected. Run: polli auth login"
|
|
564
|
+
});
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
558
567
|
if (!profile) {
|
|
559
568
|
printResult({
|
|
560
569
|
authenticated: true,
|
|
@@ -858,8 +867,10 @@ var respond = async (session, input, signal, update4) => {
|
|
|
858
867
|
signal
|
|
859
868
|
});
|
|
860
869
|
const output = [];
|
|
870
|
+
let refused = false;
|
|
861
871
|
for await (const event of sseEvents(response)) {
|
|
862
|
-
if (event.type === "response.output_text.delta") {
|
|
872
|
+
if (event.type === "response.output_text.delta" || event.type === "response.refusal.delta") {
|
|
873
|
+
if (event.type === "response.refusal.delta") refused = true;
|
|
863
874
|
await update4({
|
|
864
875
|
sessionUpdate: "agent_message_chunk",
|
|
865
876
|
content: { type: "text", text: String(event.delta) }
|
|
@@ -870,7 +881,7 @@ var respond = async (session, input, signal, update4) => {
|
|
|
870
881
|
const itemEvent = itemUpdate(item, session.tools);
|
|
871
882
|
if (itemEvent) await update4(itemEvent);
|
|
872
883
|
} else if (event.type === "response.completed") {
|
|
873
|
-
return { output };
|
|
884
|
+
return { output, ...refused && { stop: "refusal" } };
|
|
874
885
|
} else if (event.type === "response.incomplete") {
|
|
875
886
|
const response2 = event.response;
|
|
876
887
|
const filtered = response2.incomplete_details?.reason === "content_filter";
|
|
@@ -6017,6 +6028,13 @@ var modelsCommand = new Command20("models").description(
|
|
|
6017
6028
|
`Stats window in minutes (1-${MAX_STATS_WINDOW_MINUTES})`,
|
|
6018
6029
|
"60"
|
|
6019
6030
|
).action(async (query, opts) => {
|
|
6031
|
+
const params = new URLSearchParams();
|
|
6032
|
+
if (query) params.set("query", query);
|
|
6033
|
+
if (opts.source) params.set("source", opts.source);
|
|
6034
|
+
if (opts.reliability) params.set("reliability", opts.reliability);
|
|
6035
|
+
const listModels = async () => (await gen(`/models?${params}`)).filter(
|
|
6036
|
+
(m) => (opts.type === "all" || m.category === opts.type) && (!opts.voices || m.voices?.length)
|
|
6037
|
+
);
|
|
6020
6038
|
if (opts.stats) {
|
|
6021
6039
|
try {
|
|
6022
6040
|
const windowMinutes = Number(opts.window);
|
|
@@ -6026,22 +6044,12 @@ var modelsCommand = new Command20("models").description(
|
|
|
6026
6044
|
);
|
|
6027
6045
|
}
|
|
6028
6046
|
const rows = await fetchModelStats(windowMinutes);
|
|
6029
|
-
const
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
if (Number(r.total_requests ?? 0) <= 1) return false;
|
|
6036
|
-
if (wantType === "all") return true;
|
|
6037
|
-
if (decisionNames)
|
|
6038
|
-
return decisionNames.has(String(r.model));
|
|
6039
|
-
const t = String(r.event_type ?? "").replace(
|
|
6040
|
-
"generate.",
|
|
6041
|
-
""
|
|
6042
|
-
);
|
|
6043
|
-
return t === wantType;
|
|
6044
|
-
});
|
|
6047
|
+
const filtered = opts.type !== "all" || params.size || opts.voices;
|
|
6048
|
+
if (!opts.reliability) params.set("reliability", "all");
|
|
6049
|
+
const names = filtered ? new Set((await listModels()).map((m) => m.name)) : void 0;
|
|
6050
|
+
const valid = rows.filter(
|
|
6051
|
+
(r) => r.model !== "undefined" && Number(r.total_requests ?? 0) > 1 && (!names || names.has(String(r.model)))
|
|
6052
|
+
);
|
|
6045
6053
|
if (getOutputMode() === "json") {
|
|
6046
6054
|
printResult(valid);
|
|
6047
6055
|
} else {
|
|
@@ -6071,14 +6079,8 @@ var modelsCommand = new Command20("models").description(
|
|
|
6071
6079
|
}
|
|
6072
6080
|
return;
|
|
6073
6081
|
}
|
|
6074
|
-
const params = new URLSearchParams();
|
|
6075
|
-
if (query) params.set("query", query);
|
|
6076
|
-
if (opts.source) params.set("source", opts.source);
|
|
6077
|
-
if (opts.reliability) params.set("reliability", opts.reliability);
|
|
6078
6082
|
try {
|
|
6079
|
-
const models2 =
|
|
6080
|
-
(m) => (opts.type === "all" || m.category === opts.type) && (!opts.voices || m.voices?.length)
|
|
6081
|
-
);
|
|
6083
|
+
const models2 = await listModels();
|
|
6082
6084
|
if (getOutputMode() === "json") {
|
|
6083
6085
|
printResult(models2);
|
|
6084
6086
|
return;
|