DAG总览 / 组目录 / G02 API 网关与控制器

dsh-api-gateway · @deepseek-ai/dsh-api-gateway

Layer 3G02
目录:ACP 协议API 网关与控制器附件启动与插件管理客户端运行时客户端 UI 包上下文压缩上下文注入核心运行时凭据与授权交付物文档处理实验特性宿主扩展反馈通道文件系统目标与计划工具守卫Hooks 扩展宿主服务交互命令作业调度LLM 适配LSP 集成MCP 协议规划模式Agent 预设代码执行运行时运行时诊断沙箱定时调度SDK 与协议会话核心会话检索设置Shell 执行技能溢出存储SSH 远程执行存储子代理子进程终端待办类型契约框架 vendorWeb 访问Webhook工作流工作区
依赖链 · 上游(该插件依赖的前驱):
依赖链 · 下游(依赖该插件的节点):
同一拓扑层(Layer 3,层次遍历层序):
↑ Layer 2(11 插件)Layer 3↓ Layer 4(13 插件)

插件信息

包名@deepseek-ai/dsh-api-gateway
分组G02 · API 网关与控制器
拓扑层Layer 3(层次遍历:被依赖方先于依赖方)
源码路径packages/api/gateway

① 实现逻辑

Host 侧 TypertGatewayService 继承 Service 并实现 TypertGateway,构造时向 connection 注册 /api RPC 拦截器、向 webServer 注册 WebSocket 多路复用路由 /api/remote.mux(存在 appReady 时等待其就绪再监听)(src/index.ts:226-277)。invoke/stream 经 prepareInvocation 解析 Typert 描述符(严格定义或 SRC 回退)、校验精确参数、解析 lookup/context provider,再以 Reflect.apply 调用业务方法并把结果编码为 RPC 结果 (src/index.ts:345-410, 686-877)。registerRemoteEvents 消费应用选定的唯一事件源:emit 通知广播给各客户端,Agent 作用域 waterfall 以事件 id 关联并在收到结果后继续/取消 (src/index.ts:285-311, 463-655)。客户端侧 apply() 安装 ClientRemoteService,暴露 ctx.remote 与 $stream/$host (src/client/index.ts:140-199)。

内部结构动态 DAG(深色主题:橙色=上游依赖 · 绿色=下游依赖 · 棕色=外部seam · 蓝=本插件)
本插件 上游依赖 下游依赖 外部 seam

② 注册/提供(provides)

③ 依赖(depends_on · 上游前驱)

dsh-client-connectionE1+E2
承载 /api RPC 与对等 Peer 身份
src/index.ts:14 import + src/index.ts:233 connection.rpc.intercept
dsh-host-webserverE2
注册 WebSocket upgrade 路由
src/index.ts:16 import type + src/index.ts:261 webServer.registerUpgrade

④ 被依赖(dependents · 下游消费者)

dsh-api-job-controller
客户端 Remote 载体
src/client/service.ts:11 import + src/client/model.ts:5 import
dsh-api-remotes
注册转发事件源并使用客户端 Remote 载体
src/index.ts:6 import type + src/index.ts:42 ctx.typertGateway.registerRemoteEvents
dsh-api-session-controller
客户端 Remote 载体与失败类型
src/client/scope.ts:4 import + src/client/sessions/manager.ts:15 import
dsh-api-terminal-controller
客户端 Remote 载体
src/client/index.ts:5 import + src/client/model.ts:5 import
dsh-api-workspace-controller
客户端 Remote 载体
src/client/model.ts:5 import
dsh-api-workspace-files
客户端 Remote 载体
src/client/index.ts:9 import + src/client/remote.ts:6 import
dsh-client-ui-open-in-app
引入 gateway 客户端的 ctx.remote 声明合并
src/client/index.ts:14 import type {}
dsh-client-ui-sidebar-documentpreview
引入网关客户端面与其类型合并
src/client/index.ts:20 import (client)
dsh-experimental-client-ui-voice-input
经网关检测语音后端可用性
src/client/readiness.ts:3 import '@deepseek-ai/dsh-api-gateway/client'
dsh-experimental-webworker-runtime
把 typert 流经 tunnel 转发到页面
src/worker-host.ts:26 import type { TypertGateway }