@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,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* report_issue — automated QA backend for tracking unexpected tool behavior.
|
|
3
|
+
*
|
|
4
|
+
* No model-facing tool schema anymore: the write tool dispatches plain text to
|
|
5
|
+
* `xd://report_issue`, and the system prompt tells the model to write
|
|
6
|
+
* `<tool>: <concise description>` there when auto-QA is enabled.
|
|
7
|
+
*
|
|
8
|
+
* Enabled by default (`dev.autoqa` defaults to true); `PI_AUTO_QA=0` or an
|
|
9
|
+
* explicit `dev.autoqa: false` short-circuits injection entirely. When the
|
|
10
|
+
* user is only enabled by default (never configured `dev.autoqa` themselves),
|
|
11
|
+
* a persisted `dev.autoqaConsent: "denied"` also disables injection so a "No"
|
|
12
|
+
* in the consent dialog fully turns the feature off.
|
|
13
|
+
* Records grievances to a local SQLite database; never throws from the device
|
|
14
|
+
* dispatch path.
|
|
15
|
+
*
|
|
16
|
+
* Nothing is written until consent resolves. If the user has never been asked
|
|
17
|
+
* (`dev.autoqaConsent === "unset"`) the process-global consent handler —
|
|
18
|
+
* wired by `InteractiveMode` to a Yes/No popup — is invoked exactly once and
|
|
19
|
+
* the decision is persisted; a denial (or dismissal) drops the pending report
|
|
20
|
+
* without touching the database. Subsequent calls (including from subagents)
|
|
21
|
+
* read the cached decision without prompting. `PI_AUTO_QA_PUSH=1` bypasses
|
|
22
|
+
* the dialog for headless environments.
|
|
23
|
+
*
|
|
24
|
+
* When the user grants consent, push is automatically active against the
|
|
25
|
+
* bundled endpoint (`dev.autoqaPush.endpoint`, default `qa.omp.sh`). Each
|
|
26
|
+
* insert schedules a background flush that POSTs pending rows and deletes them
|
|
27
|
+
* on HTTP 2xx. `PI_AUTO_QA_PUSH=1` forces push in non-interactive environments
|
|
28
|
+
* where the consent dialog never fires. Device execution is never blocked on
|
|
29
|
+
* the network and never throws.
|
|
30
|
+
*/
|
|
31
|
+
import { Database } from "bun:sqlite";
|
|
32
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
33
|
+
import type { FetchImpl } from "@oh-my-pi/pi-ai";
|
|
34
|
+
import type { Settings } from "../config/settings";
|
|
35
|
+
import type { ToolSession } from "./index";
|
|
36
|
+
import type { XdevDispatch } from "./resolve";
|
|
37
|
+
export declare const REPORT_ISSUE_DEVICE_NAME = "report_issue";
|
|
38
|
+
export declare const REPORT_ISSUE_DEVICE_PATH = "xd://report_issue";
|
|
39
|
+
/** Usage text for `read xd://report_issue`. */
|
|
40
|
+
export declare function reportIssueDeviceUsage(): string;
|
|
41
|
+
/** Whether a tool call writes to `xd://report_issue`. */
|
|
42
|
+
export declare function isReportIssueToolCall(toolCall: {
|
|
43
|
+
name: string;
|
|
44
|
+
arguments?: Record<string, unknown>;
|
|
45
|
+
}): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether Auto-QA is active for this session.
|
|
48
|
+
*
|
|
49
|
+
* Precedence: `PI_AUTO_QA` env flag > explicit `dev.autoqa` setting >
|
|
50
|
+
* default-on unless the user previously denied consent. The denial veto only
|
|
51
|
+
* applies to the default: explicitly configuring `dev.autoqa: true` re-enables
|
|
52
|
+
* injection (recording still no-ops until consent is granted).
|
|
53
|
+
*/
|
|
54
|
+
export declare function isAutoQaEnabled(settings?: Settings): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Resolver for the user's "share grievances?" consent.
|
|
57
|
+
*
|
|
58
|
+
* Return values:
|
|
59
|
+
* - `true` — user agreed; record + ship for this run and persist.
|
|
60
|
+
* - `false` — user declined; suppress for this run and persist.
|
|
61
|
+
* - `null` — user dismissed the dialog (ESC, click-away, …) without
|
|
62
|
+
* picking an option. The decision is NOT cached or persisted,
|
|
63
|
+
* so the next `report_issue` invocation re-prompts.
|
|
64
|
+
*
|
|
65
|
+
* Persistence is the tool's job (so subagent invocations can persist into the
|
|
66
|
+
* disk-backed `Settings` instance the host registered alongside the handler),
|
|
67
|
+
* not the handler's. Implementations live in hosts that have UI affordances —
|
|
68
|
+
* today only `InteractiveMode`. When no handler is registered (CLI subcommands,
|
|
69
|
+
* tests, non-interactive runs) consent defaults to `false` — the explicit
|
|
70
|
+
* "don't collect by default" stance.
|
|
71
|
+
*/
|
|
72
|
+
export type AutoQaConsentHandler = () => Promise<boolean | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Register the consent handler and the persistent {@link Settings} instance
|
|
75
|
+
* the decision should be written to. Passing `null` clears the handler
|
|
76
|
+
* (e.g. on `InteractiveMode` teardown). Re-registration is authoritative.
|
|
77
|
+
*/
|
|
78
|
+
export declare function setAutoQaConsentHandler(handler: AutoQaConsentHandler | null, persistentSettings?: Settings | null): void;
|
|
79
|
+
/** Test-only: clear consent cache + handler. Never call from production code. */
|
|
80
|
+
export declare function __resetAutoQaConsentForTests(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the user's consent for Auto-QA grievances.
|
|
83
|
+
*
|
|
84
|
+
* Priority:
|
|
85
|
+
* 1. module cache (`cachedConsent`) — process-global, survives subagent boundaries
|
|
86
|
+
* 2. persisted setting on the caller's `Settings`
|
|
87
|
+
* 3. persisted setting on the registered persistent settings instance
|
|
88
|
+
* 4. registered UI handler (single-flight)
|
|
89
|
+
* 5. default `false` (no handler / non-interactive)
|
|
90
|
+
*/
|
|
91
|
+
export declare function resolveAutoQaConsent(settings: Settings | undefined): Promise<boolean>;
|
|
92
|
+
/**
|
|
93
|
+
* Open (or return the cached handle for) the auto-QA SQLite database at
|
|
94
|
+
* `~/.omp/autoqa.db` (XDG: `$XDG_DATA_HOME/omp/autoqa.db`), creating the
|
|
95
|
+
* schema lazily. Returns `null` when the path cannot be resolved or opened.
|
|
96
|
+
*/
|
|
97
|
+
export declare function openAutoQaDb(): Database | null;
|
|
98
|
+
export interface FlushResult {
|
|
99
|
+
pushed: number;
|
|
100
|
+
ok: boolean;
|
|
101
|
+
skipped?: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Optional per-flush controls. Used by `omp grievances push` to surface
|
|
105
|
+
* progress to a TTY and to skip the user-facing consent gate (manual
|
|
106
|
+
* pushes are the user's explicit intent, not a side effect of a device write).
|
|
107
|
+
*/
|
|
108
|
+
export interface FlushOptions {
|
|
109
|
+
/**
|
|
110
|
+
* Skip the `dev.autoqaConsent === "granted"` gate in
|
|
111
|
+
* {@link resolvePushConfig}. Endpoint configuration is still required.
|
|
112
|
+
* Reserved for explicit user-driven pushes (CLI `grievances push`,
|
|
113
|
+
* future debug recipes); never set from the device's auto-flush path.
|
|
114
|
+
*/
|
|
115
|
+
bypassConsent?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Fetch implementation for the push POST. Defaults to global fetch.
|
|
118
|
+
*/
|
|
119
|
+
fetch?: FetchImpl;
|
|
120
|
+
/**
|
|
121
|
+
* Fires once at the start of the loop with the snapshot count of
|
|
122
|
+
* unpushed rows. Subsequent inserts won't be reflected (the count is
|
|
123
|
+
* a planning hint for progress reporters, not a live total).
|
|
124
|
+
*/
|
|
125
|
+
onStart?: (totalUnpushed: number) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Fires after every successfully shipped batch with the running pushed
|
|
128
|
+
* count. Reporters compare against the `totalUnpushed` they saw in
|
|
129
|
+
* `onStart` to advance their bar.
|
|
130
|
+
*/
|
|
131
|
+
onProgress?: (pushedSoFar: number) => void;
|
|
132
|
+
}
|
|
133
|
+
/** Test-only: clear single-flight + cooldown state. Never call from production code. */
|
|
134
|
+
export declare function __resetAutoQaFlushStateForTests(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Flush queued grievances to the configured backend.
|
|
137
|
+
*/
|
|
138
|
+
export declare function flushGrievances(db?: Database, settings?: Settings, options?: FlushOptions): Promise<FlushResult>;
|
|
139
|
+
/** Test-only: await the last consent → insert → flush pipeline. */
|
|
140
|
+
export declare function __awaitAutoQaRecordPipelineForTests(): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Execute `write xd://report_issue`. `text` must be either:
|
|
143
|
+
* - `<tool>: <concise description>` on one line, or
|
|
144
|
+
* - tool name on the first line with the report body below.
|
|
145
|
+
*/
|
|
146
|
+
export declare function dispatchReportIssueDevice(session: ToolSession, text: string): Promise<{
|
|
147
|
+
result: AgentToolResult<unknown>;
|
|
148
|
+
xdev: XdevDispatch;
|
|
149
|
+
}>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolution devices: staged work is finalized through plain-text writes to
|
|
3
|
+
* always-available `xd://` URLs — no tool schema, no JSON protocol.
|
|
4
|
+
*
|
|
5
|
+
* write xd://resolve reason text → APPLY the pending staged preview
|
|
6
|
+
* write xd://reject reason text → DISCARD the pending staged preview
|
|
7
|
+
* write xd://propose plan <slug> → submit the plan for approval (plan mode)
|
|
8
|
+
*
|
|
9
|
+
* Nothing rides the system prompt: the flows that stage work teach the call
|
|
10
|
+
* shape at the moment it becomes relevant (the preview reminder for
|
|
11
|
+
* resolve/reject, the plan-mode prompt for propose).
|
|
12
|
+
*
|
|
13
|
+
* Rendering rides the write tool's xd:// delegation: renderers.ts keys the
|
|
14
|
+
* resolve renderer under `resolve` and `reject` so device writes and legacy
|
|
15
|
+
* `resolve` tool transcripts draw the same block.
|
|
16
|
+
*/
|
|
17
|
+
import type { AgentToolResult, CustomMessage } from "@oh-my-pi/pi-agent-core";
|
|
18
|
+
import type { ToolSession } from ".";
|
|
19
|
+
import type { ToolTier } from "./approval";
|
|
20
|
+
/**
|
|
21
|
+
* Dispatch metadata carried on write-tool details for renderer delegation.
|
|
22
|
+
* (原 xdev.ts 的类型面;挂载设备层已随拍板剔除,仅 resolution/report_issue
|
|
23
|
+
* 设备继续在 write details 上携带此元数据。)
|
|
24
|
+
*/
|
|
25
|
+
export interface XdevDispatch {
|
|
26
|
+
tool: string;
|
|
27
|
+
mode: "help" | "execute";
|
|
28
|
+
/** Validated inner args, kept for renderer delegation on result rebuilds. */
|
|
29
|
+
args?: Record<string, unknown>;
|
|
30
|
+
/** Approval tier of the wrapped device call (`read` = no workspace mutation). */
|
|
31
|
+
tier?: ToolTier;
|
|
32
|
+
/** Details object returned by the wrapped tool, when executed. */
|
|
33
|
+
inner?: unknown;
|
|
34
|
+
}
|
|
35
|
+
export declare const RESOLVE_DEVICE_NAME = "resolve";
|
|
36
|
+
export declare const REJECT_DEVICE_NAME = "reject";
|
|
37
|
+
export declare const PROPOSE_DEVICE_NAME = "propose";
|
|
38
|
+
/** The plain-text resolution device URLs (`xd://resolve`, …). */
|
|
39
|
+
export declare const RESOLVE_DEVICE_PATH = "xd://resolve";
|
|
40
|
+
export declare const REJECT_DEVICE_PATH = "xd://reject";
|
|
41
|
+
export declare const PROPOSE_DEVICE_PATH = "xd://propose";
|
|
42
|
+
/**
|
|
43
|
+
* Model-visible banner prepended to a staged preview's tool result text. The
|
|
44
|
+
* TUI badge (`⟨proposed⟩`) never reaches the model, and preview diffs are
|
|
45
|
+
* byte-identical to applied-edit output — without this line the model reads
|
|
46
|
+
* the result as an already-applied change.
|
|
47
|
+
*/
|
|
48
|
+
export declare const PREVIEW_PENDING_NOTICE = "Staged as a proposal \u2014 files NOT modified yet. To apply: write a one-sentence reason to xd://resolve. To discard: write to xd://reject.";
|
|
49
|
+
export type ResolutionDeviceName = typeof RESOLVE_DEVICE_NAME | typeof REJECT_DEVICE_NAME | typeof PROPOSE_DEVICE_NAME;
|
|
50
|
+
/** Whether an xd:// device name is one of the plain-text resolution devices. */
|
|
51
|
+
export declare function isResolutionDeviceName(name: string): name is ResolutionDeviceName;
|
|
52
|
+
/** One-line usage string returned by `read xd://<device>` — the only "docs" these devices carry. */
|
|
53
|
+
export declare function resolutionDeviceUsage(device: ResolutionDeviceName): string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether an assistant tool call is a `write` targeting `xd://resolve` or
|
|
56
|
+
* `xd://reject`. Used as the SoftToolRequirement compliance check while a
|
|
57
|
+
* preview is pending — a plain `write` elsewhere resolves nothing.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isPreviewResolutionToolCall(toolCall: {
|
|
60
|
+
name: string;
|
|
61
|
+
arguments?: Record<string, unknown>;
|
|
62
|
+
}): boolean;
|
|
63
|
+
/** Whether an assistant tool call is a `write` targeting `xd://propose` (plan-mode decision detection). */
|
|
64
|
+
export declare function isProposeToolCall(toolCall: {
|
|
65
|
+
name: string;
|
|
66
|
+
arguments?: Record<string, unknown>;
|
|
67
|
+
}): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The XdevDispatch metadata carried on a completed `write` execution result, or
|
|
70
|
+
* `undefined` when the execution was not a device dispatch. Consumers check
|
|
71
|
+
* `.tool` (e.g. `PROPOSE_DEVICE_NAME` for plan-mode decision tracking and the
|
|
72
|
+
* event-controller's plan-approval hook).
|
|
73
|
+
*/
|
|
74
|
+
export declare function writeDeviceDispatch(toolName: string, result: unknown): XdevDispatch | undefined;
|
|
75
|
+
/** Handler installed by plan mode; `xd://propose` dispatches the written plan title to it. */
|
|
76
|
+
export type PlanProposalHandler = (title: string) => Promise<AgentToolResult<unknown>>;
|
|
77
|
+
type ResolveAction = "apply" | "discard";
|
|
78
|
+
/** Details payload carried on a resolve/reject dispatch result (`XdevDispatch.inner`). */
|
|
79
|
+
export interface ResolveDetails {
|
|
80
|
+
action: ResolveAction;
|
|
81
|
+
reason: string;
|
|
82
|
+
sourceToolName?: string;
|
|
83
|
+
label?: string;
|
|
84
|
+
sourceResultDetails?: unknown;
|
|
85
|
+
}
|
|
86
|
+
/** Parse a completed `write` dispatch targeting `xd://resolve` or `xd://reject`. */
|
|
87
|
+
export declare function resolveDispatchDetails(toolName: string, result: unknown): ResolveDetails | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Register a non-forcing resolve-protocol handler for a staged preview. Wraps the
|
|
90
|
+
* caller's apply/reject into an onInvoked closure and stores it on the tool-choice
|
|
91
|
+
* queue's pending-invoker registry under a UNIQUE id. A `write` to `xd://resolve`
|
|
92
|
+
* or `xd://reject` dispatches to it; the agent-loop's SoftToolRequirement
|
|
93
|
+
* lifecycle injects the preview reminder and escalates to a forced `write` only
|
|
94
|
+
* if the model declines — so a compliant turn pays ZERO tool_choice change (no
|
|
95
|
+
* prompt-cache messages-cache invalidation).
|
|
96
|
+
*
|
|
97
|
+
* This is the canonical entry point for any tool that wants preview/apply
|
|
98
|
+
* semantics. No session-level abstraction is needed: callers pass their
|
|
99
|
+
* apply/reject functions directly. Resolution requires the `write` tool to be
|
|
100
|
+
* active — the session's soft requirement names it.
|
|
101
|
+
*/
|
|
102
|
+
export declare function queueResolveHandler(session: ToolSession, options: {
|
|
103
|
+
label: string;
|
|
104
|
+
sourceToolName: string;
|
|
105
|
+
apply(reason: string): Promise<AgentToolResult<unknown>>;
|
|
106
|
+
reject?(reason: string): Promise<AgentToolResult<unknown> | undefined>;
|
|
107
|
+
}): void;
|
|
108
|
+
/**
|
|
109
|
+
* The canonical preview reminder. The resolve mechanism owns the wording; the
|
|
110
|
+
* agent-loop delivers it via the session's `SoftToolRequirement.reminder` (injected
|
|
111
|
+
* once per pending-preview head) instead of a host-side steer, so it lands as a
|
|
112
|
+
* stable mid-history append and never churns the cached prefix.
|
|
113
|
+
*/
|
|
114
|
+
export declare function buildResolveReminderMessage(sourceToolName: string): CustomMessage;
|
|
115
|
+
/**
|
|
116
|
+
* Execute a resolution-device write. `text` is the raw plain-text body:
|
|
117
|
+
* - `xd://resolve` / `xd://reject` → the reason; dispatches to the pending
|
|
118
|
+
* preview invoker (in-flight queue directive first).
|
|
119
|
+
* - `xd://propose` → the plan title; dispatches to the plan-proposal handler
|
|
120
|
+
* installed by plan mode.
|
|
121
|
+
*/
|
|
122
|
+
export declare function dispatchResolutionDevice(session: ToolSession, device: ResolutionDeviceName, text: string): Promise<{
|
|
123
|
+
result: AgentToolResult<unknown>;
|
|
124
|
+
xdev: XdevDispatch;
|
|
125
|
+
}>;
|
|
126
|
+
export {};
|
|
127
|
+
/** Streaming-safe call preview for a resolution-device write: `Resolve/Reject/Propose: <text>`. */
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
export declare function looksLikeSqlite(bytes: Uint8Array): boolean;
|
|
3
|
+
/** Row cap for raw `?q=` SQL — protects against `SELECT *` on multi-million-row tables. */
|
|
4
|
+
export declare const MAX_RAW_QUERY_ROWS = 1000;
|
|
5
|
+
export interface SqlitePathCandidate {
|
|
6
|
+
sqlitePath: string;
|
|
7
|
+
subPath: string;
|
|
8
|
+
queryString: string;
|
|
9
|
+
}
|
|
10
|
+
export type SqliteSelector = {
|
|
11
|
+
kind: "list";
|
|
12
|
+
} | {
|
|
13
|
+
kind: "schema";
|
|
14
|
+
table: string;
|
|
15
|
+
sampleLimit: number;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "row";
|
|
18
|
+
table: string;
|
|
19
|
+
key: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "query";
|
|
22
|
+
table: string;
|
|
23
|
+
limit: number;
|
|
24
|
+
offset: number;
|
|
25
|
+
order?: string;
|
|
26
|
+
where?: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "raw";
|
|
29
|
+
sql: string;
|
|
30
|
+
};
|
|
31
|
+
export type SqliteRowLookup = {
|
|
32
|
+
kind: "pk";
|
|
33
|
+
column: string;
|
|
34
|
+
type: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "rowid";
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Row count for a table in the listing.
|
|
40
|
+
* - `exact`: counted in full (the table is small enough to count cheaply).
|
|
41
|
+
* - `estimate`: the planner's `sqlite_stat1` figure; the table is too large to
|
|
42
|
+
* scan, so this may be stale.
|
|
43
|
+
* - `atLeast`: a lower bound; counting was capped before reaching the end.
|
|
44
|
+
*/
|
|
45
|
+
export type TableRowCount = {
|
|
46
|
+
kind: "exact";
|
|
47
|
+
rows: number;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "estimate";
|
|
50
|
+
rows: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "atLeast";
|
|
53
|
+
rows: number;
|
|
54
|
+
};
|
|
55
|
+
export interface SqliteTableSummary {
|
|
56
|
+
name: string;
|
|
57
|
+
count: TableRowCount;
|
|
58
|
+
}
|
|
59
|
+
export declare function parseSqlitePathCandidates(filePath: string): SqlitePathCandidate[];
|
|
60
|
+
export declare function isSqliteFile(absolutePath: string): Promise<boolean>;
|
|
61
|
+
export declare function parseSqliteSelector(subPath: string, queryString: string): SqliteSelector;
|
|
62
|
+
export declare function listTables(db: Database, options?: {
|
|
63
|
+
probeCap?: number;
|
|
64
|
+
}): SqliteTableSummary[];
|
|
65
|
+
export declare function getTableSchema(db: Database, table: string): string;
|
|
66
|
+
export declare function getTablePrimaryKey(db: Database, table: string): {
|
|
67
|
+
column: string;
|
|
68
|
+
type: string;
|
|
69
|
+
} | null;
|
|
70
|
+
export declare function resolveTableRowLookup(db: Database, table: string): SqliteRowLookup;
|
|
71
|
+
export declare function queryRows(db: Database, table: string, opts: {
|
|
72
|
+
limit: number;
|
|
73
|
+
offset: number;
|
|
74
|
+
order?: string;
|
|
75
|
+
where?: string;
|
|
76
|
+
}): {
|
|
77
|
+
columns: string[];
|
|
78
|
+
rows: Record<string, unknown>[];
|
|
79
|
+
totalCount: number;
|
|
80
|
+
};
|
|
81
|
+
export declare function getRowByKey(db: Database, table: string, pk: {
|
|
82
|
+
column: string;
|
|
83
|
+
type?: string;
|
|
84
|
+
}, key: string): Record<string, unknown> | null;
|
|
85
|
+
export declare function getRowByRowId(db: Database, table: string, key: string): Record<string, unknown> | null;
|
|
86
|
+
export declare function executeReadQuery(db: Database, sql: string): {
|
|
87
|
+
columns: string[];
|
|
88
|
+
rows: Record<string, unknown>[];
|
|
89
|
+
truncated: boolean;
|
|
90
|
+
};
|
|
91
|
+
export declare function insertRow(db: Database, table: string, data: Record<string, unknown>): void;
|
|
92
|
+
export declare function updateRowByKey(db: Database, table: string, pk: {
|
|
93
|
+
column: string;
|
|
94
|
+
type?: string;
|
|
95
|
+
}, key: string, data: Record<string, unknown>): number;
|
|
96
|
+
export declare function updateRowByRowId(db: Database, table: string, key: string, data: Record<string, unknown>): number;
|
|
97
|
+
export declare function deleteRowByKey(db: Database, table: string, pk: {
|
|
98
|
+
column: string;
|
|
99
|
+
type?: string;
|
|
100
|
+
}, key: string): number;
|
|
101
|
+
export declare function deleteRowByRowId(db: Database, table: string, key: string): number;
|
|
102
|
+
export declare function renderTableList(tables: SqliteTableSummary[]): string;
|
|
103
|
+
export declare function renderSchema(createSql: string, sampleRows: {
|
|
104
|
+
columns: string[];
|
|
105
|
+
rows: Record<string, unknown>[];
|
|
106
|
+
}): string;
|
|
107
|
+
export declare function renderRow(row: Record<string, unknown>): string;
|
|
108
|
+
export declare function renderTable(columns: string[], rows: Record<string, unknown>[], meta: {
|
|
109
|
+
totalCount: number;
|
|
110
|
+
offset: number;
|
|
111
|
+
limit: number;
|
|
112
|
+
table: string;
|
|
113
|
+
dbPath: string;
|
|
114
|
+
}): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standardized error types for tool execution.
|
|
3
|
+
*
|
|
4
|
+
* Tools should throw these instead of returning error text.
|
|
5
|
+
* The agent loop catches and renders them appropriately.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base error for tool execution failures.
|
|
9
|
+
* Override render() for custom LLM-facing formatting.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ToolError extends Error {
|
|
12
|
+
readonly context?: Record<string, unknown> | undefined;
|
|
13
|
+
constructor(message: string, context?: Record<string, unknown> | undefined);
|
|
14
|
+
/** Render error for LLM consumption. Override for custom formatting. */
|
|
15
|
+
render(): string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown when a tool operation is aborted (e.g., via AbortSignal).
|
|
19
|
+
*/
|
|
20
|
+
export declare class ToolAbortError extends Error {
|
|
21
|
+
static readonly MESSAGE = "Operation aborted";
|
|
22
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Throw ToolAbortError if the signal is aborted.
|
|
26
|
+
* Use this instead of signal?.throwIfAborted() to get consistent error types.
|
|
27
|
+
*/
|
|
28
|
+
export declare function throwIfAborted(signal?: AbortSignal): void;
|
|
29
|
+
/**
|
|
30
|
+
* Render an error for LLM consumption.
|
|
31
|
+
* Handles ToolError.render() and falls back to message/string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderError(e: unknown): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ImageContent, TextContent } from "@oh-my-pi/pi-ai";
|
|
3
|
+
import type { OutputSummary, TruncationResult } from "../session/streaming-output";
|
|
4
|
+
import type { OutputMeta, TruncationOptions, TruncationSummaryOptions, TruncationTextOptions } from "./output-meta";
|
|
5
|
+
type ToolContent = Array<TextContent | ImageContent>;
|
|
6
|
+
type DetailsWithMeta = {
|
|
7
|
+
meta?: OutputMeta;
|
|
8
|
+
};
|
|
9
|
+
export declare class ToolResultBuilder<TDetails extends DetailsWithMeta> {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(details?: TDetails);
|
|
12
|
+
text(text: string): this;
|
|
13
|
+
content(content: ToolContent): this;
|
|
14
|
+
truncation(result: TruncationResult, options: TruncationOptions): this;
|
|
15
|
+
truncationFromSummary(summary: OutputSummary, options: TruncationSummaryOptions): this;
|
|
16
|
+
truncationFromText(text: string, options: TruncationTextOptions): this;
|
|
17
|
+
limits(limits: {
|
|
18
|
+
matchLimit?: number;
|
|
19
|
+
resultLimit?: number;
|
|
20
|
+
headLimit?: number;
|
|
21
|
+
columnMax?: number;
|
|
22
|
+
}): this;
|
|
23
|
+
sourceUrl(value: string): this;
|
|
24
|
+
sourcePath(value: string): this;
|
|
25
|
+
sourceInternal(value: string): this;
|
|
26
|
+
/** Flag the result as a non-throwing failure (agent-loop surfaces it as a tool error). */
|
|
27
|
+
error(value?: boolean): this;
|
|
28
|
+
/** Marks the result contextually useless — compaction may elide it once consumed. */
|
|
29
|
+
useless(value?: boolean): this;
|
|
30
|
+
done(): AgentToolResult<TDetails>;
|
|
31
|
+
}
|
|
32
|
+
export declare function toolResult<TDetails extends DetailsWithMeta>(details?: TDetails): ToolResultBuilder<TDetails>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface ToolTimeoutConfig {
|
|
2
|
+
/** Default timeout in seconds when agent omits the field */
|
|
3
|
+
default: number;
|
|
4
|
+
/** Minimum allowed timeout in seconds */
|
|
5
|
+
min: number;
|
|
6
|
+
/** Maximum allowed timeout in seconds (per-tool ceiling) */
|
|
7
|
+
max: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const TOOL_TIMEOUTS: {
|
|
10
|
+
readonly bash: {
|
|
11
|
+
readonly default: 300;
|
|
12
|
+
readonly min: 1;
|
|
13
|
+
readonly max: 3600;
|
|
14
|
+
};
|
|
15
|
+
readonly eval: {
|
|
16
|
+
readonly default: 30;
|
|
17
|
+
readonly min: 1;
|
|
18
|
+
readonly max: 3600;
|
|
19
|
+
};
|
|
20
|
+
readonly browser: {
|
|
21
|
+
readonly default: 30;
|
|
22
|
+
readonly min: 1;
|
|
23
|
+
readonly max: 300;
|
|
24
|
+
};
|
|
25
|
+
readonly computer: {
|
|
26
|
+
readonly default: 120;
|
|
27
|
+
readonly min: 1;
|
|
28
|
+
readonly max: 300;
|
|
29
|
+
};
|
|
30
|
+
readonly ssh: {
|
|
31
|
+
readonly default: 60;
|
|
32
|
+
readonly min: 1;
|
|
33
|
+
readonly max: 3600;
|
|
34
|
+
};
|
|
35
|
+
readonly fetch: {
|
|
36
|
+
readonly default: 20;
|
|
37
|
+
readonly min: 1;
|
|
38
|
+
readonly max: 45;
|
|
39
|
+
};
|
|
40
|
+
readonly debug: {
|
|
41
|
+
readonly default: 30;
|
|
42
|
+
readonly min: 5;
|
|
43
|
+
readonly max: 300;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type ToolWithTimeout = keyof typeof TOOL_TIMEOUTS;
|
|
47
|
+
/**
|
|
48
|
+
* Clamp a raw timeout to the allowed range for a tool.
|
|
49
|
+
*
|
|
50
|
+
* When `rawTimeout` is undefined the tool's `default` is used. A positive
|
|
51
|
+
* `maxTimeout` (the `tools.maxTimeout` global ceiling) caps the *resolved*
|
|
52
|
+
* value — including the default-fallback path — before the per-tool `min`/`max`
|
|
53
|
+
* floor and ceiling apply, so a configured global cap governs calls where the
|
|
54
|
+
* agent omits `timeout`, not only explicitly-passed values. `maxTimeout <= 0`
|
|
55
|
+
* means no global cap.
|
|
56
|
+
*/
|
|
57
|
+
export declare function clampTimeout(tool: ToolWithTimeout, rawTimeout?: number, maxTimeout?: number): number;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback, ToolApprovalDecision } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "../../omp/sdk.ts";
|
|
3
|
+
import type { OutputMeta } from "../../omp/tools/output-meta.ts";
|
|
4
|
+
import { type XdevDispatch } from "../../omp/tools/resolve.ts";
|
|
5
|
+
declare const writeSchema: import("@oh-my-pi/omptype").FluentType<{
|
|
6
|
+
path: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}, {
|
|
9
|
+
path: string;
|
|
10
|
+
content: string;
|
|
11
|
+
}>;
|
|
12
|
+
export type WriteToolInput = typeof writeSchema.infer;
|
|
13
|
+
/** Details returned by the write tool for TUI rendering */
|
|
14
|
+
export interface WriteToolDetails {
|
|
15
|
+
meta?: OutputMeta;
|
|
16
|
+
/** Set when the file was auto-chmod'd because content begins with a `#!` shebang. */
|
|
17
|
+
madeExecutable?: boolean;
|
|
18
|
+
/** Absolute filesystem path the write resolved to. Used by the renderer to wrap
|
|
19
|
+
* the (possibly cwd-relative) header path in an OSC 8 `file://` hyperlink. */
|
|
20
|
+
resolvedPath?: string;
|
|
21
|
+
/** Set when the write dispatched an `xd://` tool device; drives renderer delegation. */
|
|
22
|
+
xdev?: XdevDispatch;
|
|
23
|
+
}
|
|
24
|
+
type WriteParams = WriteToolInput;
|
|
25
|
+
/**
|
|
26
|
+
* Write tool implementation.
|
|
27
|
+
*
|
|
28
|
+
* Creates or overwrites files with optional LSP formatting and diagnostics.
|
|
29
|
+
*/
|
|
30
|
+
export declare class WriteTool implements AgentTool<typeof writeSchema, WriteToolDetails> {
|
|
31
|
+
#private;
|
|
32
|
+
private readonly session;
|
|
33
|
+
readonly name = "write";
|
|
34
|
+
readonly approval: (args: unknown) => ToolApprovalDecision;
|
|
35
|
+
readonly formatApprovalDetails: (args: unknown) => string[];
|
|
36
|
+
readonly label = "Write";
|
|
37
|
+
readonly description: string;
|
|
38
|
+
readonly parameters: import("@oh-my-pi/omptype").FluentType<{
|
|
39
|
+
path: string;
|
|
40
|
+
content: string;
|
|
41
|
+
}, {
|
|
42
|
+
path: string;
|
|
43
|
+
content: string;
|
|
44
|
+
}>;
|
|
45
|
+
readonly strict = true;
|
|
46
|
+
readonly concurrency = "exclusive";
|
|
47
|
+
readonly loadMode = "essential";
|
|
48
|
+
/** Stream matchers should see the real file content, not its JSON-escaped argument encoding. */
|
|
49
|
+
matcherDigest(args: unknown): string | undefined;
|
|
50
|
+
constructor(session: ToolSession);
|
|
51
|
+
execute(_toolCallId: string, { path: rawPath, content }: WriteParams, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<WriteToolDetails>, context?: AgentToolContext): Promise<AgentToolResult<WriteToolDetails>>;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-write channel for the write/edit engines.
|
|
3
|
+
*
|
|
4
|
+
* OMP routes every edit/write through an LSP writethrough (format +
|
|
5
|
+
* diagnostics). DSH has no LSP infrastructure (plan.md 拍板#5 cuts LSP), so
|
|
6
|
+
* the channel performs the actual file write directly: the edit itself is
|
|
7
|
+
* fully functional; formatting/diagnostics simply do not exist as a DSH
|
|
8
|
+
* capability. LSP-only parameters (batch request, deferred-diagnostics
|
|
9
|
+
* handle) are not part of the DSH signature.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Callback type for the file write channel. DSH's writethrough writes the
|
|
13
|
+
* content to `dst` (via the provided file handle when present) and returns
|
|
14
|
+
* nothing.
|
|
15
|
+
*/
|
|
16
|
+
export type WritethroughCallback = (dst: string, content: string, signal?: AbortSignal, file?: {
|
|
17
|
+
write(content: string): Promise<void>;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
/** Write `content` to `dst` (or the passed file handle) — no LSP pass. */
|
|
20
|
+
export declare function writethroughNoop(dst: string, content: string, _signal?: AbortSignal, file?: {
|
|
21
|
+
write(content: string): Promise<void>;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/** Async UTF-8 write (node:fs) used when no file handle is supplied. */
|
|
24
|
+
export declare function writeFileUtf8(dst: string, content: string): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface LineSpan {
|
|
2
|
+
startLine: number;
|
|
3
|
+
endLine: number;
|
|
4
|
+
}
|
|
5
|
+
/** Where the source came from, so tree-sitter can pick a grammar. */
|
|
6
|
+
export interface BlockContextSource {
|
|
7
|
+
path?: string;
|
|
8
|
+
lang?: string;
|
|
9
|
+
}
|
|
10
|
+
export type LineEntry = {
|
|
11
|
+
kind: "line";
|
|
12
|
+
lineNumber: number;
|
|
13
|
+
text: string;
|
|
14
|
+
context: boolean;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "ellipsis";
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the off-window boundary lines for a visible window: tree-sitter
|
|
20
|
+
* syntactic spans first (covers brace and indentation languages), falling back
|
|
21
|
+
* to a lexical bracket scan when the grammar is unavailable. Returns a map of
|
|
22
|
+
* `lineNumber → source text` for the lines to surface, never including a line
|
|
23
|
+
* already visible.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findBlockContextLines(fullLines: readonly string[], visibleInput: ReadonlySet<number> | readonly number[], source?: BlockContextSource): Map<number, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Build display entries for `visibleSpans` plus any off-window block-boundary
|
|
28
|
+
* lines, in source order, with `{ kind: "ellipsis" }` markers inserted across
|
|
29
|
+
* non-contiguous gaps. `options.lineText` lets callers substitute display text
|
|
30
|
+
* (e.g. column-truncated lines) for a given line number.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildLineEntriesWithBlockContext(fullLines: readonly string[], visibleSpans: readonly LineSpan[], source?: BlockContextSource, options?: {
|
|
33
|
+
lineText?: (lineNumber: number, sourceText: string, context: boolean) => string;
|
|
34
|
+
}): LineEntry[];
|
|
35
|
+
export declare function lineEntriesToPlainText(entries: readonly LineEntry[], ellipsis?: string): string;
|