UNPKG

@tanstack/ai

Version:

Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.

42 lines (41 loc) • 1.24 kB
//#region src/tools/computer-use.ts var ENVIRONMENTS = [ "browser", "linux", "mac", "windows" ]; function isEnvironment(value) { return ENVIRONMENTS.includes(value); } /** * Read the portable computer-use metadata from a tool. * * Native provider tools use namespaced kinds (for example * `anthropic.computer_use`), so they return `undefined`. * * @param tool - Any tool from the chat tool list. * @returns The metadata, or `undefined` when the tool is not a portable * computer-use tool. */ function getComputerUseToolMetadata(tool) { const metadata = tool.metadata; if (metadata?.["__kind"] !== "computer_use") return void 0; const { display, environment, capabilities } = metadata; if (!(typeof display?.width === "number" && typeof display?.height === "number" && isEnvironment(environment) && typeof capabilities?.zoom === "boolean" && typeof capabilities?.cursorPosition === "boolean")) return void 0; return { __kind: "computer_use", display: { width: display.width, height: display.height }, environment, capabilities: { zoom: capabilities.zoom, cursorPosition: capabilities.cursorPosition } }; } //#endregion export { getComputerUseToolMetadata }; //# sourceMappingURL=computer-use.js.map