Skip to main content

Propriétés

projectId

projectId : string

settings

settings : object

attributes

readonly attributes: Record<string, any>
Un ensemble d’attributs appliqués à chaque trace produite par ce client.

genai

readonly genai : objet
genai.batchOptions
optional batchOptions : BufferConfig
Configuration de BatchSpanProcessor. Ignorée sauf si spanProcessor === 'batch'.
genai.spanProcessor
optional spanProcessor: "batch" | "simple" | SpanProcessor
Mode d’export des spans GenAI.
  • 'batch' (par défaut) : BatchSpanProcessor, adapté aux agents en production et aux processus de longue durée.
  • 'simple' : SimpleSpanProcessor, une requête HTTP POST par span. Utile pour les tests et les CLI de courte durée, lorsqu’un vidage déterministe importe plus que le débit.
  • Instance de SpanProcessor : un processor fourni par l’utilisateur. L’appelant gère son cycle de vie ; l’exporter OTLP de Weave ciblant /agents/otel/v1/traces n’est pas utilisé.
readonly printCallLink: boolean
Affiche dans le terminal les liens vers l’interface Weave pour les ops.
Par défaut
true

useCallsComplete

useCallsComplete : boolean
Envoie les appels terminés au point de terminaison calls/complete (début et fin appariés côté client) au lieu de l’ancien chemin call/upsert_batch.
Par défaut
true

useOTelV2

useOTelV2 : boolean
Achemine les intégrations compatibles OTel via leur variante OTel.
Par défaut
true

traceServerApi

traceServerApi: Api<any>

Méthodes

addScore()

addScore(predictCallId, scorerCallId, runnableRefUri, scorerOutput) : Promise<string>
Ajoute le résultat d’un scorer (par exemple, sa sortie) à un appel. Utilisé dans une évaluation impérative pour joindre les résultats du scorer aux appels de prédiction.

Paramètres

string
requis
ID de l’appel predict auquel joindre le feedback
string
requis
ID de l’appel du scorer ayant généré le feedback
string
requis
URI du scorer (réf. d’op ou d’objet)
any
requis
Sortie du scorer

Renvoie

Promise<string>

createCall()

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

Paramètres

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

Renvoie

Promise<void>

finishCall()

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

Paramètres

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

Renvoie

Promise<void>

finishCallWithException()

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

Paramètres

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

Renvoie

Promise<void>

flush()

flush(): Promise<void>
Transmet au serveur tous les appels mis en mémoire tampon. À attendre avant process.exit().

Renvoie

Promise<void>

get()

get(ref) : Promise<any>

Paramètres

ObjectRef
requis
Voir ObjectRef.

Renvoie

Promise<any>

getAgentCustomAttributes()

getAgentCustomAttributes(options): Promise<Réponse<{ attributes?: object[]; has_more?: boolean; limit?: number; offset?: number; }>>
Découvrez les clés d’attributs personnalisés typés observées dans les spans d’agent du projet. Chaque ligne de résultat correspond à un triplet (source, key, value_type), accompagné du nombre de spans qui le portent. Les API de requête, de regroupement et de statistiques des spans l’utilisent pour référencer les attributs personnalisés. Filtrez les spans pris en compte en transmettant query (un filtre de span structuré), startedAfter / startedBefore (ISO-8601), ou les deux. Utilisez limit / offset pour parcourir les clés découvertes par pages.

Paramètres

object
requis

Renvoie

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

Exemple


getAgents()

getAgents(options?): Promise<Réponse<GetAgentsResult>>
Répertorie les agents avec des statistiques agrégées.

Paramètres

GetAgentsOptions = {}

Renvoie

Promise<Réponse<GetAgentsResult>>

Exemple


getAgentSpans()

getAgentSpans(options) : Promise<Réponse<GetAgentSpansResult>>
Interroge les spans d’agent, éventuellement filtrés par nom d’agent et/ou par une expression de requête de type Mongo.

Paramètres

GetAgentSpansOptions
requis

Renvoie

Promise<Réponse<GetAgentSpansResult>>

Exemples


getAgentSpanStats()

getAgentSpanStats(options) : Promise<Réponse<{ bucket_type?: "number" | "time"; columns?: object[]; end: string; granularity?: number | null; rows?: Record<string, string | number | boolean | null>[]; start: string; timezone: string; }>>
Agrégations sur les spans d’agent du projet, renvoyées sous forme de lignes et de métadonnées de colonnes adaptées aux visualisations de séries temporelles ou par compartiments. start (requis) et end définissent la fenêtre temporelle. Chaque entrée de metrics indique un champ à extraire et la façon de l’agréger (sum, avg, count, percentiles, etc.). Transmettez granularity (en secondes) pour regrouper les lignes par intervalle temporel, ou groupBy pour ventiler les résultats par agent / provider / model / etc. query filtre les spans sous-jacents avant l’agrégation.

Paramètres

object
requis

Renvoie

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

Exemple


getAgentTurn()

getAgentTurn(options) : Promise<Réponse<{ 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; }>>
Obtient les données (y compris les messages) d’un seul tour de conversation (par traceId).

Paramètres

GetAgentTurnOptions
requis

