@instaclaw/dispatch 0.6.0 → 0.6.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.
@@ -16,10 +16,17 @@ export function connect(opts) {
16
16
  console.log(` Connecting to ${opts.vmAddress}:${opts.port}...`);
17
17
  ws = new WebSocket(url, {
18
18
  rejectUnauthorized: false, // Accept self-signed certs (TOFU model)
19
+ handshakeTimeout: 10000,
19
20
  });
20
21
  ws.on("open", () => {
21
22
  reconnectDelay = 1000; // Reset backoff
22
23
  console.log(` Connected to agent on ${opts.vmAddress}`);
24
+ // Enable TCP keepalive to prevent NAT/firewall/router from killing idle connections
25
+ // Without this, home routers typically drop idle TCP after 2-5 minutes
26
+ const socket = ws?._socket;
27
+ if (socket?.setKeepAlive) {
28
+ socket.setKeepAlive(true, 30000); // Send TCP keepalive every 30s
29
+ }
23
30
  opts.onConnect?.();
24
31
  });
25
32
  ws.on("message", async (data, isBinary) => {
package/dist/executor.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Executor — receives dispatch commands and executes them via usecomputer.
3
3
  * Returns results (action confirmations or screenshot data).
4
4
  */
5
- import { execSync } from "child_process";
5
+ import { execSync, exec as execCb } from "child_process";
6
6
  import { captureScreenshot } from "./screenshot.js";
7
7
  // Dynamic import for usecomputer (ESM)
8
8
  let uc = null;
@@ -225,8 +225,7 @@ async function doExec(params) {
225
225
  // Timeout: default 30s, max 120s
226
226
  const timeoutMs = Math.min(Number(params.timeout) || 30000, 120000);
227
227
  return new Promise((resolve) => {
228
- const { exec } = require("child_process");
229
- exec(command, { timeout: timeoutMs, maxBuffer: 1024 * 1024, shell: "/bin/bash" }, (err, stdout, stderr) => {
228
+ execCb(command, { timeout: timeoutMs, maxBuffer: 1024 * 1024, shell: "/bin/bash" }, (err, stdout, stderr) => {
230
229
  const exitCode = err ? err.code ?? 1 : 0;
231
230
  // Cap output to prevent context flooding (max 4KB each)
232
231
  const cappedStdout = stdout.length > 4096 ? stdout.substring(0, 4096) + "\n[...truncated]" : stdout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instaclaw/dispatch",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Let your InstaClaw AI agent control your computer — screenshots, clicks, typing, and more via a secure WebSocket relay",
5
5
  "bin": {
6
6
  "instaclaw-dispatch": "./dist/index.js"