Skip to main content
weave / WeaveClient

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WeaveClient(«destructured»): WeaveClient

Parameters

NameType
«destructured»Object
› projectIdstring
› settings?Partial<Settings>
› traceServerApiApi<any>

Returns

WeaveClient

Defined in

src/weaveClient.ts:459

Properties

projectId

projectId: string

Defined in

src/weaveClient.ts:456

settings

settings: Settings

Defined in

src/weaveClient.ts:457

traceServerApi

traceServerApi: Api<any>

Defined in

src/weaveClient.ts:455

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

NameTypeDescription
predictCallIdstringID of the predict call to attach feedback to
scorerCallIdstringID of the scorer call that generated the feedback
runnableRefUristringURI of the scorer (Op or Object ref)
scorerOutputanyOutput of the scorer

Returns

Promise<string>

Defined in

src/weaveClient.ts:1727

createCall

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

Parameters

NameType
internalCallInternalCall
opRefany
paramsany[]
parameterNamesParameterNamesOption
thisArgany
currentCallCallStackEntry
parentCallundefined | CallStackEntry
startTimeDate
displayName?string
attributes?Record<string, any>

Returns

Promise<void>

Defined in

src/weaveClient.ts:1570

finishCall

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

Parameters

NameType
callInternalCall
resultany
currentCallCallStackEntry
parentCallundefined | CallStackEntry
summarizeundefined | (result: any) => Record<string, any>
endTimeDate
startCallPromisePromise<void>

Returns

Promise<void>

Defined in

src/weaveClient.ts:1630

finishCallWithException

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

Parameters

NameType
callInternalCall
errorany
currentCallCallStackEntry
parentCallundefined | CallStackEntry
endTimeDate
startCallPromisePromise<void>

Returns

Promise<void>

Defined in

src/weaveClient.ts:1672

get

get(ref): Promise<any>

Parameters

NameType
refObjectRef

Returns

Promise<any>

Defined in

src/weaveClient.ts:1025

getAgentCustomAttributes

getAgentCustomAttributes(options): Promise<Response<GetAgentCustomAttributesResult>> 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

NameType
optionsGetAgentCustomAttributesOptions

Returns

Promise<Response<GetAgentCustomAttributesResult>> Example
const  = await weave.init('entity/project');
const  = await .getAgentCustomAttributes({
  : {
    : {
      : [{: 'agent_name'}, {: 'my-agent'}],
    },
  },
  : '2026-06-15T00:00:00Z',
  : 200,
});

for (const  of .data.attributes ?? []) {
  .(`${.source}.${.key} (${.value_type}): ${.span_count}`);
}

Defined in

src/weaveClient.ts:772

getAgentSpanStats

getAgentSpanStats(options): Promise<Response<GetAgentSpanStatsResult>> 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

NameType
optionsGetAgentSpanStatsOptions

Returns

Promise<Response<GetAgentSpanStatsResult>> Example
const  = await weave.init('entity/project');
const  = await .getAgentSpanStats({
  : '2026-06-10T00:00:00Z',
  : '2026-06-23T00:00:00Z',
  : 86400, // one row per day
  : [
    {
      : 'total_input_tokens',
      : 'number',
      : ['sum'],
      : {: 'field', : 'input_tokens'},
    },
  ],
  : [{: 'agent_name'}],
});

for (const  of .data.rows ?? []) {
  .(.started_at_bucket, .agent_name, .total_input_tokens);
}

Defined in

src/weaveClient.ts:621

getAgentSpans

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

Parameters

NameType
optionsGetAgentSpansOptions

Returns

Promise<Response<GetAgentSpansResult>> Example
const  = await weave.init('entity/project');
const  = await .getAgentSpans({: 'my-agent', : 20});

for (const  of .data.spans) {
  .(.span_id, .span_name, .input_tokens);
}
Example
const  = await weave.init('entity/project');

const  = await .getAgentSpans({
  : 'my-agent',
  : {
    : {: [{: 'input_tokens'}, {: 1000}]},
  },
});

for (const  of .data.spans) {
  .(.span_id, .span_name, .input_tokens);
}

Defined in

src/weaveClient.ts:566

getAgentTurn

getAgentTurn(options): Promise<Response<AgentTraceChatRes>> Get data (including messages) for a single turn (by traceId).

Parameters

NameType
optionsGetAgentTurnOptions

Returns

Promise<Response<AgentTraceChatRes>> Example
const  = await weave.init('entity/project');
const  = await .getAgentTurn({
  : '01997b8a-2c89-7c4d-9d0e-2f7e5b9a1b2c',
  : true,
});

.(.data.root_span_name, .data.total_duration_ms);

for (const  of .data.messages ?? []) {
  if (.user_message) .('user:', .user_message);
  if (.assistant_message) .('assistant:', .assistant_message);
}

Defined in

src/weaveClient.ts:655

getAgentTurns

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

Parameters

NameType
optionsGetAgentTurnsOptions

Returns

Promise<Response<GetAgentTurnsResult>> Example
const  = await weave.init('entity/project');
const  = await .getAgentTurns({
  : 'trace_c50312356de3487fa90e381c9399b5b4',
  : 20,
  : true,
});

for (const  of .data.turns ?? []) {
  .(.trace_id, .root_span_name);
  for (const  of .messages ?? []) {
    if (.user_message) .('user:', .user_message);
    if (.assistant_message) .('assistant:', .assistant_message);
  }
}

