/** * City:Workspace、Embassy 与统一 transport 的资源容器。 * * City 不创建 Agent、Session 或 Plugin。应用创建 Agent 后通过 * `city.agents.add(agent)` 加入当前容器;City 管理 Agent 集合、Workspace/Embassy * 资源与统一 transport。 */ import type { WorkspaceEntry } from "../../agent/WorkspaceEntry.js"; import type { WorkspaceBase } from "@downcity/workspace"; import type { StorageProvider } from "@downcity/workspace"; import { CityHTTP } from "../transport/http/CityHTTP.js"; import { CityRPC } from "../transport/rpc/CityRPC.js"; import type { CityAgents, CityGroups, CityListenOptions, CityOptions, CityWorkspaces } from "../types/City.js"; /** Agent 实例索引与 transport 宿主。 */ export declare class City { /** City 持有的底层 Storage;默认是进程内存储。 */ readonly storage: StorageProvider; /** 当前 City 引用的 Agent,按稳定 ID 索引。 */ private readonly agents_by_id; /** 当前 City 引用的 Group,按稳定 ID 索引。 */ private readonly groups_by_id; /** City 面向应用的 Agent 集合入口。 */ readonly agents: CityAgents; /** City 面向宿主的 Group 集合入口。 */ readonly groups: CityGroups; /** City 面向宿主的 Workspace 集合入口。 */ readonly workspaces: CityWorkspaces; /** City 持有的 Workspace 资源,按稳定 ID 索引。 */ private readonly workspaces_by_id; /** City 绑定的 Embassy 服务入口。 */ readonly embassy?: CityOptions["embassy"]; /** 正在解除注册的 Agent;对查询立即不可见,失败后恢复可见。 */ private readonly removing_agent_ids; /** 每个 Agent 当前唯一的解除注册流程。 */ private readonly removal_promises; /** 宿主提供的按需 Workspace 创建能力。 */ private readonly resolve_workspace?; /** 相同 Agent/Workspace 目标当前唯一的进入流程。 */ private readonly workspace_entry_promises; /** 当前 City 唯一的 HTTP transport。 */ private readonly http_transport; /** 当前 City 唯一的 RPC transport。 */ private readonly rpc_transport; /** City transport 组合操作的唯一串行链。 */ private transport_operation_chain; /** City 自身的生命周期状态。 */ private city_status; /** City 关闭流程;并发调用共享同一个 Promise。 */ private close_promise?; constructor(options?: CityOptions); /** 按稳定 ID 获取 City 管理的 Group。 */ private get_group; /** 返回 City 管理的 Group 稳定快照。 */ private list_groups; /** 将已创建 Group 加入 City,并校验成员属于当前 City。 */ private add_group; /** 释放并移除一个 Group。 */ private remove_group; /** 返回 City 持有的 Workspace;不存在时返回 null。 */ /** 内部 AgentCity 协议;用户应使用 `city.workspaces.get()`。 */ get_workspace(workspace_id_input: string): WorkspaceBase | null; /** 返回 City 持有的 Workspace 稳定快照。 */ private list_workspaces; /** 返回当前 City 已注册 Agent 的稳定快照。 */ private list_agents; /** 按稳定 ID 返回可直接使用的 Agent;不存在时返回 null。 */ private get_agent; /** 按稳定 ID 返回内部 transport 所需 Agent;不存在时抛出明确错误。 */ private require_agent; /** 按 Agent ID 与 Workspace ID 返回 transport 所需的明确执行作用域。 */ require_workspace(agent_id_input: string, workspace_id_input: string): WorkspaceEntry; /** 按需解析并进入 Workspace;相同目标的并发请求共享一次创建流程。 */ enter_workspace(agent_id_input: string, workspace_id_input: string): Promise; /** 停止、释放并从 City 移除指定 Agent。 */ private remove_agent; /** 启动 City 唯一的 HTTP/RPC transport。 */ http(options: Parameters[0]): Promise; /** 启动 City 唯一的 RPC transport。 */ rpc(options?: Parameters[0]): Promise; /** 启动 City 唯一的 HTTP/RPC transport。 */ listen(options: CityListenOptions): Promise; /** 幂等关闭 transport,并按依赖顺序释放绑定 Agent 与 City Workspace。 */ close(): Promise; /** 将已创建 Agent 加入集合并建立唯一 City 绑定。 */ private add_agent; /** Agent 自行释放时清除 City 运行时引用。 */ release_agent(agent: { readonly id: string; }): void; /** 把宿主按需解析出的 Workspace 纳入 City 资源索引。 */ private add_workspace; /** 将 City 的底层 Storage 绑定到 Workspace 的 Shell 运行目录。 */ private bind_workspace_shell; /** 拒绝在 City 关闭后继续注入运行时资源。 */ private assert_active; /** 串行执行一次 City transport 组合操作。 */ private enqueue_transport_operation; } //# sourceMappingURL=City.d.ts.map