2026-03-17 17:45:04 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
package agentic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-03-22 03:41:07 +00:00
|
|
|
core "dappco.re/go/core"
|
2026-03-17 17:45:04 +00:00
|
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type RemoteStatusInput struct {
|
2026-03-31 05:28:26 +00:00
|
|
|
Host string `json:"host"`
|
2026-03-17 17:45:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type RemoteStatusOutput struct {
|
2026-03-23 12:53:33 +00:00
|
|
|
Success bool `json:"success"`
|
|
|
|
|
Host string `json:"host"`
|
|
|
|
|
Stats StatusOutput `json:"stats"`
|
|
|
|
|
Error string `json:"error,omitempty"`
|
2026-03-17 17:45:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 == "" {
|
2026-03-22 03:41:07 +00:00
|
|
|
return nil, RemoteStatusOutput{}, core.E("statusRemote", "host is required", nil)
|
2026-03-17 17:45:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-02 06:23:07 +00:00
|
|
|
output := RemoteStatusOutput{
|
|
|
|
|
Success: true,
|
|
|
|
|
Host: input.Host,
|
2026-03-17 17:45:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-02 06:23:07 +00:00
|
|
|
client := NewRemoteClient(input.Host)
|
2026-03-17 17:45:04 +00:00
|
|
|
|
2026-04-02 06:23:07 +00:00
|
|
|
sessionID, err := client.Initialize(ctx)
|
|
|
|
|
if err != nil {
|
2026-03-30 07:30:42 +00:00
|
|
|
return nil, RemoteStatusOutput{
|
|
|
|
|
Host: input.Host,
|
2026-04-02 06:23:07 +00:00
|
|
|
Error: core.Concat("unreachable: ", err.Error()),
|
2026-03-30 07:30:42 +00:00
|
|
|
}, nil
|
|
|
|
|
}
|
2026-04-02 06:23:07 +00:00
|
|
|
|
|
|
|
|
result, err := client.Call(ctx, sessionID, client.ToolCallBody(2, "agentic_status", map[string]any{}))
|
|
|
|
|
if err != nil {
|
2026-03-17 17:45:04 +00:00
|
|
|
return nil, RemoteStatusOutput{
|
|
|
|
|
Host: input.Host,
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
Error: core.Concat("call failed: ", err.Error()),
|
2026-03-17 17:45:04 +00:00
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 21:41:45 +00:00
|
|
|
var rpcResponse struct {
|
2026-03-17 17:45:04 +00:00
|
|
|
Result struct {
|
|
|
|
|
Content []struct {
|
|
|
|
|
Text string `json:"text"`
|
|
|
|
|
} `json:"content"`
|
|
|
|
|
} `json:"result"`
|
2026-03-21 17:10:43 +00:00
|
|
|
Error *struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
} `json:"error"`
|
2026-03-17 17:45:04 +00:00
|
|
|
}
|
2026-03-30 21:41:45 +00:00
|
|
|
if r := core.JSONUnmarshal(result, &rpcResponse); !r.OK {
|
2026-03-21 17:10:43 +00:00
|
|
|
output.Success = false
|
|
|
|
|
output.Error = "failed to parse response"
|
|
|
|
|
return nil, output, nil
|
|
|
|
|
}
|
2026-03-30 21:41:45 +00:00
|
|
|
if rpcResponse.Error != nil {
|
2026-03-21 17:10:43 +00:00
|
|
|
output.Success = false
|
2026-03-30 21:41:45 +00:00
|
|
|
output.Error = rpcResponse.Error.Message
|
2026-03-21 17:10:43 +00:00
|
|
|
return nil, output, nil
|
|
|
|
|
}
|
2026-03-30 21:41:45 +00:00
|
|
|
if len(rpcResponse.Result.Content) > 0 {
|
2026-03-17 17:45:04 +00:00
|
|
|
var statusOut StatusOutput
|
2026-03-30 21:41:45 +00:00
|
|
|
if r := core.JSONUnmarshalString(rpcResponse.Result.Content[0].Text, &statusOut); r.OK {
|
2026-03-23 12:53:33 +00:00
|
|
|
output.Stats = statusOut
|
2026-03-17 17:45:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil, output, nil
|
|
|
|
|
}
|