73 lines
2.5 KiB
Go
73 lines
2.5 KiB
Go
package ports
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/aoagents/agent-orchestrator/backend/internal/domain"
|
|
)
|
|
|
|
// PRWriter records the PR facts a PR observation carries. The pr table's own DB
|
|
// triggers emit the CDC; this just writes the rows.
|
|
type PRWriter interface {
|
|
// WritePR persists a full PR observation — scalar facts, check runs, and the
|
|
// replacement comment set — in one transaction, so the rows and the CDC
|
|
// events they emit are all-or-nothing.
|
|
WritePR(ctx context.Context, pr domain.PullRequest, checks []domain.PullRequestCheck, comments []domain.PullRequestComment) error
|
|
}
|
|
|
|
// AgentMessenger injects a message into a running agent.
|
|
type AgentMessenger interface {
|
|
Send(ctx context.Context, id domain.SessionID, message string) error
|
|
}
|
|
|
|
// ---- runtime / agent / workspace plugin ports ----
|
|
|
|
// Runtime is the full runtime adapter contract: session creation/teardown plus
|
|
// liveness probing for reapers and terminal attachment.
|
|
type Runtime interface {
|
|
Create(ctx context.Context, cfg RuntimeConfig) (RuntimeHandle, error)
|
|
Destroy(ctx context.Context, handle RuntimeHandle) error
|
|
IsAlive(ctx context.Context, handle RuntimeHandle) (bool, error)
|
|
}
|
|
|
|
// RuntimeConfig is the spec for launching a session's process in a Runtime.
|
|
// Argv is the agent's launch command as discrete arguments; each Runtime
|
|
// shell-quotes it for its own shell, so the command survives args with spaces
|
|
// (e.g. a prompt) without the caller guessing the target shell's quoting.
|
|
type RuntimeConfig struct {
|
|
SessionID domain.SessionID
|
|
WorkspacePath string
|
|
Argv []string
|
|
Env map[string]string
|
|
}
|
|
|
|
// RuntimeHandle identifies a live runtime instance. Its ID is opaque outside
|
|
// the concrete runtime adapter.
|
|
type RuntimeHandle struct {
|
|
ID string
|
|
}
|
|
|
|
// The Agent port and its supporting types live in agent.go.
|
|
|
|
// Workspace is the isolated checkout an agent works in (a git worktree or clone).
|
|
type Workspace interface {
|
|
Create(ctx context.Context, cfg WorkspaceConfig) (WorkspaceInfo, error)
|
|
Destroy(ctx context.Context, info WorkspaceInfo) error
|
|
Restore(ctx context.Context, cfg WorkspaceConfig) (WorkspaceInfo, error)
|
|
}
|
|
|
|
// WorkspaceConfig is the spec for creating or restoring a session's workspace.
|
|
type WorkspaceConfig struct {
|
|
ProjectID domain.ProjectID
|
|
SessionID domain.SessionID
|
|
Branch string
|
|
}
|
|
|
|
// WorkspaceInfo describes a created workspace — where it lives and its branch.
|
|
type WorkspaceInfo struct {
|
|
Path string
|
|
Branch string
|
|
SessionID domain.SessionID
|
|
ProjectID domain.ProjectID
|
|
}
|