@ghostspeak/sdk 2.0.6 → 2.0.7
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 +152 -30
- package/dist/GhostSpeakClient-CWmGaM9Q.d.ts +1007 -0
- package/dist/StakingModule-C5rzuOWb.d.ts +2526 -0
- package/dist/{agent-M74TCRON.js → agent-5YLZ7DAC.js} +4 -4
- package/dist/{agent-M74TCRON.js.map → agent-5YLZ7DAC.js.map} +1 -1
- package/dist/batch-operations-45CQFEID.js +4 -0
- package/dist/batch-operations-45CQFEID.js.map +1 -0
- package/dist/browser.d.ts +45 -554
- package/dist/browser.js +15 -842
- package/dist/browser.js.map +1 -1
- package/dist/chunk-AL3HQN73.js +754 -0
- package/dist/chunk-AL3HQN73.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-C5CDA3WX.js +7314 -0
- package/dist/chunk-C5CDA3WX.js.map +1 -0
- package/dist/chunk-E3FD2CNY.js +1869 -0
- package/dist/chunk-E3FD2CNY.js.map +1 -0
- package/dist/{chunk-F3DZMBUA.js → chunk-G7S6B6WB.js} +327 -493
- package/dist/chunk-G7S6B6WB.js.map +1 -0
- package/dist/chunk-IHVDQ4YI.js +4231 -0
- package/dist/chunk-IHVDQ4YI.js.map +1 -0
- package/dist/chunk-JV2SWONF.js +98 -0
- package/dist/chunk-JV2SWONF.js.map +1 -0
- package/dist/chunk-KB6CKIUK.js +231 -0
- package/dist/chunk-KB6CKIUK.js.map +1 -0
- package/dist/chunk-S74EH3KD.js +7890 -0
- package/dist/chunk-S74EH3KD.js.map +1 -0
- package/dist/chunk-SFTSZ3LC.js +156 -0
- package/dist/chunk-SFTSZ3LC.js.map +1 -0
- package/dist/chunk-SKMJJ3Q6.js +125 -0
- package/dist/chunk-SKMJJ3Q6.js.map +1 -0
- package/dist/chunk-SZGFSCNU.js +3682 -0
- package/dist/chunk-SZGFSCNU.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 +5 -4
- package/dist/client.js +11 -10
- package/dist/createAgentAuthorization-ULG47ZJI.js +5 -0
- package/dist/createAgentAuthorization-ULG47ZJI.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-EG5USUFG.js +9 -0
- package/dist/{generated-VNLHMR6Y.js.map → generated-EG5USUFG.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 +1209 -1506
- package/dist/index.js +600 -3532
- package/dist/index.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/minimal/core-minimal.d.ts +2383 -1264
- 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-OK7E7OK3.js +5 -0
- package/dist/revokeAuthorization-OK7E7OK3.js.map +1 -0
- package/dist/signature-verification-DGxR4aYQ.d.ts +448 -0
- package/dist/types.js +1 -1
- package/dist/updateReputationWithAuth-Y4ONEVSP.js +5 -0
- package/dist/updateReputationWithAuth-Y4ONEVSP.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 +24 -31
- 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,61 @@ 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. Analytics & Monitoring**
|
|
266
378
|
```typescript
|
|
267
379
|
// Collect real-time analytics
|
|
268
380
|
const analytics = await client.analytics.collectAllMetrics()
|
|
269
381
|
|
|
270
|
-
// Generate performance reports
|
|
382
|
+
// Generate performance reports
|
|
271
383
|
const report = await client.analytics.generateReport({
|
|
272
384
|
agentId: agentAddress,
|
|
273
385
|
timeRange: { start: startDate, end: endDate },
|
|
@@ -278,7 +390,7 @@ const report = await client.analytics.generateReport({
|
|
|
278
390
|
const exportData = await client.analytics.exportForDashboard('grafana')
|
|
279
391
|
```
|
|
280
392
|
|
|
281
|
-
### **
|
|
393
|
+
### **10. Privacy Features (Production)**
|
|
282
394
|
|
|
283
395
|
> 🔒 **Privacy**: Client-side ElGamal encryption is the standard for confidential transfers in GhostSpeak. It provides robust privacy verification via the x402 payment layer.
|
|
284
396
|
|
|
@@ -525,7 +637,10 @@ const client = new GhostSpeakClient({
|
|
|
525
637
|
### **Core Classes**
|
|
526
638
|
- **`GhostSpeakClient`** - Main SDK client
|
|
527
639
|
- **`AgentInstructions`** - Agent management operations
|
|
528
|
-
- **`
|
|
640
|
+
- **`DidModule`** - W3C DID document management 🆕
|
|
641
|
+
- **`ReputationModule`** - Reputation calculation and tag management 🆕
|
|
642
|
+
- **`AuthorizationModule`** - Pre-signed authorizations for facilitators 🆕
|
|
643
|
+
- **`MarketplaceInstructions`** - Marketplace operations
|
|
529
644
|
- **`EscrowInstructions`** - Escrow and payment operations
|
|
530
645
|
- **`GovernanceInstructions`** - Governance and multisig operations
|
|
531
646
|
- **`Token2022Instructions`** - Token-2022 operations
|
|
@@ -536,6 +651,13 @@ The SDK exports comprehensive TypeScript types for all operations:
|
|
|
536
651
|
```typescript
|
|
537
652
|
import type {
|
|
538
653
|
Agent,
|
|
654
|
+
DidDocument,
|
|
655
|
+
VerificationMethod,
|
|
656
|
+
ServiceEndpoint,
|
|
657
|
+
TagScore,
|
|
658
|
+
ReputationMetrics,
|
|
659
|
+
ReputationAuthorization,
|
|
660
|
+
OnChainStorageConfig,
|
|
539
661
|
ServiceListing,
|
|
540
662
|
EscrowAccount,
|
|
541
663
|
GovernanceProposal,
|