@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,930 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
Alert,
|
|
5
|
+
Animated,
|
|
6
|
+
Dimensions,
|
|
7
|
+
Easing,
|
|
8
|
+
FlatList,
|
|
9
|
+
Image,
|
|
10
|
+
Keyboard,
|
|
11
|
+
Modal,
|
|
12
|
+
Platform,
|
|
13
|
+
Pressable,
|
|
14
|
+
StatusBar,
|
|
15
|
+
StyleSheet,
|
|
16
|
+
Text,
|
|
17
|
+
TextInput,
|
|
18
|
+
View,
|
|
19
|
+
type StatusBarProps,
|
|
20
|
+
type StatusBarStyle,
|
|
21
|
+
} from 'react-native';
|
|
22
|
+
import { useKokoAgent } from '../provider/KokoProvider';
|
|
23
|
+
import { useKokoUi } from '../provider/KokoUiContext';
|
|
24
|
+
import { TaskStore } from '../task/TaskStore';
|
|
25
|
+
import type { Task, TaskNode } from '../task/types';
|
|
26
|
+
import { useTaskStore } from '../task/useTaskStore';
|
|
27
|
+
import type { MessageKey } from '../i18n';
|
|
28
|
+
import { useSafeAreaInsetsOptional } from './safeArea';
|
|
29
|
+
import { IconClose, IconStop } from './icons';
|
|
30
|
+
|
|
31
|
+
const SHEET_BG_FALLBACK = '#121316';
|
|
32
|
+
const DEFAULT_SHEET_HEIGHT_RATIO = 0.6;
|
|
33
|
+
/** Auto-growing composer: default 1 line, cap at 3. */
|
|
34
|
+
const INPUT_FONT_SIZE = 15;
|
|
35
|
+
const INPUT_LINE_HEIGHT = 22;
|
|
36
|
+
const INPUT_MAX_LINES = 3;
|
|
37
|
+
const INPUT_TEXT_MIN = INPUT_LINE_HEIGHT;
|
|
38
|
+
const INPUT_TEXT_MAX = INPUT_LINE_HEIGHT * INPUT_MAX_LINES;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Estimate height from text + box width.
|
|
42
|
+
* iOS often reports a stuck contentSize when `height` is controlled, so we
|
|
43
|
+
* must not rely on contentSize alone (paste / wrap would never grow).
|
|
44
|
+
*/
|
|
45
|
+
function estimateComposerHeight(value: string, widthPt: number): number {
|
|
46
|
+
if (!value) return INPUT_TEXT_MIN;
|
|
47
|
+
const paragraphs = value.split('\n');
|
|
48
|
+
if (widthPt <= 0) {
|
|
49
|
+
return Math.min(
|
|
50
|
+
INPUT_TEXT_MAX,
|
|
51
|
+
Math.max(INPUT_TEXT_MIN, paragraphs.length * INPUT_LINE_HEIGHT),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
// Slightly narrow so we grow a bit early rather than clip.
|
|
55
|
+
const charsPerLine = Math.max(4, Math.floor(widthPt / (INPUT_FONT_SIZE * 0.95)));
|
|
56
|
+
let lines = 0;
|
|
57
|
+
for (const para of paragraphs) {
|
|
58
|
+
const len = Math.max(1, Array.from(para).length);
|
|
59
|
+
lines += Math.ceil(len / charsPerLine);
|
|
60
|
+
}
|
|
61
|
+
lines = Math.min(INPUT_MAX_LINES, Math.max(1, lines));
|
|
62
|
+
return lines * INPUT_LINE_HEIGHT;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
type HostStatusBarSnapshot = {
|
|
67
|
+
barStyle: StatusBarStyle;
|
|
68
|
+
backgroundColor?: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Read the host app's current StatusBar appearance before we override it. */
|
|
72
|
+
function snapshotHostStatusBar(): HostStatusBarSnapshot {
|
|
73
|
+
const sb = StatusBar as unknown as {
|
|
74
|
+
_currentValues?: {
|
|
75
|
+
barStyle?: { value?: StatusBarStyle };
|
|
76
|
+
backgroundColor?: { value?: unknown };
|
|
77
|
+
};
|
|
78
|
+
_defaultProps?: {
|
|
79
|
+
barStyle?: { value?: StatusBarStyle };
|
|
80
|
+
backgroundColor?: { value?: unknown };
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const cur = sb._currentValues ?? sb._defaultProps;
|
|
84
|
+
return {
|
|
85
|
+
barStyle: cur?.barStyle?.value ?? 'default',
|
|
86
|
+
backgroundColor:
|
|
87
|
+
cur?.backgroundColor?.value != null
|
|
88
|
+
? String(cur.backgroundColor.value)
|
|
89
|
+
: undefined,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const KIND_KEYS: Record<TaskNode['kind'], MessageKey> = {
|
|
94
|
+
user: 'kind.user',
|
|
95
|
+
plan: 'kind.plan',
|
|
96
|
+
dump: 'kind.dump',
|
|
97
|
+
find: 'kind.find',
|
|
98
|
+
tap: 'kind.tap',
|
|
99
|
+
swipe: 'kind.swipe',
|
|
100
|
+
type: 'kind.type',
|
|
101
|
+
confirm: 'kind.confirm',
|
|
102
|
+
info: 'kind.info',
|
|
103
|
+
error: 'kind.error',
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function formatTime(ts: number): string {
|
|
107
|
+
const d = new Date(ts);
|
|
108
|
+
return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Chat sheet: backdrop fades in first, then sheet slides down from the top.
|
|
113
|
+
*/
|
|
114
|
+
export function KokoChatSheet({ placeholder }: { placeholder?: string }) {
|
|
115
|
+
const koko = useKokoAgent();
|
|
116
|
+
const { branding, t, colors } = useKokoUi();
|
|
117
|
+
const { tasks, ui, activeTaskId } = useTaskStore();
|
|
118
|
+
const insets = useSafeAreaInsetsOptional();
|
|
119
|
+
const [text, setText] = useState('');
|
|
120
|
+
const [inputHeight, setInputHeight] = useState(INPUT_TEXT_MIN);
|
|
121
|
+
const [inputWidth, setInputWidth] = useState(0);
|
|
122
|
+
const textRef = useRef('');
|
|
123
|
+
const [busy, setBusy] = useState(false);
|
|
124
|
+
const [mounted, setMounted] = useState(false);
|
|
125
|
+
|
|
126
|
+
const backdropOpacity = useRef(new Animated.Value(0)).current;
|
|
127
|
+
// Negative Y = off-screen above; sheet slides down from the top.
|
|
128
|
+
const sheetY = useRef(new Animated.Value(-Dimensions.get('window').height)).current;
|
|
129
|
+
const statusBarEntryRef = useRef<StatusBarProps | null>(null);
|
|
130
|
+
const hostStatusBarRef = useRef<HostStatusBarSnapshot | null>(null);
|
|
131
|
+
|
|
132
|
+
const primaryColor = branding.primaryColor;
|
|
133
|
+
const inputPlaceholder = placeholder ?? branding.placeholder;
|
|
134
|
+
|
|
135
|
+
const statusMeta = useCallback(
|
|
136
|
+
(status: Task['status']): { color: string; label: string } => {
|
|
137
|
+
switch (status) {
|
|
138
|
+
case 'running':
|
|
139
|
+
return { color: '#34D399', label: t('status.running') };
|
|
140
|
+
case 'success':
|
|
141
|
+
return { color: '#60A5FA', label: t('status.success') };
|
|
142
|
+
case 'failed':
|
|
143
|
+
return { color: '#F87171', label: t('status.failed') };
|
|
144
|
+
case 'cancelled':
|
|
145
|
+
return { color: '#A1A1AA', label: t('status.cancelled') };
|
|
146
|
+
default:
|
|
147
|
+
return { color: '#A1A1AA', label: status };
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
[t],
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const applySheetStatusBar = useCallback(() => {
|
|
154
|
+
if (statusBarEntryRef.current) return;
|
|
155
|
+
// Record host app status bar before overriding (for restore / debugging).
|
|
156
|
+
hostStatusBarRef.current = snapshotHostStatusBar();
|
|
157
|
+
statusBarEntryRef.current = StatusBar.pushStackEntry({
|
|
158
|
+
animated: true,
|
|
159
|
+
barStyle: colors.statusBar,
|
|
160
|
+
// Colour only. On Android `translucent` is a window flag on the host
|
|
161
|
+
// activity, not something we paint: flipping it relayouts the whole app
|
|
162
|
+
// out from under the status bar and back again, which reads as the host
|
|
163
|
+
// flinching every time the sheet opens. The Modal already draws under
|
|
164
|
+
// the status bar on its own.
|
|
165
|
+
...(Platform.OS === 'android' ? { backgroundColor: colors.sheetBg } : null),
|
|
166
|
+
});
|
|
167
|
+
}, [colors.sheetBg, colors.statusBar]);
|
|
168
|
+
|
|
169
|
+
const restoreHostStatusBar = useCallback(() => {
|
|
170
|
+
if (statusBarEntryRef.current) {
|
|
171
|
+
StatusBar.popStackEntry(statusBarEntryRef.current);
|
|
172
|
+
statusBarEntryRef.current = null;
|
|
173
|
+
} else if (hostStatusBarRef.current) {
|
|
174
|
+
// Fallback if stack entry was lost — re-apply recorded host values.
|
|
175
|
+
const prev = hostStatusBarRef.current;
|
|
176
|
+
StatusBar.setBarStyle(prev.barStyle, true);
|
|
177
|
+
if (Platform.OS === 'android' && prev.backgroundColor != null) {
|
|
178
|
+
StatusBar.setBackgroundColor(prev.backgroundColor, true);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
hostStatusBarRef.current = null;
|
|
182
|
+
}, []);
|
|
183
|
+
|
|
184
|
+
// This sheet hangs from the top, so a keyboard never pushes it anywhere —
|
|
185
|
+
// it just eats the bottom of the screen where the composer lives. The only
|
|
186
|
+
// thing that keeps the input reachable is capping how tall the sheet may
|
|
187
|
+
// grow. KeyboardAvoidingView cannot express that: it assumes bottom-anchored
|
|
188
|
+
// content, and on Android the Modal gets its own window that the system
|
|
189
|
+
// never resizes for the IME, so it is a no-op there anyway.
|
|
190
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
191
|
+
const [rootHeight, setRootHeight] = useState(0);
|
|
192
|
+
const [composerFocused, setComposerFocused] = useState(false);
|
|
193
|
+
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
const ios = Platform.OS === 'ios';
|
|
196
|
+
const show = Keyboard.addListener(
|
|
197
|
+
ios ? 'keyboardWillShow' : 'keyboardDidShow',
|
|
198
|
+
(e) => setKeyboardHeight(e.endCoordinates.height),
|
|
199
|
+
);
|
|
200
|
+
const hide = Keyboard.addListener(
|
|
201
|
+
ios ? 'keyboardWillHide' : 'keyboardDidHide',
|
|
202
|
+
() => setKeyboardHeight(0),
|
|
203
|
+
);
|
|
204
|
+
return () => {
|
|
205
|
+
show.remove();
|
|
206
|
+
hide.remove();
|
|
207
|
+
};
|
|
208
|
+
}, []);
|
|
209
|
+
|
|
210
|
+
const selected: Task | null = useMemo(() => {
|
|
211
|
+
const id = ui.selectedTaskId ?? activeTaskId ?? tasks[0]?.id;
|
|
212
|
+
return tasks.find((t) => t.id === id) ?? null;
|
|
213
|
+
}, [tasks, ui.selectedTaskId, activeTaskId]);
|
|
214
|
+
|
|
215
|
+
const running =
|
|
216
|
+
busy || tasks.some((t) => t.id === activeTaskId && t.status === 'running');
|
|
217
|
+
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
if (ui.sheetOpen && !ui.selectedTaskId && tasks[0]) {
|
|
220
|
+
TaskStore.setUi({ selectedTaskId: activeTaskId ?? tasks[0].id });
|
|
221
|
+
}
|
|
222
|
+
}, [ui.sheetOpen, ui.selectedTaskId, tasks, activeTaskId]);
|
|
223
|
+
|
|
224
|
+
const closeAnimated = useCallback(() => {
|
|
225
|
+
const off = -Dimensions.get('window').height;
|
|
226
|
+
Animated.parallel([
|
|
227
|
+
Animated.timing(sheetY, {
|
|
228
|
+
toValue: off,
|
|
229
|
+
duration: 260,
|
|
230
|
+
easing: Easing.in(Easing.cubic),
|
|
231
|
+
useNativeDriver: true,
|
|
232
|
+
}),
|
|
233
|
+
Animated.timing(backdropOpacity, {
|
|
234
|
+
toValue: 0,
|
|
235
|
+
duration: 220,
|
|
236
|
+
delay: 80,
|
|
237
|
+
useNativeDriver: true,
|
|
238
|
+
}),
|
|
239
|
+
]).start(() => {
|
|
240
|
+
// Always clear sheetOpen — if we only close on finished=true,
|
|
241
|
+
// an interrupted animation leaves sheetOpen stuck true and the
|
|
242
|
+
// sheet can slide back open on remount / Fast Refresh.
|
|
243
|
+
restoreHostStatusBar();
|
|
244
|
+
setMounted(false);
|
|
245
|
+
TaskStore.closeSheet();
|
|
246
|
+
});
|
|
247
|
+
}, [backdropOpacity, sheetY, restoreHostStatusBar]);
|
|
248
|
+
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
if (ui.sheetOpen) {
|
|
251
|
+
setMounted(true);
|
|
252
|
+
applySheetStatusBar();
|
|
253
|
+
sheetY.setValue(-Dimensions.get('window').height);
|
|
254
|
+
backdropOpacity.setValue(0);
|
|
255
|
+
// 1) backdrop fade 2) sheet slides down from top
|
|
256
|
+
Animated.sequence([
|
|
257
|
+
Animated.timing(backdropOpacity, {
|
|
258
|
+
toValue: 1,
|
|
259
|
+
duration: 180,
|
|
260
|
+
easing: Easing.out(Easing.quad),
|
|
261
|
+
useNativeDriver: true,
|
|
262
|
+
}),
|
|
263
|
+
Animated.timing(sheetY, {
|
|
264
|
+
toValue: 0,
|
|
265
|
+
duration: 320,
|
|
266
|
+
easing: Easing.out(Easing.cubic),
|
|
267
|
+
useNativeDriver: true,
|
|
268
|
+
}),
|
|
269
|
+
]).start();
|
|
270
|
+
} else if (mounted) {
|
|
271
|
+
restoreHostStatusBar();
|
|
272
|
+
setMounted(false);
|
|
273
|
+
backdropOpacity.setValue(0);
|
|
274
|
+
sheetY.setValue(-Dimensions.get('window').height);
|
|
275
|
+
}
|
|
276
|
+
}, [ui.sheetOpen]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
277
|
+
|
|
278
|
+
useEffect(() => () => restoreHostStatusBar(), [restoreHostStatusBar]);
|
|
279
|
+
|
|
280
|
+
const onSend = useCallback(async () => {
|
|
281
|
+
const goal = text.trim();
|
|
282
|
+
if (!goal || running) return;
|
|
283
|
+
setBusy(true);
|
|
284
|
+
setText('');
|
|
285
|
+
textRef.current = '';
|
|
286
|
+
setInputHeight(INPUT_TEXT_MIN);
|
|
287
|
+
// Drop sheet state immediately so a mid-run remount cannot reopen it.
|
|
288
|
+
restoreHostStatusBar();
|
|
289
|
+
setMounted(false);
|
|
290
|
+
TaskStore.closeSheet();
|
|
291
|
+
sheetY.setValue(-Dimensions.get('window').height);
|
|
292
|
+
backdropOpacity.setValue(0);
|
|
293
|
+
// Let host unfreeze + EmptyWallet remount before the first dump.
|
|
294
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
295
|
+
try {
|
|
296
|
+
await koko.runGoal(goal);
|
|
297
|
+
} catch {
|
|
298
|
+
// surfaced in task log
|
|
299
|
+
} finally {
|
|
300
|
+
setBusy(false);
|
|
301
|
+
}
|
|
302
|
+
}, [
|
|
303
|
+
text,
|
|
304
|
+
running,
|
|
305
|
+
koko,
|
|
306
|
+
restoreHostStatusBar,
|
|
307
|
+
sheetY,
|
|
308
|
+
backdropOpacity,
|
|
309
|
+
]);
|
|
310
|
+
|
|
311
|
+
const onStop = useCallback(() => {
|
|
312
|
+
koko.stop();
|
|
313
|
+
koko.finishTask('cancelled', t('runtime.cancelled'));
|
|
314
|
+
setBusy(false);
|
|
315
|
+
}, [koko, t]);
|
|
316
|
+
|
|
317
|
+
const confirmDeleteTask = useCallback(
|
|
318
|
+
(task: Task) => {
|
|
319
|
+
const title =
|
|
320
|
+
task.title.length > 36 ? `${task.title.slice(0, 36)}…` : task.title;
|
|
321
|
+
Alert.alert(
|
|
322
|
+
t('sheet.deleteTaskTitle'),
|
|
323
|
+
t('sheet.deleteTaskBody', { title }),
|
|
324
|
+
[
|
|
325
|
+
{ text: t('dialog.cancel'), style: 'cancel' },
|
|
326
|
+
{
|
|
327
|
+
text: t('sheet.deleteTask'),
|
|
328
|
+
style: 'destructive',
|
|
329
|
+
onPress: () => {
|
|
330
|
+
if (task.status === 'running' && task.id === activeTaskId) {
|
|
331
|
+
koko.stop();
|
|
332
|
+
}
|
|
333
|
+
TaskStore.removeTask(task.id);
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
);
|
|
338
|
+
},
|
|
339
|
+
[t, koko, activeTaskId],
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
if (!mounted && !ui.sheetOpen) return null;
|
|
343
|
+
|
|
344
|
+
const topPad = Math.max(insets.top, Platform.OS === 'ios' ? 44 : 24) + 8;
|
|
345
|
+
|
|
346
|
+
// A host whose activity runs in adjustPan never gets a keyboard frame out of
|
|
347
|
+
// Android, and neither does anything drawn inside a Modal's own window. Both
|
|
348
|
+
// are the host's call, not ours, so when the composer has focus and no frame
|
|
349
|
+
// arrived, assume a keyboard of typical size rather than let it swallow the
|
|
350
|
+
// input.
|
|
351
|
+
const screenH = rootHeight || Dimensions.get('window').height;
|
|
352
|
+
const occluded =
|
|
353
|
+
keyboardHeight > 0
|
|
354
|
+
? keyboardHeight
|
|
355
|
+
: composerFocused
|
|
356
|
+
? screenH * 0.45
|
|
357
|
+
: 0;
|
|
358
|
+
// Keep entry, empty and selected-task states at the same default height.
|
|
359
|
+
// Content scrolls inside the sheet; the keyboard may shrink, never grow it.
|
|
360
|
+
const defaultHeight = Math.round(screenH * DEFAULT_SHEET_HEIGHT_RATIO);
|
|
361
|
+
const sheetSize = {
|
|
362
|
+
height: occluded > 0
|
|
363
|
+
? Math.min(defaultHeight, Math.max(screenH * 0.3, screenH - occluded - 8))
|
|
364
|
+
: defaultHeight,
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<Modal
|
|
369
|
+
visible={mounted || ui.sheetOpen}
|
|
370
|
+
animationType="none"
|
|
371
|
+
transparent
|
|
372
|
+
presentationStyle="overFullScreen"
|
|
373
|
+
onRequestClose={closeAnimated}
|
|
374
|
+
statusBarTranslucent
|
|
375
|
+
>
|
|
376
|
+
<View
|
|
377
|
+
testID="koko-agent-overlay"
|
|
378
|
+
nativeID="koko-agent-overlay"
|
|
379
|
+
collapsable={false}
|
|
380
|
+
style={styles.root}
|
|
381
|
+
onLayout={(e) => setRootHeight(e.nativeEvent.layout.height)}
|
|
382
|
+
>
|
|
383
|
+
{/* Full-screen dim — must stay behind the sheet; tap closes. */}
|
|
384
|
+
<Animated.View
|
|
385
|
+
pointerEvents="auto"
|
|
386
|
+
style={[
|
|
387
|
+
styles.backdrop,
|
|
388
|
+
{ opacity: backdropOpacity, backgroundColor: colors.overlay },
|
|
389
|
+
]}
|
|
390
|
+
>
|
|
391
|
+
<Pressable
|
|
392
|
+
style={StyleSheet.absoluteFill}
|
|
393
|
+
onPress={closeAnimated}
|
|
394
|
+
accessibilityRole="button"
|
|
395
|
+
accessibilityLabel={t('sheet.closeA11y')}
|
|
396
|
+
/>
|
|
397
|
+
</Animated.View>
|
|
398
|
+
|
|
399
|
+
<View style={styles.sheetWrap} pointerEvents="box-none">
|
|
400
|
+
<Animated.View
|
|
401
|
+
style={[
|
|
402
|
+
styles.sheet,
|
|
403
|
+
sheetSize,
|
|
404
|
+
{
|
|
405
|
+
paddingTop: topPad,
|
|
406
|
+
transform: [{ translateY: sheetY }],
|
|
407
|
+
backgroundColor: colors.sheetBg,
|
|
408
|
+
borderColor: colors.border,
|
|
409
|
+
},
|
|
410
|
+
]}
|
|
411
|
+
>
|
|
412
|
+
<View style={styles.header}>
|
|
413
|
+
<View style={styles.brandBlock}>
|
|
414
|
+
<View style={[styles.brandMark, { backgroundColor: primaryColor }]}>
|
|
415
|
+
{branding.iconSource ? (
|
|
416
|
+
<Image
|
|
417
|
+
source={branding.iconSource}
|
|
418
|
+
style={styles.brandMarkImage}
|
|
419
|
+
resizeMode="cover"
|
|
420
|
+
/>
|
|
421
|
+
) : (
|
|
422
|
+
<Text style={styles.brandMarkText}>{branding.mark}</Text>
|
|
423
|
+
)}
|
|
424
|
+
</View>
|
|
425
|
+
<View>
|
|
426
|
+
<Text style={[styles.title, { color: colors.text }]}>
|
|
427
|
+
{branding.name}
|
|
428
|
+
</Text>
|
|
429
|
+
<Text style={[styles.subtitle, { color: colors.textSecondary }]}>
|
|
430
|
+
{branding.tagline}
|
|
431
|
+
</Text>
|
|
432
|
+
</View>
|
|
433
|
+
</View>
|
|
434
|
+
<Pressable
|
|
435
|
+
onPress={closeAnimated}
|
|
436
|
+
hitSlop={12}
|
|
437
|
+
style={styles.closeBtn}
|
|
438
|
+
accessibilityRole="button"
|
|
439
|
+
accessibilityLabel={t('sheet.closeA11y')}
|
|
440
|
+
>
|
|
441
|
+
<IconClose size={13} color={colors.textSecondary} />
|
|
442
|
+
</Pressable>
|
|
443
|
+
</View>
|
|
444
|
+
|
|
445
|
+
<Text style={[styles.section, { color: colors.textMuted }]}>
|
|
446
|
+
{t('sheet.recentTasks')}
|
|
447
|
+
</Text>
|
|
448
|
+
<FlatList
|
|
449
|
+
horizontal
|
|
450
|
+
data={tasks}
|
|
451
|
+
keyExtractor={(t) => t.id}
|
|
452
|
+
style={styles.taskStrip}
|
|
453
|
+
contentContainerStyle={styles.taskStripContent}
|
|
454
|
+
showsHorizontalScrollIndicator={false}
|
|
455
|
+
ListEmptyComponent={
|
|
456
|
+
<Text style={[styles.emptyInline, { color: colors.textMuted }]}>
|
|
457
|
+
{t('sheet.emptyTasks')}
|
|
458
|
+
</Text>
|
|
459
|
+
}
|
|
460
|
+
renderItem={({ item }) => {
|
|
461
|
+
const selectedRow = item.id === selected?.id;
|
|
462
|
+
const meta = statusMeta(item.status);
|
|
463
|
+
return (
|
|
464
|
+
<Pressable
|
|
465
|
+
style={[
|
|
466
|
+
styles.taskChip,
|
|
467
|
+
{ backgroundColor: colors.chipBg, borderColor: colors.border },
|
|
468
|
+
selectedRow && styles.taskChipOn,
|
|
469
|
+
]}
|
|
470
|
+
onPress={() => TaskStore.selectTask(item.id)}
|
|
471
|
+
onLongPress={() => confirmDeleteTask(item)}
|
|
472
|
+
delayLongPress={380}
|
|
473
|
+
accessibilityRole="button"
|
|
474
|
+
accessibilityHint={t('sheet.deleteTask')}
|
|
475
|
+
>
|
|
476
|
+
<View style={[styles.dot, { backgroundColor: meta.color }]} />
|
|
477
|
+
<View style={styles.taskChipBody}>
|
|
478
|
+
<Text
|
|
479
|
+
style={[styles.taskChipText, { color: colors.text }]}
|
|
480
|
+
numberOfLines={1}
|
|
481
|
+
>
|
|
482
|
+
{item.title}
|
|
483
|
+
</Text>
|
|
484
|
+
<Text style={[styles.taskChipMeta, { color: meta.color }]}>
|
|
485
|
+
{meta.label}
|
|
486
|
+
</Text>
|
|
487
|
+
</View>
|
|
488
|
+
</Pressable>
|
|
489
|
+
);
|
|
490
|
+
}}
|
|
491
|
+
/>
|
|
492
|
+
|
|
493
|
+
<View style={styles.sessionHead}>
|
|
494
|
+
<Text style={[styles.sectionTight, { color: colors.textMuted }]}>
|
|
495
|
+
{t('sheet.timeline')}
|
|
496
|
+
</Text>
|
|
497
|
+
{selected ? (
|
|
498
|
+
<Text
|
|
499
|
+
style={[styles.sessionHint, { color: colors.textSecondary }]}
|
|
500
|
+
numberOfLines={1}
|
|
501
|
+
>
|
|
502
|
+
{selected.title}
|
|
503
|
+
</Text>
|
|
504
|
+
) : null}
|
|
505
|
+
</View>
|
|
506
|
+
|
|
507
|
+
<FlatList
|
|
508
|
+
style={styles.nodeList}
|
|
509
|
+
data={selected?.nodes ?? []}
|
|
510
|
+
keyExtractor={(n) => n.id}
|
|
511
|
+
contentContainerStyle={
|
|
512
|
+
(selected?.nodes.length ?? 0) === 0 ? styles.nodeListEmpty : undefined
|
|
513
|
+
}
|
|
514
|
+
ListEmptyComponent={
|
|
515
|
+
<View style={styles.emptyBlock}>
|
|
516
|
+
<Text style={[styles.emptyTitle, { color: colors.text }]}>
|
|
517
|
+
{t('sheet.emptyNodesTitle')}
|
|
518
|
+
</Text>
|
|
519
|
+
<Text style={[styles.emptyHint, { color: colors.textMuted }]}>
|
|
520
|
+
{t('sheet.emptyNodesHint')}
|
|
521
|
+
</Text>
|
|
522
|
+
</View>
|
|
523
|
+
}
|
|
524
|
+
renderItem={({ item, index }) => (
|
|
525
|
+
<View style={styles.nodeRow}>
|
|
526
|
+
<View style={styles.timeline}>
|
|
527
|
+
<View
|
|
528
|
+
style={[styles.timelineDot, { backgroundColor: colors.textMuted }]}
|
|
529
|
+
/>
|
|
530
|
+
{index < (selected?.nodes.length ?? 1) - 1 ? (
|
|
531
|
+
<View
|
|
532
|
+
style={[styles.timelineLine, { backgroundColor: colors.border }]}
|
|
533
|
+
/>
|
|
534
|
+
) : null}
|
|
535
|
+
</View>
|
|
536
|
+
<View style={styles.nodeBody}>
|
|
537
|
+
<View style={styles.nodeTop}>
|
|
538
|
+
<Text style={[styles.nodeKind, { color: colors.textMuted }]}>
|
|
539
|
+
{t(KIND_KEYS[item.kind])}
|
|
540
|
+
</Text>
|
|
541
|
+
<Text style={[styles.nodeTime, { color: colors.textMuted }]}>
|
|
542
|
+
{formatTime(item.createdAt)}
|
|
543
|
+
</Text>
|
|
544
|
+
</View>
|
|
545
|
+
<Text style={[styles.nodeTitle, { color: colors.text }]}>
|
|
546
|
+
{item.title}
|
|
547
|
+
</Text>
|
|
548
|
+
</View>
|
|
549
|
+
</View>
|
|
550
|
+
)}
|
|
551
|
+
/>
|
|
552
|
+
|
|
553
|
+
<View style={styles.composer}>
|
|
554
|
+
<View
|
|
555
|
+
style={[
|
|
556
|
+
styles.inputWrap,
|
|
557
|
+
{ backgroundColor: colors.inputBg, borderColor: colors.border },
|
|
558
|
+
]}
|
|
559
|
+
onLayout={(e) => {
|
|
560
|
+
const w = Math.round(e.nativeEvent.layout.width);
|
|
561
|
+
if (w > 0 && w !== inputWidth) {
|
|
562
|
+
setInputWidth(w);
|
|
563
|
+
setInputHeight(estimateComposerHeight(textRef.current, w));
|
|
564
|
+
}
|
|
565
|
+
}}
|
|
566
|
+
>
|
|
567
|
+
<TextInput
|
|
568
|
+
style={[
|
|
569
|
+
styles.input,
|
|
570
|
+
{
|
|
571
|
+
minHeight: INPUT_TEXT_MIN,
|
|
572
|
+
height: inputHeight,
|
|
573
|
+
maxHeight: INPUT_TEXT_MAX,
|
|
574
|
+
color: colors.text,
|
|
575
|
+
},
|
|
576
|
+
]}
|
|
577
|
+
value={text}
|
|
578
|
+
onChangeText={(v) => {
|
|
579
|
+
textRef.current = v;
|
|
580
|
+
setText(v);
|
|
581
|
+
setInputHeight(estimateComposerHeight(v, inputWidth));
|
|
582
|
+
}}
|
|
583
|
+
onContentSizeChange={(e) => {
|
|
584
|
+
const v = textRef.current;
|
|
585
|
+
if (!v) {
|
|
586
|
+
setInputHeight(INPUT_TEXT_MIN);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const estimated = estimateComposerHeight(v, inputWidth);
|
|
590
|
+
const raw = e.nativeEvent.contentSize.height;
|
|
591
|
+
const fromSize =
|
|
592
|
+
raw > INPUT_LINE_HEIGHT + 8
|
|
593
|
+
? Math.min(INPUT_TEXT_MAX, Math.max(INPUT_TEXT_MIN, Math.ceil(raw)))
|
|
594
|
+
: INPUT_TEXT_MIN;
|
|
595
|
+
const next = Math.max(estimated, fromSize);
|
|
596
|
+
setInputHeight((prev) => (prev === next ? prev : next));
|
|
597
|
+
}}
|
|
598
|
+
placeholder={inputPlaceholder}
|
|
599
|
+
placeholderTextColor={colors.textMuted}
|
|
600
|
+
editable={!running}
|
|
601
|
+
multiline
|
|
602
|
+
scrollEnabled={inputHeight >= INPUT_TEXT_MAX - 1}
|
|
603
|
+
textAlignVertical="top"
|
|
604
|
+
blurOnSubmit={false}
|
|
605
|
+
onFocus={() => setComposerFocused(true)}
|
|
606
|
+
onBlur={() => setComposerFocused(false)}
|
|
607
|
+
accessibilityLabel={t('sheet.inputA11y')}
|
|
608
|
+
/>
|
|
609
|
+
</View>
|
|
610
|
+
{running ? (
|
|
611
|
+
<Pressable
|
|
612
|
+
style={[styles.btn, styles.btnStop, styles.btnIcon]}
|
|
613
|
+
onPress={onStop}
|
|
614
|
+
accessibilityRole="button"
|
|
615
|
+
accessibilityLabel={t('sheet.stopA11y')}
|
|
616
|
+
>
|
|
617
|
+
<IconStop size={12} color="#fff" />
|
|
618
|
+
</Pressable>
|
|
619
|
+
) : (
|
|
620
|
+
<Pressable
|
|
621
|
+
style={[
|
|
622
|
+
styles.btn,
|
|
623
|
+
styles.btnSend,
|
|
624
|
+
{ backgroundColor: primaryColor },
|
|
625
|
+
!text.trim() && styles.btnDisabled,
|
|
626
|
+
]}
|
|
627
|
+
onPress={onSend}
|
|
628
|
+
disabled={!text.trim()}
|
|
629
|
+
>
|
|
630
|
+
{busy ? (
|
|
631
|
+
<ActivityIndicator color="#fff" />
|
|
632
|
+
) : (
|
|
633
|
+
<Text style={styles.btnText}>{t('sheet.send')}</Text>
|
|
634
|
+
)}
|
|
635
|
+
</Pressable>
|
|
636
|
+
)}
|
|
637
|
+
</View>
|
|
638
|
+
|
|
639
|
+
<View style={[styles.handle, { backgroundColor: colors.handle }]} />
|
|
640
|
+
</Animated.View>
|
|
641
|
+
</View>
|
|
642
|
+
</View>
|
|
643
|
+
</Modal>
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const styles = StyleSheet.create({
|
|
648
|
+
root: {
|
|
649
|
+
flex: 1,
|
|
650
|
+
justifyContent: 'flex-start',
|
|
651
|
+
},
|
|
652
|
+
backdrop: {
|
|
653
|
+
...StyleSheet.absoluteFillObject,
|
|
654
|
+
zIndex: 0,
|
|
655
|
+
},
|
|
656
|
+
sheetWrap: {
|
|
657
|
+
flex: 1,
|
|
658
|
+
justifyContent: 'flex-start',
|
|
659
|
+
zIndex: 1,
|
|
660
|
+
},
|
|
661
|
+
sheet: {
|
|
662
|
+
// Definite height above bounds the flexible, scrolling step list.
|
|
663
|
+
backgroundColor: SHEET_BG_FALLBACK,
|
|
664
|
+
borderBottomLeftRadius: 22,
|
|
665
|
+
borderBottomRightRadius: 22,
|
|
666
|
+
paddingHorizontal: 16,
|
|
667
|
+
paddingBottom: 10,
|
|
668
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
669
|
+
borderColor: 'rgba(255,255,255,0.08)',
|
|
670
|
+
borderTopWidth: 0,
|
|
671
|
+
},
|
|
672
|
+
handle: {
|
|
673
|
+
alignSelf: 'center',
|
|
674
|
+
width: 40,
|
|
675
|
+
height: 4,
|
|
676
|
+
borderRadius: 2,
|
|
677
|
+
backgroundColor: 'rgba(255,255,255,0.22)',
|
|
678
|
+
marginTop: 12,
|
|
679
|
+
},
|
|
680
|
+
header: {
|
|
681
|
+
flexDirection: 'row',
|
|
682
|
+
alignItems: 'center',
|
|
683
|
+
justifyContent: 'space-between',
|
|
684
|
+
marginBottom: 18,
|
|
685
|
+
},
|
|
686
|
+
brandBlock: {
|
|
687
|
+
flexDirection: 'row',
|
|
688
|
+
alignItems: 'center',
|
|
689
|
+
gap: 12,
|
|
690
|
+
flexShrink: 1,
|
|
691
|
+
},
|
|
692
|
+
brandMark: {
|
|
693
|
+
width: 36,
|
|
694
|
+
height: 36,
|
|
695
|
+
borderRadius: 10,
|
|
696
|
+
backgroundColor: '#0A84FF',
|
|
697
|
+
alignItems: 'center',
|
|
698
|
+
justifyContent: 'center',
|
|
699
|
+
overflow: 'hidden',
|
|
700
|
+
},
|
|
701
|
+
brandMarkImage: {
|
|
702
|
+
width: 36,
|
|
703
|
+
height: 36,
|
|
704
|
+
},
|
|
705
|
+
brandMarkText: {
|
|
706
|
+
color: '#fff',
|
|
707
|
+
fontSize: 17,
|
|
708
|
+
fontWeight: '800',
|
|
709
|
+
},
|
|
710
|
+
title: {
|
|
711
|
+
color: '#F4F4F5',
|
|
712
|
+
fontSize: 18,
|
|
713
|
+
fontWeight: '800',
|
|
714
|
+
letterSpacing: -0.3,
|
|
715
|
+
},
|
|
716
|
+
subtitle: {
|
|
717
|
+
color: 'rgba(255,255,255,0.42)',
|
|
718
|
+
fontSize: 12,
|
|
719
|
+
marginTop: 2,
|
|
720
|
+
},
|
|
721
|
+
closeBtn: {
|
|
722
|
+
width: 32,
|
|
723
|
+
height: 32,
|
|
724
|
+
borderRadius: 10,
|
|
725
|
+
backgroundColor: 'rgba(255,255,255,0.06)',
|
|
726
|
+
alignItems: 'center',
|
|
727
|
+
justifyContent: 'center',
|
|
728
|
+
},
|
|
729
|
+
section: {
|
|
730
|
+
color: 'rgba(255,255,255,0.38)',
|
|
731
|
+
fontSize: 11,
|
|
732
|
+
fontWeight: '700',
|
|
733
|
+
letterSpacing: 0.6,
|
|
734
|
+
textTransform: 'uppercase',
|
|
735
|
+
marginBottom: 10,
|
|
736
|
+
},
|
|
737
|
+
sectionTight: {
|
|
738
|
+
color: 'rgba(255,255,255,0.38)',
|
|
739
|
+
fontSize: 11,
|
|
740
|
+
fontWeight: '700',
|
|
741
|
+
letterSpacing: 0.6,
|
|
742
|
+
textTransform: 'uppercase',
|
|
743
|
+
},
|
|
744
|
+
taskStrip: {
|
|
745
|
+
maxHeight: 64,
|
|
746
|
+
// The sheet shrinks to fit above the keyboard; without this the strip
|
|
747
|
+
// gives way first and clips its chips instead of the step list scrolling.
|
|
748
|
+
flexGrow: 0,
|
|
749
|
+
flexShrink: 0,
|
|
750
|
+
marginBottom: 16,
|
|
751
|
+
},
|
|
752
|
+
taskStripContent: {
|
|
753
|
+
alignItems: 'center',
|
|
754
|
+
paddingRight: 8,
|
|
755
|
+
},
|
|
756
|
+
taskChip: {
|
|
757
|
+
flexDirection: 'row',
|
|
758
|
+
alignItems: 'center',
|
|
759
|
+
paddingHorizontal: 12,
|
|
760
|
+
paddingVertical: 10,
|
|
761
|
+
borderRadius: 14,
|
|
762
|
+
backgroundColor: 'rgba(255,255,255,0.05)',
|
|
763
|
+
marginRight: 8,
|
|
764
|
+
maxWidth: 200,
|
|
765
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
766
|
+
borderColor: 'rgba(255,255,255,0.06)',
|
|
767
|
+
},
|
|
768
|
+
taskChipOn: {
|
|
769
|
+
backgroundColor: 'rgba(10,132,255,0.18)',
|
|
770
|
+
borderColor: 'rgba(10,132,255,0.35)',
|
|
771
|
+
},
|
|
772
|
+
taskChipBody: {
|
|
773
|
+
flexShrink: 1,
|
|
774
|
+
},
|
|
775
|
+
taskChipText: {
|
|
776
|
+
color: '#F4F4F5',
|
|
777
|
+
fontSize: 13,
|
|
778
|
+
fontWeight: '600',
|
|
779
|
+
},
|
|
780
|
+
taskChipMeta: {
|
|
781
|
+
fontSize: 10,
|
|
782
|
+
fontWeight: '600',
|
|
783
|
+
marginTop: 2,
|
|
784
|
+
},
|
|
785
|
+
emptyInline: {
|
|
786
|
+
color: 'rgba(255,255,255,0.35)',
|
|
787
|
+
fontSize: 13,
|
|
788
|
+
paddingVertical: 12,
|
|
789
|
+
},
|
|
790
|
+
sessionHead: {
|
|
791
|
+
flexDirection: 'row',
|
|
792
|
+
alignItems: 'baseline',
|
|
793
|
+
justifyContent: 'space-between',
|
|
794
|
+
gap: 12,
|
|
795
|
+
marginBottom: 10,
|
|
796
|
+
},
|
|
797
|
+
sessionHint: {
|
|
798
|
+
flexShrink: 1,
|
|
799
|
+
color: 'rgba(255,255,255,0.35)',
|
|
800
|
+
fontSize: 12,
|
|
801
|
+
},
|
|
802
|
+
nodeList: {
|
|
803
|
+
flexGrow: 1,
|
|
804
|
+
flexShrink: 1,
|
|
805
|
+
minHeight: 0,
|
|
806
|
+
maxHeight: Math.round(Dimensions.get('window').height * 0.42),
|
|
807
|
+
marginBottom: 14,
|
|
808
|
+
},
|
|
809
|
+
nodeListEmpty: {
|
|
810
|
+
minHeight: 120,
|
|
811
|
+
justifyContent: 'center',
|
|
812
|
+
},
|
|
813
|
+
emptyBlock: {
|
|
814
|
+
alignItems: 'center',
|
|
815
|
+
paddingVertical: 28,
|
|
816
|
+
paddingHorizontal: 20,
|
|
817
|
+
},
|
|
818
|
+
emptyTitle: {
|
|
819
|
+
color: 'rgba(255,255,255,0.55)',
|
|
820
|
+
fontSize: 15,
|
|
821
|
+
fontWeight: '600',
|
|
822
|
+
marginBottom: 6,
|
|
823
|
+
},
|
|
824
|
+
emptyHint: {
|
|
825
|
+
color: 'rgba(255,255,255,0.32)',
|
|
826
|
+
fontSize: 13,
|
|
827
|
+
textAlign: 'center',
|
|
828
|
+
lineHeight: 18,
|
|
829
|
+
},
|
|
830
|
+
nodeRow: {
|
|
831
|
+
flexDirection: 'row',
|
|
832
|
+
paddingBottom: 4,
|
|
833
|
+
},
|
|
834
|
+
timeline: {
|
|
835
|
+
width: 16,
|
|
836
|
+
alignItems: 'center',
|
|
837
|
+
marginRight: 10,
|
|
838
|
+
},
|
|
839
|
+
timelineDot: {
|
|
840
|
+
width: 7,
|
|
841
|
+
height: 7,
|
|
842
|
+
borderRadius: 4,
|
|
843
|
+
backgroundColor: '#0A84FF',
|
|
844
|
+
marginTop: 5,
|
|
845
|
+
},
|
|
846
|
+
timelineLine: {
|
|
847
|
+
width: 1,
|
|
848
|
+
flex: 1,
|
|
849
|
+
backgroundColor: 'rgba(255,255,255,0.1)',
|
|
850
|
+
marginTop: 4,
|
|
851
|
+
marginBottom: 2,
|
|
852
|
+
},
|
|
853
|
+
nodeBody: {
|
|
854
|
+
flex: 1,
|
|
855
|
+
paddingBottom: 14,
|
|
856
|
+
},
|
|
857
|
+
nodeTop: {
|
|
858
|
+
flexDirection: 'row',
|
|
859
|
+
alignItems: 'center',
|
|
860
|
+
justifyContent: 'space-between',
|
|
861
|
+
marginBottom: 3,
|
|
862
|
+
},
|
|
863
|
+
nodeKind: {
|
|
864
|
+
color: '#7DD3FC',
|
|
865
|
+
fontSize: 10,
|
|
866
|
+
fontWeight: '700',
|
|
867
|
+
letterSpacing: 0.3,
|
|
868
|
+
},
|
|
869
|
+
nodeTime: {
|
|
870
|
+
color: 'rgba(255,255,255,0.28)',
|
|
871
|
+
fontSize: 11,
|
|
872
|
+
fontVariant: ['tabular-nums'],
|
|
873
|
+
},
|
|
874
|
+
nodeTitle: {
|
|
875
|
+
color: '#ECECF0',
|
|
876
|
+
fontSize: 14,
|
|
877
|
+
lineHeight: 20,
|
|
878
|
+
},
|
|
879
|
+
dot: {
|
|
880
|
+
width: 7,
|
|
881
|
+
height: 7,
|
|
882
|
+
borderRadius: 4,
|
|
883
|
+
marginRight: 8,
|
|
884
|
+
},
|
|
885
|
+
composer: {
|
|
886
|
+
flexShrink: 0,
|
|
887
|
+
flexDirection: 'row',
|
|
888
|
+
alignItems: 'flex-end',
|
|
889
|
+
gap: 8,
|
|
890
|
+
backgroundColor: 'rgba(255,255,255,0.06)',
|
|
891
|
+
borderRadius: 16,
|
|
892
|
+
paddingLeft: 14,
|
|
893
|
+
paddingRight: 10,
|
|
894
|
+
paddingVertical: 6,
|
|
895
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
896
|
+
borderColor: 'rgba(255,255,255,0.08)',
|
|
897
|
+
},
|
|
898
|
+
inputWrap: {
|
|
899
|
+
flex: 1,
|
|
900
|
+
paddingVertical: 8,
|
|
901
|
+
paddingHorizontal: 6,
|
|
902
|
+
justifyContent: 'center',
|
|
903
|
+
},
|
|
904
|
+
input: {
|
|
905
|
+
width: '100%',
|
|
906
|
+
color: '#F4F4F5',
|
|
907
|
+
fontSize: INPUT_FONT_SIZE,
|
|
908
|
+
lineHeight: INPUT_LINE_HEIGHT,
|
|
909
|
+
paddingHorizontal: 2,
|
|
910
|
+
paddingVertical: 0,
|
|
911
|
+
margin: 0,
|
|
912
|
+
},
|
|
913
|
+
btn: {
|
|
914
|
+
minWidth: 68,
|
|
915
|
+
paddingHorizontal: 14,
|
|
916
|
+
paddingVertical: 11,
|
|
917
|
+
borderRadius: 12,
|
|
918
|
+
alignItems: 'center',
|
|
919
|
+
justifyContent: 'center',
|
|
920
|
+
marginBottom: 2,
|
|
921
|
+
},
|
|
922
|
+
btnIcon: {
|
|
923
|
+
minWidth: 44,
|
|
924
|
+
paddingHorizontal: 12,
|
|
925
|
+
},
|
|
926
|
+
btnSend: { backgroundColor: '#0A84FF' },
|
|
927
|
+
btnStop: { backgroundColor: '#FF453A' },
|
|
928
|
+
btnDisabled: { opacity: 0.4 },
|
|
929
|
+
btnText: { color: '#fff', fontWeight: '700', fontSize: 14 },
|
|
930
|
+
});
|