@huyooo/ai-chat-frontend-vue 0.3.31 → 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.
Files changed (39) hide show
  1. package/dist/{ExtensionPartHost-DRNTrMLl.js → ExtensionPartHost-Cy3IRnqK.js} +1 -1
  2. package/dist/adapter.d.ts +3 -4
  3. package/dist/components/ChatPanel.vue.d.ts +7 -3
  4. package/dist/components/common/TabContextMenu.vue.d.ts +22 -0
  5. package/dist/components/header/ChatHeader.vue.d.ts +15 -9
  6. package/dist/components/input/ChatInput.vue.d.ts +8 -0
  7. package/dist/components/input/at-views/AtChatsView.vue.d.ts +2 -1
  8. package/dist/components/input/at-views/AtDocsView.vue.d.ts +1 -0
  9. package/dist/components/input/at-views/AtTerminalsView.vue.d.ts +2 -1
  10. package/dist/components/message/MessageBubble.vue.d.ts +2 -3
  11. package/dist/components/message/PartsRenderer.vue.d.ts +1 -3
  12. package/dist/components/message/parts/CollapsibleCard.vue.d.ts +15 -4
  13. package/dist/components/message/parts/CompactPart.vue.d.ts +5 -0
  14. package/dist/components/message/parts/ContentCompressPart.vue.d.ts +5 -0
  15. package/dist/components/message/parts/ErrorPart.vue.d.ts +1 -0
  16. package/dist/components/message/parts/ToolCallPart.vue.d.ts +10 -11
  17. package/dist/components/message/parts/tool-call-actions.d.ts +0 -10
  18. package/dist/components/message/parts/tool-call-display.d.ts +82 -8
  19. package/dist/components/message/parts/useToolCallPartActions.d.ts +5 -9
  20. package/dist/components/message/parts/useToolCallPartState.d.ts +26 -39
  21. package/dist/composables/chat/types.d.ts +15 -7
  22. package/dist/composables/chat/useCapabilityConfig.d.ts +7 -7
  23. package/dist/composables/chat/useConversationManager.d.ts +21 -0
  24. package/dist/composables/chat/useMessageActions.d.ts +0 -1
  25. package/dist/composables/chat/useMessageSender.d.ts +3 -2
  26. package/dist/composables/chat/utils.d.ts +1 -1
  27. package/dist/composables/compressImage.d.ts +19 -0
  28. package/dist/composables/resolveAtFileVisionImages.d.ts +44 -0
  29. package/dist/composables/resolveAtFileVisionImages.test.d.ts +1 -0
  30. package/dist/composables/useChat.d.ts +97 -36
  31. package/dist/composables/useImageUpload.d.ts +30 -0
  32. package/dist/composables/useStickToBottom.d.ts +24 -0
  33. package/dist/{index-BOziByOM.js → index-C0V46Hl2.js} +3358 -1695
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.js +1 -1
  36. package/dist/style.css +1 -1
  37. package/dist/types/index.d.ts +41 -14
  38. package/package.json +3 -3
  39. package/dist/composables/chat/useSessionManager.d.ts +0 -17
