mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
chore: uptick
This commit is contained in:
parent
cb31732c4f
commit
8e06db56fd
14 changed files with 1712 additions and 1362 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import type { CommandDispatchResponse } from '../gatewayTypes.js'
|
||||
|
||||
export type RpcResult = Record<string, any>
|
||||
|
||||
export const asRpcResult = <T extends RpcResult = RpcResult>(value: unknown): T | null => {
|
||||
|
|
@ -8,6 +10,34 @@ export const asRpcResult = <T extends RpcResult = RpcResult>(value: unknown): T
|
|||
return value as T
|
||||
}
|
||||
|
||||
export const asCommandDispatch = (value: unknown): CommandDispatchResponse | null => {
|
||||
const o = asRpcResult(value)
|
||||
|
||||
if (!o || typeof o.type !== 'string') {
|
||||
return null
|
||||
}
|
||||
|
||||
const t = o.type
|
||||
|
||||
if (t === 'exec' || t === 'plugin') {
|
||||
return { type: t, output: typeof o.output === 'string' ? o.output : undefined }
|
||||
}
|
||||
|
||||
if (t === 'alias' && typeof o.target === 'string') {
|
||||
return { type: 'alias', target: o.target }
|
||||
}
|
||||
|
||||
if (t === 'skill' && typeof o.name === 'string') {
|
||||
return {
|
||||
type: 'skill',
|
||||
name: o.name,
|
||||
message: typeof o.message === 'string' ? o.message : undefined
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export const rpcErrorMessage = (err: unknown) => {
|
||||
if (err instanceof Error && err.message) {
|
||||
return err.message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue