scene_run plays the game the way a player would and checks the result in the same run. input presses actions by frame: press, hold over a range, release, and axis values. assert reads values with the paths scene_set takes, at a frame (@120) or at any frame of the run, with ~= comparing numbers within 0.01, and exists or gone for nodes; the report gives ok or failed with the value and the frame, a failed check fails the run, and the CLI exits with 2. shot captures up to three frames from a run with a hidden window: the answer carries them as images scaled to 640 wide (scale changes it) and the full frames stay under .aego/cache/runs. While the editor is open, the CLI and aego mcp go through it. The editor serves the agent commands on a second loopback MCP server over the same bridge and writes its address in .aego/editor.lock. A change becomes an Undo step named after its origin, via CLI or via agent with the client's name, and asset creation works because the editor does it. Window > Confirm Changes from Outside Agents (editor.proxy.confirm) makes these changes wait in the Agent panel instead; follow mode shows outside calls like the panel's agent's. When the editor does not answer, the CLI works on the files as before. The native Windows and macOS jobs of ci-platforms are named smoke: the Windows build itself is cross-compiled on the Linux runner.
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package mcp
|
|
|
|
import (
|
|
"bufio"
|
|
"encoding/json"
|
|
"io"
|
|
|
|
"aego/app/agent"
|
|
)
|
|
|
|
// Relay passes an outside agent's MCP session to the open editor, so its changes become the editor's Undo steps, named after the client.
|
|
func Relay(in io.Reader, out io.Writer, addr, token string) error {
|
|
client := "agent"
|
|
sc := bufio.NewScanner(in)
|
|
sc.Buffer(make([]byte, 0, 1<<20), maxBody)
|
|
for sc.Scan() {
|
|
line := sc.Bytes()
|
|
if len(line) == 0 {
|
|
continue
|
|
}
|
|
var msg map[string]any
|
|
if err := json.Unmarshal(line, &msg); err != nil {
|
|
continue
|
|
}
|
|
params, _ := msg["params"].(map[string]any)
|
|
switch msg["method"] {
|
|
case "initialize":
|
|
if info, ok := params["clientInfo"].(map[string]any); ok {
|
|
if name, ok := info["name"].(string); ok && name != "" {
|
|
client = name
|
|
}
|
|
}
|
|
case "tools/call":
|
|
if params != nil {
|
|
args, _ := params["arguments"].(map[string]any)
|
|
if args == nil {
|
|
args = map[string]any{}
|
|
}
|
|
args[agent.ViaArg] = "via agent: " + client
|
|
params["arguments"] = args
|
|
}
|
|
}
|
|
body, _ := json.Marshal(msg)
|
|
rep, err := agent.ProxyPost(addr, token, body)
|
|
if err != nil {
|
|
id, ok := msg["id"]
|
|
if !ok {
|
|
continue
|
|
}
|
|
rep, _ = json.Marshal(map[string]any{"jsonrpc": "2.0", "id": id, "error": map[string]any{"code": -32000, "message": "the editor closed; start the MCP server again: " + err.Error()}})
|
|
}
|
|
if len(rep) == 0 {
|
|
continue
|
|
}
|
|
if _, err := out.Write(append(rep, '\n')); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return sc.Err()
|
|
}
|