@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,174 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
Pressable,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Text,
|
|
7
|
+
TextInput,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { useKokoAgent } from '../provider/KokoProvider';
|
|
11
|
+
import { TaskStore } from '../task/TaskStore';
|
|
12
|
+
import { useTaskStore } from '../task/useTaskStore';
|
|
13
|
+
import { useKokoUi } from '../provider/KokoUiContext';
|
|
14
|
+
import { message, type LocalizedText } from '../i18n';
|
|
15
|
+
|
|
16
|
+
export type KokoComposerProps = {
|
|
17
|
+
/** Placeholder for the natural-language input. */
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
/** Disable while true (in addition to running task). */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Natural-language dialog (需求 §1.1 / §3.5):
|
|
25
|
+
* 用户自由输入一句话 → 云端 Agent → 本 App 内 dump/find/tap,字幕与任务可观测。
|
|
26
|
+
*/
|
|
27
|
+
export function KokoComposer({
|
|
28
|
+
placeholder,
|
|
29
|
+
disabled = false,
|
|
30
|
+
}: KokoComposerProps) {
|
|
31
|
+
const koko = useKokoAgent();
|
|
32
|
+
const { branding, t } = useKokoUi();
|
|
33
|
+
const { tasks, activeTaskId } = useTaskStore();
|
|
34
|
+
const [text, setText] = useState('');
|
|
35
|
+
const [busy, setBusy] = useState(false);
|
|
36
|
+
const [hint, setHint] = useState<LocalizedText | null>(null);
|
|
37
|
+
|
|
38
|
+
const running =
|
|
39
|
+
busy || tasks.some((t) => t.id === activeTaskId && t.status === 'running');
|
|
40
|
+
|
|
41
|
+
const onSend = useCallback(async () => {
|
|
42
|
+
const goal = text.trim();
|
|
43
|
+
if (!goal || running || disabled) return;
|
|
44
|
+
|
|
45
|
+
setBusy(true);
|
|
46
|
+
setHint(null);
|
|
47
|
+
setText('');
|
|
48
|
+
TaskStore.openSheet();
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const out = await koko.runGoal(goal, {
|
|
52
|
+
onNarration: (line) => setHint(line),
|
|
53
|
+
});
|
|
54
|
+
setHint(out.success ? out.summary : message('composer.incomplete', { summary: out.summary }));
|
|
55
|
+
} catch (e) {
|
|
56
|
+
setHint(e instanceof Error ? e.message : String(e));
|
|
57
|
+
} finally {
|
|
58
|
+
setBusy(false);
|
|
59
|
+
}
|
|
60
|
+
}, [text, running, disabled, koko]);
|
|
61
|
+
|
|
62
|
+
const onStop = useCallback(() => {
|
|
63
|
+
koko.stop();
|
|
64
|
+
koko.finishTask('cancelled', t('runtime.cancelled'));
|
|
65
|
+
setBusy(false);
|
|
66
|
+
setHint(message('composer.stopped'));
|
|
67
|
+
}, [koko, t]);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<View style={styles.wrap}>
|
|
71
|
+
{hint ? (
|
|
72
|
+
<Text style={styles.hint} numberOfLines={2}>
|
|
73
|
+
{typeof hint === 'string' ? hint : t(hint.key, hint.vars)}
|
|
74
|
+
</Text>
|
|
75
|
+
) : null}
|
|
76
|
+
<View style={styles.row}>
|
|
77
|
+
<TextInput
|
|
78
|
+
style={styles.input}
|
|
79
|
+
value={text}
|
|
80
|
+
onChangeText={setText}
|
|
81
|
+
placeholder={placeholder ?? branding.placeholder}
|
|
82
|
+
placeholderTextColor="rgba(255,255,255,0.35)"
|
|
83
|
+
editable={!running && !disabled}
|
|
84
|
+
returnKeyType="send"
|
|
85
|
+
onSubmitEditing={onSend}
|
|
86
|
+
blurOnSubmit={false}
|
|
87
|
+
accessibilityLabel={t('sheet.inputA11y')}
|
|
88
|
+
/>
|
|
89
|
+
{running ? (
|
|
90
|
+
<Pressable
|
|
91
|
+
style={[styles.btn, styles.btnStop]}
|
|
92
|
+
onPress={onStop}
|
|
93
|
+
accessibilityRole="button"
|
|
94
|
+
accessibilityLabel={t('sheet.stopA11y')}
|
|
95
|
+
>
|
|
96
|
+
<Text style={styles.btnText}>{t('composer.stop')}</Text>
|
|
97
|
+
</Pressable>
|
|
98
|
+
) : (
|
|
99
|
+
<Pressable
|
|
100
|
+
style={[
|
|
101
|
+
styles.btn,
|
|
102
|
+
styles.btnSend,
|
|
103
|
+
(!text.trim() || disabled) && styles.btnDisabled,
|
|
104
|
+
]}
|
|
105
|
+
onPress={onSend}
|
|
106
|
+
disabled={!text.trim() || disabled}
|
|
107
|
+
accessibilityRole="button"
|
|
108
|
+
accessibilityLabel={t('sheet.send')}
|
|
109
|
+
>
|
|
110
|
+
{busy ? (
|
|
111
|
+
<ActivityIndicator color="#fff" />
|
|
112
|
+
) : (
|
|
113
|
+
<Text style={styles.btnText}>{t('sheet.send')}</Text>
|
|
114
|
+
)}
|
|
115
|
+
</Pressable>
|
|
116
|
+
)}
|
|
117
|
+
</View>
|
|
118
|
+
</View>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const styles = StyleSheet.create({
|
|
123
|
+
wrap: {
|
|
124
|
+
width: '100%',
|
|
125
|
+
marginBottom: 8,
|
|
126
|
+
},
|
|
127
|
+
hint: {
|
|
128
|
+
color: 'rgba(255,255,255,0.55)',
|
|
129
|
+
fontSize: 12,
|
|
130
|
+
marginBottom: 6,
|
|
131
|
+
paddingHorizontal: 4,
|
|
132
|
+
},
|
|
133
|
+
row: {
|
|
134
|
+
flexDirection: 'row',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
gap: 8,
|
|
137
|
+
backgroundColor: 'rgba(28,28,30,0.96)',
|
|
138
|
+
borderRadius: 16,
|
|
139
|
+
paddingLeft: 14,
|
|
140
|
+
paddingRight: 6,
|
|
141
|
+
paddingVertical: 6,
|
|
142
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
143
|
+
borderColor: 'rgba(255,255,255,0.12)',
|
|
144
|
+
},
|
|
145
|
+
input: {
|
|
146
|
+
flex: 1,
|
|
147
|
+
color: '#F5F5F7',
|
|
148
|
+
fontSize: 15,
|
|
149
|
+
paddingVertical: 10,
|
|
150
|
+
maxHeight: 88,
|
|
151
|
+
},
|
|
152
|
+
btn: {
|
|
153
|
+
minWidth: 64,
|
|
154
|
+
paddingHorizontal: 14,
|
|
155
|
+
paddingVertical: 10,
|
|
156
|
+
borderRadius: 12,
|
|
157
|
+
alignItems: 'center',
|
|
158
|
+
justifyContent: 'center',
|
|
159
|
+
},
|
|
160
|
+
btnSend: {
|
|
161
|
+
backgroundColor: '#0A84FF',
|
|
162
|
+
},
|
|
163
|
+
btnStop: {
|
|
164
|
+
backgroundColor: '#FF453A',
|
|
165
|
+
},
|
|
166
|
+
btnDisabled: {
|
|
167
|
+
opacity: 0.4,
|
|
168
|
+
},
|
|
169
|
+
btnText: {
|
|
170
|
+
color: '#fff',
|
|
171
|
+
fontWeight: '700',
|
|
172
|
+
fontSize: 14,
|
|
173
|
+
},
|
|
174
|
+
});
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
Pressable,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Text,
|
|
7
|
+
TextInput,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { useKokoUi } from '../provider/KokoUiContext';
|
|
11
|
+
import { KokoOverlayLayer } from './KokoOverlayLayer';
|
|
12
|
+
|
|
13
|
+
export type ConfirmRequest = {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
message: string;
|
|
17
|
+
resolve: (ok: boolean) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type AskRequest = {
|
|
21
|
+
id: string;
|
|
22
|
+
question: string;
|
|
23
|
+
resolve: (answer: string | null) => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type Listener = (state: { confirm: ConfirmRequest | null; ask: AskRequest | null }) => void;
|
|
27
|
+
|
|
28
|
+
class DialogBusImpl {
|
|
29
|
+
confirm: ConfirmRequest | null = null;
|
|
30
|
+
ask: AskRequest | null = null;
|
|
31
|
+
private listeners = new Set<Listener>();
|
|
32
|
+
|
|
33
|
+
subscribe(l: Listener) {
|
|
34
|
+
this.listeners.add(l);
|
|
35
|
+
l({ confirm: this.confirm, ask: this.ask });
|
|
36
|
+
return () => {
|
|
37
|
+
this.listeners.delete(l);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private emit() {
|
|
42
|
+
for (const l of this.listeners) l({ confirm: this.confirm, ask: this.ask });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
requestConfirm(title: string, message: string): Promise<boolean> {
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
this.confirm = {
|
|
48
|
+
id: `c_${Date.now()}`,
|
|
49
|
+
title,
|
|
50
|
+
message,
|
|
51
|
+
resolve: (ok) => {
|
|
52
|
+
this.confirm = null;
|
|
53
|
+
this.emit();
|
|
54
|
+
resolve(ok);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
this.emit();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
requestAsk(question: string): Promise<string | null> {
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
this.ask = {
|
|
64
|
+
id: `a_${Date.now()}`,
|
|
65
|
+
question,
|
|
66
|
+
resolve: (answer) => {
|
|
67
|
+
this.ask = null;
|
|
68
|
+
this.emit();
|
|
69
|
+
resolve(answer);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
this.emit();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const DialogBus = new DialogBusImpl();
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Built-in confirm + ask-user modal. Mounted by KokoProvider.
|
|
81
|
+
*/
|
|
82
|
+
export function KokoDialogHost() {
|
|
83
|
+
const { t, branding, colors } = useKokoUi();
|
|
84
|
+
const [confirm, setConfirm] = useState<ConfirmRequest | null>(null);
|
|
85
|
+
const [ask, setAsk] = useState<AskRequest | null>(null);
|
|
86
|
+
const [answer, setAnswer] = useState('');
|
|
87
|
+
|
|
88
|
+
useEffect(
|
|
89
|
+
() =>
|
|
90
|
+
DialogBus.subscribe((s) => {
|
|
91
|
+
setConfirm(s.confirm);
|
|
92
|
+
setAsk(s.ask);
|
|
93
|
+
if (!s.ask) setAnswer('');
|
|
94
|
+
}),
|
|
95
|
+
[],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const onConfirm = useCallback((ok: boolean) => {
|
|
99
|
+
confirm?.resolve(ok);
|
|
100
|
+
}, [confirm]);
|
|
101
|
+
|
|
102
|
+
const onAskSubmit = useCallback(() => {
|
|
103
|
+
ask?.resolve(answer.trim() || null);
|
|
104
|
+
}, [ask, answer]);
|
|
105
|
+
|
|
106
|
+
const onAskCancel = useCallback(() => {
|
|
107
|
+
ask?.resolve(null);
|
|
108
|
+
}, [ask]);
|
|
109
|
+
|
|
110
|
+
const visible = Boolean(confirm || ask);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Modal visible={visible} transparent animationType="fade" onRequestClose={() => {
|
|
114
|
+
if (confirm) onConfirm(false);
|
|
115
|
+
else onAskCancel();
|
|
116
|
+
}}>
|
|
117
|
+
<KokoOverlayLayer
|
|
118
|
+
pointerEvents="auto"
|
|
119
|
+
style={[styles.backdrop, { backgroundColor: colors.overlay }]}
|
|
120
|
+
>
|
|
121
|
+
<View
|
|
122
|
+
style={[
|
|
123
|
+
styles.card,
|
|
124
|
+
{ backgroundColor: colors.dialogBg, borderColor: colors.border },
|
|
125
|
+
]}
|
|
126
|
+
>
|
|
127
|
+
{confirm ? (
|
|
128
|
+
<>
|
|
129
|
+
<Text style={[styles.title, { color: colors.text }]}>{confirm.title}</Text>
|
|
130
|
+
<Text style={[styles.body, { color: colors.textSecondary }]}>
|
|
131
|
+
{confirm.message}
|
|
132
|
+
</Text>
|
|
133
|
+
<View style={styles.row}>
|
|
134
|
+
<Pressable style={[styles.btn, styles.btnGhost]} onPress={() => onConfirm(false)}>
|
|
135
|
+
<Text style={[styles.btnGhostText, { color: colors.textSecondary }]}>
|
|
136
|
+
{t('dialog.cancel')}
|
|
137
|
+
</Text>
|
|
138
|
+
</Pressable>
|
|
139
|
+
<Pressable
|
|
140
|
+
style={[styles.btn, styles.btnPrimary, { backgroundColor: branding.primaryColor }]}
|
|
141
|
+
onPress={() => onConfirm(true)}
|
|
142
|
+
>
|
|
143
|
+
<Text style={styles.btnPrimaryText}>{t('dialog.confirm')}</Text>
|
|
144
|
+
</Pressable>
|
|
145
|
+
</View>
|
|
146
|
+
</>
|
|
147
|
+
) : null}
|
|
148
|
+
|
|
149
|
+
{ask ? (
|
|
150
|
+
<>
|
|
151
|
+
<Text style={[styles.title, { color: colors.text }]}>{t('dialog.askTitle')}</Text>
|
|
152
|
+
<Text style={[styles.body, { color: colors.textSecondary }]}>{ask.question}</Text>
|
|
153
|
+
<TextInput
|
|
154
|
+
style={[
|
|
155
|
+
styles.input,
|
|
156
|
+
{
|
|
157
|
+
color: colors.text,
|
|
158
|
+
backgroundColor: colors.inputBg,
|
|
159
|
+
borderColor: colors.border,
|
|
160
|
+
},
|
|
161
|
+
]}
|
|
162
|
+
value={answer}
|
|
163
|
+
onChangeText={setAnswer}
|
|
164
|
+
placeholder={t('dialog.askPlaceholder')}
|
|
165
|
+
placeholderTextColor={colors.textMuted}
|
|
166
|
+
autoFocus
|
|
167
|
+
/>
|
|
168
|
+
<View style={styles.row}>
|
|
169
|
+
<Pressable style={[styles.btn, styles.btnGhost]} onPress={onAskCancel}>
|
|
170
|
+
<Text style={[styles.btnGhostText, { color: colors.textSecondary }]}>
|
|
171
|
+
{t('dialog.cancel')}
|
|
172
|
+
</Text>
|
|
173
|
+
</Pressable>
|
|
174
|
+
<Pressable
|
|
175
|
+
style={[styles.btn, styles.btnPrimary, { backgroundColor: branding.primaryColor }]}
|
|
176
|
+
onPress={onAskSubmit}
|
|
177
|
+
>
|
|
178
|
+
<Text style={styles.btnPrimaryText}>{t('dialog.continue')}</Text>
|
|
179
|
+
</Pressable>
|
|
180
|
+
</View>
|
|
181
|
+
</>
|
|
182
|
+
) : null}
|
|
183
|
+
</View>
|
|
184
|
+
</KokoOverlayLayer>
|
|
185
|
+
</Modal>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const styles = StyleSheet.create({
|
|
190
|
+
backdrop: {
|
|
191
|
+
flex: 1,
|
|
192
|
+
backgroundColor: 'rgba(0,0,0,0.55)',
|
|
193
|
+
alignItems: 'center',
|
|
194
|
+
justifyContent: 'center',
|
|
195
|
+
padding: 24,
|
|
196
|
+
},
|
|
197
|
+
card: {
|
|
198
|
+
width: '100%',
|
|
199
|
+
maxWidth: 400,
|
|
200
|
+
borderRadius: 16,
|
|
201
|
+
backgroundColor: '#1C1C1E',
|
|
202
|
+
padding: 20,
|
|
203
|
+
},
|
|
204
|
+
title: {
|
|
205
|
+
color: '#F5F5F7',
|
|
206
|
+
fontSize: 17,
|
|
207
|
+
fontWeight: '700',
|
|
208
|
+
marginBottom: 8,
|
|
209
|
+
},
|
|
210
|
+
body: {
|
|
211
|
+
color: 'rgba(255,255,255,0.75)',
|
|
212
|
+
fontSize: 14,
|
|
213
|
+
lineHeight: 20,
|
|
214
|
+
marginBottom: 16,
|
|
215
|
+
},
|
|
216
|
+
input: {
|
|
217
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
218
|
+
borderColor: 'rgba(255,255,255,0.2)',
|
|
219
|
+
borderRadius: 10,
|
|
220
|
+
paddingHorizontal: 12,
|
|
221
|
+
paddingVertical: 10,
|
|
222
|
+
color: '#fff',
|
|
223
|
+
marginBottom: 16,
|
|
224
|
+
},
|
|
225
|
+
row: {
|
|
226
|
+
flexDirection: 'row',
|
|
227
|
+
justifyContent: 'flex-end',
|
|
228
|
+
gap: 10,
|
|
229
|
+
},
|
|
230
|
+
btn: {
|
|
231
|
+
paddingHorizontal: 16,
|
|
232
|
+
paddingVertical: 10,
|
|
233
|
+
borderRadius: 10,
|
|
234
|
+
},
|
|
235
|
+
btnGhost: {
|
|
236
|
+
backgroundColor: 'rgba(255,255,255,0.08)',
|
|
237
|
+
},
|
|
238
|
+
btnGhostText: {
|
|
239
|
+
color: 'rgba(255,255,255,0.75)',
|
|
240
|
+
fontWeight: '600',
|
|
241
|
+
},
|
|
242
|
+
btnPrimary: {
|
|
243
|
+
backgroundColor: '#0A84FF',
|
|
244
|
+
},
|
|
245
|
+
btnPrimaryText: {
|
|
246
|
+
color: '#fff',
|
|
247
|
+
fontWeight: '700',
|
|
248
|
+
},
|
|
249
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable, StyleSheet, Text, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { TaskStore } from '../task/TaskStore';
|
|
4
|
+
import { useTaskStore } from '../task/useTaskStore';
|
|
5
|
+
import { KokoOverlayLayer } from './KokoOverlayLayer';
|
|
6
|
+
|
|
7
|
+
export type KokoEntryButtonProps = {
|
|
8
|
+
label?: string;
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Demo convenience button. Production hosts should draw their own entry UI
|
|
14
|
+
* and call `openKokoChat()` / `agent.openChat()`.
|
|
15
|
+
*
|
|
16
|
+
* Marked as overlay so dump/tap skip it — otherwise the agent mistakes it for
|
|
17
|
+
* an in-app control near bottom tabs (e.g. 我的).
|
|
18
|
+
*/
|
|
19
|
+
export function KokoEntryButton({
|
|
20
|
+
label = 'Koko',
|
|
21
|
+
style,
|
|
22
|
+
}: KokoEntryButtonProps) {
|
|
23
|
+
const { tasks, activeTaskId } = useTaskStore();
|
|
24
|
+
const running = tasks.some((t) => t.id === activeTaskId && t.status === 'running');
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<KokoOverlayLayer pointerEvents="box-none" style={styles.wrap}>
|
|
28
|
+
<Pressable
|
|
29
|
+
style={[styles.btn, style, running && styles.btnDim]}
|
|
30
|
+
onPress={() => {
|
|
31
|
+
// Never open the sheet mid-run — Modal backdrop blocks host taps.
|
|
32
|
+
if (running) return;
|
|
33
|
+
TaskStore.openSheet();
|
|
34
|
+
}}
|
|
35
|
+
accessibilityRole="button"
|
|
36
|
+
accessibilityLabel="Open chat"
|
|
37
|
+
accessibilityElementsHidden
|
|
38
|
+
importantForAccessibility="no-hide-descendants"
|
|
39
|
+
>
|
|
40
|
+
<Text style={styles.text}>{label}</Text>
|
|
41
|
+
</Pressable>
|
|
42
|
+
</KokoOverlayLayer>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Imperative open for custom host buttons (preferred). */
|
|
47
|
+
export function openKokoChat(taskId?: string | null) {
|
|
48
|
+
TaskStore.openSheet(taskId);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function closeKokoChat() {
|
|
52
|
+
TaskStore.closeSheet();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const styles = StyleSheet.create({
|
|
56
|
+
wrap: {
|
|
57
|
+
alignSelf: 'flex-start',
|
|
58
|
+
},
|
|
59
|
+
btn: {
|
|
60
|
+
backgroundColor: '#111827',
|
|
61
|
+
paddingHorizontal: 14,
|
|
62
|
+
paddingVertical: 10,
|
|
63
|
+
borderRadius: 12,
|
|
64
|
+
alignSelf: 'flex-start',
|
|
65
|
+
},
|
|
66
|
+
btnDim: {
|
|
67
|
+
opacity: 0.45,
|
|
68
|
+
},
|
|
69
|
+
text: {
|
|
70
|
+
color: '#F9FAFB',
|
|
71
|
+
fontWeight: '700',
|
|
72
|
+
fontSize: 14,
|
|
73
|
+
},
|
|
74
|
+
});
|