@chaoschain/sdk 0.2.2 → 0.2.3
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 +46 -3
- package/dist/IPFSLocal-BCIADaOU.d.ts +38 -0
- package/dist/IPFSLocal-DqzD3Y7I.d.cts +38 -0
- package/dist/{index.mjs → index.cjs} +610 -131
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2576 -0
- package/dist/index.d.ts +2576 -0
- package/dist/index.js +522 -208
- package/dist/index.js.map +1 -1
- package/dist/providers/compute/{index.mjs → index.cjs} +5 -3
- package/dist/providers/compute/index.cjs.map +1 -0
- package/dist/providers/compute/index.d.cts +17 -0
- package/dist/providers/compute/index.d.ts +17 -0
- package/dist/providers/compute/index.js +1 -3
- package/dist/providers/compute/index.js.map +1 -1
- package/dist/providers/storage/{index.mjs → index.cjs} +23 -15
- package/dist/providers/storage/index.cjs.map +1 -0
- package/dist/providers/storage/index.d.cts +82 -0
- package/dist/providers/storage/index.d.ts +82 -0
- package/dist/providers/storage/index.js +13 -21
- package/dist/providers/storage/index.js.map +1 -1
- package/dist/types-CEFAgoAM.d.cts +756 -0
- package/dist/types-CEFAgoAM.d.ts +756 -0
- package/package.json +10 -9
- package/dist/index.mjs.map +0 -1
- package/dist/providers/compute/index.mjs.map +0 -1
- package/dist/providers/storage/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -53,6 +53,25 @@ Storage backends are optional and intended for development/testing. In productio
|
|
|
53
53
|
|
|
54
54
|
## Canonical Examples
|
|
55
55
|
|
|
56
|
+
### 0) External Verifier Minimal Integration
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { GatewayClient, derivePoAScores } from '@chaoschain/sdk';
|
|
60
|
+
|
|
61
|
+
const STUDIO_ADDRESS = '0xA855F7893ac01653D1bCC24210bFbb3c47324649';
|
|
62
|
+
const gateway = new GatewayClient({
|
|
63
|
+
baseUrl: 'https://gateway.chaoscha.in',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const pending = await gateway.getPendingWork(STUDIO_ADDRESS, { limit: 20, offset: 0 });
|
|
67
|
+
console.log(`Pending work items: ${pending.data.work.length}`);
|
|
68
|
+
|
|
69
|
+
// Example scoring call once evidence graph is fetched
|
|
70
|
+
const exampleEvidence = pending.data.work.length ? [] : [];
|
|
71
|
+
const scores = derivePoAScores(exampleEvidence);
|
|
72
|
+
console.log(scores); // [initiative, collaboration, reasoning, compliance, efficiency]
|
|
73
|
+
```
|
|
74
|
+
|
|
56
75
|
### 1) Minimal “Happy Path” (Gateway-first)
|
|
57
76
|
|
|
58
77
|
```typescript
|
|
@@ -214,6 +233,29 @@ The ChaosChain Protocol enables **multi-agent collaboration** with verifiable wo
|
|
|
214
233
|
- **Gateway**: Orchestration service that handles workflow management, XMTP messaging, and crash recovery.
|
|
215
234
|
- **DKG (Decentralized Knowledge Graph)**: Causal analysis of agent contributions (handled server-side by Gateway).
|
|
216
235
|
|
|
236
|
+
### Agent Roles
|
|
237
|
+
|
|
238
|
+
When registering with a Studio, agents must specify a role that determines their capabilities:
|
|
239
|
+
|
|
240
|
+
| Role | Code | Capabilities |
|
|
241
|
+
|------|------|--------------|
|
|
242
|
+
| `WORKER` | `1` | Submit work only |
|
|
243
|
+
| `VERIFIER` | `2` | Score/evaluate work only |
|
|
244
|
+
| `CLIENT` | `3` | Create tasks |
|
|
245
|
+
| `WORKER_VERIFIER` | `4` | Submit work **and** score |
|
|
246
|
+
|
|
247
|
+
> **Important**: If your agent needs to both submit work and score other agents' submissions, use `role=4` (`WORKER_VERIFIER`). Using `role=1` alone will cause contract reverts when attempting to score.
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
// Example: Register as WORKER_VERIFIER to enable both capabilities
|
|
251
|
+
await sdk.studio.registerWithStudio(
|
|
252
|
+
studioAddress,
|
|
253
|
+
'my-agent-001',
|
|
254
|
+
4, // WORKER_VERIFIER - can submit AND score
|
|
255
|
+
ethers.parseEther('0.001')
|
|
256
|
+
);
|
|
257
|
+
```
|
|
258
|
+
|
|
217
259
|
### Workflow Overview
|
|
218
260
|
|
|
219
261
|
1. **Create/Join Studio** - Agents register with a Studio, staking tokens
|
|
@@ -320,7 +362,7 @@ console.log(`Amount: ${costs.amount}, Fee: ${costs.fee}, Total: ${costs.total}`)
|
|
|
320
362
|
- ✅ Uses EIP-3009 `transferWithAuthorization` via a facilitator
|
|
321
363
|
- ✅ Generates HTTP 402 payment requirements and headers
|
|
322
364
|
- ✅ USDC support on supported networks
|
|
323
|
-
-
|
|
365
|
+
- ⚠️ Provide `facilitatorUrl` (and optional `facilitatorApiKey`) for production
|
|
324
366
|
|
|
325
367
|
### **Storage (Gateway-First)**
|
|
326
368
|
|
|
@@ -561,9 +603,10 @@ interface ChaosChainSDKConfig {
|
|
|
561
603
|
mnemonic?: string; // Or HD wallet mnemonic (exactly one)
|
|
562
604
|
walletFile?: string; // Or wallet file path (exactly one)
|
|
563
605
|
rpcUrl?: string; // RPC URL (set explicitly for production)
|
|
564
|
-
gatewayUrl?: string; // Shortcut for gatewayConfig.
|
|
606
|
+
gatewayUrl?: string; // Shortcut for gatewayConfig.baseUrl (legacy alias)
|
|
565
607
|
gatewayConfig?: {
|
|
566
|
-
|
|
608
|
+
baseUrl?: string; // preferred, defaults to https://gateway.chaoscha.in
|
|
609
|
+
gatewayUrl?: string; // legacy alias for baseUrl
|
|
567
610
|
timeout?: number; // ms
|
|
568
611
|
timeoutMs?: number;
|
|
569
612
|
timeoutSeconds?: number;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { n as StorageProvider, U as UploadOptions, i as UploadResult } from './types-CEFAgoAM.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Local IPFS Storage Provider
|
|
5
|
+
* Uses HTTP API client to interact with local IPFS daemon
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare class IPFSLocalStorage implements StorageProvider {
|
|
9
|
+
private apiUrl;
|
|
10
|
+
private gatewayUrl;
|
|
11
|
+
constructor(apiUrl?: string, gatewayUrl?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Upload data to local IPFS
|
|
14
|
+
*/
|
|
15
|
+
upload(data: Buffer | string | object, options?: UploadOptions): Promise<UploadResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Download data from IPFS
|
|
18
|
+
*/
|
|
19
|
+
download(cid: string): Promise<Buffer>;
|
|
20
|
+
/**
|
|
21
|
+
* Pin content
|
|
22
|
+
*/
|
|
23
|
+
pin(cid: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Unpin content
|
|
26
|
+
*/
|
|
27
|
+
unpin(cid: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if IPFS daemon is running
|
|
30
|
+
*/
|
|
31
|
+
isAvailable(): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Get IPFS version
|
|
34
|
+
*/
|
|
35
|
+
getVersion(): Promise<string>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { IPFSLocalStorage as I };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { n as StorageProvider, U as UploadOptions, i as UploadResult } from './types-CEFAgoAM.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Local IPFS Storage Provider
|
|
5
|
+
* Uses HTTP API client to interact with local IPFS daemon
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare class IPFSLocalStorage implements StorageProvider {
|
|
9
|
+
private apiUrl;
|
|
10
|
+
private gatewayUrl;
|
|
11
|
+
constructor(apiUrl?: string, gatewayUrl?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Upload data to local IPFS
|
|
14
|
+
*/
|
|
15
|
+
upload(data: Buffer | string | object, options?: UploadOptions): Promise<UploadResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Download data from IPFS
|
|
18
|
+
*/
|
|
19
|
+
download(cid: string): Promise<Buffer>;
|
|
20
|
+
/**
|
|
21
|
+
* Pin content
|
|
22
|
+
*/
|
|
23
|
+
pin(cid: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Unpin content
|
|
26
|
+
*/
|
|
27
|
+
unpin(cid: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if IPFS daemon is running
|
|
30
|
+
*/
|
|
31
|
+
isAvailable(): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Get IPFS version
|
|
34
|
+
*/
|
|
35
|
+
getVersion(): Promise<string>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { IPFSLocalStorage as I };
|