|
@@ -299,7 +299,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
if (screenshotPath === null && !device) return { success: false, error: '缺少完整截图路径,且无法自动获取设备截图(缺少设备ID)' }
|
|
if (screenshotPath === null && !device) return { success: false, error: '缺少完整截图路径,且无法自动获取设备截图(缺少设备ID)' }
|
|
|
const result = await executeImgBoundingBoxLocation({ device, screenshot: screenshotPath, region: regionPath, folderPath })
|
|
const result = await executeImgBoundingBoxLocation({ device, screenshot: screenshotPath, region: regionPath, folderPath })
|
|
|
if (!result.success) return { success: false, error: `图像区域定位失败: ${result.error}` }
|
|
if (!result.success) return { success: false, error: `图像区域定位失败: ${result.error}` }
|
|
|
- const outputVarName = action.outVars?.[0] != null ? String(action.outVars[0]).trim() : (action.variable ? extractVarName(action.variable) : null)
|
|
|
|
|
|
|
+ const outputVarName = action.outVars?.[0] != null ? extractVarName(String(action.outVars[0]).trim()) : (action.variable ? extractVarName(action.variable) : null)
|
|
|
if (outputVarName) {
|
|
if (outputVarName) {
|
|
|
variableContext[outputVarName] = result.corners && typeof result.corners === 'object' ? JSON.stringify(result.corners) : ''
|
|
variableContext[outputVarName] = result.corners && typeof result.corners === 'object' ? JSON.stringify(result.corners) : ''
|
|
|
await logOutVars(action, variableContext, folderPath)
|
|
await logOutVars(action, variableContext, folderPath)
|
|
@@ -319,7 +319,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
if (!device) return { success: false, error: '缺少设备 ID,无法自动获取截图' }
|
|
if (!device) return { success: false, error: '缺少设备 ID,无法自动获取截图' }
|
|
|
const result = await executeImgCenterPointLocation({ device, template: templatePath, folderPath })
|
|
const result = await executeImgCenterPointLocation({ device, template: templatePath, folderPath })
|
|
|
if (!result.success) return { success: false, error: `图像中心点定位失败: ${result.error}` }
|
|
if (!result.success) return { success: false, error: `图像中心点定位失败: ${result.error}` }
|
|
|
- const outputVarName = action.outVars?.[0] != null ? String(action.outVars[0]).trim() : (action.variable ? extractVarName(action.variable) : null)
|
|
|
|
|
|
|
+ const outputVarName = action.outVars?.[0] != null ? extractVarName(String(action.outVars[0]).trim()) : (action.variable ? extractVarName(action.variable) : null)
|
|
|
if (outputVarName) {
|
|
if (outputVarName) {
|
|
|
variableContext[outputVarName] = result.center && typeof result.center === 'object' && result.center.x !== undefined && result.center.y !== undefined
|
|
variableContext[outputVarName] = result.center && typeof result.center === 'object' && result.center.x !== undefined && result.center.y !== undefined
|
|
|
? JSON.stringify({ x: result.center.x, y: result.center.y }) : ''
|
|
? JSON.stringify({ x: result.center.x, y: result.center.y }) : ''
|
|
@@ -341,7 +341,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
const result = await executeImgCropping({ area, savePath, folderPath, device })
|
|
const result = await executeImgCropping({ area, savePath, folderPath, device })
|
|
|
if (!result.success) return { success: false, error: result.error }
|
|
if (!result.success) return { success: false, error: result.error }
|
|
|
if (action.outVars?.[0] != null) {
|
|
if (action.outVars?.[0] != null) {
|
|
|
- const outputVarName = String(action.outVars[0]).trim()
|
|
|
|
|
|
|
+ const outputVarName = extractVarName(String(action.outVars[0]).trim())
|
|
|
if (outputVarName) variableContext[outputVarName] = result.success ? '1' : '0'
|
|
if (outputVarName) variableContext[outputVarName] = result.success ? '1' : '0'
|
|
|
}
|
|
}
|
|
|
await logOutVars(action, variableContext, folderPath)
|
|
await logOutVars(action, variableContext, folderPath)
|
|
@@ -352,8 +352,8 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
const { executeReadLastMessage } = get(funcDir, 'io')
|
|
const { executeReadLastMessage } = get(funcDir, 'io')
|
|
|
const inputVars = action.inVars || action.inputVars || []
|
|
const inputVars = action.inVars || action.inputVars || []
|
|
|
const outputVars = action.outVars || action.outputVars || []
|
|
const outputVars = action.outVars || action.outputVars || []
|
|
|
- let textVar = outputVars.length > 0 ? String(outputVars[0]).trim() : action.textVariable
|
|
|
|
|
- let senderVar = outputVars.length > 1 ? String(outputVars[1]).trim() : action.senderVariable
|
|
|
|
|
|
|
+ let textVar = outputVars.length > 0 ? extractVarName(String(outputVars[0]).trim()) : (action.textVariable ? extractVarName(action.textVariable) : null)
|
|
|
|
|
+ let senderVar = outputVars.length > 1 ? extractVarName(String(outputVars[1]).trim()) : (action.senderVariable ? extractVarName(action.senderVariable) : null)
|
|
|
let inputDataString = inputVars.length > 0 ? (inputVars[0] != null ? (typeof inputVars[0] === 'string' ? inputVars[0] : (Array.isArray(inputVars[0]) || typeof inputVars[0] === 'object' ? JSON.stringify(inputVars[0]) : String(inputVars[0]))) : null) : null
|
|
let inputDataString = inputVars.length > 0 ? (inputVars[0] != null ? (typeof inputVars[0] === 'string' ? inputVars[0] : (Array.isArray(inputVars[0]) || typeof inputVars[0] === 'object' ? JSON.stringify(inputVars[0]) : String(inputVars[0]))) : null) : null
|
|
|
if (!textVar && !senderVar) return { success: false, error: 'read-last-message 缺少 textVariable 或 senderVariable 参数' }
|
|
if (!textVar && !senderVar) return { success: false, error: 'read-last-message 缺少 textVariable 或 senderVariable 参数' }
|
|
|
const result = await executeReadLastMessage({ folderPath, inputData: inputDataString, textVariable: textVar, senderVariable: senderVar })
|
|
const result = await executeReadLastMessage({ folderPath, inputData: inputDataString, textVariable: textVar, senderVariable: senderVar })
|
|
@@ -370,7 +370,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
let filePath = action.filePath
|
|
let filePath = action.filePath
|
|
|
let varName = action.variable
|
|
let varName = action.variable
|
|
|
if (action.inVars?.length > 0) filePath = action.inVars[0]
|
|
if (action.inVars?.length > 0) filePath = action.inVars[0]
|
|
|
- if (action.outVars?.length > 0) varName = String(action.outVars[0]).trim()
|
|
|
|
|
|
|
+ if (action.outVars?.length > 0) varName = extractVarName(String(action.outVars[0]).trim())
|
|
|
else if (action.variable) varName = extractVarName(action.variable)
|
|
else if (action.variable) varName = extractVarName(action.variable)
|
|
|
if (!filePath) return { success: false, error: 'read-txt 缺少 filePath 参数' }
|
|
if (!filePath) return { success: false, error: 'read-txt 缺少 filePath 参数' }
|
|
|
if (!varName) return { success: false, error: 'read-txt 缺少 variable 参数' }
|
|
if (!varName) return { success: false, error: 'read-txt 缺少 variable 参数' }
|
|
@@ -398,7 +398,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
current: typeof current === 'string' ? current : String(current),
|
|
current: typeof current === 'string' ? current : String(current),
|
|
|
})
|
|
})
|
|
|
if (!result.success) return { success: false, error: result.error }
|
|
if (!result.success) return { success: false, error: result.error }
|
|
|
- const outputVarName = action.outVars?.[0] != null ? String(action.outVars[0]).trim() : (action.variable ? extractVarName(action.variable) : null)
|
|
|
|
|
|
|
+ const outputVarName = action.outVars?.[0] != null ? extractVarName(String(action.outVars[0]).trim()) : (action.variable ? extractVarName(action.variable) : null)
|
|
|
if (outputVarName && result.result) variableContext[outputVarName] = result.result
|
|
if (outputVarName && result.result) variableContext[outputVarName] = result.result
|
|
|
return { success: true, result: result.result }
|
|
return { success: true, result: result.result }
|
|
|
}
|
|
}
|
|
@@ -417,7 +417,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
const result = await executeSaveTxt({ filePath, content, folderPath })
|
|
const result = await executeSaveTxt({ filePath, content, folderPath })
|
|
|
if (!result.success) return { success: false, error: result.error }
|
|
if (!result.success) return { success: false, error: result.error }
|
|
|
if (action.outVars?.[0] != null) {
|
|
if (action.outVars?.[0] != null) {
|
|
|
- const outputVarName = String(action.outVars[0]).trim()
|
|
|
|
|
|
|
+ const outputVarName = extractVarName(String(action.outVars[0]).trim())
|
|
|
if (outputVarName) variableContext[outputVarName] = result.success ? '1' : '0'
|
|
if (outputVarName) variableContext[outputVarName] = result.success ? '1' : '0'
|
|
|
}
|
|
}
|
|
|
await logOutVars(action, variableContext, folderPath)
|
|
await logOutVars(action, variableContext, folderPath)
|
|
@@ -481,7 +481,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
const chatResult = await executeOcrChat({ device, avatar1: avatar1Path, avatar2: avatar2Path, folderPath, region: regionParam, friendRgb, myRgb })
|
|
const chatResult = await executeOcrChat({ device, avatar1: avatar1Path, avatar2: avatar2Path, folderPath, region: regionParam, friendRgb, myRgb })
|
|
|
if (!chatResult.success) return { success: false, error: `提取消息记录失败: ${chatResult.error}` }
|
|
if (!chatResult.success) return { success: false, error: `提取消息记录失败: ${chatResult.error}` }
|
|
|
|
|
|
|
|
- const outputVarName = action.outVars?.[0] != null ? String(action.outVars[0]).trim() : (action.variable ? extractVarName(action.variable) : null)
|
|
|
|
|
|
|
+ const outputVarName = action.outVars?.[0] != null ? extractVarName(String(action.outVars[0]).trim()) : (action.variable ? extractVarName(action.variable) : null)
|
|
|
if (outputVarName) {
|
|
if (outputVarName) {
|
|
|
variableContext[outputVarName] = chatResult.messagesJson || JSON.stringify(chatResult.messages || [])
|
|
variableContext[outputVarName] = chatResult.messagesJson || JSON.stringify(chatResult.messages || [])
|
|
|
await logOutVars(action, variableContext, folderPath)
|
|
await logOutVars(action, variableContext, folderPath)
|
|
@@ -570,11 +570,11 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
|
|
|
|
|
if (action.outVars?.length > 0) {
|
|
if (action.outVars?.length > 0) {
|
|
|
if (action.outVars.length > 0) {
|
|
if (action.outVars.length > 0) {
|
|
|
- const outputVarName = action.outVars?.[0] != null ? String(action.outVars[0]).trim() : null
|
|
|
|
|
|
|
+ const outputVarName = action.outVars?.[0] != null ? extractVarName(String(action.outVars[0]).trim()) : null
|
|
|
if (outputVarName) variableContext[outputVarName] = result
|
|
if (outputVarName) variableContext[outputVarName] = result
|
|
|
}
|
|
}
|
|
|
if (action.outVars.length > 1) {
|
|
if (action.outVars.length > 1) {
|
|
|
- const callbackVarName = action.outVars?.[1] != null ? String(action.outVars[1]).trim() : null
|
|
|
|
|
|
|
+ const callbackVarName = action.outVars?.[1] != null ? extractVarName(String(action.outVars[1]).trim()) : null
|
|
|
if (callbackVarName) variableContext[callbackVarName] = 1
|
|
if (callbackVarName) variableContext[callbackVarName] = 1
|
|
|
}
|
|
}
|
|
|
await logOutVars(action, variableContext, folderPath)
|
|
await logOutVars(action, variableContext, folderPath)
|
|
@@ -584,7 +584,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
}
|
|
}
|
|
|
if (!action.outVars || action.outVars.length <= 1) {
|
|
if (!action.outVars || action.outVars.length <= 1) {
|
|
|
if (action.inVars?.length > 1 && action.inVars[1] != null) {
|
|
if (action.inVars?.length > 1 && action.inVars[1] != null) {
|
|
|
- const callbackVarName = String(action.inVars[1]).trim()
|
|
|
|
|
|
|
+ const callbackVarName = extractVarName(String(action.inVars[1]).trim())
|
|
|
if (callbackVarName) variableContext[callbackVarName] = 1
|
|
if (callbackVarName) variableContext[callbackVarName] = 1
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -645,7 +645,7 @@ async function run(actionType, action, ctx, device, folderPath) {
|
|
|
if (!result || !result.success) {
|
|
if (!result || !result.success) {
|
|
|
return { success: false, error: (result && result.error) || 'execute failed' }
|
|
return { success: false, error: (result && result.error) || 'execute failed' }
|
|
|
}
|
|
}
|
|
|
- const outputVarName = action.outVars?.[0] != null ? String(action.outVars[0]).trim() : null
|
|
|
|
|
|
|
+ const outputVarName = action.outVars?.[0] != null ? extractVarName(String(action.outVars[0]).trim()) : null
|
|
|
if (outputVarName && result != null) {
|
|
if (outputVarName && result != null) {
|
|
|
const outVal = result.path ?? result.value ?? result.result
|
|
const outVal = result.path ?? result.value ?? result.result
|
|
|
if (outVal !== undefined && outVal !== null) variableContext[outputVarName] = typeof outVal === 'string' ? outVal : String(outVal)
|
|
if (outVal !== undefined && outVal !== null) variableContext[outputVarName] = typeof outVal === 'string' ? outVal : String(outVal)
|