Project Files
src / config / resolve-config.ts
/**
* Configuration resolution utilities.
*/
import { AUTO_CONFIG_VALUE } from "./auto-sentinel"
import { configSchematics } from "./config-schematics"
import type { ToolsProviderController } from "@lmstudio/sdk"
/**
* Fully resolved configuration used by a tool invocation.
*/
interface ResolvedConfig {
/** IANA timezone name to use when no per-call override is supplied. `undefined` selects the host system timezone. */
defaultTimezone: string | undefined
}
/**
* Resolves configuration from plugin settings.
*
* @param ctl - Tools provider controller exposing plugin configuration.
* @returns The fully resolved configuration used to drive a request.
*/
export function resolveConfig(ctl: ToolsProviderController): ResolvedConfig {
const pluginConfig = ctl.getPluginConfig(configSchematics)
const pluginTimezone = pluginConfig.get("defaultTimezone") as string | null
return {
defaultTimezone: resolveTimezone(pluginTimezone),
}
}
/**
* Resolve a configured timezone value, treating the auto sentinel and empty strings as unset.
*
* @param pluginValue - Value read from plugin configuration.
* @returns The IANA timezone name, or `undefined` when the host default should apply.
*/
function resolveTimezone(pluginValue: string | null): string | undefined {
if (pluginValue === null || pluginValue === "" || pluginValue === AUTO_CONFIG_VALUE) {
return undefined
}
return pluginValue
}