Discover, convert, execute, and dispatch canonical tools from model tool calls.

ToolsClient

Local tool discovery and authenticated canonical execution.

execute

Starts one canonical execution and returns its immediate execution envelope.

Canonical dotted and restricted wire names are accepted. Mutations receive a generated UUID idempotency key when one is not supplied; pass a stable key to correlate retries across separate calls.

ts
execute(toolName: string, options: ExecuteToolOptions): Promise<ExecutionResult>
ParameterTypeRequiredDescription
toolNamestringYesCanonical dotted name or restricted name emitted to a model.
optionsExecuteToolOptionsYesCanonical input, user binding, execution mode, and retry identity.

Returns: Promise<ExecutionResult>

Throws

  • EyeballError when local validation, transport, authentication, or executor admission fails.

Example

ts
import { Eyeball } from "@eyeball/sdk";

const eyeball = new Eyeball({
  apiKey: process.env.EYEBALL_API_KEY!,
  baseUrl: process.env.EYEBALL_EXECUTOR_URL!,
});

const execution = await eyeball.tools.execute("gmail.create_draft", {
  userId: "user_42",
  input: { to: ["guest@example.com"], subject: "Review", body: "Draft" },
  idempotencyKey: "draft:reservation:42",
});

get

Resolves and converts the open-core catalog locally without calling the executor.

Hosted per-project enablement and catalog policy are eyeball-cloud concerns.

ts
get<Format extends EyeballToolFormat = "canonical">(options?: GetToolsOptions<Format>): Promise<GetToolsResult<Format>>
ParameterTypeRequiredDescription
optionsGetToolsOptions<Format>NoToolkit and capability filters plus the requested model format.

Returns: Promise<GetToolsResult<Format>>

Throws

  • EyeballError with invalid_input when filters are invalid or AI SDK callbacks have no user binding.

Example

ts
import { Eyeball } from "@eyeball/sdk";

const eyeball = new Eyeball({
  apiKey: process.env.EYEBALL_API_KEY!,
  baseUrl: process.env.EYEBALL_EXECUTOR_URL!,
});

const bundle = await eyeball.tools.get({
  toolkits: ["gmail"],
  format: "anthropic",
});
console.log(bundle.tools, bundle.nameMap);

run

Runs a model-selected tool to completion and returns only its canonical output.

The exact canonical or restricted wire name emitted by a model is accepted. Async work is polled through executions.wait before this method resolves.

ts
run(toolName: string, input: unknown, options?: RunToolOptions): Promise<JsonValue>
ParameterTypeRequiredDescription
toolNamestringYesCanonical dotted name or restricted name emitted to a model.
inputunknownYesCanonical JSON object for the selected tool.
optionsRunToolOptionsNoUser, connection, execution, idempotency, and polling controls.

Returns: Promise<JsonValue>

Throws

  • EyeballError for local validation, request failures, terminal tool errors, or polling timeout.

Example

ts
import { Eyeball } from "@eyeball/sdk";

const eyeball = new Eyeball({
  apiKey: process.env.EYEBALL_API_KEY!,
  baseUrl: process.env.EYEBALL_EXECUTOR_URL!,
});

const output = await eyeball.tools.run(
  "gmail.search_emails",
  { query: "reservation", pageSize: 5 },
  { userId: "user_42", timeoutMs: 30_000 },
);

Searches and ranks the local open-core catalog without contacting the executor.

ts
search(options: SearchToolsOptions): Promise<SearchToolsResult>
ParameterTypeRequiredDescription
optionsSearchToolsOptionsYesSearch text, result limit, and optional local catalog filters.

Returns: Promise<SearchToolsResult>

Throws

  • EyeballError with invalid_input when the query or a filter is invalid.

executeToolCalls

Dispatches framework tool calls and returns model-ready result blocks. Each call's framework ID becomes its stable, format-prefixed idempotency key so redispatching the same model response reuses the original execution instead of duplicating a mutation.

Per-call failures are serialized into safe model-facing results instead of rejecting the batch.

Overload 1

