@intentcomputing/koko-agent-sdk 1.0.1

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 (622) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/CODE_OF_CONDUCT.md +3 -0
  3. package/CONTRIBUTING.md +9 -0
  4. package/LICENSE +21 -0
  5. package/README.md +65 -0
  6. package/README.zh-CN.md +50 -0
  7. package/SECURITY.md +5 -0
  8. package/android/build.gradle +40 -0
  9. package/android/src/main/AndroidManifest.xml +2 -0
  10. package/android/src/main/java/cn/intentcomputing/kokoagentsdk/KokoAgentSdkModule.java +1356 -0
  11. package/android/src/main/java/cn/intentcomputing/kokoagentsdk/KokoAgentSdkPackage.java +23 -0
  12. package/docs/INTEGRATION.md +168 -0
  13. package/docs/INTEGRATION.zh-CN.md +140 -0
  14. package/docs/PRIVACY.md +11 -0
  15. package/docs/PRIVACY.zh-CN.md +11 -0
  16. package/docs/PUBLISH.md +11 -0
  17. package/docs/PUBLISH.zh-CN.md +11 -0
  18. package/ios/KokoAgentSdk/KokoAgentSdk.h +5 -0
  19. package/ios/KokoAgentSdk/KokoAgentSdk.m +2464 -0
  20. package/ios/KokoAgentSdk/KokoOcrBounds.h +20 -0
  21. package/ios/KokoAgentSdk/KokoScrollBounds.h +21 -0
  22. package/koko-agent-sdk.podspec +23 -0
  23. package/lib/commonjs/KokoAgent.js +1427 -0
  24. package/lib/commonjs/KokoAgent.js.map +1 -0
  25. package/lib/commonjs/assist/OnDeviceAssist.js +94 -0
  26. package/lib/commonjs/assist/OnDeviceAssist.js.map +1 -0
  27. package/lib/commonjs/assist/intentClassify.js +100 -0
  28. package/lib/commonjs/assist/intentClassify.js.map +1 -0
  29. package/lib/commonjs/assist/nodeRank.js +120 -0
  30. package/lib/commonjs/assist/nodeRank.js.map +1 -0
  31. package/lib/commonjs/assist/ocrTarget.js +135 -0
  32. package/lib/commonjs/assist/ocrTarget.js.map +1 -0
  33. package/lib/commonjs/assist/webVisualChange.js +29 -0
  34. package/lib/commonjs/assist/webVisualChange.js.map +1 -0
  35. package/lib/commonjs/client/ActionOutcomeUnknownError.js +28 -0
  36. package/lib/commonjs/client/ActionOutcomeUnknownError.js.map +1 -0
  37. package/lib/commonjs/client/AgentSession.js +858 -0
  38. package/lib/commonjs/client/AgentSession.js.map +1 -0
  39. package/lib/commonjs/client/GatewayClient.js +302 -0
  40. package/lib/commonjs/client/GatewayClient.js.map +1 -0
  41. package/lib/commonjs/client/OperationReplayGuard.js +62 -0
  42. package/lib/commonjs/client/OperationReplayGuard.js.map +1 -0
  43. package/lib/commonjs/client/RunCheckpoint.js +139 -0
  44. package/lib/commonjs/client/RunCheckpoint.js.map +1 -0
  45. package/lib/commonjs/client/loopDetect.js +184 -0
  46. package/lib/commonjs/client/loopDetect.js.map +1 -0
  47. package/lib/commonjs/client/recentSearch.js +50 -0
  48. package/lib/commonjs/client/recentSearch.js.map +1 -0
  49. package/lib/commonjs/client/walletChoiceGuard.js +18 -0
  50. package/lib/commonjs/client/walletChoiceGuard.js.map +1 -0
  51. package/lib/commonjs/client/webResultCategory.js +38 -0
  52. package/lib/commonjs/client/webResultCategory.js.map +1 -0
  53. package/lib/commonjs/commercial/AccountStore.js +78 -0
  54. package/lib/commonjs/commercial/AccountStore.js.map +1 -0
  55. package/lib/commonjs/commercial/AgentDebug.js +104 -0
  56. package/lib/commonjs/commercial/AgentDebug.js.map +1 -0
  57. package/lib/commonjs/commercial/ExecutionGuard.js +53 -0
  58. package/lib/commonjs/commercial/ExecutionGuard.js.map +1 -0
  59. package/lib/commonjs/commercial/UsageBus.js +42 -0
  60. package/lib/commonjs/commercial/UsageBus.js.map +1 -0
  61. package/lib/commonjs/commercial/branding.js +69 -0
  62. package/lib/commonjs/commercial/branding.js.map +1 -0
  63. package/lib/commonjs/commercial/devMode.js +52 -0
  64. package/lib/commonjs/commercial/devMode.js.map +1 -0
  65. package/lib/commonjs/commercial/trust.js +69 -0
  66. package/lib/commonjs/commercial/trust.js.map +1 -0
  67. package/lib/commonjs/confirmation/gate.js +62 -0
  68. package/lib/commonjs/confirmation/gate.js.map +1 -0
  69. package/lib/commonjs/cursor/CursorOverlay.js +141 -0
  70. package/lib/commonjs/cursor/CursorOverlay.js.map +1 -0
  71. package/lib/commonjs/cursor/PointerHand.js +51 -0
  72. package/lib/commonjs/cursor/PointerHand.js.map +1 -0
  73. package/lib/commonjs/cursor/controller.js +91 -0
  74. package/lib/commonjs/cursor/controller.js.map +1 -0
  75. package/lib/commonjs/cursor/pointer.js +49 -0
  76. package/lib/commonjs/cursor/pointer.js.map +1 -0
  77. package/lib/commonjs/debug/KokoRemoteSmoke.js +611 -0
  78. package/lib/commonjs/debug/KokoRemoteSmoke.js.map +1 -0
  79. package/lib/commonjs/explore/ExplorationGraph.js +418 -0
  80. package/lib/commonjs/explore/ExplorationGraph.js.map +1 -0
  81. package/lib/commonjs/explore/bootstrapExplore.js +59 -0
  82. package/lib/commonjs/explore/bootstrapExplore.js.map +1 -0
  83. package/lib/commonjs/host/HostActions.js +266 -0
  84. package/lib/commonjs/host/HostActions.js.map +1 -0
  85. package/lib/commonjs/i18n/index.js +169 -0
  86. package/lib/commonjs/i18n/index.js.map +1 -0
  87. package/lib/commonjs/i18n/runtimeMessages.js +184 -0
  88. package/lib/commonjs/i18n/runtimeMessages.js.map +1 -0
  89. package/lib/commonjs/index.js +640 -0
  90. package/lib/commonjs/index.js.map +1 -0
  91. package/lib/commonjs/native/NativeBridge.js +132 -0
  92. package/lib/commonjs/native/NativeBridge.js.map +1 -0
  93. package/lib/commonjs/native/navigationLabel.js +16 -0
  94. package/lib/commonjs/native/navigationLabel.js.map +1 -0
  95. package/lib/commonjs/native/normalizeViewTree.js +28 -0
  96. package/lib/commonjs/native/normalizeViewTree.js.map +1 -0
  97. package/lib/commonjs/native/pruneOffscreen.js +76 -0
  98. package/lib/commonjs/native/pruneOffscreen.js.map +1 -0
  99. package/lib/commonjs/native/scrollViewport.js +69 -0
  100. package/lib/commonjs/native/scrollViewport.js.map +1 -0
  101. package/lib/commonjs/package.json +1 -0
  102. package/lib/commonjs/privacy/redact.js +108 -0
  103. package/lib/commonjs/privacy/redact.js.map +1 -0
  104. package/lib/commonjs/privacy/screenEvidence.js +59 -0
  105. package/lib/commonjs/privacy/screenEvidence.js.map +1 -0
  106. package/lib/commonjs/privacy/screenModel.js +404 -0
  107. package/lib/commonjs/privacy/screenModel.js.map +1 -0
  108. package/lib/commonjs/privacy/sensitiveScreen.js +58 -0
  109. package/lib/commonjs/privacy/sensitiveScreen.js.map +1 -0
  110. package/lib/commonjs/privacy/userGate.js +213 -0
  111. package/lib/commonjs/privacy/userGate.js.map +1 -0
  112. package/lib/commonjs/protocol/actions.js +112 -0
  113. package/lib/commonjs/protocol/actions.js.map +1 -0
  114. package/lib/commonjs/provider/HostAppearanceStore.js +111 -0
  115. package/lib/commonjs/provider/HostAppearanceStore.js.map +1 -0
  116. package/lib/commonjs/provider/KokoProvider.js +81 -0
  117. package/lib/commonjs/provider/KokoProvider.js.map +1 -0
  118. package/lib/commonjs/provider/KokoUiContext.js +102 -0
  119. package/lib/commonjs/provider/KokoUiContext.js.map +1 -0
  120. package/lib/commonjs/selector/match.js +378 -0
  121. package/lib/commonjs/selector/match.js.map +1 -0
  122. package/lib/commonjs/task/TaskStore.js +361 -0
  123. package/lib/commonjs/task/TaskStore.js.map +1 -0
  124. package/lib/commonjs/task/types.js +2 -0
  125. package/lib/commonjs/task/types.js.map +1 -0
  126. package/lib/commonjs/task/useTaskStore.js +14 -0
  127. package/lib/commonjs/task/useTaskStore.js.map +1 -0
  128. package/lib/commonjs/types.js +2 -0
  129. package/lib/commonjs/types.js.map +1 -0
  130. package/lib/commonjs/ui/KokoChatSheet.js +885 -0
  131. package/lib/commonjs/ui/KokoChatSheet.js.map +1 -0
  132. package/lib/commonjs/ui/KokoComposer.js +161 -0
  133. package/lib/commonjs/ui/KokoComposer.js.map +1 -0
  134. package/lib/commonjs/ui/KokoDialogHost.js +254 -0
  135. package/lib/commonjs/ui/KokoDialogHost.js.map +1 -0
  136. package/lib/commonjs/ui/KokoEntryButton.js +81 -0
  137. package/lib/commonjs/ui/KokoEntryButton.js.map +1 -0
  138. package/lib/commonjs/ui/KokoObserver.js +522 -0
  139. package/lib/commonjs/ui/KokoObserver.js.map +1 -0
  140. package/lib/commonjs/ui/KokoOverlayLayer.js +45 -0
  141. package/lib/commonjs/ui/KokoOverlayLayer.js.map +1 -0
  142. package/lib/commonjs/ui/KokoSubtitle.js +95 -0
  143. package/lib/commonjs/ui/KokoSubtitle.js.map +1 -0
  144. package/lib/commonjs/ui/KokoTaskPanel.js +322 -0
  145. package/lib/commonjs/ui/KokoTaskPanel.js.map +1 -0
  146. package/lib/commonjs/ui/hostOverlay.js +126 -0
  147. package/lib/commonjs/ui/hostOverlay.js.map +1 -0
  148. package/lib/commonjs/ui/icons.js +132 -0
  149. package/lib/commonjs/ui/icons.js.map +1 -0
  150. package/lib/commonjs/ui/progressChrome.js +66 -0
  151. package/lib/commonjs/ui/progressChrome.js.map +1 -0
  152. package/lib/commonjs/ui/safeArea.js +96 -0
  153. package/lib/commonjs/ui/safeArea.js.map +1 -0
  154. package/lib/commonjs/ui/useOverlayOrigin.js +40 -0
  155. package/lib/commonjs/ui/useOverlayOrigin.js.map +1 -0
  156. package/lib/module/KokoAgent.js +1418 -0
  157. package/lib/module/KokoAgent.js.map +1 -0
  158. package/lib/module/assist/OnDeviceAssist.js +89 -0
  159. package/lib/module/assist/OnDeviceAssist.js.map +1 -0
  160. package/lib/module/assist/intentClassify.js +95 -0
  161. package/lib/module/assist/intentClassify.js.map +1 -0
  162. package/lib/module/assist/nodeRank.js +115 -0
  163. package/lib/module/assist/nodeRank.js.map +1 -0
  164. package/lib/module/assist/ocrTarget.js +123 -0
  165. package/lib/module/assist/ocrTarget.js.map +1 -0
  166. package/lib/module/assist/webVisualChange.js +24 -0
  167. package/lib/module/assist/webVisualChange.js.map +1 -0
  168. package/lib/module/client/ActionOutcomeUnknownError.js +23 -0
  169. package/lib/module/client/ActionOutcomeUnknownError.js.map +1 -0
  170. package/lib/module/client/AgentSession.js +854 -0
  171. package/lib/module/client/AgentSession.js.map +1 -0
  172. package/lib/module/client/GatewayClient.js +293 -0
  173. package/lib/module/client/GatewayClient.js.map +1 -0
  174. package/lib/module/client/OperationReplayGuard.js +58 -0
  175. package/lib/module/client/OperationReplayGuard.js.map +1 -0
  176. package/lib/module/client/RunCheckpoint.js +135 -0
  177. package/lib/module/client/RunCheckpoint.js.map +1 -0
  178. package/lib/module/client/loopDetect.js +177 -0
  179. package/lib/module/client/loopDetect.js.map +1 -0
  180. package/lib/module/client/recentSearch.js +46 -0
  181. package/lib/module/client/recentSearch.js.map +1 -0
  182. package/lib/module/client/walletChoiceGuard.js +14 -0
  183. package/lib/module/client/walletChoiceGuard.js.map +1 -0
  184. package/lib/module/client/webResultCategory.js +34 -0
  185. package/lib/module/client/webResultCategory.js.map +1 -0
  186. package/lib/module/commercial/AccountStore.js +75 -0
  187. package/lib/module/commercial/AccountStore.js.map +1 -0
  188. package/lib/module/commercial/AgentDebug.js +99 -0
  189. package/lib/module/commercial/AgentDebug.js.map +1 -0
  190. package/lib/module/commercial/ExecutionGuard.js +49 -0
  191. package/lib/module/commercial/ExecutionGuard.js.map +1 -0
  192. package/lib/module/commercial/UsageBus.js +38 -0
  193. package/lib/module/commercial/UsageBus.js.map +1 -0
  194. package/lib/module/commercial/branding.js +63 -0
  195. package/lib/module/commercial/branding.js.map +1 -0
  196. package/lib/module/commercial/devMode.js +45 -0
  197. package/lib/module/commercial/devMode.js.map +1 -0
  198. package/lib/module/commercial/trust.js +62 -0
  199. package/lib/module/commercial/trust.js.map +1 -0
  200. package/lib/module/confirmation/gate.js +54 -0
  201. package/lib/module/confirmation/gate.js.map +1 -0
  202. package/lib/module/cursor/CursorOverlay.js +136 -0
  203. package/lib/module/cursor/CursorOverlay.js.map +1 -0
  204. package/lib/module/cursor/PointerHand.js +47 -0
  205. package/lib/module/cursor/PointerHand.js.map +1 -0
  206. package/lib/module/cursor/controller.js +87 -0
  207. package/lib/module/cursor/controller.js.map +1 -0
  208. package/lib/module/cursor/pointer.js +45 -0
  209. package/lib/module/cursor/pointer.js.map +1 -0
  210. package/lib/module/debug/KokoRemoteSmoke.js +608 -0
  211. package/lib/module/debug/KokoRemoteSmoke.js.map +1 -0
  212. package/lib/module/explore/ExplorationGraph.js +406 -0
  213. package/lib/module/explore/ExplorationGraph.js.map +1 -0
  214. package/lib/module/explore/bootstrapExplore.js +55 -0
  215. package/lib/module/explore/bootstrapExplore.js.map +1 -0
  216. package/lib/module/host/HostActions.js +255 -0
  217. package/lib/module/host/HostActions.js.map +1 -0
  218. package/lib/module/i18n/index.js +159 -0
  219. package/lib/module/i18n/index.js.map +1 -0
  220. package/lib/module/i18n/runtimeMessages.js +180 -0
  221. package/lib/module/i18n/runtimeMessages.js.map +1 -0
  222. package/lib/module/index.js +44 -0
  223. package/lib/module/index.js.map +1 -0
  224. package/lib/module/native/NativeBridge.js +128 -0
  225. package/lib/module/native/NativeBridge.js.map +1 -0
  226. package/lib/module/native/navigationLabel.js +12 -0
  227. package/lib/module/native/navigationLabel.js.map +1 -0
  228. package/lib/module/native/normalizeViewTree.js +25 -0
  229. package/lib/module/native/normalizeViewTree.js.map +1 -0
  230. package/lib/module/native/pruneOffscreen.js +72 -0
  231. package/lib/module/native/pruneOffscreen.js.map +1 -0
  232. package/lib/module/native/scrollViewport.js +63 -0
  233. package/lib/module/native/scrollViewport.js.map +1 -0
  234. package/lib/module/package.json +1 -0
  235. package/lib/module/privacy/redact.js +103 -0
  236. package/lib/module/privacy/redact.js.map +1 -0
  237. package/lib/module/privacy/screenEvidence.js +50 -0
  238. package/lib/module/privacy/screenEvidence.js.map +1 -0
  239. package/lib/module/privacy/screenModel.js +397 -0
  240. package/lib/module/privacy/screenModel.js.map +1 -0
  241. package/lib/module/privacy/sensitiveScreen.js +52 -0
  242. package/lib/module/privacy/sensitiveScreen.js.map +1 -0
  243. package/lib/module/privacy/userGate.js +202 -0
  244. package/lib/module/privacy/userGate.js.map +1 -0
  245. package/lib/module/protocol/actions.js +108 -0
  246. package/lib/module/protocol/actions.js.map +1 -0
  247. package/lib/module/provider/HostAppearanceStore.js +101 -0
  248. package/lib/module/provider/HostAppearanceStore.js.map +1 -0
  249. package/lib/module/provider/KokoProvider.js +74 -0
  250. package/lib/module/provider/KokoProvider.js.map +1 -0
  251. package/lib/module/provider/KokoUiContext.js +96 -0
  252. package/lib/module/provider/KokoUiContext.js.map +1 -0
  253. package/lib/module/selector/match.js +366 -0
  254. package/lib/module/selector/match.js.map +1 -0
  255. package/lib/module/task/TaskStore.js +356 -0
  256. package/lib/module/task/TaskStore.js.map +1 -0
  257. package/lib/module/task/types.js +2 -0
  258. package/lib/module/task/types.js.map +1 -0
  259. package/lib/module/task/useTaskStore.js +10 -0
  260. package/lib/module/task/useTaskStore.js.map +1 -0
  261. package/lib/module/types.js +2 -0
  262. package/lib/module/types.js.map +1 -0
  263. package/lib/module/ui/KokoChatSheet.js +879 -0
  264. package/lib/module/ui/KokoChatSheet.js.map +1 -0
  265. package/lib/module/ui/KokoComposer.js +155 -0
  266. package/lib/module/ui/KokoComposer.js.map +1 -0
  267. package/lib/module/ui/KokoDialogHost.js +247 -0
  268. package/lib/module/ui/KokoDialogHost.js.map +1 -0
  269. package/lib/module/ui/KokoEntryButton.js +74 -0
  270. package/lib/module/ui/KokoEntryButton.js.map +1 -0
  271. package/lib/module/ui/KokoObserver.js +516 -0
  272. package/lib/module/ui/KokoObserver.js.map +1 -0
  273. package/lib/module/ui/KokoOverlayLayer.js +39 -0
  274. package/lib/module/ui/KokoOverlayLayer.js.map +1 -0
  275. package/lib/module/ui/KokoSubtitle.js +90 -0
  276. package/lib/module/ui/KokoSubtitle.js.map +1 -0
  277. package/lib/module/ui/KokoTaskPanel.js +316 -0
  278. package/lib/module/ui/KokoTaskPanel.js.map +1 -0
  279. package/lib/module/ui/hostOverlay.js +120 -0
  280. package/lib/module/ui/hostOverlay.js.map +1 -0
  281. package/lib/module/ui/icons.js +124 -0
  282. package/lib/module/ui/icons.js.map +1 -0
  283. package/lib/module/ui/progressChrome.js +58 -0
  284. package/lib/module/ui/progressChrome.js.map +1 -0
  285. package/lib/module/ui/safeArea.js +92 -0
  286. package/lib/module/ui/safeArea.js.map +1 -0
  287. package/lib/module/ui/useOverlayOrigin.js +36 -0
  288. package/lib/module/ui/useOverlayOrigin.js.map +1 -0
  289. package/lib/typescript/commonjs/KokoAgent.d.ts +167 -0
  290. package/lib/typescript/commonjs/KokoAgent.d.ts.map +1 -0
  291. package/lib/typescript/commonjs/assist/OnDeviceAssist.d.ts +31 -0
  292. package/lib/typescript/commonjs/assist/OnDeviceAssist.d.ts.map +1 -0
  293. package/lib/typescript/commonjs/assist/intentClassify.d.ts +18 -0
  294. package/lib/typescript/commonjs/assist/intentClassify.d.ts.map +1 -0
  295. package/lib/typescript/commonjs/assist/nodeRank.d.ts +32 -0
  296. package/lib/typescript/commonjs/assist/nodeRank.d.ts.map +1 -0
  297. package/lib/typescript/commonjs/assist/ocrTarget.d.ts +25 -0
  298. package/lib/typescript/commonjs/assist/ocrTarget.d.ts.map +1 -0
  299. package/lib/typescript/commonjs/assist/webVisualChange.d.ts +6 -0
  300. package/lib/typescript/commonjs/assist/webVisualChange.d.ts.map +1 -0
  301. package/lib/typescript/commonjs/client/ActionOutcomeUnknownError.d.ts +13 -0
  302. package/lib/typescript/commonjs/client/ActionOutcomeUnknownError.d.ts.map +1 -0
  303. package/lib/typescript/commonjs/client/AgentSession.d.ts +56 -0
  304. package/lib/typescript/commonjs/client/AgentSession.d.ts.map +1 -0
  305. package/lib/typescript/commonjs/client/GatewayClient.d.ts +149 -0
  306. package/lib/typescript/commonjs/client/GatewayClient.d.ts.map +1 -0
  307. package/lib/typescript/commonjs/client/OperationReplayGuard.d.ts +13 -0
  308. package/lib/typescript/commonjs/client/OperationReplayGuard.d.ts.map +1 -0
  309. package/lib/typescript/commonjs/client/RunCheckpoint.d.ts +57 -0
  310. package/lib/typescript/commonjs/client/RunCheckpoint.d.ts.map +1 -0
  311. package/lib/typescript/commonjs/client/loopDetect.d.ts +15 -0
  312. package/lib/typescript/commonjs/client/loopDetect.d.ts.map +1 -0
  313. package/lib/typescript/commonjs/client/recentSearch.d.ts +5 -0
  314. package/lib/typescript/commonjs/client/recentSearch.d.ts.map +1 -0
  315. package/lib/typescript/commonjs/client/walletChoiceGuard.d.ts +4 -0
  316. package/lib/typescript/commonjs/client/walletChoiceGuard.d.ts.map +1 -0
  317. package/lib/typescript/commonjs/client/webResultCategory.d.ts +5 -0
  318. package/lib/typescript/commonjs/client/webResultCategory.d.ts.map +1 -0
  319. package/lib/typescript/commonjs/commercial/AccountStore.d.ts +17 -0
  320. package/lib/typescript/commonjs/commercial/AccountStore.d.ts.map +1 -0
  321. package/lib/typescript/commonjs/commercial/AgentDebug.d.ts +25 -0
  322. package/lib/typescript/commonjs/commercial/AgentDebug.d.ts.map +1 -0
  323. package/lib/typescript/commonjs/commercial/ExecutionGuard.d.ts +18 -0
  324. package/lib/typescript/commonjs/commercial/ExecutionGuard.d.ts.map +1 -0
  325. package/lib/typescript/commonjs/commercial/UsageBus.d.ts +18 -0
  326. package/lib/typescript/commonjs/commercial/UsageBus.d.ts.map +1 -0
  327. package/lib/typescript/commonjs/commercial/branding.d.ts +25 -0
  328. package/lib/typescript/commonjs/commercial/branding.d.ts.map +1 -0
  329. package/lib/typescript/commonjs/commercial/devMode.d.ts +26 -0
  330. package/lib/typescript/commonjs/commercial/devMode.d.ts.map +1 -0
  331. package/lib/typescript/commonjs/commercial/trust.d.ts +21 -0
  332. package/lib/typescript/commonjs/commercial/trust.d.ts.map +1 -0
  333. package/lib/typescript/commonjs/confirmation/gate.d.ts +18 -0
  334. package/lib/typescript/commonjs/confirmation/gate.d.ts.map +1 -0
  335. package/lib/typescript/commonjs/cursor/CursorOverlay.d.ts +13 -0
  336. package/lib/typescript/commonjs/cursor/CursorOverlay.d.ts.map +1 -0
  337. package/lib/typescript/commonjs/cursor/PointerHand.d.ts +16 -0
  338. package/lib/typescript/commonjs/cursor/PointerHand.d.ts.map +1 -0
  339. package/lib/typescript/commonjs/cursor/controller.d.ts +30 -0
  340. package/lib/typescript/commonjs/cursor/controller.d.ts.map +1 -0
  341. package/lib/typescript/commonjs/cursor/pointer.d.ts +23 -0
  342. package/lib/typescript/commonjs/cursor/pointer.d.ts.map +1 -0
  343. package/lib/typescript/commonjs/debug/KokoRemoteSmoke.d.ts +96 -0
  344. package/lib/typescript/commonjs/debug/KokoRemoteSmoke.d.ts.map +1 -0
  345. package/lib/typescript/commonjs/explore/ExplorationGraph.d.ts +96 -0
  346. package/lib/typescript/commonjs/explore/ExplorationGraph.d.ts.map +1 -0
  347. package/lib/typescript/commonjs/explore/bootstrapExplore.d.ts +40 -0
  348. package/lib/typescript/commonjs/explore/bootstrapExplore.d.ts.map +1 -0
  349. package/lib/typescript/commonjs/host/HostActions.d.ts +101 -0
  350. package/lib/typescript/commonjs/host/HostActions.d.ts.map +1 -0
  351. package/lib/typescript/commonjs/i18n/index.d.ts +20 -0
  352. package/lib/typescript/commonjs/i18n/index.d.ts.map +1 -0
  353. package/lib/typescript/commonjs/i18n/runtimeMessages.d.ts +178 -0
  354. package/lib/typescript/commonjs/i18n/runtimeMessages.d.ts.map +1 -0
  355. package/lib/typescript/commonjs/index.d.ts +66 -0
  356. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  357. package/lib/typescript/commonjs/native/NativeBridge.d.ts +70 -0
  358. package/lib/typescript/commonjs/native/NativeBridge.d.ts.map +1 -0
  359. package/lib/typescript/commonjs/native/navigationLabel.d.ts +4 -0
  360. package/lib/typescript/commonjs/native/navigationLabel.d.ts.map +1 -0
  361. package/lib/typescript/commonjs/native/normalizeViewTree.d.ts +4 -0
  362. package/lib/typescript/commonjs/native/normalizeViewTree.d.ts.map +1 -0
  363. package/lib/typescript/commonjs/native/pruneOffscreen.d.ts +3 -0
  364. package/lib/typescript/commonjs/native/pruneOffscreen.d.ts.map +1 -0
  365. package/lib/typescript/commonjs/native/scrollViewport.d.ts +13 -0
  366. package/lib/typescript/commonjs/native/scrollViewport.d.ts.map +1 -0
  367. package/lib/typescript/commonjs/package.json +1 -0
  368. package/lib/typescript/commonjs/privacy/redact.d.ts +9 -0
  369. package/lib/typescript/commonjs/privacy/redact.d.ts.map +1 -0
  370. package/lib/typescript/commonjs/privacy/screenEvidence.d.ts +14 -0
  371. package/lib/typescript/commonjs/privacy/screenEvidence.d.ts.map +1 -0
  372. package/lib/typescript/commonjs/privacy/screenModel.d.ts +26 -0
  373. package/lib/typescript/commonjs/privacy/screenModel.d.ts.map +1 -0
  374. package/lib/typescript/commonjs/privacy/sensitiveScreen.d.ts +8 -0
  375. package/lib/typescript/commonjs/privacy/sensitiveScreen.d.ts.map +1 -0
  376. package/lib/typescript/commonjs/privacy/userGate.d.ts +58 -0
  377. package/lib/typescript/commonjs/privacy/userGate.d.ts.map +1 -0
  378. package/lib/typescript/commonjs/protocol/actions.d.ts +7 -0
  379. package/lib/typescript/commonjs/protocol/actions.d.ts.map +1 -0
  380. package/lib/typescript/commonjs/provider/HostAppearanceStore.d.ts +64 -0
  381. package/lib/typescript/commonjs/provider/HostAppearanceStore.d.ts.map +1 -0
  382. package/lib/typescript/commonjs/provider/KokoProvider.d.ts +39 -0
  383. package/lib/typescript/commonjs/provider/KokoProvider.d.ts.map +1 -0
  384. package/lib/typescript/commonjs/provider/KokoUiContext.d.ts +22 -0
  385. package/lib/typescript/commonjs/provider/KokoUiContext.d.ts.map +1 -0
  386. package/lib/typescript/commonjs/selector/match.d.ts +27 -0
  387. package/lib/typescript/commonjs/selector/match.d.ts.map +1 -0
  388. package/lib/typescript/commonjs/task/TaskStore.d.ts +65 -0
  389. package/lib/typescript/commonjs/task/TaskStore.d.ts.map +1 -0
  390. package/lib/typescript/commonjs/task/types.d.ts +66 -0
  391. package/lib/typescript/commonjs/task/types.d.ts.map +1 -0
  392. package/lib/typescript/commonjs/task/useTaskStore.d.ts +3 -0
  393. package/lib/typescript/commonjs/task/useTaskStore.d.ts.map +1 -0
  394. package/lib/typescript/commonjs/types.d.ts +372 -0
  395. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  396. package/lib/typescript/commonjs/ui/KokoChatSheet.d.ts +8 -0
  397. package/lib/typescript/commonjs/ui/KokoChatSheet.d.ts.map +1 -0
  398. package/lib/typescript/commonjs/ui/KokoComposer.d.ts +13 -0
  399. package/lib/typescript/commonjs/ui/KokoComposer.d.ts.map +1 -0
  400. package/lib/typescript/commonjs/ui/KokoDialogHost.d.ts +32 -0
  401. package/lib/typescript/commonjs/ui/KokoDialogHost.d.ts.map +1 -0
  402. package/lib/typescript/commonjs/ui/KokoEntryButton.d.ts +18 -0
  403. package/lib/typescript/commonjs/ui/KokoEntryButton.d.ts.map +1 -0
  404. package/lib/typescript/commonjs/ui/KokoObserver.d.ts +13 -0
  405. package/lib/typescript/commonjs/ui/KokoObserver.d.ts.map +1 -0
  406. package/lib/typescript/commonjs/ui/KokoOverlayLayer.d.ts +35 -0
  407. package/lib/typescript/commonjs/ui/KokoOverlayLayer.d.ts.map +1 -0
  408. package/lib/typescript/commonjs/ui/KokoSubtitle.d.ts +7 -0
  409. package/lib/typescript/commonjs/ui/KokoSubtitle.d.ts.map +1 -0
  410. package/lib/typescript/commonjs/ui/KokoTaskPanel.d.ts +7 -0
  411. package/lib/typescript/commonjs/ui/KokoTaskPanel.d.ts.map +1 -0
  412. package/lib/typescript/commonjs/ui/hostOverlay.d.ts +28 -0
  413. package/lib/typescript/commonjs/ui/hostOverlay.d.ts.map +1 -0
  414. package/lib/typescript/commonjs/ui/icons.d.ts +26 -0
  415. package/lib/typescript/commonjs/ui/icons.d.ts.map +1 -0
  416. package/lib/typescript/commonjs/ui/progressChrome.d.ts +21 -0
  417. package/lib/typescript/commonjs/ui/progressChrome.d.ts.map +1 -0
  418. package/lib/typescript/commonjs/ui/safeArea.d.ts +12 -0
  419. package/lib/typescript/commonjs/ui/safeArea.d.ts.map +1 -0
  420. package/lib/typescript/commonjs/ui/useOverlayOrigin.d.ts +22 -0
  421. package/lib/typescript/commonjs/ui/useOverlayOrigin.d.ts.map +1 -0
  422. package/lib/typescript/module/KokoAgent.d.ts +167 -0
  423. package/lib/typescript/module/KokoAgent.d.ts.map +1 -0
  424. package/lib/typescript/module/assist/OnDeviceAssist.d.ts +31 -0
  425. package/lib/typescript/module/assist/OnDeviceAssist.d.ts.map +1 -0
  426. package/lib/typescript/module/assist/intentClassify.d.ts +18 -0
  427. package/lib/typescript/module/assist/intentClassify.d.ts.map +1 -0
  428. package/lib/typescript/module/assist/nodeRank.d.ts +32 -0
  429. package/lib/typescript/module/assist/nodeRank.d.ts.map +1 -0
  430. package/lib/typescript/module/assist/ocrTarget.d.ts +25 -0
  431. package/lib/typescript/module/assist/ocrTarget.d.ts.map +1 -0
  432. package/lib/typescript/module/assist/webVisualChange.d.ts +6 -0
  433. package/lib/typescript/module/assist/webVisualChange.d.ts.map +1 -0
  434. package/lib/typescript/module/client/ActionOutcomeUnknownError.d.ts +13 -0
  435. package/lib/typescript/module/client/ActionOutcomeUnknownError.d.ts.map +1 -0
  436. package/lib/typescript/module/client/AgentSession.d.ts +56 -0
  437. package/lib/typescript/module/client/AgentSession.d.ts.map +1 -0
  438. package/lib/typescript/module/client/GatewayClient.d.ts +149 -0
  439. package/lib/typescript/module/client/GatewayClient.d.ts.map +1 -0
  440. package/lib/typescript/module/client/OperationReplayGuard.d.ts +13 -0
  441. package/lib/typescript/module/client/OperationReplayGuard.d.ts.map +1 -0
  442. package/lib/typescript/module/client/RunCheckpoint.d.ts +57 -0
  443. package/lib/typescript/module/client/RunCheckpoint.d.ts.map +1 -0
  444. package/lib/typescript/module/client/loopDetect.d.ts +15 -0
  445. package/lib/typescript/module/client/loopDetect.d.ts.map +1 -0
  446. package/lib/typescript/module/client/recentSearch.d.ts +5 -0
  447. package/lib/typescript/module/client/recentSearch.d.ts.map +1 -0
  448. package/lib/typescript/module/client/walletChoiceGuard.d.ts +4 -0
  449. package/lib/typescript/module/client/walletChoiceGuard.d.ts.map +1 -0
  450. package/lib/typescript/module/client/webResultCategory.d.ts +5 -0
  451. package/lib/typescript/module/client/webResultCategory.d.ts.map +1 -0
  452. package/lib/typescript/module/commercial/AccountStore.d.ts +17 -0
  453. package/lib/typescript/module/commercial/AccountStore.d.ts.map +1 -0
  454. package/lib/typescript/module/commercial/AgentDebug.d.ts +25 -0
  455. package/lib/typescript/module/commercial/AgentDebug.d.ts.map +1 -0
  456. package/lib/typescript/module/commercial/ExecutionGuard.d.ts +18 -0
  457. package/lib/typescript/module/commercial/ExecutionGuard.d.ts.map +1 -0
  458. package/lib/typescript/module/commercial/UsageBus.d.ts +18 -0
  459. package/lib/typescript/module/commercial/UsageBus.d.ts.map +1 -0
  460. package/lib/typescript/module/commercial/branding.d.ts +25 -0
  461. package/lib/typescript/module/commercial/branding.d.ts.map +1 -0
  462. package/lib/typescript/module/commercial/devMode.d.ts +26 -0
  463. package/lib/typescript/module/commercial/devMode.d.ts.map +1 -0
  464. package/lib/typescript/module/commercial/trust.d.ts +21 -0
  465. package/lib/typescript/module/commercial/trust.d.ts.map +1 -0
  466. package/lib/typescript/module/confirmation/gate.d.ts +18 -0
  467. package/lib/typescript/module/confirmation/gate.d.ts.map +1 -0
  468. package/lib/typescript/module/cursor/CursorOverlay.d.ts +13 -0
  469. package/lib/typescript/module/cursor/CursorOverlay.d.ts.map +1 -0
  470. package/lib/typescript/module/cursor/PointerHand.d.ts +16 -0
  471. package/lib/typescript/module/cursor/PointerHand.d.ts.map +1 -0
  472. package/lib/typescript/module/cursor/controller.d.ts +30 -0
  473. package/lib/typescript/module/cursor/controller.d.ts.map +1 -0
  474. package/lib/typescript/module/cursor/pointer.d.ts +23 -0
  475. package/lib/typescript/module/cursor/pointer.d.ts.map +1 -0
  476. package/lib/typescript/module/debug/KokoRemoteSmoke.d.ts +96 -0
  477. package/lib/typescript/module/debug/KokoRemoteSmoke.d.ts.map +1 -0
  478. package/lib/typescript/module/explore/ExplorationGraph.d.ts +96 -0
  479. package/lib/typescript/module/explore/ExplorationGraph.d.ts.map +1 -0
  480. package/lib/typescript/module/explore/bootstrapExplore.d.ts +40 -0
  481. package/lib/typescript/module/explore/bootstrapExplore.d.ts.map +1 -0
  482. package/lib/typescript/module/host/HostActions.d.ts +101 -0
  483. package/lib/typescript/module/host/HostActions.d.ts.map +1 -0
  484. package/lib/typescript/module/i18n/index.d.ts +20 -0
  485. package/lib/typescript/module/i18n/index.d.ts.map +1 -0
  486. package/lib/typescript/module/i18n/runtimeMessages.d.ts +178 -0
  487. package/lib/typescript/module/i18n/runtimeMessages.d.ts.map +1 -0
  488. package/lib/typescript/module/index.d.ts +66 -0
  489. package/lib/typescript/module/index.d.ts.map +1 -0
  490. package/lib/typescript/module/native/NativeBridge.d.ts +70 -0
  491. package/lib/typescript/module/native/NativeBridge.d.ts.map +1 -0
  492. package/lib/typescript/module/native/navigationLabel.d.ts +4 -0
  493. package/lib/typescript/module/native/navigationLabel.d.ts.map +1 -0
  494. package/lib/typescript/module/native/normalizeViewTree.d.ts +4 -0
  495. package/lib/typescript/module/native/normalizeViewTree.d.ts.map +1 -0
  496. package/lib/typescript/module/native/pruneOffscreen.d.ts +3 -0
  497. package/lib/typescript/module/native/pruneOffscreen.d.ts.map +1 -0
  498. package/lib/typescript/module/native/scrollViewport.d.ts +13 -0
  499. package/lib/typescript/module/native/scrollViewport.d.ts.map +1 -0
  500. package/lib/typescript/module/package.json +1 -0
  501. package/lib/typescript/module/privacy/redact.d.ts +9 -0
  502. package/lib/typescript/module/privacy/redact.d.ts.map +1 -0
  503. package/lib/typescript/module/privacy/screenEvidence.d.ts +14 -0
  504. package/lib/typescript/module/privacy/screenEvidence.d.ts.map +1 -0
  505. package/lib/typescript/module/privacy/screenModel.d.ts +26 -0
  506. package/lib/typescript/module/privacy/screenModel.d.ts.map +1 -0
  507. package/lib/typescript/module/privacy/sensitiveScreen.d.ts +8 -0
  508. package/lib/typescript/module/privacy/sensitiveScreen.d.ts.map +1 -0
  509. package/lib/typescript/module/privacy/userGate.d.ts +58 -0
  510. package/lib/typescript/module/privacy/userGate.d.ts.map +1 -0
  511. package/lib/typescript/module/protocol/actions.d.ts +7 -0
  512. package/lib/typescript/module/protocol/actions.d.ts.map +1 -0
  513. package/lib/typescript/module/provider/HostAppearanceStore.d.ts +64 -0
  514. package/lib/typescript/module/provider/HostAppearanceStore.d.ts.map +1 -0
  515. package/lib/typescript/module/provider/KokoProvider.d.ts +39 -0
  516. package/lib/typescript/module/provider/KokoProvider.d.ts.map +1 -0
  517. package/lib/typescript/module/provider/KokoUiContext.d.ts +22 -0
  518. package/lib/typescript/module/provider/KokoUiContext.d.ts.map +1 -0
  519. package/lib/typescript/module/selector/match.d.ts +27 -0
  520. package/lib/typescript/module/selector/match.d.ts.map +1 -0
  521. package/lib/typescript/module/task/TaskStore.d.ts +65 -0
  522. package/lib/typescript/module/task/TaskStore.d.ts.map +1 -0
  523. package/lib/typescript/module/task/types.d.ts +66 -0
  524. package/lib/typescript/module/task/types.d.ts.map +1 -0
  525. package/lib/typescript/module/task/useTaskStore.d.ts +3 -0
  526. package/lib/typescript/module/task/useTaskStore.d.ts.map +1 -0
  527. package/lib/typescript/module/types.d.ts +372 -0
  528. package/lib/typescript/module/types.d.ts.map +1 -0
  529. package/lib/typescript/module/ui/KokoChatSheet.d.ts +8 -0
  530. package/lib/typescript/module/ui/KokoChatSheet.d.ts.map +1 -0
  531. package/lib/typescript/module/ui/KokoComposer.d.ts +13 -0
  532. package/lib/typescript/module/ui/KokoComposer.d.ts.map +1 -0
  533. package/lib/typescript/module/ui/KokoDialogHost.d.ts +32 -0
  534. package/lib/typescript/module/ui/KokoDialogHost.d.ts.map +1 -0
  535. package/lib/typescript/module/ui/KokoEntryButton.d.ts +18 -0
  536. package/lib/typescript/module/ui/KokoEntryButton.d.ts.map +1 -0
  537. package/lib/typescript/module/ui/KokoObserver.d.ts +13 -0
  538. package/lib/typescript/module/ui/KokoObserver.d.ts.map +1 -0
  539. package/lib/typescript/module/ui/KokoOverlayLayer.d.ts +35 -0
  540. package/lib/typescript/module/ui/KokoOverlayLayer.d.ts.map +1 -0
  541. package/lib/typescript/module/ui/KokoSubtitle.d.ts +7 -0
  542. package/lib/typescript/module/ui/KokoSubtitle.d.ts.map +1 -0
  543. package/lib/typescript/module/ui/KokoTaskPanel.d.ts +7 -0
  544. package/lib/typescript/module/ui/KokoTaskPanel.d.ts.map +1 -0
  545. package/lib/typescript/module/ui/hostOverlay.d.ts +28 -0
  546. package/lib/typescript/module/ui/hostOverlay.d.ts.map +1 -0
  547. package/lib/typescript/module/ui/icons.d.ts +26 -0
  548. package/lib/typescript/module/ui/icons.d.ts.map +1 -0
  549. package/lib/typescript/module/ui/progressChrome.d.ts +21 -0
  550. package/lib/typescript/module/ui/progressChrome.d.ts.map +1 -0
  551. package/lib/typescript/module/ui/safeArea.d.ts +12 -0
  552. package/lib/typescript/module/ui/safeArea.d.ts.map +1 -0
  553. package/lib/typescript/module/ui/useOverlayOrigin.d.ts +22 -0
  554. package/lib/typescript/module/ui/useOverlayOrigin.d.ts.map +1 -0
  555. package/package.json +153 -0
  556. package/react-native.config.js +12 -0
  557. package/src/KokoAgent.ts +1415 -0
  558. package/src/assist/OnDeviceAssist.ts +133 -0
  559. package/src/assist/intentClassify.ts +122 -0
  560. package/src/assist/nodeRank.ts +167 -0
  561. package/src/assist/ocrTarget.ts +146 -0
  562. package/src/assist/webVisualChange.ts +24 -0
  563. package/src/client/ActionOutcomeUnknownError.ts +18 -0
  564. package/src/client/AgentSession.ts +952 -0
  565. package/src/client/GatewayClient.ts +439 -0
  566. package/src/client/OperationReplayGuard.ts +61 -0
  567. package/src/client/RunCheckpoint.ts +154 -0
  568. package/src/client/loopDetect.ts +213 -0
  569. package/src/client/recentSearch.ts +47 -0
  570. package/src/client/walletChoiceGuard.ts +15 -0
  571. package/src/client/webResultCategory.ts +28 -0
  572. package/src/commercial/AccountStore.ts +85 -0
  573. package/src/commercial/AgentDebug.ts +142 -0
  574. package/src/commercial/ExecutionGuard.ts +67 -0
  575. package/src/commercial/UsageBus.ts +44 -0
  576. package/src/commercial/branding.ts +97 -0
  577. package/src/commercial/devMode.ts +48 -0
  578. package/src/commercial/trust.ts +67 -0
  579. package/src/confirmation/gate.ts +82 -0
  580. package/src/cursor/CursorOverlay.tsx +138 -0
  581. package/src/cursor/PointerHand.tsx +49 -0
  582. package/src/cursor/controller.ts +98 -0
  583. package/src/cursor/pointer.ts +40 -0
  584. package/src/debug/KokoRemoteSmoke.tsx +561 -0
  585. package/src/explore/ExplorationGraph.ts +518 -0
  586. package/src/explore/bootstrapExplore.ts +89 -0
  587. package/src/host/HostActions.ts +349 -0
  588. package/src/i18n/index.ts +229 -0
  589. package/src/i18n/runtimeMessages.ts +180 -0
  590. package/src/index.ts +203 -0
  591. package/src/native/NativeBridge.ts +207 -0
  592. package/src/native/navigationLabel.ts +11 -0
  593. package/src/native/normalizeViewTree.ts +16 -0
  594. package/src/native/pruneOffscreen.ts +72 -0
  595. package/src/native/scrollViewport.ts +51 -0
  596. package/src/privacy/redact.ts +115 -0
  597. package/src/privacy/screenEvidence.ts +55 -0
  598. package/src/privacy/screenModel.ts +504 -0
  599. package/src/privacy/sensitiveScreen.ts +55 -0
  600. package/src/privacy/userGate.ts +233 -0
  601. package/src/protocol/actions.ts +66 -0
  602. package/src/provider/HostAppearanceStore.ts +148 -0
  603. package/src/provider/KokoProvider.tsx +118 -0
  604. package/src/provider/KokoUiContext.tsx +162 -0
  605. package/src/selector/match.ts +417 -0
  606. package/src/task/TaskStore.ts +387 -0
  607. package/src/task/types.ts +82 -0
  608. package/src/task/useTaskStore.ts +9 -0
  609. package/src/types.ts +318 -0
  610. package/src/ui/KokoChatSheet.tsx +930 -0
  611. package/src/ui/KokoComposer.tsx +174 -0
  612. package/src/ui/KokoDialogHost.tsx +249 -0
  613. package/src/ui/KokoEntryButton.tsx +74 -0
  614. package/src/ui/KokoObserver.tsx +587 -0
  615. package/src/ui/KokoOverlayLayer.tsx +53 -0
  616. package/src/ui/KokoSubtitle.tsx +80 -0
  617. package/src/ui/KokoTaskPanel.tsx +299 -0
  618. package/src/ui/hostOverlay.tsx +148 -0
  619. package/src/ui/icons.tsx +145 -0
  620. package/src/ui/progressChrome.ts +73 -0
  621. package/src/ui/safeArea.ts +95 -0
  622. package/src/ui/useOverlayOrigin.ts +29 -0
