mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 17:54:23 +01:00
wip: desktop work
This commit is contained in:
33
packages/ui/src/components/tool-registry.tsx
Normal file
33
packages/ui/src/components/tool-registry.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Component } from "solid-js"
|
||||
|
||||
export interface ToolProps {
|
||||
input: Record<string, any>
|
||||
metadata: Record<string, any>
|
||||
tool: string
|
||||
output?: string
|
||||
hideDetails?: boolean
|
||||
}
|
||||
|
||||
export type ToolComponent = Component<ToolProps>
|
||||
|
||||
const state: Record<
|
||||
string,
|
||||
{
|
||||
name: string
|
||||
render?: ToolComponent
|
||||
}
|
||||
> = {}
|
||||
|
||||
export function registerTool(input: { name: string; render?: ToolComponent }) {
|
||||
state[input.name] = input
|
||||
return input
|
||||
}
|
||||
|
||||
export function getTool(name: string) {
|
||||
return state[name]?.render
|
||||
}
|
||||
|
||||
export const ToolRegistry = {
|
||||
register: registerTool,
|
||||
render: getTool,
|
||||
}
|
||||
Reference in New Issue
Block a user