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.
Files changed (140) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/LICENSE +30 -0
  3. package/NOTICE +106 -0
  4. package/PROVENANCE.md +435 -0
  5. package/README.en.md +126 -0
  6. package/README.md +115 -2
  7. package/README.zh.md +116 -0
  8. package/bin/dsh-ops.mjs +1216 -0
  9. package/cordis.patch.yml +160 -0
  10. package/docs/manual-validation.md +53 -0
  11. package/docs/release-0.2.1.md +72 -0
  12. package/docs/schema-baseline.json +64 -0
  13. package/docs/schema-current.json +84 -0
  14. package/docs/schema-measurement.md +17 -0
  15. package/dsh-plugin.json +88 -0
  16. package/icon.svg +12 -0
  17. package/lib/binary.js +409 -0
  18. package/lib/config.js +198 -0
  19. package/lib/handshake.js +252 -0
  20. package/lib/index.js +108 -0
  21. package/lib/jobs.js +42 -0
  22. package/lib/policy.js +64 -0
  23. package/lib/presentation.js +63 -0
  24. package/lib/profile-install.js +61 -0
  25. package/lib/rust.js +194 -0
  26. package/lib/session-shells.js +78 -0
  27. package/lib/shells.js +998 -0
  28. package/lib/tools.js +657 -0
  29. package/locale/en.json +6 -0
  30. package/locale/zh.json +6 -0
  31. package/package.json +114 -4
  32. package/vendor/fastctx/Cargo.lock +3210 -0
  33. package/vendor/fastctx/Cargo.toml +94 -0
  34. package/vendor/fastctx/FORK.md +119 -0
  35. package/vendor/fastctx/LICENSE-APACHE +201 -0
  36. package/vendor/fastctx/NOTICE +40 -0
  37. package/vendor/fastctx/README.md +439 -0
  38. package/vendor/fastctx/THIRD_PARTY_LICENSES.md +17 -0
  39. package/vendor/fastctx/THIRD_PARTY_LICENSES_RUST.md +7914 -0
  40. package/vendor/fastctx/UPSTREAM.md +49 -0
  41. package/vendor/fastctx/build.rs +413 -0
  42. package/vendor/fastctx/src/background_status.rs +403 -0
  43. package/vendor/fastctx/src/binary.rs +75 -0
  44. package/vendor/fastctx/src/bounded_sort.rs +500 -0
  45. package/vendor/fastctx/src/budget.rs +781 -0
  46. package/vendor/fastctx/src/cli/mod.rs +110 -0
  47. package/vendor/fastctx/src/context_guard.rs +289 -0
  48. package/vendor/fastctx/src/control/mod.rs +6 -0
  49. package/vendor/fastctx/src/control/paths.rs +49 -0
  50. package/vendor/fastctx/src/control/settings.rs +753 -0
  51. package/vendor/fastctx/src/control/transaction.rs +531 -0
  52. package/vendor/fastctx/src/edit/document.rs +535 -0
  53. package/vendor/fastctx/src/edit/locks.rs +371 -0
  54. package/vendor/fastctx/src/edit/mod.rs +213 -0
  55. package/vendor/fastctx/src/edit/private_storage/unix.rs +315 -0
  56. package/vendor/fastctx/src/edit/private_storage/windows.rs +793 -0
  57. package/vendor/fastctx/src/edit/private_storage.rs +234 -0
  58. package/vendor/fastctx/src/edit/replace.rs +1030 -0
  59. package/vendor/fastctx/src/edit_server.rs +53 -0
  60. package/vendor/fastctx/src/encoding/reference_v011.rs +587 -0
  61. package/vendor/fastctx/src/encoding/snapshot_pipeline.rs +1678 -0
  62. package/vendor/fastctx/src/encoding.rs +1118 -0
  63. package/vendor/fastctx/src/file_executor.rs +1151 -0
  64. package/vendor/fastctx/src/file_snapshot.rs +1491 -0
  65. package/vendor/fastctx/src/glob_filter.rs +98 -0
  66. package/vendor/fastctx/src/glob_tool.rs +653 -0
  67. package/vendor/fastctx/src/grep_sink.rs +1162 -0
  68. package/vendor/fastctx/src/grep_tool.rs +2449 -0
  69. package/vendor/fastctx/src/lib.rs +45 -0
  70. package/vendor/fastctx/src/main.rs +15 -0
  71. package/vendor/fastctx/src/model.rs +51 -0
  72. package/vendor/fastctx/src/model_guidance.rs +62 -0
  73. package/vendor/fastctx/src/operation.rs +356 -0
  74. package/vendor/fastctx/src/ordered_window.rs +1235 -0
  75. package/vendor/fastctx/src/os_environment.rs +414 -0
  76. package/vendor/fastctx/src/path_codec.rs +850 -0
  77. package/vendor/fastctx/src/paths.rs +244 -0
  78. package/vendor/fastctx/src/process_identity.rs +763 -0
  79. package/vendor/fastctx/src/process_policy.rs +74 -0
  80. package/vendor/fastctx/src/read_tool/batch.rs +496 -0
  81. package/vendor/fastctx/src/read_tool/hex_file.rs +141 -0
  82. package/vendor/fastctx/src/read_tool/image_file.rs +88 -0
  83. package/vendor/fastctx/src/read_tool/mod.rs +245 -0
  84. package/vendor/fastctx/src/read_tool/pdf.rs +470 -0
  85. package/vendor/fastctx/src/read_tool/pdf_disabled.rs +47 -0
  86. package/vendor/fastctx/src/read_tool/pdf_engine.rs +664 -0
  87. package/vendor/fastctx/src/read_tool/text_file.rs +351 -0
  88. package/vendor/fastctx/src/render_plan.rs +468 -0
  89. package/vendor/fastctx/src/runtime/activity.rs +159 -0
  90. package/vendor/fastctx/src/runtime/hosts.rs +99 -0
  91. package/vendor/fastctx/src/runtime/journal.rs +556 -0
  92. package/vendor/fastctx/src/runtime/local_ipc.rs +186 -0
  93. package/vendor/fastctx/src/runtime/mod.rs +746 -0
  94. package/vendor/fastctx/src/runtime/protocol.rs +296 -0
  95. package/vendor/fastctx/src/runtime/session.rs +536 -0
  96. package/vendor/fastctx/src/runtime/windows_process.rs +66 -0
  97. package/vendor/fastctx/src/search_parallelism.rs +106 -0
  98. package/vendor/fastctx/src/search_text.rs +227 -0
  99. package/vendor/fastctx/src/server.rs +359 -0
  100. package/vendor/fastctx/src/server_manifest.rs +468 -0
  101. package/vendor/fastctx/src/server_support.rs +826 -0
  102. package/vendor/fastctx/src/session.rs +629 -0
  103. package/vendor/fastctx/src/shell/apply_patch_hint.rs +41 -0
  104. package/vendor/fastctx/src/shell/bash.rs +263 -0
  105. package/vendor/fastctx/src/shell/buffer.rs +108 -0
  106. package/vendor/fastctx/src/shell/encoding.rs +403 -0
  107. package/vendor/fastctx/src/shell/foreground.rs +115 -0
  108. package/vendor/fastctx/src/shell/jobs/admission.rs +91 -0
  109. package/vendor/fastctx/src/shell/jobs/background.rs +146 -0
  110. package/vendor/fastctx/src/shell/jobs/host.rs +830 -0
  111. package/vendor/fastctx/src/shell/jobs/identity.rs +29 -0
  112. package/vendor/fastctx/src/shell/jobs/mod.rs +1513 -0
  113. package/vendor/fastctx/src/shell/jobs/model.rs +244 -0
  114. package/vendor/fastctx/src/shell/jobs/output_log.rs +1148 -0
  115. package/vendor/fastctx/src/shell/jobs/store.rs +1300 -0
  116. package/vendor/fastctx/src/shell/mod.rs +345 -0
  117. package/vendor/fastctx/src/shell/normalize.rs +389 -0
  118. package/vendor/fastctx/src/shell/output.rs +406 -0
  119. package/vendor/fastctx/src/shell/process.rs +493 -0
  120. package/vendor/fastctx/src/shell_server.rs +156 -0
  121. package/vendor/fastctx/src/skip_report.rs +83 -0
  122. package/vendor/fastctx/src/stdio_transport.rs +177 -0
  123. package/vendor/fastctx/src/tool_schema.rs +204 -0
  124. package/vendor/fastctx/src/traversal.rs +846 -0
  125. package/vendor/fastctx/third-party/pdfium-7763/LICENSE +9 -0
  126. package/vendor/fastctx/third-party/pdfium-7763/licenses/abseil.txt +202 -0
  127. package/vendor/fastctx/third-party/pdfium-7763/licenses/agg23.txt +14 -0
  128. package/vendor/fastctx/third-party/pdfium-7763/licenses/fast_float.txt +27 -0
  129. package/vendor/fastctx/third-party/pdfium-7763/licenses/freetype.txt +169 -0
  130. package/vendor/fastctx/third-party/pdfium-7763/licenses/icu.txt +542 -0
  131. package/vendor/fastctx/third-party/pdfium-7763/licenses/lcms.txt +27 -0
  132. package/vendor/fastctx/third-party/pdfium-7763/licenses/libjpeg_turbo.ijg +260 -0
  133. package/vendor/fastctx/third-party/pdfium-7763/licenses/libjpeg_turbo.md +135 -0
  134. package/vendor/fastctx/third-party/pdfium-7763/licenses/libopenjpeg.txt +32 -0
  135. package/vendor/fastctx/third-party/pdfium-7763/licenses/libpng.txt +134 -0
  136. package/vendor/fastctx/third-party/pdfium-7763/licenses/libtiff.txt +21 -0
  137. package/vendor/fastctx/third-party/pdfium-7763/licenses/llvm-libc.txt +278 -0
  138. package/vendor/fastctx/third-party/pdfium-7763/licenses/pdfium.txt +230 -0
  139. package/vendor/fastctx/third-party/pdfium-7763/licenses/simdutf.txt +18 -0
  140. 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};