mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
feat: refactor by splitting up app and doing proper state
This commit is contained in:
parent
4cbf54fb33
commit
99d859ce4a
27 changed files with 4087 additions and 2939 deletions
24
ui-tui/src/app/gatewayContext.tsx
Normal file
24
ui-tui/src/app/gatewayContext.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { createContext, type ReactNode, useContext } from 'react'
|
||||
|
||||
import type { GatewayServices } from './interfaces.js'
|
||||
|
||||
const GatewayContext = createContext<GatewayServices | null>(null)
|
||||
|
||||
export interface GatewayProviderProps {
|
||||
children: ReactNode
|
||||
value: GatewayServices
|
||||
}
|
||||
|
||||
export function GatewayProvider({ children, value }: GatewayProviderProps) {
|
||||
return <GatewayContext.Provider value={value}>{children}</GatewayContext.Provider>
|
||||
}
|
||||
|
||||
export function useGateway() {
|
||||
const value = useContext(GatewayContext)
|
||||
|
||||
if (!value) {
|
||||
throw new Error('GatewayContext missing')
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue