@vibe-kit/dagger
Version:
Local sandbox provider for Vibekit using Dagger
315 lines (307 loc) • 9.28 kB
TypeScript
/**
* Registry Integration Bridge
*
* Provides backward compatibility by bridging Dagger package functions
* to the new shared registry infrastructure.
*/
type DockerLoginInfo$1 = {
isLoggedIn: boolean;
username?: string | null;
registry?: string;
};
type VibeKitConfig$1 = {
dockerHubUser?: string;
lastImageBuild?: string;
registryImages?: Partial<Record<AgentType$1, string>>;
privateRegistry?: string;
preferRegistryImages?: boolean;
pushImages?: boolean;
[key: string]: any;
};
type AgentType$1 = "codex" | "claude" | "opencode" | "gemini" | "grok";
/**
* Check if user is logged into Docker Hub
*/
declare function checkDockerLogin(): Promise<DockerLoginInfo$1>;
/**
* Get or create VibeKit configuration
*/
declare function getVibeKitConfig(): Promise<VibeKitConfig$1>;
/**
* Save VibeKit configuration
*/
declare function saveVibeKitConfig(config: VibeKitConfig$1): Promise<void>;
/**
* Upload images to user's Docker Hub account
*/
declare function uploadImagesToUserAccount(dockerHubUser: string, selectedAgents?: AgentType$1[]): Promise<{
success: boolean;
results: Array<{
agentType: AgentType$1;
success: boolean;
error?: string;
imageUrl?: string;
}>;
}>;
/**
* Docker registry setup utilities
*/
declare function setupUserDockerRegistry(selectedAgents?: AgentType$1[]): Promise<{
success: boolean;
config?: VibeKitConfig$1;
error?: string;
}>;
/**
* VibeKit Dagger Local Sandbox Provider
*
* Implements the sandbox provider interface using Dagger for local containerized
* development environments with ARM64 agent images.
*/
interface Logger {
debug(message: string, meta?: any): void;
info(message: string, meta?: any): void;
warn(message: string, meta?: any): void;
error(message: string, error?: Error | any, meta?: any): void;
}
interface Environment$1 {
id: string;
name: string;
status: "running" | "stopped" | "pending" | "error";
agentType?: string;
createdAt?: Date;
lastUsed?: Date;
branch?: string;
environment?: {
VIBEKIT_AGENT_TYPE?: string;
AGENT_TYPE?: string;
[key: string]: string | undefined;
};
}
interface SandboxExecutionResult {
exitCode: number;
stdout: string;
stderr: string;
}
interface SandboxCommandOptions {
timeoutMs?: number;
background?: boolean;
onStdout?: (data: string) => void;
onStderr?: (data: string) => void;
}
interface SandboxCommands {
run(command: string, options?: SandboxCommandOptions): Promise<SandboxExecutionResult>;
}
interface SandboxInstance {
sandboxId: string;
commands: SandboxCommands;
kill(): Promise<void>;
pause(): Promise<void>;
getHost(port: number): Promise<string>;
on(event: string, listener: (...args: any[]) => void): this;
emit(event: string, ...args: any[]): boolean;
}
interface SandboxProvider {
create(envs?: Record<string, string>, agentType?: "codex" | "claude" | "opencode" | "gemini" | "grok", workingDirectory?: string): Promise<SandboxInstance>;
resume(sandboxId: string): Promise<SandboxInstance>;
}
type AgentType = "codex" | "claude" | "opencode" | "gemini" | "grok";
interface LocalConfig {
preferRegistryImages?: boolean;
dockerHubUser?: string;
registryUser?: string;
registryName?: string;
pushImages?: boolean;
privateRegistry?: string;
autoInstall?: boolean;
logger?: Logger;
retryAttempts?: number;
retryDelayMs?: number;
connectionTimeout?: number;
configPath?: string;
}
declare class LocalSandboxProvider implements SandboxProvider {
private logger;
private config;
constructor(config?: LocalConfig);
create(envs?: Record<string, string>, agentType?: AgentType, workingDirectory?: string): Promise<SandboxInstance>;
resume(sandboxId: string): Promise<SandboxInstance>;
listEnvironments(): Promise<Environment$1[]>;
}
declare function createLocalProvider(config?: LocalConfig): LocalSandboxProvider;
declare function prebuildAgentImages(selectedAgents?: AgentType[]): Promise<{
success: boolean;
results: Array<{
agentType: AgentType;
success: boolean;
error?: string;
source: "registry" | "dockerfile" | "cached";
}>;
}>;
type DockerLoginInfo = {
isLoggedIn: boolean;
username?: string | null;
registry?: string;
};
type VibeKitConfig = {
dockerHubUser?: string;
lastImageBuild?: string;
registryImages?: Partial<Record<AgentType, string>>;
privateRegistry?: string;
preferRegistryImages?: boolean;
pushImages?: boolean;
[key: string]: any;
};
/**
* Local Provider Setup and Installation
*
* Handles setup and pre-building of agent images for the local provider.
* This includes validating dependencies, installing tools, and caching
* Docker images for faster startup times.
*/
interface SetupOptions {
skipPreBuild?: boolean;
selectedAgents?: AgentType[];
verbose?: boolean;
}
interface SetupResult {
success: boolean;
message: string;
preBuildResults?: Array<{
agentType: AgentType;
success: boolean;
error?: string;
}>;
warnings?: string[];
}
/**
* Validate system dependencies for local provider
*/
declare function validateDependencies(): Promise<{
valid: boolean;
issues: string[];
}>;
/**
* Setup the local provider with optional pre-building
*/
declare function setupLocalProvider(options?: SetupOptions): Promise<SetupResult>;
/**
* Pre-build specific agent images
*/
declare function prebuildSpecificAgents(agentTypes: AgentType[]): Promise<SetupResult>;
/**
* Check if local provider is properly set up
*/
declare function checkSetupStatus(): Promise<{
isSetup: boolean;
issues: string[];
recommendations: string[];
}>;
/**
* Clean up pre-built images (for maintenance)
*/
declare function cleanupPreBuiltImages(): Promise<{
success: boolean;
removed: string[];
errors: string[];
}>;
/**
* Environment Storage System
*
* Provides persistent storage for sandbox environment metadata
* to track environments across CLI sessions.
*/
interface EnvironmentRecord {
id: string;
name: string;
status: 'running' | 'stopped' | 'paused' | 'error';
agentType?: AgentType;
branch?: string;
created: Date;
lastUsed: Date;
sandboxId: string;
workingDirectory: string;
envVars: Record<string, string>;
dockerImage?: string;
pid?: number;
githubToken?: string;
model?: string;
apiKey?: string;
}
declare class EnvironmentStore {
private storePath;
private lockPath;
constructor(customPath?: string);
/**
* Ensure storage directory exists
*/
private ensureStorageDir;
/**
* Simple file-based locking for concurrent access
*/
private acquireLock;
/**
* Release the file lock
*/
private releaseLock;
/**
* Load all environments from storage
*/
load(): Promise<EnvironmentRecord[]>;
/**
* Save all environments to storage
*/
private saveAll;
/**
* Save a new environment
*/
save(env: EnvironmentRecord): Promise<void>;
/**
* Update an existing environment
*/
update(id: string, updates: Partial<EnvironmentRecord>): Promise<void>;
/**
* Delete an environment by ID
*/
delete(id: string): Promise<void>;
/**
* Find environment by ID
*/
findById(id: string): Promise<EnvironmentRecord | null>;
/**
* Find environment by name
*/
findByName(name: string): Promise<EnvironmentRecord | null>;
/**
* Get environments filtered by status
*/
getByStatus(status: EnvironmentRecord['status']): Promise<EnvironmentRecord[]>;
/**
* Get environments filtered by agent type
*/
getByAgentType(agentType: AgentType): Promise<EnvironmentRecord[]>;
/**
* Clean up old environments (older than specified days)
*/
cleanup(olderThanDays?: number): Promise<string[]>;
}
/**
* @vibe-kit/dagger - Local Sandbox Provider
*
* Main entry point for the local provider package.
* Exports all public APIs for Dagger integration and setup utilities.
*/
interface Environment {
id: string;
name: string;
status: "running" | "stopped" | "pending" | "error";
agentType?: string;
createdAt?: Date;
lastUsed?: Date;
branch?: string;
environment?: {
VIBEKIT_AGENT_TYPE?: string;
AGENT_TYPE?: string;
[key: string]: string | undefined;
};
}
export { type AgentType, type DockerLoginInfo, type Environment, type EnvironmentRecord, EnvironmentStore, type LocalConfig, type LocalConfig as LocalDaggerConfig, LocalSandboxProvider as LocalDaggerSandboxProvider, LocalSandboxProvider, type SandboxCommandOptions, type SandboxCommands, type SandboxExecutionResult, type SandboxInstance, type SandboxProvider, type SetupOptions, type SetupResult, type VibeKitConfig, checkDockerLogin, checkSetupStatus, cleanupPreBuiltImages, createLocalProvider, getVibeKitConfig, prebuildAgentImages, prebuildSpecificAgents, saveVibeKitConfig, setupLocalProvider, setupUserDockerRegistry, uploadImagesToUserAccount, validateDependencies };