@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,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AppUserGateStore = void 0;
|
|
7
|
+
exports.clearAppUserGate = clearAppUserGate;
|
|
8
|
+
exports.detectAppUserGate = detectAppUserGate;
|
|
9
|
+
exports.gateMessage = gateMessage;
|
|
10
|
+
exports.gateMessageValue = gateMessageValue;
|
|
11
|
+
exports.setAppUserGate = setAppUserGate;
|
|
12
|
+
exports.signalAppUserGateCheck = signalAppUserGateCheck;
|
|
13
|
+
exports.signalAppUserGateDone = signalAppUserGateDone;
|
|
14
|
+
exports.userGateModelText = userGateModelText;
|
|
15
|
+
var _index = require("../i18n/index.js");
|
|
16
|
+
var _sensitiveScreen = require("./sensitiveScreen.js");
|
|
17
|
+
var _screenEvidence = require("./screenEvidence.js");
|
|
18
|
+
/**
|
|
19
|
+
* Sensitive steps the agent must NOT automate:
|
|
20
|
+
* user completes them in the App (or system UI), then the run resumes.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const PASSWORD_RE = /密码|支付密码|交易密码|登录密码|安全码|设置密码|确认密码|创建密码|输入密码|passcode|password|passwd|\bpin\b|\bcvv\b|\botp\b|验证码|短信验证|set\s*passcode|confirm\s*passcode/i;
|
|
24
|
+
const AUTH_RE = /继续使用\s*(google|apple|github)|sign\s*in\s*with|oauth|授权登录|授权连接|连接硬件|配对|pair\s*device|connect\s*wallet|walletconnect|批准|approve\s*(request|connection)|允许此|允许访问/i;
|
|
25
|
+
const BIO_RE = /面容|指纹|触控\s*id|face\s*id|touch\s*id|biometric|生物识别|解锁以/i;
|
|
26
|
+
const PERMISSION_RE = /(?:想|希望|请求|需要).{0,16}(?:访问|使用|发送通知|获取|拍摄|录音)|是否允许|允许.{0,24}(?:访问|使用|拍摄|录音|定位|相机|蓝牙|麦克风|照片)|(?:would\s+like|wants?|requests?)\s+to\s+(?:access|use|send|record)|allow\s+(?:access\s+to|use\s+of)/i;
|
|
27
|
+
const CONSENT_RE = /我已备份|我明白风险|同意并继续|接受条款|i\s+(?:have\s+backed\s+up|understand\s+the\s+risks)|agree\s+and\s+continue|accept\s+(?:the\s+)?terms/i;
|
|
28
|
+
function labelOf(n) {
|
|
29
|
+
return (0, _screenEvidence.nodeLabels)(n).join(' ');
|
|
30
|
+
}
|
|
31
|
+
function classifyByLabel(label, secure) {
|
|
32
|
+
if (/验证码|otp|sms/i.test(label)) return 'otp';
|
|
33
|
+
if (/\bpin\b|passcode|安全码/i.test(label)) return 'pin';
|
|
34
|
+
if (secure || /密码|password|passwd/i.test(label)) return 'password';
|
|
35
|
+
if (BIO_RE.test(label)) return 'biometric';
|
|
36
|
+
if (PERMISSION_RE.test(label)) return 'permission';
|
|
37
|
+
if (CONSENT_RE.test(label)) return 'consent';
|
|
38
|
+
if (AUTH_RE.test(label)) return 'authorization';
|
|
39
|
+
if (PASSWORD_RE.test(label)) return 'secure_input';
|
|
40
|
+
return 'secure_input';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Host-declared sensitive gate (passcode / OAuth / permissions…).
|
|
44
|
+
* Preferred when Fabric dump misses the real controls.
|
|
45
|
+
*/
|
|
46
|
+
class AppUserGateStoreImpl {
|
|
47
|
+
hostGate = null;
|
|
48
|
+
/** User tapped「已完成」— clears until host sets a new gate. */
|
|
49
|
+
manualResumeAt = 0;
|
|
50
|
+
listeners = new Set();
|
|
51
|
+
setHostGate(gate) {
|
|
52
|
+
this.hostGate = gate ? {
|
|
53
|
+
kind: gate.kind,
|
|
54
|
+
label: String(gate.label || '需要你完成').slice(0, 80),
|
|
55
|
+
nodeId: String(gate.nodeId || 'host:gate').slice(0, 80)
|
|
56
|
+
} : null;
|
|
57
|
+
if (gate) this.manualResumeAt = 0;
|
|
58
|
+
this.emit();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** User confirms they finished the sensitive App / system step. */
|
|
62
|
+
signalDone() {
|
|
63
|
+
this.hostGate = null;
|
|
64
|
+
this.manualResumeAt = Date.now();
|
|
65
|
+
this.emit();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Recheck only: the UI must not clear a host-declared private step. */
|
|
69
|
+
requestCheck() {
|
|
70
|
+
this.manualResumeAt = Date.now();
|
|
71
|
+
this.emit();
|
|
72
|
+
}
|
|
73
|
+
getHostGate() {
|
|
74
|
+
return this.hostGate;
|
|
75
|
+
}
|
|
76
|
+
wasManuallyResumedSince(sinceMs) {
|
|
77
|
+
return this.manualResumeAt > 0 && this.manualResumeAt >= sinceMs;
|
|
78
|
+
}
|
|
79
|
+
subscribe(listener) {
|
|
80
|
+
this.listeners.add(listener);
|
|
81
|
+
listener(this.hostGate);
|
|
82
|
+
return () => this.listeners.delete(listener);
|
|
83
|
+
}
|
|
84
|
+
emit() {
|
|
85
|
+
for (const l of this.listeners) l(this.hostGate);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const AppUserGateStore = exports.AppUserGateStore = new AppUserGateStoreImpl();
|
|
89
|
+
|
|
90
|
+
/** Host: current screen needs the user to finish a sensitive step. */
|
|
91
|
+
function setAppUserGate(gate) {
|
|
92
|
+
AppUserGateStore.setHostGate({
|
|
93
|
+
kind: gate.kind,
|
|
94
|
+
label: gate.label,
|
|
95
|
+
nodeId: gate.nodeId ?? `host:gate:${gate.kind}`
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function clearAppUserGate() {
|
|
99
|
+
AppUserGateStore.setHostGate(null);
|
|
100
|
+
}
|
|
101
|
+
function signalAppUserGateDone() {
|
|
102
|
+
AppUserGateStore.signalDone();
|
|
103
|
+
}
|
|
104
|
+
function signalAppUserGateCheck() {
|
|
105
|
+
AppUserGateStore.requestCheck();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Detect App / system steps the user must complete themselves.
|
|
110
|
+
* Merges host registration with dump heuristics.
|
|
111
|
+
*/
|
|
112
|
+
function detectAppUserGate(root) {
|
|
113
|
+
const host = AppUserGateStore.getHostGate();
|
|
114
|
+
if (host) return host;
|
|
115
|
+
if (!root) return null;
|
|
116
|
+
const sensitive = (0, _sensitiveScreen.sensitiveScreenKind)(root);
|
|
117
|
+
if (sensitive) {
|
|
118
|
+
return {
|
|
119
|
+
kind: sensitive,
|
|
120
|
+
label: '请在 App 内完成隐私步骤',
|
|
121
|
+
nodeId: 'local-private-screen'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
let hit = null;
|
|
125
|
+
// All permission evidence must belong to this modal, never its background.
|
|
126
|
+
const sheetPermission = sheet => {
|
|
127
|
+
const labels = [];
|
|
128
|
+
const collect = n => {
|
|
129
|
+
if (n.visible === false || (0, _screenEvidence.isSdkChrome)(n)) return;
|
|
130
|
+
labels.push(...(0, _screenEvidence.nodeLabels)(n));
|
|
131
|
+
for (const child of n.children) collect(child);
|
|
132
|
+
};
|
|
133
|
+
collect(sheet);
|
|
134
|
+
return /相机|蓝牙|麦克风|相册|通知|定位|权限|camera|bluetooth|microphone|photos|notifications|location|permission/i.test(labels.join(' ')) && labels.some(label => /^(?:允许|始终允许|使用期间允许|仅本次允许|allow(?:\s+access)?|while using(?: the app)?|only this time)$/i.test(label)) && labels.some(label => /^(?:不允许|拒绝|稍后|don.t allow|deny|not now)$/i.test(label));
|
|
135
|
+
};
|
|
136
|
+
const walk = n => {
|
|
137
|
+
if (hit || (0, _screenEvidence.isSdkChrome)(n) || n.visible === false) return;
|
|
138
|
+
if ((0, _screenEvidence.isSystemSheet)(n) && sheetPermission(n)) {
|
|
139
|
+
hit = {
|
|
140
|
+
kind: 'permission',
|
|
141
|
+
label: 'System permission request',
|
|
142
|
+
nodeId: n.id
|
|
143
|
+
};
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const label = labelOf(n);
|
|
147
|
+
const secure = n.secure === true;
|
|
148
|
+
if ((0, _screenEvidence.isPrivateInput)(n)) {
|
|
149
|
+
hit = {
|
|
150
|
+
kind: classifyByLabel(label, secure),
|
|
151
|
+
label: '请在 App 内完成安全输入',
|
|
152
|
+
nodeId: n.id
|
|
153
|
+
};
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Affirmative legal/risk consent is a real user decision even as a button.
|
|
158
|
+
if (n.clickable && (0, _screenEvidence.nodeLabels)(n).some(text => text.length <= 80 && CONSENT_RE.test(text))) {
|
|
159
|
+
hit = {
|
|
160
|
+
kind: 'consent',
|
|
161
|
+
label: '请在 App 内确认风险或条款',
|
|
162
|
+
nodeId: n.id
|
|
163
|
+
};
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
for (const c of n.children) walk(c);
|
|
167
|
+
};
|
|
168
|
+
walk(root);
|
|
169
|
+
if (hit) return hit;
|
|
170
|
+
// A short menu is still a menu. Only static requests, actual inputs, modal
|
|
171
|
+
// evidence or explicit host declarations can establish a waiting gate.
|
|
172
|
+
for (const {
|
|
173
|
+
node,
|
|
174
|
+
label
|
|
175
|
+
} of (0, _screenEvidence.staticScreenLabels)(root)) {
|
|
176
|
+
if (label.length > 160) continue;
|
|
177
|
+
const password = _screenEvidence.PRIVATE_INPUT_PROMPT_RE.test(label);
|
|
178
|
+
const biometric = BIO_RE.test(label) && /请|验证|认证|解锁|verify|authenticate|unlock|use .+ to/i.test(label);
|
|
179
|
+
const authorization = AUTH_RE.test(label) && /请|等待|批准|授权|sign\s*in\s*with|approve|authorize|confirm|pair\s*device/i.test(label);
|
|
180
|
+
if (password || PERMISSION_RE.test(label) || CONSENT_RE.test(label) || biometric || authorization) {
|
|
181
|
+
return {
|
|
182
|
+
kind: classifyByLabel(label, false),
|
|
183
|
+
label,
|
|
184
|
+
nodeId: node.id
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return hit;
|
|
189
|
+
}
|
|
190
|
+
function gateMessageValue(gate, fallbackLocale) {
|
|
191
|
+
const keys = {
|
|
192
|
+
recovery_phrase: 'runtime.recoveryPhrase',
|
|
193
|
+
private_key: 'runtime.privateKey',
|
|
194
|
+
password: 'runtime.password',
|
|
195
|
+
pin: 'runtime.pin',
|
|
196
|
+
otp: 'runtime.otp',
|
|
197
|
+
authorization: 'runtime.authorization',
|
|
198
|
+
biometric: 'runtime.biometric',
|
|
199
|
+
permission: 'runtime.permission',
|
|
200
|
+
consent: 'runtime.consent'
|
|
201
|
+
};
|
|
202
|
+
return (0, _index.message)(keys[gate.kind] ?? 'runtime.sensitiveStep', undefined, fallbackLocale);
|
|
203
|
+
}
|
|
204
|
+
function gateMessage(gate) {
|
|
205
|
+
return (0, _index.resolveText)(gateMessageValue(gate));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Planner hint — never type secrets or fake authorizations. */
|
|
209
|
+
function userGateModelText(gate) {
|
|
210
|
+
if (!gate) return '';
|
|
211
|
+
return `- [gate:${gate.kind}] 「${gate.label}」— 等待用户在 App/系统内完成,禁止 type / 禁止代填密钥密码 / 禁止伪造授权`;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=userGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","_sensitiveScreen","_screenEvidence","PASSWORD_RE","AUTH_RE","BIO_RE","PERMISSION_RE","CONSENT_RE","labelOf","n","nodeLabels","join","classifyByLabel","label","secure","test","AppUserGateStoreImpl","hostGate","manualResumeAt","listeners","Set","setHostGate","gate","kind","String","slice","nodeId","emit","signalDone","Date","now","requestCheck","getHostGate","wasManuallyResumedSince","sinceMs","subscribe","listener","add","delete","l","AppUserGateStore","exports","setAppUserGate","clearAppUserGate","signalAppUserGateDone","signalAppUserGateCheck","detectAppUserGate","root","host","sensitive","sensitiveScreenKind","hit","sheetPermission","sheet","labels","collect","visible","isSdkChrome","push","child","children","some","walk","isSystemSheet","id","isPrivateInput","clickable","text","length","c","node","staticScreenLabels","password","PRIVATE_INPUT_PROMPT_RE","biometric","authorization","gateMessageValue","fallbackLocale","keys","recovery_phrase","private_key","pin","otp","permission","consent","message","undefined","gateMessage","resolveText","userGateModelText"],"sourceRoot":"../../../src","sources":["privacy/userGate.ts"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;;AAuBA,MAAMG,WAAW,GACf,wIAAwI;AAE1I,MAAMC,OAAO,GACX,gKAAgK;AAElK,MAAMC,MAAM,GACV,wDAAwD;AAE1D,MAAMC,aAAa,GACjB,kMAAkM;AAEpM,MAAMC,UAAU,GACd,6HAA6H;AAE/H,SAASC,OAAOA,CAACC,CAAW,EAAU;EACpC,OAAO,IAAAC,0BAAU,EAACD,CAAC,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC;AAChC;AAEA,SAASC,eAAeA,CAACC,KAAa,EAAEC,MAAe,EAAmB;EACxE,IAAI,cAAc,CAACC,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,KAAK;EAC5C,IAAI,uBAAuB,CAACE,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,KAAK;EACrD,IAAIC,MAAM,IAAI,qBAAqB,CAACC,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,UAAU;EAClE,IAAIR,MAAM,CAACU,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,WAAW;EAC1C,IAAIP,aAAa,CAACS,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,YAAY;EAClD,IAAIN,UAAU,CAACQ,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,SAAS;EAC5C,IAAIT,OAAO,CAACW,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,eAAe;EAC/C,IAAIV,WAAW,CAACY,IAAI,CAACF,KAAK,CAAC,EAAE,OAAO,cAAc;EAClD,OAAO,cAAc;AACvB;AAIA;AACA;AACA;AACA;AACA,MAAMG,oBAAoB,CAAC;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,EAAEX,eAAe,CAACC,KAAK,EAAE,KAAK,CAAC;QAAEA,KAAK;QAAEa,MAAM,EAAE4C,IAAI,CAACN;MAAG,CAAC;IACxE;EACF;EACA,OAAOb,GAAG;AACZ;AAEO,SAASyB,gBAAgBA,CAACtD,IAAiB,EAAEuD,cAAuB,EAAE;EAC3E,MAAMC,IAAkD,GAAG;IACzDC,eAAe,EAAE,wBAAwB;IAAEC,WAAW,EAAE,oBAAoB;IAC5ER,QAAQ,EAAE,kBAAkB;IAAES,GAAG,EAAE,aAAa;IAAEC,GAAG,EAAE,aAAa;IACpEP,aAAa,EAAE,uBAAuB;IAAED,SAAS,EAAE,mBAAmB;IACtES,UAAU,EAAE,oBAAoB;IAAEC,OAAO,EAAE;EAC7C,CAAC;EACD,OAAO,IAAAC,cAAO,EAACP,IAAI,CAACxD,IAAI,CAACC,IAAI,CAAC,IAAI,uBAAuB,EAAE+D,SAAS,EAAET,cAAc,CAAC;AACvF;AAEO,SAASU,WAAWA,CAACjE,IAAiB,EAAU;EACrD,OAAO,IAAAkE,kBAAW,EAACZ,gBAAgB,CAACtD,IAAI,CAAC,CAAC;AAC5C;;AAEA;AACO,SAASmE,iBAAiBA,CAACnE,IAAwB,EAAU;EAClE,IAAI,CAACA,IAAI,EAAE,OAAO,EAAE;EACpB,OAAO,WAAWA,IAAI,CAACC,IAAI,MAAMD,IAAI,CAACT,KAAK,gDAAgD;AAC7F","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.executeAgentAction = executeAgentAction;
|
|
7
|
+
/**
|
|
8
|
+
* Execute one cloud-agent tool call against the local SDK.
|
|
9
|
+
*/
|
|
10
|
+
async function executeAgentAction(agent, action) {
|
|
11
|
+
try {
|
|
12
|
+
switch (action.tool) {
|
|
13
|
+
case 'dump':
|
|
14
|
+
{
|
|
15
|
+
const tree = await agent.dump(action.args);
|
|
16
|
+
return {
|
|
17
|
+
ok: true,
|
|
18
|
+
tool: 'dump',
|
|
19
|
+
tree
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
case 'find':
|
|
23
|
+
{
|
|
24
|
+
const node = await agent.find(action.args.selector);
|
|
25
|
+
return {
|
|
26
|
+
ok: true,
|
|
27
|
+
tool: 'find',
|
|
28
|
+
node
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
case 'findAll':
|
|
32
|
+
{
|
|
33
|
+
const nodes = await agent.findAll(action.args.selector);
|
|
34
|
+
return {
|
|
35
|
+
ok: true,
|
|
36
|
+
tool: 'findAll',
|
|
37
|
+
nodes
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
case 'tap':
|
|
41
|
+
{
|
|
42
|
+
await agent.tap({
|
|
43
|
+
selector: action.args.selector,
|
|
44
|
+
nodeId: action.args.nodeId,
|
|
45
|
+
point: action.args.point,
|
|
46
|
+
options: action.args.options
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
ok: true,
|
|
50
|
+
tool: 'tap'
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
case 'swipe':
|
|
54
|
+
{
|
|
55
|
+
await agent.swipe(action.args.from, action.args.to, action.args.options);
|
|
56
|
+
return {
|
|
57
|
+
ok: true,
|
|
58
|
+
tool: 'swipe'
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
case 'pinch':
|
|
62
|
+
{
|
|
63
|
+
await agent.pinch(action.args.center, action.args.scale, action.args.options);
|
|
64
|
+
return {
|
|
65
|
+
ok: true,
|
|
66
|
+
tool: 'pinch'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
case 'type':
|
|
70
|
+
{
|
|
71
|
+
await agent.type(action.args.text, {
|
|
72
|
+
selector: action.args.selector,
|
|
73
|
+
nodeId: action.args.nodeId,
|
|
74
|
+
options: action.args.options
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
ok: true,
|
|
78
|
+
tool: 'type'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
case 'confirm':
|
|
82
|
+
{
|
|
83
|
+
const confirmed = await agent.requestConfirm({
|
|
84
|
+
action: action.args.action ?? 'confirm',
|
|
85
|
+
label: action.args.label
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
ok: true,
|
|
89
|
+
tool: 'confirm',
|
|
90
|
+
confirmed
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
default:
|
|
94
|
+
{
|
|
95
|
+
const _exhaustive = action;
|
|
96
|
+
return {
|
|
97
|
+
ok: false,
|
|
98
|
+
tool: 'dump',
|
|
99
|
+
error: `Unknown tool: ${JSON.stringify(_exhaustive)}`
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
} catch (e) {
|
|
104
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
105
|
+
return {
|
|
106
|
+
ok: false,
|
|
107
|
+
tool: action.tool,
|
|
108
|
+
error: message
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["executeAgentAction","agent","action","tool","tree","dump","args","ok","node","find","selector","nodes","findAll","tap","nodeId","point","options","swipe","from","to","pinch","center","scale","type","text","confirmed","requestConfirm","label","_exhaustive","error","JSON","stringify","e","message","Error","String"],"sourceRoot":"../../../src","sources":["protocol/actions.ts"],"mappings":";;;;;;AAGA;AACA;AACA;AACO,eAAeA,kBAAkBA,CACtCC,KAAgB,EAChBC,MAAmB,EACS;EAC5B,IAAI;IACF,QAAQA,MAAM,CAACC,IAAI;MACjB,KAAK,MAAM;QAAE;UACX,MAAMC,IAAI,GAAG,MAAMH,KAAK,CAACI,IAAI,CAACH,MAAM,CAACI,IAAI,CAAC;UAC1C,OAAO;YAAEC,EAAE,EAAE,IAAI;YAA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
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HostAppearanceStore = void 0;
|
|
7
|
+
exports.getKokoAppearance = getKokoAppearance;
|
|
8
|
+
exports.invertTheme = invertTheme;
|
|
9
|
+
exports.resolveChromeColors = resolveChromeColors;
|
|
10
|
+
exports.resolveEffectiveLocale = resolveEffectiveLocale;
|
|
11
|
+
exports.resolveThemeColors = resolveThemeColors;
|
|
12
|
+
exports.setKokoAppearance = setKokoAppearance;
|
|
13
|
+
/**
|
|
14
|
+
* Runtime host appearance (locale / theme). Prefer this over static
|
|
15
|
+
* `config.locale` / `config.theme` so the host can follow its own settings.
|
|
16
|
+
*/
|
|
17
|
+
class HostAppearanceStoreImpl {
|
|
18
|
+
state = {};
|
|
19
|
+
listeners = new Set();
|
|
20
|
+
get() {
|
|
21
|
+
return this.state;
|
|
22
|
+
}
|
|
23
|
+
set(partial) {
|
|
24
|
+
const next = {
|
|
25
|
+
locale: partial.locale !== undefined ? partial.locale : this.state.locale,
|
|
26
|
+
theme: partial.theme !== undefined ? partial.theme : this.state.theme
|
|
27
|
+
};
|
|
28
|
+
if (next.locale === this.state.locale && next.theme === this.state.theme) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.state = next;
|
|
32
|
+
for (const l of this.listeners) l();
|
|
33
|
+
}
|
|
34
|
+
subscribe(listener) {
|
|
35
|
+
this.listeners.add(listener);
|
|
36
|
+
return () => {
|
|
37
|
+
this.listeners.delete(listener);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const HostAppearanceStore = exports.HostAppearanceStore = new HostAppearanceStoreImpl();
|
|
42
|
+
|
|
43
|
+
/** Imperative API for hosts (OneKey / shop / etc.). */
|
|
44
|
+
function setKokoAppearance(partial) {
|
|
45
|
+
HostAppearanceStore.set(partial);
|
|
46
|
+
}
|
|
47
|
+
function getKokoAppearance() {
|
|
48
|
+
return HostAppearanceStore.get();
|
|
49
|
+
}
|
|
50
|
+
const DARK = {
|
|
51
|
+
mode: 'dark',
|
|
52
|
+
sheetBg: '#121316',
|
|
53
|
+
overlay: 'rgba(8, 10, 14, 0.58)',
|
|
54
|
+
text: '#F5F5F7',
|
|
55
|
+
textSecondary: 'rgba(255,255,255,0.72)',
|
|
56
|
+
textMuted: 'rgba(255,255,255,0.45)',
|
|
57
|
+
border: 'rgba(255,255,255,0.1)',
|
|
58
|
+
inputBg: 'rgba(255,255,255,0.06)',
|
|
59
|
+
chipBg: 'rgba(255,255,255,0.05)',
|
|
60
|
+
userBubble: 'rgba(10,132,255,0.18)',
|
|
61
|
+
handle: 'rgba(255,255,255,0.22)',
|
|
62
|
+
progressBg: 'rgba(20,20,22,0.94)',
|
|
63
|
+
progressText: '#fff',
|
|
64
|
+
dialogBg: '#1C1C1E',
|
|
65
|
+
statusBar: 'light-content'
|
|
66
|
+
};
|
|
67
|
+
const LIGHT = {
|
|
68
|
+
mode: 'light',
|
|
69
|
+
sheetBg: '#FFFFFF',
|
|
70
|
+
overlay: 'rgba(0, 0, 0, 0.48)',
|
|
71
|
+
text: '#111827',
|
|
72
|
+
textSecondary: 'rgba(17,24,39,0.72)',
|
|
73
|
+
textMuted: 'rgba(17,24,39,0.45)',
|
|
74
|
+
border: 'rgba(17,24,39,0.1)',
|
|
75
|
+
inputBg: 'rgba(17,24,39,0.05)',
|
|
76
|
+
chipBg: 'rgba(17,24,39,0.04)',
|
|
77
|
+
userBubble: 'rgba(10,132,255,0.12)',
|
|
78
|
+
handle: 'rgba(17,24,39,0.18)',
|
|
79
|
+
progressBg: 'rgba(255,255,255,0.96)',
|
|
80
|
+
progressText: '#111827',
|
|
81
|
+
dialogBg: '#FFFFFF',
|
|
82
|
+
statusBar: 'dark-content'
|
|
83
|
+
};
|
|
84
|
+
function resolveThemeColors(theme) {
|
|
85
|
+
return theme === 'light' ? LIGHT : DARK;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Theme for Koko chrome, given the host App's theme.
|
|
90
|
+
*
|
|
91
|
+
* Inverted on purpose: the progress pill, chat sheet and dialogs sit above the
|
|
92
|
+
* host UI as a distinct surface. Matching the App makes them blend into
|
|
93
|
+
* whatever is behind them; opposing it keeps the boundary obvious.
|
|
94
|
+
*
|
|
95
|
+
* A host that reports nothing is assumed light, which keeps chrome dark — the
|
|
96
|
+
* SDK's long-standing default.
|
|
97
|
+
*/
|
|
98
|
+
function invertTheme(appTheme) {
|
|
99
|
+
return appTheme === 'dark' ? 'light' : 'dark';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Chrome colors for a host App running `appTheme`. */
|
|
103
|
+
function resolveChromeColors(appTheme) {
|
|
104
|
+
return resolveThemeColors(invertTheme(appTheme));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Resolve effective locale: host appearance → config → en. */
|
|
108
|
+
function resolveEffectiveLocale(hostLocale, configLocale) {
|
|
109
|
+
return hostLocale ?? configLocale;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=HostAppearanceStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["HostAppearanceStoreImpl","state","listeners","Set","get","set","partial","next","locale","undefined","theme","l","subscribe","listener","add","delete","HostAppearanceStore","exports","setKokoAppearance","getKokoAppearance","DARK","mode","sheetBg","overlay","text","textSecondary","textMuted","border","inputBg","chipBg","userBubble","handle","progressBg","progressText","dialogBg","statusBar","LIGHT","resolveThemeColors","invertTheme","appTheme","resolveChromeColors","resolveEffectiveLocale","hostLocale","configLocale"],"sourceRoot":"../../../src","sources":["provider/HostAppearanceStore.ts"],"mappings":";;;;;;;;;;;;AAkBA;AACA;AACA;AACA;AACA,MAAMA,uBAAuB,CAAC;EACpBC,KAAK,GAAmB,CAAC,CAAC;EAC1BC,SAAS,GAAG,IAAIC,GAAG,CAAW,CAAC;EAEvCC,GAAGA,CAAA,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|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.KokoProvider = KokoProvider;
|
|
7
|
+
exports.useKokoAgent = useKokoAgent;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _CursorOverlay = require("../cursor/CursorOverlay.js");
|
|
11
|
+
var _KokoAgent = require("../KokoAgent.js");
|
|
12
|
+
var _KokoDialogHost = require("../ui/KokoDialogHost.js");
|
|
13
|
+
var _KokoObserver = require("../ui/KokoObserver.js");
|
|
14
|
+
var _KokoRemoteSmoke = require("../debug/KokoRemoteSmoke.js");
|
|
15
|
+
var _KokoUiContext = require("./KokoUiContext.js");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
var cache;
|
|
18
|
+
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
19
|
+
const KokoContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
20
|
+
function KokoProvider({
|
|
21
|
+
children,
|
|
22
|
+
config,
|
|
23
|
+
cursor = true,
|
|
24
|
+
observer,
|
|
25
|
+
composerPlaceholder,
|
|
26
|
+
dialogs = true,
|
|
27
|
+
remoteSmokePort,
|
|
28
|
+
resumeAfterReload = true
|
|
29
|
+
}) {
|
|
30
|
+
const mergedConfig = (0, _react.useMemo)(() => {
|
|
31
|
+
if (!config && !composerPlaceholder) return config;
|
|
32
|
+
return {
|
|
33
|
+
...config,
|
|
34
|
+
branding: {
|
|
35
|
+
...config?.branding,
|
|
36
|
+
placeholder: config?.branding?.placeholder ?? composerPlaceholder
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, [config, composerPlaceholder]);
|
|
40
|
+
const agent = (0, _react.useMemo)(() => {
|
|
41
|
+
if (mergedConfig) return (0, _KokoAgent.initKokoAgent)(mergedConfig);
|
|
42
|
+
return (0, _KokoAgent.getKokoAgent)();
|
|
43
|
+
}, [mergedConfig]);
|
|
44
|
+
const showObserver = observer ?? mergedConfig?.observer !== false;
|
|
45
|
+
const smokePort = remoteSmokePort ?? 0;
|
|
46
|
+
const resumeTried = (0, _react.useRef)(false);
|
|
47
|
+
(0, _react.useEffect)(() => {
|
|
48
|
+
if (!resumeAfterReload || resumeTried.current) return;
|
|
49
|
+
resumeTried.current = true;
|
|
50
|
+
// Let the host finish remounting its navigator first, or the resumed run
|
|
51
|
+
// plans against a half-built tree.
|
|
52
|
+
const timer = setTimeout(() => {
|
|
53
|
+
void agent.resumeInterruptedRun().catch(() => {});
|
|
54
|
+
}, 1500);
|
|
55
|
+
return () => clearTimeout(timer);
|
|
56
|
+
}, [agent, resumeAfterReload]);
|
|
57
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(KokoContext.Provider, {
|
|
58
|
+
value: agent,
|
|
59
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_KokoUiContext.KokoUiProvider, {
|
|
60
|
+
config: mergedConfig,
|
|
61
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
62
|
+
style: styles.root,
|
|
63
|
+
children: [children, cursor && !showObserver ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CursorOverlay.CursorOverlay, {}) : null, showObserver ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_KokoObserver.KokoObserver, {
|
|
64
|
+
cursor: cursor
|
|
65
|
+
}) : null, dialogs ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_KokoDialogHost.KokoDialogHost, {}) : null, smokePort > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_KokoRemoteSmoke.KokoRemoteSmoke, {
|
|
66
|
+
port: smokePort
|
|
67
|
+
}) : null]
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function useKokoAgent() {
|
|
73
|
+
const ctx = (0, _react.useContext)(KokoContext);
|
|
74
|
+
return ctx ?? (0, _KokoAgent.getKokoAgent)();
|
|
75
|
+
}
|
|
76
|
+
const styles = _reactNative.StyleSheet.create({
|
|
77
|
+
root: {
|
|
78
|
+
flex: 1
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=KokoProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_CursorOverlay","_KokoAgent","_KokoDialogHost","_KokoObserver","_KokoRemoteSmoke","_KokoUiContext","_jsxRuntime","cache","e","t","__esModule","r","c","a","Object","defineProperty","n","__proto__","default","WeakMap","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","KokoContext","createContext","KokoProvider","children","config","cursor","observer","composerPlaceholder","dialogs","remoteSmokePort","resumeAfterReload","mergedConfig","useMemo","branding","placeholder","agent","initKokoAgent","getKokoAgent","showObserver","smokePort","resumeTried","useRef","useEffect","current","timer","setTimeout","resumeInterruptedRun","catch","clearTimeout","jsx","Provider","value","KokoUiProvider","jsxs","View","style","styles","root","CursorOverlay","KokoObserver","KokoDialogHost","KokoRemoteSmoke","port","useKokoAgent","ctx","useContext","StyleSheet","create","flex"],"sourceRoot":"../../../src","sources":["provider/KokoProvider.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAQA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,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AAClD,cAAA,CAAAqD,cAAc;MAAC5B,MAAM,EAAEO,YAAa;MAAAR,QAAA,eACnC,IAAAvB,WAAA,CAAAqD,IAAA,EAAC5D,YAAA,CAAA6D,IAAI;QAACC,KAAK,EAAEC,MAAM,CAACC,IAAK;QAAAlC,QAAA,GACtBA,QAAQ,EAERE,MAAM,IAAI,CAACa,YAAY,gBAAG,IAAAtC,WAAA,CAAAiD,GAAA,EAACvD,cAAA,CAAAgE,aAAa,IAAE,CAAC,GAAG,IAAI,EAClDpB,YAAY,gBAAG,IAAAtC,WAAA,CAAAiD,GAAA,EAACpD,aAAA,CAAA8D,YAAY;UAAClC,MAAM,EAAEA;QAAO,CAAE,CAAC,GAAG,IAAI,EACtDG,OAAO,gBAAG,IAAA5B,WAAA,CAAAiD,GAAA,EAACrD,eAAA,CAAAgE,cAAc,IAAE,CAAC,GAAG,IAAI,EACnCrB,SAAS,GAAG,CAAC,gBAAG,IAAAvC,WAAA,CAAAiD,GAAA,EAACnD,gBAAA,CAAA+D,eAAe;UAACC,IAAI,EAAEvB;QAAU,CAAE,CAAC,GAAG,IAAI;MAAA,CACxD;IAAC,CACO;EAAC,CACG,CAAC;AAE3B;AAEO,SAASwB,YAAYA,CAAA,EAAc;EACxC,MAAMC,GAAG,GAAG,IAAAC,iBAAU,EAAC7C,WAAW,CAAC;EACnC,OAAO4C,GAAG,IAAI,IAAA3B,uBAAY,EAAC,CAAC;AAC9B;AAEA,MAAMmB,MAAM,GAAGU,uBAAU,CAACC,MAAM,CAAC;EAC/BV,IAAI,EAAE;IAAEW,IAAI,EAAE;EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.KokoUiProvider = KokoUiProvider;
|
|
7
|
+
exports.useKokoUi = useKokoUi;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _AccountStore = require("../commercial/AccountStore.js");
|
|
10
|
+
var _branding = require("../commercial/branding.js");
|
|
11
|
+
var _UsageBus = require("../commercial/UsageBus.js");
|
|
12
|
+
var _index = require("../i18n/index.js");
|
|
13
|
+
var _HostAppearanceStore = require("./HostAppearanceStore.js");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
var cache;
|
|
16
|
+
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
17
|
+
const KokoUiContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
18
|
+
function subscribeAccount(cb) {
|
|
19
|
+
return _AccountStore.AccountStore.subscribe(() => cb());
|
|
20
|
+
}
|
|
21
|
+
function getAccountSnapshot() {
|
|
22
|
+
return _AccountStore.AccountStore.get();
|
|
23
|
+
}
|
|
24
|
+
function subscribeAppearance(cb) {
|
|
25
|
+
return _HostAppearanceStore.HostAppearanceStore.subscribe(cb);
|
|
26
|
+
}
|
|
27
|
+
function getAppearanceSnapshot() {
|
|
28
|
+
return _HostAppearanceStore.HostAppearanceStore.get();
|
|
29
|
+
}
|
|
30
|
+
function KokoUiProvider({
|
|
31
|
+
config,
|
|
32
|
+
children
|
|
33
|
+
}) {
|
|
34
|
+
const appearance = (0, _react.useSyncExternalStore)(subscribeAppearance, getAppearanceSnapshot, getAppearanceSnapshot);
|
|
35
|
+
const locale = (0, _index.normalizeLocale)(appearance.locale ?? config?.locale);
|
|
36
|
+
// `theme` names the host App's theme; chrome takes the other one so it stays
|
|
37
|
+
// readable against the App behind it. Absent a report, assume a light App —
|
|
38
|
+
// that keeps chrome dark, as it has always been.
|
|
39
|
+
const appTheme = appearance.theme ?? config?.theme ?? 'light';
|
|
40
|
+
const theme = (0, _HostAppearanceStore.invertTheme)(appTheme);
|
|
41
|
+
const colors = (0, _react.useMemo)(() => (0, _HostAppearanceStore.resolveThemeColors)(theme), [theme]);
|
|
42
|
+
const account = (0, _react.useSyncExternalStore)(subscribeAccount, getAccountSnapshot, getAccountSnapshot);
|
|
43
|
+
const downgradeEmitted = (0, _react.useRef)(false);
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
const unsub = config?.onUsageEvent ? _UsageBus.UsageBus.subscribe(config.onUsageEvent) : undefined;
|
|
46
|
+
return () => {
|
|
47
|
+
unsub?.();
|
|
48
|
+
};
|
|
49
|
+
}, [config?.onUsageEvent]);
|
|
50
|
+
(0, _react.useEffect)(() => {
|
|
51
|
+
const token = config?.gateway?.token;
|
|
52
|
+
if (!token) return;
|
|
53
|
+
void _AccountStore.AccountStore.refresh({
|
|
54
|
+
token,
|
|
55
|
+
baseUrl: config?.gateway?.baseUrl
|
|
56
|
+
});
|
|
57
|
+
}, [config?.gateway?.token, config?.gateway?.baseUrl]);
|
|
58
|
+
const branding = (0, _react.useMemo)(() => (0, _branding.resolveBranding)(locale, config?.branding, account?.entitlements), [locale, config?.branding, account?.entitlements]);
|
|
59
|
+
(0, _react.useEffect)(() => {
|
|
60
|
+
if (branding.downgraded && !downgradeEmitted.current) {
|
|
61
|
+
downgradeEmitted.current = true;
|
|
62
|
+
_UsageBus.UsageBus.emit({
|
|
63
|
+
type: 'branding_downgraded',
|
|
64
|
+
reason: 'missing_entitlement',
|
|
65
|
+
at: Date.now()
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (!branding.downgraded) downgradeEmitted.current = false;
|
|
69
|
+
}, [branding.downgraded]);
|
|
70
|
+
const value = (0, _react.useMemo)(() => ({
|
|
71
|
+
locale,
|
|
72
|
+
theme,
|
|
73
|
+
appTheme,
|
|
74
|
+
colors,
|
|
75
|
+
branding,
|
|
76
|
+
account,
|
|
77
|
+
t: (key, vars) => (0, _index.t)(locale, key, vars)
|
|
78
|
+
}), [locale, theme, appTheme, colors, branding, account]);
|
|
79
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(KokoUiContext.Provider, {
|
|
80
|
+
value: value,
|
|
81
|
+
children: children
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function useKokoUi() {
|
|
85
|
+
const ctx = (0, _react.useContext)(KokoUiContext);
|
|
86
|
+
if (!ctx) {
|
|
87
|
+
const locale = 'en';
|
|
88
|
+
const appTheme = 'light';
|
|
89
|
+
const theme = (0, _HostAppearanceStore.invertTheme)(appTheme);
|
|
90
|
+
return {
|
|
91
|
+
locale,
|
|
92
|
+
theme,
|
|
93
|
+
appTheme,
|
|
94
|
+
colors: (0, _HostAppearanceStore.resolveThemeColors)(theme),
|
|
95
|
+
branding: (0, _branding.resolveBranding)(locale, undefined, undefined),
|
|
96
|
+
account: null,
|
|
97
|
+
t: (key, vars) => (0, _index.t)(locale, key, vars)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return ctx;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=KokoUiContext.js.map
|