@waitroom-io/sdk 0.0.1 → 0.0.4
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 +195 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# @waitroom-io/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [Waitroom](https://waitroom.io) API — the coordination layer between AI agents and humans.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @waitroom-io/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { WaitroomClient } from '@waitroom-io/sdk';
|
|
15
|
+
|
|
16
|
+
const client = new WaitroomClient({
|
|
17
|
+
apiKey: 'wr_your_api_key',
|
|
18
|
+
baseUrl: 'https://api.waitroom.io', // optional, defaults to http://localhost:3001
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Create a check-in and wait for approval
|
|
22
|
+
const checkIn = await client.checkIns.checkInAndWait('general', {
|
|
23
|
+
action: 'Deploy to production',
|
|
24
|
+
risk_level: 'high',
|
|
25
|
+
description: 'Deploying v2.1.0 with database migrations',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (checkIn.status === 'approved') {
|
|
29
|
+
console.log('Approved! Proceeding with deployment...');
|
|
30
|
+
} else if (checkIn.status === 'modified') {
|
|
31
|
+
console.log('Modified:', checkIn.modifications);
|
|
32
|
+
} else {
|
|
33
|
+
console.log('Rejected:', checkIn.decision_reason);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Resources
|
|
38
|
+
|
|
39
|
+
### Check-Ins
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// Create a check-in
|
|
43
|
+
const checkIn = await client.checkIns.create('room-slug', {
|
|
44
|
+
action: 'Deploy API',
|
|
45
|
+
risk_level: 'medium', // low | medium | high | critical
|
|
46
|
+
urgency: 'normal', // low | normal | high | urgent
|
|
47
|
+
description: 'Optional details',
|
|
48
|
+
context: { pr: '#123' },
|
|
49
|
+
timeout_minutes: 60,
|
|
50
|
+
timeout_action: 'cancel', // auto_approve | cancel | hold
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Create and wait for decision (polls with exponential backoff)
|
|
54
|
+
const result = await client.checkIns.checkInAndWait('room-slug', {
|
|
55
|
+
action: 'Deploy API',
|
|
56
|
+
}, { maxWaitMs: 300000 }); // 5 min default
|
|
57
|
+
|
|
58
|
+
// Poll status
|
|
59
|
+
const status = await client.checkIns.getStatus('ci_abc123');
|
|
60
|
+
|
|
61
|
+
// Approve / Reject / Modify
|
|
62
|
+
await client.checkIns.approve('ci_abc123', { reason: 'Looks good' });
|
|
63
|
+
await client.checkIns.reject('ci_abc123', { reason: 'Too risky' });
|
|
64
|
+
await client.checkIns.modify('ci_abc123', {
|
|
65
|
+
reason: 'Use staging first',
|
|
66
|
+
modifications: { environment: 'staging' },
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Withdraw a pending check-in
|
|
70
|
+
await client.checkIns.withdraw('ci_abc123');
|
|
71
|
+
|
|
72
|
+
// List pending check-ins in a room
|
|
73
|
+
const pending = await client.checkIns.listPending('room-slug');
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Rooms
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const rooms = await client.rooms.list();
|
|
80
|
+
const room = await client.rooms.get('room-slug');
|
|
81
|
+
const created = await client.rooms.create({ name: 'Deployments', slug: 'deployments' });
|
|
82
|
+
await client.rooms.update('room-slug', { description: 'Production deploys' });
|
|
83
|
+
await client.rooms.delete('room-slug');
|
|
84
|
+
|
|
85
|
+
// Policies
|
|
86
|
+
await client.rooms.updatePolicies('room-slug', {
|
|
87
|
+
policies: {
|
|
88
|
+
default_action: 'require_approval',
|
|
89
|
+
timeout_minutes: 30,
|
|
90
|
+
timeout_action: 'cancel',
|
|
91
|
+
rules: [
|
|
92
|
+
{ action: 'auto_approve', conditions: { risk_level: ['low'] } },
|
|
93
|
+
{ action: 'forbid', conditions: { risk_level: ['critical'] } },
|
|
94
|
+
],
|
|
95
|
+
trust_thresholds: { auto_approve_low: 80, auto_approve_medium: 60 },
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Room audit trail
|
|
100
|
+
const events = await client.rooms.getAudit('room-slug');
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Agents
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const agents = await client.agents.list();
|
|
107
|
+
const agent = await client.agents.get('agent-id');
|
|
108
|
+
const me = await client.agents.me();
|
|
109
|
+
|
|
110
|
+
// Register (human-initiated)
|
|
111
|
+
const { agent, api_key } = await client.agents.register({
|
|
112
|
+
name: 'Deploy Bot',
|
|
113
|
+
platform: 'github-actions',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Self-register (no auth required)
|
|
117
|
+
const { agent, api_key, claim_token } = await client.agents.selfRegister({
|
|
118
|
+
name: 'My Agent',
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Claim a self-registered agent
|
|
122
|
+
await client.agents.claim('wr_claim_abc123');
|
|
123
|
+
|
|
124
|
+
// Update / Delete
|
|
125
|
+
await client.agents.update('agent-id', { name: 'New Name' });
|
|
126
|
+
await client.agents.delete('agent-id');
|
|
127
|
+
|
|
128
|
+
// Regenerate API key
|
|
129
|
+
const { api_key } = await client.agents.regenerateKey('agent-id');
|
|
130
|
+
|
|
131
|
+
// Trust scores
|
|
132
|
+
const scores = await client.agents.getTrust('agent-id');
|
|
133
|
+
|
|
134
|
+
// Agent audit trail
|
|
135
|
+
const events = await client.agents.getAudit('agent-id');
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Signals
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
await client.signals.broadcast('room-slug', {
|
|
142
|
+
type: 'deployment.started',
|
|
143
|
+
payload: { version: '2.1.0', environment: 'production' },
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Watchers
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const watcher = await client.watchers.create('room-slug', {
|
|
151
|
+
event_types: ['check_in.created', 'check_in.decided'],
|
|
152
|
+
webhook_url: 'https://example.com/webhook', // optional
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
await client.watchers.remove('w_abc123');
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Audit
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
const { events, cursor } = await client.audit.list({
|
|
162
|
+
event_type: 'check_in.created',
|
|
163
|
+
limit: 50,
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Home
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// Agent dashboard summary
|
|
171
|
+
const dashboard = await client.home();
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Error Handling
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { WaitroomError } from '@waitroom-io/sdk';
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
await client.checkIns.approve('ci_abc123');
|
|
181
|
+
} catch (err) {
|
|
182
|
+
if (err instanceof WaitroomError) {
|
|
183
|
+
console.error(err.code); // 'NOT_FOUND'
|
|
184
|
+
console.error(err.statusCode); // 404
|
|
185
|
+
console.error(err.message); // 'Check-in not found'
|
|
186
|
+
console.error(err.details); // validation errors, if any
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Links
|
|
192
|
+
|
|
193
|
+
- [Documentation](https://waitroom.io/docs)
|
|
194
|
+
- [CLI](https://www.npmjs.com/package/@waitroom-io/cli)
|
|
195
|
+
- [GitHub](https://github.com/anthropics/waitroom)
|