mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:50:49 +00:00
fix: register opencode image understanding
This commit is contained in:
@@ -1,10 +1,31 @@
|
||||
import { getModels } from "@mariozechner/pi-ai";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js";
|
||||
import { registerProviderPlugin } from "../../test/helpers/plugins/provider-registration.js";
|
||||
import { expectPassthroughReplayPolicy } from "../../test/helpers/provider-replay-policy.ts";
|
||||
import plugin from "./index.js";
|
||||
|
||||
describe("opencode-go provider plugin", () => {
|
||||
it("registers image media understanding through the OpenCode Go plugin", async () => {
|
||||
const { mediaProviders } = await registerProviderPlugin({
|
||||
plugin,
|
||||
id: "opencode-go",
|
||||
name: "OpenCode Go Provider",
|
||||
});
|
||||
|
||||
expect(mediaProviders).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "opencode-go",
|
||||
capabilities: ["image"],
|
||||
defaultModels: { image: "kimi-k2.5" },
|
||||
describeImage: expect.any(Function),
|
||||
describeImages: expect.any(Function),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("owns passthrough-gemini replay policy for Gemini-backed models", async () => {
|
||||
await expectPassthroughReplayPolicy({
|
||||
plugin,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createOpencodeCatalogApiKeyAuthMethod } from "openclaw/plugin-sdk/openc
|
||||
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { PASSTHROUGH_GEMINI_REPLAY_HOOKS } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { applyOpencodeGoConfig, OPENCODE_GO_DEFAULT_MODEL_REF } from "./api.js";
|
||||
import { opencodeGoMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
||||
import { normalizeOpencodeGoBaseUrl } from "./provider-catalog.js";
|
||||
|
||||
const PROVIDER_ID = "opencode-go";
|
||||
@@ -62,5 +63,6 @@ export default definePluginEntry({
|
||||
...PASSTHROUGH_GEMINI_REPLAY_HOOKS,
|
||||
isModernModelRef: () => true,
|
||||
});
|
||||
api.registerMediaUnderstandingProvider(opencodeGoMediaUnderstandingProvider);
|
||||
},
|
||||
});
|
||||
|
||||
16
extensions/opencode-go/media-understanding-provider.test.ts
Normal file
16
extensions/opencode-go/media-understanding-provider.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { opencodeGoMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
||||
|
||||
describe("opencode-go media understanding provider", () => {
|
||||
it("declares image understanding support", () => {
|
||||
expect(opencodeGoMediaUnderstandingProvider).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "opencode-go",
|
||||
capabilities: ["image"],
|
||||
defaultModels: { image: "kimi-k2.5" },
|
||||
describeImage: expect.any(Function),
|
||||
describeImages: expect.any(Function),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
15
extensions/opencode-go/media-understanding-provider.ts
Normal file
15
extensions/opencode-go/media-understanding-provider.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import {
|
||||
describeImageWithModel,
|
||||
describeImagesWithModel,
|
||||
type MediaUnderstandingProvider,
|
||||
} from "openclaw/plugin-sdk/media-understanding";
|
||||
|
||||
export const opencodeGoMediaUnderstandingProvider: MediaUnderstandingProvider = {
|
||||
id: "opencode-go",
|
||||
capabilities: ["image"],
|
||||
defaultModels: {
|
||||
image: "kimi-k2.5",
|
||||
},
|
||||
describeImage: describeImageWithModel,
|
||||
describeImages: describeImagesWithModel,
|
||||
};
|
||||
@@ -20,6 +20,17 @@
|
||||
"cliDescription": "OpenCode API key (Go catalog)"
|
||||
}
|
||||
],
|
||||
"contracts": {
|
||||
"mediaUnderstandingProviders": ["opencode-go"]
|
||||
},
|
||||
"mediaUnderstandingProviderMetadata": {
|
||||
"opencode-go": {
|
||||
"capabilities": ["image"],
|
||||
"defaultModels": {
|
||||
"image": "kimi-k2.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { describePluginRegistrationContract } from "../../test/helpers/plugins/plugin-registration-contract.js";
|
||||
|
||||
describePluginRegistrationContract({
|
||||
pluginId: "opencode-go",
|
||||
providerIds: ["opencode-go"],
|
||||
mediaUnderstandingProviderIds: ["opencode-go"],
|
||||
requireDescribeImages: true,
|
||||
});
|
||||
Reference in New Issue
Block a user