@atlasent/sdk 2.10.0 → 2.13.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,179 +1,7 @@
1
- import { D as DecisionCanonical, R as RateLimitState, c as AtlaSentClientOptions, E as EvaluateRequest, d as EvaluateResponse, B as BatchEvalItem, e as BatchEvalResponse, S as SubscribeDecisionsOptions, f as DecisionStreamEvent, g as EvaluatePreflightResponse, V as VerifyPermitRequest, h as VerifyPermitResponse, i as DeployGateRequest, j as DeployGateResponse, k as RevokePermitRequest, l as RevokePermitResponse, m as RevokePermitByIdInput, n as RevokePermitByIdResponse, o as VerifyPermitByIdResponse, G as GetPermitResponse, p as PermitValidResponse, L as ListPermitsRequest, q as ListPermitsResponse, r as ApiKeySelfResponse, s as AuditEventsQuery, t as AuditEventsResult, u as AuditExportRequest, v as AuditExportResult, w as StreamOptions, x as StreamEvent, b as ProtectRequest, P as Permit, a as AtlaSentError, A as AtlaSentDeniedError, y as DecisionReceipt, z as DecisionReceiptAlgorithm, C as protect, F as deployGate, H as configure } from './protect-C0t0fP1y.js';
2
- export { I as AtlaSentDecision, J as AtlaSentDeniedErrorInit, K as AtlaSentErrorCode, M as AtlaSentErrorInit, N as AtlaSentEscalateError, O as AtlaSentEscalateErrorInit, Q as AuditDecision, T as AuditEvent, U as AuditEventsPage, W as AuditExport, X as AuditExportSignatureStatus, Y as BvsSnapshot, Z as ConfigureOptions, _ as ConsentClassProjection, $ as ConstraintTrace, a0 as ConstraintTracePolicy, a1 as ConstraintTraceStage, a2 as DEFAULT_RETRY_POLICY, a3 as DEPLOYMENT_PRODUCTION_ACTION, a4 as DEPLOY_GATE_CODES, a5 as Decision, a6 as DeployGateContext, a7 as DeployGateDenyCode, a8 as DeployGateEvidence, a9 as DeployOverrideClaim, aa as DeployPermitClaim, ab as EvaluateBatchResultItem, ac as EvaluateResponsePermit, ad as EvaluateRiskEnvelope, ae as EvaluateRiskEnvelopeFactor, af as PRODUCTION_DEPLOY_ACTION, ag as PermitOutcome, ah as PermitRecord, ai as PermitRevoked, aj as PermitStatus, ak as PermitWithEvidence, al as ProtectWithEvidenceOptions, am as RetryPolicy, an as StreamDecisionEvent, ao as StreamParseError, ap as StreamProgressEvent, aq as StreamTimeoutError, ar as computeBackoffMs, as as hasAttemptsLeft, at as isRetryable, au as mergePolicy, av as normalizePermitOutcome, aw as protectWithEvidence } from './protect-C0t0fP1y.js';
1
+ import { D as DecisionCanonical, R as RateLimitState, c as AtlaSentClientOptions, E as EvaluateRequest, d as EvaluateResponse, B as BatchEvalItem, e as BatchEvalResponse, S as SubscribeDecisionsOptions, f as DecisionStreamEvent, g as EvaluatePreflightResponse, V as VerifyPermitRequest, h as VerifyPermitResponse, i as DeployGateRequest, j as DeployGateResponse, k as RevokePermitRequest, l as RevokePermitResponse, m as RevokePermitByIdInput, n as RevokePermitByIdResponse, o as VerifyPermitByIdResponse, G as GetPermitResponse, p as PermitValidResponse, L as ListPermitsRequest, q as ListPermitsResponse, r as ApiKeySelfResponse, s as AuditEventsQuery, t as AuditEventsResult, u as AuditExportRequest, v as AuditExportResult, w as StreamOptions, x as StreamEvent, y as LicenseStatus, z as LicenseVerifyResult, b as ProtectRequest, P as Permit, O as OverrideV1, A as AtlaSentDeniedError, a as AtlaSentError, C as DecisionReceipt, F as ComplianceEvidenceRun, H as DecisionReceiptAlgorithm, I as protect, J as deployGate, K as configure } from './protect-Bk9q12ia.js';
2
+ export { M as ActionEvidenceBundle, N as AtlaSentDecision, Q as AtlaSentDeniedErrorInit, T as AtlaSentErrorCode, U as AtlaSentErrorInit, W as AtlaSentEscalateError, X as AtlaSentEscalateErrorInit, Y as AuditDecision, Z as AuditEvent, _ as AuditEventsPage, $ as AuditExport, a0 as AuditExportSignatureStatus, a1 as BundleVerificationError, a2 as BvsSnapshot, a3 as CompletionProof, a4 as ComplianceControlCoverage, a5 as ComplianceEvidenceSummary, a6 as ComplianceFramework, a7 as ComplianceRunStatus, a8 as ConfigureOptions, a9 as ConsentClassProjection, aa as ConstraintTrace, ab as ConstraintTracePolicy, ac as ConstraintTraceStage, ad as CreateOverrideRequest, ae as DEFAULT_RETRY_POLICY, af as DEPLOYMENT_PRODUCTION_ACTION, ag as DEPLOY_GATE_CODES, ah as Decision, ai as DecisionReceiptPayload, aj as DeployGateContext, ak as DeployGateDenyCode, al as DeployGateEvidence, am as DeployOverrideClaim, an as DeployPermitClaim, ao as EvaluateBatchResultItem, ap as EvaluateResponsePermit, aq as EvaluateRiskEnvelope, ar as EvaluateRiskEnvelopeFactor, as as EvidenceControl, at as EvidenceControlStatus, au as ListEvidenceRunsResponse, av as OverrideEvent, aw as OverrideEventType, ax as OverrideEventsResponse, ay as OverrideListResponse, az as OverrideStatus, aA as PRODUCTION_DEPLOY_ACTION, aB as PermitOutcome, aC as PermitRecord, aD as PermitRevoked, aE as PermitStatus, aF as PermitWithEvidence, aG as ProtectWithEvidenceOptions, aH as RetryPolicy, aI as SOC2ControlId, aJ as StreamDecisionEvent, aK as StreamParseError, aL as StreamProgressEvent, aM as StreamTimeoutError, aN as TriggerEvidenceRunRequest, aO as TriggerEvidenceRunResponse, aP as WhyPolicyEvaluation, aQ as WhyStage, aR as WhyTrace, aS as buildDecisionReceiptPayload, aT as buildWhyTrace, aU as computeBackoffMs, aV as computeBundleHash, aW as computeContextHash, aX as evidenceRunPasses, aY as hasAttemptsLeft, aZ as isRetryable, a_ as mergePolicy, a$ as nonPassingControls, b0 as normalizePermitOutcome, b1 as protectWithEvidence, b2 as signDecisionReceiptHmac, b3 as soc2ControlCoverageForDecision, b4 as verifyDecisionReceiptHmac } from './protect-Bk9q12ia.js';
3
3
  import { webcrypto } from 'node:crypto';
4
4
 
5
- /**
6
- * Override types — wire shapes for `/v1/overrides`.
7
- *
8
- * Overrides allow an authorized actor to bypass a deny decision for a
9
- * specific evaluation. They must be approved before they take effect
10
- * and can be revoked at any time.
11
- *
12
- * Mirrors `api/src/schemas/overrides.ts` in atlasent-control-plane.
13
- */
14
- /**
15
- * Lifecycle status of an override request.
16
- *
17
- * - `pending` — created, waiting for approval
18
- * - `approved` — approved and active; the evaluation's deny is lifted
19
- * - `revoked` — manually revoked
20
- * - `expired` — TTL elapsed before revocation
21
- */
22
- type OverrideStatus = "pending" | "approved" | "revoked" | "expired";
23
- /**
24
- * The event types that can appear on an override's event log.
25
- */
26
- type OverrideEventType = "created" | "approved" | "revoked";
27
- /**
28
- * Canonical Override domain object returned by the API.
29
- *
30
- * All timestamps are ISO-8601 UTC strings. Nullable fields are `null`
31
- * rather than omitted so wire shapes are stable.
32
- */
33
- interface OverrideV1 {
34
- id: string;
35
- orgId: string;
36
- /** The evaluation ID this override applies to. */
37
- evaluationId: string;
38
- /** Human-readable justification provided at creation time. */
39
- reason: string;
40
- status: OverrideStatus;
41
- /** Actor who requested the override. */
42
- requestedBy: string;
43
- /** Actor who approved the override, or `null` if not yet approved. */
44
- approvedBy: string | null;
45
- /** Actor who revoked the override, or `null` if not revoked. */
46
- revokedBy: string | null;
47
- /** ISO-8601 creation timestamp. */
48
- createdAt: string;
49
- /** ISO-8601 approval timestamp, or `null`. */
50
- approvedAt: string | null;
51
- /** ISO-8601 revocation timestamp, or `null`. */
52
- revokedAt: string | null;
53
- /** ISO-8601 expiry timestamp, or `null` if no TTL was set. */
54
- expiresAt: string | null;
55
- /** Arbitrary key/value metadata attached at creation. `null` when none. */
56
- metadata: Record<string, unknown> | null;
57
- }
58
- /**
59
- * Paginated list of overrides.
60
- */
61
- interface OverrideListResponse {
62
- items: OverrideV1[];
63
- /** Opaque cursor for the next page. `null` when there are no more results. */
64
- nextCursor: string | null;
65
- }
66
- /**
67
- * Input for `POST /v1/overrides` — request a new override.
68
- */
69
- interface CreateOverrideRequest {
70
- /** Human-readable justification. Required; max 2000 characters. */
71
- reason: string;
72
- /** The evaluation ID to override. */
73
- evaluationId: string;
74
- /** Lifetime in seconds. Defaults to 3600. Max 604800 (7 days). */
75
- ttlSeconds?: number;
76
- /** Arbitrary metadata to attach to the override record. */
77
- metadata?: Record<string, unknown>;
78
- }
79
- /**
80
- * Audit event appended to an override's event log on every state mutation.
81
- */
82
- interface OverrideEvent {
83
- id: string;
84
- overrideId: string;
85
- orgId: string;
86
- /** Actor who caused this event. */
87
- actorId: string;
88
- type: OverrideEventType;
89
- /** ISO-8601 timestamp. */
90
- at: string;
91
- /** Event-specific payload. `null` when none. */
92
- payload: Record<string, unknown> | null;
93
- }
94
- /**
95
- * Response for `GET /v1/overrides/:id/events`.
96
- */
97
- interface OverrideEventsResponse {
98
- items: OverrideEvent[];
99
- }
100
-
101
- /**
102
- * Compliance evidence types — wire shapes for `v1-compliance-evidence`.
103
- *
104
- * Supports on-demand SOC 2 Type II control evidence collection. The
105
- * same run shape is used for ISO 27001, GDPR, and HIPAA; control IDs
106
- * differ per framework.
107
- */
108
- type ComplianceFramework = "soc2" | "iso27001" | "gdpr" | "hipaa";
109
- type EvidenceControlStatus = "pass" | "gap" | "finding";
110
- type ComplianceRunStatus = "pending" | "running" | "completed" | "failed";
111
- /**
112
- * A single evaluated control within an evidence run.
113
- * `evidence` is a free-form object whose keys are framework-specific
114
- * metric names (e.g. `mfa_enforced_policies`, `audit_events_last_30d`).
115
- */
116
- interface EvidenceControl {
117
- control_id: string;
118
- title: string;
119
- status: EvidenceControlStatus;
120
- evidence: Record<string, unknown>;
121
- }
122
- interface ComplianceEvidenceSummary {
123
- total: number;
124
- pass: number;
125
- gap: number;
126
- finding: number;
127
- }
128
- interface ComplianceEvidenceRun {
129
- id: string;
130
- org_id: string;
131
- framework: ComplianceFramework;
132
- period_start: string;
133
- period_end: string;
134
- status: ComplianceRunStatus;
135
- controls: EvidenceControl[];
136
- summary: ComplianceEvidenceSummary | null;
137
- applied_by: string | null;
138
- created_at: string;
139
- }
140
- interface TriggerEvidenceRunRequest {
141
- framework: ComplianceFramework;
142
- /** ISO 8601 date string; defaults to 30 days ago on the server. */
143
- period_start?: string;
144
- /** ISO 8601 date string; defaults to now on the server. */
145
- period_end?: string;
146
- }
147
- interface TriggerEvidenceRunResponse {
148
- run: ComplianceEvidenceRun;
149
- }
150
- interface ListEvidenceRunsResponse {
151
- runs: ComplianceEvidenceRun[];
152
- }
153
- /**
154
- * SOC 2 control IDs evaluated by `v1-compliance-evidence`.
155
- *
156
- * | ID | Area |
157
- * |--------|------|
158
- * | CC6.1 | MFA enforcement |
159
- * | CC6.3 | Periodic access reviews |
160
- * | CC7.2 | Audit trail completeness |
161
- * | CC8.1 | Change management / HITL |
162
- * | CC3.2 | Policy violations |
163
- */
164
- type SOC2ControlId = "CC6.1" | "CC6.3" | "CC7.2" | "CC8.1" | "CC3.2";
165
- /**
166
- * Returns `true` when every control in the run has `pass` or `gap`
167
- * status (no `finding`). A `gap` means a control is partially met;
168
- * a `finding` is a blocking deficiency that requires remediation.
169
- */
170
- declare function evidenceRunPasses(run: ComplianceEvidenceRun): boolean;
171
- /**
172
- * Returns controls that do not have `pass` status, sorted so
173
- * `finding` controls appear before `gap` controls.
174
- */
175
- declare function nonPassingControls(run: ComplianceEvidenceRun): EvidenceControl[];
176
-
177
5
  /**
178
6
  * Wire types for `POST /v1-decisions-replay/:id/replay`.
179
7
  *
@@ -278,6 +106,154 @@ interface ReplayResponse {
278
106
  /** Rate-limit state from response headers. */
279
107
  rateLimit: RateLimitState | null;
280
108
  }
109
+ /**
110
+ * Result of offline evidence bundle verification via {@link verifyEvidenceBundle}.
111
+ *
112
+ * Named distinctly from {@link BundleVerificationResult} in `auditBundle.ts`
113
+ * which carries chain-integrity and signature fields for audit export bundles.
114
+ * This result covers the lighter-weight structural + hash-integrity check used
115
+ * by the Phase 3 replay client.
116
+ */
117
+ interface EvidenceBundleVerifyResult {
118
+ /** `true` when all checks passed. */
119
+ valid: boolean;
120
+ /** The `bundle_id` from the top-level bundle object, if present. */
121
+ bundleId: string | undefined;
122
+ /** The first `permit_id` found in the permits array (convenience). */
123
+ permitId: string | undefined;
124
+ /** Human-readable failure description; `undefined` when `valid` is `true`. */
125
+ reason: string | undefined;
126
+ }
127
+ /**
128
+ * Offline shape of an evidence bundle as returned by
129
+ * `GET /v1/evidence-bundles/:id` and downloaded for replay verification.
130
+ */
131
+ interface OfflineEvidenceBundleData {
132
+ bundle_id?: string;
133
+ org_id?: string;
134
+ status?: string;
135
+ permits?: Array<{
136
+ permit_id?: string;
137
+ evaluation_id?: string;
138
+ }>;
139
+ hash_chain?: {
140
+ root_hash?: string;
141
+ entry_count?: number;
142
+ };
143
+ [key: string]: unknown;
144
+ }
145
+ /**
146
+ * Verify an evidence bundle offline without a backend round-trip.
147
+ *
148
+ * Checks:
149
+ * 1. Bundle has required fields (`bundle_id`, `org_id`, `status`).
150
+ * 2. `status` is `"ready"`.
151
+ * 3. Root hash integrity if `hash_chain` is present (SHA-256 via Node crypto).
152
+ *
153
+ * Does **not** require `AtlaSentClient` or network access.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * import { verifyEvidenceBundle } from "@atlasent/sdk";
158
+ *
159
+ * const result = verifyEvidenceBundle(bundleJson);
160
+ * if (result.valid) {
161
+ * console.log("verified, first permit:", result.permitId);
162
+ * } else {
163
+ * console.error("verification failed:", result.reason);
164
+ * }
165
+ * ```
166
+ */
167
+ declare function verifyEvidenceBundle(bundle: OfflineEvidenceBundleData): EvidenceBundleVerifyResult;
168
+ /**
169
+ * Compute a deterministic SHA-256 root hash over the permits list.
170
+ * Uses `JSON.stringify` with sorted keys via a replacer for canonical form.
171
+ *
172
+ * @internal
173
+ */
174
+ declare function _computeEvidenceRootHash(permits: OfflineEvidenceBundleData["permits"]): string;
175
+
176
+ /**
177
+ * Hybrid trust-root bootstrap and snapshot management.
178
+ *
179
+ * At module load, seeds from the vendor snapshot in vendor/trust-root/.
180
+ * Optionally refreshes from https://keys.atlasent.io/.well-known/ on
181
+ * a configurable interval (default 4h, floor 5 min per ADR-005 D2).
182
+ * Refresh failure is silent — falls back to the in-memory snapshot.
183
+ *
184
+ * Snapshot expiry (valid_until) is fail-closed per ADR-005 D3:
185
+ * checkExpiry() emits a one-time console.warn at half-life, and again
186
+ * on expiry. verifyAuditBundle throws BundleVerificationError when
187
+ * expired (unless allowExpiredSnapshot=true is passed).
188
+ */
189
+ interface TrustRootKey {
190
+ kid: string;
191
+ role: "R1_release" | "R2_permit" | "R3_audit" | "R4_pack";
192
+ kty: string;
193
+ crv?: string;
194
+ alg: string;
195
+ x?: string;
196
+ valid_from?: string | null;
197
+ valid_until?: string | null;
198
+ replaced_by?: string | null;
199
+ revoked?: boolean;
200
+ tenant?: string | null;
201
+ }
202
+ interface TrustRootRevocationEntry {
203
+ kid: string;
204
+ role?: string;
205
+ revoked_at: string;
206
+ reason?: string;
207
+ }
208
+ interface TrustRootSnapshot {
209
+ /** ISO-8601 expiry of this snapshot; fail-closed when exceeded */
210
+ valid_until: string;
211
+ issued_at: string;
212
+ keys: TrustRootKey[];
213
+ revoked_keys: TrustRootRevocationEntry[];
214
+ revoked_identities: Array<{
215
+ identity: string;
216
+ revoked_at: string;
217
+ reason?: string;
218
+ }>;
219
+ }
220
+ interface TrustRootManagerOptions {
221
+ /** Override the refresh URL (default: https://keys.atlasent.io/.well-known/) */
222
+ refreshBaseUrl?: string;
223
+ /** Refresh interval in ms. Default: 4h. Floor: 5 min. */
224
+ refreshIntervalMs?: number;
225
+ /** Disable automatic background refresh. */
226
+ disableRefresh?: boolean;
227
+ /** Custom fetch implementation (for tests). */
228
+ fetch?: typeof fetch;
229
+ }
230
+ declare class TrustRootManager {
231
+ private _snapshot;
232
+ private _refreshTimer;
233
+ private readonly _opts;
234
+ constructor(initialSnapshot: TrustRootSnapshot, opts?: TrustRootManagerOptions);
235
+ getSnapshot(): TrustRootSnapshot;
236
+ /**
237
+ * Check whether the snapshot is expired, emit one-time warnings at
238
+ * half-life and expiry. Returns "ok" | "half_life" | "expired".
239
+ *
240
+ * Emits console.warn once per process at half-life (ADR-005 D3).
241
+ * Emits console.warn once per process on expiry.
242
+ */
243
+ checkExpiry(): "ok" | "half_life" | "expired";
244
+ /** Look up a key entry by kid. Returns undefined if not found. */
245
+ lookupKey(kid: string): TrustRootKey | undefined;
246
+ /** Returns true if the kid appears in revoked_keys. */
247
+ isRevoked(kid: string): boolean;
248
+ /** Replace the snapshot (e.g. after a successful refresh). */
249
+ replaceSnapshot(next: TrustRootSnapshot): void;
250
+ stopRefresh(): void;
251
+ private _scheduleRefresh;
252
+ private _doRefresh;
253
+ }
254
+ declare function getGlobalTrustRootManager(opts?: TrustRootManagerOptions): TrustRootManager;
255
+ /** Replace the global manager (primarily for tests). */
256
+ declare function __setGlobalTrustRootManagerForTests(mgr: TrustRootManager | null): void;
281
257
 
282
258
  /**
283
259
  * Dual-shape input bridge for the v2.0.0 wire format change.
@@ -310,6 +286,31 @@ interface V2EvaluateRequest {
310
286
  context?: Record<string, unknown>;
311
287
  /** Populate `risk_envelope.factors` in the response (Phase C). */
312
288
  explain?: boolean;
289
+ /** Deployment environment where the action executes (e.g. `"production"`). */
290
+ environment?: string;
291
+ /** Structured resource descriptor. Prefer over `resource_id` for new callers. */
292
+ resource?: {
293
+ type: string;
294
+ id?: string;
295
+ attributes?: Record<string, unknown>;
296
+ };
297
+ /** Snapshot of the resource before the proposed action. Enables state-transition-aware policy evaluation. */
298
+ current_state?: {
299
+ description: string;
300
+ attributes?: Record<string, unknown>;
301
+ };
302
+ /** Desired resource state after the action. */
303
+ proposed_state?: {
304
+ description: string;
305
+ attributes?: Record<string, unknown>;
306
+ };
307
+ /** Execution surface binding (CI/CD adapter, DB driver, etc.). */
308
+ execution_binding?: {
309
+ kind: string;
310
+ adapter_version?: string;
311
+ resource_id?: string;
312
+ enforcement_point?: string;
313
+ };
313
314
  }
314
315
  /**
315
316
  * Normalise an evaluate request from either the legacy v1.x shape
@@ -1544,96 +1545,801 @@ declare function isImpersonationGrantUsable(grant: CrossOrgImpersonationGrant, n
1544
1545
  declare function clampTokenDuration(grant: CrossOrgImpersonationGrant, requestedSeconds: number): number;
1545
1546
 
1546
1547
  /**
1547
- * AtlaSent HTTP client.
1548
+ * SCIM 2.0 provisioning client — user and group lifecycle management.
1548
1549
  *
1549
- * Two public methods, both backed by native `fetch`:
1550
- * - {@link AtlaSentClient.evaluate} → POST {baseUrl}/v1-evaluate
1551
- * - {@link AtlaSentClient.verifyPermit} → POST {baseUrl}/v1-verify-permit
1550
+ * Wire surface: /scim/v2/* endpoints in atlasent-api (RFC 7643/7644).
1552
1551
  *
1553
- * Fail-closed: a clean policy DENY is returned (not thrown), but
1554
- * network, timeout, bad response, 4xx/5xx, and rate-limit conditions
1555
- * all throw {@link AtlaSentError}.
1552
+ * Usage:
1553
+ *
1554
+ * ```ts
1555
+ * import { AtlaSentClient } from "@atlasent/sdk";
1556
+ *
1557
+ * const client = new AtlaSentClient({ apiKey: "..." });
1558
+ *
1559
+ * const page = await client.scim.users.list({ orgId: "org_abc" });
1560
+ * for (const user of page.Resources) {
1561
+ * console.log(user.userName);
1562
+ * }
1563
+ *
1564
+ * const newUser = await client.scim.users.create("org_abc", {
1565
+ * userName: "alice@example.com",
1566
+ * displayName: "Alice Example",
1567
+ * active: true,
1568
+ * emails: [{ value: "alice@example.com", primary: true }],
1569
+ * });
1570
+ * ```
1556
1571
  */
