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

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-BpqEnqNM.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-B7A3Eu4L.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,71 @@
1
+ /**
2
+ * Cooperative yield utility for preventing Bun event-loop busy-wait.
3
+ *
4
+ * ## Root Cause
5
+ *
6
+ * Bun 1.3.x (JavaScriptCore) event loop busy-waits (spins in userspace)
7
+ * when the only pending work is an unresolved Promise — even if there are
8
+ * active I/O watchers (stdin, child process pipes, etc.). The event loop
9
+ * continuously polls for microtask resolution instead of blocking in
10
+ * `epoll_wait`, consuming ~100% of a CPU core.
11
+ *
12
+ * This affects any `await` on a never-resolved Promise, including:
13
+ * - `Promise.withResolvers()` used for user input callbacks
14
+ * - `await proc.exited` for long-running child processes
15
+ * - Agent loop iterations waiting for the next tool call
16
+ *
17
+ * ## Fix
18
+ *
19
+ * A recurring `setInterval` keeps the event loop sleeping in `epoll_wait`.
20
+ * The `EventLoopKeepalive` class and `keepaliveWhile()` wrapper provide a
21
+ * clean way to install and clean up this keepalive timer.
22
+ *
23
+ * The older `yieldIfDue()` and `ExponentialYield` approaches (compensated
24
+ * sleep loops) are retained for the agent-loop hot-path where Promises
25
+ * resolve frequently and the keepalive alone is insufficient.
26
+ */
27
+ export declare class EventLoopKeepalive {
28
+ #private;
29
+ [Symbol.dispose](): void;
30
+ }
31
+ /**
32
+ * Cooperative yield gate. Sleeps for at least {@link YieldGateOptions.sleepMs}
33
+ * but at most once every {@link YieldGateOptions.intervalMs}; hot-path callers
34
+ * invoke it freely and only the slow path actually sleeps.
35
+ *
36
+ * The clock and sleep are injectable so tests drive the gate logic without
37
+ * touching process-global `Date.now`/`scheduler.wait` — globals a concurrent
38
+ * test file can restore mid-run, which previously made the shared gate flake.
39
+ */
40
+ export interface YieldGateOptions {
41
+ now?: () => number;
42
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
43
+ intervalMs?: number;
44
+ sleepMs?: number;
45
+ }
46
+ export declare class YieldGate {
47
+ #private;
48
+ constructor(opts?: YieldGateOptions);
49
+ yieldIfDue(signal?: AbortSignal): Promise<void>;
50
+ }
51
+ /**
52
+ * Yield to the Bun event loop, sleeping for at least 20 ms — but at most once
53
+ * every {@link YIELD_INTERVAL_MS} across all callers.
54
+ */
55
+ export declare function yieldIfDue(): Promise<void>;
56
+ export declare class ExponentialYield {
57
+ #private;
58
+ constructor(opts?: {
59
+ minMs?: number;
60
+ maxMs?: number;
61
+ multiplier?: number;
62
+ });
63
+ notifyActivity(): void;
64
+ sleep(signal?: AbortSignal): Promise<number>;
65
+ /**
66
+ * Race `racers` against an exponentially-backed-off cooperative yield.
67
+ * The losing sleep is cancelled as soon as a racer settles, so no stray
68
+ * timers keep the event loop alive past the racer's resolution.
69
+ */
70
+ race<T>(racers: Array<Promise<T>>): Promise<T>;
71
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * DSH edit tool — adapter that wires the verbatim OMP edit engine
3
+ * (`src/tools/omp/edit/`) into DSH's `defineTool` contract.
4
+ *
5
+ * This file is pure glue. All edit logic lives in `omp/` (copied verbatim);
6
+ * this adapter only:
7
+ * - builds an OMP `ToolSession` from the DSH exec context + tool-plus config,
8
+ * - picks the edit mode from the call shape (replace / patch / hashline /
9
+ * apply_patch), exactly like OMP's `EditTool.mode` resolution,
10
+ * - hands replace/apply_patch to the verbatim upstream dispatch layer
11
+ * (`omp/edit/dispatch.ts`,A-7/A-8:resolveEditPath 路径纠错 +
12
+ * executeSinglePathEntries / executeApplyPatchPerFile 聚合) and converts
13
+ * the `AgentToolResult` back to a DSH tool result.
14
+ *
15
+ * LSP/ACP/TUI are absent in DSH (plan.md 拍板#5/#8): writethrough writes through
16
+ * ctx.fs, diagnostics are never produced, and no TUI rendering happens.
17
+ */
18
+ import type { Context } from '@deepseek-ai/cordis';
19
+ import type { WritethroughCallback } from '../../omp/tools/writethrough.ts';
20
+ import type { RuntimeConfig } from '../../../config/settings.ts';
21
+ /** OMP 原版按模式渲染的 edit 描述(prompts/tools/*.md verbatim + native hashline 描述)。 */
22
+ export declare const EDIT_MODE_DESCRIPTIONS: {
23
+ readonly replace: string;
24
+ readonly patch: string;
25
+ readonly apply_patch: string;
26
+ readonly hashline: string;
27
+ };
28
+ /** File-write channel for DSH (方案A, 2026-08-27): every edit mode funnels
29
+ * through `ctx.fs` with the per-call sandbox policy resolved from the session
30
+ * (official tool-fs semantics). The OMP engines pass a `file` handle for
31
+ * patch/hashline modes — previously this adapter wrote through that handle
32
+ * (OMP node-fs direct write), bypassing the host's sandbox fence entirely,
33
+ * while replace mode went through `ctx.fs` WITHOUT the policy argument and
34
+ * was denied by the deployment fallback. Both defects are fixed here: the
35
+ * handle is ignored and the policy is always attached. */
36
+ export declare function createWritethrough(ctx: Context, exec: any): WritethroughCallback;
37
+ /** DSH edit 工具输出形状(output.schema 镜像)。 */
38
+ export interface EditToolOutput {
39
+ text: string;
40
+ }
41
+ /**
42
+ * S-13:edit.fuzzyThreshold 解析——上游 settings 面原样放行显式 0/负值
43
+ * (0 = 接受任意置信度的最佳匹配,refs edit/index.ts:112 同款语义),仅
44
+ * undefined/非数值回退引擎默认 0.95。env 层(上游 PI_EDIT_FUZZY* 环境变量
45
+ * 串解析)有意不移植:DSH 无该环境变量面,面板字段是唯一入口。
46
+ */
47
+ export declare function resolveFuzzyThreshold(raw: unknown): number;
48
+ /** 完整执行链路(defineTool.execute 与单测共用,镜像 read 的 executeReadTool)。 */
49
+ export declare function executeEditTool(exec: any, cfg: RuntimeConfig, args: any, ctx: Context | null): Promise<EditToolOutput>;
50
+ /**
51
+ * Register the edit tool. Mode is resolved per call from the argument shape
52
+ * (matching OMP's mode dispatch):
53
+ * - `input` present → hashline, or apply_patch when it starts with `***`
54
+ * - `patch` present → unified-diff patch mode
55
+ * - `edits` present (or old_string) → replace mode
56
+ */
57
+ export declare function registerEdit(ctx: Context, getConfig: () => RuntimeConfig): () => void;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A-3 合并后的纯转发层(second-impl-audit.md A-3)。
3
+ *
4
+ * 唯一实现在 `src/tools/omp/tools/auto-generated-guard.ts`(OMP refs
5
+ * packages/coding-agent/src/tools/auto-generated-guard.ts 的逐字移植,
6
+ * 含 T17-1 Windows basename 修复)。本文件不再持有任何守卫逻辑,仅为
7
+ * 既有 import 路径(omp/edit/hashline/filesystem.ts 等历史引用与单测)
8
+ * 保留转发。
9
+ */
10
+ export { assertEditableFile, assertEditableFileContent, } from "../../../omp/tools/auto-generated-guard.ts";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * DSH adapter for OMP `tools/output-meta.ts`.
3
+ *
4
+ * OMP attaches LSP diagnostics + output metadata to tool results. LSP
5
+ * diagnostics are cut (plan.md 拍板#5); the metadata *shape* is kept so
6
+ * engine code (`outputMeta().get()`) compiles unchanged.
7
+ */
8
+ export interface TruncationMeta {
9
+ kind: 'head' | 'tail' | 'middle';
10
+ startLine?: number;
11
+ totalFileLines?: number;
12
+ }
13
+ export interface SourceMeta {
14
+ path?: string;
15
+ lines?: number;
16
+ }
17
+ export interface LimitsMeta {
18
+ maxBytes?: number;
19
+ }
20
+ export interface OutputMeta {
21
+ truncation?: TruncationMeta;
22
+ source?: SourceMeta;
23
+ limits?: LimitsMeta;
24
+ }
25
+ /** Fluent builder for OutputMeta. */
26
+ export declare class OutputMetaBuilder {
27
+ #private;
28
+ truncation(value: TruncationMeta): this;
29
+ source(value: SourceMeta): this;
30
+ limits(value: LimitsMeta): this;
31
+ get(): OutputMeta;
32
+ }
33
+ /** Create a new OutputMeta builder. */
34
+ export declare function outputMeta(): OutputMetaBuilder;
@@ -0,0 +1,21 @@
1
+ import type { ToolSession } from '../../../omp/tools/index.ts';
2
+ /**
3
+ * Strip the hashline `[path#TAG]` wrapper from a write/edit target so the inner
4
+ * filesystem path drives both authorization and resolution (verbatim OMP).
5
+ */
6
+ export declare function unwrapHashlineHeaderPath(targetPath: string): string;
7
+ /** True when `targetPath` resolves inside the local sandbox (DSH: none). */
8
+ export declare function targetsLocalSandbox(_session: ToolSession, _targetPath: string): boolean;
9
+ /**
10
+ * Resolve a write/edit target to its absolute filesystem path (verbatim OMP
11
+ * resolution, minus local:// / vault:// schemes which DSH does not have).
12
+ */
13
+ export declare function resolvePlanPath(session: ToolSession, targetPath: string): string;
14
+ /**
15
+ * Plan mode hard-gate — deliberately a no-op in DSH (plan mode is a hint
16
+ * layer; official write/edit do not hard-block, plan.md §3 判定去掉).
17
+ */
18
+ export declare function enforcePlanModeWrite(_session: ToolSession, _targetPath: string, _options?: {
19
+ move?: string;
20
+ op?: 'create' | 'update' | 'delete';
21
+ }): void;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * DSH glob tool — adapter that wires the verbatim OMP glob engine
3
+ * (`src/tools/glob/adapter/omp/glob.ts`) into DSH's `defineTool` contract.
4
+ *
5
+ * This file is pure glue. All glob logic lives in `omp/` (copied verbatim);
6
+ * this adapter only:
7
+ * - builds an OMP `ToolSession` from the DSH exec context + tool-plus config,
8
+ * - constructs the verbatim `GlobTool` and calls its `execute`,
9
+ * - converts the `AgentToolResult` back to a DSH tool result, appending the
10
+ * OMP session-layer meta notice (`formatOutputNotice`, A-6) to the
11
+ * model-visible text.
12
+ *
13
+ * plan.md 拍板:glob keeps OMP's native single-param style (`path` with a
14
+ * semicolon-delimited multi-target list). DSH `hidden`/`gitignore`/`limit`
15
+ * are surfaced verbatim as optional parameters.
16
+ */
17
+ import type { Context } from '@deepseek-ai/cordis';
18
+ import type { AgentToolResult } from '@oh-my-pi/pi-agent-core';
19
+ import type { RuntimeConfig } from '../../../config/settings.ts';
20
+ export type { Settings } from '../../omp/config/settings.ts';
21
+ export type { ToolSession } from '../../omp/sdk.ts';
22
+ /** DSH glob 工具输出形状(output.schema 镜像)。 */
23
+ export interface GlobToolOutput {
24
+ path: string;
25
+ text: string;
26
+ fileCount?: number;
27
+ truncated?: boolean;
28
+ }
29
+ /**
30
+ * 把 OMP AgentToolResult 转成 DSH glob 工具输出。
31
+ *
32
+ * 上游 session 层会把 `formatOutputNotice(details.meta)` 的限量/截断提示追加
33
+ * 进模型可见文本(wrapToolWithMetaNotice → appendOutputNotice,refs
34
+ * tools/output-meta.ts:586);DSH 无 session 层,适配层在此补上(A-6),
35
+ * 否则 glob 超限截断对模型静默。
36
+ */
37
+ export declare function toGlobToolResult(result: AgentToolResult<any>, args: any): GlobToolOutput;
38
+ /**
39
+ * 完整执行链路(defineTool.execute 与单测共用)。
40
+ *
41
+ * `ctx` 参数与 read 的 executeReadTool 对齐(glob 引擎不需要 image bridge /
42
+ * session state,仅占位保持签名一致)。
43
+ */
44
+ export declare function executeGlobTool(exec: any, cfg: RuntimeConfig, args: any, ctx: Context): Promise<GlobToolOutput>;
45
+ /**
46
+ * Register the glob tool (OMP native `path` + optional `hidden`/`gitignore`/
47
+ * `limit` parameters).
48
+ */
49
+ export declare function registerGlob(ctx: Context, getConfig: () => RuntimeConfig): void;
50
+ export declare const applyGlob: typeof registerGlob;
51
+ export declare const registerGlobTool: typeof registerGlob;
52
+ export default registerGlob;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * DSH grep tool — adapter that wires the verbatim OMP grep engine
3
+ * (`src/tools/grep/adapter/omp/`) into DSH's `defineTool` contract.
4
+ *
5
+ * This file is pure glue. All grep logic lives in `omp/` (copied verbatim);
6
+ * this adapter only:
7
+ * - builds an OMP `ToolSession` from the DSH exec context + tool-plus config,
8
+ * - constructs the verbatim `GrepTool` and calls its `execute`,
9
+ * - converts the `AgentToolResult` back to a DSH tool result, appending the
10
+ * OMP session-layer meta notice (`formatOutputNotice`, A-6) to the
11
+ * model-visible text.
12
+ *
13
+ * Parameters follow OMP's native style (`pattern` regex + `path` with inline
14
+ * `:N-M` selectors); the DSH tool exposes the same schema so nothing is lost.
15
+ */
16
+ import type { Context } from '@deepseek-ai/cordis';
17
+ import type { AgentToolResult } from '@oh-my-pi/pi-agent-core';
18
+ import type { RuntimeConfig } from '../../../config/settings.ts';
19
+ export type { Settings } from '../../omp/config/settings.ts';
20
+ export type { ToolSession } from '../../omp/sdk.ts';
21
+ /** DSH grep 工具输出形状(output.schema 镜像)。 */
22
+ export interface GrepToolOutput {
23
+ text: string;
24
+ matchCount?: number;
25
+ fileCount?: number;
26
+ files?: string[];
27
+ scopePath?: string;
28
+ truncated?: boolean;
29
+ }
30
+ /**
31
+ * 把 OMP AgentToolResult 转成 DSH grep 工具输出。
32
+ *
33
+ * 上游 session 层会把 `formatOutputNotice(details.meta)` 的限量/截断提示追加
34
+ * 进模型可见文本(wrapToolWithMetaNotice → appendOutputNotice,refs
35
+ * tools/output-meta.ts:586);DSH 无 session 层,适配层在此补上(A-6),
36
+ * 否则 grep 的列宽截断/限量对模型静默。
37
+ */
38
+ export declare function toGrepToolResult(result: AgentToolResult<any>): GrepToolOutput;
39
+ /**
40
+ * 完整执行链路(defineTool.execute 与单测共用)。
41
+ *
42
+ * `ctx` 参数与 read 的 executeReadTool 对齐(grep 引擎不需要 image bridge /
43
+ * session state,仅占位保持签名一致)。
44
+ */
45
+ export declare function executeGrepTool(exec: any, cfg: RuntimeConfig, args: any, ctx: Context): Promise<GrepToolOutput>;
46
+ /**
47
+ * Register the grep tool (OMP-native `pattern` + `path` parameters; the `path`
48
+ * accepts an inline `:N-M` selector and may be a semicolon-delimited list).
49
+ */
50
+ export declare function registerGrep(ctx: Context, getConfig: () => RuntimeConfig): void;
51
+ export declare const applyGrep: typeof registerGrep;
52
+ export declare const registerGrepTool: typeof registerGrep;
53
+ export default registerGrep;
@@ -0,0 +1 @@
1
+ export declare function matchAbsolutePath(matchPath: string, searchPath: string): string;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Re-number a unified diff that uses the `+<lineNum>|content` /
3
+ * `-<lineNum>|content` / ` <lineNum>|content` line format into a compact
4
+ * current-file preview. Removed lines are counted for stats and post-edit
5
+ * offset tracking, but omitted from the preview. Added and context lines are
6
+ * anchored to their post-edit positions so a follow-up edit can reuse visible
7
+ * concrete lines directly. Long contiguous added runs are summarized with a
8
+ * `…` marker instead of echoing every inserted line.
9
+ *
10
+ * This is intentionally decoupled from the diff producer: anything that
11
+ * emits the `<sign><lineNum>|<content>` shape works.
12
+ *
13
+ * Migration note: the native engine has no equivalent export — its rendered
14
+ * `EditFileOutcome.text` already carries a compact preview, so DSH's
15
+ * `executeHashlineSingle` passes that text through untouched. This module is
16
+ * kept because `EditFileOutcome.diff` (and the diff/apply-patch engines) use
17
+ * the very same `<sign><lineNum>|<content>` shape, so the helper still has
18
+ * consumers. The algorithm is a **verbatim port** of the vendored
19
+ * `src/tools/hashline/engine/diff-preview.ts` (itself a verbatim port of the
20
+ * pre-18.0 TS engine), with the two option/result types inlined from that
21
+ * engine's `types.ts:147-160` so this file has no dependency on the deleted
22
+ * engine directory.
23
+ */
24
+ /** Result of {@link buildCompactDiffPreview}. */
25
+ export interface CompactDiffPreview {
26
+ preview: string;
27
+ addedLines: number;
28
+ removedLines: number;
29
+ }
30
+ /** Optional knobs for {@link buildCompactDiffPreview}. */
31
+ export interface CompactDiffOptions {
32
+ /** Added lines kept on each side of a long added-run elision (default 2). */
33
+ maxAddedRunContext?: number;
34
+ /** Back-compat alias for {@link maxAddedRunContext}. */
35
+ maxUnchangedRun?: number;
36
+ }
37
+ export declare function buildCompactDiffPreview(diff: string, options?: CompactDiffOptions): CompactDiffPreview;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * DSH adapter for the native (Rust) hashline engine.
3
+ *
4
+ * Upstream deleted the TypeScript `@oh-my-pi/hashline` package in 18.x and
5
+ * rewrote the engine as `crates/pi-edit/src/modes/hashline/*.rs`, exposed
6
+ * through `@oh-my-pi/pi-natives`. This module is the single seam DSH keeps
7
+ * against it, and it is a **verbatim port** of the two upstream TS files that
8
+ * replaced the old engine surface:
9
+ *
10
+ * - `refs/oh-my-pi/packages/coding-agent/src/tools/hashline-format.ts` (41L)
11
+ * → the `HL_*` constants plus the format/hash helpers below.
12
+ * - `refs/oh-my-pi/packages/coding-agent/src/edit/store.ts` (19L)
13
+ * → {@link getEditStore}.
14
+ *
15
+ * The multi-mode transport (`Patcher`/`Filesystem`/`Clipboard`/`InMemorySnapshotStore`)
16
+ * is gone on purpose: `EditSession.apply` owns staging, snapshot validation,
17
+ * `N*` block resolution, clipboard registers, the no-op loop guard, and the
18
+ * model-facing text. Hosts only supply an {@link EditPolicy} and a writer
19
+ * callback — see `./policy.ts` and `./writer.ts`.
20
+ *
21
+ * `tsconfig.json` aliases `@oh-my-pi/hashline` onto this module, so the DSH
22
+ * tools that only need the display/format helpers (read / write / grep /
23
+ * ast-edit / ast-grep / plan-mode-guard) import it directly.
24
+ */
25
+ import { blockRangeAt, EditSession, EditStore, editAutoGeneratedMessage, editDescription, editDiffString, editGrammar, editInspect, hashlineCountOps, structuredPatchHunks } from "@oh-my-pi/pi-natives";
26
+ import type { BlockRange, BlockRangeOptions, EditApplyOutcome, EditApplyRequest, EditDiffResult, EditFileOpIntent, EditFileOutcome, EditFilePreview, EditInspection, EditMatcherEntry, EditPolicy, EditPreviewBatch, EditVaultRoot, EditWriteRequest, EditWriteResponse } from "@oh-my-pi/pi-natives";
27
+ import { buildCompactDiffPreview } from "./diff-preview.ts";
28
+ import type { CompactDiffOptions, CompactDiffPreview } from "./diff-preview.ts";
29
+ import { detectLineEnding, normalizeToLF, restoreLineEndings, stripBom } from "./normalize.ts";
30
+ import type { BomResult, LineEnding } from "./normalize.ts";
31
+ /** Opens the `[path#tag]` section header. */
32
+ export declare const HL_FILE_PREFIX = "[";
33
+ /** Closes the `[path#tag]` section header. */
34
+ export declare const HL_FILE_SUFFIX = "]";
35
+ /** Separates the path from the tag inside a section header. */
36
+ export declare const HL_FILE_HASH_SEP = "#";
37
+ /** Hex digits in a section tag. */
38
+ export declare const HL_FILE_HASH_LENGTH = 4;
39
+ /** `MV` op keyword. */
40
+ export declare const HL_MOVE_KEYWORD = "MV";
41
+ /** `REM` op keyword. */
42
+ export declare const HL_REM_KEYWORD = "REM";
43
+ /** Separates an op locator from its body. */
44
+ export declare const HL_LINE_BODY_SEP = ":";
45
+ /** `[path#TAG]` section header. */
46
+ export declare function formatHashlineHeader(path: string, tag: string): string;
47
+ /** `N:line` numbered display rows starting at `startLine` (default 1). */
48
+ export declare function formatNumberedLines(text: string, startLine?: number): string;
49
+ /**
50
+ * One `N:line` display row. Composed in TS rather than delegated: the native
51
+ * surface has no single-line formatter (`hashlineFormatNumberedLines` takes a
52
+ * whole text), and the JS join is byte-identical to the native row shape —
53
+ * upstream composes it the same way (hashline-format.ts:26-28).
54
+ */
55
+ export declare function formatNumberedLine(lineNumber: number, line: string): string;
56
+ /**
57
+ * Split `text` into addressable rows, dropping the empty row a trailing
58
+ * newline produces. Upstream hashline-format.ts:30-34; the native engine
59
+ * numbers the same way internally.
60
+ */
61
+ export declare function splitAddressableFileLines(text: string): string[];
62
+ /** Strip hashline display prefixes (`N:` / `+N:` …) from pasted rows. */
63
+ export declare function stripHashlinePrefixes(lines: string[]): string[];
64
+ /** 4-hex hashline content tag for `text`. */
65
+ export declare function computeFileHash(text: string): string;
66
+ /** Owner of the lazily created per-session store. */
67
+ export interface EditStoreOwner {
68
+ editStore?: EditStore;
69
+ }
70
+ /**
71
+ * The session's store, created on first use (verbatim upstream
72
+ * `edit/store.ts:15-18`).
73
+ *
74
+ * One store per session carries the full-file snapshots that mint hashline
75
+ * tags, the `CUT`/`PUT` clipboard registers, and the byte-identical no-op loop
76
+ * guard — every {@link EditSession} the edit tool opens shares it, and the
77
+ * read/search/write tools mint their tags into it.
78
+ *
79
+ * DSH note: DSH rebuilds its `ToolSession` object on every tool call and
80
+ * round-trips the store through `shared/session-state.ts`, so the engine path
81
+ * reaches the store through `getFileSnapshotStore` in
82
+ * `src/tools/omp/edit/file-snapshot-store.ts`, which delegates here.
83
+ */
84
+ export declare function getEditStore(session: EditStoreOwner): EditStore;
85
+ /**
86
+ * Raised when the native engine rejects a payload.
87
+ *
88
+ * The Rust engine reports every rejection as an `isError` outcome carrying the
89
+ * model-facing text — mismatched tag, unseen anchor line, missing file, no-op
90
+ * escalation (upstream `edit/index.ts:495-497` returns it as a tool result).
91
+ * DSH's `edit` tool contract is throw-based (`toText` in
92
+ * `src/tools/edit/adapter/index.ts` throws when a result is `isError`), and
93
+ * DSH's per-file detail shape carries `displayErrorText` sourced from
94
+ * `MismatchError.displayMessage` (`details.ts`, `dispatch.ts`), so
95
+ * `executeHashlineSingle` re-raises the native text as this class. Both
96
+ * `message` and `displayMessage` are exactly the native text, so the model
97
+ * sees the teaching message unchanged.
98
+ *
99
+ * (Upstream's pre-18.0 `MismatchError` formatted its own richer diagnostic
100
+ * from structured fields; the native text already contains that diagnostic,
101
+ * hence the single-string shape.)
102
+ */
103
+ export declare class MismatchError extends Error {
104
+ /** Model/TUI-facing text — always identical to {@link Error.message}. */
105
+ readonly displayMessage: string;
106
+ constructor(message: string);
107
+ }
108
+ export { blockRangeAt, buildCompactDiffPreview, detectLineEnding, EditStore, EditSession, editAutoGeneratedMessage, editDescription, editDiffString, editGrammar, editInspect, hashlineCountOps, normalizeToLF, restoreLineEndings, stripBom, structuredPatchHunks, };
109
+ export type { BlockRange, BlockRangeOptions, BomResult, CompactDiffOptions, CompactDiffPreview, EditApplyOutcome, EditApplyRequest, EditDiffResult, EditFileOpIntent, EditFileOutcome, EditFilePreview, EditInspection, EditMatcherEntry, EditPolicy, EditPreviewBatch, EditVaultRoot, EditWriteRequest, EditWriteResponse, LineEnding, };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Minimal text-shape normalization: line-ending detection / round-trip and
3
+ * BOM stripping. The edit engines use these to canonicalize text to LF before
4
+ * applying edits and to restore the original shape on write-back.
5
+ *
6
+ * Migration note: this is a **verbatim port** of the vendored
7
+ * `src/tools/hashline/engine/normalize.ts` (itself a verbatim port of the
8
+ * pre-18.0 TS engine). The Rust engine has no equivalent exports — it
9
+ * normalizes internally and never hands these primitives back to the host —
10
+ * but DSH's own edit paths (`omp/edit/normalize.ts`, which re-exports this
11
+ * module through the `@oh-my-pi/hashline` alias, plus `read`/`write`/`grep`
12
+ * snapshot recording) still need them. Kept here so the single hashline seam
13
+ * keeps its old export surface after the engine directory was deleted.
14
+ */
15
+ export type LineEnding = "\r\n" | "\n";
16
+ /** Detect the first line ending style in `content`. Defaults to LF when neither is present. */
17
+ export declare function detectLineEnding(content: string): LineEnding;
18
+ /** Normalize every line ending to LF. */
19
+ export declare function normalizeToLF(text: string): string;
20
+ /** Re-encode LF text with the requested line ending. */
21
+ export declare function restoreLineEndings(text: string, ending: LineEnding): string;
22
+ export interface BomResult {
23
+ /** Either the empty string or the BOM sequence (currently UTF-8 BOM). */
24
+ bom: string;
25
+ /** Text with any leading BOM removed. */
26
+ text: string;
27
+ }
28
+ /** Strip a UTF-8 BOM if present and return both the BOM and the trailing text. */
29
+ export declare function stripBom(content: string): BomResult;
@@ -0,0 +1,98 @@
1
+ import type { ToolSession } from "../../omp/sdk.ts";
2
+ import type { EditPolicy } from "./index.ts";
3
+ /** Optional overrides for {@link buildHashlineEditPolicy}. */
4
+ export interface HashlinePolicyOptions {
5
+ /**
6
+ * The payload is a verbatim custom-format string rather than JSON
7
+ * (upstream sets this when the call arrived through the custom-tool wire).
8
+ * DSH never opens an argument stream — it hands `executeHashlineSingle` the
9
+ * parsed `{ input }` arguments — so this stays `false`.
10
+ */
11
+ rawInput?: boolean;
12
+ }
13
+ /**
14
+ * Canonicalize `cwd` for the engine policy.
15
+ *
16
+ * The Rust engine canonicalizes the paths it stores (`recordSnapshot`), but it
17
+ * uses `policy.cwd` verbatim for path resolution and for its containment check,
18
+ * and that check compares byte-wise (`path_policy.rs:429-431`). On Windows a
19
+ * workspace under `%TEMP%` reaches JS in 8.3 short form
20
+ * (`C:\Users\XIAOSO~1\...`) while the engine's canonical snapshot key is the
21
+ * long form (`C:\Users\xiaoso456\...`), so an un-normalized `cwd` makes
22
+ * `is_within` fail and tag path recovery silently skip — verified with
23
+ * `D:/tmp/hashline-probes/probe-d3-recovery.mts` (raw cwd →
24
+ * `File not found: a.ts`; canonical cwd → recovered onto `nested/a.ts`).
25
+ *
26
+ * `.native` is required: the JS `realpathSync` does NOT expand short names.
27
+ * A failure (missing directory, permissions) falls back to the input, matching
28
+ * `canonicalSnapshotKey`'s behaviour so both sides of the store agree on one
29
+ * spelling.
30
+ *
31
+ * The same byte-wise check also drives the plan-sandbox / vault-root
32
+ * decisions, so normalizing here is what keeps those from silently
33
+ * mis-evaluating on a short-name cwd. Parity measured this normalization as
34
+ * neutral for every other policy behaviour (7 scenarios, raw vs canonical).
35
+ */
36
+ export declare function canonicalCwd(cwd: string): string;
37
+ /**
38
+ * Build the engine policy for one `hashline` tool call.
39
+ *
40
+ * Field sources (all reads go through the DSH settings facade, which maps the
41
+ * OMP dotted keys onto the tool-plus config — `src/config/omp-settings.ts`):
42
+ *
43
+ * - `cwd` — `session.cwd` through {@link canonicalCwd}: the
44
+ * engine resolves every authored path against it and
45
+ * runs its byte-wise containment check on it
46
+ * (upstream :563 passes the cwd verbatim; the
47
+ * normalization is a DSH-required fix for Windows
48
+ * short names — see {@link canonicalCwd}).
49
+ * - `mode` — constant `"hashline"`: this adapter only serves the
50
+ * hashline entry point.
51
+ * - `allowFuzzy` — `edit.fuzzyMatch`, default true
52
+ * (`edit/adapter/index.ts:210`).
53
+ * - `fuzzyThreshold` — `edit.fuzzyThreshold`, default 0.95 (S-13 above).
54
+ * - `enforceSeenLines` — `edit.enforceSeenLines`, schema default false
55
+ * (`src/config/omp-settings.ts:24/72`). **Passed
56
+ * explicitly and never left to a default**: the
57
+ * vendored TS `Patcher` defaulted this to `true`,
58
+ * while upstream/native resolve it from settings
59
+ * (default `false`). The old engine's stricter
60
+ * default therefore deliberately does not survive
61
+ * the migration; DSH follows the settings value
62
+ * (strict boolean, so a missing key reads as "off").
63
+ * - `blockAutoGenerated`— `edit.blockAutoGenerated`, schema default true
64
+ * (`omp-settings.ts:21/69`); `!== false` mirrors
65
+ * `shouldBlockAutoGeneratedFiles`'s default-on
66
+ * semantics in `omp/tools/auto-generated-guard.ts:297`.
67
+ * - `planActive` — upstream reads `session.getPlanModeState()?.enabled`.
68
+ * DSH's plan mode is a hint layer with **no hard
69
+ * gate** (`edit/adapter/tools/plan-mode-guard.ts`
70
+ * documents `enforcePlanModeWrite` as a deliberate
71
+ * no-op), and no DSH session installs
72
+ * `getPlanModeState`, so this resolves to `false`.
73
+ * - `localSandboxRoot` — upstream resolves the `local://` root. DSH has no
74
+ * `local://` write sandbox: the edit-path guard
75
+ * (`edit/adapter/tools/plan-mode-guard.ts`) hardcodes
76
+ * `targetsLocalSandbox → false` and documents plan
77
+ * mode as a hint layer, so `undefined` reproduces the
78
+ * old engine's `allowTagPathRecovery` exactly (cwd
79
+ * only). **If DSH ever wires a real sandbox root, it
80
+ * must go through {@link canonicalCwd} too** — the
81
+ * engine's containment check is byte-wise on
82
+ * `localSandboxRoot` just like on `cwd`.
83
+ * Consequence (D-3, awaiting the Lead's ruling): the
84
+ * vendored engine's `allowTagPathRecovery` override —
85
+ * which let a bare/mis-typed authored path rebind onto
86
+ * the file its snapshot tag uniquely names — has no
87
+ * counterpart here. The native engine now decides tag
88
+ * path recovery from `cwd` / `localSandboxRoot` /
89
+ * `vaultRoots` / `homeDir` alone, so a bare filename
90
+ * that needs rebinding fails with native's own error
91
+ * rather than silently landing on a recovered path.
92
+ * - `vaultRoots` — upstream `isVaultEnabled() ? cachedVaultRoots() : …`.
93
+ * DSH has no `vault://` protocol → `undefined`.
94
+ * - `homeDir` — `os.homedir()` (upstream :571); the engine uses it
95
+ * to recognise and refuse home-directory escapes.
96
+ * - `rawInput` — see {@link HashlinePolicyOptions.rawInput}.
97
+ */
98
+ export declare function buildHashlineEditPolicy(session: ToolSession, options?: HashlinePolicyOptions): EditPolicy;
@@ -0,0 +1,42 @@
1
+ import type { ToolSession } from "../../omp/sdk.ts";
2
+ import type { WritethroughCallback } from "../../omp/tools/writethrough.ts";
3
+ import type { EditWriteRequest, EditWriteResponse } from "./index.ts";
4
+ /** Wiring for {@link createHashlineWriter}. */
5
+ export interface HashlineWriterOptions {
6
+ session: ToolSession;
7
+ /** DSH's sandbox-routed file-write channel. */
8
+ writethrough: WritethroughCallback;
9
+ signal?: AbortSignal;
10
+ }
11
+ /**
12
+ * The `writer` argument for `EditSession.apply`, carrying the landed-file
13
+ * record alongside the callback.
14
+ *
15
+ * The native callback signature carries a leading `error` (used by the
16
+ * streaming *preview* channel, never by write requests) — upstream ignores it
17
+ * the same way (`refs/.../edit/index.ts:576`).
18
+ */
19
+ export interface HashlineWriter {
20
+ /** The error-first callback the engine invokes for every landed change. */
21
+ (error: Error | null, request: EditWriteRequest): Promise<EditWriteResponse>;
22
+ /**
23
+ * DSH display paths (`EditWriteRequest.displayPath` — the authored form,
24
+ * e.g. `a.ts`; for a move the *source*, which is the section that landed) of
25
+ * every file this apply actually wrote, in write order.
26
+ *
27
+ * The engine calls the writer once per file and aborts on the first throw,
28
+ * so after a rejected payload this holds exactly the sections that are on
29
+ * disk — the breadcrumb `executeHashlineSingle` re-attaches to the
30
+ * model-facing error (the old TS engine reported the same list from its
31
+ * prepared batch, `engine/patcher.ts:287-296` at v17.3.5).
32
+ */
33
+ readonly landedPaths: readonly string[];
34
+ }
35
+ /**
36
+ * Build the `writer` argument for `EditSession.apply`.
37
+ *
38
+ * The returned callable also exposes {@link HashlineWriter.landedPaths}; only a
39
+ * *successful* write is recorded, so a channel refusal on file #2 leaves just
40
+ * file #1 in the list.
41
+ */
42
+ export declare function createHashlineWriter(options: HashlineWriterOptions): HashlineWriter;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Per-CDP-message timeout applied to every puppeteer launch/connect. Set above
3
+ * the fetch tool timeout (30s) so the tool wall-clock is the canonical limit;
4
+ * this constant only catches genuinely stuck CDP sockets.
5
+ */
6
+ export declare const BROWSER_PROTOCOL_TIMEOUT_MS = 60000;
7
+ /**
8
+ * Resolve the Chromium executable the browser renderer will launch.
9
+ * `PUPPETEER_EXECUTABLE_PATH` always wins, then the system
10
+ * Chrome/Edge/Chromium candidate table (Windows and macOS check mere file
11
+ * existence; Linux additionally version-probes, see {@link isChromiumExecutable}).
12
+ * Returns undefined when nothing is found — puppeteer-core would fall back to
13
+ * its own bundled-Chromium search, which for this package means failure, so
14
+ * callers should treat undefined as "browser rendering unavailable".
15
+ *
16
+ * Unlike OMP upstream there is no Chrome-for-Testing download fallback: this
17
+ * plugin ships no browser installer, and the detection button only reports
18
+ * what is already on the machine.
19
+ */
20
+ export declare function ensureChromiumExecutable(): Promise<string | undefined>;
21
+ /** Reset the cached executable resolution (test seam). */
22
+ export declare function resetChromiumExecutableForTest(): void;
23
+ /** Exposes executable candidates for detection tests (OMP parity export). */
24
+ export declare function systemChromiumCandidatesForTest(platform?: NodeJS.Platform, home?: string, which?: (name: string) => string | null | undefined): string[];
25
+ /** Expose the Linux probe for tests (OMP parity export). */
26
+ export declare function chromiumExecutableProbeForTest(executablePath: string): Promise<boolean>;
27
+ /** Expose the executable-file check for tests. */
28
+ export declare function isExecutableFileForTest(p: string): boolean;