@xache/langchain 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -107,6 +107,62 @@ const result = await extractor.extract(
107
107
  console.log(`Extracted ${result.count} memories`);
108
108
  ```
109
109
 
110
+ ### Knowledge Graph
111
+
112
+ Build and query a privacy-preserving knowledge graph of entities and relationships:
113
+
114
+ ```typescript
115
+ import {
116
+ createGraphExtractTool,
117
+ createGraphQueryTool,
118
+ createGraphAskTool,
119
+ createGraphLoadTool,
120
+ createGraphAddEntityTool,
121
+ createGraphAddRelationshipTool,
122
+ createGraphMergeEntitiesTool,
123
+ createGraphEntityHistoryTool,
124
+ XacheGraphRetriever,
125
+ } from '@xache/langchain';
126
+
127
+ const config = {
128
+ walletAddress: '0x...',
129
+ privateKey: '0x...',
130
+ llmProvider: 'anthropic',
131
+ llmApiKey: 'sk-ant-...',
132
+ };
133
+
134
+ // Extract entities from text
135
+ const extractTool = createGraphExtractTool(config);
136
+
137
+ // Query graph around an entity
138
+ const queryTool = createGraphQueryTool(config);
139
+
140
+ // Ask natural language questions
141
+ const askTool = createGraphAskTool(config);
142
+
143
+ // Load the full graph
144
+ const loadTool = createGraphLoadTool(config);
145
+
146
+ // Add entities and relationships manually
147
+ const addEntityTool = createGraphAddEntityTool(config);
148
+ const addRelTool = createGraphAddRelationshipTool(config);
149
+
150
+ // Merge duplicate entities
151
+ const mergeTool = createGraphMergeEntitiesTool(config);
152
+
153
+ // View entity version history
154
+ const historyTool = createGraphEntityHistoryTool(config);
155
+
156
+ // Use as a retriever for RAG
157
+ const graphRetriever = new XacheGraphRetriever({
158
+ walletAddress: '0x...',
159
+ privateKey: '0x...',
160
+ k: 10,
161
+ });
162
+
163
+ const docs = await graphRetriever.getRelevantDocuments('engineering team');
164
+ ```
165
+
110
166
  ### Reputation
111
167
 
112
168
  Check and verify agent reputation:
@@ -160,6 +216,8 @@ All operations use x402 micropayments (auto-handled):
160
216
  | Collective Contribute| $0.002 |
161
217
  | Collective Query | $0.011 |
162
218
  | Extraction (managed) | $0.011 |
219
+ | Graph Operations | $0.002 |
220
+ | Graph Ask (managed) | $0.011 |
163
221
 
164
222
  ## ERC-8004 Portable Reputation
165
223
 
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { BaseMemory, InputValues, MemoryVariables, OutputValues } from '@langchain/core/memory';
2
2
  import { BaseListChatMessageHistory } from '@langchain/core/chat_history';
3
3
  import { BaseMessage } from '@langchain/core/messages';
4
+ import { XacheSigner, XacheWalletProvider, LLMProvider, LLMApiFormat, SubjectContext } from '@xache/sdk';
4
5
  import { BaseRetriever, BaseRetrieverInput } from '@langchain/core/retrievers';
5
6
  import { Document } from '@langchain/core/documents';
6
7
  import { CallbackManagerForRetrieverRun } from '@langchain/core/callbacks/manager';
7
- import { LLMProvider, LLMApiFormat } from '@xache/sdk';
8
8
  import { DynamicStructuredTool } from '@langchain/core/tools';
9
9
 
10
10
  /**
@@ -15,8 +15,14 @@ import { DynamicStructuredTool } from '@langchain/core/tools';
15
15
  interface XacheChatMessageHistoryConfig {
16
16
  /** Wallet address for authentication */
17
17
  walletAddress: string;
18
- /** Private key for signing */
19
- privateKey: string;
18
+ /** Private key for signing (optional if signer or walletProvider is provided) */
19
+ privateKey?: string;
20
+ /** External signer (alternative to privateKey) */
21
+ signer?: XacheSigner;
22
+ /** Wallet provider for lazy signer resolution */
23
+ walletProvider?: XacheWalletProvider;
24
+ /** Encryption key for use with external signers */
25
+ encryptionKey?: string;
20
26
  /** Session ID to group messages */
21
27
  sessionId?: string;
22
28
  /** API URL (defaults to https://api.xache.xyz) */
@@ -166,8 +172,14 @@ declare class XacheConversationBufferMemory extends XacheMemory {
166
172
  interface XacheRetrieverConfig extends BaseRetrieverInput {
167
173
  /** Wallet address for authentication */
168
174
  walletAddress: string;
169
- /** Private key for signing */
170
- privateKey: string;
175
+ /** Private key for signing (optional if signer or walletProvider is provided) */
176
+ privateKey?: string;
177
+ /** External signer (alternative to privateKey) */
178
+ signer?: XacheSigner;
179
+ /** Wallet provider for lazy signer resolution */
180
+ walletProvider?: XacheWalletProvider;
181
+ /** Encryption key for use with external signers */
182
+ encryptionKey?: string;
171
183
  /** Number of documents to retrieve */
172
184
  k?: number;
173
185
  /** Filter by context */
@@ -238,8 +250,14 @@ interface ExtractionResult {
238
250
  interface XacheExtractorConfig {
239
251
  /** Wallet address for authentication */
240
252
  walletAddress: string;
241
- /** Private key for signing */
242
- privateKey: string;
253
+ /** Private key for signing (optional if signer or walletProvider is provided) */
254
+ privateKey?: string;
255
+ /** External signer (alternative to privateKey) */
256
+ signer?: XacheSigner;
257
+ /** Wallet provider for lazy signer resolution */
258
+ walletProvider?: XacheWalletProvider;
259
+ /** Encryption key for use with external signers */
260
+ encryptionKey?: string;
243
261
  /**
244
262
  * Extraction mode:
245
263
  * - 'xache-managed': Xache provides the LLM ($0.011)
@@ -336,8 +354,14 @@ declare class XacheExtractor {
336
354
  interface CollectiveToolConfig {
337
355
  /** Wallet address for authentication */
338
356
  walletAddress: string;
339
- /** Private key for signing */
340
- privateKey: string;
357
+ /** Private key for signing (optional if signer or walletProvider is provided) */
358
+ privateKey?: string;
359
+ /** External signer (alternative to privateKey) */
360
+ signer?: XacheSigner;
361
+ /** Wallet provider for lazy signer resolution */
362
+ walletProvider?: XacheWalletProvider;
363
+ /** Encryption key for use with external signers */
364
+ encryptionKey?: string;
341
365
  /** API URL (defaults to https://api.xache.xyz) */
342
366
  apiUrl?: string;
343
367
  /** Chain: 'base' or 'solana' */
@@ -400,8 +424,14 @@ declare class XacheCollectiveQueryTool {
400
424
  interface ReputationToolConfig {
401
425
  /** Wallet address for authentication */
402
426
  walletAddress: string;
403
- /** Private key for signing */
404
- privateKey: string;
427
+ /** Private key for signing (optional if signer or walletProvider is provided) */
428
+ privateKey?: string;
429
+ /** External signer (alternative to privateKey) */
430
+ signer?: XacheSigner;
431
+ /** Wallet provider for lazy signer resolution */
432
+ walletProvider?: XacheWalletProvider;
433
+ /** Encryption key for use with external signers */
434
+ encryptionKey?: string;
405
435
  /** API URL (defaults to https://api.xache.xyz) */
406
436
  apiUrl?: string;
407
437
  /** Chain: 'base' or 'solana' */
@@ -476,4 +506,180 @@ declare class XacheReputationChecker {
476
506
  meetsThreshold(agentDid: string, minScore: number): Promise<boolean>;
477
507
  }
478
508
 
479
- export { type CollectiveToolConfig, type ExtractedMemory, type ExtractionResult, type ReputationResult, type ReputationToolConfig, XacheChatMessageHistory, type XacheChatMessageHistoryConfig, XacheCollectiveContributeTool, XacheCollectiveQueryTool, XacheConversationBufferMemory, XacheExtractor, type XacheExtractorConfig, XacheMemory, type XacheMemoryConfig, XacheReputationChecker, XacheReputationTool, XacheRetriever, type XacheRetrieverConfig, createCollectiveContributeTool, createCollectiveQueryTool, createReputationTool };
509
+ /**
510
+ * Xache Knowledge Graph for LangChain.js
511
+ * Extract, query, and manage entities/relationships in a privacy-preserving knowledge graph
512
+ */
513
+
514
+ interface GraphToolConfig {
515
+ /** Wallet address for authentication */
516
+ walletAddress: string;
517
+ /** Private key for signing (optional if signer or walletProvider is provided) */
518
+ privateKey?: string;
519
+ /** External signer (alternative to privateKey) */
520
+ signer?: XacheSigner;
521
+ /** Wallet provider for lazy signer resolution */
522
+ walletProvider?: XacheWalletProvider;
523
+ /** Encryption key for use with external signers */
524
+ encryptionKey?: string;
525
+ /** API URL (defaults to https://api.xache.xyz) */
526
+ apiUrl?: string;
527
+ /** Chain: 'base' or 'solana' */
528
+ chain?: 'base' | 'solana';
529
+ /** Subject context for graph scoping (defaults to GLOBAL) */
530
+ subject?: SubjectContext;
531
+ /** LLM provider for extract/ask (api-key mode) */
532
+ llmProvider?: LLMProvider;
533
+ /** LLM API key */
534
+ llmApiKey?: string;
535
+ /** LLM model override */
536
+ llmModel?: string;
537
+ /** LLM endpoint URL (endpoint mode) */
538
+ llmEndpoint?: string;
539
+ /** LLM auth token (endpoint mode) */
540
+ llmAuthToken?: string;
541
+ /** LLM API format (endpoint mode, default: openai) */
542
+ llmFormat?: LLMApiFormat;
543
+ }
544
+ /**
545
+ * Create a tool for extracting entities/relationships from agent traces.
546
+ *
547
+ * @example
548
+ * ```typescript
549
+ * const extractTool = createGraphExtractTool({
550
+ * walletAddress: '0x...',
551
+ * privateKey: '0x...',
552
+ * llmProvider: 'anthropic',
553
+ * llmApiKey: 'sk-ant-...',
554
+ * });
555
+ * ```
556
+ */
557
+ declare function createGraphExtractTool(config: GraphToolConfig): DynamicStructuredTool;
558
+ /**
559
+ * Create a tool for querying the knowledge graph around a specific entity.
560
+ */
561
+ declare function createGraphQueryTool(config: GraphToolConfig): DynamicStructuredTool;
562
+ /**
563
+ * Create a tool for asking natural language questions about the knowledge graph.
564
+ */
565
+ declare function createGraphAskTool(config: GraphToolConfig): DynamicStructuredTool;
566
+ /**
567
+ * Create a tool for adding entities to the knowledge graph.
568
+ */
569
+ declare function createGraphAddEntityTool(config: GraphToolConfig): DynamicStructuredTool;
570
+ /**
571
+ * Create a tool for adding relationships between entities.
572
+ */
573
+ declare function createGraphAddRelationshipTool(config: GraphToolConfig): DynamicStructuredTool;
574
+ /**
575
+ * Create a tool for loading the full knowledge graph.
576
+ */
577
+ declare function createGraphLoadTool(config: GraphToolConfig): DynamicStructuredTool;
578
+ /**
579
+ * Create a tool for merging two entities in the knowledge graph.
580
+ */
581
+ declare function createGraphMergeEntitiesTool(config: GraphToolConfig): DynamicStructuredTool;
582
+ /**
583
+ * Create a tool for getting the version history of an entity.
584
+ */
585
+ declare function createGraphEntityHistoryTool(config: GraphToolConfig): DynamicStructuredTool;
586
+ /**
587
+ * Class wrapper for graph extract tool
588
+ */
589
+ declare class XacheGraphExtractTool {
590
+ private tool;
591
+ constructor(config: GraphToolConfig);
592
+ asTool(): DynamicStructuredTool;
593
+ }
594
+ /**
595
+ * Class wrapper for graph query tool
596
+ */
597
+ declare class XacheGraphQueryTool {
598
+ private tool;
599
+ constructor(config: GraphToolConfig);
600
+ asTool(): DynamicStructuredTool;
601
+ }
602
+ /**
603
+ * Class wrapper for graph ask tool
604
+ */
605
+ declare class XacheGraphAskTool {
606
+ private tool;
607
+ constructor(config: GraphToolConfig);
608
+ asTool(): DynamicStructuredTool;
609
+ }
610
+ /**
611
+ * Class wrapper for graph load tool
612
+ */
613
+ declare class XacheGraphLoadTool {
614
+ private tool;
615
+ constructor(config: GraphToolConfig);
616
+ asTool(): DynamicStructuredTool;
617
+ }
618
+ /**
619
+ * Class wrapper for graph merge entities tool
620
+ */
621
+ declare class XacheGraphMergeEntitiesTool {
622
+ private tool;
623
+ constructor(config: GraphToolConfig);
624
+ asTool(): DynamicStructuredTool;
625
+ }
626
+ /**
627
+ * Class wrapper for graph entity history tool
628
+ */
629
+ declare class XacheGraphEntityHistoryTool {
630
+ private tool;
631
+ constructor(config: GraphToolConfig);
632
+ asTool(): DynamicStructuredTool;
633
+ }
634
+ interface XacheGraphRetrieverConfig extends BaseRetrieverInput {
635
+ /** Wallet address for authentication */
636
+ walletAddress: string;
637
+ /** Private key for signing (optional if signer or walletProvider is provided) */
638
+ privateKey?: string;
639
+ /** External signer (alternative to privateKey) */
640
+ signer?: XacheSigner;
641
+ /** Wallet provider for lazy signer resolution */
642
+ walletProvider?: XacheWalletProvider;
643
+ /** Encryption key for use with external signers */
644
+ encryptionKey?: string;
645
+ /** API URL (defaults to https://api.xache.xyz) */
646
+ apiUrl?: string;
647
+ /** Chain: 'base' or 'solana' */
648
+ chain?: 'base' | 'solana';
649
+ /** Subject context for graph scoping */
650
+ subject?: SubjectContext;
651
+ /** Starting entity for subgraph query (optional — if not set, loads full graph) */
652
+ startEntity?: string;
653
+ /** Depth for subgraph query (default: 2) */
654
+ depth?: number;
655
+ /** Max results to return */
656
+ k?: number;
657
+ }
658
+ /**
659
+ * Retriever that fetches documents from the Xache knowledge graph.
660
+ * Each entity becomes a Document with its name, type, and summary.
661
+ *
662
+ * @example
663
+ * ```typescript
664
+ * const retriever = new XacheGraphRetriever({
665
+ * walletAddress: '0x...',
666
+ * privateKey: '0x...',
667
+ * k: 10,
668
+ * });
669
+ *
670
+ * const docs = await retriever.getRelevantDocuments('engineering team');
671
+ * ```
672
+ */
673
+ declare class XacheGraphRetriever extends BaseRetriever {
674
+ lc_namespace: string[];
675
+ static lc_name(): string;
676
+ private client;
677
+ private subject;
678
+ private startEntity?;
679
+ private depth;
680
+ private k;
681
+ constructor(config: XacheGraphRetrieverConfig);
682
+ _getRelevantDocuments(query: string, _runManager?: CallbackManagerForRetrieverRun): Promise<Document[]>;
683
+ }
684
+
685
+ export { type CollectiveToolConfig, type ExtractedMemory, type ExtractionResult, type GraphToolConfig, type ReputationResult, type ReputationToolConfig, XacheChatMessageHistory, type XacheChatMessageHistoryConfig, XacheCollectiveContributeTool, XacheCollectiveQueryTool, XacheConversationBufferMemory, XacheExtractor, type XacheExtractorConfig, XacheGraphAskTool, XacheGraphEntityHistoryTool, XacheGraphExtractTool, XacheGraphLoadTool, XacheGraphMergeEntitiesTool, XacheGraphQueryTool, XacheGraphRetriever, type XacheGraphRetrieverConfig, XacheMemory, type XacheMemoryConfig, XacheReputationChecker, XacheReputationTool, XacheRetriever, type XacheRetrieverConfig, createCollectiveContributeTool, createCollectiveQueryTool, createGraphAddEntityTool, createGraphAddRelationshipTool, createGraphAskTool, createGraphEntityHistoryTool, createGraphExtractTool, createGraphLoadTool, createGraphMergeEntitiesTool, createGraphQueryTool, createReputationTool };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { BaseMemory, InputValues, MemoryVariables, OutputValues } from '@langchain/core/memory';
2
2
  import { BaseListChatMessageHistory } from '@langchain/core/chat_history';
3
3
  import { BaseMessage } from '@langchain/core/messages';
4
+ import { XacheSigner, XacheWalletProvider, LLMProvider, LLMApiFormat, SubjectContext } from '@xache/sdk';
4
5
  import { BaseRetriever, BaseRetrieverInput } from '@langchain/core/retrievers';
5
6
  import { Document } from '@langchain/core/documents';
6
7
  import { CallbackManagerForRetrieverRun } from '@langchain/core/callbacks/manager';
7
- import { LLMProvider, LLMApiFormat } from '@xache/sdk';
8
8
  import { DynamicStructuredTool } from '@langchain/core/tools';
9
9
 
10
10
  /**
@@ -15,8 +15,14 @@ import { DynamicStructuredTool } from '@langchain/core/tools';
15
15
  interface XacheChatMessageHistoryConfig {
16
16
  /** Wallet address for authentication */
17
17
  walletAddress: string;
18
- /** Private key for signing */
19
- privateKey: string;
18
+ /** Private key for signing (optional if signer or walletProvider is provided) */
19
+ privateKey?: string;
20
+ /** External signer (alternative to privateKey) */
21
+ signer?: XacheSigner;
22
+ /** Wallet provider for lazy signer resolution */
23
+ walletProvider?: XacheWalletProvider;
24
+ /** Encryption key for use with external signers */
25
+ encryptionKey?: string;
20
26
  /** Session ID to group messages */
21
27
  sessionId?: string;
22
28
  /** API URL (defaults to https://api.xache.xyz) */
@@ -166,8 +172,14 @@ declare class XacheConversationBufferMemory extends XacheMemory {
166
172
  interface XacheRetrieverConfig extends BaseRetrieverInput {
167
173
  /** Wallet address for authentication */
168
174
  walletAddress: string;
169
- /** Private key for signing */
170
- privateKey: string;
175
+ /** Private key for signing (optional if signer or walletProvider is provided) */
176
+ privateKey?: string;
177
+ /** External signer (alternative to privateKey) */
178
+ signer?: XacheSigner;
179
+ /** Wallet provider for lazy signer resolution */
180
+ walletProvider?: XacheWalletProvider;
181
+ /** Encryption key for use with external signers */
182
+ encryptionKey?: string;
171
183
  /** Number of documents to retrieve */
172
184
  k?: number;
173
185
  /** Filter by context */
@@ -238,8 +250,14 @@ interface ExtractionResult {
238
250
  interface XacheExtractorConfig {
239
251
  /** Wallet address for authentication */
240
252
  walletAddress: string;
241
- /** Private key for signing */
242
- privateKey: string;
253
+ /** Private key for signing (optional if signer or walletProvider is provided) */
254
+ privateKey?: string;
255
+ /** External signer (alternative to privateKey) */
256
+ signer?: XacheSigner;
257
+ /** Wallet provider for lazy signer resolution */
258
+ walletProvider?: XacheWalletProvider;
259
+ /** Encryption key for use with external signers */
260
+ encryptionKey?: string;
243
261
  /**
244
262
  * Extraction mode:
245
263
  * - 'xache-managed': Xache provides the LLM ($0.011)
@@ -336,8 +354,14 @@ declare class XacheExtractor {
336
354
  interface CollectiveToolConfig {
337
355
  /** Wallet address for authentication */
338
356
  walletAddress: string;
339
- /** Private key for signing */
340
- privateKey: string;
357
+ /** Private key for signing (optional if signer or walletProvider is provided) */
358
+ privateKey?: string;
359
+ /** External signer (alternative to privateKey) */
360
+ signer?: XacheSigner;
361
+ /** Wallet provider for lazy signer resolution */
362
+ walletProvider?: XacheWalletProvider;
363
+ /** Encryption key for use with external signers */
364
+ encryptionKey?: string;
341
365
  /** API URL (defaults to https://api.xache.xyz) */
342
366
  apiUrl?: string;
343
367
  /** Chain: 'base' or 'solana' */
@@ -400,8 +424,14 @@ declare class XacheCollectiveQueryTool {
400
424
  interface ReputationToolConfig {
401
425
  /** Wallet address for authentication */
402
426
  walletAddress: string;
403
- /** Private key for signing */
404
- privateKey: string;
427
+ /** Private key for signing (optional if signer or walletProvider is provided) */
428
+ privateKey?: string;
429
+ /** External signer (alternative to privateKey) */
430
+ signer?: XacheSigner;
431
+ /** Wallet provider for lazy signer resolution */
432
+ walletProvider?: XacheWalletProvider;
433
+ /** Encryption key for use with external signers */
434
+ encryptionKey?: string;
405
435
  /** API URL (defaults to https://api.xache.xyz) */
406
436
  apiUrl?: string;
407
437
  /** Chain: 'base' or 'solana' */
@@ -476,4 +506,180 @@ declare class XacheReputationChecker {
476
506
  meetsThreshold(agentDid: string, minScore: number): Promise<boolean>;
477
507
  }
478
508
 
479
- export { type CollectiveToolConfig, type ExtractedMemory, type ExtractionResult, type ReputationResult, type ReputationToolConfig, XacheChatMessageHistory, type XacheChatMessageHistoryConfig, XacheCollectiveContributeTool, XacheCollectiveQueryTool, XacheConversationBufferMemory, XacheExtractor, type XacheExtractorConfig, XacheMemory, type XacheMemoryConfig, XacheReputationChecker, XacheReputationTool, XacheRetriever, type XacheRetrieverConfig, createCollectiveContributeTool, createCollectiveQueryTool, createReputationTool };
509
+ /**
510
+ * Xache Knowledge Graph for LangChain.js
511
+ * Extract, query, and manage entities/relationships in a privacy-preserving knowledge graph
512
+ */
513
+
514
+ interface GraphToolConfig {
515
+ /** Wallet address for authentication */
516
+ walletAddress: string;
517
+ /** Private key for signing (optional if signer or walletProvider is provided) */
518
+ privateKey?: string;
519
+ /** External signer (alternative to privateKey) */
520
+ signer?: XacheSigner;
521
+ /** Wallet provider for lazy signer resolution */
522
+ walletProvider?: XacheWalletProvider;
523
+ /** Encryption key for use with external signers */
524
+ encryptionKey?: string;
525
+ /** API URL (defaults to https://api.xache.xyz) */
526
+ apiUrl?: string;
527
+ /** Chain: 'base' or 'solana' */
528
+ chain?: 'base' | 'solana';
529
+ /** Subject context for graph scoping (defaults to GLOBAL) */
530
+ subject?: SubjectContext;
531
+ /** LLM provider for extract/ask (api-key mode) */
532
+ llmProvider?: LLMProvider;
533
+ /** LLM API key */
534
+ llmApiKey?: string;
535
+ /** LLM model override */
536
+ llmModel?: string;
537
+ /** LLM endpoint URL (endpoint mode) */
538
+ llmEndpoint?: string;
539
+ /** LLM auth token (endpoint mode) */
540
+ llmAuthToken?: string;
541
+ /** LLM API format (endpoint mode, default: openai) */
542
+ llmFormat?: LLMApiFormat;
543
+ }
544
+ /**
545
+ * Create a tool for extracting entities/relationships from agent traces.
546
+ *
547
+ * @example
548
+ * ```typescript
549
+ * const extractTool = createGraphExtractTool({
550
+ * walletAddress: '0x...',
551
+ * privateKey: '0x...',
552
+ * llmProvider: 'anthropic',
553
+ * llmApiKey: 'sk-ant-...',
554
+ * });
555
+ * ```
556
+ */
557
+ declare function createGraphExtractTool(config: GraphToolConfig): DynamicStructuredTool;
558
+ /**
559
+ * Create a tool for querying the knowledge graph around a specific entity.
560
+ */
561
+ declare function createGraphQueryTool(config: GraphToolConfig): DynamicStructuredTool;
562
+ /**
563
+ * Create a tool for asking natural language questions about the knowledge graph.
564
+ */
565
+ declare function createGraphAskTool(config: GraphToolConfig): DynamicStructuredTool;
566
+ /**
567
+ * Create a tool for adding entities to the knowledge graph.
568
+ */
569
+ declare function createGraphAddEntityTool(config: GraphToolConfig): DynamicStructuredTool;
570
+ /**
571
+ * Create a tool for adding relationships between entities.
572
+ */
573
+ declare function createGraphAddRelationshipTool(config: GraphToolConfig): DynamicStructuredTool;
574
+ /**
575
+ * Create a tool for loading the full knowledge graph.
576
+ */
577
+ declare function createGraphLoadTool(config: GraphToolConfig): DynamicStructuredTool;
578
+ /**
579
+ * Create a tool for merging two entities in the knowledge graph.
580
+ */
581
+ declare function createGraphMergeEntitiesTool(config: GraphToolConfig): DynamicStructuredTool;
582
+ /**
583
+ * Create a tool for getting the version history of an entity.
584
+ */
585
+ declare function createGraphEntityHistoryTool(config: GraphToolConfig): DynamicStructuredTool;
586
+ /**
587
+ * Class wrapper for graph extract tool
588
+ */
589
+ declare class XacheGraphExtractTool {
590
+ private tool;
591
+ constructor(config: GraphToolConfig);
592
+ asTool(): DynamicStructuredTool;
593
+ }
594
+ /**
595
+ * Class wrapper for graph query tool
596
+ */
597
+ declare class XacheGraphQueryTool {
598
+ private tool;
599
+ constructor(config: GraphToolConfig);
600
+ asTool(): DynamicStructuredTool;
601
+ }
602
+ /**
603
+ * Class wrapper for graph ask tool
604
+ */
605
+ declare class XacheGraphAskTool {
606
+ private tool;
607
+ constructor(config: GraphToolConfig);
608
+ asTool(): DynamicStructuredTool;
609
+ }
610
+ /**
611
+ * Class wrapper for graph load tool
612
+ */
613
+ declare class XacheGraphLoadTool {
614
+ private tool;
615
+ constructor(config: GraphToolConfig);
616
+ asTool(): DynamicStructuredTool;
617
+ }
618
+ /**
619
+ * Class wrapper for graph merge entities tool
620
+ */
621
+ declare class XacheGraphMergeEntitiesTool {
622
+ private tool;
623
+ constructor(config: GraphToolConfig);
624
+ asTool(): DynamicStructuredTool;
625
+ }
626
+ /**
627
+ * Class wrapper for graph entity history tool
628
+ */
629
+ declare class XacheGraphEntityHistoryTool {
630
+ private tool;
631
+ constructor(config: GraphToolConfig);
632
+ asTool(): DynamicStructuredTool;
633
+ }
634
+ interface XacheGraphRetrieverConfig extends BaseRetrieverInput {
635
+ /** Wallet address for authentication */
636
+ walletAddress: string;
637
+ /** Private key for signing (optional if signer or walletProvider is provided) */
638
+ privateKey?: string;
639
+ /** External signer (alternative to privateKey) */
640
+ signer?: XacheSigner;
641
+ /** Wallet provider for lazy signer resolution */
642
+ walletProvider?: XacheWalletProvider;
643
+ /** Encryption key for use with external signers */
644
+ encryptionKey?: string;
645
+ /** API URL (defaults to https://api.xache.xyz) */
646
+ apiUrl?: string;
647
+ /** Chain: 'base' or 'solana' */
648
+ chain?: 'base' | 'solana';
649
+ /** Subject context for graph scoping */
650
+ subject?: SubjectContext;
651
+ /** Starting entity for subgraph query (optional — if not set, loads full graph) */
652
+ startEntity?: string;
653
+ /** Depth for subgraph query (default: 2) */
654
+ depth?: number;
655
+ /** Max results to return */
656
+ k?: number;
657
+ }
658
+ /**
659
+ * Retriever that fetches documents from the Xache knowledge graph.
660
+ * Each entity becomes a Document with its name, type, and summary.
661
+ *
662
+ * @example
663
+ * ```typescript
664
+ * const retriever = new XacheGraphRetriever({
665
+ * walletAddress: '0x...',
666
+ * privateKey: '0x...',
667
+ * k: 10,
668
+ * });
669
+ *
670
+ * const docs = await retriever.getRelevantDocuments('engineering team');
671
+ * ```
672
+ */
673
+ declare class XacheGraphRetriever extends BaseRetriever {
674
+ lc_namespace: string[];
675
+ static lc_name(): string;
676
+ private client;
677
+ private subject;
678
+ private startEntity?;
679
+ private depth;
680
+ private k;
681
+ constructor(config: XacheGraphRetrieverConfig);
682
+ _getRelevantDocuments(query: string, _runManager?: CallbackManagerForRetrieverRun): Promise<Document[]>;
683
+ }
684
+
685
+ export { type CollectiveToolConfig, type ExtractedMemory, type ExtractionResult, type GraphToolConfig, type ReputationResult, type ReputationToolConfig, XacheChatMessageHistory, type XacheChatMessageHistoryConfig, XacheCollectiveContributeTool, XacheCollectiveQueryTool, XacheConversationBufferMemory, XacheExtractor, type XacheExtractorConfig, XacheGraphAskTool, XacheGraphEntityHistoryTool, XacheGraphExtractTool, XacheGraphLoadTool, XacheGraphMergeEntitiesTool, XacheGraphQueryTool, XacheGraphRetriever, type XacheGraphRetrieverConfig, XacheMemory, type XacheMemoryConfig, XacheReputationChecker, XacheReputationTool, XacheRetriever, type XacheRetrieverConfig, createCollectiveContributeTool, createCollectiveQueryTool, createGraphAddEntityTool, createGraphAddRelationshipTool, createGraphAskTool, createGraphEntityHistoryTool, createGraphExtractTool, createGraphLoadTool, createGraphMergeEntitiesTool, createGraphQueryTool, createReputationTool };