mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 00:30:45 +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
6
openclaw/extensions/qianfan/api.ts
Normal file
6
openclaw/extensions/qianfan/api.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export {
|
||||
QIANFAN_BASE_URL,
|
||||
QIANFAN_DEFAULT_MODEL_ID,
|
||||
buildQianfanProvider,
|
||||
} from "./provider-catalog.js";
|
||||
export { QIANFAN_DEFAULT_MODEL_REF } from "./onboard.js";
|
||||
31
openclaw/extensions/qianfan/index.ts
Normal file
31
openclaw/extensions/qianfan/index.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
||||
import { applyQianfanConfig, QIANFAN_DEFAULT_MODEL_REF } from "./onboard.js";
|
||||
import { buildQianfanProvider } from "./provider-catalog.js";
|
||||
|
||||
const PROVIDER_ID = "qianfan";
|
||||
|
||||
export default defineSingleProviderPluginEntry({
|
||||
id: PROVIDER_ID,
|
||||
name: "Qianfan Provider",
|
||||
description: "Bundled Qianfan provider plugin",
|
||||
provider: {
|
||||
label: "Qianfan",
|
||||
docsPath: "/providers/qianfan",
|
||||
auth: [
|
||||
{
|
||||
methodId: "api-key",
|
||||
label: "Qianfan API key",
|
||||
hint: "API key",
|
||||
optionKey: "qianfanApiKey",
|
||||
flagName: "--qianfan-api-key",
|
||||
envVar: "QIANFAN_API_KEY",
|
||||
promptMessage: "Enter Qianfan API key",
|
||||
defaultModel: QIANFAN_DEFAULT_MODEL_REF,
|
||||
applyConfig: (cfg) => applyQianfanConfig(cfg),
|
||||
},
|
||||
],
|
||||
catalog: {
|
||||
buildProvider: buildQianfanProvider,
|
||||
},
|
||||
},
|
||||
});
|
||||
61
openclaw/extensions/qianfan/onboard.ts
Normal file
61
openclaw/extensions/qianfan/onboard.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import {
|
||||
createDefaultModelsPresetAppliers,
|
||||
type ModelApi,
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/provider-onboard";
|
||||
import {
|
||||
buildQianfanProvider,
|
||||
QIANFAN_BASE_URL,
|
||||
QIANFAN_DEFAULT_MODEL_ID,
|
||||
} from "./provider-catalog.js";
|
||||
|
||||
export const QIANFAN_DEFAULT_MODEL_REF = `qianfan/${QIANFAN_DEFAULT_MODEL_ID}`;
|
||||
|
||||
function resolveQianfanPreset(cfg: OpenClawConfig): {
|
||||
api: ModelApi;
|
||||
baseUrl: string;
|
||||
defaultModels: NonNullable<ReturnType<typeof buildQianfanProvider>["models"]>;
|
||||
} {
|
||||
const defaultProvider = buildQianfanProvider();
|
||||
const existingProvider = cfg.models?.providers?.qianfan as
|
||||
| {
|
||||
baseUrl?: unknown;
|
||||
api?: unknown;
|
||||
}
|
||||
| undefined;
|
||||
const existingBaseUrl =
|
||||
typeof existingProvider?.baseUrl === "string" ? existingProvider.baseUrl.trim() : "";
|
||||
const api =
|
||||
typeof existingProvider?.api === "string"
|
||||
? (existingProvider.api as ModelApi)
|
||||
: "openai-completions";
|
||||
|
||||
return {
|
||||
api,
|
||||
baseUrl: existingBaseUrl || QIANFAN_BASE_URL,
|
||||
defaultModels: defaultProvider.models ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
const qianfanPresetAppliers = createDefaultModelsPresetAppliers({
|
||||
primaryModelRef: QIANFAN_DEFAULT_MODEL_REF,
|
||||
resolveParams: (cfg: OpenClawConfig) => {
|
||||
const preset = resolveQianfanPreset(cfg);
|
||||
return {
|
||||
providerId: "qianfan",
|
||||
api: preset.api,
|
||||
baseUrl: preset.baseUrl,
|
||||
defaultModels: preset.defaultModels,
|
||||
defaultModelId: QIANFAN_DEFAULT_MODEL_ID,
|
||||
aliases: [{ modelRef: QIANFAN_DEFAULT_MODEL_REF, alias: "QIANFAN" }],
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export function applyQianfanProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
return qianfanPresetAppliers.applyProviderConfig(cfg);
|
||||
}
|
||||
|
||||
export function applyQianfanConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
return qianfanPresetAppliers.applyConfig(cfg);
|
||||
}
|
||||
28
openclaw/extensions/qianfan/openclaw.plugin.json
Normal file
28
openclaw/extensions/qianfan/openclaw.plugin.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"id": "qianfan",
|
||||
"enabledByDefault": true,
|
||||
"providers": ["qianfan"],
|
||||
"providerAuthEnvVars": {
|
||||
"qianfan": ["QIANFAN_API_KEY"]
|
||||
},
|
||||
"providerAuthChoices": [
|
||||
{
|
||||
"provider": "qianfan",
|
||||
"method": "api-key",
|
||||
"choiceId": "qianfan-api-key",
|
||||
"choiceLabel": "Qianfan API key",
|
||||
"groupId": "qianfan",
|
||||
"groupLabel": "Qianfan",
|
||||
"groupHint": "API key",
|
||||
"optionKey": "qianfanApiKey",
|
||||
"cliFlag": "--qianfan-api-key",
|
||||
"cliOption": "--qianfan-api-key <key>",
|
||||
"cliDescription": "QIANFAN API key"
|
||||
}
|
||||
],
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
15
openclaw/extensions/qianfan/package.json
Normal file
15
openclaw/extensions/qianfan/package.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "@openclaw/qianfan-provider",
|
||||
"version": "2026.4.20",
|
||||
"private": true,
|
||||
"description": "OpenClaw Qianfan provider plugin",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@openclaw/plugin-sdk": "workspace:*"
|
||||
},
|
||||
"openclaw": {
|
||||
"extensions": [
|
||||
"./index.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
39
openclaw/extensions/qianfan/provider-catalog.ts
Normal file
39
openclaw/extensions/qianfan/provider-catalog.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
|
||||
export const QIANFAN_BASE_URL = "https://qianfan.baidubce.com/v2";
|
||||
export const QIANFAN_DEFAULT_MODEL_ID = "deepseek-v3.2";
|
||||
const QIANFAN_DEFAULT_CONTEXT_WINDOW = 98304;
|
||||
const QIANFAN_DEFAULT_MAX_TOKENS = 32768;
|
||||
const QIANFAN_DEFAULT_COST = {
|
||||
input: 0,
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
};
|
||||
|
||||
export function buildQianfanProvider(): ModelProviderConfig {
|
||||
return {
|
||||
baseUrl: QIANFAN_BASE_URL,
|
||||
api: "openai-completions",
|
||||
models: [
|
||||
{
|
||||
id: QIANFAN_DEFAULT_MODEL_ID,
|
||||
name: "DEEPSEEK V3.2",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
cost: QIANFAN_DEFAULT_COST,
|
||||
contextWindow: QIANFAN_DEFAULT_CONTEXT_WINDOW,
|
||||
maxTokens: QIANFAN_DEFAULT_MAX_TOKENS,
|
||||
},
|
||||
{
|
||||
id: "ernie-5.0-thinking-preview",
|
||||
name: "ERNIE-5.0-Thinking-Preview",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
cost: QIANFAN_DEFAULT_COST,
|
||||
contextWindow: 119000,
|
||||
maxTokens: 64000,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
16
openclaw/extensions/qianfan/tsconfig.json
Normal file
16
openclaw/extensions/qianfan/tsconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"extends": "../tsconfig.package-boundary.base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": ["./*.ts", "./src/**/*.ts"],
|
||||
"exclude": [
|
||||
"./**/*.test.ts",
|
||||
"./dist/**",
|
||||
"./node_modules/**",
|
||||
"./src/test-support/**",
|
||||
"./src/**/*test-helpers.ts",
|
||||
"./src/**/*test-harness.ts",
|
||||
"./src/**/*test-support.ts"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue