Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ”¨ chore: add `tool_execute` / `tool_result` protocol types (#13762)

Arvin Xu12bbc56db3ea
diff --git a/src/libs/agent-stream/types.ts b/src/libs/agent-stream/types.ts
index bf2216ff1d9..d2eb9ba849b 100644
--- a/src/libs/agent-stream/types.ts
+++ b/src/libs/agent-stream/types.ts
@@ -9,6 +9,7 @@ export type AgentStreamEventType =
| 'stream_retry'
| 'tool_start'
| 'tool_end'
+ | 'tool_execute'
| 'step_start'
| 'step_complete'
| 'error';
@@ -71,6 +72,22 @@ export interface StepCompleteData {
reasonDetail?: string;
}
+/**
+ * Server β†’ Client: request the client to execute a tool locally and return the result.
+ */
+export interface ToolExecuteData {
+ /** Tool function name (e.g. "readFile"). */
+ apiName: string;
+ /** JSON-encoded argument string as returned by the LLM. */
+ arguments: string;
+ /** Per-invocation deadline. Server caps against its own function budget. */
+ executionTimeoutMs: number;
+ /** Tool plugin identifier (e.g. "local-system"). */
+ identifier: string;
+ /** Unique tool call id; used as the correlation key for the returned result. */
+ toolCallId: string;
+}
+
// ─── WebSocket Protocol Messages ───
// Client β†’ Server
@@ -92,7 +109,27 @@ export interface InterruptMessage {
type: 'interrupt';
}
-export type ClientMessage = AuthMessage | HeartbeatMessage | InterruptMessage | ResumeMessage;
+/**
+ * Client β†’ Server: tool execution result, correlated by toolCallId.
+ */
+export interface ToolResultMessage {
+ content: string | null;
+ error?: {
+ message: string;
+ type?: string;
+ };
+ state?: any;
+ success: boolean;
+ toolCallId: string;
+ type: 'tool_result';
+}
+
+export type ClientMessage =
+ | AuthMessage
+ | HeartbeatMessage
+ | InterruptMessage
+ | ResumeMessage
+ | ToolResultMessage;
// Server β†’ Client
export interface AuthSuccessMessage {