@pollinations/cli 0.1.25 → 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 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.25",
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
- writeFileSync3(path, transcript, "utf-8");
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
  `));
@@ -5742,7 +5750,15 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
5742
5750
  requireKey();
5743
5751
  try {
5744
5752
  const { sandboxID } = await createSandbox(template);
5745
- setupSsh();
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
+ }
5746
5762
  printSuccess(
5747
5763
  `Sandbox ${sandboxID} created. It pauses after ${LEASE_SECONDS / 60} minutes without an ssh session.`
5748
5764
  );