qwen-audio-agent 0.9.0

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 (122) hide show
  1. package/CONTRIBUTING.md +58 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +5 -0
  4. package/PRIVACY.md +34 -0
  5. package/README.md +282 -0
  6. package/README_EN.md +316 -0
  7. package/SECURITY.md +32 -0
  8. package/THIRD_PARTY_NOTICES.md +26 -0
  9. package/cli/bin/qwenaudio.mjs +10 -0
  10. package/cli/package.json +13 -0
  11. package/cli/src/arguments.mjs +247 -0
  12. package/cli/src/gateway-service.mjs +386 -0
  13. package/cli/src/instance-lock.mjs +65 -0
  14. package/cli/src/launcher.mjs +217 -0
  15. package/cli/src/runtime.mjs +356 -0
  16. package/cli/src/webui.mjs +61 -0
  17. package/config/acp/workspace/AGENTS.md +13 -0
  18. package/config/codebuddy/workspace/.codebuddy/models.json +19 -0
  19. package/config/codebuddy/workspace/AGENTS.md +13 -0
  20. package/config/codex/workspace/AGENTS.md +13 -0
  21. package/config/frontend-agent/PROMPT.md +127 -0
  22. package/config/hermes/workspace/AGENTS.md +13 -0
  23. package/config/openclaw/openclaw.json5 +50 -0
  24. package/config/openclaw/workspace/AGENTS.md +9 -0
  25. package/config/opencode/agents/qwen-audio-agent-backend.md +65 -0
  26. package/config/opencode/workspace/AGENTS.md +16 -0
  27. package/config/qoder/workspace/AGENTS.md +16 -0
  28. package/docs/architecture-overview-en.png +0 -0
  29. package/docs/architecture-overview.png +0 -0
  30. package/docs/architecture.md +332 -0
  31. package/docs/configuration.md +386 -0
  32. package/docs/desktop-fluid-orb-thinking.gif +0 -0
  33. package/docs/desktop-goo-orb-thinking.gif +0 -0
  34. package/docs/qwen-audio-agent-three-layer-architecture-en.png +0 -0
  35. package/docs/qwen-audio-agent-three-layer-architecture.png +0 -0
  36. package/package.json +126 -0
  37. package/scripts/audit-dependencies.mjs +109 -0
  38. package/scripts/check-desktop-release-env.mjs +41 -0
  39. package/scripts/codex-acp +58 -0
  40. package/scripts/install-global.mjs +66 -0
  41. package/scripts/openclaw +194 -0
  42. package/scripts/openclaw-gateway +8 -0
  43. package/scripts/opencode-acp +6 -0
  44. package/scripts/opencode-server +179 -0
  45. package/scripts/prepare-build.mjs +38 -0
  46. package/scripts/release-check +182 -0
  47. package/scripts/set-version.mjs +133 -0
  48. package/scripts/start.mjs +43 -0
  49. package/scripts/verify-package.mjs +109 -0
  50. package/server/package.json +18 -0
  51. package/server/src/agent/acp-backend-adapter.mjs +1138 -0
  52. package/server/src/agent/acp-backend-profile.mjs +35 -0
  53. package/server/src/agent/acp-backend-session-utils.mjs +139 -0
  54. package/server/src/agent/acp-process-client.mjs +447 -0
  55. package/server/src/agent/acp-session-registry.mjs +106 -0
  56. package/server/src/agent/acp-session-tools.mjs +257 -0
  57. package/server/src/agent/agent-client.mjs +218 -0
  58. package/server/src/agent/backend-adapter.mjs +15 -0
  59. package/server/src/agent/backend-agent-instructions.mjs +8 -0
  60. package/server/src/agent/backends/codebuddy.mjs +47 -0
  61. package/server/src/agent/backends/codex.mjs +62 -0
  62. package/server/src/agent/backends/generic-acp.mjs +46 -0
  63. package/server/src/agent/backends/hermes.mjs +29 -0
  64. package/server/src/agent/backends/openclaw.mjs +101 -0
  65. package/server/src/agent/backends/opencode.mjs +36 -0
  66. package/server/src/agent/backends/qoder.mjs +47 -0
  67. package/server/src/agent/backends/registry.mjs +32 -0
  68. package/server/src/agent/backends/shared.mjs +46 -0
  69. package/server/src/agent/coordinator.mjs +308 -0
  70. package/server/src/agent/openclaw-adapter.mjs +245 -0
  71. package/server/src/app/bootstrap.mjs +244 -0
  72. package/server/src/conversation/conversation-sync.mjs +183 -0
  73. package/server/src/conversation/frontend-agent-context.mjs +162 -0
  74. package/server/src/conversation/frontend-memory.mjs +328 -0
  75. package/server/src/conversation/profiled-memory-store.mjs +87 -0
  76. package/server/src/conversation/task-result-projector.mjs +18 -0
  77. package/server/src/conversation/user-profile.mjs +234 -0
  78. package/server/src/core/config.mjs +388 -0
  79. package/server/src/core/identity.mjs +93 -0
  80. package/server/src/core/install-paths.mjs +8 -0
  81. package/server/src/core/package-version.mjs +10 -0
  82. package/server/src/core/request-security.mjs +80 -0
  83. package/server/src/index.mjs +67 -0
  84. package/server/src/process/backend-drivers/codebuddy.mjs +15 -0
  85. package/server/src/process/backend-drivers/codex.mjs +15 -0
  86. package/server/src/process/backend-drivers/generic-acp.mjs +18 -0
  87. package/server/src/process/backend-drivers/hermes.mjs +15 -0
  88. package/server/src/process/backend-drivers/openclaw.mjs +35 -0
  89. package/server/src/process/backend-drivers/opencode.mjs +75 -0
  90. package/server/src/process/backend-drivers/qoder.mjs +15 -0
  91. package/server/src/process/backend-drivers/registry.mjs +24 -0
  92. package/server/src/process/backend-drivers/shared.mjs +46 -0
  93. package/server/src/process/managed-backend.mjs +188 -0
  94. package/server/src/task/task-manager.mjs +704 -0
  95. package/server/src/task/task-scheduler.mjs +44 -0
  96. package/server/src/task/task-store.mjs +167 -0
  97. package/server/src/voice/active-voice-clients.mjs +58 -0
  98. package/server/src/voice/announcement/announcement-manager.mjs +402 -0
  99. package/server/src/voice/announcement/announcement-window.mjs +89 -0
  100. package/server/src/voice/input-transcript.mjs +9 -0
  101. package/server/src/voice/realtime-errors.mjs +6 -0
  102. package/server/src/voice/realtime-gateway.mjs +1366 -0
  103. package/server/src/voice/realtime-provider.mjs +771 -0
  104. package/server/src/voice/reconnect-backoff.mjs +30 -0
  105. package/server/src/voice/response-context.mjs +41 -0
  106. package/server/src/voice/session-permission-policy.mjs +56 -0
  107. package/server/src/voice/tools/tool-call-handler.mjs +823 -0
  108. package/server/src/voice/tools/turn-transcripts.mjs +59 -0
  109. package/server/src/voice/turn-correlation.mjs +41 -0
  110. package/shared/backend-catalog.mjs +56 -0
  111. package/shared/gateway-client.mjs +13 -0
  112. package/shared/realtime-events.mjs +55 -0
  113. package/shared/runtime-environment.mjs +422 -0
  114. package/tui/native/macos-voice-io.swift +552 -0
  115. package/tui/native/portaudio-voice-io.py +240 -0
  116. package/tui/package.json +13 -0
  117. package/tui/src/index.mjs +1217 -0
  118. package/tui/src/macos-voice-io.mjs +186 -0
  119. package/tui/src/portaudio-voice-io.mjs +158 -0
  120. package/web/dist/assets/index-BeamDvsE.js +38 -0
  121. package/web/dist/assets/index-BuB0EFih.css +1 -0
  122. package/web/dist/index.html +14 -0
