pty-wrap 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,6 +5,8 @@ import { v4 as uuidv4 } from 'uuid';
5
5
  import os from 'os';
6
6
  import { execSync } from 'child_process';
7
7
  const MQTT_URL = process.env.MQTT_URL || 'mqtt://localhost:1883';
8
+ const MQTT_USERNAME = process.env.MQTT_USERNAME || '';
9
+ const MQTT_PASSWORD = process.env.MQTT_PASSWORD || '';
8
10
  const SESSION_ID = process.env.SESSION_ID || uuidv4();
9
11
  const SHELL = process.env.SHELL || (os.platform() === 'win32' ? 'powershell.exe' : 'bash');
10
12
  const COMMAND = process.argv.slice(2);
@@ -20,9 +22,13 @@ function resolveCommand(cmd) {
20
22
  }
21
23
  let seq = 0;
22
24
  const topic = `sessions/${SESSION_ID}/stream`;
25
+ let skipOutputUntilStable = false;
26
+ let skipOutputTimer = null;
23
27
  const client = mqtt.connect(MQTT_URL, {
24
28
  clientId: `pty-wrapper-${SESSION_ID}`,
25
29
  clean: false,
30
+ username: MQTT_USERNAME || undefined,
31
+ password: MQTT_PASSWORD || undefined,
26
32
  });
27
33
  function publish(stream, payload) {
28
34
  const msg = {
@@ -56,7 +62,9 @@ client.on('connect', () => {
56
62
  env: process.env,
57
63
  });
58
64
  ptyProcess.onData((data) => {
59
- publish('output', data);
65
+ if (!skipOutputUntilStable) {
66
+ publish('output', data);
67
+ }
60
68
  process.stdout.write(data);
61
69
  });
62
70
  if (process.stdin.isTTY) {
@@ -65,6 +73,16 @@ client.on('connect', () => {
65
73
  process.stdin.resume();
66
74
  process.stdin.on('data', (data) => {
67
75
  const str = data.toString();
76
+ // Ctrl+O (0x0f) triggers Claude Code UI toggle - skip subsequent output refresh
77
+ if (str === '\x0f') {
78
+ skipOutputUntilStable = true;
79
+ if (skipOutputTimer)
80
+ clearTimeout(skipOutputTimer);
81
+ skipOutputTimer = setTimeout(() => {
82
+ skipOutputUntilStable = false;
83
+ skipOutputTimer = null;
84
+ }, 500);
85
+ }
68
86
  publish('input', str);
69
87
  ptyProcess.write(str);
70
88
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pty-wrap",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "PTY wrapper for capturing terminal sessions via MQTT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",