Skip to content

toolmark-monorepo / @toolmark/core / ToolContext

Interface: ToolContext ​

Defined in: packages/core/src/tool.ts:74

Per-call context passed to ToolDefinition.run.

Properties ​

caller ​

caller: Caller

Defined in: packages/core/src/tool.ts:80

Who is calling.


callId ​

callId: string

Defined in: packages/core/src/tool.ts:78

Unique id of this call (also the undo key).


files ​

files: object

Defined in: packages/core/src/tool.ts:99

File resolution (D27, spec §8.4) under the registry's files options and limits. Rejects with ToolmarkError('file_rejected') (a { ref } without files.resolve, a URL that is not allowed, a size/type violation, …); a tool that lets it propagate returns refusedfile_rejected with the message.

resolve() ​

resolve(ref): Promise<File>

Parameters ​
ref ​

FileRef

Returns ​

Promise<File>


signal ​

signal: AbortSignal

Defined in: packages/core/src/tool.ts:76

Aborted when the caller cancels or the registry abandons the call.

Methods ​

confirm() ​

confirm(req): Promise<ConfirmOutcome>

Defined in: packages/core/src/tool.ts:90

Ask for confirmation from inside run. human → approved; inline-mode caller → awaits the inline handler; otherwise { approved: false, reason: 'confirmation_unavailable' }. Never throws. While it is open the run's callTimeoutMs deadline is paused (the wait is bounded by confirmExpiryMs instead); an approval with edited input restores the '[redacted]' placeholders of sensitive paths to their real values. A placeholder whose real value cannot be matched unambiguously (array rows deleted, inserted, reordered or edited, or a key restructured) is not restored: the outcome is then { approved: false, reason: 'invalid' }.

Parameters ​

req ​
changes? ​

FieldChange[]

summary ​

string

Returns ​

Promise<ConfirmOutcome>


registerUndo() ​

registerUndo(restore): void

Defined in: packages/core/src/tool.ts:92

Store a restorer for tm.undo(callId).

Parameters ​

restore ​

() => ToolResult<unknown> | Promise<ToolResult<unknown>>

Returns ​

void