@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,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { message, resolveText } from "../i18n/index.js";
|
|
4
|
+
import { sensitiveScreenKind } from "./sensitiveScreen.js";
|
|
5
|
+
import { isPrivateInput, isSdkChrome, isSystemSheet, nodeLabels, PRIVATE_INPUT_PROMPT_RE, staticScreenLabels } from "./screenEvidence.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Sensitive steps the agent must NOT automate:
|
|
9
|
+
* user completes them in the App (or system UI), then the run resumes.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const PASSWORD_RE = /密码|支付密码|交易密码|登录密码|安全码|设置密码|确认密码|创建密码|输入密码|passcode|password|passwd|\bpin\b|\bcvv\b|\botp\b|验证码|短信验证|set\s*passcode|confirm\s*passcode/i;
|
|
13
|
+
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;
|
|
14
|
+
const BIO_RE = /面容|指纹|触控\s*id|face\s*id|touch\s*id|biometric|生物识别|解锁以/i;
|
|
15
|
+
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;
|
|
16
|
+
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;
|
|
17
|
+
function labelOf(n) {
|
|
18
|
+
return nodeLabels(n).join(' ');
|
|
19
|
+
}
|
|
20
|
+
function classifyByLabel(label, secure) {
|
|
21
|
+
if (/验证码|otp|sms/i.test(label)) return 'otp';
|
|
22
|
+
if (/\bpin\b|passcode|安全码/i.test(label)) return 'pin';
|
|
23
|
+
if (secure || /密码|password|passwd/i.test(label)) return 'password';
|
|
24
|
+
if (BIO_RE.test(label)) return 'biometric';
|
|
25
|
+
if (PERMISSION_RE.test(label)) return 'permission';
|
|
26
|
+
if (CONSENT_RE.test(label)) return 'consent';
|
|
27
|
+
if (AUTH_RE.test(label)) return 'authorization';
|
|
28
|
+
if (PASSWORD_RE.test(label)) return 'secure_input';
|
|
29
|
+
return 'secure_input';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Host-declared sensitive gate (passcode / OAuth / permissions…).
|
|
33
|
+
* Preferred when Fabric dump misses the real controls.
|
|
34
|
+
*/
|
|
35
|
+
class AppUserGateStoreImpl {
|
|
36
|
+
hostGate = null;
|
|
37
|
+
/** User tapped「已完成」— clears until host sets a new gate. */
|
|
38
|
+
manualResumeAt = 0;
|
|
39
|
+
listeners = new Set();
|
|
40
|
+
setHostGate(gate) {
|
|
41
|
+
this.hostGate = gate ? {
|
|
42
|
+
kind: gate.kind,
|
|
43
|
+
label: String(gate.label || '需要你完成').slice(0, 80),
|
|
44
|
+
nodeId: String(gate.nodeId || 'host:gate').slice(0, 80)
|
|
45
|
+
} : null;
|
|
46
|
+
if (gate) this.manualResumeAt = 0;
|
|
47
|
+
this.emit();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** User confirms they finished the sensitive App / system step. */
|
|
51
|
+
signalDone() {
|
|
52
|
+
this.hostGate = null;
|
|
53
|
+
this.manualResumeAt = Date.now();
|
|
54
|
+
this.emit();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Recheck only: the UI must not clear a host-declared private step. */
|
|
58
|
+
requestCheck() {
|
|
59
|
+
this.manualResumeAt = Date.now();
|
|
60
|
+
this.emit();
|
|
61
|
+
}
|
|
62
|
+
getHostGate() {
|
|
63
|
+
return this.hostGate;
|
|
64
|
+
}
|
|
65
|
+
wasManuallyResumedSince(sinceMs) {
|
|
66
|
+
return this.manualResumeAt > 0 && this.manualResumeAt >= sinceMs;
|
|
67
|
+
}
|
|
68
|
+
subscribe(listener) {
|
|
69
|
+
this.listeners.add(listener);
|
|
70
|
+
listener(this.hostGate);
|
|
71
|
+
return () => this.listeners.delete(listener);
|
|
72
|
+
}
|
|
73
|
+
emit() {
|
|
74
|
+
for (const l of this.listeners) l(this.hostGate);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const AppUserGateStore = new AppUserGateStoreImpl();
|
|
78
|
+
|
|
79
|
+
/** Host: current screen needs the user to finish a sensitive step. */
|
|
80
|
+
export function setAppUserGate(gate) {
|
|
81
|
+
AppUserGateStore.setHostGate({
|
|
82
|
+
kind: gate.kind,
|
|
83
|
+
label: gate.label,
|
|
84
|
+
nodeId: gate.nodeId ?? `host:gate:${gate.kind}`
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export function clearAppUserGate() {
|
|
88
|
+
AppUserGateStore.setHostGate(null);
|
|
89
|
+
}
|
|
90
|
+
export function signalAppUserGateDone() {
|
|
91
|
+
AppUserGateStore.signalDone();
|
|
92
|
+
}
|
|
93
|
+
export function signalAppUserGateCheck() {
|
|
94
|
+
AppUserGateStore.requestCheck();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Detect App / system steps the user must complete themselves.
|
|
99
|
+
* Merges host registration with dump heuristics.
|
|
100
|
+
*/
|
|
101
|
+
export function detectAppUserGate(root) {
|
|
102
|
+
const host = AppUserGateStore.getHostGate();
|
|
103
|
+
if (host) return host;
|
|
104
|
+
if (!root) return null;
|
|
105
|
+
const sensitive = sensitiveScreenKind(root);
|
|
106
|
+
if (sensitive) {
|
|
107
|
+
return {
|
|
108
|
+
kind: sensitive,
|
|
109
|
+
label: '请在 App 内完成隐私步骤',
|
|
110
|
+
nodeId: 'local-private-screen'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
let hit = null;
|
|
114
|
+
// All permission evidence must belong to this modal, never its background.
|
|
115
|
+
const sheetPermission = sheet => {
|
|
116
|
+
const labels = [];
|
|
117
|
+
const collect = n => {
|
|
118
|
+
if (n.visible === false || isSdkChrome(n)) return;
|
|
119
|
+
labels.push(...nodeLabels(n));
|
|
120
|
+
for (const child of n.children) collect(child);
|
|
121
|
+
};
|
|
122
|
+
collect(sheet);
|
|
123
|
+
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));
|
|
124
|
+
};
|
|
125
|
+
const walk = n => {
|
|
126
|
+
if (hit || isSdkChrome(n) || n.visible === false) return;
|
|
127
|
+
if (isSystemSheet(n) && sheetPermission(n)) {
|
|
128
|
+
hit = {
|
|
129
|
+
kind: 'permission',
|
|
130
|
+
label: 'System permission request',
|
|
131
|
+
nodeId: n.id
|
|
132
|
+
};
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const label = labelOf(n);
|
|
136
|
+
const secure = n.secure === true;
|
|
137
|
+
if (isPrivateInput(n)) {
|
|
138
|
+
hit = {
|
|
139
|
+
kind: classifyByLabel(label, secure),
|
|
140
|
+
label: '请在 App 内完成安全输入',
|
|
141
|
+
nodeId: n.id
|
|
142
|
+
};
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Affirmative legal/risk consent is a real user decision even as a button.
|
|
147
|
+
if (n.clickable && nodeLabels(n).some(text => text.length <= 80 && CONSENT_RE.test(text))) {
|
|
148
|
+
hit = {
|
|
149
|
+
kind: 'consent',
|
|
150
|
+
label: '请在 App 内确认风险或条款',
|
|
151
|
+
nodeId: n.id
|
|
152
|
+
};
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
for (const c of n.children) walk(c);
|
|
156
|
+
};
|
|
157
|
+
walk(root);
|
|
158
|
+
if (hit) return hit;
|
|
159
|
+
// A short menu is still a menu. Only static requests, actual inputs, modal
|
|
160
|
+
// evidence or explicit host declarations can establish a waiting gate.
|
|
161
|
+
for (const {
|
|
162
|
+
node,
|
|
163
|
+
label
|
|
164
|
+
} of staticScreenLabels(root)) {
|
|
165
|
+
if (label.length > 160) continue;
|
|
166
|
+
const password = PRIVATE_INPUT_PROMPT_RE.test(label);
|
|
167
|
+
const biometric = BIO_RE.test(label) && /请|验证|认证|解锁|verify|authenticate|unlock|use .+ to/i.test(label);
|
|
168
|
+
const authorization = AUTH_RE.test(label) && /请|等待|批准|授权|sign\s*in\s*with|approve|authorize|confirm|pair\s*device/i.test(label);
|
|
169
|
+
if (password || PERMISSION_RE.test(label) || CONSENT_RE.test(label) || biometric || authorization) {
|
|
170
|
+
return {
|
|
171
|
+
kind: classifyByLabel(label, false),
|
|
172
|
+
label,
|
|
173
|
+
nodeId: node.id
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return hit;
|
|
178
|
+
}
|
|
179
|
+
export function gateMessageValue(gate, fallbackLocale) {
|
|
180
|
+
const keys = {
|
|
181
|
+
recovery_phrase: 'runtime.recoveryPhrase',
|
|
182
|
+
private_key: 'runtime.privateKey',
|
|
183
|
+
password: 'runtime.password',
|
|
184
|
+
pin: 'runtime.pin',
|
|
185
|
+
otp: 'runtime.otp',
|
|
186
|
+
authorization: 'runtime.authorization',
|
|
187
|
+
biometric: 'runtime.biometric',
|
|
188
|
+
permission: 'runtime.permission',
|
|
189
|
+
consent: 'runtime.consent'
|
|
190
|
+
};
|
|
191
|
+
return message(keys[gate.kind] ?? 'runtime.sensitiveStep', undefined, fallbackLocale);
|
|
192
|
+
}
|
|
193
|
+
export function gateMessage(gate) {
|
|
194
|
+
return resolveText(gateMessageValue(gate));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Planner hint — never type secrets or fake authorizations. */
|
|
198
|
+
export function userGateModelText(gate) {
|
|
199
|
+
if (!gate) return '';
|
|
200
|
+
return `- [gate:${gate.kind}] 「${gate.label}」— 等待用户在 App/系统内完成,禁止 type / 禁止代填密钥密码 / 禁止伪造授权`;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=userGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["message","resolveText","sensitiveScreenKind","isPrivateInput","isSdkChrome","isSystemSheet","nodeLabels","PRIVATE_INPUT_PROMPT_RE","staticScreenLabels","PASSWORD_RE","AUTH_RE","BIO_RE","PERMISSION_RE","CONSENT_RE","labelOf","n","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","setAppUserGate","clearAppUserGate","signalAppUserGateDone","signalAppUserGateCheck","detectAppUserGate","root","host","sensitive","hit","sheetPermission","sheet","labels","collect","visible","push","child","children","some","walk","id","clickable","text","length","c","node","password","biometric","authorization","gateMessageValue","fallbackLocale","keys","recovery_phrase","private_key","pin","otp","permission","consent","undefined","gateMessage","userGateModelText"],"sourceRoot":"../../../src","sources":["privacy/userGate.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,WAAW,QAAyB,kBAAS;AAE/D,SAASC,mBAAmB,QAAQ,sBAAmB;AACvD,SAASC,cAAc,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,EAAEC,uBAAuB,EAAEC,kBAAkB,QAAQ,qBAAkB;;AAEtI;AACA;AACA;AACA;;AAuBA,MAAMC,WAAW,GACf,wIAAwI;AAE1I,MAAMC,OAAO,GACX,gKAAgK;AAElK,MAAMC,MAAM,GACV,wDAAwD;AAE1D,MAAMC,aAAa,GACjB,kMAAkM;AAEpM,MAAMC,UAAU,GACd,6HAA6H;AA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OAAOlF,OAAO,CAAC4E,IAAI,CAACjD,IAAI,CAACC,IAAI,CAAC,IAAI,uBAAuB,EAAEuD,SAAS,EAAER,cAAc,CAAC;AACvF;AAEA,OAAO,SAASS,WAAWA,CAACzD,IAAiB,EAAU;EACrD,OAAO1B,WAAW,CAACyE,gBAAgB,CAAC/C,IAAI,CAAC,CAAC;AAC5C;;AAEA;AACA,OAAO,SAAS0D,iBAAiBA,CAAC1D,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,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Execute one cloud-agent tool call against the local SDK.
|
|
5
|
+
*/
|
|
6
|
+
export async function executeAgentAction(agent, action) {
|
|
7
|
+
try {
|
|
8
|
+
switch (action.tool) {
|
|
9
|
+
case 'dump':
|
|
10
|
+
{
|
|
11
|
+
const tree = await agent.dump(action.args);
|
|
12
|
+
return {
|
|
13
|
+
ok: true,
|
|
14
|
+
tool: 'dump',
|
|
15
|
+
tree
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
case 'find':
|
|
19
|
+
{
|
|
20
|
+
const node = await agent.find(action.args.selector);
|
|
21
|
+
return {
|
|
22
|
+
ok: true,
|
|
23
|
+
tool: 'find',
|
|
24
|
+
node
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
case 'findAll':
|
|
28
|
+
{
|
|
29
|
+
const nodes = await agent.findAll(action.args.selector);
|
|
30
|
+
return {
|
|
31
|
+
ok: true,
|
|
32
|
+
tool: 'findAll',
|
|
33
|
+
nodes
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
case 'tap':
|
|
37
|
+
{
|
|
38
|
+
await agent.tap({
|
|
39
|
+
selector: action.args.selector,
|
|
40
|
+
nodeId: action.args.nodeId,
|
|
41
|
+
point: action.args.point,
|
|
42
|
+
options: action.args.options
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
ok: true,
|
|
46
|
+
tool: 'tap'
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
case 'swipe':
|
|
50
|
+
{
|
|
51
|
+
await agent.swipe(action.args.from, action.args.to, action.args.options);
|
|
52
|
+
return {
|
|
53
|
+
ok: true,
|
|
54
|
+
tool: 'swipe'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case 'pinch':
|
|
58
|
+
{
|
|
59
|
+
await agent.pinch(action.args.center, action.args.scale, action.args.options);
|
|
60
|
+
return {
|
|
61
|
+
ok: true,
|
|
62
|
+
tool: 'pinch'
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
case 'type':
|
|
66
|
+
{
|
|
67
|
+
await agent.type(action.args.text, {
|
|
68
|
+
selector: action.args.selector,
|
|
69
|
+
nodeId: action.args.nodeId,
|
|
70
|
+
options: action.args.options
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
ok: true,
|
|
74
|
+
tool: 'type'
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
case 'confirm':
|
|
78
|
+
{
|
|
79
|
+
const confirmed = await agent.requestConfirm({
|
|
80
|
+
action: action.args.action ?? 'confirm',
|
|
81
|
+
label: action.args.label
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
ok: true,
|
|
85
|
+
tool: 'confirm',
|
|
86
|
+
confirmed
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
default:
|
|
90
|
+
{
|
|
91
|
+
const _exhaustive = action;
|
|
92
|
+
return {
|
|
93
|
+
ok: false,
|
|
94
|
+
tool: 'dump',
|
|
95
|
+
error: `Unknown tool: ${JSON.stringify(_exhaustive)}`
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
101
|
+
return {
|
|
102
|
+
ok: false,
|
|
103
|
+
tool: action.tool,
|
|
104
|
+
error: message
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# 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;AACA,OAAO,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;YAAEJ,IAAI,EAAE,MAAM;YAAEC;UAAK,CAAC;QACzC;MACA,KAAK,MAAM;QAAE;UACX,MAAMI,IAAI,GAAG,MAAMP,KAAK,CAACQ,IAAI,CAACP,MAAM,CAACI,IAAI,CAACI,QAAQ,CAAC;UACnD,OAAO;YAAEH,EAAE,EAAE,IAAI;YAAEJ,IAAI,EAAE,MAAM;YAAEK;UAAK,CAAC;QACzC;MACA,KAAK,SAAS;QAAE;UACd,MAAMG,KAAK,GAAG,MAAMV,KAAK,CAACW,OAAO,CAACV,MAAM,CAACI,IAAI,CAACI,QAAQ,CAAC;UACvD,OAAO;YAAEH,EAAE,EAAE,IAAI;YAAEJ,IAAI,EAAE,SAAS;YAAEQ;UAAM,CAAC;QAC7C;MACA,KAAK,KAAK;QAAE;UACV,MAAMV,KAAK,CAACY,GAAG,CAAC;YACdH,QAAQ,EAAER,MAAM,CAACI,IAAI,CAACI,QAAQ;YA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;YACvCyB,KAAK,EAAEzB,MAAM,CAACI,IAAI,CAACqB;UACrB,CAAC,CAAC;UACF,OAAO;YAAEpB,EAAE,EAAE,IAAI;YAAEJ,IAAI,EAAE,SAAS;YAAEsB;UAAU,CAAC;QACjD;MACA;QAAS;UACP,MAAMG,WAAkB,GAAG1B,MAAM;UACjC,OAAO;YAAEK,EAAE,EAAE,KAAK;YAAEJ,IAAI,EAAE,MAAM;YAAE0B,KAAK,EAAE,iBAAiBC,IAAI,CAACC,SAAS,CAACH,WAAW,CAAC;UAAG,CAAC;QAC3F;IACF;EACF,CAAC,CAAC,OAAOI,CAAC,EAAE;IACV,MAAMC,OAAO,GAAGD,CAAC,YAAYE,KAAK,GAAGF,CAAC,CAACC,OAAO,GAAGE,MAAM,CAACH,CAAC,CAAC;IAC1D,OAAO;MAAEzB,EAAE,EAAE,KAAK;MAAEJ,IAAI,EAAED,MAAM,CAACC,IAAI;MAAE0B,KAAK,EAAEI;IAAQ,CAAC;EACzD;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runtime host appearance (locale / theme). Prefer this over static
|
|
5
|
+
* `config.locale` / `config.theme` so the host can follow its own settings.
|
|
6
|
+
*/
|
|
7
|
+
class HostAppearanceStoreImpl {
|
|
8
|
+
state = {};
|
|
9
|
+
listeners = new Set();
|
|
10
|
+
get() {
|
|
11
|
+
return this.state;
|
|
12
|
+
}
|
|
13
|
+
set(partial) {
|
|
14
|
+
const next = {
|
|
15
|
+
locale: partial.locale !== undefined ? partial.locale : this.state.locale,
|
|
16
|
+
theme: partial.theme !== undefined ? partial.theme : this.state.theme
|
|
17
|
+
};
|
|
18
|
+
if (next.locale === this.state.locale && next.theme === this.state.theme) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.state = next;
|
|
22
|
+
for (const l of this.listeners) l();
|
|
23
|
+
}
|
|
24
|
+
subscribe(listener) {
|
|
25
|
+
this.listeners.add(listener);
|
|
26
|
+
return () => {
|
|
27
|
+
this.listeners.delete(listener);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const HostAppearanceStore = new HostAppearanceStoreImpl();
|
|
32
|
+
|
|
33
|
+
/** Imperative API for hosts (OneKey / shop / etc.). */
|
|
34
|
+
export function setKokoAppearance(partial) {
|
|
35
|
+
HostAppearanceStore.set(partial);
|
|
36
|
+
}
|
|
37
|
+
export function getKokoAppearance() {
|
|
38
|
+
return HostAppearanceStore.get();
|
|
39
|
+
}
|
|
40
|
+
const DARK = {
|
|
41
|
+
mode: 'dark',
|
|
42
|
+
sheetBg: '#121316',
|
|
43
|
+
overlay: 'rgba(8, 10, 14, 0.58)',
|
|
44
|
+
text: '#F5F5F7',
|
|
45
|
+
textSecondary: 'rgba(255,255,255,0.72)',
|
|
46
|
+
textMuted: 'rgba(255,255,255,0.45)',
|
|
47
|
+
border: 'rgba(255,255,255,0.1)',
|
|
48
|
+
inputBg: 'rgba(255,255,255,0.06)',
|
|
49
|
+
chipBg: 'rgba(255,255,255,0.05)',
|
|
50
|
+
userBubble: 'rgba(10,132,255,0.18)',
|
|
51
|
+
handle: 'rgba(255,255,255,0.22)',
|
|
52
|
+
progressBg: 'rgba(20,20,22,0.94)',
|
|
53
|
+
progressText: '#fff',
|
|
54
|
+
dialogBg: '#1C1C1E',
|
|
55
|
+
statusBar: 'light-content'
|
|
56
|
+
};
|
|
57
|
+
const LIGHT = {
|
|
58
|
+
mode: 'light',
|
|
59
|
+
sheetBg: '#FFFFFF',
|
|
60
|
+
overlay: 'rgba(0, 0, 0, 0.48)',
|
|
61
|
+
text: '#111827',
|
|
62
|
+
textSecondary: 'rgba(17,24,39,0.72)',
|
|
63
|
+
textMuted: 'rgba(17,24,39,0.45)',
|
|
64
|
+
border: 'rgba(17,24,39,0.1)',
|
|
65
|
+
inputBg: 'rgba(17,24,39,0.05)',
|
|
66
|
+
chipBg: 'rgba(17,24,39,0.04)',
|
|
67
|
+
userBubble: 'rgba(10,132,255,0.12)',
|
|
68
|
+
handle: 'rgba(17,24,39,0.18)',
|
|
69
|
+
progressBg: 'rgba(255,255,255,0.96)',
|
|
70
|
+
progressText: '#111827',
|
|
71
|
+
dialogBg: '#FFFFFF',
|
|
72
|
+
statusBar: 'dark-content'
|
|
73
|
+
};
|
|
74
|
+
export function resolveThemeColors(theme) {
|
|
75
|
+
return theme === 'light' ? LIGHT : DARK;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Theme for Koko chrome, given the host App's theme.
|
|
80
|
+
*
|
|
81
|
+
* Inverted on purpose: the progress pill, chat sheet and dialogs sit above the
|
|
82
|
+
* host UI as a distinct surface. Matching the App makes them blend into
|
|
83
|
+
* whatever is behind them; opposing it keeps the boundary obvious.
|
|
84
|
+
*
|
|
85
|
+
* A host that reports nothing is assumed light, which keeps chrome dark — the
|
|
86
|
+
* SDK's long-standing default.
|
|
87
|
+
*/
|
|
88
|
+
export function invertTheme(appTheme) {
|
|
89
|
+
return appTheme === 'dark' ? 'light' : 'dark';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Chrome colors for a host App running `appTheme`. */
|
|
93
|
+
export function resolveChromeColors(appTheme) {
|
|
94
|
+
return resolveThemeColors(invertTheme(appTheme));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Resolve effective locale: host appearance → config → en. */
|
|
98
|
+
export function resolveEffectiveLocale(hostLocale, configLocale) {
|
|
99
|
+
return hostLocale ?? configLocale;
|
|
100
|
+
}
|
|
101
|
+
//# 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","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,EAAmB;IACpB,OAAO,IAAI,CAACH,KAAK;EACnB;EAEAI,GAAGA,CAACC,OAAuB,EAAE;IAC3B,MAAMC,IAAoB,GAAG;MAC3BC,MAAM,EACJF,OAAO,CAACE,MAAM,KAAKC,SAAS,GAAGH,OAAO,CAACE,MAAM,GAAG,IAAI,CAACP,KAAK,CAACO,MAAM;MACnEE,KAAK,EAAEJ,OAAO,CAACI,KAAK,KAAKD,SAAS,GAAGH,OAAO,CAACI,KAAK,GAAG,IAAI,CAACT,KAAK,CAACS;IAClE,CAAC;IACD,IAAIH,IAAI,CAACC,MAAM,KAAK,IAAI,CAACP,KAAK,CAACO,MAAM,IAAID,IAAI,CAACG,KAAK,KAAK,IAAI,CAACT,KAAK,CAACS,KAAK,EAAE;MACxE;IACF;IACA,IAAI,CAACT,KAAK,GAAGM,IAAI;IACjB,KAAK,MAAMI,CAAC,IAAI,IAAI,CAACT,SAAS,EAAES,CAAC,CAAC,CAAC;EACrC;EAEAC,SAASA,CAACC,QAAkB,EAAc;IACxC,IAAI,CAACX,SAAS,CAACY,GAAG,CAACD,QAAQ,CAAC;IAC5B,OAAO,MAAM;MACX,IAAI,CAACX,SAAS,CAACa,MAAM,CAACF,QAAQ,CAAC;IACjC,CAAC;EACH;AACF;AAEA,OAAO,MAAMG,mBAAmB,GAAG,IAAIhB,uBAAuB,CAAC,CAAC;;AAEhE;AACA,OAAO,SAASiB,iBAAiBA,CAACX,OAAuB,EAAE;EACzDU,mBAAmB,CAACX,GAAG,CA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GAAG,OAAO,GAAG,MAAM;AAC/C;;AAEA;AACA,OAAO,SAASC,mBAAmBA,CACjCD,QAA2B,EACV;EACjB,OAAOF,kBAAkB,CAACC,WAAW,CAACC,QAAQ,CAAC,CAAC;AAClD;;AAEA;AACA,OAAO,SAASE,sBAAsBA,CACpCC,UAAqC,EACrCC,YAAoD,EACzB;EAC3B,OAAOD,UAAU,IAAIC,YAAY;AACnC","ignoreList":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
|
+
import { CursorOverlay } from "../cursor/CursorOverlay.js";
|
|
6
|
+
import { getKokoAgent, initKokoAgent } from "../KokoAgent.js";
|
|
7
|
+
import { KokoDialogHost } from "../ui/KokoDialogHost.js";
|
|
8
|
+
import { KokoObserver } from "../ui/KokoObserver.js";
|
|
9
|
+
import { KokoRemoteSmoke } from "../debug/KokoRemoteSmoke.js";
|
|
10
|
+
import { KokoUiProvider } from "./KokoUiContext.js";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const KokoContext = /*#__PURE__*/createContext(null);
|
|
13
|
+
export function KokoProvider({
|
|
14
|
+
children,
|
|
15
|
+
config,
|
|
16
|
+
cursor = true,
|
|
17
|
+
observer,
|
|
18
|
+
composerPlaceholder,
|
|
19
|
+
dialogs = true,
|
|
20
|
+
remoteSmokePort,
|
|
21
|
+
resumeAfterReload = true
|
|
22
|
+
}) {
|
|
23
|
+
const mergedConfig = useMemo(() => {
|
|
24
|
+
if (!config && !composerPlaceholder) return config;
|
|
25
|
+
return {
|
|
26
|
+
...config,
|
|
27
|
+
branding: {
|
|
28
|
+
...config?.branding,
|
|
29
|
+
placeholder: config?.branding?.placeholder ?? composerPlaceholder
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}, [config, composerPlaceholder]);
|
|
33
|
+
const agent = useMemo(() => {
|
|
34
|
+
if (mergedConfig) return initKokoAgent(mergedConfig);
|
|
35
|
+
return getKokoAgent();
|
|
36
|
+
}, [mergedConfig]);
|
|
37
|
+
const showObserver = observer ?? mergedConfig?.observer !== false;
|
|
38
|
+
const smokePort = remoteSmokePort ?? 0;
|
|
39
|
+
const resumeTried = useRef(false);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!resumeAfterReload || resumeTried.current) return;
|
|
42
|
+
resumeTried.current = true;
|
|
43
|
+
// Let the host finish remounting its navigator first, or the resumed run
|
|
44
|
+
// plans against a half-built tree.
|
|
45
|
+
const timer = setTimeout(() => {
|
|
46
|
+
void agent.resumeInterruptedRun().catch(() => {});
|
|
47
|
+
}, 1500);
|
|
48
|
+
return () => clearTimeout(timer);
|
|
49
|
+
}, [agent, resumeAfterReload]);
|
|
50
|
+
return /*#__PURE__*/_jsx(KokoContext.Provider, {
|
|
51
|
+
value: agent,
|
|
52
|
+
children: /*#__PURE__*/_jsx(KokoUiProvider, {
|
|
53
|
+
config: mergedConfig,
|
|
54
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
55
|
+
style: styles.root,
|
|
56
|
+
children: [children, cursor && !showObserver ? /*#__PURE__*/_jsx(CursorOverlay, {}) : null, showObserver ? /*#__PURE__*/_jsx(KokoObserver, {
|
|
57
|
+
cursor: cursor
|
|
58
|
+
}) : null, dialogs ? /*#__PURE__*/_jsx(KokoDialogHost, {}) : null, smokePort > 0 ? /*#__PURE__*/_jsx(KokoRemoteSmoke, {
|
|
59
|
+
port: smokePort
|
|
60
|
+
}) : null]
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function useKokoAgent() {
|
|
66
|
+
const ctx = useContext(KokoContext);
|
|
67
|
+
return ctx ?? getKokoAgent();
|
|
68
|
+
}
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
root: {
|
|
71
|
+
flex: 1
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=KokoProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","useEffect","useMemo","useRef","StyleSheet","View","CursorOverlay","getKokoAgent","initKokoAgent","KokoDialogHost","KokoObserver","KokoRemoteSmoke","KokoUiProvider","jsx","_jsx","jsxs","_jsxs","KokoContext","KokoProvider","children","config","cursor","observer","composerPlaceholder","dialogs","remoteSmokePort","resumeAfterReload","mergedConfig","branding","placeholder","agent","showObserver","smokePort","resumeTried","current","timer","setTimeout","resumeInterruptedRun","catch","clearTimeout","Provider","value","style","styles","root","port","useKokoAgent","ctx","create","flex"],"sourceRoot":"../../../src","sources":["provider/KokoProvider.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,QAED,OAAO;AACd,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,SAASC,aAAa,QAAQ,4BAAyB;AACvD,SAASC,YAAY,EAAEC,aAAa,QAAwB,iBAAc;AAE1E,SAASC,cAAc,QAAQ,yBAAsB;AACrD,SAASC,YAAY,QAAQ,uBAAoB;AACjD,SAASC,eAAe,QAAQ,6BAA0B;AAC1D,SAASC,cAAc,QAAQ,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEjD,MAAMC,WAAW,gBAAGlB,aAAa,CAAmB,IAAI,CAAC;AAoCzD,OAAO,SAASmB,YAAYA,CAAC;EAC3BC,QAAQ;EACRC,MAAM;EACNC,MAAM,GAAG,IAAI;EACbC,QAAQ;EACRC,mBAAmB;EACnBC,OAAO,GAAG,IAAI;EACdC,eAAe;EACfC,iBAAiB,GAAG;AACH,CAAC,EAAE;EACpB,MAAMC,YAAY,GAAGzB,OAAO,CAA8B,MAAM;IAC9D,IAAI,CAACkB,MAAM,IAAI,CAACG,mB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BA,QAAQ,EAERE,MAAM,IAAI,CAACU,YAAY,gBAAGjB,IAAA,CAACR,aAAa,IAAE,CAAC,GAAG,IAAI,EAClDyB,YAAY,gBAAGjB,IAAA,CAACJ,YAAY;UAACW,MAAM,EAAEA;QAAO,CAAE,CAAC,GAAG,IAAI,EACtDG,OAAO,gBAAGV,IAAA,CAACL,cAAc,IAAE,CAAC,GAAG,IAAI,EACnCuB,SAAS,GAAG,CAAC,gBAAGlB,IAAA,CAACH,eAAe;UAACkC,IAAI,EAAEb;QAAU,CAAE,CAAC,GAAG,IAAI;MAAA,CACxD;IAAC,CACO;EAAC,CACG,CAAC;AAE3B;AAEA,OAAO,SAASc,YAAYA,CAAA,EAAc;EACxC,MAAMC,GAAG,GAAG/C,UAAU,CAACiB,WAAW,CAAC;EACnC,OAAO8B,GAAG,IAAIxC,YAAY,CAAC,CAAC;AAC9B;AAEA,MAAMoC,MAAM,GAAGvC,UAAU,CAAC4C,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IAAEK,IAAI,EAAE;EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { useSyncExternalStore } from 'react';
|
|
5
|
+
import { AccountStore } from "../commercial/AccountStore.js";
|
|
6
|
+
import { resolveBranding } from "../commercial/branding.js";
|
|
7
|
+
import { UsageBus } from "../commercial/UsageBus.js";
|
|
8
|
+
import { normalizeLocale, t } from "../i18n/index.js";
|
|
9
|
+
import { HostAppearanceStore, invertTheme, resolveThemeColors } from "./HostAppearanceStore.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const KokoUiContext = /*#__PURE__*/createContext(null);
|
|
12
|
+
function subscribeAccount(cb) {
|
|
13
|
+
return AccountStore.subscribe(() => cb());
|
|
14
|
+
}
|
|
15
|
+
function getAccountSnapshot() {
|
|
16
|
+
return AccountStore.get();
|
|
17
|
+
}
|
|
18
|
+
function subscribeAppearance(cb) {
|
|
19
|
+
return HostAppearanceStore.subscribe(cb);
|
|
20
|
+
}
|
|
21
|
+
function getAppearanceSnapshot() {
|
|
22
|
+
return HostAppearanceStore.get();
|
|
23
|
+
}
|
|
24
|
+
export function KokoUiProvider({
|
|
25
|
+
config,
|
|
26
|
+
children
|
|
27
|
+
}) {
|
|
28
|
+
const appearance = useSyncExternalStore(subscribeAppearance, getAppearanceSnapshot, getAppearanceSnapshot);
|
|
29
|
+
const locale = normalizeLocale(appearance.locale ?? config?.locale);
|
|
30
|
+
// `theme` names the host App's theme; chrome takes the other one so it stays
|
|
31
|
+
// readable against the App behind it. Absent a report, assume a light App —
|
|
32
|
+
// that keeps chrome dark, as it has always been.
|
|
33
|
+
const appTheme = appearance.theme ?? config?.theme ?? 'light';
|
|
34
|
+
const theme = invertTheme(appTheme);
|
|
35
|
+
const colors = useMemo(() => resolveThemeColors(theme), [theme]);
|
|
36
|
+
const account = useSyncExternalStore(subscribeAccount, getAccountSnapshot, getAccountSnapshot);
|
|
37
|
+
const downgradeEmitted = useRef(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const unsub = config?.onUsageEvent ? UsageBus.subscribe(config.onUsageEvent) : undefined;
|
|
40
|
+
return () => {
|
|
41
|
+
unsub?.();
|
|
42
|
+
};
|
|
43
|
+
}, [config?.onUsageEvent]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const token = config?.gateway?.token;
|
|
46
|
+
if (!token) return;
|
|
47
|
+
void AccountStore.refresh({
|
|
48
|
+
token,
|
|
49
|
+
baseUrl: config?.gateway?.baseUrl
|
|
50
|
+
});
|
|
51
|
+
}, [config?.gateway?.token, config?.gateway?.baseUrl]);
|
|
52
|
+
const branding = useMemo(() => resolveBranding(locale, config?.branding, account?.entitlements), [locale, config?.branding, account?.entitlements]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (branding.downgraded && !downgradeEmitted.current) {
|
|
55
|
+
downgradeEmitted.current = true;
|
|
56
|
+
UsageBus.emit({
|
|
57
|
+
type: 'branding_downgraded',
|
|
58
|
+
reason: 'missing_entitlement',
|
|
59
|
+
at: Date.now()
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (!branding.downgraded) downgradeEmitted.current = false;
|
|
63
|
+
}, [branding.downgraded]);
|
|
64
|
+
const value = useMemo(() => ({
|
|
65
|
+
locale,
|
|
66
|
+
theme,
|
|
67
|
+
appTheme,
|
|
68
|
+
colors,
|
|
69
|
+
branding,
|
|
70
|
+
account,
|
|
71
|
+
t: (key, vars) => t(locale, key, vars)
|
|
72
|
+
}), [locale, theme, appTheme, colors, branding, account]);
|
|
73
|
+
return /*#__PURE__*/_jsx(KokoUiContext.Provider, {
|
|
74
|
+
value: value,
|
|
75
|
+
children: children
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export function useKokoUi() {
|
|
79
|
+
const ctx = useContext(KokoUiContext);
|
|
80
|
+
if (!ctx) {
|
|
81
|
+
const locale = 'en';
|
|
82
|
+
const appTheme = 'light';
|
|
83
|
+
const theme = invertTheme(appTheme);
|
|
84
|
+
return {
|
|
85
|
+
locale,
|
|
86
|
+
theme,
|
|
87
|
+
appTheme,
|
|
88
|
+
colors: resolveThemeColors(theme),
|
|
89
|
+
branding: resolveBranding(locale, undefined, undefined),
|
|
90
|
+
account: null,
|
|
91
|
+
t: (key, vars) => t(locale, key, vars)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return ctx;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=KokoUiContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","useEffect","useMemo","useRef","useSyncExternalStore","AccountStore","resolveBranding","UsageBus","normalizeLocale","t","HostAppearanceStore","invertTheme","resolveThemeColors","jsx","_jsx","KokoUiContext","subscribeAccount","cb","subscribe","getAccountSnapshot","get","subscribeAppearance","getAppearanceSnapshot","KokoUiProvider","config","children","appearance","locale","appTheme","theme","colors","account","downgradeEmitted","unsub","onUsageEvent","undefined","token","gateway","refresh","baseUrl","branding","entitlements","downgraded","current","emit","type","reason","at","Date","now","value","key","vars","Provider","useKokoUi","ctx"],"sourceRoot":"../../../src","sources":["provider/KokoUiContext.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,QAED,OAAO;AACd,SAASC,oBAAoB,QAAQ,OAAO;AAQ5C,SAASC,YAAY,QAAQ,+BAA4B;AACzD,SACEC,eAAe,QAEV,2BAAwB;AAC/B,SAASC,QAAQ,QAAQ,2BAAwB;AACjD,SAASC,eAAe,EAAEC,CAAC,QAAyB,kBAAS;AAC7D,SACEC,mBAAmB,EACnBC,WAAW,EACXC,kBAAkB,QAEb,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAc/B,MAAMC,aAAa,gBAAGhB,aAAa,CAA4B,IAAI,CAAC;AAEpE,SAASiB,gBAAgBA,CAACC,EAAc,EAAE;EACxC,OAAOZ,YAAY,CAACa,SAAS,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;AAC3C;AAEA,SAASE,kBAAkBA,CAAA,EAAG;EAC5B,OAAOd,YAAY,CAACe,GAAG,CAAC,CAAC;AAC3B;AAEA,SAASC,mBAAmBA,CAACJ,EAAc,EAAE;EAC3C,OAAOP,mBAAmB,CAACQ,SAAS,CAACD,EAAE,CAAC;AAC1C;AAEA,SAASK,qBAAqBA,CAAA,EAAG;EAC/B,OAAOZ,mBAAmB,CAACU,GAAG,CAAC,CAAC;AAClC;AAEA,OAAO,SAASG,cAAcA,CAAC;EAC7BC,MAAM;EACNC;AAIF,CAAC,EAAE;EACD,MAAMC,UAAU,GAAGtB,oBAAoB,CACrCiB,mBAAmB,EACnBC,qBAAqB,EACrBA,qBACF,CAAC;EACD,MAAMK,MAAM,GAAGnB,eAAe,C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