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:
Nathan Flurry 2026-03-14 12:14:06 -07:00 committed by GitHub
parent 5a1b32a271
commit 70d31f819c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
82 changed files with 2625 additions and 4166 deletions

View file

@ -5,7 +5,15 @@ import { dirname, resolve } from "node:path";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { tmpdir } from "node:os";
import { InMemorySessionPersistDriver, SandboxAgent, type SessionEvent } from "../src/index.ts";
import {
InMemorySessionPersistDriver,
SandboxAgent,
type ListEventsRequest,
type ListPage,
type SessionEvent,
type SessionPersistDriver,
type SessionRecord,
} from "../src/index.ts";
import { spawnSandboxAgent, isNodeRuntime, type SandboxAgentSpawnHandle } from "../src/spawn.ts";
import { prepareMockAgentDataHome } from "./helpers/mock-agent.ts";
import WebSocket from "ws";
@ -40,6 +48,44 @@ function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
class StrictUniqueSessionPersistDriver implements SessionPersistDriver {
private readonly events = new InMemorySessionPersistDriver({
maxEventsPerSession: 500,
});
private readonly eventIndexesBySession = new Map<string, Set<number>>();
async getSession(id: string): Promise<SessionRecord | null> {
return this.events.getSession(id);
}
async listSessions(request?: { cursor?: string; limit?: number }): Promise<ListPage<SessionRecord>> {
return this.events.listSessions(request);
}
async updateSession(session: SessionRecord): Promise<void> {
await this.events.updateSession(session);
}
async listEvents(request: ListEventsRequest): Promise<ListPage<SessionEvent>> {
return this.events.listEvents(request);
}
async insertEvent(event: SessionEvent): Promise<void> {
await sleep(5);
const indexes = this.eventIndexesBySession.get(event.sessionId) ?? new Set<number>();
if (indexes.has(event.eventIndex)) {
throw new Error("UNIQUE constraint failed: sandbox_agent_events.session_id, sandbox_agent_events.event_index");
}
indexes.add(event.eventIndex);
this.eventIndexesBySession.set(event.sessionId, indexes);
await sleep(5);
await this.events.insertEvent(event);
}
}
async function waitFor<T>(fn: () => T | undefined | null, timeoutMs = 6000, stepMs = 30): Promise<T> {
const started = Date.now();
while (Date.now() - started < timeoutMs) {
@ -207,6 +253,27 @@ describe("Integration: TypeScript SDK flat session API", () => {
await sdk.dispose();
});
it("preserves observed event indexes across session creation follow-up calls", async () => {
const persist = new StrictUniqueSessionPersistDriver();
const sdk = await SandboxAgent.connect({
baseUrl,
token,
persist,
});
const session = await sdk.createSession({ agent: "mock" });
const prompt = await session.prompt([{ type: "text", text: "preserve event indexes" }]);
expect(prompt.stopReason).toBe("end_turn");
const events = await waitForAsync(async () => {
const page = await sdk.getEvents({ sessionId: session.id, limit: 200 });
return page.items.length >= 4 ? page : null;
});
expect(new Set(events.items.map((event) => event.eventIndex)).size).toBe(events.items.length);
await sdk.dispose();
});
it("covers agent query flags and filesystem HTTP helpers", async () => {
const sdk = await SandboxAgent.connect({
baseUrl,