Skip to main content

Crate codewhale_config

Crate codewhale_config 

Source

Re-exports§

pub use model_reference::Modality;
pub use model_reference::ModelReferenceCard;
pub use model_reference::ModelReferenceDatabase;
pub use setup_state::ConstitutionAuthoring;
pub use setup_state::ConstitutionChoice;
pub use setup_state::ConstitutionSource;
pub use setup_state::ConstitutionValidity;
pub use setup_state::InheritedConfigFacts;
pub use setup_state::RuntimePostureSource;
pub use setup_state::SetupState;
pub use setup_state::SetupStep;
pub use setup_state::StepEntry;
pub use setup_state::StepStatus;
pub use setup_state::TELEMETRY_NOTICE_VERSION;
pub use user_constitution::APPROX_BYTES_PER_TOKEN;
pub use user_constitution::AutonomyPreference;
pub use user_constitution::CacheProjection;
pub use user_constitution::ClauseOrigin;
pub use user_constitution::ClauseStatus;
pub use user_constitution::ConstitutionClause;
pub use user_constitution::ConstitutionRecommendation;
pub use user_constitution::MigrationOutcome;
pub use user_constitution::MigrationReceipt;
pub use user_constitution::MigrationRejection;
pub use user_constitution::Ratification;
pub use user_constitution::RatificationError;
pub use user_constitution::RecommendationParse;
pub use user_constitution::USER_CONSTITUTION_SCHEMA_VERSION;
pub use user_constitution::USER_CONSTITUTION_SCHEMA_VERSION_V1;
pub use user_constitution::UntrustedDraftParse;
pub use user_constitution::UserConstitution;
pub use user_constitution::UserConstitutionLoad;
pub use app_mode::AppMode;
pub use auth_source::AuthSourceKind;
pub use auth_source::ProviderAuthSourceToml;
pub use external_credentials::EXTERNAL_CREDENTIAL_READ_ONLY_SEMANTICS;
pub use external_credentials::ExternalCredentialAccess;
pub use external_credentials::ExternalCredentialConsentStatus;
pub use external_credentials::ExternalCredentialConsentToml;
pub use external_credentials::ExternalCredentialReadGrant;
pub use external_credentials::ExternalCredentialSource;
pub use external_credentials::default_agy_credentials_path;
pub use external_credentials::default_dsh_credentials_path;
pub use external_credentials::quote_os_path;
pub use external_credentials::resolve_external_credential_path;

Modules§

