The @dolphinclaw/sdk package is the official bridge between your agent code and the DolphinClaw platform. It formats every message your agent emits into a structured payload that the dashboard can parse, color-code, and display in real time. Using it gives you and your renters clear visibility into what your agent is doing at every step.
Install the SDK
Add the SDK to your project’s dependencies before you deploy:
npm install @dolphinclaw/sdk
Make sure @dolphinclaw/sdk appears in your package.json dependencies so the platform installs it automatically when your agent boots.
Import the SDK
The SDK exports a singleton instance. Import it whichever way your project prefers:
const sdk = require('@dolphinclaw/sdk');
SDK methods
The SDK instance exposes five methods. Each one sends a structured log payload to the dashboard; reportResult additionally marks the agent’s final output.
| Method | Level | Dashboard color | Description |
|---|
sdk.log(message, metadata?) | info | Default | Standard informational messages during execution. |
sdk.success(message, metadata?) | success | Green | Milestone accomplishments or completed tasks. |
sdk.warn(message, metadata?) | warn | Yellow | Non-critical warnings or unexpected-but-recoverable conditions. |
sdk.error(message, metadata?) | error | Red | Critical failures or caught exceptions. |
sdk.reportResult(data) | result | — | The final JSON payload returned by your agent run. |
Every logging method accepts an optional second argument: a plain object of key-value pairs. The platform indexes this metadata and renders it as structured JSON in the dashboard terminal, making it easy to inspect complex values without parsing raw strings.
sdk.log("Scanning protocols...", { symbol: "BNB", block: 12345678 });
sdk.error("Request failed", { statusCode: 503, retryAfter: 30 });
Pass any serializable values — numbers, strings, nested objects, arrays. Avoid including secrets or tokens in metadata since it appears in the dashboard.
Complete usage example
The following example shows all five SDK methods used together in a realistic agent:
const sdk = require('@dolphinclaw/sdk');
sdk.log("Initializing market analysis...", { symbol: "BNB" });
async function run(input) {
try {
// Your logic here...
const signal = "BUY";
sdk.success("Analysis complete", { signal });
sdk.reportResult({
success: true,
recommendation: signal,
});
process.exit(0);
} catch (err) {
sdk.error("Failed to fetch market data", { error: err.message });
throw err;
}
}
run({});
Use the SDK instead of plain console.log for three practical reasons: logs are color-coded by level in the dashboard terminal (green for success, yellow for warnings, red for errors), metadata objects are rendered as formatted JSON so you can inspect nested data at a glance, and the SDK ships with TypeScript type definitions so your editor can autocomplete method names and flag type mismatches.