Continuous behavioral telemetry for AI agents.
The L4 layer of the agent identity stack requires telemetry that runs continuously, is non-blocking for the agent runtime, and is queryable by every counterparty. @armalo/telemetry is the drop-in client that streams that telemetry to the Armalo Trust Oracle.
Install
pnpm add @armalo/telemetry # or npm i @armalo/telemetry
Quickstart
One client per agent runtime. Issue events; the client batches and flushes them automatically.
import { Telemetry } from '@armalo/telemetry';
const tel = new Telemetry({
apiKey: process.env.ARMALO_API_KEY!,
});
const sessionId = crypto.randomUUID();
const agentId = 'YOUR_AGENT_UUID';
tel.sessionStart({
sessionId,
agentId,
startedAt: new Date().toISOString(),
pactId: 'YOUR_PACT_UUID', // enables continuous param-binding validation
});
tel.toolCall({
sessionId,
agentId,
tool: 'transfer_funds',
params: { destination: '0xAB...', amount: 250 },
outcome: 'success',
latencyMs: 142,
attemptedAt: new Date().toISOString(),
});
tel.sessionEnd({
sessionId,
agentId,
endedAt: new Date().toISOString(),
outcome: 'success',
});
await tel.close(); // flush before process exitOne-liner: instrument any tool
Wrap any function and every invocation streams a tool_call event. Pass-through on return values and errors — telemetry never breaks the runtime.
const safeTransfer = tel.instrumentTool({
sessionId,
agentId,
tool: 'transfer_funds',
pactId: 'YOUR_PACT_UUID',
fn: async (params) => yourTransferImpl(params),
});
// Every invocation emits a tool_call event automatically.
// Errors are captured + re-thrown — telemetry never breaks your runtime.
await safeTransfer({ destination: '0xAB...', amount: 250 });Event shapes
session_startOpens a session. Attach a pactId to enable continuous param-binding evaluation on subsequent tool_call events in this session.
session_endCloses a session. outcome ∈ { success, failure, aborted, timeout }.
tool_callThe L4 substrate event. When pactId is attached, the server validates params against the pact's param_binding conditions in continuous time and records any violations to the room ledger.
responseA response emitted to a counterparty. outcome ∈ { success, refusal, partial, error }.
Failure semantics
- Network errors and 5xx responses retry with exponential backoff up to
maxRetries(default 3). - 4xx (other than 429) is permanent — the batch is dropped with one log line.
- Buffer overflow (>1000 events) drops the oldest event with a warning. The agent's correctness must not depend on telemetry succeeding.
- The client is non-blocking by default. For strong isolation, run telemetry in a separate process/sidecar with a dedicated API key.
Bind your tool calls to a pact.
Adding parameter bindings to a pact lets the L4 layer validate each tool call in continuous time. OAuth confirms who an agent is; parameter binding confirms what the agent is passing.
Parameter binding spec