Package exports
Root package exports re-exported from @maniac-ai/agents.
Classes
Maniac
Defined in: src/agents/app.ts:107
Constructors
Constructor
new Maniac(
options?):Maniac
Defined in: src/agents/app.ts:210
Parameters
options?
agents?
Record<string, Agent> | Agent[]
model?
Model | null
policy?
PermissionPolicy | null
memory?
Memory | null
budget?
{ max_iterations: number; max_tokens?: number | null; max_cost_usd?: number | null; max_wall_seconds?: number | null; } | null
observationalMemory?
{ model: unknown; reflection_model?: unknown; message_chars: number; observation_chars: number; buffer_fraction: number; activation_fraction: number; block_after: number; activate_after_idle?: number | null; activate_on_provider_change: boolean; enable_reflection: boolean; reflection_buffer_activation: number; reflection_block_after: number; scope: "thread" | "resource"; chars_per_token: number; keep_recent_messages: number; estimator?: unknown; } | null
workingMemory?
{ model: unknown; template: string; scope: "thread" | "resource"; update_after_every_turn: boolean; max_chars: number; enable_update_tool: boolean; note_section: string; } | null
memoryRelevanceFilter?
{ model: unknown; min_chars_to_filter: number; filter_observations: boolean; filter_working_memory: boolean; keep_when_empty: boolean; instructions?: string | null; } | null
Configuration for the query-conditioned memory relevance filter. See Maniac.memoryRelevanceFilter.
memoryRelevanceFilterRunner?
MemoryRelevanceFilter | null
Optional pre-built MemoryRelevanceFilter. When
omitted and memoryRelevanceFilter is set, one is auto-
constructed. Pass null to opt out.
backgroundTasks?
BackgroundTasksConfig | null
tracerFactory?
conversationStore?
ConversationStore | null
Optional pre-built ConversationStore. When omitted, one is
constructed from memory (if present). Required by chat /
chatStream.
observationBuffer?
ObservationBuffer | null
Optional pre-built ObservationBuffer. When omitted and both
memory and observationalMemory are provided, one is constructed
automatically using the (auto-built) conversation + observation
stores. Pass null to opt out even when config is supplied.
workingMemoryRunner?
WorkingMemoryRunner | null
Optional pre-built WorkingMemoryRunner. When omitted
and both memory and workingMemory are provided, one is
constructed automatically. Pass null to opt out.
checkpointStore?
RunCheckpointStore | null
Optional pre-built RunCheckpointStore. When omitted
and memory is supplied, one is auto-constructed so
Maniac.resumeCheckpoint works out of the box. Pass
null to opt out even when memory is set.
persistPartialOnError?
boolean
See Maniac.persistPartialOnError.
Returns
Properties
model?
optionalmodel?:Model|null
Defined in: src/agents/app.ts:109
policy?
optionalpolicy?:PermissionPolicy|null
Defined in: src/agents/app.ts:110
memory?
optionalmemory?:Memory|null
Defined in: src/agents/app.ts:111
budget?
optionalbudget?: {max_iterations:number;max_tokens?:number|null;max_cost_usd?:number|null;max_wall_seconds?:number|null; } |null
Defined in: src/agents/app.ts:112
observationalMemory?
optionalobservationalMemory?: {model:unknown;reflection_model?:unknown;message_chars:number;observation_chars:number;buffer_fraction:number;activation_fraction:number;block_after:number;activate_after_idle?:number|null;activate_on_provider_change:boolean;enable_reflection:boolean;reflection_buffer_activation:number;reflection_block_after:number;scope:"thread"|"resource";chars_per_token:number;keep_recent_messages:number;estimator?:unknown; } |null
Defined in: src/agents/app.ts:113
Union Members
Type Literal
{ model: unknown; reflection_model?: unknown; message_chars: number; observation_chars: number; buffer_fraction: number; activation_fraction: number; block_after: number; activate_after_idle?: number | null; activate_on_provider_change: boolean; enable_reflection: boolean; reflection_buffer_activation: number; reflection_block_after: number; scope: "thread" | "resource"; chars_per_token: number; keep_recent_messages: number; estimator?: unknown; }
model
model:
unknown
reflection_model?
optionalreflection_model?:unknown
message_chars
message_chars:
number
observation_chars
observation_chars:
number
buffer_fraction
buffer_fraction:
number
activation_fraction
activation_fraction:
number
block_after
block_after:
number
activate_after_idle?
optionalactivate_after_idle?:number|null
activate_on_provider_change
activate_on_provider_change:
boolean
enable_reflection
enable_reflection:
boolean
reflection_buffer_activation
reflection_buffer_activation:
number
reflection_block_after
reflection_block_after:
number
scope
scope:
"thread"|"resource"
Storage scope for observations and reflections. "thread"
(default) keeps the per-thread namespaces; "resource" is the
Mastra-style cross-thread mode that persists under
agent:<id>/resources/<rid>/observations and splices the
union of every thread's observations for the same resource into
the prefix. Per-thread last_observed_index accounting still
runs under the per-thread state namespace either way. Pass
resourceId on app.chat(...) to populate the namespace; runs
without a resource id fall back to thread-scope behaviour even
when the config opts in.
chars_per_token
chars_per_token:
number
keep_recent_messages
keep_recent_messages:
number
estimator?
optionalestimator?:unknown
Optional TokenEstimator consulted by ObservationBuffer
when computing per-message size. Typed as unknown to mirror the
Python schema's Any field; the buffer feature-detects via
typeof value.estimate === "function".
null
workingMemory?
optionalworkingMemory?: {model:unknown;template:string;scope:"thread"|"resource";update_after_every_turn:boolean;max_chars:number;enable_update_tool:boolean;note_section:string; } |null
Defined in: src/agents/app.ts:114
Union Members
Type Literal
{ model: unknown; template: string; scope: "thread" | "resource"; update_after_every_turn: boolean; max_chars: number; enable_update_tool: boolean; note_section: string; }
model
model:
unknown
Background Model (or provider/slug string resolved by the
inference router) used by the updater. Cheap / fast models are
appropriate; this runs on every chat boundary and never serves
the user directly.
template
template:
string
Markdown template the LM uses as the structural skeleton for the working-memory doc. Empty string means "no template" -- the LM produces a free-form doc.
scope
scope:
"thread"|"resource"
"resource" (default) pools the doc across every thread for
the same resourceId passed on app.chat(...). "thread"
keeps a per-thread doc, useful for ephemeral session-only
profiles.
update_after_every_turn
update_after_every_turn:
boolean
When true (the default) the runner schedules a background
update LM call after every chat turn. Set to false for hand-
managed docs that the application updates directly via
WorkingMemoryStore.save (or proactively via the
remember(note) built-in tool).
max_chars
max_chars:
number
Soft cap on the working-memory doc size, enforced by the updater prompt. Defaults to 4000 characters.
enable_update_tool
enable_update_tool:
boolean
When true (the default) and this config is wired into a
Maniac app, the built-in remember(note) tool is auto-
injected into every agent so the agent can proactively
persist user-flagged facts mid-turn (for example when the
user says "please remember to always cite your sources").
Set false for hand-managed docs that only the reflective
post-turn updater (or direct WorkingMemoryStore.save
calls) should touch.
note_section
note_section:
string
Markdown section header under which remember(note) appends
new bullets. The tool creates the section as a
## <note_section> heading on the first call if it doesn't
already exist in the doc.
null
memoryRelevanceFilterConfig?
optionalmemoryRelevanceFilterConfig?: {model:unknown;min_chars_to_filter:number;filter_observations:boolean;filter_working_memory:boolean;keep_when_empty:boolean;instructions?:string|null; } |null
Defined in: src/agents/app.ts:127
Optional configuration for the query-conditioned memory relevance
filter. When set, a small LM pass runs ahead of every chat turn
that carries a non-trivial memory prefix; the pass takes the new
user message plus the spliced observation / reflection / working-
memory blocks and rewrites the prefix to keep only the blocks
relevant to the query. The raw conversation history tail is
never filtered. Wired as a flag-style config (no agentAsTool
ergonomics required); fail-open on LM errors.
Mirrors Python Maniac(memory_relevance_filter=...).
Union Members
Type Literal
{ model: unknown; min_chars_to_filter: number; filter_observations: boolean; filter_working_memory: boolean; keep_when_empty: boolean; instructions?: string | null; }
model
model:
unknown
Background Model (or provider/slug string resolved via the
inference router) used to score relevance. Cheap / fast models
are the right choice: the filter runs on every chat turn that
carries a non-trivial memory prefix and never serves the user
directly. Required.
min_chars_to_filter
min_chars_to_filter:
number
Skip the filter entirely when the candidate memory prefix is
smaller than this many characters. Short prefixes are cheap to
ship verbatim and the extra LM round-trip costs more than the
savings. Set to 0 to filter unconditionally.
filter_observations
filter_observations:
boolean
When true (the default) the filter considers active observation
and reflection blocks as filterable candidates. Set false to
leave the observation tier intact.
filter_working_memory
filter_working_memory:
boolean
When true (the default) the filter splits the working-memory
doc on ## markdown headers and considers each section as a
filterable candidate. Set false to leave the doc intact.
keep_when_empty
keep_when_empty:
boolean
Behaviour when the LM votes to drop every candidate. When true
(the default) the original unfiltered prefix is preserved -- the
filter assumes a wholesale-drop verdict is more often a parsing
glitch than a true "nothing here matters" signal. Set false to
trust the LM and ship a memory-free prefix.
instructions?
optionalinstructions?:string|null
Optional override of the system prompt used by the filter LM. The default prompt asks the model to keep blocks that are directly relevant or that carry persistent facts (user identity, preferences, standing instructions).
null
backgroundTasks?
optionalbackgroundTasks?:BackgroundTasksConfig|null
Defined in: src/agents/app.ts:137
App-level background-task scheduler config. When set with
enabled: true, an internal BackgroundTaskDispatcher is
constructed lazily on first use and exposed via
Maniac.dispatcher; Maniac.runUntilIdle /
Maniac.runStreamUntilIdle drive the dispatcher.
Mirrors Python Maniac(background_tasks=...).
tracerFactory
tracerFactory:
TracerFactory
Defined in: src/agents/app.ts:138
conversationStore
readonlyconversationStore:ConversationStore|null
Defined in: src/agents/app.ts:147
Conversation store used by chat/chatStream. Auto-built
from memory when neither explicitly provided. May be null when
the app has no memory -- in that case the chat APIs throw.
observationStore
readonlyobservationStore:ObservationStore|null
Defined in: src/agents/app.ts:153
Observation store backing the optional observationBuffer.
Always present when both memory and observationalMemory were
supplied; otherwise null.
observationBuffer
readonlyobservationBuffer:ObservationBuffer|null
Defined in: src/agents/app.ts:159
Background observational-memory orchestrator. Auto-built when both
memory and observationalMemory are supplied. Owned by this app:
call aclose on shutdown to drain pending background tasks.
workingMemoryStore
readonlyworkingMemoryStore:WorkingMemoryStore|null
Defined in: src/agents/app.ts:165
Working-memory store for the singleton mutable doc the agent
carries across turns. Always present when memory and
workingMemory are both supplied; otherwise null.
checkpointStore
readonlycheckpointStore:RunCheckpointStore|null
Defined in: src/agents/app.ts:173
Tier 3 #14: optional persistent checkpoint store. Auto-built
from memory when neither explicitly provided so
Maniac.resumeCheckpoint works out of the box. Pass
null to opt out even when memory is set; pass a pre-built
instance to share a store across multiple Maniac apps.
workingMemoryRunner
readonlyworkingMemoryRunner:WorkingMemoryRunner|null
Defined in: src/agents/app.ts:179
Background working-memory updater. Auto-built when memory
and workingMemory are both supplied. Owned by this app:
call aclose on shutdown to drain the pending updater.
memoryRelevanceFilter
readonlymemoryRelevanceFilter:MemoryRelevanceFilter|null
Defined in: src/agents/app.ts:186
Query-conditioned memory relevance filter. Auto-built when
memoryRelevanceFilter is supplied. The filter is fail-open
(it logs and returns the input unchanged on any error) so
wiring it in is safe even when the filter LM is flaky.
persistPartialOnError
readonlypersistPartialOnError:boolean
Defined in: src/agents/app.ts:208
When true (the default), Maniac.chat / Maniac.chatStream
persist the partial transcript to the configured
ConversationStore for runs that finished with
status='errored' or were aborted mid-turn by a thrown
RunInterruptedError (LM provider crash, sub-agent throw,
etc.) or RunCancelledError (cooperative cancel via the
caller-supplied AbortSignal). The persisted turn is sealed
so any unanswered tool_call.id from the last assistant
message gets a synthetic
{ok: false, error: "tool call interrupted before completion"}
observation, keeping the next request well-formed for native
tool-calling providers. Set to false to restore the v0.2
behaviour where errored / interrupted runs were silently
dropped from the thread.
Reflectors (ObservationBuffer.afterTurn,
WorkingMemoryRunner.afterTurn) always stay gated on
status='completed' -- they summarize a finished exchange
and would record inaccurate notes against a partial.
Accessors
dispatcher
Get Signature
get dispatcher():
BackgroundTaskDispatcher|null
Defined in: src/agents/app.ts:1079
Lazily-constructed background-task scheduler bound to
Maniac.backgroundTasks. Returns null when no
backgroundTasks config was supplied to the constructor.
Mirrors Python Maniac.background_task_manager.
Returns
BackgroundTaskDispatcher | null
Methods
register()
register(
spec):void
Defined in: src/agents/app.ts:389
Parameters
spec
Returns
void
agent()
agent(
spec):Agent
Defined in: src/agents/app.ts:396
Parameters
spec
Omit<Agent, "model"> & object
Returns
get()
get(
agentId):Agent
Defined in: src/agents/app.ts:409
Parameters
agentId
string
Returns
run()
run<
T>(agentId,query,options?):Promise<AgentResult<T>>
Defined in: src/agents/app.ts:417
Type Parameters
T
T = string
Parameters
agentId
string
query
string
options?
Omit<RunOptions, "tracer"> & object = {}
Returns
Promise<AgentResult<T>>
runStream()
runStream<
T>(agentId,query,options?):AsyncGenerator<StreamEnvelope<T>,void,undefined>
Defined in: src/agents/app.ts:429
Type Parameters
T
T = string
Parameters
agentId
string
query
string
options?
Omit<RunOptions, "tracer"> & object = {}
Returns
AsyncGenerator<StreamEnvelope<T>, void, undefined>
chat()
chat<
T>(agentId,message,options):Promise<AgentResult<T>>
Defined in: src/agents/app.ts:461
Thread-aware chat entry point. Mirrors Python Maniac.chat.
Runs one agent turn while owning the conversation thread:
- Loads the spliced prefix via ObservationBuffer.loadThread (or ConversationStore.loadThread when no buffer is configured).
- Binds a ChatTurnContext so runReplAgent can inject
an
observationsproxy into REPL cells. - Runs the agent through runAgent.
- Persists the new turn (user message + every newly-generated message) via ConversationStore.saveTurn.
- Calls ObservationBuffer.afterTurn to advance state and schedule background observer/reflector tasks.
options.threadId is required; it scopes every memory namespace.
Throws when the app has no conversationStore (which requires
memory to have been supplied to the constructor).
Type Parameters
T
T = string
Parameters
agentId
string
message
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]
options
Returns
Promise<AgentResult<T>>
chatStream()
chatStream<
T>(agentId,message,options):AsyncGenerator<StreamEnvelope<T>,void,undefined>
Defined in: src/agents/app.ts:616
Streaming twin of chat. Yields the same StreamEnvelope
sequence as runAgentStream (every trace event followed by a
terminal { type: "result" } envelope). Conversation persistence
and afterTurn run after the terminal envelope is produced,
matching Python Maniac.chat_stream.
Type Parameters
T
T = string
Parameters
agentId
string
message
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]
options
Returns
AsyncGenerator<StreamEnvelope<T>, void, undefined>
resume()
resume<
T>(agentId,checkpoint,responses,options?):Promise<AgentResult<T>>
Defined in: src/agents/app.ts:823
Type Parameters
T
T = string
Parameters
agentId
string
checkpoint
schema_version
1 | 2 = ...
spec_id
string = ...
iteration
number = ...
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
root_messages
object[] = ...
subagent_sessions
object[] = ...
pending
object[] = ...
checkpoint_id?
string | null = ...
responses
object[]
options?
Omit<RunOptions, "tracer"> & object = {}
Returns
Promise<AgentResult<T>>
resumeStream()
resumeStream<
T>(agentId,checkpoint,responses,options?):AsyncGenerator<StreamEnvelope<T>,void,undefined>
Defined in: src/agents/app.ts:857
Streaming twin of Maniac.resume. Yields StreamEnvelopes
for every trace event of the resumed run followed by the terminal
{ type: "result" } envelope. When the resumed run completes and
threadId is set, afterTurn runs once after the terminal
envelope, matching resume.
Type Parameters
T
T = string
Parameters
agentId
string
checkpoint
schema_version
1 | 2 = ...
spec_id
string = ...
iteration
number = ...
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
root_messages
object[] = ...
subagent_sessions
object[] = ...
pending
object[] = ...
checkpoint_id?
string | null = ...
responses
object[]
options?
Omit<RunOptions, "tracer"> & object = {}
Returns
AsyncGenerator<StreamEnvelope<T>, void, undefined>
resumeCheckpoint()
resumeCheckpoint<
T>(agentId,checkpointId,responses,options?):Promise<AgentResult<T>>
Defined in: src/agents/app.ts:908
Tier 3 #14: resume a paused run via its durable checkpoint id.
Looks the checkpoint up in either the agent or thread namespace
(when threadId is supplied), hands the rehydrated payload to
Maniac.resume, and marks the stored record as resolved
when the run completes successfully. Throws when no
checkpointStore is configured (pass memory or an
explicit checkpointStore to the constructor).
Idempotency: each resume goes through a compare-and-swap
RunCheckpointStore.claim that transitions the record from
pending → resolving before the run starts. A second concurrent
call (or a retry after the first one completes) sees the record
in resolving / resolved and throws CheckpointNotPendingError
instead of re-executing the approved tool. Callers (e.g. the
channels webhook handler) should treat that error as "someone
else already handled this" and surface a no-op response.
Type Parameters
T
T = string
Parameters
agentId
string
checkpointId
string
responses
object[]
options?
Omit<RunOptions, "tracer"> & object = {}
Returns
Promise<AgentResult<T>>
resumeCheckpointStream()
resumeCheckpointStream<
T>(agentId,checkpointId,responses,options?):AsyncGenerator<StreamEnvelope<T>,void,undefined>
Defined in: src/agents/app.ts:946
Streaming twin of Maniac.resumeCheckpoint. Yields the
same StreamEnvelope sequence as resumeStream,
including the new { type: "paused" } variant before any
terminal { type: "result", result.status === "paused" } if the
resume re-pauses. Same compare-and-swap claim semantics as
resumeCheckpoint: throws CheckpointNotPendingError
(before yielding any envelopes) when the record is not pending.
Type Parameters
T
T = string
Parameters
agentId
string
checkpointId
string
responses
object[]
options?
Omit<RunOptions, "tracer"> & object = {}
Returns
AsyncGenerator<StreamEnvelope<T>, void, undefined>
listPendingCheckpoints()
listPendingCheckpoints(
agentId,options?):Promise<StoredCheckpoint[]>
Defined in: src/agents/app.ts:998
List unresolved checkpoints for an agent (and optional thread). Convenience over RunCheckpointStore.listPending.
Parameters
agentId
string
options?
threadId?
string | null
maxRecords?
number
Returns
Promise<StoredCheckpoint[]>
enqueueBackground()
enqueueBackground(
agentId,prompt,options?):object
Defined in: src/agents/app.ts:1094
Enqueue a background agent run. Returns the queued task record synchronously; the run begins as soon as a slot is free under the dispatcher's concurrency caps.
Throws when no backgroundTasks config was supplied or the
config has enabled: false.
Parameters
agentId
string
prompt
string
options?
Omit<BackgroundTaskInput, "spec" | "prompt"> = {}
Returns
object
id
id:
string
task_id
task_id:
string
agent_id
agent_id:
string
thread_id
thread_id:
string
tool_call_id
tool_call_id:
string
tool_name
tool_name:
string
toolset?
optionaltoolset?:string|null
args
args:
JsonDict
status
status:
"queued"|"running"|"completed"|"failed"|"cancelled"
enqueued_at
enqueued_at:
string
started_at?
optionalstarted_at?:string|null
finished_at?
optionalfinished_at?:string|null
ack_value?
optionalack_value?:unknown
result?
optionalresult?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null
Union Members
Type Literal
{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }
ok
ok:
boolean
value?
optionalvalue?:unknown
error?
optionalerror?:string|null
metadata
metadata:
Record<string,unknown>
cause?
optionalcause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null
Optional structured cause for failed results. Populated by the tool()
helper (and any adapter that wants to preserve thrown error context),
so consumers can distinguish validation vs. runtime failures and read
the original error name/stack without the public ok: false
discriminator changing shape.
null
retries
retries:
number
error?
optionalerror?:string|null
runUntilIdle()
runUntilIdle(
agentId?,prompt?,options?):Promise<void>
Defined in: src/agents/app.ts:1118
Block until every background task already enqueued has
terminated. When agentId and prompt are supplied, also
enqueues a fresh task before draining (mirrors Python
Maniac.run_until_idle(agent_id, query)).
Parameters
agentId?
string
prompt?
string
options?
Omit<BackgroundTaskInput, "spec" | "prompt"> = {}
Returns
Promise<void>
runStreamUntilIdle()
runStreamUntilIdle(
agentId?,prompt?,options?):AsyncGenerator<BackgroundStreamItem,void,undefined>
Defined in: src/agents/app.ts:1141
Streaming twin of runUntilIdle. Yields a tagged BackgroundStreamItem for every event emitted by every in-flight background task and for every terminal record. Returns when the dispatcher is idle.
Parameters
agentId?
string
prompt?
string
options?
Omit<BackgroundTaskInput, "spec" | "prompt"> = {}
Returns
AsyncGenerator<BackgroundStreamItem, void, undefined>
aclose()
aclose():
Promise<void>
Defined in: src/agents/app.ts:1164
Drain pending background observational-memory tasks (and the background-task dispatcher, if one was constructed) and refuse new ones. Idempotent. Long-lived programs should call this on shutdown to avoid losing in-flight work.
Returns
Promise<void>
CheckpointNotPendingError
Defined in: src/agents/app.ts:1337
Thrown by Maniac.resumeCheckpoint /
Maniac.resumeCheckpointStream when the targeted checkpoint
is not in the pending state (typically because a sibling resume
has already taken the claim or because the run already finished).
Callers — most notably the channels webhook handler — should treat
this as "the request was a duplicate" and surface a no-op response
instead of failing the HTTP call.
Extends
Error
Constructors
Constructor
new CheckpointNotPendingError(
checkpointId,status):CheckpointNotPendingError
Defined in: src/agents/app.ts:1340
Parameters
checkpointId
string
status
Returns
Overrides
Error.constructor
Properties
checkpointId
readonlycheckpointId:string
Defined in: src/agents/app.ts:1338
status
readonlystatus:CheckpointStatus
Defined in: src/agents/app.ts:1339
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
BackgroundTaskDispatcher
Defined in: src/agents/backgroundTasks.ts:133
Schedules background agent runs with concurrency caps + lifecycle hooks. See module docstring for the full contract.
Constructors
Constructor
new BackgroundTaskDispatcher(
options):BackgroundTaskDispatcher
Defined in: src/agents/backgroundTasks.ts:149
Parameters
options
Returns
Accessors
config
Get Signature
get config():
BackgroundTasksConfig
Defined in: src/agents/backgroundTasks.ts:161
Returns
closed
Get Signature
get closed():
boolean
Defined in: src/agents/backgroundTasks.ts:165
Returns
boolean
store
Get Signature
get store():
BackgroundTaskStore|null
Defined in: src/agents/backgroundTasks.ts:169
Returns
BackgroundTaskStore | null
errors
Get Signature
get errors(): readonly
Error[]
Defined in: src/agents/backgroundTasks.ts:174
Hooks / dispatch errors observed during the lifetime of this dispatcher.
Returns
readonly Error[]
Methods
pendingCount()
pendingCount(
agentId?):number
Defined in: src/agents/backgroundTasks.ts:182
Number of in-flight tasks. With no args, counts globally; with
agentId, narrows to that agent's pending count.
Parameters
agentId?
string
Returns
number
enqueue()
enqueue(
input):object
Defined in: src/agents/backgroundTasks.ts:198
Enqueue a background agent run. Returns the queued task record synchronously. The actual run begins as soon as a slot is free under the dispatcher's concurrency caps.
Throws when the dispatcher is closed or the configured backpressure
policy is reject and the queue is saturated.
Parameters
input
Returns
object
id
id:
string
task_id
task_id:
string
agent_id
agent_id:
string
thread_id
thread_id:
string
tool_call_id
tool_call_id:
string
tool_name
tool_name:
string
toolset?
optionaltoolset?:string|null
args
args:
JsonDict
status
status:
"queued"|"running"|"completed"|"failed"|"cancelled"
enqueued_at
enqueued_at:
string
started_at?
optionalstarted_at?:string|null
finished_at?
optionalfinished_at?:string|null
ack_value?
optionalack_value?:unknown
result?
optionalresult?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null
Union Members
Type Literal
{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }
ok
ok:
boolean
value?
optionalvalue?:unknown
error?
optionalerror?:string|null
metadata
metadata:
Record<string,unknown>
cause?
optionalcause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null
Optional structured cause for failed results. Populated by the tool()
helper (and any adapter that wants to preserve thrown error context),
so consumers can distinguish validation vs. runtime failures and read
the original error name/stack without the public ok: false
discriminator changing shape.
null
retries
retries:
number
error?
optionalerror?:string|null
awaitTask()
awaitTask(
taskId,timeoutMs?):Promise<{id:string;task_id:string;agent_id:string;thread_id:string;tool_call_id:string;tool_name:string;toolset?:string|null;args:JsonDict;status:"queued"|"running"|"completed"|"failed"|"cancelled";enqueued_at:string;started_at?:string|null;finished_at?:string|null;ack_value?:unknown;result?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null;retries:number;error?:string|null; }>
Defined in: src/agents/backgroundTasks.ts:288
Wait for a single task to terminate. Returns the terminal record
(completed / failed / cancelled). Throws when no task with
the given id is known.
timeoutMs (default default_wait_timeout_s from the config)
caps the wait; on timeout the in-flight controller is NOT
aborted and the most recent record is returned.
Parameters
taskId
string
timeoutMs?
number
Returns
Promise<{ id: string; task_id: string; agent_id: string; thread_id: string; tool_call_id: string; tool_name: string; toolset?: string | null; args: JsonDict; status: "queued" | "running" | "completed" | "failed" | "cancelled"; enqueued_at: string; started_at?: string | null; finished_at?: string | null; ack_value?: unknown; result?: { ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null; retries: number; error?: string | null; }>
awaitTasks()
awaitTasks(
taskIds,options?):Promise<Map<string, {id:string;task_id:string;agent_id:string;thread_id:string;tool_call_id:string;tool_name:string;toolset?:string|null;args:JsonDict;status:"queued"|"running"|"completed"|"failed"|"cancelled";enqueued_at:string;started_at?:string|null;finished_at?:string|null;ack_value?:unknown;result?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null;retries:number;error?:string|null; } |null>>
Defined in: src/agents/backgroundTasks.ts:335
Wait on several tasks at once.
mode === "all" blocks until every listed task terminates (or the
overall timeoutMs lapses). mode === "any" returns as soon as
the first listed task terminates; other tasks keep running.
Returns a Map<taskId, BackgroundTaskRecord | null> keyed by every
id passed in. A record's status reflects the latest known state,
so an un-finished task at timeout shows up with its in-flight
status (queued or running). The in-flight tasks are NOT
aborted on timeout — matching awaitTask.
Throws when any id is unknown (neither in-flight nor in the
buffered completions). The Python sibling is
BackgroundAgentRunDispatcher.await_tasks.
Parameters
taskIds
string[]
options?
mode?
"any" | "all"
timeoutMs?
number
Returns
Promise<Map<string, { id: string; task_id: string; agent_id: string; thread_id: string; tool_call_id: string; tool_name: string; toolset?: string | null; args: JsonDict; status: "queued" | "running" | "completed" | "failed" | "cancelled"; enqueued_at: string; started_at?: string | null; finished_at?: string | null; ack_value?: unknown; result?: { ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null; retries: number; error?: string | null; } | null>>
cancelTask()
cancelTask(
taskId,reason?):boolean
Defined in: src/agents/backgroundTasks.ts:426
Cancel the task with the given id. Returns true if a cancel
signal was delivered; false if the task already terminated or
is unknown.
Parameters
taskId
string
reason?
unknown
Returns
boolean
listPending()
listPending():
object[]
Defined in: src/agents/backgroundTasks.ts:435
Snapshot of currently in-flight task records.
Returns
object[]
taskEvents()
taskEvents(
taskId,lastN?): ({ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"token";payload: {[key:string]:unknown;model?:string;scope?:string;iteration?:number;toolset?:string|null;lm_span_id?:string|null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:string|null;raw_finish_reason?:string|null; };delta:string;chunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null;content_part_kind?:"file"|"text"|"image"|null;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call_start";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;toolset?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:string;toolset?:string|null;raw_finish_reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool";payload: {[key:string]:unknown;tool_call_id:string;tool_name:string;toolset?:string|null;phase:"completed"|"failed"|"cancelled"|"started";args?:JsonDict;result?:JsonDict|null;result_preview?: {[key:string]:unknown;ok?:boolean;value?:unknown;error?:string|null;metadata?:JsonDict|null;result_truncated?:boolean;value_omitted_reason?:string|null; } |null;ok?:boolean|null;allowed?:boolean|null;error?:string|null;reason?:string|null;started_at?:string|null;finished_at?:string|null;elapsed_ms?:number|null;decision?: {[key:string]:unknown;allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool_call_arguments_delta";payload: {[key:string]:unknown;tool_call_id?:string|null;tool_name?:string|null;index:number;arguments_delta:string;sequence:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"cell";payload: {[key:string]:unknown;cell_id:string;phase:"completed"|"failed"|"cancelled"|"started";code?:string|null;result?:JsonDict|null;error?:string|null;elapsed_ms?:number|null;stdout_len?:number|null;stderr_len?:number|null;variables?:string[] |null;src?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"subagent";payload: {[key:string]:unknown;phase:"error"|"completed"|"intent"|"start"|"paused"|"errored";agent_id?:string|null;toolset?:string|null;role?:string|null;prompt_summary?:string|null;prompt?:string|null;parent_span_id?:string|null;background?:boolean|null;iterations?:number|null;reason?:string|null;max_depth?:number|null;repl?:boolean|null;usage?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"agent";payload: {[key:string]:unknown;phase:"completed"|"started";agent_id:string;principal?:string|null;iterations?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"approval";payload: {[key:string]:unknown;phase:"requested"|"approved"|"denied"|"resolved";id?:string;toolset?:string|null;tool?:string|null;rule_id?:string|null;reason?:string|null;source:"guardrail"|"policy";decision?:"approve"|"deny"|null;approvals:object[]; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"memory";payload: {[key:string]:unknown;op:string;phase?:string|null;principal?:string|null;depth?:number|null;summary?:string|null;namespace?:string|null;agent_id?:string|null;thread_id?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"guardrail";payload: {[key:string]:unknown;phase:string;boundary?:string|null;action?:string|null;decision?:string|null;rule_id?:string|null;reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"background_task";payload: {[key:string]:unknown;phase:string;task_id:string;status?:string|null;progress?:number|null;output?:JsonDict|null;agent_id?:string|null;sub_agent_id?:string|null;tool?:string|null;attempt?:number|null;error?:string|null;iterations?:number|null;timeout_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"step";payload: {[key:string]:unknown;phase:"before"|"after"|"repair"|"stopped"|"finalize_vetoed";turn_index:number;iteration?:number|null;source?:string|null;reason?:string|null;elapsed_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"retry";payload: {[key:string]:unknown;attempt:number;reason:string;model?:string|null;max_attempts?:number|null;delay_s?:number|null;fallback?:boolean|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"final";payload: {[key:string]:unknown;source:string;iterations?:number|null;validated?:boolean|null;error?:string|null;pending?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"error";payload: {[key:string]:unknown;message:string;kind_of_error?:string|null;cause?:string|null;retryable?:boolean|null;reason?:string|null;detail?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"stream_gap";payload: {[key:string]:unknown;dropped_count_so_far:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"plan";payload: {[key:string]:unknown;entries:object[]; }; })[]
Defined in: src/agents/backgroundTasks.ts:449
Snapshot of the last lastN events from a task's dedicated
tracer. Used by the built-in bg_check tool to surface recent
activity from a running background subagent. Returns an empty
array when the task id is unknown.
lastN is clamped to [1, 256] so a misbehaving caller can't
pin unbounded memory by requesting the entire event log of a
long-running task.
Parameters
taskId
string
lastN?
number = 5
Returns
nextCompletion()
nextCompletion(
timeoutMs?):Promise<{id:string;task_id:string;agent_id:string;thread_id:string;tool_call_id:string;tool_name:string;toolset?:string|null;args:JsonDict;status:"queued"|"running"|"completed"|"failed"|"cancelled";enqueued_at:string;started_at?:string|null;finished_at?:string|null;ack_value?:unknown;result?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null;retries:number;error?:string|null; } |null>
Defined in: src/agents/backgroundTasks.ts:465
Pop the next terminal task record. Mirrors Python
BackgroundTaskManager.next_completion. Resolves immediately if
a completion is already buffered; otherwise waits for the next
one. timeoutMs returns null on lapse without delivering a
record.
Parameters
timeoutMs?
number
Returns
Promise<{ id: string; task_id: string; agent_id: string; thread_id: string; tool_call_id: string; tool_name: string; toolset?: string | null; args: JsonDict; status: "queued" | "running" | "completed" | "failed" | "cancelled"; enqueued_at: string; started_at?: string | null; finished_at?: string | null; ack_value?: unknown; result?: { ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null; retries: number; error?: string | null; } | null>
runUntilIdle()
runUntilIdle():
Promise<void>
Defined in: src/agents/backgroundTasks.ts:500
Block until every currently-pending task has terminated. Tasks enqueued during the await are also included.
Mirrors Python BackgroundTaskManager.wait_idle. Safe to call
multiple times.
Returns
Promise<void>
runStreamUntilIdle()
runStreamUntilIdle():
AsyncGenerator<BackgroundStreamItem,void,undefined>
Defined in: src/agents/backgroundTasks.ts:516
Stream every task's trace events through one merged tracer.
Yields a tagged BackgroundStreamItem for every event emitted by every in-flight task and for every terminal record. Returns when the dispatcher is idle.
Tasks enqueued during iteration are picked up automatically.
Returns
AsyncGenerator<BackgroundStreamItem, void, undefined>
subscribeStream()
subscribeStream(
listener): () =>void
Defined in: src/agents/backgroundTasks.ts:583
Subscribe to the merged stream of every task's events + terminal records for as long as the returned unsubscribe function is not called.
Unlike runStreamUntilIdle, this does NOT auto-complete when the dispatcher goes idle: the subscriber stays attached across idle gaps, so tasks enqueued later in the same logical batch (e.g. an orchestrator turn that spawns children one at a time) are delivered without the caller re-subscribing — and therefore without a busy-poll loop. The listener owns its own lifecycle: it keeps receiving items until it calls the returned unsubscribe function.
Delivery is push-based and synchronous from enqueue's event pipe and from task completion, so there is no polling latency. A throwing listener is captured on errors and the subscription stays live (mirrors runStreamUntilIdle).
On subscribe, the listener is seeded with a snapshot of every event already emitted by every in-flight task so a late subscriber does not miss the early progress of an already-running task.
Parameters
listener
(item) => void
Returns
() => void
aclose()
aclose(
reason?):Promise<void>
Defined in: src/agents/backgroundTasks.ts:631
Cancel pending tasks and refuse new ones. Workers receive a
cancellation reason via their AbortSignal and report a
cancelled record. Use runUntilIdle when you want to
wait for natural completion instead.
Idempotent.
Parameters
reason?
unknown
Returns
Promise<void>
LMSummarizingCompactor
Defined in: src/agents/compaction.ts:141
LM-summarizing transcript compactor.
The TypeScript port of Python's LMSummarizingCompactor (see
agents/compaction.py). Where the Python class plugs into the
step-hook protocol, this class exposes a single compact(messages)
method so callers can drive compaction from a runner extension or
an explicit pre-iteration hook of their choosing.
Behaviour mirrors Python:
- Preserves the system prompt (
messages[0]) and the original user task (messages[1]) so the agent keeps its grounding. - Preserves the trailing
keepRecentmessages so the agent has fresh local context for the next turn. - Folds the middle of the transcript into a single replacement
message (
role: "user") prefixed withsummaryHeader. - Refuses to split an assistant→tool pair across the head/tail
boundary by walking the tail boundary back over leading
role: "tool"messages (see safeTailStart). - On any summarization failure (provider error, empty response) the compactor returns the input transcript unchanged — a flaky summarizer must never corrupt the run.
Constructors
Constructor
new LMSummarizingCompactor(
options):LMSummarizingCompactor
Defined in: src/agents/compaction.ts:149
Parameters
options
Returns
Methods
compact()
compact(
messages):Promise<object[]>
Defined in: src/agents/compaction.ts:169
Parameters
messages
readonly object[]
Returns
Promise<object[]>
BaseStepHook
Defined in: src/agents/hooks.ts:44
No-op base for StepHook. Subclasses override only the
methods they need; the rest stay as pass-throughs. Mirrors Python
agents.hooks.BaseStepHook.
Extended by
Implements
Constructors
Constructor
new BaseStepHook():
BaseStepHook
Returns
Methods
beforeStep()
beforeStep(
_ctx):Promise<StepDecision|null|undefined>
Defined in: src/agents/hooks.ts:45
Parameters
_ctx
Returns
Promise<StepDecision | null | undefined>
Implementation of
beforeFinalize()
beforeFinalize(
_ctx,_resp):Promise<Continuation|null|undefined>
Defined in: src/agents/hooks.ts:49
Parameters
_ctx
_resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
Returns
Promise<Continuation | null | undefined>
Implementation of
shouldStop()
shouldStop(
_ctx,_resp,_cell):Promise<boolean>
Defined in: src/agents/hooks.ts:56
Parameters
_ctx
_resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
_cell
JsonDict | null
Returns
Promise<boolean>
Implementation of
afterStep()
afterStep(
_ctx,_resp,_cell):Promise<void>
Defined in: src/agents/hooks.ts:64
Parameters
_ctx
_resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
_cell
JsonDict | null
Returns
Promise<void>
Implementation of
CallableStepHook
Defined in: src/agents/hooks.ts:83
Adapter wrapping prepare_step / stop_when constructor sugar into
a real StepHook. Used by the runner's spec-normalization
step to translate the flat-callable sugar form into a synthesized
hook so the composition runners only deal with one shape. Either
argument may be null/undefined, in which case the corresponding
lifecycle method is a pass-through.
Mirrors Python agents.hooks._CallableStepHook.
Extends
Constructors
Constructor
new CallableStepHook(
options?):CallableStepHook
Defined in: src/agents/hooks.ts:87
Parameters
options?
prepare?
PrepareStep | null
stop?
StopWhen | null
Returns
Overrides
Methods
beforeFinalize()
beforeFinalize(
_ctx,_resp):Promise<Continuation|null|undefined>
Defined in: src/agents/hooks.ts:49
Parameters
_ctx
_resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
Returns
Promise<Continuation | null | undefined>
Inherited from
afterStep()
afterStep(
_ctx,_resp,_cell):Promise<void>
Defined in: src/agents/hooks.ts:64
Parameters
_ctx
_resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
_cell
JsonDict | null
Returns
Promise<void>
Inherited from
beforeStep()
beforeStep(
ctx):Promise<StepDecision|null|undefined>
Defined in: src/agents/hooks.ts:93
Parameters
ctx
Returns
Promise<StepDecision | null | undefined>
Overrides
shouldStop()
shouldStop(
ctx,resp,_cell):Promise<boolean>
Defined in: src/agents/hooks.ts:109
Parameters
ctx
resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
_cell
JsonDict | null
Returns
Promise<boolean>
Overrides
MemoryRelevanceFilter
Defined in: src/agents/memoryFilter.ts:485
Owns the per-turn relevance filter for one Maniac instance.
Construct with a MemoryRelevanceFilterConfig and call filterPrefix once per chat turn after the prefix has been loaded from the conversation store / observation buffer / working- memory store.
Constructors
Constructor
new MemoryRelevanceFilter(
options):MemoryRelevanceFilter
Defined in: src/agents/memoryFilter.ts:489
Parameters
options
Returns
Properties
config
readonlyconfig:object
Defined in: src/agents/memoryFilter.ts:486
model
model:
unknown
Background Model (or provider/slug string resolved via the
inference router) used to score relevance. Cheap / fast models
are the right choice: the filter runs on every chat turn that
carries a non-trivial memory prefix and never serves the user
directly. Required.
min_chars_to_filter
min_chars_to_filter:
number
Skip the filter entirely when the candidate memory prefix is
smaller than this many characters. Short prefixes are cheap to
ship verbatim and the extra LM round-trip costs more than the
savings. Set to 0 to filter unconditionally.
filter_observations
filter_observations:
boolean
When true (the default) the filter considers active observation
and reflection blocks as filterable candidates. Set false to
leave the observation tier intact.
filter_working_memory
filter_working_memory:
boolean
When true (the default) the filter splits the working-memory
doc on ## markdown headers and considers each section as a
filterable candidate. Set false to leave the doc intact.
keep_when_empty
keep_when_empty:
boolean
Behaviour when the LM votes to drop every candidate. When true
(the default) the original unfiltered prefix is preserved -- the
filter assumes a wholesale-drop verdict is more often a parsing
glitch than a true "nothing here matters" signal. Set false to
trust the LM and ship a memory-free prefix.
instructions?
optionalinstructions?:string|null
Optional override of the system prompt used by the filter LM. The default prompt asks the model to keep blocks that are directly relevant or that carry persistent facts (user identity, preferences, standing instructions).
Accessors
closed
Get Signature
get closed():
boolean
Defined in: src/agents/memoryFilter.ts:493
Returns
boolean
Methods
filterPrefix()
filterPrefix(
query,prefix,options?):Promise<object[]>
Defined in: src/agents/memoryFilter.ts:515
Return a filtered copy of prefix for the new query.
Behaviour:
- When the prefix carries no filterable memory blocks at all, the input is returned verbatim (no LM call).
- Tiers the config opted out of filtering skip the candidate list entirely; their blocks survive intact.
- When the total candidate body is below
minCharsToFilterthe LM call is skipped and the input is returned verbatim. - LM errors, parse errors, and empty responses surface as a
memory_filter_errortrace event and the unfiltered prefix is returned. The filter is fail-open. - When the LM votes to keep every candidate the original prefix is returned verbatim (fast path).
Parameters
query
string
prefix
object[]
options?
agentId?
string
threadId?
string
resourceId?
string | null
tracer?
Tracer | null
onComplete?
(summary) => void
Optional per-turn callback delivering the full kept/dropped
block metadata for this filter pass. Fires exactly once per
filterPrefix call whenever the prefix carries memory blocks
(including the short-circuit / verbatim cases). Decoupled from
the tracer memory_filter_complete event so hosts can render a
"reading memory" row even when the filter never reaches the LM.
Returns
Promise<object[]>
aclose()
aclose():
Promise<void>
Defined in: src/agents/memoryFilter.ts:665
Mark the runner closed so future calls return the input unchanged. The filter holds no background tasks (the LM call is awaited inline), so close is mostly bookkeeping for symmetry with WorkingMemoryRunner and ObservationBuffer.
Returns
Promise<void>
ObservationBuffer
Defined in: src/agents/observationalMemory/buffer.ts:145
Constructors
Constructor
new ObservationBuffer(
options):ObservationBuffer
Defined in: src/agents/observationalMemory/buffer.ts:162
Parameters
options
Returns
Accessors
config
Get Signature
get config():
object
Defined in: src/agents/observationalMemory/buffer.ts:170
Returns
model
model:
unknown
reflection_model?
optionalreflection_model?:unknown
message_chars
message_chars:
number
observation_chars
observation_chars:
number
buffer_fraction
buffer_fraction:
number
activation_fraction
activation_fraction:
number
block_after
block_after:
number
activate_after_idle?
optionalactivate_after_idle?:number|null
activate_on_provider_change
activate_on_provider_change:
boolean
enable_reflection
enable_reflection:
boolean
reflection_buffer_activation
reflection_buffer_activation:
number
reflection_block_after
reflection_block_after:
number
scope
scope:
"thread"|"resource"
Storage scope for observations and reflections. "thread"
(default) keeps the per-thread namespaces; "resource" is the
Mastra-style cross-thread mode that persists under
agent:<id>/resources/<rid>/observations and splices the
union of every thread's observations for the same resource into
the prefix. Per-thread last_observed_index accounting still
runs under the per-thread state namespace either way. Pass
resourceId on app.chat(...) to populate the namespace; runs
without a resource id fall back to thread-scope behaviour even
when the config opts in.
chars_per_token
chars_per_token:
number
keep_recent_messages
keep_recent_messages:
number
estimator?
optionalestimator?:unknown
Optional TokenEstimator consulted by ObservationBuffer
when computing per-message size. Typed as unknown to mirror the
Python schema's Any field; the buffer feature-detects via
typeof value.estimate === "function".
closed
Get Signature
get closed():
boolean
Defined in: src/agents/observationalMemory/buffer.ts:174
Returns
boolean
conversationStore
Get Signature
get conversationStore():
ConversationStore
Defined in: src/agents/observationalMemory/buffer.ts:178
Returns
observationStore
Get Signature
get observationStore():
ObservationStore
Defined in: src/agents/observationalMemory/buffer.ts:182
Returns
Methods
loadThread()
loadThread(
agentId,threadId,options?):Promise<object[]>
Defined in: src/agents/observationalMemory/buffer.ts:206
Return the spliced prefix for the next chat turn.
Loads the raw message history, then decides whether buffered
observations should activate or whether a synchronous Observer
run is needed (block_after). Returns:
[<reflection summary message>?, <active observations message>?, <recent raw messages (tail)>]
Reflection / observation summaries are user-role messages with sentinel headers so the model treats them as synopses.
Always returns a fresh list; mutating the result is safe.
Parameters
agentId
string
threadId
string
options?
spec?
Agent | null
resourceId?
string | null
tracer?
Tracer | null
Returns
Promise<object[]>
afterTurn()
afterTurn(
agentId,threadId,options?):Promise<void>
Defined in: src/agents/observationalMemory/buffer.ts:293
Update the rolling state and schedule buffered work.
Call once ConversationStore.saveTurn has returned (in
Maniac.chat and Maniac.chatStream). Bumps last_activity_ts
/ last_provider_model, then schedules a background Observer task
when the unobserved tail exceeds the buffer fraction of
message_chars.
Parameters
agentId
string
threadId
string
options?
spec?
Agent | null
resourceId?
string | null
tracer?
Tracer | null
Returns
Promise<void>
aclose()
aclose():
Promise<void>
Defined in: src/agents/observationalMemory/buffer.ts:357
Drain pending background tasks and refuse new ones.
Returns
Promise<void>
waitIdle()
waitIdle():
Promise<void>
Defined in: src/agents/observationalMemory/buffer.ts:371
Await every currently-pending background task without closing. Useful in tests that want to assert on completed buffered observations without tearing down the buffer.
Returns
Promise<void>
effectiveResourceId()
effectiveResourceId(
resourceId):string|null
Defined in: src/agents/observationalMemory/buffer.ts:1023
Return the resource id only when resource scope is active.
The buffer ignores resourceId entirely under thread scope, so
callers can always pass it through (matching the ergonomics of
app.chat(..., resourceId) regardless of the configured OM
scope). Public so the ObservationsProxy can normalise its
own scope decision the same way the buffer does.
Parameters
resourceId
string | null | undefined
Returns
string | null
ObservationsProxy
Defined in: src/agents/observationalMemory/proxy.ts:61
Thread-bound read-only view of the buffer for one chat turn.
Under resource scope current() / buffered() / reflections()
resolve from the cross-thread resource pool; state() and
recent() are intentionally always per-thread because they are
bound to the current chat's flat message history.
Constructors
Constructor
new ObservationsProxy(
options):ObservationsProxy
Defined in: src/agents/observationalMemory/proxy.ts:67
Parameters
options
Returns
Methods
current()
current():
Promise<object[]>
Defined in: src/agents/observationalMemory/proxy.ts:74
Returns
Promise<object[]>
buffered()
buffered():
Promise<object[]>
Defined in: src/agents/observationalMemory/proxy.ts:81
Returns
Promise<object[]>
reflections()
reflections():
Promise<object[]>
Defined in: src/agents/observationalMemory/proxy.ts:88
Returns
Promise<object[]>
state()
state():
Promise<{last_observed_index:number;in_flight_index:number;current_task?:string|null;suggested_response?:string|null;last_provider_model:string;last_activity_ts:string; }>
Defined in: src/agents/observationalMemory/proxy.ts:95
Returns
Promise<{ last_observed_index: number; in_flight_index: number; current_task?: string | null; suggested_response?: string | null; last_provider_model: string; last_activity_ts: string; }>
recent()
recent():
Promise<object[]>
Defined in: src/agents/observationalMemory/proxy.ts:99
Returns
Promise<object[]>
recall()
recall(
text,options?):Promise<object[]>
Defined in: src/agents/observationalMemory/proxy.ts:120
Free-text search over observation chunks for this scope.
Routes through the configured Memory adapter's search
method. With substring-only adapters this is a case-
insensitive LIKE; wire in VectorMemory for semantic
recall (kNN over an embedding of each chunk's text).
Resource-scope-aware: when the buffer's config opted into
resource scope and resourceId was supplied to
app.chat(...), the search is over the cross-thread resource
pool, so the model can answer "what did the user say about X?"
across every session for the same person.
Parameters
text
string
options?
k?
number
Returns
Promise<object[]>
recallReflections()
recallReflections(
text,options?):Promise<object[]>
Defined in: src/agents/observationalMemory/proxy.ts:136
Free-text search over reflection chunks for this scope. See recall for adapter semantics. Reflections are typically denser summaries of long-running threads, so this is the right surface when the model wants a high-level "remind me what we've been working on" rather than a chunk-level lookup.
Parameters
text
string
options?
k?
number
Returns
Promise<object[]>
WorkingMemoryRunner
Defined in: src/agents/observationalMemory/workingMemory.ts:166
Owns the working-memory updater for one Maniac instance.
Indexed by (agent_id, scope_key) -- under thread scope the
scope key is thread_id; under resource scope it's
resource_id so two threads for the same user serialise their
updates.
Constructors
Constructor
new WorkingMemoryRunner(
options):WorkingMemoryRunner
Defined in: src/agents/observationalMemory/workingMemory.ts:173
Parameters
options
Returns
Accessors
config
Get Signature
get config():
object
Defined in: src/agents/observationalMemory/workingMemory.ts:178
Returns
model
model:
unknown
Background Model (or provider/slug string resolved by the
inference router) used by the updater. Cheap / fast models are
appropriate; this runs on every chat boundary and never serves
the user directly.
template
template:
string
Markdown template the LM uses as the structural skeleton for the working-memory doc. Empty string means "no template" -- the LM produces a free-form doc.
scope
scope:
"thread"|"resource"
"resource" (default) pools the doc across every thread for
the same resourceId passed on app.chat(...). "thread"
keeps a per-thread doc, useful for ephemeral session-only
profiles.
update_after_every_turn
update_after_every_turn:
boolean
When true (the default) the runner schedules a background
update LM call after every chat turn. Set to false for hand-
managed docs that the application updates directly via
WorkingMemoryStore.save (or proactively via the
remember(note) built-in tool).
max_chars
max_chars:
number
Soft cap on the working-memory doc size, enforced by the updater prompt. Defaults to 4000 characters.
enable_update_tool
enable_update_tool:
boolean
When true (the default) and this config is wired into a
Maniac app, the built-in remember(note) tool is auto-
injected into every agent so the agent can proactively
persist user-flagged facts mid-turn (for example when the
user says "please remember to always cite your sources").
Set false for hand-managed docs that only the reflective
post-turn updater (or direct WorkingMemoryStore.save
calls) should touch.
note_section
note_section:
string
Markdown section header under which remember(note) appends
new bullets. The tool creates the section as a
## <note_section> heading on the first call if it doesn't
already exist in the doc.
store
Get Signature
get store():
WorkingMemoryStore
Defined in: src/agents/observationalMemory/workingMemory.ts:182
Returns
closed
Get Signature
get closed():
boolean
Defined in: src/agents/observationalMemory/workingMemory.ts:186
Returns
boolean
Methods
effectiveResourceId()
effectiveResourceId(
resourceId):string|null
Defined in: src/agents/observationalMemory/workingMemory.ts:196
Return the resource id only when resource scope is active.
Mirrors ObservationBuffer.effectiveResourceId so callers
can pass through whatever resourceId they have without
checking the config first.
Parameters
resourceId
string | null | undefined
Returns
string | null
load()
load(
agentId,threadId,options?):Promise<string>
Defined in: src/agents/observationalMemory/workingMemory.ts:203
Parameters
agentId
string
threadId
string
options?
resourceId?
string | null
Returns
Promise<string>
afterTurn()
afterTurn(
agentId,threadId,newMessages,options?):Promise<void>
Defined in: src/agents/observationalMemory/workingMemory.ts:219
Schedule a background updater run for the new turn.
No-op when the runner is closed, when
update_after_every_turn is false, or when newMessages
is empty.
Parameters
agentId
string
threadId
string
newMessages
object[]
options?
resourceId?
string | null
tracer?
Tracer | null
Returns
Promise<void>
aclose()
aclose():
Promise<void>
Defined in: src/agents/observationalMemory/workingMemory.ts:291
Drain pending updater tasks and refuse new ones. Idempotent.
Returns
Promise<void>
waitIdle()
waitIdle():
Promise<void>
Defined in: src/agents/observationalMemory/workingMemory.ts:300
Await currently-pending tasks without closing. Test helper.
Returns
Promise<void>
RunCancelledError
Defined in: src/agents/runner.ts:349
Thrown internally by the runner when an active AbortSignal fires during model calls, tool execution, or iteration boundaries. The public entry points (runAgent, runAgentStream, and runAgentResume) catch it and surface an errored AgentResult so callers do not have to choose between two different signals (rejection vs. status === "errored").
When the runner can attribute the cancellation to a known iteration,
partial carries the in-flight transcript so the persistence-aware
caller (Maniac.chat) can write progress before surfacing the result.
Extends
Error
Constructors
Constructor
new RunCancelledError(
message?,partial?):RunCancelledError
Defined in: src/agents/runner.ts:351
Parameters
message?
string = "run cancelled"
partial?
Returns
Overrides
Error.constructor
Properties
partial?
optionalpartial?:InterruptedRunPartial
Defined in: src/agents/runner.ts:350
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
RunInterruptedError
Defined in: src/agents/runner.ts:368
Wrapper raised by runToolCallAgent / runReplAgent when the loop
body unwinds via an unexpected exception (LM provider failure,
sub-agent throw, etc.). Carries the partial transcript at the
moment of failure so Maniac.chat can persist progress before
re-raising the original cause. Direct callers of
runAgent who want the original exception type can read
.cause (set per ECMAScript Error chaining) -- it is also passed
through unchanged when the persistence-aware chat() re-throws.
Extends
Error
Constructors
Constructor
new RunInterruptedError(
cause,partial):RunInterruptedError
Defined in: src/agents/runner.ts:371
Parameters
cause
unknown
partial
Returns
Overrides
Error.constructor
Properties
partial
partial:
InterruptedRunPartial
Defined in: src/agents/runner.ts:369
cause
cause:
unknown
Defined in: src/agents/runner.ts:370
Overrides
Error.cause
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
Tracer
Defined in: src/agents/trace.ts:46
In-memory event collector and async fan-out used by the runner.
Queue policy:
- The tracer keeps an unbounded
eventsarray containing every emitted TraceEvent inseqorder. Memory grows for the lifetime of a run; consumers that handle long-lived streams should drain aiter concurrently rather than holding it in memory. - Each call to aiter creates a per-listener cursor. There is
no shared queue across listeners. A single consumer per
aiter()call is recommended. - On subscribe, the cursor is seeded with a snapshot of the buffered
eventsarray so late subscribers (e.g. a stream consumer that starts iterating only afterrunAgentInternalhas already begun emitting) still observe every event in order, exactly once. - close sends a sentinel to every active cursor; subsequent
calls to aiter still replay the full buffered history before
terminating, which is what
runAgentStreamrelies on.
Constructors
Constructor
new Tracer(
options?):Tracer
Defined in: src/agents/trace.ts:60
Parameters
options?
TracerOptions = {}
Returns
Properties
events
readonlyevents: ({ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"token";payload: {[key:string]:unknown;model?:string;scope?:string;iteration?:number;toolset?:string|null;lm_span_id?:string|null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:string|null;raw_finish_reason?:string|null; };delta:string;chunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null;content_part_kind?:"file"|"text"|"image"|null;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call_start";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;toolset?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:string;toolset?:string|null;raw_finish_reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool";payload: {[key:string]:unknown;tool_call_id:string;tool_name:string;toolset?:string|null;phase:"completed"|"failed"|"cancelled"|"started";args?:JsonDict;result?:JsonDict|null;result_preview?: {[key:string]:unknown;ok?:boolean;value?:unknown;error?:string|null;metadata?:JsonDict|null;result_truncated?:boolean;value_omitted_reason?:string|null; } |null;ok?:boolean|null;allowed?:boolean|null;error?:string|null;reason?:string|null;started_at?:string|null;finished_at?:string|null;elapsed_ms?:number|null;decision?: {[key:string]:unknown;allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool_call_arguments_delta";payload: {[key:string]:unknown;tool_call_id?:string|null;tool_name?:string|null;index:number;arguments_delta:string;sequence:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"cell";payload: {[key:string]:unknown;cell_id:string;phase:"completed"|"failed"|"cancelled"|"started";code?:string|null;result?:JsonDict|null;error?:string|null;elapsed_ms?:number|null;stdout_len?:number|null;stderr_len?:number|null;variables?:string[] |null;src?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"subagent";payload: {[key:string]:unknown;phase:"error"|"completed"|"intent"|"start"|"paused"|"errored";agent_id?:string|null;toolset?:string|null;role?:string|null;prompt_summary?:string|null;prompt?:string|null;parent_span_id?:string|null;background?:boolean|null;iterations?:number|null;reason?:string|null;max_depth?:number|null;repl?:boolean|null;usage?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"agent";payload: {[key:string]:unknown;phase:"completed"|"started";agent_id:string;principal?:string|null;iterations?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"approval";payload: {[key:string]:unknown;phase:"requested"|"approved"|"denied"|"resolved";id?:string;toolset?:string|null;tool?:string|null;rule_id?:string|null;reason?:string|null;source:"guardrail"|"policy";decision?:"approve"|"deny"|null;approvals:object[]; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"memory";payload: {[key:string]:unknown;op:string;phase?:string|null;principal?:string|null;depth?:number|null;summary?:string|null;namespace?:string|null;agent_id?:string|null;thread_id?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"guardrail";payload: {[key:string]:unknown;phase:string;boundary?:string|null;action?:string|null;decision?:string|null;rule_id?:string|null;reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"background_task";payload: {[key:string]:unknown;phase:string;task_id:string;status?:string|null;progress?:number|null;output?:JsonDict|null;agent_id?:string|null;sub_agent_id?:string|null;tool?:string|null;attempt?:number|null;error?:string|null;iterations?:number|null;timeout_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"step";payload: {[key:string]:unknown;phase:"before"|"after"|"repair"|"stopped"|"finalize_vetoed";turn_index:number;iteration?:number|null;source?:string|null;reason?:string|null;elapsed_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"retry";payload: {[key:string]:unknown;attempt:number;reason:string;model?:string|null;max_attempts?:number|null;delay_s?:number|null;fallback?:boolean|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"final";payload: {[key:string]:unknown;source:string;iterations?:number|null;validated?:boolean|null;error?:string|null;pending?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"error";payload: {[key:string]:unknown;message:string;kind_of_error?:string|null;cause?:string|null;retryable?:boolean|null;reason?:string|null;detail?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"stream_gap";payload: {[key:string]:unknown;dropped_count_so_far:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"plan";payload: {[key:string]:unknown;entries:object[]; }; })[] =[]
Defined in: src/agents/trace.ts:47
run_id
readonlyrun_id:string
Defined in: src/agents/trace.ts:54
Stable identifier shared by every event produced by this tracer. UI
consumers correlate events by run_id; producers downstream may
include it to associate out-of-band records (background tasks, observer
lifecycles) with the originating run.
Methods
emit()
emit(
kind,payload?,options?): {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"token";payload: {[key:string]:unknown;model?:string;scope?:string;iteration?:number;toolset?:string|null;lm_span_id?:string|null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:string|null;raw_finish_reason?:string|null; };delta:string;chunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null;content_part_kind?:"file"|"text"|"image"|null;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call_start";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;toolset?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:string;toolset?:string|null;raw_finish_reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool";payload: {[key:string]:unknown;tool_call_id:string;tool_name:string;toolset?:string|null;phase:"completed"|"failed"|"cancelled"|"started";args?:JsonDict;result?:JsonDict|null;result_preview?: {[key:string]:unknown;ok?:boolean;value?:unknown;error?:string|null;metadata?:JsonDict|null;result_truncated?:boolean;value_omitted_reason?:string|null; } |null;ok?:boolean|null;allowed?:boolean|null;error?:string|null;reason?:string|null;started_at?:string|null;finished_at?:string|null;elapsed_ms?:number|null;decision?: {[key:string]:unknown;allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool_call_arguments_delta";payload: {[key:string]:unknown;tool_call_id?:string|null;tool_name?:string|null;index:number;arguments_delta:string;sequence:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"cell";payload: {[key:string]:unknown;cell_id:string;phase:"completed"|"failed"|"cancelled"|"started";code?:string|null;result?:JsonDict|null;error?:string|null;elapsed_ms?:number|null;stdout_len?:number|null;stderr_len?:number|null;variables?:string[] |null;src?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"subagent";payload: {[key:string]:unknown;phase:"error"|"completed"|"intent"|"start"|"paused"|"errored";agent_id?:string|null;toolset?:string|null;role?:string|null;prompt_summary?:string|null;prompt?:string|null;parent_span_id?:string|null;background?:boolean|null;iterations?:number|null;reason?:string|null;max_depth?:number|null;repl?:boolean|null;usage?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"agent";payload: {[key:string]:unknown;phase:"completed"|"started";agent_id:string;principal?:string|null;iterations?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"approval";payload: {[key:string]:unknown;phase:"requested"|"approved"|"denied"|"resolved";id?:string;toolset?:string|null;tool?:string|null;rule_id?:string|null;reason?:string|null;source:"guardrail"|"policy";decision?:"approve"|"deny"|null;approvals:object[]; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"memory";payload: {[key:string]:unknown;op:string;phase?:string|null;principal?:string|null;depth?:number|null;summary?:string|null;namespace?:string|null;agent_id?:string|null;thread_id?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"guardrail";payload: {[key:string]:unknown;phase:string;boundary?:string|null;action?:string|null;decision?:string|null;rule_id?:string|null;reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"background_task";payload: {[key:string]:unknown;phase:string;task_id:string;status?:string|null;progress?:number|null;output?:JsonDict|null;agent_id?:string|null;sub_agent_id?:string|null;tool?:string|null;attempt?:number|null;error?:string|null;iterations?:number|null;timeout_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"step";payload: {[key:string]:unknown;phase:"before"|"after"|"repair"|"stopped"|"finalize_vetoed";turn_index:number;iteration?:number|null;source?:string|null;reason?:string|null;elapsed_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"retry";payload: {[key:string]:unknown;attempt:number;reason:string;model?:string|null;max_attempts?:number|null;delay_s?:number|null;fallback?:boolean|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"final";payload: {[key:string]:unknown;source:string;iterations?:number|null;validated?:boolean|null;error?:string|null;pending?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"error";payload: {[key:string]:unknown;message:string;kind_of_error?:string|null;cause?:string|null;retryable?:boolean|null;reason?:string|null;detail?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"stream_gap";payload: {[key:string]:unknown;dropped_count_so_far:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"plan";payload: {[key:string]:unknown;entries:object[]; }; }
Defined in: src/agents/trace.ts:73
Emit a typed trace event. The tracer auto-assigns:
seq(monotonic per tracer, starting at 0)event_id(uuid v4)run_id(the tracer'srun_id)
Callers should NOT pre-populate these fields; any caller-supplied values are overwritten so the contract stays consistent.
Parameters
kind
payload?
Record<string, unknown> | JsonDict
options?
Omit<MakeTraceEventOptions, "seq" | "event_id" | "run_id"> = {}
Returns
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "token"; payload: {[key: string]: unknown; model?: string; scope?: string; iteration?: number; toolset?: string | null; lm_span_id?: string | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: string | null; raw_finish_reason?: string | null; }; delta: string; chunk_kind?: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control" | null; content_part_kind?: "file" | "text" | "image" | null; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; }
ts
ts:
string
depth
depth:
number
principal?
optionalprincipal?:string|null
span_id?
optionalspan_id?:string|null
parent_span_id?
optionalparent_span_id?:string|null
seq
seq:
number
event_id
event_id:
string
run_id
run_id:
string
turn_id?
optionalturn_id?:string|null
message_id?
optionalmessage_id?:string|null
block_id?
optionalblock_id?:string|null
thread_id?
optionalthread_id?:string|null
kind
kind:
"token"
payload
payload:
object
Index Signature
[key: string]: unknown
payload.model?
optionalmodel?:string
payload.scope?
optionalscope?:string
payload.iteration?
optionaliteration?:number
payload.toolset?
optionaltoolset?:string|null
payload.lm_span_id?
optionallm_span_id?:string|null
payload.usage_delta?
optionalusage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null
payload.finish_reason?
optionalfinish_reason?:string|null
payload.raw_finish_reason?
optionalraw_finish_reason?:string|null
delta
delta:
string
chunk_kind?
optionalchunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null
content_part_kind?
optionalcontent_part_kind?:"file"|"text"|"image"|null
Optional discriminator for the multimodal content part the delta
belongs to (Phase 3). Additive: existing producers may leave it
null/omitted, and existing consumers continue to work without
reading it. The runner sets it whenever a stream produces image
or file deltas (today only the Anthropic adapter); plain-text
streams keep it null.
partial_object?
optionalpartial_object?:JsonDict|null
tool_call_delta?
optionaltool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "lm_call_start"; payload: {[key: string]: unknown; model: string; scope: string; iteration: number; toolset?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "lm_call"; payload: {[key: string]: unknown; model: string; scope: string; iteration: number; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: string; toolset?: string | null; raw_finish_reason?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "tool"; payload: {[key: string]: unknown; tool_call_id: string; tool_name: string; toolset?: string | null; phase: "completed" | "failed" | "cancelled" | "started"; args?: JsonDict; result?: JsonDict | null; result_preview?: {[key: string]: unknown; ok?: boolean; value?: unknown; error?: string | null; metadata?: JsonDict | null; result_truncated?: boolean; value_omitted_reason?: string | null; } | null; ok?: boolean | null; allowed?: boolean | null; error?: string | null; reason?: string | null; started_at?: string | null; finished_at?: string | null; elapsed_ms?: number | null; decision?: {[key: string]: unknown; allowed: boolean; requires_approval: boolean; matched_rule_id?: string | null; reason?: string | null; } | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "tool_call_arguments_delta"; payload: {[key: string]: unknown; tool_call_id?: string | null; tool_name?: string | null; index: number; arguments_delta: string; sequence: number; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "cell"; payload: {[key: string]: unknown; cell_id: string; phase: "completed" | "failed" | "cancelled" | "started"; code?: string | null; result?: JsonDict | null; error?: string | null; elapsed_ms?: number | null; stdout_len?: number | null; stderr_len?: number | null; variables?: string[] | null; src?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "subagent"; payload: {[key: string]: unknown; phase: "error" | "completed" | "intent" | "start" | "paused" | "errored"; agent_id?: string | null; toolset?: string | null; role?: string | null; prompt_summary?: string | null; prompt?: string | null; parent_span_id?: string | null; background?: boolean | null; iterations?: number | null; reason?: string | null; max_depth?: number | null; repl?: boolean | null; usage?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "agent"; payload: {[key: string]: unknown; phase: "completed" | "started"; agent_id: string; principal?: string | null; iterations?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "approval"; payload: {[key: string]: unknown; phase: "requested" | "approved" | "denied" | "resolved"; id?: string; toolset?: string | null; tool?: string | null; rule_id?: string | null; reason?: string | null; source: "guardrail" | "policy"; decision?: "approve" | "deny" | null; approvals: object[]; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "memory"; payload: {[key: string]: unknown; op: string; phase?: string | null; principal?: string | null; depth?: number | null; summary?: string | null; namespace?: string | null; agent_id?: string | null; thread_id?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "guardrail"; payload: {[key: string]: unknown; phase: string; boundary?: string | null; action?: string | null; decision?: string | null; rule_id?: string | null; reason?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "background_task"; payload: {[key: string]: unknown; phase: string; task_id: string; status?: string | null; progress?: number | null; output?: JsonDict | null; agent_id?: string | null; sub_agent_id?: string | null; tool?: string | null; attempt?: number | null; error?: string | null; iterations?: number | null; timeout_ms?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "step"; payload: {[key: string]: unknown; phase: "before" | "after" | "repair" | "stopped" | "finalize_vetoed"; turn_index: number; iteration?: number | null; source?: string | null; reason?: string | null; elapsed_ms?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "retry"; payload: {[key: string]: unknown; attempt: number; reason: string; model?: string | null; max_attempts?: number | null; delay_s?: number | null; fallback?: boolean | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "final"; payload: {[key: string]: unknown; source: string; iterations?: number | null; validated?: boolean | null; error?: string | null; pending?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "error"; payload: {[key: string]: unknown; message: string; kind_of_error?: string | null; cause?: string | null; retryable?: boolean | null; reason?: string | null; detail?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "stream_gap"; payload: {[key: string]: unknown; dropped_count_so_far: number; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "plan"; payload: {[key: string]: unknown; entries: object[]; }; }
enableStreaming()
enableStreaming():
void
Defined in: src/agents/trace.ts:101
Returns
void
close()
close():
void
Defined in: src/agents/trace.ts:105
Returns
void
aiter()
aiter():
AsyncIterable<{ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"token";payload: {[key:string]:unknown;model?:string;scope?:string;iteration?:number;toolset?:string|null;lm_span_id?:string|null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:string|null;raw_finish_reason?:string|null; };delta:string;chunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null;content_part_kind?:"file"|"text"|"image"|null;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call_start";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;toolset?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:string;toolset?:string|null;raw_finish_reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool";payload: {[key:string]:unknown;tool_call_id:string;tool_name:string;toolset?:string|null;phase:"completed"|"failed"|"cancelled"|"started";args?:JsonDict;result?:JsonDict|null;result_preview?: {[key:string]:unknown;ok?:boolean;value?:unknown;error?:string|null;metadata?:JsonDict|null;result_truncated?:boolean;value_omitted_reason?:string|null; } |null;ok?:boolean|null;allowed?:boolean|null;error?:string|null;reason?:string|null;started_at?:string|null;finished_at?:string|null;elapsed_ms?:number|null;decision?: {[key:string]:unknown;allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool_call_arguments_delta";payload: {[key:string]:unknown;tool_call_id?:string|null;tool_name?:string|null;index:number;arguments_delta:string;sequence:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"cell";payload: {[key:string]:unknown;cell_id:string;phase:"completed"|"failed"|"cancelled"|"started";code?:string|null;result?:JsonDict|null;error?:string|null;elapsed_ms?:number|null;stdout_len?:number|null;stderr_len?:number|null;variables?:string[] |null;src?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"subagent";payload: {[key:string]:unknown;phase:"error"|"completed"|"intent"|"start"|"paused"|"errored";agent_id?:string|null;toolset?:string|null;role?:string|null;prompt_summary?:string|null;prompt?:string|null;parent_span_id?:string|null;background?:boolean|null;iterations?:number|null;reason?:string|null;max_depth?:number|null;repl?:boolean|null;usage?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"agent";payload: {[key:string]:unknown;phase:"completed"|"started";agent_id:string;principal?:string|null;iterations?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"approval";payload: {[key:string]:unknown;phase:"requested"|"approved"|"denied"|"resolved";id?:string;toolset?:string|null;tool?:string|null;rule_id?:string|null;reason?:string|null;source:"guardrail"|"policy";decision?:"approve"|"deny"|null;approvals:object[]; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"memory";payload: {[key:string]:unknown;op:string;phase?:string|null;principal?:string|null;depth?:number|null;summary?:string|null;namespace?:string|null;agent_id?:string|null;thread_id?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"guardrail";payload: {[key:string]:unknown;phase:string;boundary?:string|null;action?:string|null;decision?:string|null;rule_id?:string|null;reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"background_task";payload: {[key:string]:unknown;phase:string;task_id:string;status?:string|null;progress?:number|null;output?:JsonDict|null;agent_id?:string|null;sub_agent_id?:string|null;tool?:string|null;attempt?:number|null;error?:string|null;iterations?:number|null;timeout_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"step";payload: {[key:string]:unknown;phase:"before"|"after"|"repair"|"stopped"|"finalize_vetoed";turn_index:number;iteration?:number|null;source?:string|null;reason?:string|null;elapsed_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"retry";payload: {[key:string]:unknown;attempt:number;reason:string;model?:string|null;max_attempts?:number|null;delay_s?:number|null;fallback?:boolean|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"final";payload: {[key:string]:unknown;source:string;iterations?:number|null;validated?:boolean|null;error?:string|null;pending?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"error";payload: {[key:string]:unknown;message:string;kind_of_error?:string|null;cause?:string|null;retryable?:boolean|null;reason?:string|null;detail?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"stream_gap";payload: {[key:string]:unknown;dropped_count_so_far:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"plan";payload: {[key:string]:unknown;entries:object[]; }; }>
Defined in: src/agents/trace.ts:129
Async-iterable view of the trace stream.
Replay-on-subscribe: the iterator first yields a snapshot of every
event already buffered on the tracer (in original seq order), then
yields live events as they are emitted. Subscribing before, during, or
after a run all observe the same logical stream.
Multiple concurrent subscribers are supported but each call returns an independent cursor with its own queue. A single consumer per call is recommended; sharing the iterator across multiple awaiters is not supported because async generators cannot be multiplexed.
Returns
AsyncIterable<{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "token"; payload: {[key: string]: unknown; model?: string; scope?: string; iteration?: number; toolset?: string | null; lm_span_id?: string | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: string | null; raw_finish_reason?: string | null; }; delta: string; chunk_kind?: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control" | null; content_part_kind?: "file" | "text" | "image" | null; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "lm_call_start"; payload: {[key: string]: unknown; model: string; scope: string; iteration: number; toolset?: string | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "lm_call"; payload: {[key: string]: unknown; model: string; scope: string; iteration: number; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: string; toolset?: string | null; raw_finish_reason?: string | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "tool"; payload: {[key: string]: unknown; tool_call_id: string; tool_name: string; toolset?: string | null; phase: "completed" | "failed" | "cancelled" | "started"; args?: JsonDict; result?: JsonDict | null; result_preview?: {[key: string]: unknown; ok?: boolean; value?: unknown; error?: string | null; metadata?: JsonDict | null; result_truncated?: boolean; value_omitted_reason?: string | null; } | null; ok?: boolean | null; allowed?: boolean | null; error?: string | null; reason?: string | null; started_at?: string | null; finished_at?: string | null; elapsed_ms?: number | null; decision?: {[key: string]: unknown; allowed: boolean; requires_approval: boolean; matched_rule_id?: string | null; reason?: string | null; } | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "tool_call_arguments_delta"; payload: {[key: string]: unknown; tool_call_id?: string | null; tool_name?: string | null; index: number; arguments_delta: string; sequence: number; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "cell"; payload: {[key: string]: unknown; cell_id: string; phase: "completed" | "failed" | "cancelled" | "started"; code?: string | null; result?: JsonDict | null; error?: string | null; elapsed_ms?: number | null; stdout_len?: number | null; stderr_len?: number | null; variables?: string[] | null; src?: string | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "subagent"; payload: {[key: string]: unknown; phase: "error" | "completed" | "intent" | "start" | "paused" | "errored"; agent_id?: string | null; toolset?: string | null; role?: string | null; prompt_summary?: string | null; prompt?: string | null; parent_span_id?: string | null; background?: boolean | null; iterations?: number | null; reason?: string | null; max_depth?: number | null; repl?: boolean | null; usage?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "agent"; payload: {[key: string]: unknown; phase: "completed" | "started"; agent_id: string; principal?: string | null; iterations?: number | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "approval"; payload: {[key: string]: unknown; phase: "requested" | "approved" | "denied" | "resolved"; id?: string; toolset?: string | null; tool?: string | null; rule_id?: string | null; reason?: string | null; source: "guardrail" | "policy"; decision?: "approve" | "deny" | null; approvals: object[]; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "memory"; payload: {[key: string]: unknown; op: string; phase?: string | null; principal?: string | null; depth?: number | null; summary?: string | null; namespace?: string | null; agent_id?: string | null; thread_id?: string | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "guardrail"; payload: {[key: string]: unknown; phase: string; boundary?: string | null; action?: string | null; decision?: string | null; rule_id?: string | null; reason?: string | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "background_task"; payload: {[key: string]: unknown; phase: string; task_id: string; status?: string | null; progress?: number | null; output?: JsonDict | null; agent_id?: string | null; sub_agent_id?: string | null; tool?: string | null; attempt?: number | null; error?: string | null; iterations?: number | null; timeout_ms?: number | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "step"; payload: {[key: string]: unknown; phase: "before" | "after" | "repair" | "stopped" | "finalize_vetoed"; turn_index: number; iteration?: number | null; source?: string | null; reason?: string | null; elapsed_ms?: number | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "retry"; payload: {[key: string]: unknown; attempt: number; reason: string; model?: string | null; max_attempts?: number | null; delay_s?: number | null; fallback?: boolean | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "final"; payload: {[key: string]: unknown; source: string; iterations?: number | null; validated?: boolean | null; error?: string | null; pending?: number | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "error"; payload: {[key: string]: unknown; message: string; kind_of_error?: string | null; cause?: string | null; retryable?: boolean | null; reason?: string | null; detail?: string | null; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "stream_gap"; payload: {[key: string]: unknown; dropped_count_so_far: number; }; } | { ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "plan"; payload: {[key: string]: unknown; entries: object[]; }; }>
AnthropicProviderError
Defined in: src/inference/adapters/anthropic.ts:108
Extends
Error
Constructors
Constructor
new AnthropicProviderError(
response,url,body):AnthropicProviderError
Defined in: src/inference/adapters/anthropic.ts:134
Parameters
response
Response
url
string
body
string
Returns
Overrides
Error.constructor
Properties
status
readonlystatus:number
Defined in: src/inference/adapters/anthropic.ts:109
statusText
readonlystatusText:string
Defined in: src/inference/adapters/anthropic.ts:110
body
readonlybody:string
Defined in: src/inference/adapters/anthropic.ts:111
url
readonlyurl:string
Defined in: src/inference/adapters/anthropic.ts:112
headers
readonlyheaders:Headers|null
Defined in: src/inference/adapters/anthropic.ts:119
Full response headers (when constructed from a Response). Captured
so the retry layer can reach Retry-After and any other
provider-specific signals without the adapter having to enumerate
them up-front.
retryAfterMs
readonlyretryAfterMs:number|null
Defined in: src/inference/adapters/anthropic.ts:125
Normalized Retry-After delay in milliseconds. null when the
provider did not supply the header or it could not be parsed. The
retry layer prefers this over re-parsing the raw header.
retryAfterDate
readonlyretryAfterDate:Date|null
Defined in: src/inference/adapters/anthropic.ts:132
Absolute deadline parsed from a Retry-After HTTP-date header. The
retry layer recomputes (date - now) so the delay stays accurate
after a long pre-retry pause. null for the seconds form / absent
header.
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
AnthropicModel
Defined in: src/inference/adapters/anthropic.ts:150
Extends
Constructors
Constructor
new AnthropicModel(
options):AnthropicModel
Defined in: src/inference/adapters/anthropic.ts:163
Parameters
options
Returns
Overrides
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Inherited from
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Inherited from
Methods
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/adapters/anthropic.ts:181
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Overrides
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/adapters/anthropic.ts:197
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Overrides
listModels()
listModels(
opts?):Promise<object[]>
Defined in: src/inference/adapters/anthropic.ts:492
List Anthropic's catalog via the paginated GET /models.
Anthropic paginates its catalog, so this follows the has_more /
last_id cursor (via the after_id query param) until exhausted.
The catalog is sparse -- ids, display_name, and an ISO created_at
only -- so specs carry no context window or pricing. Twin of Python
AnthropicModel.list_models.
Parameters
opts?
Returns
Promise<object[]>
FallbackModel
Defined in: src/inference/adapters/fallback.ts:46
Wrap a chain of Model adapters with cross-provider failover.
TypeScript twin of inference/adapters/fallback.py. Composes with
RetryingModel: each member of the chain may itself be a
RetryingModel, so per-provider retries happen inside each link
and only after a member's retry budget is exhausted does
FallbackModel reach for the next link.
Streaming: locked to the first provider that yields a chunk. Once any inner stream has yielded, switching providers would either duplicate the prefix or drop it; we surface post-first-chunk failures untouched.
Extends
Constructors
Constructor
new FallbackModel(
primary,fallbacks?,options?):FallbackModel
Defined in: src/inference/adapters/fallback.ts:51
Parameters
primary
fallbacks?
Model[] = []
options?
FallbackModelOptions = {}
Returns
Overrides
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Inherited from
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Inherited from
Accessors
primary
Get Signature
get primary():
Model
Defined in: src/inference/adapters/fallback.ts:66
Returns
fallbacks
Get Signature
get fallbacks(): readonly
Model[]
Defined in: src/inference/adapters/fallback.ts:70
Returns
readonly Model[]
models
Get Signature
get models(): readonly
Model[]
Defined in: src/inference/adapters/fallback.ts:74
Returns
readonly Model[]
Methods
listModels()
listModels(
opts?):Promise<object[]>
Defined in: src/inference/adapters/fallback.ts:88
Delegate model discovery to the primary model. FallbackModel lists
from its primary only -- merging catalogs across providers would
yield ambiguous ids (the same slug can name different models on
different providers). Forwards to primary.listModels() when the
primary implements SupportsModelCatalog, else throws
ModelCatalogUnsupportedError. No failover here: discovery is
metadata, not a routable inference failure. Twin of Python
FallbackModel.list_models.
Parameters
opts?
Returns
Promise<object[]>
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/adapters/fallback.ts:98
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Overrides
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/adapters/fallback.ts:117
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Overrides
OpenAICompatibleProviderError
Defined in: src/inference/adapters/openaiCompatible.ts:48
Extends
Error
Constructors
Constructor
new OpenAICompatibleProviderError(
response,url,body):OpenAICompatibleProviderError
Defined in: src/inference/adapters/openaiCompatible.ts:74
Parameters
response
Response
url
string
body
string
Returns
Overrides
Error.constructor
Properties
status
readonlystatus:number
Defined in: src/inference/adapters/openaiCompatible.ts:49
statusText
readonlystatusText:string
Defined in: src/inference/adapters/openaiCompatible.ts:50
body
readonlybody:string
Defined in: src/inference/adapters/openaiCompatible.ts:51
url
readonlyurl:string
Defined in: src/inference/adapters/openaiCompatible.ts:52
headers
readonlyheaders:Headers|null
Defined in: src/inference/adapters/openaiCompatible.ts:59
Full response headers (when constructed from a Response). Captured
so the retry layer can reach Retry-After and any other
provider-specific signals without the adapter having to enumerate
them up-front.
retryAfterMs
readonlyretryAfterMs:number|null
Defined in: src/inference/adapters/openaiCompatible.ts:65
Normalized Retry-After delay in milliseconds. null when the
provider did not supply the header or it could not be parsed. The
retry layer prefers this over re-parsing the raw header.
retryAfterDate
readonlyretryAfterDate:Date|null
Defined in: src/inference/adapters/openaiCompatible.ts:72
Absolute deadline parsed from a Retry-After HTTP-date header. The
retry layer recomputes (date - now) so the delay stays accurate
after a long pre-retry pause. null for the seconds form / absent
header.
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
OpenAICompatibleModel
Defined in: src/inference/adapters/openaiCompatible.ts:90
Extends
Extended by
Constructors
Constructor
new OpenAICompatibleModel(
options):OpenAICompatibleModel
Defined in: src/inference/adapters/openaiCompatible.ts:100
Parameters
options
Returns
Overrides
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Inherited from
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Inherited from
Methods
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/adapters/openaiCompatible.ts:116
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Overrides
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/adapters/openaiCompatible.ts:149
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Overrides
listModels()
listModels(
opts?):Promise<object[]>
Defined in: src/inference/adapters/openaiCompatible.ts:345
List the models this endpoint exposes via GET /models.
OpenAI's catalog is sparse -- each entry carries only id /
created / owned_by with no context window or pricing -- so the
returned specs mostly reflect ids, with the verbatim entry preserved
on ModelSpec.raw. Subclasses override parseModels
(OpenRouter / Vercel) for richer shapes, catalogProvider for
the provider tag, and modelsHeaders when the models endpoint
needs different auth (Vercel needs none). Twin of Python
OpenAIModel.list_models.
Parameters
opts?
Returns
Promise<object[]>
OpenRouterModel
Defined in: src/inference/adapters/openrouter.ts:27
Extends
Constructors
Constructor
new OpenRouterModel(
options):OpenRouterModel
Defined in: src/inference/adapters/openrouter.ts:28
Parameters
options
Returns
Overrides
OpenAICompatibleModel.constructor
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Inherited from
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Inherited from
Methods
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/adapters/openaiCompatible.ts:116
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Inherited from
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/adapters/openaiCompatible.ts:149
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Inherited from
listModels()
listModels(
opts?):Promise<object[]>
Defined in: src/inference/adapters/openaiCompatible.ts:345
List the models this endpoint exposes via GET /models.
OpenAI's catalog is sparse -- each entry carries only id /
created / owned_by with no context window or pricing -- so the
returned specs mostly reflect ids, with the verbatim entry preserved
on ModelSpec.raw. Subclasses override parseModels
(OpenRouter / Vercel) for richer shapes, catalogProvider for
the provider tag, and modelsHeaders when the models endpoint
needs different auth (Vercel needs none). Twin of Python
OpenAIModel.list_models.
Parameters
opts?
Returns
Promise<object[]>
Inherited from
OpenAICompatibleModel.listModels
RetryingModel
Defined in: src/inference/adapters/retrying.ts:87
Wrap a Model adapter with exponential-jitter retries on transient errors.
TypeScript twin of inference/adapters/retrying.py. Two semantics
carry over verbatim:
- Streaming retries are bounded by the first yielded chunk. Once the consumer has observed any delta, restarting the stream would duplicate that token. Post-first-chunk failures are surfaced untouched.
- Tracer integration. Every retry attempt emits a
retryTraceEvent(when a tracer is wired) carrying the model slug, attempt index, max attempts, computed delay, and a string representation of the error.
Cancellation: the retryOn default returns false for
AbortError-shaped exceptions so RunOptions.signal cancellation
never gets wrapped in a retry loop. Inner adapters that respect
AbortSignal continue to short-circuit cleanly.
Extends
Constructors
Constructor
new RetryingModel(
inner,options?):RetryingModel
Defined in: src/inference/adapters/retrying.ts:100
Parameters
inner
options?
RetryingModelOptions = {}
Returns
Overrides
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Inherited from
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Inherited from
Accessors
innerModel
Get Signature
get innerModel():
Model
Defined in: src/inference/adapters/retrying.ts:145
Returns
Methods
listModels()
listModels(
opts?):Promise<object[]>
Defined in: src/inference/adapters/retrying.ts:158
Delegate model discovery to the wrapped model. RetryingModel has no
catalog of its own; it forwards to inner.listModels() when the
inner adapter implements SupportsModelCatalog, and throws
ModelCatalogUnsupportedError otherwise. The call is not
wrapped in the retry loop -- discovery is a one-shot metadata fetch
and the retry policy here targets inference calls. Twin of Python
RetryingModel.list_models.
Parameters
opts?
Returns
Promise<object[]>
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/adapters/retrying.ts:168
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Overrides
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/adapters/retrying.ts:190
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Overrides
VercelGatewayModel
Defined in: src/inference/adapters/vercelGateway.ts:59
Vercel AI Gateway adapter.
The gateway exposes an OpenAI Chat Completions–compatible endpoint at
https://ai-gateway.vercel.sh/v1/chat/completions. Model slugs use the
provider/model convention (e.g. anthropic/claude-opus-4.7,
openai/gpt-5.5, google/gemini-2.5-flash).
Auth resolves in order: explicit apiKey option, then
AI_GATEWAY_API_KEY, then VERCEL_OIDC_TOKEN. Both forms are sent on
the same Authorization: Bearer <token> header; the gateway
distinguishes them server-side. This is why we override
headers rather than relying on the base class's single-env-var
lookup: an OIDC fallback needs a second name without falling through
to OpenAI's default env var (which would silently route gateway
traffic through an OpenAI key for users who happen to have both set).
Reasoning passthrough, tool-call partials, SSE parsing, and
last-write-wins usage merging are all inherited unchanged from
OpenAICompatibleModel; the gateway emits the same
message.reasoning / delta.reasoning shape the base already
handles.
Extends
Constructors
Constructor
new VercelGatewayModel(
options):VercelGatewayModel
Defined in: src/inference/adapters/vercelGateway.ts:63
Parameters
options
Returns
Overrides
OpenAICompatibleModel.constructor
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Inherited from
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Inherited from
Methods
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/adapters/openaiCompatible.ts:116
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Inherited from
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/adapters/openaiCompatible.ts:149
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Inherited from
listModels()
listModels(
opts?):Promise<object[]>
Defined in: src/inference/adapters/openaiCompatible.ts:345
List the models this endpoint exposes via GET /models.
OpenAI's catalog is sparse -- each entry carries only id /
created / owned_by with no context window or pricing -- so the
returned specs mostly reflect ids, with the verbatim entry preserved
on ModelSpec.raw. Subclasses override parseModels
(OpenRouter / Vercel) for richer shapes, catalogProvider for
the provider tag, and modelsHeaders when the models endpoint
needs different auth (Vercel needs none). Twin of Python
OpenAIModel.list_models.
Parameters
opts?
Returns
Promise<object[]>
Inherited from
OpenAICompatibleModel.listModels
MustOverrideError
Defined in: src/inference/base.ts:230
Thrown by BaseModel when a subclass has overridden neither BaseModel.infer nor BaseModel.stream, so the default implementations would mutually recurse.
Subclasses MUST override at least one of these methods. The default
infer is implemented in terms of stream (it merges chunks); the
default stream is implemented in terms of infer (it yields one
synthetic chunk). Overriding either is sufficient.
Extends
Error
Constructors
Constructor
new MustOverrideError(
message?):MustOverrideError
Defined in: src/inference/base.ts:231
Parameters
message?
string
Returns
Overrides
Error.constructor
Properties
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
abstract BaseModel
Defined in: src/inference/base.ts:241
Extended by
Implements
Constructors
Constructor
new BaseModel(
options):BaseModel
Defined in: src/inference/base.ts:245
Parameters
options
id
string
slug
string
Returns
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Implementation of
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Implementation of
Methods
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/base.ts:250
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Implementation of
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/base.ts:261
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Implementation of
StaticModel
Defined in: src/inference/base.ts:299
Extends
Constructors
Constructor
new StaticModel(
responses,options?):StaticModel
Defined in: src/inference/base.ts:303
Parameters
responses
object[]
options?
id?
string
slug?
string
Returns
Overrides
Properties
id
readonlyid:string
Defined in: src/inference/base.ts:242
Inherited from
slug
readonlyslug:string
Defined in: src/inference/base.ts:243
Inherited from
Methods
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/inference/base.ts:261
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
Inherited from
infer()
infer(
_req,_opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/base.ts:308
Parameters
_req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
_opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Overrides
InMemoryVectorIndex
Defined in: src/memory/adapters/vector.ts:81
Reference VectorIndex using cosine similarity.
Pure-TS so the SDK stays dep-light. Fine for tests and small
workloads (a few thousand records); swap in a pgvector /
qdrant / pinecone adapter for production.
Implements
Constructors
Constructor
new InMemoryVectorIndex():
InMemoryVectorIndex
Returns
Methods
upsert()
upsert(
items):Promise<void>
Defined in: src/memory/adapters/vector.ts:84
Parameters
items
readonly [string, number[], Record<string, unknown>][]
Returns
Promise<void>
Implementation of
query()
query(
embedding,k):Promise<VectorHit[]>
Defined in: src/memory/adapters/vector.ts:92
Parameters
embedding
number[]
k
number
Returns
Promise<VectorHit[]>
Implementation of
delete()
delete(
id):Promise<boolean>
Defined in: src/memory/adapters/vector.ts:101
Parameters
id
string
Returns
Promise<boolean>
Implementation of
SqliteVectorIndex
Defined in: src/memory/adapters/vector.ts:150
Persistent VectorIndex backed by node:sqlite.
Unlike InMemoryVectorIndex, the embeddings survive a process
restart, so semantic recall is available immediately on cold start
without re-embedding the entire base store. Vectors are stored as
JSON-encoded float arrays in a single table; query loads every row
and ranks them by cosine similarity in-process. That is fine for the
few-thousand-record workloads the bundled adapters target (same
scaling envelope as InMemoryVectorIndex); swap in a
pgvector / qdrant adapter for large corpora.
Share one connection with SqliteMemory by constructing with
{ database: sqliteMemory.database } so both live in the same
on-disk file and the memory adapter's close() owns the handle.
Implements
Constructors
Constructor
new SqliteVectorIndex(
options):SqliteVectorIndex
Defined in: src/memory/adapters/vector.ts:157
Parameters
options
Returns
Methods
setup()
setup():
Promise<void>
Defined in: src/memory/adapters/vector.ts:179
Create the backing table if it does not exist. Idempotent; safe to
call repeatedly. Call once before the first upsert / query.
Returns
Promise<void>
upsert()
upsert(
items):Promise<void>
Defined in: src/memory/adapters/vector.ts:193
Parameters
items
readonly [string, number[], Record<string, unknown>][]
Returns
Promise<void>
Implementation of
query()
query(
embedding,k):Promise<VectorHit[]>
Defined in: src/memory/adapters/vector.ts:208
Parameters
embedding
number[]
k
number
Returns
Promise<VectorHit[]>
Implementation of
delete()
delete(
id):Promise<boolean>
Defined in: src/memory/adapters/vector.ts:223
Parameters
id
string
Returns
Promise<boolean>
Implementation of
close()
close():
Promise<void>
Defined in: src/memory/adapters/vector.ts:237
Close the underlying database handle if (and only if) the index
opened it. No-op for borrowed handles (the { database }
construction shape) so the owner — typically SqliteMemory —
controls the lifecycle. Idempotent.
Returns
Promise<void>
VectorMemory
Defined in: src/memory/adapters/vector.ts:272
Wrap a base Memory with semantic search via a vector index.
The base adapter owns canonical record persistence, scope
enforcement, and every helper that depends on
namespace/metadata semantics. The vector index is a sidecar that
accelerates search({ text }) calls; it never holds the only
copy of a record's content.
Implements
Constructors
Constructor
new VectorMemory(
options):VectorMemory
Defined in: src/memory/adapters/vector.ts:278
Parameters
options
Returns
Properties
base
readonlybase:Memory
Defined in: src/memory/adapters/vector.ts:273
index
readonlyindex:VectorIndex
Defined in: src/memory/adapters/vector.ts:274
Methods
save()
save(
record,scope):Promise<string>
Defined in: src/memory/adapters/vector.ts:285
Parameters
record
id
string = ...
namespace
string = ...
content
unknown = ...
metadata
Record<string, unknown> = ...
created_at
string = ...
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<string>
Implementation of
load()
load(
id,scope):Promise<{id:string;namespace:string;content:unknown;metadata:Record<string,unknown>;created_at:string; } |null>
Defined in: src/memory/adapters/vector.ts:313
Parameters
id
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<{ id: string; namespace: string; content: unknown; metadata: Record<string, unknown>; created_at: string; } | null>
Implementation of
search()
search(
query,scope):Promise<object[]>
Defined in: src/memory/adapters/vector.ts:317
Parameters
query
text?
string | null = ...
namespace?
string | null = ...
filters
Record<string, unknown> = ...
k
number = ...
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<object[]>
Implementation of
delete()
delete(
id,scope):Promise<boolean>
Defined in: src/memory/adapters/vector.ts:376
Parameters
id
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<boolean>
Implementation of
BackgroundTaskStore
Defined in: src/memory/backgroundTasks.ts:59
Constructors
Constructor
new BackgroundTaskStore(
memory,options?):BackgroundTaskStore
Defined in: src/memory/backgroundTasks.ts:63
Parameters
memory
options?
maxRecords?
number
Returns
Properties
memory
readonlymemory:Memory
Defined in: src/memory/backgroundTasks.ts:60
maxRecords
readonlymaxRecords:number
Defined in: src/memory/backgroundTasks.ts:61
Methods
saveTask()
saveTask(
record,options?):Promise<{id:string;task_id:string;agent_id:string;thread_id:string;tool_call_id:string;tool_name:string;toolset?:string|null;args:JsonDict;status:"queued"|"running"|"completed"|"failed"|"cancelled";enqueued_at:string;started_at?:string|null;finished_at?:string|null;ack_value?:unknown;result?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null;retries:number;error?:string|null; }>
Defined in: src/memory/backgroundTasks.ts:68
Parameters
record
id
string = ...
task_id
string = ...
agent_id
string = ...
thread_id
string = ...
tool_call_id
string = ...
tool_name
string = ...
toolset?
string | null = ...
args
JsonDict = ...
status
"queued" | "running" | "completed" | "failed" | "cancelled" = ...
enqueued_at
string = ...
started_at?
string | null = ...
finished_at?
string | null = ...
ack_value?
unknown = ...
result?
{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null = ...
retries
number = ...
error?
string | null = ...
options?
tracer?
Tracer | null
Returns
Promise<{ id: string; task_id: string; agent_id: string; thread_id: string; tool_call_id: string; tool_name: string; toolset?: string | null; args: JsonDict; status: "queued" | "running" | "completed" | "failed" | "cancelled"; enqueued_at: string; started_at?: string | null; finished_at?: string | null; ack_value?: unknown; result?: { ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null; retries: number; error?: string | null; }>
updateTask()
updateTask(
record,options?):Promise<{id:string;task_id:string;agent_id:string;thread_id:string;tool_call_id:string;tool_name:string;toolset?:string|null;args:JsonDict;status:"queued"|"running"|"completed"|"failed"|"cancelled";enqueued_at:string;started_at?:string|null;finished_at?:string|null;ack_value?:unknown;result?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null;retries:number;error?:string|null; }>
Defined in: src/memory/backgroundTasks.ts:94
Parameters
record
id
string = ...
task_id
string = ...
agent_id
string = ...
thread_id
string = ...
tool_call_id
string = ...
tool_name
string = ...
toolset?
string | null = ...
args
JsonDict = ...
status
"queued" | "running" | "completed" | "failed" | "cancelled" = ...
enqueued_at
string = ...
started_at?
string | null = ...
finished_at?
string | null = ...
ack_value?
unknown = ...
result?
{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null = ...
retries
number = ...
error?
string | null = ...
options?
tracer?
Tracer | null
Returns
Promise<{ id: string; task_id: string; agent_id: string; thread_id: string; tool_call_id: string; tool_name: string; toolset?: string | null; args: JsonDict; status: "queued" | "running" | "completed" | "failed" | "cancelled"; enqueued_at: string; started_at?: string | null; finished_at?: string | null; ack_value?: unknown; result?: { ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null; retries: number; error?: string | null; }>
loadTask()
loadTask(
agentId,threadId,taskId):Promise<{id:string;task_id:string;agent_id:string;thread_id:string;tool_call_id:string;tool_name:string;toolset?:string|null;args:JsonDict;status:"queued"|"running"|"completed"|"failed"|"cancelled";enqueued_at:string;started_at?:string|null;finished_at?:string|null;ack_value?:unknown;result?: {ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; } |null;retries:number;error?:string|null; } |null>
Defined in: src/memory/backgroundTasks.ts:98
Parameters
agentId
string
threadId
string
taskId
string
Returns
Promise<{ id: string; task_id: string; agent_id: string; thread_id: string; tool_call_id: string; tool_name: string; toolset?: string | null; args: JsonDict; status: "queued" | "running" | "completed" | "failed" | "cancelled"; enqueued_at: string; started_at?: string | null; finished_at?: string | null; ack_value?: unknown; result?: { ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; } | null; retries: number; error?: string | null; } | null>
listTasks()
listTasks(
agentId,threadId,options?):Promise<object[]>
Defined in: src/memory/backgroundTasks.ts:109
Parameters
agentId
string
threadId
string
options?
status?
"queued" | "running" | "completed" | "failed" | "cancelled" | null
Returns
Promise<object[]>
deleteTask()
deleteTask(
agentId,threadId,taskId):Promise<boolean>
Defined in: src/memory/backgroundTasks.ts:130
Parameters
agentId
string
threadId
string
taskId
string
Returns
Promise<boolean>
MemoryAccessError
Defined in: src/memory/base.ts:13
Extends
Error
Constructors
Constructor
new MemoryAccessError(
message):MemoryAccessError
Defined in: src/memory/base.ts:14
Parameters
message
string
Returns
Overrides
Error.constructor
Properties
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
InMemoryMemory
Defined in: src/memory/base.ts:60
Implements
Constructors
Constructor
new InMemoryMemory():
InMemoryMemory
Returns
Methods
save()
save(
record,scope):Promise<string>
Defined in: src/memory/base.ts:66
Parameters
record
id
string = ...
namespace
string = ...
content
unknown = ...
metadata
Record<string, unknown> = ...
created_at
string = ...
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<string>
Implementation of
load()
load(
id,scope):Promise<{id:string;namespace:string;content:unknown;metadata:Record<string,unknown>;created_at:string; } |null>
Defined in: src/memory/base.ts:81
Parameters
id
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<{ id: string; namespace: string; content: unknown; metadata: Record<string, unknown>; created_at: string; } | null>
Implementation of
search()
search(
query,scope):Promise<object[]>
Defined in: src/memory/base.ts:92
Parameters
query
text?
string | null = ...
namespace?
string | null = ...
filters
Record<string, unknown> = ...
k
number = ...
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<object[]>
Implementation of
delete()
delete(
id,scope):Promise<boolean>
Defined in: src/memory/base.ts:119
Parameters
id
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<boolean>
Implementation of
nextSequence()
nextSequence(
namespace,key,scope):Promise<number>
Defined in: src/memory/base.ts:132
Parameters
namespace
string
key
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<number>
Implementation of
RunCheckpointStore
Defined in: src/memory/checkpoints.ts:120
Constructors
Constructor
new RunCheckpointStore(
memory,options?):RunCheckpointStore
Defined in: src/memory/checkpoints.ts:140
Parameters
memory
options?
claimTtlSeconds?
number
Returns
Properties
memory
readonlymemory:Memory
Defined in: src/memory/checkpoints.ts:121
claimTtlSeconds
readonlyclaimTtlSeconds:number
Defined in: src/memory/checkpoints.ts:138
TTL (seconds) after which a stranded resolving claim may be stolen
by a new claim. See DEFAULT_CLAIM_TTL_SECONDS.
Methods
save()
save(
agentId,checkpoint,options?):Promise<string>
Defined in: src/memory/checkpoints.ts:145
Parameters
agentId
string
checkpoint
schema_version
1 | 2 = ...
spec_id
string = ...
iteration
number = ...
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
root_messages
object[] = ...
subagent_sessions
object[] = ...
pending
object[] = ...
checkpoint_id?
string | null = ...
options?
threadId?
string | null
prefixLen?
number | null
tracer?
Tracer | null
Returns
Promise<string>
load()
load(
agentId,checkpointId,options?):Promise<StoredCheckpoint|null>
Defined in: src/memory/checkpoints.ts:181
Parameters
agentId
string
checkpointId
string
options?
threadId?
string | null
Returns
Promise<StoredCheckpoint | null>
markResolved()
markResolved(
agentId,checkpointId,options?):Promise<boolean>
Defined in: src/memory/checkpoints.ts:191
Parameters
agentId
string
checkpointId
string
options?
threadId?
string | null
tracer?
Tracer | null
Returns
Promise<boolean>
claim()
claim(
agentId,checkpointId,options?):Promise<StoredCheckpoint|null>
Defined in: src/memory/checkpoints.ts:253
Compare-and-swap claim used by Maniac.resumeCheckpoint to defend against double-execute on a duplicate webhook delivery (or a user clicking the approval card twice).
Returns the StoredCheckpoint when the status transitioned
pending → resolving. Returns null when the checkpoint is
missing or already resolving / resolved — callers should treat
that as "someone else is already handling this" and bail out.
Within a single process this is fully atomic: a per-checkpointId
promise lock serializes the load-check-write. Across processes
the application is expected to layer its own idempotency (e.g.
the channels webhook layer's idempotencyStore) and/or use a
Memory backend with native CAS.
Stale-claim recovery: a record already in resolving is normally
un-claimable, but if its claimed_at stamp is older than
claimTtlSeconds (the prior resumer crashed before reaching a
terminal state) the claim is stolen so the approval can be retried
rather than stranded forever. Every successful claim re-stamps
claimed_at.
Parameters
agentId
string
checkpointId
string
options?
threadId?
string | null
tracer?
Tracer | null
Returns
Promise<StoredCheckpoint | null>
revertClaim()
revertClaim(
agentId,checkpointId,options?):Promise<boolean>
Defined in: src/memory/checkpoints.ts:321
Revert a claim back to pending after a failed resume.
Idempotent: if the record is missing or no longer in resolving
we leave it alone (someone else may have already moved it forward
to resolved, which would be the right terminal state anyway).
Parameters
agentId
string
checkpointId
string
options?
threadId?
string | null
tracer?
Tracer | null
Returns
Promise<boolean>
delete()
delete(
agentId,checkpointId,options?):Promise<boolean>
Defined in: src/memory/checkpoints.ts:376
Parameters
agentId
string
checkpointId
string
options?
threadId?
string | null
Returns
Promise<boolean>
listPending()
listPending(
agentId,options?):Promise<StoredCheckpoint[]>
Defined in: src/memory/checkpoints.ts:381
Parameters
agentId
string
options?
threadId?
string | null
maxRecords?
number
Returns
Promise<StoredCheckpoint[]>
listStale()
listStale(
agentId,options?):Promise<StoredCheckpoint[]>
Defined in: src/memory/checkpoints.ts:409
Surface stranded resolving checkpoints — records a crashed or
abandoned resume left mid-flight. A record counts as stale when its
claimed_at stamp is older than olderThanSeconds (defaults to
claimTtlSeconds); a missing/invalid stamp also counts.
Operators can use this to re-drive or alert on stuck approvals; a
fresh claim self-heals such records once they age past the
TTL.
Parameters
agentId
string
options?
olderThanSeconds?
number
threadId?
string | null
maxRecords?
number
Returns
Promise<StoredCheckpoint[]>
ConversationStore
Defined in: src/memory/conversation.ts:55
Extended by
Constructors
Constructor
new ConversationStore(
memory,options?):ConversationStore
Defined in: src/memory/conversation.ts:59
Parameters
memory
options?
maxTurns?
number
Returns
Properties
memory
readonlymemory:Memory
Defined in: src/memory/conversation.ts:56
maxTurns
readonlymaxTurns:number
Defined in: src/memory/conversation.ts:57
Methods
loadThread()
loadThread(
agentId,threadId,options?):Promise<object[]>
Defined in: src/memory/conversation.ts:64
Parameters
agentId
string
threadId
string
options?
tracer?
Tracer | null
resourceId?
string | null
Forwarded to the HonchoConversationStore subclass; the
base store ignores it. Mirrors Python resource_id.
userPeerId?
string | null
Forwarded to the Honcho subclass; ignored here.
assistantPeerId?
string | null
Forwarded to the Honcho subclass; ignored here.
Returns
Promise<object[]>
saveTurn()
saveTurn(
agentId,threadId,messages,options?):Promise<string|null>
Defined in: src/memory/conversation.ts:105
Parameters
agentId
string
threadId
string
messages
object[]
options?
tracer?
Tracer | null
resourceId?
string | null
Forwarded to the Honcho subclass; ignored here.
userPeerId?
string | null
Forwarded to the Honcho subclass; ignored here.
assistantPeerId?
string | null
Forwarded to the Honcho subclass; ignored here.
Returns
Promise<string | null>
clear()
clear(
agentId,threadId,options?):Promise<number>
Defined in: src/memory/conversation.ts:147
Parameters
agentId
string
threadId
string
options?
tracer?
Tracer | null
Returns
Promise<number>
HonchoConversationStore
Defined in: src/memory/honchoConversation.ts:64
Extends
Constructors
Constructor
new HonchoConversationStore(
memory,options?):HonchoConversationStore
Defined in: src/memory/honchoConversation.ts:68
Parameters
memory
options?
HonchoConversationStoreOptions = {}
Returns
Overrides
Properties
memory
readonlymemory:Memory
Defined in: src/memory/conversation.ts:56
Inherited from
maxTurns
readonlymaxTurns:number
Defined in: src/memory/conversation.ts:57
Inherited from
tokenBudget
readonlytokenBudget:number
Defined in: src/memory/honchoConversation.ts:65
honchoMemory
readonlyhonchoMemory:HonchoMemory
Defined in: src/memory/honchoConversation.ts:66
Methods
clear()
clear(
agentId,threadId,options?):Promise<number>
Defined in: src/memory/conversation.ts:147
Parameters
agentId
string
threadId
string
options?
tracer?
Tracer | null
Returns
Promise<number>
Inherited from
loadThread()
loadThread(
agentId,threadId,options?):Promise<object[]>
Defined in: src/memory/honchoConversation.ts:79
Parameters
agentId
string
threadId
string
options?
tracer?
Tracer | null
resourceId?
string | null
userPeerId?
string | null
assistantPeerId?
string | null
Returns
Promise<object[]>
Overrides
saveTurn()
saveTurn(
agentId,threadId,messages,options?):Promise<string|null>
Defined in: src/memory/honchoConversation.ts:166
Parameters
agentId
string
threadId
string
messages
object[]
options?
tracer?
Tracer | null
resourceId?
string | null
userPeerId?
string | null
assistantPeerId?
string | null
Returns
Promise<string | null>
Overrides
HonchoWorkingMemoryStore
Defined in: src/memory/honchoWorkingMemory.ts:35
Singleton-per-scope persistence for working memory.
Wraps any Memory adapter; the per-call scope is derived
from the chosen namespace exactly the way ConversationStore
and ObservationStore derive theirs.
Extends
Constructors
Constructor
new HonchoWorkingMemoryStore(
memory,options?):HonchoWorkingMemoryStore
Defined in: src/memory/honchoWorkingMemory.ts:39
Parameters
memory
options?
HonchoWorkingMemoryStoreOptions = {}
Returns
Overrides
WorkingMemoryStore.constructor
Properties
honchoMemory
readonlyhonchoMemory:HonchoMemory
Defined in: src/memory/honchoWorkingMemory.ts:36
peerCardKey
readonlypeerCardKey:string
Defined in: src/memory/honchoWorkingMemory.ts:37
memory
readonlymemory:Memory
Defined in: src/memory/workingMemory.ts:53
Inherited from
Methods
load()
load(
agentId,threadId,options?):Promise<string>
Defined in: src/memory/honchoWorkingMemory.ts:50
Return the working-memory doc for the scope, or an empty string when no record exists yet (the updater treats that as "fresh start").
Parameters
agentId
string
threadId
string
options?
WorkingMemoryOriginOptions = {}
Returns
Promise<string>
Overrides
save()
save(
agentId,threadId,doc,options?):Promise<void>
Defined in: src/memory/honchoWorkingMemory.ts:84
Upsert the working-memory doc for the scope. Looks up the
existing record id so the upsert preserves ordering on
adapters that key on id.
Parameters
agentId
string
threadId
string
doc
string
options?
WorkingMemoryOriginOptions & object = {}
Returns
Promise<void>
Overrides
clear()
clear(
agentId,threadId,options?):Promise<boolean>
Defined in: src/memory/honchoWorkingMemory.ts:131
Delete the working-memory doc for the scope. Returns true
if a record was removed, false if no doc existed.
Parameters
agentId
string
threadId
string
options?
WorkingMemoryOriginOptions = {}
Returns
Promise<boolean>
Overrides
ObservationStore
Defined in: src/memory/observations.ts:197
Constructors
Constructor
new ObservationStore(
memory,options?):ObservationStore
Defined in: src/memory/observations.ts:202
Parameters
memory
options?
maxObservations?
number
maxReflections?
number
Returns
Properties
memory
readonlymemory:Memory
Defined in: src/memory/observations.ts:198
maxObservations
readonlymaxObservations:number
Defined in: src/memory/observations.ts:199
maxReflections
readonlymaxReflections:number
Defined in: src/memory/observations.ts:200
Methods
saveObservation()
saveObservation(
agentId,threadId,record,options?):Promise<{id:string;text:string;from_index:number;to_index:number;current_task?:string|null;suggested_response?:string|null;provider_model:string;status:"buffered"|"active";chars:number;thread_id?:string|null;resource_id?:string|null; }>
Defined in: src/memory/observations.ts:208
Parameters
agentId
string
threadId
string
record
id
string = ...
text
string = ...
from_index
number = ...
to_index
number = ...
current_task?
string | null = ...
suggested_response?
string | null = ...
provider_model
string = ...
status
"buffered" | "active" = ...
chars
number = ...
thread_id?
string | null = ...
Set when ObservationalMemoryConfig.scope is "resource"
so a resource-scoped read pool can disambiguate per-thread
accounting from a shared cross-thread set. Both default to
null for thread-scoped observations whose
(agent_id, thread_id) is implicit in the namespace.
resource_id?
string | null = ...
options?
object & ObservationOriginOptions = {}
Returns
Promise<{ id: string; text: string; from_index: number; to_index: number; current_task?: string | null; suggested_response?: string | null; provider_model: string; status: "buffered" | "active"; chars: number; thread_id?: string | null; resource_id?: string | null; }>
updateObservationStatus()
updateObservationStatus(
agentId,threadId,observationId,status,options?):Promise<boolean>
Defined in: src/memory/observations.ts:247
Parameters
agentId
string
threadId
string
observationId
string
status
"buffered" | "active"
options?
object & ObservationOriginOptions = {}
Returns
Promise<boolean>
listObservations()
listObservations(
agentId,threadId,options?):Promise<object[]>
Defined in: src/memory/observations.ts:289
Parameters
agentId
string
threadId
string
options?
object & ObservationOriginOptions = {}
Returns
Promise<object[]>
deleteObservation()
deleteObservation(
agentId,threadId,observationId,options?):Promise<boolean>
Defined in: src/memory/observations.ts:313
Parameters
agentId
string
threadId
string
observationId
string
options?
Returns
Promise<boolean>
clearObservations()
clearObservations(
agentId,threadId,options?):Promise<number>
Defined in: src/memory/observations.ts:335
Delete every observation chunk for the (agentId, threadId) pool
(resource-scoped when resourceId is supplied). Returns the number
of records removed.
The backing Memory interface has no bulk-delete primitive, so the
store fans the deletes out one record at a time; the work is
batched behind this single call so consumers don't have to list +
loop themselves. Pages until the pool is empty so it clears more
than ObservationStore.maxObservations records when needed.
Parameters
agentId
string
threadId
string
options?
Returns
Promise<number>
clearReflections()
clearReflections(
agentId,threadId,options?):Promise<number>
Defined in: src/memory/observations.ts:366
Delete every reflection chunk for the (agentId, threadId) pool
(resource-scoped when resourceId is supplied). Symmetric to
clearObservations; returns the number of records removed.
Parameters
agentId
string
threadId
string
options?
Returns
Promise<number>
saveReflection()
saveReflection(
agentId,threadId,record,options?):Promise<{id:string;text:string;from_index:number;to_index:number;current_task?:string|null;suggested_response?:string|null;provider_model:string;status:"buffered"|"active";chars:number;thread_id?:string|null;resource_id?:string|null; }>
Defined in: src/memory/observations.ts:392
Parameters
agentId
string
threadId
string
record
id
string = ...
text
string = ...
from_index
number = ...
to_index
number = ...
current_task?
string | null = ...
suggested_response?
string | null = ...
provider_model
string = ...
status
"buffered" | "active" = ...
chars
number = ...
thread_id?
string | null = ...
Set when ObservationalMemoryConfig.scope is "resource"
so a resource-scoped read pool can disambiguate per-thread
accounting from a shared cross-thread set. Both default to
null for thread-scoped observations whose
(agent_id, thread_id) is implicit in the namespace.
resource_id?
string | null = ...
options?
object & ObservationOriginOptions = {}
Returns
Promise<{ id: string; text: string; from_index: number; to_index: number; current_task?: string | null; suggested_response?: string | null; provider_model: string; status: "buffered" | "active"; chars: number; thread_id?: string | null; resource_id?: string | null; }>
updateReflectionStatus()
updateReflectionStatus(
agentId,threadId,reflectionId,status,options?):Promise<boolean>
Defined in: src/memory/observations.ts:434
Parameters
agentId
string
threadId
string
reflectionId
string
status
"buffered" | "active"
options?
object & ObservationOriginOptions = {}
Returns
Promise<boolean>
listReflections()
listReflections(
agentId,threadId,options?):Promise<object[]>
Defined in: src/memory/observations.ts:476
Parameters
agentId
string
threadId
string
options?
object & ObservationOriginOptions = {}
Returns
Promise<object[]>
searchObservations()
searchObservations(
agentId,threadId,options):Promise<object[]>
Defined in: src/memory/observations.ts:512
Free-text search over observation chunks.
Routes through the wrapped Memory.search; when that adapter
is a VectorMemory the result is semantic recall (kNN over an
embedding of each chunk's text). With the shipped substring
adapters the result is a case-insensitive LIKE.
Pass resourceId to query the cross-thread resource pool.
status is filtered after retrieval so adapters without a
metadata index path stay cheap.
Parameters
agentId
string
threadId
string
options
object & ObservationOriginOptions
Returns
Promise<object[]>
searchReflections()
searchReflections(
agentId,threadId,options):Promise<object[]>
Defined in: src/memory/observations.ts:550
Free-text search over reflection chunks. Symmetric to searchObservations.
Parameters
agentId
string
threadId
string
options
object & ObservationOriginOptions
Returns
Promise<object[]>
loadState()
loadState(
agentId,threadId):Promise<{last_observed_index:number;in_flight_index:number;current_task?:string|null;suggested_response?:string|null;last_provider_model:string;last_activity_ts:string; }>
Defined in: src/memory/observations.ts:584
Parameters
agentId
string
threadId
string
Returns
Promise<{ last_observed_index: number; in_flight_index: number; current_task?: string | null; suggested_response?: string | null; last_provider_model: string; last_activity_ts: string; }>
saveState()
saveState(
agentId,threadId,state,options?):Promise<void>
Defined in: src/memory/observations.ts:594
Parameters
agentId
string
threadId
string
state
last_observed_index
number = ...
in_flight_index
number = ...
current_task?
string | null = ...
suggested_response?
string | null = ...
last_provider_model
string = ...
last_activity_ts
string = ...
options?
tracer?
Tracer | null
Returns
Promise<void>
WorkingMemoryStore
Defined in: src/memory/workingMemory.ts:52
Singleton-per-scope persistence for working memory.
Wraps any Memory adapter; the per-call scope is derived
from the chosen namespace exactly the way ConversationStore
and ObservationStore derive theirs.
Extended by
Constructors
Constructor
new WorkingMemoryStore(
memory):WorkingMemoryStore
Defined in: src/memory/workingMemory.ts:55
Parameters
memory
Returns
Properties
memory
readonlymemory:Memory
Defined in: src/memory/workingMemory.ts:53
Methods
load()
load(
agentId,threadId,options?):Promise<string>
Defined in: src/memory/workingMemory.ts:64
Return the working-memory doc for the scope, or an empty string when no record exists yet (the updater treats that as "fresh start").
Parameters
agentId
string
threadId
string
options?
WorkingMemoryOriginOptions = {}
Returns
Promise<string>
save()
save(
agentId,threadId,doc,options?):Promise<void>
Defined in: src/memory/workingMemory.ts:95
Upsert the working-memory doc for the scope. Looks up the
existing record id so the upsert preserves ordering on
adapters that key on id.
Parameters
agentId
string
threadId
string
doc
string
options?
WorkingMemoryOriginOptions & object = {}
Returns
Promise<void>
clear()
clear(
agentId,threadId,options?):Promise<boolean>
Defined in: src/memory/workingMemory.ts:131
Delete the working-memory doc for the scope. Returns true
if a record was removed, false if no doc existed.
Parameters
agentId
string
threadId
string
options?
WorkingMemoryOriginOptions = {}
Returns
Promise<boolean>
BaseLMMiddleware
Defined in: src/middleware/base.ts:13
Implements
Constructors
Constructor
new BaseLMMiddleware():
BaseLMMiddleware
Returns
Methods
beforeLmCall()
beforeLmCall(
_ctx,req):Promise<{messages:object[];response_format:"text"|"json";max_tokens?:number|null;temperature?:number|null;top_p?:number|null;top_k?:number|null;frequency_penalty?:number|null;presence_penalty?:number|null;seed?:number|null;logit_bias?:Record<string,number> |null;stop:string[];tools:object[];tool_choice: {kind:"named";name:string; } |"auto"|"required"|"none";parallel_tool_calls?:boolean|null;user?:string|null;reasoning?: {effort?:"minimal"|"low"|"medium"|"high"|null;max_tokens?:number|null;summary?:"auto"|"concise"|"detailed"|null; } |null; }>
Defined in: src/middleware/base.ts:14
Parameters
_ctx
principal
string = ...
scope
"root" | "subagent" = ...
iteration
number = ...
toolset?
string | null = ...
span_id
string = ...
parent_span_id?
string | null = ...
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
Returns
Promise<{ messages: object[]; response_format: "text" | "json"; max_tokens?: number | null; temperature?: number | null; top_p?: number | null; top_k?: number | null; frequency_penalty?: number | null; presence_penalty?: number | null; seed?: number | null; logit_bias?: Record<string, number> | null; stop: string[]; tools: object[]; tool_choice: { kind: "named"; name: string; } | "auto" | "required" | "none"; parallel_tool_calls?: boolean | null; user?: string | null; reasoning?: { effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null; }>
Implementation of
afterLmCall()
afterLmCall(
_ctx,_req,resp):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/middleware/base.ts:18
Parameters
_ctx
principal
string = ...
scope
"root" | "subagent" = ...
iteration
number = ...
toolset?
string | null = ...
span_id
string = ...
parent_span_id?
string | null = ...
_req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
Implementation of
BaseToolMiddleware
Defined in: src/middleware/base.ts:27
Implements
Constructors
Constructor
new BaseToolMiddleware():
BaseToolMiddleware
Returns
Methods
beforeInvoke()
beforeInvoke(
_ctx,call):Promise<{toolset?:string|null;tool:string;args:JsonDict;principal:string; }>
Defined in: src/middleware/base.ts:28
Parameters
_ctx
principal
string = ...
scope
"root" | "subagent" = ...
toolset
string = ...
iteration
number = ...
subagent_span_id?
string | null = ...
call
toolset?
string | null = ...
tool
string = ...
args
JsonDict = ...
principal
string = ...
Returns
Promise<{ toolset?: string | null; tool: string; args: JsonDict; principal: string; }>
Implementation of
afterInvoke()
afterInvoke(
_ctx,_call,result):Promise<{ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; }>
Defined in: src/middleware/base.ts:32
Parameters
_ctx
principal
string = ...
scope
"root" | "subagent" = ...
toolset
string = ...
iteration
number = ...
subagent_span_id?
string | null = ...
_call
toolset?
string | null = ...
tool
string = ...
args
JsonDict = ...
principal
string = ...
result
ok
boolean = ...
value?
unknown = ...
error?
string | null = ...
metadata
Record<string, unknown> = ...
cause?
{ kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null = ...
Optional structured cause for failed results. Populated by the tool()
helper (and any adapter that wants to preserve thrown error context),
so consumers can distinguish validation vs. runtime failures and read
the original error name/stack without the public ok: false
discriminator changing shape.
Returns
Promise<{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }>
Implementation of
AllowingLMGuardrail
Defined in: src/middleware/base.ts:41
Implements
Constructors
Constructor
new AllowingLMGuardrail():
AllowingLMGuardrail
Returns
Methods
checkInput()
checkInput():
Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/middleware/base.ts:42
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
Implementation of
checkOutput()
checkOutput():
Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/middleware/base.ts:46
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
Implementation of
AllowingToolGuardrail
Defined in: src/middleware/base.ts:51
Implements
Constructors
Constructor
new AllowingToolGuardrail():
AllowingToolGuardrail
Returns
Methods
checkCall()
checkCall():
Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/middleware/base.ts:52
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
Implementation of
checkResult()
checkResult():
Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/middleware/base.ts:56
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
Implementation of
SessionPermissionCache
Defined in: src/permissions/cache.ts:65
Implements
Constructors
Constructor
new SessionPermissionCache(
inner,options?):SessionPermissionCache
Defined in: src/permissions/cache.ts:70
Parameters
inner
options?
SessionPermissionCacheOptions = {}
Returns
Methods
keyFor()
statickeyFor(action):string
Defined in: src/permissions/cache.ts:79
Parameters
action
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
Returns
string
evaluate()
evaluate(
action):Promise<{allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; }>
Defined in: src/permissions/cache.ts:107
Parameters
action
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
Returns
Promise<{ allowed: boolean; requires_approval: boolean; matched_rule_id?: string | null; reason?: string | null; }>
Implementation of
evaluateMany()
evaluateMany(
actions):Promise<object[]>
Defined in: src/permissions/cache.ts:121
Optional batched evaluator (Tier 2 #8). Default implementations
live in permissions/policy.ts::evaluateMany and just loop over
evaluate; the runner calls it from the sub-action fan-out so
HTTP/DB-backed policies can answer N pending actions in a single
round-trip.
Parameters
actions
object[]
Returns
Promise<object[]>
Implementation of
remember()
remember(
action,decision):void
Defined in: src/permissions/cache.ts:151
Pin a decision so subsequent identical calls skip the inner policy. Wired up by HITL approvers to implement the "always allow this turn" UX.
Parameters
action
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
decision
allowed
boolean = ...
requires_approval
boolean = ...
matched_rule_id?
string | null = ...
reason?
string | null = ...
Returns
void
invalidate()
invalidate(
action?):void
Defined in: src/permissions/cache.ts:159
Drop a single cached entry (when action is given) or the whole
cache (when action is omitted).
Parameters
action?
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
Returns
void
AllowAllPolicy
Defined in: src/permissions/policy.ts:196
Implements
Constructors
Constructor
new AllowAllPolicy():
AllowAllPolicy
Returns
Methods
evaluate()
evaluate(
_action):object
Defined in: src/permissions/policy.ts:197
Parameters
_action
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
Returns
object
allowed
allowed:
boolean
requires_approval
requires_approval:
boolean
matched_rule_id?
optionalmatched_rule_id?:string|null
reason?
optionalreason?:string|null
Implementation of
DenyAllPolicy
Defined in: src/permissions/policy.ts:202
Implements
Constructors
Constructor
new DenyAllPolicy():
DenyAllPolicy
Returns
Methods
evaluate()
evaluate(
_action):object
Defined in: src/permissions/policy.ts:203
Parameters
_action
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
Returns
object
allowed
allowed:
boolean
requires_approval
requires_approval:
boolean
matched_rule_id?
optionalmatched_rule_id?:string|null
reason?
optionalreason?:string|null
Implementation of
StaticPermissionPolicy
Defined in: src/permissions/policy.ts:236
Implements
Constructors
Constructor
new StaticPermissionPolicy(
permissions,defaultDecision?):StaticPermissionPolicy
Defined in: src/permissions/policy.ts:237
Parameters
permissions
object[]
defaultDecision?
allowed
boolean = ...
requires_approval
boolean = ...
matched_rule_id?
string | null = ...
reason?
string | null = ...
Returns
Methods
evaluate()
evaluate(
action):object
Defined in: src/permissions/policy.ts:242
Parameters
action
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
Returns
object
allowed
allowed:
boolean
requires_approval
requires_approval:
boolean
matched_rule_id?
optionalmatched_rule_id?:string|null
reason?
optionalreason?:string|null
Implementation of
evaluateMany()
evaluateMany(
actions):object[]
Defined in: src/permissions/policy.ts:268
Tier 2 #8: single-pass batched evaluator. Walks the rule list
once, testing every action against every applicable rule. The
default evaluateMany shim in evaluateMany (below) loops over
evaluate instead, so HTTP-backed policies that benefit from a
single round-trip can opt into this method while leaving
evaluate unchanged.
Parameters
actions
object[]
Returns
object[]
Implementation of
SandboxTerminated
Defined in: src/runtime/pythonSandboxClient.ts:60
Extends
Error
Constructors
Constructor
new SandboxTerminated(
message):SandboxTerminated
Defined in: src/runtime/pythonSandboxClient.ts:61
Parameters
message
string
Returns
Overrides
Error.constructor
Properties
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
PythonSandboxClient
Defined in: src/runtime/pythonSandboxClient.ts:67
Implements
Constructors
Constructor
new PythonSandboxClient(
options?):PythonSandboxClient
Defined in: src/runtime/pythonSandboxClient.ts:85
Parameters
options?
PythonSandboxClientOptions = {}
Returns
Methods
run()
run(
code):Promise<{cell: {code:string;stdout:string;stderr:string;truncated:boolean;elapsed_ms:number; };variables:Record<string, {name:string;type_name:string;size_bytes:number;summary?:string|null; }>; }>
Defined in: src/runtime/pythonSandboxClient.ts:87
Parameters
code
string
Returns
Promise<{ cell: { code: string; stdout: string; stderr: string; truncated: boolean; elapsed_ms: number; }; variables: Record<string, { name: string; type_name: string; size_bytes: number; summary?: string | null; }>; }>
Implementation of
getVar()
getVar(
name):Promise<unknown>
Defined in: src/runtime/pythonSandboxClient.ts:99
Parameters
name
string
Returns
Promise<unknown>
Implementation of
setVar()
setVar(
name,value):Promise<void>
Defined in: src/runtime/pythonSandboxClient.ts:111
Parameters
name
string
value
unknown
Returns
Promise<void>
Implementation of
injectCallable()
injectCallable(
name,fn):Promise<void>
Defined in: src/runtime/pythonSandboxClient.ts:123
Parameters
name
string
fn
unknown
Returns
Promise<void>
Implementation of
aclose()
aclose():
Promise<void>
Defined in: src/runtime/pythonSandboxClient.ts:136
Returns
Promise<void>
Implementation of
LocalREPL
Defined in: src/runtime/repl.ts:10
Implements
Constructors
Constructor
new LocalREPL(
sandbox?):LocalREPL
Defined in: src/runtime/repl.ts:13
Parameters
sandbox?
Sandbox = ...
Returns
Properties
state
readonlystate:object
Defined in: src/runtime/repl.ts:11
variables
variables:
Record<string, {name:string;type_name:string;size_bytes:number;summary?:string|null; }>
cells
cells:
object[]
Implementation of
Methods
execute()
execute(
code):Promise<{code:string;stdout:string;stderr:string;truncated:boolean;elapsed_ms:number; }>
Defined in: src/runtime/repl.ts:15
Parameters
code
string
Returns
Promise<{ code: string; stdout: string; stderr: string; truncated: boolean; elapsed_ms: number; }>
Implementation of
getVar()
getVar(
name):Promise<unknown>
Defined in: src/runtime/repl.ts:22
Parameters
name
string
Returns
Promise<unknown>
Implementation of
setVar()
setVar(
name,value):Promise<void>
Defined in: src/runtime/repl.ts:26
Parameters
name
string
value
unknown
Returns
Promise<void>
Implementation of
inject()
inject(
name,fn):Promise<void>
Defined in: src/runtime/repl.ts:30
Parameters
name
string
fn
unknown
Returns
Promise<void>
Implementation of
aclose()
aclose():
Promise<void>
Defined in: src/runtime/repl.ts:34
Returns
Promise<void>
Implementation of
BaseException
Defined in: src/schemas/approvals.ts:65
Extends
Error
Extended by
Constructors
Constructor
new BaseException(
message):BaseException
Defined in: src/schemas/approvals.ts:66
Parameters
message
string
Returns
Overrides
Error.constructor
Properties
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
NeedsApprovalError
Defined in: src/schemas/approvals.ts:72
Extends
Constructors
Constructor
new NeedsApprovalError(
pending):NeedsApprovalError
Defined in: src/schemas/approvals.ts:75
Parameters
pending
id
string = ...
principal
string = ...
toolset
string = ...
tool
string = ...
args
JsonDict = ...
rule_id?
string | null = ...
reason?
string | null = ...
requested_at
string = ...
sub_actions
object[] = ...
Per-sub-call breakdown for batched delegated_tool invocations
(Tier 1 #2). Empty list keeps the legacy single-call shape; when
non-empty, the caller must populate
ApprovalResponse.sub_decisions to cover every sub-id (or
resume fails with a missing-decision error).
Returns
Overrides
Properties
pending
readonlypending:object
Defined in: src/schemas/approvals.ts:73
id
id:
string
principal
principal:
string
toolset
toolset:
string
tool
tool:
string
args
args:
JsonDict
rule_id?
optionalrule_id?:string|null
reason?
optionalreason?:string|null
requested_at
requested_at:
string
sub_actions
sub_actions:
object[]
Per-sub-call breakdown for batched delegated_tool invocations
(Tier 1 #2). Empty list keeps the legacy single-call shape; when
non-empty, the caller must populate
ApprovalResponse.sub_decisions to cover every sub-id (or
resume fails with a missing-decision error).
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
BaseException.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
BaseException.prepareStackTrace
ModelCatalogUnsupportedError
Defined in: src/schemas/inference.ts:563
Thrown when a provider / adapter cannot enumerate available models.
Adapters with no catalog source (mock models, or a wrapper whose inner
model can't list) throw this from listModels. Twin of Python
ModelCatalogUnsupported.
Extends
Error
Constructors
Constructor
new ModelCatalogUnsupportedError(
message?):ModelCatalogUnsupportedError
Defined in: src/schemas/inference.ts:564
Parameters
message?
string
Returns
Overrides
Error.constructor
Properties
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
Error.cause
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
Error.name
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
Error.message
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
GuardrailBlocked
Defined in: src/schemas/middleware.ts:152
Extends
Constructors
Constructor
new GuardrailBlocked(
options):GuardrailBlocked
Defined in: src/schemas/middleware.ts:157
Parameters
options
boundary
"lm_input" | "lm_output" | "tool_call" | "tool_result"
reason?
string | null
rule_id?
string | null
Returns
Overrides
Properties
boundary
readonlyboundary:"lm_input"|"lm_output"|"tool_call"|"tool_result"
Defined in: src/schemas/middleware.ts:153
reason?
readonlyoptionalreason?:string|null
Defined in: src/schemas/middleware.ts:154
rule_id?
readonlyoptionalrule_id?:string|null
Defined in: src/schemas/middleware.ts:155
stackTraceLimit
staticstackTraceLimit:number
Defined in: node_modules/@types/node/globals.d.ts:67
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
cause?
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from
name
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from
message
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from
stack?
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
BaseException.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/@types/node/globals.d.ts:55
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
BaseException.prepareStackTrace
MCPToolset
Defined in: src/tools/adapters/mcp.ts:151
Extends
Constructors
Constructor
new MCPToolset(
options):MCPToolset
Defined in: src/tools/adapters/mcp.ts:164
Parameters
options
Returns
Overrides
Properties
name
readonlyname:string
Defined in: src/tools/base.ts:135
Inherited from
description
readonlydescription:string
Defined in: src/tools/base.ts:136
Inherited from
Methods
listTools()
listTools():
Promise<Tool[]>
Defined in: src/tools/adapters/mcp.ts:338
Returns
Promise<Tool[]>
Overrides
callTool()
callTool(
toolName,args,options?):Promise<{ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; }>
Defined in: src/tools/adapters/mcp.ts:360
Invoke an MCP tool by name. Public API; also called by
MCPTool.invoke so individual Tool references reuse the
same open session.
Parameters
toolName
string
args
options?
MCPCallToolOptions = {}
Returns
Promise<{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }>
invoke()
invoke(
toolName,args,options?):Promise<{ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; }>
Defined in: src/tools/adapters/mcp.ts:385
Parameters
toolName
string
args
options?
MCPCallToolOptions = {}
Returns
Promise<{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }>
Overrides
aclose()
aclose():
Promise<void>
Defined in: src/tools/adapters/mcp.ts:397
Close the underlying session and transport. Idempotent; safe to call when no session was ever opened.
Returns
Promise<void>
searchTools()
searchTools(
query,k?):Promise<Tool[]>
Defined in: src/tools/base.ts:149
Parameters
query
string
k?
number = 10
Returns
Promise<Tool[]>
Inherited from
asDelegated()
asDelegated(
options?):Tool
Defined in: src/tools/base.ts:171
Parameters
options?
DelegatedToolOptions = {}
Returns
Inherited from
LexicalIndex
Defined in: src/tools/base.ts:113
Implements
Constructors
Constructor
new LexicalIndex():
LexicalIndex
Returns
Methods
build()
build(
tools):void
Defined in: src/tools/base.ts:116
Parameters
tools
object[]
Returns
void
Implementation of
search()
search(
query,k?):object[]
Defined in: src/tools/base.ts:120
Parameters
query
string
k?
number = 10
Returns
object[]
Implementation of
abstract BaseToolset
Defined in: src/tools/base.ts:134
Extended by
Implements
Constructors
Constructor
new BaseToolset(
options):BaseToolset
Defined in: src/tools/base.ts:141
Parameters
options
name
string
description
string
index?
Returns
Properties
name
readonlyname:string
Defined in: src/tools/base.ts:135
Implementation of
description
readonlydescription:string
Defined in: src/tools/base.ts:136
Implementation of
Methods
listTools()
abstractlistTools():Promise<Tool[]>
Defined in: src/tools/base.ts:147
Returns
Promise<Tool[]>
Implementation of
searchTools()
searchTools(
query,k?):Promise<Tool[]>
Defined in: src/tools/base.ts:149
Parameters
query
string
k?
number = 10
Returns
Promise<Tool[]>
Implementation of
invoke()
invoke(
toolName,args):Promise<{ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; }>
Defined in: src/tools/base.ts:162
Parameters
toolName
string
args
Returns
Promise<{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }>
Implementation of
asDelegated()
asDelegated(
options?):Tool
Defined in: src/tools/base.ts:171
Parameters
options?
DelegatedToolOptions = {}
Returns
Implementation of
Interfaces
LMSummarizingCompactorOptions
Defined in: src/agents/compaction.ts:77
Properties
model
model:
Model
Defined in: src/agents/compaction.ts:83
Model used for summarization. Pass the same model the agent uses or a cheaper one to decouple summarization cost from main-loop cost.
tokenBudget
tokenBudget:
number
Defined in: src/agents/compaction.ts:91
Trigger threshold expressed in characters of Message.content.
Compaction is a no-op while the cumulative content length is at
or below this number. Mirrors Python's max_chars knob (~4 chars
per token rough proxy that avoids a tokenizer dependency on the
hot path).
systemPrompt?
optionalsystemPrompt?:string
Defined in: src/agents/compaction.ts:98
Optional system prompt prepended to the summarization request. When omitted the summarizer is called with a single user message containing the prompt + formatted transcript (matches the Python baseline behaviour).
keepRecent?
optionalkeepRecent?:number
Defined in: src/agents/compaction.ts:103
Number of trailing messages to preserve verbatim. Defaults to 8 (~four assistant/tool turn pairs of fresh local context).
summaryHeader?
optionalsummaryHeader?:string
Defined in: src/agents/compaction.ts:109
Header prepended to the LM-generated summary in the replacement message. Helps the model recognize the user content as a synopsis of older turns rather than a fresh instruction.
summaryPrompt?
optionalsummaryPrompt?:string
Defined in: src/agents/compaction.ts:114
Override the default summarization prompt. The formatted transcript is appended to whatever you supply.
MemoryBlock
Defined in: src/agents/memoryFilter.ts:78
One filterable piece of memory.
id is namespaced (wm.<i>, obs.<i>, ref.<i>) so the filter
LM can distinguish tiers in the candidate list. kind duplicates
the namespace tag in a typed field so callers can match on it
without parsing the id. label is a short human-readable
description shown to the LM alongside the body.
Properties
id
id:
string
Defined in: src/agents/memoryFilter.ts:79
kind
kind:
"obs"|"wm"|"ref"
Defined in: src/agents/memoryFilter.ts:80
label
label:
string
Defined in: src/agents/memoryFilter.ts:81
body
body:
string
Defined in: src/agents/memoryFilter.ts:82
MemoryFilterReportedBlock
Defined in: src/agents/memoryFilter.ts:91
One memory block as reported to MemoryRelevanceFilterOptions
callers via the per-turn onComplete callback. preview is a short,
whitespace-collapsed projection of the block body so hosts can render
a compact "reading memory" row without streaming the full body.
Properties
id
id:
string
Defined in: src/agents/memoryFilter.ts:92
kind
kind:
"obs"|"wm"|"ref"
Defined in: src/agents/memoryFilter.ts:93
label
label:
string
Defined in: src/agents/memoryFilter.ts:94
preview
preview:
string
Defined in: src/agents/memoryFilter.ts:95
kept
kept:
boolean
Defined in: src/agents/memoryFilter.ts:96
MemoryFilterSummary
Defined in: src/agents/memoryFilter.ts:111
Per-turn outcome of MemoryRelevanceFilter.filterPrefix,
delivered to the optional onComplete callback. Unlike the tracer
memory_filter_complete event (counts only), this carries per-block
kept/dropped metadata so a host can surface exactly which observation
/ reflection / working-memory blocks stayed in context this turn.
skipped is set when the filter short-circuited without an LM call
(no_candidates, below_threshold, model_unavailable,
filter_error, parse_failure); noopReason is set when the LM ran
but the prefix was returned verbatim (kept_when_empty, all_kept).
Properties
kept
kept:
number
Defined in: src/agents/memoryFilter.ts:112
total
total:
number
Defined in: src/agents/memoryFilter.ts:113
blocks
blocks:
MemoryFilterReportedBlock[]
Defined in: src/agents/memoryFilter.ts:114
noopReason?
optionalnoopReason?:string
Defined in: src/agents/memoryFilter.ts:115
skipped?
optionalskipped?:string
Defined in: src/agents/memoryFilter.ts:116
PrefixDecomposition
Defined in: src/agents/memoryFilter.ts:134
Output of parseMemoryPrefix.
The original prefix is partitioned into three lists:
head/tail-- non-memory messages that came before / after the memory block run. The memory tiers always splice ahead of the raw history, soheadis typically empty andtailcarries the raw conversation history.blocks-- one MemoryBlock per filterable candidate.currentTask-- the trailing[Current task] ...line on the observation message, if any. Always preserved (not filtered) because the rolling state record is a single mutable hint, not a per-block candidate.
Properties
head
head:
object[]
Defined in: src/agents/memoryFilter.ts:135
role
role:
"system"|"user"|"assistant"|"tool"
content
content:
string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[]
String form is preserved verbatim for back-compat; the
ContentPart array form (Phase 3) lets producers attach
images and files to any message and annotate individual parts with
Anthropic-flavored cache_control. Consumers that only care about
the textual portion can call messageToText to flatten
either form to a string. See
docs/concepts/multimodal-content-and-cache-control.md for the
cross-language design.
name?
optionalname?:string|null
tool_calls?
optionaltool_calls?:object[] |null
tool_call_id?
optionaltool_call_id?:string|null
tail
tail:
object[]
Defined in: src/agents/memoryFilter.ts:136
role
role:
"system"|"user"|"assistant"|"tool"
content
content:
string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[]
String form is preserved verbatim for back-compat; the
ContentPart array form (Phase 3) lets producers attach
images and files to any message and annotate individual parts with
Anthropic-flavored cache_control. Consumers that only care about
the textual portion can call messageToText to flatten
either form to a string. See
docs/concepts/multimodal-content-and-cache-control.md for the
cross-language design.
name?
optionalname?:string|null
tool_calls?
optionaltool_calls?:object[] |null
tool_call_id?
optionaltool_call_id?:string|null
blocks
blocks:
MemoryBlock[]
Defined in: src/agents/memoryFilter.ts:137
wmMessageIndex
wmMessageIndex:
number|null
Defined in: src/agents/memoryFilter.ts:138
obsMessageIndex
obsMessageIndex:
number|null
Defined in: src/agents/memoryFilter.ts:139
refMessageIndex
refMessageIndex:
number|null
Defined in: src/agents/memoryFilter.ts:140
currentTask
currentTask:
string|null
Defined in: src/agents/memoryFilter.ts:141
wmOriginalDoc
wmOriginalDoc:
string
Defined in: src/agents/memoryFilter.ts:142
MemoryRelevanceFilterOptions
Defined in: src/agents/memoryFilter.ts:473
Properties
config
config:
object
Defined in: src/agents/memoryFilter.ts:474
model
model:
unknown
Background Model (or provider/slug string resolved via the
inference router) used to score relevance. Cheap / fast models
are the right choice: the filter runs on every chat turn that
carries a non-trivial memory prefix and never serves the user
directly. Required.
min_chars_to_filter
min_chars_to_filter:
number
Skip the filter entirely when the candidate memory prefix is
smaller than this many characters. Short prefixes are cheap to
ship verbatim and the extra LM round-trip costs more than the
savings. Set to 0 to filter unconditionally.
filter_observations
filter_observations:
boolean
When true (the default) the filter considers active observation
and reflection blocks as filterable candidates. Set false to
leave the observation tier intact.
filter_working_memory
filter_working_memory:
boolean
When true (the default) the filter splits the working-memory
doc on ## markdown headers and considers each section as a
filterable candidate. Set false to leave the doc intact.
keep_when_empty
keep_when_empty:
boolean
Behaviour when the LM votes to drop every candidate. When true
(the default) the original unfiltered prefix is preserved -- the
filter assumes a wholesale-drop verdict is more often a parsing
glitch than a true "nothing here matters" signal. Set false to
trust the LM and ship a memory-free prefix.
instructions?
optionalinstructions?:string|null
Optional override of the system prompt used by the filter LM. The default prompt asks the model to keep blocks that are directly relevant or that carry persistent facts (user identity, preferences, standing instructions).
ObservationBufferOptions
Defined in: src/agents/observationalMemory/buffer.ts:129
Properties
config
config:
object
Defined in: src/agents/observationalMemory/buffer.ts:130
model
model:
unknown
reflection_model?
optionalreflection_model?:unknown
message_chars
message_chars:
number
observation_chars
observation_chars:
number
buffer_fraction
buffer_fraction:
number
activation_fraction
activation_fraction:
number
block_after
block_after:
number
activate_after_idle?
optionalactivate_after_idle?:number|null
activate_on_provider_change
activate_on_provider_change:
boolean
enable_reflection
enable_reflection:
boolean
reflection_buffer_activation
reflection_buffer_activation:
number
reflection_block_after
reflection_block_after:
number
scope
scope:
"thread"|"resource"
Storage scope for observations and reflections. "thread"
(default) keeps the per-thread namespaces; "resource" is the
Mastra-style cross-thread mode that persists under
agent:<id>/resources/<rid>/observations and splices the
union of every thread's observations for the same resource into
the prefix. Per-thread last_observed_index accounting still
runs under the per-thread state namespace either way. Pass
resourceId on app.chat(...) to populate the namespace; runs
without a resource id fall back to thread-scope behaviour even
when the config opts in.
chars_per_token
chars_per_token:
number
keep_recent_messages
keep_recent_messages:
number
estimator?
optionalestimator?:unknown
Optional TokenEstimator consulted by ObservationBuffer
when computing per-message size. Typed as unknown to mirror the
Python schema's Any field; the buffer feature-detects via
typeof value.estimate === "function".
conversationStore
conversationStore:
ConversationStore
Defined in: src/agents/observationalMemory/buffer.ts:131
observationStore
observationStore:
ObservationStore
Defined in: src/agents/observationalMemory/buffer.ts:132
clock?
optionalclock?: () =>number
Defined in: src/agents/observationalMemory/buffer.ts:137
Injectable monotonic clock (seconds). Reserved for future short-window heuristics; tests may override to avoid sleeping.
Returns
number
now?
optionalnow?: () =>Date
Defined in: src/agents/observationalMemory/buffer.ts:142
Injectable wall-clock (used for last_activity_ts). Defaults to
() => new Date().
Returns
Date
ChatTurnContext
Defined in: src/agents/observationalMemory/context.ts:32
Properties
agentId
agentId:
string
Defined in: src/agents/observationalMemory/context.ts:33
threadId
threadId:
string
Defined in: src/agents/observationalMemory/context.ts:34
resourceId?
optionalresourceId?:string|null
Defined in: src/agents/observationalMemory/context.ts:43
Mastra-style "resource" identity (typically the human user)
propagated from app.chat(..., resourceId). undefined when
the caller did not supply one. The proxy injection site reads
this and constructs an ObservationsProxy over the resource
pool when both this id is set and the buffer's config opted
into resource scope.
buffer?
optionalbuffer?:ObservationBuffer|null
Defined in: src/agents/observationalMemory/context.ts:55
Active ObservationBuffer for the turn. Optional so that
chats configured with working memory but no observational
memory still get a context bound — the binding criterion is
"at least one tier is configured", not "OM is configured".
Maniac.chat sets this to null when the per-call
memory.observational is "off", even if the app has a
buffer configured, so the observations proxy is a no-op
for that turn.
workingMemoryRunner?
optionalworkingMemoryRunner?:WorkingMemoryRunner|null
Defined in: src/agents/observationalMemory/context.ts:66
Active WorkingMemoryRunner for the turn. Read by the
built-in remember(note) tool to persist user-flagged notes
under the configured working-memory namespace.
Maniac.chat sets this to null when the per-call
memory.working is anything other than "write", hiding
the remember tool for that turn (read-mode users see the
existing doc in the prefix but cannot mutate it).
access?
optionalaccess?: {observational:"read"|"write"|"off";working:"read"|"write"|"off"; } |null
Defined in: src/agents/observationalMemory/context.ts:74
Resolved per-call memory access for this turn. Most call
sites can ignore this: buffer / workingMemoryRunner are
already gated to null in modes where reads/writes are
forbidden. Carried so downstream code can distinguish
"off" from "read" if it needs to (and for tests).
Union Members
Type Literal
{ observational: "read" | "write" | "off"; working: "read" | "write" | "off"; }
observational
observational:
"read"|"write"|"off"
Mode for observational memory (the ObservationBuffer tier).
When the app has no ObservationBuffer configured this field is
ignored and the runtime treats the layer as "off" regardless.
working
working:
"read"|"write"|"off"
Mode for working memory (the singleton mutable doc).
When the app has no WorkingMemoryRunner configured this field is
ignored and the runtime treats the layer as "off" regardless.
null
ObserveOptions
Defined in: src/agents/observationalMemory/observer.ts:112
Properties
model
model:
Model
Defined in: src/agents/observationalMemory/observer.ts:113
messages
messages: readonly
object[]
Defined in: src/agents/observationalMemory/observer.ts:114
fromIndex
fromIndex:
number
Defined in: src/agents/observationalMemory/observer.ts:115
toIndex
toIndex:
number
Defined in: src/agents/observationalMemory/observer.ts:116
providerModel?
optionalproviderModel?:string|null
Defined in: src/agents/observationalMemory/observer.ts:117
status?
optionalstatus?:"buffered"|"active"
Defined in: src/agents/observationalMemory/observer.ts:118
ObservationsProxyOptions
Defined in: src/agents/observationalMemory/proxy.ts:37
Properties
buffer
buffer:
ObservationBuffer
Defined in: src/agents/observationalMemory/proxy.ts:38
agentId
agentId:
string
Defined in: src/agents/observationalMemory/proxy.ts:39
threadId
threadId:
string
Defined in: src/agents/observationalMemory/proxy.ts:40
resourceId?
optionalresourceId?:string|null
Defined in: src/agents/observationalMemory/proxy.ts:50
Mastra-style "resource" identity propagated from
app.chat(..., resourceId). Resolved through the buffer's
effectiveResourceId so the proxy only reads from the cross-
thread resource pool when both this id is supplied and the
buffer's config opted into resource scope. Otherwise observation
/ reflection lookups fall back to the per-thread namespace,
preserving the original behaviour.
ReflectOptions
Defined in: src/agents/observationalMemory/reflector.ts:45
Properties
model
model:
Model
Defined in: src/agents/observationalMemory/reflector.ts:46
observations
observations: readonly
object[]
Defined in: src/agents/observationalMemory/reflector.ts:47
fromIndex
fromIndex:
number
Defined in: src/agents/observationalMemory/reflector.ts:48
toIndex
toIndex:
number
Defined in: src/agents/observationalMemory/reflector.ts:49
providerModel?
optionalproviderModel?:string|null
Defined in: src/agents/observationalMemory/reflector.ts:50
status?
optionalstatus?:"buffered"|"active"
Defined in: src/agents/observationalMemory/reflector.ts:51
WorkingMemoryRunnerOptions
Defined in: src/agents/observationalMemory/workingMemory.ts:153
Properties
config
config:
object
Defined in: src/agents/observationalMemory/workingMemory.ts:154
model
model:
unknown
Background Model (or provider/slug string resolved by the
inference router) used by the updater. Cheap / fast models are
appropriate; this runs on every chat boundary and never serves
the user directly.
template
template:
string
Markdown template the LM uses as the structural skeleton for the working-memory doc. Empty string means "no template" -- the LM produces a free-form doc.
scope
scope:
"thread"|"resource"
"resource" (default) pools the doc across every thread for
the same resourceId passed on app.chat(...). "thread"
keeps a per-thread doc, useful for ephemeral session-only
profiles.
update_after_every_turn
update_after_every_turn:
boolean
When true (the default) the runner schedules a background
update LM call after every chat turn. Set to false for hand-
managed docs that the application updates directly via
WorkingMemoryStore.save (or proactively via the
remember(note) built-in tool).
max_chars
max_chars:
number
Soft cap on the working-memory doc size, enforced by the updater prompt. Defaults to 4000 characters.
enable_update_tool
enable_update_tool:
boolean
When true (the default) and this config is wired into a
Maniac app, the built-in remember(note) tool is auto-
injected into every agent so the agent can proactively
persist user-flagged facts mid-turn (for example when the
user says "please remember to always cite your sources").
Set false for hand-managed docs that only the reflective
post-turn updater (or direct WorkingMemoryStore.save
calls) should touch.
note_section
note_section:
string
Markdown section header under which remember(note) appends
new bullets. The tool creates the section as a
## <note_section> heading on the first call if it doesn't
already exist in the doc.
store
store:
WorkingMemoryStore
Defined in: src/agents/observationalMemory/workingMemory.ts:155
InterruptedRunPartial
Defined in: src/agents/runner.ts:330
Best-effort snapshot of the run state at the moment an interrupt fired.
Carries the in-flight transcript, last-observed iteration counter,
accumulated usage, and trace events so callers (notably
Maniac.chat / chatStream in Maniac) can persist progress
before the original exception propagates.
Properties
messages
messages:
object[]
Defined in: src/agents/runner.ts:331
role
role:
"system"|"user"|"assistant"|"tool"
content
content:
string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[]
String form is preserved verbatim for back-compat; the
ContentPart array form (Phase 3) lets producers attach
images and files to any message and annotate individual parts with
Anthropic-flavored cache_control. Consumers that only care about
the textual portion can call messageToText to flatten
either form to a string. See
docs/concepts/multimodal-content-and-cache-control.md for the
cross-language design.
name?
optionalname?:string|null
tool_calls?
optionaltool_calls?:object[] |null
tool_call_id?
optionaltool_call_id?:string|null
iterations
iterations:
number
Defined in: src/agents/runner.ts:332
usage
usage:
object
Defined in: src/agents/runner.ts:333
prompt
prompt:
number
completion
completion:
number
cost_usd?
optionalcost_usd?:number|null
cache_creation_input_tokens?
optionalcache_creation_input_tokens?:number|null
cache_read_input_tokens?
optionalcache_read_input_tokens?:number|null
trace
trace: ({
ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"token";payload: {[key:string]:unknown;model?:string;scope?:string;iteration?:number;toolset?:string|null;lm_span_id?:string|null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:string|null;raw_finish_reason?:string|null; };delta:string;chunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null;content_part_kind?:"file"|"text"|"image"|null;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call_start";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;toolset?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:string;toolset?:string|null;raw_finish_reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool";payload: {[key:string]:unknown;tool_call_id:string;tool_name:string;toolset?:string|null;phase:"completed"|"failed"|"cancelled"|"started";args?:JsonDict;result?:JsonDict|null;result_preview?: {[key:string]:unknown;ok?:boolean;value?:unknown;error?:string|null;metadata?:JsonDict|null;result_truncated?:boolean;value_omitted_reason?:string|null; } |null;ok?:boolean|null;allowed?:boolean|null;error?:string|null;reason?:string|null;started_at?:string|null;finished_at?:string|null;elapsed_ms?:number|null;decision?: {[key:string]:unknown;allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool_call_arguments_delta";payload: {[key:string]:unknown;tool_call_id?:string|null;tool_name?:string|null;index:number;arguments_delta:string;sequence:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"cell";payload: {[key:string]:unknown;cell_id:string;phase:"completed"|"failed"|"cancelled"|"started";code?:string|null;result?:JsonDict|null;error?:string|null;elapsed_ms?:number|null;stdout_len?:number|null;stderr_len?:number|null;variables?:string[] |null;src?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"subagent";payload: {[key:string]:unknown;phase:"error"|"completed"|"intent"|"start"|"paused"|"errored";agent_id?:string|null;toolset?:string|null;role?:string|null;prompt_summary?:string|null;prompt?:string|null;parent_span_id?:string|null;background?:boolean|null;iterations?:number|null;reason?:string|null;max_depth?:number|null;repl?:boolean|null;usage?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"agent";payload: {[key:string]:unknown;phase:"completed"|"started";agent_id:string;principal?:string|null;iterations?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"approval";payload: {[key:string]:unknown;phase:"requested"|"approved"|"denied"|"resolved";id?:string;toolset?:string|null;tool?:string|null;rule_id?:string|null;reason?:string|null;source:"guardrail"|"policy";decision?:"approve"|"deny"|null;approvals:object[]; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"memory";payload: {[key:string]:unknown;op:string;phase?:string|null;principal?:string|null;depth?:number|null;summary?:string|null;namespace?:string|null;agent_id?:string|null;thread_id?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"guardrail";payload: {[key:string]:unknown;phase:string;boundary?:string|null;action?:string|null;decision?:string|null;rule_id?:string|null;reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"background_task";payload: {[key:string]:unknown;phase:string;task_id:string;status?:string|null;progress?:number|null;output?:JsonDict|null;agent_id?:string|null;sub_agent_id?:string|null;tool?:string|null;attempt?:number|null;error?:string|null;iterations?:number|null;timeout_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"step";payload: {[key:string]:unknown;phase:"before"|"after"|"repair"|"stopped"|"finalize_vetoed";turn_index:number;iteration?:number|null;source?:string|null;reason?:string|null;elapsed_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"retry";payload: {[key:string]:unknown;attempt:number;reason:string;model?:string|null;max_attempts?:number|null;delay_s?:number|null;fallback?:boolean|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"final";payload: {[key:string]:unknown;source:string;iterations?:number|null;validated?:boolean|null;error?:string|null;pending?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"error";payload: {[key:string]:unknown;message:string;kind_of_error?:string|null;cause?:string|null;retryable?:boolean|null;reason?:string|null;detail?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"stream_gap";payload: {[key:string]:unknown;dropped_count_so_far:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"plan";payload: {[key:string]:unknown;entries:object[]; }; })[]
Defined in: src/agents/runner.ts:334
Embedder
Defined in: src/memory/adapters/vector.ts:54
Embed a batch of strings to a list of dense float vectors.
- Returns one vector per input string, in the same order.
- Every vector has the same dimensionality across calls.
- An empty input array returns an empty array.
Methods
embed()
embed(
texts):Promise<number[][]>
Defined in: src/memory/adapters/vector.ts:55
Parameters
texts
string[]
Returns
Promise<number[][]>
VectorIndex
Defined in: src/memory/adapters/vector.ts:68
k-NN index over (id, embedding, metadata) tuples.
query returns hits ordered by score descending. delete is
optional; the wrapper feature-detects it via typeof === "function"
so adapters whose backing store can't delete can simply omit the
method.
Methods
upsert()
upsert(
items):Promise<void>
Defined in: src/memory/adapters/vector.ts:69
Parameters
items
readonly [string, number[], Record<string, unknown>][]
Returns
Promise<void>
query()
query(
embedding,k):Promise<VectorHit[]>
Defined in: src/memory/adapters/vector.ts:70
Parameters
embedding
number[]
k
number
Returns
Promise<VectorHit[]>
delete()?
optionaldelete(id):Promise<boolean>
Defined in: src/memory/adapters/vector.ts:71
Parameters
id
string
Returns
Promise<boolean>
SqliteVectorIndexOptions
Defined in: src/memory/adapters/vector.ts:106
Properties
filename?
optionalfilename?:string
Defined in: src/memory/adapters/vector.ts:112
Open a database at filename and own its lifecycle. Use
":memory:" for an in-process database (handy for tests).
Mutually exclusive with SqliteVectorIndexOptions.database.
database?
optionaldatabase?:DatabaseSync
Defined in: src/memory/adapters/vector.ts:119
Bring-your-own DatabaseSync handle. The index never closes
borrowed handles. Pass SqliteMemory.database here to share
one connection / WAL file with the canonical record store.
Mutually exclusive with SqliteVectorIndexOptions.filename.
tableName?
optionaltableName?:string
Defined in: src/memory/adapters/vector.ts:125
Override the table name. Defaults to maniac_vector_index, so it
coexists with SqliteMemory's maniac_memory* tables in a shared
database file.
VectorMemoryOptions
Defined in: src/memory/adapters/vector.ts:248
Properties
base
base:
Memory
Defined in: src/memory/adapters/vector.ts:249
embedder
embedder:
Embedder
Defined in: src/memory/adapters/vector.ts:250
index?
optionalindex?:VectorIndex
Defined in: src/memory/adapters/vector.ts:252
Defaults to InMemoryVectorIndex.
textKey?
optionaltextKey?:string
Defined in: src/memory/adapters/vector.ts:260
When the record content is an object, embed content[textKey]
(or content[textKey].text if that field is itself an object).
Useful for envelope-style records like ObservationStore's
{ observation: { text, ... } }. Defaults to embedding the
full JSON-serialised content.
HonchoConversationStoreOptions
Defined in: src/memory/honchoConversation.ts:52
Properties
maxTurns?
optionalmaxTurns?:number
Defined in: src/memory/honchoConversation.ts:54
Forwarded to ConversationStore.
tokenBudget?
optionaltokenBudget?:number
Defined in: src/memory/honchoConversation.ts:61
Token budget passed as tokens to session.context(...). The
Honcho server allocates 40% to the summary and 60% to recent
messages by default; bump this value when you hit a model that
wants more context.
HonchoWorkingMemoryStoreOptions
Defined in: src/memory/honchoWorkingMemory.ts:20
Properties
peerCardKey?
optionalpeerCardKey?:string
Defined in: src/memory/honchoWorkingMemory.ts:27
Key used on the Honcho peer card to store the doc. Single-key shape keeps the doc's structure intact (no Honcho-side schema parsing); choose a different key only when the host application also writes its own keys to the peer card.
WorkingMemoryOriginOptions
Defined in: src/memory/workingMemory.ts:40
Properties
resourceId?
optionalresourceId?:string|null
Defined in: src/memory/workingMemory.ts:42
Resource scope; mirrors ObservationStore's same-named option.
Agent
Defined in: src/schemas/agents.ts:715
Properties
id
id:
string
Defined in: src/schemas/agents.ts:716
instructions
instructions:
string|InstructionsBuilder
Defined in: src/schemas/agents.ts:717
model
model:
Model
Defined in: src/schemas/agents.ts:718
tools?
optionaltools?:Tool[]
Defined in: src/schemas/agents.ts:719
toolsets?
optionaltoolsets?:Toolset[]
Defined in: src/schemas/agents.ts:720
repl?
optionalrepl?:ReplConfigInput|null
Defined in: src/schemas/agents.ts:721
memory?
optionalmemory?:Memory|null
Defined in: src/schemas/agents.ts:722
observational_memory?
optionalobservational_memory?: {model:unknown;reflection_model?:unknown;message_chars:number;observation_chars:number;buffer_fraction:number;activation_fraction:number;block_after:number;activate_after_idle?:number|null;activate_on_provider_change:boolean;enable_reflection:boolean;reflection_buffer_activation:number;reflection_block_after:number;scope:"thread"|"resource";chars_per_token:number;keep_recent_messages:number;estimator?:unknown; } |null
Defined in: src/schemas/agents.ts:723
Union Members
Type Literal
{ model: unknown; reflection_model?: unknown; message_chars: number; observation_chars: number; buffer_fraction: number; activation_fraction: number; block_after: number; activate_after_idle?: number | null; activate_on_provider_change: boolean; enable_reflection: boolean; reflection_buffer_activation: number; reflection_block_after: number; scope: "thread" | "resource"; chars_per_token: number; keep_recent_messages: number; estimator?: unknown; }
model
model:
unknown
reflection_model?
optionalreflection_model?:unknown
message_chars
message_chars:
number
observation_chars
observation_chars:
number
buffer_fraction
buffer_fraction:
number
activation_fraction
activation_fraction:
number
block_after
block_after:
number
activate_after_idle?
optionalactivate_after_idle?:number|null
activate_on_provider_change
activate_on_provider_change:
boolean
enable_reflection
enable_reflection:
boolean
reflection_buffer_activation
reflection_buffer_activation:
number
reflection_block_after
reflection_block_after:
number
scope
scope:
"thread"|"resource"
Storage scope for observations and reflections. "thread"
(default) keeps the per-thread namespaces; "resource" is the
Mastra-style cross-thread mode that persists under
agent:<id>/resources/<rid>/observations and splices the
union of every thread's observations for the same resource into
the prefix. Per-thread last_observed_index accounting still
runs under the per-thread state namespace either way. Pass
resourceId on app.chat(...) to populate the namespace; runs
without a resource id fall back to thread-scope behaviour even
when the config opts in.
chars_per_token
chars_per_token:
number
keep_recent_messages
keep_recent_messages:
number
estimator?
optionalestimator?:unknown
Optional TokenEstimator consulted by ObservationBuffer
when computing per-message size. Typed as unknown to mirror the
Python schema's Any field; the buffer feature-detects via
typeof value.estimate === "function".
null
policy?
optionalpolicy?:PermissionPolicy|null
Defined in: src/schemas/agents.ts:724
max_depth?
optionalmax_depth?:number
Defined in: src/schemas/agents.ts:725
budget?
optionalbudget?:object
Defined in: src/schemas/agents.ts:726
max_iterations
max_iterations:
number
max_tokens?
optionalmax_tokens?:number|null
max_cost_usd?
optionalmax_cost_usd?:number|null
max_wall_seconds?
optionalmax_wall_seconds?:number|null
lm_middleware?
optionallm_middleware?:LMMiddleware[]
Defined in: src/schemas/agents.ts:727
tool_middleware?
optionaltool_middleware?:ToolMiddleware[]
Defined in: src/schemas/agents.ts:728
lm_guardrails?
optionallm_guardrails?:LMGuardrail[]
Defined in: src/schemas/agents.ts:729
tool_guardrails?
optionaltool_guardrails?:ToolGuardrail[]
Defined in: src/schemas/agents.ts:730
output_model?
optionaloutput_model?:unknown
Defined in: src/schemas/agents.ts:731
output_repair_attempts?
optionaloutput_repair_attempts?:number
Defined in: src/schemas/agents.ts:732
background?
optionalbackground?:AgentBackgroundConfig|null
Defined in: src/schemas/agents.ts:733
step_hooks?
optionalstep_hooks?:StepHook[]
Defined in: src/schemas/agents.ts:743
List of StepHook instances that fire around each
iteration of the agent loop: beforeStep may rewrite the
request or short-circuit; shouldStop is a custom termination
predicate; afterStep is observational; beforeFinalize may
veto the no-tool-calls termination path. Hooks compose
left-to-right and are invoked in registered order. Mirrors
Python Agent.step_hooks.
prepare_step?
optionalprepare_step?:PrepareStep|null
Defined in: src/schemas/agents.ts:749
Sugar form of beforeStep. Folded into a synthesized
CallableStepHook prepended to step_hooks by the
runner's spec normalizer. Mirrors Python Agent.prepare_step.
stop_when?
optionalstop_when?:StopWhen|null
Defined in: src/schemas/agents.ts:754
Sugar form of shouldStop. Same fold-into-step_hooks
treatment as prepare_step. Mirrors Python Agent.stop_when.
reasoning?
optionalreasoning?: {effort?:"minimal"|"low"|"medium"|"high"|null;max_tokens?:number|null;summary?:"auto"|"concise"|"detailed"|null; } |null
Defined in: src/schemas/agents.ts:772
Default reasoning configuration applied to every LM call this
agent makes. The runner attaches this to InferenceRequest.reasoning
before invoking the model, so adapters that recognize the field
(OpenAI-compatible: reasoning_effort; Anthropic: thinking)
pick it up automatically.
Per-call overrides (e.g. a prepare_step hook that sets
request.reasoning to a different shape) take precedence: when
the hook leaves request.reasoning non-null the runner does NOT
merge the spec default on top of it. Setting this to null (or
leaving it unset) restores pre-Phase-4 behavior, where the field
is never sent.
See schemas/inference.ts::ReasoningConfigSchema for the field
shape and the per-provider serialization contract.
Union Members
Type Literal
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; }
effort?
optionaleffort?:"minimal"|"low"|"medium"|"high"|null
max_tokens?
optionalmax_tokens?:number|null
Hard cap on the reasoning token budget. When set:
- Anthropic adapter forwards it as
thinking.budget_tokens. - OpenAI-compatible adapter ignores it (chat completions has no
per-call budget knob beyond
max_completion_tokens); callers wanting a hard cap on OpenAI should setInferenceRequest.max_tokens.
summary?
optionalsummary?:"auto"|"concise"|"detailed"|null
OpenAI Responses-style summary verbosity. Recognized by adapters that hit the Responses API; ignored by chat-completions adapters.
null
plans_enabled?
optionalplans_enabled?:boolean
Defined in: src/schemas/agents.ts:783
When true, auto-inject the built-in set_plan tool so the LM
can publish/replace an execution plan during the run. Plans
surface through the trace stream as TraceEvent with
kind === "plan" carrying a PlanPayload; the ACP server
adapter forwards them verbatim as session/update sessionUpdate=plan notifications. Defaults to false (opt-in)
to keep the LM tool surface unchanged for agents that don't
need explicit planning. Mirrors Python Agent.plans_enabled.
Sandbox
Defined in: src/schemas/execution.ts:32
Methods
run()
run(
code):Promise<{cell: {code:string;stdout:string;stderr:string;truncated:boolean;elapsed_ms:number; };variables:Record<string, {name:string;type_name:string;size_bytes:number;summary?:string|null; }>; }>
Defined in: src/schemas/execution.ts:33
Parameters
code
string
Returns
Promise<{ cell: { code: string; stdout: string; stderr: string; truncated: boolean; elapsed_ms: number; }; variables: Record<string, { name: string; type_name: string; size_bytes: number; summary?: string | null; }>; }>
getVar()
getVar(
name):Promise<unknown>
Defined in: src/schemas/execution.ts:34
Parameters
name
string
Returns
Promise<unknown>
setVar()
setVar(
name,value):Promise<void>
Defined in: src/schemas/execution.ts:35
Parameters
name
string
value
unknown
Returns
Promise<void>
injectCallable()
injectCallable(
name,fn):Promise<void>
Defined in: src/schemas/execution.ts:36
Parameters
name
string
fn
unknown
Returns
Promise<void>
aclose()
aclose():
Promise<void>
Defined in: src/schemas/execution.ts:37
Returns
Promise<void>
ExecutionEnvironment
Defined in: src/schemas/execution.ts:40
Properties
state
state:
object
Defined in: src/schemas/execution.ts:41
variables
variables:
Record<string, {name:string;type_name:string;size_bytes:number;summary?:string|null; }>
cells
cells:
object[]
Methods
execute()
execute(
code):Promise<{code:string;stdout:string;stderr:string;truncated:boolean;elapsed_ms:number; }>
Defined in: src/schemas/execution.ts:42
Parameters
code
string
Returns
Promise<{ code: string; stdout: string; stderr: string; truncated: boolean; elapsed_ms: number; }>
getVar()
getVar(
name):Promise<unknown>
Defined in: src/schemas/execution.ts:43
Parameters
name
string
Returns
Promise<unknown>
setVar()
setVar(
name,value):Promise<void>
Defined in: src/schemas/execution.ts:44
Parameters
name
string
value
unknown
Returns
Promise<void>
inject()
inject(
name,fn):Promise<void>
Defined in: src/schemas/execution.ts:45
Parameters
name
string
fn
unknown
Returns
Promise<void>
aclose()?
optionalaclose():Promise<void>
Defined in: src/schemas/execution.ts:46
Returns
Promise<void>
Model
Defined in: src/schemas/inference.ts:480
Properties
id
id:
string
Defined in: src/schemas/inference.ts:481
slug
slug:
string
Defined in: src/schemas/inference.ts:482
Methods
infer()
infer(
req,opts?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/schemas/inference.ts:483
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
stream()
stream(
req,opts?):AsyncIterable<{kind:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control";delta:string;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:"length"|"error"|"stop"|null;raw_finish_reason?:string|null;content_part_kind?:"file"|"text"|"image"|null; }>
Defined in: src/schemas/inference.ts:484
Parameters
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
opts?
Returns
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
SupportsModelCatalog
Defined in: src/schemas/inference.ts:579
Optional capability interface for adapters that can enumerate models.
Deliberately separate from Model (which every adapter
implements) so model discovery stays a strictly additive capability:
consumers feature-detect it via supportsModelCatalog, and
adapters that can't list simply don't implement listModels (or throw
ModelCatalogUnsupportedError). Mirrors Python's
SupportsModelCatalog Protocol.
Methods
listModels()
listModels(
opts?):Promise<object[]>
Defined in: src/schemas/inference.ts:580
Parameters
opts?
Returns
Promise<object[]>
Memory
Defined in: src/schemas/memory.ts:26
Methods
save()
save(
record,scope):Promise<string>
Defined in: src/schemas/memory.ts:27
Parameters
record
id
string = ...
namespace
string = ...
content
unknown = ...
metadata
Record<string, unknown> = ...
created_at
string = ...
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<string>
load()
load(
id,scope):Promise<{id:string;namespace:string;content:unknown;metadata:Record<string,unknown>;created_at:string; } |null>
Defined in: src/schemas/memory.ts:28
Parameters
id
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<{ id: string; namespace: string; content: unknown; metadata: Record<string, unknown>; created_at: string; } | null>
search()
search(
query,scope):Promise<object[]>
Defined in: src/schemas/memory.ts:29
Parameters
query
text?
string | null = ...
namespace?
string | null = ...
filters
Record<string, unknown> = ...
k
number = ...
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<object[]>
delete()
delete(
id,scope):Promise<boolean>
Defined in: src/schemas/memory.ts:30
Parameters
id
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<boolean>
MemorySequencer
Defined in: src/schemas/memory.ts:33
Methods
nextSequence()
nextSequence(
namespace,key,scope):Promise<number>
Defined in: src/schemas/memory.ts:34
Parameters
namespace
string
key
string
scope
read
string[] = ...
write
string[] = ...
Returns
Promise<number>
TokenEstimator
Defined in: src/schemas/memory.ts:83
Optional token estimator. Implementations expose estimate(text) and
are consulted by ObservationBuffer when computing the
unobserved-tail size in chars (despite the name -- mirrors Python's
_chars_for_messages which tolerates an estimator returning either
raw chars or token-equivalent integers). When absent, the buffer
falls back to text.length.
Methods
estimate()
estimate(
text):number
Defined in: src/schemas/memory.ts:84
Parameters
text
string
Returns
number
LMMiddleware
Defined in: src/schemas/middleware.ts:116
Methods
beforeLmCall()?
optionalbeforeLmCall(ctx,req):Promise<{messages:object[];response_format:"text"|"json";max_tokens?:number|null;temperature?:number|null;top_p?:number|null;top_k?:number|null;frequency_penalty?:number|null;presence_penalty?:number|null;seed?:number|null;logit_bias?:Record<string,number> |null;stop:string[];tools:object[];tool_choice: {kind:"named";name:string; } |"auto"|"required"|"none";parallel_tool_calls?:boolean|null;user?:string|null;reasoning?: {effort?:"minimal"|"low"|"medium"|"high"|null;max_tokens?:number|null;summary?:"auto"|"concise"|"detailed"|null; } |null; }>
Defined in: src/schemas/middleware.ts:117
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
iteration
number = ...
toolset?
string | null = ...
span_id
string = ...
parent_span_id?
string | null = ...
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
Returns
Promise<{ messages: object[]; response_format: "text" | "json"; max_tokens?: number | null; temperature?: number | null; top_p?: number | null; top_k?: number | null; frequency_penalty?: number | null; presence_penalty?: number | null; seed?: number | null; logit_bias?: Record<string, number> | null; stop: string[]; tools: object[]; tool_choice: { kind: "named"; name: string; } | "auto" | "required" | "none"; parallel_tool_calls?: boolean | null; user?: string | null; reasoning?: { effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null; }>
afterLmCall()?
optionalafterLmCall(ctx,req,resp):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/schemas/middleware.ts:118
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
iteration
number = ...
toolset?
string | null = ...
span_id
string = ...
parent_span_id?
string | null = ...
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
ToolMiddleware
Defined in: src/schemas/middleware.ts:125
Methods
beforeInvoke()?
optionalbeforeInvoke(ctx,call):Promise<{toolset?:string|null;tool:string;args:JsonDict;principal:string; }>
Defined in: src/schemas/middleware.ts:126
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
toolset
string = ...
iteration
number = ...
subagent_span_id?
string | null = ...
call
toolset?
string | null = ...
tool
string = ...
args
JsonDict = ...
principal
string = ...
Returns
Promise<{ toolset?: string | null; tool: string; args: JsonDict; principal: string; }>
afterInvoke()?
optionalafterInvoke(ctx,call,result):Promise<{ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; }>
Defined in: src/schemas/middleware.ts:127
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
toolset
string = ...
iteration
number = ...
subagent_span_id?
string | null = ...
call
toolset?
string | null = ...
tool
string = ...
args
JsonDict = ...
principal
string = ...
result
ok
boolean = ...
value?
unknown = ...
error?
string | null = ...
metadata
Record<string, unknown> = ...
cause?
{ kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null = ...
Optional structured cause for failed results. Populated by the tool()
helper (and any adapter that wants to preserve thrown error context),
so consumers can distinguish validation vs. runtime failures and read
the original error name/stack without the public ok: false
discriminator changing shape.
Returns
Promise<{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }>
LMGuardrail
Defined in: src/schemas/middleware.ts:134
Methods
checkInput()?
optionalcheckInput(ctx,req):Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/schemas/middleware.ts:135
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
iteration
number = ...
toolset?
string | null = ...
span_id
string = ...
parent_span_id?
string | null = ...
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
checkOutput()?
optionalcheckOutput(ctx,req,resp):Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/schemas/middleware.ts:136
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
iteration
number = ...
toolset?
string | null = ...
span_id
string = ...
parent_span_id?
string | null = ...
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
ToolGuardrail
Defined in: src/schemas/middleware.ts:143
Methods
checkCall()?
optionalcheckCall(ctx,call):Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/schemas/middleware.ts:144
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
toolset
string = ...
iteration
number = ...
subagent_span_id?
string | null = ...
call
toolset?
string | null = ...
tool
string = ...
args
JsonDict = ...
principal
string = ...
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
checkResult()?
optionalcheckResult(ctx,call,result):Promise<{action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }>
Defined in: src/schemas/middleware.ts:145
Parameters
ctx
principal
string = ...
scope
"root" | "subagent" = ...
toolset
string = ...
iteration
number = ...
subagent_span_id?
string | null = ...
call
toolset?
string | null = ...
tool
string = ...
args
JsonDict = ...
principal
string = ...
result
ok
boolean = ...
value?
unknown = ...
error?
string | null = ...
metadata
Record<string, unknown> = ...
cause?
{ kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null = ...
Optional structured cause for failed results. Populated by the tool()
helper (and any adapter that wants to preserve thrown error context),
so consumers can distinguish validation vs. runtime failures and read
the original error name/stack without the public ok: false
discriminator changing shape.
Returns
Promise<{ action: "allow"; rule_id?: string | null; reason?: string | null; } | { action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; } | { action: "block"; rule_id?: string | null; reason?: string | null; } | { action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }>
PermissionPolicy
Defined in: src/schemas/permissions.ts:89
Methods
evaluate()
evaluate(
action): {allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; } |Promise<{allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; }>
Defined in: src/schemas/permissions.ts:90
Parameters
action
principal
string = ...
call
{ toolset?: string | null; tool: string; args: JsonDict; principal: string; } = RuntimeToolCallSchema
call.toolset?
string | null = ...
call.tool
string = ...
call.args
JsonDict = ...
call.principal
string = ...
Returns
{ allowed: boolean; requires_approval: boolean; matched_rule_id?: string | null; reason?: string | null; } | Promise<{ allowed: boolean; requires_approval: boolean; matched_rule_id?: string | null; reason?: string | null; }>
evaluateMany()?
optionalevaluateMany(actions):object[] |Promise<object[]>
Defined in: src/schemas/permissions.ts:98
Optional batched evaluator (Tier 2 #8). Default implementations
live in permissions/policy.ts::evaluateMany and just loop over
evaluate; the runner calls it from the sub-action fan-out so
HTTP/DB-backed policies can answer N pending actions in a single
round-trip.
Parameters
actions
object[]
Returns
object[] | Promise<object[]>
Tool
Defined in: src/schemas/tools.ts:65
Properties
name
name:
string
Defined in: src/schemas/tools.ts:66
description
description:
string
Defined in: src/schemas/tools.ts:67
input_schema
input_schema:
JsonDict
Defined in: src/schemas/tools.ts:68
output_schema?
optionaloutput_schema?:JsonDict|null
Defined in: src/schemas/tools.ts:69
tags
tags:
string[]
Defined in: src/schemas/tools.ts:70
background?
optionalbackground?:unknown
Defined in: src/schemas/tools.ts:71
delegated?
optionaldelegated?:boolean
Defined in: src/schemas/tools.ts:72
toolset?
optionaltoolset?:string|null
Defined in: src/schemas/tools.ts:80
Tier 2 #6: optional explicit toolset attribution. When set, the
runner prefers it over the name.split(".", 2) heuristic in
runner.ts::invokeToolCall. Adapters that already produce
namespaced tool names (MCPToolset, ComposioToolset, etc.) can
keep the heuristic by leaving this unset.
delegated_tool?
optionaldelegated_tool?:boolean
Defined in: src/schemas/tools.ts:89
Tier 1 #2: optional structural flag indicating the tool is a
batched delegate — one LM-side call routes N upstream invocations
through extractSubActions. The runner special-cases the
permission/approval path for these tools so each sub-action is
evaluated independently and a single PendingApproval is minted
carrying per-sub metadata under sub_actions.
Methods
extractSubActions()?
optionalextractSubActions(args):object[]
Defined in: src/schemas/tools.ts:97
Synchronous expansion callback used when delegated_tool === true.
Returns the per-sub-action breakdown of an inbound args dict;
the runner calls it exactly once before policy evaluation. When
unset, the batched-expansion path is skipped even if the flag is
set (the runner falls back to a single-action evaluation).
Parameters
args
Returns
object[]
invoke()
invoke(
args):Promise<{ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; }>
Defined in: src/schemas/tools.ts:98
Parameters
args
Returns
Promise<{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }>
Toolset
Defined in: src/schemas/tools.ts:101
Properties
name
name:
string
Defined in: src/schemas/tools.ts:102
description
description:
string
Defined in: src/schemas/tools.ts:103
Methods
listTools()
listTools():
Promise<Tool[]>
Defined in: src/schemas/tools.ts:104
Returns
Promise<Tool[]>
searchTools()
searchTools(
query,k?):Promise<Tool[]>
Defined in: src/schemas/tools.ts:105
Parameters
query
string
k?
number
Returns
Promise<Tool[]>
asDelegated()
asDelegated(
options?):Tool
Defined in: src/schemas/tools.ts:106
Parameters
options?
instructions?
string
model?
unknown
max_depth?
number
Returns
invoke()
invoke(
tool,args):Promise<{ok:boolean;value?:unknown;error?:string|null;metadata:Record<string,unknown>;cause?: {kind:"validation"|"runtime";name?:string;message?:string;stack?:string|null;code?:string|null;metadata?:JsonDict; } |null; }>
Defined in: src/schemas/tools.ts:107
Parameters
tool
string
args
Returns
Promise<{ ok: boolean; value?: unknown; error?: string | null; metadata: Record<string, unknown>; cause?: { kind: "validation" | "runtime"; name?: string; message?: string; stack?: string | null; code?: string | null; metadata?: JsonDict; } | null; }>
MCPClientSession
Defined in: src/tools/adapters/mcp.ts:47
Minimal duck-typed MCP client surface that MCPToolset relies on.
Real production use wraps @modelcontextprotocol/sdk's Client
(which conforms by virtue of having listTools / callTool).
Tests inject their own implementation via sessionFactory.
Methods
listTools()
listTools(
params?):Promise<{tools:object[]; }>
Defined in: src/tools/adapters/mcp.ts:48
Parameters
params?
unknown
Returns
Promise<{ tools: object[]; }>
callTool()
callTool(
params,options?):Promise<{content?:object[] |null;structuredContent?:unknown;isError?:boolean; }>
Defined in: src/tools/adapters/mcp.ts:56
Parameters
params
name
string
arguments?
Record<string, unknown>
options?
Returns
Promise<{ content?: object[] | null; structuredContent?: unknown; isError?: boolean; }>
MCPCallToolOptions
Defined in: src/tools/adapters/mcp.ts:72
Per-call options forwarded into a single tools/call. signal
propagates cancellation down to the transport's in-flight request so
aborting a run actually unblocks a hung MCP server instead of leaving
the RPC running in the background.
Properties
signal?
optionalsignal?:AbortSignal
Defined in: src/tools/adapters/mcp.ts:73
MCPSessionHandle
Defined in: src/tools/adapters/mcp.ts:80
Owns the lifecycle of an MCP client session and any underlying transport. Returned by SessionFactory.
Properties
session
session:
MCPClientSession
Defined in: src/tools/adapters/mcp.ts:81
Methods
close()
close():
Promise<void>
Defined in: src/tools/adapters/mcp.ts:82
Returns
Promise<void>
MCPToolsetOptions
Defined in: src/tools/adapters/mcp.ts:87
Properties
name
name:
string
Defined in: src/tools/adapters/mcp.ts:88
description
description:
string
Defined in: src/tools/adapters/mcp.ts:89
transport?
optionaltransport?:MCPTransport
Defined in: src/tools/adapters/mcp.ts:90
command?
optionalcommand?:string
Defined in: src/tools/adapters/mcp.ts:91
args?
optionalargs?:string[]
Defined in: src/tools/adapters/mcp.ts:92
env?
optionalenv?:Record<string,string>
Defined in: src/tools/adapters/mcp.ts:93
serverUrl?
optionalserverUrl?:string
Defined in: src/tools/adapters/mcp.ts:94
headers?
optionalheaders?:Record<string,string>
Defined in: src/tools/adapters/mcp.ts:101
Extra HTTP headers attached to every request for the
sse / streamable_http transports (e.g. Authorization,
tenant ids). Ignored by the stdio transport, which has no HTTP
surface. Forwarded onto the transport's requestInit.headers.
sessionFactory?
optionalsessionFactory?:SessionFactory
Defined in: src/tools/adapters/mcp.ts:108
Test escape hatch (mirror of Python's session_factory). When
provided, the toolset never imports @modelcontextprotocol/sdk
and never opens a real transport — it just calls this factory and
uses the returned duck-typed session.
clientInfo?
optionalclientInfo?:object
Defined in: src/tools/adapters/mcp.ts:113
Client identity advertised during MCP initialize. Defaults to
{ name: "@maniac-ai/agents", version: "0.0.0" }.
name
name:
string
version
version:
string
ToolSearchIndex
Defined in: src/tools/base.ts:108
Methods
build()
build(
tools):void
Defined in: src/tools/base.ts:109
Parameters
tools
object[]
Returns
void
search()
search(
query,k?):object[]
Defined in: src/tools/base.ts:110
Parameters
query
string
k?
number
Returns
object[]
Type Aliases
TracerFactory
TracerFactory = () =>
Tracer
Defined in: src/agents/app.ts:43
Returns
ChatOptions
ChatOptions =
Omit<RunOptions,"tracer"|"prefixMessages"|"threadId"> &object
Defined in: src/agents/app.ts:53
Options accepted by Maniac.chat / Maniac.chatStream.
threadId is required; it scopes every conversation memory operation.
resourceId is optional and activates Mastra-style cross-thread
observational memory when the configured observationalMemory.scope
is "resource". Other fields mirror RunOptions.
Type Declaration
threadId
threadId:
string
memoryAgentId?
optionalmemoryAgentId?:string
Override the agent id used to namespace every memory operation
for this turn -- conversation loadThread / saveTurn, the
observation buffer, working-memory load + update, and the
relevance filter. Defaults to the agentId positional argument.
This decouples the spec-lookup identity (agentId, which
chat / chatStream still resolve via Maniac.get) from
the conversation-memory identity. Hosts that register a unique
spec id per turn (e.g. to keep concurrent turns' specs isolated
in the singleton agents map) can pass a stable memoryAgentId
so prior turns persisted under agent:<memoryAgentId>/threads/ <threadId>/... are reloaded on the next turn instead of landing
in a fresh, empty per-turn namespace.
resourceId?
optionalresourceId?:string|null
Mastra-style "resource" identity (typically the human user the
chat belongs to). When the configured
observationalMemory.scope is "resource", observations are
pooled across every thread for this resource so the agent
sees what the same user said in other sessions. Also threaded
onto RequestContext.resource_id so dynamic-instructions
builders can vary the system prompt per user. Omit to fall
back to thread-scope behaviour.
memory?
optionalmemory?:RuntimeMemoryAccess|RuntimeMemoryAccessInput|null
Per-call opt-out / opt-in for observational and working memory.
Pass { observational: "off" } (or { working: "read" }, etc.)
to skip a tier for this turn even when the app has it
configured. Defaults to fully-on ("write") for both tiers
when the app has them; tiers the app does not have are
forced to "off" regardless. See RuntimeMemoryAccess.
userPeerId?
optionaluserPeerId?:string|null
Honcho user-peer attribution for this turn. Forwarded to the
Honcho-aware conversation store; the vanilla store ignores it.
Defaults to resourceId (when supplied) and falls back to the
HonchoMemory.defaultUserPeer.
assistantPeerId?
optionalassistantPeerId?:string|null
Honcho assistant-peer attribution for this turn. Forwarded to
the Honcho-aware conversation store; the vanilla store ignores
it. Defaults to agent:${agentId} derived inside the store.
tracer?
optionaltracer?:Tracer
BackgroundTaskInput
BackgroundTaskInput =
object
Defined in: src/agents/backgroundTasks.ts:55
Input shape for BackgroundTaskDispatcher.enqueue.
spec is required; the task wraps a single runAgent(spec, prompt, ...) call. signal is forwarded into the run; hooks are
composed with the agent- and manager-level hooks declared in the
matching AgentBackgroundConfig / BackgroundTasksConfig.
Properties
spec
spec:
Agent
Defined in: src/agents/backgroundTasks.ts:57
Required: the agent spec to run.
prompt
prompt:
string
Defined in: src/agents/backgroundTasks.ts:59
The natural-language prompt forwarded to runAgent.
threadId?
optionalthreadId?:string
Defined in: src/agents/backgroundTasks.ts:64
Conversational thread id. Defaults to a synthetic
bg:<uuid> so concurrent one-shot tasks get separate ids.
signal?
optionalsignal?:AbortSignal
Defined in: src/agents/backgroundTasks.ts:66
Optional caller-side abort signal.
toolCallId?
optionaltoolCallId?:string
Defined in: src/agents/backgroundTasks.ts:72
Optional tool_call_id the LM minted when this task originated
from a foreground tool call (background-as-tool). Surfaces on
the persisted record so callers can correlate.
toolName?
optionaltoolName?:string
Defined in: src/agents/backgroundTasks.ts:74
Optional tool_name. Defaults to the agent's spec id.
toolset?
optionaltoolset?:string|null
Defined in: src/agents/backgroundTasks.ts:76
Optional toolset label.
args?
optionalargs?:JsonDict
Defined in: src/agents/backgroundTasks.ts:78
Optional structured args persisted on the record for diagnostics.
taskHooks?
optionaltaskHooks?:object
Defined in: src/agents/backgroundTasks.ts:80
Per-task overrides for the resolved agent / manager hooks.
onComplete?
optionalonComplete?:TaskHook|null
onFailed?
optionalonFailed?:TaskHook|null
agentConfig?
optionalagentConfig?:AgentBackgroundConfig|null
Defined in: src/agents/backgroundTasks.ts:86
Per-task agent-level config; merged ahead of the spec-level
background (which is itself merged ahead of the manager
defaults).
timeoutMs?
optionaltimeoutMs?:number|null
Defined in: src/agents/backgroundTasks.ts:93
Optional task-level wait timeout. When set, overrides the
dispatcher's default_timeout_s for the underlying runAgent
call (a Promise.race against setTimeout). null disables
any timeout for this task.
DispatcherOptions
DispatcherOptions =
object
Defined in: src/agents/backgroundTasks.ts:96
Properties
config
config:
BackgroundTasksConfig
Defined in: src/agents/backgroundTasks.ts:98
Concurrency caps + backpressure policy.
store?
optionalstore?:BackgroundTaskStore|null
Defined in: src/agents/backgroundTasks.ts:100
Optional persistence store; matches Python's store=....
runAgentImpl?
optionalrunAgentImpl?: typeofrunAgent
Defined in: src/agents/backgroundTasks.ts:106
Test escape hatch: override runAgent (and runAgentStream) so
tests can exercise the scheduler without spinning up a real
model. Production callers should leave both unset.
runAgentStreamImpl?
optionalrunAgentStreamImpl?: typeofrunAgentStream
Defined in: src/agents/backgroundTasks.ts:107
now?
optionalnow?: () =>Date
Defined in: src/agents/backgroundTasks.ts:109
Test clock: returns a UTC ISO string for record timestamps.
Returns
Date
BackgroundStreamItem
BackgroundStreamItem = {
type:"event";taskId:string;event:TraceEvent; } | {type:"result";taskId:string;record:BackgroundTaskRecord; }
Defined in: src/agents/backgroundTasks.ts:927
Stream envelope yielded by BackgroundTaskDispatcher.runStreamUntilIdle.
{ type: "event" } carries a TraceEvent from the named task's tracer.
{ type: "result" } carries the terminal BackgroundTaskRecord for
that task and is yielded once per task as it completes.
StreamEnvelope
StreamEnvelope<
T> = {type:"event";event:TraceEvent; } | {type:"paused";checkpoint:RunCheckpoint;pending:PendingApproval[]; } | {type:"result";result:AgentResult<T>; }
Defined in: src/agents/runner.ts:62
Tagged stream envelope yielded by runAgentStream. Replaces the
legacy duck-typed TraceEvent | AgentResult union.
Consumers narrow on envelope.type:
for await (const env of runAgentStream(spec, query)) {
if (env.type === "event") render(env.event);
else handleResult(env.result);
}Type Parameters
T
T = string
Union Members
Type Literal
{ type: "event"; event: TraceEvent; }
Type Literal
{ type: "paused"; checkpoint: RunCheckpoint; pending: PendingApproval[]; }
type
type:
"paused"
Tier 1 #4: emitted at the start of a HITL pause, before the
terminal { type: "result" } envelope whose
result.status === "paused". Consumers that switch on
"event" | "result" keep working unchanged because the
terminal result envelope is still emitted; new consumers can
short-circuit on "paused" and start surfacing the pending
approvals to the human reviewer earlier.
checkpoint
checkpoint:
RunCheckpoint
pending
pending:
PendingApproval[]
Type Literal
{ type: "result"; result: AgentResult<T>; }
StreamItem
StreamItem<
T> =TraceEvent|AgentResult<T>
Defined in: src/agents/runner.ts:86
Type Parameters
T
T = string
Deprecated
Use StreamEnvelope instead. This alias retains the
legacy duck-typed shape for callers that still detect events vs. results
by the presence of "kind" / "status". New code should iterate over
StreamEnvelope and switch on env.type.
RunScope
RunScope =
"root"|"subagent"
Defined in: src/agents/runner.ts:88
RunContext
RunContext =
object
Defined in: src/agents/runner.ts:90
Properties
depth
depth:
number
Defined in: src/agents/runner.ts:91
scope
scope:
RunScope
Defined in: src/agents/runner.ts:92
principal
principal:
string
Defined in: src/agents/runner.ts:93
parent_span_id?
optionalparent_span_id?:string|null
Defined in: src/agents/runner.ts:94
max_depth
max_depth:
number
Defined in: src/agents/runner.ts:95
usage
usage:
TokenUsage
Defined in: src/agents/runner.ts:96
tracer
tracer:
Tracer
Defined in: src/agents/runner.ts:97
streamLmCalls?
optionalstreamLmCalls?:boolean
Defined in: src/agents/runner.ts:98
toolset?
optionaltoolset?:string|null
Defined in: src/agents/runner.ts:99
tool?
optionaltool?:string|null
Defined in: src/agents/runner.ts:100
tool_call_id?
optionaltool_call_id?:string|null
Defined in: src/agents/runner.ts:101
subagent_span_id?
optionalsubagent_span_id?:string|null
Defined in: src/agents/runner.ts:102
plan?
optionalplan?:PlanEntry[]
Defined in: src/agents/runner.ts:116
Current plan entries for the run.
Updated by setPlan / updatePlanEntry and by the
built-in set_plan LM tool. Stored on the context so middleware
and tools can read the current plan without parsing the trace
stream. The ACP server adapter reads this to honour ACP's "agents
MUST send the complete list of plan entries in each update"
semantics: every emission is a full replacement.
Mutating this list directly does not emit a trace event; use setPlan so consumers see the change.
signal?
optionalsignal?:AbortSignal|null
Defined in: src/agents/runner.ts:123
Cancellation signal for the run. Set automatically when callers pass
signal to runAgent/runAgentStream/runAgentResume, and forwarded
to nested runs by runNestedAgent. Tools that opt into cooperative
cancellation can read this via getActiveRunContext.
thread_id?
optionalthread_id?:string|null
Defined in: src/agents/runner.ts:130
Caller-scoped conversation thread id, sourced from
RunOptions.threadId. When present, every event emitted within
this run carries thread_id set to this value. Nested runs inherit
the parent's thread_id.
turn_id?
optionalturn_id?:string|null
Defined in: src/agents/runner.ts:139
Per-iteration correlation id. The runner mints this at the top of
every LM iteration and stores it here so downstream emissions
(tool/cell/step/agent events, including those produced inside
tool.invoke via getActiveRunContext) inherit a stable
turn_id shared with the surrounding lm_call_start / lm_call
pair. Mirrors the Python tool_call_loop.py convention.
message_id?
optionalmessage_id?:string|null
Defined in: src/agents/runner.ts:145
Per-iteration assistant message id minted alongside turn_id.
Echoed onto lm_call/tool events so consumers can correlate
streaming chunks back to the assistant message they belong to.
dispatcher?
optionaldispatcher?:BackgroundTaskDispatcher|null
Defined in: src/agents/runner.ts:153
The active BackgroundTaskDispatcher for this run, if any.
Threaded through by Maniac when the constructor has
backgroundTasks configured so the auto-injected bg_* control
tools can reach the dispatcher via the active run context. Nested
runs inherit the parent's dispatcher.
policy?
optionalpolicy?:PermissionPolicy|null
Defined in: src/agents/runner.ts:167
Tier 2 #5/#9: per-run permission policy override.
When set, the runner prefers this policy over spec.policy for
every tool-call evaluation. Two cases use it:
- RunOptions.policy on the top-level run lets callers override the policy without rebuilding the spec.
- runNestedAgent threads the parent's effective policy
onto the inner run context so child specs without an explicit
policyinherit (set the inner spec'spolicy: nullto opt out).
RunOptions
RunOptions =
object
Defined in: src/agents/runner.ts:170
Properties
tracer?
optionaltracer?:Tracer
Defined in: src/agents/runner.ts:171
repl?
optionalrepl?:ExecutionEnvironment|null
Defined in: src/agents/runner.ts:172
context?
optionalcontext?:RequestContext|Record<string,unknown> |null
Defined in: src/agents/runner.ts:173
prefixMessages?
optionalprefixMessages?:Message[]
Defined in: src/agents/runner.ts:174
threadId?
optionalthreadId?:string
Defined in: src/agents/runner.ts:175
signal?
optionalsignal?:AbortSignal
Defined in: src/agents/runner.ts:182
Optional cancellation signal. Aborting it cancels the run end-to-end:
subsequent model calls short-circuit with an error trace event, the
signal is exposed to tools via the active run context, and nested
agents inherit the same signal.
dispatcher?
optionaldispatcher?:BackgroundTaskDispatcher|null
Defined in: src/agents/runner.ts:190
Background-task dispatcher to thread into the run's RunContext.
The auto-injected bg_* control tools call into this dispatcher to
read pending tasks, snapshot events, cancel, or await terminal
records. Mirrors Python background_run_dispatcher on
Maniac.run(...).
policy?
optionalpolicy?:PermissionPolicy|null
Defined in: src/agents/runner.ts:201
Tier 2 #5: per-call permission policy override.
When set, the runner prefers this over spec.policy for every
tool-call evaluation in this run. Useful for one-off permission
tightening (e.g. a sensitive cron job) without rebuilding the
spec. Pass null to explicitly disable spec-level policy for
the duration of the run; omit (undefined) to fall through to
the spec.
principal?
optionalprincipal?:string
Defined in: src/agents/runner.ts:208
Tier 2 #7: per-call principal override. Defaults to spec.id
when omitted. Threaded onto RunContext.principal and the
generated principal chain (so nested agents see
<override>:agent:<inner>).
streamLmCalls?
optionalstreamLmCalls?:boolean
Defined in: src/agents/runner.ts:220
Stream every model call (emitting per-token token /
tool_call_arguments_delta trace events) instead of awaiting a
single model.infer(...) per LM call.
Off by default for direct runAgent callers, which only
need the terminal result. runAgentStream and the
BackgroundTaskDispatcher force it on so subscribers see
live token deltas. Read in makeRootRunContext; nested agents
inherit the parent's value.
TracerOptions
TracerOptions =
object
Defined in: src/agents/trace.ts:12
Construction options for Tracer.
run_id identifies the run all events belong to. When omitted, the tracer
generates a uuid at construction time. Per-event seq is monotonic and
starts at 0; event_id is a per-event uuid assigned at emit time.
Properties
run_id?
optionalrun_id?:string
Defined in: src/agents/trace.ts:13
AnthropicModelOptions
AnthropicModelOptions =
object
Defined in: src/inference/adapters/anthropic.ts:86
Properties
slug
slug:
string
Defined in: src/inference/adapters/anthropic.ts:87
id?
optionalid?:string
Defined in: src/inference/adapters/anthropic.ts:88
apiKey?
optionalapiKey?:string
Defined in: src/inference/adapters/anthropic.ts:89
apiKeyEnvVar?
optionalapiKeyEnvVar?:string
Defined in: src/inference/adapters/anthropic.ts:90
baseUrl?
optionalbaseUrl?:string
Defined in: src/inference/adapters/anthropic.ts:91
apiVersion?
optionalapiVersion?:string
Defined in: src/inference/adapters/anthropic.ts:92
defaultMaxTokens?
optionaldefaultMaxTokens?:number
Defined in: src/inference/adapters/anthropic.ts:93
headers?
optionalheaders?:Record<string,string>
Defined in: src/inference/adapters/anthropic.ts:94
timeoutMs?
optionaltimeoutMs?:number
Defined in: src/inference/adapters/anthropic.ts:95
signal?
optionalsignal?:AbortSignal
Defined in: src/inference/adapters/anthropic.ts:96
fetch?
optionalfetch?:AnthropicFetch
Defined in: src/inference/adapters/anthropic.ts:97
onUnsupportedJsonFormat?
optionalonUnsupportedJsonFormat?: (message) =>void
Defined in: src/inference/adapters/anthropic.ts:105
Optional callback invoked once per model instance the first time the
caller requests response_format: "json". Anthropic has no native
JSON mode, so the request is sent unmodified and the callback is the
"you asked for JSON, here's why we ignored it" signal. Defaults to a
console.warn on the global console.
Parameters
message
string
Returns
void
AnthropicFinishMapping
AnthropicFinishMapping =
object
Defined in: src/inference/adapters/anthropic.ts:735
Properties
reason
reason:
FinishReason
Defined in: src/inference/adapters/anthropic.ts:736
raw
raw:
string|null
Defined in: src/inference/adapters/anthropic.ts:737
FallbackPredicate
FallbackPredicate = (
error) =>boolean
Defined in: src/inference/adapters/fallback.ts:15
Parameters
error
unknown
Returns
boolean
FallbackModelOptions
FallbackModelOptions =
object
Defined in: src/inference/adapters/fallback.ts:17
Properties
fallbackOn?
optionalfallbackOn?:FallbackPredicate
Defined in: src/inference/adapters/fallback.ts:22
Predicate over the raised exception. Defaults to isFallbackEligibleError (transient HTTP plus 401/403/404).
tracer?
optionaltracer?:Tracer|null
Defined in: src/inference/adapters/fallback.ts:27
Optional tracer. When set, every fallback hop emits a retry
TraceEvent with phase="fallback".
id?
optionalid?:string
Defined in: src/inference/adapters/fallback.ts:28
slug?
optionalslug?:string
Defined in: src/inference/adapters/fallback.ts:29
ProviderFetch
ProviderFetch = (
input,init?) =>Promise<Response>
Defined in: src/inference/adapters/openaiCompatible.ts:31
Parameters
input
string | URL
init?
RequestInit
Returns
Promise<Response>
OpenAICompatibleModelOptions
OpenAICompatibleModelOptions =
object
Defined in: src/inference/adapters/openaiCompatible.ts:33
Properties
slug
slug:
string
Defined in: src/inference/adapters/openaiCompatible.ts:34
id?
optionalid?:string
Defined in: src/inference/adapters/openaiCompatible.ts:35
apiKey?
optionalapiKey?:string
Defined in: src/inference/adapters/openaiCompatible.ts:36
apiKeyEnvVar?
optionalapiKeyEnvVar?:string
Defined in: src/inference/adapters/openaiCompatible.ts:37
baseUrl?
optionalbaseUrl?:string
Defined in: src/inference/adapters/openaiCompatible.ts:38
headers?
optionalheaders?:Record<string,string>
Defined in: src/inference/adapters/openaiCompatible.ts:39
organization?
optionalorganization?:string
Defined in: src/inference/adapters/openaiCompatible.ts:40
project?
optionalproject?:string
Defined in: src/inference/adapters/openaiCompatible.ts:41
timeoutMs?
optionaltimeoutMs?:number
Defined in: src/inference/adapters/openaiCompatible.ts:42
signal?
optionalsignal?:AbortSignal
Defined in: src/inference/adapters/openaiCompatible.ts:43
fetch?
optionalfetch?:ProviderFetch
Defined in: src/inference/adapters/openaiCompatible.ts:44
requireApiKey?
optionalrequireApiKey?:boolean
Defined in: src/inference/adapters/openaiCompatible.ts:45
OpenAICompatibleFinishMapping
OpenAICompatibleFinishMapping =
object
Defined in: src/inference/adapters/openaiCompatible.ts:651
Detailed mapping of an OpenAI-compatible finish_reason to the
canonical FinishReason enum, retaining the raw provider string
for diagnostics. unknown values are explicitly mapped to "error"
(previously they were silently coerced to "stop"); operators can
read raw to attribute the surprise to a specific provider/model.
Properties
reason
reason:
FinishReason
Defined in: src/inference/adapters/openaiCompatible.ts:652
raw
raw:
string|null
Defined in: src/inference/adapters/openaiCompatible.ts:653
SseParseErrorHook
SseParseErrorHook = (
data,error) =>void
Defined in: src/inference/adapters/openaiCompatible.ts:702
Optional debug hook invoked when an SSE data: payload fails to parse as
JSON. The default is a silent skip (preserves prior behavior). Provided
mostly for tests and operators who want visibility into provider quirks.
Parameters
data
string
error
unknown
Returns
void
OpenRouterModelOptions
OpenRouterModelOptions =
Omit<OpenAICompatibleModelOptions,"apiKeyEnvVar"|"baseUrl"|"headers"|"id"> &object
Defined in: src/inference/adapters/openrouter.ts:16
Type Declaration
id?
optionalid?:string
baseUrl?
optionalbaseUrl?:string
headers?
optionalheaders?:Record<string,string>
referer?
optionalreferer?:string
title?
optionaltitle?:string
RetryPredicate
RetryPredicate = (
error) =>boolean
Defined in: src/inference/adapters/retrying.ts:18
Parameters
error
unknown
Returns
boolean
RetryingModelOptions
RetryingModelOptions =
object
Defined in: src/inference/adapters/retrying.ts:20
Properties
retries?
optionalretries?:number
Defined in: src/inference/adapters/retrying.ts:25
Maximum number of retries (additional attempts beyond the first).
Total attempts = retries + 1. Default 3.
initialBackoff?
optionalinitialBackoff?:number
Defined in: src/inference/adapters/retrying.ts:31
Initial backoff in seconds. The Nth retry waits
min(maxBackoff, initialBackoff * multiplier^(N - 1)), then a
uniform [-jitter, +jitter] fraction is applied.
maxBackoff?
optionalmaxBackoff?:number
Defined in: src/inference/adapters/retrying.ts:32
multiplier?
optionalmultiplier?:number
Defined in: src/inference/adapters/retrying.ts:33
jitter?
optionaljitter?:number
Defined in: src/inference/adapters/retrying.ts:34
retryOn?
optionalretryOn?:RetryPredicate
Defined in: src/inference/adapters/retrying.ts:40
Predicate over the raised exception. Defaults to
isTransientHttpError; returning false re-raises
immediately without retrying.
respectRetryAfter?
optionalrespectRetryAfter?:boolean
Defined in: src/inference/adapters/retrying.ts:45
Honor a server-supplied Retry-After header on 429/503 responses
by overriding the computed backoff for that attempt. Default true.
tracer?
optionaltracer?:Tracer|null
Defined in: src/inference/adapters/retrying.ts:51
Optional tracer. When set, every retry attempt emits a retry
TraceEvent so backends like the OTel exporter can attribute the
delay to the surrounding span.
id?
optionalid?:string
Defined in: src/inference/adapters/retrying.ts:52
slug?
optionalslug?:string
Defined in: src/inference/adapters/retrying.ts:53
sleep?
optionalsleep?: (seconds) =>Promise<void>
Defined in: src/inference/adapters/retrying.ts:58
Internal hook. Pluggable so tests can use a deterministic clock without sleeping for real wall-clock seconds.
Parameters
seconds
number
Returns
Promise<void>
random?
optionalrandom?: () =>number
Defined in: src/inference/adapters/retrying.ts:63
Internal hook. Replaces Math.random() so tests can pin the
jittered delay deterministically.
Returns
number
VercelGatewayModelOptions
VercelGatewayModelOptions =
Omit<OpenAICompatibleModelOptions,"apiKeyEnvVar"|"baseUrl"|"id"|"organization"|"project"> &object
Defined in: src/inference/adapters/vercelGateway.ts:28
Type Declaration
id?
optionalid?:string
baseUrl?
optionalbaseUrl?:string
ToolCallArgsParseResult
ToolCallArgsParseResult = {
ok:true;value:JsonDict; } | {ok:false;error:ToolCallArgsError; }
Defined in: src/inference/base.ts:28
Result type for parseToolCallArgs. On success carries the parsed JsonDict; on failure carries the structured ToolCallArgsError with both a message and the raw provider text for debugging.
ToolCallArgsError
ToolCallArgsError =
object
Defined in: src/inference/base.ts:32
Properties
kind
kind:
"parse"|"not_object"
Defined in: src/inference/base.ts:37
Discriminates the failure mode. parse means JSON.parse rejected
the text; not_object means the parsed JSON was not a JSON object.
message
message:
string
Defined in: src/inference/base.ts:38
raw
raw:
string
Defined in: src/inference/base.ts:40
Raw provider text we tried to parse (untouched, for debugging).
StreamChunkObserver
StreamChunkObserver = (
chunk) =>void|Promise<void>
Defined in: src/inference/base.ts:84
Parameters
chunk
Returns
void | Promise<void>
VectorHit
VectorHit = readonly [
string,number,Record<string,unknown>]
Defined in: src/memory/adapters/vector.ts:58
CheckpointStatus
CheckpointStatus =
"pending"|"resolving"|"resolved"
Defined in: src/memory/checkpoints.ts:44
Lifecycle states for a stored checkpoint.
pending: persisted and waiting for a resume call.resolving: a RunCheckpointStore.claim call has taken the lock and a resume is in-flight; concurrent resumers must bail out to avoid double-executing the approved tool.resolved: the resume finished and the record is durable for audit. Re-claims always fail.
StoredCheckpoint
StoredCheckpoint =
object
Defined in: src/memory/checkpoints.ts:46
Properties
id
id:
string
Defined in: src/memory/checkpoints.ts:47
agent_id
agent_id:
string
Defined in: src/memory/checkpoints.ts:48
thread_id
thread_id:
string|null
Defined in: src/memory/checkpoints.ts:49
status
status:
CheckpointStatus
Defined in: src/memory/checkpoints.ts:50
created_at
created_at:
string
Defined in: src/memory/checkpoints.ts:51
resolved_at
resolved_at:
string|null
Defined in: src/memory/checkpoints.ts:52
prefix_len
prefix_len:
number|null
Defined in: src/memory/checkpoints.ts:53
checkpoint
checkpoint:
RunCheckpoint
Defined in: src/memory/checkpoints.ts:54
ObservationOriginOptions
ObservationOriginOptions =
object
Defined in: src/memory/observations.ts:186
Properties
resourceId?
optionalresourceId?:string|null
Defined in: src/memory/observations.ts:194
Optional resource scope. When supplied, routes into
agent:<id>/resources/<rid>/observations (or /reflections)
instead of the per-thread namespace, and stamps the record with
thread_id / resource_id so a cross-thread read pool can
disambiguate the originating thread.
SequenceFallback
SequenceFallback = () =>
number|Promise<number>
Defined in: src/memory/sequence.ts:3
Returns
number | Promise<number>
SessionPermissionCacheOptions
SessionPermissionCacheOptions =
object
Defined in: src/permissions/cache.ts:45
Properties
ttlSeconds?
optionalttlSeconds?:number|null
Defined in: src/permissions/cache.ts:51
TTL applied to every cached decision, in seconds. Pass null /
undefined to disable expiry (use only for unit tests). Default
300 matches the Python helper.
keyFor?
optionalkeyFor?: (action) =>string
Defined in: src/permissions/cache.ts:57
Optional override for the cache key. Defaults to
${principal}:${toolset}:${tool}:${hash(args)}. Override to
widen (drop args) or narrow (include extra request metadata).
Parameters
action
Returns
string
ReplMemoryCallable
ReplMemoryCallable = (
args?) =>Promise<JsonValue>
Defined in: src/runtime/memoryProxy.ts:5
Parameters
args?
unknown
Returns
Promise<JsonValue>
ReplMemoryCallableOptions
ReplMemoryCallableOptions =
object
Defined in: src/runtime/memoryProxy.ts:13
Optional context forwarded into trace events. We intentionally take a
minimal shape (rather than importing RunContext from src/agents/)
to keep the runtime layer free of agents-package imports beyond the
Tracer type.
Properties
depth?
optionaldepth?:number
Defined in: src/runtime/memoryProxy.ts:19
Subagent / nested call depth, forwarded to tracer.emit(..., { depth })
to match the Python MemoryProxy._emit behaviour and keep trace
nesting consistent across nested REPL memory ops.
PythonSandboxClientOptions
PythonSandboxClientOptions =
object
Defined in: src/runtime/pythonSandboxClient.ts:38
Properties
pythonExecutable?
optionalpythonExecutable?:string
Defined in: src/runtime/pythonSandboxClient.ts:39
pythonPath?
optionalpythonPath?:string[]
Defined in: src/runtime/pythonSandboxClient.ts:40
cwd?
optionalcwd?:string
Defined in: src/runtime/pythonSandboxClient.ts:41
env?
optionalenv?:Record<string,string>
Defined in: src/runtime/pythonSandboxClient.ts:42
onSessionError?
optionalonSessionError?: (error) =>void
Defined in: src/runtime/pythonSandboxClient.ts:49
Optional callback invoked when the stdout reader encounters an unrecoverable error (framing desync, unhandled dispatch rejection). Useful in tests and for host instrumentation. The session is terminated and pending RPCs rejected regardless.
Parameters
error
Error
Returns
void
SandboxLayout
SandboxLayout =
object
Defined in: src/runtime/pythonSandboxClient.ts:416
Resolved sandbox process layout: where to run the worker (cwd) and
which Python source root to put on PYTHONPATH (repoRoot).
Properties
cwd
cwd:
string
Defined in: src/runtime/pythonSandboxClient.ts:416
repoRoot
repoRoot:
string
Defined in: src/runtime/pythonSandboxClient.ts:416
AgentBudget
AgentBudget =
z.infer<typeofAgentBudgetSchema>
Defined in: src/schemas/agents.ts:36
RequestContext
RequestContext =
z.infer<typeofRequestContextSchema>
Defined in: src/schemas/agents.ts:53
InstructionsBuilder
InstructionsBuilder = (
ctx) =>string|Promise<string>
Defined in: src/schemas/agents.ts:55
Parameters
ctx
Returns
string | Promise<string>
TraceKind
TraceKind =
"cell"|"lm_call"|"lm_call_start"|"token"|"agent"|"subagent"|"tool"|"tool_call_arguments_delta"|"memory"|"guardrail"|"retry"|"approval"|"step"|"final"|"error"|"background_task"|"stream_gap"|"plan"
Defined in: src/schemas/agents.ts:57
TokenPayload
TokenPayload =
z.infer<typeofTokenPayloadSchema>
Defined in: src/schemas/agents.ts:155
LMCallStartPayload
LMCallStartPayload =
z.infer<typeofLMCallStartPayloadSchema>
Defined in: src/schemas/agents.ts:163
LMCallPayload
LMCallPayload =
z.infer<typeofLMCallPayloadSchema>
Defined in: src/schemas/agents.ts:174
ToolPhase
ToolPhase =
z.infer<typeofToolPhaseSchema>
Defined in: src/schemas/agents.ts:177
ToolResultPreview
ToolResultPreview =
z.infer<typeofToolResultPreviewSchema>
Defined in: src/schemas/agents.ts:203
ToolPayload
ToolPayload =
z.infer<typeofToolPayloadSchema>
Defined in: src/schemas/agents.ts:238
ToolCallArgumentsDeltaPayload
ToolCallArgumentsDeltaPayload =
z.infer<typeofToolCallArgumentsDeltaPayloadSchema>
Defined in: src/schemas/agents.ts:272
CellPhase
CellPhase =
z.infer<typeofCellPhaseSchema>
Defined in: src/schemas/agents.ts:275
CellPayload
CellPayload =
z.infer<typeofCellPayloadSchema>
Defined in: src/schemas/agents.ts:289
SubagentPhase
SubagentPhase =
z.infer<typeofSubagentPhaseSchema>
Defined in: src/schemas/agents.ts:299
SubagentPayload
SubagentPayload =
z.infer<typeofSubagentPayloadSchema>
Defined in: src/schemas/agents.ts:316
AgentPhase
AgentPhase =
z.infer<typeofAgentPhaseSchema>
Defined in: src/schemas/agents.ts:319
AgentPayload
AgentPayload =
z.infer<typeofAgentPayloadSchema>
Defined in: src/schemas/agents.ts:327
ApprovalPhase
ApprovalPhase =
z.infer<typeofApprovalPhaseSchema>
Defined in: src/schemas/agents.ts:332
ApprovalSource
ApprovalSource =
z.infer<typeofApprovalSourceSchema>
Defined in: src/schemas/agents.ts:335
ApprovalDecision
ApprovalDecision =
z.infer<typeofApprovalDecisionSchema>
Defined in: src/schemas/agents.ts:338
ApprovalPayload
ApprovalPayload =
z.infer<typeofApprovalPayloadSchema>
Defined in: src/schemas/agents.ts:360
MemoryPayload
MemoryPayload =
z.infer<typeofMemoryPayloadSchema>
Defined in: src/schemas/agents.ts:372
GuardrailPayload
GuardrailPayload =
z.infer<typeofGuardrailPayloadSchema>
Defined in: src/schemas/agents.ts:382
BackgroundTaskPayload
BackgroundTaskPayload =
z.infer<typeofBackgroundTaskPayloadSchema>
Defined in: src/schemas/agents.ts:398
StepPhase
StepPhase =
z.infer<typeofStepPhaseSchema>
Defined in: src/schemas/agents.ts:405
StepPayload
StepPayload =
z.infer<typeofStepPayloadSchema>
Defined in: src/schemas/agents.ts:415
RetryPayload
RetryPayload =
z.infer<typeofRetryPayloadSchema>
Defined in: src/schemas/agents.ts:425
FinalPayload
FinalPayload =
z.infer<typeofFinalPayloadSchema>
Defined in: src/schemas/agents.ts:434
ErrorPayload
ErrorPayload =
z.infer<typeofErrorPayloadSchema>
Defined in: src/schemas/agents.ts:444
ContentPartKind
ContentPartKind =
z.infer<typeofContentPartKindSchema>
Defined in: src/schemas/agents.ts:457
TokenEvent
TokenEvent =
z.infer<typeofTokenEventSchema>
Defined in: src/schemas/agents.ts:477
LMCallStartEvent
LMCallStartEvent =
z.infer<typeofLMCallStartEventSchema>
Defined in: src/schemas/agents.ts:484
LMCallEvent
LMCallEvent =
z.infer<typeofLMCallEventSchema>
Defined in: src/schemas/agents.ts:491
ToolEvent
ToolEvent =
z.infer<typeofToolEventSchema>
Defined in: src/schemas/agents.ts:498
ToolCallArgumentsDeltaEvent
ToolCallArgumentsDeltaEvent =
z.infer<typeofToolCallArgumentsDeltaEventSchema>
Defined in: src/schemas/agents.ts:505
CellEvent
CellEvent =
z.infer<typeofCellEventSchema>
Defined in: src/schemas/agents.ts:512
SubagentEvent
SubagentEvent =
z.infer<typeofSubagentEventSchema>
Defined in: src/schemas/agents.ts:519
AgentEventVariant
AgentEventVariant =
z.infer<typeofAgentEventSchema>
Defined in: src/schemas/agents.ts:526
ApprovalEvent
ApprovalEvent =
z.infer<typeofApprovalEventSchema>
Defined in: src/schemas/agents.ts:533
MemoryEvent
MemoryEvent =
z.infer<typeofMemoryEventSchema>
Defined in: src/schemas/agents.ts:540
GuardrailEvent
GuardrailEvent =
z.infer<typeofGuardrailEventSchema>
Defined in: src/schemas/agents.ts:547
BackgroundTaskEvent
BackgroundTaskEvent =
z.infer<typeofBackgroundTaskEventSchema>
Defined in: src/schemas/agents.ts:554
StepEvent
StepEvent =
z.infer<typeofStepEventSchema>
Defined in: src/schemas/agents.ts:561
RetryEvent
RetryEvent =
z.infer<typeofRetryEventSchema>
Defined in: src/schemas/agents.ts:568
FinalEvent
FinalEvent =
z.infer<typeofFinalEventSchema>
Defined in: src/schemas/agents.ts:575
ErrorEvent
ErrorEvent =
z.infer<typeofErrorEventSchema>
Defined in: src/schemas/agents.ts:582
StreamGapPayload
StreamGapPayload =
z.infer<typeofStreamGapPayloadSchema>
Defined in: src/schemas/agents.ts:599
StreamGapEvent
StreamGapEvent =
z.infer<typeofStreamGapEventSchema>
Defined in: src/schemas/agents.ts:606
PlanEntryPriority
PlanEntryPriority =
z.infer<typeofPlanEntryPrioritySchema>
Defined in: src/schemas/agents.ts:618
PlanEntryStatus
PlanEntryStatus =
z.infer<typeofPlanEntryStatusSchema>
Defined in: src/schemas/agents.ts:625
PlanEntry
PlanEntry =
z.infer<typeofPlanEntrySchema>
Defined in: src/schemas/agents.ts:632
PlanPayload
PlanPayload =
z.infer<typeofPlanPayloadSchema>
Defined in: src/schemas/agents.ts:637
PlanEvent
PlanEvent =
z.infer<typeofPlanEventSchema>
Defined in: src/schemas/agents.ts:644
TraceEvent
TraceEvent =
z.infer<typeofTraceEventSchema>
Defined in: src/schemas/agents.ts:666
TracePayload
TracePayload =
TokenPayload&object|LMCallStartPayload&object|LMCallPayload&object|ToolPayload&object|ToolCallArgumentsDeltaPayload&object|CellPayload&object|SubagentPayload&object|AgentPayload&object|ApprovalPayload&object|MemoryPayload&object|GuardrailPayload&object|BackgroundTaskPayload&object|StepPayload&object|RetryPayload&object|FinalPayload&object|ErrorPayload&object|StreamGapPayload&object|PlanPayload&object
Defined in: src/schemas/agents.ts:672
TracePayloadFor
TracePayloadFor<
K> =Extract<TracePayload, {kind:K; }>
Defined in: src/schemas/agents.ts:692
Type Parameters
K
K extends TraceKind
TraceEventFor
TraceEventFor<
K> =Extract<TraceEvent, {kind:K; }>
Defined in: src/schemas/agents.ts:696
Type Parameters
K
K extends TraceKind
AgentEvent
AgentEvent =
TraceEvent
Defined in: src/schemas/agents.ts:698
AgentResult
AgentResult<
T> =Omit<z.infer<typeofAgentResultSchema>,"output"> &object
Defined in: src/schemas/agents.ts:711
Type Declaration
output?
optionaloutput?:T|null
Type Parameters
T
T = unknown
AgentSpec
AgentSpec =
Agent
Defined in: src/schemas/agents.ts:787
Deprecated
Use Agent. Kept for backwards compatibility; will be removed in a future release.
MakeTraceEventOptions
MakeTraceEventOptions =
object
Defined in: src/schemas/agents.ts:893
Common envelope-level options (depth, principal, span_id,
parent_span_id, seq, event_id, run_id) accepted by
makeTraceEvent and Tracer.emit. kind is positional;
payload-specific structured fields belong inside payload.
Token events additionally accept delta/chunk_kind/partial_object/
tool_call_delta which surface at the top level of the event so streaming
consumers can read them without unwrapping the typed payload.
Properties
depth?
optionaldepth?:number
Defined in: src/schemas/agents.ts:894
principal?
optionalprincipal?:string|null
Defined in: src/schemas/agents.ts:895
span_id?
optionalspan_id?:string|null
Defined in: src/schemas/agents.ts:896
parent_span_id?
optionalparent_span_id?:string|null
Defined in: src/schemas/agents.ts:897
seq?
optionalseq?:number
Defined in: src/schemas/agents.ts:898
event_id?
optionalevent_id?:string
Defined in: src/schemas/agents.ts:899
run_id?
optionalrun_id?:string
Defined in: src/schemas/agents.ts:900
delta?
optionaldelta?:string|null
Defined in: src/schemas/agents.ts:901
chunk_kind?
optionalchunk_kind?:StreamChunkKind|null
Defined in: src/schemas/agents.ts:902
content_part_kind?
optionalcontent_part_kind?:ContentPartKind|null
Defined in: src/schemas/agents.ts:909
Optional content-part discriminator for token events. See
ContentPartKindSchema; additive on the wire so existing
producers can omit it. The runner sets it when a stream emits
image / file deltas.
partial_object?
optionalpartial_object?:JsonDict|null
Defined in: src/schemas/agents.ts:910
tool_call_delta?
optionaltool_call_delta?:ToolCallPartial|null
Defined in: src/schemas/agents.ts:911
turn_id?
optionalturn_id?:string|null
Defined in: src/schemas/agents.ts:914
message_id?
optionalmessage_id?:string|null
Defined in: src/schemas/agents.ts:915
block_id?
optionalblock_id?:string|null
Defined in: src/schemas/agents.ts:916
thread_id?
optionalthread_id?:string|null
Defined in: src/schemas/agents.ts:917
PendingSubAction
PendingSubAction =
z.infer<typeofPendingSubActionSchema>
Defined in: src/schemas/approvals.ts:27
PendingApproval
PendingApproval =
z.infer<typeofPendingApprovalSchema>
Defined in: src/schemas/approvals.ts:47
ApprovalResponse
ApprovalResponse =
z.infer<typeofApprovalResponseSchema>
Defined in: src/schemas/approvals.ts:61
SerializedSession
SerializedSession =
z.infer<typeofSerializedSessionSchema>
Defined in: src/schemas/approvals.ts:86
RunCheckpoint
RunCheckpoint =
z.infer<typeofRunCheckpointSchema>
Defined in: src/schemas/approvals.ts:111
BackgroundStatus
BackgroundStatus =
z.infer<typeofBackgroundStatusSchema>
Defined in: src/schemas/background.ts:12
BackpressurePolicy
BackpressurePolicy =
z.infer<typeofBackpressurePolicySchema>
Defined in: src/schemas/background.ts:15
TaskHook
TaskHook = (
record) =>void|Promise<void>
Defined in: src/schemas/background.ts:24
Lifecycle callbacks fire on terminal states. They receive the full BackgroundTaskRecord so observers can correlate to other state. Sync or async; awaited if they return a thenable.
Mirrors Python schemas.background.TaskHook.
Parameters
record
Returns
void | Promise<void>
BackgroundConfig
BackgroundConfig =
z.infer<typeofBackgroundConfigSchema> &object
Defined in: src/schemas/background.ts:32
Type Declaration
on_complete?
optionalon_complete?:TaskHook|null
Tool-scoped completion hook. Composed with the agent-level and
manager-level hooks, not replaced. Mirrors Python
BackgroundConfig.on_complete.
Callable hooks live outside the Zod schema (Zod 4 cannot validate
function values inside .passthrough()); attach them on the
resolved object after parsing.
on_failed?
optionalon_failed?:TaskHook|null
Tool-scoped hook fired on failed / cancelled.
AgentBackgroundConfig
AgentBackgroundConfig =
z.infer<typeofAgentBackgroundConfigSchema> &object
Defined in: src/schemas/background.ts:52
Type Declaration
on_task_complete?
optionalon_task_complete?:TaskHook|null
Agent-scoped completion hook. Fires for every background task
dispatched by this agent. Mirrors Python
AgentBackgroundConfig.on_task_complete.
on_task_failed?
optionalon_task_failed?:TaskHook|null
Agent-scoped failure / cancellation hook.
BackgroundTasksConfig
BackgroundTasksConfig =
z.infer<typeofBackgroundTasksConfigSchema> &object
Defined in: src/schemas/background.ts:72
Type Declaration
on_task_complete?
optionalon_task_complete?:TaskHook|null
Manager-scoped completion hook. Mirrors Python
BackgroundTasksConfig.on_task_complete.
on_task_failed?
optionalon_task_failed?:TaskHook|null
Manager-scoped failure / cancellation hook.
BackgroundTaskRecord
BackgroundTaskRecord =
z.infer<typeofBackgroundTaskRecordSchema>
Defined in: src/schemas/background.ts:100
JsonValue
JsonValue =
string|number|boolean|null|JsonValue[] | {[key:string]:JsonValue; }
Defined in: src/schemas/common.ts:14
JsonDict
JsonDict =
object
Defined in: src/schemas/common.ts:22
Index Signature
[key: string]: JsonValue
SafeJsonValueResult
SafeJsonValueResult = {
ok:true;value:JsonValue; } | {ok:false;error:string; }
Defined in: src/schemas/common.ts:48
Cell
Cell =
z.infer<typeofCellSchema>
Defined in: src/schemas/execution.ts:10
ScratchpadVariable
ScratchpadVariable =
z.infer<typeofScratchpadVariableSchema>
Defined in: src/schemas/execution.ts:18
ScratchpadState
ScratchpadState =
z.infer<typeofScratchpadStateSchema>
Defined in: src/schemas/execution.ts:24
SandboxRunResult
SandboxRunResult =
z.infer<typeofSandboxRunResultSchema>
Defined in: src/schemas/execution.ts:30
CacheControlEphemeral
CacheControlEphemeral =
z.infer<typeofCacheControlEphemeralSchema>
Defined in: src/schemas/inference.ts:24
CacheControl
CacheControl =
z.infer<typeofCacheControlSchema>
Defined in: src/schemas/inference.ts:27
ImageBase64Source
ImageBase64Source =
z.infer<typeofImageBase64SourceSchema>
Defined in: src/schemas/inference.ts:40
ImageUrlSource
ImageUrlSource =
z.infer<typeofImageUrlSourceSchema>
Defined in: src/schemas/inference.ts:47
ImageSource
ImageSource =
z.infer<typeofImageSourceSchema>
Defined in: src/schemas/inference.ts:53
FileSource
FileSource =
ImageSource
Defined in: src/schemas/inference.ts:62
TextPart
TextPart =
z.infer<typeofTextPartSchema>
Defined in: src/schemas/inference.ts:70
ImagePart
ImagePart =
z.infer<typeofImagePartSchema>
Defined in: src/schemas/inference.ts:81
FilePart
FilePart =
z.infer<typeofFilePartSchema>
Defined in: src/schemas/inference.ts:95
ContentPart
ContentPart =
z.infer<typeofContentPartSchema>
Defined in: src/schemas/inference.ts:102
MessageContent
MessageContent =
z.infer<typeofMessageContentSchema>
Defined in: src/schemas/inference.ts:115
ToolDef
ToolDef =
z.infer<typeofToolDefSchema>
Defined in: src/schemas/inference.ts:147
ToolCall
ToolCall =
z.infer<typeofToolCallSchema>
Defined in: src/schemas/inference.ts:164
Message
Message =
z.infer<typeofMessageSchema>
Defined in: src/schemas/inference.ts:183
TokenUsage
TokenUsage =
z.infer<typeofTokenUsageSchema>
Defined in: src/schemas/inference.ts:197
NamedToolChoice
NamedToolChoice =
z.infer<typeofNamedToolChoiceSchema>
Defined in: src/schemas/inference.ts:225
ToolChoice
ToolChoice =
z.infer<typeofToolChoiceSchema>
Defined in: src/schemas/inference.ts:231
FinishReason
FinishReason =
z.infer<typeofFinishReasonSchema>
Defined in: src/schemas/inference.ts:234
ReasoningEffort
ReasoningEffort =
z.infer<typeofReasoningEffortSchema>
Defined in: src/schemas/inference.ts:245
ReasoningConfig
ReasoningConfig =
z.infer<typeofReasoningConfigSchema>
Defined in: src/schemas/inference.ts:289
InferenceRequest
InferenceRequest =
z.infer<typeofInferenceRequestSchema>
Defined in: src/schemas/inference.ts:367
InferenceResponse
InferenceResponse =
z.infer<typeofInferenceResponseSchema>
Defined in: src/schemas/inference.ts:415
StreamChunkKind
StreamChunkKind =
z.infer<typeofStreamChunkKindSchema>
Defined in: src/schemas/inference.ts:425
ToolCallPartial
ToolCallPartial =
z.infer<typeofToolCallPartialSchema>
Defined in: src/schemas/inference.ts:433
StreamChunk
StreamChunk =
z.infer<typeofStreamChunkSchema>
Defined in: src/schemas/inference.ts:462
ModelCallOptions
ModelCallOptions =
object
Defined in: src/schemas/inference.ts:476
Per-call options threaded into Model.infer and
Model.stream. Adapters that hit the network combine
opts.signal with their constructor-level signal (whichever fires
first aborts the in-flight fetch); pure-compute models can ignore it.
The runner forwards RunOptions.signal through here so a
caller-level abort cancels in-flight HTTP requests in addition to the
runner's own for await loop. Without this, aborting the runner only
stopped further iterations and left the current model call hanging
unless the constructor was given the same signal up-front.
Properties
signal?
optionalsignal?:AbortSignal
Defined in: src/schemas/inference.ts:477
ModelPricing
ModelPricing =
z.infer<typeofModelPricingSchema>
Defined in: src/schemas/inference.ts:529
ModelSpec
ModelSpec =
z.infer<typeofModelSpecSchema>
Defined in: src/schemas/inference.ts:555
MemoryRecord
MemoryRecord =
z.infer<typeofMemoryRecordSchema>
Defined in: src/schemas/memory.ts:10
MemoryQuery
MemoryQuery =
z.infer<typeofMemoryQuerySchema>
Defined in: src/schemas/memory.ts:18
MemoryScope
MemoryScope =
z.infer<typeofMemoryScopeSchema>
Defined in: src/schemas/memory.ts:24
ObservationStatus
ObservationStatus =
z.infer<typeofObservationStatusSchema>
Defined in: src/schemas/memory.ts:38
ObservationRecord
ObservationRecord =
z.infer<typeofObservationRecordSchema>
Defined in: src/schemas/memory.ts:60
ReflectionRecord
ReflectionRecord =
ObservationRecord
Defined in: src/schemas/memory.ts:63
ObservationState
ObservationState =
z.infer<typeofObservationStateSchema>
Defined in: src/schemas/memory.ts:73
ObservationalMemoryConfig
ObservationalMemoryConfig =
z.infer<typeofObservationalMemoryConfigSchema>
Defined in: src/schemas/memory.ts:123
WorkingMemoryConfig
WorkingMemoryConfig =
z.infer<typeofWorkingMemoryConfigSchema>
Defined in: src/schemas/memory.ts:204
MemoryRelevanceFilterConfig
MemoryRelevanceFilterConfig =
z.infer<typeofMemoryRelevanceFilterConfigSchema>
Defined in: src/schemas/memory.ts:282
MemoryAccessMode
MemoryAccessMode =
z.infer<typeofMemoryAccessModeSchema>
Defined in: src/schemas/memory.ts:299
RuntimeMemoryAccess
RuntimeMemoryAccess =
z.infer<typeofRuntimeMemoryAccessSchema>
Defined in: src/schemas/memory.ts:324
RuntimeMemoryAccessInput
RuntimeMemoryAccessInput =
object
Defined in: src/schemas/memory.ts:330
Caller-friendly partial input accepted by ChatOptions.memory.
Omitted keys default to "write".
Properties
observational?
optionalobservational?:MemoryAccessMode
Defined in: src/schemas/memory.ts:331
working?
optionalworking?:MemoryAccessMode
Defined in: src/schemas/memory.ts:332
GuardrailAction
GuardrailAction =
z.infer<typeofGuardrailActionSchema>
Defined in: src/schemas/middleware.ts:17
GuardrailAllowDecision
GuardrailAllowDecision =
z.infer<typeofGuardrailAllowDecisionSchema>
Defined in: src/schemas/middleware.ts:24
GuardrailRewriteDecision
GuardrailRewriteDecision =
z.infer<typeofGuardrailRewriteDecisionSchema>
Defined in: src/schemas/middleware.ts:32
GuardrailBlockDecision
GuardrailBlockDecision =
z.infer<typeofGuardrailBlockDecisionSchema>
Defined in: src/schemas/middleware.ts:39
GuardrailRequireApprovalDecision
GuardrailRequireApprovalDecision =
z.infer<typeofGuardrailRequireApprovalDecisionSchema>
Defined in: src/schemas/middleware.ts:52
GuardrailDecision
GuardrailDecision =
z.infer<typeofGuardrailDecisionSchema>
Defined in: src/schemas/middleware.ts:60
LMCallContext
LMCallContext =
z.infer<typeofLMCallContextSchema>
Defined in: src/schemas/middleware.ts:105
ToolCallContext
ToolCallContext =
z.infer<typeofToolCallContextSchema>
Defined in: src/schemas/middleware.ts:114
ArgConstraintOp
ArgConstraintOp =
z.infer<typeofArgConstraintOpSchema>
Defined in: src/schemas/permissions.ts:18
ArgConstraintQuantifier
ArgConstraintQuantifier =
z.infer<typeofArgConstraintQuantifierSchema>
Defined in: src/schemas/permissions.ts:28
ArgConstraint
ArgConstraint =
z.infer<typeofArgConstraintSchema>
Defined in: src/schemas/permissions.ts:42
PermissionScope
PermissionScope =
z.infer<typeofPermissionScopeSchema>
Defined in: src/schemas/permissions.ts:49
PermissionEffect
PermissionEffect =
z.infer<typeofPermissionEffectSchema>
Defined in: src/schemas/permissions.ts:65
Permission
Permission =
z.infer<typeofPermissionSchema>
Defined in: src/schemas/permissions.ts:73
PendingAction
PendingAction =
z.infer<typeofPendingActionSchema>
Defined in: src/schemas/permissions.ts:79
Decision
Decision =
z.infer<typeofDecisionSchema>
Defined in: src/schemas/permissions.ts:87
ReplConfig
ReplConfig =
Omit<z.infer<typeofReplConfigSchema>,"sandbox"> &object
Defined in: src/schemas/repl.ts:12
Type Declaration
sandbox?
optionalsandbox?:Sandbox|null
ReplConfigInput
ReplConfigInput =
Omit<z.input<typeofReplConfigSchema>,"sandbox"> &object
Defined in: src/schemas/repl.ts:16
Type Declaration
sandbox?
optionalsandbox?:Sandbox|null
ToolSchema
ToolSchema =
z.infer<typeofToolSchemaSchema>
Defined in: src/schemas/tools.ts:12
RuntimeToolCall
RuntimeToolCall =
z.infer<typeofRuntimeToolCallSchema>
Defined in: src/schemas/tools.ts:20
ToolResultCause
ToolResultCause =
z.infer<typeofToolResultCauseSchema>
Defined in: src/schemas/tools.ts:47
ToolResult
ToolResult =
z.infer<typeofToolResultSchema>
Defined in: src/schemas/tools.ts:63
MCPTransport
MCPTransport =
"stdio"|"sse"|"streamable_http"
Defined in: src/tools/adapters/mcp.ts:38
SessionFactory
SessionFactory = () =>
Promise<MCPSessionHandle>
Defined in: src/tools/adapters/mcp.ts:85
Returns
Promise<MCPSessionHandle>
ToolHandler
ToolHandler<
TInput> = (args) =>unknown|Promise<unknown>
Defined in: src/tools/base.ts:8
Type Parameters
TInput
TInput extends JsonDict = JsonDict
Parameters
args
TInput
Returns
unknown | Promise<unknown>
DelegatedToolOptions
DelegatedToolOptions =
object
Defined in: src/tools/base.ts:10
Properties
instructions?
optionalinstructions?:string
Defined in: src/tools/base.ts:11
model?
optionalmodel?:Model
Defined in: src/tools/base.ts:12
max_depth?
optionalmax_depth?:number
Defined in: src/tools/base.ts:13
policy?
optionalpolicy?:Agent["policy"]
Defined in: src/tools/base.ts:14
lm_middleware?
optionallm_middleware?:Agent["lm_middleware"]
Defined in: src/tools/base.ts:15
tool_middleware?
optionaltool_middleware?:Agent["tool_middleware"]
Defined in: src/tools/base.ts:16
lm_guardrails?
optionallm_guardrails?:Agent["lm_guardrails"]
Defined in: src/tools/base.ts:17
tool_guardrails?
optionaltool_guardrails?:Agent["tool_guardrails"]
Defined in: src/tools/base.ts:18
ToolOptions
ToolOptions<
TInput> =object
Defined in: src/tools/base.ts:21
Type Parameters
TInput
TInput extends JsonDict = JsonDict
Properties
name
name:
string
Defined in: src/tools/base.ts:22
description?
optionaldescription?:string
Defined in: src/tools/base.ts:23
inputSchema
inputSchema:
JsonDict
Defined in: src/tools/base.ts:24
outputSchema?
optionaloutputSchema?:JsonDict|null
Defined in: src/tools/base.ts:25
tags?
optionaltags?:string[]
Defined in: src/tools/base.ts:26
parse?
optionalparse?:z.ZodType<TInput>
Defined in: src/tools/base.ts:27
background?
optionalbackground?:unknown
Defined in: src/tools/base.ts:28
handler
handler:
ToolHandler<TInput>
Defined in: src/tools/base.ts:29
Variables
OBSERVER_SYSTEM_PROMPT
constOBSERVER_SYSTEM_PROMPT:string
Defined in: src/agents/observationalMemory/prompts.ts:16
Observer / Reflector system prompts.
Both prompts are copy-tuned to match Mastra's published format -- a
dated bullet list with optional priority markers and short trailing
metadata sections for current_task and suggested_response.
The prompts are intentionally compact: each Observer call sees a range of raw messages, and the Reflector sees a range of prior observations, so adding a long preamble inflates the background-LM input for no benefit.
Mirrors Python agents/observational_memory/prompts.py.
REFLECTOR_SYSTEM_PROMPT
constREFLECTOR_SYSTEM_PROMPT:string
Defined in: src/agents/observationalMemory/prompts.ts:43
DEFAULT_ANTHROPIC_BASE_URL
constDEFAULT_ANTHROPIC_BASE_URL:"https://api.anthropic.com/v1"="https://api.anthropic.com/v1"
Defined in: src/inference/adapters/anthropic.ts:77
DEFAULT_ANTHROPIC_API_VERSION
constDEFAULT_ANTHROPIC_API_VERSION:"2023-06-01"="2023-06-01"
Defined in: src/inference/adapters/anthropic.ts:78
DEFAULT_ANTHROPIC_API_KEY_ENV_VAR
constDEFAULT_ANTHROPIC_API_KEY_ENV_VAR:"ANTHROPIC_API_KEY"="ANTHROPIC_API_KEY"
Defined in: src/inference/adapters/anthropic.ts:79
DEFAULT_ANTHROPIC_MAX_TOKENS
constDEFAULT_ANTHROPIC_MAX_TOKENS:4096=4096
Defined in: src/inference/adapters/anthropic.ts:80
DEFAULT_OPENAI_COMPATIBLE_BASE_URL
constDEFAULT_OPENAI_COMPATIBLE_BASE_URL:"https://api.openai.com/v1"="https://api.openai.com/v1"
Defined in: src/inference/adapters/openaiCompatible.ts:25
DEFAULT_OPENAI_COMPATIBLE_API_KEY_ENV_VAR
constDEFAULT_OPENAI_COMPATIBLE_API_KEY_ENV_VAR:"OPENAI_API_KEY"="OPENAI_API_KEY"
Defined in: src/inference/adapters/openaiCompatible.ts:26
DEFAULT_OPENROUTER_BASE_URL
constDEFAULT_OPENROUTER_BASE_URL:"https://openrouter.ai/api/v1"="https://openrouter.ai/api/v1"
Defined in: src/inference/adapters/openrouter.ts:13
DEFAULT_OPENROUTER_API_KEY_ENV_VAR
constDEFAULT_OPENROUTER_API_KEY_ENV_VAR:"OPENROUTER_API_KEY"="OPENROUTER_API_KEY"
Defined in: src/inference/adapters/openrouter.ts:14
DEFAULT_VERCEL_GATEWAY_BASE_URL
constDEFAULT_VERCEL_GATEWAY_BASE_URL:"https://ai-gateway.vercel.sh/v1"="https://ai-gateway.vercel.sh/v1"
Defined in: src/inference/adapters/vercelGateway.ts:13
DEFAULT_VERCEL_GATEWAY_API_KEY_ENV_VAR
constDEFAULT_VERCEL_GATEWAY_API_KEY_ENV_VAR:"AI_GATEWAY_API_KEY"="AI_GATEWAY_API_KEY"
Defined in: src/inference/adapters/vercelGateway.ts:19
Primary credential env var for the Vercel AI Gateway. A long-lived project API key minted from the Vercel dashboard.
DEFAULT_VERCEL_OIDC_TOKEN_ENV_VAR
constDEFAULT_VERCEL_OIDC_TOKEN_ENV_VAR:"VERCEL_OIDC_TOKEN"="VERCEL_OIDC_TOKEN"
Defined in: src/inference/adapters/vercelGateway.ts:26
Fallback credential env var. Vercel runtimes inject a short-lived
OIDC token under this name; the gateway accepts it on the same
Authorization: Bearer header as an API key.
ALL_MEMORY_SCOPE
constALL_MEMORY_SCOPE:MemoryScope
Defined in: src/memory/base.ts:58
AgentBudgetSchema
constAgentBudgetSchema:ZodObject<{max_iterations:ZodDefault<ZodNumber>;max_tokens:ZodOptional<ZodNullable<ZodNumber>>;max_cost_usd:ZodOptional<ZodNullable<ZodNumber>>;max_wall_seconds:ZodOptional<ZodNullable<ZodNumber>>; },$strip>
Defined in: src/schemas/agents.ts:30
RequestContextSchema
constRequestContextSchema:ZodObject<{query:ZodString;agent_id:ZodString;resource_id:ZodOptional<ZodNullable<ZodString>>;metadata:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>; },$strip>
Defined in: src/schemas/agents.ts:38
TraceKindSchema
constTraceKindSchema:ZodEnum<{error:"error";tool:"tool";cell:"cell";subagent:"subagent";lm_call:"lm_call";lm_call_start:"lm_call_start";token:"token";agent:"agent";tool_call_arguments_delta:"tool_call_arguments_delta";memory:"memory";guardrail:"guardrail";retry:"retry";approval:"approval";step:"step";final:"final";background_task:"background_task";stream_gap:"stream_gap";plan:"plan"; }>
Defined in: src/schemas/agents.ts:81
TokenPayloadSchema
constTokenPayloadSchema:ZodObject<{model:ZodOptional<ZodString>;scope:ZodOptional<ZodString>;iteration:ZodOptional<ZodNumber>;toolset:ZodOptional<ZodNullable<ZodString>>;lm_span_id:ZodOptional<ZodNullable<ZodString>>;usage_delta:ZodOptional<ZodNullable<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>>;finish_reason:ZodOptional<ZodNullable<ZodString>>;raw_finish_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:142
LMCallStartPayloadSchema
constLMCallStartPayloadSchema:ZodObject<{model:ZodDefault<ZodString>;scope:ZodDefault<ZodString>;iteration:ZodDefault<ZodNumber>;toolset:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:157
LMCallPayloadSchema
constLMCallPayloadSchema:ZodObject<{model:ZodDefault<ZodString>;scope:ZodDefault<ZodString>;iteration:ZodDefault<ZodNumber>;usage:ZodDefault<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>;finish_reason:ZodDefault<ZodString>;toolset:ZodOptional<ZodNullable<ZodString>>;raw_finish_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:165
ToolPhaseSchema
constToolPhaseSchema:ZodEnum<{completed:"completed";failed:"failed";cancelled:"cancelled";started:"started"; }>
Defined in: src/schemas/agents.ts:176
ToolResultPreviewSchema
constToolResultPreviewSchema:ZodObject<{ok:ZodOptional<ZodBoolean>;value:ZodOptional<ZodNullable<ZodUnknown>>;error:ZodOptional<ZodNullable<ZodString>>;metadata:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;result_truncated:ZodOptional<ZodBoolean>;value_omitted_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:195
Bounded preview of a ToolResult attached to tool completed/failed
events for trace visibility. The full ToolResult continues to flow
through tool messages unchanged; this preview is JSON-safe and capped so
the trace stream does not balloon on large tool outputs.
result_truncated is set when the stringified value exceeded the cap
and was elided. value may also be null when the source result was
non-JSON-serializable; in that case value_omitted_reason describes why.
Producers from this SDK always populate ok, error, and metadata;
ok is left optional in the schema for forward-compat with consumers
that already used result_preview as a passthrough informal field
(e.g. early orch transcript prototypes). New consumers should treat
the SDK shape as the contract.
ToolPayloadSchema
constToolPayloadSchema:ZodObject<{tool_call_id:ZodString;tool_name:ZodString;toolset:ZodOptional<ZodNullable<ZodString>>;phase:ZodEnum<{completed:"completed";failed:"failed";cancelled:"cancelled";started:"started"; }>;args:ZodOptional<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;result:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;result_preview:ZodOptional<ZodNullable<ZodObject<{ok:ZodOptional<ZodBoolean>;value:ZodOptional<ZodNullable<ZodUnknown>>;error:ZodOptional<ZodNullable<ZodString>>;metadata:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;result_truncated:ZodOptional<ZodBoolean>;value_omitted_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>>>;ok:ZodOptional<ZodNullable<ZodBoolean>>;allowed:ZodOptional<ZodNullable<ZodBoolean>>;error:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;started_at:ZodOptional<ZodNullable<ZodString>>;finished_at:ZodOptional<ZodNullable<ZodString>>;elapsed_ms:ZodOptional<ZodNullable<ZodNumber>>;decision:ZodOptional<ZodNullable<ZodObject<{allowed:ZodBoolean;requires_approval:ZodDefault<ZodBoolean>;matched_rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$loose>>>; },$loose>
Defined in: src/schemas/agents.ts:205
ToolCallArgumentsDeltaPayloadSchema
constToolCallArgumentsDeltaPayloadSchema:ZodObject<{tool_call_id:ZodOptional<ZodNullable<ZodString>>;tool_name:ZodOptional<ZodNullable<ZodString>>;index:ZodDefault<ZodNumber>;arguments_delta:ZodDefault<ZodString>;sequence:ZodDefault<ZodNumber>; },$loose>
Defined in: src/schemas/agents.ts:265
Normalized streaming delta for a single tool call's arguments JSON.
Provider adapters (OpenAI, Anthropic, OpenRouter, ...) stream tool-call
arguments piecewise as the LM emits them. This payload normalizes
that stream onto a single shape so consumers (OTel exporter, CLI,
JSONL traces) can render argument deltas uniformly without parsing
the raw tool_call_delta chunk shape on token events.
Wire fields:
tool_call_id: the LM-supplied tool call id once the adapter has surfaced it.nullfor the first delta on providers that emit the id mid-stream; populated thereafter.tool_name: function name once known. Same nullability as id.index: position of the call in the finalInferenceResponse.tool_callslist. Stable across deltas for the same call so consumers can group on it without an id.arguments_delta: the partial JSON fragment emitted by this chunk (the increment, not the cumulative concat).sequence: monotonic counter per(turn_id, index)pair so consumers can detect missing or out-of-order deltas.
Mirrors Python ToolCallArgumentsDeltaPayload byte-for-byte.
CellPhaseSchema
constCellPhaseSchema:ZodEnum<{completed:"completed";failed:"failed";cancelled:"cancelled";started:"started"; }>
Defined in: src/schemas/agents.ts:274
CellPayloadSchema
constCellPayloadSchema:ZodObject<{cell_id:ZodString;phase:ZodEnum<{completed:"completed";failed:"failed";cancelled:"cancelled";started:"started"; }>;code:ZodOptional<ZodNullable<ZodString>>;result:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;error:ZodOptional<ZodNullable<ZodString>>;elapsed_ms:ZodOptional<ZodNullable<ZodNumber>>;stdout_len:ZodOptional<ZodNullable<ZodNumber>>;stderr_len:ZodOptional<ZodNullable<ZodNumber>>;variables:ZodOptional<ZodNullable<ZodArray<ZodString>>>;src:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:277
SubagentPhaseSchema
constSubagentPhaseSchema:ZodEnum<{error:"error";completed:"completed";intent:"intent";start:"start";paused:"paused";errored:"errored"; }>
Defined in: src/schemas/agents.ts:291
SubagentPayloadSchema
constSubagentPayloadSchema:ZodObject<{phase:ZodEnum<{error:"error";completed:"completed";intent:"intent";start:"start";paused:"paused";errored:"errored"; }>;agent_id:ZodOptional<ZodNullable<ZodString>>;toolset:ZodOptional<ZodNullable<ZodString>>;role:ZodOptional<ZodNullable<ZodString>>;prompt_summary:ZodOptional<ZodNullable<ZodString>>;prompt:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;background:ZodOptional<ZodNullable<ZodBoolean>>;iterations:ZodOptional<ZodNullable<ZodNumber>>;reason:ZodOptional<ZodNullable<ZodString>>;max_depth:ZodOptional<ZodNullable<ZodNumber>>;repl:ZodOptional<ZodNullable<ZodBoolean>>;usage:ZodOptional<ZodNullable<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>>; },$loose>
Defined in: src/schemas/agents.ts:301
AgentPhaseSchema
constAgentPhaseSchema:ZodEnum<{completed:"completed";started:"started"; }>
Defined in: src/schemas/agents.ts:318
AgentPayloadSchema
constAgentPayloadSchema:ZodObject<{phase:ZodEnum<{completed:"completed";started:"started"; }>;agent_id:ZodString;principal:ZodOptional<ZodNullable<ZodString>>;iterations:ZodOptional<ZodNullable<ZodNumber>>; },$loose>
Defined in: src/schemas/agents.ts:321
ApprovalPhaseSchema
constApprovalPhaseSchema:ZodEnum<{requested:"requested";approved:"approved";denied:"denied";resolved:"resolved"; }>
Defined in: src/schemas/agents.ts:331
ApprovalSourceSchema
constApprovalSourceSchema:ZodEnum<{guardrail:"guardrail";policy:"policy"; }>
Defined in: src/schemas/agents.ts:334
ApprovalDecisionSchema
constApprovalDecisionSchema:ZodEnum<{approve:"approve";deny:"deny"; }>
Defined in: src/schemas/agents.ts:337
ApprovalPayloadSchema
constApprovalPayloadSchema:ZodObject<{phase:ZodEnum<{requested:"requested";approved:"approved";denied:"denied";resolved:"resolved"; }>;id:ZodOptional<ZodString>;toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodOptional<ZodNullable<ZodString>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;source:ZodDefault<ZodEnum<{guardrail:"guardrail";policy:"policy"; }>>;decision:ZodOptional<ZodNullable<ZodEnum<{approve:"approve";deny:"deny"; }>>>;approvals:ZodDefault<ZodArray<ZodObject<{id:ZodString;principal:ZodString;toolset:ZodString;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;requested_at:ZodDefault<ZodString>;sub_actions:ZodDefault<ZodArray<ZodObject<{id:ZodString;toolset:ZodOptional<...>;tool:ZodString;args:ZodDefault<...>;rule_id:ZodOptional<...>;reason:ZodOptional<...>; },$strip>>>; },$strip>>>; },$loose>
Defined in: src/schemas/agents.ts:340
MemoryPayloadSchema
constMemoryPayloadSchema:ZodObject<{op:ZodDefault<ZodString>;phase:ZodOptional<ZodNullable<ZodString>>;principal:ZodOptional<ZodNullable<ZodString>>;depth:ZodOptional<ZodNullable<ZodNumber>>;summary:ZodOptional<ZodNullable<ZodString>>;namespace:ZodOptional<ZodNullable<ZodString>>;agent_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:362
GuardrailPayloadSchema
constGuardrailPayloadSchema:ZodObject<{phase:ZodDefault<ZodString>;boundary:ZodOptional<ZodNullable<ZodString>>;action:ZodOptional<ZodNullable<ZodString>>;decision:ZodOptional<ZodNullable<ZodString>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:374
BackgroundTaskPayloadSchema
constBackgroundTaskPayloadSchema:ZodObject<{phase:ZodDefault<ZodString>;task_id:ZodDefault<ZodString>;status:ZodOptional<ZodNullable<ZodString>>;progress:ZodOptional<ZodNullable<ZodNumber>>;output:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;agent_id:ZodOptional<ZodNullable<ZodString>>;sub_agent_id:ZodOptional<ZodNullable<ZodString>>;tool:ZodOptional<ZodNullable<ZodString>>;attempt:ZodOptional<ZodNullable<ZodNumber>>;error:ZodOptional<ZodNullable<ZodString>>;iterations:ZodOptional<ZodNullable<ZodNumber>>;timeout_ms:ZodOptional<ZodNullable<ZodNumber>>; },$loose>
Defined in: src/schemas/agents.ts:384
StepPhaseSchema
constStepPhaseSchema:ZodEnum<{before:"before";after:"after";repair:"repair";stopped:"stopped";finalize_vetoed:"finalize_vetoed"; }>
Defined in: src/schemas/agents.ts:404
StepPayloadSchema
constStepPayloadSchema:ZodObject<{phase:ZodEnum<{before:"before";after:"after";repair:"repair";stopped:"stopped";finalize_vetoed:"finalize_vetoed"; }>;turn_index:ZodDefault<ZodNumber>;iteration:ZodOptional<ZodNullable<ZodNumber>>;source:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;elapsed_ms:ZodOptional<ZodNullable<ZodNumber>>; },$loose>
Defined in: src/schemas/agents.ts:407
RetryPayloadSchema
constRetryPayloadSchema:ZodObject<{attempt:ZodDefault<ZodNumber>;reason:ZodDefault<ZodString>;model:ZodOptional<ZodNullable<ZodString>>;max_attempts:ZodOptional<ZodNullable<ZodNumber>>;delay_s:ZodOptional<ZodNullable<ZodNumber>>;fallback:ZodOptional<ZodNullable<ZodBoolean>>; },$loose>
Defined in: src/schemas/agents.ts:417
FinalPayloadSchema
constFinalPayloadSchema:ZodObject<{source:ZodDefault<ZodString>;iterations:ZodOptional<ZodNullable<ZodNumber>>;validated:ZodOptional<ZodNullable<ZodBoolean>>;error:ZodOptional<ZodNullable<ZodString>>;pending:ZodOptional<ZodNullable<ZodNumber>>; },$loose>
Defined in: src/schemas/agents.ts:427
ErrorPayloadSchema
constErrorPayloadSchema:ZodObject<{message:ZodDefault<ZodString>;kind_of_error:ZodOptional<ZodNullable<ZodString>>;cause:ZodOptional<ZodNullable<ZodString>>;retryable:ZodOptional<ZodNullable<ZodBoolean>>;reason:ZodOptional<ZodNullable<ZodString>>;detail:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/agents.ts:436
ContentPartKindSchema
constContentPartKindSchema:ZodEnum<{file:"file";text:"text";image:"image"; }>
Defined in: src/schemas/agents.ts:456
Discriminator for the content-part kind a TokenEvent's delta
belongs to. Set by the runner when streaming a multimodal assistant
message so consumers (e.g. the TUI) can route image/file deltas onto
a separate visual lane from plain-text deltas. Plain-text streams
leave it null/omitted (back-compat with consumers that only read
chunk_kind).
TokenEventSchema
constTokenEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"token">;payload:ZodDefault<ZodObject<{model:ZodOptional<ZodString>;scope:ZodOptional<ZodString>;iteration:ZodOptional<ZodNumber>;toolset:ZodOptional<ZodNullable<ZodString>>;lm_span_id:ZodOptional<ZodNullable<ZodString>>;usage_delta:ZodOptional<ZodNullable<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<...>>;cache_creation_input_tokens:ZodOptional<ZodNullable<...>>;cache_read_input_tokens:ZodOptional<ZodNullable<...>>; },$strip>>>;finish_reason:ZodOptional<ZodNullable<ZodString>>;raw_finish_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>>;delta:ZodDefault<ZodString>;chunk_kind:ZodOptional<ZodNullable<ZodEnum<{text:"text";reasoning:"reasoning";json_partial:"json_partial";object_partial:"object_partial";tool_call_partial:"tool_call_partial";control:"control"; }>>>;content_part_kind:ZodOptional<ZodNullable<ZodEnum<{file:"file";text:"text";image:"image"; }>>>;partial_object:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;tool_call_delta:ZodOptional<ZodNullable<ZodObject<{index:ZodDefault<ZodNumber>;id:ZodOptional<ZodNullable<ZodString>>;name:ZodOptional<ZodNullable<ZodString>>;arguments_partial:ZodDefault<ZodString>; },$strip>>>; },$strip>
Defined in: src/schemas/agents.ts:459
LMCallStartEventSchema
constLMCallStartEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"lm_call_start">;payload:ZodObject<{model:ZodDefault<ZodString>;scope:ZodDefault<ZodString>;iteration:ZodDefault<ZodNumber>;toolset:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:479
LMCallEventSchema
constLMCallEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"lm_call">;payload:ZodObject<{model:ZodDefault<ZodString>;scope:ZodDefault<ZodString>;iteration:ZodDefault<ZodNumber>;usage:ZodDefault<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>;finish_reason:ZodDefault<ZodString>;toolset:ZodOptional<ZodNullable<ZodString>>;raw_finish_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:486
ToolEventSchema
constToolEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"tool">;payload:ZodObject<{tool_call_id:ZodString;tool_name:ZodString;toolset:ZodOptional<ZodNullable<ZodString>>;phase:ZodEnum<{completed:"completed";failed:"failed";cancelled:"cancelled";started:"started"; }>;args:ZodOptional<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;result:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;result_preview:ZodOptional<ZodNullable<ZodObject<{ok:ZodOptional<ZodBoolean>;value:ZodOptional<ZodNullable<ZodUnknown>>;error:ZodOptional<ZodNullable<ZodString>>;metadata:ZodOptional<ZodNullable<ZodType<..., ..., ...>>>;result_truncated:ZodOptional<ZodBoolean>;value_omitted_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>>>;ok:ZodOptional<ZodNullable<ZodBoolean>>;allowed:ZodOptional<ZodNullable<ZodBoolean>>;error:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;started_at:ZodOptional<ZodNullable<ZodString>>;finished_at:ZodOptional<ZodNullable<ZodString>>;elapsed_ms:ZodOptional<ZodNullable<ZodNumber>>;decision:ZodOptional<ZodNullable<ZodObject<{allowed:ZodBoolean;requires_approval:ZodDefault<ZodBoolean>;matched_rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$loose>>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:493
ToolCallArgumentsDeltaEventSchema
constToolCallArgumentsDeltaEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"tool_call_arguments_delta">;payload:ZodObject<{tool_call_id:ZodOptional<ZodNullable<ZodString>>;tool_name:ZodOptional<ZodNullable<ZodString>>;index:ZodDefault<ZodNumber>;arguments_delta:ZodDefault<ZodString>;sequence:ZodDefault<ZodNumber>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:500
CellEventSchema
constCellEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"cell">;payload:ZodObject<{cell_id:ZodString;phase:ZodEnum<{completed:"completed";failed:"failed";cancelled:"cancelled";started:"started"; }>;code:ZodOptional<ZodNullable<ZodString>>;result:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;error:ZodOptional<ZodNullable<ZodString>>;elapsed_ms:ZodOptional<ZodNullable<ZodNumber>>;stdout_len:ZodOptional<ZodNullable<ZodNumber>>;stderr_len:ZodOptional<ZodNullable<ZodNumber>>;variables:ZodOptional<ZodNullable<ZodArray<ZodString>>>;src:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:507
SubagentEventSchema
constSubagentEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"subagent">;payload:ZodObject<{phase:ZodEnum<{error:"error";completed:"completed";intent:"intent";start:"start";paused:"paused";errored:"errored"; }>;agent_id:ZodOptional<ZodNullable<ZodString>>;toolset:ZodOptional<ZodNullable<ZodString>>;role:ZodOptional<ZodNullable<ZodString>>;prompt_summary:ZodOptional<ZodNullable<ZodString>>;prompt:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;background:ZodOptional<ZodNullable<ZodBoolean>>;iterations:ZodOptional<ZodNullable<ZodNumber>>;reason:ZodOptional<ZodNullable<ZodString>>;max_depth:ZodOptional<ZodNullable<ZodNumber>>;repl:ZodOptional<ZodNullable<ZodBoolean>>;usage:ZodOptional<ZodNullable<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:514
AgentEventSchema
constAgentEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"agent">;payload:ZodObject<{phase:ZodEnum<{completed:"completed";started:"started"; }>;agent_id:ZodString;principal:ZodOptional<ZodNullable<ZodString>>;iterations:ZodOptional<ZodNullable<ZodNumber>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:521
ApprovalEventSchema
constApprovalEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"approval">;payload:ZodObject<{phase:ZodEnum<{requested:"requested";approved:"approved";denied:"denied";resolved:"resolved"; }>;id:ZodOptional<ZodString>;toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodOptional<ZodNullable<ZodString>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;source:ZodDefault<ZodEnum<{guardrail:"guardrail";policy:"policy"; }>>;decision:ZodOptional<ZodNullable<ZodEnum<{approve:"approve";deny:"deny"; }>>>;approvals:ZodDefault<ZodArray<ZodObject<{id:ZodString;principal:ZodString;toolset:ZodString;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<..., ...>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;requested_at:ZodDefault<ZodString>;sub_actions:ZodDefault<ZodArray<ZodObject<..., ...>>>; },$strip>>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:528
MemoryEventSchema
constMemoryEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"memory">;payload:ZodObject<{op:ZodDefault<ZodString>;phase:ZodOptional<ZodNullable<ZodString>>;principal:ZodOptional<ZodNullable<ZodString>>;depth:ZodOptional<ZodNullable<ZodNumber>>;summary:ZodOptional<ZodNullable<ZodString>>;namespace:ZodOptional<ZodNullable<ZodString>>;agent_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:535
GuardrailEventSchema
constGuardrailEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"guardrail">;payload:ZodObject<{phase:ZodDefault<ZodString>;boundary:ZodOptional<ZodNullable<ZodString>>;action:ZodOptional<ZodNullable<ZodString>>;decision:ZodOptional<ZodNullable<ZodString>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:542
BackgroundTaskEventSchema
constBackgroundTaskEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"background_task">;payload:ZodObject<{phase:ZodDefault<ZodString>;task_id:ZodDefault<ZodString>;status:ZodOptional<ZodNullable<ZodString>>;progress:ZodOptional<ZodNullable<ZodNumber>>;output:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;agent_id:ZodOptional<ZodNullable<ZodString>>;sub_agent_id:ZodOptional<ZodNullable<ZodString>>;tool:ZodOptional<ZodNullable<ZodString>>;attempt:ZodOptional<ZodNullable<ZodNumber>>;error:ZodOptional<ZodNullable<ZodString>>;iterations:ZodOptional<ZodNullable<ZodNumber>>;timeout_ms:ZodOptional<ZodNullable<ZodNumber>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:549
StepEventSchema
constStepEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"step">;payload:ZodObject<{phase:ZodEnum<{before:"before";after:"after";repair:"repair";stopped:"stopped";finalize_vetoed:"finalize_vetoed"; }>;turn_index:ZodDefault<ZodNumber>;iteration:ZodOptional<ZodNullable<ZodNumber>>;source:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;elapsed_ms:ZodOptional<ZodNullable<ZodNumber>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:556
RetryEventSchema
constRetryEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"retry">;payload:ZodObject<{attempt:ZodDefault<ZodNumber>;reason:ZodDefault<ZodString>;model:ZodOptional<ZodNullable<ZodString>>;max_attempts:ZodOptional<ZodNullable<ZodNumber>>;delay_s:ZodOptional<ZodNullable<ZodNumber>>;fallback:ZodOptional<ZodNullable<ZodBoolean>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:563
FinalEventSchema
constFinalEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"final">;payload:ZodObject<{source:ZodDefault<ZodString>;iterations:ZodOptional<ZodNullable<ZodNumber>>;validated:ZodOptional<ZodNullable<ZodBoolean>>;error:ZodOptional<ZodNullable<ZodString>>;pending:ZodOptional<ZodNullable<ZodNumber>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:570
ErrorEventSchema
constErrorEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"error">;payload:ZodObject<{message:ZodDefault<ZodString>;kind_of_error:ZodOptional<ZodNullable<ZodString>>;cause:ZodOptional<ZodNullable<ZodString>>;retryable:ZodOptional<ZodNullable<ZodBoolean>>;reason:ZodOptional<ZodNullable<ZodString>>;detail:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:577
StreamGapPayloadSchema
constStreamGapPayloadSchema:ZodObject<{dropped_count_so_far:ZodDefault<ZodNumber>; },$loose>
Defined in: src/schemas/agents.ts:596
Marker event the Python tracer emits when its async queue drops
events under backpressure. Mirrored here so the TS discriminated
union accepts the kind without losing the surrounding events; the
payload uses .passthrough() so future producer-side fields flow
through without a schema bump.
dropped_count_so_far is the cumulative count of events dropped
since the run started (matches Python StreamGapPayload). UIs
should render a "stream degraded" affordance and can reconcile
the full event log from AgentResult.trace after run completion.
StreamGapEventSchema
constStreamGapEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"stream_gap">;payload:ZodObject<{dropped_count_so_far:ZodDefault<ZodNumber>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:601
PlanEntryPrioritySchema
constPlanEntryPrioritySchema:ZodEnum<{low:"low";medium:"medium";high:"high"; }>
Defined in: src/schemas/agents.ts:617
Plan primitives. Mirrors the Python PlanEntry / PlanPayload
shapes byte-for-byte and matches the ACP PlanEntry fields exactly
so the ACP server adapter forwards plan events without
translating any field names.
Per ACP semantics every plan event carries the COMPLETE list of
entries; consumers replace the prior plan wholesale.
PlanEntryStatusSchema
constPlanEntryStatusSchema:ZodEnum<{pending:"pending";completed:"completed";in_progress:"in_progress"; }>
Defined in: src/schemas/agents.ts:620
PlanEntrySchema
constPlanEntrySchema:ZodObject<{content:ZodString;priority:ZodDefault<ZodEnum<{low:"low";medium:"medium";high:"high"; }>>;status:ZodDefault<ZodEnum<{pending:"pending";completed:"completed";in_progress:"in_progress"; }>>; },$strip>
Defined in: src/schemas/agents.ts:627
PlanPayloadSchema
constPlanPayloadSchema:ZodObject<{entries:ZodDefault<ZodArray<ZodObject<{content:ZodString;priority:ZodDefault<ZodEnum<{low:"low";medium:"medium";high:"high"; }>>;status:ZodDefault<ZodEnum<{pending:"pending";completed:"completed";in_progress:"in_progress"; }>>; },$strip>>>; },$loose>
Defined in: src/schemas/agents.ts:634
PlanEventSchema
constPlanEventSchema:ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"plan">;payload:ZodObject<{entries:ZodDefault<ZodArray<ZodObject<{content:ZodString;priority:ZodDefault<ZodEnum<{low: ...;medium: ...;high: ...; }>>;status:ZodDefault<ZodEnum<{pending: ...;completed: ...;in_progress: ...; }>>; },$strip>>>; },$loose>; },$strip>
Defined in: src/schemas/agents.ts:639
TraceEventSchema
constTraceEventSchema:ZodDiscriminatedUnion<[ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"token">;payload:ZodDefault<ZodObject<{model:ZodOptional<ZodString>;scope:ZodOptional<ZodString>;iteration:ZodOptional<ZodNumber>;toolset:ZodOptional<ZodNullable<ZodString>>;lm_span_id:ZodOptional<ZodNullable<ZodString>>;usage_delta:ZodOptional<ZodNullable<ZodObject<{prompt: ...;completion: ...;cost_usd: ...;cache_creation_input_tokens: ...;cache_read_input_tokens: ...; },$strip>>>;finish_reason:ZodOptional<ZodNullable<ZodString>>;raw_finish_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>>;delta:ZodDefault<ZodString>;chunk_kind:ZodOptional<ZodNullable<ZodEnum<{text:"text";reasoning:"reasoning";json_partial:"json_partial";object_partial:"object_partial";tool_call_partial:"tool_call_partial";control:"control"; }>>>;content_part_kind:ZodOptional<ZodNullable<ZodEnum<{file:"file";text:"text";image:"image"; }>>>;partial_object:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;tool_call_delta:ZodOptional<ZodNullable<ZodObject<{index:ZodDefault<ZodNumber>;id:ZodOptional<ZodNullable<ZodString>>;name:ZodOptional<ZodNullable<ZodString>>;arguments_partial:ZodDefault<ZodString>; },$strip>>>; },$strip>,ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"lm_call_start">;payload:ZodObject<{model:ZodDefault<ZodString>;scope:ZodDefault<ZodString>;iteration:ZodDefault<ZodNumber>;toolset:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>,ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"lm_call">;payload:ZodObject<{model:ZodDefault<ZodString>;scope:ZodDefault<ZodString>;iteration:ZodDefault<ZodNumber>;usage:ZodDefault<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<...>>;cache_creation_input_tokens:ZodOptional<ZodNullable<...>>;cache_read_input_tokens:ZodOptional<ZodNullable<...>>; },$strip>>;finish_reason:ZodDefault<ZodString>;toolset:ZodOptional<ZodNullable<ZodString>>;raw_finish_reason:ZodOptional<ZodNullable<ZodString>>; },$loose>; },$strip>],"kind">
Defined in: src/schemas/agents.ts:646
AgentResultSchema
constAgentResultSchema:ZodObject<{status:ZodDefault<ZodEnum<{completed:"completed";paused:"paused";errored:"errored"; }>>;final:ZodString;output:ZodOptional<ZodNullable<ZodUnknown>>;iterations:ZodNumber;usage:ZodDefault<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>;trace:ZodDefault<ZodArray<ZodDiscriminatedUnion<[ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"token">;payload:ZodDefault<ZodObject<{model: ...;scope: ...;iteration: ...;toolset: ...;lm_span_id: ...;usage_delta: ...;finish_reason: ...;raw_finish_reason: ...; },$loose>>;delta:ZodDefault<ZodString>;chunk_kind:ZodOptional<ZodNullable<ZodEnum<...>>>;content_part_kind:ZodOptional<ZodNullable<ZodEnum<...>>>;partial_object:ZodOptional<ZodNullable<ZodType<..., ..., ...>>>;tool_call_delta:ZodOptional<ZodNullable<ZodObject<..., ...>>>; },$strip>,ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"lm_call_start">;payload:ZodObject<{model:ZodDefault<...>;scope:ZodDefault<...>;iteration:ZodDefault<...>;toolset:ZodOptional<...>; },$loose>; },$strip>,ZodObject<{ts:ZodDefault<ZodString>;depth:ZodDefault<ZodNumber>;principal:ZodOptional<ZodNullable<ZodString>>;span_id:ZodOptional<ZodNullable<ZodString>>;parent_span_id:ZodOptional<ZodNullable<ZodString>>;seq:ZodDefault<ZodNumber>;event_id:ZodDefault<ZodString>;run_id:ZodDefault<ZodString>;turn_id:ZodOptional<ZodNullable<ZodString>>;message_id:ZodOptional<ZodNullable<ZodString>>;block_id:ZodOptional<ZodNullable<ZodString>>;thread_id:ZodOptional<ZodNullable<ZodString>>;kind:ZodLiteral<"lm_call">;payload:ZodObject<{model:ZodDefault<...>;scope:ZodDefault<...>;iteration:ZodDefault<...>;usage:ZodDefault<...>;finish_reason:ZodDefault<...>;toolset:ZodOptional<...>;raw_finish_reason:ZodOptional<...>; },$loose>; },$strip>],"kind">>>;pending_approvals:ZodDefault<ZodArray<ZodObject<{id:ZodString;principal:ZodString;toolset:ZodString;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;requested_at:ZodDefault<ZodString>;sub_actions:ZodDefault<ZodArray<ZodObject<{id:ZodString;toolset:ZodOptional<...>;tool:ZodString;args:ZodDefault<...>;rule_id:ZodOptional<...>;reason:ZodOptional<...>; },$strip>>>; },$strip>>>;checkpoint:ZodOptional<ZodNullable<ZodObject<{schema_version:ZodDefault<ZodUnion<readonly [ZodLiteral<1>,ZodLiteral<2>]>>;spec_id:ZodString;iteration:ZodNumber;usage:ZodDefault<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<...>>;cache_creation_input_tokens:ZodOptional<ZodNullable<...>>;cache_read_input_tokens:ZodOptional<ZodNullable<...>>; },$strip>>;root_messages:ZodDefault<ZodArray<ZodObject<{role:ZodEnum<...>;content:ZodDefault<...>;name:ZodOptional<...>;tool_calls:ZodOptional<...>;tool_call_id:ZodOptional<...>; },$strip>>>;subagent_sessions:ZodDefault<ZodArray<ZodObject<{toolset:ZodString;messages:ZodDefault<...>;delegations:ZodDefault<...>; },$strip>>>;pending:ZodDefault<ZodArray<ZodObject<{id:ZodString;principal:ZodString;toolset:ZodString;tool:ZodString;args:ZodDefault<...>;rule_id:ZodOptional<...>;reason:ZodOptional<...>;requested_at:ZodDefault<...>;sub_actions:ZodDefault<...>; },$strip>>>;checkpoint_id:ZodOptional<ZodNullable<ZodString>>; },$strip>>>;messages:ZodDefault<ZodArray<ZodObject<{role:ZodEnum<{system:"system";user:"user";assistant:"assistant";tool:"tool"; }>;content:ZodDefault<ZodUnion<readonly [ZodString,ZodArray<ZodDiscriminatedUnion<..., ...>>]>>;name:ZodOptional<ZodNullable<ZodString>>;tool_calls:ZodOptional<ZodNullable<ZodArray<ZodObject<{id: ...;name: ...;arguments: ...;arguments_error: ...;arguments_raw: ...; },$strip>>>>;tool_call_id:ZodOptional<ZodNullable<ZodString>>; },$strip>>>; },$strip>
Defined in: src/schemas/agents.ts:700
normalizeAgentSpec
constnormalizeAgentSpec: (spec) =>Agent=normalizeAgent
Defined in: src/schemas/agents.ts:856
Parameters
spec
Returns
Deprecated
Use normalizeAgent.
PendingSubActionSchema
constPendingSubActionSchema:ZodObject<{id:ZodString;toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/approvals.ts:19
A single sub-call expanded out of a batched delegated_tool
invocation (Tier 1 #2).
A batched tool (e.g. a Composio allowlist app routing N upstream
API calls through one delegated tool) registers an
extractSubActions callback. The runtime expands the LM-side call
into a list of PendingSubAction entries, runs the permission
policy across them with a single evaluateMany call, and — if any
sub-action requires approval — mints a single PendingApproval
whose sub_actions carry per-sub metadata. The caller approves or
denies each sub-id independently via
ApprovalResponse.sub_decisions.
PendingApprovalSchema
constPendingApprovalSchema:ZodObject<{id:ZodString;principal:ZodString;toolset:ZodString;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;requested_at:ZodDefault<ZodString>;sub_actions:ZodDefault<ZodArray<ZodObject<{id:ZodString;toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>>>; },$strip>
Defined in: src/schemas/approvals.ts:29
ApprovalResponseSchema
constApprovalResponseSchema:ZodObject<{id:ZodString;decision:ZodEnum<{approve:"approve";deny:"deny"; }>;reason:ZodOptional<ZodNullable<ZodString>>;sub_decisions:ZodDefault<ZodRecord<ZodString,ZodEnum<{approve:"approve";deny:"deny"; }>>>; },$strip>
Defined in: src/schemas/approvals.ts:49
SerializedSessionSchema
constSerializedSessionSchema:ZodObject<{toolset:ZodString;messages:ZodDefault<ZodArray<ZodObject<{role:ZodEnum<{system:"system";user:"user";assistant:"assistant";tool:"tool"; }>;content:ZodDefault<ZodUnion<readonly [ZodString,ZodArray<ZodDiscriminatedUnion<..., ...>>]>>;name:ZodOptional<ZodNullable<ZodString>>;tool_calls:ZodOptional<ZodNullable<ZodArray<ZodObject<{id: ...;name: ...;arguments: ...;arguments_error: ...;arguments_raw: ...; },$strip>>>>;tool_call_id:ZodOptional<ZodNullable<ZodString>>; },$strip>>>;delegations:ZodDefault<ZodNumber>; },$strip>
Defined in: src/schemas/approvals.ts:81
RunCheckpointSchema
constRunCheckpointSchema:ZodObject<{schema_version:ZodDefault<ZodUnion<readonly [ZodLiteral<1>,ZodLiteral<2>]>>;spec_id:ZodString;iteration:ZodNumber;usage:ZodDefault<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>;root_messages:ZodDefault<ZodArray<ZodObject<{role:ZodEnum<{system:"system";user:"user";assistant:"assistant";tool:"tool"; }>;content:ZodDefault<ZodUnion<readonly [ZodString,ZodArray<ZodDiscriminatedUnion<..., ...>>]>>;name:ZodOptional<ZodNullable<ZodString>>;tool_calls:ZodOptional<ZodNullable<ZodArray<ZodObject<{id: ...;name: ...;arguments: ...;arguments_error: ...;arguments_raw: ...; },$strip>>>>;tool_call_id:ZodOptional<ZodNullable<ZodString>>; },$strip>>>;subagent_sessions:ZodDefault<ZodArray<ZodObject<{toolset:ZodString;messages:ZodDefault<ZodArray<ZodObject<{role:ZodEnum<...>;content:ZodDefault<...>;name:ZodOptional<...>;tool_calls:ZodOptional<...>;tool_call_id:ZodOptional<...>; },$strip>>>;delegations:ZodDefault<ZodNumber>; },$strip>>>;pending:ZodDefault<ZodArray<ZodObject<{id:ZodString;principal:ZodString;toolset:ZodString;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>;requested_at:ZodDefault<ZodString>;sub_actions:ZodDefault<ZodArray<ZodObject<{id:ZodString;toolset:ZodOptional<...>;tool:ZodString;args:ZodDefault<...>;rule_id:ZodOptional<...>;reason:ZodOptional<...>; },$strip>>>; },$strip>>>;checkpoint_id:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/approvals.ts:97
Durable, JSON-serialisable snapshot of a paused agent run.
schema_version is bumped to 2 (Tier 1 #2) to flag the additive
PendingApproval.sub_actions field. Loaders accept both 1 and
2 payloads via the tolerant decoder below; v1 records have
sub_actions: [] filled in on the way out so the runtime always
sees the v2 shape.
BackgroundStatusSchema
constBackgroundStatusSchema:ZodEnum<{queued:"queued";running:"running";completed:"completed";failed:"failed";cancelled:"cancelled"; }>
Defined in: src/schemas/background.ts:5
BackpressurePolicySchema
constBackpressurePolicySchema:ZodEnum<{queue:"queue";reject:"reject"; }>
Defined in: src/schemas/background.ts:14
BackgroundConfigSchema
constBackgroundConfigSchema:ZodObject<{enabled:ZodOptional<ZodNullable<ZodBoolean>>;timeout_s:ZodOptional<ZodNullable<ZodNumber>>;max_retries:ZodOptional<ZodNullable<ZodNumber>>;wait_timeout_s:ZodOptional<ZodNullable<ZodNumber>>; },$strip>
Defined in: src/schemas/background.ts:26
AgentBackgroundConfigSchema
constAgentBackgroundConfigSchema:ZodObject<{tools:ZodDefault<ZodRecord<ZodString,ZodUnion<readonly [ZodObject<{enabled:ZodOptional<ZodNullable<ZodBoolean>>;timeout_s:ZodOptional<ZodNullable<ZodNumber>>;max_retries:ZodOptional<ZodNullable<ZodNumber>>;wait_timeout_s:ZodOptional<ZodNullable<ZodNumber>>; },$strip>,ZodBoolean]>>>;disabled:ZodDefault<ZodBoolean>;wait_timeout_s:ZodOptional<ZodNullable<ZodNumber>>; },$strip>
Defined in: src/schemas/background.ts:47
BackgroundTasksConfigSchema
constBackgroundTasksConfigSchema:ZodObject<{enabled:ZodDefault<ZodBoolean>;global_concurrency:ZodDefault<ZodNumber>;per_agent_concurrency:ZodDefault<ZodNumber>;default_timeout_s:ZodDefault<ZodNumber>;default_retries:ZodDefault<ZodNumber>;default_wait_timeout_s:ZodDefault<ZodNumber>;backpressure:ZodDefault<ZodEnum<{queue:"queue";reject:"reject"; }>>; },$strip>
Defined in: src/schemas/background.ts:63
BackgroundTaskRecordSchema
constBackgroundTaskRecordSchema:ZodObject<{id:ZodDefault<ZodString>;task_id:ZodString;agent_id:ZodString;thread_id:ZodString;tool_call_id:ZodString;tool_name:ZodString;toolset:ZodOptional<ZodNullable<ZodString>>;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;status:ZodDefault<ZodEnum<{queued:"queued";running:"running";completed:"completed";failed:"failed";cancelled:"cancelled"; }>>;enqueued_at:ZodDefault<ZodString>;started_at:ZodOptional<ZodNullable<ZodString>>;finished_at:ZodOptional<ZodNullable<ZodString>>;ack_value:ZodOptional<ZodNullable<ZodUnknown>>;result:ZodOptional<ZodNullable<ZodObject<{ok:ZodBoolean;value:ZodOptional<ZodNullable<ZodUnknown>>;error:ZodOptional<ZodNullable<ZodString>>;metadata:ZodDefault<ZodRecord<ZodString,ZodUnknown>>;cause:ZodOptional<ZodNullable<ZodObject<{kind:ZodDefault<...>;name:ZodOptional<...>;message:ZodOptional<...>;stack:ZodOptional<...>;code:ZodOptional<...>;metadata:ZodOptional<...>; },$strip>>>; },$strip>>>;retries:ZodDefault<ZodNumber>;error:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/background.ts:82
JsonValueSchema
constJsonValueSchema:z.ZodType<JsonValue>
Defined in: src/schemas/common.ts:3
JsonDictSchema
constJsonDictSchema:ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>
Defined in: src/schemas/common.ts:24
UnknownRecordSchema
constUnknownRecordSchema:ZodRecord<ZodString,ZodUnknown>
Defined in: src/schemas/common.ts:26
CellSchema
constCellSchema:ZodObject<{code:ZodString;stdout:ZodDefault<ZodString>;stderr:ZodDefault<ZodString>;truncated:ZodDefault<ZodBoolean>;elapsed_ms:ZodDefault<ZodNumber>; },$strip>
Defined in: src/schemas/execution.ts:3
ScratchpadVariableSchema
constScratchpadVariableSchema:ZodObject<{name:ZodString;type_name:ZodString;size_bytes:ZodDefault<ZodNumber>;summary:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/execution.ts:12
ScratchpadStateSchema
constScratchpadStateSchema:ZodObject<{variables:ZodDefault<ZodRecord<ZodString,ZodObject<{name:ZodString;type_name:ZodString;size_bytes:ZodDefault<ZodNumber>;summary:ZodOptional<ZodNullable<ZodString>>; },$strip>>>;cells:ZodDefault<ZodArray<ZodObject<{code:ZodString;stdout:ZodDefault<ZodString>;stderr:ZodDefault<ZodString>;truncated:ZodDefault<ZodBoolean>;elapsed_ms:ZodDefault<ZodNumber>; },$strip>>>; },$strip>
Defined in: src/schemas/execution.ts:20
SandboxRunResultSchema
constSandboxRunResultSchema:ZodObject<{cell:ZodObject<{code:ZodString;stdout:ZodDefault<ZodString>;stderr:ZodDefault<ZodString>;truncated:ZodDefault<ZodBoolean>;elapsed_ms:ZodDefault<ZodNumber>; },$strip>;variables:ZodDefault<ZodRecord<ZodString,ZodObject<{name:ZodString;type_name:ZodString;size_bytes:ZodDefault<ZodNumber>;summary:ZodOptional<ZodNullable<ZodString>>; },$strip>>>; },$strip>
Defined in: src/schemas/execution.ts:26
CacheControlEphemeralSchema
constCacheControlEphemeralSchema:ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip>
Defined in: src/schemas/inference.ts:21
Anthropic cache_control: { "type": "ephemeral" } annotation. The only
value the SDK currently constructs. Modelled as an object (instead of a
bare literal string) so future provider-specific extensions can live
alongside type without a breaking schema change. Adapters that don't
support prompt caching strip this annotation silently and emit a
one-time per-instance warning.
CacheControlSchema
constCacheControlSchema:ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip> =CacheControlEphemeralSchema
Defined in: src/schemas/inference.ts:26
ImageBase64SourceSchema
constImageBase64SourceSchema:ZodObject<{kind:ZodDefault<ZodLiteral<"base64">>;media_type:ZodString;data:ZodString; },$strip>
Defined in: src/schemas/inference.ts:35
Inline-bytes image source. Use for screenshots / generated previews that
aren't yet available at a stable URL. media_type follows the standard
MIME shape (image/png, image/jpeg, image/webp, image/gif);
Anthropic currently rejects other types, OpenAI accepts a wider set.
ImageUrlSourceSchema
constImageUrlSourceSchema:ZodObject<{kind:ZodDefault<ZodLiteral<"url">>;url:ZodString; },$strip>
Defined in: src/schemas/inference.ts:43
URL image source. The provider fetches the bytes server-side.
ImageSourceSchema
constImageSourceSchema:ZodDiscriminatedUnion<[ZodObject<{kind:ZodDefault<ZodLiteral<"base64">>;media_type:ZodString;data:ZodString; },$strip>,ZodObject<{kind:ZodDefault<ZodLiteral<"url">>;url:ZodString; },$strip>],"kind">
Defined in: src/schemas/inference.ts:49
FileSourceSchema
constFileSourceSchema:ZodDiscriminatedUnion<[ZodObject<{kind:ZodDefault<ZodLiteral<"base64">>;media_type:ZodString;data:ZodString; },$strip>,ZodObject<{kind:ZodDefault<ZodLiteral<"url">>;url:ZodString; },$strip>],"kind"> =ImageSourceSchema
Defined in: src/schemas/inference.ts:61
FileSource shares the same shape as ImageSource (a discriminated
union of base64 inline bytes and URL references). Re-exported under a
separate alias so consumers can express the schema-level intent
clearly even though the runtime shape is identical.
TextPartSchema
constTextPartSchema:ZodObject<{type:ZodDefault<ZodLiteral<"text">>;text:ZodString;cache_control:ZodOptional<ZodNullable<ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip>>>; },$strip>
Defined in: src/schemas/inference.ts:65
Plain-text content block. The default and most common part kind.
ImagePartSchema
constImagePartSchema:ZodObject<{type:ZodDefault<ZodLiteral<"image">>;source:ZodDiscriminatedUnion<[ZodObject<{kind:ZodDefault<ZodLiteral<"base64">>;media_type:ZodString;data:ZodString; },$strip>,ZodObject<{kind:ZodDefault<ZodLiteral<"url">>;url:ZodString; },$strip>],"kind">;cache_control:ZodOptional<ZodNullable<ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip>>>; },$strip>
Defined in: src/schemas/inference.ts:76
Image content block. The Anthropic adapter emits this as a typed
image block; OpenAI-compat adapters emit an image_url block.
FilePartSchema
constFilePartSchema:ZodObject<{type:ZodDefault<ZodLiteral<"file">>;source:ZodDiscriminatedUnion<[ZodObject<{kind:ZodDefault<ZodLiteral<"base64">>;media_type:ZodString;data:ZodString; },$strip>,ZodObject<{kind:ZodDefault<ZodLiteral<"url">>;url:ZodString; },$strip>],"kind">;filename:ZodOptional<ZodNullable<ZodString>>;cache_control:ZodOptional<ZodNullable<ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip>>>; },$strip>
Defined in: src/schemas/inference.ts:89
File content block. Anthropic emits a document block (currently
PDFs); OpenAI Chat Completions has no native file-block, so the
OpenAI-compat adapter falls back to a text-only stub describing the
attachment.
ContentPartSchema
constContentPartSchema:ZodDiscriminatedUnion<[ZodObject<{type:ZodDefault<ZodLiteral<"text">>;text:ZodString;cache_control:ZodOptional<ZodNullable<ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip>>>; },$strip>,ZodObject<{type:ZodDefault<ZodLiteral<"image">>;source:ZodDiscriminatedUnion<[ZodObject<{kind:ZodDefault<ZodLiteral<"base64">>;media_type:ZodString;data:ZodString; },$strip>,ZodObject<{kind:ZodDefault<ZodLiteral<"url">>;url:ZodString; },$strip>],"kind">;cache_control:ZodOptional<ZodNullable<ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip>>>; },$strip>,ZodObject<{type:ZodDefault<ZodLiteral<"file">>;source:ZodDiscriminatedUnion<[ZodObject<{kind:ZodDefault<ZodLiteral<"base64">>;media_type:ZodString;data:ZodString; },$strip>,ZodObject<{kind:ZodDefault<ZodLiteral<"url">>;url:ZodString; },$strip>],"kind">;filename:ZodOptional<ZodNullable<ZodString>>;cache_control:ZodOptional<ZodNullable<ZodObject<{type:ZodDefault<ZodLiteral<"ephemeral">>; },$strip>>>; },$strip>],"type">
Defined in: src/schemas/inference.ts:97
MessageContentSchema
constMessageContentSchema:ZodUnion<readonly [ZodString,ZodArray<ZodDiscriminatedUnion<[ZodObject<{type:ZodDefault<ZodLiteral<"text">>;text:ZodString;cache_control:ZodOptional<ZodNullable<ZodObject<{type: ...; },$strip>>>; },$strip>,ZodObject<{type:ZodDefault<ZodLiteral<"image">>;source:ZodDiscriminatedUnion<[ZodObject<{kind: ...;media_type: ...;data: ...; },$strip>,ZodObject<{kind: ...;url: ...; },$strip>],"kind">;cache_control:ZodOptional<ZodNullable<ZodObject<{type: ...; },$strip>>>; },$strip>,ZodObject<{type:ZodDefault<ZodLiteral<"file">>;source:ZodDiscriminatedUnion<[ZodObject<{kind: ...;media_type: ...;data: ...; },$strip>,ZodObject<{kind: ...;url: ...; },$strip>],"kind">;filename:ZodOptional<ZodNullable<ZodString>>;cache_control:ZodOptional<ZodNullable<ZodObject<{type: ...; },$strip>>>; },$strip>],"type">>]>
Defined in: src/schemas/inference.ts:111
A Message's content. The string form is preserved verbatim for
back-compat; existing producers and consumers that only ever read
Message.content as a string keep working when the content is a
string. Consumers that may receive the array form should call
messageToText or pattern-match on each part's type.
ToolDefSchema
constToolDefSchema:ZodObject<{name:ZodString;description:ZodDefault<ZodString>;input_schema:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>; },$strip>
Defined in: src/schemas/inference.ts:142
ToolCallSchema
constToolCallSchema:ZodObject<{id:ZodString;name:ZodString;arguments:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;arguments_error:ZodOptional<ZodNullable<ZodString>>;arguments_raw:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/inference.ts:149
MessageSchema
constMessageSchema:ZodObject<{role:ZodEnum<{system:"system";user:"user";assistant:"assistant";tool:"tool"; }>;content:ZodDefault<ZodUnion<readonly [ZodString,ZodArray<ZodDiscriminatedUnion<[ZodObject<{type:ZodDefault<...>;text:ZodString;cache_control:ZodOptional<...>; },$strip>,ZodObject<{type:ZodDefault<...>;source:ZodDiscriminatedUnion<..., ...>;cache_control:ZodOptional<...>; },$strip>,ZodObject<{type:ZodDefault<...>;source:ZodDiscriminatedUnion<..., ...>;filename:ZodOptional<...>;cache_control:ZodOptional<...>; },$strip>],"type">>]>>;name:ZodOptional<ZodNullable<ZodString>>;tool_calls:ZodOptional<ZodNullable<ZodArray<ZodObject<{id:ZodString;name:ZodString;arguments:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;arguments_error:ZodOptional<ZodNullable<ZodString>>;arguments_raw:ZodOptional<ZodNullable<ZodString>>; },$strip>>>>;tool_call_id:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/inference.ts:166
TokenUsageSchema
constTokenUsageSchema:ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>
Defined in: src/schemas/inference.ts:185
NamedToolChoiceSchema
constNamedToolChoiceSchema:ZodObject<{kind:ZodDefault<ZodLiteral<"named">>;name:ZodString; },$strip>
Defined in: src/schemas/inference.ts:221
ToolChoiceSchema
constToolChoiceSchema:ZodUnion<readonly [ZodEnum<{auto:"auto";required:"required";none:"none"; }>,ZodObject<{kind:ZodDefault<ZodLiteral<"named">>;name:ZodString; },$strip>]>
Defined in: src/schemas/inference.ts:227
FinishReasonSchema
constFinishReasonSchema:ZodEnum<{length:"length";error:"error";stop:"stop"; }>
Defined in: src/schemas/inference.ts:233
ReasoningEffortSchema
constReasoningEffortSchema:ZodEnum<{minimal:"minimal";low:"low";medium:"medium";high:"high"; }>
Defined in: src/schemas/inference.ts:244
Effort levels recognized across reasoning-capable model families.
"minimal" is OpenAI-only (gpt-5 family); the other three are common
to OpenAI's reasoning_effort knob, OpenAI Responses' reasoning.effort,
and our normalized mapping for Anthropic's thinking.budget_tokens
(see effortToAnthropicBudgetTokens).
ReasoningConfigSchema
constReasoningConfigSchema:ZodObject<{effort:ZodOptional<ZodNullable<ZodEnum<{minimal:"minimal";low:"low";medium:"medium";high:"high"; }>>>;max_tokens:ZodOptional<ZodNullable<ZodNumber>>;summary:ZodOptional<ZodNullable<ZodEnum<{auto:"auto";concise:"concise";detailed:"detailed"; }>>>; },$strip>
Defined in: src/schemas/inference.ts:272
Provider-agnostic reasoning configuration.
Adapters translate this shape into provider-native knobs:
- OpenAI-compatible chat completions: serializes
effortas the top-levelreasoning_effortfield (gpt-5 / o-series). - OpenAI Responses-style payloads (when an adapter elects to use
them): would map onto
reasoning.{effort, summary}. - Anthropic Messages: enables extended thinking via
thinking: { type: "enabled", budget_tokens }.max_tokens(when set) is used verbatim asbudget_tokens; otherwiseeffortis mapped onto a reasonable default budget. Adapters bump the request'smax_tokensto satisfy Anthropic'sbudget_tokens < max_tokensconstraint when needed. - Adapters that don't expose any reasoning knob (e.g. older OpenAI
models that reject
reasoning_effort) ignore this field silently; the schema is additive and never required.
Set this on InferenceRequest.reasoning for per-call control,
or on Agent.reasoning to apply a default to every LM call the
runner makes for that agent. Per-call values override the spec
default; a non-null InferenceRequest.reasoning completely replaces
the spec-level config (it is not merged field-by-field).
InferenceRequestSchema
constInferenceRequestSchema:ZodObject<{messages:ZodArray<ZodObject<{role:ZodEnum<{system:"system";user:"user";assistant:"assistant";tool:"tool"; }>;content:ZodDefault<ZodUnion<readonly [ZodString,ZodArray<ZodDiscriminatedUnion<[..., ..., ...],"type">>]>>;name:ZodOptional<ZodNullable<ZodString>>;tool_calls:ZodOptional<ZodNullable<ZodArray<ZodObject<{id:ZodString;name:ZodString;arguments:ZodDefault<...>;arguments_error:ZodOptional<...>;arguments_raw:ZodOptional<...>; },$strip>>>>;tool_call_id:ZodOptional<ZodNullable<ZodString>>; },$strip>>;response_format:ZodDefault<ZodEnum<{text:"text";json:"json"; }>>;max_tokens:ZodOptional<ZodNullable<ZodNumber>>;temperature:ZodOptional<ZodNullable<ZodNumber>>;top_p:ZodOptional<ZodNullable<ZodNumber>>;top_k:ZodOptional<ZodNullable<ZodNumber>>;frequency_penalty:ZodOptional<ZodNullable<ZodNumber>>;presence_penalty:ZodOptional<ZodNullable<ZodNumber>>;seed:ZodOptional<ZodNullable<ZodNumber>>;logit_bias:ZodOptional<ZodNullable<ZodRecord<ZodString,ZodNumber>>>;stop:ZodDefault<ZodArray<ZodString>>;tools:ZodDefault<ZodArray<ZodObject<{name:ZodString;description:ZodDefault<ZodString>;input_schema:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>; },$strip>>>;tool_choice:ZodDefault<ZodUnion<readonly [ZodEnum<{auto:"auto";required:"required";none:"none"; }>,ZodObject<{kind:ZodDefault<ZodLiteral<"named">>;name:ZodString; },$strip>]>>;parallel_tool_calls:ZodOptional<ZodNullable<ZodBoolean>>;user:ZodOptional<ZodNullable<ZodString>>;reasoning:ZodOptional<ZodNullable<ZodObject<{effort:ZodOptional<ZodNullable<ZodEnum<{minimal:"minimal";low:"low";medium:"medium";high:"high"; }>>>;max_tokens:ZodOptional<ZodNullable<ZodNumber>>;summary:ZodOptional<ZodNullable<ZodEnum<{auto:"auto";concise:"concise";detailed:"detailed"; }>>>; },$strip>>>; },$strip>
Defined in: src/schemas/inference.ts:291
InferenceResponseSchema
constInferenceResponseSchema:ZodObject<{content:ZodDefault<ZodUnion<readonly [ZodString,ZodArray<ZodDiscriminatedUnion<[ZodObject<{type:ZodDefault<...>;text:ZodString;cache_control:ZodOptional<...>; },$strip>,ZodObject<{type:ZodDefault<...>;source:ZodDiscriminatedUnion<..., ...>;cache_control:ZodOptional<...>; },$strip>,ZodObject<{type:ZodDefault<...>;source:ZodDiscriminatedUnion<..., ...>;filename:ZodOptional<...>;cache_control:ZodOptional<...>; },$strip>],"type">>]>>;usage:ZodDefault<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>;finish_reason:ZodDefault<ZodEnum<{length:"length";error:"error";stop:"stop"; }>>;tool_calls:ZodDefault<ZodArray<ZodObject<{id:ZodString;name:ZodString;arguments:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;arguments_error:ZodOptional<ZodNullable<ZodString>>;arguments_raw:ZodOptional<ZodNullable<ZodString>>; },$strip>>>;reasoning:ZodOptional<ZodNullable<ZodString>>; },$loose>
Defined in: src/schemas/inference.ts:391
StreamChunkKindSchema
constStreamChunkKindSchema:ZodEnum<{text:"text";reasoning:"reasoning";json_partial:"json_partial";object_partial:"object_partial";tool_call_partial:"tool_call_partial";control:"control"; }>
Defined in: src/schemas/inference.ts:417
ToolCallPartialSchema
constToolCallPartialSchema:ZodObject<{index:ZodDefault<ZodNumber>;id:ZodOptional<ZodNullable<ZodString>>;name:ZodOptional<ZodNullable<ZodString>>;arguments_partial:ZodDefault<ZodString>; },$strip>
Defined in: src/schemas/inference.ts:427
StreamChunkSchema
constStreamChunkSchema:ZodObject<{kind:ZodDefault<ZodEnum<{text:"text";reasoning:"reasoning";json_partial:"json_partial";object_partial:"object_partial";tool_call_partial:"tool_call_partial";control:"control"; }>>;delta:ZodDefault<ZodString>;partial_object:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;tool_call_delta:ZodOptional<ZodNullable<ZodObject<{index:ZodDefault<ZodNumber>;id:ZodOptional<ZodNullable<ZodString>>;name:ZodOptional<ZodNullable<ZodString>>;arguments_partial:ZodDefault<ZodString>; },$strip>>>;usage_delta:ZodOptional<ZodNullable<ZodObject<{prompt:ZodDefault<ZodNumber>;completion:ZodDefault<ZodNumber>;cost_usd:ZodOptional<ZodNullable<ZodNumber>>;cache_creation_input_tokens:ZodOptional<ZodNullable<ZodNumber>>;cache_read_input_tokens:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>>;finish_reason:ZodOptional<ZodNullable<ZodEnum<{length:"length";error:"error";stop:"stop"; }>>>;raw_finish_reason:ZodOptional<ZodNullable<ZodString>>;content_part_kind:ZodOptional<ZodNullable<ZodEnum<{file:"file";text:"text";image:"image"; }>>>; },$strip>
Defined in: src/schemas/inference.ts:435
ModelPricingSchema
constModelPricingSchema:ZodObject<{input:ZodOptional<ZodNullable<ZodNumber>>;output:ZodOptional<ZodNullable<ZodNumber>>;cache_read:ZodOptional<ZodNullable<ZodNumber>>;cache_write:ZodOptional<ZodNullable<ZodNumber>>;request:ZodOptional<ZodNullable<ZodNumber>>;image:ZodOptional<ZodNullable<ZodNumber>>; },$strip>
Defined in: src/schemas/inference.ts:521
Per-token price metadata for a model, in USD. Every field is optional:
most catalogs populate only input / output, the sparse APIs (OpenAI,
Anthropic) populate none, and request / image are OpenRouter-
specific. input / output / cache_read / cache_write are the USD
cost of a single token; request is a fixed per-request cost and
image is the per-image-input cost. The per-token unit matches the
provider wire values and lines up with TokenUsage.cost_usd.
Providers report these as decimal strings (to dodge float drift);
adapters parse them to number -- callers needing exact decimals read
ModelSpec.raw.
ModelSpecSchema
constModelSpecSchema:ZodObject<{id:ZodString;provider:ZodOptional<ZodNullable<ZodString>>;display_name:ZodOptional<ZodNullable<ZodString>>;description:ZodOptional<ZodNullable<ZodString>>;context_window:ZodOptional<ZodNullable<ZodNumber>>;max_output_tokens:ZodOptional<ZodNullable<ZodNumber>>;pricing:ZodOptional<ZodNullable<ZodObject<{input:ZodOptional<ZodNullable<ZodNumber>>;output:ZodOptional<ZodNullable<ZodNumber>>;cache_read:ZodOptional<ZodNullable<ZodNumber>>;cache_write:ZodOptional<ZodNullable<ZodNumber>>;request:ZodOptional<ZodNullable<ZodNumber>>;image:ZodOptional<ZodNullable<ZodNumber>>; },$strip>>>;input_modalities:ZodDefault<ZodArray<ZodString>>;output_modalities:ZodDefault<ZodArray<ZodString>>;supported_parameters:ZodDefault<ZodArray<ZodString>>;created:ZodOptional<ZodNullable<ZodNumber>>;owned_by:ZodOptional<ZodNullable<ZodString>>;raw:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>; },$strip>
Defined in: src/schemas/inference.ts:540
Provider-agnostic description of a single available model, returned by
SupportsModelCatalog.listModels. Only id is guaranteed; every
other field is best-effort and reflects exactly what the provider's
catalog endpoint exposes. The verbatim provider entry is preserved on
raw so callers can read provider-specific fields the normalization
didn't surface. id is the slug used to construct the model (e.g.
"gpt-4o-mini" or "anthropic/claude-3.5-sonnet").
MemoryRecordSchema
constMemoryRecordSchema:ZodObject<{id:ZodString;namespace:ZodString;content:ZodUnknown;metadata:ZodDefault<ZodRecord<ZodString,ZodUnknown>>;created_at:ZodDefault<ZodString>; },$strip>
Defined in: src/schemas/memory.ts:3
MemoryQuerySchema
constMemoryQuerySchema:ZodObject<{text:ZodOptional<ZodNullable<ZodString>>;namespace:ZodOptional<ZodNullable<ZodString>>;filters:ZodDefault<ZodRecord<ZodString,ZodUnknown>>;k:ZodDefault<ZodNumber>; },$strip>
Defined in: src/schemas/memory.ts:12
MemoryScopeSchema
constMemoryScopeSchema:ZodObject<{read:ZodDefault<ZodArray<ZodString>>;write:ZodDefault<ZodArray<ZodString>>; },$strip>
Defined in: src/schemas/memory.ts:20
ObservationStatusSchema
constObservationStatusSchema:ZodEnum<{buffered:"buffered";active:"active"; }>
Defined in: src/schemas/memory.ts:37
ObservationRecordSchema
constObservationRecordSchema:ZodObject<{id:ZodString;text:ZodString;from_index:ZodNumber;to_index:ZodNumber;current_task:ZodOptional<ZodNullable<ZodString>>;suggested_response:ZodOptional<ZodNullable<ZodString>>;provider_model:ZodDefault<ZodString>;status:ZodDefault<ZodEnum<{buffered:"buffered";active:"active"; }>>;chars:ZodDefault<ZodNumber>;thread_id:ZodOptional<ZodNullable<ZodString>>;resource_id:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/memory.ts:40
ReflectionRecordSchema
constReflectionRecordSchema:ZodObject<{id:ZodString;text:ZodString;from_index:ZodNumber;to_index:ZodNumber;current_task:ZodOptional<ZodNullable<ZodString>>;suggested_response:ZodOptional<ZodNullable<ZodString>>;provider_model:ZodDefault<ZodString>;status:ZodDefault<ZodEnum<{buffered:"buffered";active:"active"; }>>;chars:ZodDefault<ZodNumber>;thread_id:ZodOptional<ZodNullable<ZodString>>;resource_id:ZodOptional<ZodNullable<ZodString>>; },$strip> =ObservationRecordSchema
Defined in: src/schemas/memory.ts:62
ObservationStateSchema
constObservationStateSchema:ZodObject<{last_observed_index:ZodDefault<ZodNumber>;in_flight_index:ZodDefault<ZodNumber>;current_task:ZodOptional<ZodNullable<ZodString>>;suggested_response:ZodOptional<ZodNullable<ZodString>>;last_provider_model:ZodDefault<ZodString>;last_activity_ts:ZodDefault<ZodString>; },$strip>
Defined in: src/schemas/memory.ts:65
ObservationalMemoryConfigSchema
constObservationalMemoryConfigSchema:ZodObject<{model:ZodUnknown;reflection_model:ZodOptional<ZodNullable<ZodUnknown>>;message_chars:ZodDefault<ZodNumber>;observation_chars:ZodDefault<ZodNumber>;buffer_fraction:ZodDefault<ZodNumber>;activation_fraction:ZodDefault<ZodNumber>;block_after:ZodDefault<ZodNumber>;activate_after_idle:ZodOptional<ZodNullable<ZodNumber>>;activate_on_provider_change:ZodDefault<ZodBoolean>;enable_reflection:ZodDefault<ZodBoolean>;reflection_buffer_activation:ZodDefault<ZodNumber>;reflection_block_after:ZodDefault<ZodNumber>;scope:ZodDefault<ZodEnum<{thread:"thread";resource:"resource"; }>>;chars_per_token:ZodDefault<ZodNumber>;keep_recent_messages:ZodDefault<ZodNumber>;estimator:ZodOptional<ZodNullable<ZodUnknown>>; },$strip>
Defined in: src/schemas/memory.ts:87
WorkingMemoryConfigSchema
constWorkingMemoryConfigSchema:ZodObject<{model:ZodUnknown;template:ZodDefault<ZodString>;scope:ZodDefault<ZodEnum<{thread:"thread";resource:"resource"; }>>;update_after_every_turn:ZodDefault<ZodBoolean>;max_chars:ZodDefault<ZodNumber>;enable_update_tool:ZodDefault<ZodBoolean>;note_section:ZodDefault<ZodString>; },$strip>
Defined in: src/schemas/memory.ts:151
Per-agent working-memory configuration.
Working memory is a single mutable markdown document the agent maintains across turns (the user's name, preferences, current goals, anything the agent should remember between sessions). Each chat turn:
- The runner loads the doc from
agent:<id>/threads/<tid>/working_memory(thread scope) oragent:<id>/resources/<rid>/working_memory(resource scope) and splices it into the prefix as a system-role message. - After
ConversationStore.saveTurnpersists the new turn, a small LM call rewrites the doc using the prior version plus the new turn's messages and the configuredtemplateas a structural guide.
The updater never blocks the foreground turn: failures are
caught and traced as working_memory_error; the next turn
retries. Set update_after_every_turn: false to skip the
updater entirely when you want a hand-managed doc.
Resource scope is recommended: the doc is the agent's memory of the user, so pooling it across every thread for that user matches the model the user mentally carries.
MemoryRelevanceFilterConfigSchema
constMemoryRelevanceFilterConfigSchema:ZodObject<{model:ZodUnknown;min_chars_to_filter:ZodDefault<ZodNumber>;filter_observations:ZodDefault<ZodBoolean>;filter_working_memory:ZodDefault<ZodBoolean>;keep_when_empty:ZodDefault<ZodBoolean>;instructions:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/memory.ts:238
Configuration for the query-conditioned memory relevance filter.
Observational and working memory both publish their full state into the prefix of every chat turn: the active observation log, every active reflection, and the entire working-memory doc all get spliced in. That is convenient when the agent works on one topic, but for assistants that hop across unrelated tasks (a personal aide, a multi-tenant support bot, a tool-heavy agent that switches domains every few turns) the full memory prefix becomes noisy and distracting -- the model sees a lot of context that has nothing to do with the user's latest query.
Wiring new Maniac({ memoryRelevanceFilter: { model: ... } })
inserts a small LM pass before the foreground turn that takes the
new user query plus the full memory prefix, identifies which
observation / reflection blocks and which working-memory sections
are actually relevant, and rewrites the prefix to keep only those
pieces. The raw conversation history tail is never filtered --
only the summarised memory tiers are.
The filter is intentionally exposed as a flag-style configuration
(config object on the app, not an agentAsTool wiring): callers do
not need to register a "memory filter" subagent, manage its
permissions, or thread it through the tool surface. Pass the config
once on Maniac and every chat turn picks it up automatically.
Failure modes are deliberately fail-open: an LM error, parse error, or timeout produces a one-shot trace event but the unfiltered prefix is forwarded to the agent unchanged. The filter is an optimisation, not a correctness layer.
MemoryAccessModeSchema
constMemoryAccessModeSchema:ZodEnum<{read:"read";write:"write";off:"off"; }>
Defined in: src/schemas/memory.ts:298
Per-chat memory access mode for one memory tier.
"off"-- skip both reading and writing this turn (truly ephemeral)."read"-- inject existing memory into the prefix, but record nothing from this turn (no observations, no working-memory rewrite,remembertool is hidden)."write"-- full behaviour: load + record. This is the default whenever the app has the corresponding tier configured. When the tier isn't configured, the mode collapses to"off"regardless of what the caller passed.
RuntimeMemoryAccessSchema
constRuntimeMemoryAccessSchema:ZodObject<{observational:ZodDefault<ZodEnum<{read:"read";write:"write";off:"off"; }>>;working:ZodDefault<ZodEnum<{read:"read";write:"write";off:"off"; }>>; },$strip>
Defined in: src/schemas/memory.ts:308
Per-chat opt-out / opt-in for observational and working memory.
Pass to Maniac.chat / Maniac.chatStream / Thread.send via the
memory option on ChatOptions. Defaults preserve existing behaviour
("write" for both tiers when the app has them configured).
GuardrailActionSchema
constGuardrailActionSchema:ZodEnum<{allow:"allow";require_approval:"require_approval";rewrite:"rewrite";block:"block"; }>
Defined in: src/schemas/middleware.ts:11
The four guardrail outcomes. require_approval (Tier 1 #3) routes
the call through the same HITL pause path used by the permission
policy.
GuardrailDecisionSchema
constGuardrailDecisionSchema:ZodDiscriminatedUnion<[ZodObject<{action:ZodLiteral<"allow">;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>,ZodObject<{action:ZodLiteral<"rewrite">;payload:ZodOptional<ZodNullable<ZodUnknown>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>,ZodObject<{action:ZodLiteral<"block">;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>,ZodObject<{action:ZodLiteral<"require_approval">;pending:ZodDefault<ZodArray<ZodObject<{id:ZodString;toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<..., ...>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>>>;rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>],"action">
Defined in: src/schemas/middleware.ts:54
LMCallContextSchema
constLMCallContextSchema:ZodObject<{principal:ZodString;scope:ZodEnum<{root:"root";subagent:"subagent"; }>;iteration:ZodNumber;toolset:ZodOptional<ZodNullable<ZodString>>;span_id:ZodString;parent_span_id:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/middleware.ts:97
ToolCallContextSchema
constToolCallContextSchema:ZodObject<{principal:ZodString;scope:ZodDefault<ZodEnum<{root:"root";subagent:"subagent"; }>>;toolset:ZodString;iteration:ZodNumber;subagent_span_id:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/middleware.ts:107
ArgConstraintOpSchema
constArgConstraintOpSchema:ZodEnum<{in:"in";matches:"matches";equals:"equals";not_in:"not_in";not_matches:"not_matches"; }>
Defined in: src/schemas/permissions.ts:11
Operators supported by ArgConstraint.
not_in and not_matches (Tier 3 #12) invert in and matches
respectively. They still fail closed when the path is missing — a
missing arg cannot satisfy any op.
ArgConstraintQuantifierSchema
constArgConstraintQuantifierSchema:ZodEnum<{any:"any";all:"all"; }>
Defined in: src/schemas/permissions.ts:27
Quantifier for paths that resolve to multiple values (Tier 1 #1).
"any" passes when at least one resolved leaf matches; "all"
requires every resolved leaf to match. Scalar paths behave
identically under both quantifiers.
ArgConstraintSchema
constArgConstraintSchema:ZodObject<{path:ZodString;op:ZodEnum<{in:"in";matches:"matches";equals:"equals";not_in:"not_in";not_matches:"not_matches"; }>;pattern:ZodOptional<ZodNullable<ZodString>>;values:ZodOptional<ZodNullable<ZodArray<ZodUnknown>>>;quantifier:ZodOptional<ZodNullable<ZodEnum<{any:"any";all:"all"; }>>>; },$strip>
Defined in: src/schemas/permissions.ts:30
PermissionScopeSchema
constPermissionScopeSchema:ZodObject<{toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodOptional<ZodNullable<ZodString>>;arg_constraints:ZodDefault<ZodArray<ZodObject<{path:ZodString;op:ZodEnum<{in:"in";matches:"matches";equals:"equals";not_in:"not_in";not_matches:"not_matches"; }>;pattern:ZodOptional<ZodNullable<ZodString>>;values:ZodOptional<ZodNullable<ZodArray<ZodUnknown>>>;quantifier:ZodOptional<ZodNullable<ZodEnum<{any:"any";all:"all"; }>>>; },$strip>>>; },$strip>
Defined in: src/schemas/permissions.ts:44
PermissionEffectSchema
constPermissionEffectSchema:ZodEnum<{deny:"deny";allow:"allow";require_approval:"require_approval";allow_unless_matches:"allow_unless_matches";deny_unless_matches:"deny_unless_matches"; }>
Defined in: src/schemas/permissions.ts:58
Permission rule effects.
The two ..._unless_matches effects (Tier 3 #12) invert the match
semantics so a single rule can mix allow- and deny-lists without
flipping the policy-level default decision.
PermissionSchema
constPermissionSchema:ZodObject<{id:ZodString;principal:ZodString;scope:ZodObject<{toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodOptional<ZodNullable<ZodString>>;arg_constraints:ZodDefault<ZodArray<ZodObject<{path:ZodString;op:ZodEnum<{in:"in";matches:"matches";equals:"equals";not_in:"not_in";not_matches:"not_matches"; }>;pattern:ZodOptional<ZodNullable<ZodString>>;values:ZodOptional<ZodNullable<ZodArray<...>>>;quantifier:ZodOptional<ZodNullable<ZodEnum<...>>>; },$strip>>>; },$strip>;effect:ZodEnum<{deny:"deny";allow:"allow";require_approval:"require_approval";allow_unless_matches:"allow_unless_matches";deny_unless_matches:"deny_unless_matches"; }>; },$strip>
Defined in: src/schemas/permissions.ts:67
PendingActionSchema
constPendingActionSchema:ZodObject<{principal:ZodString;call:ZodObject<{toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;principal:ZodString; },$strip>; },$strip>
Defined in: src/schemas/permissions.ts:75
DecisionSchema
constDecisionSchema:ZodObject<{allowed:ZodBoolean;requires_approval:ZodDefault<ZodBoolean>;matched_rule_id:ZodOptional<ZodNullable<ZodString>>;reason:ZodOptional<ZodNullable<ZodString>>; },$strip>
Defined in: src/schemas/permissions.ts:81
ReplConfigSchema
constReplConfigSchema:ZodObject<{sandbox:ZodOptional<ZodNullable<ZodUnknown>>;namespace_extras:ZodDefault<ZodRecord<ZodString,ZodUnknown>>;max_stdout_chars:ZodDefault<ZodNumber>;max_stderr_chars:ZodDefault<ZodNumber>;inject_parallel_helper:ZodDefault<ZodBoolean>; },$strip>
Defined in: src/schemas/repl.ts:4
ToolSchemaSchema
constToolSchemaSchema:ZodObject<{name:ZodString;description:ZodString;input_schema:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;output_schema:ZodOptional<ZodNullable<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>>;tags:ZodDefault<ZodArray<ZodString>>; },$strip>
Defined in: src/schemas/tools.ts:5
RuntimeToolCallSchema
constRuntimeToolCallSchema:ZodObject<{toolset:ZodOptional<ZodNullable<ZodString>>;tool:ZodString;args:ZodDefault<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>;principal:ZodString; },$strip>
Defined in: src/schemas/tools.ts:14
ToolResultCauseSchema
constToolResultCauseSchema:ZodObject<{kind:ZodDefault<ZodEnum<{validation:"validation";runtime:"runtime"; }>>;name:ZodOptional<ZodString>;message:ZodOptional<ZodString>;stack:ZodOptional<ZodNullable<ZodString>>;code:ZodOptional<ZodNullable<ZodString>>;metadata:ZodOptional<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>; },$strip>
Defined in: src/schemas/tools.ts:39
Structured cause attached to ToolResult when a non-ok result was
triggered by an exception. kind distinguishes:
"validation"— input failedparse(the args did not match the declared input schema). The handler was never invoked."runtime"— the handler threw at runtime.
All fields except kind are optional, so adapters can choose how much
detail to surface. stack is verbatim from Error.stack and may be
truncated by callers who care about size.
Use the metadata sub-object to attach producer-specific extras
(e.g. wire error codes, retry counters, original error.cause)
without forcing every consumer to widen the typed ToolResultCause
shape. Mirrors the pattern Python uses for metadata on
ToolResult.
ToolResultSchema
constToolResultSchema:ZodObject<{ok:ZodBoolean;value:ZodOptional<ZodNullable<ZodUnknown>>;error:ZodOptional<ZodNullable<ZodString>>;metadata:ZodDefault<ZodRecord<ZodString,ZodUnknown>>;cause:ZodOptional<ZodNullable<ZodObject<{kind:ZodDefault<ZodEnum<{validation:"validation";runtime:"runtime"; }>>;name:ZodOptional<ZodString>;message:ZodOptional<ZodString>;stack:ZodOptional<ZodNullable<ZodString>>;code:ZodOptional<ZodNullable<ZodString>>;metadata:ZodOptional<ZodType<JsonDict,unknown,$ZodTypeInternals<JsonDict,unknown>>>; },$strip>>>; },$strip>
Defined in: src/schemas/tools.ts:49
acpReadTextFile
constacpReadTextFile:Tool
Defined in: src/tools/builtin/acpFs.ts:67
acpWriteTextFile
constacpWriteTextFile:Tool
Defined in: src/tools/builtin/acpFs.ts:148
acpRunCommand
constacpRunCommand:Tool
Defined in: src/tools/builtin/acpTerminal.ts:66
bgList
constbgList:Tool
Defined in: src/tools/builtin/backgroundControl.ts:79
bg_list() — surface every in-flight task for this (agent, thread).
bgCheck
constbgCheck:Tool
Defined in: src/tools/builtin/backgroundControl.ts:116
bg_check(task_id, last_n_events?) — read recent activity and
current status for a task.
bgCancel
constbgCancel:Tool
Defined in: src/tools/builtin/backgroundControl.ts:204
bg_cancel(task_id) — request cooperative cancellation.
bgWait
constbgWait:Tool
Defined in: src/tools/builtin/backgroundControl.ts:290
bg_wait(task_ids, mode?, timeout_s?) — block until terminal.
Supports both single-task and multi-task fan-in with mode === "all" (default) or mode === "any". Single-task waits use the
same field with a one-element array (task_ids: ["t1"]).
The schema deliberately has only one task-targeting field so
the model literally cannot fill two competing slots. This was
deferred in 0.2.6 because the SDK shipped with a task_id /
task_ids pair and a description-only mutual-exclusion clause;
real-world strict-mode tool-calling traffic showed models
routinely emitted task_id: "" alongside a populated task_ids
(because strict mode fills any optional type: "string" property
with ""), or oscillated between the two fields, defeating the
multi-task fan-in. Collapsing to a single field eliminates the
ambiguity at the source.
The runtime validator continues to accept the legacy task_id
shape as a silent fallback so saved tool-call traces, older LM
outputs, and callers that haven't picked up the new schema still
resolve cleanly. When both task_ids and task_id are present,
task_ids wins and task_id is dropped (this also makes the
strict-mode hedge — task_id: "" alongside the array — a no-op
regardless of whether task_id carries an empty string or a real
id the model also surfaced).
The single-task return payload is preserved ({ status, record, result }, no results / winner keys) when task_ids carries
exactly one id, so the LM-facing return shape stays identical to
the legacy single-task call.
askAboutUser
constaskAboutUser:Tool
Defined in: src/tools/builtin/honchoTools.ts:35
Ask Honcho a natural-language question about the current user.
Auto-injected by Maniac.chat / Maniac.chatStream when (a) the
active spec carries a HonchoMemory and (b) the chat-turn
context has a resourceId bound. Outside those conditions the
tool returns a structured failure ToolResult rather than
throwing -- matching the rest of the SDK's tool failure shape.
setPlanTool
constsetPlanTool:Tool
Defined in: src/tools/builtin/plan.ts:47
remember
constremember:Tool
Defined in: src/tools/builtin/workingMemory.ts:97
Functions
sealUnansweredToolCalls()
sealUnansweredToolCalls(
turn):object[]
Defined in: src/agents/app.ts:1370
Append synthetic tool observations for any unanswered
tool_call.id ids on a trailing assistant turn.
Native tool-calling providers (OpenAI, Anthropic, Bedrock, ...)
reject a request whose transcript has an assistant message
with tool_calls followed by anything other than a tool reply
for every emitted tool_call.id. When a turn aborts mid-fan-out
(a sibling tool raised, the cancel signal fired, the LM
provider timed out between the assistant's tool emission and
the inflight tool's resolution, etc.), the in-flight
messages list ends with one or more unanswered ids --
persisting it as-is would corrupt the next turn's request.
Mirrors Python _seal_unanswered_tool_calls in agents/app.py.
Returns a fresh array; the input is not mutated.
Parameters
turn
object[]
Returns
safeTailStart()
safeTailStart(
messages,tailStart):number
Defined in: src/agents/compaction.ts:25
Walk tailStart backward so messages.slice(tailStart) doesn't open
with an orphan tool result.
OpenAI's chat-completions schema requires every role: "tool" message's
tool_call_id to reference an earlier assistant tool_calls[].id in
the same request. Compaction folds the middle of the transcript into
a summary user message, so if the tail begins with a tool message
whose paired assistant call is in the summarised middle, the wire
becomes invalid and the provider returns 400 ("No tool call found for
function call output with call_id ..."). Walk the boundary back over
leading tool messages so the tail always opens on a non-tool turn --
typically the assistant message that emitted the parallel tool calls
-- and every tool result keeps its paired call.
The walk stops at index 0 so callers can clamp afterwards (e.g. to skip past a preserved system+user head). Idempotent; safe to call on already-aligned indices.
Mirrors Python agents/compaction.safe_tail_start.
Parameters
messages
readonly object[]
tailStart
number
Returns
number
runBeforeStep()
runBeforeStep(
hooks,ctx,req):Promise<{request: {messages:object[];response_format:"text"|"json";max_tokens?:number|null;temperature?:number|null;top_p?:number|null;top_k?:number|null;frequency_penalty?:number|null;presence_penalty?:number|null;seed?:number|null;logit_bias?:Record<string,number> |null;stop:string[];tools:object[];tool_choice: {kind:"named";name:string; } |"auto"|"required"|"none";parallel_tool_calls?:boolean|null;user?:string|null;reasoning?: {effort?:"minimal"|"low"|"medium"|"high"|null;max_tokens?:number|null;summary?:"auto"|"concise"|"detailed"|null; } |null; };terminating:StepDecision|null; }>
Defined in: src/agents/hooks.ts:142
Run beforeStep across hooks and compose their patches.
Returns { request, terminating }. When any hook returns
stop: true, iteration short-circuits and terminating is the
decision (the runner uses its final / reason to build the
AgentResult). Otherwise terminating is null and request
carries the (possibly rewritten) request.
Composition rule: hooks run in registered order. Each hook sees the
messages list patched by every prior hook (via the rebuilt
ctx) and operates on the patched request.
A hook returning messages rebuilds the request with the new
messages; a hook returning request overrides the whole request
object. When both are set on a single decision, the explicit
request wins.
Parameters
hooks
readonly StepHook[]
ctx
req
messages
object[] = ...
response_format
"text" | "json" = ...
max_tokens?
number | null = ...
temperature?
number | null = ...
top_p?
number | null = ...
Nucleus-sampling cutoff. Forwarded verbatim as top_p by every
OpenAI-compatible adapter and as top_p by Anthropic. null/omitted
(the default) leaves the field off so the provider default applies.
Setting both temperature and top_p is allowed by the wire formats
but most providers recommend tuning only one.
top_k?
number | null = ...
Top-k sampling cutoff. Native on Anthropic (top_k) and most
OpenAI-compatible open-model gateways (OpenRouter, llama.cpp, mlx,
vLLM, ...). Not part of vanilla OpenAI Chat Completions — sending it
to api.openai.com is rejected server-side, mirroring the existing
reasoning_effort contract (forwarded verbatim; unsupported
endpoints surface the rejection). null/omitted leaves it off.
frequency_penalty?
number | null = ...
OpenAI frequency_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
presence_penalty?
number | null = ...
OpenAI presence_penalty (typically -2.0..2.0). Forwarded by
OpenAI-compatible adapters and LiteLLM; Anthropic has no equivalent
and silently ignores it. null/omitted leaves it off.
seed?
number | null = ...
Best-effort deterministic-sampling seed. Forwarded as seed by
OpenAI-compatible adapters and LiteLLM (providers treat it as a hint,
not a hard guarantee); Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
logit_bias?
Record<string, number> | null = ...
Per-token logit bias map (token-id string -> bias, typically
-100..100). Forwarded as logit_bias by OpenAI-compatible
adapters and LiteLLM; Anthropic has no equivalent and silently
ignores it. null/omitted leaves it off.
stop
string[] = ...
tools
object[] = ...
tool_choice
{ kind: "named"; name: string; } | "auto" | "required" | "none" = ...
parallel_tool_calls?
boolean | null = ...
Whether the provider may emit multiple tool calls in a single turn.
OpenAI-compatible adapters forward it as parallel_tool_calls (only
when tools is non-empty, the provider's own constraint). Anthropic
expresses the inverse via tool_choice.disable_parallel_tool_use: a
value of false is translated to disable_parallel_tool_use: true;
true/null leave Anthropic's default (parallel allowed) untouched.
null/omitted leaves it off for OpenAI-compatible providers.
user?
string | null = ...
Opaque stable end-user identifier for provider-side abuse
monitoring. OpenAI-compatible adapters forward it as user;
Anthropic maps it to metadata.user_id. null/omitted leaves it
off.
reasoning?
{ effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null = ...
Optional reasoning configuration. See ReasoningConfigSchema.
null/omitted means "use the provider default" -- exactly the
pre-Phase-4 behavior, so adapters can ignore this field unmodified
when callers don't set it.
Returns
Promise<{ request: { messages: object[]; response_format: "text" | "json"; max_tokens?: number | null; temperature?: number | null; top_p?: number | null; top_k?: number | null; frequency_penalty?: number | null; presence_penalty?: number | null; seed?: number | null; logit_bias?: Record<string, number> | null; stop: string[]; tools: object[]; tool_choice: { kind: "named"; name: string; } | "auto" | "required" | "none"; parallel_tool_calls?: boolean | null; user?: string | null; reasoning?: { effort?: "minimal" | "low" | "medium" | "high" | null; max_tokens?: number | null; summary?: "auto" | "concise" | "detailed" | null; } | null; }; terminating: StepDecision | null; }>
runShouldStop()
runShouldStop(
hooks,ctx,resp,cell):Promise<StepHook|null>
Defined in: src/agents/hooks.ts:179
Return the first hook whose shouldStop returns true, or null.
The runner uses the identity to attribute the trace event ("which hook stopped us"); when no hook stops, the loop continues normally.
Per-hook exceptions are swallowed (with a console.warn fallback
so misbehaving hooks surface somewhere): a misbehaving stop hook
should not abort an otherwise-completing iteration.
Parameters
hooks
readonly StepHook[]
ctx
resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
cell
JsonDict | null
Returns
Promise<StepHook | null>
runBeforeFinalize()
runBeforeFinalize(
hooks,ctx,resp):Promise<[StepHook,Continuation] |null>
Defined in: src/agents/hooks.ts:212
Return the first [hook, Continuation] pair, or null.
Iterates hooks in order; the first hook returning a non-null
Continuation wins and the runner appends its userMessage to the
transcript before iterating again.
Per-hook exceptions are swallowed (with console.warn) so a
misbehaving veto hook cannot strand the run on a final turn we
can't actually emit.
Parameters
hooks
readonly StepHook[]
ctx
resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
Returns
Promise<[StepHook, Continuation] | null>
runAfterStep()
runAfterStep(
hooks,ctx,resp,cell):Promise<void>
Defined in: src/agents/hooks.ts:240
Run every hook's afterStep, swallowing per-hook exceptions.
afterStep is observational. A misbehaving hook should not abort
the run; we log via console.warn and move on.
Parameters
hooks
readonly StepHook[]
ctx
resp
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
The model's response content. Mirrors MessageSchema.content's
union shape: a plain string for text-only responses (the
overwhelming majority today), or a ContentPart array when
the adapter streamed multimodal deltas (image / file blocks). The
runner forwards this onto the assistant message verbatim, so the
shape that flows into messages mirrors what came back from the
LM. Consumers that only care about the textual portion can call
messageToText.
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
finish_reason
"length" | "error" | "stop" = ...
tool_calls
object[] = ...
reasoning?
string | null = ...
cell
JsonDict | null
Returns
Promise<void>
hasAfterStep()
hasAfterStep(
hooks):boolean
Defined in: src/agents/hooks.ts:264
true if any hook overrides afterStep away from the no-op
default. Used by the runner to skip emitting a step phase: "after"
trace event when nothing would observe it.
Parameters
hooks
readonly StepHook[]
Returns
boolean
stepCountIs()
stepCountIs(
n):StopWhen
Defined in: src/agents/hooks.ts:295
Stop after the agent completes n iterations.
iteration is zero-based at the start of beforeStep; by the time
shouldStop runs for iteration i, the agent has produced output
for iterations 0..i. Returning true at iteration i means
"terminate now, don't run iteration i+1". So stepCountIs(2)
halts at the end of iteration index 1 (i.e. after exactly 2
iterations).
Parameters
n
number
Returns
tokensExceed()
tokensExceed(
n):StopWhen
Defined in: src/agents/hooks.ts:311
Stop once cumulative prompt + completion tokens exceed n.
Complementary to AgentBudget.max_tokens: budgets are checked at
the top of each iteration, this fires after the LM responds, so
a single oversize response can trigger termination immediately
instead of waiting for the next iteration boundary.
Parameters
n
number
Returns
wallSecondsExceed()
wallSecondsExceed(
s):StopWhen
Defined in: src/agents/hooks.ts:326
Stop once s wall-clock seconds have elapsed since the run
started. Complementary to AgentBudget.max_wall_seconds, with the
same after-LM-response semantics as tokensExceed.
Parameters
s
number
Returns
responseMatches()
responseMatches(
pattern):StopWhen
Defined in: src/agents/hooks.ts:338
Stop the first time the LM's response content matches pattern.
pattern is a RegExp or a string compiled with the default
flags; substring matches via RegExp.test semantics.
Parameters
pattern
string | RegExp
Returns
decompositionHasMemory()
decompositionHasMemory(
decomp):boolean
Defined in: src/agents/memoryFilter.ts:150
Whether the decomposition carries any filterable memory at all. Used by MemoryRelevanceFilter.filterPrefix to short-circuit the LM call on prefixes that have no memory blocks to score.
Parameters
decomp
Returns
boolean
parseMemoryPrefix()
parseMemoryPrefix(
prefix):PrefixDecomposition
Defined in: src/agents/memoryFilter.ts:166
Split a prefix into non-memory messages and filterable blocks.
Detects the sentinel headers each memory tier emits and parses
their bodies into individual MemoryBlocks. Messages that
don't carry a memory sentinel are bucketed into head (before
the memory run) or tail (after); raw conversation history is
always in the tail.
Parameters
prefix
object[]
Returns
reassemblePrefix()
reassemblePrefix(
decomp,keepIds,options):object[]
Defined in: src/agents/memoryFilter.ts:262
Rebuild a prefix message list given a subset of block ids to keep.
Blocks whose tier the filter is configured to leave alone (per
filterObservations / filterWorkingMemory) are forced into
keepIds so we don't drop them when the LM happens to overlook
them. Tiers that lose every candidate produce no corresponding
message -- that's the whole point of the filter.
currentTask survives unconditionally as the trailing line of
the observations message; it carries a single rolling hint, not
a per-block candidate.
Parameters
decomp
keepIds
Set<string>
options
filterObservations
boolean
filterWorkingMemory
boolean
Returns
parseKeepIds()
parseKeepIds(
text,validIds):Set<string> |null
Defined in: src/agents/memoryFilter.ts:428
Pull the {"keep": [...]} set out of an LM reply.
Returns null when no parsable JSON object is found at all.
Returns an empty set when the LM said "keep nothing". Ids the LM
invents that don't match anything in validIds are silently
dropped -- the model occasionally hallucinates plausible-looking
ids and we don't want a typo to collapse the whole filter.
Parameters
text
string
validIds
Set<string>
Returns
Set<string> | null
getChatContext()
getChatContext():
ChatTurnContext|null
Defined in: src/agents/observationalMemory/context.ts:80
Return the chat-turn context for the current async task, if any.
Returns
ChatTurnContext | null
chatTurnContext()
chatTurnContext<
T>(ctx,fn):Promise<T>
Defined in: src/agents/observationalMemory/context.ts:92
Run fn with the given chat-turn context bound. Mirrors Python's
chat_turn_context context manager. Use this instead of the lower-
level bindChatContext/clearChatContext helpers when
possible: AsyncLocalStorage.run automatically scopes the context
to the lifetime of fn (including any awaited microtasks within),
with no manual cleanup.
Type Parameters
T
T
Parameters
ctx
fn
() => Promise<T>
Returns
Promise<T>
bindChatContext()
bindChatContext(
ctx):object
Defined in: src/agents/observationalMemory/context.ts:107
Lower-level binding API. Returns a disposable that restores the
previously-bound context. Most call sites should prefer
chatTurnContext; this exists for parity with Python's
bind_chat_context/clear_chat_context and for callers that cannot
wrap their work in a single async function.
IMPORTANT: AsyncLocalStorage.enterWith mutates the current async
context and is contagious across awaits in the same chain. Always
call dispose() in a finally block.
Parameters
ctx
Returns
object
dispose
dispose: () =>
void
Returns
void
clearChatContext()
clearChatContext(
token):void
Defined in: src/agents/observationalMemory/context.ts:116
Backwards-compatible "clear" hook for bindChatContext.
Parameters
token
dispose
() => void
Returns
void
formatTranscript()
formatTranscript(
messages):string
Defined in: src/agents/observationalMemory/observer.ts:33
Render a message list into the Observer's input transcript.
Mirrors Python _format_transcript: tool-call requests get a
(tool_calls: ...) synopsis when the assistant message has no text
content, so the Observer doesn't lose the fact that a tool was
invoked.
Parameters
messages
readonly object[]
Returns
string
observe()
observe(
options):Promise<{id:string;text:string;from_index:number;to_index:number;current_task?:string|null;suggested_response?:string|null;provider_model:string;status:"buffered"|"active";chars:number;thread_id?:string|null;resource_id?:string|null; } |null>
Defined in: src/agents/observationalMemory/observer.ts:137
Run one Observer LM call and return the produced chunk.
Returns null when the LM raises or produces an empty/unparseable
response. The buffer treats null as "skip this round" and tries
again on the next chat boundary.
fromIndex / toIndex are flat message indices (half-open range)
into the conversation history; they're stored on the
ObservationRecord and used by activation accounting on the next
chat turn.
providerModel is a string identifier (provider/slug) used by
activate_on_provider_change; falls back to model.slug when not
supplied.
Parameters
options
Returns
Promise<{ id: string; text: string; from_index: number; to_index: number; current_task?: string | null; suggested_response?: string | null; provider_model: string; status: "buffered" | "active"; chars: number; thread_id?: string | null; resource_id?: string | null; } | null>
formatObservationInput()
formatObservationInput(
transcript):string
Defined in: src/agents/observationalMemory/prompts.ts:64
Wraps the formatted transcript with a short framing line so the LM consistently treats the contents as historical material rather than fresh instructions.
Parameters
transcript
string
Returns
string
formatReflectionInput()
formatReflectionInput(
observationLog):string
Defined in: src/agents/observationalMemory/prompts.ts:72
Parameters
observationLog
string
Returns
string
formatObservationLog()
formatObservationLog(
observations):string
Defined in: src/agents/observationalMemory/reflector.ts:29
Render a list of ObservationRecords into the Reflector input.
Each observation is prefixed with the message-index range it covers so the Reflector can reason about ordering when needed.
Parameters
observations
readonly object[]
Returns
string
reflect()
reflect(
options):Promise<{id:string;text:string;from_index:number;to_index:number;current_task?:string|null;suggested_response?:string|null;provider_model:string;status:"buffered"|"active";chars:number;thread_id?:string|null;resource_id?:string|null; } |null>
Defined in: src/agents/observationalMemory/reflector.ts:62
Fold a contiguous run of observations into a single reflection.
fromIndex / toIndex are the flat message indices the underlying
observations cover (half-open). Stored on the produced
ReflectionRecord so activation accounting stays uniform with
ObservationRecord.
Parameters
options
Returns
Promise<{ id: string; text: string; from_index: number; to_index: number; current_task?: string | null; suggested_response?: string | null; provider_model: string; status: "buffered" | "active"; chars: number; thread_id?: string | null; resource_id?: string | null; } | null>
formatWorkingMemoryMessage()
formatWorkingMemoryMessage(
doc):object
Defined in: src/agents/observationalMemory/workingMemory.ts:49
Build the system message that splices working memory into the prefix. The header is a sentinel so the LM treats the body as a persistent profile rather than user content.
Parameters
doc
string
Returns
role
role:
"system"|"user"|"assistant"|"tool"
content
content:
string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[]
String form is preserved verbatim for back-compat; the
ContentPart array form (Phase 3) lets producers attach
images and files to any message and annotate individual parts with
Anthropic-flavored cache_control. Consumers that only care about
the textual portion can call messageToText to flatten
either form to a string. See
docs/concepts/multimodal-content-and-cache-control.md for the
cross-language design.
name?
optionalname?:string|null
tool_calls?
optionaltool_calls?:object[] |null
tool_call_id?
optionaltool_call_id?:string|null
updateWorkingMemory()
updateWorkingMemory(
args):Promise<string|null>
Defined in: src/agents/observationalMemory/workingMemory.ts:70
Run one updater LM call and return the rewritten doc. Returns
null when the LM raises or produces an empty response so the
caller can treat it as "skip this round".
Parameters
args
model
priorDoc
string
newMessages
object[]
template
string
maxChars
number
Returns
Promise<string | null>
getActiveRunContext()
getActiveRunContext():
RunContext|null
Defined in: src/agents/runner.ts:236
Returns
RunContext | null
getActiveAbortSignal()
getActiveAbortSignal():
AbortSignal|undefined
Defined in: src/agents/runner.ts:245
Convenience accessor for tool authors: returns the active run's
cancellation signal, or undefined when no run context is on the stack
or the caller did not pass signal to the runner.
Returns
AbortSignal | undefined
setPlan()
setPlan(
entries):object[]
Defined in: src/agents/runner.ts:261
Replace the run's current plan and emit a plan trace event.
entries may be partial inputs (e.g. {content: "step"}); each is
validated through PlanEntrySchema so emitted events always
carry strongly-typed entries with default priority/status filled
in. Mirrors Python RunContext.set_plan(...).
Returns the new plan list (the canonical value stored on
runContext.plan) so callers can chain. When invoked outside an
active run, this is a no-op and returns an empty list.
Parameters
entries
({ content: string; priority: "low" | "medium" | "high"; status: "pending" | "completed" | "in_progress"; } | { content: string; priority?: "low" | "medium" | "high"; status?: "pending" | "completed" | "in_progress"; })[]
Returns
object[]
updatePlanEntry()
updatePlanEntry(
identifier,patch):object[]
Defined in: src/agents/runner.ts:290
Patch a single plan entry and re-emit the full plan.
identifier selects the target entry by index (when number) or by
an exact match against PlanEntry.content (when string). Per
ACP semantics the emitted plan event always carries the full,
post-patch list -- consumers replace the prior plan wholesale.
Throws when no matching entry exists; this is a programmer error and
should not be silently swallowed. Mirrors Python
RunContext.update_plan_entry.
Parameters
identifier
string | number
patch
content?
string
priority?
"low" | "medium" | "high"
status?
"pending" | "completed" | "in_progress"
Returns
object[]
runAgent()
runAgent<
T>(specInput,query,options?):Promise<AgentResult<T>>
Defined in: src/agents/runner.ts:415
Type Parameters
T
T = string
Parameters
specInput
query
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]
options?
RunOptions = {}
Returns
Promise<AgentResult<T>>
runNestedAgent()
runNestedAgent<
T>(specInput,query,options):Promise<AgentResult<T>>
Defined in: src/agents/runner.ts:464
Type Parameters
T
T = string
Parameters
specInput
query
string
options
parent
span_id?
string | null
toolset?
string | null
Returns
Promise<AgentResult<T>>
runAgentStream()
runAgentStream<
T>(spec,query,options?):AsyncGenerator<StreamEnvelope<T>,void,undefined>
Defined in: src/agents/runner.ts:525
Async-iterable run that yields a tagged StreamEnvelope for every
trace event followed by the terminal { type: "result" } envelope.
Cancellation contract:
- If the caller passes
options.signaland aborts it, the underlying run is cancelled and anerrortrace event is emitted before the iterator returns. - If the consumer breaks the
for awaitloop early (or callsreturn()on the iterator), the runner aborts the inner controller so any in-flight model call / tool / nested run sees the cancellation.
Type Parameters
T
T = string
Parameters
spec
query
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]
options?
RunOptions = {}
Returns
AsyncGenerator<StreamEnvelope<T>, void, undefined>
runAgentResume()
runAgentResume<
T>(specInput,checkpoint,responses,options?):Promise<AgentResult<T>>
Defined in: src/agents/runner.ts:591
Type Parameters
T
T = string
Parameters
specInput
checkpoint
schema_version
1 | 2 = ...
spec_id
string = ...
iteration
number = ...
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
root_messages
object[] = ...
subagent_sessions
object[] = ...
pending
object[] = ...
checkpoint_id?
string | null = ...
responses
object[]
options?
RunOptions = {}
Returns
Promise<AgentResult<T>>
runAgentResumeStream()
runAgentResumeStream<
T>(specInput,checkpoint,responses,options?):AsyncGenerator<StreamEnvelope<T>,void,undefined>
Defined in: src/agents/runner.ts:629
Streaming twin of runAgentResume. Resolves the supplied
approval responses against the checkpoint, then drives the resumed run
through the same runAgentStream envelope contract: every
TraceEvent is yielded in order followed by a terminal
{ type: "result" } envelope. Cancellation contract matches
runAgentStream.
Type Parameters
T
T = string
Parameters
specInput
checkpoint
schema_version
1 | 2 = ...
spec_id
string = ...
iteration
number = ...
usage
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } = ...
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
root_messages
object[] = ...
subagent_sessions
object[] = ...
pending
object[] = ...
checkpoint_id?
string | null = ...
responses
object[]
options?
RunOptions = {}
Returns
AsyncGenerator<StreamEnvelope<T>, void, undefined>
isTransientHttpError()
isTransientHttpError(
error):boolean
Defined in: src/inference/_retryPredicates.ts:85
Default retryOn predicate. Returns true for transient HTTP
statuses (408, 425, 429, 5xx) and recognized transport-layer errors.
Returns false for AbortError-shaped exceptions so caller
cancellation never gets wrapped in a retry loop.
Parameters
error
unknown
Returns
boolean
isFallbackEligibleError()
isFallbackEligibleError(
error):boolean
Defined in: src/inference/_retryPredicates.ts:98
Default fallbackOn predicate. Adds 401, 403, and 404 to the
transient-status set: a fallback chain should switch providers when
the primary's credentials / catalog are wrong, even though those
statuses do not get better with a same-provider retry.
Parameters
error
unknown
Returns
boolean
parseRetryAfter()
parseRetryAfter(
error):number|null
Defined in: src/inference/_retryPredicates.ts:123
Parse a Retry-After header (seconds OR HTTP-date per RFC 7231
§7.1.3) into a delay in seconds, or null when the header is absent /
malformed / the error carries no header data.
Resolution order:
error.retryAfterDate(aDatesnapshotted at error construction). Recompute(date - now) / 1000so the delay stays accurate even after the retry layer has slept on a previous attempt.error.retryAfterMs(a normalized millisecond delta). Returned as-is converted to seconds. Adapters set this from the seconds form of the header.- Legacy
response.headers/headerslookups (for adapters that don't expose the normalized fields yet, including custom adapters and the test mocks ininference-retrying.test.ts).
Parameters
error
unknown
Returns
number | null
messageToAnthropicPayload()
messageToAnthropicPayload(
message):Record<string,unknown> |null
Defined in: src/inference/adapters/anthropic.ts:648
Parameters
message
role
"system" | "user" | "assistant" | "tool" = ...
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
String form is preserved verbatim for back-compat; the
ContentPart array form (Phase 3) lets producers attach
images and files to any message and annotate individual parts with
Anthropic-flavored cache_control. Consumers that only care about
the textual portion can call messageToText to flatten
either form to a string. See
docs/concepts/multimodal-content-and-cache-control.md for the
cross-language design.
name?
string | null = ...
tool_calls?
object[] | null = ...
tool_call_id?
string | null = ...
Returns
Record<string, unknown> | null
splitSystemAndMessages()
splitSystemAndMessages(
messages):object
Defined in: src/inference/adapters/anthropic.ts:688
Parameters
messages
object[]
Returns
object
system
system:
string|Record<string,unknown>[] |null
messages
messages:
Record<string,unknown>[]
toolDefToAnthropicPayload()
toolDefToAnthropicPayload(
tool):Record<string,unknown>
Defined in: src/inference/adapters/anthropic.ts:725
Parameters
tool
name
string = ...
description
string = ...
input_schema
JsonDict = ...
Returns
Record<string, unknown>
mapAnthropicStopReason()
mapAnthropicStopReason(
raw):AnthropicFinishMapping
Defined in: src/inference/adapters/anthropic.ts:740
Parameters
raw
string | null
Returns
parseAnthropicContentBlocks()
parseAnthropicContentBlocks(
blocks):object
Defined in: src/inference/adapters/anthropic.ts:753
Parameters
blocks
({[key: string]: unknown; type: "text"; text: string; cache_control?: {[key: string]: unknown; type: "ephemeral"; } | null; } | {[key: string]: unknown; type: "image"; source: {[key: string]: unknown; type: "base64" | "url"; media_type?: string; data?: string; url?: string; }; cache_control?: {[key: string]: unknown; type: "ephemeral"; } | null; } | {[key: string]: unknown; type: "document"; source: {[key: string]: unknown; type: "base64" | "url"; media_type?: string; data?: string; url?: string; }; name?: string | null; cache_control?: {[key: string]: unknown; type: "ephemeral"; } | null; } | {[key: string]: unknown; type: "tool_use"; id: string; name: string; input: JsonDict; cache_control?: {[key: string]: unknown; type: "ephemeral"; } | null; } | {[key: string]: unknown; type: "thinking"; thinking?: string; signature?: string; } | {[key: string]: unknown; type: "redacted_thinking"; data?: string; })[]
Returns
object
content
content:
string
toolCalls
toolCalls:
object[]
reasoning
reasoning:
string|null
resetOpenAICompatibleStripWarnings()
resetOpenAICompatibleStripWarnings():
void
Defined in: src/inference/adapters/openaiCompatible.ts:425
Test-only escape hatch to reset the cache_control / FilePart
one-time warnings. Production code should never call this.
Returns
void
messageToOpenAICompatiblePayload()
messageToOpenAICompatiblePayload(
message):Record<string,unknown>
Defined in: src/inference/adapters/openaiCompatible.ts:490
Parameters
message
role
"system" | "user" | "assistant" | "tool" = ...
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] = ...
String form is preserved verbatim for back-compat; the
ContentPart array form (Phase 3) lets producers attach
images and files to any message and annotate individual parts with
Anthropic-flavored cache_control. Consumers that only care about
the textual portion can call messageToText to flatten
either form to a string. See
docs/concepts/multimodal-content-and-cache-control.md for the
cross-language design.
name?
string | null = ...
tool_calls?
object[] | null = ...
tool_call_id?
string | null = ...
Returns
Record<string, unknown>
toolDefToOpenAICompatiblePayload()
toolDefToOpenAICompatiblePayload(
tool):Record<string,unknown>
Defined in: src/inference/adapters/openaiCompatible.ts:518
Parameters
tool
name
string = ...
description
string = ...
input_schema
JsonDict = ...
Returns
Record<string, unknown>
parseOpenAICompatibleToolCalls()
parseOpenAICompatibleToolCalls(
message):object[]
Defined in: src/inference/adapters/openaiCompatible.ts:529
Parameters
message
Record<string, unknown>
Returns
usageFromOpenAICompatibleBlob()
usageFromOpenAICompatibleBlob(
blob):object
Defined in: src/inference/adapters/openaiCompatible.ts:553
Parameters
blob
unknown
Returns
object
prompt
prompt:
number
completion
completion:
number
cost_usd?
optionalcost_usd?:number|null
cache_creation_input_tokens?
optionalcache_creation_input_tokens?:number|null
cache_read_input_tokens?
optionalcache_read_input_tokens?:number|null
parseOpenAICompatibleModels()
parseOpenAICompatibleModels(
data,provider):object[]
Defined in: src/inference/adapters/openaiCompatible.ts:577
Parse a plain OpenAI-style GET /models body into ModelSpecs.
Handles the canonical { object: "list", data: [{ id, created, owned_by }] } shape used by OpenAI itself and the local OpenAI-
compatible servers (llama.cpp, mlx). These endpoints don't surface
context windows or pricing, so the specs carry just id / created /
owned_by plus the verbatim entry on raw. The one exception:
llama.cpp / mlx expose the loaded model's training context as
meta.n_ctx_train (or meta.n_ctx), mapped onto context_window.
Entries without a usable string id are skipped; a malformed body
yields [] rather than throwing. Twin of Python
parse_oai_models_list.
Parameters
data
unknown
provider
string
Returns
object[]
coercePrice()
coercePrice(
value):number|undefined
Defined in: src/inference/adapters/openaiCompatible.ts:617
Parse a provider price (decimal string or number) to USD number.
Catalog APIs report per-token prices as decimal strings; this
normalizes them. Returns undefined for missing / unparseable /
negative values (a negative price is a "not reported" sentinel); 0
is preserved as a genuinely free tier. Twin of Python coerce_price.
Parameters
value
unknown
Returns
number | undefined
coerceStringArray()
coerceStringArray(
value):string[]
Defined in: src/inference/adapters/openaiCompatible.ts:637
Filter a provider value to a list of strings, dropping non-string
elements and yielding [] for non-array input. Twin of Python
coerce_str_list.
Parameters
value
unknown
Returns
string[]
mapOpenAICompatibleFinishReasonDetailed()
mapOpenAICompatibleFinishReasonDetailed(
raw):OpenAICompatibleFinishMapping
Defined in: src/inference/adapters/openaiCompatible.ts:656
Parameters
raw
unknown
Returns
mapOpenAICompatibleFinishReason()
mapOpenAICompatibleFinishReason(
raw):"length"|"error"|"stop"
Defined in: src/inference/adapters/openaiCompatible.ts:680
Backwards-compatible thin wrapper. Prefer
mapOpenAICompatibleFinishReasonDetailed when you also want to
record the raw provider string on a StreamChunk or token event.
Parameters
raw
unknown
Returns
"length" | "error" | "stop"
setOpenAICompatibleSseParseErrorHook()
setOpenAICompatibleSseParseErrorHook(
hook):void
Defined in: src/inference/adapters/openaiCompatible.ts:707
Install (or clear with null) a global hook for SSE JSON parse errors.
Parameters
hook
SseParseErrorHook | null
Returns
void
parseOpenRouterModels()
parseOpenRouterModels(
data):object[]
Defined in: src/inference/adapters/openrouter.ts:76
Parse OpenRouter's GET /models body into ModelSpecs. OpenRouter
exposes the richest catalog of any provider: context_length ->
context_window, top_provider.max_completion_tokens ->
max_output_tokens, per-token pricing,
architecture.input_modalities / output_modalities, and
supported_parameters. The verbatim entry is preserved on
ModelSpec.raw. Twin of Python parse_openrouter_models.
Parameters
data
unknown
Returns
object[]
parseVercelModels()
parseVercelModels(
data):object[]
Defined in: src/inference/adapters/vercelGateway.ts:150
Parse the Vercel AI Gateway GET /models body into ModelSpecs.
Vercel exposes context_window, max_tokens -> max_output_tokens,
per-token pricing, capability tags -> supported_parameters, and
owned_by; tiered pricing stays on ModelSpec.raw. Model ids use the
gateway's provider/model convention. Twin of Python
parse_vercel_models.
Parameters
data
unknown
Returns
object[]
parseToolCallArgs()
parseToolCallArgs(
input):ToolCallArgsParseResult
Defined in: src/inference/base.ts:51
Parse an accumulated streaming tool-call args payload into a
JsonDict. Treats an empty/whitespace-only text as an empty object
({}) — consistent with provider semantics — but does NOT silently
coerce malformed JSON or non-object JSON values to {}. Callers must
surface the ToolCallArgsError (e.g. via a tool_arguments_invalid
trace event) rather than invoking the tool with empty arguments.
Parameters
input
string | { argsText?: string | null; } | null | undefined
Returns
mergeStreamChunks()
mergeStreamChunks(
chunks,onChunk?):Promise<{[key:string]:unknown;content:string| ({type:"text";text:string;cache_control?: {type:"ephemeral"; } |null; } | {type:"image";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };cache_control?: {type:"ephemeral"; } |null; } | {type:"file";source: {kind:"base64";media_type:string;data:string; } | {kind:"url";url:string; };filename?:string|null;cache_control?: {type:"ephemeral"; } |null; })[];usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:"length"|"error"|"stop";tool_calls:object[];reasoning?:string|null; }>
Defined in: src/inference/base.ts:86
Parameters
chunks
AsyncIterable<{ kind: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control"; delta: string; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: "length" | "error" | "stop" | null; raw_finish_reason?: string | null; content_part_kind?: "file" | "text" | "image" | null; }>
onChunk?
Returns
Promise<{[key: string]: unknown; content: string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[]; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: "length" | "error" | "stop"; tool_calls: object[]; reasoning?: string | null; }>
scopeAllowsRead()
scopeAllowsRead(
scope,namespace):boolean
Defined in: src/memory/base.ts:45
Parameters
scope
read
string[] = ...
write
string[] = ...
namespace
string
Returns
boolean
scopeAllowsWrite()
scopeAllowsWrite(
scope,namespace):boolean
Defined in: src/memory/base.ts:50
Parameters
scope
read
string[] = ...
write
string[] = ...
namespace
string
Returns
boolean
getActiveHonchoMemory()
getActiveHonchoMemory():
HonchoMemory|null
Defined in: src/memory/honchoActive.ts:23
Return the HonchoMemory bound to the current async context, or null.
Returns
HonchoMemory | null
withActiveHonchoMemory()
withActiveHonchoMemory<
T>(memory,fn):Promise<T>
Defined in: src/memory/honchoActive.ts:31
Run fn with memory bound as the active HonchoMemory.
Mirrors the chatTurnContext helper for observational memory.
Type Parameters
T
T
Parameters
memory
HonchoMemory | null
fn
() => Promise<T>
Returns
Promise<T>
hasMemorySequencer()
hasMemorySequencer(
memory):memory is Memory & { nextSequence: any }
Defined in: src/memory/sequence.ts:5
Parameters
memory
Returns
memory is Memory & { nextSequence: any }
nextIndex()
nextIndex(
memory,namespace,key,scope,options):Promise<number>
Defined in: src/memory/sequence.ts:11
Parameters
memory
namespace
string
key
string
scope
read
string[] = ...
write
string[] = ...
options
fallback
Returns
Promise<number>
resolvePath()
resolvePath(
value,path):unknown[]
Defined in: src/permissions/policy.ts:141
Resolve every leaf reachable from value along path. Missing
intermediate keys terminate the corresponding branch silently;
callers distinguish "no leaves" from "a leaf happened to be
undefined" by counting the iterator.
Parameters
value
unknown
path
string
Returns
unknown[]
evaluateMany()
evaluateMany(
policy,actions):Promise<object[]>
Defined in: src/permissions/policy.ts:279
Default implementation of PermissionPolicy.evaluateMany.
Concrete policies that don't override the optional method fall back
to looping over evaluate. Exposed as a free function so the
runner's sub-action fan-out can call it uniformly.
Parameters
policy
actions
object[]
Returns
Promise<object[]>
buildReplMemoryCallable()
buildReplMemoryCallable(
memory,principalId,tracer?,options?):ReplMemoryCallable
Defined in: src/runtime/memoryProxy.ts:22
Parameters
memory
principalId
string
tracer?
options?
ReplMemoryCallableOptions = {}
Returns
normalizeAgent()
normalizeAgent(
spec):Agent
Defined in: src/schemas/agents.ts:789
Parameters
spec
Returns
resolveInstructions()
resolveInstructions(
instructions,ctx):Promise<string>
Defined in: src/schemas/agents.ts:858
Parameters
instructions
string | InstructionsBuilder
ctx
query
string = ...
agent_id
string = ...
resource_id?
string | null = ...
Mastra-style "resource" identity (typically the human user the
chat belongs to). Plumbed through from app.chat(..., resourceId)
so a dynamic instructions builder can vary the system prompt per
user, and so cross-thread observational memory (when
ObservationalMemoryConfig.scope === "resource") can pool a
single user's observations across every thread. null when the
caller didn't pass one.
metadata
JsonDict = ...
Returns
Promise<string>
makeCheckpoint()
makeCheckpoint(
input):object
Defined in: src/schemas/agents.ts:865
Parameters
input
spec_id
string
iteration
number
usage?
{ prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }
usage.prompt
number = ...
usage.completion
number = ...
usage.cost_usd?
number | null = ...
usage.cache_creation_input_tokens?
number | null = ...
usage.cache_read_input_tokens?
number | null = ...
root_messages?
object[]
subagent_sessions?
object[]
pending?
object[]
checkpoint_id?
string | null
Returns
object
schema_version
schema_version:
1|2
spec_id
spec_id:
string
iteration
iteration:
number
usage
usage:
object
usage.prompt
prompt:
number
usage.completion
completion:
number
usage.cost_usd?
optionalcost_usd?:number|null
usage.cache_creation_input_tokens?
optionalcache_creation_input_tokens?:number|null
usage.cache_read_input_tokens?
optionalcache_read_input_tokens?:number|null
root_messages
root_messages:
object[]
subagent_sessions
subagent_sessions:
object[]
pending
pending:
object[]
checkpoint_id?
optionalcheckpoint_id?:string|null
makeTraceEvent()
makeTraceEvent<
K>(kind,payload?,options?): {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"token";payload: {[key:string]:unknown;model?:string;scope?:string;iteration?:number;toolset?:string|null;lm_span_id?:string|null;usage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null;finish_reason?:string|null;raw_finish_reason?:string|null; };delta:string;chunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null;content_part_kind?:"file"|"text"|"image"|null;partial_object?:JsonDict|null;tool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call_start";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;toolset?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"lm_call";payload: {[key:string]:unknown;model:string;scope:string;iteration:number;usage: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; };finish_reason:string;toolset?:string|null;raw_finish_reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool";payload: {[key:string]:unknown;tool_call_id:string;tool_name:string;toolset?:string|null;phase:"completed"|"failed"|"cancelled"|"started";args?:JsonDict;result?:JsonDict|null;result_preview?: {[key:string]:unknown;ok?:boolean;value?:unknown;error?:string|null;metadata?:JsonDict|null;result_truncated?:boolean;value_omitted_reason?:string|null; } |null;ok?:boolean|null;allowed?:boolean|null;error?:string|null;reason?:string|null;started_at?:string|null;finished_at?:string|null;elapsed_ms?:number|null;decision?: {[key:string]:unknown;allowed:boolean;requires_approval:boolean;matched_rule_id?:string|null;reason?:string|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"tool_call_arguments_delta";payload: {[key:string]:unknown;tool_call_id?:string|null;tool_name?:string|null;index:number;arguments_delta:string;sequence:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"cell";payload: {[key:string]:unknown;cell_id:string;phase:"completed"|"failed"|"cancelled"|"started";code?:string|null;result?:JsonDict|null;error?:string|null;elapsed_ms?:number|null;stdout_len?:number|null;stderr_len?:number|null;variables?:string[] |null;src?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"subagent";payload: {[key:string]:unknown;phase:"error"|"completed"|"intent"|"start"|"paused"|"errored";agent_id?:string|null;toolset?:string|null;role?:string|null;prompt_summary?:string|null;prompt?:string|null;parent_span_id?:string|null;background?:boolean|null;iterations?:number|null;reason?:string|null;max_depth?:number|null;repl?:boolean|null;usage?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"agent";payload: {[key:string]:unknown;phase:"completed"|"started";agent_id:string;principal?:string|null;iterations?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"approval";payload: {[key:string]:unknown;phase:"requested"|"approved"|"denied"|"resolved";id?:string;toolset?:string|null;tool?:string|null;rule_id?:string|null;reason?:string|null;source:"guardrail"|"policy";decision?:"approve"|"deny"|null;approvals:object[]; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"memory";payload: {[key:string]:unknown;op:string;phase?:string|null;principal?:string|null;depth?:number|null;summary?:string|null;namespace?:string|null;agent_id?:string|null;thread_id?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"guardrail";payload: {[key:string]:unknown;phase:string;boundary?:string|null;action?:string|null;decision?:string|null;rule_id?:string|null;reason?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"background_task";payload: {[key:string]:unknown;phase:string;task_id:string;status?:string|null;progress?:number|null;output?:JsonDict|null;agent_id?:string|null;sub_agent_id?:string|null;tool?:string|null;attempt?:number|null;error?:string|null;iterations?:number|null;timeout_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"step";payload: {[key:string]:unknown;phase:"before"|"after"|"repair"|"stopped"|"finalize_vetoed";turn_index:number;iteration?:number|null;source?:string|null;reason?:string|null;elapsed_ms?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"retry";payload: {[key:string]:unknown;attempt:number;reason:string;model?:string|null;max_attempts?:number|null;delay_s?:number|null;fallback?:boolean|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"final";payload: {[key:string]:unknown;source:string;iterations?:number|null;validated?:boolean|null;error?:string|null;pending?:number|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"error";payload: {[key:string]:unknown;message:string;kind_of_error?:string|null;cause?:string|null;retryable?:boolean|null;reason?:string|null;detail?:string|null; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"stream_gap";payload: {[key:string]:unknown;dropped_count_so_far:number; }; } | {ts:string;depth:number;principal?:string|null;span_id?:string|null;parent_span_id?:string|null;seq:number;event_id:string;run_id:string;turn_id?:string|null;message_id?:string|null;block_id?:string|null;thread_id?:string|null;kind:"plan";payload: {[key:string]:unknown;entries:object[]; }; }
Defined in: src/schemas/agents.ts:926
Build a typed TraceEvent. The payload is parsed by the per-kind payload
schema so callers can pass a bare JSON dict and still get a typed payload
back. The discriminator (kind) is set at the top level only — it is no
longer copied into payload as it was in the legacy shape.
Type Parameters
K
K extends TraceKind
Parameters
kind
K
payload?
Record<string, unknown> | JsonDict
options?
Returns
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "token"; payload: {[key: string]: unknown; model?: string; scope?: string; iteration?: number; toolset?: string | null; lm_span_id?: string | null; usage_delta?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; finish_reason?: string | null; raw_finish_reason?: string | null; }; delta: string; chunk_kind?: "text" | "reasoning" | "json_partial" | "object_partial" | "tool_call_partial" | "control" | null; content_part_kind?: "file" | "text" | "image" | null; partial_object?: JsonDict | null; tool_call_delta?: { index: number; id?: string | null; name?: string | null; arguments_partial: string; } | null; }
ts
ts:
string
depth
depth:
number
principal?
optionalprincipal?:string|null
span_id?
optionalspan_id?:string|null
parent_span_id?
optionalparent_span_id?:string|null
seq
seq:
number
event_id
event_id:
string
run_id
run_id:
string
turn_id?
optionalturn_id?:string|null
message_id?
optionalmessage_id?:string|null
block_id?
optionalblock_id?:string|null
thread_id?
optionalthread_id?:string|null
kind
kind:
"token"
payload
payload:
object
Index Signature
[key: string]: unknown
payload.model?
optionalmodel?:string
payload.scope?
optionalscope?:string
payload.iteration?
optionaliteration?:number
payload.toolset?
optionaltoolset?:string|null
payload.lm_span_id?
optionallm_span_id?:string|null
payload.usage_delta?
optionalusage_delta?: {prompt:number;completion:number;cost_usd?:number|null;cache_creation_input_tokens?:number|null;cache_read_input_tokens?:number|null; } |null
payload.finish_reason?
optionalfinish_reason?:string|null
payload.raw_finish_reason?
optionalraw_finish_reason?:string|null
delta
delta:
string
chunk_kind?
optionalchunk_kind?:"text"|"reasoning"|"json_partial"|"object_partial"|"tool_call_partial"|"control"|null
content_part_kind?
optionalcontent_part_kind?:"file"|"text"|"image"|null
Optional discriminator for the multimodal content part the delta
belongs to (Phase 3). Additive: existing producers may leave it
null/omitted, and existing consumers continue to work without
reading it. The runner sets it whenever a stream produces image
or file deltas (today only the Anthropic adapter); plain-text
streams keep it null.
partial_object?
optionalpartial_object?:JsonDict|null
tool_call_delta?
optionaltool_call_delta?: {index:number;id?:string|null;name?:string|null;arguments_partial:string; } |null
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "lm_call_start"; payload: {[key: string]: unknown; model: string; scope: string; iteration: number; toolset?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "lm_call"; payload: {[key: string]: unknown; model: string; scope: string; iteration: number; usage: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; }; finish_reason: string; toolset?: string | null; raw_finish_reason?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "tool"; payload: {[key: string]: unknown; tool_call_id: string; tool_name: string; toolset?: string | null; phase: "completed" | "failed" | "cancelled" | "started"; args?: JsonDict; result?: JsonDict | null; result_preview?: {[key: string]: unknown; ok?: boolean; value?: unknown; error?: string | null; metadata?: JsonDict | null; result_truncated?: boolean; value_omitted_reason?: string | null; } | null; ok?: boolean | null; allowed?: boolean | null; error?: string | null; reason?: string | null; started_at?: string | null; finished_at?: string | null; elapsed_ms?: number | null; decision?: {[key: string]: unknown; allowed: boolean; requires_approval: boolean; matched_rule_id?: string | null; reason?: string | null; } | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "tool_call_arguments_delta"; payload: {[key: string]: unknown; tool_call_id?: string | null; tool_name?: string | null; index: number; arguments_delta: string; sequence: number; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "cell"; payload: {[key: string]: unknown; cell_id: string; phase: "completed" | "failed" | "cancelled" | "started"; code?: string | null; result?: JsonDict | null; error?: string | null; elapsed_ms?: number | null; stdout_len?: number | null; stderr_len?: number | null; variables?: string[] | null; src?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "subagent"; payload: {[key: string]: unknown; phase: "error" | "completed" | "intent" | "start" | "paused" | "errored"; agent_id?: string | null; toolset?: string | null; role?: string | null; prompt_summary?: string | null; prompt?: string | null; parent_span_id?: string | null; background?: boolean | null; iterations?: number | null; reason?: string | null; max_depth?: number | null; repl?: boolean | null; usage?: { prompt: number; completion: number; cost_usd?: number | null; cache_creation_input_tokens?: number | null; cache_read_input_tokens?: number | null; } | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "agent"; payload: {[key: string]: unknown; phase: "completed" | "started"; agent_id: string; principal?: string | null; iterations?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "approval"; payload: {[key: string]: unknown; phase: "requested" | "approved" | "denied" | "resolved"; id?: string; toolset?: string | null; tool?: string | null; rule_id?: string | null; reason?: string | null; source: "guardrail" | "policy"; decision?: "approve" | "deny" | null; approvals: object[]; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "memory"; payload: {[key: string]: unknown; op: string; phase?: string | null; principal?: string | null; depth?: number | null; summary?: string | null; namespace?: string | null; agent_id?: string | null; thread_id?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "guardrail"; payload: {[key: string]: unknown; phase: string; boundary?: string | null; action?: string | null; decision?: string | null; rule_id?: string | null; reason?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "background_task"; payload: {[key: string]: unknown; phase: string; task_id: string; status?: string | null; progress?: number | null; output?: JsonDict | null; agent_id?: string | null; sub_agent_id?: string | null; tool?: string | null; attempt?: number | null; error?: string | null; iterations?: number | null; timeout_ms?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "step"; payload: {[key: string]: unknown; phase: "before" | "after" | "repair" | "stopped" | "finalize_vetoed"; turn_index: number; iteration?: number | null; source?: string | null; reason?: string | null; elapsed_ms?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "retry"; payload: {[key: string]: unknown; attempt: number; reason: string; model?: string | null; max_attempts?: number | null; delay_s?: number | null; fallback?: boolean | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "final"; payload: {[key: string]: unknown; source: string; iterations?: number | null; validated?: boolean | null; error?: string | null; pending?: number | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "error"; payload: {[key: string]: unknown; message: string; kind_of_error?: string | null; cause?: string | null; retryable?: boolean | null; reason?: string | null; detail?: string | null; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "stream_gap"; payload: {[key: string]: unknown; dropped_count_so_far: number; }; }
Type Literal
{ ts: string; depth: number; principal?: string | null; span_id?: string | null; parent_span_id?: string | null; seq: number; event_id: string; run_id: string; turn_id?: string | null; message_id?: string | null; block_id?: string | null; thread_id?: string | null; kind: "plan"; payload: {[key: string]: unknown; entries: object[]; }; }
nowIso()
nowIso():
string
Defined in: src/schemas/common.ts:28
Returns
string
parseJsonDict()
parseJsonDict(
value,label?):JsonDict
Defined in: src/schemas/common.ts:32
Parameters
value
unknown
label?
string = "value"
Returns
toJsonValue()
toJsonValue(
value):JsonValue
Defined in: src/schemas/common.ts:40
Parameters
value
unknown
Returns
toJsonDict()
toJsonDict(
value):JsonDict
Defined in: src/schemas/common.ts:44
Parameters
value
Record<string, unknown>
Returns
safeToJsonValue()
safeToJsonValue(
value):SafeJsonValueResult
Defined in: src/schemas/common.ts:62
Non-throwing variant of toJsonValue. Replaces cyclic references
with the literal string "[Circular]" (using a WeakSet of seen
objects) and returns a tagged result instead of throwing on
un-serializable input. Use this on hot paths (e.g. RPC success
responses over arbitrary user data) where a poison value must not
crash the caller.
toJsonValue is preserved as-is for backward compatibility.
Parameters
value
unknown
Returns
messageToText()
messageToText(
content):string
Defined in: src/schemas/inference.ts:126
Flatten a MessageContent to a plain string. Returns the input verbatim when it's already a string; for a part list, concatenates every TextPart.text. Image and file parts contribute nothing.
Adapters and consumers that only care about the textual portion (log lines, simple LLM-as-judge eval prompts) can use this helper unconditionally regardless of the producer-side shape.
Parameters
content
string | ({ type: "text"; text: string; cache_control?: { type: "ephemeral"; } | null; } | { type: "image"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; cache_control?: { type: "ephemeral"; } | null; } | { type: "file"; source: { kind: "base64"; media_type: string; data: string; } | { kind: "url"; url: string; }; filename?: string | null; cache_control?: { type: "ephemeral"; } | null; })[] | null | undefined
Returns
string
addUsage()
addUsage(
a,b):object
Defined in: src/schemas/inference.ts:199
Parameters
a
prompt
number = ...
completion
number = ...
cost_usd?
number | null = ...
cache_creation_input_tokens?
number | null = ...
cache_read_input_tokens?
number | null = ...
b
prompt
number = ...
completion
number = ...
cost_usd?
number | null = ...
cache_creation_input_tokens?
number | null = ...
cache_read_input_tokens?
number | null = ...
Returns
object
prompt
prompt:
number
completion
completion:
number
cost_usd?
optionalcost_usd?:number|null
cache_creation_input_tokens?
optionalcache_creation_input_tokens?:number|null
cache_read_input_tokens?
optionalcache_read_input_tokens?:number|null
effortToAnthropicBudgetTokens()
effortToAnthropicBudgetTokens(
effort):number
Defined in: src/schemas/inference.ts:378
Map a normalized ReasoningEffort onto an approximate Anthropic
thinking.budget_tokens value. The exact numbers are chosen to be
useful defaults rather than a literal translation -- callers who want
a precise budget should set ReasoningConfig.max_tokens directly.
The mapping is intentionally conservative on minimal (Anthropic
requires budget_tokens >= 1024).
Parameters
effort
"minimal" | "low" | "medium" | "high"
Returns
number
asToolDef()
asToolDef(
input):object
Defined in: src/schemas/inference.ts:487
Parameters
input
name
string
description?
string
input_schema?
Returns
object
name
name:
string
description
description:
string
input_schema
input_schema:
JsonDict
supportsModelCatalog()
supportsModelCatalog<
T>(model):model is T & SupportsModelCatalog
Defined in: src/schemas/inference.ts:589
Runtime feature-detection for SupportsModelCatalog. Mirrors the
Python isinstance(model, SupportsModelCatalog) check (which, for a
runtime_checkable Protocol, also just tests for a list_models
attribute).
Type Parameters
T
T extends object
Parameters
model
T
Returns
model is T & SupportsModelCatalog
coerceRuntimeMemoryAccess()
coerceRuntimeMemoryAccess(
value):object
Defined in: src/schemas/memory.ts:340
Normalise caller input into a fully-populated RuntimeMemoryAccess.
Accepts an already-built instance, a partial dict, or null/undefined.
Unknown mode strings raise a ZodError at the boundary.
Parameters
value
{ observational: "read" | "write" | "off"; working: "read" | "write" | "off"; } | RuntimeMemoryAccessInput | null | undefined
Type Literal
{ observational: "read" | "write" | "off"; working: "read" | "write" | "off"; }
observational
"read" | "write" | "off" = ...
Mode for observational memory (the ObservationBuffer tier).
When the app has no ObservationBuffer configured this field is
ignored and the runtime treats the layer as "off" regardless.
working
"read" | "write" | "off" = ...
Mode for working memory (the singleton mutable doc).
When the app has no WorkingMemoryRunner configured this field is
ignored and the runtime treats the layer as "off" regardless.
null
undefined
Returns
observational
observational:
"read"|"write"|"off"
Mode for observational memory (the ObservationBuffer tier).
When the app has no ObservationBuffer configured this field is
ignored and the runtime treats the layer as "off" regardless.
working
working:
"read"|"write"|"off"
Mode for working memory (the singleton mutable doc).
When the app has no WorkingMemoryRunner configured this field is
ignored and the runtime treats the layer as "off" regardless.
allow()
allow(): {
action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }
Defined in: src/schemas/middleware.ts:62
Returns
Type Literal
{ action: "allow"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "block"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }
action
action:
"require_approval"
pending
pending:
object[]
Sub-actions to fan the approval out across (Tier 1 #3). Empty list
is treated as "approve the inbound call as a single sub-action";
the runtime synthesises one entry from the resolved RuntimeToolCall.
rule_id?
optionalrule_id?:string|null
reason?
optionalreason?:string|null
block()
block(
reason?,options?): {action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }
Defined in: src/schemas/middleware.ts:66
Parameters
reason?
string | null
options?
rule_id?
string | null
Returns
Type Literal
{ action: "allow"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "block"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }
action
action:
"require_approval"
pending
pending:
object[]
Sub-actions to fan the approval out across (Tier 1 #3). Empty list
is treated as "approve the inbound call as a single sub-action";
the runtime synthesises one entry from the resolved RuntimeToolCall.
rule_id?
optionalrule_id?:string|null
reason?
optionalreason?:string|null
rewrite()
rewrite(
payload,options?): {action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }
Defined in: src/schemas/middleware.ts:70
Parameters
payload
unknown
options?
rule_id?
string | null
reason?
string | null
Returns
Type Literal
{ action: "allow"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "block"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }
action
action:
"require_approval"
pending
pending:
object[]
Sub-actions to fan the approval out across (Tier 1 #3). Empty list
is treated as "approve the inbound call as a single sub-action";
the runtime synthesises one entry from the resolved RuntimeToolCall.
rule_id?
optionalrule_id?:string|null
reason?
optionalreason?:string|null
requireApproval()
requireApproval(
pending?,options?): {action:"allow";rule_id?:string|null;reason?:string|null; } | {action:"rewrite";payload?:unknown;rule_id?:string|null;reason?:string|null; } | {action:"block";rule_id?:string|null;reason?:string|null; } | {action:"require_approval";pending:object[];rule_id?:string|null;reason?:string|null; }
Defined in: src/schemas/middleware.ts:85
Convenience builder for the new require_approval variant
(Tier 1 #3). Pass an empty / omitted pending list to request
approval for the single inbound call (the runtime synthesises one
sub-action), or pass multiple PendingSubActions to fan the
decision out across several upstream sub-calls (mirrors the
evaluateMany path used by delegated_tool expansion).
Parameters
pending?
object[] | null
options?
rule_id?
string | null
reason?
string | null
Returns
Type Literal
{ action: "allow"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "rewrite"; payload?: unknown; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "block"; rule_id?: string | null; reason?: string | null; }
Type Literal
{ action: "require_approval"; pending: object[]; rule_id?: string | null; reason?: string | null; }
action
action:
"require_approval"
pending
pending:
object[]
Sub-actions to fan the approval out across (Tier 1 #3). Empty list
is treated as "approve the inbound call as a single sub-action";
the runtime synthesises one entry from the resolved RuntimeToolCall.
rule_id?
optionalrule_id?:string|null
reason?
optionalreason?:string|null
acpFsTools()
acpFsTools():
Tool[]
Defined in: src/tools/builtin/acpFs.ts:215
Returns
Tool[]
acpTerminalTools()
acpTerminalTools():
Tool[]
Defined in: src/tools/builtin/acpTerminal.ts:193
Returns
Tool[]
backgroundControlTools()
backgroundControlTools():
Tool[]
Defined in: src/tools/builtin/backgroundControl.ts:578
The four built-in background-control tools. Returned by
backgroundControlTools as a fresh array so callers (e.g.
the runner's collectTools) can splice them directly into the
tool surface without worrying about aliasing.
Returns
Tool[]
honchoTools()
honchoTools():
Tool[]
Defined in: src/tools/builtin/honchoTools.ts:190
Returned as a fresh array by callers to keep the surface mutable.
Returns
Tool[]
planTools()
planTools():
Tool[]
Defined in: src/tools/builtin/plan.ts:137
Return the built-in plan tools.
Currently a single-element array (set_plan); kept as an array so
future additions can join without a signature change. Mirrors
workingMemoryTools / backgroundControlTools.
Returns
Tool[]
appendBullet()
appendBullet(
doc,options): [string,boolean]
Defined in: src/tools/builtin/workingMemory.ts:33
Return [updatedDoc, alreadyPresent].
The bullet is added under a ## <section> heading. If the
heading isn't present in doc we append a fresh section to the
end. If the bullet is byte-identical to one already in the
section's body, the doc is returned unchanged and the second
tuple element is true.
Parameters
doc
string
options
section
string
bullet
string
Returns
[string, boolean]
workingMemoryTools()
workingMemoryTools():
Tool[]
Defined in: src/tools/builtin/workingMemory.ts:216
The built-in working-memory tools. Returned by
workingMemoryTools as a fresh array so callers (e.g. the
runner's collectTools) can splice them directly into the tool
surface without worrying about aliasing.
Returns
Tool[]
References
Continuation
Re-exports Continuation
PrepareStep
Re-exports PrepareStep
StepContext
Re-exports StepContext
StepDecision
Re-exports StepDecision
StepHook
Re-exports StepHook
StopWhen
Re-exports StopWhen
SqliteMemory
Re-exports SqliteMemory
SqliteMemoryOptions
Re-exports SqliteMemoryOptions
HonchoMemory
Re-exports HonchoMemory
HonchoClientLike
Re-exports HonchoClientLike
HonchoMemoryOptions
Re-exports HonchoMemoryOptions
StaticToolset
Re-exports StaticToolset
tool
Re-exports tool