import type { DriverContext, ResourceDriver, Workspace } from "@rebuno/uber-agent/workspace";
export const workdir = "/home/user/repo";
export default function driver({
repo,
token,
prepareCheckout,
CheckpointUnavailable,
}: DriverContext): ResourceDriver<Workspace, { sandboxId: string }> {
return {
driverId: "acme.sandbox.v1",
configuration: { repo },
async create(checkpointRef) {
// Create the sandbox, from checkpointRef when given.
// Throw CheckpointUnavailable when that checkpoint is gone.
await prepareCheckout(workspace, repo, Boolean(checkpointRef));
return { handle: workspace, binding: workspace.binding };
},
async open(binding) {
// Reconnect to the sandbox with this dispatch's token.
},
// Optional: without it, the workspace has no checkpoints.
async checkpoint(workspace) {
// Snapshot the sandbox and return the snapshot's id.
},
};
}