AI SDK - 皮·哈内斯
HarnessV1 辅助适配器 @earendil-works/pi-coding-agent. Pi在主机Node.js处理中运行并使用沙盒作为远程文件系统+外壳——沙盒内部没有安装桥接处理.
- > (中文) 说明:这个包是实验性的.
设置
npm i ai @ai-sdk/harness-pi @ai-sdk/harness @ai-sdk/sandbox-vercel zod
使用量
import { HarnessAgent } from '@ai-sdk/harness/agent';
import { createPi } from '@ai-sdk/harness-pi';
import { createVercelNetworkSandboxSession } from '@ai-sdk/sandbox-vercel';
import { tool } from 'ai';
import { z } from 'zod/v4';
const agent = new HarnessAgent({
harness: createPi({ thinkingLevel: 'medium' }),
id: 'demo',
skills: [
{
name: 'careful-refactors',
description: 'Make minimal diffs and keep tests green.',
content: 'Prefer changes that touch the fewest files possible.',
},
],
tools: {
deploy: tool({
description: 'Deploy a service.',
inputSchema: z.object({ env: z.enum(['staging', 'production']) }),
execute: async ({ env }) => ({ url: `https://${env}.example.com` }),
}),
},
});
const sandboxSession = await createVercelNetworkSandboxSession({
runtime: 'node24',
});
const session = await agent.createSession({ sandboxSession });
try {
const result = await agent.generate({
session,
prompt: 'Read README.md and summarise the goals.',
});
console.log(result.text);
} finally {
await session.destroy();
await sandboxSession.destroy();
}
见 Pi 调理文档 更多信息.