shennian 0.3.1 → 0.3.2
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/README.md +3 -1
- package/dist/publish-build-manifest.json +273 -343
- package/dist/src/agents/command-spec.js +2 -2
- package/dist/src/agents/detect.js +1 -1
- package/dist/src/agents/model-registry/discovery.js +2 -2
- package/dist/src/agents/model-registry/parsers.d.ts +1 -0
- package/dist/src/agents/model-registry/parsers.js +4 -4
- package/dist/src/agents/native-capabilities.d.ts +10 -0
- package/dist/src/agents/native-capabilities.js +1 -0
- package/dist/src/agents/platform-instructions.js +5 -5
- package/dist/src/agents/workbuddy.d.ts +44 -0
- package/dist/src/agents/workbuddy.js +3 -0
- package/dist/src/commands/daemon.d.ts +1 -0
- package/dist/src/commands/daemon.js +9 -9
- package/dist/src/commands/integration.d.ts +2 -0
- package/dist/src/commands/integration.js +1 -0
- package/dist/src/commands/manager.js +1 -2
- package/dist/src/commands/pair-browser.d.ts +43 -0
- package/dist/src/commands/pair-browser.js +1 -0
- package/dist/src/commands/pair.d.ts +2 -0
- package/dist/src/commands/pair.js +11 -8
- package/dist/src/commands/room.d.ts +13 -0
- package/dist/src/commands/room.js +4 -0
- package/dist/src/commands/upgrade.d.ts +3 -0
- package/dist/src/commands/upgrade.js +1 -1
- package/dist/src/config/index.d.ts +3 -1
- package/dist/src/config/index.js +2 -1
- package/dist/src/daemon-ipc/client.d.ts +8 -0
- package/dist/src/daemon-ipc/client.js +3 -0
- package/dist/src/daemon-ipc/paths.d.ts +7 -0
- package/dist/src/daemon-ipc/paths.js +1 -0
- package/dist/src/daemon-ipc/protocol.d.ts +30 -0
- package/dist/src/daemon-ipc/protocol.js +1 -0
- package/dist/src/daemon-ipc/secret.d.ts +3 -0
- package/dist/src/daemon-ipc/secret.js +3 -0
- package/dist/src/daemon-ipc/server.d.ts +13 -0
- package/dist/src/daemon-ipc/server.js +3 -0
- package/dist/src/index.js +2 -2
- package/dist/src/integrations/claude-room-plugin-lifecycle.d.ts +47 -0
- package/dist/src/integrations/claude-room-plugin-lifecycle.js +1 -0
- package/dist/src/integrations/codex-room-plugin-lifecycle.d.ts +49 -0
- package/dist/src/integrations/codex-room-plugin-lifecycle.js +1 -0
- package/dist/src/integrations/room-plugin-bundles.d.ts +23 -0
- package/dist/src/integrations/room-plugin-bundles.js +1 -0
- package/dist/src/integrations/room-plugin-lifecycle-common.d.ts +17 -0
- package/dist/src/integrations/room-plugin-lifecycle-common.js +1 -0
- package/dist/src/integrations/room-plugin-shared.d.ts +23 -0
- package/dist/src/integrations/room-plugin-shared.js +2 -0
- package/dist/src/integrations/room-session-hook.d.ts +30 -0
- package/dist/src/integrations/room-session-hook.js +2 -0
- package/dist/src/integrations/workbuddy-plugin-bundle.d.ts +15 -0
- package/dist/src/integrations/workbuddy-plugin-bundle.js +1 -0
- package/dist/src/integrations/workbuddy-plugin-lifecycle.d.ts +52 -0
- package/dist/src/integrations/workbuddy-plugin-lifecycle.js +2 -0
- package/dist/src/integrations/workbuddy-session-hook.d.ts +22 -0
- package/dist/src/integrations/workbuddy-session-hook.js +1 -0
- package/dist/src/manager/prompt.d.ts +1 -1
- package/dist/src/manager/prompt.js +1 -1
- package/dist/src/manager/retired-external-channel-compat.d.ts +78 -0
- package/dist/src/manager/retired-external-channel-compat.js +1 -0
- package/dist/src/manager/runtime.d.ts +1 -3
- package/dist/src/manager/runtime.js +7 -7
- package/dist/src/relay/client.d.ts +2 -0
- package/dist/src/relay/client.js +1 -1
- package/dist/src/room/activation-audit.d.ts +15 -0
- package/dist/src/room/activation-audit.js +2 -0
- package/dist/src/room/activation-policy.d.ts +8 -0
- package/dist/src/room/activation-policy.js +1 -0
- package/dist/src/room/activation-service.d.ts +25 -0
- package/dist/src/room/activation-service.js +2 -0
- package/dist/src/room/attachment-cache.d.ts +40 -0
- package/dist/src/room/attachment-cache.js +2 -0
- package/dist/src/room/attachment-upload.d.ts +20 -0
- package/dist/src/room/attachment-upload.js +1 -0
- package/dist/src/room/authorized-action-coordinator.d.ts +40 -0
- package/dist/src/room/authorized-action-coordinator.js +1 -0
- package/dist/src/room/authorized-action-ipc.d.ts +11 -0
- package/dist/src/room/authorized-action-ipc.js +1 -0
- package/dist/src/room/device-authorization-client.d.ts +49 -0
- package/dist/src/room/device-authorization-client.js +1 -0
- package/dist/src/room/host-session-observation-ipc.d.ts +9 -0
- package/dist/src/room/host-session-observation-ipc.js +1 -0
- package/dist/src/room/host-session-observations.d.ts +54 -0
- package/dist/src/room/host-session-observations.js +2 -0
- package/dist/src/room/invite-bootstrap.d.ts +35 -0
- package/dist/src/room/invite-bootstrap.js +1 -0
- package/dist/src/room/invocation-token-ipc.d.ts +9 -0
- package/dist/src/room/invocation-token-ipc.js +1 -0
- package/dist/src/room/invocation-token.d.ts +53 -0
- package/dist/src/room/invocation-token.js +1 -0
- package/dist/src/room/jsonl-mirror.d.ts +73 -0
- package/dist/src/room/jsonl-mirror.js +6 -0
- package/dist/src/room/managed-room-session.d.ts +143 -0
- package/dist/src/room/managed-room-session.js +3 -0
- package/dist/src/room/mirror-sync-service.d.ts +33 -0
- package/dist/src/room/mirror-sync-service.js +1 -0
- package/dist/src/room/operator-ipc.d.ts +11 -0
- package/dist/src/room/operator-ipc.js +1 -0
- package/dist/src/room/pending-authorized-actions.d.ts +69 -0
- package/dist/src/room/pending-authorized-actions.js +3 -0
- package/dist/src/room/room-action-client.d.ts +208 -0
- package/dist/src/room/room-action-client.js +1 -0
- package/dist/src/room/room-action-ipc.d.ts +33 -0
- package/dist/src/room/room-action-ipc.js +1 -0
- package/dist/src/room/room-action-schema.d.ts +3 -0
- package/dist/src/room/room-action-schema.js +1 -0
- package/dist/src/room/room-authorized-action-executor.d.ts +23 -0
- package/dist/src/room/room-authorized-action-executor.js +1 -0
- package/dist/src/room/room-binding-client.d.ts +51 -0
- package/dist/src/room/room-binding-client.js +1 -0
- package/dist/src/room/room-binding-ipc.d.ts +29 -0
- package/dist/src/room/room-binding-ipc.js +1 -0
- package/dist/src/room/session-registry-ipc.d.ts +14 -0
- package/dist/src/room/session-registry-ipc.js +1 -0
- package/dist/src/room/session-registry.d.ts +128 -0
- package/dist/src/room/session-registry.js +2 -0
- package/dist/src/room/tool-schema.d.ts +114 -0
- package/dist/src/room/tool-schema.js +1 -0
- package/dist/src/room/tool-server.d.ts +5 -0
- package/dist/src/room/tool-server.js +3 -0
- package/dist/src/session/handlers/agent-capabilities.d.ts +3 -0
- package/dist/src/session/handlers/agent-capabilities.js +1 -0
- package/dist/src/session/handlers/agent-config.js +1 -1
- package/dist/src/session/handlers/chat.js +2 -2
- package/dist/src/session/handlers/control.js +1 -1
- package/dist/src/session/handlers/fs.d.ts +1 -0
- package/dist/src/session/handlers/fs.js +1 -1
- package/dist/src/session/manager.d.ts +16 -6
- package/dist/src/session/manager.js +1 -1
- package/dist/src/session/types.d.ts +5 -0
- package/dist/src/upgrade/engine.d.ts +14 -1
- package/dist/src/upgrade/engine.js +2 -2
- package/dist/src/upgrade/scheduler.d.ts +45 -0
- package/dist/src/upgrade/scheduler.js +1 -0
- package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts +17 -0
- package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts.map +1 -0
- package/node_modules/@shennian/wire/dist/agent-capabilities.js +2 -0
- package/node_modules/@shennian/wire/dist/agent-capabilities.js.map +1 -0
- package/node_modules/@shennian/wire/dist/index.d.ts +2 -1
- package/node_modules/@shennian/wire/dist/index.d.ts.map +1 -1
- package/node_modules/@shennian/wire/dist/index.js +2 -1
- package/node_modules/@shennian/wire/dist/index.js.map +1 -1
- package/node_modules/@shennian/wire/dist/machine.d.ts +1 -0
- package/node_modules/@shennian/wire/dist/machine.d.ts.map +1 -1
- package/node_modules/@shennian/wire/dist/methods.d.ts +1 -1
- package/node_modules/@shennian/wire/dist/methods.d.ts.map +1 -1
- package/node_modules/@shennian/wire/dist/room.d.ts +112 -0
- package/node_modules/@shennian/wire/dist/room.d.ts.map +1 -0
- package/node_modules/@shennian/wire/dist/room.js +4 -0
- package/node_modules/@shennian/wire/dist/room.js.map +1 -0
- package/node_modules/@shennian/wire/dist/session.d.ts +2 -2
- package/node_modules/@shennian/wire/dist/session.d.ts.map +1 -1
- package/node_modules/@shennian/wire/dist/session.js +1 -1
- package/node_modules/@shennian/wire/dist/session.js.map +1 -1
- package/package.json +3 -5
- package/dist/scripts/wechat-rpa-confirmation.mjs +0 -5
- package/dist/src/agents/pi-context.d.ts +0 -42
- package/dist/src/agents/pi-context.js +0 -12
- package/dist/src/agents/pi.d.ts +0 -70
- package/dist/src/agents/pi.js +0 -17
- package/dist/src/channels/base.d.ts +0 -144
- package/dist/src/channels/base.js +0 -1
- package/dist/src/channels/registry.d.ts +0 -8
- package/dist/src/channels/registry.js +0 -1
- package/dist/src/channels/reply-split.d.ts +0 -1
- package/dist/src/channels/reply-split.js +0 -10
- package/dist/src/channels/runtime.d.ts +0 -138
- package/dist/src/channels/runtime.js +0 -5
- package/dist/src/channels/secret-registry.d.ts +0 -35
- package/dist/src/channels/secret-registry.js +0 -1
- package/dist/src/channels/websocket.d.ts +0 -55
- package/dist/src/channels/websocket.js +0 -8
- package/dist/src/channels/wechat-channel/anchor.d.ts +0 -10
- package/dist/src/channels/wechat-channel/anchor.js +0 -1
- package/dist/src/channels/wechat-channel/automation-lane.d.ts +0 -35
- package/dist/src/channels/wechat-channel/automation-lane.js +0 -2
- package/dist/src/channels/wechat-channel/client.d.ts +0 -283
- package/dist/src/channels/wechat-channel/client.js +0 -1
- package/dist/src/channels/wechat-channel/cooldown.d.ts +0 -21
- package/dist/src/channels/wechat-channel/cooldown.js +0 -1
- package/dist/src/channels/wechat-channel/core/fixture-compare.d.ts +0 -52
- package/dist/src/channels/wechat-channel/core/fixture-compare.js +0 -1
- package/dist/src/channels/wechat-channel/core/media-action-plan.d.ts +0 -3
- package/dist/src/channels/wechat-channel/core/media-action-plan.js +0 -1
- package/dist/src/channels/wechat-channel/core/schema.d.ts +0 -67
- package/dist/src/channels/wechat-channel/core/schema.js +0 -1
- package/dist/src/channels/wechat-channel/core/trace-comparator.d.ts +0 -28
- package/dist/src/channels/wechat-channel/core/trace-comparator.js +0 -1
- package/dist/src/channels/wechat-channel/fingerprint.d.ts +0 -31
- package/dist/src/channels/wechat-channel/fingerprint.js +0 -1
- package/dist/src/channels/wechat-channel/helper-assets.d.ts +0 -103
- package/dist/src/channels/wechat-channel/helper-assets.js +0 -1
- package/dist/src/channels/wechat-channel/helper-client.d.ts +0 -87
- package/dist/src/channels/wechat-channel/helper-client.js +0 -3
- package/dist/src/channels/wechat-channel/helper-protocol.d.ts +0 -122
- package/dist/src/channels/wechat-channel/helper-protocol.js +0 -1
- package/dist/src/channels/wechat-channel/human-coordination.d.ts +0 -25
- package/dist/src/channels/wechat-channel/human-coordination.js +0 -1
- package/dist/src/channels/wechat-channel/index.d.ts +0 -21
- package/dist/src/channels/wechat-channel/index.js +0 -1
- package/dist/src/channels/wechat-channel/ledger.d.ts +0 -48
- package/dist/src/channels/wechat-channel/ledger.js +0 -2
- package/dist/src/channels/wechat-channel/media-cache-resolver.d.ts +0 -42
- package/dist/src/channels/wechat-channel/media-cache-resolver.js +0 -1
- package/dist/src/channels/wechat-channel/media-resolver.d.ts +0 -186
- package/dist/src/channels/wechat-channel/media-resolver.js +0 -1
- package/dist/src/channels/wechat-channel/message-key.d.ts +0 -19
- package/dist/src/channels/wechat-channel/message-key.js +0 -1
- package/dist/src/channels/wechat-channel/observer.d.ts +0 -171
- package/dist/src/channels/wechat-channel/observer.js +0 -7
- package/dist/src/channels/wechat-channel/outbound-ledger.d.ts +0 -96
- package/dist/src/channels/wechat-channel/outbound-ledger.js +0 -2
- package/dist/src/channels/wechat-channel/outbound-sender.d.ts +0 -74
- package/dist/src/channels/wechat-channel/outbound-sender.js +0 -1
- package/dist/src/channels/wechat-channel/pacing.d.ts +0 -3
- package/dist/src/channels/wechat-channel/pacing.js +0 -1
- package/dist/src/channels/wechat-channel/preflight.d.ts +0 -46
- package/dist/src/channels/wechat-channel/preflight.js +0 -1
- package/dist/src/channels/wechat-channel/runner.d.ts +0 -43
- package/dist/src/channels/wechat-channel/runner.js +0 -1
- package/dist/src/channels/wechat-channel/runtime.d.ts +0 -50
- package/dist/src/channels/wechat-channel/runtime.js +0 -1
- package/dist/src/channels/wechat-channel/scheduler.d.ts +0 -74
- package/dist/src/channels/wechat-channel/scheduler.js +0 -1
- package/dist/src/channels/wechat-channel/vector-store.d.ts +0 -44
- package/dist/src/channels/wechat-channel/vector-store.js +0 -1
- package/dist/src/channels/wechat-rpa/macos-flow.d.ts +0 -55
- package/dist/src/channels/wechat-rpa/macos-flow.js +0 -1
- package/dist/src/channels/wechat-rpa/macos.d.ts +0 -11
- package/dist/src/channels/wechat-rpa/macos.js +0 -21
- package/dist/src/channels/wechat-rpa/normalizer.d.ts +0 -49
- package/dist/src/channels/wechat-rpa/normalizer.js +0 -7
- package/dist/src/channels/wechat-rpa/product-channel.d.ts +0 -76
- package/dist/src/channels/wechat-rpa/product-channel.js +0 -16
- package/dist/src/channels/wechat-rpa-session-sync.d.ts +0 -26
- package/dist/src/channels/wechat-rpa-session-sync.js +0 -1
- package/dist/src/channels/wechat-rpa.d.ts +0 -104
- package/dist/src/channels/wechat-rpa.js +0 -6
- package/dist/src/channels/wecom.d.ts +0 -51
- package/dist/src/channels/wecom.js +0 -4
- package/dist/src/commands/external-attachments.d.ts +0 -9
- package/dist/src/commands/external-attachments.js +0 -1
- package/dist/src/commands/external.d.ts +0 -2
- package/dist/src/commands/external.js +0 -1
- package/dist/src/commands/helper-runtime-official-download.d.ts +0 -80
- package/dist/src/commands/helper-runtime-official-download.js +0 -1
- package/dist/src/commands/runtime.d.ts +0 -120
- package/dist/src/commands/runtime.js +0 -1
- package/dist/src/commands/wechat/command.d.ts +0 -3
- package/dist/src/commands/wechat/command.js +0 -1
- package/dist/src/commands/wechat/direct.d.ts +0 -14
- package/dist/src/commands/wechat/direct.js +0 -2
- package/dist/src/commands/wechat/doctor.d.ts +0 -2
- package/dist/src/commands/wechat/doctor.js +0 -1
- package/dist/src/commands/wechat/ipc.d.ts +0 -9
- package/dist/src/commands/wechat/ipc.js +0 -1
- package/dist/src/commands/wechat/operations.d.ts +0 -3
- package/dist/src/commands/wechat/operations.js +0 -4
- package/dist/src/commands/wechat/output.d.ts +0 -7
- package/dist/src/commands/wechat/output.js +0 -4
- package/dist/src/commands/wechat/types.d.ts +0 -142
- package/dist/src/commands/wechat/types.js +0 -1
- package/dist/src/commands/wechat/utils.d.ts +0 -16
- package/dist/src/commands/wechat/utils.js +0 -1
- package/dist/src/commands/wechat.d.ts +0 -6
- package/dist/src/commands/wechat.js +0 -1
- package/dist/src/devtools/wechat-channel-action-smoke.d.ts +0 -105
- package/dist/src/devtools/wechat-channel-action-smoke.js +0 -10
- package/dist/src/devtools/wechat-channel-download-report.d.ts +0 -111
- package/dist/src/devtools/wechat-channel-download-report.js +0 -2
- package/dist/src/devtools/wechat-channel-markdown-report.d.ts +0 -6
- package/dist/src/devtools/wechat-channel-markdown-report.js +0 -5
- package/dist/src/devtools/wechat-channel-product-steps.d.ts +0 -9
- package/dist/src/devtools/wechat-channel-product-steps.js +0 -40
- package/dist/src/session/handlers/skills.d.ts +0 -7
- package/dist/src/session/handlers/skills.js +0 -1
- package/dist/src/session/handlers/wechat-helper-runtime.d.ts +0 -33
- package/dist/src/session/handlers/wechat-helper-runtime.js +0 -1
- package/dist/src/skills/registry.d.ts +0 -16
- package/dist/src/skills/registry.js +0 -15
- package/dist/src/skills/setup.d.ts +0 -11
- package/dist/src/skills/setup.js +0 -1
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export declare const WECHAT_CHANNEL_MESSAGE_KINDS: readonly ["text", "image", "file", "video-file", "video-card", "link-card", "official-account-card", "mini-program-card", "system", "recall", "unknown"];
|
|
2
|
-
export type WeChatChannelMessageKind = typeof WECHAT_CHANNEL_MESSAGE_KINDS[number];
|
|
3
|
-
export declare const WECHAT_CHANNEL_ATTACHMENT_AVAILABILITIES: readonly ["edge-local", "edge-preview", "pending-download", "metadata-only", "unsupported", "failed"];
|
|
4
|
-
export type WeChatChannelAttachmentAvailability = typeof WECHAT_CHANNEL_ATTACHMENT_AVAILABILITIES[number];
|
|
5
|
-
export declare const WECHAT_CHANNEL_MEDIA_ACTION_TYPES: readonly ["click-download", "right-click-media", "ocr-click-menu-item", "materialize-clipboard", "materialize-preview", "postprocess-file"];
|
|
6
|
-
export type WeChatChannelMediaActionType = typeof WECHAT_CHANNEL_MEDIA_ACTION_TYPES[number];
|
|
7
|
-
export declare const WECHAT_CHANNEL_TRACE_PHASES: readonly ["preflight", "open_conversation", "confirm_title", "capture_window", "structure_window_request", "structure_window_response", "normalize_messages", "validate_messages", "ledger_diff", "media_plan", "media_resolve_attempt", "media_materialize", "media_postprocess", "session_ingest", "run_summary"];
|
|
8
|
-
export type WeChatChannelTracePhase = typeof WECHAT_CHANNEL_TRACE_PHASES[number];
|
|
9
|
-
export type WeChatChannelRect = {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
width: number;
|
|
13
|
-
height: number;
|
|
14
|
-
coordinateSpace?: string;
|
|
15
|
-
};
|
|
16
|
-
export type WeChatChannelMediaCandidate = {
|
|
17
|
-
messageKey: string;
|
|
18
|
-
kind: WeChatChannelMessageKind;
|
|
19
|
-
bbox?: WeChatChannelRect;
|
|
20
|
-
screenshotBbox?: WeChatChannelRect;
|
|
21
|
-
downloadActionBbox?: WeChatChannelRect | null;
|
|
22
|
-
fileName?: string | null;
|
|
23
|
-
mimeType?: string | null;
|
|
24
|
-
size?: number | null;
|
|
25
|
-
mediaStatus?: string | null;
|
|
26
|
-
};
|
|
27
|
-
export type WeChatChannelAttachmentDescriptor = {
|
|
28
|
-
type: 'image' | 'video' | 'file' | string;
|
|
29
|
-
name?: string;
|
|
30
|
-
mimeType?: string;
|
|
31
|
-
sizeBytes?: number;
|
|
32
|
-
extension?: string;
|
|
33
|
-
localPath?: string;
|
|
34
|
-
sha256?: string;
|
|
35
|
-
availability: WeChatChannelAttachmentAvailability;
|
|
36
|
-
providerError?: string;
|
|
37
|
-
sourceAction?: WeChatChannelMediaActionType;
|
|
38
|
-
materializationKind?: 'original-file' | 'clipboard-image' | 'preview-crop' | 'metadata';
|
|
39
|
-
isOriginal?: boolean;
|
|
40
|
-
mimeKindMatches?: boolean;
|
|
41
|
-
};
|
|
42
|
-
export type WeChatChannelMediaAction = {
|
|
43
|
-
type: WeChatChannelMediaActionType;
|
|
44
|
-
target?: WeChatChannelRect;
|
|
45
|
-
label?: string;
|
|
46
|
-
reasonCode?: string;
|
|
47
|
-
};
|
|
48
|
-
export type WeChatChannelMediaActionPlan = {
|
|
49
|
-
messageKey: string;
|
|
50
|
-
kind: WeChatChannelMessageKind;
|
|
51
|
-
actions: WeChatChannelMediaAction[];
|
|
52
|
-
reasonCode: string;
|
|
53
|
-
};
|
|
54
|
-
export type WeChatChannelTraceEvent = {
|
|
55
|
-
traceId: string;
|
|
56
|
-
phase: WeChatChannelTracePhase;
|
|
57
|
-
status: 'ok' | 'pending' | 'failed' | 'skipped';
|
|
58
|
-
reasonCode?: string;
|
|
59
|
-
latencyMs?: number;
|
|
60
|
-
inputHash?: string;
|
|
61
|
-
outputHash?: string;
|
|
62
|
-
};
|
|
63
|
-
export declare function normalizeWeChatChannelMessageKind(value: unknown): WeChatChannelMessageKind;
|
|
64
|
-
export declare function isWeChatChannelMessageKind(value: unknown): value is WeChatChannelMessageKind;
|
|
65
|
-
export declare function normalizeWeChatChannelAttachmentAvailability(value: unknown): WeChatChannelAttachmentAvailability;
|
|
66
|
-
export declare function isWeChatChannelAttachmentAvailability(value: unknown): value is WeChatChannelAttachmentAvailability;
|
|
67
|
-
export declare function isWeChatChannelTracePhase(value: unknown): value is WeChatChannelTracePhase;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const o=["text","image","file","video-file","video-card","link-card","official-account-card","mini-program-card","system","recall","unknown"],r=["edge-local","edge-preview","pending-download","metadata-only","unsupported","failed"],m=["click-download","right-click-media","ocr-click-menu-item","materialize-clipboard","materialize-preview","postprocess-file"],d=["preflight","open_conversation","confirm_title","capture_window","structure_window_request","structure_window_response","normalize_messages","validate_messages","ledger_diff","media_plan","media_resolve_attempt","media_materialize","media_postprocess","session_ingest","run_summary"],l={photo:"image",picture:"image",img:"image",emoji:"text",video:"video-file",video_file:"video-file",video_card:"video-card",document:"file","document-card":"file",filecard:"file","file-card":"file",link:"link-card",link_card:"link-card",card:"link-card",official:"official-account-card","official-account":"official-account-card",official_account_card:"official-account-card",miniprogram:"mini-program-card","mini-program":"mini-program-card",mini_program_card:"mini-program-card"},c={available:"edge-local",downloaded:"edge-local",local:"edge-local",preview:"edge-preview",edge_preview:"edge-preview",pending:"pending-download",pending_download:"pending-download",not_downloaded:"pending-download",metadata:"metadata-only",metadata_only:"metadata-only",unavailable:"failed","unavailable-large":"failed",unavailable_large:"failed",error:"failed"};function s(e){const a=t(e);if(!a)return"unknown";const i=o.find(n=>n===a);return i||(l[a]??"unknown")}function f(e){return o.includes(e)}function u(e){const a=t(e);if(!a)return"metadata-only";const i=r.find(n=>n===a);return i||(c[a]??"metadata-only")}function p(e){return r.includes(e)}function _(e){return d.includes(e)}function t(e){return String(e??"").trim().toLowerCase().replace(/\s+/g,"-")}export{r as WECHAT_CHANNEL_ATTACHMENT_AVAILABILITIES,m as WECHAT_CHANNEL_MEDIA_ACTION_TYPES,o as WECHAT_CHANNEL_MESSAGE_KINDS,d as WECHAT_CHANNEL_TRACE_PHASES,p as isWeChatChannelAttachmentAvailability,f as isWeChatChannelMessageKind,_ as isWeChatChannelTracePhase,u as normalizeWeChatChannelAttachmentAvailability,s as normalizeWeChatChannelMessageKind};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { WeChatChannelTraceEvent, WeChatChannelTracePhase } from './schema.js';
|
|
2
|
-
export type WeChatChannelTraceComparableField = 'status' | 'reasonCode' | 'inputHash' | 'outputHash';
|
|
3
|
-
export type WeChatChannelTracePhaseDiff = {
|
|
4
|
-
phase: WeChatChannelTracePhase | string;
|
|
5
|
-
reasonCode: 'missing_left_phase' | 'missing_right_phase' | 'phase_field_mismatch';
|
|
6
|
-
fields: WeChatChannelTraceComparableField[];
|
|
7
|
-
left?: Partial<WeChatChannelTraceEvent>;
|
|
8
|
-
right?: Partial<WeChatChannelTraceEvent>;
|
|
9
|
-
};
|
|
10
|
-
export type WeChatChannelTraceComparison = {
|
|
11
|
-
ok: boolean;
|
|
12
|
-
firstDiff?: WeChatChannelTracePhaseDiff;
|
|
13
|
-
diffs: WeChatChannelTracePhaseDiff[];
|
|
14
|
-
};
|
|
15
|
-
export type WeChatChannelPlatformTracePhaseDiff = WeChatChannelTracePhaseDiff & {
|
|
16
|
-
leftPlatform: string;
|
|
17
|
-
rightPlatform: string;
|
|
18
|
-
};
|
|
19
|
-
export type WeChatChannelPlatformTraceComparison = {
|
|
20
|
-
ok: boolean;
|
|
21
|
-
firstDiff?: WeChatChannelPlatformTracePhaseDiff;
|
|
22
|
-
diffs: WeChatChannelPlatformTracePhaseDiff[];
|
|
23
|
-
};
|
|
24
|
-
export declare function compareWeChatChannelTracePhases(input: {
|
|
25
|
-
left: WeChatChannelTraceEvent[];
|
|
26
|
-
right: WeChatChannelTraceEvent[];
|
|
27
|
-
}): WeChatChannelTraceComparison;
|
|
28
|
-
export declare function compareWeChatChannelPlatformTracePhases(traces: Record<string, WeChatChannelTraceEvent[]>): WeChatChannelPlatformTraceComparison;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const l=["status","reasonCode","inputHash","outputHash"];function g(t){const e=u(t.left),s=u(t.right),r=d([...t.left.map(o=>o.phase),...t.right.map(o=>o.phase)]),n=[];for(const o of r){const a=e.get(o),f=s.get(o);if(!a||!f){n.push({phase:o,reasonCode:a?"missing_right_phase":"missing_left_phase",fields:[],...a?{left:h(a)}:{},...f?{right:h(f)}:{}});continue}const i=l.filter(c=>p(a[c])!==p(f[c]));i.length&&n.push({phase:o,reasonCode:"phase_field_mismatch",fields:i,left:h(a),right:h(f)})}return{ok:n.length===0,firstDiff:n[0],diffs:n}}function m(t){const e=Object.entries(t);if(e.length<=1)return{ok:!0,firstDiff:void 0,diffs:[]};const[s,r]=e[0],n=[];for(const[o,a]of e.slice(1)){const f=g({left:r,right:a});n.push(...f.diffs.map(i=>({...i,leftPlatform:s,rightPlatform:o})))}return{ok:n.length===0,firstDiff:n[0],diffs:n}}function u(t){const e=new Map;for(const s of t)e.has(s.phase)||e.set(s.phase,s);return e}function d(t){const e=new Set,s=[];for(const r of t)e.has(r)||(e.add(r),s.push(r));return s}function h(t){return{phase:t.phase,status:t.status,reasonCode:t.reasonCode,inputHash:t.inputHash,outputHash:t.outputHash}}function p(t){return typeof t=="string"?t:""}export{m as compareWeChatChannelPlatformTracePhases,g as compareWeChatChannelTracePhases};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type WeChatConversationListFingerprint = {
|
|
2
|
-
conversationId?: string | null;
|
|
3
|
-
title?: string | null;
|
|
4
|
-
preview?: string | null;
|
|
5
|
-
timeText?: string | null;
|
|
6
|
-
unreadText?: string | null;
|
|
7
|
-
fingerprint?: string | null;
|
|
8
|
-
bbox?: unknown;
|
|
9
|
-
titleBox?: unknown;
|
|
10
|
-
timeBox?: unknown;
|
|
11
|
-
previewBox?: unknown;
|
|
12
|
-
};
|
|
13
|
-
export type WeChatConversationFingerprintTarget = {
|
|
14
|
-
bindingId: string;
|
|
15
|
-
conversationDisplayName: string;
|
|
16
|
-
lastConversationFingerprint?: string | null;
|
|
17
|
-
lastPreview?: string | null;
|
|
18
|
-
};
|
|
19
|
-
export type WeChatConversationFingerprintMatch = {
|
|
20
|
-
bindingId: string;
|
|
21
|
-
item: WeChatConversationListFingerprint;
|
|
22
|
-
score: number;
|
|
23
|
-
reason: 'fingerprint' | 'title-preview' | 'title' | 'none';
|
|
24
|
-
};
|
|
25
|
-
export declare function buildWeChatConversationFingerprint(input: WeChatConversationListFingerprint): string;
|
|
26
|
-
export declare function matchWeChatConversationFingerprints(input: {
|
|
27
|
-
visibleItems: WeChatConversationListFingerprint[];
|
|
28
|
-
targets: WeChatConversationFingerprintTarget[];
|
|
29
|
-
minScore?: number;
|
|
30
|
-
}): WeChatConversationFingerprintMatch[];
|
|
31
|
-
export declare function scoreConversationFingerprint(target: WeChatConversationFingerprintTarget, item: WeChatConversationListFingerprint): WeChatConversationFingerprintMatch;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const h=16;function l(n){return[s(n.title),s(n.timeText),d(n.preview)].filter(Boolean).join("|")}function d(n){const e=s(n);return e?Array.from(e).slice(0,16).join(""):""}function m(n){const e=n.minScore??.72,t=n.visibleItems.map(o=>({...o,fingerprint:o.fingerprint||l(o)})),i=[];for(const o of n.targets){let r=null;for(const c of t){const a=g(o,c);(!r||a.score>r.score)&&(r=a)}if(r&&r.score>=e&&r.reason!=="none"){i.push(r);const c=t.findIndex(a=>a===r.item);c>=0&&t.splice(c,1)}}return i}function g(n,e){const t=e.fingerprint||l(e);if(n.lastConversationFingerprint&&t&&n.lastConversationFingerprint===t)return{bindingId:n.bindingId,item:e,score:1,reason:"fingerprint"};if(f(n.conversationDisplayName)&&p(e.title,n.conversationDisplayName))return{bindingId:n.bindingId,item:e,score:1,reason:"title"};if(f(n.conversationDisplayName)&&!p(e.title,n.conversationDisplayName))return{bindingId:n.bindingId,item:e,score:0,reason:"none"};const i=u(n.conversationDisplayName,e.title),o=n.lastPreview?u(n.lastPreview,e.preview):0;return i>=.8&&o>=.55?{bindingId:n.bindingId,item:e,score:i*.7+o*.3,reason:"title-preview"}:i>=.88?{bindingId:n.bindingId,item:e,score:i*.86,reason:"title"}:{bindingId:n.bindingId,item:e,score:i*.5+o*.2,reason:"none"}}function s(n){return typeof n=="string"?n.trim().replace(/\s+/g," ").toLowerCase():""}function f(n){const e=typeof n=="string"?n.trim():"";return/^[A-Z0-9_-]{1,6}$/.test(e)&&/[A-Z]/.test(e)}function p(n,e){const t=typeof n=="string"?n.trim().replace(/\s+/g," "):"",i=typeof e=="string"?e.trim().replace(/\s+/g," "):"";return!t||!i?!1:t===i?!0:v(t)===i}function v(n){return n.normalize("NFKC").replace(/\s*[((][0-9]+[))]\s*$/u,"").replace(/\s+/g," ").trim()}function u(n,e){const t=s(n),i=s(e);return!t||!i?0:t===i?1:1-I(t,i)/Math.max(t.length,i.length)}function I(n,e){const t=Array.from({length:e.length+1},(o,r)=>r),i=Array.from({length:e.length+1},()=>0);for(let o=1;o<=n.length;o+=1){i[0]=o;for(let r=1;r<=e.length;r+=1)i[r]=Math.min(t[r]+1,i[r-1]+1,t[r-1]+(n[o-1]===e[r-1]?0:1));for(let r=0;r<=e.length;r+=1)t[r]=i[r]}return t[e.length]}export{l as buildWeChatConversationFingerprint,m as matchWeChatConversationFingerprints,g as scoreConversationFingerprint};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
export declare const WECHAT_CHANNEL_HELPER_VERSION = "0.1.12";
|
|
2
|
-
export declare const WECHAT_CHANNEL_HELPER_DIR_ENV = "SHENNIAN_WECHAT_CHANNEL_HELPER_DIR";
|
|
3
|
-
export declare const SHENNIAN_HELPER_RUNTIME_DIR_ENV = "SHENNIAN_HELPER_RUNTIME_DIR";
|
|
4
|
-
export declare const WECHAT_CHANNEL_HELPER_RUNTIME_REQUIRED_REASON = "helper_runtime_required";
|
|
5
|
-
export type WeChatChannelHelperAssetManifest = {
|
|
6
|
-
schemaVersion: 1;
|
|
7
|
-
helperVersion: string;
|
|
8
|
-
protocolVersion: number;
|
|
9
|
-
platforms: Record<string, {
|
|
10
|
-
executable: string;
|
|
11
|
-
sha256: string | null;
|
|
12
|
-
signed: boolean;
|
|
13
|
-
notarized: boolean;
|
|
14
|
-
signing?: {
|
|
15
|
-
authority?: string | null;
|
|
16
|
-
teamIdentifier?: string | null;
|
|
17
|
-
hardenedRuntime?: boolean;
|
|
18
|
-
};
|
|
19
|
-
notarization?: {
|
|
20
|
-
status?: string;
|
|
21
|
-
id?: string;
|
|
22
|
-
};
|
|
23
|
-
target?: string;
|
|
24
|
-
selfContained?: boolean;
|
|
25
|
-
}>;
|
|
26
|
-
};
|
|
27
|
-
export type WeChatChannelHelperRuntimePackageManifest = {
|
|
28
|
-
schemaVersion: 1;
|
|
29
|
-
packageKind: 'shennian-helper-runtime';
|
|
30
|
-
platform: 'darwin' | 'win32';
|
|
31
|
-
helperVersion: string;
|
|
32
|
-
protocolVersion: number;
|
|
33
|
-
minCliVersion: string;
|
|
34
|
-
sha256: {
|
|
35
|
-
runtimeManifest: string;
|
|
36
|
-
entrypoint: string | null;
|
|
37
|
-
};
|
|
38
|
-
installTarget: {
|
|
39
|
-
kind: 'app-bundle' | 'directory';
|
|
40
|
-
defaultPath: string;
|
|
41
|
-
};
|
|
42
|
-
payload: {
|
|
43
|
-
kind: 'macos-helper-app' | 'windows-helper-runtime';
|
|
44
|
-
runtimeManifest: string;
|
|
45
|
-
entrypoint: string;
|
|
46
|
-
bundleId?: string;
|
|
47
|
-
target?: string;
|
|
48
|
-
selfContained?: boolean;
|
|
49
|
-
};
|
|
50
|
-
signature: {
|
|
51
|
-
requiredForRelease: boolean;
|
|
52
|
-
signed: boolean;
|
|
53
|
-
notarized: boolean;
|
|
54
|
-
evidence?: Record<string, unknown>;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
export type WeChatChannelHelperAssetResolution = {
|
|
58
|
-
ok: true;
|
|
59
|
-
helperPath: string;
|
|
60
|
-
version: string;
|
|
61
|
-
manifest: WeChatChannelHelperAssetManifest;
|
|
62
|
-
helperDir: string;
|
|
63
|
-
warning?: string;
|
|
64
|
-
} | {
|
|
65
|
-
ok: false;
|
|
66
|
-
reasonCode: 'unsupported_platform' | 'helper_runtime_required' | 'manifest_missing' | 'helper_missing' | 'integrity_mismatch' | 'helper_not_executable';
|
|
67
|
-
message: string;
|
|
68
|
-
};
|
|
69
|
-
export type WeChatChannelHelperRuntimePackageResolution = {
|
|
70
|
-
ok: true;
|
|
71
|
-
manifestPath: string;
|
|
72
|
-
manifest: WeChatChannelHelperRuntimePackageManifest;
|
|
73
|
-
} | {
|
|
74
|
-
ok: false;
|
|
75
|
-
reasonCode: 'unsupported_platform' | 'helper_runtime_package_manifest_missing' | 'helper_runtime_package_manifest_invalid';
|
|
76
|
-
message: string;
|
|
77
|
-
manifestPath?: string;
|
|
78
|
-
};
|
|
79
|
-
export declare function resolveWeChatChannelHelperAsset(input?: {
|
|
80
|
-
platform?: NodeJS.Platform | string;
|
|
81
|
-
baseDir?: string;
|
|
82
|
-
verifyIntegrity?: boolean;
|
|
83
|
-
env?: NodeJS.ProcessEnv;
|
|
84
|
-
homedir?: string;
|
|
85
|
-
includeInstalledDesktop?: boolean;
|
|
86
|
-
}): WeChatChannelHelperAssetResolution;
|
|
87
|
-
export declare function getDefaultWeChatHelperRuntimeRoot(input?: {
|
|
88
|
-
platform?: NodeJS.Platform | string;
|
|
89
|
-
env?: NodeJS.ProcessEnv;
|
|
90
|
-
homedir?: string;
|
|
91
|
-
}): string | null;
|
|
92
|
-
export declare function helperRuntimePackageManifestCandidates(helperDir: string): string[];
|
|
93
|
-
export declare function readWeChatChannelHelperRuntimePackageManifest(input: {
|
|
94
|
-
platform?: NodeJS.Platform | string;
|
|
95
|
-
helperDir?: string;
|
|
96
|
-
manifestPath?: string;
|
|
97
|
-
}): WeChatChannelHelperRuntimePackageResolution;
|
|
98
|
-
export declare function validateWeChatChannelHelperRuntimePackageManifest(manifest: unknown, platform: NodeJS.Platform | string): {
|
|
99
|
-
ok: true;
|
|
100
|
-
} | {
|
|
101
|
-
ok: false;
|
|
102
|
-
message: string;
|
|
103
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import c from"node:fs";import s from"node:path";import w from"node:crypto";const V="0.1.12",E="SHENNIAN_WECHAT_CHANNEL_HELPER_DIR",d="SHENNIAN_HELPER_RUNTIME_DIR",S="helper_runtime_required",C=["en","v"].join("");function $(n={}){const r=n.platform??process.platform;if(r!=="darwin"&&r!=="win32")return{ok:!1,reasonCode:"unsupported_platform",message:"WeChat channel helper is only available on macOS and Windows"};const e=n.baseDir?[s.resolve(n.baseDir)]:A({platform:r,env:n.env??y(),homedir:n.homedir,includeInstalledDesktop:n.includeInstalledDesktop});let a=null;for(const t of e){const i=_({platform:r,baseDir:t,verifyIntegrity:n.verifyIntegrity});if(i.ok||(n.baseDir||c.existsSync(t))&&(a??=i,n.baseDir))return i}return a??{ok:!1,reasonCode:S,message:x(r,e)}}function _(n){const{platform:r,baseDir:e}=n,a=s.join(e,"manifest.json"),t=F(a);if(!t)return{ok:!1,reasonCode:"manifest_missing",message:`WeChat channel helper manifest is missing: ${a}`};const i=t.platforms[r],o=i?s.join(e,i.executable):"";if(!i||!o||!c.existsSync(o))return{ok:!1,reasonCode:"helper_missing",message:`WeChat channel helper executable is missing: ${o||e}`};if(L({platform:r,baseDir:e,verifyIntegrity:n.verifyIntegrity})&&i.sha256&&w.createHash("sha256").update(c.readFileSync(o)).digest("hex")!==i.sha256)return{ok:!1,reasonCode:"integrity_mismatch",message:`WeChat channel helper integrity mismatch: ${o}`};const f=H(r,o);return f.ok?{ok:!0,helperPath:o,helperDir:e,version:t.helperVersion,manifest:t,warning:i.signed&&i.notarized?void 0:"helper_not_signed_or_notarized"}:{ok:!1,reasonCode:"helper_not_executable",message:f.message}}function H(n,r){if(n!=="darwin")return{ok:!0};try{const e=c.statSync(r);return(e.mode&73)!==0?{ok:!0}:(c.chmodSync(r,e.mode|73),{ok:!0})}catch(e){return{ok:!1,message:`WeChat channel helper is not executable and could not be repaired: ${r}: ${e instanceof Error?e.message:String(e)}`}}}function A(n){const{platform:r,env:e}=n,a=r==="win32"?"windows":"macos",t=[],i=l=>{if(!l)return;const p=s.resolve(l);t.includes(p)||t.push(p)},o=e[E]?.trim();o&&i(j(o,a));const f=e[d]?.trim();if(f)for(const l of P(f,a))i(l);if(b({platform:r,platformDir:a,env:e,homedir:n.homedir,push:i}),n.includeInstalledDesktop===!1)return t;if(r==="darwin"){const l=n.homedir||e.HOME;l&&i(s.join(l,"Applications","Shennian.app","Contents","Resources","wechat-channel",a)),i(s.join("/Applications","Shennian.app","Contents","Resources","wechat-channel",a))}else if(r==="win32"){const l=n.homedir||e.USERPROFILE,p=e.LOCALAPPDATA||(l?s.join(l,"AppData","Local"):""),u=e.ProgramFiles||e.PROGRAMFILES,m=e["ProgramFiles(x86)"]||e["PROGRAMFILES(X86)"];for(const h of[p?s.join(p,"Programs","Shennian"):"",p?s.join(p,"Programs","shennian"):"",u?s.join(u,"Shennian"):"",m?s.join(m,"Shennian"):""])h&&i(s.join(h,"resources","wechat-channel",a))}return t}function b(n){const{platform:r,platformDir:e,env:a,push:t}=n;if(r==="darwin"){const i=n.homedir||a.HOME,o=g({platform:r,env:a,homedir:n.homedir});o&&(t(s.join(o,"Shennian Helper.app","Contents","Resources","wechat-channel",e)),t(s.join(o,"wechat-channel",e))),i&&t(s.join(i,"Applications","Shennian Helper.app","Contents","Resources","wechat-channel",e)),t(s.join("/Applications","Shennian Helper.app","Contents","Resources","wechat-channel",e)),t(s.join("/Library","Application Support","Shennian","Helper","wechat-channel",e))}else if(r==="win32"){const i=n.homedir||a.USERPROFILE,o=a.LOCALAPPDATA||(i?s.join(i,"AppData","Local"):""),f=a.ProgramFiles||a.PROGRAMFILES,l=a["ProgramFiles(x86)"]||a["PROGRAMFILES(X86)"];o&&(t(s.join(o,"Programs","Shennian Helper","resources","wechat-channel",e)),t(s.join(o,"Shennian","Helper","wechat-channel",e))),f&&t(s.join(f,"Shennian Helper","resources","wechat-channel",e)),l&&t(s.join(l,"Shennian Helper","resources","wechat-channel",e))}}function j(n,r){return c.existsSync(s.join(n,"manifest.json"))?n:s.join(n,r)}function P(n,r){if(c.existsSync(s.join(n,"manifest.json")))return[n];const e=s.join(n,"Shennian Helper.app","Contents","Resources","wechat-channel",r),a=s.join(n,"wechat-channel",r),t=s.join(n,r);return[e,a,t]}function g(n){const r=n.env,e=r[d]?.trim();if(e)return s.resolve(e);const a=n.homedir||(n.platform==="win32"?r.USERPROFILE:r.HOME);if(n.platform==="darwin")return a?s.join(a,"Library","Application Support","Shennian","Helper"):null;if(n.platform==="win32"){const t=r.LOCALAPPDATA||(a?s.join(a,"AppData","Local"):"");return t?s.join(t,"Shennian","Helper"):null}return null}function q(n={}){return g({platform:n.platform??process.platform,env:n.env??y(),homedir:n.homedir})}function D(n){const r=s.resolve(n);return O([s.join(r,"helper-runtime-package.json"),s.join(s.dirname(r),"..","helper-runtime-package.json")])}function U(n){const r=n.platform??process.platform;if(r!=="darwin"&&r!=="win32")return{ok:!1,reasonCode:"unsupported_platform",message:"WeChat channel helper runtime package is only available on macOS and Windows"};const e=n.manifestPath?[s.resolve(n.manifestPath)]:n.helperDir?D(n.helperDir):[],a=e.find(t=>c.existsSync(t));if(!a)return{ok:!1,reasonCode:"helper_runtime_package_manifest_missing",message:`Helper runtime package manifest is missing. Checked: ${e.join(", ")||"(none)"}`,manifestPath:e[0]};try{const t=JSON.parse(R(a)),i=v(t,r);return i.ok?{ok:!0,manifestPath:a,manifest:t}:{ok:!1,reasonCode:"helper_runtime_package_manifest_invalid",message:`${i.message}: ${a}`,manifestPath:a}}catch(t){return{ok:!1,reasonCode:"helper_runtime_package_manifest_invalid",message:`Helper runtime package manifest is invalid JSON: ${t instanceof Error?t.message:String(t)}`,manifestPath:a}}}function v(n,r){if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1,message:"manifest must be an object"};const e=n;return e.schemaVersion!==1?{ok:!1,message:"schemaVersion must be 1"}:e.packageKind!=="shennian-helper-runtime"?{ok:!1,message:"packageKind must be shennian-helper-runtime"}:e.platform!==r?{ok:!1,message:`platform must be ${r}`}:e.helperVersion?!Number.isInteger(e.protocolVersion)||Number(e.protocolVersion)<=0?{ok:!1,message:"protocolVersion must be a positive integer"}:I(e.minCliVersion)?!e.sha256||typeof e.sha256.runtimeManifest!="string"?{ok:!1,message:"sha256.runtimeManifest is required"}:k(e.sha256.runtimeManifest)?e.sha256.entrypoint!==null&&typeof e.sha256.entrypoint!="string"?{ok:!1,message:"sha256.entrypoint must be a string or null"}:typeof e.sha256.entrypoint=="string"&&!k(e.sha256.entrypoint)?{ok:!1,message:"sha256.entrypoint must be a sha256 digest or null"}:!e.installTarget?.kind||!e.installTarget.defaultPath?{ok:!1,message:"installTarget.kind and installTarget.defaultPath are required"}:!e.payload?.kind||!e.payload.runtimeManifest||!e.payload.entrypoint?{ok:!1,message:"payload.kind, payload.runtimeManifest, and payload.entrypoint are required"}:r==="darwin"&&e.installTarget.kind!=="app-bundle"?{ok:!1,message:"darwin installTarget.kind must be app-bundle"}:r==="darwin"&&e.payload.kind!=="macos-helper-app"?{ok:!1,message:"darwin payload.kind must be macos-helper-app"}:r==="win32"&&e.installTarget.kind!=="directory"?{ok:!1,message:"win32 installTarget.kind must be directory"}:r==="win32"&&e.payload.kind!=="windows-helper-runtime"?{ok:!1,message:"win32 payload.kind must be windows-helper-runtime"}:!e.signature||typeof e.signature.requiredForRelease!="boolean"||typeof e.signature.signed!="boolean"||typeof e.signature.notarized!="boolean"?{ok:!1,message:"signature.requiredForRelease, signature.signed, and signature.notarized are required"}:{ok:!0}:{ok:!1,message:"sha256.runtimeManifest must be a sha256 digest"}:{ok:!1,message:"minCliVersion must be a semver string"}:{ok:!1,message:"helperVersion is required"}}function I(n){return typeof n=="string"&&/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(n)}function k(n){return/^[a-f0-9]{64}$/i.test(n)}function L(n){return n.verifyIntegrity===!0?!0:n.verifyIntegrity===!1?!1:!N(n.platform,n.baseDir)}function N(n,r){const e=r.replace(/[\\/]+/g,"/");return n==="darwin"?/\/Shennian\.app\/Contents\/Resources\/wechat-channel\/macos$/i.test(e):n==="win32"?/\/resources\/wechat-channel\/windows$/i.test(e):!1}function x(n,r){const e=n==="win32"?"Windows":"macOS",a=r.length>0?` Checked helper directories: ${r.join(", ")}`:"";return`WeChat RPA requires Shennian Helper runtime on ${e}; open Shennian Desktop or use the \u4F7F\u7528\u5FAE\u4FE1 page to install Helper, then retry.${a}`}function y(){return globalThis.process?.[C]??{}}function F(n){try{const r=JSON.parse(R(n));return r.schemaVersion!==1||typeof r.helperVersion!="string"||!r.platforms?null:r}catch{return null}}function R(n){return c.readFileSync(n,"utf8").replace(/^\uFEFF/,"")}function O(n){const r=new Set,e=[];for(const a of n){const t=s.resolve(a);r.has(t)||(r.add(t),e.push(t))}return e}export{d as SHENNIAN_HELPER_RUNTIME_DIR_ENV,E as WECHAT_CHANNEL_HELPER_DIR_ENV,S as WECHAT_CHANNEL_HELPER_RUNTIME_REQUIRED_REASON,V as WECHAT_CHANNEL_HELPER_VERSION,q as getDefaultWeChatHelperRuntimeRoot,D as helperRuntimePackageManifestCandidates,U as readWeChatChannelHelperRuntimePackageManifest,$ as resolveWeChatChannelHelperAsset,v as validateWeChatChannelHelperRuntimePackageManifest};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { type WeChatChannelHelperCommandName, type WeChatChannelHelperCapability, type WeChatChannelHelperHealthResult, type WeChatChannelHelperReady, type WeChatChannelHelperResponse, type WeChatChannelHelperWarmupSnapshot } from './helper-protocol.js';
|
|
2
|
-
export type WeChatChannelHelperClientOptions = {
|
|
3
|
-
helperPath: string;
|
|
4
|
-
expectedHelperVersion: string;
|
|
5
|
-
args?: string[];
|
|
6
|
-
cwd?: string;
|
|
7
|
-
requiredCapabilities?: WeChatChannelHelperCapability[];
|
|
8
|
-
guardUnsafeWindowsCommands?: boolean;
|
|
9
|
-
skipUserActivityGuard?: boolean;
|
|
10
|
-
cleanupWindowsOverlays?: boolean;
|
|
11
|
-
requestLogger?: (event: WeChatChannelHelperRequestTraceEvent) => void;
|
|
12
|
-
openHelperAppForTest?: (command: string, args: string[]) => Promise<void>;
|
|
13
|
-
macosRuntimeInitialReadyTimeoutMs?: number;
|
|
14
|
-
macosRuntimeRelaunchReadyTimeoutMs?: number;
|
|
15
|
-
};
|
|
16
|
-
export type WeChatChannelHelperRequestTraceEvent = {
|
|
17
|
-
phase: 'request' | 'response' | 'error';
|
|
18
|
-
at: string;
|
|
19
|
-
id: string;
|
|
20
|
-
command: WeChatChannelHelperCommandName;
|
|
21
|
-
traceId?: string;
|
|
22
|
-
timeoutMs?: number;
|
|
23
|
-
durationMs?: number;
|
|
24
|
-
params?: Record<string, unknown>;
|
|
25
|
-
ok?: boolean;
|
|
26
|
-
errorCode?: string;
|
|
27
|
-
errorSummary?: string;
|
|
28
|
-
latencyMs?: number;
|
|
29
|
-
result?: unknown;
|
|
30
|
-
};
|
|
31
|
-
export declare class WeChatChannelHelperClient {
|
|
32
|
-
private options;
|
|
33
|
-
private child;
|
|
34
|
-
private socket;
|
|
35
|
-
private lines;
|
|
36
|
-
private readyState;
|
|
37
|
-
private warmupState;
|
|
38
|
-
private stderrTail;
|
|
39
|
-
private startPromise;
|
|
40
|
-
private requestQueueTail;
|
|
41
|
-
private lastGuardPassAtMs;
|
|
42
|
-
private pending;
|
|
43
|
-
constructor(options: WeChatChannelHelperClientOptions);
|
|
44
|
-
start(): Promise<WeChatChannelHelperReady>;
|
|
45
|
-
private startFresh;
|
|
46
|
-
private startStdioFresh;
|
|
47
|
-
private startDarwinAppSocketFresh;
|
|
48
|
-
request<T = unknown>(command: WeChatChannelHelperCommandName, params?: Record<string, unknown>, traceId?: string): Promise<WeChatChannelHelperResponse<T>>;
|
|
49
|
-
private sendRequest;
|
|
50
|
-
private sendRawRequest;
|
|
51
|
-
private guardUnsafeWindowsCommand;
|
|
52
|
-
private tryRecoverFromStuckShell;
|
|
53
|
-
private requestFirstMissingMacPermissionPrompt;
|
|
54
|
-
private cleanupWindowsOverlaysAfterCommand;
|
|
55
|
-
private cleanupWindowsOverlays;
|
|
56
|
-
healthCheck(traceId?: string): Promise<WeChatChannelHelperResponse<WeChatChannelHelperHealthResult>>;
|
|
57
|
-
getReadyState(): WeChatChannelHelperReady | null;
|
|
58
|
-
getWarmupState(): WeChatChannelHelperWarmupSnapshot | null;
|
|
59
|
-
stop(): Promise<void>;
|
|
60
|
-
private hasTransport;
|
|
61
|
-
private writeFrame;
|
|
62
|
-
private handleLine;
|
|
63
|
-
private captureWarmupSnapshot;
|
|
64
|
-
private captureStderr;
|
|
65
|
-
private formatHelperExitMessage;
|
|
66
|
-
private rejectAllPending;
|
|
67
|
-
private emitRequestTrace;
|
|
68
|
-
private stopAfterCommandTimeout;
|
|
69
|
-
private connectDarwinHelperSocket;
|
|
70
|
-
}
|
|
71
|
-
export declare function stopWindowsWeChatChannelHelperProcesses(pids?: number[]): Promise<void>;
|
|
72
|
-
type LegacyRawHelperLaunchSpec = {
|
|
73
|
-
transport: 'legacy-stdio';
|
|
74
|
-
command: string;
|
|
75
|
-
args: string[];
|
|
76
|
-
};
|
|
77
|
-
type DarwinAppSocketHelperLaunchSpec = {
|
|
78
|
-
transport: 'macos-socket';
|
|
79
|
-
command: string;
|
|
80
|
-
args: string[];
|
|
81
|
-
appPath: string;
|
|
82
|
-
runtimeDir: string;
|
|
83
|
-
runtimeFile: string;
|
|
84
|
-
};
|
|
85
|
-
export type HelperLaunchSpec = LegacyRawHelperLaunchSpec | DarwinAppSocketHelperLaunchSpec;
|
|
86
|
-
export declare function helperLaunchSpec(helperPath: string, args: string[], platform?: NodeJS.Platform): HelperLaunchSpec;
|
|
87
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{spawn as g}from"node:child_process";import{randomUUID as O}from"node:crypto";import w from"node:fs";import N from"node:net";import G from"node:os";import d from"node:path";import{createInterface as E}from"node:readline";import{decideWeChatChannelActivityGate as C,normalizeWeChatChannelActivitySnapshot as _}from"./human-coordination.js";import{createWeChatChannelHelperHello as T,extractWeChatChannelHelperWarmupSnapshot as L,timeoutForWeChatChannelHelperCommand as U,validateWeChatChannelHelperReady as R}from"./helper-protocol.js";const I=["en","v"].join(""),m=1500,V=1500,P=8e3,J="SHENNIAN_WECHAT_DANGEROUS_GUARD_THROTTLE_MS";class b extends Error{helperPid;constructor(t,r){super(t),this.helperPid=r,this.name="HelperVersionMismatchError"}}function z(){const e=process.env[J];if(e===void 0||e==="")return P;const t=Number.parseInt(e,10);return!Number.isFinite(t)||t<0?P:t}class Ce{options;child=null;socket=null;lines=null;readyState=null;warmupState=null;stderrTail="";startPromise=null;requestQueueTail=Promise.resolve();lastGuardPassAtMs=0;pending=new Map;constructor(t){this.options=t}async start(){return this.hasTransport()&&this.readyState?this.readyState:this.startPromise?this.startPromise:(this.hasTransport()&&await this.stop(),this.startPromise=this.startFresh().catch(async t=>{throw await this.stop().catch(()=>{}),t}).finally(()=>{this.startPromise=null}),this.startPromise)}async startFresh(){const t=Z(this.options.helperPath,this.options.args??[]);return t.transport==="macos-socket"?this.startDarwinAppSocketFresh(t):this.startStdioFresh(t)}async startStdioFresh(t){const r=g(t.command,t.args,{cwd:this.options.cwd,stdio:["pipe","pipe","pipe"],windowsHide:!0});this.child=r,this.stderrTail="",this.lines=E({input:r.stdout}),this.lines.on("line",s=>this.handleLine(s)),r.stderr.on("data",s=>{this.captureStderr(s)}),r.stdin.on("error",s=>{this.rejectAllPending(s instanceof Error?s:new Error(String(s)))}),r.once("error",s=>{this.child===r&&(this.child=null,this.readyState=null,this.lines?.close(),this.lines=null),this.rejectAllPending(s instanceof Error?s:new Error(String(s)))}),r.once("exit",(s,n)=>{this.child===r&&(this.child=null,this.readyState=null,this.lines?.close(),this.lines=null),this.rejectAllPending(new Error(this.formatHelperExitMessage(s,n)))});const i=new Promise((s,n)=>{const o=setTimeout(()=>n(new Error("WeChat channel helper handshake timed out")),1e4),c=u=>{clearTimeout(o),this.lines?.off("line",l),r.off("exit",a),n(new Error(`WeChat channel helper failed to start: ${u.message}`))},a=(u,h)=>{clearTimeout(o),r.off("error",c),this.lines?.off("line",l),n(new Error(this.formatHelperExitMessage(u,h)))},l=u=>{let h;try{h=JSON.parse(u)}catch{clearTimeout(o),r.off("error",c),this.lines?.off("line",l),n(new Error("WeChat channel helper sent invalid handshake JSON"));return}if(!$(h))return;clearTimeout(o),r.off("error",c),r.off("exit",a),this.lines?.off("line",l);const p=R(h,this.options.expectedHelperVersion,this.options.requiredCapabilities);p.ok?(this.readyState=h,this.captureWarmupSnapshot(h),s(h)):n(new Error(`${p.errorCode}: ${p.errorSummary}`))};r.once("error",c),r.once("exit",a),this.lines?.on("line",l)});try{r.stdin.write(`${JSON.stringify(T(this.options.expectedHelperVersion,this.options.requiredCapabilities))}
|
|
2
|
-
`)}catch(s){throw await this.stop().catch(()=>{}),s}return i}async startDarwinAppSocketFresh(t,r=!0){const i=await this.connectDarwinHelperSocket(t);this.socket=i,this.stderrTail="",this.lines=E({input:i}),this.lines.on("line",n=>this.handleLine(n)),i.on("error",n=>{this.socket===i&&(this.socket=null,this.readyState=null,this.lines?.close(),this.lines=null),this.rejectAllPending(n instanceof Error?n:new Error(String(n)))}),i.once("close",()=>{this.socket===i&&(this.socket=null,this.readyState=null,this.lines?.close(),this.lines=null),this.rejectAllPending(new Error("WeChat channel helper socket closed"))});const s=new Promise((n,o)=>{const c=setTimeout(()=>o(new Error("WeChat channel helper socket handshake timed out")),1e4),a=h=>{clearTimeout(c),this.lines?.off("line",u),i.off("close",l),o(new Error(`WeChat channel helper socket failed: ${h.message}`))},l=()=>{clearTimeout(c),i.off("error",a),this.lines?.off("line",u),o(new Error("WeChat channel helper socket closed before handshake"))},u=h=>{let p;try{p=JSON.parse(h)}catch{clearTimeout(c),i.off("error",a),i.off("close",l),this.lines?.off("line",u),o(new Error("WeChat channel helper sent invalid socket handshake JSON"));return}if(!$(p))return;clearTimeout(c),i.off("error",a),i.off("close",l),this.lines?.off("line",u);const y=R(p,this.options.expectedHelperVersion,this.options.requiredCapabilities);if(y.ok)this.readyState=p,this.captureWarmupSnapshot(p),n(p);else{const k=`${y.errorCode}: ${y.errorSummary}`;o(y.errorCode==="helper_version_mismatch"?new b(k,Number.isInteger(p.pid)?p.pid:null):new Error(k))}};i.once("error",a),i.once("close",l),this.lines?.on("line",u)});try{this.writeFrame(T(this.options.expectedHelperVersion,this.options.requiredCapabilities))}catch(n){throw await this.stop().catch(()=>{}),n}try{return await s}catch(n){if(r&&n instanceof b)return await this.stop().catch(()=>{}),await ie(n.helperPid),w.rmSync(t.runtimeFile,{force:!0}),this.startDarwinAppSocketFresh(t,!1);throw n}}async request(t,r,i){const s=this.requestQueueTail.catch(()=>{}).then(()=>this.sendRequest(t,r,i));return this.requestQueueTail=s.then(()=>{},()=>{}),s}async sendRequest(t,r,i){await this.guardUnsafeWindowsCommand(t,i);try{return await this.sendRawRequest(t,r,i)}finally{await this.cleanupWindowsOverlaysAfterCommand(t,i).catch(()=>{})}}async sendRawRequest(t,r,i){if((!this.hasTransport()||!this.readyState)&&await this.start(),!this.hasTransport())throw new Error("WeChat channel helper is not started");const s=O(),n=U(t),o=Date.now();this.emitRequestTrace({phase:"request",at:new Date(o).toISOString(),id:s,command:t,traceId:i,params:r,timeoutMs:n});const c=new Promise((a,l)=>{const u=setTimeout(()=>{this.pending.get(s)&&(this.pending.delete(s),this.stopAfterCommandTimeout(t).finally(()=>{l(new Error(`helper_command_timeout: ${t}`))}))},n);this.pending.set(s,{resolve:a,reject:l,timer:u})});try{this.writeFrame({id:s,command:t,params:r,traceId:i})}catch(a){const l=this.pending.get(s);throw l&&clearTimeout(l.timer),this.pending.delete(s),this.emitRequestTrace({phase:"error",at:new Date().toISOString(),id:s,command:t,traceId:i,durationMs:Date.now()-o,errorSummary:a instanceof Error?a.message:String(a)}),a}try{const a=await c;return this.emitRequestTrace({phase:"response",at:new Date().toISOString(),id:s,command:t,traceId:i,durationMs:Date.now()-o,ok:a.ok,errorCode:a.errorCode,errorSummary:a.errorSummary,latencyMs:a.latencyMs,result:a.result}),this.captureWarmupSnapshot(a),this.captureWarmupSnapshot(a.result),a}catch(a){throw this.emitRequestTrace({phase:"error",at:new Date().toISOString(),id:s,command:t,traceId:i,durationMs:Date.now()-o,errorSummary:a instanceof Error?a.message:String(a)}),a}}async guardUnsafeWindowsCommand(t,r){if(!this.options.guardUnsafeWindowsCommands||!he(t))return;const i=z(),s=q(t)?Math.max(V,i):i;if(s>0&&this.lastGuardPassAtMs>0&&Date.now()-this.lastGuardPassAtMs<s){if(!q(t)){if(!this.options.skipUserActivityGuard&&F(t)){const c=await this.sendRawRequest("activity.snapshot",{},r);if(!c.ok)throw new Error(`${c.errorCode??"user_activity_unknown"}: ${c.errorSummary??t}`);const a=C({snapshot:_(c.result),stage:"dangerous_action"});if(!a.ok)throw new Error(`user_active:${a.reasonCode}`)}await this.cleanupWindowsOverlays("before",t,r)}return}let n=await this.sendRawRequest("permissions.check",{},r);if(!n.ok)throw new Error(`${n.errorCode??"permissions_check_failed"}: ${n.errorSummary??t}`);let o=n.result??{};if(o.wechatRunning!==!1&&B(o)&&await this.tryRecoverFromStuckShell(r)){if(n=await this.sendRawRequest("permissions.check",{},r),!n.ok)throw new Error(`${n.errorCode??"permissions_check_failed"}: ${n.errorSummary??t}`);o=n.result??{}}if(ce(o.platform)){const c=await this.requestFirstMissingMacPermissionPrompt(o,r);if(c==="screen-recording")throw new Error("permission_screen_recording_missing");if(c==="accessibility")throw new Error("permission_accessibility_missing");if(c==="input-monitoring")throw new Error("permission_input_monitoring_missing");if(o.automation===!1)throw new Error("permission_automation_missing")}if(o.wechatRunning===!1)throw new Error("wechat_not_running");if(K(o))throw new Error("wechat_login_required");if(Q(o))throw new Error("windows_visible_desktop_unavailable");if(o.dpiMappingAvailable===!1||o.displayTopologySupported===!1)throw new Error("dpi_mapping_failed");if(o.wechatWindowAvailable===!1)throw new Error("wechat_window_unavailable");if(o.wechatMainWindowResponsive===!1)throw new Error("wechat_window_unresponsive");if(!this.options.skipUserActivityGuard&&F(t)){const c=await this.sendRawRequest("activity.snapshot",{},r);if(!c.ok)throw new Error(`${c.errorCode??"user_activity_unknown"}: ${c.errorSummary??t}`);const a=C({snapshot:_(c.result),stage:"dangerous_action"});if(!a.ok)throw new Error(`user_active:${a.reasonCode}`)}await this.cleanupWindowsOverlays("before",t,r),this.lastGuardPassAtMs=Date.now()}async tryRecoverFromStuckShell(t){try{const r=await this.sendRawRequest("wechat.healthProbe",{},t);if(!r.ok||r.result?.stuckShell!==!0)return!1;const i=await this.sendRawRequest("windows.recoverWeChat",{allowRestart:!0,onlyIfUnresponsive:!1,waitAfterStartMs:4e3},t);return i.ok===!0&&i.result?.started===!0}catch{return!1}}async requestFirstMissingMacPermissionPrompt(t,r){const i=ae(t);if(!i||process.platform!=="darwin")return i;const s=le(i);try{await this.sendRawRequest(s,{},r)}catch{}return i}async cleanupWindowsOverlaysAfterCommand(t,r){!this.options.guardUnsafeWindowsCommands||!pe(t)||await this.cleanupWindowsOverlays("after",t,r)}async cleanupWindowsOverlays(t,r,i){if(this.options.cleanupWindowsOverlays===!1)return;if(!this.readyState?.capabilities.includes("overlayCleanup"))throw new Error("helper_capability_missing: overlayCleanup");const s=await this.sendRawRequest("windows.cleanupOverlays",{stage:t,command:r,includeGeneratedMediaPreviews:!0,includeToolingTerminals:!1,waitMs:t==="after"?220:120},i);if(!s.ok)throw new Error(`${s.errorCode??"overlay_cleanup_failed"}: ${s.errorSummary??r}`)}async healthCheck(t){return this.request("health.check",{},t)}getReadyState(){return this.readyState?{...this.readyState,capabilities:[...this.readyState.capabilities]}:null}getWarmupState(){return this.warmupState?{warmState:this.warmupState.warmState,metrics:this.warmupState.metrics?{...this.warmupState.metrics}:void 0}:null}async stop(){const t=this.child,r=this.socket;this.child=null,this.socket=null,this.readyState=null,this.lines?.close(),this.lines=null,this.rejectAllPending(new Error("WeChat channel helper stopped")),r&&!r.destroyed&&r.destroy(),t&&await re(t)}hasTransport(){return!!this.child||!!this.socket}writeFrame(t){const r=`${JSON.stringify(t)}
|
|
3
|
-
`;if(this.socket){this.socket.write(r);return}if(this.child){this.child.stdin.write(r);return}throw new Error("WeChat channel helper is not started")}handleLine(t){let r;try{r=JSON.parse(t)}catch{return}if(!ue(r))return;const i=this.pending.get(r.id);i&&(clearTimeout(i.timer),this.pending.delete(r.id),i.resolve(r))}captureWarmupSnapshot(t){const r=L(t);r&&(this.warmupState=r)}captureStderr(t){const r=Buffer.isBuffer(t)?t.toString("utf8"):String(t??"");r&&(this.stderrTail=(this.stderrTail+r).slice(-2e3))}formatHelperExitMessage(t,r){const i=[t===null?null:`code=${t}`,r?`signal=${r}`:null,this.stderrTail.trim()?`stderr=${this.stderrTail.trim()}`:null].filter(Boolean);return i.length?`WeChat channel helper process exited (${i.join(", ")})`:"WeChat channel helper process exited"}rejectAllPending(t){for(const[r,i]of this.pending)clearTimeout(i.timer),i.reject(t),this.pending.delete(r)}emitRequestTrace(t){try{this.options.requestLogger?.(t)}catch{}}async stopAfterCommandTimeout(t){const r=this.child?.pid;if(await this.stop().catch(()=>{}),process.platform==="win32"){const i=typeof r=="number"&&r>0?[r]:[];await j(i).catch(()=>{})}this.emitRequestTrace({phase:"error",at:new Date().toISOString(),id:`timeout-cleanup:${t}`,command:t,errorSummary:"helper process stopped after command timeout"})}async connectDarwinHelperSocket(t){try{return await A(t.runtimeFile)}catch{w.rmSync(t.runtimeFile,{force:!0})}await D(t,{},this.options.openHelperAppForTest);const r=await x(t.runtimeFile,this.options.macosRuntimeInitialReadyTimeoutMs??5e3);if(r.ok)return r.socket;w.rmSync(t.runtimeFile,{force:!0}),await D(t,{forceNewInstance:!0},this.options.openHelperAppForTest);const i=await x(t.runtimeFile,this.options.macosRuntimeRelaunchReadyTimeoutMs??1e4);if(i.ok)return i.socket;throw new Error(`WeChat channel Helper.app socket did not become ready: ${i.error.message}`)}}async function j(e=[]){if(process.platform!=="win32")return;const t=e.filter(r=>Number.isInteger(r)&&r>0);if(t.length!==0)for(const r of t)await M(["taskkill","/PID",String(r),"/T","/F"],[0,128])}function B(e){return e.wechatWindowAvailable===!1&&(e.captureCandidateCount??0)===0&&(e.restoreCandidateCount??0)===0&&(e.hiddenRestoreCandidateCount??0)===0}function K(e){return e.wechatWindowAvailable!==!1?!1:![...e.captureCandidates??[],...e.restoreCandidates??[],...e.hiddenRestoreCandidates??[]].some(X)}function Q(e){return e.windowsVisibleDesktopAvailable===!1||e.rdpVisibleDesktopAvailable===!1||e.desktopSessionVisible===!1||e.screenLocked===!0||e.rdpDisconnected===!0}function Y(e){const t=String(e.appName||"").toLowerCase();return t==="wechat"||t==="weixin"}function X(e){return!(!Y(e)||e.visible===!1||e.minimized===!0)}function Z(e,t,r=process.platform){if(r==="darwin"){const i=ee(e);if(i&&t.length===0){const s=te();return{transport:"macos-socket",command:"/usr/bin/open",args:["-g",i,"--args","--socket-runtime",s],appPath:i,runtimeDir:s,runtimeFile:d.join(s,"runtime.json")}}}return{transport:"legacy-stdio",command:e,args:t}}function ee(e){const t=d.resolve(e),r=`${d.sep}Contents${d.sep}MacOS${d.sep}`,i=t.lastIndexOf(r);if(i<0)return null;const s=t.slice(0,i);return s.endsWith(".app")?s:null}function te(){const e=se().SHENNIAN_HELPER_RUNTIME_DIR?.trim();return e?d.resolve(e):d.join(G.homedir(),"Library","Application Support","Shennian","Helper")}async function re(e){if(W(e))return;if(process.platform==="win32"&&e.pid){e.kill("SIGTERM"),await M(["taskkill","/PID",String(e.pid),"/T","/F"],[0,128]).catch(()=>{}),await S(e,m);return}e.kill("SIGTERM"),!await S(e,m)&&e.pid&&f(e.pid)&&(e.kill("SIGKILL"),await S(e,m))}async function ie(e){if(process.platform!=="darwin"||!e||e===process.pid||!f(e))return;try{process.kill(e,"SIGTERM")}catch{return}if(!await v(e,m)&&f(e)){try{process.kill(e,"SIGKILL")}catch{return}await v(e,m)}}async function v(e,t){const r=Date.now()+t;for(;Date.now()<r;){if(!f(e))return!0;await H(Math.min(50,r-Date.now()))}return!f(e)}function W(e){return e.exitCode!==null||e.signalCode!==null}function S(e,t){return W(e)?Promise.resolve(!0):new Promise(r=>{const i=setTimeout(()=>{e.off("exit",s),r(!1)},t),s=()=>{clearTimeout(i),r(!0)};e.once("exit",s)})}function M(e,t){return new Promise((r,i)=>{const[s,...n]=e,o=g(s,n,{stdio:"ignore",windowsHide:!0});o.once("error",i),o.once("exit",c=>{c!==null&&t.includes(c)?r():i(new Error(`${s} exited ${c}`))})})}function se(){return globalThis.process?.[I]??{}}function ne(e){let t;try{t=JSON.parse(w.readFileSync(e,"utf8"))}catch(s){throw new Error(`runtime_file_unreadable: ${s instanceof Error?s.message:String(s)}`)}if(!t||typeof t!="object")throw new Error("runtime_file_invalid");const r=t.socketPath;if(typeof r!="string"||!r.trim())throw new Error("runtime_socket_missing");const i=t.pid;return{socketPath:r,...typeof i=="number"&&Number.isInteger(i)&&i>0?{pid:i}:{}}}async function A(e){const{socketPath:t,pid:r}=ne(e);if(r&&!f(r))throw new Error(`runtime_process_stale: ${r}`);return new Promise((i,s)=>{const n=N.createConnection(t),o=setTimeout(()=>{n.destroy(),s(new Error(`runtime_socket_connect_timeout: ${t}`))},1e3);n.once("connect",()=>{clearTimeout(o),n.off("error",c),i(n)});const c=a=>{clearTimeout(o),n.destroy(),s(a)};n.once("error",c)})}async function x(e,t){const r=Date.now()+t;let i=null;for(;Date.now()<r;)try{return{ok:!0,socket:await A(e)}}catch(s){i=s instanceof Error?s:new Error(String(s));const n=r-Date.now();n>0&&await H(Math.min(150,n))}return{ok:!1,error:i??new Error("runtime file missing")}}async function D(e,t={},r=oe){w.mkdirSync(e.runtimeDir,{recursive:!0,mode:448});const i=t.forceNewInstance?["-n",...e.args]:e.args;try{await r(e.command,i)}catch(s){if(!(s instanceof Error?s.message:String(s)).includes("-1712"))throw s;await r(e.command,["-n",...e.args])}}function f(e){try{return process.kill(e,0),!0}catch{return!1}}async function oe(e,t){await new Promise((r,i)=>{const s=g(e,t,{stdio:["ignore","ignore","pipe"],windowsHide:!0});let n="";s.stderr.on("data",o=>{n=(n+String(o)).slice(-2e3)}),s.once("error",i),s.once("exit",(o,c)=>{o===0?r():i(new Error(`open Helper.app failed (${c?`signal=${c}`:`code=${o}`}${n.trim()?`, stderr=${n.trim()}`:""})`))})})}function H(e){return new Promise(t=>setTimeout(t,e))}function ae(e){return e.screenRecording===!1?"screen-recording":e.accessibility===!1?"accessibility":e.inputMonitoring===!1?"input-monitoring":null}function ce(e){const t=String(e||"").toLowerCase();return t?t.includes("darwin")||t.includes("mac"):!0}function le(e){return e==="screen-recording"?"permissions.requestScreenRecording":e==="accessibility"?"permissions.requestAccessibility":"permissions.requestInputMonitoring"}function $(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="ready"&&typeof t.helperVersion=="string"&&typeof t.protocolVersion=="number"&&Array.isArray(t.capabilities)&&typeof t.pid=="number"}function ue(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.ok=="boolean"&&typeof t.latencyMs=="number"}function he(e){return e==="windows.focus"||e==="windows.capture"||e==="screen.capture"||e==="ocr.recognize"||e==="image.cropHash"||e==="wechat.searchConversation"||e==="wechat.focusMessageInput"||e==="wechat.pasteAndSubmit"||e==="keyboard.primeTextPaste"||e.startsWith("mouse.")||e.startsWith("keyboard.")||e.startsWith("clipboard.")||e==="menu.pickItem"||e==="savePanel.saveToPath"}function q(e){return e==="windows.capture"||e==="screen.capture"||e==="ocr.recognize"||e==="image.cropHash"}function pe(e){return e.startsWith("mouse.")||e.startsWith("keyboard.")||e.startsWith("clipboard.")||e==="menu.pickItem"||e==="savePanel.saveToPath"}function F(e){return e==="windows.focus"||e==="wechat.searchConversation"||e==="wechat.focusMessageInput"||e==="wechat.pasteAndSubmit"||e==="keyboard.primeTextPaste"||e.startsWith("mouse.")||e.startsWith("keyboard.")||e.startsWith("clipboard.set")||e==="clipboard.restore"||e==="menu.pickItem"||e==="savePanel.saveToPath"}export{Ce as WeChatChannelHelperClient,Z as helperLaunchSpec,j as stopWindowsWeChatChannelHelperProcesses};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
export declare const WECHAT_CHANNEL_HELPER_PROTOCOL_VERSION = 1;
|
|
2
|
-
export declare const WECHAT_CHANNEL_HELPER_COMMAND_TIMEOUT_MS: {
|
|
3
|
-
readonly healthCheck: 2000;
|
|
4
|
-
readonly permissionsCheck: 10000;
|
|
5
|
-
readonly activitySnapshot: 1000;
|
|
6
|
-
readonly automationLease: 6000;
|
|
7
|
-
readonly windowList: 10000;
|
|
8
|
-
readonly windowsEnsureReady: 20000;
|
|
9
|
-
readonly ocrRecognize: 10000;
|
|
10
|
-
readonly windowsCapture: 5000;
|
|
11
|
-
readonly mouseKeyboard: 3000;
|
|
12
|
-
readonly clipboard: 5000;
|
|
13
|
-
readonly menuPickItem: 5000;
|
|
14
|
-
readonly savePanel: 10000;
|
|
15
|
-
readonly wechatSearch: 6000;
|
|
16
|
-
readonly wechatInteraction: 15000;
|
|
17
|
-
};
|
|
18
|
-
export type WeChatChannelHelperCapability = 'screenCapture' | 'visionOcr' | 'windowList' | 'windowFocus' | 'mouseKeyboard' | 'clipboard' | 'contextMenu' | 'imageCropHash' | 'wechatSearch' | 'humanActivity' | 'automationLease' | 'overlayCleanup' | 'wechatRecovery';
|
|
19
|
-
export type WeChatChannelHelperCapabilityProfile = 'observe' | 'download' | 'send';
|
|
20
|
-
export declare const WECHAT_CHANNEL_OBSERVE_HELPER_CAPABILITIES: WeChatChannelHelperCapability[];
|
|
21
|
-
export declare const WECHAT_CHANNEL_DOWNLOAD_HELPER_CAPABILITIES: WeChatChannelHelperCapability[];
|
|
22
|
-
export declare const WECHAT_CHANNEL_SEND_HELPER_CAPABILITIES: WeChatChannelHelperCapability[];
|
|
23
|
-
export declare const WECHAT_CHANNEL_REQUIRED_HELPER_CAPABILITIES: WeChatChannelHelperCapability[];
|
|
24
|
-
export declare const WECHAT_CHANNEL_WINDOWS_OBSERVE_HELPER_CAPABILITIES: WeChatChannelHelperCapability[];
|
|
25
|
-
export declare const WECHAT_CHANNEL_WINDOWS_DOWNLOAD_HELPER_CAPABILITIES: WeChatChannelHelperCapability[];
|
|
26
|
-
export declare const WECHAT_CHANNEL_WINDOWS_SEND_HELPER_CAPABILITIES: WeChatChannelHelperCapability[];
|
|
27
|
-
export declare function requiredWeChatChannelHelperCapabilitiesForProfile(profile: WeChatChannelHelperCapabilityProfile): WeChatChannelHelperCapability[];
|
|
28
|
-
export declare function requiredWindowsWeChatChannelHelperCapabilitiesForProfile(profile: WeChatChannelHelperCapabilityProfile): WeChatChannelHelperCapability[];
|
|
29
|
-
export type WeChatChannelHelperWarmState = 'cold' | 'warming' | 'warm' | 'failed';
|
|
30
|
-
export type WeChatChannelHelperWarmupMetrics = {
|
|
31
|
-
startedAt?: string;
|
|
32
|
-
readyAt?: string;
|
|
33
|
-
warmupStartedAt?: string;
|
|
34
|
-
warmupCompletedAt?: string;
|
|
35
|
-
coldStartMs?: number;
|
|
36
|
-
warmupMs?: number;
|
|
37
|
-
firstOcrMs?: number;
|
|
38
|
-
warmOcrMs?: number;
|
|
39
|
-
lastOcrMs?: number;
|
|
40
|
-
ocrSampleCount?: number;
|
|
41
|
-
errorCode?: string;
|
|
42
|
-
errorSummary?: string;
|
|
43
|
-
};
|
|
44
|
-
export type WeChatChannelHelperWarmupSnapshot = {
|
|
45
|
-
warmState: WeChatChannelHelperWarmState;
|
|
46
|
-
metrics?: WeChatChannelHelperWarmupMetrics;
|
|
47
|
-
};
|
|
48
|
-
export type WeChatChannelHelperHello = {
|
|
49
|
-
type: 'hello';
|
|
50
|
-
protocolVersion: number;
|
|
51
|
-
expectedHelperVersion: string;
|
|
52
|
-
capabilities: WeChatChannelHelperCapability[];
|
|
53
|
-
};
|
|
54
|
-
export type WeChatChannelHelperReady = {
|
|
55
|
-
type: 'ready';
|
|
56
|
-
helperVersion: string;
|
|
57
|
-
protocolVersion: number;
|
|
58
|
-
capabilities: WeChatChannelHelperCapability[];
|
|
59
|
-
pid: number;
|
|
60
|
-
warmState?: WeChatChannelHelperWarmState;
|
|
61
|
-
warmup?: WeChatChannelHelperWarmupMetrics;
|
|
62
|
-
};
|
|
63
|
-
export type WeChatChannelHelperHealthResult = {
|
|
64
|
-
ok?: boolean;
|
|
65
|
-
helperVersion?: string;
|
|
66
|
-
protocolVersion?: number;
|
|
67
|
-
capabilities?: WeChatChannelHelperCapability[];
|
|
68
|
-
pid?: number;
|
|
69
|
-
uptimeMs?: number;
|
|
70
|
-
warmState?: WeChatChannelHelperWarmState;
|
|
71
|
-
warmup?: WeChatChannelHelperWarmupMetrics;
|
|
72
|
-
};
|
|
73
|
-
export type WeChatChannelHumanActivityReasonCode = 'recent_mouse_activity' | 'recent_mouse_click' | 'recent_scroll_activity' | 'recent_keyboard_activity' | 'frontmost_app_changed' | 'user_activity_unknown';
|
|
74
|
-
export type WeChatChannelHumanActivitySnapshot = {
|
|
75
|
-
mouseMovedSecondsAgo?: number;
|
|
76
|
-
leftMouseDownSecondsAgo?: number;
|
|
77
|
-
rightMouseDownSecondsAgo?: number;
|
|
78
|
-
scrollWheelSecondsAgo?: number;
|
|
79
|
-
keyDownSecondsAgo?: number;
|
|
80
|
-
frontmostApp?: {
|
|
81
|
-
bundleId?: string;
|
|
82
|
-
localizedName?: string;
|
|
83
|
-
} | null;
|
|
84
|
-
permissions?: {
|
|
85
|
-
accessibilityTrusted?: boolean;
|
|
86
|
-
iohidListenGranted?: boolean;
|
|
87
|
-
iohidPostGranted?: boolean;
|
|
88
|
-
};
|
|
89
|
-
privacy?: {
|
|
90
|
-
capturesKeyContent?: boolean;
|
|
91
|
-
capturesMousePath?: boolean;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
export type WeChatChannelHelperCommandName = 'health.check' | 'processes.list' | 'permissions.check' | 'permissions.requestScreenRecording' | 'permissions.requestAccessibility' | 'permissions.requestInputMonitoring' | 'activity.snapshot' | 'automation.lease.acquire' | 'automation.lease.release' | 'automation.lease.status' | 'automation.lease.simulateInterruption' | 'windows.ensureReady' | 'windows.list' | 'windows.enumerateRaw' | 'windows.focus' | 'windows.closeWindow' | 'windows.capture' | 'windows.captureAndOcr' | 'windows.cleanupOverlays' | 'windows.recoverWeChat' | 'screen.capture' | 'ocr.recognize' | 'mouse.click' | 'mouse.rightClick' | 'mouse.scroll' | 'keyboard.type' | 'keyboard.shortcut' | 'keyboard.primeTextPaste' | 'clipboard.snapshot' | 'clipboard.restore' | 'clipboard.setText' | 'clipboard.setFiles' | 'clipboard.setImage' | 'clipboard.readFileUrls' | 'clipboard.readAttachment' | 'menu.pickItem' | 'savePanel.saveToPath' | 'image.cropHash' | 'wechat.searchConversation' | 'wechat.focusMessageInput' | 'wechat.pasteAndSubmit' | 'wechat.healthProbe';
|
|
95
|
-
export type WeChatChannelHelperCommand = {
|
|
96
|
-
id: string;
|
|
97
|
-
command: WeChatChannelHelperCommandName;
|
|
98
|
-
params?: Record<string, unknown>;
|
|
99
|
-
traceId?: string;
|
|
100
|
-
};
|
|
101
|
-
export type WeChatChannelHelperResponse<T = unknown> = {
|
|
102
|
-
id: string;
|
|
103
|
-
ok: boolean;
|
|
104
|
-
result?: T;
|
|
105
|
-
errorCode?: string;
|
|
106
|
-
errorSummary?: string;
|
|
107
|
-
latencyMs: number;
|
|
108
|
-
traceId?: string;
|
|
109
|
-
warmState?: WeChatChannelHelperWarmState;
|
|
110
|
-
warmup?: WeChatChannelHelperWarmupMetrics;
|
|
111
|
-
};
|
|
112
|
-
export type WeChatChannelHelperErrorCode = 'helper_protocol_mismatch' | 'helper_version_mismatch' | 'helper_capability_missing' | 'helper_command_timeout' | 'helper_process_exited' | 'helper_invalid_response' | 'permission_screen_recording_missing' | 'permission_accessibility_missing' | 'permission_automation_missing' | 'automation_event_tap_unavailable' | 'wechat_not_running' | 'wechat_window_unavailable' | 'wechat_window_not_found' | 'wechat_window_minimized' | 'wechat_window_unresponsive' | 'wechat_recovery_failed' | 'wechat_login_required' | 'wechat_duplicate_instance' | 'wechat_single_main_window_required' | 'windows_visible_desktop_unavailable' | 'capture_failed' | 'screenshot_blank' | 'ocr_failed' | 'title_not_confirmed' | 'user_active' | 'user_takeover' | 'clipboard_unavailable' | 'clipboard_restore_failed' | 'menu_item_not_found' | 'attachment_unavailable' | 'dpi_mapping_failed' | 'platform_unsupported' | 'platform_runtime_degraded' | 'overlay_cleanup_failed';
|
|
113
|
-
export declare function createWeChatChannelHelperHello(expectedHelperVersion: string, capabilities?: WeChatChannelHelperCapability[]): WeChatChannelHelperHello;
|
|
114
|
-
export declare function validateWeChatChannelHelperReady(ready: WeChatChannelHelperReady, expectedHelperVersion: string, requiredCapabilities?: WeChatChannelHelperCapability[]): {
|
|
115
|
-
ok: true;
|
|
116
|
-
} | {
|
|
117
|
-
ok: false;
|
|
118
|
-
errorCode: WeChatChannelHelperErrorCode;
|
|
119
|
-
errorSummary: string;
|
|
120
|
-
};
|
|
121
|
-
export declare function extractWeChatChannelHelperWarmupSnapshot(value: unknown): WeChatChannelHelperWarmupSnapshot | null;
|
|
122
|
-
export declare function timeoutForWeChatChannelHelperCommand(command: WeChatChannelHelperCommandName): number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const f=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,wechatInteraction:15e3},a=["screenCapture","visionOcr","windowList","windowFocus","mouseKeyboard","clipboard","imageCropHash","wechatSearch","humanActivity"],u=[...a,"contextMenu"],c=[...u,"automationLease"],p=c,l=[...a,"overlayCleanup","wechatRecovery"],h=[...l,"contextMenu"],_=[...h,"automationLease"];function H(e){return e==="observe"?[...a]:e==="download"?[...u]:[...c]}function A(e){return e==="observe"?[...l]:e==="download"?[...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 S(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 n=r.filter(C=>!e.capabilities.includes(C));return n.length?{ok:!1,errorCode:"helper_capability_missing",errorSummary:`Helper missing capabilities: ${n.join(", ")}`}:{ok:!0}}function d(e){if(!e||typeof e!="object")return null;const t=e;if(!E(t.warmState))return null;const r=w(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"||e==="permissions.requestInputMonitoring"?i.permissionsCheck:e==="activity.snapshot"?i.activitySnapshot:e.startsWith("automation.lease.")?i.automationLease:e==="windows.list"||e==="windows.enumerateRaw"||e==="wechat.healthProbe"?i.windowList:e==="windows.ensureReady"||e==="windows.cleanupOverlays"||e==="windows.recoverWeChat"||e==="windows.closeWindow"?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==="wechat.pasteAndSubmit"||e==="wechat.focusMessageInput"||e==="wechat.searchConversation"?i.wechatInteraction:e.startsWith("wechat.")?i.wechatSearch:i.healthCheck}function E(e){return e==="cold"||e==="warming"||e==="warm"||e==="failed"}function w(e){if(!e||typeof e!="object")return;const t=e,r={};return o(t,r,"startedAt"),o(t,r,"readyAt"),o(t,r,"warmupStartedAt"),o(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"),o(t,r,"errorCode"),o(t,r,"errorSummary"),Object.keys(r).length>0?r:void 0}function o(e,t,r){typeof e[r]=="string"&&(t[r]=e[r])}function s(e,t,r){const n=e[r];typeof n=="number"&&Number.isFinite(n)&&n>=0&&(t[r]=n)}export{u as WECHAT_CHANNEL_DOWNLOAD_HELPER_CAPABILITIES,i as WECHAT_CHANNEL_HELPER_COMMAND_TIMEOUT_MS,f 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,h as WECHAT_CHANNEL_WINDOWS_DOWNLOAD_HELPER_CAPABILITIES,l as WECHAT_CHANNEL_WINDOWS_OBSERVE_HELPER_CAPABILITIES,_ as WECHAT_CHANNEL_WINDOWS_SEND_HELPER_CAPABILITIES,L as createWeChatChannelHelperHello,d as extractWeChatChannelHelperWarmupSnapshot,H as requiredWeChatChannelHelperCapabilitiesForProfile,A as requiredWindowsWeChatChannelHelperCapabilitiesForProfile,W as timeoutForWeChatChannelHelperCommand,S as validateWeChatChannelHelperReady};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { WeChatChannelHumanActivityReasonCode, WeChatChannelHumanActivitySnapshot } from './helper-protocol.js';
|
|
2
|
-
export type WeChatChannelActivityGateStage = 'observe' | 'send_start' | 'download' | 'open_conversation' | 'dangerous_action';
|
|
3
|
-
export type WeChatChannelActivityGatePolicy = {
|
|
4
|
-
mouseMovedThresholdMs: number;
|
|
5
|
-
mouseClickThresholdMs: number;
|
|
6
|
-
scrollWheelThresholdMs: number;
|
|
7
|
-
keyDownThresholdMs: number;
|
|
8
|
-
};
|
|
9
|
-
export type WeChatChannelActivityGateDecision = {
|
|
10
|
-
ok: true;
|
|
11
|
-
stage: WeChatChannelActivityGateStage;
|
|
12
|
-
} | {
|
|
13
|
-
ok: false;
|
|
14
|
-
stage: WeChatChannelActivityGateStage;
|
|
15
|
-
reasonCode: WeChatChannelHumanActivityReasonCode;
|
|
16
|
-
waitMs: number;
|
|
17
|
-
};
|
|
18
|
-
export declare const DEFAULT_WECHAT_CHANNEL_ACTIVITY_GATE_POLICY: WeChatChannelActivityGatePolicy;
|
|
19
|
-
export declare function decideWeChatChannelActivityGate(input: {
|
|
20
|
-
snapshot: WeChatChannelHumanActivitySnapshot | null | undefined;
|
|
21
|
-
stage: WeChatChannelActivityGateStage;
|
|
22
|
-
policy?: Partial<WeChatChannelActivityGatePolicy>;
|
|
23
|
-
}): WeChatChannelActivityGateDecision;
|
|
24
|
-
export declare function normalizeWeChatChannelActivitySnapshot(value: unknown): WeChatChannelHumanActivitySnapshot | null;
|
|
25
|
-
export declare function nextWeChatChannelActivityRetryAt(now: Date, waitMs: number): Date;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const u={mouseMovedThresholdMs:2e3,mouseClickThresholdMs:3e3,scrollWheelThresholdMs:3e3,keyDownThresholdMs:5e3};function p(e){const o=e.snapshot;if(!o)return{ok:!0,stage:e.stage};const s={...u,...e.policy},t=[{reasonCode:"recent_keyboard_activity",secondsAgo:o.keyDownSecondsAgo,thresholdMs:s.keyDownThresholdMs},{reasonCode:"recent_mouse_click",secondsAgo:Math.min(l(o.leftMouseDownSecondsAgo),l(o.rightMouseDownSecondsAgo)),thresholdMs:s.mouseClickThresholdMs},{reasonCode:"recent_scroll_activity",secondsAgo:o.scrollWheelSecondsAgo,thresholdMs:s.scrollWheelThresholdMs},{reasonCode:"recent_mouse_activity",secondsAgo:o.mouseMovedSecondsAgo,thresholdMs:s.mouseMovedThresholdMs}];let n=null;for(const c of t){const d=f(c.secondsAgo);if(d==null||d>=c.thresholdMs)continue;const a=Math.ceil(c.thresholdMs-d);(!n||a>n.waitMs)&&(n={reasonCode:c.reasonCode,waitMs:a})}return n?{ok:!1,stage:e.stage,reasonCode:n.reasonCode,waitMs:n.waitMs}:{ok:!0,stage:e.stage}}function y(e){if(!e||typeof e!="object")return null;const o=e,s={};if(r(o,s,"mouseMovedSecondsAgo"),r(o,s,"leftMouseDownSecondsAgo"),r(o,s,"rightMouseDownSecondsAgo"),r(o,s,"scrollWheelSecondsAgo"),r(o,s,"keyDownSecondsAgo"),o.frontmostApp&&typeof o.frontmostApp=="object"){const t=o.frontmostApp;s.frontmostApp={bundleId:h(t.bundleId),localizedName:h(t.localizedName)}}if(o.permissions&&typeof o.permissions=="object"){const t=o.permissions;s.permissions={accessibilityTrusted:i(t.accessibilityTrusted),iohidListenGranted:i(t.iohidListenGranted),iohidPostGranted:i(t.iohidPostGranted)}}if(o.privacy&&typeof o.privacy=="object"){const t=o.privacy;s.privacy={capturesKeyContent:i(t.capturesKeyContent),capturesMousePath:i(t.capturesMousePath)}}return Object.keys(s).length>0?s:null}function M(e,o){const s=Math.max(1e3,Math.ceil(o/1e3)*1e3);return new Date(e.getTime()+s)}function f(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e*1e3}function l(e){return typeof e=="number"&&Number.isFinite(e)?e:Number.POSITIVE_INFINITY}function r(e,o,s){const t=e[s];typeof t=="number"&&Number.isFinite(t)&&t>=0&&(o[s]=t)}function h(e){return typeof e=="string"&&e.trim()?e:void 0}function i(e){return typeof e=="boolean"?e:void 0}export{u as DEFAULT_WECHAT_CHANNEL_ACTIVITY_GATE_POLICY,p as decideWeChatChannelActivityGate,M as nextWeChatChannelActivityRetryAt,y as normalizeWeChatChannelActivitySnapshot};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export * from './runtime.js';
|
|
2
|
-
export * from './helper-protocol.js';
|
|
3
|
-
export * from './helper-client.js';
|
|
4
|
-
export * from './helper-assets.js';
|
|
5
|
-
export * from './client.js';
|
|
6
|
-
export * from './ledger.js';
|
|
7
|
-
export * from './scheduler.js';
|
|
8
|
-
export * from './fingerprint.js';
|
|
9
|
-
export * from './observer.js';
|
|
10
|
-
export * from './anchor.js';
|
|
11
|
-
export * from './outbound-ledger.js';
|
|
12
|
-
export * from './outbound-sender.js';
|
|
13
|
-
export * from './media-resolver.js';
|
|
14
|
-
export * from './preflight.js';
|
|
15
|
-
export * from './cooldown.js';
|
|
16
|
-
export * from './message-key.js';
|
|
17
|
-
export * from './runner.js';
|
|
18
|
-
export * from './core/schema.js';
|
|
19
|
-
export * from './core/media-action-plan.js';
|
|
20
|
-
export * from './core/trace-comparator.js';
|
|
21
|
-
export * from './core/fixture-compare.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"./runtime.js";export*from"./helper-protocol.js";export*from"./helper-client.js";export*from"./helper-assets.js";export*from"./client.js";export*from"./ledger.js";export*from"./scheduler.js";export*from"./fingerprint.js";export*from"./observer.js";export*from"./anchor.js";export*from"./outbound-ledger.js";export*from"./outbound-sender.js";export*from"./media-resolver.js";export*from"./preflight.js";export*from"./cooldown.js";export*from"./message-key.js";export*from"./runner.js";export*from"./core/schema.js";export*from"./core/media-action-plan.js";export*from"./core/trace-comparator.js";export*from"./core/fixture-compare.js";
|