@ghostspeak/sdk 1.2.0 → 1.3.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/README.md +107 -123
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.js +42 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# @ghostspeak/sdk
|
|
2
2
|
|
|
3
|
-
|
|
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 {
|
|
18
|
-
|
|
19
|
-
// Initialize client
|
|
20
|
-
const
|
|
21
|
-
const client = GhostSpeakClient.create(
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
35
|
-
agentId: 'my-ai-agent
|
|
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
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
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
|
|
49
|
-
|
|
50
|
-
### GhostSpeakClient
|
|
51
|
-
|
|
52
|
-
Main client for protocol interaction:
|
|
45
|
+
## Core Modules
|
|
53
46
|
|
|
47
|
+
### Agent Management
|
|
54
48
|
```typescript
|
|
55
|
-
|
|
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
|
-
|
|
52
|
+
// Get agent information
|
|
53
|
+
const agent = await client.agent.get({ agentAddress });
|
|
68
54
|
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
//
|
|
75
|
-
const
|
|
58
|
+
// Search agents by capabilities
|
|
59
|
+
const results = await client.agent.search({ capabilities: ['coding'] });
|
|
76
60
|
```
|
|
77
61
|
|
|
78
|
-
|
|
62
|
+
### Marketplace
|
|
79
63
|
```typescript
|
|
80
|
-
// Create service listing
|
|
81
|
-
await client.marketplace.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
74
|
+
### Escrow Payments
|
|
94
75
|
```typescript
|
|
95
|
-
// Create escrow
|
|
96
|
-
await client.escrow.create(
|
|
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
|
-
//
|
|
99
|
-
|
|
82
|
+
// Handle disputes
|
|
83
|
+
await client.escrow.dispute(wallet, escrowPda);
|
|
100
84
|
```
|
|
101
85
|
|
|
102
|
-
|
|
86
|
+
### Auctions
|
|
87
|
+
```typescript
|
|
88
|
+
// Create auction
|
|
89
|
+
await client.auction.createServiceAuction(wallet, auctionPda, userRegistry, params);
|
|
103
90
|
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
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
|
-
|
|
123
|
-
|
|
105
|
+
// Submit evidence
|
|
106
|
+
await client.dispute.submitEvidence(wallet, disputePda, evidence);
|
|
124
107
|
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
112
|
+
### Governance
|
|
113
|
+
```typescript
|
|
114
|
+
// Create multisig
|
|
115
|
+
await client.governance.createMultisig(wallet, params);
|
|
136
116
|
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- Instruction builders
|
|
147
|
-
- Type definitions
|
|
148
|
-
- Error codes
|
|
120
|
+
// List proposals
|
|
121
|
+
const proposals = await client.governance.listProposals();
|
|
122
|
+
```
|
|
149
123
|
|
|
150
|
-
##
|
|
124
|
+
## Advanced Usage
|
|
151
125
|
|
|
152
|
-
###
|
|
153
|
-
```
|
|
154
|
-
|
|
126
|
+
### Custom RPC Configuration
|
|
127
|
+
```typescript
|
|
128
|
+
const client = GhostSpeakClient.create(connection, {
|
|
129
|
+
commitment: 'confirmed',
|
|
130
|
+
programId: customProgramId
|
|
131
|
+
});
|
|
155
132
|
```
|
|
156
133
|
|
|
157
|
-
###
|
|
158
|
-
```
|
|
159
|
-
|
|
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
|
-
###
|
|
163
|
-
```
|
|
164
|
-
|
|
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
|
-
##
|
|
154
|
+
## API Reference
|
|
168
155
|
|
|
169
|
-
|
|
170
|
-
- TypeScript 5.3+
|
|
156
|
+
Full API documentation is available at [https://docs.ghostspeak.ai/sdk](https://docs.ghostspeak.ai/sdk).
|
|
171
157
|
|
|
172
|
-
##
|
|
158
|
+
## Contributing
|
|
173
159
|
|
|
174
|
-
|
|
160
|
+
See the main repository's [Contributing Guide](https://github.com/ghostspeak/ghostspeak/blob/main/CONTRIBUTING.md).
|
|
175
161
|
|
|
176
|
-
##
|
|
162
|
+
## License
|
|
177
163
|
|
|
178
|
-
|
|
179
|
-
- **Issues**: https://github.com/Prompt-or-Die/ghostspeak/issues
|
|
180
|
-
- **NPM Package**: https://www.npmjs.com/package/@ghostspeak/sdk
|
|
164
|
+
MIT
|