@emilia-protocol/sdk 0.9.0 → 0.11.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 +9 -0
- package/README.md +68 -42
- package/dist/client.d.ts +36 -30
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +193 -43
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +12 -516
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -336
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +209 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -7
- package/src/client.ts +243 -42
- package/src/index.ts +13 -932
- package/src/types.ts +229 -11
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
# Changelog
|
|
3
|
+
|
|
4
|
+
## 0.11.0 (2026-08-30)
|
|
5
|
+
|
|
6
|
+
- Rebaseline supported client methods on current API route, verb, and request
|
|
7
|
+
contracts and add a machine-checked SDK route inventory.
|
|
8
|
+
- Publish exact-action observation and execution-state types together with the
|
|
9
|
+
v1 receipt, signoff, consume-once, execution-attestation, and evidence flow.
|
package/README.md
CHANGED
|
@@ -61,13 +61,75 @@ const evaluation = await ep.trustEvaluate('merchant-xyz', 'strict');
|
|
|
61
61
|
if (evaluation.decision !== 'allow') throw new Error(`Trust check failed: ${evaluation.reasons?.join(', ')}`);
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
### Wrap a Dangerous Mutation
|
|
65
|
+
|
|
66
|
+
`requireReceipt()` is the five-minute enforcement path: create a v1 trust
|
|
67
|
+
receipt, require signoff when policy demands it, consume the receipt before the
|
|
68
|
+
write, and run the mutation. It emits a post-mutation execution attestation only
|
|
69
|
+
when the executor supplies independently observed action fields; it never treats
|
|
70
|
+
the approved plan itself as proof of execution.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const out = await ep.requireReceipt({
|
|
74
|
+
actionType: 'large_payment_release',
|
|
75
|
+
targetResourceId: 'payment_123',
|
|
76
|
+
afterState: { amount: 82000, currency: 'USD' },
|
|
77
|
+
amount: 82000,
|
|
78
|
+
currency: 'USD',
|
|
79
|
+
approverId: 'ap_controller_jane',
|
|
80
|
+
executingSystem: 'payments-api',
|
|
81
|
+
|
|
82
|
+
// Derive this from the system-of-record response or read-after-write result.
|
|
83
|
+
// If omitted, the mutation can complete but executionStatus is "unobserved".
|
|
84
|
+
observedAction: ({ result }) => ({
|
|
85
|
+
action_type: 'large_payment_release',
|
|
86
|
+
target_resource_id: result.payment_id,
|
|
87
|
+
amount: result.amount,
|
|
88
|
+
currency: result.currency,
|
|
89
|
+
}),
|
|
90
|
+
|
|
91
|
+
// Complete approval externally: passkey ceremony, operator queue, or poller.
|
|
92
|
+
// If omitted when signoff is required, the SDK fails closed and does not run.
|
|
93
|
+
onSignoffRequired: async ({ signoff }) => {
|
|
94
|
+
await waitForApprovedSignoff(signoff?.signoff_id);
|
|
95
|
+
},
|
|
96
|
+
}, async () => {
|
|
97
|
+
return releasePayment('payment_123');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
console.log(out.receipt.receipt_id);
|
|
101
|
+
console.log(out.consume.status); // "consumed"
|
|
102
|
+
console.log(out.executionStatus); // "attested" or "unobserved"
|
|
103
|
+
console.log(out.execution?.binding_status); // "match" or "drift"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For existing functions:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const guardedRelease = ep.withReceipt(
|
|
110
|
+
(payment) => ({
|
|
111
|
+
actionType: 'large_payment_release',
|
|
112
|
+
targetResourceId: payment.id,
|
|
113
|
+
afterState: payment,
|
|
114
|
+
amount: payment.amount,
|
|
115
|
+
currency: payment.currency,
|
|
116
|
+
approverId: 'ap_controller_jane',
|
|
117
|
+
executingSystem: 'payments-api',
|
|
118
|
+
onSignoffRequired: ({ signoff }) => waitForApprovedSignoff(signoff?.signoff_id),
|
|
119
|
+
}),
|
|
120
|
+
releasePayment,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
await guardedRelease({ id: 'payment_123', amount: 82000, currency: 'USD' });
|
|
124
|
+
```
|
|
125
|
+
|
|
64
126
|
---
|
|
65
127
|
|
|
66
128
|
## Environment Variables
|
|
67
129
|
|
|
68
130
|
| Variable | Description | Default |
|
|
69
131
|
|---|---|---|
|
|
70
|
-
| `EP_API_KEY` | Your EP API key (`ep_live_...`). Required for write operations. | — |
|
|
132
|
+
| `EP_API_KEY` | Your EP API key (`ep_live_...`). Required for protected reads and write operations. | — |
|
|
71
133
|
| `EP_BASE_URL` | Override the API base URL (useful for local dev). | `https://emiliaprotocol.ai` |
|
|
72
134
|
|
|
73
135
|
You can also pass these directly to the constructor:
|
|
@@ -144,7 +206,8 @@ EP enforces a mandatory due process pipeline for every negative trust event:
|
|
|
144
206
|
|
|
145
207
|
#### `ep.trustProfile(entityId)`
|
|
146
208
|
|
|
147
|
-
Get
|
|
209
|
+
Get the authenticated entity's full trust profile. This protected read is
|
|
210
|
+
self-scoped by the server (operators may use their broader authorized scope).
|
|
148
211
|
|
|
149
212
|
```typescript
|
|
150
213
|
const profile = await ep.trustProfile('merchant-xyz');
|
|
@@ -186,8 +249,6 @@ if (profile.anomaly) {
|
|
|
186
249
|
console.warn(profile.anomaly.alert); // "Sudden drop: 23 points in 7 days"
|
|
187
250
|
}
|
|
188
251
|
|
|
189
|
-
// Legacy score (fallback only — prefer trust_profile for decisions)
|
|
190
|
-
console.log(profile.compat_score); // 91
|
|
191
252
|
```
|
|
192
253
|
|
|
193
254
|
---
|
|
@@ -346,7 +407,7 @@ console.log(api_key); // "ep_live_..." — store this securely!
|
|
|
346
407
|
|
|
347
408
|
#### `ep.searchEntities(query, entityType?, minConfidence?)`
|
|
348
409
|
|
|
349
|
-
Search for entities by name, capability, or category.
|
|
410
|
+
Search for entities by name, capability, or category. Requires an API key.
|
|
350
411
|
|
|
351
412
|
```typescript
|
|
352
413
|
const { entities } = await ep.searchEntities('payment', 'agent', 'confident');
|
|
@@ -358,7 +419,7 @@ for (const e of entities) {
|
|
|
358
419
|
|
|
359
420
|
#### `ep.leaderboard(limit?, entityType?)`
|
|
360
421
|
|
|
361
|
-
Get the leaderboard
|
|
422
|
+
Get the evidence/confidence-ordered entity leaderboard. Requires an API key.
|
|
362
423
|
|
|
363
424
|
```typescript
|
|
364
425
|
// Top 5 merchants
|
|
@@ -401,32 +462,6 @@ console.log(receipt.receipt_id); // "ep_rcpt_..."
|
|
|
401
462
|
console.log(receipt.receipt_hash); // SHA-256 hash
|
|
402
463
|
```
|
|
403
464
|
|
|
404
|
-
#### `ep.batchSubmit(receipts)`
|
|
405
|
-
|
|
406
|
-
Submit up to 50 receipts in a single atomic call. Partial success is possible.
|
|
407
|
-
|
|
408
|
-
```typescript
|
|
409
|
-
const result = await ep.batchSubmit([
|
|
410
|
-
{
|
|
411
|
-
entity_id: 'merchant-a',
|
|
412
|
-
transaction_ref: 'tx-001',
|
|
413
|
-
transaction_type: 'purchase',
|
|
414
|
-
agent_behavior: 'completed',
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
entity_id: 'merchant-b',
|
|
418
|
-
transaction_ref: 'tx-002',
|
|
419
|
-
transaction_type: 'service',
|
|
420
|
-
agent_behavior: 'completed',
|
|
421
|
-
},
|
|
422
|
-
]);
|
|
423
|
-
|
|
424
|
-
result.results.forEach(r => {
|
|
425
|
-
if (r.success) console.log(`${r.entity_id}: receipt ${r.receipt_id}`);
|
|
426
|
-
else console.error(`${r.entity_id}: ${r.error}`);
|
|
427
|
-
});
|
|
428
|
-
```
|
|
429
|
-
|
|
430
465
|
#### `ep.confirmReceipt(receiptId, confirm)`
|
|
431
466
|
|
|
432
467
|
Bilateral confirmation — counterparty confirms or rejects a receipt within 48 hours. Confirmed receipts receive a higher provenance tier.
|
|
@@ -651,7 +686,7 @@ policies.forEach(p => {
|
|
|
651
686
|
|
|
652
687
|
#### `ep.stats()`
|
|
653
688
|
|
|
654
|
-
|
|
689
|
+
Authenticated operator proof metrics.
|
|
655
690
|
|
|
656
691
|
```typescript
|
|
657
692
|
const stats = await ep.stats();
|
|
@@ -669,15 +704,6 @@ const health = await ep.health();
|
|
|
669
704
|
console.log(health.status); // "ok"
|
|
670
705
|
```
|
|
671
706
|
|
|
672
|
-
#### `ep.legacyScore(entityId)` (deprecated)
|
|
673
|
-
|
|
674
|
-
Returns the 0-100 legacy compatibility score. Prefer `trustProfile()` for all new code.
|
|
675
|
-
|
|
676
|
-
```typescript
|
|
677
|
-
const { score } = await ep.legacyScore('merchant-xyz');
|
|
678
|
-
console.log(score); // 91
|
|
679
|
-
```
|
|
680
|
-
|
|
681
707
|
---
|
|
682
708
|
|
|
683
709
|
## Error Handling
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityType, TrustPolicy, TrustContext, DisputeReason, ReportType, TrustDomain, EntityTrustProfile, TrustEvaluation, SubmitReceiptInput, SubmitReceiptResult, EntitySearchResult, Dispute, LeaderboardEntry, TrustGateResult, DelegationRecord, DomainScoreResult, InstallPreflightResult, PrincipalLookupResult, LineageResult,
|
|
1
|
+
import type { EntityType, TrustPolicy, TrustContext, DisputeReason, ReportType, TrustDomain, EntityTrustProfile, TrustEvaluation, SubmitReceiptInput, SubmitReceiptResult, EntitySearchResult, Dispute, LeaderboardEntry, TrustGateResult, DelegationRecord, DomainScoreResult, InstallPreflightResult, PrincipalLookupResult, LineageResult, ConfirmReceiptResult, TrustPolicyDefinition, EPStats, EPClientOptions, EPCommitRequest, EPCommitVerification, EPCommitIssueResult, EPCommitStatusResult, EPCommitRevokeResult, EPCommitReceiptResult, AttestExecutionParams, ConsumeTrustReceiptParams, ConsumeTrustReceiptResult, CreateTrustReceiptParams, ExecutionAttestation, RequireReceiptParams, RequireReceiptResult, RequestSignoffParams, SignoffRequest, TrustReceipt, TrustReceiptEvidence, TrustReceiptState } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Client for the EMILIA Protocol API.
|
|
4
4
|
*
|
|
@@ -188,22 +188,6 @@ export declare class EPClient {
|
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
190
|
submitReceipt(input: SubmitReceiptInput): Promise<SubmitReceiptResult>;
|
|
191
|
-
/**
|
|
192
|
-
* Submit multiple receipts atomically. Maximum 50 per call.
|
|
193
|
-
*
|
|
194
|
-
* Each result in the response array indicates success or failure for that
|
|
195
|
-
* receipt independently — partial success is possible.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* ```typescript
|
|
199
|
-
* const result = await ep.batchSubmit([
|
|
200
|
-
* { entity_id: 'merchant-a', transaction_ref: 'tx-1', transaction_type: 'purchase', agent_behavior: 'completed' },
|
|
201
|
-
* { entity_id: 'merchant-b', transaction_ref: 'tx-2', transaction_type: 'service', agent_behavior: 'completed' },
|
|
202
|
-
* ]);
|
|
203
|
-
* result.results.forEach(r => console.log(r.entity_id, r.success ? 'ok' : r.error));
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
batchSubmit(receipts: SubmitReceiptInput[]): Promise<BatchReceiptResult>;
|
|
207
191
|
/**
|
|
208
192
|
* Confirm or reject a receipt as the counterparty (bilateral confirmation).
|
|
209
193
|
*
|
|
@@ -231,6 +215,40 @@ export declare class EPClient {
|
|
|
231
215
|
anchored: boolean;
|
|
232
216
|
verified: boolean;
|
|
233
217
|
}>;
|
|
218
|
+
/**
|
|
219
|
+
* Create a v1 pre-action trust receipt for a high-risk mutation.
|
|
220
|
+
*
|
|
221
|
+
* The API derives organization scope from the authenticated API key. If
|
|
222
|
+
* `organizationId` is supplied here, the server treats it as a cross-check.
|
|
223
|
+
*/
|
|
224
|
+
createTrustReceipt(params: CreateTrustReceiptParams): Promise<TrustReceipt>;
|
|
225
|
+
/** Read current receipt state from the append-only v1 audit timeline. */
|
|
226
|
+
getTrustReceipt(receiptId: string): Promise<TrustReceiptState>;
|
|
227
|
+
/** Request human signoff for a receipt that requires approval. */
|
|
228
|
+
requestSignoff(params: RequestSignoffParams): Promise<SignoffRequest>;
|
|
229
|
+
/**
|
|
230
|
+
* Consume a receipt before mutation. This is the reject-before-write gate:
|
|
231
|
+
* if this call fails, the SDK helper never runs the wrapped mutation.
|
|
232
|
+
*/
|
|
233
|
+
consumeTrustReceipt(receiptId: string, params: ConsumeTrustReceiptParams): Promise<ConsumeTrustReceiptResult>;
|
|
234
|
+
/** Emit the post-mutation execution attestation bound to the consumed receipt. */
|
|
235
|
+
attestExecution(receiptId: string, params: AttestExecutionParams): Promise<ExecutionAttestation>;
|
|
236
|
+
/** Fetch the signed evidence packet, when the receipt is in a signable state. */
|
|
237
|
+
getTrustReceiptEvidence(receiptId: string): Promise<TrustReceiptEvidence>;
|
|
238
|
+
/**
|
|
239
|
+
* Five-minute adoption helper: wrap a dangerous mutation in the v1 receipt
|
|
240
|
+
* lifecycle. The mutation runs only after the receipt is created and consumed.
|
|
241
|
+
* If signoff is required, callers must complete it in `onSignoffRequired`.
|
|
242
|
+
*/
|
|
243
|
+
requireReceipt<T>(params: RequireReceiptParams, mutate: (ctx: {
|
|
244
|
+
receipt: TrustReceipt;
|
|
245
|
+
consume: ConsumeTrustReceiptResult;
|
|
246
|
+
}) => Promise<T>): Promise<RequireReceiptResult<T>>;
|
|
247
|
+
/**
|
|
248
|
+
* Convenience wrapper for existing functions. The returned function resolves
|
|
249
|
+
* to the full receipt lifecycle result, not just the mutation return value.
|
|
250
|
+
*/
|
|
251
|
+
withReceipt<TArgs extends unknown[], TResult>(params: RequireReceiptParams | ((...args: TArgs) => RequireReceiptParams), mutate: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<RequireReceiptResult<TResult>>;
|
|
234
252
|
/**
|
|
235
253
|
* File a dispute against a receipt.
|
|
236
254
|
*
|
|
@@ -444,7 +462,7 @@ export declare class EPClient {
|
|
|
444
462
|
policies: TrustPolicyDefinition[];
|
|
445
463
|
}>;
|
|
446
464
|
/**
|
|
447
|
-
*
|
|
465
|
+
* Authenticated operator metrics — entity count, test count, tool count, policy count.
|
|
448
466
|
*
|
|
449
467
|
* @example
|
|
450
468
|
* ```typescript
|
|
@@ -524,17 +542,5 @@ export declare class EPClient {
|
|
|
524
542
|
* ```
|
|
525
543
|
*/
|
|
526
544
|
bindReceiptToCommit(commitId: string, receiptId: string): Promise<EPCommitReceiptResult>;
|
|
527
|
-
/**
|
|
528
|
-
* Legacy: get the 0-100 compatibility score for an entity.
|
|
529
|
-
*
|
|
530
|
-
* Prefer `trustProfile()` for all new integrations. This endpoint exists
|
|
531
|
-
* for backward compatibility only.
|
|
532
|
-
*
|
|
533
|
-
* @deprecated Use trustProfile() instead.
|
|
534
|
-
*/
|
|
535
|
-
legacyScore(entityId: string): Promise<{
|
|
536
|
-
entity_id: string;
|
|
537
|
-
score: number;
|
|
538
|
-
}>;
|
|
539
545
|
}
|
|
540
546
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,YAAY,EAGZ,aAAa,EACb,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,YAAY,EAGZ,aAAa,EACb,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,k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AAO,CAAC,aAAa,CAAC;IAWvD;;;;;;;;;;;;OAYG;IACG,YAAY,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,qBAAqB,EAAE,CAAA;KAAE,CAAC;IAQpE;;;;;;;;OAQG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B;;;;;;;;OAQG;IACG,MAAM,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAQnE;;;;;;;;;;;;;;;;;;OAkBG;IACG,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQxE;;;;;;;;OAQG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAOnE;;;;;;;;OAQG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAMtE;;;;;;;OAOG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQnF;;;;;;;OAOG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAQ/F"}
|
package/dist/client.js
CHANGED
|
@@ -2,9 +2,33 @@
|
|
|
2
2
|
// EMILIA Protocol — TypeScript Client
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import { EPError } from './types.js';
|
|
5
|
-
const SDK_VERSION = '
|
|
5
|
+
const SDK_VERSION = '0.11.0';
|
|
6
6
|
const DEFAULT_BASE_URL = 'https://emiliaprotocol.ai';
|
|
7
7
|
const DEFAULT_TIMEOUT = 30_000;
|
|
8
|
+
function trustReceiptBody(params) {
|
|
9
|
+
return {
|
|
10
|
+
organization_id: params.organizationId,
|
|
11
|
+
action_type: params.actionType,
|
|
12
|
+
target_resource_id: params.targetResourceId,
|
|
13
|
+
policy_id: params.policyId,
|
|
14
|
+
enforcement_mode: params.enforcementMode,
|
|
15
|
+
before_state: params.beforeState,
|
|
16
|
+
after_state: params.afterState,
|
|
17
|
+
target_changed_fields: params.targetChangedFields,
|
|
18
|
+
amount: params.amount,
|
|
19
|
+
currency: params.currency,
|
|
20
|
+
risk_flags: params.riskFlags,
|
|
21
|
+
actor_role: params.actorRole,
|
|
22
|
+
actor_department: params.actorDepartment,
|
|
23
|
+
business_hours: params.businessHours,
|
|
24
|
+
velocity_same_actor_24h: params.velocitySameActor24h,
|
|
25
|
+
prior_denials_actor_30d: params.priorDenialsActor30d,
|
|
26
|
+
prior_changes_target_30d: params.priorChangesTarget30d,
|
|
27
|
+
destination_age_days: params.destinationAgeDays,
|
|
28
|
+
quorum_policy: params.quorumPolicy,
|
|
29
|
+
metadata: params.metadata,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
8
32
|
// ----------------------------------------------------------------------------
|
|
9
33
|
// EPClient
|
|
10
34
|
// ----------------------------------------------------------------------------
|
|
@@ -73,8 +97,16 @@ export class EPClient {
|
|
|
73
97
|
const payload = data;
|
|
74
98
|
const message = typeof payload?.['error'] === 'string'
|
|
75
99
|
? payload['error']
|
|
76
|
-
:
|
|
77
|
-
|
|
100
|
+
: typeof payload?.['detail'] === 'string'
|
|
101
|
+
? payload['detail']
|
|
102
|
+
: typeof payload?.['title'] === 'string'
|
|
103
|
+
? payload['title']
|
|
104
|
+
: `EP API error: ${res.status}`;
|
|
105
|
+
const code = typeof payload?.['code'] === 'string'
|
|
106
|
+
? payload['code']
|
|
107
|
+
: typeof payload?.['type'] === 'string'
|
|
108
|
+
? payload['type'].split('/').pop()
|
|
109
|
+
: undefined;
|
|
78
110
|
throw new EPError(message, res.status, code);
|
|
79
111
|
}
|
|
80
112
|
return data;
|
|
@@ -109,7 +141,7 @@ export class EPClient {
|
|
|
109
141
|
* ```
|
|
110
142
|
*/
|
|
111
143
|
async trustProfile(entityId) {
|
|
112
|
-
return this.request(`/api/trust/profile/${encodeURIComponent(entityId)}
|
|
144
|
+
return this.request(`/api/trust/profile/${encodeURIComponent(entityId)}`, { auth: true });
|
|
113
145
|
}
|
|
114
146
|
/**
|
|
115
147
|
* Evaluate an entity against a named trust policy.
|
|
@@ -130,6 +162,7 @@ export class EPClient {
|
|
|
130
162
|
async trustEvaluate(entityId, policy = 'standard', context) {
|
|
131
163
|
return this.request('/api/trust/evaluate', {
|
|
132
164
|
method: 'POST',
|
|
165
|
+
auth: true,
|
|
133
166
|
body: {
|
|
134
167
|
entity_id: entityId,
|
|
135
168
|
policy,
|
|
@@ -157,6 +190,7 @@ export class EPClient {
|
|
|
157
190
|
async trustGate(options) {
|
|
158
191
|
return this.request('/api/trust/gate', {
|
|
159
192
|
method: 'POST',
|
|
193
|
+
auth: true,
|
|
160
194
|
body: {
|
|
161
195
|
entity_id: options.entityId,
|
|
162
196
|
action: options.action,
|
|
@@ -180,7 +214,10 @@ export class EPClient {
|
|
|
180
214
|
* ```
|
|
181
215
|
*/
|
|
182
216
|
async domainScore(entityId, domains) {
|
|
183
|
-
return this.request(`/api/trust/domain-score/${encodeURIComponent(entityId)}`, {
|
|
217
|
+
return this.request(`/api/trust/domain-score/${encodeURIComponent(entityId)}`, {
|
|
218
|
+
auth: true,
|
|
219
|
+
params: domains?.length ? { domains: domains.join(',') } : undefined,
|
|
220
|
+
});
|
|
184
221
|
}
|
|
185
222
|
/**
|
|
186
223
|
* EP-SX: Software pre-action enforcement check (experimental).
|
|
@@ -202,6 +239,7 @@ export class EPClient {
|
|
|
202
239
|
async installPreflight(entityId, policy, context) {
|
|
203
240
|
return this.request('/api/trust/install-preflight', {
|
|
204
241
|
method: 'POST',
|
|
242
|
+
auth: true,
|
|
205
243
|
body: {
|
|
206
244
|
entity_id: entityId,
|
|
207
245
|
policy: policy ?? 'standard',
|
|
@@ -255,6 +293,7 @@ export class EPClient {
|
|
|
255
293
|
*/
|
|
256
294
|
async searchEntities(query, entityType, minConfidence) {
|
|
257
295
|
return this.request('/api/entities/search', {
|
|
296
|
+
auth: true,
|
|
258
297
|
params: {
|
|
259
298
|
q: query,
|
|
260
299
|
type: entityType,
|
|
@@ -273,6 +312,7 @@ export class EPClient {
|
|
|
273
312
|
*/
|
|
274
313
|
async leaderboard(limit = 10, entityType) {
|
|
275
314
|
return this.request('/api/leaderboard', {
|
|
315
|
+
auth: true,
|
|
276
316
|
params: {
|
|
277
317
|
limit: Math.min(limit, 50),
|
|
278
318
|
type: entityType,
|
|
@@ -311,28 +351,6 @@ export class EPClient {
|
|
|
311
351
|
body: input,
|
|
312
352
|
});
|
|
313
353
|
}
|
|
314
|
-
/**
|
|
315
|
-
* Submit multiple receipts atomically. Maximum 50 per call.
|
|
316
|
-
*
|
|
317
|
-
* Each result in the response array indicates success or failure for that
|
|
318
|
-
* receipt independently — partial success is possible.
|
|
319
|
-
*
|
|
320
|
-
* @example
|
|
321
|
-
* ```typescript
|
|
322
|
-
* const result = await ep.batchSubmit([
|
|
323
|
-
* { entity_id: 'merchant-a', transaction_ref: 'tx-1', transaction_type: 'purchase', agent_behavior: 'completed' },
|
|
324
|
-
* { entity_id: 'merchant-b', transaction_ref: 'tx-2', transaction_type: 'service', agent_behavior: 'completed' },
|
|
325
|
-
* ]);
|
|
326
|
-
* result.results.forEach(r => console.log(r.entity_id, r.success ? 'ok' : r.error));
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
async batchSubmit(receipts) {
|
|
330
|
-
return this.request('/api/receipts/batch', {
|
|
331
|
-
method: 'POST',
|
|
332
|
-
auth: true,
|
|
333
|
-
body: { receipts: receipts.slice(0, 50) },
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
354
|
/**
|
|
337
355
|
* Confirm or reject a receipt as the counterparty (bilateral confirmation).
|
|
338
356
|
*
|
|
@@ -364,6 +382,149 @@ export class EPClient {
|
|
|
364
382
|
return this.request(`/api/verify/${encodeURIComponent(receiptId)}`);
|
|
365
383
|
}
|
|
366
384
|
// --------------------------------------------------------------------------
|
|
385
|
+
// v1 Trust Receipt Enforcement
|
|
386
|
+
// --------------------------------------------------------------------------
|
|
387
|
+
/**
|
|
388
|
+
* Create a v1 pre-action trust receipt for a high-risk mutation.
|
|
389
|
+
*
|
|
390
|
+
* The API derives organization scope from the authenticated API key. If
|
|
391
|
+
* `organizationId` is supplied here, the server treats it as a cross-check.
|
|
392
|
+
*/
|
|
393
|
+
async createTrustReceipt(params) {
|
|
394
|
+
return this.request('/api/v1/trust-receipts', {
|
|
395
|
+
method: 'POST',
|
|
396
|
+
auth: true,
|
|
397
|
+
body: trustReceiptBody(params),
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
/** Read current receipt state from the append-only v1 audit timeline. */
|
|
401
|
+
async getTrustReceipt(receiptId) {
|
|
402
|
+
return this.request(`/api/v1/trust-receipts/${encodeURIComponent(receiptId)}`, { auth: true });
|
|
403
|
+
}
|
|
404
|
+
/** Request human signoff for a receipt that requires approval. */
|
|
405
|
+
async requestSignoff(params) {
|
|
406
|
+
return this.request('/api/v1/signoffs/request', {
|
|
407
|
+
method: 'POST',
|
|
408
|
+
auth: true,
|
|
409
|
+
body: {
|
|
410
|
+
receipt_id: params.receiptId,
|
|
411
|
+
approver_id: params.approverId,
|
|
412
|
+
expires_in_minutes: params.expiresInMinutes,
|
|
413
|
+
comment: params.comment,
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Consume a receipt before mutation. This is the reject-before-write gate:
|
|
419
|
+
* if this call fails, the SDK helper never runs the wrapped mutation.
|
|
420
|
+
*/
|
|
421
|
+
async consumeTrustReceipt(receiptId, params) {
|
|
422
|
+
return this.request(`/api/v1/trust-receipts/${encodeURIComponent(receiptId)}/consume`, {
|
|
423
|
+
method: 'POST',
|
|
424
|
+
auth: true,
|
|
425
|
+
body: {
|
|
426
|
+
action_hash: params.actionHash,
|
|
427
|
+
executing_system: params.executingSystem,
|
|
428
|
+
execution_reference_id: params.executionReferenceId,
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
/** Emit the post-mutation execution attestation bound to the consumed receipt. */
|
|
433
|
+
async attestExecution(receiptId, params) {
|
|
434
|
+
return this.request(`/api/v1/trust-receipts/${encodeURIComponent(receiptId)}/execution`, {
|
|
435
|
+
method: 'POST',
|
|
436
|
+
auth: true,
|
|
437
|
+
body: {
|
|
438
|
+
executed_action: params.executedAction,
|
|
439
|
+
observed_action: params.observedAction,
|
|
440
|
+
executing_system: params.executingSystem,
|
|
441
|
+
execution_id: params.executionId,
|
|
442
|
+
executed_at: params.executedAt,
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
/** Fetch the signed evidence packet, when the receipt is in a signable state. */
|
|
447
|
+
async getTrustReceiptEvidence(receiptId) {
|
|
448
|
+
return this.request(`/api/v1/trust-receipts/${encodeURIComponent(receiptId)}/evidence`, { auth: true });
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Five-minute adoption helper: wrap a dangerous mutation in the v1 receipt
|
|
452
|
+
* lifecycle. The mutation runs only after the receipt is created and consumed.
|
|
453
|
+
* If signoff is required, callers must complete it in `onSignoffRequired`.
|
|
454
|
+
*/
|
|
455
|
+
async requireReceipt(params, mutate) {
|
|
456
|
+
const receipt = await this.createTrustReceipt(params);
|
|
457
|
+
if (receipt.decision === 'deny' || receipt.receipt_status === 'denied') {
|
|
458
|
+
throw new EPError('EMILIA denied the action before execution', 403, 'receipt_denied');
|
|
459
|
+
}
|
|
460
|
+
let signoff;
|
|
461
|
+
if (receipt.signoff_required) {
|
|
462
|
+
if (!params.approverId && !params.quorumPolicy) {
|
|
463
|
+
throw new EPError('Receipt requires signoff; pass approverId or quorumPolicy', 409, 'missing_approver_id');
|
|
464
|
+
}
|
|
465
|
+
signoff = await this.requestSignoff({
|
|
466
|
+
receiptId: receipt.receipt_id,
|
|
467
|
+
approverId: params.approverId,
|
|
468
|
+
expiresInMinutes: params.signoffExpiresInMinutes,
|
|
469
|
+
comment: params.signoffComment,
|
|
470
|
+
});
|
|
471
|
+
if (!params.onSignoffRequired) {
|
|
472
|
+
throw new EPError('Receipt requires human signoff before the mutation can run', 409, 'signoff_required');
|
|
473
|
+
}
|
|
474
|
+
const signoffResult = await params.onSignoffRequired({ client: this, receipt, signoff });
|
|
475
|
+
if (signoffResult === false || (typeof signoffResult === 'object' && signoffResult?.approved === false)) {
|
|
476
|
+
throw new EPError('Human signoff was not approved', 403, 'signoff_rejected');
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
const consume = await this.consumeTrustReceipt(receipt.receipt_id, {
|
|
480
|
+
actionHash: receipt.action_hash,
|
|
481
|
+
executingSystem: params.executingSystem,
|
|
482
|
+
executionReferenceId: params.executionReferenceId,
|
|
483
|
+
});
|
|
484
|
+
const result = await mutate({ receipt, consume });
|
|
485
|
+
const explicitExecutedAction = typeof params.executedAction === 'function'
|
|
486
|
+
? params.executedAction({ receipt, result })
|
|
487
|
+
: params.executedAction;
|
|
488
|
+
const observedAction = typeof params.observedAction === 'function'
|
|
489
|
+
? params.observedAction({ receipt, result })
|
|
490
|
+
: params.observedAction ?? explicitExecutedAction;
|
|
491
|
+
let execution;
|
|
492
|
+
if (observedAction !== undefined) {
|
|
493
|
+
const executedAction = explicitExecutedAction ?? receipt.canonical_action;
|
|
494
|
+
const executionId = typeof params.executionId === 'function'
|
|
495
|
+
? params.executionId(result)
|
|
496
|
+
: params.executionId;
|
|
497
|
+
execution = await this.attestExecution(receipt.receipt_id, {
|
|
498
|
+
executedAction,
|
|
499
|
+
observedAction,
|
|
500
|
+
executingSystem: params.executingSystem,
|
|
501
|
+
executionId,
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
const evidence = params.fetchEvidence
|
|
505
|
+
? await this.getTrustReceiptEvidence(receipt.receipt_id)
|
|
506
|
+
: undefined;
|
|
507
|
+
return {
|
|
508
|
+
result,
|
|
509
|
+
receipt,
|
|
510
|
+
signoff,
|
|
511
|
+
consume,
|
|
512
|
+
execution,
|
|
513
|
+
executionStatus: execution ? 'attested' : 'unobserved',
|
|
514
|
+
evidence,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Convenience wrapper for existing functions. The returned function resolves
|
|
519
|
+
* to the full receipt lifecycle result, not just the mutation return value.
|
|
520
|
+
*/
|
|
521
|
+
withReceipt(params, mutate) {
|
|
522
|
+
return async (...args) => {
|
|
523
|
+
const resolved = typeof params === 'function' ? params(...args) : params;
|
|
524
|
+
return this.requireReceipt(resolved, () => mutate(...args));
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
// --------------------------------------------------------------------------
|
|
367
528
|
// Disputes & Due Process
|
|
368
529
|
// --------------------------------------------------------------------------
|
|
369
530
|
/**
|
|
@@ -572,7 +733,7 @@ export class EPClient {
|
|
|
572
733
|
* ```
|
|
573
734
|
*/
|
|
574
735
|
async principalLookup(principalId) {
|
|
575
|
-
return this.request(`/api/identity/principal/${encodeURIComponent(principalId)}
|
|
736
|
+
return this.request(`/api/identity/principal/${encodeURIComponent(principalId)}`, { auth: true });
|
|
576
737
|
}
|
|
577
738
|
/**
|
|
578
739
|
* View entity lineage — predecessors, successors, and continuity decisions.
|
|
@@ -589,7 +750,7 @@ export class EPClient {
|
|
|
589
750
|
* ```
|
|
590
751
|
*/
|
|
591
752
|
async lineage(entityId) {
|
|
592
|
-
return this.request(`/api/identity/lineage/${encodeURIComponent(entityId)}
|
|
753
|
+
return this.request(`/api/identity/lineage/${encodeURIComponent(entityId)}`, { auth: true });
|
|
593
754
|
}
|
|
594
755
|
// --------------------------------------------------------------------------
|
|
595
756
|
// Policies
|
|
@@ -608,13 +769,13 @@ export class EPClient {
|
|
|
608
769
|
* ```
|
|
609
770
|
*/
|
|
610
771
|
async listPolicies() {
|
|
611
|
-
return this.request('/api/policies');
|
|
772
|
+
return this.request('/api/policies', { auth: true });
|
|
612
773
|
}
|
|
613
774
|
// --------------------------------------------------------------------------
|
|
614
775
|
// System
|
|
615
776
|
// --------------------------------------------------------------------------
|
|
616
777
|
/**
|
|
617
|
-
*
|
|
778
|
+
* Authenticated operator metrics — entity count, test count, tool count, policy count.
|
|
618
779
|
*
|
|
619
780
|
* @example
|
|
620
781
|
* ```typescript
|
|
@@ -623,7 +784,7 @@ export class EPClient {
|
|
|
623
784
|
* ```
|
|
624
785
|
*/
|
|
625
786
|
async stats() {
|
|
626
|
-
return this.request('/api/stats');
|
|
787
|
+
return this.request('/api/stats', { auth: true });
|
|
627
788
|
}
|
|
628
789
|
/**
|
|
629
790
|
* Health check. Returns subsystem status.
|
|
@@ -725,16 +886,5 @@ export class EPClient {
|
|
|
725
886
|
body: { receipt_id: receiptId },
|
|
726
887
|
});
|
|
727
888
|
}
|
|
728
|
-
/**
|
|
729
|
-
* Legacy: get the 0-100 compatibility score for an entity.
|
|
730
|
-
*
|
|
731
|
-
* Prefer `trustProfile()` for all new integrations. This endpoint exists
|
|
732
|
-
* for backward compatibility only.
|
|
733
|
-
*
|
|
734
|
-
* @deprecated Use trustProfile() instead.
|
|
735
|
-
*/
|
|
736
|
-
async legacyScore(entityId) {
|
|
737
|
-
return this.request(`/api/score/${encodeURIComponent(entityId)}`);
|
|
738
|
-
}
|
|
739
889
|
}
|
|
740
890
|
//# sourceMappingURL=client.js.map
|