Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(computer): read Antigravity run_command input and exit code

jeffrey02cf97475e7a
diff --git a/apps/computer/local-daemon/internal/provider/native/antigravity_fake_test.go b/apps/computer/local-daemon/internal/provider/native/antigravity_fake_test.go
index 980dba61..f79e16fc 100644
--- a/apps/computer/local-daemon/internal/provider/native/antigravity_fake_test.go
+++ b/apps/computer/local-daemon/internal/provider/native/antigravity_fake_test.go
@@ -154,7 +154,7 @@ func (f *agyFakeProcess) prompt(id json.RawMessage, sessionID string) {
map[string]any{"content": "List files", "status": "in_progress", "priority": "high"},
map[string]any{"content": "Report", "status": "pending", "priority": "low"},
}})
- f.update(sessionID, map[string]any{"sessionUpdate": "tool_call", "toolCallId": "call-1", "title": "ls", "kind": "execute", "status": "pending", "rawInput": map[string]any{"command": "ls"}})
+ f.update(sessionID, map[string]any{"sessionUpdate": "tool_call", "toolCallId": "call-1", "title": "ls", "kind": "execute", "status": "pending", "rawInput": map[string]any{"CommandLine": "ls", "WaitMsBeforeAsync": 5000}})
if f.mode == "permission" || f.mode == "permission-no-reject" {
command := os.Getenv(agyFakeCommandEnv)
if command == "" {
@@ -166,7 +166,7 @@ func (f *agyFakeProcess) prompt(id json.RawMessage, sessionID string) {
}
f.send(map[string]any{"jsonrpc": "2.0", "id": 900, "method": "session/request_permission", "params": map[string]any{
"sessionId": sessionID,
- "toolCall": map[string]any{"toolCallId": "call-1", "title": command, "kind": "execute", "rawInput": map[string]any{"command": command}},
+ "toolCall": map[string]any{"toolCallId": "call-1", "title": command, "kind": "execute", "rawInput": map[string]any{"CommandLine": command}},
"options": options,
}})
<-f.answers
diff --git a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.go b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.go
index dd20723c..0a1d9280 100644
--- a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.go
+++ b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime.go
@@ -397,13 +397,9 @@ func (t *antigravityTurn) update(params json.RawMessage, observed time.Time) {
t.output.Reset()
t.tools[update.ToolCallID] = true
t.mu.Unlock()
- var input map[string]any
- if json.Unmarshal(update.RawInput, &input) != nil {
- input = nil
- }
t.emit(Event{
Kind: EventToolCall, ObservedAt: observed, ToolName: antigravityToolName(update), InvocationID: antigravityInvocationID(update.ToolCallID),
- Input: input, ActivityKind: antigravityActivity(update.Kind), ActivityTitle: update.Title,
+ Input: antigravityInput(update.RawInput), ActivityKind: antigravityActivity(update.Kind), ActivityTitle: update.Title,
})
t.toolResult(update, observed)
case "tool_call_update":
@@ -442,7 +438,36 @@ func (t *antigravityTurn) toolResult(update acpUpdate, observed time.Time) {
if output == "" && len(update.RawOutput) > 0 && string(update.RawOutput) != "null" {
output = piText(update.RawOutput)
}
- t.emit(Event{Kind: EventToolOutput, ObservedAt: observed, Status: update.Status, InvocationID: antigravityInvocationID(update.ToolCallID), Output: output})
+ t.emit(Event{Kind: EventToolOutput, ObservedAt: observed, Status: antigravityToolStatus(update), InvocationID: antigravityInvocationID(update.ToolCallID), Output: output})
+}
+
+// antigravityInput is a tool call's input with its shell command under
+// "command", where every Runtime's command reads it; run_command names it
+// "CommandLine".
+func antigravityInput(raw json.RawMessage) map[string]any {
+ var input map[string]any
+ if json.Unmarshal(raw, &input) != nil {
+ return nil
+ }
+ if command, ok := input["CommandLine"].(string); ok {
+ if _, named := input["command"]; !named {
+ input["command"] = command
+ }
+ }
+ return input
+}
+
+// antigravityToolStatus is a tool call's terminal status. run_command reports
+// a command that exits non-zero as completed, with its exit code in the raw
+// output.
+func antigravityToolStatus(update acpUpdate) string {
+ var output struct {
+ ExitCode *int `json:"exit_code"`
+ }
+ if update.Status == "completed" && json.Unmarshal(update.RawOutput, &output) == nil && output.ExitCode != nil && *output.ExitCode != 0 {
+ return "failed"
+ }
+ return update.Status
}
// permission answers session/request_permission: through the Run's
@@ -482,8 +507,7 @@ func (t *antigravityTurn) permission(frame acpFrame) {
// antigravityReview builds the permission review of one tool call. A
// command is reviewed as a shell command so the shared shell rules apply.
func antigravityReview(call acpUpdate, workspace string) permission.Request {
- var input map[string]any
- _ = json.Unmarshal(call.RawInput, &input)
+ input := antigravityInput(call.RawInput)
encoded, _ := json.Marshal(input)
tool := antigravityToolName(call)
command := ""
diff --git a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.go b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.go
index ac3885b3..87df8bf4 100644
--- a/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.go
+++ b/apps/computer/local-daemon/internal/provider/native/antigravity_runtime_test.go
@@ -357,3 +357,26 @@ func TestAntigravityReportsTheSessionItStartsAsTheTurnCheckpoint(t *testing.T) {
t.Fatal("Start accepted an assigned session id")
}
}
+
+func TestAntigravityRunCommandMapsToSharedCommandShape(t *testing.T) {
+ input := antigravityInput(json.RawMessage(`{"CommandLine":"teamhub message send --content hi","WaitMsBeforeAsync":5000}`))
+ if input["command"] != "teamhub message send --content hi" {
+ t.Fatalf("input = %#v", input)
+ }
+ review := antigravityReview(acpUpdate{Kind: "execute", RawInput: json.RawMessage(`{"CommandLine":"rm -rf build"}`)}, t.TempDir())
+ if review.Action.Command != "rm -rf build" || review.Action.Tool != "Bash" {
+ t.Fatalf("review = %#v", review.Action)
+ }
+ for _, test := range []struct {
+ status, output, want string
+ }{
+ {"completed", `{"output":"","exit_code":1}`, "failed"},
+ {"completed", `{"output":"","exit_code":0}`, "completed"},
+ {"completed", ``, "completed"},
+ {"failed", `{"exit_code":0}`, "failed"},
+ } {
+ if got := antigravityToolStatus(acpUpdate{Status: test.status, RawOutput: json.RawMessage(test.output)}); got != test.want {
+ t.Fatalf("status %s with %s = %s, want %s", test.status, test.output, got, test.want)
+ }
+ }
+}