@adhdev/daemon-core 0.8.14 → 0.8.15

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/session-host-core",
3
- "version": "0.8.14",
3
+ "version": "0.8.15",
4
4
  "description": "ADHDev local session host core — session registry, protocol, buffers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.8.14",
3
+ "version": "0.8.15",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,15 +27,7 @@ import {
27
27
  type PtyRuntimeTransport,
28
28
  type PtyTransportFactory,
29
29
  } from './pty-transport.js';
30
- import { sanitizeSpawnEnv, ensureNodePtySpawnHelperPermissions } from './spawn-env.js';
31
-
32
- let pty: any;
33
- try {
34
- pty = require('node-pty');
35
- ensureNodePtySpawnHelperPermissions((msg: string) => LOG.info('CLI', msg));
36
- } catch {
37
- LOG.error('CLI', '[ProviderCliAdapter] node-pty not found. Terminal features disabled.');
38
- }
30
+ import { sanitizeSpawnEnv } from './spawn-env.js';
39
31
 
40
32
  // ─── Types ──────────────────────────────────────────
41
33
 
@@ -1,10 +1,20 @@
1
1
  import * as os from 'os';
2
-
3
- let pty: any;
4
- try {
5
- pty = require('node-pty');
6
- } catch {
7
- pty = null;
2
+ import { ensureNodePtySpawnHelperPermissions } from './spawn-env.js';
3
+
4
+ let cachedPty: any | null | undefined;
5
+
6
+ function loadNodePty(): any {
7
+ if (cachedPty !== undefined) return cachedPty;
8
+ try {
9
+ // Keep node-pty out of processes that delegate PTY ownership elsewhere
10
+ // (for example via session-host on Windows), so native PTY crashes do not
11
+ // take down the daemon just by importing this module.
12
+ cachedPty = require('node-pty');
13
+ ensureNodePtySpawnHelperPermissions();
14
+ } catch {
15
+ cachedPty = null;
16
+ }
17
+ return cachedPty;
8
18
  }
9
19
 
10
20
  export interface PtySpawnOptions {
@@ -90,6 +100,7 @@ class NodePtyRuntimeTransport implements PtyRuntimeTransport {
90
100
 
91
101
  export class NodePtyTransportFactory implements PtyTransportFactory {
92
102
  spawn(command: string, args: string[], options: PtySpawnOptions): PtyRuntimeTransport {
103
+ const pty = loadNodePty();
93
104
  if (!pty) throw new Error('node-pty is not installed');
94
105
  // Validate cwd — an invalid directory causes a native crash on Windows
95
106
  // (node-pty error code 267: ERROR_DIRECTORY) that bypasses JS try/catch