@linxin666/dsh-win-bash 0.4.17 → 0.4.19

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
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 0ecbceaea0a26781ee3b0340d8c55ee0aec4b61e
6
- README.zh.md: b0124801c815f6ca3520bba370cf8a63e0621801
5
+ README.md: f8261135a77cc61dc2c7e52da1d145f7305a7b80
6
+ README.zh.md: 2a7b757d799c70be4e9da034d4215412d6097435
package/README.md CHANGED
@@ -85,11 +85,11 @@ listed shell - so the mnemonic the `win_bash` description carries is
85
85
  - **Per session, never process-wide.** The withdrawal is a scoped tool
86
86
  restriction on the sessions this plugin serves. Anything else in the same
87
87
  deployment keeps the surface it composed.
88
- - **Only while `win_bash` is actually mounted.** A refused availability gate,
89
- a payload that fails verification, a non-Windows host, or a row with
90
- `replacePwsh: false` leaves `pwsh` exactly where it was. Withdrawing the
91
- only usable shell of a deployment that ends up with no replacement shell
92
- would leave the session with neither.
88
+ - **Only while `win_bash` is actually mounted.** A payload that fails
89
+ verification, a non-Windows host, or a row with `replacePwsh: false` leaves
90
+ `pwsh` exactly where it was. Withdrawing the only usable shell of a
91
+ deployment that ends up with no replacement shell would leave the session
92
+ with neither.
93
93
  - **Windows only.** On POSIX the host shell is bash, win_bash does not mount,
94
94
  and this logic produces no restriction, no listener and no effect at all.
95
95
  - **Reversible.** Every restriction is lifted when its session is disposed and
@@ -100,30 +100,9 @@ preference with the tool description alone.
100
100
 
101
101
  ## Availability
102
102
 
103
- The tool serves sessions that run the LiangShen (梁神) agent preset, so its
104
- availability follows that preset's **declaration**. At mount the plugin asks the
105
- harness's agent-preset registry whether a preset with id `liangshen` is
106
- declared; when it is, the tool registers, and when it is not, no tool is
107
- registered at all and one info line states the reason. A tool that mounted and
108
- refused every call would teach the model a capability the session does not have,
109
- which is worse than an honest absence.
110
-
111
- Three verdicts are distinguishable in the log, because they need different
112
- actions: the preset is declared (registered), no such preset is declared (enable
113
- the `dsh-liangshen` plugin row), and no usable agent-preset registry is
114
- published in this deployment. Setting `syncWithLiangShen: false` skips the gate
115
- entirely and always registers the tool.
116
-
117
- The verdict waits for the host plugin tree to settle and then reads the roster.
118
- A read that already carries the declaration decides at once; one that does not is
119
- re-read on a short bounded schedule, because the declaring plugin publishes its
120
- preset off its own activation return and the two can therefore land in either
121
- order. A late declaration is never turned into a refusal.
122
-
123
- The registry declares no roster-change event, so the verdict is decided once per
124
- mount. Toggling the LiangShen row takes effect for `win_bash` after the plugin
125
- manager refreshes the profile — the same freshness model the rest of the family
126
- uses, not an immediate one.
103
+ The tool registers on any supported Windows x64 host once the vendored payload verifies against its manifest and the row's configuration resolves. Availability follows the platform, the shipped payload and the configuration alone — no preset needs to be declared and no other plugin row needs to be enabled.
104
+
105
+ A host that is not Windows x64, or a payload that fails verification, refuses the mount with one warning line, and an invalid configuration is rejected before registration. Each leaves `win_bash` unregistered rather than mounting a tool whose every call would fail.
127
106
 
128
107
  ## Install
129
108
 
@@ -149,7 +128,6 @@ so a POSIX profile can carry the same composition without mounting anything.
149
128
  | `maxStderrBytes` | 32768 | Visible stderr byte budget (1024..524288). |
150
129
  | `enableRunInBackground` | true | Whether `run_in_background` is offered. The parameter is advertised only when this is true and the deployment composes a job registry; a deployment without one never offers it, and a call that asks for it anyway is refused rather than run in the foreground. |
151
130
  | `description` | built-in | Model-facing tool description; deployments may describe their own environment. |
152
- | `syncWithLiangShen` | true | When true, the tool registers only while the `liangshen` agent preset is declared; false skips that gate and always registers. |
153
131
  | `replacePwsh` | true | While this tool is registered, withdraw the host's `pwsh` tool from each session's model-facing surface. Visibility only: a deliberate `pwsh` call still runs. False lists both shells. |
154
132
 
155
133
  ## Tool interface
package/README.zh.md CHANGED
@@ -65,9 +65,9 @@ schema 渲染本行的配置表单。
65
65
  pre-execute 拒绝——直接把退路那一级拿掉,等于用能力损失换取一个偏好。
66
66
  - **按会话生效,绝不进程级。** 撤下是本插件所服务会话上的作用域工具限制;同一部署
67
67
  里的其它部分保留自己组合出来的面。
