@berthos / sdk
构建一个常驻应用程序:一个运行在泊位沙箱内的工具,并公开代理可以调用的函数。SDK会给你 defineApp()上下文总线和语义文件系统的生命周期钩子和客户端。
泊位 在沙盒中运行人工智能代理的工具。每个工具在类中声明它可以接触什么 berth.yml manifest, Linux内核强制执行它。
npm install @berthos/sdk zod
使用
// src/index.ts
import { defineApp } from "@berthos/sdk";
import { z } from "zod";
export default defineApp((app) => {
app.export({
name: "ping",
output: z.object({ message: z.string() }),
handler: () => ({ message: "pong" }),
});
});
# berth.yml
name: hello-world
version: 0.1.0
capabilities: []
exports:
- name: ping
output: { message: string }
在 berth.yml 太; berth test 检查它们是否匹配。应用程序可以触摸的东西来自于舱单 capabilities,而不是从代码。最快的开始是 berth init 从 @berthos/cli.
也出口: defineConnectorApp() (一个由声明式REST API描述构建的应用), requestCapability(), configureEgressProxy(),以及进程内 createLocalContextBus() 和 createLocalSemanticFs() 为测试。