@huyooo/ai-chat-types 0.2.34 → 0.2.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/index.d.ts +13 -13
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/index.ts +15 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _huyooo_ai_chat_core_events from '@huyooo/ai-chat-core/events';
|
|
2
|
+
export { AbortEvent, ChatEvent, ChatEventType, DoneEvent, ErrorCategory, ErrorDetails, ErrorEvent, PlanStep, PlanStepStatus, SearchEndEvent, SearchEvent, SearchResult, SearchResultEvent, SearchStartEvent, SideEffect, StatusEvent, StepEndEvent, StepEvent, StepStartEvent, TextDeltaEvent, TextEvent, ThinkingDeltaEvent, ThinkingEndEvent, ThinkingEvent, ThinkingStartEvent, TokenUsage, ToolApprovalRequestEvent, ToolCallInfo, ToolCallOutputEvent, ToolCallResultEvent, ToolCallStartEvent, ToolCallStatus, ToolErrorShape, ToolEvent, createAbort, createApiError, createDone, createError, createParseError, createRateLimitError, createSearchEnd, createSearchResult, createSearchStart, createStepEnd, createStepStart, createTextDelta, createThinkingDelta, createThinkingEnd, createThinkingStart, createThrowableToolError, createTimeoutError, createToolCallOutput, createToolCallResult, createToolCallStart, createToolError, isAbortEvent, isErrorEvent, isRetryableError, isSearchEvent, isStatusEvent, isStepEvent, isTextEvent, isThinkingEvent, isThrowableToolError, isToolEvent } from '@huyooo/ai-chat-core/events';
|
|
2
3
|
import { ModelOption, ChatEvent } from '@huyooo/ai-chat-core';
|
|
3
4
|
export { AutoRunConfig, AutoRunMode, McpConnectionInfo, McpConnectionStatus, McpServerConfig, ModelOption, ProviderType, ThinkingMode } from '@huyooo/ai-chat-core';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* @huyooo/ai-chat-types
|
|
7
|
-
*
|
|
8
|
-
* AI Chat 公共类型定义
|
|
9
|
-
*
|
|
10
|
-
* 架构层级:
|
|
11
|
-
* 1. ai-chat-core - 核心引擎(定义事件、工具等核心类型)
|
|
12
|
-
* 2. ai-chat-types - 公共接口(导出 ChatAdapter、重新导出 ChatEvent)
|
|
13
|
-
* 3. 各适配器包 - 实现 ChatAdapter 接口
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
6
|
/** 对话模式(扩展支持 'plan',兼容旧数据) */
|
|
17
7
|
type ChatMode = 'agent' | 'ask' | 'plan';
|
|
18
8
|
/** 聊天历史消息(无状态架构传入) */
|
|
@@ -132,6 +122,14 @@ interface ToolApprovalRequest {
|
|
|
132
122
|
name: string;
|
|
133
123
|
args: Record<string, unknown>;
|
|
134
124
|
}
|
|
125
|
+
/** 工具执行结果(executeTool 返回值) */
|
|
126
|
+
interface ToolExecutionResult {
|
|
127
|
+
success: boolean;
|
|
128
|
+
result: string;
|
|
129
|
+
error?: string;
|
|
130
|
+
resultType?: string;
|
|
131
|
+
toolError?: _huyooo_ai_chat_core_events.ToolErrorShape;
|
|
132
|
+
}
|
|
135
133
|
/** ASR 会话配置 */
|
|
136
134
|
interface AsrSessionConfig {
|
|
137
135
|
/** 音频格式 */
|
|
@@ -294,6 +292,8 @@ interface ChatAdapter {
|
|
|
294
292
|
}>;
|
|
295
293
|
onToolApprovalRequest?(callback: (request: ToolApprovalRequest) => void): () => void;
|
|
296
294
|
respondToolApproval?(id: string, approved: boolean): Promise<void>;
|
|
295
|
+
/** 执行工具(用于重试失败的工具调用,Electron 等支持) */
|
|
296
|
+
executeTool?(name: string, args: Record<string, unknown>): Promise<ToolExecutionResult>;
|
|
297
297
|
asrStart?(config?: AsrSessionConfig): Promise<{
|
|
298
298
|
success: boolean;
|
|
299
299
|
error?: string;
|
|
@@ -386,4 +386,4 @@ interface SendMessageParams {
|
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
export type { AsrResultData, AsrSessionConfig, ChatAdapter, ChatHistoryMessage, ChatMode, ChatOptions, CreateSessionParams, FileInfo, MessageRecord, OperationRecord, SaveMessageParams, SendMessageParams, SessionRecord, SkillRecord, ToolApprovalRequest, ToolInfo, TrashRecord, UpdateMessageParams, UpdateSessionParams };
|
|
389
|
+
export type { AsrResultData, AsrSessionConfig, ChatAdapter, ChatHistoryMessage, ChatMode, ChatOptions, CreateSessionParams, FileInfo, MessageRecord, OperationRecord, SaveMessageParams, SendMessageParams, SessionRecord, SkillRecord, ToolApprovalRequest, ToolExecutionResult, ToolInfo, TrashRecord, UpdateMessageParams, UpdateSessionParams };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createThinkingStart as o,createThinkingDelta as e,createThinkingEnd as r,createSearchStart as t,createSearchResult as a,createSearchEnd as c,createToolCallStart as h,createToolCallResult as i,createToolCallOutput as m,createTextDelta as p,createDone as f,createError as n,createApiError as s,createRateLimitError as u,createToolError as v,createTimeoutError as x,createParseError as y,createAbort as b,createStepStart as d,createStepEnd as g,isThinkingEvent as j,isSearchEvent as k,isToolEvent as l,isTextEvent as q,isStatusEvent as w,isErrorEvent as z,isAbortEvent as A,isStepEvent as B,isRetryableError as C}from"@huyooo/ai-chat-core/events";export{b as createAbort,s as createApiError,f as createDone,n as createError,y as createParseError,u as createRateLimitError,c as createSearchEnd,a as createSearchResult,t as createSearchStart,g as createStepEnd,d as createStepStart,p as createTextDelta,e as createThinkingDelta,r as createThinkingEnd,o as createThinkingStart,x as createTimeoutError,m as createToolCallOutput,i as createToolCallResult,h as createToolCallStart,v as createToolError,A as isAbortEvent,z as isErrorEvent,C as isRetryableError,k as isSearchEvent,w as isStatusEvent,B as isStepEvent,q as isTextEvent,j as isThinkingEvent,l as isToolEvent};
|
|
1
|
+
import{createThinkingStart as o,createThinkingDelta as e,createThinkingEnd as r,createSearchStart as t,createSearchResult as a,createSearchEnd as c,createToolCallStart as h,createToolCallResult as i,createToolCallOutput as m,createTextDelta as p,createDone as f,createError as n,createApiError as s,createRateLimitError as u,createToolError as v,createTimeoutError as x,createParseError as y,createAbort as b,createStepStart as d,createStepEnd as g,isThinkingEvent as j,isSearchEvent as k,isToolEvent as l,isTextEvent as q,isStatusEvent as w,isErrorEvent as z,isAbortEvent as A,isStepEvent as B,isRetryableError as C,createThrowableToolError as D,isThrowableToolError as E}from"@huyooo/ai-chat-core/events";export{b as createAbort,s as createApiError,f as createDone,n as createError,y as createParseError,u as createRateLimitError,c as createSearchEnd,a as createSearchResult,t as createSearchStart,g as createStepEnd,d as createStepStart,p as createTextDelta,e as createThinkingDelta,r as createThinkingEnd,o as createThinkingStart,D as createThrowableToolError,x as createTimeoutError,m as createToolCallOutput,i as createToolCallResult,h as createToolCallStart,v as createToolError,A as isAbortEvent,z as isErrorEvent,C as isRetryableError,k as isSearchEvent,w as isStatusEvent,B as isStepEvent,q as isTextEvent,j as isThinkingEvent,E as isThrowableToolError,l as isToolEvent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huyooo/ai-chat-types",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.36",
|
|
4
4
|
"description": "AI Chat 通用类型定义 - 支持 Electron/Web/CLI 多端",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@huyooo/ai-chat-core": "^0.2.
|
|
26
|
+
"@huyooo/ai-chat-core": "^0.2.36"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"tsup": "^8.0.0",
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type {
|
|
|
25
25
|
TokenUsage,
|
|
26
26
|
ErrorCategory,
|
|
27
27
|
ErrorDetails,
|
|
28
|
+
ToolErrorShape,
|
|
28
29
|
SideEffect,
|
|
29
30
|
|
|
30
31
|
// 思考事件
|
|
@@ -97,6 +98,8 @@ export {
|
|
|
97
98
|
isAbortEvent,
|
|
98
99
|
isStepEvent,
|
|
99
100
|
isRetryableError,
|
|
101
|
+
createThrowableToolError,
|
|
102
|
+
isThrowableToolError,
|
|
100
103
|
} from '@huyooo/ai-chat-core/events'
|
|
101
104
|
|
|
102
105
|
// ==================== 从 ai-chat-core 重新导出配置类型 ====================
|
|
@@ -251,6 +254,15 @@ export interface ToolApprovalRequest {
|
|
|
251
254
|
args: Record<string, unknown>
|
|
252
255
|
}
|
|
253
256
|
|
|
257
|
+
/** 工具执行结果(executeTool 返回值) */
|
|
258
|
+
export interface ToolExecutionResult {
|
|
259
|
+
success: boolean
|
|
260
|
+
result: string
|
|
261
|
+
error?: string
|
|
262
|
+
resultType?: string
|
|
263
|
+
toolError?: import('@huyooo/ai-chat-core/events').ToolErrorShape
|
|
264
|
+
}
|
|
265
|
+
|
|
254
266
|
// ==================== ASR 语音识别 ====================
|
|
255
267
|
|
|
256
268
|
/** ASR 会话配置 */
|
|
@@ -402,6 +414,9 @@ export interface ChatAdapter {
|
|
|
402
414
|
onToolApprovalRequest?(callback: (request: ToolApprovalRequest) => void): () => void
|
|
403
415
|
respondToolApproval?(id: string, approved: boolean): Promise<void>
|
|
404
416
|
|
|
417
|
+
/** 执行工具(用于重试失败的工具调用,Electron 等支持) */
|
|
418
|
+
executeTool?(name: string, args: Record<string, unknown>): Promise<ToolExecutionResult>
|
|
419
|
+
|
|
405
420
|
// ============ ASR API(可选)============
|
|
406
421
|
asrStart?(config?: AsrSessionConfig): Promise<{ success: boolean; error?: string }>
|
|
407
422
|
asrSendAudio?(audioData: ArrayBufferLike): Promise<{ success: boolean; error?: string }>
|