@deepseek-ai/dsh-bash-local 0.1.2-rc.1 → 0.1.3-alpha.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/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/shell/bash-local/README.md
5
- README.md: df9248651c94b26df3a16a19a360056a5a9199e1
6
- README.zh.md: ad5ba2143f0b0eff46264de2be48bd1bb1067edf
5
+ README.md: 462054d435433067355a91103aa0d606cea6521b
6
+ README.zh.md: 6127c6265079d522b5a58d8b1fd019c1bd909262
package/README.md CHANGED
@@ -61,7 +61,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
61
61
 
62
62
  ### Background processes
63
63
 
64
- Call `start` to run a command in the background; it returns a handle immediately and no timeout applies. `readOutput()` merges the stream deltas into one consuming read, marking stderr under a `[stderr]` section; `kill()` stops the process group; `done` settles when the process closes and never rejects. Job ids, ownership, polling, and notices belong to the generic `ctx.jobs` runtime, which the tool layer registers the handle with.
64
+ Call `start` to run a command in the background; it returns a handle immediately and no timeout applies. `readOutput()` merges the stream deltas into one consuming read, marking stderr under a `[stderr]` section; `kill()` terminates the provider-managed range; `done` settles when the direct command closes and never rejects. Job ids, ownership, polling, and notices belong to the generic `ctx.jobs` runtime, which the tool layer registers the handle with.
65
65
 
66
66
  <a id="adjusting-budgets-at-runtime"></a>
67
67
  ### Adjusting budgets at runtime
@@ -80,7 +80,7 @@ This section explains the design of the executor and points at the code that rea
80
80
 
81
81
  ### Design concept
82
82
 
83
- The executor is a Service Provider for the `ctx.shell` seam built on the subprocess capability: it owns everything bash-shaped — command defaulting and caps, deadline fusion and cause classification, the model-friendly terminal environment, and the background read merge — while process-group mechanics (bounded spill-backed output, credential scrub, kill escalation, disposal) belong to the subprocess service. Every call spawns a fresh non-login `bash -c` with no rc files, so commands are deterministic and shell state never leaks between calls.
83
+ The executor is a Service Provider for the `ctx.shell` seam built on the subprocess capability: it owns everything bash-shaped — command defaulting and caps, deadline fusion and cause classification, the model-friendly terminal environment, and the background read merge — while managed-range mechanics (bounded spill-backed output, credential scrub, termination escalation, quiescence, and disposal) belong to the subprocess service. Every call spawns a fresh non-login `bash -c` with no rc files, so commands are deterministic and shell state never leaks between calls.
84
84
 
85
85
  ### Source map
86
86
 
@@ -114,7 +114,7 @@ Read these pages when the executor contract is not enough. They move from the se
114
114
  - [bash-sandbox](../bash-sandbox/README.md) — the confining executor to compose instead when commands need the sandbox capability.
115
115
  - [tool-bash](../tool-bash/README.md) — the model-facing `bash` tool over this executor.
116
116
  - [Bash executor subsystem](../../../docs/subsystems/shell.md) — request/spec vocabulary, results, and the service contract in full.
117
- - [subprocess-local](../../subprocess/subprocess-local/README.md) — the process-group mechanics behind this executor.
117
+ - [subprocess-local](../../subprocess/subprocess-local/README.md) — the managed-range mechanics behind this executor.
118
118
 
119
119
  -----
120
120
 
@@ -137,7 +137,7 @@ These limits define when this executor is a poor fit. They are current package c
137
137
  - **Unconfined by itself** — commands run with the harness process's authority; deployments needing confinement compose `dsh-bash-sandbox`, while per-call allow/deny/ask policy belongs on the tools' `pre-execute` waterfall.
138
138
  - **No persistent shell or PTY** — every call starts a fresh non-login `bash -c`; cwd-only persistence and interactive terminal sessions remain deferred until a real workflow requires them.
139
139
  - **POSIX-only** — the `bash` binary is hardcoded and the underlying service's group semantics are POSIX; Windows is unsupported.
