Skip to content

An open-source, faster Devin alternative

TypeScript

agent CLI: polish error render + add checkpoint_not_found code

Igor Zalutskidb71e16bb958
diff --git a/cmd/oc/internal/commands/agent.go b/cmd/oc/internal/commands/agent.go
index 98965a44..45f5b932 100644
--- a/cmd/oc/internal/commands/agent.go
+++ b/cmd/oc/internal/commands/agent.go
@@ -127,7 +127,7 @@ var agentCreateCmd = &cobra.Command{
return nil
}
- return pollUntilTerminal(cmd, sc, id, "instance")
+ return pollUntilTerminal(cmd, sc, id, "Instance creation")
},
}
@@ -365,7 +365,7 @@ var agentInstallCmd = &cobra.Command{
renderAsyncFallback(os.Stdout, jsonOutput, agentID, "Package install", postErr.Error())
return nil
}
- return renderAgentError(cmd, sc, agentID, "install")
+ return renderAgentError(cmd, sc, agentID, "Install")
},
}
@@ -459,7 +459,7 @@ func pollUntilTerminal(cmd *cobra.Command, sc *client.Client, agentID, op string
// Poll lost connection; Mode 3 fallback. Work may still be
// running in sessions-api — the user just can't observe it
// from here.
- renderAsyncFallback(os.Stdout, jsonOutput, agentID, capitalize(op)+" still in progress", "")
+ renderAsyncFallback(os.Stdout, jsonOutput, agentID, op+" still in progress", "")
return nil
}
continue
@@ -484,7 +484,7 @@ func pollUntilTerminal(cmd *cobra.Command, sc *client.Client, agentID, op string
// Mode 2 — failure. Render the error block and exit with the
// class-mapped code.
if !jsonOutput {
- fmt.Fprintln(os.Stderr, " ✗ "+capitalize(op)+" failed")
+ fmt.Fprintln(os.Stderr, " ✗ "+op+" failed")
fmt.Fprintln(os.Stderr)
RenderLastError(os.Stderr, agent.LastError)
} else {
@@ -505,7 +505,7 @@ func pollUntilTerminal(cmd *cobra.Command, sc *client.Client, agentID, op string
}
// Mode 3 — poll hit the cap. Work is likely still running.
- renderAsyncFallback(os.Stdout, jsonOutput, agentID, capitalize(op)+" still in progress", "")
+ renderAsyncFallback(os.Stdout, jsonOutput, agentID, op+" still in progress", "")
return nil
}
@@ -525,7 +525,7 @@ func renderAgentError(cmd *cobra.Command, sc *client.Client, agentID, op string)
return fmt.Errorf("%s failed (no error detail available — check server logs)", op)
}
if !jsonOutput {
- fmt.Fprintln(os.Stderr, " ✗ "+capitalize(op)+" failed")
+ fmt.Fprintln(os.Stderr, " ✗ "+op+" failed")
fmt.Fprintln(os.Stderr)
RenderLastError(os.Stderr, agent.LastError)
} else {
@@ -534,13 +534,6 @@ func renderAgentError(cmd *cobra.Command, sc *client.Client, agentID, op string)
return &ExitError{Code: ExitCodeFor(agent.LastError)}
}
-func capitalize(s string) string {
- if s == "" {
- return s
- }
- return strings.ToUpper(s[:1]) + s[1:]
-}
-
// ── Helpers ──
func formatList(v interface{}) string {
diff --git a/cmd/oc/internal/commands/errors.go b/cmd/oc/internal/commands/errors.go
index da0098d4..92b8d512 100644
--- a/cmd/oc/internal/commands/errors.go
+++ b/cmd/oc/internal/commands/errors.go
@@ -47,6 +47,12 @@ var codeCatalog = map[string]struct {
"Contact an admin to share it, or use an API key from the owning org.",
docs: "https://docs.opencomputer.dev/errors/checkpoint-org",
},
+ "checkpoint_not_found": {
+ class: classUpstream4xx,
+ suggestion: "The checkpoint configured for this core no longer exists on OC.\n" +
+ "It may have been deleted or replaced. Contact the operator to\n" +
+ "rebuild the checkpoint and update the sessions-api config.",
+ },
"telegram_unauthorized": {
class: classUpstream4xx,
suggestion: "Telegram rejected the bot token. Verify the token at https://t.me/BotFather.",
@@ -100,7 +106,10 @@ func RenderLastError(w io.Writer, le *LastError) {
fmt.Fprintf(w, "%s:\n", title)
fmt.Fprintf(w, " Phase: %s\n", le.Phase)
- reason := le.Message
+ // Upstream response bodies frequently carry trailing whitespace / newlines
+ // that survive the round-trip. Normalize before appending the upstream
+ // status so the block renders on one clean line.
+ reason := strings.TrimSpace(le.Message)
if le.UpstreamStatus != 0 {
reason = fmt.Sprintf("%s (%d from upstream)", reason, le.UpstreamStatus)
}