Skip to main content

Properties

projectId

projectId: string

settings

settings: object

attributes

readonly attributes: Record<string, any>
A map of attributes applied to every trace produced by this client.

genai

readonly genai: object
genai.batchOptions
optional batchOptions: BufferConfig
BatchSpanProcessor configuration. Ignored unless spanProcessor === 'batch'.
genai.spanProcessor
optional spanProcessor: "batch" | "simple" | SpanProcessor
How GenAI spans are exported.
  • 'batch' (default): BatchSpanProcessor, suitable for production agents and long-lived processes.
  • 'simple': SimpleSpanProcessor, one HTTP POST per span. Useful for tests and short-lived CLIs where deterministic flush matters more than throughput.
  • SpanProcessor instance: a user-supplied processor. The caller owns its lifecycle; the Weave OTLP exporter targeting /agents/otel/v1/traces is not used.
readonly printCallLink: boolean
Prints links in terminal to Weave UI for ops.
Default
true

useCallsComplete

useCallsComplete: boolean
Sends finished calls to the calls/complete endpoint (start+end paired client-side) instead of the legacy call/upsert_batch path.
Default
true

useOTelV2

useOTelV2: boolean
Routes OTel-capable integrations through their OTel variant.
Default
true

traceServerApi

traceServerApi: Api<any>

Methods

addScore()

addScore(predictCallId, scorerCallId, runnableRefUri, scorerOutput): Promise<string>
Add a scorer result (e.g., scorer output) to a call. Used in imperative evaluation to attach scorer results to predict calls.

Parameters

string
required
ID of the predict call to attach feedback to
string
required
ID of the scorer call that generated the feedback
string
required
URI of the scorer (Op or Object ref)
any
required
Output of the scorer

Returns

Promise<string>

createCall()

createCall(internalCall, opRef, params, parameterNames, thisArg, currentCall, parentCall, startTime, displayName?, attributes?, eagerCallStart?): Promise<void>

Parameters

InternalCall
required
any
required
any[]
required
undefined | "useParam0Object" | string[]
required
any
required
object
required
{…} | undefined
required
Full type: { callId: string; childSummary: Record<string, any>; displayName?: string; opName?: string; traceId: string; } | undefined
Date
required
string
Record<string, any>
boolean = false

Returns

Promise<void>

finishCall()

finishCall(call, result, currentCall, parentCall, summarize, endTime, startCallPromise): Promise<void>

Parameters

InternalCall
required
any
required
object
required
{…} | undefined
required
Full type: { callId: string; childSummary: Record<string, any>; displayName?: string; opName?: string; traceId: string; } | undefined
((result) => Record<string, any>) | undefined
required
Date
required
Promise<void>
required

Returns

Promise<void>

finishCallWithException()

finishCallWithException(call, error, currentCall, parentCall, endTime, startCallPromise): Promise<void>

Parameters

InternalCall
required
any
required
object
required
{…} | undefined
required
Full type: { callId: string; childSummary: Record<string, any>; displayName?: string; opName?: string; traceId: string; } | undefined
Date
required
Promise<void>
required

Returns

Promise<void>

flush()

flush(): Promise<void>
Deliver all buffered calls to the server. Await before process.exit().

Returns

Promise<void>

get()

get(ref): Promise<any>

Parameters

ObjectRef
required

Returns

Promise<any>

getAgentCustomAttributes()

getAgentCustomAttributes(options): Promise<Response<{ attributes?: object[]; has_more?: boolean; limit?: number; offset?: number; }>>
Discover typed custom-attribute keys observed on agent spans in the project. Each result row is one (source, key, value_type) triple plus a count of how many spans carry it, which is what the spans query/group/stats APIs use to reference custom attrs. Filter the spans considered by passing query (a structured span filter), startedAfter / startedBefore (ISO-8601), or both. Use limit / offset to page through the discovered keys.

Parameters

object
required

Returns

Promise<Response<{ attributes?: object[]; has_more?: boolean; limit?: number; offset?: number; }>>

Example


getAgents()

getAgents(options?): Promise<Response<GetAgentsResult>>
List agents with aggregated stats.

Parameters

GetAgentsOptions = {}

Returns

Promise<Response<GetAgentsResult>>

Example


