@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.
- package/lib/index.mjs +11 -9
- package/lib/{scrapers-D8oWspgW.mjs → scrapers-CtQrQ5kG.mjs} +1 -1
- package/lib/types/client/BashPlusCard.d.ts +53 -0
- package/lib/types/client/ToolPlusSection.d.ts +36 -0
- package/lib/types/client/forms.d.ts +42 -0
- package/lib/types/client/index.d.ts +29 -0
- package/lib/types/client/locales.d.ts +19 -0
- package/lib/types/client/rm-safe-status-text.d.ts +15 -0
- package/lib/types/client/rows.d.ts +107 -0
- package/lib/types/client/web-connection-rpc.d.ts +22 -0
- package/lib/types/config/fields.d.ts +85 -0
- package/lib/types/config/omp-settings.d.ts +21 -0
- package/lib/types/config/settings.d.ts +212 -0
- package/lib/types/config/truncate.d.ts +27 -0
- package/lib/types/host/browser-probe-rpc.d.ts +29 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/tools/ast-edit/adapter/index.d.ts +26 -0
- package/lib/types/tools/ast-edit/adapter/sdk.d.ts +49 -0
- package/lib/types/tools/ast-grep/adapter/index.d.ts +31 -0
- package/lib/types/tools/ast-grep/adapter/sdk.d.ts +44 -0
- package/lib/types/tools/bash/adapter/spill.d.ts +34 -0
- package/lib/types/tools/bash/background.d.ts +40 -0
- package/lib/types/tools/bash/bash-executor.d.ts +102 -0
- package/lib/types/tools/bash/bash-interceptor.d.ts +33 -0
- package/lib/types/tools/bash/cd-workdir.d.ts +35 -0
- package/lib/types/tools/bash/logger.d.ts +18 -0
- package/lib/types/tools/bash/non-interactive-env.d.ts +5 -0
- package/lib/types/tools/bash/render.d.ts +46 -0
- package/lib/types/tools/bash/rm-safe-status.d.ts +62 -0
- package/lib/types/tools/bash/rm-safe.d.ts +18 -0
- package/lib/types/tools/bash/sanitize-text.d.ts +34 -0
- package/lib/types/tools/bash/shell-snapshot.d.ts +31 -0
- package/lib/types/tools/bash/shell-tokenize.d.ts +60 -0
- package/lib/types/tools/bash/streaming-output.d.ts +32 -0
- package/lib/types/tools/bash/trash-cli-main.d.ts +1 -0
- package/lib/types/tools/bash/trash-cli.d.ts +77 -0
- package/lib/types/tools/bash/types.d.ts +107 -0
- package/lib/types/tools/bash/which.d.ts +20 -0
- package/lib/types/tools/bash/windows-shell.d.ts +31 -0
- package/lib/types/tools/bash/yield.d.ts +71 -0
- package/lib/types/tools/edit/adapter/index.d.ts +57 -0
- package/lib/types/tools/edit/adapter/tools/auto-generated-guard.d.ts +10 -0
- package/lib/types/tools/edit/adapter/tools/output-meta.d.ts +34 -0
- package/lib/types/tools/edit/adapter/tools/plan-mode-guard.d.ts +21 -0
- package/lib/types/tools/glob/adapter/index.d.ts +52 -0
- package/lib/types/tools/grep/adapter/index.d.ts +53 -0
- package/lib/types/tools/grep/adapter/match-path.d.ts +1 -0
- package/lib/types/tools/hashline/native/diff-preview.d.ts +37 -0
- package/lib/types/tools/hashline/native/index.d.ts +109 -0
- package/lib/types/tools/hashline/native/normalize.d.ts +29 -0
- package/lib/types/tools/hashline/native/policy.d.ts +98 -0
- package/lib/types/tools/hashline/native/writer.d.ts +42 -0
- package/lib/types/tools/omp/browser/launch.d.ts +28 -0
- package/lib/types/tools/omp/browser/readable.d.ts +17 -0
- package/lib/types/tools/omp/config/settings-schema.d.ts +12 -0
- package/lib/types/tools/omp/config/settings.d.ts +59 -0
- package/lib/types/tools/omp/edit/apply-patch/parser.d.ts +34 -0
- package/lib/types/tools/omp/edit/details.d.ts +54 -0
- package/lib/types/tools/omp/edit/diff.d.ts +60 -0
- package/lib/types/tools/omp/edit/dispatch.d.ts +43 -0
- package/lib/types/tools/omp/edit/file-snapshot-store.d.ts +81 -0
- package/lib/types/tools/omp/edit/hashline/execute.d.ts +40 -0
- package/lib/types/tools/omp/edit/hashline/params.d.ts +6 -0
- package/lib/types/tools/omp/edit/modes/apply-patch.d.ts +25 -0
- package/lib/types/tools/omp/edit/modes/patch.d.ts +109 -0
- package/lib/types/tools/omp/edit/modes/replace.d.ts +151 -0
- package/lib/types/tools/omp/edit/normalize.d.ts +31 -0
- package/lib/types/tools/omp/edit/notebook.d.ts +50 -0
- package/lib/types/tools/omp/edit/read-file.d.ts +2 -0
- package/lib/types/tools/omp/edit/snapshot-details.d.ts +33 -0
- package/lib/types/tools/omp/extensibility/skills.d.ts +22 -0
- package/lib/types/tools/omp/internal-urls/index.d.ts +100 -0
- package/lib/types/tools/omp/internal-urls/local-protocol.d.ts +12 -0
- package/lib/types/tools/omp/internal-urls/parse.d.ts +31 -0
- package/lib/types/tools/omp/internal-urls/types.d.ts +189 -0
- package/lib/types/tools/omp/internal-urls/xd-protocol.d.ts +19 -0
- package/lib/types/tools/omp/markit/converters/docx.d.ts +6 -0
- package/lib/types/tools/omp/markit/converters/epub.d.ts +15 -0
- package/lib/types/tools/omp/markit/converters/pdf/index.d.ts +7 -0
- package/lib/types/tools/omp/markit/converters/pptx.d.ts +57 -0
- package/lib/types/tools/omp/markit/converters/xlsx.d.ts +25 -0
- package/lib/types/tools/omp/markit/index.d.ts +2 -0
- package/lib/types/tools/omp/markit/registry.d.ts +16 -0
- package/lib/types/tools/omp/markit/types.d.ts +30 -0
- package/lib/types/tools/omp/sdk.d.ts +103 -0
- package/lib/types/tools/omp/session/agent-storage.d.ts +154 -0
- package/lib/types/tools/omp/session/streaming-output.d.ts +244 -0
- package/lib/types/tools/omp/task/spawn-policy.d.ts +22 -0
- package/lib/types/tools/omp/tools/approval.d.ts +62 -0
- package/lib/types/tools/omp/tools/ast-edit.d.ts +73 -0
- package/lib/types/tools/omp/tools/ast-grep.d.ts +61 -0
- package/lib/types/tools/omp/tools/auto-generated-guard.d.ts +20 -0
- package/lib/types/tools/omp/tools/conflict-detect.d.ts +237 -0
- package/lib/types/tools/omp/tools/fetch.d.ts +103 -0
- package/lib/types/tools/omp/tools/file-recorder.d.ts +13 -0
- package/lib/types/tools/omp/tools/fs-cache-invalidation.d.ts +15 -0
- package/lib/types/tools/omp/tools/glob.d.ts +86 -0
- package/lib/types/tools/omp/tools/grep.d.ts +102 -0
- package/lib/types/tools/omp/tools/grouped-file-output.d.ts +70 -0
- package/lib/types/tools/omp/tools/index.d.ts +23 -0
- package/lib/types/tools/omp/tools/list-limit.d.ts +12 -0
- package/lib/types/tools/omp/tools/match-line-format.d.ts +11 -0
- package/lib/types/tools/omp/tools/output-meta.d.ts +160 -0
- package/lib/types/tools/omp/tools/path-utils.d.ts +326 -0
- package/lib/types/tools/omp/tools/plan-mode-guard.d.ts +33 -0
- package/lib/types/tools/omp/tools/read-archive.d.ts +16 -0
- package/lib/types/tools/omp/tools/read-format.d.ts +104 -0
- package/lib/types/tools/omp/tools/read-path-resolution.d.ts +19 -0
- package/lib/types/tools/omp/tools/read-selector.d.ts +27 -0
- package/lib/types/tools/omp/tools/read-sqlite.d.ts +16 -0
- package/lib/types/tools/omp/tools/read-summary.d.ts +15 -0
- package/lib/types/tools/omp/tools/read.d.ts +70 -0
- package/lib/types/tools/omp/tools/render-utils.d.ts +28 -0
- package/lib/types/tools/omp/tools/report-tool-issue.d.ts +149 -0
- package/lib/types/tools/omp/tools/resolve.d.ts +127 -0
- package/lib/types/tools/omp/tools/sqlite-reader.d.ts +114 -0
- package/lib/types/tools/omp/tools/tool-errors.d.ts +33 -0
- package/lib/types/tools/omp/tools/tool-result.d.ts +33 -0
- package/lib/types/tools/omp/tools/tool-timeouts.d.ts +57 -0
- package/lib/types/tools/omp/tools/write.d.ts +53 -0
- package/lib/types/tools/omp/tools/writethrough.d.ts +24 -0
- package/lib/types/tools/omp/utils/block-context.d.ts +35 -0
- package/lib/types/tools/omp/utils/cpuprofile.d.ts +51 -0
- package/lib/types/tools/omp/utils/edit-mode.d.ts +13 -0
- package/lib/types/tools/omp/utils/file-display-mode.d.ts +27 -0
- package/lib/types/tools/omp/utils/image-loading.d.ts +51 -0
- package/lib/types/tools/omp/utils/image-resize.d.ts +42 -0
- package/lib/types/tools/omp/utils/lang-from-path.d.ts +9 -0
- package/lib/types/tools/omp/utils/markit-cache.d.ts +23 -0
- package/lib/types/tools/omp/utils/markit.d.ts +30 -0
- package/lib/types/tools/omp/utils/profile-tree.d.ts +47 -0
- package/lib/types/tools/omp/utils/sample-profile.d.ts +67 -0
- package/lib/types/tools/omp/utils/sixel.d.ts +21 -0
- package/lib/types/tools/omp/utils/tools-manager.d.ts +11 -0
- package/lib/types/tools/omp/utils/turndown.d.ts +15 -0
- package/lib/types/tools/omp/utils/zip.d.ts +129 -0
- package/lib/types/tools/omp/web/browser-render.d.ts +50 -0
- package/lib/types/tools/omp/web/parallel.d.ts +68 -0
- package/lib/types/tools/omp/web/scrapers/artifacthub.d.ts +6 -0
- package/lib/types/tools/omp/web/scrapers/arxiv.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/aur.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/biorxiv.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/bluesky.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/brew.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/cheatsh.d.ts +8 -0
- package/lib/types/tools/omp/web/scrapers/chocolatey.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/choosealicense.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/cisa-kev.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/clojars.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/coingecko.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/crates-io.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/crossref.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/devto.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/discogs.d.ts +8 -0
- package/lib/types/tools/omp/web/scrapers/discourse.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/dockerhub.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/docs-rs.d.ts +9 -0
- package/lib/types/tools/omp/web/scrapers/fdroid.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/firefox-addons.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/flathub.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/github-gist.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/github.d.ts +34 -0
- package/lib/types/tools/omp/web/scrapers/gitlab.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/go-pkg.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/hackage.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/hackernews.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/hex.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/huggingface.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/iacr.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/index.d.ts +84 -0
- package/lib/types/tools/omp/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/lemmy.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/lobsters.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/mastodon.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/maven.d.ts +6 -0
- package/lib/types/tools/omp/web/scrapers/mdn.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/metacpan.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/musicbrainz.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/npm.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/nuget.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/nvd.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/ollama.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/open-vsx.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/opencorporates.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/openlibrary.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/orcid.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/osv.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/packagist.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/pub-dev.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/pubmed.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/pypi.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/rawg.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/readthedocs.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/reddit.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/repology.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/rfc.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/rubygems.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/searchcode.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/sec-edgar.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/semantic-scholar.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/snapcraft.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/sourcegraph.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/spdx.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/spotify.d.ts +8 -0
- package/lib/types/tools/omp/web/scrapers/stackoverflow.d.ts +6 -0
- package/lib/types/tools/omp/web/scrapers/terraform.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/tldr.d.ts +7 -0
- package/lib/types/tools/omp/web/scrapers/twitter.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/types.d.ts +90 -0
- package/lib/types/tools/omp/web/scrapers/utils.d.ts +26 -0
- package/lib/types/tools/omp/web/scrapers/vimeo.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/w3c.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/wikidata.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/wikipedia.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/youtube.d.ts +5 -0
- package/lib/types/tools/omp/web/search/providers/utils.d.ts +49 -0
- package/lib/types/tools/omp/web/search/types.d.ts +501 -0
- package/lib/types/tools/omp/web/search/utils.d.ts +4 -0
- package/lib/types/tools/omp/workspace-tree.d.ts +42 -0
- package/lib/types/tools/read/adapter/index.d.ts +49 -0
- package/lib/types/tools/read/adapter/internal-urls/artifact-protocol.d.ts +15 -0
- package/lib/types/tools/read/adapter/internal-urls/registry-helpers.d.ts +44 -0
- package/lib/types/tools/read/adapter/registry/agent-registry.d.ts +29 -0
- package/lib/types/tools/shared/auto-generated-guard.dsh.d.ts +16 -0
- package/lib/types/tools/shared/browser-detect.d.ts +54 -0
- package/lib/types/tools/shared/browser-rpc-channel.d.ts +40 -0
- package/lib/types/tools/shared/bun-ffi-shim.d.ts +13 -0
- package/lib/types/tools/shared/bun-named-shim.d.ts +42 -0
- package/lib/types/tools/shared/bun-shim.d.ts +138 -0
- package/lib/types/tools/shared/bun-sqlite-shim.d.ts +49 -0
- package/lib/types/tools/shared/fs-promises-shim.d.ts +15 -0
- package/lib/types/tools/shared/image-bridge.d.ts +98 -0
- package/lib/types/tools/shared/omp-prompt.d.ts +47 -0
- package/lib/types/tools/shared/sandbox-policy.d.ts +38 -0
- package/lib/types/tools/shared/session-state.d.ts +51 -0
- package/lib/types/tools/shared/tool-errors.d.ts +33 -0
- package/lib/types/tools/shared/win-path-fixes.d.ts +16 -0
- package/lib/types/tools/write/adapter/index.d.ts +31 -0
- package/lib/{utils-CCfhUQen.mjs → utils-ECAwvaPQ.mjs} +1 -1
- package/package.json +2 -2
- package/presets/package.json +1 -1
- package/scripts/patch-pi-natives.mjs +108 -108
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser and renderer for V8 `.cpuprofile` files (emitted by `node --cpu-prof`,
|
|
3
|
+
* `bun --cpu-prof`, Chrome DevTools, and the CDP `Profiler` domain).
|
|
4
|
+
*
|
|
5
|
+
* The raw file is a JSON blob with a flat node table and up to millions of
|
|
6
|
+
* sample/timestamp entries — useless to read directly. `renderCpuProfile`
|
|
7
|
+
* converts it into a compact bottleneck summary:
|
|
8
|
+
*
|
|
9
|
+
* - the hot-path call tree, pruned to frames with meaningful self time,
|
|
10
|
+
* with pass-through chains collapsed and direct recursion flattened
|
|
11
|
+
* - `(idle)` time excluded from on-CPU totals
|
|
12
|
+
* - a profile-wide "top functions by self time" table
|
|
13
|
+
*
|
|
14
|
+
* Consumed by the read tool: `*.cpuprofile` reads show the summary, `:raw`
|
|
15
|
+
* returns the original JSON.
|
|
16
|
+
*/
|
|
17
|
+
/** Matches paths the read tool should treat as V8 CPU profiles. */
|
|
18
|
+
export declare function isCpuProfilePath(filePath: string): boolean;
|
|
19
|
+
/** Call-site metadata of one profile node. `lineNumber` is 0-based. */
|
|
20
|
+
export interface CpuProfileCallFrame {
|
|
21
|
+
functionName: string;
|
|
22
|
+
url?: string;
|
|
23
|
+
lineNumber?: number;
|
|
24
|
+
}
|
|
25
|
+
/** One node in the flat profile tree; `children` are node ids. */
|
|
26
|
+
export interface CpuProfileNode {
|
|
27
|
+
id: number;
|
|
28
|
+
callFrame: CpuProfileCallFrame;
|
|
29
|
+
hitCount?: number;
|
|
30
|
+
children?: number[];
|
|
31
|
+
}
|
|
32
|
+
/** Parsed V8 CPU profile. `startTime`/`endTime`/`timeDeltas` are microseconds. */
|
|
33
|
+
export interface CpuProfile {
|
|
34
|
+
nodes: CpuProfileNode[];
|
|
35
|
+
startTime: number;
|
|
36
|
+
endTime: number;
|
|
37
|
+
samples?: number[];
|
|
38
|
+
timeDeltas?: number[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parse a `.cpuprofile` JSON blob. Accepts both the bare profile and the CDP
|
|
42
|
+
* `Profiler.stop` result shape (`{ profile: {...} }`). Returns null when the
|
|
43
|
+
* text is not a structurally valid V8 CPU profile.
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseCpuProfile(text: string): CpuProfile | null;
|
|
46
|
+
/**
|
|
47
|
+
* Render a V8 CPU profile as an agent-friendly bottleneck summary.
|
|
48
|
+
* Returns null when `text` is not a CPU profile (caller falls back to the
|
|
49
|
+
* plain-text path).
|
|
50
|
+
*/
|
|
51
|
+
export declare function renderCpuProfile(text: string): string | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type EditMode = "replace" | "patch" | "hashline" | "apply_patch";
|
|
2
|
+
export declare const DEFAULT_EDIT_MODE: EditMode;
|
|
3
|
+
export declare const EDIT_MODES: EditMode[];
|
|
4
|
+
export declare function normalizeEditMode(mode?: string | null): EditMode | undefined;
|
|
5
|
+
export interface EditModeSettingsLike {
|
|
6
|
+
get(key: "edit.mode"): unknown;
|
|
7
|
+
getEditVariantForModel?(model: string | undefined): EditMode | null;
|
|
8
|
+
}
|
|
9
|
+
export interface EditModeSessionLike {
|
|
10
|
+
settings: EditModeSettingsLike;
|
|
11
|
+
getActiveModelString?: () => string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveEditMode(session: EditModeSessionLike): EditMode;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve line-display mode for file-like outputs (read, grep, @file mentions).
|
|
3
|
+
*/
|
|
4
|
+
export interface FileDisplayMode {
|
|
5
|
+
lineNumbers: boolean;
|
|
6
|
+
hashLines: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Session-like object providing settings and tool availability for display mode resolution. */
|
|
9
|
+
export interface FileDisplayModeSession {
|
|
10
|
+
/** Whether the edit tool is available. Hashlines are suppressed without it. */
|
|
11
|
+
hasEditTool?: boolean;
|
|
12
|
+
settings: {
|
|
13
|
+
get(key: "readLineNumbers" | "edit.mode"): unknown;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Computes effective line display mode from session settings/env.
|
|
18
|
+
* Hashline mode takes precedence and implies line-addressed output everywhere.
|
|
19
|
+
* Hashlines are suppressed when the edit tool is not available (e.g. scout agents),
|
|
20
|
+
* when the caller signals a `raw` read, and when the source is `immutable`
|
|
21
|
+
* (e.g. internal URLs like artifact://, agent://, memory:// — there is no edit
|
|
22
|
+
* path that could consume the anchors). Raw output is returned as-is.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveFileDisplayMode(session: FileDisplayModeSession, options?: {
|
|
25
|
+
raw?: boolean;
|
|
26
|
+
immutable?: boolean;
|
|
27
|
+
}): FileDisplayMode;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ImageContent, Model } from "@oh-my-pi/pi-ai";
|
|
2
|
+
import { type ImageResizeOptions } from "./image-resize";
|
|
3
|
+
/**
|
|
4
|
+
* Ollama and its local-backend family decode image input through llama.cpp /
|
|
5
|
+
* `stb_image`, which is compiled without WebP support, so a WebP upload fails
|
|
6
|
+
* with an opaque HTTP 400. Detect those models so the resize pipeline encodes
|
|
7
|
+
* to PNG/JPEG instead — the automatic equivalent of `OMP_NO_WEBP=1`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function modelLacksWebpSupport(model: Pick<Model, "provider" | "api" | "imageInputDecoder"> | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* `true` when `model` cannot decode WebP, otherwise `undefined` so the
|
|
12
|
+
* `OMP_NO_WEBP` env fallback in {@link resizeImage} still applies. Feed straight
|
|
13
|
+
* into {@link ImageResizeOptions.excludeWebP}.
|
|
14
|
+
*/
|
|
15
|
+
export declare function webpExclusionForModel(model: Pick<Model, "provider" | "api"> | undefined): true | undefined;
|
|
16
|
+
export declare const MAX_IMAGE_INPUT_BYTES: number;
|
|
17
|
+
export declare const SUPPORTED_INPUT_IMAGE_MIME_TYPES: Set<string>;
|
|
18
|
+
export interface LoadImageInputOptions {
|
|
19
|
+
path: string;
|
|
20
|
+
cwd: string;
|
|
21
|
+
autoResize: boolean;
|
|
22
|
+
maxBytes?: number;
|
|
23
|
+
resolvedPath?: string;
|
|
24
|
+
detectedMimeType?: string;
|
|
25
|
+
/** Force non-WebP output (e.g. for Ollama). Leave unset to honor `OMP_NO_WEBP`. */
|
|
26
|
+
excludeWebP?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* DSH extension (拍板#22 config expansion): resize-knob passthrough onto
|
|
29
|
+
* {@link resizeImage}. Upstream never passes these — it relies on the
|
|
30
|
+
* hardcoded 1568px/500KB/200px/quality-80 defaults; the tool-plus config
|
|
31
|
+
* panel wires user-tunable values through here. Unset = upstream behavior.
|
|
32
|
+
*/
|
|
33
|
+
resize?: ImageResizeOptions;
|
|
34
|
+
}
|
|
35
|
+
export interface LoadedImageInput {
|
|
36
|
+
resolvedPath: string;
|
|
37
|
+
mimeType: string;
|
|
38
|
+
data: string;
|
|
39
|
+
textNote: string;
|
|
40
|
+
dimensionNote?: string;
|
|
41
|
+
bytes: number;
|
|
42
|
+
}
|
|
43
|
+
export declare class ImageInputTooLargeError extends Error {
|
|
44
|
+
readonly bytes: number;
|
|
45
|
+
readonly maxBytes: number;
|
|
46
|
+
constructor(bytes: number, maxBytes: number);
|
|
47
|
+
}
|
|
48
|
+
/** Converts an image to PNG, rejecting when the runtime cannot decode or encode it. */
|
|
49
|
+
export declare function convertImageToPng(image: ImageContent): Promise<ImageContent>;
|
|
50
|
+
export declare function ensureSupportedImageInput(image: ImageContent): Promise<ImageContent | null>;
|
|
51
|
+
export declare function loadImageInput(options: LoadImageInputOptions): Promise<LoadedImageInput | null>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ImageContent } from "@oh-my-pi/pi-ai";
|
|
2
|
+
export interface ImageResizeOptions {
|
|
3
|
+
maxWidth?: number;
|
|
4
|
+
maxHeight?: number;
|
|
5
|
+
/** Smallest allowed edge length (px). Inputs below this are scaled up. */
|
|
6
|
+
minDimension?: number;
|
|
7
|
+
maxBytes?: number;
|
|
8
|
+
jpegQuality?: number;
|
|
9
|
+
excludeWebP?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ResizedImage {
|
|
12
|
+
buffer: Uint8Array;
|
|
13
|
+
mimeType: string;
|
|
14
|
+
originalWidth: number;
|
|
15
|
+
originalHeight: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
wasResized: boolean;
|
|
19
|
+
decodeFailed?: boolean;
|
|
20
|
+
get data(): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resize and recompress an image to fit within the specified max dimensions and file size.
|
|
24
|
+
*
|
|
25
|
+
* Strategy:
|
|
26
|
+
* 1. Probe metadata. If already within all limits, return original.
|
|
27
|
+
* 2. Resize to fit max dimensions and encode at high quality across PNG/JPEG (+ WebP) — return smallest.
|
|
28
|
+
* 3. If still too large, walk a lossy JPEG/WebP quality ladder.
|
|
29
|
+
* 4. If still too large, walk a dimension-scale ladder × quality ladder.
|
|
30
|
+
* 5. If still too large, return the smallest variant produced.
|
|
31
|
+
*
|
|
32
|
+
* Set OMP_NO_WEBP to exclude WebP from encoding (llama.cpp STB doesn't decode it).
|
|
33
|
+
*
|
|
34
|
+
* Backed by `Bun.Image`: a chainable native pipeline that runs decode/transform/encode
|
|
35
|
+
* off the JS thread when the terminal (`.bytes()`) is awaited.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resizeImage(img: ImageContent, options?: ImageResizeOptions): Promise<ResizedImage>;
|
|
38
|
+
/**
|
|
39
|
+
* Format a dimension note for resized images.
|
|
40
|
+
* This helps the model understand the coordinate mapping.
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatDimensionNote(result: ResizedImage): string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language id for syntax highlighting and UI (icons, read tool), or undefined if unknown.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getLanguageFromPath(filePath: string): string | undefined;
|
|
5
|
+
export declare function isMarkdownPath(filePath: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* LSP language identifier; falls back to `plaintext`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectLanguageId(filePath: string): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache schema/format revision. Bumping it changes the on-disk key prefix
|
|
3
|
+
* (`v<N>-...`), so old entries become unreachable and are pruned naturally.
|
|
4
|
+
* Bump when the cache *file* shape changes (entry JSON layout, key scheme).
|
|
5
|
+
*
|
|
6
|
+
* Converter *output* changes are handled separately: the package version is
|
|
7
|
+
* folded into the key (see {@link markitConversionCacheKey}), so any release
|
|
8
|
+
* that ships new markdown from `src/markit/converters/*` auto-invalidates the
|
|
9
|
+
* cache without a manual bump here.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MARKIT_CONVERSION_CACHE_VERSION = 1;
|
|
12
|
+
export declare const MAX_MARKIT_CONVERSION_CACHE_BYTES: number;
|
|
13
|
+
export type MarkitConversionCacheStatus = "hit" | "miss" | "skipped";
|
|
14
|
+
export type MarkitConversionCacheReadResult = {
|
|
15
|
+
status: "hit";
|
|
16
|
+
content: string;
|
|
17
|
+
} | {
|
|
18
|
+
status: "miss";
|
|
19
|
+
};
|
|
20
|
+
export declare function markitConversionCacheKey(bytes: Uint8Array, extension: string): string;
|
|
21
|
+
export declare function readMarkitConversionCache(key: string): Promise<MarkitConversionCacheReadResult>;
|
|
22
|
+
export declare function pruneMarkitConversionCache(cacheDir: string): Promise<void>;
|
|
23
|
+
export declare function writeMarkitConversionCache(key: string, content: string): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type MarkitConversionCacheStatus } from "./markit-cache";
|
|
2
|
+
/**
|
|
3
|
+
* File extensions markit can actually convert to markdown — one per registered
|
|
4
|
+
* converter in `src/markit/registry.ts` (pdf, docx, pptx, xlsx, epub). This is
|
|
5
|
+
* the single source of truth shared by the read, fetch, and CLI file tools so
|
|
6
|
+
* the advertised set never drifts from the converters that back it. Legacy
|
|
7
|
+
* binary formats (`.doc`, `.ppt`, `.xls`, `.rtf`) are intentionally absent:
|
|
8
|
+
* markit has no converter for them, so routing them here only produced an
|
|
9
|
+
* `Unsupported format` error instead of letting them fall through to the
|
|
10
|
+
* binary-file handling.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CONVERTIBLE_EXTENSIONS: ReadonlySet<string>;
|
|
13
|
+
export interface MarkitConversionResult {
|
|
14
|
+
content: string;
|
|
15
|
+
ok: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
cache?: MarkitConversionCacheStatus;
|
|
18
|
+
}
|
|
19
|
+
export interface MarkitFileConversionOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Directory converters may use for extracted image or diagram files. Since
|
|
22
|
+
* those files are conversion side effects, conversions using this option
|
|
23
|
+
* bypass the markdown cache.
|
|
24
|
+
*/
|
|
25
|
+
imageDir?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function convertFileWithMarkit(filePath: string, signal?: AbortSignal, options?: MarkitFileConversionOptions): Promise<MarkitConversionResult>;
|
|
28
|
+
export declare function convertBufferWithMarkit(buffer: Uint8Array, extension: string, signal?: AbortSignal, options?: {
|
|
29
|
+
useCache?: boolean;
|
|
30
|
+
}): Promise<MarkitConversionResult>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared display-tree machinery for profile summaries (macOS `sample` reports,
|
|
3
|
+
* V8 `.cpuprofile` files). Callers build {@link ProfileNode} trees with a
|
|
4
|
+
* domain-specific metric (on-CPU samples, self microseconds, …); this module
|
|
5
|
+
* merges same-key siblings, flattens direct recursion, collapses pass-through
|
|
6
|
+
* chains, and renders the pruned hot-path tree.
|
|
7
|
+
*/
|
|
8
|
+
/** Display node: merged, recursion-flattened mirror of a profile subtree. */
|
|
9
|
+
export interface ProfileNode {
|
|
10
|
+
/** Merge/recursion identity (demangled symbol, function@call-site, …). */
|
|
11
|
+
key: string;
|
|
12
|
+
/** Human-readable label; recursion and truncation decorations are applied at render time. */
|
|
13
|
+
label: string;
|
|
14
|
+
/** Inclusive metric for this subtree (on-CPU samples, self µs, …); drives pruning and display. */
|
|
15
|
+
value: number;
|
|
16
|
+
/** Levels of direct recursion flattened into this node. */
|
|
17
|
+
recursion: number;
|
|
18
|
+
children: ProfileNode[];
|
|
19
|
+
}
|
|
20
|
+
/** Merge `b` into `a` (same key), combining values and child lists. */
|
|
21
|
+
export declare function mergeInto(a: ProfileNode, b: ProfileNode): void;
|
|
22
|
+
/**
|
|
23
|
+
* Flatten direct recursion: children carrying the node's own key are dissolved
|
|
24
|
+
* into it (their children promoted and merged), so a 15-deep recursive spine
|
|
25
|
+
* renders as one annotated node.
|
|
26
|
+
*/
|
|
27
|
+
export declare function flattenRecursion(node: ProfileNode): void;
|
|
28
|
+
/** `n` as a percentage of `total`, one decimal (`"12.3%"`); `"0%"` when total is empty. */
|
|
29
|
+
export declare function formatPct(n: number, total: number): string;
|
|
30
|
+
/** Options for {@link renderProfileNode}. */
|
|
31
|
+
export interface RenderTreeContext {
|
|
32
|
+
out: string[];
|
|
33
|
+
/** Denominator for percentage annotations. */
|
|
34
|
+
total: number;
|
|
35
|
+
/** Minimum subtree value a child needs to stay visible. */
|
|
36
|
+
minValue: number;
|
|
37
|
+
/** Format a metric value for the left column. */
|
|
38
|
+
formatValue: (value: number) => string;
|
|
39
|
+
/** Left-column width (characters) for formatted values. */
|
|
40
|
+
valueWidth: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Render one hot-path subtree: pass-through chains (single kept child, no own
|
|
44
|
+
* contribution above `minValue`) collapse into a single `a › b › c` line, and
|
|
45
|
+
* children below `minValue` are pruned.
|
|
46
|
+
*/
|
|
47
|
+
export declare function renderProfileNode(node: ProfileNode, indent: number, ctx: RenderTreeContext): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser and renderer for macOS `/usr/bin/sample` call-tree reports
|
|
3
|
+
* (conventionally saved as `*.sample.txt`).
|
|
4
|
+
*
|
|
5
|
+
* The raw report is a 10k+ line ASCII call tree with mangled symbols —
|
|
6
|
+
* expensive for an agent to digest. `renderSampleProfile` converts it into a
|
|
7
|
+
* compact bottleneck summary:
|
|
8
|
+
*
|
|
9
|
+
* - per-thread hot paths, pruned to frames with meaningful on-CPU samples,
|
|
10
|
+
* with pass-through chains collapsed and direct recursion flattened
|
|
11
|
+
* - blocked/idle threads reduced to a one-line classification
|
|
12
|
+
* - a process-wide "top functions by self samples" table
|
|
13
|
+
* - Rust v0 and legacy symbols demangled (best-effort, path extraction)
|
|
14
|
+
*
|
|
15
|
+
* Consumed by the read tool: `*.sample.txt` reads show the summary, `:raw`
|
|
16
|
+
* returns the original bytes.
|
|
17
|
+
*/
|
|
18
|
+
/** Matches paths the read tool should treat as macOS sample reports. */
|
|
19
|
+
export declare function isSampleProfilePath(filePath: string): boolean;
|
|
20
|
+
/** One frame in the sampled call tree. Counts are sample hits (subtree total). */
|
|
21
|
+
export interface SampleFrame {
|
|
22
|
+
count: number;
|
|
23
|
+
symbol: string;
|
|
24
|
+
module?: string;
|
|
25
|
+
children: SampleFrame[];
|
|
26
|
+
}
|
|
27
|
+
/** One sampled thread: `Thread_<id>` root plus its call tree. */
|
|
28
|
+
export interface SampleThread {
|
|
29
|
+
id: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
total: number;
|
|
32
|
+
roots: SampleFrame[];
|
|
33
|
+
}
|
|
34
|
+
/** Metadata from the report preamble (everything before `Call graph:`). */
|
|
35
|
+
export interface SampleProfileHeader {
|
|
36
|
+
process: string;
|
|
37
|
+
pid: number;
|
|
38
|
+
intervalMs: number;
|
|
39
|
+
path?: string;
|
|
40
|
+
codeType?: string;
|
|
41
|
+
osVersion?: string;
|
|
42
|
+
footprint?: string;
|
|
43
|
+
footprintPeak?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Parsed macOS sample report. */
|
|
46
|
+
export interface SampleProfile {
|
|
47
|
+
header: SampleProfileHeader;
|
|
48
|
+
threads: SampleThread[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse a macOS `sample` report. Returns null when the text does not look
|
|
52
|
+
* like sample output (missing analysis preamble or `Call graph:` section).
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseSampleProfile(text: string): SampleProfile | null;
|
|
55
|
+
/**
|
|
56
|
+
* Best-effort demangle of Rust symbols (v0 `_R…` and legacy `_ZN…E`).
|
|
57
|
+
* For v0 this is a path extractor, not a full demangler: identifiers are
|
|
58
|
+
* pulled out in order and joined with `::`, so generic arguments appear as
|
|
59
|
+
* extra path segments. Non-Rust symbols pass through unchanged.
|
|
60
|
+
*/
|
|
61
|
+
export declare function demangleSymbol(raw: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Render a macOS sample report as an agent-friendly bottleneck summary.
|
|
64
|
+
* Returns null when `text` is not sample output (caller falls back to the
|
|
65
|
+
* plain-text path).
|
|
66
|
+
*/
|
|
67
|
+
export declare function renderSampleProfile(text: string): string | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether SIXEL passthrough is explicitly enabled.
|
|
3
|
+
*
|
|
4
|
+
* Both gates must be enabled to preserve SIXEL control sequences:
|
|
5
|
+
* - PI_FORCE_IMAGE_PROTOCOL=sixel
|
|
6
|
+
* - PI_ALLOW_SIXEL_PASSTHROUGH=1
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSixelPassthroughEnabled(): boolean;
|
|
9
|
+
/** Returns true when the text contains a SIXEL start sequence. */
|
|
10
|
+
export declare function containsSixelSequence(text: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a boolean mask indicating which lines belong to a SIXEL sequence block.
|
|
13
|
+
* Supports multi-line SIXEL payloads generated by libsixel.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSixelLineMask(lines: string[]): boolean[];
|
|
16
|
+
/** Returns true when the line contains a SIXEL start sequence. */
|
|
17
|
+
export declare function isSixelLine(line: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Sanitizes text while preserving embedded SIXEL sequences when passthrough is enabled.
|
|
20
|
+
*/
|
|
21
|
+
export declare function sanitizeWithOptionalSixelPassthrough(text: string, sanitize: (text: string) => string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ToolName = "sd" | "sg" | "yt-dlp" | "trafilatura";
|
|
2
|
+
export declare function getToolPath(tool: ToolName): string | null;
|
|
3
|
+
/** Download a tool asset without handing the streaming Response to Bun.write. */
|
|
4
|
+
export declare function downloadFile(url: string, dest: string, signal?: AbortSignal): Promise<void>;
|
|
5
|
+
type EnsureToolOptions = {
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
silent?: boolean;
|
|
8
|
+
notify?: (message: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function ensureTool(tool: ToolName, silentOrOptions?: EnsureToolOptions): Promise<string | undefined>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import TurndownService from "@oh-my-pi/pi-utils/turndown";
|
|
2
|
+
/**
|
|
3
|
+
* Build a Turndown instance configured for GFM with the fixes omp relies on:
|
|
4
|
+
* `~~strikethrough~~`, unescaped heading periods, and single-space list markers.
|
|
5
|
+
*
|
|
6
|
+
* Shared by the web scrapers (HTML → markdown) and the markit document engine
|
|
7
|
+
* (`src/markit`). The rule set must stay identical across both call sites.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTurndown(): TurndownService;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize HTML tables so turndown-plugin-gfm can render them:
|
|
12
|
+
* - strip `<p>` tags inside `<td>`/`<th>` cells (joining paragraphs with a space)
|
|
13
|
+
* - wrap the first row in `<thead>` when missing
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeTablesHtml(html: string): string;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/** A ZIP archive decoded to a `path → bytes` map of its file members. */
|
|
2
|
+
export type Unzipped = Record<string, Uint8Array>;
|
|
3
|
+
/** Read a single ZIP entry as UTF-8 text, or `undefined` when the entry is absent. */
|
|
4
|
+
export declare function unzipText(entries: Unzipped, entryPath: string): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Decode an in-memory ZIP archive into a `path → bytes` map of its file members
|
|
7
|
+
* (directory entries and `..`-escaping names are dropped). Shares the
|
|
8
|
+
* central-directory record parser with the lazy, file-backed reader.
|
|
9
|
+
*/
|
|
10
|
+
export declare function unzip(bytes: Uint8Array): Unzipped;
|
|
11
|
+
export type ArchiveFormat = "zip" | "tar" | "tar.gz";
|
|
12
|
+
/**
|
|
13
|
+
* Where to read an archive from: an extension-inferred filesystem path, a
|
|
14
|
+
* format-tagged filesystem path, or in-memory bytes with an explicit format.
|
|
15
|
+
* ZIP paths are read lazily via ranged central-directory access.
|
|
16
|
+
*/
|
|
17
|
+
export type ArchiveSource = string | {
|
|
18
|
+
bytes: Uint8Array;
|
|
19
|
+
format: ArchiveFormat;
|
|
20
|
+
} | {
|
|
21
|
+
path: string;
|
|
22
|
+
format: ArchiveFormat;
|
|
23
|
+
};
|
|
24
|
+
/** Content for a member when packing or extracting an archive. */
|
|
25
|
+
export type ArchiveMemberContent = string | Uint8Array | Blob;
|
|
26
|
+
export interface ArchivePathCandidate {
|
|
27
|
+
archivePath: string;
|
|
28
|
+
subPath: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ArchiveNode {
|
|
31
|
+
path: string;
|
|
32
|
+
isDirectory: boolean;
|
|
33
|
+
size: number;
|
|
34
|
+
mtimeMs?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ArchiveDirectoryEntry extends ArchiveNode {
|
|
37
|
+
name: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ExtractedArchiveFile extends ArchiveNode {
|
|
40
|
+
bytes: Uint8Array;
|
|
41
|
+
}
|
|
42
|
+
/** A byte window into an archive — file-backed (lazy) or in-memory. */
|
|
43
|
+
interface ByteSource {
|
|
44
|
+
readonly size: number;
|
|
45
|
+
read(start: number, end: number): Promise<Uint8Array>;
|
|
46
|
+
}
|
|
47
|
+
interface TarStorage {
|
|
48
|
+
type: "tar";
|
|
49
|
+
buffer: Uint8Array;
|
|
50
|
+
dataOffset: number;
|
|
51
|
+
sparse: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface TarLinkStorage {
|
|
54
|
+
type: "tar-link";
|
|
55
|
+
targetPath: string;
|
|
56
|
+
}
|
|
57
|
+
interface ZipStorage {
|
|
58
|
+
type: "zip";
|
|
59
|
+
source: ByteSource;
|
|
60
|
+
compressedSize: number;
|
|
61
|
+
compression: number;
|
|
62
|
+
flags: number;
|
|
63
|
+
localHeaderOffset: number;
|
|
64
|
+
}
|
|
65
|
+
type EntryStorage = TarStorage | TarLinkStorage | ZipStorage;
|
|
66
|
+
interface ArchiveIndexEntry extends ArchiveNode {
|
|
67
|
+
storage?: EntryStorage;
|
|
68
|
+
}
|
|
69
|
+
/** Infer an archive format from a filesystem path's extension. */
|
|
70
|
+
export declare function archiveFormatFromPath(filePath: string): ArchiveFormat | undefined;
|
|
71
|
+
export declare function formatArchiveEntryLines(entries: readonly ArchiveDirectoryEntry[]): string[];
|
|
72
|
+
export declare function sniffArchiveFormat(bytes: Uint8Array): ArchiveFormat | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Split an `archive.ext:inner/path` reference into every plausible
|
|
75
|
+
* `{ archivePath, subPath }` pair, longest archive prefix first. A path may
|
|
76
|
+
* contain more than one archive extension, so each candidate is a guess at
|
|
77
|
+
* where the archive ends and the member portion begins.
|
|
78
|
+
*/
|
|
79
|
+
export declare function parseArchivePathCandidates(filePath: string): ArchivePathCandidate[];
|
|
80
|
+
/**
|
|
81
|
+
* An indexed, read-only view over a single archive. ZIP archives are indexed
|
|
82
|
+
* from the central directory and members are inflated on demand; tar archives
|
|
83
|
+
* are parsed from one in-memory buffer, members are sliced on demand, and
|
|
84
|
+
* directory symlink aliases are traversed lazily.
|
|
85
|
+
*/
|
|
86
|
+
export declare class ArchiveReader {
|
|
87
|
+
#private;
|
|
88
|
+
readonly format: ArchiveFormat;
|
|
89
|
+
constructor(format: ArchiveFormat, entries: ArchiveIndexEntry[]);
|
|
90
|
+
getNode(subPath?: string): ArchiveNode | undefined;
|
|
91
|
+
listDirectory(subPath?: string): ArchiveDirectoryEntry[];
|
|
92
|
+
readFile(subPath: string): Promise<ExtractedArchiveFile>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Open an archive for reading. ZIP archives opened from a path are indexed
|
|
96
|
+
* lazily via ranged central-directory reads (members inflate on demand); tar
|
|
97
|
+
* archives and in-memory ZIPs are read from a single buffer.
|
|
98
|
+
*/
|
|
99
|
+
export declare function openArchive(source: ArchiveSource): Promise<ArchiveReader>;
|
|
100
|
+
/** Render the top-level entries of an in-memory archive as one line each. */
|
|
101
|
+
export declare function listArchiveRoot(bytes: Uint8Array, format: ArchiveFormat, opts?: {
|
|
102
|
+
limit?: number;
|
|
103
|
+
}): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Fully materialize every file member into a `path → content` map: ZIP members
|
|
106
|
+
* are inflated in memory, tar members are sliced from the decoded archive
|
|
107
|
+
* buffer. Use this when you need every entry (rewrite, extract); for browsing
|
|
108
|
+
* or single-member reads prefer `openArchive`, which is lazy for ZIP.
|
|
109
|
+
*/
|
|
110
|
+
export declare function readArchiveEntries(source: ArchiveSource): Promise<Map<string, ArchiveMemberContent>>;
|
|
111
|
+
/**
|
|
112
|
+
* Serialize `entries` into an archive of `format` and write it to `destPath`.
|
|
113
|
+
* ZIP is framed in memory, tar / tar.gz via `Bun.Archive` (gzip for tar.gz).
|
|
114
|
+
* String members are encoded as UTF-8.
|
|
115
|
+
*/
|
|
116
|
+
export declare function writeArchive(destPath: string, format: ArchiveFormat, entries: Iterable<readonly [string, ArchiveMemberContent]>): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Extract every file member to `destDir`, creating parent directories as
|
|
119
|
+
* needed. Entries that would escape `destDir` (via `..` or an absolute path)
|
|
120
|
+
* are rejected. Returns the number of files written.
|
|
121
|
+
*/
|
|
122
|
+
export declare function extractArchive(source: ArchiveSource, destDir: string): Promise<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Frame a `path → bytes` map into a ZIP archive in memory. Each member is raw
|
|
125
|
+
* DEFLATE unless that would not shrink it, in which case it is stored. ZIP64 is
|
|
126
|
+
* not emitted; archives beyond the 32-bit limits throw rather than corrupt.
|
|
127
|
+
*/
|
|
128
|
+
export declare function zip(entries: Unzipped): Uint8Array;
|
|
129
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser JS rendering for the read URL pipeline — the last reader backend
|
|
3
|
+
* in `FETCH_PROVIDER_ORDER`. Where the other backends fetch the raw HTML and
|
|
4
|
+
* convert it server-side, this one launches a real headless Chromium
|
|
5
|
+
* (puppeteer-core), lets the page's JavaScript run, and extracts readable
|
|
6
|
+
* content from the rendered DOM — which is what SPA pages need.
|
|
7
|
+
*
|
|
8
|
+
* Design (per the 2026-08-29 plan):
|
|
9
|
+
* - Singleton browser: lazily launched on first use, reused across renders,
|
|
10
|
+
* closed after `BROWSER_IDLE_CLOSE_MS` of inactivity, best-effort killed on
|
|
11
|
+
* process exit; a memoized instance found closed (idle recycle / crash) is
|
|
12
|
+
* cleared and relaunched on the next render. A promise queue serializes
|
|
13
|
+
* renders (one page at a time).
|
|
14
|
+
* - Budget: goto ≤ min(overall timeout, 20s), `domcontentloaded` + 800ms JS
|
|
15
|
+
* settle, DOM capped at `BROWSER_RENDER_MAX_BYTES` before extraction.
|
|
16
|
+
* - Failure degenerates to `null` (the fetch chain then moves to the next
|
|
17
|
+
* backend or reports the raw HTML), never throws for "no browser".
|
|
18
|
+
*
|
|
19
|
+
* `resetBrowserForTests` is the test seam for the unit suite.
|
|
20
|
+
* @module @xiaoso/dsh-tool-plus/web/browser-render
|
|
21
|
+
*/
|
|
22
|
+
/** Cap on the rendered DOM handed to the readable extractor. */
|
|
23
|
+
export declare const BROWSER_RENDER_MAX_BYTES: number;
|
|
24
|
+
/** Idle time after which the singleton browser is closed (renders reuse it). */
|
|
25
|
+
export declare const BROWSER_IDLE_CLOSE_MS = 60000;
|
|
26
|
+
/** Extra settle time after `domcontentloaded` for JS-rendered content. */
|
|
27
|
+
export declare const RENDER_SETTLE_MS = 800;
|
|
28
|
+
/**
|
|
29
|
+
* Render a URL in a headless browser and return readable markdown, or null
|
|
30
|
+
* when no browser is available / rendering fails. Serialized through the
|
|
31
|
+
* singleton queue; honors `signal` cancellation between attempts.
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderUrlWithBrowser(url: string, options?: {
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
}): Promise<string | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Test seam: replicate the production idle-close state — the singleton
|
|
39
|
+
* browser is closed but `browserPromise` is left pointing at the dead
|
|
40
|
+
* instance (which is exactly what {@link scheduleIdleClose} does). A render
|
|
41
|
+
* in this state must relaunch rather than fail.
|
|
42
|
+
*/
|
|
43
|
+
export declare function simulateIdleCloseForTests(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Test seam: close the singleton browser (if any) and reset the queue so a
|
|
46
|
+
* later render starts from a clean state. Also clears the launch memo so a
|
|
47
|
+
* subsequent render re-resolves the executable (e.g. after the detection
|
|
48
|
+
* RPC ran).
|
|
49
|
+
*/
|
|
50
|
+
export declare function resetBrowserForTests(): Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type FetchImpl } from "@oh-my-pi/pi-ai";
|
|
2
|
+
import type { AgentStorage } from "../session/agent-storage";
|
|
3
|
+
export declare const PARALLEL_SEARCH_URL = "https://api.parallel.ai/v1beta/search";
|
|
4
|
+
export declare const PARALLEL_BETA_HEADER = "search-extract-2025-10-10";
|
|
5
|
+
export interface ParallelUsageItem {
|
|
6
|
+
name?: string;
|
|
7
|
+
count?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ParallelSearchSource {
|
|
10
|
+
title: string;
|
|
11
|
+
url: string;
|
|
12
|
+
snippet?: string;
|
|
13
|
+
publishedDate?: string;
|
|
14
|
+
excerpts: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface ParallelSearchResult {
|
|
17
|
+
requestId: string;
|
|
18
|
+
sources: ParallelSearchSource[];
|
|
19
|
+
warnings: string[];
|
|
20
|
+
usage: ParallelUsageItem[];
|
|
21
|
+
}
|
|
22
|
+
export interface ParallelExtractDocument {
|
|
23
|
+
url: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
publishedDate?: string;
|
|
26
|
+
excerpts: string[];
|
|
27
|
+
fullContent?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ParallelExtractErrorEntry {
|
|
30
|
+
url: string;
|
|
31
|
+
errorType?: string;
|
|
32
|
+
httpStatusCode?: number;
|
|
33
|
+
content?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ParallelExtractResult {
|
|
36
|
+
requestId: string;
|
|
37
|
+
results: ParallelExtractDocument[];
|
|
38
|
+
errors: ParallelExtractErrorEntry[];
|
|
39
|
+
warnings: string[];
|
|
40
|
+
usage: ParallelUsageItem[];
|
|
41
|
+
}
|
|
42
|
+
export interface ParallelSearchOptions {
|
|
43
|
+
mode?: "fast" | "research";
|
|
44
|
+
maxCharsPerResult?: number;
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
fetch?: FetchImpl;
|
|
47
|
+
}
|
|
48
|
+
export interface ParallelExtractOptions {
|
|
49
|
+
objective?: string;
|
|
50
|
+
searchQueries?: string[];
|
|
51
|
+
excerpts?: boolean;
|
|
52
|
+
fullContent?: boolean;
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
fetch?: FetchImpl;
|
|
55
|
+
}
|
|
56
|
+
export declare class ParallelApiError extends Error {
|
|
57
|
+
readonly statusCode?: number;
|
|
58
|
+
constructor(message: string, statusCode?: number);
|
|
59
|
+
}
|
|
60
|
+
export declare function parseParallelErrorResponse(statusCode: number, responseText: string): ParallelApiError;
|
|
61
|
+
export declare function parseParallelJsonResponse(response: Response, operation: "search" | "extract"): Promise<unknown>;
|
|
62
|
+
export declare function parseParallelSearchPayload(payload: unknown, options?: {
|
|
63
|
+
parseMetadata?: boolean;
|
|
64
|
+
}): ParallelSearchResult;
|
|
65
|
+
export declare function findParallelApiKey(storage: AgentStorage | null | undefined): string | null;
|
|
66
|
+
export declare function getParallelExtractContent(document: ParallelExtractDocument): string;
|
|
67
|
+
export declare function searchWithParallel(objective: string, queries: string[], options: ParallelSearchOptions, storage: AgentStorage | null | undefined): Promise<ParallelSearchResult>;
|
|
68
|
+
export declare function extractWithParallel(urls: string[], options: ParallelExtractOptions, storage: AgentStorage | null | undefined): Promise<ParallelExtractResult>;
|