mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-24 05:41:40 +00:00
fix(ui-tui): surface RPC errors and guard invalid gateway responses
This commit is contained in:
parent
0642b6cc53
commit
cac1b1b724
4 changed files with 328 additions and 55 deletions
21
ui-tui/src/lib/rpc.ts
Normal file
21
ui-tui/src/lib/rpc.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
export type RpcResult = Record<string, any>
|
||||
|
||||
export const asRpcResult = (value: unknown): RpcResult | null => {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
||||
return null
|
||||
}
|
||||
|
||||
return value as RpcResult
|
||||
}
|
||||
|
||||
export const rpcErrorMessage = (err: unknown) => {
|
||||
if (err instanceof Error && err.message) {
|
||||
return err.message
|
||||
}
|
||||
|
||||
if (typeof err === 'string' && err.trim()) {
|
||||
return err
|
||||
}
|
||||
|
||||
return 'request failed'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue