mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-01 18:02:28 +00:00
The automated rebrand sed script replaced "OpenClaw" with "Hanzo Bot" (with space) instead of "HanzoBot" in 8,315 TypeScript identifier occurrences across 1,632 files. This fixes all broken class names, type names, function names, and variable names. Co-authored-by: Hanzo Dev <[email protected]>
94 lines
2.5 KiB
TypeScript
94 lines
2.5 KiB
TypeScript
import {
|
|
buildCloudflareAiGatewayModelDefinition,
|
|
CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF,
|
|
resolveCloudflareAiGatewayBaseUrl,
|
|
} from "openclaw/plugin-sdk/provider-models";
|
|
import {
|
|
applyAgentDefaultModelPrimary,
|
|
applyProviderConfigWithDefaultModel,
|
|
type HanzoBotConfig,
|
|
} from "openclaw/plugin-sdk/provider-onboard";
|
|
|
|
export { CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF };
|
|
|
|
export function buildCloudflareAiGatewayConfigPatch(params: {
|
|
accountId: string;
|
|
gatewayId: string;
|
|
}) {
|
|
const baseUrl = resolveCloudflareAiGatewayBaseUrl(params);
|
|
return {
|
|
models: {
|
|
providers: {
|
|
"cloudflare-ai-gateway": {
|
|
baseUrl,
|
|
api: "anthropic-messages" as const,
|
|
models: [buildCloudflareAiGatewayModelDefinition()],
|
|
},
|
|
},
|
|
},
|
|
agents: {
|
|
defaults: {
|
|
models: {
|
|
[CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF]: {
|
|
alias: "Cloudflare AI Gateway",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export function applyCloudflareAiGatewayProviderConfig(
|
|
cfg: HanzoBotConfig,
|
|
params?: { accountId?: string; gatewayId?: string },
|
|
): HanzoBotConfig {
|
|
const models = { ...cfg.agents?.defaults?.models };
|
|
models[CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF] = {
|
|
...models[CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF],
|
|
alias: models[CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF]?.alias ?? "Cloudflare AI Gateway",
|
|
};
|
|
|
|
const existingProvider = cfg.models?.providers?.["cloudflare-ai-gateway"] as
|
|
| { baseUrl?: unknown }
|
|
| undefined;
|
|
const baseUrl =
|
|
params?.accountId && params?.gatewayId
|
|
? resolveCloudflareAiGatewayBaseUrl({
|
|
accountId: params.accountId,
|
|
gatewayId: params.gatewayId,
|
|
})
|
|
: typeof existingProvider?.baseUrl === "string"
|
|
? existingProvider.baseUrl
|
|
: undefined;
|
|
if (!baseUrl) {
|
|
return {
|
|
...cfg,
|
|
agents: {
|
|
...cfg.agents,
|
|
defaults: {
|
|
...cfg.agents?.defaults,
|
|
models,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
return applyProviderConfigWithDefaultModel(cfg, {
|
|
agentModels: models,
|
|
providerId: "cloudflare-ai-gateway",
|
|
api: "anthropic-messages",
|
|
baseUrl,
|
|
defaultModel: buildCloudflareAiGatewayModelDefinition(),
|
|
});
|
|
}
|
|
|
|
export function applyCloudflareAiGatewayConfig(
|
|
cfg: HanzoBotConfig,
|
|
params?: { accountId?: string; gatewayId?: string },
|
|
): HanzoBotConfig {
|
|
return applyAgentDefaultModelPrimary(
|
|
applyCloudflareAiGatewayProviderConfig(cfg, params),
|
|
CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF,
|
|
);
|
|
}
|