mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-12 06:50:48 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
78
openclaw/extensions/mistral/api.ts
Normal file
78
openclaw/extensions/mistral/api.ts
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
export { buildMistralProvider } from "./provider-catalog.js";
|
||||
export {
|
||||
buildMistralModelDefinition,
|
||||
MISTRAL_BASE_URL,
|
||||
MISTRAL_DEFAULT_MODEL_ID,
|
||||
} from "./model-definitions.js";
|
||||
export {
|
||||
applyMistralConfig,
|
||||
applyMistralProviderConfig,
|
||||
MISTRAL_DEFAULT_MODEL_REF,
|
||||
} from "./onboard.js";
|
||||
|
||||
const MISTRAL_MAX_TOKENS_FIELD = "max_tokens";
|
||||
|
||||
export const MISTRAL_MODEL_TRANSPORT_PATCH = {
|
||||
supportsStore: false,
|
||||
maxTokensField: MISTRAL_MAX_TOKENS_FIELD,
|
||||
} as const satisfies {
|
||||
supportsStore: boolean;
|
||||
maxTokensField: "max_tokens";
|
||||
};
|
||||
|
||||
export const MISTRAL_SMALL_LATEST_REASONING_EFFORT_MAP: Record<string, string> = {
|
||||
off: "none",
|
||||
minimal: "none",
|
||||
low: "high",
|
||||
medium: "high",
|
||||
high: "high",
|
||||
xhigh: "high",
|
||||
adaptive: "high",
|
||||
};
|
||||
|
||||
export const MISTRAL_SMALL_LATEST_ID = "mistral-small-latest";
|
||||
|
||||
export function resolveMistralCompatPatch(model: { id?: string }): {
|
||||
supportsStore: boolean;
|
||||
supportsReasoningEffort: boolean;
|
||||
maxTokensField: "max_tokens";
|
||||
reasoningEffortMap?: Record<string, string>;
|
||||
} {
|
||||
const reasoningEnabled = model.id === MISTRAL_SMALL_LATEST_ID;
|
||||
return {
|
||||
...MISTRAL_MODEL_TRANSPORT_PATCH,
|
||||
supportsReasoningEffort: reasoningEnabled,
|
||||
reasoningEffortMap: reasoningEnabled ? MISTRAL_SMALL_LATEST_REASONING_EFFORT_MAP : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function compatMatchesResolved(
|
||||
compat: Record<string, unknown> | undefined,
|
||||
modelId: string | undefined,
|
||||
): boolean {
|
||||
const expected = resolveMistralCompatPatch({ id: modelId });
|
||||
return (
|
||||
compat?.supportsStore === expected.supportsStore &&
|
||||
compat?.supportsReasoningEffort === expected.supportsReasoningEffort &&
|
||||
compat?.maxTokensField === expected.maxTokensField &&
|
||||
compat?.reasoningEffortMap === expected.reasoningEffortMap
|
||||
);
|
||||
}
|
||||
|
||||
export function applyMistralModelCompat<T extends { compat?: unknown; id?: string }>(model: T): T {
|
||||
const compat =
|
||||
model.compat && typeof model.compat === "object"
|
||||
? (model.compat as Record<string, unknown>)
|
||||
: undefined;
|
||||
if (compatMatchesResolved(compat, model.id)) {
|
||||
return model;
|
||||
}
|
||||
const patch = resolveMistralCompatPatch(model);
|
||||
return {
|
||||
...model,
|
||||
compat: {
|
||||
...compat,
|
||||
...patch,
|
||||
} as T extends { compat?: infer TCompat } ? TCompat : never,
|
||||
} as T;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue