@camelai/run

中文文档
0.22.1发布于 2026/10/20MITTypeScriptES Module近 30 天下载 2423

SDK for camelRun: define tools in your app, and the runtime runs the model loop, history and sandbox.

原始使用文档

@camelai/run

The TypeScript SDK for camelRun: durable agents you upsert by key and run, with tools that are ordinary functions in your code. The runtime runs the model loop, keeps each agent's history and files, and runs model-written code in a sandbox that can only call your tools.

npm install @camelai/run

Node 22 or later, Bun, Deno or Cloudflare Workers. Create an API key at https://run.camelai.com/console/tokens and export it as CAMELAI_API_KEY.

Coding agents: this version's docs are in the package, at node_modules/@camelai/run/docs/SKILL.md and docs/sdk.md. To set camelRun up in a project, read https://run.camelai.com/SKILL.md.

import { Agents, schema, tool } from "@camelai/run";

const agents = new Agents();

const weather = tool({
  description: "Today's weather in a city",
  input: schema.Object({ city: schema.String() }),
  execute: ({ city }) => ({ city, forecast: "sunny", highC: 24 }), // runs here, in your process
});

const agent = await agents.upsert("quickstart", {
  instructions: "You are a concise assistant.",
  tools: { weather },
});

const run = await agent.run("Should I bring an umbrella in Lisbon today?");
console.log(run.text);

await agents.close();
  • Keyed agents. upsert(key, config) makes the agent for your key, or brings the existing one to config; its history and files last until you delete it.
  • Runs. run() resolves with { status, text, inputs, error, toolErrors, toolCalls, … } and throws RunError on failure (unless throwOnError: false). No timeout: pass an AbortSignal to stop waiting. stream() yields text, tool calls and results as they happen, then the run.
  • People in the loop. A tool with needsApproval: true waits for approval; run.inputs[0].answer(true, { from }) resumes the run.
  • Tools. Each call's context.idempotencyKey is stable across retries; timeoutMs and context.progress() handle long calls. One process at a time serves an agent's tools; serverless and multi-user backends serve them over HTTP with serveTools (@camelai/run/server).
  • Browsers. A chat in your app: one route with createAgentHandler (@camelai/run/server) and <AgentChat> or the hooks from @camelai/run-react (or /chat without React, /ai-sdk with the AI SDK's useChat); see the Frontend guide (docs/frontend.md), or start with npm create @camelai/run-app. watchAgent (@camelai/run/watch) shows an agent live with a browser token your server mints.

Documentation: Quickstart, Concepts, SDK reference, and all of it as Markdown at https://run.camelai.com/llms.txt.

AgentRuntime and AgentClient, the lower-level interface the SDK is built on, remain available. See the SDK reference's "Changes in 0.9" when upgrading.

版本与发布记录

@camelai/run 共发布 17 个版本,首次发布于 2026/10/01;过去 12 个月发布了 17 个版本。

版本发布日期距今
0.22.1latest2026/10/2020 天前
0.22.02026/10/2020 天前
0.21.02026/10/1624 天前
0.20.02026/10/1030 天前
0.19.02026/10/1030 天前
0.18.02026/10/0930 天前

关于 @camelai/run 的常见问题

@camelai/run 是什么?

SDK for camelRun: define tools in your app, and the runtime runs the model loop, history and sandbox.

如何安装 @camelai/run?

在项目目录运行 npm install @camelai/run,或使用 pnpm add / yarn add / bun add。

@camelai/run 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@camelai/run 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@camelai/run 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@camelai/run 可以商用吗?

@camelai/run 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@camelai/run 的下载量有多少?

根据 npm 官方下载统计,@camelai/run 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,423 次,日均约 81 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@camelai/run 还在维护吗?

最新版本 0.22.1 发布于 2026/10/20(20 天前);至今共发布 17 个版本,其中过去 12 个月发布了 17 个;首次发布于 2026/10/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。