XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEWorkflow

【WinUI】XFE基于windows的工作流

公开
关注 0 Fork 0 Star 0
UTF-8
$ErrorActionPreference = 'Stop'
function Port($name, $label, $type = 'String', $required = $false, $default = $null, $choices = @()) {
    $port = [ordered]@{name=$name; label=$label; type=$type; required=$required}
    if ($null -ne $default) { $port.defaultValue=$default }
    if ($choices.Count) { $port.choices=$choices }
    return $port
}
function Action($id, $name, $description, $inputs = @(), $outputs = @()) {
    return [ordered]@{id="xfe.wecom.$id"; pluginId='xfe.wecom'; name=$name; category='企业微信'; description=$description; inputs=@($inputs); outputs=@($outputs) + @((Port 'result' '完整结果' 'Object')); executionOutputs=@('next')}
}
$message = Port 'message' '消息引用(连接接收节点 message)' 'Object' $true
$message.typeId = 'xfe.wecom.message'
$message.description = '当前接收消息的专用引用,保留引用回复与去重所需的上下文;不能使用普通对象或消息正文代替。'
$replyInputs = @($message, (Port 'content' '回复文字(1–256 字符,无换行)' 'String' $true), (Port 'quoteOriginal' '引用原消息' 'Boolean' $false $false), (Port 'dryRun' '仅试运行' 'Boolean' $false $false))
$replyOutputs = @((Port 'status' '发送状态'), (Port 'sent' '客户端已受理' 'Boolean'), (Port 'delivered' '服务器送达确认' 'Boolean'), (Port 'nativeMessageId' '原生消息 ID'))
$capabilities = @(
    (Action 'probe' '检测企业微信客户端' '只检测进程、版本和安装,不会连接或发送' @() @((Port 'clients' '运行中的客户端' 'Array'), (Port 'installation' '安装信息' 'Object'))),
    (Action 'status' '读取企微连接状态' '读取当前连接、监听状态、旧版默认 ID 与错误;默认值不影响新版消息接收' @() @((Port 'connected' '是否连接' 'Boolean'), (Port 'listening' '是否监听' 'Boolean'), (Port 'groupId' '旧版默认群 ID'), (Port 'senderId' '旧版默认成员 ID'), (Port 'error' '连接错误'))),
    (Action 'connect' '连接本机企业微信' '连接后接收所有新消息;群聊、发送者和类型由工作流中的系统条件节点判断。支持 5.0.11.6029 x86 客户端和 Windows x64 宿主' @((Port 'processId' '进程 ID(0 自动检测)' 'Number' $false 0)) @((Port 'connected' '是否连接' 'Boolean'))),
    (Action 'disconnect' '断开本机企业微信' '停止共享原生监听并断开连接;所有相关工作流停止接收消息'),
    (Action 'groups' '读取缓存群聊' '返回客户端已加载的群聊,不代表完整群列表' @() @((Port 'groups' '群列表' 'Array'))),
    (Action 'contacts' '搜索缓存联系人' '按名字或完整 ID 搜索本机已加载的联系人对象;不是完整群成员名册' @((Port 'query' '名字或 ID(留空全部)')) @((Port 'contacts' '联系人' 'Array'), (Port 'completeRoster' '是否完整名册' 'Boolean'))),
    (Action 'reply' '回复企微消息' '回复当前触发消息;先持久化去重预约,无自动重发' $replyInputs $replyOutputs),
    (Action 'quoteReply' '引用回复企微消息' '引用收到的原消息;原消息无效时停止,不降级为普通回复' $replyInputs $replyOutputs),
    (Action 'dryRun' '试运行企微回复' '记录计划,不发送、不占用持久化去重记录' $replyInputs $replyOutputs),
    (Action 'selfTest' '发送企微自测消息' '显式向文件传输助手发送一次“1”,随后读取服务器回执;不会重试' @() @((Port 'detail' '自测结果'))),
    (Action 'attempts' '读取企微发送去重统计' '包括已发送、失败和不确定的预约;重启后继续保留' @() @((Port 'reserved' '已预约消息数' 'Number')))
)
$messageOutput = [ordered]@{name='message'; label='消息引用'; type='Object'; typeId='xfe.wecom.message'; eventPath=''; aliases=@('event'); description='连接回复或引用回复节点的 message 输入;筛选时将发送者、群聊、类型等输出连接系统条件分支。旧 event 连线继续兼容。'}
$groupOutput = Port 'groupId' '群 ID'; $groupOutput.eventPath = 'conversationId'
$contentOutput = Port 'content' '消息正文'; $contentOutput.description = '文本正文;当前原生适配器可能只提供元数据,请先检查 hasContent 输出。'
$capabilities += [ordered]@{id='xfe.wecom.message.received'; pluginId='xfe.wecom'; name='收到消息'; category='企业微信'; isTrigger=$true; description='收到企业微信新消息即触发,不预设群聊、发送者或消息类型。将对应输出连接系统条件分支或多路选择,自行编排筛选。先在插件中心连接本机客户端;历史、自发和重复事件不触发'; inputs=@(); outputs=@($messageOutput, $contentOutput, (Port 'hasContent' '是否提供正文' 'Boolean'), (Port 'messageId' '消息 ID'), $groupOutput, (Port 'groupName' '群名称'), (Port 'senderId' '发送者 ID'), (Port 'senderName' '发送者名称'), (Port 'kind' '消息类型'), (Port 'createdAtUtc' '消息发送时间'), (Port 'receivedAtUtc' '消息接收时间'), (Port 'ageSeconds' '消息已发送秒数' 'Number'), (Port 'dryRun' '是否试运行' 'Boolean')); executionOutputs=@('next')}
$old = Get-Content (Join-Path $PSScriptRoot '../XFEWorkflow/XFEWorkflow.Plugins.Standard/Manifests/xfe.wecom.json') -Raw -Encoding UTF8 | ConvertFrom-Json
$capabilities += $old.capabilities[0]
$manifest = [ordered]@{schemaVersion=1; sdkMajorVersion=1; sdkMinimumVersion='1.5.0'; sdkMaximumVersionExclusive='2.0.0'; id='xfe.wecom'; name='企业微信'; version='3.0.0'; author='XFEstudio'; description='群机器人与本机收到消息触发器、类型化消息输出、普通/引用回复、试运行、自测和持久化去重。使用系统条件节点自行筛选'; assembly='XFEWorkflow.Plugins.WeCom.dll'; entryType='XFEWorkflow.Plugins.WeCom.WeComPlugin'; supportedRids=@(); permissions=@('network','credentials','native.wecom'); dependencies=@(); capabilities=$capabilities}
$manifest | ConvertTo-Json -Depth 30 | Set-Content (Join-Path $PSScriptRoot '../XFEWorkflow/XFEWorkflow.Plugins.WeCom/plugin.json') -Encoding utf8NoBOM