1557
-
1558
- declare class AtlaSentClient {
1559
- private readonly apiKey;
1560
- private readonly baseUrl;
1561
- private readonly timeoutMs;
1562
- private readonly fetchImpl;
1563
- private readonly userAgent;
1564
- private readonly retryPolicy;
1565
- constructor(options: AtlaSentClientOptions);
1572
+ declare const SCIM_USER_SCHEMA: "urn:ietf:params:scim:schemas:core:2.0:User";
1573
+ declare const SCIM_GROUP_SCHEMA: "urn:ietf:params:scim:schemas:core:2.0:Group";
1574
+ declare const SCIM_PATCH_OP_SCHEMA: "urn:ietf:params:scim:api:messages:2.0:PatchOp";
1575
+ /** SCIM email value. */
1576
+ interface ScimEmail {
1577
+ value: string;
1578
+ type?: string;
1579
+ primary?: boolean;
1580
+ }
1581
+ /** SCIM name component. */
1582
+ interface ScimName {
1583
+ formatted?: string;
1584
+ givenName?: string;
1585
+ familyName?: string;
1586
+ }
1587
+ /** Group reference embedded on a user. */
1588
+ interface ScimGroupRef {
1589
+ value: string;
1590
+ display?: string;
1591
+ }
1592
+ /** SCIM metadata block. */
1593
+ interface ScimMeta {
1594
+ resourceType?: string;
1595
+ created?: string;
1596
+ lastModified?: string;
1597
+ location?: string;
1598
+ version?: string;
1599
+ }
1600
+ /** SCIM 2.0 User resource. */
1601
+ interface ScimUser {
1602
+ schemas?: string[];
1603
+ id?: string;
1604
+ userName: string;
1605
+ displayName?: string;
1606
+ active?: boolean;
1607
+ emails?: ScimEmail[];
1608
+ name?: ScimName;
1609
+ groups?: ScimGroupRef[];
1610
+ meta?: ScimMeta;
1611
+ [k: string]: unknown;
1612
+ }
1613
+ /** Create payload for a new SCIM user. `schemas` is injected automatically. */
1614
+ type ScimUserCreate = Omit<ScimUser, "id" | "meta">;
1615
+ /** Update payload for an existing SCIM user. */
1616
+ type ScimUserUpdate = ScimUser;
1617
+ /** RFC 7644 PatchOp operation. */
1618
+ interface ScimPatchOp {
1619
+ op: "add" | "remove" | "replace";
1620
+ path?: string;
1621
+ value?: unknown;
1622
+ }
1623
+ /** SCIM 2.0 ListResponse envelope (generic). */
1624
+ interface ScimListResponse<T = unknown> {
1625
+ schemas: string[];
1626
+ totalResults: number;
1627
+ startIndex: number;
1628
+ itemsPerPage: number;
1629
+ Resources: T[];
1630
+ }
1631
+ /** Query parameters for SCIM list operations. */
1632
+ interface ScimListParams {
1633
+ /** Organisation ID (required). */
1634
+ orgId: string;
1635
+ /** SCIM filter expression, e.g. `userName eq "alice@example.com"`. */
1636
+ filter?: string;
1637
+ /** 1-based pagination offset. Defaults to 1 on the server. */
1638
+ startIndex?: number;
1639
+ /** Maximum results per page. Defaults to 100 on the server. */
1640
+ count?: number;
1641
+ }
1642
+ /** Sub-client for /scim/v2/{orgId}/Users operations. */
1643
+ interface ScimUsersSubClient {
1566
1644
  /**
1567
- * Ask the policy engine whether an agent action is permitted.
1568
- *
1569
- * Accepts either the current v2.0 shape (`action_type` / `actor_id`)
1570
- * or the legacy v1.x shape (`action` / `agent`). Legacy callers
1571
- * receive a deprecation warning via `console.warn`; the shim is
1572
- * handled by {@link normalizeEvaluateRequest} and will be removed
1573
- * in v3.0.0.
1645
+ * `GET /scim/v2/{orgId}/Users` list provisioned users.
1574
1646
  *
1575
- * A "deny" is **not** thrown — it is returned in
1576
- * `response.decision`. Network errors, invalid API key, rate
1577
- * limits, timeouts, and malformed responses throw
1578
- * {@link AtlaSentError}.
1647
+ * ```ts
1648
+ * const page = await client.scim.users.list({ orgId: "org_abc" });
1649
+ * ```
1579
1650
  */
1580
- evaluate(input: EvaluateRequest | LegacyEvaluateRequest): Promise<EvaluateResponse>;
1651
+ list(params: ScimListParams): Promise<ScimListResponse<ScimUser>>;
1581
1652
  /**
1582
- * Batch evaluatesend up to 100 decisions in a single round-trip.
1583
- *
1584
- * Wraps `POST /v1-evaluate-batch`. The server evaluates each item
1585
- * against the active policy bundle and returns results in the same
1586
- * order as the input. One rate-limit token is consumed for the
1587
- * whole batch, and one audit-chain entry lists every included
1588
- * decision id.
1589
- *
1590
- * A per-item policy `deny` is **not** thrown — it appears as
1591
- * `item.decision === "deny"` in the returned items. A whole-batch
1592
- * network error, 4xx, or 5xx throws {@link AtlaSentError}.
1653
+ * `POST /scim/v2/{orgId}/Users`provision a new user.
1593
1654
  *
1594
- * Requires the `v2_batch` tenant feature flag to be enabled on the
1595
- * org (returns 404 when off). Requires scope `evaluate:write`.
1655
+ * ```ts
1656
+ * const user = await client.scim.users.create("org_abc", {
1657
+ * userName: "alice@example.com",
1658
+ * active: true,
1659
+ * emails: [{ value: "alice@example.com", primary: true }],
1660
+ * });
1661
+ * ```
1662
+ */
1663
+ create(orgId: string, user: ScimUserCreate): Promise<ScimUser>;
1664
+ /**
1665
+ * `PUT /scim/v2/{orgId}/Users/{id}` — full replacement.
1596
1666
  *
1597
- * @param requests - 1–100 evaluate items.
1598
- * @param batchId - Optional caller-supplied UUID for idempotency.
1599
- * A retried call with the same `batchId` and identical items
1600
- * returns the cached response within 24 h (`replayed: true`).
1667
+ * ```ts
1668
+ * const updated = await client.scim.users.update("org_abc", "usr_123", user);
1669
+ * ```
1601
1670
  */
1602
- evaluateBatch(requests: BatchEvalItem[], batchId?: string): Promise<BatchEvalResponse>;
1671
+ update(orgId: string, id: string, user: ScimUserUpdate): Promise<ScimUser>;
1603
1672
  /**
1604
- * Subscribe to a live stream of decisions for this org.
1673
+ * `DELETE /scim/v2/{orgId}/Users/{id}` deprovision a user.
1605
1674
  *
1606
- * Wraps `GET /v1-decisions-stream`. The server emits one SSE frame
1607
- * per audit event and sends a heartbeat every 15 s. The session
1608
- * auto-closes after `maxSeconds` (default 30 min); reconnect with
1609
- * the last received `event.id` to resume without replaying history.
1675
+ * ```ts
1676
+ * await client.scim.users.delete("org_abc", "usr_123");
1677
+ * ```
1678
+ */
1679
+ delete(orgId: string, id: string): Promise<void>;
1680
+ }
1681
+ /** Sub-client for /scim/v2/{orgId}/Groups operations. */
1682
+ interface ScimGroupsSubClient {
1683
+ /** `GET /scim/v2/{orgId}/Groups` — list groups. */
1684
+ list(params: ScimListParams): Promise<ScimListResponse<Record<string, unknown>>>;
1685
+ /** `POST /scim/v2/{orgId}/Groups` — create a group. */
1686
+ create(orgId: string, group: Record<string, unknown>): Promise<Record<string, unknown>>;
1687
+ /** `DELETE /scim/v2/{orgId}/Groups/{id}` — delete a group. */
1688
+ delete(orgId: string, id: string): Promise<void>;
1689
+ }
1690
+ /** Top-level SCIM sub-client exposed as `client.scim`. */
1691
+ interface ScimSubClient {
1692
+ users: ScimUsersSubClient;
1693
+ groups: ScimGroupsSubClient;
1694
+ }
1695
+ type PostFn = <T>(path: string, body: unknown, query?: URLSearchParams) => Promise<{
1696
+ body: T;
1697
+ }>;
1698
+ type GetFn = <T>(path: string, query?: URLSearchParams) => Promise<{
1699
+ body: T;
1700
+ }>;
1701
+ type PutFn = <T>(path: string, body: unknown) => Promise<{
1702
+ body: T;
1703
+ }>;
1704
+ type DeleteFn = (path: string) => Promise<void>;
1705
+ /**
1706
+ * Factory that returns the SCIM sub-client bound to a host client.
1707
+ * Called internally by AtlaSentClient; not part of the public constructor API.
1708
+ */
1709
+ declare function makeScimClient(postFn: PostFn, getFn: GetFn, putFn: PutFn, deleteFn: DeleteFn): ScimSubClient;
1710
+
1711
+ /**
1712
+ * Evidence Bundle helpers — create, retrieve, and download compliance
1713
+ * evidence bundles for incident investigations and audit export.
1714
+ *
1715
+ * Wire surface: POST/GET /v1/evidence-bundles
1716
+ *
1717
+ * Usage:
1718
+ *
1719
+ * ```ts
1720
+ * import { AtlaSentClient } from "@atlasent/sdk";
1721
+ *
1722
+ * const client = new AtlaSentClient({ apiKey: "..." });
1723
+ *
1724
+ * // Create
1725
+ * const bundle = await client.evidenceBundles.create({
1726
+ * incidentId: "inc_abc123",
1727
+ * includeOverrides: true,
1728
+ * });
1729
+ *
1730
+ * // Get
1731
+ * const bundle2 = await client.evidenceBundles.get(bundle.bundleId);
1732
+ *
1733
+ * // Download as JSON or PDF
1734
+ * const pdf = await client.evidenceBundles.download(bundle.bundleId, "pdf");
1735
+ * ```
1736
+ */
1737
+ /** Status of an evidence bundle. */
1738
+ type EvidenceBundleStatus = "pending" | "building" | "ready" | "failed" | "expired";
1739
+ /** An evidence bundle record returned by the API. */
1740
+ interface EvidenceBundle {
1741
+ /** Server-assigned bundle identifier. */
1742
+ bundleId: string;
1743
+ /** Organisation the bundle belongs to. */
1744
+ orgId: string;
1745
+ /** Incident or investigation ID this bundle was created for. */
1746
+ incidentId: string;
1747
+ /** Current bundle status. */
1748
+ status: EvidenceBundleStatus;
1749
+ /** Permit IDs included in the bundle (empty = all permits for the incident). */
1750
+ includedPermits: string[];
1751
+ /** Whether override events are included. */
1752
+ includeOverrides: boolean;
1753
+ /** Format used when the bundle was created. */
1754
+ format: "json" | "pdf";
1755
+ /** ISO 8601 creation time. */
1756
+ createdAt: string;
1757
+ /** ISO 8601 expiration time. */
1758
+ expiresAt: string;
1759
+ /** Pre-signed download URL (populated when status is `ready`). */
1760
+ downloadUrl?: string;
1761
+ /** Free-form metadata supplied at creation. */
1762
+ metadata?: Record<string, unknown>;
1763
+ }
1764
+ /** Input to {@link EvidenceBundlesMixin.create}. */
1765
+ interface EvidenceBundleCreateParams {
1766
+ /** Incident or investigation ID for this bundle. */
1767
+ incidentId: string;
1768
+ /**
1769
+ * Optional list of specific permit IDs to include.
1770
+ * When omitted, all permits associated with the incident are included.
1771
+ */
1772
+ includedPermits?: string[];
1773
+ /**
1774
+ * When `true`, override events are embedded in the bundle.
1775
+ * Defaults to `false`.
1776
+ */
1777
+ includeOverrides?: boolean;
1778
+ }
1779
+ /** Query parameters for {@link EvidenceBundleSubClient.list}. */
1780
+ interface EvidenceBundleListParams {
1781
+ /** Filter bundles to a specific execution ID. */
1782
+ executionId?: string;
1783
+ /** Maximum number of bundles to return. */
1784
+ limit?: number;
1785
+ /** Opaque cursor from a previous list response for pagination. */
1786
+ cursor?: string;
1787
+ }
1788
+ /** Paginated response from {@link EvidenceBundleSubClient.list}. */
1789
+ interface EvidenceBundleListPage {
1790
+ /** Evidence bundles for this page. */
1791
+ bundles: EvidenceBundle[];
1792
+ /** Pass as `cursor` to `list()` to fetch the next page. `null` means no more pages. */
1793
+ nextCursor: string | null;
1794
+ }
1795
+ /**
1796
+ * Sub-client for evidence bundle operations.
1797
+ * Accessed as `client.evidenceBundles` on {@link AtlaSentClient}.
1798
+ */
1799
+ interface EvidenceBundleSubClient {
1800
+ /**
1801
+ * List evidence bundles for the org, with optional filters and pagination.
1610
1802
  *
1611
1803
  * ```ts
1612
- * const controller = new AbortController();
1613
- * for await (const event of client.subscribeDecisions({ signal: controller.signal })) {
1614
- * if (event.type === "heartbeat") continue;
1615
- * console.log(event.type, event.decision, event.actorId);
1616
- * if (event.type === "session_end") break; // reconnect
1804
+ * const page = await client.evidenceBundles.list({ limit: 20 });
1805
+ * for (const bundle of page.bundles) { ... }
1806
+ * if (page.nextCursor) {
1807
+ * const next = await client.evidenceBundles.list({ cursor: page.nextCursor });
1617
1808
  * }
1618
1809
  * ```
1810
+ */
1811
+ list(params?: EvidenceBundleListParams): Promise<EvidenceBundleListPage>;
1812
+ /**
1813
+ * Create a new evidence bundle.
1619
1814
  *
1620
- * Requires scope `audit:read`. Requires the `v2_decisions_stream`
1621
- * tenant feature flag (returns 404 when off).
1815
+ * ```ts
1816
+ * const bundle = await client.evidenceBundles.create({
1817
+ * incidentId: "inc_abc123",
1818
+ * includeOverrides: true,
1819
+ * });
1820
+ * ```
1622
1821
  */
1623
- subscribeDecisions(opts?: SubscribeDecisionsOptions): AsyncGenerator<DecisionStreamEvent>;
1822
+ create(params: EvidenceBundleCreateParams): Promise<EvidenceBundle>;
1624
1823
  /**
1625
- * Pre-flight evaluation that always returns the constraint trace.
1824
+ * Retrieve an evidence bundle by ID.
1626
1825
  *
1627
- * Wraps `POST /v1-evaluate?include=constraint_trace`. Use this from
1628
- * a workflow's submission step to surface trivial defects (missing
1629
- * fields, wrong roles, mis-set context) BEFORE pushing the request
1630
- * onto an approval queue — only requests that would actually pass
1631
- * make it through to a human reviewer.
1826
+ * ```ts
1827
+ * const bundle = await client.evidenceBundles.get("bnd_xyz");
1828
+ * ```
1829
+ */
1830
+ get(bundleId: string): Promise<EvidenceBundle>;
1831
+ /**
1832
+ * Download the evidence bundle contents.
1632
1833
  *
1633
- * Returns an {@link EvaluatePreflightResponse} carrying the regular
1634
- * {@link EvaluateResponse} plus the {@link ConstraintTrace}. Unlike
1635
- * {@link evaluate}, this method does NOT mark a non-allow as a
1636
- * thrown condition — the whole point is to inspect both the outcome
1834
+ * @param bundleId - The bundle to download.
1835
+ * @param format - `"json"` (default) or `"pdf"`.
1836
+ * @returns Raw bytes of the downloaded file.
1837
+ *
1838
+ * ```ts
1839
+ * const pdf = await client.evidenceBundles.download("bnd_xyz", "pdf");
1840
+ * await fs.writeFile("bundle.pdf", pdf);
1841
+ * ```
1842
+ */
1843
+ download(bundleId: string, format?: "json" | "pdf"): Promise<Buffer>;
1844
+ }
1845
+ /**
1846
+ * Factory that returns the evidence-bundles sub-client bound to a host
1847
+ * client. Called internally by AtlaSentClient; not part of the public
1848
+ * constructor API.
1849
+ */
1850
+ declare function makeEvidenceBundleClient(postFn: <T>(path: string, body: unknown) => Promise<{
1851
+ body: T;
1852
+ }>, getFn: <T>(path: string, query?: URLSearchParams) => Promise<{
1853
+ body: T;
1854
+ }>, getRawFn: (path: string) => Promise<ArrayBuffer>): EvidenceBundleSubClient;
1855
+
1856
+ /**
1857
+ * Auth helpers — token management and multi-IdP token refresh.
1858
+ *
1859
+ * Wire surface: /v1/auth/* endpoints in atlasent-api.
1860
+ *
1861
+ * Usage:
1862
+ *
1863
+ * ```ts
1864
+ * import { AtlaSentClient } from "@atlasent/sdk";
1865
+ *
1866
+ * const client = new AtlaSentClient({ apiKey: "..." });
1867
+ *
1868
+ * // Refresh using the default IdP
1869
+ * const tokens = await client.auth.refresh(currentRefreshToken);
1870
+ *
1871
+ * // Refresh using a specific IdP (multi-IdP orgs)
1872
+ * const tokens = await client.auth.refreshWithIdp("idp_okta_prod", currentRefreshToken);
1873
+ *
1874
+ * // List IdP connections
1875
+ * const connections = await client.auth.listIdpConnections();
1876
+ * ```
1877
+ */
1878
+ /** A token response from the auth endpoints. */
1879
+ interface TokenResponse {
1880
+ accessToken: string;
1881
+ refreshToken: string;
1882
+ tokenType: string;
1883
+ expiresIn: number;
1884
+ scope?: string;
1885
+ /** IdP that issued the token (populated on multi-IdP responses). */
1886
+ idpId?: string;
1887
+ }
1888
+ /** An IdP connection record. */
1889
+ interface IdpConnection {
1890
+ id: string;
1891
+ name: string;
1892
+ provider: string;
1893
+ enabled: boolean;
1894
+ isDefault: boolean;
1895
+ domains?: string[];
1896
+ createdAt: string;
1897
+ }
1898
+ /** Sub-client for token management and multi-IdP auth. */
1899
+ interface AuthSubClient {
1900
+ /**
1901
+ * Refresh an access token using the default IdP connection.
1902
+ *
1903
+ * ```ts
1904
+ * const tokens = await client.auth.refresh(currentRefreshToken);
1905
+ * ```
1906
+ */
1907
+ refresh(refreshToken: string): Promise<TokenResponse>;
1908
+ /**
1909
+ * Refresh an access token against a specific IdP connection.
1910
+ *
1911
+ * Use this in multi-IdP organisations where the caller needs to
1912
+ * specify which SSO connection to use for the token exchange.
1913
+ *
1914
+ * `idpId` corresponds to the connection ID returned by
1915
+ * `listIdpConnections()` (e.g. `"idp_okta_prod"`, `"idp_entra"`).
1916
+ *
1917
+ * ```ts
1918
+ * const tokens = await client.auth.refreshWithIdp(
1919
+ * "idp_okta_prod",
1920
+ * currentRefreshToken,
1921
+ * );
1922
+ * ```
1923
+ */
1924
+ refreshWithIdp(idpId: string, refreshToken: string): Promise<TokenResponse>;
1925
+ /**
1926
+ * List IdP connections available for this organisation.
1927
+ *
1928
+ * ```ts
1929
+ * const connections = await client.auth.listIdpConnections();
1930
+ * const primary = connections.find(c => c.isDefault);
1931
+ * ```
1932
+ */
1933
+ listIdpConnections(): Promise<IdpConnection[]>;
1934
+ }
1935
+ /**
1936
+ * Factory that returns the auth sub-client bound to a host client.
1937
+ * Called internally by AtlaSentClient; not part of the public constructor API.
1938
+ */
1939
+ declare function makeAuthClient(postFn: <T>(path: string, body: unknown) => Promise<{
1940
+ body: T;
1941
+ }>, getFn: <T>(path: string) => Promise<{
1942
+ body: T;
1943
+ }>): AuthSubClient;
1944
+
1945
+ /**
1946
+ * SSO administration — connections, JIT rules, events, enforcement state
1947
+ * machine, and the `client.sso` sub-client.
1948
+ *
1949
+ * Usage:
1950
+ *
1951
+ * ```ts
1952
+ * import { AtlaSentClient } from "@atlasent/sdk";
1953
+ *
1954
+ * const client = new AtlaSentClient({ apiKey: "..." });
1955
+ *
1956
+ * const { connections } = await client.sso.listConnections();
1957
+ * const status = await client.sso.getStatus();
1958
+ * await client.sso.enforce("enable");
1959
+ * ```
1960
+ */
1961
+ /** An SSO connection record (SAML 2.0 or OIDC). */
1962
+ interface SsoConnection {
1963
+ id: string;
1964
+ organizationId: string;
1965
+ name: string;
1966
+ protocol: "saml" | "oidc";
1967
+ idpEntityId: string;
1968
+ metadataUrl: string | null;
1969
+ metadataXml: string | null;
1970
+ emailDomain: string | null;
1971
+ enforceForDomain: boolean;
1972
+ isActive: boolean;
1973
+ supabaseProviderId: string | null;
1974
+ createdBy: string;
1975
+ createdAt: string;
1976
+ updatedAt: string;
1977
+ }
1978
+ /** Wire (snake_case) shape for SSO connection responses. */
1979
+ interface SsoConnectionWire {
1980
+ id: string;
1981
+ organization_id: string;
1982
+ name: string;
1983
+ protocol: "saml" | "oidc";
1984
+ idp_entity_id: string;
1985
+ metadata_url: string | null;
1986
+ metadata_xml: string | null;
1987
+ email_domain: string | null;
1988
+ enforce_for_domain: boolean;
1989
+ is_active: boolean;
1990
+ supabase_provider_id: string | null;
1991
+ created_by: string;
1992
+ created_at: string;
1993
+ updated_at: string;
1994
+ }
1995
+ declare function wireToSsoConnection(w: SsoConnectionWire): SsoConnection;
1996
+ type SsoRole = "owner" | "admin" | "approver" | "member" | "viewer";
1997
+ /** A JIT provisioning rule that maps an IdP claim to an org role. */
1998
+ interface SsoJitRule {
1999
+ id: string;
2000
+ connectionId: string;
2001
+ organizationId: string;
2002
+ claimAttribute: string;
2003
+ claimValue: string;
2004
+ grantedRole: SsoRole;
2005
+ precedence: number;
2006
+ isActive: boolean;
2007
+ createdAt: string;
2008
+ updatedAt: string;
2009
+ }
2010
+ /** Wire (snake_case) shape for JIT rule responses. */
2011
+ interface SsoJitRuleWire {
2012
+ id: string;
2013
+ connection_id: string;
2014
+ organization_id: string;
2015
+ claim_attribute: string;
2016
+ claim_value: string;
2017
+ granted_role: SsoRole;
2018
+ precedence: number;
2019
+ is_active: boolean;
2020
+ created_at: string;
2021
+ updated_at: string;
2022
+ }
2023
+ declare function wireToSsoJitRule(w: SsoJitRuleWire): SsoJitRule;
2024
+ /**
2025
+ * An SSO lifecycle event — login, session, config change, break-glass, or
2026
+ * JIT provisioning.
2027
+ */
2028
+ interface SsoEvent {
2029
+ id: string;
2030
+ organizationId: string;
2031
+ connectionId: string | null;
2032
+ eventType: string;
2033
+ actorEmail: string | null;
2034
+ payload: Record<string, unknown>;
2035
+ occurredAt: string;
2036
+ }
2037
+ /** Wire (snake_case) shape for SSO event responses. */
2038
+ interface SsoEventWire {
2039
+ id: string;
2040
+ organization_id: string;
2041
+ connection_id: string | null;
2042
+ event_type: string;
2043
+ actor_email: string | null;
2044
+ payload: Record<string, unknown>;
2045
+ occurred_at: string;
2046
+ }
2047
+ declare function wireToSsoEvent(w: SsoEventWire): SsoEvent;
2048
+ /** Action to pass to `POST /v1/sso/enforce`. */
2049
+ type SsoEnforceAction = "enable" | "enforce";
2050
+ /**
2051
+ * Four-boolean readiness checklist returned by `GET /v1/sso/status`.
2052
+ * All four must be `true` before enforcement is safe to activate.
2053
+ */
2054
+ interface SsoReadiness {
2055
+ /** At least one SSO connection row exists for the org. */
2056
+ connectionConfigured: boolean;
2057
+ /** At least one connection has been activated (registered with the IdP). */
2058
+ connectionTested: boolean;
2059
+ /** Break-glass access has been configured (non-default settings). */
2060
+ breakGlassSet: boolean;
2061
+ /** No unreviewed active service API keys exist. */
2062
+ serviceApiKeysReviewed: boolean;
2063
+ }
2064
+ /** Wire (snake_case) shape for the readiness response. */
2065
+ interface SsoReadinessWire {
2066
+ connection_configured: boolean;
2067
+ connection_tested: boolean;
2068
+ break_glass_set: boolean;
2069
+ service_api_keys_reviewed: boolean;
2070
+ }
2071
+ declare function wireToSsoReadiness(w: SsoReadinessWire): SsoReadiness;
2072
+ /** Input for creating a JIT provisioning rule. */
2073
+ interface SsoJitRuleInput {
2074
+ connectionId: string;
2075
+ claimAttribute: string;
2076
+ claimValue: string;
2077
+ grantedRole: SsoRole;
2078
+ precedence?: number;
2079
+ }
2080
+ /** Patchable fields for an existing JIT rule. */
2081
+ interface SsoJitRulePatch {
2082
+ claimAttribute?: string;
2083
+ claimValue?: string;
2084
+ grantedRole?: SsoRole;
2085
+ precedence?: number;
2086
+ isActive?: boolean;
2087
+ }
2088
+ /** Input for creating or updating an SSO connection. */
2089
+ interface SsoConnectionInput {
2090
+ name: string;
2091
+ protocol: "saml" | "oidc";
2092
+ idpEntityId: string;
2093
+ metadataUrl?: string | null;
2094
+ metadataXml?: string | null;
2095
+ emailDomain?: string | null;
2096
+ enforceForDomain?: boolean;
2097
+ }
2098
+ /** Result of `POST /v1/sso/enforce`. */
2099
+ interface SsoEnforceResult {
2100
+ ok: boolean;
2101
+ action: SsoEnforceAction;
2102
+ enforceSso: boolean;
2103
+ enforceSsoAt: string | null;
2104
+ }
2105
+ /**
2106
+ * Sub-client for SSO administration.
2107
+ * Accessed as `client.sso` on {@link AtlaSentClient}.
2108
+ */
2109
+ interface SsoSubClient {
2110
+ /** List all SSO connections for the org. */
2111
+ listConnections(): Promise<{
2112
+ connections: SsoConnection[];
2113
+ }>;
2114
+ /** Get a single SSO connection by ID. */
2115
+ getConnection(id: string): Promise<SsoConnection>;
2116
+ /** Create a new SSO connection. */
2117
+ createConnection(input: SsoConnectionInput): Promise<SsoConnection>;
2118
+ /** Update an existing SSO connection. */
2119
+ updateConnection(id: string, input: Partial<SsoConnectionInput>): Promise<SsoConnection>;
2120
+ /** Delete an SSO connection. */
2121
+ deleteConnection(id: string): Promise<void>;
2122
+ /** Activate (register) a connection with the IdP. */
2123
+ activateConnection(id: string): Promise<{
2124
+ ok: boolean;
2125
+ supabaseProviderId: string | null;
2126
+ }>;
2127
+ /**
2128
+ * Advance the SSO enforcement state machine.
2129
+ * `"enable"` → SSO enabled, not yet enforced.
2130
+ * `"enforce"` → SSO mandatory for all members (requires readiness checklist to pass).
2131
+ */
2132
+ enforce(action: SsoEnforceAction): Promise<SsoEnforceResult>;
2133
+ /** Get the four-boolean enforcement readiness checklist. */
2134
+ getStatus(): Promise<SsoReadiness>;
2135
+ /** List JIT provisioning rules, optionally filtered to a single connection. */
2136
+ listJitRules(connectionId?: string): Promise<{
2137
+ rules: SsoJitRule[];
2138
+ }>;
2139
+ /** Create a new JIT provisioning rule. */
2140
+ createJitRule(input: SsoJitRuleInput): Promise<SsoJitRule>;
2141
+ /** Update fields on an existing JIT rule. */
2142
+ patchJitRule(id: string, patch: SsoJitRulePatch): Promise<SsoJitRule>;
2143
+ /** Delete a JIT provisioning rule. */
2144
+ deleteJitRule(id: string): Promise<void>;
2145
+ }
2146
+ /**
2147
+ * Factory that returns the SSO sub-client bound to a host client's transport
2148
+ * helpers. Called internally by AtlaSentClient; not part of the public API.
2149
+ */
2150
+ declare function makeSsoClient(getFn: <T>(path: string, query?: URLSearchParams) => Promise<{
2151
+ body: T;
2152
+ }>, postFn: <T>(path: string, body: unknown) => Promise<{
2153
+ body: T;
2154
+ }>, patchFn: <T>(path: string, body: unknown) => Promise<{
2155
+ body: T;
2156
+ }>, deleteFn: (path: string) => Promise<void>): SsoSubClient;
2157
+
2158
+ /**
2159
+ * Access Governance Log sub-client — paginated identity lifecycle events.
2160
+ *
2161
+ * Wire surface: GET /v1/access-governance-log
2162
+ *
2163
+ * Usage:
2164
+ *
2165
+ * ```ts
2166
+ * import { AtlaSentClient } from "@atlasent/sdk";
2167
+ *
2168
+ * const client = new AtlaSentClient({ apiKey: "..." });
2169
+ *
2170
+ * const page = await client.accessGovernanceLog.list({ limit: 50 });
2171
+ * for (const event of page.events) {
2172
+ * console.log(event.eventType, event.actorEmail);
2173
+ * }
2174
+ * if (page.nextCursor) {
2175
+ * const next = await client.accessGovernanceLog.list({ cursor: page.nextCursor });
2176
+ * }
2177
+ * ```
2178
+ */
2179
+ /** A single identity lifecycle event from the access governance log. */
2180
+ interface AccessGovernanceEvent {
2181
+ id: string;
2182
+ eventType: string;
2183
+ orgId: string;
2184
+ actorId: string | null;
2185
+ actorEmail: string | null;
2186
+ ipAddress: string | null;
2187
+ metadata: Record<string, unknown>;
2188
+ createdAt: string;
2189
+ }
2190
+ /** A page of access governance events with cursor for the next page. */
2191
+ interface AccessGovernanceLogPage {
2192
+ events: AccessGovernanceEvent[];
2193
+ /** Pass as `cursor` to `list()` to fetch the next page. `null` means no more pages. */
2194
+ nextCursor: string | null;
2195
+ totalCount: number;
2196
+ }
2197
+ /** Query parameters for `accessGovernanceLog.list()`. */
2198
+ interface AccessGovernanceLogQuery {
2199
+ /** Max events to return. Default 50, max 200. */
2200
+ limit?: number;
2201
+ /** Cursor from a previous page's `nextCursor`. */
2202
+ cursor?: string;
2203
+ /** Filter by event type (e.g. `"sso.login"`, `"jit.provisioned"`). */
2204
+ eventType?: string;
2205
+ /** Filter by actor email or UUID. */
2206
+ actorId?: string;
2207
+ /** Lower bound on event timestamp (ISO 8601). */
2208
+ from?: string;
2209
+ /** Upper bound on event timestamp (ISO 8601). */
2210
+ to?: string;
2211
+ }
2212
+ /**
2213
+ * Sub-client for the access governance log.
2214
+ * Accessed as `client.accessGovernanceLog` on {@link AtlaSentClient}.
2215
+ */
2216
+ interface AccessGovernanceLogSubClient {
2217
+ /**
2218
+ * Fetch a page of identity lifecycle events for the authenticated org.
2219
+ *
2220
+ * ```ts
2221
+ * const { events, nextCursor } = await client.accessGovernanceLog.list({
2222
+ * eventType: "sso.login",
2223
+ * limit: 100,
2224
+ * });
2225
+ * ```
2226
+ */
2227
+ list(query?: AccessGovernanceLogQuery): Promise<AccessGovernanceLogPage>;
2228
+ }
2229
+ /**
2230
+ * Factory that returns the access-governance-log sub-client bound to a host
2231
+ * client's transport helpers. Called internally by AtlaSentClient.
2232
+ */
2233
+ declare function makeAccessGovernanceLogClient(getFn: <T>(path: string, query?: URLSearchParams) => Promise<{
2234
+ body: T;
2235
+ }>): AccessGovernanceLogSubClient;
2236
+
2237
+ /**
2238
+ * AtlaSent HTTP client.
2239
+ *
2240
+ * Two public methods, both backed by native `fetch`:
2241
+ * - {@link AtlaSentClient.evaluate} → POST {baseUrl}/v1-evaluate
2242
+ * - {@link AtlaSentClient.verifyPermit} → POST {baseUrl}/v1-verify-permit
2243
+ *
2244
+ * Fail-closed: a clean policy DENY is returned (not thrown), but
2245
+ * network, timeout, bad response, 4xx/5xx, and rate-limit conditions
2246
+ * all throw {@link AtlaSentError}.
2247
+ */
2248
+
2249
+ declare class AtlaSentClient {
2250
+ private readonly apiKey;
2251
+ private readonly baseUrl;
2252
+ private readonly timeoutMs;
2253
+ private readonly fetchImpl;
2254
+ private readonly userAgent;
2255
+ private readonly retryPolicy;
2256
+ /** SCIM 2.0 provisioning sub-client. Access as `client.scim`. */
2257
+ readonly scim: ScimSubClient;
2258
+ /** Evidence bundle sub-client. Access as `client.evidenceBundles`. */
2259
+ readonly evidenceBundles: EvidenceBundleSubClient;
2260
+ /** Auth / token management sub-client. Access as `client.auth`. */
2261
+ readonly auth: AuthSubClient;
2262
+ /** SSO administration sub-client. Access as `client.sso`. */
2263
+ readonly sso: SsoSubClient;
2264
+ /** Access governance log sub-client. Access as `client.accessGovernanceLog`. */
2265
+ readonly accessGovernanceLog: AccessGovernanceLogSubClient;
2266
+ /** Trust-root snapshot manager for this client instance. */
2267
+ readonly trustRoot: TrustRootManager;
2268
+ constructor(options: AtlaSentClientOptions);
2269
+ /** Return the current trust-root snapshot (pinned or last successful refresh). */
2270
+ getTrustSnapshot(): TrustRootSnapshot;
2271
+ /**
2272
+ * Ask the policy engine whether an agent action is permitted.
2273
+ *
2274
+ * Accepts either the current v2.0 shape (`action_type` / `actor_id`)
2275
+ * or the legacy v1.x shape (`action` / `agent`). Legacy callers
2276
+ * receive a deprecation warning via `console.warn`; the shim is
2277
+ * handled by {@link normalizeEvaluateRequest} and will be removed
2278
+ * in v3.0.0.
2279
+ *
2280
+ * A "deny" is **not** thrown — it is returned in
2281
+ * `response.decision`. Network errors, invalid API key, rate
2282
+ * limits, timeouts, and malformed responses throw
2283
+ * {@link AtlaSentError}.
2284
+ */
2285
+ evaluate(input: EvaluateRequest | LegacyEvaluateRequest): Promise<EvaluateResponse>;
2286
+ /**
2287
+ * Batch evaluate — send up to 100 decisions in a single round-trip.
2288
+ *
2289
+ * Wraps `POST /v1/evaluate/batch` (with fallback to
2290
+ * `POST /v1-evaluate-batch` on older runtimes). The server evaluates each item
2291
+ * against the active policy bundle and returns results in the same
2292
+ * order as the input. One rate-limit token is consumed for the
2293
+ * whole batch, and one audit-chain entry lists every included
2294
+ * decision id.
2295
+ *
2296
+ * A per-item policy `deny` is **not** thrown — it appears as
2297
+ * `item.decision === "deny"` in the returned items. A whole-batch
2298
+ * network error, 4xx, or 5xx throws {@link AtlaSentError}.
2299
+ *
2300
+ * Requires the `v2_batch` tenant feature flag to be enabled on the
2301
+ * org (returns 404 when off). Requires scope `evaluate:write`.
2302
+ *
2303
+ * @param requests - 1–100 evaluate items.
2304
+ * @param batchId - Optional caller-supplied UUID for idempotency.
2305
+ * A retried call with the same `batchId` and identical items
2306
+ * returns the cached response within 24 h (`replayed: true`).
2307
+ */
2308
+ evaluateBatch(requests: BatchEvalItem[], batchId?: string): Promise<BatchEvalResponse>;
2309
+ /**
2310
+ * Subscribe to a live stream of decisions for this org.
2311
+ *
2312
+ * Wraps `GET /v1-decisions-stream`. The server emits one SSE frame
2313
+ * per audit event and sends a heartbeat every 15 s. The session
2314
+ * auto-closes after `maxSeconds` (default 30 min); reconnect with
2315
+ * the last received `event.id` to resume without replaying history.
2316
+ *
2317
+ * ```ts
2318
+ * const controller = new AbortController();
2319
+ * for await (const event of client.subscribeDecisions({ signal: controller.signal })) {
2320
+ * if (event.type === "heartbeat") continue;
2321
+ * console.log(event.type, event.decision, event.actorId);
2322
+ * if (event.type === "session_end") break; // reconnect
2323
+ * }
2324
+ * ```
2325
+ *
2326
+ * Requires scope `audit:read`. Requires the `v2_decisions_stream`
2327
+ * tenant feature flag (returns 404 when off).
2328
+ */
2329
+ subscribeDecisions(opts?: SubscribeDecisionsOptions): AsyncGenerator<DecisionStreamEvent>;
2330
+ /**
2331
+ * Pre-flight evaluation that always returns the constraint trace.
2332
+ *
2333
+ * Wraps `POST /v1-evaluate?include=constraint_trace`. Use this from
2334
+ * a workflow's submission step to surface trivial defects (missing
2335
+ * fields, wrong roles, mis-set context) BEFORE pushing the request
2336
+ * onto an approval queue — only requests that would actually pass
2337
+ * make it through to a human reviewer.
2338
+ *
2339
+ * Returns an {@link EvaluatePreflightResponse} carrying the regular
2340
+ * {@link EvaluateResponse} plus the {@link ConstraintTrace}. Unlike
2341
+ * {@link evaluate}, this method does NOT mark a non-allow as a
2342
+ * thrown condition — the whole point is to inspect both the outcome
1637
2343
  * AND the per-policy trace, so the caller branches on
1638
2344
  * `result.evaluation.decision` and reads `result.constraintTrace`
1639
2345
  * to render the failing stages.
@@ -1879,7 +2585,8 @@ declare class AtlaSentClient {
1879
2585
  */
1880
2586
  replay(input: ReplayRequest): Promise<ReplayResponse>;
1881
2587
  /**
1882
- * Open a streaming evaluation session against `POST /v1-evaluate-stream`.
2588
+ * Open a streaming evaluation session against `POST /v1/evaluate/stream`
2589
+ * (with fallback to `POST /v1-evaluate-stream` on older runtimes).
1883
2590
  *
1884
2591
  * Yields {@link StreamDecisionEvent} and {@link StreamProgressEvent} objects
1885
2592
  * as the server emits them. The iterator ends cleanly when the server sends
@@ -1908,7 +2615,41 @@ declare class AtlaSentClient {
1908
2615
  * ```
1909
2616
  */
1910
2617
  protectStream(input: EvaluateRequest, opts?: StreamOptions): AsyncIterable<StreamEvent>;
2618
+ /**
2619
+ * Retrieve the license status of this self-hosted or air-gapped deployment.
2620
+ *
2621
+ * Calls `GET /v1/license`. Returns the current validity state, expiry,
2622
+ * enabled feature flags, and optional capacity limits for the installed
2623
+ * license key.
2624
+ *
2625
+ * Callers should check `result.status === "active"` before proceeding.
2626
+ * A `"grace"` status means the license has lapsed but a grace window
2627
+ * (`grace_until`) is still open — the deployment continues to function
2628
+ * but the license should be renewed immediately.
2629
+ *
2630
+ * Throws {@link AtlaSentError} on transport / auth failures.
2631
+ */
2632
+ getLicense(): Promise<LicenseStatus & {
2633
+ rateLimit: RateLimitState | null;
2634
+ }>;
2635
+ /**
2636
+ * Validate a signed license blob against this deployment's installed
2637
+ * public key.
2638
+ *
2639
+ * Calls `POST /v1/license/verify`. Use this when onboarding a new license
2640
+ * key or rotating an expiring one — submit the blob received from AtlaSent
2641
+ * and check `result.valid` before applying the new license.
2642
+ *
2643
+ * A `valid: false` response is **not** thrown — inspect the returned
2644
+ * object. Only transport / server errors throw {@link AtlaSentError}.
2645
+ *
2646
+ * @param blob — The signed license blob string provided by AtlaSent.
2647
+ */
2648
+ verifyLicense(blob: string): Promise<LicenseVerifyResult & {
2649
+ rateLimit: RateLimitState | null;
2650
+ }>;
1911
2651
  private post;
2652
+ private postWithPathFallback;
1912
2653
  private get;
1913
2654
  private request;
1914
2655
  /**
@@ -2173,6 +2914,13 @@ declare class AtlaSentClient {
2173
2914
  * surfaces as `clear`.
2174
2915
  */
2175
2916
  listGovernanceEvaluations(query: ListGovernanceEvaluationsQuery): Promise<GovernanceAgentEvaluation[]>;
2917
+ private _post;
2918
+ private _get;
2919
+ private _put;
2920
+ private _patch;
2921
+ private _delete;
2922
+ private _getRaw;
2923
+ private _requestRaw;
2176
2924
  }
2177
2925
 
2178
2926
  /** Node's webcrypto CryptoKey — kept local so the module doesn't depend on DOM types. */
@@ -2220,6 +2968,14 @@ interface VerifyBundleOptions {
2220
2968
  publicKeysPem?: readonly string[];
2221
2969
  /** Already-imported keys, paired with registry ids (rotation hint). */
2222
2970
  keys?: readonly VerifyKey[];
2971
+ /** Trust-root snapshot for revocation + expiry checks. */
2972
+ trustRoot?: TrustRootSnapshot;
2973
+ /**
2974
+ * Opt out of fail-closed snapshot expiry check (ADR-005 D3).
2975
+ * Intended for air-gap / offline use cases.
2976
+ * Emits a one-time warning per process start.
2977
+ */
2978
+ allowExpiredSnapshot?: boolean;
2223
2979
  }
2224
2980
  /**
2225
2981
  * Reproduces `_shared/rules.ts::canonicalJSON` byte-for-byte:
@@ -2236,7 +2992,10 @@ declare function canonicalJSON(value: unknown): string;
2236
2992
  * the literal below is byte-identical with what the backend signs.
2237
2993
  */
2238
2994
  declare function signedBytesFor(bundle: AuditBundle): Uint8Array<ArrayBuffer>;
2239
- declare function verifyAuditBundle(bundle: AuditBundle, keys: readonly VerifyKey[]): Promise<BundleVerificationResult>;
2995
+ declare function verifyAuditBundle(bundle: AuditBundle, keys: readonly VerifyKey[], trustRootOpts?: {
2996
+ trustRoot?: TrustRootSnapshot;
2997
+ allowExpiredSnapshot?: boolean;
2998
+ }): Promise<BundleVerificationResult>;
2240
2999
  /**
2241
3000
  * Load a bundle from disk (or a parsed object) and verify it.
2242
3001
  *
@@ -2245,6 +3004,11 @@ declare function verifyAuditBundle(bundle: AuditBundle, keys: readonly VerifyKey
2245
3004
  * but `signatureValid` will be false with an explanatory `reason` —
2246
3005
  * callers that want a complete offline check MUST supply the trust
2247
3006
  * set.
3007
+ *
3008
+ * When `trustRoot` is not supplied, the global trust-root manager's
3009
+ * current snapshot is used automatically (B2.3 bootstrap wire-in).
3010
+ * Pass `allowExpiredSnapshot: true` to disable fail-closed expiry
3011
+ * for air-gap environments.
2248
3012
  */
2249
3013
  declare function verifyBundle(pathOrBundle: string | AuditBundle, options?: VerifyBundleOptions): Promise<BundleVerificationResult>;
2250
3014
 
@@ -2275,6 +3039,40 @@ declare function verifyBundle(pathOrBundle: string | AuditBundle, options?: Veri
2275
3039
  * Unlike calling the executor directly, dangerous code cannot bypass
2276
3040
  * this gate: if `requirePermit` throws, the executor never runs.
2277
3041
  */
3042
+ /**
3043
+ * Catalog of built-in protected action types, mirroring `CanonicalProtectedActionType`
3044
+ * in the OpenAPI spec. Use these constants as `action_type` values in
3045
+ * {@link requirePermit} calls instead of bare strings.
3046
+ *
3047
+ * ```ts
3048
+ * await requirePermit(
3049
+ * { action_type: CanonicalProtectedActionType.DATABASE_TABLE_DELETE, ... },
3050
+ * () => db.raw("DELETE FROM users"),
3051
+ * );
3052
+ * ```
3053
+ */
3054
+ declare const CanonicalProtectedActionType: {
3055
+ readonly PRODUCTION_DEPLOY: "production.deploy";
3056
+ readonly HR_EMPLOYEE_OFFBOARD: "hr.employee.offboard";
3057
+ readonly HR_ACCESS_REVOKE: "hr.access.revoke";
3058
+ readonly HR_ROLE_ESCALATE: "hr.role.escalate";
3059
+ readonly ML_MODEL_PROMOTE: "ml.model.promote";
3060
+ readonly ML_MODEL_RETIRE: "ml.model.retire";
3061
+ readonly ML_MODEL_FINE_TUNE: "ml.model.fine_tune";
3062
+ readonly CUSTOMER_DATA_DELETE: "customer.data.delete";
3063
+ readonly CONTRACT_EXECUTE: "contract.execute";
3064
+ readonly CONTRACT_AMEND: "contract.amend";
3065
+ readonly PRICING_RULE_PUBLISH: "pricing.rule.publish";
3066
+ readonly PRICING_DISCOUNT_APPROVE: "pricing.discount.approve";
3067
+ readonly SECURITY_INCIDENT_ESCALATE: "security.incident.escalate";
3068
+ readonly SECURITY_ACCESS_QUARANTINE: "security.access.quarantine";
3069
+ readonly ACCESS_CERT_REVOKE: "access.cert.revoke";
3070
+ readonly PERIOD_CLOSE_CERTIFY: "period.close.certify";
3071
+ readonly DATABASE_MIGRATION_APPLY: "database.migration.apply";
3072
+ readonly DATABASE_SCHEMA_DROP: "database.schema.drop";
3073
+ readonly DATABASE_TABLE_DELETE: "database.table.delete";
3074
+ };
3075
+ type CanonicalProtectedActionType = (typeof CanonicalProtectedActionType)[keyof typeof CanonicalProtectedActionType];
2278
3076
  /**
2279
3077
  * Describes a potentially dangerous action to be authorized before
2280
3078
  * the executor runs. Passed as the first argument to {@link requirePermit}.
@@ -2397,6 +3195,691 @@ declare function classifyCommand(command: string): string | null;
2397
3195
  */
2398
3196
  declare function withPermit<T>(request: ProtectRequest, fn: (permit: Permit) => Promise<T> | T): Promise<T>;
2399
3197
 
3198
+ /**
3199
+ * Approval/Override Runtime — fail-closed bridge between policy `hold`/`escalate`
3200
+ * outcomes and human approval.
3201
+ *
3202
+ * `protectOrEscalate()` — like `protect()` but handles hold/escalate by:
3203
+ * 1. Creating an HITL escalation via POST /v1/hitl
3204
+ * 2. Polling until approved, rejected, or timed out
3205
+ * 3. Returning an `ApprovalPermit` on approval; throwing on rejection/timeout
3206
+ *
3207
+ * `createEscalation()` — create an HITL escalation request (lower-level)
3208
+ * `waitForEscalationApproval()` — poll until the escalation resolves
3209
+ * `requestOverride()` — request a post-hoc override for a denied evaluation
3210
+ * `configureApprovalRuntime()` — set API key / base URL once
3211
+ */
3212
+
3213
+ interface ApprovalRuntimeConfig {
3214
+ apiKey?: string;
3215
+ baseUrl?: string;
3216
+ /** Per-request HTTP timeout in ms. Default 30_000. */
3217
+ timeoutMs?: number;
3218
+ }
3219
+ /**
3220
+ * Configure the Approval Runtime singleton. Optional — if `ATLASENT_API_KEY` is
3221
+ * set in the environment, the runtime works without configuration. Calling this
3222
+ * again merges into the existing config.
3223
+ */
3224
+ declare function configureApprovalRuntime(config: ApprovalRuntimeConfig): void;
3225
+ /** Opaque handle returned when an escalation is created. */
3226
+ interface EscalationHandle {
3227
+ readonly escalationId: string;
3228
+ readonly createdAt: string;
3229
+ readonly timeoutAt: string | null;
3230
+ readonly assignedToRole: string | null;
3231
+ }
3232
+ /** Terminal resolution status of an escalation. */
3233
+ type ApprovalStatus = "approved" | "rejected" | "timed_out";
3234
+ /** Full outcome returned when an escalation resolves. */
3235
+ interface EscalationOutcome {
3236
+ readonly status: ApprovalStatus;
3237
+ readonly escalation: HitlEscalation;
3238
+ readonly resolvedBy: string | null;
3239
+ readonly resolutionNote: string | null;
3240
+ readonly resolvedAt: string | null;
3241
+ }
3242
+ /**
3243
+ * Thrown by `protectOrEscalate` / `waitForEscalationApproval` when the
3244
+ * human reviewer rejects the escalation.
3245
+ */
3246
+ declare class EscalationDeniedError extends Error {
3247
+ readonly name: "EscalationDeniedError";
3248
+ readonly escalationId: string;
3249
+ readonly outcome: EscalationOutcome;
3250
+ constructor(outcome: EscalationOutcome);
3251
+ }
3252
+ /**
3253
+ * Thrown by `protectOrEscalate` / `waitForEscalationApproval` when the
3254
+ * client-side wait window expires before the escalation resolves.
3255
+ */
3256
+ declare class EscalationTimeoutError extends Error {
3257
+ readonly name: "EscalationTimeoutError";
3258
+ readonly escalationId: string;
3259
+ readonly outcome: EscalationOutcome;
3260
+ constructor(outcome: EscalationOutcome);
3261
+ }
3262
+ /**
3263
+ * Options for creating an HITL escalation. Extends `HitlCreateRequest` with
3264
+ * API-key and base-URL overrides for per-call credential injection.
3265
+ */
3266
+ interface CreateEscalationOptions extends Partial<HitlCreateRequest> {
3267
+ apiKey?: string;
3268
+ baseUrl?: string;
3269
+ }
3270
+ /**
3271
+ * Create an HITL escalation via POST /v1/hitl.
3272
+ *
3273
+ * The escalation is placed in `pending` status; a reviewer must approve or
3274
+ * reject it before the original action can proceed. Use
3275
+ * `waitForEscalationApproval()` to poll until the escalation resolves.
3276
+ */
3277
+ declare function createEscalation(opts: CreateEscalationOptions): Promise<EscalationHandle>;
3278
+ interface WaitForApprovalOptions {
3279
+ escalationId: string;
3280
+ /** Max milliseconds to wait for a human to respond. Default 600_000 (10 min). */
3281
+ waitMs?: number;
3282
+ /** How often to poll the API. Default 5000ms. Minimum 1000ms. */
3283
+ pollIntervalMs?: number;
3284
+ apiKey?: string;
3285
+ baseUrl?: string;
3286
+ }
3287
+ /**
3288
+ * Poll GET /v1/escalations/:id until the escalation reaches a terminal status
3289
+ * (`approved`, `auto_approved`, `rejected`, or `timed_out`).
3290
+ *
3291
+ * Returns the resolved outcome regardless of approval/rejection — the caller
3292
+ * decides whether to throw. Use `protectOrEscalate()` for the opinionated flow.
3293
+ */
3294
+ declare function waitForEscalationApproval(opts: WaitForApprovalOptions): Promise<EscalationOutcome>;
3295
+ /**
3296
+ * A verified Permit granted via human approval of an HITL escalation.
3297
+ * Extends {@link Permit} with escalation provenance fields.
3298
+ *
3299
+ * `approvalBasis: "direct_policy"` — action was allowed directly by policy;
3300
+ * no escalation was created.
3301
+ *
3302
+ * `approvalBasis: "human_approval"` — the policy returned `hold`/`escalate`;
3303
+ * a human reviewer approved the escalation.
3304
+ *
3305
+ * Guards and enforcement adapters should treat both as equivalent authorization
3306
+ * proof; auditors can distinguish them via `escalationId`.
3307
+ */
3308
+ interface ApprovalPermit extends Permit {
3309
+ /**
3310
+ * The HITL escalation ID that authorized this action. Empty string when
3311
+ * the action was directly allowed by policy (no escalation needed).
3312
+ */
3313
+ readonly escalationId: string;
3314
+ /** Identity of the reviewer who approved, or `null` for `auto_approved`. */
3315
+ readonly resolvedBy: string | null;
3316
+ readonly resolutionNote: string | null;
3317
+ readonly resolvedAt: string;
3318
+ readonly approvalBasis: "direct_policy" | "human_approval";
3319
+ }
3320
+ interface ProtectOrEscalateOptions {
3321
+ /** Agent ID recorded on the escalation. Defaults to `request.agent`. */
3322
+ agentId?: string;
3323
+ /** Human-readable reason surfaced in the reviewer's queue. */
3324
+ escalationReason?: string;
3325
+ /** The proposed action payload shown to reviewers. Defaults to `request.context`. */
3326
+ proposedAction?: Record<string, unknown>;
3327
+ riskScore?: number;
3328
+ assignedToRole?: string;
3329
+ quorumRequired?: HitlQuorumTier;
3330
+ fallbackDecision?: HitlFallbackDecision;
3331
+ /** ISO-8601 — when the escalation should auto-resolve per server policy. */
3332
+ timeoutAt?: string;
3333
+ metadata?: Record<string, unknown>;
3334
+ /** Max ms to wait for a human decision. Default 600_000 (10 min). */
3335
+ waitMs?: number;
3336
+ /** How often to poll. Default 5000ms. */
3337
+ pollIntervalMs?: number;
3338
+ apiKey?: string;
3339
+ baseUrl?: string;
3340
+ /** Called with the EscalationHandle immediately after it is created. */
3341
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3342
+ }
3343
+ /**
3344
+ * Authorize an action end-to-end, automatically escalating to human review
3345
+ * when the policy returns `hold` or `escalate`.
3346
+ *
3347
+ * **Directly allowed** → returns `ApprovalPermit` with
3348
+ * `approvalBasis: "direct_policy"` (same semantics as `protect()`).
3349
+ *
3350
+ * **Hold / escalate** → creates an HITL escalation, polls for a human
3351
+ * decision, and returns `ApprovalPermit` with
3352
+ * `approvalBasis: "human_approval"` on approval.
3353
+ *
3354
+ * **Throws**:
3355
+ * - {@link EscalationDeniedError} — reviewer rejected the escalation
3356
+ * - {@link EscalationTimeoutError} — wait window elapsed without a decision
3357
+ * - {@link AtlaSentDeniedError} — hard deny (not hold/escalate); fail-closed
3358
+ * - {@link AtlaSentError} — transport / auth / server failure; fail-closed
3359
+ */
3360
+ declare function protectOrEscalate(request: ProtectRequest, opts?: ProtectOrEscalateOptions): Promise<ApprovalPermit>;
3361
+ interface RequestOverrideOptions {
3362
+ /** Human-readable justification. Required; max 2000 characters. */
3363
+ reason: string;
3364
+ /** The evaluation ID that was denied and should be overridden. */
3365
+ evaluationId: string;
3366
+ /** How long this override is valid, in seconds. Max 604800 (7 days). */
3367
+ ttlSeconds?: number;
3368
+ /** Arbitrary metadata to attach (e.g. liability attribution context). */
3369
+ metadata?: Record<string, unknown>;
3370
+ apiKey?: string;
3371
+ baseUrl?: string;
3372
+ }
3373
+ /**
3374
+ * Request a post-hoc override for a denied evaluation via POST /v1/overrides.
3375
+ *
3376
+ * The override starts in `pending` status and takes effect only after an
3377
+ * authorized actor approves it. Subsequent evaluations for the same action
3378
+ * will return `allow` while the override is `approved` and within its TTL.
3379
+ *
3380
+ * Attach `metadata.requested_by` for liability attribution.
3381
+ */
3382
+ declare function requestOverride(opts: RequestOverrideOptions): Promise<OverrideV1>;
3383
+
3384
+ type DeployEnvironment = "production" | "staging" | "development" | string;
3385
+ interface DeployGateOptions {
3386
+ service: string;
3387
+ resourceType?: string;
3388
+ sha?: string;
3389
+ workflow?: string;
3390
+ actorId?: string;
3391
+ actorLabel?: string;
3392
+ environment?: DeployEnvironment;
3393
+ description?: string;
3394
+ requireApproval?: boolean;
3395
+ assignedToRole?: string;
3396
+ waitMs?: number;
3397
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3398
+ apiKey?: string;
3399
+ baseUrl?: string;
3400
+ /** Slack Incoming Webhook URL. When set, an informational message is posted
3401
+ * when the gate returns deny or escalate. Best-effort; never throws. */
3402
+ notifySlackWebhook?: string;
3403
+ }
3404
+ declare function protectDeploy(opts: DeployGateOptions): Promise<ApprovalPermit | Permit>;
3405
+
3406
+ type CloseActionType = "period.close" | "period.reopen" | "reconciliation.lock" | "reconciliation.certify";
3407
+ interface CloseGovernanceOptions {
3408
+ action: CloseActionType;
3409
+ periodLabel: string;
3410
+ closedBy: string;
3411
+ entityId: string;
3412
+ entityName?: string;
3413
+ dataClassification?: "internal" | "confidential" | "restricted";
3414
+ assignedToRole?: string;
3415
+ requireDualApproval?: boolean;
3416
+ waitMs?: number;
3417
+ description?: string;
3418
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3419
+ apiKey?: string;
3420
+ baseUrl?: string;
3421
+ }
3422
+ interface ReconciliationCertifyOptions {
3423
+ accountId: string;
3424
+ period: string;
3425
+ certifiedBy: string;
3426
+ balanceDifference: number;
3427
+ dualApprovalRequired: boolean;
3428
+ secondApprover?: string;
3429
+ supportingEvidenceUri?: string;
3430
+ assignedToRole?: string;
3431
+ waitMs?: number;
3432
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3433
+ apiKey?: string;
3434
+ baseUrl?: string;
3435
+ }
3436
+ declare function protectReconciliationCertify(opts: ReconciliationCertifyOptions): Promise<ApprovalPermit>;
3437
+ declare function protectCloseAction(opts: CloseGovernanceOptions): Promise<ApprovalPermit>;
3438
+
3439
+ declare const VENDOR_PAYMENT_ACTION: "vendor.payment.release";
3440
+ interface PaymentReleaseOptions {
3441
+ amount: number;
3442
+ currency: string;
3443
+ vendorId: string;
3444
+ vendorName?: string;
3445
+ authorizedBy: string;
3446
+ reference?: string;
3447
+ description?: string;
3448
+ autoEscalateAbove?: number;
3449
+ requireDualApprovalAbove?: number;
3450
+ assignedToRole?: string;
3451
+ waitMs?: number;
3452
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3453
+ apiKey?: string;
3454
+ baseUrl?: string;
3455
+ }
3456
+ declare function protectPaymentRelease(opts: PaymentReleaseOptions): Promise<ApprovalPermit | Permit>;
3457
+
3458
+ declare const CUSTOMER_DATA_EXPORT_ACTION: "customer.data.export";
3459
+ interface DataExportOptions {
3460
+ dataset: string;
3461
+ destination: string;
3462
+ containsPii: boolean;
3463
+ rowCount: number;
3464
+ dataClassification: "public" | "internal" | "confidential" | "restricted";
3465
+ purpose: string;
3466
+ dpaReference?: string;
3467
+ encryption?: string;
3468
+ authorizedBy: string;
3469
+ rowCap?: number;
3470
+ assignedToRole?: string;
3471
+ waitMs?: number;
3472
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3473
+ apiKey?: string;
3474
+ baseUrl?: string;
3475
+ }
3476
+ declare function protectDataExport(opts: DataExportOptions): Promise<ApprovalPermit | Permit>;
3477
+
3478
+ type ShadowMode = "observe" | "warn" | "enforce";
3479
+ interface ShadowOutcome {
3480
+ readonly decision: "permit" | "deny" | "hold" | "escalate";
3481
+ readonly permit: Permit | null;
3482
+ readonly error: AtlaSentDeniedError | null;
3483
+ readonly would_have_blocked: boolean;
3484
+ readonly latencyMs: number;
3485
+ readonly evaluationId: string | null;
3486
+ readonly request: ProtectRequest;
3487
+ readonly mode: ShadowMode;
3488
+ }
3489
+ interface ShadowConfig {
3490
+ mode?: ShadowMode;
3491
+ onOutcome?: (outcome: ShadowOutcome) => void | Promise<void>;
3492
+ reportToApi?: boolean;
3493
+ apiKey?: string;
3494
+ baseUrl?: string;
3495
+ }
3496
+ declare function configureShadow(config: ShadowConfig): void;
3497
+ interface ShadowOptions extends ShadowConfig {
3498
+ }
3499
+ declare function protectShadow(request: ProtectRequest, opts?: ShadowOptions): Promise<ShadowOutcome>;
3500
+ interface ShadowEventPayload {
3501
+ action: string;
3502
+ agentId: string | null;
3503
+ decision: ShadowOutcome["decision"];
3504
+ would_have_blocked: boolean;
3505
+ latencyMs: number;
3506
+ evaluationId: string | null;
3507
+ mode: ShadowMode;
3508
+ deniedReason?: string;
3509
+ timestamp: string;
3510
+ }
3511
+ declare function reportShadowEvent(outcome: ShadowOutcome, opts?: Pick<ShadowConfig, "apiKey" | "baseUrl">): Promise<void>;
3512
+
3513
+ type AgentToolMode = "observe" | "enforce" | "escalate";
3514
+ interface AgentToolOptions {
3515
+ toolName: string;
3516
+ toolArgs: Record<string, unknown>;
3517
+ agentId: string;
3518
+ sessionId?: string;
3519
+ riskLevel?: "critical" | "high" | "medium" | "low";
3520
+ mode?: AgentToolMode;
3521
+ assignedToRole?: string;
3522
+ waitMs?: number;
3523
+ description?: string;
3524
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3525
+ apiKey?: string;
3526
+ baseUrl?: string;
3527
+ }
3528
+ declare function classifyToolRisk(toolName: string): "critical" | "high" | "medium" | "low";
3529
+ declare function protectToolCall(opts: AgentToolOptions): Promise<ApprovalPermit | Permit | ShadowOutcome>;
3530
+
3531
+ type GxpActionType = "manufacturing.batch_record.release" | "clinical.tmf.record.modify" | "clinical.data.access" | "clinical.source_data.read" | "clinical.signature.apply" | "clinical.deviation.report" | "clinical.consent.update" | "quality.capa.initiate" | "quality.capa.assign" | "quality.capa.progress" | "quality.capa.effectiveness_check" | "quality.capa.close" | "quality.deviation.detect" | "quality.deviation.classify" | "quality.deviation.escalate" | "quality.deviation.investigate" | "quality.deviation.close" | "quality.change_control.initiate" | "quality.change_control.classify" | "quality.change_control.approve" | "quality.change_control.implement" | "quality.change_control.close";
3532
+ interface BatchRecordReleaseOptions {
3533
+ batchId: string;
3534
+ productCode: string;
3535
+ lotNumber: string;
3536
+ certifiedBy: string;
3537
+ qaSignoffBy: string;
3538
+ batchRecordComplete: boolean;
3539
+ deviationCount: number;
3540
+ regulatoryRegion: string;
3541
+ action: "manufacturing.batch_record.release";
3542
+ assignedToRole?: string;
3543
+ waitMs?: number;
3544
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3545
+ apiKey?: string;
3546
+ baseUrl?: string;
3547
+ }
3548
+ interface ClinicalDataAccessOptions {
3549
+ subjectId: string;
3550
+ dataCategory: string;
3551
+ accessedBy: string;
3552
+ purpose: string;
3553
+ aiAgent: boolean;
3554
+ consentVerified: boolean;
3555
+ trialId: string;
3556
+ action: "clinical.data.access";
3557
+ assignedToRole?: string;
3558
+ waitMs?: number;
3559
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3560
+ apiKey?: string;
3561
+ baseUrl?: string;
3562
+ }
3563
+ interface CAPAOptions {
3564
+ capaId: string;
3565
+ action: GxpActionType & `quality.capa.${string}`;
3566
+ initiatedBy?: string;
3567
+ closedBy?: string;
3568
+ secondClosedBy?: string;
3569
+ severity?: "minor" | "major" | "critical";
3570
+ assignedToRole?: string;
3571
+ waitMs?: number;
3572
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3573
+ apiKey?: string;
3574
+ baseUrl?: string;
3575
+ [key: string]: unknown;
3576
+ }
3577
+ type GxpActionOptions = BatchRecordReleaseOptions | ClinicalDataAccessOptions | CAPAOptions | {
3578
+ action: GxpActionType;
3579
+ assignedToRole?: string;
3580
+ waitMs?: number;
3581
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3582
+ apiKey?: string;
3583
+ baseUrl?: string;
3584
+ [key: string]: unknown;
3585
+ };
3586
+ declare function protectGxpAction(opts: GxpActionOptions): Promise<ApprovalPermit>;
3587
+ declare function protectBatchRecordRelease(opts: Omit<BatchRecordReleaseOptions, "action">): Promise<ApprovalPermit>;
3588
+
3589
+ type PaymentOperationActionType = "payment.approval.approve" | "payment.approval.deny" | "payment.execute.approved" | "payment.execute.held" | "payment.execute.denied" | "payment.execute.policy_error" | "qb.transaction.approve";
3590
+ interface PaymentOperationOptions {
3591
+ paymentId: string;
3592
+ action: PaymentOperationActionType;
3593
+ amount?: number;
3594
+ currency?: string;
3595
+ approvedBy?: string;
3596
+ deniedBy?: string;
3597
+ executedBy?: string;
3598
+ heldBy?: string;
3599
+ holdReason?: string;
3600
+ policyRule?: string;
3601
+ errorCode?: string;
3602
+ bankReference?: string;
3603
+ invoiceId?: string;
3604
+ vendorId?: string;
3605
+ accountCode?: string;
3606
+ transactionId?: string;
3607
+ assignedToRole?: string;
3608
+ waitMs?: number;
3609
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3610
+ apiKey?: string;
3611
+ baseUrl?: string;
3612
+ }
3613
+ declare function protectPaymentOperation(opts: PaymentOperationOptions): Promise<ApprovalPermit | Permit>;
3614
+
3615
+ type DeploymentActionType = "deployment.production.execute" | "deployment.staging.execute" | "deployment.rollback.execute";
3616
+ /**
3617
+ * V1 backward-compatibility constant. The original `production.deploy`
3618
+ * action string from deployGate.ts is still supported by the server.
3619
+ * Use `DeploymentActionType` values for new V2 integrations.
3620
+ */
3621
+ declare const DEPLOY_V1_ACTION: "production.deploy";
3622
+ interface DeploymentV2Options {
3623
+ action: DeploymentActionType;
3624
+ deploymentId: string;
3625
+ buildSha: string;
3626
+ environment: "production" | "staging";
3627
+ approvedBy?: string;
3628
+ rollbackPlan?: string;
3629
+ changeTicket?: string;
3630
+ incidentId?: string;
3631
+ rollbackTarget?: string;
3632
+ authorizedBy?: string;
3633
+ assignedToRole?: string;
3634
+ waitMs?: number;
3635
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3636
+ apiKey?: string;
3637
+ baseUrl?: string;
3638
+ }
3639
+ declare function protectDeploymentV2(opts: DeploymentV2Options): Promise<ApprovalPermit>;
3640
+
3641
+ type BehaviorEventCategory = "general" | "health.mental" | "health.adherence" | "financial" | "minor";
3642
+ declare const BEHAVIOR_SENSITIVE_CATEGORIES: BehaviorEventCategory[];
3643
+ interface BehaviorEventOptions {
3644
+ action: "behavior.event.share";
3645
+ subjectId: string;
3646
+ eventCategory: BehaviorEventCategory;
3647
+ destination: string;
3648
+ purpose: string;
3649
+ consentVerified: boolean;
3650
+ dataMinimized: boolean;
3651
+ subjectIsMinor?: boolean;
3652
+ assignedToRole?: string;
3653
+ waitMs?: number;
3654
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3655
+ apiKey?: string;
3656
+ baseUrl?: string;
3657
+ }
3658
+ declare function protectBehaviorEvent(opts: BehaviorEventOptions): Promise<ApprovalPermit>;
3659
+
3660
+ type InfraActionType = "aws.ec2.stop_instance" | "aws.ec2.terminate_instance" | "github.repos.delete" | "database.table.drop" | "database.volume.delete" | "db.table.delete" | "infra.volume.delete";
3661
+ interface InfraActionOptions {
3662
+ action: InfraActionType;
3663
+ resourceId: string;
3664
+ authorizedBy: string;
3665
+ reason: string;
3666
+ changeTicket?: string;
3667
+ incidentId?: string;
3668
+ backupVerified?: boolean;
3669
+ region?: string;
3670
+ assignedToRole?: string;
3671
+ waitMs?: number;
3672
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3673
+ apiKey?: string;
3674
+ baseUrl?: string;
3675
+ }
3676
+ declare function protectInfraAction(opts: InfraActionOptions): Promise<ApprovalPermit | Permit>;
3677
+
3678
+ type HrActionType = "hr.employee.offboard" | "hr.access.revoke" | "hr.role.escalate";
3679
+ interface HrActionOptions {
3680
+ action: HrActionType;
3681
+ employeeId: string;
3682
+ authorizedBy: string;
3683
+ effectiveDate?: string;
3684
+ offboardingReason?: string;
3685
+ requestedRole?: string;
3686
+ businessJustification?: string;
3687
+ assignedToRole?: string;
3688
+ waitMs?: number;
3689
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3690
+ apiKey?: string;
3691
+ baseUrl?: string;
3692
+ }
3693
+ declare function protectHrAction(opts: HrActionOptions): Promise<ApprovalPermit | Permit>;
3694
+ declare function protectHrOffboard(opts: Omit<HrActionOptions, "action"> & {
3695
+ effectiveDate: string;
3696
+ offboardingReason: string;
3697
+ }): Promise<ApprovalPermit | Permit>;
3698
+ declare function protectHrRoleEscalate(opts: Omit<HrActionOptions, "action"> & {
3699
+ requestedRole: string;
3700
+ businessJustification: string;
3701
+ }): Promise<ApprovalPermit | Permit>;
3702
+
3703
+ type ModelGovernanceActionType = "ml.model.promote" | "ml.model.retire" | "ml.model.fine_tune";
3704
+ interface ModelGovernanceOptions {
3705
+ action: ModelGovernanceActionType;
3706
+ modelId: string;
3707
+ authorizedBy: string;
3708
+ reason: string;
3709
+ safetyReviewId?: string;
3710
+ serviceImpactAssessed?: boolean;
3711
+ alignmentVerified?: boolean;
3712
+ targetEnvironment?: string;
3713
+ assignedToRole?: string;
3714
+ waitMs?: number;
3715
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3716
+ apiKey?: string;
3717
+ baseUrl?: string;
3718
+ }
3719
+ declare function protectModelGovernance(opts: ModelGovernanceOptions): Promise<ApprovalPermit>;
3720
+ declare function protectModelPromotion(opts: Omit<ModelGovernanceOptions, "action">): Promise<ApprovalPermit>;
3721
+
3722
+ type DataDeleteActionType = "customer.data.delete";
3723
+ type GdprLegalBasis = "erasure_request" | "retention_expired" | "consent_withdrawn" | "controller_instruction";
3724
+ interface DataDeleteOptions {
3725
+ action: DataDeleteActionType;
3726
+ dataSubjectId: string;
3727
+ verifiedBy: string;
3728
+ gdprBasis: GdprLegalBasis;
3729
+ dpaReference?: string;
3730
+ dataCategories?: string[];
3731
+ retentionEndDate?: string;
3732
+ assignedToRole?: string;
3733
+ waitMs?: number;
3734
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3735
+ apiKey?: string;
3736
+ baseUrl?: string;
3737
+ }
3738
+ declare function protectCustomerDataDelete(opts: DataDeleteOptions): Promise<ApprovalPermit>;
3739
+
3740
+ type ContractActionType = "contract.execute" | "contract.amend";
3741
+ interface ContractActionOptions {
3742
+ action: ContractActionType;
3743
+ contractId: string;
3744
+ authorizedBy: string;
3745
+ counterparty: string;
3746
+ legalReviewId?: string;
3747
+ estimatedValue?: number;
3748
+ currency?: string;
3749
+ effectiveDate?: string;
3750
+ amendmentDescription?: string;
3751
+ assignedToRole?: string;
3752
+ waitMs?: number;
3753
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3754
+ apiKey?: string;
3755
+ baseUrl?: string;
3756
+ }
3757
+ declare function protectContractAction(opts: ContractActionOptions): Promise<ApprovalPermit>;
3758
+ declare function protectContractExecution(opts: Omit<ContractActionOptions, "action">): Promise<ApprovalPermit>;
3759
+
3760
+ type PricingActionType = "pricing.rule.publish" | "pricing.discount.approve";
3761
+ interface PricingActionOptions {
3762
+ action: PricingActionType;
3763
+ ruleId: string;
3764
+ authorizedBy: string;
3765
+ priceChangePct?: number;
3766
+ affectedSkus?: string[];
3767
+ effectiveDate?: string;
3768
+ discountPercent?: number;
3769
+ customerId?: string;
3770
+ discountReason?: string;
3771
+ assignedToRole?: string;
3772
+ waitMs?: number;
3773
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3774
+ apiKey?: string;
3775
+ baseUrl?: string;
3776
+ }
3777
+ declare function protectPricingAction(opts: PricingActionOptions): Promise<ApprovalPermit | Permit>;
3778
+ declare function protectPricingRule(opts: Omit<PricingActionOptions, "action">): Promise<ApprovalPermit | Permit>;
3779
+
3780
+ type SecurityActionType = "security.incident.escalate" | "security.access.quarantine";
3781
+ interface SecurityActionOptions {
3782
+ action: SecurityActionType;
3783
+ authorizedBy: string;
3784
+ incidentId?: string;
3785
+ severity?: "low" | "medium" | "high" | "critical";
3786
+ targetId?: string;
3787
+ quarantineReason?: string;
3788
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3789
+ apiKey?: string;
3790
+ baseUrl?: string;
3791
+ }
3792
+ declare function protectSecurityAction(opts: SecurityActionOptions): Promise<ApprovalPermit>;
3793
+ declare function protectSecurityIncidentEscalate(opts: Omit<SecurityActionOptions, "action"> & {
3794
+ incidentId: string;
3795
+ severity: "low" | "medium" | "high" | "critical";
3796
+ }): Promise<ApprovalPermit>;
3797
+ declare function protectSecurityAccessQuarantine(opts: Omit<SecurityActionOptions, "action"> & {
3798
+ targetId: string;
3799
+ quarantineReason: string;
3800
+ }): Promise<ApprovalPermit>;
3801
+
3802
+ type AccessCertActionType = "access.cert.revoke";
3803
+ interface AccessCertOptions {
3804
+ action: AccessCertActionType;
3805
+ certId: string;
3806
+ revocationReason: string;
3807
+ authorizedBy?: string;
3808
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3809
+ apiKey?: string;
3810
+ baseUrl?: string;
3811
+ }
3812
+ declare function protectAccessCertAction(opts: AccessCertOptions): Promise<ApprovalPermit>;
3813
+ declare function protectAccessCertRevoke(opts: Omit<AccessCertOptions, "action">): Promise<ApprovalPermit>;
3814
+
3815
+ type FinancialCloseActionType = "period.close.certify";
3816
+ interface FinancialCloseOptions {
3817
+ action: FinancialCloseActionType;
3818
+ periodId: string;
3819
+ certifiedBy: string;
3820
+ financialController: string;
3821
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3822
+ apiKey?: string;
3823
+ baseUrl?: string;
3824
+ }
3825
+ declare function protectFinancialCloseAction(opts: FinancialCloseOptions): Promise<ApprovalPermit>;
3826
+ declare function protectPeriodCloseCertify(opts: Omit<FinancialCloseOptions, "action">): Promise<ApprovalPermit>;
3827
+
3828
+ type DatabaseMigrationActionType = "database.migration.apply";
3829
+ type DatabaseDestructiveActionType = "database.schema.drop" | "database.table.delete";
3830
+ type DatabaseActionType = DatabaseMigrationActionType | DatabaseDestructiveActionType;
3831
+ interface PermitEvidence {
3832
+ action: DatabaseActionType;
3833
+ databaseId: string;
3834
+ authorizedBy: string;
3835
+ permitToken: string;
3836
+ timestamp: string;
3837
+ context: Record<string, unknown>;
3838
+ }
3839
+ interface DenialEvidence {
3840
+ action: DatabaseActionType;
3841
+ databaseId: string;
3842
+ authorizedBy: string;
3843
+ denialReason: string;
3844
+ evaluationId?: string;
3845
+ timestamp: string;
3846
+ context: Record<string, unknown>;
3847
+ }
3848
+ interface DatabaseActionOptions {
3849
+ action: DatabaseActionType;
3850
+ databaseId: string;
3851
+ authorizedBy: string;
3852
+ environment: "production" | "staging" | "development";
3853
+ migrationId?: string;
3854
+ migrationChecksum?: string;
3855
+ rollbackPlan?: string;
3856
+ schemaName?: string;
3857
+ tableName?: string;
3858
+ backupVerified?: boolean;
3859
+ recoveryPointId?: string;
3860
+ onPermitEvidence?: (evidence: PermitEvidence) => void | Promise<void>;
3861
+ onDenialEvidence?: (evidence: DenialEvidence) => void | Promise<void>;
3862
+ waitMs?: number;
3863
+ onEscalationCreated?: (handle: EscalationHandle) => void;
3864
+ apiKey?: string;
3865
+ baseUrl?: string;
3866
+ }
3867
+ declare function protectDatabaseAction(opts: DatabaseActionOptions): Promise<ApprovalPermit | Permit>;
3868
+ declare function protectDatabaseMigration(opts: Omit<DatabaseActionOptions, "action"> & {
3869
+ migrationId: string;
3870
+ migrationChecksum: string;
3871
+ }): Promise<ApprovalPermit | Permit>;
3872
+ declare function protectDatabaseSchemaDrop(opts: Omit<DatabaseActionOptions, "action"> & {
3873
+ schemaName: string;
3874
+ backupVerified: true;
3875
+ recoveryPointId: string;
3876
+ }): Promise<ApprovalPermit | Permit>;
3877
+ declare function protectDatabaseTableDelete(opts: Omit<DatabaseActionOptions, "action"> & {
3878
+ tableName: string;
3879
+ backupVerified: true;
3880
+ recoveryPointId: string;
3881
+ }): Promise<ApprovalPermit | Permit>;
3882
+
2400
3883
  /**
2401
3884
  * Sandbox simulation diff — wire shape for `GET /v1/agent-sandbox/:id/diff`.
2402
3885
  *
@@ -2710,6 +4193,118 @@ interface QuorumProof {
2710
4193
  approval_ids: string[];
2711
4194
  }
2712
4195
 
4196
+ /**
4197
+ * Context Envelope types — structured input set for execution-time
4198
+ * authorization decisions.
4199
+ *
4200
+ * These types mirror the `context_envelopes` + `context_signals` +
4201
+ * `context_namespace_registry` DB schema introduced in migration
4202
+ * `20260522070000_context_envelope_v1.sql`.
4203
+ *
4204
+ * A V1 envelope has a fixed top-level keyset (the canonical namespace
4205
+ * catalog). The recorder validates incoming envelopes against this catalog
4206
+ * and rejects unknown top-level keys in strict mode (V2+).
4207
+ */
4208
+ /** Canonical V1 envelope top-level namespace keys. */
4209
+ declare const CONTEXT_NAMESPACES: readonly ["intent", "actor", "resource", "environment", "history", "evidence_refs", "signals", "compatibility_overrides"];
4210
+ type ContextNamespaceKey = (typeof CONTEXT_NAMESPACES)[number];
4211
+ /** One row from `context_namespace_registry`. */
4212
+ interface ContextNamespaceEntry {
4213
+ namespace: ContextNamespaceKey;
4214
+ purpose: string;
4215
+ owner: string;
4216
+ /** `true` for the `signals` namespace — derived / inferred inputs. */
4217
+ is_signal: boolean;
4218
+ introduced_in_version: string;
4219
+ }
4220
+ /** One signal attached to a context envelope. */
4221
+ interface ContextSignal {
4222
+ /** Dotted path under the `signals` namespace (e.g. `"signals.actor_anomaly"`). */
4223
+ namespace: string;
4224
+ /** Named source that produced this signal. */
4225
+ source: string;
4226
+ /** Confidence in [0.0, 1.0]. `null` when not reported. */
4227
+ confidence: number | null;
4228
+ /** Arbitrary signal payload. */
4229
+ payload: Record<string, unknown>;
4230
+ /** ISO-8601 timestamp when the signal was produced. */
4231
+ produced_at: string;
4232
+ /** Seconds until the signal is considered stale. `null` = no expiry. */
4233
+ ttl_seconds: number | null;
4234
+ }
4235
+ /**
4236
+ * A canonical V1 context envelope — the deterministic input set that
4237
+ * powers execution-time authorization decisions.
4238
+ *
4239
+ * Envelopes are append-only and hash-committed: `envelope_hash` is
4240
+ * SHA-256 of the canonical JSON form. The permit issued by the evaluator
4241
+ * commits to this hash so the audit chain, the permit, and a verifier all
4242
+ * agree on what was evaluated.
4243
+ *
4244
+ * ```ts
4245
+ * import type { ContextEnvelope } from "@atlasent/sdk";
4246
+ *
4247
+ * const envelope: ContextEnvelope = {
4248
+ * request_id: "req_abc123",
4249
+ * org_id: "org_xyz",
4250
+ * envelope_version: "atlasent.v1",
4251
+ * protected_action: "production.deploy",
4252
+ * envelope: {
4253
+ * intent: { action: "deploy", summary: "Release v1.2.0" },
4254
+ * actor: { id: "agent:deploy-bot", roles: ["deploy"] },
4255
+ * environment: { name: "production", freeze_window: false },
4256
+ * },
4257
+ * envelope_hash: "a3f...",
4258
+ * evidence_refs: [],
4259
+ * recorded_by: "v1-evaluate",
4260
+ * received_at: "2026-06-02T00:00:00Z",
4261
+ * signals: [],
4262
+ * };
4263
+ * ```
4264
+ */
4265
+ interface ContextEnvelope {
4266
+ /** Caller-supplied idempotency / correlation key. */
4267
+ request_id: string;
4268
+ org_id: string;
4269
+ envelope_version: "atlasent.v1";
4270
+ /** The namespaced action type this envelope covers. */
4271
+ protected_action: string;
4272
+ /**
4273
+ * The full validated envelope payload. Top-level keys must be in
4274
+ * {@link CONTEXT_NAMESPACES}. Unknown keys are warn-only in V1.
4275
+ */
4276
+ envelope: Partial<Record<ContextNamespaceKey, unknown>>;
4277
+ /**
4278
+ * SHA-256 hex of `canonical-JSON(envelope)`. Three points of truth
4279
+ * (permit, audit chain, verifier) reduce to this single hash.
4280
+ */
4281
+ envelope_hash: string;
4282
+ /** UUIDs of governance evidence rows referenced by this envelope. */
4283
+ evidence_refs: string[];
4284
+ /** Which handler wrote this row (e.g. `"v1-evaluate"`). */
4285
+ recorded_by: string;
4286
+ /** ISO-8601 timestamp. */
4287
+ received_at: string;
4288
+ /** Signals attached to this envelope. */
4289
+ signals: ContextSignal[];
4290
+ }
4291
+ /**
4292
+ * Minimal input shape for recording a context envelope via
4293
+ * `context_record_envelope()`. The hash is computed by the caller
4294
+ * before submitting.
4295
+ */
4296
+ interface RecordContextEnvelopeInput {
4297
+ request_id: string;
4298
+ org_id: string;
4299
+ envelope_version: "atlasent.v1";
4300
+ protected_action: string;
4301
+ envelope: Partial<Record<ContextNamespaceKey, unknown>>;
4302
+ envelope_hash: string;
4303
+ evidence_refs?: string[];
4304
+ recorded_by?: string;
4305
+ signals?: Omit<ContextSignal, never>[];
4306
+ }
4307
+
2713
4308
  /**
2714
4309
  * Shared V1 API wire types used across multiple SDK modules.
2715
4310
  *
@@ -2841,6 +4436,130 @@ interface ProofResponse {
2841
4436
  issuedAt: string;
2842
4437
  }
2843
4438
 
4439
+ /**
4440
+ * Trust-root Phase 2 — hybrid snapshot bootstrap + revocation enforcement.
4441
+ *
4442
+ * Provides a lightweight TrustSnapshot type (numeric epoch timestamps,
4443
+ * JWK-array keys, flat revoked_kids list) alongside three helpers that
4444
+ * the verify() path and application code can call directly.
4445
+ *
4446
+ * Design decisions (ADR-005):
4447
+ *
4448
+ * - D3 (fail-closed expiry): isTrustSnapshotExpired() defaults to a 24-hour
4449
+ * TTL and returns true when the snapshot is older than that or when
4450
+ * expires_at has already passed. Callers in verify() must treat an expired
4451
+ * snapshot as a denial.
4452
+ *
4453
+ * - D4 (R2/R3 split): revoked_kids is a flat allowlist consulted for ANY
4454
+ * KID regardless of role. Role enforcement belongs in auditBundle.ts;
4455
+ * this module only answers "is this KID revoked?"
4456
+ *
4457
+ * - Bootstrap: bootstrapTrust() fetches the .well-known endpoint and merges
4458
+ * the response with an optional pinned snapshot. The pinned snapshot is
4459
+ * returned as-is if the fetch fails (silent fallback).
4460
+ *
4461
+ * - Refresh: background scheduling is handled by TrustRootManager in
4462
+ * trustRoot.ts. bootstrapTrust() is intentionally a one-shot function
4463
+ * for callers that need an explicit initial snapshot without wiring up
4464
+ * the full manager.
4465
+ */
4466
+ /**
4467
+ * Minimal JWK key entry as returned by the .well-known endpoint.
4468
+ *
4469
+ * Deliberately loose — additional vendor-defined fields (kid, use,
4470
+ * alg, crv, x, …) are preserved but not enumerated here so the type
4471
+ * survives forward additions to the key document.
4472
+ */
4473
+ interface JWK {
4474
+ /** Key identifier — used for revocation checks. */
4475
+ kid: string;
4476
+ /** Key type, e.g. "OKP", "EC", "RSA". */
4477
+ kty: string;
4478
+ [key: string]: unknown;
4479
+ }
4480
+ /**
4481
+ * Trust snapshot in the Phase 2 wire format.
4482
+ *
4483
+ * Uses numeric epoch-millisecond timestamps so callers can compare
4484
+ * directly with Date.now() without parsing ISO-8601 strings.
4485
+ */
4486
+ interface TrustSnapshot {
4487
+ /** Active verification keys from the trust root. */
4488
+ keys: JWK[];
4489
+ /** KIDs that have been revoked; any permit signed by these must be rejected. */
4490
+ revoked_kids: string[];
4491
+ /**
4492
+ * Unix epoch (ms) when this snapshot was fetched from the server.
4493
+ * Used as the reference point for TTL expiry checks.
4494
+ */
4495
+ fetched_at: number;
4496
+ /**
4497
+ * Unix epoch (ms) at which this snapshot expires regardless of TTL.
4498
+ * bootstrapTrust() derives this from the `valid_until` field in the
4499
+ * server response when available, otherwise from fetched_at + TTL.
4500
+ */
4501
+ expires_at: number;
4502
+ }
4503
+ /** Default snapshot TTL: 24 hours in milliseconds. */
4504
+ declare const DEFAULT_TRUST_TTL_MS: number;
4505
+ /**
4506
+ * Fetch a fresh TrustSnapshot from the AtlaSent trust-root documents.
4507
+ *
4508
+ * Fetches three documents from `${baseUrl}/.well-known/` in parallel:
4509
+ * - `atlasent-verifier-keys.json` — active verification keys
4510
+ * - `atlasent-revocations.json` — revoked KIDs
4511
+ * - `atlasent-trust-root.json` — validity window (valid_until, issued_at)
4512
+ *
4513
+ * Uses a 10-second timeout across all three fetches. On any failure
4514
+ * (network error, non-2xx, malformed response) the function returns the
4515
+ * `pinnedSnapshot` if provided, or re-throws the underlying error when no
4516
+ * fallback is available.
4517
+ *
4518
+ * The `expires_at` field is derived from the trust-root document's
4519
+ * `valid_until` field when present; otherwise it is set to
4520
+ * `fetched_at + ttlMs`.
4521
+ *
4522
+ * @param baseUrl Root URL of the AtlaSent keys host (no trailing slash).
4523
+ * @param pinnedSnapshot Optional pre-loaded snapshot to use as fallback.
4524
+ * @param ttlMs TTL for the snapshot in ms (default: 24 hours).
4525
+ * @param fetchImpl Custom fetch implementation (for tests/environments
4526
+ * without a global fetch).
4527
+ */
4528
+ declare function bootstrapTrust(baseUrl: string, pinnedSnapshot?: TrustSnapshot, ttlMs?: number, fetchImpl?: typeof fetch): Promise<TrustSnapshot>;
4529
+ /**
4530
+ * Returns true when the snapshot should be treated as expired.
4531
+ *
4532
+ * A snapshot is expired when EITHER:
4533
+ * 1. `expires_at` is in the past, OR
4534
+ * 2. `fetched_at + ttlMs` is in the past (age-based eviction).
4535
+ *
4536
+ * The stricter of the two checks wins so a snapshot that was fetched
4537
+ * recently but carries an already-expired `expires_at` is still rejected.
4538
+ *
4539
+ * ADR-005 D3: callers in the verify() path MUST treat an expired
4540
+ * snapshot as a denial (`failClosedOnExpiry` is honoured by the client
4541
+ * integration — see verify.ts).
4542
+ *
4543
+ * @param snapshot The snapshot to check.
4544
+ * @param ttlMs Maximum age in ms from `fetched_at` (default: 24 hours).
4545
+ * @param nowMs Override for `Date.now()` (for testing).
4546
+ */
4547
+ declare function isTrustSnapshotExpired(snapshot: TrustSnapshot, ttlMs?: number, nowMs?: number): boolean;
4548
+ /**
4549
+ * Returns true when the given KID appears in the snapshot's revocation list.
4550
+ *
4551
+ * Used by the verify() path before accepting a permit's signature:
4552
+ * ```ts
4553
+ * if (isKidRevoked(snapshot, permit.kid)) {
4554
+ * return { valid: false, reason: 'SIGNING_KEY_REVOKED' };
4555
+ * }
4556
+ * ```
4557
+ *
4558
+ * @param snapshot Trust snapshot to consult.
4559
+ * @param kid Key identifier from the permit or audit bundle header.
4560
+ */
4561
+ declare function isKidRevoked(snapshot: TrustSnapshot, kid: string): boolean;
4562
+
2844
4563
  /**
2845
4564
  * Financial Action Model — canonical types for financial execution authority.
2846
4565
  *
@@ -4340,223 +6059,187 @@ declare function evaluateMany(transport: V2Transport, req: EvaluateManyRequest):
4340
6059
  */
4341
6060
  interface AuthorizeStreamHandlers {
4342
6061
  onDecision?: (frame: StreamDecisionFrame) => void;
4343
- onError?: (frame: StreamErrorFrame) => void;
4344
- }
4345
- /**
4346
- * `POST /v1/evaluate/stream` — V2-D4.
4347
- *
4348
- * Streams `event: decision` frames in input order. Per-item RPC
4349
- * failures arrive as `event: error` frames and do not tear down the
4350
- * stream (V2-D7 async semantics). Resolves with the terminal
4351
- * `event: complete` payload.
4352
- *
4353
- * @throws {FeatureNotEnabledError} When the tenant `v2_streaming` flag is off.
4354
- * @throws {AtlaSentError} For transport failures, including the stream
4355
- * closing without a `complete` frame.
4356
- */
4357
- declare function authorizeStream(transport: V2Transport, req: EvaluateManyRequest, handlers?: AuthorizeStreamHandlers): Promise<StreamComplete>;
4358
- /**
4359
- * `POST /v1/graphql` — V2-D2 + V2-D8.
4360
- *
4361
- * Bearer-only auth (no query-param). Wave A schema is read-only
4362
- * (`recentEvaluations(limit)` + `activeBundle`). Server enforces the
4363
- * V2-D8 OR-gate (`audit:read` OR `policy:read`) at request layer and
4364
- * a per-resolver AND-gate at field resolution time.
4365
- *
4366
- * Resolver-level errors surface on `response.errors` — the SDK does
4367
- * not throw on them so callers can inspect partial data.
4368
- *
4369
- * @throws {FeatureNotEnabledError} When the tenant `v2_graphql` flag is off.
4370
- * @throws {AtlaSentError} For transport / HTTP failures.
4371
- * @throws {TypeError} When `query` is empty or the body exceeds the 1MB cap.
4372
- */
4373
- declare function graphql<T = unknown>(transport: V2Transport, req: GraphQLRequest): Promise<GraphQLResponse<T>>;
4374
-
4375
- /**
4376
- * Approval/Override Runtime — fail-closed bridge between policy `hold`/`escalate`
4377
- * outcomes and human approval.
4378
- *
4379
- * `protectOrEscalate()` — like `protect()` but handles hold/escalate by:
4380
- * 1. Creating an HITL escalation via POST /v1/hitl
4381
- * 2. Polling until approved, rejected, or timed out
4382
- * 3. Returning an `ApprovalPermit` on approval; throwing on rejection/timeout
4383
- *
4384
- * `createEscalation()` — create an HITL escalation request (lower-level)
4385
- * `waitForEscalationApproval()` — poll until the escalation resolves
4386
- * `requestOverride()` — request a post-hoc override for a denied evaluation
4387
- * `configureApprovalRuntime()` — set API key / base URL once
4388
- */
4389
-
4390
- interface ApprovalRuntimeConfig {
4391
- apiKey?: string;
4392
- baseUrl?: string;
4393
- /** Per-request HTTP timeout in ms. Default 30_000. */
4394
- timeoutMs?: number;
4395
- }
4396
- /**
4397
- * Configure the Approval Runtime singleton. Optional — if `ATLASENT_API_KEY` is
4398
- * set in the environment, the runtime works without configuration. Calling this
4399
- * again merges into the existing config.
4400
- */
4401
- declare function configureApprovalRuntime(config: ApprovalRuntimeConfig): void;
4402
- /** Opaque handle returned when an escalation is created. */
4403
- interface EscalationHandle {
4404
- readonly escalationId: string;
4405
- readonly createdAt: string;
4406
- readonly timeoutAt: string | null;
4407
- readonly assignedToRole: string | null;
4408
- }
4409
- /** Terminal resolution status of an escalation. */
4410
- type ApprovalStatus = "approved" | "rejected" | "timed_out";
4411
- /** Full outcome returned when an escalation resolves. */
4412
- interface EscalationOutcome {
4413
- readonly status: ApprovalStatus;
4414
- readonly escalation: HitlEscalation;
4415
- readonly resolvedBy: string | null;
4416
- readonly resolutionNote: string | null;
4417
- readonly resolvedAt: string | null;
4418
- }
4419
- /**
4420
- * Thrown by `protectOrEscalate` / `waitForEscalationApproval` when the
4421
- * human reviewer rejects the escalation.
4422
- */
4423
- declare class EscalationDeniedError extends Error {
4424
- readonly name: "EscalationDeniedError";
4425
- readonly escalationId: string;
4426
- readonly outcome: EscalationOutcome;
4427
- constructor(outcome: EscalationOutcome);
4428
- }
4429
- /**
4430
- * Thrown by `protectOrEscalate` / `waitForEscalationApproval` when the
4431
- * client-side wait window expires before the escalation resolves.
4432
- */
4433
- declare class EscalationTimeoutError extends Error {
4434
- readonly name: "EscalationTimeoutError";
4435
- readonly escalationId: string;
4436
- readonly outcome: EscalationOutcome;
4437
- constructor(outcome: EscalationOutcome);
4438
- }
4439
- /**
4440
- * Options for creating an HITL escalation. Extends `HitlCreateRequest` with
4441
- * API-key and base-URL overrides for per-call credential injection.
4442
- */
4443
- interface CreateEscalationOptions extends Partial<HitlCreateRequest> {
4444
- apiKey?: string;
4445
- baseUrl?: string;
4446
- }
4447
- /**
4448
- * Create an HITL escalation via POST /v1/hitl.
4449
- *
4450
- * The escalation is placed in `pending` status; a reviewer must approve or
4451
- * reject it before the original action can proceed. Use
4452
- * `waitForEscalationApproval()` to poll until the escalation resolves.
4453
- */
4454
- declare function createEscalation(opts: CreateEscalationOptions): Promise<EscalationHandle>;
4455
- interface WaitForApprovalOptions {
4456
- escalationId: string;
4457
- /** Max milliseconds to wait for a human to respond. Default 600_000 (10 min). */
4458
- waitMs?: number;
4459
- /** How often to poll the API. Default 5000ms. Minimum 1000ms. */
4460
- pollIntervalMs?: number;
4461
- apiKey?: string;
4462
- baseUrl?: string;
4463
- }
4464
- /**
4465
- * Poll GET /v1/escalations/:id until the escalation reaches a terminal status
4466
- * (`approved`, `auto_approved`, `rejected`, or `timed_out`).
4467
- *
4468
- * Returns the resolved outcome regardless of approval/rejection — the caller
4469
- * decides whether to throw. Use `protectOrEscalate()` for the opinionated flow.
4470
- */
4471
- declare function waitForEscalationApproval(opts: WaitForApprovalOptions): Promise<EscalationOutcome>;
4472
- /**
4473
- * A verified Permit granted via human approval of an HITL escalation.
4474
- * Extends {@link Permit} with escalation provenance fields.
4475
- *
4476
- * `approvalBasis: "direct_policy"` — action was allowed directly by policy;
4477
- * no escalation was created.
4478
- *
4479
- * `approvalBasis: "human_approval"` — the policy returned `hold`/`escalate`;
4480
- * a human reviewer approved the escalation.
4481
- *
4482
- * Guards and enforcement adapters should treat both as equivalent authorization
4483
- * proof; auditors can distinguish them via `escalationId`.
4484
- */
4485
- interface ApprovalPermit extends Permit {
4486
- /**
4487
- * The HITL escalation ID that authorized this action. Empty string when
4488
- * the action was directly allowed by policy (no escalation needed).
4489
- */
4490
- readonly escalationId: string;
4491
- /** Identity of the reviewer who approved, or `null` for `auto_approved`. */
4492
- readonly resolvedBy: string | null;
4493
- readonly resolutionNote: string | null;
4494
- readonly resolvedAt: string;
4495
- readonly approvalBasis: "direct_policy" | "human_approval";
4496
- }
4497
- interface ProtectOrEscalateOptions {
4498
- /** Agent ID recorded on the escalation. Defaults to `request.agent`. */
4499
- agentId?: string;
4500
- /** Human-readable reason surfaced in the reviewer's queue. */
4501
- escalationReason?: string;
4502
- /** The proposed action payload shown to reviewers. Defaults to `request.context`. */
4503
- proposedAction?: Record<string, unknown>;
4504
- riskScore?: number;
4505
- assignedToRole?: string;
4506
- quorumRequired?: HitlQuorumTier;
4507
- fallbackDecision?: HitlFallbackDecision;
4508
- /** ISO-8601 — when the escalation should auto-resolve per server policy. */
4509
- timeoutAt?: string;
4510
- metadata?: Record<string, unknown>;
4511
- /** Max ms to wait for a human decision. Default 600_000 (10 min). */
4512
- waitMs?: number;
4513
- /** How often to poll. Default 5000ms. */
4514
- pollIntervalMs?: number;
4515
- apiKey?: string;
4516
- baseUrl?: string;
4517
- /** Called with the EscalationHandle immediately after it is created. */
4518
- onEscalationCreated?: (handle: EscalationHandle) => void;
6062
+ onError?: (frame: StreamErrorFrame) => void;
4519
6063
  }
4520
6064
  /**
4521
- * Authorize an action end-to-end, automatically escalating to human review
4522
- * when the policy returns `hold` or `escalate`.
6065
+ * `POST /v1/evaluate/stream` V2-D4.
4523
6066
  *
4524
- * **Directly allowed** returns `ApprovalPermit` with
4525
- * `approvalBasis: "direct_policy"` (same semantics as `protect()`).
6067
+ * Streams `event: decision` frames in input order. Per-item RPC
6068
+ * failures arrive as `event: error` frames and do not tear down the
6069
+ * stream (V2-D7 async semantics). Resolves with the terminal
6070
+ * `event: complete` payload.
4526
6071
  *
4527
- * **Hold / escalate** creates an HITL escalation, polls for a human
4528
- * decision, and returns `ApprovalPermit` with
4529
- * `approvalBasis: "human_approval"` on approval.
6072
+ * @throws {FeatureNotEnabledError} When the tenant `v2_streaming` flag is off.
6073
+ * @throws {AtlaSentError} For transport failures, including the stream
6074
+ * closing without a `complete` frame.
6075
+ */
6076
+ declare function authorizeStream(transport: V2Transport, req: EvaluateManyRequest, handlers?: AuthorizeStreamHandlers): Promise<StreamComplete>;
6077
+ /**
6078
+ * `POST /v1/graphql` — V2-D2 + V2-D8.
4530
6079
  *
4531
- * **Throws**:
4532
- * - {@link EscalationDeniedError} reviewer rejected the escalation
4533
- * - {@link EscalationTimeoutError} wait window elapsed without a decision
4534
- * - {@link AtlaSentDeniedError} hard deny (not hold/escalate); fail-closed
4535
- * - {@link AtlaSentError} — transport / auth / server failure; fail-closed
6080
+ * Bearer-only auth (no query-param). Wave A schema is read-only
6081
+ * (`recentEvaluations(limit)` + `activeBundle`). Server enforces the
6082
+ * V2-D8 OR-gate (`audit:read` OR `policy:read`) at request layer and
6083
+ * a per-resolver AND-gate at field resolution time.
6084
+ *
6085
+ * Resolver-level errors surface on `response.errors` — the SDK does
6086
+ * not throw on them so callers can inspect partial data.
6087
+ *
6088
+ * @throws {FeatureNotEnabledError} When the tenant `v2_graphql` flag is off.
6089
+ * @throws {AtlaSentError} For transport / HTTP failures.
6090
+ * @throws {TypeError} When `query` is empty or the body exceeds the 1MB cap.
4536
6091
  */
4537
- declare function protectOrEscalate(request: ProtectRequest, opts?: ProtectOrEscalateOptions): Promise<ApprovalPermit>;
4538
- interface RequestOverrideOptions {
4539
- /** Human-readable justification. Required; max 2000 characters. */
4540
- reason: string;
4541
- /** The evaluation ID that was denied and should be overridden. */
4542
- evaluationId: string;
4543
- /** How long this override is valid, in seconds. Max 604800 (7 days). */
4544
- ttlSeconds?: number;
4545
- /** Arbitrary metadata to attach (e.g. liability attribution context). */
4546
- metadata?: Record<string, unknown>;
4547
- apiKey?: string;
4548
- baseUrl?: string;
4549
- }
6092
+ declare function graphql<T = unknown>(transport: V2Transport, req: GraphQLRequest): Promise<GraphQLResponse<T>>;
6093
+
4550
6094
  /**
4551
- * Request a post-hoc override for a denied evaluation via POST /v1/overrides.
6095
+ * Runtime v2 client authorized-state-change lifecycle.
4552
6096
  *
4553
- * The override starts in `pending` status and takes effect only after an
4554
- * authorized actor approves it. Subsequent evaluations for the same action
4555
- * will return `allow` while the override is `approved` and within its TTL.
6097
+ * Thin client over `/v2/orgs/:org_id/…` endpoints landed in
6098
+ * `atlasent-api` PR #1031. Accepts the same {@link V2Transport}
6099
+ * interface used by the existing v2 batch/stream/graphql module so
6100
+ * callers can reuse the same auth headers and fetch implementation.
4556
6101
  *
4557
- * Attach `metadata.requested_by` for liability attribution.
6102
+ * @example
6103
+ * ```ts
6104
+ * import { RuntimeV2Client } from "@atlasent/sdk/runtime_v2";
6105
+ *
6106
+ * const rt = new RuntimeV2Client({
6107
+ * baseUrl: "https://api.atlasent.io",
6108
+ * apiKey: process.env.ATLASENT_API_KEY!,
6109
+ * });
6110
+ * const decision = await rt.authorize("org_acme", { transition: { … } });
6111
+ * ```
4558
6112
  */
4559
- declare function requestOverride(opts: RequestOverrideOptions): Promise<OverrideV1>;
6113
+
6114
+ interface VerificationFailure {
6115
+ code: string;
6116
+ message: string;
6117
+ field?: string;
6118
+ }
6119
+ interface VerificationResult {
6120
+ passed: boolean;
6121
+ verified_at: string;
6122
+ failures: VerificationFailure[];
6123
+ warnings: Array<Record<string, unknown>>;
6124
+ }
6125
+ interface ExecutionReceipt {
6126
+ receipt_id: string;
6127
+ permit_id: string;
6128
+ org_id: string;
6129
+ issued_at: string;
6130
+ post_state_fingerprint: string;
6131
+ evidence_id: string;
6132
+ }
6133
+ interface PostExecutionResult {
6134
+ verified: boolean;
6135
+ evidence_completeness: "COMPLETE" | "PARTIAL" | "FAILED";
6136
+ failures: VerificationFailure[];
6137
+ receipt?: ExecutionReceipt;
6138
+ }
6139
+ interface AuthorizationDecision {
6140
+ status: "PERMITTED" | "PENDING_APPROVAL" | "DENIED" | "ERROR";
6141
+ permit?: Record<string, unknown>;
6142
+ required_approvers?: string[];
6143
+ reasons?: string[];
6144
+ policy_ids?: string[];
6145
+ code?: string;
6146
+ message?: string;
6147
+ }
6148
+ interface AuthorityRecord {
6149
+ authority_id: string;
6150
+ org_id: string;
6151
+ name: string;
6152
+ action_classes: string[];
6153
+ public_key: string;
6154
+ key_id: string;
6155
+ status: string;
6156
+ created_at: string;
6157
+ [key: string]: unknown;
6158
+ }
6159
+ interface RuntimeAuditEntry {
6160
+ entry_id: string;
6161
+ org_id: string;
6162
+ sequence: number;
6163
+ receipt_id: string;
6164
+ prior_hash: string;
6165
+ entry_hash: string;
6166
+ appended_at: string;
6167
+ }
6168
+ interface AuditChainPage {
6169
+ entries: RuntimeAuditEntry[];
6170
+ total: number;
6171
+ page: number;
6172
+ page_size: number;
6173
+ }
6174
+ interface ChainIntegrityReport {
6175
+ valid: boolean;
6176
+ checked_entries: number;
6177
+ first_sequence: number;
6178
+ last_sequence: number;
6179
+ gaps: number[];
6180
+ invalid_hashes: number[];
6181
+ verified_at: string;
6182
+ }
6183
+ interface ComplianceExport {
6184
+ export_id: string;
6185
+ org_id: string;
6186
+ from: string;
6187
+ to: string;
6188
+ entry_count: number;
6189
+ format: string;
6190
+ content_ref: string;
6191
+ content_hash: string;
6192
+ generated_at: string;
6193
+ signed_by: string;
6194
+ }
6195
+ interface AuditChainFilters {
6196
+ action_class?: string;
6197
+ principal_did?: string;
6198
+ resource_locator?: string;
6199
+ }
6200
+ /** Runtime v2 client — four-plane authorized-state-change lifecycle. */
6201
+ declare class RuntimeV2Client {
6202
+ private readonly transport;
6203
+ constructor(transport: V2Transport);
6204
+ /** `POST /v2/orgs/:orgId/transitions` */
6205
+ authorize(orgId: string, request: Record<string, unknown>): Promise<AuthorizationDecision>;
6206
+ /** `GET /v2/orgs/:orgId/permits/:permitId` */
6207
+ getPermit(orgId: string, permitId: string): Promise<Record<string, unknown> | null>;
6208
+ /** `POST /v2/orgs/:orgId/permits/:permitId/consume` */
6209
+ consume(orgId: string, permitId: string, observedSourceFingerprint: string): Promise<VerificationResult>;
6210
+ /** `POST /v2/orgs/:orgId/permits/:permitId/approve` */
6211
+ approve(orgId: string, permitId: string, approverDid: string, signature: string, comment?: string): Promise<{
6212
+ approved: boolean;
6213
+ status: string;
6214
+ }>;
6215
+ /** `POST /v2/orgs/:orgId/permits/:permitId/complete` */
6216
+ complete(orgId: string, permitId: string, evidenceId: string, observedPostFingerprint: string): Promise<PostExecutionResult>;
6217
+ /** `DELETE /v2/orgs/:orgId/permits/:permitId` */
6218
+ revokePermit(orgId: string, permitId: string, revokedBy: string, reason: string, propagatesToChildren?: boolean): Promise<void>;
6219
+ /** `GET /v2/orgs/:orgId/authorities` */
6220
+ listAuthorities(orgId: string, includeInactive?: boolean): Promise<AuthorityRecord[]>;
6221
+ /** `POST /v2/orgs/:orgId/authorities` */
6222
+ createAuthority(orgId: string, record: Record<string, unknown>): Promise<AuthorityRecord>;
6223
+ /** `GET /v2/orgs/:orgId/authorities/:authorityId` */
6224
+ getAuthority(orgId: string, authorityId: string): Promise<AuthorityRecord | null>;
6225
+ /** `POST /v2/orgs/:orgId/authorities/:authorityId/rotate` */
6226
+ rotateAuthority(orgId: string, authorityId: string, newPublicKey: string, newKeyId: string): Promise<AuthorityRecord>;
6227
+ /** `POST /v2/orgs/:orgId/authorities/:authorityId/revoke` */
6228
+ revokeAuthority(orgId: string, authorityId: string, reason: string): Promise<void>;
6229
+ /** `POST /v2/orgs/:orgId/evidence` */
6230
+ submitEvidence(orgId: string, pkg: Record<string, unknown>): Promise<void>;
6231
+ /** `GET /v2/orgs/:orgId/evidence/:evidenceId` */
6232
+ getEvidence(orgId: string, evidenceId: string): Promise<Record<string, unknown> | null>;
6233
+ /** `GET /v2/orgs/:orgId/audit-chain` */
6234
+ queryAuditChain(orgId: string, from: string, to: string, options?: AuditChainFilters & {
6235
+ page?: number;
6236
+ page_size?: number;
6237
+ }): Promise<AuditChainPage>;
6238
+ /** `GET /v2/orgs/:orgId/audit-chain/integrity` */
6239
+ verifyChainIntegrity(orgId: string, fromSequence: number, toSequence: number): Promise<ChainIntegrityReport>;
6240
+ /** `POST /v2/orgs/:orgId/compliance-export` */
6241
+ exportCompliance(orgId: string, from: string, to: string, format?: "JSON" | "CSV" | "CISA_SBOM"): Promise<ComplianceExport>;
6242
+ }
4560
6243
 
4561
6244
  /**
4562
6245
  * Context Layer — typed, validated, redaction-aware context for AtlaSent
@@ -4591,6 +6274,8 @@ declare function requestOverride(opts: RequestOverrideOptions): Promise<Override
4591
6274
  * actor: { id: "user:alice", type: "human", roles: ["deploy_engineer"] },
4592
6275
  * environment: { name: "production", region: "us-east-1" },
4593
6276
  * resource: { type: "service", id: "api-gateway", sensitivity: "restricted" },
6277
+ * org_id: "org_acme",
6278
+ * environment_id: "env_prod_us_east",
4594
6279
  * });
4595
6280
  *
4596
6281
  * const permit = await atlasent.protect({
@@ -4628,6 +6313,12 @@ interface ActorContext {
4628
6313
  ip?: string;
4629
6314
  /** Session or OAuth token ID for replay-detection rules. */
4630
6315
  session_id?: string;
6316
+ /**
6317
+ * Organization this actor belongs to. Populated from
6318
+ * `BuildActionContextInput.org_id` when the actor has no explicit org_id.
6319
+ * Used by cross-tenant policy checks and usage metering.
6320
+ */
6321
+ org_id?: string;
4631
6322
  }
4632
6323
  /**
4633
6324
  * The resource the action targets.
@@ -4654,11 +6345,11 @@ interface ResourceContext {
4654
6345
  * Deployment environment and infrastructure context.
4655
6346
  *
4656
6347
  * `name` is the field protect() reads to set the `environment` field
4657
- * on the verify-permit request. Omitting it logs a console warning
4658
- * and defaults to `"production"`.
6348
+ * on the verify-permit request. Set it explicitly in runtime contexts
6349
+ * so verification is bound to the executing environment.
4659
6350
  */
4660
6351
  interface EnvironmentContext {
4661
- /** Deployment tier. Defaults to `"production"` in protect() when absent. */
6352
+ /** Deployment tier (for example, `"production"` or `"staging"`). */
4662
6353
  name?: "production" | "staging" | "development" | "test" | string;
4663
6354
  /** Cloud or datacenter region (e.g. `"us-east-1"`, `"eu-west-1"`). */
4664
6355
  region?: string;
@@ -4724,6 +6415,19 @@ interface ActionContext {
4724
6415
  environment?: EnvironmentContext;
4725
6416
  action_meta?: ActionMetaContext;
4726
6417
  history?: HistoricalContext;
6418
+ /**
6419
+ * Organization ID — scopes the evaluation to this org's policies and
6420
+ * usage meters. Propagated from `BuildActionContextInput.org_id` and
6421
+ * also set on `actor.org_id` when the actor has no explicit org.
6422
+ */
6423
+ org_id?: string;
6424
+ /**
6425
+ * ID of the registered `org_environments` row.
6426
+ * Future billing dimension: usage will be metered per environment tier.
6427
+ * Optional and additive — existing call sites that pass `environment.name`
6428
+ * continue to work without providing this field.
6429
+ */
6430
+ environment_id?: string;
4727
6431
  /** Alias for `environment.name`. Merged into `environment` by buildActionContext. */
4728
6432
  environment_name?: string;
4729
6433
  /** Alias for `resource.type`. Merged into `resource` by buildActionContext. */
@@ -4739,6 +6443,19 @@ interface BuildActionContextInput {
4739
6443
  environment?: EnvironmentContext | string;
4740
6444
  action_meta?: ActionMetaContext;
4741
6445
  history?: HistoricalContext;
6446
+ /**
6447
+ * Organization ID — scopes the evaluation to this org's policies and
6448
+ * usage meters. Propagated to `actor.org_id` when the actor has no
6449
+ * explicit org_id, and also set as a top-level `org_id` on the context
6450
+ * so policy rules can reference it at `context.org_id`.
6451
+ */
6452
+ org_id?: string;
6453
+ /**
6454
+ * ID of the registered `org_environments` row (future billing dimension).
6455
+ * Passed through to the flat context as `environment_id`. Optional —
6456
+ * callers that pass only `environment.name` continue to work unchanged.
6457
+ */
6458
+ environment_id?: string;
4742
6459
  /** Arbitrary additional fields to pass through to the policy engine. */
4743
6460
  extra?: Record<string, unknown>;
4744
6461
  }
@@ -4749,6 +6466,8 @@ interface BuildActionContextInput {
4749
6466
  * - Populates flat shorthands (`resource_type`, `resource_id`,
4750
6467
  * `environment_name`) from the nested sub-schemas so both the nested and
4751
6468
  * flat forms are present in the output.
6469
+ * - Propagates `org_id` to `actor.org_id` when the actor has no explicit org.
6470
+ * - Propagates `environment_id` as a top-level context field for billing.
4752
6471
  * - Never throws — validation is a separate step via `validateActionContext()`.
4753
6472
  *
4754
6473
  * ```ts
@@ -4756,6 +6475,8 @@ interface BuildActionContextInput {
4756
6475
  * actor: { id: "agent:deploy-bot", type: "agent" },
4757
6476
  * environment: "production",
4758
6477
  * resource: { type: "service", id: "checkout-api" },
6478
+ * org_id: "org_acme",
6479
+ * environment_id: "env_prod_us_east",
4759
6480
  * });
4760
6481
  * ```
4761
6482
  */
@@ -4871,7 +6592,8 @@ declare function redactContext(ctx: ActionContext, rules?: readonly RedactionRul
4871
6592
  *
4872
6593
  * The output merges:
4873
6594
  * 1. All top-level scalar fields from `ActionContext` (including flat
4874
- * shorthands like `environment_name`).
6595
+ * shorthands like `environment_name`, and billing dimensions like
6596
+ * `org_id` and `environment_id`).
4875
6597
  * 2. Nested sub-schemas (`actor`, `resource`, `environment`, etc.) preserved
4876
6598
  * as nested objects so policy rules written against either the nested or
4877
6599
  * flat form work correctly.
@@ -4890,41 +6612,6 @@ declare function redactContext(ctx: ActionContext, rules?: readonly RedactionRul
4890
6612
  */
4891
6613
  declare function flattenActionContext(ctx: ActionContext): Record<string, unknown>;
4892
6614
 
4893
- type ShadowMode = "observe" | "warn" | "enforce";
4894
- interface ShadowOutcome {
4895
- readonly decision: "permit" | "deny" | "hold" | "escalate";
4896
- readonly permit: Permit | null;
4897
- readonly error: AtlaSentDeniedError | null;
4898
- readonly would_have_blocked: boolean;
4899
- readonly latencyMs: number;
4900
- readonly evaluationId: string | null;
4901
- readonly request: ProtectRequest;
4902
- readonly mode: ShadowMode;
4903
- }
4904
- interface ShadowConfig {
4905
- mode?: ShadowMode;
4906
- onOutcome?: (outcome: ShadowOutcome) => void | Promise<void>;
4907
- reportToApi?: boolean;
4908
- apiKey?: string;
4909
- baseUrl?: string;
4910
- }
4911
- declare function configureShadow(config: ShadowConfig): void;
4912
- interface ShadowOptions extends ShadowConfig {
4913
- }
4914
- declare function protectShadow(request: ProtectRequest, opts?: ShadowOptions): Promise<ShadowOutcome>;
4915
- interface ShadowEventPayload {
4916
- action: string;
4917
- agentId: string | null;
4918
- decision: ShadowOutcome["decision"];
4919
- would_have_blocked: boolean;
4920
- latencyMs: number;
4921
- evaluationId: string | null;
4922
- mode: ShadowMode;
4923
- deniedReason?: string;
4924
- timestamp: string;
4925
- }
4926
- declare function reportShadowEvent(outcome: ShadowOutcome, opts?: Pick<ShadowConfig, "apiKey" | "baseUrl">): Promise<void>;
4927
-
4928
6615
  type EnforcementMode = "observe" | "warn" | "enforce";
4929
6616
  interface HealthReport {
4930
6617
  readonly healthy: boolean;
@@ -4982,79 +6669,6 @@ interface GetEnforcementStatusOptions extends ControlSurfaceConfig {
4982
6669
  declare function getEnforcementStatus(opts: GetEnforcementStatusOptions): Promise<EnforcementStatus>;
4983
6670
  declare function getOrgSummary(opts?: ControlSurfaceConfig): Promise<OrgSummary>;
4984
6671
 
4985
- type DeployEnvironment = "production" | "staging" | "development" | string;
4986
- interface DeployGateOptions {
4987
- service: string;
4988
- resourceType?: string;
4989
- sha?: string;
4990
- workflow?: string;
4991
- actorId?: string;
4992
- actorLabel?: string;
4993
- environment?: DeployEnvironment;
4994
- description?: string;
4995
- requireApproval?: boolean;
4996
- assignedToRole?: string;
4997
- waitMs?: number;
4998
- onEscalationCreated?: (handle: EscalationHandle) => void;
4999
- apiKey?: string;
5000
- baseUrl?: string;
5001
- }
5002
- declare function protectDeploy(opts: DeployGateOptions): Promise<ApprovalPermit | Permit>;
5003
-
5004
- type CloseActionType = "period.close" | "period.reopen" | "data.export" | "reconciliation.lock";
5005
- interface CloseGovernanceOptions {
5006
- action: CloseActionType;
5007
- periodLabel: string;
5008
- closedBy: string;
5009
- entityId: string;
5010
- entityName?: string;
5011
- dataClassification?: "internal" | "confidential" | "restricted";
5012
- assignedToRole?: string;
5013
- requireDualApproval?: boolean;
5014
- waitMs?: number;
5015
- description?: string;
5016
- onEscalationCreated?: (handle: EscalationHandle) => void;
5017
- apiKey?: string;
5018
- baseUrl?: string;
5019
- }
5020
- declare function protectCloseAction(opts: CloseGovernanceOptions): Promise<ApprovalPermit>;
5021
-
5022
- interface PaymentReleaseOptions {
5023
- amount: number;
5024
- currency: string;
5025
- vendorId: string;
5026
- vendorName?: string;
5027
- authorizedBy: string;
5028
- reference?: string;
5029
- description?: string;
5030
- autoEscalateAbove?: number;
5031
- requireDualApprovalAbove?: number;
5032
- assignedToRole?: string;
5033
- waitMs?: number;
5034
- onEscalationCreated?: (handle: EscalationHandle) => void;
5035
- apiKey?: string;
5036
- baseUrl?: string;
5037
- }
5038
- declare function protectPaymentRelease(opts: PaymentReleaseOptions): Promise<ApprovalPermit | Permit>;
5039
-
5040
- type AgentToolMode = "observe" | "enforce" | "escalate";
5041
- interface AgentToolOptions {
5042
- toolName: string;
5043
- toolArgs: Record<string, unknown>;
5044
- agentId: string;
5045
- sessionId?: string;
5046
- riskLevel?: "critical" | "high" | "medium" | "low";
5047
- mode?: AgentToolMode;
5048
- assignedToRole?: string;
5049
- waitMs?: number;
5050
- description?: string;
5051
- onEscalationCreated?: (handle: EscalationHandle) => void;
5052
- apiKey?: string;
5053
- baseUrl?: string;
5054
- }
5055
- declare function classifyToolRisk(toolName: string): "critical" | "high" | "medium" | "low";
5056
- declare function protectToolCall(opts: AgentToolOptions): Promise<ApprovalPermit | Permit | ShadowOutcome>;
5057
-
5058
6672
  /**
5059
6673
  * Claims → Evidence Lineage
5060
6674
  *
@@ -5504,6 +7118,181 @@ declare class BCCAEClient {
5504
7118
  private request;
5505
7119
  }
5506
7120
 
7121
+ /**
7122
+ * Delta VQP — TypeScript client for the VQP re-derivation audit endpoints.
7123
+ *
7124
+ * VQPClient wraps two service-role-only edge functions:
7125
+ * generate → POST /functions/v1/v1-generate-vqp (creates snapshot + prompt_hash)
7126
+ * verify → POST /functions/v1/v1-verify-vqp (re-derives prompt, hashes, audits)
7127
+ *
7128
+ * These endpoints require a Supabase service_role key — not a user API key.
7129
+ * This client is for server-side admin tooling only.
7130
+ *
7131
+ * Spec: atlasent-api/supabase/functions/v1-generate-vqp, v1-verify-vqp
7132
+ * Phase 3 — Deterministic re-derivation audit.
7133
+ */
7134
+ type VqpVerdict = "qualified" | "conditionally_qualified" | "not_qualified";
7135
+ interface VQPGenerateInput {
7136
+ bundle_id: string;
7137
+ org_id: string;
7138
+ /** Additional context embedded in the VQP prompt for this snapshot. */
7139
+ vqp_context?: Record<string, unknown>;
7140
+ }
7141
+ interface VQPGenerateResponse {
7142
+ snapshot_id: string;
7143
+ bundle_id: string;
7144
+ bundle_version: string;
7145
+ overall_verdict: VqpVerdict;
7146
+ quality_score: number;
7147
+ /** SHA-256 hex of the deterministic VQP prompt used to produce this snapshot. */
7148
+ prompt_hash: string;
7149
+ generation_model: string;
7150
+ generated_at: string;
7151
+ }
7152
+ interface VQPVerifyInput {
7153
+ snapshot_id: string;
7154
+ /**
7155
+ * Re-call the AI model with the re-derived prompt to detect score drift.
7156
+ * When false (default), only prompt hash integrity is checked.
7157
+ */
7158
+ rerun?: boolean;
7159
+ }
7160
+ interface VQPVerifyResponse {
7161
+ snapshot_id: string;
7162
+ /** True when the re-derived prompt hash matches the stored snapshot.prompt_hash. */
7163
+ hash_match: boolean;
7164
+ original_prompt_hash: string;
7165
+ rerun_prompt_hash: string;
7166
+ /** Score from the re-run AI call. Null when rerun was not requested. */
7167
+ rerun_score: number | null;
7168
+ /** Verdict from the re-run AI call. Null when rerun was not requested. */
7169
+ rerun_verdict: VqpVerdict | null;
7170
+ /** rerun_score - original quality_score. Null when rerun was not requested. */
7171
+ score_delta: number | null;
7172
+ /** True when rerun_verdict differs from the stored overall_verdict. */
7173
+ verdict_changed: boolean;
7174
+ /** UUID of the written vqp_audit_log row. */
7175
+ audit_log_id: string;
7176
+ }
7177
+ interface VQPClientOptions {
7178
+ /** Supabase service_role key. These endpoints are not accessible with user API keys. */
7179
+ serviceRoleKey: string;
7180
+ /** Supabase project URL, e.g. https://<ref>.supabase.co */
7181
+ supabaseUrl: string;
7182
+ /** Request timeout in ms. Defaults to 30000 (AI re-run calls can be slow). */
7183
+ timeoutMs?: number;
7184
+ /** Inject a custom fetch implementation (testing / edge runtimes). */
7185
+ fetch?: typeof globalThis.fetch;
7186
+ }
7187
+ /**
7188
+ * Thin HTTP client for the Delta VQP Phase 3 service-role endpoints.
7189
+ *
7190
+ * Each method maps 1:1 to an edge function:
7191
+ * - {@link VQPClient.generate} → v1-generate-vqp
7192
+ * - {@link VQPClient.verify} → v1-verify-vqp
7193
+ *
7194
+ * **Server-side only.** These endpoints require `SUPABASE_SERVICE_ROLE_KEY`.
7195
+ * Never expose a service_role key in browser or agent code.
7196
+ *
7197
+ * Network errors and 5xx responses throw {@link AtlaSentError}.
7198
+ */
7199
+ declare class VQPClient {
7200
+ private readonly serviceRoleKey;
7201
+ private readonly baseUrl;
7202
+ private readonly timeoutMs;
7203
+ private readonly fetchImpl;
7204
+ constructor(options: VQPClientOptions);
7205
+ generate(input: VQPGenerateInput): Promise<VQPGenerateResponse>;
7206
+ verify(input: VQPVerifyInput): Promise<VQPVerifyResponse>;
7207
+ private post;
7208
+ private request;
7209
+ }
7210
+
7211
+ type DependencyRequirement = "permit" | "allow_decision";
7212
+ type DependencyStatus = "satisfied" | "missing" | "expired" | "invalid";
7213
+ interface ActionDependency {
7214
+ id: string;
7215
+ organization_id: string;
7216
+ parent_action_class_id: string;
7217
+ child_action_class_id: string;
7218
+ requires: DependencyRequirement;
7219
+ temporal_window_seconds: number | null;
7220
+ created_at: string;
7221
+ }
7222
+ interface CreateActionDependencyRequest {
7223
+ parent_action_class_id: string;
7224
+ child_action_class_id: string;
7225
+ requires?: DependencyRequirement;
7226
+ temporal_window_seconds?: number;
7227
+ }
7228
+ interface ActionDependencyResponse {
7229
+ action_dependency: ActionDependency;
7230
+ rateLimit: RateLimitState | null;
7231
+ }
7232
+ interface ListActionDependenciesResponse {
7233
+ action_dependencies: ActionDependency[];
7234
+ total: number;
7235
+ limit: number;
7236
+ offset: number;
7237
+ rateLimit: RateLimitState | null;
7238
+ }
7239
+ interface DependencyLink {
7240
+ dependency_id: string;
7241
+ parent_evaluation_id?: string;
7242
+ parent_permit_token_hash?: string;
7243
+ status: DependencyStatus;
7244
+ }
7245
+
7246
+ type EngineVersionStatus = "active" | "retired" | "archival";
7247
+ interface EngineVersionRecord {
7248
+ engine_version: string;
7249
+ status: EngineVersionStatus;
7250
+ bundle_compatibility_range: string | null;
7251
+ supersedes_version: string | null;
7252
+ released_at: string;
7253
+ retired_at: string | null;
7254
+ archival_until: string | null;
7255
+ notes: string | null;
7256
+ created_at: string;
7257
+ updated_at: string;
7258
+ }
7259
+ interface RegisterEngineVersionRequest {
7260
+ engine_version: string;
7261
+ status?: EngineVersionStatus;
7262
+ bundle_compatibility_range?: string;
7263
+ supersedes_version?: string;
7264
+ notes?: string;
7265
+ released_at?: string;
7266
+ }
7267
+ interface EngineVersionResponse {
7268
+ engine_version: EngineVersionRecord;
7269
+ rateLimit: RateLimitState | null;
7270
+ }
7271
+ interface ListEngineVersionsResponse {
7272
+ engine_versions: EngineVersionRecord[];
7273
+ rateLimit: RateLimitState | null;
7274
+ }
7275
+
7276
+ type SnapshotSourceKind = "system_state" | "external_system" | "caller_provided";
7277
+ interface StateSnapshotInput {
7278
+ source: string;
7279
+ source_kind: SnapshotSourceKind;
7280
+ complete: boolean;
7281
+ payload: Record<string, unknown>;
7282
+ }
7283
+ interface StateSnapshotRef {
7284
+ snapshot_id: string;
7285
+ canonical_hash?: string;
7286
+ }
7287
+ interface StateSnapshot extends StateSnapshotRef {
7288
+ organization_id: string;
7289
+ source: string;
7290
+ source_kind: SnapshotSourceKind;
7291
+ complete: boolean;
7292
+ tamper_detected: boolean;
7293
+ created_at: string;
7294
+ }
7295
+
5507
7296
  /**
5508
7297
  * @atlasent/sdk — execution-time authorization for AI agents.
5509
7298
  *
@@ -5578,6 +7367,27 @@ declare const atlasent: {
5578
7367
  readonly AtlaSentClient: typeof AtlaSentClient;
5579
7368
  readonly AtlaSentError: typeof AtlaSentError;
5580
7369
  readonly AtlaSentDeniedError: typeof AtlaSentDeniedError;
7370
+ readonly paymentGate: typeof protectPaymentRelease;
7371
+ readonly dataExportGate: typeof protectDataExport;
7372
+ readonly reconciliationGate: typeof protectReconciliationCertify;
7373
+ readonly agentGuard: typeof protectToolCall;
7374
+ readonly gxpGate: typeof protectGxpAction;
7375
+ readonly batchRecordGate: typeof protectBatchRecordRelease;
7376
+ readonly paymentOpsGate: typeof protectPaymentOperation;
7377
+ readonly deployV2Gate: typeof protectDeploymentV2;
7378
+ readonly behaviorEventGate: typeof protectBehaviorEvent;
7379
+ readonly infraGate: typeof protectInfraAction;
7380
+ readonly hrGate: typeof protectHrOffboard;
7381
+ readonly modelGovernanceGate: typeof protectModelPromotion;
7382
+ readonly dataDeleteGate: typeof protectCustomerDataDelete;
7383
+ readonly contractGate: typeof protectContractExecution;
7384
+ readonly pricingGate: typeof protectPricingRule;
7385
+ readonly securityGate: typeof protectSecurityIncidentEscalate;
7386
+ readonly accessCertGate: typeof protectAccessCertRevoke;
7387
+ readonly financialCloseGate: typeof protectPeriodCloseCertify;
7388
+ readonly databaseMigrationGate: typeof protectDatabaseMigration;
7389
+ readonly databaseSchemaDropGate: typeof protectDatabaseSchemaDrop;
7390
+ readonly databaseTableDeleteGate: typeof protectDatabaseTableDelete;
5581
7391
  };
5582
7392
 
5583
- export { type ActionBundleInput, type ActionBundleReceipt, type ActionContext, type ActionFreeze, type ActionMetaContext, type ActionTypeOverrideStat, type ActorContext, type ActorOverrideStat, type AgentAuthorityDomain, type AgentEvaluationStatus, type AgentEvidenceRef, type AgentFindingSeverity, type AgentInvokerKind, type AgentSubjectKind, type AgentToolMode, type AgentToolOptions, type AmountThreshold, type AnomalyActionType, type AnomalyResponseEvent, type AnomalyResponseRule, type AnomalyType, ApiKeySelfResponse, type ApplyPolicySyncResponse, type ApprovalArtifactSlot, type ApprovalArtifactV1, type ApprovalConcentrationAnalysis, type ApprovalIssuer, type ApprovalPermit, type ApprovalProvenance, type ApprovalQuorumV1, type ApprovalReference, type ApprovalReviewer, type ApprovalRuntimeConfig, type ApprovalStatus, type ApproveBudgetExceptionRequest, type ApproverBreakdown, AtlaSentClient, AtlaSentClientOptions, AtlaSentDeniedError, AtlaSentError, type AuditBundle, AuditEventsQuery, AuditEventsResult, AuditExportRequest, AuditExportResult, type AuthenticateConnectorInput, type AuthenticateConnectorResponse, type AuthorizeStreamHandlers, type AutonomousBoundsDenyCode, type AutonomousExecutionBounds, type AutonomousExecutionCheckResult, type AutonomousExecutionRecord, BCCAEClient, BatchEvalItem, BatchEvalResponse, type BccaeActorType, type BccaeClientOptions, type BccaeDeploymentEnv, type BccaeEvaluateInput, type BccaeEvaluateResponse, type BccaeEvidenceResponse, type BccaeExecuteInput, type BccaeExecuteResponse, type BccaeRequestSource, type BccaeResourceClassification, type BccaeRevocationTargetType, type BccaeRevokeInput, type BccaeRevokeResponse, type BccaeSecurityPosture, type BccaeTrustLevel, type BudgetConstraintCheckResult, type BudgetDenyCode, type BudgetExceptionRequest, type BudgetExceptionStatus, type BudgetLimit, type BudgetPolicy, type BudgetScope, type BudgetSpendingState, type BudgetViolation, type BudgetaryDriftAnalysis, type BuildActionContextInput, type BuildClaimEvidenceLinkOpts, type BuildFromActionBundleOpts, type BundleVerificationResult, type ClaimEvidenceLink, type CloseActionType, type CloseGovernanceOptions, type ComplianceEvidenceRun, type ComplianceEvidenceSummary, type ComplianceFramework, type ComplianceRunStatus, type ComputeOrgRiskOptions, type ComputeOrgRiskResponse, type ConcentrationAlert, type ConnectedSystemRow, type ConnectorAuditLogEntry, type ConnectorCredentialRow, type ConnectorCredentialType, type ConnectorEnforcementEventInput, type ConnectorEnforcementPolicy, type ConnectorEnforcementResult, type ConnectorRow, type ConnectorStatus, type ConnectorSyncState, type ConnectorType, type ContextValidationError, type ContextValidationResult, type ContextValidationWarning, type ControlSurfaceConfig, type CreateAnomalyResponseRuleRequest, type CreateBudgetExceptionRequest, type CreateEscalationOptions, type CreateGraphEdgeInput, type CreateGraphNodeInput, type CreateImpersonationGrantRequest, type CreateOverrideRequest, type CreateRegulatoryEscalationRequest, type CreateWebhookSubscriptionRequest, type CrossOrgImpersonationGrant, type CrossOrgPermissionCheckListParams, type CrossOrgPermissionCheckRequest, type CrossOrgPermissionCheckResult, type CrossOrgTrustHop, type CurrencyCode, DEFAULT_INCENTIVE_CONFIG, DEFAULT_REDACTION_RULES, DEFAULT_RISK_TIER_THRESHOLDS, DecisionCanonical, DecisionStreamEvent, type DelegationPropagationSummary, type DeltaSlot, type DeltaStatus, type DeployEnvironment, type DeployEvidenceInput, type DeployEvidenceSlot, type DeployGateOptions, DeployGateRequest, DeployGateResponse, type DisputeOrigin, type DisputeRecord, type DisputeReversalSummary, type DisputeStatus, type DriftChangeType, type DriftDetail, type DriftSeverity, type EconomicEvidenceBundle, type EmergencyFreeze, type EmergencyOverrideActionRow, type EnforcementAction, type EnforcementMode, type EnforcementQuorumConfig, type EnforcementStatus, type EnforcementWebhookEvent, type EngineVersionKind, type EnvelopeDriftDetail, type EnvelopeVerification, type EnvironmentContext, EscalationDeniedError, type EscalationHandle, type EscalationOutcome, EscalationTimeoutError, type EvaluateBatchItem, type EvaluateBatchResponse, type EvaluateManyRequest, EvaluatePreflightResponse, EvaluateRequest, EvaluateResponse, type EvidenceBundleSignableContent, type EvidenceBundleVerificationResult, type EvidenceControl, type EvidenceControlStatus, type EvidencePurpose, type EvidenceSlotStatus, type ExecutionAnomaly, type ExecutionApproverRow, type ExecutionCeiling, FeatureNotEnabledError, type FeatureNotEnabledErrorInit, type FinancialActionClass, type FinancialActionType, type FinancialExecutionRecord, type FinancialExecutionStatus, type FinancialGovernanceSummary, type FinancialQuorumDenyCode, type FinancialQuorumInput, type FinancialQuorumPolicy, type FinancialQuorumResult, type FinancialRiskScore, type FinancialRiskTier, type FinancialRoleRequirement, type GetEnforcementStatusOptions, type GetLatestOrgRiskResponse, GetPermitResponse, type GovernanceAgent, type GovernanceAgentEvaluation, type GovernanceAgentFinding, type GovernanceBehaviorPattern, GovernanceEnforcementError, type GovernanceEnforcementErrorInit, type GovernanceEvent, type GovernanceGate, type GovernanceGraphQueryParams, type GovernanceGraphQueryResponse, type GovernanceGraphQueryType, type GovernanceGraphResultRow, type GovernanceSignalAction, type GovernanceWebhookEvent, type GraphEdge, type GraphEdgeType, type GraphNode, type GraphNodeType, type GraphQLRequest, type GraphQLResponse, type HealthReport, type HistoricalContext, type HitlAiUnavailableFallback, type HitlApprovalRecord, type HitlApproveRequest, type HitlApproverPoolEntry, type HitlApproverType, type HitlChainHop, type HitlChainSummary, type HitlCreateRequest, type HitlDetailResponse, type HitlEscalation, type HitlFallbackDecision, type HitlHeterogeneousQuorumExtension, type HitlHeterogeneousQuorumTally, type HitlListResponse, type HitlQuorumProgress, type HitlQuorumTier, type HitlRejectRequest, type HitlRespondRequest, type HitlStatus, type IdentityAssertionBinding, type IdentityAssertionV1, type IdentityIssuer, type IdentityIssuerKey, type IdentitySubject, type IdentityTrustedIssuersConfig, type ImpersonationToken, type ImpersonationValidationResult, type IncentiveAlignmentConfig, type IncentiveSignal, type IncentiveSignalType, type IncidentChainActorEntry, type IncidentChainEvidenceRow, type IncidentChainExecutionRow, type IncidentTimelineResponse, type InstallConnectorInput, type InstallConnectorResponse, type IntegrationEvidenceSlot, type LegacyEvaluateRequest, type LegacyEvaluateResponse, type LiabilityAttributionInput, type LiabilityAttributionRecord, type LiabilityChainValidation, type LiabilityClassification, type LiabilityEdge, type LiabilityNode, type LiabilityParty, type LiabilityPartyRole, type LiabilityVisualization, type ListConnectorsResponse, type ListEnforcementPoliciesResponse, type ListEvidenceRunsResponse, type ListGovernanceAgentsResponse, type ListGovernanceEvaluationsQuery, type ListGovernanceEvaluationsResponse, type ListGovernanceFindingsQuery, type ListGovernanceFindingsResponse, type ListGraphEdgesResponse, type ListGraphNodesResponse, type ListHitlEscalationsRequest, type ListHitlEscalationsResponse, type ListOrgRiskHistoryResponse, ListPermitsRequest, ListPermitsResponse, type ListPolicySyncRunsResponse, type ListWebhookDeliveriesResponse, type ListWebhookSubscriptionsResponse, type MisalignmentAlert, NOT_APPLICABLE, type NotApplicable, type OrgRiskLevel, type OrgRiskScore, type OrgSummary, type OverrideAnalytics, type OverrideEvent, type OverrideEventType, type OverrideEventsResponse, type OverrideListResponse, type OverrideStatus, type OverrideV1, type PaymentReleaseOptions, Permit, type PermitV1, PermitValidResponse, type PolicyBundleEntry, type PolicyRef, type PolicySyncDiff, type PolicySyncRun, type PolicySyncStatus, type PrincipalKind, type ProductionDeployerRow, type ProofEvaluationSummary, type ProofPayload, type ProofResponse, type ProtectOrEscalateOptions, ProtectRequest, type ProtectedAction, type ProtectedActionEntry, type QuorumBypassConnectorRow, type QuorumIndependence, type QuorumPolicy, type QuorumProof, type QuorumRoleRequirement, RateLimitState, type RecordSignalActionRequest, type RecordSignalOutcomeRequest, type RedactionMode, type RedactionRule, type RegulatoryAuthorityLevel, type RegulatoryEscalation, type RegulatoryEscalationStatus, type ReplayDecisionResponse, type ReplayDecisionValue, type ReplayRequest, type ReplayResponse, type ReplayVarianceKind, type ReportProtectedActionOptions, type RequestOverrideOptions, type ResourceContext, type ReversalStage, type ReversalWorkflow, type RevokeConnectorResponse, RevokePermitByIdInput, RevokePermitByIdResponse, RevokePermitRequest, RevokePermitResponse, type RiskFactor, type RiskTierThreshold, type RiskTimelinePoint, type RotateCredentialsResponse, type RuntimeEvidenceSlot, type SOC2ControlId, type SandboxDiff, type SandboxDiffEmpty, type SandboxDiffPerTable, type SandboxDiffResponse, type SandboxRunMode, type SandboxRunStatus, type SandboxRunWrite, type SandboxWriteOp, type ShadowConfig, type ShadowEventPayload, type ShadowMode, type ShadowOptions, type ShadowOutcome, type SignalActionSummary, type SignalActionType, type SignedApprovalArtifact, type SpendingConstraint, type StreamComplete, type StreamDecisionFrame, type StreamErrorFrame, StreamEvent, StreamOptions, type SubmitPolicySyncRequest, type SubmitPolicySyncResponse, SubscribeDecisionsOptions, type SyncConnectorResponse, type TriggerAnomalyResponseRequest, type TriggerEvidenceRunRequest, type TriggerEvidenceRunResponse, type UpsertEnforcementPolicyInput, type UpsertEnforcementPolicyResponse, type UserApprovalRow, type V2EvaluateRequest, type V2EvaluateResponse, type V2Feature, type V2Transport, V2_BATCH_PATH, V2_GRAPHQL_MAX_DEPTH, V2_GRAPHQL_PATH, V2_MAX_BATCH_ITEMS, V2_MAX_BODY_BYTES, V2_STREAM_PATH, type ValidateContextOptions, type VerificationChecklist, type VerifyBundleOptions, type VerifyClaimEvidenceLinkOpts, type VerifyClaimEvidenceLinkResult, type VerifyKey, VerifyPermitByIdResponse, VerifyPermitRequest, VerifyPermitResponse, type WaitForApprovalOptions, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookPayload, type WebhookSubscription, WebhookVerificationError, type WeightDistribution, assertWebhook, authorizeStream, budgetUtilizationSeverity, buildActionContext, buildClaimEvidenceLink, buildClaimEvidenceLinkFromActionBundle, buildLiabilityChain, buildLiabilityVisualization, buildRiskTimeline, buildSignableContent, canonicalJSON, canonicalizeForEvidence, checkAutonomousBounds, checkBudgetConstraints, checkIntegrationHealth, clampTokenDuration, classifyCommand, classifyRiskTier, classifyToolRisk, computeApprovalRiskScore, computeEscalatedApprovalCount, computeExposureScore, computeGovernanceHealthScore, computeHHI, computeLiabilityWeights, computeOverallRiskScore, computeOverrideScore, computeRemediationUrgency, computeSignalEngagementRate, configure, configureApprovalRuntime, configureControlSurface, configureShadow, createEscalation, atlasent as default, delegationPropagationHadEffect, deployGate, detectAutonomousAnomaly, detectMisalignedIncentives, detectSelfApproval, enforceAutonomousBounds, enforceBudgetConstraint, enforceEconomicGovernance, enforceFinancialQuorum, evaluateFinancialQuorum, evaluateMany, evidenceRunPasses, findPrimaryLiabilityParties, flattenActionContext, formatPolicySyncDiff, generateBccaeNonce, getEnforcementStatus, getOrgSummary, graphql, hhiToConcentrationScore, highestAgentFindingSeverity, highestSeverityAction, hitlRequiredApproverCount, isBudgetExceptionActive, isBudgetExceptionTerminal, isEscalationSlaBreached, isFreezeActive, isImpersonationGrantUsable, isPolicySyncTerminal, isRegulatoryEscalationTerminal, isSandboxDiffPopulated, isSubstantiveSignalResponse, matchAnomalyRules, nonPassingControls, normalizeEvaluateRequest, normalizeEvaluateResponse, protect, protectCloseAction, protectDeploy, protectOrEscalate, protectPaymentRelease, protectShadow, protectToolCall, redactContext, reportProtectedAction, reportShadowEvent, requestOverride, requirePermit, scoreToRiskTier, serializeSignableContent, signedBytesFor, summarizeCrossOrgPermission, transitionDispute, transitionReversal, validateActionContext, validateLiabilityChain, verifyAuditBundle, verifyBundle, verifyClaimEvidenceLink, verifyEvidenceBundleStructure, verifyWebhook, verifyWebhookSignature, waitForEscalationApproval, withPermit, withinAutonomousCeiling };
7393
+ export { type AccessCertActionType, type AccessCertOptions, type AccessGovernanceEvent, type AccessGovernanceLogPage, type AccessGovernanceLogQuery, type AccessGovernanceLogSubClient, type ActionBundleInput, type ActionBundleReceipt, type ActionContext, type ActionDependency, type ActionDependencyResponse, type ActionFreeze, type ActionMetaContext, type ActionTypeOverrideStat, type ActorContext, type ActorOverrideStat, type AgentAuthorityDomain, type AgentEvaluationStatus, type AgentEvidenceRef, type AgentFindingSeverity, type AgentInvokerKind, type AgentSubjectKind, type AgentToolMode, type AgentToolOptions, type AmountThreshold, type AnomalyActionType, type AnomalyResponseEvent, type AnomalyResponseRule, type AnomalyType, ApiKeySelfResponse, type ApplyPolicySyncResponse, type ApprovalArtifactSlot, type ApprovalArtifactV1, type ApprovalConcentrationAnalysis, type ApprovalIssuer, type ApprovalPermit, type ApprovalProvenance, type ApprovalQuorumV1, type ApprovalReference, type ApprovalReviewer, type ApprovalRuntimeConfig, type ApprovalStatus, type ApproveBudgetExceptionRequest, type ApproverBreakdown, AtlaSentClient, AtlaSentClientOptions, AtlaSentDeniedError, AtlaSentError, type AuditBundle, type AuditChainFilters, type AuditChainPage, AuditEventsQuery, AuditEventsResult, AuditExportRequest, AuditExportResult, type AuthSubClient, type AuthenticateConnectorInput, type AuthenticateConnectorResponse, type AuthorityRecord, type AuthorizationDecision, type AuthorizeStreamHandlers, type AutonomousBoundsDenyCode, type AutonomousExecutionBounds, type AutonomousExecutionCheckResult, type AutonomousExecutionRecord, BCCAEClient, BEHAVIOR_SENSITIVE_CATEGORIES, BatchEvalItem, BatchEvalResponse, type BatchRecordReleaseOptions, type BccaeActorType, type BccaeClientOptions, type BccaeDeploymentEnv, type BccaeEvaluateInput, type BccaeEvaluateResponse, type BccaeEvidenceResponse, type BccaeExecuteInput, type BccaeExecuteResponse, type BccaeRequestSource, type BccaeResourceClassification, type BccaeRevocationTargetType, type BccaeRevokeInput, type BccaeRevokeResponse, type BccaeSecurityPosture, type BccaeTrustLevel, type BehaviorEventCategory, type BehaviorEventOptions, type BudgetConstraintCheckResult, type BudgetDenyCode, type BudgetExceptionRequest, type BudgetExceptionStatus, type BudgetLimit, type BudgetPolicy, type BudgetScope, type BudgetSpendingState, type BudgetViolation, type BudgetaryDriftAnalysis, type BuildActionContextInput, type BuildClaimEvidenceLinkOpts, type BuildFromActionBundleOpts, type BundleVerificationResult, type CAPAOptions, CONTEXT_NAMESPACES, CUSTOMER_DATA_EXPORT_ACTION, CanonicalProtectedActionType, type ChainIntegrityReport, type ClaimEvidenceLink, type ClinicalDataAccessOptions, type CloseActionType, type CloseGovernanceOptions, ComplianceEvidenceRun, type ComplianceExport, type ComputeOrgRiskOptions, type ComputeOrgRiskResponse, type ConcentrationAlert, type ConnectedSystemRow, type ConnectorAuditLogEntry, type ConnectorCredentialRow, type ConnectorCredentialType, type ConnectorEnforcementEventInput, type ConnectorEnforcementPolicy, type ConnectorEnforcementResult, type ConnectorRow, type ConnectorStatus, type ConnectorSyncState, type ConnectorType, type ContextEnvelope, type ContextNamespaceEntry, type ContextNamespaceKey, type ContextSignal, type ContextValidationError, type ContextValidationResult, type ContextValidationWarning, type ContractActionOptions, type ContractActionType, type ControlSurfaceConfig, type CreateActionDependencyRequest, type CreateAnomalyResponseRuleRequest, type CreateBudgetExceptionRequest, type CreateEscalationOptions, type CreateGraphEdgeInput, type CreateGraphNodeInput, type CreateImpersonationGrantRequest, type CreateRegulatoryEscalationRequest, type CreateWebhookSubscriptionRequest, type CrossOrgImpersonationGrant, type CrossOrgPermissionCheckListParams, type CrossOrgPermissionCheckRequest, type CrossOrgPermissionCheckResult, type CrossOrgTrustHop, type CurrencyCode, DEFAULT_INCENTIVE_CONFIG, DEFAULT_REDACTION_RULES, DEFAULT_RISK_TIER_THRESHOLDS, DEFAULT_TRUST_TTL_MS, DEPLOY_V1_ACTION, type DataDeleteActionType, type DataDeleteOptions, type DataExportOptions, type DatabaseActionOptions, type DatabaseActionType, type DatabaseDestructiveActionType, type DatabaseMigrationActionType, DecisionCanonical, DecisionReceipt, DecisionReceiptAlgorithm, DecisionStreamEvent, type DelegationPropagationSummary, type DeltaSlot, type DeltaStatus, type DenialEvidence, type DependencyLink, type DependencyRequirement, type DependencyStatus, type DeployEnvironment, type DeployEvidenceInput, type DeployEvidenceSlot, type DeployGateOptions, DeployGateRequest, DeployGateResponse, type DeploymentActionType, type DeploymentV2Options, type DisputeOrigin, type DisputeRecord, type DisputeReversalSummary, type DisputeStatus, type DriftChangeType, type DriftDetail, type DriftSeverity, type EconomicEvidenceBundle, type EmergencyFreeze, type EmergencyOverrideActionRow, type EnforcementAction, type EnforcementMode, type EnforcementQuorumConfig, type EnforcementStatus, type EnforcementWebhookEvent, type EngineVersionKind, type EngineVersionRecord, type EngineVersionResponse, type EngineVersionStatus, type EnvelopeDriftDetail, type EnvelopeVerification, type EnvironmentContext, EscalationDeniedError, type EscalationHandle, type EscalationOutcome, EscalationTimeoutError, type EvaluateBatchItem, type EvaluateBatchResponse, type EvaluateManyRequest, EvaluatePreflightResponse, EvaluateRequest, EvaluateResponse, type EvidenceBundle, type EvidenceBundleCreateParams, type EvidenceBundleListPage, type EvidenceBundleListParams, type EvidenceBundleSignableContent, type EvidenceBundleStatus, type EvidenceBundleSubClient, type EvidenceBundleVerificationResult, type EvidenceBundleVerifyResult, type EvidencePurpose, type EvidenceSlotStatus, type ExecutionAnomaly, type ExecutionApproverRow, type ExecutionCeiling, type ExecutionReceipt, FeatureNotEnabledError, type FeatureNotEnabledErrorInit, type FinancialActionClass, type FinancialActionType, type FinancialCloseActionType, type FinancialCloseOptions, type FinancialExecutionRecord, type FinancialExecutionStatus, type FinancialGovernanceSummary, type FinancialQuorumDenyCode, type FinancialQuorumInput, type FinancialQuorumPolicy, type FinancialQuorumResult, type FinancialRiskScore, type FinancialRiskTier, type FinancialRoleRequirement, type GdprLegalBasis, type GetEnforcementStatusOptions, type GetLatestOrgRiskResponse, GetPermitResponse, type GovernanceAgent, type GovernanceAgentEvaluation, type GovernanceAgentFinding, type GovernanceBehaviorPattern, GovernanceEnforcementError, type GovernanceEnforcementErrorInit, type GovernanceEvent, type GovernanceGate, type GovernanceGraphQueryParams, type GovernanceGraphQueryResponse, type GovernanceGraphQueryType, type GovernanceGraphResultRow, type GovernanceSignalAction, type GovernanceWebhookEvent, type GraphEdge, type GraphEdgeType, type GraphNode, type GraphNodeType, type GraphQLRequest, type GraphQLResponse, type GxpActionOptions, type GxpActionType, type HealthReport, type HistoricalContext, type HitlAiUnavailableFallback, type HitlApprovalRecord, type HitlApproveRequest, type HitlApproverPoolEntry, type HitlApproverType, type HitlChainHop, type HitlChainSummary, type HitlCreateRequest, type HitlDetailResponse, type HitlEscalation, type HitlFallbackDecision, type HitlHeterogeneousQuorumExtension, type HitlHeterogeneousQuorumTally, type HitlListResponse, type HitlQuorumProgress, type HitlQuorumTier, type HitlRejectRequest, type HitlRespondRequest, type HitlStatus, type HrActionOptions, type HrActionType, type IdentityAssertionBinding, type IdentityAssertionV1, type IdentityIssuer, type IdentityIssuerKey, type IdentitySubject, type IdentityTrustedIssuersConfig, type IdpConnection, type ImpersonationToken, type ImpersonationValidationResult, type IncentiveAlignmentConfig, type IncentiveSignal, type IncentiveSignalType, type IncidentChainActorEntry, type IncidentChainEvidenceRow, type IncidentChainExecutionRow, type IncidentTimelineResponse, type InfraActionOptions, type InfraActionType, type InstallConnectorInput, type InstallConnectorResponse, type IntegrationEvidenceSlot, type JWK, type LegacyEvaluateRequest, type LegacyEvaluateResponse, type LiabilityAttributionInput, type LiabilityAttributionRecord, type LiabilityChainValidation, type LiabilityClassification, type LiabilityEdge, type LiabilityNode, type LiabilityParty, type LiabilityPartyRole, type LiabilityVisualization, LicenseStatus, LicenseVerifyResult, type ListActionDependenciesResponse, type ListConnectorsResponse, type ListEnforcementPoliciesResponse, type ListEngineVersionsResponse, type ListGovernanceAgentsResponse, type ListGovernanceEvaluationsQuery, type ListGovernanceEvaluationsResponse, type ListGovernanceFindingsQuery, type ListGovernanceFindingsResponse, type ListGraphEdgesResponse, type ListGraphNodesResponse, type ListHitlEscalationsRequest, type ListHitlEscalationsResponse, type ListOrgRiskHistoryResponse, ListPermitsRequest, ListPermitsResponse, type ListPolicySyncRunsResponse, type ListWebhookDeliveriesResponse, type ListWebhookSubscriptionsResponse, type MisalignmentAlert, type ModelGovernanceActionType, type ModelGovernanceOptions, NOT_APPLICABLE, type NotApplicable, type OfflineEvidenceBundleData, type OrgRiskLevel, type OrgRiskScore, type OrgSummary, type OverrideAnalytics, OverrideV1, type PaymentOperationActionType, type PaymentOperationOptions, type PaymentReleaseOptions, Permit, type PermitEvidence, type PermitV1, PermitValidResponse, type PolicyBundleEntry, type PolicyRef, type PolicySyncDiff, type PolicySyncRun, type PolicySyncStatus, type PostExecutionResult, type PricingActionOptions, type PricingActionType, type PrincipalKind, type ProductionDeployerRow, type ProofEvaluationSummary, type ProofPayload, type ProofResponse, type ProtectOrEscalateOptions, ProtectRequest, type ProtectedAction, type ProtectedActionEntry, type QuorumBypassConnectorRow, type QuorumIndependence, type QuorumPolicy, type QuorumProof, type QuorumRoleRequirement, RateLimitState, type ReconciliationCertifyOptions, type RecordContextEnvelopeInput, type RecordSignalActionRequest, type RecordSignalOutcomeRequest, type RedactionMode, type RedactionRule, type RegisterEngineVersionRequest, type RegulatoryAuthorityLevel, type RegulatoryEscalation, type RegulatoryEscalationStatus, type ReplayDecisionResponse, type ReplayDecisionValue, type ReplayRequest, type ReplayResponse, type ReplayVarianceKind, type ReportProtectedActionOptions, type RequestOverrideOptions, type ResourceContext, type ReversalStage, type ReversalWorkflow, type RevokeConnectorResponse, RevokePermitByIdInput, RevokePermitByIdResponse, RevokePermitRequest, RevokePermitResponse, type RiskFactor, type RiskTierThreshold, type RiskTimelinePoint, type RotateCredentialsResponse, type RuntimeAuditEntry, type RuntimeEvidenceSlot, RuntimeV2Client, SCIM_GROUP_SCHEMA, SCIM_PATCH_OP_SCHEMA, SCIM_USER_SCHEMA, type SandboxDiff, type SandboxDiffEmpty, type SandboxDiffPerTable, type SandboxDiffResponse, type SandboxRunMode, type SandboxRunStatus, type SandboxRunWrite, type SandboxWriteOp, type ScimEmail, type ScimGroupRef, type ScimGroupsSubClient, type ScimListParams, type ScimListResponse, type ScimMeta, type ScimName, type ScimPatchOp, type ScimSubClient, type ScimUser, type ScimUserCreate, type ScimUserUpdate, type ScimUsersSubClient, type SecurityActionOptions, type SecurityActionType, type ShadowConfig, type ShadowEventPayload, type ShadowMode, type ShadowOptions, type ShadowOutcome, type SignalActionSummary, type SignalActionType, type SignedApprovalArtifact, type SnapshotSourceKind, type SpendingConstraint, type SsoConnection, type SsoConnectionInput, type SsoConnectionWire, type SsoEnforceAction, type SsoEnforceResult, type SsoEvent, type SsoEventWire, type SsoJitRule, type SsoJitRuleInput, type SsoJitRulePatch, type SsoJitRuleWire, type SsoReadiness, type SsoReadinessWire, type SsoRole, type SsoSubClient, type StateSnapshot, type StateSnapshotInput, type StateSnapshotRef, type StreamComplete, type StreamDecisionFrame, type StreamErrorFrame, StreamEvent, StreamOptions, type SubmitPolicySyncRequest, type SubmitPolicySyncResponse, SubscribeDecisionsOptions, type SyncConnectorResponse, type TokenResponse, type TriggerAnomalyResponseRequest, type TrustRootKey, TrustRootManager, type TrustRootManagerOptions, type TrustRootRevocationEntry, type TrustRootSnapshot, type TrustSnapshot, type UpsertEnforcementPolicyInput, type UpsertEnforcementPolicyResponse, type UserApprovalRow, type V2EvaluateRequest, type V2EvaluateResponse, type V2Feature, type V2Transport, V2_BATCH_PATH, V2_GRAPHQL_MAX_DEPTH, V2_GRAPHQL_PATH, V2_MAX_BATCH_ITEMS, V2_MAX_BODY_BYTES, V2_STREAM_PATH, VENDOR_PAYMENT_ACTION, VQPClient, type VQPClientOptions, type VQPGenerateInput, type VQPGenerateResponse, type VQPVerifyInput, type VQPVerifyResponse, type ValidateContextOptions, type VerificationChecklist, type VerificationFailure, type VerificationResult, type VerifyBundleOptions, type VerifyClaimEvidenceLinkOpts, type VerifyClaimEvidenceLinkResult, type VerifyKey, VerifyPermitByIdResponse, VerifyPermitRequest, VerifyPermitResponse, type VqpVerdict, type WaitForApprovalOptions, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookPayload, type WebhookSubscription, WebhookVerificationError, type WeightDistribution, __setGlobalTrustRootManagerForTests, _computeEvidenceRootHash, assertWebhook, authorizeStream, bootstrapTrust, budgetUtilizationSeverity, buildActionContext, buildClaimEvidenceLink, buildClaimEvidenceLinkFromActionBundle, buildLiabilityChain, buildLiabilityVisualization, buildRiskTimeline, buildSignableContent, canonicalJSON, canonicalizeForEvidence, checkAutonomousBounds, checkBudgetConstraints, checkIntegrationHealth, clampTokenDuration, classifyCommand, classifyRiskTier, classifyToolRisk, computeApprovalRiskScore, computeEscalatedApprovalCount, computeExposureScore, computeGovernanceHealthScore, computeHHI, computeLiabilityWeights, computeOverallRiskScore, computeOverrideScore, computeRemediationUrgency, computeSignalEngagementRate, configure, configureApprovalRuntime, configureControlSurface, configureShadow, createEscalation, atlasent as default, delegationPropagationHadEffect, deployGate, detectAutonomousAnomaly, detectMisalignedIncentives, detectSelfApproval, enforceAutonomousBounds, enforceBudgetConstraint, enforceEconomicGovernance, enforceFinancialQuorum, evaluateFinancialQuorum, evaluateMany, findPrimaryLiabilityParties, flattenActionContext, formatPolicySyncDiff, generateBccaeNonce, getEnforcementStatus, getGlobalTrustRootManager, getOrgSummary, graphql, hhiToConcentrationScore, highestAgentFindingSeverity, highestSeverityAction, hitlRequiredApproverCount, isBudgetExceptionActive, isBudgetExceptionTerminal, isEscalationSlaBreached, isFreezeActive, isImpersonationGrantUsable, isKidRevoked, isPolicySyncTerminal, isRegulatoryEscalationTerminal, isSandboxDiffPopulated, isSubstantiveSignalResponse, isTrustSnapshotExpired, makeAccessGovernanceLogClient, makeAuthClient, makeEvidenceBundleClient, makeScimClient, makeSsoClient, matchAnomalyRules, normalizeEvaluateRequest, normalizeEvaluateResponse, protect, protectAccessCertAction, protectAccessCertRevoke, protectBatchRecordRelease, protectBehaviorEvent, protectCloseAction, protectContractAction, protectContractExecution, protectCustomerDataDelete, protectDataExport, protectDatabaseAction, protectDatabaseMigration, protectDatabaseSchemaDrop, protectDatabaseTableDelete, protectDeploy, protectDeploymentV2, protectFinancialCloseAction, protectGxpAction, protectHrAction, protectHrOffboard, protectHrRoleEscalate, protectInfraAction, protectModelGovernance, protectModelPromotion, protectOrEscalate, protectPaymentOperation, protectPaymentRelease, protectPeriodCloseCertify, protectPricingAction, protectPricingRule, protectReconciliationCertify, protectSecurityAccessQuarantine, protectSecurityAction, protectSecurityIncidentEscalate, protectShadow, protectToolCall, redactContext, reportProtectedAction, reportShadowEvent, requestOverride, requirePermit, scoreToRiskTier, serializeSignableContent, signedBytesFor, summarizeCrossOrgPermission, transitionDispute, transitionReversal, validateActionContext, validateLiabilityChain, verifyAuditBundle, verifyBundle, verifyClaimEvidenceLink, verifyEvidenceBundle, verifyEvidenceBundleStructure, verifyWebhook, verifyWebhookSignature, waitForEscalationApproval, wireToSsoConnection, wireToSsoEvent, wireToSsoJitRule, wireToSsoReadiness, withPermit, withinAutonomousCeiling };