Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。
docs(readme): draw the architecture, and put it in both READMEs
booboosui42fdbd0741bf
diff --git a/README.md b/README.mdindex dbeae1f..44aa8a8 100644--- a/README.md+++ b/README.md@@ -225,6 +225,25 @@ Deliberately. Overlays cannot host Compose, so all UI is hand-written `View` codservice, so dependencies are constructor-injected by hand; concurrency is `Handler` plus dedicatedexecutors. 43k+ lines of Kotlin, all first-party — no code copied in from anywhere.+## Architecture++One `AccessibilityService` is the entry point and there is no main UI. A turn can begin five ways —+the offline wake word, voice or typing, a notification, a timer, or a request over WebSocket — is+logged to `ChatHistory`, and is handed to whichever backend is in effect (`brain = local` is the+out-of-box default).++The agent loop **is** `LocalBrain`. It holds the system prompt constant and inlines the volatile+parts (clock, notebook index, scenes, photos) into the user message, so the provider's prefix cache+still hits; it rebuilds the tool table every turn; and it calls the model in a **non-streaming**+`for` loop of up to `maxSteps` steps. A reply carrying tool calls goes through `methodOf()` to the+one `CommandDispatcher`; a reply without any ends the turn. The result comes back out through six+channels — speech, text, a full-screen page, saved artifacts, long text, and physical motion.++++Everything drawn here is in this repository, down to the guard rails — see+[Why you can check this instead of trusting it](#why-you-can-check-this-instead-of-trusting-it).+## Quick startThe fastest route skips the two things that actually stop people: **building it yourself, and wiring@@ -807,6 +826,7 @@ app/ the Android app (Kotlin, no Compose)ui/ the overlay: ball, subtitles, settings, self-check, scenes, pagesi18n/AppLocale.kt how the overlay reaches its stringssrc/main/res/values{,-en}/strings.xml the two user-facing string tables+docs/architecture.svg the whole picture on one page (zh-CN twin beside it)docs/permissions.md why it asks for what it asks forreports/ design labs and research notes (part of the repo, not scratch)tools/ device-side helper scripts, the ball-face lab runners, license audit@@ -930,6 +950,8 @@ been tagged yet, and version numbers do not currently identify a build.- [docs/permissions.md](docs/permissions.md) ([中文](docs/permissions.zh-CN.md)) — why it asks forthe permissions it asks for, each one against a concrete tool+- [docs/architecture.svg](docs/architecture.svg) ([中文](docs/architecture.zh-CN.svg)) — the whole+ thing on one page: a turn in, the agent loop, six ways out- [DISCLAIMER.md](DISCLAIMER.md) — where your data goes, what it can do, who bears the consequences- [docs/acceptable-use.md](docs/acceptable-use.md) ([中文](docs/acceptable-use.zh-CN.md)) — theprohibited usesdiff --git a/README.zh-CN.md b/README.zh-CN.mdindex fbf67f9..1e6794e 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -197,6 +197,23 @@ WebSocket hub 连到设备。两者之间只是一份普通的工具 schema 契构造函数注入;并发是 `Handler` + 独立 `Executor`。四万三千多行 Kotlin,全部自研 —— 没有一行是从别处拷来的。+## 架构++入口是一个 `AccessibilityService`,没有主界面。一轮可以从五个地方开始 —— 离线唤醒词、语音或+打字、一条通知、一个定时、或经 WebSocket 进来的请求 —— 先写进 `ChatHistory`,再交给当时生效的+那个后端(`brain = local` 是开箱默认)。++agent loop **就是** `LocalBrain`。它让系统提示词保持不变,把会变的部分(时钟、notebook 索引、+情景、照片)内联进 user 消息,这样服务商的前缀缓存仍然命中;工具表每轮重建;然后是一个+**非流式**的 `for` 循环,最多 `maxSteps` 步。带工具调用的回复经 `methodOf()` 送到唯一的+`CommandDispatcher`;不带工具调用的回复结束这一轮。结果从六个通道送出来 —— 语音、文字、+全屏网页、产物、长文、以及物理动作。++++图上画的每一样都在本仓库里,连护栏也在 ——+见[为什么你可以去核对,而不是选择相信](#为什么你可以去核对而不是选择相信)。+## 快速开始**最快的一条路,省掉的是真正卡住人的那两件事:自己打包、自己配令牌。**@@ -718,6 +735,7 @@ app/ Android 应用(Kotlin,无 Compose)ui/ 悬浮层:球、字幕、设置、自检、情景、产物i18n/AppLocale.kt 悬浮层怎么拿到自己的字符串src/main/res/values{,-en}/strings.xml 两张面向用户的字符串表+docs/architecture.zh-CN.svg 一页看全(英文那份在旁边)docs/permissions.zh-CN.md 为什么它要这些权限reports/ 设计实验室与调研笔记(是仓库的一部分,不是草稿)tools/ 设备侧小工具、球脸验收 runner、许可证审计@@ -832,6 +850,7 @@ CLAUDE.md 给 AI 编码助手看的架构说明(英文)## 相关文档- [docs/permissions.zh-CN.md](docs/permissions.zh-CN.md)([English](docs/permissions.md))—— 权限为什么这么要+- [docs/architecture.zh-CN.svg](docs/architecture.zh-CN.svg)([English](docs/architecture.svg))—— 一页看全:一轮怎么进来、agent loop、六个出口- [DISCLAIMER.zh-CN.md](DISCLAIMER.zh-CN.md) —— 免责声明:数据去哪、能做什么、出事谁担- [docs/acceptable-use.zh-CN.md](docs/acceptable-use.zh-CN.md) —— 可接受使用政策(禁止用途)- [SECURITY.md](SECURITY.md)(英文)—— 威胁模型、已知限制、漏洞上报diff --git a/docs/architecture.svg b/docs/architecture.svgnew file mode 100644index 0000000..9cf8b73--- /dev/null+++ b/docs/architecture.svg@@ -0,0 +1,139 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 680 1340" width="100%" role="img" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif">+<title>Andee — architecture</title>+<desc>Andee has no main UI: a single AccessibilityService, ScreenBodyService, is the entry point and the only coordinator. Five things can start a turn - the offline wake word, voice or typed input, the notification relay, timers and TODOs, and requests arriving on the WebSocket server. A turn is logged to ChatHistory and handed to one of three mutually exclusive backends: LocalBrain on device with your own key (the out-of-box default), an API market hosted by CodeFlying (used when it is compiled in, one domain proxying LLM, ASR and TTS plus a market tool surface), or a hub brain reached over a socket. Only the first two run the agent loop here. That loop is LocalBrain: it assembles the system prompt from LocalPrompt.withPersona, keeps the volatile parts (clock, notebook index, scenes, photos) in the user message, rebuilds the tool table every turn, then calls LlmClient.complete in a non-streaming for-loop of up to maxSteps, 25 by default. A reply carrying tool calls goes through methodOf() to the CommandDispatcher; a reply without any ends the turn. Guards: a generation counter cancels stale turns, three identical calls in a row stop the loop, and history is trimmed and compacted by harvest. ScreenBodyService and the dispatcher then put the result out through six channels - speech through TtsController, text as bubbles, subtitles and cards, a full-screen HTML page in HtmlActivity, saved artifacts that can be re-opened and edited just by asking, long messages read full-screen in TextPage, and physical motion through DogMotion over USB serial. When the hub answers instead, its loop runs off-device and reaches the body over the socket. Three invariants hold: a refusal lives in the dispatcher rather than the prompt, notification text is data and a notification-driven turn cannot reach the vault or enter a scene, and the model never does coordinate maths.</desc>+<defs>+<marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">+<path d="M2 1L8 5L2 9" fill="none" stroke="#8C959F" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>+</marker>+</defs>++<rect x="0" y="0" width="680" height="1340" fill="#FFFFFF"/>++<text x="40" y="50" font-size="15" fill="#1F2328" font-weight="600" dominant-baseline="central">Andee — architecture</text>+<text x="40" y="72" font-size="12" fill="#656D76" dominant-baseline="central">One AccessibilityService is the entry point, and there is no main UI.</text>++<text x="40" y="98" font-size="12" fill="#656D76" dominant-baseline="central">Ways in — five of them, and no screen to start from</text>+<rect x="40" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Wake word</text>+<text x="52" y="150" font-size="12" fill="#656D76" dominant-baseline="central">offline · DTW</text>+<rect x="162" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="174" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Voice · typing</text>+<text x="174" y="150" font-size="12" fill="#656D76" dominant-baseline="central">ASR or text</text>+<rect x="284" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="296" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Notifications</text>+<text x="296" y="150" font-size="12" fill="#656D76" dominant-baseline="central">relay service</text>+<rect x="406" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="418" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Timers · TODO</text>+<text x="418" y="150" font-size="12" fill="#656D76" dominant-baseline="central">alarms, review</text>+<rect x="528" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="540" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Hub requests</text>+<text x="540" y="150" font-size="12" fill="#656D76" dominant-baseline="central">WS :9008</text>+<path d="M96 162 V174 M218 162 V174 M340 162 V174 M462 162 V174 M584 162 V174 M96 174 H584" fill="none" stroke="#8C959F" stroke-width="1.5"/>+<path d="M340 174 V182" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="182" width="600" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="52" y="206" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">ScreenBodyService — AccessibilityService</text>+<text x="52" y="228" font-size="12" fill="#185FA5" dominant-baseline="central">The only coordinator. It builds the object graph, and the floating ball is its only face;</text>+<text x="52" y="250" font-size="12" fill="#185FA5" dominant-baseline="central">every path out ends here — the turn is logged to ChatHistory, then handed to a backend.</text>+<path d="M340 258 V276" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="276" width="600" height="132" rx="12" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="296" font-size="12" fill="#656D76" dominant-baseline="central">Which brain answers — three, mutually exclusive</text>+<rect x="56" y="306" width="180" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="68" y="328" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">LocalBrain · default</text>+<text x="68" y="348" font-size="12" fill="#185FA5" dominant-baseline="central">on device, your own key</text>+<text x="68" y="368" font-size="12" fill="#185FA5" dominant-baseline="central">LlmClient → DeepSeek</text>+<rect x="250" y="306" width="180" height="76" rx="8" fill="#FAEEDA" stroke="#EF9F27" stroke-width="1"/>+<text x="262" y="328" font-size="13" fill="#633806" font-weight="600" dominant-baseline="central">API market</text>+<text x="262" y="348" font-size="12" fill="#854F0B" dominant-baseline="central">CodeFlying · hosted</text>+<text x="262" y="368" font-size="12" fill="#854F0B" dominant-baseline="central">LLM/ASR/TTS + tools</text>+<rect x="444" y="306" width="180" height="76" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="456" y="328" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Hub brain</text>+<text x="456" y="348" font-size="12" fill="#656D76" dominant-baseline="central">remote · over WS</text>+<text x="456" y="368" font-size="12" fill="#656D76" dominant-baseline="central">off if hub_url blank</text>+<text x="52" y="396" font-size="12" fill="#656D76" dominant-baseline="central">Only the first two run the loop on this device; the hub's loop stays on the far side.</text>+<path d="M340 408 V426" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="426" width="600" height="324" rx="12" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="450" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">The harness — LocalBrain. This is the agent loop, and it lives on the tablet.</text>+<text x="52" y="472" font-size="12" fill="#656D76" dominant-baseline="central">1 · system prompt = LocalPrompt.withPersona(persona, scene), held constant</text>+<text x="52" y="492" font-size="12" fill="#656D76" dominant-baseline="central">2 · volatile parts ride in the user message: clock, notebook index, scenes, photos</text>+<text x="52" y="512" font-size="12" fill="#656D76" dominant-baseline="central">3 · the tool table is rebuilt every turn: ToolSchemas.all() + extensions + market</text>+<rect x="56" y="530" width="568" height="176" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="68" y="552" font-size="12" fill="#1F2328" font-weight="600" dominant-baseline="central">for step in 1..maxSteps — 25 unless the config raises it, clamped 1..200</text>+<rect x="72" y="566" width="536" height="42" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="84" y="587" font-size="12" fill="#185FA5" dominant-baseline="central">LlmClient.complete(history, tools) · non-streaming · 180 s read timeout</text>+<path d="M340 608 V620 M202 620 H478" fill="none" stroke="#8C959F" stroke-width="1.5"/>+<path d="M202 620 V628" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>+<path d="M478 620 V628" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>+<rect x="72" y="628" width="260" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="84" y="650" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">tool_calls present</text>+<text x="84" y="670" font-size="12" fill="#656D76" dominant-baseline="central">runTool → methodOf() → the dispatcher</text>+<rect x="348" y="628" width="260" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="360" y="650" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">no tool_calls</text>+<text x="360" y="670" font-size="12" fill="#656D76" dominant-baseline="central">onFinal(content) — the turn ends</text>+<path d="M202 680 V696 H64 V587 H72" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>+<rect x="87" y="687" width="92" height="18" rx="4" fill="#FFFFFF"/>+<text x="133" y="696" font-size="12" fill="#656D76" text-anchor="middle" dominant-baseline="central">↻ next step</text>+<rect x="56" y="714" width="568" height="28" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="68" y="728" font-size="12" fill="#656D76" dominant-baseline="central">Guards: generation cancel · 3-repeat stop · trim 60 turns / 60k chars · harvest</text>++<path d="M624 344 H656 V814 H642" fill="none" stroke="#8C959F" stroke-width="1.5" stroke-dasharray="4 4" marker-end="url(#arrow)"/>+<text x="670" y="580" font-size="10" fill="#656D76" transform="rotate(-90 670 580)" dominant-baseline="central">hub loop: off-device</text>++<path d="M340 750 V782" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="782" width="186" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="52" y="804" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">LocalBrain tool calls</text>+<text x="52" y="824" font-size="12" fill="#656D76" dominant-baseline="central">the name is already mapped</text>+<rect x="247" y="782" width="186" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="259" y="804" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">BodyWsServer</text>+<text x="259" y="824" font-size="12" fill="#656D76" dominant-baseline="central">0.0.0.0:9008, requests in</text>+<rect x="454" y="782" width="186" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="466" y="804" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">BodyWsClient</text>+<text x="466" y="824" font-size="12" fill="#656D76" dominant-baseline="central">register out, request in</text>+<path d="M133 834 V846 M340 834 V846 M547 834 V846 M133 846 H547" fill="none" stroke="#8C959F" stroke-width="1.5"/>+<path d="M340 846 V854" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="854" width="600" height="92" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="52" y="876" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">CommandDispatcher — the only way out</text>+<text x="52" y="898" font-size="12" fill="#185FA5" dominant-baseline="central">when(method) picks the real controller: device.* · screen.* · note.* · scene.*</text>+<text x="52" y="918" font-size="12" fill="#185FA5" dominant-baseline="central">meeting.* · dog.* · tts.* · ui.* — anything else forwards to market, then extensions</text>+<text x="52" y="936" font-size="12" fill="#185FA5" dominant-baseline="central">A refusal lives here, not in the prompt.</text>+<path d="M340 946 V968" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="968" width="600" height="250" rx="12" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="990" font-size="12" fill="#656D76" dominant-baseline="central">Where it comes out — six channels</text>+<rect x="56" y="1002" width="180" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="68" y="1024" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">Voice</text>+<text x="68" y="1044" font-size="12" fill="#185FA5" dominant-baseline="central">TtsController → speaker</text>+<text x="68" y="1064" font-size="12" fill="#185FA5" dominant-baseline="central">assistant audio, one take</text>+<rect x="250" y="1002" width="180" height="76" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="262" y="1024" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Text</text>+<text x="262" y="1044" font-size="12" fill="#656D76" dominant-baseline="central">bubbles, subtitles, cards</text>+<text x="262" y="1064" font-size="12" fill="#656D76" dominant-baseline="central">ChatHistory · CardUi</text>+<rect x="444" y="1002" width="180" height="76" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="456" y="1024" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Page</text>+<text x="456" y="1044" font-size="12" fill="#656D76" dominant-baseline="central">HtmlActivity, full screen</text>+<text x="456" y="1064" font-size="12" fill="#656D76" dominant-baseline="central">one page at a time</text>+<rect x="56" y="1088" width="180" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="68" y="1110" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">Artifacts</text>+<text x="68" y="1130" font-size="12" fill="#185FA5" dominant-baseline="central">ChatHistory Role.PAGE</text>+<text x="68" y="1150" font-size="12" fill="#185FA5" dominant-baseline="central">re-open, edit by asking</text>+<rect x="250" y="1088" width="180" height="76" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="262" y="1110" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Long text</text>+<text x="262" y="1130" font-size="12" fill="#656D76" dominant-baseline="central">TextPage</text>+<text x="262" y="1150" font-size="12" fill="#656D76" dominant-baseline="central">double-tap a message</text>+<rect x="444" y="1088" width="180" height="76" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="456" y="1110" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Body</text>+<text x="456" y="1130" font-size="12" fill="#656D76" dominant-baseline="central">DogMotion → USB serial</text>+<text x="456" y="1150" font-size="12" fill="#656D76" dominant-baseline="central">fire and forget</text>+<text x="52" y="1186" font-size="12" fill="#656D76" dominant-baseline="central">Speech and text at turn end; pages, cards and motion from the dispatcher mid-turn.</text>+<text x="52" y="1204" font-size="12" fill="#656D76" dominant-baseline="central">Eyes: LookActivity and ScanActivity take the screen, and the frame returns as a vision message.</text>++<rect x="40" y="1240" width="600" height="90" rx="12" fill="#FAEEDA" stroke="#EF9F27" stroke-width="1"/>+<text x="52" y="1262" font-size="13" fill="#633806" font-weight="600" dominant-baseline="central">Three invariants</text>+<text x="52" y="1284" font-size="12" fill="#854F0B" dominant-baseline="central">A refusal lives in the dispatcher, not the prompt — the prompt cannot talk it out of one</text>+<text x="52" y="1304" font-size="12" fill="#854F0B" dominant-baseline="central">Notification text is data; a notification-driven turn cannot reach the vault or enter a scene</text>+<text x="52" y="1324" font-size="12" fill="#854F0B" dominant-baseline="central">The model never does coordinate maths: the device computes 0-1000 and rejects out-of-range</text>+</svg>diff --git a/docs/architecture.zh-CN.svg b/docs/architecture.zh-CN.svgnew file mode 100644index 0000000..af02312--- /dev/null+++ b/docs/architecture.zh-CN.svg@@ -0,0 +1,139 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 680 1340" width="100%" role="img" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif">+<title>Andee — 架构图</title>+<desc>Andee 没有主界面:唯一的入口是一个 AccessibilityService,也就是 ScreenBodyService,它是唯一的协调者。能开局一轮的有五个入口——离线唤醒词、语音或打字、通知监听、定时与待办、以及从 WebSocket 服务进来的外部请求。一轮先写进 ChatHistory,然后交给三种互斥后端之一:本机 LocalBrain(自备 key,开箱默认)、CodeFlying 托管的 API market(构建进去了才启用,一个域名代理 LLM/ASR/TTS 并额外提供市场工具),以及经 socket 到达的 hub 大脑。只有前两个在本机跑 agent loop。这个 loop 就是 LocalBrain:用 LocalPrompt.withPersona 组装系统提示词,把会变的部分(时钟、notebook 索引、情景、照片)放进 user 消息,每轮重建工具表,然后在一个非流式的 for 循环里调 LlmClient.complete,最多 maxSteps 步、默认 25。带工具调用的回复经 methodOf() 送到 CommandDispatcher;不带工具调用的回复就结束这一轮。守卫:代际号取消过期轮、连续三次相同调用即停、历史裁剪并由 harvest 压缩。随后由 ScreenBodyService 和 dispatcher 把结果从六个通道送出去——语音走 TtsController,文字是气泡、字幕和卡片,网页是 HtmlActivity 里的全屏 HTML,产物存在 ChatHistory 里、说一句就能改,长文双击用 TextPage 全屏读,物理动作走 DogMotion 经 USB 串口。当改由 hub 回答时,它的循环不在本机,而是经那条 socket 到达身体。三条不变量:拒绝写在 dispatcher 里而不是提示词里;通知文本是数据,通知触发的回合碰不到保险箱也不能进或建情景;模型永远不算坐标。</desc>+<defs>+<marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">+<path d="M2 1L8 5L2 9" fill="none" stroke="#8C959F" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>+</marker>+</defs>++<rect x="0" y="0" width="680" height="1340" fill="#FFFFFF"/>++<text x="40" y="50" font-size="15" fill="#1F2328" font-weight="600" dominant-baseline="central">Andee — 架构图</text>+<text x="40" y="72" font-size="12" fill="#656D76" dominant-baseline="central">入口是一个 AccessibilityService,没有主界面。</text>++<text x="40" y="98" font-size="12" fill="#656D76" dominant-baseline="central">入口有五个,而且没有主界面</text>+<rect x="40" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">唤醒词</text>+<text x="52" y="150" font-size="12" fill="#656D76" dominant-baseline="central">离线 · DTW</text>+<rect x="162" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="174" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">语音 · 打字</text>+<text x="174" y="150" font-size="12" fill="#656D76" dominant-baseline="central">ASR 或文字</text>+<rect x="284" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="296" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">通知栏</text>+<text x="296" y="150" font-size="12" fill="#656D76" dominant-baseline="central">通知监听服务</text>+<rect x="406" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="418" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">定时 · 待办</text>+<text x="418" y="150" font-size="12" fill="#656D76" dominant-baseline="central">闹钟、静默复盘</text>+<rect x="528" y="110" width="112" height="52" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="540" y="132" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Hub 请求</text>+<text x="540" y="150" font-size="12" fill="#656D76" dominant-baseline="central">WS :9008</text>+<path d="M96 162 V174 M218 162 V174 M340 162 V174 M462 162 V174 M584 162 V174 M96 174 H584" fill="none" stroke="#8C959F" stroke-width="1.5"/>+<path d="M340 174 V182" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="182" width="600" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="52" y="206" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">ScreenBodyService — AccessibilityService</text>+<text x="52" y="228" font-size="12" fill="#185FA5" dominant-baseline="central">唯一的协调者。它建起整个对象图,悬浮球是它唯一的脸;</text>+<text x="52" y="250" font-size="12" fill="#185FA5" dominant-baseline="central">所有出口都落在这里 —— 一轮先写进 ChatHistory,再交给当时生效的后端。</text>+<path d="M340 258 V276" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="276" width="600" height="132" rx="12" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="296" font-size="12" fill="#656D76" dominant-baseline="central">谁在回答 —— 三种后端,互斥</text>+<rect x="56" y="306" width="180" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="68" y="328" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">LocalBrain · 默认</text>+<text x="68" y="348" font-size="12" fill="#185FA5" dominant-baseline="central">本机 · 自备 key</text>+<text x="68" y="368" font-size="12" fill="#185FA5" dominant-baseline="central">LlmClient → DeepSeek</text>+<rect x="250" y="306" width="180" height="76" rx="8" fill="#FAEEDA" stroke="#EF9F27" stroke-width="1"/>+<text x="262" y="328" font-size="13" fill="#633806" font-weight="600" dominant-baseline="central">API market</text>+<text x="262" y="348" font-size="12" fill="#854F0B" dominant-baseline="central">CodeFlying · 托管</text>+<text x="262" y="368" font-size="12" fill="#854F0B" dominant-baseline="central">LLM/ASR/TTS + 工具</text>+<rect x="444" y="306" width="180" height="76" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="456" y="328" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Hub brain</text>+<text x="456" y="348" font-size="12" fill="#656D76" dominant-baseline="central">远端 · 经 WS</text>+<text x="456" y="368" font-size="12" fill="#656D76" dominant-baseline="central">hub_url 为空时关掉</text>+<text x="52" y="396" font-size="12" fill="#656D76" dominant-baseline="central">只有前两个在本机跑循环;hub 的循环在对面,靠一条 socket 到达。</text>+<path d="M340 408 V426" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="426" width="600" height="324" rx="12" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="450" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">Harness —— LocalBrain。这就是 agent loop,它跑在这台平板上。</text>+<text x="52" y="472" font-size="12" fill="#656D76" dominant-baseline="central">1 · 系统提示词 = LocalPrompt.withPersona(persona, scene),保持不变</text>+<text x="52" y="492" font-size="12" fill="#656D76" dominant-baseline="central">2 · 会变的东西改走 user 消息:时钟、notebook 索引、情景、照片</text>+<text x="52" y="512" font-size="12" fill="#656D76" dominant-baseline="central">3 · 工具表每轮重建:ToolSchemas.all() + 通话扩展 + 市场</text>+<rect x="56" y="530" width="568" height="176" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="68" y="552" font-size="12" fill="#1F2328" font-weight="600" dominant-baseline="central">for step in 1..maxSteps —— 默认 25,可调,钳在 1..200</text>+<rect x="72" y="566" width="536" height="42" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="84" y="587" font-size="12" fill="#185FA5" dominant-baseline="central">LlmClient.complete(history, tools) · 非流式 · 读超时 180 秒</text>+<path d="M340 608 V620 M202 620 H478" fill="none" stroke="#8C959F" stroke-width="1.5"/>+<path d="M202 620 V628" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>+<path d="M478 620 V628" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>+<rect x="72" y="628" width="260" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="84" y="650" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">有 tool_calls</text>+<text x="84" y="670" font-size="12" fill="#656D76" dominant-baseline="central">runTool → methodOf() → dispatcher</text>+<rect x="348" y="628" width="260" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="360" y="650" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">没有 tool_calls</text>+<text x="360" y="670" font-size="12" fill="#656D76" dominant-baseline="central">onFinal(content) —— 本轮结束</text>+<path d="M202 680 V696 H64 V587 H72" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>+<rect x="87" y="687" width="92" height="18" rx="4" fill="#FFFFFF"/>+<text x="133" y="696" font-size="12" fill="#656D76" text-anchor="middle" dominant-baseline="central">↻ 下一步</text>+<rect x="56" y="714" width="568" height="28" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="68" y="728" font-size="12" fill="#656D76" dominant-baseline="central">守卫:代际号取消过期轮 · 3 次重复即停 · 历史裁到 60 轮 / 6 万字符 · harvest 压缩</text>++<path d="M624 344 H656 V814 H642" fill="none" stroke="#8C959F" stroke-width="1.5" stroke-dasharray="4 4" marker-end="url(#arrow)"/>+<text x="670" y="580" font-size="10" fill="#656D76" transform="rotate(-90 670 580)" dominant-baseline="central">hub 的循环在对面</text>++<path d="M340 750 V782" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="782" width="186" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="52" y="804" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">LocalBrain 工具调用</text>+<text x="52" y="824" font-size="12" fill="#656D76" dominant-baseline="central">名字已映射完毕</text>+<rect x="247" y="782" width="186" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="259" y="804" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">BodyWsServer</text>+<text x="259" y="824" font-size="12" fill="#656D76" dominant-baseline="central">0.0.0.0:9008,请求进来</text>+<rect x="454" y="782" width="186" height="52" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="466" y="804" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">BodyWsClient</text>+<text x="466" y="824" font-size="12" fill="#656D76" dominant-baseline="central">工具注册出去,请求进来</text>+<path d="M133 834 V846 M340 834 V846 M547 834 V846 M133 846 H547" fill="none" stroke="#8C959F" stroke-width="1.5"/>+<path d="M340 846 V854" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="854" width="600" height="92" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="52" y="876" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">CommandDispatcher —— 唯一出口</text>+<text x="52" y="898" font-size="12" fill="#185FA5" dominant-baseline="central">when(method) 挑真正干活的控制器:device.* · screen.* · note.* · scene.*</text>+<text x="52" y="918" font-size="12" fill="#185FA5" dominant-baseline="central">meeting.* · dog.* · tts.* · ui.* —— 没匹配的转给市场,再转通话扩展</text>+<text x="52" y="936" font-size="12" fill="#185FA5" dominant-baseline="central">拒绝写在这里,不在提示词里。</text>+<path d="M340 946 V968" fill="none" stroke="#8C959F" stroke-width="1.5" marker-end="url(#arrow)"/>++<rect x="40" y="968" width="600" height="250" rx="12" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="52" y="990" font-size="12" fill="#656D76" dominant-baseline="central">从哪儿出来 —— 六个通道</text>+<rect x="56" y="1002" width="180" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="68" y="1024" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">语音</text>+<text x="68" y="1044" font-size="12" fill="#185FA5" dominant-baseline="central">TtsController → 扬声器</text>+<text x="68" y="1064" font-size="12" fill="#185FA5" dominant-baseline="central">整段读,一次给完</text>+<rect x="250" y="1002" width="180" height="76" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="262" y="1024" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">文字</text>+<text x="262" y="1044" font-size="12" fill="#656D76" dominant-baseline="central">气泡、字幕、卡片</text>+<text x="262" y="1064" font-size="12" fill="#656D76" dominant-baseline="central">ChatHistory · CardUi</text>+<rect x="444" y="1002" width="180" height="76" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="456" y="1024" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">网页</text>+<text x="456" y="1044" font-size="12" fill="#656D76" dominant-baseline="central">HtmlActivity 全屏</text>+<text x="456" y="1064" font-size="12" fill="#656D76" dominant-baseline="central">一次只留一页</text>+<rect x="56" y="1088" width="180" height="76" rx="8" fill="#E6F1FB" stroke="#85B7EB" stroke-width="1"/>+<text x="68" y="1110" font-size="13" fill="#0C447C" font-weight="600" dominant-baseline="central">产物</text>+<text x="68" y="1130" font-size="12" fill="#185FA5" dominant-baseline="central">ChatHistory Role.PAGE</text>+<text x="68" y="1150" font-size="12" fill="#185FA5" dominant-baseline="central">可回看,说一句就能改</text>+<rect x="250" y="1088" width="180" height="76" rx="8" fill="#F6F8FA" stroke="#D0D7DE" stroke-width="1"/>+<text x="262" y="1110" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">长文</text>+<text x="262" y="1130" font-size="12" fill="#656D76" dominant-baseline="central">TextPage</text>+<text x="262" y="1150" font-size="12" fill="#656D76" dominant-baseline="central">双击消息全屏读</text>+<rect x="444" y="1088" width="180" height="76" rx="8" fill="#FFFFFF" stroke="#AFB8C1" stroke-width="1"/>+<text x="456" y="1110" font-size="13" fill="#1F2328" font-weight="600" dominant-baseline="central">身体</text>+<text x="456" y="1130" font-size="12" fill="#656D76" dominant-baseline="central">DogMotion → USB 串口</text>+<text x="456" y="1150" font-size="12" fill="#656D76" dominant-baseline="central">发完即返回</text>+<text x="52" y="1186" font-size="12" fill="#656D76" dominant-baseline="central">语音和文字在轮次结束时由服务发出;网页、卡片和动作在轮次中由 dispatcher 指挥。</text>+<text x="52" y="1204" font-size="12" fill="#656D76" dominant-baseline="central">眼睛也是通道:LookActivity 和 ScanActivity 占屏取帧,画面作为 vision 消息回到循环。</text>++<rect x="40" y="1240" width="600" height="90" rx="12" fill="#FAEEDA" stroke="#EF9F27" stroke-width="1"/>+<text x="52" y="1262" font-size="13" fill="#633806" font-weight="600" dominant-baseline="central">三条不变量</text>+<text x="52" y="1284" font-size="12" fill="#854F0B" dominant-baseline="central">拒绝写在 dispatcher 里,不在提示词里 —— 提示词说不动它</text>+<text x="52" y="1304" font-size="12" fill="#854F0B" dominant-baseline="central">通知文本是数据;通知触发的回合碰不到保险箱、也不能进或建情景</text>+<text x="52" y="1324" font-size="12" fill="#854F0B" dominant-baseline="central">模型永远不算坐标:0-1000 相对坐标由设备换算,越界直接报错不夹紧</text>+</svg>