@xiaoso/dsh-tool-plus 0.1.7-beta.0 → 0.1.7

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 (243) hide show
  1. package/lib/index.mjs +11 -9
  2. package/lib/{scrapers-D8oWspgW.mjs → scrapers-CtQrQ5kG.mjs} +1 -1
  3. package/lib/types/client/BashPlusCard.d.ts +53 -0
  4. package/lib/types/client/ToolPlusSection.d.ts +36 -0
  5. package/lib/types/client/forms.d.ts +42 -0
  6. package/lib/types/client/index.d.ts +29 -0
  7. package/lib/types/client/locales.d.ts +19 -0
  8. package/lib/types/client/rm-safe-status-text.d.ts +15 -0
  9. package/lib/types/client/rows.d.ts +107 -0
  10. package/lib/types/client/web-connection-rpc.d.ts +22 -0
  11. package/lib/types/config/fields.d.ts +85 -0
  12. package/lib/types/config/omp-settings.d.ts +21 -0
  13. package/lib/types/config/settings.d.ts +212 -0
  14. package/lib/types/config/truncate.d.ts +27 -0
  15. package/lib/types/host/browser-probe-rpc.d.ts +29 -0
  16. package/lib/types/index.d.ts +6 -0
  17. package/lib/types/tools/ast-edit/adapter/index.d.ts +26 -0
  18. package/lib/types/tools/ast-edit/adapter/sdk.d.ts +49 -0
  19. package/lib/types/tools/ast-grep/adapter/index.d.ts +31 -0
  20. package/lib/types/tools/ast-grep/adapter/sdk.d.ts +44 -0
  21. package/lib/types/tools/bash/adapter/spill.d.ts +34 -0
  22. package/lib/types/tools/bash/background.d.ts +40 -0
  23. package/lib/types/tools/bash/bash-executor.d.ts +102 -0
  24. package/lib/types/tools/bash/bash-interceptor.d.ts +33 -0
  25. package/lib/types/tools/bash/cd-workdir.d.ts +35 -0
  26. package/lib/types/tools/bash/logger.d.ts +18 -0
  27. package/lib/types/tools/bash/non-interactive-env.d.ts +5 -0
  28. package/lib/types/tools/bash/render.d.ts +46 -0
  29. package/lib/types/tools/bash/rm-safe-status.d.ts +62 -0
  30. package/lib/types/tools/bash/rm-safe.d.ts +18 -0
  31. package/lib/types/tools/bash/sanitize-text.d.ts +34 -0
  32. package/lib/types/tools/bash/shell-snapshot.d.ts +31 -0
  33. package/lib/types/tools/bash/shell-tokenize.d.ts +60 -0
  34. package/lib/types/tools/bash/streaming-output.d.ts +32 -0
  35. package/lib/types/tools/bash/trash-cli-main.d.ts +1 -0
  36. package/lib/types/tools/bash/trash-cli.d.ts +77 -0
  37. package/lib/types/tools/bash/types.d.ts +107 -0
  38. package/lib/types/tools/bash/which.d.ts +20 -0
  39. package/lib/types/tools/bash/windows-shell.d.ts +31 -0
  40. package/lib/types/tools/bash/yield.d.ts +71 -0
  41. package/lib/types/tools/edit/adapter/index.d.ts +57 -0
  42. package/lib/types/tools/edit/adapter/tools/auto-generated-guard.d.ts +10 -0
  43. package/lib/types/tools/edit/adapter/tools/output-meta.d.ts +34 -0
  44. package/lib/types/tools/edit/adapter/tools/plan-mode-guard.d.ts +21 -0
  45. package/lib/types/tools/glob/adapter/index.d.ts +52 -0
  46. package/lib/types/tools/grep/adapter/index.d.ts +53 -0
  47. package/lib/types/tools/grep/adapter/match-path.d.ts +1 -0
  48. package/lib/types/tools/hashline/native/diff-preview.d.ts +37 -0
  49. package/lib/types/tools/hashline/native/index.d.ts +109 -0
  50. package/lib/types/tools/hashline/native/normalize.d.ts +29 -0
  51. package/lib/types/tools/hashline/native/policy.d.ts +98 -0
  52. package/lib/types/tools/hashline/native/writer.d.ts +42 -0
  53. package/lib/types/tools/omp/browser/launch.d.ts +28 -0
  54. package/lib/types/tools/omp/browser/readable.d.ts +17 -0
  55. package/lib/types/tools/omp/config/settings-schema.d.ts +12 -0
  56. package/lib/types/tools/omp/config/settings.d.ts +59 -0
  57. package/lib/types/tools/omp/edit/apply-patch/parser.d.ts +34 -0
  58. package/lib/types/tools/omp/edit/details.d.ts +54 -0
  59. package/lib/types/tools/omp/edit/diff.d.ts +60 -0
  60. package/lib/types/tools/omp/edit/dispatch.d.ts +43 -0
  61. package/lib/types/tools/omp/edit/file-snapshot-store.d.ts +81 -0
  62. package/lib/types/tools/omp/edit/hashline/execute.d.ts +40 -0
  63. package/lib/types/tools/omp/edit/hashline/params.d.ts +6 -0
  64. package/lib/types/tools/omp/edit/modes/apply-patch.d.ts +25 -0
  65. package/lib/types/tools/omp/edit/modes/patch.d.ts +109 -0
  66. package/lib/types/tools/omp/edit/modes/replace.d.ts +151 -0
  67. package/lib/types/tools/omp/edit/normalize.d.ts +31 -0
  68. package/lib/types/tools/omp/edit/notebook.d.ts +50 -0
  69. package/lib/types/tools/omp/edit/read-file.d.ts +2 -0
  70. package/lib/types/tools/omp/edit/snapshot-details.d.ts +33 -0
  71. package/lib/types/tools/omp/extensibility/skills.d.ts +22 -0
  72. package/lib/types/tools/omp/internal-urls/index.d.ts +100 -0
  73. package/lib/types/tools/omp/internal-urls/local-protocol.d.ts +12 -0
  74. package/lib/types/tools/omp/internal-urls/parse.d.ts +31 -0
  75. package/lib/types/tools/omp/internal-urls/types.d.ts +189 -0
  76. package/lib/types/tools/omp/internal-urls/xd-protocol.d.ts +19 -0
  77. package/lib/types/tools/omp/markit/converters/docx.d.ts +6 -0
  78. package/lib/types/tools/omp/markit/converters/epub.d.ts +15 -0
  79. package/lib/types/tools/omp/markit/converters/pdf/index.d.ts +7 -0
  80. package/lib/types/tools/omp/markit/converters/pptx.d.ts +57 -0
  81. package/lib/types/tools/omp/markit/converters/xlsx.d.ts +25 -0
  82. package/lib/types/tools/omp/markit/index.d.ts +2 -0
  83. package/lib/types/tools/omp/markit/registry.d.ts +16 -0
  84. package/lib/types/tools/omp/markit/types.d.ts +30 -0
  85. package/lib/types/tools/omp/sdk.d.ts +103 -0
  86. package/lib/types/tools/omp/session/agent-storage.d.ts +154 -0
  87. package/lib/types/tools/omp/session/streaming-output.d.ts +244 -0
  88. package/lib/types/tools/omp/task/spawn-policy.d.ts +22 -0
  89. package/lib/types/tools/omp/tools/approval.d.ts +62 -0
  90. package/lib/types/tools/omp/tools/ast-edit.d.ts +73 -0
  91. package/lib/types/tools/omp/tools/ast-grep.d.ts +61 -0
  92. package/lib/types/tools/omp/tools/auto-generated-guard.d.ts +20 -0
  93. package/lib/types/tools/omp/tools/conflict-detect.d.ts +237 -0
  94. package/lib/types/tools/omp/tools/fetch.d.ts +103 -0
  95. package/lib/types/tools/omp/tools/file-recorder.d.ts +13 -0
  96. package/lib/types/tools/omp/tools/fs-cache-invalidation.d.ts +15 -0
  97. package/lib/types/tools/omp/tools/glob.d.ts +86 -0
  98. package/lib/types/tools/omp/tools/grep.d.ts +102 -0
  99. package/lib/types/tools/omp/tools/grouped-file-output.d.ts +70 -0
  100. package/lib/types/tools/omp/tools/index.d.ts +23 -0
  101. package/lib/types/tools/omp/tools/list-limit.d.ts +12 -0
  102. package/lib/types/tools/omp/tools/match-line-format.d.ts +11 -0
  103. package/lib/types/tools/omp/tools/output-meta.d.ts +160 -0
  104. package/lib/types/tools/omp/tools/path-utils.d.ts +326 -0
  105. package/lib/types/tools/omp/tools/plan-mode-guard.d.ts +33 -0
  106. package/lib/types/tools/omp/tools/read-archive.d.ts +16 -0
  107. package/lib/types/tools/omp/tools/read-format.d.ts +104 -0
  108. package/lib/types/tools/omp/tools/read-path-resolution.d.ts +19 -0
  109. package/lib/types/tools/omp/tools/read-selector.d.ts +27 -0
  110. package/lib/types/tools/omp/tools/read-sqlite.d.ts +16 -0
  111. package/lib/types/tools/omp/tools/read-summary.d.ts +15 -0
  112. package/lib/types/tools/omp/tools/read.d.ts +70 -0
  113. package/lib/types/tools/omp/tools/render-utils.d.ts +28 -0
  114. package/lib/types/tools/omp/tools/report-tool-issue.d.ts +149 -0
  115. package/lib/types/tools/omp/tools/resolve.d.ts +127 -0
  116. package/lib/types/tools/omp/tools/sqlite-reader.d.ts +114 -0
  117. package/lib/types/tools/omp/tools/tool-errors.d.ts +33 -0
  118. package/lib/types/tools/omp/tools/tool-result.d.ts +33 -0
  119. package/lib/types/tools/omp/tools/tool-timeouts.d.ts +57 -0
  120. package/lib/types/tools/omp/tools/write.d.ts +53 -0
  121. package/lib/types/tools/omp/tools/writethrough.d.ts +24 -0
  122. package/lib/types/tools/omp/utils/block-context.d.ts +35 -0
  123. package/lib/types/tools/omp/utils/cpuprofile.d.ts +51 -0
  124. package/lib/types/tools/omp/utils/edit-mode.d.ts +13 -0
  125. package/lib/types/tools/omp/utils/file-display-mode.d.ts +27 -0
  126. package/lib/types/tools/omp/utils/image-loading.d.ts +51 -0
  127. package/lib/types/tools/omp/utils/image-resize.d.ts +42 -0
  128. package/lib/types/tools/omp/utils/lang-from-path.d.ts +9 -0
  129. package/lib/types/tools/omp/utils/markit-cache.d.ts +23 -0
  130. package/lib/types/tools/omp/utils/markit.d.ts +30 -0
  131. package/lib/types/tools/omp/utils/profile-tree.d.ts +47 -0
  132. package/lib/types/tools/omp/utils/sample-profile.d.ts +67 -0
  133. package/lib/types/tools/omp/utils/sixel.d.ts +21 -0
  134. package/lib/types/tools/omp/utils/tools-manager.d.ts +11 -0
  135. package/lib/types/tools/omp/utils/turndown.d.ts +15 -0
  136. package/lib/types/tools/omp/utils/zip.d.ts +129 -0
  137. package/lib/types/tools/omp/web/browser-render.d.ts +50 -0
  138. package/lib/types/tools/omp/web/parallel.d.ts +68 -0
  139. package/lib/types/tools/omp/web/scrapers/artifacthub.d.ts +6 -0
  140. package/lib/types/tools/omp/web/scrapers/arxiv.d.ts +5 -0
  141. package/lib/types/tools/omp/web/scrapers/aur.d.ts +5 -0
  142. package/lib/types/tools/omp/web/scrapers/biorxiv.d.ts +5 -0
  143. package/lib/types/tools/omp/web/scrapers/bluesky.d.ts +5 -0
  144. package/lib/types/tools/omp/web/scrapers/brew.d.ts +5 -0
  145. package/lib/types/tools/omp/web/scrapers/cheatsh.d.ts +8 -0
  146. package/lib/types/tools/omp/web/scrapers/chocolatey.d.ts +5 -0
  147. package/lib/types/tools/omp/web/scrapers/choosealicense.d.ts +2 -0
  148. package/lib/types/tools/omp/web/scrapers/cisa-kev.d.ts +5 -0
  149. package/lib/types/tools/omp/web/scrapers/clojars.d.ts +5 -0
  150. package/lib/types/tools/omp/web/scrapers/coingecko.d.ts +5 -0
  151. package/lib/types/tools/omp/web/scrapers/crates-io.d.ts +5 -0
  152. package/lib/types/tools/omp/web/scrapers/crossref.d.ts +2 -0
  153. package/lib/types/tools/omp/web/scrapers/devto.d.ts +5 -0
  154. package/lib/types/tools/omp/web/scrapers/discogs.d.ts +8 -0
  155. package/lib/types/tools/omp/web/scrapers/discourse.d.ts +5 -0
  156. package/lib/types/tools/omp/web/scrapers/dockerhub.d.ts +5 -0
  157. package/lib/types/tools/omp/web/scrapers/docs-rs.d.ts +9 -0
  158. package/lib/types/tools/omp/web/scrapers/fdroid.d.ts +5 -0
  159. package/lib/types/tools/omp/web/scrapers/firefox-addons.d.ts +2 -0
  160. package/lib/types/tools/omp/web/scrapers/flathub.d.ts +2 -0
  161. package/lib/types/tools/omp/web/scrapers/github-gist.d.ts +5 -0
  162. package/lib/types/tools/omp/web/scrapers/github.d.ts +34 -0
  163. package/lib/types/tools/omp/web/scrapers/gitlab.d.ts +5 -0
  164. package/lib/types/tools/omp/web/scrapers/go-pkg.d.ts +5 -0
  165. package/lib/types/tools/omp/web/scrapers/hackage.d.ts +5 -0
  166. package/lib/types/tools/omp/web/scrapers/hackernews.d.ts +2 -0
  167. package/lib/types/tools/omp/web/scrapers/hex.d.ts +5 -0
  168. package/lib/types/tools/omp/web/scrapers/huggingface.d.ts +2 -0
  169. package/lib/types/tools/omp/web/scrapers/iacr.d.ts +5 -0
  170. package/lib/types/tools/omp/web/scrapers/index.d.ts +84 -0
  171. package/lib/types/tools/omp/web/scrapers/jetbrains-marketplace.d.ts +2 -0
  172. package/lib/types/tools/omp/web/scrapers/lemmy.d.ts +2 -0
  173. package/lib/types/tools/omp/web/scrapers/lobsters.d.ts +5 -0
  174. package/lib/types/tools/omp/web/scrapers/mastodon.d.ts +5 -0
  175. package/lib/types/tools/omp/web/scrapers/maven.d.ts +6 -0
  176. package/lib/types/tools/omp/web/scrapers/mdn.d.ts +2 -0
  177. package/lib/types/tools/omp/web/scrapers/metacpan.d.ts +5 -0
  178. package/lib/types/tools/omp/web/scrapers/musicbrainz.d.ts +5 -0
  179. package/lib/types/tools/omp/web/scrapers/npm.d.ts +5 -0
  180. package/lib/types/tools/omp/web/scrapers/nuget.d.ts +5 -0
  181. package/lib/types/tools/omp/web/scrapers/nvd.d.ts +5 -0
  182. package/lib/types/tools/omp/web/scrapers/ollama.d.ts +2 -0
  183. package/lib/types/tools/omp/web/scrapers/open-vsx.d.ts +5 -0
  184. package/lib/types/tools/omp/web/scrapers/opencorporates.d.ts +5 -0
  185. package/lib/types/tools/omp/web/scrapers/openlibrary.d.ts +5 -0
  186. package/lib/types/tools/omp/web/scrapers/orcid.d.ts +5 -0
  187. package/lib/types/tools/omp/web/scrapers/osv.d.ts +5 -0
  188. package/lib/types/tools/omp/web/scrapers/packagist.d.ts +5 -0
  189. package/lib/types/tools/omp/web/scrapers/pub-dev.d.ts +5 -0
  190. package/lib/types/tools/omp/web/scrapers/pubmed.d.ts +5 -0
  191. package/lib/types/tools/omp/web/scrapers/pypi.d.ts +5 -0
  192. package/lib/types/tools/omp/web/scrapers/rawg.d.ts +2 -0
  193. package/lib/types/tools/omp/web/scrapers/readthedocs.d.ts +2 -0
  194. package/lib/types/tools/omp/web/scrapers/reddit.d.ts +5 -0
  195. package/lib/types/tools/omp/web/scrapers/repology.d.ts +5 -0
  196. package/lib/types/tools/omp/web/scrapers/rfc.d.ts +5 -0
  197. package/lib/types/tools/omp/web/scrapers/rubygems.d.ts +5 -0
  198. package/lib/types/tools/omp/web/scrapers/searchcode.d.ts +2 -0
  199. package/lib/types/tools/omp/web/scrapers/sec-edgar.d.ts +5 -0
  200. package/lib/types/tools/omp/web/scrapers/semantic-scholar.d.ts +2 -0
  201. package/lib/types/tools/omp/web/scrapers/snapcraft.d.ts +2 -0
  202. package/lib/types/tools/omp/web/scrapers/sourcegraph.d.ts +2 -0
  203. package/lib/types/tools/omp/web/scrapers/spdx.d.ts +5 -0
  204. package/lib/types/tools/omp/web/scrapers/spotify.d.ts +8 -0
  205. package/lib/types/tools/omp/web/scrapers/stackoverflow.d.ts +6 -0
  206. package/lib/types/tools/omp/web/scrapers/terraform.d.ts +5 -0
  207. package/lib/types/tools/omp/web/scrapers/tldr.d.ts +7 -0
  208. package/lib/types/tools/omp/web/scrapers/twitter.d.ts +5 -0
  209. package/lib/types/tools/omp/web/scrapers/types.d.ts +90 -0
  210. package/lib/types/tools/omp/web/scrapers/utils.d.ts +26 -0
  211. package/lib/types/tools/omp/web/scrapers/vimeo.d.ts +5 -0
  212. package/lib/types/tools/omp/web/scrapers/vscode-marketplace.d.ts +5 -0
  213. package/lib/types/tools/omp/web/scrapers/w3c.d.ts +2 -0
  214. package/lib/types/tools/omp/web/scrapers/wikidata.d.ts +5 -0
  215. package/lib/types/tools/omp/web/scrapers/wikipedia.d.ts +5 -0
  216. package/lib/types/tools/omp/web/scrapers/youtube.d.ts +5 -0
  217. package/lib/types/tools/omp/web/search/providers/utils.d.ts +49 -0
  218. package/lib/types/tools/omp/web/search/types.d.ts +501 -0
  219. package/lib/types/tools/omp/web/search/utils.d.ts +4 -0
  220. package/lib/types/tools/omp/workspace-tree.d.ts +42 -0
  221. package/lib/types/tools/read/adapter/index.d.ts +49 -0
  222. package/lib/types/tools/read/adapter/internal-urls/artifact-protocol.d.ts +15 -0
  223. package/lib/types/tools/read/adapter/internal-urls/registry-helpers.d.ts +44 -0
  224. package/lib/types/tools/read/adapter/registry/agent-registry.d.ts +29 -0
  225. package/lib/types/tools/shared/auto-generated-guard.dsh.d.ts +16 -0
  226. package/lib/types/tools/shared/browser-detect.d.ts +54 -0
  227. package/lib/types/tools/shared/browser-rpc-channel.d.ts +40 -0
  228. package/lib/types/tools/shared/bun-ffi-shim.d.ts +13 -0
  229. package/lib/types/tools/shared/bun-named-shim.d.ts +42 -0
  230. package/lib/types/tools/shared/bun-shim.d.ts +138 -0
  231. package/lib/types/tools/shared/bun-sqlite-shim.d.ts +49 -0
  232. package/lib/types/tools/shared/fs-promises-shim.d.ts +15 -0
  233. package/lib/types/tools/shared/image-bridge.d.ts +98 -0
  234. package/lib/types/tools/shared/omp-prompt.d.ts +47 -0
  235. package/lib/types/tools/shared/sandbox-policy.d.ts +38 -0
  236. package/lib/types/tools/shared/session-state.d.ts +51 -0
  237. package/lib/types/tools/shared/tool-errors.d.ts +33 -0
  238. package/lib/types/tools/shared/win-path-fixes.d.ts +16 -0
  239. package/lib/types/tools/write/adapter/index.d.ts +31 -0
  240. package/lib/{utils-CCfhUQen.mjs → utils-ECAwvaPQ.mjs} +1 -1
  241. package/package.json +2 -2
  242. package/presets/package.json +1 -1
  243. package/scripts/patch-pi-natives.mjs +108 -108
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Plugin-owned settings surface for the ported bash tool: the `bash-plus`
3
+ * namespace, a FLAT settings schema (OMP `bash*`-style scalar keys — the
4
+ * client scope writes scalar fields only), its defaults, the mapping onto the
5
+ * nested {@link RuntimeConfig} the runtime consumes, and the optional-settings
6
+ * consumer wiring. Keeping the whole config-export surface here lets the
7
+ * ported OMP runtime stay pristine — the entry only calls
8
+ * {@link installBashPlusSettings} and re-exports this module's `Config`.
9
+ * @module @xiaoso/dsh-tool-plus/settings
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ import z from '@deepseek-ai/schemastery';
13
+ import type { MinimizerConfig } from '../tools/bash/types.ts';
14
+ /** Truncation strategy for background→foreground completion messages (OMP config parity). */
15
+ export type OutputTruncateStrategy = 'bytes' | 'lines';
16
+ /** Retention mode for a truncated completion message: head, tail, or middle (head+tail). */
17
+ export type OutputRetentionMode = 'head' | 'tail' | 'middle';
18
+ /** Byte-based retention settings; `middle` keeps head+tail, `head`/`tail` keep one window. */
19
+ export interface ByteRetentionConfig {
20
+ mode: OutputRetentionMode;
21
+ headBytes: number;
22
+ tailBytes: number;
23
+ }
24
+ /** Reader-backend preference for URL reads (`providers.fetch` parity). */
25
+ export type FetchReaderPreference = 'auto' | 'native' | 'trafilatura' | 'lynx' | 'parallel' | 'jina' | 'browser';
26
+ /** Line-based retention settings, mirroring the byte-based structure. */
27
+ export interface LineRetentionConfig {
28
+ mode: OutputRetentionMode;
29
+ headLines: number;
30
+ tailLines: number;
31
+ }
32
+ /**
33
+ * Background-job completion text truncation (mirrors the OMP `bashOutputTruncate*`
34
+ * family). Only the settled preview text is affected; streaming reads and the
35
+ * completion notice are untouched.
36
+ */
37
+ export interface OutputTruncateConfig {
38
+ strategy: OutputTruncateStrategy;
39
+ /** Threshold (in `strategy` units) below which the text is kept intact. */
40
+ triggerBytes: number;
41
+ triggerLines: number;
42
+ bytes: ByteRetentionConfig;
43
+ lines: LineRetentionConfig;
44
+ }
45
+ /**
46
+ * The resolved runtime configuration, nested for the OMP runtime consumers.
47
+ * {@link RuntimeConfig} is built from the flat {@link Config} by
48
+ * {@link resolveConfig}; the OMP-ported runtime files never see the flat shape.
49
+ */
50
+ export interface RuntimeConfig {
51
+ enableRunInBackground: boolean;
52
+ autoBackgroundMs: number;
53
+ defaultTimeoutMs: number;
54
+ maxTimeoutMs: number;
55
+ outputMaxBytes: number;
56
+ outputSinkTailBytes: number;
57
+ outputSinkHeadBytes: number;
58
+ minimizer: MinimizerConfig;
59
+ interceptorEnabled: boolean;
60
+ nonInteractiveEnv: boolean;
61
+ snapshotEnabled: boolean;
62
+ rmSafe: boolean;
63
+ useShellCommandWrapper: boolean;
64
+ maxBackgroundJobs: number;
65
+ outputTruncate: OutputTruncateConfig;
66
+ editBlockAutoGenerated: boolean;
67
+ editMode: string;
68
+ editFuzzyMatch: boolean;
69
+ editFuzzyThreshold: number;
70
+ editEnforceSeenLines: boolean;
71
+ readSummarizeEnabled: boolean;
72
+ readSummarizeProse: boolean;
73
+ readSummarizeMinBodyLines: number;
74
+ readSummarizeMinCommentLines: number;
75
+ readSummarizeMinTotalLines: number;
76
+ readSummarizeUnfoldUntil: number;
77
+ readSummarizeUnfoldLimit: number;
78
+ readDefaultLimit: number;
79
+ readLineNumbers: boolean;
80
+ readRenderMarkdown: boolean;
81
+ readConcurrentSafe: boolean;
82
+ grepContextBefore: number;
83
+ grepContextAfter: number;
84
+ grepCaseDefault: boolean;
85
+ grepGitignoreDefault: boolean;
86
+ globGitignoreDefault: boolean;
87
+ globHiddenDefault: boolean;
88
+ astGrepEnabled: boolean;
89
+ astEditEnabled: boolean;
90
+ fetchEnabled: boolean;
91
+ fetchMaxTimeoutSeconds: number;
92
+ fetchReader: FetchReaderPreference;
93
+ browserReaderEnabled: boolean;
94
+ imagesAutoResize: boolean;
95
+ imagesBlockImages: boolean;
96
+ imagesExcludeWebp: boolean;
97
+ imagesInputMaxBytes: number;
98
+ imagesResizeMaxSide: number;
99
+ imagesResizeMaxBytes: number;
100
+ imagesResizeMinSide: number;
101
+ imagesResizeJpegQuality: number;
102
+ }
103
+ /** Settings namespace of this plugin, served to the web Plugins page. */
104
+ export declare const BASH_PLUS_SETTINGS_NS = "tool-plus";
105
+ /** OMP-parity defaults for the completion-message truncation policy. */
106
+ export declare const DEFAULT_OUTPUT_TRUNCATE: OutputTruncateConfig;
107
+ /**
108
+ * Timing knobs (ms). DEFAULT_MAX_TIMEOUT_MS is OMP-parity (= upstream bash
109
+ * per-tool max 3600s); DEFAULT_TIMEOUT_MS was deliberately relaxed from
110
+ * 300_000 to 3_600_000 with the bash-plus settings card (763023e,
111
+ * 2026-08-19) — NOT OMP-parity (OMP bash default is 300s), compensated by
112
+ * auto-backgrounding after DEFAULT_AUTO_BACKGROUND_MS. By design there is no
113
+ * upstream `tools.maxTimeout` global-cap equivalent: maxTimeoutMs always
114
+ * applies. (second-impl-audit.md S-11 终局, 2026-08-29.)
115
+ */
116
+ export declare const DEFAULT_TIMEOUT_MS = 3600000;
117
+ export declare const DEFAULT_MAX_TIMEOUT_MS = 3600000;
118
+ export declare const DEFAULT_AUTO_BACKGROUND_MS = 60000;
119
+ export declare const DEFAULT_MAX_BACKGROUND_JOBS = 15;
120
+ /**
121
+ * Plugin settings, one scalar key per option — every field is writable through
122
+ * the client `SettingsScope.set`/`unset`. Defaults live in the {@link Config}
123
+ * schema and in {@link resolveConfig}.
124
+ */
125
+ export interface Config {
126
+ enableRunInBackground?: boolean;
127
+ autoBackgroundMs?: number;
128
+ defaultTimeoutMs?: number;
129
+ maxTimeoutMs?: number;
130
+ outputMaxBytes?: number;
131
+ outputSinkTailBytes?: number;
132
+ outputSinkHeadBytes?: number;
133
+ minimizerEnabled?: boolean;
134
+ interceptorEnabled?: boolean;
135
+ nonInteractiveEnv?: boolean;
136
+ snapshotEnabled?: boolean;
137
+ /** Redefine `rm` in the session shell to move into the system trash (default true). */
138
+ rmSafe?: boolean;
139
+ useShellCommandWrapper?: boolean;
140
+ maxBackgroundJobs?: number;
141
+ outputTruncateStrategy?: OutputTruncateStrategy;
142
+ outputTruncateTriggerBytes?: number;
143
+ outputTruncateTriggerLines?: number;
144
+ outputTruncateByteMode?: OutputRetentionMode;
145
+ outputTruncateByteHeadBytes?: number;
146
+ outputTruncateByteTailBytes?: number;
147
+ outputTruncateLineMode?: OutputRetentionMode;
148
+ outputTruncateLineHeadLines?: number;
149
+ outputTruncateLineTailLines?: number;
150
+ editBlockAutoGenerated?: boolean;
151
+ editMode?: 'replace' | 'patch' | 'hashline' | 'apply_patch';
152
+ editFuzzyMatch?: boolean;
153
+ editFuzzyThreshold?: number;
154
+ editEnforceSeenLines?: boolean;
155
+ readSummarizeEnabled?: boolean;
156
+ readSummarizeProse?: boolean;
157
+ readSummarizeMinBodyLines?: number;
158
+ readSummarizeMinCommentLines?: number;
159
+ readSummarizeMinTotalLines?: number;
160
+ readSummarizeUnfoldUntil?: number;
161
+ readSummarizeUnfoldLimit?: number;
162
+ readDefaultLimit?: number;
163
+ readLineNumbers?: boolean;
164
+ readRenderMarkdown?: boolean;
165
+ readConcurrentSafe?: boolean;
166
+ grepContextBefore?: number;
167
+ grepContextAfter?: number;
168
+ grepCaseDefault?: boolean;
169
+ grepGitignoreDefault?: boolean;
170
+ globGitignoreDefault?: boolean;
171
+ globHiddenDefault?: boolean;
172
+ astGrepEnabled?: boolean;
173
+ astEditEnabled?: boolean;
174
+ fetchEnabled?: boolean;
175
+ fetchMaxTimeoutSeconds?: number;
176
+ fetchReader?: FetchReaderPreference;
177
+ browserReaderEnabled?: boolean;
178
+ imagesAutoResize?: boolean;
179
+ imagesBlockImages?: boolean;
180
+ imagesExcludeWebp?: boolean;
181
+ imagesInputMaxBytes?: number;
182
+ imagesResizeMaxSide?: number;
183
+ imagesResizeMaxBytes?: number;
184
+ imagesResizeMinSide?: number;
185
+ imagesResizeJpegQuality?: number;
186
+ }
187
+ /**
188
+ * Runtime configuration schema for the plugin. The namespace resolves through
189
+ * this flat surface; {@link resolveConfig} maps it onto {@link RuntimeConfig}.
190
+ */
191
+ export declare const Config: z<Config>;
192
+ /**
193
+ * Resolve the flat settings (composition entry or the settings document) to
194
+ * the nested runtime config the ported OMP runtime consumes. A direct mount
195
+ * (`ctx.plugin`) skips the Loader's schema parse, so the `?? default` pass
196
+ * mirrors the schema; the settings namespace resolution rides the same path.
197
+ * @param config - flat settings, possibly partial and not schema-parsed.
198
+ * @returns the fully-defaulted nested runtime config.
199
+ */
200
+ export declare function resolveConfig(config: Config): RuntimeConfig;
201
+ /**
202
+ * Install the optional-settings consumer wiring for this plugin: while a
203
+ * settings provider is mounted, resolve through the `tool-plus` namespace
204
+ * (schema defaults → composition entry `base` → user document) and forward the
205
+ * scope to `onSource`; when none is mounted, keep the composition entry, so
206
+ * the tool keeps working exactly as composed. Mirrors the official bash-local
207
+ * pattern so a committed change applies without a reload.
208
+ * @param ctx - plugin context owning the wiring.
209
+ * @param entry - composition entry config declared by the caller.
210
+ * @param onSource - receives a thunk of the currently authoritative runtime config.
211
+ */
212
+ export declare function installBashPlusSettings(ctx: Context, entry: Config, onSource: (current: () => RuntimeConfig) => void): void;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Config-driven output truncation for background→foreground completion text.
3
+ * Provenance (second-impl-audit.md S-1, 2026-08-29): the truncation
4
+ * primitives (truncateHead/Middle/Tail, TruncationResult) are OMP 17.3.5
5
+ * verbatim, imported directly from `../omp/session/streaming-output.ts`;
6
+ * the composition layer below (trigger threshold + retention mode + notice
7
+ * format) is a plugin-specific design shipped with the bash-plus settings
8
+ * card (763023e, 2026-08-19) — `applyConfiguredTruncation` has no
9
+ * counterpart in refs/oh-my-pi 17.3.5, so the old "ported verbatim from the
10
+ * OMP bash-runtime" claim was unverifiable and has been dropped.
11
+ * @module @xiaoso/dsh-tool-plus/truncate
12
+ */
13
+ import type { OutputTruncateConfig } from './settings.ts';
14
+ /** Line count of `text` (newline count + 1), matching the OMP helper. */
15
+ export declare function countTextLines(text: string): number;
16
+ /**
17
+ * Truncate a background job's completion text per the configured strategy
18
+ * (bytes/lines), trigger threshold, and retention mode (head/tail/middle) —
19
+ * ported from the OMP bash-runtime `applyConfiguredTruncation`. Returns the
20
+ * text unchanged when it does not exceed the trigger threshold; otherwise
21
+ * appends a notice describing the truncation.
22
+ * @param text - the completion text to truncate.
23
+ * @param fullOutputPath - optional path to the full output, appended to the notice.
24
+ * @param truncate - the resolved truncation policy.
25
+ * @returns the (possibly truncated) completion text.
26
+ */
27
+ export declare function applyConfiguredTruncation(text: string, fullOutputPath: string | undefined, truncate: OutputTruncateConfig): string;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Host half of the tool-plus RPC channel: registers the `/tool-plus` logical
3
+ * channel on the official Connection transport and answers
4
+ * `browser/detect` (probe the machine for usable browsers) and
5
+ * `rmSafe/status` (query = ensure + verify the rmSafe injection). The
6
+ * settings panel (client half) calls these through
7
+ * `createWebConnectionRpc().call(...)` — the documented public RPC surface
8
+ * of `@deepseek-ai/dsh-client-connection`, not a private plugin hook.
9
+ *
10
+ * Trust policy is `loopback`: the probe only reports local filesystem paths,
11
+ * so it must never be reachable from a non-loopback host. Registration is
12
+ * best-effort — if `connection` is missing (non-web deployments) or the
13
+ * channel is already taken, the endpoints are simply unavailable and the
14
+ * panel shows "Unavailable".
15
+ * @module @xiaoso/dsh-tool-plus/host/browser-probe-rpc
16
+ */
17
+ import type { Context } from '@deepseek-ai/cordis';
18
+ /** Install-time dependencies: live config reads (hot-reload safe). */
19
+ export interface ToolPlusRpcDeps {
20
+ /** Whether rmSafe is currently enabled (resolved config). */
21
+ getRmSafe: () => boolean;
22
+ }
23
+ /**
24
+ * Install the tool-plus RPC endpoints. Returns a disposer that removes
25
+ * the registration (call it from the plugin's `ctx.effect` teardown).
26
+ * Never throws for "unavailable" — the return value tells the caller whether
27
+ * the channel is actually live.
28
+ */
29
+ export declare function installBrowserProbeRpc(ctx: Context, deps: ToolPlusRpcDeps): () => Promise<void> | void;
@@ -0,0 +1,6 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { type Config } from './config/settings.ts';
3
+ export declare const name = "tool-plus";
4
+ export declare const inject: string[];
5
+ export { Config } from './config/settings.ts';
6
+ export declare function apply(ctx: Context, config?: Config): void;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * DSH ast_edit tool — adapter that wires the verbatim OMP AST edit engine
3
+ * (`src/tools/ast-edit/adapter/omp/ast-edit.ts`) into DSH's `defineTool` contract.
4
+ *
5
+ * This file is pure glue. All edit logic lives in `omp/` (copied verbatim from
6
+ * OMP `tools/ast-edit.ts`); this adapter only:
7
+ * - builds an OMP `ToolSession` from the DSH exec context + tool-plus config,
8
+ * - constructs the verbatim `AstEditTool` and calls its `execute`,
9
+ * - converts the `AgentToolResult` back to a DSH tool result.
10
+ *
11
+ * Parameter shape is OMP-native (`ops[{pat,out}]` + `paths[]`), mirroring
12
+ * `tools/ast-edit.ts` verbatim (plan.md 拍板#11 keeps this shape). No TUI/ACP
13
+ * rendering happens in DSH; the model-facing `result.text` is surfaced directly.
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis';
16
+ import type { RuntimeConfig } from '../../../config/settings.ts';
17
+ export type { ToolSession } from './sdk.ts';
18
+ /**
19
+ * Register the ast_edit tool. Argument shape matches OMP verbatim:
20
+ * `ops` is a non-empty array of `{ pat, out }` rewrite rules, and `paths` is a
21
+ * non-empty array of files, directories, globs, or internal URLs.
22
+ */
23
+ export declare function registerAstEdit(ctx: Context, getConfig: () => RuntimeConfig): () => void;
24
+ export declare const applyAstEdit: typeof registerAstEdit;
25
+ export declare const registerAstEditTool: typeof registerAstEdit;
26
+ export default registerAstEdit;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * DSH adapter for OMP's `sdk.ts` — the `ToolSession` interface the ast_edit
3
+ * engine consumes.
4
+ *
5
+ * ast_edit reuses the read engine's tool-scope resolver (`resolveToolSearchScope`
6
+ * from `src/tools/read/adapter/omp/path-utils.ts`) and the native edit store
7
+ * (`getFileSnapshotStore` from `src/tools/omp/edit/file-snapshot-store.ts`), so this
8
+ * session facade only declares the members those engines actually touch. DSH
9
+ * supplies the session adapter (`src/tools/ast-edit/adapter/index.ts`); the
10
+ * resolve/apply queue, local:// router, skills, and snapshot store are DSH-side
11
+ * and optional (absent → preview-apply resolution is inert, matching read).
12
+ */
13
+ import type { Settings } from '../../omp/config/settings.ts';
14
+ import type { Skill } from '../../omp/extensibility/skills.ts';
15
+ import type { AgentToolResult } from '@oh-my-pi/pi-agent-core';
16
+ import type { Model } from '@oh-my-pi/pi-ai';
17
+ /** Tool-choice queue for staged resolution previews (DSH: never present). */
18
+ export interface ToolChoiceQueueLike {
19
+ registerPendingInvoker: (id: string, toolName: string, invoker: ResolveInvoker) => void;
20
+ removePendingInvoker: (id: string) => void;
21
+ }
22
+ /** Staged resolution invocation runner (DSH: never present). */
23
+ export type ResolveInvoker = (invocation: unknown) => Promise<AgentToolResult<unknown>>;
24
+ /**
25
+ * Minimal ToolSession surface used by the OMP ast_edit engine (verbatim member
26
+ * shapes). DSH provides a session adapter implementing this interface.
27
+ */
28
+ export interface ToolSession {
29
+ /** Current working directory */
30
+ cwd: string;
31
+ /** Whether an edit-capable tool is available (controls hashline output) */
32
+ hasEditTool?: boolean;
33
+ /** Session settings (read keys and edit keys; DSH maps them onto tool-plus config). */
34
+ settings: Settings;
35
+ /** Active model string for edit-mode resolution (optional in DSH). */
36
+ getActiveModelString?: () => string | undefined;
37
+ /** Active model object (optional in DSH). */
38
+ getActiveModel?: () => Model | undefined;
39
+ /** Native edit store (created lazily by the engine; hashline snapshots). */
40
+ editStore?: import('../../hashline/native/index.ts').EditStore;
41
+ /** Local protocol options (DSH has no local:// sandbox — optional). */
42
+ localProtocolOptions?: import('../../omp/internal-urls/index.ts').LocalProtocolOptions;
43
+ /** Pre-loaded skills (DSH: none). */
44
+ skills?: readonly Skill[];
45
+ /** Tool-choice queue (resolution devices; DSH: adapter-installed, captures the apply). */
46
+ getToolChoiceQueue?: () => ToolChoiceQueueLike | undefined;
47
+ /** Captured preview-apply invoker (DSH resolve channel, plan.md 拍板#14). */
48
+ pendingInvoker?: () => Promise<AgentToolResult<unknown>>;
49
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * DSH ast_grep tool — adapter that wires the verbatim OMP AST grep engine
3
+ * (`src/tools/ast-grep/adapter/omp/ast-grep.ts`) into DSH's `defineTool`
4
+ * contract.
5
+ *
6
+ * This file is pure glue. All search logic lives in `omp/` (copied verbatim
7
+ * from OMP `tools/ast-grep.ts`); this adapter only:
8
+ * - builds an OMP `ToolSession` from the DSH exec context + tool-plus config,
9
+ * - constructs the verbatim `AstGrepTool` and calls its `execute`,
10
+ * - converts the `AgentToolResult` back to a DSH tool result.
11
+ *
12
+ * ast_grep is a READ-ONLY query: it matches AST patterns and returns hashline
13
+ * headers + line-numbered matches. There is no preview or apply step.
14
+ *
15
+ * Parameter shape is OMP-native (`pat` + optional `path`/`skip`), mirroring
16
+ * `tools/ast-grep.ts` verbatim. No TUI/ACP rendering happens in DSH; the
17
+ * model-facing `result.text` is surfaced directly.
18
+ */
19
+ import type { Context } from '@deepseek-ai/cordis';
20
+ import type { RuntimeConfig } from '../../../config/settings.ts';
21
+ export type { ToolSession } from './sdk.ts';
22
+ /**
23
+ * Register the ast_grep tool. Argument shape matches OMP verbatim:
24
+ * `pat` is a required AST pattern; `path` optionally selects files,
25
+ * directories, globs, or internal URLs (semicolon-delimited list); `skip`
26
+ * optionally skips the first N matches.
27
+ */
28
+ export declare function registerAstGrep(ctx: Context, getConfig: () => RuntimeConfig): () => void;
29
+ export declare const applyAstGrep: typeof registerAstGrep;
30
+ export declare const registerAstGrepTool: typeof registerAstGrep;
31
+ export default registerAstGrep;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * DSH adapter for OMP's `sdk.ts` — the `ToolSession` interface the ast_grep
3
+ * engine consumes.
4
+ *
5
+ * ast_grep is a read-only AST search tool. It reuses the read engine's tool
6
+ * scope resolver (`resolveToolSearchScope` from
7
+ * `src/tools/read/adapter/omp/path-utils.ts`), the native edit store
8
+ * (`recordFileSnapshot`/`recordSeenLinesFromBody` from
9
+ * `src/tools/omp/edit/file-snapshot-store.ts`), and the display-mode
10
+ * resolver (`resolveFileDisplayMode`), so this session facade declares exactly
11
+ * those members. DSH supplies the session adapter
12
+ * (`src/tools/ast-grep/adapter/index.ts`); the local:// router, skills, and
13
+ * snapshot store are DSH-side and optional (absent → read-scope resolution and
14
+ * hashline recording are inert, matching read). `getSessionSpawns` feeds the
15
+ * scout-spawnability hint in the tool description (`isScoutSpawnable`); when
16
+ * absent DSH defaults to unrestricted (`"*"`).
17
+ */
18
+ import type { Settings } from '../../omp/config/settings.ts';
19
+ import type { Skill } from '../../omp/extensibility/skills.ts';
20
+ import type { Model } from '@oh-my-pi/pi-ai';
21
+ /**
22
+ * Minimal ToolSession surface used by the OMP ast_grep engine (verbatim member
23
+ * shapes). DSH provides a session adapter implementing this interface.
24
+ */
25
+ export interface ToolSession {
26
+ /** Current working directory */
27
+ cwd: string;
28
+ /** Whether an edit-capable tool is available (suppresses hashline output) */
29
+ hasEditTool?: boolean;
30
+ /** Session settings (read keys and task keys; DSH maps them onto tool-plus config). */
31
+ settings: Settings;
32
+ /** Active model string for edit-mode resolution (optional in DSH). */
33
+ getActiveModelString?: () => string | undefined;
34
+ /** Active model object (optional in DSH). */
35
+ getActiveModel?: () => Model | undefined;
36
+ /** Native edit store (created lazily by the engine; hashline snapshots). */
37
+ editStore?: import('../../hashline/native/index.ts').EditStore;
38
+ /** Local protocol options (DSH has no local:// sandbox — optional). */
39
+ localProtocolOptions?: import('../../omp/internal-urls/index.ts').LocalProtocolOptions;
40
+ /** Pre-loaded skills (DSH: none). */
41
+ skills?: readonly Skill[];
42
+ /** Session subagent-spawn policy string, used for the scout hint (optional in DSH). */
43
+ getSessionSpawns?: () => string | null | undefined;
44
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Spill-file lifecycle for the bash tool, adapted from OMP's session artifact
3
+ * seam (`session.allocateOutputArtifact("bash")` + `saveBashOriginalArtifact`)
4
+ * to the plain Node filesystem: spill files live under `<tmpdir>/dsh-bash-spill/`,
5
+ * one unique file per call, written losslessly by the executor's OutputSink
6
+ * `artifactPath` mirror. A best-effort sweep removes files older than 24h
7
+ * (including the legacy flat `dsh-bash-*.log` naming from before this module),
8
+ * so orphaned captures do not accumulate across restarts.
9
+ * @module @xiaoso/dsh-tool-plus/bash/adapter/spill
10
+ */
11
+ /** Directory holding all bash spill files. */
12
+ export declare function spillDir(): string;
13
+ /**
14
+ * Allocate one unique spill file path for a call. The directory is created on
15
+ * first use; allocation failure (read-only tmp, exotic sandbox) returns
16
+ * `undefined` and the caller simply runs without a spill mirror.
17
+ */
18
+ export declare function allocateSpillFile(): string | undefined;
19
+ /**
20
+ * Allocate one unique file for a minimizer original capture (upstream
21
+ * `saveBashOriginalArtifact`). Same failure semantics as {@link allocateSpillFile}.
22
+ */
23
+ export declare function allocateOriginalFile(): string | undefined;
24
+ /**
25
+ * Write pre-minimization original text to a fresh file.
26
+ * Returns the path, or `undefined` when the write failed.
27
+ */
28
+ export declare function saveOriginalText(text: string): string | undefined;
29
+ /**
30
+ * Best-effort sweep of orphaned spill files: everything under the spill dir
31
+ * plus the legacy flat `tmpdir/dsh-bash-*.log` files older than 24h. Never
32
+ * throws; returns the number of files removed.
33
+ */
34
+ export declare function sweepStaleSpillFiles(now?: number): number;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Background-job adaptation for the `ctx.jobs` seam: one managed job runs its
3
+ * command on its OWN `:async:` Shell (never the session's persistent shell),
4
+ * so background work never blocks the foreground session. The registry owns
5
+ * identity, lifecycle state, and completion notices (`dsh-tool-jobs` injects
6
+ * them); this module owns the execution resources and their hooks.
7
+ * @module @xiaoso/dsh-tool-plus/background
8
+ */
9
+ import type { JobHooks } from '@deepseek-ai/dsh-jobs';
10
+ import type { BashForegroundOutput, ResolvedConfig } from './types.ts';
11
+ export interface ManagedBashJob {
12
+ /** Hooks handed to `ctx.jobs.start`'s `run()`. */
13
+ hooks: JobHooks;
14
+ /**
15
+ * The run's completion in tool-result terms. Foreground callers that
16
+ * auto-background and then finish within the wait window resolve this to
17
+ * return a foreground result; the registry's `done` maps it to an outcome.
18
+ */
19
+ completion: Promise<BashForegroundOutput>;
20
+ }
21
+ /** Options for {@link startBashJob}. */
22
+ export interface StartBashJobOptions {
23
+ /** Session id prefix for the job's shell key (`<sessionId>:async:<nonce>`). */
24
+ sessionId: string;
25
+ command: string;
26
+ cwd: string;
27
+ /** Effective deadline in ms; `undefined`/0 disables the job deadline. */
28
+ timeoutMs: number | undefined;
29
+ /** Command-scoped environment (already merged with dshEnv). */
30
+ env: Record<string, string> | undefined;
31
+ config: ResolvedConfig;
32
+ }
33
+ /**
34
+ * Start one managed background bash job. The producer owns a per-job
35
+ * `AbortController` (cancellation kills only this job's shell), a bounded
36
+ * preview tail, and a consuming delta cursor for `readOutput`.
37
+ * @param options - job identity and execution parameters.
38
+ * @returns the registry hooks plus the tool-result completion promise.
39
+ */
40
+ export declare function startBashJob(options: StartBashJobOptions): ManagedBashJob;
@@ -0,0 +1,102 @@
1
+ import { type MinimizerOptions } from "@oh-my-pi/pi-natives";
2
+ export interface ShellConfig {
3
+ shell: string;
4
+ args: string[];
5
+ env: Record<string, string>;
6
+ prefix: string | undefined;
7
+ }
8
+ export interface ShellMinimizerSettings {
9
+ enabled: boolean;
10
+ settingsPath: string | undefined;
11
+ only: string[];
12
+ except: string[];
13
+ maxCaptureBytes: number;
14
+ sourceOutlineLevel: "default" | "aggressive";
15
+ legacyFilters: boolean | undefined;
16
+ }
17
+ export declare function getShellConfig(): ShellConfig;
18
+ export declare const DEFAULT_MINIMIZER_SETTINGS: ShellMinimizerSettings;
19
+ export interface BashExecutorOptions {
20
+ cwd?: string;
21
+ /** Milliseconds before aborting the command; 0 disables the executor deadline. */
22
+ timeout?: number;
23
+ onChunk?: (chunk: string) => void;
24
+ chunkThrottleMs?: number;
25
+ signal?: AbortSignal;
26
+ /** Session key suffix to isolate shell sessions per agent */
27
+ sessionKey?: string;
28
+ /** Additional environment variables to inject */
29
+ env?: Record<string, string>;
30
+ /** Run through the configured user shell instead of brush parsing directly. */
31
+ useUserShell?: boolean;
32
+ /** Capture the user rc snapshot into the session shell (default true). */
33
+ snapshotEnabled?: boolean;
34
+ /** Redefine `rm` in the session shell to move into the system trash (default false). */
35
+ rmSafe?: boolean;
36
+ /** Apply non-interactive env hardening to the command environment (default true). */
37
+ nonInteractiveEnv?: boolean;
38
+ /** Enable intelligent output minimizer. Default true. */
39
+ minimizerEnabled?: boolean;
40
+ /** Minimizer settings (filters, capture budget). Defaults to {@link DEFAULT_MINIMIZER_SETTINGS}. */
41
+ minimizerSettings?: ShellMinimizerSettings;
42
+ /** Wrap the command in `bash -c '…'` before execution (full bash environment). */
43
+ useShellCommandWrapper?: boolean;
44
+ /** OutputSink tail rolling budget (bytes). Falls back to DEFAULT_MAX_BYTES (50KB). */
45
+ spillThreshold?: number;
46
+ /** OutputSink head window (bytes). Falls back to 20KB. */
47
+ headBytes?: number;
48
+ /**
49
+ * Mirror the full raw output stream to this file while it streams — the
50
+ * upstream `artifactPath` seam (`session.allocateOutputArtifact("bash")`).
51
+ * The mirror triggers exactly when the inline head+tail windows overflow,
52
+ * so a spill file exists whenever output was dropped. Lossless by default
53
+ * (`ARTIFACT_DEFAULT_MAX_BYTES = 0`).
54
+ */
55
+ artifactPath?: string;
56
+ /**
57
+ * Called when the native minimizer rewrote the output, with the original
58
+ * pre-minimization text (upstream `onMinimizedSave`). Return the path the
59
+ * text was saved to; it is surfaced as {@link BashResult.originalOutputPath}
60
+ * so the model can recover what the minimizer discarded.
61
+ */
62
+ onMinimizedSave?: (originalText: string) => string | undefined | Promise<string | undefined>;
63
+ }
64
+ export interface BashResult {
65
+ output: string;
66
+ exitCode: number | undefined;
67
+ cancelled: boolean;
68
+ /** True when the command was killed by its timeout deadline (not a user abort). */
69
+ timedOut?: boolean;
70
+ truncated: boolean;
71
+ totalLines: number;
72
+ totalBytes: number;
73
+ outputLines: number;
74
+ outputBytes: number;
75
+ /** Present when the native minimizer rewrote the output. */
76
+ minimized?: {
77
+ filter: string;
78
+ inputBytes: number;
79
+ outputBytes: number;
80
+ };
81
+ /** Path of the spill file mirroring the full raw stream, when one was created. */
82
+ spillPath?: string;
83
+ /** Path holding the pre-minimization original text, when {@link onMinimizedSave} saved one. */
84
+ originalOutputPath?: string;
85
+ /** Lines/bytes elided between the retained head and tail windows (middle elision). */
86
+ elidedLines?: number;
87
+ elidedBytes?: number;
88
+ workingDir?: string;
89
+ /** True when the rmSafe injection failed: `rm` stays the system command and deletes permanently. */
90
+ rmSafeInjectionFailed?: boolean;
91
+ }
92
+ /**
93
+ * Release every persistent shell owned by `sessionId` (foreground shells and
94
+ * retained `:async:` shells). Dropping the last reference SIGKILLs the native
95
+ * shell and its children via kill-on-drop; called on session shutdown/unbind.
96
+ */
97
+ export declare function closeSessionShells(sessionId: string): void;
98
+ /** Translate `ShellMinimizerSettings` into native `MinimizerOptions`, or `undefined` when disabled. */
99
+ export declare function buildMinimizerOptions(group: ShellMinimizerSettings): MinimizerOptions | undefined;
100
+ export declare function needsInteractiveShellArg(shell: string): boolean;
101
+ export declare function ensureInteractiveShellArgs(shell: string, args: string[]): string[];
102
+ export declare function executeBash(command: string, options?: BashExecutorOptions): Promise<BashResult>;
@@ -0,0 +1,33 @@
1
+ export interface BashInterceptorRule {
2
+ pattern: string;
3
+ flags?: string;
4
+ tool: string;
5
+ message: string;
6
+ allowSubcommands?: string[];
7
+ }
8
+ /**
9
+ * 规则表对齐上游 refs/oh-my-pi/packages/coding-agent/src/config/settings-schema.ts:325-387(10 条)。
10
+ * 既有 6 条(read/grep/glob/edit×3)语义与消息文案保持不变;新增 echo/printf 重定向 → write(上游 :356-367)。
11
+ * hub 类 3 条(nohup/后台语法、dev/start 服务、--watch,上游 :368-386)按映射决策加入:
12
+ * pattern 逐字照抄;tool hub → bash(DSH 等价受管机制 = bash 工具 run_in_background:true,
13
+ * startBashJob → jobs 注册表 → job_output 读输出 / job_kill 停止);文案改写为 run_in_background 引导。
14
+ * DSH 无 hub 的 stdin-send/restart/跨实例观察能力,属有意不移植。
15
+ * `bashInterceptor.patterns` 配置键不在本次范围,未引入。
16
+ */
17
+ export declare const DEFAULT_BASH_INTERCEPTOR_RULES: BashInterceptorRule[];
18
+ export interface InterceptionResult {
19
+ /** If true, the bash command should be blocked */
20
+ block: boolean;
21
+ /** Error message to return instead of executing */
22
+ message?: string;
23
+ /** Suggested tool to use instead */
24
+ suggestedTool?: string;
25
+ }
26
+ /**
27
+ * Check if a bash command should be intercepted.
28
+ *
29
+ * @param command The bash command to check
30
+ * @param availableTools Set of tool names that are available
31
+ * @returns InterceptionResult indicating if the command should be blocked
32
+ */
33
+ export declare function checkBashInterception(command: string, availableTools: string[], rules?: BashInterceptorRule[], originalCommand?: string): InterceptionResult;