import * as plugins from './plugins.js'; import type { ShxAutomationContext } from './classes.automationcontext.js'; export class DeviceProxy { constructor(private context: ShxAutomationContext) {} public async call(optionsArg: { deviceId: string; toolId: string; title: string; reason: string; input?: Record; confidence?: number; }) { const callId = `call:${Date.now()}:${Math.random().toString(36).slice(2)}`; const plan: plugins.shxInterfaces.data.IToolPlan = { id: `plan:${callId}`, callerId: this.context.options.callerId, title: optionsArg.title, reason: optionsArg.reason, confidence: optionsArg.confidence ?? 0.5, calls: [ { id: callId, toolId: optionsArg.toolId, callerId: this.context.options.callerId, input: { deviceId: optionsArg.deviceId, ...(optionsArg.input ?? {}), }, }, ], }; return this.context.executePlan(plan); } public async read(deviceIdArg: string) { return this.call({ deviceId: deviceIdArg, toolId: `device:${deviceIdArg}:read`, title: `Read ${deviceIdArg}`, reason: 'Automation requested current device state.', input: {}, confidence: 1, }); } }