MCPcopy Create free account
hub / github.com/anomalyco/opencode / cloneModel

Function cloneModel

packages/opencode/test/session/llm-native-recorded.test.ts:56–66  ·  view source on GitHub ↗
(model: ModelsDev.Provider["models"][string])

Source from the content-addressed store, hash-verified

54}
55
56const cloneModel = (model: ModelsDev.Provider["models"][string]) => {
57 const cloned = structuredClone(model)
58 const { experimental, ...rest } = cloned
59 // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- The config schema accepts the same model shape except object-valued experimental metadata.
60 if (typeof experimental === "boolean") {
61 // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- The fixture model already matches config input when experimental is boolean.
62 return cloned as NonNullable<NonNullable<ConfigV1.Info["provider"]>[string]["models"]>[string]
63 }
64 // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- Dropping non-boolean experimental metadata makes the fixture model match config input.
65 return rest as NonNullable<NonNullable<ConfigV1.Info["provider"]>[string]["models"]>[string]
66}
67
68const envValue = (...names: string[]) => names.map((name) => process.env[name]).find(Boolean)
69const decodeAuth = Schema.decodeUnknownOption(Auth.Info)

Callers 1

providerConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected