agent0-sdk 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/core/agent.d.ts +76 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +477 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/contracts.d.ts +688 -0
- package/dist/core/contracts.d.ts.map +1 -0
- package/dist/core/contracts.js +348 -0
- package/dist/core/contracts.js.map +1 -0
- package/dist/core/endpoint-crawler.d.ts +44 -0
- package/dist/core/endpoint-crawler.d.ts.map +1 -0
- package/dist/core/endpoint-crawler.js +280 -0
- package/dist/core/endpoint-crawler.js.map +1 -0
- package/dist/core/feedback-manager.d.ts +98 -0
- package/dist/core/feedback-manager.d.ts.map +1 -0
- package/dist/core/feedback-manager.js +543 -0
- package/dist/core/feedback-manager.js.map +1 -0
- package/dist/core/indexer.d.ts +37 -0
- package/dist/core/indexer.d.ts.map +1 -0
- package/dist/core/indexer.js +189 -0
- package/dist/core/indexer.js.map +1 -0
- package/dist/core/ipfs-client.d.ts +88 -0
- package/dist/core/ipfs-client.d.ts.map +1 -0
- package/dist/core/ipfs-client.js +334 -0
- package/dist/core/ipfs-client.js.map +1 -0
- package/dist/core/sdk.d.ts +177 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +544 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/subgraph-client.d.ts +68 -0
- package/dist/core/subgraph-client.d.ts.map +1 -0
- package/dist/core/subgraph-client.js +635 -0
- package/dist/core/subgraph-client.js.map +1 -0
- package/dist/core/web3-client.d.ts +94 -0
- package/dist/core/web3-client.d.ts.map +1 -0
- package/dist/core/web3-client.js +197 -0
- package/dist/core/web3-client.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/models/enums.d.ts +22 -0
- package/dist/models/enums.d.ts.map +1 -0
- package/dist/models/enums.js +24 -0
- package/dist/models/enums.js.map +1 -0
- package/dist/models/generated/subgraph-types.d.ts +208 -0
- package/dist/models/generated/subgraph-types.d.ts.map +1 -0
- package/dist/models/generated/subgraph-types.js +2 -0
- package/dist/models/generated/subgraph-types.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +8 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/interfaces.d.ts +125 -0
- package/dist/models/interfaces.d.ts.map +1 -0
- package/dist/models/interfaces.js +5 -0
- package/dist/models/interfaces.js.map +1 -0
- package/dist/models/types.d.ts +11 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +5 -0
- package/dist/models/types.js.map +1 -0
- package/dist/utils/constants.d.ts +24 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +28 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/id-format.d.ts +30 -0
- package/dist/utils/id-format.d.ts.map +1 -0
- package/dist/utils/id-format.js +67 -0
- package/dist/utils/id-format.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validation.d.ts +25 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +61 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent indexer for discovery and search functionality
|
|
3
|
+
* Simplified version focused on subgraph queries (no local ML indexing)
|
|
4
|
+
*/
|
|
5
|
+
import { normalizeAddress } from '../utils/validation';
|
|
6
|
+
/**
|
|
7
|
+
* Simplified indexer that primarily uses subgraph for queries
|
|
8
|
+
* No local indexing or ML capabilities - all queries go through subgraph
|
|
9
|
+
*/
|
|
10
|
+
export class AgentIndexer {
|
|
11
|
+
constructor(web3Client, subgraphClient) {
|
|
12
|
+
this.web3Client = web3Client;
|
|
13
|
+
this.subgraphClient = subgraphClient;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get agent summary from index/subgraph
|
|
17
|
+
*/
|
|
18
|
+
async getAgent(agentId) {
|
|
19
|
+
// Use subgraph if available (preferred)
|
|
20
|
+
if (this.subgraphClient) {
|
|
21
|
+
const agent = await this.subgraphClient.getAgentById(agentId);
|
|
22
|
+
if (agent) {
|
|
23
|
+
return agent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Fallback: would need to query blockchain directly
|
|
27
|
+
// For now, throw error if not in subgraph
|
|
28
|
+
throw new Error(`Agent ${agentId} not found. Subgraph required for querying.`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Search agents with filters
|
|
32
|
+
*/
|
|
33
|
+
async searchAgents(params = {}, pageSize = 50, cursor) {
|
|
34
|
+
if (!this.subgraphClient) {
|
|
35
|
+
throw new Error('Subgraph client required for agent search');
|
|
36
|
+
}
|
|
37
|
+
// Ensure params is always an object
|
|
38
|
+
const searchParams = params || {};
|
|
39
|
+
// Parse cursor for pagination
|
|
40
|
+
const skip = cursor ? parseInt(cursor, 10) : 0;
|
|
41
|
+
// Use subgraph search which pushes filters and pagination to subgraph level (much more efficient)
|
|
42
|
+
// Fetch one extra record to check if there's a next page
|
|
43
|
+
let agents = await this.subgraphClient.searchAgents(searchParams, pageSize + 1, skip);
|
|
44
|
+
// Apply any remaining client-side filtering (for complex filters like array contains)
|
|
45
|
+
agents = this._filterAgents(agents, searchParams);
|
|
46
|
+
// Check if there are more results (we fetched pageSize + 1)
|
|
47
|
+
const hasMore = agents.length > pageSize;
|
|
48
|
+
const paginatedAgents = hasMore ? agents.slice(0, pageSize) : agents;
|
|
49
|
+
// Return next cursor if we have more results
|
|
50
|
+
const nextCursor = hasMore ? String(skip + pageSize) : undefined;
|
|
51
|
+
return {
|
|
52
|
+
items: paginatedAgents,
|
|
53
|
+
nextCursor,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
_filterAgents(agents, params) {
|
|
57
|
+
const { name, mcp, a2a, ens, did, walletAddress, supportedTrust, a2aSkills, mcpTools, mcpPrompts, mcpResources, active, x402support, chains, } = params;
|
|
58
|
+
return agents.filter(agent => {
|
|
59
|
+
// Filter by name (flattened from registrationFile)
|
|
60
|
+
if (name && !agent.name?.toLowerCase().includes(name.toLowerCase())) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Filter by MCP endpoint (flattened to agent.mcp boolean)
|
|
64
|
+
if (mcp !== undefined && agent.mcp !== mcp) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Filter by A2A endpoint (flattened to agent.a2a boolean)
|
|
68
|
+
if (a2a !== undefined && agent.a2a !== a2a) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
// Filter by ENS (flattened from registrationFile)
|
|
72
|
+
if (ens && agent.ens && normalizeAddress(agent.ens) !== normalizeAddress(ens)) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
// Filter by DID (flattened from registrationFile)
|
|
76
|
+
if (did && agent.did !== did) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
// Filter by wallet address (flattened from registrationFile)
|
|
80
|
+
if (walletAddress && agent.walletAddress && normalizeAddress(agent.walletAddress) !== normalizeAddress(walletAddress)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
// Filter by supported trusts (flattened from registrationFile)
|
|
84
|
+
if (supportedTrust && supportedTrust.length > 0) {
|
|
85
|
+
const agentTrusts = agent.supportedTrusts || [];
|
|
86
|
+
if (!supportedTrust.some((trust) => agentTrusts.includes(trust))) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Filter by A2A skills (flattened from registrationFile)
|
|
91
|
+
if (a2aSkills && a2aSkills.length > 0) {
|
|
92
|
+
const agentSkills = agent.a2aSkills || [];
|
|
93
|
+
if (!a2aSkills.some(skill => agentSkills.includes(skill))) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Filter by MCP tools (flattened from registrationFile)
|
|
98
|
+
if (mcpTools && mcpTools.length > 0) {
|
|
99
|
+
const agentTools = agent.mcpTools || [];
|
|
100
|
+
if (!mcpTools.some(tool => agentTools.includes(tool))) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Filter by MCP prompts (flattened from registrationFile)
|
|
105
|
+
if (mcpPrompts && mcpPrompts.length > 0) {
|
|
106
|
+
const agentPrompts = agent.mcpPrompts || [];
|
|
107
|
+
if (!mcpPrompts.some(prompt => agentPrompts.includes(prompt))) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Filter by MCP resources (flattened from registrationFile)
|
|
112
|
+
if (mcpResources && mcpResources.length > 0) {
|
|
113
|
+
const agentResources = agent.mcpResources || [];
|
|
114
|
+
if (!mcpResources.some(resource => agentResources.includes(resource))) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Filter by active status (flattened from registrationFile)
|
|
119
|
+
if (active !== undefined && agent.active !== active) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
// Filter by x402support (flattened from registrationFile)
|
|
123
|
+
if (x402support !== undefined && agent.x402support !== x402support) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
// Filter by chain
|
|
127
|
+
if (chains && chains.length > 0 && !chains.includes(agent.chainId)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Search agents by reputation
|
|
135
|
+
*/
|
|
136
|
+
async searchAgentsByReputation(agents, tags, reviewers, capabilities, skills, tasks, names, minAverageScore, includeRevoked = false, first = 50, skip = 0, sort = ['createdAt:desc']) {
|
|
137
|
+
if (!this.subgraphClient) {
|
|
138
|
+
throw new Error('Subgraph client required for reputation search');
|
|
139
|
+
}
|
|
140
|
+
// Parse sort parameter
|
|
141
|
+
let orderBy = 'createdAt';
|
|
142
|
+
let orderDirection = 'desc';
|
|
143
|
+
if (sort && sort.length > 0) {
|
|
144
|
+
const sortField = sort[0].split(':');
|
|
145
|
+
orderBy = sortField[0] || orderBy;
|
|
146
|
+
orderDirection = sortField[1] || orderDirection;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const agentsData = await this.subgraphClient.searchAgentsByReputation(agents, tags, reviewers, capabilities, skills, tasks, names, minAverageScore, includeRevoked, first, skip, orderBy, orderDirection);
|
|
150
|
+
// Transform to AgentSummary with averageScore in extras
|
|
151
|
+
const items = agentsData.map((agent) => {
|
|
152
|
+
const regFile = agent.registrationFile;
|
|
153
|
+
return {
|
|
154
|
+
chainId: parseInt(agent.chainId?.toString() || '0', 10),
|
|
155
|
+
agentId: agent.id || '',
|
|
156
|
+
name: regFile?.name || '',
|
|
157
|
+
image: regFile?.image || undefined,
|
|
158
|
+
description: regFile?.description || '',
|
|
159
|
+
owners: agent.owner ? [normalizeAddress(agent.owner)] : [],
|
|
160
|
+
operators: (agent.operators || []).map((op) => normalizeAddress(op)),
|
|
161
|
+
mcp: !!regFile?.mcpEndpoint,
|
|
162
|
+
a2a: !!regFile?.a2aEndpoint,
|
|
163
|
+
ens: regFile?.ens || undefined,
|
|
164
|
+
did: regFile?.did || undefined,
|
|
165
|
+
walletAddress: regFile?.agentWallet ? normalizeAddress(regFile.agentWallet) : undefined,
|
|
166
|
+
supportedTrusts: regFile?.supportedTrusts || [],
|
|
167
|
+
a2aSkills: regFile?.a2aSkills || [],
|
|
168
|
+
mcpTools: regFile?.mcpTools || [],
|
|
169
|
+
mcpPrompts: regFile?.mcpPrompts || [],
|
|
170
|
+
mcpResources: regFile?.mcpResources || [],
|
|
171
|
+
active: regFile?.active ?? false,
|
|
172
|
+
x402support: regFile?.x402support ?? false,
|
|
173
|
+
extras: {
|
|
174
|
+
averageScore: agent.averageScore !== null ? agent.averageScore : undefined,
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
const nextCursor = items.length === first ? String(skip + items.length) : undefined;
|
|
179
|
+
return {
|
|
180
|
+
items,
|
|
181
|
+
nextCursor,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
throw new Error(`Failed to search agents by reputation: ${error}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/core/indexer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,YAAY;IACvB,YACU,UAAsB,EACtB,cAA+B;QAD/B,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAiB;IACtC,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAgB;QAC7B,wCAAwC;QACxC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC9D,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,oDAAoD;QACpD,0CAA0C;QAC1C,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,6CAA6C,CAAC,CAAC;IACjF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,SAAuB,EAAE,EACzB,WAAmB,EAAE,EACrB,MAAe;QAEf,IAAI,CAAC,I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OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;oBACvF,eAAe,EAAE,OAAO,EAAE,eAAe,IAAI,EAAE;oBAC/C,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE;oBACnC,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE;oBACjC,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,EAAE;oBACrC,YAAY,EAAE,OAAO,EAAE,YAAY,IAAI,EAAE;oBACzC,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;oBAChC,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,KAAK;oBAC1C,MAAM,EAAE;wBACN,YAAY,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;qBAC3E;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAEpF,OAAO;gBACL,KAAK;gBACL,UAAU;aACX,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0CAA0C,KAAK,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPFS client for decentralized storage with support for multiple providers:
|
|
3
|
+
* - Local IPFS nodes (via ipfs-http-client)
|
|
4
|
+
* - Pinata IPFS pinning service
|
|
5
|
+
* - Filecoin Pin service
|
|
6
|
+
*/
|
|
7
|
+
import type { RegistrationFile } from '../models/interfaces';
|
|
8
|
+
export interface IPFSClientConfig {
|
|
9
|
+
url?: string;
|
|
10
|
+
filecoinPinEnabled?: boolean;
|
|
11
|
+
filecoinPrivateKey?: string;
|
|
12
|
+
pinataEnabled?: boolean;
|
|
13
|
+
pinataJwt?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Client for IPFS operations supporting multiple providers
|
|
17
|
+
*/
|
|
18
|
+
export declare class IPFSClient {
|
|
19
|
+
private provider;
|
|
20
|
+
private config;
|
|
21
|
+
private client?;
|
|
22
|
+
constructor(config: IPFSClientConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Initialize IPFS HTTP client (lazy, only when needed)
|
|
25
|
+
*/
|
|
26
|
+
private _ensureClient;
|
|
27
|
+
private _verifyPinataJwt;
|
|
28
|
+
/**
|
|
29
|
+
* Pin data to Pinata using v3 API
|
|
30
|
+
*/
|
|
31
|
+
private _pinToPinata;
|
|
32
|
+
/**
|
|
33
|
+
* Pin data to Filecoin Pin
|
|
34
|
+
* Note: This requires the Filecoin Pin API or CLI to be available
|
|
35
|
+
* For now, we'll throw an error directing users to use the CLI
|
|
36
|
+
*/
|
|
37
|
+
private _pinToFilecoin;
|
|
38
|
+
/**
|
|
39
|
+
* Pin data to local IPFS node
|
|
40
|
+
*/
|
|
41
|
+
private _pinToLocalIpfs;
|
|
42
|
+
/**
|
|
43
|
+
* Add data to IPFS and return CID
|
|
44
|
+
*/
|
|
45
|
+
add(data: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Add file to IPFS and return CID
|
|
48
|
+
* Note: This method works in Node.js environments. For browser, use add() with file content directly.
|
|
49
|
+
*/
|
|
50
|
+
addFile(filepath: string): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Get data from IPFS by CID
|
|
53
|
+
*/
|
|
54
|
+
get(cid: string): Promise<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Get JSON data from IPFS by CID
|
|
57
|
+
*/
|
|
58
|
+
getJson<T = Record<string, unknown>>(cid: string): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Pin a CID to local node
|
|
61
|
+
*/
|
|
62
|
+
pin(cid: string): Promise<{
|
|
63
|
+
pinned: string[];
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Unpin a CID from local node
|
|
67
|
+
*/
|
|
68
|
+
unpin(cid: string): Promise<{
|
|
69
|
+
unpinned: string[];
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Add JSON data to IPFS and return CID
|
|
73
|
+
*/
|
|
74
|
+
addJson(data: Record<string, unknown>): Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Add registration file to IPFS and return CID
|
|
77
|
+
*/
|
|
78
|
+
addRegistrationFile(registrationFile: RegistrationFile, chainId?: number, identityRegistryAddress?: string): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Get registration file from IPFS by CID
|
|
81
|
+
*/
|
|
82
|
+
getRegistrationFile(cid: string): Promise<RegistrationFile>;
|
|
83
|
+
/**
|
|
84
|
+
* Close IPFS client connection
|
|
85
|
+
*/
|
|
86
|
+
close(): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=ipfs-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs-client.d.ts","sourceRoot":"","sources":["../../src/core/ipfs-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAAC,CAAiB;gBAEpB,MAAM,EAAE,gBAAgB;IA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
|
3
|
+
* - Local IPFS nodes (via ipfs-http-client)
|
|
4
|
+
* - Pinata IPFS pinning service
|
|
5
|
+
* - Filecoin Pin service
|
|
6
|
+
*/
|
|
7
|
+
import { IPFS_GATEWAYS, TIMEOUTS } from '../utils/constants';
|
|
8
|
+
/**
|
|
9
|
+
* Client for IPFS operations supporting multiple providers
|
|
10
|
+
*/
|
|
11
|
+
export class IPFSClient {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
// Determine provider
|
|
15
|
+
if (config.pinataEnabled) {
|
|
16
|
+
this.provider = 'pinata';
|
|
17
|
+
this._verifyPinataJwt();
|
|
18
|
+
}
|
|
19
|
+
else if (config.filecoinPinEnabled) {
|
|
20
|
+
this.provider = 'filecoinPin';
|
|
21
|
+
// Note: Filecoin Pin in TypeScript requires external CLI or API
|
|
22
|
+
// We'll use HTTP API if available, otherwise throw error
|
|
23
|
+
}
|
|
24
|
+
else if (config.url) {
|
|
25
|
+
this.provider = 'node';
|
|
26
|
+
// Lazy initialization - client will be created on first use
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error('No IPFS provider configured. Specify url, pinataEnabled, or filecoinPinEnabled.');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Initialize IPFS HTTP client (lazy, only when needed)
|
|
34
|
+
*/
|
|
35
|
+
async _ensureClient() {
|
|
36
|
+
if (this.provider === 'node' && !this.client && this.config.url) {
|
|
37
|
+
const { create } = await import('ipfs-http-client');
|
|
38
|
+
this.client = create({ url: this.config.url });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
_verifyPinataJwt() {
|
|
42
|
+
if (!this.config.pinataJwt) {
|
|
43
|
+
throw new Error('pinataJwt is required when pinataEnabled=true');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Pin data to Pinata using v3 API
|
|
48
|
+
*/
|
|
49
|
+
async _pinToPinata(data) {
|
|
50
|
+
const url = 'https://uploads.pinata.cloud/v3/files';
|
|
51
|
+
const headers = {
|
|
52
|
+
Authorization: `Bearer ${this.config.pinataJwt}`,
|
|
53
|
+
};
|
|
54
|
+
// Create a Blob from the data
|
|
55
|
+
const blob = new Blob([data], { type: 'application/json' });
|
|
56
|
+
const formData = new FormData();
|
|
57
|
+
formData.append('file', blob, 'registration.json');
|
|
58
|
+
formData.append('network', 'public');
|
|
59
|
+
try {
|
|
60
|
+
// Add timeout to fetch
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
const timeoutId = setTimeout(() => controller.abort(), TIMEOUTS.PINATA_UPLOAD);
|
|
63
|
+
const response = await fetch(url, {
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers,
|
|
66
|
+
body: formData,
|
|
67
|
+
signal: controller.signal,
|
|
68
|
+
});
|
|
69
|
+
clearTimeout(timeoutId);
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const errorText = await response.text();
|
|
72
|
+
throw new Error(`Failed to pin to Pinata: HTTP ${response.status} - ${errorText}`);
|
|
73
|
+
}
|
|
74
|
+
const result = await response.json();
|
|
75
|
+
// v3 API returns CID in data.cid
|
|
76
|
+
const cid = result?.data?.cid || result?.cid || result?.IpfsHash;
|
|
77
|
+
if (!cid) {
|
|
78
|
+
throw new Error(`No CID returned from Pinata. Response: ${JSON.stringify(result)}`);
|
|
79
|
+
}
|
|
80
|
+
return cid;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
84
|
+
throw new Error(`Pinata upload timed out after ${TIMEOUTS.PINATA_UPLOAD / 1000} seconds`);
|
|
85
|
+
}
|
|
86
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
87
|
+
throw new Error(`Failed to pin to Pinata: ${errorMessage}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Pin data to Filecoin Pin
|
|
92
|
+
* Note: This requires the Filecoin Pin API or CLI to be available
|
|
93
|
+
* For now, we'll throw an error directing users to use the CLI
|
|
94
|
+
*/
|
|
95
|
+
async _pinToFilecoin(data) {
|
|
96
|
+
// Filecoin Pin typically requires CLI or API access
|
|
97
|
+
// This is a placeholder - in production, you'd call the Filecoin Pin API
|
|
98
|
+
throw new Error('Filecoin Pin via TypeScript SDK not yet fully implemented. ' +
|
|
99
|
+
'Please use the filecoin-pin CLI or implement the Filecoin Pin API integration.');
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Pin data to local IPFS node
|
|
103
|
+
*/
|
|
104
|
+
async _pinToLocalIpfs(data) {
|
|
105
|
+
await this._ensureClient();
|
|
106
|
+
if (!this.client) {
|
|
107
|
+
throw new Error('No IPFS client available');
|
|
108
|
+
}
|
|
109
|
+
const result = await this.client.add(data);
|
|
110
|
+
return result.cid.toString();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Add data to IPFS and return CID
|
|
114
|
+
*/
|
|
115
|
+
async add(data) {
|
|
116
|
+
try {
|
|
117
|
+
if (this.provider === 'pinata') {
|
|
118
|
+
return await this._pinToPinata(data);
|
|
119
|
+
}
|
|
120
|
+
else if (this.provider === 'filecoinPin') {
|
|
121
|
+
return await this._pinToFilecoin(data);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return await this._pinToLocalIpfs(data);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Add file to IPFS and return CID
|
|
133
|
+
* Note: This method works in Node.js environments. For browser, use add() with file content directly.
|
|
134
|
+
*/
|
|
135
|
+
async addFile(filepath) {
|
|
136
|
+
// Check if we're in Node.js environment
|
|
137
|
+
if (typeof process === 'undefined' || !process.versions?.node) {
|
|
138
|
+
throw new Error('addFile() is only available in Node.js environments. ' +
|
|
139
|
+
'For browser environments, use add() with file content directly.');
|
|
140
|
+
}
|
|
141
|
+
const fs = await import('fs');
|
|
142
|
+
const data = fs.readFileSync(filepath, 'utf-8');
|
|
143
|
+
if (this.provider === 'pinata') {
|
|
144
|
+
return this._pinToPinata(data);
|
|
145
|
+
}
|
|
146
|
+
else if (this.provider === 'filecoinPin') {
|
|
147
|
+
return this._pinToFilecoin(filepath);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
await this._ensureClient();
|
|
151
|
+
if (!this.client) {
|
|
152
|
+
throw new Error('No IPFS client available');
|
|
153
|
+
}
|
|
154
|
+
// For local IPFS, add file directly
|
|
155
|
+
const fileContent = fs.readFileSync(filepath);
|
|
156
|
+
const result = await this.client.add(fileContent);
|
|
157
|
+
return result.cid.toString();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get data from IPFS by CID
|
|
162
|
+
*/
|
|
163
|
+
async get(cid) {
|
|
164
|
+
// Extract CID from IPFS URL if needed
|
|
165
|
+
if (cid.startsWith('ipfs://')) {
|
|
166
|
+
cid = cid.slice(7); // Remove "ipfs://" prefix
|
|
167
|
+
}
|
|
168
|
+
// For Pinata and Filecoin Pin, use IPFS gateways
|
|
169
|
+
if (this.provider === 'pinata' || this.provider === 'filecoinPin') {
|
|
170
|
+
const gateways = IPFS_GATEWAYS.map(gateway => `${gateway}${cid}`);
|
|
171
|
+
// Try all gateways in parallel - use the first successful response
|
|
172
|
+
const promises = gateways.map(async (gateway) => {
|
|
173
|
+
try {
|
|
174
|
+
const response = await fetch(gateway, {
|
|
175
|
+
signal: AbortSignal.timeout(TIMEOUTS.IPFS_GATEWAY),
|
|
176
|
+
});
|
|
177
|
+
if (response.ok) {
|
|
178
|
+
return await response.text();
|
|
179
|
+
}
|
|
180
|
+
throw new Error(`HTTP ${response.status}`);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
// Use Promise.allSettled to get the first successful result
|
|
187
|
+
const results = await Promise.allSettled(promises);
|
|
188
|
+
for (const result of results) {
|
|
189
|
+
if (result.status === 'fulfilled') {
|
|
190
|
+
return result.value;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
throw new Error('Failed to retrieve data from all IPFS gateways');
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
await this._ensureClient();
|
|
197
|
+
if (!this.client) {
|
|
198
|
+
throw new Error('No IPFS client available');
|
|
199
|
+
}
|
|
200
|
+
const chunks = [];
|
|
201
|
+
for await (const chunk of this.client.cat(cid)) {
|
|
202
|
+
chunks.push(chunk);
|
|
203
|
+
}
|
|
204
|
+
// Concatenate chunks and convert to string
|
|
205
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
206
|
+
const result = new Uint8Array(totalLength);
|
|
207
|
+
let offset = 0;
|
|
208
|
+
for (const chunk of chunks) {
|
|
209
|
+
result.set(chunk, offset);
|
|
210
|
+
offset += chunk.length;
|
|
211
|
+
}
|
|
212
|
+
return new TextDecoder().decode(result);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get JSON data from IPFS by CID
|
|
217
|
+
*/
|
|
218
|
+
async getJson(cid) {
|
|
219
|
+
const data = await this.get(cid);
|
|
220
|
+
return JSON.parse(data);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Pin a CID to local node
|
|
224
|
+
*/
|
|
225
|
+
async pin(cid) {
|
|
226
|
+
if (this.provider === 'filecoinPin') {
|
|
227
|
+
// Filecoin Pin automatically pins data, so this is a no-op
|
|
228
|
+
return { pinned: [cid] };
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
await this._ensureClient();
|
|
232
|
+
if (!this.client) {
|
|
233
|
+
throw new Error('No IPFS client available');
|
|
234
|
+
}
|
|
235
|
+
await this.client.pin.add(cid);
|
|
236
|
+
return { pinned: [cid] };
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Unpin a CID from local node
|
|
241
|
+
*/
|
|
242
|
+
async unpin(cid) {
|
|
243
|
+
if (this.provider === 'filecoinPin') {
|
|
244
|
+
// Filecoin Pin doesn't support unpinning in the same way
|
|
245
|
+
return { unpinned: [cid] };
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
await this._ensureClient();
|
|
249
|
+
if (!this.client) {
|
|
250
|
+
throw new Error('No IPFS client available');
|
|
251
|
+
}
|
|
252
|
+
await this.client.pin.rm(cid);
|
|
253
|
+
return { unpinned: [cid] };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Add JSON data to IPFS and return CID
|
|
258
|
+
*/
|
|
259
|
+
async addJson(data) {
|
|
260
|
+
const jsonStr = JSON.stringify(data, null, 2);
|
|
261
|
+
return this.add(jsonStr);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Add registration file to IPFS and return CID
|
|
265
|
+
*/
|
|
266
|
+
async addRegistrationFile(registrationFile, chainId, identityRegistryAddress) {
|
|
267
|
+
// Convert from internal format { type, value, meta } to ERC-8004 format { name, endpoint, version }
|
|
268
|
+
const endpoints = [];
|
|
269
|
+
for (const ep of registrationFile.endpoints) {
|
|
270
|
+
const endpointDict = {
|
|
271
|
+
name: ep.type, // EndpointType enum value (e.g., "MCP", "A2A")
|
|
272
|
+
endpoint: ep.value,
|
|
273
|
+
};
|
|
274
|
+
// Spread meta fields (version, mcpTools, mcpPrompts, etc.) into the endpoint dict
|
|
275
|
+
if (ep.meta) {
|
|
276
|
+
Object.assign(endpointDict, ep.meta);
|
|
277
|
+
}
|
|
278
|
+
endpoints.push(endpointDict);
|
|
279
|
+
}
|
|
280
|
+
// Add walletAddress as an endpoint if present
|
|
281
|
+
if (registrationFile.walletAddress) {
|
|
282
|
+
const walletChainId = registrationFile.walletChainId || chainId || 1;
|
|
283
|
+
endpoints.push({
|
|
284
|
+
name: 'agentWallet',
|
|
285
|
+
endpoint: `eip155:${walletChainId}:${registrationFile.walletAddress}`,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
// Build registrations array
|
|
289
|
+
const registrations = [];
|
|
290
|
+
if (registrationFile.agentId) {
|
|
291
|
+
const [, , tokenId] = registrationFile.agentId.split(':');
|
|
292
|
+
const agentRegistry = chainId && identityRegistryAddress
|
|
293
|
+
? `eip155:${chainId}:${identityRegistryAddress}`
|
|
294
|
+
: `eip155:1:{identityRegistry}`;
|
|
295
|
+
registrations.push({
|
|
296
|
+
agentId: parseInt(tokenId, 10),
|
|
297
|
+
agentRegistry,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
// Build ERC-8004 compliant registration file
|
|
301
|
+
const data = {
|
|
302
|
+
type: 'https://eips.ethereum.org/EIPS/eip-8004#registration-v1',
|
|
303
|
+
name: registrationFile.name,
|
|
304
|
+
description: registrationFile.description,
|
|
305
|
+
...(registrationFile.image && { image: registrationFile.image }),
|
|
306
|
+
endpoints,
|
|
307
|
+
...(registrations.length > 0 && { registrations }),
|
|
308
|
+
...(registrationFile.trustModels.length > 0 && {
|
|
309
|
+
supportedTrusts: registrationFile.trustModels,
|
|
310
|
+
}),
|
|
311
|
+
active: registrationFile.active,
|
|
312
|
+
x402support: registrationFile.x402support,
|
|
313
|
+
};
|
|
314
|
+
return this.addJson(data);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Get registration file from IPFS by CID
|
|
318
|
+
*/
|
|
319
|
+
async getRegistrationFile(cid) {
|
|
320
|
+
const data = await this.getJson(cid);
|
|
321
|
+
return data;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Close IPFS client connection
|
|
325
|
+
*/
|
|
326
|
+
async close() {
|
|
327
|
+
if (this.client) {
|
|
328
|
+
// IPFS HTTP client doesn't have a close method in the same way
|
|
329
|
+
// But we can clear the reference
|
|
330
|
+
this.client = undefined;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|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