@chaoschain/sdk 0.2.4 → 0.3.1
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/CHANGELOG.md +53 -0
- package/README.md +135 -1
- package/dist/{IPFSLocal-BqyHRp_l.d.ts → IPFSLocal-B4hnMEfS.d.ts} +1 -1
- package/dist/{IPFSLocal-azjjaiGR.d.cts → IPFSLocal-zRj6kG8e.d.cts} +1 -1
- package/dist/index.cjs +198 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -6
- package/dist/index.d.ts +178 -6
- package/dist/index.js +198 -18
- package/dist/index.js.map +1 -1
- package/dist/providers/compute/index.d.cts +1 -1
- package/dist/providers/compute/index.d.ts +1 -1
- package/dist/providers/storage/index.d.cts +2 -2
- package/dist/providers/storage/index.d.ts +2 -2
- package/dist/{types-DZze-Z8B.d.cts → types-BBVtx_jV.d.cts} +10 -2
- package/dist/{types-DZze-Z8B.d.ts → types-BBVtx_jV.d.ts} +10 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
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-
|
|
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.cjs';
|
|
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.cjs';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
|
-
export { I as IPFSLocalStorage } from './IPFSLocal-
|
|
4
|
+
export { I as IPFSLocalStorage } from './IPFSLocal-zRj6kG8e.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* X402 Payment Manager for ChaosChain SDK
|
|
@@ -1032,6 +1032,174 @@ declare class StudioClient {
|
|
|
1032
1032
|
generateSalt(): string;
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
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
|
+
|
|
1035
1203
|
/**
|
|
1036
1204
|
* Main ChaosChain SDK Class - Complete TypeScript implementation
|
|
1037
1205
|
*
|
|
@@ -1059,7 +1227,9 @@ declare class ChaosChainSDK {
|
|
|
1059
1227
|
a2aX402Extension?: A2AX402Extension;
|
|
1060
1228
|
processIntegrity?: ProcessIntegrity;
|
|
1061
1229
|
mandateManager?: MandateManager;
|
|
1062
|
-
gateway: GatewayClient
|
|
1230
|
+
gateway: GatewayClient;
|
|
1231
|
+
/** Session client for Engineering Studio session management. */
|
|
1232
|
+
session: SessionClient;
|
|
1063
1233
|
studio: StudioClient;
|
|
1064
1234
|
readonly agentName: string;
|
|
1065
1235
|
readonly agentDomain: string;
|
|
@@ -1273,6 +1443,8 @@ declare class ChaosChainSDK {
|
|
|
1273
1443
|
getCapabilities(): Record<string, any>;
|
|
1274
1444
|
/**
|
|
1275
1445
|
* Check if Gateway is configured.
|
|
1446
|
+
* Always returns true in v0.3.0+. Gateway is always initialized pointing to
|
|
1447
|
+
* https://gateway.chaoscha.in unless overridden via gatewayConfig.
|
|
1276
1448
|
*/
|
|
1277
1449
|
isGatewayEnabled(): boolean;
|
|
1278
1450
|
/**
|
|
@@ -2535,7 +2707,7 @@ declare class StudioManager {
|
|
|
2535
2707
|
* @packageDocumentation
|
|
2536
2708
|
*/
|
|
2537
2709
|
|
|
2538
|
-
declare const SDK_VERSION = "0.
|
|
2710
|
+
declare const SDK_VERSION = "0.3.1";
|
|
2539
2711
|
declare const ERC8004_VERSION = "1.0";
|
|
2540
2712
|
declare const X402_VERSION = "1.0";
|
|
2541
2713
|
|
|
@@ -2572,4 +2744,4 @@ declare function initChaosChainSDK(config: {
|
|
|
2572
2744
|
enableStorage?: boolean;
|
|
2573
2745
|
}): ChaosChainSDK;
|
|
2574
2746
|
|
|
2575
|
-
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, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
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-
|
|
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';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
|
-
export { I as IPFSLocalStorage } from './IPFSLocal-
|
|
4
|
+
export { I as IPFSLocalStorage } from './IPFSLocal-B4hnMEfS.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* X402 Payment Manager for ChaosChain SDK
|
|
@@ -1032,6 +1032,174 @@ declare class StudioClient {
|
|
|
1032
1032
|
generateSalt(): string;
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
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
|
+
|
|
1035
1203
|
/**
|
|
1036
1204
|
* Main ChaosChain SDK Class - Complete TypeScript implementation
|
|
1037
1205
|
*
|
|
@@ -1059,7 +1227,9 @@ declare class ChaosChainSDK {
|
|
|
1059
1227
|
a2aX402Extension?: A2AX402Extension;
|
|
1060
1228
|
processIntegrity?: ProcessIntegrity;
|
|
1061
1229
|
mandateManager?: MandateManager;
|
|
1062
|
-
gateway: GatewayClient
|
|
1230
|
+
gateway: GatewayClient;
|
|
1231
|
+
/** Session client for Engineering Studio session management. */
|
|
1232
|
+
session: SessionClient;
|
|
1063
1233
|
studio: StudioClient;
|
|
1064
1234
|
readonly agentName: string;
|
|
1065
1235
|
readonly agentDomain: string;
|
|
@@ -1273,6 +1443,8 @@ declare class ChaosChainSDK {
|
|
|
1273
1443
|
getCapabilities(): Record<string, any>;
|
|
1274
1444
|
/**
|
|
1275
1445
|
* Check if Gateway is configured.
|
|
1446
|
+
* Always returns true in v0.3.0+. Gateway is always initialized pointing to
|
|
1447
|
+
* https://gateway.chaoscha.in unless overridden via gatewayConfig.
|
|
1276
1448
|
*/
|
|
1277
1449
|
isGatewayEnabled(): boolean;
|
|
1278
1450
|
/**
|
|
@@ -2535,7 +2707,7 @@ declare class StudioManager {
|
|
|
2535
2707
|
* @packageDocumentation
|
|
2536
2708
|
*/
|
|
2537
2709
|
|
|
2538
|
-
declare const SDK_VERSION = "0.
|
|
2710
|
+
declare const SDK_VERSION = "0.3.1";
|
|
2539
2711
|
declare const ERC8004_VERSION = "1.0";
|
|
2540
2712
|
declare const X402_VERSION = "1.0";
|
|
2541
2713
|
|
|
@@ -2572,4 +2744,4 @@ declare function initChaosChainSDK(config: {
|
|
|
2572
2744
|
enableStorage?: boolean;
|
|
2573
2745
|
}): ChaosChainSDK;
|
|
2574
2746
|
|
|
2575
|
-
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, 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 };
|
|
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 };
|