Tools
List of tools you can add to OpenControl.
Here are some examples of the tools you can use with OpenControl.
We’ll be adding more tools to this list. If you have a tool you want to share, feel free to edit this doc and submit a PR.
AWS
import { z } from "zod"import AWS from "aws-sdk"import { tool } from "opencontrol/tool"
const aws = tool({ name: "aws", description: "Make a call to the AWS SDK for JavaScript v2", args: z.object({ client: z.string().describe("Class name of the client to use"), command: z.string().describe("Command to call on the client"), args: z .record(z.string(), z.any()) .optional() .describe("Arguments to pass to the command"), }), async run(input) { // @ts-ignore const client = new AWS[input.client]() return await client[input.command](input.args).promise() }})
Stripe
import { z } from "zod"import { tool } from "opencontrol/tool"
const stripe = tool({ name: "stripe", description: "make a call to the stripe api", args: z.object({ method: z.string().describe("HTTP method to use"), path: z.string().describe("Path to call"), query: z.record(z.string()).optional().describe("Query params"), contentType: z.string().optional().describe("HTTP content type to use"), body: z.string().optional().describe("HTTP body to use if it is not GET"), }), async run(input) { const url = new URL("https://api.stripe.com" + input.path) if (input.query) url.search = new URLSearchParams(input.query).toString() const response = await fetch(url.toString(), { method: input.method, headers: { Authorization: `Bearer ${Resource.StripeSecret.value}`, "Content-Type": input.contentType, }, body: input.body ? input.body : undefined, }) if (!response.ok) throw new Error(await response.text()) return response.text() }})
SQL database
import { z } from "zod"import { tool } from "opencontrol/tool"import { db } from "@acme/core/drizzle/index"
const databaseRead = tool({ name: "database_query_readonly", description: "Readonly database query for MySQL, use this if there are no direct tools", args: z.object({ query: z.string() }), async run(input) { return db.transaction(async (tx) => tx.execute(input.query), { accessMode: "read only", isolationLevel: "read committed" }) }})
const databaseWrite = tool({ name: "database_query_write", description: "DANGEROUS operation that writes to the database. You MUST triple check with the user before using this tool - show them the query you are about to run.", args: z.object({ query: z.string() }), async run(input) { return db.transaction(async (tx) => tx.execute(input.query), { isolationLevel: "read committed" }) }})