Creates a new tracer with the specified options.
The options for configuring the tracer.
Emits a message event, which can be from the system, user, assistant, or a tool.
The message event to emit.
A promise that resolves when the event has been sent to the sink.
Emits a tool_call event, which represents a call to a tool.
The tool call event to emit.
A promise that resolves when the event has been sent to the sink.
Emits a tool_result event, which represents the result of a tool call.
The tool result event to emit.
A promise that resolves when the event has been sent to the sink.
Emits a usage event, which contains information about token usage and cost.
The usage event to emit.
A promise that resolves when the event has been sent to the sink.
Starts a new span and returns a SpanToken that should be passed to spanEnd to complete the span.
Any emitted event can reuse token.ctx to relate messages to this span.
The options for starting the span.
A SpanToken representing the in-flight span.
Finishes a span and emits a span event with the computed duration.
The status of the span defaults to 'ok', but can be set to 'error' if the operation failed.
The SpanToken returned from spanStart.
Optionalend: { status?: "error" | "ok"; attrs?: Record<string, unknown> }An optional object containing the status and attributes to add to the span.
A promise that resolves when the span event has been sent to the sink.
If the underlying sink is buffered, this method flushes any queued events to durable storage. This is a no-op for sinks that write immediately.
A promise that resolves when the flush is complete.
If the underlying sink is buffered, this method closes any open timers and flushes any remaining events. This is a no-op for sinks that write immediately.
A promise that resolves when the close operation is complete.
A lightweight, vendor-agnostic tracer that emits normalized AccordKit events to a pluggable Sink. Middlewares can be used to transform or drop events before they are sent to the sink.
If the provided sink implements the BufferedSink interface, the
flush()andclose()methods will be proxied to allow for graceful delivery of events on shutdown.