Renvoie

Promise<Réponse<{ 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; }>>

Exemple


getAgentTurns()

getAgentTurns(options): Promise<Réponse<GetAgentTurnsResult>>
Obtenir les données (y compris les messages) de nombreux tours de conversation (par conversationId).

Paramètres

GetAgentTurnsOptions
requis

Renvoie

Promise<Réponse<GetAgentTurnsResult>>

Exemple


getAgentVersions()

getAgentVersions(options) : Promise<Réponse<GetAgentVersionsResult>>
Liste les versions d’un agent donné.

Paramètres

GetAgentVersionsOptions
requis

Renvoie

Promise<Réponse<GetAgentVersionsResult>>

Exemple


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>; }>

Paramètres

string
requis
boolean = false

Renvoie

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()

Signature de l’appel

getCalls(options?): Promise<objet[]>
Paramètres
GetCallsOptions
Renvoie
Promise<objet[]>

Signature de l’appel

getCalls(options?, includeCosts?, limit?): Promise<objet[]>
Paramètres
CallsFilter
boolean
number
Renvoie
Promise<objet[]>

getCallsIterator()

Signature de l’appel

getCallsIterator(options?, includeCosts?, limit?): AsyncIterableIterator<CallSchema>
Paramètres
CallsFilter
boolean
number
Renvoie
AsyncIterableIterator<CallSchema>

Signature d’appel

getCallsIterator(options?): AsyncIterableIterator<CallSchema>
Paramètres
GetCallsOptions
Renvoie
AsyncIterableIterator<CallSchema>

getCallStack()

getCallStack(): CallStack

Renvoie

CallStack

getCurrentAttributes()

getCurrentAttributes(): Record<string, any>

Renvoie

Record<string, any>

linkPromptToRegistry()

linkPromptToRegistry(prompt, options): Promise<{ version_index: number | null; }>
Associe une version publiée d’un prompt à un portefeuille de registre.

Paramètres

string | ObjectRef | Prompt
requis
Voir ObjectRef.
objet
requis

Renvoie

Promise<{ version_index: number | null; }>

pendingCallCount()

pendingCallCount(): number
Appels mis en mémoire tampon côté client, mais pas encore transmis au serveur.

Renvoie

number

publish()

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

Paramètres

any
requis
string

Renvoie

Promise<ObjectRef>

pushNewCall()

pushNewCall() : objet

Renvoie

objet
objet
requis
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
requis
objet
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<Réponse<{ api_key_secret: string | null; base_url: string; headers: Record<string, string>; name: string; runtime_ids: objet[]; }>>
Enregistre un environnement d’exécution personnalisé, en remplaçant l’intégralité de sa configuration s’il existe déjà.

Paramètres

RegisterCustomRuntimeOptions
requis

Renvoie

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

runWithAttributes()

runWithAttributes<T>(attributes, fn): T

Paramètres de type

Paramètres

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

Renvoie

T

runWithCallStack()

runWithCallStack<T>(callStack, fn) : T

Paramètres de type

Paramètres

CallStack
requis
() => T
requis

Renvoie

T

saveCallEnd()

saveCallEnd(callEnd) : void

Paramètres

objet & objet
requis

Renvoie

void

saveCallStart()

saveCallStart(callStart, opts?) : void

Paramètres

object
requis
object

Renvoie

void

saveOp()

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

Paramètres

Op<(...args) => any>
requis
Voir Op.
string

Renvoie

Promise<OpRef>

searchAgents()

searchAgents(options) : Promise<Réponse<{ results: objet[]; total_conversations?: number; }>>
Recherche en texte intégral parmi les messages d’agent du projet. Renvoie les résultats regroupés par conversation, avec un aperçu de chaque message correspondant. query correspond au terme de recherche en texte intégral. Transmettez une chaîne vide pour récupérer tous les messages correspondant aux filtres structurés (agentName, conversationId, traceId) sans effectuer de recherche textuelle. Utilisez limit / offset pour parcourir les résultats page par page.

Paramètres

objet
requis

Renvoie

Promise<Réponse<{ results: objet[]; total_conversations?: number; }>>

Exemple


serializeAudio()

serializeAudio(data, audioType?): Promise<{ _type: "CustomWeaveType"; files: Record<string, string>; load_op: string; weave_type: { type: string; }; }>
Téléverse des octets audio bruts vers le magasin de contenu Weave et renvoie l’espace réservé CustomWeaveType pouvant être intégré à une sortie d’appel. Utilisez cette méthode lorsque vous créez manuellement des sorties d’appel (par ex. via saveCallEnd) et que le pipeline de sérialisation automatique de finishCall n’est pas utilisé.

Paramètres

Buffer
requis
Données audio brutes (WAV pour une compatibilité optimale avec les navigateurs)
"wav" = DEFAULT_AUDIO_TYPE
Format de fichier — seul ‘wav’ est actuellement pris en charge

Renvoie

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

updateCall()

updateCall(callId, displayName) : Promise<void>

Paramètres

string
requis
string
requis

Renvoie

Promise<void>

waitForBatchProcessing()

waitForBatchProcessing(): Promise<void>

Renvoie

Promise<void>