140
- - **A background spawn-failure note is single-delivery** — the subprocess service buffers no output for a process that never ran, so the executor injects `spawn failed: …` into exactly one `readOutput()` delta; a reader that discards that delta cannot recover it.
140
+ - **A background provider-failure note is single-delivery** — `SubprocessHandle.done` can reject before or after target execution begins, so the executor injects the stage-neutral `subprocess failed before reporting an outcome: …` into exactly one `readOutput()` delta; a reader that discards that delta cannot recover it.
141
141
 
142
142
  <a id="dev-note"></a>
143
143
  ### Dev Note
package/README.zh.md CHANGED
@@ -61,7 +61,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
61
61
 
62
62
  ### 后台进程
63
63
 
64
- 调用 `start` 即可在后台运行命令;它立即返回句柄,且不应用任何超时。`readOutput()` 把流增量合并为一次消费式读取,并在 `[stderr]` 分段下标记 stderr;`kill()` 停止进程组;`done` 在进程关闭时结算且绝不 reject。job id、所有权、轮询与通知属于通用 `ctx.jobs` 运行时,工具层会把句柄注册进去。
64
+ 调用 `start` 即可在后台运行命令;它立即返回句柄,且不应用任何超时。`readOutput()` 把流增量合并为一次消费式读取,并在 `[stderr]` 分段下标记 stderr;`kill()` 终止提供方管理的 range;`done` 在直接命令关闭时结算且绝不 reject。job id、所有权、轮询与通知属于通用 `ctx.jobs` 运行时,工具层会把句柄注册进去。
65
65
 
66
66
  <a id="adjusting-budgets-at-runtime"></a>
67
67
  ### 运行时调整预算
@@ -80,7 +80,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
80
80
 
81
81
  ### 设计概念
82
82
 
83
- 本执行器是基于 subprocess 能力的 `ctx.shell` seam 的 Service Provider:它负责所有 bash 层职责——命令默认化与上限、deadline 融合与原因分类、面向模型的终端环境,以及后台读取合并——而进程组机制(有界 spill 输出、凭据清除、终止升级、dispose(资源释放))属于 subprocess 服务。每次调用都 spawn 全新的非登录 `bash -c`,不读取 rc 文件,因此命令是确定性的,shell 状态绝不会在调用之间泄漏。
83
+ 本执行器是基于 subprocess 能力的 `ctx.shell` seam 的 Service Provider:它负责所有 bash 层职责——命令默认化与上限、deadline 融合与原因分类、面向模型的终端环境,以及后台读取合并——而 managed-range 机制(有界 spill 输出、凭据清除、终止升级、完全停稳与 dispose(资源释放))属于 subprocess 服务。每次调用都 spawn 全新的非登录 `bash -c`,不读取 rc 文件,因此命令是确定性的,shell 状态绝不会在调用之间泄漏。
84
84
 
85
85
  ### 源码地图
86
86
 
@@ -114,7 +114,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
114
114
  - [bash-sandbox](../bash-sandbox/README.zh.md) —— 需要沙箱能力时替换组合的受限执行器。
115
115
  - [tool-bash](../tool-bash/README.zh.md) —— 基于本执行器的面向模型 `bash` 工具。
116
116
  - [Bash 执行器子系统](../../../docs/subsystems/shell.zh.md) —— 请求/spec 词汇、结果与完整的服务约定。
117
- - [subprocess-local](../../subprocess/subprocess-local/README.zh.md) —— 本执行器背后的进程组机制。
117
+ - [subprocess-local](../../subprocess/subprocess-local/README.zh.md) —— 本执行器背后的 managed-range 机制。
118
118
 
119
119
  -----
120
120
 
@@ -137,7 +137,7 @@ if (result.timedOut) console.log('timed out after', result.timeoutMs)
137
137
  - **自身不提供隔离**——命令以 harness 进程的权限运行;需要隔离的部署组合 `dsh-bash-sandbox`,每次调用的 allow/deny/ask 策略则属于工具的 `pre-execute` waterfall。
138
138
  - **没有持久 shell 或 PTY**——每次调用都启动全新的非登录 `bash -c`;仅持久化 cwd 与交互式终端会话均继续延期,直到真实工作流需要它们。
