/** * AgentHTTP:把本地 Agent 暴露为最小 SDK HTTP 面的对外类。 * * 关键点(中文) * - 仅承载 RemoteAgent 对应的 SDK transport(`/api/sdk/sessions/*`)。 * - `router()` 返回一个 `Hono` 子路由,调用方 `app.route("/", agent_http.router())` 即可挂载。 * - `server()` 返回一个独立 HTTP server 句柄,按需自启、自停。 * - 同一个实例多次取 router/server 都返回缓存对象,避免重复注册。 */ import { Hono } from "hono"; import type { Agent } from "../../../agent/Agent.js"; import type { WorkspaceBase } from "@downcity/workspace"; import type { AgentPlugins } from "../../../types/plugin/PluginRuntime.js"; import type { AgentHttpBinding, AgentHttpListenOptions } from "../types/AgentHttpBinding.js"; import type { AgentHttpRuntimeOptions } from "../types/AgentHttpRuntime.js"; /** * AgentHTTP server 句柄。 */ export interface AgentHttpServerHandle { /** 监听 HTTP 端口。 */ listen(options: AgentHttpListenOptions): Promise; /** 关闭当前 HTTP server。 */ close(): Promise; /** 当前监听绑定信息,未 listen 时为 `null`。 */ binding(): AgentHttpBinding | null; } /** * 把一个 `WorkspaceEntry` 暴露为最小 SDK HTTP 面。 */ export declare class AgentHTTP { private readonly agent; private readonly workspace?; private readonly plugins; private readonly session_collection; private readonly runtime_options; private cached_router; private cached_server; constructor(agent_or_workspace: Agent | { agent: Agent; workspace: WorkspaceBase; plugins: AgentPlugins; }, workspace_or_options?: WorkspaceBase | AgentHttpRuntimeOptions, runtime_options?: AgentHttpRuntimeOptions); /** * 返回一个挂载到外部 hono server 用的子路由。 * * 说明(中文) * - 多次调用返回同一个 hono 实例,避免重复注册。 * - 不在这里附加 CORS / logger,由调用方按需在自己的入口 hono 上挂中间件。 */ router(): Hono; /** * 返回独立 HTTP server 句柄。 */ server(): AgentHttpServerHandle; /** * 关闭通过本实例 `server()` 启动的 HTTP server。 * * 说明(中文) * - 仅作用于 `server()` 创建的独立 HTTP server。 * - `router()` 挂到外部 hono 的场景由调用方自己管理生命周期。 */ close(): Promise; } /** 为已装配完成的 Hono Router 创建独立 Node HTTP Server 句柄。 */ export declare function create_agent_http_server_handle(app: Hono): AgentHttpServerHandle; //# sourceMappingURL=AgentHTTP.d.ts.map