claw-subagent-service 0.0.144 → 0.0.145

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claw-subagent-service",
3
- "version": "0.0.144",
3
+ "version": "0.0.145",
4
4
  "description": "虾说智能助手",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -115,10 +115,11 @@ async function getOrCreateGatewaySession(fallbackSessionId) {
115
115
  async function ensureOpencodeRunning(log) {
116
116
  try {
117
117
  // 快速检查 4096 端口
118
- await axios.get('http://127.0.0.1:4096/global/health', { timeout: 3000 });
118
+ const healthResponse = await axios.get('http://127.0.0.1:4096/global/health', { timeout: 3000 });
119
+ log('DEBUG', `OpenCode health check: ${JSON.stringify(healthResponse.data)}`);
119
120
  return true;
120
- } catch {
121
- log('WARN', 'OpenCode 服务未运行,准备启动...');
121
+ } catch (e) {
122
+ log('WARN', `OpenCode 服务未运行: ${e.message},准备启动...`);
122
123
 
123
124
  const { exec } = require('child_process');
124
125
 
@@ -130,11 +131,12 @@ async function ensureOpencodeRunning(log) {
130
131
 
131
132
  // 再次检查
132
133
  try {
133
- await axios.get('http://127.0.0.1:4096/global/health', { timeout: 3000 });
134
+ const healthResponse = await axios.get('http://127.0.0.1:4096/global/health', { timeout: 3000 });
135
+ log('DEBUG', `OpenCode health check after start: ${JSON.stringify(healthResponse.data)}`);
134
136
  log('INFO', 'OpenCode 服务已启动');
135
137
  return true;
136
- } catch {
137
- log('ERROR', 'OpenCode 服务启动失败');
138
+ } catch (e) {
139
+ log('ERROR', `OpenCode 服务启动失败: ${e.message}`);
138
140
  return false;
139
141
  }
140
142
  }
@@ -171,6 +173,9 @@ async function forwardChatMessage(sessionId, content, onDelta, logFn, timeoutMs
171
173
  log('DEBUG', `请求体包含 system 参数: ${!!requestBody.system}`);
172
174
 
173
175
  try {
176
+ log('DEBUG', `发送请求到: ${url}`);
177
+ log('DEBUG', `请求体: ${JSON.stringify(requestBody).substring(0, 500)}`);
178
+
174
179
  const response = await axios.post(url, requestBody, {
175
180
  headers: { 'Content-Type': 'application/json' },
176
181
  timeout: timeoutMs
@@ -181,6 +186,7 @@ async function forwardChatMessage(sessionId, content, onDelta, logFn, timeoutMs
181
186
  log('DEBUG', `响应数据类型: ${typeof result}`);
182
187
  log('DEBUG', `响应数据 keys: ${Object.keys(result).join(', ')}`);
183
188
  log('DEBUG', `响应数据: ${JSON.stringify(result).substring(0, 1000)}`);
189
+ log('DEBUG', `响应 headers: ${JSON.stringify(response.headers)}`);
184
190
 
185
191
  const parts = result.parts || [];
186
192
  const info = result.info || {};