68
- - **只在 `win_bash` 真的挂载成功时。** 可用性门控拒绝、载荷校验失败、非 Windows
69
- 宿主,或行里写了 `replacePwsh: false`,都会让 `pwsh` 原封不动。对最终没有替代
70
- shell 的部署再撤掉它唯一可用的 shell,会让会话两个都没有。
68
+ - **只在 `win_bash` 真的挂载成功时。** 载荷校验失败、非 Windows 宿主,或行里写了
69
+ `replacePwsh: false`,都会让 `pwsh` 原封不动。对最终没有替代 shell 的部署再
70
+ 撤掉它唯一可用的 shell,会让会话两个都没有。
71
71
  - **仅 Windows。** POSIX 上宿主 shell 是 bash,win_bash 不挂载,这套逻辑不产生任何
72
72
  限制、监听器或副作用。
73
73
  - **可逆。** 每条限制都会在对应会话销毁时、以及插件卸载时被解除,且逐个隔离回调。
@@ -76,23 +76,12 @@ schema 渲染本行的配置表单。
76
76
 
77
77
  ## 可用性
78
78
 
79
- 本工具服务于运行梁神(LiangShen)agent preset 的会话,因此其可用性跟随该预设的
80
- **声明状态**。挂载时插件向宿主的 agent-preset 注册表查询是否声明了 id 为
81
- `liangshen` 的预设:已声明则注册工具;未声明则完全不注册任何工具,并用一行
82
- info 日志说明原因。一个「挂载了但每次调用都报错」的工具等于教模型一个会话并不
83
- 具备的能力,比诚实的缺席更糟。
79
+ 只要随包载荷通过清单校验、本行配置解析通过,本工具就在任何受支持的 Windows x64
80
+ 宿主上注册。可用性只跟随平台、随包载荷与配置,无需声明任何 preset,也无需启用其它
81
+ 插件行。
84
82
 
85
- 日志中可区分三种判定,因为它们需要不同的处置:预设已声明(已注册)、未声明该
86
- 预设(去启用 `dsh-liangshen` 插件行)、本部署没有可用的 agent-preset 注册表。
87
- 把 `syncWithLiangShen` 设为 false 会完全跳过门控并总是注册本工具。
88
-
89
- 判定会先等宿主插件树稳定,再读取名册。若首次读取就已带上该声明,立即判定;
90
- 若没有,则按一个短的、有上限的节奏重读——因为声明方插件是在自己的激活返回之后才
91
- 发布预设的,两者先后顺序不固定。迟到的声明绝不会被当成拒绝。
92
-
93
- 注册表不提供声明变更事件,因此判定在每次挂载时做一次。切换梁神插件行后,
94
- `win_bash` 会在插件管理器刷新 profile 后跟随生效——与家族其它部分同一套新鲜度
95
- 模型,而非即时生效。
83
+ 非 Windows x64 的宿主、或校验失败的载荷,会用一行警告拒绝挂载;非法配置会在注册
84
+ 之前被拒绝。三者都只让 `win_bash` 不予注册,绝不挂载一个每次调用都会失败的工具。
96
85
 
97
86
  ## 安装
98
87
 
@@ -118,7 +107,6 @@ bundle patch 把本包的行在非 Windows 宿主上标为 disabled,因此 POS
118
107
  | `maxStderrBytes` | 32768 | stderr 可见字节上限(1024..524288)。 |
119
108
  | `enableRunInBackground` | true | 是否提供 `run_in_background`。只有该项为 true 且部署组合了 job registry 时该参数才会被声明;没有 registry 的部署不会声明它,此时仍然请求该参数的调用会被拒绝,而不是退化到前台执行。 |
120
109
  | `description` | 内置 | 面向模型的工具描述;部署可描述自己的环境。 |
121
- | `syncWithLiangShen` | true | 为 true 时仅在 `liangshen` agent preset 已声明时注册本工具;false 跳过该门控、总是注册。 |
122
110
  | `replacePwsh` | true | 本工具注册期间,把宿主的 `pwsh` 工具从每个会话的模型可见面上撤下。只管可见性:刻意发起的 `pwsh` 调用照常执行。false 则两个 shell 并列。 |
123
111
 
124
112
  ## 工具接口
package/lib/index.js CHANGED
@@ -1605,14 +1605,6 @@ const STDERR_MIN_BYTES = 1024;
1605
1605
  /** Visible stderr budget ceiling, in bytes. */
1606
1606
  const STDERR_MAX_BYTES = 512 * 1024;
