/** * Bash tool: execute shell commands in the host environment. * * Cross-platform: bash/zsh on macOS and Linux, PowerShell on Windows. * Tracks working directory across calls within an agentic loop. * Supports background execution with auto-yield. * * Reference: docs/cortex/tools/bash.md */ import { Type, type Static } from 'typebox'; import type { CwdTracker } from '../shared/cwd-tracker.js'; import type { ToolContentDetails, ToolExecuteContext } from '../../types.js'; import { type BackgroundTask, type CortexToolRuntime } from '../runtime.js'; export declare const BashParams: Type.TObject<{ command: Type.TString; timeout: Type.TOptional; description: Type.TOptional; background: Type.TOptional; }>; export type BashParamsType = Static; export interface BashDetails { stdout: string; stderr: string; exitCode: number | null; duration: number; interrupted: boolean; timedOut: boolean; backgrounded: boolean; taskId: string | null; finalCwd: string; } /** * Partial result details emitted during bash streaming via onUpdate. */ export interface BashStreamUpdate { /** New stdout chunk since last update (complete lines only). */ stdout: string; /** New stderr chunk since last update. */ stderr: string; /** Total stdout lines emitted so far. */ totalLines: number; } export interface BashToolConfig { runtime?: CortexToolRuntime | undefined; cwdTracker?: CwdTracker | undefined; /** Custom shell path override. */ shellPath?: string | undefined; /** Auto-yield threshold in ms. Default: 10000. */ autoYieldThreshold?: number | undefined; /** Callback for tracking subprocess PIDs (for cleanup on exit). */ onProcessSpawned?: ((pid: number) => void) | undefined; /** Callback for removing tracked PIDs when process exits. */ onProcessExited?: ((pid: number) => void) | undefined; /** * Fired when a backgrounded task (explicit `background: true` or an * auto-yielded long-running command) finishes. The agent uses this to wake * its loop and deliver the result, so it does not have to poll repeatedly. */ onBackgroundTaskComplete?: ((taskId: string) => void) | undefined; /** Utility model completion function for Layer 7 safety classifier. */ utilityComplete?: ((context: unknown) => Promise) | undefined; /** Whether the consumer is currently auto-approving tool calls. */ isAutoApprove?: boolean | (() => boolean) | undefined; /** * Consumer-set environment variable overrides that bypass the security blocklist. * Merged ON TOP of the sanitized environment for shell subprocesses. * Used for macOS dock icon suppression vars (DYLD_INSERT_LIBRARIES, etc.). */ envOverrides?: Record | undefined; } export declare function getBackgroundTask(id: string): BackgroundTask | undefined; export declare function getAllBackgroundTasks(): Map; export declare function createBashTool(config: BashToolConfig): { name: string; description: string; parameters: typeof BashParams; execute: (params: BashParamsType, context?: ToolExecuteContext) => Promise>; }; //# sourceMappingURL=index.d.ts.map