Documentation
¶
Overview ¶
Package ipc provides inter-process communication between the Forge daemon and CLI/TUI clients via platform-native mechanisms (named pipe on Windows, Unix domain socket on Linux/macOS).
Protocol: newline-delimited JSON messages.
Server side (daemon):
svr := ipc.NewServer()
svr.OnCommand(func(cmd Command) Response { ... })
svr.Start(ctx)
Client side (CLI/TUI):
client := ipc.NewClient()
resp, err := client.Send(Command{Type: "status"})
events := client.Subscribe(ctx) // stream events
Index ¶
- func ForgeDir() string
- func SocketExists() bool
- type ClarificationPayload
- type Client
- type CloseBeadPayload
- type Command
- type CommandHandler
- type CrucibleStatusItem
- type CruciblesResponse
- type DismissBeadPayload
- type Event
- type KillWorkerPayload
- type MergePRPayload
- type Response
- type RetryBeadPayload
- type RunBeadPayload
- type Server
- type StatusPayload
- type TagBeadPayload
- type ViewLogsPayload
- type ViewLogsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SocketExists ¶
func SocketExists() bool
SocketExists checks whether the daemon's IPC socket file exists.
Types ¶
type ClarificationPayload ¶
type ClarificationPayload struct {
BeadID string `json:"bead_id"`
Anvil string `json:"anvil"` // Required: which anvil the bead belongs to
Reason string `json:"reason"` // Why clarification is needed (used when setting)
}
ClarificationPayload is the payload for "set_clarification" / "clear_clarification" commands.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client connects to the daemon's IPC socket.
type CloseBeadPayload ¶
CloseBeadPayload is the payload for a "close_bead" command that closes a bead via bd close.
type Command ¶
type Command struct {
Type string `json:"type"` // "status", "kill_worker", "refresh", "queue", "run_bead", "set_clarification", "clear_clarification"
Payload json.RawMessage `json:"payload"` // Type-specific data
}
Command is a message sent from a client to the daemon.
type CommandHandler ¶
CommandHandler is called by the server for each incoming command.
type CrucibleStatusItem ¶
type CrucibleStatusItem struct {
ParentID string `json:"parent_id"`
ParentTitle string `json:"parent_title"`
Anvil string `json:"anvil"`
Branch string `json:"branch"`
Phase string `json:"phase"` // "started", "dispatching", "waiting", "final_pr", "complete", "paused"
TotalChildren int `json:"total_children"`
CompletedChildren int `json:"completed_children"`
CurrentChild string `json:"current_child"`
StartedAt string `json:"started_at"`
}
CrucibleStatusItem represents an active Crucible's current state.
type CruciblesResponse ¶
type CruciblesResponse struct {
Crucibles []CrucibleStatusItem `json:"crucibles"`
}
CruciblesResponse is the response payload for a "crucibles" command.
type DismissBeadPayload ¶
type DismissBeadPayload struct {
BeadID string `json:"bead_id"`
Anvil string `json:"anvil"`
PRID int `json:"pr_id,omitempty"`
}
DismissBeadPayload is the payload for a "dismiss_bead" command. Removes the bead from the Needs Attention list. When PRID > 0, the dismiss targets an exhausted PR (setting status to closed) rather than the retries table.
type Event ¶
type Event struct {
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
Data json.RawMessage `json:"data"`
}
Event is a push notification from daemon to subscribed clients.
type KillWorkerPayload ¶
KillWorkerPayload is the payload for a "kill_worker" command.
type MergePRPayload ¶
type MergePRPayload struct {
PRID int `json:"pr_id"`
PRNumber int `json:"pr_number"`
Anvil string `json:"anvil"`
}
MergePRPayload is the payload for a "merge_pr" command. Triggers a squash merge (or configured strategy) of a ready-to-merge PR.
type Response ¶
type Response struct {
Type string `json:"type"` // "ok", "error", "status", "event"
Payload json.RawMessage `json:"payload"` // Type-specific data
}
Response is a message sent from the daemon to a client.
type RetryBeadPayload ¶
type RetryBeadPayload struct {
BeadID string `json:"bead_id"`
Anvil string `json:"anvil"`
PRID int `json:"pr_id,omitempty"`
}
RetryBeadPayload is the payload for a "retry_bead" command. Clears needs_human flag and resets retry count so the bead re-enters the queue. When PRID > 0, the retry targets an exhausted PR (resetting fix counters and status back to open) rather than the retries table.
type RunBeadPayload ¶
type RunBeadPayload struct {
BeadID string `json:"bead_id"`
Anvil string `json:"anvil"` // Optional: narrows search if multiple anvils have same bead ID
}
RunBeadPayload is the payload for a "run_bead" command.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server listens for IPC connections from CLI/TUI clients.
func (*Server) OnCommand ¶
func (s *Server) OnCommand(h CommandHandler)
OnCommand sets the handler for incoming commands.
type StatusPayload ¶
type StatusPayload struct {
Running bool `json:"running"`
PID int `json:"pid"`
Uptime string `json:"uptime"`
Workers int `json:"workers"`
QueueSize int `json:"queue_size"`
OpenPRs int `json:"open_prs"`
LastPoll string `json:"last_poll"`
Quotas map[string]provider.Quota `json:"quotas,omitempty"`
DailyCost float64 `json:"daily_cost"`
DailyCostLimit float64 `json:"daily_cost_limit,omitempty"`
// CostLimitPaused reports that cost-based auto-dispatch via the Poller is
// currently paused due to hitting the daily cost limit. Manual run_bead
// dispatch remains allowed while this flag is true.
CostLimitPaused bool `json:"cost_limit_paused,omitempty"`
// CopilotPremiumRequests is the weighted count of Copilot premium requests used today.
CopilotPremiumRequests float64 `json:"copilot_premium_requests,omitempty"`
// CopilotRequestLimit is the configured daily limit (0 = no limit).
CopilotRequestLimit int `json:"copilot_request_limit,omitempty"`
// CopilotLimitReached is true when the copilot daily request limit has been reached.
CopilotLimitReached bool `json:"copilot_limit_reached,omitempty"`
}
StatusPayload is the response for a "status" command.
type TagBeadPayload ¶
TagBeadPayload is the payload for a "tag_bead" command that adds the anvil's configured auto-dispatch label to a bead via bd update. The daemon derives the tag from its own config; the client only needs to supply the bead identity.
type ViewLogsPayload ¶
type ViewLogsPayload struct {
BeadID string `json:"bead_id"`
}
ViewLogsPayload is the payload for a "view_logs" command.
type ViewLogsResponse ¶
type ViewLogsResponse struct {
LogPath string `json:"log_path"`
LastLines []string `json:"last_lines"`
}
ViewLogsResponse is the response payload for a "view_logs" command.