Skip to content

feat: bili daemon 子命令——每会话动态端口起代理(native 模式 A) #518

Description

@ranxianglei

来源: #513 分析 native 模式时拆出的子任务(owner 已确认方案)。

新增薄子命令 bili daemon:供 agent 侧插件动态启动每会话专属代理。

需求:

  • 复用 src/launcher.ts 现有 ensureProxyRunning 流程(probe/spawn/launch token 握手/EADDRINUSE 重试);--fresh 语义:跳过 attach,总是新起实例(每会话隔离,探索如何发布为native模式 #513 owner 拍板)
  • 端口动态分配(bind-0 试探或 EADDRINUSE 回退),不用静态端口
  • per-session 结果文件:父进程建临时路径经 env(如 BILI_RESULT_FILE)传给 child;child 绑定成功后原子写 {origin, pid, launchToken};父进程只轮询自己的文件。全局 instance file 照写(MCP shell/install 用,last-writer-wins 可接受)
  • BILI_PARENT_PID=<宿主进程pid>,复用现有 Windows 上 launcher 子代理从无优雅退出:stopProxy 直接 TerminateProcess,SIGBREAK-flush 全史 0 次触发,防抖窗状态+进行中轮被拦腰 #414 父进程监视机制在 agent 退出时自动回收代理
  • 启动成功后向 stdout 输出单行 JSON {origin, port, pid, logPath} 并 exit 0;失败 exit 非零 + stderr 说明
  • 测试:单测(沿用 launcher 测试的 deps 注入模式)+ 集成测试(真起进程、解析 JSON、清理)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions