@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.
- package/CHANGELOG.md +10 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +9 -0
- package/LICENSE +21 -0
- package/README.md +65 -0
- package/README.zh-CN.md +50 -0
- package/SECURITY.md +5 -0
- package/android/build.gradle +40 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/cn/intentcomputing/kokoagentsdk/KokoAgentSdkModule.java +1356 -0
- package/android/src/main/java/cn/intentcomputing/kokoagentsdk/KokoAgentSdkPackage.java +23 -0
- package/docs/INTEGRATION.md +168 -0
- package/docs/INTEGRATION.zh-CN.md +140 -0
- package/docs/PRIVACY.md +11 -0
- package/docs/PRIVACY.zh-CN.md +11 -0
- package/docs/PUBLISH.md +11 -0
- package/docs/PUBLISH.zh-CN.md +11 -0
- package/ios/KokoAgentSdk/KokoAgentSdk.h +5 -0
- package/ios/KokoAgentSdk/KokoAgentSdk.m +2464 -0
- package/ios/KokoAgentSdk/KokoOcrBounds.h +20 -0
- package/ios/KokoAgentSdk/KokoScrollBounds.h +21 -0
- package/koko-agent-sdk.podspec +23 -0
- package/lib/commonjs/KokoAgent.js +1427 -0
- package/lib/commonjs/KokoAgent.js.map +1 -0
- package/lib/commonjs/assist/OnDeviceAssist.js +94 -0
- package/lib/commonjs/assist/OnDeviceAssist.js.map +1 -0
- package/lib/commonjs/assist/intentClassify.js +100 -0
- package/lib/commonjs/assist/intentClassify.js.map +1 -0
- package/lib/commonjs/assist/nodeRank.js +120 -0
- package/lib/commonjs/assist/nodeRank.js.map +1 -0
- package/lib/commonjs/assist/ocrTarget.js +135 -0
- package/lib/commonjs/assist/ocrTarget.js.map +1 -0
- package/lib/commonjs/assist/webVisualChange.js +29 -0
- package/lib/commonjs/assist/webVisualChange.js.map +1 -0
- package/lib/commonjs/client/ActionOutcomeUnknownError.js +28 -0
- package/lib/commonjs/client/ActionOutcomeUnknownError.js.map +1 -0
- package/lib/commonjs/client/AgentSession.js +858 -0
- package/lib/commonjs/client/AgentSession.js.map +1 -0
- package/lib/commonjs/client/GatewayClient.js +302 -0
- package/lib/commonjs/client/GatewayClient.js.map +1 -0
- package/lib/commonjs/client/OperationReplayGuard.js +62 -0
- package/lib/commonjs/client/OperationReplayGuard.js.map +1 -0
- package/lib/commonjs/client/RunCheckpoint.js +139 -0
- package/lib/commonjs/client/RunCheckpoint.js.map +1 -0
- package/lib/commonjs/client/loopDetect.js +184 -0
- package/lib/commonjs/client/loopDetect.js.map +1 -0
- package/lib/commonjs/client/recentSearch.js +50 -0
- package/lib/commonjs/client/recentSearch.js.map +1 -0
- package/lib/commonjs/client/walletChoiceGuard.js +18 -0
- package/lib/commonjs/client/walletChoiceGuard.js.map +1 -0
- package/lib/commonjs/client/webResultCategory.js +38 -0
- package/lib/commonjs/client/webResultCategory.js.map +1 -0
- package/lib/commonjs/commercial/AccountStore.js +78 -0
- package/lib/commonjs/commercial/AccountStore.js.map +1 -0
- package/lib/commonjs/commercial/AgentDebug.js +104 -0
- package/lib/commonjs/commercial/AgentDebug.js.map +1 -0
- package/lib/commonjs/commercial/ExecutionGuard.js +53 -0
- package/lib/commonjs/commercial/ExecutionGuard.js.map +1 -0
- package/lib/commonjs/commercial/UsageBus.js +42 -0
- package/lib/commonjs/commercial/UsageBus.js.map +1 -0
- package/lib/commonjs/commercial/branding.js +69 -0
- package/lib/commonjs/commercial/branding.js.map +1 -0
- package/lib/commonjs/commercial/devMode.js +52 -0
- package/lib/commonjs/commercial/devMode.js.map +1 -0
- package/lib/commonjs/commercial/trust.js +69 -0
- package/lib/commonjs/commercial/trust.js.map +1 -0
- package/lib/commonjs/confirmation/gate.js +62 -0
- package/lib/commonjs/confirmation/gate.js.map +1 -0
- package/lib/commonjs/cursor/CursorOverlay.js +141 -0
- package/lib/commonjs/cursor/CursorOverlay.js.map +1 -0
- package/lib/commonjs/cursor/PointerHand.js +51 -0
- package/lib/commonjs/cursor/PointerHand.js.map +1 -0
- package/lib/commonjs/cursor/controller.js +91 -0
- package/lib/commonjs/cursor/controller.js.map +1 -0
- package/lib/commonjs/cursor/pointer.js +49 -0
- package/lib/commonjs/cursor/pointer.js.map +1 -0
- package/lib/commonjs/debug/KokoRemoteSmoke.js +611 -0
- package/lib/commonjs/debug/KokoRemoteSmoke.js.map +1 -0
- package/lib/commonjs/explore/ExplorationGraph.js +418 -0
- package/lib/commonjs/explore/ExplorationGraph.js.map +1 -0
- package/lib/commonjs/explore/bootstrapExplore.js +59 -0
- package/lib/commonjs/explore/bootstrapExplore.js.map +1 -0
- package/lib/commonjs/host/HostActions.js +266 -0
- package/lib/commonjs/host/HostActions.js.map +1 -0
- package/lib/commonjs/i18n/index.js +169 -0
- package/lib/commonjs/i18n/index.js.map +1 -0
- package/lib/commonjs/i18n/runtimeMessages.js +184 -0
- package/lib/commonjs/i18n/runtimeMessages.js.map +1 -0
- package/lib/commonjs/index.js +640 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/native/NativeBridge.js +132 -0
- package/lib/commonjs/native/NativeBridge.js.map +1 -0
- package/lib/commonjs/native/navigationLabel.js +16 -0
- package/lib/commonjs/native/navigationLabel.js.map +1 -0
- package/lib/commonjs/native/normalizeViewTree.js +28 -0
- package/lib/commonjs/native/normalizeViewTree.js.map +1 -0
- package/lib/commonjs/native/pruneOffscreen.js +76 -0
- package/lib/commonjs/native/pruneOffscreen.js.map +1 -0
- package/lib/commonjs/native/scrollViewport.js +69 -0
- package/lib/commonjs/native/scrollViewport.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/privacy/redact.js +108 -0
- package/lib/commonjs/privacy/redact.js.map +1 -0
- package/lib/commonjs/privacy/screenEvidence.js +59 -0
- package/lib/commonjs/privacy/screenEvidence.js.map +1 -0
- package/lib/commonjs/privacy/screenModel.js +404 -0
- package/lib/commonjs/privacy/screenModel.js.map +1 -0
- package/lib/commonjs/privacy/sensitiveScreen.js +58 -0
- package/lib/commonjs/privacy/sensitiveScreen.js.map +1 -0
- package/lib/commonjs/privacy/userGate.js +213 -0
- package/lib/commonjs/privacy/userGate.js.map +1 -0
- package/lib/commonjs/protocol/actions.js +112 -0
- package/lib/commonjs/protocol/actions.js.map +1 -0
- package/lib/commonjs/provider/HostAppearanceStore.js +111 -0
- package/lib/commonjs/provider/HostAppearanceStore.js.map +1 -0
- package/lib/commonjs/provider/KokoProvider.js +81 -0
- package/lib/commonjs/provider/KokoProvider.js.map +1 -0
- package/lib/commonjs/provider/KokoUiContext.js +102 -0
- package/lib/commonjs/provider/KokoUiContext.js.map +1 -0
- package/lib/commonjs/selector/match.js +378 -0
- package/lib/commonjs/selector/match.js.map +1 -0
- package/lib/commonjs/task/TaskStore.js +361 -0
- package/lib/commonjs/task/TaskStore.js.map +1 -0
- package/lib/commonjs/task/types.js +2 -0
- package/lib/commonjs/task/types.js.map +1 -0
- package/lib/commonjs/task/useTaskStore.js +14 -0
- package/lib/commonjs/task/useTaskStore.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/ui/KokoChatSheet.js +885 -0
- package/lib/commonjs/ui/KokoChatSheet.js.map +1 -0
- package/lib/commonjs/ui/KokoComposer.js +161 -0
- package/lib/commonjs/ui/KokoComposer.js.map +1 -0
- package/lib/commonjs/ui/KokoDialogHost.js +254 -0
- package/lib/commonjs/ui/KokoDialogHost.js.map +1 -0
- package/lib/commonjs/ui/KokoEntryButton.js +81 -0
- package/lib/commonjs/ui/KokoEntryButton.js.map +1 -0
- package/lib/commonjs/ui/KokoObserver.js +522 -0
- package/lib/commonjs/ui/KokoObserver.js.map +1 -0
- package/lib/commonjs/ui/KokoOverlayLayer.js +45 -0
- package/lib/commonjs/ui/KokoOverlayLayer.js.map +1 -0
- package/lib/commonjs/ui/KokoSubtitle.js +95 -0
- package/lib/commonjs/ui/KokoSubtitle.js.map +1 -0
- package/lib/commonjs/ui/KokoTaskPanel.js +322 -0
- package/lib/commonjs/ui/KokoTaskPanel.js.map +1 -0
- package/lib/commonjs/ui/hostOverlay.js +126 -0
- package/lib/commonjs/ui/hostOverlay.js.map +1 -0
- package/lib/commonjs/ui/icons.js +132 -0
- package/lib/commonjs/ui/icons.js.map +1 -0
- package/lib/commonjs/ui/progressChrome.js +66 -0
- package/lib/commonjs/ui/progressChrome.js.map +1 -0
- package/lib/commonjs/ui/safeArea.js +96 -0
- package/lib/commonjs/ui/safeArea.js.map +1 -0
- package/lib/commonjs/ui/useOverlayOrigin.js +40 -0
- package/lib/commonjs/ui/useOverlayOrigin.js.map +1 -0
- package/lib/module/KokoAgent.js +1418 -0
- package/lib/module/KokoAgent.js.map +1 -0
- package/lib/module/assist/OnDeviceAssist.js +89 -0
- package/lib/module/assist/OnDeviceAssist.js.map +1 -0
- package/lib/module/assist/intentClassify.js +95 -0
- package/lib/module/assist/intentClassify.js.map +1 -0
- package/lib/module/assist/nodeRank.js +115 -0
- package/lib/module/assist/nodeRank.js.map +1 -0
- package/lib/module/assist/ocrTarget.js +123 -0
- package/lib/module/assist/ocrTarget.js.map +1 -0
- package/lib/module/assist/webVisualChange.js +24 -0
- package/lib/module/assist/webVisualChange.js.map +1 -0
- package/lib/module/client/ActionOutcomeUnknownError.js +23 -0
- package/lib/module/client/ActionOutcomeUnknownError.js.map +1 -0
- package/lib/module/client/AgentSession.js +854 -0
- package/lib/module/client/AgentSession.js.map +1 -0
- package/lib/module/client/GatewayClient.js +293 -0
- package/lib/module/client/GatewayClient.js.map +1 -0
- package/lib/module/client/OperationReplayGuard.js +58 -0
- package/lib/module/client/OperationReplayGuard.js.map +1 -0
- package/lib/module/client/RunCheckpoint.js +135 -0
- package/lib/module/client/RunCheckpoint.js.map +1 -0
- package/lib/module/client/loopDetect.js +177 -0
- package/lib/module/client/loopDetect.js.map +1 -0
- package/lib/module/client/recentSearch.js +46 -0
- package/lib/module/client/recentSearch.js.map +1 -0
- package/lib/module/client/walletChoiceGuard.js +14 -0
- package/lib/module/client/walletChoiceGuard.js.map +1 -0
- package/lib/module/client/webResultCategory.js +34 -0
- package/lib/module/client/webResultCategory.js.map +1 -0
- package/lib/module/commercial/AccountStore.js +75 -0
- package/lib/module/commercial/AccountStore.js.map +1 -0
- package/lib/module/commercial/AgentDebug.js +99 -0
- package/lib/module/commercial/AgentDebug.js.map +1 -0
- package/lib/module/commercial/ExecutionGuard.js +49 -0
- package/lib/module/commercial/ExecutionGuard.js.map +1 -0
- package/lib/module/commercial/UsageBus.js +38 -0
- package/lib/module/commercial/UsageBus.js.map +1 -0
- package/lib/module/commercial/branding.js +63 -0
- package/lib/module/commercial/branding.js.map +1 -0
- package/lib/module/commercial/devMode.js +45 -0
- package/lib/module/commercial/devMode.js.map +1 -0
- package/lib/module/commercial/trust.js +62 -0
- package/lib/module/commercial/trust.js.map +1 -0
- package/lib/module/confirmation/gate.js +54 -0
- package/lib/module/confirmation/gate.js.map +1 -0
- package/lib/module/cursor/CursorOverlay.js +136 -0
- package/lib/module/cursor/CursorOverlay.js.map +1 -0
- package/lib/module/cursor/PointerHand.js +47 -0
- package/lib/module/cursor/PointerHand.js.map +1 -0
- package/lib/module/cursor/controller.js +87 -0
- package/lib/module/cursor/controller.js.map +1 -0
- package/lib/module/cursor/pointer.js +45 -0
- package/lib/module/cursor/pointer.js.map +1 -0
- package/lib/module/debug/KokoRemoteSmoke.js +608 -0
- package/lib/module/debug/KokoRemoteSmoke.js.map +1 -0
- package/lib/module/explore/ExplorationGraph.js +406 -0
- package/lib/module/explore/ExplorationGraph.js.map +1 -0
- package/lib/module/explore/bootstrapExplore.js +55 -0
- package/lib/module/explore/bootstrapExplore.js.map +1 -0
- package/lib/module/host/HostActions.js +255 -0
- package/lib/module/host/HostActions.js.map +1 -0
- package/lib/module/i18n/index.js +159 -0
- package/lib/module/i18n/index.js.map +1 -0
- package/lib/module/i18n/runtimeMessages.js +180 -0
- package/lib/module/i18n/runtimeMessages.js.map +1 -0
- package/lib/module/index.js +44 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native/NativeBridge.js +128 -0
- package/lib/module/native/NativeBridge.js.map +1 -0
- package/lib/module/native/navigationLabel.js +12 -0
- package/lib/module/native/navigationLabel.js.map +1 -0
- package/lib/module/native/normalizeViewTree.js +25 -0
- package/lib/module/native/normalizeViewTree.js.map +1 -0
- package/lib/module/native/pruneOffscreen.js +72 -0
- package/lib/module/native/pruneOffscreen.js.map +1 -0
- package/lib/module/native/scrollViewport.js +63 -0
- package/lib/module/native/scrollViewport.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/privacy/redact.js +103 -0
- package/lib/module/privacy/redact.js.map +1 -0
- package/lib/module/privacy/screenEvidence.js +50 -0
- package/lib/module/privacy/screenEvidence.js.map +1 -0
- package/lib/module/privacy/screenModel.js +397 -0
- package/lib/module/privacy/screenModel.js.map +1 -0
- package/lib/module/privacy/sensitiveScreen.js +52 -0
- package/lib/module/privacy/sensitiveScreen.js.map +1 -0
- package/lib/module/privacy/userGate.js +202 -0
- package/lib/module/privacy/userGate.js.map +1 -0
- package/lib/module/protocol/actions.js +108 -0
- package/lib/module/protocol/actions.js.map +1 -0
- package/lib/module/provider/HostAppearanceStore.js +101 -0
- package/lib/module/provider/HostAppearanceStore.js.map +1 -0
- package/lib/module/provider/KokoProvider.js +74 -0
- package/lib/module/provider/KokoProvider.js.map +1 -0
- package/lib/module/provider/KokoUiContext.js +96 -0
- package/lib/module/provider/KokoUiContext.js.map +1 -0
- package/lib/module/selector/match.js +366 -0
- package/lib/module/selector/match.js.map +1 -0
- package/lib/module/task/TaskStore.js +356 -0
- package/lib/module/task/TaskStore.js.map +1 -0
- package/lib/module/task/types.js +2 -0
- package/lib/module/task/types.js.map +1 -0
- package/lib/module/task/useTaskStore.js +10 -0
- package/lib/module/task/useTaskStore.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/ui/KokoChatSheet.js +879 -0
- package/lib/module/ui/KokoChatSheet.js.map +1 -0
- package/lib/module/ui/KokoComposer.js +155 -0
- package/lib/module/ui/KokoComposer.js.map +1 -0
- package/lib/module/ui/KokoDialogHost.js +247 -0
- package/lib/module/ui/KokoDialogHost.js.map +1 -0
- package/lib/module/ui/KokoEntryButton.js +74 -0
- package/lib/module/ui/KokoEntryButton.js.map +1 -0
- package/lib/module/ui/KokoObserver.js +516 -0
- package/lib/module/ui/KokoObserver.js.map +1 -0
- package/lib/module/ui/KokoOverlayLayer.js +39 -0
- package/lib/module/ui/KokoOverlayLayer.js.map +1 -0
- package/lib/module/ui/KokoSubtitle.js +90 -0
- package/lib/module/ui/KokoSubtitle.js.map +1 -0
- package/lib/module/ui/KokoTaskPanel.js +316 -0
- package/lib/module/ui/KokoTaskPanel.js.map +1 -0
- package/lib/module/ui/hostOverlay.js +120 -0
- package/lib/module/ui/hostOverlay.js.map +1 -0
- package/lib/module/ui/icons.js +124 -0
- package/lib/module/ui/icons.js.map +1 -0
- package/lib/module/ui/progressChrome.js +58 -0
- package/lib/module/ui/progressChrome.js.map +1 -0
- package/lib/module/ui/safeArea.js +92 -0
- package/lib/module/ui/safeArea.js.map +1 -0
- package/lib/module/ui/useOverlayOrigin.js +36 -0
- package/lib/module/ui/useOverlayOrigin.js.map +1 -0
- package/lib/typescript/commonjs/KokoAgent.d.ts +167 -0
- package/lib/typescript/commonjs/KokoAgent.d.ts.map +1 -0
- package/lib/typescript/commonjs/assist/OnDeviceAssist.d.ts +31 -0
- package/lib/typescript/commonjs/assist/OnDeviceAssist.d.ts.map +1 -0
- package/lib/typescript/commonjs/assist/intentClassify.d.ts +18 -0
- package/lib/typescript/commonjs/assist/intentClassify.d.ts.map +1 -0
- package/lib/typescript/commonjs/assist/nodeRank.d.ts +32 -0
- package/lib/typescript/commonjs/assist/nodeRank.d.ts.map +1 -0
- package/lib/typescript/commonjs/assist/ocrTarget.d.ts +25 -0
- package/lib/typescript/commonjs/assist/ocrTarget.d.ts.map +1 -0
- package/lib/typescript/commonjs/assist/webVisualChange.d.ts +6 -0
- package/lib/typescript/commonjs/assist/webVisualChange.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/ActionOutcomeUnknownError.d.ts +13 -0
- package/lib/typescript/commonjs/client/ActionOutcomeUnknownError.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/AgentSession.d.ts +56 -0
- package/lib/typescript/commonjs/client/AgentSession.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/GatewayClient.d.ts +149 -0
- package/lib/typescript/commonjs/client/GatewayClient.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/OperationReplayGuard.d.ts +13 -0
- package/lib/typescript/commonjs/client/OperationReplayGuard.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/RunCheckpoint.d.ts +57 -0
- package/lib/typescript/commonjs/client/RunCheckpoint.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/loopDetect.d.ts +15 -0
- package/lib/typescript/commonjs/client/loopDetect.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/recentSearch.d.ts +5 -0
- package/lib/typescript/commonjs/client/recentSearch.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/walletChoiceGuard.d.ts +4 -0
- package/lib/typescript/commonjs/client/walletChoiceGuard.d.ts.map +1 -0
- package/lib/typescript/commonjs/client/webResultCategory.d.ts +5 -0
- package/lib/typescript/commonjs/client/webResultCategory.d.ts.map +1 -0
- package/lib/typescript/commonjs/commercial/AccountStore.d.ts +17 -0
- package/lib/typescript/commonjs/commercial/AccountStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/commercial/AgentDebug.d.ts +25 -0
- package/lib/typescript/commonjs/commercial/AgentDebug.d.ts.map +1 -0
- package/lib/typescript/commonjs/commercial/ExecutionGuard.d.ts +18 -0
- package/lib/typescript/commonjs/commercial/ExecutionGuard.d.ts.map +1 -0
- package/lib/typescript/commonjs/commercial/UsageBus.d.ts +18 -0
- package/lib/typescript/commonjs/commercial/UsageBus.d.ts.map +1 -0
- package/lib/typescript/commonjs/commercial/branding.d.ts +25 -0
- package/lib/typescript/commonjs/commercial/branding.d.ts.map +1 -0
- package/lib/typescript/commonjs/commercial/devMode.d.ts +26 -0
- package/lib/typescript/commonjs/commercial/devMode.d.ts.map +1 -0
- package/lib/typescript/commonjs/commercial/trust.d.ts +21 -0
- package/lib/typescript/commonjs/commercial/trust.d.ts.map +1 -0
- package/lib/typescript/commonjs/confirmation/gate.d.ts +18 -0
- package/lib/typescript/commonjs/confirmation/gate.d.ts.map +1 -0
- package/lib/typescript/commonjs/cursor/CursorOverlay.d.ts +13 -0
- package/lib/typescript/commonjs/cursor/CursorOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/cursor/PointerHand.d.ts +16 -0
- package/lib/typescript/commonjs/cursor/PointerHand.d.ts.map +1 -0
- package/lib/typescript/commonjs/cursor/controller.d.ts +30 -0
- package/lib/typescript/commonjs/cursor/controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/cursor/pointer.d.ts +23 -0
- package/lib/typescript/commonjs/cursor/pointer.d.ts.map +1 -0
- package/lib/typescript/commonjs/debug/KokoRemoteSmoke.d.ts +96 -0
- package/lib/typescript/commonjs/debug/KokoRemoteSmoke.d.ts.map +1 -0
- package/lib/typescript/commonjs/explore/ExplorationGraph.d.ts +96 -0
- package/lib/typescript/commonjs/explore/ExplorationGraph.d.ts.map +1 -0
- package/lib/typescript/commonjs/explore/bootstrapExplore.d.ts +40 -0
- package/lib/typescript/commonjs/explore/bootstrapExplore.d.ts.map +1 -0
- package/lib/typescript/commonjs/host/HostActions.d.ts +101 -0
- package/lib/typescript/commonjs/host/HostActions.d.ts.map +1 -0
- package/lib/typescript/commonjs/i18n/index.d.ts +20 -0
- package/lib/typescript/commonjs/i18n/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/i18n/runtimeMessages.d.ts +178 -0
- package/lib/typescript/commonjs/i18n/runtimeMessages.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +66 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/NativeBridge.d.ts +70 -0
- package/lib/typescript/commonjs/native/NativeBridge.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/navigationLabel.d.ts +4 -0
- package/lib/typescript/commonjs/native/navigationLabel.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/normalizeViewTree.d.ts +4 -0
- package/lib/typescript/commonjs/native/normalizeViewTree.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/pruneOffscreen.d.ts +3 -0
- package/lib/typescript/commonjs/native/pruneOffscreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/scrollViewport.d.ts +13 -0
- package/lib/typescript/commonjs/native/scrollViewport.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/privacy/redact.d.ts +9 -0
- package/lib/typescript/commonjs/privacy/redact.d.ts.map +1 -0
- package/lib/typescript/commonjs/privacy/screenEvidence.d.ts +14 -0
- package/lib/typescript/commonjs/privacy/screenEvidence.d.ts.map +1 -0
- package/lib/typescript/commonjs/privacy/screenModel.d.ts +26 -0
- package/lib/typescript/commonjs/privacy/screenModel.d.ts.map +1 -0
- package/lib/typescript/commonjs/privacy/sensitiveScreen.d.ts +8 -0
- package/lib/typescript/commonjs/privacy/sensitiveScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/privacy/userGate.d.ts +58 -0
- package/lib/typescript/commonjs/privacy/userGate.d.ts.map +1 -0
- package/lib/typescript/commonjs/protocol/actions.d.ts +7 -0
- package/lib/typescript/commonjs/protocol/actions.d.ts.map +1 -0
- package/lib/typescript/commonjs/provider/HostAppearanceStore.d.ts +64 -0
- package/lib/typescript/commonjs/provider/HostAppearanceStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/provider/KokoProvider.d.ts +39 -0
- package/lib/typescript/commonjs/provider/KokoProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/provider/KokoUiContext.d.ts +22 -0
- package/lib/typescript/commonjs/provider/KokoUiContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/selector/match.d.ts +27 -0
- package/lib/typescript/commonjs/selector/match.d.ts.map +1 -0
- package/lib/typescript/commonjs/task/TaskStore.d.ts +65 -0
- package/lib/typescript/commonjs/task/TaskStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/task/types.d.ts +66 -0
- package/lib/typescript/commonjs/task/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/task/useTaskStore.d.ts +3 -0
- package/lib/typescript/commonjs/task/useTaskStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +372 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoChatSheet.d.ts +8 -0
- package/lib/typescript/commonjs/ui/KokoChatSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoComposer.d.ts +13 -0
- package/lib/typescript/commonjs/ui/KokoComposer.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoDialogHost.d.ts +32 -0
- package/lib/typescript/commonjs/ui/KokoDialogHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoEntryButton.d.ts +18 -0
- package/lib/typescript/commonjs/ui/KokoEntryButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoObserver.d.ts +13 -0
- package/lib/typescript/commonjs/ui/KokoObserver.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoOverlayLayer.d.ts +35 -0
- package/lib/typescript/commonjs/ui/KokoOverlayLayer.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoSubtitle.d.ts +7 -0
- package/lib/typescript/commonjs/ui/KokoSubtitle.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/KokoTaskPanel.d.ts +7 -0
- package/lib/typescript/commonjs/ui/KokoTaskPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hostOverlay.d.ts +28 -0
- package/lib/typescript/commonjs/ui/hostOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/icons.d.ts +26 -0
- package/lib/typescript/commonjs/ui/icons.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/progressChrome.d.ts +21 -0
- package/lib/typescript/commonjs/ui/progressChrome.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/safeArea.d.ts +12 -0
- package/lib/typescript/commonjs/ui/safeArea.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/useOverlayOrigin.d.ts +22 -0
- package/lib/typescript/commonjs/ui/useOverlayOrigin.d.ts.map +1 -0
- package/lib/typescript/module/KokoAgent.d.ts +167 -0
- package/lib/typescript/module/KokoAgent.d.ts.map +1 -0
- package/lib/typescript/module/assist/OnDeviceAssist.d.ts +31 -0
- package/lib/typescript/module/assist/OnDeviceAssist.d.ts.map +1 -0
- package/lib/typescript/module/assist/intentClassify.d.ts +18 -0
- package/lib/typescript/module/assist/intentClassify.d.ts.map +1 -0
- package/lib/typescript/module/assist/nodeRank.d.ts +32 -0
- package/lib/typescript/module/assist/nodeRank.d.ts.map +1 -0
- package/lib/typescript/module/assist/ocrTarget.d.ts +25 -0
- package/lib/typescript/module/assist/ocrTarget.d.ts.map +1 -0
- package/lib/typescript/module/assist/webVisualChange.d.ts +6 -0
- package/lib/typescript/module/assist/webVisualChange.d.ts.map +1 -0
- package/lib/typescript/module/client/ActionOutcomeUnknownError.d.ts +13 -0
- package/lib/typescript/module/client/ActionOutcomeUnknownError.d.ts.map +1 -0
- package/lib/typescript/module/client/AgentSession.d.ts +56 -0
- package/lib/typescript/module/client/AgentSession.d.ts.map +1 -0
- package/lib/typescript/module/client/GatewayClient.d.ts +149 -0
- package/lib/typescript/module/client/GatewayClient.d.ts.map +1 -0
- package/lib/typescript/module/client/OperationReplayGuard.d.ts +13 -0
- package/lib/typescript/module/client/OperationReplayGuard.d.ts.map +1 -0
- package/lib/typescript/module/client/RunCheckpoint.d.ts +57 -0
- package/lib/typescript/module/client/RunCheckpoint.d.ts.map +1 -0
- package/lib/typescript/module/client/loopDetect.d.ts +15 -0
- package/lib/typescript/module/client/loopDetect.d.ts.map +1 -0
- package/lib/typescript/module/client/recentSearch.d.ts +5 -0
- package/lib/typescript/module/client/recentSearch.d.ts.map +1 -0
- package/lib/typescript/module/client/walletChoiceGuard.d.ts +4 -0
- package/lib/typescript/module/client/walletChoiceGuard.d.ts.map +1 -0
- package/lib/typescript/module/client/webResultCategory.d.ts +5 -0
- package/lib/typescript/module/client/webResultCategory.d.ts.map +1 -0
- package/lib/typescript/module/commercial/AccountStore.d.ts +17 -0
- package/lib/typescript/module/commercial/AccountStore.d.ts.map +1 -0
- package/lib/typescript/module/commercial/AgentDebug.d.ts +25 -0
- package/lib/typescript/module/commercial/AgentDebug.d.ts.map +1 -0
- package/lib/typescript/module/commercial/ExecutionGuard.d.ts +18 -0
- package/lib/typescript/module/commercial/ExecutionGuard.d.ts.map +1 -0
- package/lib/typescript/module/commercial/UsageBus.d.ts +18 -0
- package/lib/typescript/module/commercial/UsageBus.d.ts.map +1 -0
- package/lib/typescript/module/commercial/branding.d.ts +25 -0
- package/lib/typescript/module/commercial/branding.d.ts.map +1 -0
- package/lib/typescript/module/commercial/devMode.d.ts +26 -0
- package/lib/typescript/module/commercial/devMode.d.ts.map +1 -0
- package/lib/typescript/module/commercial/trust.d.ts +21 -0
- package/lib/typescript/module/commercial/trust.d.ts.map +1 -0
- package/lib/typescript/module/confirmation/gate.d.ts +18 -0
- package/lib/typescript/module/confirmation/gate.d.ts.map +1 -0
- package/lib/typescript/module/cursor/CursorOverlay.d.ts +13 -0
- package/lib/typescript/module/cursor/CursorOverlay.d.ts.map +1 -0
- package/lib/typescript/module/cursor/PointerHand.d.ts +16 -0
- package/lib/typescript/module/cursor/PointerHand.d.ts.map +1 -0
- package/lib/typescript/module/cursor/controller.d.ts +30 -0
- package/lib/typescript/module/cursor/controller.d.ts.map +1 -0
- package/lib/typescript/module/cursor/pointer.d.ts +23 -0
- package/lib/typescript/module/cursor/pointer.d.ts.map +1 -0
- package/lib/typescript/module/debug/KokoRemoteSmoke.d.ts +96 -0
- package/lib/typescript/module/debug/KokoRemoteSmoke.d.ts.map +1 -0
- package/lib/typescript/module/explore/ExplorationGraph.d.ts +96 -0
- package/lib/typescript/module/explore/ExplorationGraph.d.ts.map +1 -0
- package/lib/typescript/module/explore/bootstrapExplore.d.ts +40 -0
- package/lib/typescript/module/explore/bootstrapExplore.d.ts.map +1 -0
- package/lib/typescript/module/host/HostActions.d.ts +101 -0
- package/lib/typescript/module/host/HostActions.d.ts.map +1 -0
- package/lib/typescript/module/i18n/index.d.ts +20 -0
- package/lib/typescript/module/i18n/index.d.ts.map +1 -0
- package/lib/typescript/module/i18n/runtimeMessages.d.ts +178 -0
- package/lib/typescript/module/i18n/runtimeMessages.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +66 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/native/NativeBridge.d.ts +70 -0
- package/lib/typescript/module/native/NativeBridge.d.ts.map +1 -0
- package/lib/typescript/module/native/navigationLabel.d.ts +4 -0
- package/lib/typescript/module/native/navigationLabel.d.ts.map +1 -0
- package/lib/typescript/module/native/normalizeViewTree.d.ts +4 -0
- package/lib/typescript/module/native/normalizeViewTree.d.ts.map +1 -0
- package/lib/typescript/module/native/pruneOffscreen.d.ts +3 -0
- package/lib/typescript/module/native/pruneOffscreen.d.ts.map +1 -0
- package/lib/typescript/module/native/scrollViewport.d.ts +13 -0
- package/lib/typescript/module/native/scrollViewport.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/privacy/redact.d.ts +9 -0
- package/lib/typescript/module/privacy/redact.d.ts.map +1 -0
- package/lib/typescript/module/privacy/screenEvidence.d.ts +14 -0
- package/lib/typescript/module/privacy/screenEvidence.d.ts.map +1 -0
- package/lib/typescript/module/privacy/screenModel.d.ts +26 -0
- package/lib/typescript/module/privacy/screenModel.d.ts.map +1 -0
- package/lib/typescript/module/privacy/sensitiveScreen.d.ts +8 -0
- package/lib/typescript/module/privacy/sensitiveScreen.d.ts.map +1 -0
- package/lib/typescript/module/privacy/userGate.d.ts +58 -0
- package/lib/typescript/module/privacy/userGate.d.ts.map +1 -0
- package/lib/typescript/module/protocol/actions.d.ts +7 -0
- package/lib/typescript/module/protocol/actions.d.ts.map +1 -0
- package/lib/typescript/module/provider/HostAppearanceStore.d.ts +64 -0
- package/lib/typescript/module/provider/HostAppearanceStore.d.ts.map +1 -0
- package/lib/typescript/module/provider/KokoProvider.d.ts +39 -0
- package/lib/typescript/module/provider/KokoProvider.d.ts.map +1 -0
- package/lib/typescript/module/provider/KokoUiContext.d.ts +22 -0
- package/lib/typescript/module/provider/KokoUiContext.d.ts.map +1 -0
- package/lib/typescript/module/selector/match.d.ts +27 -0
- package/lib/typescript/module/selector/match.d.ts.map +1 -0
- package/lib/typescript/module/task/TaskStore.d.ts +65 -0
- package/lib/typescript/module/task/TaskStore.d.ts.map +1 -0
- package/lib/typescript/module/task/types.d.ts +66 -0
- package/lib/typescript/module/task/types.d.ts.map +1 -0
- package/lib/typescript/module/task/useTaskStore.d.ts +3 -0
- package/lib/typescript/module/task/useTaskStore.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +372 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoChatSheet.d.ts +8 -0
- package/lib/typescript/module/ui/KokoChatSheet.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoComposer.d.ts +13 -0
- package/lib/typescript/module/ui/KokoComposer.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoDialogHost.d.ts +32 -0
- package/lib/typescript/module/ui/KokoDialogHost.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoEntryButton.d.ts +18 -0
- package/lib/typescript/module/ui/KokoEntryButton.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoObserver.d.ts +13 -0
- package/lib/typescript/module/ui/KokoObserver.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoOverlayLayer.d.ts +35 -0
- package/lib/typescript/module/ui/KokoOverlayLayer.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoSubtitle.d.ts +7 -0
- package/lib/typescript/module/ui/KokoSubtitle.d.ts.map +1 -0
- package/lib/typescript/module/ui/KokoTaskPanel.d.ts +7 -0
- package/lib/typescript/module/ui/KokoTaskPanel.d.ts.map +1 -0
- package/lib/typescript/module/ui/hostOverlay.d.ts +28 -0
- package/lib/typescript/module/ui/hostOverlay.d.ts.map +1 -0
- package/lib/typescript/module/ui/icons.d.ts +26 -0
- package/lib/typescript/module/ui/icons.d.ts.map +1 -0
- package/lib/typescript/module/ui/progressChrome.d.ts +21 -0
- package/lib/typescript/module/ui/progressChrome.d.ts.map +1 -0
- package/lib/typescript/module/ui/safeArea.d.ts +12 -0
- package/lib/typescript/module/ui/safeArea.d.ts.map +1 -0
- package/lib/typescript/module/ui/useOverlayOrigin.d.ts +22 -0
- package/lib/typescript/module/ui/useOverlayOrigin.d.ts.map +1 -0
- package/package.json +153 -0
- package/react-native.config.js +12 -0
- package/src/KokoAgent.ts +1415 -0
- package/src/assist/OnDeviceAssist.ts +133 -0
- package/src/assist/intentClassify.ts +122 -0
- package/src/assist/nodeRank.ts +167 -0
- package/src/assist/ocrTarget.ts +146 -0
- package/src/assist/webVisualChange.ts +24 -0
- package/src/client/ActionOutcomeUnknownError.ts +18 -0
- package/src/client/AgentSession.ts +952 -0
- package/src/client/GatewayClient.ts +439 -0
- package/src/client/OperationReplayGuard.ts +61 -0
- package/src/client/RunCheckpoint.ts +154 -0
- package/src/client/loopDetect.ts +213 -0
- package/src/client/recentSearch.ts +47 -0
- package/src/client/walletChoiceGuard.ts +15 -0
- package/src/client/webResultCategory.ts +28 -0
- package/src/commercial/AccountStore.ts +85 -0
- package/src/commercial/AgentDebug.ts +142 -0
- package/src/commercial/ExecutionGuard.ts +67 -0
- package/src/commercial/UsageBus.ts +44 -0
- package/src/commercial/branding.ts +97 -0
- package/src/commercial/devMode.ts +48 -0
- package/src/commercial/trust.ts +67 -0
- package/src/confirmation/gate.ts +82 -0
- package/src/cursor/CursorOverlay.tsx +138 -0
- package/src/cursor/PointerHand.tsx +49 -0
- package/src/cursor/controller.ts +98 -0
- package/src/cursor/pointer.ts +40 -0
- package/src/debug/KokoRemoteSmoke.tsx +561 -0
- package/src/explore/ExplorationGraph.ts +518 -0
- package/src/explore/bootstrapExplore.ts +89 -0
- package/src/host/HostActions.ts +349 -0
- package/src/i18n/index.ts +229 -0
- package/src/i18n/runtimeMessages.ts +180 -0
- package/src/index.ts +203 -0
- package/src/native/NativeBridge.ts +207 -0
- package/src/native/navigationLabel.ts +11 -0
- package/src/native/normalizeViewTree.ts +16 -0
- package/src/native/pruneOffscreen.ts +72 -0
- package/src/native/scrollViewport.ts +51 -0
- package/src/privacy/redact.ts +115 -0
- package/src/privacy/screenEvidence.ts +55 -0
- package/src/privacy/screenModel.ts +504 -0
- package/src/privacy/sensitiveScreen.ts +55 -0
- package/src/privacy/userGate.ts +233 -0
- package/src/protocol/actions.ts +66 -0
- package/src/provider/HostAppearanceStore.ts +148 -0
- package/src/provider/KokoProvider.tsx +118 -0
- package/src/provider/KokoUiContext.tsx +162 -0
- package/src/selector/match.ts +417 -0
- package/src/task/TaskStore.ts +387 -0
- package/src/task/types.ts +82 -0
- package/src/task/useTaskStore.ts +9 -0
- package/src/types.ts +318 -0
- package/src/ui/KokoChatSheet.tsx +930 -0
- package/src/ui/KokoComposer.tsx +174 -0
- package/src/ui/KokoDialogHost.tsx +249 -0
- package/src/ui/KokoEntryButton.tsx +74 -0
- package/src/ui/KokoObserver.tsx +587 -0
- package/src/ui/KokoOverlayLayer.tsx +53 -0
- package/src/ui/KokoSubtitle.tsx +80 -0
- package/src/ui/KokoTaskPanel.tsx +299 -0
- package/src/ui/hostOverlay.tsx +148 -0
- package/src/ui/icons.tsx +145 -0
- package/src/ui/progressChrome.ts +73 -0
- package/src/ui/safeArea.ts +95 -0
- package/src/ui/useOverlayOrigin.ts +29 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import type { ViewNode } from '../types';
|
|
2
|
+
import { sensitiveScreenKind } from './sensitiveScreen';
|
|
3
|
+
import { scrollViewports } from '../native/scrollViewport';
|
|
4
|
+
import { redactOutbound } from './redact';
|
|
5
|
+
import { isSdkChrome } from './screenEvidence';
|
|
6
|
+
|
|
7
|
+
export type AffordanceKind =
|
|
8
|
+
| 'button'
|
|
9
|
+
| 'tab'
|
|
10
|
+
| 'field'
|
|
11
|
+
| 'row'
|
|
12
|
+
| 'link'
|
|
13
|
+
| 'sheet'
|
|
14
|
+
| 'toggle'
|
|
15
|
+
| 'adjustable'
|
|
16
|
+
| 'other';
|
|
17
|
+
|
|
18
|
+
export type Affordance = {
|
|
19
|
+
kind: AffordanceKind;
|
|
20
|
+
/** Primary human label (text or a11y). */
|
|
21
|
+
label: string;
|
|
22
|
+
nodeId: string;
|
|
23
|
+
/** Nearby list/row context if any. */
|
|
24
|
+
near?: string;
|
|
25
|
+
clickable: boolean;
|
|
26
|
+
/** Already-active tab / segment / option — re-tapping it is a no-op. */
|
|
27
|
+
selected?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type ExtraNode = ViewNode & {
|
|
31
|
+
selected?: boolean;
|
|
32
|
+
sheet?: boolean;
|
|
33
|
+
toggle?: boolean;
|
|
34
|
+
adjustable?: boolean;
|
|
35
|
+
on?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type Ranked = Affordance & { y: number; score: number; testID?: string };
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Scroll descriptions UIKit synthesizes for accessibility.
|
|
42
|
+
*
|
|
43
|
+
* They ride along on scroll containers and get concatenated into the label of
|
|
44
|
+
* whatever sits inside, so a real list row reads "BTC Bitcoin … Vertical scr"
|
|
45
|
+
* with its own content truncated away. Nothing can be aimed at them.
|
|
46
|
+
*/
|
|
47
|
+
const A11Y_SCROLL_NOISE =
|
|
48
|
+
/\b(vertical|horizontal)\s+scroll\s+bar,\s*\d+\s*pages?\b|\bsection\s+index\b/gi;
|
|
49
|
+
|
|
50
|
+
function labelOf(n: ViewNode): string {
|
|
51
|
+
const raw = (n.text || n.accessibilityLabel || '').replace(
|
|
52
|
+
A11Y_SCROLL_NOISE,
|
|
53
|
+
' ',
|
|
54
|
+
);
|
|
55
|
+
const t = redactOutbound(raw).replace(/\s+/g, ' ').trim();
|
|
56
|
+
return t.slice(0, 80);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Labels often sit on Fabric Paragraph children while Pressable is the parent. */
|
|
60
|
+
function descendantLabel(n: ViewNode, depth = 0): string {
|
|
61
|
+
const own = labelOf(n);
|
|
62
|
+
if (own) return own;
|
|
63
|
+
if (depth >= 4) return '';
|
|
64
|
+
const parts: string[] = [];
|
|
65
|
+
for (const c of n.children) {
|
|
66
|
+
const l = descendantLabel(c, depth + 1);
|
|
67
|
+
if (l) parts.push(l);
|
|
68
|
+
if (parts.join(' ').length >= 80) break;
|
|
69
|
+
}
|
|
70
|
+
return parts.join(' ').replace(/\s+/g, ' ').trim().slice(0, 80);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function isExcludedSubtree(node: ViewNode): boolean {
|
|
74
|
+
return isSdkChrome(node) || /logbox/i.test(`${node.type} ${node.testID || ''}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Dev LogBox / framework warnings that leak into accessibility trees. */
|
|
78
|
+
function isNoiseLabel(label: string): boolean {
|
|
79
|
+
const s = label.trim();
|
|
80
|
+
if (!s) return false;
|
|
81
|
+
return (
|
|
82
|
+
/Dialog Animation duration/i.test(s) ||
|
|
83
|
+
/estimatedContentHeight/i.test(s) ||
|
|
84
|
+
/please use estimatedContentHeight/i.test(s) ||
|
|
85
|
+
/Require cycle:/i.test(s) ||
|
|
86
|
+
/Open debugger to view warnings/i.test(s) ||
|
|
87
|
+
/^!,?\s*Open debugger/i.test(s) ||
|
|
88
|
+
/^LogBox/i.test(s) ||
|
|
89
|
+
/PurchasesReactNative/i.test(s) ||
|
|
90
|
+
/See \d+ more components/i.test(s) ||
|
|
91
|
+
/^(addLog|addConsoleLog|reactConsoleErrorHandler|anonymous|renderWithHooks),/i.test(
|
|
92
|
+
s,
|
|
93
|
+
) ||
|
|
94
|
+
/platform=ios&dev=true/i.test(s)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isIgnoredLabel(label: string): boolean {
|
|
99
|
+
return isNoiseLabel(label);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function isField(n: ViewNode): boolean {
|
|
103
|
+
const t = n.type.toLowerCase();
|
|
104
|
+
return (
|
|
105
|
+
/textfield|textinput|edittext|uitextfield|uitextview|textarea/.test(t) ||
|
|
106
|
+
(!!n.accessibilityLabel &&
|
|
107
|
+
/input|输入|placeholder|what do you/i.test(n.accessibilityLabel) &&
|
|
108
|
+
!n.clickable)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function collectNear(root: ViewNode, id: string): string | undefined {
|
|
113
|
+
let parent: ViewNode | null = null;
|
|
114
|
+
let found = false;
|
|
115
|
+
const walk = (n: ViewNode, p: ViewNode | null) => {
|
|
116
|
+
if (n.id === id) {
|
|
117
|
+
parent = p;
|
|
118
|
+
found = true;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
for (const c of n.children) {
|
|
122
|
+
walk(c, n);
|
|
123
|
+
if (found) return;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
walk(root, null);
|
|
127
|
+
if (!parent) return undefined;
|
|
128
|
+
const bits: string[] = [];
|
|
129
|
+
const gather = (n: ViewNode) => {
|
|
130
|
+
if (n.visible === false || isExcludedSubtree(n)) return;
|
|
131
|
+
const l = labelOf(n);
|
|
132
|
+
if (l && n.id !== id) bits.push(l);
|
|
133
|
+
for (const c of n.children) gather(c);
|
|
134
|
+
};
|
|
135
|
+
gather(parent);
|
|
136
|
+
const joined = [...new Set(bits)]
|
|
137
|
+
.filter((b) => !isIgnoredLabel(b))
|
|
138
|
+
.slice(0, 4)
|
|
139
|
+
.join(' · ');
|
|
140
|
+
return joined || undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Text inside an affordance, in reading order.
|
|
145
|
+
*
|
|
146
|
+
* A list row or card whose own label is just a title loses the association
|
|
147
|
+
* between its cells: three tokens laid out as name/price/change siblings
|
|
148
|
+
* reach the planner as nine unrelated fragments, so "which one gained most"
|
|
149
|
+
* is unanswerable. Reading order is the only thing that ties a price to a
|
|
150
|
+
* name, so keep it — do not sort or globally de-duplicate.
|
|
151
|
+
*/
|
|
152
|
+
function descendantContext(n: ViewNode, ownLabel: string): string | undefined {
|
|
153
|
+
const bits: string[] = [];
|
|
154
|
+
const gather = (cur: ViewNode) => {
|
|
155
|
+
if (cur.visible === false || isExcludedSubtree(cur)) return;
|
|
156
|
+
if (cur !== n) {
|
|
157
|
+
const l = labelOf(cur);
|
|
158
|
+
if (l && l !== ownLabel && l !== bits[bits.length - 1] && !isIgnoredLabel(l)) {
|
|
159
|
+
bits.push(l);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
for (const c of cur.children) gather(c);
|
|
163
|
+
};
|
|
164
|
+
gather(n);
|
|
165
|
+
if (bits.length < 2) return undefined;
|
|
166
|
+
return bits.join(' · ');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A label carrying only a number — a price, a percentage, a count.
|
|
171
|
+
*
|
|
172
|
+
* This is data the screen is showing, not something to aim at. Left ranked
|
|
173
|
+
* as a plain short button it outscores the controls around it and fills the
|
|
174
|
+
* model with fragments like 「$0.00352」 that say nothing about what tapping
|
|
175
|
+
* them would do.
|
|
176
|
+
*/
|
|
177
|
+
function isDataOnlyLabel(label: string): boolean {
|
|
178
|
+
const s = label.trim();
|
|
179
|
+
if (!s) return false;
|
|
180
|
+
return /^[+\-$€£¥₿~≈]*[\d][\d.,\s]*(%|[KkMmBb])?$/.test(s);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function kindOf(n: ExtraNode, label: string, near?: string): AffordanceKind {
|
|
184
|
+
if (/uitab(?:bar)?button|bottomnavigationitem|tabview$/i.test(n.type)) return 'tab';
|
|
185
|
+
if (n.sheet && (n as ViewNode).clickable) return 'sheet';
|
|
186
|
+
if (n.toggle) return 'toggle';
|
|
187
|
+
if (n.adjustable || /picker|datepicker|uiswitch|slider|stepper|seekbar|segment|numberpicker/i.test(n.type)) {
|
|
188
|
+
return 'adjustable';
|
|
189
|
+
}
|
|
190
|
+
if (/delete|删除|trash|remove|关闭|close|cancel|取消|好|ok|确定|允许|不允许/i.test(label)) {
|
|
191
|
+
return 'button';
|
|
192
|
+
}
|
|
193
|
+
if (/add|添加|创建|导入|确认|submit|send|下一步|登录|保存|分享|share/i.test(label)) {
|
|
194
|
+
return 'button';
|
|
195
|
+
}
|
|
196
|
+
if (near && near !== label) return 'row';
|
|
197
|
+
return 'button';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function isLikelyCtaLabel(label: string): boolean {
|
|
201
|
+
const s = label.trim();
|
|
202
|
+
if (!s || s.length > 24) return false;
|
|
203
|
+
return /^(创建|添加|新建|导入|登录|注册|开始|继续|下一步|完成|确认|提交|发送|连接|恢复)/.test(
|
|
204
|
+
s,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function scoreAffordance(a: Ranked, screenH: number): number {
|
|
209
|
+
let s = 0;
|
|
210
|
+
const bottomBand = screenH * 0.72;
|
|
211
|
+
// Recovery navigation must survive a dense page's candidate limit.
|
|
212
|
+
if (a.y < screenH * 0.25 && /^(back|go back|close|返回|返回上一级|关闭)$/i.test(a.label)) s += 500;
|
|
213
|
+
if (a.kind === 'tab') s += 400;
|
|
214
|
+
// Primary empty-state CTAs (center) must outrank bottom tabs in the snapshot.
|
|
215
|
+
if (isLikelyCtaLabel(a.label) && a.y < bottomBand) s += 260;
|
|
216
|
+
// Bottom tab / dock chrome must survive list truncation.
|
|
217
|
+
if (a.y >= bottomBand) s += 200;
|
|
218
|
+
if (a.kind === 'sheet') s += 180;
|
|
219
|
+
if (a.kind === 'field') s += 120;
|
|
220
|
+
if (a.kind === 'toggle' || a.kind === 'adjustable') s += 110;
|
|
221
|
+
if (a.kind === 'button' && !a.near) s += 90;
|
|
222
|
+
if (a.kind === 'button' && a.near) s += 40;
|
|
223
|
+
if (a.kind === 'row') s += 20;
|
|
224
|
+
// Prefer short nav labels over long product row titles.
|
|
225
|
+
if (a.label.length <= 12 && !a.near) s += 30;
|
|
226
|
+
if (a.testID) s += 25;
|
|
227
|
+
// A bare number is short and context-free, so the bonuses above would rank
|
|
228
|
+
// a price above the search box on the same screen. Fields keep their score:
|
|
229
|
+
// an amount input is labelled by its current value and still needs typing.
|
|
230
|
+
if (a.kind !== 'field' && isDataOnlyLabel(a.label)) s -= 140;
|
|
231
|
+
return s;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Semantic screen model for the planner — "what can this screen do?"
|
|
236
|
+
* Collects all candidates then keeps the highest-priority ones so bottom
|
|
237
|
+
* navigation is not crowded out by long product lists.
|
|
238
|
+
*/
|
|
239
|
+
export function extractAffordances(root: ViewNode, max = 40): Affordance[] {
|
|
240
|
+
if (sensitiveScreenKind(root)) return [];
|
|
241
|
+
const ranked: Ranked[] = [];
|
|
242
|
+
const seen = new Set<string>();
|
|
243
|
+
const screenH = Math.max(root.frame?.height ?? 0, 1);
|
|
244
|
+
const byId = new Map(flattenForModel(root).map((n) => [n.id, n]));
|
|
245
|
+
const parents = new Map<string, ViewNode>();
|
|
246
|
+
const indexParents = (node: ViewNode) => {
|
|
247
|
+
for (const child of node.children) { parents.set(child.id, node); indexParents(child); }
|
|
248
|
+
};
|
|
249
|
+
indexParents(root);
|
|
250
|
+
|
|
251
|
+
const parentOf = (n: ViewNode): ViewNode | undefined => parents.get(n.id);
|
|
252
|
+
const isAncestor = (ancestor: ViewNode, child: ViewNode): boolean => {
|
|
253
|
+
for (let parent = parentOf(child); parent; parent = parentOf(parent)) {
|
|
254
|
+
if (parent.id === ancestor.id) return true;
|
|
255
|
+
}
|
|
256
|
+
return false;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const climbInteractive = (n: ViewNode): ViewNode => {
|
|
260
|
+
// A testID is a test hook, not an affordance: hosts put them on the text
|
|
261
|
+
// inside a row as readily as on the row. Stopping there emits the cell and
|
|
262
|
+
// hides the control, so only fall back to it when nothing above is
|
|
263
|
+
// interactive.
|
|
264
|
+
let testIdFallback: ViewNode | undefined;
|
|
265
|
+
let cur: ViewNode | undefined = n;
|
|
266
|
+
while (cur) {
|
|
267
|
+
const x = cur as ExtraNode;
|
|
268
|
+
if (cur.clickable || x.toggle || x.adjustable || x.sheet) return cur;
|
|
269
|
+
if (cur.testID && !testIdFallback) testIdFallback = cur;
|
|
270
|
+
cur = parentOf(cur);
|
|
271
|
+
}
|
|
272
|
+
return testIdFallback ?? n;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const hasInteractiveAncestor = (n: ViewNode): boolean => {
|
|
276
|
+
for (let cur = parentOf(n); cur; cur = parentOf(cur)) {
|
|
277
|
+
const x = cur as ExtraNode;
|
|
278
|
+
if (cur.clickable || x.toggle || x.adjustable || x.sheet) return true;
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const pushButton = (n: ViewNode, label: string, near?: string) => {
|
|
284
|
+
if (!label || isIgnoredLabel(label)) return;
|
|
285
|
+
const node = n as ExtraNode;
|
|
286
|
+
const kind = kindOf(node, label, near);
|
|
287
|
+
const key = `b:${label}:${near ?? ''}:${kind}:${n.id}`;
|
|
288
|
+
if (seen.has(key)) return;
|
|
289
|
+
// Only nested wrappers describe the same action. Identical sibling labels
|
|
290
|
+
// belong to distinct rows (e.g. Delete beside two different products).
|
|
291
|
+
const index = ranked.findIndex(a => {
|
|
292
|
+
const previous = byId.get(a.nodeId);
|
|
293
|
+
return a.label === label && previous &&
|
|
294
|
+
(previous.id === n.id || isAncestor(previous, n) || isAncestor(n, previous));
|
|
295
|
+
});
|
|
296
|
+
if (index >= 0) {
|
|
297
|
+
const previous = index >= 0 ? byId.get(ranked[index].nodeId) : undefined;
|
|
298
|
+
if (!previous || !n.clickable || (previous.clickable &&
|
|
299
|
+
previous.frame.width * previous.frame.height <= n.frame.width * n.frame.height)) return;
|
|
300
|
+
ranked.splice(index, 1);
|
|
301
|
+
}
|
|
302
|
+
seen.add(key);
|
|
303
|
+
ranked.push({
|
|
304
|
+
kind,
|
|
305
|
+
label,
|
|
306
|
+
nodeId: n.id,
|
|
307
|
+
// Wide enough for a row of cells; a 3-item card runs about 85 chars.
|
|
308
|
+
near: near && near !== label ? near.slice(0, 120) : undefined,
|
|
309
|
+
clickable: true,
|
|
310
|
+
selected: (n as ExtraNode).selected || undefined,
|
|
311
|
+
testID: n.testID,
|
|
312
|
+
y: n.frame?.y ?? 0,
|
|
313
|
+
score: 0,
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const walk = (n: ViewNode) => {
|
|
318
|
+
if (n.visible === false || isExcludedSubtree(n)) return;
|
|
319
|
+
const node = n as ExtraNode;
|
|
320
|
+
const label = descendantLabel(n);
|
|
321
|
+
const field = isField(n);
|
|
322
|
+
const y = n.frame?.y ?? 0;
|
|
323
|
+
|
|
324
|
+
if (field && label) {
|
|
325
|
+
const key = `f:${n.id}`;
|
|
326
|
+
if (!seen.has(key)) {
|
|
327
|
+
seen.add(key);
|
|
328
|
+
ranked.push({
|
|
329
|
+
kind: 'field',
|
|
330
|
+
label,
|
|
331
|
+
nodeId: n.id,
|
|
332
|
+
near: collectNear(root, n.id),
|
|
333
|
+
clickable: n.clickable,
|
|
334
|
+
y,
|
|
335
|
+
score: 0,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
} else if (
|
|
339
|
+
(n.clickable || node.toggle || node.adjustable) &&
|
|
340
|
+
(label || node.toggle || node.adjustable) &&
|
|
341
|
+
!(label && isIgnoredLabel(label))
|
|
342
|
+
) {
|
|
343
|
+
// Context from inside the control first, from around it second. A row's
|
|
344
|
+
// own cells are what make it identifiable; its siblings are other rows.
|
|
345
|
+
const near = descendantContext(n, label) ?? collectNear(root, n.id);
|
|
346
|
+
let display =
|
|
347
|
+
label ||
|
|
348
|
+
(node.toggle
|
|
349
|
+
? `开关${node.on != null ? (node.on ? '(开)' : '(关)') : ''}`
|
|
350
|
+
: '') ||
|
|
351
|
+
(node.adjustable ? '可调节控件' : '') ||
|
|
352
|
+
n.type.split('.').pop() ||
|
|
353
|
+
'控件';
|
|
354
|
+
if (node.toggle && label && node.on != null) {
|
|
355
|
+
display = `${label}(${node.on ? '开' : '关'})`;
|
|
356
|
+
}
|
|
357
|
+
if (
|
|
358
|
+
node.adjustable &&
|
|
359
|
+
typeof node.value === 'number' &&
|
|
360
|
+
Number.isFinite(node.value)
|
|
361
|
+
) {
|
|
362
|
+
const v = Math.round(node.value * 100) / 100;
|
|
363
|
+
const lo =
|
|
364
|
+
typeof node.min === 'number' ? Math.round(node.min * 100) / 100 : null;
|
|
365
|
+
const hi =
|
|
366
|
+
typeof node.max === 'number' ? Math.round(node.max * 100) / 100 : null;
|
|
367
|
+
const range = lo != null && hi != null ? `,${lo}–${hi}` : '';
|
|
368
|
+
display = `${display}(${v}${range})`;
|
|
369
|
+
}
|
|
370
|
+
pushButton(n, display, near && near !== display ? near : undefined);
|
|
371
|
+
} else if (label && isLikelyCtaLabel(label)) {
|
|
372
|
+
// Tamagui Button: text often on a non-clickable Paragraph — promote CTA.
|
|
373
|
+
const target = climbInteractive(n);
|
|
374
|
+
const near = collectNear(root, target.id);
|
|
375
|
+
pushButton(target, label, near && near !== label ? near : undefined);
|
|
376
|
+
} else if (n.testID && label && !isIgnoredLabel(label)) {
|
|
377
|
+
// Already covered: the clickable ancestor was pushed on the way down,
|
|
378
|
+
// with this text as part of its context. Emitting the cell too would
|
|
379
|
+
// duplicate it stripped of everything that made it meaningful.
|
|
380
|
+
if (!hasInteractiveAncestor(n)) {
|
|
381
|
+
const target = climbInteractive(n);
|
|
382
|
+
pushButton(target, label, collectNear(root, target.id));
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
for (const c of n.children) walk(c);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
walk(root);
|
|
390
|
+
|
|
391
|
+
for (const a of ranked) {
|
|
392
|
+
a.score = scoreAffordance(a, screenH);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
ranked.sort((a, b) => b.score - a.score || a.y - b.y);
|
|
396
|
+
|
|
397
|
+
// Bottom tab chrome often outranks page body — reserve slots for upper content
|
|
398
|
+
// so tab switches change the fingerprint and Discovery lists reach the planner.
|
|
399
|
+
const bottomBand = screenH * 0.72;
|
|
400
|
+
const upper = ranked.filter((a) => a.y < bottomBand);
|
|
401
|
+
const bottom = ranked.filter((a) => a.y >= bottomBand);
|
|
402
|
+
const upperSlots = Math.max(Math.ceil(max * 0.65), max - 5);
|
|
403
|
+
const picked: Ranked[] = [];
|
|
404
|
+
const seenIds = new Set<string>();
|
|
405
|
+
const take = (list: Ranked[], n: number) => {
|
|
406
|
+
for (const a of list) {
|
|
407
|
+
if (picked.length >= n) break;
|
|
408
|
+
if (seenIds.has(a.nodeId)) continue;
|
|
409
|
+
seenIds.add(a.nodeId);
|
|
410
|
+
picked.push(a);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
take(upper, upperSlots);
|
|
414
|
+
take(bottom, max);
|
|
415
|
+
take(ranked, max);
|
|
416
|
+
|
|
417
|
+
return picked
|
|
418
|
+
.slice(0, max)
|
|
419
|
+
.map(({ kind, label, nodeId, near, clickable, selected }) => ({
|
|
420
|
+
kind,
|
|
421
|
+
label,
|
|
422
|
+
nodeId,
|
|
423
|
+
near,
|
|
424
|
+
clickable,
|
|
425
|
+
selected,
|
|
426
|
+
}));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function flattenForModel(root: ViewNode): ViewNode[] {
|
|
430
|
+
const out: ViewNode[] = [];
|
|
431
|
+
const walk = (n: ViewNode) => {
|
|
432
|
+
if (n.visible === false || isExcludedSubtree(n)) return;
|
|
433
|
+
out.push(n);
|
|
434
|
+
for (const c of n.children) walk(c);
|
|
435
|
+
};
|
|
436
|
+
walk(root);
|
|
437
|
+
return out;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Read-only page copy is state too: wizard steps may reuse every button. */
|
|
441
|
+
export function readablePageContent(root: ViewNode, max = 24): string[] {
|
|
442
|
+
if (sensitiveScreenKind(root)) return [];
|
|
443
|
+
const controls = new Set(extractAffordances(root, 100).map(a => a.label));
|
|
444
|
+
const text = new Set<string>();
|
|
445
|
+
const hasCopy = (n: ViewNode): boolean => n.visible !== false && !isExcludedSubtree(n) &&
|
|
446
|
+
(!!labelOf(n) || n.children.some(hasCopy));
|
|
447
|
+
const walk = (n: ViewNode) => {
|
|
448
|
+
if (n.visible === false || n.secure || isExcludedSubtree(n)) return;
|
|
449
|
+
// Prefer leaf copy to native ancestors' aggregated (and truncated) labels.
|
|
450
|
+
const hasChildCopy = n.children.some(hasCopy);
|
|
451
|
+
const label = (n.text || n.accessibilityLabel || '').replace(/\s+/g, ' ').trim();
|
|
452
|
+
if (!hasChildCopy && label && !controls.has(label) && !isIgnoredLabel(label) &&
|
|
453
|
+
!isDataOnlyLabel(label) && !/^\d{1,2}:\d{2}$/.test(label)) text.add(redactOutbound(label, root).slice(0, 500));
|
|
454
|
+
for (const c of n.children) walk(c);
|
|
455
|
+
};
|
|
456
|
+
walk(root);
|
|
457
|
+
return redactOutbound([...text].slice(0, max), root);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** Compact text for LLM context (token-friendly). */
|
|
461
|
+
export function screenModelText(
|
|
462
|
+
root: ViewNode,
|
|
463
|
+
max = 40,
|
|
464
|
+
hostExtra?: string,
|
|
465
|
+
): string {
|
|
466
|
+
if (sensitiveScreenKind(root)) return '[private screen — user completes locally]';
|
|
467
|
+
const items = extractAffordances(root, max);
|
|
468
|
+
const controls = items.length
|
|
469
|
+
? items
|
|
470
|
+
.map((a) => {
|
|
471
|
+
const near = a.near ? ` · near「${a.near}」` : '';
|
|
472
|
+
const hint =
|
|
473
|
+
a.kind === 'tab'
|
|
474
|
+
? ' · 一级栏目入口,目标属于该栏目时先进入'
|
|
475
|
+
: a.kind === 'toggle'
|
|
476
|
+
? ' · tap 切换'
|
|
477
|
+
: a.kind === 'adjustable'
|
|
478
|
+
? ' · tap/swipe 调到目标值(看括号内当前值)'
|
|
479
|
+
: '';
|
|
480
|
+
const state = a.selected ? ' · 当前已选中(无需再点)' : '';
|
|
481
|
+
return `- [${a.kind}] 「${a.label}」 id=${a.nodeId}${near}${state}${hint}`;
|
|
482
|
+
})
|
|
483
|
+
.join('\n')
|
|
484
|
+
: '';
|
|
485
|
+
const regions = scrollViewports(root).slice(0, 6).map(({ node, frame: f }) =>
|
|
486
|
+
`- [scroll-region] id=${node.id} bounds=(${Math.round(f.x)},${Math.round(f.y)},${Math.round(f.width)},${Math.round(f.height)}) · 仅用于当前列表,优先相关可见导航;滑动起终点须在区域内`,
|
|
487
|
+
).join('\n');
|
|
488
|
+
const content = readablePageContent(root).map(text => `- [content] ${text}`).join('\n');
|
|
489
|
+
const dumpPart = [controls, content, regions].filter(Boolean).join('\n');
|
|
490
|
+
const host = (hostExtra || '').trim();
|
|
491
|
+
if (dumpPart && host) return `${dumpPart}\n${host}`;
|
|
492
|
+
if (dumpPart) return dumpPart;
|
|
493
|
+
if (host) return host;
|
|
494
|
+
return '(未识别到可操作控件或滚动区域;等待加载后重新观察,勿盲目滑动)';
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/** One-line snapshot for history feedback after an action. */
|
|
498
|
+
export function screenSnapshotLine(root: ViewNode, max = 12): string {
|
|
499
|
+
if (sensitiveScreenKind(root)) return '[private screen — user completes locally]';
|
|
500
|
+
const items = extractAffordances(root, max);
|
|
501
|
+
const content = readablePageContent(root);
|
|
502
|
+
const copy = content.length ? ` | content: ${content.join(' | ')}` : '';
|
|
503
|
+
return `screen: ${items.length ? items.map(a => `${a.label}${a.selected ? ' [selected]' : ''}`).join(' | ') : '(no controls)'}${copy}`;
|
|
504
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { runtimeText } from '../i18n';
|
|
2
|
+
import type { ViewNode } from '../types';
|
|
3
|
+
import { isPrivateInput, isSdkChrome, PRIVATE_INPUT_PROMPT_RE, staticScreenLabels } from './screenEvidence';
|
|
4
|
+
|
|
5
|
+
export type SensitiveScreenKind = 'password' | 'recovery_phrase' | 'private_key';
|
|
6
|
+
|
|
7
|
+
/** Local-only classification. Never return a field value or mnemonic word. */
|
|
8
|
+
export function sensitiveScreenKind(root: ViewNode | null | undefined): SensitiveScreenKind | null {
|
|
9
|
+
if (!root) return null;
|
|
10
|
+
let result: SensitiveScreenKind | null = null;
|
|
11
|
+
let legacyPhraseCells = 0;
|
|
12
|
+
let legacySuggestions = false;
|
|
13
|
+
const visit = (n: ViewNode) => {
|
|
14
|
+
if (isSdkChrome(n)) return;
|
|
15
|
+
if (n.visible === false) {
|
|
16
|
+
for (const child of n.children || []) visit(child);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (isPrivateInput(n)) result = 'password';
|
|
20
|
+
const id = n.testID || '';
|
|
21
|
+
if (/textfield|textinput|edittext|textview|textarea/i.test(n.type) &&
|
|
22
|
+
/助记词|mnemonic|(?:recovery|seed)[\s_-]*phrase/i.test(`${id} ${n.accessibilityLabel || ''}`)) result = 'recovery_phrase';
|
|
23
|
+
if (/textfield|textinput|edittext|textview|textarea/i.test(n.type) &&
|
|
24
|
+
/私钥|private[\s_-]*key/i.test(`${id} ${n.accessibilityLabel || ''}`)) result = 'private_key';
|
|
25
|
+
if (/privacy-sensitive.*(?:phrase|mnemonic|seed)/i.test(id)) {
|
|
26
|
+
result = 'recovery_phrase';
|
|
27
|
+
}
|
|
28
|
+
if (/phrase-index\d+/i.test(id)) legacyPhraseCells++;
|
|
29
|
+
if (/^suggest-|^wordIndex$/i.test(id)) legacySuggestions = true;
|
|
30
|
+
if (/privacy-sensitive.*private|private[-_]?key[-_]?(?:value|field|input)/i.test(id)) {
|
|
31
|
+
result = 'private_key';
|
|
32
|
+
}
|
|
33
|
+
for (const child of n.children || []) visit(child);
|
|
34
|
+
};
|
|
35
|
+
visit(root);
|
|
36
|
+
if (result) return result;
|
|
37
|
+
const headings = staticScreenLabels(root).map(({ label }) => label);
|
|
38
|
+
// Legacy wallet IDs are not reserved SDK markers: suggest-* is also common
|
|
39
|
+
// in public search. Require phrase context or an actual indexed word grid.
|
|
40
|
+
if (legacyPhraseCells >= 3 || ((legacyPhraseCells || legacySuggestions) &&
|
|
41
|
+
headings.some(text => /助记词|mnemonic|(?:recovery|seed)\s+phrase/i.test(text)))) return 'recovery_phrase';
|
|
42
|
+
for (const text of headings) {
|
|
43
|
+
if (PRIVATE_INPUT_PROMPT_RE.test(text)) return 'password';
|
|
44
|
+
if (/^(?:(?:验证|确认|备份|显示|查看|输入|导入|恢复)(?:您的|你的)?助记词|(?:verify|confirm|back\s*up|backup|show|reveal|import|enter)\s+(?:(?:your|the)\s+)?(?:recovery\s+|seed\s+)?(?:phrase|mnemonic))\s*[::??]?$/i.test(text)) return 'recovery_phrase';
|
|
45
|
+
if (/^(?:(?:导出|显示|查看|输入|导入)(?:您的|你的)?私钥|(?:export|show|reveal|import|enter)\s+(?:(?:your|the)\s+)?private\s*key)\s*[::]?$/i.test(text)) return 'private_key';
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class SensitiveScreenError extends Error {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(runtimeText('runtime.privateStep'));
|
|
53
|
+
this.name = 'SensitiveScreenError';
|
|
54
|
+
}
|
|
55
|
+
}
|