( authored: ExistingModel, modelMetadata: Record<string, Record<string, unknown>>, modelPath: string, )
| 472 | } |
| 473 | |
| 474 | function resolveBaseModel( |
| 475 | authored: ExistingModel, |
| 476 | modelMetadata: Record<string, Record<string, unknown>>, |
| 477 | modelPath: string, |
| 478 | ) { |
| 479 | const baseModelID = authored.base_model; |
| 480 | if (baseModelID === undefined) return authored; |
| 481 | |
| 482 | const base = modelMetadata[baseModelID]; |
| 483 | if (base === undefined) { |
| 484 | throw new Error(`Unable to resolve base_model: ${baseModelID}`, { |
| 485 | cause: { modelPath, toml: authored }, |
| 486 | }); |
| 487 | } |
| 488 | |
| 489 | const merged = structuredClone( |
| 490 | mergeDeep( |
| 491 | base, |
| 492 | Object.fromEntries( |
| 493 | Object.entries(authored).filter(([, value]) => value !== undefined), |
| 494 | ), |
| 495 | ), |
| 496 | ) as Record<string, unknown>; |
| 497 | applyOmit(merged, authored.base_model_omit ?? []); |
| 498 | |
| 499 | const parsed = ExistingModel.safeParse(merged); |
| 500 | if (!parsed.success) { |
| 501 | parsed.error.cause = { modelPath, toml: merged }; |
| 502 | throw parsed.error; |
| 503 | } |
| 504 | return parsed.data as ExistingModel; |
| 505 | } |
| 506 | |
| 507 | function inheritableModelMetadata(model: Record<string, unknown>) { |
| 508 | const { |
no test coverage detected