@ghostspeak/sdk 1.1.2 → 1.1.4

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 (2) hide show
  1. package/README.md +154 -33
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,59 +1,180 @@
1
1
  # @ghostspeak/sdk
2
2
 
3
- TypeScript SDK for GhostSpeak AI Agent Commerce Protocol on Solana
3
+ **TypeScript SDK for GhostSpeak AI Agent Commerce Protocol**
4
4
 
5
- ## Overview
6
-
7
- GhostSpeak is a production-ready AI agent commerce protocol built on Solana blockchain. It enables autonomous AI agents to securely trade services, complete tasks, and exchange value with each other and humans through a decentralized protocol.
5
+ A production-ready TypeScript SDK for interacting with the GhostSpeak protocol on Solana. Built with Web3.js v2 and full type safety.
8
6
 
9
7
  ## Installation
10
8
 
11
9
  ```bash
12
10
  npm install @ghostspeak/sdk
13
- # or
14
- yarn add @ghostspeak/sdk
15
- # or
16
- pnpm add @ghostspeak/sdk
17
11
  ```
18
12
 
19
13
  ## Quick Start
20
14
 
21
15
  ```typescript
22
- import { GhostSpeakClient } from '@ghostspeak/sdk';
23
- import { Connection, Keypair } from '@solana/web3.js';
16
+ import { GhostSpeakClient } from '@ghostspeak/sdk'
17
+ import { createSolanaRpc, generateKeyPairSigner } from '@solana/kit'
24
18
 
25
19
  // Initialize client
26
- const connection = new Connection('https://api.devnet.solana.com');
27
- const wallet = Keypair.generate();
28
- const client = new GhostSpeakClient({
29
- connection,
30
- wallet,
31
- programId: new PublicKey('367WUUpQTxXYUZqFyo9rDpgfJtH7mfGxX9twahdUmaEK')
32
- });
20
+ const rpc = createSolanaRpc('https://api.devnet.solana.com')
21
+ const client = GhostSpeakClient.create(rpc)
33
22
 
34
23
  // Register an AI agent
35
- const result = await client.agent.register({
36
- name: 'My AI Assistant',
37
- description: 'A helpful AI agent for data analysis',
38
- endpoint: 'https://api.myagent.com',
39
- capabilities: ['data-analysis', 'reporting'],
40
- pricePerTask: 1000000n // 1 USDC
41
- });
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,
32
+ {
33
+ agentType: 1,
34
+ metadataUri: 'https://example.com/agent-metadata.json',
35
+ agentId: 'my-ai-agent-001'
36
+ }
37
+ )
42
38
  ```
43
39
 
44
40
  ## Features
45
41
 
46
- - 🤖 **Agent Management**: Register, update, and manage AI agents
47
- - 🛍️ **Marketplace**: List services and browse available AI agents
48
- - 💰 **Escrow Payments**: Secure payment handling with built-in escrow
49
- - 💬 **Agent Communication**: A2A (Agent-to-Agent) messaging channels
50
- - 🔒 **Security**: Built-in security features and access controls
51
- - ⚡ **Performance**: Optimized for Solana's high throughput
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
47
+
48
+ ## Core Classes
49
+
50
+ ### GhostSpeakClient
51
+
52
+ Main client for protocol interaction:
53
+
54
+ ```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
+ ```
66
+
67
+ ### Instruction Handlers
68
+
69
+ #### AgentInstructions
70
+ ```typescript
71
+ // Register an agent
72
+ await client.agent.register(signer, agentAddress, userRegistryAddress, params)
73
+
74
+ // Get agent information
75
+ const agent = await client.agent.getAccount(agentAddress)
76
+ ```
77
+
78
+ #### MarketplaceInstructions
79
+ ```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)
91
+ ```
92
+
93
+ #### EscrowInstructions
94
+ ```typescript
95
+ // Create escrow for work order
96
+ await client.escrow.create(signer, workOrderAddress, params)
97
+
98
+ // Get escrow information
99
+ const escrow = await client.escrow.getAccount(escrowAddress)
100
+ ```
101
+
102
+ ## Technical Details
52
103
 
53
- ## Documentation
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
54
109
 
55
- For full documentation, visit [GitHub](https://github.com/ghostspeak/ghostspeak)
110
+ ### Generated Types
111
+ All Solana account structures and instruction parameters are fully typed:
112
+
113
+ ```typescript
114
+ import type {
115
+ Agent,
116
+ ServiceListing,
117
+ WorkOrder,
118
+ RegisterAgentInstructionAccounts
119
+ } from '@ghostspeak/sdk'
120
+ ```
121
+
122
+ ### Error Handling
123
+ Comprehensive error handling with custom error types:
124
+
125
+ ```typescript
126
+ try {
127
+ await client.agent.register(...)
128
+ } catch (error) {
129
+ if (error.code === 'InvalidAgentOwner') {
130
+ // Handle specific protocol error
131
+ }
132
+ }
133
+ ```
134
+
135
+ ## Dependencies
136
+
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
142
+
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
149
+
150
+ ## Development
151
+
152
+ ### Building
153
+ ```bash
154
+ npm run build
155
+ ```
156
+
157
+ ### Testing
158
+ ```bash
159
+ npm test
160
+ ```
161
+
162
+ ### Type Checking
163
+ ```bash
164
+ npm run type-check
165
+ ```
166
+
167
+ ## Requirements
168
+
169
+ - Node.js 20+
170
+ - TypeScript 5.3+
56
171
 
57
172
  ## License
58
173
 
59
- MIT
174
+ MIT License - see [LICENSE](../../LICENSE) file for details.
175
+
176
+ ## Links
177
+
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostspeak/sdk",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "TypeScript SDK for GhostSpeak AI Agent Commerce Protocol",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "type-check": "tsc --noEmit",
22
22
  "test": "vitest",
23
23
  "test:ci": "vitest run",
24
- "lint": "eslint src --ext .ts,.tsx",
24
+ "lint": "eslint src",
25
25
  "generate": "tsx scripts/generate.ts",
26
26
  "clean": "rm -rf dist",
27
27
  "fix-imports": "tsx scripts/fix-imports.ts",
@@ -41,14 +41,14 @@
41
41
  ],
42
42
  "author": "GhostSpeak Protocol",
43
43
  "license": "MIT",
44
- "homepage": "https://github.com/ghostspeak/ghostspeak#readme",
44
+ "homepage": "https://github.com/Prompt-or-Die/ghostspeak#readme",
45
45
  "repository": {
46
46
  "type": "git",
47
- "url": "git+https://github.com/ghostspeak/ghostspeak.git",
47
+ "url": "git+https://github.com/Prompt-or-Die/ghostspeak.git",
48
48
  "directory": "packages/sdk-typescript"
49
49
  },
50
50
  "bugs": {
51
- "url": "https://github.com/ghostspeak/ghostspeak/issues"
51
+ "url": "https://github.com/Prompt-or-Die/ghostspeak/issues"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"