SovaraClient, trace, and CompatibilityError, plus
the TypeScript types SovaraClientOptions, SovaraTraceOptions,
SovaraSubtraceOptions, SovaraTurnOptions, and TraceOptions.
For existing integrations, client.run(..., { runId }), client.subrun() and
client.getRunId() remain deprecated aliases for the trace methods below.
SovaraRunOptions and SovaraSubrunOptions remain exported for those calls.
These aliases use the current server contract and trace ID derivation.
new SovaraClient(options)
Creates a project-bound client. Project identity and connection configuration
belong to the client, not to individual traces.
sovara_client.trace(name, fn, options?)
Opens and finalizes a recording session around a synchronous or asynchronous
callback. No turn is created implicitly; work outside turn() remains recorded
without a turn.
Returns the callback result as
Promise<T>. Use getTraceId() inside the callback
to read the trace ID. A supplied sovara- ID must already exist in the project.
If the server is unreachable, the callback may run without recording and
getTraceId() returns undefined. Authentication, compatibility, and callback
errors propagate.
For a remote server:
sovara_client.subtrace(name, fn, options?)
Creates a child trace under the active trace. The optional lessonScope replaces
the inherited lesson scope for that child.
Promise<T> for the callback result. Requires an enclosing trace
opened by the same client; the callback still executes if that enclosing trace
is in no-capture mode.
sovara_client.turn(options, fn)
Groups one interaction in the active trace or subtrace. Accepts optional
turnInput?: string and returns the callback result as Promise<T>.
trace(fn, options?)
Wraps a synchronous or asynchronous function as a step, recording arguments,
return values, latency, status, and exceptions.
name defaults to the function or method name. meta adds step metadata.
The curried form trace(options)(fn) and Stage 3 method decorators are also
supported. Use standard decorators rather than TypeScript’s legacy
experimentalDecorators mode. Wrapping a synchronous function preserves its
synchronous return value; wrapping an async function preserves its promise.
sovara_client.lessonScope(scope, fn)
Temporarily replaces the active lesson scope. Paths include descendants;
null or a root marker selects all lessons, and [] disables retrieval.
Restores the previous scope when the callback completes and returns the callback
result as Promise<T>. It can wrap an existing trace’s work or establish a scope
for traces opened inside the callback. Inside an active trace, use the same client.
sovara_client.logInput(value)
Stores the latest user-visible input on the active trace. This value appears in
the Input column of the Traces table and replaces the previously logged input.
Objects and arrays are serialized as JSON.
Promise<void>. Outside an active trace, it warns once and does nothing.
sovara_client.logOutput(value)
Stores the latest user-visible output on the active trace. This value appears in
the Output column of the Traces table and replaces the previously logged output.
Objects and arrays are serialized as JSON.
Promise<void>. Outside an active trace, it warns once and does nothing.
sovara_client.logMetrics(metrics)
Adds filterable custom metrics to the active trace. Values must be booleans or
finite numbers. Supply at least one metric. Keys must start with a lowercase
letter, contain only lowercase letters, digits, and underscores, and be at most
32 characters. Strings, objects, arrays, and null are not metric values.
Promise<void>. Logging the same key again updates its latest value.
Outside an active trace, it warns once and does nothing.
Await logging calls inside the trace opened by this client. Validation and
transport errors reject the promise. These helpers do not log evaluation-level results.
sovara_client.getTraceId()
Returns the current trace or subtrace ID as a string, or undefined when called
outside an active trace.
Claude Agent SDK wrapper
Install@anthropic-ai/claude-agent-sdk separately and import its instrumented
entrypoints from @sovara/runner/claude:
query and startup. Create the query or connection inside
the intended trace and turn, and consume it before leaving the recording. A
long-lived connection retains the context in which it was created. Custom
Claude Agent SDK transports are not supported by this wrapper.