@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,561 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { AppState, Platform } from 'react-native';
|
|
3
|
+
import { useKokoAgent } from '../provider/KokoProvider';
|
|
4
|
+
import { TaskStore } from '../task/TaskStore';
|
|
5
|
+
import { screenModelText } from '../privacy/screenModel';
|
|
6
|
+
import { viewTreeOutline, redactViewTreeClient } from '../privacy/redact';
|
|
7
|
+
import { sensitiveScreenKind, SensitiveScreenError } from '../privacy/sensitiveScreen';
|
|
8
|
+
import { NativeBridge } from '../native/NativeBridge';
|
|
9
|
+
import { buildOnDeviceAssist } from '../assist/OnDeviceAssist';
|
|
10
|
+
import { getProgressChromeFrame } from '../ui/progressChrome';
|
|
11
|
+
import { CursorController } from '../cursor/controller';
|
|
12
|
+
import { KokoAgent } from '../KokoAgent';
|
|
13
|
+
import { detectAppUserGate } from '../privacy/userGate';
|
|
14
|
+
import { safePlannerModel } from '../client/GatewayClient';
|
|
15
|
+
import { HostAppearanceStore } from '../provider/HostAppearanceStore';
|
|
16
|
+
import { visibleWebViewFrames } from '../assist/ocrTarget';
|
|
17
|
+
import { isMetroDevBuild } from '../commercial/devMode';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Why the progress chrome did or did not render, sampled on every store
|
|
21
|
+
* change. Polling from the Mac cannot see this: the queue is starved while a
|
|
22
|
+
* task runs, so the interesting states are over before a reply gets through.
|
|
23
|
+
*/
|
|
24
|
+
type ChromeSample = {
|
|
25
|
+
t: number;
|
|
26
|
+
running: boolean;
|
|
27
|
+
sheetOpen: boolean;
|
|
28
|
+
suppressed: boolean;
|
|
29
|
+
epoch: number;
|
|
30
|
+
frame: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const chromeTrace: ChromeSample[] = [];
|
|
34
|
+
let chromeTraceStarted = 0;
|
|
35
|
+
|
|
36
|
+
function recordChromeSample() {
|
|
37
|
+
const s = TaskStore.snapshot();
|
|
38
|
+
const active = s.tasks.find((t) => t.id === s.activeTaskId);
|
|
39
|
+
const f = getProgressChromeFrame();
|
|
40
|
+
if (!chromeTraceStarted) chromeTraceStarted = Date.now();
|
|
41
|
+
if (chromeTrace.length > 400) chromeTrace.shift();
|
|
42
|
+
chromeTrace.push({
|
|
43
|
+
t: Date.now() - chromeTraceStarted,
|
|
44
|
+
running: active?.status === 'running',
|
|
45
|
+
sheetOpen: Boolean(s.ui.sheetOpen),
|
|
46
|
+
suppressed: Boolean(s.ui.chromeSuppressed),
|
|
47
|
+
epoch: s.ui.chromeEpoch ?? 0,
|
|
48
|
+
frame: f ? `${Math.round(f.x)},${Math.round(f.y)} ${Math.round(f.width)}x${Math.round(f.height)}` : 'null',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type KokoRemoteSmokeCmd =
|
|
53
|
+
| { id: string; type: 'ping' }
|
|
54
|
+
| { id: string; type: 'openChat'; taskId?: string | null }
|
|
55
|
+
| { id: string; type: 'closeChat' }
|
|
56
|
+
| { id: string; type: 'stop' }
|
|
57
|
+
| { id: string; type: 'snapshot' }
|
|
58
|
+
| { id: string; type: 'verifyLocalWebText'; text: string; goal: string; cursorAtTarget?: boolean }
|
|
59
|
+
| { id: string; type: 'inspectWalletChoices' }
|
|
60
|
+
| { id: string; type: 'inspectWebWalletProvider' }
|
|
61
|
+
| { id: string; type: 'inspectWebState' }
|
|
62
|
+
| { id: string; type: 'chromeTrace'; clear?: boolean }
|
|
63
|
+
| { id: string; type: 'dump'; includeTree?: boolean }
|
|
64
|
+
| {
|
|
65
|
+
id: string;
|
|
66
|
+
type: 'tap';
|
|
67
|
+
point?: { x: number; y: number };
|
|
68
|
+
text?: string;
|
|
69
|
+
nodeId?: string;
|
|
70
|
+
}
|
|
71
|
+
| { id: string; type: 'runGoal'; goal: string }
|
|
72
|
+
| {
|
|
73
|
+
id: string;
|
|
74
|
+
type: 'recognizeScreenText';
|
|
75
|
+
maxTokens?: number;
|
|
76
|
+
languages?: string[];
|
|
77
|
+
}
|
|
78
|
+
| { id: string; type: 'alertAction'; title: string }
|
|
79
|
+
| { id: string; type: 'cursorAt'; x: number; y: number; holdMs?: number }
|
|
80
|
+
| { id: string; type: 'onDeviceAssist'; goal: string; skipOcr?: boolean }
|
|
81
|
+
| {
|
|
82
|
+
id: string;
|
|
83
|
+
type: 'explore';
|
|
84
|
+
maxSteps?: number;
|
|
85
|
+
maxScreens?: number;
|
|
86
|
+
mode?: 'full' | 'quick';
|
|
87
|
+
appKey?: string;
|
|
88
|
+
}
|
|
89
|
+
| { id: string; type: 'exploreGraph' }
|
|
90
|
+
| { id: string; type: 'clearExploreGraph' };
|
|
91
|
+
|
|
92
|
+
type SmokeResult = {
|
|
93
|
+
id: string;
|
|
94
|
+
ok: boolean;
|
|
95
|
+
type: string;
|
|
96
|
+
at: number;
|
|
97
|
+
error?: string;
|
|
98
|
+
data?: unknown;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
async function fetchJson(
|
|
102
|
+
url: string,
|
|
103
|
+
init?: RequestInit & { timeoutMs?: number },
|
|
104
|
+
): Promise<{ ok: boolean; status: number; json: unknown }> {
|
|
105
|
+
const timeoutMs = init?.timeoutMs ?? 4000;
|
|
106
|
+
const ctrl = new AbortController();
|
|
107
|
+
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
108
|
+
try {
|
|
109
|
+
const res = await fetch(url, { ...init, signal: ctrl.signal });
|
|
110
|
+
let json: unknown = null;
|
|
111
|
+
try {
|
|
112
|
+
json = await res.json();
|
|
113
|
+
} catch {
|
|
114
|
+
json = null;
|
|
115
|
+
}
|
|
116
|
+
return { ok: res.ok, status: res.status, json };
|
|
117
|
+
} finally {
|
|
118
|
+
clearTimeout(timer);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* DEV-only remote driver: poll a host HTTP queue and run SDK ops.
|
|
124
|
+
* Host-agnostic — any app can enable via KokoProvider `remoteSmokePort`.
|
|
125
|
+
* Simulator reaches Mac localhost as 127.0.0.1.
|
|
126
|
+
*/
|
|
127
|
+
export function KokoRemoteSmoke({
|
|
128
|
+
port = 9877,
|
|
129
|
+
enabled = true,
|
|
130
|
+
}: {
|
|
131
|
+
port?: number;
|
|
132
|
+
enabled?: boolean;
|
|
133
|
+
}) {
|
|
134
|
+
const koko = useKokoAgent();
|
|
135
|
+
const busy = useRef(false);
|
|
136
|
+
const kokoRef = useRef(koko);
|
|
137
|
+
kokoRef.current = koko;
|
|
138
|
+
const active = enabled && isMetroDevBuild();
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!active) return;
|
|
142
|
+
recordChromeSample();
|
|
143
|
+
return TaskStore.subscribe(recordChromeSample);
|
|
144
|
+
}, [active]);
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (!active) return;
|
|
148
|
+
if (Platform.OS === 'web') return;
|
|
149
|
+
|
|
150
|
+
const base = `http://127.0.0.1:${port}`;
|
|
151
|
+
let cancelled = false;
|
|
152
|
+
|
|
153
|
+
const post = async (path: string, body: unknown) => {
|
|
154
|
+
await fetchJson(`${base}${path}`, {
|
|
155
|
+
method: 'POST',
|
|
156
|
+
headers: { 'Content-Type': 'application/json' },
|
|
157
|
+
body: JSON.stringify(body),
|
|
158
|
+
timeoutMs: 4000,
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const handle = async (cmd: KokoRemoteSmokeCmd): Promise<SmokeResult> => {
|
|
163
|
+
const at = Date.now();
|
|
164
|
+
const agent = kokoRef.current;
|
|
165
|
+
try {
|
|
166
|
+
if (['tap', 'recognizeScreenText', 'type', 'screenshot', 'alertAction'].includes(cmd.type) &&
|
|
167
|
+
sensitiveScreenKind(await NativeBridge.dump())) throw new SensitiveScreenError();
|
|
168
|
+
switch (cmd.type) {
|
|
169
|
+
case 'ping':
|
|
170
|
+
return {
|
|
171
|
+
id: cmd.id,
|
|
172
|
+
ok: true,
|
|
173
|
+
type: cmd.type,
|
|
174
|
+
at,
|
|
175
|
+
data: { appState: AppState.currentState },
|
|
176
|
+
};
|
|
177
|
+
case 'verifyLocalWebText': {
|
|
178
|
+
// Read-only integration diagnostic. No recognized page text or
|
|
179
|
+
// screenshots are returned; the label is supplied by the caller.
|
|
180
|
+
const tree = await NativeBridge.dump();
|
|
181
|
+
if (detectAppUserGate(tree) || sensitiveScreenKind(tree)) throw new SensitiveScreenError();
|
|
182
|
+
const local = new KokoAgent({ observer: false });
|
|
183
|
+
const found = await local.find({ match: [{ text: cmd.text }] }, tree);
|
|
184
|
+
const assist = await buildOnDeviceAssist(cmd.goal, tree);
|
|
185
|
+
const model = safePlannerModel(redactViewTreeClient(tree), cmd.goal, assist.goalOcrLabels, assist.walletChoices);
|
|
186
|
+
// Exercise the same fresh OCR revalidation used immediately before
|
|
187
|
+
// a tap, without dispatching a touch or exporting recognized text.
|
|
188
|
+
const internal = local as unknown as {
|
|
189
|
+
lastTree: typeof tree;
|
|
190
|
+
ocrTargets: Map<string, { text: string; webview: boolean }>;
|
|
191
|
+
currentOcrPoint: (text: string, root?: typeof tree) => Promise<unknown>;
|
|
192
|
+
};
|
|
193
|
+
internal.lastTree = tree;
|
|
194
|
+
const observed = found ? internal.ocrTargets.get(found.id) : undefined;
|
|
195
|
+
let revalidated = false;
|
|
196
|
+
let cursorCheckStarted = false;
|
|
197
|
+
if (cmd.cursorAtTarget && found?.frame) {
|
|
198
|
+
if (TaskStore.snapshot().activeTaskId) throw new Error('task already running');
|
|
199
|
+
TaskStore.startTask('Local read-only cursor visibility check');
|
|
200
|
+
cursorCheckStarted = true;
|
|
201
|
+
CursorController.showAt(found.frame.x + found.frame.width / 2, found.frame.y + found.frame.height / 2);
|
|
202
|
+
await new Promise<void>((resolve) => setTimeout(resolve, 350));
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
revalidated = observed
|
|
206
|
+
? Boolean(await internal.currentOcrPoint(observed.text, observed.webview ? tree : undefined))
|
|
207
|
+
: false;
|
|
208
|
+
} finally {
|
|
209
|
+
if (cursorCheckStarted) {
|
|
210
|
+
CursorController.hide();
|
|
211
|
+
TaskStore.finishTask('cancelled');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { id: cmd.id, ok: true, type: cmd.type, at, data: {
|
|
215
|
+
found: Boolean(found), viaOcr: found?.type === 'KokoOcrText',
|
|
216
|
+
usesRequestedLabel: found?.text === cmd.text,
|
|
217
|
+
plannerHasLocalEvidence: model.includes('[local-ocr]'),
|
|
218
|
+
plannerHasWalletChoices: model.includes('[local-wallet-choices]'),
|
|
219
|
+
revalidated,
|
|
220
|
+
} };
|
|
221
|
+
}
|
|
222
|
+
case 'inspectWalletChoices': {
|
|
223
|
+
const tree = await NativeBridge.dump();
|
|
224
|
+
if (detectAppUserGate(tree) || sensitiveScreenKind(tree)) throw new SensitiveScreenError();
|
|
225
|
+
const ocr = await NativeBridge.recognizeScreenText({ maxTokens: 64, hideOverlays: true });
|
|
226
|
+
const patterns: Array<[string, RegExp]> = [
|
|
227
|
+
['MetaMask', /metamask/i], ['WalletConnect', /wallet\s*connect/i],
|
|
228
|
+
['Coinbase Wallet', /coinbase/i], ['OneKey', /one\s*key/i],
|
|
229
|
+
['UKey', /u\s*key/i], ['Uniswap Wallet', /uniswap\s*wallet/i],
|
|
230
|
+
['Trust Wallet', /trust\s*wallet/i], ['Phantom', /phantom/i],
|
|
231
|
+
['OKX Wallet', /okx/i], ['More', /^(more|更多)(\s|$)/i],
|
|
232
|
+
['Browser wallet', /browser\s*wallet|浏览器钱包/i],
|
|
233
|
+
['Other wallets', /other\s*wallets|其他钱包/i],
|
|
234
|
+
['Installed', /installed|已安装/i],
|
|
235
|
+
];
|
|
236
|
+
return { id: cmd.id, ok: true, type: cmd.type, at, data: {
|
|
237
|
+
choices: patterns.filter(([, re]) => ocr.texts.some((hit) => re.test(hit.text)))
|
|
238
|
+
.map(([label]) => label),
|
|
239
|
+
positions: patterns.flatMap(([label, re]) => ocr.texts
|
|
240
|
+
.filter((hit) => re.test(hit.text) && hit.frame)
|
|
241
|
+
.map((hit) => ({ label, frame: hit.frame }))),
|
|
242
|
+
} };
|
|
243
|
+
}
|
|
244
|
+
case 'inspectWebState': {
|
|
245
|
+
const tree = await NativeBridge.dump();
|
|
246
|
+
if (detectAppUserGate(tree) || sensitiveScreenKind(tree)) throw new SensitiveScreenError();
|
|
247
|
+
const ocr = await NativeBridge.recognizeScreenText({ maxTokens: 64, hideOverlays: true });
|
|
248
|
+
const patterns: Record<string, RegExp> = {
|
|
249
|
+
private: /password|passcode|mnemonic|recovery phrase|seed phrase|private key|密码|助记词|私钥/i,
|
|
250
|
+
accountAddress: /0x[a-f0-9]{4,}|0x[a-f0-9]{2,}…/i,
|
|
251
|
+
connect: /connect|连接|連接/i, wallet: /wallet|钱包|錢包/i,
|
|
252
|
+
provider: /metamask|walletconnect|coinbase|onekey|ukey/i,
|
|
253
|
+
loading: /loading|connecting|加载|連接中|连接中|请稍候/i,
|
|
254
|
+
error: /error|failed|failure|错误|失敗|失败/i,
|
|
255
|
+
approval: /approve|authorize|confirm|allow|批准|授权|確認|确认|同意/i,
|
|
256
|
+
qr: /qr code|二维码|二維碼/i, uniswap: /uniswap/i,
|
|
257
|
+
};
|
|
258
|
+
return { id: cmd.id, ok: true, type: cmd.type, at, data: {
|
|
259
|
+
flags: Object.fromEntries(Object.entries(patterns).map(([key, re]) => [key, ocr.texts.some(hit => re.test(hit.text))])),
|
|
260
|
+
} };
|
|
261
|
+
}
|
|
262
|
+
case 'inspectWebWalletProvider': {
|
|
263
|
+
const tree = await NativeBridge.dump();
|
|
264
|
+
if (detectAppUserGate(tree) || sensitiveScreenKind(tree)) throw new SensitiveScreenError();
|
|
265
|
+
const frame = visibleWebViewFrames(tree)[0];
|
|
266
|
+
if (!frame) return { id: cmd.id, ok: false, type: cmd.type, at, error: 'webview not visible' };
|
|
267
|
+
const flags = await NativeBridge.inspectWebWalletProvider({ x: frame.x + frame.width / 2, y: frame.y + frame.height / 2 });
|
|
268
|
+
return { id: cmd.id, ok: Boolean(flags), type: cmd.type, at, data: { flags } };
|
|
269
|
+
}
|
|
270
|
+
case 'openChat':
|
|
271
|
+
agent.openChat(cmd.taskId);
|
|
272
|
+
return { id: cmd.id, ok: true, type: cmd.type, at };
|
|
273
|
+
case 'closeChat':
|
|
274
|
+
agent.closeChat();
|
|
275
|
+
return { id: cmd.id, ok: true, type: cmd.type, at };
|
|
276
|
+
case 'stop':
|
|
277
|
+
agent.stop();
|
|
278
|
+
return { id: cmd.id, ok: true, type: cmd.type, at };
|
|
279
|
+
case 'chromeTrace': {
|
|
280
|
+
const rows = chromeTrace.slice();
|
|
281
|
+
if (cmd.clear) {
|
|
282
|
+
chromeTrace.length = 0;
|
|
283
|
+
chromeTraceStarted = 0;
|
|
284
|
+
}
|
|
285
|
+
return { id: cmd.id, ok: true, type: cmd.type, at, data: { rows } };
|
|
286
|
+
}
|
|
287
|
+
case 'snapshot': {
|
|
288
|
+
const snap = TaskStore.snapshot();
|
|
289
|
+
return {
|
|
290
|
+
id: cmd.id,
|
|
291
|
+
ok: true,
|
|
292
|
+
type: cmd.type,
|
|
293
|
+
at,
|
|
294
|
+
data: {
|
|
295
|
+
appState: AppState.currentState,
|
|
296
|
+
appearance: HostAppearanceStore.get(),
|
|
297
|
+
ui: snap.ui,
|
|
298
|
+
activeTaskId: snap.activeTaskId,
|
|
299
|
+
tasks: snap.tasks.map((t) => ({
|
|
300
|
+
id: t.id,
|
|
301
|
+
title: t.title,
|
|
302
|
+
status: t.status,
|
|
303
|
+
nodeCount: t.nodes.length,
|
|
304
|
+
findDiagnostics: t.nodes.filter((n) => n.kind === 'find').map((n) => ({
|
|
305
|
+
title: n.title,
|
|
306
|
+
status: n.status,
|
|
307
|
+
targetKind: n.detail?.startsWith('ocr:') ? 'ocr' : n.detail ? 'native' : 'none',
|
|
308
|
+
})),
|
|
309
|
+
firstNodes: t.nodes.slice(0, 8).map((n) => ({
|
|
310
|
+
kind: n.kind,
|
|
311
|
+
title: n.title,
|
|
312
|
+
status: n.status,
|
|
313
|
+
})),
|
|
314
|
+
lastNodes: t.nodes.slice(-6).map((n) => ({
|
|
315
|
+
kind: n.kind,
|
|
316
|
+
title: n.title,
|
|
317
|
+
status: n.status,
|
|
318
|
+
})),
|
|
319
|
+
})),
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
case 'dump': {
|
|
324
|
+
// Native dump — no active goal required (agent.dump() is gated).
|
|
325
|
+
const tree = await NativeBridge.dump();
|
|
326
|
+
const outline = viewTreeOutline(tree).slice(0, 4000);
|
|
327
|
+
const model = screenModelText(tree).slice(0, 4000);
|
|
328
|
+
return {
|
|
329
|
+
id: cmd.id,
|
|
330
|
+
ok: true,
|
|
331
|
+
type: cmd.type,
|
|
332
|
+
at,
|
|
333
|
+
// `includeTree` ships a redacted tree so scripts/capture_dump_fixture.py
|
|
334
|
+
// can save it as an offline regression fixture. Off by default: a
|
|
335
|
+
// dense host tree is megabytes.
|
|
336
|
+
data: { outline, model, tree: cmd.includeTree ? redactViewTreeClient(tree) : undefined },
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
case 'tap': {
|
|
340
|
+
// Raw synthetic touch, bypassing selector + ExecutionGuard, so a
|
|
341
|
+
// failing task can be narrowed to "the touch never lands" vs
|
|
342
|
+
// "the planner aimed at the wrong node".
|
|
343
|
+
const before = screenModelText(await NativeBridge.dump()).slice(0, 2000);
|
|
344
|
+
const point =
|
|
345
|
+
cmd.point ??
|
|
346
|
+
(() => {
|
|
347
|
+
throw new Error('tap requires point');
|
|
348
|
+
})();
|
|
349
|
+
await NativeBridge.tap(point);
|
|
350
|
+
await new Promise((r) => setTimeout(r, 1200));
|
|
351
|
+
const after = screenModelText(await NativeBridge.dump()).slice(0, 2000);
|
|
352
|
+
return {
|
|
353
|
+
id: cmd.id,
|
|
354
|
+
ok: true,
|
|
355
|
+
type: cmd.type,
|
|
356
|
+
at,
|
|
357
|
+
data: { point, changed: before !== after, before, after },
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
case 'recognizeScreenText': {
|
|
361
|
+
const ocr = await NativeBridge.recognizeScreenText({
|
|
362
|
+
maxTokens: cmd.maxTokens ?? 24,
|
|
363
|
+
languages: cmd.languages,
|
|
364
|
+
hideOverlays: true,
|
|
365
|
+
});
|
|
366
|
+
return {
|
|
367
|
+
id: cmd.id,
|
|
368
|
+
ok: ocr.backend === 'vision' || ocr.tokens.length > 0,
|
|
369
|
+
type: cmd.type,
|
|
370
|
+
at,
|
|
371
|
+
data: {
|
|
372
|
+
backend: ocr.backend,
|
|
373
|
+
tokenCount: ocr.tokens.length,
|
|
374
|
+
tokens: ocr.tokens.slice(0, 32),
|
|
375
|
+
texts: ocr.texts.slice(0, 16),
|
|
376
|
+
nativeAvailable: NativeBridge.isAvailable(),
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
case 'cursorAt': {
|
|
381
|
+
// Isolates pointer rendering from the planner: the chrome only
|
|
382
|
+
// shows while a task runs, so claim one for the hold.
|
|
383
|
+
const taskId = TaskStore.startTask('cursorAt').id;
|
|
384
|
+
CursorController.showAt(cmd.x, cmd.y, 0);
|
|
385
|
+
await new Promise((r) => setTimeout(r, cmd.holdMs ?? 4000));
|
|
386
|
+
const state = CursorController.getState();
|
|
387
|
+
CursorController.hide();
|
|
388
|
+
TaskStore.finishTask('success', taskId);
|
|
389
|
+
return { id: cmd.id, ok: true, type: cmd.type, at, data: { state } };
|
|
390
|
+
}
|
|
391
|
+
case 'alertAction': {
|
|
392
|
+
const before = screenModelText(await NativeBridge.dump());
|
|
393
|
+
const invoked = await NativeBridge.invokeAlertAction(cmd.title);
|
|
394
|
+
await new Promise((r) => setTimeout(r, 800));
|
|
395
|
+
const after = screenModelText(await NativeBridge.dump());
|
|
396
|
+
return {
|
|
397
|
+
id: cmd.id,
|
|
398
|
+
ok: invoked,
|
|
399
|
+
type: cmd.type,
|
|
400
|
+
at,
|
|
401
|
+
data: { invoked, changed: after !== before, after: after.slice(0, 600) },
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
case 'onDeviceAssist': {
|
|
405
|
+
const tree = await NativeBridge.dump();
|
|
406
|
+
const assist = await buildOnDeviceAssist(cmd.goal, tree, {
|
|
407
|
+
skipOcr: cmd.skipOcr,
|
|
408
|
+
});
|
|
409
|
+
return {
|
|
410
|
+
id: cmd.id,
|
|
411
|
+
ok: Boolean(assist.modelText || assist.ranked.length),
|
|
412
|
+
type: cmd.type,
|
|
413
|
+
at,
|
|
414
|
+
data: {
|
|
415
|
+
intent: assist.intent,
|
|
416
|
+
confidence: assist.confidence,
|
|
417
|
+
backend: assist.backend,
|
|
418
|
+
tokens: assist.tokens,
|
|
419
|
+
ocrTokens: assist.ocrTokens,
|
|
420
|
+
ranked: assist.ranked.slice(0, 8),
|
|
421
|
+
modelText: assist.modelText.slice(0, 2000),
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
case 'runGoal': {
|
|
426
|
+
const out = await agent.runGoal(cmd.goal);
|
|
427
|
+
const snap = TaskStore.snapshot();
|
|
428
|
+
const active = snap.tasks.find((t) => t.id === snap.activeTaskId);
|
|
429
|
+
return {
|
|
430
|
+
id: cmd.id,
|
|
431
|
+
ok: Boolean(out?.success),
|
|
432
|
+
type: cmd.type,
|
|
433
|
+
at,
|
|
434
|
+
data: {
|
|
435
|
+
result: out,
|
|
436
|
+
task: active
|
|
437
|
+
? {
|
|
438
|
+
id: active.id,
|
|
439
|
+
title: active.title,
|
|
440
|
+
status: active.status,
|
|
441
|
+
nodes: active.nodes.map((n) => ({
|
|
442
|
+
kind: n.kind,
|
|
443
|
+
title: n.title,
|
|
444
|
+
status: n.status,
|
|
445
|
+
})),
|
|
446
|
+
}
|
|
447
|
+
: null,
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
case 'explore': {
|
|
452
|
+
const out = await agent.bootstrapExplore({
|
|
453
|
+
mode: cmd.mode ?? 'full',
|
|
454
|
+
maxSteps: cmd.maxSteps ?? (cmd.mode === 'quick' ? 24 : 80),
|
|
455
|
+
maxScreens: cmd.maxScreens,
|
|
456
|
+
appKey: cmd.appKey,
|
|
457
|
+
});
|
|
458
|
+
return {
|
|
459
|
+
id: cmd.id,
|
|
460
|
+
ok: Boolean(out?.success),
|
|
461
|
+
type: cmd.type,
|
|
462
|
+
at,
|
|
463
|
+
data: {
|
|
464
|
+
summary: out.summary,
|
|
465
|
+
steps: out.steps,
|
|
466
|
+
stats: {
|
|
467
|
+
nodes: out.graph.nodes.length,
|
|
468
|
+
edges: out.graph.edges.length,
|
|
469
|
+
},
|
|
470
|
+
sampleEdges: out.graph.edges.slice(0, 20).map((e) => ({
|
|
471
|
+
label: e.label,
|
|
472
|
+
count: e.count,
|
|
473
|
+
})),
|
|
474
|
+
sampleNodeLabels: out.graph.nodes
|
|
475
|
+
.slice(0, 12)
|
|
476
|
+
.map((n) => n.labels.slice(0, 6)),
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
case 'exploreGraph': {
|
|
481
|
+
const g = agent.getExplorationGraph();
|
|
482
|
+
return {
|
|
483
|
+
id: cmd.id,
|
|
484
|
+
ok: true,
|
|
485
|
+
type: cmd.type,
|
|
486
|
+
at,
|
|
487
|
+
data: {
|
|
488
|
+
stats: { nodes: g.nodes.length, edges: g.edges.length },
|
|
489
|
+
nodes: g.nodes.slice(0, 20).map((n) => ({
|
|
490
|
+
id: n.id,
|
|
491
|
+
labels: n.labels.slice(0, 8),
|
|
492
|
+
visitCount: n.visitCount,
|
|
493
|
+
})),
|
|
494
|
+
edges: g.edges.slice(0, 30).map((e) => ({
|
|
495
|
+
label: e.label,
|
|
496
|
+
count: e.count,
|
|
497
|
+
fromId: e.fromId,
|
|
498
|
+
toId: e.toId,
|
|
499
|
+
})),
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
case 'clearExploreGraph': {
|
|
504
|
+
agent.clearExplorationGraph();
|
|
505
|
+
return { id: cmd.id, ok: true, type: cmd.type, at };
|
|
506
|
+
}
|
|
507
|
+
default:
|
|
508
|
+
return {
|
|
509
|
+
id: (cmd as { id: string }).id,
|
|
510
|
+
ok: false,
|
|
511
|
+
type: 'unknown',
|
|
512
|
+
at,
|
|
513
|
+
error: 'unknown command',
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
} catch (e) {
|
|
517
|
+
return {
|
|
518
|
+
id: cmd.id,
|
|
519
|
+
ok: false,
|
|
520
|
+
type: cmd.type,
|
|
521
|
+
at,
|
|
522
|
+
error: e instanceof Error ? e.message : String(e),
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
const tick = async () => {
|
|
528
|
+
if (cancelled || busy.current) return;
|
|
529
|
+
if (AppState.currentState !== 'active') return;
|
|
530
|
+
busy.current = true;
|
|
531
|
+
try {
|
|
532
|
+
const res = await fetchJson(`${base}/cmd`, { method: 'GET', timeoutMs: 3500 });
|
|
533
|
+
const cmd = res.json as KokoRemoteSmokeCmd | null;
|
|
534
|
+
if (!cmd || !cmd.id) return;
|
|
535
|
+
// Ack early so the host knows we accepted work (avoids silent drops).
|
|
536
|
+
await post('/ack', { id: cmd.id, type: cmd.type, at: Date.now() });
|
|
537
|
+
const result = await handle(cmd);
|
|
538
|
+
await post('/result', result);
|
|
539
|
+
} catch {
|
|
540
|
+
// ignore — next tick retries
|
|
541
|
+
} finally {
|
|
542
|
+
busy.current = false;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
void post('/hello', { at: Date.now(), platform: Platform.OS });
|
|
547
|
+
const timer = setInterval(() => {
|
|
548
|
+
void tick();
|
|
549
|
+
}, 600);
|
|
550
|
+
const sub = AppState.addEventListener('change', (s) => {
|
|
551
|
+
if (s === 'active') void tick();
|
|
552
|
+
});
|
|
553
|
+
return () => {
|
|
554
|
+
cancelled = true;
|
|
555
|
+
clearInterval(timer);
|
|
556
|
+
sub.remove();
|
|
557
|
+
};
|
|
558
|
+
}, [active, port]);
|
|
559
|
+
|
|
560
|
+
return null;
|
|
561
|
+
}
|