aira-sdk 0.1.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/LICENSE +21 -0
- package/README.md +198 -0
- package/dist/client.d.ts +129 -0
- package/dist/client.js +254 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/types.d.ts +123 -0
- package/dist/types.js +15 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aira (Softure UG)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Aira TypeScript SDK
|
|
2
|
+
|
|
3
|
+
**Legal infrastructure for AI agents.** Cryptographic proof for every action your AI agent takes.
|
|
4
|
+
|
|
5
|
+
Aira provides the accountability layer that autonomous AI agents need to operate in regulated environments. Every action is notarized with Ed25519 signatures and RFC 3161 timestamps — producing court-admissible proof that an action happened, who authorized it, and what decision was made.
|
|
6
|
+
|
|
7
|
+
**What you get:**
|
|
8
|
+
- **Notarize actions** — cryptographic receipts for every agent decision, email, transaction
|
|
9
|
+
- **Register agents** — verifiable identity with versioned configs and public profiles
|
|
10
|
+
- **Multi-model consensus** — run the same decision through multiple AI models, flag disagreements
|
|
11
|
+
- **Evidence packages** — sealed, tamper-proof bundles for legal discovery and audit
|
|
12
|
+
- **Agent lifecycle** — wills, succession plans, death certificates, compliance snapshots
|
|
13
|
+
- **Liability commitments** — record accountability commitments with cryptographic proof
|
|
14
|
+
- **Human authorization** — require human co-signatures on high-stakes actions
|
|
15
|
+
- **Public verification** — anyone can verify a receipt without an account
|
|
16
|
+
|
|
17
|
+
Built for EU AI Act, SR 11-7, and GDPR compliance. Self-hostable. Open-source SDK.
|
|
18
|
+
|
|
19
|
+
[](https://www.npmjs.com/package/aira-sdk)
|
|
20
|
+
[](https://opensource.org/licenses/MIT)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install aira-sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { Aira } from "aira-sdk";
|
|
30
|
+
|
|
31
|
+
const aira = new Aira({ apiKey: "aira_live_xxx" });
|
|
32
|
+
|
|
33
|
+
// Notarize an agent action
|
|
34
|
+
const receipt = await aira.notarize({
|
|
35
|
+
actionType: "email_sent",
|
|
36
|
+
details: "Sent onboarding email to customer@example.com",
|
|
37
|
+
agentId: "support-agent",
|
|
38
|
+
modelId: "claude-sonnet-4-6",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(receipt.signature); // ed25519:base64url...
|
|
42
|
+
console.log(receipt.action_id); // uuid
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Agent Registry
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
const agent = await aira.registerAgent({
|
|
49
|
+
agentSlug: "lending-agent",
|
|
50
|
+
displayName: "Loan Decision Engine",
|
|
51
|
+
capabilities: ["credit_scoring", "risk_assessment"],
|
|
52
|
+
public: true,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await aira.publishVersion("lending-agent", {
|
|
56
|
+
version: "1.0.0",
|
|
57
|
+
modelId: "claude-sonnet-4-6",
|
|
58
|
+
changelog: "Initial release",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const agents = await aira.listAgents();
|
|
62
|
+
console.log(agents.total); // 5
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Action Notarization
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Notarize with chain of custody
|
|
69
|
+
const decision = await aira.notarize({
|
|
70
|
+
actionType: "loan_approved",
|
|
71
|
+
details: "Approved loan #4521 for €25,000",
|
|
72
|
+
agentId: "lending-agent",
|
|
73
|
+
modelId: "claude-sonnet-4-6",
|
|
74
|
+
idempotencyKey: "loan-4521",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Chain a follow-up action
|
|
78
|
+
const email = await aira.notarize({
|
|
79
|
+
actionType: "email_sent",
|
|
80
|
+
details: "Sent approval notification",
|
|
81
|
+
agentId: "lending-agent",
|
|
82
|
+
parentActionId: decision.action_id,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Get chain of custody
|
|
86
|
+
const chain = await aira.getActionChain(decision.action_id);
|
|
87
|
+
|
|
88
|
+
// Human co-signature
|
|
89
|
+
await aira.authorizeAction(decision.action_id);
|
|
90
|
+
|
|
91
|
+
// Legal hold
|
|
92
|
+
await aira.setLegalHold(decision.action_id);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Multi-Model Consensus
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const result = await aira.runCase(
|
|
99
|
+
"Should we approve loan #4521?",
|
|
100
|
+
["claude-sonnet-4-6", "gpt-4o", "gemini-2.0-flash"],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
console.log(result.consensus.decision); // "APPROVE"
|
|
104
|
+
console.log(result.consensus.confidence); // 0.92
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Evidence Packages
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const pkg = await aira.createEvidencePackage({
|
|
111
|
+
title: "Q1 2026 Lending Audit",
|
|
112
|
+
actionIds: [decision.action_id, email.action_id],
|
|
113
|
+
description: "All lending decisions for regulatory review",
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
console.log(pkg.package_hash); // sha256:...
|
|
117
|
+
console.log(pkg.signature); // ed25519:...
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Agent Will & Estate
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
await aira.setAgentWill("lending-agent", {
|
|
124
|
+
successorSlug: "lending-agent-v2",
|
|
125
|
+
successionPolicy: "transfer_to_successor",
|
|
126
|
+
dataRetentionDays: 2555,
|
|
127
|
+
notifyEmails: ["compliance@acme.com"],
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
await aira.createComplianceSnapshot({
|
|
131
|
+
framework: "eu-ai-act",
|
|
132
|
+
agentSlug: "lending-agent",
|
|
133
|
+
findings: { art_12_logging: "pass", art_14_oversight: "pass" },
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Escrow (Liability Commitments)
|
|
138
|
+
|
|
139
|
+
Escrow accounts are **accountability ledgers** — they record liability commitments with cryptographic proof. No real funds are custodied by Aira.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const account = await aira.createEscrowAccount({ purpose: "Loan liability" });
|
|
143
|
+
await aira.escrowDeposit(account.id, 15000, "Liability commitment for loan #4521");
|
|
144
|
+
await aira.escrowRelease(account.id, 15000, "Loan disbursed successfully");
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Chat
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const response = await aira.ask("How many loan decisions were notarized this week?");
|
|
151
|
+
console.log(response.content);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Public Verification
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// No auth needed — anyone can verify
|
|
158
|
+
const result = await aira.verifyAction("action-uuid");
|
|
159
|
+
console.log(result.valid); // true
|
|
160
|
+
console.log(result.message); // "Action receipt exists..."
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Error Handling
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { Aira, AiraError } from "aira-sdk";
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
await aira.notarize({ actionType: "test", details: "test" });
|
|
170
|
+
} catch (e) {
|
|
171
|
+
if (e instanceof AiraError) {
|
|
172
|
+
console.log(e.status); // 429
|
|
173
|
+
console.log(e.code); // "PLAN_LIMIT_EXCEEDED"
|
|
174
|
+
console.log(e.message); // "Monthly operation limit reached"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Configuration
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
const aira = new Aira({
|
|
183
|
+
apiKey: "aira_live_xxx",
|
|
184
|
+
baseUrl: "https://your-self-hosted.com", // Self-hosted
|
|
185
|
+
timeout: 60_000, // Request timeout in ms
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT
|
|
192
|
+
|
|
193
|
+
## Links
|
|
194
|
+
|
|
195
|
+
- [Documentation](https://docs.airaproof.com)
|
|
196
|
+
- [API Reference](https://docs.airaproof.com/docs/api-reference)
|
|
197
|
+
- [Python SDK](https://pypi.org/project/aira-sdk/)
|
|
198
|
+
- [Dashboard](https://app.airaproof.com)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { ActionReceipt, ActionDetail, AgentDetail, AgentVersion, EvidencePackage, ComplianceSnapshot, EscrowAccount, EscrowTransaction, VerifyResult, PaginatedList } from "./types";
|
|
2
|
+
export interface AiraOptions {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class Aira {
|
|
8
|
+
private baseUrl;
|
|
9
|
+
private apiKey;
|
|
10
|
+
private timeout;
|
|
11
|
+
constructor(options: AiraOptions);
|
|
12
|
+
private request;
|
|
13
|
+
private get;
|
|
14
|
+
private post;
|
|
15
|
+
private put;
|
|
16
|
+
private del;
|
|
17
|
+
private paginated;
|
|
18
|
+
notarize(params: {
|
|
19
|
+
actionType: string;
|
|
20
|
+
details: string;
|
|
21
|
+
agentId?: string;
|
|
22
|
+
agentVersion?: string;
|
|
23
|
+
modelId?: string;
|
|
24
|
+
modelVersion?: string;
|
|
25
|
+
instructionHash?: string;
|
|
26
|
+
parentActionId?: string;
|
|
27
|
+
storeDetails?: boolean;
|
|
28
|
+
idempotencyKey?: string;
|
|
29
|
+
}): Promise<ActionReceipt>;
|
|
30
|
+
getAction(actionId: string): Promise<ActionDetail>;
|
|
31
|
+
listActions(params?: {
|
|
32
|
+
page?: number;
|
|
33
|
+
perPage?: number;
|
|
34
|
+
actionType?: string;
|
|
35
|
+
agentId?: string;
|
|
36
|
+
status?: string;
|
|
37
|
+
}): Promise<PaginatedList<ActionDetail>>;
|
|
38
|
+
authorizeAction(actionId: string): Promise<Record<string, unknown>>;
|
|
39
|
+
setLegalHold(actionId: string): Promise<Record<string, unknown>>;
|
|
40
|
+
releaseLegalHold(actionId: string): Promise<Record<string, unknown>>;
|
|
41
|
+
getActionChain(actionId: string): Promise<Record<string, unknown>[]>;
|
|
42
|
+
verifyAction(actionId: string): Promise<VerifyResult>;
|
|
43
|
+
registerAgent(params: {
|
|
44
|
+
agentSlug: string;
|
|
45
|
+
displayName: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
capabilities?: string[];
|
|
48
|
+
public?: boolean;
|
|
49
|
+
}): Promise<AgentDetail>;
|
|
50
|
+
getAgent(slug: string): Promise<AgentDetail>;
|
|
51
|
+
listAgents(params?: {
|
|
52
|
+
page?: number;
|
|
53
|
+
status?: string;
|
|
54
|
+
}): Promise<PaginatedList<AgentDetail>>;
|
|
55
|
+
updateAgent(slug: string, fields: Partial<{
|
|
56
|
+
displayName: string;
|
|
57
|
+
description: string;
|
|
58
|
+
capabilities: string[];
|
|
59
|
+
public: boolean;
|
|
60
|
+
}>): Promise<AgentDetail>;
|
|
61
|
+
publishVersion(slug: string, params: {
|
|
62
|
+
version: string;
|
|
63
|
+
changelog?: string;
|
|
64
|
+
modelId?: string;
|
|
65
|
+
instructionHash?: string;
|
|
66
|
+
configHash?: string;
|
|
67
|
+
}): Promise<AgentVersion>;
|
|
68
|
+
listVersions(slug: string): Promise<AgentVersion[]>;
|
|
69
|
+
decommissionAgent(slug: string): Promise<AgentDetail>;
|
|
70
|
+
transferAgent(slug: string, toOrgId: string, reason?: string): Promise<Record<string, unknown>>;
|
|
71
|
+
getAgentActions(slug: string, page?: number): Promise<PaginatedList>;
|
|
72
|
+
runCase(details: string, models: string[], options?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
73
|
+
getCase(caseId: string): Promise<Record<string, unknown>>;
|
|
74
|
+
listCases(page?: number): Promise<PaginatedList>;
|
|
75
|
+
getReceipt(receiptId: string): Promise<Record<string, unknown>>;
|
|
76
|
+
exportReceipt(receiptId: string, format?: "json" | "pdf"): Promise<Record<string, unknown>>;
|
|
77
|
+
createEvidencePackage(params: {
|
|
78
|
+
title: string;
|
|
79
|
+
actionIds: string[];
|
|
80
|
+
description?: string;
|
|
81
|
+
agentSlugs?: string[];
|
|
82
|
+
}): Promise<EvidencePackage>;
|
|
83
|
+
listEvidencePackages(page?: number): Promise<PaginatedList<EvidencePackage>>;
|
|
84
|
+
getEvidencePackage(packageId: string): Promise<EvidencePackage>;
|
|
85
|
+
timeTravel(params: {
|
|
86
|
+
pointInTime: string;
|
|
87
|
+
agentSlug?: string;
|
|
88
|
+
actionType?: string;
|
|
89
|
+
}): Promise<Record<string, unknown>>;
|
|
90
|
+
liabilityChain(actionId: string, maxDepth?: number): Promise<Record<string, unknown>[]>;
|
|
91
|
+
setAgentWill(slug: string, params: {
|
|
92
|
+
successorSlug?: string;
|
|
93
|
+
successionPolicy?: string;
|
|
94
|
+
dataRetentionDays?: number;
|
|
95
|
+
notifyEmails?: string[];
|
|
96
|
+
instructions?: string;
|
|
97
|
+
}): Promise<Record<string, unknown>>;
|
|
98
|
+
getAgentWill(slug: string): Promise<Record<string, unknown>>;
|
|
99
|
+
issueDeathCertificate(slug: string, reason?: string): Promise<Record<string, unknown>>;
|
|
100
|
+
getDeathCertificate(slug: string): Promise<Record<string, unknown>>;
|
|
101
|
+
createComplianceSnapshot(params: {
|
|
102
|
+
framework: string;
|
|
103
|
+
agentSlug?: string;
|
|
104
|
+
findings?: Record<string, string>;
|
|
105
|
+
}): Promise<ComplianceSnapshot>;
|
|
106
|
+
listComplianceSnapshots(params?: {
|
|
107
|
+
page?: number;
|
|
108
|
+
framework?: string;
|
|
109
|
+
}): Promise<PaginatedList<ComplianceSnapshot>>;
|
|
110
|
+
createEscrowAccount(params?: {
|
|
111
|
+
purpose?: string;
|
|
112
|
+
currency?: string;
|
|
113
|
+
agentId?: string;
|
|
114
|
+
counterpartyOrgId?: string;
|
|
115
|
+
}): Promise<EscrowAccount>;
|
|
116
|
+
listEscrowAccounts(page?: number): Promise<PaginatedList<EscrowAccount>>;
|
|
117
|
+
getEscrowAccount(accountId: string): Promise<EscrowAccount>;
|
|
118
|
+
escrowDeposit(accountId: string, amount: number, description?: string, referenceActionId?: string): Promise<EscrowTransaction>;
|
|
119
|
+
escrowRelease(accountId: string, amount: number, description?: string, referenceActionId?: string): Promise<EscrowTransaction>;
|
|
120
|
+
escrowDispute(accountId: string, amount: number, description: string, referenceActionId?: string): Promise<EscrowTransaction>;
|
|
121
|
+
ask(message: string, params?: {
|
|
122
|
+
history?: Record<string, unknown>[];
|
|
123
|
+
model?: string;
|
|
124
|
+
}): Promise<{
|
|
125
|
+
content: string;
|
|
126
|
+
tools_used: string[];
|
|
127
|
+
model_id?: string;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Aira = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
const DEFAULT_BASE_URL = "https://api.airaproof.com";
|
|
6
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
7
|
+
const MAX_DETAILS_LENGTH = 50_000;
|
|
8
|
+
function buildBody(obj) {
|
|
9
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined && v !== null));
|
|
10
|
+
}
|
|
11
|
+
function sanitizeDetails(text) {
|
|
12
|
+
return text.length > MAX_DETAILS_LENGTH ? text.slice(0, MAX_DETAILS_LENGTH) + "...[truncated]" : text;
|
|
13
|
+
}
|
|
14
|
+
class Aira {
|
|
15
|
+
baseUrl;
|
|
16
|
+
apiKey;
|
|
17
|
+
timeout;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
if (!options.apiKey)
|
|
20
|
+
throw new Error("apiKey is required");
|
|
21
|
+
if (!options.apiKey.startsWith("aira_live_") && !options.apiKey.startsWith("aira_test_")) {
|
|
22
|
+
console.warn("API key does not start with 'aira_live_' or 'aira_test_' — is this correct?");
|
|
23
|
+
}
|
|
24
|
+
this.apiKey = options.apiKey;
|
|
25
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "") + "/api/v1";
|
|
26
|
+
this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
|
|
27
|
+
}
|
|
28
|
+
async request(method, path, body, auth = true) {
|
|
29
|
+
const controller = new AbortController();
|
|
30
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
31
|
+
const headers = { "Content-Type": "application/json" };
|
|
32
|
+
if (auth)
|
|
33
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
34
|
+
try {
|
|
35
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
36
|
+
method,
|
|
37
|
+
headers,
|
|
38
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
39
|
+
signal: controller.signal,
|
|
40
|
+
});
|
|
41
|
+
if (res.status === 204)
|
|
42
|
+
return {};
|
|
43
|
+
const data = (await res.json().catch(() => ({ error: res.statusText, code: "UNKNOWN" })));
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
throw new types_1.AiraError(res.status, data.code ?? "UNKNOWN", data.error ?? res.statusText);
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
get(path, params, auth = true) {
|
|
54
|
+
const qs = params ? "?" + new URLSearchParams(Object.entries(params).filter(([, v]) => v != null).map(([k, v]) => [k, String(v)])).toString() : "";
|
|
55
|
+
return this.request("GET", path + qs, undefined, auth);
|
|
56
|
+
}
|
|
57
|
+
post(path, body) {
|
|
58
|
+
return this.request("POST", path, body);
|
|
59
|
+
}
|
|
60
|
+
put(path, body) {
|
|
61
|
+
return this.request("PUT", path, body);
|
|
62
|
+
}
|
|
63
|
+
del(path) {
|
|
64
|
+
return this.request("DELETE", path);
|
|
65
|
+
}
|
|
66
|
+
paginated(data) {
|
|
67
|
+
const p = data.pagination;
|
|
68
|
+
return { data: data.data, total: p.total, page: p.page, per_page: p.per_page, has_more: p.has_more };
|
|
69
|
+
}
|
|
70
|
+
// ==================== Actions ====================
|
|
71
|
+
async notarize(params) {
|
|
72
|
+
const body = buildBody({
|
|
73
|
+
action_type: params.actionType,
|
|
74
|
+
details: sanitizeDetails(params.details),
|
|
75
|
+
agent_id: params.agentId,
|
|
76
|
+
agent_version: params.agentVersion,
|
|
77
|
+
model_id: params.modelId,
|
|
78
|
+
model_version: params.modelVersion,
|
|
79
|
+
instruction_hash: params.instructionHash,
|
|
80
|
+
parent_action_id: params.parentActionId,
|
|
81
|
+
store_details: params.storeDetails || undefined,
|
|
82
|
+
idempotency_key: params.idempotencyKey,
|
|
83
|
+
});
|
|
84
|
+
return this.post("/actions", body);
|
|
85
|
+
}
|
|
86
|
+
async getAction(actionId) {
|
|
87
|
+
return this.get(`/actions/${actionId}`);
|
|
88
|
+
}
|
|
89
|
+
async listActions(params) {
|
|
90
|
+
const data = await this.get("/actions", buildBody({
|
|
91
|
+
page: params?.page, per_page: params?.perPage, action_type: params?.actionType, agent_id: params?.agentId, status: params?.status,
|
|
92
|
+
}));
|
|
93
|
+
return this.paginated(data);
|
|
94
|
+
}
|
|
95
|
+
async authorizeAction(actionId) {
|
|
96
|
+
return this.post(`/actions/${actionId}/authorize`, {});
|
|
97
|
+
}
|
|
98
|
+
async setLegalHold(actionId) {
|
|
99
|
+
return this.post(`/actions/${actionId}/hold`, {});
|
|
100
|
+
}
|
|
101
|
+
async releaseLegalHold(actionId) {
|
|
102
|
+
return this.del(`/actions/${actionId}/hold`);
|
|
103
|
+
}
|
|
104
|
+
async getActionChain(actionId) {
|
|
105
|
+
const data = await this.get(`/actions/${actionId}/chain`);
|
|
106
|
+
return data.chain ?? [];
|
|
107
|
+
}
|
|
108
|
+
async verifyAction(actionId) {
|
|
109
|
+
return this.get(`/verify/action/${actionId}`, undefined, false);
|
|
110
|
+
}
|
|
111
|
+
// ==================== Agents ====================
|
|
112
|
+
async registerAgent(params) {
|
|
113
|
+
return this.post("/agents", buildBody({
|
|
114
|
+
agent_slug: params.agentSlug, display_name: params.displayName,
|
|
115
|
+
description: params.description, capabilities: params.capabilities, public: params.public,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
async getAgent(slug) {
|
|
119
|
+
return this.get(`/agents/${slug}`);
|
|
120
|
+
}
|
|
121
|
+
async listAgents(params) {
|
|
122
|
+
const data = await this.get("/agents", buildBody({ page: params?.page, status: params?.status }));
|
|
123
|
+
return this.paginated(data);
|
|
124
|
+
}
|
|
125
|
+
async updateAgent(slug, fields) {
|
|
126
|
+
return this.put(`/agents/${slug}`, buildBody({
|
|
127
|
+
display_name: fields.displayName, description: fields.description,
|
|
128
|
+
capabilities: fields.capabilities, public: fields.public,
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
async publishVersion(slug, params) {
|
|
132
|
+
return this.post(`/agents/${slug}/versions`, buildBody({
|
|
133
|
+
version: params.version, changelog: params.changelog, model_id: params.modelId,
|
|
134
|
+
instruction_hash: params.instructionHash, config_hash: params.configHash,
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
async listVersions(slug) {
|
|
138
|
+
return this.get(`/agents/${slug}/versions`);
|
|
139
|
+
}
|
|
140
|
+
async decommissionAgent(slug) {
|
|
141
|
+
return this.post(`/agents/${slug}/decommission`, {});
|
|
142
|
+
}
|
|
143
|
+
async transferAgent(slug, toOrgId, reason) {
|
|
144
|
+
return this.post(`/agents/${slug}/transfer`, buildBody({ to_org_id: toOrgId, reason }));
|
|
145
|
+
}
|
|
146
|
+
async getAgentActions(slug, page = 1) {
|
|
147
|
+
const data = await this.get(`/agents/${slug}/actions`, { page });
|
|
148
|
+
return this.paginated(data);
|
|
149
|
+
}
|
|
150
|
+
// ==================== Cases ====================
|
|
151
|
+
async runCase(details, models, options) {
|
|
152
|
+
const body = { details, models };
|
|
153
|
+
if (options)
|
|
154
|
+
body.options = options;
|
|
155
|
+
return this.post("/cases", body);
|
|
156
|
+
}
|
|
157
|
+
async getCase(caseId) {
|
|
158
|
+
return this.get(`/cases/${caseId}`);
|
|
159
|
+
}
|
|
160
|
+
async listCases(page = 1) {
|
|
161
|
+
const data = await this.get("/cases", { page });
|
|
162
|
+
return this.paginated(data);
|
|
163
|
+
}
|
|
164
|
+
// ==================== Receipts ====================
|
|
165
|
+
async getReceipt(receiptId) {
|
|
166
|
+
return this.get(`/receipts/${receiptId}`);
|
|
167
|
+
}
|
|
168
|
+
async exportReceipt(receiptId, format = "json") {
|
|
169
|
+
return this.get(`/receipts/${receiptId}/export`, { format });
|
|
170
|
+
}
|
|
171
|
+
// ==================== Evidence ====================
|
|
172
|
+
async createEvidencePackage(params) {
|
|
173
|
+
return this.post("/evidence/packages", buildBody({
|
|
174
|
+
title: params.title, action_ids: params.actionIds, description: params.description, agent_slugs: params.agentSlugs,
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
async listEvidencePackages(page = 1) {
|
|
178
|
+
const data = await this.get("/evidence/packages", { page });
|
|
179
|
+
return this.paginated(data);
|
|
180
|
+
}
|
|
181
|
+
async getEvidencePackage(packageId) {
|
|
182
|
+
return this.get(`/evidence/packages/${packageId}`);
|
|
183
|
+
}
|
|
184
|
+
async timeTravel(params) {
|
|
185
|
+
return this.post("/evidence/time-travel", buildBody({
|
|
186
|
+
point_in_time: params.pointInTime, agent_slug: params.agentSlug, action_type: params.actionType,
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
async liabilityChain(actionId, maxDepth = 10) {
|
|
190
|
+
const data = await this.get(`/evidence/liability-chain/${actionId}`, { max_depth: maxDepth });
|
|
191
|
+
return data.chain ?? [];
|
|
192
|
+
}
|
|
193
|
+
// ==================== Estate ====================
|
|
194
|
+
async setAgentWill(slug, params) {
|
|
195
|
+
return this.put(`/estate/agents/${slug}/will`, buildBody({
|
|
196
|
+
successor_slug: params.successorSlug, succession_policy: params.successionPolicy ?? "transfer_to_successor",
|
|
197
|
+
data_retention_days: params.dataRetentionDays, notify_emails: params.notifyEmails, instructions: params.instructions,
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
async getAgentWill(slug) {
|
|
201
|
+
return this.get(`/estate/agents/${slug}/will`);
|
|
202
|
+
}
|
|
203
|
+
async issueDeathCertificate(slug, reason = "Decommissioned by organization") {
|
|
204
|
+
return this.post(`/estate/agents/${slug}/death-certificate`, { reason });
|
|
205
|
+
}
|
|
206
|
+
async getDeathCertificate(slug) {
|
|
207
|
+
return this.get(`/estate/agents/${slug}/death-certificate`);
|
|
208
|
+
}
|
|
209
|
+
async createComplianceSnapshot(params) {
|
|
210
|
+
return this.post("/estate/compliance", buildBody({
|
|
211
|
+
framework: params.framework, agent_slug: params.agentSlug, findings: params.findings,
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
async listComplianceSnapshots(params) {
|
|
215
|
+
const data = await this.get("/estate/compliance", buildBody({
|
|
216
|
+
page: params?.page, framework: params?.framework,
|
|
217
|
+
}));
|
|
218
|
+
return this.paginated(data);
|
|
219
|
+
}
|
|
220
|
+
// ==================== Escrow ====================
|
|
221
|
+
async createEscrowAccount(params) {
|
|
222
|
+
return this.post("/escrow/accounts", buildBody({
|
|
223
|
+
purpose: params?.purpose, currency: params?.currency ?? "EUR",
|
|
224
|
+
agent_id: params?.agentId, counterparty_org_id: params?.counterpartyOrgId,
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
async listEscrowAccounts(page = 1) {
|
|
228
|
+
const data = await this.get("/escrow/accounts", { page });
|
|
229
|
+
return this.paginated(data);
|
|
230
|
+
}
|
|
231
|
+
async getEscrowAccount(accountId) {
|
|
232
|
+
return this.get(`/escrow/accounts/${accountId}`);
|
|
233
|
+
}
|
|
234
|
+
async escrowDeposit(accountId, amount, description, referenceActionId) {
|
|
235
|
+
return this.post(`/escrow/accounts/${accountId}/deposit`, buildBody({
|
|
236
|
+
amount, description, reference_action_id: referenceActionId,
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
async escrowRelease(accountId, amount, description, referenceActionId) {
|
|
240
|
+
return this.post(`/escrow/accounts/${accountId}/release`, buildBody({
|
|
241
|
+
amount, description, reference_action_id: referenceActionId,
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
async escrowDispute(accountId, amount, description, referenceActionId) {
|
|
245
|
+
return this.post(`/escrow/accounts/${accountId}/dispute`, buildBody({
|
|
246
|
+
amount, description, reference_action_id: referenceActionId,
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
// ==================== Chat ====================
|
|
250
|
+
async ask(message, params) {
|
|
251
|
+
return this.post("/chat", buildBody({ message, history: params?.history, model: params?.model }));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.Aira = Aira;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Aira } from "./client";
|
|
2
|
+
export type { AiraOptions } from "./client";
|
|
3
|
+
export { AiraError, type ActionReceipt, type ActionDetail, type AgentDetail, type AgentVersion, type EvidencePackage, type ComplianceSnapshot, type EscrowAccount, type EscrowTransaction, type VerifyResult, type PaginatedList, } from "./types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiraError = exports.Aira = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "Aira", { enumerable: true, get: function () { return client_1.Aira; } });
|
|
6
|
+
var types_1 = require("./types");
|
|
7
|
+
Object.defineProperty(exports, "AiraError", { enumerable: true, get: function () { return types_1.AiraError; } });
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** Cryptographic receipt from notarizing an action. */
|
|
2
|
+
export interface ActionReceipt {
|
|
3
|
+
action_id: string;
|
|
4
|
+
payload_hash: string;
|
|
5
|
+
signature: string;
|
|
6
|
+
receipt_id: string;
|
|
7
|
+
action_type: string;
|
|
8
|
+
agent_id: string | null;
|
|
9
|
+
created_at: string;
|
|
10
|
+
}
|
|
11
|
+
/** Full action details including receipt and authorizations. */
|
|
12
|
+
export interface ActionDetail {
|
|
13
|
+
action_id: string;
|
|
14
|
+
action_type: string;
|
|
15
|
+
action_details_hash: string;
|
|
16
|
+
agent_id: string | null;
|
|
17
|
+
model_id: string | null;
|
|
18
|
+
instruction_hash: string | null;
|
|
19
|
+
parent_action_id: string | null;
|
|
20
|
+
status: string;
|
|
21
|
+
legal_hold: boolean;
|
|
22
|
+
created_at: string;
|
|
23
|
+
receipt: {
|
|
24
|
+
receipt_id: string;
|
|
25
|
+
payload_hash: string;
|
|
26
|
+
signature: string;
|
|
27
|
+
public_key_id: string;
|
|
28
|
+
timestamp_token: string | null;
|
|
29
|
+
receipt_version: string;
|
|
30
|
+
verify_url: string;
|
|
31
|
+
} | null;
|
|
32
|
+
authorizations: {
|
|
33
|
+
id: string;
|
|
34
|
+
authorizer_email: string;
|
|
35
|
+
authorized_at: string | null;
|
|
36
|
+
}[];
|
|
37
|
+
request_id: string;
|
|
38
|
+
}
|
|
39
|
+
/** Registered agent identity. */
|
|
40
|
+
export interface AgentDetail {
|
|
41
|
+
id: string;
|
|
42
|
+
agent_slug: string;
|
|
43
|
+
display_name: string;
|
|
44
|
+
description: string | null;
|
|
45
|
+
capabilities: string[] | null;
|
|
46
|
+
status: string;
|
|
47
|
+
public: boolean;
|
|
48
|
+
registered_at: string;
|
|
49
|
+
metadata: Record<string, unknown> | null;
|
|
50
|
+
versions: AgentVersion[];
|
|
51
|
+
request_id: string;
|
|
52
|
+
}
|
|
53
|
+
/** Agent version info. */
|
|
54
|
+
export interface AgentVersion {
|
|
55
|
+
id: string;
|
|
56
|
+
version: string;
|
|
57
|
+
model_id: string | null;
|
|
58
|
+
instruction_hash: string | null;
|
|
59
|
+
config_hash: string | null;
|
|
60
|
+
changelog: string | null;
|
|
61
|
+
status: string;
|
|
62
|
+
published_at: string | null;
|
|
63
|
+
}
|
|
64
|
+
/** Sealed evidence package. */
|
|
65
|
+
export interface EvidencePackage {
|
|
66
|
+
id: string;
|
|
67
|
+
title: string;
|
|
68
|
+
description: string | null;
|
|
69
|
+
package_hash: string;
|
|
70
|
+
signature: string;
|
|
71
|
+
action_count: number;
|
|
72
|
+
created_at: string;
|
|
73
|
+
}
|
|
74
|
+
/** Compliance snapshot. */
|
|
75
|
+
export interface ComplianceSnapshot {
|
|
76
|
+
id: string;
|
|
77
|
+
framework: string;
|
|
78
|
+
agent_slug: string | null;
|
|
79
|
+
findings: Record<string, string>;
|
|
80
|
+
status: string;
|
|
81
|
+
created_at: string;
|
|
82
|
+
}
|
|
83
|
+
/** Escrow account. */
|
|
84
|
+
export interface EscrowAccount {
|
|
85
|
+
id: string;
|
|
86
|
+
status: string;
|
|
87
|
+
currency: string;
|
|
88
|
+
balance: string;
|
|
89
|
+
purpose: string | null;
|
|
90
|
+
created_at: string;
|
|
91
|
+
}
|
|
92
|
+
/** Escrow transaction (deposit, release, dispute). */
|
|
93
|
+
export interface EscrowTransaction {
|
|
94
|
+
id: string;
|
|
95
|
+
transaction_type: string;
|
|
96
|
+
amount: string;
|
|
97
|
+
description: string | null;
|
|
98
|
+
transaction_hash: string;
|
|
99
|
+
signature: string;
|
|
100
|
+
created_at: string;
|
|
101
|
+
}
|
|
102
|
+
/** Public verification result. */
|
|
103
|
+
export interface VerifyResult {
|
|
104
|
+
valid: boolean;
|
|
105
|
+
receipt_id: string | null;
|
|
106
|
+
verified_at: string;
|
|
107
|
+
public_key_id: string;
|
|
108
|
+
message: string;
|
|
109
|
+
}
|
|
110
|
+
/** Paginated list response. */
|
|
111
|
+
export interface PaginatedList<T = Record<string, unknown>> {
|
|
112
|
+
data: T[];
|
|
113
|
+
total: number;
|
|
114
|
+
page: number;
|
|
115
|
+
per_page: number;
|
|
116
|
+
has_more: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** Aira API error. */
|
|
119
|
+
export declare class AiraError extends Error {
|
|
120
|
+
status: number;
|
|
121
|
+
code: string;
|
|
122
|
+
constructor(status: number, code: string, message: string);
|
|
123
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiraError = void 0;
|
|
4
|
+
/** Aira API error. */
|
|
5
|
+
class AiraError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
code;
|
|
8
|
+
constructor(status, code, message) {
|
|
9
|
+
super(`[${code}] ${message}`);
|
|
10
|
+
this.name = "AiraError";
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AiraError = AiraError;
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aira-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for Aira — legal infrastructure for AI agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "Aira <sdk@airaproof.com>",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/aira-proof/typescript-sdk"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://airaproof.com",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"aira",
|
|
19
|
+
"ai",
|
|
20
|
+
"agents",
|
|
21
|
+
"notarization",
|
|
22
|
+
"compliance",
|
|
23
|
+
"eu-ai-act",
|
|
24
|
+
"cryptographic-receipts"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"lint": "tsc --noEmit"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^25.5.0",
|
|
33
|
+
"typescript": "^5.4.0",
|
|
34
|
+
"vitest": "^2.0.0"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
}
|
|
39
|
+
}
|