TypeScript API Reference
The define* helpers, the runtime ctx, and where each one is imported from.
This is the public surface of the eve package: the define* helpers you author with, the ctx they receive at runtime, and the import path for each. The full contract lives in packages/eve/src/public/index.ts; anything not exported there is a framework internal.
Identity comes from the filesystem, not a field you set. A tool at agent/tools/get_weather.ts is get_weather, and a connection at agent/connections/linear.ts is linear, so no definition carries a name or id.
Most files look the same: import a helper, default-export the result.
import { defineAgent } from "eve";
export default defineAgent({ model: "anthropic/claude-opus-4.8" });import { defineTool } from "eve/tools";
import { z } from "zod";
export default defineTool({
description: "Get the weather for a city.",
inputSchema: z.object({ city: z.string() }),
async execute({ city }, ctx) {
return { city, condition: "Sunny" };
},
});The define* helpers
| Helper | Import from | Authored at | Guide |
|---|---|---|---|
defineAgent | eve | agent/agent.ts | agent.ts |
defineTool | eve/tools | agent/tools/<name>.ts | Tools |
defineDynamic | eve, eve/tools, eve/skills, eve/instructions | dynamic model or subagent agent.ts; agent/{tools,skills,instructions}/ | Dynamic capabilities |
defineMcpClientConnection | eve/connections | agent/connections/<name>.ts | MCP connections |
defineOpenAPIConnection | eve/connections | agent/connections/<name>.ts | OpenAPI connections |
defineChannel | eve/channels | agent/channels/<name>.ts | Custom channels |
eveChannel, slackChannel, and the other platforms | eve/channels/<platform> | agent/channels/<platform>.ts | Channels |
defineSkill | eve/skills | agent/skills/<name>.ts | Skills |
defineInstructions | eve/instructions | agent/instructions.ts | Instructions |
defineHook | eve/hooks | agent/hooks/<slug>.ts | Hooks |
defineSchedule | eve/schedules | agent/schedules/<name>.ts | Schedules |
defineState | eve/context | tools, hooks, lifecycle | Session context |
defineSandbox | eve/sandbox | agent/sandbox.ts | Sandbox |
defineInstrumentation | eve/instrumentation | agent/instrumentation.ts | instrumentation.ts |
defineRemoteAgent | eve | agent/subagents/<id>/agent.ts | Remote agents |
defineEval | eve/evals | evals/*.eval.ts | Evals |
defineEvalConfig | eve/evals | evals/evals.config.ts | Evals |
mockModel | eve/evals | Deterministic fixture agent models | Evals |
useEveAgent | eve/react, eve/vue, eve/svelte | frontend | Frontend |
A few additional helpers round out the set: defineGlobTool, defineGrepTool, disableTool, experimental_workflow, and webSearch from eve/tools (see Built-in tools), sleep from eve/tools/sleep, the route verbs GET/POST/PUT/PATCH/DELETE/WS from eve/channels, the approval policies always/once/never from eve/tools/approval, and the channel auth helpers localDev/vercelOidc/placeholderAuth from eve/channels/auth. To wrap a framework-provided tool, import its definition from eve/tools/defaults (bash, readFile, writeFile, glob, grep, webFetch, todo, loadSkill). AgentReasoningDefinition is exported from eve for the top-level defineAgent({ reasoning }) setting. AgentLimitsDefinition is exported for defineAgent({ limits }). AgentWorkflowDefinition and AgentWorkflowWorldDefinition are exported from eve for the defineAgent({ experimental: { workflow } }) config shape. ExperimentalWorkflowToolInput, WebSearchToolInput, and WebSearchProvider are exported from eve/tools for their corresponding tool configuration helpers.
defineInstructions accepts { content: string, role?: "system" | "user" }; omitted role means "system". Its eve/instructions version of defineDynamic accepts only session.started and turn.started handlers returning defineInstructions(...) or null. The legacy { markdown: string } definition remains available as a deprecated system-role form.
Runtime context (ctx)
ctx is passed to your tool execute, hook handlers, channel event handlers, and connection auth/header resolvers. It is live only while authored code is running, so reaching for it at module top level throws. See Session context for the full model.
| Member | Use |
|---|---|
ctx.session | Current session, turn, auth, and optional parent lineage (read-only) |
ctx.getSandbox() | Live sandbox handle; stop() releases compute but preserves durable state |
ctx.getSkill(identifier) | Handle for a named skill visible to the current agent |
ctx.getToken(provider) | Resolve a bearer token for an inline auth provider such as connect("...") |
ctx.requireAuth(provider) | Evict and re-authorize an inline provider, commonly after a downstream 401 |
Imports at a glance
| Import | Holds |
|---|---|
eve | defineAgent, defineRemoteAgent, defineDynamic, agent config types |
eve/tools | defineTool, defineDynamic, defineGlobTool, defineGrepTool, disableTool, experimental_workflow |
eve/tools/defaults | framework tool definitions as plain values |
eve/tools/approval | always, once, never |
eve/tools/sleep | opt-in durable sleep tool |
eve/connections | defineMcpClientConnection, defineOpenAPIConnection |
eve/channels | defineChannel, route verbs |
eve/channels/eve | eveChannel |
eve/channels/auth | localDev, vercelOidc, placeholderAuth |
eve/channels/{slack,discord,teams,telegram,twilio,github} | platform channel factories |
eve/hooks | defineHook |
eve/schedules | defineSchedule |
eve/skills | defineSkill, defineDynamic |
eve/instructions | defineInstructions, defineDynamic |
eve/context | defineState, session and state types |
eve/sandbox | defineSandbox, backends |
eve/instrumentation | defineInstrumentation, isChannel |
eve/models/openai | experimental_chatgpt |
eve/evals | defineEval, defineEvalConfig, mockModel, eval types |
eve/evals/expect | includes, equals, matches, similarity |
eve/evals/reporters | Braintrust, JUnit, EvalReporter |
eve/evals/loaders | loadJson, loadYaml |
eve/react, eve/vue, eve/svelte | useEveAgent |
eve/next, eve/nuxt, eve/sveltekit | framework bundler plugins |
eve/client | Client, ClientSession |
Exported types ship from the same entrypoint as the helper they describe (for example ToolDefinition and ToolContext from eve/tools). For the exhaustive list, read packages/eve/src/public/index.ts.
ChatGPT subscription models
experimental_chatgpt() from eve/models/openai serves an OpenAI model through the local Codex login and bills the ChatGPT subscription. With no argument, it selects gpt-5.6-sol:
import { defineAgent } from "eve";
import { experimental_chatgpt } from "eve/models/openai";
export default defineAgent({
model: experimental_chatgpt(),
modelContextWindowTokens: 200_000,
});Pass another bare OpenAI model slug to override the default. The helper reads credentials from codex login, so use it only where that local login exists.
What to read next
agent.ts: the agent config these helpers configure- Tools:
defineTool, the most-used helper - Project layout: where each define* lives on disk