Runtime#
Generated from crates/node/index.d.ts via sphinx-js.
AnthropicMessagesCodec#
Built-in codec for the Anthropic Messages API.
Implements both request codec (decode/encode) and response codec
(decodeResponse). Construct with new AnthropicMessagesCodec().
Kind: class
Members#
decodeunknown: Decode an opaque LLM request into structured form.encodeunknown: Encode structured changes back into an opaque LLM request.decodeResponseunknown: Decode a raw LLM response into structured form.
OpenAIResponsesCodec#
Built-in codec for the OpenAI Responses API.
Implements both request codec (decode/encode) and response codec
(decodeResponse). Construct with new OpenAIResponsesCodec().
Kind: class
Members#
decodeunknown: Decode an opaque LLM request into structured form.encodeunknown: Encode structured changes back into an opaque LLM request.decodeResponseunknown: Decode a raw LLM response into structured form.
OpenAIChatCodec#
Built-in codec for the OpenAI Chat Completions API.
Implements both request codec (decode/encode) and response codec
(decodeResponse). Construct with new OpenAIChatCodec().
Kind: class
Members#
decodeunknown: Decode an opaque LLM request into structured form.encodeunknown: Encode structured changes back into an opaque LLM request.decodeResponseunknown: Decode a raw LLM response into structured form.
LlmRequest#
An LLM request, encapsulating headers and content.
Construct via new LlmRequest(headers, content).
Kind: class
Members#
headersany: The metadata headers as a JSON object.contentany: The request payload as a JSON value.
LlmHandle#
A handle representing an in-progress LLM call.
Returned by llmCall() and used to signal completion via llmCallEnd().
Kind: class
Members#
uuidstring: The unique identifier for this LLM call.namestring: The name of the LLM provider being called.attributesnumber: Bitfield of LLM attributes (e.g., STATELESS, STREAMING).parentUuidstring: The UUID of the parent scope that initiated this LLM call, ornull.
ToolHandle#
A handle representing an in-progress tool call.
Returned by toolCall() and used to signal completion via toolCallEnd().
Kind: class
Members#
uuidstring: The unique identifier for this tool call.namestring: The name of the tool being called.attributesnumber: Bitfield of tool attributes (e.g., LOCAL).parentUuidstring: The UUID of the parent scope that initiated this tool call, ornull.
ScopeHandle#
A handle to an execution scope in the agent runtime.
Scopes form a hierarchical stack representing the current execution context
(e.g., agent -> function -> tool). Use this handle to reference a specific scope
when pushing child scopes, emitting events, or making tool/LLM calls.
Kind: class
Members#
uuidstring: The unique identifier for this scope.namestring: The human-readable name of this scope.scopeTypeScopeType: The type of this scope (Agent, Tool, Llm, etc.).attributesnumber: Bitfield of scope attributes (e.g., PARALLEL, RELOCATABLE).parentUuidstring: The UUID of this scope’s parent, ornullif this is the root scope.dataany: Optional user-defined data associated with this scope.metadataany: Optional metadata associated with this scope.
ScopeStack#
Handle to an isolated scope stack for per-request/per-task isolation.
Kind: class
LlmStream#
An async iterator over chunks from a streaming LLM response.
Obtained from llmStreamCallExecute(). Call next() repeatedly to consume
response chunks. Returns null when the stream is fully consumed.
Kind: class
Members#
nextunknown: Retrieve the next chunk from the stream.
Returns the next JSON chunk, or null when the stream is exhausted.
Throws if the underlying stream encountered an error.
OpenInferenceSubscriber#
OpenInference-backed event subscriber.
Kind: class
Members#
registerunknown: Register this subscriber globally with the given name.deregisterunknown: Deregister a subscriber by name.forceFlushunknown: Force a flush of finished spans through the exporter.shutdownunknown: Shut down the underlying tracer provider.
OpenTelemetrySubscriber#
OpenTelemetry-backed event subscriber.
Kind: class
Members#
registerunknown: Register this subscriber globally with the given name.deregisterunknown: Deregister a subscriber by name.forceFlushunknown: Force a flush of finished spans through the exporter.shutdownunknown: Shut down the underlying tracer provider.
AtifExporter#
An ATIF (Agent Trajectory Interchange Format) exporter that collects lifecycle events and exports them as a structured trajectory.
Create an instance with session and agent metadata, then register it as an event subscriber.
When ready, call exportJson() to serialize the collected trajectory.
Kind: class
Members#
registerunknown: Register this exporter as an event subscriber with the given name.
Throws if a subscriber with the same name already exists.
deregisterunknown: Deregister this exporter’s event subscriber by name.
Returns true if a subscriber with that name was found and removed.
exportJsonunknown: Export the collected trajectory as a JSON string.
Returns a JSON-serialized AtifTrajectory.
clearunknown: Clear all collected events from the exporter.
listPluginKinds#
List registered plugin kinds.
Kind: function
Returns#
string[]
activePluginReport#
Return the last successfully configured plugin report.
Kind: function
Returns#
any
clearPluginConfiguration#
Clear the active global plugin configuration.
Kind: function
initializePlugins#
Initialize the active global plugin components.
Kind: function
Parameters#
configJson
Returns#
Promise<Json>
deregisterPlugin#
Deregister a plugin by kind.
Kind: function
Parameters#
pluginKindstring
Returns#
boolean
registerPlugin#
Register a plugin backed by JavaScript callbacks.
validate receives (pluginConfig) and should return a diagnostics array.
register receives (pluginConfig, context) and should use the context methods
to attach subscribers or intercepts. Both callbacks must be synchronous.
Kind: function
Parameters#
pluginKindstringvalidate(args: any[]) => anyregister(args: any[]) => any
validatePluginConfig#
Validate a plugin config document and return a structured diagnostics report.
Kind: function
Parameters#
configJson
Returns#
Json
OpenInferenceConfig#
Mutable configuration object for OpenInferenceSubscriber.
Kind: interface
Members#
transport?string:"http_binary"(default) or"grpc".endpoint?string: OTLP endpoint, such ashttp://localhost:4318/v1/traces.headers?Json: Extra exporter headers/metadata as string key/value pairs.resourceAttributes?Json: Extra OpenInference resource attributes as string key/value pairs.serviceName?string:service.nameresource attribute. Defaults to"nemo-flow".serviceNamespace?string: Optionalservice.namespaceresource attribute.serviceVersion?string: Optionalservice.versionresource attribute.instrumentationScope?string: Instrumentation scope name. Defaults to"nemo-flow-openinference".timeoutMillis?number: Export timeout in milliseconds. Defaults to3000.
OpenTelemetryConfig#
Mutable configuration object for OpenTelemetrySubscriber.
Kind: interface
Members#
transport?string:"http_binary"(default) or"grpc".endpoint?string: OTLP endpoint, such ashttp://localhost:4318/v1/traces.headers?Json: Extra exporter headers/metadata as string key/value pairs.resourceAttributes?Json: Extra OpenTelemetry resource attributes as string key/value pairs.serviceName?string:service.nameresource attribute. Defaults to"nemo-flow".serviceNamespace?string: Optionalservice.namespaceresource attribute.serviceVersion?string: Optionalservice.versionresource attribute.instrumentationScope?string: Instrumentation scope name. Defaults to"nemo-flow-otel".timeoutMillis?number: Export timeout in milliseconds. Defaults to3000.
llmConditionalExecution#
Run the registered LLM conditional execution guardrail chain.
Throws if any guardrail rejects. The request should be a JSON object with headers
and content fields matching the LlmRequest schema.
Kind: function
Parameters#
requestJson
Returns#
Promise<void>
llmRequestIntercepts#
Run the registered LLM request intercept chain on the given request.
The request should be a JSON object with headers and content fields matching
the LlmRequest schema. Returns the transformed request as JSON.
Kind: function
Parameters#
namestringrequestJson
Returns#
Promise<unknown>
toolConditionalExecution#
Run the registered tool conditional execution guardrail chain.
Throws if any guardrail rejects.
Kind: function
Parameters#
namestringargsJson
Returns#
Promise<void>
toolRequestIntercepts#
Run the registered tool request intercept chain on the given arguments.
Returns the transformed arguments.
Kind: function
Parameters#
namestringargsJson
Returns#
Promise<unknown>
scopeDeregisterSubscriber#
Deregister a scope-local event subscriber by name.
Returns true if a subscriber with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterSubscriber#
Register a scope-local named event subscriber that receives lifecycle events for the specified scope.
The callback receives each event as a JSON-serialized JsEvent object. Events are
delivered asynchronously and non-blocking. Throws if a subscriber with the same name
already exists on the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestringcallback(arg: Json) => any
scopeDeregisterLlmStreamExecutionIntercept#
Deregister a scope-local LLM stream execution intercept by name.
Returns true if an intercept with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterLlmStreamExecutionIntercept#
Register a scope-local streaming LLM execution intercept following the middleware chain pattern.
The callable receives the request and a next function. Call next(request) to
invoke the next intercept or original streaming implementation; in Node the
returned promise resolves to an array of downstream JSON chunks. Skip calling
next to short-circuit the chain.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumbercallable(args: any[]) => any
scopeDeregisterLlmExecutionIntercept#
Deregister a scope-local LLM execution intercept by name.
Returns true if an intercept with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterLlmExecutionIntercept#
Register a scope-local LLM execution intercept following the middleware chain pattern.
The callable receives the request and a next function. Call next(request) to
invoke the next intercept or original implementation; skip calling next to
short-circuit the chain.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumbercallable(args: any[]) => any
scopeDeregisterLlmRequestIntercept#
Deregister a scope-local LLM request intercept by name.
Returns true if an intercept with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterLlmRequestIntercept#
Register a scope-local intercept that transforms LLM request data.
The callable receives the LlmRequest (as JSON) and returns a transformed request.
If breakChain is true, no lower-priority intercepts run after this one.
Higher priority values run first.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberbreakChainbooleancallable(arg: Json) => any
scopeDeregisterLlmConditionalExecutionGuardrail#
Deregister a scope-local LLM conditional execution guardrail by name.
Returns true if a guardrail with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterLlmConditionalExecutionGuardrail#
Register a scope-local guardrail that conditionally gates LLM execution.
The guardrail callback receives the LLM request as JSON and must return null to allow
execution or a rejection reason string to block it. Higher priority values run first.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberguardrail(arg: Json) => any
scopeDeregisterLlmSanitizeResponseGuardrail#
Deregister a scope-local LLM response sanitization guardrail by name.
Returns true if a guardrail with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterLlmSanitizeResponseGuardrail#
Register a scope-local guardrail that sanitizes LLM response data after execution.
The guardrail callback receives the LLM response as a JSON value and must return
the sanitized response as JSON. Higher priority values run first. Throws if a guardrail
with the same name already exists on the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberguardrail(arg: Json) => any
scopeDeregisterLlmSanitizeRequestGuardrail#
Deregister a scope-local LLM request sanitization guardrail by name.
Returns true if a guardrail with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterLlmSanitizeRequestGuardrail#
Register a scope-local guardrail that sanitizes LLM request data before execution.
The guardrail callback receives the LLM request as JSON and must return the sanitized request.
Higher priority values run first. Throws if a guardrail with the same name already exists
on the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberguardrail(arg: Json) => any
scopeDeregisterToolExecutionIntercept#
Deregister a scope-local tool execution intercept by name.
Returns true if an intercept with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterToolExecutionIntercept#
Register a scope-local tool execution intercept following the middleware chain pattern.
The callable receives the args and a next function. Call next(args) to invoke
the next intercept or original implementation; skip calling next to short-circuit
the chain.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumbercallable(args: any[]) => any
scopeDeregisterToolRequestIntercept#
r” Deregister a scope-local tool request intercept by name.
r”
r” Returns true if an intercept with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterToolRequestIntercept#
r” Register a scope-local intercept that transforms tool request arguments.
r”
r” The callable receives (toolName, args) and returns transformed args. If breakChain
r” is true, no lower-priority intercepts run after this one. Higher priority values run first.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberbreakChainbooleancallable(arg0: string, arg1: Json) => any
scopeDeregisterToolConditionalExecutionGuardrail#
Deregister a scope-local tool conditional execution guardrail by name.
Returns true if a guardrail with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterToolConditionalExecutionGuardrail#
Register a scope-local guardrail that conditionally gates tool execution.
The guardrail callback receives (toolName, args) and must return null to allow
execution or a rejection reason string to block it. Higher priority values run first.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberguardrail(arg0: string, arg1: Json) => any
scopeDeregisterToolSanitizeResponseGuardrail#
r” Deregister a scope-local tool response sanitization guardrail by name.
r”
r” Returns true if a guardrail with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterToolSanitizeResponseGuardrail#
r” Register a scope-local guardrail that sanitizes tool response data after execution.
r”
r” The guardrail callback receives (toolName, result) and must return sanitized result.
r” Higher priority values run first. Throws if a guardrail with the same name already exists
r” on the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberguardrail(arg0: string, arg1: Json) => any
scopeDeregisterToolSanitizeRequestGuardrail#
r” Deregister a scope-local tool request sanitization guardrail by name.
r”
r” Returns true if a guardrail with that name was found and removed from the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestring
Returns#
boolean
scopeRegisterToolSanitizeRequestGuardrail#
r” Register a scope-local guardrail that sanitizes tool request arguments before execution.
r”
r” The guardrail callback receives (toolName, args) and must return sanitized args.
r” Higher priority values run first. Throws if a guardrail with the same name already exists
r” on the specified scope.
Kind: function
Parameters#
scopeUuidstringnamestringprioritynumberguardrail(arg0: string, arg1: Json) => any
deregisterSubscriber#
Deregister an event subscriber by name.
Returns true if a subscriber with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerSubscriber#
Register a named event subscriber that receives all lifecycle events.
The callback receives each event as a JSON-serialized JsEvent object. Events are
delivered asynchronously and non-blocking. Throws if a subscriber with the same name
already exists.
Kind: function
Parameters#
namestringcallback(arg: Json) => any
deregisterLlmStreamExecutionIntercept#
Deregister an LLM stream execution intercept by name.
Returns true if an intercept with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerLlmStreamExecutionIntercept#
Register a streaming LLM execution intercept following the middleware chain pattern.
The callable receives the request and a next function. Call next(request) to
invoke the next intercept or original streaming implementation; in Node the
returned promise resolves to an array of downstream JSON chunks. Skip calling
next to short-circuit the chain.
Kind: function
Parameters#
namestringprioritynumbercallable(args: any[]) => any
deregisterLlmExecutionIntercept#
Deregister an LLM execution intercept by name.
Returns true if an intercept with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerLlmExecutionIntercept#
Register an LLM execution intercept following the middleware chain pattern.
The callable receives the request and a next function. Call next(request) to
invoke the next intercept or original implementation; skip calling next to
short-circuit the chain.
Kind: function
Parameters#
namestringprioritynumbercallable(args: any[]) => any
deregisterLlmRequestIntercept#
Deregister an LLM request intercept by name.
Returns true if an intercept with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerLlmRequestIntercept#
Register an intercept that transforms LLM request data.
The callable receives the LlmRequest (as JSON) and returns a transformed request.
If breakChain is true, no lower-priority intercepts run after this one.
Higher priority values run first.
Kind: function
Parameters#
namestringprioritynumberbreakChainbooleancallable(arg: Json) => any
deregisterLlmConditionalExecutionGuardrail#
Deregister an LLM conditional execution guardrail by name.
Returns true if a guardrail with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerLlmConditionalExecutionGuardrail#
Register a guardrail that conditionally gates LLM execution.
The guardrail callback receives the LLM request as JSON and must return null to allow
execution or a rejection reason string to block it. Higher priority values run first.
Kind: function
Parameters#
namestringprioritynumberguardrail(arg: Json) => any
deregisterLlmSanitizeResponseGuardrail#
Deregister an LLM response sanitization guardrail by name.
Returns true if a guardrail with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerLlmSanitizeResponseGuardrail#
Register a guardrail that sanitizes LLM response data after execution.
The guardrail callback receives the LLM response as a JSON value and must return
the sanitized response as JSON. Higher priority values run first. Throws if a guardrail
with the same name already exists.
Kind: function
Parameters#
namestringprioritynumberguardrail(arg: Json) => any
deregisterLlmSanitizeRequestGuardrail#
Deregister an LLM request sanitization guardrail by name.
Returns true if a guardrail with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerLlmSanitizeRequestGuardrail#
Register a guardrail that sanitizes LLM request data before execution.
The guardrail callback receives the LLM request as JSON and must return the sanitized request.
Higher priority values run first. Throws if a guardrail with the same name already exists.
Kind: function
Parameters#
namestringprioritynumberguardrail(arg: Json) => any
deregisterToolExecutionIntercept#
Deregister a tool execution intercept by name.
Returns true if an intercept with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerToolExecutionIntercept#
Register a tool execution intercept following the middleware chain pattern.
The callable receives the args and a next function. Call next(args) to invoke
the next intercept or original implementation; skip calling next to short-circuit
the chain.
Kind: function
Parameters#
namestringprioritynumbercallable(args: any[]) => any
deregisterToolRequestIntercept#
r” Deregister a tool request intercept by name.
r”
r” Returns true if an intercept with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerToolRequestIntercept#
r” Register an intercept that transforms tool request arguments.
r”
r” The callable receives (toolName, args) and returns transformed args. If breakChain
r” is true, no lower-priority intercepts run after this one. Higher priority values run first.
Kind: function
Parameters#
namestringprioritynumberbreakChainbooleancallable(arg0: string, arg1: Json) => any
deregisterToolConditionalExecutionGuardrail#
Deregister a tool conditional execution guardrail by name.
Returns true if a guardrail with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerToolConditionalExecutionGuardrail#
Register a guardrail that conditionally gates tool execution.
The guardrail callback receives (toolName, args) and must return null to allow
execution or a rejection reason string to block it. Higher priority values run first.
Kind: function
Parameters#
namestringprioritynumberguardrail(arg0: string, arg1: Json) => any
deregisterToolSanitizeResponseGuardrail#
r” Deregister a tool response sanitization guardrail by name.
r”
r” Returns true if a guardrail with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerToolSanitizeResponseGuardrail#
r” Register a guardrail that sanitizes tool response data after execution.
r”
r” The guardrail callback receives (toolName, result) and must return sanitized result.
r” Higher priority values run first. Throws if a guardrail with the same name already exists.
Kind: function
Parameters#
namestringprioritynumberguardrail(arg0: string, arg1: Json) => any
deregisterToolSanitizeRequestGuardrail#
r” Deregister a tool request sanitization guardrail by name.
r”
r” Returns true if a guardrail with that name was found and removed.
Kind: function
Parameters#
namestring
Returns#
boolean
registerToolSanitizeRequestGuardrail#
r” Register a guardrail that sanitizes tool request arguments before execution.
r”
r” The guardrail callback receives (toolName, args) and must return sanitized args.
r” Higher priority values run first. Throws if a guardrail with the same name already exists.
Kind: function
Parameters#
namestringprioritynumberguardrail(arg0: string, arg1: Json) => any
llmStreamCallExecute#
Execute a streaming LLM call end-to-end with full lifecycle management.
Like llmCallExecute, conditional-execution guardrails run first on the raw request.
Sanitize-request guardrails only affect the emitted Start event payload, and
sanitize-response guardrails only affect the aggregated End event payload.
Returns an LlmStream whose next() method yields response chunks incrementally.
The func callback receives the intercepted request as JSON and its response is streamed back.
Stream-level intercepts are applied to each chunk.
The request should be a JSON object with headers and content fields matching
the LlmRequest schema.
The optional collector callback is invoked with each intercepted chunk as JSON,
allowing the caller to accumulate chunks for aggregation. The optional finalizer
callback is invoked once when the stream is exhausted and must return a JSON value
representing the aggregated response.
Kind: function
Parameters#
namestringrequestJsonfunc(arg: Json) => anycollector(arg: Json) => anyfinalizer() => anyhandleScopeHandleattributesnumberdataanymetadataanymodelNamestringcodecDecode(arg: Json) => anycodecEncode(arg: Json) => anyresponseCodecDecode(arg: Json) => any
Returns#
Promise<LlmStream>
llmCallExecuteAsync#
Execute an LLM call end-to-end, supporting both sync and async (Promise-returning) callbacks.
Same lifecycle as llmCallExecute (guardrails → intercepts → func → response processing),
but transparently handles JS callbacks that return Promises.
Kind: function
Parameters#
namestringrequestJsonfunc(args: any[]) => anyhandleScopeHandleattributesnumberdataanymetadataanymodelNamestringcodecDecode(arg: Json) => anycodecEncode(arg: Json) => anyresponseCodecDecode(arg: Json) => any
Returns#
Promise<unknown>
llmCallExecute#
Execute an LLM call end-to-end with full lifecycle management.
Runs conditional-execution guardrails (on raw request) → request intercepts →
sanitize-request guardrails for the emitted Start event payload →
execution intercepts → func → sanitize-response guardrails for the emitted
End event payload. On rejection, only a standalone Mark event is emitted
(no Start/End pair) and GuardrailRejected is returned. The request
should be a JSON object with headers and content fields matching the
LlmRequest schema. Returns the final execution response; sanitize
guardrails do not rewrite the caller-visible value.
Kind: function
Parameters#
namestringrequestJsonfunc(arg: Json) => anyhandleScopeHandleattributesnumberdataanymetadataanymodelNamestringcodecDecode(arg: Json) => anycodecEncode(arg: Json) => anyresponseCodecDecode(arg: Json) => any
Returns#
Promise<unknown>
llmCallEnd#
End a manual LLM call lifecycle span.
Signals that the LLM call identified by handle has completed with the given response.
Sanitize-response guardrails are applied to the emitted end-event payload; response
intercepts run only through llmCallExecute. Optional data is used when the
sanitized response is JSON null, and optional metadata is recorded on the end event.
Optional timestamp is a Unix timestamp in microseconds recorded on the end event.
It must be a safe integer number; omit it to use the runtime default end timestamp.
Kind: function
Parameters#
handleLlmHandleresponseJsondataanymetadataanytimestampnumber
llmCall#
Begin a manual LLM call lifecycle span.
Registers an LLM invocation with the given provider name and request payload.
The request should be a JSON object with headers and content fields matching
the LlmRequest schema. Returns an LlmHandle that must be passed to llmCallEnd()
when the response is received. Sanitize-request guardrails are applied to the emitted
start-event payload; request and execution intercepts run only through llmCallExecute.
Optional handle specifies the parent scope; attributes is a bitfield; data is
stored on the handle; metadata is recorded on the start event; and modelName is
recorded in the LLM event category profile. Optional timestamp is a Unix timestamp
in microseconds recorded as the handle start time and start event timestamp. It must
be a safe integer number; omit it to use the current runtime time.
Kind: function
Parameters#
namestringrequestJsonhandleScopeHandleattributesnumberdataanymetadataanymodelNamestringtimestampnumber
Returns#
LlmHandle
toolCallExecuteAsync#
Execute a tool call end-to-end, supporting both sync and async (Promise-returning) callbacks.
Same lifecycle as toolCallExecute (guardrails → intercepts → func → response processing),
but transparently handles JS callbacks that return Promises. Uses napi_is_promise to detect
Promise return values and resolves them before continuing the pipeline.
Accepts a raw JsFunction instead of ThreadsafeFunction so it can create a
promise-aware wrapper with access to Env.
Kind: function
Parameters#
namestringargsJsonfunc(args: any[]) => anyhandleScopeHandleattributesnumberdataanymetadataany
Returns#
Promise<unknown>
toolCallExecute#
Execute a tool call end-to-end with full lifecycle management.
Runs conditional-execution guardrails (on raw args) → request intercepts →
sanitize-request guardrails for the emitted Start event payload →
execution intercepts → func → sanitize-response guardrails for the emitted
End event payload. On rejection, only a standalone Mark event is emitted
(no Start/End pair) and GuardrailRejected is returned. Returns the final
execution result; sanitize guardrails do not rewrite the caller-visible value.
Kind: function
Parameters#
namestringargsJsonfunc(arg: Json) => anyhandleScopeHandleattributesnumberdataanymetadataany
Returns#
Promise<unknown>
toolCallEnd#
End a manual tool call lifecycle span.
Signals that the tool call identified by handle has completed with the given result.
Sanitize-response guardrails are applied to the emitted end-event payload; response
intercepts run only through toolCallExecute. Optional data is used when the
sanitized result is JSON null, and optional metadata is recorded on the end event.
Optional timestamp is a Unix timestamp in microseconds recorded on the end event.
It must be a safe integer number; omit it to use the runtime default end timestamp.
Kind: function
Parameters#
handleToolHandleresultJsondataanymetadataanytimestampnumber
toolCall#
Begin a manual tool call lifecycle span.
Registers a tool invocation with the given name and args. Sanitize-request
guardrails are applied to the emitted start-event payload; request and execution
intercepts run only through toolCallExecute. Returns a ToolHandle that must
be passed to toolCallEnd() when the tool finishes. Optional handle specifies
the parent scope; attributes is a bitfield; data is stored on the handle;
metadata is recorded on the start event; and toolCallId is recorded in the
tool event category profile. Optional timestamp is a Unix timestamp in
microseconds recorded as the handle start time and start event timestamp. It must
be a safe integer number; omit it to use the current runtime time.
Kind: function
Parameters#
namestringargsJsonhandleScopeHandleattributesnumberdataanymetadataanytoolCallIdstringtimestampnumber
Returns#
ToolHandle
event#
Emit a custom mark event on the current scope.
Emits a named event with optional data and metadata payloads. If handle is provided,
the event is associated with that scope; otherwise it uses the current top scope.
Optional timestamp is a Unix timestamp in microseconds recorded on the mark event.
It must be a safe integer number; omit it to use the current runtime time.
Kind: function
Parameters#
namestringhandleScopeHandledataanymetadataanytimestampnumber
withScope#
Push a scope, run a callback, then pop the scope automatically.
Creates a child scope with the given name and scopeType, invokes the
callback with the new scope handle, and guarantees that the scope is popped
when the callback completes (whether it returns normally, throws, or returns a
rejected Promise). Supports both synchronous and async (Promise-returning)
callbacks.
Optional handle sets the parent scope; attributes is a bitfield of scope
attribute flags; data is stored on the scope handle; metadata is recorded
on the start event; and input is exported as the semantic start-event payload.
Returns a Promise that resolves with the callback’s return value.
Kind: function
Parameters#
namestringscopeTypeScopeTypecallback(args: any[]) => anyhandleScopeHandleattributesnumberdataanymetadataanyinputany
Returns#
Promise<unknown>
popScope#
Pop an execution scope from the scope stack.
Removes the scope identified by handle from the stack and emits an end event.
Optional output is a semantic JSON payload exported on the scope end event.
Optional timestamp is a Unix timestamp in microseconds recorded on the end event.
It must be a safe integer number; omit it to use the runtime default end timestamp.
Throws if the handle does not match the current top scope.
Kind: function
Parameters#
handleScopeHandleoutputanytimestampnumber
pushScope#
Push a new execution scope onto the scope stack.
Creates a child scope with the given name and scopeType. If handle is provided,
the new scope is parented to that scope; otherwise it is parented to the current top scope.
Optional attributes is a bitfield of scope attribute flags.
Optional data is a JSON application payload stored on the scope handle.
Optional metadata is a JSON metadata payload recorded on the scope start event.
Optional input is a semantic JSON payload exported on the scope start event.
Optional timestamp is a Unix timestamp in microseconds recorded as the handle
start time and start event timestamp. It must be a safe integer number; omit it
to use the current runtime time.
Returns the handle for the newly created scope.
Kind: function
Parameters#
namestringscopeTypeScopeTypehandleScopeHandleattributesnumberdataanymetadataanyinputanytimestampnumber
Returns#
ScopeHandle
getHandle#
Get the handle for the current top-of-stack execution scope.
Returns the ScopeHandle for the innermost active scope on the current task’s scope stack.
Throws if the scope stack is empty.
Kind: function
Returns#
ScopeHandle
clearLastCallbackError#
Clears the most recent callback error recorded by the Node binding.
Kind: function
getLastCallbackError#
Returns the most recent callback error that could not be surfaced through a direct exception.
This is primarily used for sanitize/intercept/finalizer callback paths whose
core callback signatures cannot return Result.
Kind: function
Returns#
string
scopeStackActive#
Returns whether the current execution context has an explicitly-initialized scope stack.
Returns true if setThreadScopeStack has been called on the current
thread, or the caller is inside a task-local scope. Returns false when
only the auto-created default is present.
Kind: function
Returns#
boolean
setThreadScopeStack#
Binds a scope stack to the current thread.
Kind: function
Parameters#
stackScopeStack
currentScopeStack#
Returns the current execution context’s scope stack handle.
Kind: function
Returns#
ScopeStack
createScopeStack#
Creates a new isolated scope stack.
Kind: function
Returns#
ScopeStack
endStream#
Signal that a stream is complete. Drops the sender so the Rust
receiver sees the channel as closed.
Kind: function
Parameters#
streamIdnumber
pushStreamChunk#
Push a chunk into the stream identified by streamId.
Called from JavaScript during async generator iteration.
Kind: function
Parameters#
streamIdnumberchunkJson
Returns#
boolean