pub struct SettingsManager { /* private fields */ }Expand description
Both scopes and their merged view.
Implementations§
Source§impl SettingsManager
impl SettingsManager
Sourcepub fn load(
agent_dir: &Path,
project_dir: &Path,
project_trusted: bool,
) -> SettingsManager
pub fn load( agent_dir: &Path, project_dir: &Path, project_trusted: bool, ) -> SettingsManager
Loads both scopes, the project’s from project_dir, and that only
when project_trusted.
Sourcepub fn in_memory() -> SettingsManager
pub fn in_memory() -> SettingsManager
Settings with no files behind them.
Sourcepub fn errors(&self) -> &[String]
pub fn errors(&self) -> &[String]
Why settings files failed to load, as pi’s warnings word them.
Sourcepub fn default_tools(&self) -> Option<Vec<String>>
pub fn default_tools(&self) -> Option<Vec<String>>
pi’s getDefaultTools: the tools the merged defaultTools enables, or
None when no scope sets it. A value that is not a list enables none,
and entries that are not strings are skipped.
Sourcepub fn merged_document(&self) -> &Map<String, Value>
pub fn merged_document(&self) -> &Map<String, Value>
Both scopes merged as written, values of any type included: pi’s
settings.
Sourcepub fn default_thinking_level(&self) -> Option<ThinkingLevel>
pub fn default_thinking_level(&self) -> Option<ThinkingLevel>
defaultThinkingLevel, if set: a value that names no level becomes
off, the first level pi’s clamp offers.
Sourcepub fn http_idle_timeout_ms(&self) -> Result<u64, String>
pub fn http_idle_timeout_ms(&self) -> Result<u64, String>
pi’s getHttpIdleTimeoutMs: httpIdleTimeoutMs in milliseconds, as a
number, a numeric string or "disabled" (0), five minutes when unset.
Sourcepub fn websocket_connect_timeout_ms(&self) -> Result<Option<u64>, String>
pub fn websocket_connect_timeout_ms(&self) -> Result<Option<u64>, String>
pi’s getWebSocketConnectTimeoutMs: websocketConnectTimeoutMs, read
as httpIdleTimeoutMs is, or None when unset.
Sourcepub fn provider_timeout_ms(&self) -> Option<f64>
pub fn provider_timeout_ms(&self) -> Option<f64>
retry.provider.timeoutMs when it is a number, unchecked, as pi
passes it on to providers.
Sourcepub fn compaction_error(&self, model: Option<&Model>) -> Option<String>
pub fn compaction_error(&self, model: Option<&Model>) -> Option<String>
pi’s getCompactionTokenSetting checks: the error for a
compaction token setting, or model’s override of one, that is not
a non-negative safe integer.
Sourcepub fn cache_warming_mode(&self) -> CacheWarming
pub fn cache_warming_mode(&self) -> CacheWarming
pi’s getCacheWarmingMode: cacheWarming from the global settings
only, because each refresh costs money, defaulting to streaming when
unset or invalid.
Sourcepub fn project_dir(&self) -> &Path
pub fn project_dir(&self) -> &Path
The directory whose .yapi folder holds the project’s files: the
project’s settings, resources and system prompt files.
Sourcepub fn project_trusted(&self) -> bool
pub fn project_trusted(&self) -> bool
Whether the project scope is loaded.
Sourcepub fn document(&self, scope: Scope) -> &Map<String, Value>
pub fn document(&self, scope: Scope) -> &Map<String, Value>
The settings document of scope as written, empty for an untrusted
project.
Sourcepub fn set(
&mut self,
scope: Scope,
key: &str,
value: Option<Value>,
) -> Result<(), SettingsError>
pub fn set( &mut self, scope: Scope, key: &str, value: Option<Value>, ) -> Result<(), SettingsError>
Sets a top-level key in a scope and writes that file. None removes it.
Sourcepub fn set_nested(
&mut self,
scope: Scope,
field: &str,
key: &str,
value: Option<Value>,
) -> Result<(), SettingsError>
pub fn set_nested( &mut self, scope: Scope, field: &str, key: &str, value: Option<Value>, ) -> Result<(), SettingsError>
Sets key inside the object setting field of scope, keeping its
other keys, and writes that scope’s file. None removes the key and
keeps the object.