@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,16 @@
1
+ /**
2
+ * A-3 合并后的兼容转发层(second-impl-audit.md A-3)。
3
+ *
4
+ * 唯一实现在 `../omp/tools/auto-generated-guard.ts`(OMP 逐字移植 + T17-1
5
+ * Windows basename 修复)。原「简化重写」已删除:SimpleLRU、手搓 peekFile、
6
+ * 截断的三步整改文案、推送开关全部移除;开关语义改为 settings-pull
7
+ * (`edit.blockAutoGenerated`,三级回退 activeSettings → 全局 settings →
8
+ * schema 默认 true,refs settings-schema.ts:3230)。
9
+ */
10
+ export { assertEditableFile, assertEditableFileContent, } from '../omp/tools/auto-generated-guard.ts';
11
+ /**
12
+ * @deprecated 兼容旧推送式 API:守卫已改为 settings-pull(调用方传
13
+ * session.settings,未传时回退全局/默认),推送开关不再参与行为判定。
14
+ * 保留为 no-op 以兼容既有 import;src/index.ts 的调用点已删除。
15
+ */
16
+ export declare function setBlockAutoGenerated(_enabled: boolean): void;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Browser executable detection for the read browser renderer — a thin,
3
+ * fully-injectable shell over the OMP probe family (`src/tools/omp/browser/launch.ts`).
4
+ *
5
+ * Two entry points share one candidate pipeline:
6
+ * - {@link probeBrowsers} — no caching; every call walks the candidate table.
7
+ * Backs the settings-panel "探测浏览器" button via the host RPC, so a user
8
+ * can re-probe after installing a browser.
9
+ * - {@link detectBrowser} — memoizes the first success as the renderer's
10
+ * executable choice, so repeated reads do not re-stat the filesystem.
11
+ *
12
+ * Candidate kinds are annotated for display (`edge` / `chrome` / `chromium` /
13
+ * `cfr` / `env`); the renderer itself only needs the resolved path, so the
14
+ * detection result and the launch path never drift.
15
+ *
16
+ * Host-side only: this module imports node:fs, so it must never be reached
17
+ * from the browser client half (it isn't — the client imports the channel
18
+ * constants module, not this one).
19
+ * @module @xiaoso/dsh-tool-plus/browser-detect
20
+ */
21
+ /** Browser family labels surfaced by the detection button. */
22
+ export type BrowserKind = "edge" | "chrome" | "chromium" | "cfr" | "env";
23
+ /** One detected browser executable. */
24
+ export interface DetectedBrowser {
25
+ kind: BrowserKind;
26
+ name: string;
27
+ path: string;
28
+ }
29
+ /** Injectable environment; everything the probe touches comes through here. */
30
+ export interface BrowserDetectEnv {
31
+ platform: NodeJS.Platform;
32
+ home: string;
33
+ which: (name: string) => string | null | undefined;
34
+ exists: (p: string) => boolean;
35
+ /** Directory listing for Chrome-for-Testing cache roots. */
36
+ readdir?: (p: string) => string[];
37
+ /** PUPPETEER_EXECUTABLE_PATH override (wins over the table). */
38
+ envPath?: string;
39
+ /** Chrome-for-Testing cache roots to scan (defaults to getPuppeteerDir()). */
40
+ cacheDirs?: readonly string[];
41
+ }
42
+ /** Default environment: the real platform/homedir/which/filesystem. */
43
+ export declare function defaultBrowserDetectEnv(): BrowserDetectEnv;
44
+ /** Detect every usable browser on the machine, best first. No caching. */
45
+ export declare function probeBrowsers(env?: BrowserDetectEnv): DetectedBrowser[];
46
+ /**
47
+ * Resolve the browser the renderer will launch (memoized). Mirrors
48
+ * {@link ensureChromiumExecutable} priority (PUPPETEER_EXECUTABLE_PATH →
49
+ * system table → Chrome-for-Testing cache) but keeps its own display
50
+ * metadata; returns undefined when no browser exists.
51
+ */
52
+ export declare function detectBrowser(env?: BrowserDetectEnv): DetectedBrowser | undefined;
53
+ /** Clear the memoized detection (re-probe on next call; test seam). */
54
+ export declare function resetBrowserDetectionForTest(): void;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Shared RPC channel constants for the browser-detection round trip between
3
+ * the settings panel (client half) and the host. Both halves import this
4
+ * module so the channel/endpoint never drift.
5
+ *
6
+ * The channel rides the official `@deepseek-ai/dsh-client-connection` generic
7
+ * RPC transport (host registers with `ctx.connection.rpc.handle`; the client
8
+ * calls via `createWebConnectionRpc().call`). Channel names must match
9
+ * `/^\/[A-Za-z0-9._~-]+$/` and `/api` is reserved — `/tool-plus` is ours.
10
+ * @module @xiaoso/dsh-tool-plus/browser-rpc-channel
11
+ */
12
+ /** Logical RPC channel registered by the host half of this plugin. */
13
+ export declare const TOOL_PLUS_RPC_CHANNEL = "/tool-plus";
14
+ /** Endpoint that probes the machine for usable browsers (probeBrowsers). */
15
+ export declare const BROWSER_DETECT_ENDPOINT = "browser/detect";
16
+ /** Endpoint that reports the rmSafe injection status (query = ensure + verify). */
17
+ export declare const RM_SAFE_STATUS_ENDPOINT = "rmSafe/status";
18
+ /** Payload of a browser/detect call (currently empty). */
19
+ export interface BrowserDetectPayload {
20
+ }
21
+ /** One detected browser as surfaced over the wire. */
22
+ export interface BrowserDetectItem {
23
+ kind: 'edge' | 'chrome' | 'chromium' | 'cfr' | 'env';
24
+ name: string;
25
+ path: string;
26
+ }
27
+ /** Successful browser/detect result. */
28
+ export interface BrowserDetectValue {
29
+ found: BrowserDetectItem[];
30
+ }
31
+ /** rmSafe/status result (mirrors RmSafeStatus from bash/rm-safe-status). */
32
+ export type RmSafeStatusValue = {
33
+ status: 'disabled';
34
+ } | {
35
+ status: 'failed';
36
+ reason: 'snapshot-unavailable' | 'cli-missing' | 'snapshot-write-failed' | 'runtime-not-effective';
37
+ } | {
38
+ status: 'injected';
39
+ runtime: 'function' | 'system' | 'unknown';
40
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * DSH named-import shim for `bun:ffi` (pi-utils stderr-guard / process-name).
3
+ * Both consumers degrade silently when dlopen is unavailable ("Never throws:
4
+ * bun:ffi unavailability ... degrades silently"), so this shim returns null.
5
+ */
6
+ export declare const FFIType: Record<string, number>;
7
+ export declare function dlopen(): null;
8
+ export declare const ptr: () => number;
9
+ /** FFI C-string view (pi-tui ttyid) — never populated since dlopen is null. */
10
+ export declare class CString {
11
+ constructor(_ptr: number);
12
+ toString(): string;
13
+ }
@@ -0,0 +1,42 @@
1
+ import { GlobShim } from './bun-shim.ts';
2
+ export { GlobShim as Glob } from './bun-shim.ts';
3
+ /** Bun.YAML (pi-utils frontmatter) — yaml package under the hood. */
4
+ export declare const YAML: {
5
+ parse: (s: string) => unknown;
6
+ stringify: (v: unknown) => string;
7
+ };
8
+ /** Bun build plugin hook (pi-utils module-timer) — inert under Node. */
9
+ export declare function plugin(): void;
10
+ /** Minimal Bun-shell result (pi-ai perplexity OAuth; never reached on non-macOS). */
11
+ declare class BunShellResult {
12
+ get exitCode(): number;
13
+ text(): string;
14
+ quiet(): this;
15
+ nothrow(): this;
16
+ cwd(): this;
17
+ }
18
+ /** Bun shell template tag (Bun `$`). Perplexity's macOS defaults read only. */
19
+ export declare function $(_strings: TemplateStringsArray, ..._expr: unknown[]): BunShellResult;
20
+ /** HTTP cookie (pi-ai OAuth flows). */
21
+ export declare class Cookie {
22
+ #private;
23
+ name: string;
24
+ value: string;
25
+ constructor(name: string, value: string, expires?: Date);
26
+ static parse(header: string): Cookie;
27
+ isExpired(): boolean;
28
+ }
29
+ /** Ordered cookie jar (Bun CookieMap surface used by pi-ai OAuth). */
30
+ export declare class CookieMap implements Iterable<[string, string]> {
31
+ #private;
32
+ get size(): number;
33
+ set(name: string, value: string): void;
34
+ get(name: string): string | undefined;
35
+ delete(name: string): boolean;
36
+ has(name: string): boolean;
37
+ clear(): void;
38
+ [Symbol.iterator](): Iterator<[string, string]>;
39
+ }
40
+ export type Subprocess = unknown;
41
+ export type Spawn = unknown;
42
+ export type BunFile = GlobShim;
@@ -0,0 +1,138 @@
1
+ export declare class BunFileShim {
2
+ readonly path: string;
3
+ constructor(p: string);
4
+ get size(): number;
5
+ get name(): string;
6
+ exists(): Promise<boolean>;
7
+ text(): Promise<string>;
8
+ json(): Promise<unknown>;
9
+ arrayBuffer(): Promise<ArrayBuffer>;
10
+ bytes(): Promise<Uint8Array>;
11
+ writer(): FileSinkShim;
12
+ /** Bun extension: stat the file (patched Node implementation). */
13
+ stat(): Promise<{
14
+ mtimeMs: number;
15
+ size: number;
16
+ isDirectory(): boolean;
17
+ }>;
18
+ /** Bun extension: delete the file. */
19
+ unlink(): Promise<void>;
20
+ /** Bun extension: write content to the file (overwrite). */
21
+ write(content: string | Uint8Array | Blob | ArrayBuffer): Promise<void>;
22
+ /** Bun extension: a sub-range view of the file. */
23
+ slice(start?: number, end?: number): BunFileShim;
24
+ stream(): ReadableStream<Uint8Array>;
25
+ }
26
+ /** Sub-range view of a file (Bun's `BunFile.slice`). */
27
+ export declare class BunFileSliceShim extends BunFileShim {
28
+ #private;
29
+ constructor(filePath: string, start: number, end: number | undefined);
30
+ get size(): number;
31
+ text(): Promise<string>;
32
+ bytes(): Promise<Uint8Array>;
33
+ arrayBuffer(): Promise<ArrayBuffer>;
34
+ /** Blob semantics: stream yields only the slice window. */
35
+ stream(): ReadableStream<Uint8Array>;
36
+ }
37
+ export declare class FileSinkShim {
38
+ #private;
39
+ constructor(filePath: string);
40
+ write(chunk: string | Uint8Array): void;
41
+ flush(): void;
42
+ end(): void;
43
+ close(): void;
44
+ }
45
+ export declare class GlobShim {
46
+ #private;
47
+ constructor(pattern: string);
48
+ scan(opts?: {
49
+ cwd?: string;
50
+ absolute?: boolean;
51
+ onlyFiles?: boolean;
52
+ dot?: boolean;
53
+ }): AsyncGenerator<string>;
54
+ match(input: string): boolean;
55
+ }
56
+ declare class CryptoHasherShim {
57
+ #private;
58
+ constructor(algorithm: string);
59
+ update(data: string | Uint8Array): this;
60
+ digest(encoding: 'hex' | 'base64' | 'buffer' | string): string | Buffer;
61
+ }
62
+ interface ImageStep {
63
+ op: 'resize' | 'png' | 'jpeg' | 'webp' | 'rotate' | 'flip' | 'blur' | 'sharpen';
64
+ args: unknown[];
65
+ }
66
+ export declare class BunImageShim {
67
+ #private;
68
+ constructor(bytes: Uint8Array | ArrayBuffer, steps?: readonly ImageStep[]);
69
+ metadata(): Promise<{
70
+ width: number;
71
+ height: number;
72
+ format?: string;
73
+ hasAlpha?: boolean;
74
+ }>;
75
+ resize(widthOrOpts?: number | {
76
+ width?: number;
77
+ height?: number;
78
+ quality?: number;
79
+ }, height?: number): BunImageShim;
80
+ /** Bun's resize() accepts { width, height, fit } — expose fit through to sharp. */
81
+ resizeWithFit(width: number, height: number, fit: 'cover' | 'contain' | 'fill' | 'inside' | 'outside'): BunImageShim;
82
+ png(): BunImageShim;
83
+ jpeg(opts?: {
84
+ quality?: number;
85
+ }): BunImageShim;
86
+ webp(opts?: {
87
+ quality?: number;
88
+ }): BunImageShim;
89
+ rotate(): BunImageShim;
90
+ flip(flip: boolean): BunImageShim;
91
+ blur(radius: number): BunImageShim;
92
+ sharpen(radius?: number): BunImageShim;
93
+ bytes(): Promise<Uint8Array>;
94
+ toBase64(): Promise<string>;
95
+ write(destPath: string): Promise<number>;
96
+ }
97
+ type ArchiveMemberContent = string | Uint8Array | Blob;
98
+ declare function archiveWrite(destPath: string, record: Record<string, ArchiveMemberContent>, opts?: {
99
+ compress?: 'gzip';
100
+ }): Promise<void>;
101
+ export declare function bunStripANSI(text: string): string;
102
+ export interface BunShimSurface {
103
+ file(path: string): BunFileShim;
104
+ write(path: string, data: string | Uint8Array | Blob | ArrayBuffer): Promise<void>;
105
+ env: NodeJS.ProcessEnv;
106
+ which(command: string, options?: {
107
+ PATH?: string;
108
+ cwd?: string;
109
+ }): string | null;
110
+ sleep(ms: number): Promise<void>;
111
+ randomUUIDv7(): string;
112
+ stringWidth(s: string): number;
113
+ Glob: typeof GlobShim;
114
+ Archive: {
115
+ write: typeof archiveWrite;
116
+ };
117
+ FileSink: typeof FileSinkShim;
118
+ Image: typeof BunImageShim;
119
+ CryptoHasher: typeof CryptoHasherShim;
120
+ color(color: string, format?: string): string;
121
+ stripANSI(text: string): string;
122
+ JSON: {
123
+ parse(s: string): unknown;
124
+ stringify(v: unknown): string;
125
+ };
126
+ JSON5: {
127
+ parse(s: string): unknown;
128
+ };
129
+ Encoding: Record<string, never>;
130
+ native: undefined;
131
+ BunFile: typeof BunFileShim;
132
+ version: string;
133
+ hash: ((input: string | ArrayBuffer | Uint8Array, seed?: number | bigint) => number) & {
134
+ xxHash64(data: string | ArrayBuffer | Uint8Array, seed?: bigint): bigint;
135
+ };
136
+ }
137
+ export declare function installBunShim(): void;
138
+ export {};
@@ -0,0 +1,49 @@
1
+ import type { StatementSync } from 'node:sqlite';
2
+ /**
3
+ * Bindings bun:sqlite accepts. Includes `boolean` because the unmodified OMP
4
+ * write path passes booleans directly; the shim coerces them to `1`/`0` for
5
+ * node:sqlite, which rejects them.
6
+ */
7
+ export type SQLQueryBindings = string | number | bigint | boolean | null | Uint8Array;
8
+ /** Constructor options for {@link Database} — a superset of bun's surface. */
9
+ export interface DatabaseOptions {
10
+ readonly?: boolean;
11
+ create?: boolean;
12
+ strict?: boolean;
13
+ }
14
+ /** Wrap a node `StatementSync` in Bun's `Statement` surface. */
15
+ export declare class Statement<T = unknown, B extends unknown[] = unknown[]> {
16
+ #private;
17
+ constructor(s: StatementSync);
18
+ /** First result row as `T`, or `null` when the query returned no row. */
19
+ get(...params: B): T | null;
20
+ /** All result rows; node returns `[]` when there are none — normalise to that. */
21
+ all(...params: B): T[];
22
+ /** Execute a write statement; returns affected-row and insert info. */
23
+ run(...params: B): {
24
+ changes: number;
25
+ lastInsertRowid: number | bigint;
26
+ };
27
+ /** Lazily iterate over result rows. */
28
+ iterate(...params: B): IterableIterator<T>;
29
+ /** Number of bind parameters in the prepared SQL. */
30
+ get paramsCount(): number;
31
+ /** Column names of the result set (for SELECT statements). */
32
+ get columnNames(): string[];
33
+ /** bun's `finalize()` — node closes statements with the database, so no-op. */
34
+ finalize(): void;
35
+ }
36
+ /** Wrap a node `DatabaseSync` in a bun `Database` surface. */
37
+ export declare class Database {
38
+ private readonly s;
39
+ constructor(path: string, opts?: DatabaseOptions);
40
+ /** Compile a prepared statement. */
41
+ prepare<T = unknown, B extends unknown[] = unknown[]>(sql: string): Statement<T, B>;
42
+ /** Execute a SQL string directly (bun `db.run`); no result row set. */
43
+ run(sql: string): void;
44
+ /** Execute one or more SQL statements. */
45
+ exec(sql: string): void;
46
+ /** Run `fn` inside a BEGIN/COMMIT transaction, rolling back on throw. */
47
+ transaction<T extends (...args: any[]) => any>(fn: T): T;
48
+ close(): void;
49
+ }
@@ -0,0 +1,15 @@
1
+ export * from 'fs/promises';
2
+ /** Bun's `node:fs/promises` extension: `exists(path)` → `Promise<boolean>`.
3
+ * Bun swallows every stat error, not just ENOENT — ENAMETOOLONG on a 60k-char
4
+ * path also yields false (probe audit-probes/S15/s15-exists4.ts). */
5
+ export declare function exists(path: string): Promise<boolean>;
6
+ /**
7
+ * Augment the real `node:fs/promises` module type with Bun's `exists` so tsc
8
+ * (which resolves `node:*` builtins through `@types/node`, not via tsconfig
9
+ * `paths`) sees the extension on the bundled module too. At build time the
10
+ * tsdown alias replaces `node:fs/promises` with this shim; at typecheck time
11
+ * this augmentation covers the direct `node:fs/promises` imports.
12
+ */
13
+ declare module 'node:fs/promises' {
14
+ function exists(path: string): Promise<boolean>;
15
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Shared image bridge (拍板#22, 2026-08-28) — the single DSH-facing seam
3
+ * through which the OMP engines (read's restored image path, fetch's URL
4
+ * image path) turn image bytes into model-visible content.
5
+ *
6
+ * DSH's content model has no inline base64 image block: an ImageBlock is
7
+ * exactly `{ type: 'image', attachment: ImageAttachmentRef }`
8
+ * (dsh-llm types). Every image entering the model therefore MUST pass
9
+ * through the host `attachments` service (saveImage → content-addressed
10
+ * normalized master → per-request variants). This module owns:
11
+ *
12
+ * - the extension → media-type table (mirrors official dsh-tool-fs),
13
+ * - the route vision-capability probe (omp flavor: unknown passes, explicit
14
+ * non-image routes soft-refuse to a model-facing metadata text instead of
15
+ * a thrown error — 用户拍板 2026-08-28),
16
+ * - saveImage + AttachmentError → recoverable-message mapping (official
17
+ * read_image's five-branch design, verbatim wording),
18
+ * - the `<path>/<type>/<content>` envelope with originalDimensions
19
+ * coordinate-multiplier advice (official formatImageReadOutput).
20
+ *
21
+ * The OMP layer never imports cordis/dsh packages: engines call these helpers
22
+ * through `ToolSession.getAttachments` and the exec context the adapter
23
+ * hands them, keeping the omp/ copies upstream-shaped.
24
+ */
25
+ export type ImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';
26
+ /** Normalized outcome of one attachment-store commit (official ref shape). */
27
+ export interface SavedImageRef {
28
+ attachmentId: string;
29
+ mediaType: ImageMediaType;
30
+ bytes: number;
31
+ width: number;
32
+ height: number;
33
+ name?: string;
34
+ originalDimensions?: {
35
+ width: number;
36
+ height: number;
37
+ };
38
+ }
39
+ /** Minimal structural view of the host `attachments` service. */
40
+ export interface AttachmentsService {
41
+ imageLimits?: {
42
+ maxImageBytes?: number;
43
+ maxMessageImageBytes?: number;
44
+ maxImagePixels?: number;
45
+ maxImageDimension?: number;
46
+ mediaTypes?: readonly string[];
47
+ };
48
+ saveImage?: (input: {
49
+ data: Uint8Array;
50
+ mediaType: string;
51
+ name?: string;
52
+ }) => Promise<unknown>;
53
+ }
54
+ /** Minimal structural view of the host `llm` service. */
55
+ export interface LlmRouteService {
56
+ resolveModelInfo?: (provider: string, model: string, signal: AbortSignal) => Promise<{
57
+ inputModalities?: readonly string[];
58
+ }>;
59
+ }
60
+ /**
61
+ * Facade the DSH adapter builds over ctx.get('attachments')/ctx.get('llm')
62
+ * plus the calling route, handed to the engines via ToolSession.
63
+ */
64
+ export interface ImageBridge {
65
+ attachments: AttachmentsService | undefined;
66
+ /** 'supported' = route declares image input; 'unsupported' = declares it does not; 'unknown' = not resolvable. */
67
+ routeImageSupport: () => Promise<'supported' | 'unsupported' | 'unknown'>;
68
+ }
69
+ export declare const IMAGE_EXTENSIONS: Readonly<Record<string, ImageMediaType>>;
70
+ export declare function imageMediaTypeForExtension(ext: string): ImageMediaType | undefined;
71
+ /** Admission byte cap: min(source cap, per-message cap) — official formula. */
72
+ export declare function imageByteCap(bridge: ImageBridge, fallback?: number): number;
73
+ /** Commit bytes to the attachment store, mapping AttachmentErrors to the
74
+ * official read_image recoverable messages. `displayPath` is only used for
75
+ * message rendering. Throws Error (not AttachmentError) for model consumption. */
76
+ export declare function saveImageViaBridge(bridge: ImageBridge, input: {
77
+ data: Uint8Array;
78
+ mediaType: ImageMediaType;
79
+ name?: string;
80
+ displayPath: string;
81
+ }): Promise<SavedImageRef>;
82
+ /** Accept either the official branded ref or a plain object from a mock. */
83
+ export declare function normalizeSavedImageRef(ref: unknown): SavedImageRef;
84
+ export declare function formatImageEnvelope(displayPath: string, image: SavedImageRef): string;
85
+ /** Content blocks for one committed image: envelope text + attachment block. */
86
+ export declare function imageContentBlocks(displayPath: string, image: SavedImageRef): Array<{
87
+ type: 'text';
88
+ text: string;
89
+ } | {
90
+ type: 'image';
91
+ attachment: SavedImageRef;
92
+ }>;
93
+ export declare function formatImageUnsupportedNote(displayPath: string, metadata: {
94
+ mimeType?: string;
95
+ width?: number;
96
+ height?: number;
97
+ bytes?: number;
98
+ } | undefined, reason: string): string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * OMP prompt.md → DSH tool description 适配层(verbatim md 不动,适配在此)。
3
+ *
4
+ * OMP 的 prompts/tools/*.md 用 Handlebars 条件渲染,DSH 的 defineTool
5
+ * description 是静态字符串,这里提供:
6
+ * - `renderOmpPrompt`:完全委托 OMP 自家引擎(@oh-my-pi/pi-utils 的
7
+ * prompt.render = 结构化 Handlebars 解析 + post-render format 后处理,
8
+ * 与上游 read.ts 渲染工具描述同一条管线)。按「移植绝不允许第二套实现」
9
+ * (notebook T10-1 同类教训):自写 regex 渲染器已删除——其全文懒匹配
10
+ * 会跨条件边界吞并并在真值分支残留孤立 `{{/if}}`(2026-08-28 tools:sdk
11
+ * "malformed prompt variable" 事故根源)。strict:false → 未传变量按 falsy
12
+ * 取 else 分支;畸形模板 compile 期抛错(注册期 fail-loud)。
13
+ * - `sanitizeOmpPrompt`:按工具剔除 DSH 不适用的 OMP 提法(内部协议
14
+ * artifact:// ssh:// memory:// xd://、browser、scout/Task 子代理、inspect_image),
15
+ * 全部剔除点记录在 step.md「提示词接入」节;md 源文件保持 verbatim 不变。
16
+ */
17
+ export interface OmpPromptVars {
18
+ /** read 输出是否带 [PATH#TAG] hashline 锚点头(= edit.mode === 'hashline') */
19
+ IS_HL_MODE?: boolean;
20
+ /** DSH 无 inspect_image 工具:read.md 图片条件句恒渲染 else 分支(引擎内部
21
+ * #renderDescription 用),DSH 面再经 sanitizeReadPrompt 改写为附件提交语义
22
+ * (拍板#22:图片经 attachments 入库,非 vision 路由降级 metadata 文本)。 */
23
+ INSPECT_IMAGE_ENABLED?: boolean;
24
+ /** DSH 无 OMP Task/scout 子代理,恒 false → 相关句在 sanitize 中整体剔除,无需变量 */
25
+ scoutAvailable?: boolean;
26
+ }
27
+ /** 渲染 {{#if KEY}}A{{else}}B{{/if}} 与 {{#if KEY}}A{{/if}}——委托 OMP 引擎
28
+ * (@oh-my-pi/pi-utils prompt.render,strict:false:未传变量按 falsy 取 else
29
+ * 分支;畸形模板 compile 期抛错,注册期 fail-loud)。保留首尾 trim 对齐
30
+ * 既有调用点行为。 */
31
+ export declare function renderOmpPrompt(text: string, vars: OmpPromptVars): string;
32
+ /** grep.md:internal URLs 提法 + scout 句剔除。 */
33
+ export declare function sanitizeGrepPrompt(text: string): string;
34
+ /** glob.md:internal URL/memory:// 提法 + scout avoid 句剔除。 */
35
+ export declare function sanitizeGlobPrompt(text: string): string;
36
+ /** read.md:browser 提法剔除 + 图片句改为 DSH 实际行为(拍板#22 附件提交)+ internal URIs 段删除({{#if}} 由 renderer 处理)。 */
37
+ export declare function sanitizeReadPrompt(text: string): string;
38
+ /** ast-edit.md:xd://resolve 预演确认协议已随内部路由删除;DSH 为预览后自动落盘(拍板#14)。 */
39
+ export declare function sanitizeAstEditPrompt(text: string): string;
40
+ /** ast-grep.md:scout 句剔除。 */
41
+ export declare function sanitizeAstGrepPrompt(text: string): string;
42
+ /** write.md / patch.md / apply-patch.md / replace.md / hashline prompt.md:无 DSH 不适用提法。 */
43
+ export declare function sanitizeWritePrompt(text: string): string;
44
+ export declare function sanitizePatchPrompt(text: string): string;
45
+ export declare function sanitizeApplyPatchPrompt(text: string): string;
46
+ export declare function sanitizeReplacePrompt(text: string): string;
47
+ export declare function sanitizeHashlinePrompt(text: string): string;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Per-call sandbox policy resolution for DSH file mutations (方案A, 2026-08-27).
3
+ *
4
+ * Mirrors the official `@deepseek-ai/dsh-tool-fs` FsSandboxController semantics:
5
+ * the mounted `ctx.fs` reports `sandboxMode` (the capability fact — undefined
6
+ * means no confining backend, mutations go unfenced); when a confining backend
7
+ * is mounted, the shared `sandboxPolicy` service resolves the SESSION's
8
+ * standing mode + workspace root into the per-call policy that
9
+ * `ctx.fs.writeText` / `ctx.fs.editText` take as their final argument.
10
+ *
11
+ * Differences from the official controller (deliberate, adapter-scoped):
12
+ * - No escalation advertisement: OMP-native tool schemas carry no
13
+ * `sandbox_permissions`/`justification` fields, so nothing is advertised
14
+ * and `FS_SANDBOX_DENIED` surfaces as the provider's own error text.
15
+ * - Degradation instead of fail-fast: if `ctx.sandboxPolicy` is missing in a
16
+ * composition (host builds always pair it with a confining `ctx.fs`; test
17
+ * doubles may not), the policy resolves to `undefined` and the mutation
18
+ * falls back to the deployment default — never crash registration.
19
+ */
20
+ /** Minimal structural type of the policy object produced by `sandboxPolicy.resolve`.
21
+ * `mode` mirrors the host's closed `SandboxMode` vocabulary
22
+ * (read-only / workspace-write / danger-full-access) so the object is
23
+ * structurally assignable to `SandboxExecutionPolicy` without importing the
24
+ * host-internal type. */
25
+ export type SandboxPolicyMode = 'read-only' | 'workspace-write' | 'danger-full-access';
26
+ export interface SandboxPolicyLike {
27
+ mode: SandboxPolicyMode;
28
+ /** Required: the host SandboxExecutionPolicy always carries the workspace
29
+ * root (session cwd, or the deployment fallback root). */
30
+ workspaceRoot: string;
31
+ }
32
+ /**
33
+ * Resolve the per-call mutation policy for the given exec context, or
34
+ * `undefined` when the mounted filesystem does not confine (or the policy
35
+ * service is unavailable). Pass the result as the final argument of
36
+ * `ctx.fs.writeText` / `ctx.fs.editText`.
37
+ */
38
+ export declare function resolveSandboxPolicy(ctx: any, exec: any): SandboxPolicyLike | undefined;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * OMP 引擎 session 级状态(跨工具调用保持)。
3
+ *
4
+ * OMP 的 read/write/edit 引擎把冲突注册表(ConflictHistory)、native 编辑存储
5
+ * (EditStore:hashline 快照 / 寄存器 / no-op 守卫)等挂在 ToolSession 对象上,
6
+ * 同一 agent 会话内跨工具调用共享。DSH 适配层
7
+ * 每次 execute 都新建 ToolSession,导致这些状态丢失(T11-2:read 注册的
8
+ * 冲突 id 在 write 时找不到)。本模块按 DSH Session 对象
9
+ * (exec.agent.session)持久化这些状态:WeakMap 键控,session 销毁自动
10
+ * 回收,无泄漏。
11
+ *
12
+ * 用法(适配层):
13
+ * 1. execute 开始时 `attachOmpSessionState(session, exec?.agent?.session)`
14
+ * 把上次调用保存的状态挂到新建的 ToolSession 上;
15
+ * 2. execute 结束后 `persistOmpSessionState(exec?.agent?.session, session)`
16
+ * 把引擎惰性新建/更新的状态写回共享存储。
17
+ *
18
+ * 类型说明:read/write 各自 verbatim 拷贝了一份 conflict-detect.ts,两个
19
+ * ConflictHistory class 因 `#nextId` 私有字段互不兼容(名义类型)。本模块
20
+ * 只搬运状态、不调用其方法,故用 `unknown` 宽松承载,避免跨拷贝类型耦合。
21
+ */
22
+ export interface OmpSessionState {
23
+ /** 冲突注册表(read 注册 / write 消费)。 */
24
+ conflictHistory?: unknown;
25
+ /**
26
+ * native 编辑存储 `EditStore`(read 锚点 / edit seen-lines 校验 / 锚点漂移恢复 /
27
+ * CUT-PUT 寄存器 / no-op 循环守卫;A-4 桥接,与 conflictHistory 对称:
28
+ * attach/persist round-trip)。
29
+ */
30
+ editStore?: unknown;
31
+ }
32
+ /** 取(或惰性建)某个 DSH session 的 OMP 状态。 */
33
+ export declare function getOmpSessionState(sessionKey: object): OmpSessionState;
34
+ /**
35
+ * 把共享状态挂到新建的 ToolSession 上(execute 开始时调用)。
36
+ * 无 sessionKey(无会话上下文)时跳过——状态不跨调用保持。
37
+ */
38
+ export declare function attachOmpSessionState(session: {
39
+ conflictHistory?: unknown;
40
+ editStore?: unknown;
41
+ }, sessionKey: object | undefined): void;
42
+ /**
43
+ * 把 ToolSession 上引擎新建/更新的状态写回共享存储(execute 结束后调用)。
44
+ * OMP 引擎会惰性新建 ConflictHistory / EditStore 并赋到 session
45
+ * 对象上(如 read.ts 经 getFileSnapshotStore 挂快照库),必须回写才能被
46
+ * 下一次调用恢复。
47
+ */
48
+ export declare function persistOmpSessionState(sessionKey: object | undefined, session: {
49
+ conflictHistory?: unknown;
50
+ editStore?: unknown;
51
+ }): void;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Standardized error types for tool execution.
3
+ *
4
+ * Tools should throw these instead of returning error text.
5
+ * The agent loop catches and renders them appropriately.
6
+ */
7
+ /**
8
+ * Base error for tool execution failures.
9
+ * Override render() for custom LLM-facing formatting.
10
+ */
11
+ export declare class ToolError extends Error {
12
+ readonly context?: Record<string, unknown> | undefined;
13
+ constructor(message: string, context?: Record<string, unknown> | undefined);
14
+ /** Render error for LLM consumption. Override for custom formatting. */
15
+ render(): string;
16
+ }
17
+ /**
18
+ * Error thrown when a tool operation is aborted (e.g., via AbortSignal).
19
+ */
20
+ export declare class ToolAbortError extends Error {
21
+ static readonly MESSAGE = "Operation aborted";
22
+ constructor(message?: string, options?: ErrorOptions);
23
+ }
24
+ /**
25
+ * Throw ToolAbortError if the signal is aborted.
26
+ * Use this instead of signal?.throwIfAborted() to get consistent error types.
27
+ */
28
+ export declare function throwIfAborted(signal?: AbortSignal): void;
29
+ /**
30
+ * Render an error for LLM consumption.
31
+ * Handles ToolError.render() and falls back to message/string.
32
+ */
33
+ export declare function renderError(e: unknown): string;
@@ -0,0 +1,16 @@
1
+ export type ProbeResult = 'exists' | 'missing' | 'unknown';
2
+ /**
3
+ * probe 判定纯函数(供单测直接覆盖修正分支)。
4
+ *
5
+ * @param lstatOk lstat 是否成功
6
+ * @param openOk open 验证是否成功(仅 needsOpenVerify 时有意义)
7
+ * @param needsOpenVerify 是否需要对含冒号的 Windows 路径做 open 验证
8
+ */
9
+ export declare function resolveProbeResult(lstatOk: boolean, openOk: boolean, needsOpenVerify: boolean): ProbeResult;
10
+ /** Windows NTFS ADS 感知的 probe:lstat 成功但 open 失败 → "missing"。 */
11
+ export declare function probeLiteralPathExists(filePath: string, cwd: string): Promise<ProbeResult>;
12
+ /** 字面优先于选择器拆分(修正版 probe)。 */
13
+ export declare function splitPathAndSelPreferringLiteral(rawPath: string, cwd: string): Promise<{
14
+ path: string;
15
+ sel?: string;
16
+ }>;