139
139
  - **仅支持 POSIX**——`bash` 二进制已硬编码,底层服务的进程组语义也是 POSIX 的;不支持 Windows。
140
- - **后台 spawn 失败提示只交付一次**——subprocess 服务不会为从未真正运行的进程缓冲任何输出,因此执行器把 `spawn failed: …` 注入恰好一个 `readOutput()` 增量;丢弃了该增量的读取方无法再恢复它。
140
+ - **后台 provider failure 提示只交付一次**——`SubprocessHandle.done` 可能在 target 开始执行前或后 reject,因此执行器把不声明失败阶段的 `subprocess failed before reporting an outcome: …` 注入恰好一个 `readOutput()` 增量;丢弃了该增量的读取方无法再恢复它。
141
141
 
142
142
  <a id="dev-note"></a>
143
143
  ### 开发备注
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import { MAX_TIMER_DELAY_MS, clampTimeout, deadline, timeoutOf } from "@deepseek
4
4
  //#region lib/types/index.js
5
5
  /**
6
6
  * Local Service Provider for the bash capability seam over the subprocess
7
- * capability seam. Public commands run as `bash -c` in a managed process group spawned
7
+ * capability seam. Public commands run as `bash -c` in a provider-managed range
8
8
  * through `ctx.subprocess`; subclasses may reuse the same mechanics with an
9
9
  * explicit argv. This executor owns command defaulting, deadlines and cause
10
10
  * classification, the model-friendly terminal environment, and the model-facing
@@ -117,9 +117,9 @@ function assertServiceableBashConfig(config) {
117
117
  if (resolved.graceMs > MAX_TIMER_DELAY_MS) throw new Error(`bash-local: graceMs must be no greater than ${MAX_TIMER_DELAY_MS}`);
118
118
  }
119
119
  /**
120
- * Local bash executor over `ctx.subprocess`. Bounded output, spill files, and
121
- * process-group SIGTERM→SIGKILL escalation are the subprocess service's
122
- * mechanics; this executor supplies their configured budgets per spawn, so a
120
+ * Local bash executor over `ctx.subprocess`. Bounded output, spill files,
121
+ * managed-range SIGTERM→SIGKILL escalation, and quiescence are the subprocess
122
+ * service's mechanics; this executor supplies their configured budgets per spawn, so a
123
123
  * still-running background process stays managed (killed and joined at
124
124
  * composition teardown) even across an executor reload.
125
125
  */
@@ -263,20 +263,20 @@ var LocalBashExecutor = class LocalBashExecutor extends ShellExecutor {
263
263
  }
264
264
  /**
265
265
  * Start an explicit argv with the background lifecycle, environment, output,
266
- * cancellation, and process-tree ownership semantics of this executor.
266
+ * cancellation, and managed-range ownership semantics of this executor.
267
267
  * Subclasses use this after replacing the public command's shell argv at an
268
268
  * execution boundary.
269
269
  * @param spec - resolved execution settings and caller-owned command metadata.
270
270
  * @param argv - exact executable and arguments to hand to `ctx.subprocess`.
271
- * @returns the live background handle; spawn rejection settles it as killed.
271
+ * @returns the live background handle; provider rejection settles it as killed.
272
272
  */
