dsh-cloud-experts 0.1.1 → 0.1.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/README.md CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  ## 版本
32
32
 
33
- - 0.1.1:对齐官方 bundle 的 inject 声明(`subagents` + `subprocess`)。
33
+ - 0.1.2:ssh 内置 ServerAliveInterval=15(NAT 防断)+ 本地 360s 看门狗;0.1.1:对齐官方 inject。
34
34
 
35
35
  ## License
36
36
 
package/lib/index.js CHANGED
@@ -69,7 +69,8 @@ class CloudExpertProvider {
69
69
  const stamp = new Date().toISOString().replace(/[^0-9]/g, "").slice(0, 14);
70
70
  const consultId = `PLUGIN-${stamp}-${this.expert}-${randomUUID().slice(0, 8)}`;
71
71
  const remoteCmd = [this.config.remoteEntry, this.expert, "--id", consultId, "--origin", this.config.origin].join(" ");
72
- const argv = ["ssh", "-o", "BatchMode=yes", "-o", "IdentitiesOnly=yes", "-o", "ConnectTimeout=15"];
72
+ const argv = ["ssh", "-o", "BatchMode=yes", "-o", "IdentitiesOnly=yes", "-o", "ConnectTimeout=15",
73
+ "-o", "ServerAliveInterval=15", "-o", "ServerAliveCountMax=4", "-o", "LogLevel=ERROR"];
73
74
  if (this.config.keyPath) argv.push("-i", this.config.keyPath);
74
75
  argv.push(this.config.host, remoteCmd);
75
76
 
@@ -91,6 +92,11 @@ class CloudExpertProvider {
91
92
  const stdinWrite = writeAll(child.stdin, Buffer.from(text, "utf8")).catch(() => {});
92
93
 
93
94
  const controller = new AbortController();
95
+ const watchdog = setTimeout(() => {
96
+ try { child.stdin?.end(); } catch {}
97
+ try { child.terminate(); } catch {}
98
+ controller.abort(new Error(`cloud-experts: ${this.expert} local watchdog fired (360s)`));
99
+ }, 360000);
94
100
  const requestCancel = () => {
95
101
  if (!controller.signal.aborted) controller.abort(new Error(`cloud-experts: ${this.expert} run cancelled locally`));
96
102
  try { child.stdin?.end(); } catch {}
@@ -100,7 +106,8 @@ class CloudExpertProvider {
100
106
  request.signal.addEventListener("abort", onAbort, { once: true });
101
107
 
102
108
  const attempt = async () => {
103
- await stdinWrite;
109
+ try {
110
+ await stdinWrite;
104
111
  const info = await child.done;
105
112
  const code = info && typeof info.code === "number" ? info.code : 0;
106
113
  const envelope = /FED_ENVELOPE:(\{[^\n]*\})/.exec(err);
@@ -113,6 +120,9 @@ class CloudExpertProvider {
113
120
  }
114
121
  const failure = /FED_ERROR:([\w:.-]+)/.exec(err);
115
122
  throw new Error(`cloud-experts: ${failure?.[1] ?? `exit-${code}`} ${err.slice(0, 200)}`);
123
+ } finally {
124
+ clearTimeout(watchdog);
125
+ }
116
126
  };
117
127
 
118
128
  const result = settleRunResult({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-cloud-experts",
3
3
  "description": "Cloud expert subagents (claude/codex on the fed VPS) over SSH fed-expert wrapper",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {