ToolDefinition
A tool as you write it: its spec (minus id, which is its key in tools) plus the code behind it.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
F extends readonly ToolField[] |
readonly ToolField[] |
A extends readonly ToolAction[] |
readonly ToolAction[] |
Properties
Section titled “Properties”actions?
Section titled “actions?”
optionalactions?:A
category?
Section titled “category?”
optionalcategory?:ToolCategory
clipboardKinds?
Section titled “clipboardKinds?”
optionalclipboardKinds?: readonlyClipboardKind[]
dropActions?
Section titled “dropActions?”
optionaldropActions?: readonlyToolDropAction[]
fields?
Section titled “fields?”
optionalfields?:F
icon:
string
SF Symbol name.
optionallive?:boolean
remembersInputs?
Section titled “remembersInputs?”
optionalremembersInputs?:boolean
summary?
Section titled “summary?”
optionalsummary?:string
One line: what it does for you.
title:
string
One or two short words: it sits under an icon in the tray.
Methods
Section titled “Methods”drop()?
Section titled “drop()?”
optionaldrop(action,files,ctx):Promise<ToolDropResult>
Runs one of dropActions on dropped files (absolute paths). Required when dropActions is set.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
action |
string |
files |
string[] |
ctx |
ToolContext |
Returns
Section titled “Returns”Promise<ToolDropResult>
run(
action,values,ctx):Promise<ToolBlock[]>
Runs one of actions. Return the output blocks; throw an Error whose message
says what went wrong and what to do (“Can’t reach npm. Check your connection.”)
and Blipbar shows it as a failed status.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
action |
A[number]["id"] |
values |
ToolValues<F> |
ctx |
ToolContext |
Returns
Section titled “Returns”Promise<ToolBlock[]>