shennian 0.2.78 → 0.2.84
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.
- package/dist/scripts/wechat-rpa-win-visual.mjs +1155 -127
- package/dist/scripts/wechat-rpa-win.mjs +227 -1
- package/dist/src/agents/external-channel-instructions.js +1 -3
- package/dist/src/channels/base.d.ts +9 -2
- package/dist/src/channels/runtime.d.ts +2 -1
- package/dist/src/channels/runtime.js +16 -32
- package/dist/src/channels/secret-registry.d.ts +3 -1
- package/dist/src/channels/wechat-rpa/macos-flow.d.ts +6 -5
- package/dist/src/channels/wechat-rpa/macos-flow.js +7 -80
- package/dist/src/channels/wechat-rpa/normalizer.d.ts +5 -1
- package/dist/src/channels/wechat-rpa/normalizer.js +14 -1
- package/dist/src/channels/wechat-rpa/windows-visual-flow.d.ts +4 -0
- package/dist/src/channels/wechat-rpa/windows-visual-flow.js +13 -6
- package/dist/src/channels/wechat-rpa.d.ts +12 -5
- package/dist/src/channels/wechat-rpa.js +362 -71
- package/dist/src/commands/daemon.d.ts +13 -2
- package/dist/src/commands/daemon.js +175 -14
- package/dist/src/commands/manager.d.ts +1 -1
- package/dist/src/commands/manager.js +13 -10
- package/dist/src/index.js +64 -39
- package/dist/src/manager/runtime.js +35 -3
- package/dist/src/native-fusion/opencode-parser.js +2 -0
- package/dist/src/native-fusion/parsers.js +15 -0
- package/dist/src/native-fusion/service.js +3 -23
- package/package.json +3 -3
|
@@ -33,7 +33,7 @@ export class WeChatRpaDeduper {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
export function normalizeWeChatRpaMessage(input) {
|
|
36
|
+
export function normalizeWeChatRpaMessage(input, options = {}) {
|
|
37
37
|
const conversationName = cleanText(input.conversationName);
|
|
38
38
|
const text = cleanText(input.text);
|
|
39
39
|
const attachments = normalizeAttachments(input.attachments);
|
|
@@ -44,6 +44,7 @@ export function normalizeWeChatRpaMessage(input) {
|
|
|
44
44
|
const conversationId = weChatRpaConversationId(conversationName);
|
|
45
45
|
const senderId = stableId('wechat-sender', senderName || 'unknown');
|
|
46
46
|
const rawRef = cleanText(input.rawId || '') || null;
|
|
47
|
+
const isMentioned = input.isMentioned === true || isMentionedByText(text, options.selfNicknames);
|
|
47
48
|
const messageId = rawRef
|
|
48
49
|
? stableId('wechat-message', `${conversationName}\n${rawRef}`)
|
|
49
50
|
: stableId('wechat-message', `${conversationName}\n${senderName || ''}\n${text}\n${attachments.map((item) => item.name || item.url || item.type).join('\n')}\n${receivedAt}`);
|
|
@@ -55,6 +56,7 @@ export function normalizeWeChatRpaMessage(input) {
|
|
|
55
56
|
text,
|
|
56
57
|
attachments,
|
|
57
58
|
receivedAt,
|
|
59
|
+
isMentioned,
|
|
58
60
|
rawRef,
|
|
59
61
|
};
|
|
60
62
|
}
|
|
@@ -112,3 +114,14 @@ function normalizeIso(value) {
|
|
|
112
114
|
function stableId(prefix, value) {
|
|
113
115
|
return `${prefix}:${createHash('sha256').update(value).digest('hex').slice(0, 24)}`;
|
|
114
116
|
}
|
|
117
|
+
function isMentionedByText(text, selfNicknames) {
|
|
118
|
+
const aliases = Array.isArray(selfNicknames)
|
|
119
|
+
? selfNicknames.map((item) => cleanText(item)).filter(Boolean)
|
|
120
|
+
: [];
|
|
121
|
+
if (!aliases.length)
|
|
122
|
+
return false;
|
|
123
|
+
return aliases.some((alias) => {
|
|
124
|
+
const escaped = alias.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
125
|
+
return new RegExp(`@\\s*${escaped}(?=$|\\s|[,。!?,.!?::;;、)])`).test(text);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
@@ -4,6 +4,10 @@ type WindowsVisualObservation = {
|
|
|
4
4
|
text?: string;
|
|
5
5
|
confidence?: number;
|
|
6
6
|
role?: string;
|
|
7
|
+
senderName?: string | null;
|
|
8
|
+
observedAt?: string | null;
|
|
9
|
+
timestampIso?: string | null;
|
|
10
|
+
isMentioned?: boolean | null;
|
|
7
11
|
attachment?: MacWeChatRpaAttachment;
|
|
8
12
|
};
|
|
9
13
|
type WindowsVisualSent = {
|
|
@@ -23,12 +23,10 @@ export function buildWindowsVisualFlowExec(options) {
|
|
|
23
23
|
args.push('--file', attachmentPath);
|
|
24
24
|
if (options.downloadAttachmentsDir)
|
|
25
25
|
args.push('--download-attachments-dir', options.downloadAttachmentsDir);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (options.cloudOcrChannelId)
|
|
31
|
-
args.push('--channel-id', options.cloudOcrChannelId);
|
|
26
|
+
void options.cloudOcrUrl;
|
|
27
|
+
void options.cloudOcrToken;
|
|
28
|
+
void options.cloudOcrMode;
|
|
29
|
+
void options.cloudOcrChannelId;
|
|
32
30
|
if (options.helperPath)
|
|
33
31
|
args.push('--helper', options.helperPath);
|
|
34
32
|
if (options.ocrFixturePath)
|
|
@@ -69,6 +67,8 @@ export async function runWindowsWeChatRpaVisualFlow(options) {
|
|
|
69
67
|
if (!parsed)
|
|
70
68
|
throw new Error(stderr.trim() || stdout.slice(0, 1_000) || 'WeChat RPA Windows visual flow returned invalid JSON');
|
|
71
69
|
const flow = windowsSummaryToFlowResult(options, parsed);
|
|
70
|
+
if (!flow.ok && hasSendAttempt(flow))
|
|
71
|
+
return flow;
|
|
72
72
|
if (!flow.ok)
|
|
73
73
|
throw new Error(flow.error || 'WeChat RPA Windows visual flow failed');
|
|
74
74
|
return flow;
|
|
@@ -111,6 +111,9 @@ function normalizeAttachmentPaths(options) {
|
|
|
111
111
|
}
|
|
112
112
|
return result;
|
|
113
113
|
}
|
|
114
|
+
function hasSendAttempt(result) {
|
|
115
|
+
return Boolean(result.sentReply || result.sentAttachment || result.sentReplyObserved || result.sentAttachmentObserved);
|
|
116
|
+
}
|
|
114
117
|
function observationsToMessages(groupName, observations) {
|
|
115
118
|
const messages = [];
|
|
116
119
|
for (const item of Array.isArray(observations) ? observations : []) {
|
|
@@ -125,6 +128,10 @@ function observationsToMessages(groupName, observations) {
|
|
|
125
128
|
id: `win:${stableId(`${groupName}\n${text}\n${attachment?.name || ''}`)}`,
|
|
126
129
|
text,
|
|
127
130
|
confidence: item.confidence,
|
|
131
|
+
senderName: item.senderName,
|
|
132
|
+
observedAt: item.observedAt,
|
|
133
|
+
timestampIso: item.timestampIso,
|
|
134
|
+
isMentioned: item.isMentioned,
|
|
128
135
|
attachments: attachment ? [attachment] : [],
|
|
129
136
|
});
|
|
130
137
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ExternalChannelAdapter, ExternalChannelConfig, ExternalChannelRuntimeStatus, ExternalMessageEvent, ExternalReply } from './base.js';
|
|
1
|
+
import type { ExternalChannelAdapter, ExternalChannelConfig, ExternalChannelRuntimeStatus, ExternalChannelSendResult, ExternalMessageEvent, ExternalReply } from './base.js';
|
|
2
2
|
import { type WeChatRpaObservedMessage } from './wechat-rpa/normalizer.js';
|
|
3
|
+
export declare function selectWeChatRpaLabReadKind(recentLimit?: number | null): 'read-latest' | 'scroll-read';
|
|
3
4
|
type WeChatRpaEvent = ExternalMessageEvent & {
|
|
4
5
|
type: 'external.message';
|
|
5
6
|
managerSessionId: string;
|
|
@@ -13,10 +14,7 @@ export declare class WeChatRpaChannelAdapter implements ExternalChannelAdapter {
|
|
|
13
14
|
connect(config: ExternalChannelConfig): Promise<void>;
|
|
14
15
|
disconnect(config: ExternalChannelConfig): Promise<void>;
|
|
15
16
|
syncNow(config: ExternalChannelConfig): Promise<ExternalMessageEvent[]>;
|
|
16
|
-
send(config: ExternalChannelConfig, reply: ExternalReply): Promise<
|
|
17
|
-
status: 'sent' | 'queued';
|
|
18
|
-
reason?: string;
|
|
19
|
-
}>;
|
|
17
|
+
send(config: ExternalChannelConfig, reply: ExternalReply): Promise<ExternalChannelSendResult>;
|
|
20
18
|
health(config: ExternalChannelConfig): Promise<{
|
|
21
19
|
ok: boolean;
|
|
22
20
|
message?: string;
|
|
@@ -43,6 +41,15 @@ export declare function windowsVisualFlowHealth(secret: {
|
|
|
43
41
|
ok: boolean;
|
|
44
42
|
message?: string;
|
|
45
43
|
};
|
|
44
|
+
export declare function planWeChatRpaLabSendTasks(input: {
|
|
45
|
+
groupName: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
attachmentPath?: string;
|
|
48
|
+
dedupeKey?: string;
|
|
49
|
+
requestId?: string;
|
|
50
|
+
policy?: 'work' | 'polite';
|
|
51
|
+
}): Array<Record<string, unknown>>;
|
|
52
|
+
export declare function weChatRpaLabTaskKindForAttachment(filePath: string): 'send-image' | 'send-video' | 'send-file';
|
|
46
53
|
export declare function materializeWeChatRpaOutboundAttachment(workDir: string, attachment: NonNullable<ExternalReply['attachment']>): Promise<string>;
|
|
47
54
|
export declare function annotateWeChatRpaInboundAttachments(attachments: WeChatRpaObservedMessage['attachments']): WeChatRpaObservedMessage['attachments'];
|
|
48
55
|
export {};
|