app_mode
The TUI’s user-facing operating mode. Lives in codewhale-config so settings, receipts, and other crates can name it without depending on the TUI; the TUI adds the localized picker strings through an extension trait.
auth_source
auto_model
Legacy DeepSeek-scoped prompt complexity classifier.
catalog
Models.dev-backed provider catalog snapshots and a secret-free live cache (#3385, feeding EPIC #2608 and #3383).
external_credentials
model_reference
Factual model reference database (#3205, #2300).
models_dev
Models.dev catalog schema and helpers.
persistence
Transactional persistence, atomic writes, and secret redaction for the v0.8.67 constitution-first setup lane (#3410).
pricing
Provider/offering-scoped pricing projection with provenance (#3085).
provider
Built-in provider metadata.
route
Route foundation: additive, runtime-unwired types for EPIC #2608.
setup_state
Unified setup-state model for the v0.8.67 constitution-first setup lane (#3403).
user_constitution
Structured user-global constitution and its deterministic renderer (#3793).

Structs§

AdvisorConfigToml
On-disk schema for [advisor] (#3982).
CliRuntimeOverrides
ConfigMigration
ConfigStore
ConfigToml
CustomLspDef
User-defined LSP server for one file extension (used inside LspConfigToml::custom).
FleetConfigToml
On-disk schema for the [fleet] table (#3165). See config.example.toml and docs/FLEET.md for documentation.
FleetDelegationHints
Delegation hints for future fleet manager scheduling.
FleetExecConfig
Headless worker execution constraints (#3027).
FleetProfile
Fleet org-chart profile.
FleetProfilePermissions
Safe permission defaults attached to a fleet profile.
FleetRole
Semantic role declaration for a fleet profile.
FleetRolePreset
A named role preset that bundles common worker settings.
HarnessPosture
A concrete harness posture with policy knobs.
HarnessProfile
A harness profile binds a posture to a provider route and model pattern.
HookSinksToml
On-disk schema for the [hook_sinks] table.
HotbarBinding
Validated hotbar binding used by future render/dispatch layers.
HotbarBindingToml
On-disk schema for one [[hotbar]] table.
HotbarConfigResolution
LspConfigToml
On-disk schema for the [lsp] table (#136). See config.example.toml for documentation. All fields are optional so the TUI runtime can fall back to its own defaults when keys are absent.
NamedFleetConfigToml
On-disk schema for a single named Fleet entry under [fleets.<name>] (#5039).
NetworkPolicyToml
On-disk schema for the [network] table (#135). See config.example.toml for documentation.
PermissionsSnapshot
A parsed, read-only view of the active sibling permissions.toml.
PermissionsToml
Sibling permissions.toml schema.
ProviderChain
Ordered primary-plus-fallback provider list for future provider routing.
ProviderConfigToml
ProvidersToml
ResolvedRuntimeOptions
Secrets
High-level facade combining a KeyringStore with environment variable fallbacks.
SkillsToml
On-disk schema for the [skills] table (#140). See config.example.toml for documentation.
SnapshotsToml
On-disk schema for the [snapshots] table (#137). See config.example.toml for documentation.
StateMigration
ToolAskRule
Typed rule that controls whether a tool invocation is denied, allowed, or requires approval.
ToolsToml
On-disk schema for the [tools] table (#2076).
VerifierConfigToml
On-disk schema for [verifier].
WorkflowConfigToml
On-disk schema for the [workflow] table (#4128 / Section 2.11).
XaiOAuthCredentialStore
Stable handle to Codewhale’s private xAI OAuth directory.
XaiOAuthRevocation
Files retired from an active xAI OAuth epoch before a mode switch commits.

Enums§

ConfigApiKeyValueKind
Canonical structural classification for configured API-key values.
FleetLoadout
Model class or route-role hint for a profile.
FleetResolutionError
Error returned when a named Fleet or operator cannot be resolved (#5039).
FleetSlot
Org-chart slot for grouping fleet profiles.
HarnessCompactionStrategy
How this posture should approach compaction and prompt-cache stability.
HarnessPostureKind
Kinds of built-in harness postures.
HarnessSafetyPosture
Safety posture applied when the runtime consumes a harness profile.
HarnessToolSurface
Which tool catalog shape this posture prefers.
HotbarConfigWarning
Non-fatal hotbar config issue. Invalid slots are skipped; duplicate slots use the last binding; unknown actions are kept for UI feedback.
ModelSource
Where the resolved runtime model id came from.
PermissionsFileState
On-disk state of the active sibling permissions.toml.
ProjectConfigOutcome
What load_project_config_outcome found in the workspace.
ProviderKind
ProviderSource
RuntimeApiKeySource
StateMigrationKind
VerifierVerdictPolicy
Verdict policy for the verifier-preview surface (#2093).

Constants§

API_KEYRING_SENTINEL
Secret-store routing metadata; never credential material.
CODEWHALE_APP_DIR
Canonical Codewhale app directory name under the user home.
CONFIG_FILE_NAME
DEFAULT_HOTBAR_ACTIONS
DEFAULT_SPAWN_DEPTH
Canonical recursion-depth policy for the headless worker runtime.
DEFAULT_STREAM_CHUNK_TIMEOUT_SECS
DEFAULT_TELEMETRY_ENDPOINT
Where an enabled session’s batches go when nobody has said otherwise.
FLEET_DEFAULT_MAX_TURNS
Default finite step budget for Fleet workers. Individual tasks can lower this via budget.max_tool_calls; the session-level config max_turns acts as the hard ceiling. Set the config value to 0 to disable the cap.
HOTBAR_SLOT_COUNT
LEGACY_APP_DIR
Legacy DeepSeek-branded directory retained for compatibility reads.
LEGACY_XAI_OAUTH_FILE_NAME
MAX_SPAWN_DEPTH_CEILING
Hard ceiling on recursion depth for any worker/sub-agent. The default stays conservative at DEFAULT_SPAWN_DEPTH, while explicit config can opt into deeper trees for direct-API providers that can tolerate the fanout. Raising this single constant lifts the limit everywhere (the fleet clamp and agent validation both read it).
MAX_STREAM_CHUNK_TIMEOUT_SECS
MIN_STREAM_CHUNK_TIMEOUT_SECS
OPENCODE_GO_CHAT_MODELS
OpenCode Go models documented for its OpenAI Chat Completions endpoint.
PERMISSIONS_FILE_NAME
TELEMETRY_FLOOR_ENV
The dispatcher’s statement to the TUI child about why telemetry is off.
XAI_OAUTH_GENERATION_PREFIX
XAI_OAUTH_GENERATION_SUFFIX

Functions§

auth_mode_disables_api_key
Whether an authentication mode explicitly disables upstream provider auth.
auth_mode_requires_api_key
Whether an authentication mode requires API-key material.
auth_mode_uses_kimi_imported_token
Whether an authentication mode selects Kimi’s imported bearer token.
built_in_harness_profiles
Built-in profile seeds for common provider/model families.
built_in_role_presets
Built-in role presets that are always available without config.
classify_config_api_key_value
clear_all_xai_oauth_credentials
Explicit logout policy: remove the legacy Codewhale-owned file and every valid generated xAI OAuth file. Unknown files in the credentials directory are never touched.
codewhale_home
Resolve the primary CodeWhale home directory.
codewhale_home_is_explicit
Whether $CODEWHALE_HOME is set to a non-empty value.
config_path_is_workspace_scoped
Whether path names a workspace-scoped config document — <repo>/.codewhale/config.toml (or the legacy .deepseek layout) inside a checkout — rather than a user-global config file.
create_config_document
Create a config file only if it is still absent when the shared lock is acquired. This closes the exists()/create race in first-run writers.
default_config_path
default_hotbar_bindings
default_hotbar_bindings_toml
The default hotbar slots in on-disk ([[hotbar]]) form. Since #3807 an absent hotbar key means “hidden”, so /hotbar on persists these explicit bindings rather than deleting the key. Kept in terms of default_hotbar_bindings so DEFAULT_HOTBAR_ACTIONS stays the single source of truth.
default_secrets
Process-wide default Secrets façade. The first caller wins; the lock is exposed so test or CLI code can install an explicit backend (e.g. an codewhale_secrets::InMemoryKeyringStore) before any resolver runs.
ensure_project_state_dir
Ensure a project-local state subdirectory exists under .codewhale/, creating it if necessary. Returns the directory path.
ensure_state_dir
Ensure a state subdirectory exists under the primary CodeWhale root, creating it if necessary. This is the write-path resolver.
ensure_state_dir_with_migration
Variant of ensure_state_dir that exposes whether a legacy state path was migrated. Most callers should use ensure_state_dir; this is kept for tests and future UI surfaces that want to render the notice themselves.
is_sensitive_config_key
is_upstream_auth_header
Whether an HTTP header can carry the model provider’s primary credential.
is_valid_xai_oauth_generation
known_foreign_model_owner
A provider owner that Codewhale can identify with high confidence when an official route is handed a foreign model id.
legacy_deepseek_home
Resolve the legacy DeepSeek home directory ($HOME/.deepseek).
legacy_xai_oauth_path
load_permissions_snapshot
Load the active sibling permission rules with confirmation tokens suitable for a later compare-and-remove operation.
load_project_config
Load a project-level config from the workspace.
load_project_config_outcome
Load a project-level config from the workspace, reporting why a file that exists could not be used.
merge_and_preserve_comments
Merge comments and formatting from an original TOML file into a freshly serialized document so user annotations (comments, whitespace, disabled keys) survive config rewrites.
migrate_config_if_needed
v0.8.44: one-time migration from ~/.deepseek/config.toml to ~/.codewhale/config.toml. Called on first launch after the config is loaded; copies the legacy file if the primary doesn’t exist yet. Never overwrites an existing primary config.
mutate_config_document
Parse the latest document under the shared write lock, apply mutate, and atomically persist only the resulting delta.
opencode_go_chat_model_id
Canonicalize an OpenCode Go model that is documented for the OpenAI Chat Completions endpoint. The live /models roster also contains Anthropic-Messages-only models; returning None for those is the protocol cutline shared by config and the TUI live-catalog paths.
permissions_path_for_config_path
project_approval_policy_is_allowed
project_sandbox_mode_is_allowed
provider_base_url_is_official
Whether base_url belongs to the provider’s official endpoint family.
provider_preserves_custom_base_url_model
Whether base_url is outside the provider’s official endpoint family and therefore owns its model-id namespace.
read_permissions_file
Read a resolved permissions.toml path using the same checked/no-follow path handling as config loading.
remove_permission_rule
Remove one zero-based permission rule if expected_token still describes that exact index in the current file.
remove_xai_oauth_generation
Delete one superseded generation after its replacement pointer committed. The basename is validated before any filesystem access.
replace_config_document_if_unchanged
Replace a full typed snapshot only when on-disk bytes still equal the snapshot the caller originally loaded. None means the file was absent.
resolve_config_path
resolve_hotbar_bindings
resolve_permissions_path
resolve_project_state_dir
Resolve a project-local state subdirectory, preferring .codewhale/ when it exists, falling back to .deepseek/ for legacy projects.
resolve_state_dir
Resolve a state subdirectory, preferring the CodeWhale root if it already exists, otherwise falling back to the legacy root.
scrub_plaintext_api_keys_from_config_backup
Remove plaintext api_key entries from the one-time config backup, if it exists.
set_config_document_value
Set a value at segments, creating implicit parent tables while preserving existing key/value decor.
telemetry_floor_in_force
Whether an environment-level kill switch forces telemetry off here.
unset_config_document_value
Remove a value at segments without disturbing unrelated tables or decor.
validate_xai_oauth_generation
with_xai_oauth_lifecycle_lock
Serialize every Codewhale-owned xAI OAuth lifecycle mutation across threads and processes while pinning the lexical credentials directory.
with_xai_oauth_revocation_transaction
Run an authority mode switch while the prior owned OAuth epoch is hidden from concurrent Codewhale readers. A failed authority mutation restores the old files; a successful mutation permanently removes them.
xai_oauth_credentials_dir
xai_oauth_generation_path