@pollinations/cli 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +29 -12
- 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.26",
|
|
18
18
|
description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
|
|
19
19
|
type: "module",
|
|
20
20
|
bin: {
|
|
@@ -1163,10 +1163,7 @@ async function* streamSSE(response, onEvent) {
|
|
|
1163
1163
|
|
|
1164
1164
|
// src/commands/gen/chat.ts
|
|
1165
1165
|
function createChatCommand() {
|
|
1166
|
-
return new Command6("chat").description("Interactive multi-turn chat session").option(
|
|
1167
|
-
"--model <model>",
|
|
1168
|
-
"Text model (default: from config or 'openai')"
|
|
1169
|
-
).option("--system <msg>", "System message").option("--temperature <n>", "Randomness (0-2)").option("--max-tokens <n>", "Maximum output tokens").option("--save <path>", "Save conversation transcript on exit").action(async (opts) => {
|
|
1166
|
+
return new Command6("chat").description("Interactive multi-turn chat session").option("--model <model>", "Text model (default: API default)").option("--system <msg>", "System message").option("--temperature <n>", "Randomness (0-2)").option("--max-tokens <n>", "Maximum output tokens").option("--save <path>", "Save conversation transcript on exit").action(async (opts) => {
|
|
1170
1167
|
const temperature = opts.temperature === void 0 ? void 0 : numberOption("--temperature", opts.temperature, 0, 2);
|
|
1171
1168
|
const maxTokens = opts.maxTokens === void 0 ? void 0 : numberOption(
|
|
1172
1169
|
"--max-tokens",
|
|
@@ -1186,7 +1183,7 @@ function createChatCommand() {
|
|
|
1186
1183
|
process.stderr.write(
|
|
1187
1184
|
chalk4.green(
|
|
1188
1185
|
`
|
|
1189
|
-
Chat session started (model: ${opts.model})
|
|
1186
|
+
Chat session started (model: ${opts.model ?? "API default"})
|
|
1190
1187
|
`
|
|
1191
1188
|
) + chalk4.dim(
|
|
1192
1189
|
"Type /exit to quit, /clear to reset, /save <path> to save\n\n"
|
|
@@ -1242,7 +1239,10 @@ Chat session started (model: ${opts.model})
|
|
|
1242
1239
|
}
|
|
1243
1240
|
process.stderr.write(`${chalk4.yellow("ai")} > `);
|
|
1244
1241
|
let content = "";
|
|
1245
|
-
for await (const chunk of streamSSE(res)
|
|
1242
|
+
for await (const chunk of streamSSE(res, (event) => {
|
|
1243
|
+
if (typeof event.usage?.total_tokens === "number")
|
|
1244
|
+
totalTokens += event.usage.total_tokens;
|
|
1245
|
+
})) {
|
|
1246
1246
|
content += chunk;
|
|
1247
1247
|
process.stderr.write(chunk);
|
|
1248
1248
|
}
|
|
@@ -1259,7 +1259,15 @@ Chat session started (model: ${opts.model})
|
|
|
1259
1259
|
const transcript = messages.filter((m) => m.role !== "system").map(
|
|
1260
1260
|
(m) => `${m.role === "user" ? "You" : "AI"}: ${m.content}`
|
|
1261
1261
|
).join("\n\n");
|
|
1262
|
-
|
|
1262
|
+
try {
|
|
1263
|
+
writeFileSync3(path, transcript, "utf-8");
|
|
1264
|
+
} catch (err) {
|
|
1265
|
+
printError(
|
|
1266
|
+
err instanceof Error ? err.message : "Failed to save transcript"
|
|
1267
|
+
);
|
|
1268
|
+
if (closed) process.exitCode = 1;
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1263
1271
|
if (!isJson) {
|
|
1264
1272
|
process.stderr.write(chalk4.green(`Saved to ${path}
|
|
1265
1273
|
`));
|
|
@@ -4195,7 +4203,7 @@ var yamlClient = (adapter) => {
|
|
|
4195
4203
|
const doc = parseDocument3(readTextIfExists(path) ?? "");
|
|
4196
4204
|
if (doc.errors.length) throw doc.errors[0];
|
|
4197
4205
|
if (doc.contents === null) doc.contents = doc.createNode({});
|
|
4198
|
-
if (!isMap3(doc.contents) || doc.
|
|
4206
|
+
if (!isMap3(doc.contents) || doc.get(table) != null && !isMap3(doc.get(table))) {
|
|
4199
4207
|
throw new Error(
|
|
4200
4208
|
`${path}: expected YAML mappings for config and ${table}`
|
|
4201
4209
|
);
|
|
@@ -4206,6 +4214,7 @@ var yamlClient = (adapter) => {
|
|
|
4206
4214
|
if (JSON.stringify(entries) === JSON.stringify(before)) {
|
|
4207
4215
|
return { installed: ownedEntryNames(entries), removed };
|
|
4208
4216
|
}
|
|
4217
|
+
if (doc.get(table) == null) doc.set(table, doc.createNode({}));
|
|
4209
4218
|
for (const name of Object.keys(before)) {
|
|
4210
4219
|
if (!(name in entries)) doc.deleteIn([table, name]);
|
|
4211
4220
|
}
|
|
@@ -5700,9 +5709,9 @@ function setupSsh() {
|
|
|
5700
5709
|
"# Written by `polli sandbox ssh-config`.",
|
|
5701
5710
|
"Host *.polli",
|
|
5702
5711
|
" User user",
|
|
5703
|
-
` IdentityFile ${SSH_KEY}`,
|
|
5712
|
+
` IdentityFile "${SSH_KEY}"`,
|
|
5704
5713
|
" IdentitiesOnly yes",
|
|
5705
|
-
` UserKnownHostsFile ${join15(SSH_DIR, "known_hosts")}`,
|
|
5714
|
+
` UserKnownHostsFile "${join15(SSH_DIR, "known_hosts")}"`,
|
|
5706
5715
|
" StrictHostKeyChecking accept-new",
|
|
5707
5716
|
` ProxyCommand ${polli} sandbox proxy %h`,
|
|
5708
5717
|
""
|
|
@@ -5741,7 +5750,15 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
5741
5750
|
requireKey();
|
|
5742
5751
|
try {
|
|
5743
5752
|
const { sandboxID } = await createSandbox(template);
|
|
5744
|
-
|
|
5753
|
+
try {
|
|
5754
|
+
setupSsh();
|
|
5755
|
+
} catch (err) {
|
|
5756
|
+
printResult({ id: sandboxID });
|
|
5757
|
+
fail(
|
|
5758
|
+
`Sandbox ${sandboxID} created, but failed to set up ssh`,
|
|
5759
|
+
err
|
|
5760
|
+
);
|
|
5761
|
+
}
|
|
5745
5762
|
printSuccess(
|
|
5746
5763
|
`Sandbox ${sandboxID} created. It pauses after ${LEASE_SECONDS / 60} minutes without an ssh session.`
|
|
5747
5764
|
);
|