mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-15 10:36:09 +00:00
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 head30c9fc130f. - Required merge gates passed before the squash merge. Prepared head SHA:30c9fc130fReview: 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
121 lines
3.9 KiB
TypeScript
121 lines
3.9 KiB
TypeScript
// Tencent plugin entrypoint registers its OpenClaw integration.
|
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
|
import { buildSingleProviderApiKeyCatalog } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
import {
|
|
TOKENHUB_MODEL_CATALOG,
|
|
TOKENHUB_PROVIDER_ID,
|
|
TOKENPLAN_MODEL_CATALOG,
|
|
TOKENPLAN_PROVIDER_ID,
|
|
} from "./models.js";
|
|
import {
|
|
applyTokenHubConfig,
|
|
TOKENHUB_DEFAULT_MODEL_REF,
|
|
applyTokenPlanConfig,
|
|
TOKENPLAN_DEFAULT_MODEL_REF,
|
|
} from "./onboard.js";
|
|
import { buildTokenHubProvider, buildTokenPlanProvider } from "./provider-catalog.js";
|
|
import { wrapTencentProviderStream } from "./stream.js";
|
|
|
|
function buildStaticCatalogEntries(providerId: string, catalog: typeof TOKENHUB_MODEL_CATALOG) {
|
|
return catalog.map((entry) => ({
|
|
provider: providerId,
|
|
id: entry.id,
|
|
name: entry.name,
|
|
reasoning: entry.reasoning,
|
|
input: [...entry.input],
|
|
contextWindow: entry.contextWindow,
|
|
}));
|
|
}
|
|
|
|
function createTokenHubApiKeyAuthMethod() {
|
|
return createProviderApiKeyAuthMethod({
|
|
providerId: TOKENHUB_PROVIDER_ID,
|
|
methodId: "api-key",
|
|
label: "Tencent TokenHub",
|
|
hint: "Hy via Tencent TokenHub Gateway",
|
|
optionKey: "tokenhubApiKey",
|
|
flagName: "--tokenhub-api-key",
|
|
envVar: "TOKENHUB_API_KEY",
|
|
promptMessage: "Enter Tencent TokenHub API key",
|
|
defaultModel: TOKENHUB_DEFAULT_MODEL_REF,
|
|
expectedProviders: [TOKENHUB_PROVIDER_ID],
|
|
applyConfig: applyTokenHubConfig,
|
|
wizard: {
|
|
choiceId: "tokenhub-api-key",
|
|
choiceLabel: "Tencent TokenHub",
|
|
groupId: "tencent",
|
|
groupLabel: "Tencent Cloud",
|
|
groupHint: "Tencent TokenHub",
|
|
},
|
|
});
|
|
}
|
|
|
|
export default definePluginEntry({
|
|
id: "tencent",
|
|
name: "Tencent Cloud Provider",
|
|
description: "Bundled Tencent Cloud provider plugin (TokenHub, TokenPlan)",
|
|
register(api) {
|
|
api.registerProvider({
|
|
id: TOKENHUB_PROVIDER_ID,
|
|
label: "Tencent TokenHub",
|
|
docsPath: "/providers/tencent",
|
|
envVars: ["TOKENHUB_API_KEY"],
|
|
auth: [createTokenHubApiKeyAuthMethod()],
|
|
catalog: {
|
|
order: "simple",
|
|
run: (ctx) =>
|
|
buildSingleProviderApiKeyCatalog({
|
|
ctx,
|
|
providerId: TOKENHUB_PROVIDER_ID,
|
|
buildProvider: buildTokenHubProvider,
|
|
}),
|
|
},
|
|
augmentModelCatalog: () =>
|
|
buildStaticCatalogEntries(TOKENHUB_PROVIDER_ID, TOKENHUB_MODEL_CATALOG),
|
|
wrapStreamFn: wrapTencentProviderStream,
|
|
});
|
|
|
|
api.registerProvider({
|
|
id: TOKENPLAN_PROVIDER_ID,
|
|
label: "Tencent TokenPlan",
|
|
docsPath: "/providers/tencent",
|
|
envVars: ["TOKENPLAN_API_KEY"],
|
|
auth: [
|
|
createProviderApiKeyAuthMethod({
|
|
providerId: TOKENPLAN_PROVIDER_ID,
|
|
methodId: "api-key",
|
|
label: "Tencent TokenPlan",
|
|
hint: "Hy via Tencent TokenPlan Gateway",
|
|
optionKey: "tokenplanApiKey",
|
|
flagName: "--tokenplan-api-key",
|
|
envVar: "TOKENPLAN_API_KEY",
|
|
promptMessage: "Enter Tencent TokenPlan API key",
|
|
defaultModel: TOKENPLAN_DEFAULT_MODEL_REF,
|
|
expectedProviders: [TOKENPLAN_PROVIDER_ID],
|
|
applyConfig: applyTokenPlanConfig,
|
|
wizard: {
|
|
choiceId: "tokenplan-api-key",
|
|
choiceLabel: "Tencent TokenPlan",
|
|
groupId: "tencent",
|
|
groupLabel: "Tencent Cloud",
|
|
groupHint: "Tencent TokenPlan",
|
|
},
|
|
}),
|
|
],
|
|
catalog: {
|
|
order: "simple",
|
|
run: (ctx) =>
|
|
buildSingleProviderApiKeyCatalog({
|
|
ctx,
|
|
providerId: TOKENPLAN_PROVIDER_ID,
|
|
buildProvider: buildTokenPlanProvider,
|
|
}),
|
|
},
|
|
augmentModelCatalog: () =>
|
|
buildStaticCatalogEntries(TOKENPLAN_PROVIDER_ID, TOKENPLAN_MODEL_CATALOG),
|
|
wrapStreamFn: wrapTencentProviderStream,
|
|
});
|
|
},
|
|
});
|