Class AtomicConfigStore
Multi-process-safe JSON configuration file manager for JD.AI. Uses file-level locking for cross-process safety and a SemaphoreSlim for in-process concurrency. Writes are atomic: data is written to a temporary file then moved into place.
public sealed class AtomicConfigStore : IDisposable
- Inheritance
-
AtomicConfigStore
- Implements
- Inherited Members
Constructors
AtomicConfigStore(string?)
Creates a new AtomicConfigStore.
public AtomicConfigStore(string? configPath = null)
Parameters
configPathstringFull path to the JSON config file, or
nullto use the default~/.jdai/config.json.
Methods
AddToolPermissionRuleAsync(string, bool, bool, string?, CancellationToken)
Adds an allow/deny rule for tool execution in global or project scope.
public Task AddToolPermissionRuleAsync(string toolPattern, bool allow, bool projectScope, string? projectPath = null, CancellationToken ct = default)
Parameters
toolPatternstringallowboolprojectScopeboolprojectPathstringctCancellationToken
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetDefaultModelAsync(string?, CancellationToken)
Gets the default model, optionally scoped to a project path.
public Task<string?> GetDefaultModelAsync(string? projectPath = null, CancellationToken ct = default)
Parameters
projectPathstringctCancellationToken
Returns
GetDefaultProviderAsync(string?, CancellationToken)
Gets the default provider, optionally scoped to a project path.
public Task<string?> GetDefaultProviderAsync(string? projectPath = null, CancellationToken ct = default)
Parameters
projectPathstringctCancellationToken
Returns
GetDefaultShellAsync(string?, CancellationToken)
Gets the default shell, optionally scoped to a project path.
public Task<string?> GetDefaultShellAsync(string? projectPath = null, CancellationToken ct = default)
Parameters
projectPathstringctCancellationToken
Returns
GetToolPermissionProfileAsync(string?, CancellationToken)
Gets explicit tool permissions resolved for global + project scope.
public Task<ToolPermissionProfile> GetToolPermissionProfileAsync(string? projectPath = null, CancellationToken ct = default)
Parameters
projectPathstringctCancellationToken
Returns
ReadAsync(CancellationToken)
Reads the current configuration, returning an empty config when the file does not exist.
public Task<JdAiConfig> ReadAsync(CancellationToken ct = default)
Parameters
Returns
SetDefaultModelAsync(string, string?, CancellationToken)
Sets the default model, optionally scoped to a project path.
public Task SetDefaultModelAsync(string model, string? projectPath = null, CancellationToken ct = default)
Parameters
modelstringprojectPathstringctCancellationToken
Returns
SetDefaultProviderAsync(string, string?, CancellationToken)
Sets the default provider, optionally scoped to a project path.
public Task SetDefaultProviderAsync(string provider, string? projectPath = null, CancellationToken ct = default)
Parameters
providerstringprojectPathstringctCancellationToken
Returns
SetDefaultShellAsync(string, string?, CancellationToken)
Sets the default shell, optionally scoped to a project path.
public Task SetDefaultShellAsync(string shell, string? projectPath = null, CancellationToken ct = default)
Parameters
shellstringprojectPathstringctCancellationToken
Returns
WriteAsync(Action<JdAiConfig>, CancellationToken)
Atomically mutates the configuration. The mutate action receives
the current config (read under lock) and should apply changes in-place.
public Task WriteAsync(Action<JdAiConfig> mutate, CancellationToken ct = default)
Parameters
mutateAction<JdAiConfig>ctCancellationToken