Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: CLI instance commands return only IDs/results without auto-printed JSON

Mariof1eed946e539
diff --git a/cmd/pinchtab/cmd_cli.go b/cmd/pinchtab/cmd_cli.go
index 4cc7ff3e..d4593341 100644
--- a/cmd/pinchtab/cmd_cli.go
+++ b/cmd/pinchtab/cmd_cli.go
@@ -686,9 +686,14 @@ func cliInstanceLaunch(client *http.Client, base, token string, args []string) {
}
}
- result := doPost(client, base, token, "/instances/launch", body)
- if result == nil {
- return
+ // Use doPostRaw to avoid auto-printing JSON
+ respBody := doPostRaw(client, base, token, "/instances/launch", body)
+
+ // Parse and extract ID
+ var result map[string]any
+ if err := json.Unmarshal(respBody, &result); err != nil {
+ fmt.Fprintf(os.Stderr, "Failed to parse response: %v\n", err)
+ os.Exit(1)
}
// Display only ID as primary output
@@ -713,9 +718,13 @@ func cliInstanceStop(client *http.Client, base, token string, args []string) {
}
instID := args[0]
- result := doPost(client, base, token, fmt.Sprintf("/instances/%s/stop", instID), nil)
- if result == nil {
- return
+ respBody := doPostRaw(client, base, token, fmt.Sprintf("/instances/%s/stop", instID), nil)
+
+ // Parse and extract status
+ var result map[string]any
+ if err := json.Unmarshal(respBody, &result); err != nil {
+ fmt.Fprintf(os.Stderr, "Failed to parse response: %v\n", err)
+ os.Exit(1)
}
// Display result
@@ -875,6 +884,29 @@ func doPost(client *http.Client, base, token, path string, body map[string]any)
return result
}
+// doPostRaw sends POST request and returns raw response bytes (without auto-printing)
+func doPostRaw(client *http.Client, base, token, path string, body map[string]any) []byte {
+ data, _ := json.Marshal(body)
+ req, _ := http.NewRequest("POST", base+path, bytes.NewReader(data))
+ req.Header.Set("Content-Type", "application/json")
+ if token != "" {
+ req.Header.Set("Authorization", "Bearer "+token)
+ }
+ resp, err := client.Do(req)
+ if err != nil {
+ fatal("Request failed: %v", err)
+ }
+ defer func() { _ = resp.Body.Close() }()
+ respBody, _ := io.ReadAll(resp.Body)
+
+ if resp.StatusCode >= 400 {
+ fmt.Fprintf(os.Stderr, "Error %d: %s\n", resp.StatusCode, string(respBody))
+ os.Exit(1)
+ }
+
+ return respBody
+}
+
// checkServerAndGuide checks if pinchtab server is running and provides guidance
func checkServerAndGuide(client *http.Client, base, token string) bool {
req, _ := http.NewRequest("GET", base+"/health", nil)