@@ -0,0 +1,65 @@
1
+ ---
2
+ description: Persistent OpenCode backend Agent for qwen-audio-agent.
3
+ mode: primary
4
+ options:
5
+ enable_thinking: false
6
+ permission:
7
+ task: allow
8
+ qwen_audio_agent_sessions_list: allow
9
+ qwen_audio_agent_session_start: allow
10
+ qwen_audio_agent_session_send: allow
11
+ qwen_audio_agent_session_status: allow
12
+ qwen_audio_agent_session_cancel: allow
13
+ question: deny
14
+ doom_loop: deny
15
+ external_directory: ask
16
+ read: allow
17
+ ---
18
+
19
+ You are the persistent backend Agent behind the unified 千问Audio assistant.
20
+
21
+ qwen-audio-agent supplies a coordination envelope containing the final ASR, a
22
+ conservative objective, and bounded recent voice context. Use it to resolve
23
+ conversational references, but treat the final ASR as the source of truth.
24
+
25
+ You own all work inside OpenCode. Decide for yourself how to execute it using
26
+ the tools, agents, sessions, skills and context available in your environment.
27
+ qwen-audio-agent never selects or constrains your internal execution strategy.
28
+
29
+ Each qwen-audio-agent request expects one final backend response. Recover the
30
+ request ID from the coordination envelope and output only this JSON shape:
31
+ `{"work_id":"request id","state":"completed","mode":"respond","presentation":{"speech":"natural concise final result","inline":null}}`.
32
+ Use `inline` for detailed Markdown, code, links, or other screen-oriented
33
+ content. This constrains the transport shape only; choose the actual speech
34
+ naturally from the result and current conversation.
35
+
36
+ Only return after the requested work is actually finished or genuinely
37
+ blocked. An acknowledgement, progress update, future promise, or wording such
38
+ as "working on it" is not a final result. Do not return `active`. Continue the
39
+ current turn until you can truthfully return `completed`.
40
+
41
+ There is one transport exception. After
42
+ `qwen_audio_agent_session_start` or `qwen_audio_agent_session_send` returns
43
+ `status=started`, stop using tools and finish the turn with:
44
+ `{"work_id":"request id","state":"delegated","mode":"delegate","delegation_id":"exact delegation_id","target_session_id":"exact session_id","presentation":{"speech":"your natural confirmation to the user","inline":null}}`.
45
+ Use your judgment to make `presentation.speech` useful and natural in the
46
+ current conversation. You may explain what was created or submitted and how
47
+ the project will be approached. Do not claim the delegated work itself is
48
+ finished. Do not call `qwen_audio_agent_session_status`, perform the delegated
49
+ work yourself, or continue using tools. qwen-audio-agent will wait for that
50
+ exact delegated Session and send its verified final result back for
51
+ presentation.
52
+
53
+ `qwen_audio_agent_session_status` is only a status query. If it fails, report
54
+ that the status could not be retrieved. Do not fall back to `bash`, `read`,
55
+ `glob`, `grep`, or any other tool to inspect the target project, and do not
56
+ redo or approximate the delegated task from your own context.
57
+
58
+ Follow the response contract in each request exactly. Keep spoken content as a
59
+ concise semantic suggestion; the realtime model will adapt it to the live
60
+ conversation. Place detailed material in the requested screen output. Never
61
+ expose internal routing, session IDs, agent names, or protocol details.
62
+
63
+ Generating, saving, and inspecting an artifact does not authorize opening it.
64
+ Do not launch a browser, image viewer, file, URL, or desktop application unless
65
+ the user explicitly asked to open or preview that result.
@@ -0,0 +1,16 @@
1
+ # qwen-audio-agent OpenCode Workspace
2
+
3
+ This is the default working directory for the persistent qwen-audio-agent backend
4
+ Agent running on OpenCode.
5
+
6
+ - Complete qwen-audio-agent requests with OpenCode's native tools and project sessions.
7
+ - Keep newly created projects and deliverables inside descriptive
8
+ subdirectories instead of placing unrelated files at the workspace root.
9
+ - Continue an existing OpenCode Chat when the user refers to prior work; do
10
+ not silently create a same-name replacement.
11
+ - Do not modify the qwen-audio-agent source repository unless the user explicitly
12
+ asks to work on qwen-audio-agent itself.
13
+ - Only claim completion after the responsible tool or external system
14
+ confirms success.
15
+ - Do not expose internal Session IDs, routing metadata, or delegation details
16
+ to the user.
@@ -0,0 +1,16 @@
1
+ # qwen-audio-agent Qoder Coordinator Workspace
2
+
3
+ This workspace belongs to the persistent qwen-audio-agent coordinator Session.
4
+
5
+ - Treat each qwen-audio-agent request envelope as the current voice request.
6
+ - Use the qwen_audio_agent Session tools to list, start, or continue native
7
+ Qoder project Sessions.
8
+ - Send natural user task text to project Sessions. Never copy transport
9
+ envelopes, work IDs, or internal routing instructions into project history.
10
+ - Preserve the requested action level. An implementation, fix, or "continue
11
+ working" request must remain an execution request; do not turn it into a
12
+ read-only review or wait for confirmation unless the user asked for planning
13
+ or an indispensable choice is missing.
14
+ - Continue an existing Session when the user refers to prior Qoder work.
15
+ - Only work in this coordinator workspace when no project Session is needed.
16
+ - Never expose Session IDs, delegation IDs, or internal routing metadata.
Binary file
@@ -0,0 +1,332 @@
1
+ # qwen-audio-agent architecture
2
+
3
+ This document defines the product boundary. Changes that contradict these
4
+ invariants are architecture changes, not local feature work.
5
+
6
+ ## 1. User-visible model
7
+
8
+ The user talks to one qwen-audio assistant. Internally there are two qwen-audio-agent
9
+ layers:
10
+
11
+ 1. **Realtime frontend** — full-duplex speech, simple direct answers, and basic
12
+ local time/memory tools.
13
+ 2. **Backend Agent** — one persistent Agent Session that owns every request
14
+ requiring tools, current information, files, applications, code, or
15
+ multi-step work.
16
+
17
+ The backend may be OpenCode, OpenClaw, Qoder, or another ACP-compatible Agent.
18
+ It may internally use tools, skills, agents, or other Sessions. Those are
19
+ backend-private implementation details and do not create additional
20
+ qwen-audio-agent layers. All backends connect through one ACP client and one
21
+ shared coordination adapter; backend-specific launch and capability behavior
22
+ lives in registered drivers.
23
+
24
+ ## 2. Nonblocking request flow
25
+
26
+ ```text
27
+ final ASR
28
+ │
29
+ ├─ immediately answerable ───────────────► Realtime speech
30
+ │
31
+ └─ requires work
32
+ │ spawn_thinking(objective)
33
+ ▼
34
+ Work accepted
35
+ │ response returns to Realtime immediately
36
+ ▼
37
+ owner FIFO queue
38
+ │
39
+ ▼
40
+ fixed Backend Agent Session
41
+ │ the backend decides how to work
42
+ ▼
43
+ final presentation
44
+ │ waits for a safe duplex insertion window
45
+ ▼
46
+ Realtime naturally speaks the result
47
+ ```
48
+
49
+ `spawn_thinking` never waits for the requested work. The user can continue
50
+ speaking while multiple Work items are queued. For each owner, only one Work
51
+ item is sent into the Backend Agent Session at a time.
52
+
53
+ ## 3. Realtime boundary
54
+
55
+ Realtime has exactly six tools:
56
+
57
+ ```text
58
+ spawn_thinking
59
+ cancel_agent_task
60
+ get_agent_task_status
61
+ get_current_time
62
+ user_memory
63
+ respond_agent_permission
64
+ ```
65
+
66
+ `user_memory` keeps one small protocol for frontend-owned memory:
67
+
68
+ - `recall` reads profile or long-term text records and returns stable IDs;
69
+ - `remember` adds a new durable fact;
70
+ - `replace` atomically replaces recalled IDs when the user corrects a fact;
71
+ - `forget` removes explicitly requested records.
72
+
73
+ Only the marked managed section of `USER.md` is editable. User-maintained profile
74
+ text outside that section is returned as read-only data and cannot be replaced.
75
+
76
+ `get_agent_task_status` is the single Realtime entry point for lifecycle,
77
+ progress, and interim-result questions. The Gateway answers non-delegated Work
78
+ directly. For `delegated` Work it creates a hidden, high-priority control query
79
+ that uses the coordinator to call `session_status`. The query waits behind an
80
+ already-running coordinator turn but ahead of ordinary queued Work, and its
81
+ result is delivered through the normal asynchronous announcement path. It is
82
+ not exposed as a user Work item and cannot become the implicit target of a
83
+ later status or cancellation request.
84
+
85
+ It does not have tools for:
86
+
87
+ - selecting, creating, continuing, or cancelling backend Sessions;
88
+ - choosing synchronous, asynchronous, foreground, or background execution;
89
+ - selecting backend execution strategy;
90
+ - selecting tools, Agents, or subagents.
91
+
92
+ `respond_agent_permission` is the only exception to the rule that Realtime does
93
+ not control backend execution. It may relay only an explicit current-turn user
94
+ decision for a pending, owner-scoped permission request supplied by the
95
+ Gateway. It may understand natural affirmative or negative wording such as
96
+ “可以” or “不允许”, but it cannot invent consent without a current-turn user
97
+ utterance, create a request, choose a tool, or modify a backend permission
98
+ policy. Replies are limited to `always` and `reject`; `always` uses the
99
+ backend's Session-scoped permission option when available.
100
+
101
+ The `objective` passed to `spawn_thinking` is a conservative interpretation of
102
+ the user's request, not an execution plan. Recent voice context is separately
103
+ included in the backend Agent envelope so references such as “continue that
104
+ page” remain understandable. Final ASR remains the source of truth.
105
+
106
+ ## 4. Fixed Backend Agent Session
107
+
108
+ The ACP adapter owns one persistent coordinator Session identity per owner and
109
+ backend:
110
+
111
+ ```text
112
+ qwen-audio-agent:<owner>:backend
113
+ ```
114
+
115
+ The Gateway stores the native ACP Session ID behind that stable key and calls
116
+ `session/resume` on later turns. Project delegation likewise resumes the
117
+ selected native Session in its recorded working directory, so voice-originated
118
+ work remains in the backend's own Session history rather than a Gateway copy.
119
+
120
+ Voice browser session IDs and Work IDs never change that identity. A new voice
121
+ conversation therefore continues using the same backend Agent context.
122
+
123
+ Both the Gateway queue and the ACP adapter serialize writes. This double guard
124
+ prevents concurrent messages from racing inside one backend Session.
125
+
126
+ The backend Agent owns its execution strategy. qwen-audio-agent supplies the user
127
+ request, recent voice context, local preferences, and a final response shape;
128
+ it does not instruct the backend Agent how to use backend-specific capabilities.
129
+
130
+ ## 5. Work state
131
+
132
+ A qwen-audio-agent Work record is a delivery receipt, not a mirror of the backend's
133
+ internal task graph.
134
+
135
+ ```text
136
+ queued → running ─────────────────────────→ completed
137
+ │ └→ delegated → finalizing ────────┘
138
+ └────────────→ cancelling → cancelled
139
+ ↘ failed
140
+ ```
141
+
142
+ Public fields are limited to the user request, timestamps, final result/error,
143
+ generic tool activity, a bounded pending permission summary, and notification
144
+ state. There is no execution mode, delivery mode, subagent state, backend
145
+ permission identifier, backend topology, or backend cancellation internals.
146
+
147
+ The UI presents both `queued` and `running` as the same “processing” state.
148
+ Queue position is an internal scheduling detail and does not change the user's
149
+ duplex conversation.
150
+
151
+ Active Work cannot be safely resumed after a Gateway restart, so
152
+ they become failed with an explicit restart reason. Completed results and
153
+ notification delivery state are persisted.
154
+
155
+ ## 6. Progress animation
156
+
157
+ Progress is observability, not control. The ACP adapter projects standard
158
+ `session/update` notifications into generic activity:
159
+
160
+ - tool name, bounded user-safe detail, and running/completed state;
161
+ - text/reasoning activity represented only as “organizing result”.
162
+
163
+ The UI maps this to stable phrases such as “searching”, “reading”, “generating
164
+ an image”, or “organizing the result”. Session IDs, subagent IDs, raw permission
165
+ payloads, and raw reasoning are not shown. A pending permission may show the
166
+ exact bounded operation or command needed for informed consent, after
167
+ secret-like values are redacted.
168
+
169
+ Activity never produces spoken status updates and never affects the queue.
170
+
171
+ ## 7. Final result delivery
172
+
173
+ The backend Agent returns one final presentation:
174
+
175
+ ```json
176
+ {
177
+ "work_id": "work id",
178
+ "state": "completed",
179
+ "mode": "respond",
180
+ "presentation": {
181
+ "speech": "concise result material",
182
+ "inline": null
183
+ }
184
+ }
185
+ ```
186
+
187
+ `speech` is semantic material, not a script. Realtime adapts it to the live
188
+ conversation. `inline` carries Markdown, code, or links for the shared
189
+ timeline.
190
+
191
+ Completed results prefer the originating conversation. On a fresh connection,
192
+ unfinished results from older conversations may be recovered for the same
193
+ owner. A renewable claim prevents two live frontends from presenting the same
194
+ result. Results are injected into Realtime context and marked delivered only
195
+ after playback finishes. If the user interrupts, is speaking, or another
196
+ response is pending, delivery waits and retries without duplicating context.
197
+ Retries are bounded so one malformed result cannot block later completions.
198
+
199
+ When the backend Agent hands work to another native backend Session, the
200
+ intermediate transport response is instead:
201
+
202
+ ```json
203
+ {
204
+ "work_id": "work id",
205
+ "state": "delegated",
206
+ "mode": "delegate",
207
+ "delegation_id": "opaque run id",
208
+ "target_session_id": "opaque backend Session id",
209
+ "presentation": {
210
+ "speech": "a natural confirmation authored by the backend Agent",
211
+ "inline": null
212
+ }
213
+ }
214
+ ```
215
+
216
+ This response is never a user-visible completion. The adapter immediately
217
+ lets the backend Agent naturally finish this short post-tool response, moves
218
+ the original Work to `delegated`, and
219
+ releases both the backend Agent serialization lock and the Work scheduler
220
+ lane. Other voice requests can therefore use the coordinator while the target
221
+ Session runs. The adapter independently keeps the Work lifecycle and event
222
+ subscription alive. Only the matching ACP target prompt completion correlated
223
+ to the delegation ID can complete the Work. The adapter then briefly
224
+ reacquires the backend Agent lock and sends that verified result to it for
225
+ final presentation. A busy target, an empty result, an unrelated Session
226
+ update, or an older result cannot complete the Work.
227
+
228
+ The normal backend request timeout applies separately to the initial
229
+ coordinator turn and the final presentation turn. It does not apply while the
230
+ adapter is waiting for the delegated Session. During that interval, only an
231
+ explicit Work cancellation or backend shutdown cancels the target Session.
232
+
233
+ Cancellation is confirmed rather than optimistic. `queued` Work is cancelled
234
+ locally. `running` or `finalizing` Work aborts its active backend request. For
235
+ `delegated` Work, an idle coordinator is first asked to call
236
+ `session_cancel`; if the coordinator Session is occupied, the ACP adapter
237
+ directly sends `session/cancel` to the exact correlated target Session. The Work remains
238
+ `cancelling` until one of those paths confirms the stop, then becomes
239
+ `cancelled`. A failed stop becomes `failed` with the cancellation error.
240
+ After a direct adapter abort, the Gateway records a cancellation fact and
241
+ injects it once into the next safe coordinator turn. This reconciles the
242
+ coordinator's history without delaying cancellation or repeating the stop.
243
+
244
+ The delegated `presentation` is authored by the backend Agent with normal
245
+ reasoning and is spoken immediately as a start confirmation. It may explain
246
+ what was created, submitted, or planned, but it is not a final result. The
247
+ adapter aborts the backend turn only as a timeout fallback if it fails to finish
248
+ after the asynchronous Session tool has already succeeded.
249
+
250
+ ## 8. Backend-internal capabilities
251
+
252
+ For OpenCode and Qoder, the Gateway injects the same five MCP tools into the
253
+ coordinator through ACP: Session list, start, send, status, and cancel. OpenClaw
254
+ ACP does not accept client-supplied MCP servers, so the same coordination
255
+ contract maps to OpenClaw's native Session tools. `session_start` and
256
+ `session_send` return an opaque delegation ID. After either succeeds, the
257
+ backend Agent must not poll, repeat the work, or answer from its own context;
258
+ the adapter owns waiting, cancellation, permission routing, and result
259
+ correlation.
260
+
261
+ `session_status` is observational only. If the query fails, the backend Agent
262
+ must report the failure; it must not inspect the target directory with native
263
+ tools or duplicate the delegated work.
264
+
265
+ Frontend code must not depend on which internal capability was chosen.
266
+ Frontend task snapshots may expose only a bounded title and generic delegated
267
+ state, never delegation IDs, target Session IDs, directories, or raw events.
268
+
269
+ ## 9. Dependency direction
270
+
271
+ ```text
272
+ WebUI / TUI / Desktop
273
+ ↓ WebSocket and HTTP
274
+ Realtime Gateway
275
+ ↓ spawn_thinking
276
+ Work queue
277
+ ↓
278
+ backend Agent envelope
279
+ ↓
280
+ Shared ACP adapter
281
+ ↓
282
+ OpenCode ACP, OpenClaw ACP bridge, or Qoder ACP
283
+ ```
284
+
285
+ Backend-specific API details belong only in `server/src/agent`. Realtime tools
286
+ must not import backend adapters. The UI consumes only public Work events and
287
+ final timeline content. Package-level `shared` modules are foundational runtime
288
+ utilities; server `core` may depend on them, but they must not depend on server
289
+ layers.
290
+
291
+ Gateway may serve the immutable `web/dist` artifact as a deployment
292
+ convenience, but this is static hosting only. Gateway source must not import UI
293
+ components, presentation text, styling, terminal behavior, or desktop behavior.
294
+ All three UIs own their rendering and map structured protocol fields to their
295
+ own labels and interaction patterns.
296
+
297
+ ## 10. Process ownership
298
+
299
+ The Gateway is the only core product service. The shared adapter owns one ACP
300
+ stdio child and stops it with the Gateway. OpenCode and Qoder run directly as
301
+ ACP agents; managed OpenCode may additionally expose its native local Session
302
+ UI. OpenClaw uses a small ACP bridge; in managed mode the Gateway also owns its
303
+ OpenClaw Gateway, while compatible mode attaches the bridge to an
304
+ already-running Gateway. Qoder does not currently offer compatible mode.
305
+
306
+ Desktop, TUI and WebUI are replaceable Gateway clients. They must never spawn,
307
+ restart or stop the Gateway or a backend. Closing a UI therefore cannot affect
308
+ queued work or the fixed backend Agent Session. Configuration that changes
309
+ Realtime or backend behavior takes effect on the next Gateway start; changing a
310
+ UI's Gateway URL only reconnects that UI.
311
+
312
+ The macOS desktop renderer is packaged inside the application. Electron serves
313
+ those immutable assets from a private, random loopback path and proxies only
314
+ Gateway HTTP API and Realtime WebSocket traffic. Desktop UI assets must not be
315
+ loaded from the Gateway: rebuilding the desktop application must be sufficient
316
+ to update its appearance without upgrading the running Gateway frontend.
317
+
318
+ ## 11. Review checklist
319
+
320
+ Before merging a change, verify:
321
+
322
+ 1. Can Realtime still converse while backend work is queued or running?
323
+ 2. Does every executable request enter the same persistent backend Agent
324
+ Session?
325
+ 3. Did any frontend API gain knowledge of Session, subagent, permission, or
326
+ execution mode?
327
+ 4. Are tool events used only for generic UI progress?
328
+ 5. Is completion spoken only from a final backend Agent result?
329
+ 6. Did any UI begin managing a Gateway or backend process?
330
+ 7. Can interruption postpone speech without cancelling submitted Work?
331
+ 8. Do tests cover FIFO serialization, fixed Session reuse, tool animation, and
332
+ delivery retry?