@ berthos/adapter-core
这个 DeployAdapter 每个泊位部署目标实现的接口。 @berthos/adapter-e2b, @berthos/adapter-daytona 和 @berthos/adapter-k8s 在此基础上继续发展 berth CLI只与这个接口对话,从不与提供程序SDK对话。
泊位 在沙盒中运行人工智能代理的工具。每个工具在类中声明它可以接触什么 berth.yml manifest, Linux内核强制执行它。
npm install @berthos/adapter-core
您只需要这个包来为新的提供程序编写适配器。
使用
import type { DeployAdapter } from "@berthos/adapter-core";
export function createMyAdapter(): DeployAdapter {
return {
name: "my-provider",
upload: async (target) => pushImage(target.imageRef), // -> { remoteImageRef }
start: async (remoteImageRef, target) => bootInstance(remoteImageRef, target), // -> DeployHandle
teardown: async (handle) => handle.stop(),
};
}
| 成员 | 它是做什么的 |
|---|---|
upload(target) | 使 target.imageRef 提供方可用的;返回 { remoteImageRef } |
start(remoteImageRef, target) | 启动一个实例;返回一个 DeployHandle (id, status(), streamLogs(), stop()) |
teardown(handle) | 停止并删除实例 |
list?, connect?, previewUrl?, rpcUrl?, pause?, resume?, fork?, snapshot? | 可选的。实现你的提供商支持的那些;否则,命令行会退退或报告该特性不支持 |
DeployTarget 是 { imageRef, manifest, env?, region? }. withTimeout(), DEPLOY_CREATE_TIMEOUT_MS (5分钟) 和 DEPLOY_READ_TIMEOUT_MS (30秒)导出用于绑定提供程序调用。
文档
Kubernetes适配器参考 (界面的工作示例)· 回购