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