mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:30:42 +00:00
fix(copilot): refresh live discovery config
This commit is contained in:
@@ -61,7 +61,17 @@ describe("github-copilot plugin", () => {
|
||||
const provider = registerProviderWithPluginConfig({ discovery: { enabled: false } });
|
||||
|
||||
const result = await provider.catalog.run({
|
||||
config: {},
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
"github-copilot": {
|
||||
config: {
|
||||
discovery: { enabled: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
agentDir: "/tmp/agent",
|
||||
env: { GH_TOKEN: "gh_test_token" },
|
||||
resolveProviderApiKey: () => ({ apiKey: "gh_test_token" }),
|
||||
@@ -70,4 +80,40 @@ describe("github-copilot plugin", () => {
|
||||
expect(result).toBeNull();
|
||||
expect(resolveCopilotApiTokenMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("uses live plugin config to re-enable discovery after startup disable", async () => {
|
||||
resolveCopilotApiTokenMock.mockResolvedValueOnce({
|
||||
token: "copilot_api_token",
|
||||
baseUrl: "https://api.githubcopilot.live",
|
||||
});
|
||||
const provider = registerProviderWithPluginConfig({ discovery: { enabled: false } });
|
||||
|
||||
const result = await provider.catalog.run({
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
"github-copilot": {
|
||||
config: {
|
||||
discovery: { enabled: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
agentDir: "/tmp/agent",
|
||||
env: { GH_TOKEN: "gh_test_token" },
|
||||
resolveProviderApiKey: () => ({ apiKey: "gh_test_token" }),
|
||||
} as never);
|
||||
|
||||
expect(resolveCopilotApiTokenMock).toHaveBeenCalledWith({
|
||||
githubToken: "gh_test_token",
|
||||
env: { GH_TOKEN: "gh_test_token" },
|
||||
});
|
||||
expect(result).toEqual({
|
||||
provider: {
|
||||
baseUrl: "https://api.githubcopilot.live",
|
||||
models: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
resolvePluginConfigObject,
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/config-runtime";
|
||||
import { definePluginEntry, type ProviderAuthContext } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { ensureAuthProfileStore } from "openclaw/plugin-sdk/provider-auth";
|
||||
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime";
|
||||
@@ -24,7 +28,15 @@ export default definePluginEntry({
|
||||
name: "GitHub Copilot Provider",
|
||||
description: "Bundled GitHub Copilot provider plugin",
|
||||
register(api) {
|
||||
const pluginConfig = (api.pluginConfig ?? {}) as GithubCopilotPluginConfig;
|
||||
const startupPluginConfig = (api.pluginConfig ?? {}) as GithubCopilotPluginConfig;
|
||||
|
||||
function resolveCurrentPluginConfig(config?: OpenClawConfig): GithubCopilotPluginConfig {
|
||||
const runtimePluginConfig = resolvePluginConfigObject(config, "github-copilot");
|
||||
if (runtimePluginConfig) {
|
||||
return runtimePluginConfig as GithubCopilotPluginConfig;
|
||||
}
|
||||
return config ? {} : startupPluginConfig;
|
||||
}
|
||||
|
||||
async function runGitHubCopilotAuth(ctx: ProviderAuthContext) {
|
||||
const { githubCopilotLoginCommand } = await loadGithubCopilotRuntime();
|
||||
@@ -100,6 +112,7 @@ export default definePluginEntry({
|
||||
catalog: {
|
||||
order: "late",
|
||||
run: async (ctx) => {
|
||||
const pluginConfig = resolveCurrentPluginConfig(ctx.config);
|
||||
const discoveryEnabled =
|
||||
pluginConfig.discovery?.enabled ?? ctx.config?.models?.copilotDiscovery?.enabled;
|
||||
if (discoveryEnabled === false) {
|
||||
|
||||
Reference in New Issue
Block a user