@vtj/designer 0.18.29 → 0.19.1
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/Editor-BC5UMWRY.js +4 -0
- package/dist/{css.worker-IZUCUZQ_.js → css.worker--aXH2aPB.js} +7 -7
- package/dist/editor.worker-Bi14wvgY.js +25 -0
- package/dist/html.worker-Ck_eCw9C.js +25 -0
- package/dist/{index-COfzXcr2.js → index-eE76U6YW.js} +13432 -14941
- package/dist/index.mjs +1 -1
- package/dist/json.worker-DyfNKmEG.js +25 -0
- package/dist/style.css +1 -1
- package/dist/{ts.worker-DaMuWc1v.js → ts.worker-BRcnI7fF.js} +63 -63
- package/package.json +8 -8
- package/types/components/hooks/index.d.ts +0 -2
- package/types/components/hooks/useOpenApi.d.ts +2 -0
- package/types/components/shared/binder.d.ts +2 -2
- package/types/components/widgets/agent/architect-plan.d.ts +23 -0
- package/types/components/widgets/agent/composables/useAgentApi.d.ts +37 -0
- package/types/components/widgets/agent/composables/useArchitectPlan.d.ts +7 -0
- package/types/components/widgets/agent/composables/useAuth.d.ts +7 -0
- package/types/components/widgets/agent/composables/useAutoScroll.d.ts +13 -0
- package/types/components/widgets/agent/composables/useDualAgent.d.ts +15 -0
- package/types/components/widgets/agent/composables/useEditorStep.d.ts +4 -0
- package/types/components/widgets/agent/composables/useFileRecognition.d.ts +46 -0
- package/types/components/widgets/agent/composables/useReplayChat.d.ts +5 -0
- package/types/components/widgets/agent/composables/useSSEStream.d.ts +7 -0
- package/types/components/widgets/agent/constants.d.ts +16 -0
- package/types/components/widgets/agent/conversation-round.d.ts +26 -0
- package/types/components/widgets/{ai → agent}/detail.d.ts +10 -9
- package/types/components/widgets/agent/editor-step.d.ts +22 -0
- package/types/components/widgets/agent/index.d.ts +21 -0
- package/types/components/widgets/{ai → agent}/invite-tip.d.ts +1 -1
- package/types/components/widgets/agent/message-input.d.ts +35 -0
- package/types/components/widgets/{ai → agent}/pay-tip.d.ts +4 -2
- package/types/components/widgets/agent/records.d.ts +18 -0
- package/types/components/widgets/{ai → agent}/stream-markdown.d.ts +2 -2
- package/types/components/widgets/agent/summary.d.ts +19 -0
- package/types/components/widgets/agent/types/agent.d.ts +346 -0
- package/types/components/widgets/agent/utils/approval.d.ts +10 -0
- package/types/components/widgets/agent/utils/breakpoint.d.ts +2 -0
- package/types/components/widgets/agent/utils/chat.d.ts +10 -0
- package/types/components/widgets/agent/utils/export.d.ts +4 -0
- package/types/components/widgets/agent/utils/filePrompt.d.ts +9 -0
- package/types/components/widgets/agent/utils/genId.d.ts +4 -0
- package/types/components/widgets/agent/utils/index.d.ts +6 -0
- package/types/components/widgets/agent/utils/json.d.ts +18 -0
- package/types/components/widgets/agent/utils/markdown.d.ts +1 -0
- package/types/components/widgets/agent/utils/messages.d.ts +185 -0
- package/types/components/widgets/agent/utils/outputParser.d.ts +24 -0
- package/types/components/widgets/agent/utils/plan.d.ts +7 -0
- package/types/components/widgets/agent/utils/request.d.ts +1 -0
- package/types/components/widgets/agent/utils/response.d.ts +25 -0
- package/types/components/widgets/agent/utils/resume.d.ts +7 -0
- package/types/components/widgets/agent/utils/summary.d.ts +2 -0
- package/types/components/widgets/agent/utils/toolExecutor.d.ts +23 -0
- package/types/components/widgets/apis/form.d.ts +2 -2
- package/types/components/widgets/apis/swagger.d.ts +1 -1
- package/types/components/widgets/devtools/index.d.ts +1 -1
- package/types/components/widgets/env/index.d.ts +1 -1
- package/types/components/widgets/i18n/index.d.ts +1 -1
- package/types/components/widgets/index.d.ts +20 -673
- package/types/framework/ToolRegistry.d.ts +4 -0
- package/types/framework/engine.d.ts +2 -1
- package/types/framework/openapi.d.ts +4 -0
- package/types/framework/types.d.ts +2 -0
- package/types/version.d.ts +2 -2
- package/dist/Editor-Ce3ItXi1.js +0 -4
- package/dist/editor.worker-BzVsh9i0.js +0 -25
- package/dist/html.worker-BXHIYJhq.js +0 -25
- package/dist/json.worker-3UoNfmKv.js +0 -25
- package/types/components/hooks/useAI.d.ts +0 -236
- package/types/components/hooks/useAgent.d.ts +0 -17
- package/types/components/widgets/ai/avatar.d.ts +0 -3
- package/types/components/widgets/ai/bubble.d.ts +0 -26
- package/types/components/widgets/ai/chat-input.d.ts +0 -29
- package/types/components/widgets/ai/image-input.d.ts +0 -155
- package/types/components/widgets/ai/index.d.ts +0 -677
- package/types/components/widgets/ai/json-input.d.ts +0 -342
- package/types/components/widgets/ai/new-topic.d.ts +0 -23
- package/types/components/widgets/ai/records.d.ts +0 -18
- /package/types/components/widgets/{ai → agent}/login-tip.d.ts +0 -0
- /package/types/components/widgets/{ai → agent}/model-dialog.d.ts +0 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { Engine, TopicDto, ChatDto } from '../../../../framework';
|
|
3
|
+
import { Access } from '@vtj/renderer';
|
|
4
|
+
import { AgentStatusMessage } from '../utils/messages';
|
|
5
|
+
/** SSE 数据块(与框架 CompletionChunk 结构兼容,含服务端扩展的 vtj 字段) */
|
|
6
|
+
export interface SSEChunkData {
|
|
7
|
+
id?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
choices?: Array<{
|
|
10
|
+
delta?: {
|
|
11
|
+
content?: string | null;
|
|
12
|
+
reasoning_content?: string | null;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
usage?: {
|
|
16
|
+
prompt_tokens?: number;
|
|
17
|
+
completion_tokens?: number;
|
|
18
|
+
total_tokens?: number;
|
|
19
|
+
} | null;
|
|
20
|
+
vtj?: {
|
|
21
|
+
model?: string;
|
|
22
|
+
agent?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** SSE 流完成结果 */
|
|
26
|
+
export interface StreamCompletionResult {
|
|
27
|
+
done: () => void;
|
|
28
|
+
reasoning: string;
|
|
29
|
+
usage: {
|
|
30
|
+
prompt_tokens?: number;
|
|
31
|
+
completion_tokens?: number;
|
|
32
|
+
total_tokens?: number;
|
|
33
|
+
} | null;
|
|
34
|
+
modelUsed: string;
|
|
35
|
+
/** reasoning 阶段持续时间(毫秒) */
|
|
36
|
+
reasoningTime: number;
|
|
37
|
+
}
|
|
38
|
+
/** 计划步骤 */
|
|
39
|
+
export interface PlanStep {
|
|
40
|
+
id: string;
|
|
41
|
+
type: 'tool_call' | 'vue_code' | 'diff' | 'text';
|
|
42
|
+
description: string;
|
|
43
|
+
target?: string;
|
|
44
|
+
toolName?: string;
|
|
45
|
+
/** 步骤依赖(服务端 HarnessPlan 协议字段,透传保留) */
|
|
46
|
+
dependsOn?: string[];
|
|
47
|
+
}
|
|
48
|
+
/** Architect 返回的计划 */
|
|
49
|
+
export interface PlanResult {
|
|
50
|
+
intent: string;
|
|
51
|
+
safety: 'readonly' | 'write' | 'destructive';
|
|
52
|
+
steps: PlanStep[];
|
|
53
|
+
answer?: string;
|
|
54
|
+
/** 计划上下文键(服务端 HarnessPlan 协议字段,透传保留) */
|
|
55
|
+
contextKeys?: string[];
|
|
56
|
+
}
|
|
57
|
+
/** Editor 每轮对话信息 */
|
|
58
|
+
export interface EditorTurn {
|
|
59
|
+
turn: number;
|
|
60
|
+
type: string;
|
|
61
|
+
content: string;
|
|
62
|
+
reasoning: string;
|
|
63
|
+
/** Vue/Diff 执行后的最终源码与 DSL */
|
|
64
|
+
vue?: string;
|
|
65
|
+
dsl?: Record<string, any>;
|
|
66
|
+
prompt?: string;
|
|
67
|
+
toolAction?: string;
|
|
68
|
+
toolParams?: unknown[];
|
|
69
|
+
toolResult?: {
|
|
70
|
+
success: boolean;
|
|
71
|
+
result?: unknown;
|
|
72
|
+
error?: string;
|
|
73
|
+
duration: number;
|
|
74
|
+
};
|
|
75
|
+
resultSummary?: string;
|
|
76
|
+
approval?: {
|
|
77
|
+
id: string;
|
|
78
|
+
action: string;
|
|
79
|
+
risk: 'write' | 'destructive';
|
|
80
|
+
status: 'pending' | 'approved' | 'rejected';
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Editor 步骤执行结果(UI 展示用) */
|
|
84
|
+
export interface EditorStepResult {
|
|
85
|
+
stepIdx: number;
|
|
86
|
+
step: PlanStep;
|
|
87
|
+
content: string;
|
|
88
|
+
reasoning: string;
|
|
89
|
+
error: string | null;
|
|
90
|
+
done: boolean;
|
|
91
|
+
turns: EditorTurn[];
|
|
92
|
+
tokens?: number;
|
|
93
|
+
duration?: number;
|
|
94
|
+
/** 取消时产生的未完成槽位标记(断点恢复时定位用) */
|
|
95
|
+
aborted?: boolean;
|
|
96
|
+
}
|
|
97
|
+
/** 步骤执行返回值(内部使用) */
|
|
98
|
+
export interface StepExecutionResult {
|
|
99
|
+
content: string;
|
|
100
|
+
error: string | null;
|
|
101
|
+
tokens: number;
|
|
102
|
+
duration: number;
|
|
103
|
+
toolResult?: {
|
|
104
|
+
action: string;
|
|
105
|
+
result: unknown;
|
|
106
|
+
} | null;
|
|
107
|
+
}
|
|
108
|
+
/** 步骤记录(用于总结和 trace) */
|
|
109
|
+
export interface StepRecord {
|
|
110
|
+
stepId: string;
|
|
111
|
+
type: string;
|
|
112
|
+
description: string;
|
|
113
|
+
status: 'completed' | 'failed';
|
|
114
|
+
content: string;
|
|
115
|
+
error: string | null;
|
|
116
|
+
tokens: number;
|
|
117
|
+
duration: number;
|
|
118
|
+
}
|
|
119
|
+
/** 附件展示信息(不含识别描述,描述仅用于提交请求) */
|
|
120
|
+
export interface AttachmentInfo {
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
type: 'image' | 'json';
|
|
124
|
+
/** 文件访问 URL(本地相对路径或 OSS 完整地址) */
|
|
125
|
+
url?: string;
|
|
126
|
+
}
|
|
127
|
+
/** 一轮完整的 Architect → Editor → Summary 对话 */
|
|
128
|
+
export interface ConversationRound {
|
|
129
|
+
id: string;
|
|
130
|
+
userMessage: string;
|
|
131
|
+
/** Architect 对应的 chats 表记录 ID,重试时复用避免重复插入 */
|
|
132
|
+
architectChatId: string;
|
|
133
|
+
architectPlan: PlanResult | null;
|
|
134
|
+
architectAnswer: string;
|
|
135
|
+
architectStreamText: string;
|
|
136
|
+
reasoningText: string;
|
|
137
|
+
/** Architect 规划失败原因(大模型输出无效/异常时记录,UI 与导出展示) */
|
|
138
|
+
architectError?: string;
|
|
139
|
+
/** Architect 规划自动重试次数(大模型输出无效时自动重发) */
|
|
140
|
+
architectRetryCount?: number;
|
|
141
|
+
editorResults: EditorStepResult[];
|
|
142
|
+
summaryText: string;
|
|
143
|
+
summaryReasoning: string;
|
|
144
|
+
summaryError: string;
|
|
145
|
+
summaryAttempt: number;
|
|
146
|
+
/** 附件快照(气泡展示用,与输入框 files 解耦) */
|
|
147
|
+
attachments?: AttachmentInfo[];
|
|
148
|
+
/** 实际提交后端的完整 prompt(含文件识别描述),重试时复用 */
|
|
149
|
+
promptSent?: string;
|
|
150
|
+
}
|
|
151
|
+
/** 导出数据结构 */
|
|
152
|
+
export interface ExportData {
|
|
153
|
+
exportTime: string;
|
|
154
|
+
topicId: string;
|
|
155
|
+
model: string;
|
|
156
|
+
userMessage: string;
|
|
157
|
+
/** 所有对话轮次 */
|
|
158
|
+
rounds?: ExportRound[];
|
|
159
|
+
}
|
|
160
|
+
/** 导出单轮数据 */
|
|
161
|
+
export interface ExportRound {
|
|
162
|
+
userMessage: string;
|
|
163
|
+
architect?: {
|
|
164
|
+
reasoning: string | null;
|
|
165
|
+
output: string | null;
|
|
166
|
+
plan: PlanResult | null;
|
|
167
|
+
answer: string | null;
|
|
168
|
+
};
|
|
169
|
+
steps: ExportedStep[];
|
|
170
|
+
summary?: string;
|
|
171
|
+
/** 总结生成错误信息 */
|
|
172
|
+
summaryError?: string;
|
|
173
|
+
/** Architect 规划失败原因 */
|
|
174
|
+
architectError?: string;
|
|
175
|
+
/** 本轮错误信息 */
|
|
176
|
+
error?: string;
|
|
177
|
+
}
|
|
178
|
+
/** 导出的步骤数据 */
|
|
179
|
+
export interface ExportedStep {
|
|
180
|
+
index: number;
|
|
181
|
+
stepId: string;
|
|
182
|
+
description: string;
|
|
183
|
+
type: string;
|
|
184
|
+
status: 'failed' | 'completed' | 'executing';
|
|
185
|
+
error: string | null;
|
|
186
|
+
turns: ExportedTurn[];
|
|
187
|
+
}
|
|
188
|
+
/** 导出的轮次数据 */
|
|
189
|
+
export interface ExportedTurn {
|
|
190
|
+
turn: number;
|
|
191
|
+
type: string;
|
|
192
|
+
prompt: string | null;
|
|
193
|
+
output: string;
|
|
194
|
+
reasoning?: string;
|
|
195
|
+
toolCall?: {
|
|
196
|
+
action: string;
|
|
197
|
+
parameters: unknown[] | null;
|
|
198
|
+
result?: {
|
|
199
|
+
success: boolean;
|
|
200
|
+
result: unknown;
|
|
201
|
+
error: unknown;
|
|
202
|
+
duration: number;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
resultSummary?: string;
|
|
206
|
+
}
|
|
207
|
+
/** 创建话题请求体(扩展自框架 TopicDto) */
|
|
208
|
+
export interface AgentTopicBody extends TopicDto {
|
|
209
|
+
agent?: 'architect' | 'editor';
|
|
210
|
+
userId?: string;
|
|
211
|
+
userName?: string;
|
|
212
|
+
files?: string;
|
|
213
|
+
requestId?: string;
|
|
214
|
+
}
|
|
215
|
+
/** 创建聊天请求体(扩展自框架 ChatDto) */
|
|
216
|
+
export interface AgentChatBody extends ChatDto {
|
|
217
|
+
agent?: 'architect' | 'editor';
|
|
218
|
+
stepId?: string;
|
|
219
|
+
attempt?: number;
|
|
220
|
+
userId?: string;
|
|
221
|
+
userName?: string;
|
|
222
|
+
files?: string;
|
|
223
|
+
requestId?: string;
|
|
224
|
+
}
|
|
225
|
+
/** 保存聊天记录请求体(chats 表字段) */
|
|
226
|
+
export interface SaveChatBody {
|
|
227
|
+
id: string;
|
|
228
|
+
topicId: string;
|
|
229
|
+
userId: string;
|
|
230
|
+
status?: string;
|
|
231
|
+
content?: string;
|
|
232
|
+
reasoning?: string;
|
|
233
|
+
modelUsed?: string;
|
|
234
|
+
tokens?: number;
|
|
235
|
+
tokensPrompt?: number;
|
|
236
|
+
tokensCompletion?: number;
|
|
237
|
+
thinking?: number;
|
|
238
|
+
toolCallId?: string;
|
|
239
|
+
toolContent?: string;
|
|
240
|
+
vue?: string;
|
|
241
|
+
dsl?: string;
|
|
242
|
+
source?: string;
|
|
243
|
+
}
|
|
244
|
+
/** 更新话题请求体 */
|
|
245
|
+
export interface UpdateTopicBody {
|
|
246
|
+
id: string;
|
|
247
|
+
status?: string;
|
|
248
|
+
planJson?: PlanResult | null;
|
|
249
|
+
traceId?: string;
|
|
250
|
+
currentStepId?: string;
|
|
251
|
+
}
|
|
252
|
+
/** 保存 trace 请求体 */
|
|
253
|
+
export interface SaveTraceBody {
|
|
254
|
+
traceId: string;
|
|
255
|
+
topicId: string;
|
|
256
|
+
planJson: PlanResult | null;
|
|
257
|
+
stepsJson: StepRecord[];
|
|
258
|
+
finalStatus: 'failed' | 'completed';
|
|
259
|
+
totalTokens: number;
|
|
260
|
+
totalDuration: number;
|
|
261
|
+
}
|
|
262
|
+
/** 基础设施依赖 */
|
|
263
|
+
export interface DualAgentInfrastructure {
|
|
264
|
+
token: Ref<string>;
|
|
265
|
+
model: Ref<string>;
|
|
266
|
+
existingTopicId: Ref<string>;
|
|
267
|
+
setTopicId: (id: string) => void;
|
|
268
|
+
getEngine: () => Engine | null;
|
|
269
|
+
registerTools: () => void;
|
|
270
|
+
abortSse: () => void;
|
|
271
|
+
access?: Access;
|
|
272
|
+
setStatus: (message: AgentStatusMessage) => void;
|
|
273
|
+
}
|
|
274
|
+
/** API 依赖 */
|
|
275
|
+
export interface DualAgentApi {
|
|
276
|
+
postTopic: (body: AgentTopicBody) => Promise<any>;
|
|
277
|
+
postChat: (body: AgentChatBody) => Promise<any>;
|
|
278
|
+
executeArchitectPlan: (topicId: string, architectChatId: string, userId: string, traceId: string, userMessage: string, round: ConversationRound, signal?: AbortSignal) => Promise<void>;
|
|
279
|
+
retryEditorPlan: (topicId: string, userId: string, traceId: string, userMessage: string, round: ConversationRound, stepIndex: number, signal?: AbortSignal) => Promise<void>;
|
|
280
|
+
resumeEditorPlan: (topicId: string, userId: string, traceId: string, userMessage: string, round: ConversationRound, signal?: AbortSignal) => Promise<void>;
|
|
281
|
+
retrySummary: (topicId: string, userId: string, traceId: string, userMessage: string, round: ConversationRound, signal?: AbortSignal) => Promise<void>;
|
|
282
|
+
}
|
|
283
|
+
/** 对话状态 */
|
|
284
|
+
export interface DualAgentState {
|
|
285
|
+
conversationRounds: Ref<ConversationRound[]>;
|
|
286
|
+
}
|
|
287
|
+
/** Editor 步骤执行依赖 */
|
|
288
|
+
export interface EditorStepDeps {
|
|
289
|
+
streamCompletion: (topicId: string, chatId: string, onChunk?: (text: string) => void, onReasoning?: (text: string) => void) => Promise<StreamCompletionResult>;
|
|
290
|
+
postChat: (body: AgentChatBody) => Promise<any>;
|
|
291
|
+
saveChat: (body: SaveChatBody) => Promise<any>;
|
|
292
|
+
updateTopic: (body: UpdateTopicBody) => Promise<any>;
|
|
293
|
+
getEngine: () => Engine | null;
|
|
294
|
+
setStatus: (message: AgentStatusMessage) => void;
|
|
295
|
+
requestApproval: (id: string) => Promise<boolean>;
|
|
296
|
+
}
|
|
297
|
+
/** Architect 规划执行依赖 */
|
|
298
|
+
export interface ArchitectPlanDeps {
|
|
299
|
+
streamCompletion: (topicId: string, chatId: string, onChunk?: (text: string) => void, onReasoning?: (text: string) => void) => Promise<StreamCompletionResult>;
|
|
300
|
+
postChat: (body: AgentChatBody) => Promise<any>;
|
|
301
|
+
saveChat: (body: SaveChatBody) => Promise<any>;
|
|
302
|
+
updateTopic: (body: UpdateTopicBody) => Promise<any>;
|
|
303
|
+
saveTrace: (body: SaveTraceBody) => Promise<any>;
|
|
304
|
+
setStatus: (message: AgentStatusMessage) => void;
|
|
305
|
+
executeEditorStep: (topicId: string, userId: string, step: PlanStep, stepIdx: number, allSteps: PlanStep[], stepStart: number, editorResults: EditorStepResult[], signal?: AbortSignal, retrySlot?: EditorStepResult) => Promise<StepExecutionResult>;
|
|
306
|
+
}
|
|
307
|
+
/** 后端返回的 chat 记录(transformChat 后格式) */
|
|
308
|
+
export interface ChatRecord {
|
|
309
|
+
id: string;
|
|
310
|
+
topicId: string;
|
|
311
|
+
userId: string;
|
|
312
|
+
userName: string;
|
|
313
|
+
/** 用户提示词 (原 userContent) */
|
|
314
|
+
prompt: string;
|
|
315
|
+
/** AI 回复内容 (原 assistantContent) */
|
|
316
|
+
content: string;
|
|
317
|
+
/** 推理内容 (原 reasoningContent) */
|
|
318
|
+
reasoning: string;
|
|
319
|
+
status: string;
|
|
320
|
+
/** token 用量 (原 tokenUsage) */
|
|
321
|
+
tokens: number;
|
|
322
|
+
/** 错误消息 (原 errorMessage) */
|
|
323
|
+
message: string;
|
|
324
|
+
/** 思考用时毫秒 (原 thinkingTime) */
|
|
325
|
+
thinking: number;
|
|
326
|
+
modelUsed: string;
|
|
327
|
+
agentRole: string;
|
|
328
|
+
stepId: string;
|
|
329
|
+
attempt: number;
|
|
330
|
+
tokensPrompt: number;
|
|
331
|
+
tokensCompletion: number;
|
|
332
|
+
toolCallId: string;
|
|
333
|
+
toolContent: string;
|
|
334
|
+
vue: string;
|
|
335
|
+
source: string;
|
|
336
|
+
dsl: Record<string, any> | string;
|
|
337
|
+
/** 附件信息(持久化到 chats.files) */
|
|
338
|
+
files?: AttachmentInfo[];
|
|
339
|
+
createdAt: string;
|
|
340
|
+
updatedAt: string;
|
|
341
|
+
}
|
|
342
|
+
/** 回显 composable 依赖 */
|
|
343
|
+
export interface ReplayChatDeps {
|
|
344
|
+
getChats: (topicId: string) => Promise<ChatRecord[]>;
|
|
345
|
+
setStatus: (message: AgentStatusMessage) => void;
|
|
346
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EditorTurn } from '../types/agent';
|
|
2
|
+
export type ApprovalRisk = 'write' | 'destructive';
|
|
3
|
+
export declare function createEditorTurn(turn: number): EditorTurn;
|
|
4
|
+
/**
|
|
5
|
+
* 获取工具调用的审批风险等级
|
|
6
|
+
* @param action 工具名称
|
|
7
|
+
* @param declared 工具定义中显式声明的风险等级(优先使用)
|
|
8
|
+
* @returns 需要审批时返回风险等级,无需审批(只读操作)返回 null
|
|
9
|
+
*/
|
|
10
|
+
export declare function getApprovalRisk(action: string, declared?: ApprovalRisk | null): ApprovalRisk | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SaveChatBody, StreamCompletionResult } from '../types/agent';
|
|
2
|
+
export declare function buildChatSaveBody(opts: {
|
|
3
|
+
id: string;
|
|
4
|
+
topicId: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
status?: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
result: StreamCompletionResult | null;
|
|
9
|
+
tokens?: number;
|
|
10
|
+
}): SaveChatBody;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ConversationRound } from '../types/agent';
|
|
2
|
+
/** 从轮次数据推导错误信息 */
|
|
3
|
+
export declare function deriveError(r: ConversationRound): string | undefined;
|
|
4
|
+
export declare function exportConversation(existingTopicId: string, model: string, rounds: ConversationRound[]): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件识别描述块工具
|
|
3
|
+
* useFileRecognition.buildFilePrompt 生成的描述块带剥离标记,
|
|
4
|
+
* 回显/重试时可用此工具还原用户纯文本
|
|
5
|
+
*/
|
|
6
|
+
/** 文件识别描述块(useFileRecognition.buildFilePrompt 生成的带标记格式) */
|
|
7
|
+
export declare const FILE_DESC_BLOCK_RE: RegExp;
|
|
8
|
+
/** 从 prompt 中剥离文件识别描述块,还原用户纯文本(旧数据无标记时原样返回) */
|
|
9
|
+
export declare function stripFileDescBlocks(prompt: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON 提取工具
|
|
3
|
+
* 从 LLM 混合输出中稳健地提取 JSON 对象,替代脆弱的贪婪正则 `\{[\s\S]*\}`
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 从文本中提取第一个完整的顶层 JSON 对象
|
|
7
|
+
*
|
|
8
|
+
* 策略:
|
|
9
|
+
* 1. 优先取 ```json 代码块内容
|
|
10
|
+
* 2. 回退:从第一个 `{` 开始做括号配对扫描(忽略字符串内的花括号与转义),
|
|
11
|
+
* 保证在对象之后还存在其他花括号文本时也能正确截取
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractJsonObject(text: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* 从文本中提取 JSON 并解析
|
|
16
|
+
* @returns 解析成功返回对象,失败返回 null
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseJsonObject<T = Record<string, any>>(text: string): T | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatMarkdownContent(value: unknown): string;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export type AgentStatusType = 'info' | 'warning' | 'success' | 'danger';
|
|
3
|
+
export interface AgentStatusMessage {
|
|
4
|
+
text: string;
|
|
5
|
+
type: AgentStatusType;
|
|
6
|
+
}
|
|
7
|
+
/** 写入状态文本与类型 */
|
|
8
|
+
export declare function setAgentStatus(statusText: Ref<string>, statusType: Ref<AgentStatusType>, message: AgentStatusMessage): void;
|
|
9
|
+
/** 状态写入回调(各 composable deps 统一使用,避免传递双 ref) */
|
|
10
|
+
export type StatusSetter = (message: AgentStatusMessage) => void;
|
|
11
|
+
/** 常用状态消息 */
|
|
12
|
+
export declare const Messages: {
|
|
13
|
+
tokenMissing: {
|
|
14
|
+
readonly text: "请先获取 Token";
|
|
15
|
+
readonly type: "danger";
|
|
16
|
+
};
|
|
17
|
+
promptEmpty: {
|
|
18
|
+
readonly text: "请输入消息或上传文件";
|
|
19
|
+
readonly type: "danger";
|
|
20
|
+
};
|
|
21
|
+
topicIdMissing: {
|
|
22
|
+
readonly text: "请输入 Topic ID";
|
|
23
|
+
readonly type: "danger";
|
|
24
|
+
};
|
|
25
|
+
retryTopicIdMissing: {
|
|
26
|
+
readonly text: "缺少 Topic ID,无法重试";
|
|
27
|
+
readonly type: "danger";
|
|
28
|
+
};
|
|
29
|
+
resumeTopicIdMissing: {
|
|
30
|
+
readonly text: "缺少 Topic ID,无法恢复";
|
|
31
|
+
readonly type: "danger";
|
|
32
|
+
};
|
|
33
|
+
noRetryRound: {
|
|
34
|
+
readonly text: "没有可重试的轮次";
|
|
35
|
+
readonly type: "danger";
|
|
36
|
+
};
|
|
37
|
+
noResumeRound: {
|
|
38
|
+
readonly text: "没有可恢复的轮次";
|
|
39
|
+
readonly type: "danger";
|
|
40
|
+
};
|
|
41
|
+
architectChatIdMissing: {
|
|
42
|
+
readonly text: "该轮次缺少 Architect chat ID,无法重试";
|
|
43
|
+
readonly type: "danger";
|
|
44
|
+
};
|
|
45
|
+
stepNotFailed: {
|
|
46
|
+
readonly text: "该步骤不是失败状态";
|
|
47
|
+
readonly type: "danger";
|
|
48
|
+
};
|
|
49
|
+
lockedProject: {
|
|
50
|
+
readonly text: "项目已被锁定,无法应用变更";
|
|
51
|
+
readonly type: "danger";
|
|
52
|
+
};
|
|
53
|
+
userRejectedTool: {
|
|
54
|
+
readonly text: "用户拒绝执行此操作";
|
|
55
|
+
readonly type: "danger";
|
|
56
|
+
};
|
|
57
|
+
userRejectedVue: {
|
|
58
|
+
readonly text: "用户拒绝应用 Vue 变更";
|
|
59
|
+
readonly type: "danger";
|
|
60
|
+
};
|
|
61
|
+
userRejectedDiff: {
|
|
62
|
+
readonly text: "用户拒绝应用 Diff";
|
|
63
|
+
readonly type: "danger";
|
|
64
|
+
};
|
|
65
|
+
projectNotReady: {
|
|
66
|
+
readonly text: "项目未就绪";
|
|
67
|
+
readonly type: "danger";
|
|
68
|
+
};
|
|
69
|
+
fileNotReady: {
|
|
70
|
+
readonly text: "当前文件未就绪";
|
|
71
|
+
readonly type: "danger";
|
|
72
|
+
};
|
|
73
|
+
sourceUnavailable: {
|
|
74
|
+
readonly text: "无法获取当前文件源码";
|
|
75
|
+
readonly type: "danger";
|
|
76
|
+
};
|
|
77
|
+
stepNotRetryable: {
|
|
78
|
+
readonly text: "没有可重试的失败步骤";
|
|
79
|
+
readonly type: "danger";
|
|
80
|
+
};
|
|
81
|
+
summaryNotRetryable: {
|
|
82
|
+
readonly text: "没有可重试的总结";
|
|
83
|
+
readonly type: "danger";
|
|
84
|
+
};
|
|
85
|
+
planNotResumable: {
|
|
86
|
+
readonly text: "没有可恢复的计划";
|
|
87
|
+
readonly type: "danger";
|
|
88
|
+
};
|
|
89
|
+
replayStepFailed: {
|
|
90
|
+
readonly text: "执行失败";
|
|
91
|
+
readonly type: "danger";
|
|
92
|
+
};
|
|
93
|
+
replaySummaryFailed: {
|
|
94
|
+
readonly text: "总结生成失败";
|
|
95
|
+
readonly type: "danger";
|
|
96
|
+
};
|
|
97
|
+
creatingTopic: {
|
|
98
|
+
readonly text: "创建话题 (architect)...";
|
|
99
|
+
readonly type: "info";
|
|
100
|
+
};
|
|
101
|
+
creatingArchitectChat: {
|
|
102
|
+
readonly text: "创建 Architect 聊天...";
|
|
103
|
+
readonly type: "info";
|
|
104
|
+
};
|
|
105
|
+
architectPlanning: {
|
|
106
|
+
readonly text: "Architect 规划中...";
|
|
107
|
+
readonly type: "warning";
|
|
108
|
+
};
|
|
109
|
+
retryingSummary: {
|
|
110
|
+
readonly text: "重新生成任务总结...";
|
|
111
|
+
readonly type: "warning";
|
|
112
|
+
};
|
|
113
|
+
planInvalid: {
|
|
114
|
+
readonly text: "Architect 输出异常,未生成有效计划";
|
|
115
|
+
readonly type: "danger";
|
|
116
|
+
};
|
|
117
|
+
architectAnswered: {
|
|
118
|
+
readonly text: "Architect 直接回答";
|
|
119
|
+
readonly type: "success";
|
|
120
|
+
};
|
|
121
|
+
generatingSummary: {
|
|
122
|
+
readonly text: "生成任务总结...";
|
|
123
|
+
readonly type: "warning";
|
|
124
|
+
};
|
|
125
|
+
resumedSummary: {
|
|
126
|
+
readonly text: "恢复生成任务总结...";
|
|
127
|
+
readonly type: "warning";
|
|
128
|
+
};
|
|
129
|
+
summaryRegenerated: {
|
|
130
|
+
readonly text: "任务总结已重新生成";
|
|
131
|
+
readonly type: "success";
|
|
132
|
+
};
|
|
133
|
+
summaryGenerated: {
|
|
134
|
+
readonly text: "任务总结已生成";
|
|
135
|
+
readonly type: "success";
|
|
136
|
+
};
|
|
137
|
+
retryingLastRequest: {
|
|
138
|
+
readonly text: "重试上次请求...";
|
|
139
|
+
readonly type: "warning";
|
|
140
|
+
};
|
|
141
|
+
resumingFromPrompt: {
|
|
142
|
+
readonly text: "检测到续跑意图,从断点恢复执行...";
|
|
143
|
+
readonly type: "warning";
|
|
144
|
+
};
|
|
145
|
+
cancelled: {
|
|
146
|
+
readonly text: "已取消";
|
|
147
|
+
readonly type: "info";
|
|
148
|
+
};
|
|
149
|
+
loadingHistory: {
|
|
150
|
+
readonly text: "加载历史记录...";
|
|
151
|
+
readonly type: "info";
|
|
152
|
+
};
|
|
153
|
+
historyEmpty: {
|
|
154
|
+
readonly text: "未找到交互记录";
|
|
155
|
+
readonly type: "warning";
|
|
156
|
+
};
|
|
157
|
+
replayTopicIdMissing: {
|
|
158
|
+
readonly text: "缺少 Topic ID";
|
|
159
|
+
readonly type: "danger";
|
|
160
|
+
};
|
|
161
|
+
topicCreated: (topicId: string) => AgentStatusMessage;
|
|
162
|
+
planGenerated: (intent: string) => AgentStatusMessage;
|
|
163
|
+
allStepsDone: (count: number) => AgentStatusMessage;
|
|
164
|
+
stepFailed: (index: number) => AgentStatusMessage;
|
|
165
|
+
summaryFailed: (message: string) => AgentStatusMessage;
|
|
166
|
+
cancelledWithProgress: (done: number, total: number) => AgentStatusMessage;
|
|
167
|
+
resumingStep: (step: number, total: number) => AgentStatusMessage;
|
|
168
|
+
retryingStep: (index: number) => AgentStatusMessage;
|
|
169
|
+
retryArchitect: (label: string) => AgentStatusMessage;
|
|
170
|
+
architectRetrying: (attempt: number, max: number) => AgentStatusMessage;
|
|
171
|
+
architectFailed: (message: string) => AgentStatusMessage;
|
|
172
|
+
error: (message: string) => AgentStatusMessage;
|
|
173
|
+
retryFailed: (message: string) => AgentStatusMessage;
|
|
174
|
+
historyLoaded: (count: number) => AgentStatusMessage;
|
|
175
|
+
historyLoadFailed: (message: string) => AgentStatusMessage;
|
|
176
|
+
historyFormatInvalid: (type: string) => AgentStatusMessage;
|
|
177
|
+
editorExecuting: (description: string, index: number, total: number) => AgentStatusMessage;
|
|
178
|
+
awaitingApproval: (action: string, risk: string) => AgentStatusMessage;
|
|
179
|
+
executingAction: (action: string) => AgentStatusMessage;
|
|
180
|
+
actionRejected: (action: string) => AgentStatusMessage;
|
|
181
|
+
chatCreateFailed: (message: string) => AgentStatusMessage;
|
|
182
|
+
maxTurnsReached: (count: number) => AgentStatusMessage;
|
|
183
|
+
vueToDslFailed: (message: string) => AgentStatusMessage;
|
|
184
|
+
diffApplyFailed: (message: string) => AgentStatusMessage;
|
|
185
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor 输出解析器
|
|
3
|
+
* 识别 LLM 输出中的代码块类型:json(tool_call)、vue、diff
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolCall {
|
|
6
|
+
action: string;
|
|
7
|
+
parameters: any[];
|
|
8
|
+
}
|
|
9
|
+
export interface DiffPatch {
|
|
10
|
+
search: string;
|
|
11
|
+
replace: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ParsedOutput {
|
|
14
|
+
type: 'tool_call' | 'vue_code' | 'diff' | 'unknown';
|
|
15
|
+
tool?: ToolCall;
|
|
16
|
+
code?: string;
|
|
17
|
+
patches?: DiffPatch[];
|
|
18
|
+
raw?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 解析 LLM 输出,识别输出类型
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseOutput(text: string): ParsedOutput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withRequestRetry<T>(request: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 远程接口响应处理(纯函数)
|
|
3
|
+
* - unwrapOpenApi:响应码校验与 data 解包
|
|
4
|
+
* - pickChat / pickTopic:后端响应存在两套形态(裸对象 / { topic|chat } 包裹,
|
|
5
|
+
* 主键存在 id / chatId 双命名),统一提取,避免调用侧散落 `xxx.xxx || xxx` 兼容逻辑
|
|
6
|
+
*/
|
|
7
|
+
/** 响应码校验解包:非零 code / success=false 抛错,优先返回 data 字段 */
|
|
8
|
+
export declare function unwrapOpenApi<T>(response: any): T;
|
|
9
|
+
/** chat 实体提取结果 */
|
|
10
|
+
export interface PickedChat {
|
|
11
|
+
/** chat 实体(优先取包裹字段,回退整包) */
|
|
12
|
+
chat: any;
|
|
13
|
+
/** chat 主键(兼容 id / chatId 双命名) */
|
|
14
|
+
chatId: string;
|
|
15
|
+
}
|
|
16
|
+
/** topic 实体提取结果(topic 响应同时携带起始 chat) */
|
|
17
|
+
export interface PickedTopic extends PickedChat {
|
|
18
|
+
topic: any;
|
|
19
|
+
topicId: string;
|
|
20
|
+
userId: string;
|
|
21
|
+
}
|
|
22
|
+
/** 提取 chat 实体与主键 */
|
|
23
|
+
export declare function pickChat(response: any): PickedChat;
|
|
24
|
+
/** 提取 topic 实体、主键与起始 chat */
|
|
25
|
+
export declare function pickTopic(response: any): PickedTopic;
|