Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(scheduler): check remote explicit engine support
Yuewei-LL9df735b7cbab
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.tsindex 1d9ac96cf5..d81e317c65 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts@@ -27,6 +27,38 @@ function setup(invoke = vi.fn<Invoke>(async () => ({ ok: true, result: [] }))) {}describe('desktop scheduler cross-device transport', () => {+ // PR #6830 / discussion_r4385260097, unit: the existing route/null tests omit+ // explicit engine updates with inherited location. An old host silently drops+ // modelAgentKind; the public adapter must reject before issuing that write.+ it.each([+ { capabilities: {}, patch: { modelAgentKind: 'codex', model: 'gpt-5' }, supported: false },+ { capabilities: { supportsScheduleModelSelection: false }, patch: { modelAgentKind: 'codex', model: 'gpt-5' }, supported: false },+ { capabilities: { supportsScheduleAgentDeviceSelection: true }, patch: { modelAgentKind: 'codex', model: 'gpt-5' }, supported: false },+ { capabilities: { supportsScheduleModelSelection: true }, patch: { modelAgentKind: 'codex', model: 'gpt-5' }, supported: true },+ { capabilities: { supportsScheduleModelSelection: true }, patch: { modelAgentKind: 'codex', model: 'gpt-5', modelAgentDeviceId: '' }, supported: false },+ { capabilities: { supportsScheduleModelSelection: true, supportsScheduleAgentDeviceSelection: true }, patch: { modelAgentKind: 'codex', model: 'gpt-5', modelAgentDeviceId: '' }, supported: true },+ ])('checks explicit engine support before remote writes: $capabilities / $patch', async ({ capabilities, patch, supported }) => {+ const s = setup();+ s.invoke.mockResolvedValueOnce({ ok: true, result: capabilities });+ s.invoke.mockResolvedValueOnce({ ok: true, result: { id: 's1' } });+ const result = await s.remote.invoke('mac', 'update', ['s1', patch]);+ expect(result).toMatchObject(supported ? { ok: true, data: { id: 's1' } } : { ok: false, code: 'REMOTE_UNSUPPORTED' });+ expect(s.invoke.mock.calls[0].slice(0, 3)).toEqual(['mac', 'maker:get-capabilities', ['claude-code']]);+ expect(s.invoke).toHaveBeenCalledTimes(supported ? 2 : 1);+ if (supported) expect(s.invoke.mock.calls[1].slice(0, 3)).toEqual(['mac', 'maker:schedule:update', ['s1', patch]]);+ });++ it('does not send an engine update after the account changes during capability lookup', async () => {+ const s = setup();+ s.invoke.mockImplementationOnce(async () => {+ s.changeOwner();+ return { ok: true, result: { supportsScheduleModelSelection: true } };+ });+ expect(await s.remote.invoke('mac', 'update', ['s1', { modelAgentKind: 'codex', model: 'gpt-5' }]))+ .toMatchObject({ ok: false });+ expect(s.invoke.mock.calls.map(([, channel]) => channel)).toEqual(['maker:get-capabilities']);+ });+// Unit: an old host ignores the new route field; reject before a write can run locally instead.it.each([false, true])('checks remote schedule location support before writing (%s)', async (supported) => {const s = setup();diff --git a/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts b/apps/desktop/src/main/mcp-integrations/schedulerDevices.tsindex 0c6a9115d0..5689226ab3 100644--- a/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts+++ b/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts@@ -101,11 +101,20 @@ export function createSchedulerRemoteDeps(deps: {let response: InvokeResultPayload;try {const patch = op === 'update' ? args[1] as Record<string, unknown> | undefined : undefined;- if (patch && (Object.prototype.hasOwnProperty.call(patch, 'modelAgentDeviceId')- || ['modelAgentKind', 'model', 'providerId', 'effort'].some((key) => patch[key] === null))) {+ const needsModelSelection = patch?.modelAgentKind != null;+ const needsLocationSelection = patch && (Object.prototype.hasOwnProperty.call(patch, 'modelAgentDeviceId')+ || ['modelAgentKind', 'model', 'providerId', 'effort'].some((key) => patch[key] === null));+ if (needsModelSelection || needsLocationSelection) {const capabilities = await deps.invoke(deviceId, 'maker:get-capabilities', ['claude-code'], { preSend: assertCurrent });assertCurrent();- if (!capabilities.ok || !(capabilities.result as { supportsScheduleAgentDeviceSelection?: boolean } | null)?.supportsScheduleAgentDeviceSelection) {+ const supported = capabilities.ok ? capabilities.result as {+ supportsScheduleModelSelection?: boolean;+ supportsScheduleAgentDeviceSelection?: boolean;+ } | null : null;+ if (needsModelSelection && supported?.supportsScheduleModelSelection !== true) {+ return { ok: false, code: 'REMOTE_UNSUPPORTED', message: '目标电脑的版本不支持自动化完整模型选择,请先更新目标电脑' };+ }+ if (needsLocationSelection && !supported?.supportsScheduleAgentDeviceSelection) {return { ok: false, code: 'REMOTE_UNSUPPORTED', message: '目标电脑的版本不支持自动化选择远程或分享供应商,请先更新目标电脑' };}}diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 87dbb56935..a1a114dd62 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -3542,6 +3542,9 @@ SQL NULL 对应缺省;项目 `version: 1` 配置同样允许该字段,旧文不把“选本机”误作继承绑定任务的位置。更新可沿用已存的完整选择,恢复跟随时清除显式选择。`maker:get-capabilities` 返回 `supportsScheduleAgentDeviceSelection: true`。新调用方只有明确看到此能力才向其它电脑提交位置选择;旧端未知字段会被忽略,禁止静默降级。+跨电脑更新非空 `modelAgentKind` 时,即使省略位置以继承原位置,也必须先确认既有+`supportsScheduleModelSelection: true`;旧端不支持时在写入前拒绝。同时设置位置或清空模型+字段时,两项所需能力一起核验,复用一次能力查询及原有账号代次检查,不新增协议字段。跨电脑 `schedule_update` 清空 `modelAgentDeviceId` / `modelAgentKind` / `model` / `providerId` /`effort` 时,同样先核验此能力,再保留可序列化的 `null` 发送;接收端 IPC 转成带 key 的`undefined` 后交给 Scheduler 与存储。省略字段仍是不修改,不在发送前丢掉清空意图。