getAgentSpans()

getAgentSpans(options): Promise<Response<GetAgentSpansResult>>
Query agent spans, optionally filtered by agent name and/or a mongo-style query expression.

Parameters

GetAgentSpansOptions
required

Returns

Promise<Response<GetAgentSpansResult>>

Examples


getAgentSpanStats()

getAgentSpanStats(options): Promise<Response<{ bucket_type?: "number" | "time"; columns?: object[]; end: string; granularity?: number | null; rows?: Record<string, string | number | boolean | null>[]; start: string; timezone: string; }>>
Agregations over agent spans in the project, returned as rows + column metadata suitable for time-series / bucketed visualizations. start (required) and end define the time window. Each entry in metrics declares a field to extract and how to aggregate it (sum, avg, count, percentiles, etc.). Pass granularity (seconds) to bucket rows by time, or groupBy to break results out per agent / provider / model / etc. query filters the underlying spans before aggregation.

Parameters

object
required

Returns

Promise<Response<{ bucket_type?: "number" | "time"; columns?: object[]; end: string; granularity?: number | null; rows?: Record<string, string | number | boolean | null>[]; start: string; timezone: string; }>>

Example


getAgentTurn()

getAgentTurn(options): Promise<Response<{ agent_name?: string | null; agent_version?: string | null; feedback?: Record<string, any>[] | null; messages?: object[]; provider?: string | null; root_span_name?: string | null; status_code?: "UNSET" | "OK" | "ERROR" | null; total_cost_usd?: number | null; total_duration_ms?: number | null; trace_id: string; }>>
Get data (including messages) for a single turn (by traceId).

Parameters

GetAgentTurnOptions
required

Returns

Promise<Response<{ agent_name?: string | null; agent_version?: string | null; feedback?: Record<string, any>[] | null; messages?: object[]; provider?: string | null; root_span_name?: string | null; status_code?: "UNSET" | "OK" | "ERROR" | null; total_cost_usd?: number | null; total_duration_ms?: number | null; trace_id: string; }>>

Example


getAgentTurns()

getAgentTurns(options): Promise<Response<GetAgentTurnsResult>>
Get data (including messages) for many turns (by conversationId).

Parameters

GetAgentTurnsOptions
required

Returns

Promise<Response<GetAgentTurnsResult>>

Example


getAgentVersions()

getAgentVersions(options): Promise<Response<GetAgentVersionsResult>>
List versions for a given agent.

Parameters

GetAgentVersionsOptions
required

Returns

Promise<Response<GetAgentVersionsResult>>

Example


getCall()

getCall(callId, includeCosts?): Promise<{ attributes: Record<string, any>; deleted_at?: string | null; display_name?: string | null; ended_at?: string | null; exception?: string | null; expire_at?: string | null; id: string; inputs: Record<string, any>; op_name: string; output?: null; parent_id?: string | null; project_id: string; started_at: string; storage_size_bytes?: number | null; summary?: Record<string, any>; thread_id?: string | null; total_storage_size_bytes?: number | null; trace_id: string; turn_id?: string | null; wb_run_id?: string | null; wb_run_step?: number | null; wb_run_step_end?: number | null; wb_user_id?: string | null; wb_username?: string | null; setDisplayName: Promise<void>; }>

Parameters

string
required
boolean = false

Returns

Promise<{ attributes: Record<string, any>; deleted_at?: string | null; display_name?: string | null; ended_at?: string | null; exception?: string | null; expire_at?: string | null; id: string; inputs: Record<string, any>; op_name: string; output?: null; parent_id?: string | null; project_id: string; started_at: string; storage_size_bytes?: number | null; summary?: Record<string, any>; thread_id?: string | null; total_storage_size_bytes?: number | null; trace_id: string; turn_id?: string | null; wb_run_id?: string | null; wb_run_step?: number | null; wb_run_step_end?: number | null; wb_user_id?: string | null; wb_username?: string | null; setDisplayName: Promise<void>; }>

getCalls()

Call Signature

getCalls(options?): Promise<object[]>
Parameters
GetCallsOptions
Returns
Promise<object[]>

Call Signature

getCalls(options?, includeCosts?, limit?): Promise<object[]>
Parameters
CallsFilter
boolean
number
Returns
Promise<object[]>

