@emilia-protocol/sdk 0.1.0 → 0.10.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/dist/index.d.ts CHANGED
@@ -1,194 +1,750 @@
1
- /**
2
- * @emilia-protocol/sdk
3
- *
4
- * TypeScript SDK for EMILIA Protocol (EP).
5
- * The trust layer for agentic commerce.
6
- *
7
- * Usage:
8
- * import { EmiliaClient } from '@emilia-protocol/sdk';
9
- * const ep = new EmiliaClient({ apiKey: 'ep_live_...' });
10
- * const score = await ep.getScore('rex-booking-v1');
11
- *
12
- * @license Apache-2.0
13
- */
14
- export interface EmiliaConfig {
15
- /** Base URL of the EP implementation. Default: https://emiliaprotocol.ai */
1
+ /** EMILIA Protocol — Full SDK. Zero dependencies, native fetch. @license Apache-2.0 */
2
+ export interface EPClientOptions {
16
3
  baseUrl?: string;
17
- /** API key for write operations (ep_live_...) */
18
4
  apiKey?: string;
19
- /** Request timeout in ms. Default: 10000 */
20
5
  timeout?: number;
6
+ retries?: number;
21
7
  }
22
- export interface ScoreBreakdown {
23
- delivery_accuracy: number | null;
24
- product_accuracy: number | null;
25
- price_integrity: number | null;
26
- return_processing: number | null;
27
- agent_satisfaction: number | null;
28
- consistency: number | null;
29
- }
30
- export interface ScoreResult {
31
- entity_id: string;
32
- display_name: string;
33
- entity_type: 'agent' | 'merchant' | 'service_provider';
34
- description?: string;
35
- category?: string;
36
- capabilities?: string[];
37
- emilia_score: number;
38
- established: boolean;
39
- total_receipts: number;
40
- successful_receipts: number;
41
- success_rate: number | null;
42
- breakdown: ScoreBreakdown | null;
43
- verified: boolean;
44
- a2a_endpoint?: string;
45
- ucp_profile_url?: string;
46
- member_since: string;
47
- }
48
- export type TransactionType = 'purchase' | 'service' | 'task_completion' | 'delivery' | 'return';
49
- export interface SubmitReceiptInput {
50
- entity_id: string;
51
- transaction_type: TransactionType;
52
- transaction_ref?: string;
53
- delivery_accuracy?: number;
54
- product_accuracy?: number;
55
- price_integrity?: number;
56
- return_processing?: number;
57
- agent_satisfaction?: number;
58
- evidence?: Record<string, unknown>;
59
- }
60
- export interface ReceiptResult {
61
- receipt: {
62
- receipt_id: string;
63
- entity_id: string;
64
- composite_score: number;
65
- receipt_hash: string;
66
- created_at: string;
67
- };
68
- entity_score: {
69
- emilia_score: number;
70
- total_receipts: number;
71
- };
8
+ export interface Party {
9
+ entityRef: string;
10
+ role: 'initiator' | 'responder';
72
11
  }
73
- export interface RegisterEntityInput {
74
- entity_id: string;
75
- display_name: string;
76
- entity_type: 'agent' | 'merchant' | 'service_provider';
77
- description: string;
78
- capabilities?: string[];
79
- website_url?: string;
80
- category?: string;
81
- service_area?: string;
82
- a2a_endpoint?: string;
83
- ucp_profile_url?: string;
84
- }
85
- export interface RegisterResult {
86
- entity: {
87
- id: string;
88
- entity_id: string;
89
- display_name: string;
90
- entity_number?: number;
91
- emilia_score: number;
92
- };
93
- api_key: string;
12
+ export interface InitiateHandshakeParams {
13
+ mode: 'mutual' | 'one-way' | 'delegated';
14
+ policyId: string;
15
+ parties: Party[];
16
+ binding?: Record<string, unknown>;
17
+ interactionId?: string;
18
+ }
19
+ export interface PresentParams {
20
+ partyRole: string;
21
+ presentationType: 'ep_trust_profile' | 'verifiable_credential' | 'attestation';
22
+ claims: Record<string, unknown>;
23
+ issuerRef?: string;
24
+ disclosureMode?: 'full' | 'selective' | 'zk';
25
+ }
26
+ export interface GateParams {
27
+ entityId: string;
28
+ action: string;
29
+ policy?: 'strict' | 'standard' | 'permissive' | string;
30
+ handshakeId?: string;
31
+ valueUsd?: number;
32
+ delegationId?: string;
33
+ }
34
+ export interface ConsumeParams {
35
+ receiptData?: Record<string, unknown>;
36
+ }
37
+ export interface IssueChallengeParams {
38
+ entityId: string;
39
+ scope: string;
40
+ context?: Record<string, unknown>;
41
+ }
42
+ export interface AttestParams {
43
+ signature: string;
44
+ payload: Record<string, unknown>;
45
+ }
46
+ export interface ConsumeSignoffParams {
47
+ action: string;
48
+ context?: Record<string, unknown>;
49
+ }
50
+ export interface DenyChallengeParams {
51
+ reason?: string;
52
+ }
53
+ export interface RevokeSignoffOptions {
54
+ reason?: string;
55
+ force?: boolean;
56
+ }
57
+ export interface CreateDelegationParams {
58
+ delegatorId: string;
59
+ delegateeId: string;
60
+ scope: string;
61
+ policyId: string;
62
+ constraints?: Record<string, unknown>;
63
+ expiresAt?: string;
64
+ }
65
+ export interface IssueCommitParams {
66
+ handshakeId: string;
67
+ action: string;
68
+ payload: Record<string, unknown>;
69
+ binding?: Record<string, unknown>;
70
+ }
71
+ export interface RecordObservationParams {
72
+ source_type: string;
73
+ source_ref: string;
74
+ subject_ref: string;
75
+ actor_ref: string;
76
+ action_type: string;
77
+ target_ref?: string;
78
+ issuer_ref?: string;
79
+ observation_type: string;
80
+ severity_hint: string;
81
+ evidence_hash?: string;
82
+ expires_at: string;
83
+ metadata?: Record<string, unknown>;
84
+ }
85
+ export interface CheckActionParams {
86
+ subject_ref: string;
87
+ actor_ref: string;
88
+ action_type: string;
89
+ target_ref?: string;
90
+ issuer_ref?: string;
91
+ context_hash: string;
92
+ payload_hash?: string;
93
+ policy_class?: string;
94
+ }
95
+ export interface CreateSuppressionParams {
96
+ scope_binding_hash: string;
97
+ reason_code: string;
98
+ justification: string;
99
+ expires_at: string;
100
+ }
101
+ export type GuardActionType = 'benefit_bank_account_change' | 'benefit_address_change' | 'caseworker_override' | 'vendor_bank_account_change' | 'beneficiary_creation' | 'large_payment_release' | 'ai_agent_payment_action';
102
+ export type GuardDecision = 'allow' | 'observe' | 'allow_with_signoff' | 'deny';
103
+ export type GuardEnforcementMode = 'observe' | 'warn' | 'enforce';
104
+ export interface GuardQuorumPolicy {
105
+ mode?: 'threshold' | 'all';
106
+ required: number;
107
+ approvers: Array<{
108
+ role: string;
109
+ approver: string;
110
+ }>;
111
+ }
112
+ export interface CreateTrustReceiptParams {
113
+ organizationId?: string;
114
+ actionType: GuardActionType | string;
115
+ targetResourceId: string;
116
+ policyId?: string;
117
+ enforcementMode?: GuardEnforcementMode;
118
+ beforeState?: Record<string, unknown>;
119
+ afterState?: Record<string, unknown>;
120
+ targetChangedFields?: string[];
121
+ amount?: number;
122
+ currency?: string;
123
+ riskFlags?: string[];
124
+ actorRole?: string;
125
+ actorDepartment?: string;
126
+ businessHours?: boolean;
127
+ velocitySameActor24h?: number;
128
+ priorDenialsActor30d?: number;
129
+ priorChangesTarget30d?: number;
130
+ destinationAgeDays?: number;
131
+ quorumPolicy?: GuardQuorumPolicy;
132
+ metadata?: Record<string, unknown>;
133
+ }
134
+ export interface TrustReceipt {
135
+ receipt_id: string;
136
+ decision: GuardDecision;
137
+ observed_decision?: GuardDecision | null;
138
+ policy_id: string;
139
+ policy_hash: string;
140
+ action_hash: string;
141
+ before_state_hash?: string | null;
142
+ after_state_hash?: string | null;
143
+ nonce: string;
144
+ expires_at: string;
145
+ signoff_required: boolean;
146
+ signoff_request_id?: string | null;
147
+ risk_flags?: string[];
148
+ receipt_status: string;
149
+ enforcement_mode: string;
150
+ reasons?: string[];
151
+ canonical_action: Record<string, unknown>;
152
+ }
153
+ export interface TrustReceiptState {
154
+ receipt_id: string;
155
+ organization_id: string;
156
+ action_type: string;
157
+ decision: GuardDecision;
158
+ enforcement_mode: string;
159
+ policy_id: string;
160
+ policy_hash: string;
161
+ action_hash: string;
162
+ expires_at: string;
163
+ signoff_required: boolean;
164
+ receipt_status: string;
165
+ signoff_key_class?: string | null;
166
+ timeline_event_count: number;
94
167
  }
95
- export interface VerifyResult {
168
+ export interface RequestSignoffParams {
169
+ receiptId: string;
170
+ approverId?: string;
171
+ expiresInMinutes?: number;
172
+ comment?: string;
173
+ }
174
+ export interface SignoffRequest {
175
+ signoff_id?: string;
96
176
  receipt_id: string;
97
- receipt_hash: string;
98
- anchored: boolean;
99
- batch?: {
100
- id: string;
101
- merkle_root: string;
102
- leaf_count: number;
103
- tx_hash: string | null;
104
- block_number: number | null;
105
- status: string;
106
- created_at: string;
177
+ action_hash: string;
178
+ initiator_id: string;
179
+ approver_id?: string;
180
+ expires_at: string;
181
+ status: string;
182
+ quorum?: {
183
+ mode: string;
184
+ required: number;
185
+ count: number;
107
186
  };
108
- proof?: Array<{
109
- hash: string;
110
- position: 'left' | 'right';
111
- }>;
112
- verified: boolean;
113
- how_to_verify?: Record<string, string | null>;
114
- }
115
- export interface SearchResult {
116
- entities: Array<{
117
- entity_id: string;
118
- display_name: string;
119
- entity_type: string;
120
- description: string;
121
- emilia_score: number;
122
- total_receipts: number;
123
- verified: boolean;
187
+ signoffs?: Array<{
188
+ signoff_id: string;
189
+ role?: string;
190
+ approver_id: string;
124
191
  }>;
125
192
  }
126
- export interface LeaderboardResult {
127
- entities: Array<{
128
- entity_id: string;
129
- display_name: string;
130
- entity_type: string;
131
- emilia_score: number;
132
- total_receipts: number;
193
+ export interface ConsumeTrustReceiptResult {
194
+ receipt_id: string;
195
+ status: string;
196
+ consumed_at: string;
197
+ consumed_by_system: string;
198
+ execution_reference_id?: string | null;
199
+ }
200
+ export interface ExecutionAttestation {
201
+ receipt_id: string;
202
+ status: string;
203
+ binding_status: string;
204
+ executed_action_hash: string;
205
+ approved_action_hash: string;
206
+ execution_integrity: Record<string, unknown>;
207
+ }
208
+ export interface TrustReceiptEvidence {
209
+ document: Record<string, unknown> | null;
210
+ public_key: string | null;
211
+ signed: boolean;
212
+ verify_with: string;
213
+ receipt_id: string;
214
+ organization_id: string;
215
+ issued_at: string;
216
+ expires_at: string;
217
+ schema_version: string;
218
+ [key: string]: unknown;
219
+ }
220
+ export interface RequireReceiptParams extends CreateTrustReceiptParams {
221
+ executingSystem: string;
222
+ executionReferenceId?: string;
223
+ approverId?: string;
224
+ signoffComment?: string;
225
+ signoffExpiresInMinutes?: number;
226
+ onSignoffRequired?: (ctx: {
227
+ client: EPClient;
228
+ receipt: TrustReceipt;
229
+ signoff?: SignoffRequest;
230
+ }) => Promise<void | boolean | {
231
+ approved?: boolean;
133
232
  }>;
233
+ executedAction?: Record<string, unknown> | ((ctx: {
234
+ receipt: TrustReceipt;
235
+ result: unknown;
236
+ }) => Record<string, unknown>);
237
+ executionId?: string | ((result: unknown) => string | undefined);
238
+ fetchEvidence?: boolean;
134
239
  }
135
- export declare class EmiliaError extends Error {
136
- status: number;
137
- constructor(message: string, status: number);
240
+ export interface RequireReceiptResult<T> {
241
+ result: T;
242
+ receipt: TrustReceipt;
243
+ signoff?: SignoffRequest;
244
+ consume: ConsumeTrustReceiptResult;
245
+ execution: ExecutionAttestation;
246
+ evidence?: TrustReceiptEvidence;
138
247
  }
139
- export declare class EmiliaClient {
140
- private baseUrl;
141
- private apiKey;
142
- private timeout;
143
- constructor(config?: EmiliaConfig);
144
- private request;
145
- /**
146
- * Look up an entity's EMILIA Score.
147
- * No authentication required — scores are public by design.
148
- */
149
- getScore(entityId: string): Promise<ScoreResult>;
150
- /**
151
- * Submit a transaction receipt.
152
- * Requires API key.
153
- */
154
- submitReceipt(input: SubmitReceiptInput): Promise<ReceiptResult>;
155
- /**
156
- * Register a new entity.
157
- * Requires API key.
158
- */
159
- registerEntity(input: RegisterEntityInput): Promise<RegisterResult>;
160
- /**
161
- * Verify a receipt against the on-chain Merkle root.
162
- * No authentication required.
163
- */
164
- verifyReceipt(receiptId: string): Promise<VerifyResult>;
248
+ export interface ObservationResponse {
249
+ observation_id: string;
250
+ observation_type: string;
251
+ severity_hint: string;
252
+ observed_at: string;
253
+ expires_at: string;
254
+ }
255
+ export interface AdvisoryResponse {
256
+ advisory_id: string;
257
+ status: string;
258
+ reason_codes: string[];
259
+ recommended_policy_action: string;
260
+ evidence_refs: string[];
261
+ scope_binding_hash: string;
262
+ issued_at: string;
263
+ expires_at: string;
264
+ version: number;
265
+ }
266
+ export interface SuppressionResponse {
267
+ suppression_id: string;
268
+ status: string;
269
+ created_at: string;
270
+ expires_at: string;
271
+ }
272
+ export interface SignoffFilters {
273
+ entityId?: string;
274
+ scope?: string;
275
+ status?: string;
276
+ limit?: number;
277
+ offset?: number;
278
+ }
279
+ export interface DateRange {
280
+ from?: string;
281
+ to?: string;
282
+ }
283
+ export interface EscalateSignoffParams {
284
+ challengeId: string;
285
+ escalateTo: string;
286
+ reason: string;
287
+ }
288
+ export interface NotifySignoffParams {
289
+ challengeId: string;
290
+ channel: string;
291
+ }
292
+ export interface SearchEventsParams {
293
+ query: string;
294
+ filters?: Record<string, unknown>;
295
+ }
296
+ export interface ExportAuditParams {
297
+ format?: 'json' | 'csv' | 'pdf';
298
+ dateRange?: DateRange;
299
+ entityId?: string;
300
+ eventTypes?: string[];
301
+ }
302
+ export interface GetAuditReportParams {
303
+ reportType: string;
304
+ dateRange: DateRange;
305
+ }
306
+ export interface SimulatePolicyParams {
307
+ policyId: string;
308
+ context: Record<string, unknown>;
309
+ }
310
+ export interface RolloutPolicyParams {
311
+ policyId: string;
312
+ /** Policy version number to roll out (resolved against handshake_policies). */
313
+ version: number;
314
+ /** Target environment, e.g. "production" or "staging". */
315
+ environment: string;
316
+ strategy?: 'immediate' | 'canary';
317
+ /** Traffic percentage (1–99) for canary rollouts. */
318
+ canaryPct?: number;
319
+ }
320
+ export interface DiffPolicyVersionsParams {
321
+ policyId: string;
322
+ /** First version number to compare. */
323
+ v1: number;
324
+ /** Second version number to compare. */
325
+ v2: number;
326
+ }
327
+ export interface Policy {
328
+ name: string;
329
+ family: string;
330
+ description: string;
331
+ minConfidence?: string;
332
+ minScore?: number;
333
+ }
334
+ export interface Handshake {
335
+ id: string;
336
+ status: string;
337
+ mode: string;
338
+ policyId: string;
339
+ parties: Party[];
340
+ createdAt: string;
341
+ }
342
+ export interface Presentation {
343
+ presentationId: string;
344
+ partyRole: string;
345
+ status: string;
346
+ createdAt: string;
347
+ }
348
+ export interface VerificationResult {
349
+ handshakeId: string;
350
+ result: 'accepted' | 'rejected' | 'partial';
351
+ reasonCodes: string[];
352
+ evaluatedAt: string;
353
+ }
354
+ export interface GateResult {
355
+ decision: 'allow' | 'deny' | 'review';
356
+ commitRef?: string;
357
+ reasons: string[];
358
+ appealPath?: string;
359
+ }
360
+ export interface SignoffChallenge {
361
+ challengeId: string;
362
+ entityId: string;
363
+ scope: string;
364
+ nonce: string;
365
+ expiresAt: string;
366
+ }
367
+ export interface SignoffAttestation {
368
+ attestationId: string;
369
+ challengeId: string;
370
+ status: 'valid' | 'invalid' | 'expired';
371
+ signoffId?: string;
372
+ createdAt: string;
373
+ }
374
+ export interface SignoffConsumption {
375
+ signoffId: string;
376
+ consumed: boolean;
377
+ action: string;
378
+ consumedAt?: string;
379
+ }
380
+ export interface Consumption {
381
+ handshakeId: string;
382
+ consumed: boolean;
383
+ receiptId?: string;
384
+ consumedAt?: string;
385
+ }
386
+ export interface RevokeResult {
387
+ id: string;
388
+ revoked: boolean;
389
+ revokedAt: string;
390
+ }
391
+ export interface DenyResult {
392
+ challengeId: string;
393
+ denied: boolean;
394
+ reason?: string;
395
+ deniedAt: string;
396
+ }
397
+ export interface Delegation {
398
+ delegationId: string;
399
+ delegatorId: string;
400
+ delegateeId: string;
401
+ scope: string;
402
+ policyId: string;
403
+ status: string;
404
+ constraints?: Record<string, unknown>;
405
+ createdAt: string;
406
+ expiresAt?: string;
407
+ }
408
+ export interface DelegationVerification {
409
+ delegationId: string;
410
+ valid: boolean;
411
+ status: string;
412
+ reasonCodes: string[];
413
+ verifiedAt: string;
414
+ }
415
+ export interface Commit {
416
+ commitId: string;
417
+ handshakeId: string;
418
+ action: string;
419
+ status: string;
420
+ payload: Record<string, unknown>;
421
+ createdAt: string;
422
+ }
423
+ export interface CommitVerification {
424
+ commitId: string;
425
+ valid: boolean;
426
+ status: string;
427
+ reasonCodes: string[];
428
+ verifiedAt: string;
429
+ }
430
+ export interface PendingSignoff {
431
+ challengeId: string;
432
+ entityId: string;
433
+ scope: string;
434
+ status: string;
435
+ createdAt: string;
436
+ expiresAt: string;
437
+ }
438
+ export interface PendingSignoffsResponse {
439
+ items: PendingSignoff[];
440
+ total: number;
441
+ offset: number;
442
+ limit: number;
443
+ }
444
+ export interface SignoffQueueItem {
445
+ challengeId: string;
446
+ entityId: string;
447
+ scope: string;
448
+ priority: string;
449
+ status: string;
450
+ createdAt: string;
451
+ expiresAt: string;
452
+ }
453
+ export interface SignoffQueueResponse {
454
+ items: SignoffQueueItem[];
455
+ total: number;
456
+ offset: number;
457
+ limit: number;
458
+ }
459
+ export interface SignoffDashboard {
460
+ pending: number;
461
+ approved: number;
462
+ denied: number;
463
+ expired: number;
464
+ averageResponseTime: number;
465
+ recentActivity: DashboardActivity[];
466
+ }
467
+ export interface DashboardActivity {
468
+ challengeId: string;
469
+ action: string;
470
+ entityId: string;
471
+ timestamp: string;
472
+ }
473
+ export interface SignoffAnalytics {
474
+ totalChallenges: number;
475
+ approvalRate: number;
476
+ averageResponseTime: number;
477
+ byScope: Record<string, number>;
478
+ timeseries: AnalyticsDataPoint[];
479
+ }
480
+ export interface AnalyticsDataPoint {
481
+ timestamp: string;
482
+ count: number;
483
+ approved: number;
484
+ denied: number;
485
+ }
486
+ export interface EscalationResult {
487
+ challengeId: string;
488
+ escalatedTo: string;
489
+ escalatedAt: string;
490
+ status: string;
491
+ }
492
+ export interface NotificationResult {
493
+ challengeId: string;
494
+ channel: string;
495
+ sent: boolean;
496
+ sentAt: string;
497
+ }
498
+ export interface AuditEvent {
499
+ eventId: string;
500
+ type: string;
501
+ entityId: string;
502
+ action: string;
503
+ metadata: Record<string, unknown>;
504
+ timestamp: string;
505
+ }
506
+ export interface SearchEventsResponse {
507
+ items: AuditEvent[];
508
+ total: number;
509
+ }
510
+ export interface EventTimeline {
511
+ handshakeId: string;
512
+ events: AuditEvent[];
513
+ }
514
+ export interface ExportAuditResult {
515
+ exportId: string;
516
+ format: string;
517
+ status: string;
518
+ downloadUrl?: string;
519
+ createdAt: string;
520
+ }
521
+ export interface AuditReport {
522
+ reportType: string;
523
+ dateRange: DateRange;
524
+ summary: Record<string, unknown>;
525
+ items: AuditEvent[];
526
+ generatedAt: string;
527
+ }
528
+ export interface IntegrityCheckResult {
529
+ healthy: boolean;
530
+ checks: IntegrityCheck[];
531
+ checkedAt: string;
532
+ }
533
+ export interface IntegrityCheck {
534
+ name: string;
535
+ status: 'pass' | 'fail' | 'warn';
536
+ message?: string;
537
+ }
538
+ export interface PolicySimulationResult {
539
+ policyId: string;
540
+ decision: 'allow' | 'deny' | 'review';
541
+ reasons: string[];
542
+ evaluatedAt: string;
543
+ }
544
+ export interface PolicyRolloutResult {
545
+ rollout_id: string;
546
+ /** handshake_policies policy_id of the rolled-out version row. */
547
+ policy_id: string;
548
+ policy_key: string;
549
+ version: number;
550
+ environment: string;
551
+ strategy: string;
552
+ status: string;
553
+ canary_pct: number | null;
554
+ initiated_at: string;
555
+ tenant_id: string;
556
+ }
557
+ /**
558
+ * A policy version is a handshake_policies row. Versions sharing a policy_key
559
+ * form the version history of a single policy.
560
+ */
561
+ export interface PolicyVersion {
562
+ policy_id: string;
563
+ policy_key: string;
564
+ version: number;
565
+ name: string;
566
+ mode: string;
567
+ status: string;
568
+ rules: Record<string, unknown>;
569
+ created_at: string;
570
+ updated_at: string;
571
+ }
572
+ export interface PolicyVersionsResult {
573
+ policy_id: string;
574
+ policy_key: string;
575
+ versions: PolicyVersion[];
576
+ count: number;
577
+ tenant_id: string;
578
+ }
579
+ /** A single classified field change between two policy versions' rules. */
580
+ export interface PolicyChange {
581
+ path: string;
582
+ before: unknown;
583
+ after: unknown;
584
+ risk: 'loosening' | 'tightening' | 'neutral';
585
+ rationale: string;
586
+ }
587
+ /** Semantic diff of v1.rules vs v2.rules. */
588
+ export interface PolicyRulesDiff {
589
+ changes: PolicyChange[];
590
+ risk: 'loosening' | 'tightening' | 'neutral';
591
+ summary: {
592
+ loosening: number;
593
+ tightening: number;
594
+ neutral: number;
595
+ };
596
+ }
597
+ export interface PolicyDiff {
598
+ policy_id: string;
599
+ policy_key: string;
600
+ /** The lower-numbered handshake_policies version row. */
601
+ v1: PolicyVersion;
602
+ /** The higher-numbered handshake_policies version row. */
603
+ v2: PolicyVersion;
604
+ diff: PolicyRulesDiff;
605
+ tenant_id: string;
606
+ }
607
+ export declare class EPError extends Error {
608
+ readonly status?: number | undefined;
609
+ readonly code?: string | undefined;
610
+ constructor(message: string, status?: number | undefined, code?: string | undefined);
611
+ }
612
+ export declare class EPCloudClient {
613
+ private readonly _request;
614
+ /** @internal */
615
+ constructor(_request: <T>(method: string, path: string, body?: unknown, auth?: boolean) => Promise<T>);
616
+ /** Get pending signoffs, optionally filtered by entity, scope, or status. */
617
+ getPendingSignoffs(filters?: SignoffFilters): Promise<PendingSignoffsResponse>;
618
+ /** Get the signoff queue with optional filtering. */
619
+ getSignoffQueue(filters?: SignoffFilters): Promise<SignoffQueueResponse>;
620
+ /** Get a dashboard summary of signoff activity over a date range. */
621
+ getSignoffDashboard(dateRange?: DateRange): Promise<SignoffDashboard>;
622
+ /** Get analytics for signoff activity with optional granularity. */
623
+ getSignoffAnalytics(dateRange?: DateRange, granularity?: 'hour' | 'day' | 'week' | 'month'): Promise<SignoffAnalytics>;
624
+ /** Escalate a signoff challenge to another entity. */
625
+ escalateSignoff(challengeId: string, escalateTo: string, reason: string): Promise<EscalationResult>;
626
+ /** Send a notification about a signoff challenge via the specified channel. */
627
+ notifySignoff(challengeId: string, channel: string): Promise<NotificationResult>;
628
+ /** Search audit events by query string and optional filters. */
629
+ searchEvents(query: string, filters?: Record<string, unknown>): Promise<SearchEventsResponse>;
630
+ /** Get a chronological timeline of events for a specific handshake. */
631
+ getEventTimeline(handshakeId: string): Promise<EventTimeline>;
632
+ /** Export audit data in the specified format. */
633
+ exportAudit(params: ExportAuditParams): Promise<ExportAuditResult>;
634
+ /** Generate an audit report for the given type and date range. */
635
+ getAuditReport(reportType: string, dateRange: DateRange): Promise<AuditReport>;
636
+ /** Run an integrity check on the protocol data store. */
637
+ checkIntegrity(): Promise<IntegrityCheckResult>;
638
+ /** Simulate a policy against a hypothetical context without persisting any state. */
639
+ simulatePolicy(policyId: string, context: Record<string, unknown>): Promise<PolicySimulationResult>;
165
640
  /**
166
- * Search for entities.
167
- * No authentication required.
641
+ * Roll out a specific policy version to an environment. The version is
642
+ * resolved against handshake_policies by the policy's policy_key. Immediate
643
+ * rollouts supersede the prior active rollout for that (policy_key,
644
+ * environment); canary rollouts coexist (canaryPct in 1–99).
168
645
  */
169
- searchEntities(query: string, options?: {
170
- entityType?: 'agent' | 'merchant' | 'service_provider';
171
- minScore?: number;
172
- }): Promise<SearchResult>;
646
+ rolloutPolicy(policyId: string, version: number, environment: string, strategy?: 'immediate' | 'canary', canaryPct?: number): Promise<PolicyRolloutResult>;
173
647
  /**
174
- * Get the leaderboard.
175
- * No authentication required.
648
+ * List all versions of a policy. Versions are the handshake_policies rows
649
+ * sharing the policy's policy_key, returned newest-first inside an envelope.
176
650
  */
177
- getLeaderboard(options?: {
178
- limit?: number;
179
- entityType?: 'agent' | 'merchant' | 'service_provider';
180
- }): Promise<LeaderboardResult>;
651
+ getPolicyVersions(policyId: string): Promise<PolicyVersionsResult>;
181
652
  /**
182
- * Check if an entity meets a minimum trust threshold.
183
- * Returns true if the entity's score >= minScore.
653
+ * Diff two versions of a policy to see what changed between their rules.
654
+ * v1 and v2 are version numbers; the response includes both version rows and
655
+ * a semantic diff classified as loosening / tightening / neutral.
184
656
  */
185
- isTrusted(entityId: string, minScore?: number): Promise<boolean>;
657
+ diffPolicyVersions(policyId: string, v1: number, v2: number): Promise<PolicyDiff>;
658
+ /** @internal Build query string from SignoffFilters. */
659
+ private _buildQs;
660
+ /** @internal Build query string from DateRange. */
661
+ private _buildDateRangeQs;
662
+ /** @internal Convert key-value pairs to a query string. */
663
+ private _toQs;
664
+ }
665
+ export declare class EPClient {
666
+ private readonly baseUrl;
667
+ private readonly apiKey;
668
+ private readonly timeout;
669
+ private readonly retries;
670
+ /** Cloud-specific endpoints (dashboards, analytics, audit, policy management). */
671
+ readonly cloud: EPCloudClient;
672
+ constructor(options?: EPClientOptions);
673
+ private request;
674
+ /** List available trust policies. */
675
+ listPolicies(params?: {
676
+ scope?: string;
677
+ }): Promise<Policy[]>;
678
+ /** Initiate a trust handshake between parties. */
679
+ initiateHandshake(params: InitiateHandshakeParams): Promise<Handshake>;
680
+ /** Present credentials to a handshake. */
681
+ present(handshakeId: string, params: PresentParams): Promise<Presentation>;
682
+ /** Verify a handshake -- evaluate all presentations against policy. */
683
+ verify(handshakeId: string): Promise<VerificationResult>;
684
+ /** Pre-action trust gate. Returns allow/deny/review with commit ref. */
685
+ gate(params: GateParams): Promise<GateResult>;
686
+ /** Retrieve details of a specific handshake by ID. */
687
+ getHandshake(handshakeId: string): Promise<Handshake>;
688
+ /** Revoke an active handshake, invalidating all associated state. */
689
+ revokeHandshake(handshakeId: string): Promise<RevokeResult>;
690
+ /** Consume a handshake -- finalize and optionally bind a receipt. */
691
+ consume(handshakeId: string, params?: ConsumeParams): Promise<Consumption>;
692
+ /** Create a v1 pre-action trust receipt for a high-risk mutation. */
693
+ createTrustReceipt(params: CreateTrustReceiptParams): Promise<TrustReceipt>;
694
+ /** Read current receipt state from the append-only v1 audit timeline. */
695
+ getTrustReceipt(receiptId: string): Promise<TrustReceiptState>;
696
+ /** Request human signoff for a receipt that requires approval. */
697
+ requestSignoff(params: RequestSignoffParams): Promise<SignoffRequest>;
698
+ /** Consume a receipt before mutation. If this fails, do not execute the write. */
699
+ consumeTrustReceipt(receiptId: string, params: {
700
+ actionHash: string;
701
+ executingSystem: string;
702
+ executionReferenceId?: string;
703
+ }): Promise<ConsumeTrustReceiptResult>;
704
+ /** Emit the post-mutation execution attestation bound to the consumed receipt. */
705
+ attestExecution(receiptId: string, params: {
706
+ executedAction: Record<string, unknown>;
707
+ executingSystem: string;
708
+ executionId?: string;
709
+ executedAt?: string;
710
+ }): Promise<ExecutionAttestation>;
711
+ /** Fetch the signed evidence packet, when the receipt is in a signable state. */
712
+ getTrustReceiptEvidence(receiptId: string): Promise<TrustReceiptEvidence>;
186
713
  /**
187
- * Submit a receipt and verify the entity meets a threshold in one call.
188
- * Returns the receipt result and whether the entity is still trusted.
714
+ * Wrap a dangerous mutation in the v1 receipt lifecycle.
715
+ * The mutation runs only after create + consume succeed.
189
716
  */
190
- submitAndCheck(input: SubmitReceiptInput, minScore?: number): Promise<ReceiptResult & {
191
- still_trusted: boolean;
192
- }>;
717
+ requireReceipt<T>(params: RequireReceiptParams, mutate: (ctx: {
718
+ receipt: TrustReceipt;
719
+ consume: ConsumeTrustReceiptResult;
720
+ }) => Promise<T>): Promise<RequireReceiptResult<T>>;
721
+ /** Wrap an existing async function with requireReceipt(). */
722
+ withReceipt<TArgs extends unknown[], TResult>(params: RequireReceiptParams | ((...args: TArgs) => RequireReceiptParams), mutate: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<RequireReceiptResult<TResult>>;
723
+ /** Issue a signoff challenge for an entity. */
724
+ issueChallenge(params: IssueChallengeParams): Promise<SignoffChallenge>;
725
+ /** Attest to a signoff challenge with a cryptographic signature. */
726
+ attest(challengeId: string, params: AttestParams): Promise<SignoffAttestation>;
727
+ /** Deny a signoff challenge with an optional reason. */
728
+ denyChallenge(challengeId: string, reason?: string): Promise<DenyResult>;
729
+ /** Revoke a previously granted signoff. */
730
+ revokeSignoff(challengeId: string, options?: RevokeSignoffOptions): Promise<RevokeResult>;
731
+ /** Consume a signoff -- mark it as used for a specific action. */
732
+ consumeSignoff(signoffId: string, params: ConsumeSignoffParams): Promise<SignoffConsumption>;
733
+ /** Create a trust delegation from one entity to another. */
734
+ createDelegation(params: CreateDelegationParams): Promise<Delegation>;
735
+ /** Verify the validity of an existing delegation. */
736
+ verifyDelegation(delegationId: string): Promise<DelegationVerification>;
737
+ /** Issue a trust commit binding a handshake to a specific action. */
738
+ issueCommit(params: IssueCommitParams): Promise<Commit>;
739
+ /** Verify a previously issued commit. */
740
+ verifyCommit(commitId: string): Promise<CommitVerification>;
741
+ /** Record a behavioral or contextual observation for the Eye subsystem. */
742
+ recordObservation(params: RecordObservationParams): Promise<ObservationResponse>;
743
+ /** Check an action against recorded observations and return an advisory. */
744
+ checkAction(params: CheckActionParams): Promise<AdvisoryResponse>;
745
+ /** Retrieve an existing advisory by ID. */
746
+ getAdvisory(advisoryId: string): Promise<AdvisoryResponse>;
747
+ /** Create a suppression to exclude a reason code from future advisories. */
748
+ createSuppression(params: CreateSuppressionParams): Promise<SuppressionResponse>;
193
749
  }
194
- export default EmiliaClient;
750
+ //# sourceMappingURL=index.d.ts.map