Flue 是一个用于构建下一代智能体(或代理)的 TypeScript 框架。
Flue is a TypeScript framework for building the next generation of agents

原始链接: https://flueframework.com/

## Flue Agent 示例总结 这段代码展示了几个“Flue”代理的示例——旨在响应事件并完成任务的自主工具。Flue 利用各种沙箱和模型选项来实现灵活性。 **主要特点:** * **事件触发:** 代理由触发器激活,例如 Webhook 或 CI 运行,无需持续轮询。 * **沙箱:** Flue 支持多种沙箱方法: * **GitHub Actions:** 使用 `Octokit` 与 GitHub 交互,对问题进行分类并直接发布评论(使用 `GITHUB_TOKEN` 安全地进行操作)。 * **`just-bash`:** 在 Node.js 环境中提供 bash shell,允许访问文件系统和执行 Python。 * **Daytona:** 利用容器进行隔离的代码执行,克隆仓库并运行 `npm install`。 * **Cloudflare Workers/R2:** 将 Cloudflare R2 bucket 挂载为代理的文件系统,以便访问知识库。 * **模型灵活性:** 支持来自 Anthropic (Claude)、OpenAI (GPT) 和 OpenRouter (Kimi) 的模型。 * **技能与角色:** 代理可以利用预定义的技能并承担特定角色(例如,数据分析师、支持代理),以增强任务完成度。 这些示例展示了 Flue 创建强大、适应性强的代理的能力,适用于各种用例,从 GitHub 问题管理到数据分析和客户支持。

对不起。
相关文章

原文
import type { FlueContext } from '@flue/sdk/client';
import { Octokit } from '@octokit/core';
import * as v from 'valibot';

// Triggered in CI via `flue run` CLI — no HTTP endpoint needed.
export const triggers = {};

// Built for: Node, GitHub Actions
export default async function ({ init, payload, env }: FlueContext) {
  const { issueNumber } = payload;
  const agent = await init({ model: 'anthropic/claude-opus-4-7' });
  const session = await agent.session();
  // Run the 'triage' skill to triage the GitHub issue.
  const triage = await session.skill('triage', {
    args: { issueNumber },
    result: v.object({
      severity: v.picklist(['low', 'medium', 'high', 'critical']),
      reproducible: v.boolean(),
      summary: v.string(),
    }),
  });
  // Post the triage result back to GitHub.
  // The agent/sandbox never sees your sensitive GITHUB_TOKEN.
  const body = `**Severity:** ${triage.severity}\n**Reproducible:** ${triage.reproducible}\n\n${triage.summary}`;
  await (new Octokit({ auth: env.GITHUB_TOKEN })).request(
    'POST /repos/{owner}/{repo}/issues/{num}/comments', 
    { owner: 'withastro', repo: 'flue', num: issueNumber, body },
  );
}
import type { FlueContext } from '@flue/sdk/client';
import { Bash, InMemoryFs, MountableFs, ReadWriteFs } from 'just-bash';

// POST /agents/data/:id
export const triggers = { webhook: true };

// Built for: Node
export default async function ({ init, payload }: FlueContext) {
  // Mount the current directory at /workspace, so the agent can read,
  // write, grep, and glob from your project files using bash.
  const fs = new MountableFs({ base: new InMemoryFs() });
  fs.mount('/workspace', new ReadWriteFs({ root: process.cwd() }));

  // Create a custom virtual sandbox with 'just-bash'. Enable Python use
  // so the agent can write code to analyze data, generate reports, etc.
  const agent = await init({
    sandbox: () => new Bash({ fs, cwd: '/workspace', python: true }),
    model: 'anthropic/claude-sonnet-4-6',
  });
  const session = await agent.session();
  // Prompt! The agent harness includes your workspace AGENTS.md,
  // skills, and roles (aka subagents) to analyze the data and
  // complete your task as desired.
  return await session.prompt(
    `Answer this user question: ${payload.message}`,
    { role: 'data-analyst' },
  );
}
import type { FlueContext } from '@flue/sdk/client';
import { Daytona } from '@daytona/sdk';
import { daytona } from '@flue/connectors/daytona';

// POST /agents/code/:id
export const triggers = { webhook: true };

// Built for: Node, Daytona
export default async function ({ init, payload, env }: FlueContext) {
  // Each agent gets a real container via Daytona.
  const client = new Daytona({ apiKey: env.DAYTONA_API_KEY });
  const sandbox = await client.create();
  const agent = await init({ sandbox: daytona(sandbox), model: 'openai/gpt-5.5' });
  const session = await agent.session();
  // Setup the sandbox (for illustrative purposes only). 
  // In production, you'd want to bake setup into the container image,
  // or use a snapshot (if available from your sandbox provider).
  await session.shell(`git clone ${payload.repo} /workspace/project`);
  await session.shell('npm install', { cwd: '/workspace/project' });
  return await session.prompt(payload.prompt);
}
import { getVirtualSandbox } from '@flue/sdk/cloudflare';
import type { FlueContext } from '@flue/sdk/client';

// POST /agents/support/:id
export const triggers = { webhook: true };

// Built for: Cloudflare Workers, R2
export default async function ({ init, payload, env }: FlueContext) {
  // Mount your R2 bucket (declared as a binding in wrangler.jsonc) as
  // the agent's filesystem at /workspace, backed by Durable Object
  // SQLite + R2 under the hood. The agent searches it with bash —
  // grep, glob, read — without spinning up a container.
  const sandbox = await getVirtualSandbox(env.KNOWLEDGE_BASE_BUCKET);
  const agent = await init({ sandbox, model: 'openrouter/moonshotai/kimi-k2.6' });
  const session = await agent.session();
  // Prompt! The agent harness includes your workspace AGENTS.md,
  // skills, and roles (aka subagents) to complete your task as 
  // desired. Use `session.skill()` to call a skill directly.
  return await session.prompt(
    `Respond to this customer message: ${payload.message}`,
    { role: 'support-agent' },
  );
}
联系我们 contact @ memedata.com