aira-sdk 0.1.3 → 0.3.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/README.md +306 -101
- package/dist/client.d.ts +41 -0
- package/dist/client.js +103 -0
- package/dist/extras/index.d.ts +21 -0
- package/dist/extras/index.js +31 -0
- package/dist/extras/langchain.d.ts +42 -0
- package/dist/extras/langchain.js +95 -0
- package/dist/extras/mcp.d.ts +49 -0
- package/dist/extras/mcp.js +163 -0
- package/dist/extras/openai-agents.d.ts +38 -0
- package/dist/extras/openai-agents.js +82 -0
- package/dist/extras/trust.d.ts +33 -0
- package/dist/extras/trust.js +77 -0
- package/dist/extras/vercel-ai.d.ts +48 -0
- package/dist/extras/vercel-ai.js +102 -0
- package/dist/extras/webhooks.d.ts +34 -0
- package/dist/extras/webhooks.js +59 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/offline.d.ts +16 -0
- package/dist/offline.js +27 -0
- package/dist/session.d.ts +20 -0
- package/dist/session.js +24 -0
- package/package.json +57 -2
package/README.md
CHANGED
|
@@ -1,171 +1,346 @@
|
|
|
1
1
|
# Aira TypeScript SDK
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**AI compliance infrastructure for AI agents.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/aira-sdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
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
|
|
8
|
+
Aira produces cryptographic receipts for every action your AI agent takes. Ed25519 signatures and RFC 3161 timestamps create tamper-proof, court-admissible proof of what happened, who authorized it, and which model made the decision. Built for EU AI Act, SR 11-7, and GDPR compliance.
|
|
16
9
|
|
|
17
|
-
|
|
10
|
+
---
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
## Integration Matrix
|
|
13
|
+
|
|
14
|
+
Drop Aira into your existing agent framework with one import:
|
|
15
|
+
|
|
16
|
+
| Framework | Import | Integration |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| **LangChain.js** | `import { AiraCallbackHandler } from "aira-sdk/extras/langchain"` | Callback handler |
|
|
19
|
+
| **Vercel AI** | `import { AiraVercelMiddleware } from "aira-sdk/extras/vercel-ai"` | Middleware |
|
|
20
|
+
| **OpenAI Agents** | `import { AiraGuardrail } from "aira-sdk/extras/openai-agents"` | Guardrail |
|
|
21
|
+
| **MCP** | `import { createServer } from "aira-sdk/extras/mcp"` | MCP Server |
|
|
22
|
+
| **Webhooks** | `import { verifySignature } from "aira-sdk/extras/webhooks"` | Verification |
|
|
23
|
+
|
|
24
|
+
Or install the core SDK alone:
|
|
21
25
|
|
|
22
26
|
```bash
|
|
23
27
|
npm install aira-sdk
|
|
24
28
|
```
|
|
25
29
|
|
|
30
|
+
---
|
|
31
|
+
|
|
26
32
|
## Quick Start
|
|
27
33
|
|
|
34
|
+
Every call to `notarize()` returns a cryptographic receipt -- Ed25519-signed, timestamped, tamper-proof.
|
|
35
|
+
|
|
28
36
|
```typescript
|
|
29
37
|
import { Aira } from "aira-sdk";
|
|
30
38
|
|
|
31
39
|
const aira = new Aira({ apiKey: "aira_live_xxx" });
|
|
32
40
|
|
|
33
|
-
// Notarize an agent action
|
|
34
41
|
const receipt = await aira.notarize({
|
|
35
42
|
actionType: "email_sent",
|
|
36
43
|
details: "Sent onboarding email to customer@example.com",
|
|
37
44
|
agentId: "support-agent",
|
|
38
45
|
modelId: "claude-sonnet-4-6",
|
|
46
|
+
instructionHash: "sha256:a1b2c3...",
|
|
39
47
|
});
|
|
40
48
|
|
|
41
|
-
console.log(receipt.
|
|
42
|
-
console.log(receipt.
|
|
49
|
+
console.log(receipt.payload_hash); // sha256:e5f6a7b8...
|
|
50
|
+
console.log(receipt.signature); // ed25519:base64url...
|
|
51
|
+
console.log(receipt.action_id); // uuid — publicly verifiable
|
|
43
52
|
```
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Framework Integrations
|
|
57
|
+
|
|
58
|
+
### LangChain.js
|
|
59
|
+
|
|
60
|
+
`AiraCallbackHandler` notarizes every tool call, chain completion, and LLM invocation with a cryptographic receipt. No changes to your chain logic.
|
|
46
61
|
|
|
47
62
|
```typescript
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
displayName: "Loan Decision Engine",
|
|
51
|
-
capabilities: ["credit_scoring", "risk_assessment"],
|
|
52
|
-
public: true,
|
|
53
|
-
});
|
|
63
|
+
import { Aira } from "aira-sdk";
|
|
64
|
+
import { AiraCallbackHandler } from "aira-sdk/extras/langchain";
|
|
54
65
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
modelId: "claude-sonnet-4-6",
|
|
58
|
-
changelog: "Initial release",
|
|
59
|
-
});
|
|
66
|
+
const aira = new Aira({ apiKey: "aira_live_xxx" });
|
|
67
|
+
const handler = new AiraCallbackHandler({ client: aira, agentId: "research-agent", modelId: "gpt-4o" });
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
// Every tool call and chain completion gets a signed receipt
|
|
70
|
+
const result = await chain.invoke({ input: "Analyze Q1 revenue" }, { callbacks: [handler] });
|
|
63
71
|
```
|
|
64
72
|
|
|
65
|
-
|
|
73
|
+
### Vercel AI
|
|
74
|
+
|
|
75
|
+
`AiraVercelMiddleware` wraps your Vercel AI `streamText` / `generateText` calls so every model invocation is notarized with a tamper-proof receipt.
|
|
66
76
|
|
|
67
77
|
```typescript
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
});
|
|
78
|
+
import { Aira } from "aira-sdk";
|
|
79
|
+
import { AiraVercelMiddleware } from "aira-sdk/extras/vercel-ai";
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const aira = new Aira({ apiKey: "aira_live_xxx" });
|
|
82
|
+
const middleware = new AiraVercelMiddleware({ client: aira, agentId: "assistant-agent" });
|
|
83
|
+
|
|
84
|
+
// Wrap your Vercel AI calls — receipts at invocation and completion
|
|
85
|
+
const result = await middleware.wrapGenerateText({
|
|
86
|
+
model: openai("gpt-4o"),
|
|
87
|
+
prompt: "Summarize the contract terms",
|
|
83
88
|
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### OpenAI Agents SDK
|
|
92
|
+
|
|
93
|
+
`AiraGuardrail` wraps any tool function to automatically notarize both invocation and result with cryptographic proof.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Aira } from "aira-sdk";
|
|
97
|
+
import { AiraGuardrail } from "aira-sdk/extras/openai-agents";
|
|
98
|
+
|
|
99
|
+
const aira = new Aira({ apiKey: "aira_live_xxx" });
|
|
100
|
+
const guardrail = new AiraGuardrail({ client: aira, agentId: "assistant-agent" });
|
|
101
|
+
|
|
102
|
+
// Wrap tools — every call and result gets a signed receipt
|
|
103
|
+
const search = guardrail.wrapTool(searchTool, { toolName: "web_search" });
|
|
104
|
+
const execute = guardrail.wrapTool(codeExecutor, { toolName: "code_exec" });
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## MCP Server
|
|
110
|
+
|
|
111
|
+
Expose Aira as an MCP tool server. Any MCP-compatible AI agent can notarize actions and verify receipts without SDK integration.
|
|
84
112
|
|
|
85
|
-
|
|
86
|
-
|
|
113
|
+
```typescript
|
|
114
|
+
import { createServer } from "aira-sdk/extras/mcp";
|
|
115
|
+
|
|
116
|
+
const server = createServer({ apiKey: "aira_live_xxx" });
|
|
117
|
+
server.listen(); // stdio transport
|
|
118
|
+
```
|
|
87
119
|
|
|
88
|
-
|
|
89
|
-
await aira.authorizeAction(decision.action_id);
|
|
120
|
+
The server exposes three tools: `notarize_action`, `verify_action`, and `get_receipt` -- each producing cryptographically signed results.
|
|
90
121
|
|
|
91
|
-
|
|
92
|
-
|
|
122
|
+
Add to your MCP client config:
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"mcpServers": {
|
|
127
|
+
"aira": {
|
|
128
|
+
"command": "npx",
|
|
129
|
+
"args": ["aira-sdk", "mcp"],
|
|
130
|
+
"env": { "AIRA_API_KEY": "aira_live_xxx" }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
93
134
|
```
|
|
94
135
|
|
|
95
|
-
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Session
|
|
139
|
+
|
|
140
|
+
Pre-fill defaults for a block of related actions. Every `notarize()` call within the session inherits the agent identity, producing receipts that share a common provenance chain.
|
|
96
141
|
|
|
97
142
|
```typescript
|
|
98
|
-
const
|
|
99
|
-
"Should we approve loan #4521?",
|
|
100
|
-
["claude-sonnet-4-6", "gpt-4o", "gemini-2.0-flash"],
|
|
101
|
-
);
|
|
143
|
+
const sess = aira.session("onboarding-agent", { modelId: "claude-sonnet-4-6" });
|
|
102
144
|
|
|
103
|
-
|
|
104
|
-
|
|
145
|
+
await sess.notarize({ actionType: "identity_verified", details: "Verified customer ID #4521" });
|
|
146
|
+
await sess.notarize({ actionType: "account_created", details: "Created account for customer #4521" });
|
|
147
|
+
await sess.notarize({ actionType: "welcome_sent", details: "Sent welcome email to customer #4521" });
|
|
105
148
|
```
|
|
106
149
|
|
|
107
|
-
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Offline Mode
|
|
153
|
+
|
|
154
|
+
Queue notarizations locally when connectivity is unavailable. Cryptographic receipts are generated server-side when you sync -- nothing is lost.
|
|
108
155
|
|
|
109
156
|
```typescript
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
});
|
|
157
|
+
const aira = new Aira({ apiKey: "aira_live_xxx", offline: true });
|
|
158
|
+
|
|
159
|
+
// These queue locally — no network calls
|
|
160
|
+
await aira.notarize({ actionType: "scan_completed", details: "Scanned document batch #77" });
|
|
161
|
+
await aira.notarize({ actionType: "classification_done", details: "Classified 142 documents" });
|
|
162
|
+
|
|
163
|
+
console.log(aira.pendingCount); // 2
|
|
115
164
|
|
|
116
|
-
|
|
117
|
-
|
|
165
|
+
// Flush to API when back online — receipts are generated for each action
|
|
166
|
+
const results = await aira.sync();
|
|
118
167
|
```
|
|
119
168
|
|
|
120
|
-
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Webhook Verification
|
|
172
|
+
|
|
173
|
+
Verify that incoming webhooks are authentic Aira events, not forged requests. HMAC-SHA256 signature verification ensures tamper-proof delivery.
|
|
121
174
|
|
|
122
175
|
```typescript
|
|
123
|
-
|
|
124
|
-
successorSlug: "lending-agent-v2",
|
|
125
|
-
successionPolicy: "transfer_to_successor",
|
|
126
|
-
dataRetentionDays: 2555,
|
|
127
|
-
notifyEmails: ["compliance@acme.com"],
|
|
128
|
-
});
|
|
176
|
+
import { verifySignature, parseEvent } from "aira-sdk/extras/webhooks";
|
|
129
177
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
178
|
+
// Verify the webhook signature (HMAC-SHA256)
|
|
179
|
+
const isValid = verifySignature({
|
|
180
|
+
payload: request.body,
|
|
181
|
+
signature: request.headers["x-aira-signature"],
|
|
182
|
+
secret: "whsec_xxx",
|
|
134
183
|
});
|
|
184
|
+
|
|
185
|
+
if (isValid) {
|
|
186
|
+
const event = parseEvent(request.body);
|
|
187
|
+
console.log(event.eventType); // "action.notarized"
|
|
188
|
+
console.log(event.data); // Action data with cryptographic receipt
|
|
189
|
+
console.log(event.deliveryId); // Unique delivery ID
|
|
190
|
+
}
|
|
135
191
|
```
|
|
136
192
|
|
|
137
|
-
|
|
193
|
+
Supported event types: `action.notarized`, `action.authorized`, `agent.registered`, `agent.decommissioned`, `evidence.sealed`, `escrow.deposited`, `escrow.released`, `escrow.disputed`, `compliance.snapshot_created`, `case.complete`, `case.requires_human_review`.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Core SDK Methods
|
|
198
|
+
|
|
199
|
+
All 56 methods on `Aira`. Every write operation produces a cryptographic receipt.
|
|
200
|
+
|
|
201
|
+
| Category | Method | Description |
|
|
202
|
+
|---|---|---|
|
|
203
|
+
| **Actions** | `notarize()` | Notarize an action -- returns Ed25519-signed receipt |
|
|
204
|
+
| | `getAction()` | Retrieve action details + receipt |
|
|
205
|
+
| | `listActions()` | List actions with filters (type, agent, status) |
|
|
206
|
+
| | `authorizeAction()` | Human co-signature on high-stakes action |
|
|
207
|
+
| | `setLegalHold()` | Prevent deletion -- litigation hold |
|
|
208
|
+
| | `releaseLegalHold()` | Release litigation hold |
|
|
209
|
+
| | `getActionChain()` | Chain of custody for an action |
|
|
210
|
+
| | `verifyAction()` | Public verification -- no auth required |
|
|
211
|
+
| **Agents** | `registerAgent()` | Register verifiable agent identity |
|
|
212
|
+
| | `getAgent()` | Retrieve agent profile |
|
|
213
|
+
| | `listAgents()` | List registered agents |
|
|
214
|
+
| | `updateAgent()` | Update agent metadata |
|
|
215
|
+
| | `publishVersion()` | Publish versioned agent config |
|
|
216
|
+
| | `listVersions()` | List agent versions |
|
|
217
|
+
| | `decommissionAgent()` | Decommission agent |
|
|
218
|
+
| | `transferAgent()` | Transfer ownership to another org |
|
|
219
|
+
| | `getAgentActions()` | List actions by agent |
|
|
220
|
+
| **Trust Layer** | `getAgentDid()` | Retrieve agent's W3C DID (`did:web`) |
|
|
221
|
+
| | `rotateAgentKeys()` | Rotate agent's Ed25519 signing keys |
|
|
222
|
+
| | `getAgentCredential()` | Get agent's W3C Verifiable Credential |
|
|
223
|
+
| | `verifyCredential()` | Verify a Verifiable Credential |
|
|
224
|
+
| | `revokeCredential()` | Revoke agent's Verifiable Credential |
|
|
225
|
+
| | `requestMutualSign()` | Initiate mutual notarization with counterparty |
|
|
226
|
+
| | `completeMutualSign()` | Complete mutual notarization (counterparty signs) |
|
|
227
|
+
| | `getMutualSignStatus()` | Check status of a mutual sign request |
|
|
228
|
+
| | `getReputation()` | Get agent reputation score and tier |
|
|
229
|
+
| | `listReputationHistory()` | List reputation score history |
|
|
230
|
+
| | `setEndpointPolicy()` | Set endpoint verification policy |
|
|
231
|
+
| | `getEndpointPolicy()` | Get current endpoint policy |
|
|
232
|
+
| | `resolveDid()` | Resolve any DID to its DID Document |
|
|
233
|
+
| | `checkTrust()` | Run full trust check against a counterparty |
|
|
234
|
+
| | `listCredentials()` | List all credentials for an agent |
|
|
235
|
+
| | `getTrustBundle()` | Get DID + VC + reputation in one call |
|
|
236
|
+
| **Cases** | `runCase()` | Multi-model consensus adjudication |
|
|
237
|
+
| | `getCase()` | Retrieve case result |
|
|
238
|
+
| | `listCases()` | List cases |
|
|
239
|
+
| **Receipts** | `getReceipt()` | Retrieve cryptographic receipt |
|
|
240
|
+
| | `exportReceipt()` | Export receipt as JSON or PDF |
|
|
241
|
+
| **Evidence** | `createEvidencePackage()` | Sealed, tamper-proof evidence bundle |
|
|
242
|
+
| | `listEvidencePackages()` | List evidence packages |
|
|
243
|
+
| | `getEvidencePackage()` | Retrieve evidence package |
|
|
244
|
+
| | `timeTravel()` | Query actions at a point in time |
|
|
245
|
+
| | `liabilityChain()` | Walk full liability chain |
|
|
246
|
+
| **Estate** | `setAgentWill()` | Define succession plan |
|
|
247
|
+
| | `getAgentWill()` | Retrieve agent will |
|
|
248
|
+
| | `issueDeathCertificate()` | Decommission with succession trigger |
|
|
249
|
+
| | `getDeathCertificate()` | Retrieve death certificate |
|
|
250
|
+
| | `createComplianceSnapshot()` | Compliance snapshot (EU AI Act, SR 11-7, GDPR) |
|
|
251
|
+
| | `listComplianceSnapshots()` | List snapshots by framework |
|
|
252
|
+
| **Escrow** | `createEscrowAccount()` | Create liability commitment ledger |
|
|
253
|
+
| | `listEscrowAccounts()` | List escrow accounts |
|
|
254
|
+
| | `getEscrowAccount()` | Retrieve escrow account |
|
|
255
|
+
| | `escrowDeposit()` | Record liability commitment |
|
|
256
|
+
| | `escrowRelease()` | Release commitment after completion |
|
|
257
|
+
| | `escrowDispute()` | Dispute -- flag liability issue |
|
|
258
|
+
| **Chat** | `ask()` | Query your notarized data via AI |
|
|
259
|
+
| **Offline** | `sync()` | Flush offline queue to API |
|
|
260
|
+
| **Session** | `session()` | Scoped session with pre-filled defaults |
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Trust Layer
|
|
265
|
+
|
|
266
|
+
Standards-based identity and trust for agents: W3C DIDs, Verifiable Credentials, mutual notarization, and reputation scoring. Every agent gets a cryptographically verifiable identity that other agents (and humans) can check before interacting.
|
|
267
|
+
|
|
268
|
+
### DID Identity
|
|
269
|
+
|
|
270
|
+
Every registered agent gets a W3C-compliant DID (`did:web`):
|
|
138
271
|
|
|
139
|
-
|
|
272
|
+
```typescript
|
|
273
|
+
// Retrieve the agent's DID
|
|
274
|
+
const did = await aira.getAgentDid("my-agent");
|
|
275
|
+
console.log(did); // "did:web:airaproof.com:agents:my-agent"
|
|
276
|
+
|
|
277
|
+
// Rotate signing keys (old keys are revoked, new keys are published)
|
|
278
|
+
await aira.rotateAgentKeys("my-agent");
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Verifiable Credentials
|
|
140
282
|
|
|
141
283
|
```typescript
|
|
142
|
-
|
|
143
|
-
await aira.
|
|
144
|
-
|
|
284
|
+
// Get the agent's W3C Verifiable Credential
|
|
285
|
+
const vc = await aira.getAgentCredential("my-agent");
|
|
286
|
+
|
|
287
|
+
// Verify any VC (returns validity, issuer, expiry)
|
|
288
|
+
const result = await aira.verifyCredential(vc);
|
|
289
|
+
console.log(result.valid); // true
|
|
290
|
+
|
|
291
|
+
// Revoke a credential
|
|
292
|
+
await aira.revokeCredential("my-agent", { reason: "Agent deprecated" });
|
|
145
293
|
```
|
|
146
294
|
|
|
147
|
-
|
|
295
|
+
### Mutual Notarization
|
|
296
|
+
|
|
297
|
+
For high-stakes actions, both parties co-sign:
|
|
148
298
|
|
|
149
299
|
```typescript
|
|
150
|
-
|
|
151
|
-
|
|
300
|
+
// Agent A initiates — sends a signing request to the counterparty
|
|
301
|
+
const request = await aira.requestMutualSign({
|
|
302
|
+
actionId: "act-uuid",
|
|
303
|
+
counterpartyDid: "did:web:partner.com:agents:their-agent",
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Agent B completes — signs the same payload
|
|
307
|
+
const receipt = await aira.completeMutualSign({
|
|
308
|
+
actionId: "act-uuid",
|
|
309
|
+
did: "did:web:partner.com:agents:their-agent",
|
|
310
|
+
signature: "z...",
|
|
311
|
+
signedPayloadHash: "sha256:...",
|
|
152
312
|
});
|
|
153
|
-
console.log(response.content);
|
|
154
313
|
```
|
|
155
314
|
|
|
156
|
-
|
|
315
|
+
### Reputation
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
const rep = await aira.getReputation("my-agent");
|
|
319
|
+
console.log(rep.score); // 84
|
|
320
|
+
console.log(rep.tier); // "Verified"
|
|
321
|
+
```
|
|
157
322
|
|
|
158
|
-
|
|
323
|
+
### Trust Policy in Integrations
|
|
159
324
|
|
|
160
|
-
|
|
325
|
+
Pass a `trustPolicy` to any framework integration to run automated trust checks before agent interactions:
|
|
161
326
|
|
|
162
327
|
```typescript
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
328
|
+
import { AiraCallbackHandler } from "aira-sdk/extras/langchain";
|
|
329
|
+
|
|
330
|
+
const handler = new AiraCallbackHandler(aira, "research-agent", {
|
|
331
|
+
modelId: "gpt-4o",
|
|
332
|
+
trustPolicy: {
|
|
333
|
+
verifyCounterparty: true, // resolve counterparty DID
|
|
334
|
+
minReputation: 60, // warn if reputation score below 60
|
|
335
|
+
requireValidVc: true, // check Verifiable Credential validity
|
|
336
|
+
blockRevokedVc: true, // block if counterparty VC is revoked
|
|
337
|
+
blockUnregistered: false, // don't block agents without Aira DIDs
|
|
338
|
+
},
|
|
339
|
+
});
|
|
167
340
|
```
|
|
168
341
|
|
|
342
|
+
---
|
|
343
|
+
|
|
169
344
|
## Error Handling
|
|
170
345
|
|
|
171
346
|
```typescript
|
|
@@ -182,24 +357,54 @@ try {
|
|
|
182
357
|
}
|
|
183
358
|
```
|
|
184
359
|
|
|
360
|
+
All framework integrations (LangChain.js, Vercel AI, OpenAI Agents) are non-blocking by default -- notarization failures are logged, never raised. Your agent keeps running.
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
185
364
|
## Configuration
|
|
186
365
|
|
|
187
366
|
```typescript
|
|
188
367
|
const aira = new Aira({
|
|
189
|
-
apiKey: "aira_live_xxx",
|
|
190
|
-
baseUrl: "https://your-self-hosted.com",
|
|
191
|
-
timeout: 60_000,
|
|
368
|
+
apiKey: "aira_live_xxx", // Required — aira_live_ or aira_test_ prefix
|
|
369
|
+
baseUrl: "https://your-self-hosted.com", // Self-hosted deployment
|
|
370
|
+
timeout: 60_000, // Request timeout in ms
|
|
371
|
+
offline: true, // Queue locally, sync later
|
|
192
372
|
});
|
|
193
373
|
```
|
|
194
374
|
|
|
195
|
-
|
|
375
|
+
| Env Variable | Description |
|
|
376
|
+
|---|---|
|
|
377
|
+
| `AIRA_API_KEY` | API key (used by MCP server) |
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## SDK Parity
|
|
382
|
+
|
|
383
|
+
| Feature | Python | TypeScript |
|
|
384
|
+
|---|---|---|
|
|
385
|
+
| Core API (45+ methods) | Yes | Yes |
|
|
386
|
+
| Trust Layer (DID, VC, Reputation) | Yes | Yes |
|
|
387
|
+
| LangChain | Yes | Yes |
|
|
388
|
+
| CrewAI | Yes | -- (Python-only) |
|
|
389
|
+
| Vercel AI | -- (JS-only) | Yes |
|
|
390
|
+
| OpenAI Agents | Yes | Yes |
|
|
391
|
+
| Google ADK | Yes (Python-only) | -- |
|
|
392
|
+
| AWS Bedrock | Yes (Python-only) | -- |
|
|
393
|
+
| MCP Server | Yes | Yes |
|
|
394
|
+
| Webhooks | Yes | Yes |
|
|
395
|
+
| CLI | Yes | -- (use Python CLI) |
|
|
396
|
+
| Offline Mode | Yes | Yes |
|
|
397
|
+
| Session | Yes | Yes |
|
|
196
398
|
|
|
197
|
-
|
|
399
|
+
---
|
|
198
400
|
|
|
199
401
|
## Links
|
|
200
402
|
|
|
201
|
-
- [
|
|
403
|
+
- [Website](https://airaproof.com)
|
|
404
|
+
- [npm Package](https://www.npmjs.com/package/aira-sdk)
|
|
405
|
+
- [Python SDK (PyPI)](https://pypi.org/project/aira-sdk/)
|
|
202
406
|
- [Documentation](https://docs.airaproof.com)
|
|
203
407
|
- [API Reference](https://docs.airaproof.com/docs/api-reference)
|
|
204
|
-
- [
|
|
408
|
+
- [Interactive Demo](https://app.airaproof.com/demo) -- try Aira in your browser, no code needed
|
|
205
409
|
- [Dashboard](https://app.airaproof.com)
|
|
410
|
+
- [GitHub](https://github.com/aira-proof/typescript-sdk)
|
package/dist/client.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { ActionReceipt, ActionDetail, AgentDetail, AgentVersion, EvidencePackage, ComplianceSnapshot, EscrowAccount, EscrowTransaction, VerifyResult, PaginatedList } from "./types";
|
|
2
|
+
import { AiraSession } from "./session";
|
|
2
3
|
export interface AiraOptions {
|
|
3
4
|
apiKey: string;
|
|
4
5
|
baseUrl?: string;
|
|
5
6
|
timeout?: number;
|
|
7
|
+
offline?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export declare class Aira {
|
|
8
10
|
private baseUrl;
|
|
9
11
|
private apiKey;
|
|
10
12
|
private timeout;
|
|
13
|
+
private queue;
|
|
11
14
|
constructor(options: AiraOptions);
|
|
12
15
|
private request;
|
|
13
16
|
private get;
|
|
@@ -126,4 +129,42 @@ export declare class Aira {
|
|
|
126
129
|
tools_used: string[];
|
|
127
130
|
model_id?: string;
|
|
128
131
|
}>;
|
|
132
|
+
/** Get full DID info for an agent. */
|
|
133
|
+
getAgentDid(slug: string): Promise<Record<string, unknown>>;
|
|
134
|
+
/** Rotate an agent's DID keypair. */
|
|
135
|
+
rotateAgentKeys(slug: string): Promise<Record<string, unknown>>;
|
|
136
|
+
/** Resolve any did:web DID to its DID document. */
|
|
137
|
+
resolveDid(did: string): Promise<Record<string, unknown>>;
|
|
138
|
+
/** Get the current valid VC for an agent. */
|
|
139
|
+
getAgentCredential(slug: string): Promise<Record<string, unknown>>;
|
|
140
|
+
/** Get full credential history for an agent. */
|
|
141
|
+
getAgentCredentials(slug: string): Promise<Record<string, unknown>>;
|
|
142
|
+
/** Revoke the current credential for an agent. */
|
|
143
|
+
revokeCredential(slug: string, reason?: string): Promise<Record<string, unknown>>;
|
|
144
|
+
/** Verify a Verifiable Credential — checks signature, expiry, revocation. */
|
|
145
|
+
verifyCredential(credential: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
146
|
+
/** Initiate a mutual signing request for an action. */
|
|
147
|
+
requestMutualSign(actionId: string, counterpartyDid: string): Promise<Record<string, unknown>>;
|
|
148
|
+
/** Get the action payload awaiting counterparty signature. */
|
|
149
|
+
getPendingMutualSign(actionId: string): Promise<Record<string, unknown>>;
|
|
150
|
+
/** Submit counterparty signature to complete mutual signing. */
|
|
151
|
+
completeMutualSign(actionId: string, did: string, signature: string, signedPayloadHash: string): Promise<Record<string, unknown>>;
|
|
152
|
+
/** Get the co-signed receipt for a mutually signed action. */
|
|
153
|
+
getMutualSignReceipt(actionId: string): Promise<Record<string, unknown>>;
|
|
154
|
+
/** Reject a mutual signing request. */
|
|
155
|
+
rejectMutualSign(actionId: string, reason?: string): Promise<Record<string, unknown>>;
|
|
156
|
+
/** Get current reputation score for an agent. */
|
|
157
|
+
getReputation(slug: string): Promise<Record<string, unknown>>;
|
|
158
|
+
/** Get full reputation history for an agent. */
|
|
159
|
+
getReputationHistory(slug: string): Promise<Record<string, unknown>>;
|
|
160
|
+
/** Submit a signed attestation of a successful interaction. */
|
|
161
|
+
attestReputation(slug: string, counterpartyDid: string, actionId: string, attestation: string, signature: string): Promise<Record<string, unknown>>;
|
|
162
|
+
/** Verify a reputation score by returning inputs and score_hash. */
|
|
163
|
+
verifyReputation(slug: string): Promise<Record<string, unknown>>;
|
|
164
|
+
/** Create a scoped session with pre-filled defaults. */
|
|
165
|
+
session(agentId: string, defaults?: Record<string, unknown>): AiraSession;
|
|
166
|
+
/** Number of queued offline requests. */
|
|
167
|
+
get pendingCount(): number;
|
|
168
|
+
/** Flush offline queue to API. Returns list of API responses. */
|
|
169
|
+
sync(): Promise<Record<string, unknown>[]>;
|
|
129
170
|
}
|