@chaoschain/sdk 0.2.3 → 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.
- package/README.md +73 -15
- package/dist/{IPFSLocal-BCIADaOU.d.ts → IPFSLocal-BqyHRp_l.d.ts} +1 -1
- package/dist/{IPFSLocal-DqzD3Y7I.d.cts → IPFSLocal-azjjaiGR.d.cts} +1 -1
- package/dist/index.cjs +77 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +77 -38
- 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-DZze-Z8B.d.cts} +35 -11
- package/dist/{types-CEFAgoAM.d.ts → types-DZze-Z8B.d.ts} +35 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,25 +53,53 @@ Storage backends are optional and intended for development/testing. In productio
|
|
|
53
53
|
|
|
54
54
|
## Canonical Examples
|
|
55
55
|
|
|
56
|
-
### 0)
|
|
56
|
+
### 0) Verifier agent (pending work → evidence → scores)
|
|
57
|
+
|
|
58
|
+
Verifier agents poll for pending work, fetch the evidence DAG, extract deterministic signals, then compose and submit score vectors. The SDK uses a **3-layer scoring** flow: **signal extraction** → **score composition** → **on-chain consensus**. Compliance and efficiency are **required** from the verifier.
|
|
57
59
|
|
|
58
60
|
```typescript
|
|
59
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
GatewayClient,
|
|
63
|
+
ChaosChainSDK,
|
|
64
|
+
AgentRole,
|
|
65
|
+
NetworkConfig,
|
|
66
|
+
verifyWorkEvidence,
|
|
67
|
+
composeScoreVector,
|
|
68
|
+
} from '@chaoschain/sdk';
|
|
60
69
|
|
|
61
70
|
const STUDIO_ADDRESS = '0xA855F7893ac01653D1bCC24210bFbb3c47324649';
|
|
62
|
-
const gateway = new GatewayClient({
|
|
63
|
-
baseUrl: 'https://gateway.chaoscha.in',
|
|
64
|
-
});
|
|
71
|
+
const gateway = new GatewayClient({ baseUrl: 'https://gateway.chaoscha.in' });
|
|
65
72
|
|
|
73
|
+
// 1) Discover pending work (no auth)
|
|
66
74
|
const pending = await gateway.getPendingWork(STUDIO_ADDRESS, { limit: 20, offset: 0 });
|
|
67
|
-
console.log(`Pending work items: ${pending.data.work.length}`);
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
76
|
+
for (const work of pending.data.work) {
|
|
77
|
+
// 2) Fetch evidence (API key required — contact ChaosChain for access)
|
|
78
|
+
const evidenceRes = await fetch(
|
|
79
|
+
`https://gateway.chaoscha.in/v1/work/${work.work_id}/evidence`,
|
|
80
|
+
{ headers: { 'x-api-key': process.env.CHAOSCHAIN_API_KEY! } }
|
|
81
|
+
);
|
|
82
|
+
const { data } = await evidenceRes.json();
|
|
83
|
+
const evidence = data.dkg_evidence;
|
|
84
|
+
|
|
85
|
+
// 3) Validate DAG + extract deterministic signals
|
|
86
|
+
const result = verifyWorkEvidence(evidence);
|
|
87
|
+
if (!result.valid || !result.signals) continue;
|
|
88
|
+
|
|
89
|
+
// 4) Compose final score vector (compliance + efficiency required)
|
|
90
|
+
const scores = composeScoreVector(result.signals, {
|
|
91
|
+
complianceScore: 85, // your assessment: tests pass? constraints followed?
|
|
92
|
+
efficiencyScore: 78, // your assessment: proportional effort?
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// 5) Submit on-chain (requires SDK with signer + studio.submitScoreVectorForWorker)
|
|
96
|
+
// await sdk.studio.submitScoreVectorForWorker(STUDIO_ADDRESS, work.work_id, workerAddress, [...scores]);
|
|
97
|
+
console.log(`Scores for ${work.work_id}: [${scores.join(', ')}]`);
|
|
98
|
+
}
|
|
73
99
|
```
|
|
74
100
|
|
|
101
|
+
**Full verifier flow** (registration, polling loop, reputation): see the [Verifier Integration Guide](https://github.com/ChaosChain/chaoschain/blob/main/docs/VERIFIER_INTEGRATION_GUIDE.md) (or `docs/VERIFIER_INTEGRATION_GUIDE.md` in the ChaosChain repo). Gateway base URL: `https://gateway.chaoscha.in`. Evidence endpoint requires an API key.
|
|
102
|
+
|
|
75
103
|
### 1) Minimal “Happy Path” (Gateway-first)
|
|
76
104
|
|
|
77
105
|
```typescript
|
|
@@ -364,6 +392,22 @@ console.log(`Amount: ${costs.amount}, Fee: ${costs.fee}, Total: ${costs.total}`)
|
|
|
364
392
|
- ✅ USDC support on supported networks
|
|
365
393
|
- ⚠️ Provide `facilitatorUrl` (and optional `facilitatorApiKey`) for production
|
|
366
394
|
|
|
395
|
+
### **Verifier agents (PoA scoring)**
|
|
396
|
+
|
|
397
|
+
The SDK supports **verifier agents** that assess work submitted to ChaosChain Studios. Scoring follows the Proof-of-Agency (PoA) spec in three layers:
|
|
398
|
+
|
|
399
|
+
| Layer | Responsibility | SDK API |
|
|
400
|
+
|-------|----------------|--------|
|
|
401
|
+
| **1. Signal extraction** | Deterministic features from the evidence DAG (0..1 normalized) | `extractAgencySignals(evidence, context?)`, `verifyWorkEvidence(evidence, context?)` |
|
|
402
|
+
| **2. Score composition** | Verifier judgment + signal defaults → integer vector [0, 100] × 5 | `composeScoreVector(signals, assessment)` |
|
|
403
|
+
| **3. Consensus** | Median / MAD / stake-weighted aggregation | On-chain (contract) |
|
|
404
|
+
|
|
405
|
+
- **Initiative, collaboration, reasoning**: Derived from graph structure (root ratio, edge density, depth). The SDK applies saturation and anti-gaming rules; you can override with your own scores via `composeScoreVector`.
|
|
406
|
+
- **Compliance and efficiency**: **Required** from the verifier. Pass `complianceScore` and `efficiencyScore` (0..100 or 0..1) into `composeScoreVector`; the SDK does not substitute defaults for these.
|
|
407
|
+
- **Policy-aware extraction**: Pass `studioPolicy` and optional `workMandate` in the context to `extractAgencySignals` or `verifyWorkEvidence` for deterministic compliance/efficiency signals when the studio defines policy.
|
|
408
|
+
|
|
409
|
+
Key exports: `verifyWorkEvidence`, `composeScoreVector`, `extractAgencySignals`, `AgencySignals`, `VerifierAssessment`, `EvidencePackage`. For the full step-by-step (registration, gateway URL, evidence fetch, on-chain submit), see the [Verifier Integration Guide](https://github.com/ChaosChain/chaoschain/blob/main/docs/VERIFIER_INTEGRATION_GUIDE.md).
|
|
410
|
+
|
|
367
411
|
### **Storage (Gateway-First)**
|
|
368
412
|
|
|
369
413
|
In production, evidence storage is handled by the Gateway during workflow orchestration. The SDK exposes `upload`/`download` methods for local development and testing only.
|
|
@@ -394,7 +438,7 @@ const sdk = new ChaosChainSDK({
|
|
|
394
438
|
privateKey: process.env.PRIVATE_KEY!,
|
|
395
439
|
rpcUrl: process.env.RPC_URL!,
|
|
396
440
|
gatewayConfig: {
|
|
397
|
-
gatewayUrl: 'https://gateway.
|
|
441
|
+
gatewayUrl: 'https://gateway.chaoscha.in',
|
|
398
442
|
},
|
|
399
443
|
});
|
|
400
444
|
|
|
@@ -665,12 +709,19 @@ interface ChaosChainSDKConfig {
|
|
|
665
709
|
| **Gateway** | `gateway.healthCheck()` | Check Gateway health |
|
|
666
710
|
| | `gateway.submitWork(...)` | Submit work via Gateway |
|
|
667
711
|
| | `gateway.submitScore(...)` | Submit scores via Gateway |
|
|
712
|
+
| | `gateway.getPendingWork(studio, opts)` | Pending work for a studio |
|
|
713
|
+
| | `gateway.getWorkEvidence(workHash)` | Evidence graph for work |
|
|
668
714
|
| | `gateway.closeEpoch(...)` | Close epoch via Gateway |
|
|
669
715
|
| | `gateway.getWorkflow(id)` | Get workflow by ID |
|
|
670
716
|
| | `gateway.listWorkflows(params)` | List workflows |
|
|
671
717
|
| | `gateway.waitForCompletion(id)` | Wait for workflow completion |
|
|
718
|
+
| **Verifier** | `verifyWorkEvidence(evidence, context?)` | Validate DAG + extract signals |
|
|
719
|
+
| | `composeScoreVector(signals, assessment)` | Final score vector [0..100]×5 |
|
|
720
|
+
| | `extractAgencySignals(evidence, context?)` | Deterministic signals only |
|
|
721
|
+
| | `validateEvidenceGraph(evidence)` | DAG valid (no cycles) |
|
|
672
722
|
| **Studio** | `studio.createStudio(name, logic)` | Create new Studio |
|
|
673
723
|
| | `studio.registerWithStudio(...)` | Register with Studio |
|
|
724
|
+
| | `studio.submitScoreVectorForWorker(...)` | Submit PoA scores (verifiers) |
|
|
674
725
|
| | `studio.getPendingRewards(...)` | Check pending rewards |
|
|
675
726
|
| | `studio.withdrawRewards(...)` | Withdraw rewards |
|
|
676
727
|
| **Wallet** | `getAddress()` | Get wallet address |
|
|
@@ -820,7 +871,7 @@ async function studioWorkflow() {
|
|
|
820
871
|
privateKey: process.env.PRIVATE_KEY!,
|
|
821
872
|
rpcUrl: process.env.RPC_URL!,
|
|
822
873
|
gatewayConfig: {
|
|
823
|
-
gatewayUrl: 'https://gateway.
|
|
874
|
+
gatewayUrl: 'https://gateway.chaoscha.in',
|
|
824
875
|
},
|
|
825
876
|
});
|
|
826
877
|
|
|
@@ -896,7 +947,7 @@ async function verifierWorkflow() {
|
|
|
896
947
|
privateKey: process.env.PRIVATE_KEY!,
|
|
897
948
|
rpcUrl: process.env.RPC_URL!,
|
|
898
949
|
gatewayConfig: {
|
|
899
|
-
gatewayUrl: 'https://gateway.
|
|
950
|
+
gatewayUrl: 'https://gateway.chaoscha.in',
|
|
900
951
|
},
|
|
901
952
|
});
|
|
902
953
|
|
|
@@ -996,8 +1047,11 @@ PRIVATE_KEY=your_private_key_here
|
|
|
996
1047
|
BASE_SEPOLIA_RPC_URL=https://sepolia.base.org
|
|
997
1048
|
ETHEREUM_SEPOLIA_RPC_URL=https://rpc.sepolia.org
|
|
998
1049
|
|
|
999
|
-
# Gateway (for ChaosChain Studios)
|
|
1000
|
-
GATEWAY_URL=https://gateway.
|
|
1050
|
+
# Gateway (for ChaosChain Studios; default base URL)
|
|
1051
|
+
GATEWAY_URL=https://gateway.chaoscha.in
|
|
1052
|
+
|
|
1053
|
+
# Verifier agents: API key for evidence endpoint (contact ChaosChain)
|
|
1054
|
+
CHAOSCHAIN_API_KEY=cc_...
|
|
1001
1055
|
|
|
1002
1056
|
# Optional: Custom RPC endpoints
|
|
1003
1057
|
LINEA_SEPOLIA_RPC_URL=https://rpc.sepolia.linea.build
|
|
@@ -1095,6 +1149,9 @@ A: DKG performs causal analysis of agent contributions in multi-agent tasks. It'
|
|
|
1095
1149
|
**Q: How do x402 payments work?**
|
|
1096
1150
|
A: Real USDC/ETH transfers using Coinbase's HTTP 402 protocol. 2.5% fee goes to ChaosChain treasury.
|
|
1097
1151
|
|
|
1152
|
+
**Q: How do I build a verifier agent?**
|
|
1153
|
+
A: Use `GatewayClient.getPendingWork(studio)` to discover work, fetch evidence via `GET /v1/work/:hash/evidence` (API key required), then `verifyWorkEvidence(evidence)` and `composeScoreVector(signals, { complianceScore, efficiencyScore })`. Submit with `sdk.studio.submitScoreVectorForWorker()`. See the [Verifier Integration Guide](https://github.com/ChaosChain/chaoschain/blob/main/docs/VERIFIER_INTEGRATION_GUIDE.md) for the full flow (registration, polling, reputation).
|
|
1154
|
+
|
|
1098
1155
|
**Q: How does commit-reveal scoring work?**
|
|
1099
1156
|
A: Verifiers first commit a hash of their scores (preventing front-running), then reveal actual scores in a second phase. Gateway handles this automatically when you use `mode: 'COMMIT_REVEAL'`.
|
|
1100
1157
|
|
|
@@ -1122,6 +1179,7 @@ MIT License - see [LICENSE](LICENSE) file.
|
|
|
1122
1179
|
- **GitHub**: [https://github.com/ChaosChain/chaoschain-sdk-ts](https://github.com/ChaosChain/chaoschain-sdk-ts)
|
|
1123
1180
|
- **npm**: [https://www.npmjs.com/package/@chaoschain/sdk](https://www.npmjs.com/package/@chaoschain/sdk)
|
|
1124
1181
|
- **Changelog**: [CHANGELOG.md](CHANGELOG.md)
|
|
1182
|
+
- **Verifier Integration Guide**: [docs/VERIFIER_INTEGRATION_GUIDE.md](https://github.com/ChaosChain/chaoschain/blob/main/docs/VERIFIER_INTEGRATION_GUIDE.md) (registration, pending work, evidence, PoA scoring)
|
|
1125
1183
|
- **Python SDK**: [https://pypi.org/project/chaoschain-sdk/](https://pypi.org/project/chaoschain-sdk/)
|
|
1126
1184
|
- **ERC-8004 Spec**: [https://eips.ethereum.org/EIPS/eip-8004](https://eips.ethereum.org/EIPS/eip-8004)
|
|
1127
1185
|
- **x402 Protocol**: [https://www.x402.org/](https://www.x402.org/)
|
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
|
}
|
|
@@ -15396,7 +15396,6 @@ var StudioClient = class {
|
|
|
15396
15396
|
|
|
15397
15397
|
// src/ChaosChainSDK.ts
|
|
15398
15398
|
var ChaosChainSDK = class _ChaosChainSDK {
|
|
15399
|
-
static warnedGatewayMissing = false;
|
|
15400
15399
|
static warnedStudioClientProduction = false;
|
|
15401
15400
|
// Core components
|
|
15402
15401
|
walletManager;
|
|
@@ -15574,25 +15573,16 @@ var ChaosChainSDK = class _ChaosChainSDK {
|
|
|
15574
15573
|
this.computeProvider
|
|
15575
15574
|
);
|
|
15576
15575
|
}
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
`\u{1F310} Gateway client initialized: ${gatewayConfig.baseUrl || gatewayConfig.gatewayUrl || "https://gateway.chaoscha.in"}`
|
|
15582
|
-
);
|
|
15583
|
-
}
|
|
15576
|
+
const gatewayConfig = config.gatewayConfig ?? (config.gatewayUrl ? { gatewayUrl: config.gatewayUrl } : {});
|
|
15577
|
+
this.gateway = new GatewayClient(gatewayConfig);
|
|
15578
|
+
const gatewayBaseUrl = gatewayConfig.baseUrl ?? gatewayConfig.gatewayUrl ?? "https://gateway.chaoscha.in";
|
|
15579
|
+
console.log(`\u{1F310} Gateway client initialized: ${gatewayBaseUrl}`);
|
|
15584
15580
|
this.studio = new StudioClient({
|
|
15585
15581
|
provider: this.provider,
|
|
15586
15582
|
signer: this.walletManager.getWallet(),
|
|
15587
15583
|
network: typeof config.network === "string" ? config.network : config.network
|
|
15588
15584
|
});
|
|
15589
15585
|
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
15586
|
if (process.env.NODE_ENV === "production" && !isLocalNetwork && !_ChaosChainSDK.warnedStudioClientProduction) {
|
|
15597
15587
|
console.warn(
|
|
15598
15588
|
"\u26A0\uFE0F StudioClient is intended for low-level or testing use. In production, prefer Gateway workflows."
|
|
@@ -16017,7 +16007,7 @@ var ChaosChainSDK = class _ChaosChainSDK {
|
|
|
16017
16007
|
* Get SDK version
|
|
16018
16008
|
*/
|
|
16019
16009
|
getVersion() {
|
|
16020
|
-
return "0.2.
|
|
16010
|
+
return "0.2.4";
|
|
16021
16011
|
}
|
|
16022
16012
|
/**
|
|
16023
16013
|
* Get SDK capabilities summary
|
|
@@ -16472,24 +16462,51 @@ function resolveScoring(policy, mandate) {
|
|
|
16472
16462
|
}
|
|
16473
16463
|
function computeObserved(evidence) {
|
|
16474
16464
|
const totalNodes = evidence.length;
|
|
16465
|
+
const byId = /* @__PURE__ */ new Map();
|
|
16475
16466
|
const childrenOf = /* @__PURE__ */ new Map();
|
|
16476
16467
|
for (const e of evidence) {
|
|
16468
|
+
byId.set(e.arweave_tx_id, e);
|
|
16477
16469
|
childrenOf.set(e.arweave_tx_id, []);
|
|
16478
16470
|
}
|
|
16479
16471
|
let edgeCount = 0;
|
|
16480
16472
|
let rootCount = 0;
|
|
16481
|
-
let integrationNodeCount = 0;
|
|
16482
16473
|
let artifactCount = 0;
|
|
16483
16474
|
for (const e of evidence) {
|
|
16484
16475
|
edgeCount += e.parent_ids.length;
|
|
16485
16476
|
if (e.parent_ids.length === 0) rootCount++;
|
|
16486
|
-
if (e.parent_ids.length > 1) integrationNodeCount++;
|
|
16487
16477
|
if (e.artifact_ids.length > 0) artifactCount++;
|
|
16488
16478
|
for (const pid of e.parent_ids) {
|
|
16489
16479
|
const c = childrenOf.get(pid);
|
|
16490
16480
|
if (c) c.push(e.arweave_tx_id);
|
|
16491
16481
|
}
|
|
16492
16482
|
}
|
|
16483
|
+
const rootOrigins = /* @__PURE__ */ new Map();
|
|
16484
|
+
function getRootOrigins(id) {
|
|
16485
|
+
if (rootOrigins.has(id)) return rootOrigins.get(id);
|
|
16486
|
+
const node = byId.get(id);
|
|
16487
|
+
if (!node || node.parent_ids.length === 0) {
|
|
16488
|
+
const s = /* @__PURE__ */ new Set([id]);
|
|
16489
|
+
rootOrigins.set(id, s);
|
|
16490
|
+
return s;
|
|
16491
|
+
}
|
|
16492
|
+
const origins = /* @__PURE__ */ new Set();
|
|
16493
|
+
for (const pid of node.parent_ids) {
|
|
16494
|
+
for (const r of getRootOrigins(pid)) origins.add(r);
|
|
16495
|
+
}
|
|
16496
|
+
rootOrigins.set(id, origins);
|
|
16497
|
+
return origins;
|
|
16498
|
+
}
|
|
16499
|
+
for (const e of evidence) getRootOrigins(e.arweave_tx_id);
|
|
16500
|
+
let integrationNodeCount = 0;
|
|
16501
|
+
for (const e of evidence) {
|
|
16502
|
+
if (e.parent_ids.length < 2) continue;
|
|
16503
|
+
const parentRootSets = e.parent_ids.filter((pid) => byId.has(pid)).map((pid) => rootOrigins.get(pid));
|
|
16504
|
+
const uniqueRoots = /* @__PURE__ */ new Set();
|
|
16505
|
+
for (const s of parentRootSets) {
|
|
16506
|
+
for (const r of s) uniqueRoots.add(r);
|
|
16507
|
+
}
|
|
16508
|
+
if (uniqueRoots.size >= 2) integrationNodeCount++;
|
|
16509
|
+
}
|
|
16493
16510
|
let terminalCount = 0;
|
|
16494
16511
|
for (const [, children] of childrenOf) {
|
|
16495
16512
|
if (children.length === 0) terminalCount++;
|
|
@@ -16622,12 +16639,13 @@ function extractAgencySignals(evidence, context) {
|
|
|
16622
16639
|
durationMs: observed.durationMs
|
|
16623
16640
|
};
|
|
16624
16641
|
if (!scoring) {
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16642
|
+
const SOFT_CAP = 0.9;
|
|
16643
|
+
initiativeSignal = Math.max(0, Math.min(SOFT_CAP, rootRatio));
|
|
16644
|
+
collaborationSignal = Math.max(0, Math.min(SOFT_CAP, edgeDensity));
|
|
16645
|
+
reasoningSignal = Math.max(0, Math.min(SOFT_CAP, depthRatio));
|
|
16628
16646
|
} else {
|
|
16629
16647
|
const ir = scoring.initiative.rootRatio;
|
|
16630
|
-
|
|
16648
|
+
const initiativeBase = rangeFit(rootRatio, ir.min, ir.target, ir.max);
|
|
16631
16649
|
const cw = scoring.collaboration.weights;
|
|
16632
16650
|
const ed = scoring.collaboration.edgeDensity;
|
|
16633
16651
|
const intR = scoring.collaboration.integrationRatio;
|
|
@@ -16639,7 +16657,13 @@ function extractAgencySignals(evidence, context) {
|
|
|
16639
16657
|
}
|
|
16640
16658
|
collaborationSignal = Math.max(0, Math.min(1, collaborationSignal));
|
|
16641
16659
|
const dr = scoring.reasoning.depthRatio;
|
|
16642
|
-
|
|
16660
|
+
const reasoningBase = rangeFit(depthRatio, dr.min, dr.target, dr.max);
|
|
16661
|
+
const fragmentationPenalty = rootRatio > ir.max ? (rootRatio - ir.max) * 0.5 : 0;
|
|
16662
|
+
const overcomplexityPenalty = depthRatio > dr.max ? (depthRatio - dr.max) * 0.5 : 0;
|
|
16663
|
+
initiativeSignal = Math.max(0, Math.min(1, initiativeBase - fragmentationPenalty));
|
|
16664
|
+
reasoningSignal = Math.max(0, Math.min(1, reasoningBase - overcomplexityPenalty));
|
|
16665
|
+
observedBlock.fragmentationPenalty = fragmentationPenalty;
|
|
16666
|
+
observedBlock.overcomplexityPenalty = overcomplexityPenalty;
|
|
16643
16667
|
const compResult = computeComplianceSignal(evidence, observed, scoring, context?.workMandate);
|
|
16644
16668
|
complianceSignal = compResult.signal;
|
|
16645
16669
|
observedBlock.testsPresent = compResult.testsPresent;
|
|
@@ -16688,17 +16712,32 @@ function normalizeInput(value) {
|
|
|
16688
16712
|
return Math.max(0, Math.min(1, v));
|
|
16689
16713
|
}
|
|
16690
16714
|
var CLAMP_100 = (v) => Math.max(0, Math.min(100, Math.round(v)));
|
|
16715
|
+
function resolveDimension(override, signal) {
|
|
16716
|
+
if (override !== void 0) return normalizeInput(override);
|
|
16717
|
+
return signal ?? 0;
|
|
16718
|
+
}
|
|
16691
16719
|
function composeScoreVector(signals, assessment) {
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16720
|
+
if (assessment.complianceScore === void 0 || assessment.complianceScore === null) {
|
|
16721
|
+
throw new Error("complianceScore is required for production scoring");
|
|
16722
|
+
}
|
|
16723
|
+
if (assessment.efficiencyScore === void 0 || assessment.efficiencyScore === null) {
|
|
16724
|
+
throw new Error("efficiencyScore is required for production scoring");
|
|
16725
|
+
}
|
|
16726
|
+
return [
|
|
16727
|
+
CLAMP_100(resolveDimension(assessment.initiativeScore, signals.initiativeSignal) * 100),
|
|
16728
|
+
CLAMP_100(resolveDimension(assessment.collaborationScore, signals.collaborationSignal) * 100),
|
|
16729
|
+
CLAMP_100(resolveDimension(assessment.reasoningScore, signals.reasoningSignal) * 100),
|
|
16730
|
+
CLAMP_100(normalizeInput(assessment.complianceScore) * 100),
|
|
16731
|
+
CLAMP_100(normalizeInput(assessment.efficiencyScore) * 100)
|
|
16732
|
+
];
|
|
16733
|
+
}
|
|
16734
|
+
function composeScoreVectorWithDefaults(signals, assessment) {
|
|
16696
16735
|
return [
|
|
16697
|
-
CLAMP_100(
|
|
16698
|
-
CLAMP_100(
|
|
16699
|
-
CLAMP_100(
|
|
16700
|
-
CLAMP_100(
|
|
16701
|
-
CLAMP_100(
|
|
16736
|
+
CLAMP_100(resolveDimension(assessment?.initiativeScore, signals.initiativeSignal) * 100),
|
|
16737
|
+
CLAMP_100(resolveDimension(assessment?.collaborationScore, signals.collaborationSignal) * 100),
|
|
16738
|
+
CLAMP_100(resolveDimension(assessment?.reasoningScore, signals.reasoningSignal) * 100),
|
|
16739
|
+
CLAMP_100(resolveDimension(assessment?.complianceScore, signals.complianceSignal) * 100),
|
|
16740
|
+
CLAMP_100(resolveDimension(assessment?.efficiencyScore, signals.efficiencySignal) * 100)
|
|
16702
16741
|
];
|
|
16703
16742
|
}
|
|
16704
16743
|
function derivePoAScores(evidence, options) {
|
|
@@ -16712,7 +16751,7 @@ function derivePoAScores(evidence, options) {
|
|
|
16712
16751
|
];
|
|
16713
16752
|
}
|
|
16714
16753
|
const signals = extractAgencySignals(evidence);
|
|
16715
|
-
return
|
|
16754
|
+
return composeScoreVectorWithDefaults(signals, {
|
|
16716
16755
|
complianceScore: options?.compliance,
|
|
16717
16756
|
efficiencyScore: options?.efficiency
|
|
16718
16757
|
});
|
|
@@ -16764,7 +16803,7 @@ function verifyWorkEvidence(evidence, context) {
|
|
|
16764
16803
|
}
|
|
16765
16804
|
|
|
16766
16805
|
// src/index.ts
|
|
16767
|
-
var SDK_VERSION = "0.2.
|
|
16806
|
+
var SDK_VERSION = "0.2.4";
|
|
16768
16807
|
var ERC8004_VERSION = "1.0";
|
|
16769
16808
|
var X402_VERSION = "1.0";
|
|
16770
16809
|
var src_default = ChaosChainSDK;
|
|
@@ -16839,6 +16878,7 @@ exports.X402Server = X402Server;
|
|
|
16839
16878
|
exports.X402_VERSION = X402_VERSION;
|
|
16840
16879
|
exports.ZeroGStorage = ZeroGStorage;
|
|
16841
16880
|
exports.composeScoreVector = composeScoreVector;
|
|
16881
|
+
exports.composeScoreVectorWithDefaults = composeScoreVectorWithDefaults;
|
|
16842
16882
|
exports.computeDepth = computeDepth;
|
|
16843
16883
|
exports.default = src_default;
|
|
16844
16884
|
exports.derivePoAScores = derivePoAScores;
|