BEEOS CLOUD / DEVELOPER REFERENCE
Harness SDK
在 OpenClaw、Hermes 或自定义智能体内注册运行时并处理聊天
Harness SDK 只发布 TypeScript 与 Python。TypeScript 包 @beeos-ai/cloud-harness-sdk 导出 RuntimeRegistrationCoordinator,用于注册和续租。Python 发行包 beeos-cloud-harness-sdk 的导入名是 beeos_cloud_harness_sdk,导出 BeeOSAgentRuntime。没有 Java、Rust 或 Go 包。参阅语言配置。
TypeScript 示例负责运行时注册。Python 示例在产品后端使用服务端 SDK 2.0.0,调用已注册的 harness;BEEOS_HARNESS_ID 从 cloud.harnesses.list() 选择。服务端 SDK 2.0.0 不提供 Python 运行时注册或 complete_reply,这些仍由运行时 host 负责。bsk_ Key 只保存在产品后端。
import {
RuntimeRegistrationCoordinator,
type RuntimeRegistrationConfig,
type RuntimeRegistrationTransport,
} from "@beeos-ai/cloud-harness-sdk";
async function startRuntime(
transport: RuntimeRegistrationTransport,
config: RuntimeRegistrationConfig,
onLeaseLost: (reason: "fenced" | "expired" | "heartbeat_failed", cause?: unknown) => void,
) {
const runtime = new RuntimeRegistrationCoordinator(transport, config, onLeaseLost);
await runtime.start();
return runtime;
}Python 的 BeeOSAgentRuntime.register 只保存处理函数,不打开网络监听。宿主适配器把方法调用交给 runtime.dispatch_runtime_method(method, params)。Cloud Responses/chat 使用 session/prompt;没有自定义运行时方法处理函数时,会分发给 on_chat_message。事件带有预创建回复的 replyMessageId,通过 runtime.chat.complete_reply(conversation_id, reply_message_id, text) 完成该回复。若注册了 on_runtime_method,应自行将 session/prompt 交给 runtime.dispatch_session_prompt(params)。独立消息平面适配器把信封交给 runtime.consume_envelope(envelope)。consume_envelope 只在信封带有消息 ID 和信道 ID 时产生聊天事件。chat_cancel 会调用 on_chat_cancel。
messages.reply(conversation_id, inbound_message_id, text) 属于独立消息平面的 agent_reply 操作,不会完成 Cloud chat 预创建的回复。退出时调用 runtime.close();之后的请求会抛出 runtime_closed。参阅端口与错误和自定义智能体指南。