@pollinations/cli 0.1.79 → 0.1.81
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 +23 -0
- package/SKILL.md +1 -0
- package/dist/index.js +674 -181
- package/dist/index.js.map +1 -1
- package/package.json +3 -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.81",
|
|
18
18
|
description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
|
|
19
19
|
type: "module",
|
|
20
20
|
bin: {
|
|
@@ -74,6 +74,8 @@ var init_package = __esm({
|
|
|
74
74
|
node: ">=20.0.0"
|
|
75
75
|
},
|
|
76
76
|
dependencies: {
|
|
77
|
+
"@agentclientprotocol/sdk": "^2.4.0",
|
|
78
|
+
"@modelcontextprotocol/client": "^2.4.0",
|
|
77
79
|
chalk: "^5.4.1",
|
|
78
80
|
commander: "^14.0.3",
|
|
79
81
|
"cross-spawn": "^7.0.6",
|
|
@@ -293,7 +295,7 @@ var init_output = __esm({
|
|
|
293
295
|
});
|
|
294
296
|
|
|
295
297
|
// src/lib/api.ts
|
|
296
|
-
var ApiError, requireKey, PERMISSION_HINTS, permissionHint, send, request, gen, genText;
|
|
298
|
+
var ApiError, requireKey, PERMISSION_HINTS, permissionHint, send, request, gen, genText, genResponse;
|
|
297
299
|
var init_api = __esm({
|
|
298
300
|
"src/lib/api.ts"() {
|
|
299
301
|
"use strict";
|
|
@@ -333,7 +335,7 @@ var init_api = __esm({
|
|
|
333
335
|
Or allow it for this login: ${grant}` : hint;
|
|
334
336
|
};
|
|
335
337
|
send = async (baseUrl, path, options = {}) => {
|
|
336
|
-
const { method = "GET", body, apiKey } = options;
|
|
338
|
+
const { method = "GET", body, apiKey, signal } = options;
|
|
337
339
|
const key = resolveApiKey(apiKey);
|
|
338
340
|
const headers = {
|
|
339
341
|
"Content-Type": "application/json",
|
|
@@ -343,7 +345,8 @@ Or allow it for this login: ${grant}` : hint;
|
|
|
343
345
|
const res = await fetch(`${baseUrl}${path}`, {
|
|
344
346
|
method,
|
|
345
347
|
headers,
|
|
346
|
-
body: body ? JSON.stringify(body) : void 0
|
|
348
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
349
|
+
signal
|
|
347
350
|
});
|
|
348
351
|
if (!res.ok) {
|
|
349
352
|
const text = await res.text().catch(() => "Unknown error");
|
|
@@ -361,6 +364,7 @@ Or allow it for this login: ${grant}` : hint;
|
|
|
361
364
|
};
|
|
362
365
|
gen = (path, options) => request(BASE_URL, path, options);
|
|
363
366
|
genText = async (path, options) => (await send(BASE_URL, path, options)).text();
|
|
367
|
+
genResponse = (path, options) => send(BASE_URL, path, options);
|
|
364
368
|
}
|
|
365
369
|
});
|
|
366
370
|
|
|
@@ -386,7 +390,7 @@ __export(auth_exports, {
|
|
|
386
390
|
showAuthStatus: () => showAuthStatus,
|
|
387
391
|
whoamiCommand: () => whoamiCommand
|
|
388
392
|
});
|
|
389
|
-
import { Command
|
|
393
|
+
import { Command, Option } from "commander";
|
|
390
394
|
function profileName(profile) {
|
|
391
395
|
return profile.githubUsername ?? profile.name ?? "unknown";
|
|
392
396
|
}
|
|
@@ -543,14 +547,23 @@ async function showAuthStatus() {
|
|
|
543
547
|
return;
|
|
544
548
|
}
|
|
545
549
|
const masked = `${key.slice(0, 5)}...${key.slice(-6)}`;
|
|
550
|
+
const rejectedKey = (error) => error instanceof ApiError && error.status === 401 ? error : null;
|
|
546
551
|
const [profile, balance] = await Promise.all([
|
|
547
552
|
gen("/account/profile", { apiKey: key }).catch(
|
|
548
|
-
|
|
553
|
+
rejectedKey
|
|
549
554
|
),
|
|
550
555
|
gen("/account/balance", { apiKey: key }).catch(
|
|
551
|
-
|
|
556
|
+
rejectedKey
|
|
552
557
|
)
|
|
553
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
|
+
}
|
|
554
567
|
if (!profile) {
|
|
555
568
|
printResult({
|
|
556
569
|
authenticated: true,
|
|
@@ -587,7 +600,7 @@ var init_auth = __esm({
|
|
|
587
600
|
throw error;
|
|
588
601
|
}
|
|
589
602
|
};
|
|
590
|
-
login = new
|
|
603
|
+
login = new Command("login").description("Authenticate with Pollinations").addOption(
|
|
591
604
|
new Option(
|
|
592
605
|
"--token <key>",
|
|
593
606
|
"Secret API key (sk_) for direct auth"
|
|
@@ -603,30 +616,557 @@ var init_auth = __esm({
|
|
|
603
616
|
}
|
|
604
617
|
if (getOutputMode() === "json") printResult({ authenticated: true });
|
|
605
618
|
});
|
|
606
|
-
logout = new
|
|
619
|
+
logout = new Command("logout").description("Clear stored credentials").action(() => {
|
|
607
620
|
clearCredentials();
|
|
608
621
|
printSuccess("Logged out. Credentials cleared.");
|
|
609
622
|
if (process.env.POLLINATIONS_API_KEY)
|
|
610
623
|
printInfo("POLLINATIONS_API_KEY is still set and stays in use.");
|
|
611
624
|
printInfo(flavor.logout);
|
|
612
625
|
});
|
|
613
|
-
status = new
|
|
614
|
-
authCommand = new
|
|
615
|
-
whoamiCommand = new
|
|
626
|
+
status = new Command("status").description("Show current auth status and balance").action(showAuthStatus);
|
|
627
|
+
authCommand = new Command("auth").description("Login, logout, and check auth status").addCommand(login).addCommand(logout).addCommand(status);
|
|
628
|
+
whoamiCommand = new Command("whoami").description("Show current auth status and balance (alias of auth status)").action(showAuthStatus);
|
|
616
629
|
}
|
|
617
630
|
});
|
|
618
631
|
|
|
619
632
|
// src/index.ts
|
|
620
633
|
import { readFileSync as readFileSync10 } from "fs";
|
|
621
634
|
import chalk12 from "chalk";
|
|
622
|
-
import { Command as
|
|
635
|
+
import { Command as Command28 } from "commander";
|
|
636
|
+
|
|
637
|
+
// src/commands/acp.ts
|
|
638
|
+
init_package();
|
|
639
|
+
init_api();
|
|
640
|
+
init_config();
|
|
641
|
+
init_output();
|
|
642
|
+
import { randomUUID } from "crypto";
|
|
643
|
+
import { Readable, Writable } from "stream";
|
|
644
|
+
import { Command as Command2 } from "commander";
|
|
645
|
+
|
|
646
|
+
// src/lib/stream.ts
|
|
647
|
+
async function* streamSSE(response, onEvent) {
|
|
648
|
+
for await (const event of sseEvents(response)) {
|
|
649
|
+
const parsed = event;
|
|
650
|
+
if (parsed.error) {
|
|
651
|
+
throw new Error(
|
|
652
|
+
parsed.error.message ?? JSON.stringify(parsed.error)
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
onEvent?.(parsed);
|
|
656
|
+
const delta = parsed.choices?.[0]?.delta;
|
|
657
|
+
if (delta?.content) yield delta.content;
|
|
658
|
+
if (delta?.refusal) yield delta.refusal;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
async function* sseEvents(response) {
|
|
662
|
+
const reader = response.body?.getReader();
|
|
663
|
+
if (!reader) throw new Error("No response body");
|
|
664
|
+
const decoder = new TextDecoder();
|
|
665
|
+
let buffer = "";
|
|
666
|
+
try {
|
|
667
|
+
while (true) {
|
|
668
|
+
const { done, value } = await reader.read();
|
|
669
|
+
if (done) throw new Error("Stream interrupted before [DONE]");
|
|
670
|
+
buffer += decoder.decode(value, { stream: true });
|
|
671
|
+
const lines = buffer.split("\n");
|
|
672
|
+
buffer = lines.pop() ?? "";
|
|
673
|
+
for (const line of lines) {
|
|
674
|
+
if (!line.startsWith("data:")) continue;
|
|
675
|
+
const data = line.slice(5).trim();
|
|
676
|
+
if (data === "[DONE]") return;
|
|
677
|
+
let parsed;
|
|
678
|
+
try {
|
|
679
|
+
parsed = JSON.parse(data);
|
|
680
|
+
} catch {
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
yield parsed;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
} finally {
|
|
687
|
+
await reader.cancel().catch(() => void 0);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// src/commands/acp.ts
|
|
692
|
+
init_auth();
|
|
693
|
+
var MAX_ROUNDS = 20;
|
|
694
|
+
var errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
695
|
+
var parseJson = (text) => {
|
|
696
|
+
try {
|
|
697
|
+
return JSON.parse(text);
|
|
698
|
+
} catch {
|
|
699
|
+
return text;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
var textUpdate = (text) => [
|
|
703
|
+
{ type: "content", content: { type: "text", text } }
|
|
704
|
+
];
|
|
705
|
+
var userMessage = (prompt2) => ({
|
|
706
|
+
role: "user",
|
|
707
|
+
content: prompt2.flatMap((block) => {
|
|
708
|
+
if (block.type === "text") {
|
|
709
|
+
return [{ type: "input_text", text: block.text }];
|
|
710
|
+
}
|
|
711
|
+
if (block.type === "image") {
|
|
712
|
+
return [
|
|
713
|
+
{
|
|
714
|
+
type: "input_image",
|
|
715
|
+
image_url: `data:${block.mimeType};base64,${block.data}`
|
|
716
|
+
}
|
|
717
|
+
];
|
|
718
|
+
}
|
|
719
|
+
if (block.type === "resource_link") {
|
|
720
|
+
return [
|
|
721
|
+
{ type: "input_text", text: `${block.name}: ${block.uri}` }
|
|
722
|
+
];
|
|
723
|
+
}
|
|
724
|
+
if (block.type === "resource") {
|
|
725
|
+
const { resource } = block;
|
|
726
|
+
if ("text" in resource) {
|
|
727
|
+
return [
|
|
728
|
+
{
|
|
729
|
+
type: "input_text",
|
|
730
|
+
text: `File ${resource.uri}:
|
|
731
|
+
${resource.text}`
|
|
732
|
+
}
|
|
733
|
+
];
|
|
734
|
+
}
|
|
735
|
+
if (resource.mimeType?.startsWith("image/")) {
|
|
736
|
+
return [
|
|
737
|
+
{
|
|
738
|
+
type: "input_image",
|
|
739
|
+
image_url: `data:${resource.mimeType};base64,${resource.blob}`
|
|
740
|
+
}
|
|
741
|
+
];
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return [];
|
|
745
|
+
})
|
|
746
|
+
});
|
|
747
|
+
var hostedResult = (output) => {
|
|
748
|
+
const text = output.map((part) => part.text ?? "").join("");
|
|
749
|
+
const result10 = parseJson(text);
|
|
750
|
+
if (typeof result10 !== "object" || !Array.isArray(result10?.content)) {
|
|
751
|
+
return { text, failed: false };
|
|
752
|
+
}
|
|
753
|
+
return { text: resultText(result10), failed: result10.isError === true };
|
|
754
|
+
};
|
|
755
|
+
var resultText = (result10) => {
|
|
756
|
+
const parts = (result10.content ?? []).flatMap(
|
|
757
|
+
(part) => part.type === "text" ? [part.text] : []
|
|
758
|
+
);
|
|
759
|
+
return parts.length ? parts.join("\n") : JSON.stringify(result10);
|
|
760
|
+
};
|
|
761
|
+
var itemUpdate = (item, editorTools) => {
|
|
762
|
+
if (item.type === "function_call") {
|
|
763
|
+
const call = item;
|
|
764
|
+
return {
|
|
765
|
+
sessionUpdate: "tool_call",
|
|
766
|
+
toolCallId: call.call_id,
|
|
767
|
+
title: call.name,
|
|
768
|
+
kind: "other",
|
|
769
|
+
// Editor tools wait for the editor; hosted tools are running.
|
|
770
|
+
status: editorTools.has(call.name) ? "pending" : "in_progress",
|
|
771
|
+
rawInput: parseJson(call.arguments)
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
if (item.type === "function_call_output") {
|
|
775
|
+
const { text, failed } = hostedResult(
|
|
776
|
+
item.output
|
|
777
|
+
);
|
|
778
|
+
return {
|
|
779
|
+
sessionUpdate: "tool_call_update",
|
|
780
|
+
toolCallId: String(item.call_id),
|
|
781
|
+
status: failed ? "failed" : "completed",
|
|
782
|
+
content: textUpdate(text)
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
return void 0;
|
|
786
|
+
};
|
|
787
|
+
var listAgents = async () => (await gen("/v1/models?agent=true")).data;
|
|
788
|
+
var agentOption = (session) => ({
|
|
789
|
+
id: "agent",
|
|
790
|
+
name: "Agent",
|
|
791
|
+
category: "model",
|
|
792
|
+
type: "select",
|
|
793
|
+
currentValue: session.agent,
|
|
794
|
+
options: session.agents.map((agent) => ({
|
|
795
|
+
value: agent.id,
|
|
796
|
+
name: agent.title || agent.id,
|
|
797
|
+
description: agent.description || null
|
|
798
|
+
}))
|
|
799
|
+
});
|
|
800
|
+
var toolName = (taken, server, tool) => [tool, `${server}_${tool}`].map((name) => name.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64)).find((name) => !taken.has(name) && !name.startsWith("mcp__"));
|
|
801
|
+
var connectServers = async (servers, cwd) => {
|
|
802
|
+
const { Client, StreamableHTTPClientTransport } = await import("@modelcontextprotocol/client");
|
|
803
|
+
const { StdioClientTransport } = await import("@modelcontextprotocol/client/stdio");
|
|
804
|
+
const tools = /* @__PURE__ */ new Map();
|
|
805
|
+
const clients = [];
|
|
806
|
+
for (const server of servers) {
|
|
807
|
+
const client = new Client({ name: "polli", version: package_default.version });
|
|
808
|
+
try {
|
|
809
|
+
if ("type" in server && server.type === "sse") {
|
|
810
|
+
throw new Error("SSE transport is not supported");
|
|
811
|
+
}
|
|
812
|
+
await client.connect(
|
|
813
|
+
"type" in server && server.type === "http" ? new StreamableHTTPClientTransport(new URL(server.url), {
|
|
814
|
+
requestInit: {
|
|
815
|
+
headers: Object.fromEntries(
|
|
816
|
+
server.headers.map((h) => [h.name, h.value])
|
|
817
|
+
)
|
|
818
|
+
}
|
|
819
|
+
}) : new StdioClientTransport({
|
|
820
|
+
command: server.command,
|
|
821
|
+
args: server.args,
|
|
822
|
+
cwd,
|
|
823
|
+
// The SDK adds a safe default env (PATH, HOME…),
|
|
824
|
+
// never process.env, which can hold the key.
|
|
825
|
+
env: Object.fromEntries(
|
|
826
|
+
server.env.map((v) => [v.name, v.value])
|
|
827
|
+
)
|
|
828
|
+
})
|
|
829
|
+
);
|
|
830
|
+
clients.push(client);
|
|
831
|
+
for (const tool of (await client.listTools()).tools) {
|
|
832
|
+
const name = toolName(tools, server.name, tool.name);
|
|
833
|
+
if (!name) {
|
|
834
|
+
printWarn(`Skipping MCP tool ${server.name}/${tool.name}`);
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
tools.set(name, {
|
|
838
|
+
client,
|
|
839
|
+
name: tool.name,
|
|
840
|
+
definition: {
|
|
841
|
+
type: "function",
|
|
842
|
+
name,
|
|
843
|
+
description: tool.description,
|
|
844
|
+
parameters: tool.inputSchema
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
} catch (error) {
|
|
849
|
+
printWarn(
|
|
850
|
+
`MCP server ${server.name} failed: ${errorMessage(error)}`
|
|
851
|
+
);
|
|
852
|
+
await client.close().catch(() => void 0);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return { tools, clients };
|
|
856
|
+
};
|
|
857
|
+
var respond = async (session, input, signal, update4) => {
|
|
858
|
+
const tools = [...session.tools.values()].map((tool) => tool.definition);
|
|
859
|
+
const response = await genResponse("/v1/responses", {
|
|
860
|
+
method: "POST",
|
|
861
|
+
body: {
|
|
862
|
+
model: session.agent,
|
|
863
|
+
input,
|
|
864
|
+
stream: true,
|
|
865
|
+
...tools.length ? { tools } : {}
|
|
866
|
+
},
|
|
867
|
+
signal
|
|
868
|
+
});
|
|
869
|
+
const output = [];
|
|
870
|
+
let refused = false;
|
|
871
|
+
for await (const event of sseEvents(response)) {
|
|
872
|
+
if (event.type === "response.output_text.delta" || event.type === "response.refusal.delta") {
|
|
873
|
+
if (event.type === "response.refusal.delta") refused = true;
|
|
874
|
+
await update4({
|
|
875
|
+
sessionUpdate: "agent_message_chunk",
|
|
876
|
+
content: { type: "text", text: String(event.delta) }
|
|
877
|
+
});
|
|
878
|
+
} else if (event.type === "response.output_item.done") {
|
|
879
|
+
const item = event.item;
|
|
880
|
+
output.push(item);
|
|
881
|
+
const itemEvent = itemUpdate(item, session.tools);
|
|
882
|
+
if (itemEvent) await update4(itemEvent);
|
|
883
|
+
} else if (event.type === "response.completed") {
|
|
884
|
+
return { output, ...refused && { stop: "refusal" } };
|
|
885
|
+
} else if (event.type === "response.incomplete") {
|
|
886
|
+
const response2 = event.response;
|
|
887
|
+
const filtered = response2.incomplete_details?.reason === "content_filter";
|
|
888
|
+
return { output, stop: filtered ? "refusal" : "max_tokens" };
|
|
889
|
+
} else if (event.type === "response.failed") {
|
|
890
|
+
const response2 = event.response;
|
|
891
|
+
throw new Error(response2.error?.message ?? "The agent run failed");
|
|
892
|
+
} else if (event.type === "error") {
|
|
893
|
+
throw new Error(String(event.message ?? "The agent run failed"));
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
throw new Error("The agent's stream ended early");
|
|
897
|
+
};
|
|
898
|
+
var runEditorTool = async (session, call, client, signal, update4) => {
|
|
899
|
+
const tool = session.tools.get(call.name);
|
|
900
|
+
if (!session.alwaysAllowed.has(call.name)) {
|
|
901
|
+
const { outcome } = await client.request("session/request_permission", {
|
|
902
|
+
sessionId: session.id,
|
|
903
|
+
toolCall: { toolCallId: call.call_id },
|
|
904
|
+
options: [
|
|
905
|
+
{ optionId: "allow", name: "Allow", kind: "allow_once" },
|
|
906
|
+
{
|
|
907
|
+
optionId: "always",
|
|
908
|
+
name: "Always allow",
|
|
909
|
+
kind: "allow_always"
|
|
910
|
+
},
|
|
911
|
+
{ optionId: "reject", name: "Reject", kind: "reject_once" }
|
|
912
|
+
]
|
|
913
|
+
});
|
|
914
|
+
if (outcome.outcome === "cancelled") return void 0;
|
|
915
|
+
const { optionId } = outcome;
|
|
916
|
+
if (optionId === "always") session.alwaysAllowed.add(call.name);
|
|
917
|
+
if (optionId !== "allow" && optionId !== "always") {
|
|
918
|
+
const text = "The user rejected this tool call.";
|
|
919
|
+
await update4({
|
|
920
|
+
sessionUpdate: "tool_call_update",
|
|
921
|
+
toolCallId: call.call_id,
|
|
922
|
+
status: "failed",
|
|
923
|
+
content: textUpdate(text)
|
|
924
|
+
});
|
|
925
|
+
return JSON.stringify({
|
|
926
|
+
isError: true,
|
|
927
|
+
content: [{ type: "text", text }]
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
await update4({
|
|
932
|
+
sessionUpdate: "tool_call_update",
|
|
933
|
+
toolCallId: call.call_id,
|
|
934
|
+
status: "in_progress"
|
|
935
|
+
});
|
|
936
|
+
let result10;
|
|
937
|
+
try {
|
|
938
|
+
result10 = await tool.client.callTool(
|
|
939
|
+
{
|
|
940
|
+
name: tool.name,
|
|
941
|
+
arguments: parseJson(call.arguments)
|
|
942
|
+
},
|
|
943
|
+
{ signal }
|
|
944
|
+
);
|
|
945
|
+
} catch (error) {
|
|
946
|
+
if (signal.aborted) return void 0;
|
|
947
|
+
result10 = {
|
|
948
|
+
isError: true,
|
|
949
|
+
content: [{ type: "text", text: errorMessage(error) }]
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
result10 = {
|
|
953
|
+
...result10,
|
|
954
|
+
content: (result10.content ?? []).map(
|
|
955
|
+
(part) => part.type === "text" || part.type === "resource_link" || part.type === "resource" && "text" in part.resource ? part : { type: "text", text: `[${part.type} output omitted]` }
|
|
956
|
+
)
|
|
957
|
+
};
|
|
958
|
+
await update4({
|
|
959
|
+
sessionUpdate: "tool_call_update",
|
|
960
|
+
toolCallId: call.call_id,
|
|
961
|
+
status: result10.isError ? "failed" : "completed",
|
|
962
|
+
content: textUpdate(resultText(result10))
|
|
963
|
+
});
|
|
964
|
+
return JSON.stringify(result10);
|
|
965
|
+
};
|
|
966
|
+
var resultIds = (items) => new Set(
|
|
967
|
+
items.filter((item) => item.type === "function_call_output").map((item) => item.call_id)
|
|
968
|
+
);
|
|
969
|
+
var answered = (items) => {
|
|
970
|
+
const done = resultIds(items);
|
|
971
|
+
return items.filter(
|
|
972
|
+
(item) => item.type !== "function_call" || done.has(item.call_id)
|
|
973
|
+
);
|
|
974
|
+
};
|
|
975
|
+
var prompt = async (session, blocks, client, requestSignal) => {
|
|
976
|
+
const cancel = new AbortController();
|
|
977
|
+
session.cancel = cancel;
|
|
978
|
+
requestSignal.addEventListener("abort", () => cancel.abort(), {
|
|
979
|
+
once: true
|
|
980
|
+
});
|
|
981
|
+
const { signal } = cancel;
|
|
982
|
+
const update4 = (update5) => client.notify("session/update", { sessionId: session.id, update: update5 });
|
|
983
|
+
const input = [...session.history, userMessage(blocks)];
|
|
984
|
+
try {
|
|
985
|
+
for (let round2 = 0; round2 < MAX_ROUNDS; round2++) {
|
|
986
|
+
const { output, stop } = await respond(
|
|
987
|
+
session,
|
|
988
|
+
input,
|
|
989
|
+
signal,
|
|
990
|
+
update4
|
|
991
|
+
);
|
|
992
|
+
if (stop === "refusal") {
|
|
993
|
+
input.length = session.history.length;
|
|
994
|
+
return { stopReason: stop };
|
|
995
|
+
}
|
|
996
|
+
input.push(...output);
|
|
997
|
+
const done = resultIds(output);
|
|
998
|
+
const calls = output.filter(
|
|
999
|
+
(item) => item.type === "function_call" && !done.has(item.call_id) && session.tools.has(String(item.name))
|
|
1000
|
+
);
|
|
1001
|
+
if (stop || !calls.length) {
|
|
1002
|
+
return { stopReason: stop ?? "end_turn" };
|
|
1003
|
+
}
|
|
1004
|
+
for (const call of calls) {
|
|
1005
|
+
const output2 = await runEditorTool(
|
|
1006
|
+
session,
|
|
1007
|
+
call,
|
|
1008
|
+
client,
|
|
1009
|
+
signal,
|
|
1010
|
+
update4
|
|
1011
|
+
);
|
|
1012
|
+
if (output2 === void 0) return { stopReason: "cancelled" };
|
|
1013
|
+
input.push({
|
|
1014
|
+
type: "function_call_output",
|
|
1015
|
+
call_id: call.call_id,
|
|
1016
|
+
output: output2
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
return { stopReason: "max_turn_requests" };
|
|
1021
|
+
} catch (error) {
|
|
1022
|
+
if (signal.aborted) return { stopReason: "cancelled" };
|
|
1023
|
+
if (!resultIds(input.slice(session.history.length)).size) {
|
|
1024
|
+
input.length = session.history.length;
|
|
1025
|
+
}
|
|
1026
|
+
throw error;
|
|
1027
|
+
} finally {
|
|
1028
|
+
session.history = answered(input);
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
var acpAgent = async (defaultAgent) => {
|
|
1032
|
+
const acp = await import("@agentclientprotocol/sdk");
|
|
1033
|
+
const { RequestError } = acp;
|
|
1034
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
1035
|
+
const session = (id) => {
|
|
1036
|
+
const found = sessions.get(id);
|
|
1037
|
+
if (!found) throw RequestError.sessionNotFound(id);
|
|
1038
|
+
return found;
|
|
1039
|
+
};
|
|
1040
|
+
const app = acp.agent({ name: "polli" }).onRequest("initialize", () => ({
|
|
1041
|
+
protocolVersion: acp.PROTOCOL_VERSION,
|
|
1042
|
+
agentCapabilities: {
|
|
1043
|
+
promptCapabilities: { image: true, embeddedContext: true },
|
|
1044
|
+
mcpCapabilities: { http: true },
|
|
1045
|
+
sessionCapabilities: { close: {} }
|
|
1046
|
+
},
|
|
1047
|
+
authMethods: [
|
|
1048
|
+
{
|
|
1049
|
+
id: "pollinations-login",
|
|
1050
|
+
name: "Sign in to Pollinations",
|
|
1051
|
+
description: "Approve a key in your browser, or set POLLINATIONS_API_KEY."
|
|
1052
|
+
}
|
|
1053
|
+
],
|
|
1054
|
+
agentInfo: {
|
|
1055
|
+
name: "polli",
|
|
1056
|
+
title: "Pollinations",
|
|
1057
|
+
version: package_default.version
|
|
1058
|
+
}
|
|
1059
|
+
})).onRequest("authenticate", async () => {
|
|
1060
|
+
try {
|
|
1061
|
+
setKeyOverride(await loginWithDeviceFlow());
|
|
1062
|
+
} catch {
|
|
1063
|
+
throw RequestError.internalError(
|
|
1064
|
+
void 0,
|
|
1065
|
+
"Sign-in failed. Run polli auth login in a terminal, or set POLLINATIONS_API_KEY."
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
return {};
|
|
1069
|
+
}).onRequest("session/new", async ({ params }) => {
|
|
1070
|
+
if (!resolveApiKey()) throw RequestError.authRequired();
|
|
1071
|
+
const agents = await listAgents();
|
|
1072
|
+
const agent = defaultAgent ?? agents[0]?.id;
|
|
1073
|
+
if (!agent) throw new Error("No agents found");
|
|
1074
|
+
const created = {
|
|
1075
|
+
id: randomUUID(),
|
|
1076
|
+
agent,
|
|
1077
|
+
agents: agents.some((listed) => listed.id === agent) ? agents : [{ id: agent }, ...agents],
|
|
1078
|
+
history: [],
|
|
1079
|
+
alwaysAllowed: /* @__PURE__ */ new Set(),
|
|
1080
|
+
...await connectServers(params.mcpServers, params.cwd)
|
|
1081
|
+
};
|
|
1082
|
+
sessions.set(created.id, created);
|
|
1083
|
+
return {
|
|
1084
|
+
sessionId: created.id,
|
|
1085
|
+
configOptions: [agentOption(created)]
|
|
1086
|
+
};
|
|
1087
|
+
}).onRequest("session/set_config_option", ({ params }) => {
|
|
1088
|
+
const found = session(params.sessionId);
|
|
1089
|
+
if (params.configId !== "agent" || typeof params.value !== "string") {
|
|
1090
|
+
throw RequestError.invalidParams(void 0, "Unknown option");
|
|
1091
|
+
}
|
|
1092
|
+
if (found.agent !== params.value) {
|
|
1093
|
+
found.agent = params.value;
|
|
1094
|
+
found.alwaysAllowed.clear();
|
|
1095
|
+
}
|
|
1096
|
+
return { configOptions: [agentOption(found)] };
|
|
1097
|
+
}).onRequest("session/prompt", async ({ params, client, signal }) => {
|
|
1098
|
+
const found = session(params.sessionId);
|
|
1099
|
+
try {
|
|
1100
|
+
return await prompt(found, params.prompt, client, signal);
|
|
1101
|
+
} catch (error) {
|
|
1102
|
+
if (error instanceof ApiError && error.status === 401) {
|
|
1103
|
+
throw RequestError.authRequired();
|
|
1104
|
+
}
|
|
1105
|
+
throw RequestError.internalError(
|
|
1106
|
+
void 0,
|
|
1107
|
+
errorMessage(error)
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
}).onNotification("session/cancel", ({ params }) => {
|
|
1111
|
+
sessions.get(params.sessionId)?.cancel?.abort();
|
|
1112
|
+
}).onRequest("session/close", async ({ params }) => {
|
|
1113
|
+
const found = session(params.sessionId);
|
|
1114
|
+
found.cancel?.abort();
|
|
1115
|
+
sessions.delete(found.id);
|
|
1116
|
+
await Promise.all(found.clients.map((client) => client.close()));
|
|
1117
|
+
return {};
|
|
1118
|
+
});
|
|
1119
|
+
const close = () => Promise.all(
|
|
1120
|
+
[...sessions.values()].flatMap(
|
|
1121
|
+
(found) => found.clients.map((client) => client.close())
|
|
1122
|
+
)
|
|
1123
|
+
);
|
|
1124
|
+
return { app, close };
|
|
1125
|
+
};
|
|
1126
|
+
var serve = async (agent) => {
|
|
1127
|
+
const { ndJsonStream } = await import("@agentclientprotocol/sdk");
|
|
1128
|
+
const { app, close } = await acpAgent(agent);
|
|
1129
|
+
console.log = console.info = console.debug = console.error;
|
|
1130
|
+
const connection = app.connect(
|
|
1131
|
+
ndJsonStream(
|
|
1132
|
+
Writable.toWeb(process.stdout),
|
|
1133
|
+
Readable.toWeb(process.stdin)
|
|
1134
|
+
)
|
|
1135
|
+
);
|
|
1136
|
+
try {
|
|
1137
|
+
await connection.closed;
|
|
1138
|
+
} finally {
|
|
1139
|
+
await close();
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
var acpCommand = new Command2("acp").description(
|
|
1143
|
+
"Serve Pollinations agents to editors over the Agent Client Protocol"
|
|
1144
|
+
).argument(
|
|
1145
|
+
"[agent]",
|
|
1146
|
+
"Agent to start with, e.g. community/<owner>/<name>; the editor can switch"
|
|
1147
|
+
).addHelpText(
|
|
1148
|
+
"after",
|
|
1149
|
+
`
|
|
1150
|
+
Editors start this command themselves. Zed (settings.json):
|
|
1151
|
+
"agent_servers": {
|
|
1152
|
+
"Pollinations": {
|
|
1153
|
+
"type": "custom",
|
|
1154
|
+
"command": "npx",
|
|
1155
|
+
"args": ["-y", "@pollinations/cli", "acp"]
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
The agent runs on Pollinations. MCP servers the editor passes are connected
|
|
1160
|
+
here and offered to the agent as tools; each call asks for your permission.
|
|
1161
|
+
`
|
|
1162
|
+
).action((agent) => serve(agent));
|
|
623
1163
|
|
|
624
1164
|
// src/commands/agents.ts
|
|
625
1165
|
init_api();
|
|
626
1166
|
init_output();
|
|
627
1167
|
import { readFileSync as readFileSync2 } from "fs";
|
|
628
1168
|
import chalk2 from "chalk";
|
|
629
|
-
import { Command } from "commander";
|
|
1169
|
+
import { Command as Command3 } from "commander";
|
|
630
1170
|
function readConfig(path) {
|
|
631
1171
|
try {
|
|
632
1172
|
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
@@ -684,7 +1224,7 @@ function printAgents(agents) {
|
|
|
684
1224
|
]
|
|
685
1225
|
);
|
|
686
1226
|
}
|
|
687
|
-
var list = new
|
|
1227
|
+
var list = new Command3("list").description("List agents owned by your account").action(async () => {
|
|
688
1228
|
const key = requireKey();
|
|
689
1229
|
try {
|
|
690
1230
|
const response = await gen("/account/agents", {
|
|
@@ -698,7 +1238,7 @@ var list = new Command("list").description("List agents owned by your account").
|
|
|
698
1238
|
throw new ExitSignal(1);
|
|
699
1239
|
}
|
|
700
1240
|
});
|
|
701
|
-
var get = new
|
|
1241
|
+
var get = new Command3("get").description("Get an agent owned by your account").argument("<id>", "Agent id").action(async (id) => {
|
|
702
1242
|
const key = requireKey();
|
|
703
1243
|
try {
|
|
704
1244
|
const agent = await gen(
|
|
@@ -714,7 +1254,7 @@ var get = new Command("get").description("Get an agent owned by your account").a
|
|
|
714
1254
|
throw new ExitSignal(1);
|
|
715
1255
|
}
|
|
716
1256
|
});
|
|
717
|
-
var create = new
|
|
1257
|
+
var create = new Command3("create").description("Create a managed agent").requiredOption(
|
|
718
1258
|
"--config <file>",
|
|
719
1259
|
"JSON agent config file sent directly to the API"
|
|
720
1260
|
).option("--name <name>", "Prompt-agent callable model name").option("--title <title>", "Prompt-agent catalog title").option("--description <text>", "Prompt-agent description").option(
|
|
@@ -751,7 +1291,7 @@ It can take a minute or two to become callable while the model catalog refreshes
|
|
|
751
1291
|
throw new ExitSignal(1);
|
|
752
1292
|
}
|
|
753
1293
|
});
|
|
754
|
-
var update = new
|
|
1294
|
+
var update = new Command3("update").description("Update an agent; fields you leave out keep their values").argument("<id>", "Agent id").option(
|
|
755
1295
|
"--config <file>",
|
|
756
1296
|
'JSON with only the fields to change, e.g. {"systemPrompt": "..."}'
|
|
757
1297
|
).option("--name <name>", "Callable model name").option("--title <title>", "Display title shown in the catalog").option("--description <text>", "Agent description; empty clears it").option("--visibility <visibility>", "Agent visibility: private or public").action(async (id, opts) => {
|
|
@@ -781,7 +1321,7 @@ var update = new Command("update").description("Update an agent; fields you leav
|
|
|
781
1321
|
throw new ExitSignal(1);
|
|
782
1322
|
}
|
|
783
1323
|
});
|
|
784
|
-
var remove = new
|
|
1324
|
+
var remove = new Command3("delete").description("Delete an agent and its model registration").argument("<id>", "Agent id").action(async (id) => {
|
|
785
1325
|
const key = requireKey();
|
|
786
1326
|
try {
|
|
787
1327
|
await gen(
|
|
@@ -797,7 +1337,7 @@ var remove = new Command("delete").description("Delete an agent and its model re
|
|
|
797
1337
|
throw new ExitSignal(1);
|
|
798
1338
|
}
|
|
799
1339
|
});
|
|
800
|
-
var sync = new
|
|
1340
|
+
var sync = new Command3("sync").description("Deploy the latest revision of a code agent").argument("<id>", "Agent id").action(async (id) => {
|
|
801
1341
|
const key = requireKey();
|
|
802
1342
|
try {
|
|
803
1343
|
const result10 = await gen(`/account/agents/${encodeURIComponent(id)}/sync`, {
|
|
@@ -817,7 +1357,7 @@ var sync = new Command("sync").description("Deploy the latest revision of a code
|
|
|
817
1357
|
throw new ExitSignal(1);
|
|
818
1358
|
}
|
|
819
1359
|
});
|
|
820
|
-
var agentsCommand = new
|
|
1360
|
+
var agentsCommand = new Command3("agents").description("Manage agents").addCommand(list).addCommand(get).addCommand(create).addCommand(update).addCommand(sync).addCommand(remove);
|
|
821
1361
|
|
|
822
1362
|
// src/index.ts
|
|
823
1363
|
init_auth();
|
|
@@ -826,7 +1366,7 @@ init_auth();
|
|
|
826
1366
|
init_config();
|
|
827
1367
|
init_output();
|
|
828
1368
|
import chalk3 from "chalk";
|
|
829
|
-
import { Command as
|
|
1369
|
+
import { Command as Command4 } from "commander";
|
|
830
1370
|
import open from "open";
|
|
831
1371
|
var DOCS_URL = `${BASE_URL}/docs`;
|
|
832
1372
|
var LLM_TXT_URL = `${BASE_URL}/docs/llm.txt`;
|
|
@@ -845,7 +1385,7 @@ function styleMarkdown(md) {
|
|
|
845
1385
|
(_, hashes, text) => chalk3.hex("#a78bfa").bold(`${hashes} ${text}`)
|
|
846
1386
|
).replace(/```([\s\S]*?)```/g, (block) => chalk3.dim(block)).replace(/`([^`\n]+)`/g, (_, code) => chalk3.cyan(code));
|
|
847
1387
|
}
|
|
848
|
-
var docsCommand = new
|
|
1388
|
+
var docsCommand = new Command4("docs").description("Show Pollinations API documentation").argument(
|
|
849
1389
|
"[endpoint]",
|
|
850
1390
|
"Filter docs to a specific endpoint (e.g. /image, /v1/chat/completions)"
|
|
851
1391
|
).option("--open", "Open documentation in browser instead of printing").action(async (endpoint, opts) => {
|
|
@@ -912,11 +1452,11 @@ var docsCommand = new Command3("docs").description("Show Pollinations API docume
|
|
|
912
1452
|
// src/commands/earnings.ts
|
|
913
1453
|
init_api();
|
|
914
1454
|
init_output();
|
|
915
|
-
import { Command as
|
|
1455
|
+
import { Command as Command5 } from "commander";
|
|
916
1456
|
function totalPollenEarned(perEntity) {
|
|
917
1457
|
return perEntity.reduce((sum, row) => sum + row.pollen_earned, 0);
|
|
918
1458
|
}
|
|
919
|
-
var earningsCommand = new
|
|
1459
|
+
var earningsCommand = new Command5("earnings").description("Show developer earnings from BYOP apps and community models").option("--days <n>", "Rolling window in days", "30").action(async (opts) => {
|
|
920
1460
|
const key = requireKey();
|
|
921
1461
|
const days = opts.days;
|
|
922
1462
|
try {
|
|
@@ -952,11 +1492,11 @@ var earningsCommand = new Command4("earnings").description("Show developer earni
|
|
|
952
1492
|
});
|
|
953
1493
|
|
|
954
1494
|
// src/commands/gen/index.ts
|
|
955
|
-
import { Command as
|
|
1495
|
+
import { Command as Command16 } from "commander";
|
|
956
1496
|
|
|
957
1497
|
// src/commands/gen/audio.ts
|
|
958
1498
|
import { writeFileSync as writeFileSync2 } from "fs";
|
|
959
|
-
import { Command as
|
|
1499
|
+
import { Command as Command6 } from "commander";
|
|
960
1500
|
|
|
961
1501
|
// src/lib/errors.ts
|
|
962
1502
|
init_api();
|
|
@@ -1002,15 +1542,15 @@ async function generationKey() {
|
|
|
1002
1542
|
if (getOutputMode() !== "human" || !process.stdin.isTTY || !process.stderr.isTTY) {
|
|
1003
1543
|
return requireKey();
|
|
1004
1544
|
}
|
|
1005
|
-
const
|
|
1545
|
+
const prompt2 = createInterface({
|
|
1006
1546
|
input: process.stdin,
|
|
1007
1547
|
output: process.stderr
|
|
1008
1548
|
});
|
|
1009
1549
|
let answer;
|
|
1010
1550
|
try {
|
|
1011
|
-
answer = await
|
|
1551
|
+
answer = await prompt2.question("Not logged in. Log in now? [Y/n] ");
|
|
1012
1552
|
} finally {
|
|
1013
|
-
|
|
1553
|
+
prompt2.close();
|
|
1014
1554
|
}
|
|
1015
1555
|
if (answer.trim() && !/^y(es)?$/i.test(answer.trim())) {
|
|
1016
1556
|
throw new ApiError(401, "Login required. Run: polli auth login");
|
|
@@ -1159,7 +1699,7 @@ async function generateWithTimestamps(text, opts, alignmentPath) {
|
|
|
1159
1699
|
return Buffer.from(data.audio_base64, "base64");
|
|
1160
1700
|
}
|
|
1161
1701
|
function createAudioCommand() {
|
|
1162
|
-
return new
|
|
1702
|
+
return new Command6("audio").description(
|
|
1163
1703
|
"Generate speech or music from text (stdin ok). Discover voices: polli models --type audio --voices"
|
|
1164
1704
|
).addHelpText(
|
|
1165
1705
|
"after",
|
|
@@ -1236,7 +1776,7 @@ init_config();
|
|
|
1236
1776
|
import { writeFileSync as writeFileSync3 } from "fs";
|
|
1237
1777
|
import { createInterface as createInterface2 } from "readline";
|
|
1238
1778
|
import chalk4 from "chalk";
|
|
1239
|
-
import { Command as
|
|
1779
|
+
import { Command as Command7 } from "commander";
|
|
1240
1780
|
|
|
1241
1781
|
// src/lib/number-option.ts
|
|
1242
1782
|
init_output();
|
|
@@ -1252,45 +1792,8 @@ function numberOption(flag, value, min, max, integer = false) {
|
|
|
1252
1792
|
|
|
1253
1793
|
// src/commands/gen/chat.ts
|
|
1254
1794
|
init_output();
|
|
1255
|
-
|
|
1256
|
-
// src/lib/stream.ts
|
|
1257
|
-
async function* streamSSE(response, onEvent) {
|
|
1258
|
-
const reader = response.body?.getReader();
|
|
1259
|
-
if (!reader) throw new Error("No response body");
|
|
1260
|
-
const decoder = new TextDecoder();
|
|
1261
|
-
let buffer = "";
|
|
1262
|
-
while (true) {
|
|
1263
|
-
const { done, value } = await reader.read();
|
|
1264
|
-
if (done) throw new Error("Stream interrupted before [DONE]");
|
|
1265
|
-
buffer += decoder.decode(value, { stream: true });
|
|
1266
|
-
const lines = buffer.split("\n");
|
|
1267
|
-
buffer = lines.pop() ?? "";
|
|
1268
|
-
for (const line of lines) {
|
|
1269
|
-
if (!line.startsWith("data:")) continue;
|
|
1270
|
-
const data = line.slice(5).trim();
|
|
1271
|
-
if (data === "[DONE]") return;
|
|
1272
|
-
let parsed;
|
|
1273
|
-
try {
|
|
1274
|
-
parsed = JSON.parse(data);
|
|
1275
|
-
} catch {
|
|
1276
|
-
continue;
|
|
1277
|
-
}
|
|
1278
|
-
if (parsed.error) {
|
|
1279
|
-
throw new Error(
|
|
1280
|
-
parsed.error.message ?? JSON.stringify(parsed.error)
|
|
1281
|
-
);
|
|
1282
|
-
}
|
|
1283
|
-
onEvent?.(parsed);
|
|
1284
|
-
const delta = parsed.choices?.[0]?.delta;
|
|
1285
|
-
if (delta?.content) yield delta.content;
|
|
1286
|
-
if (delta?.refusal) yield delta.refusal;
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
// src/commands/gen/chat.ts
|
|
1292
1795
|
function createChatCommand() {
|
|
1293
|
-
return new
|
|
1796
|
+
return new Command7("chat").description("Interactive multi-turn chat session").option("--model <model>", "Text model (default: API default)").option("--system <msg>", "System message").option("--temperature <n>", "Randomness (0-2)").option("--max-tokens <n>", "Maximum output tokens").option("--save <path>", "Save conversation transcript on exit").action(async (opts) => {
|
|
1294
1797
|
const temperature = opts.temperature === void 0 ? void 0 : numberOption("--temperature", opts.temperature, 0, 2);
|
|
1295
1798
|
const maxTokens = opts.maxTokens === void 0 ? void 0 : numberOption(
|
|
1296
1799
|
"--max-tokens",
|
|
@@ -1472,10 +1975,10 @@ Session ended. ${totalTokens} tokens used.
|
|
|
1472
1975
|
}
|
|
1473
1976
|
|
|
1474
1977
|
// src/commands/gen/embeddings.ts
|
|
1475
|
-
import { Command as
|
|
1978
|
+
import { Command as Command8 } from "commander";
|
|
1476
1979
|
init_output();
|
|
1477
1980
|
function createEmbeddingsCommand() {
|
|
1478
|
-
return new
|
|
1981
|
+
return new Command8("embeddings").description(
|
|
1479
1982
|
"Generate vector embeddings for one or more texts (stdin: one per line)"
|
|
1480
1983
|
).argument("[inputs...]", "Texts to embed (or pipe via stdin)").option("--model <model>", "Embedding model").option("--dimensions <n>", "Output dimensions (128-4096)").option(
|
|
1481
1984
|
"--task-type <type>",
|
|
@@ -1522,7 +2025,7 @@ function createEmbeddingsCommand() {
|
|
|
1522
2025
|
|
|
1523
2026
|
// src/commands/gen/image.ts
|
|
1524
2027
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
1525
|
-
import { Command as
|
|
2028
|
+
import { Command as Command9 } from "commander";
|
|
1526
2029
|
|
|
1527
2030
|
// src/lib/estimate.ts
|
|
1528
2031
|
init_api();
|
|
@@ -1636,13 +2139,13 @@ var EXTENSION_BY_CONTENT_TYPE = {
|
|
|
1636
2139
|
"image/svg+xml": "svg"
|
|
1637
2140
|
};
|
|
1638
2141
|
function createImageCommand() {
|
|
1639
|
-
return new
|
|
2142
|
+
return new Command9("image").description("Generate an image from a prompt").argument("<prompt>", "Image description").option("--model <model>", "Image model", "zimage").option("--width <n>", "Image width", "1024").option("--height <n>", "Image height", "1024").option("--seed <n>", "Random seed").option("--safe", "Enable safety filters").option(
|
|
1640
2143
|
"--transparent",
|
|
1641
2144
|
"Transparent background (GPT Image 1 Mini, 1.5 and 2.5 only)"
|
|
1642
2145
|
).option(
|
|
1643
2146
|
"--image <url...>",
|
|
1644
2147
|
"Reference image URL(s) for editing/i2i (repeatable)"
|
|
1645
|
-
).option("--output <path>", "Save to file (extension inferred)").option("--estimate", "Show the estimated Pollen cost; don't generate").action(async (
|
|
2148
|
+
).option("--output <path>", "Save to file (extension inferred)").option("--estimate", "Show the estimated Pollen cost; don't generate").action(async (prompt2, opts) => {
|
|
1646
2149
|
const isHuman = getOutputMode() === "human";
|
|
1647
2150
|
const params = new URLSearchParams({
|
|
1648
2151
|
model: opts.model,
|
|
@@ -1671,7 +2174,7 @@ function createImageCommand() {
|
|
|
1671
2174
|
height: Number(opts.height),
|
|
1672
2175
|
references: opts.image?.length ?? 0
|
|
1673
2176
|
});
|
|
1674
|
-
const encodedPrompt = encodeURIComponent(
|
|
2177
|
+
const encodedPrompt = encodeURIComponent(prompt2);
|
|
1675
2178
|
const path = `/image/${encodedPrompt}?${params}`;
|
|
1676
2179
|
if (opts.output) prepareOutputPath(opts.output);
|
|
1677
2180
|
if (isHuman) printInfo("Generating image...");
|
|
@@ -1696,7 +2199,7 @@ function createImageCommand() {
|
|
|
1696
2199
|
// src/commands/gen/isolate.ts
|
|
1697
2200
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
1698
2201
|
import { basename } from "path";
|
|
1699
|
-
import { Command as
|
|
2202
|
+
import { Command as Command10 } from "commander";
|
|
1700
2203
|
|
|
1701
2204
|
// src/lib/input-file.ts
|
|
1702
2205
|
init_output();
|
|
@@ -1755,7 +2258,7 @@ function mimeTypeFor(file) {
|
|
|
1755
2258
|
// src/commands/gen/isolate.ts
|
|
1756
2259
|
init_output();
|
|
1757
2260
|
function createIsolateCommand() {
|
|
1758
|
-
return new
|
|
2261
|
+
return new Command10("isolate").description(
|
|
1759
2262
|
"Remove music and background noise from a local audio or video file"
|
|
1760
2263
|
).argument("<file>", "Source audio or video file path").option("--model <model>", "Voice-isolation model").option("--output <path>", "Save to file", "isolated.mp3").action(async (file, opts) => {
|
|
1761
2264
|
const isHuman = getOutputMode() === "human";
|
|
@@ -1789,13 +2292,13 @@ function createIsolateCommand() {
|
|
|
1789
2292
|
|
|
1790
2293
|
// src/commands/gen/model3d.ts
|
|
1791
2294
|
import { writeFileSync as writeFileSync6 } from "fs";
|
|
1792
|
-
import { Command as
|
|
2295
|
+
import { Command as Command11 } from "commander";
|
|
1793
2296
|
init_output();
|
|
1794
2297
|
var EXTENSION_BY_CONTENT_TYPE2 = {
|
|
1795
2298
|
"model/ply": "ply"
|
|
1796
2299
|
};
|
|
1797
2300
|
function createModel3dCommand() {
|
|
1798
|
-
return new
|
|
2301
|
+
return new Command11("3d").description("Generate a 3D model from a prompt and/or image").argument("[prompt]", "3D model description (optional with --image)").option(
|
|
1799
2302
|
"--model <model>",
|
|
1800
2303
|
"3D model (default: microsoft/trellis-2 with --image, hyper3d/rodin-2.5 for text-only)"
|
|
1801
2304
|
).option(
|
|
@@ -1847,10 +2350,10 @@ function createModel3dCommand() {
|
|
|
1847
2350
|
// src/commands/gen/text.ts
|
|
1848
2351
|
import { writeFileSync as writeFileSync7 } from "fs";
|
|
1849
2352
|
import chalk5 from "chalk";
|
|
1850
|
-
import { Command as
|
|
2353
|
+
import { Command as Command12 } from "commander";
|
|
1851
2354
|
init_output();
|
|
1852
2355
|
function createTextCommand() {
|
|
1853
|
-
return new
|
|
2356
|
+
return new Command12("text").description(
|
|
1854
2357
|
"Generate text from a prompt (also reads stdin: echo 'hello' | polli gen text)"
|
|
1855
2358
|
).argument("[prompt]", "Text prompt (or pipe via stdin)").option("--model <model>", "Text model").option("--system <msg>", "System message").option("--temperature <n>", "Randomness (0-2)").option("--max-tokens <n>", "Maximum output tokens").option("--top-p <n>", "Nucleus sampling (0-1)").option("--frequency-penalty <n>", "Repetition penalty (-2 to 2)").option("--presence-penalty <n>", "Topic penalty (-2 to 2)").option("--seed <n>", "Reproducibility seed").option("--json-response", "Force model to return JSON object").option(
|
|
1856
2359
|
"--reasoning <effort>",
|
|
@@ -1863,8 +2366,8 @@ function createTextCommand() {
|
|
|
1863
2366
|
"Wait for full response instead of streaming tokens"
|
|
1864
2367
|
).action(async (promptArg, opts, command) => {
|
|
1865
2368
|
const stdinText = (await readStdin(promptArg ? 3e3 : void 0)).trim();
|
|
1866
|
-
const
|
|
1867
|
-
if (!
|
|
2369
|
+
const prompt2 = promptArg || stdinText;
|
|
2370
|
+
if (!prompt2) {
|
|
1868
2371
|
printError(
|
|
1869
2372
|
"No prompt provided. Pass as argument or pipe via stdin."
|
|
1870
2373
|
);
|
|
@@ -1891,13 +2394,13 @@ ${stdinText}` : stdinText;
|
|
|
1891
2394
|
`--image requires a public http(s) URL, not a local path: ${invalidImage}`
|
|
1892
2395
|
);
|
|
1893
2396
|
if (images.length > 0) {
|
|
1894
|
-
const parts = [{ type: "text", text:
|
|
2397
|
+
const parts = [{ type: "text", text: prompt2 }];
|
|
1895
2398
|
for (const url of images) {
|
|
1896
2399
|
parts.push({ type: "image_url", image_url: { url } });
|
|
1897
2400
|
}
|
|
1898
2401
|
messages.push({ role: "user", content: parts });
|
|
1899
2402
|
} else {
|
|
1900
|
-
messages.push({ role: "user", content:
|
|
2403
|
+
messages.push({ role: "user", content: prompt2 });
|
|
1901
2404
|
}
|
|
1902
2405
|
const body = { messages };
|
|
1903
2406
|
if (opts.model) body.model = opts.model;
|
|
@@ -2020,10 +2523,10 @@ ${stdinText}` : stdinText;
|
|
|
2020
2523
|
// src/commands/gen/transcribe.ts
|
|
2021
2524
|
import { readFileSync as readFileSync4 } from "fs";
|
|
2022
2525
|
import { basename as basename2 } from "path";
|
|
2023
|
-
import { Command as
|
|
2526
|
+
import { Command as Command13 } from "commander";
|
|
2024
2527
|
init_output();
|
|
2025
2528
|
function createTranscribeCommand() {
|
|
2026
|
-
return new
|
|
2529
|
+
return new Command13("transcribe").description("Transcribe audio to text (speech-to-text)").argument("<file>", "Audio file path (mp3, wav, etc.)").option(
|
|
2027
2530
|
"--model <model>",
|
|
2028
2531
|
"STT model (whisper, scribe, universal-2, universal-3.5-pro)",
|
|
2029
2532
|
"whisper"
|
|
@@ -2057,14 +2560,14 @@ function createTranscribeCommand() {
|
|
|
2057
2560
|
|
|
2058
2561
|
// src/commands/gen/video.ts
|
|
2059
2562
|
import { writeFileSync as writeFileSync8 } from "fs";
|
|
2060
|
-
import { Command as
|
|
2563
|
+
import { Command as Command14 } from "commander";
|
|
2061
2564
|
init_output();
|
|
2062
2565
|
var DEFAULT_VIDEO_MODEL = "google/veo-3.1-fast";
|
|
2063
2566
|
function createVideoCommand() {
|
|
2064
|
-
return new
|
|
2567
|
+
return new Command14("video").description("Generate a video from a prompt").argument("<prompt>", "Video description").option("--model <model>", "Video model (default: API default)").option("--width <n>", "Video width").option("--height <n>", "Video height").option("--duration <n>", "Duration in seconds (1-30)").option("--aspect-ratio <ratio>", "16:9 or 9:16").option("--audio", "Include AI soundtrack").option("--seed <n>", "Random seed").option(
|
|
2065
2568
|
"--image <url...>",
|
|
2066
2569
|
"Reference frame URL(s) for start/end frames (repeatable)"
|
|
2067
|
-
).option("--output <path>", "Save to file", "video.mp4").option("--estimate", "Show the estimated Pollen cost; don't generate").action(async (
|
|
2570
|
+
).option("--output <path>", "Save to file", "video.mp4").option("--estimate", "Show the estimated Pollen cost; don't generate").action(async (prompt2, opts) => {
|
|
2068
2571
|
const isHuman = getOutputMode() === "human";
|
|
2069
2572
|
const params = new URLSearchParams();
|
|
2070
2573
|
if (opts.model) params.set("model", opts.model);
|
|
@@ -2095,7 +2598,7 @@ function createVideoCommand() {
|
|
|
2095
2598
|
duration: opts.duration ? Number(opts.duration) : void 0,
|
|
2096
2599
|
audio: !!opts.audio
|
|
2097
2600
|
});
|
|
2098
|
-
const encodedPrompt = encodeURIComponent(
|
|
2601
|
+
const encodedPrompt = encodeURIComponent(prompt2);
|
|
2099
2602
|
const path = `/video/${encodedPrompt}?${params}`;
|
|
2100
2603
|
prepareOutputPath(opts.output);
|
|
2101
2604
|
if (isHuman)
|
|
@@ -2118,10 +2621,10 @@ function createVideoCommand() {
|
|
|
2118
2621
|
// src/commands/gen/voice-change.ts
|
|
2119
2622
|
import { readFileSync as readFileSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
2120
2623
|
import { basename as basename3 } from "path";
|
|
2121
|
-
import { Command as
|
|
2624
|
+
import { Command as Command15 } from "commander";
|
|
2122
2625
|
init_output();
|
|
2123
2626
|
function createVoiceChangeCommand() {
|
|
2124
|
-
return new
|
|
2627
|
+
return new Command15("voice-change").description("Re-speak a local audio file in another voice").argument("<file>", "Source audio file path").option(
|
|
2125
2628
|
"--voice <voice>",
|
|
2126
2629
|
"Preset voice name or ElevenLabs voice ID",
|
|
2127
2630
|
"alloy"
|
|
@@ -2162,12 +2665,12 @@ function createVoiceChangeCommand() {
|
|
|
2162
2665
|
|
|
2163
2666
|
// src/commands/gen/index.ts
|
|
2164
2667
|
function createGenCommand() {
|
|
2165
|
-
return new
|
|
2668
|
+
return new Command16("gen").description("Generate text, images, audio, video, and more").addCommand(createTextCommand()).addCommand(createImageCommand()).addCommand(createAudioCommand()).addCommand(createVideoCommand()).addCommand(createModel3dCommand()).addCommand(createEmbeddingsCommand()).addCommand(createVoiceChangeCommand()).addCommand(createIsolateCommand()).addCommand(createChatCommand()).addCommand(createTranscribeCommand());
|
|
2166
2669
|
}
|
|
2167
2670
|
|
|
2168
2671
|
// src/commands/harness.ts
|
|
2169
2672
|
import { homedir as homedir2 } from "os";
|
|
2170
|
-
import { Command as
|
|
2673
|
+
import { Command as Command17 } from "commander";
|
|
2171
2674
|
|
|
2172
2675
|
// src/harnesses/bloom.ts
|
|
2173
2676
|
import { join as join4 } from "path";
|
|
@@ -2623,7 +3126,7 @@ var runScript = (ctx, script, args, input) => {
|
|
|
2623
3126
|
};
|
|
2624
3127
|
};
|
|
2625
3128
|
var generic = (ctx, ...args) => runScript(ctx, "providers.mjs", ["generic", ...args]);
|
|
2626
|
-
var
|
|
3129
|
+
var parseJson2 = (run2, what) => {
|
|
2627
3130
|
if (!run2.ok) {
|
|
2628
3131
|
throw new Error(
|
|
2629
3132
|
`${what}: ${(run2.err || run2.out).trim().slice(0, 500)}`
|
|
@@ -2638,7 +3141,7 @@ var parseJson = (run2, what) => {
|
|
|
2638
3141
|
var provider = (ctx) => {
|
|
2639
3142
|
const run2 = generic(ctx, "show", PROVIDER, "--json");
|
|
2640
3143
|
if (!run2.ok) return null;
|
|
2641
|
-
return
|
|
3144
|
+
return parseJson2(
|
|
2642
3145
|
run2,
|
|
2643
3146
|
"Codex Router provider status"
|
|
2644
3147
|
).provider;
|
|
@@ -2649,7 +3152,7 @@ var ownsProvider = (value) => Boolean(
|
|
|
2649
3152
|
var credentialConfigured = (ctx) => {
|
|
2650
3153
|
const run2 = generic(ctx, "credential", PROVIDER, "status", "--json");
|
|
2651
3154
|
if (!run2.ok) return false;
|
|
2652
|
-
return
|
|
3155
|
+
return parseJson2(
|
|
2653
3156
|
run2,
|
|
2654
3157
|
"Codex Router credential status"
|
|
2655
3158
|
).configured === true;
|
|
@@ -2809,7 +3312,7 @@ var configureCodex = async (ctx, model, options = {}) => {
|
|
|
2809
3312
|
if (!check.ok) {
|
|
2810
3313
|
throw failRun(check, "Codex Router smoke test");
|
|
2811
3314
|
}
|
|
2812
|
-
const result10 =
|
|
3315
|
+
const result10 = parseJson2(check, "Codex Router smoke test");
|
|
2813
3316
|
if (result10.ok !== true || !result10.results?.some(
|
|
2814
3317
|
(item) => item.name === "basic response" && item.ok === true
|
|
2815
3318
|
)) {
|
|
@@ -2889,7 +3392,7 @@ import { parseEnv as parseEnv2 } from "util";
|
|
|
2889
3392
|
import { isMap, isSeq, parseDocument, Scalar } from "yaml";
|
|
2890
3393
|
|
|
2891
3394
|
// SKILL.md?raw
|
|
2892
|
-
var SKILL_default = '---\nname: polli\ndescription: Generate images, text, audio, video, and transcribe speech via the Pollinations API using the polli CLI. Use when asked to generate media, call pollinations.ai, check pollen balance, list models, manage API keys, inspect quests, manage agents or my-models, publish a static site, or run polli commands.\nallowed-tools: Bash(polli *)\n---\n\n# polli \u2014 Pollinations CLI\n\nThin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys, usage, quests, agents, and invite-only my-models.\n\nIf `polli` is not installed, run `npm i -g @pollinations/cli@latest` (provides the `polli` binary).\n\n## When to use this skill\n\n- User asks to **generate an image / text / audio / video** via pollinations\n- User mentions **polli, pollinations, pollen, pollinations.ai**\n- User wants to **transcribe speech** or run TTS\n- User asks about their **pollen balance, usage, or API keys**\n- User wants to **browse or filter available models**\n- User wants to inspect **quests** or manage invite-only **my-models**\n- User wants to create or update a hosted prompt **agent**\n- User wants to **publish a website or web app** they built\n\nFor agent-assisted login, use `polli --json auth login --no-browser`. Read stderr while the command runs and show the user the verification URL and user code so they can review access. On approval, stdout contains one JSON result: `{"authenticated":true}`. Tokens are stored locally and never included in that result.\n\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\n| Agent-assisted login | `polli --json auth login --no-browser` |\n| Store an existing key | `printf \'%s\' "$POLLINATIONS_API_KEY" \\| polli auth login --with-token` |\n| Generate image | `polli gen image "<prompt>" --output out.png` |\n| Generate text | `polli gen text "<prompt>"` |\n| Text with stdin as context | `echo "<ctx>" \\| polli gen text "<question>"` |\n| Describe an image (vision) | `polli gen text "what is this?" --image <url>` |\n| One-shot TTS | `polli gen audio "<text>" --output speech.mp3` |\n| Speak out loud | `polli gen audio "<text>" --play` (uses `afplay` on macOS; `ffplay`/`mpv`/`mpg123` on Linux) |\n| Generate video | `polli gen video "<prompt>" --output out.mp4` |\n| Generate a 3D model | `polli gen 3d "<prompt>" --output out.glb` (or `--image <url>` for image-only models) |\n| Embed text | `polli gen embeddings "<text>" ["<text2>" ...]` (one vector per line; also reads stdin) |\n| Change a voice | `polli gen voice-change talk.mp3 --voice nova` |\n| Isolate speech | `polli gen isolate interview.mp4` (strips music/noise) |\n| Speech + character timings | `polli gen audio "<text>" --timestamps` (also writes `speech.mp3.json`) |\n| Transcribe audio | `polli gen transcribe path/to.mp3` |\n| Upload a local file | `polli upload path/to.png` (prints public URL) |\n| List all models | `polli models` |\n| Search models | `polli models <query>` (`--source official\\|community`, `--reliability all`) |\n| Discover voices | `polli models --type audio --voices` (one line per model) |\n| Filter models by type | `polli models --type image` (text, decision, image, audio, video, 3d, embedding, realtime) |\n| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |\n| Check balance | `polli usage` |\n| Developer earnings | `polli earnings` (`--days <n>`) |\n| List your quests + claim state | `polli quests` (filters: `--open --claimable --claimed --coming-soon`) |\n| Manage prompt agents | `polli agents list` |\n| Manage invite-only community models | `polli my-models list` |\n| Update the CLI | `polli update` (global installs only; npx/local get instructions) |\n| Connect a coding harness to Pollinations | `polli harness <bloom\\|dsh\\|hermes\\|opencode\\|openclaw\\|pi\\|prime\\|tgpt\\|vibe> on` (available adapters: `polli harness --help`) |\n| Start a Linux sandbox (alpha) | `polli sandbox create` (`--timeout <seconds>` to keep it running without ssh, `0` until you pause or kill it; `pollinations-large` as the template for 4 vCPU and 8 GB; then `list`, `logs <id>`, `timeout <id> <seconds>`, `pause <id>`, `kill <id>`); the default template comes logged in, with the coding harnesses |\n| ssh / scp / rsync into a sandbox | `ssh <sandbox-id>.polli`. Port forwarding (`ssh -L 3000:localhost:3000 <sandbox-id>.polli`) and VS Code Remote-SSH work. An open connection keeps the sandbox running and paid; it pauses 15\u201320 minutes after the last one closes (5\u201310 on Windows) |\n| Publish a static site | `polli sites deploy ./dist --name my-app` (prints `https://my-app.pollinations.app`; then `list`, `delete <name>`) |\n| Machine-readable output | append `--json` to any command |\n\n## Setup\n\nOne-time: `polli auth login` (device-flow; creates a key with `profile`, `usage`, and `keys`). To store an existing key, run\n`printf \'%s\' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify\nwith `polli auth status` (or `polli whoami`).\nOverride the stored key for a single command with `--key <key>`, or set `POLLINATIONS_API_KEY` in the environment.\nPrefix any command with `POLLINATIONS_ENV=staging` to use staging; it keeps its own login, so run `POLLINATIONS_ENV=staging polli auth login` once. An exported `POLLINATIONS_API_KEY` wins over both logins.\n\n## Recipes\n\n### Generate an image to a file\n```bash\npolli gen image "a fox reading a book, studio ghibli style" --output fox.png\n```\nDefaults: `tongyi-mai/z-image-turbo`, 1024x1024. Without `--output` the file is `image.<ext>`, with the extension inferred from the response\'s `Content-Type` (`tongyi-mai/z-image-turbo` and `black-forest-labs/flux.1-schnell` return JPEG, so `image.jpg`); an explicit `--output` is used as given. Pick a different model with `--model black-forest-labs/flux.1-schnell` (see `polli models --type image`). For edits / img2img, pass one or more `--image <url>` flags \u2014 **must be public http(s) URLs**, local paths are rejected client-side. **Only models that list `"image"` in `input_modalities` actually consume the flag** \u2014 `black-forest-labs/flux.1-schnell` and `tongyi-mai/z-image-turbo` are text-only and will silently ignore `--image`. Find i2i-capable models with `polli models --type image --json | jq -r \'.[] | select(.input_modalities | contains(["image"])) | .name\'` (common choices: `google/gemini-2.5-flash-image`, `black-forest-labs/flux.1-kontext-pro`, `prunaai/p-image-edit`). To use a local file, upload it first with `polli upload` (see next recipe). **Img2img models may treat `--width`/`--height` as a hint** and keep the source aspect \u2014 check the output with `file`/`ffprobe`; if the aspect matters, pre-crop the source or crop afterwards.\n\n### Upload a local file to get a public URL\n```bash\nURL=$(polli upload cat.png)\npolli gen image "make the cat purple" --image "$URL" --output purple.png\n```\n`polli upload <file>` streams one raw-file request to `media.pollinations.ai` (400 MiB max; 30-day lifecycle, refreshed by GETs once the object is at least 15 days old). Each upload receives a unique id. Human mode: URL on stdout and id/size/contentType on stderr. `--json`: full upload response on stdout. The returned URL is public (no auth to fetch) and works anywhere `--image` is accepted \u2014 `gen image`, `gen video`, etc.\n\n### Generate text\n```bash\npolli gen text "summarize the three laws of robotics"\n```\nSave to file: `--output summary.txt`. Use `--system "<msg>"` to set system prompt. For reasoning models, pass `--reasoning low|medium|high` to control reasoning effort. **Only send `--reasoning` to models where `reasoning: true`** in `polli models --type text --json` \u2014 the flag is not validated client-side, and non-reasoning models may silently accept it (openai), ignore it, or return a 400 (mistral).\n\n### Describe an image with a vision model\n```bash\nURL=$(polli upload selfie.jpg)\npolli gen text "turn this person into a cartoon pet in one playful sentence" --image "$URL"\n```\n`gen text --image <url...>` attaches one or more **public https URLs** as an OpenAI-style multimodal message \u2014 repeatable for multi-image prompts. Local paths aren\'t supported; run them through `polli upload` first (see the upload recipe above). **Only text models with `"image"` in `input_modalities` actually read the image** \u2014 filter with `polli models --type text --json | jq -r \'.[] | select(.input_modalities | index("image")) | .name\'`. Non-vision models silently ignore the attachment. Good defaults: `openai`, `gemini`, `claude`.\n\n### Pipe stdin as context into text generation\n```bash\ncat README.md | polli gen text "what does this project do?"\n```\nstdin becomes context; the positional argument is the question.\n\n### Interactive chat session\n```bash\npolli gen chat --model openai/gpt-5.4-nano --system "you are a terse assistant"\n```\nSlash commands inside the session: `/exit`, `/clear`, `/save <path>`.\n\n### Text-to-speech\n```bash\npolli gen audio "hello world" --voice nova --output hello.mp3\necho "long script" | polli gen audio --voice nova --output out.mp3\n```\nWithout `--voice`, the API uses the model\'s default voice. Voices differ per model: `polli models --type audio --voices` lists each model\'s voices, so pass the matching `--model` with `--voice`. Format defaults to mp3; `--format opus|aac|flac|wav` to change. Accepts stdin (same as `gen text`). Add `--play` to save and then play the audio back (handy for narration/demos). Playback starts after the file is fully written, and the command blocks until playback finishes \u2014 if you want fire-and-forget, wrap in a subshell: `( polli gen audio "..." --play & )`. Player on macOS: `afplay`; on Linux it tries `ffplay`, then `mpv`, then `mpg123` in that order.\n\n### Generate music (elevenlabs/music-v2)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenlabs/music-v2 --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (elevenlabs/eleven-text-to-sound-v2)\n```bash\npolli gen audio "thunderclap with heavy rain" --model elevenlabs/eleven-text-to-sound-v2 --duration 5 --output thunder.mp3\n```\nText-to-sound-effect via ElevenLabs (aliases: `sfx`, `sound-effects`). `--duration` 0.5\u201330s (omit to let the model pick). Billed per second of output (~$0.004/s, capped at $0.12 for a full 30s).\n\n### Multilingual TTS (elevenlabs/eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model elevenlabs/eleven-multilingual-v2 --voice rachel --output fr.mp3\n```\nStable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) \u2014 a non-alpha alternative to the default v3.\n\n### Estimate the cost before generating\n```bash\npolli gen image "a fox" --model flux --estimate\npolli gen video "a spacecraft landing on mars" --model veo --duration 8 --audio --estimate\n```\n`--estimate` reads the public model list (`/image/models`), prints the estimated Pollen for that request and exits without generating. Per-image, per-megapixel and per-second rates, plus fixed per-generation fees, give a number; token-billed models (e.g. `gpt-image-2`, `nanobanana`) print `estimate: unknown` with their rates, because the charge depends on usage the provider reports afterwards. `--json` adds `pollen` (null when unknown) and the per-rate `lines`.\n\n### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model alibaba/wan-2.2-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model alibaba/wan-2.2-fast` at ~$0.01/sec, **fixed 5-second output** (any `--duration` value is ignored \u2014 you always pay for and receive 5 sec). For image-to-video, pass `--image <url>` with a **public HTTPS URL** (local file paths and 404/rate-limited hosts will fail with a server error).\n\n**Flag support varies per model and is not enforced client-side.** `--duration`, `--aspect-ratio`, and `--audio` are forwarded to the server but may be silently ignored \u2014 verified on `wan-fast` where duration is locked to 5s, `--aspect-ratio 9:16` still returns 16:9, and `--audio` produces no audio track. Always inspect the output (`file`, `ffprobe`) before trusting a flag worked. Check `polli models --type video --json` for per-model capabilities.\n\n**Video is not tracked by `--stats`.** `polli models --type video --stats` returns empty \u2014 the stats pipe only records text/image/audio events. To compare video models, fall back to `polli models --type video --json` and look at price/description fields. The same applies to `--type 3d`.\n\n### Generate a 3D model\n```bash\npolli gen 3d "a red fox" --output fox.glb\npolli gen 3d --image https://media.pollinations.ai/abc --resolution high\n```\n`--model` defaults to `hyper3d/rodin-2.5` for a text-only prompt and `microsoft/trellis-2` once `--image <url>` is given (public http(s), upload local files first with `polli upload`) \u2014 `trellis-2` is **image-to-3D only** and rejects a bare prompt. `--resolution low|medium|high` only affects `trellis-2`. The output extension is inferred from the response\'s `Content-Type`, not the model name: `nvidia/asset-harvester` returns a Gaussian Splat `.ply`, everything else returns `.glb`. `hyper3d/rodin-2.5` and `nvidia/asset-harvester` require Paid Pollen.\n\n### Generate embeddings\n```bash\npolli gen embeddings "first text" "second text" --model google/gemini-embedding-2\nprintf \'first\\nsecond\\n\' | polli gen embeddings # one input per stdin line\n```\nPrints one JSON array per input, in input order, one per line (pipe/`jq`-friendly). `--dimensions <n>` (128-4096), `--task-type` (Gemini retrieval hint), and `--input-type query|document` (Cohere) are optional. `--json` prints the full response including `usage`.\n\n### Change or isolate a voice\n```bash\npolli gen voice-change talk.mp3 --voice nova --format wav\npolli gen isolate interview.mp4\n```\n`voice-change` re-speaks a **local** audio file in another voice (preset name or ElevenLabs voice ID) \u2014 default output `voice.<format>`. `isolate` strips music/background noise from local audio **or video**, keeping only speech \u2014 default output `isolated.mp3`. Both upload the file as multipart form data; ElevenLabs requires **at least 4.6 seconds** of audio for isolation, shorter clips fail with the API\'s `audio_too_short` error.\n\n### Speech with character-level timestamps\n```bash\npolli gen audio "Hello world" --timestamps\n```\nSaves the audio as usual (`speech.mp3` by default) and appends `.json` to its path for the `alignment`/`normalized_alignment` character timings. Only `elevenlabs/eleven-v3`, `elevenlabs/eleven-flash-v2.5`, and `elevenlabs/eleven-multilingual-v2` support this \u2014 other models fail with the API\'s error message.\n\n### Transcribe audio to text\n```bash\npolli gen transcribe recording.mp3 --language en\n```\nModels: `openai/whisper-large-v3` (default), `elevenlabs/scribe-v2`, `assemblyai/universal-2`, `assemblyai/universal-3.5-pro`. Accepts common audio formats (mp3, wav, m4a, flac, ogg); non-audio input (e.g. a `.txt` file) returns a clear `400 invalid_request_error: extension "txt" not supported` \u2014 no need to pre-validate with `file`. Default output is the plain transcript on stdout as a single line (pipe-friendly). Use `--json` for structured output: **whisper** and **AssemblyAI** return timing data when requested through the API; **scribe** returns only `{text: "..."}` \u2014 use whisper or AssemblyAI if you need timing data. `--language <ISO-639-1>` (e.g. `en`, `fr`) is an optional hint that can improve accuracy for non-English or accented speech.\n\n### Discover models\n```bash\npolli models --type text # text models only\npolli models flux # search name, aliases, title, description, publisher\npolli models --source community # official or community only\npolli models --reliability all # also community models failing health checks\npolli models --type audio --voices # voices per model\npolli models --type image --verbose # with publisher, context length, pricing\npolli models --stats # health + avg latency + err% (60m default)\npolli models --stats --window 5 # last 5 minutes only\n```\nUse `--stats` before choosing a model. **Caveat**: the `err%` column counts **5xx only** \u2014 a model can show `0.0%` while having massive 4xx rates (auth, validation, etc.). For the full picture use `--stats --json` and read `errors_4xx`, `errors_5xx`, `latency_p95_ms`.\n\n**Pricing fields are per-token, not per-request.** `completionImageTokens: 0.000008` means each output image-token costs that much \u2014 a single 1024x1024 image from `openai/gpt-image-1-mini` lands at ~$0.008, not $0.000008. Flat-priced image models (`black-forest-labs/flux.1-schnell`, `tongyi-mai/z-image-turbo`) expose `completionImageTokens` as the whole-image price because they emit exactly one "token" per image. When in doubt, make one call and read the true cost from `polli usage --history --limit 5 --json`.\n\n### Check usage and balance\n```bash\npolli usage # current pollen balance\npolli usage --history # recent individual requests\npolli usage --daily # daily cost summary\npolli usage --daily --key polli-harness-claude --days 1 # cost of one harness key for the last day (`--model`, `--csv` filter/export both views; `--key` is repeatable)\npolli earnings # developer earnings total + per-entity breakdown (default 30d)\npolli earnings --days 7 # rolling window\npolli quests # your quests + claim state (open/claimable/claimed/closed/coming)\npolli quests --claimable # only rewards ready to claim\n```\n**History is eventually consistent** \u2014 a request you just made may not appear for 30\u201360s. When matching costs to freshly-generated media, use `--limit 50` and filter by timestamp, and retry if the expected entry is missing. `polli usage --json` returns `{"pollen": <number>}` \u2014 the current balance only; use `--history --json` or `--daily --json` for cost breakdowns. Those print a JSON array of the API usage records (numeric `cost_usd`, `api_key_id`, available per-modality token fields), not the table columns.\n\n### Manage my-models\n```bash\npolli my-models list\npolli my-models models --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY"\npolli my-models create --name my-model --title "My Model" --api chat_completions --url https://api.example.com/v1/chat/completions --bearer-token "$UPSTREAM_KEY" --upstream-model gpt-4.1-mini --required-safety privacy,secrets,sexual,violence,shield\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model flux\npolli my-models update <id> --description "Updated description"\npolli my-models update <id> --paid-only # only accept Paid Pollen; --no-paid-only reverts\npolli my-models update <id> --required-safety privacy,secrets,sexual,violence,shield\npolli my-models delete <id>\n```\n`my-models` manages owned community text, image, and transcription models. Any account can create private models; `communityEndpointsAllowed: true` is required only to publish them. API keys require `account:keys`. Use `account:usage` for narrow read-only usage and `polli quests`; use both permissions when a client needs both read-only account state and admin operations. Quest claiming is dashboard-only; `polli quests` is read-only and account-aware.\n\n### Register an image my-model\n```bash\npolli my-models test --modality image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --model image-v1\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --input-modalities text,image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model image-v1\n```\nTest before creating. The probe reports the pricing mode it detected and the input modalities it found, including whether the endpoint accepts image edits; pass those back as `--input-modalities text,image` to advertise edit support. `polli my-models list` shows them in the `inputs` column.\n\nTwo billing modes: `--image-pricing request` charges `--completion-image-price` per generated image, while `--image-pricing tokens` bills returned token usage per 1M through `--prompt-text-price`, `--prompt-image-price`, and `--completion-image-price`.\n\nPrices only apply to `--visibility public` models. A private model is owner-only and always free, so every price flag above is stored as `0` until you publish \u2014 and making a published model private clears its prices again.\n\n`--modality` is fixed at creation \u2014 `update` cannot change it.\n\n### Manage agents\n\n```bash\npolli agents list\npolli agents get <id>\npolli agents create --config agent.json --name my-agent --title "My Agent"\npolli agents create --config code-agent.json\npolli agents update <id> --config agent.json\npolli agents sync <id>\npolli agents delete <id>\n```\nPrompt-agent config contains `systemPrompt`, `baseModel`, and optional `mcpServers` (add `composio` to act in the caller\'s own accounts, such as a GitHub commit; callers connect apps at https://enter.pollinations.ai/account#connectors); create also requires `--name` and `--title`. Code-agent config contains `type: "code_agent"` and a public GitHub `repository` with `agent.ts` at its root; its model ID, title, and description come from GitHub. Use server IDs from the MCP catalog. Updates are partial: send only the fields to change; the rest keep their values. `sync` deploys the latest GitHub revision of a code agent.\n\nCreating an agent also creates its callable model listing. Managed agents are text-only and free, with no fallbacks or per-user RPM. Deleting the agent also deletes its model listing. See [Publish an Agent](https://github.com/pollinations/pollinations/blob/main/BUILD_YOUR_OWN_AGENT.md).\n\n### Publish a static site\n```bash\nnpm run build\npolli sites deploy ./dist --name my-app --verify # \u2192 https://my-app.pollinations.app\npolli sites list\npolli sites delete my-app\n```\nPublishes a folder of static files with an `index.html`; unknown paths serve `index.html`, so single-page apps route on the client. Deploying the same name again replaces the site and uploads only changed files. Names are 3\u201332 lowercase letters, digits and hyphens, starting with a letter; the first deploy claims the name. Limits: 5 sites per account, 200 MB and 1,000 files per site, 25 MiB per file. Dotfiles and `node_modules` are not uploaded. Sites are public: never put an API key in them. To call Pollinations from a site, let visitors connect through Pollinations Connect and spend their own Pollen (see [Pollinations Pay](https://gen.pollinations.ai/docs/llm.txt?section=byop)). Share the URL the command prints rather than composing one from the name.\n\n`--verify` reads every published file without credentials and compares its bytes to the build, following redirects and retrying failures. The published URL (or site object with `--json`) is printed before verification. A failed check reports that the site is published, exits non-zero and does not roll back.\n\n### Manage API keys\n```bash\npolli keys list # list all keys on the account\npolli keys info # details about the CURRENTLY AUTHENTICATED key only (takes no id)\npolli keys create --name "my-bot" --type secret --budget 1000 --permissions profile usage # scoped key\npolli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings\npolli keys create --name "server" --models black-forest-labs/flux.1-schnell tongyi-mai/z-image-turbo # only these two models\npolli keys update <id> --models text black-forest-labs/flux.1-schnell # every text model plus FLUX.1 Schnell\npolli keys revoke <id> # id comes from `keys list --json`\n```\n`--models` takes categories (`text`, `image`, `video`, `audio`, `3d`, `embedding`, `realtime`, `decision`) and model IDs from `polli models`. A category includes models added later; a model ID allows only that model.\n`--permissions <perms...>` scopes what the new key can do on the account (e.g. `profile usage` lets it call `polli --key <new> usage`). **Without `--permissions`, new scoped keys can generate media but cannot read account state** \u2014 `polli --key <new> usage` will 403. Include `keys` to let the new key create, list, and revoke keys itself. Existing keys with `account:keys` can manage my-models where that invite-only feature is enabled, but still need `account:usage` for read-only account state. Publishable app keys default developer earnings off; pass `--earnings` to enable them. To inspect a specific key other than the current one, use `polli keys list --json | jq \'.[] | select(.id == "<id>")\'`. `keys info` is intentionally scoped to the caller\'s own key.\n\n### Connect a coding harness\nPolli defaults to `openai/gpt-6-sol`; `--model <id>` overrides it. Bloom is key-only and keeps its own model selection.\n\n```bash\npolli harness --help # supported harnesses\npolli harness bloom on # create a dedicated key for Bloom CLI\npolli harness dsh on # login if needed, mint key "polli-harness-dsh", write provider + default model\npolli harness dsh on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness dsh on --no-mcp # configure the provider and skill without MCP tools\npolli harness dsh off # restore the config backed up before "on"\npolli harness hermes on # login if needed, mint key "polli-harness-hermes", add provider + Polli skill\npolli harness hermes on --model deepseek/deepseek-v4-flash # use the model ID from `polli models`\npolli harness hermes off # restore the config backed up before "on"\npolli harness opencode on # add the Pollinations provider (OpenCode 1.x and 2.x)\npolli harness opencode off # remove the provider setup and stored key\npolli harness pi on # login if needed, mint key "polli-harness-pi", configure Pi with Pollinations\npolli harness pi on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness pi off # restore the Pi config backed up before "on"\npolli harness openclaw on # login if needed, mint key "polli-harness-openclaw", add provider + Polli skill\npolli harness openclaw off # remove the Pollinations provider, key, and skill\npolli harness tgpt on # use tgpt\'s Pollinations provider with a dedicated key\npolli harness tgpt off # restore tgpt\'s previous configuration\npolli harness vibe on # Mistral Vibe provider, live models, dedicated key, and Polli skill\npolli harness vibe on --model deepseek/deepseek-v4-flash\npolli harness vibe off # restore Vibe\'s previous user configuration\n```\nEach adapter checks that its harness can be launched before login, key creation, or configuration. DSH\'s official launch uses `npx`, so its adapter checks for `npx`; Bloom, Hermes Agent, OpenCode, OpenClaw, Pi, tgpt, and Mistral Vibe require their installed commands.\n\nMistral Vibe writes `$VIBE_HOME/config.toml`, `.env`, and `skills/polli/` (default `~/.vibe`), using the native OpenAI-compatible provider. Session titles and smart approval use the selected Pollinations model too. Restart Vibe afterward; project, agent, admin, and environment overrides still take precedence. Setup reformats TOML; `off` restores untouched files or strips only the Pollinations setup after edits. Install with `uv tool install mistral-vibe`.\n\nBloom already uses Pollinations and only needs a dedicated key in `$BLOOM_HOME/.env` (default `~/.bloom/.env`). tgpt\'s existing Pollinations provider is selected in `~/.config/tgpt/config.conf` with a dedicated key and model. The DSH adapter globally configures the Pollinations provider, hosted Pollinations MCP, and this skill under `$DSH_HOME` (default `~/.dsh`). OpenCode adds a `pollinations` provider (read by both 1.x and 2.x) and stores its dedicated key in the provider\'s options. OpenClaw adds a `pollinations` provider to `~/.openclaw/openclaw.json`, stores a dedicated key in `env.vars`, and installs this skill under `~/.openclaw/skills/polli/`. Pi writes `~/.pi/agent/models.json`, `auth.json`, and `settings.json`, and installs this skill under `~/.pi/agent/skills/polli/`. Guide: `polli docs` section "Coding Harnesses".\n\n### Read API docs\n```bash\npolli docs # full llm.txt reference\npolli docs /v1/chat/completions # filter to one endpoint\npolli docs --open # open in browser\n```\n\n## Output contract\n\n- **Default (human mode):** varies by command \u2014 most emit `key: value` pairs or tab-separated tables with a header row. Exceptions: `gen text` prints the full response to stdout; `gen transcribe` prints the transcript as plain text; `gen chat` runs an interactive REPL. Status/progress messages go to stderr, so pipes stay clean.\n- **`--json`:** every command emits machine-parseable JSON to stdout; all human messages go to stderr. **Always prefer `--json` when piping into `jq` or parsing** \u2014 it\'s the only shape with a stable contract.\n- **Exit codes:** 0 on success, non-zero on auth failure, rate limit, network error, or invalid args. Error messages go to stderr.\n\n## Agent operating rules\n\n1. **Run `polli auth status` (or `polli whoami`) first** if you don\'t know whether the user is logged in. Fail fast with a clear "run `polli auth login`" message if not.\n2. **Prefer `--json`** whenever you\'ll parse the output. Never grep human-formatted tables.\n3. **Don\'t hardcode model IDs.** Fetch the live list with `polli models --type <type>`. Model availability changes.\n4. **Before picking a model for production use, check `polli models --stats`.** Rule of thumb for "healthy": `err%` \u2264 5, `avg` latency in a reasonable range for the modality (standard text <5s, image <10s, video <60s), and `requests` high enough to be statistically meaningful (ignore rows with <10 requests \u2014 noise). **Filter by capability first, then optimize by health** \u2014 e.g. for a reasoning task, narrow to models where `reasoning: true` (via `polli models --type text --json`), *then* cross-reference against `--stats` output. The healthiest model overall may not support the capability you need. **Reasoning models are inherently slower \u2014 expect 5\u201350s, not <5s**; when picking among them, prioritize low `err%` and request count over raw latency, and compare latency only within the reasoning-capable subset.\n5. **Always pass `--output <path>`** for `gen image`, `gen audio`, `gen video` \u2014 otherwise the file lands in the current directory with a default name.\n6. **For stdin-as-context** on `gen text`, pipe the context and pass the question as the positional argument: `cat file | polli gen text "question about the file"`.\n7. **For exact flag lists, run `polli <cmd> --help` or `polli gen <cmd> --help`.** This skill\'s recipes cover the common path; the CLI\'s own help is always the source of truth.\n8. **Use `polli docs [endpoint]` over guessing API shapes.** It prints the canonical `llm.txt` reference from the live API.\n\n## Common pitfalls\n\n- Forgetting `--output` on binary generators (image/audio/video) \u2014 the file goes to a default path, which may not be what the user wants.\n- Using `polli gen text --json` expecting OpenAI chat-completions shape \u2014 the CLI\'s `--json` wraps its own structure. Use `polli docs /v1/chat/completions` to see the raw API shape if you need it.\n- Running commands without auth \u2014 `polli auth status` / `polli whoami` tells you who you\'re logged in as and your balance in one call.\n- **`gen text` streams to a TTY, buffers when piped.** The default now auto-detects \u2014 a human at the terminal sees tokens tick in, a pipe/redirect gets the full response once. Force either mode with `--stream` or `--no-stream`. For scripts and chains like `polli gen text \u2026 | polli gen audio \u2026`, you don\'t need to do anything; buffering happens automatically.\n- **Translating a `polli` workflow into a browser app.** `gen.pollinations.ai` requires a bearer token for generation requests, so a plain client-side `fetch` with no auth returns 401 unless it is served from cache. Mint a scoped key with `polli keys create` and proxy via your own backend.\n- **Backgrounded `polli gen` can fail silently** \u2014 no output file, empty log, no error (a safety rejection is an explicit 400). Run in the foreground; if backgrounded, check the `--output` file exists and retry once in the foreground before calling it failed.\n- **Content-safety 400s aren\'t only about violence.** Body-focused action phrasing can trip a sexual-content category on some edit models. Rephrase the benign intent neutrally (e.g. sport framing) and retry with a new seed.\n';
|
|
3395
|
+
var SKILL_default = '---\nname: polli\ndescription: Generate images, text, audio, video, and transcribe speech via the Pollinations API using the polli CLI. Use when asked to generate media, call pollinations.ai, check pollen balance, list models, manage API keys, inspect quests, manage agents or my-models, publish a static site, or run polli commands.\nallowed-tools: Bash(polli *)\n---\n\n# polli \u2014 Pollinations CLI\n\nThin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys, usage, quests, agents, and invite-only my-models.\n\nIf `polli` is not installed, run `npm i -g @pollinations/cli@latest` (provides the `polli` binary).\n\n## When to use this skill\n\n- User asks to **generate an image / text / audio / video** via pollinations\n- User mentions **polli, pollinations, pollen, pollinations.ai**\n- User wants to **transcribe speech** or run TTS\n- User asks about their **pollen balance, usage, or API keys**\n- User wants to **browse or filter available models**\n- User wants to inspect **quests** or manage invite-only **my-models**\n- User wants to create or update a hosted prompt **agent**\n- User wants to **publish a website or web app** they built\n\nFor agent-assisted login, use `polli --json auth login --no-browser`. Read stderr while the command runs and show the user the verification URL and user code so they can review access. On approval, stdout contains one JSON result: `{"authenticated":true}`. Tokens are stored locally and never included in that result.\n\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\n| Agent-assisted login | `polli --json auth login --no-browser` |\n| Store an existing key | `printf \'%s\' "$POLLINATIONS_API_KEY" \\| polli auth login --with-token` |\n| Generate image | `polli gen image "<prompt>" --output out.png` |\n| Generate text | `polli gen text "<prompt>"` |\n| Text with stdin as context | `echo "<ctx>" \\| polli gen text "<question>"` |\n| Describe an image (vision) | `polli gen text "what is this?" --image <url>` |\n| One-shot TTS | `polli gen audio "<text>" --output speech.mp3` |\n| Speak out loud | `polli gen audio "<text>" --play` (uses `afplay` on macOS; `ffplay`/`mpv`/`mpg123` on Linux) |\n| Generate video | `polli gen video "<prompt>" --output out.mp4` |\n| Generate a 3D model | `polli gen 3d "<prompt>" --output out.glb` (or `--image <url>` for image-only models) |\n| Embed text | `polli gen embeddings "<text>" ["<text2>" ...]` (one vector per line; also reads stdin) |\n| Change a voice | `polli gen voice-change talk.mp3 --voice nova` |\n| Isolate speech | `polli gen isolate interview.mp4` (strips music/noise) |\n| Speech + character timings | `polli gen audio "<text>" --timestamps` (also writes `speech.mp3.json`) |\n| Transcribe audio | `polli gen transcribe path/to.mp3` |\n| Upload a local file | `polli upload path/to.png` (prints public URL) |\n| List all models | `polli models` |\n| Search models | `polli models <query>` (`--source official\\|community`, `--reliability all`) |\n| Discover voices | `polli models --type audio --voices` (one line per model) |\n| Filter models by type | `polli models --type image` (text, decision, image, audio, video, 3d, embedding, realtime) |\n| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |\n| Check balance | `polli usage` |\n| Developer earnings | `polli earnings` (`--days <n>`) |\n| List your quests + claim state | `polli quests` (filters: `--open --claimable --claimed --coming-soon`) |\n| Manage prompt agents | `polli agents list` |\n| Manage invite-only community models | `polli my-models list` |\n| Update the CLI | `polli update` (global installs only; npx/local get instructions) |\n| Use Pollinations agents in Zed or JetBrains (ACP) | `polli acp [agent]` as the editor\'s agent server command; editor MCP servers become agent tools |\n| Connect a coding harness to Pollinations | `polli harness <bloom\\|dsh\\|hermes\\|opencode\\|openclaw\\|pi\\|prime\\|tgpt\\|vibe> on` (available adapters: `polli harness --help`) |\n| Start a Linux sandbox (alpha) | `polli sandbox create` (`--timeout <seconds>` to keep it running without ssh, `0` until you pause or kill it; `pollinations-large` as the template for 4 vCPU and 8 GB; then `list`, `logs <id>`, `timeout <id> <seconds>`, `pause <id>`, `kill <id>`); the default template comes logged in, with the coding harnesses |\n| ssh / scp / rsync into a sandbox | `ssh <sandbox-id>.polli`. Port forwarding (`ssh -L 3000:localhost:3000 <sandbox-id>.polli`) and VS Code Remote-SSH work. An open connection keeps the sandbox running and paid; it pauses 15\u201320 minutes after the last one closes (5\u201310 on Windows) |\n| Publish a static site | `polli sites deploy ./dist --name my-app` (prints `https://my-app.pollinations.app`; then `list`, `delete <name>`) |\n| Machine-readable output | append `--json` to any command |\n\n## Setup\n\nOne-time: `polli auth login` (device-flow; creates a key with `profile`, `usage`, and `keys`). To store an existing key, run\n`printf \'%s\' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify\nwith `polli auth status` (or `polli whoami`).\nOverride the stored key for a single command with `--key <key>`, or set `POLLINATIONS_API_KEY` in the environment.\nPrefix any command with `POLLINATIONS_ENV=staging` to use staging; it keeps its own login, so run `POLLINATIONS_ENV=staging polli auth login` once. An exported `POLLINATIONS_API_KEY` wins over both logins.\n\n## Recipes\n\n### Generate an image to a file\n```bash\npolli gen image "a fox reading a book, studio ghibli style" --output fox.png\n```\nDefaults: `tongyi-mai/z-image-turbo`, 1024x1024. Without `--output` the file is `image.<ext>`, with the extension inferred from the response\'s `Content-Type` (`tongyi-mai/z-image-turbo` and `black-forest-labs/flux.1-schnell` return JPEG, so `image.jpg`); an explicit `--output` is used as given. Pick a different model with `--model black-forest-labs/flux.1-schnell` (see `polli models --type image`). For edits / img2img, pass one or more `--image <url>` flags \u2014 **must be public http(s) URLs**, local paths are rejected client-side. **Only models that list `"image"` in `input_modalities` actually consume the flag** \u2014 `black-forest-labs/flux.1-schnell` and `tongyi-mai/z-image-turbo` are text-only and will silently ignore `--image`. Find i2i-capable models with `polli models --type image --json | jq -r \'.[] | select(.input_modalities | contains(["image"])) | .name\'` (common choices: `google/gemini-2.5-flash-image`, `black-forest-labs/flux.1-kontext-pro`, `prunaai/p-image-edit`). To use a local file, upload it first with `polli upload` (see next recipe). **Img2img models may treat `--width`/`--height` as a hint** and keep the source aspect \u2014 check the output with `file`/`ffprobe`; if the aspect matters, pre-crop the source or crop afterwards.\n\n### Upload a local file to get a public URL\n```bash\nURL=$(polli upload cat.png)\npolli gen image "make the cat purple" --image "$URL" --output purple.png\n```\n`polli upload <file>` streams one raw-file request to `media.pollinations.ai` (400 MiB max; 30-day lifecycle, refreshed by GETs once the object is at least 15 days old). Each upload receives a unique id. Human mode: URL on stdout and id/size/contentType on stderr. `--json`: full upload response on stdout. The returned URL is public (no auth to fetch) and works anywhere `--image` is accepted \u2014 `gen image`, `gen video`, etc.\n\n### Generate text\n```bash\npolli gen text "summarize the three laws of robotics"\n```\nSave to file: `--output summary.txt`. Use `--system "<msg>"` to set system prompt. For reasoning models, pass `--reasoning low|medium|high` to control reasoning effort. **Only send `--reasoning` to models where `reasoning: true`** in `polli models --type text --json` \u2014 the flag is not validated client-side, and non-reasoning models may silently accept it (openai), ignore it, or return a 400 (mistral).\n\n### Describe an image with a vision model\n```bash\nURL=$(polli upload selfie.jpg)\npolli gen text "turn this person into a cartoon pet in one playful sentence" --image "$URL"\n```\n`gen text --image <url...>` attaches one or more **public https URLs** as an OpenAI-style multimodal message \u2014 repeatable for multi-image prompts. Local paths aren\'t supported; run them through `polli upload` first (see the upload recipe above). **Only text models with `"image"` in `input_modalities` actually read the image** \u2014 filter with `polli models --type text --json | jq -r \'.[] | select(.input_modalities | index("image")) | .name\'`. Non-vision models silently ignore the attachment. Good defaults: `openai`, `gemini`, `claude`.\n\n### Pipe stdin as context into text generation\n```bash\ncat README.md | polli gen text "what does this project do?"\n```\nstdin becomes context; the positional argument is the question.\n\n### Interactive chat session\n```bash\npolli gen chat --model openai/gpt-5.4-nano --system "you are a terse assistant"\n```\nSlash commands inside the session: `/exit`, `/clear`, `/save <path>`.\n\n### Text-to-speech\n```bash\npolli gen audio "hello world" --voice nova --output hello.mp3\necho "long script" | polli gen audio --voice nova --output out.mp3\n```\nWithout `--voice`, the API uses the model\'s default voice. Voices differ per model: `polli models --type audio --voices` lists each model\'s voices, so pass the matching `--model` with `--voice`. Format defaults to mp3; `--format opus|aac|flac|wav` to change. Accepts stdin (same as `gen text`). Add `--play` to save and then play the audio back (handy for narration/demos). Playback starts after the file is fully written, and the command blocks until playback finishes \u2014 if you want fire-and-forget, wrap in a subshell: `( polli gen audio "..." --play & )`. Player on macOS: `afplay`; on Linux it tries `ffplay`, then `mpv`, then `mpg123` in that order.\n\n### Generate music (elevenlabs/music-v2)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenlabs/music-v2 --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (elevenlabs/eleven-text-to-sound-v2)\n```bash\npolli gen audio "thunderclap with heavy rain" --model elevenlabs/eleven-text-to-sound-v2 --duration 5 --output thunder.mp3\n```\nText-to-sound-effect via ElevenLabs (aliases: `sfx`, `sound-effects`). `--duration` 0.5\u201330s (omit to let the model pick). Billed per second of output (~$0.004/s, capped at $0.12 for a full 30s).\n\n### Multilingual TTS (elevenlabs/eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model elevenlabs/eleven-multilingual-v2 --voice rachel --output fr.mp3\n```\nStable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) \u2014 a non-alpha alternative to the default v3.\n\n### Estimate the cost before generating\n```bash\npolli gen image "a fox" --model flux --estimate\npolli gen video "a spacecraft landing on mars" --model veo --duration 8 --audio --estimate\n```\n`--estimate` reads the public model list (`/image/models`), prints the estimated Pollen for that request and exits without generating. Per-image, per-megapixel and per-second rates, plus fixed per-generation fees, give a number; token-billed models (e.g. `gpt-image-2`, `nanobanana`) print `estimate: unknown` with their rates, because the charge depends on usage the provider reports afterwards. `--json` adds `pollen` (null when unknown) and the per-rate `lines`.\n\n### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model alibaba/wan-2.2-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model alibaba/wan-2.2-fast` at ~$0.01/sec, **fixed 5-second output** (any `--duration` value is ignored \u2014 you always pay for and receive 5 sec). For image-to-video, pass `--image <url>` with a **public HTTPS URL** (local file paths and 404/rate-limited hosts will fail with a server error).\n\n**Flag support varies per model and is not enforced client-side.** `--duration`, `--aspect-ratio`, and `--audio` are forwarded to the server but may be silently ignored \u2014 verified on `wan-fast` where duration is locked to 5s, `--aspect-ratio 9:16` still returns 16:9, and `--audio` produces no audio track. Always inspect the output (`file`, `ffprobe`) before trusting a flag worked. Check `polli models --type video --json` for per-model capabilities.\n\n**Video is not tracked by `--stats`.** `polli models --type video --stats` returns empty \u2014 the stats pipe only records text/image/audio events. To compare video models, fall back to `polli models --type video --json` and look at price/description fields. The same applies to `--type 3d`.\n\n### Generate a 3D model\n```bash\npolli gen 3d "a red fox" --output fox.glb\npolli gen 3d --image https://media.pollinations.ai/abc --resolution high\n```\n`--model` defaults to `hyper3d/rodin-2.5` for a text-only prompt and `microsoft/trellis-2` once `--image <url>` is given (public http(s), upload local files first with `polli upload`) \u2014 `trellis-2` is **image-to-3D only** and rejects a bare prompt. `--resolution low|medium|high` only affects `trellis-2`. The output extension is inferred from the response\'s `Content-Type`, not the model name: `nvidia/asset-harvester` returns a Gaussian Splat `.ply`, everything else returns `.glb`. `hyper3d/rodin-2.5` and `nvidia/asset-harvester` require Paid Pollen.\n\n### Generate embeddings\n```bash\npolli gen embeddings "first text" "second text" --model google/gemini-embedding-2\nprintf \'first\\nsecond\\n\' | polli gen embeddings # one input per stdin line\n```\nPrints one JSON array per input, in input order, one per line (pipe/`jq`-friendly). `--dimensions <n>` (128-4096), `--task-type` (Gemini retrieval hint), and `--input-type query|document` (Cohere) are optional. `--json` prints the full response including `usage`.\n\n### Change or isolate a voice\n```bash\npolli gen voice-change talk.mp3 --voice nova --format wav\npolli gen isolate interview.mp4\n```\n`voice-change` re-speaks a **local** audio file in another voice (preset name or ElevenLabs voice ID) \u2014 default output `voice.<format>`. `isolate` strips music/background noise from local audio **or video**, keeping only speech \u2014 default output `isolated.mp3`. Both upload the file as multipart form data; ElevenLabs requires **at least 4.6 seconds** of audio for isolation, shorter clips fail with the API\'s `audio_too_short` error.\n\n### Speech with character-level timestamps\n```bash\npolli gen audio "Hello world" --timestamps\n```\nSaves the audio as usual (`speech.mp3` by default) and appends `.json` to its path for the `alignment`/`normalized_alignment` character timings. Only `elevenlabs/eleven-v3`, `elevenlabs/eleven-flash-v2.5`, and `elevenlabs/eleven-multilingual-v2` support this \u2014 other models fail with the API\'s error message.\n\n### Transcribe audio to text\n```bash\npolli gen transcribe recording.mp3 --language en\n```\nModels: `openai/whisper-large-v3` (default), `elevenlabs/scribe-v2`, `assemblyai/universal-2`, `assemblyai/universal-3.5-pro`. Accepts common audio formats (mp3, wav, m4a, flac, ogg); non-audio input (e.g. a `.txt` file) returns a clear `400 invalid_request_error: extension "txt" not supported` \u2014 no need to pre-validate with `file`. Default output is the plain transcript on stdout as a single line (pipe-friendly). Use `--json` for structured output: **whisper** and **AssemblyAI** return timing data when requested through the API; **scribe** returns only `{text: "..."}` \u2014 use whisper or AssemblyAI if you need timing data. `--language <ISO-639-1>` (e.g. `en`, `fr`) is an optional hint that can improve accuracy for non-English or accented speech.\n\n### Discover models\n```bash\npolli models --type text # text models only\npolli models flux # search name, aliases, title, description, publisher\npolli models --source community # official or community only\npolli models --reliability all # also community models failing health checks\npolli models --type audio --voices # voices per model\npolli models --type image --verbose # with publisher, context length, pricing\npolli models --stats # health + avg latency + err% (60m default)\npolli models --stats --window 5 # last 5 minutes only\n```\nUse `--stats` before choosing a model. **Caveat**: the `err%` column counts **5xx only** \u2014 a model can show `0.0%` while having massive 4xx rates (auth, validation, etc.). For the full picture use `--stats --json` and read `errors_4xx`, `errors_5xx`, `latency_p95_ms`.\n\n**Pricing fields are per-token, not per-request.** `completionImageTokens: 0.000008` means each output image-token costs that much \u2014 a single 1024x1024 image from `openai/gpt-image-1-mini` lands at ~$0.008, not $0.000008. Flat-priced image models (`black-forest-labs/flux.1-schnell`, `tongyi-mai/z-image-turbo`) expose `completionImageTokens` as the whole-image price because they emit exactly one "token" per image. When in doubt, make one call and read the true cost from `polli usage --history --limit 5 --json`.\n\n### Check usage and balance\n```bash\npolli usage # current pollen balance\npolli usage --history # recent individual requests\npolli usage --daily # daily cost summary\npolli usage --daily --key polli-harness-claude --days 1 # cost of one harness key for the last day (`--model`, `--csv` filter/export both views; `--key` is repeatable)\npolli earnings # developer earnings total + per-entity breakdown (default 30d)\npolli earnings --days 7 # rolling window\npolli quests # your quests + claim state (open/claimable/claimed/closed/coming)\npolli quests --claimable # only rewards ready to claim\n```\n**History is eventually consistent** \u2014 a request you just made may not appear for 30\u201360s. When matching costs to freshly-generated media, use `--limit 50` and filter by timestamp, and retry if the expected entry is missing. `polli usage --json` returns `{"pollen": <number>}` \u2014 the current balance only; use `--history --json` or `--daily --json` for cost breakdowns. Those print a JSON array of the API usage records (numeric `cost_usd`, `api_key_id`, available per-modality token fields), not the table columns.\n\n### Manage my-models\n```bash\npolli my-models list\npolli my-models models --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY"\npolli my-models create --name my-model --title "My Model" --api chat_completions --url https://api.example.com/v1/chat/completions --bearer-token "$UPSTREAM_KEY" --upstream-model gpt-4.1-mini --required-safety privacy,secrets,sexual,violence,shield\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model flux\npolli my-models update <id> --description "Updated description"\npolli my-models update <id> --paid-only # only accept Paid Pollen; --no-paid-only reverts\npolli my-models update <id> --required-safety privacy,secrets,sexual,violence,shield\npolli my-models delete <id>\n```\n`my-models` manages owned community text, image, and transcription models. Any account can create private models; `communityEndpointsAllowed: true` is required only to publish them. API keys require `account:keys`. Use `account:usage` for narrow read-only usage and `polli quests`; use both permissions when a client needs both read-only account state and admin operations. Quest claiming is dashboard-only; `polli quests` is read-only and account-aware.\n\n### Register an image my-model\n```bash\npolli my-models test --modality image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --model image-v1\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --input-modalities text,image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model image-v1\n```\nTest before creating. The probe reports the pricing mode it detected and the input modalities it found, including whether the endpoint accepts image edits; pass those back as `--input-modalities text,image` to advertise edit support. `polli my-models list` shows them in the `inputs` column.\n\nTwo billing modes: `--image-pricing request` charges `--completion-image-price` per generated image, while `--image-pricing tokens` bills returned token usage per 1M through `--prompt-text-price`, `--prompt-image-price`, and `--completion-image-price`.\n\nPrices only apply to `--visibility public` models. A private model is owner-only and always free, so every price flag above is stored as `0` until you publish \u2014 and making a published model private clears its prices again.\n\n`--modality` is fixed at creation \u2014 `update` cannot change it.\n\n### Manage agents\n\n```bash\npolli agents list\npolli agents get <id>\npolli agents create --config agent.json --name my-agent --title "My Agent"\npolli agents create --config code-agent.json\npolli agents update <id> --config agent.json\npolli agents sync <id>\npolli agents delete <id>\n```\nPrompt-agent config contains `systemPrompt`, `baseModel`, and optional `mcpServers` (add `composio` to act in the caller\'s own accounts, such as a GitHub commit; callers connect apps at https://enter.pollinations.ai/account#connectors); create also requires `--name` and `--title`. Code-agent config contains `type: "code_agent"` and a public GitHub `repository` with `agent.ts` at its root; its model ID, title, and description come from GitHub. Use server IDs from the MCP catalog. Updates are partial: send only the fields to change; the rest keep their values. `sync` deploys the latest GitHub revision of a code agent.\n\nCreating an agent also creates its callable model listing. Managed agents are text-only and free, with no fallbacks or per-user RPM. Deleting the agent also deletes its model listing. See [Publish an Agent](https://github.com/pollinations/pollinations/blob/main/BUILD_YOUR_OWN_AGENT.md).\n\n### Publish a static site\n```bash\nnpm run build\npolli sites deploy ./dist --name my-app --verify # \u2192 https://my-app.pollinations.app\npolli sites list\npolli sites delete my-app\n```\nPublishes a folder of static files with an `index.html`; unknown paths serve `index.html`, so single-page apps route on the client. Deploying the same name again replaces the site and uploads only changed files. Names are 3\u201332 lowercase letters, digits and hyphens, starting with a letter; the first deploy claims the name. Limits: 5 sites per account, 200 MB and 1,000 files per site, 25 MiB per file. Dotfiles and `node_modules` are not uploaded. Sites are public: never put an API key in them. To call Pollinations from a site, let visitors connect through Pollinations Connect and spend their own Pollen (see [Pollinations Pay](https://gen.pollinations.ai/docs/llm.txt?section=byop)). Share the URL the command prints rather than composing one from the name.\n\n`--verify` reads every published file without credentials and compares its bytes to the build, following redirects and retrying failures. The published URL (or site object with `--json`) is printed before verification. A failed check reports that the site is published, exits non-zero and does not roll back.\n\n### Manage API keys\n```bash\npolli keys list # list all keys on the account\npolli keys info # details about the CURRENTLY AUTHENTICATED key only (takes no id)\npolli keys create --name "my-bot" --type secret --budget 1000 --permissions profile usage # scoped key\npolli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings\npolli keys create --name "server" --models black-forest-labs/flux.1-schnell tongyi-mai/z-image-turbo # only these two models\npolli keys update <id> --models text black-forest-labs/flux.1-schnell # every text model plus FLUX.1 Schnell\npolli keys revoke <id> # id comes from `keys list --json`\n```\n`--models` takes categories (`text`, `image`, `video`, `audio`, `3d`, `embedding`, `realtime`, `decision`) and model IDs from `polli models`. A category includes models added later; a model ID allows only that model.\n`--permissions <perms...>` scopes what the new key can do on the account (e.g. `profile usage` lets it call `polli --key <new> usage`). **Without `--permissions`, new scoped keys can generate media but cannot read account state** \u2014 `polli --key <new> usage` will 403. Include `keys` to let the new key create, list, and revoke keys itself. Existing keys with `account:keys` can manage my-models where that invite-only feature is enabled, but still need `account:usage` for read-only account state. Publishable app keys default developer earnings off; pass `--earnings` to enable them. To inspect a specific key other than the current one, use `polli keys list --json | jq \'.[] | select(.id == "<id>")\'`. `keys info` is intentionally scoped to the caller\'s own key.\n\n### Connect a coding harness\nPolli defaults to `openai/gpt-6-sol`; `--model <id>` overrides it. Bloom is key-only and keeps its own model selection.\n\n```bash\npolli harness --help # supported harnesses\npolli harness bloom on # create a dedicated key for Bloom CLI\npolli harness dsh on # login if needed, mint key "polli-harness-dsh", write provider + default model\npolli harness dsh on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness dsh on --no-mcp # configure the provider and skill without MCP tools\npolli harness dsh off # restore the config backed up before "on"\npolli harness hermes on # login if needed, mint key "polli-harness-hermes", add provider + Polli skill\npolli harness hermes on --model deepseek/deepseek-v4-flash # use the model ID from `polli models`\npolli harness hermes off # restore the config backed up before "on"\npolli harness opencode on # add the Pollinations provider (OpenCode 1.x and 2.x)\npolli harness opencode off # remove the provider setup and stored key\npolli harness pi on # login if needed, mint key "polli-harness-pi", configure Pi with Pollinations\npolli harness pi on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness pi off # restore the Pi config backed up before "on"\npolli harness openclaw on # login if needed, mint key "polli-harness-openclaw", add provider + Polli skill\npolli harness openclaw off # remove the Pollinations provider, key, and skill\npolli harness tgpt on # use tgpt\'s Pollinations provider with a dedicated key\npolli harness tgpt off # restore tgpt\'s previous configuration\npolli harness vibe on # Mistral Vibe provider, live models, dedicated key, and Polli skill\npolli harness vibe on --model deepseek/deepseek-v4-flash\npolli harness vibe off # restore Vibe\'s previous user configuration\n```\nEach adapter checks that its harness can be launched before login, key creation, or configuration. DSH\'s official launch uses `npx`, so its adapter checks for `npx`; Bloom, Hermes Agent, OpenCode, OpenClaw, Pi, tgpt, and Mistral Vibe require their installed commands.\n\nMistral Vibe writes `$VIBE_HOME/config.toml`, `.env`, and `skills/polli/` (default `~/.vibe`), using the native OpenAI-compatible provider. Session titles and smart approval use the selected Pollinations model too. Restart Vibe afterward; project, agent, admin, and environment overrides still take precedence. Setup reformats TOML; `off` restores untouched files or strips only the Pollinations setup after edits. Install with `uv tool install mistral-vibe`.\n\nBloom already uses Pollinations and only needs a dedicated key in `$BLOOM_HOME/.env` (default `~/.bloom/.env`). tgpt\'s existing Pollinations provider is selected in `~/.config/tgpt/config.conf` with a dedicated key and model. The DSH adapter globally configures the Pollinations provider, hosted Pollinations MCP, and this skill under `$DSH_HOME` (default `~/.dsh`). OpenCode adds a `pollinations` provider (read by both 1.x and 2.x) and stores its dedicated key in the provider\'s options. OpenClaw adds a `pollinations` provider to `~/.openclaw/openclaw.json`, stores a dedicated key in `env.vars`, and installs this skill under `~/.openclaw/skills/polli/`. Pi writes `~/.pi/agent/models.json`, `auth.json`, and `settings.json`, and installs this skill under `~/.pi/agent/skills/polli/`. Guide: `polli docs` section "Coding Harnesses".\n\n### Read API docs\n```bash\npolli docs # full llm.txt reference\npolli docs /v1/chat/completions # filter to one endpoint\npolli docs --open # open in browser\n```\n\n## Output contract\n\n- **Default (human mode):** varies by command \u2014 most emit `key: value` pairs or tab-separated tables with a header row. Exceptions: `gen text` prints the full response to stdout; `gen transcribe` prints the transcript as plain text; `gen chat` runs an interactive REPL. Status/progress messages go to stderr, so pipes stay clean.\n- **`--json`:** every command emits machine-parseable JSON to stdout; all human messages go to stderr. **Always prefer `--json` when piping into `jq` or parsing** \u2014 it\'s the only shape with a stable contract.\n- **Exit codes:** 0 on success, non-zero on auth failure, rate limit, network error, or invalid args. Error messages go to stderr.\n\n## Agent operating rules\n\n1. **Run `polli auth status` (or `polli whoami`) first** if you don\'t know whether the user is logged in. Fail fast with a clear "run `polli auth login`" message if not.\n2. **Prefer `--json`** whenever you\'ll parse the output. Never grep human-formatted tables.\n3. **Don\'t hardcode model IDs.** Fetch the live list with `polli models --type <type>`. Model availability changes.\n4. **Before picking a model for production use, check `polli models --stats`.** Rule of thumb for "healthy": `err%` \u2264 5, `avg` latency in a reasonable range for the modality (standard text <5s, image <10s, video <60s), and `requests` high enough to be statistically meaningful (ignore rows with <10 requests \u2014 noise). **Filter by capability first, then optimize by health** \u2014 e.g. for a reasoning task, narrow to models where `reasoning: true` (via `polli models --type text --json`), *then* cross-reference against `--stats` output. The healthiest model overall may not support the capability you need. **Reasoning models are inherently slower \u2014 expect 5\u201350s, not <5s**; when picking among them, prioritize low `err%` and request count over raw latency, and compare latency only within the reasoning-capable subset.\n5. **Always pass `--output <path>`** for `gen image`, `gen audio`, `gen video` \u2014 otherwise the file lands in the current directory with a default name.\n6. **For stdin-as-context** on `gen text`, pipe the context and pass the question as the positional argument: `cat file | polli gen text "question about the file"`.\n7. **For exact flag lists, run `polli <cmd> --help` or `polli gen <cmd> --help`.** This skill\'s recipes cover the common path; the CLI\'s own help is always the source of truth.\n8. **Use `polli docs [endpoint]` over guessing API shapes.** It prints the canonical `llm.txt` reference from the live API.\n\n## Common pitfalls\n\n- Forgetting `--output` on binary generators (image/audio/video) \u2014 the file goes to a default path, which may not be what the user wants.\n- Using `polli gen text --json` expecting OpenAI chat-completions shape \u2014 the CLI\'s `--json` wraps its own structure. Use `polli docs /v1/chat/completions` to see the raw API shape if you need it.\n- Running commands without auth \u2014 `polli auth status` / `polli whoami` tells you who you\'re logged in as and your balance in one call.\n- **`gen text` streams to a TTY, buffers when piped.** The default now auto-detects \u2014 a human at the terminal sees tokens tick in, a pipe/redirect gets the full response once. Force either mode with `--stream` or `--no-stream`. For scripts and chains like `polli gen text \u2026 | polli gen audio \u2026`, you don\'t need to do anything; buffering happens automatically.\n- **Translating a `polli` workflow into a browser app.** `gen.pollinations.ai` requires a bearer token for generation requests, so a plain client-side `fetch` with no auth returns 401 unless it is served from cache. Mint a scoped key with `polli keys create` and proxy via your own backend.\n- **Backgrounded `polli gen` can fail silently** \u2014 no output file, empty log, no error (a safety rejection is an explicit 400). Run in the foreground; if backgrounded, check the `--output` file exists and retry once in the foreground before calling it failed.\n- **Content-safety 400s aren\'t only about violence.** Body-focused action phrasing can trip a sexual-content category on some edit models. Rephrase the benign intent neutrally (e.g. sport framing) and retry with a new seed.\n';
|
|
2893
3396
|
|
|
2894
3397
|
// src/harnesses/dsh.ts
|
|
2895
3398
|
init_config();
|
|
@@ -4345,20 +4848,20 @@ var withOnOptions = (command) => command.option("--model <id>", "Default model f
|
|
|
4345
4848
|
);
|
|
4346
4849
|
var harnessSubcommand = (harness) => {
|
|
4347
4850
|
const command = withOnOptions(
|
|
4348
|
-
new
|
|
4851
|
+
new Command17(harness.id).description(harness.description)
|
|
4349
4852
|
).action((options) => runOn(harness, options));
|
|
4350
4853
|
command.addCommand(
|
|
4351
|
-
new
|
|
4854
|
+
new Command17("on").description(`Connect ${harness.label} to Pollinations`).action(() => runOn(harness, command.opts()))
|
|
4352
4855
|
);
|
|
4353
4856
|
command.addCommand(
|
|
4354
|
-
new
|
|
4857
|
+
new Command17("off").description(`Restore ${harness.label}'s previous configuration`).action(() => runOff(harness))
|
|
4355
4858
|
);
|
|
4356
4859
|
command.addCommand(
|
|
4357
|
-
new
|
|
4860
|
+
new Command17("status").description(`Show ${harness.label}'s Pollinations status`).action(() => runStatus(harness))
|
|
4358
4861
|
);
|
|
4359
4862
|
return command;
|
|
4360
4863
|
};
|
|
4361
|
-
var harnessCommand = new
|
|
4864
|
+
var harnessCommand = new Command17("harness").description("Configure coding harnesses to use Pollinations").addHelpText(
|
|
4362
4865
|
"after",
|
|
4363
4866
|
"\nGuide: https://gen.pollinations.ai/docs#tag/coding-harnesses\n"
|
|
4364
4867
|
);
|
|
@@ -4370,7 +4873,7 @@ for (const harness of HARNESSES) {
|
|
|
4370
4873
|
init_api();
|
|
4371
4874
|
init_output();
|
|
4372
4875
|
import chalk6 from "chalk";
|
|
4373
|
-
import { Command as
|
|
4876
|
+
import { Command as Command18 } from "commander";
|
|
4374
4877
|
var MODELS_HELP = "Models the key can use: categories (text, image, video, audio, 3d, embedding, realtime, decision) or model IDs from `polli models`. A category includes models added later; a model ID allows only that model";
|
|
4375
4878
|
var formatPerms = (p) => {
|
|
4376
4879
|
if (!p) return "-";
|
|
@@ -4383,7 +4886,7 @@ var formatPerms = (p) => {
|
|
|
4383
4886
|
}
|
|
4384
4887
|
return parts.join(" ") || "-";
|
|
4385
4888
|
};
|
|
4386
|
-
var list2 = new
|
|
4889
|
+
var list2 = new Command18("list").description("List all API keys for your account").option(
|
|
4387
4890
|
"--verbose",
|
|
4388
4891
|
"Show id, created, last_used, enabled columns (use --json for full raw data)"
|
|
4389
4892
|
).action(async (opts) => {
|
|
@@ -4429,7 +4932,7 @@ var list2 = new Command17("list").description("List all API keys for your accoun
|
|
|
4429
4932
|
fail("Failed to list keys", err);
|
|
4430
4933
|
}
|
|
4431
4934
|
});
|
|
4432
|
-
var info = new
|
|
4935
|
+
var info = new Command18("info").description(
|
|
4433
4936
|
"Show details about the currently authenticated key (no args). To inspect another key by id, use `polli keys list --json`."
|
|
4434
4937
|
).action(async () => {
|
|
4435
4938
|
const key = requireKey();
|
|
@@ -4451,7 +4954,7 @@ var info = new Command17("info").description(
|
|
|
4451
4954
|
fail("Failed to fetch key info", err);
|
|
4452
4955
|
}
|
|
4453
4956
|
});
|
|
4454
|
-
var create2 = new
|
|
4957
|
+
var create2 = new Command18("create").description(
|
|
4455
4958
|
"Create a new API key. Use --type publishable to create an app key."
|
|
4456
4959
|
).requiredOption("--name <name>", "Key name").option(
|
|
4457
4960
|
"--type <type>",
|
|
@@ -4536,7 +5039,7 @@ Examples:
|
|
|
4536
5039
|
fail("Failed to create key", err);
|
|
4537
5040
|
}
|
|
4538
5041
|
});
|
|
4539
|
-
var update2 = new
|
|
5042
|
+
var update2 = new Command18("update").description("Change which models an API key can use").argument("<id>", "Key ID to update (see `polli keys list`)").requiredOption("--models <models...>", MODELS_HELP).addHelpText(
|
|
4540
5043
|
"after",
|
|
4541
5044
|
`
|
|
4542
5045
|
Examples:
|
|
@@ -4561,7 +5064,7 @@ Examples:
|
|
|
4561
5064
|
fail("Failed to update key", err);
|
|
4562
5065
|
}
|
|
4563
5066
|
});
|
|
4564
|
-
var revoke = new
|
|
5067
|
+
var revoke = new Command18("revoke").description("Revoke an API key by ID").argument("<id>", "Key ID to revoke").action(async (id) => {
|
|
4565
5068
|
const key = requireKey();
|
|
4566
5069
|
try {
|
|
4567
5070
|
await gen(`/account/keys/${id}`, {
|
|
@@ -4573,11 +5076,11 @@ var revoke = new Command17("revoke").description("Revoke an API key by ID").argu
|
|
|
4573
5076
|
fail("Failed to revoke key", err);
|
|
4574
5077
|
}
|
|
4575
5078
|
});
|
|
4576
|
-
var keysCommand = new
|
|
5079
|
+
var keysCommand = new Command18("keys").description("Manage API keys (create, list, update, revoke)").addCommand(list2).addCommand(info).addCommand(create2).addCommand(update2).addCommand(revoke);
|
|
4577
5080
|
|
|
4578
5081
|
// src/commands/mcp.ts
|
|
4579
5082
|
import { homedir as homedir3 } from "os";
|
|
4580
|
-
import { Command as
|
|
5083
|
+
import { Command as Command19 } from "commander";
|
|
4581
5084
|
init_output();
|
|
4582
5085
|
|
|
4583
5086
|
// src/mcp/catalog.ts
|
|
@@ -5403,7 +5906,7 @@ var runStatus2 = async (clientId) => {
|
|
|
5403
5906
|
fail("Failed to inspect MCP client status", error);
|
|
5404
5907
|
}
|
|
5405
5908
|
};
|
|
5406
|
-
var mcpCommand = new
|
|
5909
|
+
var mcpCommand = new Command19("mcp").description("Install Pollinations MCP servers into coding agents and IDEs").addHelpText(
|
|
5407
5910
|
"after",
|
|
5408
5911
|
`
|
|
5409
5912
|
Supported clients: ${MCP_CLIENTS.map((client) => client.id).join(", ")}
|
|
@@ -5411,10 +5914,10 @@ Guide: https://gen.pollinations.ai/docs#tag/mcp
|
|
|
5411
5914
|
`
|
|
5412
5915
|
);
|
|
5413
5916
|
mcpCommand.addCommand(
|
|
5414
|
-
new
|
|
5917
|
+
new Command19("list").description("List the live MCP server catalog").action(runList)
|
|
5415
5918
|
);
|
|
5416
5919
|
mcpCommand.addCommand(
|
|
5417
|
-
new
|
|
5920
|
+
new Command19("install").description(
|
|
5418
5921
|
"Install Pollinations MCP servers into a client (dedicated API key per client)"
|
|
5419
5922
|
).argument(
|
|
5420
5923
|
"<client>",
|
|
@@ -5427,7 +5930,7 @@ mcpCommand.addCommand(
|
|
|
5427
5930
|
)
|
|
5428
5931
|
);
|
|
5429
5932
|
mcpCommand.addCommand(
|
|
5430
|
-
new
|
|
5933
|
+
new Command19("remove").description(
|
|
5431
5934
|
"Remove Pollinations-owned MCP entries from a client (other entries are kept)"
|
|
5432
5935
|
).argument(
|
|
5433
5936
|
"<client>",
|
|
@@ -5440,7 +5943,7 @@ mcpCommand.addCommand(
|
|
|
5440
5943
|
)
|
|
5441
5944
|
);
|
|
5442
5945
|
mcpCommand.addCommand(
|
|
5443
|
-
new
|
|
5946
|
+
new Command19("status").description("Show which Pollinations MCP servers a client has").argument(
|
|
5444
5947
|
"[client]",
|
|
5445
5948
|
`one of: ${MCP_CLIENTS.map((c) => c.id).join(", ")}`
|
|
5446
5949
|
).action((client) => runStatus2(client))
|
|
@@ -5450,7 +5953,7 @@ mcpCommand.addCommand(
|
|
|
5450
5953
|
init_api();
|
|
5451
5954
|
init_output();
|
|
5452
5955
|
import chalk7 from "chalk";
|
|
5453
|
-
import { Command as
|
|
5956
|
+
import { Command as Command20, Option as Option2 } from "commander";
|
|
5454
5957
|
|
|
5455
5958
|
// src/commands/stats.ts
|
|
5456
5959
|
init_config();
|
|
@@ -5490,7 +5993,7 @@ function buildRow(m, verbose) {
|
|
|
5490
5993
|
}
|
|
5491
5994
|
return row;
|
|
5492
5995
|
}
|
|
5493
|
-
var modelsCommand = new
|
|
5996
|
+
var modelsCommand = new Command20("models").description(
|
|
5494
5997
|
"List available models and their voices, or show model health stats"
|
|
5495
5998
|
).argument(
|
|
5496
5999
|
"[query]",
|
|
@@ -5525,6 +6028,13 @@ var modelsCommand = new Command19("models").description(
|
|
|
5525
6028
|
`Stats window in minutes (1-${MAX_STATS_WINDOW_MINUTES})`,
|
|
5526
6029
|
"60"
|
|
5527
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
|
+
);
|
|
5528
6038
|
if (opts.stats) {
|
|
5529
6039
|
try {
|
|
5530
6040
|
const windowMinutes = Number(opts.window);
|
|
@@ -5534,22 +6044,10 @@ var modelsCommand = new Command19("models").description(
|
|
|
5534
6044
|
);
|
|
5535
6045
|
}
|
|
5536
6046
|
const rows = await fetchModelStats(windowMinutes);
|
|
5537
|
-
const
|
|
5538
|
-
const
|
|
5539
|
-
(
|
|
5540
|
-
)
|
|
5541
|
-
const valid = rows.filter((r) => {
|
|
5542
|
-
if (r.model === "undefined") return false;
|
|
5543
|
-
if (Number(r.total_requests ?? 0) <= 1) return false;
|
|
5544
|
-
if (wantType === "all") return true;
|
|
5545
|
-
if (decisionNames)
|
|
5546
|
-
return decisionNames.has(String(r.model));
|
|
5547
|
-
const t = String(r.event_type ?? "").replace(
|
|
5548
|
-
"generate.",
|
|
5549
|
-
""
|
|
5550
|
-
);
|
|
5551
|
-
return t === wantType;
|
|
5552
|
-
});
|
|
6047
|
+
const names = opts.type !== "all" || params.size || opts.voices ? new Set((await listModels()).map((m) => m.name)) : void 0;
|
|
6048
|
+
const valid = rows.filter(
|
|
6049
|
+
(r) => r.model !== "undefined" && Number(r.total_requests ?? 0) > 1 && (!names || names.has(String(r.model)))
|
|
6050
|
+
);
|
|
5553
6051
|
if (getOutputMode() === "json") {
|
|
5554
6052
|
printResult(valid);
|
|
5555
6053
|
} else {
|
|
@@ -5579,14 +6077,8 @@ var modelsCommand = new Command19("models").description(
|
|
|
5579
6077
|
}
|
|
5580
6078
|
return;
|
|
5581
6079
|
}
|
|
5582
|
-
const params = new URLSearchParams();
|
|
5583
|
-
if (query) params.set("query", query);
|
|
5584
|
-
if (opts.source) params.set("source", opts.source);
|
|
5585
|
-
if (opts.reliability) params.set("reliability", opts.reliability);
|
|
5586
6080
|
try {
|
|
5587
|
-
const models2 =
|
|
5588
|
-
(m) => (opts.type === "all" || m.category === opts.type) && (!opts.voices || m.voices?.length)
|
|
5589
|
-
);
|
|
6081
|
+
const models2 = await listModels();
|
|
5590
6082
|
if (getOutputMode() === "json") {
|
|
5591
6083
|
printResult(models2);
|
|
5592
6084
|
return;
|
|
@@ -5621,7 +6113,7 @@ var modelsCommand = new Command19("models").description(
|
|
|
5621
6113
|
init_api();
|
|
5622
6114
|
init_output();
|
|
5623
6115
|
import chalk8 from "chalk";
|
|
5624
|
-
import { Command as
|
|
6116
|
+
import { Command as Command21 } from "commander";
|
|
5625
6117
|
var PRICE_FLAGS = [
|
|
5626
6118
|
["--prompt-text-price <number>", "Prompt text token price"],
|
|
5627
6119
|
["--prompt-cached-price <number>", "Prompt cached token price"],
|
|
@@ -5808,7 +6300,7 @@ function printModels(models2) {
|
|
|
5808
6300
|
);
|
|
5809
6301
|
}
|
|
5810
6302
|
}
|
|
5811
|
-
var list3 = new
|
|
6303
|
+
var list3 = new Command21("list").description("List models owned by your account").action(async () => {
|
|
5812
6304
|
const key = requireKey();
|
|
5813
6305
|
try {
|
|
5814
6306
|
const res = await gen("/account/my-models", {
|
|
@@ -5820,7 +6312,7 @@ var list3 = new Command20("list").description("List models owned by your account
|
|
|
5820
6312
|
}
|
|
5821
6313
|
});
|
|
5822
6314
|
var create3 = addPriceOptions(
|
|
5823
|
-
new
|
|
6315
|
+
new Command21("create").description("Register a community model endpoint").requiredOption("--name <name>", "Model name").requiredOption("--title <title>", "Display title shown in the catalog").option("--description <text>", "Model description").option(
|
|
5824
6316
|
"--base-url <url>",
|
|
5825
6317
|
"Media API base URL, or exact video endpoint URL"
|
|
5826
6318
|
).option(
|
|
@@ -5873,7 +6365,7 @@ var create3 = addPriceOptions(
|
|
|
5873
6365
|
}
|
|
5874
6366
|
});
|
|
5875
6367
|
var update3 = addPriceOptions(
|
|
5876
|
-
new
|
|
6368
|
+
new Command21("update").description("Update one of your models").argument("<id>", "Model id").option("--name <name>", "Model name").option("--title <title>", "Display title shown in the catalog").option("--description <text>", "Model description").option(
|
|
5877
6369
|
"--base-url <url>",
|
|
5878
6370
|
"Media API base URL, or exact video endpoint URL"
|
|
5879
6371
|
).option(
|
|
@@ -5922,7 +6414,7 @@ var update3 = addPriceOptions(
|
|
|
5922
6414
|
fail("Failed to update model", err);
|
|
5923
6415
|
}
|
|
5924
6416
|
});
|
|
5925
|
-
var remove2 = new
|
|
6417
|
+
var remove2 = new Command21("delete").description("Delete one of your models").argument("<id>", "Model id").action(async (id) => {
|
|
5926
6418
|
const key = requireKey();
|
|
5927
6419
|
try {
|
|
5928
6420
|
await gen(
|
|
@@ -5938,7 +6430,7 @@ var remove2 = new Command20("delete").description("Delete one of your models").a
|
|
|
5938
6430
|
fail("Failed to delete model", err);
|
|
5939
6431
|
}
|
|
5940
6432
|
});
|
|
5941
|
-
var models = new
|
|
6433
|
+
var models = new Command21("models").description("List upstream models from an endpoint before registering it").requiredOption("--base-url <url>", "OpenAI-compatible base URL").requiredOption("--bearer-token <token>", "Upstream bearer token").action(async (opts) => {
|
|
5942
6434
|
const key = requireKey();
|
|
5943
6435
|
try {
|
|
5944
6436
|
const res = await gen(
|
|
@@ -5963,7 +6455,7 @@ var models = new Command20("models").description("List upstream models from an e
|
|
|
5963
6455
|
fail("Failed to fetch upstream models", err);
|
|
5964
6456
|
}
|
|
5965
6457
|
});
|
|
5966
|
-
var test = new
|
|
6458
|
+
var test = new Command21("test").description("Test an endpoint/model before registering it").option(
|
|
5967
6459
|
"--base-url <url>",
|
|
5968
6460
|
"Media API base URL, or exact video endpoint URL"
|
|
5969
6461
|
).option("--api <api>", "Text upstream API: chat_completions or responses").option("--url <url>", "Exact text endpoint URL for the selected API").requiredOption("--bearer-token <token>", "Upstream bearer token").option("--model <model>", "Upstream model id (not used for video)").option(
|
|
@@ -6000,7 +6492,7 @@ var test = new Command20("test").description("Test an endpoint/model before regi
|
|
|
6000
6492
|
fail("Failed to test model", err);
|
|
6001
6493
|
}
|
|
6002
6494
|
});
|
|
6003
|
-
var myModelsCommand = new
|
|
6495
|
+
var myModelsCommand = new Command21("my-models").description(
|
|
6004
6496
|
"Manage private and published community text, image, video, transcription, and embedding models"
|
|
6005
6497
|
).addCommand(list3).addCommand(create3).addCommand(update3).addCommand(remove2).addCommand(models).addCommand(test);
|
|
6006
6498
|
|
|
@@ -6009,7 +6501,7 @@ init_api();
|
|
|
6009
6501
|
init_config();
|
|
6010
6502
|
init_output();
|
|
6011
6503
|
import chalk9 from "chalk";
|
|
6012
|
-
import { Command as
|
|
6504
|
+
import { Command as Command22 } from "commander";
|
|
6013
6505
|
function questStatus(quest) {
|
|
6014
6506
|
if (quest.state === "coming_soon" || quest.status === "coming_soon") {
|
|
6015
6507
|
return "coming";
|
|
@@ -6070,7 +6562,7 @@ function renderQuests(quests) {
|
|
|
6070
6562
|
["status", "category", "reward", "title", "url"]
|
|
6071
6563
|
);
|
|
6072
6564
|
}
|
|
6073
|
-
var questsCommand = new
|
|
6565
|
+
var questsCommand = new Command22("quests").description(
|
|
6074
6566
|
"List your quests with claim state (open / claimable / claimed / closed / coming)"
|
|
6075
6567
|
).option("--open", "Show only open quests").option("--claimable", "Show only quests with a reward ready to claim").option("--claimed", "Show only already-claimed quests").option("--coming-soon", "Show only coming-soon quests").action(async (opts) => {
|
|
6076
6568
|
try {
|
|
@@ -6101,7 +6593,7 @@ var questsCommand = new Command21("quests").description(
|
|
|
6101
6593
|
// src/commands/sandbox/index.ts
|
|
6102
6594
|
init_api();
|
|
6103
6595
|
init_output();
|
|
6104
|
-
import { Command as
|
|
6596
|
+
import { Command as Command23, InvalidArgumentError } from "commander";
|
|
6105
6597
|
|
|
6106
6598
|
// src/commands/sandbox/e2b.ts
|
|
6107
6599
|
init_api();
|
|
@@ -6403,8 +6895,8 @@ var logLine = (entry) => [
|
|
|
6403
6895
|
([key, value]) => `${key}=${/\s/.test(value) ? JSON.stringify(value) : value}`
|
|
6404
6896
|
)
|
|
6405
6897
|
].join(" ");
|
|
6406
|
-
var sandboxCommand = new
|
|
6407
|
-
new
|
|
6898
|
+
var sandboxCommand = new Command23("sandbox").description("E2B sandboxes billed to your Pollinations account (alpha)").addCommand(
|
|
6899
|
+
new Command23("create").description("Start a sandbox you can ssh into").argument(
|
|
6408
6900
|
"[template]",
|
|
6409
6901
|
"pollinations-large has 4 vCPU and 8 GB; pollinations-azure, pollinations-azure-large and pollinations-azure-xl (8 vCPU, 16 GB) run on Azure",
|
|
6410
6902
|
"pollinations"
|
|
@@ -6442,7 +6934,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6442
6934
|
}
|
|
6443
6935
|
)
|
|
6444
6936
|
).addCommand(
|
|
6445
|
-
new
|
|
6937
|
+
new Command23("list").description("List your sandboxes").action(async () => {
|
|
6446
6938
|
requireKey();
|
|
6447
6939
|
try {
|
|
6448
6940
|
const sandboxes = await listSandboxes();
|
|
@@ -6465,7 +6957,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6465
6957
|
}
|
|
6466
6958
|
})
|
|
6467
6959
|
).addCommand(
|
|
6468
|
-
new
|
|
6960
|
+
new Command23("timeout").description(
|
|
6469
6961
|
"Keep a sandbox running at least <seconds> from now, paid 10 minutes at a time; 0 never expires; resumes a paused one"
|
|
6470
6962
|
).argument("<id>").argument("<seconds>", "seconds from now, or 0", parseTimeout).action(async (id, seconds) => {
|
|
6471
6963
|
requireKey();
|
|
@@ -6480,7 +6972,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6480
6972
|
}
|
|
6481
6973
|
})
|
|
6482
6974
|
).addCommand(
|
|
6483
|
-
new
|
|
6975
|
+
new Command23("pause").description(
|
|
6484
6976
|
"Pause a sandbox, keeping its files and memory, until ssh or timeout resumes it"
|
|
6485
6977
|
).argument("<id>").action(async (id) => {
|
|
6486
6978
|
requireKey();
|
|
@@ -6494,7 +6986,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6494
6986
|
}
|
|
6495
6987
|
})
|
|
6496
6988
|
).addCommand(
|
|
6497
|
-
new
|
|
6989
|
+
new Command23("logs").description("Show a sandbox's system log: start and processes").argument("<id>").action(async (id) => {
|
|
6498
6990
|
requireKey();
|
|
6499
6991
|
try {
|
|
6500
6992
|
const { logEntries } = await sandboxLogs(id);
|
|
@@ -6514,7 +7006,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6514
7006
|
}
|
|
6515
7007
|
})
|
|
6516
7008
|
).addCommand(
|
|
6517
|
-
new
|
|
7009
|
+
new Command23("kill").description("Delete sandboxes and their files").argument("<ids...>").action(async (ids) => {
|
|
6518
7010
|
requireKey();
|
|
6519
7011
|
try {
|
|
6520
7012
|
for (const id of ids) {
|
|
@@ -6526,7 +7018,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6526
7018
|
}
|
|
6527
7019
|
})
|
|
6528
7020
|
).addCommand(
|
|
6529
|
-
new
|
|
7021
|
+
new Command23("ssh-config").description(
|
|
6530
7022
|
"Set up ssh to <sandbox-id>.polli (create does this for you)"
|
|
6531
7023
|
).action(() => {
|
|
6532
7024
|
try {
|
|
@@ -6539,7 +7031,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6539
7031
|
}
|
|
6540
7032
|
})
|
|
6541
7033
|
).addCommand(
|
|
6542
|
-
new
|
|
7034
|
+
new Command23("proxy").description("ssh ProxyCommand for <sandbox-id>.polli").argument("<host>").action(async (host) => {
|
|
6543
7035
|
stderrToTerminal();
|
|
6544
7036
|
requireKey();
|
|
6545
7037
|
try {
|
|
@@ -6561,7 +7053,7 @@ import { readdirSync as readdirSync2, readFileSync as readFileSync8 } from "fs";
|
|
|
6561
7053
|
import { extname as extname2, join as join17, relative, resolve as resolve3, sep } from "path";
|
|
6562
7054
|
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
6563
7055
|
import chalk10 from "chalk";
|
|
6564
|
-
import { Command as
|
|
7056
|
+
import { Command as Command24 } from "commander";
|
|
6565
7057
|
init_output();
|
|
6566
7058
|
function collectSiteFiles(dir) {
|
|
6567
7059
|
const files10 = [];
|
|
@@ -6614,7 +7106,7 @@ async function verifySiteFiles(files10, siteUrl, retryDelayMs = 5e3) {
|
|
|
6614
7106
|
} catch (error) {
|
|
6615
7107
|
if (attempt === 5) {
|
|
6616
7108
|
throw new Error(
|
|
6617
|
-
`Verification failed for ${file.path}: ${
|
|
7109
|
+
`Verification failed for ${file.path}: ${errorMessage2(error)}`
|
|
6618
7110
|
);
|
|
6619
7111
|
}
|
|
6620
7112
|
await setTimeout2(retryDelayMs);
|
|
@@ -6655,8 +7147,8 @@ async function uploadBuckets(session, files10) {
|
|
|
6655
7147
|
}
|
|
6656
7148
|
return jwt;
|
|
6657
7149
|
}
|
|
6658
|
-
var
|
|
6659
|
-
var deploy = new
|
|
7150
|
+
var errorMessage2 = (error) => error instanceof Error ? error.message : "unknown";
|
|
7151
|
+
var deploy = new Command24("deploy").description(
|
|
6660
7152
|
"Publish a folder of static files (with an index.html) at https://<name>.pollinations.app"
|
|
6661
7153
|
).argument("[dir]", "Folder to publish, e.g. your build output", ".").requiredOption(
|
|
6662
7154
|
"--name <name>",
|
|
@@ -6696,12 +7188,12 @@ var deploy = new Command23("deploy").description(
|
|
|
6696
7188
|
if (opts.verify) await verifySiteFiles(files10, site.url);
|
|
6697
7189
|
} catch (error) {
|
|
6698
7190
|
printError(
|
|
6699
|
-
site ? `Site published at ${site.url}, but verification failed: ${
|
|
7191
|
+
site ? `Site published at ${site.url}, but verification failed: ${errorMessage2(error)}` : `Failed to deploy site: ${errorMessage2(error)}`
|
|
6700
7192
|
);
|
|
6701
7193
|
throw new ExitSignal(1);
|
|
6702
7194
|
}
|
|
6703
7195
|
});
|
|
6704
|
-
var list4 = new
|
|
7196
|
+
var list4 = new Command24("list").description("List your sites").action(async () => {
|
|
6705
7197
|
const key = requireKey();
|
|
6706
7198
|
try {
|
|
6707
7199
|
const { data } = await gen("/account/sites", {
|
|
@@ -6720,11 +7212,11 @@ var list4 = new Command23("list").description("List your sites").action(async ()
|
|
|
6720
7212
|
["name", "url", "published"]
|
|
6721
7213
|
);
|
|
6722
7214
|
} catch (error) {
|
|
6723
|
-
printError(`Failed to list sites: ${
|
|
7215
|
+
printError(`Failed to list sites: ${errorMessage2(error)}`);
|
|
6724
7216
|
throw new ExitSignal(1);
|
|
6725
7217
|
}
|
|
6726
7218
|
});
|
|
6727
|
-
var remove3 = new
|
|
7219
|
+
var remove3 = new Command24("delete").description("Take a site offline and free its name").argument("<name>", "Site name").action(async (name) => {
|
|
6728
7220
|
const key = requireKey();
|
|
6729
7221
|
try {
|
|
6730
7222
|
await gen(`/account/sites/${encodeURIComponent(name)}`, {
|
|
@@ -6733,11 +7225,11 @@ var remove3 = new Command23("delete").description("Take a site offline and free
|
|
|
6733
7225
|
});
|
|
6734
7226
|
printSuccess(`Site deleted: ${name}`);
|
|
6735
7227
|
} catch (error) {
|
|
6736
|
-
printError(`Failed to delete site: ${
|
|
7228
|
+
printError(`Failed to delete site: ${errorMessage2(error)}`);
|
|
6737
7229
|
throw new ExitSignal(1);
|
|
6738
7230
|
}
|
|
6739
7231
|
});
|
|
6740
|
-
var sitesCommand = new
|
|
7232
|
+
var sitesCommand = new Command24("sites").description("Host static sites at <name>.pollinations.app").addCommand(deploy).addCommand(list4).addCommand(remove3);
|
|
6741
7233
|
|
|
6742
7234
|
// src/commands/update.ts
|
|
6743
7235
|
init_output();
|
|
@@ -6745,7 +7237,7 @@ import { execSync, spawnSync as spawnSync3 } from "child_process";
|
|
|
6745
7237
|
import { existsSync as existsSync4, readFileSync as readFileSync9 } from "fs";
|
|
6746
7238
|
import { dirname as dirname4, join as join18, resolve as resolve4, sep as sep2 } from "path";
|
|
6747
7239
|
import { fileURLToPath } from "url";
|
|
6748
|
-
import { Command as
|
|
7240
|
+
import { Command as Command25 } from "commander";
|
|
6749
7241
|
var PACKAGE_NAME = "@pollinations/cli";
|
|
6750
7242
|
var REGISTRY_URL = "https://registry.npmjs.org/@pollinations%2Fcli/latest";
|
|
6751
7243
|
function findPackageRoot(fromDir) {
|
|
@@ -6791,7 +7283,7 @@ var NON_GLOBAL_ADVICE = {
|
|
|
6791
7283
|
npx: `Run the latest version with: npx ${PACKAGE_NAME}@latest <command>`,
|
|
6792
7284
|
local: `Not a global npm install. Update the dependency where it's declared, or install globally with: npm install -g ${PACKAGE_NAME}`
|
|
6793
7285
|
};
|
|
6794
|
-
var updateCommand = new
|
|
7286
|
+
var updateCommand = new Command25("update").description(
|
|
6795
7287
|
`Update the globally installed ${PACKAGE_NAME} to the latest version`
|
|
6796
7288
|
).action(async () => {
|
|
6797
7289
|
try {
|
|
@@ -6860,7 +7352,7 @@ init_config();
|
|
|
6860
7352
|
import { createReadStream, statSync as statSync5 } from "fs";
|
|
6861
7353
|
import { readFile } from "fs/promises";
|
|
6862
7354
|
import { basename as basename6 } from "path";
|
|
6863
|
-
import { Command as
|
|
7355
|
+
import { Command as Command26 } from "commander";
|
|
6864
7356
|
init_output();
|
|
6865
7357
|
var encodeExtValue = (value) => encodeURIComponent(value).replace(
|
|
6866
7358
|
/['()*]/g,
|
|
@@ -6871,7 +7363,7 @@ var fileNameHeaders = (name) => ({
|
|
|
6871
7363
|
"Content-Disposition": `attachment; filename*=UTF-8''${encodeExtValue(name)}`,
|
|
6872
7364
|
...HEADER_SAFE.test(name) && { "X-File-Name": name }
|
|
6873
7365
|
});
|
|
6874
|
-
var uploadCommand = new
|
|
7366
|
+
var uploadCommand = new Command26("upload").description(
|
|
6875
7367
|
"Upload a local file to media.pollinations.ai and print its public URL"
|
|
6876
7368
|
).argument("<file>", "Path to the local file to upload").action(async (file) => {
|
|
6877
7369
|
const key = requireKey();
|
|
@@ -6916,7 +7408,7 @@ var uploadCommand = new Command25("upload").description(
|
|
|
6916
7408
|
init_api();
|
|
6917
7409
|
init_config();
|
|
6918
7410
|
import chalk11 from "chalk";
|
|
6919
|
-
import { Command as
|
|
7411
|
+
import { Command as Command27 } from "commander";
|
|
6920
7412
|
init_output();
|
|
6921
7413
|
var KEY_ID_RE = /^[a-zA-Z0-9]{32}$/;
|
|
6922
7414
|
var isKeyId = (value) => KEY_ID_RE.test(value);
|
|
@@ -6981,7 +7473,7 @@ function splitKeyArgs(argv, command = "usage") {
|
|
|
6981
7473
|
}
|
|
6982
7474
|
return { authKey, filterKeys };
|
|
6983
7475
|
}
|
|
6984
|
-
var usageCommand = new
|
|
7476
|
+
var usageCommand = new Command27("usage").description(
|
|
6985
7477
|
"Show pollen balance (default), usage history, or daily summary"
|
|
6986
7478
|
).option("--limit <n>", "Number of records", "20").option("--history", "Show individual request history").option("--daily", "Show daily summary instead of individual requests").option(
|
|
6987
7479
|
"--model <id>",
|
|
@@ -7156,7 +7648,7 @@ async function notifyUpdate(pkg2) {
|
|
|
7156
7648
|
var pkg = JSON.parse(
|
|
7157
7649
|
readFileSync10(new URL("../package.json", import.meta.url), "utf-8")
|
|
7158
7650
|
);
|
|
7159
|
-
var program = new
|
|
7651
|
+
var program = new Command28();
|
|
7160
7652
|
program.name("polli").description(
|
|
7161
7653
|
"The Pollinations CLI \u2014 for humans, AI agents, and everything in between"
|
|
7162
7654
|
).version(`${pkg.version} \u2014 ${flavor.version}`).option("--json", "Output as JSON").option("--key <key>", "Override stored API key for this command").addHelpText(
|
|
@@ -7188,6 +7680,7 @@ program.addCommand(questsCommand);
|
|
|
7188
7680
|
program.addCommand(agentsCommand);
|
|
7189
7681
|
program.addCommand(myModelsCommand);
|
|
7190
7682
|
program.addCommand(harnessCommand);
|
|
7683
|
+
program.addCommand(acpCommand);
|
|
7191
7684
|
program.addCommand(sandboxCommand);
|
|
7192
7685
|
program.addCommand(sitesCommand);
|
|
7193
7686
|
program.addCommand(createGenCommand());
|