Dobby
Collector SDK · Node.js / TypeScript

@dobbyai/collector

Capture telemetry from any Node.js / TypeScript AI agent and stream it to Dobby for governance, compliance, and observability.

View on npm v0.1.0 LIVE · MIT · 0 deps · Node 18+

What this gives you

Every agent run captured

Run lifecycle, LLM calls, tool invocations, agent steps — all stream to Dobby in 10-second batches. Visible in /dashboard/workloads/runs within ~5s of completion.

Policy Scanner auto-fires

Each captured run triggers a compliance scan against your org's Policy Templates (SOC 2 / GDPR / HIPAA / EU AI Act / ISO 42001). Verdicts surface in /dashboard/compliance.

tracing_enabled flips to configured

SDK auto-emits W3C traceparent per batch. The Surrounding-mode governance control "tracing_enabled" automatically marks your org as configured after the first run.

Zero runtime dependencies

Base @dobbyai/collector pulls no production deps — uses Node 18+ built-ins (fetch + crypto.randomUUID + node:async_hooks). Framework peer deps are optional, install only what you use.

Install

npm install @dobbyai/collector

Manual API (any framework, recommended starting point)

Works with any agent code — no framework dependency. Verified end-to-end on prod 2026-05-17 with 6/6 telemetry fields green.

import { init, startRun, endRun, span, shutdown } from '@dobbyai/collector';

init({
  apiKey: process.env.DOBBY_API_KEY!,        // dsdk_* token from the wizard
  connectorId: process.env.DOBBY_CONNECTOR_ID!, // wc_* connector id
});

const run = startRun({
  name: 'weekly_report',
  inputs: { week: '2026-W19' },
});

const docs = await span('retrieval', { kind: 'tool', inputs: { q: 'sales' } }, async () => {
  return await retriever.invoke('sales');
});

const summary = await span('summarize', { kind: 'llm' }, async () => {
  return await llm.invoke(docs);
});

endRun(run, { outputs: { summary }, status: 'success' });
await shutdown(); // forces final flush

Framework auto-instrumentation

Each handler is a subpath export — install only the peer dep for the framework you use. Base @dobbyai/collector pulls NO framework deps.

LangChain.js

Pass DobbyLangChainCallbackHandler to your AgentExecutor.invoke() — every chain.start/end, llm.start/end, tool.start/end, agent.step automatically emits a Dobby event. One workload_run per .invoke() call.

npm install @langchain/core
import { init } from '@dobbyai/collector';
import { DobbyLangChainCallbackHandler } from '@dobbyai/collector/langchain';

init({ framework: 'langchain' });
const handler = new DobbyLangChainCallbackHandler();

// Pass to .invoke() / .stream() — every LangChain callback emits a Dobby event
const result = await agent.invoke(
  { input: 'What is the population of Reykjavik?' },
  { callbacks: [handler] },
);

Mastra

wrapMastraAgent returns a Proxy that intercepts .generate() and .stream() calls. Same shape as the original Agent — no other code changes. Tool calls land as nested spans.

npm install @mastra/core
import { init } from '@dobbyai/collector';
import { wrapMastraAgent } from '@dobbyai/collector/mastra';
import { Agent } from '@mastra/core';

init({ framework: 'mastra' });

const agent = wrapMastraAgent(
  new Agent({ /* ... */ }),
  { agentName: 'research-bot' },
);

// Same shape as the original Agent — Proxy intercepts .generate() / .stream()
const result = await agent.generate('What is the weather?');

Vercel AI SDK

trackVercelAiCall wraps generateText / generateObject Promises. vercelAiCallbacks returns { onStepFinish, onFinish } to spread into streamText. Tool calls + step events captured per call.

npm install ai @ai-sdk/openai
import { trackVercelAiCall, vercelAiCallbacks } from '@dobbyai/collector/vercel-ai';
import { generateText, streamText } from 'ai';
import { openai } from '@ai-sdk/openai';

init({ framework: 'vercel-ai' });

// Non-streaming
const result = await trackVercelAiCall(
  'weekly_summary',
  { inputs: { topic: 'AI safety' } },
  () => generateText({ model: openai('gpt-4o-mini'), prompt: '...', tools: {/*...*/} }),
);

// Streaming
const cbs = vercelAiCallbacks({ agentName: 'live_chat' });
const stream = streamText({
  model: openai('gpt-4o-mini'),
  prompt: '...',
  ...cbs,
});

Ready to onboard a customer?

Use the step-by-step walkthrough — covers credential generation, framework-specific snippets, troubleshooting, and known gotchas. ~10–15 minutes end-to-end.

Walkthrough doc

Related

Dobby AI Platform - AI Agents That Execute Real Work With Full Control