chore: uptick

This commit is contained in:
Brooklyn Nicholson 2026-04-16 01:04:35 -05:00
parent cb31732c4f
commit 8e06db56fd
14 changed files with 1712 additions and 1362 deletions

View file

@ -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