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.
@@ -1,5 +1,6 @@
1
1
  import { EventBus } from '../core/event-bus';
2
- import { AgentChatOptions, ChatMessage, ChatSettings, ChatCommand, ToolPackage, FileAttachment } from '../types';
2
+ import { AgentChatOptions, ChatMessage, ChatSettings, ChatCommand, SessionMeta, ToolPackage, FileAttachment } from '../types';
3
+ declare function setDeviceId(id: string): void;
3
4
  export declare function useAgentChat(options: AgentChatOptions): {
4
5
  messages: import('vue').Ref<{
5
6
  id: string;
@@ -48,10 +49,12 @@ export declare function useAgentChat(options: AgentChatOptions): {
48
49
  toolResults?: {
49
50
  callId: string;
50
51
  name: string;
52
+ alias?: string;
51
53
  arguments: string;
52
54
  result: string;
53
55
  success: boolean;
54
- status: "running" | "success" | "error";
56
+ status: "running" | "success" | "error" | "blocked";
57
+ hint?: string;
55
58
  }[];
56
59
  hideMarkdown?: boolean;
57
60
  }[], ChatMessage[] | {
@@ -101,49 +104,77 @@ export declare function useAgentChat(options: AgentChatOptions): {
101
104
  toolResults?: {
102
105
  callId: string;
103
106
  name: string;
107
+ alias?: string;
104
108
  arguments: string;
105
109
  result: string;
106
110
  success: boolean;
107
- status: "running" | "success" | "error";
111
+ status: "running" | "success" | "error" | "blocked";
112
+ hint?: string;
108
113
  }[];
109
114
  hideMarkdown?: boolean;
110
115
  }[]>;
111
116
  settings: import('vue').Ref<{
112
- apiKey: string;
113
- baseUrl: string;
114
- model: string;
115
- temperature: number;
116
- useTools?: boolean;
117
+ providerId: string;
117
118
  providerMode: "direct" | "proxy";
118
119
  proxyUrl: string;
119
- thinking?: boolean;
120
- thinkingEffort?: "low" | "high" | "max";
120
+ providers: Record<string, import('..').ProviderSettings>;
121
121
  mdTableClick?: boolean;
122
122
  mdListClick?: boolean;
123
- }, ChatSettings | {
124
- apiKey: string;
125
- baseUrl: string;
126
- model: string;
127
- temperature: number;
128
123
  useTools?: boolean;
129
- providerMode: "direct" | "proxy";
130
- proxyUrl: string;
124
+ apiKey?: string;
125
+ baseUrl?: string;
126
+ model?: string;
127
+ temperature?: number;
131
128
  thinking?: boolean;
132
129
  thinkingEffort?: "low" | "high" | "max";
130
+ }, ChatSettings | {
131
+ providerId: string;
132
+ providerMode: "direct" | "proxy";
133
+ proxyUrl: string;
134
+ providers: Record<string, import('..').ProviderSettings>;
133
135
  mdTableClick?: boolean;
134
136
  mdListClick?: boolean;
137
+ useTools?: boolean;
138
+ apiKey?: string;
139
+ baseUrl?: string;
140
+ model?: string;
141
+ temperature?: number;
142
+ thinking?: boolean;
143
+ thinkingEffort?: "low" | "high" | "max";
135
144
  }>;
136
145
  loading: import('vue').Ref<boolean, boolean>;
137
146
  errorMsg: import('vue').Ref<string, string>;
147
+ syncError: import('vue').Ref<string, string>;
138
148
  hasApiKey: import('vue').ComputedRef<boolean>;
139
149
  toolPackages: ToolPackage[];
140
150
  fileStore: Map<string, FileAttachment>;
141
151
  visible: import('vue').Ref<boolean, boolean>;
142
152
  eventBus: EventBus;
143
153
  deviceId: string;
154
+ setDeviceId: typeof setDeviceId;
155
+ sessions: import('vue').Ref<{
156
+ id: string;
157
+ title: string;
158
+ createdAt: number;
159
+ updatedAt: number;
160
+ messageCount?: number;
161
+ }[], SessionMeta[] | {
162
+ id: string;
163
+ title: string;
164
+ createdAt: number;
165
+ updatedAt: number;
166
+ messageCount?: number;
167
+ }[]>;
168
+ currentSessionId: import('vue').Ref<string, string>;
169
+ sessionsLoading: import('vue').Ref<boolean, boolean>;
170
+ newSession: () => Promise<void>;
171
+ switchSession: (id: string) => Promise<void>;
172
+ deleteSession: (id: string) => Promise<void>;
144
173
  sendMessage: (text: string, files?: FileAttachment[]) => Promise<void>;
145
174
  stopGeneration: () => void;
146
175
  clearMessages: () => Promise<void>;
147
176
  saveSettings: (next: ChatSettings) => void;
177
+ dispose: () => void;
148
178
  suggestedCommands: ChatCommand[];
149
179
  };
180
+ export {};
package/dist/config.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- export declare const MODEL_OPTIONS: {
2
- label: string;
3
- value: string;
4
- }[];
1
+ import { ChatSettings, ProviderPreset, ProviderSettings } from './types';
2
+ export declare const DEFAULT_PROVIDER_ID = "deepseek";
3
+ export declare const PROVIDER_PRESETS: ProviderPreset[];
4
+ export declare function registerProviderPreset(preset: ProviderPreset): void;
5
+ export declare function getProviderPreset(id?: string): ProviderPreset | undefined;
6
+ export declare function listProviderPresets(): ProviderPreset[];
7
+ export declare function createProviderSettings(preset: ProviderPreset): ProviderSettings;
8
+ export declare function syncLegacySettings(settings: ChatSettings): ChatSettings;
9
+ export declare function normalizeSettings(input?: Partial<ChatSettings>): ChatSettings;
10
+ export declare function mergeSettings(base: ChatSettings, raw?: Partial<ChatSettings>): ChatSettings;
11
+ export declare const MODEL_OPTIONS: import('./types').ProviderModelOption[];
@@ -2,3 +2,4 @@ import { ToolPackage } from '../types';
2
2
  export declare function buildPackageSection(pkg: ToolPackage): string;
3
3
  export declare function buildSystemPrompt(packages: ToolPackage[]): string;
4
4
  export declare const REPEAT_COMMAND_RULE = "--- \u91CD\u590D\u6307\u4EE4\u5904\u7406\u89C4\u5219 ---\n\u5982\u679C\u7528\u6237\u518D\u6B21\u53D1\u9001\u76F8\u540C\u6216\u7C7B\u4F3C\u7684\u6307\u4EE4\uFF08\u5373\u4F7F\u4E4B\u524D\u5DF2\u7ECF\u6267\u884C\u8FC7\uFF09\uFF0C\u5FC5\u987B\u91CD\u65B0\u8C03\u7528\u5BF9\u5E94\u7684\u5DE5\u5177\u518D\u6B21\u6267\u884C\u3002\n\u4E0D\u5F97\u4EE5\"\u5DF2\u7ECF\u6267\u884C\u8FC7\"\"\u4E4B\u524D\u505A\u8FC7\"\u7B49\u7406\u7531\u62D2\u7EDD\uFF0C\u4E5F\u4E0D\u80FD\u7528\u5386\u53F2\u4E2D\u7684\u5DE5\u5177\u7ED3\u679C\u4EE3\u66FF\u91CD\u65B0\u6267\u884C\u3002";
5
+ export declare const TOOL_REQUIREMENT_RULE = "--- \u5DE5\u5177\u524D\u7F6E\u6761\u4EF6\u89C4\u5219 ---\n1. \u8C03\u7528\u5DE5\u5177\u524D\u5148\u5BF9\u7167\u8BE5\u5DE5\u5177\u7684\"\u524D\u7F6E\u6761\u4EF6\"\uFF1B\u672A\u6EE1\u8DB3\u65F6\u5148\u8865\u9F50\uFF08\u8C03\u7528\u5EFA\u8BAE\u7684\u524D\u7F6E\u5DE5\u5177\uFF0C\u6216\u5411\u7528\u6237\u786E\u8BA4\uFF09\uFF0C\u4E0D\u8981\u76F4\u63A5\u8C03\u7528\u3002\n2. \u5982\u679C\u5DE5\u5177\u7ED3\u679C\u8FD4\u56DE {\"ok\":false,\"code\":\"REQUIREMENT_UNMET\"}\uFF0C\u7981\u6B62\u7F16\u9020\u6267\u884C\u7ED3\u679C\u3001\u7981\u6B62\u56DE\u590D\"\u5DF2\u5B8C\u6210\"\uFF1B\n \u5FC5\u987B\u6309 hint / suggestedTool \u8865\u9F50\u524D\u7F6E\u6761\u4EF6\u540E\u91CD\u8BD5\u540C\u4E00\u5DE5\u5177\u3002\n3. \u5C5E\u4E8E\"\u9700\u8981\u7528\u6237\u786E\u8BA4\"\u7684\u524D\u7F6E\u6761\u4EF6\u800C\u7528\u6237\u5C1A\u672A\u660E\u786E\u9009\u62E9\u65F6\uFF0C\u5FC5\u987B\u5148\u5411\u7528\u6237\u63D0\u95EE\uFF0C\u7981\u6B62\u81EA\u884C\u5047\u8BBE\u3002";
@@ -0,0 +1,21 @@
1
+ import { ChatMessage, SessionMeta } from '../types';
2
+ /**
3
+ * 会话存储抽象:
4
+ * - 直连模式 → createLocalSessionStore(localStorage)
5
+ * - 代理模式 → createProxySessionStore(server /api/sessions)
6
+ */
7
+ export interface SessionStore {
8
+ list(): Promise<SessionMeta[]>;
9
+ create(title: string): Promise<SessionMeta>;
10
+ load(id: string): Promise<ChatMessage[]>;
11
+ save(id: string, messages: ChatMessage[], patch?: {
12
+ title?: string;
13
+ }): Promise<SessionMeta | null>;
14
+ remove(id: string): Promise<void>;
15
+ }
16
+ /** 会话标题:首条用户消息前 24 字,其次文件名,最后回退"新对话" */
17
+ export declare function deriveSessionTitle(text: string, files?: Array<{
18
+ name?: string;
19
+ }>): string;
20
+ export declare function createLocalSessionStore(prefix: string): SessionStore;
21
+ export declare function createProxySessionStore(apiBase: string, deviceId: string): SessionStore;
@@ -0,0 +1,44 @@
1
+ import { ToolRequirement, ToolRequirementAction, ToolRequirementContext, ToolRequirementResult } from '../types';
2
+ /** 前置条件未满足的结构化错误码 */
3
+ export declare const REQUIREMENT_UNMET_CODE = "REQUIREMENT_UNMET";
4
+ export interface UnmetRequirement {
5
+ description: string;
6
+ check?: string;
7
+ message: string;
8
+ hint?: string;
9
+ suggestedTool?: string;
10
+ action: ToolRequirementAction;
11
+ }
12
+ export interface RequirementPayload {
13
+ ok: false;
14
+ code: typeof REQUIREMENT_UNMET_CODE;
15
+ tool: string;
16
+ requirements: Array<{
17
+ description: string;
18
+ check?: string;
19
+ message: string;
20
+ }>;
21
+ hint?: string;
22
+ suggestedTool?: string;
23
+ action: ToolRequirementAction;
24
+ retryable: true;
25
+ }
26
+ export type RequirementChecker = (ctx: ToolRequirementContext) => ToolRequirementResult | Promise<ToolRequirementResult>;
27
+ /** 单条 / 数组统一成数组 */
28
+ export declare function normalizeRequirements(input?: ToolRequirement | ToolRequirement[]): ToolRequirement[];
29
+ /**
30
+ * 评估前置条件。
31
+ * - 只声明了 tools 的条件是"提示词级建议",不拦截;
32
+ * - 声明了 check 的条件交给宿主 checker 判定(未提供 checker 时放行,由调用方告警);
33
+ * - checker 抛异常按未满足处理(fail-closed),避免半状态产生副作用。
34
+ */
35
+ export declare function evaluateRequirements(requirements: ToolRequirement[], ctx: {
36
+ sessionId: string;
37
+ packageId: string;
38
+ toolName: string;
39
+ args: Record<string, any>;
40
+ }, checker?: RequirementChecker): Promise<UnmetRequirement[]>;
41
+ /** 组装给模型看的结构化失败结果 */
42
+ export declare function buildRequirementPayload(toolName: string, unmet: UnmetRequirement[]): RequirementPayload;
43
+ /** 从失败结果里取一句可展示的原因(UI 用) */
44
+ export declare function summarizeRequirementFailure(result: string): string;