agent-tool-chat 1.1.6 → 1.6.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/README.md +127 -5
- package/dist/agent-core/agent.d.ts +8 -0
- package/dist/agent-core/index.d.ts +2 -1
- package/dist/agent-core/storage.d.ts +4 -0
- package/dist/agent-core/truncate.d.ts +8 -0
- package/dist/agent-core/types.d.ts +16 -0
- package/dist/agent-tool-chat.css +1 -1
- package/dist/api/openai-compatible.d.ts +11 -0
- package/dist/api/openai.d.ts +2 -0
- package/dist/api/provider-registry.d.ts +8 -0
- package/dist/components/ChatMessage.vue.d.ts +3 -7
- package/dist/components/ChatPanel.vue.d.ts +42 -1
- package/dist/components/SelectionSend.vue.d.ts +25 -0
- package/dist/components/SessionDrawer.vue.d.ts +22 -0
- package/dist/composables/useAgentChat.d.ts +48 -17
- package/dist/config.d.ts +11 -4
- package/dist/core/context-builder.d.ts +1 -0
- package/dist/core/session-store.d.ts +21 -0
- package/dist/core/tool-requirements.d.ts +44 -0
- package/dist/index.cjs +46 -37
- package/dist/index.d.ts +11 -3
- package/dist/index.js +4303 -3166
- package/dist/types.d.ts +122 -10
- package/package.json +2 -1
package/dist/types.d.ts
CHANGED
|
@@ -3,8 +3,14 @@ import { CoreMessage, ToolCall, StreamResult, ToolDefinition as CoreToolDefiniti
|
|
|
3
3
|
export type { CoreMessage, ToolCall, StreamResult, LLMProviderConfig };
|
|
4
4
|
export interface ToolDefinition {
|
|
5
5
|
name: string;
|
|
6
|
+
alias?: string;
|
|
6
7
|
description: string;
|
|
7
8
|
parameters: Record<string, any>;
|
|
9
|
+
/**
|
|
10
|
+
* 执行前置条件。声明后会写进系统提示词;
|
|
11
|
+
* 带 check 的条件由宿主 onCheckToolRequirement 权威判定,未满足时不执行工具。
|
|
12
|
+
*/
|
|
13
|
+
requires?: ToolRequirement | ToolRequirement[];
|
|
8
14
|
displayHints?: {
|
|
9
15
|
suggestComponent?: string;
|
|
10
16
|
resultFormat?: 'table' | 'card' | 'list' | 'text' | 'map' | 'none' | 'auto';
|
|
@@ -81,28 +87,119 @@ export interface ChatMessage {
|
|
|
81
87
|
export interface ToolResult {
|
|
82
88
|
callId: string;
|
|
83
89
|
name: string;
|
|
90
|
+
alias?: string;
|
|
84
91
|
arguments: string;
|
|
85
92
|
result: string;
|
|
86
93
|
success: boolean;
|
|
87
|
-
status: 'running' | 'success' | 'error';
|
|
94
|
+
status: 'running' | 'success' | 'error' | 'blocked';
|
|
95
|
+
/** 被前置条件阻断时的原因(status === 'blocked') */
|
|
96
|
+
hint?: string;
|
|
88
97
|
}
|
|
89
|
-
export
|
|
98
|
+
export type ToolRequirementAction = 'call-tool' | 'ask-user' | 'block';
|
|
99
|
+
export interface ToolRequirement {
|
|
100
|
+
/** 条件说明(必填,会写进系统提示词) */
|
|
101
|
+
description: string;
|
|
102
|
+
/** 建议先成功调用的工具名(仅提示词建议,不做硬拦截) */
|
|
103
|
+
tools?: string[];
|
|
104
|
+
/** 宿主校验项 id,由 onCheckToolRequirement 判定;未满足则不执行工具 */
|
|
105
|
+
check?: string;
|
|
106
|
+
/** 未满足时给模型/用户的指令 */
|
|
107
|
+
hint?: string;
|
|
108
|
+
/** 未满足时建议动作,默认:有 tools → call-tool,否则 ask-user */
|
|
109
|
+
action?: ToolRequirementAction;
|
|
110
|
+
}
|
|
111
|
+
export interface ToolRequirementContext {
|
|
112
|
+
sessionId: string;
|
|
113
|
+
packageId: string;
|
|
114
|
+
toolName: string;
|
|
115
|
+
args: Record<string, any>;
|
|
116
|
+
check: string;
|
|
117
|
+
description?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ToolRequirementResult {
|
|
120
|
+
ok: boolean;
|
|
121
|
+
/** 未满足原因(进 tool 结果与 UI) */
|
|
122
|
+
message?: string;
|
|
123
|
+
/** 覆盖声明里的 hint */
|
|
124
|
+
hint?: string;
|
|
125
|
+
/** 建议先调用的工具 */
|
|
126
|
+
suggestedTool?: string;
|
|
127
|
+
action?: ToolRequirementAction;
|
|
128
|
+
}
|
|
129
|
+
export interface SessionMeta {
|
|
130
|
+
id: string;
|
|
131
|
+
title: string;
|
|
132
|
+
/** 毫秒时间戳 */
|
|
133
|
+
createdAt: number;
|
|
134
|
+
/** 毫秒时间戳 */
|
|
135
|
+
updatedAt: number;
|
|
136
|
+
messageCount?: number;
|
|
137
|
+
}
|
|
138
|
+
export interface ProviderModelOption {
|
|
139
|
+
label: string;
|
|
140
|
+
value: string;
|
|
141
|
+
}
|
|
142
|
+
export interface ProviderCapabilities {
|
|
143
|
+
/** 是否支持温度参数,默认 true */
|
|
144
|
+
temperature?: boolean;
|
|
145
|
+
/** 是否显示思考模式开关 */
|
|
146
|
+
thinking?: boolean;
|
|
147
|
+
/** 是否显示思考强度选择 */
|
|
148
|
+
reasoningEffort?: boolean;
|
|
149
|
+
/** 是否支持工具调用,默认 true */
|
|
150
|
+
tools?: boolean;
|
|
151
|
+
}
|
|
152
|
+
export interface ProviderPreset {
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
protocol: 'openai-compatible';
|
|
156
|
+
defaultBaseUrl: string;
|
|
157
|
+
defaultModel: string;
|
|
158
|
+
models: ProviderModelOption[];
|
|
159
|
+
/** 允许手动输入模型名,默认 true */
|
|
160
|
+
allowCustomModel?: boolean;
|
|
161
|
+
apiKeyUrl?: string;
|
|
162
|
+
capabilities: ProviderCapabilities;
|
|
163
|
+
/** 提供方私有请求字段注入,如 DeepSeek 的 thinking */
|
|
164
|
+
buildBody?: (body: Record<string, any>, config: LLMProviderConfig) => void;
|
|
165
|
+
/** 自定义鉴权头,默认 Bearer */
|
|
166
|
+
buildHeaders?: (apiKey: string) => Record<string, string>;
|
|
167
|
+
}
|
|
168
|
+
export interface ProviderSettings {
|
|
90
169
|
apiKey: string;
|
|
91
170
|
baseUrl: string;
|
|
92
171
|
model: string;
|
|
93
172
|
temperature: number;
|
|
94
|
-
|
|
173
|
+
thinking: boolean;
|
|
174
|
+
thinkingEffort: 'low' | 'high' | 'max';
|
|
175
|
+
}
|
|
176
|
+
export interface ChatSettings {
|
|
177
|
+
/** 当前模型提供方 ID */
|
|
178
|
+
providerId: string;
|
|
95
179
|
providerMode: 'direct' | 'proxy';
|
|
96
180
|
proxyUrl: string;
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
thinkingEffort?: 'low' | 'high' | 'max';
|
|
101
|
-
/** md 内容表格行点击选择(触发"我选择 X"回灌对话),默认关闭 */
|
|
181
|
+
/** 各提供方独立配置 */
|
|
182
|
+
providers: Record<string, ProviderSettings>;
|
|
183
|
+
/** md 内容表格行点击选择(触发"我选择 X"回灌对话),默认开启 */
|
|
102
184
|
mdTableClick?: boolean;
|
|
103
|
-
/** md
|
|
185
|
+
/** md 内容列表项点击执行,默认开启 */
|
|
104
186
|
mdListClick?: boolean;
|
|
187
|
+
/** @deprecated 预留字段,当前未实现任何行为 */
|
|
188
|
+
useTools?: boolean;
|
|
189
|
+
/** @deprecated 兼容旧代码,始终镜像当前 provider 的值 */
|
|
190
|
+
apiKey?: string;
|
|
191
|
+
/** @deprecated 兼容旧代码,始终镜像当前 provider 的值 */
|
|
192
|
+
baseUrl?: string;
|
|
193
|
+
/** @deprecated 兼容旧代码,始终镜像当前 provider 的值 */
|
|
194
|
+
model?: string;
|
|
195
|
+
/** @deprecated 兼容旧代码,始终镜像当前 provider 的值 */
|
|
196
|
+
temperature?: number;
|
|
197
|
+
/** @deprecated 兼容旧代码,始终镜像当前 provider 的值 */
|
|
198
|
+
thinking?: boolean;
|
|
199
|
+
/** @deprecated 兼容旧代码,始终镜像当前 provider 的值 */
|
|
200
|
+
thinkingEffort?: 'low' | 'high' | 'max';
|
|
105
201
|
}
|
|
202
|
+
export declare const DEFAULT_PROVIDER_SETTINGS: Record<string, ProviderSettings>;
|
|
106
203
|
export declare const DEFAULT_SETTINGS: ChatSettings;
|
|
107
204
|
export interface ChatCommand {
|
|
108
205
|
label: string;
|
|
@@ -111,10 +208,17 @@ export interface ChatCommand {
|
|
|
111
208
|
export interface AgentChatOptions {
|
|
112
209
|
toolPackages: ToolPackage[];
|
|
113
210
|
onToolCall?: (call: ToolCallEvent) => Promise<any>;
|
|
211
|
+
/**
|
|
212
|
+
* 工具前置条件校验钩子:声明了 requires.check 的工具在执行前会调用它,
|
|
213
|
+
* 返回 ok:false 时不执行工具,并把结构化结果回给模型。
|
|
214
|
+
*/
|
|
215
|
+
onCheckToolRequirement?: (ctx: ToolRequirementContext) => ToolRequirementResult | Promise<ToolRequirementResult>;
|
|
114
216
|
provider?: any;
|
|
115
217
|
providerConfig?: Partial<LLMProviderConfig>;
|
|
116
|
-
/**
|
|
218
|
+
/** 初始设置项:作为默认值,localStorage 中已保存的设置按字段覆盖 */
|
|
117
219
|
settings?: Partial<ChatSettings>;
|
|
220
|
+
/** 扩展模型提供方预设(OpenAI 兼容协议) */
|
|
221
|
+
providerPresets?: ProviderPreset[];
|
|
118
222
|
systemPrompt?: string;
|
|
119
223
|
storagePrefix?: string;
|
|
120
224
|
/** 上传的文件数据是否发给 LLM,默认 false(仅前端展示) */
|
|
@@ -129,6 +233,14 @@ export interface AgentChatOptions {
|
|
|
129
233
|
maxContextTokens?: number;
|
|
130
234
|
/** 历史消息硬上限(条),超出仅保留最近 N 条;≤0 表示不限制。默认 60(见 useAgentChat) */
|
|
131
235
|
maxHistoryMessages?: number;
|
|
236
|
+
/** 单次工具结果写入模型的字符上限;0 表示不限制。默认 30000(见 useAgentChat) */
|
|
237
|
+
maxToolResultChars?: number;
|
|
238
|
+
/**
|
|
239
|
+
* 承载 chat 实例的组件卸载时是否自动 dispose(停止业务事件引擎)。
|
|
240
|
+
* 默认 false:业务事件按应用级常驻,避免宿主缓存实例后路由往返导致事件失效;
|
|
241
|
+
* 需要旧的"卸载即清理"行为时显式传 true。
|
|
242
|
+
*/
|
|
243
|
+
disposeOnUnmount?: boolean;
|
|
132
244
|
}
|
|
133
245
|
export interface BusinessEvent {
|
|
134
246
|
type: string;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "agent-tool-chat",
|
|
3
3
|
"description": "An agent-driven chat plugin with ToolPackage architecture and host-controlled execution",
|
|
4
4
|
"author": "kangjinrui <1092014304@qq.com>",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.6.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
8
8
|
"type": "module",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "vite build && .\\copy-mp.bat",
|
|
29
|
+
"build:host": "vite build && node scripts/copy-to-host.mjs",
|
|
29
30
|
"dev": "vite build --watch",
|
|
30
31
|
"prepublishOnly": "npm run build"
|
|
31
32
|
},
|