@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,22 @@
|
|
|
1
|
+
/** Default agent used when a session has unrestricted spawning. */
|
|
2
|
+
export declare const DEFAULT_SPAWN_AGENT = "task";
|
|
3
|
+
/** Spawn policy derived from a parent agent's `spawns` frontmatter. */
|
|
4
|
+
export interface ResolvedSpawnPolicy {
|
|
5
|
+
/** True when at least one subagent may be spawned. */
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
/** Agent used when the caller omits the agent field. */
|
|
8
|
+
defaultAgent: string;
|
|
9
|
+
/** Explicitly allowed agents, or `null` when the policy is unrestricted. */
|
|
10
|
+
allowedAgents: readonly string[] | null;
|
|
11
|
+
/** Text used in spawn rejection messages. */
|
|
12
|
+
allowedErrorText: string;
|
|
13
|
+
/** Backtick-quoted explicit agents for prompt descriptions. */
|
|
14
|
+
allowedPromptText?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Resolves spawn frontmatter into the default and prompt/error surfaces. */
|
|
17
|
+
export declare function resolveSpawnPolicy(parentSpawns: string | boolean | null | undefined): ResolvedSpawnPolicy;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the `scout` agent is spawnable in a session: not disabled via
|
|
20
|
+
* `task.disabledAgents`, and permitted by the session spawn policy.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isScoutSpawnable(disabledAgents: readonly string[] | undefined, spawns: string | boolean | null | undefined): boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool approval resolution.
|
|
3
|
+
*
|
|
4
|
+
* Approval policy is declared by each tool. This module only knows how to:
|
|
5
|
+
* - normalize user `tools.approval.<tool>: allow | deny | prompt` overrides,
|
|
6
|
+
* - compare a tool capability tier against the active approval mode,
|
|
7
|
+
* - format the generic approval prompt body.
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentTool, ToolTier } from "@oh-my-pi/pi-agent-core";
|
|
10
|
+
export type { ToolApproval, ToolApprovalDecision, ToolTier } from "@oh-my-pi/pi-agent-core";
|
|
11
|
+
export type ApprovalPolicy = "allow" | "deny" | "prompt";
|
|
12
|
+
export type ApprovalMode = "always-ask" | "write" | "yolo";
|
|
13
|
+
type ApprovalSubject = Pick<AgentTool, "name" | "approval" | "formatApprovalDetails">;
|
|
14
|
+
export interface ResolvedApproval {
|
|
15
|
+
policy: ApprovalPolicy;
|
|
16
|
+
tier: ToolTier;
|
|
17
|
+
reason?: string;
|
|
18
|
+
override: boolean;
|
|
19
|
+
source?: "tool" | "user" | "mode";
|
|
20
|
+
/** User-policy key that produced `source: "user"` (defaults to the tool name). */
|
|
21
|
+
policyKey?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Evaluate a tool's own approval declaration against `args` and return the
|
|
25
|
+
* resulting capability tier, defaulting to `exec` when the tool omits an
|
|
26
|
+
* approval. Unlike reading `tool.approval` directly, this runs function-valued
|
|
27
|
+
* approvals — the write tool's `xd://` gate uses it to take a mounted device's
|
|
28
|
+
* argument-dependent tier instead of falling back to `exec`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveToolTier(tool: ApprovalSubject, args: unknown): ToolTier;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve approval policy for a tool call.
|
|
33
|
+
*
|
|
34
|
+
* Resolution order:
|
|
35
|
+
* 1. Tool `approval(args)` decision, defaulting to tier "exec" when omitted.
|
|
36
|
+
* A decision may carry a `policyKey` — `tools.approval.<policyKey>` is then
|
|
37
|
+
* the user override consulted instead of `tools.approval.<tool.name>`, with
|
|
38
|
+
* the invoking tool's own policy as the fallback when the user set none for
|
|
39
|
+
* the keyed sub-tool (e.g. an `xd://` device dispatch without a device
|
|
40
|
+
* policy still honors `tools.approval.write`).
|
|
41
|
+
* 2. User per-tool override, if set and valid.
|
|
42
|
+
* 3. Active mode tier comparison.
|
|
43
|
+
*
|
|
44
|
+
* In yolo mode, override-based tool prompts are ignored; user `tools.approval`
|
|
45
|
+
* settings remain authoritative.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveApproval(tool: ApprovalSubject, args: unknown, mode: ApprovalMode, userConfig?: Record<string, unknown>): ResolvedApproval;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a tool call requires user approval.
|
|
50
|
+
*
|
|
51
|
+
* @throws Error if policy is 'deny'
|
|
52
|
+
* @returns Object with required flag and optional reason for the prompt
|
|
53
|
+
*/
|
|
54
|
+
export declare function requiresApproval(tool: ApprovalSubject, args: unknown, mode: ApprovalMode, userConfig?: Record<string, unknown>): {
|
|
55
|
+
required: boolean;
|
|
56
|
+
reason?: string;
|
|
57
|
+
};
|
|
58
|
+
export declare function truncateForPrompt(value: string, maxChars?: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* Format the approval prompt body shown to the user.
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatApprovalPrompt(tool: ApprovalSubject, args: unknown, reason?: string): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolExample } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { ToolSession } from "../sdk";
|
|
4
|
+
import type { OutputMeta } from "../../omp/tools/output-meta.ts";
|
|
5
|
+
declare const astEditSchema: import("@oh-my-pi/omptype").FluentType<{
|
|
6
|
+
paths: string[];
|
|
7
|
+
ops: {
|
|
8
|
+
out: string;
|
|
9
|
+
pat: string;
|
|
10
|
+
}[];
|
|
11
|
+
}, {
|
|
12
|
+
paths: string[];
|
|
13
|
+
ops: {
|
|
14
|
+
out: string;
|
|
15
|
+
pat: string;
|
|
16
|
+
}[];
|
|
17
|
+
}>;
|
|
18
|
+
export interface AstEditToolDetails {
|
|
19
|
+
totalReplacements: number;
|
|
20
|
+
filesTouched: number;
|
|
21
|
+
filesSearched: number;
|
|
22
|
+
applied: boolean;
|
|
23
|
+
limitReached: boolean;
|
|
24
|
+
parseErrors?: string[];
|
|
25
|
+
/** Total parse error count before {@link PARSE_ERRORS_LIMIT} capping. Omitted when no errors. */
|
|
26
|
+
parseErrorsTotal?: number;
|
|
27
|
+
scopePath?: string;
|
|
28
|
+
files?: string[];
|
|
29
|
+
fileReplacements?: Array<{
|
|
30
|
+
path: string;
|
|
31
|
+
count: number;
|
|
32
|
+
}>;
|
|
33
|
+
meta?: OutputMeta;
|
|
34
|
+
/** Pre-formatted text for the user-visible TUI render. Mirrors `result.text` lines but uses
|
|
35
|
+
* a `│` gutter (no model-only hashline anchors). The TUI uses this directly so it never parses model-facing text. */
|
|
36
|
+
displayContent?: string;
|
|
37
|
+
/** Absolute base directory used during the edit. Used by the renderer to resolve
|
|
38
|
+
* display-relative paths to absolute paths for OSC 8 hyperlinks. */
|
|
39
|
+
searchPath?: string;
|
|
40
|
+
/** Session cwd at edit time. Display header paths are cwd-relative, so the
|
|
41
|
+
* renderer resolves them against this; `searchPath` is the scope target. */
|
|
42
|
+
cwd?: string;
|
|
43
|
+
}
|
|
44
|
+
type AstEditSchemaInfer = typeof astEditSchema.infer;
|
|
45
|
+
export declare class AstEditTool implements AgentTool<typeof astEditSchema, AstEditToolDetails> {
|
|
46
|
+
private readonly session;
|
|
47
|
+
readonly name = "ast_edit";
|
|
48
|
+
readonly approval: (args: unknown) => "read" | "write";
|
|
49
|
+
readonly formatApprovalDetails: (args: unknown) => string[];
|
|
50
|
+
readonly label = "AST Edit";
|
|
51
|
+
readonly summary = "Perform AST-aware code edits (structural refactoring)";
|
|
52
|
+
readonly description: string;
|
|
53
|
+
readonly parameters: import("@oh-my-pi/omptype").FluentType<{
|
|
54
|
+
paths: string[];
|
|
55
|
+
ops: {
|
|
56
|
+
out: string;
|
|
57
|
+
pat: string;
|
|
58
|
+
}[];
|
|
59
|
+
}, {
|
|
60
|
+
paths: string[];
|
|
61
|
+
ops: {
|
|
62
|
+
out: string;
|
|
63
|
+
pat: string;
|
|
64
|
+
}[];
|
|
65
|
+
}>;
|
|
66
|
+
readonly strict = true;
|
|
67
|
+
readonly examples: readonly ToolExample<AstEditSchemaInfer>[];
|
|
68
|
+
readonly deferrable = true;
|
|
69
|
+
readonly loadMode = "discoverable";
|
|
70
|
+
constructor(session: ToolSession);
|
|
71
|
+
execute(_toolCallId: string, params: AstEditSchemaInfer, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<AstEditToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<AstEditToolDetails>>;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolExample } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { ToolSession } from "../sdk";
|
|
4
|
+
import type { OutputMeta } from "../../omp/tools/output-meta.ts";
|
|
5
|
+
declare const astGrepSchema: import("@oh-my-pi/omptype").FluentType<{
|
|
6
|
+
pat: string;
|
|
7
|
+
path?: string | undefined;
|
|
8
|
+
skip?: number | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
pat: string;
|
|
11
|
+
path?: string | undefined;
|
|
12
|
+
skip?: number | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export interface AstGrepToolDetails {
|
|
15
|
+
matchCount: number;
|
|
16
|
+
fileCount: number;
|
|
17
|
+
filesSearched: number;
|
|
18
|
+
limitReached: boolean;
|
|
19
|
+
parseErrors?: string[];
|
|
20
|
+
/** Total parse error count before {@link PARSE_ERRORS_LIMIT} capping. Omitted when no errors. */
|
|
21
|
+
parseErrorsTotal?: number;
|
|
22
|
+
scopePath?: string;
|
|
23
|
+
files?: string[];
|
|
24
|
+
fileMatches?: Array<{
|
|
25
|
+
path: string;
|
|
26
|
+
count: number;
|
|
27
|
+
}>;
|
|
28
|
+
meta?: OutputMeta;
|
|
29
|
+
/** Pre-formatted text for the user-visible TUI render. Mirrors `result.text` lines but uses
|
|
30
|
+
* a `│` gutter and `*` to mark match lines. The TUI uses this directly so it never parses model-facing text. */
|
|
31
|
+
displayContent?: string;
|
|
32
|
+
/** Absolute base directory used during search. Used by the renderer to resolve
|
|
33
|
+
* display-relative paths to absolute paths for OSC 8 hyperlinks. */
|
|
34
|
+
searchPath?: string;
|
|
35
|
+
/** Session cwd at search time. Display header/match paths are cwd-relative, so
|
|
36
|
+
* the renderer resolves them against this; `searchPath` is the scope target. */
|
|
37
|
+
cwd?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare class AstGrepTool implements AgentTool<typeof astGrepSchema, AstGrepToolDetails> {
|
|
40
|
+
private readonly session;
|
|
41
|
+
readonly name = "ast_grep";
|
|
42
|
+
readonly approval: "read";
|
|
43
|
+
readonly label = "AST Grep";
|
|
44
|
+
readonly summary = "Search code with AST patterns (structural grep)";
|
|
45
|
+
get description(): string;
|
|
46
|
+
readonly parameters: import("@oh-my-pi/omptype").FluentType<{
|
|
47
|
+
pat: string;
|
|
48
|
+
path?: string | undefined;
|
|
49
|
+
skip?: number | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
pat: string;
|
|
52
|
+
path?: string | undefined;
|
|
53
|
+
skip?: number | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
readonly strict = true;
|
|
56
|
+
readonly examples: readonly ToolExample<typeof astGrepSchema.inferIn>[];
|
|
57
|
+
readonly loadMode = "discoverable";
|
|
58
|
+
constructor(session: ToolSession);
|
|
59
|
+
execute(_toolCallId: string, params: typeof astGrepSchema.infer, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<AstGrepToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<AstGrepToolDetails>>;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Settings } from "../config/settings.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Check if a file is auto-generated by examining its content.
|
|
4
|
+
* Throws ToolError if the file appears to be auto-generated.
|
|
5
|
+
*
|
|
6
|
+
* @param absolutePath - Absolute path to the file
|
|
7
|
+
* @param displayPath - Path to show in error messages (relative or as provided)
|
|
8
|
+
* @param activeSettings - Session settings; falls back to global settings or the schema default
|
|
9
|
+
*/
|
|
10
|
+
export declare function assertEditableFile(absolutePath: string, displayPath?: string, activeSettings?: Settings): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if file content is auto-generated.
|
|
13
|
+
* Uses only the first CHECK_BYTE_COUNT characters of the content.
|
|
14
|
+
* Throws ToolError if the content appears to be auto-generated.
|
|
15
|
+
*
|
|
16
|
+
* @param content - File content to check (can be full content or prefix)
|
|
17
|
+
* @param displayPath - Path to show in error messages
|
|
18
|
+
* @param activeSettings - Session settings; falls back to global settings or the schema default
|
|
19
|
+
*/
|
|
20
|
+
export declare function assertEditableFileContent(content: string, displayPath: string, activeSettings?: Settings): void;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect and resolve unresolved git merge conflicts that surface in `read`
|
|
3
|
+
* output.
|
|
4
|
+
*
|
|
5
|
+
* Workflow:
|
|
6
|
+
* 1. `read` collects lines from disk as usual.
|
|
7
|
+
* 2. `scanConflictLines` inspects those lines (no extra I/O) for
|
|
8
|
+
* well-formed `<<<<<<<` / `=======` / `>>>>>>>` blocks.
|
|
9
|
+
* 3. Each completed block is registered with the session's
|
|
10
|
+
* `ConflictHistory`, which assigns it a stable id.
|
|
11
|
+
* 4. The read output is returned verbatim with a short footer naming
|
|
12
|
+
* every conflict id surfaced, and the agent calls
|
|
13
|
+
* `write({ path: "conflict://<id>", content })` to splice the
|
|
14
|
+
* recorded region with the chosen content.
|
|
15
|
+
*
|
|
16
|
+
* Marker shape is strict: only column-0 markers of the exact prefix length
|
|
17
|
+
* followed by either EOL or a single space + label count. Lines that
|
|
18
|
+
* merely start with `<` or `=` never match.
|
|
19
|
+
*/
|
|
20
|
+
import type { ToolSession } from "./index";
|
|
21
|
+
export interface ConflictBlock {
|
|
22
|
+
/** 1-indexed line of the `<<<<<<<` marker. */
|
|
23
|
+
startLine: number;
|
|
24
|
+
/** 1-indexed line of the `=======` separator. */
|
|
25
|
+
separatorLine: number;
|
|
26
|
+
/** 1-indexed line of the `>>>>>>>` marker. */
|
|
27
|
+
endLine: number;
|
|
28
|
+
/** 1-indexed line of the `|||||||` base marker (diff3 only). */
|
|
29
|
+
baseLine?: number;
|
|
30
|
+
oursLabel?: string;
|
|
31
|
+
baseLabel?: string;
|
|
32
|
+
theirsLabel?: string;
|
|
33
|
+
oursLines: string[];
|
|
34
|
+
baseLines?: string[];
|
|
35
|
+
theirsLines: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Scan an already-collected array of file lines for completed conflict
|
|
39
|
+
* blocks. `firstLineNumber` is the 1-indexed line number of `lines[0]`
|
|
40
|
+
* (so a windowed read starting at line 200 passes `firstLineNumber: 200`).
|
|
41
|
+
*
|
|
42
|
+
* Only fully-closed blocks (opener + separator + closer all present in
|
|
43
|
+
* the window) are returned. A block whose closer is past the window's
|
|
44
|
+
* tail is dropped — the agent will see the open marker and can widen
|
|
45
|
+
* the read.
|
|
46
|
+
*/
|
|
47
|
+
export declare function scanConflictLines(lines: readonly string[], firstLineNumber: number): ConflictBlock[];
|
|
48
|
+
/**
|
|
49
|
+
* Scan a whole file for unresolved conflict blocks.
|
|
50
|
+
*
|
|
51
|
+
* Reads at most `maxBytes` (default 10 MB) so this stays cheap on
|
|
52
|
+
* pathological files. Files truncated by the cap report
|
|
53
|
+
* `scanTruncated: true`; only complete blocks within the scanned prefix
|
|
54
|
+
* are returned, so trailing partial markers never invent fake blocks.
|
|
55
|
+
*/
|
|
56
|
+
export declare function scanFileForConflicts(absolutePath: string, options?: {
|
|
57
|
+
maxBytes?: number;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
blocks: ConflictBlock[];
|
|
60
|
+
scanTruncated: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Recorded conflict block keyed by a session-stable id. The history is
|
|
64
|
+
* append-only; ids stay valid even after later writes resolve other
|
|
65
|
+
* blocks in the same file, so retries don't depend on re-reading.
|
|
66
|
+
*/
|
|
67
|
+
export interface ConflictEntry extends ConflictBlock {
|
|
68
|
+
id: number;
|
|
69
|
+
absolutePath: string;
|
|
70
|
+
displayPath: string;
|
|
71
|
+
}
|
|
72
|
+
/** Per-session log of conflict regions surfaced by `read`. */
|
|
73
|
+
export declare class ConflictHistory {
|
|
74
|
+
#private;
|
|
75
|
+
/**
|
|
76
|
+
* Register a conflict block. Returns the (possibly pre-existing) entry
|
|
77
|
+
* — if the same `absolutePath`+`startLine` was registered before, the
|
|
78
|
+
* earlier id is reused so a re-read does not inflate the counter or
|
|
79
|
+
* orphan the prior id. The recorded region is overwritten on re-read
|
|
80
|
+
* so the splice always reflects the current marker positions on disk.
|
|
81
|
+
*/
|
|
82
|
+
register(input: Omit<ConflictEntry, "id">): ConflictEntry;
|
|
83
|
+
get(id: number): ConflictEntry | undefined;
|
|
84
|
+
/** Snapshot every registered entry in insertion (id) order. */
|
|
85
|
+
entries(): ConflictEntry[];
|
|
86
|
+
/** Drop a single entry by id. Used after a successful resolve. */
|
|
87
|
+
invalidate(id: number): void;
|
|
88
|
+
/** Drop every entry referencing `absolutePath`. Used after a successful resolve. */
|
|
89
|
+
invalidatePath(absolutePath: string): void;
|
|
90
|
+
}
|
|
91
|
+
/** Lazily attach a `ConflictHistory` to the session and return it. */
|
|
92
|
+
export declare function getConflictHistory(session: ToolSession): ConflictHistory;
|
|
93
|
+
/** A side of a conflict block that the `read` tool can render via `conflict://N/<scope>`. */
|
|
94
|
+
export type ConflictScope = "ours" | "theirs" | "base";
|
|
95
|
+
/** Parsed `conflict://<N>` / `conflict://<N>/<scope>` / `conflict://*` URI. */
|
|
96
|
+
export interface ParsedConflictUri {
|
|
97
|
+
/** `"*"` selects every currently-registered conflict (bulk write only). */
|
|
98
|
+
id: number | "*";
|
|
99
|
+
scope?: ConflictScope;
|
|
100
|
+
/**
|
|
101
|
+
* When `raw` was a malformed `<file-prefix>:conflict://…` path, the
|
|
102
|
+
* stripped prefix is preserved here so callers can surface a gentle
|
|
103
|
+
* "you don't need the file path" note. `undefined` for clean URIs.
|
|
104
|
+
*/
|
|
105
|
+
recoveredPrefix?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parse a `conflict://<N>`, `conflict://<N>/<scope>`, or `conflict://*` URI.
|
|
109
|
+
*
|
|
110
|
+
* Returns `null` for non-conflict paths; throws `ToolError` for a
|
|
111
|
+
* well-formed scheme with an invalid id or scope so the agent gets a
|
|
112
|
+
* clear actionable message rather than a confusing "not found" later.
|
|
113
|
+
*
|
|
114
|
+
* `*` is the bulk-write wildcard — only valid as `conflict://*` (no
|
|
115
|
+
* scope segment). Use it with `write({ path: "conflict://*", content })`
|
|
116
|
+
* to apply `content` (with optional `@ours` / `@theirs` / `@base` /
|
|
117
|
+
* `@both` shorthand) to every currently-registered conflict in one shot.
|
|
118
|
+
*/
|
|
119
|
+
export declare function parseConflictUri(raw: string): ParsedConflictUri | null;
|
|
120
|
+
/** Result of {@link spliceConflict}: the new file text plus any boundary-echo repair applied. */
|
|
121
|
+
export interface ConflictSplice {
|
|
122
|
+
text: string;
|
|
123
|
+
/** Replacement lines dropped because they duplicated the context directly above the region. */
|
|
124
|
+
trimmedLeading: number;
|
|
125
|
+
/** Replacement lines dropped because they duplicated the context directly below the region. */
|
|
126
|
+
trimmedTrailing: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Splice the conflict region recorded in `entry` out of `originalText`
|
|
130
|
+
* and replace it with `replacement` (markers and all sides included).
|
|
131
|
+
*
|
|
132
|
+
* Works like the edit tool's patch infra: locates the recorded marker
|
|
133
|
+
* block by content (anchored to `entry.startLine` as the preferred
|
|
134
|
+
* match), so out-of-band edits earlier in the file that shift line
|
|
135
|
+
* numbers don't break resolution. Throws clearly when the marker block
|
|
136
|
+
* has actually been altered or removed.
|
|
137
|
+
*
|
|
138
|
+
* Boundary-echo repair (same philosophy as the edit tool's hashline
|
|
139
|
+
* keeper repair): models frequently paste the "whole resolved function"
|
|
140
|
+
* including the lines that live directly before/after the marker block,
|
|
141
|
+
* which the verbatim splice would duplicate. Replacement lines that
|
|
142
|
+
* exactly echo the adjacent context are dropped when the echo is
|
|
143
|
+
* unambiguous — two or more consecutive lines, or a single line whose
|
|
144
|
+
* removal fixes a delimiter-balance mismatch against the recorded sides.
|
|
145
|
+
*/
|
|
146
|
+
export declare function spliceConflict(originalText: string, entry: ConflictEntry, replacement: string): ConflictSplice;
|
|
147
|
+
/**
|
|
148
|
+
* True when two registered blocks record the same marker-block content
|
|
149
|
+
* (labels and all sides). Out-of-band edits can shift a block's line
|
|
150
|
+
* numbers between reads, registering a fresh id while the stale one
|
|
151
|
+
* persists; callers use content identity to treat a locate-miss for the
|
|
152
|
+
* stale twin as "already resolved" instead of a hard failure.
|
|
153
|
+
*/
|
|
154
|
+
export declare function conflictRegionsEqual(a: ConflictBlock, b: ConflictBlock): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* True when the entry's recorded marker block still occurs in `content`
|
|
157
|
+
* (LF-normalized — recorded sections are stored LF). Distinguishes a stale
|
|
158
|
+
* re-registration of a just-resolved region (no longer present) from a
|
|
159
|
+
* DISTINCT conflict block that happens to be byte-identical (still present
|
|
160
|
+
* elsewhere in the file and must stay addressable).
|
|
161
|
+
*/
|
|
162
|
+
export declare function conflictRegionPresent(content: string, entry: ConflictBlock): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Expand `@ours` / `@theirs` / `@base` / `@both` line tokens against the
|
|
165
|
+
* recorded sections of `entry`. A token only triggers when it is the
|
|
166
|
+
* entire content of a line (after CRLF normalisation), so `@ours` inside
|
|
167
|
+
* actual code is left alone. Other lines pass through verbatim.
|
|
168
|
+
*
|
|
169
|
+
* - `@ours` → expands to the recorded `oursLines` (in order).
|
|
170
|
+
* - `@theirs` → expands to the recorded `theirsLines` (in order).
|
|
171
|
+
* - `@base` → expands to `baseLines`; throws if no base section was
|
|
172
|
+
* recorded (i.e. the conflict was 2-way, not diff3).
|
|
173
|
+
* - `@both` → expands to `oursLines` then `theirsLines`.
|
|
174
|
+
*/
|
|
175
|
+
export declare function expandContentTokens(content: string, entry: ConflictEntry): string;
|
|
176
|
+
/**
|
|
177
|
+
* Materialise a conflict block for `conflict://<N>` reads (and their
|
|
178
|
+
* `/ours` / `/theirs` / `/base` scopes).
|
|
179
|
+
*
|
|
180
|
+
* Returns:
|
|
181
|
+
* - `lines`: the lines to render, ordered top-to-bottom.
|
|
182
|
+
* - `startLine`: the 1-indexed file line number `lines[0]` corresponds
|
|
183
|
+
* to, so the read formatter can label hashline anchors with the
|
|
184
|
+
* original file positions.
|
|
185
|
+
*
|
|
186
|
+
* Bare (no scope) returns the full block including marker lines. A
|
|
187
|
+
* scoped view returns only that side's body — `base` throws when the
|
|
188
|
+
* recorded conflict is a 2-way merge with no base section.
|
|
189
|
+
*/
|
|
190
|
+
export declare function renderConflictRegion(entry: ConflictEntry, scope: ConflictScope | undefined): {
|
|
191
|
+
lines: string[];
|
|
192
|
+
startLine: number;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Build a compact diff-style footer describing the conflicts registered
|
|
196
|
+
* during a read. Designed to be appended after the file content.
|
|
197
|
+
*
|
|
198
|
+
* Format:
|
|
199
|
+
*
|
|
200
|
+
* ⚠ N unresolved conflicts detected
|
|
201
|
+
* - ours = HEAD
|
|
202
|
+
* - theirs = feature/x
|
|
203
|
+
* NOTICE: …
|
|
204
|
+
*
|
|
205
|
+
* ──── #1 L42-48 ────
|
|
206
|
+
* <<< ours
|
|
207
|
+
* …ours body…
|
|
208
|
+
* === base ≡ ours
|
|
209
|
+
* >>> theirs
|
|
210
|
+
* …theirs body…
|
|
211
|
+
*
|
|
212
|
+
* Labels are aggregated once at the top from the first entry that has
|
|
213
|
+
* them; when a section body equals another section's body the redundant
|
|
214
|
+
* body is collapsed to `≡ <other>`.
|
|
215
|
+
*/
|
|
216
|
+
export interface FormatConflictWarningOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Total number of conflicts in the underlying file. If greater than
|
|
219
|
+
* `entries.length` the header notes how many are visible vs the total
|
|
220
|
+
* and points at `:conflicts` for the compact list.
|
|
221
|
+
*/
|
|
222
|
+
totalInFile?: number;
|
|
223
|
+
/** Display path used inside the `:conflicts` hint. */
|
|
224
|
+
displayPath?: string;
|
|
225
|
+
/** Whether the underlying file scan hit its byte cap. */
|
|
226
|
+
scanTruncated?: boolean;
|
|
227
|
+
}
|
|
228
|
+
export declare function formatConflictWarning(entries: readonly ConflictEntry[], options?: FormatConflictWarningOptions): string;
|
|
229
|
+
/**
|
|
230
|
+
* Render a single-line-per-block index of every conflict in a file.
|
|
231
|
+
* Used by the `<path>:conflicts` read selector to give the agent a cheap overview
|
|
232
|
+
* of a heavily-conflicted file without dumping every body.
|
|
233
|
+
*/
|
|
234
|
+
export declare function formatConflictSummary(entries: readonly ConflictEntry[], options?: {
|
|
235
|
+
displayPath: string;
|
|
236
|
+
scanTruncated?: boolean;
|
|
237
|
+
}): string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { FetchImpl } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { Settings } from "../config/settings";
|
|
4
|
+
import type { ToolSession } from "../sdk";
|
|
5
|
+
import type { AgentStorage } from "../session/agent-storage";
|
|
6
|
+
import { type OutputMeta } from "./output-meta";
|
|
7
|
+
import { type LineRange } from "./path-utils";
|
|
8
|
+
export interface ParsedReadUrlTarget {
|
|
9
|
+
path: string;
|
|
10
|
+
raw: boolean;
|
|
11
|
+
offset?: number;
|
|
12
|
+
limit?: number;
|
|
13
|
+
/** Populated only when the selector carries 2+ ranges. Single-range stays on offset/limit. */
|
|
14
|
+
ranges?: readonly LineRange[];
|
|
15
|
+
}
|
|
16
|
+
export declare function parseReadUrlTarget(readPath: string): ParsedReadUrlTarget | null;
|
|
17
|
+
/** Reader backends for {@link renderHtmlToText}, in default priority order. */
|
|
18
|
+
export type FetchProvider = "native" | "trafilatura" | "lynx" | "parallel" | "jina" | "browser";
|
|
19
|
+
export declare const FETCH_PROVIDER_ORDER: readonly FetchProvider[];
|
|
20
|
+
/**
|
|
21
|
+
* Render HTML to markdown by trying reader backends in priority order: native
|
|
22
|
+
* (in-process), trafilatura, lynx, Parallel, Jina, then the browser
|
|
23
|
+
* (headless-Chromium JS rendering, see {@link renderUrlWithBrowser} — gated
|
|
24
|
+
* behind `browser.readerEnabled`). The `providers.fetch` setting picks the
|
|
25
|
+
* order — `auto` uses the default above; any specific backend is tried first,
|
|
26
|
+
* then the remaining backends as fallbacks. Every backend's output must clear
|
|
27
|
+
* the same quality gate (>100 non-whitespace chars and not
|
|
28
|
+
* {@link isLowQualityOutput}) before it is accepted, otherwise the next
|
|
29
|
+
* backend is tried.
|
|
30
|
+
*
|
|
31
|
+
* When the raw HTML is a CSR app shell (script-heavy, text-light), output
|
|
32
|
+
* from {@link CSR_SUSCEPTIBLE} backends (which cannot execute page
|
|
33
|
+
* JavaScript) is held back as low quality so the chain still reaches the
|
|
34
|
+
* browser backend; with no usable browser the parked shell is returned as
|
|
35
|
+
* before, so degradation is unchanged. The browser's own output on a shell
|
|
36
|
+
* is accepted as-is (a noscript remnant is expected in it).
|
|
37
|
+
*
|
|
38
|
+
* The overall `timeout` budget bounds the whole call; remote backends (Parallel,
|
|
39
|
+
* Jina) are additionally capped at `REMOTE_READER_MAX_MS` so a hung endpoint
|
|
40
|
+
* cannot starve later renderers — especially the purely-local native converter,
|
|
41
|
+
* which always works on already-loaded HTML. Only a real `userSignal`
|
|
42
|
+
* cancellation aborts the chain (#1449).
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderHtmlToText(url: string, html: string, timeout: number, settings: Settings, userSignal: AbortSignal | undefined, storage: AgentStorage | null, fetchOverride?: FetchImpl): Promise<{
|
|
45
|
+
content: string;
|
|
46
|
+
ok: boolean;
|
|
47
|
+
method: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Detect a client-side-rendered (CSR) app shell in raw HTML: script-dense
|
|
51
|
+
* markup with almost no statically visible text. Such pages only produce body
|
|
52
|
+
* content after JavaScript executes, so JS-unaware extractors (native/
|
|
53
|
+
* trafilatura/lynx) necessarily return a shell remnant (title/meta remnants)
|
|
54
|
+
* while the browser backend can render the real body. Deliberately
|
|
55
|
+
* conservative — compact HTML, multiple script tags, sparse static text — so
|
|
56
|
+
* genuine SSR pages are never flagged and their rendering order is unchanged.
|
|
57
|
+
* @returns true when the HTML looks like an unrendered SPA shell.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isCsrHtmlShell(html: string): boolean;
|
|
60
|
+
interface FetchImagePayload {
|
|
61
|
+
data: string;
|
|
62
|
+
mimeType: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ReadUrlToolDetails {
|
|
65
|
+
kind: "url";
|
|
66
|
+
url: string;
|
|
67
|
+
finalUrl: string;
|
|
68
|
+
contentType: string;
|
|
69
|
+
method: string;
|
|
70
|
+
truncated: boolean;
|
|
71
|
+
notes: string[];
|
|
72
|
+
meta?: OutputMeta;
|
|
73
|
+
/** DSH (拍板#22): committed attachment facts when the URL image went through the bridge. */
|
|
74
|
+
image?: import("../../shared/image-bridge.ts").SavedImageRef;
|
|
75
|
+
}
|
|
76
|
+
interface ReadUrlEntry {
|
|
77
|
+
artifactId?: string;
|
|
78
|
+
artifactPath?: string;
|
|
79
|
+
details: ReadUrlToolDetails;
|
|
80
|
+
image?: FetchImagePayload;
|
|
81
|
+
output: string;
|
|
82
|
+
content: string;
|
|
83
|
+
}
|
|
84
|
+
/** Fetch and render a URL for a read or search operation. */
|
|
85
|
+
export declare function fetchReadUrl(session: ToolSession, params: {
|
|
86
|
+
path: string;
|
|
87
|
+
raw?: boolean;
|
|
88
|
+
}, signal?: AbortSignal, options?: {
|
|
89
|
+
ensureArtifact?: boolean;
|
|
90
|
+
}): Promise<ReadUrlEntry>;
|
|
91
|
+
/** Materialize rendered URL body text to a local file for tools that require filesystem paths. */
|
|
92
|
+
export declare function materializeReadUrlToFile(session: ToolSession, params: {
|
|
93
|
+
path: string;
|
|
94
|
+
raw?: boolean;
|
|
95
|
+
}, signal?: AbortSignal): Promise<{
|
|
96
|
+
path: string;
|
|
97
|
+
details: ReadUrlToolDetails;
|
|
98
|
+
}>;
|
|
99
|
+
export declare function executeReadUrl(session: ToolSession, params: {
|
|
100
|
+
path: string;
|
|
101
|
+
raw?: boolean;
|
|
102
|
+
}, signal?: AbortSignal): Promise<AgentToolResult<ReadUrlToolDetails>>;
|
|
103
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a deduplicating recorder for relative file paths.
|
|
3
|
+
* Preserves insertion order in `list`; subsequent duplicates are ignored.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createFileRecorder(): {
|
|
6
|
+
record: (relativePath: string) => void;
|
|
7
|
+
list: string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Strip native virtual-root prefixes and format file paths relative to cwd when
|
|
11
|
+
* they are inside cwd. Paths outside cwd remain absolute.
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatResultPath(filePath: string, isDirectory: boolean, basePath: string, cwd: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invalidate shared filesystem scan caches after a content write/update.
|
|
3
|
+
*/
|
|
4
|
+
export declare function invalidateFsScanAfterWrite(path: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Invalidate shared filesystem scan caches after deleting a file.
|
|
7
|
+
*/
|
|
8
|
+
export declare function invalidateFsScanAfterDelete(path: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Invalidate shared filesystem scan caches after a rename/move.
|
|
11
|
+
*
|
|
12
|
+
* Some watchers care about the disappearance at the old path; others about the
|
|
13
|
+
* appearance at the new one. Bust both to keep callers honest.
|
|
14
|
+
*/
|
|
15
|
+
export declare function invalidateFsScanAfterRename(oldPath: string, newPath: string): void;
|