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。

Merge main into fix/6745-shared-provider-route

ylliuuu669acdea6af95a
diff --cc apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts
index fd801f9a50,5652e90244..86ab99319d
--- a/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts
+++ b/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts
@@@ -1,7 -1,8 +1,8 @@@
import type { AgentKind, Effort } from '@cindy/maker-core';
-import { effectiveSourceIdForModel, findCatalogModel, type ProviderView } from '@cindy/model-providers';
+import { connectedProvidersForAgent, effectiveSourceIdForModel, findCatalogModel, isModelSelectableForNewRoute, type ProviderView } from '@cindy/model-providers';
import { resolveCompatibleSessionRuntimeEffort } from './sessionRuntimeControl';
import { parseScheduledModelBaseline, type ScheduledModelBaseline } from '../../shared/scheduledModelBaseline';
+ import { throwIpcError } from '../utils/ipcValidate';
/** A saved automation choice, applied only while its target's send lock is held. */
export interface ScheduledModelSelection {
@@@ -96,12 -91,10 +99,12 @@@ export function resolveScheduledModelSe
): ScheduledModelSelection {
const providerId = selection.providerId ??
effectiveSourceIdForModel(providers, null, selection.model, selection.agentKind);
- const provider = providers.find((candidate) => candidate.id === providerId);
+ const provider = connectedProvidersForAgent(providers, selection.agentKind)
+ .find((candidate) => candidate.id === providerId);
const model = findCatalogModel(provider, selection.model, selection.agentKind, { exact: true });
- if (!provider?.connected || !model) {
+ if (!provider || !model ||
+ !isModelSelectableForNewRoute(model, { userProvider: provider.source === 'user' })) {
- throw new Error(`Scheduled model "${selection.model}" is unavailable from provider "${providerId ?? 'default'}"`);
+ throwIpcError('MODEL_SELECTION_UNAVAILABLE', `Scheduled model "${selection.model}" is unavailable from provider "${providerId ?? 'default'}"`);
}
return {
...selection,
@@@ -148,12 -125,10 +151,12 @@@ export async function applyScheduledMod
}
if (deps.isBusy()) throw new ScheduledModelSelectionBusyError('Scheduled model selection waits for the current turn');
assertScheduledHarnessSupported(target, selection.agentKind);
- const resolved = await deps.resolveSelection(selection);
+ // Automation changes model preferences within the bound task's execution location.
+ // Persisted baselines from older clients have no location of their own.
+ const resolved = await deps.resolveSelection(selection, target);
if (target.agentKind !== resolved.agentKind) {
const result = await deps.switchHarness(resolved);
- if (!result.engineReady || result.retryPending) throw new Error('Scheduled Harness switch did not become ready');
+ if (!result.engineReady || result.retryPending) throwIpcError('HARNESS_SWITCH_NOT_READY', 'Scheduled Harness switch did not become ready');
}
await deps.applyModel(resolved);
return resolved;