ts
executeToolCalls(eyeball: Eyeball, calls: readonly AnthropicToolCall[], options: ExecuteToolCallsOptions): Promise<AnthropicToolResultBlock[]>
ParameterTypeRequiredDescription
eyeballEyeballYesConfigured SDK client used for canonical execution.
callsreadonly AnthropicToolCall[]YesAnthropic tool-use blocks or OpenAI function tool calls from one response.
optionsExecuteToolCallsOptionsYesExact emitted name map plus optional execution and polling controls.

Returns: Promise<AnthropicToolResultBlock[]>

Overload 2

ts
executeToolCalls(eyeball: Eyeball, calls: readonly OpenAIToolCall[], options: ExecuteToolCallsOptions): Promise<OpenAIToolResultMessage[]>
ParameterTypeRequiredDescription
eyeballEyeballYesConfigured SDK client used for canonical execution.
callsreadonly OpenAIToolCall[]YesAnthropic tool-use blocks or OpenAI function tool calls from one response.
optionsExecuteToolCallsOptionsYesExact emitted name map plus optional execution and polling controls.

Returns: Promise<OpenAIToolResultMessage[]>

Types

SearchToolsOptions

Query and optional local catalog filters for tools.search.

ts
export interface SearchToolsOptions {
  query: string;
  limit?: number;
  /** Optional local catalog filters, applied before ranking. */
  toolkits?: readonly string[];
  capability?: CapabilitySlug;
  /** Accepted for parity with the future hosted project-scoped search surface. */
  userId?: string;
}
PropertyTypeRequiredReadonlyDescription
capability"email" | "calendar_scheduling" | "messaging_chat" | "voice_telephony" | "sms" | "crm" | "erp_accounting" | "social_media_data" | "social_media_publishing" | "file_storage_docs" | "spreadsheets_databases" | "project_management_dev_tools" | "payments_billing" | "ecommerce" | "customer_support" | "web_search_scraping" | "hr_recruiting" | "marketing_ads" | "sign_forms" | "ai_media_utilities"NoNo
limitnumberNoNo
querystringYesNo
toolkitsreadonly string[]NoNoOptional local catalog filters, applied before ranking.
userIdstringNoNoAccepted for parity with the future hosted project-scoped search surface.

SearchToolsResult

Canonical definitions ranked by local catalog relevance.

ts
export interface SearchToolsResult {
  tools: readonly ToolDefinition[];
}
PropertyTypeRequiredReadonlyDescription
toolsreadonly ToolDefinition[]YesNo

GetToolsOptions

Local catalog filters and conversion controls for tools.get.

ts
export interface GetToolsOptions<
  Format extends EyeballToolFormat = "canonical",
> {
  /**
   * Binds framework-owned execute callbacks to an end user. Tool discovery itself is
   * resolved entirely from the local `@eyeball/catalog`; hosted project catalog policy
   * belongs to eyeball-cloud and is not fetched by this method.
   */
  userId?: string;
  toolkits?: readonly string[];
  capability?: CapabilitySlug;
  format?: Format;
  /** MCP only: include async-by-nature tools after Tasks support is negotiated. */
  includeAsync?: boolean;
}
PropertyTypeRequiredReadonlyDescription
capability"email" | "calendar_scheduling" | "messaging_chat" | "voice_telephony" | "sms" | "crm" | "erp_accounting" | "social_media_data" | "social_media_publishing" | "file_storage_docs" | "spreadsheets_databases" | "project_management_dev_tools" | "payments_billing" | "ecommerce" | "customer_support" | "web_search_scraping" | "hr_recruiting" | "marketing_ads" | "sign_forms" | "ai_media_utilities"NoNo
formatFormatNoNo
includeAsyncbooleanNoNoMCP only: include async-by-nature tools after Tasks support is negotiated.
toolkitsreadonly string[]NoNo
userIdstringNoNoBinds framework-owned execute callbacks to an end user. Tool discovery itself is resolved entirely from the local @eyeball/catalog; hosted project catalog policy belongs to eyeball-cloud and is not fetched by this method.

GetToolsResult

Converted model tools plus canonical definitions and reversible names.

