@toolcog/runtime
Toolcog runtime
Classes
AgentContext
Extends
Constructors
new AgentContext()
new AgentContext(
parent
,options
?):AgentContext
Parameters
• parent: null
| AgentContext
= null
• options?: AgentContextOptions
Returns
Overrides
Defined in
Properties
error
readonly
static
error: typeoferror
Inherited from
Defined in
errorMonitor
readonly
static
errorMonitor: typeoferrorMonitor
Inherited from
Defined in
Accessors
messages
get
messages(): readonlyMessage
[]
Returns
readonly Message
[]
Defined in
parent
get
parent():null
|AgentContext
Returns
null
| AgentContext
Defined in
query
get
query():undefined
|string
Returns
undefined
| string
Defined in
tools
get
tools(): readonlyToolSource
[]
Returns
readonly ToolSource
[]
Defined in
Methods
addListener()
addListener<
Event
>(event
,listener
,options
?):this
Type Parameters
• Event extends keyof AgentContextEvents
Parameters
• event: Event
• listener: EmitListener
<AgentContextEvents
[Event
]>
• options?: EmitListenerOptions
Returns
this
Inherited from
Defined in
addMessage()
addMessage(
message
):void
Parameters
• message: Message
Returns
void
Defined in
clear()
clear():
void
Returns
void
Defined in
emit()
emit<
Event
>(event
, …args
):boolean
Type Parameters
• Event extends keyof AgentContextEvents
Parameters
• event: Event
• …args: AgentContextEvents
[Event
]
Returns
boolean
Inherited from
Defined in
events()
events():
IterableIterator
<keyofAgentContextEvents
,any
,any
>
Returns
IterableIterator
<keyof AgentContextEvents
, any
, any
>
Inherited from
Defined in
listeners()
listeners<
Event
>(event
):IterableIterator
<EmitListener
<AgentContextEvents
[Event
]>,any
,any
>
Type Parameters
• Event extends keyof AgentContextEvents
Parameters
• event: Event
Returns
IterableIterator
<EmitListener
<AgentContextEvents
[Event
]>, any
, any
>
Inherited from
Defined in
on()
on<
Event
>(event
,options
?):AsyncIterableIterator
<AgentContextEvents
[Event
],any
,any
>
Type Parameters
• Event extends keyof AgentContextEvents
Parameters
• event: Event
• options?: EmitAsyncOptions
Returns
AsyncIterableIterator
<AgentContextEvents
[Event
], any
, any
>
Inherited from
Defined in
once()
once<
Event
>(event
,options
?):Promise
<AgentContextEvents
[Event
]>
Type Parameters
• Event extends keyof AgentContextEvents
Parameters
• event: Event
• options?: EmitAsyncOptions
Returns
Promise
<AgentContextEvents
[Event
]>
Inherited from
Defined in
removeListener()
removeListener<
Event
>(event
,listener
,options
?):this
Type Parameters
• Event extends keyof AgentContextEvents
Parameters
• event: Event
• listener: EmitListener
<AgentContextEvents
[Event
]>
• options?: EmitListenerOptions
Returns
this
Inherited from
Defined in
setQuery()
setQuery(
query
):void
Parameters
• query: undefined
| string
Returns
void
Defined in
spawn()
spawn(
options
?):AgentContext
Parameters
• options?: AgentContextOptions
Returns
Defined in
useTool()
useTool<
T
>(tool
):T
Type Parameters
• T extends ToolSource
Parameters
• tool: T
Returns
T
Defined in
useTools()
useTools<
T
>(tools
):T
Type Parameters
• T extends readonly ToolSource
[]
Parameters
• tools: T
Returns
T
Defined in
create()
static
create(options
?):AgentContext
Parameters
• options?: AgentContextOptions
Returns
Defined in
current()
static
current():AgentContext
Returns
Defined in
get()
static
get():null
|AgentContext
Returns
null
| AgentContext
Defined in
getOrCreate()
static
getOrCreate(options
?):AgentContext
Parameters
• options?: AgentContextOptions
Returns
Defined in
run()
static
run<F
>(context
,func
, …args
):ReturnType
<F
>
Type Parameters
• F extends (…args
) => unknown
Parameters
• context: undefined
| null
| AgentContext
• func: F
• …args: Parameters
<F
>
Returns
ReturnType
<F
>
Defined in
spawn()
static
spawn<R
>(options
,func
):R
Type Parameters
• R
Parameters
• options: undefined
| AgentContextOptions
• func
Returns
R
Defined in
Job
Extends
Constructors
new Job()
new Job(
parent
,info
?):Job
Parameters
• parent: null
| Job
= null
• info?: JobInfo
Returns
Overrides
Defined in
Properties
error
readonly
static
error: typeoferror
Inherited from
Defined in
errorMonitor
readonly
static
errorMonitor: typeoferrorMonitor
Inherited from
Defined in
Accessors
childCount
get
childCount():number
Returns
number
Defined in
depth
get
depth():number
Returns
number
Defined in
descendantCount
get
descendantCount():number
Returns
number
Defined in
ellipsize
get
ellipsize():undefined
|number
Returns
undefined
| number
Defined in
finished
get
finished():boolean
Returns
boolean
Defined in
firstChild
get
firstChild():null
|Job
Returns
null
| Job
Defined in
lastChild
get
lastChild():null
|Job
Returns
null
| Job
Defined in
nextSibling
get
nextSibling():null
|Job
Returns
null
| Job
Defined in
output
get
output():undefined
|string
Returns
undefined
| string
Defined in
outputType
get
outputType():JobOutputType
Returns
Defined in
parent
get
parent():null
|Job
Returns
null
| Job
Defined in
prevSibling
get
prevSibling():null
|Job
Returns
null
| Job
Defined in
root
get
root():Job
Returns
Defined in
title
get
title():undefined
|string
Returns
undefined
| string
Defined in
Methods
addListener()
addListener<
Event
>(event
,listener
,options
?):this
Type Parameters
• Event extends keyof JobEvents
Parameters
• event: Event
• listener: EmitListener
<JobEvents
[Event
]>
• options?: EmitListenerOptions
Returns
this
Inherited from
Defined in
children()
children(
startIndex
):Iterable
<Job
,any
,any
>
Parameters
• startIndex: number
= 0
Returns
Iterable
<Job
, any
, any
>
Defined in
descendants()
descendants(
startIndex
):Iterable
<Job
,any
,any
>
Parameters
• startIndex: number
= 0
Returns
Iterable
<Job
, any
, any
>
Defined in
emit()
emit<
Event
>(event
, …args
):boolean
Type Parameters
• Event extends keyof JobEvents
Parameters
• event: Event
• …args: JobEvents
[Event
]
Returns
boolean
Inherited from
Defined in
events()
events():
IterableIterator
<keyofJobEvents
,any
,any
>
Returns
IterableIterator
<keyof JobEvents
, any
, any
>
Inherited from
Defined in
finish()
finish(
info
?):void
Parameters
• info?: string
| JobInfo
Returns
void
Defined in
fork()
fork(
info
?):Job
Parameters
• info?: JobInfo
Returns
Defined in
listeners()
listeners<
Event
>(event
):IterableIterator
<EmitListener
<JobEvents
[Event
]>,any
,any
>
Type Parameters
• Event extends keyof JobEvents
Parameters
• event: Event
Returns
IterableIterator
<EmitListener
<JobEvents
[Event
]>, any
, any
>
Inherited from
Defined in
on()
on<
Event
>(event
,options
?):AsyncIterableIterator
<JobEvents
[Event
],any
,any
>
Type Parameters
• Event extends keyof JobEvents
Parameters
• event: Event
• options?: EmitAsyncOptions
Returns
AsyncIterableIterator
<JobEvents
[Event
], any
, any
>
Inherited from
Defined in
once()
once<
Event
>(event
,options
?):Promise
<JobEvents
[Event
]>
Type Parameters
• Event extends keyof JobEvents
Parameters
• event: Event
• options?: EmitAsyncOptions
Returns
Promise
<JobEvents
[Event
]>
Inherited from
Defined in
removeListener()
removeListener<
Event
>(event
,listener
,options
?):this
Type Parameters
• Event extends keyof JobEvents
Parameters
• event: Event
• listener: EmitListener
<JobEvents
[Event
]>
• options?: EmitListenerOptions
Returns
this
Inherited from
Defined in
update()
update(
info
):void
Parameters
• info: string
| JobInfo
Returns
void
Defined in
get()
static
get():null
|Job
Returns
null
| Job
Defined in
run()
static
run<F
>(job
,func
, …args
):ReturnType
<F
>
Type Parameters
• F extends (…args
) => unknown
Parameters
• job: undefined
| null
| Job
• func: F
• …args: Parameters
<F
>
Returns
ReturnType
<F
>
Defined in
spawn()
static
spawn<R
>(info
,func
):Promise
<Awaited
<R
>>
Type Parameters
• R
Parameters
• info: undefined
| string
| JobInfo
• func
Returns
Promise
<Awaited
<R
>>
Defined in
Runtime
Constructors
new Runtime()
new Runtime(
config
?):Runtime
Parameters
• config?: RuntimeConfig
Returns
Defined in
Accessors
embedderConfig
get
embedderConfig():EmbedderConfig
Returns
Defined in
generatorConfig
get
generatorConfig():GeneratorConfig
Returns
Defined in
indexerConfig
get
indexerConfig():IndexerConfig
Returns
Defined in
inventory
get
inventory():Inventory
<Float32Array
>
Returns
Inventory
<Float32Array
>
Defined in
plugins
get
plugins():Plugin
[]
Returns
Plugin
[]
Defined in
Methods
embed()
embed<
T
>(texts
,options
?):Promise
<Embedded
<T
>>
Type Parameters
• T extends string
| readonly string
[]
Parameters
• texts: T
• options?: EmbedderOptions
Returns
Promise
<Embedded
<T
>>
Defined in
embedder()
embedder(
options
?):Promise
<Embedder
>
Parameters
• options?: EmbedderOptions
Returns
Promise
<Embedder
>
Defined in
embedderOptions()
embedderOptions(
options
):EmbedderOptions
Parameters
• options: undefined
| EmbedderOptions
Returns
Defined in
generate()
generate(
args
,options
?):Promise
<unknown
>
Parameters
• args: unknown
• options?: GeneratorOptions
Returns
Promise
<unknown
>
Defined in
generator()
generator(
options
?):Promise
<Generator
>
Parameters
• options?: GeneratorOptions
Returns
Promise
<Generator
>
Defined in
generatorOptions()
generatorOptions(
options
):GeneratorOptions
Parameters
• options: undefined
| GeneratorOptions
Returns
Defined in
index()
index<
T
>(idioms
,options
?):Promise
<Index
<T
>>
Type Parameters
• T extends readonly unknown
[]
Parameters
• idioms: Idioms
<T
>
• options?: IndexerOptions
Returns
Promise
<Index
<T
>>
Defined in
indexer()
indexer(
options
):Promise
<Indexer
>
Parameters
• options: IndexerOptions
Returns
Promise
<Indexer
>
Defined in
indexerOptions()
indexerOptions(
options
):IndexerOptions
Parameters
• options: undefined
| IndexerOptions
Returns
Defined in
resolveIdiom()
resolveIdiom(
id
,value
):undefined
|Embeddings
<Float32Array
>
Parameters
• id: string
• value: unknown
Returns
undefined
| Embeddings
<Float32Array
>
Defined in
create()
static
create(config
?):Promise
<Runtime
>
Parameters
• config?: RuntimeConfigSource
Returns
Promise
<Runtime
>
Defined in
current()
static
current():Runtime
Returns
Defined in
get()
static
get():null
|Runtime
Returns
null
| Runtime
Defined in
resolveConfig()
static
resolveConfig(config
?):Promise
<RuntimeConfig
>
Parameters
• config?: RuntimeConfigSource
Returns
Promise
<RuntimeConfig
>
Defined in
run()
static
run<F
>(runtime
,func
, …args
):ReturnType
<F
>
Type Parameters
• F extends (…args
) => unknown
Parameters
• runtime: undefined
| null
| Runtime
• func: F
• …args: Parameters
<F
>
Returns
ReturnType
<F
>
Defined in
systemPrompt()
static
systemPrompt():string
Returns
string
Defined in
Interfaces
AgentContextOptions
Properties
messages?
optional
messages:Message
[]
Defined in
tools?
optional
tools:ToolSource
[]
Defined in
AssistantMessage
A chat message from an assistant to a user.
Properties
content
readonly
content:string
| readonlyAssistantBlock
[]
The content of the message, either a string or an array of content blocks.
Defined in
role
readonly
role:"assistant"
Identifies this as a message coming from the assistant.
Defined in
IdiomDef
Properties
embeds
embeds:
string
[]
Defined in
IdiomInventory<V>
Type Parameters
• V = EmbeddingVector
Properties
embeddings
embeddings:
Embeddings
<V
>
Defined in
ImageBlock
A content block containing an image.
Properties
source
readonly
source:string
The URL of the image.
Defined in
type
readonly
type:"image"
Identifies this as an image content block.
Defined in
IndexDef
Properties
idioms
idioms:
string
[]
Defined in
Inventory<V>
Type Parameters
• V = EmbeddingVector
Properties
embeddingModels
embeddingModels:
string
&object
[]
Defined in
idioms
idioms:
object
Index Signature
[idiomId
: string
]: IdiomInventory
<V
>
Defined in
JobInfo
Properties
ellipsize?
optional
ellipsize:number
Defined in
output?
optional
output:string
Defined in
outputType?
optional
outputType:JobOutputType
Defined in
title?
optional
title:string
Defined in
Manifest
Properties
modules
modules:
object
Index Signature
[moduleId
: string
]: ModuleDef
Defined in
ModuleDef
Properties
idioms
idioms:
object
Index Signature
[idiomId
: string
]: IdiomDef
Defined in
indexes
indexes:
object
Index Signature
[indexId
: string
]: IndexDef
Defined in
prompts
prompts:
object
Index Signature
[promptId
: string
]: PromptDef
Defined in
tools
tools:
object
Index Signature
[toolId
: string
]: ToolDef
Defined in
Plugin
Properties
embedder()?
readonly
optional
embedder: (options
?) =>Promise
<undefined
|Embedder
>
Parameters
• options?: EmbedderOptions
Returns
Promise
<undefined
| Embedder
>
Defined in
generator()?
readonly
optional
generator: (options
?) =>Promise
<undefined
|Generator
>
Parameters
• options?: GeneratorOptions
Returns
Promise
<undefined
| Generator
>
Defined in
indexer()?
readonly
optional
indexer: (options
) =>Promise
<undefined
|Indexer
>
Parameters
• options: IndexerOptions
Returns
Promise
<undefined
| Indexer
>
Defined in
name
readonly
name:string
Defined in
version?
readonly
optional
version:string
Defined in
Precache<V>
Type Parameters
• V = EmbeddingVector
Properties
embeddings
embeddings:
Embeddings
<V
>
Defined in
PrefetchInventoryOptions
Properties
embedder?
optional
embedder:Embedder
Defined in
embeddingModels?
optional
embeddingModels:string
&object
[]
Defined in
precache?
optional
precache:Precache
<Float32Array
>
Defined in
PromptDef
Properties
description?
optional
description:string
Defined in
instructions
instructions:
undefined
|string
Defined in
name?
optional
name:string
Defined in
parameters?
optional
parameters:Schema
Defined in
returns?
optional
returns:Schema
Defined in
RefusalBlock
A content block containing a refusal message.
Properties
refusal
readonly
refusal:string
The stated reason for the refusal.
Defined in
type
readonly
type:"refusal"
Identifies this as a refusal content block.
Defined in
RequestBlock
A content block containing a tool request.
Properties
arguments
readonly
arguments:unknown
The arguments to the tool function.
Defined in
id
readonly
id:string
A unique identifier for this tool request.
Defined in
name
readonly
name:string
The name of the tool to invoke.
Defined in
type
readonly
type:"request"
Identifies this as a tool request content block.
Defined in
ResponseBlock
A content block containing a tool response.
Properties
id
readonly
id:string
The unique identifier of the tool request.
Defined in
result
readonly
result:string
The return value of the tool function.
Defined in
type
readonly
type:"response"
Identifies this as a tool response content block.
Defined in
RuntimeConfig
Properties
embedder?
optional
embedder:EmbedderConfig
Defined in
generator?
optional
generator:GeneratorConfig
Defined in
indexer?
optional
indexer:IndexerConfig
Defined in
inventory?
optional
inventory:Inventory
<Float32Array
>
Defined in
plugins?
optional
plugins:null
|Plugin
[]
Defined in
RuntimeConfigSource
Properties
embedder?
optional
embedder:EmbedderConfig
Defined in
generator?
optional
generator:GeneratorConfig
Defined in
indexer?
optional
indexer:IndexerConfig
Defined in
inventory?
optional
inventory:InventorySource
Defined in
plugins?
optional
plugins:null
|PluginSource
[]
Defined in
TextBlock
A content block containing text.
Properties
text
readonly
text:string
The text content for this block.
Defined in
type
readonly
type:"text"
Identifies this as a text content block.
Defined in
ToolDef
Properties
description?
optional
description:string
Defined in
name?
optional
name:string
Defined in
parameters?
optional
parameters:Schema
Defined in
returns?
optional
returns:Schema
Defined in
UserMessage
A chat message from a user to an assistant.
Properties
content
readonly
content:string
| readonlyUserBlock
[]
The content of the message, either a string or an array of content blocks.
Defined in
role
readonly
role:"user"
Identifies this as a message coming from the user.
Defined in
Type Aliases
AgentContextEvents
AgentContextEvents:
object
Type declaration
message
message: [
Message
,AgentContext
]
spawn
spawn: [
AgentContext
,AgentContext
]
useTool
useTool: [
ToolSource
,AgentContext
]
Defined in
AssistantBlock
AssistantBlock:
TextBlock
|RefusalBlock
|RequestBlock
A content block in a message from an assistant to a user.
Defined in
InventorySource
InventorySource: () =>
Promise
<Inventory
|undefined
> |Inventory
|undefined
|Promise
<Inventory
|undefined
> |Inventory
|string
|boolean
|undefined
Defined in
JobEvents
JobEvents:
object
Type declaration
finish
finish: [
Job
]
fork
update
update: [
Job
]
Defined in
JobOutputType
JobOutputType:
"text"
|"markdown"
|"json"
Defined in
Message
Message:
UserMessage
|AssistantMessage
A chat message between a user and an assistant.
Defined in
MessageBlock
MessageBlock:
UserBlock
|AssistantBlock
A content block in a message between a user and an assistant.
Defined in
PluginSource
PluginSource: () =>
Promise
<Plugin
|undefined
> |Plugin
|undefined
|Promise
<Plugin
|undefined
> |Plugin
|undefined
Defined in
UserBlock
UserBlock:
TextBlock
|ImageBlock
|ResponseBlock
A content block in a message from a user to an assistant.
Defined in
Variables
inventoryFileName
const
inventoryFileName:"toolcog-inventory.yaml"
="toolcog-inventory.yaml"
Defined in
manifestFileName
const
manifestFileName:"toolcog-manifest.yaml"
="toolcog-manifest.yaml"
Defined in
precacheFileName
const
precacheFileName:".toolcog/precache.yaml"
=".toolcog/precache.yaml"
Defined in
Functions
cosineDistance()
cosineDistance(
a
,b
):number
Parameters
• a: Float32Array
• b: Float32Array
Returns
number
Defined in
createInventory()
createInventory():
Inventory
<Float32Array
>
Returns
Inventory
<Float32Array
>
Defined in
createManifest()
createManifest():
Manifest
Returns
Defined in
createModuleDef()
createModuleDef():
ModuleDef
Returns
Defined in
createPrecache()
createPrecache():
Precache
<Float32Array
>
Returns
Precache
<Float32Array
>
Defined in
currentQuery()
currentQuery():
undefined
|string
Returns
undefined
| string
Defined in
currentTools()
currentTools(): readonly
ToolSource
[]
Returns
readonly ToolSource
[]
Defined in
embed()
embed<
T
>(embed
,options
?):Promise
<Embedded
<T
>>
Type Parameters
• T extends string
| readonly string
[]
Parameters
• embed: T
• options?: EmbedderOptions
Returns
Promise
<Embedded
<T
>>
Defined in
formatInventory()
formatInventory(
cache
):string
Parameters
• cache: Inventory
<Float32Array
>
Returns
string
Defined in
formatManifest()
formatManifest(
manifest
):string
Parameters
• manifest: Manifest
Returns
string
Defined in
formatPrecache()
formatPrecache(
cache
):string
Parameters
• cache: Precache
<Float32Array
>
Returns
string
Defined in
generate()
generate(
args
,options
?):Promise
<unknown
>
Parameters
• args: unknown
• options?: GeneratorOptions
Returns
Promise
<unknown
>
Defined in
index()
index<
T
>(idioms
,options
?):Promise
<Index
<T
>>
Type Parameters
• T extends readonly unknown
[]
Parameters
• idioms: Idioms
<T
>
• options?: IndexerOptions
Returns
Promise
<Index
<T
>>
Defined in
indexer()
indexer<
T
>(idioms
,indexerOptions
?):Promise
<Index
<T
>>
Type Parameters
• T extends readonly unknown
[]
Parameters
• idioms: Idioms
<T
>
• indexerOptions?: IndexerOptions
Returns
Promise
<Index
<T
>>
Defined in
parseInventory()
parseInventory(
yaml
):Inventory
<Float32Array
>
Parameters
• yaml: string
Returns
Inventory
<Float32Array
>
Defined in
parseManifest()
parseManifest(
yaml
):Manifest
Parameters
• yaml: string
Returns
Defined in
parsePrecache()
parsePrecache(
yaml
):Precache
<Float32Array
>
Parameters
• yaml: string
Returns
Precache
<Float32Array
>
Defined in
prefetchInventory()
prefetchInventory(
manifest
,options
?):Promise
<Inventory
<Float32Array
>>
Parameters
• manifest: Manifest
• options?: PrefetchInventoryOptions
Returns
Promise
<Inventory
<Float32Array
>>
Defined in
resolveIdiom()
resolveIdiom(
id
,value
):undefined
|Embeddings
<Float32Array
>
Parameters
• id: string
• value: unknown
Returns
undefined
| Embeddings
<Float32Array
>
Defined in
resolveInventory()
resolveInventory(
inventory
):Promise
<undefined
|Inventory
<Float32Array
>>
Parameters
• inventory: InventorySource
Returns
Promise
<undefined
| Inventory
<Float32Array
>>
Defined in
resolveManifestFile()
resolveManifestFile(
ts
,compilerOptions
,getCommonSourceDirectory
,fileName
):undefined
|string
Parameters
• ts: __module
• compilerOptions: CompilerOptions
• getCommonSourceDirectory
• fileName: string
= manifestFileName
Returns
undefined
| string
Defined in
resolvePlugin()
resolvePlugin(
plugin
):Promise
<undefined
|Plugin
>
Parameters
• plugin: PluginSource
Returns
Promise
<undefined
| Plugin
>
Defined in
resolvePlugins()
resolvePlugins(
plugins
):Promise
<null
|Plugin
[]>
Parameters
• plugins: undefined
| null
| readonly PluginSource
[]
Returns
Promise
<null
| Plugin
[]>
Defined in
useTool()
useTool<
T
>(tool
):T
Type Parameters
• T extends ToolSource
Parameters
• tool: T
Returns
T
Defined in
useTools()
useTools<
T
>(tools
):T
Type Parameters
• T extends readonly ToolSource
[]
Parameters
• tools: T
Returns
T