@auctra/sdk 0.6.0 → 0.6.2

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.
@@ -1,689 +1,11 @@
1
- import { type KeyObject } from "node:crypto";
2
- export declare const AUCTRA_SDK_VERSION = "0.6.0";
3
- export type AgentEnvironment = "dev" | "staging" | "production";
4
- export type AuthorityLevel = "low" | "medium" | "high" | "critical";
5
- export type Decision = "allowed" | "blocked" | "require_approval";
6
- export type PolicyType = "spending" | "data_access" | "communication" | "approval";
7
- export type ActorType = "human" | "agent" | "service" | "tool";
8
- export type RiskLevel = "low" | "medium" | "high" | "critical";
9
- export type IntentStatus = "active" | "expired" | "completed" | "revoked" | "suspended";
10
- export type EvaluateActionInput = {
11
- agentId: string;
12
- actionType: string;
13
- payload?: Record<string, unknown>;
14
- claimedIntentId?: string;
15
- intentAnchorToken?: string;
16
- parentActionId?: string;
17
- actor?: {
18
- id?: string;
19
- type?: ActorType;
20
- name?: string;
21
- };
22
- action?: {
23
- target?: string;
24
- description?: string;
25
- riskLevel?: RiskLevel;
26
- metadata?: Record<string, unknown>;
27
- };
28
- };
29
- export type EvaluateActionResponse = {
30
- decision: Decision;
31
- risk_score: number;
32
- reason: string;
33
- delegation_id: string | null;
34
- authority_id: string | null;
35
- delegator: string | null;
36
- sponsor: string;
37
- matched_policies: string[];
38
- action_request_id: string;
39
- evidence: DecisionEvidence;
40
- evidence_payload: DecisionEvidencePayload;
41
- protocol?: {
42
- version: string;
43
- action?: Record<string, unknown>;
44
- decision?: Record<string, unknown>;
45
- };
46
- intelligence?: {
47
- authority_valid: boolean;
48
- root_intent_valid: boolean;
49
- intent_status: string;
50
- trust_summary?: string;
51
- };
52
- };
53
- export type RequestOptions = {
54
- idempotencyKey?: string;
55
- signal?: AbortSignal;
56
- };
57
- export type AuctraClientOptions = {
58
- apiKey: string;
59
- baseUrl?: string;
60
- timeoutMs?: number;
61
- maxRetries?: number;
62
- fetch?: typeof fetch;
63
- };
64
- export type Agent = {
65
- id: string;
66
- identity_id: string;
67
- name: string;
68
- description: string | null;
69
- model_provider: "openai" | "anthropic" | "gemini" | "local";
70
- model_name: string;
71
- environment: AgentEnvironment;
72
- authority_level: AuthorityLevel;
73
- status: "active" | "suspended" | "restricted" | "compromised";
74
- trust_rating: number;
75
- sponsor: {
76
- id: string;
77
- full_name: string;
78
- email: string;
79
- };
80
- created_at: string;
81
- };
82
- export type CreateAgentInput = {
83
- name: string;
84
- modelProvider: Agent["model_provider"];
85
- modelName: string;
86
- description?: string;
87
- environment?: AgentEnvironment;
88
- authorityLevel?: AuthorityLevel;
89
- sponsorUserId?: string;
90
- };
91
- export type Delegation = {
92
- id: string;
93
- agent: {
94
- id: string;
95
- name: string;
96
- };
97
- delegator: {
98
- id: string;
99
- full_name: string;
100
- email: string;
101
- };
102
- scope: {
103
- action_types: string[];
104
- };
105
- limits: {
106
- max_amount?: number;
107
- max_count?: number;
108
- currency?: string;
109
- environment?: AgentEnvironment;
110
- max_actions_per_window?: {
111
- count: number;
112
- window_seconds: number;
113
- action_type?: string;
114
- };
115
- max_amount_per_window?: {
116
- amount: number;
117
- window_seconds: number;
118
- };
119
- };
120
- valid_from: string;
121
- valid_until: string;
122
- status: "active" | "revoked" | "expired";
123
- is_active: boolean;
124
- mandate?: MandateEvidence | null;
125
- mandate_payload?: MandatePayload | null;
126
- evidence?: DecisionEvidence | null;
127
- evidence_payload?: DecisionEvidencePayload | null;
128
- created_at: string;
129
- };
130
- export type CreateDelegationInput = {
131
- agentId: string;
132
- actionTypes: string[];
133
- validUntil: string;
134
- maxAmount?: number;
135
- maxCount?: number;
136
- environment?: AgentEnvironment;
137
- currency?: string;
138
- delegatorUserId?: string;
139
- /** Parent authority/delegation id for subset-constrained delegation chains. */
140
- parentAuthorityId?: string;
141
- parentDelegationId?: string;
142
- maxDelegationDepth?: number;
143
- maxActionsPerWindow?: {
144
- count: number;
145
- windowSeconds: number;
146
- actionType?: string;
147
- };
148
- maxAmountPerWindow?: {
149
- amount: number;
150
- windowSeconds: number;
151
- };
152
- };
153
- export type AuthoritySummary = {
154
- id: string;
155
- protocol_version: string;
156
- status: string;
157
- payload_hash: string;
158
- signed: boolean;
159
- parent_authority_id: string | null;
160
- capabilities: unknown;
161
- };
162
- export type IssueAuthorityInput = {
163
- /** Subject agent id */
164
- subject: string;
165
- capabilities: string[];
166
- expiresAt: string;
167
- constraints?: {
168
- maxAmount?: number;
169
- currency?: string;
170
- maxCount?: number;
171
- environment?: AgentEnvironment;
172
- };
173
- delegation?: {
174
- allowed?: boolean;
175
- maxDepth?: number;
176
- };
177
- issuer?: string;
178
- delegatorUserId?: string;
179
- maxActionsPerWindow?: {
180
- count: number;
181
- windowSeconds: number;
182
- actionType?: string;
183
- };
184
- maxAmountPerWindow?: {
185
- amount: number;
186
- windowSeconds: number;
187
- };
188
- };
189
- export type DelegateAuthorityInput = IssueAuthorityInput & {
190
- /** Parent authority id — child must be a subset of parent */
191
- parent: string;
192
- };
193
- export type ActionRequest = {
194
- id: string;
195
- agent_name: string;
196
- action_type: string;
197
- action_summary: string;
198
- payload: Record<string, unknown>;
199
- decision: string;
200
- decision_reason: string | null;
201
- risk_score: number;
202
- delegation_id: string | null;
203
- policy_ids: string[];
204
- claimed_intent_id: string | null;
205
- parent_action_id: string | null;
206
- actor_id: string | null;
207
- actor_type: ActorType;
208
- action_target: string | null;
209
- action_description: string | null;
210
- action_risk_level: RiskLevel | null;
211
- action_metadata: Record<string, unknown>;
212
- pending_approval_id: string | null;
213
- created_at: string;
214
- decided_at: string | null;
215
- };
216
- export type Intent = {
217
- id: string;
218
- title: string;
219
- description: string | null;
220
- intent_type: string | null;
221
- status: IntentStatus;
222
- risk_level: RiskLevel;
223
- max_risk_level: RiskLevel;
224
- expires_at: string | null;
225
- created_at: string;
226
- owner: {
227
- id: string;
228
- full_name: string;
229
- email: string;
230
- } | null;
231
- linked_actions: number;
232
- };
233
- export type IntentDetail = Omit<Intent, "linked_actions"> & {
234
- linked_actions: Array<{
235
- action_request_id: string;
236
- action_type: string;
237
- summary: string;
238
- decision: string;
239
- alignment_status: string;
240
- alignment_score: number | null;
241
- }>;
242
- };
243
- export type CreateAuthorityEdgeInput = {
244
- fromActorId: string;
245
- fromActorType: ActorType;
246
- toActorId: string;
247
- toActorType: ActorType;
248
- authorityScope: string;
249
- conditions?: Record<string, unknown>;
250
- maxRiskLevel?: RiskLevel;
251
- expiresAt?: string;
252
- };
253
- export type CreateIntentInput = {
254
- title: string;
255
- description?: string;
256
- intentType?: string;
257
- riskLevel?: RiskLevel;
258
- maxRiskLevel?: RiskLevel;
259
- expiresAt?: string;
260
- allowedActionTypes?: string[];
261
- targetPattern?: string;
262
- resourceAllowlist?: string[];
263
- };
264
- export type UpdateIntentInput = {
265
- status?: Exclude<IntentStatus, "expired">;
266
- title?: string;
267
- description?: string | null;
268
- intentType?: string | null;
269
- riskLevel?: RiskLevel;
270
- maxRiskLevel?: RiskLevel;
271
- expiresAt?: string | null;
272
- };
273
- export type UpdateAgentStatusInput = {
274
- status: Agent["status"];
275
- reason?: string;
276
- /** Permanently revoke instead of quarantine (default: quarantine on restrict/suspend). */
277
- revokeDelegations?: boolean;
278
- /** Restore quarantined delegations when reactivating (default: true). */
279
- restoreDelegations?: boolean;
280
- };
281
- export type AuthorityGraph = {
282
- nodes: Array<{
283
- id: string;
284
- type: ActorType;
285
- label: string;
286
- }>;
287
- edges: Array<{
288
- id: string;
289
- from: string;
290
- to: string;
291
- fromType: ActorType;
292
- toType: ActorType;
293
- scope: string;
294
- status: string;
295
- edgeType: string;
296
- }>;
297
- };
298
- export type ActionEvaluation = {
299
- id: string;
300
- action_request_id: string;
301
- intent_id: string | null;
302
- decision: "allowed" | "requires_approval" | "blocked";
303
- risk_score: number;
304
- authority_valid: boolean;
305
- intent_valid: boolean;
306
- root_intent_valid: boolean;
307
- reasons: string[];
308
- created_at: string;
309
- };
310
- export type RootIntentChain = {
311
- valid: boolean;
312
- root_human_id: string | null;
313
- root_intent_id: string | null;
314
- reason: string | null;
315
- chain: Array<{
316
- actionId?: string;
317
- actorId: string;
318
- actorType: ActorType;
319
- intentId?: string;
320
- parentActionId?: string;
321
- label?: string;
322
- }>;
323
- };
324
- export type Policy = {
325
- id: string;
326
- name: string;
327
- description: string | null;
328
- policy_type: PolicyType;
329
- status: "active" | "draft" | "archived";
330
- priority: number;
331
- conditions: Record<string, unknown>;
332
- actions: Record<string, unknown>;
333
- created_at: string;
334
- };
335
- export type CreatePolicyInput = {
336
- name: string;
337
- description?: string;
338
- policyType: PolicyType;
339
- status?: "active" | "draft";
340
- priority?: number;
341
- actionType?: string;
342
- amountGreaterThan?: number;
343
- resourceSensitivity?: "public" | "internal" | "confidential" | "pii";
344
- externalRecipient?: boolean;
345
- environment?: AgentEnvironment;
346
- decision: "block" | "require_approval";
347
- approverRole?: "owner" | "admin" | "reviewer";
348
- maxActionsPerWindow?: {
349
- count: number;
350
- windowSeconds: number;
351
- actionType?: string;
352
- };
353
- maxAmountPerWindow?: {
354
- amount: number;
355
- windowSeconds: number;
356
- };
357
- };
358
- export type CustomActionType = {
359
- id: string;
360
- label: string;
361
- description: string | null;
362
- category: string;
363
- policy_type: PolicyType;
364
- payload_schema: Record<string, unknown>;
365
- source: "builtin" | "custom";
366
- template?: boolean;
367
- created_at?: string | null;
368
- };
369
- export type CreateCustomActionTypeInput = {
370
- id: string;
371
- label: string;
372
- description?: string;
373
- category?: string;
374
- policyType: PolicyType;
375
- payloadSchema?: Record<string, unknown>;
376
- };
377
- export type PolicySimulation = {
378
- policy_id: string;
379
- policy_name: string;
380
- policy_status: string;
381
- sample_size: number;
382
- changed_count: number;
383
- unchanged_count: number;
384
- would_block_count: number;
385
- replay_source?: "audit_events" | "action_requests" | "mixed";
386
- deltas: Array<{
387
- action_request_id: string;
388
- action_type: string;
389
- current_decision: string;
390
- simulated_decision: string;
391
- changed: boolean;
392
- }>;
393
- };
394
- export type MandateEvidence = {
395
- format: "auctra-mandate.v0.1";
396
- payload_hash: string;
397
- signed: false;
398
- } | {
399
- format: "auctra-mandate.v0.1";
400
- signed: true;
401
- payload_hash: string;
402
- payload: Record<string, unknown>;
403
- signature: {
404
- alg: "Ed25519";
405
- key_id: string;
406
- value: string;
407
- };
408
- };
409
- export type MandatePayload = Record<string, unknown>;
410
- export type DecisionEvidencePayload = Record<string, unknown>;
411
- export type DecisionEvidence = {
412
- format: "auctra-evidence.v0.1";
413
- payload_hash: string;
414
- signed: false;
415
- } | {
416
- format: "auctra-evidence.v0.1";
417
- signed: true;
418
- payload_hash: string;
419
- payload: Record<string, unknown>;
420
- signature: {
421
- alg: "Ed25519";
422
- key_id: string;
423
- value: string;
424
- };
425
- };
426
- export type AuditChainVerification = {
427
- valid: boolean;
428
- total: number;
429
- sealed_total: number;
430
- legacy_unsealed_total: number;
431
- events: Array<{
432
- id: string;
433
- hashValid: boolean;
434
- linkValid: boolean;
435
- sequenceValid: boolean;
436
- valid: boolean;
437
- legacy: boolean;
438
- }>;
439
- };
440
- export type ArtifactVerification = {
441
- valid: boolean;
442
- hashValid: boolean;
443
- signatureValid: boolean;
444
- };
445
- export type AuditEvent = {
446
- id: string;
447
- event_type: string;
448
- event_summary: string;
449
- decision: string | null;
450
- decision_reason: string | null;
451
- authority_valid_at_action: boolean | null;
452
- actor_name: string;
453
- approver_name: string | null;
454
- policy_applied: string | null;
455
- delegation_id: string | null;
456
- hash: string | null;
457
- previous_hash: string | null;
458
- chain_index?: number;
459
- mandate?: MandateEvidence | null;
460
- evidence?: DecisionEvidence | null;
461
- payload?: Record<string, unknown>;
462
- created_at: string;
463
- };
464
- export type ApiKeySummary = {
465
- id: string;
466
- name: string;
467
- key_prefix: string;
468
- environment: "development" | "production";
469
- permissions: string[];
470
- status: "active" | "revoked";
471
- last_used_at: string | null;
472
- created_at: string;
473
- };
474
- export declare class AuctraApiError extends Error {
475
- readonly status: number;
476
- readonly code?: string;
477
- readonly details?: unknown;
478
- readonly requestId?: string;
479
- constructor(message: string, options: {
480
- status: number;
481
- code?: string;
482
- details?: unknown;
483
- requestId?: string;
484
- });
485
- }
486
- export declare function verifyMandateArtifact(input: {
487
- payload: MandatePayload;
488
- evidence: MandateEvidence;
489
- publicKeyPem?: string | KeyObject;
490
- }): ArtifactVerification;
491
- export declare function verifyDecisionArtifact(input: {
492
- payload: DecisionEvidencePayload;
493
- evidence: DecisionEvidence;
494
- publicKeyPem?: string | KeyObject;
495
- }): ArtifactVerification;
496
- export declare class Auctra {
497
- private readonly apiKey;
498
- private readonly baseUrl;
499
- private readonly timeoutMs;
500
- private readonly maxRetries;
501
- private readonly fetchImpl;
502
- constructor(options: AuctraClientOptions);
503
- private request;
504
- private executeOrEvaluateAction;
505
- private issueAuthorityRequest;
506
- /**
507
- * Authority Protocol — issue, verify, delegate (subset), revoke.
508
- * There is no legacy createDelegation() surface.
509
- */
510
- get authority(): {
511
- issue: (input: IssueAuthorityInput) => Promise<{
512
- authority: AuthoritySummary;
513
- authority_id: string;
514
- delegation: Delegation;
515
- }>;
516
- verify: (payload: Record<string, unknown>, artifact: Record<string, unknown>) => Promise<{
517
- valid: boolean;
518
- hashValid: boolean;
519
- signatureValid: boolean;
520
- expired: boolean;
521
- status: string;
522
- issuer: string;
523
- subject: string;
524
- capabilities: string[];
525
- constraints: Record<string, unknown>;
526
- expiresAt: string;
527
- protocolVersion: string;
528
- }>;
529
- delegate: (input: DelegateAuthorityInput) => Promise<{
530
- authority: AuthoritySummary;
531
- authority_id: string;
532
- delegation: Delegation;
533
- }>;
534
- revoke: (authorityId: string) => Promise<{
535
- ok: true;
536
- }>;
537
- };
538
- /**
539
- * Action Protocol — evaluate (dry-run) vs execute (enforce + evidence).
540
- * There is no legacy evaluateAction() surface.
541
- */
542
- get action(): {
543
- evaluate: (input: EvaluateActionInput, options?: RequestOptions) => Promise<EvaluateActionResponse>;
544
- execute: (input: EvaluateActionInput, options?: RequestOptions) => Promise<EvaluateActionResponse>;
545
- };
546
- get evidence(): {
547
- verify: (payload: DecisionEvidencePayload, evidence: DecisionEvidence) => Promise<ArtifactVerification>;
548
- };
549
- verifyMandate(payload: MandatePayload, evidence: MandateEvidence): Promise<ArtifactVerification>;
550
- listIntents(): Promise<{
551
- intents: Intent[];
552
- }>;
553
- createIntent(input: CreateIntentInput): Promise<{
554
- intent: {
555
- id: string;
556
- title: string;
557
- status: string;
558
- };
559
- }>;
560
- getIntent(intentId: string): Promise<{
561
- intent: IntentDetail;
562
- }>;
563
- updateIntentStatus(intentId: string, status: Exclude<IntentStatus, "expired">): Promise<{
564
- intent: {
565
- id: string;
566
- title: string;
567
- status: IntentStatus;
568
- };
569
- }>;
570
- updateIntent(intentId: string, input: UpdateIntentInput): Promise<{
571
- intent: {
572
- id: string;
573
- title: string;
574
- status: IntentStatus;
575
- description?: string | null;
576
- intent_type?: string | null;
577
- risk_level?: RiskLevel;
578
- max_risk_level?: RiskLevel;
579
- expires_at?: string | null;
580
- };
581
- }>;
582
- getAuthorityGraph(): Promise<{
583
- authority_graph: AuthorityGraph;
584
- }>;
585
- createAuthorityEdge(input: CreateAuthorityEdgeInput): Promise<{
586
- edge: {
587
- id: string;
588
- };
589
- }>;
590
- getActionEvaluation(actionRequestId: string): Promise<{
591
- evaluation: ActionEvaluation;
592
- }>;
593
- getRootIntentChain(actionRequestId: string): Promise<{
594
- root_intent_chain: RootIntentChain;
595
- }>;
596
- listAgents(): Promise<{
597
- agents: Agent[];
598
- }>;
599
- getAgent(agentId: string): Promise<{
600
- agent: Agent;
601
- }>;
602
- createAgent(input: CreateAgentInput): Promise<{
603
- agent: Agent;
604
- }>;
605
- updateAgentStatus(agentId: string, input: UpdateAgentStatusInput): Promise<{
606
- agent: {
607
- id: string;
608
- name: string;
609
- status: Agent["status"];
610
- };
611
- }>;
612
- deleteAgent(agentId: string): Promise<{
613
- ok: true;
614
- }>;
615
- listAuthorities(): Promise<{
616
- delegations: Delegation[];
617
- authorities?: AuthoritySummary[];
618
- }>;
619
- getAuthority(authorityId: string): Promise<{
620
- delegation: Delegation;
621
- }>;
622
- listActionRequests(): Promise<{
623
- action_requests: ActionRequest[];
624
- }>;
625
- approveActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
626
- ok: true;
627
- decision: "approved" | "rejected" | "escalated";
628
- action_decision: "allowed" | "blocked" | "require_approval";
629
- reason: string;
630
- }>;
631
- rejectActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
632
- ok: true;
633
- decision: "approved" | "rejected" | "escalated";
634
- action_decision: "allowed" | "blocked" | "require_approval";
635
- reason: string;
636
- }>;
637
- escalateActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
638
- ok: true;
639
- decision: "approved" | "rejected" | "escalated";
640
- action_decision: "allowed" | "blocked" | "require_approval";
641
- reason: string;
642
- }>;
643
- private resolveActionRequest;
644
- listPolicies(): Promise<{
645
- policies: Policy[];
646
- }>;
647
- createPolicy(input: CreatePolicyInput): Promise<{
648
- policy: Pick<Policy, "id" | "name" | "status" | "created_at">;
649
- }>;
650
- simulatePolicy(policyId: string, input?: {
651
- limit?: number;
652
- since?: string;
653
- }): Promise<{
654
- simulation: PolicySimulation;
655
- meta: {
656
- simulated_at: string;
657
- sample_size: number;
658
- changed_count: number;
659
- unchanged_count: number;
660
- };
661
- }>;
662
- publishPolicy(policyId: string, input?: {
663
- force?: boolean;
664
- }): Promise<{
665
- ok: true;
666
- policyId: string;
667
- simulation: Record<string, unknown>;
668
- }>;
669
- listActionTypes(): Promise<{
670
- action_types: CustomActionType[];
671
- }>;
672
- listCustomActionTypes(): Promise<{
673
- action_types: CustomActionType[];
674
- }>;
675
- createCustomActionType(input: CreateCustomActionTypeInput): Promise<{
676
- action_type: Pick<CustomActionType, "id" | "label" | "policy_type" | "source" | "created_at">;
677
- }>;
678
- listAuditEvents(): Promise<{
679
- audit_events: AuditEvent[];
680
- }>;
681
- getAuditEvent(auditEventId: string): Promise<{
682
- audit_event: AuditEvent;
683
- }>;
684
- verifyAuditChain(): Promise<AuditChainVerification>;
685
- listApiKeys(): Promise<{
686
- api_keys: ApiKeySummary[];
687
- }>;
688
- }
1
+ /**
2
+ * @auctra/sdk Stage 1.0 public surface.
3
+ *
4
+ * Modular layout under src/{types,artifacts,client,authority,action,evidence}.ts.
5
+ * Canonical API: authority.* / action.* / evidence.* — no createDelegation / evaluateAction.
6
+ */
7
+ export { AUCTRA_SDK_VERSION, DEFAULT_BASE_URL } from "./types.js";
8
+ export type * from "./types.js";
9
+ export { AuctraApiError, verifyMandateArtifact, verifyDecisionArtifact } from "./artifacts.js";
10
+ export { Auctra } from "./client.js";
689
11
  //# sourceMappingURL=index.d.ts.map