Files
openclaw/extensions/tencent/config-compat.test.ts
Sulaga 2b51c255f8 feat(tencent): add Tencent Hy3 provider (TokenHub and TokenPlan) (#99076)
Summary:
- Merged feat(tencent): add Tencent Hy3 provider (TokenHub and TokenPlan) after ClawSweeper review.

Automerge notes:
- Ran the ClawSweeper repair loop before final review.
- Included post-review commit in the final squash: fix(tencent): preserve TokenHub auth compatibility
- Included post-review commit in the final squash: refactor(tencent): unify TokenPlan env/flag naming with TokenHub
- Included post-review commit in the final squash: docs: refresh Tencent provider docs metadata
- Included post-review commit in the final squash: fix: allow TokenPlan provider config overlays
- Included post-review commit in the final squash: docs: dedupe Tencent provider glossary labels
- Included post-review commit in the final squash: fix(tencent): repair TokenHub model defaults

Validation:
- ClawSweeper review passed for head 30c9fc130f.
- Required merge gates passed before the squash merge.

Prepared head SHA: 30c9fc130f
Review: https://github.com/openclaw/openclaw/pull/99076#issuecomment-4888527271

Co-authored-by: leisang <leisang@tencent.com>
Co-authored-by: Mason Huang <masonxhuang@tencent.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Approved-by: hxy91819
2026-07-06 04:29:48 +00:00

113 lines
3.5 KiB
TypeScript

// Tencent tests cover config compatibility repair behavior.
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { describe, expect, it } from "vitest";
import {
migrateTencentTokenHubModelDefaults,
TENCENT_TOKENHUB_DEFAULT_MODEL_REF,
TENCENT_TOKENHUB_PREVIEW_MODEL_REF,
} from "./config-compat.js";
describe("Tencent config compatibility", () => {
it("adds the stable TokenHub model and makes it primary for old preview defaults", () => {
const config = {
agents: {
defaults: {
model: {
primary: TENCENT_TOKENHUB_PREVIEW_MODEL_REF,
fallbacks: ["openai/gpt-5.5"],
},
models: {
[TENCENT_TOKENHUB_PREVIEW_MODEL_REF]: {
alias: "Preview",
},
},
},
},
} as OpenClawConfig;
const result = migrateTencentTokenHubModelDefaults(config);
expect(result.changes).toEqual([
`Updated Tencent TokenHub agent model defaults to include ${TENCENT_TOKENHUB_DEFAULT_MODEL_REF} and ${TENCENT_TOKENHUB_PREVIEW_MODEL_REF}.`,
`Changed Tencent TokenHub primary default from ${TENCENT_TOKENHUB_PREVIEW_MODEL_REF} to ${TENCENT_TOKENHUB_DEFAULT_MODEL_REF}.`,
]);
expect(result.config.agents?.defaults?.model).toEqual({
primary: TENCENT_TOKENHUB_DEFAULT_MODEL_REF,
fallbacks: ["openai/gpt-5.5"],
});
expect(result.config.agents?.defaults?.models).toEqual({
[TENCENT_TOKENHUB_PREVIEW_MODEL_REF]: {
alias: "Preview",
},
[TENCENT_TOKENHUB_DEFAULT_MODEL_REF]: {
alias: "Hy3 (TokenHub)",
},
});
expect(config.agents?.defaults?.models).not.toHaveProperty(TENCENT_TOKENHUB_DEFAULT_MODEL_REF);
});
it("adds the preview TokenHub model for hy3-only intermediate configs", () => {
const config = {
agents: {
defaults: {
model: TENCENT_TOKENHUB_DEFAULT_MODEL_REF,
models: {
[TENCENT_TOKENHUB_DEFAULT_MODEL_REF]: {},
},
},
},
} as OpenClawConfig;
const result = migrateTencentTokenHubModelDefaults(config);
expect(result.config.agents?.defaults?.model).toBe(TENCENT_TOKENHUB_DEFAULT_MODEL_REF);
expect(result.config.agents?.defaults?.models).toEqual({
[TENCENT_TOKENHUB_DEFAULT_MODEL_REF]: {
alias: "Hy3 (TokenHub)",
},
[TENCENT_TOKENHUB_PREVIEW_MODEL_REF]: {
alias: "Hy3 preview (TokenHub)",
},
});
});
it("does not create a model allowlist when TokenHub models are not already configured", () => {
const config = {
models: {
providers: {
"tencent-tokenhub": {
baseUrl: "https://tokenhub.tencentmaas.com/v1",
models: [],
},
},
},
} as OpenClawConfig;
const result = migrateTencentTokenHubModelDefaults(config);
expect(result).toEqual({ config, changes: [] });
});
it("does not report changes after TokenHub defaults are already repaired", () => {
const config = {
agents: {
defaults: {
model: { primary: TENCENT_TOKENHUB_DEFAULT_MODEL_REF },
models: {
[TENCENT_TOKENHUB_DEFAULT_MODEL_REF]: {
alias: "Hy3 (TokenHub)",
},
[TENCENT_TOKENHUB_PREVIEW_MODEL_REF]: {
alias: "Hy3 preview (TokenHub)",
},
},
},
},
} as OpenClawConfig;
const result = migrateTencentTokenHubModelDefaults(config);
expect(result).toEqual({ config, changes: [] });
});
});