@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
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Evidence DAG utilities for ChaosChain PoA scoring.
|
|
5
|
+
*
|
|
6
|
+
* These helpers operate on evidence graphs produced by the gateway's DKG engine.
|
|
7
|
+
* Verifier agents use them to derive Proof-of-Agency scores from evidence structure.
|
|
8
|
+
*
|
|
9
|
+
* Architecture (3 layers per VA scoring spec):
|
|
10
|
+
*
|
|
11
|
+
* Layer 1 — extractAgencySignals(evidence, context?)
|
|
12
|
+
* Deterministic signal extraction. 0..1 normalized.
|
|
13
|
+
* Same evidence + same policy = same signals.
|
|
14
|
+
*
|
|
15
|
+
* Layer 2 — composeScoreVector(signals, assessment?)
|
|
16
|
+
* Verifier agent produces final score vector.
|
|
17
|
+
* Accepts 0..1 or 0..100 inputs, normalizes internally.
|
|
18
|
+
* Output: integer tuple [0..100] × 5 for on-chain submission.
|
|
19
|
+
*
|
|
20
|
+
* Layer 3 — Contract aggregation (outside SDK)
|
|
21
|
+
* Median / MAD / stake-weighted consensus over verifier vectors.
|
|
22
|
+
*/
|
|
23
|
+
interface EvidencePackage {
|
|
24
|
+
arweave_tx_id: string;
|
|
25
|
+
author: string;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
parent_ids: string[];
|
|
28
|
+
payload_hash: string;
|
|
29
|
+
artifact_ids: string[];
|
|
30
|
+
signature: string;
|
|
31
|
+
}
|
|
32
|
+
/** @deprecated Use WorkVerificationResult instead */
|
|
33
|
+
interface WorkEvidenceVerificationResult {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
scores: number[];
|
|
36
|
+
}
|
|
37
|
+
interface WorkVerificationResult {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
signals?: AgencySignals;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Verifier assessment — optional overrides for each dimension.
|
|
43
|
+
* Values can be in 0..1 (normalized) or 0..100 (integer); the SDK
|
|
44
|
+
* auto-detects and normalizes internally.
|
|
45
|
+
*/
|
|
46
|
+
type VerifierAssessment = {
|
|
47
|
+
initiativeScore?: number;
|
|
48
|
+
collaborationScore?: number;
|
|
49
|
+
reasoningScore?: number;
|
|
50
|
+
complianceScore?: number;
|
|
51
|
+
efficiencyScore?: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Deterministic agency signals extracted from an evidence DAG.
|
|
55
|
+
*
|
|
56
|
+
* Signals are normalized to [0, 1]. The `observed` block carries raw graph
|
|
57
|
+
* features so verifier agents can apply their own judgment on top.
|
|
58
|
+
*/
|
|
59
|
+
type AgencySignals = {
|
|
60
|
+
initiativeSignal: number;
|
|
61
|
+
collaborationSignal: number;
|
|
62
|
+
reasoningSignal: number;
|
|
63
|
+
complianceSignal?: number;
|
|
64
|
+
efficiencySignal?: number;
|
|
65
|
+
observed: {
|
|
66
|
+
totalNodes: number;
|
|
67
|
+
rootCount: number;
|
|
68
|
+
edgeCount: number;
|
|
69
|
+
maxDepth: number;
|
|
70
|
+
artifactCount: number;
|
|
71
|
+
terminalCount: number;
|
|
72
|
+
integrationNodeCount: number;
|
|
73
|
+
uniqueAuthors?: number;
|
|
74
|
+
testsPresent?: boolean;
|
|
75
|
+
policyViolations?: string[];
|
|
76
|
+
requiredArtifactsPresent?: string[];
|
|
77
|
+
missingArtifacts?: string[];
|
|
78
|
+
durationMs?: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type ScoreRange = {
|
|
82
|
+
min: number;
|
|
83
|
+
target: number;
|
|
84
|
+
max: number;
|
|
85
|
+
};
|
|
86
|
+
type EngineeringStudioPolicy = {
|
|
87
|
+
version: string;
|
|
88
|
+
studioName: string;
|
|
89
|
+
scoring: {
|
|
90
|
+
initiative: {
|
|
91
|
+
rootRatio: ScoreRange;
|
|
92
|
+
};
|
|
93
|
+
collaboration: {
|
|
94
|
+
edgeDensity: ScoreRange;
|
|
95
|
+
integrationRatio: ScoreRange;
|
|
96
|
+
weights: {
|
|
97
|
+
edgeDensity: number;
|
|
98
|
+
integrationRatio: number;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
reasoning: {
|
|
102
|
+
depthRatio: ScoreRange;
|
|
103
|
+
};
|
|
104
|
+
compliance: {
|
|
105
|
+
requiredChecks: string[];
|
|
106
|
+
forbiddenPatterns: string[];
|
|
107
|
+
requiredArtifacts: string[];
|
|
108
|
+
weights: {
|
|
109
|
+
testsPresent: number;
|
|
110
|
+
requiredArtifactsPresent: number;
|
|
111
|
+
noPolicyViolations: number;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
efficiency: {
|
|
115
|
+
durationRatio?: ScoreRange;
|
|
116
|
+
artifactCountRatio?: ScoreRange;
|
|
117
|
+
weights: {
|
|
118
|
+
durationRatio?: number;
|
|
119
|
+
artifactCountRatio?: number;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
verifierInstructions: {
|
|
124
|
+
initiative: string;
|
|
125
|
+
collaboration: string;
|
|
126
|
+
reasoning: string;
|
|
127
|
+
compliance: string;
|
|
128
|
+
efficiency: string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
type WorkMandate = {
|
|
132
|
+
taskId: string;
|
|
133
|
+
title: string;
|
|
134
|
+
objective: string;
|
|
135
|
+
taskType: 'bugfix' | 'feature' | 'refactor' | 'review' | 'research';
|
|
136
|
+
constraints?: {
|
|
137
|
+
mustPassTests?: boolean;
|
|
138
|
+
requiredArtifacts?: string[];
|
|
139
|
+
forbiddenPatterns?: string[];
|
|
140
|
+
latencyBudgetMs?: number;
|
|
141
|
+
targetFiles?: string[];
|
|
142
|
+
};
|
|
143
|
+
overrides?: Partial<EngineeringStudioPolicy['scoring']>;
|
|
144
|
+
verifierPrompt?: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Optional context passed to extractAgencySignals for policy-conditioned scoring.
|
|
148
|
+
*/
|
|
149
|
+
type SignalExtractionContext = {
|
|
150
|
+
studioPolicy?: EngineeringStudioPolicy;
|
|
151
|
+
workMandate?: WorkMandate;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Maps a value to [0, 1] based on a (min, target, max) range.
|
|
155
|
+
*
|
|
156
|
+
* - value <= min or value >= max → 0
|
|
157
|
+
* - value === target → 1
|
|
158
|
+
* - value between min and target → linear interpolation 0..1
|
|
159
|
+
* - value between target and max → linear interpolation 1..0
|
|
160
|
+
*
|
|
161
|
+
* Result is clamped to [0, 1].
|
|
162
|
+
*/
|
|
163
|
+
declare function rangeFit(value: number, min: number, target: number, max: number): number;
|
|
164
|
+
/**
|
|
165
|
+
* Deterministic agency signal extraction from an evidence DAG.
|
|
166
|
+
*
|
|
167
|
+
* Without context: produces raw structural ratio signals (Phase 1 baseline).
|
|
168
|
+
* With studioPolicy/workMandate: produces policy-conditioned signals via
|
|
169
|
+
* rangeFit, including deterministic compliance and efficiency (Phase 2).
|
|
170
|
+
*
|
|
171
|
+
* Same evidence + same context always produces the same signals.
|
|
172
|
+
*/
|
|
173
|
+
declare function extractAgencySignals(evidence: EvidencePackage[], context?: SignalExtractionContext): AgencySignals;
|
|
174
|
+
/**
|
|
175
|
+
* Returns the maximum causal depth of the evidence DAG.
|
|
176
|
+
* A single-node graph has depth 1. A linear chain of N nodes has depth N.
|
|
177
|
+
*/
|
|
178
|
+
declare function computeDepth(evidence: EvidencePackage[]): number;
|
|
179
|
+
/**
|
|
180
|
+
* Composes a final on-chain score vector from deterministic signals and
|
|
181
|
+
* optional verifier assessment.
|
|
182
|
+
*
|
|
183
|
+
* For each dimension:
|
|
184
|
+
* - If the verifier provides an override → use it (normalized)
|
|
185
|
+
* - Otherwise → use the deterministic signal
|
|
186
|
+
* - If the signal is also undefined → 0
|
|
187
|
+
*
|
|
188
|
+
* Input values can be in 0..1 or 0..100; the SDK auto-detects.
|
|
189
|
+
* Output is always integer tuple [0..100] × 5 ready for contract submission.
|
|
190
|
+
*/
|
|
191
|
+
declare function composeScoreVector(signals: AgencySignals, assessment?: VerifierAssessment): [number, number, number, number, number];
|
|
192
|
+
/**
|
|
193
|
+
* Convenience wrapper: extract signals + compose score vector in one call.
|
|
194
|
+
*
|
|
195
|
+
* Returns [Initiative, Collaboration, Reasoning, Compliance, Efficiency]
|
|
196
|
+
* as integers 0..100 for on-chain submission.
|
|
197
|
+
*
|
|
198
|
+
* Compliance and efficiency come from signals when available, or from the
|
|
199
|
+
* verifier-provided `options`. No hardcoded placeholders.
|
|
200
|
+
*/
|
|
201
|
+
declare function derivePoAScores(evidence: EvidencePackage[], options?: {
|
|
202
|
+
compliance?: number;
|
|
203
|
+
efficiency?: number;
|
|
204
|
+
}): [number, number, number, number, number];
|
|
205
|
+
/**
|
|
206
|
+
* Validates that the evidence forms a valid DAG:
|
|
207
|
+
* - No cycles
|
|
208
|
+
* - All parent_ids reference existing nodes
|
|
209
|
+
*/
|
|
210
|
+
declare function validateEvidenceGraph(evidence: EvidencePackage[]): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* High-level verifier helper:
|
|
213
|
+
* 1) validates evidence graph integrity
|
|
214
|
+
* 2) extracts deterministic agency signals (optionally policy-conditioned)
|
|
215
|
+
*
|
|
216
|
+
* Returns { valid, signals } — the verifier then uses composeScoreVector()
|
|
217
|
+
* to produce the final on-chain score vector.
|
|
218
|
+
*/
|
|
219
|
+
declare function verifyWorkEvidence(evidence: EvidencePackage[], context?: SignalExtractionContext): WorkVerificationResult;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* ChaosChain SDK Type Definitions
|
|
223
|
+
* TypeScript types and interfaces for building verifiable AI agents
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Supported blockchain networks with pre-deployed ERC-8004 contracts
|
|
228
|
+
*/
|
|
229
|
+
declare enum NetworkConfig {
|
|
230
|
+
ETHEREUM_MAINNET = "ethereum-mainnet",
|
|
231
|
+
ETHEREUM_SEPOLIA = "ethereum-sepolia",
|
|
232
|
+
BASE_MAINNET = "base-mainnet",
|
|
233
|
+
BASE_SEPOLIA = "base-sepolia",
|
|
234
|
+
POLYGON_MAINNET = "polygon-mainnet",
|
|
235
|
+
POLYGON_AMOY = "polygon-amoy",
|
|
236
|
+
ARBITRUM_MAINNET = "arbitrum-mainnet",
|
|
237
|
+
ARBITRUM_TESTNET = "arbitrum-testnet",
|
|
238
|
+
CELO_MAINNET = "celo-mainnet",
|
|
239
|
+
CELO_TESTNET = "celo-testnet",
|
|
240
|
+
GNOSIS_MAINNET = "gnosis-mainnet",
|
|
241
|
+
SCROLL_MAINNET = "scroll-mainnet",
|
|
242
|
+
SCROLL_TESTNET = "scroll-testnet",
|
|
243
|
+
TAIKO_MAINNET = "taiko-mainnet",
|
|
244
|
+
MONAD_MAINNET = "monad-mainnet",
|
|
245
|
+
MONAD_TESTNET = "monad-testnet",
|
|
246
|
+
OPTIMISM_SEPOLIA = "optimism-sepolia",
|
|
247
|
+
LINEA_SEPOLIA = "linea-sepolia",
|
|
248
|
+
HEDERA_TESTNET = "hedera-testnet",
|
|
249
|
+
MODE_TESTNET = "mode-testnet",
|
|
250
|
+
ZEROG_TESTNET = "0g-testnet",
|
|
251
|
+
BSC_MAINNET = "bsc-mainnet",
|
|
252
|
+
BSC_TESTNET = "bsc-testnet",
|
|
253
|
+
LOCAL = "local"
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* W3C-compliant payment methods supported by the SDK.
|
|
257
|
+
*/
|
|
258
|
+
declare enum PaymentMethod {
|
|
259
|
+
BASIC_CARD = "basic-card",
|
|
260
|
+
GOOGLE_PAY = "https://google.com/pay",
|
|
261
|
+
APPLE_PAY = "https://apple.com/apple-pay",
|
|
262
|
+
PAYPAL = "https://paypal.com",
|
|
263
|
+
A2A_X402 = "https://a2a.org/x402",
|
|
264
|
+
DIRECT_TRANSFER = "direct-transfer"
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Agent role in the ChaosChain network
|
|
268
|
+
*/
|
|
269
|
+
declare enum AgentRole {
|
|
270
|
+
WORKER = "worker",
|
|
271
|
+
VERIFIER = "verifier",
|
|
272
|
+
CLIENT = "client",
|
|
273
|
+
ORCHESTRATOR = "orchestrator"
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* ERC-8004 contract addresses for a network
|
|
277
|
+
*/
|
|
278
|
+
interface ContractAddresses {
|
|
279
|
+
identity: string;
|
|
280
|
+
reputation: string;
|
|
281
|
+
validation: string;
|
|
282
|
+
identityRegistry?: string;
|
|
283
|
+
reputationRegistry?: string;
|
|
284
|
+
validationRegistry?: string;
|
|
285
|
+
identity_registry?: string;
|
|
286
|
+
reputation_registry?: string;
|
|
287
|
+
validation_registry?: string;
|
|
288
|
+
rewardsDistributor?: string | null;
|
|
289
|
+
chaosCore?: string | null;
|
|
290
|
+
rewards_distributor?: string | null;
|
|
291
|
+
chaos_core?: string | null;
|
|
292
|
+
network?: NetworkConfig | null;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Network configuration with RPC and contract addresses
|
|
296
|
+
*/
|
|
297
|
+
interface NetworkInfo {
|
|
298
|
+
chainId: number;
|
|
299
|
+
name: string;
|
|
300
|
+
rpcUrl: string;
|
|
301
|
+
contracts: ContractAddresses;
|
|
302
|
+
nativeCurrency: {
|
|
303
|
+
name: string;
|
|
304
|
+
symbol: string;
|
|
305
|
+
decimals: number;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Agent metadata structure (ERC-8004 compliant)
|
|
310
|
+
*/
|
|
311
|
+
interface AgentMetadata {
|
|
312
|
+
name: string;
|
|
313
|
+
domain: string;
|
|
314
|
+
role: AgentRole | string;
|
|
315
|
+
capabilities?: string[];
|
|
316
|
+
version?: string;
|
|
317
|
+
description?: string;
|
|
318
|
+
image?: string;
|
|
319
|
+
contact?: string;
|
|
320
|
+
supportedTrust?: string[];
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Agent registration result
|
|
324
|
+
*/
|
|
325
|
+
interface AgentRegistration {
|
|
326
|
+
agentId: bigint;
|
|
327
|
+
txHash: string;
|
|
328
|
+
owner: string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Feedback submission parameters
|
|
332
|
+
*/
|
|
333
|
+
interface FeedbackParams {
|
|
334
|
+
agentId: bigint;
|
|
335
|
+
rating: number;
|
|
336
|
+
feedbackUri: string;
|
|
337
|
+
feedbackData?: FeedbackData;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Feedback metadata payload (ERC-8004 Jan/Feb 2026)
|
|
341
|
+
*/
|
|
342
|
+
interface FeedbackData extends Record<string, unknown> {
|
|
343
|
+
tag1?: string;
|
|
344
|
+
tag2?: string;
|
|
345
|
+
endpoint?: string;
|
|
346
|
+
value?: number | bigint;
|
|
347
|
+
valueDecimals?: number;
|
|
348
|
+
content?: string;
|
|
349
|
+
feedbackHash?: string;
|
|
350
|
+
/**
|
|
351
|
+
* @deprecated ERC-8004 Jan 2026 removed feedbackAuth
|
|
352
|
+
*/
|
|
353
|
+
feedbackAuth?: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Feedback record
|
|
357
|
+
*/
|
|
358
|
+
interface FeedbackRecord {
|
|
359
|
+
feedbackId: bigint;
|
|
360
|
+
fromAgent: bigint;
|
|
361
|
+
toAgent: bigint;
|
|
362
|
+
rating: number;
|
|
363
|
+
value?: number;
|
|
364
|
+
valueDecimals?: number;
|
|
365
|
+
tag1?: string;
|
|
366
|
+
tag2?: string;
|
|
367
|
+
endpoint?: string;
|
|
368
|
+
feedbackIndex?: bigint;
|
|
369
|
+
feedbackUri: string;
|
|
370
|
+
timestamp: number;
|
|
371
|
+
revoked: boolean;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Validation request parameters
|
|
375
|
+
*/
|
|
376
|
+
interface ValidationRequestParams {
|
|
377
|
+
validatorAgentId: bigint;
|
|
378
|
+
requestUri: string;
|
|
379
|
+
requestHash: string;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Validation request record
|
|
383
|
+
*/
|
|
384
|
+
interface ValidationRequest {
|
|
385
|
+
requestId: bigint;
|
|
386
|
+
requester: bigint;
|
|
387
|
+
validator: bigint;
|
|
388
|
+
requestUri: string;
|
|
389
|
+
requestHash: string;
|
|
390
|
+
status: ValidationStatus;
|
|
391
|
+
responseUri?: string;
|
|
392
|
+
timestamp: number;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Validation status enum
|
|
396
|
+
*/
|
|
397
|
+
declare enum ValidationStatus {
|
|
398
|
+
PENDING = 0,
|
|
399
|
+
APPROVED = 1,
|
|
400
|
+
REJECTED = 2
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* x402 payment parameters
|
|
404
|
+
*/
|
|
405
|
+
interface X402PaymentParams {
|
|
406
|
+
toAgent: string;
|
|
407
|
+
amount: string;
|
|
408
|
+
currency?: string;
|
|
409
|
+
serviceType?: string;
|
|
410
|
+
metadata?: Record<string, unknown>;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* x402 payment result
|
|
414
|
+
*/
|
|
415
|
+
interface X402Payment {
|
|
416
|
+
from: string;
|
|
417
|
+
to: string;
|
|
418
|
+
amount: string;
|
|
419
|
+
currency: string;
|
|
420
|
+
txHash: string;
|
|
421
|
+
timestamp: number;
|
|
422
|
+
feeAmount?: string;
|
|
423
|
+
feeTxHash?: string;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Storage upload options
|
|
427
|
+
*/
|
|
428
|
+
interface UploadOptions {
|
|
429
|
+
mime?: string;
|
|
430
|
+
metadata?: Record<string, unknown>;
|
|
431
|
+
pin?: boolean;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Storage upload result
|
|
435
|
+
*/
|
|
436
|
+
interface UploadResult {
|
|
437
|
+
cid: string;
|
|
438
|
+
uri: string;
|
|
439
|
+
size?: number;
|
|
440
|
+
timestamp: number;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Storage provider interface
|
|
444
|
+
*/
|
|
445
|
+
interface StorageProvider {
|
|
446
|
+
upload(data: Buffer | string | object, options?: UploadOptions): Promise<UploadResult>;
|
|
447
|
+
download(cid: string): Promise<Buffer>;
|
|
448
|
+
pin(cid: string): Promise<void>;
|
|
449
|
+
unpin(cid: string): Promise<void>;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Compute provider interface
|
|
453
|
+
*/
|
|
454
|
+
interface ComputeProvider {
|
|
455
|
+
inference(model: string, input: unknown): Promise<unknown>;
|
|
456
|
+
getModels(): Promise<string[]>;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Verification method
|
|
460
|
+
*/
|
|
461
|
+
declare enum VerificationMethod {
|
|
462
|
+
TEE_ML = "tee-ml",// Trusted Execution Environment
|
|
463
|
+
ZK_ML = "zk-ml",// Zero-Knowledge Machine Learning
|
|
464
|
+
OP_ML = "op-ml",// Optimistic Machine Learning
|
|
465
|
+
NONE = "none"
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* TEE attestation data
|
|
469
|
+
*/
|
|
470
|
+
interface TEEAttestation {
|
|
471
|
+
jobId: string;
|
|
472
|
+
provider: string;
|
|
473
|
+
executionHash: string;
|
|
474
|
+
verificationMethod: VerificationMethod;
|
|
475
|
+
model?: string;
|
|
476
|
+
attestationData: unknown;
|
|
477
|
+
proof?: string;
|
|
478
|
+
metadata?: unknown;
|
|
479
|
+
timestamp: string;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Integrity proof structure
|
|
483
|
+
*/
|
|
484
|
+
interface IntegrityProof {
|
|
485
|
+
proofId: string;
|
|
486
|
+
functionName: string;
|
|
487
|
+
codeHash: string;
|
|
488
|
+
executionHash: string;
|
|
489
|
+
timestamp: Date;
|
|
490
|
+
agentName: string;
|
|
491
|
+
verificationStatus: string;
|
|
492
|
+
ipfsCid?: string;
|
|
493
|
+
teeAttestation?: TEEAttestation;
|
|
494
|
+
teeProvider?: string;
|
|
495
|
+
teeJobId?: string;
|
|
496
|
+
teeExecutionHash?: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Main SDK configuration
|
|
500
|
+
*/
|
|
501
|
+
interface ChaosChainSDKConfig {
|
|
502
|
+
agentName: string;
|
|
503
|
+
agentDomain: string;
|
|
504
|
+
agentRole: AgentRole | string;
|
|
505
|
+
network: NetworkConfig | string;
|
|
506
|
+
privateKey?: string;
|
|
507
|
+
mnemonic?: string;
|
|
508
|
+
rpcUrl?: string;
|
|
509
|
+
enableAP2?: boolean;
|
|
510
|
+
enableProcessIntegrity?: boolean;
|
|
511
|
+
enablePayments?: boolean;
|
|
512
|
+
enableStorage?: boolean;
|
|
513
|
+
storageProvider?: StorageProvider;
|
|
514
|
+
computeProvider?: ComputeProvider;
|
|
515
|
+
walletFile?: string;
|
|
516
|
+
facilitatorUrl?: string;
|
|
517
|
+
facilitatorApiKey?: string;
|
|
518
|
+
facilitatorMode?: 'managed' | 'decentralized';
|
|
519
|
+
agentId?: string;
|
|
520
|
+
gatewayUrl?: string;
|
|
521
|
+
gatewayConfig?: GatewayClientConfig;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Wallet configuration
|
|
525
|
+
*/
|
|
526
|
+
interface WalletConfig {
|
|
527
|
+
privateKey?: string;
|
|
528
|
+
mnemonic?: string;
|
|
529
|
+
walletFile?: string;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Transaction result
|
|
533
|
+
*/
|
|
534
|
+
interface TransactionResult {
|
|
535
|
+
hash: string;
|
|
536
|
+
receipt?: ethers.TransactionReceipt;
|
|
537
|
+
confirmations?: number;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Workflow types supported by Gateway.
|
|
541
|
+
*/
|
|
542
|
+
declare enum WorkflowType {
|
|
543
|
+
WORK_SUBMISSION = "WorkSubmission",
|
|
544
|
+
SCORE_SUBMISSION = "ScoreSubmission",
|
|
545
|
+
CLOSE_EPOCH = "CloseEpoch"
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Workflow states.
|
|
549
|
+
*/
|
|
550
|
+
declare enum WorkflowState {
|
|
551
|
+
CREATED = "CREATED",
|
|
552
|
+
RUNNING = "RUNNING",
|
|
553
|
+
STALLED = "STALLED",
|
|
554
|
+
COMPLETED = "COMPLETED",
|
|
555
|
+
FAILED = "FAILED"
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Score submission modes supported by Gateway.
|
|
559
|
+
* - DIRECT: Simple direct scoring via submitScoreVectorForWorker (default, MVP)
|
|
560
|
+
* - COMMIT_REVEAL: Commit-reveal pattern (prevents last-mover bias)
|
|
561
|
+
*/
|
|
562
|
+
declare enum ScoreSubmissionMode {
|
|
563
|
+
DIRECT = "direct",
|
|
564
|
+
COMMIT_REVEAL = "commit_reveal"
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Progress data for a workflow.
|
|
568
|
+
* Populated as the workflow progresses through steps.
|
|
569
|
+
*/
|
|
570
|
+
interface WorkflowProgress {
|
|
571
|
+
/** Arweave transaction ID for evidence archival */
|
|
572
|
+
arweaveTxId?: string;
|
|
573
|
+
/** Whether Arweave transaction is confirmed */
|
|
574
|
+
arweaveConfirmed?: boolean;
|
|
575
|
+
/** On-chain transaction hash */
|
|
576
|
+
onchainTxHash?: string;
|
|
577
|
+
/** Whether on-chain transaction is confirmed */
|
|
578
|
+
onchainConfirmed?: boolean;
|
|
579
|
+
/** Block number of on-chain confirmation */
|
|
580
|
+
onchainBlock?: number;
|
|
581
|
+
/** Score submission transaction hash (direct mode) */
|
|
582
|
+
scoreTxHash?: string;
|
|
583
|
+
/** Commit transaction hash (commit-reveal mode) */
|
|
584
|
+
commitTxHash?: string;
|
|
585
|
+
/** Reveal transaction hash (commit-reveal mode) */
|
|
586
|
+
revealTxHash?: string;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Error information for a failed workflow.
|
|
590
|
+
*/
|
|
591
|
+
interface WorkflowError {
|
|
592
|
+
/** Step where the error occurred */
|
|
593
|
+
step: string;
|
|
594
|
+
/** Human-readable error message */
|
|
595
|
+
message: string;
|
|
596
|
+
/** Optional error code */
|
|
597
|
+
code?: string;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Status of a workflow.
|
|
601
|
+
*/
|
|
602
|
+
interface WorkflowStatus {
|
|
603
|
+
/** Unique workflow identifier (UUID) */
|
|
604
|
+
workflowId: string;
|
|
605
|
+
/** Type of workflow */
|
|
606
|
+
workflowType: WorkflowType;
|
|
607
|
+
/** Current state */
|
|
608
|
+
state: WorkflowState;
|
|
609
|
+
/** Current step name */
|
|
610
|
+
step: string;
|
|
611
|
+
/** Unix timestamp of creation */
|
|
612
|
+
createdAt: number;
|
|
613
|
+
/** Unix timestamp of last update */
|
|
614
|
+
updatedAt: number;
|
|
615
|
+
/** Progress information */
|
|
616
|
+
progress: WorkflowProgress;
|
|
617
|
+
/** Error information (if state is FAILED) */
|
|
618
|
+
error?: WorkflowError;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Gateway health response payload.
|
|
622
|
+
*/
|
|
623
|
+
interface GatewayHealthResponse {
|
|
624
|
+
status: string;
|
|
625
|
+
timestamp?: number;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Gateway auth mode.
|
|
629
|
+
*/
|
|
630
|
+
type GatewayAuthMode = 'apiKey' | 'signature';
|
|
631
|
+
/**
|
|
632
|
+
* Gateway signature auth input.
|
|
633
|
+
*/
|
|
634
|
+
interface GatewaySignatureAuth {
|
|
635
|
+
/** Precomputed signature for the request (server validates against address + timestamp). */
|
|
636
|
+
address: string;
|
|
637
|
+
signature: string;
|
|
638
|
+
/** Optional Unix epoch in milliseconds; defaults to Date.now() when omitted. */
|
|
639
|
+
timestamp?: number;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Gateway auth configuration.
|
|
643
|
+
*/
|
|
644
|
+
interface GatewayAuthConfig {
|
|
645
|
+
authMode?: GatewayAuthMode;
|
|
646
|
+
apiKey?: string;
|
|
647
|
+
signature?: GatewaySignatureAuth;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Gateway retry configuration.
|
|
651
|
+
*/
|
|
652
|
+
interface GatewayRetryConfig {
|
|
653
|
+
/** Retries are disabled by default; enable explicitly for transient errors only. */
|
|
654
|
+
enabled?: boolean;
|
|
655
|
+
maxRetries?: number;
|
|
656
|
+
initialDelayMs?: number;
|
|
657
|
+
maxDelayMs?: number;
|
|
658
|
+
backoffFactor?: number;
|
|
659
|
+
jitter?: boolean;
|
|
660
|
+
jitterRatio?: number;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Gateway client configuration.
|
|
664
|
+
*/
|
|
665
|
+
interface GatewayClientConfig {
|
|
666
|
+
/** Gateway API URL (preferred key, e.g. "https://gateway.chaoscha.in"). */
|
|
667
|
+
baseUrl?: string;
|
|
668
|
+
/** Legacy alias for baseUrl (kept for backward compatibility). */
|
|
669
|
+
gatewayUrl?: string;
|
|
670
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
671
|
+
timeout?: number;
|
|
672
|
+
/** Request timeout in milliseconds (alias of timeout) */
|
|
673
|
+
timeoutMs?: number;
|
|
674
|
+
/** Request timeout in seconds (alias of timeout) */
|
|
675
|
+
timeoutSeconds?: number;
|
|
676
|
+
/** Maximum time to wait for workflow completion in milliseconds (default: 300000) */
|
|
677
|
+
maxPollTime?: number;
|
|
678
|
+
/** Maximum time to wait for workflow completion in milliseconds (alias of maxPollTime) */
|
|
679
|
+
maxPollTimeMs?: number;
|
|
680
|
+
/** Maximum time to wait for workflow completion in seconds (alias of maxPollTime) */
|
|
681
|
+
maxPollTimeSeconds?: number;
|
|
682
|
+
/** Interval between status polls in milliseconds (default: 2000) */
|
|
683
|
+
pollInterval?: number;
|
|
684
|
+
/** Interval between status polls in milliseconds (alias of pollInterval) */
|
|
685
|
+
pollIntervalMs?: number;
|
|
686
|
+
/** Interval between status polls in seconds (alias of pollInterval) */
|
|
687
|
+
pollIntervalSeconds?: number;
|
|
688
|
+
/** Optional default headers merged into each request */
|
|
689
|
+
headers?: Record<string, string>;
|
|
690
|
+
/** Optional auth configuration */
|
|
691
|
+
auth?: GatewayAuthConfig;
|
|
692
|
+
/** Optional retry configuration (disabled by default) */
|
|
693
|
+
retry?: GatewayRetryConfig;
|
|
694
|
+
}
|
|
695
|
+
interface PendingWorkItem {
|
|
696
|
+
work_id: string;
|
|
697
|
+
agent_id: number;
|
|
698
|
+
epoch: number | null;
|
|
699
|
+
submitted_at: string;
|
|
700
|
+
evidence_anchor: string | null;
|
|
701
|
+
derivation_root: string | null;
|
|
702
|
+
}
|
|
703
|
+
interface PendingWorkResponse {
|
|
704
|
+
version: string;
|
|
705
|
+
data: {
|
|
706
|
+
studio: string;
|
|
707
|
+
work: PendingWorkItem[];
|
|
708
|
+
total: number;
|
|
709
|
+
limit: number;
|
|
710
|
+
offset: number;
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
interface WorkEvidenceResponse {
|
|
714
|
+
version: string;
|
|
715
|
+
data: {
|
|
716
|
+
work_id: string;
|
|
717
|
+
thread_root: string;
|
|
718
|
+
dkg_evidence: EvidencePackage[];
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* @deprecated XMTP functionality has moved to the Gateway service.
|
|
723
|
+
* This type is kept for backward compatibility only.
|
|
724
|
+
* Do NOT implement XMTP client in SDK - use Gateway instead.
|
|
725
|
+
*/
|
|
726
|
+
interface XMTPMessageData {
|
|
727
|
+
messageId: string;
|
|
728
|
+
fromAgent: string;
|
|
729
|
+
toAgent: string;
|
|
730
|
+
content: any;
|
|
731
|
+
timestamp: number;
|
|
732
|
+
parentIds: string[];
|
|
733
|
+
artifactIds: string[];
|
|
734
|
+
signature: string;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* @deprecated DKG functionality has moved to the Gateway service.
|
|
738
|
+
* This type is kept for backward compatibility only.
|
|
739
|
+
* Do NOT implement DKG in SDK - Gateway constructs the graph.
|
|
740
|
+
*/
|
|
741
|
+
interface DKGNodeData {
|
|
742
|
+
author: string;
|
|
743
|
+
sig: string;
|
|
744
|
+
ts: number;
|
|
745
|
+
xmtpMsgId: string;
|
|
746
|
+
artifactIds: string[];
|
|
747
|
+
payloadHash: string;
|
|
748
|
+
parents: string[];
|
|
749
|
+
content?: string;
|
|
750
|
+
nodeType?: string;
|
|
751
|
+
metadata?: Record<string, any>;
|
|
752
|
+
vlc?: string;
|
|
753
|
+
canonicalHash?: string;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
export { AgentRole as A, extractAgencySignals as B, type ContractAddresses as C, type DKGNodeData as D, composeScoreVector as E, type FeedbackParams as F, type GatewayClientConfig as G, rangeFit as H, type IntegrityProof as I, type EvidencePackage as J, type WorkEvidenceVerificationResult as K, type WorkVerificationResult as L, type AgencySignals as M, NetworkConfig as N, type VerifierAssessment as O, type PendingWorkResponse as P, type ScoreRange as Q, type EngineeringStudioPolicy as R, ScoreSubmissionMode as S, type TEEAttestation as T, type UploadOptions as U, type ValidationRequestParams as V, type WalletConfig as W, type X402PaymentParams as X, type WorkMandate as Y, type SignalExtractionContext as Z, type NetworkInfo as a, type GatewayHealthResponse as b, type WorkflowStatus as c, type WorkEvidenceResponse as d, type ChaosChainSDKConfig as e, type AgentMetadata as f, type AgentRegistration as g, PaymentMethod as h, type UploadResult as i, type WorkflowError as j, type FeedbackRecord as k, type ValidationRequest as l, type X402Payment as m, type StorageProvider as n, type ComputeProvider as o, type TransactionResult as p, ValidationStatus as q, WorkflowType as r, WorkflowState as s, type WorkflowProgress as t, type PendingWorkItem as u, type XMTPMessageData as v, computeDepth as w, derivePoAScores as x, validateEvidenceGraph as y, verifyWorkEvidence as z };
|