@pollinations/cli 0.1.23 → 0.1.24
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 +1 -1
- package/SKILL.md +2 -2
- package/dist/index.js +222 -499
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var init_package = __esm({
|
|
|
14
14
|
"package.json"() {
|
|
15
15
|
package_default = {
|
|
16
16
|
name: "@pollinations/cli",
|
|
17
|
-
version: "0.1.
|
|
17
|
+
version: "0.1.24",
|
|
18
18
|
description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
|
|
19
19
|
type: "module",
|
|
20
20
|
bin: {
|
|
@@ -292,9 +292,9 @@ var init_api = __esm({
|
|
|
292
292
|
init_config();
|
|
293
293
|
init_output();
|
|
294
294
|
ApiError = class extends Error {
|
|
295
|
-
constructor(
|
|
295
|
+
constructor(status4, message) {
|
|
296
296
|
super(message);
|
|
297
|
-
this.status =
|
|
297
|
+
this.status = status4;
|
|
298
298
|
this.name = "ApiError";
|
|
299
299
|
}
|
|
300
300
|
status;
|
|
@@ -734,13 +734,13 @@ var remove = new Command("delete").description("Delete an agent and its model re
|
|
|
734
734
|
});
|
|
735
735
|
var sync = new Command("sync").description("Deploy the latest revision of a code agent").argument("<id>", "Agent id").action(async (id) => {
|
|
736
736
|
try {
|
|
737
|
-
const
|
|
737
|
+
const result9 = await gen(`/account/agents/${encodeURIComponent(id)}/sync`, {
|
|
738
738
|
method: "POST"
|
|
739
739
|
});
|
|
740
|
-
if (getOutputMode() === "json") printResult(
|
|
740
|
+
if (getOutputMode() === "json") printResult(result9);
|
|
741
741
|
else {
|
|
742
742
|
printSuccess(
|
|
743
|
-
|
|
743
|
+
result9.updated ? `Agent deployed at ${result9.deployedCommitSha}` : `Agent already uses ${result9.deployedCommitSha}`
|
|
744
744
|
);
|
|
745
745
|
}
|
|
746
746
|
} catch (error) {
|
|
@@ -822,31 +822,12 @@ var docsCommand = new Command3("docs").description("Show Pollinations API docume
|
|
|
822
822
|
init_api();
|
|
823
823
|
init_output();
|
|
824
824
|
import { Command as Command4 } from "commander";
|
|
825
|
-
var MAX_EARNINGS_DAYS = 90;
|
|
826
|
-
function parseDaysWindow(value) {
|
|
827
|
-
const days = Number(value);
|
|
828
|
-
if (!Number.isInteger(days) || days < 1) {
|
|
829
|
-
throw new Error("--days must be a positive integer");
|
|
830
|
-
}
|
|
831
|
-
if (days > MAX_EARNINGS_DAYS) {
|
|
832
|
-
throw new Error(`--days must be ${MAX_EARNINGS_DAYS} or less`);
|
|
833
|
-
}
|
|
834
|
-
return days;
|
|
835
|
-
}
|
|
836
825
|
function totalPollenEarned(perEntity) {
|
|
837
826
|
return perEntity.reduce((sum, row) => sum + row.pollen_earned, 0);
|
|
838
827
|
}
|
|
839
|
-
var earningsCommand = new Command4("earnings").description("Show developer earnings from BYOP apps and community models").option("--days <n>", "Rolling window in days
|
|
828
|
+
var earningsCommand = new Command4("earnings").description("Show developer earnings from BYOP apps and community models").option("--days <n>", "Rolling window in days", "30").action(async (opts) => {
|
|
840
829
|
const key = requireKey();
|
|
841
|
-
|
|
842
|
-
try {
|
|
843
|
-
days = parseDaysWindow(opts.days);
|
|
844
|
-
} catch (err) {
|
|
845
|
-
printError(
|
|
846
|
-
err instanceof Error ? err.message : "Invalid --days value"
|
|
847
|
-
);
|
|
848
|
-
throw new ExitSignal(1);
|
|
849
|
-
}
|
|
830
|
+
const days = opts.days;
|
|
850
831
|
try {
|
|
851
832
|
const data = await gen(
|
|
852
833
|
`/account/earnings?days=${days}`,
|
|
@@ -892,8 +873,8 @@ init_client();
|
|
|
892
873
|
init_config();
|
|
893
874
|
init_output();
|
|
894
875
|
import { createInterface } from "readline/promises";
|
|
895
|
-
async function budgetHint(
|
|
896
|
-
if (
|
|
876
|
+
async function budgetHint(status4, bodyText) {
|
|
877
|
+
if (status4 !== 402) return null;
|
|
897
878
|
let code;
|
|
898
879
|
try {
|
|
899
880
|
code = JSON.parse(bodyText)?.error?.code;
|
|
@@ -1159,8 +1140,8 @@ async function* streamSSE(response, onEvent) {
|
|
|
1159
1140
|
const lines = buffer.split("\n");
|
|
1160
1141
|
buffer = lines.pop() ?? "";
|
|
1161
1142
|
for (const line of lines) {
|
|
1162
|
-
if (!line.startsWith("data:
|
|
1163
|
-
const data = line.slice(
|
|
1143
|
+
if (!line.startsWith("data:")) continue;
|
|
1144
|
+
const data = line.slice(5).trim();
|
|
1164
1145
|
if (data === "[DONE]") return;
|
|
1165
1146
|
let parsed;
|
|
1166
1147
|
try {
|
|
@@ -1451,10 +1432,12 @@ var MIME_BY_EXT = {
|
|
|
1451
1432
|
".mp3": "audio/mpeg",
|
|
1452
1433
|
".wav": "audio/wav",
|
|
1453
1434
|
".ogg": "audio/ogg",
|
|
1435
|
+
".opus": "audio/ogg",
|
|
1454
1436
|
".m4a": "audio/mp4",
|
|
1455
1437
|
".flac": "audio/flac",
|
|
1456
1438
|
".aac": "audio/aac",
|
|
1457
1439
|
".mp4": "video/mp4",
|
|
1440
|
+
".mkv": "video/x-matroska",
|
|
1458
1441
|
".webm": "video/webm",
|
|
1459
1442
|
".mov": "video/quicktime"
|
|
1460
1443
|
};
|
|
@@ -2083,72 +2066,9 @@ var bloom = {
|
|
|
2083
2066
|
|
|
2084
2067
|
// src/harnesses/claude-code.ts
|
|
2085
2068
|
init_config();
|
|
2086
|
-
|
|
2087
|
-
|
|
2069
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
2070
|
+
import { tmpdir } from "os";
|
|
2088
2071
|
import { join as join5 } from "path";
|
|
2089
|
-
var CCR_INSTALL = "npm install -g @musistudio/claude-code-router@latest";
|
|
2090
|
-
var ccrDir = (ctx) => ctx.env.CCR_CONFIG_DIR?.trim() || (process.platform === "win32" ? join5(
|
|
2091
|
-
ctx.env.APPDATA ?? join5(ctx.home, "AppData", "Roaming"),
|
|
2092
|
-
"claude-code-router"
|
|
2093
|
-
) : join5(ctx.home, ".claude-code-router"));
|
|
2094
|
-
var serviceFile = (ctx) => join5(ccrDir(ctx), "service.json");
|
|
2095
|
-
var processAlive = (pid) => {
|
|
2096
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
2097
|
-
try {
|
|
2098
|
-
process.kill(pid, 0);
|
|
2099
|
-
return true;
|
|
2100
|
-
} catch {
|
|
2101
|
-
return false;
|
|
2102
|
-
}
|
|
2103
|
-
};
|
|
2104
|
-
var readCcrService = (ctx) => {
|
|
2105
|
-
const text = readTextIfExists(serviceFile(ctx));
|
|
2106
|
-
if (!text) return null;
|
|
2107
|
-
try {
|
|
2108
|
-
const state = JSON.parse(text);
|
|
2109
|
-
if (!state.pid || !state.url || !processAlive(state.pid)) return null;
|
|
2110
|
-
const url = new URL(state.url);
|
|
2111
|
-
const token = url.searchParams.get("ccr_web_token") ?? "";
|
|
2112
|
-
if (!token) return null;
|
|
2113
|
-
return { origin: url.origin, token };
|
|
2114
|
-
} catch {
|
|
2115
|
-
return null;
|
|
2116
|
-
}
|
|
2117
|
-
};
|
|
2118
|
-
var ccrInstalled = (ctx) => commandExists("ccr", ctx.env);
|
|
2119
|
-
var ccrServiceRunning = (ctx) => readCcrService(ctx) !== null;
|
|
2120
|
-
var requireCcrService = (ctx) => {
|
|
2121
|
-
const service = readCcrService(ctx);
|
|
2122
|
-
if (!service) {
|
|
2123
|
-
throw new Error(
|
|
2124
|
-
"Claude Code Router is not running. Start it first with: ccr start"
|
|
2125
|
-
);
|
|
2126
|
-
}
|
|
2127
|
-
return service;
|
|
2128
|
-
};
|
|
2129
|
-
var ccrRpc = async (service, method, ...args) => {
|
|
2130
|
-
const response = await fetch(`${service.origin}/api/ccr/rpc`, {
|
|
2131
|
-
method: "POST",
|
|
2132
|
-
headers: {
|
|
2133
|
-
"content-type": "application/json",
|
|
2134
|
-
"x-ccr-web-auth": service.token
|
|
2135
|
-
},
|
|
2136
|
-
body: JSON.stringify({ method, args })
|
|
2137
|
-
});
|
|
2138
|
-
const text = await response.text();
|
|
2139
|
-
if (!response.ok) {
|
|
2140
|
-
throw new Error(
|
|
2141
|
-
`Claude Code Router RPC ${method} failed (${response.status}): ${text.slice(0, 400)}`
|
|
2142
|
-
);
|
|
2143
|
-
}
|
|
2144
|
-
const body = JSON.parse(text);
|
|
2145
|
-
if (body.ok !== true) {
|
|
2146
|
-
throw new Error(
|
|
2147
|
-
`Claude Code Router RPC ${method} failed: ${body.error?.message ?? "unknown error"}`
|
|
2148
|
-
);
|
|
2149
|
-
}
|
|
2150
|
-
return body.value;
|
|
2151
|
-
};
|
|
2152
2072
|
|
|
2153
2073
|
// src/harnesses/models.ts
|
|
2154
2074
|
init_api();
|
|
@@ -2175,18 +2095,18 @@ var fetchHarnessModels = async (selectedModel) => {
|
|
|
2175
2095
|
init_api();
|
|
2176
2096
|
init_config();
|
|
2177
2097
|
var keyUsageCount = async (apiKey) => {
|
|
2178
|
-
const
|
|
2098
|
+
const result9 = await gen(
|
|
2179
2099
|
"/account/key/usage?limit=1",
|
|
2180
2100
|
{ apiKey }
|
|
2181
2101
|
);
|
|
2182
|
-
return Number(
|
|
2102
|
+
return Number(result9.count ?? result9.usage?.length ?? 0);
|
|
2183
2103
|
};
|
|
2184
2104
|
var accountLastRequest = async (apiKey) => {
|
|
2185
2105
|
const accountKey = resolveApiKey();
|
|
2186
2106
|
if (!accountKey || accountKey === apiKey) return null;
|
|
2187
2107
|
try {
|
|
2188
|
-
const
|
|
2189
|
-
const row =
|
|
2108
|
+
const result9 = await gen("/account/keys", { apiKey: accountKey });
|
|
2109
|
+
const row = result9.data?.find(
|
|
2190
2110
|
(item) => item.enabled !== false && Boolean(item.start) && apiKey.startsWith(item.start)
|
|
2191
2111
|
);
|
|
2192
2112
|
return row?.lastRequest ? Date.parse(row.lastRequest) : null;
|
|
@@ -2210,304 +2130,128 @@ var waitForKeyUsageIncrease = async (apiKey, before, options = {}) => {
|
|
|
2210
2130
|
}
|
|
2211
2131
|
}
|
|
2212
2132
|
throw new Error(
|
|
2213
|
-
"
|
|
2133
|
+
"The smoke test returned, but no request appeared for the dedicated Pollinations key."
|
|
2214
2134
|
);
|
|
2215
2135
|
};
|
|
2216
2136
|
|
|
2217
2137
|
// src/harnesses/claude-code.ts
|
|
2218
2138
|
var ID2 = "claude-code";
|
|
2219
2139
|
var LABEL2 = "Claude Code";
|
|
2220
|
-
var PROVIDER_ID = "pollinations-polli-harness";
|
|
2221
|
-
var PROVIDER_NAME = "Pollinations";
|
|
2222
|
-
var PROFILE_ID = "pollinations-claude-code";
|
|
2223
2140
|
var DEFAULT_MODEL = "openai/gpt-6-sol";
|
|
2224
|
-
var
|
|
2225
|
-
var
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2141
|
+
var INSTALL = "Install Claude Code: https://claude.com/claude-code";
|
|
2142
|
+
var MODEL_VARS = [
|
|
2143
|
+
"ANTHROPIC_MODEL",
|
|
2144
|
+
"ANTHROPIC_DEFAULT_FABLE_MODEL",
|
|
2145
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
2146
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
2147
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL"
|
|
2148
|
+
];
|
|
2149
|
+
var settingsPath = (ctx) => join5(ctx.home, ".pollinations", "claude-code.json");
|
|
2150
|
+
var readEnv = (ctx) => {
|
|
2151
|
+
try {
|
|
2152
|
+
return JSON.parse(readTextIfExists(settingsPath(ctx)) ?? "{}").env ?? {};
|
|
2153
|
+
} catch {
|
|
2154
|
+
return {};
|
|
2231
2155
|
}
|
|
2232
|
-
return true;
|
|
2233
2156
|
};
|
|
2234
|
-
var
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
);
|
|
2238
|
-
var ownsProvider = (value) => Boolean(
|
|
2239
|
-
value && value.id === PROVIDER_ID && value.name === PROVIDER_NAME && value.type === "openai_chat_completions" && value.api_base_url?.replace(/\/$/, "") === `${BASE_URL}/v1`
|
|
2240
|
-
);
|
|
2241
|
-
var profileFor = (config) => config.profile.profiles.find((item) => item.id === PROFILE_ID);
|
|
2242
|
-
var ownsProfile = (profile) => Boolean(
|
|
2243
|
-
profile && profile.id === PROFILE_ID && profile.name === "Pollinations" && profile.agent === "claude-code" && profile.scope === "ccr"
|
|
2244
|
-
);
|
|
2245
|
-
var routeModel = (model) => `openai/${model}`;
|
|
2246
|
-
var routerInfo = async (ctx) => {
|
|
2247
|
-
if (!ccrInstalled(ctx) || !ccrServiceRunning(ctx)) {
|
|
2248
|
-
return { version: "", compatible: false };
|
|
2249
|
-
}
|
|
2250
|
-
const service = requireCcrService(ctx);
|
|
2251
|
-
const info2 = await ccrRpc(service, "getAppInfo");
|
|
2252
|
-
const version = String(info2.version ?? "");
|
|
2253
|
-
return { version, compatible: ccrVersionCompatible(version) };
|
|
2254
|
-
};
|
|
2255
|
-
var result2 = async (ctx) => {
|
|
2256
|
-
const router = ccrInstalled(ctx);
|
|
2257
|
-
const client = commandExists("claude", ctx.env);
|
|
2258
|
-
const serviceRunning = ccrServiceRunning(ctx);
|
|
2259
|
-
let version = "";
|
|
2260
|
-
let compatible = false;
|
|
2261
|
-
let providerReady = false;
|
|
2262
|
-
let profileReady = false;
|
|
2263
|
-
let model;
|
|
2264
|
-
let conflict = false;
|
|
2265
|
-
if (router && serviceRunning) {
|
|
2266
|
-
const info2 = await routerInfo(ctx);
|
|
2267
|
-
version = info2.version;
|
|
2268
|
-
compatible = info2.compatible;
|
|
2269
|
-
if (compatible) {
|
|
2270
|
-
const service = requireCcrService(ctx);
|
|
2271
|
-
const config = await ccrRpc(service, "getConfig");
|
|
2272
|
-
const provider2 = providerFor(config);
|
|
2273
|
-
conflict = Boolean(conflictingProvider(config));
|
|
2274
|
-
providerReady = ownsProvider(provider2) && Boolean(provider2?.api_key);
|
|
2275
|
-
const profile = profileFor(config);
|
|
2276
|
-
profileReady = ownsProfile(profile) && profile?.enabled === true;
|
|
2277
|
-
if (profile?.model?.startsWith("openai/")) {
|
|
2278
|
-
model = profile.model.slice("openai/".length);
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
const next = !router ? `Install Claude Code Router: ${CCR_INSTALL}` : !client ? "Install Claude Code: https://claude.com/claude-code" : !serviceRunning ? "Start Claude Code Router first: ccr start" : !compatible ? `Upgrade Claude Code Router to >= ${MIN_CCR_VERSION.join(".")}.` : conflict ? "A different provider named 'Pollinations' already exists in CCR; rename it before running Polli." : !providerReady || !profileReady ? "Run: polli harness claude-code on" : 'Ready. Launch with: ccr "Pollinations"';
|
|
2157
|
+
var status2 = (ctx) => {
|
|
2158
|
+
const installed = commandExists("claude", ctx.env);
|
|
2159
|
+
const env = readEnv(ctx);
|
|
2160
|
+
const written = env.ANTHROPIC_BASE_URL === BASE_URL && Boolean(env.ANTHROPIC_AUTH_TOKEN) && Boolean(env.ANTHROPIC_MODEL);
|
|
2283
2161
|
return {
|
|
2284
2162
|
harness: ID2,
|
|
2285
2163
|
label: LABEL2,
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
routerInstalled: router,
|
|
2292
|
-
routerVersion: version || void 0,
|
|
2293
|
-
routerCompatible: compatible,
|
|
2294
|
-
routerReady: serviceRunning,
|
|
2295
|
-
clientInstalled: client,
|
|
2296
|
-
providerReady,
|
|
2297
|
-
profileReady,
|
|
2298
|
-
next
|
|
2164
|
+
installed,
|
|
2165
|
+
configured: installed && written,
|
|
2166
|
+
model: env.ANTHROPIC_MODEL || void 0,
|
|
2167
|
+
files: [settingsPath(ctx)],
|
|
2168
|
+
next: !installed ? INSTALL : !written ? "Run: polli harness claude-code on" : `Ready. Launch with: claude --settings "${settingsPath(ctx)}"`
|
|
2299
2169
|
};
|
|
2300
2170
|
};
|
|
2301
|
-
var smokeTest =
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
}
|
|
2323
|
-
]
|
|
2324
|
-
})
|
|
2325
|
-
});
|
|
2326
|
-
const text = await response.text();
|
|
2327
|
-
if (!response.ok || !/\bpong\b/i.test(text)) {
|
|
2171
|
+
var smokeTest = (ctx) => {
|
|
2172
|
+
const run2 = spawnSync2(
|
|
2173
|
+
"claude",
|
|
2174
|
+
[
|
|
2175
|
+
"-p",
|
|
2176
|
+
"--settings",
|
|
2177
|
+
settingsPath(ctx),
|
|
2178
|
+
"--no-session-persistence",
|
|
2179
|
+
"Reply with exactly one word: pong"
|
|
2180
|
+
],
|
|
2181
|
+
{
|
|
2182
|
+
cwd: tmpdir(),
|
|
2183
|
+
// Fail fast instead of retrying a broken setup for minutes.
|
|
2184
|
+
env: { ...ctx.env, CLAUDE_CODE_MAX_RETRIES: "1" },
|
|
2185
|
+
encoding: "utf-8",
|
|
2186
|
+
timeout: 18e4,
|
|
2187
|
+
windowsHide: true
|
|
2188
|
+
}
|
|
2189
|
+
);
|
|
2190
|
+
if (run2.error) throw run2.error;
|
|
2191
|
+
if (run2.status !== 0 || !/\bpong\b/i.test(run2.stdout)) {
|
|
2328
2192
|
throw new Error(
|
|
2329
|
-
`Claude Code
|
|
2193
|
+
`Claude Code smoke test failed: ${`${run2.stdout}${run2.stderr}`.trim().slice(0, 500)}`
|
|
2330
2194
|
);
|
|
2331
2195
|
}
|
|
2332
2196
|
};
|
|
2333
|
-
var
|
|
2334
|
-
const
|
|
2335
|
-
const
|
|
2336
|
-
const
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
"Claude Code Router already has a different provider named 'Pollinations'. No changes were made."
|
|
2341
|
-
);
|
|
2342
|
-
}
|
|
2343
|
-
if (existing && !ownsProvider(existing)) {
|
|
2344
|
-
throw new Error(
|
|
2345
|
-
"Claude Code Router contains the Polli provider id with foreign settings. No changes were made."
|
|
2346
|
-
);
|
|
2347
|
-
}
|
|
2348
|
-
const originalProfile = profileFor(original);
|
|
2349
|
-
if (originalProfile && !ownsProfile(originalProfile)) {
|
|
2350
|
-
throw new Error(
|
|
2351
|
-
"The CCR Polli profile id already exists with foreign settings. No changes were made."
|
|
2352
|
-
);
|
|
2353
|
-
}
|
|
2354
|
-
const next = structuredClone(original);
|
|
2355
|
-
const provider2 = {
|
|
2356
|
-
...existing ?? {},
|
|
2357
|
-
id: PROVIDER_ID,
|
|
2358
|
-
name: PROVIDER_NAME,
|
|
2359
|
-
provider: "pollinations",
|
|
2360
|
-
type: "openai_chat_completions",
|
|
2361
|
-
api_base_url: `${BASE_URL}/v1`,
|
|
2362
|
-
api_key: settings.apiKey,
|
|
2363
|
-
models: settings.models.map((item) => item.id),
|
|
2364
|
-
enabled: true
|
|
2365
|
-
};
|
|
2366
|
-
next.Providers = [
|
|
2367
|
-
...next.Providers.filter((item) => item.id !== PROVIDER_ID),
|
|
2368
|
-
provider2
|
|
2369
|
-
];
|
|
2370
|
-
const existingProfile = profileFor(next);
|
|
2371
|
-
const profile = {
|
|
2372
|
-
...existingProfile ?? {},
|
|
2373
|
-
id: PROFILE_ID,
|
|
2374
|
-
name: "Pollinations",
|
|
2375
|
-
agent: "claude-code",
|
|
2376
|
-
enabled: true,
|
|
2377
|
-
scope: "ccr",
|
|
2378
|
-
surface: "cli",
|
|
2379
|
-
model: routeModel(settings.model),
|
|
2380
|
-
availableModels: settings.models.map((item) => routeModel(item.id))
|
|
2197
|
+
var configure = async (ctx, apiKey, model) => {
|
|
2198
|
+
const path = settingsPath(ctx);
|
|
2199
|
+
const previous = readTextIfExists(path);
|
|
2200
|
+
const env = {
|
|
2201
|
+
ANTHROPIC_BASE_URL: BASE_URL,
|
|
2202
|
+
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
2203
|
+
...Object.fromEntries(MODEL_VARS.map((name) => [name, model]))
|
|
2381
2204
|
};
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
profile
|
|
2385
|
-
];
|
|
2386
|
-
const beforeUsage = await keyUsageCount(settings.apiKey);
|
|
2387
|
-
const startedAt = Date.now();
|
|
2205
|
+
writeTextAtomic(path, `${JSON.stringify({ env }, null, 2)}
|
|
2206
|
+
`, 384);
|
|
2388
2207
|
try {
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
if (!gateway.endpoint || gateway.state !== "running") {
|
|
2394
|
-
throw new Error(
|
|
2395
|
-
"Claude Code Router gateway is not running after configuration."
|
|
2396
|
-
);
|
|
2397
|
-
}
|
|
2398
|
-
await smokeTest(saved, gateway.endpoint, settings.model);
|
|
2399
|
-
await waitForKeyUsageIncrease(settings.apiKey, beforeUsage, {
|
|
2400
|
-
afterMs: startedAt
|
|
2401
|
-
});
|
|
2208
|
+
const before = await keyUsageCount(apiKey);
|
|
2209
|
+
const startedAt = Date.now();
|
|
2210
|
+
smokeTest(ctx);
|
|
2211
|
+
await waitForKeyUsageIncrease(apiKey, before, { afterMs: startedAt });
|
|
2402
2212
|
} catch (error) {
|
|
2403
|
-
|
|
2213
|
+
if (previous === null) removeIfExists(path);
|
|
2214
|
+
else writeTextAtomic(path, previous, 384);
|
|
2404
2215
|
throw error;
|
|
2405
2216
|
}
|
|
2406
|
-
return { ...
|
|
2217
|
+
return { ...status2(ctx), smokeVerified: true };
|
|
2407
2218
|
};
|
|
2408
2219
|
var claudeCode = {
|
|
2409
2220
|
id: ID2,
|
|
2410
2221
|
label: LABEL2,
|
|
2411
|
-
description: "Use Pollinations in Claude Code through
|
|
2412
|
-
restartHint:
|
|
2222
|
+
description: "Use Pollinations in Claude Code through gen's Anthropic Messages API, with a separate settings file",
|
|
2223
|
+
restartHint: "Launch with: claude --settings ~/.pollinations/claude-code.json",
|
|
2413
2224
|
async on(ctx, options) {
|
|
2414
|
-
if (!ccrInstalled(ctx)) {
|
|
2415
|
-
throw new Error(
|
|
2416
|
-
`Claude Code Router was not found. Install it first: ${CCR_INSTALL}`
|
|
2417
|
-
);
|
|
2418
|
-
}
|
|
2419
2225
|
if (!commandExists("claude", ctx.env)) {
|
|
2420
|
-
throw new Error(
|
|
2421
|
-
"Claude Code was not found. Install it first: https://claude.com/claude-code"
|
|
2422
|
-
);
|
|
2423
|
-
}
|
|
2424
|
-
if (!ccrServiceRunning(ctx)) {
|
|
2425
|
-
throw new Error(
|
|
2426
|
-
"Claude Code Router is not running. Start it with 'ccr start' before Polli login or key creation."
|
|
2427
|
-
);
|
|
2428
|
-
}
|
|
2429
|
-
const info2 = await routerInfo(ctx);
|
|
2430
|
-
if (!info2.compatible) {
|
|
2431
|
-
throw new Error(
|
|
2432
|
-
`Claude Code Router ${info2.version || "unknown"} is unsupported; upgrade to >= ${MIN_CCR_VERSION.join(".")} before Polli login or key creation.`
|
|
2433
|
-
);
|
|
2226
|
+
throw new Error(`Claude Code was not found. ${INSTALL}`);
|
|
2434
2227
|
}
|
|
2435
2228
|
const model = options.model ?? DEFAULT_MODEL;
|
|
2436
|
-
|
|
2437
|
-
const service = requireCcrService(ctx);
|
|
2438
|
-
const config = await ccrRpc(service, "getConfig");
|
|
2439
|
-
const current = providerFor(config);
|
|
2440
|
-
if (conflictingProvider(config)) {
|
|
2441
|
-
throw new Error(
|
|
2442
|
-
"A different CCR provider named 'Pollinations' already exists. No changes were made."
|
|
2443
|
-
);
|
|
2444
|
-
}
|
|
2445
|
-
if (current && !ownsProvider(current)) {
|
|
2446
|
-
throw new Error(
|
|
2447
|
-
"The CCR Polli provider id already exists with foreign settings. No changes were made."
|
|
2448
|
-
);
|
|
2449
|
-
}
|
|
2450
|
-
const profile = profileFor(config);
|
|
2451
|
-
if (profile && !ownsProfile(profile)) {
|
|
2452
|
-
throw new Error(
|
|
2453
|
-
"The CCR Polli profile id already exists with foreign settings. No changes were made."
|
|
2454
|
-
);
|
|
2455
|
-
}
|
|
2229
|
+
await fetchHarnessModels(model);
|
|
2456
2230
|
const apiKey = await resolveHarnessKey(
|
|
2457
2231
|
{
|
|
2458
2232
|
id: ID2,
|
|
2459
2233
|
label: LABEL2,
|
|
2460
|
-
existingKey:
|
|
2234
|
+
existingKey: readEnv(ctx).ANTHROPIC_AUTH_TOKEN || null
|
|
2461
2235
|
},
|
|
2462
2236
|
{ browser: options.browser }
|
|
2463
2237
|
);
|
|
2464
|
-
return
|
|
2238
|
+
return configure(ctx, apiKey, model);
|
|
2465
2239
|
},
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
...await result2(ctx),
|
|
2470
|
-
configured: false,
|
|
2471
|
-
outcome: "unchanged"
|
|
2472
|
-
};
|
|
2473
|
-
}
|
|
2474
|
-
const service = requireCcrService(ctx);
|
|
2475
|
-
const config = await ccrRpc(service, "getConfig");
|
|
2476
|
-
const current = providerFor(config);
|
|
2477
|
-
const profile = profileFor(config);
|
|
2478
|
-
const ownedProvider = ownsProvider(current);
|
|
2479
|
-
const ownedProfile = ownsProfile(profile);
|
|
2480
|
-
if (!ownedProvider && !ownedProfile) {
|
|
2481
|
-
return {
|
|
2482
|
-
...await result2(ctx),
|
|
2483
|
-
configured: false,
|
|
2484
|
-
outcome: "unchanged"
|
|
2485
|
-
};
|
|
2486
|
-
}
|
|
2487
|
-
const next = structuredClone(config);
|
|
2488
|
-
if (ownedProvider) {
|
|
2489
|
-
next.Providers = next.Providers.filter(
|
|
2490
|
-
(item) => item.id !== PROVIDER_ID
|
|
2491
|
-
);
|
|
2492
|
-
}
|
|
2493
|
-
if (ownedProfile) {
|
|
2494
|
-
next.profile.profiles = next.profile.profiles.filter(
|
|
2495
|
-
(item) => item.id !== PROFILE_ID
|
|
2496
|
-
);
|
|
2497
|
-
}
|
|
2498
|
-
await ccrRpc(service, "saveConfig", next, { applyProfile: false });
|
|
2240
|
+
off(ctx) {
|
|
2241
|
+
const existed = readTextIfExists(settingsPath(ctx)) !== null;
|
|
2242
|
+
removeIfExists(settingsPath(ctx));
|
|
2499
2243
|
return {
|
|
2500
|
-
...
|
|
2244
|
+
...status2(ctx),
|
|
2501
2245
|
configured: false,
|
|
2502
|
-
outcome: "stripped"
|
|
2246
|
+
outcome: existed ? "stripped" : "unchanged"
|
|
2503
2247
|
};
|
|
2504
2248
|
},
|
|
2505
|
-
status:
|
|
2249
|
+
status: status2
|
|
2506
2250
|
};
|
|
2507
2251
|
|
|
2508
2252
|
// src/harnesses/codex.ts
|
|
2509
2253
|
init_config();
|
|
2510
|
-
import { spawnSync as
|
|
2254
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
2511
2255
|
import { join as join6 } from "path";
|
|
2512
2256
|
var ID3 = "codex";
|
|
2513
2257
|
var LABEL3 = "Codex";
|
|
@@ -2523,7 +2267,7 @@ var routerRoot = (ctx) => ctx.env.CODEX_ROUTER_SOURCE_ROOT?.trim() || ctx.env.MO
|
|
|
2523
2267
|
ctx.env.XDG_DATA_HOME ?? join6(ctx.home, ".local", "share"),
|
|
2524
2268
|
"codex-router"
|
|
2525
2269
|
));
|
|
2526
|
-
var
|
|
2270
|
+
var routerInfo = (ctx) => {
|
|
2527
2271
|
const text = readTextIfExists(join6(routerRoot(ctx), "package.json"));
|
|
2528
2272
|
if (!text) return { installed: false, version: "" };
|
|
2529
2273
|
try {
|
|
@@ -2546,7 +2290,7 @@ var codexRouterVersionCompatible = (value) => {
|
|
|
2546
2290
|
return true;
|
|
2547
2291
|
};
|
|
2548
2292
|
var runScript = (ctx, script, args, input) => {
|
|
2549
|
-
const run2 =
|
|
2293
|
+
const run2 = spawnSync3(
|
|
2550
2294
|
process.execPath,
|
|
2551
2295
|
[join6(routerRoot(ctx), "src", script), ...args],
|
|
2552
2296
|
{
|
|
@@ -2583,7 +2327,7 @@ var provider = (ctx) => {
|
|
|
2583
2327
|
"Codex Router provider status"
|
|
2584
2328
|
).provider;
|
|
2585
2329
|
};
|
|
2586
|
-
var
|
|
2330
|
+
var ownsProvider = (value) => Boolean(
|
|
2587
2331
|
value && value.description === OWNER_MARKER && value.baseUrl.replace(/\/$/, "") === `${BASE_URL}/v1` && value.adapter === "openai-chat"
|
|
2588
2332
|
);
|
|
2589
2333
|
var credentialConfigured = (ctx) => {
|
|
@@ -2614,7 +2358,7 @@ var setCredential = (ctx, key) => {
|
|
|
2614
2358
|
'await mod.runGenericCommand(["credential","pollinations","set","--json"],',
|
|
2615
2359
|
"{ prompt: () => value.trim() });"
|
|
2616
2360
|
].join(" ");
|
|
2617
|
-
const run2 =
|
|
2361
|
+
const run2 = spawnSync3(
|
|
2618
2362
|
process.execPath,
|
|
2619
2363
|
["--input-type=module", "-e", bridge],
|
|
2620
2364
|
{
|
|
@@ -2684,14 +2428,14 @@ var smoke = (ctx, model) => runScript(ctx, "compatibility-test.mjs", [
|
|
|
2684
2428
|
"--json"
|
|
2685
2429
|
]);
|
|
2686
2430
|
var failRun = (run2, what) => new Error(`${what}: ${(run2.err || run2.out).trim().slice(0, 500)}`);
|
|
2687
|
-
var
|
|
2688
|
-
const info2 =
|
|
2431
|
+
var status3 = (ctx) => {
|
|
2432
|
+
const info2 = routerInfo(ctx);
|
|
2689
2433
|
const installed = info2.installed;
|
|
2690
2434
|
const version = info2.version;
|
|
2691
2435
|
const compatible = installed && codexRouterVersionCompatible(version);
|
|
2692
2436
|
const client = commandExists("codex", ctx.env);
|
|
2693
2437
|
const current = compatible ? provider(ctx) : null;
|
|
2694
|
-
const owned =
|
|
2438
|
+
const owned = ownsProvider(current);
|
|
2695
2439
|
const key = owned && credentialConfigured(ctx);
|
|
2696
2440
|
const models2 = owned ? selectedModels(ctx) : [];
|
|
2697
2441
|
const next = !installed ? `Install Codex Router: ${ROUTER_INSTALL}` : !compatible ? `Upgrade Codex Router to >= ${MIN_ROUTER_VERSION.join(".")}.` : !client ? "Install Codex: https://github.com/openai/codex" : current && !owned ? "Provider id 'pollinations' exists but is not owned by Polli; rename or remove it manually." : !owned ? "Run: polli harness codex on" : !key ? "Run 'on' again to repair the dedicated Pollinations key." : models2.length === 0 ? "Run 'on' with --model to curate a Pollinations model." : "Ready.";
|
|
@@ -2714,7 +2458,7 @@ var status2 = (ctx) => {
|
|
|
2714
2458
|
};
|
|
2715
2459
|
var configureCodex = async (ctx, model, options = {}) => {
|
|
2716
2460
|
const current = provider(ctx);
|
|
2717
|
-
if (current && !
|
|
2461
|
+
if (current && !ownsProvider(current)) {
|
|
2718
2462
|
throw new Error(
|
|
2719
2463
|
"Codex Router already has a provider named 'pollinations' that Polli does not own. No changes were made."
|
|
2720
2464
|
);
|
|
@@ -2751,8 +2495,8 @@ var configureCodex = async (ctx, model, options = {}) => {
|
|
|
2751
2495
|
if (!check.ok) {
|
|
2752
2496
|
throw failRun(check, "Codex Router smoke test");
|
|
2753
2497
|
}
|
|
2754
|
-
const
|
|
2755
|
-
if (
|
|
2498
|
+
const result9 = parseJson(check, "Codex Router smoke test");
|
|
2499
|
+
if (result9.ok !== true || !result9.results?.some(
|
|
2756
2500
|
(item) => item.name === "basic response" && item.ok === true
|
|
2757
2501
|
)) {
|
|
2758
2502
|
throw new Error(
|
|
@@ -2762,11 +2506,15 @@ var configureCodex = async (ctx, model, options = {}) => {
|
|
|
2762
2506
|
await waitForKeyUsageIncrease(key, before, {
|
|
2763
2507
|
afterMs: startedAt
|
|
2764
2508
|
});
|
|
2765
|
-
return {
|
|
2509
|
+
return {
|
|
2510
|
+
...status3(ctx),
|
|
2511
|
+
model: `${PROVIDER}/${model}`,
|
|
2512
|
+
smokeVerified: true
|
|
2513
|
+
};
|
|
2766
2514
|
} catch (error) {
|
|
2767
2515
|
try {
|
|
2768
2516
|
if (!hadModel && provider(ctx)) removeModel(ctx, model);
|
|
2769
|
-
if (addedProvider &&
|
|
2517
|
+
if (addedProvider && ownsProvider(provider(ctx))) {
|
|
2770
2518
|
removeProvider(ctx);
|
|
2771
2519
|
} else if (previousKey && key && previousKey !== key) {
|
|
2772
2520
|
setCredential(ctx, previousKey);
|
|
@@ -2782,7 +2530,7 @@ var codex = {
|
|
|
2782
2530
|
description: "Use Pollinations in Codex through Codex Router",
|
|
2783
2531
|
restartHint: "Fully quit and reopen Codex, then choose the Pollinations model exposed by Codex Router.",
|
|
2784
2532
|
async on(ctx, options) {
|
|
2785
|
-
const info2 =
|
|
2533
|
+
const info2 = routerInfo(ctx);
|
|
2786
2534
|
if (!info2.installed) {
|
|
2787
2535
|
throw new Error(
|
|
2788
2536
|
`Codex Router was not found. Install it first: ${ROUTER_INSTALL}`
|
|
@@ -2804,10 +2552,10 @@ var codex = {
|
|
|
2804
2552
|
return configureCodex(ctx, model, { browser: options.browser });
|
|
2805
2553
|
},
|
|
2806
2554
|
off(ctx) {
|
|
2807
|
-
const current =
|
|
2808
|
-
if (!current || !
|
|
2555
|
+
const current = routerInfo(ctx).installed ? provider(ctx) : null;
|
|
2556
|
+
if (!current || !ownsProvider(current)) {
|
|
2809
2557
|
return {
|
|
2810
|
-
...
|
|
2558
|
+
...status3(ctx),
|
|
2811
2559
|
configured: false,
|
|
2812
2560
|
outcome: "unchanged"
|
|
2813
2561
|
};
|
|
@@ -2815,12 +2563,12 @@ var codex = {
|
|
|
2815
2563
|
const run2 = removeProvider(ctx);
|
|
2816
2564
|
if (!run2.ok) throw failRun(run2, "Codex Router cleanup");
|
|
2817
2565
|
return {
|
|
2818
|
-
...
|
|
2566
|
+
...status3(ctx),
|
|
2819
2567
|
configured: false,
|
|
2820
2568
|
outcome: "stripped"
|
|
2821
2569
|
};
|
|
2822
2570
|
},
|
|
2823
|
-
status:
|
|
2571
|
+
status: status3
|
|
2824
2572
|
};
|
|
2825
2573
|
|
|
2826
2574
|
// src/harnesses/dsh.ts
|
|
@@ -2829,7 +2577,7 @@ import { parseEnv as parseEnv2 } from "util";
|
|
|
2829
2577
|
import { isMap, isSeq, parseDocument, Scalar } from "yaml";
|
|
2830
2578
|
|
|
2831
2579
|
// SKILL.md?raw
|
|
2832
|
-
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, 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\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\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| Filter models by type | `polli models --type image` (text, image, audio, video, 3d, embedding) |\n| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |\n| Check balance | `polli usage` |\n| Developer earnings | `polli earnings` (`--days <n>`, max 90) |\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> on` (available adapters: `polli harness --help`) |\n| Start a Linux sandbox (alpha) | `polli sandbox create` (then `list`, `logs <id>`, `timeout <id> <seconds>`, `kill <id>`); the default template comes logged in, with the coding harnesses |\n| ssh / scp / rsync into a sandbox | `ssh <sandbox-id>.polli` |\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>`.\nPrefix any command with `POLLINATIONS_ENV=staging` to use staging; it keeps its own login, so run `POLLINATIONS_ENV=staging polli auth login` once.\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: `zimage`, 1024x1024. Pick a different model with `--model flux` (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 `flux` and `zimage` 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: `nanobanana`, `kontext`, `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 --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```\nDefault voice is `sage`. To discover the full live voice list, use the model registry: `polli models --type audio --json | jq -r \'.[].voices[]?\'` \u2014 each audio model entry includes its `voices[]` array. 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 (elevenmusic)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenmusic --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (eleven-sfx)\n```bash\npolli gen audio "thunderclap with heavy rain" --model eleven-sfx --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 (eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model 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### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model wan-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model wan-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: `whisper` (default), `scribe`, `universal-2`, `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 --type image --verbose # with 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 `gptimage` lands at ~$0.008, not $0.000008. Flat-priced image models (`flux`, `zimage`) 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, max 90\npolli quests # your quests + claim state (open/claimable/claimed/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.\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 delete <id>\n```\nPrompt-agent config contains `systemPrompt`, `baseModel`, and optional `mcpServers`; 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. Prompt-agent updates replace the complete runtime configuration.\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### 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 revoke <id> # id comes from `keys list --json`\n```\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 # enable the Pollinations OpenCode plugin\npolli harness opencode off # remove the plugin 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\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, and tgpt require their installed commands.\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 enables the existing Pollinations plugin and stores its dedicated key in the plugin config. 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';
|
|
2580
|
+
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, 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\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\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| Filter models by type | `polli models --type image` (text, image, audio, video, 3d, embedding) |\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> on` (available adapters: `polli harness --help`) |\n| Start a Linux sandbox (alpha) | `polli sandbox create` (then `list`, `logs <id>`, `timeout <id> <seconds>`, `kill <id>`); the default template comes logged in, with the coding harnesses |\n| ssh / scp / rsync into a sandbox | `ssh <sandbox-id>.polli` |\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>`.\nPrefix any command with `POLLINATIONS_ENV=staging` to use staging; it keeps its own login, so run `POLLINATIONS_ENV=staging polli auth login` once.\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: `zimage`, 1024x1024. Pick a different model with `--model flux` (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 `flux` and `zimage` 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: `nanobanana`, `kontext`, `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 --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```\nDefault voice is `sage`. To discover the full live voice list, use the model registry: `polli models --type audio --json | jq -r \'.[].voices[]?\'` \u2014 each audio model entry includes its `voices[]` array. 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 (elevenmusic)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenmusic --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (eleven-sfx)\n```bash\npolli gen audio "thunderclap with heavy rain" --model eleven-sfx --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 (eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model 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### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model wan-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model wan-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: `whisper` (default), `scribe`, `universal-2`, `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 --type image --verbose # with 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 `gptimage` lands at ~$0.008, not $0.000008. Flat-priced image models (`flux`, `zimage`) 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/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.\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 delete <id>\n```\nPrompt-agent config contains `systemPrompt`, `baseModel`, and optional `mcpServers`; 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. Prompt-agent updates replace the complete runtime configuration.\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### 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 revoke <id> # id comes from `keys list --json`\n```\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 # enable the Pollinations OpenCode plugin\npolli harness opencode off # remove the plugin 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\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, and tgpt require their installed commands.\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 enables the existing Pollinations plugin and stores its dedicated key in the plugin config. 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';
|
|
2833
2581
|
|
|
2834
2582
|
// src/harnesses/dsh.ts
|
|
2835
2583
|
init_config();
|
|
@@ -2852,13 +2600,13 @@ var dshHome = (ctx) => {
|
|
|
2852
2600
|
if (!configured?.trim()) return join7(ctx.home, ".dsh");
|
|
2853
2601
|
return resolveHomePath(ctx.home, configured);
|
|
2854
2602
|
};
|
|
2855
|
-
var
|
|
2603
|
+
var settingsPath2 = (ctx) => join7(dshHome(ctx), "settings.yaml");
|
|
2856
2604
|
var envPath2 = (ctx) => join7(dshHome(ctx), ".env");
|
|
2857
2605
|
var patchPath = (ctx) => join7(dshHome(ctx), "cordis.patch.yml");
|
|
2858
2606
|
var skillPath = (ctx) => join7(dshHome(ctx), "skills", "polli", "SKILL.md");
|
|
2859
2607
|
var loadYaml = (path) => parseDocument(readTextIfExists(path) ?? "", { customTags: [JS_TAG] });
|
|
2860
2608
|
var files2 = (ctx) => [
|
|
2861
|
-
|
|
2609
|
+
settingsPath2(ctx),
|
|
2862
2610
|
envPath2(ctx),
|
|
2863
2611
|
patchPath(ctx),
|
|
2864
2612
|
skillPath(ctx)
|
|
@@ -2978,13 +2726,13 @@ var providerConfig = (models2) => ({
|
|
|
2978
2726
|
}))
|
|
2979
2727
|
});
|
|
2980
2728
|
var writeConfig = (ctx, settings) => {
|
|
2981
|
-
const doc = loadYaml(
|
|
2729
|
+
const doc = loadYaml(settingsPath2(ctx));
|
|
2982
2730
|
doc.setIn(PROVIDER_PATH, doc.createNode(providerConfig(settings.models)));
|
|
2983
2731
|
doc.setIn(
|
|
2984
2732
|
DEFAULT_MODEL_PATH,
|
|
2985
2733
|
doc.createNode({ provider: PROVIDER2, model: settings.model })
|
|
2986
2734
|
);
|
|
2987
|
-
writeTextAtomic(
|
|
2735
|
+
writeTextAtomic(settingsPath2(ctx), doc.toString(YAML_OUT), 384);
|
|
2988
2736
|
setEnvKey(ctx, settings.apiKey);
|
|
2989
2737
|
if (settings.mcp === false) removeMcpEntry(ctx);
|
|
2990
2738
|
else writeMcpEntry(ctx);
|
|
@@ -2993,7 +2741,7 @@ var writeConfig = (ctx, settings) => {
|
|
|
2993
2741
|
}
|
|
2994
2742
|
};
|
|
2995
2743
|
var stripConfig = (ctx) => {
|
|
2996
|
-
const doc = loadYaml(
|
|
2744
|
+
const doc = loadYaml(settingsPath2(ctx));
|
|
2997
2745
|
let changed = false;
|
|
2998
2746
|
if (doc.hasIn(PROVIDER_PATH)) {
|
|
2999
2747
|
doc.deleteIn(PROVIDER_PATH);
|
|
@@ -3004,7 +2752,7 @@ var stripConfig = (ctx) => {
|
|
|
3004
2752
|
changed = true;
|
|
3005
2753
|
}
|
|
3006
2754
|
if (changed)
|
|
3007
|
-
writeTextAtomic(
|
|
2755
|
+
writeTextAtomic(settingsPath2(ctx), doc.toString(YAML_OUT), 384);
|
|
3008
2756
|
changed = deleteEnvKey(ctx) || changed;
|
|
3009
2757
|
changed = removeMcpEntry(ctx) || changed;
|
|
3010
2758
|
if (readTextIfExists(skillPath(ctx)) === SKILL_default) {
|
|
@@ -3013,8 +2761,8 @@ var stripConfig = (ctx) => {
|
|
|
3013
2761
|
}
|
|
3014
2762
|
return changed;
|
|
3015
2763
|
};
|
|
3016
|
-
var
|
|
3017
|
-
const doc = loadYaml(
|
|
2764
|
+
var result2 = (ctx) => {
|
|
2765
|
+
const doc = loadYaml(settingsPath2(ctx));
|
|
3018
2766
|
const model = doc.getIn([...DEFAULT_MODEL_PATH, "model"]);
|
|
3019
2767
|
return {
|
|
3020
2768
|
harness: ID4,
|
|
@@ -3027,11 +2775,11 @@ var result3 = (ctx) => {
|
|
|
3027
2775
|
};
|
|
3028
2776
|
var configureDsh = (ctx, settings) => {
|
|
3029
2777
|
applyWithSnapshot(ctx, ID4, files2(ctx), () => writeConfig(ctx, settings));
|
|
3030
|
-
return
|
|
2778
|
+
return result2(ctx);
|
|
3031
2779
|
};
|
|
3032
2780
|
var disableDsh = (ctx) => {
|
|
3033
2781
|
const outcome = restoreOrStrip(ctx, ID4, files2(ctx), () => stripConfig(ctx));
|
|
3034
|
-
return { ...
|
|
2782
|
+
return { ...result2(ctx), configured: false, outcome };
|
|
3035
2783
|
};
|
|
3036
2784
|
var dsh = {
|
|
3037
2785
|
id: ID4,
|
|
@@ -3058,7 +2806,7 @@ var dsh = {
|
|
|
3058
2806
|
});
|
|
3059
2807
|
},
|
|
3060
2808
|
off: disableDsh,
|
|
3061
|
-
status:
|
|
2809
|
+
status: result2
|
|
3062
2810
|
};
|
|
3063
2811
|
|
|
3064
2812
|
// src/harnesses/hermes.ts
|
|
@@ -3126,13 +2874,13 @@ var deleteEnvKey2 = (ctx) => {
|
|
|
3126
2874
|
writeTextAtomic(envPath3(ctx), filtered.join("\n"), 384);
|
|
3127
2875
|
return true;
|
|
3128
2876
|
};
|
|
3129
|
-
var
|
|
2877
|
+
var ownsProvider2 = (doc) => doc.getIn(["providers", PROVIDER3, "api"]) === `${BASE_URL}/v1` && doc.getIn(["providers", PROVIDER3, "key_env"]) === KEY_ENV3;
|
|
3130
2878
|
var writeConfig2 = (ctx, model) => {
|
|
3131
2879
|
const doc = loadYaml2(configPath(ctx));
|
|
3132
2880
|
if (!isMap2(doc.contents)) {
|
|
3133
2881
|
throw new Error(`${configPath(ctx)} must contain a YAML mapping`);
|
|
3134
2882
|
}
|
|
3135
|
-
if (doc.hasIn(["providers", PROVIDER3]) && !
|
|
2883
|
+
if (doc.hasIn(["providers", PROVIDER3]) && !ownsProvider2(doc)) {
|
|
3136
2884
|
throw new Error(
|
|
3137
2885
|
"An existing pollinations provider has different settings; leaving it unchanged."
|
|
3138
2886
|
);
|
|
@@ -3148,7 +2896,7 @@ var stripConfig2 = (ctx) => {
|
|
|
3148
2896
|
const doc = loadYaml2(configPath(ctx));
|
|
3149
2897
|
if (!isMap2(doc.contents)) return false;
|
|
3150
2898
|
let changed = false;
|
|
3151
|
-
if (!
|
|
2899
|
+
if (!ownsProvider2(doc)) return false;
|
|
3152
2900
|
for (const field of ["name", "api", "key_env"]) {
|
|
3153
2901
|
doc.deleteIn(["providers", PROVIDER3, field]);
|
|
3154
2902
|
}
|
|
@@ -3184,9 +2932,9 @@ var cleanupSkillDir = (ctx) => {
|
|
|
3184
2932
|
} catch {
|
|
3185
2933
|
}
|
|
3186
2934
|
};
|
|
3187
|
-
var
|
|
2935
|
+
var result3 = (ctx) => {
|
|
3188
2936
|
const doc = loadYaml2(configPath(ctx));
|
|
3189
|
-
const configured = isMap2(doc.contents) &&
|
|
2937
|
+
const configured = isMap2(doc.contents) && ownsProvider2(doc) && doc.getIn(["model", "provider"]) === PROVIDER3 && readKey3(ctx) !== null && readTextIfExists(skillPath2(ctx)) !== null;
|
|
3190
2938
|
const model = doc.getIn(["model", "default"]);
|
|
3191
2939
|
return {
|
|
3192
2940
|
harness: ID5,
|
|
@@ -3203,7 +2951,7 @@ var writeAll = (ctx, settings) => {
|
|
|
3203
2951
|
writeSkill(ctx);
|
|
3204
2952
|
};
|
|
3205
2953
|
var stripAll = (ctx) => {
|
|
3206
|
-
if (!
|
|
2954
|
+
if (!ownsProvider2(loadYaml2(configPath(ctx)))) return false;
|
|
3207
2955
|
let changed = stripConfig2(ctx);
|
|
3208
2956
|
changed = deleteEnvKey2(ctx) || changed;
|
|
3209
2957
|
changed = stripSkill(ctx) || changed;
|
|
@@ -3211,12 +2959,12 @@ var stripAll = (ctx) => {
|
|
|
3211
2959
|
};
|
|
3212
2960
|
var configureHermes = (ctx, settings) => {
|
|
3213
2961
|
applyWithSnapshot(ctx, ID5, files3(ctx), () => writeAll(ctx, settings));
|
|
3214
|
-
return
|
|
2962
|
+
return result3(ctx);
|
|
3215
2963
|
};
|
|
3216
2964
|
var disableHermes = (ctx) => {
|
|
3217
2965
|
const outcome = restoreOrStrip(ctx, ID5, files3(ctx), () => stripAll(ctx));
|
|
3218
2966
|
cleanupSkillDir(ctx);
|
|
3219
|
-
return { ...
|
|
2967
|
+
return { ...result3(ctx), configured: false, outcome };
|
|
3220
2968
|
};
|
|
3221
2969
|
var INSTALL_HINT = process.platform === "win32" ? "iex (irm https://hermes-agent.nousresearch.com/install.ps1)" : "curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash";
|
|
3222
2970
|
var hermesInstalled = (ctx) => commandExists("hermes", ctx.env, [
|
|
@@ -3243,11 +2991,11 @@ var hermes = {
|
|
|
3243
2991
|
return configureHermes(ctx, { apiKey, model });
|
|
3244
2992
|
},
|
|
3245
2993
|
off: disableHermes,
|
|
3246
|
-
status:
|
|
2994
|
+
status: result3
|
|
3247
2995
|
};
|
|
3248
2996
|
|
|
3249
2997
|
// src/harnesses/openclaw.ts
|
|
3250
|
-
import { spawnSync as
|
|
2998
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
3251
2999
|
import { join as join9 } from "path";
|
|
3252
3000
|
import JSON5 from "json5";
|
|
3253
3001
|
init_config();
|
|
@@ -3348,7 +3096,7 @@ var stripConfig3 = (ctx) => {
|
|
|
3348
3096
|
}
|
|
3349
3097
|
return changed;
|
|
3350
3098
|
};
|
|
3351
|
-
var
|
|
3099
|
+
var result4 = (ctx) => {
|
|
3352
3100
|
const doc = loadJson(configPath2(ctx));
|
|
3353
3101
|
const provider2 = asRecord(doc.models?.providers?.[PROVIDER4]);
|
|
3354
3102
|
const primary = asRecord(doc.agents?.defaults?.model).primary;
|
|
@@ -3367,16 +3115,16 @@ var configureOpenClaw = (ctx, models2, apiKey, model) => {
|
|
|
3367
3115
|
files4(ctx),
|
|
3368
3116
|
() => writeConfig3(ctx, models2, apiKey, model)
|
|
3369
3117
|
);
|
|
3370
|
-
return
|
|
3118
|
+
return result4(ctx);
|
|
3371
3119
|
};
|
|
3372
3120
|
var disableOpenClaw = (ctx) => {
|
|
3373
3121
|
const outcome = restoreOrStrip(ctx, ID6, files4(ctx), () => stripConfig3(ctx));
|
|
3374
|
-
return { ...
|
|
3122
|
+
return { ...result4(ctx), configured: false, outcome };
|
|
3375
3123
|
};
|
|
3376
3124
|
var openclawInstalled = (ctx) => commandExists("openclaw", ctx.env);
|
|
3377
3125
|
var initializeOpenClaw = (ctx) => {
|
|
3378
3126
|
if (readTextIfExists(configPath2(ctx)) !== null) return;
|
|
3379
|
-
const setup =
|
|
3127
|
+
const setup = spawnSync4("openclaw", ["setup", "--baseline"], {
|
|
3380
3128
|
env: ctx.env,
|
|
3381
3129
|
stdio: "ignore"
|
|
3382
3130
|
});
|
|
@@ -3406,7 +3154,7 @@ var openclaw = {
|
|
|
3406
3154
|
return configureOpenClaw(ctx, models2, apiKey, model);
|
|
3407
3155
|
},
|
|
3408
3156
|
off: disableOpenClaw,
|
|
3409
|
-
status:
|
|
3157
|
+
status: result4
|
|
3410
3158
|
};
|
|
3411
3159
|
|
|
3412
3160
|
// src/harnesses/opencode.ts
|
|
@@ -3520,7 +3268,7 @@ var stripOpenCodeConfig = (ctx) => {
|
|
|
3520
3268
|
if (changed) writeJson(path, config);
|
|
3521
3269
|
return changed;
|
|
3522
3270
|
};
|
|
3523
|
-
var
|
|
3271
|
+
var result5 = (ctx) => {
|
|
3524
3272
|
const config = openCodeConfig(ctx);
|
|
3525
3273
|
const model = isOurDefaultModel(config.model) ? config.model.slice("pollinations/enter/".length) : void 0;
|
|
3526
3274
|
return {
|
|
@@ -3542,11 +3290,11 @@ var stripConfig4 = (ctx) => {
|
|
|
3542
3290
|
};
|
|
3543
3291
|
var configureOpenCode = (ctx, settings) => {
|
|
3544
3292
|
applyWithSnapshot(ctx, ID7, files5(ctx), () => writeConfig4(ctx, settings));
|
|
3545
|
-
return
|
|
3293
|
+
return result5(ctx);
|
|
3546
3294
|
};
|
|
3547
3295
|
var disableOpenCode = (ctx) => {
|
|
3548
3296
|
const outcome = restoreOrStrip(ctx, ID7, files5(ctx), () => stripConfig4(ctx));
|
|
3549
|
-
return { ...
|
|
3297
|
+
return { ...result5(ctx), configured: false, outcome };
|
|
3550
3298
|
};
|
|
3551
3299
|
var openCodeInstalled = (ctx) => commandExists("opencode", ctx.env, [
|
|
3552
3300
|
join10(ctx.home, ".opencode", "bin", "opencode")
|
|
@@ -3576,7 +3324,7 @@ var opencode = {
|
|
|
3576
3324
|
return configureOpenCode(ctx, { apiKey, model });
|
|
3577
3325
|
},
|
|
3578
3326
|
off: disableOpenCode,
|
|
3579
|
-
status:
|
|
3327
|
+
status: result5
|
|
3580
3328
|
};
|
|
3581
3329
|
|
|
3582
3330
|
// src/harnesses/pi.ts
|
|
@@ -3593,12 +3341,12 @@ var piAgentDir = (ctx) => {
|
|
|
3593
3341
|
};
|
|
3594
3342
|
var modelsPath = (ctx) => join11(piAgentDir(ctx), "models.json");
|
|
3595
3343
|
var authPath = (ctx) => join11(piAgentDir(ctx), "auth.json");
|
|
3596
|
-
var
|
|
3344
|
+
var settingsPath3 = (ctx) => join11(piAgentDir(ctx), "settings.json");
|
|
3597
3345
|
var skillFile2 = (ctx) => join11(piAgentDir(ctx), "skills", "polli", "SKILL.md");
|
|
3598
3346
|
var files6 = (ctx) => [
|
|
3599
3347
|
modelsPath(ctx),
|
|
3600
3348
|
authPath(ctx),
|
|
3601
|
-
|
|
3349
|
+
settingsPath3(ctx),
|
|
3602
3350
|
skillFile2(ctx)
|
|
3603
3351
|
];
|
|
3604
3352
|
var loadJson2 = (path) => {
|
|
@@ -3646,10 +3394,10 @@ var writeConfig5 = (ctx, settings) => {
|
|
|
3646
3394
|
const auth = loadJson2(authPath(ctx));
|
|
3647
3395
|
auth[PROVIDER5] = { type: "api_key", key: settings.apiKey };
|
|
3648
3396
|
saveJson2(authPath(ctx), auth);
|
|
3649
|
-
const piSettings = loadJson2(
|
|
3397
|
+
const piSettings = loadJson2(settingsPath3(ctx));
|
|
3650
3398
|
piSettings.defaultProvider = PROVIDER5;
|
|
3651
3399
|
piSettings.defaultModel = settings.model;
|
|
3652
|
-
saveJson2(
|
|
3400
|
+
saveJson2(settingsPath3(ctx), piSettings);
|
|
3653
3401
|
if (readTextIfExists(skillFile2(ctx)) === null) {
|
|
3654
3402
|
writeTextAtomic(skillFile2(ctx), SKILL_default, 384);
|
|
3655
3403
|
}
|
|
@@ -3674,13 +3422,13 @@ var stripConfig5 = (ctx) => {
|
|
|
3674
3422
|
changed = true;
|
|
3675
3423
|
}
|
|
3676
3424
|
}
|
|
3677
|
-
const settingsText = readTextIfExists(
|
|
3425
|
+
const settingsText = readTextIfExists(settingsPath3(ctx));
|
|
3678
3426
|
if (settingsText?.trim()) {
|
|
3679
3427
|
const data = JSON.parse(settingsText);
|
|
3680
3428
|
if (data.defaultProvider === PROVIDER5) {
|
|
3681
3429
|
delete data.defaultProvider;
|
|
3682
3430
|
delete data.defaultModel;
|
|
3683
|
-
saveJson2(
|
|
3431
|
+
saveJson2(settingsPath3(ctx), data);
|
|
3684
3432
|
changed = true;
|
|
3685
3433
|
}
|
|
3686
3434
|
}
|
|
@@ -3690,10 +3438,10 @@ var stripConfig5 = (ctx) => {
|
|
|
3690
3438
|
}
|
|
3691
3439
|
return changed;
|
|
3692
3440
|
};
|
|
3693
|
-
var
|
|
3441
|
+
var result6 = (ctx) => {
|
|
3694
3442
|
const modelsData = loadJson2(modelsPath(ctx));
|
|
3695
3443
|
const authData = loadJson2(authPath(ctx));
|
|
3696
|
-
const settingsData = loadJson2(
|
|
3444
|
+
const settingsData = loadJson2(settingsPath3(ctx));
|
|
3697
3445
|
const providers = modelsData.providers;
|
|
3698
3446
|
const provider2 = providers?.[PROVIDER5];
|
|
3699
3447
|
const hasProvider = provider2?.baseUrl === `${BASE_URL}/v1` && provider2?.api === "openai-completions";
|
|
@@ -3711,11 +3459,11 @@ var result7 = (ctx) => {
|
|
|
3711
3459
|
};
|
|
3712
3460
|
var configurePi = (ctx, settings) => {
|
|
3713
3461
|
applyWithSnapshot(ctx, ID8, files6(ctx), () => writeConfig5(ctx, settings));
|
|
3714
|
-
return
|
|
3462
|
+
return result6(ctx);
|
|
3715
3463
|
};
|
|
3716
3464
|
var disablePi = (ctx) => {
|
|
3717
3465
|
const outcome = restoreOrStrip(ctx, ID8, files6(ctx), () => stripConfig5(ctx));
|
|
3718
|
-
return { ...
|
|
3466
|
+
return { ...result6(ctx), configured: false, outcome };
|
|
3719
3467
|
};
|
|
3720
3468
|
var pi = {
|
|
3721
3469
|
id: ID8,
|
|
@@ -3737,7 +3485,7 @@ var pi = {
|
|
|
3737
3485
|
return configurePi(ctx, { apiKey, model, models: models2 });
|
|
3738
3486
|
},
|
|
3739
3487
|
off: disablePi,
|
|
3740
|
-
status:
|
|
3488
|
+
status: result6
|
|
3741
3489
|
};
|
|
3742
3490
|
|
|
3743
3491
|
// src/harnesses/prime.ts
|
|
@@ -3754,12 +3502,12 @@ var primeAgentDir = (ctx) => {
|
|
|
3754
3502
|
};
|
|
3755
3503
|
var modelsPath2 = (ctx) => join12(primeAgentDir(ctx), "models.json");
|
|
3756
3504
|
var authPath2 = (ctx) => join12(primeAgentDir(ctx), "auth.json");
|
|
3757
|
-
var
|
|
3505
|
+
var settingsPath4 = (ctx) => join12(primeAgentDir(ctx), "settings.json");
|
|
3758
3506
|
var skillPath3 = (ctx) => join12(primeAgentDir(ctx), "skills", "polli", "SKILL.md");
|
|
3759
3507
|
var files7 = (ctx) => [
|
|
3760
3508
|
modelsPath2(ctx),
|
|
3761
3509
|
authPath2(ctx),
|
|
3762
|
-
|
|
3510
|
+
settingsPath4(ctx),
|
|
3763
3511
|
skillPath3(ctx)
|
|
3764
3512
|
];
|
|
3765
3513
|
var loadJson3 = (path) => {
|
|
@@ -3817,10 +3565,10 @@ var writeConfig6 = (ctx, models2, apiKey, model) => {
|
|
|
3817
3565
|
doc.providers = providers;
|
|
3818
3566
|
saveJson3(modelsPath2(ctx), doc);
|
|
3819
3567
|
writeAuth(ctx, apiKey);
|
|
3820
|
-
const settings = loadJson3(
|
|
3568
|
+
const settings = loadJson3(settingsPath4(ctx));
|
|
3821
3569
|
settings.defaultProvider = PROVIDER6;
|
|
3822
3570
|
settings.defaultModel = model;
|
|
3823
|
-
saveJson3(
|
|
3571
|
+
saveJson3(settingsPath4(ctx), settings);
|
|
3824
3572
|
if (readTextIfExists(skillPath3(ctx)) === null) {
|
|
3825
3573
|
writeTextAtomic(skillPath3(ctx), SKILL_default, 384);
|
|
3826
3574
|
}
|
|
@@ -3835,11 +3583,11 @@ var stripConfig6 = (ctx) => {
|
|
|
3835
3583
|
changed = true;
|
|
3836
3584
|
}
|
|
3837
3585
|
changed = deleteAuth(ctx) || changed;
|
|
3838
|
-
const settings = loadJson3(
|
|
3586
|
+
const settings = loadJson3(settingsPath4(ctx));
|
|
3839
3587
|
if (settings && settings.defaultProvider === PROVIDER6) {
|
|
3840
3588
|
delete settings.defaultProvider;
|
|
3841
3589
|
delete settings.defaultModel;
|
|
3842
|
-
saveJson3(
|
|
3590
|
+
saveJson3(settingsPath4(ctx), settings);
|
|
3843
3591
|
changed = true;
|
|
3844
3592
|
}
|
|
3845
3593
|
if (readTextIfExists(skillPath3(ctx)) === SKILL_default) {
|
|
@@ -3848,10 +3596,10 @@ var stripConfig6 = (ctx) => {
|
|
|
3848
3596
|
}
|
|
3849
3597
|
return changed;
|
|
3850
3598
|
};
|
|
3851
|
-
var
|
|
3599
|
+
var result7 = (ctx) => {
|
|
3852
3600
|
const doc = loadJson3(modelsPath2(ctx));
|
|
3853
3601
|
const provider2 = doc?.providers?.[PROVIDER6];
|
|
3854
|
-
const settings = loadJson3(
|
|
3602
|
+
const settings = loadJson3(settingsPath4(ctx));
|
|
3855
3603
|
const model = settings?.defaultProvider === PROVIDER6 ? settings.defaultModel : void 0;
|
|
3856
3604
|
return {
|
|
3857
3605
|
harness: ID9,
|
|
@@ -3868,11 +3616,11 @@ var configurePrime = (ctx, models2, apiKey, model) => {
|
|
|
3868
3616
|
files7(ctx),
|
|
3869
3617
|
() => writeConfig6(ctx, models2, apiKey, model)
|
|
3870
3618
|
);
|
|
3871
|
-
return
|
|
3619
|
+
return result7(ctx);
|
|
3872
3620
|
};
|
|
3873
3621
|
var disablePrime = (ctx) => {
|
|
3874
3622
|
const outcome = restoreOrStrip(ctx, ID9, files7(ctx), () => stripConfig6(ctx));
|
|
3875
|
-
return { ...
|
|
3623
|
+
return { ...result7(ctx), configured: false, outcome };
|
|
3876
3624
|
};
|
|
3877
3625
|
var prime = {
|
|
3878
3626
|
id: ID9,
|
|
@@ -3894,7 +3642,7 @@ var prime = {
|
|
|
3894
3642
|
return configurePrime(ctx, models2, apiKey, model);
|
|
3895
3643
|
},
|
|
3896
3644
|
off: disablePrime,
|
|
3897
|
-
status:
|
|
3645
|
+
status: result7
|
|
3898
3646
|
};
|
|
3899
3647
|
|
|
3900
3648
|
// src/harnesses/tgpt.ts
|
|
@@ -3941,7 +3689,7 @@ var stripConfig7 = (ctx) => {
|
|
|
3941
3689
|
writeTextAtomic(configPath3(ctx), filtered.join("\n"), 384);
|
|
3942
3690
|
return true;
|
|
3943
3691
|
};
|
|
3944
|
-
var
|
|
3692
|
+
var result8 = (ctx) => {
|
|
3945
3693
|
const config = readConfig2(ctx);
|
|
3946
3694
|
const model = config.POLLINATIONS_MODEL || void 0;
|
|
3947
3695
|
return {
|
|
@@ -3959,11 +3707,11 @@ var configureTgpt = (ctx, apiKey, model = DEFAULT_MODEL9) => {
|
|
|
3959
3707
|
files8(ctx),
|
|
3960
3708
|
() => writeConfig7(ctx, apiKey, model)
|
|
3961
3709
|
);
|
|
3962
|
-
return
|
|
3710
|
+
return result8(ctx);
|
|
3963
3711
|
};
|
|
3964
3712
|
var disableTgpt = (ctx) => {
|
|
3965
3713
|
const outcome = restoreOrStrip(ctx, ID10, files8(ctx), () => stripConfig7(ctx));
|
|
3966
|
-
return { ...
|
|
3714
|
+
return { ...result8(ctx), configured: false, outcome };
|
|
3967
3715
|
};
|
|
3968
3716
|
var tgpt = {
|
|
3969
3717
|
id: ID10,
|
|
@@ -3984,7 +3732,7 @@ var tgpt = {
|
|
|
3984
3732
|
return configureTgpt(ctx, apiKey, options.model ?? DEFAULT_MODEL9);
|
|
3985
3733
|
},
|
|
3986
3734
|
off: disableTgpt,
|
|
3987
|
-
status:
|
|
3735
|
+
status: result8
|
|
3988
3736
|
};
|
|
3989
3737
|
|
|
3990
3738
|
// src/harnesses/index.ts
|
|
@@ -4012,26 +3760,26 @@ var OFF_MESSAGES = {
|
|
|
4012
3760
|
};
|
|
4013
3761
|
var runOn = async (harness, options) => {
|
|
4014
3762
|
try {
|
|
4015
|
-
const
|
|
3763
|
+
const result9 = await harness.on(context(), options);
|
|
4016
3764
|
await gen("/account/polli/harness-on", {
|
|
4017
3765
|
method: "POST",
|
|
4018
3766
|
body: { harness: harness.id }
|
|
4019
3767
|
}).catch(() => void 0);
|
|
4020
|
-
const model =
|
|
3768
|
+
const model = result9.model ? ` (model: ${result9.model})` : "";
|
|
4021
3769
|
printSuccess(`${harness.label} now uses Pollinations${model}.`);
|
|
4022
3770
|
printInfo(harness.restartHint);
|
|
4023
|
-
printResult(
|
|
3771
|
+
printResult(result9);
|
|
4024
3772
|
} catch (error) {
|
|
4025
3773
|
fail(`Failed to connect ${harness.label}`, error);
|
|
4026
3774
|
}
|
|
4027
3775
|
};
|
|
4028
3776
|
var runOff = async (harness) => {
|
|
4029
3777
|
try {
|
|
4030
|
-
const
|
|
4031
|
-
const outcome =
|
|
3778
|
+
const result9 = await harness.off(context());
|
|
3779
|
+
const outcome = result9.outcome ?? "unchanged";
|
|
4032
3780
|
printSuccess(`${harness.label}: ${OFF_MESSAGES[outcome]}`);
|
|
4033
3781
|
if (outcome !== "unchanged") printInfo(harness.restartHint);
|
|
4034
|
-
printResult(
|
|
3782
|
+
printResult(result9);
|
|
4035
3783
|
} catch (error) {
|
|
4036
3784
|
fail(`Failed to disconnect ${harness.label}`, error);
|
|
4037
3785
|
}
|
|
@@ -4075,6 +3823,17 @@ init_api();
|
|
|
4075
3823
|
init_output();
|
|
4076
3824
|
import chalk6 from "chalk";
|
|
4077
3825
|
import { Command as Command17 } from "commander";
|
|
3826
|
+
var formatPerms = (p) => {
|
|
3827
|
+
if (!p) return "-";
|
|
3828
|
+
const parts = [];
|
|
3829
|
+
for (const [key, v] of Object.entries(p)) {
|
|
3830
|
+
if (!v?.length) continue;
|
|
3831
|
+
parts.push(
|
|
3832
|
+
v.length <= 2 ? `${key}:${v.join("|")}` : `${key}:${v.length}`
|
|
3833
|
+
);
|
|
3834
|
+
}
|
|
3835
|
+
return parts.join(" ") || "-";
|
|
3836
|
+
};
|
|
4078
3837
|
var list2 = new Command17("list").description("List all API keys for your account").option(
|
|
4079
3838
|
"--verbose",
|
|
4080
3839
|
"Show id, created, last_used, enabled columns (use --json for full raw data)"
|
|
@@ -4092,17 +3851,6 @@ var list2 = new Command17("list").description("List all API keys for your accoun
|
|
|
4092
3851
|
printResult(res.data);
|
|
4093
3852
|
return;
|
|
4094
3853
|
}
|
|
4095
|
-
const formatPerms = (p) => {
|
|
4096
|
-
if (!p) return "-";
|
|
4097
|
-
const parts = [];
|
|
4098
|
-
for (const [key2, v] of Object.entries(p)) {
|
|
4099
|
-
if (!v?.length) continue;
|
|
4100
|
-
parts.push(
|
|
4101
|
-
v.length <= 2 ? `${key2}:${v.join("|")}` : `${key2}:${v.length}`
|
|
4102
|
-
);
|
|
4103
|
-
}
|
|
4104
|
-
return parts.join(" ") || "-";
|
|
4105
|
-
};
|
|
4106
3854
|
const check = process.platform === "win32" ? "yes" : "\u2713";
|
|
4107
3855
|
const cross = process.platform === "win32" ? "no" : "\u2717";
|
|
4108
3856
|
const rows = res.data.map((k) => ({
|
|
@@ -4219,7 +3967,7 @@ Examples:
|
|
|
4219
3967
|
type: created.type,
|
|
4220
3968
|
prefix: created.prefix,
|
|
4221
3969
|
expires: created.expiresAt ?? "never",
|
|
4222
|
-
permissions: created.permissions,
|
|
3970
|
+
permissions: getOutputMode() === "human" && created.permissions ? formatPerms(created.permissions) : created.permissions,
|
|
4223
3971
|
budget: created.pollenBudget ?? "unlimited",
|
|
4224
3972
|
redirectUris: created.metadata?.redirectUris,
|
|
4225
3973
|
earnings: created.metadata?.earningsEnabled
|
|
@@ -4272,7 +4020,7 @@ var resolveServers = (catalog, requested) => {
|
|
|
4272
4020
|
};
|
|
4273
4021
|
|
|
4274
4022
|
// src/mcp/clients.ts
|
|
4275
|
-
import { spawnSync as
|
|
4023
|
+
import { spawnSync as spawnSync5 } from "child_process";
|
|
4276
4024
|
import { join as join14 } from "path";
|
|
4277
4025
|
import { isMap as isMap3, parseDocument as parseDocument3 } from "yaml";
|
|
4278
4026
|
init_config();
|
|
@@ -4670,13 +4418,13 @@ var jsonClients = [
|
|
|
4670
4418
|
}
|
|
4671
4419
|
}),
|
|
4672
4420
|
preflight: (ctx) => {
|
|
4673
|
-
const
|
|
4421
|
+
const result9 = spawnSync5("pi", ["--version"], {
|
|
4674
4422
|
env: ctx.env,
|
|
4675
4423
|
encoding: "utf8",
|
|
4676
4424
|
timeout: 5e3
|
|
4677
4425
|
});
|
|
4678
|
-
const version =
|
|
4679
|
-
if (
|
|
4426
|
+
const version = result9.stdout?.trim().match(/^(\d+)\.(\d+)\.\d+/);
|
|
4427
|
+
if (result9.status !== 0 || !version || Number(version[1]) === 0 && Number(version[2]) < 99) {
|
|
4680
4428
|
throw new Error(
|
|
4681
4429
|
"Pi 0.99+ is required for native MCP. Install or upgrade: npm install -g --ignore-scripts @earendil-works/pi-coding-agent@latest"
|
|
4682
4430
|
);
|
|
@@ -4685,14 +4433,14 @@ var jsonClients = [
|
|
|
4685
4433
|
}
|
|
4686
4434
|
];
|
|
4687
4435
|
var run = (command, args) => {
|
|
4688
|
-
const
|
|
4436
|
+
const result9 = spawnSync5(command, args, {
|
|
4689
4437
|
stdio: ["ignore", "pipe", "pipe"],
|
|
4690
4438
|
encoding: "utf-8"
|
|
4691
4439
|
});
|
|
4692
|
-
if (
|
|
4693
|
-
if (
|
|
4440
|
+
if (result9.error) throw result9.error;
|
|
4441
|
+
if (result9.status !== 0) {
|
|
4694
4442
|
throw new Error(
|
|
4695
|
-
`${command} ${args[0]} failed (${
|
|
4443
|
+
`${command} ${args[0]} failed (${result9.status}): ${result9.stderr?.trim() || result9.stdout?.trim() || "no output"}`
|
|
4696
4444
|
);
|
|
4697
4445
|
}
|
|
4698
4446
|
};
|
|
@@ -4765,6 +4513,7 @@ var jsonTableIds = (file, table, ownedOnly = true) => (ctx) => {
|
|
|
4765
4513
|
const config = readJsonObject(file(ctx));
|
|
4766
4514
|
return ownedOnly ? ownedEntryNames(config[table]) : Object.keys(config[table] ?? {});
|
|
4767
4515
|
};
|
|
4516
|
+
var claudeConfigFile = (ctx) => join14(ctx.env.CLAUDE_CONFIG_DIR || ctx.home, ".claude.json");
|
|
4768
4517
|
var codexConfigToml = (ctx) => join14(ctx.env.CODEX_HOME ?? join14(ctx.home, ".codex"), "config.toml");
|
|
4769
4518
|
var codexInstalledIds = (toml, baseUrl = BASE_URL) => {
|
|
4770
4519
|
const ids = [];
|
|
@@ -4814,17 +4563,10 @@ var cliClients = [
|
|
|
4814
4563
|
serverId
|
|
4815
4564
|
],
|
|
4816
4565
|
installHint: "Install it from https://claude.com/claude-code.",
|
|
4817
|
-
installedIds: jsonTableIds(
|
|
4818
|
-
|
|
4819
|
-
"mcpServers"
|
|
4820
|
-
),
|
|
4821
|
-
configuredIds: jsonTableIds(
|
|
4822
|
-
(ctx) => join14(ctx.home, ".claude.json"),
|
|
4823
|
-
"mcpServers",
|
|
4824
|
-
false
|
|
4825
|
-
),
|
|
4566
|
+
installedIds: jsonTableIds(claudeConfigFile, "mcpServers"),
|
|
4567
|
+
configuredIds: jsonTableIds(claudeConfigFile, "mcpServers", false),
|
|
4826
4568
|
recoverKey: (ctx) => recoverKeyFromTable(
|
|
4827
|
-
readJsonObject(
|
|
4569
|
+
readJsonObject(claudeConfigFile(ctx)).mcpServers
|
|
4828
4570
|
)
|
|
4829
4571
|
}
|
|
4830
4572
|
}),
|
|
@@ -5030,23 +4772,23 @@ var runInstall = async (client, servers, options) => {
|
|
|
5030
4772
|
},
|
|
5031
4773
|
{ browser: options.browser }
|
|
5032
4774
|
);
|
|
5033
|
-
const
|
|
4775
|
+
const result9 = await client.install(context2(), selected, key);
|
|
5034
4776
|
printSuccess(
|
|
5035
4777
|
`${client.label}: configured ${selected.map((server) => server.id).join(", ")}.`
|
|
5036
4778
|
);
|
|
5037
|
-
for (const note of
|
|
5038
|
-
printResult({ ...
|
|
4779
|
+
for (const note of result9.notes) printInfo(note);
|
|
4780
|
+
printResult({ ...result9 });
|
|
5039
4781
|
} catch (error) {
|
|
5040
4782
|
fail(`Failed to install MCP servers into ${client.label}`, error);
|
|
5041
4783
|
}
|
|
5042
4784
|
};
|
|
5043
4785
|
var runRemove = async (client, servers) => {
|
|
5044
4786
|
try {
|
|
5045
|
-
const
|
|
4787
|
+
const result9 = await client.remove(
|
|
5046
4788
|
context2(),
|
|
5047
4789
|
servers.length ? servers : void 0
|
|
5048
4790
|
);
|
|
5049
|
-
const removed =
|
|
4791
|
+
const removed = result9.removed ?? [];
|
|
5050
4792
|
if (removed.length === 0) {
|
|
5051
4793
|
printInfo(
|
|
5052
4794
|
`${client.label}: no Pollinations-owned MCP entries found; nothing changed.`
|
|
@@ -5056,7 +4798,7 @@ var runRemove = async (client, servers) => {
|
|
|
5056
4798
|
`${client.label}: removed ${removed.join(", ")}. Other MCP entries were left untouched.`
|
|
5057
4799
|
);
|
|
5058
4800
|
}
|
|
5059
|
-
printResult({ ...
|
|
4801
|
+
printResult({ ...result9 });
|
|
5060
4802
|
} catch (error) {
|
|
5061
4803
|
fail(`Failed to remove MCP servers from ${client.label}`, error);
|
|
5062
4804
|
}
|
|
@@ -5679,16 +5421,16 @@ function questStatus(quest) {
|
|
|
5679
5421
|
}
|
|
5680
5422
|
return "open";
|
|
5681
5423
|
}
|
|
5682
|
-
function colorStatus(
|
|
5683
|
-
switch (
|
|
5424
|
+
function colorStatus(status4) {
|
|
5425
|
+
switch (status4) {
|
|
5684
5426
|
case "claimable":
|
|
5685
|
-
return chalk9.green(
|
|
5427
|
+
return chalk9.green(status4);
|
|
5686
5428
|
case "claimed":
|
|
5687
|
-
return chalk9.cyan(
|
|
5429
|
+
return chalk9.cyan(status4);
|
|
5688
5430
|
case "coming":
|
|
5689
|
-
return chalk9.dim(
|
|
5431
|
+
return chalk9.dim(status4);
|
|
5690
5432
|
default:
|
|
5691
|
-
return
|
|
5433
|
+
return status4;
|
|
5692
5434
|
}
|
|
5693
5435
|
}
|
|
5694
5436
|
function rewardLabel(quest) {
|
|
@@ -6110,7 +5852,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6110
5852
|
|
|
6111
5853
|
// src/commands/update.ts
|
|
6112
5854
|
init_output();
|
|
6113
|
-
import { execSync, spawnSync as
|
|
5855
|
+
import { execSync, spawnSync as spawnSync6 } from "child_process";
|
|
6114
5856
|
import { existsSync as existsSync4, readFileSync as readFileSync8 } from "fs";
|
|
6115
5857
|
import { dirname as dirname2, join as join16, resolve as resolve2, sep } from "path";
|
|
6116
5858
|
import { fileURLToPath } from "url";
|
|
@@ -6191,7 +5933,7 @@ var updateCommand = new Command23("update").description(
|
|
|
6191
5933
|
printInfo(
|
|
6192
5934
|
`Updating ${PACKAGE_NAME} ${currentVersion} \u2192 ${latest}...`
|
|
6193
5935
|
);
|
|
6194
|
-
const install =
|
|
5936
|
+
const install = spawnSync6(
|
|
6195
5937
|
"npm",
|
|
6196
5938
|
["install", "-g", `${PACKAGE_NAME}@latest`],
|
|
6197
5939
|
{
|
|
@@ -6347,7 +6089,7 @@ var usageCommand = new Command25("usage").description(
|
|
|
6347
6089
|
"Filter by model id (repeatable)",
|
|
6348
6090
|
collect,
|
|
6349
6091
|
[]
|
|
6350
|
-
).option("--days <n>", "Rolling window in days
|
|
6092
|
+
).option("--days <n>", "Rolling window in days").option("--csv", "Print the raw CSV export").addHelpText(
|
|
6351
6093
|
"after",
|
|
6352
6094
|
chalk10.dim(
|
|
6353
6095
|
'\nKey filter:\n --key <name-or-id> Filter by API key name or id (repeatable, resolves\n names via /account/keys). Placed after "usage" it filters;\n before "usage" it stays the global auth override.'
|
|
@@ -6391,17 +6133,6 @@ var usageCommand = new Command25("usage").description(
|
|
|
6391
6133
|
throw new ExitSignal(1);
|
|
6392
6134
|
}
|
|
6393
6135
|
}
|
|
6394
|
-
let days;
|
|
6395
|
-
if (opts.days !== void 0) {
|
|
6396
|
-
try {
|
|
6397
|
-
days = parseDaysWindow(opts.days);
|
|
6398
|
-
} catch (err) {
|
|
6399
|
-
printError(
|
|
6400
|
-
err instanceof Error ? err.message : "Invalid --days value"
|
|
6401
|
-
);
|
|
6402
|
-
throw new ExitSignal(1);
|
|
6403
|
-
}
|
|
6404
|
-
}
|
|
6405
6136
|
let keyIds = [];
|
|
6406
6137
|
if (filterKeys.length > 0) {
|
|
6407
6138
|
const ids = filterKeys.filter(isKeyId);
|
|
@@ -6423,7 +6154,7 @@ var usageCommand = new Command25("usage").description(
|
|
|
6423
6154
|
}
|
|
6424
6155
|
}
|
|
6425
6156
|
const params = new URLSearchParams();
|
|
6426
|
-
if (days !== void 0) params.set("days",
|
|
6157
|
+
if (opts.days !== void 0) params.set("days", opts.days);
|
|
6427
6158
|
try {
|
|
6428
6159
|
if (opts.daily) {
|
|
6429
6160
|
if (opts.csv) {
|
|
@@ -6451,12 +6182,7 @@ var usageCommand = new Command25("usage").description(
|
|
|
6451
6182
|
);
|
|
6452
6183
|
return;
|
|
6453
6184
|
}
|
|
6454
|
-
|
|
6455
|
-
if (!Number.isInteger(limit) || limit < 1) {
|
|
6456
|
-
printError("--limit must be a positive integer");
|
|
6457
|
-
throw new ExitSignal(1);
|
|
6458
|
-
}
|
|
6459
|
-
params.set("limit", String(limit));
|
|
6185
|
+
params.set("limit", opts.limit);
|
|
6460
6186
|
if (keyIds.length > 0) params.set("api_key_ids", keyIds.join(","));
|
|
6461
6187
|
if (models2.length > 0) params.set("models", models2.join(","));
|
|
6462
6188
|
if (opts.csv) params.set("format", "csv");
|
|
@@ -6479,10 +6205,7 @@ var usageCommand = new Command25("usage").description(
|
|
|
6479
6205
|
}))
|
|
6480
6206
|
);
|
|
6481
6207
|
} catch (err) {
|
|
6482
|
-
|
|
6483
|
-
`Failed to fetch usage: ${err instanceof Error ? err.message : "unknown"}`
|
|
6484
|
-
);
|
|
6485
|
-
throw new ExitSignal(1);
|
|
6208
|
+
fail("Failed to fetch usage", err);
|
|
6486
6209
|
}
|
|
6487
6210
|
});
|
|
6488
6211
|
|