@chaoschain/sdk 0.3.1 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { N as NetworkConfig, I as IntegrityProof, W as WalletConfig, a as NetworkInfo, C as ContractAddresses, G as GatewayClientConfig, b as GatewayHealthResponse, c as WorkflowStatus, S as ScoreSubmissionMode, P as PendingWorkResponse, d as WorkEvidenceResponse, A as AgentRole, e as ChaosChainSDKConfig, f as AgentMetadata, g as AgentRegistration, F as FeedbackParams, h as PaymentMethod, U as UploadOptions, i as UploadResult, j as WorkflowError } from './types-BBVtx_jV.js';
2
- export { O as AgencySignals, o as ComputeProvider, D as DKGNodeData, R as DemoAssessment, Z as EngineeringStudioPolicy, K as EvidencePackage, k as FeedbackRecord, u as PendingWorkItem, Y as ScoreRange, $ as SignalExtractionContext, n as StorageProvider, T as TEEAttestation, p as TransactionResult, l as ValidationRequest, V as ValidationRequestParams, q as ValidationStatus, Q as VerifierAssessment, L as WorkEvidenceVerificationResult, _ as WorkMandate, M as WorkVerificationResult, t as WorkflowProgress, s as WorkflowState, r as WorkflowType, m as X402Payment, X as X402PaymentParams, v as XMTPMessageData, E as composeScoreVector, H as composeScoreVectorWithDefaults, w as computeDepth, x as derivePoAScores, B as extractAgencySignals, J as rangeFit, y as validateEvidenceGraph, z as verifyWorkEvidence } from './types-BBVtx_jV.js';
1
+ import { N as NetworkConfig, I as IntegrityProof, W as WalletConfig, b as NetworkInfo, c as ContractAddresses, A as AgentRole, d as ChaosChainSDKConfig, e as AgentMetadata, f as AgentRegistration, F as FeedbackParams, P as PaymentMethod, U as UploadOptions, a as UploadResult, g as WorkflowStatus, h as ScoreSubmissionMode } from './types-C0Ay90UI.js';
2
+ export { M as AgencySignals, C as ComputeProvider, D as DKGNodeData, Q as DemoAssessment, Y as EngineeringStudioPolicy, J as EvidencePackage, i as FeedbackRecord, G as GatewayClientConfig, r as PendingWorkItem, s as PendingWorkResponse, R as ScoreRange, _ as SignalExtractionContext, S as StorageProvider, T as TEEAttestation, l as TransactionResult, j as ValidationRequest, V as ValidationRequestParams, m as ValidationStatus, O as VerifierAssessment, t as WorkEvidenceResponse, K as WorkEvidenceVerificationResult, Z as WorkMandate, L as WorkVerificationResult, q as WorkflowError, p as WorkflowProgress, o as WorkflowState, n as WorkflowType, k as X402Payment, X as X402PaymentParams, u as XMTPMessageData, B as composeScoreVector, E as composeScoreVectorWithDefaults, v as computeDepth, w as derivePoAScores, z as extractAgencySignals, H as rangeFit, x as validateEvidenceGraph, y as verifyWorkEvidence } from './types-C0Ay90UI.js';
3
3
  import { ethers } from 'ethers';
4
- export { I as IPFSLocalStorage } from './IPFSLocal-B4hnMEfS.js';
4
+ import { G as GatewayClient } from './index-CL0fidQs.js';
5
+ export { A as AgentRegistrationError, C as ChaosChainSDKError, b as ConfigurationError, a as ContractError, d as GatewayConnectionError, c as GatewayError, e as GatewayTimeoutError, I as IntegrityVerificationError, P as PaymentError, V as SDKValidationError, S as StorageError, W as WorkflowFailedError } from './index-CL0fidQs.js';
6
+ import { SessionClient } from './session/index.js';
7
+ export { Session, SessionAgentOverride, SessionAgentRole, SessionClientConfig, SessionCompleteResult, SessionLogOptions, SessionStartOptions } from './session/index.js';
8
+ export { I as IPFSLocalStorage } from './IPFSLocal-B_Sgmd_Q.js';
5
9
 
