@wu529778790/open-im 1.11.8-beta.4 → 1.11.8-beta.5
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/dist/config/types.d.ts +4 -0
- package/dist/config.js +2 -0
- package/dist/opencode/sdk-runner.js +23 -0
- package/dist/shared/ai-task.js +3 -1
- package/package.json +1 -1
package/dist/config/types.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface Config {
|
|
|
26
26
|
codexCliPath: string;
|
|
27
27
|
codebuddyCliPath: string;
|
|
28
28
|
opencodeCliPath: string;
|
|
29
|
+
/** OpenCode SDK 使用的模型(格式: providerID/modelID,如 zhipuai-coding-plan/glm-5.1) */
|
|
30
|
+
opencodeModel?: string;
|
|
29
31
|
/** Claude 访问 API 的代理(如 http://127.0.0.1:7890) */
|
|
30
32
|
claudeProxy?: string;
|
|
31
33
|
/** Codex 访问 chatgpt.com 的代理(如 http://127.0.0.1:7890) */
|
|
@@ -186,6 +188,8 @@ export interface FileToolCodeBuddy {
|
|
|
186
188
|
}
|
|
187
189
|
export interface FileToolOpenCode {
|
|
188
190
|
cliPath?: string;
|
|
191
|
+
/** 模型(格式: providerID/modelID) */
|
|
192
|
+
model?: string;
|
|
189
193
|
}
|
|
190
194
|
export interface FileConfig {
|
|
191
195
|
telegramBotToken?: string;
|
package/dist/config.js
CHANGED
|
@@ -226,6 +226,7 @@ export function loadConfig() {
|
|
|
226
226
|
const codebuddyCliPath = process.env.CODEBUDDY_CLI_PATH ?? tcb.cliPath ?? resolveWindowsCliPath(AI_TOOL_BY_ID.codebuddy.cliDefault ?? 'codebuddy');
|
|
227
227
|
const topencode = file.tools?.opencode ?? {};
|
|
228
228
|
const opencodeCliPath = process.env.OPENCODE_CLI_PATH ?? topencode.cliPath ?? resolveWindowsCliPath(AI_TOOL_BY_ID.opencode.cliDefault ?? 'opencode');
|
|
229
|
+
const opencodeModel = process.env.OPENCODE_MODEL ?? topencode.model;
|
|
229
230
|
const claudeWorkDir = process.env.CLAUDE_WORK_DIR ?? tc.workDir ?? process.cwd();
|
|
230
231
|
const skipPermissions = process.env.OPEN_IM_SKIP_PERMISSIONS === 'false'
|
|
231
232
|
? false
|
|
@@ -519,6 +520,7 @@ export function loadConfig() {
|
|
|
519
520
|
codexCliPath,
|
|
520
521
|
codebuddyCliPath,
|
|
521
522
|
opencodeCliPath,
|
|
523
|
+
opencodeModel,
|
|
522
524
|
claudeProxy,
|
|
523
525
|
codexProxy,
|
|
524
526
|
claudeWorkDir,
|
|
@@ -144,10 +144,33 @@ export async function runOpenCodeSdk(prompt, sessionId, workDir, callbacks, opti
|
|
|
144
144
|
parts: [{ type: 'text', text: prompt }],
|
|
145
145
|
...(options?.model ? { model: parseModel(options.model) } : {}),
|
|
146
146
|
});
|
|
147
|
+
// 调试:dump SDK 返回值结构
|
|
148
|
+
log.info(`SDK prompt raw result: hasData=${!!result.data}, hasError=${!!result.error}, keys=${Object.keys(result).join(',')}`);
|
|
149
|
+
if (result.error) {
|
|
150
|
+
const errStr = result.error instanceof Error ? result.error.message : JSON.stringify(result.error).substring(0, 500);
|
|
151
|
+
log.info(`SDK prompt error detail: ${errStr}`);
|
|
152
|
+
}
|
|
153
|
+
if (result.data) {
|
|
154
|
+
const d = result.data;
|
|
155
|
+
log.info(`SDK prompt data keys: ${Object.keys(d).join(',')}, parts count: ${Array.isArray(d.parts) ? d.parts.length : 'N/A'}, info keys: ${d.info && typeof d.info === 'object' ? Object.keys(d.info).join(',') : 'N/A'}`);
|
|
156
|
+
}
|
|
147
157
|
abortController.abort();
|
|
148
158
|
await background.catch(() => { });
|
|
149
159
|
runSettled = true;
|
|
160
|
+
// SDK 返回 { data, error } 二元组;error 存在时 data 为 undefined
|
|
161
|
+
const sdkError = result.error;
|
|
162
|
+
if (sdkError) {
|
|
163
|
+
const errMsg = sdkError instanceof Error ? sdkError.message : JSON.stringify(sdkError);
|
|
164
|
+
log.error(`SDK prompt returned error: ${errMsg}`);
|
|
165
|
+
callbacks.onError(errMsg);
|
|
166
|
+
return { abort: () => { } };
|
|
167
|
+
}
|
|
150
168
|
const data = result.data;
|
|
169
|
+
if (!data) {
|
|
170
|
+
log.error(`SDK prompt returned no data and no error — result keys: ${Object.keys(result).join(',')}`);
|
|
171
|
+
callbacks.onError('SDK 返回空数据');
|
|
172
|
+
return { abort: () => { } };
|
|
173
|
+
}
|
|
151
174
|
const parts = data?.parts ?? [];
|
|
152
175
|
const finalText = parts
|
|
153
176
|
.filter((p) => p.type === 'text' && typeof p.text === 'string')
|
package/dist/shared/ai-task.js
CHANGED
|
@@ -290,7 +290,9 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
|
|
|
290
290
|
}, {
|
|
291
291
|
model: aiCommand === 'claude'
|
|
292
292
|
? (sessionManager.getModel(ctx.userId, ctx.threadId) ?? config.claudeModel)
|
|
293
|
-
:
|
|
293
|
+
: aiCommand === 'opencode'
|
|
294
|
+
? config.opencodeModel
|
|
295
|
+
: undefined,
|
|
294
296
|
chatId: ctx.chatId,
|
|
295
297
|
// 默认跳过权限确认,保持全自动执行(可通过 config 或环境变量关闭)
|
|
296
298
|
skipPermissions: config.skipPermissions ?? true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wu529778790/open-im",
|
|
3
|
-
"version": "1.11.8-beta.
|
|
3
|
+
"version": "1.11.8-beta.5",
|
|
4
4
|
"description": "Your AI coding assistant, in every chat app. Multi-platform IM bridge for Claude Code, Codex, and CodeBuddy.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|