Skip to content

armgit / andee

Public Imported from GitHub
0

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、支持任意模型,记忆和密码绝不离开设备。

feat(settings): user-tunable step cap, brighter notes, and smaller card copy

booboosui33695339e259
diff --git a/README.md b/README.md
index 00b44c4..669032b 100644
--- a/README.md
+++ b/README.md
@@ -277,9 +277,16 @@ behind it falls back to something else. The ball does at least say so out loud,
doing nothing.
**2. The voice key — optional.** A [Volcengine Speech](https://www.volcengine.com/product/voice-tech)
-API key, in the **Voice API key** field. Without it ASR and TTS fail during the WebSocket
-handshake, which surfaces as a **connect timeout** — the device looks like it has a network problem
-when what it has is a blank field. Everything else still works; it is just mute and deaf.
+API key, in the **火山 API key** field of the same **Backend → On-device** tab. Without it ASR and
+TTS fail during the WebSocket handshake, which surfaces as a **connect timeout** — the device looks
+like it has a network problem when what it has is a blank field. Everything else still works; it is
+just mute and deaf.
+
+> **If you took the CodeFlying route in [Quick Start](#quick-start), both keys are already baked in.**
+> ⚙ → **Backend** will show **CodeFlying** as the active tab; LLM, ASR, TTS and the long tail of
+> third-party APIs (image / video / music generation, geolocation, weather, PDF, search, news,
+> stocks, …) all go through one key, wrapped and billed by CodeFlying so you don't sign up for each
+> provider yourself. The two keys above only apply to the **On-device** tab you configure yourself.
You do not have to remember this: the first run is a stepped setup that walks you through both, and
afterwards the **✓** button in the ball's control bar opens the self-check list, which says which of
@@ -637,16 +644,18 @@ For a first install, this order is the shortest path:
2. Go straight to "display over other apps" and grant the overlay → come back and the ball is there
3. Go to Accessibility → enable Andee
4. Tap the ball, and allow the microphone prompt
-5. Open the ⚙ on the ball, set `hub_url` = `ws://<your Mac's IP>:9100`, set `device_name` to anything,
- and save
+5. Open the ⚙ on the ball. In **Advanced**, turn on **Show cloud option** (the **Cloud** tab is
+ hidden by default). Go back to **Backend**, flip the picker to **Cloud**, set `hub_url` =
+ `ws://<your Mac's IP>:9100` and `device_name` to anything, and save
6. logcat should show `hub: registered as body-xxx with N tools`, and the brain side should log
`[body_hub] 'body-xxx' registered (…) with N tools`
If any step does not line up, go back to that section's **Verify**.
-> If you only want the brain on this device, replace step 5 with `brain` = `local` plus an
-> OpenAI-compatible endpoint, and leave `hub_url` empty — running without a hub is a supported mode,
-> not a degraded one.
+> If you only want the brain on this device, replace step 5 with **Backend → On-device** and fill in
+> an OpenAI-compatible endpoint plus `llm_api_key` — running without a hub is a supported mode, not a
+> degraded one. If your APK was packaged via CodeFlying, the **CodeFlying** tab is the default and
+> there is nothing to fill in.
## Wake word ("Hey Andee")
diff --git a/README.zh-CN.md b/README.zh-CN.md
index c5307ab..507256a 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -246,8 +246,14 @@ OpenAI 兼容端点(`llm_api_key`,默认 `https://api.deepseek.com`)。**
—— 它后面没有别的兜底。球至少会把这句话说出来,而不是默默什么都不做。
**2. 语音密钥 —— 非必须。** 一个[火山引擎语音服务](https://www.volcengine.com/product/voice-tech)
-的 API Key,填在「语音密钥」。不填,识别和合成会在 WebSocket 握手阶段失败,**表现为连接超时** ——
-看着像网络坏了,其实是那一栏空着。其余功能照常,只是既听不见也说不出。
+的 API Key,填在**后端 → 本机**同一 tab 下的「火山 API Key」。不填,识别和合成会在 WebSocket
+握手阶段失败,**表现为连接超时** —— 看着像网络坏了,其实是那一栏空着。其余功能照常,只是既听不见
+也说不出。
+
+> **如果你走的是[快速开始](#快速开始)里 CodeFlying 那条路,这两把 Key 都已经在安装包里了。**
+> ⚙ → **后端**会直接显示 **CodeFlying** 这一 tab 为当前后端;LLM、ASR、TTS 以及海量第三方 API
+> (AI 图片/视频/音乐生成、地理位置、天气、PDF、搜索、新闻、股票……)都走同一把 Key,由 CodeFlying
+> 统一封装并计费,免去你逐一申请密钥和维护账单的麻烦。上面两把 Key 只适用于你自己配置的**本机** tab。
这些不用记:第一次启动会有一个分步引导,带你把这两样填好;之后球的控制条上的 **✓** 会打开自检
清单,直接告诉你缺哪一个,并给出去处理的按钮。
@@ -676,14 +682,17 @@ adb usb # 想切回来时执行
2. 立刻去「显示在其他应用上层」开悬浮窗 → 回来能看到球了
3. 去「无障碍」→ 开 Andee
4. 点一下球,弹麦克风申请 → 允许
-5. 打开球上的 ⚙,填 `hub_url` = `ws://<你 Mac 的 IP>:9100`、`device_name` = 随便起,保存
+5. 打开球上的 ⚙,先翻到**高级**把「显示云端选项」打开(**云端** tab 默认是藏起来的);回到
+ **后端**,picker 切到 **云端**,填 `hub_url` = `ws://<你 Mac 的 IP>:9100`、`device_name` =
+ 随便起,保存
6. logcat 里应该出现 `hub: registered as body-xxx with N tools`,同时大脑侧日志出现
`[body_hub] 'body-xxx' registered (…) with N tools`
任一步没对上,回来看本文档对应章节的**验证**。
-> 只想要本机大脑的话,第 5 步改成把 `brain` 选成 `local` 并填一个 OpenAI 兼容端点,`hub_url`
-> 留空即可 —— 服务端模式是合法模式,不需要 hub。
+> 只想要本机大脑的话,第 5 步改成**后端 → 本机**,填一个 OpenAI 兼容端点和 `llm_api_key` 即可 ——
+> 不走 hub 是合法模式,不是降级。如果你的 APK 是通过 CodeFlying 打包的,那条 tab 也是默认选中的
+> 一个,什么都不用填。
## 目录结构
diff --git a/app/src/main/java/net/kuafuai/andee/brain/LocalBrain.kt b/app/src/main/java/net/kuafuai/andee/brain/LocalBrain.kt
index b8d6094..b5ddaba 100644
--- a/app/src/main/java/net/kuafuai/andee/brain/LocalBrain.kt
+++ b/app/src/main/java/net/kuafuai/andee/brain/LocalBrain.kt
@@ -502,7 +502,12 @@ class LocalBrain(
var lastSignature = ""
var repeats = 0
- for (step in 1..MAX_ITERATIONS) {
+ // Read once per turn so the setting can change without a brain
+ // restart — see [VoiceConfig.maxSteps]. Values outside 1..200 are
+ // clamped by the reader; a 0 saved by hand would otherwise refuse
+ // every turn before it started.
+ val maxSteps = net.kuafuai.andee.config.VoiceConfig.maxSteps(appContext)
+ for (step in 1..maxSteps) {
if (gen != generation.get()) return
// `enter_scene` mid-turn should change how the rest of this turn
// reads, not only the next one. A string compare, free when nothing
@@ -588,14 +593,14 @@ class LocalBrain(
if (images.isNotEmpty()) attachImages(images)
}
- Log.w(TAG, "hit MAX_ITERATIONS")
- BrainTrace.end(gen, "hit MAX_ITERATIONS")
+ Log.w(TAG, "hit max steps ($maxSteps)")
+ BrainTrace.end(gen, "hit max steps ($maxSteps)")
if (!internal) {
onFinal(
AppLocale.str(
appContext,
R.string.brain_max_steps,
- MAX_ITERATIONS,
+ maxSteps,
)
)
}
@@ -1084,12 +1089,9 @@ class LocalBrain(
companion object {
private const val TAG = "Brain"
- /**
- * A real task is a dozen steps; this is the runaway guard, and hitting
- * it produces a final answer rather than silence — a ball that just
- * stops is the one failure the user cannot interpret.
- */
- private const val MAX_ITERATIONS = 25
+ // The per-turn step cap moved to [VoiceConfig.maxSteps] / "max_steps"
+ // pref so a user who wants longer tasks can raise it from the settings
+ // card. See the runTurn loop and [VoiceConfig.DEFAULT_MAX_STEPS].
/** Lower than the cloud's 10: a local round costs the user a minute. */
private const val MAX_REPEATS = 3
diff --git a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
index 9576ccd..2564587 100644
--- a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
+++ b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
@@ -406,6 +406,7 @@ data class VoiceConfig(
"sweep_daily_cap" to p.getString(
"sweep_daily_cap", DEFAULT_SWEEP_DAILY_CAP.toString(),
)!!,
+ "max_steps" to maxSteps(context).toString(),
)
}
@@ -433,6 +434,21 @@ data class VoiceConfig(
private fun defaultThinking(): String =
if (BuildConfig.DEFAULT_THINKING.trim().lowercase() == "off") "disabled" else "enabled"
+ /**
+ * Hard cap on tool-call steps per task. A real task is a dozen steps;
+ * this is the runaway guard, and hitting it produces a final answer
+ * rather than silence. Editable from the settings card so a user who
+ * routinely runs longer tasks can raise it; coerced to a sane range
+ * (1..200) so a stray zero doesn't make the brain refuse everything
+ * and a stray thousand doesn't burn an unbounded bill.
+ */
+ const val DEFAULT_MAX_STEPS = 25
+
+ fun maxSteps(context: Context): Int =
+ (context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
+ .getString("max_steps", "")?.trim()?.toIntOrNull()
+ ?: DEFAULT_MAX_STEPS).coerceIn(1, 200)
+
const val LANG_ZH = "zh"
const val LANG_EN = "en"
@@ -558,6 +574,7 @@ data class VoiceConfig(
"lang",
"ball",
"sweep", "sweep_quiet_minutes", "sweep_daily_cap",
+ "max_steps",
)
}
}
diff --git a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
index b89cc67..47aa53a 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
@@ -364,6 +364,7 @@ class SettingsUi(
notebookSection(form)
notifySection(form)
vaultSection(form)
+ maxStepsSection(form)
advancedSection(form)
@@ -374,6 +375,27 @@ class SettingsUi(
return card
}
+ /**
+ * 单次任务最多步数: the per-task runaway guard. In 常用 rather than 高级
+ * because it is a knob a user might actually turn — "the AI gave up
+ * halfway" has one cause and one fix, and burying it behind a disclosure
+ * means the user cannot find the fix on their own.
+ */
+ private fun maxStepsSection(form: LinearLayout) {
+ val panel = group(
+ form,
+ lctx.getString(R.string.settings_max_steps),
+ lctx.getString(R.string.settings_max_steps_note),
+ )
+ field(
+ panel,
+ "max_steps",
+ lctx.getString(R.string.settings_max_steps),
+ hint = VoiceConfig.DEFAULT_MAX_STEPS.toString(),
+ numeric = true,
+ )
+ }
+
/**
* 高级: the three sections a configured device never opens.
*
@@ -857,7 +879,10 @@ class SettingsUi(
private fun confirmBody(text: String): TextView = TextView(context).apply {
this.text = text
textSize = Glass.Type.CAPTION
- setTextColor(Color.parseColor(Glass.MUTED))
+ // SECONDARY, same reason as [noteView]: this is the warning body on a
+ // factory-reset / clear-chat confirm — the one thing the user must
+ // actually read before tapping the red button.
+ setTextColor(Color.parseColor(Glass.SECONDARY))
setLineSpacing(dp(4).toFloat(), 1f)
setPadding(0, dp(8), 0, 0)
}
@@ -1140,8 +1165,12 @@ class SettingsUi(
// least of all — but at 11sp on a 690dp-wide card they end up as one
// line each, which is both harder to read and denser-looking than the
// rows they sit between.
+ //
+ // SECONDARY, not MUTED: these are explanations the user is meant to
+ // read, so one step brighter against the card fill — MUTED is the
+ // right shade for a timestamp or an inactive icon, not a paragraph.
textSize = Glass.Type.CAPTION
- setTextColor(Color.parseColor(Glass.MUTED))
+ setTextColor(Color.parseColor(Glass.SECONDARY))
setLineSpacing(dp(4).toFloat(), 1f)
}
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index 4539452..837639f 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -74,8 +74,8 @@
<string name="settings_brain_codeflying">CodeFlying</string>
<string name="settings_show_hub">Show cloud option</string>
<string name="settings_show_hub_note">Adds a Cloud backend tab for connecting to a hub you host yourself.</string>
- <string name="settings_brain_codeflying_note">Powered by your backend hosted on CodeFlying.app: ships models and voice services by default, plus a per-device database for CRUD-style business logic, and a long tail of third-party API integrations — AI image / video / music generation, geolocation, weather, PDF conversion, search, news, stocks, and more.\n\nNote: using CodeFlying backend services may incur charges.</string>
- <string name="settings_brain_codeflying_unconfigured">CodeFlying is not configured on this Andee. From a computer, visit CodeFlying.app and have it build an Andee install package wired to your own backend — install it over this app and you get the default models, voice services, a per-device database and a long list of third-party API integrations (AI image / video / music generation, weather, location, PDF, search, news, stocks, and more).\n\nNote: using CodeFlying backend services may incur charges.</string>
+ <string name="settings_brain_codeflying_note">Powered by your backend hosted on CodeFlying.app: ships models and voice services by default, with a long tail of third-party API integrations — AI image / video / music generation, geolocation, weather, PDF conversion, search, news, stocks, and more. CodeFlying wraps and bills every third-party API in one place, so you don\'t have to sign up for each provider and juggle their keys and invoices yourself.\n\nNote: using CodeFlying backend services may incur charges.</string>
+ <string name="settings_brain_codeflying_unconfigured">CodeFlying is not configured on this Andee. From a computer, visit CodeFlying.app and have it build an Andee install package wired to your own backend — install it over this app and you get the default models, voice services, and a long list of third-party API integrations (AI image / video / music generation, weather, location, PDF, search, news, stocks, and more). CodeFlying wraps and bills every third-party API in one place, so you don\'t have to sign up for each provider and juggle their keys and invoices yourself.\n\nNote: using CodeFlying backend services may incur charges.</string>
<string name="settings_hub_url">Hub URL</string>
<!-- The hub URL box is empty on a fresh install — the hint is what the
user sees in that empty box, so it is the pitch, not the format. -->
@@ -118,6 +118,8 @@
<string name="settings_voice_tts_sample_rate">TTS sample rate</string>
<string name="settings_section_diagnostics">Diagnostics</string>
<string name="settings_section_advanced">Advanced</string>
+ <string name="settings_max_steps">Max steps per task</string>
+ <string name="settings_max_steps_note">The most tool calls the AI may make in a single task before stopping with a final answer. Guards against runaway loops and bills. Default 25 — a dozen steps is enough for most tasks.</string>
<string name="settings_advanced_note">Show the cloud option, typing, diagnostics and factory reset. Nothing here for day-to-day use.</string>
<string name="settings_grounding">Grounding capture</string>
<string name="settings_grounding_note">Records coordinate taps and screenshots to files/grounding for offline analysis — it photographs whatever you are doing. Needs the accessibility service restarted to take effect.</string>
@@ -260,13 +262,13 @@
<string name="dev_perm_say_notification">I\'ll open Notification access settings — find this app and turn it on.</string>
<string name="history_empty">No conversation yet</string>
<string name="history_role_you">You · %1$s</string>
- <string name="history_role_assistant">Assistant · %1$s</string>
+ <string name="history_role_assistant">Andee · %1$s</string>
<string name="history_role_error">Error · %1$s</string>
<string name="history_role_page_open">Page · %1$s · Tap to reopen</string>
<string name="history_role_page_cleared">Page · %1$s · Cleared</string>
<string name="html_default_title">AI page</string>
<string name="textpage_role_you">You</string>
- <string name="textpage_role_assistant">Assistant</string>
+ <string name="textpage_role_assistant">Andee</string>
<string name="textpage_role_error">Error</string>
<string name="textpage_role_page">Page</string>
<string name="card_ack">Got it</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c5aebb9..de2cdf8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -51,8 +51,8 @@
<string name="settings_brain_codeflying">CodeFlying</string>
<string name="settings_show_hub">显示云端选项</string>
<string name="settings_show_hub_note">把「云端」加到后端选项里,用来连你自己搭的 Hub。</string>
- <string name="settings_brain_codeflying_note">由您在 CodeFlying.net 平台托管的后端服务提供支持:默认提供模型和语音服务,并支持独立数据库能力实现数据持久化(增删改查等业务逻辑),以及海量第三方 API 集成——AI 图片/视频/音乐生成,地理位置、天气、PDF 转换、搜索、新闻、股票等等。\n\n注意:使用 CodeFlying 的后端服务可能会产生费用。</string>
- <string name="settings_brain_codeflying_unconfigured">这台 Andee 没有配置 CodeFlying。到电脑上访问 CodeFlying.net,用它一键生成带有您专属后端的 Andee 安装包并替换当前应用,就能用上默认模型、语音、持久化数据库和海量第三方 API(AI 图片/视频/音乐生成、天气、位置、PDF、搜索、新闻、股票等等)。\n\n注意:使用 CodeFlying 的后端服务可能会产生费用。</string>
+ <string name="settings_brain_codeflying_note">由您在 CodeFlying.net 平台托管的后端服务提供支持:默认提供模型和语音服务,并集成海量第三方 API——AI 图片/视频/音乐生成,地理位置、天气、PDF 转换、搜索、新闻、股票等等。所有第三方 API 由 CodeFlying 统一封装并计费,免去您自己逐一申请密钥和维护账单的麻烦。\n\n注意:使用 CodeFlying 的后端服务可能会产生费用。</string>
+ <string name="settings_brain_codeflying_unconfigured">这台 Andee 没有配置 CodeFlying。到电脑上访问 CodeFlying.net,用它一键生成带有您专属后端的 Andee 安装包并替换当前应用,就能用上默认模型、语音以及海量第三方 API(AI 图片/视频/音乐生成、天气、位置、PDF、搜索、新闻、股票等等)。所有第三方 API 由 CodeFlying 统一封装并计费,免去您自己逐一申请密钥和维护账单的麻烦。\n\n注意:使用 CodeFlying 的后端服务可能会产生费用。</string>
<string name="settings_hub_url">Hub 地址</string>
<!-- The hub URL box is empty on a fresh install — the hint is what the
user sees in that empty box, so it is the pitch, not the format. -->
@@ -95,6 +95,8 @@
<string name="settings_voice_tts_sample_rate">合成采样率</string>
<string name="settings_section_diagnostics">诊断</string>
<string name="settings_section_advanced">高级</string>
+ <string name="settings_max_steps">单次任务最多步数</string>
+ <string name="settings_max_steps_note">每轮任务里 AI 最多能调用多少次工具。超过就停下并给个结束语,防止死循环烧 token。默认 25,一般的任务十几步就够了。</string>
<string name="settings_advanced_note">显示云端选项、打字、诊断和恢复出厂设置。日常用不到,都藏在这里。</string>
<string name="settings_grounding">接地采集</string>
<string name="settings_grounding_note">把坐标点击和截图记到 files/grounding 供离线分析 —— 它会拍下你当时在做的事。改完要重开无障碍服务才生效。</string>
@@ -241,13 +243,13 @@
<string name="dev_perm_say_notification">会打开通知使用权设置,找到这个应用打开开关。</string>
<string name="history_empty">还没有对话</string>
<string name="history_role_you">你 · %1$s</string>
- <string name="history_role_assistant">助手 · %1$s</string>
+ <string name="history_role_assistant">Andee · %1$s</string>
<string name="history_role_error">出错 · %1$s</string>
<string name="history_role_page_open">界面 · %1$s · 点击重新打开</string>
<string name="history_role_page_cleared">界面 · %1$s · 已清理</string>
<string name="html_default_title">AI 界面</string>
<string name="textpage_role_you">你</string>
- <string name="textpage_role_assistant">助手</string>
+ <string name="textpage_role_assistant">Andee</string>
<string name="textpage_role_error">出错</string>
<string name="textpage_role_page">界面</string>
<string name="card_ack">知道了</string>