Skip to main content
Last updated on

Mastra SDK (TypeScript)

The OpenBox Mastra SDK connects a Mastra runtime to OpenBox. It governs tools, workflow steps, workflows, and agent runs while attaching operational telemetry that operators can inspect in the dashboard.

Published package: @openbox-ai/openbox-mastra-sdk

Runnable reference application:

GuideDescription
Integration WalkthroughEnd-to-end guide for wiring withOpenBox(), manual wrappers, and telemetry into a Mastra service
ConfigurationEnvironment variables, runtime options, defaults, and production guidance
Error HandlingRuntime errors, approval outcomes, guardrail failures, and startup validation issues
Event ModelUnderstand workflows, activities, signals, and how Mastra runs appear in OpenBox
Approvals and GuardrailsHow verdicts are enforced and how to test live guardrails correctly
TelemetryHTTP, database, file, and traced-function capture behavior
TroubleshootingDiagnose startup, policy, approvals, telemetry, and UI interpretation issues
What the SDK Does

The SDK's job is to connect a Mastra runtime to OpenBox. Trust policy, approvals, guardrails, dashboards, and operator workflows live on the OpenBox platform, not inside the SDK.

Philosophy

The integration is intentionally minimal:

  • One standard bootstrap path with withOpenBox()
  • No rewrite of existing agent, tool, or workflow logic
  • Automatic governance at Mastra runtime boundaries
  • Automatic telemetry capture through OpenTelemetry

Recommended Entry Point

For most services, use withOpenBox():

import { withOpenBox } from "@openbox-ai/openbox-mastra-sdk";

await withOpenBox(mastra, {
apiKey: process.env.OPENBOX_API_KEY,
apiUrl: process.env.OPENBOX_URL
});

It validates configuration, creates the OpenBox runtime, installs telemetry, wraps existing registrations, and keeps future Mastra registrations governed.

Public API Summary

Most integrations only need these exports:

  • withOpenBox()
  • getOpenBoxRuntime()
  • wrapTool()
  • wrapWorkflow()
  • wrapAgent()
  • setupOpenBoxOpenTelemetry()
  • traced()

What The SDK Captures

OpenBox receives:

Workflow Boundaries

  • WorkflowStarted
  • WorkflowCompleted
  • WorkflowFailed

Activity Boundaries

  • ActivityStarted
  • ActivityCompleted

These apply to:

  • wrapped tools
  • wrapped non-tool workflow steps

Signals

  • SignalReceived(user_input)
  • SignalReceived(resume)
  • SignalReceived(agent_output)

Operational Telemetry

  • HTTP requests
  • supported database activity
  • file operations when enabled
  • custom traced functions

Supported Runtime Conditions

RequirementValue
Node.js>=24.10.0
Mastra@mastra/core ^1.8.0
Module formatESM
OpenBox Corereachable over HTTPS except localhost development

Next Steps

  1. Start with the Integration Walkthrough.
  2. Configure production behavior in Configuration.
  3. Read Event Model before writing policy or guardrails.