diff options
Diffstat (limited to 'internal/executor/channel.go')
| -rw-r--r-- | internal/executor/channel.go | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/internal/executor/channel.go b/internal/executor/channel.go index 8605ffa..debe21d 100644 --- a/internal/executor/channel.go +++ b/internal/executor/channel.go @@ -3,46 +3,33 @@ package executor import ( "context" "encoding/json" - "errors" "sync" "time" + "github.com/thepeterstone/claudomator/internal/agentchannel" "github.com/thepeterstone/claudomator/internal/event" "github.com/thepeterstone/claudomator/internal/task" "github.com/google/uuid" ) -// ErrAgentBlocked is returned by AgentChannel.AskUser when the transport cannot -// deliver an answer within the current run — e.g. the file transport, which can -// only write-and-exit. Runners translate it into a *BlockedError so the task -// blocks and resumes later. Transports that can suspend the agent in-session -// (MCP, Phase 2) instead block and return the answer. -var ErrAgentBlocked = errors.New("agent blocked awaiting user input") - -// SubtaskSpec describes a child task an agent wants to spawn. -type SubtaskSpec struct { - Name string - Instructions string - Model string - MaxBudgetUSD float64 -} - -// AgentChannel is how a Runner reports agent-originated signals to the rest of -// the system. Implementations translate these into stored artifacts and events. -// The transport by which a Runner detects these signals — post-exit files -// today, MCP/tool-use in Phase 2 — is the Runner's private concern. -type AgentChannel interface { - // AskUser records that the agent needs human input. Transports that can - // suspend the agent in-session return the answer; those that cannot return - // ErrAgentBlocked. - AskUser(ctx context.Context, questionJSON string) (answer string, err error) - // ReportSummary records the agent's final summary text. - ReportSummary(ctx context.Context, summary string) error - // SpawnSubtask creates a child task and returns its ID. - SpawnSubtask(ctx context.Context, spec SubtaskSpec) (taskID string, err error) - // RecordProgress records a free-form progress note from the agent. - RecordProgress(ctx context.Context, message string) error -} +// AgentChannel, SubtaskSpec, BlockedError, and ErrAgentBlocked used to be +// defined directly in this package. Phase 1 of the multi-provider refactor +// moved them to internal/agentchannel (a small leaf package with no +// executor dependency) so that internal/agentloop — the new provider-neutral +// tool-use loop — can construct/inspect them without importing +// internal/executor. That matters because internal/executor now imports +// internal/agentloop (via nativerunner.go, which wires an agentloop.Loop up +// to a Runner); if agentloop imported executor too, that would be a direct +// import cycle. Re-exporting via type aliases (and a var assignment for the +// sentinel error) here means every existing reference to +// executor.AgentChannel / executor.SubtaskSpec / executor.BlockedError / +// executor.ErrAgentBlocked keeps compiling and behaving identically — an +// alias is the same type, not a copy. +type AgentChannel = agentchannel.AgentChannel +type SubtaskSpec = agentchannel.SubtaskSpec +type BlockedError = agentchannel.BlockedError + +var ErrAgentBlocked = agentchannel.ErrAgentBlocked // channelStore is the subset of storage the default channel needs. type channelStore interface { |
