mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-17 01:04:42 +00:00
chore(foundry): improve sandbox impl + status pill (#252)
* Improve Daytona sandbox provisioning and frontend UI Refactor git clone script in Daytona provider to use cleaner shell logic for GitHub token authentication and branch checkout. Add support for private repository clones with token-based auth. Improve Daytona provider error handling and git configuration setup. Frontend improvements include enhanced dev panel, workspace dashboard, sidebar navigation, and UI components for better task/session management. Update interest manager and backend client to support improved session state handling. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * Add header status pill showing task/session/sandbox state Surface aggregate status (error, provisioning, running, ready, no sandbox) as a colored pill in the transcript panel header. Integrates task runtime status, session status, and sandbox availability via the sandboxProcesses interest topic so the pill accurately reflects unreachable sandboxes. Includes mock tasks demonstrating error, provisioning, and running states, unit tests for deriveHeaderStatus, and workspace-dashboard integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5a1b32a271
commit
70d31f819c
82 changed files with 2625 additions and 4166 deletions
|
|
@ -1,113 +0,0 @@
|
|||
import { Daytona, type Image } from "@daytonaio/sdk";
|
||||
|
||||
export interface DaytonaSandbox {
|
||||
id: string;
|
||||
state?: string;
|
||||
snapshot?: string;
|
||||
labels?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface DaytonaCreateSandboxOptions {
|
||||
image: string | Image;
|
||||
envVars?: Record<string, string>;
|
||||
labels?: Record<string, string>;
|
||||
autoStopInterval?: number;
|
||||
}
|
||||
|
||||
export interface DaytonaPreviewEndpoint {
|
||||
url: string;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export interface DaytonaClientOptions {
|
||||
apiUrl?: string;
|
||||
apiKey?: string;
|
||||
target?: string;
|
||||
}
|
||||
|
||||
function normalizeApiUrl(input?: string): string | undefined {
|
||||
if (!input) return undefined;
|
||||
const trimmed = input.replace(/\/+$/, "");
|
||||
if (trimmed.endsWith("/api")) {
|
||||
return trimmed;
|
||||
}
|
||||
return `${trimmed}/api`;
|
||||
}
|
||||
|
||||
export class DaytonaClient {
|
||||
private readonly daytona: Daytona;
|
||||
|
||||
constructor(options: DaytonaClientOptions) {
|
||||
const apiUrl = normalizeApiUrl(options.apiUrl);
|
||||
this.daytona = new Daytona({
|
||||
_experimental: {},
|
||||
...(apiUrl ? { apiUrl } : {}),
|
||||
...(options.apiKey ? { apiKey: options.apiKey } : {}),
|
||||
...(options.target ? { target: options.target } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
async createSandbox(options: DaytonaCreateSandboxOptions): Promise<DaytonaSandbox> {
|
||||
const sandbox = await this.daytona.create({
|
||||
image: options.image,
|
||||
envVars: options.envVars,
|
||||
labels: options.labels,
|
||||
...(options.autoStopInterval !== undefined ? { autoStopInterval: options.autoStopInterval } : {}),
|
||||
});
|
||||
|
||||
return {
|
||||
id: sandbox.id,
|
||||
state: sandbox.state,
|
||||
snapshot: sandbox.snapshot,
|
||||
labels: (sandbox as any).labels,
|
||||
};
|
||||
}
|
||||
|
||||
async getSandbox(sandboxId: string): Promise<DaytonaSandbox> {
|
||||
const sandbox = await this.daytona.get(sandboxId);
|
||||
return {
|
||||
id: sandbox.id,
|
||||
state: sandbox.state,
|
||||
snapshot: sandbox.snapshot,
|
||||
labels: (sandbox as any).labels,
|
||||
};
|
||||
}
|
||||
|
||||
async startSandbox(sandboxId: string, timeoutSeconds?: number): Promise<void> {
|
||||
const sandbox = await this.daytona.get(sandboxId);
|
||||
await sandbox.start(timeoutSeconds);
|
||||
}
|
||||
|
||||
async stopSandbox(sandboxId: string, timeoutSeconds?: number): Promise<void> {
|
||||
const sandbox = await this.daytona.get(sandboxId);
|
||||
await sandbox.stop(timeoutSeconds);
|
||||
}
|
||||
|
||||
async deleteSandbox(sandboxId: string): Promise<void> {
|
||||
const sandbox = await this.daytona.get(sandboxId);
|
||||
await this.daytona.delete(sandbox);
|
||||
}
|
||||
|
||||
async executeCommand(sandboxId: string, command: string): Promise<{ exitCode: number; result: string }> {
|
||||
const sandbox = await this.daytona.get(sandboxId);
|
||||
const response = await sandbox.process.executeCommand(command);
|
||||
return {
|
||||
exitCode: response.exitCode,
|
||||
result: response.result,
|
||||
};
|
||||
}
|
||||
|
||||
async getPreviewEndpoint(sandboxId: string, port: number): Promise<DaytonaPreviewEndpoint> {
|
||||
const sandbox = await this.daytona.get(sandboxId);
|
||||
// Use signed preview URLs for server-to-sandbox communication.
|
||||
// The standard preview link may redirect to an interactive Auth0 flow from non-browser clients.
|
||||
// Signed preview URLs work for direct HTTP access.
|
||||
//
|
||||
// Request a longer-lived URL so sessions can run for several minutes without refresh.
|
||||
const preview = await sandbox.getSignedPreviewUrl(port, 6 * 60 * 60);
|
||||
return {
|
||||
url: preview.url,
|
||||
token: preview.token,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ export interface BranchSnapshot {
|
|||
}
|
||||
|
||||
export async function fetch(repoPath: string, options?: GitAuthOptions): Promise<void> {
|
||||
await execFileAsync("git", ["-C", repoPath, "fetch", "--prune"], {
|
||||
await execFileAsync("git", ["-C", repoPath, "fetch", "--prune", "--no-auto-gc"], {
|
||||
timeout: DEFAULT_GIT_FETCH_TIMEOUT_MS,
|
||||
env: gitEnv(options),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue