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,244 @@
|
|
|
1
|
+
//! On-disk background-job records and process-launch messages.
|
|
2
|
+
|
|
3
|
+
pub(crate) use crate::process_identity::ProcessIdentity;
|
|
4
|
+
use serde::{Deserialize, Serialize};
|
|
5
|
+
use std::path::PathBuf;
|
|
6
|
+
use std::time::SystemTime;
|
|
7
|
+
|
|
8
|
+
pub(super) const JOB_SCHEMA_VERSION: u32 = 3;
|
|
9
|
+
pub(super) const META_FILE: &str = "meta.json";
|
|
10
|
+
pub(super) const EXIT_FILE: &str = "exit.json";
|
|
11
|
+
pub(super) const CAPTURE_ERROR_FILE: &str = "capture-error.json";
|
|
12
|
+
pub(super) const OUTPUT_TRUNCATION_FILE: &str = "output-truncated.json";
|
|
13
|
+
pub(super) const KILL_REQUEST_FILE: &str = "kill.request";
|
|
14
|
+
pub(super) const OUTPUT_LOG_FILE: &str = "output.log";
|
|
15
|
+
pub(super) const OUTPUT_INDEX_FILE: &str = "output.idx";
|
|
16
|
+
|
|
17
|
+
/// Best-effort provenance captured by the server that requested a background job.
|
|
18
|
+
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
19
|
+
pub(crate) struct OriginSnapshot {
|
|
20
|
+
pub(crate) server_pid: u32,
|
|
21
|
+
/// Process creation token disambiguating a recycled server PID.
|
|
22
|
+
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
23
|
+
pub(crate) server_started: Option<String>,
|
|
24
|
+
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
25
|
+
pub(crate) parent_pid: Option<u32>,
|
|
26
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
27
|
+
pub(crate) parent_executable: Option<String>,
|
|
28
|
+
pub(crate) server_cwd: String,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Immutable metadata written once after the detached supervisor owns the process tree.
|
|
32
|
+
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
33
|
+
pub(crate) struct JobMeta {
|
|
34
|
+
pub(crate) schema_version: u32,
|
|
35
|
+
pub(crate) command: String,
|
|
36
|
+
pub(crate) cwd: String,
|
|
37
|
+
pub(crate) login_shell: bool,
|
|
38
|
+
/// Default delivery-time decoder selected when this job was started.
|
|
39
|
+
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
40
|
+
pub(crate) encoding: Option<String>,
|
|
41
|
+
pub(crate) supervisor: ProcessIdentity,
|
|
42
|
+
pub(crate) origin: OriginSnapshot,
|
|
43
|
+
pub(crate) started_at: String,
|
|
44
|
+
/// Nanosecond ordering key kept separate so the public timestamp remains second-precision.
|
|
45
|
+
#[serde(default)]
|
|
46
|
+
pub(crate) started_at_unix_nanos: u64,
|
|
47
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
48
|
+
pub(crate) isolation_warning: Option<String>,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// Why the supervisor wrote the terminal record.
|
|
52
|
+
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
|
53
|
+
#[serde(rename_all = "kebab-case")]
|
|
54
|
+
pub(crate) enum TerminationKind {
|
|
55
|
+
#[default]
|
|
56
|
+
Exited,
|
|
57
|
+
Killed,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// Immutable terminal record written exactly once after the process tree exits.
|
|
61
|
+
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
62
|
+
pub(crate) struct ExitRecord {
|
|
63
|
+
pub(crate) exit_code: i32,
|
|
64
|
+
pub(crate) total_lines: u64,
|
|
65
|
+
pub(crate) had_loss: bool,
|
|
66
|
+
pub(crate) ended_at: String,
|
|
67
|
+
/// Nanosecond ordering key for deterministic newest-first listing and oldest-first reaping.
|
|
68
|
+
#[serde(default)]
|
|
69
|
+
pub(crate) ended_at_unix_nanos: u64,
|
|
70
|
+
#[serde(default, skip_serializing_if = "is_natural_exit")]
|
|
71
|
+
pub(crate) termination: TerminationKind,
|
|
72
|
+
/// Fallback copy of a capture failure when its dedicated immutable record could not be published.
|
|
73
|
+
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
74
|
+
pub(crate) capture_error: Option<CaptureErrorRecord>,
|
|
75
|
+
/// Frozen per-job quota state, also written while the job is still running.
|
|
76
|
+
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
77
|
+
pub(crate) output_truncation: Option<OutputTruncationRecord>,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn is_natural_exit(kind: &TerminationKind) -> bool {
|
|
81
|
+
*kind == TerminationKind::Exited
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
impl ExitRecord {
|
|
85
|
+
/// Whether job_kill ended this job. Displays must say "killed" instead of showing
|
|
86
|
+
/// exit_code: Windows TerminateProcess hardcodes exit code 1, so the number cannot
|
|
87
|
+
/// distinguish a requested stop from a real failure (2026-08-08).
|
|
88
|
+
pub(crate) fn was_killed(&self) -> bool {
|
|
89
|
+
self.termination == TerminationKind::Killed
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// One durable capture failure; the command itself continues to run.
|
|
94
|
+
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
95
|
+
pub(crate) struct CaptureErrorRecord {
|
|
96
|
+
pub(crate) after_seq: u64,
|
|
97
|
+
pub(crate) reason: String,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// Durable notice that the supervisor kept draining output after its disk quota was exhausted.
|
|
101
|
+
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
102
|
+
pub(crate) struct OutputTruncationRecord {
|
|
103
|
+
pub(crate) limit_bytes: u64,
|
|
104
|
+
pub(crate) persisted_log_bytes: u64,
|
|
105
|
+
pub(crate) persisted_index_bytes: u64,
|
|
106
|
+
pub(crate) after_seq: u64,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// One normalized display line from a schema-v1/v2 JSONL segment.
|
|
110
|
+
///
|
|
111
|
+
/// Schema-v3 writers never create this envelope; the type remains solely for
|
|
112
|
+
/// the required N-1 read compatibility path.
|
|
113
|
+
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
|
114
|
+
pub(crate) struct SpoolLine {
|
|
115
|
+
pub(crate) seq: u64,
|
|
116
|
+
/// UTF-8 text from schema v1 records, retained for backward compatibility.
|
|
117
|
+
#[serde(default, skip_serializing_if = "String::is_empty")]
|
|
118
|
+
pub(crate) text: String,
|
|
119
|
+
/// Raw normalized bytes written by schema v2 supervisors.
|
|
120
|
+
#[serde(
|
|
121
|
+
default,
|
|
122
|
+
skip_serializing_if = "Option::is_none",
|
|
123
|
+
with = "optional_base64"
|
|
124
|
+
)]
|
|
125
|
+
pub(crate) raw_bytes: Option<Vec<u8>>,
|
|
126
|
+
#[serde(default)]
|
|
127
|
+
pub(crate) total_bytes: u64,
|
|
128
|
+
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
129
|
+
pub(crate) stream_encoding: Option<crate::shell::normalize::StreamEncoding>,
|
|
130
|
+
pub(crate) truncated: bool,
|
|
131
|
+
/// Lifetime loss flag propagated forward so retained segments remain self-describing.
|
|
132
|
+
pub(crate) had_loss: bool,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// Complete launch payload streamed over a private inherited pipe, never exposed in argv.
|
|
136
|
+
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
137
|
+
pub(crate) struct LaunchSpec {
|
|
138
|
+
pub(crate) job_id: String,
|
|
139
|
+
pub(crate) job_dir: PathBuf,
|
|
140
|
+
pub(crate) bash: PathBuf,
|
|
141
|
+
pub(crate) command: String,
|
|
142
|
+
pub(crate) cwd: PathBuf,
|
|
143
|
+
pub(crate) login_shell: bool,
|
|
144
|
+
#[serde(default)]
|
|
145
|
+
pub(crate) encoding: Option<String>,
|
|
146
|
+
/// Exact native environment captured by the stdio proxy that started this job.
|
|
147
|
+
pub(crate) environment: crate::session::SessionEnvironment,
|
|
148
|
+
/// Locale selected for this session's bash before the detached supervisor starts.
|
|
149
|
+
pub(crate) utf8_locale: String,
|
|
150
|
+
/// Combined `output.log` + `output.idx` ceiling frozen before detachment.
|
|
151
|
+
pub(crate) output_limit_bytes: u64,
|
|
152
|
+
pub(crate) origin: OriginSnapshot,
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// One logical line exposed by the unified new/legacy log reader.
|
|
156
|
+
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
157
|
+
pub(crate) struct StoredLine {
|
|
158
|
+
pub(crate) seq: u64,
|
|
159
|
+
pub(crate) bytes: Vec<u8>,
|
|
160
|
+
pub(crate) total_bytes: u64,
|
|
161
|
+
pub(crate) stream_encoding: Option<crate::shell::normalize::StreamEncoding>,
|
|
162
|
+
pub(crate) legacy_text: Option<String>,
|
|
163
|
+
pub(crate) known_truncated: bool,
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
impl StoredLine {
|
|
167
|
+
pub(crate) fn encoded_line(&self) -> crate::shell::encoding::EncodedLine<'_> {
|
|
168
|
+
crate::shell::encoding::EncodedLine {
|
|
169
|
+
bytes: &self.bytes,
|
|
170
|
+
total_bytes: self.total_bytes.max(self.bytes.len() as u64),
|
|
171
|
+
stream_encoding: self.stream_encoding,
|
|
172
|
+
legacy_text: self.legacy_text.as_deref(),
|
|
173
|
+
known_truncated: self.known_truncated,
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
impl From<SpoolLine> for StoredLine {
|
|
179
|
+
fn from(line: SpoolLine) -> Self {
|
|
180
|
+
let legacy_text = line.raw_bytes.is_none().then_some(line.text);
|
|
181
|
+
Self {
|
|
182
|
+
seq: line.seq,
|
|
183
|
+
total_bytes: line.total_bytes,
|
|
184
|
+
stream_encoding: line.stream_encoding,
|
|
185
|
+
known_truncated: line.truncated,
|
|
186
|
+
bytes: line.raw_bytes.unwrap_or_default(),
|
|
187
|
+
legacy_text,
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
mod optional_base64 {
|
|
193
|
+
use base64::Engine;
|
|
194
|
+
use serde::{Deserialize, Deserializer, Serializer};
|
|
195
|
+
|
|
196
|
+
pub(super) fn serialize<S>(value: &Option<Vec<u8>>, serializer: S) -> Result<S::Ok, S::Error>
|
|
197
|
+
where
|
|
198
|
+
S: Serializer,
|
|
199
|
+
{
|
|
200
|
+
match value {
|
|
201
|
+
Some(bytes) => {
|
|
202
|
+
serializer.serialize_some(&base64::engine::general_purpose::STANDARD.encode(bytes))
|
|
203
|
+
}
|
|
204
|
+
None => serializer.serialize_none(),
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
pub(super) fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<u8>>, D::Error>
|
|
209
|
+
where
|
|
210
|
+
D: Deserializer<'de>,
|
|
211
|
+
{
|
|
212
|
+
let value = Option::<String>::deserialize(deserializer)?;
|
|
213
|
+
value
|
|
214
|
+
.map(|value| {
|
|
215
|
+
base64::engine::general_purpose::STANDARD
|
|
216
|
+
.decode(value)
|
|
217
|
+
.map_err(serde::de::Error::custom)
|
|
218
|
+
})
|
|
219
|
+
.transpose()
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
#[derive(Clone, Debug)]
|
|
224
|
+
pub(crate) enum JobStatus {
|
|
225
|
+
Running,
|
|
226
|
+
Exited(ExitRecord),
|
|
227
|
+
Interrupted,
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
impl JobStatus {
|
|
231
|
+
pub(crate) fn is_running(&self) -> bool {
|
|
232
|
+
matches!(self, Self::Running)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/// One validated registry entry assembled independently from its job directory.
|
|
237
|
+
#[derive(Clone, Debug)]
|
|
238
|
+
pub(crate) struct JobRecord {
|
|
239
|
+
pub(crate) id: String,
|
|
240
|
+
pub(crate) directory: PathBuf,
|
|
241
|
+
pub(crate) meta: JobMeta,
|
|
242
|
+
pub(crate) status: JobStatus,
|
|
243
|
+
pub(crate) ended_sort_key: SystemTime,
|
|
244
|
+
}
|