claw-subagent-service 0.0.144 → 0.0.146
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
|
@@ -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',
|
|
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',
|
|
138
|
+
} catch (e) {
|
|
139
|
+
log('ERROR', `OpenCode 服务启动失败: ${e.message}`);
|
|
138
140
|
return false;
|
|
139
141
|
}
|
|
140
142
|
}
|
|
@@ -162,15 +164,20 @@ async function forwardChatMessage(sessionId, content, onDelta, logFn, timeoutMs
|
|
|
162
164
|
log('DEBUG', `发送消息: ${content}`);
|
|
163
165
|
log('DEBUG', `请求超时: ${timeoutMs}ms`);
|
|
164
166
|
|
|
165
|
-
// 构建请求体,包含 system 参数
|
|
167
|
+
// 构建请求体,包含 system 和 model 参数
|
|
168
|
+
// model 字段是必需的,告诉 Gateway 使用哪个 AI 提供商和模型
|
|
166
169
|
const requestBody = {
|
|
167
170
|
system: SYSTEM_PROMPT,
|
|
171
|
+
model: { providerID: 'opencode', modelID: 'default' },
|
|
168
172
|
parts: [{ type: 'text', text: content }]
|
|
169
173
|
};
|
|
170
174
|
|
|
171
175
|
log('DEBUG', `请求体包含 system 参数: ${!!requestBody.system}`);
|
|
172
176
|
|
|
173
177
|
try {
|
|
178
|
+
log('DEBUG', `发送请求到: ${url}`);
|
|
179
|
+
log('DEBUG', `请求体: ${JSON.stringify(requestBody).substring(0, 500)}`);
|
|
180
|
+
|
|
174
181
|
const response = await axios.post(url, requestBody, {
|
|
175
182
|
headers: { 'Content-Type': 'application/json' },
|
|
176
183
|
timeout: timeoutMs
|
|
@@ -181,6 +188,7 @@ async function forwardChatMessage(sessionId, content, onDelta, logFn, timeoutMs
|
|
|
181
188
|
log('DEBUG', `响应数据类型: ${typeof result}`);
|
|
182
189
|
log('DEBUG', `响应数据 keys: ${Object.keys(result).join(', ')}`);
|
|
183
190
|
log('DEBUG', `响应数据: ${JSON.stringify(result).substring(0, 1000)}`);
|
|
191
|
+
log('DEBUG', `响应 headers: ${JSON.stringify(response.headers)}`);
|
|
184
192
|
|
|
185
193
|
const parts = result.parts || [];
|
|
186
194
|
const info = result.info || {};
|