@nicknisi/pi-relay 0.3.2 → 0.3.4

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
@@ -101,6 +101,7 @@ The directory is created `0700` and every file `0600` — other users on the mac
101
101
  ## Caveats
102
102
 
103
103
  - **Mailbox semantics support Linux and macOS only.** Relay rejects user-controlled symlinks in configured-root components, permits protected root-owned system aliases such as macOS `/var`, pins root, mailbox, and durable-claim descriptors for each operation, and uses descriptor-relative `openat`/`renameat`/`unlinkat` calls, atomic renames, descriptor polling for watches, and `0600`/`0700` permission bits. Windows is unsupported.
104
+ - **Bun <= 1.3.14 refused.** Those Bun versions abort the process when koffi's GC finalizer releases an N-API reference ([oven-sh/bun#39263](https://github.com/oven-sh/bun/issues/39263), fixed upstream after 1.3.14), so relay fails load with a clear error on them instead. Node.js and newer Bun load normally.
104
105
  - **One machine.** Delivery is a file landing in a directory; two sessions reach each other exactly when they share a filesystem. A container and its host cannot.
105
106
  - **Presence is heartbeat-accurate**, not instantaneous (within ~45s).
106
107
  - Delivery injects with `deliverAs: "steer"` (lands between tool calls) and `triggerTurn: true` (wakes an idle session).
@@ -1,11 +1,22 @@
1
1
  /** Descriptor-relative, symlink-safe filesystem operations for the relay store. Pi-free. */
2
2
  import { randomBytes } from 'node:crypto';
3
3
  import * as fs from 'node:fs';
4
+ import { createRequire } from 'node:module';
4
5
  import * as path from 'node:path';
5
- import koffi from 'koffi';
6
6
  if (process.platform !== 'darwin' && process.platform !== 'linux') {
7
7
  throw new Error(`Relay filesystem operations are unsupported on ${process.platform}`);
8
8
  }
9
+ // Bun <= 1.3.14 aborts the whole process when koffi's GC finalizer releases
10
+ // an N-API reference (oven-sh/bun#39263, fixed after 1.3.14). Fail extension
11
+ // load cleanly on those versions instead.
12
+ const bunVersion = globalThis.Bun?.version;
13
+ if (bunVersion !== undefined) {
14
+ const [major = 0, minor = 0, patch = 0] = bunVersion.split('-')[0].split('.').map(Number);
15
+ if (major < 1 || (major === 1 && (minor < 3 || (minor === 3 && patch <= 14)))) {
16
+ throw new Error(`Relay requires Node.js or Bun > 1.3.14: koffi crashes Bun ${bunVersion} (oven-sh/bun#39263)`);
17
+ }
18
+ }
19
+ const koffi = createRequire(import.meta.url)('koffi');
9
20
  const NOFOLLOW = fs.constants.O_NOFOLLOW ?? 0;
10
21
  const DIRECTORY = fs.constants.O_DIRECTORY ?? 0;
11
22
  const CLOEXEC = process.platform === 'darwin' ? 0x01000000 : 0x00080000;
package/filesystem.ts CHANGED
@@ -1,13 +1,26 @@
1
1
  /** Descriptor-relative, symlink-safe filesystem operations for the relay store. Pi-free. */
2
2
  import { randomBytes } from 'node:crypto';
3
3
  import * as fs from 'node:fs';
4
+ import { createRequire } from 'node:module';
4
5
  import * as path from 'node:path';
5
- import koffi from 'koffi';
6
6
 
7
7
  if (process.platform !== 'darwin' && process.platform !== 'linux') {
8
8
  throw new Error(`Relay filesystem operations are unsupported on ${process.platform}`);
9
9
  }
10
10
 
11
+ // Bun <= 1.3.14 aborts the whole process when koffi's GC finalizer releases
12
+ // an N-API reference (oven-sh/bun#39263, fixed after 1.3.14). Fail extension
13
+ // load cleanly on those versions instead.
14
+ const bunVersion = (globalThis as { Bun?: { version?: string } }).Bun?.version;
15
+ if (bunVersion !== undefined) {
16
+ const [major = 0, minor = 0, patch = 0] = bunVersion.split('-')[0]!.split('.').map(Number);
17
+ if (major < 1 || (major === 1 && (minor < 3 || (minor === 3 && patch <= 14)))) {
18
+ throw new Error(`Relay requires Node.js or Bun > 1.3.14: koffi crashes Bun ${bunVersion} (oven-sh/bun#39263)`);
19
+ }
20
+ }
21
+
22
+ const koffi = createRequire(import.meta.url)('koffi') as typeof import('koffi');
23
+
11
24
  const NOFOLLOW = fs.constants.O_NOFOLLOW ?? 0;
12
25
  const DIRECTORY = fs.constants.O_DIRECTORY ?? 0;
13
26
  const CLOEXEC = process.platform === 'darwin' ? 0x01000000 : 0x00080000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nicknisi/pi-relay",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Brokerless session-to-session messaging for pi — a file mailbox that outlives the process, with ask/reply coordination. Formerly @nicknisi/pi-intercom.",
5
5
  "keywords": [
6
6
  "pi",