Works in Node.js v18+, browsers, and React Native.

Install

Client setup

Options: clientKey (browser/RN) or clientId + clientSecret (server), plus optional baseUrl (default https://api.agents.beforequery.com).

Run an agent

MCP tools

Typed wrappers over the project MCP server; the JSON-RPC initialize handshake happens lazily:

A2A protocol

defineAgent — graph as code

Define and validate agent graphs in TypeScript; the output matches the backend JSON format:
Validation rules: at least one node; exactly one coordinator; unique node ids; edges must reference existing nodes; self-loops rejected. Violations throw AgentGraphError.

Error handling

Self-hosted agent runtime

The package ships an HTTP runtime server so you can execute agent graphs on your own infrastructure (credentials still authenticate against the BeforeQuery API for retrieval and LLM calls).
Agent definitions are .json files in the mounted directory — either a named manifest with remoteAgentId (proxies to a cloud agent) or a bare graph (filename stem becomes the agent ID, validated by defineAgent at startup). Runtime endpoints: GET /healthz, GET /agents, POST /run/:agentId with body { input, context? }.

Local testing