aira-sdk 1.0.0 → 2.4.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/types.d.ts CHANGED
@@ -1,27 +1,88 @@
1
- /** Cryptographic receipt from notarizing an action. */
1
+ /**
2
+ * Compliance framework identifiers — string values accepted by
3
+ * `Aira.createComplianceReport()` and returned on `ComplianceReport.framework`.
4
+ * Import these constants rather than hard-coding the wire strings so
5
+ * callers stay in lockstep with the backend if a name ever changes.
6
+ */
7
+ export declare const FRAMEWORK_ART12: "eu_ai_act_art12";
8
+ export declare const FRAMEWORK_ART9: "eu_ai_act_art9";
9
+ export declare const FRAMEWORK_ART6: "eu_ai_act_art6";
10
+ export declare const FRAMEWORK_ANNEX_IV: "eu_ai_act_annex_iv";
11
+ /**
12
+ * Authorization result from `authorize()` — Step 1 of the two-step flow.
13
+ *
14
+ * Status tells you what to do next:
15
+ * - "authorized" → execute the action, then call `notarize()`
16
+ * - "pending_approval" → enqueue the action_id and wait for human approval
17
+ *
18
+ * POLICY_DENIED is raised as an `AiraError` — not returned as a status.
19
+ */
20
+ export interface Authorization {
21
+ action_id: string;
22
+ status: "authorized" | "pending_approval";
23
+ created_at: string;
24
+ request_id: string;
25
+ warnings: string[] | null;
26
+ }
27
+ /**
28
+ * Cryptographic receipt from notarizing an action — Step 2 of the two-step flow.
29
+ *
30
+ * Only populated when `status === "notarized"`. For "failed" outcomes,
31
+ * the receipt fields stay null — only the audit trail is recorded.
32
+ */
2
33
  export interface ActionReceipt {
3
34
  action_id: string;
4
- receipt_id?: string;
5
- payload_hash?: string;
6
- signature?: string;
7
- timestamp_token?: string | null;
35
+ status: "notarized" | "failed";
8
36
  created_at: string;
9
37
  request_id: string;
10
- status?: string;
11
- action_type?: string;
12
- agent_id?: string | null;
13
- warnings?: string[] | null;
14
- policy_evaluation?: {
15
- policy_id: string;
16
- policy_name: string;
17
- decision: string;
18
- reasoning: string | null;
19
- confidence: number | null;
20
- } | null;
38
+ receipt_id: string | null;
39
+ payload_hash: string | null;
40
+ signature: string | null;
41
+ timestamp_token: string | null;
42
+ /**
43
+ * Output content-scan result attached at notarize time when the
44
+ * org has an output policy enabled. ``null`` when output filtering
45
+ * is off (global flag or per-org).
46
+ */
47
+ output_scan_flags?: OutputScanFlags | null;
48
+ warnings: string[] | null;
49
+ }
50
+ export interface OutputScanHit {
51
+ name: string;
52
+ library: string;
53
+ severity: "info" | "warning" | "critical";
54
+ description: string;
55
+ matches: number;
56
+ /** Always `"[REDACTED]"` — the matched fragment never travels. */
57
+ sample: string;
58
+ }
59
+ export interface OutputScanFlags {
60
+ scanned_at: string;
61
+ libraries: string[];
62
+ mode: "flag" | "deny" | "redact";
63
+ decision: "allow" | "require_approval" | "deny";
64
+ worst_severity: "info" | "warning" | "critical" | null;
65
+ hits: OutputScanHit[];
66
+ }
67
+ export interface OutputPolicy {
68
+ enabled: boolean;
69
+ mode: "flag" | "deny" | "redact";
70
+ libraries: string[];
71
+ deny_severity_threshold: "info" | "warning" | "critical";
72
+ redact_severity_threshold: "info" | "warning" | "critical";
73
+ request_id: string;
74
+ }
75
+ export interface OutputPolicyUpdate {
76
+ enabled?: boolean;
77
+ mode?: "flag" | "deny" | "redact";
78
+ libraries?: string[];
79
+ deny_severity_threshold?: "info" | "warning" | "critical";
80
+ redact_severity_threshold?: "info" | "warning" | "critical";
21
81
  }
22
82
  /** Full action details including receipt and authorizations. */
