@vienna-os/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/README.md +302 -0
- package/dist/index.d.mts +954 -0
- package/dist/index.d.ts +954 -0
- package/dist/index.js +868 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +824 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# @vienna-os/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for **Vienna OS** — the AI Agent Governance Platform.
|
|
4
|
+
|
|
5
|
+
Submit intents, manage policies, govern your fleet, and stay compliant — all with full type safety and zero runtime dependencies.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@vienna-os/sdk)
|
|
8
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @vienna-os/sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { ViennaClient } from '@vienna-os/sdk';
|
|
20
|
+
|
|
21
|
+
const vienna = new ViennaClient({
|
|
22
|
+
apiKey: process.env.VIENNA_API_KEY!,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Submit an agent intent through the governance pipeline
|
|
26
|
+
const result = await vienna.intent.submit({
|
|
27
|
+
action: 'wire_transfer',
|
|
28
|
+
source: 'billing-bot',
|
|
29
|
+
payload: {
|
|
30
|
+
amount: 75000,
|
|
31
|
+
currency: 'USD',
|
|
32
|
+
recipient: 'vendor-123',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log(result.status); // 'executed' | 'pending_approval' | 'denied'
|
|
37
|
+
console.log(result.riskTier); // 'T0' | 'T1' | 'T2' | 'T3'
|
|
38
|
+
console.log(result.auditId); // Every action is audited
|
|
39
|
+
console.log(result.warrant); // Cryptographic proof of authorization
|
|
40
|
+
|
|
41
|
+
// Handle warrant-based governance flow
|
|
42
|
+
if (result.status === 'pending_approval') {
|
|
43
|
+
console.log('Waiting for human approval...');
|
|
44
|
+
console.log(`View at: https://console.regulator.ai/approvals/${result.intentId}`);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Framework Integration
|
|
49
|
+
|
|
50
|
+
Vienna OS provides convenience wrappers for popular AI agent frameworks:
|
|
51
|
+
|
|
52
|
+
### LangChain
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { createForLangChain } from '@vienna-os/sdk';
|
|
56
|
+
|
|
57
|
+
const vienna = createForLangChain({
|
|
58
|
+
apiKey: process.env.VIENNA_API_KEY!,
|
|
59
|
+
agentId: 'langchain-bot',
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Submit tool calls through governance
|
|
63
|
+
const result = await vienna.submitToolIntent('web_search', {
|
|
64
|
+
query: 'AI governance best practices',
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Wait for T2/T3 approvals
|
|
68
|
+
if (result.status === 'pending_approval') {
|
|
69
|
+
const status = await vienna.waitForApproval(result.intentId);
|
|
70
|
+
console.log(`Final status: ${status}`);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### CrewAI
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { createForCrewAI } from '@vienna-os/sdk';
|
|
78
|
+
|
|
79
|
+
const vienna = createForCrewAI({
|
|
80
|
+
apiKey: process.env.VIENNA_API_KEY!,
|
|
81
|
+
agentId: 'crew-researcher',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const result = await vienna.submitTaskIntent('market_research', {
|
|
85
|
+
topic: 'AI governance trends',
|
|
86
|
+
depth: 'comprehensive',
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### AutoGen
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { createForAutoGen } from '@vienna-os/sdk';
|
|
94
|
+
|
|
95
|
+
const vienna = createForAutoGen({
|
|
96
|
+
apiKey: process.env.VIENNA_API_KEY!,
|
|
97
|
+
agentId: 'autogen-assistant',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const result = await vienna.submitConversationIntent('get_stock_price', {
|
|
101
|
+
symbol: 'NVDA',
|
|
102
|
+
exchange: 'NASDAQ',
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### OpenClaw
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { createForOpenClaw } from '@vienna-os/sdk';
|
|
110
|
+
|
|
111
|
+
const vienna = createForOpenClaw({
|
|
112
|
+
apiKey: process.env.VIENNA_API_KEY!,
|
|
113
|
+
agentId: 'openclaw-agent',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const result = await vienna.submitSkillIntent('web_search', {
|
|
117
|
+
query: 'OpenAI news',
|
|
118
|
+
max_results: 10,
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Risk Tiers
|
|
123
|
+
|
|
124
|
+
Vienna OS classifies all agent actions by risk level:
|
|
125
|
+
|
|
126
|
+
| Tier | Description | Examples | Approval Required |
|
|
127
|
+
|------|-------------|----------|-------------------|
|
|
128
|
+
| **T0** | Read-only, no external impact | View files, search web, read databases | No |
|
|
129
|
+
| **T1** | Low-risk writes, reversible | Create temp files, send notifications | No |
|
|
130
|
+
| **T2** | Medium-risk, business impact | Send emails, modify configs, API calls | Optional |
|
|
131
|
+
| **T3** | High-risk, significant impact | Financial transactions, delete data, deploy code | Yes |
|
|
132
|
+
|
|
133
|
+
## Core API
|
|
134
|
+
|
|
135
|
+
### Intent Submission
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Submit and track intents
|
|
139
|
+
const result = await vienna.intent.submit({
|
|
140
|
+
action: 'deploy_code',
|
|
141
|
+
source: 'ci-bot',
|
|
142
|
+
payload: {
|
|
143
|
+
repository: 'api-server',
|
|
144
|
+
environment: 'production'
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Check status
|
|
149
|
+
const status = await vienna.intent.status('int-abc123');
|
|
150
|
+
|
|
151
|
+
// Simulate without executing (dry-run)
|
|
152
|
+
const simulation = await vienna.intent.simulate({
|
|
153
|
+
action: 'wire_transfer',
|
|
154
|
+
source: 'billing-bot',
|
|
155
|
+
payload: { amount: 100000 },
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Policy Management
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Create a new policy
|
|
163
|
+
await vienna.policies.create({
|
|
164
|
+
name: 'High-Value Transfers',
|
|
165
|
+
conditions: [{
|
|
166
|
+
field: 'payload.amount',
|
|
167
|
+
operator: 'greater_than',
|
|
168
|
+
value: 50000,
|
|
169
|
+
}],
|
|
170
|
+
actions: ['require_approval'],
|
|
171
|
+
riskTier: 'T3',
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// List and evaluate policies
|
|
175
|
+
const policies = await vienna.policies.list({ enabled: true });
|
|
176
|
+
const evaluation = await vienna.policies.evaluate('pol-123', intentRequest);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Approval Workflows
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// List pending approvals
|
|
183
|
+
const pending = await vienna.approvals.list({ status: 'pending' });
|
|
184
|
+
|
|
185
|
+
// Approve an action
|
|
186
|
+
await vienna.approvals.approve('appr-123', {
|
|
187
|
+
operator: 'jane',
|
|
188
|
+
notes: 'Verified with finance team',
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// Deny an action
|
|
192
|
+
await vienna.approvals.deny('appr-456', {
|
|
193
|
+
operator: 'jane',
|
|
194
|
+
reason: 'Exceeds quarterly budget',
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Fleet Management
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// Monitor your agent fleet
|
|
202
|
+
const agents = await vienna.fleet.list();
|
|
203
|
+
const metrics = await vienna.fleet.metrics('agent-1');
|
|
204
|
+
|
|
205
|
+
// Manage agent status
|
|
206
|
+
await vienna.fleet.suspend('agent-1', { reason: 'Suspicious activity' });
|
|
207
|
+
await vienna.fleet.activate('agent-1');
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Compliance & Reporting
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// Generate compliance reports
|
|
214
|
+
const report = await vienna.compliance.generate({
|
|
215
|
+
type: 'quarterly',
|
|
216
|
+
periodStart: '2024-01-01',
|
|
217
|
+
periodEnd: '2024-03-31',
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// Get quick statistics
|
|
221
|
+
const stats = await vienna.compliance.quickStats({ days: 30 });
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Configuration
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
const vienna = new ViennaClient({
|
|
228
|
+
apiKey: 'vna_your_api_key', // Required
|
|
229
|
+
baseUrl: 'https://vienna-os.fly.dev', // Optional
|
|
230
|
+
timeout: 30000, // Optional, default 30s
|
|
231
|
+
retries: 3, // Optional, default 3
|
|
232
|
+
onError: (error) => { // Optional global error handler
|
|
233
|
+
console.error('Vienna error:', error);
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Error Handling
|
|
239
|
+
|
|
240
|
+
The SDK provides detailed error types:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import {
|
|
244
|
+
ViennaError,
|
|
245
|
+
ViennaAuthError,
|
|
246
|
+
ViennaRateLimitError
|
|
247
|
+
} from '@vienna-os/sdk';
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
await vienna.intent.submit(intent);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (error instanceof ViennaAuthError) {
|
|
253
|
+
console.error('Authentication failed');
|
|
254
|
+
} else if (error instanceof ViennaRateLimitError) {
|
|
255
|
+
console.error('Rate limit exceeded, retry after:', error.retryAfter);
|
|
256
|
+
} else if (error instanceof ViennaError) {
|
|
257
|
+
console.error('Vienna API error:', error.code, error.message);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Examples
|
|
263
|
+
|
|
264
|
+
Check out the [examples directory](./examples/) for complete working examples:
|
|
265
|
+
|
|
266
|
+
- [`basic-usage.ts`](./examples/basic-usage.ts) — Simple intent submission and status checking
|
|
267
|
+
- [`langchain-integration.ts`](./examples/langchain-integration.ts) — Wrapping LangChain tools with governance
|
|
268
|
+
- [`approval-workflow.ts`](./examples/approval-workflow.ts) — T2/T3 approval polling and management
|
|
269
|
+
|
|
270
|
+
## TypeScript Support
|
|
271
|
+
|
|
272
|
+
The SDK is written in TypeScript and provides complete type definitions:
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
import type {
|
|
276
|
+
IntentResult,
|
|
277
|
+
RiskTier,
|
|
278
|
+
PolicyRule,
|
|
279
|
+
FleetAgent
|
|
280
|
+
} from '@vienna-os/sdk';
|
|
281
|
+
|
|
282
|
+
const result: IntentResult = await vienna.intent.submit(intent);
|
|
283
|
+
const tier: RiskTier = result.riskTier; // Typed as 'T0' | 'T1' | 'T2' | 'T3'
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Documentation
|
|
287
|
+
|
|
288
|
+
- **Full Documentation**: [regulator.ai/docs](https://regulator.ai/docs)
|
|
289
|
+
- **Live Console**: [console.regulator.ai](https://console.regulator.ai)
|
|
290
|
+
- **API Reference**: [regulator.ai/docs/api](https://regulator.ai/docs/api)
|
|
291
|
+
- **Governance Guide**: [regulator.ai/docs/governance](https://regulator.ai/docs/governance)
|
|
292
|
+
- **Policy Examples**: [regulator.ai/docs/policies](https://regulator.ai/docs/policies)
|
|
293
|
+
|
|
294
|
+
## Support
|
|
295
|
+
|
|
296
|
+
- **Issues**: [GitHub Issues](https://github.com/risk-ai/regulator.ai/issues)
|
|
297
|
+
- **Documentation**: [regulator.ai/docs](https://regulator.ai/docs)
|
|
298
|
+
- **Email**: support@regulator.ai
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
Apache-2.0 — See [LICENSE](./LICENSE) for details.
|