Type Definitions
Implementation Reference
Source Files:
packages/core/src/types/index.ts
- Main type exportspackages/core/src/types/target.ts
- Target type definitionspackages/core/src/types/result.ts
- Result type definitionspackages/core/src/types/options.ts
- Options type definitionspackages/core/src/types/config.ts
- Configuration types
Core Types
Target Types
Target
Base target interface for all execution targets.
interface Target {
type: 'local' | 'ssh' | 'docker' | 'kubernetes';
name?: string;
description?: string;
}
LocalTarget
Local execution target.
interface LocalTarget extends Target {
type: 'local';
shell?: string;
cwd?: string;
env?: Record<string, string>;
}
SSHTarget
SSH remote execution target.
interface SSHTarget extends Target {
type: 'ssh';
host: string;
port?: number;
user?: string;
password?: string;
privateKey?: string | Buffer;
passphrase?: string;
agentForward?: boolean;
strictHostKeyChecking?: boolean;
knownHosts?: string;
timeout?: number;
keepaliveInterval?: number;
keepaliveCountMax?: number;
readyTimeout?: number;
compress?: boolean;
algorithms?: {
kex?: string[];
cipher?: string[];
serverHostKey?: string[];
hmac?: string[];
};
}
DockerTarget
Docker container execution target.
interface DockerTarget extends Target {
type: 'docker';
container: string;
image?: string;
user?: string;
workingDir?: string;
env?: Record<string, string>;
privileged?: boolean;
network?: string;
volumes?: string[];
ports?: string[];
detach?: boolean;
remove?: boolean;
tty?: boolean;
interactive?: boolean;
}
KubernetesTarget
Kubernetes pod execution target.
interface KubernetesTarget extends Target {
type: 'kubernetes';
pod: string;
container?: string;
namespace?: string;
context?: string;
kubeconfig?: string;
labels?: Record<string, string>;
annotations?: Record<string, string>;
serviceAccount?: string;
}
Execution Types
ExecutionOptions
Options for command execution.
interface ExecutionOptions {
// Working directory
cwd?: string;
// Environment variables
env?: Record<string, string | undefined>;
// Shell configuration
shell?: string | boolean;
// Timeout in milliseconds
timeout?: number;
// Maximum buffer size for stdout/stderr
maxBuffer?: number;
// Encoding for output
encoding?: BufferEncoding;
// Abort signal for cancellation
signal?: AbortSignal;
// Input stream or data
stdin?: string | Buffer | Readable;
// Output streams
stdout?: Writable;
stderr?: Writable;
// Behavior flags
quiet?: boolean;
verbose?: boolean;
nothrow?: boolean;
// Process options
uid?: number;
gid?: number;
windowsHide?: boolean;
killSignal?: string | number;
}
ExecutionResult
Result of command execution.
interface ExecutionResult {
// Output
stdout: string;
stderr: string;
// Exit status
exitCode: number;
signal?: string;
// Success indicator
ok: boolean;
// Metadata
command: string;
duration: number;
target?: Target;
// Original options
options?: ExecutionOptions;
}
ProcessOutput
Extended output with additional properties.
interface ProcessOutput extends ExecutionResult {
// Additional stream data
combined?: string;
// Parsed data
lines?: string[];
json?: any;
// Process info
pid?: number;
killed?: boolean;
}
Configuration Types
Config
Main configuration interface.
interface Config {
// Project metadata
name?: string;
description?: string;
version?: string;
// Targets
targets?: {
hosts?: Record<string, SSHTarget>;
containers?: Record<string, DockerTarget>;
pods?: Record<string, KubernetesTarget>;
groups?: Record<string, string[]>;
};
// Tasks
tasks?: Record<string, Task>;
// Variables
variables?: Record<string, any>;
// Defaults
defaults?: {
shell?: string;
timeout?: number;
cwd?: string;
env?: Record<string, string>;
ssh?: Partial<SSHTarget>;
docker?: Partial<DockerTarget>;
kubernetes?: Partial<KubernetesTarget>;
};
// Commands configuration
commands?: Record<string, CommandConfig>;
// Aliases
aliases?: Record<string, string>;
// Scripts configuration
scripts?: {
env?: Record<string, string>;
globals?: string[];
runtime?: 'auto' | 'node' | 'bun' | 'deno';
};
}
Task
Task definition.
interface Task {
// Basic info
name?: string;
description?: string;
// Execution
command?: string;
script?: string;
steps?: TaskStep[];
// Parameters
params?: TaskParameter[];
// Target selection
targets?: string | string[];
parallel?: boolean;
// Options
timeout?: number;
cwd?: string;
env?: Record<string, string>;
// Conditions
condition?: string;
continueOnError?: boolean;
// Dependencies
depends?: string[];
// Hooks
before?: string | string[];
after?: string | string[];
onError?: string | string[];
}
TaskStep
Individual step in a multi-step task.
interface TaskStep {
name: string;
command?: string;
script?: string;
targets?: string | string[];
condition?: string;
continueOnError?: boolean;
timeout?: number;
env?: Record<string, string>;
}
TaskParameter
Task parameter definition.
interface TaskParameter {
name: string;
description?: string;
type?: 'string' | 'number' | 'boolean' | 'array' | 'object';
required?: boolean;
default?: any;
values?: any[];
pattern?: string;
min?: number;
max?: number;
}
Connection Types
ConnectionPool
SSH connection pool configuration.
interface ConnectionPoolConfig {
// Pool size
max?: number;
min?: number;
// Timeouts
acquireTimeoutMillis?: number;
createTimeoutMillis?: number;
destroyTimeoutMillis?: number;
idleTimeoutMillis?: number;
reapIntervalMillis?: number;
// Behavior
createRetryIntervalMillis?: number;
propagateCreateError?: boolean;
// Validation
testOnBorrow?: boolean;
testOnReturn?: boolean;
testWhileIdle?: boolean;
// Eviction
evictionRunIntervalMillis?: number;
numTestsPerEvictionRun?: number;
softIdleTimeoutMillis?: number;
}
SSHConnection
Active SSH connection.
interface SSHConnection {
// Connection state
connected: boolean;
ready: boolean;
// Execute command
exec(command: string, options?: ExecOptions): Promise<ExecutionResult>;
// File operations
uploadFile(localPath: string, remotePath: string): Promise<void>;
downloadFile(remotePath: string, localPath: string): Promise<void>;
// Port forwarding
forwardPort(localPort: number, remoteHost: string, remotePort: number): Promise<void>;
reverseForward(remotePort: number, localHost: string, localPort: number): Promise<void>;
// Connection management
close(): Promise<void>;
destroy(): void;
}
Error Types
XecError
Base error class for all Xec errors.
class XecError extends Error {
readonly code: string;
readonly details?: any;
readonly cause?: Error;
}
ExecutionError
Error thrown when command execution fails.
class ExecutionError extends XecError {
readonly exitCode: number;
readonly signal?: string;
readonly stdout: string;
readonly stderr: string;
readonly command: string;
readonly duration: number;
readonly target?: Target;
}
ValidationError
Error thrown for validation failures.
class ValidationError extends XecError {
readonly field?: string;
readonly value?: any;
readonly constraint?: string;
}
ConnectionError
Error thrown for connection failures.
class ConnectionError extends XecError {
readonly host?: string;
readonly port?: number;
readonly protocol?: string;
readonly attempt?: number;
}
TimeoutError
Error thrown when operation times out.
class TimeoutError extends XecError {
readonly timeout: number;
readonly operation?: string;
}
ConfigurationError
Error thrown for configuration issues.
class ConfigurationError extends XecError {
readonly configPath?: string;
readonly key?: string;
}
Event Types
ExecutionEvent
Events emitted during execution.
interface ExecutionEvent {
type: 'start' | 'stdout' | 'stderr' | 'end' | 'error';
timestamp: Date;
command?: string;
target?: Target;
data?: any;
}
ConnectionEvent
Events for connection lifecycle.
interface ConnectionEvent {
type: 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'error';
timestamp: Date;
target: Target;
error?: Error;
}