项目文件夹

文件
2026-07-13 12:38:34 +08:00

26 行
846 B
TypeScript

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
/**
* Mastra × Composio — Tool Router
*
* The v1-canonical way to give an agent tools: create a session scoped to one
* or more toolkits, then hand `session.tools()` to a Mastra Agent. The session
* exposes Composio's router meta-tools (search + multi-execute), so the agent
* discovers and runs the toolkit's tools dynamically.
*
* Uses the unauthenticated HACKERNEWS toolkit — no connected account needed.
*
* Prerequisites:
* - COMPOSIO_API_KEY (https://app.composio.dev)
* - OPENAI_API_KEY (or swap the model — see README)
*
* Run:
* bun ts/examples/mastra/src/tool-router.ts
*/
import 'dotenv/config';
import { runToolRouterHackerNewsAgent } from './hackernews-agent/tool-router';
const text = await runToolRouterHackerNewsAgent(process.env);
console.log('\n🤖 Agent response:\n');
console.log(text);