ts
export interface GetToolsResult<Format extends EyeballToolFormat> {
  tools: EyeballToolFormatMap[Format];
  nameMap: ToolNameMap;
  raw: readonly ToolDefinition[];
}
PropertyTypeRequiredReadonlyDescription
nameMapToolNameMapYesNo
rawreadonly ToolDefinition[]YesNo
toolsEyeballToolFormatMap[Format]YesNo

EyeballToolFormat

Tool-definition formats emitted for supported model frameworks and MCP.

ts
export type EyeballToolFormat =
  | "canonical"
  | "anthropic"
  | "openai"
  | "ai-sdk"
  | "mcp";

EyeballToolFormatMap

Compile-time mapping from a requested format to its emitted tool container.

ts
export interface EyeballToolFormatMap {
  canonical: readonly ToolDefinition[];
  anthropic: AnthropicToolDescriptor[];
  openai: OpenAIFunctionToolDescriptor[];
  "ai-sdk": AiSdkToolSet;
  mcp: McpToolDescriptor[];
}
PropertyTypeRequiredReadonlyDescription
ai-sdkAiSdkToolSetYesNo
anthropicAnthropicToolDescriptor[]YesNo
canonicalreadonly ToolDefinition[]YesNo
mcpMcpToolDescriptor[]YesNo
openaiOpenAIFunctionToolDescriptor[]YesNo

ExecuteToolOptions

Canonical input and execution controls for tools.execute.

ts
export interface ExecuteToolOptions {
  /** Uses the client-level userId when omitted. */
  userId?: string;
  input: Readonly<Record<string, JsonValue>>;
  /** Defaults from the canonical tool's `annotations.async` value. */
  mode?: ExecutionMode;
  /**
   * Stable caller key for retry correlation. When omitted for a mutation, the SDK
   * generates a fresh `crypto.randomUUID()` for this invocation. Pass your own key
   * when separate calls must replay the same execution.
   */
  idempotencyKey?: string;
  connectionId?: ConnectionId;
}
PropertyTypeRequiredReadonlyDescription
connectionIdconn_$&#123;string&#125;NoNo
idempotencyKeystringNoNoStable caller key for retry correlation. When omitted for a mutation, the SDK generates a fresh crypto.randomUUID() for this invocation. Pass your own key when separate calls must replay the same execution.
inputReadonly<Record<string, JsonValue>>YesNo
modeExecutionModeNoNoDefaults from the canonical tool's annotations.async value.
userIdstringNoNoUses the client-level userId when omitted.

RunToolOptions

Execution and polling controls for tools.run.

ts
export interface RunToolOptions
  extends Omit<ExecuteToolOptions, "input">,
    WaitForExecutionOptions {}
PropertyTypeRequiredReadonlyDescription
connectionIdconn_$&#123;string&#125;NoNo
idempotencyKeystringNoNoStable caller key for retry correlation. When omitted for a mutation, the SDK generates a fresh crypto.randomUUID() for this invocation. Pass your own key when separate calls must replay the same execution.
modeExecutionModeNoNoDefaults from the canonical tool's annotations.async value.
pollMsnumberNoNoMilliseconds between polls. Defaults to 500.
timeoutMsnumberNoNoTotal milliseconds before a timeout error. Defaults to 60,000.
userIdstringNoNoUses the client-level userId when omitted.

ExecuteToolCallsOptions

Name-map boundary and execution controls for framework tool-call dispatch.

ts
export interface ExecuteToolCallsOptions {
  /** Exact map emitted with the model-facing tool bundle. Unmapped calls are rejected. */
  nameMap: ToolNameMap;
  /** Uses the client-level userId when omitted. */
  userId?: string;
  connectionId?: ConnectionId;
  mode?: ExecutionMode;
  pollMs?: number;
  timeoutMs?: number;
}
PropertyTypeRequiredReadonlyDescription
connectionIdconn_$&#123;string&#125;NoNo
modeExecutionModeNoNo
nameMapToolNameMapYesNoExact map emitted with the model-facing tool bundle. Unmapped calls are rejected.
pollMsnumberNoNo
timeoutMsnumberNoNo
userIdstringNoNoUses the client-level userId when omitted.

AnthropicToolCall

Anthropic tool_use block accepted by executeToolCalls.

