HomeSDK Documentation

SDK Documentation

Canonical reference for the DashClaw SDK (v2.5.0). 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: process.env.DASHCLAW_BASE_URL,
  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. The guard response includes a `learning` field with historical performance context when available (recent scores, drift status, learned patterns, feedback summary).

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();

Agent Lifecycle

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

Report agent presence and health to the control plane. Call periodically to indicate the agent is alive.

ParameterTypeRequiredDescription
statusstringNoAgent status — 'online', 'busy', 'idle'. Defaults to 'online'
metadataobjectNoArbitrary metadata to include with the heartbeat
await claw.heartbeat('online', { cycle: 42, uptime_ms: 360000 });

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

Report active provider connections and their status. Appears in the agent's Fleet profile.

ParameterTypeRequiredDescription
connectionsArray<Object>YesList of { name, type, status } connection objects
await claw.reportConnections([
  { name: 'OpenAI', type: 'llm', status: 'connected' },
  { name: 'Postgres', type: 'database', status: 'connected' },
]);

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();

claw.getLessons({ actionType, limit }) / claw.get_lessons(action_type=..., limit=...)

Fetch consolidated lessons from scored outcomes — what DashClaw has learned about this agent's performance patterns.

ParameterTypeRequiredDescription
actionTypestringNoFilter by action type
limitnumberNoMax lessons to return (default 10)

Returns: Promise<{ lessons: Object[], drift_warnings: Object[], agent_id: string }>

const { lessons, drift_warnings } = await claw.getLessons({ actionType: 'deploy' });
lessons.forEach(l => console.log(l.guidance));

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 }] 
});

Agent Messaging

claw.sendMessage(params) / claw.send_message(**kwargs)

Send a point-to-point message or broadcast to all agents in the organization.

ParameterTypeRequiredDescription
tostringNoTarget agent ID (omit for broadcast)
bodystringYesMessage content
typestringNoaction|info|lesson|question
urgentbooleanNoMark as high priority
await claw.sendMessage({
  to: 'scout-agent-01',
  body: 'I have finished indexing the repository. You can start the analysis.',
  type: 'status'
});

claw.getInbox(options?) / claw.get_inbox(**kwargs)

Retrieve messages from the agent inbox with optional filtering.

ParameterTypeRequiredDescription
typestringNoFilter by message type
unreadbooleanNoOnly return unread messages
limitnumberNoMax messages to return

Returns: Promise<{ messages, total, unread_count }>

const { messages } = await claw.getInbox({ unread: true, limit: 10 });

Session Handoffs

claw.createHandoff(handoff) / claw.create_handoff(**kwargs)

Create a session handoff document to persist state between agent sessions or transfer context to another agent.

await claw.createHandoff({
  summary: 'Completed initial data collection from Jira.',
  key_decisions: ['Prioritize high-severity bugs', 'Ignore closed tickets'],
  open_tasks: ['Run security scan on src/', 'Draft fix for #123'],
  next_priorities: ['Security audit']
});

claw.getLatestHandoff() / claw.get_latest_handoff()

Retrieve the most recent handoff for the current agent.

Returns: Promise<Object|null>

const handoff = await claw.getLatestHandoff();

Security Scanning

claw.scanPromptInjection(text) / claw.scan_prompt_injection(text)

Scan untrusted input for potential prompt injection or jailbreak attempts.

ParameterTypeRequiredDescription
textstringYesUntrusted input to scan

Returns: Promise<{ clean: boolean, risk_level: string, recommendation: string }>

const result = await claw.scanPromptInjection(userInput);
if (!result.clean) {
  console.warn('Injection risk:', result.risk_level);
}

User Feedback

claw.submitFeedback(params) / claw.submit_feedback(**kwargs)

Submit feedback for a specific agent action. Used for human evaluation of agent performance.

ParameterTypeRequiredDescription
action_idstringYesTarget action ID
ratingnumberYes1-5 star rating
commentstringNoTextual feedback
categorystringNoGrouping tag
await claw.submitFeedback({
  action_id: 'act_4b2s8...',
  rating: 4,
  comment: 'Action was safe and effective but took longer than expected.',
  category: 'performance_review'
});

Context Threads

claw.createThread(options) / claw.create_thread(**kwargs)

Create a new context thread to track a multi-step reasoning chain or investigation.

ParameterTypeRequiredDescription
namestringYesThread name
summarystringNoInitial thread summary

Returns: Promise<{ thread, thread_id }>

const { thread } = await claw.createThread({ name: 'Deploy analysis', summary: 'Evaluating safety' });

claw.addThreadEntry(threadId, content, entryType) / claw.add_thread_entry(...)

Append an observation, conclusion, or decision to an existing context thread.

ParameterTypeRequiredDescription
threadIdstringYesThread ID to append to
contentstringYesEntry content
entryTypestringYes'observation' | 'conclusion' | 'decision'
await claw.addThreadEntry('ct_abc123', 'Staging checks passed', 'observation');

claw.closeThread(threadId, summary?) / claw.close_thread(thread_id, summary=None)

Close a context thread, optionally providing a final summary.

ParameterTypeRequiredDescription
threadIdstringYesThread ID to close
summarystringNoFinal summary of the thread
await claw.closeThread('ct_abc123', 'Deploy approved after staging check');

Bulk Sync

claw.syncState(state) / claw.sync_state(**kwargs)

Bulk-sync agent state including decisions, lessons, goals, context, relationships, memory, and preferences in a single call.

ParameterTypeRequiredDescription
stateobjectYesState object with keys: decisions, lessons, goals, context, relationships, memory, preferences
await claw.syncState({ decisions: [...], lessons: [...], goals: [...] });

Error Handling

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