@wzwjustdoit/dsh-plugin-git-bash 0.0.0-stage → 0.4.0
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/LICENSE +21 -0
- package/README.md +154 -2
- package/client.js +736 -0
- package/cordis.patch.yml +27 -0
- package/lib/agents.d.ts +5 -0
- package/lib/agents.d.ts.map +1 -0
- package/lib/agents.js +56 -0
- package/lib/agents.js.map +1 -0
- package/lib/discovery.d.ts +21 -0
- package/lib/discovery.d.ts.map +1 -0
- package/lib/discovery.js +122 -0
- package/lib/discovery.js.map +1 -0
- package/lib/index.d.ts +55 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +369 -0
- package/lib/index.js.map +1 -0
- package/native/CMakeLists.txt +58 -0
- package/native/bin/win32-x64/msys-token-guard-hook.dll +0 -0
- package/native/bin/win32-x64/msys-token-guard.exe +0 -0
- package/native/msys-token-guard-hook.cpp +470 -0
- package/native/msys-token-guard.cpp +671 -0
- package/native/vendor/detours/LICENSE.md +23 -0
- package/native/vendor/detours/README.dsh.md +13 -0
- package/native/vendor/detours/creatwth.cpp +1577 -0
- package/native/vendor/detours/detours.cpp +2364 -0
- package/native/vendor/detours/detours.h +1059 -0
- package/native/vendor/detours/detver.h +27 -0
- package/native/vendor/detours/disasm.cpp +4236 -0
- package/native/vendor/detours/image.cpp +2251 -0
- package/native/vendor/detours/modules.cpp +929 -0
- package/native/vendor/detours/uimports.cpp +269 -0
- package/package.json +120 -4
- package/scripts/build-native.mjs +35 -0
- package/scripts/dsh.desktop.startup/README.md +27 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.bat +28 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.sh +46 -0
- package/scripts/dsh.desktop.startup/dsh.desktop.startup.gitbash.vbs +0 -0
- package/scripts/dsh.web.startup/README.md +33 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.bat +28 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.sh +48 -0
- package/scripts/dsh.web.startup/dsh.web.startup.gitbash.vbs +0 -0
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Replace the platform-selected PowerShell stack with Git Bash on Windows.
|
|
2
|
+
# On other platforms the stock Bash provider remains unchanged.
|
|
3
|
+
|
|
4
|
+
- id: bash-sandbox
|
|
5
|
+
disabled: !!js process.platform === 'win32'
|
|
6
|
+
|
|
7
|
+
- id: pwsh-sandbox
|
|
8
|
+
disabled: true
|
|
9
|
+
|
|
10
|
+
- id: tool-bash
|
|
11
|
+
disabled: false
|
|
12
|
+
|
|
13
|
+
- id: tool-pwsh
|
|
14
|
+
disabled: true
|
|
15
|
+
|
|
16
|
+
- insert:
|
|
17
|
+
- id: git-bash-shell
|
|
18
|
+
name: '@wzwjustdoit/dsh-plugin-git-bash'
|
|
19
|
+
disabled: !!js process.platform !== 'win32'
|
|
20
|
+
config:
|
|
21
|
+
timeoutMs: 60000
|
|
22
|
+
|
|
23
|
+
# Web agent presets contribute PowerShell from an ancestor scope. This
|
|
24
|
+
# adapter shadows that contribution with the global Git Bash-backed tool.
|
|
25
|
+
- id: git-bash-agent-shell
|
|
26
|
+
name: '@wzwjustdoit/dsh-plugin-git-bash/agents'
|
|
27
|
+
disabled: !!js process.platform !== 'win32'
|
package/lib/agents.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,eAAO,MAAM,IAAI,yBAAyB,CAAC;AAC3C,eAAO,MAAM,MAAM,UAAsC,CAAC;AAG1D,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA0DxC"}
|
package/lib/agents.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const name = "git-bash-agent-shell";
|
|
2
|
+
export const inject = ["agents", "tools", "systemPrompt"];
|
|
3
|
+
// Make the global Git Bash-backed Bash tool win over preset-provided shells.
|
|
4
|
+
export function apply(ctx) {
|
|
5
|
+
const installed = new Map();
|
|
6
|
+
const install = (agent) => {
|
|
7
|
+
if (installed.has(agent))
|
|
8
|
+
return;
|
|
9
|
+
let cleanup;
|
|
10
|
+
cleanup = agent.ctx.effect(() => {
|
|
11
|
+
const disposers = [];
|
|
12
|
+
const globalBash = ctx.tools.get("bash");
|
|
13
|
+
if (!globalBash) {
|
|
14
|
+
throw new Error("git-bash-agent-shell: the global bash tool is unavailable; keep the tool-bash row enabled");
|
|
15
|
+
}
|
|
16
|
+
disposers.push(agent.ctx.tools.register(globalBash));
|
|
17
|
+
if (ctx.tools.get("pwsh", agent)) {
|
|
18
|
+
disposers.push(agent.ctx.tools.restrict({ deny: ["pwsh"] }));
|
|
19
|
+
}
|
|
20
|
+
disposers.push(agent.ctx.systemPrompt.section({
|
|
21
|
+
name: "tool:bash",
|
|
22
|
+
order: 105,
|
|
23
|
+
text: "Check the [exit code: N] marker on every Git Bash result; investigate failures before moving on.",
|
|
24
|
+
}));
|
|
25
|
+
disposers.push(agent.ctx.systemPrompt.section({
|
|
26
|
+
name: "tool:pwsh",
|
|
27
|
+
order: 105,
|
|
28
|
+
text: "",
|
|
29
|
+
}));
|
|
30
|
+
return () => {
|
|
31
|
+
for (const dispose of disposers.reverse())
|
|
32
|
+
dispose();
|
|
33
|
+
if (installed.get(agent) === cleanup)
|
|
34
|
+
installed.delete(agent);
|
|
35
|
+
};
|
|
36
|
+
}, "git-bash-agent-shell.install()");
|
|
37
|
+
installed.set(agent, cleanup);
|
|
38
|
+
};
|
|
39
|
+
ctx.effect(() => {
|
|
40
|
+
const stopCreated = ctx.on("agent/created", ({ agent }) => {
|
|
41
|
+
install(agent);
|
|
42
|
+
return undefined;
|
|
43
|
+
});
|
|
44
|
+
const stopDisposed = ctx.on("agent/disposed", ({ agent }) => installed.delete(agent));
|
|
45
|
+
for (const agent of ctx.agents.list())
|
|
46
|
+
install(agent);
|
|
47
|
+
return async () => {
|
|
48
|
+
stopCreated();
|
|
49
|
+
stopDisposed();
|
|
50
|
+
const cleanups = [...installed.values()];
|
|
51
|
+
installed.clear();
|
|
52
|
+
await Promise.allSettled(cleanups.map((cleanup) => Promise.resolve(cleanup())));
|
|
53
|
+
};
|
|
54
|
+
}, "git-bash-agent-shell.lifecycle()");
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAC3C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;AAE1D,6EAA6E;AAC7E,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;IAElD,MAAM,OAAO,GAAG,CAAC,KAAY,EAAQ,EAAE;QACrC,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO;QAEjC,IAAI,OAAuB,CAAC;QAC5B,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;YAC9B,MAAM,SAAS,GAAyB,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACzC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;YACJ,CAAC;YAED,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;YAErD,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,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MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtF,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAEtD,OAAO,KAAK,IAAI,EAAE;YAChB,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;YACzC,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QAClF,CAAC,CAAC;IACJ,CAAC,EAAE,kCAAkC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const GIT_BASH_PATH_ENV = "DSH_GIT_BASH_PATH";
|
|
2
|
+
export declare const GIT_BASH_PATH_CONFINED_ENV = "DSH_GIT_BASH_PATH_CONFINED";
|
|
3
|
+
export interface GitBashDiscoveryOptions {
|
|
4
|
+
env?: NodeJS.ProcessEnv;
|
|
5
|
+
platform?: NodeJS.Platform;
|
|
6
|
+
/** Environment variable naming the configured executable; defaults to {@link GIT_BASH_PATH_ENV}. */
|
|
7
|
+
envName?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function gitBashCandidates(env?: NodeJS.ProcessEnv): string[];
|
|
10
|
+
export declare function resolveGitBashPath(executable?: string, options?: GitBashDiscoveryOptions): string;
|
|
11
|
+
/**
|
|
12
|
+
* The validated `bash.exe` named by one environment variable, or `undefined`
|
|
13
|
+
* when that variable is unset. Unlike {@link resolveGitBashPath} this never
|
|
14
|
+
* falls back to auto-discovery, so callers can layer several variables.
|
|
15
|
+
* @param envName - environment variable to read (case-insensitively).
|
|
16
|
+
* @param options - environment/platform overrides, as for {@link resolveGitBashPath}.
|
|
17
|
+
* @returns the resolved executable, or `undefined` when the variable is unset.
|
|
18
|
+
* @throws when the variable is set but names a missing or unusable executable.
|
|
19
|
+
*/
|
|
20
|
+
export declare function configuredGitBashPath(envName: string, options?: GitBashDiscoveryOptions): string | undefined;
|
|
21
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAKrD,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA8CD,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,EAAE,CAiChF;AAGD,wBAAgB,kBAAkB,CAChC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GAAE,uBAA4B,GACpC,MAAM,CA8BR;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAA4B,GACpC,MAAM,GAAG,SAAS,CAIpB"}
|
package/lib/discovery.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { accessSync, constants, realpathSync, statSync, } from "node:fs";
|
|
2
|
+
import { win32 } from "node:path";
|
|
3
|
+
export const GIT_BASH_PATH_ENV = "DSH_GIT_BASH_PATH";
|
|
4
|
+
// The Git installation the confined modes use. Its MSYS named-object hash must
|
|
5
|
+
// differ from the unconfined one's, so a Low-integrity child can create its own
|
|
6
|
+
// `\BaseNamedObjects\msys-2.0S5-<hash>` instead of opening an existing
|
|
7
|
+
// Medium-labelled object (see README's "两个环境变量的分工" section).
|
|
8
|
+
export const GIT_BASH_PATH_CONFINED_ENV = "DSH_GIT_BASH_PATH_CONFINED";
|
|
9
|
+
function envValue(env, name) {
|
|
10
|
+
const wanted = name.toLowerCase();
|
|
11
|
+
const entry = Object.entries(env).find(([key]) => key.toLowerCase() === wanted);
|
|
12
|
+
const value = entry?.[1]?.trim();
|
|
13
|
+
return value && value.length > 0 ? value : undefined;
|
|
14
|
+
}
|
|
15
|
+
function expandEnvironmentVariables(value, env) {
|
|
16
|
+
return value.replace(/%([^%]+)%/g, (match, name) => envValue(env, name) ?? match);
|
|
17
|
+
}
|
|
18
|
+
function canonicalExecutable(candidate) {
|
|
19
|
+
try {
|
|
20
|
+
if (!statSync(candidate).isFile())
|
|
21
|
+
return undefined;
|
|
22
|
+
accessSync(candidate, constants.X_OK);
|
|
23
|
+
return realpathSync.native(candidate);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function uniqueWindowsPaths(paths) {
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
const result = [];
|
|
32
|
+
for (const candidate of paths) {
|
|
33
|
+
const normalized = win32.normalize(candidate.trim());
|
|
34
|
+
if (normalized.length === 0)
|
|
35
|
+
continue;
|
|
36
|
+
const key = normalized.toLowerCase();
|
|
37
|
+
if (seen.has(key))
|
|
38
|
+
continue;
|
|
39
|
+
seen.add(key);
|
|
40
|
+
result.push(normalized);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function appendGitRoot(candidates, root) {
|
|
45
|
+
if (!root)
|
|
46
|
+
return;
|
|
47
|
+
candidates.push(win32.join(root, "bin", "bash.exe"), win32.join(root, "usr", "bin", "bash.exe"));
|
|
48
|
+
}
|
|
49
|
+
// Return likely Git for Windows Bash locations in preference order.
|
|
50
|
+
export function gitBashCandidates(env = process.env) {
|
|
51
|
+
const candidates = [];
|
|
52
|
+
for (const variable of ["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"]) {
|
|
53
|
+
const directory = envValue(env, variable);
|
|
54
|
+
if (directory)
|
|
55
|
+
appendGitRoot(candidates, win32.join(directory, "Git"));
|
|
56
|
+
}
|
|
57
|
+
const localAppData = envValue(env, "LOCALAPPDATA");
|
|
58
|
+
if (localAppData)
|
|
59
|
+
appendGitRoot(candidates, win32.join(localAppData, "Programs", "Git"));
|
|
60
|
+
const userProfile = envValue(env, "USERPROFILE");
|
|
61
|
+
if (userProfile) {
|
|
62
|
+
appendGitRoot(candidates, win32.join(userProfile, "scoop", "apps", "git", "current"));
|
|
63
|
+
appendGitRoot(candidates, win32.join(userProfile, "AppData", "Local", "Programs", "Git"));
|
|
64
|
+
}
|
|
65
|
+
appendGitRoot(candidates, envValue(env, "GIT_INSTALL_ROOT"));
|
|
66
|
+
const pathValue = envValue(env, "PATH") ?? "";
|
|
67
|
+
for (const rawEntry of pathValue.split(win32.delimiter)) {
|
|
68
|
+
const entry = rawEntry.trim().replace(/^"|"$/g, "");
|
|
69
|
+
if (entry.length === 0)
|
|
70
|
+
continue;
|
|
71
|
+
const gitRoot = /^(.*[\\/]git)(?:[\\/].*)?$/i.exec(entry)?.[1];
|
|
72
|
+
if (gitRoot)
|
|
73
|
+
appendGitRoot(candidates, gitRoot);
|
|
74
|
+
if (/(?:^|[\\/])git(?:[\\/]|$)/i.test(entry)) {
|
|
75
|
+
candidates.push(win32.join(entry, "bash.exe"));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return uniqueWindowsPaths(candidates);
|
|
79
|
+
}
|
|
80
|
+
// Resolve and validate the Git for Windows Bash executable.
|
|
81
|
+
export function resolveGitBashPath(executable, options = {}) {
|
|
82
|
+
const env = options.env ?? process.env;
|
|
83
|
+
const platform = options.platform ?? process.platform;
|
|
84
|
+
if (platform !== "win32") {
|
|
85
|
+
throw new Error("git-bash: Git for Windows is supported only on Windows");
|
|
86
|
+
}
|
|
87
|
+
const configured = executable?.trim() || envValue(env, options.envName ?? GIT_BASH_PATH_ENV);
|
|
88
|
+
if (configured) {
|
|
89
|
+
const expanded = expandEnvironmentVariables(configured, env);
|
|
90
|
+
const resolved = canonicalExecutable(expanded);
|
|
91
|
+
if (resolved)
|
|
92
|
+
return resolved;
|
|
93
|
+
throw new Error(`git-bash: configured executable does not exist or is not executable: ${expanded}`);
|
|
94
|
+
}
|
|
95
|
+
const candidates = gitBashCandidates(env);
|
|
96
|
+
for (const candidate of candidates) {
|
|
97
|
+
const resolved = canonicalExecutable(candidate);
|
|
98
|
+
if (resolved)
|
|
99
|
+
return resolved;
|
|
100
|
+
}
|
|
101
|
+
throw new Error([
|
|
102
|
+
"git-bash: Git for Windows Bash was not found.",
|
|
103
|
+
`Install Git for Windows or set ${GIT_BASH_PATH_ENV} to bash.exe.`,
|
|
104
|
+
candidates.length > 0 ? `Checked: ${candidates.join(", ")}` : "No candidate paths were available.",
|
|
105
|
+
].join(" "));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The validated `bash.exe` named by one environment variable, or `undefined`
|
|
109
|
+
* when that variable is unset. Unlike {@link resolveGitBashPath} this never
|
|
110
|
+
* falls back to auto-discovery, so callers can layer several variables.
|
|
111
|
+
* @param envName - environment variable to read (case-insensitively).
|
|
112
|
+
* @param options - environment/platform overrides, as for {@link resolveGitBashPath}.
|
|
113
|
+
* @returns the resolved executable, or `undefined` when the variable is unset.
|
|
114
|
+
* @throws when the variable is set but names a missing or unusable executable.
|
|
115
|
+
*/
|
|
116
|
+
export function configuredGitBashPath(envName, options = {}) {
|
|
117
|
+
const env = options.env ?? process.env;
|
|
118
|
+
if (!envValue(env, envName))
|
|
119
|
+
return undefined;
|
|
120
|
+
return resolveGitBashPath(undefined, { ...options, envName });
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names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M,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,oCAAoC;KACnG,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,UAAmC,EAAE;IAErC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,OAAO,kBAAkB,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAChE,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { LocalBashExecutor } from "@deepseek-ai/dsh-bash-local";
|
|
3
|
+
import type { Config as LocalBashConfig } from "@deepseek-ai/dsh-bash-local";
|
|
4
|
+
import type { SandboxMode } from "@deepseek-ai/dsh-sandbox";
|
|
5
|
+
import type { ShellExecRequest, ShellExecSpec, ShellExecution, ShellProcess } from "@deepseek-ai/dsh-shell";
|
|
6
|
+
import z from "@deepseek-ai/schemastery";
|
|
7
|
+
export { GIT_BASH_PATH_CONFINED_ENV, GIT_BASH_PATH_ENV, configuredGitBashPath, gitBashCandidates, resolveGitBashPath, } from "./discovery.js";
|
|
8
|
+
export interface Config extends LocalBashConfig {
|
|
9
|
+
executable?: string;
|
|
10
|
+
confinedExecutable?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const Config: z<Config>;
|
|
13
|
+
export declare function describeGuardFailure(detail: string): string;
|
|
14
|
+
export declare class GitBashExecutor extends LocalBashExecutor {
|
|
15
|
+
static inject: string[];
|
|
16
|
+
static Config: typeof LocalBashExecutor.Config;
|
|
17
|
+
private readonly executableCache;
|
|
18
|
+
private readonly mode;
|
|
19
|
+
private readonly processFacts;
|
|
20
|
+
constructor(ctx: Context, config: Config);
|
|
21
|
+
/**
|
|
22
|
+
* The bash.exe for one file-effect mode. `danger-full-access` uses the
|
|
23
|
+
* unconfined installation (`executable` / {@link GIT_BASH_PATH_ENV}); the
|
|
24
|
+
* confined modes prefer their dedicated installation (`confinedExecutable` /
|
|
25
|
+
* {@link GIT_BASH_PATH_CONFINED_ENV}) so their MSYS shared object is created
|
|
26
|
+
* fresh by the Low-integrity child rather than inherited as a Medium object.
|
|
27
|
+
* @param mode - the resolved policy mode for this execution.
|
|
28
|
+
*/
|
|
29
|
+
private executableFor;
|
|
30
|
+
/** The unconfined-mode bash.exe; kept as the public property existing tests and callers read. */
|
|
31
|
+
get executable(): string;
|
|
32
|
+
get sandboxMode(): SandboxMode;
|
|
33
|
+
resolve(request: ShellExecRequest): ShellExecSpec;
|
|
34
|
+
private argv;
|
|
35
|
+
private guardedArgv;
|
|
36
|
+
private policy;
|
|
37
|
+
private confine;
|
|
38
|
+
private serverDaclNormalized;
|
|
39
|
+
private ensureServerDaclNormalized;
|
|
40
|
+
execute(spec: ShellExecSpec): Promise<ShellExecution>;
|
|
41
|
+
/**
|
|
42
|
+
* Decorate the handle's foreground projection in place, memoized once. The
|
|
43
|
+
* handle keeps its identity (never wrapped in a second object) because the
|
|
44
|
+
* per-process facts and `onProcessDone` key on the exact instance.
|
|
45
|
+
*/
|
|
46
|
+
private static decorateResult;
|
|
47
|
+
/**
|
|
48
|
+
* Stamp per-process sandbox facts before `done` settles. Full-access
|
|
49
|
+
* processes carry no facts; provider rejections are classified as runner
|
|
50
|
+
* failures rather than denials.
|
|
51
|
+
*/
|
|
52
|
+
protected onProcessDone(proc: ShellProcess, stderr: string, providerRejected: boolean, providerError?: unknown): void;
|
|
53
|
+
}
|
|
54
|
+
export default GitBashExecutor;
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|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