1607
1607
  /**
1608
- * Whether win_bash follows the LiangShen agent preset's declaration by
1609
- * default. When true (the shipped setting) the tool registers only for a
1610
- * deployment that declares the `liangshen` preset; false skips the gate and
1611
- * always registers, which is the escape hatch for a session that wants this
1612
- * shell without the preset.
1613
- */
1614
- const DEFAULT_SYNC_WITH_LIANGSHEN = true;
1615
- /**
1616
1608
  * Model-facing tool description. Active voice; states the shell preference and
1617
1609
  * the persistence guarantee, so a model knows which shell to reach for before
1618
1610
  * it knows anything else about this tool.
@@ -1660,7 +1652,6 @@ const Config = Schema.object({
1660
1652
  maxStdoutBytes: Schema.number().min(STDOUT_MIN_BYTES).max(STDOUT_MAX_BYTES).default(DEFAULT_MAX_STDOUT_BYTES),
1661
1653
  maxStderrBytes: Schema.number().min(STDERR_MIN_BYTES).max(STDERR_MAX_BYTES).default(DEFAULT_MAX_STDERR_BYTES),
1662
1654
  description: Schema.string().default(DEFAULT_DESCRIPTION),
1663
- syncWithLiangShen: Schema.boolean().default(true),
1664
1655
  replacePwsh: Schema.boolean().default(true),
1665
1656
  enableRunInBackground: Schema.boolean().default(true)
1666
1657
  });
@@ -1670,7 +1661,6 @@ const CONFIG_DEFAULTS = {
1670
1661
  maxStdoutBytes: DEFAULT_MAX_STDOUT_BYTES,
1671
1662
  maxStderrBytes: DEFAULT_MAX_STDERR_BYTES,
1672
1663
  description: DEFAULT_DESCRIPTION,
1673
- syncWithLiangShen: true,
1674
1664
  replacePwsh: true,
1675
1665
  enableRunInBackground: true
1676
1666
  };
@@ -1689,7 +1679,7 @@ const CONFIG_DEFAULTS = {
1689
1679
  function resolveConfig(input) {
1690
1680
  const resolved = {
1691
1681
  ...CONFIG_DEFAULTS,
1692
- ...input ?? {}
1682
+ ...input
1693
1683
  };
1694
1684
  const violations = validateConfig(resolved);
1695
1685
  if (violations.length > 0) throw new Error("win_bash config rejected: " + violations.map((v) => v.field + ": " + v.message).join("; "));
@@ -1716,10 +1706,6 @@ function validateConfig(config) {
1716
1706
  field: "description",
1717
1707
  message: "must be a non-empty string"
1718
1708
  });
1719
- if (typeof config.syncWithLiangShen !== "boolean") violations.push({
1720
- field: "syncWithLiangShen",
1721
- message: "must be a boolean"
1722
- });
1723
1709
  if (typeof config.replacePwsh !== "boolean") violations.push({
1724
1710
  field: "replacePwsh",
1725
1711
  message: "must be a boolean"
@@ -1731,199 +1717,17 @@ function validateConfig(config) {
1731
1717
  return violations;
1732
1718
  }
1733
1719
  //#endregion
1734
- //#region src/gate.ts
1735
- /** Preset id whose declaration makes win_bash available. */
1736
- const LIANGSHEN_PRESET_ID = "liangshen";
1737
- /** Upper bound on the wait for the Host plugin tree to settle, in milliseconds. */
1738
- const GATE_SETTLE_TIMEOUT_MS = 1e4;
1739
- /** Upper bound on one registry roster read, in milliseconds. */
1740
- const GATE_READ_TIMEOUT_MS = 1e4;
1741
- /**
1742
- * How long a roster that does not yet declare LiangShen keeps being re-read,
1743
- * in milliseconds. See the module header: the declaring plugin publishes the
1744
- * definition on a detached chain, so the tree can settle first. Only paid when
1745
- * the declaration is genuinely absent, since a visible one returns at once.
1746
- */
1747
- const GATE_DECLARATION_WAIT_MS = 5e3;
1748
- /** Re-read cadence during {@link GATE_DECLARATION_WAIT_MS}, in milliseconds. */
1749
- const GATE_POLL_INTERVAL_MS = 250;
1750
- /**
1751
- * Whether a roster declares the preset this tool follows.
1752
- * @param presets - rows as {@link PresetRosterReader.list} returns them.
1753
- * @returns true when one row carries the LiangShen id.
1754
- */
1755
- function declaresLiangShen(presets) {
1756
- return presets.some((preset) => preset?.id === LIANGSHEN_PRESET_ID);
1757
- }
1758
- /**
1759
- * Read one optional service without letting a refused lookup escape: a cordis
1760
- * service proxy throws for a name it cannot resolve, and an absent optional
1761
- * service is an ordinary state here, not an error.
1762
- * @param ctx - the plugin context.
1763
- * @param name - the service name.
1764
- * @returns the service, or undefined when it is not resolvable.
1765
- */
1766
- function readService$1(ctx, name) {
1767
- try {
1768
- return ctx.get(name);
1769
- } catch {
1770
- return;
1771
- }
1772
- }
1773
- /**
1774
- * The published registry, when this deployment has one shaped like the one this
1775
- * gate consumes.
1776
- * @param ctx - the plugin context.
1777
- * @returns the reader, or undefined when no usable registry is published.
1778
- */
1779
- function readPresetRegistry(ctx) {
1780
- const candidate = readService$1(ctx, "agentPresets");
1781
- if (candidate === null || typeof candidate !== "object") return void 0;
1782
- if (typeof candidate.list !== "function") return void 0;
1783
- return candidate;
1784
- }
1785
- /**
1786
- * Run one promise with a deadline. The timer is always cleared, so a fast
1787
- * answer leaves no stray handle behind.
1788
- * @param work - the promise to bound.
1789
- * @param timeoutMs - the bound in milliseconds.
1790
- * @returns the promise's value.
1791
- * @throws when the deadline passes first.
1792
- */
1793
- async function withDeadline(work, timeoutMs) {
1794
- let timer;
1795
- try {
1796
- return await Promise.race([work, new Promise((_resolve, reject) => {
1797
- timer = setTimeout(() => {
1798
- reject(/* @__PURE__ */ new Error("timed out after " + timeoutMs.toString() + "ms"));
1799
- }, timeoutMs);
1800
- })]);
1801
- } finally {
1802
- if (timer !== void 0) clearTimeout(timer);
1803
- }
1804
- }
1805
- /**
1806
- * Wait until the Host loader tree has no pending import or lifecycle work.
1807
- *
1808
- * Waiting for the whole tree rather than this row's neighbours is deliberate:
1809
- * the roster belongs to the deployment, not to one group, and the loader's own
1810
- * await() is the only predicate that means "every row has been applied". A row
1811
- * merely waiting for a service it will never get carries no pending task, so it
1812
- * cannot hold this wait open; one that is genuinely mid-activation can, which is
1813
- * exactly the case the bound covers.
1814
- * @param ctx - the plugin context.
1815
- * @param options - the deadlines for this run.
1816
- * @returns how far the settle got.
1817
- */
1818
- async function settleHostTree(ctx, options = {}) {
1819
- const loader = readService$1(ctx, "loader");
1820
- if (loader === null || typeof loader !== "object") return "unavailable";
1821
- const wait = loader.await;
1822
- if (typeof wait !== "function") return "unavailable";
1823
- try {
1824
- await withDeadline(Promise.resolve(wait.call(loader)).then(() => void 0), options.settleTimeoutMs ?? 1e4);
1825
- return "settled";
1826
- } catch {
1827
- return "timed-out";
1828
- }
1829
- }
1830
- /**
1831
- * Sleep one timer turn.
1832
- *
1833
- * Production code, not a test helper: the wait IS the declaration window the
1834
- * module header describes, and the gate is only ever reached from a mount.
1835
- * @param ms - how long to wait.
1836
- */
1837
- function waitFor(ms) {
1838
- return new Promise((resolve) => {
1839
- setTimeout(resolve, ms);
1840
- });
1841
- }
1842
- /** One roster read, or undefined when the registry could not answer. */
1843
- async function readRoster(registry, timeoutMs) {
1844
- try {
1845
- const rows = await withDeadline(Promise.resolve(registry.list()), timeoutMs);
1846
- return Array.isArray(rows) ? rows : void 0;
1847
- } catch {
1848
- return;
1849
- }
1850
- }
1851
- /**
1852
- * Decide whether the LiangShen preset is declared in this deployment.
1853
- *
1854
- * Call this OFF the plugin's activation path — never awaited from a plugin
1855
- * apply. list() is not a leaf read: it audits every declared preset and, for one
1856
- * whose mounted subtree still has pending rows, awaits the Host loader tree
1857
- * (agent-preset-registry lib/index.js diagnostic). A plugin whose activation
1858
- * awaited this would wait on the loader tree while its OWN activation is among
1859
- * the tasks that tree is waiting for, and neither wait would ever settle. The
1860
- * entry calls this after its synchronous activation returned, which is what
1861
- * keeps this a wait and not a deadlock.
1862
- * @param ctx - the plugin context.
1863
- * @param options - the deadlines and cadence for this run.
1864
- * @returns the verdict, with the reason for the caller's log line.
1865
- */
1866
- async function startLiangShenGate(ctx, options = {}) {
1867
- const settled = await settleHostTree(ctx, options);
1868
- const registry = readPresetRegistry(ctx);
1869
- if (registry === void 0) return {
1870
- allowed: false,
1871
- reason: "registry-absent",
1872
- settled,
1873
- reads: 0
1874
- };
1875
- const readTimeoutMs = options.readTimeoutMs ?? 1e4;
1876
- const pollIntervalMs = options.pollIntervalMs ?? 250;
1877
- const waitMs = options.declarationWaitMs ?? 5e3;
1878
- let reads = 0;
1879
- const first = await readRoster(registry, readTimeoutMs);
1880
- reads += 1;
1881
- if (first === void 0) return {
1882
- allowed: false,
1883
- reason: "registry-unreadable",
1884
- settled,
1885
- reads
1886
- };
1887
- if (declaresLiangShen(first)) return {
1888
- allowed: true,
1889
- reason: "declared",
1890
- settled,
1891
- reads
1892
- };
1893
- const deadline = Date.now() + waitMs;
1894
- let answered = false;
1895
- while (Date.now() < deadline) {
1896
- await waitFor(Math.min(pollIntervalMs, Math.max(0, deadline - Date.now())));
1897
- const rows = await readRoster(registry, readTimeoutMs);
1898
- reads += 1;
1899
- if (rows === void 0) continue;
1900
- answered = true;
1901
- if (declaresLiangShen(rows)) return {
1902
- allowed: true,
1903
- reason: "declared",
1904
- settled,
1905
- reads
1906
- };
1907
- }
1908
- return {
1909
- allowed: false,
1910
- reason: answered ? "not-declared" : "registry-unreadable",
1911
- settled,
1912
- reads
1913
- };
1914
- }
1915
- //#endregion
1916
1720
  //#region src/pwsh-replacement.ts
