mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-20 17:41:33 -06:00
3d76246792
* refactor: resolve final export name collisions * refactor: update remaining collision rename consumers * style: format rebased auth helpers * test: update remaining session entry mocks * test: update remaining runtime mock exports * test: update delivery info path mock * refactor: reconcile combined collision sweeps * chore: regenerate collision and sdk baselines
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
|
import {
|
|
resolveAllowedModelRef,
|
|
resolveDefaultModelForAgent,
|
|
} from "../../agents/model-selection.js";
|
|
import { resolveEffectiveAgentRuntime } from "../../agents/thinking-runtime.js";
|
|
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
|
import type { SessionCatalogCreateTarget } from "../session-catalog.js";
|
|
|
|
type RuntimeSessionCatalogCreateTargetParams = {
|
|
config: OpenClawConfig;
|
|
requestedAgentId?: string;
|
|
provider: string;
|
|
modelIds: readonly string[];
|
|
agentRuntime: string;
|
|
};
|
|
|
|
/**
|
|
* Resolve a synchronous catalog create target through the same model/runtime
|
|
* policy used by agent turns, without making plugins import that policy graph.
|
|
*/
|
|
export function resolveAgentCatalogCreateTarget(
|
|
params: RuntimeSessionCatalogCreateTargetParams,
|
|
): SessionCatalogCreateTarget | undefined {
|
|
const agentId = params.requestedAgentId ?? resolveDefaultAgentId(params.config);
|
|
const defaultModel = resolveDefaultModelForAgent({ cfg: params.config, agentId });
|
|
for (const modelId of params.modelIds) {
|
|
if (
|
|
resolveEffectiveAgentRuntime({
|
|
cfg: params.config,
|
|
provider: params.provider,
|
|
modelId,
|
|
agentId,
|
|
}) !== params.agentRuntime
|
|
) {
|
|
continue;
|
|
}
|
|
const model = `${params.provider}/${modelId}`;
|
|
const allowed = resolveAllowedModelRef({
|
|
cfg: params.config,
|
|
catalog: [],
|
|
raw: model,
|
|
defaultProvider: defaultModel.provider,
|
|
defaultModel: defaultModel.model,
|
|
agentId,
|
|
});
|
|
if (!("error" in allowed)) {
|
|
return { model, agentRuntime: params.agentRuntime };
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|