@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.
@@ -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 };
package/dist/index.js ADDED
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AgentType: () => AgentType,
24
+ MemoryType: () => MemoryType,
25
+ StorageType: () => StorageType,
26
+ UIComponentType: () => UIComponentType
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/AgentLatticeProtocol.ts
31
+ var AgentType = /* @__PURE__ */ ((AgentType2) => {
32
+ AgentType2["REACT"] = "react";
33
+ AgentType2["DEEP_AGENT"] = "deep_agent";
34
+ AgentType2["PLAN_EXECUTE"] = "plan_execute";
35
+ AgentType2["SEQUENTIAL"] = "sequential";
36
+ return AgentType2;
37
+ })(AgentType || {});
38
+
39
+ // src/MemoryLatticeProtocol.ts
40
+ var MemoryType = /* @__PURE__ */ ((MemoryType2) => {
41
+ MemoryType2["SHORT_TERM"] = "short_term";
42
+ MemoryType2["LONG_TERM"] = "long_term";
43
+ MemoryType2["EPISODIC"] = "episodic";
44
+ MemoryType2["SEMANTIC"] = "semantic";
45
+ MemoryType2["WORKING"] = "working";
46
+ return MemoryType2;
47
+ })(MemoryType || {});
48
+
49
+ // src/StorageLatticeProtocol.ts
50
+ var StorageType = /* @__PURE__ */ ((StorageType2) => {
51
+ StorageType2["MEMORY"] = "memory";
52
+ StorageType2["LOCAL"] = "local";
53
+ StorageType2["DATABASE"] = "database";
54
+ StorageType2["CLOUD"] = "cloud";
55
+ StorageType2["DISTRIBUTED"] = "distributed";
56
+ return StorageType2;
57
+ })(StorageType || {});
58
+
59
+ // src/UILatticeProtocol.ts
60
+ var UIComponentType = /* @__PURE__ */ ((UIComponentType2) => {
61
+ UIComponentType2["CONTAINER"] = "container";
62
+ UIComponentType2["INPUT"] = "input";
63
+ UIComponentType2["BUTTON"] = "button";
64
+ UIComponentType2["LIST"] = "list";
65
+ UIComponentType2["TABLE"] = "table";
66
+ UIComponentType2["CHART"] = "chart";
67
+ UIComponentType2["FORM"] = "form";
68
+ UIComponentType2["CARD"] = "card";
69
+ UIComponentType2["MODAL"] = "modal";
70
+ UIComponentType2["CUSTOM"] = "custom";
71
+ return UIComponentType2;
72
+ })(UIComponentType || {});
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ AgentType,
76
+ MemoryType,
77
+ StorageType,
78
+ UIComponentType
79
+ });
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/StorageLatticeProtocol.ts","../src/UILatticeProtocol.ts"],"sourcesContent":["/**\n * Protocols\n *\n * 导出所有Lattice协议接口,为整个系统提供统一的接口规范\n */\n\nexport * from \"./BaseLatticeProtocol\";\nexport * from \"./ToolLatticeProtocol\";\nexport * from \"./ModelLatticeProtocol\";\nexport * from \"./AgentLatticeProtocol\";\nexport * from \"./MemoryLatticeProtocol\";\nexport * from \"./StorageLatticeProtocol\";\nexport * from \"./UILatticeProtocol\";\nexport * from \"./MessageProtocol\";\n\n// 导出通用类型\nexport * from \"./types\";\n","/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport { ZodSchema } from \"zod\";\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 智能体类型枚举\n */\nexport enum AgentType {\n REACT = \"react\",\n DEEP_AGENT = \"deep_agent\",\n PLAN_EXECUTE = \"plan_execute\",\n SEQUENTIAL = \"sequential\",\n}\n\n/**\n * 智能体配置接口\n */\nexport interface AgentConfig {\n key: string; // 唯一键\n name: string; // 名称\n description: string; // 描述\n type: AgentType; // 智能体类型\n tools?: string[]; // 使用的工具列表\n subAgents?: string[]; // 子智能体列表\n prompt: string; // 提示词\n schema?: ZodSchema<any>; // 输入验证模式\n modelKey?: string; // 使用的模型键\n}\n\n/**\n * 智能体客户端类型\n */\nexport type AgentClient = CompiledStateGraph<any, any, any, any, any>;\n\n/**\n * Graph构建选项\n */\nexport interface GraphBuildOptions {\n overrideTools?: string[];\n overrideModel?: string;\n metadata?: Record<string, any>;\n}\n\n/**\n * 智能体Lattice协议接口\n */\nexport interface AgentLatticeProtocol\n extends BaseLatticeProtocol<AgentConfig, AgentClient> {\n // 智能体执行函数\n invoke: (input: any, options?: any) => Promise<any>;\n\n // 构建智能体图\n buildGraph: (options?: GraphBuildOptions) => Promise<AgentClient>;\n}\n","/**\n * MemoryLatticeProtocol\n *\n * 记忆Lattice的协议,用于管理智能体的上下文和记忆\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 记忆类型枚举\n */\nexport enum MemoryType {\n SHORT_TERM = \"short_term\",\n LONG_TERM = \"long_term\",\n EPISODIC = \"episodic\",\n SEMANTIC = \"semantic\",\n WORKING = \"working\",\n}\n\n/**\n * 记忆配置接口\n */\nexport interface MemoryConfig {\n name: string; // 名称\n description: string; // 描述\n type: MemoryType; // 记忆类型\n ttl?: number; // 生存时间\n capacity?: number; // 容量限制\n}\n\n/**\n * 记忆客户端接口\n */\nexport interface MemoryClient {\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n\n/**\n * 记忆Lattice协议接口\n */\nexport interface MemoryLatticeProtocol\n extends BaseLatticeProtocol<MemoryConfig, MemoryClient> {\n // 记忆操作方法\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n","/**\n * StorageLatticeProtocol\n *\n * 存储Lattice的协议,用于数据持久化和状态管理\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 存储类型枚举\n */\nexport enum StorageType {\n MEMORY = \"memory\",\n LOCAL = \"local\",\n DATABASE = \"database\",\n CLOUD = \"cloud\",\n DISTRIBUTED = \"distributed\",\n}\n\n/**\n * 存储配置接口\n */\nexport interface StorageConfig {\n name: string; // 名称\n description: string; // 描述\n type: StorageType; // 存储类型\n connectionString?: string; // 连接字符串\n options?: Record<string, any>; // 其他选项\n}\n\n/**\n * 存储客户端接口\n */\nexport interface StorageClient {\n set: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n has: (key: string) => Promise<boolean>;\n delete: (key: string) => Promise<boolean>;\n clear: () => Promise<void>;\n transaction: <T>(operations: () => Promise<T>) => Promise<T>;\n}\n\n/**\n * 存储Lattice协议接口\n */\nexport interface StorageLatticeProtocol\n extends BaseLatticeProtocol<StorageConfig, StorageClient> {\n // 存储操作方法\n set: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n has: (key: string) => Promise<boolean>;\n delete: (key: string) => Promise<boolean>;\n clear: () => Promise<void>;\n transaction: <T>(operations: () => Promise<T>) => Promise<T>;\n}\n","/**\n * UILatticeProtocol\n *\n * UI Lattice的协议,用于定义用户界面组件\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * UI组件类型枚举\n */\nexport enum UIComponentType {\n CONTAINER = \"container\",\n INPUT = \"input\",\n BUTTON = \"button\",\n LIST = \"list\",\n TABLE = \"table\",\n CHART = \"chart\",\n FORM = \"form\",\n CARD = \"card\",\n MODAL = \"modal\",\n CUSTOM = \"custom\",\n}\n\n/**\n * UI配置接口\n */\nexport interface UIConfig {\n name: string; // 组件名称\n description: string; // 组件描述\n type: UIComponentType; // 组件类型\n props?: Record<string, any>; // 组件属性\n children?: string[]; // 子组件列表\n}\n\n/**\n * UI组件接口\n * 使用泛型以适应不同的UI框架(React, Vue等)\n */\nexport interface UIComponent<T = any> {\n render: (props?: any) => T;\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n\n/**\n * UI Lattice协议接口\n */\nexport interface UILatticeProtocol<T = any>\n extends BaseLatticeProtocol<UIConfig, UIComponent<T>> {\n // UI渲染方法\n render: (props?: any) => T;\n\n // 事件处理\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,kBAAe;AACf,EAAAA,WAAA,gBAAa;AAJH,SAAAA;AAAA,GAAA;;;ACFL,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,aAAU;AALA,SAAAA;AAAA,GAAA;;;ACAL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,YAAS;AACT,EAAAA,aAAA,WAAQ;AACR,EAAAA,aAAA,cAAW;AACX,EAAAA,aAAA,WAAQ;AACR,EAAAA,aAAA,iBAAc;AALJ,SAAAA;AAAA,GAAA;;;ACAL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,eAAY;AACZ,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AACT,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AAVC,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","StorageType","UIComponentType"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,50 @@
1
+ // src/AgentLatticeProtocol.ts
2
+ var AgentType = /* @__PURE__ */ ((AgentType2) => {
3
+ AgentType2["REACT"] = "react";
4
+ AgentType2["DEEP_AGENT"] = "deep_agent";
5
+ AgentType2["PLAN_EXECUTE"] = "plan_execute";
6
+ AgentType2["SEQUENTIAL"] = "sequential";
7
+ return AgentType2;
8
+ })(AgentType || {});
9
+
10
+ // src/MemoryLatticeProtocol.ts
11
+ var MemoryType = /* @__PURE__ */ ((MemoryType2) => {
12
+ MemoryType2["SHORT_TERM"] = "short_term";
13
+ MemoryType2["LONG_TERM"] = "long_term";
14
+ MemoryType2["EPISODIC"] = "episodic";
15
+ MemoryType2["SEMANTIC"] = "semantic";
16
+ MemoryType2["WORKING"] = "working";
17
+ return MemoryType2;
18
+ })(MemoryType || {});
19
+
20
+ // src/StorageLatticeProtocol.ts
21
+ var StorageType = /* @__PURE__ */ ((StorageType2) => {
22
+ StorageType2["MEMORY"] = "memory";
23
+ StorageType2["LOCAL"] = "local";
24
+ StorageType2["DATABASE"] = "database";
25
+ StorageType2["CLOUD"] = "cloud";
26
+ StorageType2["DISTRIBUTED"] = "distributed";
27
+ return StorageType2;
28
+ })(StorageType || {});
29
+
30
+ // src/UILatticeProtocol.ts
31
+ var UIComponentType = /* @__PURE__ */ ((UIComponentType2) => {
32
+ UIComponentType2["CONTAINER"] = "container";
33
+ UIComponentType2["INPUT"] = "input";
34
+ UIComponentType2["BUTTON"] = "button";
35
+ UIComponentType2["LIST"] = "list";
36
+ UIComponentType2["TABLE"] = "table";
37
+ UIComponentType2["CHART"] = "chart";
38
+ UIComponentType2["FORM"] = "form";
39
+ UIComponentType2["CARD"] = "card";
40
+ UIComponentType2["MODAL"] = "modal";
41
+ UIComponentType2["CUSTOM"] = "custom";
42
+ return UIComponentType2;
43
+ })(UIComponentType || {});
44
+ export {
45
+ AgentType,
46
+ MemoryType,
47
+ StorageType,
48
+ UIComponentType
49
+ };
50
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/StorageLatticeProtocol.ts","../src/UILatticeProtocol.ts"],"sourcesContent":["/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport { ZodSchema } from \"zod\";\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 智能体类型枚举\n */\nexport enum AgentType {\n REACT = \"react\",\n DEEP_AGENT = \"deep_agent\",\n PLAN_EXECUTE = \"plan_execute\",\n SEQUENTIAL = \"sequential\",\n}\n\n/**\n * 智能体配置接口\n */\nexport interface AgentConfig {\n key: string; // 唯一键\n name: string; // 名称\n description: string; // 描述\n type: AgentType; // 智能体类型\n tools?: string[]; // 使用的工具列表\n subAgents?: string[]; // 子智能体列表\n prompt: string; // 提示词\n schema?: ZodSchema<any>; // 输入验证模式\n modelKey?: string; // 使用的模型键\n}\n\n/**\n * 智能体客户端类型\n */\nexport type AgentClient = CompiledStateGraph<any, any, any, any, any>;\n\n/**\n * Graph构建选项\n */\nexport interface GraphBuildOptions {\n overrideTools?: string[];\n overrideModel?: string;\n metadata?: Record<string, any>;\n}\n\n/**\n * 智能体Lattice协议接口\n */\nexport interface AgentLatticeProtocol\n extends BaseLatticeProtocol<AgentConfig, AgentClient> {\n // 智能体执行函数\n invoke: (input: any, options?: any) => Promise<any>;\n\n // 构建智能体图\n buildGraph: (options?: GraphBuildOptions) => Promise<AgentClient>;\n}\n","/**\n * MemoryLatticeProtocol\n *\n * 记忆Lattice的协议,用于管理智能体的上下文和记忆\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 记忆类型枚举\n */\nexport enum MemoryType {\n SHORT_TERM = \"short_term\",\n LONG_TERM = \"long_term\",\n EPISODIC = \"episodic\",\n SEMANTIC = \"semantic\",\n WORKING = \"working\",\n}\n\n/**\n * 记忆配置接口\n */\nexport interface MemoryConfig {\n name: string; // 名称\n description: string; // 描述\n type: MemoryType; // 记忆类型\n ttl?: number; // 生存时间\n capacity?: number; // 容量限制\n}\n\n/**\n * 记忆客户端接口\n */\nexport interface MemoryClient {\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n\n/**\n * 记忆Lattice协议接口\n */\nexport interface MemoryLatticeProtocol\n extends BaseLatticeProtocol<MemoryConfig, MemoryClient> {\n // 记忆操作方法\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n","/**\n * StorageLatticeProtocol\n *\n * 存储Lattice的协议,用于数据持久化和状态管理\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 存储类型枚举\n */\nexport enum StorageType {\n MEMORY = \"memory\",\n LOCAL = \"local\",\n DATABASE = \"database\",\n CLOUD = \"cloud\",\n DISTRIBUTED = \"distributed\",\n}\n\n/**\n * 存储配置接口\n */\nexport interface StorageConfig {\n name: string; // 名称\n description: string; // 描述\n type: StorageType; // 存储类型\n connectionString?: string; // 连接字符串\n options?: Record<string, any>; // 其他选项\n}\n\n/**\n * 存储客户端接口\n */\nexport interface StorageClient {\n set: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n has: (key: string) => Promise<boolean>;\n delete: (key: string) => Promise<boolean>;\n clear: () => Promise<void>;\n transaction: <T>(operations: () => Promise<T>) => Promise<T>;\n}\n\n/**\n * 存储Lattice协议接口\n */\nexport interface StorageLatticeProtocol\n extends BaseLatticeProtocol<StorageConfig, StorageClient> {\n // 存储操作方法\n set: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n has: (key: string) => Promise<boolean>;\n delete: (key: string) => Promise<boolean>;\n clear: () => Promise<void>;\n transaction: <T>(operations: () => Promise<T>) => Promise<T>;\n}\n","/**\n * UILatticeProtocol\n *\n * UI Lattice的协议,用于定义用户界面组件\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * UI组件类型枚举\n */\nexport enum UIComponentType {\n CONTAINER = \"container\",\n INPUT = \"input\",\n BUTTON = \"button\",\n LIST = \"list\",\n TABLE = \"table\",\n CHART = \"chart\",\n FORM = \"form\",\n CARD = \"card\",\n MODAL = \"modal\",\n CUSTOM = \"custom\",\n}\n\n/**\n * UI配置接口\n */\nexport interface UIConfig {\n name: string; // 组件名称\n description: string; // 组件描述\n type: UIComponentType; // 组件类型\n props?: Record<string, any>; // 组件属性\n children?: string[]; // 子组件列表\n}\n\n/**\n * UI组件接口\n * 使用泛型以适应不同的UI框架(React, Vue等)\n */\nexport interface UIComponent<T = any> {\n render: (props?: any) => T;\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n\n/**\n * UI Lattice协议接口\n */\nexport interface UILatticeProtocol<T = any>\n extends BaseLatticeProtocol<UIConfig, UIComponent<T>> {\n // UI渲染方法\n render: (props?: any) => T;\n\n // 事件处理\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n"],"mappings":";AAaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,kBAAe;AACf,EAAAA,WAAA,gBAAa;AAJH,SAAAA;AAAA,GAAA;;;ACFL,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,aAAU;AALA,SAAAA;AAAA,GAAA;;;ACAL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,YAAS;AACT,EAAAA,aAAA,WAAQ;AACR,EAAAA,aAAA,cAAW;AACX,EAAAA,aAAA,WAAQ;AACR,EAAAA,aAAA,iBAAc;AALJ,SAAAA;AAAA,GAAA;;;ACAL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,eAAY;AACZ,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AACT,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AAVC,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","StorageType","UIComponentType"]}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@axiom-lattice/protocols",
3
+ "version": "1.0.1",
4
+ "description": "Unified protocol type definitions for Axiom Lattice framework",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsup src/index.ts --format cjs,esm --dts --sourcemap",
17
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
18
+ "lint": "eslint src/**/*.ts",
19
+ "clean": "rimraf dist"
20
+ },
21
+ "keywords": [
22
+ "lattice",
23
+ "protocols",
24
+ "types",
25
+ "interfaces"
26
+ ],
27
+ "author": "",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "@langchain/core": "^0.3.72",
31
+ "@langchain/langgraph": "^0.4.6",
32
+ "zod": "^3.24.2"
33
+ },
34
+ "devDependencies": {
35
+ "@types/jest": "^29.5.12",
36
+ "@types/node": "^20.11.24",
37
+ "eslint": "^8",
38
+ "rimraf": "^5.0.5",
39
+ "tsup": "^8.0.1",
40
+ "typescript": "^5.4.2"
41
+ },
42
+ "peerDependencies": {
43
+ "@langchain/core": "^0.3.72",
44
+ "@langchain/langgraph": "^0.4.6",
45
+ "zod": "^3.24.2"
46
+ }
47
+ }