shennian 0.2.103 → 0.2.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -226,8 +226,8 @@
|
|
|
226
226
|
},
|
|
227
227
|
{
|
|
228
228
|
"file": "src/channels/wechat-channel/helper-protocol.js",
|
|
229
|
-
"beforeBytes":
|
|
230
|
-
"afterBytes":
|
|
229
|
+
"beforeBytes": 8066,
|
|
230
|
+
"afterBytes": 3795
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
"file": "src/channels/wechat-channel/human-coordination.js",
|
|
@@ -421,8 +421,8 @@
|
|
|
421
421
|
},
|
|
422
422
|
{
|
|
423
423
|
"file": "src/commands/wechat/output.js",
|
|
424
|
-
"beforeBytes":
|
|
425
|
-
"afterBytes":
|
|
424
|
+
"beforeBytes": 12064,
|
|
425
|
+
"afterBytes": 7347
|
|
426
426
|
},
|
|
427
427
|
{
|
|
428
428
|
"file": "src/commands/wechat/types.js",
|
|
@@ -4,6 +4,7 @@ export declare const WECHAT_CHANNEL_HELPER_COMMAND_TIMEOUT_MS: {
|
|
|
4
4
|
readonly permissionsCheck: 10000;
|
|
5
5
|
readonly activitySnapshot: 1000;
|
|
6
6
|
readonly automationLease: 6000;
|
|
7
|
+
readonly windowList: 10000;
|
|
7
8
|
readonly windowsEnsureReady: 20000;
|
|
8
9
|
readonly ocrRecognize: 10000;
|
|
9
10
|
readonly windowsCapture: 5000;
|
|
@@ -89,7 +90,7 @@ export type WeChatChannelHumanActivitySnapshot = {
|
|
|
89
90
|
capturesMousePath?: boolean;
|
|
90
91
|
};
|
|
91
92
|
};
|
|
92
|
-
export type WeChatChannelHelperCommandName = 'health.check' | 'permissions.check' | 'permissions.requestScreenRecording' | 'permissions.requestAccessibility' | 'activity.snapshot' | 'automation.lease.acquire' | 'automation.lease.release' | 'automation.lease.status' | 'automation.lease.simulateInterruption' | 'windows.ensureReady' | 'windows.list' | 'windows.focus' | 'windows.capture' | 'windows.captureAndOcr' | 'windows.cleanupOverlays' | 'windows.recoverWeChat' | 'screen.capture' | 'ocr.recognize' | 'mouse.click' | 'mouse.rightClick' | 'mouse.scroll' | 'keyboard.type' | 'keyboard.shortcut' | 'clipboard.snapshot' | 'clipboard.restore' | 'clipboard.setText' | 'clipboard.setFiles' | 'clipboard.setImage' | 'clipboard.readFileUrls' | 'clipboard.readAttachment' | 'menu.pickItem' | 'savePanel.saveToPath' | 'image.cropHash' | 'wechat.searchConversation' | 'wechat.focusMessageInput';
|
|
93
|
+
export type WeChatChannelHelperCommandName = 'health.check' | 'processes.list' | 'permissions.check' | 'permissions.requestScreenRecording' | 'permissions.requestAccessibility' | 'activity.snapshot' | 'automation.lease.acquire' | 'automation.lease.release' | 'automation.lease.status' | 'automation.lease.simulateInterruption' | 'windows.ensureReady' | 'windows.list' | 'windows.enumerateRaw' | 'windows.focus' | 'windows.capture' | 'windows.captureAndOcr' | 'windows.cleanupOverlays' | 'windows.recoverWeChat' | 'screen.capture' | 'ocr.recognize' | 'mouse.click' | 'mouse.rightClick' | 'mouse.scroll' | 'keyboard.type' | 'keyboard.shortcut' | 'clipboard.snapshot' | 'clipboard.restore' | 'clipboard.setText' | 'clipboard.setFiles' | 'clipboard.setImage' | 'clipboard.readFileUrls' | 'clipboard.readAttachment' | 'menu.pickItem' | 'savePanel.saveToPath' | 'image.cropHash' | 'wechat.searchConversation' | 'wechat.focusMessageInput';
|
|
93
94
|
export type WeChatChannelHelperCommand = {
|
|
94
95
|
id: string;
|
|
95
96
|
command: WeChatChannelHelperCommandName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const w=1,i={healthCheck:2e3,permissionsCheck:1e4,activitySnapshot:1e3,automationLease:6e3,windowList:1e4,windowsEnsureReady:2e4,ocrRecognize:1e4,windowsCapture:5e3,mouseKeyboard:3e3,clipboard:5e3,menuPickItem:5e3,savePanel:1e4,wechatSearch:6e3},a=["screenCapture","visionOcr","windowList","windowFocus","mouseKeyboard","clipboard","imageCropHash","wechatSearch","humanActivity"],u=[...a,"contextMenu"],c=[...u,"automationLease"],p=c,l=[...a,"overlayCleanup","wechatRecovery"],C=[...l,"contextMenu"],h=[...C,"automationLease"];function H(e){return e==="observe"?[...a]:e==="download"?[...u]:[...c]}function A(e){return e==="observe"?[...l]:e==="download"?[...C]:[...h]}function L(e,t=p){const r=String(e||"").trim();if(!r)throw new Error("WeChat channel helper expected version is required");return{type:"hello",protocolVersion:1,expectedHelperVersion:r,capabilities:[...t]}}function d(e,t,r=p){if(!e||e.type!=="ready")return{ok:!1,errorCode:"helper_invalid_response",errorSummary:"Helper did not send a ready frame"};if(e.protocolVersion!==1)return{ok:!1,errorCode:"helper_protocol_mismatch",errorSummary:`Helper protocol ${e.protocolVersion} does not match 1`};if(e.helperVersion!==t)return{ok:!1,errorCode:"helper_version_mismatch",errorSummary:`Helper version ${e.helperVersion} does not match ${t}`};const o=r.filter(_=>!e.capabilities.includes(_));return o.length?{ok:!1,errorCode:"helper_capability_missing",errorSummary:`Helper missing capabilities: ${o.join(", ")}`}:{ok:!0}}function S(e){if(!e||typeof e!="object")return null;const t=e;if(!E(t.warmState))return null;const r=f(t.warmup);return r?{warmState:t.warmState,metrics:r}:{warmState:t.warmState}}function W(e){return e==="health.check"?i.healthCheck:e==="processes.list"?i.windowList:e==="permissions.check"||e==="permissions.requestScreenRecording"||e==="permissions.requestAccessibility"?i.permissionsCheck:e==="activity.snapshot"?i.activitySnapshot:e.startsWith("automation.lease.")?i.automationLease:e==="windows.list"||e==="windows.enumerateRaw"?i.windowList:e==="windows.ensureReady"||e==="windows.cleanupOverlays"||e==="windows.recoverWeChat"?i.windowsEnsureReady:e==="ocr.recognize"||e==="windows.captureAndOcr"?i.ocrRecognize:e==="windows.capture"||e==="screen.capture"?i.windowsCapture:e.startsWith("mouse.")||e.startsWith("keyboard.")?i.mouseKeyboard:e.startsWith("clipboard.")?i.clipboard:e==="menu.pickItem"?i.menuPickItem:e==="savePanel.saveToPath"?i.savePanel:e.startsWith("wechat.")?i.wechatSearch:i.healthCheck}function E(e){return e==="cold"||e==="warming"||e==="warm"||e==="failed"}function f(e){if(!e||typeof e!="object")return;const t=e,r={};return n(t,r,"startedAt"),n(t,r,"readyAt"),n(t,r,"warmupStartedAt"),n(t,r,"warmupCompletedAt"),s(t,r,"coldStartMs"),s(t,r,"warmupMs"),s(t,r,"firstOcrMs"),s(t,r,"warmOcrMs"),s(t,r,"lastOcrMs"),s(t,r,"ocrSampleCount"),n(t,r,"errorCode"),n(t,r,"errorSummary"),Object.keys(r).length>0?r:void 0}function n(e,t,r){typeof e[r]=="string"&&(t[r]=e[r])}function s(e,t,r){const o=e[r];typeof o=="number"&&Number.isFinite(o)&&o>=0&&(t[r]=o)}export{u as WECHAT_CHANNEL_DOWNLOAD_HELPER_CAPABILITIES,i as WECHAT_CHANNEL_HELPER_COMMAND_TIMEOUT_MS,w as WECHAT_CHANNEL_HELPER_PROTOCOL_VERSION,a as WECHAT_CHANNEL_OBSERVE_HELPER_CAPABILITIES,p as WECHAT_CHANNEL_REQUIRED_HELPER_CAPABILITIES,c as WECHAT_CHANNEL_SEND_HELPER_CAPABILITIES,C as WECHAT_CHANNEL_WINDOWS_DOWNLOAD_HELPER_CAPABILITIES,l as WECHAT_CHANNEL_WINDOWS_OBSERVE_HELPER_CAPABILITIES,h as WECHAT_CHANNEL_WINDOWS_SEND_HELPER_CAPABILITIES,L as createWeChatChannelHelperHello,S as extractWeChatChannelHelperWarmupSnapshot,H as requiredWeChatChannelHelperCapabilitiesForProfile,A as requiredWindowsWeChatChannelHelperCapabilitiesForProfile,W as timeoutForWeChatChannelHelperCommand,d as validateWeChatChannelHelperReady};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
`;for(const
|
|
1
|
+
import b from"node:path";import{cleanInline as a,stringValue as o}from"./utils.js";const y=["SHENNIAN_WECHAT_CHANNEL_HELPER_DIR","SHENNIAN_HELPER_RUNTIME_DIR","packages/helper-runtime/wechat-channel","packages\\helper-runtime\\wechat-channel","packages/helper-runtime/dist","packages\\helper-runtime\\dist","wechat-rpa-windows-product-send-runner","PowerShell one-shot runner","activity.snapshot","automation.lease."],w=new Set(["wechat_not_running"]);function I(e,n){if(n){console.log(JSON.stringify(e,null,2));return}console.log(e.sendStatus)}function H(e,n){if(n==="json"){console.log(JSON.stringify(e,null,2));return}console.log(W(e).trimEnd())}function M(e,n,t,i){const r=k(e,n,t);i?console.log(JSON.stringify(r,null,2)):console.error(`${r.reasonCode}: ${r.message}`),process.exitCode=1}function k(e,n,t){const i=t instanceof Error?t.message:String(t||"wechat_tool_failed"),r=a(i)||"wechat_tool_failed",c=/^([a-z][a-z0-9_]*)(?::\s*(.*))?$/i.exec(r),s=o(t?.reasonCode)||c?.[1]||"wechat_tool_failed",l=q(s,r),_=a(c?.[2]||r),v=R(l,_,s),h=o(t?.outDir),d=o(t?.helperTracePath),p=o(t?.activityGuardPath),m=o(t?.traceId),f=E(l);return{ok:!1,operation:e,...n?.trim()?{conversation:n.trim()}:{},reasonCode:l,...S(s,l,_)?{rawReasonCode:s}:{},message:v,...m?{traceId:m}:{},...h?{outDir:h}:{},...d?{helperTracePath:d}:{},...p?{activityGuardPath:p}:{},...f?{userAction:f}:{}}}function W(e){const n=[];if(e.messages.length===0)return`\uFF08\u6CA1\u6709\u8BFB\u5230\uFF09
|
|
2
|
+
`;for(const t of e.messages)n.push(`${P(t)}: ${C(t)}`);return`${n.join(`
|
|
3
3
|
`)}
|
|
4
|
-
`}function
|
|
4
|
+
`}function q(e,n=""){const t=e.trim().toLowerCase(),i=`${t} ${n}`.toLowerCase();return t?t==="insufficient_credits"?"insufficient_credits":t==="entitlement_required"||t==="enterprise_required"||t.includes("entitlement")?"entitlement_required":t==="manual_review_required"||t.includes("manual_review")?"manual_review_required":t==="attachment_pending"||/attachment.*pending|media_original_pending/.test(i)?"attachment_pending":/helper_runtime_required|helper_runtime_source_missing|helper_runtime_package_manifest_missing|manifest_missing|helper_missing|helper_not_executable/.test(t)?"helper_missing":/helper_runtime_cli_too_old|helper_runtime_version_mismatch|helper_runtime_protocol_mismatch|helper_runtime_platform_mismatch|helper_runtime_package_manifest_invalid|integrity_mismatch/.test(t)?"helper_version_incompatible":/^user_active|recent_(keyboard|mouse|scroll)|frontmost_app_changed|user_takeover|activity/.test(t)?"user_active_retry_later":/helper_command_timeout/.test(t)?"wechat_window_unavailable":u(i)?"wechat_tool_failed":/permission|accessibility|screen_recording|automation|mac_input|input-monitoring/.test(i)?"permission_required":/wechat_login_required|login_required|安全验证|扫码登录|重新登录/.test(i)?"wechat_login_required":/wechat_single_main_window_required|wechat_duplicate_instance|duplicate_main_window/.test(t)?"wechat_single_main_window_required":/visible_desktop|desktop_session|screen_locked|session_locked|rdp_disconnected|rdp.*visible|rdp.*desktop/.test(i)?"windows_visible_desktop_unavailable":/dpi_mapping_failed|display_topology|monitor_topology|multi_?monitor|multi_?screen/.test(i)?"dpi_mapping_failed":/conversation_not|conversation_title_not_confirmed|conversation_not_visible|open_read_required|search_result_not_visible/.test(t)?"conversation_not_found":/wechat_window|wechat_not_running|window_not|window_unavailable|window_unresponsive/.test(t)?"wechat_window_unavailable":t:"wechat_tool_failed"}function E(e){if(e==="wechat_login_required")return"Open WeChat on this machine, complete login or security verification, then retry.";if(e==="wechat_window_unavailable")return"Open the main WeChat window on the active desktop, then retry.";if(e==="wechat_single_main_window_required")return"Close duplicate WeChat main windows, login prompts, or security prompts, then retry with exactly one signed-in WeChat main window.";if(e==="windows_visible_desktop_unavailable")return"Unlock or reconnect the Windows visible desktop session, keep WeChat visible, then retry.";if(e==="dpi_mapping_failed")return"Move WeChat fully onto one visible display or use a supported display scaling setup, then retry.";if(e==="conversation_not_found")return"Check the WeChat conversation name and make sure the conversation can be searched.";if(e==="helper_missing")return"Open Shennian Desktop or run `shennian runtime install helper`, then retry.";if(e==="helper_version_incompatible")return"Run `shennian runtime repair helper` or upgrade Shennian CLI, then retry.";if(e==="permission_required")return"Grant Shennian Helper/Desktop the required macOS permissions, then retry.";if(e==="entitlement_required")return"Enable the WeChat capability for this account in Shennian.";if(e==="insufficient_credits")return"Add credits or adjust the account plan in Shennian.";if(e==="user_active_retry_later")return"Wait until the user is idle, then retry.";if(e==="attachment_pending")return"Open WeChat and let the attachment finish downloading, then retry.";if(e==="manual_review_required")return"Review the current WeChat window before retrying."}function R(e,n,t){const i=t.trim().toLowerCase();return!n||n===e||u(n)||w.has(i)?$(e):n}function S(e,n,t){const i=e.trim().toLowerCase();return!(e===n||w.has(i)||u(`${e} ${t}`))}function u(e){const n=e.replace(/\\/g,"/").toLowerCase();return y.some(t=>{const i=t.replace(/\\/g,"/").toLowerCase();return n.includes(i)})}function $(e){return e==="wechat_login_required"?"WeChat needs login or security verification on this machine.":e==="wechat_window_unavailable"?"WeChat window is not available on the active desktop.":e==="wechat_single_main_window_required"?"Exactly one signed-in WeChat main window is required.":e==="windows_visible_desktop_unavailable"?"Windows visible desktop session is unavailable.":e==="dpi_mapping_failed"?"Windows display scaling or monitor geometry cannot be mapped safely.":e==="conversation_not_found"?"WeChat conversation was not found.":e==="helper_missing"?"Shennian Helper runtime is not installed or cannot be found.":e==="helper_version_incompatible"?"Shennian Helper runtime is incompatible with this CLI.":e==="permission_required"?"Required local permissions are missing.":e==="entitlement_required"?"WeChat capability is not enabled for this account.":e==="insufficient_credits"?"Insufficient credits.":e==="user_active_retry_later"?"User activity is in progress; retry later.":e==="attachment_pending"?"WeChat attachment is still pending.":e==="manual_review_required"?"Manual review is required before retrying.":e}function C(e){const n=e.attachments||[],t=a(e.text);return t&&n.length===0?t:t&&n.length>0?`${t} ${n.map(g).join("\u3001")}`:n.length>0?n.map(g).join("\u3001"):"\uFF08\u6D88\u606F\uFF09"}function P(e){return a(e.sender.name||e.sender.id||"\u5BF9\u65B9")}function g(e){const n=a(e.name||b.basename(e.localPath||"")||e.type||"\u9644\u4EF6"),t=e.localPath||e.url||"",i=e.availability&&e.availability!=="edge-local"?` (${e.availability})`:"";return t?`[${L(n)}](${A(t)})${i}`:`${n}${i}`}function A(e){const n=e.replace(/\\/g,"/");return/[\s()<>]/.test(n)?`<${n.replace(/[<>]/g,"")}>`:n}function L(e){return a(e).replace(/([\\\]])/g,"\\$1")}export{W as buildWeChatReadMarkdown,k as buildWeChatToolErrorResult,H as printReadLatestResult,M as printToolError,I as printToolResult};
|