agent/pkg/agentic/remote_status.go
Snider 90b03191b2 feat(agent): v0.2.0 — HTTP daemon, remote dispatch, review queue, verify+merge
Major additions:
- core-agent serve: persistent HTTP daemon with PID file, health check, registry
- agentic_dispatch_remote: dispatch tasks to remote agents (Charon) over MCP HTTP
- agentic_status_remote: check remote agent workspace status
- agentic_mirror: sync Forge repos to GitHub mirrors with file count limits
- agentic_review_queue: CodeRabbit/Codex review queue with rate-limit awareness
- verify.go: auto-verify (run tests) + auto-merge + retry with rebase + needs-review label
- monitor sync: checkin API integration for cross-agent repo sync
- PostToolUse inbox notification hook (check-notify.sh)

Dispatch improvements:
- --dangerously-skip-permissions (CLI flag changed)
- proc.CloseStdin() after spawn (Claude CLI stdin pipe fix)
- GOWORK=off in agent env and verify
- Exit code / BLOCKED.md / failure detection
- Monitor poke for instant notifications

New agent types:
- coderabbit: CodeRabbit CLI review (--plain --base)
- codex:review: OpenAI Codex review mode

Integrations:
- CODEX.md: OpenAI Codex conventions file
- Gemini extension: points at core-agent MCP (not Node server)
- Codex config: core-agent MCP server added
- GitHub webhook handler + CodeRabbit KPI tables (PHP)
- Forgejo provider for uptelligence webhooks
- Agent checkin endpoint for repo sync

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 17:45:04 +00:00

97 lines
2.5 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package agentic
import (
"context"
"encoding/json"
"net/http"
"time"
coreerr "forge.lthn.ai/core/go-log"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
// --- agentic_status_remote tool ---
// RemoteStatusInput queries a remote core-agent for workspace status.
type RemoteStatusInput struct {
Host string `json:"host"` // Remote agent host (e.g. "charon")
}
// RemoteStatusOutput is the response from a remote status check.
type RemoteStatusOutput struct {
Success bool `json:"success"`
Host string `json:"host"`
Workspaces []WorkspaceInfo `json:"workspaces"`
Count int `json:"count"`
Error string `json:"error,omitempty"`
}
func (s *PrepSubsystem) registerRemoteStatusTool(server *mcp.Server) {
mcp.AddTool(server, &mcp.Tool{
Name: "agentic_status_remote",
Description: "Check workspace status on a remote core-agent (e.g. Charon). Shows running, completed, blocked, and failed agents.",
}, s.statusRemote)
}
func (s *PrepSubsystem) statusRemote(ctx context.Context, _ *mcp.CallToolRequest, input RemoteStatusInput) (*mcp.CallToolResult, RemoteStatusOutput, error) {
if input.Host == "" {
return nil, RemoteStatusOutput{}, coreerr.E("statusRemote", "host is required", nil)
}
addr := resolveHost(input.Host)
token := remoteToken(input.Host)
url := "http://" + addr + "/mcp"
client := &http.Client{Timeout: 15 * time.Second}
sessionID, err := mcpInitialize(ctx, client, url, token)
if err != nil {
return nil, RemoteStatusOutput{
Host: input.Host,
Error: "unreachable: " + err.Error(),
}, nil
}
rpcReq := map[string]any{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": map[string]any{
"name": "agentic_status",
"arguments": map[string]any{},
},
}
body, _ := json.Marshal(rpcReq)
result, err := mcpCall(ctx, client, url, token, sessionID, body)
if err != nil {
return nil, RemoteStatusOutput{
Host: input.Host,
Error: "call failed: " + err.Error(),
}, nil
}
output := RemoteStatusOutput{
Success: true,
Host: input.Host,
}
var rpcResp struct {
Result struct {
Content []struct {
Text string `json:"text"`
} `json:"content"`
} `json:"result"`
}
if json.Unmarshal(result, &rpcResp) == nil && len(rpcResp.Result.Content) > 0 {
var statusOut StatusOutput
if json.Unmarshal([]byte(rpcResp.Result.Content[0].Text), &statusOut) == nil {
output.Workspaces = statusOut.Workspaces
output.Count = statusOut.Count
}
}
return nil, output, nil
}