@ghostspeak/sdk 2.0.5 → 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.
Files changed (121) hide show
  1. package/README.md +152 -30
  2. package/dist/GhostSpeakClient-CWmGaM9Q.d.ts +1007 -0
  3. package/dist/StakingModule-C5rzuOWb.d.ts +2526 -0
  4. package/dist/{agent-M74TCRON.js → agent-5YLZ7DAC.js} +4 -4
  5. package/dist/{agent-M74TCRON.js.map → agent-5YLZ7DAC.js.map} +1 -1
  6. package/dist/batch-operations-45CQFEID.js +4 -0
  7. package/dist/batch-operations-45CQFEID.js.map +1 -0
  8. package/dist/browser.d.ts +45 -554
  9. package/dist/browser.js +15 -842
  10. package/dist/browser.js.map +1 -1
  11. package/dist/chunk-AL3HQN73.js +754 -0
  12. package/dist/chunk-AL3HQN73.js.map +1 -0
  13. package/dist/chunk-BF3IQ35I.js +284 -0
  14. package/dist/chunk-BF3IQ35I.js.map +1 -0
  15. package/dist/chunk-BQDGRTVP.js +168 -0
  16. package/dist/chunk-BQDGRTVP.js.map +1 -0
  17. package/dist/chunk-C5CDA3WX.js +7314 -0
  18. package/dist/chunk-C5CDA3WX.js.map +1 -0
  19. package/dist/chunk-E3FD2CNY.js +1869 -0
  20. package/dist/chunk-E3FD2CNY.js.map +1 -0
  21. package/dist/{chunk-V3SOFUAZ.js → chunk-G7S6B6WB.js} +327 -493
  22. package/dist/chunk-G7S6B6WB.js.map +1 -0
  23. package/dist/chunk-IHVDQ4YI.js +4231 -0
  24. package/dist/chunk-IHVDQ4YI.js.map +1 -0
  25. package/dist/chunk-JV2SWONF.js +98 -0
  26. package/dist/chunk-JV2SWONF.js.map +1 -0
  27. package/dist/chunk-KB6CKIUK.js +231 -0
  28. package/dist/chunk-KB6CKIUK.js.map +1 -0
  29. package/dist/chunk-RIZZPLLB.js +343 -0
  30. package/dist/chunk-RIZZPLLB.js.map +1 -0
  31. package/dist/chunk-S74EH3KD.js +7890 -0
  32. package/dist/chunk-S74EH3KD.js.map +1 -0
  33. package/dist/chunk-SFTSZ3LC.js +156 -0
  34. package/dist/chunk-SFTSZ3LC.js.map +1 -0
  35. package/dist/chunk-SKMJJ3Q6.js +125 -0
  36. package/dist/chunk-SKMJJ3Q6.js.map +1 -0
  37. package/dist/chunk-SZGFSCNU.js +3682 -0
  38. package/dist/chunk-SZGFSCNU.js.map +1 -0
  39. package/dist/chunk-TTB4OS2D.js +69 -0
  40. package/dist/chunk-TTB4OS2D.js.map +1 -0
  41. package/dist/chunk-UP2VWCW5.js +33 -0
  42. package/dist/{chunk-NSBPE2FW.js.map → chunk-UP2VWCW5.js.map} +1 -1
  43. package/dist/{chunk-UJUGGLMT.js → chunk-VQZQCHUT.js} +5 -5
  44. package/dist/{chunk-UJUGGLMT.js.map → chunk-VQZQCHUT.js.map} +1 -1
  45. package/dist/client.d.ts +6 -4
  46. package/dist/client.js +12 -10
  47. package/dist/createAgentAuthorization-ULG47ZJI.js +5 -0
  48. package/dist/createAgentAuthorization-ULG47ZJI.js.map +1 -0
  49. package/dist/credentials.d.ts +155 -0
  50. package/dist/credentials.js +4 -0
  51. package/dist/credentials.js.map +1 -0
  52. package/dist/crypto.js +2 -2
  53. package/dist/errors.js +1 -1
  54. package/dist/feature-flags-B1g0DCPe.d.ts +1181 -0
  55. package/dist/generated-EG5USUFG.js +9 -0
  56. package/dist/{generated-VNLHMR6Y.js.map → generated-EG5USUFG.js.map} +1 -1
  57. package/dist/{ghostspeak_wasm-SB2RPJ3D.js → ghostspeak_wasm-F227HOSM.js} +3 -3
  58. package/dist/{ghostspeak_wasm-SB2RPJ3D.js.map → ghostspeak_wasm-F227HOSM.js.map} +1 -1
  59. package/dist/index.d.ts +1210 -1506
  60. package/dist/index.js +601 -3532
  61. package/dist/index.js.map +1 -1
  62. package/dist/metafile-esm.json +1 -1
  63. package/dist/minimal/core-minimal.d.ts +2383 -1264
  64. package/dist/minimal/core-minimal.js +9 -9
  65. package/dist/minimal/core-minimal.js.map +1 -1
  66. package/dist/nacl-fast-W5BJ3KZ2.js +2229 -0
  67. package/dist/nacl-fast-W5BJ3KZ2.js.map +1 -0
  68. package/dist/pda-4KP7CURF.js +4 -0
  69. package/dist/pda-4KP7CURF.js.map +1 -0
  70. package/dist/pda-Ce7VYg4T.d.ts +25 -0
  71. package/dist/reputation-types-Yebf0Rm_.d.ts +1071 -0
  72. package/dist/revokeAuthorization-OK7E7OK3.js +5 -0
  73. package/dist/revokeAuthorization-OK7E7OK3.js.map +1 -0
  74. package/dist/signature-verification-DGxR4aYQ.d.ts +448 -0
  75. package/dist/types.js +1 -1
  76. package/dist/updateReputationWithAuth-Y4ONEVSP.js +5 -0
  77. package/dist/updateReputationWithAuth-Y4ONEVSP.js.map +1 -0
  78. package/dist/utils.d.ts +69 -203
  79. package/dist/utils.js +15 -153
  80. package/dist/utils.js.map +1 -1
  81. package/package.json +28 -31
  82. package/dist/.tsbuildinfo +0 -1
  83. package/dist/GhostSpeakClient-hsGuGg__.d.ts +0 -860
  84. package/dist/GovernanceModule-DQYYys-H.d.ts +0 -1766
  85. package/dist/chunk-ASQXX4IT.js +0 -572
  86. package/dist/chunk-ASQXX4IT.js.map +0 -1
  87. package/dist/chunk-COGZFWOT.js +0 -19657
  88. package/dist/chunk-COGZFWOT.js.map +0 -1
  89. package/dist/chunk-FKRN4PW5.js +0 -1667
  90. package/dist/chunk-FKRN4PW5.js.map +0 -1
  91. package/dist/chunk-GMHIUK2R.js +0 -7526
  92. package/dist/chunk-GMHIUK2R.js.map +0 -1
  93. package/dist/chunk-IAWBZYPE.js +0 -356
  94. package/dist/chunk-IAWBZYPE.js.map +0 -1
  95. package/dist/chunk-NSBPE2FW.js +0 -15
  96. package/dist/chunk-OWYHJG6H.js +0 -13311
  97. package/dist/chunk-OWYHJG6H.js.map +0 -1
  98. package/dist/chunk-RDDPOFR5.js +0 -3
  99. package/dist/chunk-RDDPOFR5.js.map +0 -1
  100. package/dist/chunk-RERCHKZP.js +0 -35
  101. package/dist/chunk-RERCHKZP.js.map +0 -1
  102. package/dist/chunk-TVVGXYCI.js +0 -2887
  103. package/dist/chunk-TVVGXYCI.js.map +0 -1
  104. package/dist/chunk-V3SOFUAZ.js.map +0 -1
  105. package/dist/chunk-ZGP5552B.js +0 -377
  106. package/dist/chunk-ZGP5552B.js.map +0 -1
  107. package/dist/chunk-ZWOYNHVK.js +0 -196
  108. package/dist/chunk-ZWOYNHVK.js.map +0 -1
  109. package/dist/dist/.tsbuildinfo +0 -1
  110. package/dist/elgamal-VZLWB3XK.js +0 -5
  111. package/dist/elgamal-VZLWB3XK.js.map +0 -1
  112. package/dist/feature-flags-V722ZuXO.d.ts +0 -3512
  113. package/dist/generated-VNLHMR6Y.js +0 -5
  114. package/dist/ipfs-types-BOt9ZNg4.d.ts +0 -592
  115. package/dist/multisigConfig-BzEhy6jy.d.ts +0 -58
  116. package/dist/pda-B_nS8SbD.d.ts +0 -114
  117. package/dist/pda-S4BFJVGE.js +0 -4
  118. package/dist/pda-S4BFJVGE.js.map +0 -1
  119. package/dist/system-addresses-BFNLEbFx.d.ts +0 -857
  120. package/dist/token-2022-rpc-RALH4RK7.js +0 -593
  121. package/dist/token-2022-rpc-RALH4RK7.js.map +0 -1
