shennian 0.3.1 → 0.3.3

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.
Files changed (296) hide show
  1. package/README.md +3 -1
  2. package/dist/publish-build-manifest.json +291 -341
  3. package/dist/src/agents/codex.js +1 -1
  4. package/dist/src/agents/command-spec.js +2 -2
  5. package/dist/src/agents/detect.js +1 -1
  6. package/dist/src/agents/model-registry/discovery.js +2 -2
  7. package/dist/src/agents/model-registry/parsers.d.ts +1 -0
  8. package/dist/src/agents/model-registry/parsers.js +4 -4
  9. package/dist/src/agents/model-registry/service.js +1 -1
  10. package/dist/src/agents/native-capabilities.d.ts +10 -0
  11. package/dist/src/agents/native-capabilities.js +1 -0
  12. package/dist/src/agents/platform-instructions.js +5 -5
  13. package/dist/src/agents/runtime-compatibility.d.ts +11 -0
  14. package/dist/src/agents/runtime-compatibility.js +1 -0
  15. package/dist/src/agents/workbuddy.d.ts +44 -0
  16. package/dist/src/agents/workbuddy.js +3 -0
  17. package/dist/src/commands/daemon.d.ts +1 -0
  18. package/dist/src/commands/daemon.js +9 -9
  19. package/dist/src/commands/integration.d.ts +2 -0
  20. package/dist/src/commands/integration.js +1 -0
  21. package/dist/src/commands/manager.js +1 -2
  22. package/dist/src/commands/pair-browser.d.ts +43 -0
  23. package/dist/src/commands/pair-browser.js +1 -0
  24. package/dist/src/commands/pair.d.ts +2 -0
  25. package/dist/src/commands/pair.js +11 -8
  26. package/dist/src/commands/room.d.ts +13 -0
  27. package/dist/src/commands/room.js +4 -0
  28. package/dist/src/commands/upgrade.d.ts +3 -0
  29. package/dist/src/commands/upgrade.js +1 -1
  30. package/dist/src/config/index.d.ts +3 -1
  31. package/dist/src/config/index.js +2 -1
  32. package/dist/src/daemon-ipc/client.d.ts +8 -0
  33. package/dist/src/daemon-ipc/client.js +3 -0
  34. package/dist/src/daemon-ipc/paths.d.ts +7 -0
  35. package/dist/src/daemon-ipc/paths.js +1 -0
  36. package/dist/src/daemon-ipc/protocol.d.ts +30 -0
  37. package/dist/src/daemon-ipc/protocol.js +1 -0
  38. package/dist/src/daemon-ipc/secret.d.ts +3 -0
  39. package/dist/src/daemon-ipc/secret.js +3 -0
  40. package/dist/src/daemon-ipc/server.d.ts +13 -0
  41. package/dist/src/daemon-ipc/server.js +3 -0
  42. package/dist/src/index.js +2 -2
  43. package/dist/src/integrations/claude-room-plugin-lifecycle.d.ts +47 -0
  44. package/dist/src/integrations/claude-room-plugin-lifecycle.js +1 -0
  45. package/dist/src/integrations/codex-room-plugin-lifecycle.d.ts +49 -0
  46. package/dist/src/integrations/codex-room-plugin-lifecycle.js +1 -0
  47. package/dist/src/integrations/room-plugin-bundles.d.ts +23 -0
  48. package/dist/src/integrations/room-plugin-bundles.js +1 -0
  49. package/dist/src/integrations/room-plugin-lifecycle-common.d.ts +17 -0
  50. package/dist/src/integrations/room-plugin-lifecycle-common.js +1 -0
  51. package/dist/src/integrations/room-plugin-shared.d.ts +24 -0
  52. package/dist/src/integrations/room-plugin-shared.js +2 -0
  53. package/dist/src/integrations/room-session-hook.d.ts +30 -0
  54. package/dist/src/integrations/room-session-hook.js +2 -0
  55. package/dist/src/integrations/workbuddy-plugin-bundle.d.ts +15 -0
  56. package/dist/src/integrations/workbuddy-plugin-bundle.js +1 -0
  57. package/dist/src/integrations/workbuddy-plugin-lifecycle.d.ts +52 -0
  58. package/dist/src/integrations/workbuddy-plugin-lifecycle.js +2 -0
  59. package/dist/src/integrations/workbuddy-session-hook.d.ts +22 -0
  60. package/dist/src/integrations/workbuddy-session-hook.js +1 -0
  61. package/dist/src/manager/prompt.d.ts +1 -1
  62. package/dist/src/manager/prompt.js +1 -1
  63. package/dist/src/manager/retired-external-channel-compat.d.ts +78 -0
  64. package/dist/src/manager/retired-external-channel-compat.js +1 -0
  65. package/dist/src/manager/runtime.d.ts +1 -3
  66. package/dist/src/manager/runtime.js +7 -7
  67. package/dist/src/relay/client.d.ts +2 -0
  68. package/dist/src/relay/client.js +1 -1
  69. package/dist/src/room/activation-audit.d.ts +15 -0
  70. package/dist/src/room/activation-audit.js +2 -0
  71. package/dist/src/room/activation-policy.d.ts +8 -0
  72. package/dist/src/room/activation-policy.js +1 -0
  73. package/dist/src/room/activation-service.d.ts +25 -0
  74. package/dist/src/room/activation-service.js +2 -0
  75. package/dist/src/room/agent-tool.d.ts +62 -0
  76. package/dist/src/room/agent-tool.js +1 -0
  77. package/dist/src/room/attachment-cache.d.ts +40 -0
  78. package/dist/src/room/attachment-cache.js +2 -0
  79. package/dist/src/room/attachment-upload.d.ts +20 -0
  80. package/dist/src/room/attachment-upload.js +1 -0
  81. package/dist/src/room/authorized-action-coordinator.d.ts +40 -0
  82. package/dist/src/room/authorized-action-coordinator.js +1 -0
  83. package/dist/src/room/authorized-action-ipc.d.ts +11 -0
  84. package/dist/src/room/authorized-action-ipc.js +1 -0
  85. package/dist/src/room/device-authorization-client.d.ts +49 -0
  86. package/dist/src/room/device-authorization-client.js +1 -0
  87. package/dist/src/room/host-session-observation-ipc.d.ts +9 -0
  88. package/dist/src/room/host-session-observation-ipc.js +1 -0
  89. package/dist/src/room/host-session-observations.d.ts +54 -0
  90. package/dist/src/room/host-session-observations.js +2 -0
  91. package/dist/src/room/invite-bootstrap.d.ts +35 -0
  92. package/dist/src/room/invite-bootstrap.js +1 -0
  93. package/dist/src/room/invocation-token-ipc.d.ts +9 -0
  94. package/dist/src/room/invocation-token-ipc.js +1 -0
  95. package/dist/src/room/invocation-token.d.ts +53 -0
  96. package/dist/src/room/invocation-token.js +1 -0
  97. package/dist/src/room/jsonl-mirror.d.ts +73 -0
  98. package/dist/src/room/jsonl-mirror.js +6 -0
  99. package/dist/src/room/managed-room-binding.d.ts +42 -0
  100. package/dist/src/room/managed-room-binding.js +1 -0
  101. package/dist/src/room/managed-room-session.d.ts +143 -0
  102. package/dist/src/room/managed-room-session.js +3 -0
  103. package/dist/src/room/mirror-sync-service.d.ts +33 -0
  104. package/dist/src/room/mirror-sync-service.js +1 -0
  105. package/dist/src/room/operator-ipc.d.ts +11 -0
  106. package/dist/src/room/operator-ipc.js +1 -0
  107. package/dist/src/room/pending-authorized-actions.d.ts +69 -0
  108. package/dist/src/room/pending-authorized-actions.js +3 -0
  109. package/dist/src/room/room-action-client.d.ts +210 -0
  110. package/dist/src/room/room-action-client.js +1 -0
  111. package/dist/src/room/room-action-ipc.d.ts +33 -0
  112. package/dist/src/room/room-action-ipc.js +1 -0
  113. package/dist/src/room/room-action-schema.d.ts +3 -0
  114. package/dist/src/room/room-action-schema.js +1 -0
  115. package/dist/src/room/room-authorized-action-executor.d.ts +23 -0
  116. package/dist/src/room/room-authorized-action-executor.js +1 -0
  117. package/dist/src/room/room-binding-client.d.ts +51 -0
  118. package/dist/src/room/room-binding-client.js +1 -0
  119. package/dist/src/room/room-binding-ipc.d.ts +29 -0
  120. package/dist/src/room/room-binding-ipc.js +1 -0
  121. package/dist/src/room/session-registry-ipc.d.ts +14 -0
  122. package/dist/src/room/session-registry-ipc.js +1 -0
  123. package/dist/src/room/session-registry.d.ts +128 -0
  124. package/dist/src/room/session-registry.js +2 -0
  125. package/dist/src/room/tool-schema.d.ts +118 -0
  126. package/dist/src/room/tool-schema.js +1 -0
  127. package/dist/src/room/tool-server.d.ts +5 -0
  128. package/dist/src/room/tool-server.js +3 -0
  129. package/dist/src/session/handlers/agent-capabilities.d.ts +3 -0
  130. package/dist/src/session/handlers/agent-capabilities.js +1 -0
  131. package/dist/src/session/handlers/agent-config.js +1 -1
  132. package/dist/src/session/handlers/chat.js +2 -2
  133. package/dist/src/session/handlers/control.js +1 -1
  134. package/dist/src/session/handlers/fs.d.ts +1 -0
  135. package/dist/src/session/handlers/fs.js +1 -1
  136. package/dist/src/session/handlers/room-managed.d.ts +4 -0
  137. package/dist/src/session/handlers/room-managed.js +1 -0
  138. package/dist/src/session/manager.d.ts +18 -6
  139. package/dist/src/session/manager.js +1 -1
  140. package/dist/src/session/types.d.ts +5 -0
  141. package/dist/src/upgrade/engine.d.ts +14 -1
  142. package/dist/src/upgrade/engine.js +2 -2
  143. package/dist/src/upgrade/scheduler.d.ts +45 -0
  144. package/dist/src/upgrade/scheduler.js +1 -0
  145. package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts +17 -0
  146. package/node_modules/@shennian/wire/dist/agent-capabilities.d.ts.map +1 -0
  147. package/node_modules/@shennian/wire/dist/agent-capabilities.js +2 -0
  148. package/node_modules/@shennian/wire/dist/agent-capabilities.js.map +1 -0
  149. package/node_modules/@shennian/wire/dist/agent-workspace.d.ts +41 -0
  150. package/node_modules/@shennian/wire/dist/agent-workspace.d.ts.map +1 -0
  151. package/node_modules/@shennian/wire/dist/agent-workspace.js +3 -0
  152. package/node_modules/@shennian/wire/dist/agent-workspace.js.map +1 -0
  153. package/node_modules/@shennian/wire/dist/index.d.ts +3 -1
  154. package/node_modules/@shennian/wire/dist/index.d.ts.map +1 -1
  155. package/node_modules/@shennian/wire/dist/index.js +3 -1
  156. package/node_modules/@shennian/wire/dist/index.js.map +1 -1
  157. package/node_modules/@shennian/wire/dist/machine.d.ts +1 -0
  158. package/node_modules/@shennian/wire/dist/machine.d.ts.map +1 -1
  159. package/node_modules/@shennian/wire/dist/methods.d.ts +1 -1
  160. package/node_modules/@shennian/wire/dist/methods.d.ts.map +1 -1
  161. package/node_modules/@shennian/wire/dist/room.d.ts +112 -0
  162. package/node_modules/@shennian/wire/dist/room.d.ts.map +1 -0
  163. package/node_modules/@shennian/wire/dist/room.js +4 -0
  164. package/node_modules/@shennian/wire/dist/room.js.map +1 -0
  165. package/node_modules/@shennian/wire/dist/session.d.ts +15 -2
  166. package/node_modules/@shennian/wire/dist/session.d.ts.map +1 -1
  167. package/node_modules/@shennian/wire/dist/session.js +1 -1
  168. package/node_modules/@shennian/wire/dist/session.js.map +1 -1
  169. package/package.json +3 -5
  170. package/dist/scripts/wechat-rpa-confirmation.mjs +0 -5
  171. package/dist/src/agents/pi-context.d.ts +0 -42
  172. package/dist/src/agents/pi-context.js +0 -12
  173. package/dist/src/agents/pi.d.ts +0 -70
  174. package/dist/src/agents/pi.js +0 -17
  175. package/dist/src/channels/base.d.ts +0 -144
  176. package/dist/src/channels/base.js +0 -1
  177. package/dist/src/channels/registry.d.ts +0 -8
  178. package/dist/src/channels/registry.js +0 -1
  179. package/dist/src/channels/reply-split.d.ts +0 -1
  180. package/dist/src/channels/reply-split.js +0 -10
  181. package/dist/src/channels/runtime.d.ts +0 -138
  182. package/dist/src/channels/runtime.js +0 -5
  183. package/dist/src/channels/secret-registry.d.ts +0 -35
  184. package/dist/src/channels/secret-registry.js +0 -1
  185. package/dist/src/channels/websocket.d.ts +0 -55
  186. package/dist/src/channels/websocket.js +0 -8
  187. package/dist/src/channels/wechat-channel/anchor.d.ts +0 -10
  188. package/dist/src/channels/wechat-channel/anchor.js +0 -1
  189. package/dist/src/channels/wechat-channel/automation-lane.d.ts +0 -35
  190. package/dist/src/channels/wechat-channel/automation-lane.js +0 -2
  191. package/dist/src/channels/wechat-channel/client.d.ts +0 -283
  192. package/dist/src/channels/wechat-channel/client.js +0 -1
  193. package/dist/src/channels/wechat-channel/cooldown.d.ts +0 -21
  194. package/dist/src/channels/wechat-channel/cooldown.js +0 -1
  195. package/dist/src/channels/wechat-channel/core/fixture-compare.d.ts +0 -52
  196. package/dist/src/channels/wechat-channel/core/fixture-compare.js +0 -1
  197. package/dist/src/channels/wechat-channel/core/media-action-plan.d.ts +0 -3
  198. package/dist/src/channels/wechat-channel/core/media-action-plan.js +0 -1
  199. package/dist/src/channels/wechat-channel/core/schema.d.ts +0 -67
  200. package/dist/src/channels/wechat-channel/core/schema.js +0 -1
  201. package/dist/src/channels/wechat-channel/core/trace-comparator.d.ts +0 -28
  202. package/dist/src/channels/wechat-channel/core/trace-comparator.js +0 -1
  203. package/dist/src/channels/wechat-channel/fingerprint.d.ts +0 -31
  204. package/dist/src/channels/wechat-channel/fingerprint.js +0 -1
  205. package/dist/src/channels/wechat-channel/helper-assets.d.ts +0 -103
  206. package/dist/src/channels/wechat-channel/helper-assets.js +0 -1
  207. package/dist/src/channels/wechat-channel/helper-client.d.ts +0 -87
  208. package/dist/src/channels/wechat-channel/helper-client.js +0 -3
  209. package/dist/src/channels/wechat-channel/helper-protocol.d.ts +0 -122
  210. package/dist/src/channels/wechat-channel/helper-protocol.js +0 -1
  211. package/dist/src/channels/wechat-channel/human-coordination.d.ts +0 -25
  212. package/dist/src/channels/wechat-channel/human-coordination.js +0 -1
  213. package/dist/src/channels/wechat-channel/index.d.ts +0 -21
  214. package/dist/src/channels/wechat-channel/index.js +0 -1
  215. package/dist/src/channels/wechat-channel/ledger.d.ts +0 -48
  216. package/dist/src/channels/wechat-channel/ledger.js +0 -2
  217. package/dist/src/channels/wechat-channel/media-cache-resolver.d.ts +0 -42
  218. package/dist/src/channels/wechat-channel/media-cache-resolver.js +0 -1
  219. package/dist/src/channels/wechat-channel/media-resolver.d.ts +0 -186
  220. package/dist/src/channels/wechat-channel/media-resolver.js +0 -1
  221. package/dist/src/channels/wechat-channel/message-key.d.ts +0 -19
  222. package/dist/src/channels/wechat-channel/message-key.js +0 -1
  223. package/dist/src/channels/wechat-channel/observer.d.ts +0 -171
  224. package/dist/src/channels/wechat-channel/observer.js +0 -7
  225. package/dist/src/channels/wechat-channel/outbound-ledger.d.ts +0 -96
  226. package/dist/src/channels/wechat-channel/outbound-ledger.js +0 -2
  227. package/dist/src/channels/wechat-channel/outbound-sender.d.ts +0 -74
  228. package/dist/src/channels/wechat-channel/outbound-sender.js +0 -1
  229. package/dist/src/channels/wechat-channel/pacing.d.ts +0 -3
  230. package/dist/src/channels/wechat-channel/pacing.js +0 -1
  231. package/dist/src/channels/wechat-channel/preflight.d.ts +0 -46
  232. package/dist/src/channels/wechat-channel/preflight.js +0 -1
  233. package/dist/src/channels/wechat-channel/runner.d.ts +0 -43
  234. package/dist/src/channels/wechat-channel/runner.js +0 -1
  235. package/dist/src/channels/wechat-channel/runtime.d.ts +0 -50
  236. package/dist/src/channels/wechat-channel/runtime.js +0 -1
  237. package/dist/src/channels/wechat-channel/scheduler.d.ts +0 -74
  238. package/dist/src/channels/wechat-channel/scheduler.js +0 -1
  239. package/dist/src/channels/wechat-channel/vector-store.d.ts +0 -44
  240. package/dist/src/channels/wechat-channel/vector-store.js +0 -1
  241. package/dist/src/channels/wechat-rpa/macos-flow.d.ts +0 -55
  242. package/dist/src/channels/wechat-rpa/macos-flow.js +0 -1
  243. package/dist/src/channels/wechat-rpa/macos.d.ts +0 -11
  244. package/dist/src/channels/wechat-rpa/macos.js +0 -21
  245. package/dist/src/channels/wechat-rpa/normalizer.d.ts +0 -49
  246. package/dist/src/channels/wechat-rpa/normalizer.js +0 -7
  247. package/dist/src/channels/wechat-rpa/product-channel.d.ts +0 -76
  248. package/dist/src/channels/wechat-rpa/product-channel.js +0 -16
  249. package/dist/src/channels/wechat-rpa-session-sync.d.ts +0 -26
  250. package/dist/src/channels/wechat-rpa-session-sync.js +0 -1
  251. package/dist/src/channels/wechat-rpa.d.ts +0 -104
  252. package/dist/src/channels/wechat-rpa.js +0 -6
  253. package/dist/src/channels/wecom.d.ts +0 -51
  254. package/dist/src/channels/wecom.js +0 -4
  255. package/dist/src/commands/external-attachments.d.ts +0 -9
  256. package/dist/src/commands/external-attachments.js +0 -1
  257. package/dist/src/commands/external.d.ts +0 -2
  258. package/dist/src/commands/external.js +0 -1
  259. package/dist/src/commands/helper-runtime-official-download.d.ts +0 -80
  260. package/dist/src/commands/helper-runtime-official-download.js +0 -1
  261. package/dist/src/commands/runtime.d.ts +0 -120
  262. package/dist/src/commands/runtime.js +0 -1
  263. package/dist/src/commands/wechat/command.d.ts +0 -3
  264. package/dist/src/commands/wechat/command.js +0 -1
  265. package/dist/src/commands/wechat/direct.d.ts +0 -14
  266. package/dist/src/commands/wechat/direct.js +0 -2
  267. package/dist/src/commands/wechat/doctor.d.ts +0 -2
  268. package/dist/src/commands/wechat/doctor.js +0 -1
  269. package/dist/src/commands/wechat/ipc.d.ts +0 -9
  270. package/dist/src/commands/wechat/ipc.js +0 -1
  271. package/dist/src/commands/wechat/operations.d.ts +0 -3
  272. package/dist/src/commands/wechat/operations.js +0 -4
  273. package/dist/src/commands/wechat/output.d.ts +0 -7
  274. package/dist/src/commands/wechat/output.js +0 -4
  275. package/dist/src/commands/wechat/types.d.ts +0 -142
  276. package/dist/src/commands/wechat/types.js +0 -1
  277. package/dist/src/commands/wechat/utils.d.ts +0 -16
  278. package/dist/src/commands/wechat/utils.js +0 -1
  279. package/dist/src/commands/wechat.d.ts +0 -6
  280. package/dist/src/commands/wechat.js +0 -1
  281. package/dist/src/devtools/wechat-channel-action-smoke.d.ts +0 -105
  282. package/dist/src/devtools/wechat-channel-action-smoke.js +0 -10
  283. package/dist/src/devtools/wechat-channel-download-report.d.ts +0 -111
  284. package/dist/src/devtools/wechat-channel-download-report.js +0 -2
  285. package/dist/src/devtools/wechat-channel-markdown-report.d.ts +0 -6
  286. package/dist/src/devtools/wechat-channel-markdown-report.js +0 -5
  287. package/dist/src/devtools/wechat-channel-product-steps.d.ts +0 -9
  288. package/dist/src/devtools/wechat-channel-product-steps.js +0 -40
  289. package/dist/src/session/handlers/skills.d.ts +0 -7
  290. package/dist/src/session/handlers/skills.js +0 -1
  291. package/dist/src/session/handlers/wechat-helper-runtime.d.ts +0 -33
  292. package/dist/src/session/handlers/wechat-helper-runtime.js +0 -1
  293. package/dist/src/skills/registry.d.ts +0 -16
  294. package/dist/src/skills/registry.js +0 -15
  295. package/dist/src/skills/setup.d.ts +0 -11
  296. package/dist/src/skills/setup.js +0 -1
