@axiom-lattice/protocols 1.0.1
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/.turbo/turbo-build.log +20 -0
- package/README.md +68 -0
- package/dist/index.d.mts +468 -0
- package/dist/index.d.ts +468 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +50 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -0
- package/src/AgentLatticeProtocol.ts +60 -0
- package/src/BaseLatticeProtocol.ts +59 -0
- package/src/MemoryLatticeProtocol.ts +55 -0
- package/src/MessageProtocol.ts +108 -0
- package/src/ModelLatticeProtocol.ts +45 -0
- package/src/StorageLatticeProtocol.ts +55 -0
- package/src/ToolLatticeProtocol.ts +40 -0
- package/src/UILatticeProtocol.ts +57 -0
- package/src/examples/MessageProtocolExample.ts +183 -0
- package/src/index.ts +17 -0
- package/src/types.ts +81 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
> @axiom-lattice/protocols@1.0.0 build /home/runner/work/agentic/agentic/packages/protocols
|
|
3
|
+
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.0
|
|
8
|
+
[34mCLI[39m Target: es2020
|
|
9
|
+
[34mCJS[39m Build start
|
|
10
|
+
[34mESM[39m Build start
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m2.67 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m6.47 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 41ms
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m1.56 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m5.96 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 42ms
|
|
17
|
+
[34mDTS[39m Build start
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 2317ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m10.35 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m10.35 KB[39m
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @axiom-lattice/protocols
|
|
2
|
+
|
|
3
|
+
Unified protocol type definitions for the Axiom Lattice framework.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides a collection of standardized protocol interfaces for the Axiom Lattice framework. These protocols define the contract between different components of the system, ensuring consistent behavior and interoperability.
|
|
8
|
+
|
|
9
|
+
## Protocols
|
|
10
|
+
|
|
11
|
+
- `BaseLatticeProtocol`: Base protocol for all lattice types
|
|
12
|
+
- `ModelLatticeProtocol`: Protocol for LLM model integration
|
|
13
|
+
- `ToolLatticeProtocol`: Protocol for tool execution
|
|
14
|
+
- `AgentLatticeProtocol`: Protocol for agent behavior
|
|
15
|
+
- `MemoryLatticeProtocol`: Protocol for memory management
|
|
16
|
+
- `StorageLatticeProtocol`: Protocol for data storage
|
|
17
|
+
- `UILatticeProtocol`: Protocol for UI components
|
|
18
|
+
- `MessageProtocol`: Protocol for standardized message communication
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import {
|
|
24
|
+
ModelLatticeProtocol,
|
|
25
|
+
ToolLatticeProtocol,
|
|
26
|
+
MessageProtocol,
|
|
27
|
+
Message,
|
|
28
|
+
UserMessage,
|
|
29
|
+
AssistantMessage,
|
|
30
|
+
} from "@axiom-lattice/protocols";
|
|
31
|
+
|
|
32
|
+
// Implement a model lattice
|
|
33
|
+
class MyModelLattice implements ModelLatticeProtocol {
|
|
34
|
+
// Implementation details...
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Implement a tool lattice
|
|
38
|
+
class MyToolLattice implements ToolLatticeProtocol {
|
|
39
|
+
// Implementation details...
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Use message protocol for communication
|
|
43
|
+
class MyMessageHandler implements MessageProtocol {
|
|
44
|
+
// Implementation details...
|
|
45
|
+
|
|
46
|
+
// Example of creating a conversation
|
|
47
|
+
createConversation() {
|
|
48
|
+
const messages: Message[] = [
|
|
49
|
+
{
|
|
50
|
+
id: "user_1",
|
|
51
|
+
role: "user",
|
|
52
|
+
content: "Hello, can you help me?",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "asst_1",
|
|
56
|
+
role: "assistant",
|
|
57
|
+
content: "Of course! What can I help you with today?",
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
return messages;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { StructuredTool } from '@langchain/core/tools';
|
|
2
|
+
import { ZodSchema } from 'zod';
|
|
3
|
+
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
4
|
+
import { BaseMessage as BaseMessage$1 } from '@langchain/core/messages';
|
|
5
|
+
import { ChatResult } from '@langchain/core/outputs';
|
|
6
|
+
import { CompiledStateGraph } from '@langchain/langgraph';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* BaseLatticeProtocol
|
|
10
|
+
*
|
|
11
|
+
* 所有Lattice类型的基础协议,定义了通用接口和行为
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* 基础Lattice协议接口
|
|
15
|
+
* @template TConfig 配置类型
|
|
16
|
+
* @template TClient 客户端类型
|
|
17
|
+
*/
|
|
18
|
+
interface BaseLatticeProtocol<TConfig = any, TClient = any> {
|
|
19
|
+
key: string;
|
|
20
|
+
config: TConfig;
|
|
21
|
+
client: TClient;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Lattice消息接口
|
|
25
|
+
*/
|
|
26
|
+
interface LatticeMessage {
|
|
27
|
+
type: string;
|
|
28
|
+
source: string;
|
|
29
|
+
target?: string;
|
|
30
|
+
payload: any;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
metadata?: Record<string, any>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Lattice错误接口
|
|
36
|
+
*/
|
|
37
|
+
interface LatticeError {
|
|
38
|
+
code: string;
|
|
39
|
+
message: string;
|
|
40
|
+
source: string;
|
|
41
|
+
stack?: string;
|
|
42
|
+
metadata?: Record<string, any>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Lattice事件总线接口
|
|
46
|
+
*/
|
|
47
|
+
interface LatticeEventBus {
|
|
48
|
+
subscribe: (eventType: string, handler: (message: LatticeMessage) => void) => void;
|
|
49
|
+
unsubscribe: (eventType: string, handler: (message: LatticeMessage) => void) => void;
|
|
50
|
+
publish: (eventType: string, message: LatticeMessage) => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* ToolLatticeProtocol
|
|
55
|
+
*
|
|
56
|
+
* 工具Lattice的协议,用于定义可执行的功能单元
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 工具配置接口
|
|
61
|
+
*/
|
|
62
|
+
interface ToolConfig {
|
|
63
|
+
name: string;
|
|
64
|
+
description: string;
|
|
65
|
+
schema?: ZodSchema<any>;
|
|
66
|
+
returnDirect?: boolean;
|
|
67
|
+
needUserApprove?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 工具执行函数类型
|
|
71
|
+
*/
|
|
72
|
+
type ToolExecutor<TInput = any, TOutput = any> = (input: TInput, config?: any) => Promise<TOutput>;
|
|
73
|
+
/**
|
|
74
|
+
* 工具Lattice协议接口
|
|
75
|
+
*/
|
|
76
|
+
interface ToolLatticeProtocol extends BaseLatticeProtocol<ToolConfig, StructuredTool> {
|
|
77
|
+
execute: ToolExecutor;
|
|
78
|
+
validate: (input: any) => boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* ModelLatticeProtocol
|
|
83
|
+
*
|
|
84
|
+
* 模型Lattice的协议,用于封装各种LLM模型的统一接口
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* LLM配置接口
|
|
89
|
+
*/
|
|
90
|
+
interface LLMConfig {
|
|
91
|
+
provider: "azure" | "openai" | "deepseek" | "siliconcloud" | "volcengine";
|
|
92
|
+
model: string;
|
|
93
|
+
maxTokens?: number;
|
|
94
|
+
temperature?: number;
|
|
95
|
+
timeout?: number;
|
|
96
|
+
maxRetries?: number;
|
|
97
|
+
streaming?: boolean;
|
|
98
|
+
apiKeyEnvName?: string;
|
|
99
|
+
baseURL?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 模型Lattice协议接口
|
|
103
|
+
*/
|
|
104
|
+
interface ModelLatticeProtocol extends BaseLatticeProtocol<LLMConfig, BaseChatModel> {
|
|
105
|
+
generate: (messages: BaseMessage$1[], options?: any) => Promise<ChatResult>;
|
|
106
|
+
invokeWithStructuredOutput: <T>(input: any, schema: ZodSchema<T>, options?: any) => Promise<T>;
|
|
107
|
+
bindTools: (tools: any[], options?: any) => any;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* AgentLatticeProtocol
|
|
112
|
+
*
|
|
113
|
+
* 智能体Lattice的协议,定义了智能体的行为和组合方式
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 智能体类型枚举
|
|
118
|
+
*/
|
|
119
|
+
declare enum AgentType {
|
|
120
|
+
REACT = "react",
|
|
121
|
+
DEEP_AGENT = "deep_agent",
|
|
122
|
+
PLAN_EXECUTE = "plan_execute",
|
|
123
|
+
SEQUENTIAL = "sequential"
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 智能体配置接口
|
|
127
|
+
*/
|
|
128
|
+
interface AgentConfig {
|
|
129
|
+
key: string;
|
|
130
|
+
name: string;
|
|
131
|
+
description: string;
|
|
132
|
+
type: AgentType;
|
|
133
|
+
tools?: string[];
|
|
134
|
+
subAgents?: string[];
|
|
135
|
+
prompt: string;
|
|
136
|
+
schema?: ZodSchema<any>;
|
|
137
|
+
modelKey?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 智能体客户端类型
|
|
141
|
+
*/
|
|
142
|
+
type AgentClient = CompiledStateGraph<any, any, any, any, any>;
|
|
143
|
+
/**
|
|
144
|
+
* Graph构建选项
|
|
145
|
+
*/
|
|
146
|
+
interface GraphBuildOptions {
|
|
147
|
+
overrideTools?: string[];
|
|
148
|
+
overrideModel?: string;
|
|
149
|
+
metadata?: Record<string, any>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 智能体Lattice协议接口
|
|
153
|
+
*/
|
|
154
|
+
interface AgentLatticeProtocol extends BaseLatticeProtocol<AgentConfig, AgentClient> {
|
|
155
|
+
invoke: (input: any, options?: any) => Promise<any>;
|
|
156
|
+
buildGraph: (options?: GraphBuildOptions) => Promise<AgentClient>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* MemoryLatticeProtocol
|
|
161
|
+
*
|
|
162
|
+
* 记忆Lattice的协议,用于管理智能体的上下文和记忆
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 记忆类型枚举
|
|
167
|
+
*/
|
|
168
|
+
declare enum MemoryType {
|
|
169
|
+
SHORT_TERM = "short_term",
|
|
170
|
+
LONG_TERM = "long_term",
|
|
171
|
+
EPISODIC = "episodic",
|
|
172
|
+
SEMANTIC = "semantic",
|
|
173
|
+
WORKING = "working"
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 记忆配置接口
|
|
177
|
+
*/
|
|
178
|
+
interface MemoryConfig {
|
|
179
|
+
name: string;
|
|
180
|
+
description: string;
|
|
181
|
+
type: MemoryType;
|
|
182
|
+
ttl?: number;
|
|
183
|
+
capacity?: number;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* 记忆客户端接口
|
|
187
|
+
*/
|
|
188
|
+
interface MemoryClient {
|
|
189
|
+
add: (key: string, value: any) => Promise<void>;
|
|
190
|
+
get: (key: string) => Promise<any>;
|
|
191
|
+
update: (key: string, value: any) => Promise<void>;
|
|
192
|
+
delete: (key: string) => Promise<void>;
|
|
193
|
+
search: (query: string, options?: any) => Promise<any[]>;
|
|
194
|
+
clear: () => Promise<void>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* 记忆Lattice协议接口
|
|
198
|
+
*/
|
|
199
|
+
interface MemoryLatticeProtocol extends BaseLatticeProtocol<MemoryConfig, MemoryClient> {
|
|
200
|
+
add: (key: string, value: any) => Promise<void>;
|
|
201
|
+
get: (key: string) => Promise<any>;
|
|
202
|
+
update: (key: string, value: any) => Promise<void>;
|
|
203
|
+
delete: (key: string) => Promise<void>;
|
|
204
|
+
search: (query: string, options?: any) => Promise<any[]>;
|
|
205
|
+
clear: () => Promise<void>;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* StorageLatticeProtocol
|
|
210
|
+
*
|
|
211
|
+
* 存储Lattice的协议,用于数据持久化和状态管理
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 存储类型枚举
|
|
216
|
+
*/
|
|
217
|
+
declare enum StorageType {
|
|
218
|
+
MEMORY = "memory",
|
|
219
|
+
LOCAL = "local",
|
|
220
|
+
DATABASE = "database",
|
|
221
|
+
CLOUD = "cloud",
|
|
222
|
+
DISTRIBUTED = "distributed"
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 存储配置接口
|
|
226
|
+
*/
|
|
227
|
+
interface StorageConfig {
|
|
228
|
+
name: string;
|
|
229
|
+
description: string;
|
|
230
|
+
type: StorageType;
|
|
231
|
+
connectionString?: string;
|
|
232
|
+
options?: Record<string, any>;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 存储客户端接口
|
|
236
|
+
*/
|
|
237
|
+
interface StorageClient {
|
|
238
|
+
set: (key: string, value: any) => Promise<void>;
|
|
239
|
+
get: (key: string) => Promise<any>;
|
|
240
|
+
has: (key: string) => Promise<boolean>;
|
|
241
|
+
delete: (key: string) => Promise<boolean>;
|
|
242
|
+
clear: () => Promise<void>;
|
|
243
|
+
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* 存储Lattice协议接口
|
|
247
|
+
*/
|
|
248
|
+
interface StorageLatticeProtocol extends BaseLatticeProtocol<StorageConfig, StorageClient> {
|
|
249
|
+
set: (key: string, value: any) => Promise<void>;
|
|
250
|
+
get: (key: string) => Promise<any>;
|
|
251
|
+
has: (key: string) => Promise<boolean>;
|
|
252
|
+
delete: (key: string) => Promise<boolean>;
|
|
253
|
+
clear: () => Promise<void>;
|
|
254
|
+
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* UILatticeProtocol
|
|
259
|
+
*
|
|
260
|
+
* UI Lattice的协议,用于定义用户界面组件
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* UI组件类型枚举
|
|
265
|
+
*/
|
|
266
|
+
declare enum UIComponentType {
|
|
267
|
+
CONTAINER = "container",
|
|
268
|
+
INPUT = "input",
|
|
269
|
+
BUTTON = "button",
|
|
270
|
+
LIST = "list",
|
|
271
|
+
TABLE = "table",
|
|
272
|
+
CHART = "chart",
|
|
273
|
+
FORM = "form",
|
|
274
|
+
CARD = "card",
|
|
275
|
+
MODAL = "modal",
|
|
276
|
+
CUSTOM = "custom"
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* UI配置接口
|
|
280
|
+
*/
|
|
281
|
+
interface UIConfig {
|
|
282
|
+
name: string;
|
|
283
|
+
description: string;
|
|
284
|
+
type: UIComponentType;
|
|
285
|
+
props?: Record<string, any>;
|
|
286
|
+
children?: string[];
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* UI组件接口
|
|
290
|
+
* 使用泛型以适应不同的UI框架(React, Vue等)
|
|
291
|
+
*/
|
|
292
|
+
interface UIComponent<T = any> {
|
|
293
|
+
render: (props?: any) => T;
|
|
294
|
+
addEventListener: (event: string, handler: Function) => void;
|
|
295
|
+
removeEventListener: (event: string, handler: Function) => void;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* UI Lattice协议接口
|
|
299
|
+
*/
|
|
300
|
+
interface UILatticeProtocol<T = any> extends BaseLatticeProtocol<UIConfig, UIComponent<T>> {
|
|
301
|
+
render: (props?: any) => T;
|
|
302
|
+
addEventListener: (event: string, handler: Function) => void;
|
|
303
|
+
removeEventListener: (event: string, handler: Function) => void;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* MessageProtocol
|
|
308
|
+
*
|
|
309
|
+
*/
|
|
310
|
+
/**
|
|
311
|
+
* Base message interface
|
|
312
|
+
*/
|
|
313
|
+
interface BaseMessage {
|
|
314
|
+
id: string;
|
|
315
|
+
role: string;
|
|
316
|
+
content?: string;
|
|
317
|
+
name?: string;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* User message interface
|
|
321
|
+
*/
|
|
322
|
+
interface UserMessage extends BaseMessage {
|
|
323
|
+
role: "human";
|
|
324
|
+
content: string;
|
|
325
|
+
files?: Array<{
|
|
326
|
+
name: string;
|
|
327
|
+
id: string;
|
|
328
|
+
}>;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Tool call interface
|
|
332
|
+
*/
|
|
333
|
+
interface ToolCall {
|
|
334
|
+
id: string;
|
|
335
|
+
name: string;
|
|
336
|
+
args: Record<string, any>;
|
|
337
|
+
type: "tool_call";
|
|
338
|
+
response?: string;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Assistant message interface
|
|
342
|
+
*/
|
|
343
|
+
interface AssistantMessage extends BaseMessage {
|
|
344
|
+
role: "ai";
|
|
345
|
+
content?: string;
|
|
346
|
+
tool_calls?: ToolCall[];
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* System message interface
|
|
350
|
+
*/
|
|
351
|
+
interface SystemMessage extends BaseMessage {
|
|
352
|
+
role: "system";
|
|
353
|
+
content: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Tool message interface
|
|
357
|
+
*/
|
|
358
|
+
interface ToolMessage extends BaseMessage {
|
|
359
|
+
role: "tool";
|
|
360
|
+
content: string;
|
|
361
|
+
tool_call_id: string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Developer message interface
|
|
365
|
+
*/
|
|
366
|
+
interface DeveloperMessage extends BaseMessage {
|
|
367
|
+
role: "developer";
|
|
368
|
+
content: string;
|
|
369
|
+
}
|
|
370
|
+
interface MessageChunk {
|
|
371
|
+
type: string;
|
|
372
|
+
data: {
|
|
373
|
+
id: string;
|
|
374
|
+
content?: string;
|
|
375
|
+
tool_call_chunks?: Array<{
|
|
376
|
+
name?: string;
|
|
377
|
+
args?: string;
|
|
378
|
+
id?: string;
|
|
379
|
+
index: number;
|
|
380
|
+
}>;
|
|
381
|
+
tool_calls?: Array<{
|
|
382
|
+
name: string;
|
|
383
|
+
args: Record<string, any>;
|
|
384
|
+
id: string;
|
|
385
|
+
type: string;
|
|
386
|
+
response?: string;
|
|
387
|
+
}>;
|
|
388
|
+
additional_kwargs?: {
|
|
389
|
+
tool_calls?: Array<{
|
|
390
|
+
function?: {
|
|
391
|
+
name?: string;
|
|
392
|
+
arguments?: any;
|
|
393
|
+
};
|
|
394
|
+
id?: string;
|
|
395
|
+
}>;
|
|
396
|
+
};
|
|
397
|
+
tool_call_id?: string;
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Message type union
|
|
402
|
+
*/
|
|
403
|
+
type Message = UserMessage | AssistantMessage | SystemMessage | ToolMessage | DeveloperMessage;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* 通用类型定义
|
|
407
|
+
*
|
|
408
|
+
* 提供跨Lattice使用的通用类型
|
|
409
|
+
*/
|
|
410
|
+
/**
|
|
411
|
+
* 通用结果接口
|
|
412
|
+
*/
|
|
413
|
+
interface Result<T = any> {
|
|
414
|
+
success: boolean;
|
|
415
|
+
data?: T;
|
|
416
|
+
error?: string;
|
|
417
|
+
metadata?: Record<string, any>;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* 分页请求参数
|
|
421
|
+
*/
|
|
422
|
+
interface PaginationParams {
|
|
423
|
+
page?: number;
|
|
424
|
+
pageSize?: number;
|
|
425
|
+
sortBy?: string;
|
|
426
|
+
sortOrder?: "asc" | "desc";
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* 分页响应结果
|
|
430
|
+
*/
|
|
431
|
+
interface PaginatedResult<T = any> {
|
|
432
|
+
items: T[];
|
|
433
|
+
total: number;
|
|
434
|
+
page: number;
|
|
435
|
+
pageSize: number;
|
|
436
|
+
totalPages: number;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* 过滤条件
|
|
440
|
+
*/
|
|
441
|
+
interface FilterCondition {
|
|
442
|
+
field: string;
|
|
443
|
+
operator: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "contains" | "startsWith" | "endsWith";
|
|
444
|
+
value: any;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* 查询参数
|
|
448
|
+
*/
|
|
449
|
+
interface QueryParams {
|
|
450
|
+
pagination?: PaginationParams;
|
|
451
|
+
filters?: FilterCondition[];
|
|
452
|
+
search?: string;
|
|
453
|
+
includes?: string[];
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* 通用ID类型
|
|
457
|
+
*/
|
|
458
|
+
type ID = string | number;
|
|
459
|
+
/**
|
|
460
|
+
* 时间戳类型
|
|
461
|
+
*/
|
|
462
|
+
type Timestamp = number;
|
|
463
|
+
/**
|
|
464
|
+
* 通用回调函数类型
|
|
465
|
+
*/
|
|
466
|
+
type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
|
|
467
|
+
|
|
468
|
+
export { type AgentClient, type AgentConfig, type AgentLatticeProtocol, AgentType, type AssistantMessage, type BaseLatticeProtocol, type BaseMessage, type Callback, type DeveloperMessage, type FilterCondition, type GraphBuildOptions, type ID, type LLMConfig, type LatticeError, type LatticeEventBus, type LatticeMessage, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type QueryParams, type Result, type StorageClient, type StorageConfig, type StorageLatticeProtocol, StorageType, type SystemMessage, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UserMessage };
|