ts
export interface AnthropicToolCall {
  type: "tool_use";
  id: string;
  name: string;
  input: unknown;
}
PropertyTypeRequiredReadonlyDescription
idstringYesNo
inputunknownYesNo
namestringYesNo
type"tool_use"YesNo

AnthropicToolResultBlock

Anthropic tool_result block returned by executeToolCalls.

ts
export interface AnthropicToolResultBlock {
  type: "tool_result";
  tool_use_id: string;
  content: string;
  is_error?: boolean;
}
PropertyTypeRequiredReadonlyDescription
contentstringYesNo
is_errorbooleanNoNo
tool_use_idstringYesNo
type"tool_result"YesNo

OpenAIFunctionToolCall

OpenAI function tool call accepted by executeToolCalls.

ts
export interface OpenAIFunctionToolCall {
  id: string;
  type: "function";
  function: {
    name: string;
    arguments: string | Readonly<Record<string, JsonValue>>;
  };
}
PropertyTypeRequiredReadonlyDescription
function{ name: string; arguments: string | Readonly<Record<string, JsonValue>>; }YesNo
idstringYesNo
type"function"YesNo

OpenAICustomToolCall

OpenAI custom tool call represented in the public input union.

ts
export interface OpenAICustomToolCall {
  id: string;
  type: "custom";
  custom: { name: string; input: string };
}
PropertyTypeRequiredReadonlyDescription
custom{ name: string; input: string; }YesNo
idstringYesNo
type"custom"YesNo

OpenAIToolCall

OpenAI function or custom tool call accepted by executeToolCalls.

ts
export type OpenAIToolCall = OpenAIFunctionToolCall | OpenAICustomToolCall;

OpenAIToolResultMessage

OpenAI tool result message returned by executeToolCalls.

ts
export interface OpenAIToolResultMessage {
  role: "tool";
  tool_call_id: string;
  content: string;
}
PropertyTypeRequiredReadonlyDescription
contentstringYesNo
role"tool"YesNo
tool_call_idstringYesNo

QualifiedToolName

ts
export type QualifiedToolName = `${string}.${string}`;

ToolDefinition

ts
export interface ToolDefinition {
  /** Exactly `<toolkit>.<canonical-tool>`, for example `gmail.send_email`. */
  name: QualifiedToolName;
  toolkit: ToolkitSlug;
  capability: CapabilitySlug;
  /** LLM-facing purpose, selection guidance, exclusions, and consequences. */
  description: string;
  inputSchema: ObjectSchema202012;
  outputSchema?: ObjectSchema202012;
  annotations: ToolAnnotations;
  version: SemVer;
}
PropertyTypeRequiredReadonlyDescription
annotationsToolAnnotationsYesNo
capability"email" | "calendar_scheduling" | "messaging_chat" | "voice_telephony" | "sms" | "crm" | "erp_accounting" | "social_media_data" | "social_media_publishing" | "file_storage_docs" | "spreadsheets_databases" | "project_management_dev_tools" | "payments_billing" | "ecommerce" | "customer_support" | "web_search_scraping" | "hr_recruiting" | "marketing_ads" | "sign_forms" | "ai_media_utilities"YesNo
descriptionstringYesNoLLM-facing purpose, selection guidance, exclusions, and consequences.
inputSchemaObjectSchema202012YesNo
name$&#123;string&#125;.$&#123;string&#125;YesNoExactly <toolkit>.<canonical-tool>, for example gmail.send_email.
outputSchemaObjectSchema202012NoNo
toolkitstringYesNo
version$&#123;number&#125;.$&#123;number&#125;.$&#123;number&#125;YesNo

ToolNameMap

ts
export interface ToolNameMap {
  canonicalToWire: Readonly<Record<QualifiedToolName, string>>;
  wireToCanonical: Readonly<Record<string, QualifiedToolName>>;
}
PropertyTypeRequiredReadonlyDescription
canonicalToWireReadonly<Record<$&#123;string&#125;.$&#123;string&#125;, string>>YesNo
wireToCanonicalReadonly<Record<string, $&#123;string&#125;.$&#123;string&#125;>>YesNo