mirrors-sdk@0.6.2. Start with the quickstart
for integration code.
Constructor
new Mirrors({ apiUrl, apiKey, agentId }) creates a client for one agent. Reuse it
across that agent’s conversations. Keep keys in server secrets. Node.js 22 or later
is required; ES modules and CommonJS are supported.
Context retrieval
getContext({ trace }, { signal?, timeoutMs? }) returns a promise for:
The call’s
timeoutMs may shorten the total 1,000 ms wait budget to 1–1,000 ms.
The SDK allows up to 16 concurrent context waits. A newer retrieval for the same
trace supersedes the older pending wait. Changed captured evidence, finalization,
release, local disable, and shutdown invalidate pending retrievals.
accepted means a server decision was received. It does not report that your
application applied the context or that the agent succeeded.
Trace capture
captureTrace({ trace, final, terminal? }) returns a delivery ticket immediately.
It captures original history in the background without returning context.
ticket.receipt is the current delivery status. ticket.done resolves with the
settled receipt. Observe it outside the model execution path. A final capture can
queue ingestion; queued analysis is not completed analysis.
The optional terminal value is completed, failed, or canceled and is valid
only on final capture. See trace capture for the schema.
Lifecycle
Never reuse a released or completed execution ID. Call
flush before dispose
when you want an explicit bounded capture drain.
Existing integrations
sendTrace, prefetchTrace, submitTrace, injectSystemPrompt, and close remain
available for compatibility. Awaiting legacy sendTrace does not wait for fresh
context. New integrations should use getContext and captureTrace directly.