Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(remote-agent): preserve limit overrides and keep idle runs alive
fmfsaisaibe08631e7c3a
diff --git a/apps/desktop/src/main/device-link/__tests__/providerShareManagement.test.ts b/apps/desktop/src/main/device-link/__tests__/providerShareManagement.test.tsindex d9b991239f..576abb88ef 100644--- a/apps/desktop/src/main/device-link/__tests__/providerShareManagement.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/providerShareManagement.test.ts@@ -53,7 +53,7 @@ vi.mock('../providerShareGuest.js', () => ({ startProviderShareGuest: vi.fn(), svi.mock('../providerShareGuestPrefs.js', () => ({ configureProviderShareGuestPrefs: vi.fn(), invalidateProviderShareGuestPrefsCache: vi.fn() }));vi.mock('../providerShareGuestPrefsIpc.js', () => ({ setProviderShareCredentialConsentFromIpc: vi.fn() }));-import { executeProviderShareManagementCommand, registerProviderShareIpc, startProviderShareRuntime, stopProviderShareRuntime } from '../providerShareRuntime';+import { executeProviderShareManagementCommand, parseProviderShareCommand, registerProviderShareIpc, startProviderShareRuntime, stopProviderShareRuntime } from '../providerShareRuntime';const createLink: ProviderShareManagementCommand = { action: 'create-link', providerId: 'anthropic' };const LINK_ID = 'a'.repeat(64);@@ -80,6 +80,15 @@ beforeEach(() => {afterEach(() => stopProviderShareRuntime());+describe('remote task limit management payloads', () => {+ it.each([{ perDevice: 24 }, { total: 80 }, { perDevice: 16, total: 64 }])('preserves only supplied fields in %j', limits => {+ expect(parseProviderShareCommand({ action: 'set-run-limits', limits })).toEqual({ action: 'set-run-limits', limits });+ });+ it.each([{}, { unknown: 1 }, { perDevice: '16' }, { perDevice: 0 }, { total: 1001 }, { total: 1.5 }])('rejects malformed patches %j', limits => {+ expect(() => parseProviderShareCommand({ action: 'set-run-limits', limits })).toThrow('INVALID_PARAMS');+ });+});+describe('same-account share management during account transitions', () => {it.each([createLink, ...mutations,diff --git a/apps/desktop/src/main/device-link/providerShareRuntime.ts b/apps/desktop/src/main/device-link/providerShareRuntime.tsindex 0a9046b9d3..290be17391 100644--- a/apps/desktop/src/main/device-link/providerShareRuntime.ts+++ b/apps/desktop/src/main/device-link/providerShareRuntime.ts@@ -1,4 +1,4 @@-import { isRemoteAgentLimits } from '../../shared/remoteAgentLimits.js';+import { isRemoteAgentLimitsPatch } from '../../shared/remoteAgentLimits.js';import { readRemoteAgentLimitsState, saveRemoteAgentLimits } from '../remote-agent/host/limitsStore.js';import { remoteAgentLimitUsage } from './dispatch.js';/**@@ -335,8 +335,8 @@ export function parseProviderShareCommand(raw: unknown): ProviderShareCommand {case 'reset-run-limits':return { action: value.action };case 'set-run-limits':- if (!isRemoteAgentLimits(value.limits)) throwIpcError('INVALID_PARAMS', 'Invalid remote task limits');- return { action: value.action, limits: { perDevice: value.limits.perDevice, total: value.limits.total } };+ if (!isRemoteAgentLimitsPatch(value.limits)) throwIpcError('INVALID_PARAMS', 'Invalid remote task limits');+ return { action: value.action, limits: { ...value.limits } };case 'owned':return { action: 'owned', range: usageRange(value.range) };case 'own-usage':diff --git a/apps/desktop/src/main/remote-agent/__tests__/limitsStore.test.ts b/apps/desktop/src/main/remote-agent/__tests__/limitsStore.test.tsindex 184c359a98..8009ccfbf9 100644--- a/apps/desktop/src/main/remote-agent/__tests__/limitsStore.test.ts+++ b/apps/desktop/src/main/remote-agent/__tests__/limitsStore.test.ts@@ -20,6 +20,29 @@ beforeEach(async () => {afterEach(async () => { await fs.rm(state.root, { recursive: true, force: true }); });describe('remote task limit overrides', () => {+ it('only persists supplied fields and preserves earlier explicit choices', async () => {+ await saveRemoteAgentLimits({ perDevice: 24 });+ expect(readRemoteAgentLimitsState()).toMatchObject({+ value: { perDevice: 24, total: 64 }, customizedKeys: ['perDevice'],+ });+ expect(JSON.parse(await fs.readFile(path.join(state.root, 'a', 'remote-agent-limits.json'), 'utf8'))).toEqual({ perDevice: 24 });+ await saveRemoteAgentLimits({ total: 80 });+ await saveRemoteAgentLimits({ perDevice: 16 });+ expect(readRemoteAgentLimitsState()).toMatchObject({+ value: { perDevice: 16, total: 80 }, customizedKeys: ['perDevice', 'total'],+ });+ await expect(saveRemoteAgentLimits({ total: 8 })).rejects.toThrow('INVALID_PARAMS');+ expect(readRemoteAgentLimitsState().value).toEqual({ perDevice: 16, total: 80 });+ });++ it('validates concurrent partial updates against the value inside the write lock', async () => {+ await saveRemoteAgentLimits({ perDevice: 16, total: 64 });+ const results = await Promise.allSettled([+ saveRemoteAgentLimits({ perDevice: 60 }), saveRemoteAgentLimits({ total: 32 }),+ ]);+ expect(results.filter(result => result.status === 'rejected')).toHaveLength(1);+ expect(isRemoteAgentLimits(readRemoteAgentLimitsState().value)).toBe(true);+ });it('keeps explicit defaults, isolates accounts, and resets by deleting overrides', async () => {expect(readRemoteAgentLimitsState().isCustomized).toBe(false);await saveRemoteAgentLimits({ perDevice: 16, total: 64 });diff --git a/apps/desktop/src/main/remote-agent/__tests__/poll.test.ts b/apps/desktop/src/main/remote-agent/__tests__/poll.test.tsindex c2c28651ec..d64e7e2a5e 100644--- a/apps/desktop/src/main/remote-agent/__tests__/poll.test.ts+++ b/apps/desktop/src/main/remote-agent/__tests__/poll.test.ts@@ -3,11 +3,12 @@*/import { randomUUID } from 'node:crypto';-import { REMOTE_AGENT_READ_MAX_BYTES, type RemoteAgentErrorInfo } from '@cindy/device-link';+import { REMOTE_AGENT_MAX_POLL_RUNS, REMOTE_AGENT_READ_MAX_BYTES, REMOTE_AGENT_READ_WAIT_MS, type RemoteAgentErrorInfo } from '@cindy/device-link';import { afterEach, describe, expect, it, vi } from 'vitest';import { RemoteAgentPoller, type PolledRun } from '../controller/poller';import { EventLog } from '../eventLog';+import { REMOTE_AGENT_HOST_IDLE_MS } from '../host/runHost';interface FakeRun {log: EventLog;@@ -112,6 +113,38 @@ afterEach(() => {});describe('multiplexed poll', () => {+ it.each([130, 1000])('refreshes all %i idle runs before host expiry with at most two polls', async count => {+ vi.useFakeTimers();+ const host = fakeHost(REMOTE_AGENT_READ_WAIT_MS);+ const lastRead = new Map<string, number>();+ let inflight = 0;+ let peak = 0;+ const poller = new RemoteAgentPoller(async args => {+ const request = args[0] as { runs: Array<{ runId: string }> };+ expect(request.runs.length).toBeLessThanOrEqual(REMOTE_AGENT_MAX_POLL_RUNS);+ request.runs.forEach(({ runId }) => lastRead.set(runId, Date.now()));+ peak = Math.max(peak, ++inflight);+ try { return await host.invoke(args); } finally { inflight -= 1; }+ });+ const sinks = Array.from({ length: count }, (_, i) => collector(`idle-${i}`));+ for (const sink of sinks) {+ host.add(sink.run.runId);+ lastRead.set(sink.run.runId, Date.now());+ poller.register(sink.run);+ }+ try {+ // 没有任何事件,host 每次都挂满 10 秒;连续检查两个回收周期。+ for (let elapsed = 0; elapsed < REMOTE_AGENT_HOST_IDLE_MS * 2; elapsed += 5_000) {+ await vi.advanceTimersByTimeAsync(5_000);+ expect(Math.max(...[...lastRead.values()].map(at => Date.now() - at))).toBeLessThan(REMOTE_AGENT_HOST_IDLE_MS);+ }+ expect(peak).toBeLessThanOrEqual(2);+ expect(sinks.every(sink => sink.lost === null)).toBe(true);+ } finally {+ sinks.forEach(sink => poller.unregister(sink.run.runId));+ await vi.advanceTimersByTimeAsync(REMOTE_AGENT_READ_WAIT_MS);+ }+ });it('keeps pulling a run registered during a long wait, without waiting for the old poll to time out', async () => {// 被控端照实挂满等待时间:旧的长等待只覆盖第一个任务。const host = fakeHost(10_000);diff --git a/apps/desktop/src/main/remote-agent/controller/poller.ts b/apps/desktop/src/main/remote-agent/controller/poller.tsindex 761eaf1398..cb22a60676 100644--- a/apps/desktop/src/main/remote-agent/controller/poller.ts+++ b/apps/desktop/src/main/remote-agent/controller/poller.ts@@ -1,9 +1,9 @@/*** 远程 Agent 事件拉取(控制端,每台运行 Agent 的电脑一个)。*- * 同一台电脑上的全部任务共用一个 `poll`:一次带上每个任务的游标,对方没有新数据时挂起最多- * READ_WAIT_MS。任务再多也只占设备互联一个长等待;新任务登记时另发一个覆盖全部任务的 poll,- * 同时在途的 poll 不超过两个。两个 poll 返回的数据可能重叠,按 from 去重,游标只前进不后退。+ * 同一台电脑上的全部任务共用一个拉取器:每个 `poll` 最多携带 64 个任务的游标,按整批轮转,+ * 对方没有新数据时挂起最多 READ_WAIT_MS。新任务登记时可另发一个 poll,同时在途最多两个。+ * 两个 poll 返回的数据可能重叠,按 from 去重,游标只前进不后退。** 链路抖动:poll 按游标幂等,可恢复的错误退避后重拉;对方长时间不可达时结束全部任务。*/@@ -110,8 +110,9 @@ export class RemoteAgentPoller {private snapshot(): Array<{ runId: string; cursor: number }> {const all = [...this.entries.values()].map((entry) => ({ runId: entry.run.runId, cursor: entry.cursor }));if (all.length <= REMOTE_AGENT_MAX_POLL_RUNS) return all;- // 超出单次上限时轮流取(对方每台控制端的任务数远低于这个上限,正常走不到)。- const start = this.rotation++ % all.length;+ // 按整批推进,避免大量空闲任务在下次被拉取前超过 host 的存活期限。+ const start = this.rotation % all.length;+ this.rotation = (start + REMOTE_AGENT_MAX_POLL_RUNS) % all.length;this.needFresh = true;return [...all.slice(start), ...all.slice(0, start)].slice(0, REMOTE_AGENT_MAX_POLL_RUNS);}diff --git a/apps/desktop/src/main/remote-agent/host/limitsStore.ts b/apps/desktop/src/main/remote-agent/host/limitsStore.tsindex 9319d9f098..9dc696d366 100644--- a/apps/desktop/src/main/remote-agent/host/limitsStore.ts+++ b/apps/desktop/src/main/remote-agent/host/limitsStore.ts@@ -3,7 +3,7 @@ import { createLogger } from '../../logger.js';import { createOverrideSettingsFile } from '../../maker-host/override-settings-file.js';import { captureProviderManagementScope } from '../../provider-group/managementScope.js';import { throwIpcError } from '../../utils/ipcValidate.js';-import { DEFAULT_REMOTE_AGENT_LIMITS, isRemoteAgentLimits, type RemoteAgentLimits } from '../../../shared/remoteAgentLimits.js';+import { DEFAULT_REMOTE_AGENT_LIMITS, isRemoteAgentLimits, isRemoteAgentLimitsPatch, type RemoteAgentLimits } from '../../../shared/remoteAgentLimits.js';const store = createOverrideSettingsFile<RemoteAgentLimits>({filePath: () => ownerScopedUserDataPath('remote-agent-limits.json'),@@ -21,13 +21,16 @@ export function readRemoteAgentLimitsState() {return store.readState();}-export async function saveRemoteAgentLimits(value: RemoteAgentLimits | null): Promise<void> {+export async function saveRemoteAgentLimits(value: Partial<RemoteAgentLimits> | null): Promise<void> {const assertCurrent = captureProviderManagementScope();if (value === null) await store.resetAtomic();else {- if (!isRemoteAgentLimits(value)) throwIpcError('INVALID_PARAMS', 'Invalid remote task limits');+ if (!isRemoteAgentLimitsPatch(value)) throwIpcError('INVALID_PARAMS', 'Invalid remote task limits');// 显式保存默认值也是用户选择;恢复默认才删除 overrides。- await store.writePatchAtomic(value, { preserveDefaults: true });+ await store.updateAtomic(current => {+ if (!isRemoteAgentLimits({ ...current.value, ...value })) throwIpcError('INVALID_PARAMS', 'Invalid remote task limits');+ return value;+ }, { preserveDefaults: true });}assertCurrent();}diff --git a/apps/desktop/src/renderer/features/provider-share/RemoteAgentLimitsSection.tsx b/apps/desktop/src/renderer/features/provider-share/RemoteAgentLimitsSection.tsxindex c8e912e956..d8e726377d 100644--- a/apps/desktop/src/renderer/features/provider-share/RemoteAgentLimitsSection.tsx+++ b/apps/desktop/src/renderer/features/provider-share/RemoteAgentLimitsSection.tsx@@ -13,15 +13,17 @@ import { providerManagementErrorKey, providerShareManagementCommand } from '../pexport function RemoteAgentLimitsSection({ deviceId }: { deviceId?: string }) {const { t } = useTranslation();const [view, setView] = useState<RemoteAgentLimitsView | null>(null);- const [draft, setDraft] = useState<{ perDevice: string; total: string } | null>(null);+ const [draft, setDraft] = useState<Partial<{ perDevice: string; total: string }> | null>(null);const [errorKey, setErrorKey] = useState<string | null>(null);const [busy, setBusy] = useState(false);const saving = useRef(false);+ const reading = useRef<number | null>(null);const sequence = useRef(0);const load = useCallback(async () => {- if (saving.current) return;+ if (saving.current || reading.current !== null) return;const seq = ++sequence.current;+ reading.current = seq;const owner = getDataOwnerGeneration();try {const next = await providerShareManagementCommand({ action: 'get-run-limits' }, deviceId);@@ -31,6 +33,8 @@ export function RemoteAgentLimitsSection({ deviceId }: { deviceId?: string }) {} catch (error) {if (seq !== sequence.current || !isDataOwnerGenerationCurrent(owner)) return;setErrorKey(providerManagementErrorKey(error, Boolean(deviceId)));+ } finally {+ if (reading.current === seq) reading.current = null;}}, [deviceId]);@@ -39,13 +43,14 @@ export function RemoteAgentLimitsSection({ deviceId }: { deviceId?: string }) {const timer = window.setInterval(() => {if (document.visibilityState !== 'hidden') void load();}, 5_000);- return () => { sequence.current += 1; window.clearInterval(timer); };+ return () => { sequence.current += 1; reading.current = null; window.clearInterval(timer); };}, [load]);- const values = draft ?? { perDevice: String(view?.value.perDevice ?? ''), total: String(view?.value.total ?? '') };+ const values = { perDevice: String(view?.value.perDevice ?? ''), total: String(view?.value.total ?? ''), ...draft };const limits = { perDevice: Number(values.perDevice), total: Number(values.total) };const valid = isRemoteAgentLimits(limits);- const changed = view && (limits.perDevice !== view.value.perDevice || limits.total !== view.value.total);+ const changed = view && (['perDevice', 'total'] as const).some(key =>+ draft?.[key] !== undefined && (limits[key] !== view.value[key] || !view.customizedKeys.includes(key)));const save = async (reset: boolean) => {if (saving.current || (!reset && !valid)) return;@@ -55,7 +60,10 @@ export function RemoteAgentLimitsSection({ deviceId }: { deviceId?: string }) {const owner = getDataOwnerGeneration();try {const next = await providerShareManagementCommand(reset- ? { action: 'reset-run-limits' } : { action: 'set-run-limits', limits }, deviceId);+ ? { action: 'reset-run-limits' } : { action: 'set-run-limits', limits: {+ ...(draft?.perDevice !== undefined ? { perDevice: limits.perDevice } : {}),+ ...(draft?.total !== undefined ? { total: limits.total } : {}),+ } }, deviceId);if (seq !== sequence.current || !isDataOwnerGenerationCurrent(owner)) return;setView(next);setDraft(null);@@ -86,7 +94,7 @@ export function RemoteAgentLimitsSection({ deviceId }: { deviceId?: string }) {<FormField key={key} label={t(`providerShare.runLimits.${key}`)}>{control => <Input {...control} type="number" min={1} max={REMOTE_AGENT_LIMIT_MAX} step={1}disabled={busy || Boolean(errorKey)} value={values[key]} data-testid={`remote-agent-limit-${key}`}- onChange={value => setDraft({ ...values, [key]: value })} />}+ onChange={value => setDraft(previous => ({ ...previous, [key]: value }))} />}</FormField>))}</div>diff --git a/apps/desktop/src/renderer/features/provider-share/__tests__/RemoteAgentLimitsSection.test.tsx b/apps/desktop/src/renderer/features/provider-share/__tests__/RemoteAgentLimitsSection.test.tsxindex 8f7026c239..1816cbf41e 100644--- a/apps/desktop/src/renderer/features/provider-share/__tests__/RemoteAgentLimitsSection.test.tsx+++ b/apps/desktop/src/renderer/features/provider-share/__tests__/RemoteAgentLimitsSection.test.tsx@@ -27,6 +27,32 @@ beforeEach(() => {afterEach(() => { cleanup(); vi.useRealTimers(); });describe('RemoteAgentLimitsSection', () => {+ it('saves only edited fields, including an explicitly chosen default', async () => {+ render(<RemoteAgentLimitsSection />);+ await waitFor(() => expect(input('perDevice').value).toBe('16'));+ fireEvent.change(input('perDevice'), { target: { value: '32' } });+ fireEvent.click(button('save'));+ await waitFor(() => expect(command).toHaveBeenLastCalledWith({ action: 'set-run-limits', limits: { perDevice: 32 } }, undefined));+ await waitFor(() => expect(button('save').disabled).toBe(true));+ fireEvent.change(input('perDevice'), { target: { value: '24' } });+ fireEvent.change(input('perDevice'), { target: { value: '16' } });+ expect(button('save').disabled).toBe(false);+ fireEvent.click(button('save'));+ await waitFor(() => expect(command).toHaveBeenLastCalledWith({ action: 'set-run-limits', limits: { perDevice: 16 } }, undefined));+ });++ it('accepts slow reads instead of superseding every response with the next poll', async () => {+ vi.useFakeTimers();+ command.mockImplementation(() => new Promise(resolve => setTimeout(() => resolve(view()), 6_000)));+ render(<RemoteAgentLimitsSection deviceId="slow-computer" />);+ await act(async () => { await vi.advanceTimersByTimeAsync(5_000); });+ expect(command).toHaveBeenCalledTimes(1);+ await act(async () => { await vi.advanceTimersByTimeAsync(1_000); });+ expect(input('perDevice').value).toBe('16');+ await act(async () => { await vi.advanceTimersByTimeAsync(10_000); });+ expect(command).toHaveBeenCalledTimes(2);+ expect(input('total').value).toBe('64');+ });it('validates both limits, saves on the selected computer and resets its overrides', async () => {render(<RemoteAgentLimitsSection deviceId="provider-computer" />);await waitFor(() => expect(input('perDevice').value).toBe('16'));@@ -54,7 +80,7 @@ describe('RemoteAgentLimitsSection', () => {await act(async () => { await vi.advanceTimersByTimeAsync(5_000); });expect(command).toHaveBeenCalledTimes(2);expect(input('perDevice').value).toBe('32');- expect(input('total').value).toBe('64');+ expect(input('total').value).toBe('80');});it('does not show an old account response after an account switch', async () => {diff --git a/apps/desktop/src/shared/providerShare.ts b/apps/desktop/src/shared/providerShare.tsindex 65549decca..a7268f7217 100644--- a/apps/desktop/src/shared/providerShare.ts+++ b/apps/desktop/src/shared/providerShare.ts@@ -160,7 +160,7 @@ export interface ProviderShareSettledEvent {export type ProviderShareCommand =| { action: 'get-run-limits' }| { action: 'reset-run-limits' }- | { action: 'set-run-limits'; limits: RemoteAgentLimits }+ | { action: 'set-run-limits'; limits: Partial<RemoteAgentLimits> }| { action: 'owned'; range: ProviderShareUsageRange }/** 这个供应商按使用方的用量(本机与我的其他电脑)。不依赖分享服务。 */| { action: 'own-usage'; providerId: string; range: ProviderShareUsageRange }diff --git a/apps/desktop/src/shared/remoteAgentLimits.ts b/apps/desktop/src/shared/remoteAgentLimits.tsindex 8c11c57d77..f78135dca1 100644--- a/apps/desktop/src/shared/remoteAgentLimits.ts+++ b/apps/desktop/src/shared/remoteAgentLimits.ts@@ -15,6 +15,15 @@ export function isRemoteAgentLimits(value: unknown): value is RemoteAgentLimits&& v.perDevice >= 1 && v.perDevice <= v.total && v.total <= REMOTE_AGENT_LIMIT_MAX;}+/** 仅接收用户编辑过的字段;合并后的大小关系由写入端在锁内校验。 */+export function isRemoteAgentLimitsPatch(value: unknown): value is Partial<RemoteAgentLimits> {+ if (!value || typeof value !== 'object' || Array.isArray(value)) return false;+ const entries = Object.entries(value);+ return entries.length > 0 && entries.every(([key, limit]) =>+ (key === 'perDevice' || key === 'total')+ && Number.isInteger(limit) && limit >= 1 && limit <= REMOTE_AGENT_LIMIT_MAX);+}+export interface RemoteAgentLimitUsage {total: number;devices: number;diff --git a/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsx b/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsxindex 2e495fbbf1..defc972cbb 100644--- a/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsx+++ b/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsx@@ -109,6 +109,17 @@ describe.each(SUPPORTED_LOCALES)('mobile errors in %s', locale => {describe.each(SUPPORTED_LOCALES)('known mobile remote errors in %s', locale => {+ it.each(['DEVICE_LIMIT', 'TOTAL_LIMIT'])('recognizes wrapped %s errors from the remote computer', async reason => {+ await i18n.changeLanguage(locale);+ const message = `LAZY_CREATE_FAILED: [REMOTE_AGENT_BUSY] [${reason}] upstream diagnostic`;+ const key = `session.remoteError.REMOTE_AGENT_${reason}`;+ expect(unclassifiedAgentErrorI18nKey(message)).toBe(key);+ const [normalized] = normalizeRemoteMessages([row(message)]);+ expect(normalized.body).toBe(i18n.t(key));+ expect(normalized.body).not.toContain('upstream diagnostic');+ expect(unclassifiedAgentErrorI18nKey('[REMOTE_AGENT_BUSY] too many tasks')).toBe('session.remoteError.REMOTE_AGENT_BUSY');+ });+it('has every desktop bracket-code translation without relying on fallback languages', async () => {await i18n.changeLanguage(locale);const desktop = JSON.parse(readFileSync(`../desktop/src/renderer/i18n/locales/${locale}/common.json`, 'utf8'));diff --git a/apps/mobile/src/i18n/locales/en/session.json b/apps/mobile/src/i18n/locales/en/session.jsonindex 58ed4b858d..513052915b 100644--- a/apps/mobile/src/i18n/locales/en/session.json+++ b/apps/mobile/src/i18n/locales/en/session.json@@ -572,6 +572,8 @@"REMOTE_AGENT_EXPIRED": "This session already ended on the computer running the Agent. Send your message again.","REMOTE_AGENT_NOT_FOUND": "This session already ended on the computer running the Agent. Send your message again.","REMOTE_AGENT_BUSY": "Too many sessions are running on the other computer. End some of them and try again.",+ "REMOTE_AGENT_DEVICE_LIMIT": "This device has reached its remote session limit. Archive unused sessions or ask the provider owner to raise the limit in Remote & sharing.",+ "REMOTE_AGENT_TOTAL_LIMIT": "The provider computer has reached its total remote session limit. Ask the owner to release unused sessions or raise the limit in Remote & sharing.","REMOTE_AGENT_UNSUPPORTED": "This Agent isn't available on the other computer. Install or sign in to it there, or pick another Agent.","REMOTE_AGENT_INVALID": "Something went wrong talking to the computer running the Agent. Try again; if it keeps happening, update Cindy on both computers.","REMOTE_AGENT_PROVIDER_NOT_ALLOWED": "That computer hasn’t allowed remote use of this provider. On that computer, turn on “Allow remote use” in Settings → Providers, or pick another model.",diff --git a/apps/mobile/src/i18n/locales/ja/session.json b/apps/mobile/src/i18n/locales/ja/session.jsonindex 55c05775ac..674ac7772c 100644--- a/apps/mobile/src/i18n/locales/ja/session.json+++ b/apps/mobile/src/i18n/locales/ja/session.json@@ -572,6 +572,8 @@"REMOTE_AGENT_EXPIRED": "このセッションは Agent を実行しているパソコンですでに終了しています。もう一度送信してください。","REMOTE_AGENT_NOT_FOUND": "このセッションは Agent を実行しているパソコンですでに終了しています。もう一度送信してください。","REMOTE_AGENT_BUSY": "相手のパソコンで実行中のセッションが多すぎます。いくつか終了してからもう一度お試しください。",+ "REMOTE_AGENT_DEVICE_LIMIT": "このデバイスのリモートセッション数が上限に達しました。不要なセッションをアーカイブするか、提供者に「リモートと共有」で上限の変更を依頼してください。",+ "REMOTE_AGENT_TOTAL_LIMIT": "提供者のパソコンのリモートセッション総数が上限に達しました。提供者に不要なセッションの解放、または「リモートと共有」での上限変更を依頼してください。","REMOTE_AGENT_UNSUPPORTED": "相手のパソコンではこの Agent を使えません。そのパソコンでインストールまたはサインインするか、別の Agent を選んでください。","REMOTE_AGENT_INVALID": "Agent を実行しているパソコンとの通信でエラーが発生しました。もう一度お試しください。続く場合は両方のパソコンの Cindy を最新版に更新してください。","REMOTE_AGENT_PROVIDER_NOT_ALLOWED": "そのパソコンでは、このプロバイダーのリモート利用が許可されていません。そのパソコンの「設定 → モデルプロバイダー」で「リモート利用を許可」をオンにするか、別のモデルを選んでください。",diff --git a/apps/mobile/src/i18n/locales/ko/session.json b/apps/mobile/src/i18n/locales/ko/session.jsonindex c202b3a8f4..6303bf83db 100644--- a/apps/mobile/src/i18n/locales/ko/session.json+++ b/apps/mobile/src/i18n/locales/ko/session.json@@ -568,6 +568,8 @@"REMOTE_AGENT_EXPIRED": "이 세션은 Agent를 실행하는 컴퓨터에서 이미 종료되었습니다. 다시 보내 주세요.","REMOTE_AGENT_NOT_FOUND": "이 세션은 Agent를 실행하는 컴퓨터에서 이미 종료되었습니다. 다시 보내 주세요.","REMOTE_AGENT_BUSY": "상대 컴퓨터에서 실행 중인 세션이 너무 많습니다. 일부를 종료한 뒤 다시 시도하세요.",+ "REMOTE_AGENT_DEVICE_LIMIT": "이 기기의 원격 세션 수가 한도에 도달했습니다. 사용하지 않는 세션을 보관하거나 제공자에게 원격 및 공유에서 한도를 높여 달라고 요청하세요.",+ "REMOTE_AGENT_TOTAL_LIMIT": "제공자 컴퓨터의 전체 원격 세션 수가 한도에 도달했습니다. 제공자에게 불필요한 세션을 해제하거나 원격 및 공유에서 한도를 높여 달라고 요청하세요.","REMOTE_AGENT_UNSUPPORTED": "상대 컴퓨터에서는 이 Agent를 사용할 수 없습니다. 그 컴퓨터에서 설치하거나 로그인한 뒤 다시 시도하거나, 다른 Agent를 선택하세요.","REMOTE_AGENT_INVALID": "Agent를 실행하는 컴퓨터와 통신하는 중 오류가 발생했습니다. 다시 시도하고, 계속되면 두 컴퓨터의 Cindy를 모두 최신 버전으로 업데이트하세요.","REMOTE_AGENT_PROVIDER_NOT_ALLOWED": "그 컴퓨터에서 이 제공자의 원격 사용을 허용하지 않았습니다. 그 컴퓨터의 설정 → 모델 제공자에서 원격 사용 허용을 켜거나 다른 모델을 선택하세요.",diff --git a/apps/mobile/src/i18n/locales/zh-CN/session.json b/apps/mobile/src/i18n/locales/zh-CN/session.jsonindex 0226e1cc10..201946fd10 100644--- a/apps/mobile/src/i18n/locales/zh-CN/session.json+++ b/apps/mobile/src/i18n/locales/zh-CN/session.json@@ -568,6 +568,8 @@"REMOTE_AGENT_EXPIRED": "这个任务在运行 Agent 的电脑上已经结束。请重新发送。","REMOTE_AGENT_NOT_FOUND": "这个任务在运行 Agent 的电脑上已经结束。请重新发送。","REMOTE_AGENT_BUSY": "那台电脑上同时运行的任务太多。先结束一些任务后再试。",+ "REMOTE_AGENT_DEVICE_LIMIT": "这台设备保留的远程任务数已达上限。可归档暂时不用的任务,或请远程电脑的主人在“远程与分享”中提高上限。",+ "REMOTE_AGENT_TOTAL_LIMIT": "远程电脑保留的任务总数已达上限。请那台电脑的主人释放暂时不用的任务,或在“远程与分享”中提高上限。","REMOTE_AGENT_UNSUPPORTED": "那台电脑上这个 Agent 不可用。在那台电脑上安装或登录后再试,或换一个 Agent。","REMOTE_AGENT_INVALID": "和运行 Agent 的电脑通信出错。请重试;如果一直出现,请把两台电脑上的 Cindy 都更新到最新版。","REMOTE_AGENT_PROVIDER_NOT_ALLOWED": "那台电脑没有允许远程调用这个供应商。请在那台电脑的「设置 → 模型供应商」里打开「允许被远程调用」,或换一个模型。",diff --git a/apps/mobile/src/i18n/locales/zh-TW/session.json b/apps/mobile/src/i18n/locales/zh-TW/session.jsonindex f12f61956c..eda621dfca 100644--- a/apps/mobile/src/i18n/locales/zh-TW/session.json+++ b/apps/mobile/src/i18n/locales/zh-TW/session.json@@ -572,6 +572,8 @@"REMOTE_AGENT_EXPIRED": "這個任務在執行 Agent 的電腦上已經結束。請重新傳送。","REMOTE_AGENT_NOT_FOUND": "這個任務在執行 Agent 的電腦上已經結束。請重新傳送。","REMOTE_AGENT_BUSY": "那臺電腦上同時執行的任務太多。先結束一些任務後再試。",+ "REMOTE_AGENT_DEVICE_LIMIT": "這台裝置保留的遠端任務數已達上限。可封存暫時不用的任務,或請遠端電腦的主人在「遠端與分享」中提高上限。",+ "REMOTE_AGENT_TOTAL_LIMIT": "遠端電腦保留的任務總數已達上限。請那台電腦的主人釋放暫時不用的任務,或在「遠端與分享」中提高上限。","REMOTE_AGENT_UNSUPPORTED": "那臺電腦上這個 Agent 無法使用。在那臺電腦上安裝或登入後再試,或換一個 Agent。","REMOTE_AGENT_INVALID": "與執行 Agent 的電腦通訊時出錯。請重試;如果持續出現,請把兩臺電腦上的 Cindy 都更新到最新版。","REMOTE_AGENT_PROVIDER_NOT_ALLOWED": "那臺電腦沒有允許遠端呼叫這個供應商。請在那臺電腦的「設定 → 模型供應商」裡開啟「允許遠端呼叫」,或換一個模型。",diff --git a/apps/mobile/src/session/agentErrorI18n.ts b/apps/mobile/src/session/agentErrorI18n.tsindex ec3eb5b656..70ad2fb0a8 100644--- a/apps/mobile/src/session/agentErrorI18n.ts+++ b/apps/mobile/src/session/agentErrorI18n.ts@@ -70,6 +70,8 @@ export function autoReviewUnavailableGuidanceCode(sessionSource: unknown): strin/** Unknown provider messages stay in diagnostic details, never in the localized summary. */export function unclassifiedAgentErrorI18nKey(message: string, sessionSource?: unknown): string {+ const limitReason = /\[REMOTE_AGENT_BUSY\] \[(DEVICE_LIMIT|TOTAL_LIMIT)\]/.exec(message)?.[1];+ if (limitReason) return `session.remoteError.REMOTE_AGENT_${limitReason}`;const parsed = parseAgentErrorCode(message);const code = parsed?.code === 'AUTO_REVIEW_UNAVAILABLE'? autoReviewUnavailableGuidanceCode(sessionSource)diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex abc361270e..78c43d8c97 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -1289,6 +1289,8 @@ B 上的 Worker 是一条普通任务,`sessions.orca_remote_lead`(migration 01- **提供方远程任务数量设置**:沿用 `maker:remote-agent:v1`,不加必填字段;`caps.maxRuns` 返回当前单设备上限(1~1000,旧解析器可读)。超限仍回 `REMOTE_AGENT_BUSY`,message 用 `[DEVICE_LIMIT]` / `[TOTAL_LIMIT]` 区分原因,旧端继续按忙碌处理。本机 `provider-share:command` 与同账号管理通道增加 `get-run-limits` / `set-run-limits` / `reset-run-limits`;+ `set-run-limits.limits` 只包含用户编辑过的 `perDevice` / `total`,写入端在锁内合并当前值并验证大小关系;+ 未编辑字段不落盘,继续跟随默认值或此前显式设置。两个字段同时提供仍兼容。不向受邀者开放。旧端不认识这些管理命令时显示需要更新,不回退伪造成功。设置只影响新增实例,不中断存量。大额度下控制端仍按每批最多 64 个任务轮转 poll,不提高 wire 上限。- **caps 新增可选 `guestRelay: true`**(`RemoteAgentCaps`):被控端能按受邀者隔离运行(供应商级授权与受邀者出站边界都已接上)。diff --git a/docs/dev-rules/remote-and-mobile-adaptation.md b/docs/dev-rules/remote-and-mobile-adaptation.mdindex 614c5fed72..a669ca1ce4 100644--- a/docs/dev-rules/remote-and-mobile-adaptation.md+++ b/docs/dev-rules/remote-and-mobile-adaptation.md@@ -118,9 +118,11 @@ relay 以 close 1013 `inbound backpressure` 主动断连,此时任何「立即其余 op 不自动重放。2. **动作层级**:与故障同半径——只影响这台被控端的拉取器,不重建 link、不断开 relay、不影响其它被控端和普通远控请求。被控端侧对无人拉取的任务按任务超时(3 分钟)收尾,不波及其它任务。-3. **多 peer**:被控端按 `(控制端, runId)` 隔离任务;每个控制端最多 16 个任务。控制端每台被控端一个- 拉取器,全部任务共用一个挂起最多 10s 的 `poll`,同时在途最多两个,任务再多也不占满共享的- 12 个在途配额;被控端连续立即返回空结果时控制端放慢到 1s 一次,防止空转。2 台控制端共享被控端、+3. **多 peer**:被控端按 `(控制端, runId)` 隔离任务;默认每台控制设备最多 16 个任务、整机最多 64 个,+ 主人可在「远程与分享」调整(最多 1000)。控制端每台被控端一个拉取器,每次 `poll` 最多带 64 个任务,+ 按整批轮转,挂起最多 10s,同时在途最多两个,任务再多也不占满共享的 12 个在途配额;+ `poll.test.ts` 用 130 / 1000 个空闲任务验证拉取间隔始终短于 3 分钟的回收期限。+ 被控端连续立即返回空结果时控制端放慢到 1s 一次,防止空转。2 台控制端共享被控端、其中一台静默的回归仍需在双实例实机验证中补测。**托管 Codex 的关键线程 RPC**(#5764):Agent 所在电脑上的 Codex 经 exec-server 逐个读任务所在电脑的