refactor(core): use Predicate.isReadonlyObject for settings guard
This commit is contained in:
parent
38398fd450
commit
759db0d172
1 changed files with 2 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ export * as SessionRunnerModel from "./model"
|
|||
|
||||
import { makeLocationNode } from "../../effect/app-node"
|
||||
import { Model } from "@opencode-ai/llm"
|
||||
import { Context, Effect, Layer, Schema } from "effect"
|
||||
import { Context, Effect, Layer, Predicate, Schema } from "effect"
|
||||
import { produce } from "immer"
|
||||
import { Catalog } from "../../catalog"
|
||||
import { Credential } from "../../credential"
|
||||
|
|
@ -186,7 +186,7 @@ const stripApiKey = (body: ModelV2.Info["request"]["body"]) => {
|
|||
const requestSettings = (request: ModelV2.Info["request"]) => {
|
||||
if (!("settings" in request)) return undefined
|
||||
const settings = request.settings
|
||||
if (!isRecord(settings)) return undefined
|
||||
if (!Predicate.isReadonlyObject(settings)) return undefined
|
||||
if (Object.keys(settings).length === 0) return undefined
|
||||
return settings
|
||||
}
|
||||
|
|
@ -197,10 +197,6 @@ const settingsString = (settings: ModelV2.Info["api"]["settings"], key: string)
|
|||
return undefined
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
/** Resolves models from the catalog belonging to the current Location runtime. */
|
||||
export const locationLayer = Layer.effect(
|
||||
Service,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue