@yvhitxcel/opencode-remote 0.16.1 → 0.16.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.
@@ -2,6 +2,13 @@
2
2
  import { spawn } from 'child_process';
3
3
  import { platform } from 'os';
4
4
 
5
+ const CRASH_PATTERNS = [
6
+ 'Assertion failed',
7
+ 'UV_HANDLE_CLOSING',
8
+ 'src\\win\\async.c',
9
+ 'libuv',
10
+ ];
11
+
5
12
  export class CodexAgentAdapter {
6
13
  name = 'codex';
7
14
  aliases = ['cx'];
@@ -25,6 +32,16 @@ export class CodexAgentAdapter {
25
32
  const historyText = history.map(msg => `[${msg.role}]: ${msg.content}`).join('\n\n');
26
33
  return `Context:\n${historyText}\n\n${prompt}`;
27
34
  }
35
+
36
+ extractErrorMessage(stdout, stderr) {
37
+ const lines = [...stdout.trim().split('\n'), ...stderr.trim().split('\n')]
38
+ .map(l => l.trim()).filter(Boolean)
39
+ .filter(l => !CRASH_PATTERNS.some(p => l.includes(p)));
40
+ if (lines.length > 0) return lines.join('\n');
41
+ const first = [...stdout.trim().split('\n'), ...stderr.trim().split('\n')]
42
+ .find(l => /Error|error|ERROR|^\d{3}/.test(l));
43
+ return first || null;
44
+ }
28
45
 
29
46
  callCodex(prompt) {
30
47
  return new Promise((resolve) => {
@@ -37,7 +54,12 @@ export class CodexAgentAdapter {
37
54
  proc.stdout?.on('data', (data) => { stdout += data.toString(); });
38
55
  proc.stderr?.on('data', (data) => { stderr += data.toString(); });
39
56
  proc.on('close', (code) => {
40
- resolve(code === 0 ? stdout.trim() : `❌ Codex 错误: ${stderr}`);
57
+ if (code === 0) {
58
+ resolve(stdout.trim());
59
+ } else {
60
+ const detail = this.extractErrorMessage(stdout, stderr);
61
+ resolve(`❌ Codex 错误${detail ? `: ${detail}` : ''}`);
62
+ }
41
63
  });
42
64
  });
43
65
  }
@@ -2,6 +2,13 @@
2
2
  import { spawn } from 'child_process';
3
3
  import { platform } from 'os';
4
4
 
5
+ const CRASH_PATTERNS = [
6
+ 'Assertion failed',
7
+ 'UV_HANDLE_CLOSING',
8
+ 'src\\win\\async.c',
9
+ 'libuv',
10
+ ];
11
+
5
12
  export class CopilotAgentAdapter {
6
13
  name = 'copilot';
7
14
  aliases = ['copilot-cli', 'copilot'];
@@ -25,6 +32,16 @@ export class CopilotAgentAdapter {
25
32
  const historyText = history.map(msg => `[${msg.role}]: ${msg.content}`).join('\n\n');
26
33
  return `Context:\n${historyText}\n\n${prompt}`;
27
34
  }
35
+
36
+ extractErrorMessage(stdout, stderr) {
37
+ const lines = [...stdout.trim().split('\n'), ...stderr.trim().split('\n')]
38
+ .map(l => l.trim()).filter(Boolean)
39
+ .filter(l => !CRASH_PATTERNS.some(p => l.includes(p)));
40
+ if (lines.length > 0) return lines.join('\n');
41
+ const first = [...stdout.trim().split('\n'), ...stderr.trim().split('\n')]
42
+ .find(l => /Error|error|ERROR|^\d{3}/.test(l));
43
+ return first || null;
44
+ }
28
45
 
29
46
  callCopilot(prompt) {
30
47
  return new Promise((resolve) => {
@@ -37,7 +54,12 @@ export class CopilotAgentAdapter {
37
54
  proc.stdout?.on('data', (data) => { stdout += data.toString(); });
38
55
  proc.stderr?.on('data', (data) => { stderr += data.toString(); });
39
56
  proc.on('close', (code) => {
40
- resolve(code === 0 ? stdout.trim() : `❌ Copilot 错误: ${stderr}`);
57
+ if (code === 0) {
58
+ resolve(stdout.trim());
59
+ } else {
60
+ const detail = this.extractErrorMessage(stdout, stderr);
61
+ resolve(`❌ Copilot 错误${detail ? `: ${detail}` : ''}`);
62
+ }
41
63
  });
42
64
  });
43
65
  }
@@ -2,6 +2,13 @@
2
2
  import { spawn } from 'child_process';
3
3
  import { platform } from 'os';
4
4
 
5
+ const CRASH_PATTERNS = [
6
+ 'Assertion failed',
7
+ 'UV_HANDLE_CLOSING',
8
+ 'src\\win\\async.c',
9
+ 'libuv',
10
+ ];
11
+
5
12
  export class OpenCodeAgentAdapter {
6
13
  name = 'opencode';
7
14
  aliases = ['oc', 'opencodeai'];
@@ -28,17 +35,28 @@ export class OpenCodeAgentAdapter {
28
35
  return `Previous conversation:\n${historyText}\n\nCurrent request: ${prompt}`;
29
36
  }
30
37
 
38
+ extractErrorMessage(stdout, stderr) {
39
+ const lines = [...stdout.trim().split('\n'), ...stderr.trim().split('\n')]
40
+ .map(l => l.trim()).filter(Boolean)
41
+ .filter(l => !CRASH_PATTERNS.some(p => l.includes(p)));
42
+
43
+ if (lines.length > 0) return lines.join('\n');
44
+ const first = [...stdout.trim().split('\n'), ...stderr.trim().split('\n')]
45
+ .find(l => /Error|error|ERROR|^\d{3}/.test(l));
46
+ return first || null;
47
+ }
48
+
31
49
  callOpenCode(prompt) {
32
50
  return new Promise((resolve) => {
33
51
  const proc = spawn('opencode', ['run', '--format', 'json', prompt], {
34
52
  stdio: ['ignore', 'pipe', 'pipe'],
35
53
  shell: true,
36
54
  });
37
-
55
+
38
56
  let stdout = '';
39
57
  let stderr = '';
40
58
  let fullText = '';
41
-
59
+
42
60
  proc.stdout?.on('data', (data) => {
43
61
  stdout += data.toString();
44
62
  const lines = stdout.split('\n');
@@ -51,12 +69,16 @@ export class OpenCodeAgentAdapter {
51
69
  } catch {}
52
70
  }
53
71
  });
54
-
72
+
55
73
  proc.stderr?.on('data', (data) => { stderr += data.toString(); });
56
-
74
+
57
75
  proc.on('close', (code) => {
58
76
  if (code !== 0) {
59
- resolve(`❌ OpenCode 错误。请运行 \`opencode auth login\` 配置认证。`);
77
+ const detail = this.extractErrorMessage(stdout, stderr);
78
+ const hint = detail
79
+ ? `: ${detail}`
80
+ : '。请运行 `opencode auth login` 配置认证。';
81
+ resolve(`❌ OpenCode 错误${hint}`);
60
82
  } else {
61
83
  resolve(fullText || '完成');
62
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yvhitxcel/opencode-remote",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "🤖 AI 专家团队随时待命!只需输入 /z,自动分析项目、诊断问题、给出改进方案。支持微信/飞书/Telegram 远程控制 OpenCode、Claude Code、Codex、Copilot。手机也能搞开发。",
5
5
  "type": "module",
6
6
  "bin": {