HomeSDK Documentation

SDK Documentation

Canonical reference for the DashClaw SDK (v2.1.5). Node.js and Python parity across all core governance features.

Quick Start

1

Install

npm install dashclaw
2

Initialize

import { DashClaw } from 'dashclaw';

const claw = new DashClaw({
  baseUrl: 'https://dashclaw.io',
  apiKey: process.env.DASHCLAW_API_KEY,
  agentId: 'my-agent'
});
3

Governance Loop

// 1. Ask permission
const result = await claw.guard({
  action_type: 'deploy',
  risk_score: 85,
  declared_goal: 'Update auth service to v2.1.1'
});

if (result.decision === 'block') {
  throw new Error(`Blocked: ${result.reasons.join(', ')}`);
}

// 2. Log intent
const { action_id } = await claw.createAction({
  action_type: 'deploy',
  declared_goal: 'Update auth service to v2.1.1'
});

try {
  // 3. Log evidence
  await claw.recordAssumption({
    action_id,
    assumption: 'Tests passed'
  });

  // ... deploy ...

  // 4. Record outcome
  await claw.updateOutcome(action_id, { status: 'completed' });
} catch (err) {
  await claw.updateOutcome(action_id, { status: 'failed', error_message: err.message });
}

Constructor

const claw = new DashClaw({ baseUrl, apiKey, agentId });
ParameterTypeRequiredDescription
baseUrl / base_urlstringYesDashboard URL
apiKey / api_keystringYesAPI Key
agentId / agent_idstringYesUnique Agent ID

Behavior Guard

claw.guard(context)

Evaluate guard policies for a proposed action. Call this before risky operations.

ParameterTypeRequiredDescription
action_typestringYesProposed action type
risk_scorenumberNo0-100

Returns: Promise<{ decision: string, reasons: string[], risk_score: number, agent_risk_score: number | null }>

const result = await claw.guard({ action_type: 'deploy', risk_score: 85 });

Action Recording

claw.createAction(action) / claw.create_action(**kwargs)

Create a new action record.

Returns: Promise<{ action_id: string }>

const { action_id } = await claw.createAction({ action_type: 'deploy' });

claw.waitForApproval(id) / claw.wait_for_approval(id)

Poll for human approval.

await claw.waitForApproval(action_id);

claw.updateOutcome(id, outcome) / claw.update_outcome(id, **kwargs)

Log final results.

await claw.updateOutcome(action_id, { status: 'completed' });

claw.recordAssumption(asm) / claw.record_assumption(asm)

Track agent beliefs.

await claw.recordAssumption({ action_id, assumption: '...' });

Signals

claw.getSignals() / claw.get_signals()

Get current risk signals across all agents.

Returns: Promise<{ signals: Object[] }>

const { signals } = await claw.getSignals();

Swarm Intelligence

Map your entire fleet as a neural web, highlighting high-risk nodes and message flows.

claw.heartbeat(status, metadata) / claw.heartbeat(status=...)

Report agent presence and health to the control plane.

ParameterTypeRequiredDescription
statusstringNoAgent status (online, busy, offline)
metadataobjectNoAdditional agent state
await claw.heartbeat('online', { task: 'monitoring' });

claw.reportConnections(connections) / claw.report_connections(connections)

Report active provider connections and their status.

ParameterTypeRequiredDescription
connectionsArray<Object>YesList of provider connection objects
await claw.reportConnections([
  { provider: 'openai', status: 'active', plan_name: 'enterprise' }
]);

Loops & Assumptions

claw.registerOpenLoop(actionId, type, desc) / claw.register_open_loop(...)

Register an unresolved dependency for a decision. Open loops track work that must be completed before the decision is fully resolved.

ParameterTypeRequiredDescription
action_idstringYesAssociated action
loop_typestringYesThe category of the loop
descriptionstringYesWhat needs to be resolved
await claw.registerOpenLoop(action_id, 'validation', 'Waiting for PR review');

claw.resolveOpenLoop(loopId, status, res) / claw.resolve_open_loop(...)

Resolve a pending loop.

await claw.resolveOpenLoop(loop_id, 'completed', 'Approved');

claw.recordAssumption(asm) / claw.record_assumption(asm)

Record what the agent believed to be true when making a decision.

await claw.recordAssumption({ action_id, assumption: 'User is authenticated' });

Learning Analytics

claw.getLearningVelocity() / claw.get_learning_velocity()

Compute learning velocity (rate of score improvement) for agents.

Returns: Promise<{ velocity: Array<Object> }>

const { velocity } = await claw.getLearningVelocity();

claw.getLearningCurves() / claw.get_learning_curves()

Compute learning curves per action type to measure efficiency gains.

const curves = await claw.getLearningCurves();

Prompt Management

claw.renderPrompt() / claw.render_prompt()

Fetch rendered prompt from DashClaw.

const { rendered } = await claw.renderPrompt({
  template_id: 'marketing',
  variables: { company: 'Apple' }
});

Evaluation Framework

claw.createScorer(name, type, config) / claw.create_scorer(...)

Create a reusable scorer definition for automated evaluation.

ParameterTypeRequiredDescription
namestringYesScorer name
scorer_typestringYesType (llm_judge, regex, range)
configobjectNoScorer configuration
await claw.createScorer('toxicity', 'regex', { pattern: 'bad-word' });

Scoring Profiles

claw.createScoringProfile(config) / claw.create_scoring_profile(...)

Define weighted quality scoring profiles across multiple scorers.

await claw.createScoringProfile({ 
  name: 'prod-quality', 
  dimensions: [{ scorer: 'toxicity', weight: 0.5 }] 
});

Compliance Engine

claw.mapCompliance(framework) / claw.map_compliance(framework)

Map active policies to a compliance framework's controls.

await claw.mapCompliance('SOC2');

claw.getProofReport(format) / claw.get_proof_report(format)

Generate a compliance proof report from active policies.

const report = await claw.getProofReport('json');

Activity Logs

claw.getActivityLogs(filters) / claw.get_activity_logs(**filters)

Query the immutable audit trail of all workspace changes and administrative events.

const logs = await claw.getActivityLogs({ limit: 10 });

Webhooks

claw.createWebhook(url, events) / claw.create_webhook(url, events)

Register an HMAC-signed webhook for real-time exfiltration of governance events.

await claw.createWebhook('https://api.myapp.com/hooks', ['action.blocked']);

Error Handling

Error shape
{ message: "Validation failed", status: 400 }