@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,15 @@
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types";
2
+ /** A metadata value: a bare string, or a node carrying `#text` and/or array children. */
3
+ type MetaValue = string | MetaNode;
4
+ interface MetaNode {
5
+ "#text"?: string;
6
+ [index: number]: MetaValue;
7
+ }
8
+ export declare class EpubConverter implements Converter {
9
+ name: string;
10
+ accepts(streamInfo: StreamInfo): boolean;
11
+ convert(input: Buffer, _streamInfo: StreamInfo): Promise<ConversionResult>;
12
+ getText(node: MetaValue | undefined): string | undefined;
13
+ getTextArray(node: MetaValue | undefined): (string | undefined)[];
14
+ }
15
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ConversionResult, Converter, StreamInfo } from "../../types";
2
+ /** Converts PDF buffers to Markdown through the native `pdf-inspector` bridge. */
3
+ export declare class PdfConverter implements Converter {
4
+ name: string;
5
+ accepts(streamInfo: StreamInfo): boolean;
6
+ convert(input: Buffer, _streamInfo: StreamInfo): Promise<ConversionResult>;
7
+ }
@@ -0,0 +1,57 @@
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types";
2
+ /** A text value: bare string/number, or a `{ "#text" }` node when the element carries attributes. */
3
+ type XmlText = string | number | {
4
+ "#text"?: string;
5
+ };
6
+ interface TextRun {
7
+ "a:t"?: XmlText;
8
+ }
9
+ interface Paragraph {
10
+ "a:r"?: TextRun | TextRun[];
11
+ }
12
+ interface TextBody {
13
+ "a:p"?: Paragraph | Paragraph[];
14
+ }
15
+ interface CNvPr {
16
+ "@_name": string;
17
+ }
18
+ interface Placeholder {
19
+ "@_type": string;
20
+ }
21
+ interface NvPr {
22
+ "p:ph"?: Placeholder;
23
+ }
24
+ interface NvSpPr {
25
+ "p:cNvPr"?: CNvPr;
26
+ "p:nvPr"?: NvPr;
27
+ }
28
+ interface Shape {
29
+ "p:txBody"?: TextBody;
30
+ "p:nvSpPr"?: NvSpPr;
31
+ }
32
+ interface TableCell {
33
+ "a:txBody"?: TextBody;
34
+ }
35
+ interface TableRow {
36
+ "a:tc"?: TableCell | TableCell[];
37
+ }
38
+ interface Table {
39
+ "a:tr"?: TableRow | TableRow[];
40
+ }
41
+ interface GraphicData {
42
+ "a:tbl"?: Table;
43
+ }
44
+ interface Graphic {
45
+ "a:graphicData"?: GraphicData;
46
+ }
47
+ interface GraphicFrame {
48
+ "a:graphic"?: Graphic;
49
+ }
50
+ export declare class PptxConverter implements Converter {
51
+ name: string;
52
+ accepts(streamInfo: StreamInfo): boolean;
53
+ convert(input: Buffer, streamInfo: StreamInfo): Promise<ConversionResult>;
54
+ extractText(shape: Shape): string;
55
+ extractTable(gf: GraphicFrame): string | null;
56
+ }
57
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ConversionResult, Converter, StreamInfo } from "../types";
2
+ /** A text value: bare string/number, or a `{ "#text" }` node when the element carries attributes. */
3
+ type XmlText = string | number | {
4
+ "#text"?: string;
5
+ };
6
+ interface RichTextRun {
7
+ t?: XmlText;
8
+ }
9
+ interface StringItem {
10
+ t?: XmlText;
11
+ r?: RichTextRun | RichTextRun[];
12
+ }
13
+ interface Cell {
14
+ "@_t"?: string;
15
+ v?: string | number;
16
+ is?: StringItem;
17
+ }
18
+ export declare class XlsxConverter implements Converter {
19
+ name: string;
20
+ accepts(streamInfo: StreamInfo): boolean;
21
+ convert(input: Buffer, _streamInfo: StreamInfo): Promise<ConversionResult>;
22
+ getCellValue(cell: Cell, shared: StringItem[]): string;
23
+ getSharedString(shared: StringItem[], idx: number): string;
24
+ }
25
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./registry";
2
+ export * from "./types";
@@ -0,0 +1,16 @@
1
+ import type { ConversionResult, MarkitOptions, StreamInfo } from "./types";
2
+ /**
3
+ * In-house document → markdown engine (replaces the `markit-ai` package).
4
+ *
5
+ * Only the document converters omp routes are registered (pdf, docx, pptx,
6
+ * xlsx, epub). The first converter whose `accepts()` returns true and whose
7
+ * `convert()` succeeds wins.
8
+ */
9
+ export declare class Markit {
10
+ #private;
11
+ constructor(options?: MarkitOptions);
12
+ convertFile(filePath: string, extra?: {
13
+ imageDir?: string;
14
+ }): Promise<ConversionResult>;
15
+ convert(input: Buffer, streamInfo: StreamInfo): Promise<ConversionResult>;
16
+ }
@@ -0,0 +1,30 @@
1
+ export interface StreamInfo {
2
+ mimetype?: string;
3
+ extension?: string;
4
+ charset?: string;
5
+ filename?: string;
6
+ localPath?: string;
7
+ url?: string;
8
+ /** Directory to write extracted images/diagrams. */
9
+ imageDir?: string;
10
+ }
11
+ export interface ConversionResult {
12
+ markdown: string;
13
+ title?: string;
14
+ }
15
+ export interface MarkitOptions {
16
+ /** Describe an image, return markdown. Receives raw bytes and mimetype. */
17
+ describe?: (image: Buffer, mimetype: string) => Promise<string>;
18
+ /** Transcribe audio, return text. Receives raw bytes and mimetype. */
19
+ transcribe?: (audio: Buffer, mimetype: string) => Promise<string>;
20
+ /** Extra instructions appended to the image description prompt. */
21
+ prompt?: string;
22
+ }
23
+ export interface Converter {
24
+ /** Human-readable name for error messages. */
25
+ name: string;
26
+ /** Quick check: can this converter handle the given stream? */
27
+ accepts(streamInfo: StreamInfo): boolean;
28
+ /** Convert the source to markdown. */
29
+ convert(input: Buffer, streamInfo: StreamInfo, options?: MarkitOptions): Promise<ConversionResult>;
30
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * DSH adapter for OMP `sdk.ts` — the `ToolSession` interface consumed by the
3
+ * tool-plus engines (read/write/grep/glob/edit).
4
+ *
5
+ * Shared superset: read/write/grep/glob adapter copies declared the members
6
+ * their engine touches; this shared copy keeps the union (read's
7
+ * conflict-history, grep/glob's `getSessionSpawns`, the native edit store).
8
+ * DSH provides a session adapter implementing this interface.
9
+ */
10
+ import type { Settings } from './config/settings.ts';
11
+ import type { Skill } from './extensibility/skills.ts';
12
+ import type { ConflictHistory } from './tools/conflict-detect.ts';
13
+ import type { Model } from '@oh-my-pi/pi-ai';
14
+ declare module '@oh-my-pi/pi-agent-core' {
15
+ interface AgentToolContext {
16
+ hasUI?: boolean;
17
+ toolNames?: string[];
18
+ /** Session settings (cross-module nominal Settings — typed loosely). */
19
+ settings?: any;
20
+ /** Session manager (DSH: none). */
21
+ sessionManager?: {
22
+ saveArtifact: (text: string, toolName: string) => Promise<string | undefined>;
23
+ };
24
+ }
25
+ }
26
+ /**
27
+ * Minimal ToolSession surface used by the OMP engines (verbatim member
28
+ * shapes, shared superset). DSH provides a session adapter implementing
29
+ * this interface.
30
+ */
31
+ export interface ToolSession {
32
+ /** Current working directory */
33
+ cwd: string;
34
+ /** Whether an edit-capable tool is available (controls hashline output) */
35
+ hasEditTool?: boolean;
36
+ /** Session settings (read.* keys; DSH maps them onto tool-plus config). */
37
+ settings: Settings;
38
+ /** Active model string for mode resolution (optional in DSH). */
39
+ getActiveModelString?: () => string | undefined;
40
+ /** Active model object (image-capability checks; optional in DSH). */
41
+ getActiveModel?: () => Model | undefined;
42
+ /**
43
+ * DSH image bridge (拍板#22): attachment store + route vision-capability
44
+ * probe handed to the read/fetch image paths. Optional — engines degrade to
45
+ * a model-facing metadata text when absent.
46
+ */
47
+ imageBridge?: () => import('../shared/image-bridge.ts').ImageBridge | undefined;
48
+ /**
49
+ * Native edit store (created lazily by the engine): the hashline snapshot
50
+ * ring, the `CUT`/`PUT` clipboard registers and the no-op loop guard. Shared
51
+ * by read / search / write / edit through `file-snapshot-store.ts`, and
52
+ * round-tripped across tool calls by `shared/session-state.ts`.
53
+ */
54
+ editStore?: import('../hashline/native/index.ts').EditStore;
55
+ /** Plan-mode state (DSH plan is a hint layer — never enabled). */
56
+ getPlanModeState?: () => {
57
+ enabled: boolean;
58
+ planFilePath: string;
59
+ } | undefined;
60
+ /** Plan reference path (DSH: none). */
61
+ getPlanReferencePath?: () => string | null;
62
+ /** Local protocol options (DSH has no local:// sandbox — optional). */
63
+ localProtocolOptions?: import('./internal-urls/index.ts').LocalProtocolOptions;
64
+ getArtifactsDir?: () => string | null;
65
+ /** Allocate a new artifact path (DSH: none). */
66
+ allocateOutputArtifact?: (toolType: string) => Promise<{
67
+ id?: string;
68
+ path?: string;
69
+ }>;
70
+ getSessionId?: () => string | null;
71
+ /** Session spawn policy (DSH: none — engines fall back to `"*"`). */
72
+ getSessionSpawns?: () => string | boolean | null | undefined;
73
+ /** Fetch implementation for URL reads (DSH: global fetch). */
74
+ fetch?: typeof globalThis.fetch;
75
+ /** Tool-choice queue (resolution devices; DSH: none). */
76
+ getToolChoiceQueue?: () => ToolChoiceQueueLike | undefined;
77
+ /** Plan-proposal handler (resolution devices; DSH: none). */
78
+ peekPlanProposalHandler?: () => PlanProposalHandler | undefined;
79
+ /** Queued/pending invocation peek (resolution devices; DSH: none). */
80
+ peekQueueInvoker?: () => ResolveInvoker | undefined;
81
+ peekPendingInvoker?: () => ResolveInvoker | undefined;
82
+ /** Clear pending invokers (resolution devices; DSH: none). */
83
+ clearPendingInvokers?: () => void;
84
+ /** Whether a built-in tool is active in this turn's tool set. */
85
+ isToolActive?: (name: string) => boolean;
86
+ /** Pre-loaded skills (DSH: none). */
87
+ skills?: readonly Skill[];
88
+ /** Auth storage for search providers (DSH: none). */
89
+ authStorage?: import('@oh-my-pi/pi-ai').AuthStorage;
90
+ /** Conflict history for conflict:// write-back (DSH: absent). */
91
+ conflictHistory?: ConflictHistory;
92
+ }
93
+ /** Tool-choice queue for staged resolution previews (DSH: never present). */
94
+ export interface ToolChoiceQueueLike {
95
+ registerPendingInvoker: (id: string, toolName: string, invoker: ResolveInvoker) => void;
96
+ removePendingInvoker: (id: string) => void;
97
+ }
98
+ /** Plan-proposal approval handler (DSH: never present). */
99
+ export type PlanProposalHandler = (title: string) => Promise<import('@oh-my-pi/pi-agent-core').AgentToolResult<unknown>>;
100
+ /** Staged resolution invocation runner (DSH: never present). */
101
+ export type ResolveInvoker = (invocation: unknown) => Promise<import('@oh-my-pi/pi-agent-core').AgentToolResult<unknown>>;
102
+ /** DSH: no auth storage discovery — search providers have no credentials. */
103
+ export declare function discoverAuthStorage(_agentDir?: string): Promise<import('@oh-my-pi/pi-ai').AuthStorage>;
@@ -0,0 +1,154 @@
1
+ import { type AuthCredential, type AuthCredentialStore, type StoredAuthCredential } from "@oh-my-pi/pi-ai";
2
+ import type { RawSettings as Settings } from "../config/settings";
3
+ /** One completed request's timing, folded into the per-model aggregates. */
4
+ export interface ModelPerfSample {
5
+ /** Output tokens the provider reported for the turn. */
6
+ outputTokens: number;
7
+ /** Total request duration in milliseconds. */
8
+ durationMs: number;
9
+ /** Time to first token in milliseconds; omit when the provider did not report one. */
10
+ ttftMs?: number;
11
+ }
12
+ /** Recency-weighted per-model performance averages. */
13
+ export interface ModelPerfStats {
14
+ /** Decayed sample count backing the averages. */
15
+ samples: number;
16
+ /** Average output tokens/sec over the total request duration. */
17
+ tps: number;
18
+ /** Average time-to-first-token in milliseconds; null when no sample reported one. */
19
+ ttftMs: number | null;
20
+ }
21
+ /** Current agent.db schema version; bump when schema changes require migration. */
22
+ export declare const SCHEMA_VERSION = 6;
23
+ /**
24
+ * Unified SQLite storage for agent settings, model usage, and auth credentials.
25
+ * Delegates auth credential operations to AuthCredentialStore from @oh-my-pi/pi-ai.
26
+ * Uses singleton pattern per database path; access via AgentStorage.open().
27
+ */
28
+ export declare class AgentStorage {
29
+ #private;
30
+ private constructor();
31
+ /**
32
+ * Returns singleton instance for the given database path, creating if needed.
33
+ * Retries on the `SQLITE_BUSY` family (including `SQLITE_BUSY_RECOVERY`) with
34
+ * exponential backoff. See issue #2421.
35
+ * @param dbPath - Path to the SQLite database file (defaults to config path)
36
+ * @returns AgentStorage instance for the given path
37
+ */
38
+ static open(dbPath?: string): Promise<AgentStorage>;
39
+ /** @internal Reset all singletons and close their databases — test-only. */
40
+ static resetInstance(): void;
41
+ /**
42
+ * Reads legacy settings persisted in the agent.db `settings` table.
43
+ * The canonical settings store is `config.yml`; this accessor only
44
+ * exists so the config loader can migrate values from older installs.
45
+ * @returns Settings object, or null if no settings are stored
46
+ */
47
+ getSettings(): Settings | null;
48
+ /**
49
+ * Records model usage, updating the last-used timestamp.
50
+ * @param modelKey - Model key in "provider/modelId" format
51
+ */
52
+ recordModelUsage(modelKey: string): void;
53
+ /**
54
+ * Gets model keys ordered by most recently used.
55
+ * Results are cached until recordModelUsage is called.
56
+ * @returns Array of model keys ("provider/modelId") in MRU order
57
+ */
58
+ getModelUsageOrder(): string[];
59
+ /**
60
+ * Folds one completed request's timing into the model's perf aggregates.
61
+ * TPS is measured over the total request duration — not the post-TTFT
62
+ * decode window, which undercounts generation time (and so inflates the
63
+ * rate) when reasoning tokens are generated before the first visible
64
+ * token. Invalid samples (no tokens, no duration) are dropped.
65
+ *
66
+ * Deferred like prompt history: samples are batched and written in one
67
+ * transaction after {@link MODEL_PERF_FLUSH_DELAY_MS}, keeping SQLite off
68
+ * the turn-completion hot path. Fire-and-forget safe — flush failures are
69
+ * logged, never thrown; await the returned promise only to observe the flush.
70
+ * @param modelKey - Model key in "provider/modelId" format
71
+ */
72
+ recordModelPerf(modelKey: string, sample: ModelPerfSample): Promise<void>;
73
+ /**
74
+ * Returns recency-weighted TPS/TTFT averages for every model with recorded
75
+ * requests, keyed by "provider/modelId". Read by the /models browser.
76
+ * Also kicks the one-time background stats.db import; until it completes,
77
+ * models without live samples are simply absent.
78
+ */
79
+ getModelPerf(): Map<string, ModelPerfStats>;
80
+ /**
81
+ * Imports recent measurable request rows from an `omp stats` database
82
+ * (`messages` table) into the model_perf aggregates. Walks newest-first
83
+ * over the timestamp index in {@link MODEL_PERF_BACKFILL_CHUNK}-row chunks,
84
+ * yielding to the event loop between chunks, and keeps at most
85
+ * {@link MODEL_PERF_DECAY_AT} rows per model within the
86
+ * {@link MODEL_PERF_BACKFILL_MAX_AGE_MS} window — beyond either bound the
87
+ * live decay would erase the contribution anyway. Errored turns are
88
+ * excluded; aborted turns with reported usage count, matching live capture.
89
+ * Sums land in one additive transaction at the end, so concurrent live
90
+ * samples merge correctly regardless of order.
91
+ * @param statsDbPath - Path to a stats.db file; opened read-only
92
+ * @returns Number of rows folded in
93
+ * @throws When the stats db cannot be opened or queried
94
+ */
95
+ backfillModelPerfFromStats(statsDbPath: string): Promise<number>;
96
+ /**
97
+ * Checks if any auth credentials exist in storage.
98
+ * @returns True if at least one credential is stored
99
+ */
100
+ hasAuthCredentials(): boolean;
101
+ /**
102
+ * Returns the underlying {@link AuthCredentialStore} so callers that need
103
+ * the lower-level pi-ai abstraction (e.g. `findAnthropicAuth(store)`) can
104
+ * reuse this storage's open database connection instead of opening their
105
+ * own.
106
+ */
107
+ get authStore(): AuthCredentialStore;
108
+ /**
109
+ * Lists auth credentials, optionally filtered by provider.
110
+ * Only returns active (non-disabled) credentials by default.
111
+ * @param provider - Optional provider name to filter by
112
+ * @param includeDisabled - If true, includes disabled credentials
113
+ * @returns Array of stored credentials with their database IDs
114
+ */
115
+ listAuthCredentials(provider?: string, includeDisabled?: boolean): StoredAuthCredential[];
116
+ /**
117
+ * Atomically replaces all credentials for a provider.
118
+ * Useful for OAuth token refresh where old tokens should be discarded.
119
+ * @param provider - Provider name (e.g., "anthropic", "openai")
120
+ * @param credentials - New credentials to store
121
+ * @returns Array of newly stored credentials with their database IDs
122
+ */
123
+ replaceAuthCredentialsForProvider(provider: string, credentials: AuthCredential[]): StoredAuthCredential[];
124
+ /**
125
+ * Updates an existing auth credential by ID.
126
+ * @param id - Database row ID of the credential to update
127
+ * @param credential - New credential data
128
+ */
129
+ updateAuthCredential(id: number, credential: AuthCredential): void;
130
+ /**
131
+ * Disables an auth credential by ID with a persisted cause.
132
+ * @param id - Database row ID of the credential to disable
133
+ * @param disabledCause - Human-readable cause stored with the disabled row
134
+ */
135
+ deleteAuthCredential(id: number, disabledCause: string): void;
136
+ /**
137
+ * Disables all auth credentials for a provider with a persisted cause.
138
+ * @param provider - Provider name whose credentials should be disabled
139
+ * @param disabledCause - Human-readable cause stored with the disabled rows
140
+ */
141
+ deleteAuthCredentialsForProvider(provider: string, disabledCause: string): void;
142
+ /**
143
+ * Gets a cached value by key. Returns null if not found or expired.
144
+ */
145
+ getCache(key: string): string | null;
146
+ /**
147
+ * Sets a cached value with expiry time (unix seconds).
148
+ */
149
+ setCache(key: string, value: string, expiresAtSec: number): void;
150
+ /**
151
+ * Deletes expired cache entries. Call periodically for cleanup.
152
+ */
153
+ cleanExpiredCache(): void;
154
+ }
@@ -0,0 +1,244 @@
1
+ import type { AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
2
+ export declare const DEFAULT_MAX_LINES = 3000;
3
+ export declare const DEFAULT_MAX_BYTES: number;
4
+ export declare const DEFAULT_MAX_COLUMN = 512;
5
+ /**
6
+ * Default artifact-on-disk cap for {@link OutputSink}.
7
+ *
8
+ * `0` means unbounded: by default, `artifact://<id>` references preserve the
9
+ * complete raw stream instead of a capped head/tail sample.
10
+ */
11
+ export declare const ARTIFACT_DEFAULT_MAX_BYTES = 0;
12
+ /** Default head budget; the remainder becomes the rolling tail window. */
13
+ export declare const ARTIFACT_DEFAULT_HEAD_BYTES: number;
14
+ export interface OutputSummary {
15
+ output: string;
16
+ truncated: boolean;
17
+ totalLines: number;
18
+ totalBytes: number;
19
+ outputLines: number;
20
+ outputBytes: number;
21
+ /** Bytes elided from the middle when head-retain mode is active. */
22
+ elidedBytes?: number;
23
+ /** Lines elided from the middle when head-retain mode is active. */
24
+ elidedLines?: number;
25
+ /** Bytes dropped by the per-line column cap (sum across all lines). */
26
+ columnDroppedBytes?: number;
27
+ /** Number of distinct lines that hit the per-line column cap. */
28
+ columnTruncatedLines?: number;
29
+ /** Configured per-line column cap in effect (chars), when > 0. */
30
+ columnMax?: number;
31
+ /** Artifact ID for internal URL access (artifact://<id>) when truncated */
32
+ artifactId?: string;
33
+ }
34
+ export interface OutputSinkOptions {
35
+ artifactPath?: string;
36
+ artifactId?: string;
37
+ /**
38
+ * Total inline body budget (bytes). Default DEFAULT_MAX_BYTES. The head
39
+ * window and rolling tail window share this budget, so a composed
40
+ * `dump()` body never exceeds it (plus the elision marker).
41
+ */
42
+ spillThreshold?: number;
43
+ /**
44
+ * When > 0, the sink keeps the first `headBytes` of output in addition to
45
+ * the rolling tail window. Output between the two windows is elided
46
+ * (middle elision). Clamped to `spillThreshold / 2` so the tail keeps at
47
+ * least half the inline budget. Default 0 = tail-only behavior.
48
+ */
49
+ headBytes?: number;
50
+ /**
51
+ * Per-line byte cap. When > 0, lines wider than `maxColumns` bytes are
52
+ * truncated with an ellipsis at write time; remaining bytes up to the next
53
+ * `\n` are dropped. Cap state persists across chunks so split-mid-line
54
+ * writes still respect the budget. Default 0 = no per-line cap.
55
+ */
56
+ maxColumns?: number;
57
+ onChunk?: (chunk: string) => void;
58
+ /** Minimum ms between onChunk calls. 0 = every chunk (default). */
59
+ chunkThrottleMs?: number;
60
+ /**
61
+ * Optional cap on bytes written to the artifact-on-disk file. When the cap
62
+ * is hit, the head window is preserved verbatim and subsequent output feeds
63
+ * a rolling tail window; on close, the sink writes a single
64
+ * `[ARTIFACT TRUNCATED: …]` notice between them. Default
65
+ * {@link ARTIFACT_DEFAULT_MAX_BYTES} (unbounded).
66
+ */
67
+ artifactMaxBytes?: number;
68
+ /**
69
+ * Bytes reserved for the head window of the capped artifact file. The
70
+ * tail window receives `artifactMaxBytes - artifactHeadBytes`. Default
71
+ * {@link ARTIFACT_DEFAULT_HEAD_BYTES}; clamped to `[0, artifactMaxBytes]`.
72
+ */
73
+ artifactHeadBytes?: number;
74
+ }
75
+ export interface TruncationResult {
76
+ content: string;
77
+ truncated?: boolean;
78
+ truncatedBy?: "lines" | "bytes" | "middle";
79
+ totalLines: number;
80
+ totalBytes: number;
81
+ outputLines?: number;
82
+ outputBytes?: number;
83
+ /** Bytes elided from the middle (truncateMiddle only). */
84
+ elidedBytes?: number;
85
+ /** Lines elided from the middle (truncateMiddle only). */
86
+ elidedLines?: number;
87
+ lastLinePartial?: boolean;
88
+ firstLineExceedsLimit?: boolean;
89
+ }
90
+ export interface TruncationOptions {
91
+ /** Maximum number of lines (default: 3000) */
92
+ maxLines?: number;
93
+ /** Maximum number of bytes (default: 50KB) */
94
+ maxBytes?: number;
95
+ /**
96
+ * For `truncateMiddle`: bytes reserved for the head window. The tail
97
+ * window receives `maxBytes - maxHeadBytes`. Default `floor(maxBytes/2)`.
98
+ */
99
+ maxHeadBytes?: number;
100
+ /**
101
+ * For `truncateMiddle`: lines reserved for the head window. The tail
102
+ * window receives `maxLines - maxHeadLines`. Default `floor(maxLines/2)`.
103
+ */
104
+ maxHeadLines?: number;
105
+ }
106
+ /** Result from byte-level truncation helpers. */
107
+ export interface ByteTruncationResult {
108
+ text: string;
109
+ bytes: number;
110
+ }
111
+ export interface TailTruncationNoticeOptions {
112
+ fullOutputPath?: string;
113
+ originalContent?: string;
114
+ suffix?: string;
115
+ }
116
+ export interface HeadTruncationNoticeOptions {
117
+ startLine?: number;
118
+ totalFileLines?: number;
119
+ }
120
+ /**
121
+ * Truncate a string/buffer to fit within a byte limit, keeping the tail.
122
+ * Handles multi-byte UTF-8 boundaries correctly.
123
+ */
124
+ export declare function truncateTailBytes(data: string | Uint8Array, maxBytes: number): ByteTruncationResult;
125
+ /**
126
+ * Truncate a string/buffer to fit within a byte limit, keeping the head.
127
+ * Handles multi-byte UTF-8 boundaries correctly.
128
+ */
129
+ export declare function truncateHeadBytes(data: string | Uint8Array, maxBytes: number): ByteTruncationResult;
130
+ /**
131
+ * Truncate a single line to max characters, appending '…' if truncated.
132
+ */
133
+ export declare function truncateLine(line: string, maxChars?: number): {
134
+ text: string;
135
+ wasTruncated: boolean;
136
+ };
137
+ /** Shared helper to build a no-truncation result. */
138
+ export declare function noTruncResult(content: string, totalLines?: number, totalBytes?: number): TruncationResult;
139
+ /**
140
+ * Truncate content from the head (keep first N lines/bytes).
141
+ * Never returns partial lines. If the first line exceeds the byte limit,
142
+ * returns empty content with firstLineExceedsLimit=true.
143
+ *
144
+ * This implementation avoids Buffer.from(content) for the whole input.
145
+ * It only computes UTF-8 byteLength for candidate lines that can still fit.
146
+ */
147
+ export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
148
+ /**
149
+ * Truncate content from the tail (keep last N lines/bytes).
150
+ * May return a partial first line if the last line exceeds the byte limit.
151
+ *
152
+ * Also avoids Buffer.from(content) for the whole input.
153
+ */
154
+ export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
155
+ /**
156
+ * Format the inline marker substituted for the elided middle region.
157
+ * Returned without surrounding newlines so callers can position it freely.
158
+ */
159
+ export declare function formatMiddleElisionMarker(elidedLines: number, elidedBytes: number): string;
160
+ /**
161
+ * Truncate content keeping a head window and a tail window, eliding the middle.
162
+ *
163
+ * The combined output is `<head>\n<marker>\n<tail>` when truncation is needed.
164
+ * `maxHeadBytes` defaults to `floor(maxBytes / 2)`; the tail receives the
165
+ * remainder. Falls back to `truncateTail` / `truncateHead` if either side's
166
+ * budget is empty or the content already fits.
167
+ */
168
+ export declare function truncateMiddle(content: string, options?: TruncationOptions): TruncationResult;
169
+ /** Options for {@link enforceInlineByteCap}. */
170
+ export interface InlineByteCapOptions {
171
+ /** Inline byte budget. Defaults to {@link DEFAULT_MAX_BYTES}. */
172
+ maxBytes?: number;
173
+ /**
174
+ * Persist the full text as a session artifact. When an artifact id is
175
+ * returned, a `[raw output: artifact://<id>]` footer is appended so the
176
+ * elided bytes stay recoverable.
177
+ */
178
+ saveArtifact?: (full: string) => string | undefined | Promise<string | undefined>;
179
+ }
180
+ /**
181
+ * Final-defense inline size guard for tool results.
182
+ *
183
+ * No-op when `text` fits within `maxBytes` (the common path). Otherwise keeps
184
+ * ~60% of the budget from the head and ~25% from the tail — cut on line
185
+ * boundaries, never splitting a multi-byte UTF-8 sequence — with an elision
186
+ * marker between. The remaining ~15% is slack for the marker and the optional
187
+ * `[raw output: artifact://<id>]` footer, so the result stays under `maxBytes`.
188
+ */
189
+ export declare function enforceInlineByteCap(text: string, options: InlineByteCapOptions): Promise<string>;
190
+ export declare class TailBuffer {
191
+ #private;
192
+ readonly maxBytes: number;
193
+ constructor(maxBytes: number);
194
+ append(text: string): void;
195
+ text(): string;
196
+ bytes(): number;
197
+ }
198
+ export declare class OutputSink {
199
+ #private;
200
+ constructor(options?: OutputSinkOptions);
201
+ /**
202
+ * Push a chunk of output. The buffer management and onChunk callback run
203
+ * synchronously. File sink writes are deferred and serialized internally.
204
+ */
205
+ push(chunk: string): void;
206
+ createInput(): WritableStream<Uint8Array | string>;
207
+ /**
208
+ * Replace the in-memory buffer with the given text. Used when an upstream
209
+ * minimizer rewrites the captured output after the raw bytes have already
210
+ * been streamed.
211
+ *
212
+ * After this call the buffer is authoritative: streaming counters realign
213
+ * to the replacement, the retained head window is cleared, and head
214
+ * retention is disabled so subsequent `push()` calls append directly to the
215
+ * tail buffer instead of repopulating the (now meaningless) head window
216
+ * — which would otherwise reorder content and trip the middle-elision
217
+ * branch in `dump()` against stale totals.
218
+ */
219
+ replace(text: string): void;
220
+ dump(notice?: string): Promise<OutputSummary>;
221
+ /**
222
+ * Release the artifact spill descriptor on an exit path that skips
223
+ * {@link dump} — a thrown error or abort. Idempotent and safe in a
224
+ * `finally`: if {@link dump} already ran this is a no-op, otherwise it
225
+ * flushes the capped tail and closes the sink so the descriptor is not
226
+ * leaked until a later unrelated read hits `EMFILE` (issue #6463).
227
+ */
228
+ dispose(): Promise<void>;
229
+ }
230
+ /**
231
+ * Format a truncation notice for tail-truncated output (bash, python, ssh).
232
+ * Returns empty string if not truncated.
233
+ */
234
+ export declare function formatTailTruncationNotice(truncation: TruncationResult, options?: TailTruncationNoticeOptions): string;
235
+ /**
236
+ * Format a truncation notice for head-truncated output (read tool).
237
+ * Returns empty string if not truncated.
238
+ */
239
+ export declare function formatHeadTruncationNotice(truncation: TruncationResult, options?: HeadTruncationNoticeOptions): string;
240
+ /**
241
+ * Build an onChunk handler that appends to a TailBuffer and emits a streaming
242
+ * update (when `onUpdate` is defined) with the buffer's current text.
243
+ */
244
+ export declare function streamTailUpdates<TDetails, TInput = unknown>(tailBuffer: TailBuffer, onUpdate: AgentToolUpdateCallback<TDetails, TInput> | undefined): (chunk: string) => void;