pub struct WorkflowConfig {
pub cwd: String,
pub client_config: ClientConfig,
pub run_profile: RunProfile,
}Expand description
One explicit data model for reusable workflow defaults. This keeps simple and advanced paths on a single concrete structure.
Fields§
§cwd: String§client_config: ClientConfig§run_profile: RunProfileImplementations§
Source§impl WorkflowConfig
impl WorkflowConfig
Sourcepub fn new(cwd: impl Into<String>) -> Self
pub fn new(cwd: impl Into<String>) -> Self
Create config with safe defaults:
- runtime discovery via
ClientConfig::new() - model unset, effort medium, approval never, sandbox read-only
- cwd normalized to absolute path without filesystem existence checks (non-utf8 absolute paths fall back to caller-provided UTF-8 input without lossy conversion)
Sourcepub fn with_client_config(self, client_config: ClientConfig) -> Self
pub fn with_client_config(self, client_config: ClientConfig) -> Self
Replace whole client config.
Sourcepub fn with_run_profile(self, run_profile: RunProfile) -> Self
pub fn with_run_profile(self, run_profile: RunProfile) -> Self
Replace whole run profile.
Sourcepub fn with_cli_bin(self, cli_bin: impl Into<PathBuf>) -> Self
pub fn with_cli_bin(self, cli_bin: impl Into<PathBuf>) -> Self
Override codex binary location.
Sourcepub fn with_compatibility_guard(self, guard: CompatibilityGuard) -> Self
pub fn with_compatibility_guard(self, guard: CompatibilityGuard) -> Self
Override runtime compatibility policy.
Sourcepub fn without_compatibility_guard(self) -> Self
pub fn without_compatibility_guard(self) -> Self
Disable compatibility guard.
Sourcepub fn with_initialize_capabilities(
self,
initialize_capabilities: InitializeCapabilities,
) -> Self
pub fn with_initialize_capabilities( self, initialize_capabilities: InitializeCapabilities, ) -> Self
Override initialize capability switches.
Sourcepub fn enable_experimental_api(self) -> Self
pub fn enable_experimental_api(self) -> Self
Opt into Codex experimental app-server methods and fields.
Sourcepub fn with_global_hooks(self, hooks: RuntimeHookConfig) -> Self
pub fn with_global_hooks(self, hooks: RuntimeHookConfig) -> Self
Replace global runtime hooks (connect-time).
Sourcepub fn with_global_pre_hook(self, hook: Arc<dyn PreHook>) -> Self
pub fn with_global_pre_hook(self, hook: Arc<dyn PreHook>) -> Self
Register one global runtime pre hook (connect-time).
Sourcepub fn with_global_post_hook(self, hook: Arc<dyn PostHook>) -> Self
pub fn with_global_post_hook(self, hook: Arc<dyn PostHook>) -> Self
Register one global runtime post hook (connect-time).
Sourcepub fn with_global_pre_tool_use_hook(self, hook: Arc<dyn PreHook>) -> Self
pub fn with_global_pre_tool_use_hook(self, hook: Arc<dyn PreHook>) -> Self
Register one global pre-tool-use hook (fires via the internal approval loop). The runtime manages the approval channel and auto-escalates ApprovalPolicy → Untrusted. Allocation: amortized O(1) push. Complexity: O(1).
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set explicit model override.
Sourcepub fn with_effort(self, effort: ReasoningEffort) -> Self
pub fn with_effort(self, effort: ReasoningEffort) -> Self
Set explicit reasoning effort.
Sourcepub fn with_approval_policy(self, approval_policy: ApprovalPolicy) -> Self
pub fn with_approval_policy(self, approval_policy: ApprovalPolicy) -> Self
Set approval policy override.
Sourcepub fn with_sandbox_policy(self, sandbox_policy: SandboxPolicy) -> Self
pub fn with_sandbox_policy(self, sandbox_policy: SandboxPolicy) -> Self
Set sandbox policy override.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set prompt timeout.
Sourcepub fn with_output_schema(self, output_schema: Value) -> Self
pub fn with_output_schema(self, output_schema: Value) -> Self
Set one optional JSON Schema for the final assistant message.
Sourcepub fn with_attachment(self, attachment: PromptAttachment) -> Self
pub fn with_attachment(self, attachment: PromptAttachment) -> Self
Add one attachment.
Sourcepub fn attach_path(self, path: impl Into<String>) -> Self
pub fn attach_path(self, path: impl Into<String>) -> Self
Add one @path attachment.
Sourcepub fn attach_path_with_placeholder(
self,
path: impl Into<String>,
placeholder: impl Into<String>,
) -> Self
pub fn attach_path_with_placeholder( self, path: impl Into<String>, placeholder: impl Into<String>, ) -> Self
Add one @path attachment with placeholder.
Sourcepub fn attach_image_url(self, url: impl Into<String>) -> Self
pub fn attach_image_url(self, url: impl Into<String>) -> Self
Add one remote image attachment.
Sourcepub fn attach_local_image(self, path: impl Into<String>) -> Self
pub fn attach_local_image(self, path: impl Into<String>) -> Self
Add one local image attachment.
Sourcepub fn attach_skill(
self,
name: impl Into<String>,
path: impl Into<String>,
) -> Self
pub fn attach_skill( self, name: impl Into<String>, path: impl Into<String>, ) -> Self
Add one skill attachment.
Sourcepub fn with_run_hooks(self, hooks: RuntimeHookConfig) -> Self
pub fn with_run_hooks(self, hooks: RuntimeHookConfig) -> Self
Replace run-level hooks.
Sourcepub fn with_run_pre_hook(self, hook: Arc<dyn PreHook>) -> Self
pub fn with_run_pre_hook(self, hook: Arc<dyn PreHook>) -> Self
Register one run-level pre hook.
Sourcepub fn with_run_post_hook(self, hook: Arc<dyn PostHook>) -> Self
pub fn with_run_post_hook(self, hook: Arc<dyn PostHook>) -> Self
Register one run-level post hook.
Sourcepub fn with_shell_pre_hook(
self,
name: &'static str,
command: impl Into<String>,
) -> Self
pub fn with_shell_pre_hook( self, name: &'static str, command: impl Into<String>, ) -> Self
Register an external shell command as a global pre-hook (connect-time).
The command is run via sh -c. Default timeout: 5 seconds.
On exit 0 → Noop or Mutate. On exit 2 → Block. On other exit → HookIssue.
Allocation: two Strings.
Sourcepub fn with_shell_post_hook(
self,
name: &'static str,
command: impl Into<String>,
) -> Self
pub fn with_shell_post_hook( self, name: &'static str, command: impl Into<String>, ) -> Self
Register an external shell command as a global post-hook (connect-time).
The command is run via sh -c. Default timeout: 5 seconds.
On exit 0 → Ok(()). On other exit → HookIssue (non-fatal, logged in report).
Allocation: two Strings.
Sourcepub fn with_shell_pre_hook_timeout(
self,
name: &'static str,
command: impl Into<String>,
timeout: Duration,
) -> Self
pub fn with_shell_pre_hook_timeout( self, name: &'static str, command: impl Into<String>, timeout: Duration, ) -> Self
Register an external shell command as a global pre-hook with explicit timeout. Allocation: two Strings.
Sourcepub fn to_session_config(&self) -> SessionConfig
pub fn to_session_config(&self) -> SessionConfig
Build session config with the same cwd/profile defaults.
Trait Implementations§
Source§impl Clone for WorkflowConfig
impl Clone for WorkflowConfig
Source§fn clone(&self) -> WorkflowConfig
fn clone(&self) -> WorkflowConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more