aira-sdk 3.0.0 → 3.2.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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Authorization, ActionReceipt, ActionDetail, AgentDetail, AgentVersion, CosignResult, EvidencePackage, ComplianceSnapshot, EscrowAccount, EscrowTransaction, VerifyResult, PaginatedList, ComplianceReport, ComplianceReportListResponse, ComplianceReportVerification, ActionExplanation, ExplanationVerification, OutputPolicy, OutputPolicyUpdate } from "./types";
1
+ import { Authorization, ActionReceipt, ActionDetail, AgentDetail, AgentVersion, CosignResult, EvidencePackage, ComplianceSnapshot, EscrowAccount, EscrowTransaction, VerifyResult, PaginatedList, ComplianceReport, ComplianceReportListResponse, ComplianceReportVerification, ActionExplanation, ExplanationVerification, OutputPolicy, OutputPolicyUpdate, DoraIncident, IctThirdParty, DoraTest } from "./types";
2
2
  import { AiraSession } from "./session";
3
3
  export interface AiraOptions {
4
4
  apiKey: string;
@@ -326,6 +326,103 @@ export declare class Aira {
326
326
  * required server-side.
327
327
  */
328
328
  updateOutputPolicy(updates: OutputPolicyUpdate): Promise<OutputPolicy>;
329
+ /** Open a new DORA ICT incident (Article 17). */
330
+ createDoraIncident(params: {
331
+ title: string;
332
+ description: string;
333
+ detectedAt: string;
334
+ affectedServices?: string[];
335
+ clientsAffectedCount?: number;
336
+ geographicScope?: string[];
337
+ relatedActionUuids?: string[];
338
+ }): Promise<DoraIncident>;
339
+ /** List DORA incidents with optional filters. */
340
+ listDoraIncidents(params?: {
341
+ status?: string;
342
+ severity?: string;
343
+ isMajor?: boolean;
344
+ limit?: number;
345
+ offset?: number;
346
+ }): Promise<{
347
+ items: DoraIncident[];
348
+ total: number;
349
+ limit: number;
350
+ offset: number;
351
+ request_id: string;
352
+ }>;
353
+ /** Get one DORA incident. */
354
+ getDoraIncident(incidentUuid: string): Promise<DoraIncident>;
355
+ /** Classify a detected incident (Article 18). */
356
+ classifyDoraIncident(incidentUuid: string, params: {
357
+ severity: "critical" | "high" | "medium" | "low";
358
+ category: string;
359
+ isMajor?: boolean;
360
+ rootCauseSummary?: string;
361
+ rootCauseClassification?: string;
362
+ thirdPartyUuid?: string;
363
+ }): Promise<DoraIncident>;
364
+ /** Mark an incident resolved + record post-mortem fields. */
365
+ resolveDoraIncident(incidentUuid: string, params: {
366
+ resolutionSummary: string;
367
+ lessonsLearned?: string;
368
+ resolvedAt?: string;
369
+ }): Promise<DoraIncident>;
370
+ /** Generate (if needed) and download the major-incident PDF for ESA submission. */
371
+ downloadDoraIncidentReport(incidentUuid: string): Promise<Uint8Array>;
372
+ /** Add a vendor to the ICT third-party register (Article 28). */
373
+ createIctThirdParty(params: {
374
+ vendorName: string;
375
+ serviceDescription: string;
376
+ serviceType: string;
377
+ criticality: "critical" | "non_critical" | "supporting";
378
+ contractStartDate?: string;
379
+ contractEndDate?: string;
380
+ exitStrategySummary?: string;
381
+ subcontractors?: string[];
382
+ dataCategories?: string[];
383
+ jurisdiction?: string;
384
+ }): Promise<IctThirdParty>;
385
+ /** List ICT third-party register entries. */
386
+ listIctThirdParties(params?: {
387
+ criticality?: string;
388
+ isActive?: boolean;
389
+ limit?: number;
390
+ offset?: number;
391
+ }): Promise<{
392
+ items: IctThirdParty[];
393
+ total: number;
394
+ limit: number;
395
+ offset: number;
396
+ request_id: string;
397
+ }>;
398
+ getIctThirdParty(thirdPartyUuid: string): Promise<IctThirdParty>;
399
+ /** PATCH semantics — only supplied fields change. */
400
+ updateIctThirdParty(thirdPartyUuid: string, fields: Partial<IctThirdParty> & {
401
+ is_active?: boolean;
402
+ }): Promise<IctThirdParty>;
403
+ /** Log a DORA resilience test (Articles 24-27). */
404
+ createDoraTest(params: {
405
+ testType: string;
406
+ title: string;
407
+ scope: string;
408
+ conductedAt: string;
409
+ conductedBy: string;
410
+ status: "passed" | "failed" | "partial";
411
+ findingsSummary?: string;
412
+ remediationPlan?: string;
413
+ remediationDueAt?: string;
414
+ }): Promise<DoraTest>;
415
+ listDoraTests(params?: {
416
+ testType?: string;
417
+ limit?: number;
418
+ offset?: number;
419
+ }): Promise<{
420
+ items: DoraTest[];
421
+ total: number;
422
+ limit: number;
423
+ offset: number;
424
+ request_id: string;
425
+ }>;
329
426
  /**
330
427
  * Article 6 right-to-explanation for a single action.
331
428
  *
package/dist/client.js CHANGED
@@ -624,6 +624,146 @@ class Aira {
624
624
  }
625
625
  return this.patch("/output-policies", body);
626
626
  }
627
+ // ==================== DORA (EU 2022/2554) ====================
628
+ /** Open a new DORA ICT incident (Article 17). */
629
+ async createDoraIncident(params) {
630
+ const body = buildBody({
631
+ title: params.title,
632
+ description: params.description,
633
+ detected_at: params.detectedAt,
634
+ affected_services: params.affectedServices,
635
+ clients_affected_count: params.clientsAffectedCount,
636
+ geographic_scope: params.geographicScope,
637
+ related_action_uuids: params.relatedActionUuids,
638
+ });
639
+ return this.post("/dora/incidents", body);
640
+ }
641
+ /** List DORA incidents with optional filters. */
642
+ async listDoraIncidents(params) {
643
+ const qs = new URLSearchParams();
644
+ if (params?.status)
645
+ qs.append("status", params.status);
646
+ if (params?.severity)
647
+ qs.append("severity", params.severity);
648
+ if (params?.isMajor !== undefined)
649
+ qs.append("is_major", String(params.isMajor));
650
+ if (params?.limit !== undefined)
651
+ qs.append("limit", String(params.limit));
652
+ if (params?.offset !== undefined)
653
+ qs.append("offset", String(params.offset));
654
+ const path = qs.toString() ? `/dora/incidents?${qs}` : "/dora/incidents";
655
+ return this.get(path);
656
+ }
657
+ /** Get one DORA incident. */
658
+ async getDoraIncident(incidentUuid) {
659
+ return this.get(`/dora/incidents/${incidentUuid}`);
660
+ }
661
+ /** Classify a detected incident (Article 18). */
662
+ async classifyDoraIncident(incidentUuid, params) {
663
+ const body = buildBody({
664
+ severity: params.severity,
665
+ category: params.category,
666
+ is_major: params.isMajor,
667
+ root_cause_summary: params.rootCauseSummary,
668
+ root_cause_classification: params.rootCauseClassification,
669
+ third_party_uuid: params.thirdPartyUuid,
670
+ });
671
+ return this.put(`/dora/incidents/${incidentUuid}/classify`, body);
672
+ }
673
+ /** Mark an incident resolved + record post-mortem fields. */
674
+ async resolveDoraIncident(incidentUuid, params) {
675
+ const body = buildBody({
676
+ resolution_summary: params.resolutionSummary,
677
+ lessons_learned: params.lessonsLearned,
678
+ resolved_at: params.resolvedAt,
679
+ });
680
+ return this.put(`/dora/incidents/${incidentUuid}/resolve`, body);
681
+ }
682
+ /** Generate (if needed) and download the major-incident PDF for ESA submission. */
683
+ async downloadDoraIncidentReport(incidentUuid) {
684
+ if (this.queue) {
685
+ throw new types_1.AiraError(0, "OFFLINE", "Downloads not available offline");
686
+ }
687
+ const controller = new AbortController();
688
+ const timer = setTimeout(() => controller.abort(), this.timeout);
689
+ try {
690
+ const res = await fetchWithRetry(() => fetch(`${this.baseUrl}/dora/incidents/${incidentUuid}/report`, {
691
+ method: "GET",
692
+ headers: { Authorization: `Bearer ${this.apiKey}` },
693
+ signal: controller.signal,
694
+ }));
695
+ if (!res.ok) {
696
+ throw new types_1.AiraError(res.status, "DOWNLOAD_FAILED", res.statusText);
697
+ }
698
+ return new Uint8Array(await res.arrayBuffer());
699
+ }
700
+ finally {
701
+ clearTimeout(timer);
702
+ }
703
+ }
704
+ /** Add a vendor to the ICT third-party register (Article 28). */
705
+ async createIctThirdParty(params) {
706
+ const body = buildBody({
707
+ vendor_name: params.vendorName,
708
+ service_description: params.serviceDescription,
709
+ service_type: params.serviceType,
710
+ criticality: params.criticality,
711
+ contract_start_date: params.contractStartDate,
712
+ contract_end_date: params.contractEndDate,
713
+ exit_strategy_summary: params.exitStrategySummary,
714
+ subcontractors: params.subcontractors,
715
+ data_categories: params.dataCategories,
716
+ jurisdiction: params.jurisdiction,
717
+ });
718
+ return this.post("/dora/third-parties", body);
719
+ }
720
+ /** List ICT third-party register entries. */
721
+ async listIctThirdParties(params) {
722
+ const qs = new URLSearchParams();
723
+ if (params?.criticality)
724
+ qs.append("criticality", params.criticality);
725
+ if (params?.isActive !== undefined)
726
+ qs.append("is_active", String(params.isActive));
727
+ if (params?.limit !== undefined)
728
+ qs.append("limit", String(params.limit));
729
+ if (params?.offset !== undefined)
730
+ qs.append("offset", String(params.offset));
731
+ const path = qs.toString() ? `/dora/third-parties?${qs}` : "/dora/third-parties";
732
+ return this.get(path);
733
+ }
734
+ async getIctThirdParty(thirdPartyUuid) {
735
+ return this.get(`/dora/third-parties/${thirdPartyUuid}`);
736
+ }
737
+ /** PATCH semantics — only supplied fields change. */
738
+ async updateIctThirdParty(thirdPartyUuid, fields) {
739
+ return this.put(`/dora/third-parties/${thirdPartyUuid}`, fields);
740
+ }
741
+ /** Log a DORA resilience test (Articles 24-27). */
742
+ async createDoraTest(params) {
743
+ const body = buildBody({
744
+ test_type: params.testType,
745
+ title: params.title,
746
+ scope: params.scope,
747
+ conducted_at: params.conductedAt,
748
+ conducted_by: params.conductedBy,
749
+ status: params.status,
750
+ findings_summary: params.findingsSummary,
751
+ remediation_plan: params.remediationPlan,
752
+ remediation_due_at: params.remediationDueAt,
753
+ });
754
+ return this.post("/dora/tests", body);
755
+ }
756
+ async listDoraTests(params) {
757
+ const qs = new URLSearchParams();
758
+ if (params?.testType)
759
+ qs.append("test_type", params.testType);
760
+ if (params?.limit !== undefined)
761
+ qs.append("limit", String(params.limit));
762
+ if (params?.offset !== undefined)
763
+ qs.append("offset", String(params.offset));
764
+ const path = qs.toString() ? `/dora/tests?${qs}` : "/dora/tests";
765
+ return this.get(path);
766
+ }
627
767
  /**
628
768
  * Article 6 right-to-explanation for a single action.
629
769
  *
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Helpers for routing LLM SDK calls through Aira Gateway.
3
+ *
4
+ * Usage (OpenAI):
5
+ * import OpenAI from "openai";
6
+ * import { gatewayOpenAIConfig } from "aira-sdk/gateway";
7
+ * const client = new OpenAI({
8
+ * ...gatewayOpenAIConfig({ airaApiKey: "aira_live_..." }),
9
+ * apiKey: "sk-...",
10
+ * });
11
+ *
12
+ * Usage (Anthropic):
13
+ * import Anthropic from "@anthropic-ai/sdk";
14
+ * import { gatewayAnthropicConfig } from "aira-sdk/gateway";
15
+ * const client = new Anthropic({
16
+ * ...gatewayAnthropicConfig({ airaApiKey: "aira_live_..." }),
17
+ * apiKey: "sk-ant-...",
18
+ * });
19
+ */
20
+ export declare function gatewayOpenAIConfig(opts: {
21
+ airaApiKey: string;
22
+ gatewayUrl?: string;
23
+ }): {
24
+ baseURL: string;
25
+ defaultHeaders: Record<string, string>;
26
+ };
27
+ export declare function gatewayAnthropicConfig(opts: {
28
+ airaApiKey: string;
29
+ gatewayUrl?: string;
30
+ }): {
31
+ baseURL: string;
32
+ defaultHeaders: Record<string, string>;
33
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Helpers for routing LLM SDK calls through Aira Gateway.
4
+ *
5
+ * Usage (OpenAI):
6
+ * import OpenAI from "openai";
7
+ * import { gatewayOpenAIConfig } from "aira-sdk/gateway";
8
+ * const client = new OpenAI({
9
+ * ...gatewayOpenAIConfig({ airaApiKey: "aira_live_..." }),
10
+ * apiKey: "sk-...",
11
+ * });
12
+ *
13
+ * Usage (Anthropic):
14
+ * import Anthropic from "@anthropic-ai/sdk";
15
+ * import { gatewayAnthropicConfig } from "aira-sdk/gateway";
16
+ * const client = new Anthropic({
17
+ * ...gatewayAnthropicConfig({ airaApiKey: "aira_live_..." }),
18
+ * apiKey: "sk-ant-...",
19
+ * });
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.gatewayOpenAIConfig = gatewayOpenAIConfig;
23
+ exports.gatewayAnthropicConfig = gatewayAnthropicConfig;
24
+ const DEFAULT_GATEWAY_URL = "https://api.airaproof.com";
25
+ function gatewayOpenAIConfig(opts) {
26
+ const base = (opts.gatewayUrl ?? DEFAULT_GATEWAY_URL).replace(/\/$/, "");
27
+ return {
28
+ baseURL: `${base}/gateway/openai/v1`,
29
+ defaultHeaders: { "X-Aira-Api-Key": opts.airaApiKey },
30
+ };
31
+ }
32
+ function gatewayAnthropicConfig(opts) {
33
+ const base = (opts.gatewayUrl ?? DEFAULT_GATEWAY_URL).replace(/\/$/, "");
34
+ return {
35
+ baseURL: `${base}/gateway/anthropic/v1`,
36
+ defaultHeaders: { "X-Aira-Api-Key": opts.airaApiKey },
37
+ };
38
+ }
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export type { AiraOptions } from "./client";
3
3
  export { AiraSession } from "./session";
4
4
  export { OfflineQueue } from "./offline";
5
5
  export type { QueuedRequest } from "./offline";
6
- export { AiraError, FRAMEWORK_ANNEX_IV, FRAMEWORK_ART12, FRAMEWORK_ART9, FRAMEWORK_ART6, type Authorization, type ActionReceipt, type ActionDetail, type AgentDetail, type AgentVersion, type CosignResult, type EvidencePackage, type ComplianceSnapshot, type EscrowAccount, type EscrowTransaction, type VerifyResult, type PaginatedList, type ComplianceReport, type ComplianceReportListResponse, type ComplianceReportVerification, type ActionExplanation, type ExplanationEnvelope, type ExplanationVerification, type OutputPolicy, type OutputPolicyUpdate, type OutputScanFlags, type OutputScanHit, } from "./types";
6
+ export { gatewayOpenAIConfig, gatewayAnthropicConfig } from "./gateway";
7
+ export { AiraError, FRAMEWORK_ANNEX_IV, FRAMEWORK_ART12, FRAMEWORK_ART9, FRAMEWORK_ART6, type Authorization, type ActionReceipt, type ActionDetail, type AgentDetail, type AgentVersion, type CosignResult, type EvidencePackage, type ComplianceSnapshot, type EscrowAccount, type EscrowTransaction, type VerifyResult, type PaginatedList, type ComplianceReport, type ComplianceReportListResponse, type ComplianceReportVerification, type ActionExplanation, type ExplanationEnvelope, type ExplanationVerification, type OutputPolicy, type OutputPolicyUpdate, type OutputScanFlags, type OutputScanHit, type DoraIncident, type IctThirdParty, type DoraTest, } from "./types";
package/dist/index.js CHANGED
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FRAMEWORK_ART6 = exports.FRAMEWORK_ART9 = exports.FRAMEWORK_ART12 = exports.FRAMEWORK_ANNEX_IV = exports.AiraError = exports.OfflineQueue = exports.AiraSession = exports.Aira = void 0;
3
+ exports.FRAMEWORK_ART6 = exports.FRAMEWORK_ART9 = exports.FRAMEWORK_ART12 = exports.FRAMEWORK_ANNEX_IV = exports.AiraError = exports.gatewayAnthropicConfig = exports.gatewayOpenAIConfig = exports.OfflineQueue = exports.AiraSession = exports.Aira = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "Aira", { enumerable: true, get: function () { return client_1.Aira; } });
6
6
  var session_1 = require("./session");
7
7
  Object.defineProperty(exports, "AiraSession", { enumerable: true, get: function () { return session_1.AiraSession; } });
8
8
  var offline_1 = require("./offline");
9
9
  Object.defineProperty(exports, "OfflineQueue", { enumerable: true, get: function () { return offline_1.OfflineQueue; } });
10
+ var gateway_1 = require("./gateway");
11
+ Object.defineProperty(exports, "gatewayOpenAIConfig", { enumerable: true, get: function () { return gateway_1.gatewayOpenAIConfig; } });
12
+ Object.defineProperty(exports, "gatewayAnthropicConfig", { enumerable: true, get: function () { return gateway_1.gatewayAnthropicConfig; } });
10
13
  var types_1 = require("./types");
11
14
  Object.defineProperty(exports, "AiraError", { enumerable: true, get: function () { return types_1.AiraError; } });
12
15
  Object.defineProperty(exports, "FRAMEWORK_ANNEX_IV", { enumerable: true, get: function () { return types_1.FRAMEWORK_ANNEX_IV; } });
package/dist/types.d.ts CHANGED
@@ -72,6 +72,62 @@ export interface OutputPolicy {
72
72
  redact_severity_threshold: "info" | "warning" | "critical";
73
73
  request_id: string;
74
74
  }
75
+ export interface DoraIncident {
76
+ uuid: string;
77
+ title: string;
78
+ status: "detected" | "classified" | "resolved" | "reported";
79
+ severity: "critical" | "high" | "medium" | "low" | null;
80
+ category: string | null;
81
+ is_major: boolean;
82
+ detected_at: string;
83
+ classified_at: string | null;
84
+ resolved_at: string | null;
85
+ reported_at: string | null;
86
+ clients_affected_count: number;
87
+ has_report: boolean;
88
+ created_at: string;
89
+ org_uuid?: string | null;
90
+ description?: string | null;
91
+ affected_services?: string[] | null;
92
+ geographic_scope?: string[] | null;
93
+ root_cause_summary?: string | null;
94
+ root_cause_classification?: string | null;
95
+ third_party_uuid?: string | null;
96
+ resolution_summary?: string | null;
97
+ lessons_learned?: string | null;
98
+ related_action_uuids?: string[] | null;
99
+ report_content_hash?: string | null;
100
+ report_signature?: string | null;
101
+ report_signing_key_id?: string | null;
102
+ report_signed_at?: string | null;
103
+ report_pdf_size_bytes?: number | null;
104
+ request_id?: string;
105
+ }
106
+ export interface IctThirdParty {
107
+ uuid: string;
108
+ org_uuid: string;
109
+ vendor_name: string;
110
+ service_description: string;
111
+ service_type: string;
112
+ criticality: "critical" | "non_critical" | "supporting";
113
+ contract_start_date: string | null;
114
+ contract_end_date: string | null;
115
+ exit_strategy_summary: string | null;
116
+ subcontractors: string[] | null;
117
+ data_categories: string[] | null;
118
+ jurisdiction: string | null;
119
+ is_active: boolean;
120
+ created_at: string;
121
+ request_id?: string;
122
+ }
123
+ export interface DoraTest {
124
+ uuid: string;
125
+ test_type: string;
126
+ title: string;
127
+ conducted_at: string;
128
+ conducted_by: string;
129
+ status: "passed" | "failed" | "partial";
130
+ }
75
131
  export interface OutputPolicyUpdate {
76
132
  enabled?: boolean;
77
133
  mode?: "flag" | "deny" | "redact";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aira-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.2.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",
@@ -9,6 +9,10 @@
9
9
  "types": "./dist/index.d.ts",
10
10
  "default": "./dist/index.js"
11
11
  },
12
+ "./gateway": {
13
+ "types": "./dist/gateway.d.ts",
14
+ "default": "./dist/gateway.js"
15
+ },
12
16
  "./extras/langchain": {
13
17
  "types": "./dist/extras/langchain.d.ts",
14
18
  "default": "./dist/extras/langchain.js"