openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
114 lines (113 loc) • 4.18 kB
JavaScript
import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs";
import { i as listAgentIds } from "./agent-roster-t1ooUdXp.mjs";
import { a as resolveAgentDir, f as resolveAgentWorkspaceDir, r as resolveAgentConfig } from "./agent-scope-config-DmXgFGKP.mjs";
import { i as DEFAULT_PROVIDER, n as DEFAULT_MODEL } from "./defaults-BWyoTPqn.mjs";
import "./agent-scope-BwB8YH6y.mjs";
import { C as findModelInCatalog } from "./model-selection-shared-9Kz63Hhm.mjs";
import { n as resolveDefaultModelForAgent } from "./model-selection-config-Bvf5WqHo.mjs";
import { i as resolveConversationCapabilityProfile } from "./conversation-capability-profile-Be5DqCww.mjs";
import "./model-selection-C2A4Wyix.mjs";
import "./model-catalog-ZbVopayG.mjs";
import { d as readPreparedModelCatalog } from "./prepared-model-catalog-DSktrHGK.mjs";
import { f as isUpdateDoctorLintPass } from "./update-phase-YdZvaQsy.mjs";
import { n as supportsModelTools } from "./model-tool-support-BJrIU874.mjs";
//#region src/flows/doctor-tool-schema-frames.ts
function modelContextFinding(e, t, n = false) {
return {
checkId: "core/doctor/runtime-tool-schemas",
severity: "warning",
message: n ? `Agent ${e} model-specific tool schema inspection was deferred because its provider needs live model discovery.` : `Agent ${e} runtime tool schema inspection could not prepare its selected model context.`,
errorCode: n ? "provider-dynamic-model-deferred" : "model-context-unavailable",
path: `agents.${e}.model`,
requirement: t,
fixHint: n ? "Use the model in an authenticated agent run to validate its tool schemas." : "Resolve the provider/model loading problem, then rerun doctor to validate model-specific tool schemas."
};
}
/** Prepare each agent's local facts before acquiring the operation's tool registrations. */
async function prepareDoctorToolSchemaFrames(e, t = {}) {
const n = t.env ?? process.env;
const r = t.mode !== void 0 && t.mode !== "lint" && !isUpdateDoctorLintPass(n);
const i = [];
const a = [];
for (const o of listAgentIds(e)) {
if (resolveAgentConfig(e, o)?.runtime?.type === "acp") continue;
const s = resolveAgentDir(e, o, n);
const c = resolveAgentWorkspaceDir(e, o, n);
const prepare = async () => {
const t = resolveDefaultModelForAgent({
cfg: e,
agentId: o,
allowPluginNormalization: !r
});
let n;
if (r) {
const { resolveModelAsync: r } = await import("./model-BGxC_MMq.mjs");
const i = await r(t.provider, t.model, s, e, {
modelIdSource: "selected",
agentId: o,
workspaceDir: c,
skipAgentDiscovery: true,
allowBundledStaticCatalogFallback: true,
deferProviderDynamicModelPreparation: true
});
if (!i.model) {
a.push(modelContextFinding(o, i.error, Boolean(i.deferred)));
return;
}
n = i.model;
} else {
const r = await readPreparedModelCatalog({
config: e,
agentId: o,
agentDir: s,
readOnly: true,
providerDiscoveryProviderIds: []
});
const i = findModelInCatalog(r, t.provider, t.model);
const a = t.provider || "openai";
const c = t.model || "gpt-6-astra";
const l = i?.api ?? (a === "openai" ? "openai-responses" : void 0);
const u = i?.baseUrl ?? (l === "openai-chatgpt-responses" ? "https://chatgpt.com/backend-api" : a === "openai" ? "https://api.openai.com/v1" : void 0);
n = {
...i,
provider: a,
id: c,
name: i?.name ?? c,
...l ? { api: l } : {},
...u ? { baseUrl: u } : {}
};
}
if (!supportsModelTools(n)) return;
const l = resolveConversationCapabilityProfile({
config: e,
agentId: o,
workspaceDir: c,
modelProvider: t.provider,
modelId: t.model
});
i.push({
agentId: o,
agentDir: s,
workspaceDir: c,
modelRef: t,
model: n,
capabilityProfile: l
});
};
try {
if (t.runWithPluginMetadataSnapshot) await t.runWithPluginMetadataSnapshot({
config: e,
workspaceDir: c
}, prepare);
else await prepare();
} catch (e) {
a.push(modelContextFinding(o, formatErrorMessage(e)));
}
}
return {
frames: i,
findings: a
};
}
//#endregion
export { prepareDoctorToolSchemaFrames };