pty-manager 1.9.0 → 1.9.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/index.d.mts CHANGED
@@ -52,6 +52,17 @@ interface SpawnConfig {
52
52
  * are emitted as autoResponded=false instead of being auto-responded.
53
53
  * Auto-response rules (ruleOverrides) are unaffected. */
54
54
  skipAdapterAutoResponse?: boolean;
55
+ /**
56
+ * Whether to inherit the parent process environment variables.
57
+ * When `true` (default), `process.env` is spread as the base of the spawned
58
+ * process environment. When `false`, only `adapter.getEnv()` output and
59
+ * `config.env` are used — the caller is responsible for providing any
60
+ * necessary system vars (PATH, HOME, etc.) via `config.env`.
61
+ *
62
+ * Set to `false` for security-sensitive contexts where the host process has
63
+ * secrets that spawned agents should not access.
64
+ */
65
+ inheritProcessEnv?: boolean;
55
66
  }
56
67
  /**
57
68
  * Handle to a running session
@@ -101,7 +112,7 @@ interface ParsedOutput {
101
112
  */
102
113
  interface LoginDetection {
103
114
  required: boolean;
104
- type?: 'api_key' | 'oauth' | 'browser' | 'device_code';
115
+ type?: 'api_key' | 'oauth' | 'browser' | 'device_code' | 'cli_auth';
105
116
  url?: string;
106
117
  deviceCode?: string;
107
118
  instructions?: string;
@@ -109,7 +120,7 @@ interface LoginDetection {
109
120
  /**
110
121
  * Normalized authentication methods for runtime event consumers.
111
122
  */
112
- type AuthRequiredMethod = 'api_key' | 'oauth_browser' | 'device_code' | 'unknown';
123
+ type AuthRequiredMethod = 'api_key' | 'cli_auth' | 'oauth_browser' | 'device_code' | 'unknown';
113
124
  /**
114
125
  * Structured authentication-required payload emitted by PTY session/manager.
115
126
  */
@@ -693,6 +704,12 @@ declare class PTYSession extends EventEmitter {
693
704
  * @param keys - Key name(s) to send, e.g. "ctrl+c" or ["up", "up", "enter"]
694
705
  */
695
706
  sendKeys(keys: string | string[]): void;
707
+ /**
708
+ * Build the environment object for spawning a PTY process.
709
+ * Merges base env (process.env unless opted out), adapter env, and config env,
710
+ * with TERM/COLORTERM always forced.
711
+ */
712
+ static buildSpawnEnv(config: SpawnConfig, adapterEnv: Record<string, string>): Record<string, string>;
696
713
  /**
697
714
  * Normalize a list of key names for SPECIAL_KEYS lookup.
698
715
  *
package/dist/index.d.ts CHANGED
@@ -52,6 +52,17 @@ interface SpawnConfig {
52
52
  * are emitted as autoResponded=false instead of being auto-responded.
53
53
  * Auto-response rules (ruleOverrides) are unaffected. */
54
54
  skipAdapterAutoResponse?: boolean;
55
+ /**
56
+ * Whether to inherit the parent process environment variables.
57
+ * When `true` (default), `process.env` is spread as the base of the spawned
58
+ * process environment. When `false`, only `adapter.getEnv()` output and
59
+ * `config.env` are used — the caller is responsible for providing any
60
+ * necessary system vars (PATH, HOME, etc.) via `config.env`.
61
+ *
62
+ * Set to `false` for security-sensitive contexts where the host process has
63
+ * secrets that spawned agents should not access.
64
+ */
65
+ inheritProcessEnv?: boolean;
55
66
  }
56
67
  /**
57
68
  * Handle to a running session
@@ -101,7 +112,7 @@ interface ParsedOutput {
101
112
  */
102
113
  interface LoginDetection {
103
114
  required: boolean;
104
- type?: 'api_key' | 'oauth' | 'browser' | 'device_code';
115
+ type?: 'api_key' | 'oauth' | 'browser' | 'device_code' | 'cli_auth';
105
116
  url?: string;
106
117
  deviceCode?: string;
107
118
  instructions?: string;
@@ -109,7 +120,7 @@ interface LoginDetection {
109
120
  /**
110
121
  * Normalized authentication methods for runtime event consumers.
111
122
  */
112
- type AuthRequiredMethod = 'api_key' | 'oauth_browser' | 'device_code' | 'unknown';
123
+ type AuthRequiredMethod = 'api_key' | 'cli_auth' | 'oauth_browser' | 'device_code' | 'unknown';
113
124
  /**
114
125
  * Structured authentication-required payload emitted by PTY session/manager.
115
126
  */
@@ -693,6 +704,12 @@ declare class PTYSession extends EventEmitter {
693
704
  * @param keys - Key name(s) to send, e.g. "ctrl+c" or ["up", "up", "enter"]
694
705
  */
695
706
  sendKeys(keys: string | string[]): void;
707
+ /**
708
+ * Build the environment object for spawning a PTY process.
709
+ * Merges base env (process.env unless opted out), adapter env, and config env,
710
+ * with TERM/COLORTERM always forced.
711
+ */
712
+ static buildSpawnEnv(config: SpawnConfig, adapterEnv: Record<string, string>): Record<string, string>;
696
713
  /**
697
714
  * Normalize a list of key names for SPECIAL_KEYS lookup.
698
715
  *
package/dist/index.js CHANGED
@@ -601,6 +601,8 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
601
601
  switch (type) {
602
602
  case "api_key":
603
603
  return "api_key";
604
+ case "cli_auth":
605
+ return "cli_auth";
604
606
  case "device_code":
605
607
  return "device_code";
606
608
  case "oauth":
@@ -900,14 +902,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
900
902
  const command = this.adapter.getCommand();
901
903
  const args = this.adapter.getArgs(this.config);
902
904
  const adapterEnv = this.adapter.getEnv(this.config);
903
- const env = {
904
- ...process.env,
905
- ...adapterEnv,
906
- ...this.config.env,
907
- // Force terminal settings
908
- TERM: "xterm-256color",
909
- COLORTERM: "truecolor"
910
- };
905
+ const env = _PTYSession.buildSpawnEnv(this.config, adapterEnv);
911
906
  this.logger.info(
912
907
  { sessionId: this.id, command, args: args.join(" ") },
913
908
  "Starting PTY session"
@@ -1289,6 +1284,21 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
1289
1284
  }
1290
1285
  }
1291
1286
  }
1287
+ /**
1288
+ * Build the environment object for spawning a PTY process.
1289
+ * Merges base env (process.env unless opted out), adapter env, and config env,
1290
+ * with TERM/COLORTERM always forced.
1291
+ */
1292
+ static buildSpawnEnv(config, adapterEnv) {
1293
+ const baseEnv = config.inheritProcessEnv !== false ? process.env : {};
1294
+ return {
1295
+ ...baseEnv,
1296
+ ...adapterEnv,
1297
+ ...config.env,
1298
+ TERM: "xterm-256color",
1299
+ COLORTERM: "truecolor"
1300
+ };
1301
+ }
1292
1302
  /**
1293
1303
  * Normalize a list of key names for SPECIAL_KEYS lookup.
1294
1304
  *