Aggiunto supporto al motore CLI Antigravity (agy)

This commit is contained in:
Benedetta committed 2026-10-18 14:41:29 +02:00
1 parent 67d91e6a1f
commit 6bbaf7192f
12 files changed
+199 -69

No files matched your search

+80 -1
View File
@@ -1,4 +1,5 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Net.Http.Headers;
namespace AgentWikiUi.Core;
@@ -159,11 +160,89 @@ sealed class CodexEngine : Engine
}
}
sealed class AgyEngine : Engine
{
public override string Id => "agy";
public override string Name => "Antigravity";
public override string Author => "Antigravity";
public override string Executable => "agy";
public override bool OwnsSessionId => true;
public override ModelOption[] Models { get; } =
[
new("Gemini 3.0 Flash (Low)", "gemini-3.0-flash-low"),
new("Gemini 3.0 Flash (Medium)", "gemini-3.0-flash-medium"),
new("Gemini 3.0 Flash (High)", "gemini-3.0-flash-high"),
new("Claude Sonnet 4.6 (Thinking)", "claude-sonnet-4-6"),
new("Claude Opus 4.6 (Thinking)", "claude-opus-4-6-thinking"),
new("GPT-OSS 120B (Medium)", "gpt-oss-120b-medium"),
];
public override string[] Efforts { get; } = ["low", "medium", "high", "xhigh", "max"];
public override string DefaultModelId => "gemini-3.0-flash-low";
public override List<string> BuildArgs(string prompt, string? sessionId, bool resume, string model, string effort, bool structured)
{
var args = new List<string>();
if (structured) args.AddRange(["--output-format", "json"]);
if (resume && sessionId is not null) args.AddRange(["--conversation", sessionId]);
if (model != "") args.AddRange(["--model", model]);
if (effort != "") args.AddRange(["--effort", effort]);
args.AddRange(["--print-timeout", "120s"]);
args.AddRange(["-p", prompt]); // tutti i flag vanno passati PRIMA di -p
return args;
}
public override EngineReply Parse(int code, string stdout, string stderr)
{
string? conversationId = null;
string? response = null;
string? error = null;
var trimmed = stdout.Trim();
if (!string.IsNullOrEmpty(trimmed))
{
var start = trimmed.IndexOf('{');
var end = trimmed.LastIndexOf('}');
if (start >= 0 && end > start)
{
try
{
using var doc = JsonDocument.Parse(trimmed.Substring(start, end - start + 1));
var root = doc.RootElement;
if (root.TryGetProperty("conversation_id", out var convProp))
conversationId = convProp.GetString();
if (root.TryGetProperty("response", out var respProp))
response = respProp.GetString();
if (root.TryGetProperty("status", out var statusProp) && statusProp.GetString() != "SUCCESS")
error = $"Stato {statusProp.GetString()}";
if (root.TryGetProperty("error", out var errProp))
error = errProp.GetString() ?? error;
}
catch (JsonException) { }
}
}
if (code != 0) return new("", conversationId, Failed(code, error ?? stderr.Trim()));
if (error is not null && string.IsNullOrWhiteSpace(response)) return new("", conversationId, error);
if (string.IsNullOrWhiteSpace(response)) return new("", conversationId, error ?? (string.IsNullOrWhiteSpace(stderr) ? "agy non ha restituito nessuna risposta." : stderr.Trim()));
return new(response.Trim(), conversationId, null);
}
public override async Task<string?> FetchLatestVersionAsync(HttpClient http, CancellationToken ct)
{
var text = await http.GetStringAsync("https://antigravity-cli-auto-updater-974169037036.us-central1.run.app", ct);
var m = Regex.Match(text, @"Stable Version:\s*v?(\d+\.\d+(?:\.\d+)?)");
return m.Success ? m.Groups[1].Value : text.Trim();
}
}
static class Engines
{
public static readonly Engine Claude = new ClaudeEngine();
public static readonly Engine Codex = new CodexEngine();
public static readonly Engine[] All = [Claude, Codex];
public static readonly Engine Agy = new AgyEngine();
public static readonly Engine[] All = [Claude, Codex, Agy];
public static Engine? Find(string? id) => All.FirstOrDefault(e => e.Id == id);
}
+2
View File
@@ -126,6 +126,8 @@ static class EngineUpdater
("codex", _) => OperatingSystem.IsWindows()
? "powershell -ExecutionPolicy ByPass -c \"irm https://chatgpt.com/codex/install.ps1 | iex\""
: "curl -fsSL https://chatgpt.com/codex/install.sh | sh",
("agy", InstallMethod.Homebrew) => "brew upgrade agy",
("agy", _) => "agy update",
_ => $"{engine.Executable} update",
};
}