ui: Refactor Built-In Tools naming (Server/Browser) (#27271)

* server: rename built-in tools to server tools

* ui: rename built-in tools to server/browser tools
This commit is contained in:
Aleksander Grygier
2026-08-17 22:23:22 +02:00
committed by GitHub
parent 058df671b2
commit 0021a77de0
49 changed files with 315 additions and 286 deletions
+3 -3
View File
@@ -262,9 +262,9 @@ export { ParameterSyncService } from './parameter-sync.service';
export { MCPService } from './mcp.service';
/**
* **SandboxService** - Frontend JavaScript execution in a browser sandbox
* **SandboxService** - Browser JavaScript execution in a browser sandbox
*
* Stateless executor for the run_javascript frontend tool. Model generated
* Stateless executor for the run_javascript browser tool. Model generated
* code runs in a Web Worker spawned inside a sandboxed iframe with an opaque
* origin: no access to the app origin, its storage or its API, and outgoing
* requests carry a null origin. The code never touches a main thread, so the
@@ -274,7 +274,7 @@ export { MCPService } from './mcp.service';
* **Architecture & Relationships:**
* - **SandboxService** (this class): Stateless sandbox execution
* - **toolsStore**: Exposes the tool definition when the sandbox is enabled
* - **agenticStore**: Dispatches ToolSource.FRONTEND calls here
* - **agenticStore**: Dispatches ToolSource.BROWSER calls here
*
* @see buildSandboxToolDefinition in utils/sandbox-tool - tool schema sent to the LLM
* @see agenticStore in stores/agentic.svelte.ts - tool dispatch
@@ -28,15 +28,15 @@ function fileExtension(path: string): string {
}
/**
* **ReadMediaService** - frontend executor for the `read_media` tool
* **ReadMediaService** - browser executor for the `read_media` tool
*
* The tool is synthetic: no such tool exists on the server. It reads the file
* through the built-in `read_file` tool with the `base64` response type, then
* through the server `read_file` tool with the `base64` response type, then
* turns the bytes into a data URI line. The agentic store lifts that line into
* an image or audio attachment on the tool result message, which is what makes
* the model perceive the file instead of reading a wall of base64.
*
* Living in the frontend is what lets it exist only for models that can
* Living in the browser is what lets it exist only for models that can
* actually use the result - the server has no idea which model is selected.
*
* @see buildReadMediaToolDefinition in constants/read-media.ts - tool schema sent to the LLM
@@ -82,7 +82,7 @@ export class ReadMediaService {
}
const raw = await ToolsService.executeToolRaw(
BuiltInTool.READ_FILE,
BuiltInTool.SERVER_READ_FILE,
{ path },
signal,
cwd,
+2 -2
View File
@@ -68,7 +68,7 @@ function formatReply(reply: SandboxReply): ToolExecutionResult {
export class SandboxService {
/**
* Execute a frontend sandbox tool call and return its output.
* Execute a browser sandbox tool call and return its output.
* One disposable iframe per execution, removed on completion,
* timeout or abort. Removing the iframe terminates the worker
* at the browser level, so runaway code cannot outlive it.
@@ -79,7 +79,7 @@ export class SandboxService {
signal?: AbortSignal
): Promise<ToolExecutionResult> {
if (toolName !== SANDBOX_TOOL_NAME) {
return { content: `Unknown frontend tool: ${toolName}`, isError: true };
return { content: `Unknown browser tool: ${toolName}`, isError: true };
}
const code = typeof params.code === 'string' ? params.code : '';
+7 -7
View File
@@ -1,23 +1,23 @@
import { base } from '$app/paths';
import { API_TOOLS, HEADERS } from '$lib/constants';
import { ToolResponseField } from '$lib/enums';
import type { ServerBuiltinToolInfo, ToolExecutionResult } from '$lib/types';
import type { ServerToolInfo, ToolExecutionResult } from '$lib/types';
import { apiFetch } from '$lib/utils';
import { getJsonHeaders } from '$lib/utils/api-headers';
import { parseSseJsonStream, type SseJsonEvent } from '$lib/utils/sse';
export class ToolsService {
/**
* Fetch the list of built-in tools from the server.
* Fetch the list of server tools from the server.
*
* @returns Array of tool definitions in OpenAI-compatible format
*/
static async list(): Promise<ServerBuiltinToolInfo[]> {
return apiFetch<ServerBuiltinToolInfo[]>(API_TOOLS.LIST);
static async list(): Promise<ServerToolInfo[]> {
return apiFetch<ServerToolInfo[]>(API_TOOLS.LIST);
}
/**
* Execute a built-in tool on the server.
* Execute a server tool on the server.
*
* @param cwd - Working directory for the tool call, sent as the
* x-tool-cwd request header. The server resolves relative paths
@@ -48,7 +48,7 @@ export class ToolsService {
}
/**
* Execute a built-in tool and return the raw JSON response. Unlike
* Execute a server tool and return the raw JSON response. Unlike
* executeTool, this preserves structured fields (e.g. file_glob_search's
* `entries` and `base`) that the flattened ToolExecutionResult drops.
*
@@ -77,7 +77,7 @@ export class ToolsService {
}
/**
* Stream a built-in tool's output chunks from the server. The server
* Stream a server tool's output chunks from the server. The server
* `POST /tools` endpoint with `{stream: true}` emits `data: {"chunk": "..."}`
* events followed by a terminal `data: {"done": true}` (optionally with
* `error`). Yields the chunk string for each partial event.