23
83
  export interface ActionDetail {
24
84
  action_id: string;
85
+ org_id: string;
25
86
  action_type: string;
26
87
  action_details_hash: string;
27
88
  agent_id: string | null;
@@ -39,6 +100,7 @@ export interface ActionDetail {
39
100
  timestamp_token: string | null;
40
101
  receipt_version: string;
41
102
  verify_url: string;
103
+ created_at: string | null;
42
104
  } | null;
43
105
  authorizations: {
44
106
  id: string;
@@ -46,6 +108,10 @@ export interface ActionDetail {
46
108
  authorized_at: string | null;
47
109
  }[];
48
110
  request_id: string;
111
+ system_prompt_hash?: string | null;
112
+ tool_inputs_hash?: string | null;
113
+ model_params?: Record<string, unknown> | null;
114
+ execution_env?: Record<string, unknown> | null;
49
115
  }
50
116
  /** Registered agent identity. */
51
117
  export interface AgentDetail {
@@ -125,7 +191,18 @@ export interface EscrowTransaction {
125
191
  description?: string | null;
126
192
  reference_action_id?: string | null;
127
193
  }
128
- /** Public verification result. */
194
+ /**
195
+ * Result of a public action receipt verification.
196
+ *
197
+ * The endpoint actually recomputes the SHA-256 hash and verifies the
198
+ * Ed25519 signature against the published public key — `valid` is the
199
+ * result of that real cryptographic check, not just an existence check.
200
+ *
201
+ * On a successful (or tamper-detected) verification the result includes
202
+ * the full evidence — `signature`, `public_key`, `signed_payload`,
203
+ * `timestamp_token` — so an external auditor can re-run the same check
204
+ * with OpenSSL or any Ed25519 library without trusting Aira's verdict.
205
+ */
129
206
  export interface VerifyResult {
130
207
  valid: boolean;
131
208
  public_key_id: string;
@@ -134,6 +211,17 @@ export interface VerifyResult {
134
211
  request_id: string;
135
212
  receipt_id?: string | null;
136
213
  action_id?: string | null;
214
+ payload_hash?: string | null;
215
+ signature?: string | null;
216
+ public_key?: string | null;
217
+ algorithm?: string | null;
218
+ timestamp_token?: string | null;
219
+ signed_payload?: Record<string, unknown> | null;
220
+ policy_evaluator_attestation?: {
221
+ evaluator_key_id: string;
222
+ signature: string;
223
+ payload_hash: string;
224
+ } | null;
137
225
  }
138
226
  /** Paginated list response. */
139
227
  export interface PaginatedList<T = Record<string, unknown>> {
@@ -143,9 +231,98 @@ export interface PaginatedList<T = Record<string, unknown>> {
143
231
  per_page: number;
144
232
  has_more: boolean;
145
233
  }
146
- /** Aira API error. */
234
+ /**
235
+ * Human co-signature on an action.
236
+ *
237
+ * Returned by `Aira.cosign()`. Records that a specific human has
238
+ * acknowledged or signed off on an action that was already authorized
239
+ * (and optionally already notarized).
240
+ */
241
+ export interface CosignResult {
242
+ cosignature_id: string;
243
+ action_id: string;
244
+ cosigner_email: string;
245
+ cosigned_at: string;
246
+ request_id: string;
247
+ }
248
+ /**
249
+ * Aira API error.
250
+ *
251
+ * There is a single error type — catch `AiraError` and branch on
252
+ * `e.code` (`"POLICY_DENIED"`, `"INVALID_STATE"`, `"NOT_FOUND"`, ...).
253
+ * There are no subclasses per error code.
254
+ */
147
255
  export declare class AiraError extends Error {
148
- status: number;
256
+ /** HTTP status code from the backend response. */
257
+ statusCode: number;
258
+ /** Error code string (e.g. "POLICY_DENIED", "INVALID_STATE"). */
149
259
  code: string;
150
- constructor(status: number, code: string, message: string);
260
+ /** Optional backend-supplied context (policy_id, action_id, etc.). */
261
+ details: Record<string, unknown>;
262
+ constructor(statusCode: number, code: string, message: string, details?: Record<string, unknown>);
263
+ }
264
+ export interface ComplianceReport {
265
+ id: string;
266
+ framework: string;
267
+ status: "pending" | "generating" | "ready" | "failed";
268
+ created_at: string;
269
+ request_id?: string;
270
+ org_id?: string;
271
+ period_start?: string | null;
272
+ period_end?: string | null;
273
+ action_id?: string | null;
274
+ agent_filter?: string[] | null;
275
+ receipt_count?: number | null;
276
+ pdf_size_bytes?: number | null;
277
+ content_hash?: string | null;
278
+ signature?: string | null;
279
+ signing_key_id?: string | null;
280
+ timestamp_token?: string | null;
281
+ timestamp_token_present?: boolean;
282
+ report_metadata?: Record<string, unknown> | null;
283
+ error_message?: string | null;
284
+ generated_at?: string | null;
285
+ }
286
+ export interface ComplianceReportListResponse {
287
+ items: ComplianceReport[];
288
+ total: number;
289
+ limit: number;
290
+ offset: number;
291
+ request_id: string;
292
+ }
293
+ export interface ComplianceReportVerification {
294
+ report_id: string;
295
+ valid: boolean;
296
+ checks: Record<string, unknown>;
297
+ descriptor?: Record<string, unknown> | null;
298
+ request_id: string;
299
+ }
300
+ export interface ExplanationEnvelope {
301
+ alg: string;
302
+ signing_key_id: string;
303
+ content_hash: string;
304
+ signature: string;
305
+ generated_at: string;
306
+ }
307
+ export interface ActionExplanation {
308
+ action: Record<string, unknown>;
309
+ policy_chain: Array<Record<string, unknown>>;
310
+ approval_chain: Array<Record<string, unknown>>;
311
+ receipt?: Record<string, unknown> | null;
312
+ regulation: Record<string, unknown>;
313
+ /**
314
+ * Ed25519 signature over the canonical JSON of every field above
315
+ * (except ``_envelope`` itself and ``request_id``). The on-wire key
316
+ * is ``_envelope`` — the SDK exposes it under the same name so a
317
+ * saved ``JSON.stringify(explanation)`` round-trips through
318
+ * :meth:`Aira.verifyActionExplanation` untouched.
319
+ */
320
+ _envelope?: ExplanationEnvelope;
321
+ request_id: string;
322
+ }
323
+ export interface ExplanationVerification {
324
+ valid: boolean;
325
+ checks: Record<string, unknown>;
326
+ signing_key_id?: string | null;
327
+ request_id: string;
151
328
  }
package/dist/types.js CHANGED
@@ -1,15 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AiraError = void 0;
4
- /** Aira API error. */
3
+ exports.AiraError = exports.FRAMEWORK_ANNEX_IV = exports.FRAMEWORK_ART6 = exports.FRAMEWORK_ART9 = exports.FRAMEWORK_ART12 = void 0;
4
+ /**
5
+ * Compliance framework identifiers — string values accepted by
6
+ * `Aira.createComplianceReport()` and returned on `ComplianceReport.framework`.
7
+ * Import these constants rather than hard-coding the wire strings so
8
+ * callers stay in lockstep with the backend if a name ever changes.
9
+ */
10
+ exports.FRAMEWORK_ART12 = "eu_ai_act_art12";
11
+ exports.FRAMEWORK_ART9 = "eu_ai_act_art9";
12
+ exports.FRAMEWORK_ART6 = "eu_ai_act_art6";
13
+ exports.FRAMEWORK_ANNEX_IV = "eu_ai_act_annex_iv";
14
+ /**
15
+ * Aira API error.
16
+ *
17
+ * There is a single error type — catch `AiraError` and branch on
18
+ * `e.code` (`"POLICY_DENIED"`, `"INVALID_STATE"`, `"NOT_FOUND"`, ...).
19
+ * There are no subclasses per error code.
20
+ */
5
21
  class AiraError extends Error {
6
- status;
22
+ /** HTTP status code from the backend response. */
23
+ statusCode;
24
+ /** Error code string (e.g. "POLICY_DENIED", "INVALID_STATE"). */
7
25
  code;
8
- constructor(status, code, message) {
26
+ /** Optional backend-supplied context (policy_id, action_id, etc.). */
27
+ details;
28
+ constructor(statusCode, code, message, details = {}) {
9
29
  super(`[${code}] ${message}`);
10
30
  this.name = "AiraError";
11
- this.status = status;
31
+ this.statusCode = statusCode;
12
32
  this.code = code;
33
+ this.details = details;
13
34
  }
14
35
  }
15
36
  exports.AiraError = AiraError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aira-sdk",
3
- "version": "1.0.0",
3
+ "version": "2.4.0",
4
4
  "description": "The authorization and audit layer for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",