getCallsIterator()

Call Signature

getCallsIterator(options?, includeCosts?, limit?): AsyncIterableIterator<CallSchema>
Parameters
CallsFilter
boolean
number
Returns
AsyncIterableIterator<CallSchema>

Call Signature

getCallsIterator(options?): AsyncIterableIterator<CallSchema>
Parameters
GetCallsOptions
Returns
AsyncIterableIterator<CallSchema>

getCallStack()

getCallStack(): CallStack

Returns

CallStack

getCurrentAttributes()

getCurrentAttributes(): Record<string, any>

Returns

Record<string, any>

linkPromptToRegistry()

linkPromptToRegistry(prompt, options): Promise<{ version_index: number | null; }>
Link a published prompt version into a registry portfolio.

Parameters

string | ObjectRef | Prompt
required
object
required

Returns

Promise<{ version_index: number | null; }>

pendingCallCount()

pendingCallCount(): number
Calls buffered client-side but not yet delivered to the server.

Returns

number

publish()

publish(obj, objId?): Promise<ObjectRef>

Parameters

any
required
string

Returns

Promise<ObjectRef>

pushNewCall()

pushNewCall(): object

Returns

object
object
required
currentCall.callId
callId: string
currentCall.childSummary
childSummary: Record<string, any>
currentCall.displayName
optional displayName: string
currentCall.opName
optional opName: string
currentCall.traceId
traceId: string
CallStack
required
object
parentCall.callId
callId: string
parentCall.childSummary
childSummary: Record<string, any>
parentCall.displayName
optional displayName: string
parentCall.opName
optional opName: string
parentCall.traceId
traceId: string

registerCustomRuntime()

registerCustomRuntime(options): Promise<Response<{ api_key_secret: string | null; base_url: string; headers: Record<string, string>; name: string; runtime_ids: object[]; }>>
Register a custom runtime, replacing its complete configuration if it exists.

Parameters

RegisterCustomRuntimeOptions
required

Returns

Promise<Response<{ api_key_secret: string | null; base_url: string; headers: Record<string, string>; name: string; runtime_ids: object[]; }>>

runWithAttributes()

runWithAttributes<T>(attributes, fn): T

Type Parameters

Parameters

Record<string, any>
required
() => T
required

Returns

T

runWithCallStack()

runWithCallStack<T>(callStack, fn): T

Type Parameters

Parameters

CallStack
required
() => T
required

Returns

T

saveCallEnd()

saveCallEnd(callEnd): void

Parameters

object & object
required

Returns

void

saveCallStart()

saveCallStart(callStart, opts?): void

Parameters

object
required
object

Returns

void

saveOp()

saveOp(op, objId?): Promise<OpRef>

Parameters

Op<(...args) => any>
required
See Op.
string

Returns

Promise<OpRef>

searchAgents()

searchAgents(options): Promise<Response<{ results: object[]; total_conversations?: number; }>>
Full-text search across agent messages in the project. Returns hits grouped by conversation, with a preview of each matched message. query is the full-text search term. Pass an empty string to retrieve all messages matching the structured filters (agentName, conversationId, traceId) without text matching. Use limit / offset to page through results.

Parameters

object
required

Returns

Promise<Response<{ results: object[]; total_conversations?: number; }>>

Example


serializeAudio()

serializeAudio(data, audioType?): Promise<{ _type: "CustomWeaveType"; files: Record<string, string>; load_op: string; weave_type: { type: string; }; }>
Upload raw audio bytes to the Weave content store and return the CustomWeaveType placeholder that can be embedded in a call output. Use this when building call outputs manually (e.g. via saveCallEnd) where the automatic serialization pipeline from finishCall is not used.

Parameters

Buffer
required
Raw audio bytes (WAV for best browser compatibility)
"wav" = DEFAULT_AUDIO_TYPE
File format — currently only ‘wav’ is supported

Returns

Promise<{ _type: "CustomWeaveType"; files: Record<string, string>; load_op: string; weave_type: { type: string; }; }>

updateCall()

updateCall(callId, displayName): Promise<void>

Parameters

string
required
string
required

Returns

Promise<void>

waitForBatchProcessing()

waitForBatchProcessing(): Promise<void>

Returns

Promise<void>