@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,90 @@
|
|
|
1
|
+
import type { AgentStorage } from "../../session/agent-storage";
|
|
2
|
+
export { formatNumber } from "@oh-my-pi/pi-utils";
|
|
3
|
+
export interface RenderResult {
|
|
4
|
+
url: string;
|
|
5
|
+
finalUrl: string;
|
|
6
|
+
contentType: string;
|
|
7
|
+
method: string;
|
|
8
|
+
content: string;
|
|
9
|
+
fetchedAt: string;
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
notes: string[];
|
|
12
|
+
}
|
|
13
|
+
export type SpecialHandler = (url: string, timeout: number, signal?: AbortSignal, storage?: AgentStorage | null) => Promise<RenderResult | null>;
|
|
14
|
+
export declare const MAX_OUTPUT_CHARS = 500000;
|
|
15
|
+
export declare const MAX_BYTES: number;
|
|
16
|
+
/**
|
|
17
|
+
* Truncate and cleanup output
|
|
18
|
+
*/
|
|
19
|
+
export declare function finalizeOutput(content: string): {
|
|
20
|
+
content: string;
|
|
21
|
+
truncated: boolean;
|
|
22
|
+
};
|
|
23
|
+
export interface LoadPageOptions {
|
|
24
|
+
timeout?: number;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
method?: string;
|
|
27
|
+
body?: string;
|
|
28
|
+
maxBytes?: number;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
/**
|
|
31
|
+
* Return true to skip reading the response body for this content type
|
|
32
|
+
* (lowercased mime, no params). The caller is expected to re-fetch the
|
|
33
|
+
* payload as binary; this avoids streaming + decoding huge binaries twice.
|
|
34
|
+
*/
|
|
35
|
+
skipBodyForContentType?: (contentType: string) => boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface LoadPageResult {
|
|
38
|
+
content: string;
|
|
39
|
+
contentType: string;
|
|
40
|
+
finalUrl: string;
|
|
41
|
+
ok: boolean;
|
|
42
|
+
status?: number;
|
|
43
|
+
/** True when the body was cut mid-stream at maxBytes. */
|
|
44
|
+
truncated?: boolean;
|
|
45
|
+
/** Last transport-level error message when ok is false. */
|
|
46
|
+
error?: string;
|
|
47
|
+
/** True when the body read was skipped via skipBodyForContentType. */
|
|
48
|
+
bodySkipped?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fetch a page with timeout and size limit
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadPage(url: string, options?: LoadPageOptions): Promise<LoadPageResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Convert HTML to markdown using Turndown with GFM support.
|
|
56
|
+
* Strips script/style tags before conversion.
|
|
57
|
+
*/
|
|
58
|
+
export declare function htmlToBasicMarkdown(html: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Build a RenderResult from markdown content. Calls finalizeOutput internally.
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildResult(md: string, opts: {
|
|
63
|
+
url: string;
|
|
64
|
+
finalUrl?: string;
|
|
65
|
+
method: string;
|
|
66
|
+
fetchedAt: string;
|
|
67
|
+
notes?: string[];
|
|
68
|
+
contentType?: string;
|
|
69
|
+
}): RenderResult;
|
|
70
|
+
/**
|
|
71
|
+
* Format a date value as YYYY-MM-DD. Returns empty string on invalid input.
|
|
72
|
+
*/
|
|
73
|
+
export declare function formatIsoDate(value?: string | number | Date): string;
|
|
74
|
+
/**
|
|
75
|
+
* Decode common HTML entities.
|
|
76
|
+
*/
|
|
77
|
+
export declare function decodeHtmlEntities(text: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Format seconds into HH:MM:SS or MM:SS.
|
|
80
|
+
*/
|
|
81
|
+
export declare function formatMediaDuration(totalSeconds: number): string;
|
|
82
|
+
/**
|
|
83
|
+
* Extract localized text, preferring en-US/en.
|
|
84
|
+
*/
|
|
85
|
+
export type LocalizedText = string | Record<string, string | null> | null | undefined;
|
|
86
|
+
export declare function getLocalizedText(value: LocalizedText, defaultLocale?: string): string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Check if content looks like HTML by inspecting the leading tag.
|
|
89
|
+
*/
|
|
90
|
+
export declare function looksLikeHtml(content: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isRecord } from "@oh-my-pi/pi-utils";
|
|
2
|
+
export { isRecord };
|
|
3
|
+
export declare function asRecord(value: unknown): Record<string, unknown> | null;
|
|
4
|
+
export declare function asString(value: unknown): string | null;
|
|
5
|
+
export declare function asNumber(value: unknown): number | null;
|
|
6
|
+
export interface BinaryFetchSuccess {
|
|
7
|
+
ok: true;
|
|
8
|
+
buffer: Uint8Array;
|
|
9
|
+
contentDisposition?: string;
|
|
10
|
+
}
|
|
11
|
+
export type BinaryFetchResult = BinaryFetchSuccess | {
|
|
12
|
+
ok: false;
|
|
13
|
+
error?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Fetch binary content from a URL
|
|
17
|
+
*/
|
|
18
|
+
export declare function fetchBinary(url: string, timeout?: number, signal?: AbortSignal): Promise<BinaryFetchResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Convert binary content to markdown using markit.
|
|
21
|
+
*/
|
|
22
|
+
export declare function convertWithMarkit(buffer: Uint8Array, extension: string, timeout?: number, signal?: AbortSignal): Promise<{
|
|
23
|
+
content: string;
|
|
24
|
+
ok: boolean;
|
|
25
|
+
error?: string;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AgentStorage } from "../../../session/agent-storage";
|
|
2
|
+
import { SearchProviderError, type SearchProviderId, type SearchSource } from "../../../web/search/types";
|
|
3
|
+
/**
|
|
4
|
+
* Search for an API credential by checking an env-derived key first,
|
|
5
|
+
* then falling back to agent.db stored credentials for the given providers.
|
|
6
|
+
*
|
|
7
|
+
* The caller MUST supply an open {@link AgentStorage} handle so the helper
|
|
8
|
+
* never reaches out to global filesystem state; both the unified web_search
|
|
9
|
+
* chain and one-shot CLI calls open storage exactly once and thread it
|
|
10
|
+
* through every provider.
|
|
11
|
+
*
|
|
12
|
+
* @param storage - Open agent storage handle
|
|
13
|
+
* @param envKey - Pre-resolved environment variable value (or null)
|
|
14
|
+
* @param storageProviders - Provider names to look up in AgentStorage
|
|
15
|
+
*/
|
|
16
|
+
export declare function findCredential(storage: AgentStorage | null | undefined, envKey: string | null | undefined, ...storageProviders: string[]): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* The 60-second default tolerates legitimate slow LLM-mediated responses
|
|
19
|
+
* (Anthropic web_search_20250305, Perplexity, Gemini, Codex) while bounding
|
|
20
|
+
* Windows stalls when Bun's `AbortSignal` fails to propagate. Callers may
|
|
21
|
+
* configure a longer provider deadline, capped at five minutes by the
|
|
22
|
+
* dispatcher; pure search APIs typically settle far faster.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SEARCH_HARD_TIMEOUT_MS: number;
|
|
25
|
+
/**
|
|
26
|
+
* Compose a caller-supplied {@link AbortSignal} with a hard timeout so an
|
|
27
|
+
* outbound `fetch()` is guaranteed to settle within `ms` even when the
|
|
28
|
+
* runtime fails to propagate cancellation to the underlying transport.
|
|
29
|
+
*
|
|
30
|
+
* Bun's WinHTTP backend on Windows is known to ignore `AbortSignal` once a
|
|
31
|
+
* TCP/TLS connection stalls (oven-sh/bun#15275, oven-sh/bun#18536); without
|
|
32
|
+
* this safety net a stalled web-search request freezes the entire session
|
|
33
|
+
* because the user's Esc is never delivered to the native layer.
|
|
34
|
+
*
|
|
35
|
+
* @param signal - Caller cancellation signal, if any.
|
|
36
|
+
* @param ms - Hard timeout in milliseconds. Defaults to {@link SEARCH_HARD_TIMEOUT_MS}.
|
|
37
|
+
*/
|
|
38
|
+
export declare function withHardTimeout(signal: AbortSignal | undefined, ms?: number): AbortSignal;
|
|
39
|
+
/**
|
|
40
|
+
* Map a provider's raw source list to the unified SearchSource shape,
|
|
41
|
+
* clamped to the requested result count and annotated with ageSeconds.
|
|
42
|
+
*/
|
|
43
|
+
export declare function toSearchSources(sources: ReadonlyArray<{
|
|
44
|
+
title: string;
|
|
45
|
+
url: string;
|
|
46
|
+
snippet?: string;
|
|
47
|
+
publishedDate?: string;
|
|
48
|
+
}>, numResults: number): SearchSource[];
|
|
49
|
+
export declare function classifyProviderHttpError(provider: SearchProviderId, status: number, body: string): SearchProviderError | null;
|