@vtj/designer 0.18.27 → 0.19.0
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-aD1U5H8b.js +4 -0
- package/dist/{index-BtJsaFJm.js → index-De2f2yWt.js} +12295 -10599
- package/dist/index.mjs +29 -28
- package/dist/style.css +1 -1
- 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 +4 -6
- 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/components/widgets/scripts/group.d.ts +2 -2
- 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/renderer.d.ts +1 -0
- package/types/framework/types.d.ts +2 -0
- package/types/utils.d.ts +2 -1
- package/types/version.d.ts +2 -2
- package/dist/Editor-BGOUCiNb.js +0 -4
- 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,46 @@
|
|
|
1
|
+
import { AttachmentInfo } from '../types/agent';
|
|
2
|
+
import { Ref, ComputedRef } from 'vue';
|
|
3
|
+
export interface UploadedFile {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: 'image' | 'json';
|
|
7
|
+
description: string;
|
|
8
|
+
recognizing: boolean;
|
|
9
|
+
error: string;
|
|
10
|
+
/** 图片的 objectURL,用于缩略图预览 */
|
|
11
|
+
previewUrl: string;
|
|
12
|
+
/** 识别成功后后端返回的文件访问地址 */
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function useFileRecognition(recognitionFile: (file: File) => Promise<{
|
|
16
|
+
title?: string;
|
|
17
|
+
content?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
}>): {
|
|
21
|
+
files: Ref<{
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
type: "image" | "json";
|
|
25
|
+
description: string;
|
|
26
|
+
recognizing: boolean;
|
|
27
|
+
error: string;
|
|
28
|
+
previewUrl: string;
|
|
29
|
+
url: string;
|
|
30
|
+
}[], UploadedFile[] | {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
type: "image" | "json";
|
|
34
|
+
description: string;
|
|
35
|
+
recognizing: boolean;
|
|
36
|
+
error: string;
|
|
37
|
+
previewUrl: string;
|
|
38
|
+
url: string;
|
|
39
|
+
}[]>;
|
|
40
|
+
recognizing: ComputedRef<boolean>;
|
|
41
|
+
uploadFile: (file: File) => Promise<void>;
|
|
42
|
+
removeFile: (fileId: string) => void;
|
|
43
|
+
buildFilePrompt: () => string;
|
|
44
|
+
buildAttachments: () => AttachmentInfo[];
|
|
45
|
+
clearFiles: () => void;
|
|
46
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SSEChunkData, StreamCompletionResult } from '../types/agent';
|
|
2
|
+
type ChatCompletions = (topicId: string, chatId: string, callback?: (data: SSEChunkData | null, done?: boolean) => void, error?: (error: Error, cancel?: boolean) => void) => Promise<(() => void) | undefined>;
|
|
3
|
+
export declare function useSSEStream(chatCompletions: ChatCompletions): {
|
|
4
|
+
streamCompletion: (topicId: string, chatId: string, onChunk?: (text: string) => void, onReasoning?: (text: string) => void) => Promise<StreamCompletionResult>;
|
|
5
|
+
abortAll: () => void;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent 模块常量
|
|
3
|
+
* 集中管理流程参数、超时、存储键等可配置项
|
|
4
|
+
*/
|
|
5
|
+
/** Editor 单步骤内最大工具调用轮次(ReAct 循环上限) */
|
|
6
|
+
export declare const MAX_TURNS = 10;
|
|
7
|
+
/** 工具执行超时时间(毫秒) */
|
|
8
|
+
export declare const TOOL_TIMEOUT_MS = 30000;
|
|
9
|
+
/** 代码块显示偏好存储键 */
|
|
10
|
+
export declare const HIDE_CODE_STORAGE_KEY = "CHAT_HIDE_CODE";
|
|
11
|
+
/** 滚动判断"接近底部"的阈值(像素) */
|
|
12
|
+
export declare const SCROLL_NEAR_BOTTOM_THRESHOLD = 80;
|
|
13
|
+
/** 服务端"额度/Token 用尽"错误文案片段(命中时弹出付费提示) */
|
|
14
|
+
export declare const PAY_LIMIT_MESSAGES: string[];
|
|
15
|
+
/** 判断错误文案是否命中付费提示条件 */
|
|
16
|
+
export declare const isPayLimitError: (text: string) => boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConversationRound } from './types/agent';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
round: ConversationRound;
|
|
5
|
+
roundNumber: number;
|
|
6
|
+
isLatest: boolean;
|
|
7
|
+
retryable: boolean;
|
|
8
|
+
code: boolean;
|
|
9
|
+
detailsCommand: number;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
12
|
+
view: (source: string, language: string, dsl?: Record<string, any> | undefined) => any;
|
|
13
|
+
resolveApproval: (id: string, approved: boolean) => any;
|
|
14
|
+
apply: (dsl: Record<string, any>) => any;
|
|
15
|
+
retryStep: (stepIndex: number) => any;
|
|
16
|
+
retrySummary: () => any;
|
|
17
|
+
retryArchitect: () => any;
|
|
18
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
onView?: ((source: string, language: string, dsl?: Record<string, any> | undefined) => any) | undefined;
|
|
20
|
+
onResolveApproval?: ((id: string, approved: boolean) => any) | undefined;
|
|
21
|
+
onApply?: ((dsl: Record<string, any>) => any) | undefined;
|
|
22
|
+
onRetryStep?: ((stepIndex: number) => any) | undefined;
|
|
23
|
+
onRetrySummary?: (() => any) | undefined;
|
|
24
|
+
onRetryArchitect?: (() => any) | undefined;
|
|
25
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLElement>;
|
|
26
|
+
export default _default;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { AIChat } from '../../hooks';
|
|
2
1
|
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions, CreateComponentPublicInstanceWithMixins, GlobalComponents, GlobalDirectives } from 'vue';
|
|
3
2
|
import { Props } from '../../editor/Editor';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
source: string;
|
|
5
|
+
language: string;
|
|
6
|
+
dsl: any;
|
|
7
|
+
updateDsl: (source: string) => Promise<any>;
|
|
8
|
+
};
|
|
9
|
+
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
10
|
+
apply: (dsl: any) => any;
|
|
11
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
onApply?: ((dsl: any) => any) | undefined;
|
|
12
13
|
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
13
14
|
editorRef: CreateComponentPublicInstanceWithMixins<Readonly< Props> & Readonly<{
|
|
14
15
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EditorStepResult } from './types/agent';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
step: EditorStepResult;
|
|
5
|
+
code: boolean;
|
|
6
|
+
detailsCommand: number;
|
|
7
|
+
retryable: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
10
|
+
view: (source: string, language: string, dsl?: Record<string, any> | undefined) => any;
|
|
11
|
+
retry: () => any;
|
|
12
|
+
resolveApproval: (id: string, approved: boolean) => any;
|
|
13
|
+
apply: (dsl: Record<string, any>) => any;
|
|
14
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
|
+
onView?: ((source: string, language: string, dsl?: Record<string, any> | undefined) => any) | undefined;
|
|
16
|
+
onRetry?: (() => any) | undefined;
|
|
17
|
+
onResolveApproval?: ((id: string, approved: boolean) => any) | undefined;
|
|
18
|
+
onApply?: ((dsl: Record<string, any>) => any) | undefined;
|
|
19
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
20
|
+
turnContentRefs: HTMLDivElement;
|
|
21
|
+
}, HTMLElement>;
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions, CreateComponentPublicInstanceWithMixins, GlobalComponents, GlobalDirectives } from 'vue';
|
|
2
|
+
import { Props } from './pay-tip';
|
|
3
|
+
declare const _default: DefineComponent<{}, {
|
|
4
|
+
newTask: () => void;
|
|
5
|
+
start: () => Promise<void>;
|
|
6
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {
|
|
7
|
+
payTipRef: CreateComponentPublicInstanceWithMixins<Readonly< Props> & Readonly<{}>, {
|
|
8
|
+
show: () => void;
|
|
9
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
|
|
10
|
+
P: {};
|
|
11
|
+
B: {};
|
|
12
|
+
D: {};
|
|
13
|
+
C: {};
|
|
14
|
+
M: {};
|
|
15
|
+
Defaults: {};
|
|
16
|
+
}, Readonly< Props> & Readonly<{}>, {
|
|
17
|
+
show: () => void;
|
|
18
|
+
}, {}, {}, {}, {}> | null;
|
|
19
|
+
conversationRef: HTMLDivElement;
|
|
20
|
+
}, any>;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DictOption } from '../../../framework';
|
|
2
|
+
import { UploadedFile } from './composables/useFileRecognition';
|
|
3
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
message: string;
|
|
6
|
+
running: boolean;
|
|
7
|
+
hasTopic: boolean;
|
|
8
|
+
files: UploadedFile[];
|
|
9
|
+
recognizing: boolean;
|
|
10
|
+
autoApprove: boolean;
|
|
11
|
+
model: string;
|
|
12
|
+
models: DictOption[];
|
|
13
|
+
};
|
|
14
|
+
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
15
|
+
abort: () => any;
|
|
16
|
+
"update:message": (value: string) => any;
|
|
17
|
+
start: () => any;
|
|
18
|
+
continue: () => any;
|
|
19
|
+
"update:autoApprove": (value: boolean) => any;
|
|
20
|
+
"update:model": (value: string) => any;
|
|
21
|
+
"upload-file": (file: File) => any;
|
|
22
|
+
"remove-file": (fileId: string) => any;
|
|
23
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
onAbort?: (() => any) | undefined;
|
|
25
|
+
"onUpdate:message"?: ((value: string) => any) | undefined;
|
|
26
|
+
onStart?: (() => any) | undefined;
|
|
27
|
+
onContinue?: (() => any) | undefined;
|
|
28
|
+
"onUpdate:autoApprove"?: ((value: boolean) => any) | undefined;
|
|
29
|
+
"onUpdate:model"?: ((value: string) => any) | undefined;
|
|
30
|
+
"onUpload-file"?: ((file: File) => any) | undefined;
|
|
31
|
+
"onRemove-file"?: ((fileId: string) => any) | undefined;
|
|
32
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
33
|
+
fileInputRef: HTMLInputElement;
|
|
34
|
+
}, HTMLElement>;
|
|
35
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Settings } from '
|
|
1
|
+
import { Settings } from '../../../framework';
|
|
2
2
|
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
3
|
export interface Props {
|
|
4
4
|
settings?: Settings;
|
|
@@ -8,5 +8,7 @@ export interface Props {
|
|
|
8
8
|
getOrder: any;
|
|
9
9
|
getImage: (path?: string) => string | undefined;
|
|
10
10
|
}
|
|
11
|
-
declare const _default: DefineComponent<Props, {
|
|
11
|
+
declare const _default: DefineComponent<Props, {
|
|
12
|
+
show: () => void;
|
|
13
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
12
14
|
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AITopic } from '../../../framework';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
topics?: AITopic[];
|
|
5
|
+
current?: AITopic | null;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
8
|
+
load: (topic: AITopic) => any;
|
|
9
|
+
remove: (topic: AITopic) => any;
|
|
10
|
+
new: () => any;
|
|
11
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
onLoad?: ((topic: AITopic) => any) | undefined;
|
|
13
|
+
onRemove?: ((topic: AITopic) => any) | undefined;
|
|
14
|
+
onNew?: (() => any) | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
topics: AITopic[];
|
|
17
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
18
|
+
export default _default;
|
|
@@ -4,9 +4,9 @@ type __VLS_Props = {
|
|
|
4
4
|
code?: boolean;
|
|
5
5
|
};
|
|
6
6
|
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
7
|
-
click: (
|
|
7
|
+
click: (source: string, language: string) => any;
|
|
8
8
|
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
-
onClick?: ((
|
|
9
|
+
onClick?: ((source: string, language: string) => any) | undefined;
|
|
10
10
|
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
11
11
|
container: HTMLDivElement;
|
|
12
12
|
}, HTMLDivElement>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
text: string;
|
|
4
|
+
reasoning: string;
|
|
5
|
+
error: string;
|
|
6
|
+
code: boolean;
|
|
7
|
+
detailsCommand: number;
|
|
8
|
+
retryable: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
11
|
+
view: (source: string, language: string) => any;
|
|
12
|
+
retry: () => any;
|
|
13
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
14
|
+
onView?: ((source: string, language: string) => any) | undefined;
|
|
15
|
+
onRetry?: (() => any) | undefined;
|
|
16
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
17
|
+
reasoningPreRef: HTMLPreElement;
|
|
18
|
+
}, any>;
|
|
19
|
+
export default _default;
|
|
@@ -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;
|