work-ally 0.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/AGENTS.md +110 -0
  2. package/DASHBOARD.md +160 -0
  3. package/PRODUCT.md +113 -0
  4. package/README.md +403 -0
  5. package/ally.sh +171 -0
  6. package/bridge/src/approval-rules.ts +360 -0
  7. package/bridge/src/channel-delivery.ts +207 -0
  8. package/bridge/src/channel-types.ts +22 -0
  9. package/bridge/src/channels/fake/adapter.ts +31 -0
  10. package/bridge/src/channels/feishu/adapter.ts +411 -0
  11. package/bridge/src/channels/feishu/approvals.ts +6 -0
  12. package/bridge/src/channels/feishu/formatter.ts +276 -0
  13. package/bridge/src/channels/feishu/normalize.ts +368 -0
  14. package/bridge/src/codex-config.ts +52 -0
  15. package/bridge/src/config.ts +240 -0
  16. package/bridge/src/fake-runtime-client.ts +505 -0
  17. package/bridge/src/handoff-service.ts +494 -0
  18. package/bridge/src/logger.ts +194 -0
  19. package/bridge/src/memory-digest.ts +186 -0
  20. package/bridge/src/receiver-approval-autonomy.ts +158 -0
  21. package/bridge/src/receiver-control-core.ts +140 -0
  22. package/bridge/src/receiver-control-work-session.ts +218 -0
  23. package/bridge/src/receiver-control.ts +83 -0
  24. package/bridge/src/receiver-delivery.ts +136 -0
  25. package/bridge/src/receiver-helpers.ts +96 -0
  26. package/bridge/src/receiver-human-gate.ts +333 -0
  27. package/bridge/src/receiver-inbound-preflight.ts +162 -0
  28. package/bridge/src/receiver-recovery.ts +236 -0
  29. package/bridge/src/receiver-runtime-callbacks.ts +367 -0
  30. package/bridge/src/receiver-runtime-policy.ts +132 -0
  31. package/bridge/src/receiver-runtime-state.ts +124 -0
  32. package/bridge/src/receiver-support-actions.ts +189 -0
  33. package/bridge/src/receiver-thread-start.ts +57 -0
  34. package/bridge/src/receiver-turn-coordination.ts +94 -0
  35. package/bridge/src/receiver-turn-execution.ts +257 -0
  36. package/bridge/src/receiver-turn-failure.ts +143 -0
  37. package/bridge/src/receiver-turn-result.ts +185 -0
  38. package/bridge/src/receiver-turn-steer.ts +70 -0
  39. package/bridge/src/receiver-work-session.ts +76 -0
  40. package/bridge/src/receiver.ts +329 -0
  41. package/bridge/src/router.ts +62 -0
  42. package/bridge/src/runtime-client-agent-messages.ts +150 -0
  43. package/bridge/src/runtime-client-message-dispatch.ts +176 -0
  44. package/bridge/src/runtime-client-protocol.ts +411 -0
  45. package/bridge/src/runtime-client-request-ops.ts +56 -0
  46. package/bridge/src/runtime-client-run-turn.ts +158 -0
  47. package/bridge/src/runtime-client-thread-ops.ts +270 -0
  48. package/bridge/src/runtime-client-transport.ts +309 -0
  49. package/bridge/src/runtime-client-turn-poll.ts +224 -0
  50. package/bridge/src/runtime-client-turn-read.ts +185 -0
  51. package/bridge/src/runtime-client-turn-state.ts +105 -0
  52. package/bridge/src/runtime-client.ts +344 -0
  53. package/bridge/src/runtime-user-input.ts +403 -0
  54. package/bridge/src/scheduler.ts +239 -0
  55. package/bridge/src/server-handoff-command.ts +364 -0
  56. package/bridge/src/server-main.ts +80 -0
  57. package/bridge/src/server-routine-command.ts +60 -0
  58. package/bridge/src/server-routine-execution.ts +222 -0
  59. package/bridge/src/server-runtime-app-support.ts +107 -0
  60. package/bridge/src/server-runtime-app.ts +238 -0
  61. package/bridge/src/server-thread-sync-command.ts +63 -0
  62. package/bridge/src/server.ts +17 -0
  63. package/bridge/src/session-store-delivery.ts +220 -0
  64. package/bridge/src/session-store-human-gate.ts +380 -0
  65. package/bridge/src/session-store-inbound-acceptance.ts +66 -0
  66. package/bridge/src/session-store-meta.ts +134 -0
  67. package/bridge/src/session-store-turn-ledger.ts +272 -0
  68. package/bridge/src/session-store.ts +380 -0
  69. package/bridge/src/system-notify.ts +220 -0
  70. package/bridge/src/thread-sync.ts +200 -0
  71. package/bridge/src/translator.ts +494 -0
  72. package/bridge/src/types.ts +289 -0
  73. package/bridge/src/utils.ts +104 -0
  74. package/bridge/src/work-session-store.ts +471 -0
  75. package/docs/.gitkeep +0 -0
  76. package/docs/architecture/codex-feishu-bridge-proposal.md +2742 -0
  77. package/docs/completed/FEATURE-feishu-markdown-and-reply-support.md +327 -0
  78. package/docs/completed/README.md +21 -0
  79. package/docs/completed/SPEC-approval-autonomy-and-safe-defaults.md +205 -0
  80. package/docs/completed/SPEC-approval-batch-and-strict-reply-shortcuts.md +153 -0
  81. package/docs/completed/SPEC-conversation-noise-reduction-and-busy-input-gate.md +538 -0
  82. package/docs/completed/SPEC-engineering-sop-skillization.md +190 -0
  83. package/docs/completed/SPEC-faithful-bridge-core-thinning-v2.md +376 -0
  84. package/docs/completed/SPEC-faithful-bridge-core-thinning.md +1071 -0
  85. package/docs/completed/SPEC-group-chat-sender-identity.md +301 -0
  86. package/docs/completed/SPEC-middleware-exception-visibility.md +227 -0
  87. package/docs/completed/SPEC-nightly-memory-digest-visibility.md +121 -0
  88. package/docs/completed/SPEC-project-group-chat-human-centered-conversation-mapping.md +326 -0
  89. package/docs/completed/SPEC-remove-cli-persona-bootstrap.md +201 -0
  90. package/docs/developer-workflow.md +49 -0
  91. package/docs/implementation/SPEC-codex-same-machine-session-handoff-implementation.md +239 -0
  92. package/docs/implementation/test-coverage-map.md +363 -0
  93. package/docs/implementation/work-ally-implementation-guide.md +790 -0
  94. package/docs/issues/README.md +10 -0
  95. package/docs/issues/pending/ANALYSIS-ally-premature-recovery-notice-and-task-state-semantics-2026-03-18.md +295 -0
  96. package/docs/issues/resolved/ANALYSIS-approval-waiting-visible-but-approval-artifact-missing-2026-03-16.md +466 -0
  97. package/docs/issues/resolved/ANALYSIS-blocking-state-visible-without-user-actionable-artifact-2026-03-16.md +261 -0
  98. package/docs/issues/resolved/ANALYSIS-codex-app-server-transport-disconnect-semantics-2026-03-14.md +606 -0
  99. package/docs/issues/resolved/ANALYSIS-premature-terminalization-on-fresh-thread-poll-and-object-error-leak-2026-03-16.md +348 -0
  100. package/docs/issues/resolved/ANALYSIS-runtime-turn-delivery-and-recovery-2026-03-14.md +603 -0
  101. package/docs/issues/resolved/ANALYSIS-self-test-gap-approval-waiting-visible-but-approval-artifact-missing-2026-03-16.md +166 -0
  102. package/docs/issues/resolved/ANALYSIS-self-test-gap-blocking-state-visible-without-user-actionable-artifact-2026-03-16.md +186 -0
  103. package/docs/issues/resolved/ANALYSIS-self-test-gap-premature-terminalization-on-fresh-thread-poll-and-object-error-leak-2026-03-16.md +166 -0
  104. package/docs/issues/resolved/REPORT-ally-runtime-turn-delivery-3b42fb8-2026-03-15.md +373 -0
  105. package/docs/manual-acceptance.md +127 -0
  106. package/docs/ops-runbook.md +44 -0
  107. package/docs/planning/FEATURE-memory-system.md +748 -0
  108. package/docs/planning/SPEC-active-turn-steer-and-context-compaction-visibility.md +269 -0
  109. package/docs/planning/SPEC-approval-rules-inheritance-and-local-validation-lane.md +450 -0
  110. package/docs/planning/SPEC-assistant-persona-bootstrap.md +199 -0
  111. package/docs/planning/SPEC-assistant-rename.md +610 -0
  112. package/docs/planning/SPEC-bridge-app-server-protocol-alignment.md +667 -0
  113. package/docs/planning/SPEC-claude-runtime-host-for-work-ally.md +434 -0
  114. package/docs/planning/SPEC-cli-feishu-codex-session-unification.md +236 -0
  115. package/docs/planning/SPEC-codex-same-machine-session-handoff.md +873 -0
  116. package/docs/planning/SPEC-feishu-reaction-shortcuts.md +282 -0
  117. package/docs/planning/SPEC-local-stable-release-boundary.md +166 -0
  118. package/docs/planning/SPEC-managed-thread-entry-and-surface-mobility.md +862 -0
  119. package/docs/planning/SPEC-minimal-bridge-semantics-and-user-visible-surface.md +362 -0
  120. package/docs/planning/SPEC-npm-alpha-distribution-and-install-first-release.md +222 -0
  121. package/docs/planning/SPEC-remove-websocket-runtime-transport.md +364 -0
  122. package/docs/planning/SPEC-runtime-abstraction-phase-1.md +424 -0
  123. package/docs/planning/SPEC-runtime-connection-and-turn-recovery-semantics.md +274 -0
  124. package/docs/planning/SPEC-session-presence-and-state-visibility.md +397 -0
  125. package/docs/planning/SPEC-skill-first-capability-packaging.md +338 -0
  126. package/docs/planning/SPEC-stable-archive-contract.md +456 -0
  127. package/docs/planning/SPEC-supervised-start-boundary.md +127 -0
  128. package/docs/planning/SPEC-user-barrier-reduction-and-activation.md +832 -0
  129. package/docs/planning/ally-next.md +1278 -0
  130. package/docs/planning/assistant-workbench-spec.md +725 -0
  131. package/docs/planning/product-workbench.md +283 -0
  132. package/docs/product-onboarding.md +227 -0
  133. package/docs/product-spec-standard.md +528 -0
  134. package/docs/troubleshooting.md +45 -0
  135. package/docs/user-quickstart.md +46 -0
  136. package/internal/dispatch.sh +95 -0
  137. package/internal/lib/common.sh +1450 -0
  138. package/internal/modules/assistant/manage.sh +1312 -0
  139. package/internal/modules/bootstrap/setup.sh +144 -0
  140. package/internal/modules/config/init-env.sh +10 -0
  141. package/internal/modules/global/manage.sh +154 -0
  142. package/internal/modules/handoff/manage.sh +54 -0
  143. package/internal/modules/mcp/manage.sh +83 -0
  144. package/internal/modules/ops/logs.sh +76 -0
  145. package/internal/modules/routines/manage.sh +55 -0
  146. package/internal/modules/runtime/assistant-autosave.sh +26 -0
  147. package/internal/modules/runtime/restart.sh +6 -0
  148. package/internal/modules/runtime/start.sh +283 -0
  149. package/internal/modules/runtime/status.sh +194 -0
  150. package/internal/modules/runtime/stop.sh +55 -0
  151. package/internal/modules/runtime/supervisor.sh +216 -0
  152. package/internal/modules/runtime/update.sh +26 -0
  153. package/package.json +41 -0
  154. package/runtime/config/.gitkeep +0 -0
  155. package/runtime/host/.gitkeep +0 -0
  156. package/runtime/host/healthcheck-codex-app-server.ts +22 -0
  157. package/runtime/host/ping-pong-codex-app-server.ts +66 -0
  158. package/runtime/host/probe-codex-app-server.ts +115 -0
  159. package/skills/archive-reader/SKILL.md +9 -0
  160. package/skills/feishu-production-debug/SKILL.md +37 -0
  161. package/skills/feishu-production-debug/references/feishu-debug-order.md +49 -0
  162. package/skills/feishu-production-debug/references/platform-permission-baseline.md +23 -0
  163. package/skills/issue-to-spec-triage/SKILL.md +44 -0
  164. package/skills/issue-to-spec-triage/references/triage-rules.md +66 -0
  165. package/skills/memory-digest/SKILL.md +9 -0
  166. package/skills/post-implementation-closure/SKILL.md +39 -0
  167. package/skills/post-implementation-closure/references/closure-checklist.md +45 -0
  168. package/skills/post-implementation-closure/references/doc-drift-map.md +49 -0
  169. package/skills/product-spec/SKILL.md +244 -0
  170. package/templates/env.example +5 -0
  171. package/templates/routines/nightly-memory-digest.yaml +10 -0
  172. package/templates/workspace/AGENTS.md +26 -0
