Patch Changes
-
#911
975831aThanks @omeraplak! - feat: expose Cloudflare Workersenvbindings in serverless contextsWhen using
@voltagent/serverless-honoon Cloudflare Workers, the runtimeenvis now injected into the
context map for agent requests, workflow runs, and tool executions.@voltagent/coreexports
SERVERLESS_ENV_CONTEXT_KEYso you can access bindings like D1 fromoptions.context(tools) or
state.context(workflow steps). Tool execution also acceptscontextas aMap, preserving
userId/conversationIdwhen provided that way.@voltagent/coreis also marked as side-effect free so edge bundlers can tree-shake the PlanAgent
filesystem backend, avoiding Node-only dependency loading when it is not used.Usage:
import { createTool, SERVERLESS_ENV_CONTEXT_KEY } from "@voltagent/core"; import type { D1Database } from "@cloudflare/workers-types"; import { z } from "zod"; type Env = { DB: D1Database }; export const listUsers = createTool({ name: "list-users", description: "Fetch users from D1", parameters: z.object({}), execute: async (_args, options) => { const env = options?.context?.get(SERVERLESS_ENV_CONTEXT_KEY) as Env | undefined; const db = env?.DB; if (!db) { throw new Error("D1 binding is missing (env.DB)"); } const { results } = await db.prepare("SELECT id, name FROM users").all(); return results; }, });
-
Updated dependencies [
975831a]:- @voltagent/server-core@2.1.1