Buckets:
| import path from "path" | |
| import { describe, expect } from "bun:test" | |
| import { Effect, Layer } from "effect" | |
| import { Catalog } from "@opencode-ai/core/catalog" | |
| import { Integration } from "@opencode-ai/core/integration" | |
| import { Credential } from "@opencode-ai/core/credential" | |
| import { Database } from "@opencode-ai/core/database/database" | |
| import { EventV2 } from "@opencode-ai/core/event" | |
| import { Flag } from "@opencode-ai/core/flag/flag" | |
| import { Location } from "@opencode-ai/core/location" | |
| import { ModelsDev } from "@opencode-ai/core/models-dev" | |
| import { PluginV2 } from "@opencode-ai/core/plugin" | |
| import { ModelsDevPlugin } from "@opencode-ai/core/plugin/models-dev" | |
| import { Policy } from "@opencode-ai/core/policy" | |
| import { AbsolutePath } from "@opencode-ai/core/schema" | |
| import { location } from "../fixture/location" | |
| import { testEffect } from "../lib/effect" | |
| const events = EventV2.defaultLayer | |
| const locationLayer = Layer.succeed( | |
| Location.Service, | |
| Location.Service.of(location({ directory: AbsolutePath.make(import.meta.dir) })), | |
| ) | |
| const plugins = PluginV2.layer.pipe(Layer.provide(events)) | |
| const policy = Policy.layer.pipe(Layer.provide(locationLayer)) | |
| const connections = Credential.layer.pipe( | |
| Layer.fresh, | |
| Layer.provide(Database.layerFromPath(":memory:").pipe(Layer.fresh)), | |
| Layer.provide(events), | |
| ) | |
| const catalog = Catalog.layer.pipe(Layer.provide(Layer.mergeAll(events, locationLayer, plugins, policy, connections))) | |
| const integrations = Integration.locationLayer.pipe(Layer.provide(events), Layer.provide(connections)) | |
| const layer = Layer.mergeAll( | |
| catalog.pipe(Layer.provide(connections)), | |
| integrations, | |
| connections, | |
| events, | |
| locationLayer, | |
| plugins, | |
| ) | |
| const it = testEffect(layer) | |
| describe("ModelsDevPlugin", () => { | |
| it.effect("registers key methods for providers with environment variables", () => | |
| Effect.acquireUseRelease( | |
| Effect.sync(() => { | |
| const previous = { | |
| path: Flag.OPENCODE_MODELS_PATH, | |
| disabled: Flag.OPENCODE_DISABLE_MODELS_FETCH, | |
| } | |
| Flag.OPENCODE_MODELS_PATH = path.join(import.meta.dir, "fixtures", "models-dev.json") | |
| Flag.OPENCODE_DISABLE_MODELS_FETCH = true | |
| return previous | |
| }), | |
| () => | |
| Effect.gen(function* () { | |
| yield* ModelsDevPlugin.effect | |
| const integrations = yield* Integration.Service | |
| expect(yield* integrations.list()).toEqual([ | |
| new Integration.Info({ | |
| id: Integration.ID.make("acme"), | |
| name: "Acme", | |
| methods: [ | |
| new Integration.KeyMethod({ type: "key" }), | |
| new Integration.EnvMethod({ | |
| type: "env", | |
| names: ["ACME_API_KEY"], | |
| }), | |
| ], | |
| connections: [], | |
| }), | |
| ]) | |
| }).pipe(Effect.provide(ModelsDev.defaultLayer)), | |
| (previous) => | |
| Effect.sync(() => { | |
| Flag.OPENCODE_MODELS_PATH = previous.path | |
| Flag.OPENCODE_DISABLE_MODELS_FETCH = previous.disabled | |
| }), | |
| ), | |
| ) | |
| }) | |
Xet Storage Details
- Size:
- 3.07 kB
- Xet hash:
- 765bea4c5b24a05753c38004fd30bf9d8bec849da840435a28de551d2fdcb719
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.