mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
refactor(vscode-ide-companion): translate Chinese comments to English
- Translate all Chinese comments in TypeScript files to English for better code readability - Update documentation comments to be in English - Maintain code functionality while improving internationalization 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -52,11 +52,11 @@ export class AcpConnection {
|
|||||||
private nextRequestId = { value: 0 };
|
private nextRequestId = { value: 0 };
|
||||||
private backend: AcpBackend | null = null;
|
private backend: AcpBackend | null = null;
|
||||||
|
|
||||||
// 模块实例
|
// Module instances
|
||||||
private messageHandler: AcpMessageHandler;
|
private messageHandler: AcpMessageHandler;
|
||||||
private sessionManager: AcpSessionManager;
|
private sessionManager: AcpSessionManager;
|
||||||
|
|
||||||
// 回调函数
|
// Callback functions
|
||||||
onSessionUpdate: (data: AcpSessionUpdate) => void = () => {};
|
onSessionUpdate: (data: AcpSessionUpdate) => void = () => {};
|
||||||
onPermissionRequest: (data: AcpPermissionRequest) => Promise<{
|
onPermissionRequest: (data: AcpPermissionRequest) => Promise<{
|
||||||
optionId: string;
|
optionId: string;
|
||||||
@@ -200,7 +200,7 @@ export class AcpConnection {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 初始化协议
|
// Initialize protocol
|
||||||
const res = await this.sessionManager.initialize(
|
const res = await this.sessionManager.initialize(
|
||||||
this.child,
|
this.child,
|
||||||
this.pendingRequests,
|
this.pendingRequests,
|
||||||
@@ -249,7 +249,7 @@ export class AcpConnection {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 响应
|
// Response
|
||||||
this.messageHandler.handleMessage(
|
this.messageHandler.handleMessage(
|
||||||
message,
|
message,
|
||||||
this.pendingRequests,
|
this.pendingRequests,
|
||||||
|
|||||||
@@ -5,29 +5,29 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP文件操作处理器
|
* ACP File Operation Handler
|
||||||
*
|
*
|
||||||
* 负责处理ACP协议中的文件读写操作
|
* Responsible for handling file read and write operations in the ACP protocol
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP文件操作处理器类
|
* ACP File Operation Handler Class
|
||||||
* 提供文件读写功能,符合ACP协议规范
|
* Provides file read and write functionality according to ACP protocol specifications
|
||||||
*/
|
*/
|
||||||
export class AcpFileHandler {
|
export class AcpFileHandler {
|
||||||
/**
|
/**
|
||||||
* 处理读取文本文件请求
|
* Handle read text file request
|
||||||
*
|
*
|
||||||
* @param params - 文件读取参数
|
* @param params - File read parameters
|
||||||
* @param params.path - 文件路径
|
* @param params.path - File path
|
||||||
* @param params.sessionId - 会话ID
|
* @param params.sessionId - Session ID
|
||||||
* @param params.line - 起始行号(可选)
|
* @param params.line - Starting line number (optional)
|
||||||
* @param params.limit - 读取行数限制(可选)
|
* @param params.limit - Read line limit (optional)
|
||||||
* @returns 文件内容
|
* @returns File content
|
||||||
* @throws 当文件读取失败时抛出错误
|
* @throws Error when file reading fails
|
||||||
*/
|
*/
|
||||||
async handleReadTextFile(params: {
|
async handleReadTextFile(params: {
|
||||||
path: string;
|
path: string;
|
||||||
@@ -48,7 +48,7 @@ export class AcpFileHandler {
|
|||||||
`[ACP] Successfully read file: ${params.path} (${content.length} bytes)`,
|
`[ACP] Successfully read file: ${params.path} (${content.length} bytes)`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 处理行偏移和限制
|
// Handle line offset and limit
|
||||||
if (params.line !== null || params.limit !== null) {
|
if (params.line !== null || params.limit !== null) {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
const startLine = params.line || 0;
|
const startLine = params.line || 0;
|
||||||
@@ -71,14 +71,14 @@ export class AcpFileHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理写入文本文件请求
|
* Handle write text file request
|
||||||
*
|
*
|
||||||
* @param params - 文件写入参数
|
* @param params - File write parameters
|
||||||
* @param params.path - 文件路径
|
* @param params.path - File path
|
||||||
* @param params.content - 文件内容
|
* @param params.content - File content
|
||||||
* @param params.sessionId - 会话ID
|
* @param params.sessionId - Session ID
|
||||||
* @returns null表示成功
|
* @returns null indicates success
|
||||||
* @throws 当文件写入失败时抛出错误
|
* @throws Error when file writing fails
|
||||||
*/
|
*/
|
||||||
async handleWriteTextFile(params: {
|
async handleWriteTextFile(params: {
|
||||||
path: string;
|
path: string;
|
||||||
@@ -91,12 +91,12 @@ export class AcpFileHandler {
|
|||||||
console.log(`[ACP] Content size: ${params.content.length} bytes`);
|
console.log(`[ACP] Content size: ${params.content.length} bytes`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 确保目录存在
|
// Ensure directory exists
|
||||||
const dirName = path.dirname(params.path);
|
const dirName = path.dirname(params.path);
|
||||||
console.log(`[ACP] Ensuring directory exists: ${dirName}`);
|
console.log(`[ACP] Ensuring directory exists: ${dirName}`);
|
||||||
await fs.mkdir(dirName, { recursive: true });
|
await fs.mkdir(dirName, { recursive: true });
|
||||||
|
|
||||||
// 写入文件
|
// Write file
|
||||||
await fs.writeFile(params.path, params.content, 'utf-8');
|
await fs.writeFile(params.path, params.content, 'utf-8');
|
||||||
|
|
||||||
console.log(`[ACP] Successfully wrote file: ${params.path}`);
|
console.log(`[ACP] Successfully wrote file: ${params.path}`);
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP消息处理器
|
* ACP Message Handler
|
||||||
*
|
*
|
||||||
* 负责处理ACP协议中的消息接收、解析和分发
|
* Responsible for receiving, parsing, and distributing messages in the ACP protocol
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
@@ -27,8 +27,8 @@ import { AcpFileHandler } from './acpFileHandler.js';
|
|||||||
import type { ChildProcess } from 'child_process';
|
import type { ChildProcess } from 'child_process';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP消息处理器类
|
* ACP Message Handler Class
|
||||||
* 负责消息的接收、解析和处理
|
* Responsible for receiving, parsing, and processing messages
|
||||||
*/
|
*/
|
||||||
export class AcpMessageHandler {
|
export class AcpMessageHandler {
|
||||||
private fileHandler: AcpFileHandler;
|
private fileHandler: AcpFileHandler;
|
||||||
@@ -38,10 +38,10 @@ export class AcpMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送响应消息到子进程
|
* Send response message to child process
|
||||||
*
|
*
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param response - 响应消息
|
* @param response - Response message
|
||||||
*/
|
*/
|
||||||
sendResponseMessage(child: ChildProcess | null, response: AcpResponse): void {
|
sendResponseMessage(child: ChildProcess | null, response: AcpResponse): void {
|
||||||
if (child?.stdin) {
|
if (child?.stdin) {
|
||||||
@@ -52,11 +52,11 @@ export class AcpMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理接收到的消息
|
* Handle received messages
|
||||||
*
|
*
|
||||||
* @param message - ACP消息
|
* @param message - ACP message
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param callbacks - 回调函数集合
|
* @param callbacks - Callback functions collection
|
||||||
*/
|
*/
|
||||||
handleMessage(
|
handleMessage(
|
||||||
message: AcpMessage,
|
message: AcpMessage,
|
||||||
@@ -65,14 +65,14 @@ export class AcpMessageHandler {
|
|||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if ('method' in message) {
|
if ('method' in message) {
|
||||||
// 请求或通知
|
// Request or notification
|
||||||
this.handleIncomingRequest(message, callbacks).catch(() => {});
|
this.handleIncomingRequest(message, callbacks).catch(() => {});
|
||||||
} else if (
|
} else if (
|
||||||
'id' in message &&
|
'id' in message &&
|
||||||
typeof message.id === 'number' &&
|
typeof message.id === 'number' &&
|
||||||
pendingRequests.has(message.id)
|
pendingRequests.has(message.id)
|
||||||
) {
|
) {
|
||||||
// 响应
|
// Response
|
||||||
this.handleResponse(message, pendingRequests, callbacks);
|
this.handleResponse(message, pendingRequests, callbacks);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -81,11 +81,11 @@ export class AcpMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理响应消息
|
* Handle response message
|
||||||
*
|
*
|
||||||
* @param message - 响应消息
|
* @param message - Response message
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param callbacks - 回调函数集合
|
* @param callbacks - Callback functions collection
|
||||||
*/
|
*/
|
||||||
private handleResponse(
|
private handleResponse(
|
||||||
message: AcpMessage,
|
message: AcpMessage,
|
||||||
@@ -138,11 +138,11 @@ export class AcpMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理进入的请求
|
* Handle incoming requests
|
||||||
*
|
*
|
||||||
* @param message - 请求或通知消息
|
* @param message - Request or notification message
|
||||||
* @param callbacks - 回调函数集合
|
* @param callbacks - Callback functions collection
|
||||||
* @returns 请求处理结果
|
* @returns Request processing result
|
||||||
*/
|
*/
|
||||||
async handleIncomingRequest(
|
async handleIncomingRequest(
|
||||||
message: AcpRequest | AcpNotification,
|
message: AcpRequest | AcpNotification,
|
||||||
@@ -190,11 +190,11 @@ export class AcpMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理权限请求
|
* Handle permission requests
|
||||||
*
|
*
|
||||||
* @param params - 权限请求参数
|
* @param params - Permission request parameters
|
||||||
* @param callbacks - 回调函数集合
|
* @param callbacks - Callback functions collection
|
||||||
* @returns 权限请求结果
|
* @returns Permission request result
|
||||||
*/
|
*/
|
||||||
private async handlePermissionRequest(
|
private async handlePermissionRequest(
|
||||||
params: AcpPermissionRequest,
|
params: AcpPermissionRequest,
|
||||||
@@ -206,7 +206,7 @@ export class AcpMessageHandler {
|
|||||||
const response = await callbacks.onPermissionRequest(params);
|
const response = await callbacks.onPermissionRequest(params);
|
||||||
const optionId = response.optionId;
|
const optionId = response.optionId;
|
||||||
|
|
||||||
// 处理取消、拒绝或允许
|
// Handle cancel, deny, or allow
|
||||||
let outcome: string;
|
let outcome: string;
|
||||||
if (optionId.includes('reject') || optionId === 'cancel') {
|
if (optionId.includes('reject') || optionId === 'cancel') {
|
||||||
outcome = 'rejected';
|
outcome = 'rejected';
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP会话管理器
|
* ACP Session Manager
|
||||||
*
|
*
|
||||||
* 负责管理ACP协议的会话操作,包括初始化、认证、会话创建和切换等
|
* Responsible for managing ACP protocol session operations, including initialization, authentication, session creation, and switching
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { JSONRPC_VERSION } from '../shared/acpTypes.js';
|
import { JSONRPC_VERSION } from '../shared/acpTypes.js';
|
||||||
@@ -21,22 +21,22 @@ import type { PendingRequest } from './connectionTypes.js';
|
|||||||
import type { ChildProcess } from 'child_process';
|
import type { ChildProcess } from 'child_process';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP会话管理器类
|
* ACP Session Manager Class
|
||||||
* 提供会话的初始化、认证、创建、加载和切换功能
|
* Provides session initialization, authentication, creation, loading, and switching functionality
|
||||||
*/
|
*/
|
||||||
export class AcpSessionManager {
|
export class AcpSessionManager {
|
||||||
private sessionId: string | null = null;
|
private sessionId: string | null = null;
|
||||||
private isInitialized = false;
|
private isInitialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送请求到ACP服务器
|
* Send request to ACP server
|
||||||
*
|
*
|
||||||
* @param method - 请求方法名
|
* @param method - Request method name
|
||||||
* @param params - 请求参数
|
* @param params - Request parameters
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 请求响应
|
* @returns Request response
|
||||||
*/
|
*/
|
||||||
private sendRequest<T = unknown>(
|
private sendRequest<T = unknown>(
|
||||||
method: string,
|
method: string,
|
||||||
@@ -81,10 +81,10 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息到子进程
|
* Send message to child process
|
||||||
*
|
*
|
||||||
* @param message - 请求或通知消息
|
* @param message - Request or notification message
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
*/
|
*/
|
||||||
private sendMessage(
|
private sendMessage(
|
||||||
message: AcpRequest | AcpNotification,
|
message: AcpRequest | AcpNotification,
|
||||||
@@ -98,12 +98,12 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化ACP协议连接
|
* Initialize ACP protocol connection
|
||||||
*
|
*
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 初始化响应
|
* @returns Initialization response
|
||||||
*/
|
*/
|
||||||
async initialize(
|
async initialize(
|
||||||
child: ChildProcess | null,
|
child: ChildProcess | null,
|
||||||
@@ -135,13 +135,13 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进行认证
|
* Perform authentication
|
||||||
*
|
*
|
||||||
* @param methodId - 认证方法ID
|
* @param methodId - Authentication method ID
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 认证响应
|
* @returns Authentication response
|
||||||
*/
|
*/
|
||||||
async authenticate(
|
async authenticate(
|
||||||
methodId: string | undefined,
|
methodId: string | undefined,
|
||||||
@@ -168,13 +168,13 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建新会话
|
* Create new session
|
||||||
*
|
*
|
||||||
* @param cwd - 工作目录
|
* @param cwd - Working directory
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 新会话响应
|
* @returns New session response
|
||||||
*/
|
*/
|
||||||
async newSession(
|
async newSession(
|
||||||
cwd: string,
|
cwd: string,
|
||||||
@@ -202,14 +202,14 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送提示消息
|
* Send prompt message
|
||||||
*
|
*
|
||||||
* @param prompt - 提示内容
|
* @param prompt - Prompt content
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 响应
|
* @returns Response
|
||||||
* @throws 当没有活动会话时抛出错误
|
* @throws Error when there is no active session
|
||||||
*/
|
*/
|
||||||
async sendPrompt(
|
async sendPrompt(
|
||||||
prompt: string,
|
prompt: string,
|
||||||
@@ -234,13 +234,13 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载已有会话
|
* Load existing session
|
||||||
*
|
*
|
||||||
* @param sessionId - 会话ID
|
* @param sessionId - Session ID
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 加载响应
|
* @returns Load response
|
||||||
*/
|
*/
|
||||||
async loadSession(
|
async loadSession(
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
@@ -291,12 +291,12 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会话列表
|
* Get session list
|
||||||
*
|
*
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 会话列表响应
|
* @returns Session list response
|
||||||
*/
|
*/
|
||||||
async listSessions(
|
async listSessions(
|
||||||
child: ChildProcess | null,
|
child: ChildProcess | null,
|
||||||
@@ -324,11 +324,11 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 切换到指定会话
|
* Switch to specified session
|
||||||
*
|
*
|
||||||
* @param sessionId - 会话ID
|
* @param sessionId - Session ID
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 切换响应
|
* @returns Switch response
|
||||||
*/
|
*/
|
||||||
async switchSession(
|
async switchSession(
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
@@ -349,9 +349,9 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消当前会话的提示生成
|
* Cancel prompt generation for current session
|
||||||
*
|
*
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
*/
|
*/
|
||||||
async cancelSession(child: ChildProcess | null): Promise<void> {
|
async cancelSession(child: ChildProcess | null): Promise<void> {
|
||||||
if (!this.sessionId) {
|
if (!this.sessionId) {
|
||||||
@@ -376,13 +376,13 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存当前会话
|
* Save current session
|
||||||
*
|
*
|
||||||
* @param tag - 保存标签
|
* @param tag - Save tag
|
||||||
* @param child - 子进程实例
|
* @param child - Child process instance
|
||||||
* @param pendingRequests - 待处理请求映射表
|
* @param pendingRequests - Pending requests map
|
||||||
* @param nextRequestId - 请求ID计数器
|
* @param nextRequestId - Request ID counter
|
||||||
* @returns 保存响应
|
* @returns Save response
|
||||||
*/
|
*/
|
||||||
async saveSession(
|
async saveSession(
|
||||||
tag: string,
|
tag: string,
|
||||||
@@ -410,7 +410,7 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置会话管理器状态
|
* Reset session manager state
|
||||||
*/
|
*/
|
||||||
reset(): void {
|
reset(): void {
|
||||||
this.sessionId = null;
|
this.sessionId = null;
|
||||||
@@ -418,14 +418,14 @@ export class AcpSessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前会话ID
|
* Get current session ID
|
||||||
*/
|
*/
|
||||||
getCurrentSessionId(): string | null {
|
getCurrentSessionId(): string | null {
|
||||||
return this.sessionId;
|
return this.sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否已初始化
|
* Check if initialized
|
||||||
*/
|
*/
|
||||||
getIsInitialized(): boolean {
|
getIsInitialized(): boolean {
|
||||||
return this.isInitialized;
|
return this.isInitialized;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP连接类型定义
|
* ACP Connection Type Definitions
|
||||||
*
|
*
|
||||||
* 包含了ACP连接所需的所有类型和接口定义
|
* Contains all types and interface definitions required for ACP connection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { ChildProcess } from 'child_process';
|
import type { ChildProcess } from 'child_process';
|
||||||
@@ -17,47 +17,47 @@ import type {
|
|||||||
} from '../shared/acpTypes.js';
|
} from '../shared/acpTypes.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 待处理的请求信息
|
* Pending Request Information
|
||||||
*/
|
*/
|
||||||
export interface PendingRequest<T = unknown> {
|
export interface PendingRequest<T = unknown> {
|
||||||
/** 成功回调 */
|
/** Success callback */
|
||||||
resolve: (value: T) => void;
|
resolve: (value: T) => void;
|
||||||
/** 失败回调 */
|
/** Failure callback */
|
||||||
reject: (error: Error) => void;
|
reject: (error: Error) => void;
|
||||||
/** 超时定时器ID */
|
/** Timeout timer ID */
|
||||||
timeoutId?: NodeJS.Timeout;
|
timeoutId?: NodeJS.Timeout;
|
||||||
/** 请求方法名 */
|
/** Request method name */
|
||||||
method: string;
|
method: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP连接回调函数类型
|
* ACP Connection Callback Function Types
|
||||||
*/
|
*/
|
||||||
export interface AcpConnectionCallbacks {
|
export interface AcpConnectionCallbacks {
|
||||||
/** 会话更新回调 */
|
/** Session update callback */
|
||||||
onSessionUpdate: (data: AcpSessionUpdate) => void;
|
onSessionUpdate: (data: AcpSessionUpdate) => void;
|
||||||
/** 权限请求回调 */
|
/** Permission request callback */
|
||||||
onPermissionRequest: (data: AcpPermissionRequest) => Promise<{
|
onPermissionRequest: (data: AcpPermissionRequest) => Promise<{
|
||||||
optionId: string;
|
optionId: string;
|
||||||
}>;
|
}>;
|
||||||
/** 回合结束回调 */
|
/** Turn end callback */
|
||||||
onEndTurn: () => void;
|
onEndTurn: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACP连接状态
|
* ACP Connection State
|
||||||
*/
|
*/
|
||||||
export interface AcpConnectionState {
|
export interface AcpConnectionState {
|
||||||
/** 子进程实例 */
|
/** Child process instance */
|
||||||
child: ChildProcess | null;
|
child: ChildProcess | null;
|
||||||
/** 待处理的请求映射表 */
|
/** Pending requests map */
|
||||||
pendingRequests: Map<number, PendingRequest<unknown>>;
|
pendingRequests: Map<number, PendingRequest<unknown>>;
|
||||||
/** 下一个请求ID */
|
/** Next request ID */
|
||||||
nextRequestId: number;
|
nextRequestId: number;
|
||||||
/** 当前会话ID */
|
/** Current session ID */
|
||||||
sessionId: string | null;
|
sessionId: string | null;
|
||||||
/** 是否已初始化 */
|
/** Whether initialized */
|
||||||
isInitialized: boolean;
|
isInitialized: boolean;
|
||||||
/** 后端类型 */
|
/** Backend type */
|
||||||
backend: string | null;
|
backend: string | null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ export class QwenAgentManager {
|
|||||||
* Connect to Qwen service
|
* Connect to Qwen service
|
||||||
*
|
*
|
||||||
* @param workingDir - Working directory
|
* @param workingDir - Working directory
|
||||||
* @param authStateManager - Auth state manager (optional)
|
* @param authStateManager - Authentication state manager (optional)
|
||||||
|
* @param cliPath - CLI path (optional, if provided will override the path in configuration)
|
||||||
*/
|
*/
|
||||||
async connect(
|
async connect(
|
||||||
workingDir: string,
|
workingDir: string,
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ export class QwenConnectionHandler {
|
|||||||
* @param connection - ACP connection instance
|
* @param connection - ACP connection instance
|
||||||
* @param sessionReader - Session reader instance
|
* @param sessionReader - Session reader instance
|
||||||
* @param workingDir - Working directory
|
* @param workingDir - Working directory
|
||||||
* @param authStateManager - Auth state manager (optional)
|
* @param authStateManager - Authentication state manager (optional)
|
||||||
|
* @param cliPath - CLI path (optional, if provided will override the path in configuration)
|
||||||
*/
|
*/
|
||||||
async connect(
|
async connect(
|
||||||
connection: AcpConnection,
|
connection: AcpConnection,
|
||||||
@@ -100,7 +101,7 @@ export class QwenConnectionHandler {
|
|||||||
'[QwenAgentManager] Found existing sessions:',
|
'[QwenAgentManager] Found existing sessions:',
|
||||||
sessions.length,
|
sessions.length,
|
||||||
);
|
);
|
||||||
const lastSession = sessions[0]; // 已按lastUpdated排序
|
const lastSession = sessions[0]; // Already sorted by lastUpdated
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await connection.switchSession(lastSession.sessionId);
|
await connection.switchSession(lastSession.sessionId);
|
||||||
|
|||||||
@@ -5,71 +5,71 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Qwen Agent Manager 类型定义
|
* Qwen Agent Manager Type Definitions
|
||||||
*
|
*
|
||||||
* 包含所有相关的接口和类型定义
|
* Contains all related interfaces and type definitions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { AcpPermissionRequest } from '../shared/acpTypes.js';
|
import type { AcpPermissionRequest } from '../shared/acpTypes.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聊天消息
|
* Chat Message
|
||||||
*/
|
*/
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
/** 消息角色:用户或助手 */
|
/** Message role: user or assistant */
|
||||||
role: 'user' | 'assistant';
|
role: 'user' | 'assistant';
|
||||||
/** 消息内容 */
|
/** Message content */
|
||||||
content: string;
|
content: string;
|
||||||
/** 时间戳 */
|
/** Timestamp */
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划条目
|
* Plan Entry
|
||||||
*/
|
*/
|
||||||
export interface PlanEntry {
|
export interface PlanEntry {
|
||||||
/** 条目内容 */
|
/** Entry content */
|
||||||
content: string;
|
content: string;
|
||||||
/** 优先级 */
|
/** Priority */
|
||||||
priority: 'high' | 'medium' | 'low';
|
priority: 'high' | 'medium' | 'low';
|
||||||
/** 状态 */
|
/** Status */
|
||||||
status: 'pending' | 'in_progress' | 'completed';
|
status: 'pending' | 'in_progress' | 'completed';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工具调用更新数据
|
* Tool Call Update Data
|
||||||
*/
|
*/
|
||||||
export interface ToolCallUpdateData {
|
export interface ToolCallUpdateData {
|
||||||
/** 工具调用ID */
|
/** Tool call ID */
|
||||||
toolCallId: string;
|
toolCallId: string;
|
||||||
/** 工具类型 */
|
/** Tool type */
|
||||||
kind?: string;
|
kind?: string;
|
||||||
/** 工具标题 */
|
/** Tool title */
|
||||||
title?: string;
|
title?: string;
|
||||||
/** 状态 */
|
/** Status */
|
||||||
status?: string;
|
status?: string;
|
||||||
/** 原始输入 */
|
/** Raw input */
|
||||||
rawInput?: unknown;
|
rawInput?: unknown;
|
||||||
/** 内容 */
|
/** Content */
|
||||||
content?: Array<Record<string, unknown>>;
|
content?: Array<Record<string, unknown>>;
|
||||||
/** 位置信息 */
|
/** Location information */
|
||||||
locations?: Array<{ path: string; line?: number | null }>;
|
locations?: Array<{ path: string; line?: number | null }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回调函数集合
|
* Callback Functions Collection
|
||||||
*/
|
*/
|
||||||
export interface QwenAgentCallbacks {
|
export interface QwenAgentCallbacks {
|
||||||
/** 消息回调 */
|
/** Message callback */
|
||||||
onMessage?: (message: ChatMessage) => void;
|
onMessage?: (message: ChatMessage) => void;
|
||||||
/** 流式文本块回调 */
|
/** Stream text chunk callback */
|
||||||
onStreamChunk?: (chunk: string) => void;
|
onStreamChunk?: (chunk: string) => void;
|
||||||
/** 思考文本块回调 */
|
/** Thought text chunk callback */
|
||||||
onThoughtChunk?: (chunk: string) => void;
|
onThoughtChunk?: (chunk: string) => void;
|
||||||
/** 工具调用回调 */
|
/** Tool call callback */
|
||||||
onToolCall?: (update: ToolCallUpdateData) => void;
|
onToolCall?: (update: ToolCallUpdateData) => void;
|
||||||
/** 计划回调 */
|
/** Plan callback */
|
||||||
onPlan?: (entries: PlanEntry[]) => void;
|
onPlan?: (entries: PlanEntry[]) => void;
|
||||||
/** 权限请求回调 */
|
/** Permission request callback */
|
||||||
onPermissionRequest?: (request: AcpPermissionRequest) => Promise<string>;
|
onPermissionRequest?: (request: AcpPermissionRequest) => Promise<string>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import * as vscode from 'vscode';
|
|||||||
import { CliDetector } from './cliDetector.js';
|
import { CliDetector } from './cliDetector.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CLI 检测和安装处理器
|
* CLI Detection and Installation Handler
|
||||||
* 负责 Qwen CLI 的检测、安装和提示功能
|
* Responsible for detecting, installing, and prompting for Qwen CLI
|
||||||
*/
|
*/
|
||||||
export class CliInstaller {
|
export class CliInstaller {
|
||||||
/**
|
/**
|
||||||
* 检查 CLI 安装状态并发送结果到 WebView
|
* Check CLI installation status and send results to WebView
|
||||||
* @param sendToWebView 发送消息到 WebView 的回调函数
|
* @param sendToWebView Callback function to send messages to WebView
|
||||||
*/
|
*/
|
||||||
static async checkInstallation(
|
static async checkInstallation(
|
||||||
sendToWebView: (message: unknown) => void,
|
sendToWebView: (message: unknown) => void,
|
||||||
@@ -50,8 +50,8 @@ export class CliInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提示用户安装 CLI
|
* Prompt user to install CLI
|
||||||
* 显示警告消息,提供安装选项
|
* Display warning message with installation options
|
||||||
*/
|
*/
|
||||||
static async promptInstallation(): Promise<void> {
|
static async promptInstallation(): Promise<void> {
|
||||||
const selection = await vscode.window.showWarningMessage(
|
const selection = await vscode.window.showWarningMessage(
|
||||||
@@ -71,8 +71,8 @@ export class CliInstaller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装 Qwen CLI
|
* Install Qwen CLI
|
||||||
* 通过 npm 安装全局 CLI 包
|
* Install global CLI package via npm
|
||||||
*/
|
*/
|
||||||
static async install(): Promise<void> {
|
static async install(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import * as vscode from 'vscode';
|
|||||||
import { getFileName } from '../utils/webviewUtils.js';
|
import { getFileName } from '../utils/webviewUtils.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件操作处理器
|
* File Operations Handler
|
||||||
* 负责处理文件打开和 diff 查看功能
|
* Responsible for handling file opening and diff viewing functionality
|
||||||
*/
|
*/
|
||||||
export class FileOperations {
|
export class FileOperations {
|
||||||
/**
|
/**
|
||||||
* 打开文件并可选跳转到指定行和列
|
* Open file and optionally navigate to specified line and column
|
||||||
* @param filePath 文件路径,可以包含行号和列号(格式:path/to/file.ts:123 或 path/to/file.ts:123:45)
|
* @param filePath File path, can include line and column numbers (format: path/to/file.ts:123 or path/to/file.ts:123:45)
|
||||||
*/
|
*/
|
||||||
static async openFile(filePath?: string): Promise<void> {
|
static async openFile(filePath?: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@@ -73,8 +73,8 @@ export class FileOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开 diff 视图比较文件变更
|
* Open diff view to compare file changes
|
||||||
* @param data Diff 数据,包含文件路径、旧内容和新内容
|
* @param data Diff data, including file path, old content, and new content
|
||||||
*/
|
*/
|
||||||
static async openDiff(data?: {
|
static async openDiff(data?: {
|
||||||
path?: string;
|
path?: string;
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import type { ConversationStore } from '../storage/conversationStore.js';
|
|||||||
import { MessageRouter } from './handlers/MessageRouter.js';
|
import { MessageRouter } from './handlers/MessageRouter.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MessageHandler (重构版)
|
* MessageHandler (Refactored Version)
|
||||||
* 这是一个轻量级的包装类,内部使用 MessageRouter 和各个子处理器
|
* This is a lightweight wrapper class that internally uses MessageRouter and various sub-handlers
|
||||||
* 保持与原有代码的接口兼容性
|
* Maintains interface compatibility with the original code
|
||||||
*/
|
*/
|
||||||
export class MessageHandler {
|
export class MessageHandler {
|
||||||
private router: MessageRouter;
|
private router: MessageRouter;
|
||||||
@@ -31,28 +31,28 @@ export class MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由消息到对应的处理器
|
* Route messages to the corresponding handler
|
||||||
*/
|
*/
|
||||||
async route(message: { type: string; data?: unknown }): Promise<void> {
|
async route(message: { type: string; data?: unknown }): Promise<void> {
|
||||||
await this.router.route(message);
|
await this.router.route(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置当前会话 ID
|
* Set current session ID
|
||||||
*/
|
*/
|
||||||
setCurrentConversationId(id: string | null): void {
|
setCurrentConversationId(id: string | null): void {
|
||||||
this.router.setCurrentConversationId(id);
|
this.router.setCurrentConversationId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前会话 ID
|
* Get current session ID
|
||||||
*/
|
*/
|
||||||
getCurrentConversationId(): string | null {
|
getCurrentConversationId(): string | null {
|
||||||
return this.router.getCurrentConversationId();
|
return this.router.getCurrentConversationId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置权限处理器
|
* Set permission handler
|
||||||
*/
|
*/
|
||||||
setPermissionHandler(
|
setPermissionHandler(
|
||||||
handler: (message: { type: string; data: { optionId: string } }) => void,
|
handler: (message: { type: string; data: { optionId: string } }) => void,
|
||||||
@@ -61,21 +61,21 @@ export class MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置登录处理器
|
* Set login handler
|
||||||
*/
|
*/
|
||||||
setLoginHandler(handler: () => Promise<void>): void {
|
setLoginHandler(handler: () => Promise<void>): void {
|
||||||
this.router.setLoginHandler(handler);
|
this.router.setLoginHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 追加流式内容
|
* Append stream content
|
||||||
*/
|
*/
|
||||||
appendStreamContent(chunk: string): void {
|
appendStreamContent(chunk: string): void {
|
||||||
this.router.appendStreamContent(chunk);
|
this.router.appendStreamContent(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否正在保存 checkpoint
|
* Check if saving checkpoint
|
||||||
*/
|
*/
|
||||||
getIsSavingCheckpoint(): boolean {
|
getIsSavingCheckpoint(): boolean {
|
||||||
return this.router.getIsSavingCheckpoint();
|
return this.router.getIsSavingCheckpoint();
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Panel 和 Tab 管理器
|
* Panel and Tab Manager
|
||||||
* 负责管理 WebView Panel 的创建、显示和 Tab 跟踪
|
* Responsible for managing the creation, display, and tab tracking of WebView Panels
|
||||||
*/
|
*/
|
||||||
export class PanelManager {
|
export class PanelManager {
|
||||||
private panel: vscode.WebviewPanel | null = null;
|
private panel: vscode.WebviewPanel | null = null;
|
||||||
@@ -20,14 +20,14 @@ export class PanelManager {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前的 Panel
|
* Get the current Panel
|
||||||
*/
|
*/
|
||||||
getPanel(): vscode.WebviewPanel | null {
|
getPanel(): vscode.WebviewPanel | null {
|
||||||
return this.panel;
|
return this.panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 Panel(用于恢复)
|
* Set Panel (for restoration)
|
||||||
*/
|
*/
|
||||||
setPanel(panel: vscode.WebviewPanel): void {
|
setPanel(panel: vscode.WebviewPanel): void {
|
||||||
console.log('[PanelManager] Setting panel for restoration');
|
console.log('[PanelManager] Setting panel for restoration');
|
||||||
@@ -35,8 +35,8 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建新的 WebView Panel
|
* Create new WebView Panel
|
||||||
* @returns 是否是新创建的 Panel
|
* @returns Whether it is a newly created Panel
|
||||||
*/
|
*/
|
||||||
async createPanel(): Promise<boolean> {
|
async createPanel(): Promise<boolean> {
|
||||||
if (this.panel) {
|
if (this.panel) {
|
||||||
@@ -126,8 +126,8 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找已存在的 Qwen Code webview 所在的 group 和 view column
|
* Find the group and view column where the existing Qwen Code webview is located
|
||||||
* @returns 找到的 group 和 view column,如果没有则返回 undefined
|
* @returns The found group and view column, or undefined if not found
|
||||||
*/
|
*/
|
||||||
private findExistingQwenCodeGroup():
|
private findExistingQwenCodeGroup():
|
||||||
| { group: vscode.TabGroup; viewColumn: vscode.ViewColumn }
|
| { group: vscode.TabGroup; viewColumn: vscode.ViewColumn }
|
||||||
@@ -160,8 +160,8 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动锁定编辑器组(仅在新创建 Panel 时调用)
|
* Auto-lock editor group (only called when creating a new Panel)
|
||||||
* 注意:我们不再自动锁定 Qwen Code group,以允许用户创建多个 Qwen Code tab
|
* Note: We no longer auto-lock Qwen Code group to allow users to create multiple Qwen Code tabs
|
||||||
*/
|
*/
|
||||||
async autoLockEditorGroup(): Promise<void> {
|
async autoLockEditorGroup(): Promise<void> {
|
||||||
if (!this.panel) {
|
if (!this.panel) {
|
||||||
@@ -175,8 +175,8 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示 Panel(如果存在则 reveal,否则什么都不做)
|
* Show Panel (reveal if exists, otherwise do nothing)
|
||||||
* @param preserveFocus 是否保持焦点
|
* @param preserveFocus Whether to preserve focus
|
||||||
*/
|
*/
|
||||||
revealPanel(preserveFocus: boolean = true): void {
|
revealPanel(preserveFocus: boolean = true): void {
|
||||||
if (this.panel) {
|
if (this.panel) {
|
||||||
@@ -185,8 +185,8 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 捕获与 WebView Panel 对应的 Tab
|
* Capture the Tab corresponding to the WebView Panel
|
||||||
* 用于跟踪和管理 Tab 状态
|
* Used for tracking and managing Tab state
|
||||||
*/
|
*/
|
||||||
captureTab(): void {
|
captureTab(): void {
|
||||||
if (!this.panel) {
|
if (!this.panel) {
|
||||||
@@ -211,8 +211,8 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册 Panel 的 dispose 事件处理器
|
* Register the dispose event handler for the Panel
|
||||||
* @param disposables 用于存储 Disposable 的数组
|
* @param disposables Array used to store Disposable objects
|
||||||
*/
|
*/
|
||||||
registerDisposeHandler(disposables: vscode.Disposable[]): void {
|
registerDisposeHandler(disposables: vscode.Disposable[]): void {
|
||||||
if (!this.panel) {
|
if (!this.panel) {
|
||||||
@@ -231,8 +231,8 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册视图状态变化事件处理器
|
* Register the view state change event handler
|
||||||
* @param disposables 用于存储 Disposable 的数组
|
* @param disposables Array used to store Disposable objects
|
||||||
*/
|
*/
|
||||||
registerViewStateChangeHandler(disposables: vscode.Disposable[]): void {
|
registerViewStateChangeHandler(disposables: vscode.Disposable[]): void {
|
||||||
if (!this.panel) {
|
if (!this.panel) {
|
||||||
@@ -251,7 +251,7 @@ export class PanelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁 Panel
|
* Dispose Panel
|
||||||
*/
|
*/
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
this.panel?.dispose();
|
this.panel?.dispose();
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ import * as vscode from 'vscode';
|
|||||||
import { escapeHtml } from '../utils/webviewUtils.js';
|
import { escapeHtml } from '../utils/webviewUtils.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebView HTML 内容生成器
|
* WebView HTML Content Generator
|
||||||
* 负责生成 WebView 的 HTML 内容
|
* Responsible for generating the HTML content of the WebView
|
||||||
*/
|
*/
|
||||||
export class WebViewContent {
|
export class WebViewContent {
|
||||||
/**
|
/**
|
||||||
* 生成 WebView 的 HTML 内容
|
* Generate HTML content for the WebView
|
||||||
* @param panel WebView Panel
|
* @param panel WebView Panel
|
||||||
* @param extensionUri 扩展的 URI
|
* @param extensionUri Extension URI
|
||||||
* @returns HTML 字符串
|
* @returns HTML string
|
||||||
*/
|
*/
|
||||||
static generate(
|
static generate(
|
||||||
panel: vscode.WebviewPanel,
|
panel: vscode.WebviewPanel,
|
||||||
@@ -29,7 +29,7 @@ export class WebViewContent {
|
|||||||
// Convert extension URI for webview access - this allows frontend to construct resource paths
|
// Convert extension URI for webview access - this allows frontend to construct resource paths
|
||||||
const extensionUriForWebview = panel.webview.asWebviewUri(extensionUri);
|
const extensionUriForWebview = panel.webview.asWebviewUri(extensionUri);
|
||||||
|
|
||||||
// 对 URI 进行 HTML 转义以防止潜在的注入攻击
|
// Escape URI for HTML to prevent potential injection attacks
|
||||||
const safeExtensionUri = escapeHtml(extensionUriForWebview.toString());
|
const safeExtensionUri = escapeHtml(extensionUriForWebview.toString());
|
||||||
const safeScriptUri = escapeHtml(scriptUri.toString());
|
const safeScriptUri = escapeHtml(scriptUri.toString());
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ export class WebViewProvider {
|
|||||||
constructor(
|
constructor(
|
||||||
context: vscode.ExtensionContext,
|
context: vscode.ExtensionContext,
|
||||||
private extensionUri: vscode.Uri,
|
private extensionUri: vscode.Uri,
|
||||||
authStateManager?: AuthStateManager, // 可选的全局AuthStateManager实例
|
authStateManager?: AuthStateManager, // Optional global AuthStateManager instance
|
||||||
) {
|
) {
|
||||||
this.agentManager = new QwenAgentManager();
|
this.agentManager = new QwenAgentManager();
|
||||||
this.conversationStore = new ConversationStore(context);
|
this.conversationStore = new ConversationStore(context);
|
||||||
// 如果提供了全局的authStateManager,则使用它,否则创建新的实例
|
// If a global authStateManager is provided, use it, otherwise create a new instance
|
||||||
this.authStateManager = authStateManager || new AuthStateManager(context);
|
this.authStateManager = authStateManager || new AuthStateManager(context);
|
||||||
this.panelManager = new PanelManager(extensionUri, () => {
|
this.panelManager = new PanelManager(extensionUri, () => {
|
||||||
// Panel dispose callback
|
// Panel dispose callback
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export const useSessionManagement = (vscode: VSCodeAPI) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理Save session响应
|
* Handle Save session response
|
||||||
*/
|
*/
|
||||||
const handleSaveSessionResponse = useCallback(
|
const handleSaveSessionResponse = useCallback(
|
||||||
(response: { success: boolean; message?: string }) => {
|
(response: { success: boolean; message?: string }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user