@pollinations/cli 0.1.57 → 0.1.59

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 CHANGED
@@ -190,19 +190,20 @@ See [Coding Harnesses](https://github.com/pollinations/pollinations/blob/main/CO
190
190
 
191
191
  ## Sandboxes
192
192
 
193
- Linux VMs from E2B, paid from your wallet (alpha).
193
+ Linux VMs on E2B or Azure, paid from your wallet (alpha).
194
194
 
195
195
  ```bash
196
196
  polli sandbox create # prints the id and sets up ssh
197
197
  polli sandbox create --timeout 0 # runs until you pause or kill it
198
198
  polli sandbox create pollinations-large # 4 vCPU, 8 GB
199
+ polli sandbox create pollinations-azure # on Azure; pollinations-azure-large and pollinations-azure-xl (8 vCPU, 16 GB) too
199
200
  ssh <id>.polli # scp and rsync work too
200
201
  polli sandbox timeout <id> 14400 # keep it running 4 hours without ssh
201
202
  polli sandbox pause <id>
202
203
  polli sandbox kill <id>
203
204
  ```
204
205
 
205
- The default template, and `pollinations-large`, come logged in with the coding harnesses installed; the first interactive `ssh` connects them. See [Sandboxes](https://gen.pollinations.ai/docs#tag/sandboxes) for cost, limits, and using E2B's own CLI and SDKs.
206
+ The `pollinations` templates, on E2B or Azure, come logged in with the coding harnesses installed; the first interactive `ssh` connects them. See [Sandboxes](https://gen.pollinations.ai/docs#tag/sandboxes) for cost, limits, and using E2B's own CLI and SDKs.
206
207
 
207
208
  ## Links
208
209
 
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.57",
17
+ version: "0.1.59",
18
18
  description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
19
19
  type: "module",
20
20
  bin: {
@@ -5907,8 +5907,9 @@ import { join as join15 } from "path";
5907
5907
 
5908
5908
  // src/commands/sandbox/bootstrap.sh?raw
5909
5909
  var bootstrap_default = `#!/bin/bash
5910
- # Runs as root in an E2B sandbox on every \`ssh <id>.polli\`; each step is
5911
- # idempotent. E2B sandboxes run systemd, which runs sshd once installed. E2B's
5910
+ # Runs as root in a sandbox on every \`ssh <id>.polli\`; each step is
5911
+ # idempotent. E2B sandboxes run systemd, which runs sshd once installed;
5912
+ # Azure's run none, so sshd runs on its own there. E2B's
5912
5913
  # base image sets \`PermitEmptyPasswords yes\` and \`user\` has no password, so
5913
5914
  # sshd would accept a login without a key; the settings prepended below win
5914
5915
  # because sshd uses the first value it reads.
@@ -5926,25 +5927,37 @@ if [ ! -x /usr/local/bin/websocat ]; then
5926
5927
  fi
5927
5928
  mkdir -p /run/sshd
5928
5929
  ssh-keygen -A >/dev/null
5930
+ # \`start\` leaves a running sshd as it is; \`restart\` makes it reread its config.
5931
+ sshd_service() {
5932
+ if [ -d /run/systemd/system ]; then
5933
+ systemctl "$1" ssh
5934
+ elif [ -s /run/sshd.pid ] && kill -0 "$(cat /run/sshd.pid)" 2>/dev/null; then
5935
+ [ "$1" = start ] || kill -HUP "$(cat /run/sshd.pid)"
5936
+ else
5937
+ /usr/sbin/sshd
5938
+ fi
5939
+ }
5929
5940
  key_only() {
5930
5941
  test "$(sshd -T | grep -cxE '(permitemptypasswords|passwordauthentication|kbdinteractiveauthentication|permitrootlogin) no')" = 4
5931
5942
  }
5932
5943
  if key_only; then
5933
- systemctl start ssh
5944
+ sshd_service start
5934
5945
  else
5935
5946
  printf 'PermitEmptyPasswords no\\nPasswordAuthentication no\\nKbdInteractiveAuthentication no\\nPermitRootLogin no\\n\\n' |
5936
5947
  cat - /etc/ssh/sshd_config > /tmp/sshd_config
5937
5948
  cat /tmp/sshd_config > /etc/ssh/sshd_config
5938
5949
  key_only
5939
- systemctl restart ssh
5950
+ sshd_service restart
5940
5951
  fi
5941
5952
  install -d -m 700 -o user -g user /home/user/.ssh
5942
5953
  touch /home/user/.ssh/authorized_keys
5943
5954
  grep -qxF "$POLLI_SSH_KEY" /home/user/.ssh/authorized_keys || printf '%s\\n' "$POLLI_SSH_KEY" >> /home/user/.ssh/authorized_keys
5944
5955
  chown user:user /home/user/.ssh/authorized_keys
5945
5956
  chmod 600 /home/user/.ssh/authorized_keys
5957
+ # On one CPU: after a resume, an Azure box's CPUs disagree on the time by
5958
+ # milliseconds, and websocat's timers abort when the time runs backwards.
5946
5959
  if ! { [ -s /run/polli-ws.pid ] && kill -0 "$(cat /run/polli-ws.pid)" 2>/dev/null; }; then
5947
- setsid nohup sh -c 'while :; do websocat -b -E "ws-l:0.0.0.0:$POLLI_SSH_PORT" tcp:127.0.0.1:22; sleep 1; done' >/dev/null 2>&1 </dev/null &
5960
+ setsid nohup sh -c 'while :; do taskset -c 0 websocat -b -E "ws-l:0.0.0.0:$POLLI_SSH_PORT" tcp:127.0.0.1:22; sleep 1; done' >/dev/null 2>&1 </dev/null &
5948
5961
  echo $! > /run/polli-ws.pid
5949
5962
  fi
5950
5963
  # Templates with herdr, like \`pollinations\`, get its server, so agents in its
@@ -5987,7 +6000,7 @@ function stderrToTerminal() {
5987
6000
  return true;
5988
6001
  });
5989
6002
  }
5990
- var sandboxUrl = (s, port, scheme = "https") => `${scheme}://${port}-${s.sandboxID}.${s.domain || "e2b.app"}`;
6003
+ var sandboxUrl = (s, port, scheme = "https") => s.domain?.endsWith(".adcproxy.io") ? `${scheme}://${s.sandboxID}--${port}.${s.domain}` : `${scheme}://${port}-${s.sandboxID}.${s.domain || "e2b.app"}`;
5991
6004
  async function runAsRoot(s, script, envs) {
5992
6005
  const request2 = Buffer.from(
5993
6006
  JSON.stringify({
@@ -6031,7 +6044,7 @@ async function runAsRoot(s, script, envs) {
6031
6044
  }
6032
6045
  async function proxy(host) {
6033
6046
  const id = host.replace(/\.polli$/, "");
6034
- if (!/^[a-z0-9]+$/.test(id)) {
6047
+ if (!/^[a-z0-9-]+$/.test(id)) {
6035
6048
  fail(`Expected <sandbox-id>.polli, got "${host}"`);
6036
6049
  }
6037
6050
  if (typeof WebSocket === "undefined")
@@ -6146,7 +6159,7 @@ var logLine = (entry) => [
6146
6159
  var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed to your Pollinations account (alpha)").addCommand(
6147
6160
  new Command22("create").description("Start a sandbox you can ssh into").argument(
6148
6161
  "[template]",
6149
- "E2B template; pollinations-large has 4 vCPU and 8 GB",
6162
+ "pollinations-large has 4 vCPU and 8 GB; pollinations-azure, pollinations-azure-large and pollinations-azure-xl (8 vCPU, 16 GB) run on Azure",
6150
6163
  "pollinations"
6151
6164
  ).option(
6152
6165
  "--timeout <seconds>",
@@ -6326,6 +6339,10 @@ function collectSiteFiles(dir) {
6326
6339
  walk(dir);
6327
6340
  return files9;
6328
6341
  }
6342
+ function assetType(file) {
6343
+ const type = mimeTypeFor(file);
6344
+ return type === "application/octet-stream" ? "application/null" : type;
6345
+ }
6329
6346
  async function uploadBuckets(session, files9) {
6330
6347
  const byHash = new Map(files9.map((file) => [file.hash, file]));
6331
6348
  let jwt = session.jwt;
@@ -6338,7 +6355,7 @@ async function uploadBuckets(session, files9) {
6338
6355
  form.append(
6339
6356
  hash,
6340
6357
  new Blob([readFileSync8(file.file).toString("base64")], {
6341
- type: mimeTypeFor(file.file)
6358
+ type: assetType(file.file)
6342
6359
  }),
6343
6360
  hash
6344
6361
  );