Initialize smartkvm package
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { SmartKvmTerminal } from './smartkvm.classes.kvmterminal.js';
|
||||
import type { IKvmTerminalCommandResult } from './smartkvm.interfaces.js';
|
||||
|
||||
export interface ISmartKvmTool<TInput = unknown, TOutput = unknown> {
|
||||
name: string;
|
||||
description: string;
|
||||
parameters: unknown;
|
||||
execute: (input: TInput) => Promise<TOutput>;
|
||||
}
|
||||
|
||||
export interface ISmartKvmToolOptions {
|
||||
terminal: SmartKvmTerminal;
|
||||
}
|
||||
|
||||
export interface ISmartKvmTerminalRunCommandInput {
|
||||
command: string;
|
||||
}
|
||||
|
||||
export type TSmartKvmTerminalObserveInput = Record<string, never>;
|
||||
|
||||
export const createSmartKvmTools = (options: ISmartKvmToolOptions): ISmartKvmTool[] => {
|
||||
return [
|
||||
{
|
||||
name: 'kvm_terminal_run_command',
|
||||
description: 'Run a command through the visual KVM terminal transport and return OCR-parsed output.',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
command: {
|
||||
type: 'string',
|
||||
description: 'The terminal command to run.',
|
||||
},
|
||||
},
|
||||
required: ['command'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
execute: async (input: unknown): Promise<IKvmTerminalCommandResult> => {
|
||||
const typedInput = input as Partial<ISmartKvmTerminalRunCommandInput>;
|
||||
if (!typedInput || typeof typedInput.command !== 'string') {
|
||||
throw new Error('kvm_terminal_run_command requires a string command.');
|
||||
}
|
||||
return options.terminal.runCommand(typedInput.command);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'kvm_terminal_observe',
|
||||
description: 'Observe the current visual KVM terminal text through the configured OCR engine.',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {},
|
||||
additionalProperties: false,
|
||||
},
|
||||
execute: async (): Promise<string> => {
|
||||
return options.terminal.observeText();
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
Reference in New Issue
Block a user