mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:11:24 +00:00
refactor(agent): dedupe harness and command workflows
This commit is contained in:
@@ -335,6 +335,32 @@ function ensureImageInput(model: OpenAIModel): OpenAIModel {
|
||||
};
|
||||
}
|
||||
|
||||
function buildOpenRouterScanResult(params: {
|
||||
entry: OpenRouterModelMeta;
|
||||
isFree: boolean;
|
||||
tool: ProbeResult;
|
||||
image: ProbeResult;
|
||||
}): ModelScanResult {
|
||||
const { entry, isFree } = params;
|
||||
return {
|
||||
id: entry.id,
|
||||
name: entry.name,
|
||||
provider: "openrouter",
|
||||
modelRef: `openrouter/${entry.id}`,
|
||||
contextLength: entry.contextLength,
|
||||
maxCompletionTokens: entry.maxCompletionTokens,
|
||||
supportedParametersCount: entry.supportedParametersCount,
|
||||
supportsToolsMeta: entry.supportsToolsMeta,
|
||||
modality: entry.modality,
|
||||
inferredParamB: entry.inferredParamB,
|
||||
createdAtMs: entry.createdAtMs,
|
||||
pricing: entry.pricing,
|
||||
isFree,
|
||||
tool: params.tool,
|
||||
image: params.image,
|
||||
};
|
||||
}
|
||||
|
||||
async function mapWithConcurrency<T, R>(
|
||||
items: T[],
|
||||
concurrency: number,
|
||||
@@ -427,23 +453,12 @@ export async function scanOpenRouterModels(
|
||||
async (entry) => {
|
||||
const isFree = isFreeOpenRouterModel(entry);
|
||||
if (!probe) {
|
||||
return {
|
||||
id: entry.id,
|
||||
name: entry.name,
|
||||
provider: "openrouter",
|
||||
modelRef: `openrouter/${entry.id}`,
|
||||
contextLength: entry.contextLength,
|
||||
maxCompletionTokens: entry.maxCompletionTokens,
|
||||
supportedParametersCount: entry.supportedParametersCount,
|
||||
supportsToolsMeta: entry.supportsToolsMeta,
|
||||
modality: entry.modality,
|
||||
inferredParamB: entry.inferredParamB,
|
||||
createdAtMs: entry.createdAtMs,
|
||||
pricing: entry.pricing,
|
||||
return buildOpenRouterScanResult({
|
||||
entry,
|
||||
isFree,
|
||||
tool: { ok: false, latencyMs: null, skipped: true },
|
||||
image: { ok: false, latencyMs: null, skipped: true },
|
||||
} satisfies ModelScanResult;
|
||||
});
|
||||
}
|
||||
|
||||
const model: OpenAIModel = {
|
||||
@@ -461,23 +476,12 @@ export async function scanOpenRouterModels(
|
||||
? await probeImage(ensureImageInput(model), apiKey, timeoutMs)
|
||||
: { ok: false, latencyMs: null, skipped: true };
|
||||
|
||||
return {
|
||||
id: entry.id,
|
||||
name: entry.name,
|
||||
provider: "openrouter",
|
||||
modelRef: `openrouter/${entry.id}`,
|
||||
contextLength: entry.contextLength,
|
||||
maxCompletionTokens: entry.maxCompletionTokens,
|
||||
supportedParametersCount: entry.supportedParametersCount,
|
||||
supportsToolsMeta: entry.supportsToolsMeta,
|
||||
modality: entry.modality,
|
||||
inferredParamB: entry.inferredParamB,
|
||||
createdAtMs: entry.createdAtMs,
|
||||
pricing: entry.pricing,
|
||||
return buildOpenRouterScanResult({
|
||||
entry,
|
||||
isFree,
|
||||
tool: toolResult,
|
||||
image: imageResult,
|
||||
} satisfies ModelScanResult;
|
||||
});
|
||||
},
|
||||
{
|
||||
onProgress: (completed, total) =>
|
||||
|
||||
Reference in New Issue
Block a user