@agentskit/runtime — Functions
API functions for @agentskit/runtime.
#Function: blackboard()
blackboard<
TContext>(config):AgentHandle<TContext>
Defined in: topologies.ts:233
#Type Parameters
#TContext
TContext = unknown
#Parameters
#config
BlackboardConfig<TContext>
#Returns
AgentHandle<TContext>
#Function: compileFlow()
compileFlow<
TInput>(options):CompiledFlow<TInput>
Defined in: flow.ts:176
#Type Parameters
#TInput
TInput = unknown
#Parameters
#options
CompileFlowOptions<TInput>
#Returns
CompiledFlow<TInput>
#Function: createAuctionHandler()
createAuctionHandler<
Ctx>(opts): (node,input,ctx) =>Promise<TopologyOutcome>
Defined in: multi-agent-auction.ts:59
#Type Parameters
#Ctx
Ctx
#Parameters
#opts
#Returns
(node, input, ctx) => Promise<TopologyOutcome>
#Function: createChatTrigger()
createChatTrigger<
TContext>(options):ChatTrigger
Defined in: chat-trigger.ts:238
Build a unified chat-surface trigger. Wire the returned handler
into your HTTP framework (Express / Hono / Next route handler) at
the surface's webhook URL.
#Type Parameters
#TContext
TContext = unknown
#Parameters
#options
ChatTriggerOptions<TContext>
#Returns
#Function: createCompareHandler()
createCompareHandler<
Ctx>(opts): (node,input,ctx) =>Promise<TopologyOutcome>
Defined in: multi-agent-compare.ts:93
#Type Parameters
#Ctx
Ctx
#Parameters
#opts
#Returns
(node, input, ctx) => Promise<TopologyOutcome>
#Function: createCronScheduler()
createCronScheduler<
TContext>(options):CronScheduler
Defined in: background.ts:154
#Type Parameters
#TContext
TContext = unknown
#Parameters
#options
CronSchedulerOptions<TContext>
#Returns
#Function: createDebateHandler()
createDebateHandler<
Ctx>(opts): (node,input,ctx) =>Promise<TopologyOutcome>
Defined in: multi-agent-debate.ts:12
#Type Parameters
#Ctx
Ctx
#Parameters
#opts
DebateHandlerOptions<Ctx>
#Returns
(node, input, ctx) => Promise<TopologyOutcome>
#Function: createDurableRunner()
createDurableRunner(
options):DurableRunner
Defined in: durable.ts:82
#Parameters
#options
#Returns
#Function: createFileStepLog()
createFileStepLog(
path):Promise<StepLogStore>
Defined in: durable.ts:217
File-backed StepLogStore — persists every step as one JSONL line.
#Parameters
#path
string
#Returns
Promise<StepLogStore>
#Function: createInMemoryStepLog()
createInMemoryStepLog():
StepLogStore
Defined in: durable.ts:192
In-memory StepLogStore — tests, single-process demos, examples.
#Returns
#Function: createQuotaTracker()
createQuotaTracker(
options):QuotaTracker
Defined in: quota.ts:75
#Parameters
#options
#Returns
#Function: createRuntime()
createRuntime(
config):object
Defined in: runner.ts:95
#Parameters
#config
#Returns
object
#run()
run(
task,options?):Promise<RunResult>
#Parameters
task
string
options?
#Returns
Promise<RunResult>
#Function: createSharedContext()
createSharedContext(
initial?):SharedContext
Defined in: shared-context.ts:15
#Parameters
#initial?
Record<string, unknown>
#Returns
#Function: createValidatorGuard()
createValidatorGuard(
options):ValidatorGuard
Defined in: validator-guard.ts:102
#Parameters
#options
#Returns
#Function: createVoteHandler()
createVoteHandler<
Ctx>(opts): (node,input,ctx) =>Promise<TopologyOutcome>
Defined in: multi-agent-vote.ts:105
#Type Parameters
#Ctx
Ctx
#Parameters
#opts
VoteHandlerOptions<Ctx>
#Returns
(node, input, ctx) => Promise<TopologyOutcome>
#Function: createWebhookHandler()
createWebhookHandler<
TContext>(options):WebhookHandler
Defined in: background.ts:262
Build a framework-agnostic webhook handler. Wire into Express / Hono / Next API routes by passing in the parsed request and piping the returned response.
#Type Parameters
#TContext
TContext = unknown
#Parameters
#options
WebhookOptions<TContext>
#Returns
#Function: cronMatches()
cronMatches(
schedule,now):boolean
Defined in: background.ts:135
#Parameters
#schedule
ParsedCron
#now
Date
#Returns
boolean
#Function: denyPattern()
denyPattern(
pattern,name?):Validator
Defined in: validator-guard.ts:201
Regex-deny validator. Fails when the pattern matches.
#Parameters
#pattern
RegExp
#name?
string = 'deny-pattern'
#Returns
#Function: flowToMermaid()
flowToMermaid(
def):string
Defined in: flow.ts:250
Render a FlowDefinition as a Mermaid flowchart TD. Used by the
visual editor's preview pane and by agentskit flow render.
#Parameters
#def
#Returns
string
#Function: hierarchical()
hierarchical<
TContext>(config):AgentHandle<TContext>
Defined in: topologies.ts:189
#Type Parameters
#TContext
TContext = unknown
#Parameters
#config
HierarchicalConfig<TContext>
#Returns
AgentHandle<TContext>
#Function: invokeStructured()
invokeStructured<
T>(opts):Promise<T>
Defined in: structured.ts:22
Run a skill that must produce STRUCTURED output, and return it validated — the
first-class version of the pattern every pipeline agent hand-rolls (offer one
submit_* tool, run, read it back from result.toolCalls, parse).
The model's only job is to call tool once; execute just acknowledges. The
parse callback validates the args (e.g. (a) => MySchema.parse(a) with Zod) so
this stays dependency-free — the runtime never imports Zod.
const cls = await invokeStructured({
adapter, skill: classifier, task,
tool: submitClassificationTool,
parse: (args) => Classification.parse(args),
})#Type Parameters
#T
T
#Parameters
#opts
#adapter
AdapterFactory
#maxSteps?
number
#memory?
ChatMemory
#observers?
Observer[]
#onConfirm?
(toolCall) => boolean | Promise<boolean>
#parse
(args) => T
Validate + shape the tool args (throws on invalid).
#signal?
AbortSignal
#skill?
SkillDefinition
#task
string
#tool
ToolDefinition
The submit tool the skill must call exactly once.
#tools?
ToolDefinition<Record<string, unknown>>[]
Extra tools available during the run (besides tool).
#Returns
Promise<T>
#Function: isJson()
isJson(
options?):Validator
Defined in: validator-guard.ts:231
JSON-parse validator. Fails when the output is not valid JSON.
#Parameters
#options?
#maxRetries?
number
#name?
string
#repairPrompt?
string
#Returns
#Function: lengthRange()
lengthRange(
options):Validator
Defined in: validator-guard.ts:218
Length-bounds validator. Useful for token-budget guarantees.
#Parameters
#options
#max?
number
#min?
number
#name?
string
#Returns
#Function: parseSchedule()
parseSchedule(
schedule):ParsedSchedule
Defined in: background.ts:102
#Parameters
#schedule
string
#Returns
ParsedSchedule
#Function: piiDenyValidator()
piiDenyValidator(
opts?):Validator
Defined in: pii-validator.ts:18
A Validator that FAILS when the agent's output still contains PII — the bridge
between @agentskit/core/security's redactor and the createValidatorGuard chain.
Use it as a deterministic last-line gate on agents that must not leak PII
(redaction, summarization, anything exporting cross-tenant), instead of trusting
the system prompt to do it.
import { createValidatorGuard, piiDenyValidator } from '@agentskit/runtime'
const guard = createValidatorGuard({ validators: [piiDenyValidator()] })Default onFail: 'block' — a PII leak is not something to silently retry past.
#Parameters
#opts?
#name?
string
#onFail?
#rules?
PIIRule[]
#Returns
#Function: resolveConcurrency()
resolveConcurrency(
limit):number
Defined in: multi-agent.ts:133
Resolve a concurrency limit from optional opts, falling back to the default.
#Parameters
#limit
number | undefined
#Returns
number
#Function: settleWithConcurrency()
settleWithConcurrency<
I,T>(items,limit,fn):Promise<PromiseSettledResult<T>[]>
Defined in: multi-agent.ts:40
Run fn over items with at most limit calls in flight at once, returning
a PromiseSettledResult per item in input order — a concurrency-bounded
drop-in for Promise.allSettled(items.map(fn)).
#Type Parameters
#I
I
#T
T
#Parameters
#items
readonly I[]
#limit
number
#fn
(item, index) => Promise<T>
#Returns
Promise<PromiseSettledResult<T>[]>
#Function: speculate()
speculate(
input):Promise<SpeculateOutput>
Defined in: speculate.ts:86
Fan out a request to N adapters in parallel, then pick the winner. Common pattern: run a cheap+fast model alongside a slow+accurate one and take whichever finishes first, or use a custom picker to score results (e.g. pick longest, most-on-topic, lowest cost).
#Parameters
#input
#Returns
Promise<SpeculateOutput>
#Function: supervisor()
supervisor<
TContext>(config):AgentHandle<TContext>
Defined in: topologies.ts:46
#Type Parameters
#TContext
TContext = unknown
#Parameters
#config
SupervisorConfig<TContext>
#Returns
AgentHandle<TContext>
#Function: swarm()
swarm<
TContext>(config):AgentHandle<TContext>
Defined in: topologies.ts:129
#Type Parameters
#TContext
TContext = unknown
#Parameters
#config
SwarmConfig<TContext>
#Returns
AgentHandle<TContext>
#Function: validateFlow()
validateFlow(
def,registry?):FlowValidationResult
Defined in: flow.ts:67
#Parameters
#def
#registry?
FlowRegistry<unknown>
#Returns
#Function: withQuotas()
withQuotas(
tools,tracker,runIdFor?):ToolDefinition<Record<string,unknown>>[]
Defined in: quota.ts:239
Wrap a list of tools so every execute call is gated by the quota
tracker. Drop-in replacement for the raw tool array passed to
createRuntime(\{ tools \}).
#Parameters
#tools
ToolDefinition<Record<string, unknown>>[]
#tracker
#runIdFor?
(context) => string
#Returns
ToolDefinition<Record<string, unknown>>[]