dashclaw 1.2.4 → 1.2.5
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 +522 -155
- package/dashclaw.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,194 +1,561 @@
|
|
|
1
|
-
# DashClaw
|
|
1
|
+
# DashClaw SDK Reference (Full)
|
|
2
2
|
|
|
3
|
-
Full
|
|
3
|
+
Full reference for the DashClaw SDK (Node.js). For Python, see the [Python SDK docs](../sdk-python/README.md).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Install, configure, and instrument your AI agents with 57 methods across action recording, behavior guard, context management, session handoffs, security scanning, and more.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
### 1. Copy the SDK
|
|
12
|
+
Install from npm, or copy the single-file SDK directly.
|
|
9
13
|
```bash
|
|
10
14
|
npm install dashclaw
|
|
11
15
|
```
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```js
|
|
17
|
+
### 2. Initialize the client
|
|
18
|
+
```javascript
|
|
16
19
|
import { DashClaw } from 'dashclaw';
|
|
17
20
|
|
|
18
21
|
const claw = new DashClaw({
|
|
19
|
-
baseUrl: 'https://your-
|
|
22
|
+
baseUrl: 'https://your-dashboard.vercel.app',
|
|
20
23
|
apiKey: process.env.DASHCLAW_API_KEY,
|
|
21
24
|
agentId: 'my-agent',
|
|
22
25
|
agentName: 'My Agent',
|
|
23
|
-
// Optional: Cryptographic Identity Binding
|
|
24
|
-
// Supports CryptoKey object or plain JWK object
|
|
25
|
-
// privateKey: JSON.parse(process.env.AGENT_PRIVATE_KEY)
|
|
26
26
|
});
|
|
27
|
+
```
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
### 3. Record your first action
|
|
30
|
+
```javascript
|
|
31
|
+
// Create an action before doing work
|
|
29
32
|
const { action_id } = await claw.createAction({
|
|
30
33
|
action_type: 'deploy',
|
|
31
|
-
declared_goal: 'Deploy
|
|
34
|
+
declared_goal: 'Deploy authentication service',
|
|
32
35
|
risk_score: 60,
|
|
33
36
|
});
|
|
34
37
|
|
|
35
38
|
// ... do the work ...
|
|
36
39
|
|
|
40
|
+
// Update when done
|
|
37
41
|
await claw.updateOutcome(action_id, {
|
|
38
42
|
status: 'completed',
|
|
39
|
-
output_summary: 'Auth service deployed
|
|
43
|
+
output_summary: 'Auth service deployed to prod',
|
|
40
44
|
});
|
|
41
45
|
```
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
---
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
## Constructor
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
import { DashClaw } from 'dashclaw';
|
|
52
|
-
import { OpenClawAgent } from 'dashclaw';
|
|
51
|
+
Create a DashClaw instance. Requires Node 18+ (native fetch).
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
const claw = new DashClaw({ baseUrl, apiKey, agentId, agentName, swarmId, guardMode, guardCallback });
|
|
53
55
|
```
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
| `registerOpenLoop(loop)` | Register an unresolved item |
|
|
73
|
-
| `resolveOpenLoop(loopId, status, resolution)` | Close an open loop |
|
|
74
|
-
| `getOpenLoops(filters?)` | List open loops |
|
|
75
|
-
| `registerAssumption(assumption)` | Record an assumption |
|
|
76
|
-
| `getAssumption(assumptionId)` | Get single assumption |
|
|
77
|
-
| `validateAssumption(id, validated, reason?)` | Validate or invalidate |
|
|
78
|
-
| `getDriftReport(filters?)` | Get assumption drift scores |
|
|
79
|
-
|
|
80
|
-
### Signals (1)
|
|
81
|
-
|
|
82
|
-
| Method | Description |
|
|
83
|
-
|--------|-------------|
|
|
84
|
-
| `getSignals()` | Get computed risk signals |
|
|
85
|
-
|
|
86
|
-
### Dashboard Data (9)
|
|
87
|
-
|
|
88
|
-
| Method | Description |
|
|
89
|
-
|--------|-------------|
|
|
90
|
-
| `recordDecision(entry)` | Record a decision |
|
|
91
|
-
| `createGoal(goal)` | Create a goal |
|
|
92
|
-
| `recordContent(content)` | Record content creation |
|
|
93
|
-
| `recordInteraction(interaction)` | Record a relationship interaction |
|
|
94
|
-
| `reportConnections(connections)` | Report agent integrations |
|
|
95
|
-
| `createCalendarEvent(event)` | Create a calendar event |
|
|
96
|
-
| `recordIdea(idea)` | Record an idea/inspiration |
|
|
97
|
-
| `reportMemoryHealth(report)` | Report memory health snapshot |
|
|
98
|
-
| `reportTokenUsage(usage)` | Report token usage (legacy) |
|
|
99
|
-
|
|
100
|
-
### Session Handoffs (3)
|
|
101
|
-
|
|
102
|
-
| Method | Description |
|
|
103
|
-
|--------|-------------|
|
|
104
|
-
| `createHandoff(handoff)` | Create a session handoff document |
|
|
105
|
-
| `getHandoffs(filters?)` | Get handoffs for this agent |
|
|
106
|
-
| `getLatestHandoff()` | Get the most recent handoff |
|
|
107
|
-
|
|
108
|
-
### Context Manager (7)
|
|
109
|
-
|
|
110
|
-
| Method | Description |
|
|
111
|
-
|--------|-------------|
|
|
112
|
-
| `captureKeyPoint(point)` | Capture a key point |
|
|
113
|
-
| `getKeyPoints(filters?)` | Get key points |
|
|
114
|
-
| `createThread(thread)` | Create a context thread |
|
|
115
|
-
| `addThreadEntry(threadId, content)` | Add entry to a thread |
|
|
116
|
-
| `closeThread(threadId, summary?)` | Close a thread |
|
|
117
|
-
| `getThreads(filters?)` | Get threads |
|
|
118
|
-
| `getContextSummary()` | Today's points + active threads |
|
|
119
|
-
|
|
120
|
-
### Automation Snippets (4)
|
|
121
|
-
|
|
122
|
-
| Method | Description |
|
|
123
|
-
|--------|-------------|
|
|
124
|
-
| `saveSnippet(snippet)` | Save/update a code snippet |
|
|
125
|
-
| `getSnippets(filters?)` | Search and list snippets |
|
|
126
|
-
| `useSnippet(snippetId)` | Mark snippet as used |
|
|
127
|
-
| `deleteSnippet(snippetId)` | Delete a snippet |
|
|
128
|
-
|
|
129
|
-
### User Preferences (6)
|
|
130
|
-
|
|
131
|
-
| Method | Description |
|
|
132
|
-
|--------|-------------|
|
|
133
|
-
| `logObservation(obs)` | Log a user observation |
|
|
134
|
-
| `setPreference(pref)` | Set a learned preference |
|
|
135
|
-
| `logMood(entry)` | Log user mood/energy |
|
|
136
|
-
| `trackApproach(entry)` | Track approach success/failure |
|
|
137
|
-
| `getPreferenceSummary()` | Get preference summary |
|
|
138
|
-
| `getApproaches(filters?)` | Get tracked approaches |
|
|
139
|
-
|
|
140
|
-
### Daily Digest (1)
|
|
141
|
-
|
|
142
|
-
| Method | Description |
|
|
143
|
-
|--------|-------------|
|
|
144
|
-
| `getDailyDigest(date?)` | Aggregated daily summary |
|
|
145
|
-
|
|
146
|
-
### Security Scanning (2)
|
|
147
|
-
|
|
148
|
-
| Method | Description |
|
|
149
|
-
|--------|-------------|
|
|
150
|
-
| `scanContent(text, destination?)` | Scan text for sensitive data |
|
|
151
|
-
| `reportSecurityFinding(text, dest?)` | Scan + store finding metadata |
|
|
152
|
-
|
|
153
|
-
### Agent Messaging (9)
|
|
154
|
-
|
|
155
|
-
| Method | Description |
|
|
156
|
-
|--------|-------------|
|
|
157
|
-
| `sendMessage(params)` | Send message to agent or broadcast |
|
|
158
|
-
| `getInbox(filters?)` | Get inbox messages |
|
|
159
|
-
| `markRead(messageIds)` | Mark messages as read |
|
|
160
|
-
| `archiveMessages(messageIds)` | Archive messages |
|
|
161
|
-
| `broadcast(params)` | Send to all agents in org |
|
|
162
|
-
| `createMessageThread(params)` | Start a conversation thread |
|
|
163
|
-
| `getMessageThreads(filters?)` | List message threads |
|
|
164
|
-
| `resolveMessageThread(threadId, summary?)` | Close a thread |
|
|
165
|
-
| `saveSharedDoc(params)` | Create/update shared document |
|
|
166
|
-
|
|
167
|
-
### Behavior Guard (2)
|
|
168
|
-
|
|
169
|
-
| Method | Description |
|
|
170
|
-
|--------|-------------|
|
|
171
|
-
| `guard(context, options?)` | Check policies before action |
|
|
172
|
-
| `getGuardDecisions(filters?)` | List recent decisions |
|
|
173
|
-
|
|
174
|
-
### Bulk Sync (1)
|
|
175
|
-
|
|
176
|
-
| Method | Description |
|
|
177
|
-
|--------|-------------|
|
|
178
|
-
| `syncState(state)` | Sync multiple categories in one request |
|
|
179
|
-
|
|
180
|
-
## Authentication
|
|
181
|
-
|
|
182
|
-
The SDK sends your API key via the `x-api-key` header. The key determines which organization's data you access.
|
|
183
|
-
|
|
184
|
-
```js
|
|
57
|
+
### Parameters
|
|
58
|
+
| Parameter | Type | Required | Description |
|
|
59
|
+
|-----------|------|----------|-------------|
|
|
60
|
+
| baseUrl | string | Yes | DashClaw dashboard URL (e.g. "https://your-app.vercel.app") |
|
|
61
|
+
| apiKey | string | Yes | API key for authentication (determines which org\'s data you access) |
|
|
62
|
+
| agentId | string | Yes | Unique identifier for this agent |
|
|
63
|
+
| agentName | string | No | Human-readable agent name |
|
|
64
|
+
| swarmId | string | No | Swarm/group identifier if part of a multi-agent system |
|
|
65
|
+
| guardMode | string | No | Auto guard check before createAction/track: "off" (default), "warn" (log + proceed), "enforce" (throw on block) |
|
|
66
|
+
| guardCallback | Function | No | Called with guard decision object when guardMode is active |
|
|
67
|
+
|
|
68
|
+
### Guard Mode
|
|
69
|
+
When `guardMode` is set, every call to `createAction()` and `track()` automatically checks guard policies before proceeding.
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import { DashClaw, GuardBlockedError } from 'dashclaw';
|
|
73
|
+
|
|
185
74
|
const claw = new DashClaw({
|
|
186
|
-
baseUrl: 'https://your-
|
|
75
|
+
baseUrl: 'https://your-app.vercel.app',
|
|
187
76
|
apiKey: process.env.DASHCLAW_API_KEY,
|
|
188
77
|
agentId: 'my-agent',
|
|
78
|
+
guardMode: 'enforce', // throws GuardBlockedError on block/require_approval
|
|
79
|
+
guardCallback: (decision) => console.log('Guard:', decision.decision),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
await claw.createAction({ action_type: 'deploy', declared_goal: 'Ship v2' });
|
|
84
|
+
} catch (err) {
|
|
85
|
+
if (err instanceof GuardBlockedError) {
|
|
86
|
+
console.log(err.decision); // 'block' or 'require_approval'
|
|
87
|
+
console.log(err.reasons); // ['Risk score 90 >= threshold 80']
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Action Recording
|
|
95
|
+
|
|
96
|
+
Create, update, and query action records. Every agent action gets a full audit trail.
|
|
97
|
+
|
|
98
|
+
### claw.createAction(action)
|
|
99
|
+
Create a new action record. The agent's agentId, agentName, and swarmId are automatically attached.
|
|
100
|
+
|
|
101
|
+
**Parameters:**
|
|
102
|
+
| Parameter | Type | Required | Description |
|
|
103
|
+
|-----------|------|----------|-------------|
|
|
104
|
+
| action_type | string | Yes | One of: build, deploy, post, apply, security, message, api, calendar, research, review, fix, refactor, test, config, monitor, alert, cleanup, sync, migrate, other |
|
|
105
|
+
| declared_goal | string | Yes | What this action aims to accomplish |
|
|
106
|
+
| action_id | string | No | Custom action ID (auto-generated act_ UUID if omitted) |
|
|
107
|
+
| reasoning | string | No | Why the agent decided to take this action |
|
|
108
|
+
| authorization_scope | string | No | What permissions were granted |
|
|
109
|
+
| trigger | string | No | What triggered this action |
|
|
110
|
+
| systems_touched | string[] | No | Systems this action interacts with |
|
|
111
|
+
| input_summary | string | No | Summary of input data |
|
|
112
|
+
| parent_action_id | string | No | Parent action if this is a sub-action |
|
|
113
|
+
| reversible | boolean | No | Whether this action can be undone (default: true) |
|
|
114
|
+
| risk_score | number | No | Risk score 0-100 (default: 0) |
|
|
115
|
+
| confidence | number | No | Confidence level 0-100 (default: 50) |
|
|
116
|
+
|
|
117
|
+
**Returns:** `Promise<{ action: Object, action_id: string }>`
|
|
118
|
+
|
|
119
|
+
**Example:**
|
|
120
|
+
```javascript
|
|
121
|
+
const { action_id } = await claw.createAction({
|
|
122
|
+
action_type: 'deploy',
|
|
123
|
+
declared_goal: 'Deploy auth service to production',
|
|
124
|
+
risk_score: 70,
|
|
125
|
+
systems_touched: ['kubernetes', 'auth-service'],
|
|
126
|
+
reasoning: 'Scheduled release after QA approval',
|
|
189
127
|
});
|
|
190
128
|
```
|
|
191
129
|
|
|
192
|
-
|
|
130
|
+
### claw.updateOutcome(actionId, outcome)
|
|
131
|
+
Update the outcome of an existing action. Automatically sets timestamp_end if not provided.
|
|
132
|
+
|
|
133
|
+
**Parameters:**
|
|
134
|
+
| Parameter | Type | Required | Description |
|
|
135
|
+
|-----------|------|----------|-------------|
|
|
136
|
+
| actionId | string | Yes | The action_id to update |
|
|
137
|
+
| status | string | No | New status: completed, failed, cancelled |
|
|
138
|
+
| output_summary | string | No | What happened |
|
|
139
|
+
| side_effects | string[] | No | Unintended consequences |
|
|
140
|
+
| artifacts_created | string[] | No | Files, records, etc. created |
|
|
141
|
+
| error_message | string | No | Error details if failed |
|
|
142
|
+
| duration_ms | number | No | How long it took in milliseconds |
|
|
143
|
+
| cost_estimate | number | No | Estimated cost in USD |
|
|
144
|
+
|
|
145
|
+
**Returns:** `Promise<{ action: Object }>`
|
|
146
|
+
|
|
147
|
+
### claw.track(actionDef, fn)
|
|
148
|
+
Helper that creates an action, runs your async function, and auto-updates the outcome. If fn throws, the action is marked as failed with the error message.
|
|
149
|
+
|
|
150
|
+
**Parameters:**
|
|
151
|
+
| Parameter | Type | Required | Description |
|
|
152
|
+
|-----------|------|----------|-------------|
|
|
153
|
+
| actionDef | Object | Yes | Action definition (same params as createAction) |
|
|
154
|
+
| fn | Function | Yes | Async function to execute. Receives { action_id } as argument. |
|
|
155
|
+
|
|
156
|
+
**Returns:** `Promise<*> (the return value of fn)`
|
|
157
|
+
|
|
158
|
+
### claw.getActions(filters?)
|
|
159
|
+
Get a list of actions with optional filters. Returns paginated results with stats.
|
|
160
|
+
|
|
161
|
+
**Parameters:**
|
|
162
|
+
| Parameter | Type | Required | Description |
|
|
163
|
+
|-----------|------|----------|-------------|
|
|
164
|
+
| agent_id | string | No | Filter by agent |
|
|
165
|
+
| swarm_id | string | No | Filter by swarm |
|
|
166
|
+
| status | string | No | Filter by status (running, completed, failed, cancelled) |
|
|
167
|
+
| action_type | string | No | Filter by type |
|
|
168
|
+
| risk_min | number | No | Minimum risk score |
|
|
169
|
+
| limit | number | No | Max results (default: 50) |
|
|
170
|
+
| offset | number | No | Pagination offset (default: 0) |
|
|
171
|
+
|
|
172
|
+
**Returns:** `Promise<{ actions: Object[], total: number, stats: Object }>`
|
|
173
|
+
|
|
174
|
+
### claw.getAction(actionId)
|
|
175
|
+
Get a single action with its associated open loops and assumptions.
|
|
176
|
+
|
|
177
|
+
**Parameters:**
|
|
178
|
+
| Parameter | Type | Required | Description |
|
|
179
|
+
|-----------|------|----------|-------------|
|
|
180
|
+
| actionId | string | Yes | The action_id to retrieve |
|
|
181
|
+
|
|
182
|
+
**Returns:** `Promise<{ action: Object, open_loops: Object[], assumptions: Object[] }>`
|
|
183
|
+
|
|
184
|
+
### claw.getActionTrace(actionId)
|
|
185
|
+
Get root-cause trace for an action, including its assumptions, open loops, parent chain, and related actions.
|
|
186
|
+
|
|
187
|
+
**Parameters:**
|
|
188
|
+
| Parameter | Type | Required | Description |
|
|
189
|
+
|-----------|------|----------|-------------|
|
|
190
|
+
| actionId | string | Yes | The action_id to trace |
|
|
191
|
+
|
|
192
|
+
**Returns:** `Promise<{ action: Object, trace: Object }>`
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Real-Time Flight Recorder
|
|
197
|
+
|
|
198
|
+
Stream actions live to the dashboard as they happen.
|
|
199
|
+
|
|
200
|
+
### claw.track(actionDef, fn)
|
|
201
|
+
(Already documented above) - Use `track()` to automatically emit `running` events at start and `completed`/`failed` events at finish. These show up instantly on the "Flight Recorder" dashboard.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Token & Cost Analytics
|
|
206
|
+
|
|
207
|
+
Track token usage and estimated costs for every action. DashClaw automatically aggregates these into "Cost per Goal" metrics.
|
|
208
|
+
|
|
209
|
+
**Usage:**
|
|
210
|
+
Pass `tokens_in`, `tokens_out`, and `model` when creating or updating actions.
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
await claw.createAction({
|
|
214
|
+
action_type: 'generation',
|
|
215
|
+
declared_goal: 'Generate blog post',
|
|
216
|
+
model: 'gpt-4o',
|
|
217
|
+
tokens_in: 1500,
|
|
218
|
+
tokens_out: 400,
|
|
219
|
+
// cost_estimate is auto-calculated on the server if model is known
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Supported Models for Auto-Pricing:**
|
|
224
|
+
- GPT-4o, GPT-4-Turbo
|
|
225
|
+
- Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku
|
|
226
|
+
- Llama 3 (70b, 8b)
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Loops & Assumptions
|
|
231
|
+
|
|
232
|
+
Track unresolved dependencies and log what your agents assume. Catch drift before it causes failures.
|
|
233
|
+
|
|
234
|
+
### claw.registerOpenLoop(loop)
|
|
235
|
+
Register an open loop (unresolved dependency, pending approval, etc.) for an action.
|
|
236
|
+
|
|
237
|
+
**Parameters:**
|
|
238
|
+
| Parameter | Type | Required | Description |
|
|
239
|
+
|-----------|------|----------|-------------|
|
|
240
|
+
| action_id | string | Yes | Parent action ID |
|
|
241
|
+
| loop_type | string | Yes | One of: followup, question, dependency, approval, review, handoff, other |
|
|
242
|
+
| description | string | Yes | What needs to be resolved |
|
|
243
|
+
| priority | string | No | One of: low, medium, high, critical (default: medium) |
|
|
244
|
+
| owner | string | No | Who is responsible for resolving this |
|
|
245
|
+
|
|
246
|
+
**Returns:** `Promise<{ loop: Object, loop_id: string }>`
|
|
247
|
+
|
|
248
|
+
### claw.resolveOpenLoop(loopId, status, resolution?)
|
|
249
|
+
Resolve or cancel an open loop.
|
|
250
|
+
|
|
251
|
+
**Parameters:**
|
|
252
|
+
| Parameter | Type | Required | Description |
|
|
253
|
+
|-----------|------|----------|-------------|
|
|
254
|
+
| loopId | string | Yes | The loop_id to resolve |
|
|
255
|
+
| status | string | Yes | "resolved" or "cancelled" |
|
|
256
|
+
| resolution | string | No | Resolution description (required when resolving) |
|
|
257
|
+
|
|
258
|
+
**Returns:** `Promise<{ loop: Object }>`
|
|
259
|
+
|
|
260
|
+
### claw.registerAssumption(assumption)
|
|
261
|
+
Register an assumption made during an action. Track what your agent assumes so you can validate or invalidate later.
|
|
262
|
+
|
|
263
|
+
**Parameters:**
|
|
264
|
+
| Parameter | Type | Required | Description |
|
|
265
|
+
|-----------|------|----------|-------------|
|
|
266
|
+
| action_id | string | Yes | Parent action ID |
|
|
267
|
+
| assumption | string | Yes | The assumption being made |
|
|
268
|
+
| basis | string | No | Evidence or reasoning for the assumption |
|
|
269
|
+
| validated | boolean | No | Whether this has been validated (default: false) |
|
|
270
|
+
|
|
271
|
+
**Returns:** `Promise<{ assumption: Object, assumption_id: string }>`
|
|
272
|
+
|
|
273
|
+
### claw.getAssumption(assumptionId)
|
|
274
|
+
Get a single assumption by ID.
|
|
275
|
+
|
|
276
|
+
**Parameters:**
|
|
277
|
+
| Parameter | Type | Required | Description |
|
|
278
|
+
|-----------|------|----------|-------------|
|
|
279
|
+
| assumptionId | string | Yes | The assumption_id to retrieve |
|
|
280
|
+
|
|
281
|
+
**Returns:** `Promise<{ assumption: Object }>`
|
|
282
|
+
|
|
283
|
+
### claw.validateAssumption(assumptionId, validated, invalidated_reason?)
|
|
284
|
+
Validate or invalidate an assumption. When invalidating, a reason is required.
|
|
285
|
+
|
|
286
|
+
**Parameters:**
|
|
287
|
+
| Parameter | Type | Required | Description |
|
|
288
|
+
|-----------|------|----------|-------------|
|
|
289
|
+
| assumptionId | string | Yes | The assumption_id to update |
|
|
290
|
+
| validated | boolean | Yes | true to validate, false to invalidate |
|
|
291
|
+
| invalidated_reason | string | No | Required when invalidating (validated = false) |
|
|
292
|
+
|
|
293
|
+
**Returns:** `Promise<{ assumption: Object }>`
|
|
294
|
+
|
|
295
|
+
### claw.getOpenLoops(filters?)
|
|
296
|
+
Get open loops with optional filters. Returns paginated results with stats.
|
|
193
297
|
|
|
194
|
-
|
|
298
|
+
**Parameters:**
|
|
299
|
+
| Parameter | Type | Required | Description |
|
|
300
|
+
|-----------|------|----------|-------------|
|
|
301
|
+
| status | string | No | Filter by status: open, resolved, cancelled |
|
|
302
|
+
| loop_type | string | No | Filter by loop type |
|
|
303
|
+
| priority | string | No | Filter by priority |
|
|
304
|
+
| limit | number | No | Max results (default: 50) |
|
|
305
|
+
|
|
306
|
+
**Returns:** `Promise<{ loops: Object[], total: number, stats: Object }>`
|
|
307
|
+
|
|
308
|
+
### claw.getDriftReport(filters?)
|
|
309
|
+
Get drift report for assumptions with risk scoring. Shows which assumptions are stale, unvalidated, or contradicted by outcomes.
|
|
310
|
+
|
|
311
|
+
**Parameters:**
|
|
312
|
+
| Parameter | Type | Required | Description |
|
|
313
|
+
|-----------|------|----------|-------------|
|
|
314
|
+
| action_id | string | No | Filter by action |
|
|
315
|
+
| limit | number | No | Max results (default: 50) |
|
|
316
|
+
|
|
317
|
+
**Returns:** `Promise<{ assumptions: Object[], drift_summary: Object }>`
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Signals
|
|
322
|
+
|
|
323
|
+
Automatic detection of problematic agent behavior. Seven signal types fire based on action patterns — no configuration required.
|
|
324
|
+
|
|
325
|
+
### claw.getSignals()
|
|
326
|
+
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.
|
|
327
|
+
|
|
328
|
+
**Returns:** `Promise<{ signals: Object[], counts: { red: number, amber: number, total: number } }>`
|
|
329
|
+
|
|
330
|
+
### Signal Types
|
|
331
|
+
- **autonomy_spike**: Agent taking too many actions without human checkpoints
|
|
332
|
+
- **high_impact_low_oversight**: Critical actions without sufficient review
|
|
333
|
+
- **repeated_failures**: Same action type failing multiple times
|
|
334
|
+
- **stale_loop**: Open loops unresolved past their expected timeline
|
|
335
|
+
- **assumption_drift**: Assumptions becoming stale or contradicted by outcomes
|
|
336
|
+
- **stale_assumption**: Assumptions not validated within expected timeframe
|
|
337
|
+
- **stale_running_action**: Actions stuck in running state for over 4 hours
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Behavior Guard
|
|
342
|
+
|
|
343
|
+
Check org-level policies before executing risky actions. Returns allow, warn, block, or require_approval based on configured guard policies.
|
|
344
|
+
|
|
345
|
+
### claw.guard(context, options?)
|
|
346
|
+
Evaluate guard policies for a proposed action. Call this before risky operations to get a go/no-go decision. The agent_id is auto-attached from the SDK constructor.
|
|
347
|
+
|
|
348
|
+
**Parameters:**
|
|
349
|
+
| Parameter | Type | Required | Description |
|
|
350
|
+
|-----------|------|----------|-------------|
|
|
351
|
+
| context.action_type | string | Yes | The type of action being proposed |
|
|
352
|
+
| context.risk_score | number | No | Risk score 0-100 |
|
|
353
|
+
| context.systems_touched | string[] | No | Systems this action will affect |
|
|
354
|
+
| context.reversible | boolean | No | Whether the action can be undone |
|
|
355
|
+
| context.declared_goal | string | No | What the action accomplishes |
|
|
356
|
+
| options.includeSignals | boolean | No | Also check live risk signals (adds latency) |
|
|
357
|
+
|
|
358
|
+
**Returns:** `Promise<{ decision: string, reasons: string[], warnings: string[], matched_policies: string[], evaluated_at: string }>`
|
|
359
|
+
|
|
360
|
+
### claw.getGuardDecisions(filters?)
|
|
361
|
+
Retrieve recent guard evaluation decisions for audit and review.
|
|
362
|
+
|
|
363
|
+
**Parameters:**
|
|
364
|
+
| Parameter | Type | Required | Description |
|
|
365
|
+
|-----------|------|----------|-------------|
|
|
366
|
+
| filters.decision | string | No | Filter by decision: allow, warn, block, require_approval |
|
|
367
|
+
| filters.limit | number | No | Max results (default 20, max 100) |
|
|
368
|
+
| filters.offset | number | No | Pagination offset |
|
|
369
|
+
|
|
370
|
+
**Returns:** `Promise<{ decisions: Object[], total: number, stats: Object }>`
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Dashboard Data
|
|
375
|
+
|
|
376
|
+
Push data from your agent directly to the DashClaw dashboard. All methods auto-attach the agent's agentId.
|
|
377
|
+
|
|
378
|
+
### claw.recordDecision(entry)
|
|
379
|
+
Record a decision for the learning database. Track what your agent decides and why.
|
|
380
|
+
|
|
381
|
+
**Parameters:**
|
|
382
|
+
| Parameter | Type | Required | Description |
|
|
383
|
+
|-----------|------|----------|-------------|
|
|
384
|
+
| decision | string | Yes | What was decided |
|
|
385
|
+
| context | string | No | Context around the decision |
|
|
386
|
+
| reasoning | string | No | Why this decision was made |
|
|
387
|
+
| outcome | string | No | "success", "failure", or "pending" |
|
|
388
|
+
| confidence | number | No | Confidence level 0-100 |
|
|
389
|
+
|
|
390
|
+
**Returns:** `Promise<{ decision: Object }>`
|
|
391
|
+
|
|
392
|
+
### claw.createGoal(goal)
|
|
393
|
+
Create a goal in the goals tracker.
|
|
394
|
+
|
|
395
|
+
**Parameters:**
|
|
396
|
+
| Parameter | Type | Required | Description |
|
|
397
|
+
|-----------|------|----------|-------------|
|
|
398
|
+
| title | string | Yes | Goal title |
|
|
399
|
+
| category | string | No | Goal category |
|
|
400
|
+
| description | string | No | Detailed description |
|
|
401
|
+
| target_date | string | No | Target completion date (ISO string) |
|
|
402
|
+
| progress | number | No | Progress 0-100 |
|
|
403
|
+
| status | string | No | "active", "completed", or "paused" |
|
|
404
|
+
|
|
405
|
+
**Returns:** `Promise<{ goal: Object }>`
|
|
406
|
+
|
|
407
|
+
### claw.recordContent(content)
|
|
408
|
+
Record content creation (articles, posts, documents).
|
|
409
|
+
|
|
410
|
+
**Parameters:**
|
|
411
|
+
| Parameter | Type | Required | Description |
|
|
412
|
+
|-----------|------|----------|-------------|
|
|
413
|
+
| title | string | Yes | Content title |
|
|
414
|
+
| platform | string | No | Platform (e.g., "linkedin", "twitter") |
|
|
415
|
+
| status | string | No | "draft" or "published" |
|
|
416
|
+
| url | string | No | Published URL |
|
|
417
|
+
|
|
418
|
+
**Returns:** `Promise<{ content: Object }>`
|
|
419
|
+
|
|
420
|
+
### claw.recordInteraction(interaction)
|
|
421
|
+
Record a relationship interaction (message, meeting, email).
|
|
422
|
+
|
|
423
|
+
**Parameters:**
|
|
424
|
+
| Parameter | Type | Required | Description |
|
|
425
|
+
|-----------|------|----------|-------------|
|
|
426
|
+
| summary | string | Yes | What happened |
|
|
427
|
+
| contact_name | string | No | Contact name (auto-resolves to contact_id) |
|
|
428
|
+
| contact_id | string | No | Direct contact ID |
|
|
429
|
+
| direction | string | No | "inbound" or "outbound" |
|
|
430
|
+
| type | string | No | Interaction type (e.g., "message", "meeting", "email") |
|
|
431
|
+
| platform | string | No | Platform used |
|
|
432
|
+
|
|
433
|
+
**Returns:** `Promise<{ interaction: Object }>`
|
|
434
|
+
|
|
435
|
+
### claw.reportConnections(connections)
|
|
436
|
+
Report active connections/integrations for this agent.
|
|
437
|
+
|
|
438
|
+
**Parameters:**
|
|
439
|
+
| Parameter | Type | Required | Description |
|
|
440
|
+
|-----------|------|----------|-------------|
|
|
441
|
+
| connections | Object[] | Yes | Array of connection objects |
|
|
442
|
+
| connections[].provider | string | Yes | Service name (e.g., "anthropic", "github") |
|
|
443
|
+
| connections[].authType | string | No | Auth method |
|
|
444
|
+
| connections[].planName | string | No | Plan name |
|
|
445
|
+
| connections[].status | string | No | Connection status |
|
|
446
|
+
| connections[].metadata | Object|string | No | Optional metadata |
|
|
447
|
+
|
|
448
|
+
**Returns:** `Promise<{ connections: Object[], created: number }>`
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## Session Handoffs
|
|
453
|
+
|
|
454
|
+
### claw.createHandoff(handoff)
|
|
455
|
+
Create a session handoff document summarizing work done, decisions made, and next priorities.
|
|
456
|
+
|
|
457
|
+
**Parameters:**
|
|
458
|
+
| Parameter | Type | Required | Description |
|
|
459
|
+
|-----------|------|----------|-------------|
|
|
460
|
+
| summary | string | Yes | Session summary |
|
|
461
|
+
| session_date | string | No | Date string (defaults to today) |
|
|
462
|
+
| key_decisions | string[] | No | Key decisions made this session |
|
|
463
|
+
| open_tasks | string[] | No | Tasks still open |
|
|
464
|
+
| mood_notes | string | No | User mood/energy observations |
|
|
465
|
+
| next_priorities | string[] | No | What to focus on next |
|
|
466
|
+
|
|
467
|
+
**Returns:** `Promise<{handoff: Object, handoff_id: string}>`
|
|
468
|
+
|
|
469
|
+
### claw.getHandoffs(filters?)
|
|
470
|
+
Get handoffs for this agent with optional date and limit filters.
|
|
471
|
+
|
|
472
|
+
**Parameters:**
|
|
473
|
+
| Parameter | Type | Required | Description |
|
|
474
|
+
|-----------|------|----------|-------------|
|
|
475
|
+
| date | string | No | Filter by session_date |
|
|
476
|
+
| limit | number | No | Max results |
|
|
477
|
+
|
|
478
|
+
**Returns:** `Promise<{handoffs: Object[], total: number}>`
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Context Manager
|
|
483
|
+
|
|
484
|
+
Capture key points and organize context into threads for long-running topics.
|
|
485
|
+
|
|
486
|
+
### claw.captureKeyPoint(point)
|
|
487
|
+
Capture a key point from the current session for later recall.
|
|
488
|
+
|
|
489
|
+
**Parameters:**
|
|
490
|
+
| Parameter | Type | Required | Description |
|
|
491
|
+
|-----------|------|----------|-------------|
|
|
492
|
+
| content | string | Yes | The key point content |
|
|
493
|
+
| category | string | No | decision, task, insight, question, general |
|
|
494
|
+
| importance | number | No | Importance 1-10 (default 5) |
|
|
495
|
+
| session_date | string | No | Date string (defaults to today) |
|
|
496
|
+
|
|
497
|
+
**Returns:** `Promise<{point: Object, point_id: string}>`
|
|
498
|
+
|
|
499
|
+
### claw.createThread(thread)
|
|
500
|
+
Create a context thread for tracking a topic across multiple entries.
|
|
501
|
+
|
|
502
|
+
**Parameters:**
|
|
503
|
+
| Parameter | Type | Required | Description |
|
|
504
|
+
|-----------|------|----------|-------------|
|
|
505
|
+
| name | string | Yes | Thread name (unique per agent per org) |
|
|
506
|
+
| summary | string | No | Initial summary |
|
|
507
|
+
|
|
508
|
+
**Returns:** `Promise<{thread: Object, thread_id: string}>`
|
|
509
|
+
|
|
510
|
+
### claw.addThreadEntry(threadId, content, entryType?)
|
|
511
|
+
Add an entry to an existing thread.
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## Agent Messaging
|
|
516
|
+
|
|
517
|
+
### claw.sendMessage(params)
|
|
518
|
+
Send a message to another agent or broadcast.
|
|
519
|
+
|
|
520
|
+
**Parameters:**
|
|
521
|
+
| Parameter | Type | Required | Description |
|
|
522
|
+
|-----------|------|----------|-------------|
|
|
523
|
+
| to | string | No | Target agent ID (null = broadcast) |
|
|
524
|
+
| type | string | No | info, action, lesson, question, status |
|
|
525
|
+
| subject | string | No | Subject line (max 200 chars) |
|
|
526
|
+
| body | string | Yes | Message body (max 2000 chars) |
|
|
527
|
+
| threadId | string | No | Thread ID to attach to |
|
|
528
|
+
| urgent | boolean | No | Mark as urgent |
|
|
529
|
+
| docRef | string | No | Reference to a shared doc ID |
|
|
530
|
+
|
|
531
|
+
**Returns:** `Promise<{message: Object, message_id: string}>`
|
|
532
|
+
|
|
533
|
+
### claw.saveSharedDoc(params)
|
|
534
|
+
Create or update a shared workspace document. Upserts by name.
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## Bulk Sync
|
|
539
|
+
|
|
540
|
+
### claw.syncState(state)
|
|
541
|
+
Push multiple data categories in a single request. Accepts connections, memory, goals, learning, content, inspiration, context_points, context_threads, handoffs, preferences, and snippets.
|
|
542
|
+
|
|
543
|
+
**Returns:** `Promise<{results: Object, total_synced: number, total_errors: number, duration_ms: number}>`
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
## Error Handling
|
|
548
|
+
|
|
549
|
+
All SDK methods throw on non-2xx responses. Errors include `status` (HTTP code) and `details` (when available).
|
|
550
|
+
|
|
551
|
+
```javascript
|
|
552
|
+
try {
|
|
553
|
+
await claw.createAction({ ... });
|
|
554
|
+
} catch (err) {
|
|
555
|
+
if (err.status === 401) {
|
|
556
|
+
console.error('Invalid API key');
|
|
557
|
+
} else {
|
|
558
|
+
console.error(`Action failed: \${err.message}`);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
```
|
package/dashclaw.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dashclaw",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Full-featured agent toolkit for the DashClaw platform. 58 methods for action recording, context management, session handoffs, security scanning, behavior guard, bulk sync, and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"ai-agent",
|
|
25
25
|
"observability",
|
|
26
26
|
"agent-toolkit",
|
|
27
|
-
"
|
|
27
|
+
"dashclaw",
|
|
28
28
|
"dashclaw",
|
|
29
29
|
"action-recording",
|
|
30
30
|
"context-management",
|