From 03c235777a3e9b0cce63e088e5161dec855dbee3 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Wed, 14 Oct 2026 14:22:03 -0300 Subject: [PATCH 1/4] chore: start 330 From f67b38c17e7abd6c36444b0ee2bfcb6e154d68fd Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Fri, 6 Nov 2026 11:51:58 +0000 Subject: [PATCH 2/4] chore(tooling): propagate reviewed Beans AI tooling --- .codegraph-version | 1 + .codegraph/.gitignore | 5 +++ AGENTS.md | 2 + docs/ai-tooling.md | 86 +++++++++++++++++++++++++++++++++++++++++++ scripts/codegraph.sh | 17 +++++++++ 5 files changed, 111 insertions(+) create mode 100644 .codegraph-version create mode 100644 .codegraph/.gitignore create mode 100644 docs/ai-tooling.md create mode 100755 scripts/codegraph.sh diff --git a/.codegraph-version b/.codegraph-version new file mode 100644 index 00000000..fdd3be6d --- /dev/null +++ b/.codegraph-version @@ -0,0 +1 @@ +1.6.2 diff --git a/.codegraph/.gitignore b/.codegraph/.gitignore new file mode 100644 index 00000000..d20c0fe4 --- /dev/null +++ b/.codegraph/.gitignore @@ -0,0 +1,5 @@ +# CodeGraph data files — local to each machine, not for committing. +# Ignore everything in .codegraph/ except this file itself, so transient +# files (the database, daemon.pid, sockets, logs) never show up in git. +* +!.gitignore diff --git a/AGENTS.md b/AGENTS.md index a6f3edd8..e4ffb564 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,7 @@ # Beans +For T3 onboarding, retrieval, command output and model reservations, follow [AI tooling](docs/ai-tooling.md). Product work remains HOLD until Heitor explicitly says OK. + Read [ARCHITECTURE.md](./ARCHITECTURE.md) before writing code, then the subject docs it lists for the parts you change. Identity is a local key pair. Paired Devices sync through an E2E relay. Provider credentials belong to the account: they sync to every paired Device as a blob encrypted with the account key. The AppKit app talks to the local CLI. diff --git a/docs/ai-tooling.md b/docs/ai-tooling.md new file mode 100644 index 00000000..b781f692 --- /dev/null +++ b/docs/ai-tooling.md @@ -0,0 +1,86 @@ +# Prepare and use AI tooling + +Read [AGENTS.md](../AGENTS.md), [BEANS.md](../BEANS.md) and [ARCHITECTURE.md](../ARCHITECTURE.md) before changing Beans. `CLAUDE.md` points to `AGENTS.md`; preserve that link and all existing instructions. + +## Keep product work on HOLD + +This preparation permits onboarding, tooling installation, independently reviewed tooling PRs, normal tooling merges and branch propagation. Product work remains HOLD until Heitor explicitly says OK. Green checks, a tooling merge and completed propagation do not release product work. Do not merge product PRs during this rollout. + +The central coordinator owns global settings and routing. Read `/Users/heitor/.config/ai-tooling/COORDINATION.md` and the current `GLOBAL-ROLLOUT.md` linked there. Report global configuration gaps to that coordinator. Keep one external rollout REPORT with commands, exit codes, receipt hashes, exact heads, resources and blockers. + +Target `bloodf/beans` explicitly for GitHub operations. `origin` is the Beans repository; `upstream` is `egoist/lorca`. T3's upstream canonical identity does not authorize upstream publication or integration. Confirm remotes, branch, HEAD, current base, worktrees and dirty state before writing. Similar source content does not prove ancestry. + +Preserve all refs with a verified Git bundle before propagation. Save staged and unstaged patches, untracked files and their hashes separately. Use an isolated tooling checkout. Preserve existing worktrees and previous work. Do not use automatic stash, `reset --hard`, force push or shared cleanup. + +## Retrieve source with CodeGraph 1.6.2 + +The standalone CLI is pinned by `.codegraph-version`. `scripts/codegraph.sh` checks the installed version, disables telemetry for its process and runs from this checkout's root. Keep CodeGraph outside application dependencies. + +Use the existing installation when it matches the pin. For workstation installation, inspect the installer at `https://raw.githubusercontent.com/colbymchenry/codegraph/f72c9d2efb14454ff4f9fd7b8460abd82f19a287/install.sh`, then run the inspected file with `CODEGRAPH_VERSION=v1.6.2`. Installation and user-specific MCP configuration belong to the central coordinator. + +Run these commands from the repository root: + +```sh +sh scripts/codegraph.sh init --yes +sh scripts/codegraph.sh sync +sh scripts/codegraph.sh status --json +sh scripts/codegraph.sh query dispatch --limit 5 --json +sh scripts/codegraph.sh callers dispatch --file crates/cli/src/api.rs --limit 5 --json +sh scripts/codegraph.sh explore --max-files 3 'api dispatch websocket serve' +``` + +Start with a bounded query before broad source reads. For exact text, missing results or unsupported syntax, use bounded `rg` and exact file ranges. Inspect the actual definition and caller before changing a flow. A graph relationship does not prove runtime behavior or complete dynamic call coverage. + +Each worktree has its own `.codegraph/` index. Do not copy databases between checkouts. Run `sync` and inspect `status --json` after checkout or edits. Check indexed languages, file/node counts, pending changes, worktree mismatch and index completion. Rebuild with `index` after changing include/exclude/extension rules. Version 1.6.2 has no `--strict` flag. + +Track only `.codegraph/.gitignore` inside `.codegraph/`. The ignore file excludes databases, logs, sockets, locks and daemon state. Never commit generated graphs or index data. With a configured CodeGraph MCP, keep the default single `codegraph_explore` tool; otherwise use the same bounded CLI commands. + +## Preserve command status with RTK 1.0.1 + +Read `/Users/heitor/.codex/RTK.md` when present. With a native RTK PreToolUse hook, run normal commands and do not wrap them twice. Without a native hook, use supported explicit commands such as `rtk git status` and `rtk gh pr list --repo bloodf/beans`. MiniMax uses this CLI route. Do not assume one harness's hooks apply to another. + +Preserve the actual exit code and first failure receipt. If condensed output is empty, contradictory or unusable, recover it with `rtk bypass ` or the stored raw receipt. Diagnose the first failure before another attempt. Do not weaken a check, timeout, baseline, security boundary or review requirement to obtain green results. + +## Use Caveman and Ponytail + +Use concise, complete Portuguese sentences with the user. Keep errors, identifiers, numbers and negations exact. Write code, persisted documents and critical instructions in complete language. + +Inspect the affected flow and callers, reuse existing code and standard libraries, and make the smallest complete change. Verify behavior at the relevant boundary. Preserve security, accessibility, approval, encryption and data-loss controls. Installation, synthetic probes, local checks, hosted checks and live behavior are separate evidence. + +## Verify TokenEconomizer per harness + +Reuse the central installation. Preserve the mode without auxiliary paid model calls: `microskills=envfacts`, `loopguard=off`, `repomap=off` and `toolprune=propose`. Do not set a paid model or enable paid proposers. Keep orchestration, review, device and required verification tools available; proposals cannot override project policy. + +From the checkout, inspect effective state without a model call: + +```sh +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" status +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" config show +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" repos list +``` + +Confirm the repository identity is the Beans origin and verify a worktree maps to that same repository. Record the installed adapter's supported events for each harness actually used. Codex's installed hook file declares `SessionStart`, `UserPromptSubmit`, `PostToolUse`, `Stop` and `SessionEnd`; declaration alone does not prove delivery through T3. + +Separate configuration present from fresh-session runtime proof. Loading a skill, starting a process or seeing a zero-session status does not prove the full lifecycle. Record unproved events as UNKNOWN. Do not invent adapters or hook support for Antigravity, MiniMax or another harness. TokenEconomizer learns repository facts and proposes tool pruning; it is not a generic output compressor. No local token savings are claimed without measurement. + +## Reserve every worker through the central dispatcher + +Before each tooling worker, reserve a route: + +```sh +t3-model-route reserve --project beans --purpose tooling --task '' +``` + +Launch only the exact returned provider, model and options through the applicable T3 delegation mechanism. Antigravity accepts Google models only. MiniMax M3.1 Flash requires `m:minimax:MiniMax-M3.1-Flash:v:thinking`. Quota UNKNOWN is not proof of capacity. Never substitute another project, provider or model, retry quota blindly, edit the global helper or implement a local round robin. + +Give each worker exact scope and file ownership. State that concurrent work must be preserved. Record the lease, task/run, provider, model and terminal outcome. Release only the exact lease after terminal evidence. Start no top-level thread for a worker. Use a fresh independent reviewer for each review or re-check, with the exact base/head and applicable risk requirements. No author approves their own change. + +## Verify and propagate tooling + +Keep the existing Beans gates. `bun run check:docs`, `bun run check:catalog` and the same-repository PR test matrix remain applicable. Inspect the current workflow definitions before execution; a local tooling smoke does not replace hosted checks. Product homes, accounts, relays, signing inputs and deployments are not tooling fixtures. + +Create one tooling PR against current Beans `main` and link it immediately to T3. Merge only after independent exact-head review and the real required checks pass. When waiting for hosted checks, use T3's PR watch and end the run; do not poll CI. + +Before propagation, prepare a per-ref plan with original head, target payload, old-head ancestry proof and recovery instructions. Append only tooling to every existing local and origin branch, including historical branches and open PR heads. Preserve each branch's existing instruction and ignore bytes. Do not merge unrelated product history, silently resolve divergence or recreate a branch absent from the server. Push fast-forward with explicit refspecs. Stop on the first remote write failure, re-read remote state and report to central before retry or a strategy change. + +Recheck current remote and PR heads, rescan for new refs, validate indexes in used checkouts and settle owned processes and leases. Record any uncovered ref as BLOCKED with a concrete reason. Product work still waits for Heitor's explicit OK. diff --git a/scripts/codegraph.sh b/scripts/codegraph.sh new file mode 100755 index 00000000..d6aa27fb --- /dev/null +++ b/scripts/codegraph.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Run from any directory with the repository's reviewed CodeGraph version. +set -eu +codegraph_root=$(CDPATH= cd "$(dirname "$0")/.." && pwd) +cd "$codegraph_root" +codegraph_expected=$(cat .codegraph-version) +if ! command -v codegraph >/dev/null 2>&1; then + echo "CodeGraph $codegraph_expected required. See docs/ai-tooling.md." >&2 + exit 1 +fi +codegraph_actual=$(codegraph --version) +if [ "$codegraph_actual" != "$codegraph_expected" ]; then + echo "CodeGraph $codegraph_expected required; found $codegraph_actual. See docs/ai-tooling.md." >&2 + exit 1 +fi +export CODEGRAPH_TELEMETRY=0 +exec codegraph "$@" From 8f88a00e64ef9e31318eaa4d6427ed12922e8b53 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Sat, 7 Nov 2026 17:00:57 -0300 Subject: [PATCH 3/4] fix(mobile): localize memory pages in Simplified Chinese --- mobile/app/chat-info/memory/[id].tsx | 100 +++---- mobile/app/chat-info/memory/advanced.tsx | 28 +- mobile/app/chat-info/memory/local.tsx | 12 +- mobile/app/chat-info/memory/setup.tsx | 28 +- mobile/app/settings/memory/connection.tsx | 56 ++-- mobile/app/settings/memory/embedding.tsx | 46 +-- mobile/app/settings/memory/index.tsx | 24 +- mobile/app/settings/memory/local-setup.tsx | 34 ++- mobile/src/i18n/zh.ts | 326 +++++++++++++++++++++ mobile/src/ui/memoryLocalization.test.ts | 41 +++ mobile/src/ui/memoryUI.tsx | 35 ++- 11 files changed, 560 insertions(+), 170 deletions(-) create mode 100644 mobile/src/ui/memoryLocalization.test.ts diff --git a/mobile/app/chat-info/memory/[id].tsx b/mobile/app/chat-info/memory/[id].tsx index be46fe3d..d089f87e 100644 --- a/mobile/app/chat-info/memory/[id].tsx +++ b/mobile/app/chat-info/memory/[id].tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useLocalSearchParams, useRouter } from 'expo-router'; import { useEffect, useState } from 'react'; import * as Crypto from 'expo-crypto'; @@ -10,6 +11,7 @@ import { confirmMemory, MemoryAction, MemoryForm, MemoryOutput, plaintextDisclos import { MemoryDeletionState } from '../../../src/ui/memoryTask'; const advanced: MemoryAdvancedFeature[] = ['bank_profile', 'bank_config', 'directives', 'mental_models', 'mental_model_history', 'observations', 'memory_edit', 'memory_invalidate', 'memory_restore', 'documents', 'sessions', 'resources', 'tasks']; export default function BotMemoryScreen() { + useLanguage(); const { id } = useLocalSearchParams<{ id: string; }>(), router = useRouter(), task = useMemoryTask(); @@ -33,7 +35,7 @@ export default function BotMemoryScreen() { const connection = config?.connections.find(c => c.id === saved?.connection_id); const caps = health?.capabilities ?? {}; const activationReason = connectionActivationReason(connection); - const reason = (action: Parameters[1]) => activationReason ?? (dirty ? 'Save or cancel preference changes first.' : !supportsMemoryAction(caps, action) ? 'Not negotiated by this Runner/backend. Check readiness explicitly.' : undefined); + const reason = (action: Parameters[1]) => activationReason ?? (dirty ? t('Save or cancel preference changes first.') : !supportsMemoryAction(caps, action) ? t('Not negotiated by this Runner/backend. Check readiness explicitly.') : undefined); function edit(action: () => void) { action(); setDirty(true); update(n => n + 1); } async function save() { if (!draft || !config) throw new Error('preferences_not_loaded'); await memoryService.savePreferences(draft, config); setSaved(await memoryService.getPreferences(id)); } @@ -46,71 +48,71 @@ export default function BotMemoryScreen() { return current; } const deletionPreferences = deletion.preferences; - const deletionReason = deletionPreferences ? undefined : 'Deletion confirmation unavailable. Refresh preferences before another attempt.'; + const deletionReason = deletionPreferences ? undefined : t('Deletion confirmation unavailable. Refresh preferences before another attempt.'); async function deleteMemory(target: string | undefined, confirmed: MemoryPreferencesView) { setOutput(await deletion.run(confirmed, () => memoryService.delete(id, target, connection!.revision, confirmed.deletion_epoch, caps, true), refreshDeletionPreferences)); } - return -
- - router.push({ pathname: '/chat-info/memory/local', params: { id } })}/> - - - {health?.reason && } - {connection?.backend === 'lance_db' && } - {health?.deletion_pending && } - confirmMemory('Check this bot’s memory endpoint?', `Read-only readiness on ${runner?.name ?? bot?.runner_id}. No retain, reflect, DDL, asset download or inference.`, () => void task.run(async () => { setHealth(await memoryService.health(id)); }))}/> - router.push('/settings/memory')}/> + return +
+ + router.push({ pathname: '/chat-info/memory/local', params: { id } })}/> + + + {health?.reason && } + {connection?.backend === 'lance_db' && } + {health?.deletion_pending && } + confirmMemory(t('Check this bot’s memory endpoint?'), t("Read-only readiness on {v0}. No retain, reflect, DDL, asset download or inference.", { v0: String(runner?.name ?? bot?.runner_id) }), () => void task.run(async () => { setHealth(await memoryService.health(id)); }))}/> + router.push('/settings/memory')}/>
{draft && <> -
- c.id === draft.connectionID)?.name ?? 'Off', choices: [{ title: 'Off', selected: !draft.connectionID, onPress: () => edit(() => { draft.connectionID = null; }) }, ...(config?.connections.filter(c => c.availability === 'supported').map(c => ({ title: c.name, selected: c.id === draft.connectionID, onPress: () => edit(() => { draft.connectionID = c.id; }) })) ?? [])] }}/> - {config?.connections.filter(c => c.availability === 'blocked').map(c => )} - edit(() => { draft.autoRecall = v; })}/> - {(['timeout_ms', 'max_bytes', 'max_results', 'max_context_chars'] as const).map(k => edit(() => { draft.recallBudget = { ...draft.recallBudget, [k]: Number(v) }; })}/>)} +
+ c.id === draft.connectionID)?.name ?? t('Off'), choices: [{ title: t('Off'), selected: !draft.connectionID, onPress: () => edit(() => { draft.connectionID = null; }) }, ...(config?.connections.filter(c => c.availability === 'supported').map(c => ({ title: c.name, selected: c.id === draft.connectionID, onPress: () => edit(() => { draft.connectionID = c.id; }) })) ?? [])] }}/> + {config?.connections.filter(c => c.availability === 'blocked').map(c => )} + edit(() => { draft.autoRecall = v; })}/> + {(['timeout_ms', 'max_bytes', 'max_results', 'max_context_chars'] as const).map(k => edit(() => { draft.recallBudget = { ...draft.recallBudget, [k]: Number(v) }; })}/>)}
-
- edit(() => { draft.captureConversation = v; if (!v) + -
- edit(() => { draft.captureGroupText = v; })}/> - confirmMemory('Approve future group-text capture?', `Bot: ${bot?.name ?? id}\nConnection: ${draft.connectionID}\nCapture conversation: ${draft.captureConversation}\nPer-turn cap: ${draft.maxCaptureDeliveriesPerTurn}\n\nOther participants’ text may be processed outside relay encryption. No historical backfill.`, () => { draft.approveGroupCapture(); update(n => n + 1); })}/> +
+ edit(() => { draft.captureGroupText = v; })}/> + confirmMemory(t('Approve future group-text capture?'), t("Bot: {v0}\nConnection: {v1}\nCapture conversation: {v2}\nPer-turn cap: {v3}\n\nOther participants’ text may be processed outside relay encryption. No historical backfill.", { v0: String(bot?.name ?? id), v1: String(draft.connectionID), v2: String(draft.captureConversation), v3: String(draft.maxCaptureDeliveriesPerTurn) }), () => { draft.approveGroupCapture(); update(n => n + 1); })}/>
-
- confirmMemory('Approve this bot’s remote plaintext choices?', `Bot: ${bot?.name ?? id}\nConnection: ${draft.connectionID}\nAutomatic recall: ${draft.autoRecall}\nFuture capture: ${draft.captureConversation}\nGroup text: ${draft.captureGroupText}\nPer-turn cap: ${draft.maxCaptureDeliveriesPerTurn}\n\n${plaintextDisclosure}`, () => { draft.approveRemotePlaintext(); update(n => n + 1); })}/> +
+ confirmMemory(t('Approve this bot’s remote plaintext choices?'), t("Bot: {v0}\nConnection: {v1}\nAutomatic recall: {v2}\nFuture capture: {v3}\nGroup text: {v4}\nPer-turn cap: {v5}\n\n{v6}", { v0: String(bot?.name ?? id), v1: String(draft.connectionID), v2: String(draft.autoRecall), v3: String(draft.captureConversation), v4: String(draft.captureGroupText), v5: String(draft.maxCaptureDeliveriesPerTurn), v6: String(t(plaintextDisclosure)) }), () => { draft.approveRemotePlaintext(); update(n => n + 1); })}/>
} -
- { setText(v); setRequestID(Crypto.randomUUID()); }}/> - confirmMemory('Send and retain this text?', plaintextDisclosure, () => void task.run(async () => { setOutput(await memoryService.retain(id, text, requestID, caps, true)); await refreshOperations(); }))}/> - - confirmMemory('Send this search query?', plaintextDisclosure, () => void task.run(async () => setOutput(await memoryService.recall(id, query, caps, true))))}/> - confirmMemory('Run native reflection?', plaintextDisclosure + ' This is service-native reflect, not similarity search or Beans synthesis.', () => void task.run(async () => setOutput(await memoryService.reflect(id, query, caps, true))))}/> - - confirmMemory('Inspect this document?', 'Fetch own-bot document and provenance from the assigned Runner’s memory service.', () => void task.run(async () => setOutput(await memoryService.inspect(id, documentID, caps))))}/> - void task.run(refreshDeletionPreferences)}/> - confirmMemory('Delete this document?', `${documentID}\nBot: ${id}\nConnection revision: ${connection?.revision.counter}\nEpoch: ${deletionPreferences?.deletion_epoch}\nPending does not mean erased. Backups/history may remain.`, () => void task.run(() => deleteMemory(documentID, deletionPreferences!)), true)}/> - confirmMemory('Clear this bot’s entire bank?', `Bot: ${id}\nConnection: ${connection?.name}\nRevision: ${connection?.revision.counter}\nEpoch: ${deletionPreferences?.deletion_epoch}\nQueued writes are fenced. Pending cleanup is not verified erasure; backups/history can remain.`, () => void task.run(() => deleteMemory(undefined, deletionPreferences!)), true)}/> +
+ { setText(v); setRequestID(Crypto.randomUUID()); }}/> + confirmMemory(t('Send and retain this text?'), t(plaintextDisclosure), () => void task.run(async () => { setOutput(await memoryService.retain(id, text, requestID, caps, true)); await refreshOperations(); }))}/> + + confirmMemory(t('Send this search query?'), t(plaintextDisclosure), () => void task.run(async () => setOutput(await memoryService.recall(id, query, caps, true))))}/> + confirmMemory(t('Run native reflection?'), t(plaintextDisclosure) + t(' This is service-native reflect, not similarity search or Beans synthesis.'), () => void task.run(async () => setOutput(await memoryService.reflect(id, query, caps, true))))}/> + + confirmMemory(t('Inspect this document?'), t('Fetch own-bot document and provenance from the assigned Runner’s memory service.'), () => void task.run(async () => setOutput(await memoryService.inspect(id, documentID, caps))))}/> + void task.run(refreshDeletionPreferences)}/> + confirmMemory(t('Delete this document?'), t("{v0}\nBot: {v1}\nConnection revision: {v2}\nEpoch: {v3}\nPending does not mean erased. Backups/history may remain.", { v0: String(documentID), v1: String(id), v2: String(connection?.revision.counter), v3: String(deletionPreferences?.deletion_epoch) }), () => void task.run(() => deleteMemory(documentID, deletionPreferences!)), true)}/> + confirmMemory(t('Clear this bot’s entire bank?'), t("Bot: {v0}\nConnection: {v1}\nRevision: {v2}\nEpoch: {v3}\nQueued writes are fenced. Pending cleanup is not verified erasure; backups/history can remain.", { v0: String(id), v1: String(connection?.name), v2: String(connection?.revision.counter), v3: String(deletionPreferences?.deletion_epoch) }), () => void task.run(() => deleteMemory(undefined, deletionPreferences!)), true)}/>
-
- void task.run(refreshOperations)}/> - {operations?.deletion?.pending && } +
+ void task.run(refreshOperations)}/> + {operations?.deletion?.pending && }
{operations?.operations.map(op =>
- - confirmMemory('Poll this operation?', 'One explicit status call; no automatic polling or retries.', () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'status', caps, true)); await refreshOperations(); }))}/> - confirmMemory('Retry this delivery?', plaintextDisclosure + ' Stable IDs do not guarantee exactly-once billing.', () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'retry', caps, true)); await refreshOperations(); }))}/> - confirmMemory('Cancel this operation?', 'Cooperative cancellation does not guarantee no late writes or refunds.', () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'cancel', caps, true)); await refreshOperations(); }))}/> + + confirmMemory(t('Poll this operation?'), t('One explicit status call; no automatic polling or retries.'), () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'status', caps, true)); await refreshOperations(); }))}/> + confirmMemory(t('Retry this delivery?'), t(plaintextDisclosure) + t(' Stable IDs do not guarantee exactly-once billing.'), () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'retry', caps, true)); await refreshOperations(); }))}/> + confirmMemory(t('Cancel this operation?'), t('Cooperative cancellation does not guarantee no late writes or refunds.'), () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'cancel', caps, true)); await refreshOperations(); }))}/>
)} -
- {advanced.filter(feature => !activationReason && connection && advancedForms(connection.backend, feature, caps).length > 0).map(feature => router.push({ pathname: '/chat-info/memory/advanced', params: { id, feature } })}/>)} - router.push({ pathname: '/chat-info/memory/setup', params: { id } })}/> +
+ {advanced.filter(feature => !activationReason && connection && advancedForms(connection.backend, feature, caps).length > 0).map(feature => router.push({ pathname: '/chat-info/memory/advanced', params: { id, feature } })}/>)} + router.push({ pathname: '/chat-info/memory/setup', params: { id } })}/>
- {output !== undefined && } + {output !== undefined && } ; } diff --git a/mobile/app/chat-info/memory/advanced.tsx b/mobile/app/chat-info/memory/advanced.tsx index 5466129c..65b671a4 100644 --- a/mobile/app/chat-info/memory/advanced.tsx +++ b/mobile/app/chat-info/memory/advanced.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useLocalSearchParams } from 'expo-router'; import { useEffect, useState } from 'react'; import { memoryService } from '../../../src/core/memoryServiceNative'; @@ -7,6 +8,7 @@ import { useBotMap } from '../../../src/core/store'; import { FieldRow, Row, Section } from '../../../src/ui/forms'; import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, plaintextDisclosure, useMemoryTask } from '../../../src/ui/memoryUI'; export default function MemoryAdvancedScreen() { + useLanguage(); const params = useLocalSearchParams<{ id: string; feature: MemoryAdvancedFeature; @@ -24,20 +26,20 @@ export default function MemoryAdvancedScreen() { const forms = backend && !activationReason ? advancedForms(backend, params.feature, health?.capabilities) : []; const form = forms.find(f => f.action === action); const allowed = supportsMemoryAction(health?.capabilities, params.feature, action); - const busyReason = activationReason ?? (!allowed ? 'Exact action not negotiated. Explicitly check readiness first.' : !form ? 'Choose an implemented action.' : form.spending && !health?.capabilities.operation_status ? 'Async operation status is not supported. Billed extraction/refresh disabled.' : undefined); - return -
- - confirmMemory('Check readiness?', 'One explicit read-only request on the assigned Runner. No billed inference.', () => void task.run(async () => setHealth(await memoryService.health(params.id))))}/> - {health?.reason && } - {!!forms.length && f.action)} onChange={v => { setAction(v); setValues({}); }}/>} - {!forms.length && } + const busyReason = activationReason ?? (!allowed ? t('Exact action not negotiated. Explicitly check readiness first.') : !form ? t('Choose an implemented action.') : form.spending && !health?.capabilities.operation_status ? t('Async operation status is not supported. Billed extraction/refresh disabled.') : undefined); + return +
+ + confirmMemory(t('Check readiness?'), t('One explicit read-only request on the assigned Runner. No billed inference.'), () => void task.run(async () => setHealth(await memoryService.health(params.id))))}/> + {health?.reason && } + {!!forms.length && f.action)} onChange={v => { setAction(v); setValues({}); }}/>} + {!forms.length && }
- {form &&
- {form.fields.map(f => f.type === 'boolean' ? setValues({ ...values, [f.name]: v })}/> : setValues({ ...values, [f.name]: v })} keyboardType={f.type === 'number' ? 'number-pad' : 'default'} multiline={['content', 'text', 'source_query', 'reflect_mission', 'retain_mission', 'retain_custom_instructions'].includes(f.name)} autoCapitalize="none" autoCorrect={false}/>)} - confirmMemory(`Approve ${params.feature} / ${form.action}?`, `Bot: ${params.id}\nAssigned Runner: ${bot?.runner_id}\nFields: ${JSON.stringify(values)}\n\n${plaintextDisclosure}${form.destructive ? '\nDeletion/cancellation may leave remote history, backups or late writes.' : ''}`, () => void task.run(async () => setOutput(await memoryService.advanced(params.id, params.feature, form.action, advancedBody(params.feature, form, values), health!.capabilities, true))), form.destructive)}/> + {form &&
+ {form.fields.map(f => f.type === 'boolean' ? setValues({ ...values, [f.name]: v })}/> : setValues({ ...values, [f.name]: v })} keyboardType={f.type === 'number' ? 'number-pad' : 'default'} multiline={['content', 'text', 'source_query', 'reflect_mission', 'retain_mission', 'retain_custom_instructions'].includes(f.name)} autoCapitalize="none" autoCorrect={false}/>)} + confirmMemory(t("Approve {v0} / {v1}?", { v0: String(params.feature), v1: String(form.action) }), t("Bot: {v0}\nAssigned Runner: {v1}\nFields: {v2}\n\n{v3}{v4}", { v0: String(params.id), v1: String(bot?.runner_id), v2: String(JSON.stringify(values)), v3: String(t(plaintextDisclosure)), v4: String(form.destructive ? t("\nDeletion/cancellation may leave remote history, backups or late writes.") : '') }), () => void task.run(async () => setOutput(await memoryService.advanced(params.id, params.feature, form.action, advancedBody(params.feature, form, values), health!.capabilities, true))), form.destructive)}/>
} - {output !== undefined && } - {params.feature === 'documents' &&
} + {output !== undefined && } + {params.feature === 'documents' &&
} ; } diff --git a/mobile/app/chat-info/memory/local.tsx b/mobile/app/chat-info/memory/local.tsx index 495fb8cf..32db3972 100644 --- a/mobile/app/chat-info/memory/local.tsx +++ b/mobile/app/chat-info/memory/local.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useLocalSearchParams } from 'expo-router'; import { useState } from 'react'; import { memoryService } from '../../../src/core/memoryServiceNative'; @@ -6,6 +7,7 @@ import type { LocalMemoryView } from '../../../src/core/memoryService'; import { FieldRow, Row, Section } from '../../../src/ui/forms'; import { confirmMemory, MemoryAction, MemoryForm, useMemoryTask } from '../../../src/ui/memoryUI'; export default function LocalMemoryScreen() { + useLanguage(); const { id } = useLocalSearchParams<{ id: string; }>(); @@ -16,11 +18,11 @@ export default function LocalMemoryScreen() { async function load() { const value = await memoryService.readLocal(id); setSaved(value); setText(value.text); } async function save() { if (!saved) throw new Error('local_memory_not_loaded'); await memoryService.saveLocal(id, text, saved.hash); } - return -
- - dirty ? confirmMemory('Discard draft and reload?', 'The latest Runner file replaces this local draft.', () => void task.run(load), true) : void task.run(load)}/> - {saved && <>{saved.truncated && }} + return +
+ + dirty ? confirmMemory(t('Discard draft and reload?'), t('The latest Runner file replaces this local draft.'), () => void task.run(load), true) : void task.run(load)}/> + {saved && <>{saved.truncated && }}
; } diff --git a/mobile/app/chat-info/memory/setup.tsx b/mobile/app/chat-info/memory/setup.tsx index fa23f335..678935bf 100644 --- a/mobile/app/chat-info/memory/setup.tsx +++ b/mobile/app/chat-info/memory/setup.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useLocalSearchParams } from 'expo-router'; import { useEffect, useState } from 'react'; import { memoryService } from '../../../src/core/memoryServiceNative'; @@ -6,6 +7,7 @@ import { useBotMap } from '../../../src/core/store'; import { FieldRow, Row, Section, ToggleRow } from '../../../src/ui/forms'; import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, useMemoryTask } from '../../../src/ui/memoryUI'; export default function BotMemorySetupScreen() { + useLanguage(); const { id } = useLocalSearchParams<{ id: string; }>(); @@ -24,22 +26,22 @@ export default function BotMemorySetupScreen() { const actions: BotSetupAction[] = activationReason ? [] : backend === 'pgvector' ? ['pgvector.initialize'] : backend === 'lance_db' ? ['lance.binding', 'lance.export', 'lance.import'] : []; function change(fn: () => void) { fn(); setDirty(true); setPreview(undefined); } async function makePreview() { setPreview(await memoryService.botPreview(action, id, action === 'lance.binding' ? { directory: path, create } : action === 'lance.export' || action === 'lance.import' ? { path } : undefined)); } - return -
- - {backend === 'lance_db' && } - {actions.length ? change(() => setAction(v))}/> : } + return +
+ + {backend === 'lance_db' && } + {actions.length ? change(() => setAction(v))}/> : }
- {actions.includes(action) && action === 'pgvector.initialize' &&
} - {actions.includes(action) && action.startsWith('lance.') &&
- change(() => setPath(v))} autoCapitalize="none" autoCorrect={false}/> - {action === 'lance.binding' && change(() => setCreate(v))}/>} + {actions.includes(action) && action === 'pgvector.initialize' &&
} + {actions.includes(action) && action.startsWith('lance.') &&
+ change(() => setPath(v))} autoCapitalize="none" autoCorrect={false}/> + {action === 'lance.binding' && change(() => setCreate(v))}/>}
} -
confirmMemory('Inspect exact setup target?', `Bot: ${id}\nAssigned Runner: ${bot?.runner_id}\nAction: ${action}\nNo DDL/import/export is applied by preview. Lance previews freeze bounded plaintext transfer bytes on the Runner.`, () => void task.run(makePreview))}/>
+
confirmMemory(t('Inspect exact setup target?'), t("Bot: {v0}\nAssigned Runner: {v1}\nAction: {v2}\nNo DDL/import/export is applied by preview. Lance previews freeze bounded plaintext transfer bytes on the Runner.", { v0: String(id), v1: String(bot?.runner_id), v2: String(action) }), () => void task.run(makePreview))}/>
{!activationReason && preview && <> - -
confirmMemory('Apply the exact displayed preview?', `Bot: ${preview.bot_id}\nRunner: ${preview.runner_id}\nAction: ${preview.action}\nApprove only the displayed target/schema/SQL or source/target/namespace/fingerprint. No override, fallback or overwrite is permitted. Transfer files contain plaintext and must be handled privately.`, () => void task.run(async () => { setPreview(undefined); setOutput(await memoryService.applyBotPreview(preview, true)); setDirty(false); }))}/>
+ +
confirmMemory(t('Apply the exact displayed preview?'), t("Bot: {v0}\nRunner: {v1}\nAction: {v2}\nApprove only the displayed target/schema/SQL or source/target/namespace/fingerprint. No override, fallback or overwrite is permitted. Transfer files contain plaintext and must be handled privately.", { v0: String(preview.bot_id), v1: String(preview.runner_id), v2: String(preview.action) }), () => void task.run(async () => { setPreview(undefined); setOutput(await memoryService.applyBotPreview(preview, true)); setDirty(false); }))}/>
} - {output !== undefined && } + {output !== undefined && } ; } diff --git a/mobile/app/settings/memory/connection.tsx b/mobile/app/settings/memory/connection.tsx index 309b28d2..a5a9e5d6 100644 --- a/mobile/app/settings/memory/connection.tsx +++ b/mobile/app/settings/memory/connection.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useLocalSearchParams } from 'expo-router'; import { useEffect, useState } from 'react'; import * as Crypto from 'expo-crypto'; @@ -10,6 +11,7 @@ type Binding = NonNullable['bindings'][string]>; export default function MemoryConnectionScreen() { + useLanguage(); const params = useLocalSearchParams<{ id?: string; }>(); @@ -87,48 +89,48 @@ export default function MemoryConnectionScreen() { embedding_profile: embedding === 'none' ? null : embedding, ...(insecure === 'keep' ? {} : { allow_insecure_http: insecure === 'allow' }), options }); } - return -
- edit(() => setName(v))}/> - {saved && } - {saved ? : { edit(() => setBackend(v)); if (v === 'lance_db') useRunnerLocal(); }}/>} + return +
+ edit(() => setName(v))}/> + {saved && } + {saved ? : { edit(() => setBackend(v)); if (v === 'lance_db') useRunnerLocal(); }}/>} {backend === 'lance_db' ? <> - - edit(() => { setEndpointAction('keep'); setEndpoint(''); setSecretAction('keep'); setKey(''); setReplaceOptions(false); }) }] : []), - { title: 'Runner-local (explicit)', selected: endpointAction === 'clear', onPress: () => saved - ? confirmMemory('Configure Runner-local LanceDB?', 'This explicitly clears the private endpoint and connection credential; it is not a fallback after a Cloud failure. Remote data remains untouched. Save this choice, then explicitly configure the bot’s private database on its assigned Runner.', useRunnerLocal, true) + + edit(() => { setEndpointAction('keep'); setEndpoint(''); setSecretAction('keep'); setKey(''); setReplaceOptions(false); }) }] : []), + { title: t('Runner-local (explicit)'), selected: endpointAction === 'clear', onPress: () => saved + ? confirmMemory(t('Configure Runner-local LanceDB?'), t('This explicitly clears the private endpoint and connection credential; it is not a fallback after a Cloud failure. Remote data remains untouched. Save this choice, then explicitly configure the bot’s private database on its assigned Runner.'), useRunnerLocal, true) : useRunnerLocal() }, ] }}/> : <> - edit(() => setEndpointAction(v))}/> - {endpointAction === 'replace' && edit(() => setEndpoint(v))} autoCapitalize="none" autoCorrect={false} placeholder={backend === 'pgvector' ? 'postgresql://host/database' : 'https://…'}/>} + edit(() => setEndpointAction(v))}/> + {endpointAction === 'replace' && edit(() => setEndpoint(v))} autoCapitalize="none" autoCorrect={false} placeholder={backend === 'pgvector' ? 'postgresql://host/database' : 'https://…'}/>} } - edit(() => setEmbedding('none')) }, ...(view?.embeddings.map(e => ({ title: e.model, selected: embedding === e.id, onPress: () => edit(() => setEmbedding(e.id)) })) ?? [])] }}/> - {backend !== 'lance_db' && ({ title: value, selected: insecure === value, onPress: () => value === 'allow' ? confirmMemory('Allow unencrypted HTTP?', 'Plaintext and credentials may be exposed on the network. Approve only a trusted private endpoint.', () => edit(() => setInsecure('allow'))) : edit(() => setInsecure(value as 'keep' | 'deny')) })) }}/>} + edit(() => setEmbedding('none')) }, ...(view?.embeddings.map(e => ({ title: e.model, selected: embedding === e.id, onPress: () => edit(() => setEmbedding(e.id)) })) ?? [])] }}/> + {backend !== 'lance_db' && ({ title: t(value), selected: insecure === value, onPress: () => value === 'allow' ? confirmMemory(t('Allow unencrypted HTTP?'), t('Plaintext and credentials may be exposed on the network. Approve only a trusted private endpoint.'), () => edit(() => setInsecure('allow'))) : edit(() => setInsecure(value as 'keep' | 'deny')) })) }}/>}
{backend !== 'lance_db' && edit(() => { setSecretAction(v); setKey(''); })} onValue={v => edit(() => setKey(v))}/>} -
- {backend !== 'open_viking' && backend !== 'lance_db' && edit(() => setReplaceOptions(v))}/>} - {replaceOptions && backend === 'pgvector' && edit(() => setSchema(v))} autoCapitalize="none" autoCorrect={false}/>} - {backend === 'open_viking' && } +
+ {backend !== 'open_viking' && backend !== 'lance_db' && edit(() => setReplaceOptions(v))}/>} + {replaceOptions && backend === 'pgvector' && edit(() => setSchema(v))} autoCapitalize="none" autoCorrect={false}/>} + {backend === 'open_viking' && }
{backend === 'open_viking' && bots.map(bot => { const b = bindings[bot.id]; const change = (next: Binding) => edit(() => setBindings(current => ({ ...current, [bot.id]: next }))); - return
- v === 'remove' - ? confirmMemory('Remove this bot binding?', `Bot: ${bot.name} (${bot.id})\nOnly this bot’s private binding/key is removed from the account connection. Other bot bindings remain unchanged. Remote data is not deleted.`, () => bindingChange(bot.id, 'remove'), true) + return
+ v === 'remove' + ? confirmMemory(t('Remove this bot binding?'), t("Bot: {v0} ({v1})\nOnly this bot’s private binding/key is removed from the account connection. Other bot bindings remain unchanged. Remote data is not deleted.", { v0: String(bot.name), v1: String(bot.id) }), () => bindingChange(bot.id, 'remove'), true) : bindingChange(bot.id, v)}/> {b && <> - change({ ...b, mode, secret: { action: 'replace', value: '' } })}/> - change({ ...b, account_id, secret: { action: 'replace', value: '' } })} autoCapitalize="none"/> - change({ ...b, user_id, secret: { action: 'replace', value: '' } })} autoCapitalize="none"/> - change({ ...b, secret: action === 'replace' ? { action, value: '' } : { action } })}/> - {b.secret.action === 'replace' && change({ ...b, secret: { action: 'replace', value } })} autoCapitalize="none" autoCorrect={false}/>} + change({ ...b, mode, secret: { action: 'replace', value: '' } })}/> + change({ ...b, account_id, secret: { action: 'replace', value: '' } })} autoCapitalize="none"/> + change({ ...b, user_id, secret: { action: 'replace', value: '' } })} autoCapitalize="none"/> + change({ ...b, secret: action === 'replace' ? { action, value: '' } : { action } })}/> + {b.secret.action === 'replace' && change({ ...b, secret: { action: 'replace', value } })} autoCapitalize="none" autoCorrect={false}/>} }
; })} - {saved &&
confirmMemory('Disconnect this connection?', saved.name + ' is removed from the encrypted account configuration. Remote data remains.', () => void task.run(async () => { await memoryService.disconnectConnection(id); setDirty(false); setLoaded(false); }), true)}/>
} + {saved &&
confirmMemory(t('Disconnect this connection?'), saved.name + t(' is removed from the encrypted account configuration. Remote data remains.'), () => void task.run(async () => { await memoryService.disconnectConnection(id); setDirty(false); setLoaded(false); }), true)}/>
} ; } diff --git a/mobile/app/settings/memory/embedding.tsx b/mobile/app/settings/memory/embedding.tsx index 5945a4f4..8abcd6d3 100644 --- a/mobile/app/settings/memory/embedding.tsx +++ b/mobile/app/settings/memory/embedding.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useLocalSearchParams } from 'expo-router'; import { useEffect, useState } from 'react'; import * as Crypto from 'expo-crypto'; @@ -7,6 +8,7 @@ import { FieldRow, Row, Section, ToggleRow } from '../../../src/ui/forms'; import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemorySecret, useMemoryTask } from '../../../src/ui/memoryUI'; const localStart: LocalModelConfig = { model_sha256: '', tokenizer_sha256: '', max_tokens: 512, pooling: 'mean', tensors: { input_ids: 'input_ids', attention_mask: 'attention_mask', output: 'last_hidden_state', token_type_ids: null }, add_special_tokens: true, pad_id: 0, pad_type_id: 0, pad_token: '[PAD]' }; export default function EmbeddingScreen() { + useLanguage(); const params = useLocalSearchParams<{ id?: string; }>(); @@ -26,32 +28,32 @@ export default function EmbeddingScreen() { async function save() { if (params.id && !saved) throw new Error('profile_not_loaded'); if (saved?.has_secret && profile.mode === 'api' && action === 'keep') throw new Error('complete_profile_replacement_requires_replace_or_clear_key'); await memoryService.setEmbedding(id, profile, secretPatch(action, key)); } - return -
- field('model', v)} autoCapitalize="none"/> - field('revision', v)} autoCapitalize="none"/> - field('dimensions', Number(v))}/> - field('mode', v)}/> - field('normalization', v)}/> - field('distance', v)}/> - field('document_prefix', v)} autoCapitalize="none"/> - field('query_prefix', v)} autoCapitalize="none"/> - {profile.mode === 'api' && field('endpoint', v)} placeholder="https://host/embeddings" autoCapitalize="none" autoCorrect={false}/>} + return +
+ field('model', v)} autoCapitalize="none"/> + field('revision', v)} autoCapitalize="none"/> + field('dimensions', Number(v))}/> + field('mode', v)}/> + field('normalization', v)}/> + field('distance', v)}/> + field('document_prefix', v)} autoCapitalize="none"/> + field('query_prefix', v)} autoCapitalize="none"/> + {profile.mode === 'api' && field('endpoint', v)} placeholder="https://host/embeddings" autoCapitalize="none" autoCorrect={false}/>}
{profile.mode === 'api' && { setAction(v); setDirty(true); }} onValue={v => { setKey(v); setDirty(true); }}/>} {profile.mode === 'local_cpu' && <> -
- local('model_sha256', v)} autoCapitalize="none" autoCorrect={false}/> - local('tokenizer_sha256', v)} autoCapitalize="none" autoCorrect={false}/> - local('max_tokens', Number(v))}/> - local('pooling', v)}/> - local('add_special_tokens', v)}/> - local('pad_id', Number(v))}/> - local('pad_type_id', Number(v))}/> - local('pad_token', v)}/> +
+ local('model_sha256', v)} autoCapitalize="none" autoCorrect={false}/> + local('tokenizer_sha256', v)} autoCapitalize="none" autoCorrect={false}/> + local('max_tokens', Number(v))}/> + local('pooling', v)}/> + local('add_special_tokens', v)}/> + local('pad_id', Number(v))}/> + local('pad_type_id', Number(v))}/> + local('pad_token', v)}/>
-
{(['input_ids', 'attention_mask', 'output', 'token_type_ids'] as const).map(k => local('tensors', { ...l.tensors, [k]: k === 'token_type_ids' ? (v || null) : v })} autoCapitalize="none" autoCorrect={false}/>)}
+
{(['input_ids', 'attention_mask', 'output', 'token_type_ids'] as const).map(k => local('tensors', { ...l.tensors, [k]: k === 'token_type_ids' ? (v || null) : v })} autoCapitalize="none" autoCorrect={false}/>)}
} - {saved &&
confirmMemory('Remove profile?', saved.model, () => void task.run(async () => { await memoryService.removeEmbedding(id); setDirty(false); setSaved(undefined); }), true)}/>
} + {saved &&
confirmMemory(t('Remove profile?'), saved.model, () => void task.run(async () => { await memoryService.removeEmbedding(id); setDirty(false); setSaved(undefined); }), true)}/>
} ; } diff --git a/mobile/app/settings/memory/index.tsx b/mobile/app/settings/memory/index.tsx index a5a841ea..f7d2d04f 100644 --- a/mobile/app/settings/memory/index.tsx +++ b/mobile/app/settings/memory/index.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useFocusEffect, useRouter } from 'expo-router'; import { useCallback, useState } from 'react'; import { memoryService } from '../../../src/core/memoryServiceNative'; @@ -5,22 +6,23 @@ import { LANCE_CLOUD_UNAVAILABLE_REASON, type MemoryConnectionsView } from '../. import { Row, Section } from '../../../src/ui/forms'; import { MemoryForm, useMemoryTask, MemoryAction } from '../../../src/ui/memoryUI'; export default function MemoryConnectionsScreen() { + useLanguage(); const router = useRouter(), task = useMemoryTask(); const [view, setView] = useState(); async function refresh() { setView(await memoryService.listConnections()); } useFocusEffect(useCallback(() => { void task.run(refresh); }, [task])); - return -
- {view?.connections.map(c => router.push({ pathname: '/settings/memory/connection', params: { id: c.id } })}/>)} - {view && !view.connections.length && } - router.push('/settings/memory/connection')}/> - + return +
+ {view?.connections.map(c => router.push({ pathname: '/settings/memory/connection', params: { id: c.id } })}/>)} + {view && !view.connections.length && } + router.push('/settings/memory/connection')}/> +
-
- {view?.embeddings.map(e => router.push({ pathname: '/settings/memory/embedding', params: { id: e.id } })}/>)} - router.push('/settings/memory/embedding')}/> - router.push('/settings/memory/local-setup')}/> +
+ {view?.embeddings.map(e => router.push({ pathname: '/settings/memory/embedding', params: { id: e.id } })}/>)} + router.push('/settings/memory/embedding')}/> + router.push('/settings/memory/local-setup')}/>
-
void task.run(refresh)}/>
+
void task.run(refresh)}/>
; } diff --git a/mobile/app/settings/memory/local-setup.tsx b/mobile/app/settings/memory/local-setup.tsx index 667b392b..04a45bb3 100644 --- a/mobile/app/settings/memory/local-setup.tsx +++ b/mobile/app/settings/memory/local-setup.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../../../src/i18n'; import { useEffect, useState } from 'react'; import { memoryService } from '../../../src/core/memoryServiceNative'; import type { AssetRequest, LocalPreview, MemoryEmbeddingView } from '../../../src/core/memoryService'; @@ -5,6 +6,7 @@ import { useStore } from '../../../src/core/store'; import { FieldRow, Row, Section } from '../../../src/ui/forms'; import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, useMemoryTask } from '../../../src/ui/memoryUI'; export default function LocalEmbeddingSetupScreen() { + useLanguage(); const task = useMemoryTask(), devices = useStore(s => s.devices); const runners = devices.filter(d => ['macos', 'linux', 'windows'].includes(d.os)); const [runner, setRunner] = useState(''); @@ -20,25 +22,25 @@ export default function LocalEmbeddingSetupScreen() { const profile = profiles.find(p => p.id === profileID); async function makePreview() { if (!runner || !profile) throw new Error('runner_and_profile_required'); setPreview(await memoryService.localPreview(runner, profile.id, profile.revision, { assets })); } - return -
- r.id === runner)?.name ?? 'Choose', choices: runners.map(r => ({ title: r.name, selected: r.id === runner, onPress: () => change(() => setRunner(r.id)) })) }}/> - ({ title: p.model, selected: p.id === profileID, onPress: () => change(() => setProfileID(p.id)) })) }}/> - {!runners.length && } + return +
+ r.id === runner)?.name ?? t('Choose'), choices: runners.map(r => ({ title: r.name, selected: r.id === runner, onPress: () => change(() => setRunner(r.id)) })) }}/> + ({ title: p.model, selected: p.id === profileID, onPress: () => change(() => setProfileID(p.id)) })) }}/> + {!runners.length && }
- {assets.map((a, i) =>
- asset(i, { ...a, source: kind === 'supplied' ? { kind, path: '' } : { kind, url: '' } })}/> - asset(i, { ...a, source: a.source.kind === 'supplied' ? { kind: 'supplied', path: v } : { kind: 'download', url: v } })} autoCapitalize="none" autoCorrect={false}/> - asset(i, { ...a, license: v })}/> - asset(i, { ...a, bytes: Number(v) })}/> - asset(i, { ...a, sha256: v })} autoCapitalize="none" autoCorrect={false}/> + {assets.map((a, i) =>
+ asset(i, { ...a, source: kind === 'supplied' ? { kind, path: '' } : { kind, url: '' } })}/> + asset(i, { ...a, source: a.source.kind === 'supplied' ? { kind: 'supplied', path: v } : { kind: 'download', url: v } })} autoCapitalize="none" autoCorrect={false}/> + asset(i, { ...a, license: v })}/> + asset(i, { ...a, bytes: Number(v) })}/> + asset(i, { ...a, sha256: v })} autoCapitalize="none" autoCorrect={false}/>
)} -
void task.run(makePreview)}/>
+
void task.run(makePreview)}/>
{preview && <> - -
confirmMemory('Install these exact assets on this Runner?', 'Approve only the displayed sources, licenses, byte counts and hashes, and explicit runtime/model load on ' + preview.runner_id + '. Downloads may transfer bytes; no inference is invoked.', () => void task.run(async () => { setPreview(undefined); setResult(await memoryService.applyLocalPreview(preview, true)); setDirty(false); }))}/>
+ +
confirmMemory(t('Install these exact assets on this Runner?'), t('Approve only the displayed sources, licenses, byte counts and hashes, and explicit runtime/model load on ') + preview.runner_id + t('. Downloads may transfer bytes; no inference is invoked.'), () => void task.run(async () => { setPreview(undefined); setResult(await memoryService.applyLocalPreview(preview, true)); setDirty(false); }))}/>
} -
confirmMemory('Check local runtime?', 'This explicit status request can load a previously approved native runtime on the selected Runner. It does not infer or download.', () => void task.run(async () => setResult(await memoryService.localStatus(runner, profileID))))}/>
- {result !== undefined && } +
confirmMemory(t('Check local runtime?'), t('This explicit status request can load a previously approved native runtime on the selected Runner. It does not infer or download.'), () => void task.run(async () => setResult(await memoryService.localStatus(runner, profileID))))}/>
+ {result !== undefined && } ; } diff --git a/mobile/src/i18n/zh.ts b/mobile/src/i18n/zh.ts index e6df2dd0..35dc6ed1 100644 --- a/mobile/src/i18n/zh.ts +++ b/mobile/src/i18n/zh.ts @@ -517,4 +517,330 @@ export const zh: Record = { "Installing {latest}… Beans restarts when it is done.": "正在安装 {latest}… 完成后 Beans 会重新启动。", "Android is already confirming this installation. Cancel it to keep new drafts.": "Android 已在确认此次安装。请取消安装以保留新草稿。", "Couldn’t install the update": "无法安装更新", + "Account Connections": "账户连接", + "Account connections": "账户连接", + "Action": "操作", + "Action fields": "操作字段", + "Activation blocked": "激活已阻止", + "Add Connection": "添加连接", + "Add Embedding Profile": "添加嵌入配置", + "Add Memory Connection": "添加记忆连接", + "Add a connection, then choose it in a bot’s Memory page.": "添加连接,然后在机器人的记忆页面选择它。", + "Add special tokens": "添加特殊词元", + "Allow unencrypted HTTP?": "允许未加密的 HTTP?", + "Apply This Exact Preview": "应用此精确预览", + "Apply the exact displayed preview?": "应用显示的精确预览?", + "Approve Exact Recall/Capture Choices": "批准确切的召回/采集选项", + "Approve Group Capture Choices": "批准群聊采集选项", + "Approve Install and Runtime Load": "批准安装和加载运行时", + "Approve future group-text capture?": "批准未来的群聊文本采集?", + "Approve only the displayed sources, licenses, byte counts and hashes, and explicit runtime/model load on ": "仅批准显示的来源、许可证、字节数和哈希,以及在以下 Runner 上显式加载运行时/模型:", + "Approve table creation in preview": "在预览中批准创建表", + "Approve this bot’s remote plaintext choices?": "批准此机器人的远程明文选项?", + "Assigned Runner": "指定 Runner", + "Async operation status is not supported. Billed extraction/refresh disabled.": "不支持异步操作状态。已禁用收费的提取/刷新。", + "Authorization": "授权", + "Automatic recall": "自动召回", + "Automatic recall sends task text once per eligible normal turn. It injects bounded evidence as untrusted historical data. Outages leave local memory usable.": "自动召回在每个符合条件的正常轮次发送一次任务文本。它将有界证据作为不可信的历史数据注入。服务中断时本地记忆仍可使用。", + "Backend": "后端", + "Backend options": "后端选项", + "Backend-specific capabilities": "后端特定能力", + "Binding change": "绑定更改", + "Blocked / unavailable": "已阻止 / 不可用", + "Bot Memory": "机器人记忆", + "Bot key": "机器人密钥", + "Bot memory": "机器人记忆", + "Cancel Operation": "取消操作", + "Cancel this operation?": "取消此操作?", + "Capture conversation": "采集对话", + "Capture group text": "采集群聊文本", + "Check Approved Local Runtime": "检查已批准的本地运行时", + "Check Negotiated Capabilities": "检查协商能力", + "Check Operation": "检查操作", + "Check Service Readiness": "检查服务就绪状态", + "Check local runtime?": "检查本地运行时?", + "Check readiness?": "检查就绪状态?", + "Check this bot’s memory endpoint?": "检查此机器人的记忆端点?", + "Choose": "选择", + "Choose a Runner and profile.": "选择 Runner 和配置。", + "Choose a Runner and saved local_cpu profile.": "选择 Runner 和已保存的 local_cpu 配置。", + "Choose a pgvector or LanceDB connection for this bot. The Runner reports build/runtime/schema availability through actual RPC errors, never simulated readiness.": "为此机器人选择 pgvector 或 LanceDB 连接。Runner 通过实际 RPC 错误报告构建/运行时/架构的可用性,绝不模拟就绪状态。", + "Choose an implemented action.": "选择已实现的操作。", + "Choose saved local_cpu profile": "选择已保存的 local_cpu 配置", + "Clear Entire Own-bot Bank": "清空此机器人的整个记忆库", + "Clear this bot’s entire bank?": "清空此机器人的整个记忆库?", + "Configuration eligibility": "配置资格", + "Configure Runner-local LanceDB?": "配置 Runner 本地 LanceDB?", + "Confirm": "确认", + "Connection": "连接", + "Connection is blocked.": "连接已阻止。", + "Context budget exceeded": "超出上下文预算", + "Continue": "继续", + "Controls use negotiated capabilities, never backend-name parity. OpenViking sessions/resources/tasks are distinct. Vector stores do not offer native reflect or mental models.": "控件使用协商能力,绝不假定同名后端功能相同。OpenViking 会话/资源/任务各不相同。向量存储不提供原生反思或心智模型。", + "Cooperative cancellation does not guarantee no late writes or refunds.": "协作取消不保证不会发生延迟写入,也不保证退款。", + "Database/OID/role/address/port/version/session identity and schema SQL must match the preview.": "数据库/OID/角色/地址/端口/版本/会话标识和架构 SQL 必须与预览一致。", + "Delete Document": "删除文档", + "Delete this document?": "删除此文档?", + "Deletion confirmation unavailable. Refresh preferences before another attempt.": "删除确认不可用。再次尝试前请刷新偏好设置。", + "Deletion pending": "等待删除", + "Delivery operations": "交付操作", + "Delivery unknown — not confirmed stored": "交付未知 — 未确认存储", + "Dimensions": "维度", + "Direct document deletion is not sent through this advanced panel.": "此高级面板不会发送直接删除文档的请求。", + "Directory": "目录", + "Disabled: an enforced downstream total-cost policy is required. Turn-completion delivery is separately capped at 0–4.": "已禁用:需要强制执行的下游总费用策略。轮次完成交付另有限额,为 0–4。", + "Discard draft and reload?": "放弃草稿并重新加载?", + "Disconnect Connection": "断开连接", + "Disconnect invalidates queued use but never deletes service data.": "断开连接会使排队使用失效,但绝不删除服务数据。", + "Disconnect this connection?": "断开此连接?", + "Distance": "距离", + "Doc prefix": "文档前缀", + "Document ID": "文档 ID", + "Edit Memory Connection": "编辑记忆连接", + "Eligible — not initialized/ready": "符合条件 — 未初始化/未就绪", + "Eligible — readiness not checked by configuration": "符合条件 — 配置未检查就绪状态", + "Embedding Profile": "嵌入配置", + "Embedding profile": "嵌入配置", + "Embedding profiles": "嵌入配置", + "Enable group capture and conversation capture first.": "请先启用群聊采集和对话采集。", + "Encrypted configuration syncs to paired Devices. Service work runs on each bot’s assigned Runner. Saving a connection does not initialize a schema, download assets, or enable capture.": "加密配置同步到已配对设备。服务工作在每个机器人的指定 Runner 上运行。保存连接不会初始化架构、下载资源或启用采集。", + "Endpoint": "端点", + "Enter a document ID.": "输入文档 ID。", + "Enter a query first.": "请先输入查询。", + "Enter text first.": "请先输入文本。", + "Enter the Runner-local absolute path.": "输入 Runner 本地的绝对路径。", + "Enter the exact document ID.": "输入确切的文档 ID。", + "Every action requires its own approval. Only completed means stored. An uncertain delivery can have charged the service; retries are not exactly-once billing.": "每项操作都需要单独批准。只有 completed 才表示已存储。不确定的交付可能已产生服务费用;重试不保证只计费一次。", + "Every source path is on the selected Runner, never on this phone. Preview performs no acquisition or inference. Downloads require an administrator-approved HTTPS origin. Applying separately approves exact source/license/bytes/SHA-256 and runtime load; no fallback.": "所有源路径都位于所选 Runner,绝不在此手机上。预览不获取资源也不执行推理。下载需要管理员批准的 HTTPS 来源。应用时单独批准确切的来源/许可证/字节数/SHA-256 和运行时加载;无回退。", + "Exact URL": "确切 URL", + "Exact action not negotiated. Explicitly check readiness first.": "尚未协商此确切操作。请先显式检查就绪状态。", + "Exact approval": "精确批准内容", + "Exact bytes": "确切字节数", + "Exact pgvector initialization": "精确 pgvector 初始化", + "Exact target / schema / SQL / transfer": "确切目标 / 架构 / SQL / 传输", + "Exact vector space": "精确向量空间", + "Explicit preview and approval; no phone paths or runtime.": "显式预览和批准;无手机路径或运行时。", + "Explicit save / search": "显式保存 / 搜索", + "Explicitly check readiness. Missing or empty action permissions expose no advanced controls.": "请显式检查就绪状态。操作权限缺失或为空时不显示高级控件。", + "Fenced deletion": "受隔离屏障保护的删除", + "Fetch own-bot document and provenance from the assigned Runner’s memory service.": "从指定 Runner 的记忆服务获取此机器人的文档和来源。", + "Future conversation capture": "未来对话采集", + "Generate Exact Preview": "生成精确预览", + "Group context never grants another bot’s bank access. This may send other participants’ visible conversation text to the configured memory endpoint.": "群聊上下文绝不授予访问其他机器人记忆库的权限。这可能将其他参与者的可见对话文本发送到配置的记忆端点。", + "HTTP policy": "HTTP 策略", + "HTTPS URL": "HTTPS URL", + "Independent local editor; never uploads to the memory service.": "独立本地编辑器;绝不上传到记忆服务。", + "Inspect Document / Provenance": "查看文档 / 来源", + "Inspect exact setup target?": "检查确切的设置目标?", + "Inspect this document?": "查看此文档?", + "Install these exact assets on this Runner?": "在此 Runner 上安装这些确切资源?", + "Keep key is valid only for the exact saved bot/mode/account/user identity. Identity changes discard entered keys and require a fresh replacement; core rechecks this. Remove disconnects only this binding, not its remote data.": "保留密钥仅适用于已保存的确切机器人/模式/账户/用户标识。标识更改会丢弃输入的密钥并要求重新替换;核心会再次检查。移除仅断开此绑定,不删除其远程数据。", + "Keep private target": "保留私有目标", + "Key action": "密钥操作", + "Known options are an atomic replacement. Keep preserves private options.": "已知选项以原子方式替换。保留会保留私有选项。", + "LanceDB Cloud activation unavailable": "LanceDB Cloud 激活不可用", + "LanceDB storage target": "LanceDB 存储目标", + "License": "许可证", + "Load Local Memory": "加载本地记忆", + "Loaded budget": "已加载预算", + "Local Assets on a Runner": "Runner 上的本地资源", + "Local MEMORY.md": "本地 MEMORY.md", + "Max tokens": "最大词元数", + "Memory Connections": "记忆连接", + "Mode": "模式", + "Model SHA": "模型 SHA", + "Native Hindsight Reflect": "原生 Hindsight 反思", + "New key": "新密钥", + "No connections": "无连接", + "No negotiated actions": "无已协商操作", + "No paired Runner": "无已配对 Runner", + "No paths belong in this profile. Install the exact runtime/model/tokenizer on a selected Runner through a separate preview and approval. CPU only; no phone runtime or automatic download/fallback.": "此配置不包含路径。通过单独预览和批准在所选 Runner 上安装确切的运行时/模型/分词器。仅 CPU;无手机运行时或自动下载/回退。", + "No supported setup action for this connection.": "此连接无受支持的设置操作。", + "Normalization": "归一化", + "Not checked": "未检查", + "Not loaded": "未加载", + "Not negotiated by this Runner/backend. Check readiness explicitly.": "此 Runner/后端尚未协商此能力。请显式检查就绪状态。", + "Off by default. Only future eligible completed visible user/assistant text is captured after admission and completion consent checks. No history backfill, attachments, hidden thinking, secrets or tool output. Scrubbing is best effort, not DLP.": "默认关闭。仅在准入和完成同意检查后采集未来符合条件的已完成、可见用户/助手文本。无历史回填、附件、隐藏思考、秘密或工具输出。清理尽力而为,不是 DLP。", + "One explicit read-only request on the assigned Runner. No billed inference.": "在指定 Runner 上发送一次显式只读请求。无收费推理。", + "One explicit status call; no automatic polling or retries.": "一次显式状态调用;无自动轮询或重试。", + "Only a bounded portion is loaded into bot context. The editor retains the full file.": "仅将有界部分加载到机器人上下文。编辑器保留完整文件。", + "Only masked model/revision/dimensions are read back. Enter the complete intended profile. Model/revision, source hashes and all preprocessing participate in the fingerprint. Existing vector indexes refuse mismatches; saving is not reindexing and does not call inference.": "仅读回脱敏的模型/修订/维度。请输入完整的预期配置。模型/修订、来源哈希和所有预处理均参与指纹。现有向量索引拒绝不匹配;保存不会重建索引,也不调用推理。", + "Only these exact adapter-defined fields are sent. IDs are document/directive/model/session/task IDs within the core-bound own-bot scope. Resource paths are relative under resources/, never a target URI. Comma-separated tags; booleans are true/false. Blank optional fields are omitted.": "仅发送适配器定义的这些确切字段。ID 是核心绑定的此机器人范围内的文档/指令/模型/会话/任务 ID。资源路径是 resources/ 下的相对路径,绝不是目标 URI。标签以逗号分隔;布尔值为 true/false。省略空白可选字段。", + "Own-bot scope": "此机器人范围", + "Own-bot service": "此机器人的服务", + "Pad ID": "填充 ID", + "Pad token": "填充词元", + "Pad type ID": "填充类型 ID", + "Pair a desktop Runner before installing local assets.": "安装本地资源前请配对桌面 Runner。", + "Pending cleanup": "等待清理", + "Per-bot authorization": "每个机器人的授权", + "Per-bot patches preserve every omitted private binding/key. Keep sends no edit; Remove sends an explicit null for that bot only. No whole-map replacement is offered. Stored identities and keys are never read back.": "逐机器人补丁保留所有省略的私有绑定/密钥。保留不发送修改;移除仅为该机器人发送显式 null。不提供整张映射替换。绝不读回已存储的标识和密钥。", + "Per-turn cap": "每轮上限", + "Plaintext and credentials may be exposed on the network. Approve only a trusted private endpoint.": "明文和凭据可能在网络上暴露。仅批准可信的私有端点。", + "Plaintext approval": "明文批准", + "Poll this operation?": "查询此操作状态?", + "Pooling": "池化", + "Portable local model contract": "可移植本地模型契约", + "Preview Exact Asset Plan": "预览精确资源计划", + "Preview inspects the actual connected target and returns the complete non-destructive SQL, extension, tables, indexes and permissions. No DDL applies during preview. Apply accepts only the one-use token; no client SQL overrides.": "预览检查实际连接的目标并返回完整的非破坏性 SQL、扩展、表、索引和权限。预览期间不应用 DDL。应用仅接受一次性令牌;不允许客户端覆盖 SQL。", + "Profile": "配置", + "Query": "查询", + "Query prefix": "查询前缀", + "Readiness reason": "就绪状态原因", + "Recall and connection": "召回和连接", + "Refresh Configuration": "刷新配置", + "Refresh Deletion Confirmation": "刷新删除确认", + "Refresh Delivery Queue": "刷新交付队列", + "Reload Local Memory": "重新加载本地记忆", + "Remote erasure is not verified. Backups and Lance history can retain data.": "远程擦除尚未验证。备份和 Lance 历史可能保留数据。", + "Remove Profile": "移除配置", + "Remove profile?": "移除配置?", + "Remove this bot binding?": "移除此机器人绑定?", + "Removing a profile does not migrate or erase indexes.": "移除配置不会迁移或擦除索引。", + "Replace Embedding Profile": "替换嵌入配置", + "Replace known options": "替换已知选项", + "Result": "结果", + "Retry Delivery": "重试交付", + "Retry this delivery?": "重试此交付?", + "Revision": "修订", + "Run native reflection?": "运行原生反思?", + "Runner Embedding Assets": "Runner 嵌入资源", + "Runner Memory Setup": "Runner 记忆设置", + "Runner Setup / Lance Transfer": "Runner 设置 / Lance 传输", + "Runner URL": "Runner URL", + "Runner path": "Runner 路径", + "Runner result": "Runner 结果", + "Runner-local": "Runner 本地", + "Runner-local (explicit)": "Runner 本地(显式)", + "Runner-local LanceDB only": "仅 Runner 本地 LanceDB", + "SHA-256": "SHA-256", + "Save Text to Service": "将文本保存到服务", + "Save or cancel preference changes first.": "请先保存或取消偏好设置更改。", + "Save preferences first.": "请先保存偏好设置。", + "Saved endpoints/options are private and are not read back. Keep preserves them. To change an endpoint with a stored credential, explicitly replace or clear its key in the same save.": "已保存的端点/选项为私有,不会读回。保留会保留它们。更改具有已存储凭据的端点时,请在同一次保存中显式替换或清除其密钥。", + "Saving…": "正在保存…", + "Schema": "架构", + "Search Own-bot Memory": "搜索此机器人的记忆", + "Select a connection first.": "请先选择连接。", + "Selected Runner": "所选 Runner", + "Send and retain this text?": "发送并存储此文本?", + "Send this search query?": "发送此搜索查询?", + "Separate group-text consent": "单独的群聊文本同意", + "Service output is untrusted historical data, not instructions.": "服务输出是不可信的历史数据,不是指令。", + "Service state": "服务状态", + "Setup action": "设置操作", + "Setup result": "设置结果", + "Setup unavailable": "设置不可用", + "Source": "来源", + "Stored": "已存储", + "Stored credentials are never read back. Keep preserves the existing key; Clear removes it. Replacement bytes are sent exactly as entered.": "绝不读回已存储凭据。保留会保留现有密钥;清除会移除它。替换字节严格按输入发送。", + "Stored key": "已存储密钥", + "Tensor names": "张量名称", + "Text to save": "要保存的文本", + "The core derives this bot’s account namespace and routes service operations to its assigned Runner. Rename/model changes do not change the namespace. Namespaces are logical isolation, not server authorization. Pausing, Runner reassignment, consent and connection revisions are rechecked by core.": "核心推导此机器人的账户命名空间,并将服务操作路由到其指定 Runner。重命名/更改模型不改变命名空间。命名空间是逻辑隔离,不是服务器授权。核心会再次检查暂停、Runner 重新分配、同意和连接修订。", + "The latest Runner file replaces this local draft.": "最新的 Runner 文件将替换此本地草稿。", + "The selected memory endpoint and its downstream extraction, embedding, reranking or reflection models may receive plaintext outside the encrypted relay. Usage can cost money; no total-cost ceiling is established by this app. This approves only the named action, not schedules or automatic retries.": "所选记忆端点及其下游提取、嵌入、重排序或反思模型可能在加密中继之外接收明文。使用可能产生费用;此应用未设定总费用上限。此批准仅针对指定操作,不包括计划任务或自动重试。", + "These actions never activate Cloud or fall back from a failed Cloud connection. Configure the connection explicitly Runner-local first. Enter a path on the assigned Runner, not this phone. Local DB files do not sync through the account. Moving a bot requires explicit export/import or private transfer. Transfers are plaintext and limited to 8 MiB / 1000 documents; exact namespace, fingerprint and generation must validate. Cloud transfer is unsupported.": "这些操作绝不激活 Cloud,也不会从失败的 Cloud 连接回退。请先将连接显式配置为 Runner 本地。输入指定 Runner 上的路径,而非此手机。数据库本地文件不会通过账户同步。迁移机器人需要显式导出/导入或私有传输。传输为明文,上限为 8 MiB / 1000 个文档;必须验证确切的命名空间、指纹和代次。不支持 Cloud 传输。", + "These are trusted UI-only operations routed to the bot’s assigned Runner. No phone vector database or native runtime. Nothing applies until the exact worker-produced preview is displayed and approved. Tokens expire and are single-use even when apply fails.": "这些是仅由可信 UI 发起、路由到机器人指定 Runner 的操作。无手机向量数据库或原生运行时。在显示并批准工作进程生成的精确预览前不会应用任何内容。令牌会过期,且即使应用失败也只能使用一次。", + "This editor reads/writes only the assigned Runner’s local MEMORY.md through the existing core RPC. It does not retain content in a memory service, enable capture or merge historical conversations. Hash-based conflict protection refuses stale writes; a failed save keeps your draft.": "此编辑器仅通过现有核心 RPC 读写指定 Runner 的本地 MEMORY.md。它不会在记忆服务中存储内容、启用采集或合并历史对话。基于哈希的冲突保护拒绝过期写入;保存失败会保留草稿。", + "This explicit status request can load a previously approved native runtime on the selected Runner. It does not infer or download.": "此显式状态请求可以在所选 Runner 上加载先前批准的原生运行时。它不执行推理或下载。", + "This explicitly clears the private endpoint and connection credential; it is not a fallback after a Cloud failure. Remote data remains untouched. Save this choice, then explicitly configure the bot’s private database on its assigned Runner.": "这会显式清除私有端点和连接凭据;不是 Cloud 失败后的回退。远程数据保持不变。保存此选项,然后在指定 Runner 上显式配置机器人的私有数据库。", + "This state is not retryable.": "此状态不可重试。", + "Tokenizer SHA": "分词器 SHA", + "Transfer file": "传输文件", + "USER keys must match the expected account/user. A trusted gateway is explicitly configured; a shared USER key plus identity headers is not isolation.": "USER 密钥必须匹配预期账户/用户。可信网关需要显式配置;共享 USER 密钥加标识请求头并不构成隔离。", + "Unattended background capture": "无人值守后台采集", + "Unavailable": "不可用", + "Uncertain delivery has no verified idempotency; retry disabled.": "不确定交付没有经过验证的幂等性;已禁用重试。", + "Untrusted service result": "不可信服务结果", + "Use the main per-bot Memory page for document/bank deletion. Its exact revision/epoch confirmation fences queued writes.": "请使用各机器人的记忆主页面删除文档/记忆库。其确切修订/纪元确认可隔离排队写入。", + "User": "用户", + "Your unsaved memory changes will be lost.": "未保存的记忆更改将丢失。", + "pgvector and LanceDB require an exact model/revision/preprocessing vector space. Changing it requires a validated replacement index; dimensions alone are not compatible.": "pgvector 和 LanceDB 要求精确的模型/修订/预处理向量空间。更改需要经过验证的替换索引;仅维度相同并不兼容。", + " No auto-refresh schedules, consolidation or routine opt-in is implied. Directive content is intentionally configured service policy; returned historical text is not instructions. Only exact negotiated action verbs are shown and rechecked before dispatch.": " 不表示同意自动刷新计划、整合或例行任务。指令内容是有意配置的服务策略;返回的历史文本不是指令。仅显示已协商的确切操作动词,并在发送前再次检查。", + " Stable IDs do not guarantee exactly-once billing.": " 稳定 ID 不保证只计费一次。", + " This is service-native reflect, not similarity search or Beans synthesis.": " 这是服务原生反思,不是相似性搜索或 Beans 综合。", + " is removed from the encrypted account configuration. Remote data remains.": " 将从加密账户配置中移除。远程数据保留。", + ". Downloads may transfer bytes; no inference is invoked.": "。下载可能传输字节;不调用推理。", + "Run {v0}": "运行 {v0}", + "Approve {v0} / {v1}?": "批准 {v0} / {v1}?", + "Bot: {v0}\nAssigned Runner: {v1}\nFields: {v2}\n\n{v3}{v4}": "机器人:{v0}\n指定 Runner:{v1}\n字段:{v2}\n\n{v3}{v4}", + "{v0} Memory": "{v0} 的记忆", + "Read-only readiness on {v0}. No retain, reflect, DDL, asset download or inference.": "在 {v0} 上进行只读就绪检查。不存储、不反思、不执行 DDL、不下载资源或推理。", + "{v0} — activation blocked": "{v0} — 激活已阻止", + "Bot: {v0}\nConnection: {v1}\nCapture conversation: {v2}\nPer-turn cap: {v3}\n\nOther participants’ text may be processed outside relay encryption. No historical backfill.": "机器人:{v0}\n连接:{v1}\n采集对话:{v2}\n每轮上限:{v3}\n\n其他参与者的文本可能在中继加密之外处理。无历史回填。", + "Bot: {v0}\nConnection: {v1}\nAutomatic recall: {v2}\nFuture capture: {v3}\nGroup text: {v4}\nPer-turn cap: {v5}\n\n{v6}": "机器人:{v0}\n连接:{v1}\n自动召回:{v2}\n未来采集:{v3}\n群聊文本:{v4}\n每轮上限:{v5}\n\n{v6}", + "{v0}\nBot: {v1}\nConnection revision: {v2}\nEpoch: {v3}\nPending does not mean erased. Backups/history may remain.": "{v0}\n机器人:{v1}\n连接修订:{v2}\n纪元:{v3}\n等待中不表示已擦除。备份/历史可能保留。", + "Bot: {v0}\nConnection: {v1}\nRevision: {v2}\nEpoch: {v3}\nQueued writes are fenced. Pending cleanup is not verified erasure; backups/history can remain.": "机器人:{v0}\n连接:{v1}\n修订:{v2}\n纪元:{v3}\n排队写入受隔离屏障保护。等待清理不表示已验证擦除;备份/历史可能保留。", + "Epoch {v0}": "纪元 {v0}", + "{v0}/{v1} lines · {v2}/{v3} bytes": "{v0}/{v1} 行 · {v2}/{v3} 字节", + "Bot: {v0} ({v1})\nOnly this bot’s private binding/key is removed from the account connection. Other bot bindings remain unchanged. Remote data is not deleted.": "机器人:{v0}({v1})\n仅从账户连接中移除此机器人的私有绑定/密钥。其他机器人绑定保持不变。不会删除远程数据。", + "Bot: {v0}\nAssigned Runner: {v1}\nAction: {v2}\nNo DDL/import/export is applied by preview. Lance previews freeze bounded plaintext transfer bytes on the Runner.": "机器人:{v0}\n指定 Runner:{v1}\n操作:{v2}\n预览不应用 DDL/导入/导出。Lance 预览在 Runner 上冻结有界的明文传输字节。", + "Bot: {v0}\nRunner: {v1}\nAction: {v2}\nApprove only the displayed target/schema/SQL or source/target/namespace/fingerprint. No override, fallback or overwrite is permitted. Transfer files contain plaintext and must be handled privately.": "机器人:{v0}\nRunner:{v1}\n操作:{v2}\n仅批准显示的目标/架构/SQL 或来源/目标/命名空间/指纹。不允许覆盖、回退或覆写。传输文件包含明文,必须私密处理。", + "Activation blocked · {v0}": "激活已阻止 · {v0}", + "{v0} · Eligible configuration, not readiness · Setup checked per bot": "{v0} · 符合条件的配置,非就绪状态 · 按机器人检查设置", + "{v0} · {v1} dimensions": "{v0} · {v1} 维", + "\nDeletion/cancellation may leave remote history, backups or late writes.": "\n删除/取消可能留下远程历史、备份或延迟写入。", + "keep": "保留", + "replace": "替换", + "clear": "清除", + "edit": "编辑", + "remove": "移除", + "allow": "允许", + "deny": "拒绝", + "none": "无", + "local_cpu": "本地 CPU", + "supplied": "提供的文件", + "download": "下载", + "runtime": "运行时", + "model": "模型", + "tokenizer": "分词器", + "true": "是", + "false": "否", + "queued": "排队中", + "submitted": "已提交", + "processing": "处理中", + "completed": "已完成", + "delivery_unknown": "交付未知", + "ready": "就绪", + "degraded": "降级", + "setup_required": "需要设置", + "Choose and save a connection first.": "请先选择并保存连接。", + "LanceDB Cloud transport is unavailable until an upstream safe transport hook exists (lancedb_cloud_transport_unavailable). Credentials cannot enable it. Runner-local LanceDB is separate; no paid or local fallback.": "在上游提供安全传输钩子前,LanceDB Cloud 传输不可用(lancedb_cloud_transport_unavailable)。凭据无法启用它。Runner 本地 LanceDB 是独立配置;无付费或本地回退。", + "preferences_not_loaded": "偏好设置未加载(preferences_not_loaded)", + "local_memory_not_loaded": "本地记忆未加载(local_memory_not_loaded)", + "profile_not_found": "未找到配置(profile_not_found)", + "profile_not_loaded": "配置未加载(profile_not_loaded)", + "complete_profile_replacement_requires_replace_or_clear_key": "完整替换配置需要替换或清除密钥(complete_profile_replacement_requires_replace_or_clear_key)", + "connection_not_found": "未找到连接(connection_not_found)", + "configuration_not_loaded": "配置未加载(configuration_not_loaded)", + "name_required": "需要名称(name_required)", + "endpoint_change_requires_replace_or_clear_key": "更改端点需要替换或清除密钥(endpoint_change_requires_replace_or_clear_key)", + "runner_and_profile_required": "需要 Runner 和配置(runner_and_profile_required)", + "memory_request_failed": "记忆请求失败(memory_request_failed)", + "stale_confirmation": "确认已过期(stale_confirmation)", + "invalid_budget": "预算无效(invalid_budget)", + "enforced_spending_policy_required": "需要强制执行的费用策略(enforced_spending_policy_required)", + "plaintext_consent_required": "需要明文同意(plaintext_consent_required)", + "group_consent_required": "需要群聊同意(group_consent_required)", + "invalid_capture_cap": "采集上限无效(invalid_capture_cap)", + "group_capture_requires_conversation": "群聊采集需要启用对话采集(group_capture_requires_conversation)", + "connection_required": "需要连接(connection_required)", + "timeout_ms": "超时(毫秒)", + "max_bytes": "最大字节数", + "max_results": "最大结果数", + "max_context_chars": "最大上下文字符数", + "bank profile": "记忆库概况", + "bank config": "记忆库配置", + "directives": "指令", + "mental models": "心智模型", + "mental model history": "心智模型历史", + "observations": "观察", + "memory edit": "编辑记忆", + "memory invalidate": "使记忆失效", + "memory restore": "恢复记忆", + "documents": "文档", + "sessions": "会话", + "resources": "资源", + "tasks": "任务", }; diff --git a/mobile/src/ui/memoryLocalization.test.ts b/mobile/src/ui/memoryLocalization.test.ts new file mode 100644 index 00000000..7e1aa370 --- /dev/null +++ b/mobile/src/ui/memoryLocalization.test.ts @@ -0,0 +1,41 @@ +import { afterEach, expect, test, vi } from 'vitest'; +import { readFileSync, readdirSync } from 'node:fs'; +import { resolve } from 'node:path'; +import ts from 'typescript'; +vi.mock('../core/prefs', () => ({ loadPrefs: () => ({}), savePrefs: () => {} })); +vi.mock('expo-localization', () => ({ getLocales: () => [{ languageCode: 'en' }] })); +const { t, setAppLanguage } = await import('../i18n'); +const { zh } = await import('../i18n/zh'); +afterEach(() => setAppLanguage('en')); +const disclosure = 'The selected memory endpoint and its downstream extraction, embedding, reranking or reflection models may receive plaintext outside the encrypted relay. Usage can cost money; no total-cost ceiling is established by this app. This approves only the named action, not schedules or automatic retries.'; +test('consent preserves English and names scope and cost limits in Chinese', () => { + setAppLanguage('en'); + expect(t(disclosure)).toBe(disclosure); + setAppLanguage('zh'); + expect(t(disclosure)).toBe('所选记忆端点及其下游提取、嵌入、重排序或反思模型可能在加密中继之外接收明文。使用可能产生费用;此应用未设定总费用上限。此批准仅针对指定操作,不包括计划任务或自动重试。'); + expect(t('Clear this bot’s entire bank?')).toBe('清空此机器人的整个记忆库?'); + expect(t('Delete this document?')).toBe('删除此文档?'); + expect(t('Run {v0}', { v0: 'retain' })).toBe('运行 retain'); + setAppLanguage('en'); + expect(t('Run {v0}', { v0: 'retain' })).toBe('Run retain'); +}); +test('memory presentation keys have Chinese translations with identical placeholders', () => { + const dirs = ['app/chat-info/memory', 'app/settings/memory']; + const paths = dirs.flatMap(dir => readdirSync(resolve(dir)).filter(f => f.endsWith('.tsx')).map(f => resolve(dir, f))); + paths.push(resolve('src/ui/memoryUI.tsx')); + let checked = 0; + for (const path of paths) { + const source = ts.createSourceFile(path, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX); + function visit(node: ts.Node) { + if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 't' && node.arguments[0] && ts.isStringLiteral(node.arguments[0])) { + const key = node.arguments[0].text; + expect(zh[key], `${path}: ${key}`).toBeTruthy(); + expect(zh[key].match(/\{\w+\}/g)?.sort() ?? []).toEqual(key.match(/\{\w+\}/g)?.sort() ?? []); + checked++; + } + ts.forEachChild(node, visit); + } + visit(source); + } + expect(checked).toBeGreaterThan(200); +}); diff --git a/mobile/src/ui/memoryUI.tsx b/mobile/src/ui/memoryUI.tsx index 45439972..f787bad6 100644 --- a/mobile/src/ui/memoryUI.tsx +++ b/mobile/src/ui/memoryUI.tsx @@ -1,3 +1,4 @@ +import { t, useLanguage } from '../i18n'; import { Stack, useRouter } from 'expo-router'; import { useNavigation, usePreventRemove } from 'expo-router/react-navigation'; import { useEffect, useRef, useState, type ReactNode } from 'react'; @@ -13,6 +14,7 @@ export function useMemoryTask() { return task; } export function useMemoryGuard(busy: boolean, dirty: boolean) { + useLanguage(); const router = useRouter(), navigation = useNavigation(); const [leaving, setLeaving] = useState(false); const busyNow = useRef(busy); @@ -20,9 +22,9 @@ export function useMemoryGuard(busy: boolean, dirty: boolean) { usePreventRemove(!leaving && (busy || dirty), ({ data }) => { if (busyNow.current) return; - Alert.alert('Discard changes?', 'Your unsaved memory changes will be lost.', [ - { text: 'Keep Editing', style: 'cancel' }, - { text: 'Discard', style: 'destructive', onPress: () => { if (!busyNow.current) + Alert.alert(t('Discard changes?'), t('Your unsaved memory changes will be lost.'), [ + { text: t('Keep Editing'), style: 'cancel' }, + { text: t('Discard'), style: 'destructive', onPress: () => { if (!busyNow.current) navigation.dispatch(data.action); } }, ]); }); @@ -39,14 +41,15 @@ export function MemoryForm({ title, dirty, guardDirty = dirty, task, onSave, chi onSave?: () => Promise; children: ReactNode; }) { + useLanguage(); const p = usePalette(); const guard = useMemoryGuard(task.busy, guardDirty); return <> - {onSave && void task.run(async () => { await onSave(); guard.finish(); })}/>} + {onSave && void task.run(async () => { await onSave(); guard.finish(); })}/>} - {task.busy && } - {task.error && {task.error}} + {task.busy && } + {task.error && {t(task.error)}} {children} ; @@ -57,7 +60,8 @@ export function MemoryAction({ title, reason, onPress, destructive = false }: { onPress: () => void; destructive?: boolean; }) { - return ; + useLanguage(); + return ; } export function MemoryChoice({ title, value, values, onChange }: { title: string; @@ -65,7 +69,8 @@ export function MemoryChoice({ title, value, values, onChange values: readonly T[]; onChange: (value: T) => void; }) { - return ({ title: v, selected: v === value, onPress: () => onChange(v) })) }}/>; + useLanguage(); + return ({ title: t(v), selected: v === value, onPress: () => onChange(v) })) }}/>; } export function MemorySecret({ action, value, onAction, onValue, hasSecret }: { action: SecretPatch['action']; @@ -74,20 +79,22 @@ export function MemorySecret({ action, value, onAction, onValue, hasSecret }: { onValue: (value: string) => void; hasSecret: boolean; }) { - return
- - - {action === 'replace' && } + useLanguage(); + return
+ + + {action === 'replace' && }
; } export function MemoryOutput({ title, value }: { title: string; value: unknown; }) { + useLanguage(); const p = usePalette(); - return
{typeof value === 'string' ? value : JSON.stringify(value, (key, value) => /secret|api_key|authorization|preview_token|^token$/i.test(key) ? undefined : value, 2)}
; + return
{typeof value === 'string' ? value : JSON.stringify(value, (key, value) => /secret|api_key|authorization|preview_token|^token$/i.test(key) ? undefined : value, 2)}
; } export function confirmMemory(title: string, description: string, action: () => void, destructive = false) { - Alert.alert(title, description, [{ text: 'Cancel', style: 'cancel' }, { text: destructive ? 'Confirm' : 'Continue', style: destructive ? 'destructive' : 'default', onPress: action }]); + Alert.alert(title, description, [{ text: t('Cancel'), style: 'cancel' }, { text: destructive ? t('Confirm') : t('Continue'), style: destructive ? 'destructive' : 'default', onPress: action }]); } export const plaintextDisclosure = 'The selected memory endpoint and its downstream extraction, embedding, reranking or reflection models may receive plaintext outside the encrypted relay. Usage can cost money; no total-cost ceiling is established by this app. This approves only the named action, not schedules or automatic retries.'; From 362459fb49801d01476e2fa8d4fa6fc80146b339 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Sat, 7 Nov 2026 17:08:05 -0300 Subject: [PATCH 4/4] fix(mobile): expose dynamic memory translation keys to validator --- mobile/app/chat-info/memory/[id].tsx | 30 ++++----- mobile/app/chat-info/memory/advanced.tsx | 12 ++-- mobile/app/chat-info/memory/setup.tsx | 4 +- mobile/app/settings/memory/connection.tsx | 8 +-- mobile/app/settings/memory/embedding.tsx | 4 +- mobile/app/settings/memory/index.tsx | 4 +- mobile/app/settings/memory/local-setup.tsx | 4 +- mobile/src/ui/memoryLocalization.test.ts | 26 +++++++- mobile/src/ui/memoryUI.tsx | 77 +++++++++++++++++++++- 9 files changed, 131 insertions(+), 38 deletions(-) diff --git a/mobile/app/chat-info/memory/[id].tsx b/mobile/app/chat-info/memory/[id].tsx index d089f87e..ad5c269e 100644 --- a/mobile/app/chat-info/memory/[id].tsx +++ b/mobile/app/chat-info/memory/[id].tsx @@ -7,7 +7,7 @@ import { LANCE_CLOUD_UNAVAILABLE_REASON, connectionActivationReason, MemoryPrefe import { advancedForms } from '../../../src/core/memoryAdvanced'; import { useBotMap, useStore } from '../../../src/core/store'; import { FieldRow, Row, Section, ToggleRow } from '../../../src/ui/forms'; -import { confirmMemory, MemoryAction, MemoryForm, MemoryOutput, plaintextDisclosure, useMemoryTask } from '../../../src/ui/memoryUI'; +import { memoryText, confirmMemory, MemoryAction, MemoryForm, MemoryOutput, plaintextDisclosure, useMemoryTask } from '../../../src/ui/memoryUI'; import { MemoryDeletionState } from '../../../src/ui/memoryTask'; const advanced: MemoryAdvancedFeature[] = ['bank_profile', 'bank_config', 'directives', 'mental_models', 'mental_model_history', 'observations', 'memory_edit', 'memory_invalidate', 'memory_restore', 'documents', 'sessions', 'resources', 'tasks']; export default function BotMemoryScreen() { @@ -58,10 +58,10 @@ export default function BotMemoryScreen() {
router.push({ pathname: '/chat-info/memory/local', params: { id } })}/> - - - {health?.reason && } - {connection?.backend === 'lance_db' && } + + + {health?.reason && } + {connection?.backend === 'lance_db' && } {health?.deletion_pending && } confirmMemory(t('Check this bot’s memory endpoint?'), t("Read-only readiness on {v0}. No retain, reflect, DDL, asset download or inference.", { v0: String(runner?.name ?? bot?.runner_id) }), () => void task.run(async () => { setHealth(await memoryService.health(id)); }))}/> router.push('/settings/memory')}/> @@ -69,9 +69,9 @@ export default function BotMemoryScreen() { {draft && <>
c.id === draft.connectionID)?.name ?? t('Off'), choices: [{ title: t('Off'), selected: !draft.connectionID, onPress: () => edit(() => { draft.connectionID = null; }) }, ...(config?.connections.filter(c => c.availability === 'supported').map(c => ({ title: c.name, selected: c.id === draft.connectionID, onPress: () => edit(() => { draft.connectionID = c.id; }) })) ?? [])] }}/> - {config?.connections.filter(c => c.availability === 'blocked').map(c => )} + {config?.connections.filter(c => c.availability === 'blocked').map(c => )} edit(() => { draft.autoRecall = v; })}/> - {(['timeout_ms', 'max_bytes', 'max_results', 'max_context_chars'] as const).map(k => edit(() => { draft.recallBudget = { ...draft.recallBudget, [k]: Number(v) }; })}/>)} + {(['timeout_ms', 'max_bytes', 'max_results', 'max_context_chars'] as const).map(k => edit(() => { draft.recallBudget = { ...draft.recallBudget, [k]: Number(v) }; })}/>)}
-
- confirmMemory(t('Approve this bot’s remote plaintext choices?'), t("Bot: {v0}\nConnection: {v1}\nAutomatic recall: {v2}\nFuture capture: {v3}\nGroup text: {v4}\nPer-turn cap: {v5}\n\n{v6}", { v0: String(bot?.name ?? id), v1: String(draft.connectionID), v2: String(draft.autoRecall), v3: String(draft.captureConversation), v4: String(draft.captureGroupText), v5: String(draft.maxCaptureDeliveriesPerTurn), v6: String(t(plaintextDisclosure)) }), () => { draft.approveRemotePlaintext(); update(n => n + 1); })}/> +
+ confirmMemory(t('Approve this bot’s remote plaintext choices?'), t("Bot: {v0}\nConnection: {v1}\nAutomatic recall: {v2}\nFuture capture: {v3}\nGroup text: {v4}\nPer-turn cap: {v5}\n\n{v6}", { v0: String(bot?.name ?? id), v1: String(draft.connectionID), v2: String(draft.autoRecall), v3: String(draft.captureConversation), v4: String(draft.captureGroupText), v5: String(draft.maxCaptureDeliveriesPerTurn), v6: String(memoryText(plaintextDisclosure)) }), () => { draft.approveRemotePlaintext(); update(n => n + 1); })}/>
}
{ setText(v); setRequestID(Crypto.randomUUID()); }}/> - confirmMemory(t('Send and retain this text?'), t(plaintextDisclosure), () => void task.run(async () => { setOutput(await memoryService.retain(id, text, requestID, caps, true)); await refreshOperations(); }))}/> + confirmMemory(t('Send and retain this text?'), memoryText(plaintextDisclosure), () => void task.run(async () => { setOutput(await memoryService.retain(id, text, requestID, caps, true)); await refreshOperations(); }))}/> - confirmMemory(t('Send this search query?'), t(plaintextDisclosure), () => void task.run(async () => setOutput(await memoryService.recall(id, query, caps, true))))}/> - confirmMemory(t('Run native reflection?'), t(plaintextDisclosure) + t(' This is service-native reflect, not similarity search or Beans synthesis.'), () => void task.run(async () => setOutput(await memoryService.reflect(id, query, caps, true))))}/> + confirmMemory(t('Send this search query?'), memoryText(plaintextDisclosure), () => void task.run(async () => setOutput(await memoryService.recall(id, query, caps, true))))}/> + confirmMemory(t('Run native reflection?'), memoryText(plaintextDisclosure) + t(' This is service-native reflect, not similarity search or Beans synthesis.'), () => void task.run(async () => setOutput(await memoryService.reflect(id, query, caps, true))))}/> confirmMemory(t('Inspect this document?'), t('Fetch own-bot document and provenance from the assigned Runner’s memory service.'), () => void task.run(async () => setOutput(await memoryService.inspect(id, documentID, caps))))}/> void task.run(refreshDeletionPreferences)}/> @@ -104,13 +104,13 @@ export default function BotMemoryScreen() { {operations?.deletion?.pending && }
{operations?.operations.map(op =>
- + confirmMemory(t('Poll this operation?'), t('One explicit status call; no automatic polling or retries.'), () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'status', caps, true)); await refreshOperations(); }))}/> - confirmMemory(t('Retry this delivery?'), t(plaintextDisclosure) + t(' Stable IDs do not guarantee exactly-once billing.'), () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'retry', caps, true)); await refreshOperations(); }))}/> + confirmMemory(t('Retry this delivery?'), memoryText(plaintextDisclosure) + t(' Stable IDs do not guarantee exactly-once billing.'), () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'retry', caps, true)); await refreshOperations(); }))}/> confirmMemory(t('Cancel this operation?'), t('Cooperative cancellation does not guarantee no late writes or refunds.'), () => void task.run(async () => { setOutput(await memoryService.operation(id, op.id, 'cancel', caps, true)); await refreshOperations(); }))}/>
)}
- {advanced.filter(feature => !activationReason && connection && advancedForms(connection.backend, feature, caps).length > 0).map(feature => router.push({ pathname: '/chat-info/memory/advanced', params: { id, feature } })}/>)} + {advanced.filter(feature => !activationReason && connection && advancedForms(connection.backend, feature, caps).length > 0).map(feature => router.push({ pathname: '/chat-info/memory/advanced', params: { id, feature } })}/>)} router.push({ pathname: '/chat-info/memory/setup', params: { id } })}/>
{output !== undefined && } diff --git a/mobile/app/chat-info/memory/advanced.tsx b/mobile/app/chat-info/memory/advanced.tsx index 65b671a4..02883849 100644 --- a/mobile/app/chat-info/memory/advanced.tsx +++ b/mobile/app/chat-info/memory/advanced.tsx @@ -6,7 +6,7 @@ import { connectionActivationReason, supportsMemoryAction, type MemoryConnection import { advancedBody, advancedForms } from '../../../src/core/memoryAdvanced'; import { useBotMap } from '../../../src/core/store'; import { FieldRow, Row, Section } from '../../../src/ui/forms'; -import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, plaintextDisclosure, useMemoryTask } from '../../../src/ui/memoryUI'; +import { memoryText, confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, plaintextDisclosure, useMemoryTask } from '../../../src/ui/memoryUI'; export default function MemoryAdvancedScreen() { useLanguage(); const params = useLocalSearchParams<{ @@ -27,17 +27,17 @@ export default function MemoryAdvancedScreen() { const form = forms.find(f => f.action === action); const allowed = supportsMemoryAction(health?.capabilities, params.feature, action); const busyReason = activationReason ?? (!allowed ? t('Exact action not negotiated. Explicitly check readiness first.') : !form ? t('Choose an implemented action.') : form.spending && !health?.capabilities.operation_status ? t('Async operation status is not supported. Billed extraction/refresh disabled.') : undefined); - return -
+ return +
confirmMemory(t('Check readiness?'), t('One explicit read-only request on the assigned Runner. No billed inference.'), () => void task.run(async () => setHealth(await memoryService.health(params.id))))}/> - {health?.reason && } + {health?.reason && } {!!forms.length && f.action)} onChange={v => { setAction(v); setValues({}); }}/>} {!forms.length && }
{form &&
- {form.fields.map(f => f.type === 'boolean' ? setValues({ ...values, [f.name]: v })}/> : setValues({ ...values, [f.name]: v })} keyboardType={f.type === 'number' ? 'number-pad' : 'default'} multiline={['content', 'text', 'source_query', 'reflect_mission', 'retain_mission', 'retain_custom_instructions'].includes(f.name)} autoCapitalize="none" autoCorrect={false}/>)} - confirmMemory(t("Approve {v0} / {v1}?", { v0: String(params.feature), v1: String(form.action) }), t("Bot: {v0}\nAssigned Runner: {v1}\nFields: {v2}\n\n{v3}{v4}", { v0: String(params.id), v1: String(bot?.runner_id), v2: String(JSON.stringify(values)), v3: String(t(plaintextDisclosure)), v4: String(form.destructive ? t("\nDeletion/cancellation may leave remote history, backups or late writes.") : '') }), () => void task.run(async () => setOutput(await memoryService.advanced(params.id, params.feature, form.action, advancedBody(params.feature, form, values), health!.capabilities, true))), form.destructive)}/> + {form.fields.map(f => f.type === 'boolean' ? setValues({ ...values, [f.name]: v })}/> : setValues({ ...values, [f.name]: v })} keyboardType={f.type === 'number' ? 'number-pad' : 'default'} multiline={['content', 'text', 'source_query', 'reflect_mission', 'retain_mission', 'retain_custom_instructions'].includes(f.name)} autoCapitalize="none" autoCorrect={false}/>)} + confirmMemory(t("Approve {v0} / {v1}?", { v0: String(params.feature), v1: String(form.action) }), t("Bot: {v0}\nAssigned Runner: {v1}\nFields: {v2}\n\n{v3}{v4}", { v0: String(params.id), v1: String(bot?.runner_id), v2: String(JSON.stringify(values)), v3: String(memoryText(plaintextDisclosure)), v4: String(form.destructive ? t("\nDeletion/cancellation may leave remote history, backups or late writes.") : '') }), () => void task.run(async () => setOutput(await memoryService.advanced(params.id, params.feature, form.action, advancedBody(params.feature, form, values), health!.capabilities, true))), form.destructive)}/>
} {output !== undefined && } {params.feature === 'documents' &&
} diff --git a/mobile/app/chat-info/memory/setup.tsx b/mobile/app/chat-info/memory/setup.tsx index 678935bf..15760a25 100644 --- a/mobile/app/chat-info/memory/setup.tsx +++ b/mobile/app/chat-info/memory/setup.tsx @@ -5,7 +5,7 @@ import { memoryService } from '../../../src/core/memoryServiceNative'; import { LANCE_CLOUD_UNAVAILABLE_REASON, connectionActivationReason, type BotPreview, type BotSetupAction, type MemoryConnectionView } from '../../../src/core/memoryService'; import { useBotMap } from '../../../src/core/store'; import { FieldRow, Row, Section, ToggleRow } from '../../../src/ui/forms'; -import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, useMemoryTask } from '../../../src/ui/memoryUI'; +import { memoryText, confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, useMemoryTask } from '../../../src/ui/memoryUI'; export default function BotMemorySetupScreen() { useLanguage(); const { id } = useLocalSearchParams<{ @@ -29,7 +29,7 @@ export default function BotMemorySetupScreen() { return
- {backend === 'lance_db' && } + {backend === 'lance_db' && } {actions.length ? change(() => setAction(v))}/> : }
{actions.includes(action) && action === 'pgvector.initialize' &&
} diff --git a/mobile/app/settings/memory/connection.tsx b/mobile/app/settings/memory/connection.tsx index a5a9e5d6..4338a00a 100644 --- a/mobile/app/settings/memory/connection.tsx +++ b/mobile/app/settings/memory/connection.tsx @@ -6,7 +6,7 @@ import { memoryService } from '../../../src/core/memoryServiceNative'; import { LANCE_CLOUD_UNAVAILABLE_REASON, secretPatch, type MemoryBackend, type MemoryConnectionView, type MemoryConnectionOptions, type MemoryConnectionsView, type SecretPatch } from '../../../src/core/memoryService'; import { useStore } from '../../../src/core/store'; import { FieldRow, Row, Section, ToggleRow } from '../../../src/ui/forms'; -import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemorySecret, useMemoryTask } from '../../../src/ui/memoryUI'; +import { memoryText, confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemorySecret, useMemoryTask } from '../../../src/ui/memoryUI'; type Binding = NonNullable['bindings'][string]>; @@ -92,10 +92,10 @@ export default function MemoryConnectionScreen() { return
edit(() => setName(v))}/> - {saved && } + {saved && } {saved ? : { edit(() => setBackend(v)); if (v === 'lance_db') useRunnerLocal(); }}/>} {backend === 'lance_db' ? <> - + edit(() => { setEndpointAction('keep'); setEndpoint(''); setSecretAction('keep'); setKey(''); setReplaceOptions(false); }) }] : []), { title: t('Runner-local (explicit)'), selected: endpointAction === 'clear', onPress: () => saved @@ -107,7 +107,7 @@ export default function MemoryConnectionScreen() { {endpointAction === 'replace' && edit(() => setEndpoint(v))} autoCapitalize="none" autoCorrect={false} placeholder={backend === 'pgvector' ? 'postgresql://host/database' : 'https://…'}/>} } edit(() => setEmbedding('none')) }, ...(view?.embeddings.map(e => ({ title: e.model, selected: embedding === e.id, onPress: () => edit(() => setEmbedding(e.id)) })) ?? [])] }}/> - {backend !== 'lance_db' && ({ title: t(value), selected: insecure === value, onPress: () => value === 'allow' ? confirmMemory(t('Allow unencrypted HTTP?'), t('Plaintext and credentials may be exposed on the network. Approve only a trusted private endpoint.'), () => edit(() => setInsecure('allow'))) : edit(() => setInsecure(value as 'keep' | 'deny')) })) }}/>} + {backend !== 'lance_db' && ({ title: memoryText(value), selected: insecure === value, onPress: () => value === 'allow' ? confirmMemory(t('Allow unencrypted HTTP?'), t('Plaintext and credentials may be exposed on the network. Approve only a trusted private endpoint.'), () => edit(() => setInsecure('allow'))) : edit(() => setInsecure(value as 'keep' | 'deny')) })) }}/>}
{backend !== 'lance_db' && edit(() => { setSecretAction(v); setKey(''); })} onValue={v => edit(() => setKey(v))}/>}
diff --git a/mobile/app/settings/memory/embedding.tsx b/mobile/app/settings/memory/embedding.tsx index 8abcd6d3..6bedf461 100644 --- a/mobile/app/settings/memory/embedding.tsx +++ b/mobile/app/settings/memory/embedding.tsx @@ -5,7 +5,7 @@ import * as Crypto from 'expo-crypto'; import { memoryService } from '../../../src/core/memoryServiceNative'; import { secretPatch, type EmbeddingProfileEdit, type LocalModelConfig, type MemoryEmbeddingView, type SecretPatch } from '../../../src/core/memoryService'; import { FieldRow, Row, Section, ToggleRow } from '../../../src/ui/forms'; -import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemorySecret, useMemoryTask } from '../../../src/ui/memoryUI'; +import { memoryText, confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemorySecret, useMemoryTask } from '../../../src/ui/memoryUI'; const localStart: LocalModelConfig = { model_sha256: '', tokenizer_sha256: '', max_tokens: 512, pooling: 'mean', tensors: { input_ids: 'input_ids', attention_mask: 'attention_mask', output: 'last_hidden_state', token_type_ids: null }, add_special_tokens: true, pad_id: 0, pad_type_id: 0, pad_token: '[PAD]' }; export default function EmbeddingScreen() { useLanguage(); @@ -52,7 +52,7 @@ export default function EmbeddingScreen() { local('pad_type_id', Number(v))}/> local('pad_token', v)}/>
-
{(['input_ids', 'attention_mask', 'output', 'token_type_ids'] as const).map(k => local('tensors', { ...l.tensors, [k]: k === 'token_type_ids' ? (v || null) : v })} autoCapitalize="none" autoCorrect={false}/>)}
+
{(['input_ids', 'attention_mask', 'output', 'token_type_ids'] as const).map(k => local('tensors', { ...l.tensors, [k]: k === 'token_type_ids' ? (v || null) : v })} autoCapitalize="none" autoCorrect={false}/>)}
} {saved &&
confirmMemory(t('Remove profile?'), saved.model, () => void task.run(async () => { await memoryService.removeEmbedding(id); setDirty(false); setSaved(undefined); }), true)}/>
}
; diff --git a/mobile/app/settings/memory/index.tsx b/mobile/app/settings/memory/index.tsx index f7d2d04f..9eeac6ed 100644 --- a/mobile/app/settings/memory/index.tsx +++ b/mobile/app/settings/memory/index.tsx @@ -4,7 +4,7 @@ import { useCallback, useState } from 'react'; import { memoryService } from '../../../src/core/memoryServiceNative'; import { LANCE_CLOUD_UNAVAILABLE_REASON, type MemoryConnectionsView } from '../../../src/core/memoryService'; import { Row, Section } from '../../../src/ui/forms'; -import { MemoryForm, useMemoryTask, MemoryAction } from '../../../src/ui/memoryUI'; +import { memoryText, MemoryForm, useMemoryTask, MemoryAction } from '../../../src/ui/memoryUI'; export default function MemoryConnectionsScreen() { useLanguage(); const router = useRouter(), task = useMemoryTask(); @@ -16,7 +16,7 @@ export default function MemoryConnectionsScreen() { {view?.connections.map(c => router.push({ pathname: '/settings/memory/connection', params: { id: c.id } })}/>)} {view && !view.connections.length && } router.push('/settings/memory/connection')}/> - +
{view?.embeddings.map(e => router.push({ pathname: '/settings/memory/embedding', params: { id: e.id } })}/>)} diff --git a/mobile/app/settings/memory/local-setup.tsx b/mobile/app/settings/memory/local-setup.tsx index 04a45bb3..cd474a9d 100644 --- a/mobile/app/settings/memory/local-setup.tsx +++ b/mobile/app/settings/memory/local-setup.tsx @@ -4,7 +4,7 @@ import { memoryService } from '../../../src/core/memoryServiceNative'; import type { AssetRequest, LocalPreview, MemoryEmbeddingView } from '../../../src/core/memoryService'; import { useStore } from '../../../src/core/store'; import { FieldRow, Row, Section } from '../../../src/ui/forms'; -import { confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, useMemoryTask } from '../../../src/ui/memoryUI'; +import { memoryText, confirmMemory, MemoryAction, MemoryChoice, MemoryForm, MemoryOutput, useMemoryTask } from '../../../src/ui/memoryUI'; export default function LocalEmbeddingSetupScreen() { useLanguage(); const task = useMemoryTask(), devices = useStore(s => s.devices); @@ -28,7 +28,7 @@ export default function LocalEmbeddingSetupScreen() { ({ title: p.model, selected: p.id === profileID, onPress: () => change(() => setProfileID(p.id)) })) }}/> {!runners.length && }
- {assets.map((a, i) =>
+ {assets.map((a, i) =>
asset(i, { ...a, source: kind === 'supplied' ? { kind, path: '' } : { kind, url: '' } })}/> asset(i, { ...a, source: a.source.kind === 'supplied' ? { kind: 'supplied', path: v } : { kind: 'download', url: v } })} autoCapitalize="none" autoCorrect={false}/> asset(i, { ...a, license: v })}/> diff --git a/mobile/src/ui/memoryLocalization.test.ts b/mobile/src/ui/memoryLocalization.test.ts index 7e1aa370..40163519 100644 --- a/mobile/src/ui/memoryLocalization.test.ts +++ b/mobile/src/ui/memoryLocalization.test.ts @@ -2,10 +2,17 @@ import { afterEach, expect, test, vi } from 'vitest'; import { readFileSync, readdirSync } from 'node:fs'; import { resolve } from 'node:path'; import ts from 'typescript'; +vi.mock('expo-router', () => ({ Stack: {}, useRouter: vi.fn() })); +vi.mock('expo-router/react-navigation', () => ({ useNavigation: vi.fn(), usePreventRemove: vi.fn() })); +vi.mock('react-native', () => ({ ActivityIndicator: 'ActivityIndicator', Alert: { alert: vi.fn() }, ScrollView: 'ScrollView', Text: 'Text', View: 'View' })); +vi.mock('./forms', () => ({ FieldRow: 'FieldRow', Row: 'Row', Section: 'Section' })); +vi.mock('./navigation', () => ({ FormToolbar: 'FormToolbar' })); +vi.mock('./theme', () => ({ usePalette: vi.fn() })); vi.mock('../core/prefs', () => ({ loadPrefs: () => ({}), savePrefs: () => {} })); vi.mock('expo-localization', () => ({ getLocales: () => [{ languageCode: 'en' }] })); const { t, setAppLanguage } = await import('../i18n'); const { zh } = await import('../i18n/zh'); +const { memoryText, plaintextDisclosure } = await import('./memoryUI'); afterEach(() => setAppLanguage('en')); const disclosure = 'The selected memory endpoint and its downstream extraction, embedding, reranking or reflection models may receive plaintext outside the encrypted relay. Usage can cost money; no total-cost ceiling is established by this app. This approves only the named action, not schedules or automatic retries.'; test('consent preserves English and names scope and cost limits in Chinese', () => { @@ -21,8 +28,8 @@ test('consent preserves English and names scope and cost limits in Chinese', () }); test('memory presentation keys have Chinese translations with identical placeholders', () => { const dirs = ['app/chat-info/memory', 'app/settings/memory']; - const paths = dirs.flatMap(dir => readdirSync(resolve(dir)).filter(f => f.endsWith('.tsx')).map(f => resolve(dir, f))); - paths.push(resolve('src/ui/memoryUI.tsx')); + const paths = dirs.flatMap(dir => readdirSync(resolve(import.meta.dirname, "../..", dir)).filter(f => f.endsWith('.tsx')).map(f => resolve(import.meta.dirname, "../..", dir, f))); + paths.push(resolve(import.meta.dirname, "memoryUI.tsx")); let checked = 0; for (const path of paths) { const source = ts.createSourceFile(path, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX); @@ -39,3 +46,18 @@ test('memory presentation keys have Chinese translations with identical placehol } expect(checked).toBeGreaterThan(200); }); + +test('dynamic memory labels follow language changes and retain unknown service messages', () => { + setAppLanguage('en'); + expect(memoryText('keep')).toBe('keep'); + expect(memoryText('Choose and save a connection first.')).toBe('Choose and save a connection first.'); + expect(memoryText(plaintextDisclosure)).toBe(disclosure); + setAppLanguage('zh'); + expect(memoryText('keep')).toBe('保留'); + expect(memoryText('Choose and save a connection first.')).toBe('请先选择并保存连接。'); + expect(memoryText('plaintext_consent_required')).toBe('需要明文同意(plaintext_consent_required)'); + expect(memoryText(plaintextDisclosure)).toBe(t(disclosure)); + expect(memoryText('backend_specific_unknown_error')).toBe('backend_specific_unknown_error'); + setAppLanguage('en'); + expect(memoryText('keep')).toBe('keep'); +}); diff --git a/mobile/src/ui/memoryUI.tsx b/mobile/src/ui/memoryUI.tsx index f787bad6..8b7616fe 100644 --- a/mobile/src/ui/memoryUI.tsx +++ b/mobile/src/ui/memoryUI.tsx @@ -49,7 +49,7 @@ export function MemoryForm({ title, dirty, guardDirty = dirty, task, onSave, chi {onSave && void task.run(async () => { await onSave(); guard.finish(); })}/>} {task.busy && } - {task.error && {t(task.error)}} + {task.error && {memoryText(task.error)}} {children} ; @@ -61,7 +61,7 @@ export function MemoryAction({ title, reason, onPress, destructive = false }: { destructive?: boolean; }) { useLanguage(); - return ; + return ; } export function MemoryChoice({ title, value, values, onChange }: { title: string; @@ -70,7 +70,7 @@ export function MemoryChoice({ title, value, values, onChange onChange: (value: T) => void; }) { useLanguage(); - return ({ title: t(v), selected: v === value, onPress: () => onChange(v) })) }}/>; + return ({ title: memoryText(v), selected: v === value, onPress: () => onChange(v) })) }}/>; } export function MemorySecret({ action, value, onAction, onValue, hasSecret }: { action: SecretPatch['action']; @@ -98,3 +98,74 @@ export function confirmMemory(title: string, description: string, action: () => Alert.alert(title, description, [{ text: t('Cancel'), style: 'cancel' }, { text: destructive ? t('Confirm') : t('Continue'), style: destructive ? 'destructive' : 'default', onPress: action }]); } export const plaintextDisclosure = 'The selected memory endpoint and its downstream extraction, embedding, reranking or reflection models may receive plaintext outside the encrypted relay. Usage can cost money; no total-cost ceiling is established by this app. This approves only the named action, not schedules or automatic retries.'; + +// Keep dynamic memory labels explicit so the shared localization checker sees the +// same keys the UI resolves. Unknown service messages retain the normal fallback. +export function memoryText(key: string): string { + switch (key) { + case "Choose and save a connection first.": return t("Choose and save a connection first."); + case "LanceDB Cloud transport is unavailable until an upstream safe transport hook exists (lancedb_cloud_transport_unavailable). Credentials cannot enable it. Runner-local LanceDB is separate; no paid or local fallback.": return t("LanceDB Cloud transport is unavailable until an upstream safe transport hook exists (lancedb_cloud_transport_unavailable). Credentials cannot enable it. Runner-local LanceDB is separate; no paid or local fallback."); + case "The selected memory endpoint and its downstream extraction, embedding, reranking or reflection models may receive plaintext outside the encrypted relay. Usage can cost money; no total-cost ceiling is established by this app. This approves only the named action, not schedules or automatic retries.": return t("The selected memory endpoint and its downstream extraction, embedding, reranking or reflection models may receive plaintext outside the encrypted relay. Usage can cost money; no total-cost ceiling is established by this app. This approves only the named action, not schedules or automatic retries."); + case "allow": return t("allow"); + case "bank config": return t("bank config"); + case "bank profile": return t("bank profile"); + case "clear": return t("clear"); + case "complete_profile_replacement_requires_replace_or_clear_key": return t("complete_profile_replacement_requires_replace_or_clear_key"); + case "completed": return t("completed"); + case "configuration_not_loaded": return t("configuration_not_loaded"); + case "connection_not_found": return t("connection_not_found"); + case "connection_required": return t("connection_required"); + case "degraded": return t("degraded"); + case "delivery_unknown": return t("delivery_unknown"); + case "deny": return t("deny"); + case "directives": return t("directives"); + case "documents": return t("documents"); + case "download": return t("download"); + case "edit": return t("edit"); + case "endpoint_change_requires_replace_or_clear_key": return t("endpoint_change_requires_replace_or_clear_key"); + case "enforced_spending_policy_required": return t("enforced_spending_policy_required"); + case "false": return t("false"); + case "group_capture_requires_conversation": return t("group_capture_requires_conversation"); + case "group_consent_required": return t("group_consent_required"); + case "invalid_budget": return t("invalid_budget"); + case "invalid_capture_cap": return t("invalid_capture_cap"); + case "keep": return t("keep"); + case "local_cpu": return t("local_cpu"); + case "local_memory_not_loaded": return t("local_memory_not_loaded"); + case "max_bytes": return t("max_bytes"); + case "max_context_chars": return t("max_context_chars"); + case "max_results": return t("max_results"); + case "memory edit": return t("memory edit"); + case "memory invalidate": return t("memory invalidate"); + case "memory restore": return t("memory restore"); + case "memory_request_failed": return t("memory_request_failed"); + case "mental model history": return t("mental model history"); + case "mental models": return t("mental models"); + case "model": return t("model"); + case "name_required": return t("name_required"); + case "none": return t("none"); + case "observations": return t("observations"); + case "plaintext_consent_required": return t("plaintext_consent_required"); + case "preferences_not_loaded": return t("preferences_not_loaded"); + case "processing": return t("processing"); + case "profile_not_found": return t("profile_not_found"); + case "profile_not_loaded": return t("profile_not_loaded"); + case "queued": return t("queued"); + case "ready": return t("ready"); + case "remove": return t("remove"); + case "replace": return t("replace"); + case "resources": return t("resources"); + case "runner_and_profile_required": return t("runner_and_profile_required"); + case "runtime": return t("runtime"); + case "sessions": return t("sessions"); + case "setup_required": return t("setup_required"); + case "stale_confirmation": return t("stale_confirmation"); + case "submitted": return t("submitted"); + case "supplied": return t("supplied"); + case "tasks": return t("tasks"); + case "timeout_ms": return t("timeout_ms"); + case "tokenizer": return t("tokenizer"); + case "true": return t("true"); + default: return t(key); + } +}