@opencode-cloud/core 6.2.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +1 -1
- package/package.json +1 -1
- package/src/config/mod.rs +1 -1
- package/src/docker/Dockerfile +1 -1
- package/src/docker/exec.rs +70 -0
- package/src/docker/mod.rs +3 -1
- package/src/lib.rs +1 -1
package/Cargo.toml
CHANGED
package/package.json
CHANGED
package/src/config/mod.rs
CHANGED
|
@@ -65,7 +65,7 @@ pub fn ensure_data_dir() -> Result<PathBuf> {
|
|
|
65
65
|
/// If the config file doesn't exist, creates a new one with default values.
|
|
66
66
|
/// Supports JSONC (JSON with comments).
|
|
67
67
|
/// Rejects unknown fields for strict validation.
|
|
68
|
-
pub fn
|
|
68
|
+
pub fn load_config_or_default() -> Result<Config> {
|
|
69
69
|
let config_path =
|
|
70
70
|
get_config_path().ok_or_else(|| anyhow::anyhow!("Could not determine config file path"))?;
|
|
71
71
|
|
package/src/docker/Dockerfile
CHANGED
|
@@ -516,7 +516,7 @@ RUN echo 'export PATH="/home/opencode/.local/bin:$PATH"' >> /home/opencode/.zshr
|
|
|
516
516
|
# Clone the fork and build opencode from source (as non-root user)
|
|
517
517
|
# Pin to specific commit for reproducibility
|
|
518
518
|
# Build opencode from source (BuildKit cache mounts disabled for now)
|
|
519
|
-
RUN OPENCODE_COMMIT="
|
|
519
|
+
RUN OPENCODE_COMMIT="ecaebed0934eeda267a66226eb8c2106beaf68c8" \
|
|
520
520
|
&& rm -rf /tmp/opencode-repo \
|
|
521
521
|
&& git clone --depth 1 https://github.com/pRizz/opencode.git /tmp/opencode-repo \
|
|
522
522
|
&& cd /tmp/opencode-repo \
|
package/src/docker/exec.rs
CHANGED
|
@@ -82,6 +82,76 @@ pub async fn exec_command(
|
|
|
82
82
|
Ok(output)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/// Execute a command and capture output plus exit code
|
|
86
|
+
///
|
|
87
|
+
/// Returns a tuple of (output, exit_code). Exit code is -1 if not available.
|
|
88
|
+
pub async fn exec_command_with_status(
|
|
89
|
+
client: &DockerClient,
|
|
90
|
+
container: &str,
|
|
91
|
+
cmd: Vec<&str>,
|
|
92
|
+
) -> Result<(String, i64), DockerError> {
|
|
93
|
+
let exec_config = CreateExecOptions {
|
|
94
|
+
attach_stdout: Some(true),
|
|
95
|
+
attach_stderr: Some(true),
|
|
96
|
+
cmd: Some(cmd.iter().map(|s| s.to_string()).collect()),
|
|
97
|
+
user: Some("root".to_string()),
|
|
98
|
+
..Default::default()
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
let exec = client
|
|
102
|
+
.inner()
|
|
103
|
+
.create_exec(container, exec_config)
|
|
104
|
+
.await
|
|
105
|
+
.map_err(|e| DockerError::Container(format!("Failed to create exec: {e}")))?;
|
|
106
|
+
|
|
107
|
+
let exec_id = exec.id.clone();
|
|
108
|
+
let start_config = StartExecOptions {
|
|
109
|
+
detach: false,
|
|
110
|
+
..Default::default()
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
let mut output = String::new();
|
|
114
|
+
|
|
115
|
+
match client
|
|
116
|
+
.inner()
|
|
117
|
+
.start_exec(&exec.id, Some(start_config))
|
|
118
|
+
.await
|
|
119
|
+
.map_err(|e| DockerError::Container(format!("Failed to start exec: {e}")))?
|
|
120
|
+
{
|
|
121
|
+
StartExecResults::Attached {
|
|
122
|
+
output: mut stream, ..
|
|
123
|
+
} => {
|
|
124
|
+
while let Some(result) = stream.next().await {
|
|
125
|
+
match result {
|
|
126
|
+
Ok(log_output) => {
|
|
127
|
+
output.push_str(&log_output.to_string());
|
|
128
|
+
}
|
|
129
|
+
Err(e) => {
|
|
130
|
+
return Err(DockerError::Container(format!(
|
|
131
|
+
"Error reading exec output: {e}"
|
|
132
|
+
)));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
StartExecResults::Detached => {
|
|
138
|
+
return Err(DockerError::Container(
|
|
139
|
+
"Exec unexpectedly detached".to_string(),
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let inspect = client
|
|
145
|
+
.inner()
|
|
146
|
+
.inspect_exec(&exec_id)
|
|
147
|
+
.await
|
|
148
|
+
.map_err(|e| DockerError::Container(format!("Failed to inspect exec: {e}")))?;
|
|
149
|
+
|
|
150
|
+
let exit_code = inspect.exit_code.unwrap_or(-1);
|
|
151
|
+
|
|
152
|
+
Ok((output, exit_code))
|
|
153
|
+
}
|
|
154
|
+
|
|
85
155
|
/// Execute a command with stdin input and capture output
|
|
86
156
|
///
|
|
87
157
|
/// Creates an exec instance with stdin attached, writes the provided data to
|
package/src/docker/mod.rs
CHANGED
|
@@ -50,7 +50,9 @@ pub use update::{UpdateResult, has_previous_image, rollback_image, update_image}
|
|
|
50
50
|
pub use version::{VERSION_LABEL, get_cli_version, get_image_version, versions_compatible};
|
|
51
51
|
|
|
52
52
|
// Container exec operations
|
|
53
|
-
pub use exec::{
|
|
53
|
+
pub use exec::{
|
|
54
|
+
exec_command, exec_command_exit_code, exec_command_with_status, exec_command_with_stdin,
|
|
55
|
+
};
|
|
54
56
|
|
|
55
57
|
// User management operations
|
|
56
58
|
pub use users::{
|
package/src/lib.rs
CHANGED
|
@@ -14,7 +14,7 @@ pub mod version;
|
|
|
14
14
|
pub use version::{get_version, get_version_long};
|
|
15
15
|
|
|
16
16
|
// Re-export config types and functions
|
|
17
|
-
pub use config::{Config, get_hosts_path,
|
|
17
|
+
pub use config::{Config, get_hosts_path, load_config_or_default, save_config};
|
|
18
18
|
|
|
19
19
|
// Re-export singleton types
|
|
20
20
|
pub use singleton::{InstanceLock, SingletonError};
|