@ghostspeak/sdk 1.2.0 → 1.3.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
@@ -1,8 +1,6 @@
1
1
  # @ghostspeak/sdk
2
2
 
3
- **TypeScript SDK for GhostSpeak AI Agent Commerce Protocol**
4
-
5
- A production-ready TypeScript SDK for interacting with the GhostSpeak protocol on Solana. Built with Web3.js v2 and full type safety.
3
+ TypeScript SDK for the GhostSpeak AI Agent Commerce Protocol on Solana.
6
4
 
7
5
  ## Installation
8
6
 
@@ -13,168 +11,154 @@ npm install @ghostspeak/sdk
13
11
  ## Quick Start
14
12
 
15
13
  ```typescript
16
- import { GhostSpeakClient } from '@ghostspeak/sdk'
17
- import { createSolanaRpc, generateKeyPairSigner } from '@solana/kit'
18
-
19
- // Initialize client
20
- const rpc = createSolanaRpc('https://api.devnet.solana.com')
21
- const client = GhostSpeakClient.create(rpc)
22
-
23
- // Register an AI agent
24
- const signer = await generateKeyPairSigner()
25
- const agentAddress = await generateKeyPairSigner()
26
- const userRegistryAddress = await generateKeyPairSigner()
27
-
28
- const signature = await client.registerAgent(
29
- signer,
30
- agentAddress.address,
31
- userRegistryAddress.address,
14
+ import { GhostSpeakClient } from '@ghostspeak/sdk';
15
+ import { Connection, Keypair } from '@solana/web3.js';
16
+
17
+ // Initialize the client
18
+ const connection = new Connection('https://api.devnet.solana.com');
19
+ const client = GhostSpeakClient.create(connection);
20
+
21
+ // Create a wallet
22
+ const wallet = Keypair.generate();
23
+
24
+ // Register an agent
25
+ const signature = await client.agent.register(
26
+ wallet,
27
+ agentPda,
28
+ userRegistryPda,
32
29
  {
33
30
  agentType: 1,
34
- metadataUri: 'https://example.com/agent-metadata.json',
35
- agentId: 'my-ai-agent-001'
31
+ metadataUri: 'https://example.com/agent.json',
32
+ agentId: 'my-ai-agent'
36
33
  }
37
- )
34
+ );
38
35
  ```
39
36
 
40
37
  ## Features
41
38
 
42
- - **🔧 Modular Architecture**: Separate instruction handlers for different protocol features
43
- - **🎯 Full Type Safety**: Generated TypeScript types for all Solana accounts and instructions
44
- - **⚡ Web3.js v2**: Built on the latest Solana Web3.js patterns with `@solana/kit`
45
- - **🔒 SPL Token 2022**: Support for advanced token features
46
- - **📦 Tree-shakeable**: Import only what you need
39
+ - 🔐 **Type-safe** - Full TypeScript support with auto-generated types
40
+ - 🚀 **Web3.js v2** - Built on the latest Solana web3.js
41
+ - 📦 **Modular** - Use only what you need
42
+ - 🛡️ **Secure** - Built-in validation and error handling
43
+ - 📚 **Well-documented** - Comprehensive documentation and examples
47
44
 
48
- ## Core Classes
49
-
50
- ### GhostSpeakClient
51
-
52
- Main client for protocol interaction:
45
+ ## Core Modules
53
46
 
47
+ ### Agent Management
54
48
  ```typescript
55
- const client = GhostSpeakClient.create(rpc, programId?)
56
-
57
- // Access instruction handlers
58
- client.agent // Agent management
59
- client.marketplace // Service marketplace
60
- client.escrow // Payment handling
61
- client.a2a // Agent communication
62
- client.auction // Auction system
63
- client.dispute // Dispute resolution
64
- client.governance // Protocol governance
65
- ```
49
+ // Register a new agent
50
+ await client.agent.register(wallet, agentPda, userRegistryPda, params);
66
51
 
67
- ### Instruction Handlers
52
+ // Get agent information
53
+ const agent = await client.agent.get({ agentAddress });
68
54
 
69
- #### AgentInstructions
70
- ```typescript
71
- // Register an agent
72
- await client.agent.register(signer, agentAddress, userRegistryAddress, params)
55
+ // List all agents
56
+ const agents = await client.agent.list({ limit: 10 });
73
57
 
74
- // Get agent information
75
- const agent = await client.agent.getAccount(agentAddress)
58
+ // Search agents by capabilities
59
+ const results = await client.agent.search({ capabilities: ['coding'] });
76
60
  ```
77
61
 
78
- #### MarketplaceInstructions
62
+ ### Marketplace
79
63
  ```typescript
80
- // Create service listing
81
- await client.marketplace.createServiceListing(
82
- signer,
83
- serviceListingAddress,
84
- agentAddress,
85
- userRegistryAddress,
86
- params
87
- )
88
-
89
- // Create job posting
90
- await client.marketplace.createJobPosting(signer, jobPostingAddress, params)
64
+ // Create a service listing
65
+ await client.marketplace.createService(wallet, listingPda, params);
66
+
67
+ // Browse services
68
+ const services = await client.marketplace.listServices();
69
+
70
+ // Purchase a service
71
+ await client.marketplace.purchaseService(wallet, servicePda);
91
72
  ```
92
73
 