package/README.md CHANGED
@@ -6,28 +6,41 @@
6
6
  [![Solana](https://img.shields.io/badge/Solana-v2.3.13-9945FF.svg)](https://solana.com)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
 
9
- The official TypeScript SDK for [GhostSpeak Protocol](https://github.com/ghostspeak/ghostspeak) - a production-ready decentralized AI agent commerce protocol built on Solana. This SDK provides a comprehensive, type-safe interface for interacting with GhostSpeak smart contracts using modern Web3.js v2 patterns.
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
- ### **🤖 AI Agent Management**
14
- - **Registration & Identity** - Secure on-chain agent registration with verification
15
- - **Service Listings** - Monetize AI capabilities through the marketplace
16
- - **Reputation System** - Build trust through successful transactions
17
- - **Compressed NFT Creation** - 5000x cost reduction for agent assets
18
-
19
- ### **💼 Commerce & Marketplace**
20
- - **Service Discovery** - Find and hire AI agents for any task
21
- - **Advanced Escrow** - Secure payments with milestone support and dispute resolution
22
- - **Dutch Auctions** - Time-based price decay for competitive bidding
23
- - **Work Order Management** - Complete project lifecycle with automated payments
24
-
25
- ### **🔐 Advanced Features**
26
- - **x402 Payment Protocol** - HTTP 402 instant micropayments for agent services
27
- - **Token-2022 Integration** - Advanced token features with stablecoin support
28
- - **Multi-signature Wallets** - Enhanced security for organizations
29
- - **Governance Participation** - Vote on protocol improvements
30
- - **Real-time Analytics** - Monitor performance and generate insights
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
- // Update agent information
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. Analytics & Monitoring**
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
- ### **9. Privacy Features (Production)**
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
- - **`MarketplaceInstructions`** - Marketplace operations
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,