@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,233 @@
|
|
|
1
|
+
import { message, resolveText, type MessageKey } from '../i18n';
|
|
2
|
+
import type { ViewNode } from '../types';
|
|
3
|
+
import { sensitiveScreenKind } from './sensitiveScreen';
|
|
4
|
+
import { isPrivateInput, isSdkChrome, isSystemSheet, nodeLabels, PRIVATE_INPUT_PROMPT_RE, staticScreenLabels } from './screenEvidence';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sensitive steps the agent must NOT automate:
|
|
8
|
+
* user completes them in the App (or system UI), then the run resumes.
|
|
9
|
+
*/
|
|
10
|
+
export type AppUserGateKind =
|
|
11
|
+
| 'recovery_phrase'
|
|
12
|
+
| 'private_key'
|
|
13
|
+
| 'password'
|
|
14
|
+
| 'pin'
|
|
15
|
+
| 'otp'
|
|
16
|
+
| 'secure_input'
|
|
17
|
+
/** OAuth / social login / hardware pairing / dApp connect — user must authorize. */
|
|
18
|
+
| 'authorization'
|
|
19
|
+
/** Face ID / Touch ID / fingerprint. */
|
|
20
|
+
| 'biometric'
|
|
21
|
+
/** System permission sheets (camera, Bluetooth, photos, …). */
|
|
22
|
+
| 'permission'
|
|
23
|
+
/** Explicit consent / legal / seed reveal confirmation the user must do. */
|
|
24
|
+
| 'consent';
|
|
25
|
+
|
|
26
|
+
export type AppUserGate = {
|
|
27
|
+
kind: AppUserGateKind;
|
|
28
|
+
label: string;
|
|
29
|
+
nodeId: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const PASSWORD_RE =
|
|
33
|
+
/密码|支付密码|交易密码|登录密码|安全码|设置密码|确认密码|创建密码|输入密码|passcode|password|passwd|\bpin\b|\bcvv\b|\botp\b|验证码|短信验证|set\s*passcode|confirm\s*passcode/i;
|
|
34
|
+
|
|
35
|
+
const AUTH_RE =
|
|
36
|
+
/继续使用\s*(google|apple|github)|sign\s*in\s*with|oauth|授权登录|授权连接|连接硬件|配对|pair\s*device|connect\s*wallet|walletconnect|批准|approve\s*(request|connection)|允许此|允许访问/i;
|
|
37
|
+
|
|
38
|
+
const BIO_RE =
|
|
39
|
+
/面容|指纹|触控\s*id|face\s*id|touch\s*id|biometric|生物识别|解锁以/i;
|
|
40
|
+
|
|
41
|
+
const PERMISSION_RE =
|
|
42
|
+
/(?:想|希望|请求|需要).{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;
|
|
43
|
+
|
|
44
|
+
const CONSENT_RE =
|
|
45
|
+
/我已备份|我明白风险|同意并继续|接受条款|i\s+(?:have\s+backed\s+up|understand\s+the\s+risks)|agree\s+and\s+continue|accept\s+(?:the\s+)?terms/i;
|
|
46
|
+
|
|
47
|
+
function labelOf(n: ViewNode): string {
|
|
48
|
+
return nodeLabels(n).join(' ');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function classifyByLabel(label: string, secure: boolean): AppUserGateKind {
|
|
52
|
+
if (/验证码|otp|sms/i.test(label)) return 'otp';
|
|
53
|
+
if (/\bpin\b|passcode|安全码/i.test(label)) return 'pin';
|
|
54
|
+
if (secure || /密码|password|passwd/i.test(label)) return 'password';
|
|
55
|
+
if (BIO_RE.test(label)) return 'biometric';
|
|
56
|
+
if (PERMISSION_RE.test(label)) return 'permission';
|
|
57
|
+
if (CONSENT_RE.test(label)) return 'consent';
|
|
58
|
+
if (AUTH_RE.test(label)) return 'authorization';
|
|
59
|
+
if (PASSWORD_RE.test(label)) return 'secure_input';
|
|
60
|
+
return 'secure_input';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type Listener = (gate: AppUserGate | null) => void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Host-declared sensitive gate (passcode / OAuth / permissions…).
|
|
67
|
+
* Preferred when Fabric dump misses the real controls.
|
|
68
|
+
*/
|
|
69
|
+
class AppUserGateStoreImpl {
|
|
70
|
+
private hostGate: AppUserGate | null = null;
|
|
71
|
+
/** User tapped「已完成」— clears until host sets a new gate. */
|
|
72
|
+
private manualResumeAt = 0;
|
|
73
|
+
private listeners = new Set<Listener>();
|
|
74
|
+
|
|
75
|
+
setHostGate(gate: AppUserGate | null) {
|
|
76
|
+
this.hostGate = gate
|
|
77
|
+
? {
|
|
78
|
+
kind: gate.kind,
|
|
79
|
+
label: String(gate.label || '需要你完成').slice(0, 80),
|
|
80
|
+
nodeId: String(gate.nodeId || 'host:gate').slice(0, 80),
|
|
81
|
+
}
|
|
82
|
+
: null;
|
|
83
|
+
if (gate) this.manualResumeAt = 0;
|
|
84
|
+
this.emit();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** User confirms they finished the sensitive App / system step. */
|
|
88
|
+
signalDone() {
|
|
89
|
+
this.hostGate = null;
|
|
90
|
+
this.manualResumeAt = Date.now();
|
|
91
|
+
this.emit();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Recheck only: the UI must not clear a host-declared private step. */
|
|
95
|
+
requestCheck() {
|
|
96
|
+
this.manualResumeAt = Date.now();
|
|
97
|
+
this.emit();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getHostGate(): AppUserGate | null {
|
|
101
|
+
return this.hostGate;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
wasManuallyResumedSince(sinceMs: number): boolean {
|
|
105
|
+
return this.manualResumeAt > 0 && this.manualResumeAt >= sinceMs;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
subscribe(listener: Listener): () => void {
|
|
109
|
+
this.listeners.add(listener);
|
|
110
|
+
listener(this.hostGate);
|
|
111
|
+
return () => this.listeners.delete(listener);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private emit() {
|
|
115
|
+
for (const l of this.listeners) l(this.hostGate);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const AppUserGateStore = new AppUserGateStoreImpl();
|
|
120
|
+
|
|
121
|
+
/** Host: current screen needs the user to finish a sensitive step. */
|
|
122
|
+
export function setAppUserGate(
|
|
123
|
+
gate: Omit<AppUserGate, 'nodeId'> & { nodeId?: string },
|
|
124
|
+
) {
|
|
125
|
+
AppUserGateStore.setHostGate({
|
|
126
|
+
kind: gate.kind,
|
|
127
|
+
label: gate.label,
|
|
128
|
+
nodeId: gate.nodeId ?? `host:gate:${gate.kind}`,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function clearAppUserGate() {
|
|
133
|
+
AppUserGateStore.setHostGate(null);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function signalAppUserGateDone() {
|
|
137
|
+
AppUserGateStore.signalDone();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function signalAppUserGateCheck() {
|
|
141
|
+
AppUserGateStore.requestCheck();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Detect App / system steps the user must complete themselves.
|
|
146
|
+
* Merges host registration with dump heuristics.
|
|
147
|
+
*/
|
|
148
|
+
export function detectAppUserGate(
|
|
149
|
+
root: ViewNode | null | undefined,
|
|
150
|
+
): AppUserGate | null {
|
|
151
|
+
const host = AppUserGateStore.getHostGate();
|
|
152
|
+
if (host) return host;
|
|
153
|
+
if (!root) return null;
|
|
154
|
+
|
|
155
|
+
const sensitive = sensitiveScreenKind(root);
|
|
156
|
+
if (sensitive) {
|
|
157
|
+
return { kind: sensitive, label: '请在 App 内完成隐私步骤', nodeId: 'local-private-screen' };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let hit: AppUserGate | null = null;
|
|
161
|
+
// All permission evidence must belong to this modal, never its background.
|
|
162
|
+
const sheetPermission = (sheet: ViewNode): boolean => {
|
|
163
|
+
const labels: string[] = [];
|
|
164
|
+
const collect = (n: ViewNode) => {
|
|
165
|
+
if (n.visible === false || isSdkChrome(n)) return;
|
|
166
|
+
labels.push(...nodeLabels(n));
|
|
167
|
+
for (const child of n.children) collect(child);
|
|
168
|
+
};
|
|
169
|
+
collect(sheet);
|
|
170
|
+
return /相机|蓝牙|麦克风|相册|通知|定位|权限|camera|bluetooth|microphone|photos|notifications|location|permission/i.test(labels.join(' ')) &&
|
|
171
|
+
labels.some(label => /^(?:允许|始终允许|使用期间允许|仅本次允许|allow(?:\s+access)?|while using(?: the app)?|only this time)$/i.test(label)) &&
|
|
172
|
+
labels.some(label => /^(?:不允许|拒绝|稍后|don.t allow|deny|not now)$/i.test(label));
|
|
173
|
+
};
|
|
174
|
+
const walk = (n: ViewNode) => {
|
|
175
|
+
if (hit || isSdkChrome(n) || n.visible === false) return;
|
|
176
|
+
if (isSystemSheet(n) && sheetPermission(n)) {
|
|
177
|
+
hit = { kind: 'permission', label: 'System permission request', nodeId: n.id };
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const label = labelOf(n);
|
|
181
|
+
const secure = n.secure === true;
|
|
182
|
+
if (isPrivateInput(n)) {
|
|
183
|
+
hit = {
|
|
184
|
+
kind: classifyByLabel(label, secure),
|
|
185
|
+
label: '请在 App 内完成安全输入',
|
|
186
|
+
nodeId: n.id,
|
|
187
|
+
};
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Affirmative legal/risk consent is a real user decision even as a button.
|
|
192
|
+
if (n.clickable && nodeLabels(n).some(text => text.length <= 80 && CONSENT_RE.test(text))) {
|
|
193
|
+
hit = { kind: 'consent', label: '请在 App 内确认风险或条款', nodeId: n.id };
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
for (const c of n.children) walk(c);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
walk(root);
|
|
200
|
+
if (hit) return hit;
|
|
201
|
+
// A short menu is still a menu. Only static requests, actual inputs, modal
|
|
202
|
+
// evidence or explicit host declarations can establish a waiting gate.
|
|
203
|
+
for (const { node, label } of staticScreenLabels(root)) {
|
|
204
|
+
if (label.length > 160) continue;
|
|
205
|
+
const password = PRIVATE_INPUT_PROMPT_RE.test(label);
|
|
206
|
+
const biometric = BIO_RE.test(label) && /请|验证|认证|解锁|verify|authenticate|unlock|use .+ to/i.test(label);
|
|
207
|
+
const authorization = AUTH_RE.test(label) && /请|等待|批准|授权|sign\s*in\s*with|approve|authorize|confirm|pair\s*device/i.test(label);
|
|
208
|
+
if (password || PERMISSION_RE.test(label) || CONSENT_RE.test(label) || biometric || authorization) {
|
|
209
|
+
return { kind: classifyByLabel(label, false), label, nodeId: node.id };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return hit;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function gateMessageValue(gate: AppUserGate, fallbackLocale?: string) {
|
|
216
|
+
const keys: Partial<Record<AppUserGateKind, MessageKey>> = {
|
|
217
|
+
recovery_phrase: 'runtime.recoveryPhrase', private_key: 'runtime.privateKey',
|
|
218
|
+
password: 'runtime.password', pin: 'runtime.pin', otp: 'runtime.otp',
|
|
219
|
+
authorization: 'runtime.authorization', biometric: 'runtime.biometric',
|
|
220
|
+
permission: 'runtime.permission', consent: 'runtime.consent',
|
|
221
|
+
};
|
|
222
|
+
return message(keys[gate.kind] ?? 'runtime.sensitiveStep', undefined, fallbackLocale);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function gateMessage(gate: AppUserGate): string {
|
|
226
|
+
return resolveText(gateMessageValue(gate));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Planner hint — never type secrets or fake authorizations. */
|
|
230
|
+
export function userGateModelText(gate: AppUserGate | null): string {
|
|
231
|
+
if (!gate) return '';
|
|
232
|
+
return `- [gate:${gate.kind}] 「${gate.label}」— 等待用户在 App/系统内完成,禁止 type / 禁止代填密钥密码 / 禁止伪造授权`;
|
|
233
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { KokoAgent } from '../KokoAgent';
|
|
2
|
+
import type { AgentAction, AgentActionResult } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Execute one cloud-agent tool call against the local SDK.
|
|
6
|
+
*/
|
|
7
|
+
export async function executeAgentAction(
|
|
8
|
+
agent: KokoAgent,
|
|
9
|
+
action: AgentAction,
|
|
10
|
+
): Promise<AgentActionResult> {
|
|
11
|
+
try {
|
|
12
|
+
switch (action.tool) {
|
|
13
|
+
case 'dump': {
|
|
14
|
+
const tree = await agent.dump(action.args);
|
|
15
|
+
return { ok: true, tool: 'dump', tree };
|
|
16
|
+
}
|
|
17
|
+
case 'find': {
|
|
18
|
+
const node = await agent.find(action.args.selector);
|
|
19
|
+
return { ok: true, tool: 'find', node };
|
|
20
|
+
}
|
|
21
|
+
case 'findAll': {
|
|
22
|
+
const nodes = await agent.findAll(action.args.selector);
|
|
23
|
+
return { ok: true, tool: 'findAll', nodes };
|
|
24
|
+
}
|
|
25
|
+
case 'tap': {
|
|
26
|
+
await agent.tap({
|
|
27
|
+
selector: action.args.selector,
|
|
28
|
+
nodeId: action.args.nodeId,
|
|
29
|
+
point: action.args.point,
|
|
30
|
+
options: action.args.options,
|
|
31
|
+
});
|
|
32
|
+
return { ok: true, tool: 'tap' };
|
|
33
|
+
}
|
|
34
|
+
case 'swipe': {
|
|
35
|
+
await agent.swipe(action.args.from, action.args.to, action.args.options);
|
|
36
|
+
return { ok: true, tool: 'swipe' };
|
|
37
|
+
}
|
|
38
|
+
case 'pinch': {
|
|
39
|
+
await agent.pinch(action.args.center, action.args.scale, action.args.options);
|
|
40
|
+
return { ok: true, tool: 'pinch' };
|
|
41
|
+
}
|
|
42
|
+
case 'type': {
|
|
43
|
+
await agent.type(action.args.text, {
|
|
44
|
+
selector: action.args.selector,
|
|
45
|
+
nodeId: action.args.nodeId,
|
|
46
|
+
options: action.args.options,
|
|
47
|
+
});
|
|
48
|
+
return { ok: true, tool: 'type' };
|
|
49
|
+
}
|
|
50
|
+
case 'confirm': {
|
|
51
|
+
const confirmed = await agent.requestConfirm({
|
|
52
|
+
action: action.args.action ?? 'confirm',
|
|
53
|
+
label: action.args.label,
|
|
54
|
+
});
|
|
55
|
+
return { ok: true, tool: 'confirm', confirmed };
|
|
56
|
+
}
|
|
57
|
+
default: {
|
|
58
|
+
const _exhaustive: never = action;
|
|
59
|
+
return { ok: false, tool: 'dump', error: `Unknown tool: ${JSON.stringify(_exhaustive)}` };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
64
|
+
return { ok: false, tool: action.tool, error: message };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { KokoLocale } from '../types';
|
|
2
|
+
|
|
3
|
+
export type KokoTheme = 'light' | 'dark';
|
|
4
|
+
|
|
5
|
+
export type KokoAppearance = {
|
|
6
|
+
locale?: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* The **host App's** theme, not the SDK's.
|
|
9
|
+
*
|
|
10
|
+
* Koko chrome floats on top of the host UI, so it renders in the opposite
|
|
11
|
+
* theme: a pill in the App's own colors disappears into the screen behind
|
|
12
|
+
* it. Report what the App is using and the SDK picks the contrasting side.
|
|
13
|
+
*/
|
|
14
|
+
theme?: KokoTheme | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type Listener = () => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runtime host appearance (locale / theme). Prefer this over static
|
|
21
|
+
* `config.locale` / `config.theme` so the host can follow its own settings.
|
|
22
|
+
*/
|
|
23
|
+
class HostAppearanceStoreImpl {
|
|
24
|
+
private state: KokoAppearance = {};
|
|
25
|
+
private listeners = new Set<Listener>();
|
|
26
|
+
|
|
27
|
+
get(): KokoAppearance {
|
|
28
|
+
return this.state;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
set(partial: KokoAppearance) {
|
|
32
|
+
const next: KokoAppearance = {
|
|
33
|
+
locale:
|
|
34
|
+
partial.locale !== undefined ? partial.locale : this.state.locale,
|
|
35
|
+
theme: partial.theme !== undefined ? partial.theme : this.state.theme,
|
|
36
|
+
};
|
|
37
|
+
if (next.locale === this.state.locale && next.theme === this.state.theme) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.state = next;
|
|
41
|
+
for (const l of this.listeners) l();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
subscribe(listener: Listener): () => void {
|
|
45
|
+
this.listeners.add(listener);
|
|
46
|
+
return () => {
|
|
47
|
+
this.listeners.delete(listener);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const HostAppearanceStore = new HostAppearanceStoreImpl();
|
|
53
|
+
|
|
54
|
+
/** Imperative API for hosts (OneKey / shop / etc.). */
|
|
55
|
+
export function setKokoAppearance(partial: KokoAppearance) {
|
|
56
|
+
HostAppearanceStore.set(partial);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getKokoAppearance(): KokoAppearance {
|
|
60
|
+
return HostAppearanceStore.get();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type KokoThemeColors = {
|
|
64
|
+
mode: KokoTheme;
|
|
65
|
+
sheetBg: string;
|
|
66
|
+
overlay: string;
|
|
67
|
+
text: string;
|
|
68
|
+
textSecondary: string;
|
|
69
|
+
textMuted: string;
|
|
70
|
+
border: string;
|
|
71
|
+
inputBg: string;
|
|
72
|
+
chipBg: string;
|
|
73
|
+
userBubble: string;
|
|
74
|
+
handle: string;
|
|
75
|
+
progressBg: string;
|
|
76
|
+
progressText: string;
|
|
77
|
+
dialogBg: string;
|
|
78
|
+
statusBar: 'light-content' | 'dark-content';
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const DARK: KokoThemeColors = {
|
|
82
|
+
mode: 'dark',
|
|
83
|
+
sheetBg: '#121316',
|
|
84
|
+
overlay: 'rgba(8, 10, 14, 0.58)',
|
|
85
|
+
text: '#F5F5F7',
|
|
86
|
+
textSecondary: 'rgba(255,255,255,0.72)',
|
|
87
|
+
textMuted: 'rgba(255,255,255,0.45)',
|
|
88
|
+
border: 'rgba(255,255,255,0.1)',
|
|
89
|
+
inputBg: 'rgba(255,255,255,0.06)',
|
|
90
|
+
chipBg: 'rgba(255,255,255,0.05)',
|
|
91
|
+
userBubble: 'rgba(10,132,255,0.18)',
|
|
92
|
+
handle: 'rgba(255,255,255,0.22)',
|
|
93
|
+
progressBg: 'rgba(20,20,22,0.94)',
|
|
94
|
+
progressText: '#fff',
|
|
95
|
+
dialogBg: '#1C1C1E',
|
|
96
|
+
statusBar: 'light-content',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const LIGHT: KokoThemeColors = {
|
|
100
|
+
mode: 'light',
|
|
101
|
+
sheetBg: '#FFFFFF',
|
|
102
|
+
overlay: 'rgba(0, 0, 0, 0.48)',
|
|
103
|
+
text: '#111827',
|
|
104
|
+
textSecondary: 'rgba(17,24,39,0.72)',
|
|
105
|
+
textMuted: 'rgba(17,24,39,0.45)',
|
|
106
|
+
border: 'rgba(17,24,39,0.1)',
|
|
107
|
+
inputBg: 'rgba(17,24,39,0.05)',
|
|
108
|
+
chipBg: 'rgba(17,24,39,0.04)',
|
|
109
|
+
userBubble: 'rgba(10,132,255,0.12)',
|
|
110
|
+
handle: 'rgba(17,24,39,0.18)',
|
|
111
|
+
progressBg: 'rgba(255,255,255,0.96)',
|
|
112
|
+
progressText: '#111827',
|
|
113
|
+
dialogBg: '#FFFFFF',
|
|
114
|
+
statusBar: 'dark-content',
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export function resolveThemeColors(theme?: KokoTheme | null): KokoThemeColors {
|
|
118
|
+
return theme === 'light' ? LIGHT : DARK;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Theme for Koko chrome, given the host App's theme.
|
|
123
|
+
*
|
|
124
|
+
* Inverted on purpose: the progress pill, chat sheet and dialogs sit above the
|
|
125
|
+
* host UI as a distinct surface. Matching the App makes them blend into
|
|
126
|
+
* whatever is behind them; opposing it keeps the boundary obvious.
|
|
127
|
+
*
|
|
128
|
+
* A host that reports nothing is assumed light, which keeps chrome dark — the
|
|
129
|
+
* SDK's long-standing default.
|
|
130
|
+
*/
|
|
131
|
+
export function invertTheme(appTheme?: KokoTheme | null): KokoTheme {
|
|
132
|
+
return appTheme === 'dark' ? 'light' : 'dark';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Chrome colors for a host App running `appTheme`. */
|
|
136
|
+
export function resolveChromeColors(
|
|
137
|
+
appTheme?: KokoTheme | null,
|
|
138
|
+
): KokoThemeColors {
|
|
139
|
+
return resolveThemeColors(invertTheme(appTheme));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Resolve effective locale: host appearance → config → en. */
|
|
143
|
+
export function resolveEffectiveLocale(
|
|
144
|
+
hostLocale: string | null | undefined,
|
|
145
|
+
configLocale: KokoLocale | string | null | undefined,
|
|
146
|
+
): string | null | undefined {
|
|
147
|
+
return hostLocale ?? configLocale;
|
|
148
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import { StyleSheet, View } from 'react-native';
|
|
10
|
+
import { CursorOverlay } from '../cursor/CursorOverlay';
|
|
11
|
+
import { getKokoAgent, initKokoAgent, type KokoAgent } from '../KokoAgent';
|
|
12
|
+
import type { KokoAgentConfig } from '../types';
|
|
13
|
+
import { KokoDialogHost } from '../ui/KokoDialogHost';
|
|
14
|
+
import { KokoObserver } from '../ui/KokoObserver';
|
|
15
|
+
import { KokoRemoteSmoke } from '../debug/KokoRemoteSmoke';
|
|
16
|
+
import { KokoUiProvider } from './KokoUiContext';
|
|
17
|
+
|
|
18
|
+
const KokoContext = createContext<KokoAgent | null>(null);
|
|
19
|
+
|
|
20
|
+
export type KokoProviderProps = {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
config?: KokoAgentConfig;
|
|
23
|
+
/** Show cursor overlay (default true). */
|
|
24
|
+
cursor?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Progress pill (running only) + chat sheet host (default true).
|
|
27
|
+
* Idle = nothing visible; open via openKokoChat() from host UI.
|
|
28
|
+
*/
|
|
29
|
+
observer?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Prefer `config.branding.placeholder` (paid entitlement) or locale defaults.
|
|
32
|
+
*/
|
|
33
|
+
composerPlaceholder?: string;
|
|
34
|
+
/** Built-in confirm / ask-user dialogs (default true). */
|
|
35
|
+
dialogs?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* DEV remote smoke driver port (poll `127.0.0.1:<port>/cmd`).
|
|
38
|
+
* Host-agnostic; omit / 0 to disable.
|
|
39
|
+
*/
|
|
40
|
+
remoteSmokePort?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Resume a goal that a JS-context restart interrupted (default true).
|
|
43
|
+
*
|
|
44
|
+
* Actions like changing locale or theme can remount the RN root, which kills
|
|
45
|
+
* the run performing them. When that happens the SDK picks the goal back up
|
|
46
|
+
* on the next init and lets the planner finish it from the current screen.
|
|
47
|
+
*
|
|
48
|
+
* This means the agent can act shortly after launch without a fresh user
|
|
49
|
+
* request. Set false if a host would rather drop interrupted runs.
|
|
50
|
+
*/
|
|
51
|
+
resumeAfterReload?: boolean;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export function KokoProvider({
|
|
55
|
+
children,
|
|
56
|
+
config,
|
|
57
|
+
cursor = true,
|
|
58
|
+
observer,
|
|
59
|
+
composerPlaceholder,
|
|
60
|
+
dialogs = true,
|
|
61
|
+
remoteSmokePort,
|
|
62
|
+
resumeAfterReload = true,
|
|
63
|
+
}: KokoProviderProps) {
|
|
64
|
+
const mergedConfig = useMemo<KokoAgentConfig | undefined>(() => {
|
|
65
|
+
if (!config && !composerPlaceholder) return config;
|
|
66
|
+
return {
|
|
67
|
+
...config,
|
|
68
|
+
branding: {
|
|
69
|
+
...config?.branding,
|
|
70
|
+
placeholder: config?.branding?.placeholder ?? composerPlaceholder,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}, [config, composerPlaceholder]);
|
|
74
|
+
|
|
75
|
+
const agent = useMemo(() => {
|
|
76
|
+
if (mergedConfig) return initKokoAgent(mergedConfig);
|
|
77
|
+
return getKokoAgent();
|
|
78
|
+
}, [mergedConfig]);
|
|
79
|
+
|
|
80
|
+
const showObserver = observer ?? mergedConfig?.observer !== false;
|
|
81
|
+
const smokePort = remoteSmokePort ?? 0;
|
|
82
|
+
|
|
83
|
+
const resumeTried = useRef(false);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!resumeAfterReload || resumeTried.current) return;
|
|
86
|
+
resumeTried.current = true;
|
|
87
|
+
// Let the host finish remounting its navigator first, or the resumed run
|
|
88
|
+
// plans against a half-built tree.
|
|
89
|
+
const timer = setTimeout(() => {
|
|
90
|
+
void agent.resumeInterruptedRun().catch(() => {});
|
|
91
|
+
}, 1500);
|
|
92
|
+
return () => clearTimeout(timer);
|
|
93
|
+
}, [agent, resumeAfterReload]);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<KokoContext.Provider value={agent}>
|
|
97
|
+
<KokoUiProvider config={mergedConfig}>
|
|
98
|
+
<View style={styles.root}>
|
|
99
|
+
{children}
|
|
100
|
+
{/* Cursor lives inside KokoObserver's single overlay Modal when observer is on. */}
|
|
101
|
+
{cursor && !showObserver ? <CursorOverlay /> : null}
|
|
102
|
+
{showObserver ? <KokoObserver cursor={cursor} /> : null}
|
|
103
|
+
{dialogs ? <KokoDialogHost /> : null}
|
|
104
|
+
{smokePort > 0 ? <KokoRemoteSmoke port={smokePort} /> : null}
|
|
105
|
+
</View>
|
|
106
|
+
</KokoUiProvider>
|
|
107
|
+
</KokoContext.Provider>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function useKokoAgent(): KokoAgent {
|
|
112
|
+
const ctx = useContext(KokoContext);
|
|
113
|
+
return ctx ?? getKokoAgent();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const styles = StyleSheet.create({
|
|
117
|
+
root: { flex: 1 },
|
|
118
|
+
});
|