6
10
  /**
7
11
  * X402 Payment Manager for ChaosChain SDK
@@ -715,152 +719,6 @@ declare function getNetworkInfo(network: NetworkConfig | string): NetworkInfo;
715
719
  */
716
720
  declare function getContractAddresses(network: NetworkConfig | string): ContractAddresses;
717
721
 
718
- declare class GatewayClient {
719
- private gatewayUrl;
720
- private timeout;
721
- private maxPollTime;
722
- private pollInterval;
723
- private defaultHeaders?;
724
- private auth?;
725
- private retryConfig?;
726
- constructor(config: GatewayClientConfig);
727
- private _resolveTimeout;
728
- private _resolveAuthMode;
729
- private _buildHeaders;
730
- private _classifyStatusCode;
731
- private _normalizeError;
732
- private _getRetryDelayMs;
733
- private _sleep;
734
- /**
735
- * Make HTTP request to Gateway.
736
- * Handles errors and transforms them to Gateway exceptions.
737
- */
738
- private _request;
739
- /**
740
- * Parse workflow status from API response.
741
- */
742
- private _parseWorkflowStatus;
743
- healthCheck(): Promise<GatewayHealthResponse>;
744
- isHealthy(): Promise<boolean>;
745
- /**
746
- * Create a work submission workflow.
747
- * POST /workflows/work-submission
748
- *
749
- * SDK prepares inputs; Gateway handles:
750
- * - Evidence upload to Arweave
751
- * - Transaction submission
752
- * - Confirmation waiting
753
- *
754
- * @param studioAddress - Ethereum address of the studio
755
- * @param epoch - Epoch number
756
- * @param agentAddress - Ethereum address of the submitting agent
757
- * @param dataHash - Bytes32 hash of the work (as hex string)
758
- * @param threadRoot - Bytes32 DKG thread root (as hex string)
759
- * @param evidenceRoot - Bytes32 evidence Merkle root (as hex string)
760
- * @param evidenceContent - Raw evidence bytes (will be base64 encoded)
761
- * @param signerAddress - Ethereum address of the signer (must be registered in Gateway)
762
- * @returns WorkflowStatus - Initial status of the created workflow
763
- */
764
- submitWork(studioAddress: string, epoch: number, agentAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, evidenceContent: Buffer | string, signerAddress: string): Promise<WorkflowStatus>;
765
- /**
766
- * Create a score submission workflow.
767
- * POST /workflows/score-submission
768
- *
769
- * Supports two modes:
770
- * - DIRECT (default): Simple direct scoring, requires workerAddress
771
- * - COMMIT_REVEAL: Commit-reveal pattern, requires salt
772
- *
773
- * @param studioAddress - Ethereum address of the studio
774
- * @param epoch - Epoch number
775
- * @param validatorAddress - Ethereum address of the validator
776
- * @param dataHash - Bytes32 hash of the work being scored (as hex string)
777
- * @param scores - Array of dimension scores (0-10000 basis points)
778
- * @param signerAddress - Ethereum address of the signer
779
- * @param options - Additional options (workerAddress, salt, mode)
780
- */
781
- submitScore(studioAddress: string, epoch: number, validatorAddress: string, dataHash: string, scores: number[], signerAddress: string, options?: {
782
- workerAddress?: string;
783
- salt?: string;
784
- mode?: ScoreSubmissionMode;
785
- }): Promise<WorkflowStatus>;
786
- /**
787
- * Create a close epoch workflow.
788
- * POST /workflows/close-epoch
789
- *
790
- * This is economically final — cannot be undone.
791
- *
792
- * @param studioAddress - Ethereum address of the studio
793
- * @param epoch - Epoch number to close
794
- * @param signerAddress - Ethereum address of the signer
795
- */
796
- closeEpoch(studioAddress: string, epoch: number, signerAddress: string): Promise<WorkflowStatus>;
797
- /**
798
- * Get workflow status by ID.
799
- * GET /workflows/{id}
800
- */
801
- getWorkflow(workflowId: string): Promise<WorkflowStatus>;
802
- /**
803
- * List workflows with optional filters.
804
- * GET /workflows?studio=&state=&type=
805
- */
806
- listWorkflows(options?: {
807
- studio?: string;
808
- state?: string;
809
- workflowType?: string;
810
- }): Promise<WorkflowStatus[]>;
811
- /**
812
- * Poll workflow until it reaches a terminal state.
813
- *
814
- * @param workflowId - UUID of the workflow
815
- * @param options - Polling options
816
- * @throws WorkflowFailedError - If workflow reaches FAILED state
817
- * @throws GatewayTimeoutError - If maxWait exceeded
818
- */
819
- waitForCompletion(workflowId: string, options?: {
820
- maxWait?: number;
821
- pollInterval?: number;
822
- onProgress?: (status: WorkflowStatus) => void;
823
- }): Promise<WorkflowStatus>;
824
- /**
825
- * Submit work and wait for completion.
826
- */
827
- submitWorkAndWait(studioAddress: string, epoch: number, agentAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, evidenceContent: Buffer | string, signerAddress: string, options?: {
828
- onProgress?: (status: WorkflowStatus) => void;
829
- }): Promise<WorkflowStatus>;
830
- /**
831
- * Submit score and wait for completion.
832
- */
833
- submitScoreAndWait(studioAddress: string, epoch: number, validatorAddress: string, dataHash: string, scores: number[], signerAddress: string, options?: {
834
- workerAddress?: string;
835
- workAddress?: string;
836
- salt?: string;
837
- mode?: ScoreSubmissionMode;
838
- onProgress?: (status: WorkflowStatus) => void;
839
- }): Promise<WorkflowStatus>;
840
- /**
841
- * Close epoch and wait for completion.
842
- */
843
- closeEpochAndWait(studioAddress: string, epoch: number, signerAddress: string, options?: {
844
- onProgress?: (status: WorkflowStatus) => void;
845
- }): Promise<WorkflowStatus>;
846
- /**
847
- * Fetch pending (unfinalized) work for a studio from the gateway.
848
- *
849
- * @param studioAddress - 0x-prefixed studio contract address
850
- * @param options - Optional limit/offset for pagination
851
- * @returns Typed pending work response
852
- */
853
- getPendingWork(studioAddress: string, options?: {
854
- limit?: number;
855
- offset?: number;
856
- }): Promise<PendingWorkResponse>;
857
- /**
858
- * Fetch full evidence graph for a work submission.
859
- * Endpoint: GET /v1/work/{hash}/evidence
860
- */
861
- getWorkEvidence(workHash: string): Promise<WorkEvidenceResponse>;
862
- }
863
-
864
722
  interface StudioClientConfig {
865
723
  provider: ethers.Provider;
866
724
  signer: ethers.Signer;
@@ -1032,174 +890,6 @@ declare class StudioClient {
1032
890
  generateSalt(): string;
1033
891
  }
1034
892
 
1035
- /**
1036
- * Session — high-level wrapper for ChaosChain Engineering Studio sessions.
1037
- *
1038
- * Agents use this class to log work events without constructing raw event schemas,
1039
- * managing parent IDs, or thinking about DAGs. The gateway handles all of that.
1040
- *
1041
- * @example
1042
- * ```ts
1043
- * const session = await client.start({ studio_address: '0x...', agent_address: '0x...' });
1044
- * await session.log({ summary: 'Planning cache layer implementation' });
1045
- * await session.step('implementing', 'Added CacheService class');
1046
- * await session.step('testing', 'All 47 tests pass');
1047
- * const { workflow_id, data_hash } = await session.complete();
1048
- * ```
1049
- */
1050
- /** Valid agent roles accepted by the gateway for session events. */
1051
- type SessionAgentRole = 'worker' | 'verifier' | 'collaborator';
1052
- /** Per-event agent override. */
1053
- interface SessionAgentOverride {
1054
- /** Wallet address of the agent emitting this event. */
1055
- agent_address: string;
1056
- /** Agent role (defaults to `"worker"`). Must be `worker`, `verifier`, or `collaborator`. */
1057
- role?: SessionAgentRole;
1058
- }
1059
- /** Options for {@link Session.log}. */
1060
- interface SessionLogOptions {
1061
- /** Human-readable description of what happened. */
1062
- summary: string;
1063
- /** Canonical event type. Defaults to `"artifact_created"`. */
1064
- event_type?: string;
1065
- /** Arbitrary metadata attached to the event. */
1066
- metadata?: Record<string, unknown>;
1067
- /** Override the session-level agent for this event. */
1068
- agent?: SessionAgentOverride;
1069
- }
1070
- /** Result returned by {@link Session.complete}. */
1071
- interface SessionCompleteResult {
1072
- workflow_id: string | null;
1073
- data_hash: string | null;
1074
- }
1075
- declare class Session {
1076
- /** Session ID returned by the gateway. */
1077
- readonly sessionId: string;
1078
- private readonly gatewayUrl;
1079
- private readonly apiKey;
1080
- private readonly studioAddress;
1081
- private readonly agentAddress;
1082
- private readonly studioPolicyVersion;
1083
- private readonly workMandateId;
1084
- private readonly taskType;
1085
- private lastEventId;
1086
- /** @internal — use {@link SessionClient.start} to create instances. */
1087
- constructor(opts: {
1088
- sessionId: string;
1089
- gatewayUrl: string;
1090
- apiKey?: string;
1091
- lastEventId?: string | null;
1092
- studioAddress: string;
1093
- agentAddress: string;
1094
- studioPolicyVersion: string;
1095
- workMandateId: string;
1096
- taskType: string;
1097
- });
1098
- /**
1099
- * Log a session event.
1100
- *
1101
- * Automatically generates `event_id`, `timestamp`, and chains `parent_event_ids`
1102
- * from the previous event so the gateway can build a causal DAG.
1103
- *
1104
- * @param opts - Event details. Only `summary` is required.
1105
- * @throws Error if the gateway returns a non-2xx status.
1106
- */
1107
- log(opts: SessionLogOptions): Promise<void>;
1108
- /**
1109
- * Convenience wrapper around {@link log} that maps human-friendly step names
1110
- * to canonical event types.
1111
- *
1112
- * Mappings:
1113
- * - `"planning"` → `plan_created`
1114
- * - `"testing"` → `test_run`
1115
- * - `"debugging"` → `debug_step`
1116
- * - `"implementing"` → `file_written`
1117
- * - `"completing"` → `submission_created`
1118
- *
1119
- * Unknown step types fall back to `artifact_created`.
1120
- *
1121
- * @param stepType - Friendly step name.
1122
- * @param summary - What happened in this step.
1123
- */
1124
- step(stepType: string, summary: string, agent?: SessionAgentOverride): Promise<void>;
1125
- /**
1126
- * Complete the session.
1127
- *
1128
- * Triggers the on-chain WorkSubmission workflow (if the gateway is configured for it)
1129
- * and returns `workflow_id` + `data_hash` for downstream verification/scoring.
1130
- *
1131
- * @param opts - Optional status (`"completed"` | `"failed"`) and summary.
1132
- * @returns `{ workflow_id, data_hash }` — both may be `null` if the gateway
1133
- * workflow engine is not configured.
1134
- * @throws Error if the gateway returns a non-2xx status.
1135
- */
1136
- complete(opts?: {
1137
- status?: 'completed' | 'failed';
1138
- summary?: string;
1139
- }): Promise<SessionCompleteResult>;
1140
- private post;
1141
- }
1142
-
1143
- /**
1144
- * SessionClient — factory for creating ChaosChain Engineering Studio sessions.
1145
- *
1146
- * @example
1147
- * ```ts
1148
- * import { SessionClient } from '@chaoschain/sdk';
1149
- *
1150
- * const client = new SessionClient({ gatewayUrl: 'https://gateway.chaoscha.in', apiKey: 'cc_...' });
1151
- * const session = await client.start({
1152
- * studio_address: '0xFA0795fD5D7F58eCAa7Eae35Ad9cB8AED9424Dd0',
1153
- * agent_address: '0x9B4Cef62a0ce1671ccFEFA6a6D8cBFa165c49831',
1154
- * task_type: 'feature',
1155
- * });
1156
- *
1157
- * await session.log({ summary: 'Started implementing cache layer' });
1158
- * await session.step('testing', 'All tests pass');
1159
- * const result = await session.complete();
1160
- * ```
1161
- */
1162
-
1163
- /** Configuration for {@link SessionClient}. */
1164
- interface SessionClientConfig {
1165
- /** Gateway base URL (default: `"https://gateway.chaoscha.in"`). */
1166
- gatewayUrl?: string;
1167
- /** API key sent as `X-API-Key` header. */
1168
- apiKey?: string;
1169
- }
1170
- /** Options for {@link SessionClient.start}. */
1171
- interface SessionStartOptions {
1172
- /** Studio contract address (required). */
1173
- studio_address: string;
1174
- /** Worker agent wallet address (required). */
1175
- agent_address: string;
1176
- /** Work mandate ID (default: `"generic-task"`). */
1177
- work_mandate_id?: string;
1178
- /** Task classification (default: `"general"`). */
1179
- task_type?: string;
1180
- /** Studio policy version (default: `"engineering-studio-default-v1"`). */
1181
- studio_policy_version?: string;
1182
- /** Client-provided session ID. Server generates one if omitted. */
1183
- session_id?: string;
1184
- }
1185
- declare class SessionClient {
1186
- private readonly gatewayUrl;
1187
- private readonly apiKey;
1188
- constructor(config?: SessionClientConfig);
1189
- /**
1190
- * Create a new coding session on the gateway.
1191
- *
1192
- * Returns a {@link Session} instance that can be used to log events, run steps,
1193
- * and complete the session. The gateway persists all events and constructs the
1194
- * Evidence DAG automatically.
1195
- *
1196
- * @param opts - Session creation parameters.
1197
- * @returns A live {@link Session} bound to the newly created session ID.
1198
- * @throws Error if the gateway returns a non-2xx status.
1199
- */
1200
- start(opts: SessionStartOptions): Promise<Session>;
1201
- }
1202
-
1203
893
  /**
1204
894
  * Main ChaosChain SDK Class - Complete TypeScript implementation
1205
895
  *
@@ -1957,80 +1647,6 @@ declare class AutoStorageManager implements StorageBackend {
1957
1647
  getAvailableBackends(): string[];
1958
1648
  }
1959
1649
 
1960
- /**
1961
- * Exception classes for the ChaosChain SDK.
1962
- *
1963
- * This module defines all custom exceptions used throughout the SDK
1964
- * to provide clear error handling and debugging information.
1965
- */
1966
- declare class ChaosChainSDKError extends Error {
1967
- details: Record<string, any>;
1968
- constructor(message: string, details?: Record<string, any>);
1969
- toString(): string;
1970
- }
1971
- declare class AgentRegistrationError extends ChaosChainSDKError {
1972
- constructor(message: string, details?: Record<string, any>);
1973
- }
1974
- declare class PaymentError extends ChaosChainSDKError {
1975
- constructor(message: string, details?: Record<string, any>);
1976
- }
1977
- declare class StorageError extends ChaosChainSDKError {
1978
- constructor(message: string, details?: Record<string, any>);
1979
- }
1980
- declare class IntegrityVerificationError extends ChaosChainSDKError {
1981
- constructor(message: string, details?: Record<string, any>);
1982
- }
1983
- declare class ContractError extends ChaosChainSDKError {
1984
- constructor(message: string, details?: Record<string, any>);
1985
- }
1986
- declare class ValidationError extends ChaosChainSDKError {
1987
- constructor(message: string, details?: Record<string, any>);
1988
- }
1989
- declare class ConfigurationError extends ChaosChainSDKError {
1990
- constructor(message: string, details?: Record<string, any>);
1991
- }
1992
- /**
1993
- * Options passed when constructing a GatewayError (statusCode, response, category, retryable).
1994
- */
1995
- interface GatewayErrorDetails {
1996
- statusCode?: number;
1997
- response?: Record<string, any>;
1998
- category?: 'transient' | 'permanent' | 'auth' | 'unknown';
1999
- retryable?: boolean;
2000
- }
2001
- /**
2002
- * Base error from Gateway API.
2003
- */
2004
- declare class GatewayError extends ChaosChainSDKError {
2005
- readonly statusCode?: number;
2006
- readonly response?: Record<string, any>;
2007
- readonly category?: 'transient' | 'permanent' | 'auth' | 'unknown';
2008
- readonly retryable?: boolean;
2009
- constructor(message: string, details?: GatewayErrorDetails);
2010
- }
2011
- /**
2012
- * Failed to connect to Gateway.
2013
- */
2014
- declare class GatewayConnectionError extends GatewayError {
2015
- constructor(message: string);
2016
- }
2017
- /**
2018
- * Gateway request or polling timed out.
2019
- */
2020
- declare class GatewayTimeoutError extends GatewayError {
2021
- readonly workflowId: string;
2022
- readonly lastStatus?: WorkflowStatus;
2023
- constructor(workflowId: string, message: string, lastStatus?: WorkflowStatus);
2024
- }
2025
- /**
2026
- * Workflow reached FAILED state.
2027
- */
2028
- declare class WorkflowFailedError extends GatewayError {
2029
- readonly workflowId: string;
2030
- readonly workflowError: WorkflowError;
2031
- constructor(workflowId: string, error: WorkflowError);
2032
- }
2033
-
2034
1650
  /**
2035
1651
  * ERC-8004 v1.0 Contract ABIs and Addresses
2036
1652
  *
@@ -2707,7 +2323,7 @@ declare class StudioManager {
2707
2323
  * @packageDocumentation
2708
2324
  */
2709
2325
 
2710
- declare const SDK_VERSION = "0.3.1";
2326
+ declare const SDK_VERSION = "0.3.3";
2711
2327
  declare const ERC8004_VERSION = "1.0";
2712
2328
  declare const X402_VERSION = "1.0";
2713
2329
 
@@ -2744,4 +2360,4 @@ declare function initChaosChainSDK(config: {
2744
2360
  enableStorage?: boolean;
2745
2361
  }): ChaosChainSDK;
2746
2362
 
2747
- export { A2AX402Extension, AgentMetadata, AgentRegistration, AgentRegistrationError, AgentRole, AutoStorageManager, CHAOS_CORE_ABI, ChaosAgent, ChaosChainSDK, ChaosChainSDKConfig, ChaosChainSDKError, ConfigurationError, ContractAddresses, ContractError, ERC8004_VERSION, FeedbackParams, GatewayClient, GatewayClientConfig, GatewayConnectionError, GatewayError, GatewayTimeoutError, GoogleAP2Integration, IDENTITY_REGISTRY_ABI, PinataStorage as IPFSPinataStorage, IntegrityProof, IntegrityVerificationError, IrysStorage, IrysStorage as IrysStorageProvider, LocalIPFSStorage, MandateManager, NetworkConfig, PaymentError, type PaymentHeader, PaymentManager, PaymentMethod, PendingWorkResponse, PinataStorage, REPUTATION_REGISTRY_ABI, REWARDS_DISTRIBUTOR_ABI, ValidationError as SDKValidationError, SDK_VERSION, STUDIO_FACTORY_ABI, STUDIO_PROXY_ABI, Session, type SessionAgentOverride, type SessionAgentRole, SessionClient, type SessionClientConfig, type SessionCompleteResult, type SessionLogOptions, type SessionStartOptions, type SettleRequest, type SettleResponse, type StorageBackend, StorageError, type StorageResult, StudioClient, type StudioClientConfig, StudioManager, type StudioManagerConfig, type Task, type TransferAuthorizationParams, UploadOptions, UploadResult, VALIDATION_REGISTRY_ABI, WalletConfig, WalletManager, WorkEvidenceResponse, type WorkerBid, WorkflowError, WorkflowFailedError, WorkflowStatus, type X402FacilitatorConfig, X402PaymentManager, type X402PaymentProof, type X402PaymentRequest$1 as X402PaymentRequest, type X402PaymentRequirements, X402Server, X402_VERSION, ZeroGStorage, ChaosChainSDK as default, getContractAddresses, getNetworkInfo, initChaosChainSDK };
2363
+ export { A2AX402Extension, AgentMetadata, AgentRegistration, AgentRole, AutoStorageManager, CHAOS_CORE_ABI, ChaosAgent, ChaosChainSDK, ChaosChainSDKConfig, ContractAddresses, ERC8004_VERSION, FeedbackParams, GatewayClient, GoogleAP2Integration, IDENTITY_REGISTRY_ABI, PinataStorage as IPFSPinataStorage, IntegrityProof, IrysStorage, IrysStorage as IrysStorageProvider, LocalIPFSStorage, MandateManager, NetworkConfig, type PaymentHeader, PaymentManager, PaymentMethod, PinataStorage, REPUTATION_REGISTRY_ABI, REWARDS_DISTRIBUTOR_ABI, SDK_VERSION, STUDIO_FACTORY_ABI, STUDIO_PROXY_ABI, SessionClient, type SettleRequest, type SettleResponse, type StorageBackend, type StorageResult, StudioClient, type StudioClientConfig, StudioManager, type StudioManagerConfig, type Task, type TransferAuthorizationParams, UploadOptions, UploadResult, VALIDATION_REGISTRY_ABI, WalletConfig, WalletManager, type WorkerBid, WorkflowStatus, type X402FacilitatorConfig, X402PaymentManager, type X402PaymentProof, type X402PaymentRequest$1 as X402PaymentRequest, type X402PaymentRequirements, X402Server, X402_VERSION, ZeroGStorage, ChaosChainSDK as default, getContractAddresses, getNetworkInfo, initChaosChainSDK };
package/dist/index.js CHANGED
@@ -15375,10 +15375,16 @@ var STEP_TYPE_MAP = {
15375
15375
  var Session = class {
15376
15376
  /** Session ID returned by the gateway. */
15377
15377
  sessionId;
15378
- gatewayUrl;
15379
- apiKey;
15378
+ /** Epoch number returned by the gateway. */
15379
+ epoch;
15380
+ /** Studio contract address for this session. */
15380
15381
  studioAddress;
15382
+ /** Default agent wallet address for this session. */
15381
15383
  agentAddress;
15384
+ /** URL to view this session's Evidence DAG in the browser. */
15385
+ viewerUrl;
15386
+ gatewayUrl;
15387
+ apiKey;
15382
15388
  studioPolicyVersion;
15383
15389
  workMandateId;
15384
15390
  taskType;
@@ -15386,6 +15392,8 @@ var Session = class {
15386
15392
  /** @internal — use {@link SessionClient.start} to create instances. */
15387
15393
  constructor(opts) {
15388
15394
  this.sessionId = opts.sessionId;
15395
+ this.epoch = opts.epoch;
15396
+ this.viewerUrl = `${opts.gatewayUrl}/v1/sessions/${opts.sessionId}/viewer`;
15389
15397
  this.gatewayUrl = opts.gatewayUrl;
15390
15398
  this.apiKey = opts.apiKey;
15391
15399
  this.lastEventId = opts.lastEventId ?? null;
@@ -15401,7 +15409,12 @@ var Session = class {
15401
15409
  * Automatically generates `event_id`, `timestamp`, and chains `parent_event_ids`
15402
15410
  * from the previous event so the gateway can build a causal DAG.
15403
15411
  *
15404
- * @param opts - Event details. Only `summary` is required.
15412
+ * @param opts.summary - Human-readable description of what happened (required).
15413
+ * @param opts.event_type - Canonical event type (default: `"artifact_created"`).
15414
+ * @param opts.metadata - Arbitrary key-value metadata attached to the event.
15415
+ * @param opts.agent - Override the session-level agent for this event.
15416
+ * Pass `{ agent_address, role? }` to emit the event from a different agent.
15417
+ * Valid roles: `"worker"`, `"verifier"`, `"collaborator"`. Defaults to `"worker"`.
15405
15418
  * @throws Error if the gateway returns a non-2xx status.
15406
15419
  */
15407
15420
  async log(opts) {
@@ -15444,8 +15457,9 @@ var Session = class {
15444
15457
  *
15445
15458
  * Unknown step types fall back to `artifact_created`.
15446
15459
  *
15447
- * @param stepType - Friendly step name.
15460
+ * @param stepType - Friendly step name (`"planning"`, `"implementing"`, `"testing"`, `"debugging"`, `"completing"`).
15448
15461
  * @param summary - What happened in this step.
15462
+ * @param agent - Optional agent override for this event. Same as `log({ agent })`.
15449
15463
  */
15450
15464
  async step(stepType, summary, agent) {
15451
15465
  const eventType = STEP_TYPE_MAP[stepType] ?? "artifact_created";
@@ -15455,11 +15469,13 @@ var Session = class {
15455
15469
  * Complete the session.
15456
15470
  *
15457
15471
  * Triggers the on-chain WorkSubmission workflow (if the gateway is configured for it)
15458
- * and returns `workflow_id` + `data_hash` for downstream verification/scoring.
15472
+ * and returns the session result.
15459
15473
  *
15460
- * @param opts - Optional status (`"completed"` | `"failed"`) and summary.
15461
- * @returns `{ workflow_id, data_hash }` both may be `null` if the gateway
15462
- * workflow engine is not configured.
15474
+ * @param opts.status - `"completed"` or `"failed"` (default: `"completed"`).
15475
+ * @param opts.summary - Human-readable summary of the session outcome.
15476
+ * @returns `{ workflow_id, data_hash, epoch }` — `workflow_id` and `data_hash`
15477
+ * may be `null` if the gateway workflow engine is not configured.
15478
+ * `epoch` is the epoch this session belongs to.
15463
15479
  * @throws Error if the gateway returns a non-2xx status.
15464
15480
  */
15465
15481
  async complete(opts) {
@@ -15469,7 +15485,8 @@ var Session = class {
15469
15485
  const data = await this.post(`/v1/sessions/${this.sessionId}/complete`, body);
15470
15486
  return {
15471
15487
  workflow_id: data.data?.workflow_id ?? null,
15472
- data_hash: data.data?.data_hash ?? null
15488
+ data_hash: data.data?.data_hash ?? null,
15489
+ epoch: data.data.epoch
15473
15490
  };
15474
15491
  }
15475
15492
  // ---------------------------------------------------------------------------
@@ -15506,8 +15523,16 @@ var SessionClient = class {
15506
15523
  * and complete the session. The gateway persists all events and constructs the
15507
15524
  * Evidence DAG automatically.
15508
15525
  *
15509
- * @param opts - Session creation parameters.
15510
- * @returns A live {@link Session} bound to the newly created session ID.
15526
+ * The returned session exposes `session.sessionId`, `session.epoch`,
15527
+ * `session.studioAddress`, and `session.agentAddress`.
15528
+ *
15529
+ * @param opts.studio_address - Studio contract address (required).
15530
+ * @param opts.agent_address - Worker agent wallet address (required).
15531
+ * @param opts.task_type - Task classification: `"feature"`, `"bugfix"`, `"refactor"`, etc. (default: `"general"`).
15532
+ * @param opts.work_mandate_id - Work mandate identifier (default: `"generic-task"`).
15533
+ * @param opts.studio_policy_version - Studio policy version (default: `"engineering-studio-default-v1"`).
15534
+ * @param opts.session_id - Client-provided session ID. Server generates one if omitted.
15535
+ * @returns A live {@link Session} bound to the newly created session ID and epoch.
15511
15536
  * @throws Error if the gateway returns a non-2xx status.
15512
15537
  */
15513
15538
  async start(opts) {
@@ -15544,7 +15569,8 @@ var SessionClient = class {
15544
15569
  agentAddress: opts.agent_address,
15545
15570
  studioPolicyVersion: opts.studio_policy_version ?? "engineering-studio-default-v1",
15546
15571
  workMandateId: opts.work_mandate_id ?? "generic-task",
15547
- taskType: opts.task_type ?? "general"
15572
+ taskType: opts.task_type ?? "general",
15573
+ epoch: data.data.epoch
15548
15574
  });
15549
15575
  }
15550
15576
  };
@@ -16157,7 +16183,7 @@ var ChaosChainSDK = class _ChaosChainSDK {
16157
16183
  * Get SDK version
16158
16184
  */
16159
16185
  getVersion() {
16160
- return "0.3.1";
16186
+ return "0.3.3";
16161
16187
  }
16162
16188
  /**
16163
16189
  * Get SDK capabilities summary
@@ -16955,7 +16981,7 @@ function verifyWorkEvidence(evidence, context) {
16955
16981
  }
16956
16982
 
16957
16983
  // src/index.ts
16958
- var SDK_VERSION = "0.3.1";
16984
+ var SDK_VERSION = "0.3.3";
16959
16985
  var ERC8004_VERSION = "1.0";
16960
16986
  var X402_VERSION = "1.0";
16961
16987
  var src_default = ChaosChainSDK;