@lesscap/baton-cli 0.4.0 → 0.4.1

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/baton.mjs CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from 'node:module';
3
+ const require = createRequire(import.meta.url);
2
4
  var __create = Object.create;
3
5
  var __defProp = Object.defineProperty;
4
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesscap/baton-cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "baton CLI — register/run a worker, manage projects/requirements/tasks/sessions",
@@ -8,7 +8,8 @@
8
8
  "baton": "dist/baton.mjs"
9
9
  },
10
10
  "files": [
11
- "dist"
11
+ "dist",
12
+ "scripts"
12
13
  ],
13
14
  "devDependencies": {
14
15
  "@types/node": "^25.9.1",
@@ -27,7 +28,8 @@
27
28
  },
28
29
  "scripts": {
29
30
  "baton": "tsx src/index.ts",
30
- "build": "esbuild src/index.ts --bundle --platform=node --format=esm --packages=bundle --external:@anthropic-ai/claude-agent-sdk --external:node-pty --banner:js=\"#!/usr/bin/env node\" --outfile=dist/baton.mjs && chmod +x dist/baton.mjs",
31
+ "build": "node build.mjs && chmod +x dist/baton.mjs",
32
+ "postinstall": "node scripts/postinstall.mjs",
31
33
  "typecheck": "tsc --noEmit -p tsconfig.json",
32
34
  "test": "tsx --test 'src/**/*.test.ts'"
33
35
  }
@@ -0,0 +1,21 @@
1
+ // Ensure node-pty's native addon actually loads after install. Its prebuilt
2
+ // binaries don't cover every Node version (24/26 ship none, or a partial one that
3
+ // installs without a working spawn-helper), so the bundle would crash the first
4
+ // time a worker opens a terminal. If it won't load, rebuild it from source (needs
5
+ // python3 + a C++ toolchain). Non-fatal: a worker that can't build it simply has
6
+ // interactive terminals disabled, while the headless relay keeps working.
7
+ import { execSync } from 'node:child_process'
8
+ import { createRequire } from 'node:module'
9
+
10
+ const require = createRequire(import.meta.url)
11
+ try {
12
+ require('node-pty')
13
+ } catch {
14
+ try {
15
+ execSync('npm rebuild node-pty --build-from-source', { stdio: 'inherit' })
16
+ } catch {
17
+ console.error(
18
+ '[baton-cli] node-pty native build failed — interactive terminals disabled (install python3 + a C++ toolchain to enable them)',
19
+ )
20
+ }
21
+ }