Skip to content

Commit 26c2e7c

Browse files
committed
robust fallback for rich Text and safer output handling
1 parent 81383d9 commit 26c2e7c

File tree

1 file changed

+8
-8
lines changed
  • packages/agent-os/src/agent_os/policies

1 file changed

+8
-8
lines changed

packages/agent-os/src/agent_os/policies/cli.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def error(msg: str, no_color: bool = False) -> None:
8989
console = _import_console(no_color, use_stderr=True)
9090
Text = _import_rich_text()
9191
if console and Text:
92-
console.print(Text.from_markup(msg), style="red")
92+
console.print(Text(msg), style="red")
9393
else:
9494
print(msg, file=sys.stderr)
9595

@@ -98,34 +98,34 @@ def success(msg: str, no_color: bool = False) -> None:
9898
console = _import_console(no_color, use_stderr=False)
9999
Text = _import_rich_text()
100100
if console and Text:
101-
console.print(Text.from_markup(msg), style="green")
101+
console.print(Text(msg), style="green")
102102
else:
103103
print(msg)
104104

105105
def warn(msg: str, no_color: bool = False) -> None:
106106
"""Print a warning message in yellow to stdout."""
107107
console = _import_console(no_color, use_stderr=False)
108108
Text = _import_rich_text()
109-
if console:
110-
console.print(Text.from_markup(msg), style="yellow")
109+
if console and Text:
110+
console.print(Text(msg), style="yellow")
111111
else:
112112
print(msg)
113113

114114
def policy_violation(msg: str, no_color: bool = False) -> None:
115115
"""Print a policy violation message in bold red to stdout."""
116116
console = _import_console(no_color, use_stderr=True)
117117
Text = _import_rich_text()
118-
if console:
119-
console.print(Text.from_markup(msg), style="bold red")
118+
if console and Text:
119+
console.print(Text(msg), style="bold red")
120120
else:
121121
print(msg)
122122

123123
def passed_check(msg: str, no_color: bool = False) -> None:
124124
"""Print a passed-check message with a green checkmark to stdout."""
125125
console = _import_console(no_color, use_stderr=False)
126126
Text = _import_rich_text()
127-
if console:
128-
console.print(Text.from_markup(f"\u2714 {msg}"), style="green")
127+
if console and Text:
128+
console.print(Text(f"\u2714 {msg}"), style="green")
129129
else:
130130
print(f"\u2714 {msg}")
131131

0 commit comments

Comments
 (0)