ToolResultBlock
Defined in: src/types/messages.ts:310
Tool result content block.
Implements
Section titled “Implements”ToolResultBlockDataJSONSerializable<{toolResult:ToolResultBlockData; }>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ToolResultBlock(data): ToolResultBlock;Defined in: src/types/messages.ts:338
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { toolUseId: string; status: "success" | "error"; content: ToolResultContent[]; error?: Error; } |
data.toolUseId | string |
data.status | "success" | "error" |
data.content | ToolResultContent[] |
data.error? | Error |
Returns
Section titled “Returns”ToolResultBlock
Properties
Section titled “Properties”readonly type: "toolResultBlock";Defined in: src/types/messages.ts:314
Discriminator for tool result content.
toolUseId
Section titled “toolUseId”readonly toolUseId: string;Defined in: src/types/messages.ts:319
The ID of the tool use that this result corresponds to.
Implementation of
Section titled “Implementation of”status
Section titled “status”readonly status: "success" | "error";Defined in: src/types/messages.ts:324
Status of the tool execution.
Implementation of
Section titled “Implementation of”content
Section titled “content”readonly content: ToolResultContent[];Defined in: src/types/messages.ts:329
The content returned by the tool.
Implementation of
Section titled “Implementation of”error?
Section titled “error?”readonly optional error: Error;Defined in: src/types/messages.ts:336
The original error object when status is ‘error’. Available for inspection by hooks, error handlers, and event loop. Tools must wrap non-Error thrown values into Error objects.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): { toolResult: ToolResultBlockData;};Defined in: src/types/messages.ts:352
Serializes the ToolResultBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify(). Note: The error field is not serialized (deferred for future implementation).
Returns
Section titled “Returns”{ toolResult: ToolResultBlockData;}| Name | Type | Defined in |
|---|---|---|
toolResult | ToolResultBlockData | src/types/messages.ts:352 |
Implementation of
Section titled “Implementation of”JSONSerializable.toJSONfromJSON()
Section titled “fromJSON()”static fromJSON(data): ToolResultBlock;Defined in: src/types/messages.ts:368
Creates a ToolResultBlock instance from its wrapped data format.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | { toolResult: ToolResultBlockData; } | Wrapped ToolResultBlockData to deserialize |
data.toolResult | ToolResultBlockData | - |
Returns
Section titled “Returns”ToolResultBlock
ToolResultBlock instance