@huyooo/ai-chat-frontend-vue 0.3.32 → 0.3.36
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/{ExtensionPartHost-C7fRnilA.js → ExtensionPartHost-Cy3IRnqK.js} +1 -1
- package/dist/adapter.d.ts +3 -4
- package/dist/components/ChatPanel.vue.d.ts +7 -1
- package/dist/components/common/TabContextMenu.vue.d.ts +22 -0
- package/dist/components/header/ChatHeader.vue.d.ts +15 -9
- package/dist/components/input/ChatInput.vue.d.ts +8 -0
- package/dist/components/input/at-views/AtChatsView.vue.d.ts +2 -1
- package/dist/components/input/at-views/AtDocsView.vue.d.ts +1 -0
- package/dist/components/input/at-views/AtTerminalsView.vue.d.ts +2 -1
- package/dist/composables/chat/types.d.ts +9 -7
- package/dist/composables/chat/useConversationManager.d.ts +21 -0
- package/dist/composables/compressImage.d.ts +19 -0
- package/dist/composables/resolveAtFileVisionImages.d.ts +44 -0
- package/dist/composables/resolveAtFileVisionImages.test.d.ts +1 -0
- package/dist/composables/useChat.d.ts +72 -23
- package/dist/composables/useImageUpload.d.ts +30 -0
- package/dist/index-C0V46Hl2.js +12460 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +8 -3
- package/package.json +3 -3
- package/dist/composables/chat/useSessionManager.d.ts +0 -17
- package/dist/index-C8JDRRkn.js +0 -16447
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as VueRuntime from "vue";
|
|
2
2
|
import { defineComponent, inject, ref, computed, onMounted, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeStyle, createCommentVNode, createElementVNode, createVNode, unref, toDisplayString } from "vue";
|
|
3
3
|
import { Icon } from "@iconify/vue";
|
|
4
|
-
import { D, A, b, _ as _export_sfc } from "./index-
|
|
4
|
+
import { D, A, b, _ as _export_sfc } from "./index-C0V46Hl2.js";
|
|
5
5
|
const e = `data-huyooo-extension-theme`, t = `
|
|
6
6
|
:host {
|
|
7
7
|
--sx-bg: var(--chat-bg, var(--huyooo-bg, #ffffff));
|
package/dist/adapter.d.ts
CHANGED
|
@@ -36,22 +36,21 @@ export interface SendMessageOptions {
|
|
|
36
36
|
thinkingMode: ThinkingMode;
|
|
37
37
|
}
|
|
38
38
|
/** 创建会话选项 */
|
|
39
|
-
export interface
|
|
39
|
+
export interface CreateConversationOptions {
|
|
40
40
|
title: string;
|
|
41
41
|
model: string;
|
|
42
42
|
mode: ChatMode;
|
|
43
43
|
}
|
|
44
44
|
/** 更新会话选项 */
|
|
45
|
-
export interface
|
|
45
|
+
export interface UpdateConversationOptions {
|
|
46
46
|
title?: string;
|
|
47
47
|
model?: string;
|
|
48
48
|
mode?: ChatMode;
|
|
49
49
|
}
|
|
50
50
|
/** 保存消息选项 */
|
|
51
51
|
export interface SaveMessageOptions {
|
|
52
|
-
|
|
52
|
+
conversationId: string;
|
|
53
53
|
role: 'user' | 'assistant';
|
|
54
54
|
content: string;
|
|
55
55
|
parts?: MessagePartInput[];
|
|
56
|
-
operationIds?: string;
|
|
57
56
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Component } from 'vue';
|
|
2
2
|
import type { ChatAdapter } from '../adapter';
|
|
3
3
|
import type { ModelOption, ChatMode } from '../types';
|
|
4
|
+
import type { AtContextItem } from '@huyooo/ai-chat-types';
|
|
4
5
|
import type { ChatRuntime, ToolCompleteEvent } from '../composables/useChat';
|
|
5
6
|
import type { WelcomeConfig } from './message/welcome-types';
|
|
6
7
|
interface Props {
|
|
@@ -37,6 +38,8 @@ interface Props {
|
|
|
37
38
|
currentPath?: string;
|
|
38
39
|
/** @ 文件面板的回退根目录 */
|
|
39
40
|
rootDir?: string;
|
|
41
|
+
/** 解析系统拖入 File 的绝对路径(Electron: webUtils.getPathForFile) */
|
|
42
|
+
resolveDroppedFilePath?: (file: File) => string;
|
|
40
43
|
/** 显示会话审计入口 */
|
|
41
44
|
showAuditAction?: boolean;
|
|
42
45
|
}
|
|
@@ -45,6 +48,8 @@ declare const _default: import("vue").DefineComponent<Props, {
|
|
|
45
48
|
setInputText: (text: string) => void;
|
|
46
49
|
/** 在当前光标位置插入文本 */
|
|
47
50
|
insertInputText: (text: string) => void;
|
|
51
|
+
/** 追加 @ 上下文 chip(与输入框 @ 选择器同一套 AtContextItem) */
|
|
52
|
+
addAtContextItems: (items: AtContextItem[]) => void;
|
|
48
53
|
/** 聚焦输入框 */
|
|
49
54
|
focusInput: () => void;
|
|
50
55
|
/** 发送消息 */
|
|
@@ -64,10 +69,11 @@ declare const _default: import("vue").DefineComponent<Props, {
|
|
|
64
69
|
}>, {
|
|
65
70
|
defaultModel: string;
|
|
66
71
|
defaultMode: ChatMode;
|
|
72
|
+
visible: boolean;
|
|
67
73
|
onClose: () => void;
|
|
68
74
|
rootDir: string;
|
|
69
75
|
currentPath: string;
|
|
70
|
-
|
|
76
|
+
resolveDroppedFilePath: (file: File) => string;
|
|
71
77
|
models: ModelOption[];
|
|
72
78
|
partRenderers: Record<string, Component>;
|
|
73
79
|
stepsExpandedType: "open" | "close" | "auto";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface TabContextMenuItem {
|
|
2
|
+
id: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
shortcut?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
separator?: boolean;
|
|
9
|
+
action?: () => void;
|
|
10
|
+
}
|
|
11
|
+
type __VLS_Props = {
|
|
12
|
+
visible: boolean;
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
options: TabContextMenuItem[];
|
|
16
|
+
};
|
|
17
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
close: () => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
20
|
+
onClose?: (() => any) | undefined;
|
|
21
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConversationRecord } from '../../types';
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
conversations: ConversationRecord[];
|
|
4
|
+
currentConversationId?: string | null;
|
|
5
5
|
showClose?: boolean;
|
|
6
6
|
showAudit?: boolean;
|
|
7
7
|
};
|
|
@@ -12,9 +12,12 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
12
12
|
"delete-session": (sessionId: string) => any;
|
|
13
13
|
"hide-session": (sessionId: string, hidden: boolean) => any;
|
|
14
14
|
"clear-all": () => any;
|
|
15
|
-
"close-others": () => any;
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
"close-others": (sessionId: string) => any;
|
|
16
|
+
"close-to-right": (sessionId: string) => any;
|
|
17
|
+
export: (sessionId: string) => any;
|
|
18
|
+
"copy-id": (sessionId: string) => any;
|
|
19
|
+
"rename-session": (sessionId: string, title: string) => any;
|
|
20
|
+
"reorder-sessions": (fromIndex: number, toIndex: number) => any;
|
|
18
21
|
audit: () => any;
|
|
19
22
|
feedback: () => any;
|
|
20
23
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
@@ -24,9 +27,12 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {
|
|
|
24
27
|
"onDelete-session"?: ((sessionId: string) => any) | undefined;
|
|
25
28
|
"onHide-session"?: ((sessionId: string, hidden: boolean) => any) | undefined;
|
|
26
29
|
"onClear-all"?: (() => any) | undefined;
|
|
27
|
-
"onClose-others"?: (() => any) | undefined;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
"onClose-others"?: ((sessionId: string) => any) | undefined;
|
|
31
|
+
"onClose-to-right"?: ((sessionId: string) => any) | undefined;
|
|
32
|
+
onExport?: ((sessionId: string) => any) | undefined;
|
|
33
|
+
"onCopy-id"?: ((sessionId: string) => any) | undefined;
|
|
34
|
+
"onRename-session"?: ((sessionId: string, title: string) => any) | undefined;
|
|
35
|
+
"onReorder-sessions"?: ((fromIndex: number, toIndex: number) => any) | undefined;
|
|
30
36
|
onAudit?: (() => any) | undefined;
|
|
31
37
|
onFeedback?: (() => any) | undefined;
|
|
32
38
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -17,6 +17,11 @@ type __VLS_Props = {
|
|
|
17
17
|
currentPath?: string;
|
|
18
18
|
/** @ 文件面板的回退根目录 */
|
|
19
19
|
rootDir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 解析系统(Finder)拖入 File 的绝对路径。
|
|
22
|
+
* Electron 宿主应传入 webUtils.getPathForFile;未提供时只能处理应用内自定义拖拽载荷。
|
|
23
|
+
*/
|
|
24
|
+
resolveDroppedFilePath?: (file: File) => string;
|
|
20
25
|
mode?: ChatMode;
|
|
21
26
|
model?: string;
|
|
22
27
|
/** 模型列表(tooltip 由后端下发,前端仅透传渲染) */
|
|
@@ -32,6 +37,8 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
|
32
37
|
clear: () => void;
|
|
33
38
|
/** 添加图片 */
|
|
34
39
|
addImages: (files: File[]) => void;
|
|
40
|
+
/** 外部(如 Finder 右键)追加 @ 上下文 chip,已存在则去重 */
|
|
41
|
+
addAtContextItems: (items: AtContextItem[]) => void;
|
|
35
42
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
36
43
|
send: (text: string, images?: ImageData[] | undefined, atContextItems?: AtContextItem[] | undefined) => any;
|
|
37
44
|
cancel: () => any;
|
|
@@ -61,6 +68,7 @@ declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
|
61
68
|
currentPath: string;
|
|
62
69
|
value: string;
|
|
63
70
|
variant: "input" | "message";
|
|
71
|
+
resolveDroppedFilePath: (file: File) => string;
|
|
64
72
|
models: ModelOption[];
|
|
65
73
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
66
74
|
export default _default;
|
|
@@ -4,10 +4,11 @@ type __VLS_Props = {
|
|
|
4
4
|
adapter: ChatAdapter;
|
|
5
5
|
query: string;
|
|
6
6
|
activeIndex: number;
|
|
7
|
+
selectedMentions?: string[];
|
|
7
8
|
};
|
|
8
9
|
declare function getActiveItem(): {
|
|
9
10
|
kind: "chat";
|
|
10
|
-
|
|
11
|
+
conversationId: string;
|
|
11
12
|
updatedAt: number;
|
|
12
13
|
preview?: string | undefined;
|
|
13
14
|
matchedMessageId?: string | undefined;
|
|
@@ -4,10 +4,11 @@ type __VLS_Props = {
|
|
|
4
4
|
adapter: ChatAdapter;
|
|
5
5
|
query: string;
|
|
6
6
|
activeIndex: number;
|
|
7
|
+
selectedMentions?: string[];
|
|
7
8
|
};
|
|
8
9
|
declare function getActiveItem(): {
|
|
9
10
|
kind: "terminal";
|
|
10
|
-
|
|
11
|
+
terminalSessionId: string;
|
|
11
12
|
cwd: string;
|
|
12
13
|
status: string;
|
|
13
14
|
updatedAt: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 用于子模块间传递共享状态和配置
|
|
4
4
|
*/
|
|
5
5
|
import type { Ref } from 'vue';
|
|
6
|
-
import type { AtContextItem, ChatAdapter, ChatCapabilityExtensionGroup, ChatEvent, ChatMode, ChatHistoryMessage,
|
|
6
|
+
import type { AtContextItem, ChatAdapter, ChatCapabilityExtensionGroup, ChatEvent, ChatMode, ChatHistoryMessage, ConversationRecord } from '@huyooo/ai-chat-types';
|
|
7
7
|
import type { ChatMessage } from '../../types';
|
|
8
8
|
/** 排队中的消息 */
|
|
9
9
|
export interface QueuedMessage {
|
|
@@ -13,7 +13,7 @@ export interface QueuedMessage {
|
|
|
13
13
|
atContextItems?: AtContextItem[];
|
|
14
14
|
}
|
|
15
15
|
/** 会话状态 - 每个会话独立的状态 */
|
|
16
|
-
export interface
|
|
16
|
+
export interface ConversationState {
|
|
17
17
|
messages: ChatMessage[];
|
|
18
18
|
hasMoreHistory: boolean;
|
|
19
19
|
oldestLoadedSequence: number | null;
|
|
@@ -76,12 +76,14 @@ export interface PendingContentCompressData {
|
|
|
76
76
|
/** streamAssistantResponse 参数 */
|
|
77
77
|
export interface StreamRequestParams {
|
|
78
78
|
sessionId: string;
|
|
79
|
-
state:
|
|
79
|
+
state: ConversationState;
|
|
80
80
|
userMsgId: string;
|
|
81
81
|
history: ChatHistoryMessage[];
|
|
82
82
|
text: string;
|
|
83
83
|
images?: string[];
|
|
84
84
|
atContextItems?: AtContextItem[];
|
|
85
|
+
/** @file 图片视觉双写状态,写入 grant metadata */
|
|
86
|
+
visionStatusByPath?: Record<string, string>;
|
|
85
87
|
/** finally 中是否处理队列(仅 sendMessage 需要) */
|
|
86
88
|
processQueue?: boolean;
|
|
87
89
|
}
|
|
@@ -89,9 +91,9 @@ export interface StreamRequestParams {
|
|
|
89
91
|
export interface ChatContext {
|
|
90
92
|
adapter: ChatAdapter;
|
|
91
93
|
/** 每个会话的独立状态 Map(reactive) */
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
conversationStates: Map<string, ConversationState>;
|
|
95
|
+
conversations: Ref<ConversationRecord[]>;
|
|
96
|
+
currentConversationId: Ref<string | null>;
|
|
95
97
|
mode: Ref<ChatMode>;
|
|
96
98
|
model: Ref<string>;
|
|
97
99
|
webSearch: Ref<boolean>;
|
|
@@ -102,5 +104,5 @@ export interface ChatContext {
|
|
|
102
104
|
onToolComplete?: (event: ToolCompleteEvent) => void;
|
|
103
105
|
onToolApprovalPending?: (event: ToolApprovalPendingEvent) => void;
|
|
104
106
|
/** 获取或创建会话状态(确保响应式) */
|
|
105
|
-
|
|
107
|
+
getConversationState: (sessionId: string) => ConversationState;
|
|
106
108
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对话管理模块
|
|
3
|
+
* 包含会话的增删改查、切换、导出等操作
|
|
4
|
+
*/
|
|
5
|
+
import type { ChatContext } from './types';
|
|
6
|
+
export declare function useConversationManager(ctx: ChatContext): {
|
|
7
|
+
loadConversations: () => Promise<void>;
|
|
8
|
+
switchConversation: (sessionId: string) => Promise<void>;
|
|
9
|
+
loadOlderMessages: () => Promise<void>;
|
|
10
|
+
createNewConversation: () => Promise<import("@huyooo/ai-chat-types").ConversationRecord | null>;
|
|
11
|
+
deleteConversation: (sessionId: string) => Promise<void>;
|
|
12
|
+
deleteCurrentConversation: () => Promise<void>;
|
|
13
|
+
hideConversation: (sessionId: string, hidden: boolean) => Promise<void>;
|
|
14
|
+
clearAllSessions: () => Promise<void>;
|
|
15
|
+
hideOtherSessions: (anchorSessionId?: string) => Promise<void>;
|
|
16
|
+
hideSessionsToRight: (sessionId: string) => Promise<void>;
|
|
17
|
+
renameConversation: (sessionId: string, title: string) => Promise<void>;
|
|
18
|
+
reorderConversations: (fromIndex: number, toIndex: number) => Promise<void>;
|
|
19
|
+
exportSession: (sessionId?: string) => Promise<string | null>;
|
|
20
|
+
exportCurrentSession: () => Promise<string | null>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 浏览器端图片压缩(与贴图入口共用参数)
|
|
3
|
+
*/
|
|
4
|
+
export interface CompressedImage {
|
|
5
|
+
dataUrl: string;
|
|
6
|
+
base64: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CompressImageOptions {
|
|
10
|
+
maxWidth?: number;
|
|
11
|
+
maxHeight?: number;
|
|
12
|
+
quality?: number;
|
|
13
|
+
}
|
|
14
|
+
/** 从 data URL 压缩 */
|
|
15
|
+
export declare function compressImageFromDataUrl(dataUrl: string, options?: CompressImageOptions): Promise<CompressedImage>;
|
|
16
|
+
/** 从 File 压缩 */
|
|
17
|
+
export declare function compressImageFile(file: File, options?: CompressImageOptions): Promise<CompressedImage>;
|
|
18
|
+
/** 裸 base64 + mime → 压缩后的 data URL 项 */
|
|
19
|
+
export declare function compressImageBase64(base64: string, mimeType: string, options?: CompressImageOptions): Promise<CompressedImage>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file 图片 → vision images[] 双写
|
|
3
|
+
*
|
|
4
|
+
* - 保留 atContext(工具仍拿路径)
|
|
5
|
+
* - vision 模型时把本地图片压缩后并入 images[]
|
|
6
|
+
* - 非 vision:不发送任何图(含历史双写残留)
|
|
7
|
+
* - existingImages 约定为「用户主动贴图」;不要传入上一轮已合并的双写结果(避免 resend 重复)
|
|
8
|
+
*/
|
|
9
|
+
import type { AtContextItem } from '@huyooo/ai-chat-types';
|
|
10
|
+
export type VisionInjectStatus = 'injected' | 'skipped_no_vision' | 'skipped_read_failed' | 'skipped_limit';
|
|
11
|
+
export interface VisionInjectRecord {
|
|
12
|
+
path: string;
|
|
13
|
+
status: VisionInjectStatus;
|
|
14
|
+
}
|
|
15
|
+
export interface ResolveAtFileVisionImagesInput {
|
|
16
|
+
atContextItems?: AtContextItem[];
|
|
17
|
+
/** 用户主动贴图(不含 @file 双写产物) */
|
|
18
|
+
existingImages?: string[];
|
|
19
|
+
supportsVision: boolean;
|
|
20
|
+
maxImages?: number;
|
|
21
|
+
maxBytes?: number;
|
|
22
|
+
maxRawBytes?: number;
|
|
23
|
+
readFileBase64?: (filePath: string) => Promise<string | null>;
|
|
24
|
+
}
|
|
25
|
+
export interface ResolveAtFileVisionImagesResult {
|
|
26
|
+
images: string[] | undefined;
|
|
27
|
+
visionRecords: VisionInjectRecord[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 从 @file 中挑选图片路径,在 vision 可用时压缩并入 images[]。
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveAtFileVisionImages(input: ResolveAtFileVisionImagesInput): Promise<ResolveAtFileVisionImagesResult>;
|
|
33
|
+
/** 将双写记录转成 grant metadata 用的 path → status 映射 */
|
|
34
|
+
export declare function toVisionStatusByPath(records: VisionInjectRecord[]): Record<string, VisionInjectStatus>;
|
|
35
|
+
/**
|
|
36
|
+
* 重发时取出「用户贴图」底图,避免把上次 @file 双写结果再次当 existing。
|
|
37
|
+
* - 优先用消息上记录的 userAttachedImages
|
|
38
|
+
* - 历史消息缺字段且带 @ 图片时:只信赖 atContext 重新注入,不沿用 merged images
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveUserAttachedImagesForResend(message: {
|
|
41
|
+
images?: string[];
|
|
42
|
+
userAttachedImages?: string[];
|
|
43
|
+
atContextItems?: AtContextItem[];
|
|
44
|
+
}, atContextItems?: AtContextItem[]): string[] | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,27 +12,27 @@
|
|
|
12
12
|
* - chat/utils.ts 纯工具函数(无框架依赖)
|
|
13
13
|
* - chat/types.ts 内部共享类型
|
|
14
14
|
* - chat/useCapabilityConfig.ts 聊天能力配置
|
|
15
|
-
* - chat/
|
|
15
|
+
* - chat/useConversationManager.ts 对话管理
|
|
16
16
|
* - chat/useMessageSender.ts 消息发送核心逻辑
|
|
17
17
|
* - chat/useMessageActions.ts 消息操作
|
|
18
18
|
*/
|
|
19
|
-
import type { ChatMode,
|
|
19
|
+
import type { ChatMode, ConversationRecord } from '@huyooo/ai-chat-types';
|
|
20
20
|
export type { QueuedMessage, ToolUI, ToolCompleteEvent, UseChatOptions } from './chat/types';
|
|
21
|
-
import type { UseChatOptions,
|
|
21
|
+
import type { UseChatOptions, ConversationState } from './chat/types';
|
|
22
22
|
import type { ChatMessage, ContentPart } from '../types';
|
|
23
23
|
/**
|
|
24
24
|
* 聊天状态管理 Composable
|
|
25
25
|
*
|
|
26
26
|
* 核心架构:
|
|
27
|
-
* -
|
|
27
|
+
* - conversationStates: Map<sessionId, ConversationState> 存储每个会话的独立状态
|
|
28
28
|
* - 多会话可同时进行请求,互不干扰
|
|
29
29
|
* - 切换 tab 不会停止任何正在进行的请求
|
|
30
30
|
* - 通过 computed 属性暴露当前会话的状态
|
|
31
31
|
*/
|
|
32
32
|
export declare function useChat(options: UseChatOptions): {
|
|
33
|
-
|
|
33
|
+
conversations: import("vue").Ref<{
|
|
34
34
|
id: string;
|
|
35
|
-
|
|
35
|
+
hostExtId: string | null;
|
|
36
36
|
userId: string | null;
|
|
37
37
|
title: string;
|
|
38
38
|
model: string;
|
|
@@ -40,11 +40,12 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
40
40
|
webSearchEnabled: boolean;
|
|
41
41
|
thinkingEnabled: boolean;
|
|
42
42
|
hidden: boolean;
|
|
43
|
+
tabOrder: number;
|
|
43
44
|
createdAt: Date;
|
|
44
45
|
updatedAt: Date;
|
|
45
|
-
}[],
|
|
46
|
+
}[], ConversationRecord[] | {
|
|
46
47
|
id: string;
|
|
47
|
-
|
|
48
|
+
hostExtId: string | null;
|
|
48
49
|
userId: string | null;
|
|
49
50
|
title: string;
|
|
50
51
|
model: string;
|
|
@@ -52,10 +53,11 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
52
53
|
webSearchEnabled: boolean;
|
|
53
54
|
thinkingEnabled: boolean;
|
|
54
55
|
hidden: boolean;
|
|
56
|
+
tabOrder: number;
|
|
55
57
|
createdAt: Date;
|
|
56
58
|
updatedAt: Date;
|
|
57
59
|
}[]>;
|
|
58
|
-
|
|
60
|
+
currentConversationId: import("vue").Ref<string | null, string | null>;
|
|
59
61
|
messages: import("vue").ComputedRef<{
|
|
60
62
|
id: string;
|
|
61
63
|
role: "user" | "assistant" | "system";
|
|
@@ -117,7 +119,7 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
117
119
|
extensionId?: string | undefined;
|
|
118
120
|
args?: Record<string, unknown> | undefined;
|
|
119
121
|
status: "pending" | "running" | "done" | "error" | "cancelled" | "skipped";
|
|
120
|
-
confirmationReason?: import("@huyooo/ai-chat-
|
|
122
|
+
confirmationReason?: import("@huyooo/ai-chat-core").ToolConfirmationReason | undefined;
|
|
121
123
|
summary?: string | undefined;
|
|
122
124
|
details?: string[] | undefined;
|
|
123
125
|
tags?: string[] | undefined;
|
|
@@ -184,6 +186,8 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
184
186
|
atContextItems?: ({
|
|
185
187
|
kind: "file";
|
|
186
188
|
path: string;
|
|
189
|
+
isDirectory?: boolean | undefined;
|
|
190
|
+
visionPreviewAttached?: boolean | undefined;
|
|
187
191
|
id: string;
|
|
188
192
|
label: string;
|
|
189
193
|
mention: string;
|
|
@@ -201,7 +205,7 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
201
205
|
description?: string | undefined;
|
|
202
206
|
} | {
|
|
203
207
|
kind: "terminal";
|
|
204
|
-
|
|
208
|
+
terminalSessionId: string;
|
|
205
209
|
cwd: string;
|
|
206
210
|
status: string;
|
|
207
211
|
updatedAt: string;
|
|
@@ -211,7 +215,7 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
211
215
|
description?: string | undefined;
|
|
212
216
|
} | {
|
|
213
217
|
kind: "chat";
|
|
214
|
-
|
|
218
|
+
conversationId: string;
|
|
215
219
|
updatedAt: number;
|
|
216
220
|
preview?: string | undefined;
|
|
217
221
|
matchedMessageId?: string | undefined;
|
|
@@ -219,6 +223,25 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
219
223
|
label: string;
|
|
220
224
|
mention: string;
|
|
221
225
|
description?: string | undefined;
|
|
226
|
+
} | {
|
|
227
|
+
kind: "skill";
|
|
228
|
+
skillId: string;
|
|
229
|
+
extensionId?: string | undefined;
|
|
230
|
+
extensionName?: string | undefined;
|
|
231
|
+
id: string;
|
|
232
|
+
label: string;
|
|
233
|
+
mention: string;
|
|
234
|
+
description?: string | undefined;
|
|
235
|
+
} | {
|
|
236
|
+
kind: "tool";
|
|
237
|
+
alias: string;
|
|
238
|
+
toolSource: "native" | "mcp";
|
|
239
|
+
extensionId?: string | undefined;
|
|
240
|
+
extensionName?: string | undefined;
|
|
241
|
+
id: string;
|
|
242
|
+
label: string;
|
|
243
|
+
mention: string;
|
|
244
|
+
description?: string | undefined;
|
|
222
245
|
})[] | undefined;
|
|
223
246
|
model?: string | undefined;
|
|
224
247
|
modelDisplayName?: string | undefined;
|
|
@@ -226,6 +249,7 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
226
249
|
webSearchEnabled?: boolean | undefined;
|
|
227
250
|
thinkingEnabled?: boolean | undefined;
|
|
228
251
|
images?: string[] | undefined;
|
|
252
|
+
userAttachedImages?: string[] | undefined;
|
|
229
253
|
loading?: boolean | undefined;
|
|
230
254
|
agentPhase?: "thinking" | "compressing" | undefined;
|
|
231
255
|
copied?: boolean | undefined;
|
|
@@ -258,21 +282,25 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
258
282
|
isLoading: import("vue").ComputedRef<boolean>;
|
|
259
283
|
hasMoreHistory: import("vue").ComputedRef<boolean>;
|
|
260
284
|
isLoadingHistory: import("vue").ComputedRef<boolean>;
|
|
261
|
-
|
|
285
|
+
conversationStates: import("vue").Reactive<Map<string, ConversationState>>;
|
|
262
286
|
mode: import("vue").Ref<ChatMode, ChatMode>;
|
|
263
287
|
model: import("vue").Ref<string, string>;
|
|
264
288
|
webSearch: import("vue").Ref<boolean, boolean>;
|
|
265
289
|
thinking: import("vue").Ref<boolean, boolean>;
|
|
266
|
-
|
|
267
|
-
|
|
290
|
+
loadConversations: () => Promise<void>;
|
|
291
|
+
switchConversation: (sessionId: string) => Promise<void>;
|
|
268
292
|
loadOlderMessages: () => Promise<void>;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
293
|
+
createNewConversation: () => Promise<ConversationRecord | null>;
|
|
294
|
+
deleteConversation: (sessionId: string) => Promise<void>;
|
|
295
|
+
deleteCurrentConversation: () => Promise<void>;
|
|
296
|
+
hideConversation: (sessionId: string, hidden: boolean) => Promise<void>;
|
|
273
297
|
clearAllSessions: () => Promise<void>;
|
|
274
|
-
hideOtherSessions: () => Promise<void>;
|
|
275
|
-
|
|
298
|
+
hideOtherSessions: (anchorSessionId?: string) => Promise<void>;
|
|
299
|
+
hideSessionsToRight: (sessionId: string) => Promise<void>;
|
|
300
|
+
renameConversation: (sessionId: string, title: string) => Promise<void>;
|
|
301
|
+
reorderConversations: (fromIndex: number, toIndex: number) => Promise<void>;
|
|
302
|
+
exportSession: (sessionId?: string) => Promise<string | null>;
|
|
303
|
+
exportCurrentSession: () => Promise<string | null>;
|
|
276
304
|
sendMessage: (text: string, images?: string[], atContextItems?: import("@huyooo/ai-chat-types").AtContextItem[]) => Promise<void>;
|
|
277
305
|
appendAssistantMessage: (input: {
|
|
278
306
|
parts: ContentPart[];
|
|
@@ -296,6 +324,8 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
296
324
|
atContextItems?: ({
|
|
297
325
|
kind: "file";
|
|
298
326
|
path: string;
|
|
327
|
+
isDirectory?: boolean | undefined;
|
|
328
|
+
visionPreviewAttached?: boolean | undefined;
|
|
299
329
|
id: string;
|
|
300
330
|
label: string;
|
|
301
331
|
mention: string;
|
|
@@ -313,7 +343,7 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
313
343
|
description?: string | undefined;
|
|
314
344
|
} | {
|
|
315
345
|
kind: "terminal";
|
|
316
|
-
|
|
346
|
+
terminalSessionId: string;
|
|
317
347
|
cwd: string;
|
|
318
348
|
status: string;
|
|
319
349
|
updatedAt: string;
|
|
@@ -323,7 +353,7 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
323
353
|
description?: string | undefined;
|
|
324
354
|
} | {
|
|
325
355
|
kind: "chat";
|
|
326
|
-
|
|
356
|
+
conversationId: string;
|
|
327
357
|
updatedAt: number;
|
|
328
358
|
preview?: string | undefined;
|
|
329
359
|
matchedMessageId?: string | undefined;
|
|
@@ -331,6 +361,25 @@ export declare function useChat(options: UseChatOptions): {
|
|
|
331
361
|
label: string;
|
|
332
362
|
mention: string;
|
|
333
363
|
description?: string | undefined;
|
|
364
|
+
} | {
|
|
365
|
+
kind: "skill";
|
|
366
|
+
skillId: string;
|
|
367
|
+
extensionId?: string | undefined;
|
|
368
|
+
extensionName?: string | undefined;
|
|
369
|
+
id: string;
|
|
370
|
+
label: string;
|
|
371
|
+
mention: string;
|
|
372
|
+
description?: string | undefined;
|
|
373
|
+
} | {
|
|
374
|
+
kind: "tool";
|
|
375
|
+
alias: string;
|
|
376
|
+
toolSource: "native" | "mcp";
|
|
377
|
+
extensionId?: string | undefined;
|
|
378
|
+
extensionName?: string | undefined;
|
|
379
|
+
id: string;
|
|
380
|
+
label: string;
|
|
381
|
+
mention: string;
|
|
382
|
+
description?: string | undefined;
|
|
334
383
|
})[] | undefined;
|
|
335
384
|
}[]>;
|
|
336
385
|
removeQueuedMessage: (messageId: string) => void;
|
|
@@ -7,12 +7,20 @@ export interface ImageItem {
|
|
|
7
7
|
dataUrl: string;
|
|
8
8
|
base64: string;
|
|
9
9
|
mimeType: string;
|
|
10
|
+
/** 来自 @file 预览时记录本地路径,便于与 chip 联动移除 */
|
|
11
|
+
sourcePath?: string;
|
|
10
12
|
}
|
|
11
13
|
/** 导出给外部使用的图片数据格式 */
|
|
12
14
|
export interface ImageData {
|
|
13
15
|
base64: string;
|
|
14
16
|
mimeType: string;
|
|
15
17
|
}
|
|
18
|
+
/** 压缩/读盘中的占位槽 */
|
|
19
|
+
export interface ImagePendingSlot {
|
|
20
|
+
id: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
sourcePath?: string;
|
|
23
|
+
}
|
|
16
24
|
/** useImageUpload 配置项 */
|
|
17
25
|
interface UseImageUploadOptions {
|
|
18
26
|
/** 最大图片数量,默认 5 */
|
|
@@ -37,17 +45,31 @@ export declare function useImageUpload(options?: UseImageUploadOptions): {
|
|
|
37
45
|
dataUrl: string;
|
|
38
46
|
base64: string;
|
|
39
47
|
mimeType: string;
|
|
48
|
+
sourcePath?: string | undefined;
|
|
40
49
|
}[], ImageItem[] | {
|
|
41
50
|
dataUrl: string;
|
|
42
51
|
base64: string;
|
|
43
52
|
mimeType: string;
|
|
53
|
+
sourcePath?: string | undefined;
|
|
54
|
+
}[]>;
|
|
55
|
+
pendingSlots: import("vue").Ref<{
|
|
56
|
+
id: string;
|
|
57
|
+
label?: string | undefined;
|
|
58
|
+
sourcePath?: string | undefined;
|
|
59
|
+
}[], ImagePendingSlot[] | {
|
|
60
|
+
id: string;
|
|
61
|
+
label?: string | undefined;
|
|
62
|
+
sourcePath?: string | undefined;
|
|
44
63
|
}[]>;
|
|
45
64
|
isDragOver: import("vue").Ref<boolean, boolean>;
|
|
46
65
|
previewVisible: import("vue").Ref<boolean, boolean>;
|
|
47
66
|
previewIndex: import("vue").Ref<number, number>;
|
|
48
67
|
imageUrls: import("vue").ComputedRef<string[]>;
|
|
49
68
|
imageData: import("vue").ComputedRef<ImageData[]>;
|
|
69
|
+
imageRefs: import("vue").ComputedRef<string[]>;
|
|
50
70
|
hasImages: import("vue").ComputedRef<boolean>;
|
|
71
|
+
isProcessing: import("vue").ComputedRef<boolean>;
|
|
72
|
+
hasPreviewRow: import("vue").ComputedRef<boolean>;
|
|
51
73
|
handleImageSelect: (event: Event) => void;
|
|
52
74
|
handlePaste: (event: ClipboardEvent) => void;
|
|
53
75
|
handleDragOver: (event: DragEvent) => void;
|
|
@@ -57,6 +79,14 @@ export declare function useImageUpload(options?: UseImageUploadOptions): {
|
|
|
57
79
|
closePreview: () => void;
|
|
58
80
|
removeImage: (index: number) => void;
|
|
59
81
|
clearImages: () => void;
|
|
82
|
+
beginPending: (meta?: {
|
|
83
|
+
label?: string;
|
|
84
|
+
sourcePath?: string;
|
|
85
|
+
}) => string | null;
|
|
86
|
+
endPending: (id: string) => void;
|
|
87
|
+
cancelPendingBySourcePath: (sourcePath: string) => void;
|
|
88
|
+
addImageItem: (item: ImageItem) => boolean;
|
|
89
|
+
removeImagesBySourcePath: (sourcePath: string) => void;
|
|
60
90
|
addImages: (files: File[]) => void;
|
|
61
91
|
initImages: (data: string[]) => void;
|
|
62
92
|
};
|