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: CodeFlying is the default backend, with a typed key and a link to get one

booboosuifb12fcac19c1
diff --git a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
index 78ca35c..5ea11a1 100644
--- a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
+++ b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
@@ -1996,6 +1996,17 @@ class BodyCoreService : Service() {
},
onClearChat = { clearChatHistory() },
onClearNotes = { clearNotebook() },
+ // The card comes down first: an overlay left up would sit over the
+ // page it just opened. Same trip as the self-check card's errand.
+ onOpenLink = { url ->
+ window.setPagePerched(true)
+ net.kuafuai.andee.ui.SelfCheckActivity.showForErrand(
+ this,
+ android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse(url)),
+ )
+ dispatcher.compactForUser()
+ settings?.hide()
+ },
// The card owns its own language switch; the ball, the scrollback
// and the pinned tips live in this service and have to be told.
// See FloatingWindowUi.onLocaleChanged.
@@ -2724,13 +2735,20 @@ class BodyCoreService : Service() {
// with no key answers nothing at all, and "nothing at all" is the one
// failure a user cannot diagnose from the outside.
if (bc.apiKey.isEmpty()) {
- reportNoBrain(AppLocale.str(this, R.string.svc_no_brain_local), announce)
+ reportNoBrain(
+ AppLocale.str(
+ this,
+ if (bc.mode == net.kuafuai.andee.config.VoiceConfig.BRAIN_CODEFLYING) R.string.svc_no_brain_codeflying
+ else R.string.svc_no_brain_local,
+ ),
+ announce,
+ )
}
// CodeFlying is the only backend with a market behind it. Everywhere
// else this object is inert — empty tool list, `hasMethod` always false
// — so a local or hub brain's tool surface is exactly what it was.
val market = net.kuafuai.andee.market.MarketTools(
- baseUrl = net.kuafuai.andee.config.VoiceConfig.codeFlyingMarketBaseUrl(),
+ baseUrl = net.kuafuai.andee.config.VoiceConfig.codeFlyingMarketBaseUrl(this),
apiKey = bc.apiKey,
enabled = bc.mode == net.kuafuai.andee.config.VoiceConfig.BRAIN_CODEFLYING,
)
diff --git a/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt b/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt
index 928fb9d..dc47ee2 100644
--- a/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt
+++ b/app/src/main/java/net/kuafuai/andee/brain/AndroidBrainHost.kt
@@ -116,13 +116,13 @@ class AndroidBrainHost(
private fun res(key: BrainText): Int = when (key) {
BrainText.NO_KEY -> R.string.brain_no_key
+ BrainText.NO_KEY_CODEFLYING -> R.string.brain_no_key_codeflying
BrainText.NO_RESULT -> R.string.brain_no_result
BrainText.REPEAT_STOP -> R.string.brain_repeat_stop
BrainText.MAX_STEPS -> R.string.brain_max_steps
BrainText.ERROR -> R.string.brain_error
BrainText.ERROR_400 -> R.string.brain_error_400
BrainText.ERROR_402 -> R.string.brain_error_402
- BrainText.ERROR_402_CODEFLYING -> R.string.brain_error_402_codeflying
BrainText.ERROR_404 -> R.string.brain_error_404
BrainText.ERROR_429 -> R.string.brain_error_429
BrainText.ERROR_5XX -> R.string.brain_error_5xx
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 887fe2b..f06150d 100644
--- a/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
+++ b/app/src/main/java/net/kuafuai/andee/config/VoiceConfig.kt
@@ -45,6 +45,8 @@ object VoiceConfig {
*/
internal val OVERRIDE_KEYS = setOf(
"api_key", "asr_endpoint", "tts_endpoint",
+ // Blank goes back to the key the build carries.
+ "codeflying_key",
// The Google rows all have a real value to fall back to — the
// build's, or the constant — so an empty box means "use that",
// which is the only way back to a baked-in key.
@@ -205,70 +207,47 @@ object VoiceConfig {
if (uiLanguage(context) == LANG_EN) DEFAULT_LLM_MODEL_EN else DEFAULT_LLM_MODEL
/**
- * CodeFlying is available iff the build was configured with ENABLED and
- * a non-empty DOMAIN. ENABLED alone with no DOMAIN silently falls back
- * to [BRAIN_LOCAL] — the picker hides the CodeFlying tab and the
- * default brain reads as local.
+ * The CodeFlying server, from the build's `CODEFLYING_DOMAIN`. There is no
+ * "available" switch: CodeFlying is always a choice and the default one, and
+ * a build packaged without a domain simply has nowhere to send it yet.
*/
- fun isCodeFlyingAvailable(): Boolean =
- BuildConfig.CODEFLYING_ENABLED && BuildConfig.CODEFLYING_DOMAIN.isNotBlank()
+ fun codeFlyingEndpoint(@Suppress("UNUSED_PARAMETER") context: Context): net.kuafuai.andee.config.CodeFlyingEndpoint? =
+ net.kuafuai.andee.config.CodeFlyingEndpoint.parse(
+ BuildConfig.CODEFLYING_DOMAIN, BuildConfig.CODEFLYING_SSL_ENABLED,
+ )
/**
* The CodeFlying API key in effect for this install.
*
- * Read from `assets/andee_key.txt` first: production APKs are built once
- * from shared source (empty key) and the per-user `kft_` token is written
- * into that asset at package time, so a Gradle rebuild is not needed per
- * user. Dev builds that never had the file (or have a blank one) fall
- * back to [BuildConfig.CODEFLYING_KEY] from local.properties.
+ * A key the user typed (`codeflying_key`) wins. Otherwise
+ * `assets/andee_key.txt`: production APKs are built once from shared
+ * source (empty key) and the per-user `kft_` token is written into that
+ * asset at package time. Dev builds fall back to
+ * [BuildConfig.CODEFLYING_KEY] from local.properties.
*/
fun codeFlyingKey(context: Context): String =
+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
+ .getString("codeflying_key", "").orEmpty().trim()
+ .ifEmpty { codeFlyingBuiltInKey(context) }
+
+ /** The key that came with the APK, ignoring anything typed. */
+ fun codeFlyingBuiltInKey(context: Context): String =
runCatching {
context.assets.open("andee_key.txt").bufferedReader().use { it.readText().trim() }
}.getOrDefault("").ifEmpty { BuildConfig.CODEFLYING_KEY }
- /** `wss` / `ws` for WebSocket URLs, chosen by `CODEFLYING_SSL_ENABLED`. */
- private fun codeFlyingWsScheme(): String =
- if (BuildConfig.CODEFLYING_SSL_ENABLED) "wss" else "ws"
-
- /** `https` / `http` for the LLM REST base URL. */
- private fun codeFlyingHttpScheme(): String =
- if (BuildConfig.CODEFLYING_SSL_ENABLED) "https" else "http"
-
- /** Bare host, no scheme and no trailing slash. One place, so the three URLs below cannot drift. */
- private fun codeFlyingHost(): String =
- BuildConfig.CODEFLYING_DOMAIN.trim().trimEnd('/')
-
- /** Bare CodeFlying origin, e.g. `http://124.71.176.202`. */
- fun codeFlyingBaseUrl(): String = "${codeFlyingHttpScheme()}://${codeFlyingHost()}"
-
- /**
- * Origin for the market tool endpoints, e.g. `http://host/baas-api`.
- *
- * `/baas-api/` exists because the bare `/api/` on that host is the
- * front-end's static directory — nginx only forwards that tree to baas
- * under this prefix. The voice endpoints need no such prefix (`/voice/`
- * has its own location), which is why this is a separate accessor rather
- * than folded into [codeFlyingBaseUrl]: pointing the LLM and ASR/TTS at
- * `/baas-api/` as well would put the WebSocket upgrade on a location that
- * may not carry the `Upgrade` headers.
- *
- * The `/baas-api` segment is a deployment detail, like the `/voice/llm`
- * suffix above it — it belongs to whichever nginx the build points at.
- */
- fun codeFlyingMarketBaseUrl(): String = "${codeFlyingBaseUrl()}/baas-api"
+ /** Origin for the market tools; see [net.kuafuai.andee.config.CodeFlyingEndpoint.marketBaseUrl]. */
+ fun codeFlyingMarketBaseUrl(context: Context): String =
+ codeFlyingEndpoint(context)?.marketBaseUrl.orEmpty()
- /** WebSocket origin, same host on the `ws`/`wss` scheme. */
- private fun codeFlyingWsBaseUrl(): String = "${codeFlyingWsScheme()}://${codeFlyingHost()}"
+ fun codeFlyingLlmBaseUrl(context: Context): String =
+ codeFlyingEndpoint(context)?.llmBaseUrl.orEmpty()
- /** Full LLM REST base URL for CodeFlying, e.g. `https://foo.net/voice/llm`. */
- fun codeFlyingLlmBaseUrl(): String = "${codeFlyingBaseUrl()}/voice/llm"
+ fun codeFlyingAsrEndpoint(context: Context): String =
+ codeFlyingEndpoint(context)?.asrEndpoint.orEmpty()
- /** Full ASR WebSocket URL for CodeFlying. */
- fun codeFlyingAsrEndpoint(): String = "${codeFlyingWsBaseUrl()}/voice/asr/bigmodel_async"
-
- /** Full TTS WebSocket URL for CodeFlying. */
- fun codeFlyingTtsEndpoint(): String = "${codeFlyingWsBaseUrl()}/voice/tts/bidirection"
+ fun codeFlyingTtsEndpoint(context: Context): String =
+ codeFlyingEndpoint(context)?.ttsEndpoint.orEmpty()
/**
* Which palette the UI draws with. `true` = night, and false = day.
@@ -355,7 +334,7 @@ object VoiceConfig {
*/
fun brainMode(context: Context): String {
val p = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
- return resolveBrainMode(p.getString("brain", ""))
+ return resolveBrainMode(context, p.getString("brain", ""))
}
/**
@@ -373,13 +352,13 @@ object VoiceConfig {
* play" is how a build that does not enable it ends up hiding the very
* voice settings it is reading from.
*/
- fun resolveBrainMode(raw: String?): String {
+ fun resolveBrainMode(context: Context, raw: String?): String {
val saved = raw?.trim()?.lowercase().orEmpty()
return when (saved) {
BRAIN_HUB -> BRAIN_HUB
BRAIN_LOCAL -> BRAIN_LOCAL
- BRAIN_CODEFLYING -> if (isCodeFlyingAvailable()) BRAIN_CODEFLYING else BRAIN_LOCAL
- "" -> if (isCodeFlyingAvailable()) BRAIN_CODEFLYING else BRAIN_LOCAL
+ BRAIN_CODEFLYING -> BRAIN_CODEFLYING
+ "" -> BRAIN_CODEFLYING
else -> BRAIN_LOCAL
}
}
@@ -395,7 +374,7 @@ object VoiceConfig {
return BrainConfig(
mode = BRAIN_CODEFLYING,
apiKey = codeFlyingKey(context),
- baseUrl = codeFlyingLlmBaseUrl(),
+ baseUrl = codeFlyingLlmBaseUrl(context),
model = p.getString("llm_model", DEFAULT_LLM_MODEL)
.orEmpty().trim().ifEmpty { DEFAULT_LLM_MODEL },
thinking = p.getString("llm_thinking", defaultThinking())
@@ -567,13 +546,13 @@ object VoiceConfig {
return VoiceSettings(
apiKey = if (codeFlying) codeFlyingKey(context)
else p.getString("api_key", "").orEmpty().trim().ifEmpty { API_KEY },
- asrEndpoint = if (codeFlying) codeFlyingAsrEndpoint()
+ asrEndpoint = if (codeFlying) codeFlyingAsrEndpoint(context)
else p.getString("asr_endpoint", null)
?.takeIf { it.isNotEmpty() }
?: DEFAULT_ASR_ENDPOINT,
asrResourceId = p.getString("asr_resource_id", DEFAULT_ASR_RESOURCE)!!,
asrUid = uid,
- ttsEndpoint = if (codeFlying) codeFlyingTtsEndpoint()
+ ttsEndpoint = if (codeFlying) codeFlyingTtsEndpoint(context)
else p.getString("tts_endpoint", null)
?.takeIf { it.isNotEmpty() }
?: DEFAULT_TTS_ENDPOINT,
@@ -620,6 +599,12 @@ object VoiceConfig {
// keys that have a real compiled-in default: there, blank is
// the only way back to it. Route them before the drop, or an
// override once saved could never be taken out.
+ // The card shows the key in effect, so saving it back unchanged must not
+ // pin the build's key as a user override: store only a different one.
+ if (k == "codeflying_key" && v.trim() == codeFlyingBuiltInKey(context)) {
+ p.remove(k)
+ continue
+ }
if (k in OVERRIDE_KEYS) {
if (v.isBlank()) p.remove(k) else p.putString(k, v.trim())
continue
@@ -648,6 +633,7 @@ object VoiceConfig {
// overridable from local.properties now, so the settings card
// must show saved-or-empty rather than saved-or-default.
"api_key" to p.getString("api_key", "").orEmpty(),
+ "codeflying_key" to codeFlyingKey(context),
"asr_endpoint" to p.getString("asr_endpoint", "").orEmpty(),
"asr_resource_id" to p.getString("asr_resource_id", DEFAULT_ASR_RESOURCE)!!,
"uid" to p.getString("uid", "").orEmpty(),
@@ -670,7 +656,10 @@ object VoiceConfig {
"hub_url" to hc.url,
"device_id" to hc.deviceId,
"device_name" to hc.deviceName,
- "brain" to bc.mode,
+ // What the card selects: nothing saved is CodeFlying (the default tab for a
+ // new install), whether or not this build can run it — the tab then says so.
+ // Not bc.mode, which has CodeFlying already resolved away to local.
+ "brain" to p.getString("brain", "").orEmpty().trim().lowercase().ifEmpty { BRAIN_CODEFLYING },
"show_hub" to if (showHub(context)) "on" else "off",
// llm_api_key / llm_base_url / llm_model are the 本机 tab's rows —
// the user's own credentials and the endpoint they point at.
@@ -913,6 +902,7 @@ object VoiceConfig {
"theme",
"uid",
"api_key",
+ "codeflying_key",
"asr_endpoint", "asr_resource_id",
"tts_endpoint", "tts_resource_id", "tts_sample_rate",
"voice_provider",
diff --git a/app/src/main/java/net/kuafuai/andee/device/SelfCheck.kt b/app/src/main/java/net/kuafuai/andee/device/SelfCheck.kt
index a1f6d32..be593a6 100644
--- a/app/src/main/java/net/kuafuai/andee/device/SelfCheck.kt
+++ b/app/src/main/java/net/kuafuai/andee/device/SelfCheck.kt
@@ -400,6 +400,7 @@ object SelfCheck {
level = if (missing) Level.FAIL else Level.OK,
detail = when {
!missing -> R.string.check_detail_brain_on
+ bc.mode == VoiceConfig.BRAIN_CODEFLYING -> R.string.check_detail_brain_codeflying_key_missing
bc.isLocal -> R.string.check_detail_brain_key_missing
else -> R.string.check_detail_brain_hub_missing
},
@@ -910,6 +911,7 @@ object SelfCheck {
title = R.string.check_title_voice_key,
level = if (has) Level.OK else Level.WARN,
detail = if (has) R.string.check_detail_voice_key_ok
+ else if (VoiceConfig.brainMode(context) == VoiceConfig.BRAIN_CODEFLYING) R.string.check_detail_voice_key_codeflying_missing
else R.string.check_detail_voice_key_missing,
fix = if (has) Fix.Nothing else Fix.OurSettings,
)
diff --git a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt
index 1cfcf44..76bf764 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt
@@ -1,6 +1,7 @@
package net.kuafuai.andee.ui
import android.content.Intent
+import android.net.Uri
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.provider.Settings
@@ -550,6 +551,9 @@ class SelfCheckActivity : StageActivity() {
onFactoryReset = { FactoryReset.wipe(this) },
onClearChat = { ChatHistory.wipe(this) },
onClearNotes = { Notebook.wipe(this) },
+ // This host is an Activity: it can open a browser itself, and the
+ // card is hosted by the sheet that stays here when the user comes back.
+ onOpenLink = { url -> runCatching { startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) } },
onLocaleChanged = {
paintedLang = VoiceConfig.uiLanguage(this)
if (::ui.isInitialized) ui.repaintForLanguage()
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 212ca87..ce18099 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt
@@ -119,6 +119,14 @@ class SettingsUi(
* future caller) still switches its own language correctly.
*/
private val onLocaleChanged: () -> Unit = {},
+ /**
+ * Open a web page. An overlay cannot launch a browser itself (the
+ * background-launch restriction), so the host does it: the service via
+ * `SelfCheckActivity.showForErrand`, the Activity host directly. The host
+ * also takes this card down first — an overlay left up would sit on top of
+ * the page it just opened.
+ */
+ private val onOpenLink: (String) -> Unit = {},
) {
private val wm: WindowManager =
@@ -578,7 +586,7 @@ class SettingsUi(
*
* Visibility rules:
* * **CodeFlying** is only in the picker when the build enables it with a
- * non-empty domain (see [VoiceConfig.isCodeFlyingAvailable]). The tab
+ * non-empty domain (the build's CODEFLYING_DOMAIN). The tab
* itself has no editable rows — endpoints and credential are compiled
* in — just a note describing what the hosted backend offers.
* * **云端** is only in the picker when the user has turned the "显示
@@ -609,9 +617,11 @@ class SettingsUi(
// the saved value sticks, so the picker rebuilds correctly, and
// installing a configured build later flips the behaviour on without
// the user having to re-pick.
+ // CodeFlying leads: it is the default tab on a fresh install, and the
+ // leftmost cell is the fallback (see [segmented]).
val options = buildList {
- add(VoiceConfig.BRAIN_LOCAL to lctx.getString(R.string.settings_brain_local))
add(VoiceConfig.BRAIN_CODEFLYING to lctx.getString(R.string.settings_brain_codeflying))
+ add(VoiceConfig.BRAIN_LOCAL to lctx.getString(R.string.settings_brain_local))
if (VoiceConfig.showHub(context)) {
add(VoiceConfig.BRAIN_HUB to lctx.getString(R.string.settings_brain_cloud))
}
@@ -639,28 +649,30 @@ class SettingsUi(
)
note(hubBlock, lctx.getString(R.string.settings_brain_cloud_note))
- // ---- CodeFlying tab (description only) ----
- // Which note depends on whether this build was configured for
- // CodeFlying: configured says "what this is, you may be billed",
- // unconfigured says "it's not set up on this APK, go to the website".
+ // ---- CodeFlying tab ----
+ // No "connected or not": the tab is the default, and the one thing it has
+ // to say is how to get a key while there is none. With a key it says what
+ // the backend is.
val cfBlock = block(panel)
- val cfReady = VoiceConfig.isCodeFlyingAvailable()
- // A person who lands on this tab has already said "I don't have keys".
- // If this build carries no CodeFlying either, that has to be the first
- // thing said, not a paragraph they have to infer it from — the note
- // below explains how to get one, but only this line says the tab in
- // front of them is currently doing nothing.
- if (!cfReady) {
- cfBlock.addView(noteView(lctx.getString(R.string.settings_codeflying_not_connected)).apply {
- setTextColor(Color.parseColor(Glass.WARN))
- }, rowParams(dp(4)))
+ val cfKeyed = VoiceConfig.codeFlyingKey(context).isNotEmpty()
+ // Same words and same link whether or not a key is set: the tab does not
+ // describe the state, the key box below does.
+ note(cfBlock, lctx.getString(R.string.settings_brain_codeflying_note))
+ note(cfBlock, lctx.getString(R.string.settings_codeflying_get_key))
+ linkNote(cfBlock, lctx.getString(R.string.settings_codeflying_open_site)) {
+ onOpenLink(lctx.getString(R.string.codeflying_url))
}
- val cfNoteKey = if (cfReady) {
- R.string.settings_brain_codeflying_note
- } else {
- R.string.settings_brain_codeflying_unconfigured
- }
- note(cfBlock, lctx.getString(cfNoteKey))
+ // Shows the key in effect (typed, else the build's); editing it overrides.
+ // The server address is the build's and has no row. The key row is always
+ // here: it is where a person who just got a key from the link above puts it.
+ field(
+ cfBlock,
+ "codeflying_key",
+ lctx.getString(R.string.settings_codeflying_key),
+ hint = "kft_…",
+ secret = true,
+ copyValue = { VoiceConfig.codeFlyingKey(context) },
+ )
// ---- 本机 tab: LLM + 火山 voice rows ----
val localBlock = block(panel)
@@ -874,11 +886,10 @@ class SettingsUi(
Glass.setVisible(hubBlock, m == VoiceConfig.BRAIN_HUB, animate)
Glass.setVisible(cfBlock, m == VoiceConfig.BRAIN_CODEFLYING, animate)
Glass.setVisible(localBlock, m == VoiceConfig.BRAIN_LOCAL, animate)
- Glass.setVisible(
- voiceBlock,
- VoiceConfig.resolveBrainMode(m) != VoiceConfig.BRAIN_CODEFLYING,
- animate,
- )
+ // Keyed on the tab the user is looking at, not on what the build
+ // can resolve it to: CodeFlying carries its own voice, and a voice
+ // key row under that tab is a row nothing reads.
+ Glass.setVisible(voiceBlock, m != VoiceConfig.BRAIN_CODEFLYING, animate)
}
applyMode(mode, false)
applyThinking = { th, animate ->
@@ -1520,6 +1531,8 @@ class SettingsUi(
hint: String? = null,
numeric: Boolean = false,
secret: Boolean = false,
+ /** When set, a 复制 link sits beside the 显示 toggle and copies this (the value in effect, even if the box is blank). */
+ copyValue: (() -> String)? = null,
) {
rowLabel(parent, label)
val et = EditText(context).apply {
@@ -1569,6 +1582,24 @@ class SettingsUi(
text = if (shown) lctx.getString(R.string.common_hide) else lctx.getString(R.string.common_show)
}
})
+ if (copyValue != null) {
+ row.addView(TextView(context).apply {
+ text = lctx.getString(R.string.common_copy)
+ textSize = Glass.Type.CAPTION
+ setTextColor(Color.parseColor(Glass.ACCENT))
+ setPadding(dp(10), dp(8), dp(2), dp(8))
+ isClickable = true
+ setOnClickListener {
+ val v = et.text?.toString().orEmpty().trim().ifEmpty { copyValue() }
+ if (v.isNotEmpty()) {
+ val cm = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
+ cm.setPrimaryClip(android.content.ClipData.newPlainText("CodeFlying", v))
+ text = lctx.getString(R.string.common_copied)
+ postDelayed({ text = lctx.getString(R.string.common_copy) }, 1500)
+ }
+ }
+ })
+ }
parent.addView(row, rowParams(dp(5)))
}
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index 6f6433e..0340c22 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -68,14 +68,13 @@
<string name="settings_clear_notes_confirm_body">Everything it noted down, your preferences, and any reminder not yet due are deleted, with no way back. The current chat history is untouched.</string>
<string name="settings_clear_notes_confirm">Clear it</string>
<string name="settings_section_brain">Backend</string>
- <string name="settings_brain_panel_note">Takes effect when you close this panel — no need to restart the accessibility service.</string>
+ <string name="settings_brain_panel_note">The AI model and voice service Andee uses to think, listen and speak.</string>
<string name="settings_brain_cloud">Cloud</string>
<string name="settings_brain_local">On-device</string>
<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">CodeFlying (CodeFlying.app) is connected: models and voice are set up and ready to go. You can also tap into a long list of third-party services — AI image, video and music generation, location, weather, PDF conversion, search, news, stocks and more. CodeFlying wraps and bills all of them in one place, so you never have to sign up with each provider or juggle their keys and invoices.\n\nAccount and top-ups: open CodeFlying.app in a computer browser and sign in. If you see a balance error (HTTP 402), top up there.\n\nNote: using CodeFlying backend services may incur charges.</string>
- <string name="settings_brain_codeflying_unconfigured">Want Andee to draw, make videos, write music, check the weather, search the news, convert PDFs, or watch stocks for you? Connect CodeFlying: models and voice come set up, and a long list of third-party services is one hookup away, with no separate sign-ups, keys or invoices.\n\nTo get started, open CodeFlying.app in a computer browser and generate your own Andee install package in one click, then install it over this app. New users get free credit, so you can try it first.\n\nNote: using CodeFlying backend services may incur charges.</string>
+ <string name="settings_brain_codeflying_note">CodeFlying (CodeFlying.app): models and voice come set up for you; add your key and it works. You can also tap into a long list of third-party services — AI image, video and music generation, location, weather, PDF conversion, search, news, stocks and more. CodeFlying wraps and bills all of them in one place, so you never have to sign up with each provider or juggle their keys and invoices.\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. -->
@@ -94,8 +93,13 @@
<string name="common_medium">Medium</string>
<string name="common_low">Low</string>
<string name="settings_brain_local_note">The device runs the agent loop itself, with no hub. Without a key it will not take over.</string>
- <string name="settings_codeflying_not_connected">CodeFlying is not connected yet</string>
+ <string name="settings_codeflying_get_key">No key? Sign up at the link below, then paste your key into the box underneath. New users get free credit.</string>
+ <string name="settings_codeflying_open_site">Open CodeFlying.app ›</string>
+ <string name="codeflying_url" translatable="false">https://www.codeflying.app/andee</string>
<string name="settings_no_key_use_codeflying">No key? Tap here to switch to CodeFlying</string>
+ <string name="settings_codeflying_key">CodeFlying key</string>
+ <string name="common_copy">Copy</string>
+ <string name="common_copied">Copied</string>
<string name="settings_section_wake">Wake word</string>
<string name="settings_wake_enrolled">Enrolled — say your wake word and it wakes up</string>
<string name="settings_wake_not_enrolled">Not enrolled — pick a phrase and say it 3 times to wake me by voice, e.g. “Hey Andee”</string>
@@ -421,6 +425,8 @@
<string name="svc_notification_auto_line">(%1$s has a message — taking a look myself…)</string>
<string name="svc_no_brain_hub">No brain is connected yet, so I can\'t speak.</string>
<string name="svc_no_brain_local">The local brain has no key yet, so I can\'t speak.</string>
+ <string name="svc_no_brain_codeflying">There is no CodeFlying key yet, so I can\'t speak.</string>
+ <string name="svc_btn_get_key">Get a key</string>
<string name="notebook_dump_header">"Notebook · %1$d memories\n"</string>
<string name="notebook_dump_sort_note">"(Listed by type and most-recently updated; read-only)\n\n"</string>
@@ -475,9 +481,9 @@
<!-- LocalBrain — display half only; see the comment on the Chinese side. -->
<string name="brain_no_key">The on-device brain has no API key yet. Long-press the ball to bring the card back, tap ⚙ in the control bar, and put the key in Backend → On-device → “DeepSeek Key”.</string>
+ <string name="brain_no_key_codeflying">There is no CodeFlying key yet. Long-press the ball to bring the card back, tap ⚙, and paste the key under Backend → CodeFlying. No key? Get one at CodeFlying.app.</string>
<string name="brain_error">Something broke on my side: %1$s</string>
<string name="brain_error_402">The backend answered 402, which most likely means the account is out of balance. Open Settings → Backend to see which provider you are using, then top up on that provider\'s website and try again.</string>
- <string name="brain_error_402_codeflying">The backend answered 402, which most likely means your CodeFlying balance has run out. Open CodeFlying.app in a computer browser, sign in, top up, and try again.</string>
<string name="brain_error_auth">The backend refused the request (HTTP %1$d): the key is wrong, expired or disabled. Check the key in Settings → Backend, and generate a new one on the provider\'s website if needed.</string>
<string name="brain_error_400">The backend rejected the request: %1$s\nThe usual cause is a misspelled model name. Check it in Settings → Backend.</string>
<string name="brain_error_404">The backend could not find that address (HTTP 404). Check the endpoint URL and the model name in Settings → Backend.</string>
@@ -545,6 +551,7 @@
<string name="check_detail_brain_on">Configured.</string>
<string name="check_detail_brain_hub_missing">Not set. The brain is set to the cloud, so the address of your own hub goes in ⚙ → Backend → Cloud → “Hub URL”. The Cloud tab is hidden by default — if you cannot see it, turn on Advanced → “Show cloud option” first. Without it there is nowhere to send what you say: no answers, and nothing on screen moves. To have this device think for itself, pick “On-device” in the same row.</string>
<string name="check_detail_brain_key_missing">Not set. The brain is set to run on this device, so open a DeepSeek account of your own and put the key in ⚙ → Backend → On-device → “DeepSeek Key”. Without it, what you say arrives and nothing can be answered or acted on.</string>
+ <string name="check_detail_brain_codeflying_key_missing">Not set. The backend is CodeFlying: sign up at CodeFlying.app, then put the key in ⚙ → Backend → CodeFlying. Without it, what you say arrives and nothing can be answered or acted on.</string>
<string name="check_detail_model_cloud">Cloud assistant — the model is not on this device.</string>
<string name="check_detail_model_no_key">No key yet. Fill one in and this becomes testable.</string>
<string name="check_detail_checking">Checking…</string>
@@ -582,6 +589,7 @@
<string name="check_detail_mic_off">Not allowed. Tapping the ball does nothing at all — the failure that least resembles a permission problem.</string>
<string name="check_detail_voice_key_ok">Set. Recognition and synthesis use it to reach the provider.</string>
<string name="check_detail_voice_key_missing">Not set. The source ships without a key — open a speech service of your own and put its key in ⚙ → Backend → On-device. Without it, hearing and speaking cannot connect, and what you get back is a connection timeout that looks like a network fault. Everything else works.</string>
+ <string name="check_detail_voice_key_codeflying_missing">Voice uses the same CodeFlying key as the brain: put it in ⚙ → Backend → CodeFlying. Without it, listening and speaking cannot connect.</string>
<string name="check_detail_voice_host_ok">%1$s is reachable.</string>
<string name="check_detail_voice_host_bad">Could not reach %1$s: %2$s. Both recognition and synthesis will time out.</string>
<string name="check_detail_wake_on">Taught, and it wakes when you say it.</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f6a6208..3e43c4e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -45,14 +45,13 @@
<string name="settings_clear_notes_confirm_body">它记下的事、你的偏好、还没到点的提醒,都会删掉,找不回来。这场聊天记录不受影响。</string>
<string name="settings_clear_notes_confirm">确认清空</string>
<string name="settings_section_brain">后端</string>
- <string name="settings_brain_panel_note">关掉这个面板就生效,不用重开无障碍服务。</string>
+ <string name="settings_brain_panel_note">提供 AI 模型和语音服务,Andee 靠它思考、听和说。</string>
<string name="settings_brain_cloud">云端</string>
<string name="settings_brain_local">本机</string>
<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(CodeFlying.net):默认模型和语音都配好了,开箱就能用。还能直接调用海量第三方能力 —— AI 画图/做视频/写音乐、定位、天气、PDF 转换、搜索、新闻、股票……全部由 CodeFlying 统一封装、统一计费,不用自己逐个去申请密钥、对账单。\n\n账户管理和充值:用电脑浏览器打开 CodeFlying.net 登录。如果提示余额不足(HTTP 402),去那里充值即可。\n\n提示:使用 CodeFlying 的后端服务可能会产生费用。</string>
- <string name="settings_brain_codeflying_unconfigured">想让 Andee 直接会画图、做视频、写音乐、查天气、搜新闻、转 PDF、看股票?接上 CodeFlying 就行:默认模型和语音都帮你配好,海量第三方能力一次接入,不用自己逐个申请密钥、对账单。\n\n怎么开始:用电脑浏览器打开 CodeFlying.net,一键生成专属于你的 Andee 安装包,装上去替换当前应用就好。新用户可免费获得额度,先试试再决定。\n\n提示:使用 CodeFlying 的后端服务可能会产生费用。</string>
+ <string name="settings_brain_codeflying_note">CodeFlying(CodeFlying.net):默认模型和语音都帮你配好,填上密钥就能用。还能直接调用海量第三方能力 —— AI 画图/做视频/写音乐、定位、天气、PDF 转换、搜索、新闻、股票……全部由 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. -->
@@ -71,8 +70,13 @@
<string name="common_medium">中</string>
<string name="common_low">低</string>
<string name="settings_brain_local_note">设备自己跑 agent loop,不连 Hub。没有 Key 就不会接管。</string>
- <string name="settings_codeflying_not_connected">您还未接入 CodeFlying</string>
+ <string name="settings_codeflying_get_key">没有密钥?到下面的链接注册登录,复制你的密钥粘贴到下方输入框。新用户可免费获得额度。</string>
+ <string name="settings_codeflying_open_site">打开 CodeFlying.net ›</string>
+ <string name="codeflying_url" translatable="false">https://www.codeflying.net/andee</string>
<string name="settings_no_key_use_codeflying">没有密钥?点这里切换到 CodeFlying 配置</string>
+ <string name="settings_codeflying_key">CodeFlying 密钥</string>
+ <string name="common_copy">复制</string>
+ <string name="common_copied">已复制</string>
<string name="settings_section_wake">语音唤醒</string>
<string name="settings_wake_enrolled">已录入 —— 说出你录的唤醒词就行</string>
<string name="settings_wake_not_enrolled">未录入 —— 自己选个词录 3 遍就能语音唤醒,例如「嘿 Andee」</string>
@@ -432,6 +436,8 @@
<string name="svc_notification_auto_line">(%1$s 来消息了,我自己看一眼…)</string>
<string name="svc_no_brain_hub">还没有接上大脑,我说不上话。</string>
<string name="svc_no_brain_local">本地大脑还没配 key,我说不上话。</string>
+ <string name="svc_no_brain_codeflying">还没有 CodeFlying 密钥,我说不上话。</string>
+ <string name="svc_btn_get_key">获取密钥</string>
<!--
config/Notebook.kt — the read-only dump the settings sheet renders. The
@@ -551,9 +557,9 @@
stays as it is in both languages.
-->
<string name="brain_no_key">本地大脑还没配 API key。长按小球把卡片展开,点控制条上的 ⚙ 打开设置,把 Key 填进「后端」→「本机」→「DeepSeek Key」。</string>
+ <string name="brain_no_key_codeflying">还没有 CodeFlying 密钥。长按小球展开卡片,点 ⚙ 打开设置,在「后端」→「CodeFlying」里粘贴密钥;还没有的话,去 CodeFlying.net 注册获取。</string>
<string name="brain_error">我这边出错了:%1$s</string>
<string name="brain_error_402">后端服务返回了 402,多半是账户余额不足了。到「设置」→「后端」看看当前用的是哪家服务商,打开它的官网充值后再试。</string>
- <string name="brain_error_402_codeflying">后端服务返回了 402,多半是 CodeFlying 账户余额不足了。用电脑浏览器打开 CodeFlying.net 登录后充值,再试一次。</string>
<string name="brain_error_auth">后端拒绝了请求(HTTP %1$d):Key 填错、过期或被停用了。到「设置」→「后端」检查 Key,必要时去服务商官网重新生成一个。</string>
<string name="brain_error_400">后端说请求有问题:%1$s\n最常见的原因是模型名写错了,到「设置」→「后端」核对一下模型名。</string>
<string name="brain_error_404">后端找不到这个地址(HTTP 404)。到「设置」→「后端」检查接口地址和模型名有没有填错。</string>
@@ -630,6 +636,7 @@
<string name="check_detail_brain_on">已配置。</string>
<string name="check_detail_brain_hub_missing">还没填。现在用的是云端大脑,得把你自己搭的 Hub 地址填进 ⚙ →「后端」→「云端」→「Hub 地址」。「云端」默认藏着,看不到就先去「高级」→「显示云端选项」把它打开。没有它,你说的话没地方送,问了不会有回答,屏幕也不会动。想让这台设备自己想,就在同一排把大脑切成「本机」。</string>
<string name="check_detail_brain_key_missing">还没填。现在用的是本机大脑,得你自己去 DeepSeek 开一个,把 Key 填进 ⚙ →「后端」→「本机」→「DeepSeek Key」。没有它,你说的话我收得到,却答不出、也动不了手。</string>
+ <string name="check_detail_brain_codeflying_key_missing">还没填。现在用的是 CodeFlying,到 CodeFlying.net 注册登录拿到密钥,填进 ⚙ →「后端」→「CodeFlying」。没有它,你说的话我收得到,却答不出、也动不了手。</string>
<string name="check_detail_model_cloud">云端大脑,模型不在这台设备上。</string>
<string name="check_detail_model_no_key">还没填 Key,填了才测得了。</string>
<string name="check_detail_checking">检查中…</string>
@@ -666,6 +673,7 @@
<string name="check_detail_mic_off">没允许。点球不会有任何反应 —— 这是最不像权限问题的一条。</string>
<string name="check_detail_voice_key_ok">已填。识别和合成用它连服务商。</string>
<string name="check_detail_voice_key_missing">还没填。源码里不带密钥,得你自己去开一个语音服务,把 Key 填进 ⚙ →「后端」→「本机」。没有它,听和说都连不上 —— 报出来的却是连接超时,看着像网络坏了。其余功能照常。</string>
+ <string name="check_detail_voice_key_codeflying_missing">语音用的是 CodeFlying 的密钥,和大脑是同一个,填进 ⚙ →「后端」→「CodeFlying」即可。没有它,听和说都连不上。</string>
<string name="check_detail_voice_host_ok">%1$s 可达。</string>
<string name="check_detail_voice_host_bad">连不上 %1$s:%2$s。识别和合成都会超时。</string>
<string name="check_detail_wake_on">已录入,喊一声就醒。</string>
diff --git a/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt b/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt
index 548c45a..05973c9 100644
--- a/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt
+++ b/core/src/main/kotlin/net/kuafuai/andee/brain/BrainHost.kt
@@ -144,13 +144,14 @@ data class FoldedTopic(val id: Long, val title: String, val summary: String)
*/
enum class BrainText {
NO_KEY,
+ /** The CodeFlying backend is selected but no key is set: names where to get one. */
+ NO_KEY_CODEFLYING,
NO_RESULT,
REPEAT_STOP,
MAX_STEPS,
ERROR,
ERROR_400,
ERROR_402,
- ERROR_402_CODEFLYING,
ERROR_404,
ERROR_429,
ERROR_5XX,
diff --git a/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt b/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt
index ad676c5..6456d1a 100644
--- a/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt
+++ b/core/src/main/kotlin/net/kuafuai/andee/brain/LocalBrain.kt
@@ -289,7 +289,7 @@ class LocalBrain(
if (cfg.apiKey.isEmpty()) {
// Said out loud rather than logged: from the ball's point of view a
// missing key is indistinguishable from a brain that never answers.
- onFinal(host.text(BrainText.NO_KEY))
+ onFinal(noKeyText())
return
}
// The quiet-hour timer measures silence from the user's last words, so
@@ -366,7 +366,7 @@ class LocalBrain(
fun peerTask(text: String, onAnswer: (String?) -> Unit) {
val t = text.trim()
if (t.isEmpty()) return onAnswer(null)
- if (cfg.apiKey.isEmpty()) return onAnswer(host.text(BrainText.NO_KEY))
+ if (cfg.apiKey.isEmpty()) return onAnswer(noKeyText())
loop.execute {
if (busy.get()) {
host.logInfo(TAG, "peer task queued behind a running turn: ${t.take(60)}")
@@ -539,12 +539,15 @@ class LocalBrain(
* exactly like the ball going quiet. Anything unrecognised falls back to
* the old generic line with the raw message, so nothing is hidden.
*/
+ /** The sentence for "no key": the CodeFlying one says where to get it. */
+ private fun noKeyText(): String =
+ host.text(if (cfg.mode == BrainConfig.BRAIN_CODEFLYING) BrainText.NO_KEY_CODEFLYING else BrainText.NO_KEY)
+
private fun explainFailure(t: Throwable): String {
fun s(id: BrainText, vararg args: Any) = host.text(id, *args)
if (t is LlmHttpException) {
- val codeFlying = cfg.mode == BrainConfig.BRAIN_CODEFLYING
return when (t.code) {
- 402 -> if (codeFlying) s(BrainText.ERROR_402_CODEFLYING) else s(BrainText.ERROR_402)
+ 402 -> s(BrainText.ERROR_402)
401, 403 -> s(BrainText.ERROR_AUTH, t.code)
400 -> s(BrainText.ERROR_400, t.detail.take(160).ifBlank { "HTTP 400" })
404 -> s(BrainText.ERROR_404)
diff --git a/core/src/main/kotlin/net/kuafuai/andee/config/CodeFlyingEndpoint.kt b/core/src/main/kotlin/net/kuafuai/andee/config/CodeFlyingEndpoint.kt
new file mode 100644
index 0000000..8edb43f
--- /dev/null
+++ b/core/src/main/kotlin/net/kuafuai/andee/config/CodeFlyingEndpoint.kt
@@ -0,0 +1,40 @@
+package net.kuafuai.andee.config
+
+/**
+ * Where CodeFlying lives, derived from one string the user (or the build) gives.
+ *
+ * The three URL shapes below are the only place the paths `/voice/llm`, `/voice/asr/...` and
+ * `/baas-api` are written, so the phone and the Mac cannot drift apart on them.
+ *
+ * [parse] accepts a bare host (`124.71.176.202`, `host:8080`) or one with a scheme
+ * (`https://host`). A scheme the user typed wins over [sslDefault]; a bare host takes the default,
+ * which on the phone is the build's `CODEFLYING_SSL_ENABLED` and on the Mac is off.
+ */
+class CodeFlyingEndpoint private constructor(val host: String, val ssl: Boolean) {
+ private val http get() = if (ssl) "https" else "http"
+ private val ws get() = if (ssl) "wss" else "ws"
+
+ /** Bare origin, e.g. `http://124.71.176.202`. */
+ val baseUrl: String get() = "$http://$host"
+
+ /** Origin of the market tools; the bare `/api/` on that host is the front end's static directory. */
+ val marketBaseUrl: String get() = "$baseUrl/baas-api"
+ val llmBaseUrl: String get() = "$baseUrl/voice/llm"
+ val asrEndpoint: String get() = "$ws://$host/voice/asr/bigmodel_async"
+ val ttsEndpoint: String get() = "$ws://$host/voice/tts/bidirection"
+
+ companion object {
+ fun parse(input: String?, sslDefault: Boolean): CodeFlyingEndpoint? {
+ var s = input.orEmpty().trim()
+ if (s.isEmpty()) return null
+ var ssl = sslDefault
+ val scheme = Regex("^([a-zA-Z]+)://").find(s)
+ if (scheme != null) {
+ ssl = scheme.groupValues[1].lowercase() in setOf("https", "wss")
+ s = s.substring(scheme.range.last + 1)
+ }
+ s = s.trimEnd('/')
+ return if (s.isEmpty() || s.any { it.isWhitespace() || it == '/' }) null else CodeFlyingEndpoint(s, ssl)
+ }
+ }
+}
diff --git a/core/src/test/kotlin/net/kuafuai/andee/config/CodeFlyingEndpointTest.kt b/core/src/test/kotlin/net/kuafuai/andee/config/CodeFlyingEndpointTest.kt
new file mode 100644
index 0000000..a0b3c38
--- /dev/null
+++ b/core/src/test/kotlin/net/kuafuai/andee/config/CodeFlyingEndpointTest.kt
@@ -0,0 +1,25 @@
+package net.kuafuai.andee.config
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
+import org.junit.Test
+
+class CodeFlyingEndpointTest {
+ @Test fun bareHostTakesTheDefaultScheme() {
+ val e = CodeFlyingEndpoint.parse(" 1.2.3.4:8080/ ", sslDefault = false)!!
+ assertEquals("http://1.2.3.4:8080/voice/llm", e.llmBaseUrl)
+ assertEquals("ws://1.2.3.4:8080/voice/asr/bigmodel_async", e.asrEndpoint)
+ assertEquals("http://1.2.3.4:8080/baas-api", e.marketBaseUrl)
+ }
+
+ @Test fun typedSchemeWins() {
+ val e = CodeFlyingEndpoint.parse("https://cf.example.com", sslDefault = false)!!
+ assertEquals("wss://cf.example.com/voice/tts/bidirection", e.ttsEndpoint)
+ }
+
+ @Test fun junkIsNull() {
+ assertNull(CodeFlyingEndpoint.parse("", false))
+ assertNull(CodeFlyingEndpoint.parse("a b", false))
+ assertNull(CodeFlyingEndpoint.parse("host/path", false))
+ }
+}
diff --git a/desktop/build.gradle b/desktop/build.gradle
index adbfc2b..eea6988 100644
--- a/desktop/build.gradle
+++ b/desktop/build.gradle
@@ -47,6 +47,29 @@ tasks.register('buildBridge', Exec) {
}
tasks.register('buildNative') { dependsOn('buildTrashTool', 'buildBridge') }
sourceSets.main.resources.srcDir(nativeOut)
+
+// The CodeFlying build settings, read from local.properties exactly as :app does
+// (CODEFLYING_ENABLED / _DOMAIN / _SSL_ENABLED / _KEY). local.properties is gitignored, so a
+// checkout with nothing configured builds a Mac app with no CodeFlying server, as before.
+def codeFlyingOut = layout.buildDirectory.dir('generated/codeflying')
+tasks.register('generateCodeFlyingConfig') {
+ def localFile = rootProject.file('local.properties')
+ def out = codeFlyingOut.get().file('codeflying.properties').asFile
+ inputs.files(localFile).optional()
+ outputs.file(out)
+ doLast {
+ def lp = new Properties()
+ if (localFile.exists()) localFile.withInputStream { lp.load(it) }
+ def o = new Properties()
+ ['CODEFLYING_ENABLED', 'CODEFLYING_DOMAIN', 'CODEFLYING_SSL_ENABLED', 'CODEFLYING_KEY'].each {
+ o.setProperty(it, lp.getProperty(it, '').trim())
+ }
+ out.parentFile.mkdirs()
+ out.withOutputStream { o.store(it, 'generated from local.properties') }
+ }
+}
+sourceSets.main.resources.srcDir(codeFlyingOut)
+processResources.dependsOn('generateCodeFlyingConfig')
processResources.dependsOn('buildNative')
dependencies {
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Assistant.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Assistant.kt
index 2333d72..fe94e36 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Assistant.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Assistant.kt
@@ -78,25 +78,56 @@ object Assistant {
private fun secrets(): List<Pair<String, String>> = buildList {
Settings.get("llm_api_key").takeIf { it.length >= 8 }?.let { add("Andee's model key" to it) }
Settings.get("api_key").takeIf { it.length >= 8 }?.let { add("Andee's voice key" to it) }
+ codeFlyingKey().takeIf { it.length >= 8 }?.let { add("Andee's CodeFlying key" to it) }
addAll(VaultSecrets.values())
}
private var brain: LocalBrain? = null
private var builtFor: BrainConfig? = null
+ /** Where CodeFlying is: the build's address (null only if the build was packaged without one). */
+ fun codeFlyingEndpoint() =
+ net.kuafuai.andee.config.CodeFlyingEndpoint.parse(CodeFlyingBuild.domain, CodeFlyingBuild.ssl)
+
+ /** The key in effect: one typed in settings, else the build's. */
+ fun codeFlyingKey(): String = Settings.get("codeflying_key").ifEmpty { CodeFlyingBuild.key }
+
+ /**
+ * The backend in force. Unset is CodeFlying, key or not — the phone's rule.
+ */
+ fun brainMode(): String = when (Settings.get("brain").trim().lowercase()) {
+ BrainConfig.BRAIN_CODEFLYING -> BrainConfig.BRAIN_CODEFLYING
+ BrainConfig.BRAIN_HUB -> BrainConfig.BRAIN_HUB
+ BrainConfig.BRAIN_LOCAL -> BrainConfig.BRAIN_LOCAL
+ "" -> BrainConfig.BRAIN_CODEFLYING
+ else -> BrainConfig.BRAIN_LOCAL
+ }
+
fun config(): BrainConfig {
- val mode = Settings.get("brain").let { if (it == BrainConfig.BRAIN_CODEFLYING) it else BrainConfig.BRAIN_LOCAL }
val zh = Strings.lang() == "zh"
+ val cf = codeFlyingEndpoint()
+ val thinking = Settings.get("llm_thinking") != "disabled"
+ val effort = Settings.get("llm_reasoning_effort").ifEmpty { "high" }
+ if (brainMode() == BrainConfig.BRAIN_CODEFLYING && cf != null) {
+ return BrainConfig(
+ mode = BrainConfig.BRAIN_CODEFLYING,
+ apiKey = codeFlyingKey(),
+ baseUrl = cf.llmBaseUrl,
+ model = Settings.get("llm_model").ifEmpty { "deepseek-flash" },
+ thinking = thinking,
+ reasoningEffort = effort,
+ )
+ }
return BrainConfig(
- mode = mode,
+ mode = BrainConfig.BRAIN_LOCAL,
apiKey = Settings.get("llm_api_key"),
baseUrl = Settings.get("llm_base_url").trimEnd('/').ifEmpty {
if (zh) "https://api.deepseek.com" else "https://api.openai.com/v1"
},
model = Settings.get("llm_model").ifEmpty { if (zh) "deepseek-flash" else "gpt-4o-mini" },
// Unset reads as on, as on the phone (its build default is on); only an explicit "disabled" turns it off.
- thinking = Settings.get("llm_thinking") != "disabled",
- reasoningEffort = Settings.get("llm_reasoning_effort").ifEmpty { "high" },
+ thinking = thinking,
+ reasoningEffort = effort,
)
}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt
index 93b5cd5..35efc9e 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt
@@ -81,7 +81,7 @@ fun SelfCheckCard(onDone: () -> Unit, onOpenSettings: () -> Unit) {
justChecked = false
}
Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(20.dp)) {
- GlassHeader(if (zh) "自检" else "Self-check", if (zh) "每一项都可能悄悄坏掉" else "Each of these can fail silently", onClose = onDone)
+ GlassHeader(if (zh) "自检" else "Self-check", if (zh) "每一项都可能悄悄坏掉" else "Each of these can fail silently", onClose = onDone, trailing = { LangToggle() })
for (r in rows) {
Row(
Modifier.fillMaxWidth().glassPanel(14).padding(12.dp),
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/CodeFlyingBuild.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/CodeFlyingBuild.kt
new file mode 100644
index 0000000..a3f0c8f
--- /dev/null
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/CodeFlyingBuild.kt
@@ -0,0 +1,24 @@
+package net.kuafuai.andee.desktop
+
+import java.util.Properties
+
+/**
+ * What the build was packaged with for CodeFlying, from `local.properties` at build time
+ * (see `generateCodeFlyingConfig` in desktop/build.gradle) — the phone's `BuildConfig.CODEFLYING_*`.
+ * Nothing configured reads as "not available", and the 本机 backend carries on.
+ */
+object CodeFlyingBuild {
+ private val p: Properties by lazy {
+ Properties().apply {
+ runCatching {
+ CodeFlyingBuild::class.java.getResourceAsStream("/codeflying.properties")?.use { load(it.reader(Charsets.UTF_8)) }
+ }
+ }
+ }
+
+ private fun flag(key: String) = p.getProperty(key, "").trim().lowercase().let { it == "true" || it == "1" || it == "yes" }
+
+ val domain: String get() = p.getProperty("CODEFLYING_DOMAIN", "").trim()
+ val ssl: Boolean get() = flag("CODEFLYING_SSL_ENABLED")
+ val key: String get() = p.getProperty("CODEFLYING_KEY", "").trim()
+}
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Glass.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Glass.kt
index 0f86bd9..37d2a6a 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Glass.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Glass.kt
@@ -11,10 +11,15 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
@@ -96,6 +101,31 @@ fun GlassHeader(title: String, subtitle: String? = null, onClose: () -> Unit, tr
}
}
+/**
+ * 中 / EN in a card's header, as the phone's LangToggle: written the instant it is tapped, and the
+ * card redraws in the new language. Settings and the self-check both carry it, so a person who
+ * lands on a card in the wrong language can change it without going anywhere.
+ */
+@Composable
+fun LangToggle() {
+ val cur = Strings.lang()
+ Row(Modifier.glassWell(16).padding(3.dp), horizontalArrangement = Arrangement.spacedBy(2.dp)) {
+ for ((tag, label) in listOf("zh" to "中", "en" to "EN")) {
+ val on = tag == cur
+ Text(
+ label, color = if (on) Palette.title else Palette.secondary, fontSize = 13.sp, fontWeight = FontWeight.SemiBold,
+ textAlign = androidx.compose.ui.text.style.TextAlign.Center,
+ modifier = Modifier.width(38.dp)
+ .background(if (on) Palette.thumb else Color.Transparent, RoundedCornerShape(13.dp))
+ .border(1.dp, if (on) Palette.thumbEdge else Color.Transparent, RoundedCornerShape(13.dp))
+ .clickable { if (!on) { Settings.save(mapOf("lang" to tag)); Strings.changed() } }
+ .padding(vertical = 5.dp),
+ )
+ }
+ }
+ Spacer(Modifier.width(10.dp))
+}
+
@Composable
fun SectionTitle(title: String) {
Spacer(Modifier.height(16.dp))
@@ -103,6 +133,20 @@ fun SectionTitle(title: String) {
Spacer(Modifier.height(6.dp))
}
+/**
+ * One block of a settings card, as the phone draws it: a small accent title above, and the rows
+ * inside one rounded panel. Settings are a stack of these, so each reads as its own thing
+ * rather than one long list.
+ */
+@Composable
+fun Section(title: String, note: String? = null, content: @Composable androidx.compose.foundation.layout.ColumnScope.() -> Unit) {
+ Spacer(Modifier.height(22.dp))
+ Text(title, color = Palette.accent, fontSize = 12.sp, letterSpacing = 1.sp)
+ if (note != null) Text(note, color = Palette.secondary, fontSize = 12.sp, modifier = Modifier.padding(top = 4.dp))
+ Spacer(Modifier.height(8.dp))
+ Column(Modifier.fillMaxWidth().glassPanel(20).padding(18.dp), content = content)
+}
+
/** The phone's sliding-thumb segmented picker. */
@Composable
fun SegmentedPicker(options: List<Pair<String, String>>, selected: String, onPick: (String) -> Unit) {
@@ -127,23 +171,50 @@ fun SegmentedPicker(options: List<Pair<String, String>>, selected: String, onPic
}
@Composable
-fun GlassField(label: String, value: String, onValue: (String) -> Unit, secret: Boolean = false, hint: String = "") {
+fun GlassField(
+ label: String, value: String, onValue: (String) -> Unit, secret: Boolean = false, hint: String = "",
+ /** When set, a 复制 link sits by the 显示 toggle and copies this (or the typed text, if any). */
+ copyValue: (() -> String)? = null,
+) {
Spacer(Modifier.height(8.dp))
Text(label, color = Palette.secondary, fontSize = 12.sp)
Spacer(Modifier.height(4.dp))
- BasicTextField(
- value = value,
- onValueChange = onValue,
- singleLine = true,
- visualTransformation = if (secret) PasswordVisualTransformation() else VisualTransformation.None,
- textStyle = TextStyle(color = Palette.label, fontSize = 14.sp),
- cursorBrush = SolidColor(Palette.accent),
- modifier = Modifier.fillMaxWidth().glassWell(12).padding(horizontal = 12.dp, vertical = 10.dp),
- decorationBox = { inner ->
- // A blank row shows what it resolves to, as on the phone: the hint is the value in force.
- Box { if (value.isEmpty() && hint.isNotEmpty()) Text(hint, color = Palette.muted, fontSize = 14.sp, maxLines = 1); inner() }
- },
- )
+ var shown by remember { mutableStateOf(false) }
+ var copied by remember { mutableStateOf(false) }
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ BasicTextField(
+ value = value,
+ onValueChange = onValue,
+ singleLine = true,
+ visualTransformation = if (secret && !shown) PasswordVisualTransformation() else VisualTransformation.None,
+ textStyle = TextStyle(color = Palette.label, fontSize = 14.sp),
+ cursorBrush = SolidColor(Palette.accent),
+ modifier = Modifier.weight(1f).glassWell(12).padding(horizontal = 12.dp, vertical = 10.dp),
+ decorationBox = { inner ->
+ // A blank row shows what it resolves to, as on the phone: the hint is the value in force.
+ Box { if (value.isEmpty() && hint.isNotEmpty()) Text(hint, color = Palette.muted, fontSize = 14.sp, maxLines = 1); inner() }
+ },
+ )
+ if (secret) {
+ Text(
+ Strings.get(if (shown) "s_common_hide" else "s_common_show"), color = Palette.accent, fontSize = 12.sp,
+ modifier = Modifier.padding(start = 12.dp).clickable { shown = !shown },
+ )
+ if (copyValue != null) {
+ Text(
+ Strings.get(if (copied) "s_common_copied" else "s_common_copy"), color = Palette.accent, fontSize = 12.sp,
+ modifier = Modifier.padding(start = 12.dp).clickable {
+ val v = value.trim().ifEmpty { copyValue() }
+ if (v.isNotEmpty()) {
+ java.awt.Toolkit.getDefaultToolkit().systemClipboard
+ .setContents(java.awt.datatransfer.StringSelection(v), null)
+ copied = true
+ }
+ },
+ )
+ }
+ }
+ }
}
@Composable
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Settings.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Settings.kt
index 1e20677..a3ea8fc 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Settings.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Settings.kt
@@ -32,7 +32,7 @@ object Settings {
val KEYS = setOf(
"brain", "llm_api_key", "llm_base_url", "llm_model", "llm_thinking", "llm_reasoning_effort",
- "api_key", "asr_endpoint", "tts_endpoint", "asr_resource_id", "tts_resource_id", "tts_speaker",
+ "api_key", "codeflying_key", "asr_endpoint", "tts_endpoint", "asr_resource_id", "tts_resource_id", "tts_speaker",
"voice_provider", "lang", "max_steps", "scene", "ball", "ball_pos", "notify", "sweep", "sweep_quiet_minutes", "sweep_daily_cap",
"shell_mode", "shell_workdirs", "shell_critical_confirm", "mute",
"google_api_key", "google_project", "google_location", "google_asr_model", "google_tts_model", "google_base_url",
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
index c37a0ab..3a6538a 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/SettingsScreen.kt
@@ -46,11 +46,16 @@ fun SettingsScreen(
) {
val zh = Strings.lang() == "zh"
fun t(a: String, b: String) = if (zh) a else b
- val v = remember { mutableStateMapOf<String, String>().apply { putAll(Settings.all()) } }
+ val v = remember { mutableStateMapOf<String, String>().apply {
+ putAll(Settings.all())
+ // The key in effect is shown, typed or the build's; saving it back unchanged stores nothing (below).
+ put("codeflying_key", Assistant.codeFlyingKey())
+ } }
var fullOpenAsk by remember { mutableStateOf(false) }
var advanced by remember { mutableStateOf(false) }
var confirm by remember { mutableStateOf("") } // "", "chat", "notes", "factory"
- val brain = v["brain"].orEmpty().ifEmpty { "local" }
+ // The tab shown: nothing saved is CodeFlying, the default tab for a new install.
+ val brain = v["brain"].orEmpty().ifEmpty { "codeflying" }.let { if (it == "hub" && v["show_hub"] != "on") "codeflying" else it }
// The voice provider the card shows is the one in force: a saved pick, else by language.
val provider = when (v["voice_provider"].orEmpty().trim().lowercase()) {
@@ -63,196 +68,203 @@ fun SettingsScreen(
val llmUrlHint = if (en) "https://api.openai.com/v1" else "https://api.deepseek.com"
Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(20.dp)) {
- GlassHeader(st("settings_title"), subtitle = t("所有设置都存在本机", "Everything stays on this Mac"), onClose = onDone)
-
- // ---- language: written the instant it is tapped, like the phone ----
- SectionTitle(t("界面语言", "Language"))
- SegmentedPicker(listOf("zh" to "中", "en" to "EN"), Strings.lang()) {
- Settings.save(mapOf("lang" to it))
- v["lang"] = it
- Strings.changed()
- }
+ GlassHeader(st("settings_title"), subtitle = t("所有设置都存在本机", "Everything stays on this Mac"), onClose = onDone, trailing = { LangToggle() })
// ---- 后端 ----
- SectionTitle(st("settings_section_brain"))
- SegmentedPicker(
- buildList {
- add("local" to st("settings_brain_local"))
- add("codeflying" to st("settings_brain_codeflying"))
- if (v["show_hub"] == "on") add("hub" to st("settings_brain_cloud"))
- },
- brain,
- ) { v["brain"] = it }
- when (brain) {
- "hub" -> {
- GlassField(st("settings_hub_url"), v["hub_url"].orEmpty(), { v["hub_url"] = it }, hint = st("settings_hub_url_hint"))
- GlassField(st("settings_device_name"), v["device_name"].orEmpty(), { v["device_name"] = it }, hint = st("settings_device_name_hint"))
- Note(st("settings_brain_cloud_note"))
- }
- // macOS has no CodeFlying endpoint in the build — Assistant.config
- // keeps the mode but still talks to the key from 本机 — so this tab
- // is never wired up here, and says so before it explains how to.
- "codeflying" -> {
- Text(
- st("settings_codeflying_not_connected"),
- color = Palette.warn, fontSize = 13.sp,
- modifier = Modifier.padding(top = 8.dp),
- )
- Note(st("settings_brain_codeflying_unconfigured"))
- }
- else -> {
- GlassField(st("settings_llm_api_key"), v["llm_api_key"].orEmpty(), { v["llm_api_key"] = it }, secret = true, hint = "sk-…")
- NoKeyHint { v["brain"] = "codeflying" }
- GlassField(st("settings_llm_model"), v["llm_model"].orEmpty(), { v["llm_model"] = it }, hint = llmModelHint)
- GlassField(st("settings_llm_base_url"), v["llm_base_url"].orEmpty(), { v["llm_base_url"] = it }, hint = llmUrlHint)
- RowLabel(st("settings_llm_thinking"))
- val thinking = v["llm_thinking"].orEmpty().ifEmpty { "enabled" }
- SegmentedPicker(listOf("enabled" to st("common_on"), "disabled" to st("common_off")), thinking) { v["llm_thinking"] = it }
- if (thinking != "disabled") {
- RowLabel(st("settings_llm_effort"))
- SegmentedPicker(
- listOf("high" to st("common_high"), "medium" to st("common_medium"), "low" to st("common_low")),
- v["llm_reasoning_effort"].orEmpty().ifEmpty { "high" },
- ) { v["llm_reasoning_effort"] = it }
+ Section(st("settings_section_brain"), note = st("settings_brain_panel_note")) {
+ SegmentedPicker(
+ buildList {
+ add("codeflying" to st("settings_brain_codeflying"))
+ add("local" to st("settings_brain_local"))
+ if (v["show_hub"] == "on") add("hub" to st("settings_brain_cloud"))
+ },
+ brain,
+ ) { v["brain"] = it }
+ when (brain) {
+ "hub" -> {
+ GlassField(st("settings_hub_url"), v["hub_url"].orEmpty(), { v["hub_url"] = it }, hint = st("settings_hub_url_hint"))
+ GlassField(st("settings_device_name"), v["device_name"].orEmpty(), { v["device_name"] = it }, hint = st("settings_device_name_hint"))
+ Note(st("settings_brain_cloud_note"))
+ }
+ // The server comes from the build (CodeFlyingBuild), as on the phone; only the key is typed here.
+ "codeflying" -> {
+ val keyed = Assistant.codeFlyingKey().isNotEmpty()
+ // Same words and link whether or not a key is set; the key box below is the state.
+ Note(st("settings_brain_codeflying_note"))
+ Note(st("settings_codeflying_get_key"))
+ Text(
+ st("settings_codeflying_open_site"), color = Palette.accent, fontSize = 12.sp,
+ modifier = Modifier.padding(top = 6.dp).clickable {
+ runCatching { java.awt.Desktop.getDesktop().browse(java.net.URI(st("codeflying_url"))) }
+ },
+ )
+ // Always drawn, connected or not: it is where a key from the link above goes.
+ GlassField(
+ st("settings_codeflying_key"), v["codeflying_key"].orEmpty(), { v["codeflying_key"] = it },
+ secret = true, hint = "kft_…", copyValue = { Assistant.codeFlyingKey() },
+ )
+ }
+ else -> {
+ GlassField(st("settings_llm_api_key"), v["llm_api_key"].orEmpty(), { v["llm_api_key"] = it }, secret = true, hint = "sk-…")
+ NoKeyHint { v["brain"] = "codeflying" }
+ GlassField(st("settings_llm_model"), v["llm_model"].orEmpty(), { v["llm_model"] = it }, hint = llmModelHint)
+ GlassField(st("settings_llm_base_url"), v["llm_base_url"].orEmpty(), { v["llm_base_url"] = it }, hint = llmUrlHint)
+ RowLabel(st("settings_llm_thinking"))
+ val thinking = v["llm_thinking"].orEmpty().ifEmpty { "enabled" }
+ SegmentedPicker(listOf("enabled" to st("common_on"), "disabled" to st("common_off")), thinking) { v["llm_thinking"] = it }
+ if (thinking != "disabled") {
+ RowLabel(st("settings_llm_effort"))
+ SegmentedPicker(
+ listOf("high" to st("common_high"), "medium" to st("common_medium"), "low" to st("common_low")),
+ v["llm_reasoning_effort"].orEmpty().ifEmpty { "high" },
+ ) { v["llm_reasoning_effort"] = it }
+ }
+ Note(st("settings_brain_local_note"))
}
- Note(st("settings_brain_local_note"))
}
- }
- // ---- who hears and speaks (not drawn under CodeFlying, which brings its own voice) ----
- if (brain != "codeflying") {
- RowLabel(st("settings_voice_provider"))
- SegmentedPicker(
- listOf("huoshan" to st("settings_voice_provider_huoshan"), "google" to st("settings_voice_provider_google")),
- provider,
- ) { v["voice_provider"] = it }
- if (provider == "google") {
- GlassField(st("settings_google_api_key"), v["google_api_key"].orEmpty(), { v["google_api_key"] = it }, secret = true, hint = st("settings_google_api_key_hint"))
- NoKeyHint { v["brain"] = "codeflying" }
- GlassField(st("settings_google_project"), v["google_project"].orEmpty(), { v["google_project"] = it }, hint = st("settings_google_project_hint"))
- GlassField(st("settings_google_location"), v["google_location"].orEmpty(), { v["google_location"] = it }, hint = "asia-northeast1")
- GlassField(st("settings_google_asr_model"), v["google_asr_model"].orEmpty(), { v["google_asr_model"] = it }, hint = "gemini-live-2.5-flash-preview-native-audio")
- GlassField(st("settings_google_tts_model"), v["google_tts_model"].orEmpty(), { v["google_tts_model"] = it }, hint = "gemini-2.5-flash-preview-tts")
- GlassField(st("settings_google_base_url"), v["google_base_url"].orEmpty(), { v["google_base_url"] = it }, hint = "https://aiplatform.googleapis.com")
- GlassField(st("settings_google_language"), v["google_language"].orEmpty(), { v["google_language"] = it }, hint = st("settings_google_language_hint"))
- Note(st("settings_voice_google_note"))
- } else {
- GlassField(st("settings_voice_api_key"), v["api_key"].orEmpty(), { v["api_key"] = it }, secret = true, hint = st("settings_voice_api_key_hint"))
- NoKeyHint { v["brain"] = "codeflying" }
- GlassField(st("settings_voice_asr_endpoint"), v["asr_endpoint"].orEmpty(), { v["asr_endpoint"] = it }, hint = "wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async")
- GlassField(st("settings_voice_asr_resource_id"), v["asr_resource_id"].orEmpty(), { v["asr_resource_id"] = it }, hint = "volc.bigasr.sauc.duration")
- GlassField(st("settings_voice_tts_endpoint"), v["tts_endpoint"].orEmpty(), { v["tts_endpoint"] = it }, hint = "wss://openspeech.bytedance.com/api/v3/tts/bidirection")
- GlassField(st("settings_voice_tts_resource_id"), v["tts_resource_id"].orEmpty(), { v["tts_resource_id"] = it }, hint = "seed-tts-2.0")
- GlassField(st("settings_voice_tts_sample_rate"), v["tts_sample_rate"].orEmpty(), { v["tts_sample_rate"] = it }, hint = "24000")
+ // ---- who hears and speaks (not drawn under CodeFlying, which brings its own voice) ----
+ if (brain != "codeflying") {
+ RowLabel(st("settings_voice_provider"))
+ SegmentedPicker(
+ listOf("huoshan" to st("settings_voice_provider_huoshan"), "google" to st("settings_voice_provider_google")),
+ provider,
+ ) { v["voice_provider"] = it }
+ if (provider == "google") {
+ GlassField(st("settings_google_api_key"), v["google_api_key"].orEmpty(), { v["google_api_key"] = it }, secret = true, hint = st("settings_google_api_key_hint"))
+ NoKeyHint { v["brain"] = "codeflying" }
+ GlassField(st("settings_google_project"), v["google_project"].orEmpty(), { v["google_project"] = it }, hint = st("settings_google_project_hint"))
+ GlassField(st("settings_google_location"), v["google_location"].orEmpty(), { v["google_location"] = it }, hint = "asia-northeast1")
+ GlassField(st("settings_google_asr_model"), v["google_asr_model"].orEmpty(), { v["google_asr_model"] = it }, hint = "gemini-live-2.5-flash-preview-native-audio")
+ GlassField(st("settings_google_tts_model"), v["google_tts_model"].orEmpty(), { v["google_tts_model"] = it }, hint = "gemini-2.5-flash-preview-tts")
+ GlassField(st("settings_google_base_url"), v["google_base_url"].orEmpty(), { v["google_base_url"] = it }, hint = "https://aiplatform.googleapis.com")
+ GlassField(st("settings_google_language"), v["google_language"].orEmpty(), { v["google_language"] = it }, hint = st("settings_google_language_hint"))
+ Note(st("settings_voice_google_note"))
+ } else {
+ GlassField(st("settings_voice_api_key"), v["api_key"].orEmpty(), { v["api_key"] = it }, secret = true, hint = st("settings_voice_api_key_hint"))
+ NoKeyHint { v["brain"] = "codeflying" }
+ GlassField(st("settings_voice_asr_endpoint"), v["asr_endpoint"].orEmpty(), { v["asr_endpoint"] = it }, hint = "wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async")
+ GlassField(st("settings_voice_asr_resource_id"), v["asr_resource_id"].orEmpty(), { v["asr_resource_id"] = it }, hint = "volc.bigasr.sauc.duration")
+ GlassField(st("settings_voice_tts_endpoint"), v["tts_endpoint"].orEmpty(), { v["tts_endpoint"] = it }, hint = "wss://openspeech.bytedance.com/api/v3/tts/bidirection")
+ GlassField(st("settings_voice_tts_resource_id"), v["tts_resource_id"].orEmpty(), { v["tts_resource_id"] = it }, hint = "seed-tts-2.0")
+ GlassField(st("settings_voice_tts_sample_rate"), v["tts_sample_rate"].orEmpty(), { v["tts_sample_rate"] = it }, hint = "24000")
+ }
}
- }
+ }
// ---- 外观: eager, the redraw is the confirmation ----
- SectionTitle(st("settings_section_theme"))
- Note(st("settings_theme_note"))
- SegmentedPicker(
- listOf("day" to st("settings_theme_day"), "night" to st("settings_theme_night")),
- if (Palette.night) "night" else "day",
- ) { Palette.setNight(it == "night") }
+ Section(st("settings_section_theme"), note = st("settings_theme_note")) {
+ SegmentedPicker(
+ listOf("day" to st("settings_theme_day"), "night" to st("settings_theme_night")),
+ if (Palette.night) "night" else "day",
+ ) { Palette.setNight(it == "night") }
+ }
// ---- 形象与表情: a door, like the phone's — the card is where looks are tried and picked ----
- SectionTitle(st("settings_section_expr"))
- Note(st("settings_expr_note"))
- Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_expr_open")) { onOpenExpressions() } }
+ Section(st("settings_section_expr")) {
+ Note(st("settings_expr_note"))
+ Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_expr_open")) { onOpenExpressions() } }
+ }
// ---- 小本本 ----
- SectionTitle(st("settings_section_notebook"))
- SegmentedPicker(listOf("on" to st("common_on"), "off" to st("common_off")), v["sweep"].orEmpty().ifEmpty { "on" }) { v["sweep"] = it }
- Note(st("settings_notebook_sweep_note"))
- GlassField(st("settings_notebook_quiet_minutes"), v["sweep_quiet_minutes"].orEmpty(), { v["sweep_quiet_minutes"] = it }, hint = "20")
- GlassField(st("settings_notebook_daily_cap"), v["sweep_daily_cap"].orEmpty(), { v["sweep_daily_cap"] = it }, hint = "12")
- Note(
- st("settings_notebook_today") + ":" + st(
- "settings_notebook_stats", Sweep.countToday(), Sweep.tokensToday(),
- DesktopNotebook.book.memories().size, DesktopNotebook.book.todos("pending").size,
- ),
- )
+ Section(st("settings_section_notebook")) {
+ SegmentedPicker(listOf("on" to st("common_on"), "off" to st("common_off")), v["sweep"].orEmpty().ifEmpty { "on" }) { v["sweep"] = it }
+ Note(st("settings_notebook_sweep_note"))
+ GlassField(st("settings_notebook_quiet_minutes"), v["sweep_quiet_minutes"].orEmpty(), { v["sweep_quiet_minutes"] = it }, hint = "20")
+ GlassField(st("settings_notebook_daily_cap"), v["sweep_daily_cap"].orEmpty(), { v["sweep_daily_cap"] = it }, hint = "12")
+ Note(
+ st("settings_notebook_today") + ":" + st(
+ "settings_notebook_stats", Sweep.countToday(), Sweep.tokensToday(),
+ DesktopNotebook.book.memories().size, DesktopNotebook.book.todos("pending").size,
+ ),
+ )
+ }
// ---- 装备: a summary here, the card is where it is read and edited ----
- SectionTitle(st("settings_section_gear"))
- val gearShelf = remember { Assistant.gear.gear }
- val installed = remember { gearShelf.forCard() }
- val learned = installed.count { (i, _) -> i.does.isNotBlank() }
- Note(
- if (installed.isEmpty()) st("settings_gear_empty_note")
- else st("settings_gear_count_note", installed.size, learned),
- )
- Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_gear_manage")) { onOpenGear() } }
-
- // ---- 消息提醒 ----
- SectionTitle(st("settings_section_notify"))
- SegmentedPicker(
- listOf("off" to st("common_off"), "chat" to st("settings_notify_chat"), "all" to st("settings_notify_all")),
- v["notify"].orEmpty().ifEmpty { "off" },
- ) { v["notify"] = it }
- Note(st("settings_notify_note"))
- if (net.kuafuai.andee.desktop.mac.MacNotifications.state == net.kuafuai.andee.desktop.mac.MacNotifications.State.NO_ACCESS) {
- Text(
- t("读不到通知:在 系统设置 → 隐私与安全性 → 完全磁盘访问权限 里加上 Andee。",
- "Can't read notifications: add Andee under System Settings → Privacy & Security → Full Disk Access."),
- color = Palette.warn, fontSize = 12.sp, modifier = Modifier.padding(top = 4.dp),
+ Section(st("settings_section_gear")) {
+ val gearShelf = remember { Assistant.gear.gear }
+ val installed = remember { gearShelf.forCard() }
+ val learned = installed.count { (i, _) -> i.does.isNotBlank() }
+ Note(
+ if (installed.isEmpty()) st("settings_gear_empty_note")
+ else st("settings_gear_count_note", installed.size, learned),
)
+ Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_gear_manage")) { onOpenGear() } }
+
}
+ // ---- 消息提醒 ----
+ Section(st("settings_section_notify")) {
+ SegmentedPicker(
+ listOf("off" to st("common_off"), "chat" to st("settings_notify_chat"), "all" to st("settings_notify_all")),
+ v["notify"].orEmpty().ifEmpty { "off" },
+ ) { v["notify"] = it }
+ Note(st("settings_notify_note"))
+ if (net.kuafuai.andee.desktop.mac.MacNotifications.state == net.kuafuai.andee.desktop.mac.MacNotifications.State.NO_ACCESS) {
+ Text(
+ t("读不到通知:在 系统设置 → 隐私与安全性 → 完全磁盘访问权限 里加上 Andee。",
+ "Can't read notifications: add Andee under System Settings → Privacy & Security → Full Disk Access."),
+ color = Palette.warn, fontSize = 12.sp, modifier = Modifier.padding(top = 4.dp),
+ )
+ }
+ }
// ---- 保险箱: a summary here, and the door to the card ----
- SectionTitle(st("settings_section_vault"))
- val vaultN = remember { runCatching { net.kuafuai.andee.desktop.mac.MacVault.entries().size }.getOrDefault(0) }
- Note(if (vaultN == 0) st("settings_vault_empty_note") else st("settings_vault_count_note", vaultN))
- Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_vault_manage")) { onOpenVault() } }
+ Section(st("settings_section_vault")) {
+ val vaultN = remember { runCatching { net.kuafuai.andee.desktop.mac.MacVault.entries().size }.getOrDefault(0) }
+ Note(if (vaultN == 0) st("settings_vault_empty_note") else st("settings_vault_count_note", vaultN))
+ Row(Modifier.padding(top = 8.dp)) { Pill(st("settings_vault_manage")) { onOpenVault() } }
+ }
// ---- 单次任务最多步数 ----
- SectionTitle(st("settings_max_steps"))
- Note(st("settings_max_steps_note"))
- GlassField(st("settings_max_steps"), v["max_steps"].orEmpty(), { v["max_steps"] = it }, hint = "25")
+ Section(st("settings_max_steps"), note = st("settings_max_steps_note")) {
+ GlassField(st("settings_max_steps"), v["max_steps"].orEmpty(), { v["max_steps"] = it }, hint = "25")
+ }
// ---- Mac only: the shell ----
- SectionTitle(t("命令行", "Commands"))
- SegmentedPicker(
- listOf("ask" to t("问我", "Ask me"), "auto" to t("自动", "Automatic"), "read_only" to t("只读", "Read-only"), "full" to t("完全开放", "Full")),
- v["shell_mode"].orEmpty().ifEmpty { "ask" },
- ) { picked ->
- if (picked == "full" && v["shell_mode"] != "full") fullOpenAsk = true else v["shell_mode"] = picked
+ Section(t("命令行", "Commands")) {
+ SegmentedPicker(
+ listOf("ask" to t("问我", "Ask me"), "auto" to t("自动", "Automatic"), "read_only" to t("只读", "Read-only"), "full" to t("完全开放", "Full")),
+ v["shell_mode"].orEmpty().ifEmpty { "ask" },
+ ) { picked ->
+ if (picked == "full" && v["shell_mode"] != "full") fullOpenAsk = true else v["shell_mode"] = picked
+ }
+ Note(
+ when (v["shell_mode"].orEmpty().ifEmpty { "ask" }) {
+ "auto" -> t("在沙箱里,普通命令直接跑;删大量文件、强推这类仍先问你。", "Ordinary commands run in the sandbox; destructive ones still ask first.")
+ "read_only" -> t("只允许查看类命令,其它一律拒绝。", "Only read-only commands are allowed.")
+ "full" -> t("不进沙箱、不问:Andee 能改动这台 Mac 上的任何文件。", "No sandbox, no asking: Andee can change any file.")
+ else -> t("只读命令直接跑,其它每条先问你。", "Read-only commands run; everything else asks first.")
+ },
+ )
+ GlassField(t("工作文件夹(逗号分隔,留空用 ~/Andee)", "Work folders (comma-separated; blank = ~/Andee)"), v["shell_workdirs"].orEmpty(), { v["shell_workdirs"] = it })
+ if (fullOpenAsk) {
+ FullOpenConfirm(zh, onYes = { v["shell_mode"] = "full"; fullOpenAsk = false }, onNo = { fullOpenAsk = false })
+ }
}
- Note(
- when (v["shell_mode"].orEmpty().ifEmpty { "ask" }) {
- "auto" -> t("在沙箱里,普通命令直接跑;删大量文件、强推这类仍先问你。", "Ordinary commands run in the sandbox; destructive ones still ask first.")
- "read_only" -> t("只允许查看类命令,其它一律拒绝。", "Only read-only commands are allowed.")
- "full" -> t("不进沙箱、不问:Andee 能改动这台 Mac 上的任何文件。", "No sandbox, no asking: Andee can change any file.")
- else -> t("只读命令直接跑,其它每条先问你。", "Read-only commands run; everything else asks first.")
- },
- )
- GlassField(t("工作文件夹(逗号分隔,留空用 ~/Andee)", "Work folders (comma-separated; blank = ~/Andee)"), v["shell_workdirs"].orEmpty(), { v["shell_workdirs"] = it })
- SectionTitle(t("SSH 钥匙", "SSH keys"))
- SshKeys(zh)
- if (fullOpenAsk) {
- FullOpenConfirm(zh, onYes = { v["shell_mode"] = "full"; fullOpenAsk = false }, onNo = { fullOpenAsk = false })
+ Section(t("SSH 钥匙", "SSH keys")) {
+ SshKeys(zh)
}
-
// ---- 高级: folded, with the note saying what is behind it ----
- SectionTitle(st("settings_section_advanced"))
- Row(
- Modifier.fillMaxWidth().glassPanel(12).clickable { advanced = !advanced }.padding(12.dp),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- Text(st("settings_advanced_note"), color = Palette.secondary, fontSize = 12.sp, modifier = Modifier.weight(1f))
- Text(if (advanced) "⌃" else "⌄", color = Palette.secondary, fontSize = 16.sp)
+ Section(st("settings_section_advanced")) {
+ Row(
+ Modifier.fillMaxWidth().clickable { advanced = !advanced },
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(st("settings_advanced_note"), color = Palette.secondary, fontSize = 12.sp, modifier = Modifier.weight(1f))
+ Text(if (advanced) "⌃" else "⌄", color = Palette.secondary, fontSize = 16.sp)
+ }
}
if (advanced) {
- SectionTitle(st("settings_show_hub"))
- SegmentedPicker(listOf("off" to st("common_off"), "on" to st("common_on")), v["show_hub"].orEmpty().ifEmpty { "off" }) { v["show_hub"] = it }
- Note(st("settings_show_hub_note"))
-
- SectionTitle(st("settings_section_diagnostics"))
- RowLabel(st("settings_grounding"))
- SegmentedPicker(listOf("off" to st("common_off"), "on" to st("common_on")), v["grounding"].orEmpty().ifEmpty { "off" }) { v["grounding"] = it }
- Note(st("settings_grounding_note"))
- Note(st("settings_device_id") + ":" + Settings.uid())
- Spacer(Modifier.height(12.dp))
+ Section(st("settings_show_hub"), note = st("settings_show_hub_note")) {
+ SegmentedPicker(listOf("off" to st("common_off"), "on" to st("common_on")), v["show_hub"].orEmpty().ifEmpty { "off" }) { v["show_hub"] = it }
+ }
+ Section(st("settings_section_diagnostics")) {
+ RowLabel(st("settings_grounding"))
+ SegmentedPicker(listOf("off" to st("common_off"), "on" to st("common_on")), v["grounding"].orEmpty().ifEmpty { "off" }) { v["grounding"] = it }
+ Note(st("settings_grounding_note"))
+ Note(st("settings_device_id") + ":" + Settings.uid())
+ }
+ Spacer(Modifier.height(16.dp))
when (confirm) {
"chat" -> ConfirmBlock(st("settings_clear_chat_confirm_title"), st("settings_clear_chat_confirm_body"), st("settings_clear_chat_confirm"),
onNo = { confirm = "" }) { Assistant.stop(); Scrollback.wipe(); Pages.wipe(); confirm = "" }
@@ -276,7 +288,8 @@ fun SettingsScreen(
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
SecondaryButton(st("common_cancel"), Modifier.weight(1f)) { onDone() }
PrimaryButton(st("common_save"), Modifier.weight(1f)) {
- Settings.save(v.toMap())
+ // "lang" is written the instant the header toggle is tapped; the copy held here is from when the card opened.
+ Settings.save(v.toMap().minus("lang") + ("codeflying_key" to v["codeflying_key"].orEmpty().trim().takeIf { it != CodeFlyingBuild.key }.orEmpty()))
v["ball"]?.let { MacBall.pickLook(it) }
Thread { Assistant.ensure() }.start()
onDone()
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt
index ad9ac66..9237b0c 100644
--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt
+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/voice/MacVoice.kt
@@ -56,18 +56,25 @@ object MacVoice {
@Volatile private var tts: TtsEngine? = null
/** What the phone calls VoiceConfig.load(): the same keys, the same defaults. */
- fun settings(): VoiceSettings = VoiceSettings(
- apiKey = Settings.get("api_key"),
- asrEndpoint = Settings.get("asr_endpoint").ifEmpty { "wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async" },
+ fun settings(): VoiceSettings {
+ // Under CodeFlying the address and key are the hosted backend's, and the voice is 火山, as on the phone.
+ val cf = net.kuafuai.andee.desktop.Assistant.codeFlyingEndpoint()
+ ?.takeIf { net.kuafuai.andee.desktop.Assistant.config().mode == net.kuafuai.andee.config.BrainConfig.BRAIN_CODEFLYING }
+ return settings(cf)
+ }
+
+ private fun settings(codeFlying: net.kuafuai.andee.config.CodeFlyingEndpoint?): VoiceSettings = VoiceSettings(
+ apiKey = if (codeFlying != null) net.kuafuai.andee.desktop.Assistant.codeFlyingKey() else Settings.get("api_key"),
+ asrEndpoint = codeFlying?.asrEndpoint ?: Settings.get("asr_endpoint").ifEmpty { "wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async" },
asrResourceId = Settings.get("asr_resource_id").ifEmpty { "volc.bigasr.sauc.duration" },
asrUid = Settings.uid(),
- ttsEndpoint = Settings.get("tts_endpoint").ifEmpty { "wss://openspeech.bytedance.com/api/v3/tts/bidirection" },
+ ttsEndpoint = codeFlying?.ttsEndpoint ?: Settings.get("tts_endpoint").ifEmpty { "wss://openspeech.bytedance.com/api/v3/tts/bidirection" },
ttsResourceId = Settings.get("tts_resource_id").ifEmpty { "seed-tts-2.0" },
// The voice is the character's: read from the look the ball is wearing, per utterance, as the phone does.
ttsSpeaker = net.kuafuai.andee.ui.ball.BallLooks.byName(Settings.get("ball").ifEmpty { null }).voice
.ifEmpty { "zh_female_vv_uranus_bigtts" },
ttsSampleRate = Settings.get("tts_sample_rate").toIntOrNull()?.takeIf { it in 8_000..48_000 } ?: 24_000,
- voiceProvider = Settings.voiceProvider(),
+ voiceProvider = if (codeFlying != null) VoiceSettings.VOICE_HUOSHAN else Settings.voiceProvider(),
googleApiKey = Settings.get("google_api_key"),
googleBaseUrl = Settings.get("google_base_url").ifEmpty { "https://aiplatform.googleapis.com" },
googleProject = Settings.get("google_project"),
diff --git a/desktop/src/main/resources/strings_en.properties b/desktop/src/main/resources/strings_en.properties
index 160d23c..01d5759 100644
--- a/desktop/src/main/resources/strings_en.properties
+++ b/desktop/src/main/resources/strings_en.properties
@@ -6,7 +6,6 @@ MAX_STEPS=I have spent %1$d steps on this without finishing, so I stopped to ask
ERROR=Something broke on my side: %1$s
ERROR_400=The backend rejected the request: %1$s\nThe usual cause is a misspelled model name. Check it in Settings → Backend.
ERROR_402=The backend answered 402, which most likely means the account is out of balance. Open Settings → Backend to see which provider you are using, then top up on that provider's website and try again.
-ERROR_402_CODEFLYING=The backend answered 402, which most likely means your CodeFlying balance has run out. Open CodeFlying.app in a computer browser, sign in, top up, and try again.
ERROR_404=The backend could not find that address (HTTP 404). Check the endpoint URL and the model name in Settings → Backend.
ERROR_429=The backend is busy or being asked too often (HTTP 429). Say it again in a moment. If it keeps happening, check on the provider's website whether your quota has run out.
ERROR_5XX=The backend itself is having trouble (HTTP %1$d). Your settings are not the problem. Try again in a few minutes, or check the provider's website for maintenance notices.
@@ -58,14 +57,13 @@ s_settings_clear_notes_confirm_title=Clear the notebook?
s_settings_clear_notes_confirm_body=Everything it noted down, your preferences, and any reminder not yet due are deleted, with no way back. The current chat history is untouched.
s_settings_clear_notes_confirm=Clear it
s_settings_section_brain=Backend
-s_settings_brain_panel_note=Takes effect when you close this panel — no need to restart the accessibility service.
+s_settings_brain_panel_note=The AI model and voice service Andee uses to think, listen and speak.
s_settings_brain_cloud=Cloud
s_settings_brain_local=On-device
s_settings_brain_codeflying=CodeFlying
s_settings_show_hub=Show cloud option
s_settings_show_hub_note=Adds a Cloud backend tab for connecting to a hub you host yourself.
-s_settings_brain_codeflying_note=CodeFlying (CodeFlying.app) is connected: models and voice are set up and ready to go. You can also tap into a long list of third-party services — AI image, video and music generation, location, weather, PDF conversion, search, news, stocks and more. CodeFlying wraps and bills all of them in one place, so you never have to sign up with each provider or juggle their keys and invoices.\n\nAccount and top-ups: open CodeFlying.app in a computer browser and sign in. If you see a balance error (HTTP 402), top up there.\n\nNote: using CodeFlying backend services may incur charges.
-s_settings_brain_codeflying_unconfigured=Want Andee to draw, make videos, write music, check the weather, search the news, convert PDFs, or watch stocks for you? Connect CodeFlying: models and voice come set up, and a long list of third-party services is one hookup away, with no separate sign-ups, keys or invoices.\n\nTo get started, open CodeFlying.app in a computer browser and generate your own Andee install package in one click, then install it over this app. New users get free credit, so you can try it first.\n\nNote: using CodeFlying backend services may incur charges.
+s_settings_brain_codeflying_note=CodeFlying (CodeFlying.app): models and voice come set up for you; add your key and it works. You can also tap into a long list of third-party services — AI image, video and music generation, location, weather, PDF conversion, search, news, stocks and more. CodeFlying wraps and bills all of them in one place, so you never have to sign up with each provider or juggle their keys and invoices.\n\nNote: using CodeFlying backend services may incur charges.
s_settings_hub_url=Hub URL
s_settings_hub_url_hint=Link your cloud agent
s_settings_device_name=Device name
@@ -83,7 +81,6 @@ s_common_medium=Medium
s_common_low=Low
s_settings_brain_local_note=The device runs the agent loop itself, with no hub. Without a key it will not take over.
s_settings_no_key_use_codeflying=No key? Click here to switch to CodeFlying
-s_settings_codeflying_not_connected=CodeFlying is not connected yet
s_settings_section_wake=Wake word
s_settings_wake_enrolled=Enrolled — say your wake word and it wakes up
s_settings_wake_not_enrolled=Not enrolled — pick a phrase and say it 3 times to wake me by voice, e.g. “Hey Andee”
@@ -205,3 +202,10 @@ s_settings_theme_night=Dark
s_settings_section_expr=Looks & expressions
s_settings_expr_note=See every character and every expression; tap one to switch.
s_settings_expr_open=Open
+s_settings_codeflying_key=CodeFlying key
+s_common_copy=Copy
+s_common_copied=Copied
+s_settings_codeflying_get_key=No key? Sign up at the link below, then paste your key into the box underneath. New users get free credit.
+s_settings_codeflying_open_site=Open CodeFlying.app ›
+s_codeflying_url=https://www.codeflying.app/andee
+NO_KEY_CODEFLYING=There is no CodeFlying key yet. Open Settings → Backend → CodeFlying and paste the key; no key? Get one at CodeFlying.app.
diff --git a/desktop/src/main/resources/strings_zh.properties b/desktop/src/main/resources/strings_zh.properties
index b015707..34d1a44 100644
--- a/desktop/src/main/resources/strings_zh.properties
+++ b/desktop/src/main/resources/strings_zh.properties
@@ -6,7 +6,6 @@ MAX_STEPS=这件事我做了 %1$d 步还没办完,先停下来问你一句:
ERROR=我这边出错了:%1$s
ERROR_400=后端说请求有问题:%1$s\n最常见的原因是模型名写错了,到「设置」→「后端」核对一下模型名。
ERROR_402=后端服务返回了 402,多半是账户余额不足了。到「设置」→「后端」看看当前用的是哪家服务商,打开它的官网充值后再试。
-ERROR_402_CODEFLYING=后端服务返回了 402,多半是 CodeFlying 账户余额不足了。用电脑浏览器打开 CodeFlying.net 登录后充值,再试一次。
ERROR_404=后端找不到这个地址(HTTP 404)。到「设置」→「后端」检查接口地址和模型名有没有填错。
ERROR_429=后端现在太忙或者请求太频繁了(HTTP 429),过一会儿再说一遍就行。如果一直这样,去服务商官网看看额度有没有用完。
ERROR_5XX=后端服务自己出了问题(HTTP %1$d),不是你这边的设置有误。过几分钟再试;一直不行就去服务商官网看看是否在维护。
@@ -58,14 +57,13 @@ s_settings_clear_notes_confirm_title=清空小本本?
s_settings_clear_notes_confirm_body=它记下的事、你的偏好、还没到点的提醒,都会删掉,找不回来。这场聊天记录不受影响。
s_settings_clear_notes_confirm=确认清空
s_settings_section_brain=后端
-s_settings_brain_panel_note=关掉这个面板就生效,不用重开无障碍服务。
+s_settings_brain_panel_note=提供 AI 模型和语音服务,Andee 靠它思考、听和说。
s_settings_brain_cloud=云端
s_settings_brain_local=本机
s_settings_brain_codeflying=CodeFlying
s_settings_show_hub=显示云端选项
s_settings_show_hub_note=把「云端」加到后端选项里,用来连你自己搭的 Hub。
-s_settings_brain_codeflying_note=已接入 CodeFlying(CodeFlying.net):默认模型和语音都配好了,开箱就能用。还能直接调用海量第三方能力 —— AI 画图/做视频/写音乐、定位、天气、PDF 转换、搜索、新闻、股票……全部由 CodeFlying 统一封装、统一计费,不用自己逐个去申请密钥、对账单。\n\n账户管理和充值:用电脑浏览器打开 CodeFlying.net 登录。如果提示余额不足(HTTP 402),去那里充值即可。\n\n提示:使用 CodeFlying 的后端服务可能会产生费用。
-s_settings_brain_codeflying_unconfigured=想让 Andee 直接会画图、做视频、写音乐、查天气、搜新闻、转 PDF、看股票?接上 CodeFlying 就行:默认模型和语音都帮你配好,海量第三方能力一次接入,不用自己逐个申请密钥、对账单。\n\n怎么开始:用电脑浏览器打开 CodeFlying.net,一键生成专属于你的 Andee 安装包,装上去替换当前应用就好。新用户可免费获得额度,先试试再决定。\n\n提示:使用 CodeFlying 的后端服务可能会产生费用。
+s_settings_brain_codeflying_note=CodeFlying(CodeFlying.net):默认模型和语音都帮你配好,填上密钥就能用。还能直接调用海量第三方能力 —— AI 画图/做视频/写音乐、定位、天气、PDF 转换、搜索、新闻、股票……全部由 CodeFlying 统一封装、统一计费,不用自己逐个去申请密钥、对账单。\n\n提示:使用 CodeFlying 的后端服务可能会产生费用。
s_settings_hub_url=Hub 地址
s_settings_hub_url_hint=链接你的云端Agent
s_settings_device_name=设备名
@@ -83,7 +81,6 @@ s_common_medium=中
s_common_low=低
s_settings_brain_local_note=设备自己跑 agent loop,不连 Hub。没有 Key 就不会接管。
s_settings_no_key_use_codeflying=没有密钥?点这里切换到 CodeFlying 配置
-s_settings_codeflying_not_connected=您还未接入 CodeFlying
s_settings_section_wake=语音唤醒
s_settings_wake_enrolled=已录入 —— 说出你录的唤醒词就行
s_settings_wake_not_enrolled=未录入 —— 自己选个词录 3 遍就能语音唤醒,例如「嘿 Andee」
@@ -205,3 +202,10 @@ s_settings_theme_night=深色
s_settings_section_expr=形象与表情
s_settings_expr_note=看看每个形象和每个表情,点一下就换。
s_settings_expr_open=打开
+s_settings_codeflying_key=CodeFlying 密钥
+s_common_copy=复制
+s_common_copied=已复制
+s_settings_codeflying_get_key=没有密钥?到下面的链接注册登录,复制你的密钥粘贴到下方输入框。新用户可免费获得额度。
+s_settings_codeflying_open_site=打开 CodeFlying.net ›
+s_codeflying_url=https://www.codeflying.net/andee
+NO_KEY_CODEFLYING=还没有 CodeFlying 密钥。打开「设置」→「后端」→「CodeFlying」,粘贴密钥;还没有的话,去 CodeFlying.net 注册获取。