@chaoschain/sdk 0.2.3 → 0.3.0
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 +35 -0
- package/README.md +167 -16
- package/dist/{IPFSLocal-BCIADaOU.d.ts → IPFSLocal-B4hnMEfS.d.ts} +1 -1
- package/dist/{IPFSLocal-DqzD3Y7I.d.cts → IPFSLocal-zRj6kG8e.d.cts} +1 -1
- package/dist/index.cjs +269 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +167 -7
- package/dist/index.d.ts +167 -7
- package/dist/index.js +268 -52
- 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-CEFAgoAM.d.cts → types-BBVtx_jV.d.cts} +45 -13
- package/dist/{types-CEFAgoAM.d.ts → types-BBVtx_jV.d.ts} +45 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12037,10 +12037,10 @@ var X402PaymentManager = class {
|
|
|
12037
12037
|
*/
|
|
12038
12038
|
getTreasuryAddress(network) {
|
|
12039
12039
|
const treasuries = {
|
|
12040
|
-
"base-sepolia": "
|
|
12041
|
-
"ethereum-sepolia": "
|
|
12042
|
-
"optimism-sepolia": "
|
|
12043
|
-
"linea-sepolia": "
|
|
12040
|
+
"base-sepolia": "0x20E7B2A2c8969725b88Dd3EF3a11Bc3353C83F70",
|
|
12041
|
+
"ethereum-sepolia": "0x20E7B2A2c8969725b88Dd3EF3a11Bc3353C83F70",
|
|
12042
|
+
"optimism-sepolia": "0x20E7B2A2c8969725b88Dd3EF3a11Bc3353C83F70",
|
|
12043
|
+
"linea-sepolia": "0x20E7B2A2c8969725b88Dd3EF3a11Bc3353C83F70"
|
|
12044
12044
|
};
|
|
12045
12045
|
return treasuries[network] || treasuries["base-sepolia"];
|
|
12046
12046
|
}
|
|
@@ -15393,10 +15393,189 @@ var StudioClient = class {
|
|
|
15393
15393
|
return ethers.ethers.hexlify(ethers.ethers.randomBytes(32));
|
|
15394
15394
|
}
|
|
15395
15395
|
};
|
|
15396
|
+
var STEP_TYPE_MAP = {
|
|
15397
|
+
planning: "plan_created",
|
|
15398
|
+
testing: "test_run",
|
|
15399
|
+
debugging: "debug_step",
|
|
15400
|
+
implementing: "file_written",
|
|
15401
|
+
completing: "submission_created"
|
|
15402
|
+
};
|
|
15403
|
+
var Session = class {
|
|
15404
|
+
/** Session ID returned by the gateway. */
|
|
15405
|
+
sessionId;
|
|
15406
|
+
gatewayUrl;
|
|
15407
|
+
apiKey;
|
|
15408
|
+
studioAddress;
|
|
15409
|
+
agentAddress;
|
|
15410
|
+
studioPolicyVersion;
|
|
15411
|
+
workMandateId;
|
|
15412
|
+
taskType;
|
|
15413
|
+
lastEventId;
|
|
15414
|
+
/** @internal — use {@link SessionClient.start} to create instances. */
|
|
15415
|
+
constructor(opts) {
|
|
15416
|
+
this.sessionId = opts.sessionId;
|
|
15417
|
+
this.gatewayUrl = opts.gatewayUrl;
|
|
15418
|
+
this.apiKey = opts.apiKey;
|
|
15419
|
+
this.lastEventId = opts.lastEventId ?? null;
|
|
15420
|
+
this.studioAddress = opts.studioAddress;
|
|
15421
|
+
this.agentAddress = opts.agentAddress;
|
|
15422
|
+
this.studioPolicyVersion = opts.studioPolicyVersion;
|
|
15423
|
+
this.workMandateId = opts.workMandateId;
|
|
15424
|
+
this.taskType = opts.taskType;
|
|
15425
|
+
}
|
|
15426
|
+
/**
|
|
15427
|
+
* Log a session event.
|
|
15428
|
+
*
|
|
15429
|
+
* Automatically generates `event_id`, `timestamp`, and chains `parent_event_ids`
|
|
15430
|
+
* from the previous event so the gateway can build a causal DAG.
|
|
15431
|
+
*
|
|
15432
|
+
* @param opts - Event details. Only `summary` is required.
|
|
15433
|
+
* @throws Error if the gateway returns a non-2xx status.
|
|
15434
|
+
*/
|
|
15435
|
+
async log(opts) {
|
|
15436
|
+
const eventId = crypto2.randomUUID();
|
|
15437
|
+
const event = {
|
|
15438
|
+
event_id: eventId,
|
|
15439
|
+
event_type: opts.event_type ?? "artifact_created",
|
|
15440
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15441
|
+
summary: opts.summary,
|
|
15442
|
+
causality: {
|
|
15443
|
+
parent_event_ids: this.lastEventId ? [this.lastEventId] : []
|
|
15444
|
+
},
|
|
15445
|
+
agent: { agent_address: this.agentAddress, role: "worker" },
|
|
15446
|
+
studio: {
|
|
15447
|
+
studio_address: this.studioAddress,
|
|
15448
|
+
studio_policy_version: this.studioPolicyVersion
|
|
15449
|
+
},
|
|
15450
|
+
task: {
|
|
15451
|
+
work_mandate_id: this.workMandateId,
|
|
15452
|
+
task_type: this.taskType
|
|
15453
|
+
},
|
|
15454
|
+
...opts.metadata ? { metadata: opts.metadata } : {}
|
|
15455
|
+
};
|
|
15456
|
+
await this.post(`/v1/sessions/${this.sessionId}/events`, [event]);
|
|
15457
|
+
this.lastEventId = eventId;
|
|
15458
|
+
}
|
|
15459
|
+
/**
|
|
15460
|
+
* Convenience wrapper around {@link log} that maps human-friendly step names
|
|
15461
|
+
* to canonical event types.
|
|
15462
|
+
*
|
|
15463
|
+
* Mappings:
|
|
15464
|
+
* - `"planning"` → `plan_created`
|
|
15465
|
+
* - `"testing"` → `test_run`
|
|
15466
|
+
* - `"debugging"` → `debug_step`
|
|
15467
|
+
* - `"implementing"` → `file_written`
|
|
15468
|
+
* - `"completing"` → `submission_created`
|
|
15469
|
+
*
|
|
15470
|
+
* Unknown step types fall back to `artifact_created`.
|
|
15471
|
+
*
|
|
15472
|
+
* @param stepType - Friendly step name.
|
|
15473
|
+
* @param summary - What happened in this step.
|
|
15474
|
+
*/
|
|
15475
|
+
async step(stepType, summary) {
|
|
15476
|
+
const eventType = STEP_TYPE_MAP[stepType] ?? "artifact_created";
|
|
15477
|
+
await this.log({ event_type: eventType, summary });
|
|
15478
|
+
}
|
|
15479
|
+
/**
|
|
15480
|
+
* Complete the session.
|
|
15481
|
+
*
|
|
15482
|
+
* Triggers the on-chain WorkSubmission workflow (if the gateway is configured for it)
|
|
15483
|
+
* and returns `workflow_id` + `data_hash` for downstream verification/scoring.
|
|
15484
|
+
*
|
|
15485
|
+
* @param opts - Optional status (`"completed"` | `"failed"`) and summary.
|
|
15486
|
+
* @returns `{ workflow_id, data_hash }` — both may be `null` if the gateway
|
|
15487
|
+
* workflow engine is not configured.
|
|
15488
|
+
* @throws Error if the gateway returns a non-2xx status.
|
|
15489
|
+
*/
|
|
15490
|
+
async complete(opts) {
|
|
15491
|
+
const body = {};
|
|
15492
|
+
if (opts?.status) body.status = opts.status;
|
|
15493
|
+
if (opts?.summary) body.summary = opts.summary;
|
|
15494
|
+
const data = await this.post(`/v1/sessions/${this.sessionId}/complete`, body);
|
|
15495
|
+
return {
|
|
15496
|
+
workflow_id: data.data?.workflow_id ?? null,
|
|
15497
|
+
data_hash: data.data?.data_hash ?? null
|
|
15498
|
+
};
|
|
15499
|
+
}
|
|
15500
|
+
// ---------------------------------------------------------------------------
|
|
15501
|
+
// Internal HTTP helper
|
|
15502
|
+
// ---------------------------------------------------------------------------
|
|
15503
|
+
async post(path4, body) {
|
|
15504
|
+
const url = `${this.gatewayUrl}${path4}`;
|
|
15505
|
+
const headers = { "Content-Type": "application/json" };
|
|
15506
|
+
if (this.apiKey) headers["X-API-Key"] = this.apiKey;
|
|
15507
|
+
try {
|
|
15508
|
+
const res = await axios2__default.default({ method: "POST", url, data: body, headers, timeout: 3e4 });
|
|
15509
|
+
return res.data;
|
|
15510
|
+
} catch (err) {
|
|
15511
|
+
const axiosErr = err;
|
|
15512
|
+
const status = axiosErr.response?.status ?? 0;
|
|
15513
|
+
const detail = JSON.stringify(axiosErr.response?.data ?? axiosErr.message);
|
|
15514
|
+
throw new Error(`Session request failed: POST ${path4} \u2192 ${status} ${detail}`);
|
|
15515
|
+
}
|
|
15516
|
+
}
|
|
15517
|
+
};
|
|
15518
|
+
|
|
15519
|
+
// src/session/SessionClient.ts
|
|
15520
|
+
var SessionClient = class {
|
|
15521
|
+
gatewayUrl;
|
|
15522
|
+
apiKey;
|
|
15523
|
+
constructor(config = {}) {
|
|
15524
|
+
this.gatewayUrl = (config.gatewayUrl ?? "https://gateway.chaoscha.in").replace(/\/$/, "");
|
|
15525
|
+
this.apiKey = config.apiKey;
|
|
15526
|
+
}
|
|
15527
|
+
/**
|
|
15528
|
+
* Create a new coding session on the gateway.
|
|
15529
|
+
*
|
|
15530
|
+
* Returns a {@link Session} instance that can be used to log events, run steps,
|
|
15531
|
+
* and complete the session. The gateway persists all events and constructs the
|
|
15532
|
+
* Evidence DAG automatically.
|
|
15533
|
+
*
|
|
15534
|
+
* @param opts - Session creation parameters.
|
|
15535
|
+
* @returns A live {@link Session} bound to the newly created session ID.
|
|
15536
|
+
* @throws Error if the gateway returns a non-2xx status.
|
|
15537
|
+
*/
|
|
15538
|
+
async start(opts) {
|
|
15539
|
+
const body = {
|
|
15540
|
+
studio_address: opts.studio_address,
|
|
15541
|
+
agent_address: opts.agent_address
|
|
15542
|
+
};
|
|
15543
|
+
if (opts.work_mandate_id) body.work_mandate_id = opts.work_mandate_id;
|
|
15544
|
+
if (opts.task_type) body.task_type = opts.task_type;
|
|
15545
|
+
if (opts.studio_policy_version) body.studio_policy_version = opts.studio_policy_version;
|
|
15546
|
+
if (opts.session_id) body.session_id = opts.session_id;
|
|
15547
|
+
const url = `${this.gatewayUrl}/v1/sessions`;
|
|
15548
|
+
const headers = { "Content-Type": "application/json" };
|
|
15549
|
+
if (this.apiKey) headers["X-API-Key"] = this.apiKey;
|
|
15550
|
+
let data;
|
|
15551
|
+
try {
|
|
15552
|
+
const res = await axios2__default.default({ method: "POST", url, data: body, headers, timeout: 3e4 });
|
|
15553
|
+
data = res.data;
|
|
15554
|
+
} catch (err) {
|
|
15555
|
+
const axiosErr = err;
|
|
15556
|
+
const status = axiosErr.response?.status ?? 0;
|
|
15557
|
+
const detail = JSON.stringify(axiosErr.response?.data ?? axiosErr.message);
|
|
15558
|
+
throw new Error(`Failed to create session: POST /v1/sessions \u2192 ${status} ${detail}`);
|
|
15559
|
+
}
|
|
15560
|
+
const sessionId = data.data?.session_id;
|
|
15561
|
+
if (!sessionId) {
|
|
15562
|
+
throw new Error("Gateway response missing session_id");
|
|
15563
|
+
}
|
|
15564
|
+
return new Session({
|
|
15565
|
+
sessionId,
|
|
15566
|
+
gatewayUrl: this.gatewayUrl,
|
|
15567
|
+
apiKey: this.apiKey,
|
|
15568
|
+
studioAddress: opts.studio_address,
|
|
15569
|
+
agentAddress: opts.agent_address,
|
|
15570
|
+
studioPolicyVersion: opts.studio_policy_version ?? "engineering-studio-default-v1",
|
|
15571
|
+
workMandateId: opts.work_mandate_id ?? "generic-task",
|
|
15572
|
+
taskType: opts.task_type ?? "general"
|
|
15573
|
+
});
|
|
15574
|
+
}
|
|
15575
|
+
};
|
|
15396
15576
|
|
|
15397
15577
|
// src/ChaosChainSDK.ts
|
|
15398
15578
|
var ChaosChainSDK = class _ChaosChainSDK {
|
|
15399
|
-
static warnedGatewayMissing = false;
|
|
15400
15579
|
static warnedStudioClientProduction = false;
|
|
15401
15580
|
// Core components
|
|
15402
15581
|
walletManager;
|
|
@@ -15411,8 +15590,10 @@ var ChaosChainSDK = class _ChaosChainSDK {
|
|
|
15411
15590
|
a2aX402Extension;
|
|
15412
15591
|
processIntegrity;
|
|
15413
15592
|
mandateManager;
|
|
15414
|
-
// Gateway client for workflow submission (
|
|
15415
|
-
gateway
|
|
15593
|
+
// Gateway client for workflow submission (always initialized)
|
|
15594
|
+
gateway;
|
|
15595
|
+
/** Session client for Engineering Studio session management. */
|
|
15596
|
+
session;
|
|
15416
15597
|
// Studio client for direct on-chain operations
|
|
15417
15598
|
studio;
|
|
15418
15599
|
// Configuration
|
|
@@ -15574,41 +15755,25 @@ var ChaosChainSDK = class _ChaosChainSDK {
|
|
|
15574
15755
|
this.computeProvider
|
|
15575
15756
|
);
|
|
15576
15757
|
}
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15583
|
-
}
|
|
15758
|
+
const gatewayConfig = config.gatewayConfig ?? (config.gatewayUrl ? { gatewayUrl: config.gatewayUrl } : {});
|
|
15759
|
+
this.gateway = new GatewayClient(gatewayConfig);
|
|
15760
|
+
const gatewayBaseUrl = gatewayConfig.baseUrl ?? gatewayConfig.gatewayUrl ?? "https://gateway.chaoscha.in";
|
|
15761
|
+
this.session = new SessionClient({
|
|
15762
|
+
gatewayUrl: gatewayBaseUrl,
|
|
15763
|
+
apiKey: gatewayConfig.auth?.apiKey
|
|
15764
|
+
});
|
|
15584
15765
|
this.studio = new StudioClient({
|
|
15585
15766
|
provider: this.provider,
|
|
15586
15767
|
signer: this.walletManager.getWallet(),
|
|
15587
15768
|
network: typeof config.network === "string" ? config.network : config.network
|
|
15588
15769
|
});
|
|
15589
15770
|
const isLocalNetwork = String(config.network) === "local" /* LOCAL */ || String(config.network) === "local";
|
|
15590
|
-
if (!this.gateway && !isLocalNetwork && !_ChaosChainSDK.warnedGatewayMissing) {
|
|
15591
|
-
console.warn(
|
|
15592
|
-
"\u26A0\uFE0F Gateway is not configured. For production workflows, use gatewayConfig to enable Gateway orchestration."
|
|
15593
|
-
);
|
|
15594
|
-
_ChaosChainSDK.warnedGatewayMissing = true;
|
|
15595
|
-
}
|
|
15596
15771
|
if (process.env.NODE_ENV === "production" && !isLocalNetwork && !_ChaosChainSDK.warnedStudioClientProduction) {
|
|
15597
15772
|
console.warn(
|
|
15598
15773
|
"\u26A0\uFE0F StudioClient is intended for low-level or testing use. In production, prefer Gateway workflows."
|
|
15599
15774
|
);
|
|
15600
15775
|
_ChaosChainSDK.warnedStudioClientProduction = true;
|
|
15601
15776
|
}
|
|
15602
|
-
console.log(`\u{1F680} ChaosChain SDK initialized for ${this.agentName}`);
|
|
15603
|
-
console.log(` Network: ${this.network}`);
|
|
15604
|
-
console.log(` Wallet: ${this.walletManager.getAddress()}`);
|
|
15605
|
-
console.log(` Features:`);
|
|
15606
|
-
console.log(` - ERC-8004: \u2705`);
|
|
15607
|
-
console.log(` - x402 Payments: ${this.x402PaymentManager ? "\u2705" : "\u274C"}`);
|
|
15608
|
-
console.log(` - Multi-Payment: ${this.paymentManager ? "\u2705" : "\u274C"}`);
|
|
15609
|
-
console.log(` - Google AP2: ${this.googleAP2 ? "\u2705" : "\u274C"}`);
|
|
15610
|
-
console.log(` - Process Integrity: ${this.processIntegrity ? "\u2705" : "\u274C"}`);
|
|
15611
|
-
console.log(` - Storage: \u2705`);
|
|
15612
15777
|
}
|
|
15613
15778
|
// ============================================================================
|
|
15614
15779
|
// ERC-8004 Identity Methods
|
|
@@ -16017,7 +16182,7 @@ var ChaosChainSDK = class _ChaosChainSDK {
|
|
|
16017
16182
|
* Get SDK version
|
|
16018
16183
|
*/
|
|
16019
16184
|
getVersion() {
|
|
16020
|
-
return "0.
|
|
16185
|
+
return "0.3.0";
|
|
16021
16186
|
}
|
|
16022
16187
|
/**
|
|
16023
16188
|
* Get SDK capabilities summary
|
|
@@ -16047,9 +16212,11 @@ var ChaosChainSDK = class _ChaosChainSDK {
|
|
|
16047
16212
|
}
|
|
16048
16213
|
/**
|
|
16049
16214
|
* Check if Gateway is configured.
|
|
16215
|
+
* Always returns true in v0.3.0+. Gateway is always initialized pointing to
|
|
16216
|
+
* https://gateway.chaoscha.in unless overridden via gatewayConfig.
|
|
16050
16217
|
*/
|
|
16051
16218
|
isGatewayEnabled() {
|
|
16052
|
-
return
|
|
16219
|
+
return true;
|
|
16053
16220
|
}
|
|
16054
16221
|
/**
|
|
16055
16222
|
* Get Gateway client instance.
|
|
@@ -16472,24 +16639,51 @@ function resolveScoring(policy, mandate) {
|
|
|
16472
16639
|
}
|
|
16473
16640
|
function computeObserved(evidence) {
|
|
16474
16641
|
const totalNodes = evidence.length;
|
|
16642
|
+
const byId = /* @__PURE__ */ new Map();
|
|
16475
16643
|
const childrenOf = /* @__PURE__ */ new Map();
|
|
16476
16644
|
for (const e of evidence) {
|
|
16645
|
+
byId.set(e.arweave_tx_id, e);
|
|
16477
16646
|
childrenOf.set(e.arweave_tx_id, []);
|
|
16478
16647
|
}
|
|
16479
16648
|
let edgeCount = 0;
|
|
16480
16649
|
let rootCount = 0;
|
|
16481
|
-
let integrationNodeCount = 0;
|
|
16482
16650
|
let artifactCount = 0;
|
|
16483
16651
|
for (const e of evidence) {
|
|
16484
16652
|
edgeCount += e.parent_ids.length;
|
|
16485
16653
|
if (e.parent_ids.length === 0) rootCount++;
|
|
16486
|
-
if (e.parent_ids.length > 1) integrationNodeCount++;
|
|
16487
16654
|
if (e.artifact_ids.length > 0) artifactCount++;
|
|
16488
16655
|
for (const pid of e.parent_ids) {
|
|
16489
16656
|
const c = childrenOf.get(pid);
|
|
16490
16657
|
if (c) c.push(e.arweave_tx_id);
|
|
16491
16658
|
}
|
|
16492
16659
|
}
|
|
16660
|
+
const rootOrigins = /* @__PURE__ */ new Map();
|
|
16661
|
+
function getRootOrigins(id) {
|
|
16662
|
+
if (rootOrigins.has(id)) return rootOrigins.get(id);
|
|
16663
|
+
const node = byId.get(id);
|
|
16664
|
+
if (!node || node.parent_ids.length === 0) {
|
|
16665
|
+
const s = /* @__PURE__ */ new Set([id]);
|
|
16666
|
+
rootOrigins.set(id, s);
|
|
16667
|
+
return s;
|
|
16668
|
+
}
|
|
16669
|
+
const origins = /* @__PURE__ */ new Set();
|
|
16670
|
+
for (const pid of node.parent_ids) {
|
|
16671
|
+
for (const r of getRootOrigins(pid)) origins.add(r);
|
|
16672
|
+
}
|
|
16673
|
+
rootOrigins.set(id, origins);
|
|
16674
|
+
return origins;
|
|
16675
|
+
}
|
|
16676
|
+
for (const e of evidence) getRootOrigins(e.arweave_tx_id);
|
|
16677
|
+
let integrationNodeCount = 0;
|
|
16678
|
+
for (const e of evidence) {
|
|
16679
|
+
if (e.parent_ids.length < 2) continue;
|
|
16680
|
+
const parentRootSets = e.parent_ids.filter((pid) => byId.has(pid)).map((pid) => rootOrigins.get(pid));
|
|
16681
|
+
const uniqueRoots = /* @__PURE__ */ new Set();
|
|
16682
|
+
for (const s of parentRootSets) {
|
|
16683
|
+
for (const r of s) uniqueRoots.add(r);
|
|
16684
|
+
}
|
|
16685
|
+
if (uniqueRoots.size >= 2) integrationNodeCount++;
|
|
16686
|
+
}
|
|
16493
16687
|
let terminalCount = 0;
|
|
16494
16688
|
for (const [, children] of childrenOf) {
|
|
16495
16689
|
if (children.length === 0) terminalCount++;
|
|
@@ -16622,12 +16816,13 @@ function extractAgencySignals(evidence, context) {
|
|
|
16622
16816
|
durationMs: observed.durationMs
|
|
16623
16817
|
};
|
|
16624
16818
|
if (!scoring) {
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16819
|
+
const SOFT_CAP = 0.9;
|
|
16820
|
+
initiativeSignal = Math.max(0, Math.min(SOFT_CAP, rootRatio));
|
|
16821
|
+
collaborationSignal = Math.max(0, Math.min(SOFT_CAP, edgeDensity));
|
|
16822
|
+
reasoningSignal = Math.max(0, Math.min(SOFT_CAP, depthRatio));
|
|
16628
16823
|
} else {
|
|
16629
16824
|
const ir = scoring.initiative.rootRatio;
|
|
16630
|
-
|
|
16825
|
+
const initiativeBase = rangeFit(rootRatio, ir.min, ir.target, ir.max);
|
|
16631
16826
|
const cw = scoring.collaboration.weights;
|
|
16632
16827
|
const ed = scoring.collaboration.edgeDensity;
|
|
16633
16828
|
const intR = scoring.collaboration.integrationRatio;
|
|
@@ -16639,7 +16834,13 @@ function extractAgencySignals(evidence, context) {
|
|
|
16639
16834
|
}
|
|
16640
16835
|
collaborationSignal = Math.max(0, Math.min(1, collaborationSignal));
|
|
16641
16836
|
const dr = scoring.reasoning.depthRatio;
|
|
16642
|
-
|
|
16837
|
+
const reasoningBase = rangeFit(depthRatio, dr.min, dr.target, dr.max);
|
|
16838
|
+
const fragmentationPenalty = rootRatio > ir.max ? (rootRatio - ir.max) * 0.5 : 0;
|
|
16839
|
+
const overcomplexityPenalty = depthRatio > dr.max ? (depthRatio - dr.max) * 0.5 : 0;
|
|
16840
|
+
initiativeSignal = Math.max(0, Math.min(1, initiativeBase - fragmentationPenalty));
|
|
16841
|
+
reasoningSignal = Math.max(0, Math.min(1, reasoningBase - overcomplexityPenalty));
|
|
16842
|
+
observedBlock.fragmentationPenalty = fragmentationPenalty;
|
|
16843
|
+
observedBlock.overcomplexityPenalty = overcomplexityPenalty;
|
|
16643
16844
|
const compResult = computeComplianceSignal(evidence, observed, scoring, context?.workMandate);
|
|
16644
16845
|
complianceSignal = compResult.signal;
|
|
16645
16846
|
observedBlock.testsPresent = compResult.testsPresent;
|
|
@@ -16688,17 +16889,32 @@ function normalizeInput(value) {
|
|
|
16688
16889
|
return Math.max(0, Math.min(1, v));
|
|
16689
16890
|
}
|
|
16690
16891
|
var CLAMP_100 = (v) => Math.max(0, Math.min(100, Math.round(v)));
|
|
16892
|
+
function resolveDimension(override, signal) {
|
|
16893
|
+
if (override !== void 0) return normalizeInput(override);
|
|
16894
|
+
return signal ?? 0;
|
|
16895
|
+
}
|
|
16691
16896
|
function composeScoreVector(signals, assessment) {
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16897
|
+
if (assessment.complianceScore === void 0 || assessment.complianceScore === null) {
|
|
16898
|
+
throw new Error("complianceScore is required for production scoring");
|
|
16899
|
+
}
|
|
16900
|
+
if (assessment.efficiencyScore === void 0 || assessment.efficiencyScore === null) {
|
|
16901
|
+
throw new Error("efficiencyScore is required for production scoring");
|
|
16902
|
+
}
|
|
16903
|
+
return [
|
|
16904
|
+
CLAMP_100(resolveDimension(assessment.initiativeScore, signals.initiativeSignal) * 100),
|
|
16905
|
+
CLAMP_100(resolveDimension(assessment.collaborationScore, signals.collaborationSignal) * 100),
|
|
16906
|
+
CLAMP_100(resolveDimension(assessment.reasoningScore, signals.reasoningSignal) * 100),
|
|
16907
|
+
CLAMP_100(normalizeInput(assessment.complianceScore) * 100),
|
|
16908
|
+
CLAMP_100(normalizeInput(assessment.efficiencyScore) * 100)
|
|
16909
|
+
];
|
|
16910
|
+
}
|
|
16911
|
+
function composeScoreVectorWithDefaults(signals, assessment) {
|
|
16696
16912
|
return [
|
|
16697
|
-
CLAMP_100(
|
|
16698
|
-
CLAMP_100(
|
|
16699
|
-
CLAMP_100(
|
|
16700
|
-
CLAMP_100(
|
|
16701
|
-
CLAMP_100(
|
|
16913
|
+
CLAMP_100(resolveDimension(assessment?.initiativeScore, signals.initiativeSignal) * 100),
|
|
16914
|
+
CLAMP_100(resolveDimension(assessment?.collaborationScore, signals.collaborationSignal) * 100),
|
|
16915
|
+
CLAMP_100(resolveDimension(assessment?.reasoningScore, signals.reasoningSignal) * 100),
|
|
16916
|
+
CLAMP_100(resolveDimension(assessment?.complianceScore, signals.complianceSignal) * 100),
|
|
16917
|
+
CLAMP_100(resolveDimension(assessment?.efficiencyScore, signals.efficiencySignal) * 100)
|
|
16702
16918
|
];
|
|
16703
16919
|
}
|
|
16704
16920
|
function derivePoAScores(evidence, options) {
|
|
@@ -16712,7 +16928,7 @@ function derivePoAScores(evidence, options) {
|
|
|
16712
16928
|
];
|
|
16713
16929
|
}
|
|
16714
16930
|
const signals = extractAgencySignals(evidence);
|
|
16715
|
-
return
|
|
16931
|
+
return composeScoreVectorWithDefaults(signals, {
|
|
16716
16932
|
complianceScore: options?.compliance,
|
|
16717
16933
|
efficiencyScore: options?.efficiency
|
|
16718
16934
|
});
|
|
@@ -16764,7 +16980,7 @@ function verifyWorkEvidence(evidence, context) {
|
|
|
16764
16980
|
}
|
|
16765
16981
|
|
|
16766
16982
|
// src/index.ts
|
|
16767
|
-
var SDK_VERSION = "0.
|
|
16983
|
+
var SDK_VERSION = "0.3.0";
|
|
16768
16984
|
var ERC8004_VERSION = "1.0";
|
|
16769
16985
|
var X402_VERSION = "1.0";
|
|
16770
16986
|
var src_default = ChaosChainSDK;
|
|
@@ -16825,6 +17041,8 @@ exports.SDKValidationError = ValidationError;
|
|
|
16825
17041
|
exports.SDK_VERSION = SDK_VERSION;
|
|
16826
17042
|
exports.STUDIO_FACTORY_ABI = STUDIO_FACTORY_ABI;
|
|
16827
17043
|
exports.STUDIO_PROXY_ABI = STUDIO_PROXY_ABI;
|
|
17044
|
+
exports.Session = Session;
|
|
17045
|
+
exports.SessionClient = SessionClient;
|
|
16828
17046
|
exports.StorageError = StorageError;
|
|
16829
17047
|
exports.StudioClient = StudioClient;
|
|
16830
17048
|
exports.StudioManager = StudioManager;
|
|
@@ -16839,6 +17057,7 @@ exports.X402Server = X402Server;
|
|
|
16839
17057
|
exports.X402_VERSION = X402_VERSION;
|
|
16840
17058
|
exports.ZeroGStorage = ZeroGStorage;
|
|
16841
17059
|
exports.composeScoreVector = composeScoreVector;
|
|
17060
|
+
exports.composeScoreVectorWithDefaults = composeScoreVectorWithDefaults;
|
|
16842
17061
|
exports.computeDepth = computeDepth;
|
|
16843
17062
|
exports.default = src_default;
|
|
16844
17063
|
exports.derivePoAScores = derivePoAScores;
|