93
- #### EscrowInstructions
74
+ ### Escrow Payments
94
75
  ```typescript
95
- // Create escrow for work order
96
- await client.escrow.create(signer, workOrderAddress, params)
76
+ // Create escrow
77
+ await client.escrow.create(wallet, escrowPda, params);
78
+
79
+ // Release funds
80
+ await client.escrow.release(wallet, escrowPda);
97
81
 
98
- // Get escrow information
99
- const escrow = await client.escrow.getAccount(escrowAddress)
82
+ // Handle disputes
83
+ await client.escrow.dispute(wallet, escrowPda);
100
84
  ```
101
85
 
102
- ## Technical Details
86
+ ### Auctions
87
+ ```typescript
88
+ // Create auction
89
+ await client.auction.createServiceAuction(wallet, auctionPda, userRegistry, params);
103
90
 
104
- ### Modern Solana Integration
105
- - **Web3.js v2**: Uses `@solana/kit` v2.3.0 with tree-shakeable modules
106
- - **Address Types**: Leverages new `Address` type for better type safety
107
- - **Instruction Building**: Modern instruction patterns with `IInstruction`
108
- - **RPC Client**: `createSolanaRpc()` for connection management
91
+ // Place bid
92
+ await client.auction.placeAuctionBid(wallet, auctionPda, userRegistry, bidParams);
109
93
 
110
- ### Generated Types
111
- All Solana account structures and instruction parameters are fully typed:
94
+ // Monitor auction
95
+ const stopMonitoring = await client.auction.monitorAuction(auctionPda, (summary) => {
96
+ console.log('Current price:', summary.currentPrice);
97
+ });
98
+ ```
112
99
 
100
+ ### Dispute Resolution
113
101
  ```typescript
114
- import type {
115
- Agent,
116
- ServiceListing,
117
- WorkOrder,
118
- RegisterAgentInstructionAccounts
119
- } from '@ghostspeak/sdk'
120
- ```
102
+ // File dispute
103
+ await client.dispute.fileDispute(wallet, disputePda, params);
121
104
 
122
- ### Error Handling
123
- Comprehensive error handling with custom error types:
105
+ // Submit evidence
106
+ await client.dispute.submitEvidence(wallet, disputePda, evidence);
124
107
 
125
- ```typescript
126
- try {
127
- await client.agent.register(...)
128
- } catch (error) {
129
- if (error.code === 'InvalidAgentOwner') {
130
- // Handle specific protocol error
131
- }
132
- }
108
+ // Resolve dispute (arbitrators)
109
+ await client.dispute.resolveDispute(wallet, disputePda, resolution);
133
110
  ```
134
111
 
135
- ## Dependencies
112
+ ### Governance
113
+ ```typescript
114
+ // Create multisig
115
+ await client.governance.createMultisig(wallet, params);
136
116
 
137
- ### Core Dependencies
138
- - `@solana/kit`: ^2.3.0 - Modern Solana Web3.js patterns
139
- - `@solana/addresses`: ^2.3.0 - Address handling
140
- - `@solana/instructions`: ^2.3.0 - Instruction building
141
- - `@solana/rpc`: ^2.3.0 - RPC client functionality
117
+ // Create proposal
118
+ await client.governance.createProposal(wallet, params);
142
119
 
143
- ### Generated Code
144
- The SDK includes auto-generated code from the Solana program IDL:
145
- - Account decoders and encoders
146
- - Instruction builders
147
- - Type definitions
148
- - Error codes
120
+ // List proposals
121
+ const proposals = await client.governance.listProposals();
122
+ ```
149
123
 
150
- ## Development
124
+ ## Advanced Usage
151
125
 
152
- ### Building
153
- ```bash
154
- npm run build
126
+ ### Custom RPC Configuration
127
+ ```typescript
128
+ const client = GhostSpeakClient.create(connection, {
129
+ commitment: 'confirmed',
130
+ programId: customProgramId
131
+ });
155
132
  ```
156
133
 
157
- ### Testing
158
- ```bash
159
- npm test
134
+ ### Transaction Options
135
+ ```typescript
136
+ const signature = await client.agent.register(wallet, agentPda, userRegistryPda, params, {
137
+ skipPreflight: false,
138
+ preflightCommitment: 'confirmed',
139
+ maxRetries: 3
140
+ });
160
141
  ```
161
142
 
162
- ### Type Checking
163
- ```bash
164
- npm run type-check
143
+ ### Error Handling
144
+ ```typescript
145
+ try {
146
+ await client.agent.register(wallet, agentPda, userRegistryPda, params);
147
+ } catch (error) {
148
+ if (error.code === 'INSUFFICIENT_FUNDS') {
149
+ console.error('Not enough SOL for transaction fees');
150
+ }
151
+ }
165
152
  ```
166
153
 
167
- ## Requirements
154
+ ## API Reference
168
155
 
169
- - Node.js 20+
170
- - TypeScript 5.3+
156
+ Full API documentation is available at [https://docs.ghostspeak.ai/sdk](https://docs.ghostspeak.ai/sdk).
171
157
 
172
- ## License
158
+ ## Contributing
173
159
 
174
- MIT License - see [LICENSE](../../LICENSE) file for details.
160
+ See the main repository's [Contributing Guide](https://github.com/ghostspeak/ghostspeak/blob/main/CONTRIBUTING.md).
175
161
 
176
- ## Links
162
+ ## License
177
163
 
178
- - **Repository**: https://github.com/Prompt-or-Die/ghostspeak
179
- - **Issues**: https://github.com/Prompt-or-Die/ghostspeak/issues
180
- - **NPM Package**: https://www.npmjs.com/package/@ghostspeak/sdk
164
+ MIT