@@ -1,283 +0,0 @@
1
- import type { WeChatChannelRuntime, WeChatChannelBindingConfig } from './runtime.js';
2
- export type WeChatChannelApiClientOptions = {
3
- serverUrl?: string;
4
- machineToken?: string;
5
- fetchImpl?: typeof fetch;
6
- };
7
- export type WeChatChannelObservedMessage = {
8
- stableMessageKey: string;
9
- senderRole: 'self' | 'contact' | 'system' | 'unknown';
10
- senderName?: string | null;
11
- kind: string;
12
- normalizedText?: string | null;
13
- anchorText?: string | null;
14
- anchorMetadata?: unknown;
15
- neighborContext?: unknown;
16
- textExcerpt?: string | null;
17
- bbox?: unknown;
18
- mediaMetadata?: unknown;
19
- isBaseline?: boolean;
20
- deliveryStatus?: string;
21
- observedAt?: string;
22
- visualBlocks?: WeChatChannelVisualBlock[];
23
- };
24
- export type WeChatChannelStructuredMessageCandidate = Omit<WeChatChannelObservedMessage, 'stableMessageKey'> & {
25
- stableMessageKey?: string;
26
- };
27
- export type WeChatChannelVisualBlock = {
28
- stableMessageKey?: string;
29
- blockId: string;
30
- blockKind: string;
31
- bbox?: unknown;
32
- model?: string;
33
- modelVersion?: string | null;
34
- dims?: number;
35
- vectorBase64?: string;
36
- vectorStoreKey?: string;
37
- signature?: string;
38
- };
39
- export type WeChatChannelEmbedVisualInput = {
40
- screenshots?: Array<{
41
- captureIndex?: number;
42
- mimeType: string;
43
- dataBase64: string;
44
- width: number;
45
- height: number;
46
- }>;
47
- visualBlocks: Array<{
48
- stableMessageKey?: string;
49
- blockId?: string;
50
- blockKind?: string;
51
- bbox?: unknown;
52
- mimeType?: string;
53
- dataBase64?: string;
54
- width?: number;
55
- height?: number;
56
- }>;
57
- traceId?: string;
58
- };
59
- export type WeChatChannelEmbedVisualResponse = {
60
- ok: true;
61
- visualBlocks?: WeChatChannelVisualBlock[];
62
- embeddedBlocks?: WeChatChannelVisualBlock[];
63
- reasonCode?: string;
64
- modelVersion?: string | null;
65
- dims?: number | null;
66
- usage?: unknown;
67
- usageRefId?: string;
68
- latencyMs?: number | null;
69
- };
70
- export type WeChatChannelClassifyWindowInput = {
71
- screenshot: {
72
- mimeType: string;
73
- dataBase64: string;
74
- width: number;
75
- height: number;
76
- windowId?: string | null;
77
- };
78
- traceId?: string;
79
- };
80
- export type WeChatChannelClassifyWindowResponse = {
81
- ok: true;
82
- status?: string;
83
- windowKind?: 'chat_main' | 'article' | 'settings' | 'login' | 'other';
84
- conversationTitle?: string | null;
85
- isTargetConversation?: boolean;
86
- confidence?: number;
87
- layout?: {
88
- messageInputRect?: {
89
- x?: number;
90
- y?: number;
91
- width?: number;
92
- height?: number;
93
- coordinateSpace?: string;
94
- } | null;
95
- searchInputRect?: {
96
- x?: number;
97
- y?: number;
98
- width?: number;
99
- height?: number;
100
- coordinateSpace?: string;
101
- } | null;
102
- } | null;
103
- reasonCode?: string;
104
- warnings?: string[];
105
- usageRefId?: string;
106
- latencyMs?: number | null;
107
- modelVersion?: string | null;
108
- };
109
- export type WeChatChannelApiClient = ReturnType<typeof createWeChatChannelApiClient>;
110
- export declare class WeChatChannelApiError extends Error {
111
- readonly reasonCode: string;
112
- readonly statusCode: number;
113
- readonly details?: unknown | undefined;
114
- constructor(message: string, reasonCode: string, statusCode: number, details?: unknown | undefined);
115
- }
116
- export type WeChatChannelObserveInput = {
117
- screenshots: Array<{
118
- captureIndex?: number;
119
- mimeType: string;
120
- dataBase64: string;
121
- width: number;
122
- height: number;
123
- }>;
124
- edgeOcrBlocks?: unknown[];
125
- visibleConversationFingerprints?: unknown[];
126
- localLedgerTailAnchors?: unknown[];
127
- traceId?: string;
128
- };
129
- export type WeChatChannelObserveResponse = {
130
- ok: true;
131
- observedMessages?: WeChatChannelObservedMessage[];
132
- diff?: unknown;
133
- reasonCode?: string;
134
- usageRefId?: string;
135
- };
136
- export type WeChatChannelStructureWindowInput = WeChatChannelObserveInput;
137
- export type WeChatChannelStructureWindowResponse = {
138
- ok: true;
139
- structuredMessages?: WeChatChannelStructuredMessageCandidate[];
140
- observedMessages?: WeChatChannelStructuredMessageCandidate[];
141
- mediaCandidates?: unknown[];
142
- reasonCode?: string;
143
- usageRefId?: string;
144
- schemaVersion?: number;
145
- };
146
- export type WeChatChannelRuntimePolicyResponse = {
147
- ok: true;
148
- feature?: {
149
- enabled?: boolean;
150
- reasonCode?: string | null;
151
- edgeRuntime?: {
152
- enabled?: boolean;
153
- reasonCode?: string | null;
154
- minClientRuntimeVersion?: number;
155
- };
156
- };
157
- serverDecision?: {
158
- required?: boolean;
159
- available?: boolean;
160
- edgeRuntimeAvailable?: boolean;
161
- };
162
- runtime?: {
163
- defaultPollIntervalSeconds?: number;
164
- minPollIntervalSeconds?: number;
165
- maxPollIntervalSeconds?: number;
166
- current?: {
167
- id?: string;
168
- status?: string | null;
169
- pollIntervalSeconds?: number | null;
170
- foregroundPolicy?: string | null;
171
- } | null;
172
- scanPolicy?: {
173
- plan?: 'free' | 'pro' | 'team';
174
- defaultPollIntervalSeconds?: number;
175
- minPollIntervalSeconds?: number;
176
- maxPollIntervalSeconds?: number;
177
- highFrequencyAvailable?: boolean;
178
- reasonCode?: string | null;
179
- };
180
- };
181
- usagePolicy?: {
182
- scanPolicy?: {
183
- plan?: 'free' | 'pro' | 'team';
184
- defaultPollIntervalSeconds?: number;
185
- minPollIntervalSeconds?: number;
186
- maxPollIntervalSeconds?: number;
187
- highFrequencyAvailable?: boolean;
188
- reasonCode?: string | null;
189
- };
190
- };
191
- };
192
- export type WeChatChannelBindingResponse = {
193
- ok: true;
194
- binding: {
195
- id: string;
196
- runtimeId?: string | null;
197
- machineId: string;
198
- sessionId: string;
199
- conversationName: string;
200
- enabled: boolean;
201
- allowReply?: boolean;
202
- downloadMedia?: boolean;
203
- updatedAt?: string | null;
204
- } | null;
205
- };
206
- export type WeChatChannelBindingsResponse = {
207
- ok: true;
208
- machineId: string;
209
- bindings: Array<{
210
- id: string;
211
- runtimeId?: string | null;
212
- machineId: string;
213
- sessionId: string;
214
- conversationName: string;
215
- enabled: boolean;
216
- allowReply?: boolean;
217
- downloadMedia?: boolean;
218
- updatedAt?: string | null;
219
- sessionTitle?: string | null;
220
- sessionWorkDir?: string | null;
221
- sessionAgentType?: string | null;
222
- sessionAgentSessionId?: string | null;
223
- sessionModelId?: string | null;
224
- }>;
225
- };
226
- export type WeChatChannelOutboundStatusInput = {
227
- replyId: string;
228
- idempotencyKey: string;
229
- status: string;
230
- replyBaseRevision?: number;
231
- sentAt?: string;
232
- confirmedAt?: string;
233
- failureCode?: string;
234
- lastErrorSummary?: string;
235
- nextAttemptAt?: string;
236
- attemptCount?: number;
237
- commitStage?: string;
238
- copyableContentRef?: string;
239
- copyableText?: string;
240
- agentVisible?: boolean;
241
- };
242
- export type WeChatChannelRunStatusInput = {
243
- status: string;
244
- reasonCode?: string;
245
- traceId?: string;
246
- lastErrorSummary?: string;
247
- preflight?: {
248
- checkedAt?: string;
249
- screenRecording?: boolean | 'granted' | 'denied' | 'restricted' | 'unknown' | 'not_determined';
250
- accessibility?: boolean | 'granted' | 'denied' | 'restricted' | 'unknown' | 'not_determined';
251
- inputMonitoring?: boolean | 'granted' | 'denied' | 'restricted' | 'unknown' | 'not_determined';
252
- automation?: boolean | 'granted' | 'denied' | 'restricted' | 'unknown' | 'not_determined';
253
- wechatRunning?: boolean;
254
- wechatAppDetected?: boolean;
255
- helperReady?: boolean;
256
- };
257
- };
258
- export type WeChatChannelRuntimePreflightInput = WeChatChannelRunStatusInput['preflight'];
259
- export declare function createWeChatChannelApiClient(options?: WeChatChannelApiClientOptions): {
260
- getRuntimePolicy: () => Promise<WeChatChannelRuntimePolicyResponse>;
261
- getBinding: (input: {
262
- machineId?: string | null;
263
- sessionId: string;
264
- }) => Promise<WeChatChannelBindingResponse>;
265
- listBindings: (input?: {
266
- machineId?: string | null;
267
- }) => Promise<WeChatChannelBindingsResponse>;
268
- upsertRuntime: (runtime: WeChatChannelRuntime, binding?: WeChatChannelBindingConfig, input?: {
269
- preflight?: WeChatChannelRuntimePreflightInput;
270
- helperVersion?: string;
271
- clientRuntimeVersion?: string;
272
- }) => Promise<unknown>;
273
- observe: (runtime: WeChatChannelRuntime, binding: WeChatChannelBindingConfig, input: WeChatChannelObserveInput) => Promise<WeChatChannelObserveResponse>;
274
- structureWindow: (runtime: WeChatChannelRuntime, binding: WeChatChannelBindingConfig, input: WeChatChannelStructureWindowInput) => Promise<WeChatChannelStructureWindowResponse>;
275
- embedVisual: (runtime: WeChatChannelRuntime, binding: WeChatChannelBindingConfig, input: WeChatChannelEmbedVisualInput) => Promise<WeChatChannelEmbedVisualResponse>;
276
- classifyWindow: (runtime: WeChatChannelRuntime, binding: WeChatChannelBindingConfig, input: WeChatChannelClassifyWindowInput) => Promise<WeChatChannelClassifyWindowResponse>;
277
- ingest: (runtime: WeChatChannelRuntime, binding: WeChatChannelBindingConfig, input: {
278
- idempotencyKey: string;
279
- messages: WeChatChannelObservedMessage[];
280
- }) => Promise<unknown>;
281
- reportOutboundStatus: (runtime: WeChatChannelRuntime, binding: WeChatChannelBindingConfig, input: WeChatChannelOutboundStatusInput) => Promise<unknown>;
282
- reportRunStatus: (runtime: WeChatChannelRuntime, binding: WeChatChannelBindingConfig, input: WeChatChannelRunStatusInput) => Promise<unknown>;
283
- };
@@ -1 +0,0 @@
1
- import{SERVERS as f}from"../../region.js";import{loadConfig as y}from"../../config/index.js";class h extends Error{reasonCode;statusCode;details;constructor(o,d,c,I){super(o),this.reasonCode=d,this.statusCode=c,this.details=I,this.name="WeChatChannelApiError"}}function A(r={}){const o=y(),d=v(r.serverUrl||o.serverUrl||f.cn.url),c=r.machineToken||o.machineToken,I=r.fetchImpl||fetch;if(!c)throw new Error("WeChat channel requires a paired machine token");async function t(s,n){const e=C(n);let a;try{a=await I(`${d}/api/channels/wechat${s}`,{method:n===void 0?"GET":"POST",headers:{authorization:`Bearer ${c}`,...n===void 0?{}:{"content-type":"application/json"},...e?{"x-trace-id":e}:{}},body:n===void 0?void 0:JSON.stringify(n)})}catch(i){const u=i instanceof Error?i.message:String(i||"network request failed");throw new h(`WeChat channel API ${s} network failed: ${u}`,"wechat_channel_network_failed",0,{path:s,traceId:e||null,cause:u})}const m=await a.text();let l=null;try{l=m?JSON.parse(m):null}catch{throw new h(`WeChat channel API ${s} returned invalid JSON`,"wechat_channel_invalid_response",a.status,{path:s,traceId:e||null,text:m.slice(0,200)})}if(!a.ok||l?.ok===!1){const i=w(l?.reasonCode)||a.statusText||"request_failed";throw new h(`WeChat channel API ${s} failed: ${i}`,i,a.status,{path:s,traceId:e||null,statusCode:a.status})}return l}return{getRuntimePolicy:()=>t("/runtime-policy"),getBinding:s=>{const n=new URLSearchParams;return s.machineId&&n.set("machineId",s.machineId),n.set("sessionId",s.sessionId),t(`/binding?${n}`)},listBindings:(s={})=>{const n=new URLSearchParams;s.machineId&&n.set("machineId",s.machineId);const e=n.toString()?`?${n}`:"";return t(`/bindings${e}`)},upsertRuntime:(s,n,e)=>t("/runtime",{runtimeId:s.runtimeId,machineId:s.machineId,pollIntervalSeconds:Math.round(s.policy.pollIntervalMs/1e3),foregroundPolicy:s.foregroundPolicy,clientRuntimeVersion:e?.clientRuntimeVersion??String(s.policy.runtimeVersion),helperVersion:e?.helperVersion,preflight:e?.preflight,...n?g(n):{}}),observe:(s,n,e)=>t("/observe",{runtimeId:s.runtimeId,bindingId:n.bindingId,sessionId:n.sessionId,machineId:s.machineId,conversationName:n.conversationDisplayName,schemaVersion:s.policy.runtimeVersion,screenshots:e.screenshots,edgeOcrBlocks:e.edgeOcrBlocks??[],visibleConversationFingerprints:e.visibleConversationFingerprints??[],localLedgerTailAnchors:e.localLedgerTailAnchors??[],traceId:e.traceId}),structureWindow:(s,n,e)=>t("/structure-window",{runtimeId:s.runtimeId,bindingId:n.bindingId,sessionId:n.sessionId,machineId:s.machineId,conversationName:n.conversationDisplayName,schemaVersion:s.policy.runtimeVersion,screenshots:e.screenshots,edgeOcrBlocks:e.edgeOcrBlocks??[],visibleConversationFingerprints:e.visibleConversationFingerprints??[],localLedgerTailAnchors:e.localLedgerTailAnchors??[],traceId:e.traceId}),embedVisual:(s,n,e)=>t("/embed-visual",{runtimeId:s.runtimeId,bindingId:n.bindingId,sessionId:n.sessionId,machineId:s.machineId,conversationName:n.conversationDisplayName,schemaVersion:s.policy.runtimeVersion,screenshots:e.screenshots??[],visualBlocks:e.visualBlocks,traceId:e.traceId}),classifyWindow:(s,n,e)=>t("/classify-window",{runtimeId:s.runtimeId,bindingId:n.bindingId,sessionId:n.sessionId,machineId:s.machineId,conversationName:n.conversationDisplayName,screenshot:e.screenshot,traceId:e.traceId}),ingest:(s,n,e)=>t("/ingest",{runtimeId:s.runtimeId,idempotencyKey:e.idempotencyKey,bindingId:n.bindingId,sessionId:n.sessionId,machineId:s.machineId,messages:e.messages}),reportOutboundStatus:(s,n,e)=>t("/outbound-status",{runtimeId:s.runtimeId,replyId:e.replyId,idempotencyKey:e.idempotencyKey,bindingId:n.bindingId,sessionId:n.sessionId,machineId:s.machineId,status:e.status,replyBaseRevision:e.replyBaseRevision,sentAt:e.sentAt,confirmedAt:e.confirmedAt,failureCode:e.failureCode,lastErrorSummary:e.lastErrorSummary,nextAttemptAt:e.nextAttemptAt,attemptCount:e.attemptCount,commitStage:e.commitStage,copyableContentRef:e.copyableContentRef,copyableText:e.copyableText,agentVisible:e.agentVisible}),reportRunStatus:(s,n,e)=>t("/run-status",{runtimeId:s.runtimeId,bindingId:n.bindingId,sessionId:n.sessionId,machineId:s.machineId,status:e.status,reasonCode:e.reasonCode,traceId:e.traceId,lastErrorSummary:e.lastErrorSummary,preflight:e.preflight})}}function g(r){return{bindingId:r.bindingId,sessionId:r.sessionId,conversationName:r.conversationDisplayName,enabled:r.enabled,allowReply:r.allowReply,downloadMedia:r.downloadMedia}}function v(r){return r.replace(/\/+$/,"")}function C(r){if(!r||typeof r!="object")return;const o=r.traceId;return(typeof o=="string"?o.trim():"")||void 0}function w(r){return typeof r=="string"?r.trim():""}export{h as WeChatChannelApiError,A as createWeChatChannelApiClient};
@@ -1,21 +0,0 @@
1
- export type WeChatChannelCooldownState = {
2
- consecutiveInterruptions: number;
3
- cooldownUntil?: string | null;
4
- manualReviewReason?: string | null;
5
- };
6
- export declare const WECHAT_CHANNEL_INTERRUPTION_COOLDOWN_THRESHOLD = 3;
7
- export declare const WECHAT_CHANNEL_INTERRUPTION_COOLDOWN_MS: number;
8
- export declare const WECHAT_CHANNEL_BILLING_PAUSE_MS: number;
9
- export declare function isWeChatChannelCooldownActive(state: WeChatChannelCooldownState | undefined, now?: Date): boolean;
10
- export declare function noteWeChatChannelInterruption(input: {
11
- state?: WeChatChannelCooldownState;
12
- reason?: string;
13
- now?: Date;
14
- }): WeChatChannelCooldownState;
15
- export declare function noteWeChatChannelStableRun(state?: WeChatChannelCooldownState): WeChatChannelCooldownState;
16
- export declare function clearExpiredWeChatChannelCooldown(state: WeChatChannelCooldownState, now?: Date): WeChatChannelCooldownState;
17
- export declare function noteWeChatChannelBillingPause(input: {
18
- state?: WeChatChannelCooldownState;
19
- reason?: string;
20
- now?: Date;
21
- }): WeChatChannelCooldownState;
@@ -1 +0,0 @@
1
- const r=3,u=3e5,a=18e5;function l(n,e=new Date){if(!n?.cooldownUntil)return!1;const o=new Date(n.cooldownUntil).getTime();return Number.isFinite(o)&&o>e.getTime()}function c(n){const e=n.now??new Date,o=n.state??{consecutiveInterruptions:0},i=o.consecutiveInterruptions+1,t={consecutiveInterruptions:i,cooldownUntil:o.cooldownUntil??null,manualReviewReason:o.manualReviewReason??null};return i>=3&&(t.cooldownUntil=new Date(e.getTime()+3e5).toISOString(),t.manualReviewReason=n.reason||"user_interruption_cooldown"),t}function s(n){return{consecutiveInterruptions:0,cooldownUntil:n?.cooldownUntil??null,manualReviewReason:n?.manualReviewReason??null}}function w(n,e=new Date){return l(n,e)?n:{...n,cooldownUntil:null}}function C(n){const e=n.now??new Date;return{consecutiveInterruptions:0,cooldownUntil:new Date(e.getTime()+18e5).toISOString(),manualReviewReason:n.reason||"insufficient_credits"}}export{a as WECHAT_CHANNEL_BILLING_PAUSE_MS,u as WECHAT_CHANNEL_INTERRUPTION_COOLDOWN_MS,r as WECHAT_CHANNEL_INTERRUPTION_COOLDOWN_THRESHOLD,w as clearExpiredWeChatChannelCooldown,l as isWeChatChannelCooldownActive,C as noteWeChatChannelBillingPause,c as noteWeChatChannelInterruption,s as noteWeChatChannelStableRun};
@@ -1,52 +0,0 @@
1
- import { type WeChatChannelMediaAction, type WeChatChannelMediaActionPlan, type WeChatChannelMediaCandidate, type WeChatChannelMessageKind, type WeChatChannelRect } from './schema.js';
2
- export type WeChatChannelFixtureNormalizedMessage = {
3
- index: number;
4
- senderRole: string;
5
- senderName: string | null;
6
- kind: WeChatChannelMessageKind;
7
- text: string;
8
- bbox?: WeChatChannelRect;
9
- mediaStatus: string;
10
- downloadActionBbox?: WeChatChannelRect | null;
11
- };
12
- export type WeChatChannelFixtureActionPlanProjection = {
13
- messageKey: string;
14
- kind: WeChatChannelMessageKind;
15
- reasonCode: string;
16
- actions: Array<Pick<WeChatChannelMediaAction, 'type' | 'target' | 'label' | 'reasonCode'>>;
17
- };
18
- export type WeChatChannelFixtureProjection = {
19
- normalizedMessages: WeChatChannelFixtureNormalizedMessage[];
20
- mediaCandidates: Array<WeChatChannelMediaCandidate & {
21
- index: number;
22
- }>;
23
- actionPlans: WeChatChannelFixtureActionPlanProjection[];
24
- };
25
- export type WeChatChannelFixtureProjectionDiff = {
26
- section: keyof WeChatChannelFixtureProjection;
27
- index: number;
28
- reasonCode: 'missing_left_item' | 'missing_right_item' | 'fixture_projection_mismatch';
29
- left?: unknown;
30
- right?: unknown;
31
- };
32
- export type WeChatChannelFixtureProjectionComparison = {
33
- ok: boolean;
34
- firstDiff?: WeChatChannelFixtureProjectionDiff;
35
- diffs: WeChatChannelFixtureProjectionDiff[];
36
- };
37
- export type WeChatChannelPlatformFixtureProjectionDiff = WeChatChannelFixtureProjectionDiff & {
38
- leftPlatform: string;
39
- rightPlatform: string;
40
- };
41
- export type WeChatChannelPlatformFixtureProjectionComparison = {
42
- ok: boolean;
43
- firstDiff?: WeChatChannelPlatformFixtureProjectionDiff;
44
- diffs: WeChatChannelPlatformFixtureProjectionDiff[];
45
- };
46
- export declare function projectWeChatChannelFixtureMessages(input: {
47
- messages: unknown[];
48
- messageKeyPrefix?: string;
49
- }): WeChatChannelFixtureProjection;
50
- export declare function compareWeChatChannelFixtureProjections(left: WeChatChannelFixtureProjection, right: WeChatChannelFixtureProjection): WeChatChannelFixtureProjectionComparison;
51
- export declare function compareWeChatChannelPlatformFixtureProjections(projections: Record<string, WeChatChannelFixtureProjection>): WeChatChannelPlatformFixtureProjectionComparison;
52
- export declare function projectActionPlan(plan: WeChatChannelMediaActionPlan): WeChatChannelFixtureActionPlanProjection;
@@ -1 +0,0 @@
1
- import{buildWeChatChannelMediaActionPlan as g}from"./media-action-plan.js";import{normalizeWeChatChannelMessageKind as p}from"./schema.js";const x=new Set(["image","file","video-file"]);function M(n){const t=n.messages.map((o,r)=>C(o,r)),e=t.filter(o=>x.has(o.kind)&&!!o.bbox).map(o=>y(o,n.messageKeyPrefix)).filter(o=>o!=null),i=e.map(o=>_(g(o))).filter(o=>o.actions.length>0);return{normalizedMessages:t,mediaCandidates:e,actionPlans:i}}function w(n,t){const e=[];for(const i of["normalizedMessages","mediaCandidates","actionPlans"]){const o=n[i],r=t[i],f=Math.max(o.length,r.length);for(let d=0;d<f;d+=1){const a=o[d],l=r[d];if(a==null||l==null){e.push({section:i,index:d,reasonCode:a==null?"missing_left_item":"missing_right_item",...a!=null?{left:a}:{},...l!=null?{right:l}:{}});continue}h(a)!==h(l)&&e.push({section:i,index:d,reasonCode:"fixture_projection_mismatch",left:a,right:l})}}return{ok:e.length===0,firstDiff:e[0],diffs:e}}function j(n){const t=Object.entries(n);if(t.length<=1)return{ok:!0,firstDiff:void 0,diffs:[]};const[e,i]=t[0],o=[];for(const[r,f]of t.slice(1)){const d=w(i,f);o.push(...d.diffs.map(a=>({...a,leftPlatform:e,rightPlatform:r})))}return{ok:o.length===0,firstDiff:o[0],diffs:o}}function _(n){return{messageKey:n.messageKey,kind:n.kind,reasonCode:n.reasonCode,actions:n.actions.map(t=>({type:t.type,...t.target?{target:t.target}:{},...t.label?{label:t.label}:{},...t.reasonCode?{reasonCode:t.reasonCode}:{}}))}}function C(n,t){const e=m(n)?n:{},i=p(e.kind??e.messageType??e.message_type??e.type),o=b(e.bbox??e.rect),r=b(e.downloadActionBbox??e.downloadActionBbox_2d??e.download_action_bbox??e.download_action_bbox_2d);return{index:c(e.index)??t,senderRole:s(e.senderRole)||"incoming",senderName:s(e.senderName)||null,kind:i,text:i==="text"?s(e.text).trim():s(e.text),...o?{bbox:o}:{},mediaStatus:A(e.mediaStatus??e.media_status??e.downloadStatus??e.download_status,i),...r?{downloadActionBbox:r}:{}}}function y(n,t){return n.bbox?{index:n.index,messageKey:t?`${t}:${n.index}`:String(n.index),kind:n.kind,bbox:n.bbox,downloadActionBbox:n.downloadActionBbox??null,mediaStatus:n.mediaStatus}:null}function A(n,t){if(!x.has(t))return"unknown";const e=s(n).toLowerCase().replace(/-/g,"_");return["downloaded","ready","available","loaded","\u5DF2\u4E0B\u8F7D"].includes(e)?"downloaded":["not_downloaded","undownloaded","needs_download","need_download","download_required","\u672A\u4E0B\u8F7D","\u5F85\u4E0B\u8F7D"].includes(e)?"not_downloaded":["loading","downloading","in_progress","\u4E0B\u8F7D\u4E2D"].includes(e)?"loading":"unknown"}function b(n){if(!m(n))return;const t=c(n.x),e=c(n.y),i=c(n.width),o=c(n.height);if(!(t==null||e==null||i==null||o==null))return{x:t,y:e,width:i,height:o,...s(n.coordinateSpace)?{coordinateSpace:s(n.coordinateSpace)}:{}}}function h(n){return JSON.stringify(u(n))}function u(n){return Array.isArray(n)?n.map(u):m(n)?Object.fromEntries(Object.keys(n).sort().map(t=>[t,u(n[t])])):n}function m(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function s(n){return typeof n=="string"?n.trim():""}function c(n){const t=Number(n);return Number.isFinite(t)?t:null}export{w as compareWeChatChannelFixtureProjections,j as compareWeChatChannelPlatformFixtureProjections,_ as projectActionPlan,M as projectWeChatChannelFixtureMessages};
@@ -1,3 +0,0 @@
1
- import { type WeChatChannelMediaActionPlan, type WeChatChannelMediaCandidate } from './schema.js';
2
- export declare function buildWeChatChannelMediaActionPlan(candidate: WeChatChannelMediaCandidate): WeChatChannelMediaActionPlan;
3
- export declare function shouldClickDownloadAffordance(candidate: WeChatChannelMediaCandidate): boolean;
@@ -1 +0,0 @@
1
- import{normalizeWeChatChannelMessageKind as a,normalizeWeChatChannelAttachmentAvailability as n}from"./schema.js";const r=new Set(["image","file","video-file"]),i=new Set(["video-card","link-card","official-account-card","mini-program-card"]);function m(e){const o=a(e.kind);if(!r.has(o))return{messageKey:e.messageKey,kind:o,actions:[],reasonCode:i.has(o)?"unsupported_share_card":"unsupported_media_kind"};if(!e.bbox)return{messageKey:e.messageKey,kind:o,actions:[],reasonCode:"media_bbox_missing"};const t=[...c(o,e.bbox),{type:"postprocess-file",reasonCode:"verify-local-attachment"}];return{messageKey:e.messageKey,kind:o,actions:t,reasonCode:"copy_clipboard_plan"}}function u(e){return e.downloadActionBbox?n(e.mediaStatus)==="pending-download"?!0:String(e.mediaStatus??"").trim().toLowerCase().replace(/-/g,"_")==="loading":!1}function s(e){return e==="image"?"\u590D\u5236\u56FE\u7247":e==="video-file"?"\u590D\u5236\u89C6\u9891":"\u590D\u5236\u6587\u4EF6"}function c(e,o,t=!1){return[{type:"right-click-media",target:o,reasonCode:t?`retry-open-${e}-context-menu-after-download`:`open-${e}-context-menu`},{type:"ocr-click-menu-item",label:s(e),reasonCode:t?`retry-copy-${e}-from-context-menu`:`copy-${e}-from-context-menu`},{type:"materialize-clipboard",reasonCode:t?"retry-materialize-system-clipboard-attachment":"materialize-system-clipboard-attachment"}]}export{m as buildWeChatChannelMediaActionPlan,u as shouldClickDownloadAffordance};
@@ -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
- };