273
273
  startArgv(spec, argv) {
274
274
  const running = this.ctx.subprocess.spawn(this.spawnSpec(spec, argv, this.config.maxOutputBytes, spec.signal));
275
275
  const collected = LocalBashExecutor.collected(running);
276
- let spawnFailureNote;
277
- const consumeSpawnFailure = () => {
278
- const note = spawnFailureNote ?? "";
279
- spawnFailureNote = void 0;
276
+ let providerFailureNote;
277
+ const consumeProviderFailure = () => {
278
+ const note = providerFailureNote ?? "";
279
+ providerFailureNote = void 0;
280
280
  return note;
281
281
  };
282
282
  let stdoutOffset = 0;
@@ -292,15 +292,21 @@ var LocalBashExecutor = class LocalBashExecutor extends ShellExecutor {
292
292
  this.onProcessDone(proc, collected.stderr.readFrom(0).text, false);
293
293
  }, (error) => {
294
294
  proc.status = "killed";
295
- spawnFailureNote = `spawn failed: ${String(error)}`;
296
- this.onProcessDone(proc, spawnFailureNote, true, error);
295
+ let detail = "unprintable provider failure";
296
+ try {
297
+ detail = String(error);
298
+ } catch {}
299
+ providerFailureNote = `subprocess failed before reporting an outcome: ${detail}`;
300
+ this.onProcessDone(proc, providerFailureNote, true, error);
297
301
  }),
298
302
  readOutput: () => {
299
303
  const out = collected.stdout.readFrom(stdoutOffset);
300
304
  const err = collected.stderr.readFrom(stderrOffset);
301
305
  stdoutOffset = out.nextOffset;
302
306
  stderrOffset = err.nextOffset;
303
- const errText = err.text.length > 0 ? err.text : consumeSpawnFailure();
307
+ const providerFailure = consumeProviderFailure();
308
+ const failureSeparator = err.text.length > 0 && !err.text.endsWith("\n") ? "\n" : "";
309
+ const errText = err.text + (providerFailure.length > 0 ? `${failureSeparator}${providerFailure}` : "");
304
310
  const separator = out.text.length > 0 && !out.text.endsWith("\n") ? "\n" : "";
305
311
  return {
306
312
  delta: out.text + (errText.length > 0 ? `${separator}[stderr]\n${errText}` : ""),
@@ -320,15 +326,15 @@ var LocalBashExecutor = class LocalBashExecutor extends ShellExecutor {
320
326
  }
321
327
  /**
322
328
  * Settlement hook for subclasses that attach execution facts to a process.
323
- * Called after exit facts or spawn-failure output are stamped and before
329
+ * Called after exit facts or provider-failure output are stamped and before
324
330
  * {@link ShellProcess.done} resolves. The base implementation is intentionally
325
331
  * empty.
326
332
  * @param _proc - the settled process handle.
327
333
  * @param _stderr - the process's retained stderr tail used by subclasses for settlement classification.
328
- * @param _spawnFailed - whether the subprocess promise rejected before a process started.
329
- * @param _spawnError - the original spawn rejection reason, which may itself be undefined.
334
+ * @param _providerRejected - whether the subprocess promise rejected without a direct outcome.
335
+ * @param _providerError - the provider rejection reason, which may itself be undefined.
330
336
  */
331
- onProcessDone(_proc, _stderr, _spawnFailed, _spawnError) {}
337
+ onProcessDone(_proc, _stderr, _providerRejected, _providerError) {}
332
338
  };
333
339
  //#endregion
334
340
  export { ENV_OVERRIDES, LocalBashExecutor, LocalBashExecutor as default, assertServiceableBashConfig };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Local Service Provider for the bash capability seam over the subprocess
3
- * capability seam. Public commands run as `bash -c` in a managed process group spawned
3
+ * capability seam. Public commands run as `bash -c` in a provider-managed range
4
4
  * through `ctx.subprocess`; subclasses may reuse the same mechanics with an
5
5
  * explicit argv. This executor owns command defaulting, deadlines and cause
6
6
  * classification, the model-friendly terminal environment, and the model-facing
@@ -52,9 +52,9 @@ type ResolvedConfig = Required<Omit<Config, 'cwd'>> & Pick<Config, 'cwd'>;
52
52
  */
53
53
  export declare function assertServiceableBashConfig(config: Config): void;
54
54
  /**
55
- * Local bash executor over `ctx.subprocess`. Bounded output, spill files, and
56
- * process-group SIGTERM→SIGKILL escalation are the subprocess service's
57
- * mechanics; this executor supplies their configured budgets per spawn, so a
55
+ * Local bash executor over `ctx.subprocess`. Bounded output, spill files,
56
+ * managed-range SIGTERM→SIGKILL escalation, and quiescence are the subprocess
57
+ * service's mechanics; this executor supplies their configured budgets per spawn, so a
58
58
  * still-running background process stays managed (killed and joined at
59
59
  * composition teardown) even across an executor reload.
60
60
  */
@@ -91,25 +91,25 @@ export declare class LocalBashExecutor extends ShellExecutor {
91
91
  start(spec: ShellExecSpec): ShellProcess;
92
92
  /**
93
93
  * Start an explicit argv with the background lifecycle, environment, output,
94
- * cancellation, and process-tree ownership semantics of this executor.
94
+ * cancellation, and managed-range ownership semantics of this executor.
95
95
  * Subclasses use this after replacing the public command's shell argv at an
96
96
  * execution boundary.
97
97
  * @param spec - resolved execution settings and caller-owned command metadata.
98
98
  * @param argv - exact executable and arguments to hand to `ctx.subprocess`.
99
- * @returns the live background handle; spawn rejection settles it as killed.
99
+ * @returns the live background handle; provider rejection settles it as killed.
100
100
  */
101
101
  protected startArgv(spec: ShellExecSpec, argv: readonly string[]): ShellProcess;
102
102
  /**
103
103
  * Settlement hook for subclasses that attach execution facts to a process.
104
- * Called after exit facts or spawn-failure output are stamped and before
104
+ * Called after exit facts or provider-failure output are stamped and before
105
105
  * {@link ShellProcess.done} resolves. The base implementation is intentionally
106
106
  * empty.
107
107
  * @param _proc - the settled process handle.
108
108
  * @param _stderr - the process's retained stderr tail used by subclasses for settlement classification.
109
- * @param _spawnFailed - whether the subprocess promise rejected before a process started.
110
- * @param _spawnError - the original spawn rejection reason, which may itself be undefined.
109
+ * @param _providerRejected - whether the subprocess promise rejected without a direct outcome.
110
+ * @param _providerError - the provider rejection reason, which may itself be undefined.
111
111
  */
112
- protected onProcessDone(_proc: ShellProcess, _stderr: string, _spawnFailed: boolean, _spawnError?: unknown): void;
112
+ protected onProcessDone(_proc: ShellProcess, _stderr: string, _providerRejected: boolean, _providerError?: unknown): void;
113
113
  }
114
114
  export default LocalBashExecutor;
115
115
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-bash-local",
3
3
  "description": "Local-subprocess implementation of the DeepSeek Harness bash executor seam",
4
- "version": "0.1.2-rc.1",
4
+ "version": "0.1.3-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,21 +27,21 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "peerDependencies": {
30
- "@deepseek-ai/dsh-shell": "^0.1.2-rc.1",
31
- "@deepseek-ai/dsh-timeout": "^0.1.2-rc.1",
30
+ "@deepseek-ai/dsh-shell": "^0.1.3-alpha.2",
31
+ "@deepseek-ai/dsh-subprocess": "^0.1.3-alpha.2",
32
+ "@deepseek-ai/dsh-timeout": "^0.1.3-alpha.2",
32
33
  "@deepseek-ai/cordis": "^4.0.2",
33
- "@deepseek-ai/dsh-settings": "^0.1.2-rc.1",
34
- "@deepseek-ai/dsh-subprocess": "^0.1.2-rc.1"
34
+ "@deepseek-ai/dsh-settings": "^0.1.3-alpha.2"
35
35
  },
36
36
  "dependencies": {
37
37
  "@deepseek-ai/schemastery": "^3.18.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@deepseek-ai/dsh-shell": "^0.1.2-rc.1",
41
- "@deepseek-ai/dsh-subprocess": "^0.1.2-rc.1",
42
- "@deepseek-ai/dsh-subprocess-local": "^0.1.2-rc.1",
43
- "@deepseek-ai/dsh-timeout": "^0.1.2-rc.1",
44
- "@deepseek-ai/cordis": "^4.0.2",
45
- "@deepseek-ai/dsh-settings": "^0.1.2-rc.1"
40
+ "@deepseek-ai/dsh-shell": "^0.1.3-alpha.2",
41
+ "@deepseek-ai/dsh-subprocess": "^0.1.3-alpha.2",
42
+ "@deepseek-ai/dsh-subprocess-local": "^0.1.3-alpha.2",
43
+ "@deepseek-ai/dsh-timeout": "^0.1.3-alpha.2",
44
+ "@deepseek-ai/dsh-settings": "^0.1.3-alpha.2",
45
+ "@deepseek-ai/cordis": "^4.0.2"
46
46
  }
47
47
  }