Skip to content

Commit 9f67bb2

Browse files
ianhodgeoz-agent
andauthored
Creating backend abstraction for self hosted worker (#29)
Co-authored-by: Oz <oz-agent@warp.dev>
1 parent a695136 commit 9f67bb2

3 files changed

Lines changed: 616 additions & 541 deletions

File tree

internal/worker/backend.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package worker
2+
3+
import (
4+
"context"
5+
6+
"github.com/warpdotdev/oz-agent-worker/internal/types"
7+
)
8+
9+
// TaskParams contains pre-processed task parameters common to all backends.
10+
// This provides a layer of abstraction between the wire-format TaskAssignmentMessage
11+
// and the backend interface, so backends don't need to handle common concerns like
12+
// resolving environment variables, choosing default images, or building base CLI args.
13+
type TaskParams struct {
14+
TaskID string
15+
Task *types.Task
16+
17+
// EnvVars contains pre-resolved common environment variables (TASK_ID, Git config,
18+
// assignment env vars). Backends append their own config-specific env vars.
19+
EnvVars []string
20+
21+
// BaseArgs contains the base CLI arguments for the agent command
22+
// (agent run --share ... --task-id ... --server-root-url ... + augmented args).
23+
// Backends prepend their invocation prefix and append backend-specific flags.
24+
BaseArgs []string
25+
26+
// DockerImage is the resolved Docker image name (with default fallback applied).
27+
// Backends that don't use Docker can ignore this.
28+
DockerImage string
29+
30+
// Sidecars is the unified list of sidecar mounts for this task. The Warp agent
31+
// sidecar (mounted at /agent) is included as the first entry when present, followed
32+
// by any additional sidecars from the assignment. Backends that don't use sidecars
33+
// can ignore this.
34+
Sidecars []types.SidecarMount
35+
}
36+
37+
// Backend defines the interface for task execution backends.
38+
type Backend interface {
39+
// ExecuteTask runs the agent for the given task parameters.
40+
ExecuteTask(ctx context.Context, params *TaskParams) error
41+
// Shutdown cleans up backend resources.
42+
Shutdown(ctx context.Context)
43+
}

0 commit comments

Comments
 (0)