@wu529778790/open-im 1.11.8-beta.28 → 1.11.8-beta.29

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.
@@ -21,6 +21,7 @@ interface ClaudeSessionMeta {
21
21
  export declare function findLatestClaudeSession(workDir: string): Promise<ClaudeSessionMeta | undefined>;
22
22
  export declare class ClaudeSDKAdapter implements ToolAdapter {
23
23
  readonly toolId = "claude-sdk";
24
+ readonly interactionMode = "native";
24
25
  /**
25
26
  * 清理所有活跃的查询
26
27
  */
@@ -205,6 +205,7 @@ function enrichClaudeErrorMessage(message, stderr) {
205
205
  }
206
206
  export class ClaudeSDKAdapter {
207
207
  toolId = 'claude-sdk';
208
+ interactionMode = 'native';
208
209
  /**
209
210
  * 清理所有活跃的查询
210
211
  */
@@ -2,6 +2,7 @@ import type { RunCallbacks, RunHandle, RunOptions, ToolAdapter } from './tool-ad
2
2
  export declare class CodeBuddyAdapter implements ToolAdapter {
3
3
  private cliPath;
4
4
  readonly toolId = "codebuddy";
5
+ readonly interactionMode = "open";
5
6
  constructor(cliPath: string);
6
7
  run(prompt: string, sessionId: string | undefined, workDir: string, callbacks: RunCallbacks, options?: RunOptions): RunHandle;
7
8
  }
@@ -3,6 +3,7 @@ import { isSessionInvalidMessage } from '../shared/session-invalid-detector.js';
3
3
  export class CodeBuddyAdapter {
4
4
  cliPath;
5
5
  toolId = 'codebuddy';
6
+ interactionMode = 'open';
6
7
  constructor(cliPath) {
7
8
  this.cliPath = cliPath;
8
9
  }
@@ -5,6 +5,7 @@ import type { RunCallbacks, RunHandle, RunOptions, ToolAdapter } from "./tool-ad
5
5
  export declare class CodexAdapter implements ToolAdapter {
6
6
  private cliPath;
7
7
  readonly toolId = "codex";
8
+ readonly interactionMode = "open";
8
9
  constructor(cliPath: string);
9
10
  run(prompt: string, sessionId: string | undefined, workDir: string, callbacks: RunCallbacks, options?: RunOptions): RunHandle;
10
11
  }
@@ -6,6 +6,7 @@ import { isSessionInvalidMessage } from "../shared/session-invalid-detector.js";
6
6
  export class CodexAdapter {
7
7
  cliPath;
8
8
  toolId = "codex";
9
+ interactionMode = "open";
9
10
  constructor(cliPath) {
10
11
  this.cliPath = cliPath;
11
12
  }
@@ -1,5 +1,6 @@
1
1
  import type { RunCallbacks, RunHandle, RunOptions, ToolAdapter } from './tool-adapter.interface.js';
2
2
  export declare class OpenCodeAdapter implements ToolAdapter {
3
3
  readonly toolId = "opencode";
4
+ readonly interactionMode = "open";
4
5
  run(prompt: string, sessionId: string | undefined, workDir: string, callbacks: RunCallbacks, options?: RunOptions): RunHandle;
5
6
  }
@@ -2,6 +2,7 @@ import { runOpenCodeSdk } from '../opencode/sdk-runner.js';
2
2
  import { isSessionInvalidMessage } from '../shared/session-invalid-detector.js';
3
3
  export class OpenCodeAdapter {
4
4
  toolId = 'opencode';
5
+ interactionMode = 'open';
5
6
  run(prompt, sessionId, workDir, callbacks, options) {
6
7
  const handle = runOpenCodeSdk(prompt, sessionId, workDir, {
7
8
  onText: callbacks.onText,
@@ -40,7 +40,9 @@ export interface RunOptions {
40
40
  export interface RunHandle {
41
41
  abort: () => void;
42
42
  }
43
+ export type InteractionMode = 'native' | 'open';
43
44
  export interface ToolAdapter {
44
45
  readonly toolId: string;
46
+ readonly interactionMode: InteractionMode;
45
47
  run(prompt: string, sessionId: string | undefined, workDir: string, callbacks: RunCallbacks, options?: RunOptions): RunHandle;
46
48
  }
@@ -180,6 +180,22 @@ function buildCompletionNote(result, sessionManager, ctx) {
180
180
  parts.push(ctxWarning);
181
181
  return parts.join(' | ');
182
182
  }
183
+ function buildRunOptions(config, sessionManager, ctx, aiCommand, toolAdapter) {
184
+ const defaultSkipPermissions = toolAdapter.interactionMode === 'native'
185
+ ? false
186
+ : (config.skipPermissions ?? true);
187
+ return {
188
+ model: aiCommand === 'claude'
189
+ ? (sessionManager.getModel(ctx.userId, ctx.threadId) ?? config.claudeModel)
190
+ : aiCommand === 'opencode'
191
+ ? config.opencodeModel
192
+ : undefined,
193
+ chatId: ctx.chatId,
194
+ skipPermissions: defaultSkipPermissions,
195
+ skipAutoResume: sessionManager.isFreshSession(ctx.userId),
196
+ ...(aiCommand === 'codex' && config.codexProxy ? { proxy: config.codexProxy } : {}),
197
+ };
198
+ }
183
199
  export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
184
200
  const { config, sessionManager } = deps;
185
201
  return new Promise((resolve) => {
@@ -459,19 +475,7 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
459
475
  cleanup();
460
476
  resolve();
461
477
  },
462
- }, {
463
- model: aiCommand === 'claude'
464
- ? (sessionManager.getModel(ctx.userId, ctx.threadId) ?? config.claudeModel)
465
- : aiCommand === 'opencode'
466
- ? config.opencodeModel
467
- : undefined,
468
- chatId: ctx.chatId,
469
- // 默认跳过权限确认,保持全自动执行(可通过 config 或环境变量关闭)
470
- skipPermissions: config.skipPermissions ?? true,
471
- // /new 后跳过自动恢复 CLI session
472
- skipAutoResume: sessionManager.isFreshSession(ctx.userId),
473
- ...(aiCommand === 'codex' && config.codexProxy ? { proxy: config.codexProxy } : {}),
474
- });
478
+ }, buildRunOptions(config, sessionManager, ctx, aiCommand, toolAdapter));
475
479
  return activeHandle;
476
480
  };
477
481
  taskState = {
@@ -61,14 +61,14 @@ async function downloadTelegramFile(bot, fileId, basenameHint, fallbackExtension
61
61
  }
62
62
  export function setupTelegramHandlers(bot, config, sessionManager) {
63
63
  // Create shared platform event context
64
- const ctx = createPlatformEventContext({
64
+ const platformCtx = createPlatformEventContext({
65
65
  platform: 'telegram',
66
66
  allowedUserIds: config.telegramAllowedUserIds,
67
67
  config,
68
68
  sessionManager,
69
69
  sender: { sendTextReply, sendDirectorySelection },
70
70
  });
71
- const { accessControl, requestQueue, runningTasks } = ctx;
71
+ const { accessControl, requestQueue, runningTasks } = platformCtx;
72
72
  // Telegram-specific sender callbacks for the factory
73
73
  const telegramSender = {
74
74
  sendThinkingMessage: async (chatId, replyToMessageId, toolId) => {
@@ -316,24 +316,14 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
316
316
  if (parts.length >= 3) {
317
317
  const choiceNum = parts[2];
318
318
  const chatId = String(ctx.chat?.id ?? "");
319
- // 将用户选择作为消息发送给 AI
320
- const { handleTextFlow } = await import("../platform/handle-text-flow.js");
321
319
  await handleTextFlow({
322
320
  platform: "telegram",
323
321
  userId,
324
322
  chatId,
325
323
  text: choiceNum,
326
- ctx: createPlatformEventContext({
327
- platform: "telegram",
328
- allowedUserIds: config.telegramAllowedUserIds,
329
- config,
330
- sessionManager,
331
- sender: { sendTextReply: async () => { } },
332
- }),
333
- handleAIRequest: async () => { },
334
- sendTextReply: async (c, t) => {
335
- await sendTextReply(c, t);
336
- },
324
+ ctx: platformCtx,
325
+ handleAIRequest,
326
+ sendTextReply,
337
327
  workDir: sessionManager.getWorkDir(userId),
338
328
  convId: sessionManager.getConvId(userId),
339
329
  });
@@ -352,7 +342,7 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
352
342
  userId,
353
343
  chatId,
354
344
  text,
355
- ctx,
345
+ ctx: platformCtx,
356
346
  handleAIRequest,
357
347
  sendTextReply,
358
348
  replyToMessageId: messageId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.11.8-beta.28",
3
+ "version": "1.11.8-beta.29",
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",