@lesscap/baton-cli 0.4.0 → 0.4.2

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.2",
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,30 @@
1
+ // Ensure node-pty can actually spawn a pty after install. Its prebuilt binaries
2
+ // are unreliable on newer Node (24/26 ship a partial one whose pty.node loads but
3
+ // whose spawn-helper fails with `posix_spawnp failed`), so a plain require() isn't
4
+ // a real check — spawn a throwaway pty. If that fails, rebuild from source (needs
5
+ // python3 + a C++ toolchain). Non-fatal: a host that can't build it just loses
6
+ // interactive terminals, 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
+
12
+ const works = () => {
13
+ try {
14
+ const pty = require('node-pty')
15
+ pty.spawn(process.platform === 'win32' ? 'cmd.exe' : '/bin/sh', [], { cols: 80, rows: 24 }).kill()
16
+ return true
17
+ } catch {
18
+ return false
19
+ }
20
+ }
21
+
22
+ if (!works()) {
23
+ try {
24
+ execSync('npm rebuild node-pty --build-from-source', { stdio: 'inherit' })
25
+ } catch {
26
+ console.error(
27
+ '[baton-cli] node-pty native build failed — interactive terminals disabled (install python3 + a C++ toolchain to enable them)',
28
+ )
29
+ }
30
+ }