@ghostspeak/sdk 2.0.6 → 2.0.8
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 +295 -30
- package/dist/GhostSpeakClient-bnXwUPHI.d.ts +1011 -0
- package/dist/StakingModule-DunDShLq.d.ts +2446 -0
- package/dist/{agent-M74TCRON.js → agent-S42FIMR7.js} +4 -4
- package/dist/{agent-M74TCRON.js.map → agent-S42FIMR7.js.map} +1 -1
- package/dist/batch-operations-45CQFEID.js +4 -0
- package/dist/batch-operations-45CQFEID.js.map +1 -0
- package/dist/browser-CI5_6Gzk.d.ts +234 -0
- package/dist/browser.d.ts +6 -576
- package/dist/browser.js +15 -842
- package/dist/browser.js.map +1 -1
- package/dist/chunk-46QWY3MG.js +156 -0
- package/dist/chunk-46QWY3MG.js.map +1 -0
- package/dist/{chunk-F3DZMBUA.js → chunk-5QBSC4T4.js} +327 -493
- package/dist/chunk-5QBSC4T4.js.map +1 -0
- package/dist/chunk-5QZVFUXB.js +4176 -0
- package/dist/chunk-5QZVFUXB.js.map +1 -0
- package/dist/chunk-6XCCMJ6M.js +1865 -0
- package/dist/chunk-6XCCMJ6M.js.map +1 -0
- package/dist/chunk-A7ALCVUI.js +98 -0
- package/dist/chunk-A7ALCVUI.js.map +1 -0
- package/dist/chunk-AWMGX3OX.js +814 -0
- package/dist/chunk-AWMGX3OX.js.map +1 -0
- package/dist/chunk-BF3IQ35I.js +284 -0
- package/dist/chunk-BF3IQ35I.js.map +1 -0
- package/dist/chunk-BQDGRTVP.js +168 -0
- package/dist/chunk-BQDGRTVP.js.map +1 -0
- package/dist/chunk-IQM5RASO.js +8502 -0
- package/dist/chunk-IQM5RASO.js.map +1 -0
- package/dist/chunk-JYXSOXCP.js +3850 -0
- package/dist/chunk-JYXSOXCP.js.map +1 -0
- package/dist/chunk-OXA7MECJ.js +7787 -0
- package/dist/chunk-OXA7MECJ.js.map +1 -0
- package/dist/chunk-QLRWUHN2.js +231 -0
- package/dist/chunk-QLRWUHN2.js.map +1 -0
- package/dist/chunk-SKMJJ3Q6.js +125 -0
- package/dist/chunk-SKMJJ3Q6.js.map +1 -0
- package/dist/chunk-TTB4OS2D.js +69 -0
- package/dist/chunk-TTB4OS2D.js.map +1 -0
- package/dist/chunk-UP2VWCW5.js +33 -0
- package/dist/{chunk-NSBPE2FW.js.map → chunk-UP2VWCW5.js.map} +1 -1
- package/dist/{chunk-UJUGGLMT.js → chunk-VQZQCHUT.js} +5 -5
- package/dist/{chunk-UJUGGLMT.js.map → chunk-VQZQCHUT.js.map} +1 -1
- package/dist/client.d.ts +4 -4
- package/dist/client.js +11 -10
- package/dist/createAgentAuthorization-KGZNXZBT.js +5 -0
- package/dist/createAgentAuthorization-KGZNXZBT.js.map +1 -0
- package/dist/credentials.js +1 -1
- package/dist/crypto.js +2 -2
- package/dist/errors.js +1 -1
- package/dist/feature-flags-B1g0DCPe.d.ts +1181 -0
- package/dist/generated-QJREJQ2C.js +9 -0
- package/dist/{generated-VNLHMR6Y.js.map → generated-QJREJQ2C.js.map} +1 -1
- package/dist/{ghostspeak_wasm-SB2RPJ3D.js → ghostspeak_wasm-F227HOSM.js} +3 -3
- package/dist/{ghostspeak_wasm-SB2RPJ3D.js.map → ghostspeak_wasm-F227HOSM.js.map} +1 -1
- package/dist/index.d.ts +1179 -1498
- package/dist/index.js +356 -3578
- package/dist/index.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/minimal/core-minimal.d.ts +2446 -1245
- package/dist/minimal/core-minimal.js +9 -9
- package/dist/minimal/core-minimal.js.map +1 -1
- package/dist/nacl-fast-W5BJ3KZ2.js +2229 -0
- package/dist/nacl-fast-W5BJ3KZ2.js.map +1 -0
- package/dist/pda-4KP7CURF.js +4 -0
- package/dist/pda-4KP7CURF.js.map +1 -0
- package/dist/pda-Ce7VYg4T.d.ts +25 -0
- package/dist/reputation-types-Yebf0Rm_.d.ts +1071 -0
- package/dist/revokeAuthorization-2ZRO6GUZ.js +5 -0
- package/dist/revokeAuthorization-2ZRO6GUZ.js.map +1 -0
- package/dist/signature-verification-DGxR4aYQ.d.ts +448 -0
- package/dist/types.js +1 -1
- package/dist/updateReputationWithAuth-PCEUOCFV.js +5 -0
- package/dist/updateReputationWithAuth-PCEUOCFV.js.map +1 -0
- package/dist/utils.d.ts +69 -203
- package/dist/utils.js +15 -153
- package/dist/utils.js.map +1 -1
- package/package.json +27 -34
- package/dist/.tsbuildinfo +0 -1
- package/dist/GhostSpeakClient-D_66Uzsf.d.ts +0 -707
- package/dist/GovernanceModule-DQYYys-H.d.ts +0 -1766
- package/dist/chunk-APCKGD23.js +0 -1328
- package/dist/chunk-APCKGD23.js.map +0 -1
- package/dist/chunk-ASQXX4IT.js +0 -572
- package/dist/chunk-ASQXX4IT.js.map +0 -1
- package/dist/chunk-COGZFWOT.js +0 -19657
- package/dist/chunk-COGZFWOT.js.map +0 -1
- package/dist/chunk-F3DZMBUA.js.map +0 -1
- package/dist/chunk-GMHIUK2R.js +0 -7526
- package/dist/chunk-GMHIUK2R.js.map +0 -1
- package/dist/chunk-IAWBZYPE.js +0 -356
- package/dist/chunk-IAWBZYPE.js.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-OWYHJG6H.js +0 -13311
- package/dist/chunk-OWYHJG6H.js.map +0 -1
- package/dist/chunk-RDDPOFR5.js +0 -3
- package/dist/chunk-RDDPOFR5.js.map +0 -1
- package/dist/chunk-RERCHKZP.js +0 -35
- package/dist/chunk-RERCHKZP.js.map +0 -1
- package/dist/chunk-TVVGXYCI.js +0 -2887
- package/dist/chunk-TVVGXYCI.js.map +0 -1
- package/dist/chunk-ZGP5552B.js +0 -377
- package/dist/chunk-ZGP5552B.js.map +0 -1
- package/dist/chunk-ZWOYNHVK.js +0 -196
- package/dist/chunk-ZWOYNHVK.js.map +0 -1
- package/dist/dist/.tsbuildinfo +0 -1
- package/dist/elgamal-VZLWB3XK.js +0 -5
- package/dist/elgamal-VZLWB3XK.js.map +0 -1
- package/dist/feature-flags-V722ZuXO.d.ts +0 -3512
- package/dist/generated-VNLHMR6Y.js +0 -5
- package/dist/ipfs-types-BOt9ZNg4.d.ts +0 -592
- package/dist/multisigConfig-BzEhy6jy.d.ts +0 -58
- package/dist/pda-B_nS8SbD.d.ts +0 -114
- package/dist/pda-S4BFJVGE.js +0 -4
- package/dist/pda-S4BFJVGE.js.map +0 -1
- package/dist/system-addresses-BFNLEbFx.d.ts +0 -857
- package/dist/token-2022-rpc-RALH4RK7.js +0 -593
- package/dist/token-2022-rpc-RALH4RK7.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,28 +6,41 @@
|
|
|
6
6
|
[](https://solana.com)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
The official TypeScript SDK for [GhostSpeak Protocol](https://github.com/ghostspeak/ghostspeak) - a
|
|
9
|
+
The official TypeScript SDK for [GhostSpeak Protocol](https://github.com/ghostspeak/ghostspeak) - a decentralized **Verifiable Credentials (VC)**, **Reputation**, and **Identity Layer** for AI agents on Solana. Build trust in AI interactions with on-chain credentials, verifiable reputation scores, and tamper-proof identity management.
|
|
10
10
|
|
|
11
11
|
## 🌟 **Features**
|
|
12
12
|
|
|
13
|
-
###
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
### **🔐 Identity & Credentials**
|
|
14
|
+
- **On-Chain Agent Identity** - Immutable agent registration on Solana
|
|
15
|
+
- **Verifiable Credentials** - Issue W3C-compliant credentials for AI agents
|
|
16
|
+
- **Credential Verification** - Cryptographically verify agent credentials
|
|
17
|
+
- **Multi-Level Verification** - Basic, Verified, and Elite trust levels
|
|
18
|
+
- **W3C DID Support** - Full Decentralized Identifier (DID) implementation 🆕
|
|
19
|
+
- **Cross-Chain DIDs** - Export DIDs to W3C format for multi-chain verification 🆕
|
|
20
|
+
|
|
21
|
+
### **⭐ Reputation System**
|
|
22
|
+
- **Ghost Score** - Comprehensive reputation algorithm (0-1000)
|
|
23
|
+
- **On-Chain Reputation** - Tamper-proof reputation tracking
|
|
24
|
+
- **Multi-Factor Scoring** - Credentials, transactions, verification, staking
|
|
25
|
+
- **Reputation Decay** - Time-based decay for inactive agents
|
|
26
|
+
- **Granular Tags** - 80+ automatic tags with confidence scoring 🆕
|
|
27
|
+
- **Multi-Source Aggregation** - Combine reputation from PayAI, GitHub, and custom sources 🆕
|
|
28
|
+
- **Conflict Detection** - Automatic detection of conflicting reputation data 🆕
|
|
29
|
+
|
|
30
|
+
### **🔐 Authorization System** 🆕
|
|
31
|
+
- **Pre-Signed Authorizations** - Agents pre-authorize facilitators (e.g., PayAI) for reputation updates
|
|
32
|
+
- **Off-Chain by Default** - FREE signature-based authorizations with no blockchain fees
|
|
33
|
+
- **Optional On-Chain Storage** - Immutable audit trail for ~0.002 SOL (configurable)
|
|
34
|
+
- **Flexible Fee Structures** - Default, custom, and tiered pricing models
|
|
35
|
+
- **Usage Limits** - Built-in index limits and expiration for security
|
|
36
|
+
- **Cost Estimation** - Calculate fees before transactions
|
|
37
|
+
- **Facilitator Integration** - Seamless PayAI and X402 protocol support
|
|
38
|
+
|
|
39
|
+
### **🎫 Credential Management**
|
|
40
|
+
- **Issue Credentials** - Grant verifiable credentials to agents
|
|
41
|
+
- **Revoke Credentials** - Remove invalid or expired credentials
|
|
42
|
+
- **Credential Types** - KYC, service-specific, performance-based
|
|
43
|
+
- **Batch Operations** - Issue multiple credentials efficiently
|
|
31
44
|
|
|
32
45
|
### **🛠️ Developer Experience**
|
|
33
46
|
- **Full Type Safety** - 100% TypeScript with comprehensive types
|
|
@@ -76,18 +89,59 @@ import { generateKeyPairSigner } from '@solana/signers'
|
|
|
76
89
|
// Create agent signer
|
|
77
90
|
const agent = await generateKeyPairSigner()
|
|
78
91
|
|
|
79
|
-
// Register agent on-chain
|
|
92
|
+
// Register agent on-chain with identity
|
|
80
93
|
const signature = await client.agents.register(agent, {
|
|
81
|
-
agentId: 1n,
|
|
82
94
|
name: "My AI Assistant",
|
|
83
95
|
description: "Specialized in data analysis and report generation",
|
|
84
96
|
capabilities: ["data-analysis", "report-generation", "text-processing"],
|
|
85
|
-
serviceEndpoint: "https://my-agent.example.com/api"
|
|
97
|
+
serviceEndpoint: "https://my-agent.example.com/api",
|
|
98
|
+
metadata: {
|
|
99
|
+
version: "1.0.0",
|
|
100
|
+
model: "GPT-4",
|
|
101
|
+
provider: "OpenAI"
|
|
102
|
+
}
|
|
86
103
|
})
|
|
87
104
|
|
|
88
105
|
console.log(`Agent registered! Signature: ${signature}`)
|
|
89
106
|
```
|
|
90
107
|
|
|
108
|
+
### **Issue a Verifiable Credential**
|
|
109
|
+
```typescript
|
|
110
|
+
// Issue a credential to an agent
|
|
111
|
+
const credentialSignature = await client.credentials.issueCredential(issuer, {
|
|
112
|
+
agentAddress: agent.address,
|
|
113
|
+
credentialType: "KYC_VERIFIED",
|
|
114
|
+
issuer: issuer.address,
|
|
115
|
+
issuanceDate: Date.now(),
|
|
116
|
+
expirationDate: Date.now() + (365 * 24 * 60 * 60 * 1000), // 1 year
|
|
117
|
+
metadata: {
|
|
118
|
+
verificationType: "identity",
|
|
119
|
+
verificationLevel: "advanced"
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
console.log(`Credential issued! Signature: ${credentialSignature}`)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### **Calculate Ghost Score (Reputation)**
|
|
127
|
+
```typescript
|
|
128
|
+
// Get comprehensive reputation score
|
|
129
|
+
const reputation = await client.reputation.getAgentReputation(agent.address)
|
|
130
|
+
|
|
131
|
+
console.log(`Ghost Score: ${reputation.ghostScore}/1000`)
|
|
132
|
+
console.log(`Breakdown:`)
|
|
133
|
+
console.log(`- Credentials: ${reputation.components.credentialScore}`)
|
|
134
|
+
console.log(`- Transactions: ${reputation.components.transactionScore}`)
|
|
135
|
+
console.log(`- Verification: ${reputation.components.verificationScore}`)
|
|
136
|
+
console.log(`- Staking: ${reputation.components.stakingScore}`)
|
|
137
|
+
|
|
138
|
+
// Get automatic reputation tags
|
|
139
|
+
const metrics = await client.reputation.convertMetricsForTagging(onChainMetrics)
|
|
140
|
+
const tags = await client.reputation.calculateTagsForAgent(metrics)
|
|
141
|
+
|
|
142
|
+
console.log(`Tags: ${tags.map(t => t.tagName).join(', ')}`)
|
|
143
|
+
```
|
|
144
|
+
|
|
91
145
|
### **Create a Service Listing**
|
|
92
146
|
```typescript
|
|
93
147
|
// List your agent's services
|
|
@@ -128,21 +182,30 @@ await client.escrow.completeMilestone(agent, escrowSignature, 0)
|
|
|
128
182
|
|
|
129
183
|
## 📚 **Core SDK Components**
|
|
130
184
|
|
|
131
|
-
### **1. Agent Management**
|
|
185
|
+
### **1. Agent Management & DIDs**
|
|
132
186
|
```typescript
|
|
133
187
|
// Register new agent
|
|
134
188
|
await client.agents.register(signer, params)
|
|
135
189
|
|
|
136
|
-
//
|
|
190
|
+
// Create DID for agent (W3C-compliant)
|
|
191
|
+
await client.did.create(signer, {
|
|
192
|
+
controller: signer.address,
|
|
193
|
+
network: 'devnet'
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
// Export DID to W3C format for cross-chain use
|
|
197
|
+
const w3cDid = await client.did.exportW3C(signer.address)
|
|
198
|
+
|
|
199
|
+
// Update agent information
|
|
137
200
|
await client.agents.update(signer, agentPda, updateParams)
|
|
138
201
|
|
|
139
202
|
// Get agent details
|
|
140
203
|
const agent = await client.agents.getAgent(agentAddress)
|
|
141
204
|
|
|
142
205
|
// List all agents with filtering
|
|
143
|
-
const agents = await client.agents.listAgents({
|
|
206
|
+
const agents = await client.agents.listAgents({
|
|
144
207
|
verificationStatus: 'verified',
|
|
145
|
-
category: 'ai-assistant'
|
|
208
|
+
category: 'ai-assistant'
|
|
146
209
|
})
|
|
147
210
|
```
|
|
148
211
|
|
|
@@ -262,12 +325,204 @@ await client.token2022.confidentialTransfer(sender, {
|
|
|
262
325
|
})
|
|
263
326
|
```
|
|
264
327
|
|
|
265
|
-
### **8.
|
|
328
|
+
### **8. Authorization System (PayAI Integration)** 🆕
|
|
329
|
+
|
|
330
|
+
Pre-authorize facilitators to update your agent's reputation with built-in security limits.
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
// Create off-chain authorization (FREE)
|
|
334
|
+
const authorization = await client.authorization.createAuthorization({
|
|
335
|
+
authorizedSource: payAIFacilitatorAddress,
|
|
336
|
+
indexLimit: 1000, // Allow 1000 reputation updates
|
|
337
|
+
expiresIn: 30 * 24 * 60 * 60, // 30 days
|
|
338
|
+
network: 'mainnet-beta'
|
|
339
|
+
}, agentKeypair)
|
|
340
|
+
|
|
341
|
+
// Share with facilitator webhook
|
|
342
|
+
await fetch('https://payai.example.com/register-agent', {
|
|
343
|
+
method: 'POST',
|
|
344
|
+
body: JSON.stringify({
|
|
345
|
+
agentAddress: authorization.agentAddress,
|
|
346
|
+
authorization: client.authorization.serializeAuthorization(authorization)
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
// Estimate on-chain storage cost (optional)
|
|
351
|
+
const cost = await client.authorization.estimateStorageCost({
|
|
352
|
+
authorizedSource: payAIFacilitatorAddress,
|
|
353
|
+
expiresIn: 30 * 24 * 60 * 60
|
|
354
|
+
})
|
|
355
|
+
console.log(`On-chain storage: ${cost} SOL`) // 0.002 SOL
|
|
356
|
+
|
|
357
|
+
// Store on-chain for audit trail (optional, ~0.002 SOL)
|
|
358
|
+
const signature = await client.authorization.storeAuthorizationOnChain(
|
|
359
|
+
authorization,
|
|
360
|
+
agentSigner,
|
|
361
|
+
{
|
|
362
|
+
storageFee: 1500000n, // Custom: 0.0015 SOL
|
|
363
|
+
feePayedByAgent: true
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
// Verify authorization signature
|
|
368
|
+
const isValid = await client.authorization.verifySignature(authorization)
|
|
369
|
+
|
|
370
|
+
// Check authorization status
|
|
371
|
+
const status = client.authorization.getAuthorizationStatus(authorization, 0)
|
|
372
|
+
console.log(`Remaining uses: ${status.remainingUses}/${authorization.indexLimit}`)
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
**See:** [Authorization Storage Guide](./docs/AUTHORIZATION_STORAGE.md) for complete documentation.
|
|
376
|
+
|
|
377
|
+
### **9. External ID Resolution (REST API)** 🆕
|
|
378
|
+
|
|
379
|
+
Resolve cross-platform identities to Ghost addresses using the GhostSpeak Public API. Faster than on-chain lookups for read operations.
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
import { ExternalIdResolver } from '@ghostspeak/sdk'
|
|
383
|
+
|
|
384
|
+
// Initialize resolver for devnet
|
|
385
|
+
const resolver = new ExternalIdResolver({
|
|
386
|
+
cluster: 'devnet' // Uses https://api-devnet.ghostspeak.ai
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
// Production mainnet
|
|
390
|
+
const mainnetResolver = new ExternalIdResolver({
|
|
391
|
+
cluster: 'mainnet-beta' // Uses https://api.ghostspeak.ai
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
// Custom API URL
|
|
395
|
+
const customResolver = new ExternalIdResolver({
|
|
396
|
+
apiUrl: 'https://custom-api.example.com'
|
|
397
|
+
})
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
#### **Resolve External IDs to Ghost Addresses**
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
// Quick resolve - returns Ghost address
|
|
404
|
+
const ghostAddress = await resolver.resolve('payai', 'agent-123')
|
|
405
|
+
console.log(`Ghost Address: ${ghostAddress}`)
|
|
406
|
+
|
|
407
|
+
// Full lookup - returns mapping + Ghost data
|
|
408
|
+
const result = await resolver.lookup('payai', 'agent-123')
|
|
409
|
+
console.log(`Platform: ${result.mapping.platform}`)
|
|
410
|
+
console.log(`External ID: ${result.mapping.externalId}`)
|
|
411
|
+
console.log(`Ghost Address: ${result.mapping.ghostAddress}`)
|
|
412
|
+
console.log(`Verified: ${result.mapping.verified}`)
|
|
413
|
+
|
|
414
|
+
if (result.ghost) {
|
|
415
|
+
console.log(`Name: ${result.ghost.name}`)
|
|
416
|
+
console.log(`Ghost Score: ${result.ghost.ghostScore}`)
|
|
417
|
+
console.log(`Status: ${result.ghost.status}`)
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### **Fetch Ghost Data via API**
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
// Get full Ghost profile (faster than on-chain query)
|
|
425
|
+
const ghost = await resolver.getGhost(ghostAddress)
|
|
426
|
+
console.log(`Agent: ${ghost.name}`)
|
|
427
|
+
console.log(`Owner: ${ghost.owner}`)
|
|
428
|
+
console.log(`Reputation: ${ghost.reputationScore}`)
|
|
429
|
+
console.log(`External IDs:`, ghost.externalIdentifiers)
|
|
430
|
+
|
|
431
|
+
// Get Ghost Score breakdown
|
|
432
|
+
const score = await resolver.getGhostScore(ghostAddress)
|
|
433
|
+
console.log(`Score: ${score.score}/${score.maxScore}`)
|
|
434
|
+
score.components.forEach(c => {
|
|
435
|
+
console.log(`- ${c.source}: ${c.score} (weight: ${c.weight})`)
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
// Get detailed reputation data
|
|
439
|
+
const reputation = await resolver.getGhostReputation(ghostAddress)
|
|
440
|
+
console.log('Reputation breakdown:', reputation)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
#### **Batch Operations**
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
// Resolve multiple external IDs in parallel
|
|
447
|
+
const identifiers = [
|
|
448
|
+
{ platform: 'payai', externalId: 'agent-1' },
|
|
449
|
+
{ platform: 'elizaos', externalId: 'eliza-bot' },
|
|
450
|
+
{ platform: 'github', externalId: 'ai-assistant-007' }
|
|
451
|
+
]
|
|
452
|
+
|
|
453
|
+
const addresses = await resolver.resolveBatch(identifiers)
|
|
454
|
+
addresses.forEach((addr, i) => {
|
|
455
|
+
if (addr) {
|
|
456
|
+
console.log(`${identifiers[i].platform}:${identifiers[i].externalId} → ${addr}`)
|
|
457
|
+
} else {
|
|
458
|
+
console.log(`${identifiers[i].platform}:${identifiers[i].externalId} → Not found`)
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
#### **Check Existence & List External IDs**
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
// Check if external ID exists
|
|
467
|
+
const exists = await resolver.exists('payai', 'agent-123')
|
|
468
|
+
console.log(`Exists: ${exists}`)
|
|
469
|
+
|
|
470
|
+
// Get all external IDs for a Ghost
|
|
471
|
+
const externalIds = await resolver.getExternalIds(ghostAddress)
|
|
472
|
+
externalIds.forEach(id => {
|
|
473
|
+
console.log(`${id.platform}:${id.externalId} (verified: ${id.verified})`)
|
|
474
|
+
})
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
#### **API Health Check**
|
|
478
|
+
|
|
479
|
+
```typescript
|
|
480
|
+
// Check API availability and network status
|
|
481
|
+
const health = await resolver.checkHealth()
|
|
482
|
+
console.log(`Status: ${health.status}`)
|
|
483
|
+
console.log(`Network: ${health.network}`)
|
|
484
|
+
console.log(`RPC Connected: ${health.rpc.connected}`)
|
|
485
|
+
console.log(`RPC Latency: ${health.rpc.latency}ms`)
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
#### **Error Handling**
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
import {
|
|
492
|
+
ExternalIdNotFoundError,
|
|
493
|
+
GhostNotFoundError,
|
|
494
|
+
GhostSpeakError
|
|
495
|
+
} from '@ghostspeak/sdk'
|
|
496
|
+
|
|
497
|
+
try {
|
|
498
|
+
const address = await resolver.resolve('payai', 'non-existent')
|
|
499
|
+
} catch (error) {
|
|
500
|
+
if (error instanceof ExternalIdNotFoundError) {
|
|
501
|
+
console.error(`No Ghost found for ${error.platform}:${error.externalId}`)
|
|
502
|
+
} else if (error instanceof GhostNotFoundError) {
|
|
503
|
+
console.error(`Ghost not found: ${error.message}`)
|
|
504
|
+
} else if (error instanceof GhostSpeakError) {
|
|
505
|
+
console.error(`API Error [${error.code}]: ${error.message}`)
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
#### **Supported Platforms**
|
|
511
|
+
|
|
512
|
+
- `payai` - PayAI Network agents
|
|
513
|
+
- `elizaos` - ElizaOS framework agents
|
|
514
|
+
- `github` - GitHub-verified agents
|
|
515
|
+
- `twitter` - Twitter/X-verified agents
|
|
516
|
+
- Custom platforms (defined by facilitators)
|
|
517
|
+
|
|
518
|
+
**Performance:** API lookups are **10-50x faster** than on-chain queries, ideal for real-time integrations.
|
|
519
|
+
|
|
520
|
+
### **10. Analytics & Monitoring**
|
|
266
521
|
```typescript
|
|
267
522
|
// Collect real-time analytics
|
|
268
523
|
const analytics = await client.analytics.collectAllMetrics()
|
|
269
524
|
|
|
270
|
-
// Generate performance reports
|
|
525
|
+
// Generate performance reports
|
|
271
526
|
const report = await client.analytics.generateReport({
|
|
272
527
|
agentId: agentAddress,
|
|
273
528
|
timeRange: { start: startDate, end: endDate },
|
|
@@ -278,7 +533,7 @@ const report = await client.analytics.generateReport({
|
|
|
278
533
|
const exportData = await client.analytics.exportForDashboard('grafana')
|
|
279
534
|
```
|
|
280
535
|
|
|
281
|
-
### **
|
|
536
|
+
### **11. Privacy Features (Production)**
|
|
282
537
|
|
|
283
538
|
> 🔒 **Privacy**: Client-side ElGamal encryption is the standard for confidential transfers in GhostSpeak. It provides robust privacy verification via the x402 payment layer.
|
|
284
539
|
|
|
@@ -525,7 +780,10 @@ const client = new GhostSpeakClient({
|
|
|
525
780
|
### **Core Classes**
|
|
526
781
|
- **`GhostSpeakClient`** - Main SDK client
|
|
527
782
|
- **`AgentInstructions`** - Agent management operations
|
|
528
|
-
- **`
|
|
783
|
+
- **`DidModule`** - W3C DID document management 🆕
|
|
784
|
+
- **`ReputationModule`** - Reputation calculation and tag management 🆕
|
|
785
|
+
- **`AuthorizationModule`** - Pre-signed authorizations for facilitators 🆕
|
|
786
|
+
- **`MarketplaceInstructions`** - Marketplace operations
|
|
529
787
|
- **`EscrowInstructions`** - Escrow and payment operations
|
|
530
788
|
- **`GovernanceInstructions`** - Governance and multisig operations
|
|
531
789
|
- **`Token2022Instructions`** - Token-2022 operations
|
|
@@ -536,6 +794,13 @@ The SDK exports comprehensive TypeScript types for all operations:
|
|
|
536
794
|
```typescript
|
|
537
795
|
import type {
|
|
538
796
|
Agent,
|
|
797
|
+
DidDocument,
|
|
798
|
+
VerificationMethod,
|
|
799
|
+
ServiceEndpoint,
|
|
800
|
+
TagScore,
|
|
801
|
+
ReputationMetrics,
|
|
802
|
+
ReputationAuthorization,
|
|
803
|
+
OnChainStorageConfig,
|
|
539
804
|
ServiceListing,
|
|
540
805
|
EscrowAccount,
|
|
541
806
|
GovernanceProposal,
|