feat(web): add interactive sidebar terminals
This commit is contained in:
1 parent
6d99a8a53a
commit
e15a9b1bec
132 files changed
+5985
-101
No files matched your search
@@ -0,0 +1,28 @@
|
||||
/** Shell selection and executable verification use the target execution provider. */
|
||||
import type { SubprocessRuntime } from '@deepseek-ai/dsh-subprocess'
|
||||
import type { TerminalShell } from './types.ts'
|
||||
|
||||
/**
|
||||
* Resolve the configured shell or the execution environment's default shell.
|
||||
* @param subprocess - target execution provider.
|
||||
* @param configured - optional profile overriding the environment's default shell.
|
||||
* @param signal - resolution cancellation.
|
||||
* @returns one verified shell; a declared default that cannot resolve rejects.
|
||||
*/
|
||||
export async function resolveShell(
|
||||
subprocess: SubprocessRuntime, configured: TerminalShell | undefined, signal: AbortSignal,
|
||||
): Promise<TerminalShell> {
|
||||
let shell = configured
|
||||
if (shell === undefined) {
|
||||
const environment = await subprocess.terminalEnvironment(signal)
|
||||
shell = profile(environment.defaultShell ?? (environment.platform === 'windows' ? 'cmd.exe' : '/bin/sh'))
|
||||
}
|
||||
const path = await subprocess.resolveExecutable(shell.path, undefined, signal)
|
||||
return { ...shell, path }
|
||||
}
|
||||
|
||||
function profile(path: string): TerminalShell {
|
||||
const name = path.slice(Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')) + 1)
|
||||
const kind = name.toLowerCase().replace(/\.exe$/u, '')
|
||||
return { path, name, args: kind === 'cmd' ? [] : kind === 'pwsh' || kind === 'powershell' ? ['-NoLogo'] : ['-i'] }
|
||||
}
|
||||
Reference in new issue
Block a user