.(`total turns: ${.data.total_turns}, has more: ${.data.has_more}`);

Defined in

src/weaveClient.ts:688

getAgentVersions

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

Parameters

Returns

Promise<Response<GetAgentVersionsResult>> Example
const  = await weave.init('entity/project');
const  = await .getAgentVersions({: 'my-agent', : 20});

for (const  of .data.versions) {
  .(.agent_version, .total_input_tokens);
}

.(`total count: ${.data.total_count}`)

Defined in

src/weaveClient.ts:522

getAgents

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

Parameters

NameType
optionsGetAgentsOptions

Returns

Promise<Response<GetAgentsResult>> Example
const  = await weave.init('entity/project');
const  = await .getAgents({: 20});

for (const  of .data.agents) {
  .(.agent_name, .total_input_tokens);
}

.(`total count: ${.data.total_count}`)

Defined in

src/weaveClient.ts:488

getCall

getCall(callId, includeCosts?): Promise<Call>

Parameters

NameTypeDefault value
callIdstringundefined
includeCostsbooleanfalse

Returns

Promise<Call>

Defined in

src/weaveClient.ts:902

getCallStack

getCallStack(): CallStack

Returns

CallStack

Defined in

src/weaveClient.ts:1482

getCalls

getCalls(options?): Promise<Call[]>

Parameters

NameType
options?GetCallsOptions

Returns

Promise<Call[]>

Defined in

src/weaveClient.ts:935 getCalls(options?, includeCosts?, limit?): Promise<Call[]>

Parameters

NameType
options?CallsFilter
includeCosts?boolean
limit?number

Returns

Promise<Call[]>

Defined in

src/weaveClient.ts:936

getCallsIterator

getCallsIterator(options?, includeCosts?, limit?): AsyncIterableIterator<CallSchema, any, any>

Parameters

NameType
options?CallsFilter
includeCosts?boolean
limit?number

Returns

AsyncIterableIterator<CallSchema, any, any>

Defined in

src/weaveClient.ts:957 getCallsIterator(options?): AsyncIterableIterator<CallSchema, any, any>

Parameters

NameType
options?GetCallsOptions

Returns

AsyncIterableIterator<CallSchema, any, any>

Defined in

src/weaveClient.ts:962

getCurrentAttributes

getCurrentAttributes(): Record<string, any>

Returns

Record<string, any>

Defined in

src/weaveClient.ts:1486

linkPromptToRegistry

linkPromptToRegistry(prompt, options): Promise<LinkAssetToRegistryRes> Link a published prompt version into a registry portfolio.

Parameters

NameType
promptRegistryLinkable
optionsLinkPromptToRegistryOptions

Returns

Promise<LinkAssetToRegistryRes>

Defined in

src/weaveClient.ts:1181

publish

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

Parameters

NameType
objany
objId?string

Returns

Promise<ObjectRef>

Defined in

src/weaveClient.ts:890

pushNewCall

pushNewCall(): Object

Returns

Object
NameType
currentCallCallStackEntry
newStackCallStack
parentCall?CallStackEntry

Defined in

src/weaveClient.ts:1490

runWithAttributes

runWithAttributes<T>(attributes, fn): T

Type parameters

Name
T

Parameters

NameType
attributesRecord<string, any>
fn() => T

Returns

T

Defined in

src/weaveClient.ts:1498

runWithCallStack

runWithCallStack<T>(callStack, fn): T

Type parameters

Name
T

Parameters

NameType
callStackCallStack
fn() => T

Returns

T

Defined in

src/weaveClient.ts:1494

saveCallEnd

saveCallEnd(callEnd): void

Parameters

NameType
callEndEndedCallSchemaForInsert

Returns

void

Defined in

src/weaveClient.ts:1477

saveCallStart

saveCallStart(callStart): void

Parameters

NameType
callStartStartedCallSchemaForInsert

Returns

void

Defined in

src/weaveClient.ts:1472

saveOp

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

Parameters

NameType
opOp<(…args: any[]) => any>
objId?string

Returns

Promise<OpRef>

Defined in

src/weaveClient.ts:1537

searchAgents

searchAgents(options): Promise<Response<SearchAgentsResult>> 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

NameType
optionsSearchAgentsOptions

Returns

Promise<Response<SearchAgentsResult>> Example
const  = await weave.init('entity/project');
const  = await .searchAgents({
  : 'Liverpool',
  : 'Assistant',
  : 20,
});

for (const  of .data.results ?? []) {
  .(`${.conversation_id} (${.agent_name})`);
  for (const  of .matched_messages) {
    .(`  [${.role}] ${.content_preview}`);
  }
}

.(`total conversations: ${.data.total_conversations}`);

Defined in

src/weaveClient.ts:730

serializeAudio

serializeAudio(data, audioType?): Promise<SerializedFileBlob> 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

NameTypeDefault valueDescription
dataBuffer<ArrayBufferLike>undefinedRaw audio bytes (WAV for best browser compatibility)
audioType"wav"DEFAULT_AUDIO_TYPEFile format — currently only ‘wav’ is supported

Returns

Promise<SerializedFileBlob>

Defined in

src/weaveClient.ts:1424

updateCall

updateCall(callId, displayName): Promise<void>

Parameters

NameType
callIdstring
displayNamestring

Returns

Promise<void>

Defined in

src/weaveClient.ts:1710

waitForBatchProcessing

waitForBatchProcessing(): Promise<void>

Returns

Promise<void>

Defined in

src/weaveClient.ts:801