原文
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' },
);
}