(gateway: GatewayClient, id: string, value: string | number, scope: string = 'global')
| 16 | : Object.entries(variables || {}).map(([id, variable]) => ({ ...variable, id, scope })); |
| 17 | return { success: true, data }; |
| 18 | } catch (error) { |
| 19 | return { success: false, error: `获取变量列表失败: ${error}` }; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | export async function setVariable(gateway: GatewayClient, id: string, value: string | number, scope: string = 'global'): Promise<ToolResponse> { |
| 24 | try { |
| 25 | await gateway.callApi('setVarValue', { scope, id, value }, 10000); |
| 26 | return { success: true, message: `变量 ${id} 已更新为 ${value}` }; |
| 27 | } catch (error) { |
| 28 | return { success: false, error: `设置变量值失败: ${error}` }; |
no test coverage detected