@@ -0,0 +1,366 @@
1
+ "use strict";
2
+
3
+ function norm(s) {
4
+ return s.trim().toLowerCase();
5
+ }
6
+
7
+ /**
8
+ * Strip particles models often invent around a real on-screen label
9
+ * (「创建钱包」→「创建新钱包」/「立即创建钱包」). Host-agnostic fillers only.
10
+ */
11
+ function softKey(s) {
12
+ return norm(s).replace(/[\s\-_./·•::()()【】[\]]+/g, '').replace(/^(请|立即|马上|点击|轻点|去|进入|开始|打开)+|(按钮|button|btn)$/gi, '')
13
+ // Infix noise the model adds between shared stems (创建「新」钱包).
14
+ .replace(/(创建|新建|添加|新增|开通|注册|登录|登入|提交|确认|发送|保存|删除|取消|返回|下一步|完成)(?:全新|新的|新|一个|一下)*/g, '$1');
15
+ }
16
+ function levenshtein(a, b) {
17
+ if (a === b) return 0;
18
+ if (!a.length) return b.length;
19
+ if (!b.length) return a.length;
20
+ const row = Array.from({
21
+ length: b.length + 1
22
+ }, (_, i) => i);
23
+ for (let i = 0; i < a.length; i++) {
24
+ let prev = i + 1;
25
+ for (let j = 0; j < b.length; j++) {
26
+ const cur = a[i] === b[j] ? row[j] : 1 + Math.min(row[j], row[j + 1], prev);
27
+ row[j] = prev;
28
+ prev = cur;
29
+ }
30
+ row[b.length] = prev;
31
+ }
32
+ return row[b.length];
33
+ }
34
+
35
+ /** Scripts where one character carries a whole morpheme. */
36
+ const IDEOGRAPHIC = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uac00-\ud7af]/;
37
+ function isIdeographic(s) {
38
+ const chars = [...s];
39
+ if (!chars.length) return false;
40
+ const hits = chars.filter(c => IDEOGRAPHIC.test(c)).length;
41
+ return hits / chars.length >= 0.5;
42
+ }
43
+
44
+ /**
45
+ * Digit runs identify a specific thing — Account #1 vs #2, 1.2x vs 1.6x,
46
+ * 第2个 vs 第3个. Loose matching must never cross them, or the agent acts on
47
+ * the wrong account.
48
+ */
49
+ function digitsConflict(a, b) {
50
+ const da = (a.match(/\d+/g) || []).join('.');
51
+ const db = (b.match(/\d+/g) || []).join('.');
52
+ return !!da && !!db && da !== db;
53
+ }
54
+
55
+ /**
56
+ * Edit budget for a fuzzy label match.
57
+ *
58
+ * Latin typos are cheap to forgive. One substituted ideograph is a different
59
+ * word — 发送/发现, 交换/交易, 合同/合约, 钱币/钱包 all sit at distance 1 — so
60
+ * ideographic labels get no budget until they are long enough that a single
61
+ * edit cannot flip the meaning. Differing digits get no budget at all.
62
+ */
63
+ function editBudget(a, b) {
64
+ if (digitsConflict(a, b)) return 0;
65
+ const len = Math.max(a.length, b.length);
66
+ if (isIdeographic(a) || isIdeographic(b)) return len >= 6 ? 1 : 0;
67
+ return len <= 4 ? 1 : 2;
68
+ }
69
+
70
+ /** Loose label match: substring either way, soft filler strip, small edit distance. */
71
+ export function textMatches(haystack, needle, exact) {
72
+ if (!haystack) return false;
73
+ const h = norm(haystack);
74
+ const n = norm(needle);
75
+ if (!n) return false;
76
+ if (exact) return h === n;
77
+ if (h === n) return true;
78
+ const hs = softKey(haystack);
79
+ const ns = softKey(needle);
80
+ if (hs && ns && hs === ns) return true;
81
+
82
+ // Short CJK labels name distinct controls: 服务设置 is a section heading,
83
+ // not the 设置 button. Substring matching must not invent a visible target.
84
+ if (n.length <= 2 && isIdeographic(n) && isIdeographic(h)) return false;
85
+
86
+ // Screen text contains the full needle (safe).
87
+ if (h.includes(n) && n.length >= 2) return true;
88
+ if (hs && ns && hs.includes(ns) && ns.length >= 2) {
89
+ const ratio = ns.length / hs.length;
90
+ if (ratio >= 0.5) return true;
91
+ }
92
+
93
+ // Needle contains screen text only when nearly the same after softKey
94
+ // (「创建新钱包」→「创建钱包»). Never match 「创建钱包」 onto bare 「钱包」.
95
+ if (hs && ns && ns.includes(hs) && hs.length >= 2 && !digitsConflict(hs, ns)) {
96
+ if (hs.length / ns.length >= 0.72) return true;
97
+ }
98
+ if (h.length <= 16 && n.length <= 16) {
99
+ // Require similar length — else 「添加钱包」≈「钱包」(dist 2) false-positives.
100
+ const maxLen = Math.max(h.length, n.length);
101
+ const minLen = Math.min(h.length, n.length);
102
+ const budget = editBudget(h, n);
103
+ if (budget > 0 && minLen / maxLen >= 0.75) {
104
+ if (levenshtein(h, n) <= budget) return true;
105
+ }
106
+ if (hs && ns && hs.length <= 16 && ns.length <= 16) {
107
+ const maxL = Math.max(hs.length, ns.length);
108
+ const minL = Math.min(hs.length, ns.length);
109
+ const softBudget = editBudget(hs, ns);
110
+ if (softBudget > 0 && minL / maxL >= 0.75) {
111
+ if (levenshtein(hs, ns) <= softBudget) return true;
112
+ }
113
+ }
114
+ }
115
+ return false;
116
+ }
117
+ function regionContains(frame, region, window) {
118
+ const ratio = 'ratio' in region && typeof region.ratio === 'number' ? region.ratio : 0.2;
119
+ // Without window size, approximate using large canvas; callers may refine later.
120
+ const W = window?.width ?? Math.max(frame.x + frame.width, 400);
121
+ const H = window?.height ?? Math.max(frame.y + frame.height, 800);
122
+ const cx = frame.x + frame.width / 2;
123
+ const cy = frame.y + frame.height / 2;
124
+ switch (region.region) {
125
+ case 'top':
126
+ return cy <= H * ratio;
127
+ case 'bottom':
128
+ return cy >= H * (1 - ratio);
129
+ case 'left':
130
+ return cx <= W * ratio;
131
+ case 'right':
132
+ return cx >= W * (1 - ratio);
133
+ case 'center':
134
+ {
135
+ const m = ratio;
136
+ return cx >= W * m && cx <= W * (1 - m) && cy >= H * m && cy <= H * (1 - m);
137
+ }
138
+ default:
139
+ return true;
140
+ }
141
+ }
142
+ function collectTexts(node, depth = 0, maxDepth = 3) {
143
+ const out = [];
144
+ if (node.text) out.push(node.text);
145
+ if (node.accessibilityLabel) out.push(node.accessibilityLabel);
146
+ if (depth >= maxDepth) return out;
147
+ for (const c of node.children) out.push(...collectTexts(c, depth + 1, maxDepth));
148
+ return out;
149
+ }
150
+ function parentTextsNear(root, targetId) {
151
+ // Walk tree; when we find target, return texts from parent and siblings.
152
+ let parentOfTarget = null;
153
+ let found = false;
154
+ const walk = (n, parent) => {
155
+ if (n.id === targetId) {
156
+ parentOfTarget = parent;
157
+ found = true;
158
+ return;
159
+ }
160
+ for (const c of n.children) {
161
+ walk(c, n);
162
+ if (found) return;
163
+ }
164
+ };
165
+ walk(root, null);
166
+ if (!parentOfTarget) return collectTexts(root).slice(0, 20);
167
+ return collectTexts(parentOfTarget);
168
+ }
169
+ export function flattenTree(root) {
170
+ const out = [];
171
+ const walk = n => {
172
+ out.push(n);
173
+ for (const c of n.children) walk(c);
174
+ };
175
+ walk(root);
176
+ return out;
177
+ }
178
+ export function findNodeById(root, id) {
179
+ if (root.id === id) return root;
180
+ for (const c of root.children) {
181
+ const hit = findNodeById(c, id);
182
+ if (hit) return hit;
183
+ }
184
+ return null;
185
+ }
186
+ function nodeHasText(node, needle, exact) {
187
+ if (textMatches(node.text, needle, exact) || textMatches(node.accessibilityLabel, needle, exact)) {
188
+ return true;
189
+ }
190
+ // Wrapper Pressable often has empty text; label sits on a child Text.
191
+ if (exact) return false;
192
+ return collectTexts(node).some(t => textMatches(t, needle, false));
193
+ }
194
+ function matchesRule(node, rule, root) {
195
+ if ('text' in rule) {
196
+ return nodeHasText(node, rule.text, rule.exact);
197
+ }
198
+ if ('nearText' in rule) {
199
+ const nearby = parentTextsNear(root, node.id).join(' ');
200
+ return textMatches(nearby, rule.nearText, rule.exact);
201
+ }
202
+ if ('clickable' in rule) {
203
+ return node.clickable === rule.clickable;
204
+ }
205
+ if ('type' in rule) {
206
+ return norm(node.type).includes(norm(rule.type));
207
+ }
208
+ if ('testID' in rule) {
209
+ return !!node.testID && node.testID === rule.testID;
210
+ }
211
+ if ('accessibilityLabel' in rule) {
212
+ return textMatches(node.accessibilityLabel, rule.accessibilityLabel, rule.exact);
213
+ }
214
+ if ('region' in rule) {
215
+ return regionContains(node.frame, rule);
216
+ }
217
+ return false;
218
+ }
219
+ export function nodeMatches(node, selector, root) {
220
+ if (node.visible === false || node.enabled === false) return false;
221
+ if (!selector.match.length) return false;
222
+ return selector.match.every(rule => matchesRule(node, rule, root));
223
+ }
224
+ export function findAll(root, selector) {
225
+ return flattenTree(root).filter(n => nodeMatches(n, selector, root));
226
+ }
227
+
228
+ /** Climb to the nearest clickable / toggle / sheet ancestor (inclusive). */
229
+ function nearestInteractive(root, node) {
230
+ const byId = new Map(flattenTree(root).map(n => [n.id, n]));
231
+ // parent id = everything before last /
232
+ let cur = node;
233
+ while (cur) {
234
+ if (cur.visible !== false && cur.enabled !== false && (cur.clickable || cur.toggle || cur.adjustable || cur.sheet)) return cur;
235
+ const parentId = cur.id.includes('/') ? cur.id.slice(0, cur.id.lastIndexOf('/')) : '';
236
+ cur = parentId ? byId.get(parentId) : undefined;
237
+ }
238
+ return node;
239
+ }
240
+ function isDegenerateHit(root, n) {
241
+ // Full-window / root wrappers are never useful tap targets.
242
+ if (!n.id || n.id === root.id || n.id === '0') return true;
243
+ const rw = Math.max(1, root.frame.width);
244
+ const rh = Math.max(1, root.frame.height);
245
+ const areaRatio = n.frame.width * n.frame.height / (rw * rh);
246
+ if (areaRatio >= 0.55) return true;
247
+ return false;
248
+ }
249
+ function isInputOrInputWrapper(node) {
250
+ if (/textfield|textinput|edittext|uitextview|textarea|searchbar/i.test(node.type)) return true;
251
+ return node.children.some(child => child.visible !== false && isInputOrInputWrapper(child));
252
+ }
253
+ export function find(root, selector, options) {
254
+ let all = findAll(root, selector);
255
+ // Common RN case: model asks clickable+text, but text is on a child Text
256
+ // while Pressable wrapper is the only clickable node (handled by nodeHasText).
257
+ // If still empty, drop clickable requirement, match text, then climb to wrapper.
258
+ if (!all.length) {
259
+ const withoutClick = {
260
+ ...selector,
261
+ match: selector.match.filter(r => !('clickable' in r))
262
+ };
263
+ if (withoutClick.match.length > 0 && withoutClick.match.length < selector.match.length) {
264
+ const leaves = findAll(root, withoutClick);
265
+ const upgraded = leaves.map(n => nearestInteractive(root, n));
266
+ const wantClickable = selector.match.some(r => 'clickable' in r && r.clickable === true);
267
+ all = wantClickable ? upgraded.filter(n => n.clickable || n.toggle || n.sheet || n.adjustable) : upgraded;
268
+ // De-dupe by id
269
+ const seen = new Set();
270
+ all = all.filter(n => seen.has(n.id) ? false : (seen.add(n.id), true));
271
+ }
272
+ }
273
+ all = all.filter(n => !isDegenerateHit(root, n));
274
+ if (!all.length) return null;
275
+ // A query field can contain the same text as a search result. For a tap on
276
+ // an action, prefer matching non-input controls, including when the input is
277
+ // wrapped in a clickable RN view. An explicit input type remains authoritative.
278
+ const explicitlyInput = selector.match.some(rule => 'type' in rule && /textfield|textinput|edittext|uitextview|textarea|searchbar/i.test(rule.type));
279
+ if (options?.preferNonInput && !explicitlyInput) {
280
+ const actions = all.filter(node => !isInputOrInputWrapper(node));
281
+ if (actions.length) all = actions;
282
+ }
283
+ // Prefer interactive + compact controls (not giant containers).
284
+ const ranked = selector.index !== undefined ? all : [...all].sort((a, b) => rankMatch(b) + labelSpecificity(b, selector) - rankMatch(a) - labelSpecificity(a, selector) || a.frame.width * a.frame.height - b.frame.width * b.frame.height);
285
+ const index = selector.index ?? 0;
286
+ return ranked[index] ?? null;
287
+ }
288
+
289
+ /**
290
+ * Last-resort: find best interactive node whose visible text soft-matches needle.
291
+ * Used when the planner invents near-synonym copy not present verbatim.
292
+ */
293
+ export function findBySoftLabel(root, needle, options) {
294
+ const n = needle.trim();
295
+ if (!n) return null;
296
+ let best = null;
297
+ let bestScore = -1;
298
+ for (const node of flattenTree(root)) {
299
+ if (node.visible === false || node.enabled === false) continue;
300
+ if (isDegenerateHit(root, node)) continue;
301
+ const labels = [node.text, node.accessibilityLabel, ...collectTexts(node, 0, 2)].filter(t => !!t && t.trim().length > 0);
302
+ if (!labels.some(t => textMatches(t, n))) continue;
303
+ let score = rankMatch(node) + labelSpecificity(node, {
304
+ match: [{
305
+ text: n
306
+ }]
307
+ });
308
+ if (options?.preferNonInput && isInputOrInputWrapper(node)) score -= 200;
309
+ // Prefer roomy-but-not-huge tap targets (real buttons over tiny glyphs).
310
+ const area = node.frame.width * node.frame.height;
311
+ score += Math.min(40, area / 800);
312
+ // Penalize oversized containers.
313
+ score -= Math.min(60, area / 20_000);
314
+ if (score > bestScore) {
315
+ bestScore = score;
316
+ best = nearestInteractive(root, node);
317
+ }
318
+ }
319
+ if (best && isDegenerateHit(root, best)) return null;
320
+ return best;
321
+ }
322
+ function rankMatch(n) {
323
+ let s = 0;
324
+ if (n.toggle) s += 100;
325
+ if (n.adjustable) s += 80;
326
+ if (n.sheet && n.clickable) s += 70;
327
+ if (n.clickable) s += 40;
328
+ if (n.enabled) s += 5;
329
+ if (n.visible) s += 2;
330
+ // Prefer tighter frames among equals.
331
+ const area = n.frame.width * n.frame.height;
332
+ if (area > 0 && area < 120_000) s += 3;
333
+ return s;
334
+ }
335
+
336
+ /** A control's own label is stronger evidence than an ancestor's aggregated text. */
337
+ function labelSpecificity(node, selector) {
338
+ let score = 0;
339
+ for (const rule of selector.match) {
340
+ const wanted = 'text' in rule ? rule.text : 'accessibilityLabel' in rule ? rule.accessibilityLabel : undefined;
341
+ if (!wanted) continue;
342
+ const own = [node.text, node.accessibilityLabel].filter(x => !!x);
343
+ if (own.some(text => norm(text) === norm(wanted))) score += 100;else if (own.some(text => softKey(text) === softKey(wanted))) score += 90;else {
344
+ const labels = new Set(collectTexts(node, 0, 3).map(softKey).filter(Boolean));
345
+ if (labels.size === 1 && labels.has(softKey(wanted))) score += 90;
346
+ }
347
+ }
348
+ return score;
349
+ }
350
+
351
+ /** Keep a broad actionable container from centering between adjacent controls. */
352
+ export function centerOfLabel(node, label) {
353
+ if (!label) return centerOf(node);
354
+ const key = softKey(label);
355
+ if (!key || [node.text, node.accessibilityLabel].some(text => text && softKey(text) === key)) return centerOf(node);
356
+ const targets = flattenTree(node).filter(child => child !== node && child.visible !== false && child.enabled !== false && child.frame.width > 0 && child.frame.height > 0 && [child.text, child.accessibilityLabel].some(text => text && softKey(text) === key));
357
+ targets.sort((a, b) => rankMatch(b) - rankMatch(a) || a.frame.width * a.frame.height - b.frame.width * b.frame.height);
358
+ return centerOf(targets[0] || node);
359
+ }
360
+ export function centerOf(node) {
361
+ return {
362
+ x: node.frame.x + node.frame.width / 2,
363
+ y: node.frame.y + node.frame.height / 2
364
+ };
365
+ }
366
+ //# sourceMappingURL=match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["norm","s","trim","toLowerCase","softKey","replace","levenshtein","a","b","length","row","Array","from","_","i","prev","j","cur","Math","min","IDEOGRAPHIC","isIdeographic","chars","hits","filter","c","test","digitsConflict","da","match","join","db","editBudget","len","max","textMatches","haystack","needle","exact","h","n","hs","ns","includes","ratio","maxLen","minLen","budget","maxL","minL","softBudget","regionContains","frame","region","window","W","width","x","H","height","y","cx","cy","m","collectTexts","node","depth","maxDepth","out","text","push","accessibilityLabel","children","parentTextsNear","root","targetId","parentOfTarget","found","walk","parent","id","slice","flattenTree","findNodeById","hit","nodeHasText","some","t","matchesRule","rule","nearby","nearText","clickable","type","testID","nodeMatches","selector","visible","enabled","every","findAll","nearestInteractive","byId","Map","map","toggle","adjustable","sheet","parentId","lastIndexOf","get","undefined","isDegenerateHit","rw","rh","areaRatio","isInputOrInputWrapper","child","find","options","all","withoutClick","r","leaves","upgraded","wantClickable","seen","Set","has","add","explicitlyInput","preferNonInput","actions","ranked","index","sort","rankMatch","labelSpecificity","findBySoftLabel","best","bestScore","labels","score","area","wanted","own","Boolean","size","centerOfLabel","label","centerOf","key","targets"],"sourceRoot":"../../../src","sources":["selector/match.ts"],"mappings":";;AAEA,SAASA,IAAIA,CAACC,CAAS,EAAU;EAC/B,OAAOA,CAAC,CAACC,IAAI,CAAC,CAAC,CAACC,WAA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