@@ -0,0 +1,364 @@
1
+ # SPEC: Remove WebSocket Runtime Transport
2
+
3
+ 更新时间:2026-03-17
4
+ 状态:Ready for implementation
5
+ Owner:work-ally engineering
6
+ 相关文档:
7
+ - `docs/planning/SPEC-bridge-app-server-protocol-alignment.md`
8
+ - `docs/planning/SPEC-runtime-connection-and-turn-recovery-semantics.md`
9
+ - `docs/issues/resolved/ANALYSIS-codex-app-server-transport-disconnect-semantics-2026-03-14.md`
10
+
11
+ ## 1. Summary
12
+
13
+ 本 spec 的目标很直接:
14
+
15
+ > 把 `work-ally` 中 `bridge <-> Codex App Server` 的 websocket transport 整条链删干净,改成本机默认 `stdio` child-process transport。
16
+
17
+ 理由也很直接:
18
+
19
+ 1. websocket 在官方语义里不是默认稳定基线,而是 experimental transport
20
+ 2. 对当前产品来说,它没有提供独立产品能力
21
+ 3. 它却引入了额外的 runtime-host 进程、listen 地址、端口分配、重连状态机、health/state 文件、排障面和测试面
22
+ 4. 既然 bridge 的最终正确性已经转向 pull-primary + ledger,那么 websocket 不再承担真相职责;此时继续保留它,只剩复杂度成本
23
+
24
+ 本次改动不是“顺手优化 transport”,而是一次架构收口:
25
+
26
+ 1. bridge 直接拉起 `codex app-server --listen stdio://`
27
+ 2. bridge 通过 stdio 双向 JSON-RPC 与其通信
28
+ 3. 删除 runtime-host websocket 守护、listen URL 分配和对应运维概念
29
+ 4. 保留 pull-primary、ledger、approval/user-input、final-reply redelivery 等上层语义不变
30
+
31
+ 一句话:**功能不变,transport 变薄,稳定性与可维护性上升。**
32
+
33
+ ## 2. 背景
34
+
35
+ 前一轮协议对齐已经收口了一个关键判断:
36
+
37
+ 1. bridge 不该再把 transport 生命周期误判成任务真相
38
+ 2. 最终结果应继续以 `thread/read(includeTurns=true)` 为 pull-primary 真相源
39
+ 3. 在线事件只作为实时体验增强和协议事实缓存
40
+
41
+ 这意味着 websocket 已经从“正确性基石”降级为“运输层实现细节”。
42
+
43
+ 既然如此,就要继续追问一句:
44
+
45
+ > 这个实现细节本身还有没有独立价值?
46
+
47
+ 当前答案是:没有。
48
+
49
+ 当前 websocket 链条带来的额外复杂度包括:
50
+
51
+ 1. `runtime-host` 独立后台进程
52
+ 2. `WORK_ALLY_CODEX_LISTEN` / `listenUrl` / runtime.env / health.json
53
+ 3. 端口选择、冲突重试、allocator lock
54
+ 4. websocket connect/close/reconnect 状态机
55
+ 5. shell 验证依赖 loopback listen
56
+ 6. 运维文档里大量 `runtime-host listen` / `runtime-host` 状态说明
57
+
58
+ 这些东西并不提升用户能力,只是在维护 transport 本身。
59
+
60
+ ## 3. 问题定义
61
+
62
+ 当前 websocket transport 的问题不是“偶尔断一下”,而是它形成了一整条本不该存在的产品内部子系统。
63
+
64
+ ### 3.1 多出来的进程层
65
+
66
+ 当前本机路径是:
67
+
68
+ 1. `ally start`
69
+ 2. 启动 `runtime-host` 后台进程
70
+ 3. `runtime-host` 以 `codex app-server --listen ws://127.0.0.1:PORT` 运行
71
+ 4. bridge 再通过 websocket 连接它
72
+
73
+ 这让产品多了一层无谓的进程边界。
74
+
75
+ ### 3.2 多出来的地址层
76
+
77
+ 当前为了 websocket,需要维护:
78
+
79
+ 1. listen URL 选择
80
+ 2. runtime 状态文件中的 `WORK_ALLY_CODEX_LISTEN`
81
+ 3. health 中的 `listen`
82
+ 4. 用户侧 `ally status` 中的 `runtime-host listen`
83
+
84
+ 这些都不是用户需要的产品概念。
85
+
86
+ ### 3.3 多出来的故障层
87
+
88
+ 当前 transport 一旦出问题,系统就多出一整类本可避免的故障:
89
+
90
+ 1. loopback listen 失败
91
+ 2. 端口冲突
92
+ 3. runtime-host 活着但 websocket 会话失效
93
+ 4. reconnect 行为与 pull-primary 叠加后的复杂语义
94
+
95
+ ### 3.4 多出来的测试层
96
+
97
+ 当前 shell 与 unit 测试里不得不覆盖:
98
+
99
+ 1. listen URL 选择
100
+ 2. runtime-host 存活
101
+ 3. websocket close/reconnect
102
+ 4. probe/ping-pong 依赖 listen 地址
103
+
104
+ 这会拖慢门禁,也让测试地图偏离真正要守的产品合同。
105
+
106
+ ## 4. 为什么现在做
107
+
108
+ 现在适合做,而不是以后。
109
+
110
+ 1. 前一轮协议语义已经先收好了,transport 可以单独切,不会再和任务语义混改
111
+ 2. 当前产品还处于内部打磨期,可以接受一次 clean break
112
+ 3. 如果继续拖,更多 shell、desktop、文档、运营口径都会继续建立在 `runtime-host/ws` 之上
113
+ 4. 这个复杂度没有业务价值,越早删越好
114
+
115
+ ## 5. 目标
116
+
117
+ 本次改动必须达成以下目标:
118
+
119
+ 1. bridge 默认直接使用 `stdio` transport 与 `codex app-server` 通信
120
+ 2. bridge 负责拉起和管理自己的 runtime child process,不再依赖 websocket listen 地址
121
+ 3. 删除 `WORK_ALLY_CODEX_LISTEN`、runtime listen state、port allocator 这条链
122
+ 4. 删除 `runtime-host` 作为单独后台服务的概念;用户运维口径只保留 bridge / supervisor / autosave
123
+ 5. pull-primary、approval、user-input、redelivery、ledger 等上层行为保持不变
124
+ 6. shell / unit / integration 门禁同步迁移到 stdio 主路径
125
+ 7. 文档、README、status 输出、runbook 不再暴露 websocket/runtime-host listen 概念
126
+
127
+ ## 6. 非目标
128
+
129
+ 这次明确不做:
130
+
131
+ 1. 不改变 Feishu 通道实现
132
+ 2. 不重写 approval / user-input / session-store 语义
133
+ 3. 不把 bridge 和 Codex 变成远程分布式架构
134
+ 4. 不在本期保留 websocket 作为并行 fallback transport
135
+ 5. 不为了兼容旧状态而长期保留 runtime-host 双轨逻辑
136
+
137
+ 原则:**不搞双轨长期并存。**
138
+
139
+ ## 7. 新模型
140
+
141
+ ### 7.1 运行模型
142
+
143
+ 新模型应改为:
144
+
145
+ 1. `ally start`
146
+ 2. `supervisor` 拉起 `bridge`
147
+ 3. `bridge` 内部按需启动 `codex app-server --listen stdio://`
148
+ 4. `CodexRuntimeClient` 通过子进程 `stdin/stdout` 做 JSON-RPC
149
+
150
+ 也就是说,runtime 不再是 bridge 外面的“另一个服务”,而是 bridge 直接管理的本地 child process。
151
+
152
+ ### 7.2 生命周期
153
+
154
+ 1. bridge 启动时,先拉起 app-server child
155
+ 2. bridge 停止时,一并停止 child
156
+ 3. child 异常退出时,bridge 将其视为 runtime transport failure,并继续沿现有 pull-primary / recovery 语义处理
157
+ 4. supervisor 不再单独托管 runtime-host,只托管 bridge 与 assistant-autosave
158
+
159
+ ### 7.3 健康语义
160
+
161
+ 对用户和运维侧只保留:
162
+
163
+ 1. `bridge` 是否运行
164
+ 2. bridge 内部 runtime 是否 healthy
165
+
166
+ 不再单独输出:
167
+
168
+ 1. `runtime-host pid`
169
+ 2. `runtime-host listen`
170
+ 3. `WORK_ALLY_CODEX_LISTEN`
171
+
172
+ 必要时 bridge health 可以包含:
173
+
174
+ 1. `runtime_status: healthy|degraded|stopped`
175
+ 2. `runtime_reason`
176
+
177
+ 但这属于 bridge 内部健康事实,不再暴露为独立 transport 面板。
178
+
179
+ ## 8. 机制设计
180
+
181
+ ### 8.1 Runtime Client 抽象
182
+
183
+ `CodexRuntimeClient` 需要从“websocket client”重构为“app-server transport client”。
184
+
185
+ 最小拆分:
186
+
187
+ 1. 保留 JSON-RPC 协议逻辑、turn state、pull-primary、approval/user-input 解析
188
+ 2. 替换底层 transport:
189
+ - 从 `WebSocket` 读写
190
+ - 改为 child process `stdin/stdout` 读写
191
+ 3. `connect()` 的含义从“建立 ws 连接”变成“确保 child process 已存在且 initialize 完成”
192
+ 4. `disconnect()` 的含义从“关闭 websocket”变成“停止 child process 并清理 pending request”
193
+
194
+ ### 8.2 Child Process 管理
195
+
196
+ bridge 内部需要:
197
+
198
+ 1. `spawn('codex', ['app-server', '--listen', 'stdio://'])`
199
+ 2. 绑定 `stdin/stdout/stderr`
200
+ 3. 逐行读取 stdout JSONL
201
+ 4. stderr 只进日志,不作为协议通道
202
+ 5. 子进程退出时统一走 runtime disconnect/recovery 逻辑
203
+
204
+ ### 8.3 配置模型
205
+
206
+ 删除:
207
+
208
+ 1. `runtime.listenUrl`
209
+ 2. `WORK_ALLY_CODEX_LISTEN`
210
+ 3. runtime.env 中的 listen state
211
+
212
+ 保留:
213
+
214
+ 1. `runtime.mode`
215
+ 2. `approvalPolicy`
216
+ 3. `sandboxMode`
217
+ 4. assistant `codexHome`
218
+
219
+ 如需显式 transport 配置,最多保留内部字段:
220
+
221
+ 1. `runtime.transport = stdio`
222
+
223
+ 但默认不需要暴露给用户。
224
+
225
+ ### 8.4 Shell / Supervisor / Status
226
+
227
+ 需要同步修改:
228
+
229
+ 1. `internal/modules/runtime/start.sh`
230
+ - 不再启动独立 runtime-host
231
+ - bridge 启动前不再做 listen URL 分配
232
+ 2. `internal/modules/runtime/supervisor.sh`
233
+ - 不再维护 runtime-host 子进程
234
+ 3. `internal/modules/runtime/status.sh`
235
+ - 删除 `runtime-host listen`
236
+ - 删除 runtime-host 独立 pid/health 展示
237
+ - 只展示 bridge 与其内部 runtime 健康
238
+ 4. `internal/lib/common.sh`
239
+ - 删除 runtime listen state / allocator / healthcheck shell 路径
240
+
241
+ ### 8.5 Probe / Ping-Pong 工具
242
+
243
+ `runtime/host/*.ts` 这些 websocket/listen probe 脚本需要改造或删除。
244
+
245
+ 建议:
246
+
247
+ 1. 保留“真实 codex app-server 探针”这个能力
248
+ 2. 但探针改成直接走 stdio child-process,而不是依赖外部 listen URL
249
+ 3. `find-open-listen-url.ts` 可直接删除
250
+
251
+ ## 9. 用户与维护者可见变化
252
+
253
+ ### 9.1 用户侧
254
+
255
+ 用户不应感知功能变化。
256
+
257
+ 仍然保持:
258
+
259
+ 1. `ally start`
260
+ 2. `ally stop`
261
+ 3. `ally status`
262
+
263
+ 用户侧变化只体现在:
264
+
265
+ 1. 少一层无意义的 runtime-host 概念
266
+ 2. 少一类 transport/listen/端口相关故障
267
+
268
+ ### 9.2 维护者侧
269
+
270
+ 维护者会看到:
271
+
272
+ 1. `ally status` 不再显示 `runtime-host listen`
273
+ 2. runbook 不再教人看 `WORK_ALLY_CODEX_LISTEN`
274
+ 3. shell 验证不再依赖 loopback listen 权限
275
+
276
+ ## 10. 验收标准
277
+
278
+ ### 10.1 功能行为
279
+
280
+ 1. 普通 Feishu / fake channel 对话仍可完成完整 turn
281
+ 2. approval / user-input / `/stop` / recovery / redelivery 行为不回归
282
+ 3. routines 仍可调用真实 Codex runtime
283
+
284
+ ### 10.2 架构行为
285
+
286
+ 1. 仓库主链路中不再依赖 websocket listen URL
287
+ 2. `runtime-host` 不再作为独立后台服务存在
288
+ 3. `WORK_ALLY_CODEX_LISTEN` 不再是默认主路径配置
289
+ 4. `find-open-listen-url.ts`、port allocator、runtime.env listen state 被清理
290
+
291
+ ### 10.3 文档行为
292
+
293
+ 1. README / quickstart / runbook / troubleshooting 不再把 websocket runtime-host 当默认模型
294
+ 2. 测试地图同步反映 stdio 主路径
295
+
296
+ ### 10.4 自动化门禁
297
+
298
+ 至少通过:
299
+
300
+ 1. `node --test tests/unit/runtime/**/*.test.mjs tests/unit/session/**/*.test.mjs tests/integration/session/**/*.test.mjs`
301
+ 2. 相关 shell smoke(尤其 `tests/shell/codex-runtime.sh`、`tests/shell/status-health.sh`、`tests/shell/smoke.sh`)
302
+ 3. 必要时更新 `tests/fixtures/empty-work-ally-home/releases/stable/`
303
+
304
+ ## 11. 子任务拆解
305
+
306
+ ### A. Runtime client transport 改造
307
+
308
+ 1. 抽离 JSON-RPC codec 与 transport
309
+ 2. 用 stdio child-process 替换 websocket transport
310
+ 3. 保持现有 runTurn / pull-primary / approval / user-input / recoverTurnResult 接口不变
311
+
312
+ ### B. Runtime lifecycle 清理
313
+
314
+ 1. 删除 runtime-host listen state
315
+ 2. 删除 allocator / runtime.env listen
316
+ 3. 删除独立 runtime-host supervisor 管理
317
+
318
+ ### C. Shell / probe / status 收口
319
+
320
+ 1. 重写真实 codex runtime shell 测试为 stdio 模式
321
+ 2. 重写 probe/ping-pong 工具
322
+ 3. 更新 `ally status` 输出
323
+
324
+ ### D. 文档与测试地图收口
325
+
326
+ 1. README
327
+ 2. user quickstart
328
+ 3. ops runbook / troubleshooting
329
+ 4. test coverage map
330
+
331
+ ## 12. 风险
332
+
333
+ ### 风险 1:child-process 管理不当导致 bridge 停止时残留 Codex 进程
334
+
335
+ 应对:
336
+
337
+ 1. 明确 `disconnect()` / process exit cleanup
338
+ 2. shell 测试补 stop/restart 场景
339
+
340
+ ### 风险 2:stdio JSONL 处理有边界差异
341
+
342
+ 应对:
343
+
344
+ 1. 先做最小真实 probe
345
+ 2. 保持现有 fake runtime 和高密度 unit/integration 测试不动,上层接口不变
346
+
347
+ ### 风险 3:status/runbook 一次没清干净,留下旧口径
348
+
349
+ 应对:
350
+
351
+ 1. 全仓 `rg websocket|listenUrl|runtime-host listen|WORK_ALLY_CODEX_LISTEN`
352
+ 2. 逐项清理 shipped 文档
353
+
354
+ ## 13. 完成定义
355
+
356
+ 只有同时满足以下条件,才算这次“删干净”:
357
+
358
+ 1. bridge 默认运行不再依赖 websocket listen URL
359
+ 2. `runtime-host` 独立后台服务已从默认模型删除
360
+ 3. `CodexRuntimeClient` 已以 stdio child-process 为主路径
361
+ 4. shell、unit、integration 测试已更新并通过
362
+ 5. README / runbook / status / troubleshooting 已无旧 websocket 主模型口径
363
+ 6. 用户不需要知道 `listen`、端口、runtime-host 这些中间概念
364
+