copilot

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package copilot is the first inference provider behind CSF's brain contract: the GitHub Copilot agent loop, reached through the existing Copilot adapter's generated Workbench client (services/copilot-adapter/gen/api). It wraps that client; it does not reimplement or move the adapter.

Copilot is an agent loop, so what it proposes for an assignment is one queued agent turn in a Workbench session and worktree. The tool calls that turn makes are themselves proposals: the session's permission policy (ask, by default) holds each one as a pending session request until the caller resolves it. Accepting the turn grants no tool permission.

Index

Constants

View Source
const ProviderName = "copilot"

ProviderName is the Provider every Copilot proposal carries.

Variables

View Source
var ErrNoSession = errors.New("copilot address: a nonzero session identifier is required")

ErrNoSession reports an address built without a session identifier.

Functions

This section is empty.

Types

type Assignment

type Assignment struct {
	Session api.CreateSessionJSONRequestBody
	Prompt  api.SubmitPromptJSONRequestBody
}

Assignment is the context the Copilot brain decides on: the generated Workbench session and prompt requests. Their idempotency keys make a repeated proposal replay the same session and turn.

type CopilotBrain

type CopilotBrain struct {
	// contains filtered or unexported fields
}

CopilotBrain proposes Copilot agent turns through a Workbench client.

func NewCopilotBrain

func NewCopilotBrain(client IWorkbenchClient) (*CopilotBrain, error)

NewCopilotBrain wraps client, the capability that reaches the Copilot adapter. The caller owns the client's endpoint, transport and lifetime.

func (*CopilotBrain) Propose

func (brain *CopilotBrain) Propose(ctx context.Context, assignment *Assignment) (*model.Proposal[Turn], error)

Propose creates (or replays) the assignment's session and queues its prompt, returning the accepted turn as the single proposed action.

type IWorkbenchClient

type IWorkbenchClient interface {
	CreateSessionWithResponse(ctx context.Context, body api.CreateSessionJSONRequestBody, reqEditors ...api.RequestEditorFn) (*api.CreateSessionResponse, error)
	SubmitPromptWithResponse(ctx context.Context, sessionId api.SessionId, body api.SubmitPromptJSONRequestBody, reqEditors ...api.RequestEditorFn) (*api.SubmitPromptResponse, error)
}

IWorkbenchClient is the slice of the adapter's generated client this provider uses. *api.ClientWithResponses satisfies it; specs substitute a gomock double at exactly this boundary.

type InProcessAddress

type InProcessAddress struct {
	model.InProcessTier
	Session uuid.UUID
}

InProcessAddress is a Copilot Workbench session multiplexed on the bridge of a Copilot adapter mounted in the same runtime as the inbox. Messages reach it by a direct call into that adapter, so it is in the in-process tier. Build one only in the composition that mounts the adapter.

func NewInProcessAddress

func NewInProcessAddress(session uuid.UUID) (InProcessAddress, error)

NewInProcessAddress addresses session on the adapter mounted in this runtime.

func (InProcessAddress) Key

func (address InProcessAddress) Key() string

Key is copilot/in_process/<session>.

func (InProcessAddress) Provider

func (address InProcessAddress) Provider() string

Provider is ProviderName.

type NetworkAddress

type NetworkAddress struct {
	model.NetworkTier
	Session uuid.UUID
	Adapter string
}

NetworkAddress is a Copilot Workbench session on an adapter in another runtime, reached through the Copilot provider over ipc/net. Adapter is that adapter's host:port; on this fleet it is a tailnet address.

func NewNetworkAddress

func NewNetworkAddress(session uuid.UUID, adapter string) (NetworkAddress, error)

NewNetworkAddress addresses session on the adapter at adapter (host:port).

func (NetworkAddress) Key

func (address NetworkAddress) Key() string

Key is copilot/network/<adapter>/<session>.

func (NetworkAddress) Provider

func (address NetworkAddress) Provider() string

Provider is ProviderName.

type Turn

type Turn struct {
	SessionID  uuid.UUID
	WorktreeID uuid.UUID
	TurnID     uuid.UUID
}

Turn is the action the Copilot brain proposes for an assignment. A turn identifier acknowledges prompt acceptance; it does not prove completion.

type UnconfirmedTurnError

type UnconfirmedTurnError struct {
	Turn Turn
	Err  error
}

UnconfirmedTurnError reports that the session exists but prompt acceptance was not confirmed. Turn carries the session and worktree with a zero TurnID; retrying the same assignment recovers its identities.

func (*UnconfirmedTurnError) Error

func (failure *UnconfirmedTurnError) Error() string

func (*UnconfirmedTurnError) Unwrap

func (failure *UnconfirmedTurnError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL