airloom 0.1.17 → 0.1.21

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.
Files changed (2) hide show
  1. package/dist/index.js +38 -14
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -602,7 +602,7 @@ var AblyAdapter = class {
602
602
  import { sha256 as sha2562 } from "@noble/hashes/sha256";
603
603
  import { networkInterfaces } from "node:os";
604
604
  import { fileURLToPath } from "node:url";
605
- import { dirname, resolve as resolve3 } from "node:path";
605
+ import { dirname as dirname2, resolve as resolve3 } from "node:path";
606
606
  import { existsSync as existsSync4 } from "node:fs";
607
607
 
608
608
  // src/server.ts
@@ -1025,9 +1025,25 @@ function getConfigPath() {
1025
1025
  }
1026
1026
 
1027
1027
  // src/terminal.ts
1028
- import { basename, delimiter as delimiter2, isAbsolute as isAbsolute2, join as join3, resolve as resolve2 } from "node:path";
1029
- import { existsSync as existsSync2 } from "node:fs";
1028
+ import { basename, delimiter as delimiter2, dirname, isAbsolute as isAbsolute2, join as join3, resolve as resolve2 } from "node:path";
1029
+ import { chmodSync, existsSync as existsSync2, statSync } from "node:fs";
1030
+ import { createRequire } from "node:module";
1030
1031
  import { spawn as spawn2 } from "node-pty";
1032
+ function fixSpawnHelperPermissions() {
1033
+ try {
1034
+ const require_ = createRequire(import.meta.url);
1035
+ const ptyDir = dirname(require_.resolve("node-pty/package.json"));
1036
+ const helperPath = join3(ptyDir, "prebuilds", `${process.platform}-${process.arch}`, "spawn-helper");
1037
+ if (!existsSync2(helperPath)) return;
1038
+ const mode = statSync(helperPath).mode;
1039
+ if (!(mode & 73)) {
1040
+ chmodSync(helperPath, mode | 493);
1041
+ console.log(`[host] Fixed spawn-helper permissions: ${helperPath}`);
1042
+ }
1043
+ } catch {
1044
+ }
1045
+ }
1046
+ fixSpawnHelperPermissions();
1031
1047
  function resolveExecutable2(command, envPath = process.env.PATH ?? "") {
1032
1048
  if (!command) return null;
1033
1049
  if (isAbsolute2(command) && existsSync2(command)) return command;
@@ -1128,19 +1144,27 @@ var TerminalSession = class {
1128
1144
  start() {
1129
1145
  const command = getDefaultTerminalCommand(this.getLaunchCommand?.());
1130
1146
  const file = resolveExecutable2(command.file) ?? command.file;
1131
- console.log(`[host] PTY spawn: ${file} ${command.args.join(" ")} (${this.cols}x${this.rows})`);
1147
+ const cwd = process.cwd();
1148
+ console.log(`[host] PTY spawn: ${file} ${command.args.join(" ")} (${this.cols}x${this.rows}) node=${process.version}`);
1132
1149
  const env = { ...process.env, TERM: "xterm-256color" };
1150
+ const spawnOpts = { name: "xterm-256color", cols: this.cols, rows: this.rows, cwd, env };
1133
1151
  try {
1134
- this.pty = spawn2(file, command.args, {
1135
- name: "xterm-256color",
1136
- cols: this.cols,
1137
- rows: this.rows,
1138
- cwd: process.cwd(),
1139
- env
1140
- });
1152
+ this.pty = spawn2(file, command.args, spawnOpts);
1141
1153
  } catch (err) {
1142
- console.error("[host] PTY spawn failed:", err.message);
1143
- return;
1154
+ const e = err;
1155
+ console.error(`[host] PTY spawn failed: ${e.message} (code=${e.code ?? "none"}) file=${file} cwd=${cwd}`);
1156
+ if (file !== "/bin/sh") {
1157
+ console.error("[host] Retrying with /bin/sh...");
1158
+ try {
1159
+ this.pty = spawn2("/bin/sh", [], spawnOpts);
1160
+ console.log("[host] PTY fallback to /bin/sh succeeded");
1161
+ } catch (err2) {
1162
+ console.error("[host] PTY fallback also failed:", err2.message);
1163
+ return;
1164
+ }
1165
+ } else {
1166
+ return;
1167
+ }
1144
1168
  }
1145
1169
  this.pty.onData((data) => {
1146
1170
  process.stdout.write(data);
@@ -1795,7 +1819,7 @@ var ABLY_TOKEN_TTL = parseInt(process.env.ABLY_TOKEN_TTL ?? String(24 * 60 * 60
1795
1819
  var HOST_PORT = cliArgs.port ?? parseInt(process.env.HOST_PORT ?? "0", 10);
1796
1820
  var useAbly = !!ABLY_API_KEY;
1797
1821
  var isDefaultKey = useAbly && ABLY_API_KEY === DEFAULT_ABLY_KEY;
1798
- var __dirname = dirname(fileURLToPath(import.meta.url));
1822
+ var __dirname = dirname2(fileURLToPath(import.meta.url));
1799
1823
  function getLanIP() {
1800
1824
  for (const ifaces of Object.values(networkInterfaces())) {
1801
1825
  for (const iface of ifaces ?? []) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "airloom",
3
- "version": "0.1.17",
3
+ "version": "0.1.21",
4
4
  "description": "Run AI on your computer, control it from your phone. E2E encrypted.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,6 +32,7 @@
32
32
  "esbuild": "^0.27.4"
33
33
  },
34
34
  "scripts": {
35
+ "postinstall": "node -e \"process.env.CI||require('child_process').execSync('npm rebuild node-pty',{stdio:'inherit'})\"",
35
36
  "dev": "pnpm build:host-only && pnpm copy-viewer && node dist/index.js",
36
37
  "start": "node dist/index.js",
37
38
  "build": "pnpm --dir ../viewer build && node build.mjs && pnpm copy-viewer",