@@ -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-BOziByOM.js";
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 CreateSessionOptions {
39
+ export interface CreateConversationOptions {
40
40
  title: string;
41
41
  model: string;
42
42
  mode: ChatMode;
43
43
  }
44
44
  /** 更新会话选项 */
45
- export interface UpdateSessionOptions {
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
- sessionId: string;
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,12 +48,12 @@ 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
  /** 发送消息 */
51
56
  sendMessage: (text: string) => void;
52
- /** 当前工作目录 */
53
- setCwd: (dir: string) => void;
54
57
  /** 重新加载聊天能力快照 */
55
58
  loadCapabilities: () => Promise<void>;
56
59
  /** 重新从主进程拉取聊天能力与偏好 */
@@ -66,10 +69,11 @@ declare const _default: import("vue").DefineComponent<Props, {
66
69
  }>, {
67
70
  defaultModel: string;
68
71
  defaultMode: ChatMode;
72
+ visible: boolean;
69
73
  onClose: () => void;
70
74
  rootDir: string;
71
75
  currentPath: string;
72
- visible: boolean;
76
+ resolveDroppedFilePath: (file: File) => string;
73
77
  models: ModelOption[];
74
78
  partRenderers: Record<string, Component>;
75
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 { SessionRecord } from '../../types';
1
+ import type { ConversationRecord } from '../../types';
2
2
  type __VLS_Props = {
3
- sessions: SessionRecord[];
4
- currentSessionId?: string | null;
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
- export: () => any;
17
- "copy-id": () => any;
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
- onExport?: (() => any) | undefined;
29
- "onCopy-id"?: (() => any) | undefined;
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
- sessionId: string;
11
+ conversationId: string;
11
12
  updatedAt: number;
12
13
  preview?: string | undefined;
13
14
  matchedMessageId?: string | undefined;
@@ -4,6 +4,7 @@ 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: "doc";
@@ -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
- sessionId: string;
11
+ terminalSessionId: string;
11
12
  cwd: string;
12
13
  status: string;
13
14
  updatedAt: string;
@@ -1,6 +1,6 @@
1
1
  import type { ContentPart, FinishReason } from '../../types';
2
2
  import type { ChatAdapter, ImageData } from '../../adapter';
3
- import type { AtContextItem, AutoRunConfig } from '@huyooo/ai-chat-types';
3
+ import type { AtContextItem } from '@huyooo/ai-chat-types';
4
4
  type __VLS_Props = {
5
5
  role: 'user' | 'assistant' | 'system';
6
6
  /** 消息 ID(用于 retry 等操作) */
@@ -37,8 +37,7 @@ type __VLS_Props = {
37
37
  onCancelToolCall?: (toolCallId: string) => void;
38
38
  /** 重试失败的工具调用(toolError.retryable 时) */
39
39
  onRetryToolCall?: (messageId: string, toolCallId: string) => void;
40
- autoRunConfig?: AutoRunConfig;
41
- onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
40
+ onAllowToolForSession?: (toolKey: string) => void;
42
41
  /** 结束原因(done 事件携带) */
43
42
  finishReason?: FinishReason;
44
43
  /** Token 使用统计 */
@@ -1,7 +1,6 @@
1
1
  import type { Component } from 'vue';
2
2
  import type { ContentPart, StepsExpandedType } from '../../types';
3
3
  import type { ChatAdapter } from '../../adapter';
4
- import type { AutoRunConfig } from '@huyooo/ai-chat-types';
5
4
  type __VLS_Props = {
6
5
  parts: ContentPart[];
7
6
  expandedType?: StepsExpandedType;
@@ -12,8 +11,7 @@ type __VLS_Props = {
12
11
  onCancelToolCall?: (toolCallId: string) => void;
13
12
  /** 重试失败的工具调用(透传给 ToolCallPart) */
14
13
  onRetryToolCall?: (toolCallId: string) => void;
15
- autoRunConfig?: AutoRunConfig;
16
- onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
14
+ onAllowToolForSession?: (toolKey: string) => void;
17
15
  };
18
16
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
17
  expandedType: StepsExpandedType;
@@ -9,12 +9,19 @@ type __VLS_Props = {
9
9
  titleColor?: string;
10
10
  /** 副标题 */
11
11
  subtitle?: string;
12
- /** 是否展开 */
13
- modelValue: boolean;
14
12
  /** 图标是否旋转(加载状态) */
15
13
  spinning?: boolean;
16
14
  /** 是否可折叠(显示 chevron) */
17
15
  collapsible?: boolean;
16
+ /** 标题可点击(如打开文件) */
17
+ titleInteractive?: boolean;
18
+ /** 标题原生 title 提示 */
19
+ titleTooltip?: string;
20
+ /** 待确认等场景的视觉强调 */
21
+ attention?: 'none' | 'warning' | 'danger';
22
+ };
23
+ type __VLS_PublicProps = __VLS_Props & {
24
+ modelValue: boolean;
18
25
  };
19
26
  declare var __VLS_9: {}, __VLS_19: {};
20
27
  type __VLS_Slots = {} & {
@@ -22,14 +29,18 @@ type __VLS_Slots = {} & {
22
29
  } & {
23
30
  default?: (props: typeof __VLS_19) => any;
24
31
  };
25
- declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
32
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
+ "title-click": () => any;
26
34
  "update:modelValue": (value: boolean) => any;
27
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
35
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
36
+ "onTitle-click"?: (() => any) | undefined;
28
37
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
29
38
  }>, {
30
39
  iconColor: string;
31
40
  spinning: boolean;
32
41
  collapsible: boolean;
42
+ titleInteractive: boolean;
43
+ attention: "none" | "warning" | "danger";
33
44
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
45
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
35
46
  export default _default;
@@ -1,5 +1,10 @@
1
+ import type { CompressionStrategy } from '../../../types';
1
2
  type __VLS_Props = {
2
3
  status: 'running' | 'done' | 'failed';
4
+ model?: string;
5
+ modelLabel?: string;
6
+ strategy?: CompressionStrategy;
7
+ error?: string;
3
8
  estimatedTokens?: number;
4
9
  budget?: number;
5
10
  compressedTokens?: number;
@@ -1,9 +1,14 @@
1
+ import type { CompressionStrategy } from '../../../types';
1
2
  type __VLS_Props = {
2
3
  status: 'running' | 'done' | 'failed';
3
4
  model?: string;
5
+ modelLabel?: string;
6
+ strategy?: CompressionStrategy;
7
+ error?: string;
4
8
  summary?: string;
5
9
  originalTokens?: number;
6
10
  compressedTokens?: number;
11
+ budget?: number;
7
12
  duration?: number;
8
13
  };
9
14
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,6 +1,7 @@
1
1
  type __VLS_Props = {
2
2
  message: string;
3
3
  category?: string;
4
+ code?: string;
4
5
  retryable?: boolean;
5
6
  };
6
7
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,10 +1,12 @@
1
1
  import type { ChatAdapter } from '../../../adapter';
2
- import type { AutoRunConfig } from '@huyooo/ai-chat-types';
3
- import type { AssetApprovalPolicy, AssetHostDependency, AssetSideEffectLevel, ToolApprovalReason } from '@huyooo/ai-chat-shared';
2
+ import type { ToolConfirmationReason } from '@huyooo/ai-chat-shared';
4
3
  import type { StepsExpandedType } from '../../../types';
5
4
  type __VLS_Props = {
6
5
  id: string;
7
6
  name: string;
7
+ displayName?: string;
8
+ toolName?: string;
9
+ extensionId?: string;
8
10
  args?: Record<string, unknown>;
9
11
  status: 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped';
10
12
  output?: {
@@ -19,19 +21,16 @@ type __VLS_Props = {
19
21
  suggestion?: string;
20
22
  details?: Record<string, unknown>;
21
23
  };
22
- approvalReason?: ToolApprovalReason;
23
- approvalPolicy?: AssetApprovalPolicy;
24
- sideEffectLevel?: AssetSideEffectLevel;
25
- hostDependency?: AssetHostDependency;
26
- riskSummary?: string;
27
- riskTags?: string[];
28
- riskSignals?: string[];
24
+ confirmationReason?: ToolConfirmationReason;
25
+ summary?: string;
26
+ details?: string[];
27
+ tags?: string[];
29
28
  expandedType?: StepsExpandedType;
30
29
  adapter?: ChatAdapter;
31
30
  /** 取消工具调用(优先使用上层传入,确保能同步更新 UI 状态) */
32
31
  onCancelToolCall?: (toolCallId: string) => void;
33
- autoRunConfig?: AutoRunConfig;
34
- onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
32
+ /** 本会话允许该工具(由 runtime 注入) */
33
+ onAllowToolForSession?: (toolKey: string) => void;
35
34
  /** 重试工具调用(toolError.retryable 时显示按钮,参数为 toolCallId) */
36
35
  onRetryToolCall?: (toolCallId: string) => void;
37
36
  };
@@ -1,6 +1,4 @@
1
- import type { AutoRunConfig } from '@huyooo/ai-chat-types';
2
1
  import type { ChatAdapter } from '../../../adapter';
3
- import { type AssetApprovalPolicy, type AssetSideEffectLevel } from '@huyooo/ai-chat-shared';
4
2
  export interface ToolCancelActionOptions {
5
3
  id: string;
6
4
  adapter?: ChatAdapter;
@@ -11,14 +9,6 @@ export interface ToolRetryActionOptions {
11
9
  onRetryToolCall?: (toolCallId: string) => void;
12
10
  onEmitRetry?: (toolCallId: string) => void;
13
11
  }
14
- export declare function saveToolAutoRunMode(config: AutoRunConfig | undefined, mode: string, onSaveConfig?: (config: AutoRunConfig) => Promise<void>, governance?: {
15
- approvalPolicy?: AssetApprovalPolicy;
16
- sideEffectLevel?: AssetSideEffectLevel;
17
- }): Promise<void>;
18
12
  export declare function respondToolApproval(adapter: ChatAdapter | undefined, id: string, approved: boolean): Promise<void>;
19
13
  export declare function cancelToolCall(options: ToolCancelActionOptions): void;
20
14
  export declare function retryToolCall(options: ToolRetryActionOptions): void;
21
- export declare function shouldAutoRunOnModeChange(oldMode: string, newMode: string, status: 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped', governance?: {
22
- approvalPolicy?: AssetApprovalPolicy;
23
- sideEffectLevel?: AssetSideEffectLevel;
24
- }): boolean;
@@ -1,25 +1,99 @@
1
1
  export type CommandHighlightTone = 'danger' | 'warning';
2
2
  export type ArgSignalTone = CommandHighlightTone | 'neutral';
3
3
  export type ToolCallStatus = 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped';
4
+ /** 宿主打开本地路径时的可选定位 / 类型提示 */
5
+ export type OpenFilesystemPathOptions = {
6
+ line?: number;
7
+ column?: number;
8
+ /** 已知是目录时传 directory,避免宿主按编辑器文件打开 */
9
+ pathKind?: 'file' | 'directory';
10
+ };
11
+ /** 宿主注入:打开/定位本地文件(IDE tab / 系统打开等由宿主决定) */
12
+ export type OpenFilesystemPathFromPart = (filePath: string, options?: OpenFilesystemPathOptions) => void | Promise<void>;
4
13
  export interface ImportantArgSignal {
5
14
  label: string;
6
15
  value: string;
7
16
  tone: ArgSignalTone;
8
17
  dedupeHints: string[];
18
+ /** 该 signal 已表达的 args 键;覆盖判定以此为准,而非全局白名单 */
19
+ coveredKeys: string[];
20
+ /** 可点击打开的完整路径(path 类 signal) */
21
+ openPath?: string;
22
+ pathKind?: 'file' | 'directory';
9
23
  }
10
- export type ToolSideEffectLevel = 'read' | 'write' | 'destructive' | undefined;
11
- export declare function getRunButtonText(sideEffectLevel: ToolSideEffectLevel): "确认执行高风险命令" | "确认执行" | "运行";
24
+ /** UI 最多展示的参数 chips 数;覆盖判定仍用完整 signals */
25
+ export declare const MAX_DISPLAYED_ARG_SIGNALS = 4;
26
+ export declare function getRunButtonText(): string;
12
27
  export declare function getToolStatusIcon(status: ToolCallStatus): string;
13
28
  export declare function getToolStatusIconColor(status: ToolCallStatus): string;
14
29
  export declare function getToolStatusDisplayIcon(status: ToolCallStatus): string;
15
30
  export declare function getToolStatusText(status: ToolCallStatus): string;
16
- export declare function getToolCallTitle(name: string, status: ToolCallStatus): string;
17
- export declare function getRunButtonClass(sideEffectLevel: ToolSideEffectLevel): "btn-run-danger" | "btn-run-warning" | "btn-run-primary";
18
- export declare function getRiskSummaryClass(sideEffectLevel: ToolSideEffectLevel): "tool-risk-summary-danger" | "tool-risk-summary-warning" | "tool-risk-summary-neutral";
31
+ /** 标题优先 displayName;缺省回退 name。状态靠图标表达 */
32
+ export declare function getToolCallTitle(name: string, _status?: ToolCallStatus, displayName?: string): string;
33
+ /** 从工具参数中解析主可打开路径(用于标题文件名) */
34
+ export declare function resolvePrimaryOpenablePath(args?: Record<string, unknown>, toolName?: string): {
35
+ path: string;
36
+ basename: string;
37
+ pathKind: 'file' | 'directory';
38
+ } | null;
39
+ /** 有主路径时标题用 basename,工具名进副标题(Cursor 风);副标题只用 displayName */
40
+ export declare function buildToolCallHeader(input: {
41
+ name: string;
42
+ displayName?: string;
43
+ args?: Record<string, unknown>;
44
+ }): {
45
+ title: string;
46
+ subtitle?: string;
47
+ primaryOpenPath: string | null;
48
+ primaryPathKind?: 'file' | 'directory';
49
+ titleTooltip?: string;
50
+ };
51
+ /** 行号:优先 start_line,供打开时定位 */
52
+ export declare function resolveToolCallOpenLocation(args?: Record<string, unknown>): OpenFilesystemPathOptions | undefined;
53
+ /** path chip 图标 */
54
+ export declare function getPathSignalIcon(signal: ImportantArgSignal): string;
55
+ /** UI chips:截断展示数量(主路径升标题后仍保留,展开可见完整路径等详情) */
56
+ export declare function filterDisplayedArgSignals(signals: ImportantArgSignal[], _primaryOpenPath: string | null): ImportantArgSignal[];
57
+ /** 仅 pending / running / 可重试 error 需要底栏操作 */
58
+ export declare function shouldShowToolFooter(status: ToolCallStatus, canRetry: boolean): boolean;
59
+ /** 确认区:pending 且有 summary/details/tags/reason 时展示 */
60
+ export declare function shouldShowToolConfirmationPanel(input: {
61
+ status: ToolCallStatus;
62
+ hasReasonText: boolean;
63
+ hasSummary: boolean;
64
+ detailCount: number;
65
+ tagCount?: number;
66
+ }): boolean;
67
+ export declare function getRunButtonClass(): string;
68
+ export declare function getRiskSummaryClass(): string;
19
69
  export declare function getArgSignalClass(tone: ArgSignalTone): "tool-arg-signal-danger" | "tool-arg-signal-warning" | "tool-arg-signal-neutral";
20
- export declare function getGovernanceTagClass(tag: string): "tool-governance-tag-danger" | "tool-governance-tag-warning" | "tool-governance-tag-neutral";
21
- export declare function getToolArgsType(name: string, args?: Record<string, unknown>): "text" | "command" | "json";
70
+ export declare function getToolArgsType(name: string, args?: Record<string, unknown>): 'json' | 'command' | 'text';
22
71
  export declare function getToolArgsText(name: string, args?: Record<string, unknown>): string;
23
72
  export declare function renderHighlightedCommand(command: string): string;
24
- export declare function buildImportantArgSignals(args: Record<string, unknown> | undefined, sideEffectLevel?: 'read' | 'write' | 'destructive'): ImportantArgSignal[];
73
+ export declare function buildImportantArgSignals(args: Record<string, unknown> | undefined, toolName?: string): ImportantArgSignal[];
74
+ /** 参数是否已被 signal 完整覆盖(避免「文件 chip」和 JSON path 重复) */
75
+ export declare function areArgsCoveredBySignals(args: Record<string, unknown> | undefined, signals: ImportantArgSignal[]): boolean;
76
+ /** 是否还需要展示原始 args 块 */
77
+ export declare function shouldShowToolArgsBlock(input: {
78
+ argsType: 'json' | 'command' | 'text';
79
+ args?: Record<string, unknown>;
80
+ signals: ImportantArgSignal[];
81
+ }): boolean;
82
+ /**
83
+ * signal chips:详情统一走 args JSON/命令/文本块(与审计一致),不再用 chips 顶详情
84
+ */
85
+ export declare function shouldShowArgSignals(_input: {
86
+ argsType: 'json' | 'command' | 'text';
87
+ args?: Record<string, unknown>;
88
+ signals: ImportantArgSignal[];
89
+ }): boolean;
90
+ /** 展开区是否已有任一实质内容(用于空态兜底) */
91
+ export declare function hasToolCallExpandContent(input: {
92
+ showArgsBlock: boolean;
93
+ showArgSignals: boolean;
94
+ showRiskPanel: boolean;
95
+ hasOutput: boolean;
96
+ hasErrorPanel: boolean;
97
+ showFooter: boolean;
98
+ }): boolean;
25
99
  export declare function filterDisplayedRiskSignals(riskSignals: string[], importantArgSignals: ImportantArgSignal[]): string[];
@@ -1,10 +1,9 @@
1
- import { type Ref } from 'vue';
2
- import type { AutoRunConfig } from '@huyooo/ai-chat-types';
3
1
  import type { ChatAdapter } from '../../../adapter';
4
- import type { AssetApprovalPolicy, AssetSideEffectLevel } from '@huyooo/ai-chat-shared';
5
2
  interface ToolCallPartActionProps {
6
3
  id: string;
7
4
  name: string;
5
+ toolName?: string;
6
+ extensionId?: string;
8
7
  status: 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped';
9
8
  output?: {
10
9
  stdout?: string;
@@ -12,15 +11,12 @@ interface ToolCallPartActionProps {
12
11
  };
13
12
  adapter?: ChatAdapter;
14
13
  onCancelToolCall?: (toolCallId: string) => void;
15
- autoRunConfig?: AutoRunConfig;
16
- onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
17
14
  onRetryToolCall?: (toolCallId: string) => void;
18
- approvalPolicy?: AssetApprovalPolicy;
19
- sideEffectLevel?: AssetSideEffectLevel;
15
+ onAllowToolForSession?: (toolKey: string) => void;
20
16
  }
21
- export declare function useToolCallPartActions(props: ToolCallPartActionProps, currentMode: Ref<string>, emitRetry: (toolCallId: string) => void): {
17
+ export declare function useToolCallPartActions(props: ToolCallPartActionProps, emitRetry: (toolCallId: string) => void): {
18
+ handleAllowForSession: (toolKey: string) => Promise<void>;
22
19
  handleCancel: () => void;
23
- handleModeChange: (value: string) => Promise<void>;
24
20
  handleRetry: () => void;
25
21
  handleRun: () => Promise<void>;
26
22
  handleSkip: () => Promise<void>;
@@ -1,70 +1,57 @@
1
- import type { AssetApprovalPolicy, AssetHostDependency, AssetSideEffectLevel, ToolApprovalReason } from '@huyooo/ai-chat-shared';
2
- import type { AutoRunConfig } from '@huyooo/ai-chat-types';
1
+ import type { ToolConfirmationReason } from '@huyooo/ai-chat-shared';
3
2
  import type { StepsExpandedType } from '../../../types';
4
- /**
5
- * useToolCallPartState 的最小输入集。
6
- *
7
- * 这里故意只保留当前状态组合所需字段,避免 composable 反向依赖整个组件 props。
8
- */
9
3
  interface ToolCallPartStateProps {
10
4
  name: string;
5
+ displayName?: string;
11
6
  args?: Record<string, unknown>;
12
7
  status: 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped';
13
8
  output?: {
14
9
  stdout?: string;
15
10
  stderr?: string;
16
11
  };
17
- approvalReason?: ToolApprovalReason;
18
- approvalPolicy?: AssetApprovalPolicy;
19
- sideEffectLevel?: AssetSideEffectLevel;
20
- hostDependency?: AssetHostDependency;
21
- riskSummary?: string;
22
- riskTags?: string[];
23
- riskSignals?: string[];
12
+ confirmationReason?: ToolConfirmationReason;
13
+ summary?: string;
14
+ details?: string[];
15
+ tags?: string[];
24
16
  expandedType?: StepsExpandedType;
25
17
  toolError?: {
26
18
  retryable?: boolean;
27
19
  };
28
- autoRunConfig?: AutoRunConfig;
29
20
  }
30
- /**
31
- * 基于 ToolCallPart 的输入 props 派生模板状态。
32
- *
33
- * 返回值按三类组织:
34
- * - governance:审批原因、风险摘要、标签、去重后的风险信号
35
- * - display:参数文本/高亮、状态图标/标题、按钮文案与样式,包含命令片段高亮与命令行参数信号
36
- * - panel state:输出面板 tab、展开状态、重试能力
37
- *
38
- * 其中命令行/终端工具相关状态包括:
39
- * - 命令文本高亮:如 `rm -rf`、`npm install`、`curl | sh`
40
- * - 关键参数信号:如文件路径、目录、source/destination、批量文件数、query、chunk
41
- * - 工具治理展示:如 destructive/write/read 对应的按钮文案、摘要颜色、风险标签
42
- * - 输出面板状态:stdout/stderr 切换、日志保存入口、运行中默认展开
43
- */
44
21
  export declare function useToolCallPartState(props: ToolCallPartStateProps): {
45
22
  activeOutputText: import("vue").ComputedRef<string>;
46
23
  activeStream: import("vue").Ref<"stdout" | "stderr", "stdout" | "stderr">;
47
- approvalReasonText: import("vue").ComputedRef<string | undefined>;
24
+ approvalPromptText: import("vue").ComputedRef<string | undefined>;
25
+ confirmationReasonText: import("vue").ComputedRef<string | undefined>;
48
26
  argsText: import("vue").ComputedRef<string>;
49
- argsType: import("vue").ComputedRef<"text" | "command" | "json">;
27
+ argsType: import("vue").ComputedRef<"command" | "text" | "json">;
50
28
  canRetry: import("vue").ComputedRef<boolean>;
51
- currentMode: import("vue").ComputedRef<import("@huyooo/ai-chat-shared").ToolRunMode>;
52
- displayedRiskSignals: import("vue").ComputedRef<string[]>;
29
+ cardAttention: import("vue").ComputedRef<"none" | "warning">;
30
+ details: import("vue").ComputedRef<string[]>;
31
+ tags: import("vue").ComputedRef<string[]>;
53
32
  expanded: import("vue").WritableComputedRef<boolean, boolean>;
54
- governanceTags: import("vue").ComputedRef<string[]>;
55
33
  hasOutput: import("vue").ComputedRef<boolean>;
56
34
  highlightedCommand: import("vue").ComputedRef<string>;
57
35
  highlightedJson: import("vue").ComputedRef<string>;
58
36
  importantArgSignals: import("vue").ComputedRef<import("./tool-call-display").ImportantArgSignal[]>;
59
- modeSelectionDisabled: import("vue").ComputedRef<boolean>;
60
- riskSummary: import("vue").ComputedRef<string | undefined>;
61
- riskSummaryClass: import("vue").ComputedRef<"tool-risk-summary-danger" | "tool-risk-summary-warning" | "tool-risk-summary-neutral">;
62
- runButtonClass: import("vue").ComputedRef<"btn-run-danger" | "btn-run-warning" | "btn-run-primary">;
63
- runButtonText: import("vue").ComputedRef<"确认执行高风险命令" | "确认执行" | "运行">;
37
+ primaryOpenPath: import("vue").ComputedRef<string | null>;
38
+ primaryPathKind: import("vue").ComputedRef<"file" | "directory" | undefined>;
39
+ riskSummaryClass: import("vue").ComputedRef<string>;
40
+ runButtonClass: import("vue").ComputedRef<string>;
41
+ runButtonText: import("vue").ComputedRef<string>;
42
+ showAllowForSession: import("vue").ComputedRef<boolean>;
43
+ showArgSignals: import("vue").ComputedRef<boolean>;
44
+ showArgsBlock: import("vue").ComputedRef<boolean>;
45
+ showConfirmationPanel: import("vue").ComputedRef<boolean>;
46
+ showEmptyDetail: import("vue").ComputedRef<boolean>;
47
+ showFooter: import("vue").ComputedRef<boolean>;
64
48
  statusDisplayIcon: import("vue").ComputedRef<string>;
65
49
  statusIcon: import("vue").ComputedRef<string>;
66
50
  statusIconColor: import("vue").ComputedRef<string>;
67
51
  statusText: import("vue").ComputedRef<string>;
52
+ subtitle: import("vue").ComputedRef<string | undefined>;
53
+ summary: import("vue").ComputedRef<string | undefined>;
68
54
  title: import("vue").ComputedRef<string>;
55
+ titleTooltip: import("vue").ComputedRef<string | undefined>;
69
56
  };
70
57
  export {};