refactor(core): consolidate tool architecture
This commit is contained in:
parent
0fd73a2976
commit
8db7487c89
466 changed files with 9405 additions and 11071 deletions
|
|
@ -2,11 +2,11 @@ import { AISDK } from "@opencode-ai/core/aisdk"
|
|||
import { describe, expect, mock } from "bun:test"
|
||||
import { Effect } from "effect"
|
||||
import { Catalog } from "@opencode-ai/core/catalog"
|
||||
import { ModelV2 } from "@opencode-ai/core/model"
|
||||
import { PluginV2 } from "@opencode-ai/core/plugin"
|
||||
import { Model } from "@opencode-ai/core/model"
|
||||
import { Plugin } from "@opencode-ai/core/plugin"
|
||||
import { PluginHost } from "@opencode-ai/core/plugin/host"
|
||||
import { GitLabPlugin } from "@opencode-ai/core/plugin/provider/gitlab"
|
||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||
import { Provider } from "@opencode-ai/core/provider"
|
||||
import { testEffect } from "../lib/effect"
|
||||
import { PluginTestLayer } from "./fixture"
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ const gitlabSDKOptions: Record<string, unknown>[] = []
|
|||
const it = testEffect(PluginTestLayer)
|
||||
|
||||
const addPlugin = Effect.fn(function* () {
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
const host = yield* PluginHost.make(plugin)
|
||||
yield* GitLabPlugin.effect(host)
|
||||
|
|
@ -64,13 +64,13 @@ describe("GitLabPlugin", () => {
|
|||
() =>
|
||||
Effect.gen(function* () {
|
||||
gitlabSDKOptions.length = 0
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
yield* addPlugin()
|
||||
yield* aisdk.runSDK({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("claude")),
|
||||
modelID: ModelV2.ID.make("claude"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("claude")),
|
||||
modelID: Model.ID.make("claude"),
|
||||
package: "aisdk:test-provider",
|
||||
}),
|
||||
package: "gitlab-ai-provider",
|
||||
|
|
@ -102,13 +102,13 @@ describe("GitLabPlugin", () => {
|
|||
() =>
|
||||
Effect.gen(function* () {
|
||||
gitlabSDKOptions.length = 0
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
yield* addPlugin()
|
||||
yield* aisdk.runSDK({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("claude")),
|
||||
modelID: ModelV2.ID.make("claude"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("claude")),
|
||||
modelID: Model.ID.make("claude"),
|
||||
package: "aisdk:test-provider",
|
||||
}),
|
||||
package: "gitlab-ai-provider",
|
||||
|
|
@ -128,13 +128,13 @@ describe("GitLabPlugin", () => {
|
|||
() =>
|
||||
Effect.gen(function* () {
|
||||
gitlabSDKOptions.length = 0
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
yield* addPlugin()
|
||||
yield* aisdk.runSDK({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("claude")),
|
||||
modelID: ModelV2.ID.make("claude"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("claude")),
|
||||
modelID: Model.ID.make("claude"),
|
||||
package: "aisdk:test-provider",
|
||||
}),
|
||||
package: "gitlab-ai-provider",
|
||||
|
|
@ -170,13 +170,13 @@ describe("GitLabPlugin", () => {
|
|||
it.effect("ignores non-GitLab SDK packages", () =>
|
||||
Effect.gen(function* () {
|
||||
gitlabSDKOptions.length = 0
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
yield* addPlugin()
|
||||
const result = yield* aisdk.runSDK({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("claude")),
|
||||
modelID: ModelV2.ID.make("claude"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("claude")),
|
||||
modelID: Model.ID.make("claude"),
|
||||
package: "aisdk:test-provider",
|
||||
}),
|
||||
package: "@ai-sdk/openai",
|
||||
|
|
@ -189,14 +189,14 @@ describe("GitLabPlugin", () => {
|
|||
|
||||
it.effect("uses workflowChat for duo workflow models and preserves selectedModelRef", () =>
|
||||
Effect.gen(function* () {
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
const calls: [string, unknown][] = []
|
||||
yield* addPlugin()
|
||||
const result = yield* aisdk.runLanguage({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("duo-workflow-custom")),
|
||||
modelID: ModelV2.ID.make("duo-workflow-custom"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("duo-workflow-custom")),
|
||||
modelID: Model.ID.make("duo-workflow-custom"),
|
||||
package: "aisdk:test-provider",
|
||||
headers: {},
|
||||
settings: { workflowRef: "ref", workflowDefinition: "definition" },
|
||||
|
|
@ -223,14 +223,14 @@ describe("GitLabPlugin", () => {
|
|||
|
||||
it.effect("uses exact static workflow model ids when the provider recognizes them", () =>
|
||||
Effect.gen(function* () {
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
const calls: [string, unknown][] = []
|
||||
yield* addPlugin()
|
||||
const result = yield* aisdk.runLanguage({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("duo-workflow-exact")),
|
||||
modelID: ModelV2.ID.make("duo-workflow-exact"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("duo-workflow-exact")),
|
||||
modelID: Model.ID.make("duo-workflow-exact"),
|
||||
package: "aisdk:test-provider",
|
||||
}),
|
||||
sdk: {
|
||||
|
|
@ -251,14 +251,14 @@ describe("GitLabPlugin", () => {
|
|||
|
||||
it.effect("uses provider feature flags instead of model settings feature flags", () =>
|
||||
Effect.gen(function* () {
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
const calls: [string, unknown][] = []
|
||||
yield* addPlugin()
|
||||
yield* aisdk.runLanguage({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("duo-workflow-custom")),
|
||||
modelID: ModelV2.ID.make("duo-workflow-custom"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("duo-workflow-custom")),
|
||||
modelID: Model.ID.make("duo-workflow-custom"),
|
||||
package: "aisdk:test-provider",
|
||||
headers: {},
|
||||
settings: { featureFlags: { request_flag: true } },
|
||||
|
|
@ -278,14 +278,14 @@ describe("GitLabPlugin", () => {
|
|||
|
||||
it.effect("uses agenticChat with provider aiGatewayHeaders and feature flags for normal models", () =>
|
||||
Effect.gen(function* () {
|
||||
const plugin = yield* PluginV2.Service
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
const calls: [string, unknown][] = []
|
||||
yield* addPlugin()
|
||||
yield* aisdk.runLanguage({
|
||||
model: ModelV2.Info.make({
|
||||
...ModelV2.Info.default(ProviderV2.ID.make("gitlab"), ModelV2.ID.make("claude")),
|
||||
modelID: ModelV2.ID.make("claude"),
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("gitlab"), Model.ID.make("claude")),
|
||||
modelID: Model.ID.make("claude"),
|
||||
package: "aisdk:test-provider",
|
||||
headers: { h: "v" },
|
||||
settings: {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue