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

Function restoreModelRefs

packages/opencode/script/schema.ts:53–62  ·  view source on GitHub ↗
(value: unknown, key?: string)

Source from the content-addressed store, hash-verified

51}
52
53function restoreModelRefs(value: unknown, key?: string): unknown {
54 if (Array.isArray(value)) return value.map((item) => restoreModelRefs(item))
55 if (!isRecord(value)) return value
56
57 const schema = Object.fromEntries(Object.entries(value).map(([name, item]) => [name, restoreModelRefs(item, name)]))
58 if ((key === "model" || key === "small_model") && schema.type === "string") {
59 return { ...schema, $ref: MODEL_REF }
60 }
61 return schema
62}
63
64function isRecord(value: unknown): value is JsonSchema {
65 return typeof value === "object" && value !== null && !Array.isArray(value)

Callers 1

generateEffectFunction · 0.85

Calls 1

isRecordFunction · 0.70

Tested by

no test coverage detected