1917
1721
  /** The host tool this module withdraws while win_bash serves a session. */
1918
1722
  const HOST_PWSH_TOOL = "pwsh";
1919
1723
  /** The one session mode win_bash can actually serve; every other mode refuses. */
1920
1724
  const SERVING_MODE = "danger-full-access";
1921
1725
  /** Every mode the policy service may answer with. */
1922
- const SANDBOX_MODES$1 = [
1726
+ const SANDBOX_MODES$1 = /* @__PURE__ */ new Set([
1923
1727
  "read-only",
1924
1728
  "workspace-write",
1925
1729
  "danger-full-access"
1926
- ];
1730
+ ]);
1927
1731
  /** The message of a thrown value, whatever it is. */
1928
1732
  function messageOf$1(error) {
1929
1733
  return error instanceof Error ? error.message : String(error);
@@ -1981,7 +1785,7 @@ function servingVerdict(read, session) {
1981
1785
  if (typeof cwd !== "string" || cwd === "") return "refuses";
1982
1786
  try {
1983
1787
  const mode = read.resolve({ session })?.mode;
1984
- if (!SANDBOX_MODES$1.includes(mode)) return "unknown";
1788
+ if (!SANDBOX_MODES$1.has(mode)) return "unknown";
1985
1789
  return mode === "danger-full-access" ? "serves" : "refuses";
1986
1790
  } catch {
1987
1791
  return "unknown";
@@ -2902,11 +2706,11 @@ const BACKGROUND_STDERR_BYTES = SHELL_STDERR_CAPTURE_BYTES;
2902
2706
  /** The registered tool name. Deliberately not bash. */
2903
2707
  const WIN_BASH_TOOL = "win_bash";
2904
2708
  /** Every sandbox mode a session may run under. */
2905
- const SANDBOX_MODES = [
2709
+ const SANDBOX_MODES = /* @__PURE__ */ new Set([
2906
2710
  "read-only",
2907
2711
  "workspace-write",
2908
2712
  "danger-full-access"
2909
- ];
2713
+ ]);
2910
2714
  /** The only mode this tool runs under; every other mode is refused. */
2911
2715
  const SUPPORTED_MODE = "danger-full-access";
2912
2716
  /**
@@ -3114,7 +2918,7 @@ function resolvePolicy(ctx, agent) {
3114
2918
  if (service === void 0 || typeof service.resolve !== "function") return void 0;
3115
2919
  const session = agent?.session;
3116
2920
  const policy = service.resolve(session === void 0 ? {} : { session });
3117
- if (!SANDBOX_MODES.includes(policy.mode) || typeof policy.workspaceRoot !== "string") throw new Error("win_bash: the sandbox policy service returned an invalid policy; no command was started.");
2921
+ if (!SANDBOX_MODES.has(policy.mode) || typeof policy.workspaceRoot !== "string") throw new Error("win_bash: the sandbox policy service returned an invalid policy; no command was started.");
3118
2922
  return policy;
3119
2923
  }
3120
2924
  /**
@@ -3257,25 +3061,14 @@ const name = "dsh-win-bash";
3257
3061
  /** Required services: the tool registry and the managed subprocess seam. */
3258
3062
  const inject = ["tools", "subprocess"];
3259
3063
  /**
3260
- * One human-readable line explaining a refused gate verdict.
3261
- * @param outcome - the gate's verdict.
3262
- * @returns the message the entry logs.
3263
- */
3264
- function gateRefusalMessage(outcome) {
3265
- const settleNote = outcome.settled === "timed-out" ? "; the host plugin tree did not settle in time, so the roster was read during boot" : "";
3266
- if (outcome.reason === "registry-absent") return "win_bash was not registered (syncWithLiangShen is on and this deployment publishes no agent-preset registry, so a preset with id liangshen cannot be declared)" + settleNote;
3267
- if (outcome.reason === "registry-unreadable") return "win_bash was not registered (syncWithLiangShen is on and the agent-preset registry roster could not be read)" + settleNote;
3268
- return "win_bash was not registered (syncWithLiangShen is on and no preset with id liangshen is declared; enable the dsh-liangshen plugin row, or set syncWithLiangShen to false to register this shell without the preset)" + settleNote;
3269
- }
3270
- /**
3271
3064
  * Register the win_bash tool and its per-session shell registry on the calling
3272
3065
  * fiber. Called only once per fiber: the caller decides whether to call at all.
3273
3066
  *
3274
- * The host pwsh replacement is installed from HERE and not from the gate or
3275
- * apply, because its precondition is exactly "win_bash is now on the wire": a
3276
- * deployment whose gate refused, whose payload failed verification, or that
3277
- * runs on a POSIX host never reaches this function and therefore never touches
3278
- * the host's shell.
3067
+ * The host pwsh replacement is installed from HERE and not from apply, because
3068
+ * its precondition is exactly "win_bash is now on the wire": a deployment whose
3069
+ * payload failed verification, whose config was rejected, or that runs on a
3070
+ * POSIX host never reaches this function and therefore never touches the host's
3071
+ * shell.
3279
3072
  * @param ctx - context carrying tools and subprocess.
3280
3073
  * @param config - the resolved configuration.
3281
3074
  * @param runtime - the verified payload paths.
@@ -3296,56 +3089,6 @@ function registerWinBash(ctx, config, runtime) {
3296
3089
  if (config.replacePwsh) installPwshReplacement(ctx);
3297
3090
  }
3298
3091
  /**
3299
- * Apply the availability gate, then register the tool when it allows it.
3300
- *
3301
- * The returned promise is deliberately NOT awaited by apply: the gate's roster
3302
- * read audits every declared preset and can await the Host loader tree, which
3303
- * still counts this very activation among its pending tasks — awaiting it from
3304
- * inside the activation would make the two waits depend on each other and
3305
- * neither would settle. Keeping the decision off the activation path also
3306
- * keeps the loader entry's own inertia free of it, so the tree can settle.
3307
- *
3308
- * A fiber disposed while the gate was deciding registers nothing: its tool
3309
- * effect would be refused anyway, and its shells would outlive it.
3310
- * @param ctx - context carrying tools and subprocess.
3311
- * @param config - the resolved configuration.
3312
- * @param runtime - the verified payload paths.
3313
- * @param options - gate deadlines; the defaults are the shipped bounds.
3314
- * @returns the decision, for the caller to observe (never rejects).
3315
- */
3316
- async function mountWithGate(ctx, config, runtime, options = {}) {
3317
- let closed = false;
3318
- ctx.effect(() => () => {
3319
- closed = true;
3320
- }, "dsh-win-bash: gate continuation lifetime");
3321
- const mount = (announcement) => {
3322
- if (announcement !== void 0) ctx.logger?.info?.(announcement);
3323
- try {
3324
- registerWinBash(ctx, config, runtime);
3325
- } catch (error) {
3326
- ctx.logger?.error?.("dsh-win-bash: win_bash could not be registered: " + (error instanceof Error ? error.message : String(error)));
3327
- }
3328
- };
3329
- if (!config.syncWithLiangShen) {
3330
- mount();
3331
- return;
3332
- }
3333
- let outcome;
3334
- try {
3335
- outcome = await startLiangShenGate(ctx, options);
3336
- } catch (error) {
3337
- if (closed) return;
3338
- ctx.logger?.warn?.("dsh-win-bash: win_bash was not registered (the LiangShen availability gate failed: " + (error instanceof Error ? error.message : String(error)) + ")");
3339
- return;
3340
- }
3341
- if (closed) return;
3342
- if (!outcome.allowed) {
3343
- ctx.logger?.info?.("dsh-win-bash: " + gateRefusalMessage(outcome));
3344
- return;
3345
- }
3346
- mount("dsh-win-bash: win_bash registered (the liangshen preset is declared)");
3347
- }
3348
- /**
3349
3092
  * Mount the plugin.
3350
3093
  * @param ctx - context carrying tools and subprocess.
3351
3094
  * @param config - the row's config, validated by {@link Config}.
@@ -3377,9 +3120,11 @@ function apply(ctx, config) {
3377
3120
  }, (error) => {
3378
3121
  ctx.logger?.warn?.("dsh-win-bash: the orphaned shell temp directory sweep failed: " + (error instanceof Error ? error.message : String(error)));
3379
3122
  });
3380
- mountWithGate(ctx, resolved, runtime).catch((error) => {
3381
- ctx.logger?.error?.("dsh-win-bash: the mount continuation failed: " + (error instanceof Error ? error.message : String(error)));
3382
- });
3123
+ try {
3124
+ registerWinBash(ctx, resolved, runtime);
3125
+ } catch (error) {
3126
+ ctx.logger?.error?.("dsh-win-bash: win_bash could not be registered: " + (error instanceof Error ? error.message : String(error)));
3127
+ }
3383
3128
  }
3384
3129
  //#endregion
3385
- export { BACKGROUND_JOB_KIND, CACHE_DIR_PARTS, CACHE_STAGING_PREFIX, CONFIG_DEFAULTS, Config, DEFAULT_DESCRIPTION, DEFAULT_ENABLE_RUN_IN_BACKGROUND, DEFAULT_REPLACE_PWSH, DEFAULT_SYNC_WITH_LIANGSHEN, GATE_DECLARATION_WAIT_MS, GATE_POLL_INTERVAL_MS, GATE_READ_TIMEOUT_MS, GATE_SETTLE_TIMEOUT_MS, HOST_PWSH_TOOL, ISOLATED_CACHE_DIR_PARTS, LIANGSHEN_PRESET_ID, RUNTIME_ROOT_ENV, SERVING_MODE, SHELL_TEMP_PREFIX, ShellRegistry, ShellUnavailableError, WIN_BASH_TOOL, apply, bashIn, bashPath, binIn, buildFrame, cacheRoot, declaresLiangShen, gateRefusalMessage, inject, installPwshReplacement, isolatedCacheRoot, markerFor, mountWithGate, name, parseChecksums, parseFrame, payloadKey, prepareRuntime, readJobRegistry, readPresetRegistry, registerWinBash, removeShellTempDir, renderResult, resolveRuntime, runtimeRoot, settleHostTree, shIn, shPath, shellArgv, shellEnvironment, shellTempDir, startBackgroundJob, startLiangShenGate, stripTerminalEscapes, sweepOrphanShellTempDirs, truncationNotice, validateConfig, verifyPayload, verifyPayloadRoot };
3130
+ export { BACKGROUND_JOB_KIND, CACHE_DIR_PARTS, CACHE_STAGING_PREFIX, CONFIG_DEFAULTS, Config, DEFAULT_DESCRIPTION, DEFAULT_ENABLE_RUN_IN_BACKGROUND, DEFAULT_REPLACE_PWSH, HOST_PWSH_TOOL, ISOLATED_CACHE_DIR_PARTS, RUNTIME_ROOT_ENV, SERVING_MODE, SHELL_TEMP_PREFIX, ShellRegistry, ShellUnavailableError, WIN_BASH_TOOL, apply, bashIn, bashPath, binIn, buildFrame, cacheRoot, inject, installPwshReplacement, isolatedCacheRoot, markerFor, name, parseChecksums, parseFrame, payloadKey, prepareRuntime, readJobRegistry, registerWinBash, removeShellTempDir, renderResult, resolveRuntime, runtimeRoot, shIn, shPath, shellArgv, shellEnvironment, shellTempDir, startBackgroundJob, stripTerminalEscapes, sweepOrphanShellTempDirs, truncationNotice, validateConfig, verifyPayload, verifyPayloadRoot };
@@ -23,14 +23,6 @@ export declare const STDOUT_MAX_BYTES: number;
23
23
  export declare const STDERR_MIN_BYTES = 1024;
24
24
  /** Visible stderr budget ceiling, in bytes. */
25
25
  export declare const STDERR_MAX_BYTES: number;
26
- /**
27
- * Whether win_bash follows the LiangShen agent preset's declaration by
28
- * default. When true (the shipped setting) the tool registers only for a
29
- * deployment that declares the `liangshen` preset; false skips the gate and
30
- * always registers, which is the escape hatch for a session that wants this
31
- * shell without the preset.
32
- */
33
- export declare const DEFAULT_SYNC_WITH_LIANGSHEN = true;
34
26
  /**
35
27
  * Model-facing tool description. Active voice; states the shell preference and
36
28
  * the persistence guarantee, so a model knows which shell to reach for before
@@ -74,8 +66,6 @@ export interface WinBashConfigInput {
74
66
  maxStderrBytes?: number;
75
67
  /** Model-facing tool description override. */
76
68
  description?: string;
77
- /** Whether the tool's availability follows the LiangShen preset declaration. */
78
- syncWithLiangShen?: boolean;
79
69
  /** Whether the host's pwsh tool is hidden while win_bash is registered. */
80
70
  replacePwsh?: boolean;
81
71
  /** Whether run_in_background is available (also requires a job registry). */
@@ -91,8 +81,6 @@ export interface WinBashConfig {
91
81
  maxStderrBytes: number;
92
82
  /** Model-facing tool description. */
93
83
  description: string;
94
- /** Whether the tool's availability follows the LiangShen preset declaration. */
95
- syncWithLiangShen: boolean;
96
84
  /** Whether the host's pwsh tool is hidden while win_bash is registered. */
97
85
  replacePwsh: boolean;
98
86
  /** Whether run_in_background is available (also requires a job registry). */
@@ -25,13 +25,13 @@
25
25
  * or no safe root at all, keeps the tool working from the packaged tree and
26
26
  * logs that updates will need this host stopped.
27
27
  *
28
- * Availability gate: win_bash serves sessions that run the LiangShen (梁神)
29
- * preset, so its registration follows that preset's DECLARATION in the
30
- * harness's agent-preset registry — declared means registered, undeclared
31
- * means the tool is never registered and one info line says why. The gate's
32
- * config escape hatch is syncWithLiangShen: false, which skips it and always
33
- * registers. See ./gate.ts for the API the gate reads and the timing
34
- * constraints it satisfies.
28
+ * Registration: on a supported Windows x64 host the tool registers as soon as
29
+ * the payload verifies and the config resolves — availability follows the
30
+ * platform, the shipped payload and the configuration alone, with no preset
31
+ * registry read. apply() registers synchronously; a failed payload check
32
+ * refuses the mount, a config error is thrown, and a tool-registry refusal is
33
+ * caught and logged so it never escapes apply as an unhandled rejection.
34
+ * A retired availability key left in an old profile row is ignored, not rejected.
35
35
  *
36
36
  * Host shell replacement: once win_bash is registered, the host's own pwsh
37
37
  * tool is withdrawn from each session win_bash can actually SERVE - the
@@ -44,70 +44,43 @@
44
44
  *
45
45
  * Lifecycle: one shell process per calling agent, released when that agent is
46
46
  * disposed and when the plugin fiber unloads. The pwsh restriction follows the
47
- * same lifecycle, lifted with the agent and with the fiber. apply() returns as
48
- * soon as the plugin is configured: the gate decides in mountWithGate, whose
49
- * promise is deliberately NOT returned from apply (see that function).
47
+ * same lifecycle, lifted with the agent and with the fiber. apply() registers
48
+ * the tool directly once the payload and config check out; a tool-registry
49
+ * failure is logged rather than escaping as an unhandled rejection.
50
50
  * @module @linxin666/dsh-win-bash
51
51
  */
52
52
  import type { Context } from '@deepseek-ai/cordis';
53
53
  import { Config, type WinBashConfig, type WinBashConfigInput } from './config.ts';
54
- import { type GateOptions, type GateOutcome } from './gate.ts';
55
54
  import { type RuntimeReady } from './runtime.ts';
56
55
  export { BACKGROUND_JOB_KIND, startBackgroundJob } from './background.ts';
57
56
  export type { BackgroundCommand, JobHandleLike, JobHooksLike, JobOutcomeLike, JobOutputSourceLike, JobRegistryLike, JobSourceReadLike, } from './background.ts';
58
57
  export { Config };
59
58
  export type { WinBashConfig, WinBashConfigInput };
60
- export { CONFIG_DEFAULTS, DEFAULT_DESCRIPTION, DEFAULT_ENABLE_RUN_IN_BACKGROUND, DEFAULT_REPLACE_PWSH, DEFAULT_SYNC_WITH_LIANGSHEN, validateConfig, } from './config.ts';
59
+ export { CONFIG_DEFAULTS, DEFAULT_DESCRIPTION, DEFAULT_ENABLE_RUN_IN_BACKGROUND, DEFAULT_REPLACE_PWSH, validateConfig, } from './config.ts';
61
60
  export { HOST_PWSH_TOOL, SERVING_MODE, installPwshReplacement, type PwshReplacementOptions, type ScopedRestrictor, type SessionPolicyReader, } from './pwsh-replacement.ts';
62
61
  export { WIN_BASH_TOOL, renderResult, readJobRegistry, stripTerminalEscapes, truncationNotice } from './tool.ts';
63
62
  export type { RenderFacts } from './tool.ts';
64
63
  export { SHELL_TEMP_PREFIX, ShellRegistry, ShellUnavailableError, removeShellTempDir, shellArgv, shellEnvironment, shellTempDir, sweepOrphanShellTempDirs, type ShellTempSweep, type ShellTempSweepOptions, } from './shell.ts';
65
64
  export { buildFrame, markerFor, parseFrame } from './protocol.ts';
66
- export { GATE_DECLARATION_WAIT_MS, GATE_POLL_INTERVAL_MS, GATE_READ_TIMEOUT_MS, GATE_SETTLE_TIMEOUT_MS, LIANGSHEN_PRESET_ID, declaresLiangShen, readPresetRegistry, settleHostTree, startLiangShenGate, type GateOptions, type GateOutcome, type GateReason, type PresetRosterReader, type PresetRosterRow, type SettleStatus, } from './gate.ts';
67
65
  export { CACHE_DIR_PARTS, CACHE_STAGING_PREFIX, ISOLATED_CACHE_DIR_PARTS, RUNTIME_ROOT_ENV, bashIn, bashPath, binIn, cacheRoot, isolatedCacheRoot, parseChecksums, payloadKey, prepareRuntime, resolveRuntime, runtimeRoot, shIn, shPath, verifyPayload, verifyPayloadRoot, type CopyTree, type PrepareRuntimeOptions, } from './runtime.ts';
68
66
  /** Cordis plugin name; also the loader row id this package mounts under. */
69
67
  export declare const name = "dsh-win-bash";
70
68
  /** Required services: the tool registry and the managed subprocess seam. */
71
69
  export declare const inject: string[];
72
- /**
73
- * One human-readable line explaining a refused gate verdict.
74
- * @param outcome - the gate's verdict.
75
- * @returns the message the entry logs.
76
- */
77
- export declare function gateRefusalMessage(outcome: GateOutcome): string;
78
70
  /**
79
71
  * Register the win_bash tool and its per-session shell registry on the calling
80
72
  * fiber. Called only once per fiber: the caller decides whether to call at all.
81
73
  *
82
- * The host pwsh replacement is installed from HERE and not from the gate or
83
- * apply, because its precondition is exactly "win_bash is now on the wire": a
84
- * deployment whose gate refused, whose payload failed verification, or that
85
- * runs on a POSIX host never reaches this function and therefore never touches
86
- * the host's shell.
74
+ * The host pwsh replacement is installed from HERE and not from apply, because
75
+ * its precondition is exactly "win_bash is now on the wire": a deployment whose
76
+ * payload failed verification, whose config was rejected, or that runs on a
77
+ * POSIX host never reaches this function and therefore never touches the host's
78
+ * shell.
87
79
  * @param ctx - context carrying tools and subprocess.
88
80
  * @param config - the resolved configuration.
89
81
  * @param runtime - the verified payload paths.
90
82
  */
91
83
  export declare function registerWinBash(ctx: Context, config: WinBashConfig, runtime: RuntimeReady): void;
92
- /**
93
- * Apply the availability gate, then register the tool when it allows it.
94
- *
95
- * The returned promise is deliberately NOT awaited by apply: the gate's roster
96
- * read audits every declared preset and can await the Host loader tree, which
97
- * still counts this very activation among its pending tasks — awaiting it from
98
- * inside the activation would make the two waits depend on each other and
99
- * neither would settle. Keeping the decision off the activation path also
100
- * keeps the loader entry's own inertia free of it, so the tree can settle.
101
- *
102
- * A fiber disposed while the gate was deciding registers nothing: its tool
103
- * effect would be refused anyway, and its shells would outlive it.
104
- * @param ctx - context carrying tools and subprocess.
105
- * @param config - the resolved configuration.
106
- * @param runtime - the verified payload paths.
107
- * @param options - gate deadlines; the defaults are the shipped bounds.
108
- * @returns the decision, for the caller to observe (never rejects).
109
- */
110
- export declare function mountWithGate(ctx: Context, config: WinBashConfig, runtime: RuntimeReady, options?: GateOptions): Promise<void>;
111
84
  /**
112
85
  * Mount the plugin.
113
86
  * @param ctx - context carrying tools and subprocess.