dashclaw 2.6.0 → 2.8.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 +101 -1
- package/dashclaw.js +70 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# DashClaw SDK (v2.
|
|
1
|
+
# DashClaw SDK (v2.7.0)
|
|
2
2
|
|
|
3
3
|
**Minimal governance runtime for AI agents.**
|
|
4
4
|
|
|
@@ -235,6 +235,106 @@ await claw.syncState({
|
|
|
235
235
|
|
|
236
236
|
---
|
|
237
237
|
|
|
238
|
+
## Agent Identity
|
|
239
|
+
|
|
240
|
+
Enroll agents via public-key pairing and manage approved identities for signature verification. Pairing is available in the v1 legacy SDK; the REST endpoints are callable directly from any HTTP client.
|
|
241
|
+
|
|
242
|
+
### Create Pairing
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
// Node SDK (v1 legacy)
|
|
246
|
+
import { DashClaw } from 'dashclaw/legacy';
|
|
247
|
+
const claw = new DashClaw({ baseUrl, apiKey, agentId });
|
|
248
|
+
|
|
249
|
+
const { pairing } = await claw.createPairing(publicKeyPem, 'RSASSA-PKCS1-v1_5', 'my-agent');
|
|
250
|
+
console.log(pairing.id); // pair_...
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Wait for Pairing Approval
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
const approved = await claw.waitForPairing(pairing.id, { timeout: 300 });
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Get Pairing
|
|
260
|
+
|
|
261
|
+
```javascript
|
|
262
|
+
const status = await claw.getPairing(pairingId);
|
|
263
|
+
console.log(status.pairing.status); // pending | approved | expired
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Approve Pairing (Admin)
|
|
267
|
+
|
|
268
|
+
```javascript
|
|
269
|
+
// Direct HTTP — admin API key required
|
|
270
|
+
const res = await fetch(`${baseUrl}/api/pairings/${pairingId}/approve`, {
|
|
271
|
+
method: 'POST',
|
|
272
|
+
headers: { 'x-api-key': adminApiKey }
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### List Pairings (Admin)
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
const res = await fetch(`${baseUrl}/api/pairings`, {
|
|
280
|
+
headers: { 'x-api-key': adminApiKey }
|
|
281
|
+
});
|
|
282
|
+
const { pairings } = await res.json();
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Register Identity (Admin)
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
// Node SDK (v1 legacy)
|
|
289
|
+
await claw.registerIdentity('agent-007', publicKeyPem, 'RSASSA-PKCS1-v1_5');
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### List Identities (Admin)
|
|
293
|
+
|
|
294
|
+
```javascript
|
|
295
|
+
const { identities } = await claw.getIdentities();
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Revoke Identity (Admin)
|
|
299
|
+
|
|
300
|
+
```javascript
|
|
301
|
+
// Direct HTTP — admin API key required
|
|
302
|
+
const res = await fetch(`${baseUrl}/api/identities/${agentId}`, {
|
|
303
|
+
method: 'DELETE',
|
|
304
|
+
headers: { 'x-api-key': adminApiKey }
|
|
305
|
+
});
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## Action Context (Auto-Tagging)
|
|
311
|
+
|
|
312
|
+
When sending messages or recording assumptions during an action, use `actionContext()` to automatically tag them with the action_id:
|
|
313
|
+
|
|
314
|
+
### Node.js
|
|
315
|
+
```javascript
|
|
316
|
+
const action = await claw.createAction({ action_type: 'deploy', declared_goal: 'Deploy v2' });
|
|
317
|
+
|
|
318
|
+
const ctx = claw.actionContext(action.action_id);
|
|
319
|
+
await ctx.sendMessage({ to: 'ops-agent', type: 'status', body: 'Starting deploy' });
|
|
320
|
+
await ctx.recordAssumption({ assumption: 'Staging tests passed' });
|
|
321
|
+
await ctx.updateOutcome({ status: 'completed', output_summary: 'Deployed' });
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Python
|
|
325
|
+
```python
|
|
326
|
+
action = claw.create_action(action_type="deploy", declared_goal="Deploy v2")
|
|
327
|
+
|
|
328
|
+
with claw.action_context(action["action_id"]) as ctx:
|
|
329
|
+
ctx.send_message("Starting deploy", to="ops-agent")
|
|
330
|
+
ctx.record_assumption({"assumption": "Staging tests passed"})
|
|
331
|
+
ctx.update_outcome(status="completed", output_summary="Deployed")
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Messages sent through the context are automatically correlated with the action in the decisions ledger and timeline.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
238
338
|
## Error Handling
|
|
239
339
|
|
|
240
340
|
DashClaw uses standard HTTP status codes and custom error classes:
|
package/dashclaw.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DashClaw SDK v2 (Stable Runtime API)
|
|
2
|
+
* DashClaw SDK v2.8.0 (Stable Runtime API)
|
|
3
3
|
* Focused governance runtime client for AI agents.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -456,6 +456,26 @@ class DashClaw {
|
|
|
456
456
|
});
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
+
/**
|
|
460
|
+
* Create a scoped action context that auto-tags messages and assumptions
|
|
461
|
+
* with the given action_id.
|
|
462
|
+
* @param {string} actionId - The action_id to attach to all operations
|
|
463
|
+
* @returns {{ sendMessage, recordAssumption, updateOutcome }}
|
|
464
|
+
*/
|
|
465
|
+
actionContext(actionId) {
|
|
466
|
+
return {
|
|
467
|
+
sendMessage: ({ to, type, subject, body, threadId, urgent }) => {
|
|
468
|
+
return this.sendMessage({ to, type, subject, body, threadId, urgent, actionId });
|
|
469
|
+
},
|
|
470
|
+
recordAssumption: (assumption) => {
|
|
471
|
+
return this.recordAssumption({ ...assumption, action_id: actionId });
|
|
472
|
+
},
|
|
473
|
+
updateOutcome: (outcome) => {
|
|
474
|
+
return this.updateOutcome(actionId, outcome);
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
459
479
|
/**
|
|
460
480
|
* GET /api/messages — Fetch this agent's inbox.
|
|
461
481
|
*/
|
|
@@ -574,6 +594,55 @@ class DashClaw {
|
|
|
574
594
|
...state,
|
|
575
595
|
});
|
|
576
596
|
}
|
|
597
|
+
|
|
598
|
+
// ---------------------------------------------------------------------------
|
|
599
|
+
// Session Lifecycle
|
|
600
|
+
// ---------------------------------------------------------------------------
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* POST /api/sessions — Create a new agent session.
|
|
604
|
+
* @param {string} agentId - Agent identifier (defaults to this.agentId)
|
|
605
|
+
* @param {string} workspace - Workspace path or identifier
|
|
606
|
+
* @param {string|null} [branch=null] - Optional git branch
|
|
607
|
+
*/
|
|
608
|
+
async createSession(agentId, workspace, branch = null) {
|
|
609
|
+
return this._request('/api/sessions', 'POST', {
|
|
610
|
+
agent_id: agentId || this.agentId,
|
|
611
|
+
workspace,
|
|
612
|
+
branch,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* GET /api/sessions/:id — Fetch a single session by ID.
|
|
618
|
+
*/
|
|
619
|
+
async getSession(sessionId) {
|
|
620
|
+
return this._request(`/api/sessions/${sessionId}`, 'GET');
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* PATCH /api/sessions/:id — Update session state.
|
|
625
|
+
* @param {string} sessionId
|
|
626
|
+
* @param {Object} updates - Fields to update (status, green_level, branch_freshness, commits_behind, blocked_reason)
|
|
627
|
+
*/
|
|
628
|
+
async updateSession(sessionId, updates) {
|
|
629
|
+
return this._request(`/api/sessions/${sessionId}`, 'PATCH', updates);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* GET /api/sessions — List sessions with optional filters.
|
|
634
|
+
* @param {Object} [filters={}] - Query filters (agent_id, status, limit)
|
|
635
|
+
*/
|
|
636
|
+
async listSessions(filters = {}) {
|
|
637
|
+
return this._request('/api/sessions', 'GET', null, filters);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* GET /api/sessions/:id/events — Fetch events for a session.
|
|
642
|
+
*/
|
|
643
|
+
async getSessionEvents(sessionId) {
|
|
644
|
+
return this._request(`/api/sessions/${sessionId}/events`, 'GET');
|
|
645
|
+
}
|
|
577
646
|
}
|
|
578
647
|
|
|
579
648
|
export { DashClaw, ApprovalDeniedError, GuardBlockedError };
|