dashclaw 1.7.0 → 1.7.2
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 +198 -103
- package/dashclaw.js +476 -467
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Full reference for the DashClaw SDK (Node.js). For Python, see the [Python SDK docs](../sdk-python/README.md).
|
|
4
4
|
|
|
5
|
-
Install, configure, and instrument your AI agents with 60+ methods across action recording, behavior guard, context management, session handoffs, security scanning, and more.
|
|
5
|
+
Install, configure, and instrument your AI agents with 60+ methods across action recording, behavior guard, context management, session handoffs, security scanning, and more.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -19,7 +19,8 @@ npm install dashclaw
|
|
|
19
19
|
import { DashClaw } from 'dashclaw';
|
|
20
20
|
|
|
21
21
|
const claw = new DashClaw({
|
|
22
|
-
baseUrl:
|
|
22
|
+
baseUrl: process.env.DASHCLAW_BASE_URL || 'http://localhost:3000',
|
|
23
|
+
// Use http://localhost:3000 for local, or https://your-app.vercel.app for cloud
|
|
23
24
|
apiKey: process.env.DASHCLAW_API_KEY,
|
|
24
25
|
agentId: 'my-agent',
|
|
25
26
|
agentName: 'My Agent',
|
|
@@ -51,52 +52,52 @@ await claw.updateOutcome(action_id, {
|
|
|
51
52
|
|
|
52
53
|
Create a DashClaw instance. Requires Node 18+ (native fetch).
|
|
53
54
|
|
|
54
|
-
```javascript
|
|
55
|
-
const claw = new DashClaw({
|
|
56
|
-
baseUrl,
|
|
57
|
-
apiKey,
|
|
58
|
-
agentId,
|
|
59
|
-
agentName,
|
|
60
|
-
swarmId,
|
|
61
|
-
guardMode,
|
|
62
|
-
guardCallback,
|
|
63
|
-
autoRecommend,
|
|
64
|
-
recommendationConfidenceMin,
|
|
65
|
-
recommendationCallback,
|
|
66
|
-
hitlMode,
|
|
67
|
-
});
|
|
68
|
-
```
|
|
55
|
+
```javascript
|
|
56
|
+
const claw = new DashClaw({
|
|
57
|
+
baseUrl,
|
|
58
|
+
apiKey,
|
|
59
|
+
agentId,
|
|
60
|
+
agentName,
|
|
61
|
+
swarmId,
|
|
62
|
+
guardMode,
|
|
63
|
+
guardCallback,
|
|
64
|
+
autoRecommend,
|
|
65
|
+
recommendationConfidenceMin,
|
|
66
|
+
recommendationCallback,
|
|
67
|
+
hitlMode,
|
|
68
|
+
});
|
|
69
|
+
```
|
|
69
70
|
|
|
70
71
|
### Parameters
|
|
71
72
|
| Parameter | Type | Required | Description |
|
|
72
73
|
|-----------|------|----------|-------------|
|
|
73
|
-
| baseUrl | string | Yes | DashClaw dashboard URL (e.g. "https://your-app.vercel.app") |
|
|
74
|
+
| baseUrl | string | Yes | DashClaw dashboard URL (e.g. "http://localhost:3000" or "https://your-app.vercel.app") |
|
|
74
75
|
| apiKey | string | Yes | API key for authentication (determines which org\'s data you access) |
|
|
75
76
|
| agentId | string | Yes | Unique identifier for this agent |
|
|
76
77
|
| agentName | string | No | Human-readable agent name |
|
|
77
|
-
| swarmId | string | No | Swarm/group identifier if part of a multi-agent system |
|
|
78
|
-
| guardMode | string | No | Auto guard check before createAction/track: "off" (default), "warn" (log + proceed), "enforce" (throw on block) |
|
|
79
|
-
| guardCallback | Function | No | Called with guard decision object when guardMode is active |
|
|
80
|
-
| autoRecommend | string | No | Recommendation auto-adapt mode: "off" (default), "warn" (record override), "enforce" (apply safe hints) |
|
|
81
|
-
| recommendationConfidenceMin | number | No | Min recommendation confidence required for auto-adapt in enforce mode (default 70) |
|
|
82
|
-
| recommendationCallback | Function | No | Called with recommendation adaptation details when autoRecommend is active |
|
|
83
|
-
| hitlMode | string | No | HITL behavior: "off" (default - return 202 immediately), "wait" (automatically block and poll until approved/denied) |
|
|
84
|
-
|
|
85
|
-
### Guard Mode, Auto-Recommend, and HITL
|
|
86
|
-
When enabled, every call to `createAction()` can run recommendation adaptation and guard checks before submission.
|
|
78
|
+
| swarmId | string | No | Swarm/group identifier if part of a multi-agent system |
|
|
79
|
+
| guardMode | string | No | Auto guard check before createAction/track: "off" (default), "warn" (log + proceed), "enforce" (throw on block) |
|
|
80
|
+
| guardCallback | Function | No | Called with guard decision object when guardMode is active |
|
|
81
|
+
| autoRecommend | string | No | Recommendation auto-adapt mode: "off" (default), "warn" (record override), "enforce" (apply safe hints) |
|
|
82
|
+
| recommendationConfidenceMin | number | No | Min recommendation confidence required for auto-adapt in enforce mode (default 70) |
|
|
83
|
+
| recommendationCallback | Function | No | Called with recommendation adaptation details when autoRecommend is active |
|
|
84
|
+
| hitlMode | string | No | HITL behavior: "off" (default - return 202 immediately), "wait" (automatically block and poll until approved/denied) |
|
|
85
|
+
|
|
86
|
+
### Guard Mode, Auto-Recommend, and HITL
|
|
87
|
+
When enabled, every call to `createAction()` can run recommendation adaptation and guard checks before submission.
|
|
87
88
|
|
|
88
89
|
```javascript
|
|
89
90
|
import { DashClaw, GuardBlockedError, ApprovalDeniedError } from 'dashclaw';
|
|
90
91
|
|
|
91
|
-
const claw = new DashClaw({
|
|
92
|
-
baseUrl: '
|
|
93
|
-
apiKey: process.env.DASHCLAW_API_KEY,
|
|
94
|
-
agentId: 'my-agent',
|
|
95
|
-
autoRecommend: 'enforce', // apply safe recommendation hints
|
|
96
|
-
recommendationConfidenceMin: 80,
|
|
97
|
-
guardMode: 'enforce', // throws GuardBlockedError on block
|
|
98
|
-
hitlMode: 'wait', // poll until approved or throw ApprovalDeniedError
|
|
99
|
-
});
|
|
92
|
+
const claw = new DashClaw({
|
|
93
|
+
baseUrl: 'http://localhost:3000',
|
|
94
|
+
apiKey: process.env.DASHCLAW_API_KEY,
|
|
95
|
+
agentId: 'my-agent',
|
|
96
|
+
autoRecommend: 'enforce', // apply safe recommendation hints
|
|
97
|
+
recommendationConfidenceMin: 80,
|
|
98
|
+
guardMode: 'enforce', // throws GuardBlockedError on block
|
|
99
|
+
hitlMode: 'wait', // poll until approved or throw ApprovalDeniedError
|
|
100
|
+
});
|
|
100
101
|
|
|
101
102
|
try {
|
|
102
103
|
await claw.createAction({ action_type: 'deploy', declared_goal: 'Ship v2' });
|
|
@@ -356,7 +357,7 @@ Get drift report for assumptions with risk scoring. Shows which assumptions are
|
|
|
356
357
|
|
|
357
358
|
## Signals
|
|
358
359
|
|
|
359
|
-
Automatic detection of problematic agent behavior. Seven signal types fire based on action patterns
|
|
360
|
+
Automatic detection of problematic agent behavior. Seven signal types fire based on action patterns - no configuration required.
|
|
360
361
|
|
|
361
362
|
### claw.getSignals()
|
|
362
363
|
Get current risk signals across all agents. Returns 7 signal types: autonomy_spike, high_impact_low_oversight, repeated_failures, stale_loop, assumption_drift, stale_assumption, and stale_running_action.
|
|
@@ -411,8 +412,8 @@ Retrieve recent guard evaluation decisions for audit and review.
|
|
|
411
412
|
|
|
412
413
|
Push data from your agent directly to the DashClaw dashboard. All methods auto-attach the agent's agentId.
|
|
413
414
|
|
|
414
|
-
### claw.recordDecision(entry)
|
|
415
|
-
Record a decision for the learning database. Track what your agent decides and why.
|
|
415
|
+
### claw.recordDecision(entry)
|
|
416
|
+
Record a decision for the learning database. Track what your agent decides and why.
|
|
416
417
|
|
|
417
418
|
**Parameters:**
|
|
418
419
|
| Parameter | Type | Required | Description |
|
|
@@ -423,69 +424,69 @@ Record a decision for the learning database. Track what your agent decides and w
|
|
|
423
424
|
| outcome | string | No | "success", "failure", or "pending" |
|
|
424
425
|
| confidence | number | No | Confidence level 0-100 |
|
|
425
426
|
|
|
426
|
-
**Returns:** `Promise<{ decision: Object }>`
|
|
427
|
-
|
|
428
|
-
### claw.getRecommendations(filters?)
|
|
429
|
-
Get adaptive recommendations synthesized from scored historical episodes.
|
|
430
|
-
|
|
431
|
-
**Parameters:**
|
|
432
|
-
| Parameter | Type | Required | Description |
|
|
433
|
-
|-----------|------|----------|-------------|
|
|
434
|
-
| filters.action_type | string | No | Filter by action type |
|
|
435
|
-
| filters.agent_id | string | No | Override agent scope (defaults to SDK agent) |
|
|
436
|
-
| filters.include_inactive | boolean | No | Include disabled recommendations (admin/service only) |
|
|
437
|
-
| filters.track_events | boolean | No | Record fetched telemetry (default true) |
|
|
438
|
-
| filters.include_metrics | boolean | No | Include computed metrics in response |
|
|
439
|
-
| filters.lookback_days | number | No | Lookback window for include_metrics |
|
|
440
|
-
| filters.limit | number | No | Max results (default 50) |
|
|
441
|
-
|
|
442
|
-
**Returns:** `Promise<{ recommendations: Object[], metrics?: Object, total: number }>`
|
|
443
|
-
|
|
444
|
-
### claw.getRecommendationMetrics(filters?)
|
|
445
|
-
Get recommendation telemetry and effectiveness deltas.
|
|
446
|
-
|
|
447
|
-
**Parameters:**
|
|
448
|
-
| Parameter | Type | Required | Description |
|
|
449
|
-
|-----------|------|----------|-------------|
|
|
450
|
-
| filters.action_type | string | No | Filter by action type |
|
|
451
|
-
| filters.agent_id | string | No | Override agent scope (defaults to SDK agent) |
|
|
452
|
-
| filters.lookback_days | number | No | Lookback window (default 30) |
|
|
453
|
-
| filters.limit | number | No | Max recommendations to evaluate (default 100) |
|
|
454
|
-
| filters.include_inactive | boolean | No | Include disabled recommendations (admin/service only) |
|
|
455
|
-
|
|
456
|
-
**Returns:** `Promise<{ metrics: Object[], summary: Object, lookback_days: number }>`
|
|
457
|
-
|
|
458
|
-
### claw.recordRecommendationEvents(events)
|
|
459
|
-
Write recommendation telemetry events (single event or batch).
|
|
460
|
-
|
|
461
|
-
**Returns:** `Promise<{ created: Object[], created_count: number }>`
|
|
462
|
-
|
|
463
|
-
### claw.setRecommendationActive(recommendationId, active)
|
|
464
|
-
Enable or disable one recommendation.
|
|
465
|
-
|
|
466
|
-
**Returns:** `Promise<{ recommendation: Object }>`
|
|
467
|
-
|
|
468
|
-
### claw.rebuildRecommendations(options?)
|
|
469
|
-
Recompute recommendations from recent learning episodes.
|
|
470
|
-
|
|
471
|
-
**Parameters:**
|
|
472
|
-
| Parameter | Type | Required | Description |
|
|
473
|
-
|-----------|------|----------|-------------|
|
|
474
|
-
| options.action_type | string | No | Restrict rebuild to one action type |
|
|
475
|
-
| options.lookback_days | number | No | Episode history window (default 30) |
|
|
476
|
-
| options.min_samples | number | No | Minimum samples per recommendation (default 5) |
|
|
477
|
-
| options.episode_limit | number | No | Episode scan cap (default 5000) |
|
|
478
|
-
| options.action_id | string | No | Score this action before rebuilding |
|
|
479
|
-
|
|
480
|
-
**Returns:** `Promise<{ recommendations: Object[], total: number, episodes_scanned: number }>`
|
|
481
|
-
|
|
482
|
-
### claw.recommendAction(action)
|
|
483
|
-
Apply top recommendation hints to an action payload without mutating the original object.
|
|
484
|
-
|
|
485
|
-
**Returns:** `Promise<{ action: Object, recommendation: Object|null, adapted_fields: string[] }>`
|
|
486
|
-
|
|
487
|
-
### claw.createGoal(goal)
|
|
488
|
-
Create a goal in the goals tracker.
|
|
427
|
+
**Returns:** `Promise<{ decision: Object }>`
|
|
428
|
+
|
|
429
|
+
### claw.getRecommendations(filters?)
|
|
430
|
+
Get adaptive recommendations synthesized from scored historical episodes.
|
|
431
|
+
|
|
432
|
+
**Parameters:**
|
|
433
|
+
| Parameter | Type | Required | Description |
|
|
434
|
+
|-----------|------|----------|-------------|
|
|
435
|
+
| filters.action_type | string | No | Filter by action type |
|
|
436
|
+
| filters.agent_id | string | No | Override agent scope (defaults to SDK agent) |
|
|
437
|
+
| filters.include_inactive | boolean | No | Include disabled recommendations (admin/service only) |
|
|
438
|
+
| filters.track_events | boolean | No | Record fetched telemetry (default true) |
|
|
439
|
+
| filters.include_metrics | boolean | No | Include computed metrics in response |
|
|
440
|
+
| filters.lookback_days | number | No | Lookback window for include_metrics |
|
|
441
|
+
| filters.limit | number | No | Max results (default 50) |
|
|
442
|
+
|
|
443
|
+
**Returns:** `Promise<{ recommendations: Object[], metrics?: Object, total: number }>`
|
|
444
|
+
|
|
445
|
+
### claw.getRecommendationMetrics(filters?)
|
|
446
|
+
Get recommendation telemetry and effectiveness deltas.
|
|
447
|
+
|
|
448
|
+
**Parameters:**
|
|
449
|
+
| Parameter | Type | Required | Description |
|
|
450
|
+
|-----------|------|----------|-------------|
|
|
451
|
+
| filters.action_type | string | No | Filter by action type |
|
|
452
|
+
| filters.agent_id | string | No | Override agent scope (defaults to SDK agent) |
|
|
453
|
+
| filters.lookback_days | number | No | Lookback window (default 30) |
|
|
454
|
+
| filters.limit | number | No | Max recommendations to evaluate (default 100) |
|
|
455
|
+
| filters.include_inactive | boolean | No | Include disabled recommendations (admin/service only) |
|
|
456
|
+
|
|
457
|
+
**Returns:** `Promise<{ metrics: Object[], summary: Object, lookback_days: number }>`
|
|
458
|
+
|
|
459
|
+
### claw.recordRecommendationEvents(events)
|
|
460
|
+
Write recommendation telemetry events (single event or batch).
|
|
461
|
+
|
|
462
|
+
**Returns:** `Promise<{ created: Object[], created_count: number }>`
|
|
463
|
+
|
|
464
|
+
### claw.setRecommendationActive(recommendationId, active)
|
|
465
|
+
Enable or disable one recommendation.
|
|
466
|
+
|
|
467
|
+
**Returns:** `Promise<{ recommendation: Object }>`
|
|
468
|
+
|
|
469
|
+
### claw.rebuildRecommendations(options?)
|
|
470
|
+
Recompute recommendations from recent learning episodes.
|
|
471
|
+
|
|
472
|
+
**Parameters:**
|
|
473
|
+
| Parameter | Type | Required | Description |
|
|
474
|
+
|-----------|------|----------|-------------|
|
|
475
|
+
| options.action_type | string | No | Restrict rebuild to one action type |
|
|
476
|
+
| options.lookback_days | number | No | Episode history window (default 30) |
|
|
477
|
+
| options.min_samples | number | No | Minimum samples per recommendation (default 5) |
|
|
478
|
+
| options.episode_limit | number | No | Episode scan cap (default 5000) |
|
|
479
|
+
| options.action_id | string | No | Score this action before rebuilding |
|
|
480
|
+
|
|
481
|
+
**Returns:** `Promise<{ recommendations: Object[], total: number, episodes_scanned: number }>`
|
|
482
|
+
|
|
483
|
+
### claw.recommendAction(action)
|
|
484
|
+
Apply top recommendation hints to an action payload without mutating the original object.
|
|
485
|
+
|
|
486
|
+
**Returns:** `Promise<{ action: Object, recommendation: Object|null, adapted_fields: string[] }>`
|
|
487
|
+
|
|
488
|
+
### claw.createGoal(goal)
|
|
489
|
+
Create a goal in the goals tracker.
|
|
489
490
|
|
|
490
491
|
**Parameters:**
|
|
491
492
|
| Parameter | Type | Required | Description |
|
|
@@ -607,6 +608,100 @@ Add an entry to an existing thread.
|
|
|
607
608
|
|
|
608
609
|
---
|
|
609
610
|
|
|
611
|
+
## Automation Snippets
|
|
612
|
+
|
|
613
|
+
Save, search, and reuse code snippets across agent sessions.
|
|
614
|
+
|
|
615
|
+
### claw.saveSnippet(snippet)
|
|
616
|
+
Save or update a reusable code snippet. Upserts on name.
|
|
617
|
+
|
|
618
|
+
**Parameters:**
|
|
619
|
+
| Parameter | Type | Required | Description |
|
|
620
|
+
|-----------|------|----------|-------------|
|
|
621
|
+
| name | string | Yes | Snippet name (unique per org) |
|
|
622
|
+
| code | string | Yes | The snippet code |
|
|
623
|
+
| description | string | No | What this snippet does |
|
|
624
|
+
| language | string | No | Programming language |
|
|
625
|
+
| tags | string[] | No | Tags for categorization |
|
|
626
|
+
|
|
627
|
+
**Returns:** `Promise<{snippet: Object, snippet_id: string}>`
|
|
628
|
+
|
|
629
|
+
**Example:**
|
|
630
|
+
```javascript
|
|
631
|
+
await claw.saveSnippet({
|
|
632
|
+
name: 'fetch-with-retry',
|
|
633
|
+
code: 'async function fetchRetry(url, n = 3) { ... }',
|
|
634
|
+
language: 'javascript',
|
|
635
|
+
tags: ['fetch', 'retry'],
|
|
636
|
+
});
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### claw.getSnippet(snippetId)
|
|
640
|
+
Fetch a single snippet by ID.
|
|
641
|
+
|
|
642
|
+
**Parameters:**
|
|
643
|
+
| Parameter | Type | Required | Description |
|
|
644
|
+
|-----------|------|----------|-------------|
|
|
645
|
+
| snippetId | string | Yes | The snippet ID |
|
|
646
|
+
|
|
647
|
+
**Returns:** `Promise<{snippet: Object}>`
|
|
648
|
+
|
|
649
|
+
**Example:**
|
|
650
|
+
```javascript
|
|
651
|
+
const { snippet } = await claw.getSnippet('sn_abc123');
|
|
652
|
+
console.log(snippet.name, snippet.language);
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
### claw.getSnippets(filters?)
|
|
656
|
+
Search and list snippets.
|
|
657
|
+
|
|
658
|
+
**Parameters:**
|
|
659
|
+
| Parameter | Type | Required | Description |
|
|
660
|
+
|-----------|------|----------|-------------|
|
|
661
|
+
| search | string | No | Search name/description |
|
|
662
|
+
| tag | string | No | Filter by tag |
|
|
663
|
+
| language | string | No | Filter by language |
|
|
664
|
+
| limit | number | No | Max results |
|
|
665
|
+
|
|
666
|
+
**Returns:** `Promise<{snippets: Object[], total: number}>`
|
|
667
|
+
|
|
668
|
+
**Example:**
|
|
669
|
+
```javascript
|
|
670
|
+
const { snippets } = await claw.getSnippets({ language: 'javascript' });
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### claw.useSnippet(snippetId)
|
|
674
|
+
Mark a snippet as used (increments use_count).
|
|
675
|
+
|
|
676
|
+
**Parameters:**
|
|
677
|
+
| Parameter | Type | Required | Description |
|
|
678
|
+
|-----------|------|----------|-------------|
|
|
679
|
+
| snippetId | string | Yes | Snippet ID |
|
|
680
|
+
|
|
681
|
+
**Returns:** `Promise<{snippet: Object}>`
|
|
682
|
+
|
|
683
|
+
**Example:**
|
|
684
|
+
```javascript
|
|
685
|
+
await claw.useSnippet('sn_abc123');
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
### claw.deleteSnippet(snippetId)
|
|
689
|
+
Delete a snippet.
|
|
690
|
+
|
|
691
|
+
**Parameters:**
|
|
692
|
+
| Parameter | Type | Required | Description |
|
|
693
|
+
|-----------|------|----------|-------------|
|
|
694
|
+
| snippetId | string | Yes | Snippet ID |
|
|
695
|
+
|
|
696
|
+
**Returns:** `Promise<{deleted: boolean, id: string}>`
|
|
697
|
+
|
|
698
|
+
**Example:**
|
|
699
|
+
```javascript
|
|
700
|
+
await claw.deleteSnippet('sn_abc123');
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
---
|
|
704
|
+
|
|
610
705
|
## Agent Messaging
|
|
611
706
|
|
|
612
707
|
### claw.sendMessage(params)
|