dsh-ops 0.0.0-stage → 0.2.2
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/CHANGELOG.md +202 -0
- package/LICENSE +30 -0
- package/NOTICE +106 -0
- package/PROVENANCE.md +435 -0
- package/README.en.md +126 -0
- package/README.md +115 -2
- package/README.zh.md +116 -0
- package/bin/dsh-ops.mjs +1216 -0
- package/cordis.patch.yml +160 -0
- package/docs/manual-validation.md +53 -0
- package/docs/release-0.2.1.md +72 -0
- package/docs/schema-baseline.json +64 -0
- package/docs/schema-current.json +84 -0
- package/docs/schema-measurement.md +17 -0
- package/dsh-plugin.json +88 -0
- package/icon.svg +12 -0
- package/lib/binary.js +409 -0
- package/lib/config.js +198 -0
- package/lib/handshake.js +252 -0
- package/lib/index.js +108 -0
- package/lib/jobs.js +42 -0
- package/lib/policy.js +64 -0
- package/lib/presentation.js +63 -0
- package/lib/profile-install.js +61 -0
- package/lib/rust.js +194 -0
- package/lib/session-shells.js +78 -0
- package/lib/shells.js +998 -0
- package/lib/tools.js +657 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +114 -4
- package/vendor/fastctx/Cargo.lock +3210 -0
- package/vendor/fastctx/Cargo.toml +94 -0
- package/vendor/fastctx/FORK.md +119 -0
- package/vendor/fastctx/LICENSE-APACHE +201 -0
- package/vendor/fastctx/NOTICE +40 -0
- package/vendor/fastctx/README.md +439 -0
- package/vendor/fastctx/THIRD_PARTY_LICENSES.md +17 -0
- package/vendor/fastctx/THIRD_PARTY_LICENSES_RUST.md +7914 -0
- package/vendor/fastctx/UPSTREAM.md +49 -0
- package/vendor/fastctx/build.rs +413 -0
- package/vendor/fastctx/src/background_status.rs +403 -0
- package/vendor/fastctx/src/binary.rs +75 -0
- package/vendor/fastctx/src/bounded_sort.rs +500 -0
- package/vendor/fastctx/src/budget.rs +781 -0
- package/vendor/fastctx/src/cli/mod.rs +110 -0
- package/vendor/fastctx/src/context_guard.rs +289 -0
- package/vendor/fastctx/src/control/mod.rs +6 -0
- package/vendor/fastctx/src/control/paths.rs +49 -0
- package/vendor/fastctx/src/control/settings.rs +753 -0
- package/vendor/fastctx/src/control/transaction.rs +531 -0
- package/vendor/fastctx/src/edit/document.rs +535 -0
- package/vendor/fastctx/src/edit/locks.rs +371 -0
- package/vendor/fastctx/src/edit/mod.rs +213 -0
- package/vendor/fastctx/src/edit/private_storage/unix.rs +315 -0
- package/vendor/fastctx/src/edit/private_storage/windows.rs +793 -0
- package/vendor/fastctx/src/edit/private_storage.rs +234 -0
- package/vendor/fastctx/src/edit/replace.rs +1030 -0
- package/vendor/fastctx/src/edit_server.rs +53 -0
- package/vendor/fastctx/src/encoding/reference_v011.rs +587 -0
- package/vendor/fastctx/src/encoding/snapshot_pipeline.rs +1678 -0
- package/vendor/fastctx/src/encoding.rs +1118 -0
- package/vendor/fastctx/src/file_executor.rs +1151 -0
- package/vendor/fastctx/src/file_snapshot.rs +1491 -0
- package/vendor/fastctx/src/glob_filter.rs +98 -0
- package/vendor/fastctx/src/glob_tool.rs +653 -0
- package/vendor/fastctx/src/grep_sink.rs +1162 -0
- package/vendor/fastctx/src/grep_tool.rs +2449 -0
- package/vendor/fastctx/src/lib.rs +45 -0
- package/vendor/fastctx/src/main.rs +15 -0
- package/vendor/fastctx/src/model.rs +51 -0
- package/vendor/fastctx/src/model_guidance.rs +62 -0
- package/vendor/fastctx/src/operation.rs +356 -0
- package/vendor/fastctx/src/ordered_window.rs +1235 -0
- package/vendor/fastctx/src/os_environment.rs +414 -0
- package/vendor/fastctx/src/path_codec.rs +850 -0
- package/vendor/fastctx/src/paths.rs +244 -0
- package/vendor/fastctx/src/process_identity.rs +763 -0
- package/vendor/fastctx/src/process_policy.rs +74 -0
- package/vendor/fastctx/src/read_tool/batch.rs +496 -0
- package/vendor/fastctx/src/read_tool/hex_file.rs +141 -0
- package/vendor/fastctx/src/read_tool/image_file.rs +88 -0
- package/vendor/fastctx/src/read_tool/mod.rs +245 -0
- package/vendor/fastctx/src/read_tool/pdf.rs +470 -0
- package/vendor/fastctx/src/read_tool/pdf_disabled.rs +47 -0
- package/vendor/fastctx/src/read_tool/pdf_engine.rs +664 -0
- package/vendor/fastctx/src/read_tool/text_file.rs +351 -0
- package/vendor/fastctx/src/render_plan.rs +468 -0
- package/vendor/fastctx/src/runtime/activity.rs +159 -0
- package/vendor/fastctx/src/runtime/hosts.rs +99 -0
- package/vendor/fastctx/src/runtime/journal.rs +556 -0
- package/vendor/fastctx/src/runtime/local_ipc.rs +186 -0
- package/vendor/fastctx/src/runtime/mod.rs +746 -0
- package/vendor/fastctx/src/runtime/protocol.rs +296 -0
- package/vendor/fastctx/src/runtime/session.rs +536 -0
- package/vendor/fastctx/src/runtime/windows_process.rs +66 -0
- package/vendor/fastctx/src/search_parallelism.rs +106 -0
- package/vendor/fastctx/src/search_text.rs +227 -0
- package/vendor/fastctx/src/server.rs +359 -0
- package/vendor/fastctx/src/server_manifest.rs +468 -0
- package/vendor/fastctx/src/server_support.rs +826 -0
- package/vendor/fastctx/src/session.rs +629 -0
- package/vendor/fastctx/src/shell/apply_patch_hint.rs +41 -0
- package/vendor/fastctx/src/shell/bash.rs +263 -0
- package/vendor/fastctx/src/shell/buffer.rs +108 -0
- package/vendor/fastctx/src/shell/encoding.rs +403 -0
- package/vendor/fastctx/src/shell/foreground.rs +115 -0
- package/vendor/fastctx/src/shell/jobs/admission.rs +91 -0
- package/vendor/fastctx/src/shell/jobs/background.rs +146 -0
- package/vendor/fastctx/src/shell/jobs/host.rs +830 -0
- package/vendor/fastctx/src/shell/jobs/identity.rs +29 -0
- package/vendor/fastctx/src/shell/jobs/mod.rs +1513 -0
- package/vendor/fastctx/src/shell/jobs/model.rs +244 -0
- package/vendor/fastctx/src/shell/jobs/output_log.rs +1148 -0
- package/vendor/fastctx/src/shell/jobs/store.rs +1300 -0
- package/vendor/fastctx/src/shell/mod.rs +345 -0
- package/vendor/fastctx/src/shell/normalize.rs +389 -0
- package/vendor/fastctx/src/shell/output.rs +406 -0
- package/vendor/fastctx/src/shell/process.rs +493 -0
- package/vendor/fastctx/src/shell_server.rs +156 -0
- package/vendor/fastctx/src/skip_report.rs +83 -0
- package/vendor/fastctx/src/stdio_transport.rs +177 -0
- package/vendor/fastctx/src/tool_schema.rs +204 -0
- package/vendor/fastctx/src/traversal.rs +846 -0
- package/vendor/fastctx/third-party/pdfium-7763/LICENSE +9 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/abseil.txt +202 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/agg23.txt +14 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/fast_float.txt +27 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/freetype.txt +169 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/icu.txt +542 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/lcms.txt +27 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/libjpeg_turbo.ijg +260 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/libjpeg_turbo.md +135 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/libopenjpeg.txt +32 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/libpng.txt +134 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/libtiff.txt +21 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/llvm-libc.txt +278 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/pdfium.txt +230 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/simdutf.txt +18 -0
- package/vendor/fastctx/third-party/pdfium-7763/licenses/zlib.txt +29 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
//! Private cross-platform byte streams for stdio proxy to control-center connections.
|
|
2
|
+
|
|
3
|
+
use std::path::{Path, PathBuf};
|
|
4
|
+
use tokio::io::{AsyncRead, AsyncWrite};
|
|
5
|
+
|
|
6
|
+
pub(crate) trait LocalStream: AsyncRead + AsyncWrite + Send + Unpin {}
|
|
7
|
+
impl<T> LocalStream for T where T: AsyncRead + AsyncWrite + Send + Unpin {}
|
|
8
|
+
pub(crate) type BoxedStream = Box<dyn LocalStream>;
|
|
9
|
+
|
|
10
|
+
/// Address material shared by the proxy and the matching build's control center.
|
|
11
|
+
#[derive(Clone, Debug)]
|
|
12
|
+
pub(crate) struct LocalEndpoint {
|
|
13
|
+
runtime_directory: PathBuf,
|
|
14
|
+
id: String,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
impl LocalEndpoint {
|
|
18
|
+
pub(crate) fn new(runtime_directory: PathBuf, id: String) -> Self {
|
|
19
|
+
Self {
|
|
20
|
+
runtime_directory,
|
|
21
|
+
id,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
pub(crate) fn runtime_directory(&self) -> &Path {
|
|
26
|
+
&self.runtime_directory
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
pub(crate) fn startup_lock_path(&self) -> PathBuf {
|
|
30
|
+
self.runtime_directory
|
|
31
|
+
.join(format!("{}.startup.lock", self.id))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pub(crate) fn instance_lock_path(&self) -> PathBuf {
|
|
35
|
+
self.runtime_directory
|
|
36
|
+
.join(format!("{}.instance.lock", self.id))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#[cfg(unix)]
|
|
40
|
+
fn socket_path(&self) -> PathBuf {
|
|
41
|
+
self.runtime_directory.join(format!("{}.sock", self.id))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#[cfg(windows)]
|
|
45
|
+
fn pipe_name(&self) -> String {
|
|
46
|
+
format!(r"\\.\pipe\{}", self.id)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#[cfg(unix)]
|
|
51
|
+
mod platform {
|
|
52
|
+
use super::{BoxedStream, LocalEndpoint};
|
|
53
|
+
use std::os::unix::fs::PermissionsExt;
|
|
54
|
+
use tokio::net::{UnixListener, UnixStream};
|
|
55
|
+
|
|
56
|
+
pub(crate) struct Listener {
|
|
57
|
+
inner: UnixListener,
|
|
58
|
+
socket_path: std::path::PathBuf,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
impl Listener {
|
|
62
|
+
pub(crate) fn bind(endpoint: &LocalEndpoint) -> Result<Self, String> {
|
|
63
|
+
let socket_path = endpoint.socket_path();
|
|
64
|
+
if let Err(error) = std::fs::remove_file(&socket_path)
|
|
65
|
+
&& error.kind() != std::io::ErrorKind::NotFound
|
|
66
|
+
{
|
|
67
|
+
return Err(format!(
|
|
68
|
+
"Cannot remove a stale control-center socket {}: {error}",
|
|
69
|
+
crate::paths::display_path(&socket_path)
|
|
70
|
+
));
|
|
71
|
+
}
|
|
72
|
+
let inner = UnixListener::bind(&socket_path).map_err(|error| {
|
|
73
|
+
format!(
|
|
74
|
+
"Cannot bind the control-center socket {}: {error}",
|
|
75
|
+
crate::paths::display_path(&socket_path)
|
|
76
|
+
)
|
|
77
|
+
})?;
|
|
78
|
+
std::fs::set_permissions(&socket_path, std::fs::Permissions::from_mode(0o600))
|
|
79
|
+
.map_err(|error| {
|
|
80
|
+
format!(
|
|
81
|
+
"Cannot secure the control-center socket {}: {error}",
|
|
82
|
+
crate::paths::display_path(&socket_path)
|
|
83
|
+
)
|
|
84
|
+
})?;
|
|
85
|
+
Ok(Self { inner, socket_path })
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
pub(crate) async fn accept(&mut self) -> Result<BoxedStream, String> {
|
|
89
|
+
self.inner
|
|
90
|
+
.accept()
|
|
91
|
+
.await
|
|
92
|
+
.map(|(stream, _)| Box::new(stream) as BoxedStream)
|
|
93
|
+
.map_err(|error| format!("Cannot accept a control-center connection: {error}"))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
impl Drop for Listener {
|
|
98
|
+
fn drop(&mut self) {
|
|
99
|
+
let _ = std::fs::remove_file(&self.socket_path);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
pub(crate) async fn connect(endpoint: &LocalEndpoint) -> Result<BoxedStream, String> {
|
|
104
|
+
UnixStream::connect(endpoint.socket_path())
|
|
105
|
+
.await
|
|
106
|
+
.map(|stream| Box::new(stream) as BoxedStream)
|
|
107
|
+
.map_err(|error| format!("Cannot connect to the FastCtx control center: {error}"))
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
#[cfg(windows)]
|
|
112
|
+
mod platform {
|
|
113
|
+
use super::{BoxedStream, LocalEndpoint};
|
|
114
|
+
use tokio::net::windows::named_pipe::{
|
|
115
|
+
ClientOptions, NamedPipeServer, ServerOptions as PipeServerOptions,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
pub(crate) struct Listener {
|
|
119
|
+
endpoint: LocalEndpoint,
|
|
120
|
+
current: Option<NamedPipeServer>,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
impl Listener {
|
|
124
|
+
pub(crate) fn bind(endpoint: &LocalEndpoint) -> Result<Self, String> {
|
|
125
|
+
let current = create_server(endpoint, true)?;
|
|
126
|
+
Ok(Self {
|
|
127
|
+
endpoint: endpoint.clone(),
|
|
128
|
+
current: Some(current),
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pub(crate) async fn accept(&mut self) -> Result<BoxedStream, String> {
|
|
133
|
+
if self.current.is_none() {
|
|
134
|
+
self.current = Some(create_server(&self.endpoint, false)?);
|
|
135
|
+
}
|
|
136
|
+
if let Err(error) = self
|
|
137
|
+
.current
|
|
138
|
+
.as_mut()
|
|
139
|
+
.expect("the named-pipe listener is initialized before accept")
|
|
140
|
+
.connect()
|
|
141
|
+
.await
|
|
142
|
+
{
|
|
143
|
+
self.current = None;
|
|
144
|
+
return Err(format!(
|
|
145
|
+
"Cannot accept a control-center connection: {error}"
|
|
146
|
+
));
|
|
147
|
+
}
|
|
148
|
+
let connected = self
|
|
149
|
+
.current
|
|
150
|
+
.take()
|
|
151
|
+
.expect("the connected named-pipe listener remains present");
|
|
152
|
+
// Do not discard an already accepted session if allocating the next pipe instance
|
|
153
|
+
// fails. The following accept retries allocation while live sessions keep running.
|
|
154
|
+
self.current = create_server(&self.endpoint, false).ok();
|
|
155
|
+
Ok(Box::new(connected))
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
fn create_server(endpoint: &LocalEndpoint, first: bool) -> Result<NamedPipeServer, String> {
|
|
160
|
+
let descriptor = crate::edit::private_storage::PrivateSecurityDescriptor::new()?;
|
|
161
|
+
let mut attributes = descriptor.security_attributes();
|
|
162
|
+
let mut options = PipeServerOptions::new();
|
|
163
|
+
options.first_pipe_instance(first);
|
|
164
|
+
// SAFETY: attributes and its descriptor stay live for this synchronous CreateNamedPipeW
|
|
165
|
+
// call. Windows copies the descriptor into the new kernel object before returning.
|
|
166
|
+
unsafe {
|
|
167
|
+
options.create_with_security_attributes_raw(
|
|
168
|
+
endpoint.pipe_name(),
|
|
169
|
+
(&mut attributes as *mut windows_sys::Win32::Security::SECURITY_ATTRIBUTES).cast(),
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
.map_err(|error| format!("Cannot create the private control-center pipe: {error}"))
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
pub(crate) async fn connect(endpoint: &LocalEndpoint) -> Result<BoxedStream, String> {
|
|
176
|
+
ClientOptions::new()
|
|
177
|
+
.open(endpoint.pipe_name())
|
|
178
|
+
.map(|stream| Box::new(stream) as BoxedStream)
|
|
179
|
+
.map_err(|error| format!("Cannot connect to the FastCtx control center: {error}"))
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
#[cfg(not(any(unix, windows)))]
|
|
184
|
+
compile_error!("FastCtx control-center IPC requires Unix-domain sockets or Windows named pipes.");
|
|
185
|
+
|
|
186
|
+
pub(crate) use platform::{Listener, connect};
|