HomeSDK Documentation

SDK Documentation

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

Capability model

The SDK is one product surface inside the broader OSuite governance stack. Governance depth depends on runtime control points, while self-host and future SaaS are control-plane deployment models.

Self-host and future SaaS are deployment models for the OSuite control plane. They do not determine governance level by themselves.

Quick Start

Governance levels

Evidence Import

OSuite ingests evidence and supports replay, audit, and post-facto analysis.

Advisory Governance

OSuite evaluates policy before execution, but the external runtime may not enforce the stop.

Approval-Orchestrated Governance

OSuite can pause execution, wait for approval, and resume or deny deterministically.

Runtime-Enforced Governance

OSuite sits at the real execution boundary and can enforce before side effects happen.

Product surfaces

Embedded Runtime SDK / Package

Instrument customer-controlled runtimes, tools, and orchestrators from inside the code.

Runtime Boundary Adapter

Intercept real tool or action execution at the boundary where side effects occur.

Control Plane

Run policy, approvals, replay, and evidence management as the operator system of record.

Evidence Import Surface

Import actions, traces, and logs when the external runtime cannot be governed directly.

Deployment models

Self-Hosted Control Plane

Run the OSuite control plane in your own infrastructure and under your own operations model.

SaaS Control Plane

Use a OSuite-managed control plane once the hosted service is available.

1

Install

npm install osuite
2

Initialize

import { OSuite } from 'osuite';

const claw = new OSuite({
  baseUrl: process.env.OSUITE_BASE_URL,
  apiKey: process.env.OSUITE_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 OSuite({ 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 OSuite 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 OSuite.

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

Agent Identity

Enroll agents via public-key pairing and manage approved identities. Pairing requests are created by agents; approval is an admin action. Once approved, the agent's public key is registered as a trusted identity for signature verification.

POST /api/pairings

Create an agent pairing request. The agent submits its public key and waits for operator approval.

ParameterTypeRequiredDescription
public_keystringYesPEM-encoded RSA public key
algorithmstringNoKey algorithm. Default: RSASSA-PKCS1-v1_5
agent_namestringNoHuman-readable label for the agent

Returns: { pairing: { id, status, agent_name, created_at } }

Create pairing request
// Node SDK (v1 legacy)
import { OSuite } from 'osuite/legacy';
const claw = new OSuite({ baseUrl, apiKey, agentId });

const { pairing } = await claw.createPairing(publicKeyPem, 'RSASSA-PKCS1-v1_5', 'my-agent');
console.log(pairing.id); // pair_...

GET /api/pairings

List all pairing requests for the organization. Admin API key required.

Returns: { pairings: Array<{ id, status, agent_name, created_at, approved_at }> }

List pairings (admin)
const res = await fetch('/api/pairings', {
  headers: { 'x-api-key': adminApiKey }
});
const { pairings } = await res.json();

GET /api/pairings/:id

Get a specific pairing request by ID. Used by agents to poll for approval status.

Returns: { pairing: { id, status, agent_name, created_at, approved_at } }

Poll pairing status
// Node SDK (v1 legacy)
const status = await claw.getPairing(pairingId);
console.log(status.pairing.status); // pending | approved | expired

POST /api/pairings/:id/approve

Approve a pending pairing request. Admin API key required. On approval, the agent's public key is registered as a trusted identity.

Returns: { pairing: { id, status, approved_at } }

Approve pairing (admin)
const res = await fetch(`/api/pairings/${pairingId}/approve`, {
  method: 'POST',
  headers: { 'x-api-key': adminApiKey }
});

POST /api/identities

Directly register an agent's public key as a trusted identity. Admin API key required. Bypasses the pairing flow.

ParameterTypeRequiredDescription
agent_idstringYesUnique agent identifier
public_keystringYesPEM-encoded RSA public key
algorithmstringNoKey algorithm. Default: RSASSA-PKCS1-v1_5

Returns: { identity: { agent_id, algorithm, created_at } }

Register identity (admin)
// Node SDK (v1 legacy)
await claw.registerIdentity('agent-007', publicKeyPem, 'RSASSA-PKCS1-v1_5');

GET /api/identities

List all registered agent identities for the organization. Admin API key required.

Returns: { identities: Array<{ agent_id, algorithm, created_at }> }

List identities (admin)
// Node SDK (v1 legacy)
const { identities } = await claw.getIdentities();

DELETE /api/identities/:agentId

Revoke a registered agent identity. Admin API key required. The agent's public key is removed and signature verification will fail for future actions.

Returns: { success: true }

Revoke identity (admin)
const res = await fetch(`/api/identities/${agentId}`, {
  method: 'DELETE',
  headers: { 'x-api-key': adminApiKey }
});

Error Handling

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