@xiaoso/dsh-tool-plus 0.1.0-beta.2 → 0.1.0-beta.4
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/README.en.md +122 -0
- package/README.md +3 -2
- package/THIRD_PARTY_NOTICES.md +4 -35
- package/lib/abort-B7izMMna.mjs +51 -0
- package/lib/abort-D1_Z5Ut5.mjs +51 -0
- package/lib/abort-dIkZBV7Q.mjs +51 -0
- package/lib/amazon-bedrock-B0nxT06F.mjs +917 -0
- package/lib/amazon-bedrock-D-shAr1X.mjs +917 -0
- package/lib/amazon-bedrock-WQhvjHYu.mjs +917 -0
- package/lib/anthropic-BWsZFzU8.mjs +262 -0
- package/lib/anthropic-CJCauvYz.mjs +3115 -0
- package/lib/anthropic-CMT1Qj1t.mjs +3115 -0
- package/lib/anthropic-CZghe_9U.mjs +3115 -0
- package/lib/anthropic-sCMH7JID.mjs +262 -0
- package/lib/anthropic-tTntD8BD.mjs +262 -0
- package/lib/api-key-login-BzqNdM2y.mjs +157 -0
- package/lib/api-key-login-CWVwvHT1.mjs +157 -0
- package/lib/api-key-login-CpzSezsi.mjs +157 -0
- package/lib/aws-credentials-8Mgn5MAy.mjs +867 -0
- package/lib/aws-credentials-CXryMobh.mjs +867 -0
- package/lib/aws-credentials-ChG79ey-.mjs +867 -0
- package/lib/azure-openai-responses-CNkHiLUh.mjs +274 -0
- package/lib/azure-openai-responses-Cgmc-rbL.mjs +274 -0
- package/lib/azure-openai-responses-DuukbD0F.mjs +274 -0
- package/lib/bun-shim.mjs +252 -12
- package/lib/bundled-references-CSuBco5p.mjs +55 -0
- package/lib/bundled-references-Cavaffah.mjs +55 -0
- package/lib/bundled-references-sLN0YdXU.mjs +55 -0
- package/lib/callback-server-BEFNf-jf.mjs +398 -0
- package/lib/callback-server-CQ5Jo8F-.mjs +398 -0
- package/lib/callback-server-DDSrZ6l_.mjs +398 -0
- package/lib/client.js +111 -41
- package/lib/cursor-B3zg7EHj.mjs +273 -0
- package/lib/cursor-B6TUEmgP.mjs +135 -0
- package/lib/cursor-BIQfBC6V.mjs +135 -0
- package/lib/cursor-D8gvtTL3.mjs +135 -0
- package/lib/cursor-DNk6eXDd.mjs +5470 -0
- package/lib/cursor-DkSX2h3H.mjs +5441 -0
- package/lib/cursor-MjSm74IJ.mjs +273 -0
- package/lib/cursor-aJrXeYCb.mjs +273 -0
- package/lib/cursor-mJQwUKXK.mjs +5441 -0
- package/lib/device-code-DBo3B5nh.mjs +51 -0
- package/lib/device-code-DIb0FU-H.mjs +51 -0
- package/lib/device-code-OI_tQcmc.mjs +51 -0
- package/lib/devin-BHZZyMhO.mjs +95 -0
- package/lib/devin-BK7DHeca.mjs +114 -0
- package/lib/devin-CfMp3cXS.mjs +95 -0
- package/lib/devin-CldyPD8K.mjs +95 -0
- package/lib/devin-CzRpTUOA.mjs +114 -0
- package/lib/devin-D9zR5B_R.mjs +542 -0
- package/lib/devin-DXOeNyU7.mjs +542 -0
- package/lib/devin-Q1yem3lp.mjs +114 -0
- package/lib/devin-vNZTNUON.mjs +542 -0
- package/lib/error-B3bevhrs.mjs +1449 -0
- package/lib/error-Dd8DIqs-.mjs +1449 -0
- package/lib/error-yCSG0mGC.mjs +1449 -0
- package/lib/event-stream-BDPi64mK.mjs +151 -0
- package/lib/event-stream-BbFZJy-z.mjs +151 -0
- package/lib/event-stream-loUa0s1T.mjs +151 -0
- package/lib/fs-promises-shim-Bx0fpxuk.mjs +57 -0
- package/lib/github-copilot-4GaMtQmg.mjs +208 -0
- package/lib/github-copilot-B1yiyVRh.mjs +104 -0
- package/lib/github-copilot-B2HGSIJK.mjs +104 -0
- package/lib/github-copilot-BWT3eAOF.mjs +208 -0
- package/lib/github-copilot-CYkjeTi3.mjs +208 -0
- package/lib/github-copilot-jscUZ8Hf.mjs +104 -0
- package/lib/gitlab-duo-CM7Ref1H.mjs +155 -0
- package/lib/gitlab-duo-akICyfeD.mjs +155 -0
- package/lib/gitlab-duo-gubO4FNw.mjs +155 -0
- package/lib/gitlab-duo-workflow-BGAF6JDw.mjs +91 -0
- package/lib/gitlab-duo-workflow-CSEgYk3N.mjs +91 -0
- package/lib/gitlab-duo-workflow-D78tdn8E.mjs +91 -0
- package/lib/google-BS4T25Pn.mjs +30 -0
- package/lib/google-TFe-7-of.mjs +30 -0
- package/lib/google-antigravity-DGmwC2KV.mjs +198 -0
- package/lib/google-antigravity-DNYhgTpA.mjs +198 -0
- package/lib/google-antigravity-Dlkdhahq.mjs +198 -0
- package/lib/google-auth-B6gjsZvg.mjs +232 -0
- package/lib/google-auth-De7_s3eo.mjs +232 -0
- package/lib/google-auth-DhqpOYrX.mjs +232 -0
- package/lib/google-gemini-cli-BG_LRdIV.mjs +850 -0
- package/lib/google-gemini-cli-CWu8HvXW.mjs +211 -0
- package/lib/google-gemini-cli-Cb97bzQc.mjs +850 -0
- package/lib/google-gemini-cli-Cqds_Q5T.mjs +850 -0
- package/lib/google-gemini-cli-Dsztq0N5.mjs +211 -0
- package/lib/google-gemini-cli-zJhiOcND.mjs +211 -0
- package/lib/google-oauth-shared-CuEHaDDj.mjs +147 -0
- package/lib/google-oauth-shared-CwNWYdmR.mjs +147 -0
- package/lib/google-oauth-shared-yqlyqPPC.mjs +147 -0
- package/lib/google-shared-CgKmmdO3.mjs +760 -0
- package/lib/google-shared-Dr-VG-ap.mjs +760 -0
- package/lib/google-shared-DzhCb9b0.mjs +760 -0
- package/lib/google-vertex-BDN2tLaD.mjs +99 -0
- package/lib/google-vertex-DopVOQOG.mjs +99 -0
- package/lib/google-vertex-kscbkyRb.mjs +99 -0
- package/lib/google-zyDOG9x7.mjs +30 -0
- package/lib/identity-Da1GPU9a.mjs +219 -0
- package/lib/identity-DnB63pS7.mjs +219 -0
- package/lib/identity-xRP7_eSR.mjs +219 -0
- package/lib/idle-iterator-Baoyn3Hp.mjs +366 -0
- package/lib/idle-iterator-C6XbWcuB.mjs +366 -0
- package/lib/idle-iterator-DUjKQEGT.mjs +366 -0
- package/lib/index.mjs +4608 -3935
- package/lib/kimi--wUOWER5.mjs +236 -0
- package/lib/kimi-DMVI-zrZ.mjs +236 -0
- package/lib/kimi-Dh0pv3WZ.mjs +236 -0
- package/lib/markit-BL3cH47U.mjs +1417 -0
- package/lib/markit-BNiNY6SE.mjs +1417 -0
- package/lib/markit-M0jhziqU.mjs +1417 -0
- package/lib/minimax-code-BK-3eBbz.mjs +53 -0
- package/lib/minimax-code-DCbuA6Yk.mjs +53 -0
- package/lib/minimax-code-Uq8Qu9LW.mjs +53 -0
- package/lib/models-CfT4coYT.mjs +104660 -0
- package/lib/models-D_XnT6ay.mjs +104660 -0
- package/lib/models-SGASygJ3.mjs +104660 -0
- package/lib/ollama-BQMGPxtV.mjs +589 -0
- package/lib/ollama-DPzBmq89.mjs +589 -0
- package/lib/ollama-DoBz5SFm.mjs +589 -0
- package/lib/openai-codex-Bi-4S4PX.mjs +255 -0
- package/lib/openai-codex-CQL_kvYL.mjs +255 -0
- package/lib/openai-codex-Ch8CkT3p.mjs +255 -0
- package/lib/openai-codex-responses-CvxL_FMF.mjs +3144 -0
- package/lib/openai-codex-responses-Cz-2qpC7.mjs +3144 -0
- package/lib/openai-codex-responses-pejZgdZo.mjs +3144 -0
- package/lib/openai-completions-CF8IyNtP.mjs +1360 -0
- package/lib/openai-completions-DIf361kF.mjs +1360 -0
- package/lib/openai-completions-i8doczAk.mjs +1360 -0
- package/lib/openai-reasoning-fallback-DGVVLgd1.mjs +286 -0
- package/lib/openai-reasoning-fallback-Nj6yB2rY.mjs +286 -0
- package/lib/openai-reasoning-fallback-OdJREP1o.mjs +286 -0
- package/lib/openai-responses-BqXJInHX.mjs +867 -0
- package/lib/openai-responses-DTkBiiy-.mjs +867 -0
- package/lib/openai-responses-Db_a-U4-.mjs +867 -0
- package/lib/opencode-DaJjcUbf.mjs +38 -0
- package/lib/opencode-DhMolSoB.mjs +38 -0
- package/lib/opencode-Rq_Q2vAO.mjs +38 -0
- package/lib/perplexity-9b-RQ0mV.mjs +194 -0
- package/lib/perplexity-C4iLVMUj.mjs +194 -0
- package/lib/perplexity-Uu7Jzg5b.mjs +194 -0
- package/lib/proxy-DDqrmjjC.mjs +190 -0
- package/lib/proxy-ZtUcl6r5.mjs +190 -0
- package/lib/proxy-pM_NIv-H.mjs +190 -0
- package/lib/request-debug-HJMoJncL.mjs +183 -0
- package/lib/sanitize-text-CfcXzw5X.mjs +33 -0
- package/lib/scrapers-BkFfcPHj.mjs +9198 -0
- package/lib/scrapers-CL-WgdU1.mjs +9198 -0
- package/lib/scrapers-CVptboMs.mjs +9198 -0
- package/lib/scrapers-CipyKyCH.mjs +9198 -0
- package/lib/scrapers-DGfrYhtw.mjs +9198 -0
- package/lib/scrapers-DSUPYoUF.mjs +9198 -0
- package/lib/scrapers-DZ2GXmp7.mjs +9198 -0
- package/lib/scrapers-nhQAvc8d.mjs +9198 -0
- package/lib/shell-snapshot-fn-env.sh +67 -43
- package/lib/src-BgpusnsB.mjs +5076 -0
- package/lib/src-DTid0g4K.mjs +5001 -0
- package/lib/src-lDmkSRbm.mjs +5006 -0
- package/lib/stream-BlldLkVq.mjs +10236 -0
- package/lib/stream-CRtexYLe.mjs +10236 -0
- package/lib/stream-C_RAoxJC.mjs +10236 -0
- package/lib/stream-markup-healing-2toHXWXM.mjs +491 -0
- package/lib/stream-markup-healing-DMsxBx1L.mjs +491 -0
- package/lib/stream-markup-healing-KMkiAA00.mjs +491 -0
- package/lib/turndown-DN7ByzEI.mjs +667 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/config/fields.d.ts +1 -1
- package/lib/types/config/settings.d.ts +25 -3
- package/lib/types/config/truncate.d.ts +9 -5
- package/lib/types/tools/bash/background.d.ts +1 -1
- package/lib/types/tools/bash/bash-executor.d.ts +4 -0
- package/lib/types/tools/bash/bash-interceptor.d.ts +10 -8
- package/lib/types/tools/bash/cd-workdir.d.ts +35 -0
- package/lib/types/tools/bash/non-interactive-env.d.ts +2 -0
- package/lib/types/tools/bash/render.d.ts +4 -3
- package/lib/types/tools/bash/sanitize-text.d.ts +5 -0
- package/lib/types/tools/bash/shell-snapshot.d.ts +4 -1
- package/lib/types/tools/bash/shell-tokenize.d.ts +60 -0
- package/lib/types/tools/bash/streaming-output.d.ts +12 -212
- 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/edit/adapter/index.d.ts +25 -3
- package/lib/types/tools/edit/adapter/tools/auto-generated-guard.d.ts +7 -17
- package/lib/types/tools/glob/adapter/index.d.ts +27 -1
- package/lib/types/tools/grep/adapter/index.d.ts +29 -1
- package/lib/types/tools/omp/edit/dispatch.d.ts +43 -0
- package/lib/types/tools/omp/edit/hashline/noop-loop-guard.d.ts +3 -1
- package/lib/types/tools/omp/sdk.d.ts +6 -0
- package/lib/types/tools/omp/tools/auto-generated-guard.d.ts +20 -0
- package/lib/types/tools/omp/tools/fetch.d.ts +2 -0
- package/lib/types/tools/omp/tools/read.d.ts +2 -8
- package/lib/types/tools/omp/tools/write.d.ts +4 -4
- package/lib/types/tools/omp/utils/image-loading.d.ts +10 -36
- package/lib/types/tools/read/adapter/index.d.ts +4 -1
- package/lib/types/tools/read-image/index.d.ts +4 -0
- package/lib/types/tools/shared/auto-generated-guard.dsh.d.ts +16 -4
- package/lib/types/tools/shared/bun-shim.d.ts +39 -3
- package/lib/types/tools/shared/fs-promises-shim.d.ts +3 -1
- package/lib/types/tools/shared/image-bridge.d.ts +98 -0
- package/lib/types/tools/shared/omp-prompt.d.ts +17 -9
- package/lib/types/tools/shared/session-state.d.ts +9 -3
- package/lib/utils-2Wq2eATG.mjs +8119 -0
- package/lib/utils-BnX8O3vi.mjs +12303 -0
- package/lib/utils-Bw139LTz.mjs +8119 -0
- package/lib/utils-CE8N8P4Q.mjs +12315 -0
- package/lib/utils-CZw4tVZQ.mjs +12315 -0
- package/lib/utils-C_MrQ_0z.mjs +12301 -0
- package/lib/utils-CiGN7OHR.mjs +12315 -0
- package/lib/utils-Cp76gCyk.mjs +8119 -0
- package/lib/utils-D0GRDgAr.mjs +12315 -0
- package/lib/utils-D0Z1fyoO.mjs +12299 -0
- package/lib/utils-D2YknRk4.mjs +51 -0
- package/lib/utils-DppGHXQB.mjs +51 -0
- package/lib/utils-DzXZDfYc.mjs +51 -0
- package/lib/utils-W8WdSBpX.mjs +12315 -0
- package/lib/vision-guard-01qSwFpf.mjs +92 -0
- package/lib/vision-guard-BDD4OrKo.mjs +92 -0
- package/lib/vision-guard-DzZGaOga.mjs +92 -0
- package/lib/wafer-CgtPHerf.mjs +17 -0
- package/lib/wafer-DRU0EjZX.mjs +17 -0
- package/lib/wafer-cBtrn6q9.mjs +17 -0
- package/lib/xai-oauth-Buk8XVvM.mjs +446 -0
- package/lib/xai-oauth-CMal8l1O.mjs +446 -0
- package/lib/xai-oauth-DPHDXKD7.mjs +446 -0
- package/lib/xiaomi-CZgwvX2G.mjs +157 -0
- package/lib/xiaomi-D2qT5cAC.mjs +157 -0
- package/lib/xiaomi-Dd87KSg5.mjs +157 -0
- package/lib/zai-7DWMkEqM.mjs +203 -0
- package/lib/zai-C59YnomG.mjs +203 -0
- package/lib/zai-CFeOt-53.mjs +203 -0
- package/lib/zip-Cg9ANN_U.mjs +1316 -0
- package/lib/zip-D36ZKsP8.mjs +1316 -0
- package/lib/zip-D6QXpvaJ.mjs +1316 -0
- package/package.json +14 -10
- package/presets/package.json +1 -1
- package/presets/tool-plus-ptc/preset.yml +1 -1
- package/presets/tool-plus-standard/preset.yml +1 -1
|
@@ -64,7 +64,7 @@ export interface ToolPlusTab {
|
|
|
64
64
|
fields: readonly string[];
|
|
65
65
|
}
|
|
66
66
|
/** Identifiers of every tool tab. */
|
|
67
|
-
export type ToolPlusToolId = 'bash' | 'read' | 'writeEdit' | 'grep' | 'astGrep' | 'astEdit'
|
|
67
|
+
export type ToolPlusToolId = 'bash' | 'read' | 'writeEdit' | 'grep' | 'astGrep' | 'astEdit';
|
|
68
68
|
/** Field group ids -> locale key of the group heading. */
|
|
69
69
|
export declare const TOOL_PLUS_GROUP_LABELS: Record<string, BashPlusLocaleKey>;
|
|
70
70
|
/**
|
|
@@ -75,6 +75,7 @@ export interface RuntimeConfig {
|
|
|
75
75
|
readDefaultLimit: number;
|
|
76
76
|
readLineNumbers: boolean;
|
|
77
77
|
readRenderMarkdown: boolean;
|
|
78
|
+
readConcurrentSafe: boolean;
|
|
78
79
|
grepContextBefore: number;
|
|
79
80
|
grepContextAfter: number;
|
|
80
81
|
astGrepEnabled: boolean;
|
|
@@ -82,13 +83,27 @@ export interface RuntimeConfig {
|
|
|
82
83
|
fetchEnabled: boolean;
|
|
83
84
|
fetchMaxTimeoutSeconds: number;
|
|
84
85
|
imagesAutoResize: boolean;
|
|
85
|
-
|
|
86
|
+
imagesBlockImages: boolean;
|
|
87
|
+
imagesExcludeWebp: boolean;
|
|
88
|
+
imagesInputMaxBytes: number;
|
|
89
|
+
imagesResizeMaxSide: number;
|
|
90
|
+
imagesResizeMaxBytes: number;
|
|
91
|
+
imagesResizeMinSide: number;
|
|
92
|
+
imagesResizeJpegQuality: number;
|
|
86
93
|
}
|
|
87
94
|
/** Settings namespace of this plugin, served to the web Plugins page. */
|
|
88
95
|
export declare const BASH_PLUS_SETTINGS_NS: import("@deepseek-ai/dsh-settings").SettingsNamespace;
|
|
89
96
|
/** OMP-parity defaults for the completion-message truncation policy. */
|
|
90
97
|
export declare const DEFAULT_OUTPUT_TRUNCATE: OutputTruncateConfig;
|
|
91
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Timing knobs (ms). DEFAULT_MAX_TIMEOUT_MS is OMP-parity (= upstream bash
|
|
100
|
+
* per-tool max 3600s); DEFAULT_TIMEOUT_MS was deliberately relaxed from
|
|
101
|
+
* 300_000 to 3_600_000 with the bash-plus settings card (763023e,
|
|
102
|
+
* 2026-08-19) — NOT OMP-parity (OMP bash default is 300s), compensated by
|
|
103
|
+
* auto-backgrounding after DEFAULT_AUTO_BACKGROUND_MS. By design there is no
|
|
104
|
+
* upstream `tools.maxTimeout` global-cap equivalent: maxTimeoutMs always
|
|
105
|
+
* applies. (second-impl-audit.md S-11 终局, 2026-08-29.)
|
|
106
|
+
*/
|
|
92
107
|
export declare const DEFAULT_TIMEOUT_MS = 3600000;
|
|
93
108
|
export declare const DEFAULT_MAX_TIMEOUT_MS = 3600000;
|
|
94
109
|
export declare const DEFAULT_AUTO_BACKGROUND_MS = 60000;
|
|
@@ -136,6 +151,7 @@ export interface Config {
|
|
|
136
151
|
readDefaultLimit?: number;
|
|
137
152
|
readLineNumbers?: boolean;
|
|
138
153
|
readRenderMarkdown?: boolean;
|
|
154
|
+
readConcurrentSafe?: boolean;
|
|
139
155
|
grepContextBefore?: number;
|
|
140
156
|
grepContextAfter?: number;
|
|
141
157
|
astGrepEnabled?: boolean;
|
|
@@ -143,7 +159,13 @@ export interface Config {
|
|
|
143
159
|
fetchEnabled?: boolean;
|
|
144
160
|
fetchMaxTimeoutSeconds?: number;
|
|
145
161
|
imagesAutoResize?: boolean;
|
|
146
|
-
|
|
162
|
+
imagesBlockImages?: boolean;
|
|
163
|
+
imagesExcludeWebp?: boolean;
|
|
164
|
+
imagesInputMaxBytes?: number;
|
|
165
|
+
imagesResizeMaxSide?: number;
|
|
166
|
+
imagesResizeMaxBytes?: number;
|
|
167
|
+
imagesResizeMinSide?: number;
|
|
168
|
+
imagesResizeJpegQuality?: number;
|
|
147
169
|
}
|
|
148
170
|
/**
|
|
149
171
|
* Runtime configuration schema for the plugin. The namespace resolves through
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Config-driven output truncation for background→foreground completion text
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Config-driven output truncation for background→foreground completion text.
|
|
3
|
+
* Provenance (second-impl-audit.md S-1, 2026-08-29): the truncation
|
|
4
|
+
* primitives (truncateHead/Middle/Tail, TruncationResult) are OMP 17.3.5
|
|
5
|
+
* verbatim, imported directly from `../omp/session/streaming-output.ts`;
|
|
6
|
+
* the composition layer below (trigger threshold + retention mode + notice
|
|
7
|
+
* format) is a plugin-specific design shipped with the bash-plus settings
|
|
8
|
+
* card (763023e, 2026-08-19) — `applyConfiguredTruncation` has no
|
|
9
|
+
* counterpart in refs/oh-my-pi 17.3.5, so the old "ported verbatim from the
|
|
10
|
+
* OMP bash-runtime" claim was unverifiable and has been dropped.
|
|
7
11
|
* @module @xiaoso/dsh-tool-plus/truncate
|
|
8
12
|
*/
|
|
9
13
|
import type { OutputTruncateConfig } from './settings.ts';
|
|
@@ -24,7 +24,7 @@ export interface StartBashJobOptions {
|
|
|
24
24
|
sessionId: string;
|
|
25
25
|
command: string;
|
|
26
26
|
cwd: string;
|
|
27
|
-
/** Effective deadline in ms; `undefined
|
|
27
|
+
/** Effective deadline in ms; `undefined`/0 disables the job deadline. */
|
|
28
28
|
timeoutMs: number | undefined;
|
|
29
29
|
/** Command-scoped environment (already merged with dshEnv). */
|
|
30
30
|
env: Record<string, string> | undefined;
|
|
@@ -63,6 +63,8 @@ export interface BashResult {
|
|
|
63
63
|
output: string;
|
|
64
64
|
exitCode: number | undefined;
|
|
65
65
|
cancelled: boolean;
|
|
66
|
+
/** True when the command was killed by its timeout deadline (not a user abort). */
|
|
67
|
+
timedOut?: boolean;
|
|
66
68
|
truncated: boolean;
|
|
67
69
|
totalLines: number;
|
|
68
70
|
totalBytes: number;
|
|
@@ -91,4 +93,6 @@ export interface BashResult {
|
|
|
91
93
|
export declare function closeSessionShells(sessionId: string): void;
|
|
92
94
|
/** Translate `ShellMinimizerSettings` into native `MinimizerOptions`, or `undefined` when disabled. */
|
|
93
95
|
export declare function buildMinimizerOptions(group: ShellMinimizerSettings): MinimizerOptions | undefined;
|
|
96
|
+
export declare function needsInteractiveShellArg(shell: string): boolean;
|
|
97
|
+
export declare function ensureInteractiveShellArgs(shell: string, args: string[]): string[];
|
|
94
98
|
export declare function executeBash(command: string, options?: BashExecutorOptions): Promise<BashResult>;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bash intent interceptor - redirects common shell patterns to proper tools.
|
|
3
|
-
*
|
|
4
|
-
* When an LLM calls bash with patterns like `grep`, `cat`, `find`, etc.,
|
|
5
|
-
* this interceptor provides helpful error messages directing them to use
|
|
6
|
-
* the specialized tools instead.
|
|
7
|
-
*/
|
|
8
1
|
export interface BashInterceptorRule {
|
|
9
2
|
pattern: string;
|
|
10
3
|
flags?: string;
|
|
@@ -12,6 +5,15 @@ export interface BashInterceptorRule {
|
|
|
12
5
|
message: string;
|
|
13
6
|
allowSubcommands?: string[];
|
|
14
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* 规则表对齐上游 refs/oh-my-pi/packages/coding-agent/src/config/settings-schema.ts:325-387(10 条)。
|
|
10
|
+
* 既有 6 条(read/grep/glob/edit×3)语义与消息文案保持不变;新增 echo/printf 重定向 → write(上游 :356-367)。
|
|
11
|
+
* hub 类 3 条(nohup/后台语法、dev/start 服务、--watch,上游 :368-386)按映射决策加入:
|
|
12
|
+
* pattern 逐字照抄;tool hub → bash(DSH 等价受管机制 = bash 工具 run_in_background:true,
|
|
13
|
+
* startBashJob → jobs 注册表 → job_output 读输出 / job_kill 停止);文案改写为 run_in_background 引导。
|
|
14
|
+
* DSH 无 hub 的 stdin-send/restart/跨实例观察能力,属有意不移植。
|
|
15
|
+
* `bashInterceptor.patterns` 配置键不在本次范围,未引入。
|
|
16
|
+
*/
|
|
15
17
|
export declare const DEFAULT_BASH_INTERCEPTOR_RULES: BashInterceptorRule[];
|
|
16
18
|
export interface InterceptionResult {
|
|
17
19
|
/** If true, the bash command should be blocked */
|
|
@@ -28,4 +30,4 @@ export interface InterceptionResult {
|
|
|
28
30
|
* @param availableTools Set of tool names that are available
|
|
29
31
|
* @returns InterceptionResult indicating if the command should be blocked
|
|
30
32
|
*/
|
|
31
|
-
export declare function checkBashInterception(command: string, availableTools: string[], rules?: BashInterceptorRule[]): InterceptionResult;
|
|
33
|
+
export declare function checkBashInterception(command: string, availableTools: string[], rules?: BashInterceptorRule[], originalCommand?: string): InterceptionResult;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leading `cd <path> && …` workdir extraction and `~` expansion for the bash
|
|
3
|
+
* tool.
|
|
4
|
+
*
|
|
5
|
+
* Extraction delegates to `extractLeadingCdTarget` (shell-tokenize.ts, verbatim
|
|
6
|
+
* port of upstream tools/shell-tokenize.ts), so redirect prefixes, extra
|
|
7
|
+
* arguments, command substitution, and unterminated quotes all bail and leave
|
|
8
|
+
* the whole command with the shell. `~`/`~/…` prefixes expand against
|
|
9
|
+
* `os.homedir()` with upstream `expandTilde` semantics
|
|
10
|
+
* (refs packages/coding-agent/src/tools/path-utils.ts).
|
|
11
|
+
* @module @xiaoso/dsh-tool-plus/bash/cd-workdir
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Expand a leading `~`/`~/…`/`~\…` prefix to the home directory, matching
|
|
15
|
+
* upstream `expandTilde` (refs tools/path-utils.ts). A bare `~name` is joined
|
|
16
|
+
* under the home directory like upstream (user-home approximation).
|
|
17
|
+
*/
|
|
18
|
+
export declare function expandTilde(filePath: string, home?: string): string;
|
|
19
|
+
/** A leading `cd <path> && …` split into its (tilde-expanded) workdir and the remainder. */
|
|
20
|
+
export interface CdWorkdir {
|
|
21
|
+
/** Tilde-expanded working directory for the leading `cd`. */
|
|
22
|
+
workdir: string;
|
|
23
|
+
/** Command remainder after the top-level `&&`. */
|
|
24
|
+
command: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extract a leading `cd <path> && …` prefix, expanding `~` in the target.
|
|
28
|
+
*
|
|
29
|
+
* Returns `null` when the command does not start with exactly `cd`, one path
|
|
30
|
+
* token, and a top-level `&&` — redirects (`cd /tmp 2>/dev/null && …`), extra
|
|
31
|
+
* arguments, command substitution (`$`, backticks, `(`), and unterminated
|
|
32
|
+
* quotes all leave the whole command for the shell instead of absorbing shell
|
|
33
|
+
* syntax into the structured workdir seam.
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractCdWorkdir(command: string, home?: string): CdWorkdir | null;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Portable command that rejects credential prompts without assuming an FHS layout. */
|
|
2
|
+
export declare const REJECT_PROMPT_COMMAND: string;
|
|
1
3
|
export declare const NON_INTERACTIVE_ENV: Readonly<Record<string, string>>;
|
|
2
4
|
/** Builds the per-command environment for non-interactive child processes. */
|
|
3
5
|
export declare function buildNonInteractiveEnv(overrides?: Record<string, string>, baseEnv?: Record<string, string | undefined>, platform?: NodeJS.Platform): Record<string, string>;
|
|
@@ -17,9 +17,10 @@ export declare function formatWallTimeNotice(wallTimeMs: number): string;
|
|
|
17
17
|
* middle elision, shown range for one-sided truncation) plus elided stats,
|
|
18
18
|
* then the spill-file pointer and a read-back hint. Range reconstruction rides
|
|
19
19
|
* the shared OMP algorithm (`outputMeta().truncationFromSummary`), with the
|
|
20
|
-
* upstream `artifact
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* upstream `artifact://N` clause replaced by the spill-file path — bash spill
|
|
21
|
+
* files are plain files (deliberately not registered in the read tool's
|
|
22
|
+
* artifact:// space, see adapter/spill.ts) and are recovered with `:N-M`
|
|
23
|
+
* inline selectors instead.
|
|
23
24
|
* @returns the notice lines, or `undefined` when output was not truncated.
|
|
24
25
|
*/
|
|
25
26
|
export declare function formatTruncationNotice(value: CollectedOutput): string[] | undefined;
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* malformed path; when it changes the input, replacement characters are
|
|
9
9
|
* dropped and the normalized result goes through the well-formed sanitizer.
|
|
10
10
|
*
|
|
11
|
+
* S-8 normalization: ANSI stripping re-exports the ECMA-48 state machine from
|
|
12
|
+
* `src/tools/shared/bun-shim.ts` — the same function installed as
|
|
13
|
+
* `Bun.stripANSI`; `toWellFormed()` delegates to the native
|
|
14
|
+
* `String.prototype.toWellFormed`.
|
|
15
|
+
*
|
|
11
16
|
* Fast path: well-formed input with no controls or ANSI returns the original
|
|
12
17
|
* string after the control probe.
|
|
13
18
|
*/
|
|
@@ -18,8 +18,11 @@ export declare function sanitizeSnapshotForBrush(content: string): {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a shell snapshot, caching the result.
|
|
20
20
|
* Returns the path to the snapshot file, or null if creation failed.
|
|
21
|
+
*
|
|
22
|
+
* `timeoutMs` is configurable so callers exercising failure handling do not
|
|
23
|
+
* have to wait out the production startup budget.
|
|
21
24
|
*/
|
|
22
|
-
export declare function getOrCreateSnapshot(shell: string, env: Record<string, string | undefined
|
|
25
|
+
export declare function getOrCreateSnapshot(shell: string, env: Record<string, string | undefined>, timeoutMs?: number): Promise<string | null>;
|
|
23
26
|
/**
|
|
24
27
|
* Delete every cached snapshot file and clear the cache. Called from the
|
|
25
28
|
* plugin's disposal path (the pi-gateway original ran this through its
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conservative shell command tokenizer shared by the bash approval-pattern
|
|
3
|
+
* matcher and the gh-cache invalidator.
|
|
4
|
+
*
|
|
5
|
+
* Splits a bash command into independent command segments, each a list of word
|
|
6
|
+
* tokens. Handles single/double-quoted strings, backslash escapes, and the
|
|
7
|
+
* standard operators (`;`, `&&`, `||`, `|`, `&`, `(`, `)`, newlines) as segment
|
|
8
|
+
* boundaries so callers treat the pieces as independent command sequences.
|
|
9
|
+
*
|
|
10
|
+
* It is deliberately not a full POSIX parser — heredocs, command substitution,
|
|
11
|
+
* and arithmetic expansion are out of scope; callers fall through when they
|
|
12
|
+
* cannot find the structure they need.
|
|
13
|
+
*/
|
|
14
|
+
export declare function tokenizeShellSegments(command: string): string[][];
|
|
15
|
+
/**
|
|
16
|
+
* A flat shell command segment with the context needed to decide interception.
|
|
17
|
+
*
|
|
18
|
+
* @see extractFlatShellCommandSegments
|
|
19
|
+
*/
|
|
20
|
+
interface FlatShellCommandSegment {
|
|
21
|
+
/** Original segment text with quoting and escaping preserved. */
|
|
22
|
+
text: string;
|
|
23
|
+
/**
|
|
24
|
+
* True when this segment consumes the previous stage's stdout via an
|
|
25
|
+
* unquoted `|` or `|&`. Blank and comment-only continuation lines preserve
|
|
26
|
+
* the pending pipe state. Such a stage reads piped stdin, so path-based
|
|
27
|
+
* dedicated tools (read/grep/glob) cannot replace it. `||`, `;`, `&`, and
|
|
28
|
+
* `&&` start an independent command and leave this false.
|
|
29
|
+
*/
|
|
30
|
+
pipedStdin: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the flat shell command segments with the original text of each. Unlike
|
|
34
|
+
* `tokenizeShellSegments`, this preserves quoting and escaping so the results
|
|
35
|
+
* are safe to match against user-configured regular expressions, and flags
|
|
36
|
+
* segments that receive piped stdin.
|
|
37
|
+
*
|
|
38
|
+
* The extractor deliberately declines to split syntax whose execution context
|
|
39
|
+
* cannot be determined with this small scanner (heredocs, command substitution,
|
|
40
|
+
* backticks, grouping, and malformed quoting). Callers must still check the
|
|
41
|
+
* complete input in that case.
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractFlatShellCommandSegments(command: string): FlatShellCommandSegment[];
|
|
44
|
+
/**
|
|
45
|
+
* Parses a leading `cd <path> && ...` prefix so the bash tool can route the
|
|
46
|
+
* target through its structured `cwd` parameter when the model omits it.
|
|
47
|
+
*
|
|
48
|
+
* Returns the single path token (quotes and backslash escapes resolved to their
|
|
49
|
+
* literal value) and the command remainder after the top-level `&&`, or `null`
|
|
50
|
+
* when the command does not begin with exactly `cd`, one path token, and a
|
|
51
|
+
* top-level `&&`. The scanner deliberately bails on anything else in the prefix
|
|
52
|
+
* — redirects (`cd /tmp 2>/dev/null && ...`), extra arguments, or paths needing
|
|
53
|
+
* shell expansion (`$`, backticks, `(`) — leaving the whole command for the
|
|
54
|
+
* shell instead of absorbing shell syntax into `cwd`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function extractLeadingCdTarget(command: string): {
|
|
57
|
+
path: string;
|
|
58
|
+
rest: string;
|
|
59
|
+
} | null;
|
|
60
|
+
export {};
|
|
@@ -1,232 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export declare const DEFAULT_MAX_COLUMN = 512;
|
|
1
|
+
import { OutputSink as VerbatimOutputSink, OutputSummary as VerbatimOutputSummary, type OutputSinkOptions } from "../omp/session/streaming-output.ts";
|
|
2
|
+
export * from "../omp/session/streaming-output.ts";
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `0` means unbounded: by default, `artifact://<id>` references preserve the
|
|
8
|
-
* complete raw stream instead of a capped head/tail sample.
|
|
4
|
+
* Verbatim `OutputSummary` 加 DSH 增量字段 `artifactPath`。
|
|
9
5
|
*/
|
|
10
|
-
export
|
|
11
|
-
/** Default head budget; the remainder becomes the rolling tail window. */
|
|
12
|
-
export declare const ARTIFACT_DEFAULT_HEAD_BYTES: number;
|
|
13
|
-
export interface OutputSummary {
|
|
14
|
-
output: string;
|
|
15
|
-
truncated: boolean;
|
|
16
|
-
totalLines: number;
|
|
17
|
-
totalBytes: number;
|
|
18
|
-
outputLines: number;
|
|
19
|
-
outputBytes: number;
|
|
20
|
-
/** Bytes elided from the middle when head-retain mode is active. */
|
|
21
|
-
elidedBytes?: number;
|
|
22
|
-
/** Lines elided from the middle when head-retain mode is active. */
|
|
23
|
-
elidedLines?: number;
|
|
24
|
-
/** Bytes dropped by the per-line column cap (sum across all lines). */
|
|
25
|
-
columnDroppedBytes?: number;
|
|
26
|
-
/** Number of distinct lines that hit the per-line column cap. */
|
|
27
|
-
columnTruncatedLines?: number;
|
|
28
|
-
/** Configured per-line column cap in effect (chars), when > 0. */
|
|
29
|
-
columnMax?: number;
|
|
30
|
-
/** Artifact ID for internal URL access (artifact://<id>) when truncated */
|
|
31
|
-
artifactId?: string;
|
|
6
|
+
export interface OutputSummary extends VerbatimOutputSummary {
|
|
32
7
|
/**
|
|
33
8
|
* Path of the spill file mirroring the raw stream, when one was created.
|
|
34
9
|
* Present even when only the per-line column cap triggered mirroring.
|
|
35
10
|
*/
|
|
36
11
|
artifactPath?: string;
|
|
37
12
|
}
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
spillThreshold?: number;
|
|
43
|
-
/**
|
|
44
|
-
* When > 0, the sink keeps the first `headBytes` of output in addition to
|
|
45
|
-
* the rolling tail window. Output between the two windows is elided
|
|
46
|
-
* (middle elision). Default 0 = tail-only behavior.
|
|
47
|
-
*/
|
|
48
|
-
headBytes?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Per-line byte cap. When > 0, lines wider than `maxColumns` bytes are
|
|
51
|
-
* truncated with an ellipsis at write time; remaining bytes up to the next
|
|
52
|
-
* `\n` are dropped. Cap state persists across chunks so split-mid-line
|
|
53
|
-
* writes still respect the budget. Default 0 = no per-line cap.
|
|
54
|
-
*/
|
|
55
|
-
maxColumns?: number;
|
|
56
|
-
onChunk?: (chunk: string) => void;
|
|
57
|
-
/** Minimum ms between onChunk calls. 0 = every chunk (default). */
|
|
58
|
-
chunkThrottleMs?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Optional cap on bytes written to the artifact-on-disk file. When the cap
|
|
61
|
-
* is hit, the head window is preserved verbatim and subsequent output feeds
|
|
62
|
-
* a rolling tail window; on close, the sink writes a single
|
|
63
|
-
* `[ARTIFACT TRUNCATED: …]` notice between them. Default
|
|
64
|
-
* {@link ARTIFACT_DEFAULT_MAX_BYTES} (unbounded).
|
|
65
|
-
*/
|
|
66
|
-
artifactMaxBytes?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Bytes reserved for the head window of the capped artifact file. The
|
|
69
|
-
* tail window receives `artifactMaxBytes - artifactHeadBytes`. Default
|
|
70
|
-
* {@link ARTIFACT_DEFAULT_HEAD_BYTES}; clamped to `[0, artifactMaxBytes]`.
|
|
71
|
-
*/
|
|
72
|
-
artifactHeadBytes?: number;
|
|
73
|
-
}
|
|
74
|
-
export interface TruncationResult {
|
|
75
|
-
content: string;
|
|
76
|
-
truncated?: boolean;
|
|
77
|
-
truncatedBy?: "lines" | "bytes" | "middle";
|
|
78
|
-
totalLines: number;
|
|
79
|
-
totalBytes: number;
|
|
80
|
-
outputLines?: number;
|
|
81
|
-
outputBytes?: number;
|
|
82
|
-
/** Bytes elided from the middle (truncateMiddle only). */
|
|
83
|
-
elidedBytes?: number;
|
|
84
|
-
/** Lines elided from the middle (truncateMiddle only). */
|
|
85
|
-
elidedLines?: number;
|
|
86
|
-
lastLinePartial?: boolean;
|
|
87
|
-
firstLineExceedsLimit?: boolean;
|
|
88
|
-
}
|
|
89
|
-
export interface TruncationOptions {
|
|
90
|
-
/** Maximum number of lines (default: 3000) */
|
|
91
|
-
maxLines?: number;
|
|
92
|
-
/** Maximum number of bytes (default: 50KB) */
|
|
93
|
-
maxBytes?: number;
|
|
94
|
-
/**
|
|
95
|
-
* For `truncateMiddle`: bytes reserved for the head window. The tail
|
|
96
|
-
* window receives `maxBytes - maxHeadBytes`. Default `floor(maxBytes/2)`.
|
|
97
|
-
*/
|
|
98
|
-
maxHeadBytes?: number;
|
|
99
|
-
/**
|
|
100
|
-
* For `truncateMiddle`: lines reserved for the head window. The tail
|
|
101
|
-
* window receives `maxLines - maxHeadLines`. Default `floor(maxLines/2)`.
|
|
102
|
-
*/
|
|
103
|
-
maxHeadLines?: number;
|
|
104
|
-
}
|
|
105
|
-
/** Result from byte-level truncation helpers. */
|
|
106
|
-
export interface ByteTruncationResult {
|
|
107
|
-
text: string;
|
|
108
|
-
bytes: number;
|
|
109
|
-
}
|
|
110
|
-
export interface TailTruncationNoticeOptions {
|
|
111
|
-
fullOutputPath?: string;
|
|
112
|
-
originalContent?: string;
|
|
113
|
-
suffix?: string;
|
|
114
|
-
}
|
|
115
|
-
export interface HeadTruncationNoticeOptions {
|
|
116
|
-
startLine?: number;
|
|
117
|
-
totalFileLines?: number;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Truncate a string/buffer to fit within a byte limit, keeping the tail.
|
|
121
|
-
* Handles multi-byte UTF-8 boundaries correctly.
|
|
122
|
-
*/
|
|
123
|
-
export declare function truncateTailBytes(data: string | Uint8Array, maxBytes: number): ByteTruncationResult;
|
|
124
|
-
/**
|
|
125
|
-
* Truncate a string/buffer to fit within a byte limit, keeping the head.
|
|
126
|
-
* Handles multi-byte UTF-8 boundaries correctly.
|
|
127
|
-
*/
|
|
128
|
-
export declare function truncateHeadBytes(data: string | Uint8Array, maxBytes: number): ByteTruncationResult;
|
|
129
|
-
/**
|
|
130
|
-
* Truncate a single line to max characters, appending '…' if truncated.
|
|
131
|
-
*/
|
|
132
|
-
export declare function truncateLine(line: string, maxChars?: number): {
|
|
133
|
-
text: string;
|
|
134
|
-
wasTruncated: boolean;
|
|
135
|
-
};
|
|
136
|
-
/** Shared helper to build a no-truncation result. */
|
|
137
|
-
export declare function noTruncResult(content: string, totalLines?: number, totalBytes?: number): TruncationResult;
|
|
138
|
-
/**
|
|
139
|
-
* Truncate content from the head (keep first N lines/bytes).
|
|
140
|
-
* Never returns partial lines. If the first line exceeds the byte limit,
|
|
141
|
-
* returns empty content with firstLineExceedsLimit=true.
|
|
142
|
-
*
|
|
143
|
-
* This implementation avoids Buffer.from(content) for the whole input.
|
|
144
|
-
* It only computes UTF-8 byteLength for candidate lines that can still fit.
|
|
145
|
-
*/
|
|
146
|
-
export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
|
|
147
|
-
/**
|
|
148
|
-
* Truncate content from the tail (keep last N lines/bytes).
|
|
149
|
-
* May return a partial first line if the last line exceeds the byte limit.
|
|
150
|
-
*
|
|
151
|
-
* Also avoids Buffer.from(content) for the whole input.
|
|
152
|
-
*/
|
|
153
|
-
export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
|
|
154
|
-
/**
|
|
155
|
-
* Format the inline marker substituted for the elided middle region.
|
|
156
|
-
* Returned without surrounding newlines so callers can position it freely.
|
|
157
|
-
*/
|
|
158
|
-
export declare function formatMiddleElisionMarker(elidedLines: number, elidedBytes: number): string;
|
|
159
|
-
/**
|
|
160
|
-
* Truncate content keeping a head window and a tail window, eliding the middle.
|
|
161
|
-
*
|
|
162
|
-
* The combined output is `<head>\n<marker>\n<tail>` when truncation is needed.
|
|
163
|
-
* `maxHeadBytes` defaults to `floor(maxBytes / 2)`; the tail receives the
|
|
164
|
-
* remainder. Falls back to `truncateTail` / `truncateHead` if either side's
|
|
165
|
-
* budget is empty or the content already fits.
|
|
166
|
-
*/
|
|
167
|
-
export declare function truncateMiddle(content: string, options?: TruncationOptions): TruncationResult;
|
|
168
|
-
/** Options for {@link enforceInlineByteCap}. */
|
|
169
|
-
export interface InlineByteCapOptions {
|
|
170
|
-
/** Inline byte budget. Defaults to {@link DEFAULT_MAX_BYTES}. */
|
|
171
|
-
maxBytes?: number;
|
|
172
|
-
/**
|
|
173
|
-
* Persist the full text as a session artifact. When an artifact id is
|
|
174
|
-
* returned, a `[raw output: artifact://<id>]` footer is appended so the
|
|
175
|
-
* elided bytes stay recoverable.
|
|
176
|
-
*/
|
|
177
|
-
saveArtifact?: (full: string) => string | undefined | Promise<string | undefined>;
|
|
13
|
+
export declare class OutputSink extends VerbatimOutputSink {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(options?: OutputSinkOptions);
|
|
16
|
+
dump(notice?: string): Promise<OutputSummary>;
|
|
178
17
|
}
|
|
179
18
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* ~60% of the budget from the head and ~25% from the tail — cut on line
|
|
184
|
-
* boundaries, never splitting a multi-byte UTF-8 sequence — with an elision
|
|
185
|
-
* marker between. The remaining ~15% is slack for the marker and the optional
|
|
186
|
-
* `[raw output: artifact://<id>]` footer, so the result stays under `maxBytes`.
|
|
19
|
+
* Composition wrapper over the verbatim {@link TailBuffer}, adding the DSH
|
|
20
|
+
* `reset()` increment. The verbatim class keeps its state in private fields,
|
|
21
|
+
* so reset is modeled as a fresh window with the same budget.
|
|
187
22
|
*/
|
|
188
|
-
export declare function enforceInlineByteCap(text: string, options: InlineByteCapOptions): Promise<string>;
|
|
189
23
|
export declare class TailBuffer {
|
|
190
24
|
#private;
|
|
191
25
|
readonly maxBytes: number;
|
|
192
26
|
constructor(maxBytes: number);
|
|
193
27
|
append(text: string): void;
|
|
194
28
|
text(): string;
|
|
29
|
+
bytes(): number;
|
|
195
30
|
/** Drop all held output; the next {@link append} starts a fresh window. */
|
|
196
31
|
reset(): void;
|
|
197
|
-
bytes(): number;
|
|
198
32
|
}
|
|
199
|
-
export declare class OutputSink {
|
|
200
|
-
#private;
|
|
201
|
-
constructor(options?: OutputSinkOptions);
|
|
202
|
-
/**
|
|
203
|
-
* Push a chunk of output. The buffer management and onChunk callback run
|
|
204
|
-
* synchronously. File sink writes are deferred and serialized internally.
|
|
205
|
-
*/
|
|
206
|
-
push(chunk: string): void;
|
|
207
|
-
createInput(): WritableStream<Uint8Array | string>;
|
|
208
|
-
/**
|
|
209
|
-
* Replace the in-memory buffer with the given text. Used when an upstream
|
|
210
|
-
* minimizer rewrites the captured output after the raw bytes have already
|
|
211
|
-
* been streamed.
|
|
212
|
-
*
|
|
213
|
-
* After this call the buffer is authoritative: streaming counters realign
|
|
214
|
-
* to the replacement, the retained head window is cleared, and head
|
|
215
|
-
* retention is disabled so subsequent `push()` calls append directly to the
|
|
216
|
-
* tail buffer instead of repopulating the (now meaningless) head window
|
|
217
|
-
* — which would otherwise reorder content and trip the middle-elision
|
|
218
|
-
* branch in `dump()` against stale totals.
|
|
219
|
-
*/
|
|
220
|
-
replace(text: string): void;
|
|
221
|
-
dump(notice?: string): Promise<OutputSummary>;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Format a truncation notice for tail-truncated output (bash, python, ssh).
|
|
225
|
-
* Returns empty string if not truncated.
|
|
226
|
-
*/
|
|
227
|
-
export declare function formatTailTruncationNotice(truncation: TruncationResult, options?: TailTruncationNoticeOptions): string;
|
|
228
|
-
/**
|
|
229
|
-
* Format a truncation notice for head-truncated output (read tool).
|
|
230
|
-
* Returns empty string if not truncated.
|
|
231
|
-
*/
|
|
232
|
-
export declare function formatHeadTruncationNotice(truncation: TruncationResult, options?: HeadTruncationNoticeOptions): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal PATH (+ PATHEXT on Windows) executable lookup, standing in for
|
|
3
|
+
* `Bun.which` / pi-utils `$which` on the Node runtime.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: pi-utils' `$which` calls `Bun.which` at module top level
|
|
6
|
+
* (node_modules @oh-my-pi/pi-utils src/which.ts:196), which the bun-shim does
|
|
7
|
+
* not provide — so DSH code that must resolve executables the way OMP does
|
|
8
|
+
* (procmgr `resolveWindowsShell` for shell discovery, `REJECT_PROMPT_COMMAND`
|
|
9
|
+
* in non-interactive-env) uses this scanner instead. Single implementation —
|
|
10
|
+
* any new caller resolves executables through here, never hand-rolls a PATH
|
|
11
|
+
* walk.
|
|
12
|
+
* @module @xiaoso/dsh-tool-plus/bash/which
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Resolve `command` against PATH the way `Bun.which` would: absolute/relative
|
|
16
|
+
* candidates are returned as-is when they name an existing file; bare names
|
|
17
|
+
* are looked up in each PATH dir (appending PATHEXT extensions on win32, in
|
|
18
|
+
* order). Returns the first existing regular file, or `undefined`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findOnPath(command: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows shell discovery, ported from oh-my-pi procmgr's `resolveWindowsShell`
|
|
3
|
+
* (refs/oh-my-pi/packages/utils/src/procmgr.ts:148-173) — adapted verbatim:
|
|
4
|
+
* `Bun.env` → injectable Node env (default `process.env`), and pi-utils
|
|
5
|
+
* `$which` → `findOnPath` (src/tools/bash/which.ts).
|
|
6
|
+
*
|
|
7
|
+
* Deliberately NOT ported from procmgr: buildSpawnEnv, shell prefix handling,
|
|
8
|
+
* direnv integration, and PI_SHELL_PREFIX — DSH has no shell-prefix seam;
|
|
9
|
+
* commands run inside the embedded brush shell or the resolved user shell.
|
|
10
|
+
* @module @xiaoso/dsh-tool-plus/bash/windows-shell
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the external shell to advertise on Windows.
|
|
14
|
+
*
|
|
15
|
+
* A host bash is OPTIONAL: bash tool commands always execute in the embedded
|
|
16
|
+
* brush-core shell. The resolved binary only serves the spawn-a-shell paths,
|
|
17
|
+
* so this prefers a real Git Bash when one exists and otherwise falls back to
|
|
18
|
+
* cmd.exe — it never fails.
|
|
19
|
+
*
|
|
20
|
+
* Search order:
|
|
21
|
+
* 1. Git for Windows install roots (machine + per-user installers)
|
|
22
|
+
* 2. scoop installs — scoop's git manifest sets GIT_INSTALL_ROOT and shims
|
|
23
|
+
* sh.exe/git.exe but never bash.exe, so PATH lookup alone misses it
|
|
24
|
+
* 3. bash.exe on PATH (Cygwin, MSYS2, ...)
|
|
25
|
+
* 4. sh.exe on PATH (Git for Windows' sh.exe is bash; prefer a sibling
|
|
26
|
+
* bash.exe when present)
|
|
27
|
+
* 5. cmd.exe from ComSpec
|
|
28
|
+
*
|
|
29
|
+
* Exported for tests; `env` overrides process.env-based discovery.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveWindowsShell(env?: NodeJS.ProcessEnv): string;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DSH edit tool — adapter that wires the verbatim OMP edit engine
|
|
3
|
-
* (`src/tools/edit
|
|
3
|
+
* (`src/tools/omp/edit/`) into DSH's `defineTool` contract.
|
|
4
4
|
*
|
|
5
5
|
* This file is pure glue. All edit logic lives in `omp/` (copied verbatim);
|
|
6
6
|
* this adapter only:
|
|
7
7
|
* - builds an OMP `ToolSession` from the DSH exec context + tool-plus config,
|
|
8
8
|
* - picks the edit mode from the call shape (replace / patch / hashline /
|
|
9
9
|
* apply_patch), exactly like OMP's `EditTool.mode` resolution,
|
|
10
|
-
* -
|
|
11
|
-
* `
|
|
10
|
+
* - hands replace/apply_patch to the verbatim upstream dispatch layer
|
|
11
|
+
* (`omp/edit/dispatch.ts`,A-7/A-8:resolveEditPath 路径纠错 +
|
|
12
|
+
* executeSinglePathEntries / executeApplyPatchPerFile 聚合) and converts
|
|
13
|
+
* the `AgentToolResult` back to a DSH tool result.
|
|
12
14
|
*
|
|
13
15
|
* LSP/ACP/TUI are absent in DSH (plan.md 拍板#5/#8): writethrough writes through
|
|
14
16
|
* ctx.fs, diagnostics are never produced, and no TUI rendering happens.
|
|
@@ -16,6 +18,13 @@
|
|
|
16
18
|
import type { Context } from '@deepseek-ai/cordis';
|
|
17
19
|
import type { WritethroughCallback } from '../../omp/tools/writethrough.ts';
|
|
18
20
|
import type { RuntimeConfig } from '../../../config/settings.ts';
|
|
21
|
+
/** OMP 原版按模式渲染的 edit 描述(prompts/tools/*.md verbatim + hashline 引擎 prompt.md)。 */
|
|
22
|
+
export declare const EDIT_MODE_DESCRIPTIONS: {
|
|
23
|
+
readonly replace: string;
|
|
24
|
+
readonly patch: string;
|
|
25
|
+
readonly apply_patch: string;
|
|
26
|
+
readonly hashline: string;
|
|
27
|
+
};
|
|
19
28
|
/** File-write channel for DSH (方案A, 2026-08-27): every edit mode funnels
|
|
20
29
|
* through `ctx.fs` with the per-call sandbox policy resolved from the session
|
|
21
30
|
* (official tool-fs semantics). The OMP engines pass a `file` handle for
|
|
@@ -25,6 +34,19 @@ import type { RuntimeConfig } from '../../../config/settings.ts';
|
|
|
25
34
|
* was denied by the deployment fallback. Both defects are fixed here: the
|
|
26
35
|
* handle is ignored and the policy is always attached. */
|
|
27
36
|
export declare function createWritethrough(ctx: Context, exec: any): WritethroughCallback;
|
|
37
|
+
/** DSH edit 工具输出形状(output.schema 镜像)。 */
|
|
38
|
+
export interface EditToolOutput {
|
|
39
|
+
text: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* S-13:edit.fuzzyThreshold 解析——上游 settings 面原样放行显式 0/负值
|
|
43
|
+
* (0 = 接受任意置信度的最佳匹配,refs edit/index.ts:112 同款语义),仅
|
|
44
|
+
* undefined/非数值回退引擎默认 0.95。env 层(上游 PI_EDIT_FUZZY* 环境变量
|
|
45
|
+
* 串解析)有意不移植:DSH 无该环境变量面,面板字段是唯一入口。
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveFuzzyThreshold(raw: unknown): number;
|
|
48
|
+
/** 完整执行链路(defineTool.execute 与单测共用,镜像 read 的 executeReadTool)。 */
|
|
49
|
+
export declare function executeEditTool(exec: any, cfg: RuntimeConfig, args: any, ctx: Context | null): Promise<EditToolOutput>;
|
|
28
50
|
/**
|
|
29
51
|
* Register the edit tool. Mode is resolved per call from the argument shape
|
|
30
52
|
* (matching OMP's mode dispatch):
|