Skip to main content

vv_agent/runtime/background_sessions/
options.rs

1use std::collections::BTreeMap;
2use std::path::PathBuf;
3use std::process::Child;
4use std::sync::Arc;
5use std::time::Instant;
6
7use crate::workspace::WorkspaceBackend;
8
9#[derive(Debug, Clone, Default)]
10pub struct BackgroundSessionStartOptions {
11    pub stdin: Option<String>,
12    pub auto_confirm: bool,
13    pub shell: Option<String>,
14    pub windows_shell_priority: Option<Vec<String>>,
15    pub env: Option<BTreeMap<String, String>>,
16}
17
18pub struct BackgroundSessionAdoptOptions {
19    pub command: String,
20    pub cwd: PathBuf,
21    pub timeout_seconds: u64,
22    pub child: Child,
23    pub output_path: PathBuf,
24    pub shell: Option<String>,
25    pub started_at: Option<Instant>,
26    pub artifact_backend: Option<Arc<dyn WorkspaceBackend>>,
27    pub artifact_task_id: String,
28    pub artifact_tool_call_id: String,
29}
30
31impl BackgroundSessionAdoptOptions {
32    pub fn new(
33        command: impl Into<String>,
34        cwd: impl Into<PathBuf>,
35        timeout_seconds: u64,
36        child: Child,
37        output_path: impl Into<PathBuf>,
38    ) -> Self {
39        Self {
40            command: command.into(),
41            cwd: cwd.into(),
42            timeout_seconds,
43            child,
44            output_path: output_path.into(),
45            shell: None,
46            started_at: None,
47            artifact_backend: None,
48            artifact_task_id: String::new(),
49            artifact_tool_call_id: String::new(),
50        }
51    }
52
53    pub fn with_shell(mut self, shell: impl Into<String>) -> Self {
54        self.shell = Some(shell.into());
55        self
56    }
57
58    pub fn with_started_at(mut self, started_at: Instant) -> Self {
59        self.started_at = Some(started_at);
60        self
61    }
62
63    pub fn with_artifact_context(
64        mut self,
65        backend: Arc<dyn WorkspaceBackend>,
66        task_id: impl Into<String>,
67        tool_call_id: impl Into<String>,
68    ) -> Self {
69        self.artifact_backend = Some(backend);
70        self.artifact_task_id = task_id.into();
71        self.artifact_tool_call_id = tool_call_id.into();
72        self
73    }
74}