mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-22 08:53:46 +08:00
✨ feat(ai-chat): 新增上下文探针并拆分输入区组件
- 新增 inspect_ai_context 内置工具与系统提示引导 - 拆分 AIChatInput 的上下文、附件、提示条和斜杠命令模块 - 补充工具目录、执行器与输入区相关测试
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { DBGetAllColumns, DBGetDatabases, DBGetTables } from '../../../wailsjs/go/app/App';
|
||||
|
||||
import type { SqlLog } from '../../store';
|
||||
import type { AIChatMessage, AIMCPToolDescriptor, AIToolCall, SavedConnection, TabData } from '../../types';
|
||||
import type { AIChatMessage, AIContextItem, AIMCPToolDescriptor, AIToolCall, SavedConnection, TabData } from '../../types';
|
||||
import { buildRpcConnectionConfig } from '../../utils/connectionRpcConfig';
|
||||
import { buildAIReadonlyPreviewSQL } from '../../utils/aiSqlLimit';
|
||||
import { buildPaginatedSelectSQL, quoteQualifiedIdent } from '../../utils/sql';
|
||||
import { resolveAITableSchemaToolResult } from '../../utils/aiTableSchemaTool';
|
||||
import { buildAIContextSnapshot } from './aiContextInsights';
|
||||
import {
|
||||
buildActiveTabSnapshot,
|
||||
buildRecentSqlLogsSnapshot,
|
||||
@@ -35,6 +36,8 @@ interface AILocalToolRuntime {
|
||||
export interface ExecuteLocalAIToolCallOptions {
|
||||
toolCall: AIToolCall;
|
||||
connections: SavedConnection[];
|
||||
activeContext?: { connectionId: string; dbName: string } | null;
|
||||
aiContexts?: Record<string, AIContextItem[]>;
|
||||
tabs?: TabData[];
|
||||
activeTabId?: string | null;
|
||||
mcpTools: AIMCPToolDescriptor[];
|
||||
@@ -160,6 +163,8 @@ const buildPreviewSQLForTable = (connection: SavedConnection, tableName: string,
|
||||
export async function executeLocalAIToolCall({
|
||||
toolCall,
|
||||
connections,
|
||||
activeContext = null,
|
||||
aiContexts = {},
|
||||
tabs = [],
|
||||
activeTabId = null,
|
||||
mcpTools,
|
||||
@@ -204,6 +209,21 @@ export async function executeLocalAIToolCall({
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'inspect_ai_context': {
|
||||
try {
|
||||
content = JSON.stringify(buildAIContextSnapshot({
|
||||
activeContext,
|
||||
aiContexts,
|
||||
connections,
|
||||
includeDDL: args.includeDDL === true,
|
||||
ddlLimit: args.ddlLimit,
|
||||
}));
|
||||
success = true;
|
||||
} catch (error: any) {
|
||||
content = `读取当前 AI 上下文失败: ${error?.message || error}`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'get_connections': {
|
||||
const availableConnections = connections.map((connection) => ({
|
||||
id: connection.id,
|
||||
|
||||
Reference in New Issue
Block a user