/ utils / shell / shellProvider.ts
shellProvider.ts
 1  export const SHELL_TYPES = ['bash', 'powershell'] as const
 2  export type ShellType = (typeof SHELL_TYPES)[number]
 3  export const DEFAULT_HOOK_SHELL: ShellType = 'bash'
 4  
 5  export type ShellProvider = {
 6    type: ShellType
 7    shellPath: string
 8    detached: boolean
 9  
10    /**
11     * Build the full command string including all shell-specific setup.
12     * For bash: source snapshot, session env, disable extglob, eval-wrap, pwd tracking.
13     */
14    buildExecCommand(
15      command: string,
16      opts: {
17        id: number | string
18        sandboxTmpDir?: string
19        useSandbox: boolean
20      },
21    ): Promise<{ commandString: string; cwdFilePath: string }>
22  
23    /**
24     * Shell args for spawn (e.g., ['-c', '-l', cmd] for bash).
25     */
26    getSpawnArgs(commandString: string): string[]
27  
28    /**
29     * Extra env vars for this shell type.
30     * May perform async initialization (e.g., tmux socket setup for bash).
31     */
32    getEnvironmentOverrides(command: string): Promise<Record<string, string>>
33  }