@axiom-lattice/protocols 2.1.4 → 2.1.6
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 +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +247 -50
- package/dist/index.d.ts +247 -50
- package/dist/index.js +0 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/AssistantStoreProtocol.ts +113 -0
- package/src/EmbeddingsLatticeProtocol.ts +30 -0
- package/src/QueueLatticeProtocol.ts +1 -0
- package/src/ThreadStoreProtocol.ts +113 -0
- package/src/VectorStoreLatticeProtocol.ts +73 -0
- package/src/index.ts +4 -1
- package/src/StorageLatticeProtocol.ts +0 -55
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/protocols@2.1.
|
|
2
|
+
> @axiom-lattice/protocols@2.1.6 build /home/runner/work/agentic/agentic/packages/protocols
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2020
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
12
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[32m3.
|
|
15
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m1.92 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m8.37 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 52ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m3.20 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m9.08 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 53ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 2897ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m19.40 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m19.40 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,9 @@ import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
|
4
4
|
import { BaseMessage as BaseMessage$1 } from '@langchain/core/messages';
|
|
5
5
|
import { ChatResult } from '@langchain/core/outputs';
|
|
6
6
|
import { CompiledStateGraph } from '@langchain/langgraph';
|
|
7
|
+
import { Embeddings } from '@langchain/core/embeddings';
|
|
8
|
+
import { VectorStore } from '@langchain/core/vectorstores';
|
|
9
|
+
import { DocumentInterface } from '@langchain/core/documents';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* BaseLatticeProtocol
|
|
@@ -257,55 +260,6 @@ interface MemoryLatticeProtocol extends BaseLatticeProtocol<MemoryConfig, Memory
|
|
|
257
260
|
clear: () => Promise<void>;
|
|
258
261
|
}
|
|
259
262
|
|
|
260
|
-
/**
|
|
261
|
-
* StorageLatticeProtocol
|
|
262
|
-
*
|
|
263
|
-
* 存储Lattice的协议,用于数据持久化和状态管理
|
|
264
|
-
*/
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* 存储类型枚举
|
|
268
|
-
*/
|
|
269
|
-
declare enum StorageType {
|
|
270
|
-
MEMORY = "memory",
|
|
271
|
-
LOCAL = "local",
|
|
272
|
-
DATABASE = "database",
|
|
273
|
-
CLOUD = "cloud",
|
|
274
|
-
DISTRIBUTED = "distributed"
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* 存储配置接口
|
|
278
|
-
*/
|
|
279
|
-
interface StorageConfig {
|
|
280
|
-
name: string;
|
|
281
|
-
description: string;
|
|
282
|
-
type: StorageType;
|
|
283
|
-
connectionString?: string;
|
|
284
|
-
options?: Record<string, any>;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* 存储客户端接口
|
|
288
|
-
*/
|
|
289
|
-
interface StorageClient {
|
|
290
|
-
set: (key: string, value: any) => Promise<void>;
|
|
291
|
-
get: (key: string) => Promise<any>;
|
|
292
|
-
has: (key: string) => Promise<boolean>;
|
|
293
|
-
delete: (key: string) => Promise<boolean>;
|
|
294
|
-
clear: () => Promise<void>;
|
|
295
|
-
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* 存储Lattice协议接口
|
|
299
|
-
*/
|
|
300
|
-
interface StorageLatticeProtocol extends BaseLatticeProtocol<StorageConfig, StorageClient> {
|
|
301
|
-
set: (key: string, value: any) => Promise<void>;
|
|
302
|
-
get: (key: string) => Promise<any>;
|
|
303
|
-
has: (key: string) => Promise<boolean>;
|
|
304
|
-
delete: (key: string) => Promise<boolean>;
|
|
305
|
-
clear: () => Promise<void>;
|
|
306
|
-
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
263
|
/**
|
|
310
264
|
* UILatticeProtocol
|
|
311
265
|
*
|
|
@@ -410,6 +364,62 @@ interface QueueLatticeProtocol extends BaseLatticeProtocol<QueueConfig, QueueCli
|
|
|
410
364
|
}>;
|
|
411
365
|
}
|
|
412
366
|
|
|
367
|
+
/**
|
|
368
|
+
* EmbeddingsLatticeProtocol
|
|
369
|
+
*
|
|
370
|
+
* Embeddings Lattice protocol for defining unified interface for embedding models
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Embeddings configuration interface
|
|
375
|
+
*/
|
|
376
|
+
interface EmbeddingsConfig {
|
|
377
|
+
name: string;
|
|
378
|
+
description?: string;
|
|
379
|
+
dimensions?: number;
|
|
380
|
+
maxChunkSize?: number;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Embeddings Lattice protocol interface
|
|
384
|
+
*/
|
|
385
|
+
interface EmbeddingsLatticeProtocol extends BaseLatticeProtocol<EmbeddingsConfig, Embeddings> {
|
|
386
|
+
embedDocuments: (texts: string[]) => Promise<number[][]>;
|
|
387
|
+
embedQuery: (text: string) => Promise<number[]>;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* VectorStoreLatticeProtocol
|
|
392
|
+
*
|
|
393
|
+
* VectorStore Lattice protocol for defining unified interface for vector store implementations
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* VectorStore configuration interface
|
|
398
|
+
*/
|
|
399
|
+
interface VectorStoreConfig {
|
|
400
|
+
name: string;
|
|
401
|
+
description?: string;
|
|
402
|
+
type?: string;
|
|
403
|
+
config?: Record<string, any>;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* VectorStore Lattice protocol interface
|
|
407
|
+
*/
|
|
408
|
+
interface VectorStoreLatticeProtocol extends BaseLatticeProtocol<VectorStoreConfig, VectorStore> {
|
|
409
|
+
addVectors: (vectors: number[][], documents: DocumentInterface[], options?: Record<string, any>) => Promise<string[] | void>;
|
|
410
|
+
addDocuments: (documents: DocumentInterface[], options?: Record<string, any>) => Promise<string[] | void>;
|
|
411
|
+
delete: (params?: Record<string, any>) => Promise<void>;
|
|
412
|
+
similaritySearchVectorWithScore: (query: number[], k: number, filter?: VectorStore["FilterType"]) => Promise<[DocumentInterface, number][]>;
|
|
413
|
+
similaritySearch: (query: string, k?: number, filter?: VectorStore["FilterType"]) => Promise<DocumentInterface[]>;
|
|
414
|
+
similaritySearchWithScore: (query: string, k?: number, filter?: VectorStore["FilterType"]) => Promise<[DocumentInterface, number][]>;
|
|
415
|
+
maxMarginalRelevanceSearch?: (query: string, options: {
|
|
416
|
+
k: number;
|
|
417
|
+
fetchK?: number;
|
|
418
|
+
lambda?: number;
|
|
419
|
+
filter?: VectorStore["FilterType"];
|
|
420
|
+
}) => Promise<DocumentInterface[]>;
|
|
421
|
+
}
|
|
422
|
+
|
|
413
423
|
/**
|
|
414
424
|
* MessageProtocol
|
|
415
425
|
*
|
|
@@ -513,6 +523,193 @@ interface MessageChunk {
|
|
|
513
523
|
*/
|
|
514
524
|
type Message = UserMessage | AssistantMessage | SystemMessage | ToolMessage | DeveloperMessage;
|
|
515
525
|
|
|
526
|
+
/**
|
|
527
|
+
* ThreadStoreProtocol
|
|
528
|
+
*
|
|
529
|
+
* Thread store protocol definitions for the Axiom Lattice framework
|
|
530
|
+
* Provides standardized interfaces for thread management across all implementations
|
|
531
|
+
*/
|
|
532
|
+
/**
|
|
533
|
+
* Thread type definition
|
|
534
|
+
*/
|
|
535
|
+
interface Thread {
|
|
536
|
+
/**
|
|
537
|
+
* Thread identifier
|
|
538
|
+
*/
|
|
539
|
+
id: string;
|
|
540
|
+
/**
|
|
541
|
+
* Assistant identifier this thread belongs to
|
|
542
|
+
*/
|
|
543
|
+
assistantId: string;
|
|
544
|
+
/**
|
|
545
|
+
* Thread metadata
|
|
546
|
+
*/
|
|
547
|
+
metadata?: Record<string, any>;
|
|
548
|
+
/**
|
|
549
|
+
* Thread creation timestamp
|
|
550
|
+
*/
|
|
551
|
+
createdAt: Date;
|
|
552
|
+
/**
|
|
553
|
+
* Thread last update timestamp
|
|
554
|
+
*/
|
|
555
|
+
updatedAt: Date;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Create thread request type
|
|
559
|
+
*/
|
|
560
|
+
interface CreateThreadRequest {
|
|
561
|
+
/**
|
|
562
|
+
* Thread metadata
|
|
563
|
+
*/
|
|
564
|
+
metadata?: Record<string, any>;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* ThreadStore interface
|
|
568
|
+
* Provides CRUD operations for thread data
|
|
569
|
+
* All operations are scoped to an assistant ID
|
|
570
|
+
*/
|
|
571
|
+
interface ThreadStore {
|
|
572
|
+
/**
|
|
573
|
+
* Get all threads for a specific assistant
|
|
574
|
+
* @param assistantId Assistant identifier
|
|
575
|
+
* @returns Array of threads for the assistant
|
|
576
|
+
*/
|
|
577
|
+
getThreadsByAssistantId(assistantId: string): Promise<Thread[]>;
|
|
578
|
+
/**
|
|
579
|
+
* Get a thread by ID for a specific assistant
|
|
580
|
+
* @param assistantId Assistant identifier
|
|
581
|
+
* @param threadId Thread identifier
|
|
582
|
+
* @returns Thread if found, undefined otherwise
|
|
583
|
+
*/
|
|
584
|
+
getThreadById(assistantId: string, threadId: string): Promise<Thread | undefined>;
|
|
585
|
+
/**
|
|
586
|
+
* Create a new thread for an assistant
|
|
587
|
+
* @param assistantId Assistant identifier
|
|
588
|
+
* @param threadId Thread identifier
|
|
589
|
+
* @param data Thread creation data
|
|
590
|
+
* @returns Created thread
|
|
591
|
+
*/
|
|
592
|
+
createThread(assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
|
|
593
|
+
/**
|
|
594
|
+
* Update an existing thread
|
|
595
|
+
* @param assistantId Assistant identifier
|
|
596
|
+
* @param threadId Thread identifier
|
|
597
|
+
* @param updates Partial thread data to update
|
|
598
|
+
* @returns Updated thread if found, null otherwise
|
|
599
|
+
*/
|
|
600
|
+
updateThread(assistantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
|
|
601
|
+
/**
|
|
602
|
+
* Delete a thread by ID
|
|
603
|
+
* @param assistantId Assistant identifier
|
|
604
|
+
* @param threadId Thread identifier
|
|
605
|
+
* @returns true if deleted, false otherwise
|
|
606
|
+
*/
|
|
607
|
+
deleteThread(assistantId: string, threadId: string): Promise<boolean>;
|
|
608
|
+
/**
|
|
609
|
+
* Check if thread exists
|
|
610
|
+
* @param assistantId Assistant identifier
|
|
611
|
+
* @param threadId Thread identifier
|
|
612
|
+
* @returns true if thread exists, false otherwise
|
|
613
|
+
*/
|
|
614
|
+
hasThread(assistantId: string, threadId: string): Promise<boolean>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* AssistantStoreProtocol
|
|
619
|
+
*
|
|
620
|
+
* Assistant store protocol definitions for the Axiom Lattice framework
|
|
621
|
+
* Provides standardized interfaces for assistant management across all implementations
|
|
622
|
+
*/
|
|
623
|
+
/**
|
|
624
|
+
* Assistant type definition
|
|
625
|
+
*/
|
|
626
|
+
interface Assistant {
|
|
627
|
+
/**
|
|
628
|
+
* Assistant identifier
|
|
629
|
+
*/
|
|
630
|
+
id: string;
|
|
631
|
+
/**
|
|
632
|
+
* Assistant name
|
|
633
|
+
*/
|
|
634
|
+
name: string;
|
|
635
|
+
/**
|
|
636
|
+
* Assistant description
|
|
637
|
+
*/
|
|
638
|
+
description?: string;
|
|
639
|
+
/**
|
|
640
|
+
* Graph definition for the assistant
|
|
641
|
+
*/
|
|
642
|
+
graphDefinition: any;
|
|
643
|
+
/**
|
|
644
|
+
* Assistant creation timestamp
|
|
645
|
+
*/
|
|
646
|
+
createdAt: Date;
|
|
647
|
+
/**
|
|
648
|
+
* Assistant last update timestamp
|
|
649
|
+
*/
|
|
650
|
+
updatedAt: Date;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Create assistant request type
|
|
654
|
+
*/
|
|
655
|
+
interface CreateAssistantRequest {
|
|
656
|
+
/**
|
|
657
|
+
* Assistant name
|
|
658
|
+
*/
|
|
659
|
+
name: string;
|
|
660
|
+
/**
|
|
661
|
+
* Assistant description
|
|
662
|
+
*/
|
|
663
|
+
description?: string;
|
|
664
|
+
/**
|
|
665
|
+
* Graph definition for the assistant
|
|
666
|
+
*/
|
|
667
|
+
graphDefinition: any;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* AssistantStore interface
|
|
671
|
+
* Provides CRUD operations for assistant data
|
|
672
|
+
*/
|
|
673
|
+
interface AssistantStore {
|
|
674
|
+
/**
|
|
675
|
+
* Get all assistants
|
|
676
|
+
* @returns Array of all assistants
|
|
677
|
+
*/
|
|
678
|
+
getAllAssistants(): Promise<Assistant[]>;
|
|
679
|
+
/**
|
|
680
|
+
* Get assistant by ID
|
|
681
|
+
* @param id Assistant identifier
|
|
682
|
+
* @returns Assistant if found, undefined otherwise
|
|
683
|
+
*/
|
|
684
|
+
getAssistantById(id: string): Promise<Assistant | null>;
|
|
685
|
+
/**
|
|
686
|
+
* Create a new assistant
|
|
687
|
+
* @param id Assistant identifier
|
|
688
|
+
* @param data Assistant creation data
|
|
689
|
+
* @returns Created assistant
|
|
690
|
+
*/
|
|
691
|
+
createAssistant(id: string, data: CreateAssistantRequest): Promise<Assistant>;
|
|
692
|
+
/**
|
|
693
|
+
* Update an existing assistant
|
|
694
|
+
* @param id Assistant identifier
|
|
695
|
+
* @param updates Partial assistant data to update
|
|
696
|
+
* @returns Updated assistant if found, null otherwise
|
|
697
|
+
*/
|
|
698
|
+
updateAssistant(id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
|
|
699
|
+
/**
|
|
700
|
+
* Delete an assistant by ID
|
|
701
|
+
* @param id Assistant identifier
|
|
702
|
+
* @returns true if deleted, false otherwise
|
|
703
|
+
*/
|
|
704
|
+
deleteAssistant(id: string): Promise<boolean>;
|
|
705
|
+
/**
|
|
706
|
+
* Check if assistant exists
|
|
707
|
+
* @param id Assistant identifier
|
|
708
|
+
* @returns true if assistant exists, false otherwise
|
|
709
|
+
*/
|
|
710
|
+
hasAssistant(id: string): Promise<boolean>;
|
|
711
|
+
}
|
|
712
|
+
|
|
516
713
|
/**
|
|
517
714
|
* 通用类型定义
|
|
518
715
|
*
|
|
@@ -576,4 +773,4 @@ type Timestamp = number;
|
|
|
576
773
|
*/
|
|
577
774
|
type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
|
|
578
775
|
|
|
579
|
-
export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, AgentType, type AssistantMessage, type BaseLatticeProtocol, type BaseMessage, type Callback, type DeepAgentConfig, type DeveloperMessage, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, 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 PlanExecuteAgentConfig, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type SequentialAgentConfig, type
|
|
776
|
+
export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type BaseLatticeProtocol, type BaseMessage, type Callback, type CreateAssistantRequest, type CreateThreadRequest, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, 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 PlanExecuteAgentConfig, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type SequentialAgentConfig, type SystemMessage, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UserMessage, type VectorStoreConfig, type VectorStoreLatticeProtocol, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
|
4
4
|
import { BaseMessage as BaseMessage$1 } from '@langchain/core/messages';
|
|
5
5
|
import { ChatResult } from '@langchain/core/outputs';
|
|
6
6
|
import { CompiledStateGraph } from '@langchain/langgraph';
|
|
7
|
+
import { Embeddings } from '@langchain/core/embeddings';
|
|
8
|
+
import { VectorStore } from '@langchain/core/vectorstores';
|
|
9
|
+
import { DocumentInterface } from '@langchain/core/documents';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* BaseLatticeProtocol
|
|
@@ -257,55 +260,6 @@ interface MemoryLatticeProtocol extends BaseLatticeProtocol<MemoryConfig, Memory
|
|
|
257
260
|
clear: () => Promise<void>;
|
|
258
261
|
}
|
|
259
262
|
|
|
260
|
-
/**
|
|
261
|
-
* StorageLatticeProtocol
|
|
262
|
-
*
|
|
263
|
-
* 存储Lattice的协议,用于数据持久化和状态管理
|
|
264
|
-
*/
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* 存储类型枚举
|
|
268
|
-
*/
|
|
269
|
-
declare enum StorageType {
|
|
270
|
-
MEMORY = "memory",
|
|
271
|
-
LOCAL = "local",
|
|
272
|
-
DATABASE = "database",
|
|
273
|
-
CLOUD = "cloud",
|
|
274
|
-
DISTRIBUTED = "distributed"
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* 存储配置接口
|
|
278
|
-
*/
|
|
279
|
-
interface StorageConfig {
|
|
280
|
-
name: string;
|
|
281
|
-
description: string;
|
|
282
|
-
type: StorageType;
|
|
283
|
-
connectionString?: string;
|
|
284
|
-
options?: Record<string, any>;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* 存储客户端接口
|
|
288
|
-
*/
|
|
289
|
-
interface StorageClient {
|
|
290
|
-
set: (key: string, value: any) => Promise<void>;
|
|
291
|
-
get: (key: string) => Promise<any>;
|
|
292
|
-
has: (key: string) => Promise<boolean>;
|
|
293
|
-
delete: (key: string) => Promise<boolean>;
|
|
294
|
-
clear: () => Promise<void>;
|
|
295
|
-
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* 存储Lattice协议接口
|
|
299
|
-
*/
|
|
300
|
-
interface StorageLatticeProtocol extends BaseLatticeProtocol<StorageConfig, StorageClient> {
|
|
301
|
-
set: (key: string, value: any) => Promise<void>;
|
|
302
|
-
get: (key: string) => Promise<any>;
|
|
303
|
-
has: (key: string) => Promise<boolean>;
|
|
304
|
-
delete: (key: string) => Promise<boolean>;
|
|
305
|
-
clear: () => Promise<void>;
|
|
306
|
-
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
263
|
/**
|
|
310
264
|
* UILatticeProtocol
|
|
311
265
|
*
|
|
@@ -410,6 +364,62 @@ interface QueueLatticeProtocol extends BaseLatticeProtocol<QueueConfig, QueueCli
|
|
|
410
364
|
}>;
|
|
411
365
|
}
|
|
412
366
|
|
|
367
|
+
/**
|
|
368
|
+
* EmbeddingsLatticeProtocol
|
|
369
|
+
*
|
|
370
|
+
* Embeddings Lattice protocol for defining unified interface for embedding models
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Embeddings configuration interface
|
|
375
|
+
*/
|
|
376
|
+
interface EmbeddingsConfig {
|
|
377
|
+
name: string;
|
|
378
|
+
description?: string;
|
|
379
|
+
dimensions?: number;
|
|
380
|
+
maxChunkSize?: number;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Embeddings Lattice protocol interface
|
|
384
|
+
*/
|
|
385
|
+
interface EmbeddingsLatticeProtocol extends BaseLatticeProtocol<EmbeddingsConfig, Embeddings> {
|
|
386
|
+
embedDocuments: (texts: string[]) => Promise<number[][]>;
|
|
387
|
+
embedQuery: (text: string) => Promise<number[]>;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* VectorStoreLatticeProtocol
|
|
392
|
+
*
|
|
393
|
+
* VectorStore Lattice protocol for defining unified interface for vector store implementations
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* VectorStore configuration interface
|
|
398
|
+
*/
|
|
399
|
+
interface VectorStoreConfig {
|
|
400
|
+
name: string;
|
|
401
|
+
description?: string;
|
|
402
|
+
type?: string;
|
|
403
|
+
config?: Record<string, any>;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* VectorStore Lattice protocol interface
|
|
407
|
+
*/
|
|
408
|
+
interface VectorStoreLatticeProtocol extends BaseLatticeProtocol<VectorStoreConfig, VectorStore> {
|
|
409
|
+
addVectors: (vectors: number[][], documents: DocumentInterface[], options?: Record<string, any>) => Promise<string[] | void>;
|
|
410
|
+
addDocuments: (documents: DocumentInterface[], options?: Record<string, any>) => Promise<string[] | void>;
|
|
411
|
+
delete: (params?: Record<string, any>) => Promise<void>;
|
|
412
|
+
similaritySearchVectorWithScore: (query: number[], k: number, filter?: VectorStore["FilterType"]) => Promise<[DocumentInterface, number][]>;
|
|
413
|
+
similaritySearch: (query: string, k?: number, filter?: VectorStore["FilterType"]) => Promise<DocumentInterface[]>;
|
|
414
|
+
similaritySearchWithScore: (query: string, k?: number, filter?: VectorStore["FilterType"]) => Promise<[DocumentInterface, number][]>;
|
|
415
|
+
maxMarginalRelevanceSearch?: (query: string, options: {
|
|
416
|
+
k: number;
|
|
417
|
+
fetchK?: number;
|
|
418
|
+
lambda?: number;
|
|
419
|
+
filter?: VectorStore["FilterType"];
|
|
420
|
+
}) => Promise<DocumentInterface[]>;
|
|
421
|
+
}
|
|
422
|
+
|
|
413
423
|
/**
|
|
414
424
|
* MessageProtocol
|
|
415
425
|
*
|
|
@@ -513,6 +523,193 @@ interface MessageChunk {
|
|
|
513
523
|
*/
|
|
514
524
|
type Message = UserMessage | AssistantMessage | SystemMessage | ToolMessage | DeveloperMessage;
|
|
515
525
|
|
|
526
|
+
/**
|
|
527
|
+
* ThreadStoreProtocol
|
|
528
|
+
*
|
|
529
|
+
* Thread store protocol definitions for the Axiom Lattice framework
|
|
530
|
+
* Provides standardized interfaces for thread management across all implementations
|
|
531
|
+
*/
|
|
532
|
+
/**
|
|
533
|
+
* Thread type definition
|
|
534
|
+
*/
|
|
535
|
+
interface Thread {
|
|
536
|
+
/**
|
|
537
|
+
* Thread identifier
|
|
538
|
+
*/
|
|
539
|
+
id: string;
|
|
540
|
+
/**
|
|
541
|
+
* Assistant identifier this thread belongs to
|
|
542
|
+
*/
|
|
543
|
+
assistantId: string;
|
|
544
|
+
/**
|
|
545
|
+
* Thread metadata
|
|
546
|
+
*/
|
|
547
|
+
metadata?: Record<string, any>;
|
|
548
|
+
/**
|
|
549
|
+
* Thread creation timestamp
|
|
550
|
+
*/
|
|
551
|
+
createdAt: Date;
|
|
552
|
+
/**
|
|
553
|
+
* Thread last update timestamp
|
|
554
|
+
*/
|
|
555
|
+
updatedAt: Date;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Create thread request type
|
|
559
|
+
*/
|
|
560
|
+
interface CreateThreadRequest {
|
|
561
|
+
/**
|
|
562
|
+
* Thread metadata
|
|
563
|
+
*/
|
|
564
|
+
metadata?: Record<string, any>;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* ThreadStore interface
|
|
568
|
+
* Provides CRUD operations for thread data
|
|
569
|
+
* All operations are scoped to an assistant ID
|
|
570
|
+
*/
|
|
571
|
+
interface ThreadStore {
|
|
572
|
+
/**
|
|
573
|
+
* Get all threads for a specific assistant
|
|
574
|
+
* @param assistantId Assistant identifier
|
|
575
|
+
* @returns Array of threads for the assistant
|
|
576
|
+
*/
|
|
577
|
+
getThreadsByAssistantId(assistantId: string): Promise<Thread[]>;
|
|
578
|
+
/**
|
|
579
|
+
* Get a thread by ID for a specific assistant
|
|
580
|
+
* @param assistantId Assistant identifier
|
|
581
|
+
* @param threadId Thread identifier
|
|
582
|
+
* @returns Thread if found, undefined otherwise
|
|
583
|
+
*/
|
|
584
|
+
getThreadById(assistantId: string, threadId: string): Promise<Thread | undefined>;
|
|
585
|
+
/**
|
|
586
|
+
* Create a new thread for an assistant
|
|
587
|
+
* @param assistantId Assistant identifier
|
|
588
|
+
* @param threadId Thread identifier
|
|
589
|
+
* @param data Thread creation data
|
|
590
|
+
* @returns Created thread
|
|
591
|
+
*/
|
|
592
|
+
createThread(assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
|
|
593
|
+
/**
|
|
594
|
+
* Update an existing thread
|
|
595
|
+
* @param assistantId Assistant identifier
|
|
596
|
+
* @param threadId Thread identifier
|
|
597
|
+
* @param updates Partial thread data to update
|
|
598
|
+
* @returns Updated thread if found, null otherwise
|
|
599
|
+
*/
|
|
600
|
+
updateThread(assistantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
|
|
601
|
+
/**
|
|
602
|
+
* Delete a thread by ID
|
|
603
|
+
* @param assistantId Assistant identifier
|
|
604
|
+
* @param threadId Thread identifier
|
|
605
|
+
* @returns true if deleted, false otherwise
|
|
606
|
+
*/
|
|
607
|
+
deleteThread(assistantId: string, threadId: string): Promise<boolean>;
|
|
608
|
+
/**
|
|
609
|
+
* Check if thread exists
|
|
610
|
+
* @param assistantId Assistant identifier
|
|
611
|
+
* @param threadId Thread identifier
|
|
612
|
+
* @returns true if thread exists, false otherwise
|
|
613
|
+
*/
|
|
614
|
+
hasThread(assistantId: string, threadId: string): Promise<boolean>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* AssistantStoreProtocol
|
|
619
|
+
*
|
|
620
|
+
* Assistant store protocol definitions for the Axiom Lattice framework
|
|
621
|
+
* Provides standardized interfaces for assistant management across all implementations
|
|
622
|
+
*/
|
|
623
|
+
/**
|
|
624
|
+
* Assistant type definition
|
|
625
|
+
*/
|
|
626
|
+
interface Assistant {
|
|
627
|
+
/**
|
|
628
|
+
* Assistant identifier
|
|
629
|
+
*/
|
|
630
|
+
id: string;
|
|
631
|
+
/**
|
|
632
|
+
* Assistant name
|
|
633
|
+
*/
|
|
634
|
+
name: string;
|
|
635
|
+
/**
|
|
636
|
+
* Assistant description
|
|
637
|
+
*/
|
|
638
|
+
description?: string;
|
|
639
|
+
/**
|
|
640
|
+
* Graph definition for the assistant
|
|
641
|
+
*/
|
|
642
|
+
graphDefinition: any;
|
|
643
|
+
/**
|
|
644
|
+
* Assistant creation timestamp
|
|
645
|
+
*/
|
|
646
|
+
createdAt: Date;
|
|
647
|
+
/**
|
|
648
|
+
* Assistant last update timestamp
|
|
649
|
+
*/
|
|
650
|
+
updatedAt: Date;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Create assistant request type
|
|
654
|
+
*/
|
|
655
|
+
interface CreateAssistantRequest {
|
|
656
|
+
/**
|
|
657
|
+
* Assistant name
|
|
658
|
+
*/
|
|
659
|
+
name: string;
|
|
660
|
+
/**
|
|
661
|
+
* Assistant description
|
|
662
|
+
*/
|
|
663
|
+
description?: string;
|
|
664
|
+
/**
|
|
665
|
+
* Graph definition for the assistant
|
|
666
|
+
*/
|
|
667
|
+
graphDefinition: any;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* AssistantStore interface
|
|
671
|
+
* Provides CRUD operations for assistant data
|
|
672
|
+
*/
|
|
673
|
+
interface AssistantStore {
|
|
674
|
+
/**
|
|
675
|
+
* Get all assistants
|
|
676
|
+
* @returns Array of all assistants
|
|
677
|
+
*/
|
|
678
|
+
getAllAssistants(): Promise<Assistant[]>;
|
|
679
|
+
/**
|
|
680
|
+
* Get assistant by ID
|
|
681
|
+
* @param id Assistant identifier
|
|
682
|
+
* @returns Assistant if found, undefined otherwise
|
|
683
|
+
*/
|
|
684
|
+
getAssistantById(id: string): Promise<Assistant | null>;
|
|
685
|
+
/**
|
|
686
|
+
* Create a new assistant
|
|
687
|
+
* @param id Assistant identifier
|
|
688
|
+
* @param data Assistant creation data
|
|
689
|
+
* @returns Created assistant
|
|
690
|
+
*/
|
|
691
|
+
createAssistant(id: string, data: CreateAssistantRequest): Promise<Assistant>;
|
|
692
|
+
/**
|
|
693
|
+
* Update an existing assistant
|
|
694
|
+
* @param id Assistant identifier
|
|
695
|
+
* @param updates Partial assistant data to update
|
|
696
|
+
* @returns Updated assistant if found, null otherwise
|
|
697
|
+
*/
|
|
698
|
+
updateAssistant(id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
|
|
699
|
+
/**
|
|
700
|
+
* Delete an assistant by ID
|
|
701
|
+
* @param id Assistant identifier
|
|
702
|
+
* @returns true if deleted, false otherwise
|
|
703
|
+
*/
|
|
704
|
+
deleteAssistant(id: string): Promise<boolean>;
|
|
705
|
+
/**
|
|
706
|
+
* Check if assistant exists
|
|
707
|
+
* @param id Assistant identifier
|
|
708
|
+
* @returns true if assistant exists, false otherwise
|
|
709
|
+
*/
|
|
710
|
+
hasAssistant(id: string): Promise<boolean>;
|
|
711
|
+
}
|
|
712
|
+
|
|
516
713
|
/**
|
|
517
714
|
* 通用类型定义
|
|
518
715
|
*
|
|
@@ -576,4 +773,4 @@ type Timestamp = number;
|
|
|
576
773
|
*/
|
|
577
774
|
type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
|
|
578
775
|
|
|
579
|
-
export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, AgentType, type AssistantMessage, type BaseLatticeProtocol, type BaseMessage, type Callback, type DeepAgentConfig, type DeveloperMessage, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, 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 PlanExecuteAgentConfig, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type SequentialAgentConfig, type
|
|
776
|
+
export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type BaseLatticeProtocol, type BaseMessage, type Callback, type CreateAssistantRequest, type CreateThreadRequest, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, 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 PlanExecuteAgentConfig, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type SequentialAgentConfig, type SystemMessage, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UserMessage, type VectorStoreConfig, type VectorStoreLatticeProtocol, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig };
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,6 @@ __export(index_exports, {
|
|
|
23
23
|
AgentType: () => AgentType,
|
|
24
24
|
MemoryType: () => MemoryType,
|
|
25
25
|
QueueType: () => QueueType,
|
|
26
|
-
StorageType: () => StorageType,
|
|
27
26
|
UIComponentType: () => UIComponentType,
|
|
28
27
|
getSubAgentsFromConfig: () => getSubAgentsFromConfig,
|
|
29
28
|
getToolsFromConfig: () => getToolsFromConfig,
|
|
@@ -69,16 +68,6 @@ var MemoryType = /* @__PURE__ */ ((MemoryType2) => {
|
|
|
69
68
|
return MemoryType2;
|
|
70
69
|
})(MemoryType || {});
|
|
71
70
|
|
|
72
|
-
// src/StorageLatticeProtocol.ts
|
|
73
|
-
var StorageType = /* @__PURE__ */ ((StorageType2) => {
|
|
74
|
-
StorageType2["MEMORY"] = "memory";
|
|
75
|
-
StorageType2["LOCAL"] = "local";
|
|
76
|
-
StorageType2["DATABASE"] = "database";
|
|
77
|
-
StorageType2["CLOUD"] = "cloud";
|
|
78
|
-
StorageType2["DISTRIBUTED"] = "distributed";
|
|
79
|
-
return StorageType2;
|
|
80
|
-
})(StorageType || {});
|
|
81
|
-
|
|
82
71
|
// src/UILatticeProtocol.ts
|
|
83
72
|
var UIComponentType = /* @__PURE__ */ ((UIComponentType2) => {
|
|
84
73
|
UIComponentType2["CONTAINER"] = "container";
|
|
@@ -105,7 +94,6 @@ var QueueType = /* @__PURE__ */ ((QueueType2) => {
|
|
|
105
94
|
AgentType,
|
|
106
95
|
MemoryType,
|
|
107
96
|
QueueType,
|
|
108
|
-
StorageType,
|
|
109
97
|
UIComponentType,
|
|
110
98
|
getSubAgentsFromConfig,
|
|
111
99
|
getToolsFromConfig,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/StorageLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.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 \"./QueueLatticeProtocol\";\nexport * from \"./MessageProtocol\";\n\n// 导出通用类型\nexport * from \"./types\";\n","/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport z, { ZodObject, 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 * Base agent configuration shared by all agent types\n */\ninterface BaseAgentConfig {\n key: string; // Unique key\n name: string; // Name\n description: string; // Description\n prompt: string; // Prompt\n schema?: ZodObject<any, any, any, any, any>; // Input validation schema\n modelKey?: string; // Model key to use\n}\n\n/**\n * REACT agent configuration\n */\nexport interface ReactAgentConfig extends BaseAgentConfig {\n type: AgentType.REACT;\n tools?: string[]; // Tool list\n}\n\n/**\n * DEEP_AGENT configuration - only this type supports subAgents\n */\nexport interface DeepAgentConfig extends BaseAgentConfig {\n type: AgentType.DEEP_AGENT;\n tools?: string[]; // Tool list\n subAgents?: string[]; // Sub-agent list (unique to DEEP_AGENT)\n internalSubAgents?: AgentConfig[]; // Internal sub-agent list (unique to DEEP_AGENT)\n}\n\n/**\n * PLAN_EXECUTE agent configuration\n */\nexport interface PlanExecuteAgentConfig extends BaseAgentConfig {\n type: AgentType.PLAN_EXECUTE;\n tools?: string[]; // Tool list\n}\n\n/**\n * SEQUENTIAL agent configuration\n */\nexport interface SequentialAgentConfig extends BaseAgentConfig {\n type: AgentType.SEQUENTIAL;\n}\n\n/**\n * Agent configuration union type\n * Different agent types have different configuration options\n */\nexport type AgentConfig =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig\n | SequentialAgentConfig;\n\n/**\n * Agent configuration with tools property\n */\nexport type AgentConfigWithTools =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig;\n\n/**\n * Type guard to check if config has tools property\n */\nexport function hasTools(config: AgentConfig): config is AgentConfigWithTools {\n return config.type !== AgentType.SEQUENTIAL;\n}\n\n/**\n * Type guard to check if config is DeepAgentConfig (has subAgents)\n */\nexport function isDeepAgentConfig(\n config: AgentConfig\n): config is DeepAgentConfig {\n return config.type === AgentType.DEEP_AGENT;\n}\n\n/**\n * Get tools from config safely\n */\nexport function getToolsFromConfig(config: AgentConfig): string[] {\n if (hasTools(config)) {\n return config.tools || [];\n }\n return [];\n}\n\n/**\n * Get subAgents from config safely (only DeepAgentConfig has subAgents)\n */\nexport function getSubAgentsFromConfig(config: AgentConfig): string[] {\n if (isDeepAgentConfig(config)) {\n return config.subAgents || [];\n }\n return [];\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","/**\n * QueueLatticeProtocol\n *\n * Queue Lattice protocol for task queue management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Queue service type enumeration\n */\nexport enum QueueType {\n MEMORY = \"memory\",\n REDIS = \"redis\",\n}\n\n/**\n * Queue configuration interface\n */\nexport interface QueueConfig {\n name: string; // Queue name\n description: string; // Queue description\n type: QueueType; // Queue service type\n queueName?: string; // Specific queue name (e.g., \"tasks\")\n options?: Record<string, any>; // Additional options (e.g., Redis connection options)\n}\n\n/**\n * Queue operation result interface\n */\nexport interface QueueResult<T = any> {\n data: T | null;\n error: any | null;\n}\n\n/**\n * Queue client interface\n */\nexport interface QueueClient {\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n/**\n * Queue Lattice protocol interface\n */\nexport interface QueueLatticeProtocol\n extends BaseLatticeProtocol<QueueConfig, QueueClient> {\n // Queue operations\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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;AAyEL,SAAS,SAAS,QAAqD;AAC5E,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,kBACd,QAC2B;AAC3B,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,mBAAmB,QAA+B;AAChE,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO,OAAO,SAAS,CAAC;AAAA,EAC1B;AACA,SAAO,CAAC;AACV;AAKO,SAAS,uBAAuB,QAA+B;AACpE,MAAI,kBAAkB,MAAM,GAAG;AAC7B,WAAO,OAAO,aAAa,CAAC;AAAA,EAC9B;AACA,SAAO,CAAC;AACV;;;AC1GO,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;;;ACAL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","StorageType","UIComponentType","QueueType"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.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 \"./UILatticeProtocol\";\nexport * from \"./QueueLatticeProtocol\";\nexport * from \"./EmbeddingsLatticeProtocol\";\nexport * from \"./VectorStoreLatticeProtocol\";\nexport * from \"./MessageProtocol\";\nexport * from \"./ThreadStoreProtocol\";\nexport * from \"./AssistantStoreProtocol\";\n\n// 导出通用类型\nexport * from \"./types\";\n","/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport z, { ZodObject, 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 * Base agent configuration shared by all agent types\n */\ninterface BaseAgentConfig {\n key: string; // Unique key\n name: string; // Name\n description: string; // Description\n prompt: string; // Prompt\n schema?: ZodObject<any, any, any, any, any>; // Input validation schema\n modelKey?: string; // Model key to use\n}\n\n/**\n * REACT agent configuration\n */\nexport interface ReactAgentConfig extends BaseAgentConfig {\n type: AgentType.REACT;\n tools?: string[]; // Tool list\n}\n\n/**\n * DEEP_AGENT configuration - only this type supports subAgents\n */\nexport interface DeepAgentConfig extends BaseAgentConfig {\n type: AgentType.DEEP_AGENT;\n tools?: string[]; // Tool list\n subAgents?: string[]; // Sub-agent list (unique to DEEP_AGENT)\n internalSubAgents?: AgentConfig[]; // Internal sub-agent list (unique to DEEP_AGENT)\n}\n\n/**\n * PLAN_EXECUTE agent configuration\n */\nexport interface PlanExecuteAgentConfig extends BaseAgentConfig {\n type: AgentType.PLAN_EXECUTE;\n tools?: string[]; // Tool list\n}\n\n/**\n * SEQUENTIAL agent configuration\n */\nexport interface SequentialAgentConfig extends BaseAgentConfig {\n type: AgentType.SEQUENTIAL;\n}\n\n/**\n * Agent configuration union type\n * Different agent types have different configuration options\n */\nexport type AgentConfig =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig\n | SequentialAgentConfig;\n\n/**\n * Agent configuration with tools property\n */\nexport type AgentConfigWithTools =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig;\n\n/**\n * Type guard to check if config has tools property\n */\nexport function hasTools(config: AgentConfig): config is AgentConfigWithTools {\n return config.type !== AgentType.SEQUENTIAL;\n}\n\n/**\n * Type guard to check if config is DeepAgentConfig (has subAgents)\n */\nexport function isDeepAgentConfig(\n config: AgentConfig\n): config is DeepAgentConfig {\n return config.type === AgentType.DEEP_AGENT;\n}\n\n/**\n * Get tools from config safely\n */\nexport function getToolsFromConfig(config: AgentConfig): string[] {\n if (hasTools(config)) {\n return config.tools || [];\n }\n return [];\n}\n\n/**\n * Get subAgents from config safely (only DeepAgentConfig has subAgents)\n */\nexport function getSubAgentsFromConfig(config: AgentConfig): string[] {\n if (isDeepAgentConfig(config)) {\n return config.subAgents || [];\n }\n return [];\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 * 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","/**\n * QueueLatticeProtocol\n *\n * Queue Lattice protocol for task queue management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Queue service type enumeration\n */\nexport enum QueueType {\n MEMORY = \"memory\",\n REDIS = \"redis\",\n}\n\n/**\n * Queue configuration interface\n */\nexport interface QueueConfig {\n name: string; // Queue name\n description: string; // Queue description\n type: QueueType; // Queue service type\n queueName?: string; // Specific queue name (e.g., \"tasks\")\n options?: Record<string, any>; // Additional options (e.g., Redis connection options)\n}\n\n/**\n * Queue operation result interface\n */\nexport interface QueueResult<T = any> {\n data: T | null;\n error: any | null;\n}\n\n/**\n * Queue client interface\n */\nexport interface QueueClient {\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n/**\n * Queue Lattice protocol interface\n */\nexport interface QueueLatticeProtocol\n extends BaseLatticeProtocol<QueueConfig, QueueClient> {\n // Queue operations\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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;AAyEL,SAAS,SAAS,QAAqD;AAC5E,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,kBACd,QAC2B;AAC3B,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,mBAAmB,QAA+B;AAChE,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO,OAAO,SAAS,CAAC;AAAA,EAC1B;AACA,SAAO,CAAC;AACV;AAKO,SAAS,uBAAuB,QAA+B;AACpE,MAAI,kBAAkB,MAAM,GAAG;AAC7B,WAAO,OAAO,aAAa,CAAC;AAAA,EAC9B;AACA,SAAO,CAAC;AACV;;;AC1GO,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,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;;;ACAL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","UIComponentType","QueueType"]}
|
package/dist/index.mjs
CHANGED
|
@@ -35,16 +35,6 @@ var MemoryType = /* @__PURE__ */ ((MemoryType2) => {
|
|
|
35
35
|
return MemoryType2;
|
|
36
36
|
})(MemoryType || {});
|
|
37
37
|
|
|
38
|
-
// src/StorageLatticeProtocol.ts
|
|
39
|
-
var StorageType = /* @__PURE__ */ ((StorageType2) => {
|
|
40
|
-
StorageType2["MEMORY"] = "memory";
|
|
41
|
-
StorageType2["LOCAL"] = "local";
|
|
42
|
-
StorageType2["DATABASE"] = "database";
|
|
43
|
-
StorageType2["CLOUD"] = "cloud";
|
|
44
|
-
StorageType2["DISTRIBUTED"] = "distributed";
|
|
45
|
-
return StorageType2;
|
|
46
|
-
})(StorageType || {});
|
|
47
|
-
|
|
48
38
|
// src/UILatticeProtocol.ts
|
|
49
39
|
var UIComponentType = /* @__PURE__ */ ((UIComponentType2) => {
|
|
50
40
|
UIComponentType2["CONTAINER"] = "container";
|
|
@@ -70,7 +60,6 @@ export {
|
|
|
70
60
|
AgentType,
|
|
71
61
|
MemoryType,
|
|
72
62
|
QueueType,
|
|
73
|
-
StorageType,
|
|
74
63
|
UIComponentType,
|
|
75
64
|
getSubAgentsFromConfig,
|
|
76
65
|
getToolsFromConfig,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/StorageLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.ts"],"sourcesContent":["/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport z, { ZodObject, 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 * Base agent configuration shared by all agent types\n */\ninterface BaseAgentConfig {\n key: string; // Unique key\n name: string; // Name\n description: string; // Description\n prompt: string; // Prompt\n schema?: ZodObject<any, any, any, any, any>; // Input validation schema\n modelKey?: string; // Model key to use\n}\n\n/**\n * REACT agent configuration\n */\nexport interface ReactAgentConfig extends BaseAgentConfig {\n type: AgentType.REACT;\n tools?: string[]; // Tool list\n}\n\n/**\n * DEEP_AGENT configuration - only this type supports subAgents\n */\nexport interface DeepAgentConfig extends BaseAgentConfig {\n type: AgentType.DEEP_AGENT;\n tools?: string[]; // Tool list\n subAgents?: string[]; // Sub-agent list (unique to DEEP_AGENT)\n internalSubAgents?: AgentConfig[]; // Internal sub-agent list (unique to DEEP_AGENT)\n}\n\n/**\n * PLAN_EXECUTE agent configuration\n */\nexport interface PlanExecuteAgentConfig extends BaseAgentConfig {\n type: AgentType.PLAN_EXECUTE;\n tools?: string[]; // Tool list\n}\n\n/**\n * SEQUENTIAL agent configuration\n */\nexport interface SequentialAgentConfig extends BaseAgentConfig {\n type: AgentType.SEQUENTIAL;\n}\n\n/**\n * Agent configuration union type\n * Different agent types have different configuration options\n */\nexport type AgentConfig =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig\n | SequentialAgentConfig;\n\n/**\n * Agent configuration with tools property\n */\nexport type AgentConfigWithTools =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig;\n\n/**\n * Type guard to check if config has tools property\n */\nexport function hasTools(config: AgentConfig): config is AgentConfigWithTools {\n return config.type !== AgentType.SEQUENTIAL;\n}\n\n/**\n * Type guard to check if config is DeepAgentConfig (has subAgents)\n */\nexport function isDeepAgentConfig(\n config: AgentConfig\n): config is DeepAgentConfig {\n return config.type === AgentType.DEEP_AGENT;\n}\n\n/**\n * Get tools from config safely\n */\nexport function getToolsFromConfig(config: AgentConfig): string[] {\n if (hasTools(config)) {\n return config.tools || [];\n }\n return [];\n}\n\n/**\n * Get subAgents from config safely (only DeepAgentConfig has subAgents)\n */\nexport function getSubAgentsFromConfig(config: AgentConfig): string[] {\n if (isDeepAgentConfig(config)) {\n return config.subAgents || [];\n }\n return [];\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","/**\n * QueueLatticeProtocol\n *\n * Queue Lattice protocol for task queue management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Queue service type enumeration\n */\nexport enum QueueType {\n MEMORY = \"memory\",\n REDIS = \"redis\",\n}\n\n/**\n * Queue configuration interface\n */\nexport interface QueueConfig {\n name: string; // Queue name\n description: string; // Queue description\n type: QueueType; // Queue service type\n queueName?: string; // Specific queue name (e.g., \"tasks\")\n options?: Record<string, any>; // Additional options (e.g., Redis connection options)\n}\n\n/**\n * Queue operation result interface\n */\nexport interface QueueResult<T = any> {\n data: T | null;\n error: any | null;\n}\n\n/**\n * Queue client interface\n */\nexport interface QueueClient {\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n/**\n * Queue Lattice protocol interface\n */\nexport interface QueueLatticeProtocol\n extends BaseLatticeProtocol<QueueConfig, QueueClient> {\n // Queue operations\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\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;AAyEL,SAAS,SAAS,QAAqD;AAC5E,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,kBACd,QAC2B;AAC3B,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,mBAAmB,QAA+B;AAChE,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO,OAAO,SAAS,CAAC;AAAA,EAC1B;AACA,SAAO,CAAC;AACV;AAKO,SAAS,uBAAuB,QAA+B;AACpE,MAAI,kBAAkB,MAAM,GAAG;AAC7B,WAAO,OAAO,aAAa,CAAC;AAAA,EAC9B;AACA,SAAO,CAAC;AACV;;;AC1GO,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;;;ACAL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","StorageType","UIComponentType","QueueType"]}
|
|
1
|
+
{"version":3,"sources":["../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.ts"],"sourcesContent":["/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport z, { ZodObject, 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 * Base agent configuration shared by all agent types\n */\ninterface BaseAgentConfig {\n key: string; // Unique key\n name: string; // Name\n description: string; // Description\n prompt: string; // Prompt\n schema?: ZodObject<any, any, any, any, any>; // Input validation schema\n modelKey?: string; // Model key to use\n}\n\n/**\n * REACT agent configuration\n */\nexport interface ReactAgentConfig extends BaseAgentConfig {\n type: AgentType.REACT;\n tools?: string[]; // Tool list\n}\n\n/**\n * DEEP_AGENT configuration - only this type supports subAgents\n */\nexport interface DeepAgentConfig extends BaseAgentConfig {\n type: AgentType.DEEP_AGENT;\n tools?: string[]; // Tool list\n subAgents?: string[]; // Sub-agent list (unique to DEEP_AGENT)\n internalSubAgents?: AgentConfig[]; // Internal sub-agent list (unique to DEEP_AGENT)\n}\n\n/**\n * PLAN_EXECUTE agent configuration\n */\nexport interface PlanExecuteAgentConfig extends BaseAgentConfig {\n type: AgentType.PLAN_EXECUTE;\n tools?: string[]; // Tool list\n}\n\n/**\n * SEQUENTIAL agent configuration\n */\nexport interface SequentialAgentConfig extends BaseAgentConfig {\n type: AgentType.SEQUENTIAL;\n}\n\n/**\n * Agent configuration union type\n * Different agent types have different configuration options\n */\nexport type AgentConfig =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig\n | SequentialAgentConfig;\n\n/**\n * Agent configuration with tools property\n */\nexport type AgentConfigWithTools =\n | ReactAgentConfig\n | DeepAgentConfig\n | PlanExecuteAgentConfig;\n\n/**\n * Type guard to check if config has tools property\n */\nexport function hasTools(config: AgentConfig): config is AgentConfigWithTools {\n return config.type !== AgentType.SEQUENTIAL;\n}\n\n/**\n * Type guard to check if config is DeepAgentConfig (has subAgents)\n */\nexport function isDeepAgentConfig(\n config: AgentConfig\n): config is DeepAgentConfig {\n return config.type === AgentType.DEEP_AGENT;\n}\n\n/**\n * Get tools from config safely\n */\nexport function getToolsFromConfig(config: AgentConfig): string[] {\n if (hasTools(config)) {\n return config.tools || [];\n }\n return [];\n}\n\n/**\n * Get subAgents from config safely (only DeepAgentConfig has subAgents)\n */\nexport function getSubAgentsFromConfig(config: AgentConfig): string[] {\n if (isDeepAgentConfig(config)) {\n return config.subAgents || [];\n }\n return [];\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 * 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","/**\n * QueueLatticeProtocol\n *\n * Queue Lattice protocol for task queue management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Queue service type enumeration\n */\nexport enum QueueType {\n MEMORY = \"memory\",\n REDIS = \"redis\",\n}\n\n/**\n * Queue configuration interface\n */\nexport interface QueueConfig {\n name: string; // Queue name\n description: string; // Queue description\n type: QueueType; // Queue service type\n queueName?: string; // Specific queue name (e.g., \"tasks\")\n options?: Record<string, any>; // Additional options (e.g., Redis connection options)\n}\n\n/**\n * Queue operation result interface\n */\nexport interface QueueResult<T = any> {\n data: T | null;\n error: any | null;\n}\n\n/**\n * Queue client interface\n */\nexport interface QueueClient {\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n/**\n * Queue Lattice protocol interface\n */\nexport interface QueueLatticeProtocol\n extends BaseLatticeProtocol<QueueConfig, QueueClient> {\n // Queue operations\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n\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;AAyEL,SAAS,SAAS,QAAqD;AAC5E,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,kBACd,QAC2B;AAC3B,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,mBAAmB,QAA+B;AAChE,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO,OAAO,SAAS,CAAC;AAAA,EAC1B;AACA,SAAO,CAAC;AACV;AAKO,SAAS,uBAAuB,QAA+B;AACpE,MAAI,kBAAkB,MAAM,GAAG;AAC7B,WAAO,OAAO,aAAa,CAAC;AAAA,EAC9B;AACA,SAAO,CAAC;AACV;;;AC1GO,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,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;;;ACAL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","UIComponentType","QueueType"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AssistantStoreProtocol
|
|
3
|
+
*
|
|
4
|
+
* Assistant store protocol definitions for the Axiom Lattice framework
|
|
5
|
+
* Provides standardized interfaces for assistant management across all implementations
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Assistant type definition
|
|
10
|
+
*/
|
|
11
|
+
export interface Assistant {
|
|
12
|
+
/**
|
|
13
|
+
* Assistant identifier
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Assistant name
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Assistant description
|
|
24
|
+
*/
|
|
25
|
+
description?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Graph definition for the assistant
|
|
29
|
+
*/
|
|
30
|
+
graphDefinition: any;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Assistant creation timestamp
|
|
34
|
+
*/
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Assistant last update timestamp
|
|
39
|
+
*/
|
|
40
|
+
updatedAt: Date;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create assistant request type
|
|
45
|
+
*/
|
|
46
|
+
export interface CreateAssistantRequest {
|
|
47
|
+
/**
|
|
48
|
+
* Assistant name
|
|
49
|
+
*/
|
|
50
|
+
name: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Assistant description
|
|
54
|
+
*/
|
|
55
|
+
description?: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Graph definition for the assistant
|
|
59
|
+
*/
|
|
60
|
+
graphDefinition: any;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* AssistantStore interface
|
|
65
|
+
* Provides CRUD operations for assistant data
|
|
66
|
+
*/
|
|
67
|
+
export interface AssistantStore {
|
|
68
|
+
/**
|
|
69
|
+
* Get all assistants
|
|
70
|
+
* @returns Array of all assistants
|
|
71
|
+
*/
|
|
72
|
+
getAllAssistants(): Promise<Assistant[]>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get assistant by ID
|
|
76
|
+
* @param id Assistant identifier
|
|
77
|
+
* @returns Assistant if found, undefined otherwise
|
|
78
|
+
*/
|
|
79
|
+
getAssistantById(id: string): Promise<Assistant | null>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Create a new assistant
|
|
83
|
+
* @param id Assistant identifier
|
|
84
|
+
* @param data Assistant creation data
|
|
85
|
+
* @returns Created assistant
|
|
86
|
+
*/
|
|
87
|
+
createAssistant(id: string, data: CreateAssistantRequest): Promise<Assistant>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Update an existing assistant
|
|
91
|
+
* @param id Assistant identifier
|
|
92
|
+
* @param updates Partial assistant data to update
|
|
93
|
+
* @returns Updated assistant if found, null otherwise
|
|
94
|
+
*/
|
|
95
|
+
updateAssistant(
|
|
96
|
+
id: string,
|
|
97
|
+
updates: Partial<CreateAssistantRequest>
|
|
98
|
+
): Promise<Assistant | null>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Delete an assistant by ID
|
|
102
|
+
* @param id Assistant identifier
|
|
103
|
+
* @returns true if deleted, false otherwise
|
|
104
|
+
*/
|
|
105
|
+
deleteAssistant(id: string): Promise<boolean>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Check if assistant exists
|
|
109
|
+
* @param id Assistant identifier
|
|
110
|
+
* @returns true if assistant exists, false otherwise
|
|
111
|
+
*/
|
|
112
|
+
hasAssistant(id: string): Promise<boolean>;
|
|
113
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmbeddingsLatticeProtocol
|
|
3
|
+
*
|
|
4
|
+
* Embeddings Lattice protocol for defining unified interface for embedding models
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Embeddings } from "@langchain/core/embeddings";
|
|
8
|
+
import { BaseLatticeProtocol } from "./BaseLatticeProtocol";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Embeddings configuration interface
|
|
12
|
+
*/
|
|
13
|
+
export interface EmbeddingsConfig {
|
|
14
|
+
name: string; // Embeddings model name
|
|
15
|
+
description?: string; // Description of the embeddings model
|
|
16
|
+
dimensions?: number; // Embedding dimensions
|
|
17
|
+
maxChunkSize?: number; // Maximum chunk size for embedding
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Embeddings Lattice protocol interface
|
|
22
|
+
*/
|
|
23
|
+
export interface EmbeddingsLatticeProtocol
|
|
24
|
+
extends BaseLatticeProtocol<EmbeddingsConfig, Embeddings> {
|
|
25
|
+
// Embed documents into vectors
|
|
26
|
+
embedDocuments: (texts: string[]) => Promise<number[][]>;
|
|
27
|
+
|
|
28
|
+
// Embed a single query into a vector
|
|
29
|
+
embedQuery: (text: string) => Promise<number[]>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThreadStoreProtocol
|
|
3
|
+
*
|
|
4
|
+
* Thread store protocol definitions for the Axiom Lattice framework
|
|
5
|
+
* Provides standardized interfaces for thread management across all implementations
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Thread type definition
|
|
10
|
+
*/
|
|
11
|
+
export interface Thread {
|
|
12
|
+
/**
|
|
13
|
+
* Thread identifier
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Assistant identifier this thread belongs to
|
|
19
|
+
*/
|
|
20
|
+
assistantId: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Thread metadata
|
|
24
|
+
*/
|
|
25
|
+
metadata?: Record<string, any>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Thread creation timestamp
|
|
29
|
+
*/
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Thread last update timestamp
|
|
34
|
+
*/
|
|
35
|
+
updatedAt: Date;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create thread request type
|
|
40
|
+
*/
|
|
41
|
+
export interface CreateThreadRequest {
|
|
42
|
+
/**
|
|
43
|
+
* Thread metadata
|
|
44
|
+
*/
|
|
45
|
+
metadata?: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* ThreadStore interface
|
|
50
|
+
* Provides CRUD operations for thread data
|
|
51
|
+
* All operations are scoped to an assistant ID
|
|
52
|
+
*/
|
|
53
|
+
export interface ThreadStore {
|
|
54
|
+
/**
|
|
55
|
+
* Get all threads for a specific assistant
|
|
56
|
+
* @param assistantId Assistant identifier
|
|
57
|
+
* @returns Array of threads for the assistant
|
|
58
|
+
*/
|
|
59
|
+
getThreadsByAssistantId(assistantId: string): Promise<Thread[]>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get a thread by ID for a specific assistant
|
|
63
|
+
* @param assistantId Assistant identifier
|
|
64
|
+
* @param threadId Thread identifier
|
|
65
|
+
* @returns Thread if found, undefined otherwise
|
|
66
|
+
*/
|
|
67
|
+
getThreadById(
|
|
68
|
+
assistantId: string,
|
|
69
|
+
threadId: string
|
|
70
|
+
): Promise<Thread | undefined>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Create a new thread for an assistant
|
|
74
|
+
* @param assistantId Assistant identifier
|
|
75
|
+
* @param threadId Thread identifier
|
|
76
|
+
* @param data Thread creation data
|
|
77
|
+
* @returns Created thread
|
|
78
|
+
*/
|
|
79
|
+
createThread(
|
|
80
|
+
assistantId: string,
|
|
81
|
+
threadId: string,
|
|
82
|
+
data: CreateThreadRequest
|
|
83
|
+
): Promise<Thread>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Update an existing thread
|
|
87
|
+
* @param assistantId Assistant identifier
|
|
88
|
+
* @param threadId Thread identifier
|
|
89
|
+
* @param updates Partial thread data to update
|
|
90
|
+
* @returns Updated thread if found, null otherwise
|
|
91
|
+
*/
|
|
92
|
+
updateThread(
|
|
93
|
+
assistantId: string,
|
|
94
|
+
threadId: string,
|
|
95
|
+
updates: Partial<CreateThreadRequest>
|
|
96
|
+
): Promise<Thread | null>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Delete a thread by ID
|
|
100
|
+
* @param assistantId Assistant identifier
|
|
101
|
+
* @param threadId Thread identifier
|
|
102
|
+
* @returns true if deleted, false otherwise
|
|
103
|
+
*/
|
|
104
|
+
deleteThread(assistantId: string, threadId: string): Promise<boolean>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Check if thread exists
|
|
108
|
+
* @param assistantId Assistant identifier
|
|
109
|
+
* @param threadId Thread identifier
|
|
110
|
+
* @returns true if thread exists, false otherwise
|
|
111
|
+
*/
|
|
112
|
+
hasThread(assistantId: string, threadId: string): Promise<boolean>;
|
|
113
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VectorStoreLatticeProtocol
|
|
3
|
+
*
|
|
4
|
+
* VectorStore Lattice protocol for defining unified interface for vector store implementations
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { VectorStore } from "@langchain/core/vectorstores";
|
|
8
|
+
import { DocumentInterface } from "@langchain/core/documents";
|
|
9
|
+
import { BaseLatticeProtocol } from "./BaseLatticeProtocol";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* VectorStore configuration interface
|
|
13
|
+
*/
|
|
14
|
+
export interface VectorStoreConfig {
|
|
15
|
+
name: string; // VectorStore name
|
|
16
|
+
description?: string; // Description of the vector store
|
|
17
|
+
type?: string; // Vector store type (e.g., "pinecone", "chroma", "pgvector")
|
|
18
|
+
config?: Record<string, any>; // Configuration for the vector store
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* VectorStore Lattice protocol interface
|
|
23
|
+
*/
|
|
24
|
+
export interface VectorStoreLatticeProtocol
|
|
25
|
+
extends BaseLatticeProtocol<VectorStoreConfig, VectorStore> {
|
|
26
|
+
// Add precomputed vectors and documents
|
|
27
|
+
addVectors: (
|
|
28
|
+
vectors: number[][],
|
|
29
|
+
documents: DocumentInterface[],
|
|
30
|
+
options?: Record<string, any>
|
|
31
|
+
) => Promise<string[] | void>;
|
|
32
|
+
|
|
33
|
+
// Add documents (will be embedded automatically)
|
|
34
|
+
addDocuments: (
|
|
35
|
+
documents: DocumentInterface[],
|
|
36
|
+
options?: Record<string, any>
|
|
37
|
+
) => Promise<string[] | void>;
|
|
38
|
+
|
|
39
|
+
// Delete documents by parameters
|
|
40
|
+
delete: (params?: Record<string, any>) => Promise<void>;
|
|
41
|
+
|
|
42
|
+
// Similarity search with vector query
|
|
43
|
+
similaritySearchVectorWithScore: (
|
|
44
|
+
query: number[],
|
|
45
|
+
k: number,
|
|
46
|
+
filter?: VectorStore["FilterType"]
|
|
47
|
+
) => Promise<[DocumentInterface, number][]>;
|
|
48
|
+
|
|
49
|
+
// Similarity search with text query
|
|
50
|
+
similaritySearch: (
|
|
51
|
+
query: string,
|
|
52
|
+
k?: number,
|
|
53
|
+
filter?: VectorStore["FilterType"]
|
|
54
|
+
) => Promise<DocumentInterface[]>;
|
|
55
|
+
|
|
56
|
+
// Similarity search with text query and scores
|
|
57
|
+
similaritySearchWithScore: (
|
|
58
|
+
query: string,
|
|
59
|
+
k?: number,
|
|
60
|
+
filter?: VectorStore["FilterType"]
|
|
61
|
+
) => Promise<[DocumentInterface, number][]>;
|
|
62
|
+
|
|
63
|
+
// Maximal marginal relevance search (optional)
|
|
64
|
+
maxMarginalRelevanceSearch?: (
|
|
65
|
+
query: string,
|
|
66
|
+
options: {
|
|
67
|
+
k: number;
|
|
68
|
+
fetchK?: number;
|
|
69
|
+
lambda?: number;
|
|
70
|
+
filter?: VectorStore["FilterType"];
|
|
71
|
+
}
|
|
72
|
+
) => Promise<DocumentInterface[]>;
|
|
73
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -9,10 +9,13 @@ export * from "./ToolLatticeProtocol";
|
|
|
9
9
|
export * from "./ModelLatticeProtocol";
|
|
10
10
|
export * from "./AgentLatticeProtocol";
|
|
11
11
|
export * from "./MemoryLatticeProtocol";
|
|
12
|
-
export * from "./StorageLatticeProtocol";
|
|
13
12
|
export * from "./UILatticeProtocol";
|
|
14
13
|
export * from "./QueueLatticeProtocol";
|
|
14
|
+
export * from "./EmbeddingsLatticeProtocol";
|
|
15
|
+
export * from "./VectorStoreLatticeProtocol";
|
|
15
16
|
export * from "./MessageProtocol";
|
|
17
|
+
export * from "./ThreadStoreProtocol";
|
|
18
|
+
export * from "./AssistantStoreProtocol";
|
|
16
19
|
|
|
17
20
|
// 导出通用类型
|
|
18
21
|
export * from "./types";
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StorageLatticeProtocol
|
|
3
|
-
*
|
|
4
|
-
* 存储Lattice的协议,用于数据持久化和状态管理
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { BaseLatticeProtocol } from "./BaseLatticeProtocol";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 存储类型枚举
|
|
11
|
-
*/
|
|
12
|
-
export enum StorageType {
|
|
13
|
-
MEMORY = "memory",
|
|
14
|
-
LOCAL = "local",
|
|
15
|
-
DATABASE = "database",
|
|
16
|
-
CLOUD = "cloud",
|
|
17
|
-
DISTRIBUTED = "distributed",
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 存储配置接口
|
|
22
|
-
*/
|
|
23
|
-
export interface StorageConfig {
|
|
24
|
-
name: string; // 名称
|
|
25
|
-
description: string; // 描述
|
|
26
|
-
type: StorageType; // 存储类型
|
|
27
|
-
connectionString?: string; // 连接字符串
|
|
28
|
-
options?: Record<string, any>; // 其他选项
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 存储客户端接口
|
|
33
|
-
*/
|
|
34
|
-
export interface StorageClient {
|
|
35
|
-
set: (key: string, value: any) => Promise<void>;
|
|
36
|
-
get: (key: string) => Promise<any>;
|
|
37
|
-
has: (key: string) => Promise<boolean>;
|
|
38
|
-
delete: (key: string) => Promise<boolean>;
|
|
39
|
-
clear: () => Promise<void>;
|
|
40
|
-
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 存储Lattice协议接口
|
|
45
|
-
*/
|
|
46
|
-
export interface StorageLatticeProtocol
|
|
47
|
-
extends BaseLatticeProtocol<StorageConfig, StorageClient> {
|
|
48
|
-
// 存储操作方法
|
|
49
|
-
set: (key: string, value: any) => Promise<void>;
|
|
50
|
-
get: (key: string) => Promise<any>;
|
|
51
|
-
has: (key: string) => Promise<boolean>;
|
|
52
|
-
delete: (key: string) => Promise<boolean>;
|
|
53
|
-
clear: () => Promise<void>;
|
|
54
|
-
transaction: <T>(operations: () => Promise<T>) => Promise<T>;
|
|
55
|
-
}
|