Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(scheduler): preserve model choices across script and remote updates

Yuewei-LL5accb26fc267
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts
index c001a197bb..c36273683a 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts
@@ -17,6 +17,18 @@ import { BUILTIN_TEMPLATES, Scheduler } from '@cindy/maker-scheduler';
import { applyTemplateToMobileScheduleDraft, buildMobileScheduleInput, createMobileScheduleDraft, updateDraftBoundSessionId } from '@cindy/maker-shared/schedule-form';
const handlers = vi.hoisted(() => new Map<string, (...args: unknown[]) => Promise<unknown>>());
+const generation = vi.hoisted(() => ({ install: vi.fn(), providers: vi.fn(), sessionProvider: vi.fn() }));
+vi.mock('../../scheduler-host/hook-script-generator.js', async (importOriginal) => ({
+ ...await importOriginal<typeof import('../../scheduler-host/hook-script-generator.js')>(),
+ installHookScript: generation.install,
+}));
+vi.mock('../../maker-host/createDesktopProviderService.js', () => ({
+ getDesktopProviderService: () => ({ listProviders: generation.providers }),
+}));
+vi.mock('../../maker-host/session-provider-store.js', async (importOriginal) => ({
+ ...await importOriginal<typeof import('../../maker-host/session-provider-store.js')>(),
+ getSessionProvider: generation.sessionProvider,
+}));
vi.mock('electron', () => ({
ipcMain: { handle: vi.fn((name, handler) => handlers.set(name, handler)) },
@@ -145,6 +157,52 @@ describe('scheduled model selection IPC compatibility', () => {
const fullForm = { cronExpr: '0 9 * * *', manual: false, notify: { desktop: true, feishu: false },
targetSessionId: 'bound', agentKind: 'codex', model: 'pi-model' } as UpdateScheduleInput;
+ // PR #6830, unit: actual IPC + Scheduler + storage, after a JSON round-trip.
+ // The old remote MCP could set this route but could never restore follow mode.
+ it('persists remote model clearing while omitted model fields remain untouched', async () => {
+ let saved = { ...existing, modelAgentDeviceId: 'shared:owner', name: 'Bound', prompt: 'Run',
+ recurring: true, timezone: 'UTC', cronExpr: '0 9 * * *', status: 'active', workspaceKind: 'dialogue' } as Schedule;
+ const storage = {
+ get: vi.fn(async () => ({ ...saved })),
+ update: vi.fn(async (_id: string, patch: Partial<Schedule>) => (saved = { ...saved, ...patch })),
+ };
+ setSchedulerReady(new Scheduler({ storage: storage as never, runner: { fire: vi.fn() } }), storage as never);
+ registerScheduleHandlers();
+ await handlers.get('maker:schedule:update')!(null, saved.id, JSON.parse(JSON.stringify({ name: 'Renamed' })));
+ expect(saved).toMatchObject({ modelAgentDeviceId: 'shared:owner', modelAgentKind: 'pi', model: 'pi-model' });
+ const clear = { modelAgentDeviceId: null, modelAgentKind: null, model: null, providerId: null, effort: null, fastMode: false };
+ await handlers.get('maker:schedule:update')!(null, saved.id, JSON.parse(JSON.stringify(clear)));
+ const reopened = await handlers.get('maker:schedule:get')!(null, saved.id);
+ expect(reopened).toMatchObject({ name: 'Renamed', targetSessionId: 'bound', agentKind: 'codex',
+ modelAgentDeviceId: undefined, modelAgentKind: undefined, model: undefined, providerId: undefined, effort: undefined, fastMode: false });
+ });
+
+ // PR #6830, unit: a remote bound task supplies cwd only when the user explicitly
+ // selects a local Codex model. The generator must use the connected local source.
+ it('resolves an explicit local hook model without inheriting the remote task route', async () => {
+ generation.providers.mockResolvedValue([{ id: 'local-source', source: 'user', connected: true, agents: ['codex'],
+ routing: { codex: {} }, models: { codex: [{ id: 'local-model', name: 'Local', contextWindow: 1000 }] } }]);
+ generation.sessionProvider.mockReturnValue('remote-source');
+ generation.install.mockResolvedValue({ command: 'node check.mjs' });
+ const maker = { getSessionMeta: vi.fn(async () => ({ agentKind: 'claude-code', model: 'remote-model', agentDeviceId: 'studio' })) };
+ registerScheduleHandlers(() => maker as never);
+ const result = await handlers.get('maker:schedule:generate-pre-run-hook')!(null, {
+ description: 'check changes', targetSessionId: 'bound', resolveBoundSessionRoute: true,
+ modelAgentDeviceId: '', agentKind: 'codex', model: 'local-model',
+ });
+ expect(result).toMatchObject({ ok: true, command: 'node check.mjs' });
+ expect(generation.install).toHaveBeenLastCalledWith(expect.anything(), expect.objectContaining({
+ agentKind: 'codex', model: 'local-model', providerId: 'local-source',
+ }));
+ const calls = generation.install.mock.calls.length;
+ const unavailable = await handlers.get('maker:schedule:generate-pre-run-hook')!(null, {
+ description: 'check changes', targetSessionId: 'bound', resolveBoundSessionRoute: true,
+ modelAgentDeviceId: '', agentKind: 'codex', model: 'missing',
+ });
+ expect(unavailable).toMatchObject({ ok: false, reason: 'no_candidate' });
+ expect(generation.install).toHaveBeenCalledTimes(calls);
+ });
+
it('normalizes an old Mobile full form inside the update handler before partial merge', async () => {
const updateFromCurrent = vi.fn(async (_id, update) => ({ ...existing, ...await update(existing) }));
setSchedulerReady({ updateFromCurrent } as never, {} as never);
diff --git a/apps/desktop/src/main/maker-ipc/schedule.ts b/apps/desktop/src/main/maker-ipc/schedule.ts
index 4079287a81..b783b12a77 100644
--- a/apps/desktop/src/main/maker-ipc/schedule.ts
+++ b/apps/desktop/src/main/maker-ipc/schedule.ts
@@ -386,6 +386,12 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
ipcMain.handle(MAKER_INVOKE.SCHEDULE_UPDATE, async (_e, id: unknown, patch: unknown) => {
const scheduleId = requireString(id, 'id');
requireObject(patch, 'patch');
+ // JSON must keep null until this receiving boundary; undefined keys disappear
+ // in transit. Only model-selection axes gain explicit clearing semantics.
+ const normalizedPatch = { ...patch as Record<string, unknown> };
+ for (const key of ['modelAgentDeviceId', 'modelAgentKind', 'model', 'providerId', 'effort']) {
+ if (normalizedPatch[key] === null) normalizedPatch[key] = undefined;
+ }
return withScheduler(({ scheduler }) =>
scheduler.updateFromCurrent(scheduleId, (existing) =>
stabilizePreRunHookForUpdate(
@@ -394,7 +400,7 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
existing,
normalizeLegacyDeviceLinkIntervalClear(
normalizeNullableIntervalMs(
- patch as UpdateScheduleInput & { intervalMs?: number | null },
+ normalizedPatch as UpdateScheduleInput & { intervalMs?: number | null },
),
isDeviceLinkInvoke(),
),
@@ -509,7 +515,12 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
targetSessionId,
resolveBoundSessionRoute: body.resolveBoundSessionRoute === true,
})) {
- const session = await maker.getSessionMeta(targetSessionId).catch(() => null);
+ // Explicit local choices resolve only against the host catalog. The bound
+ // task still supplies cwd, but its remote model/provider must not leak in.
+ const explicitLocal = body.modelAgentDeviceId === '';
+ const session = explicitLocal
+ ? requestedAgentKind ? { agentKind: requestedAgentKind, model: model ?? '', agentDeviceId: null } : null
+ : await maker.getSessionMeta(targetSessionId).catch(() => null);
if (session?.agentDeviceId) return unsupportedRemoteGeneration(providerId, model ?? session.model, session.agentKind);
// Bound-session fallback must use the same live connection snapshot as
// the provider picker. Never turn an unconnected built-in provider into
@@ -523,7 +534,7 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
});
const route = resolveBoundSessionGenerationRoute({
session,
- sessionProviderId: getSessionProvider(targetSessionId),
+ sessionProviderId: explicitLocal ? undefined : getSessionProvider(targetSessionId),
requestedProviderId: providerId,
requestedModel: model,
providers,
@@ -533,7 +544,7 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
ok: false as const,
reason: 'no_candidate' as const,
attempts: [{
- providerId: getSessionProvider(targetSessionId) ?? targetSessionId,
+ providerId: explicitLocal ? providerId ?? '' : getSessionProvider(targetSessionId) ?? targetSessionId,
model: session?.model?.trim() ?? '',
transport: session?.agentKind === 'codex' ? 'codex-responses' as const : 'litellm-chat-completions' as const,
status: 'skipped' as const,
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts
index 168f71a8e0..1d9ac96cf5 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts
@@ -38,6 +38,19 @@ describe('desktop scheduler cross-device transport', () => {
expect(result.ok).toBe(supported);
if (!supported) expect(result).toMatchObject({ code: 'REMOTE_UNSUPPORTED' });
});
+ // PR #6830, unit: route clearing needs the same new-host capability as setting
+ // a location, including partial clears that omit the location field entirely.
+ it.each([false, true])('checks support before forwarding null model axes (%s)', async (supported) => {
+ const s = setup();
+ const patch = { modelAgentKind: null, model: null, providerId: null, effort: null };
+ s.invoke.mockResolvedValueOnce({ ok: true, result: { supportsScheduleAgentDeviceSelection: supported } });
+ s.invoke.mockResolvedValueOnce({ ok: true, result: { id: 's1' } });
+ const result = await s.remote.invoke('mac', 'update', ['s1', patch]);
+ expect(result.ok).toBe(supported);
+ 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]]);
+ else expect(result).toMatchObject({ code: 'REMOTE_UNSUPPORTED' });
+ });
it('reuses the existing remote-control schedule channels with their argument shapes', async () => {
const s = setup();
await s.remote.invoke('mac', 'list', [{ status: 'active' }]);
diff --git a/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts b/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts
index 7511594917..0c6a9115d0 100644
--- a/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts
+++ b/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts
@@ -101,7 +101,8 @@ 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')) {
+ if (patch && (Object.prototype.hasOwnProperty.call(patch, 'modelAgentDeviceId')
+ || ['modelAgentKind', 'model', 'providerId', 'effort'].some((key) => patch[key] === null))) {
const capabilities = await deps.invoke(deviceId, 'maker:get-capabilities', ['claude-code'], { preSend: assertCurrent });
assertCurrent();
if (!capabilities.ok || !(capabilities.result as { supportsScheduleAgentDeviceSelection?: boolean } | null)?.supportsScheduleAgentDeviceSelection) {
diff --git a/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts
index e3c18350e4..faef25739e 100644
--- a/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts
+++ b/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts
@@ -599,6 +599,20 @@ describe('SchedulerScriptCapabilityBroker', () => {
expect(result).toMatchObject({ target_session_id: 'session-1', wake_kind: 'created' });
});
+ // PR #6830 / unit: MCP may persist a different model Harness. Exercise the
+ // actual dispatch entry, which previously paired this Codex model with Claude.
+ it('dispatches a new task with the explicit model Harness', async () => {
+ sendToSessionMock.mockResolvedValue({ ok: true, targetSessionId: 'new', agentKind: 'codex', wakeKind: 'created' });
+ await new SchedulerScriptCapabilityBroker().call(
+ { method: 'sessions.dispatch', params: { message: 'run task' } },
+ new Set(['sessions.dispatch']),
+ { schedule: schedule({ agentKind: 'claude-code', modelAgentKind: 'codex', modelAgentDeviceId: '' }) },
+ );
+ expect(sendToSessionMock).toHaveBeenCalledWith(expect.objectContaining({
+ createDefaults: expect.objectContaining({ agentKind: 'codex', model: 'gpt-5.5', providerId: 'provider-1' }),
+ }));
+ });
+
// Integration regression: a persisted remote route must never become local
// create defaults merely because sessions.dispatch omits a target task.
it.each([
diff --git a/apps/desktop/src/main/scheduler-host/script-capability-broker.ts b/apps/desktop/src/main/scheduler-host/script-capability-broker.ts
index 6b315d9413..75ccb4729e 100644
--- a/apps/desktop/src/main/scheduler-host/script-capability-broker.ts
+++ b/apps/desktop/src/main/scheduler-host/script-capability-broker.ts
@@ -224,14 +224,15 @@ export class SchedulerScriptCapabilityBroker implements ScriptCapabilityBroker {
if (schedule.modelAgentDeviceId ?? schedule.agentDeviceId) {
fail('PRECONDITION_FAILED', 'script execution does not support remote model sources; select a local model before switching modes');
}
+ const agentKind = schedule.modelAgentKind ?? schedule.agentKind;
const explicitProviderId = schedule.providerId?.trim() || null;
const dynamicDefaultRoute = !schedule.model?.trim()
- ? await this.deps.resolveDefaultModelRoute?.(schedule.agentKind, explicitProviderId) ?? null
+ ? await this.deps.resolveDefaultModelRoute?.(agentKind, explicitProviderId) ?? null
: null;
const model = schedule.model?.trim() || dynamicDefaultRoute?.model;
- if (!model) fail('PRECONDITION_FAILED', `${schedule.agentKind} has no connected model source`);
+ if (!model) fail('PRECONDITION_FAILED', `${agentKind} has no connected model source`);
return {
- agentKind: schedule.agentKind,
+ agentKind,
model,
providerId: explicitProviderId ?? dynamicDefaultRoute?.providerId ?? null,
effort: schedule.effort as DispatchEffort | undefined,
diff --git a/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx b/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx
index f154596bf8..e6d41435b7 100644
--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx
+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx
@@ -287,10 +287,11 @@ export function ScheduleFormDialog({
scheduleName: form.name.trim() || undefined,
providerId: providerId ?? undefined,
// Remote selections use the existing local utility-model fallback above.
- modelAgentDeviceId: undefined,
+ modelAgentDeviceId: remoteAgentLocation ? undefined : form.modelAgentDeviceId,
// bound 任务的缺省模型/来源维度由 main 按绑定会话补齐;provider/model 的显式
// 覆盖仍原样透传。persistent 任务即使已回写 targetSessionId,也按任务级选择生成。
- agentKind: resolveBoundSessionRoute || remoteAgentLocation ? undefined : form.agentKind,
+ agentKind: remoteAgentLocation || (resolveBoundSessionRoute && form.modelAgentDeviceId !== '')
+ ? undefined : form.agentKind,
model: inheritsBoundSessionModel || remoteAgentLocation ? undefined : form.model.trim() || undefined,
// 绑定会话任务:workingDir 不发(表单残留值可能是改绑前的过期项目目录,
// 显式值会压过会话解析),真实 cwd 由 main 按会话 meta.workDir 解析 ——
@@ -322,6 +323,7 @@ export function ScheduleFormDialog({
form.name,
form.providerId,
selectedAgentDeviceId,
+ form.modelAgentDeviceId,
form.effort,
form.agentKind,
form.model,
diff --git a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleFormDialog.test.tsx b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleFormDialog.test.tsx
index 1712a2f83d..df67bae2d8 100644
--- a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleFormDialog.test.tsx
+++ b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleFormDialog.test.tsx
@@ -80,6 +80,23 @@ beforeEach(() => {
localStorage.clear();
});
afterEach(cleanup);
+afterEach(() => vi.unstubAllGlobals());
+
+// PR #6830, unit/jsdom: a bound remote task must not hide an explicit local
+// model-only selection from the real hook-generation IPC request.
+it('sends the explicit local Harness and location when generating a bound hook', async () => {
+ const generatePreRunHook = vi.fn(async () => ({ ok: false, reason: 'no_candidate', attempts: [] }));
+ vi.stubGlobal('electronAPI', { maker: { schedule: { generatePreRunHook } } });
+ state.references.set('bound', { id: 'bound', state: 'available', status: 'active', agentKind: 'claude-code', agentDeviceId: 'studio' });
+ mount(schedule({ targetSessionId: 'bound', modelAgentKind: 'codex', modelAgentDeviceId: '', providerId: '',
+ preRunHook: { command: 'node check.mjs' } }));
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.editor.preRunHook.aiModify' }));
+ fireEvent.change(screen.getByPlaceholderText('scheduler.editor.preRunHook.aiPlaceholder'), { target: { value: 'check changes' } });
+ fireEvent.click(screen.getByRole('button', { name: 'scheduler.editor.preRunHook.aiGenerate' }));
+ await waitFor(() => expect(generatePreRunHook).toHaveBeenCalledWith(expect.objectContaining({
+ targetSessionId: 'bound', modelAgentDeviceId: '', agentKind: 'codex', model: 'shared', resolveBoundSessionRoute: true,
+ })));
+});
it('saves a selected remote-only model against its own catalog', async () => {
const form = mount(schedule());
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 4c85cd390f..e52647a3a7 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -615,9 +615,9 @@ SSH 主机不自动成为设备目录成员。实现与回归见 `mcp-integratio
`maker:schedule:*` channel,参数形状不变,被控端仍由原 IPC 入口校验并执行。`schedule_list` 的
`query` 文本筛选在发起端对返回结果做,不改请求。`device` 缺省时返回形状与原来一致,三个读取工具
都只多出 `scope: "local"`。跨电脑读取按电脑分组,离线、未开启远程控制、撤权、超时、不支持的电脑逐台
-列出,`partial` 表示覆盖不全。`schedule_update` 跨电脑时拒绝 `bindToCurrentSession` 和
-`intervalMs` 以外的 `null` 清空(JSON 边界表达不了「带 key 的 undefined」),明确报
-`INVALID_PARAMS`,不写出与意图不符的任务。其它电脑返回的定时任务与运行记录里,`targetSessionId` / `sessionId` 加上 `deviceId::` 前缀(与历史
+列出,`partial` 表示覆盖不全。`schedule_update` 跨电脑时拒绝 `bindToCurrentSession`;除
+`intervalMs` 与下文模型选择字段外,其它字段的 `null` 清空仍明确报 `INVALID_PARAMS`,
+不写出与意图不符的任务。其它电脑返回的定时任务与运行记录里,`targetSessionId` / `sessionId` 加上 `deviceId::` 前缀(与历史
查询同一约定),跨电脑 `schedule_update` 收到同一台电脑前缀的 `targetSessionId` 先去掉再发送,指向
别的电脑的拒绝。被控端对 `preRunHook` 是整对象替换:跨电脑改它必须
显式带 `timeoutMs`(数值,或 `null` 表示不限时,后者发送为不带 `timeoutMs` 的整对象),否则报 `INVALID_PARAMS`(省略会清成不限时,发起端先读后写又会覆盖并发修改)。被控端不认识这些 channel(早于完整控制面的旧版本)时
@@ -3193,6 +3193,9 @@ SQL NULL 对应缺省;项目 `version: 1` 配置同样允许该字段,旧文
不把“选本机”误作继承绑定任务的位置。更新可沿用已存的完整选择,恢复跟随时清除显式选择。
`maker:get-capabilities` 返回 `supportsScheduleAgentDeviceSelection: true`。
新调用方只有明确看到此能力才向其它电脑提交位置选择;旧端未知字段会被忽略,禁止静默降级。
+跨电脑 `schedule_update` 清空 `modelAgentDeviceId` / `modelAgentKind` / `model` / `providerId` /
+`effort` 时,同样先核验此能力,再保留可序列化的 `null` 发送;接收端 IPC 转成带 key 的
+`undefined` 后交给 Scheduler 与存储。省略字段仍是不修改,不在发送前丢掉清空意图。
旧调用方修改新自动化的非模型字段仍保留位置;修改模型路线却未携带已固定的位置时拒绝保存,
避免意外把另一台电脑的供应商当作本机来源。执行与恢复仍使用既有远程授权、目录与切换协议。
diff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.md
index 12688ee856..009dae5174 100644
--- a/docs/product-rules/agent-user-parity.md
+++ b/docs/product-rules/agent-user-parity.md
@@ -52,7 +52,7 @@
| 协同 / Worker | Lead 使用远程供应商时派发跨设备 Worker;独立选择工作电脑与模型电脑 | 有 | 有(`execution_device_id` + `agent_device_id`;目录查询支持同一工作电脑范围) |
| 协同 / Worker | 为 Worker 新建 worktree、指定源分支、归档时回收 | 有 | 无 |
| 定时任务 | 列出、详情、运行记录、修改、暂停、恢复、删除、立即运行 | 有 | 有(2026-10-14) |
-| 定时任务 | 选择远程/分享供应商模型(运行位置、引擎、模型与速度);绑定任务或持续模式切回本机须保留完整引擎/模型选择 | 有 | 有(目标电脑须支持 `supportsScheduleAgentDeviceSelection`) |
+| 定时任务 | 选择远程/分享供应商模型(运行位置、引擎、模型与速度)及清除覆盖恢复跟随;绑定任务或持续模式切回本机须保留完整引擎/模型选择 | 有 | 有(设置或清除模型选择均核验目标电脑的 `supportsScheduleAgentDeviceSelection`) |
| 定时任务 | 新建、安装检查脚本 | 有(绑定远程 Agent 时由本机辅助模型生成脚本) | 无 |
| 定时任务 | 查可选运行位置与模型;设每次新建任务的 Agent 运行位置(其他电脑 / 分享来的供应商) | 有(2026-10-22) | 无 |
| 定时任务 | 删除单条运行记录、标记已读 | 无 | 无 |
diff --git a/docs/product-rules/model-selector-unified.md b/docs/product-rules/model-selector-unified.md
index b03bcafade..a8f122b9f0 100644
--- a/docs/product-rules/model-selector-unified.md
+++ b/docs/product-rules/model-selector-unified.md
@@ -219,8 +219,11 @@ Desktop 的 `ModelRouteSelector` 提供完整控件,`ModelRouteSelectorContent
两种形式均透传统一选择器的完整选模结果;专用能力限制仍由调用场景声明。
前置检查脚本的 AI 生成使用直接 utility HTTP 接口。表单选择远程来源时沿用本机辅助模型兜底;
直接向该接口传远程来源仍明确拒绝,不得误用本机同名供应商。已有脚本的执行不受影响。
+绑定远程任务但显式选回本机时,生成请求保留本机标记与所选引擎,缺省来源按本机目录补齐;
+绑定任务只提供工作目录,不借用它的远程模型或来源。
“仅运行脚本”模式暂不支持远程模型来源;切换保存时保留完整来源并明确拒绝,原配置不变,
先选回本机模型后可切换。脚本的 `sessions.dispatch` 新建任务同样不得将远程配置解释成本机来源。
+本机脚本新建任务使用 `modelAgentKind ?? agentKind` 与所选模型配对;投递既有任务仍沿用该任务配置。
---
diff --git a/packages/lizi-mcps/src/__tests__/schedulerDevices.test.ts b/packages/lizi-mcps/src/__tests__/schedulerDevices.test.ts
index b883e36bc2..26ced57173 100644
--- a/packages/lizi-mcps/src/__tests__/schedulerDevices.test.ts
+++ b/packages/lizi-mcps/src/__tests__/schedulerDevices.test.ts
@@ -413,6 +413,17 @@ describe("cindy_scheduler cross-device routing", () => {
expect(s.scheduler.pause).toHaveBeenCalledWith("l1", undefined);
});
+ // PR #6830, unit: the real MCP entry must retain explicit clearing across JSON;
+ // replacing null with undefined here would silently keep the old remote route.
+ it("forwards model selection clearing as JSON null without changing omitted fields", async () => {
+ const s = setup();
+ const patch = { modelAgentDeviceId: null, modelAgentKind: null, model: null, providerId: null, effort: null, fastMode: false };
+ const result = parse(await s.registry.call("schedule_update", { id: "r1", device: "mbp", ...patch }));
+ expect(result.ok).toBe(true);
+ expect(JSON.parse(JSON.stringify(s.invoke.mock.calls[0]))).toEqual(["mbp", "update", ["r1", patch]]);
+ expect(s.scheduler.updateFromCurrent).not.toHaveBeenCalled();
+ });
+
it("rejects writes that cannot be expressed on another computer instead of guessing", async () => {
const s = setup();
for (const args of [{ id: "r1", device: "all" }]) {
@@ -425,7 +436,7 @@ describe("cindy_scheduler cross-device routing", () => {
}
for (const patch of [
{ bindToCurrentSession: true },
- { model: null },
+ { workingDir: null },
{ cronExpr: "not a cron" },
// 运行位置 id 相对本机的设备目录,对那台电脑没有意义。
{ agentDeviceId: "studio", model: "claude-opus-5-5" },
diff --git a/packages/lizi-mcps/src/scheduler/update.ts b/packages/lizi-mcps/src/scheduler/update.ts
index ae44f0ffa7..eb899fb624 100644
--- a/packages/lizi-mcps/src/scheduler/update.ts
+++ b/packages/lizi-mcps/src/scheduler/update.ts
@@ -24,7 +24,7 @@ export function registerScheduleUpdateTool(
name: 'schedule_update',
category: 'scheduler',
description:
- '修改一条定时任务的部分字段(patch 形态)。默认改本机的;其它电脑上的任务传 device(此时不支持 bindToCurrentSession,也不支持用 null 清空 intervalMs 以外的字段;改 preRunHook 必须显式带 timeoutMs(数值,或 null 表示不限时);targetSessionId 可传该电脑的 deviceId::sessionId 或其本机 id,不能指向别的电脑)。改 cronExpr / timezone 时 nextFireAt 会自动重算。要暂停 / 恢复请用 schedule_pause / schedule_resume,不要直接 patch status。把任务改成跟进**当前对话**的 heartbeat 请传 bindToCurrentSession=true(代码自动绑定本会话,无需也不要自己查 / 传 session id)。' +
+ '修改一条定时任务的部分字段(patch 形态)。默认改本机的;其它电脑上的任务传 device(此时不支持 bindToCurrentSession;null 可清空 intervalMs,以及支持模型位置选择的目标电脑上的 modelAgentDeviceId / modelAgentKind / model / providerId / effort,其它字段暂不支持;改 preRunHook 必须显式带 timeoutMs(数值,或 null 表示不限时);targetSessionId 可传该电脑的 deviceId::sessionId 或其本机 id,不能指向别的电脑)。改 cronExpr / timezone 时 nextFireAt 会自动重算。要暂停 / 恢复请用 schedule_pause / schedule_resume,不要直接 patch status。把任务改成跟进**当前对话**的 heartbeat 请传 bindToCurrentSession=true(代码自动绑定本会话,无需也不要自己查 / 传 session id)。' +
'**目标值缺失时先问用户,禁止盲猜**:用户指令模糊(如"改一下时间"没说改到几点、"换个模型"没说换哪个)时,先用 AskUserQuestion(或一句话追问)确认目标值再 patch;只改用户点名的字段,不要顺手"优化"其它字段。',
inputShape: {
id: z.string().min(1).describe('Schedule id'),
@@ -150,8 +150,9 @@ export function registerScheduleUpdateTool(
? '改其它电脑上的 preRunHook 必须显式传 timeoutMs(数值,或 null 表示不限时;先用 schedule_get 读到当前值)'
: (patch as { agentDeviceId?: string | null }).agentDeviceId !== undefined
? '其它电脑上的定时任务不能设运行位置 agentDeviceId'
- : Object.entries(patch).some(([key, value]) => value === null && key !== 'intervalMs')
- ? '其它电脑上的定时任务暂不支持用 null 清空 intervalMs 以外的字段'
+ : Object.entries(patch).some(([key, value]) => value === null
+ && !['intervalMs', 'modelAgentDeviceId', 'modelAgentKind', 'model', 'providerId', 'effort'].includes(key))
+ ? '其它电脑上的定时任务只支持用 null 清空间隔和模型选择字段'
: null;
if (unsupported) {
return buildJsonResult(
@@ -169,6 +170,7 @@ export function registerScheduleUpdateTool(
}
const hook = patch.preRunHook as { command: string; timeoutMs?: number | null } | undefined;
// 不限时在对方入口的表达就是不带 timeoutMs 的整对象。
+ // Model-selection nulls must survive JSON; the receiving IPC clears them.
const remotePatch = hook?.timeoutMs === null
? { ...patch, preRunHook: { command: hook.command } }
: patch;