@adminide-stack/yantra-mobile 12.0.196-alpha.0 → 12.0.196-alpha.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/lib/components/CustomDrawer.js +17 -1
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/compute.js +57 -1
- package/lib/compute.js.map +1 -1
- package/lib/config/env-config.js +11 -1
- package/lib/config/env-config.js.map +1 -1
- package/lib/features/agent-chat/NativeAgentChat.js +7 -0
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/canvas/extendVideo.js +5 -1
- package/lib/features/canvas/extendVideo.js.map +1 -1
- package/lib/features/canvas/workflow/StepSheet.js +18 -1
- package/lib/features/canvas/workflow/StepSheet.js.map +1 -1
- package/lib/features/canvas/workflow/workflowSteps.js +102 -31
- package/lib/features/canvas/workflow/workflowSteps.js.map +1 -1
- package/lib/features/chat/ComposerMicSend.js +35 -0
- package/lib/features/chat/ComposerMicSend.js.map +1 -0
- package/lib/features/chat/ComposerModeSwitch.js +64 -1
- package/lib/features/chat/ComposerModeSwitch.js.map +1 -1
- package/lib/features/chat/askUser.js +6 -1
- package/lib/features/chat/askUser.js.map +1 -1
- package/lib/features/connectors/ConnectorSheet.js +443 -0
- package/lib/features/connectors/ConnectorSheet.js.map +1 -0
- package/lib/features/connectors/ConnectorsPage.js +320 -0
- package/lib/features/connectors/ConnectorsPage.js.map +1 -0
- package/lib/features/connectors/connectConnector.js +278 -0
- package/lib/features/connectors/connectConnector.js.map +1 -0
- package/lib/features/connectors/connectorCatalog.js +222 -0
- package/lib/features/connectors/connectorCatalog.js.map +1 -0
- package/lib/features/connectors/useConnectorCatalog.js +153 -0
- package/lib/features/connectors/useConnectorCatalog.js.map +1 -0
- package/lib/features/home/needsYou/HomeNeedsYou.js +618 -0
- package/lib/features/home/needsYou/HomeNeedsYou.js.map +1 -0
- package/lib/features/home/needsYou/chatFollowUps.js +333 -0
- package/lib/features/home/needsYou/chatFollowUps.js.map +1 -0
- package/lib/features/home/needsYou/format.js +47 -0
- package/lib/features/home/needsYou/format.js.map +1 -0
- package/lib/features/home/needsYou/historyText.js +40 -0
- package/lib/features/home/needsYou/historyText.js.map +1 -0
- package/lib/features/home/needsYou/inboxHighlights.js +152 -0
- package/lib/features/home/needsYou/inboxHighlights.js.map +1 -0
- package/lib/features/home/needsYou/panelsSettings.js +71 -0
- package/lib/features/home/needsYou/panelsSettings.js.map +1 -0
- package/lib/features/home/needsYou/ported/commandConfirmProtocol.js +13 -0
- package/lib/features/home/needsYou/ported/commandConfirmProtocol.js.map +1 -0
- package/lib/features/home/needsYou/ported/paymentApprovalProtocol.js +91 -0
- package/lib/features/home/needsYou/ported/paymentApprovalProtocol.js.map +1 -0
- package/lib/features/home/needsYou/ported/resultCardModels.js +659 -0
- package/lib/features/home/needsYou/ported/resultCardModels.js.map +1 -0
- package/lib/features/home/needsYou/types.js +1 -0
- package/lib/features/home/needsYou/types.js.map +1 -0
- package/lib/features/home/needsYou/useChatFollowUps.js +149 -0
- package/lib/features/home/needsYou/useChatFollowUps.js.map +1 -0
- package/lib/features/home/needsYou/useHomeBriefing.js +68 -0
- package/lib/features/home/needsYou/useHomeBriefing.js.map +1 -0
- package/lib/features/home/needsYou/useInboxHighlights.js +173 -0
- package/lib/features/home/needsYou/useInboxHighlights.js.map +1 -0
- package/lib/features/home/needsYou/usePanelsSettings.js +105 -0
- package/lib/features/home/needsYou/usePanelsSettings.js.map +1 -0
- package/lib/features/shopping/DealCard.js +8 -1
- package/lib/features/shopping/DealCard.js.map +1 -1
- package/lib/features/shopping/DealRails.js +24 -7
- package/lib/features/shopping/DealRails.js.map +1 -1
- package/lib/features/shopping/DealsPanel.js +1 -1
- package/lib/features/shopping/DealsPanel.js.map +1 -1
- package/lib/features/shopping/HolidayDealsPanel.js +529 -0
- package/lib/features/shopping/HolidayDealsPanel.js.map +1 -0
- package/lib/features/shopping/HolidayDealsParts.js +954 -0
- package/lib/features/shopping/HolidayDealsParts.js.map +1 -0
- package/lib/features/shopping/HolidayOffers.js +351 -0
- package/lib/features/shopping/HolidayOffers.js.map +1 -0
- package/lib/features/shopping/ProductCard.js +80 -14
- package/lib/features/shopping/ProductCard.js.map +1 -1
- package/lib/features/shopping/ProductDetailSheet.js +22 -3
- package/lib/features/shopping/ProductDetailSheet.js.map +1 -1
- package/lib/features/shopping/SavedPanel.js +341 -5
- package/lib/features/shopping/SavedPanel.js.map +1 -1
- package/lib/features/shopping/SearchResults.js +8 -2
- package/lib/features/shopping/SearchResults.js.map +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js +12 -0
- package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
- package/lib/features/shopping/ShoppingExperience.js +56 -19
- package/lib/features/shopping/ShoppingExperience.js.map +1 -1
- package/lib/features/shopping/TrendingSections.js +13 -4
- package/lib/features/shopping/TrendingSections.js.map +1 -1
- package/lib/features/shopping/WatchlistPanel.js +61 -5
- package/lib/features/shopping/WatchlistPanel.js.map +1 -1
- package/lib/features/shopping/catalog.js +41 -2
- package/lib/features/shopping/catalog.js.map +1 -1
- package/lib/features/shopping/chat/brainRouter.js +14 -0
- package/lib/features/shopping/chat/brainRouter.js.map +1 -1
- package/lib/features/shopping/chat/shoppingTurn.js +88 -16
- package/lib/features/shopping/chat/shoppingTurn.js.map +1 -1
- package/lib/features/shopping/hooks/useHolidayDeals.js +388 -0
- package/lib/features/shopping/hooks/useHolidayDeals.js.map +1 -0
- package/lib/features/shopping/hooks/useProductMedia.js +33 -6
- package/lib/features/shopping/hooks/useProductMedia.js.map +1 -1
- package/lib/features/shopping/hooks/useShoppingHistorySync.js +8 -4
- package/lib/features/shopping/hooks/useShoppingHistorySync.js.map +1 -1
- package/lib/features/shopping/hooks/useTrendingProducts.js +11 -3
- package/lib/features/shopping/hooks/useTrendingProducts.js.map +1 -1
- package/lib/features/shopping/savedProducts.js +76 -6
- package/lib/features/shopping/savedProducts.js.map +1 -1
- package/lib/features/shopping/services/aiRelevance.js +212 -0
- package/lib/features/shopping/services/aiRelevance.js.map +1 -0
- package/lib/features/shopping/services/blackFriday.js +301 -0
- package/lib/features/shopping/services/blackFriday.js.map +1 -0
- package/lib/features/shopping/services/blackFridayBrowserSites.js +137 -0
- package/lib/features/shopping/services/blackFridayBrowserSites.js.map +1 -0
- package/lib/features/shopping/services/catalogProductSearch.js +21 -3
- package/lib/features/shopping/services/catalogProductSearch.js.map +1 -1
- package/lib/features/shopping/services/holidayDeals.js +143 -0
- package/lib/features/shopping/services/holidayDeals.js.map +1 -0
- package/lib/features/shopping/services/mediaShape.js +7 -0
- package/lib/features/shopping/services/mediaShape.js.map +1 -0
- package/lib/features/shopping/services/modelStep.js +95 -0
- package/lib/features/shopping/services/modelStep.js.map +1 -0
- package/lib/features/shopping/services/modelWords.js +14 -0
- package/lib/features/shopping/services/modelWords.js.map +1 -0
- package/lib/features/shopping/services/productAvailability.js +5 -1
- package/lib/features/shopping/services/productAvailability.js.map +1 -1
- package/lib/features/shopping/services/productFilters.js +2 -2
- package/lib/features/shopping/services/productFilters.js.map +1 -1
- package/lib/features/shopping/services/productMedia.js +103 -18
- package/lib/features/shopping/services/productMedia.js.map +1 -1
- package/lib/features/shopping/services/retailerUrl.js +11 -8
- package/lib/features/shopping/services/retailerUrl.js.map +1 -1
- package/lib/features/shopping/services/salesDealsStore.js +3 -2
- package/lib/features/shopping/services/salesDealsStore.js.map +1 -1
- package/lib/features/shopping/services/savedReads.js +82 -0
- package/lib/features/shopping/services/savedReads.js.map +1 -0
- package/lib/features/shopping/services/searchCardFields.js +2 -0
- package/lib/features/shopping/services/searchCardFields.js.map +1 -1
- package/lib/features/shopping/services/searchRelevance.js +154 -24
- package/lib/features/shopping/services/searchRelevance.js.map +1 -1
- package/lib/features/shopping/services/secondHand.js +12 -0
- package/lib/features/shopping/services/secondHand.js.map +1 -0
- package/lib/features/shopping/services/shoppingProductSearch.js +82 -10
- package/lib/features/shopping/services/shoppingProductSearch.js.map +1 -1
- package/lib/features/shopping/services/shoppingSearchConnectorClient.js +14 -1
- package/lib/features/shopping/services/shoppingSearchConnectorClient.js.map +1 -1
- package/lib/features/shopping/services/shoppingSubgraph.js +2 -1
- package/lib/features/shopping/services/shoppingSubgraph.js.map +1 -1
- package/lib/features/shopping/services/storedGalleries.js +130 -0
- package/lib/features/shopping/services/storedGalleries.js.map +1 -0
- package/lib/features/shopping/services/usedSites.js +263 -0
- package/lib/features/shopping/services/usedSites.js.map +1 -0
- package/lib/features/shopping/services/verifyProducts.js +3 -3
- package/lib/features/shopping/services/verifyProducts.js.map +1 -1
- package/lib/features/shopping/services/watchDeal.js +61 -0
- package/lib/features/shopping/services/watchDeal.js.map +1 -0
- package/lib/features/shopping/shoppingRuntime.js +7 -2
- package/lib/features/shopping/shoppingRuntime.js.map +1 -1
- package/lib/features/shopping/state/accountCaches.js +20 -0
- package/lib/features/shopping/state/accountCaches.js.map +1 -0
- package/lib/features/shopping/state/holidayDealsRequest.js +22 -0
- package/lib/features/shopping/state/holidayDealsRequest.js.map +1 -0
- package/lib/features/shopping/tutorials/ShoppingTutorialDock.js +1 -1
- package/lib/features/shopping/tutorials/ShoppingTutorialDock.js.map +1 -1
- package/lib/features/shopping/tutorials/shoppingTutorials.js +2 -0
- package/lib/features/shopping/tutorials/shoppingTutorials.js.map +1 -1
- package/lib/features/shopping/useShoppingSearch.js +74 -18
- package/lib/features/shopping/useShoppingSearch.js.map +1 -1
- package/lib/features/team-chat/TeamChatExperience.js +474 -0
- package/lib/features/team-chat/TeamChatExperience.js.map +1 -0
- package/lib/features/team-chat/api/client.js +198 -0
- package/lib/features/team-chat/api/client.js.map +1 -0
- package/lib/features/team-chat/api/live.js +160 -0
- package/lib/features/team-chat/api/live.js.map +1 -0
- package/lib/features/team-chat/api/ops.js +241 -0
- package/lib/features/team-chat/api/ops.js.map +1 -0
- package/lib/features/team-chat/app.js +12 -0
- package/lib/features/team-chat/app.js.map +1 -0
- package/lib/features/team-chat/components/Avatar.js +107 -0
- package/lib/features/team-chat/components/Avatar.js.map +1 -0
- package/lib/features/team-chat/components/Composer.js +641 -0
- package/lib/features/team-chat/components/Composer.js.map +1 -0
- package/lib/features/team-chat/components/Dialogs.js +598 -0
- package/lib/features/team-chat/components/Dialogs.js.map +1 -0
- package/lib/features/team-chat/components/EmojiPicker.js +165 -0
- package/lib/features/team-chat/components/EmojiPicker.js.map +1 -0
- package/lib/features/team-chat/components/MessageItem.js +658 -0
- package/lib/features/team-chat/components/MessageItem.js.map +1 -0
- package/lib/features/team-chat/components/MessageList.js +248 -0
- package/lib/features/team-chat/components/MessageList.js.map +1 -0
- package/lib/features/team-chat/components/Mrkdwn.js +228 -0
- package/lib/features/team-chat/components/Mrkdwn.js.map +1 -0
- package/lib/features/team-chat/components/QuickSwitcher.js +215 -0
- package/lib/features/team-chat/components/QuickSwitcher.js.map +1 -0
- package/lib/features/team-chat/components/ui.js +662 -0
- package/lib/features/team-chat/components/ui.js.map +1 -0
- package/lib/features/team-chat/nativeTeamChatRegistry.js +15 -0
- package/lib/features/team-chat/nativeTeamChatRegistry.js.map +1 -0
- package/lib/features/team-chat/state/fetched.js +39 -0
- package/lib/features/team-chat/state/fetched.js.map +1 -0
- package/lib/features/team-chat/state/lists.js +230 -0
- package/lib/features/team-chat/state/lists.js.map +1 -0
- package/lib/features/team-chat/state/store.js +1108 -0
- package/lib/features/team-chat/state/store.js.map +1 -0
- package/lib/features/team-chat/state/useChannelDirectory.js +21 -0
- package/lib/features/team-chat/state/useChannelDirectory.js.map +1 -0
- package/lib/features/team-chat/theme.js +77 -0
- package/lib/features/team-chat/theme.js.map +1 -0
- package/lib/features/team-chat/utils/composeText.js +72 -0
- package/lib/features/team-chat/utils/composeText.js.map +1 -0
- package/lib/features/team-chat/utils/emoji.js +369 -0
- package/lib/features/team-chat/utils/emoji.js.map +1 -0
- package/lib/features/team-chat/utils/format.js +109 -0
- package/lib/features/team-chat/utils/format.js.map +1 -0
- package/lib/features/team-chat/utils/messageRows.js +24 -0
- package/lib/features/team-chat/utils/messageRows.js.map +1 -0
- package/lib/features/team-chat/utils/mrkdwn.js +222 -0
- package/lib/features/team-chat/utils/mrkdwn.js.map +1 -0
- package/lib/features/team-chat/utils/notify.js +47 -0
- package/lib/features/team-chat/utils/notify.js.map +1 -0
- package/lib/features/team-chat/utils/pickFiles.js +81 -0
- package/lib/features/team-chat/utils/pickFiles.js.map +1 -0
- package/lib/features/team-chat/views/ActivityView.js +235 -0
- package/lib/features/team-chat/views/ActivityView.js.map +1 -0
- package/lib/features/team-chat/views/BrowseView.js +179 -0
- package/lib/features/team-chat/views/BrowseView.js.map +1 -0
- package/lib/features/team-chat/views/ChannelView.js +475 -0
- package/lib/features/team-chat/views/ChannelView.js.map +1 -0
- package/lib/features/team-chat/views/DetailsPane.js +816 -0
- package/lib/features/team-chat/views/DetailsPane.js.map +1 -0
- package/lib/features/team-chat/views/DraftsView.js +212 -0
- package/lib/features/team-chat/views/DraftsView.js.map +1 -0
- package/lib/features/team-chat/views/FilesView.js +152 -0
- package/lib/features/team-chat/views/FilesView.js.map +1 -0
- package/lib/features/team-chat/views/NewMessageView.js +286 -0
- package/lib/features/team-chat/views/NewMessageView.js.map +1 -0
- package/lib/features/team-chat/views/PeopleView.js +118 -0
- package/lib/features/team-chat/views/PeopleView.js.map +1 -0
- package/lib/features/team-chat/views/ProfilePane.js +220 -0
- package/lib/features/team-chat/views/ProfilePane.js.map +1 -0
- package/lib/features/team-chat/views/SavedView.js +113 -0
- package/lib/features/team-chat/views/SavedView.js.map +1 -0
- package/lib/features/team-chat/views/SearchView.js +307 -0
- package/lib/features/team-chat/views/SearchView.js.map +1 -0
- package/lib/features/team-chat/views/Sidebar.js +368 -0
- package/lib/features/team-chat/views/Sidebar.js.map +1 -0
- package/lib/features/team-chat/views/ThreadPane.js +139 -0
- package/lib/features/team-chat/views/ThreadPane.js.map +1 -0
- package/lib/features/team-chat/views/ThreadsView.js +157 -0
- package/lib/features/team-chat/views/ThreadsView.js.map +1 -0
- package/lib/features/webbuilder/WebBuilderExperience.js +276 -42
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +10 -4
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/components/AssetChips.js +61 -0
- package/lib/features/webbuilder/components/AssetChips.js.map +1 -0
- package/lib/features/webbuilder/components/AssetSiteChooser.js +100 -0
- package/lib/features/webbuilder/components/AssetSiteChooser.js.map +1 -0
- package/lib/features/webbuilder/components/CommentsLayer.js +485 -0
- package/lib/features/webbuilder/components/CommentsLayer.js.map +1 -0
- package/lib/features/webbuilder/components/Composer.js +16 -2
- package/lib/features/webbuilder/components/Composer.js.map +1 -1
- package/lib/features/webbuilder/components/ComposerModeSwitch.js +71 -0
- package/lib/features/webbuilder/components/ComposerModeSwitch.js.map +1 -0
- package/lib/features/webbuilder/components/MyAssetsPicker.js +500 -0
- package/lib/features/webbuilder/components/MyAssetsPicker.js.map +1 -0
- package/lib/features/webbuilder/components/PlanDocument.js +165 -0
- package/lib/features/webbuilder/components/PlanDocument.js.map +1 -0
- package/lib/features/webbuilder/components/PlanDraftCard.js +205 -0
- package/lib/features/webbuilder/components/PlanDraftCard.js.map +1 -0
- package/lib/features/webbuilder/components/PlanView.js +788 -0
- package/lib/features/webbuilder/components/PlanView.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewConsoleSheet.js +334 -0
- package/lib/features/webbuilder/components/PreviewConsoleSheet.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewFrame.js +45 -3
- package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +94 -10
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +84 -14
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/StudioHome.js +69 -6
- package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
- package/lib/features/webbuilder/components/StyleDirectionsSheet.js +291 -0
- package/lib/features/webbuilder/components/StyleDirectionsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/VersionChangesView.js +574 -0
- package/lib/features/webbuilder/components/VersionChangesView.js.map +1 -0
- package/lib/features/webbuilder/components/VersionPreviewView.js +186 -0
- package/lib/features/webbuilder/components/VersionPreviewView.js.map +1 -0
- package/lib/features/webbuilder/components/VersionsSheet.js +673 -16
- package/lib/features/webbuilder/components/VersionsSheet.js.map +1 -1
- package/lib/features/webbuilder/connectorTemplates.js +6 -1
- package/lib/features/webbuilder/connectorTemplates.js.map +1 -1
- package/lib/features/webbuilder/myAssets.js +101 -0
- package/lib/features/webbuilder/myAssets.js.map +1 -0
- package/lib/features/webbuilder/planChat.js +146 -0
- package/lib/features/webbuilder/planChat.js.map +1 -0
- package/lib/features/webbuilder/planDocument.js +89 -0
- package/lib/features/webbuilder/planDocument.js.map +1 -0
- package/lib/features/webbuilder/planStore.js +55 -0
- package/lib/features/webbuilder/planStore.js.map +1 -0
- package/lib/features/webbuilder/previewCommentsScript.js +218 -0
- package/lib/features/webbuilder/previewCommentsScript.js.map +1 -0
- package/lib/features/webbuilder/previewConsoleScript.js +39 -0
- package/lib/features/webbuilder/previewConsoleScript.js.map +1 -0
- package/lib/features/webbuilder/styleDirections.js +85 -0
- package/lib/features/webbuilder/styleDirections.js.map +1 -0
- package/lib/features/webbuilder/useCanvasComments.js +335 -0
- package/lib/features/webbuilder/useCanvasComments.js.map +1 -0
- package/lib/features/webbuilder/useCatalogTemplates.js +37 -0
- package/lib/features/webbuilder/useCatalogTemplates.js.map +1 -0
- package/lib/features/webbuilder/usePlanMode.js +145 -0
- package/lib/features/webbuilder/usePlanMode.js.map +1 -0
- package/lib/features/webbuilder/useStyleDirections.js +112 -0
- package/lib/features/webbuilder/useStyleDirections.js.map +1 -0
- package/lib/features/webbuilder/web/assets/assetsApi.js +174 -0
- package/lib/features/webbuilder/web/assets/assetsApi.js.map +1 -0
- package/lib/features/webbuilder/web/assets/assetsApi.ts +173 -0
- package/lib/features/webbuilder/web/assets/myAssets.js +341 -0
- package/lib/features/webbuilder/web/assets/myAssets.js.map +1 -0
- package/lib/features/webbuilder/web/assets/myAssets.ts +396 -0
- package/lib/features/webbuilder/web/canvas/elementName.js +46 -0
- package/lib/features/webbuilder/web/canvas/elementName.js.map +1 -0
- package/lib/features/webbuilder/web/canvas/visualEditorBridge.js +95 -0
- package/lib/features/webbuilder/web/canvas/visualEditorBridge.js.map +1 -0
- package/lib/features/webbuilder/web/chat/agentTurn.js +24 -0
- package/lib/features/webbuilder/web/chat/agentTurn.js.map +1 -0
- package/lib/features/webbuilder/web/chat/planMode.js +164 -0
- package/lib/features/webbuilder/web/chat/planMode.js.map +1 -0
- package/lib/features/webbuilder/web/chat/realPlans.js +66 -0
- package/lib/features/webbuilder/web/chat/realPlans.js.map +1 -0
- package/lib/features/webbuilder/web/comments/comments.js +336 -0
- package/lib/features/webbuilder/web/comments/comments.js.map +1 -0
- package/lib/features/webbuilder/web/comments/commentsApi.js +59 -0
- package/lib/features/webbuilder/web/comments/commentsApi.js.map +1 -0
- package/lib/features/webbuilder/web/components/planView.js +21 -0
- package/lib/features/webbuilder/web/components/planView.js.map +1 -0
- package/lib/features/webbuilder/web/console/consolePanel.js +43 -0
- package/lib/features/webbuilder/web/console/consolePanel.js.map +1 -0
- package/lib/features/webbuilder/web/console/previewConsole.js +256 -0
- package/lib/features/webbuilder/web/console/previewConsole.js.map +1 -0
- package/lib/features/webbuilder/web/console/usePreviewConsole.js +147 -0
- package/lib/features/webbuilder/web/console/usePreviewConsole.js.map +1 -0
- package/lib/features/webbuilder/web/design/directions.js +419 -1
- package/lib/features/webbuilder/web/design/directions.js.map +1 -1
- package/lib/features/webbuilder/web/history/diffActions.js +222 -0
- package/lib/features/webbuilder/web/history/diffActions.js.map +1 -0
- package/lib/features/webbuilder/web/history/diffHighlight.js +18 -0
- package/lib/features/webbuilder/web/history/diffHighlight.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionActions.js +272 -0
- package/lib/features/webbuilder/web/history/versionActions.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionDiff.js +338 -0
- package/lib/features/webbuilder/web/history/versionDiff.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionPreview.js +83 -0
- package/lib/features/webbuilder/web/history/versionPreview.js.map +1 -0
- package/lib/features/webbuilder/web/history/versionPreviewMachine.js +150 -0
- package/lib/features/webbuilder/web/history/versionPreviewMachine.js.map +1 -0
- package/lib/features/webbuilder/web/history/versions.js +326 -1
- package/lib/features/webbuilder/web/history/versions.js.map +1 -1
- package/lib/features/webbuilder/web/hosted/hostedTurn.js +36 -0
- package/lib/features/webbuilder/web/hosted/hostedTurn.js.map +1 -0
- package/lib/features/webbuilder/web/studio/brandKit.js +25 -0
- package/lib/features/webbuilder/web/studio/brandKit.js.map +1 -0
- package/lib/features/webbuilder/web/utils/promptSafe.js +15 -0
- package/lib/features/webbuilder/web/utils/promptSafe.js.map +1 -0
- package/lib/features/webbuilder/web/webServices.js +3 -1
- package/lib/features/webbuilder/web/webServices.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/routes.json +55 -0
- package/lib/screens/Account/index.js +13 -5
- package/lib/screens/Account/index.js.map +1 -1
- package/lib/screens/Chat/index.js +16 -0
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +202 -39
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/HomeHero.js +52 -38
- package/lib/screens/Home/components/HomeHero.js.map +1 -1
- package/lib/screens/Home/components/homeCatalog.js +8 -1
- package/lib/screens/Home/components/homeCatalog.js.map +1 -1
- package/lib/screens/TeamChat/index.js +41 -0
- package/lib/screens/TeamChat/index.js.map +1 -0
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js +9 -2
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js.map +1 -1
- package/lib/screens/WebBuilderNative/index.js +13 -3
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/useConnectorTemplates.js +2 -2
- package/lib/screens/WebBuilderNative/useConnectorTemplates.js.map +1 -1
- package/package.json +3 -3
|
@@ -47,14 +47,14 @@ function ratingNumber(rating) {
|
|
|
47
47
|
return Number.isFinite(value) ? Math.min(5, Math.max(0, value)) : 0;
|
|
48
48
|
}
|
|
49
49
|
function catalogCardToProduct(card, departmentId, index) {
|
|
50
|
-
var _a;
|
|
50
|
+
var _a, _b;
|
|
51
51
|
const name = (card.title || card.name || "").trim();
|
|
52
52
|
if (!name) return null;
|
|
53
53
|
const dept = departmentBadge(departmentId);
|
|
54
54
|
const retailerId = (card.retailer || "").trim();
|
|
55
55
|
const key = card.sku || card.id || `${index}`;
|
|
56
56
|
const url = sanitizeRetailerUrl((_a = card.url) == null ? void 0 : _a.trim());
|
|
57
|
-
return reconcilePricing(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues({
|
|
57
|
+
return reconcilePricing(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues({
|
|
58
58
|
id: `cat-${retailerId || "x"}-${key}`,
|
|
59
59
|
name,
|
|
60
60
|
departmentId: dept.id,
|
|
@@ -79,6 +79,8 @@ function catalogCardToProduct(card, departmentId, index) {
|
|
|
79
79
|
inStock: card.inStock
|
|
80
80
|
} : {}), card.brand ? {
|
|
81
81
|
brand: card.brand
|
|
82
|
+
} : {}), ((_b = card.category) == null ? void 0 : _b.trim()) ? {
|
|
83
|
+
storeCategory: card.category.trim()
|
|
82
84
|
} : {}), retailerId ? {
|
|
83
85
|
retailerId
|
|
84
86
|
} : {}), card.sku ? {
|
|
@@ -356,6 +358,7 @@ async function fetchPriceHistory(params) {
|
|
|
356
358
|
} : {});
|
|
357
359
|
}
|
|
358
360
|
async function addPriceWatch(params) {
|
|
361
|
+
var _a;
|
|
359
362
|
const result = await invokeShoppingSearchConnector(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
360
363
|
retailer: params.retailer,
|
|
361
364
|
productId: params.productId
|
|
@@ -371,6 +374,21 @@ async function addPriceWatch(params) {
|
|
|
371
374
|
currency: params.currency
|
|
372
375
|
} : {}), SHOPPING_SEARCH_ACTIONS.WATCH_ADD);
|
|
373
376
|
if (!result.success) throw new Error(result.error || "Could not add the price watch");
|
|
377
|
+
const alerts = (_a = result.data) == null ? void 0 : _a.alerts;
|
|
378
|
+
return alerts && typeof alerts.armed === "boolean" ? {
|
|
379
|
+
alerts: __spreadValues({
|
|
380
|
+
armed: alerts.armed
|
|
381
|
+
}, alerts.error ? {
|
|
382
|
+
error: String(alerts.error)
|
|
383
|
+
} : {})
|
|
384
|
+
} : {};
|
|
385
|
+
}
|
|
386
|
+
async function removePriceWatch(params) {
|
|
387
|
+
const result = await invokeShoppingSearchConnector({
|
|
388
|
+
retailer: params.retailer,
|
|
389
|
+
productId: params.productId
|
|
390
|
+
}, SHOPPING_SEARCH_ACTIONS.WATCH_REMOVE);
|
|
391
|
+
if (!result.success) throw new Error(result.error || "Could not stop watching this product");
|
|
374
392
|
}
|
|
375
393
|
async function fetchWatchStatus() {
|
|
376
394
|
var _a, _b, _c;
|
|
@@ -408,4 +426,4 @@ async function fetchWatchStatus() {
|
|
|
408
426
|
}, ((_c = result.data) == null ? void 0 : _c.hint) ? {
|
|
409
427
|
hint: result.data.hint
|
|
410
428
|
} : {});
|
|
411
|
-
}export{DEFAULT_CATALOG_RETAILERS,DEPARTMENT_CATALOG_RETAILERS,addPriceWatch,catalogCardToProduct,catalogRetailersFor,compareRetailers,fetchPriceHistory,fetchWatchStatus,isCatalogConfigured,searchCatalogDeals,searchCatalogDealsByQuery,searchCatalogProducts};//# sourceMappingURL=catalogProductSearch.js.map
|
|
429
|
+
}export{DEFAULT_CATALOG_RETAILERS,DEPARTMENT_CATALOG_RETAILERS,addPriceWatch,catalogCardToProduct,catalogRetailersFor,compareRetailers,fetchPriceHistory,fetchWatchStatus,isCatalogConfigured,removePriceWatch,searchCatalogDeals,searchCatalogDealsByQuery,searchCatalogProducts};//# sourceMappingURL=catalogProductSearch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogProductSearch.js","sources":["../../../../src/features/shopping/services/catalogProductSearch.ts"],"sourcesContent":["/**\n * The typed-catalog source: LemmeBuyIt through the connector's `lemmebuyit`\n * provider.\n *\n * Every other source on this page is a SERP read - Parallel AI renders a\n * retailer's search-results page and the connector regexes titles, prices and\n * images out of the excerpt text. That is why `Product.price` is so often 0 and\n * why \"who else sells this\" was not a question the page could ask: a rendered\n * page contains neither a reliable price nor a product identifier.\n *\n * This source returns typed rows instead, which unlocks three things the page now\n * shows: the real discount (original price + percent), cross-retailer compare by\n * shared identifier, and a weekly price series.\n *\n * All of it needs a LemmeBuyIt API key. When one is absent the calls fail fast\n * with the connector's own actionable message rather than returning an empty list\n * that would read as \"nothing found\".\n */\nimport { departmentBadge, type Product } from '../catalog';\nimport { getShoppingRuntime } from '../shoppingRuntime';\nimport { reconcilePricing } from './pricing';\nimport { sanitizeRetailerUrl } from './retailerUrl';\nimport {\n invokeShoppingSearchConnector,\n isConnectorLaneAbort,\n SHOPPING_SEARCH_ACTIONS,\n resolveShoppingSearchConnectorCredentials,\n type ConnectorLaneOptions,\n} from './shoppingSearchConnectorClient';\n\n/**\n * Retailers the catalog sweeps when no department is selected.\n *\n * LemmeBuyIt exposes 97 retailers / ~281M products; this page previously asked two\n * of them. The cap is not the API, it is time: the endpoint is retailer-scoped and\n * the free plan allows one concurrent MCP session, so breadth costs roughly a\n * second per retailer. Six is about the most that stays interactive while still\n * making \"who has it cheapest\" a real answer rather than a two-horse race.\n */\nexport const DEFAULT_CATALOG_RETAILERS = ['walmart', 'target', 'best_buy', 'kohls', 'macys', 'woot'];\n\n/**\n * Per-department retailers, so a department chip asks shops that actually stock\n * that department. Ids verified against list_retailers.\n */\nexport const DEPARTMENT_CATALOG_RETAILERS: Record<string, string[]> = {\n 'high-tech': ['best_buy', 'walmart', 'target', 'woot', 'samsung', 'dell'],\n sports: ['dicks_sporting_goods', 'scheels', 'cabelas', 'nike', 'walmart', 'bass_pro_shop'],\n beauty: ['ulta', 'sephora', 'walgreens', 'macys', 'walmart', 'mac_cosmetics'],\n 'home-garden': ['homedepot', 'lowes', 'wayfair', 'ace_hardware', 'walmart', 'ashley_homestore'],\n office: ['walmart', 'target', 'best_buy', 'woot', 'barnes_and_noble', 'qvc'],\n toys: ['walmart', 'target', 'lego', 'disney_store', 'american_girl', 'barnes_and_noble'],\n fashion: ['kohls', 'macys', 'nike', 'target', 'walmart', 'nordstrom'],\n grocery: ['walmart', 'target', 'walgreens', 'kroger', 'costco', 'sams_club'],\n auto: ['walmart', 'autozone', 'advance_auto_parts', 'homedepot', 'lowes', 'harbor_freight'],\n pets: ['chewy', 'petco', 'petsmart', 'walmart', 'target', 'tractor_supply'],\n};\n\n/** The retailer set for a department, falling back to the general default. */\nexport function catalogRetailersFor(departmentId?: string): string[] {\n return (departmentId && DEPARTMENT_CATALOG_RETAILERS[departmentId]) || DEFAULT_CATALOG_RETAILERS;\n}\n\n/** One row as the connector's `toCard` mapper emits it. */\nexport interface CatalogCard {\n id?: string;\n name?: string;\n title?: string;\n price?: number;\n priceText?: string;\n originalPrice?: number;\n discountPercent?: number;\n currency?: string;\n retailer?: string;\n url?: string;\n imageUrl?: string;\n rating?: string | number;\n reviewCount?: number;\n brand?: string;\n category?: string;\n inStock?: boolean;\n upc?: string;\n ean?: string;\n gtin?: string;\n mpn?: string;\n asin?: string;\n sku?: string;\n}\n\nexport interface CatalogSearchPayload {\n success?: boolean;\n query?: string;\n retailer?: string;\n /** Which path produced the rows; `*-sweep` means every retailer was covered. */\n source?: string;\n affiliateDisclosure?: string;\n products?: CatalogCard[];\n totalCount?: number;\n totalHits?: number;\n nextCursor?: string;\n error?: string;\n}\n\n/** `deals` rows come straight from SQL over the indexed store, in snake_case. */\ninterface DealRow {\n retailer_id?: string;\n product_id?: string;\n product_name?: string;\n brand?: string;\n current_price?: number;\n original_price?: number;\n discount_percentage?: number;\n rating?: number;\n in_stock?: boolean;\n product_url?: string;\n}\n\ninterface DealsPayload {\n success?: boolean;\n count?: number;\n deals?: DealRow[];\n /** Set when the result is empty, distinguishing \"no match\" from \"not indexed\". */\n hint?: string;\n}\n\nexport interface CompareRow {\n retailerId: string;\n productId: string;\n productName?: string;\n currentPrice?: number;\n inStock?: boolean;\n deltaToCheapest?: number;\n productUrl?: string;\n}\n\nexport interface CompareResult {\n identifier: string;\n lookupType: string;\n count: number;\n cheapest?: number;\n rows: CompareRow[];\n hint?: string;\n}\n\nexport interface PricePoint {\n ts: string;\n price: number;\n}\n\nexport interface PriceHistory {\n points: PricePoint[];\n /** Why the series is empty when it is (a plan gate, an unindexed product) - in the connector's words. */\n hint?: string;\n /** The provider's plan does not include the series. Not an error. */\n planGated?: boolean;\n}\n\nexport interface WatchRow {\n retailerId: string;\n productId: string;\n /** Listing snapshot kept with the pin, so the row renders without a catalog round-trip. */\n name?: string;\n url?: string;\n currentPrice?: number;\n previousPrice?: number;\n delta?: number;\n targetPrice?: number;\n hitTarget?: boolean;\n /** Where currentPrice came from: this pod's index, a live catalog lookup, or the price at pin time. */\n priceSource?: 'indexed' | 'live' | 'pinned';\n addedAt?: string;\n}\n\n/**\n * True when the catalog-backed views should be shown.\n *\n * Prefers the host's explicit `catalogEnabled` flag and falls back to \"the host\n * gave us a key\". The fallback keeps every existing host working unchanged; the\n * flag exists because a host can be perfectly able to use the provider while\n * holding no key itself - the connector resolves the credential backend-side.\n */\nexport function isCatalogConfigured(): boolean {\n const runtime = getShoppingRuntime().config.shoppingSearch;\n if (typeof runtime?.catalogEnabled === 'boolean') return runtime.catalogEnabled;\n return !!resolveShoppingSearchConnectorCredentials().lemmebuyitApiKey;\n}\n\n/**\n * Placeholder for a catalog row with no image.\n *\n * `Product.icon`/`accent` are a department's, and ProductImage falls back to them\n * when there is no thumbnail. A catalog row does not come from a department\n * search, so it would inherit DEPARTMENTS[0] (\"High-Tech\") and put a laptop emoji\n * on a coffee grinder. A neutral bag says \"no picture\" instead of asserting a\n * category the row never claimed.\n */\nconst CATALOG_PLACEHOLDER = { icon: '\\u{1F6CD}', accent: '#94a3b8' };\n\nfunction ratingNumber(rating: string | number | undefined): number {\n const value = typeof rating === 'number' ? rating : Number.parseFloat(String(rating ?? ''));\n return Number.isFinite(value) ? Math.min(5, Math.max(0, value)) : 0;\n}\n\n/**\n * One connector catalog row as a storefront {@link Product}.\n *\n * Exported because the catalog sweep is no longer its only caller - the\n * better-price lookup (`betterPrice.ts`) runs its own identifier / price-sorted\n * queries against the same action and must map the rows identically, or a row\n * would carry a different id and price shape depending on which question asked\n * for it.\n */\nexport function catalogCardToProduct(\n card: CatalogCard,\n departmentId: string | undefined,\n index: number,\n): Product | null {\n const name = (card.title || card.name || '').trim();\n if (!name) return null;\n const dept = departmentBadge(departmentId);\n const retailerId = (card.retailer || '').trim();\n const key = card.sku || card.id || `${index}`;\n // Catalog rows arrive as affiliate links (Impact `goto.*` redirects, tracking\n // params) that often 404 or come back malformed. Repair them to the canonical\n // retailer product URL so the card actually opens the right page.\n const url = sanitizeRetailerUrl(card.url?.trim());\n\n // The index states a list price and a percent separately; make them agree\n // (and drop a percent nothing backs) before the discount badge reads them.\n return reconcilePricing<Product>({\n id: `cat-${retailerId || 'x'}-${key}`,\n name,\n departmentId: dept.id,\n price: typeof card.price === 'number' && Number.isFinite(card.price) ? card.price : 0,\n rating: ratingNumber(card.rating),\n reviews: typeof card.reviewCount === 'number' ? card.reviewCount : 0,\n icon: CATALOG_PLACEHOLDER.icon,\n accent: CATALOG_PLACEHOLDER.accent,\n ...(card.imageUrl ? { imageUrl: card.imageUrl } : {}),\n ...(url ? { url } : {}),\n source: 'catalog',\n ...(typeof card.originalPrice === 'number' ? { originalPrice: card.originalPrice } : {}),\n ...(typeof card.discountPercent === 'number' ? { discountPercent: card.discountPercent } : {}),\n ...(card.currency ? { currency: card.currency } : {}),\n ...(typeof card.inStock === 'boolean' ? { inStock: card.inStock } : {}),\n ...(card.brand ? { brand: card.brand } : {}),\n ...(retailerId ? { retailerId } : {}),\n ...(card.sku ? { sku: card.sku } : {}),\n ...(card.upc ? { upc: card.upc } : {}),\n ...(card.ean ? { ean: card.ean } : {}),\n ...(card.gtin ? { gtin: card.gtin } : {}),\n ...(card.mpn ? { mpn: card.mpn } : {}),\n ...(card.asin ? { asin: card.asin } : {}),\n });\n}\n\nexport interface CatalogSearchParams {\n query: string;\n departmentId?: string;\n category?: string;\n budget?: number | string;\n maxResults?: number;\n /** Retailers to fan out across. Defaults to {@link DEFAULT_CATALOG_RETAILERS}. */\n retailers?: string[];\n inStockOnly?: boolean;\n /** Priority and cancellation in the one-at-a-time LemmeBuyIt lane. */\n lane?: ConnectorLaneOptions;\n}\n\n/**\n * Searches the catalog across retailers and merges the rows.\n *\n * The endpoint is retailer-scoped, so N retailers is N calls - run SEQUENTIALLY,\n * not in parallel. On a non-Enterprise LemmeBuyIt plan the connector reaches the\n * catalog over MCP, which allows exactly ONE concurrent session per key: two\n * overlapping retailer calls are two connector invocations, two sessions, and the\n * second gets `429 Concurrent session limit reached`. Sequential costs latency and\n * buys correctness.\n *\n * One retailer failing stays non-fatal - better Walmart's rows than nothing\n * because Target timed out. Every retailer failing rethrows the first error, so a\n * missing key still surfaces instead of looking like an empty catalog.\n */\nexport async function searchCatalogProducts(params: CatalogSearchParams): Promise<{\n products: Product[];\n query: string;\n totalCount: number;\n /** Set when rows came from the free tier, whose product links are affiliate URLs. */\n affiliateDisclosure?: string;\n error?: string;\n}> {\n const query = params.query.trim();\n if (!query) throw new Error('Catalog search requires a query');\n\n const retailers = params.retailers?.length ? params.retailers : catalogRetailersFor(params.departmentId);\n const budget = typeof params.budget === 'string' ? Number.parseFloat(params.budget) : params.budget;\n\n // ONE call sweeping every retailer, not one call per retailer. The connector\n // walks them inside a single MCP session, which is both far faster and the only\n // shape that respects the one-session-per-key limit.\n const [primary, ...rest] = retailers;\n // A cancelled call is not a failed one: it rethrows as the abort it is, so a\n // rail the shopper scrolled away from never reports \"catalog search failed\".\n const failedUnlessAborted = (reason: unknown) => {\n if (isConnectorLaneAbort(reason)) throw reason;\n return { success: false as const, error: String(reason) };\n };\n const outcome = await invokeShoppingSearchConnector<CatalogSearchPayload>(\n {\n retailer: primary,\n ...(rest.length ? { retailers: rest } : {}),\n query,\n limit: params.maxResults ?? 24,\n sortBy: 'relevance',\n ...(Number.isFinite(budget) && (budget as number) > 0 ? { maxPrice: budget } : {}),\n ...(params.inStockOnly ? { inStock: true } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.CATALOG_SEARCH,\n params.lane,\n ).catch(failedUnlessAborted);\n\n const deptId = params.departmentId;\n const products: Product[] = [];\n const failures: string[] = [];\n let affiliateDisclosure: string | undefined;\n\n if (!outcome.success) {\n // Nothing came back at all - surface the reason rather than an empty grid,\n // so a missing key never reads as \"this product does not exist\".\n throw new Error(outcome.error || 'Catalog search failed');\n }\n\n const payload = 'data' in outcome ? outcome.data : undefined;\n affiliateDisclosure = payload?.affiliateDisclosure;\n for (const card of payload?.products ?? []) {\n const product = catalogCardToProduct(card, deptId, products.length);\n if (product) products.push(product);\n }\n if (payload?.error) failures.push(payload.error);\n\n // Compatibility with a connector that predates the multi-retailer sweep: it\n // ignores `retailers` and answers for the primary one only, which would\n // silently narrow the page from six shops to one. Detect it by the source tag\n // and ask the rest one retailer at a time.\n //\n // All of them are queued at ONCE. The lane already runs one call at a time\n // (the MCP plan allows a single concurrent session), so awaiting each before\n // queueing the next bought no safety - it only left a gap after every call\n // for other queued work to take the lane, which is how a search ended up\n // interleaved one call apiece with the landing page's rails.\n const sweptAll = (payload?.source ?? '').includes('sweep');\n if (!sweptAll && rest.length) {\n const walked = await Promise.all(\n rest.map((extra) =>\n invokeShoppingSearchConnector<CatalogSearchPayload>(\n {\n retailer: extra,\n query,\n limit: Math.max(4, Math.ceil((params.maxResults ?? 24) / retailers.length)),\n sortBy: 'relevance',\n ...(Number.isFinite(budget) && (budget as number) > 0 ? { maxPrice: budget } : {}),\n ...(params.inStockOnly ? { inStock: true } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.CATALOG_SEARCH,\n params.lane,\n ).catch(failedUnlessAborted),\n ),\n );\n for (const more of walked) {\n if (!more.success) continue;\n const extraPayload = 'data' in more ? more.data : undefined;\n for (const card of extraPayload?.products ?? []) {\n const product = catalogCardToProduct(card, deptId, products.length);\n if (product) products.push(product);\n }\n }\n }\n\n // The connector already merges cheapest-first across the sweep; re-sort because\n // toProduct can drop rows and the surface owns the final order either way.\n products.sort((a, b) => (a.price || Number.MAX_SAFE_INTEGER) - (b.price || Number.MAX_SAFE_INTEGER));\n\n return {\n products,\n query,\n totalCount: products.length,\n ...(affiliateDisclosure ? { affiliateDisclosure } : {}),\n ...(failures.length ? { error: failures.join(' · ') } : {}),\n };\n}\n\nexport interface DealsQuery {\n minDiscount?: number;\n maxPrice?: number;\n minRating?: number;\n minReviews?: number;\n inStock?: boolean;\n category?: string;\n retailers?: string[];\n sort?: 'discount' | 'price';\n limit?: number;\n}\n\n/** Compound deal finder over the indexed store. */\nexport async function searchCatalogDeals(query: DealsQuery): Promise<{\n products: Product[];\n hint?: string;\n}> {\n const result = await invokeShoppingSearchConnector<DealsPayload>(\n {\n ...(query.minDiscount !== undefined ? { minDiscount: query.minDiscount } : {}),\n ...(query.maxPrice !== undefined ? { maxPrice: query.maxPrice } : {}),\n ...(query.minRating !== undefined ? { minRating: query.minRating } : {}),\n ...(query.minReviews !== undefined ? { minReviews: query.minReviews } : {}),\n ...(query.inStock ? { inStock: true } : {}),\n ...(query.category ? { category: query.category } : {}),\n ...(query.retailers?.length ? { retailers: query.retailers } : {}),\n sort: query.sort ?? 'discount',\n limit: query.limit ?? 24,\n },\n SHOPPING_SEARCH_ACTIONS.DEALS,\n );\n\n if (!result.success) throw new Error(result.error || 'Deal search failed');\n\n const dept = departmentBadge();\n const products = (result.data?.deals ?? [])\n .map((row, index): Product | null => {\n const name = (row.product_name || '').trim();\n if (!name) return null;\n const url = sanitizeRetailerUrl(row.product_url?.trim());\n return reconcilePricing<Product>({\n id: `deal-${row.retailer_id ?? 'x'}-${row.product_id ?? index}`,\n name,\n departmentId: dept.id,\n price: typeof row.current_price === 'number' ? row.current_price : 0,\n rating: typeof row.rating === 'number' ? Math.min(5, Math.max(0, row.rating)) : 0,\n reviews: 0,\n icon: CATALOG_PLACEHOLDER.icon,\n accent: CATALOG_PLACEHOLDER.accent,\n ...(url ? { url } : {}),\n source: 'catalog',\n ...(typeof row.original_price === 'number' ? { originalPrice: row.original_price } : {}),\n ...(typeof row.discount_percentage === 'number' ? { discountPercent: row.discount_percentage } : {}),\n ...(typeof row.in_stock === 'boolean' ? { inStock: row.in_stock } : {}),\n ...(row.brand ? { brand: row.brand } : {}),\n ...(row.retailer_id ? { retailerId: row.retailer_id } : {}),\n ...(row.product_id ? { sku: row.product_id } : {}),\n });\n })\n .filter((p): p is Product => p !== null);\n\n return { products, ...(result.data?.hint ? { hint: result.data.hint } : {}) };\n}\n\n/**\n * Deals for a SEARCH TERM, rather than the whole indexed store.\n *\n * {@link searchCatalogDeals} above ranks everything indexed, which is the right\n * answer to \"what is worth buying right now\" and the wrong one to \"deals on\n * headphones\" — it has no query parameter at all. `CATALOG_SEARCH` does, and it\n * also carries every bar the Deals view sets, so one call answers both halves.\n *\n * `full: true` is REQUIRED, not incidental: the connector gates\n * `minDiscountPercent` / `onSale` / `minRating` / `minReviews` behind it, and\n * without the flag those filters are silently ignored — you get a plain relevance\n * search wearing a deals label.\n */\nexport async function searchCatalogDealsByQuery(params: {\n query: string;\n minDiscount?: number;\n maxPrice?: number;\n minRating?: number;\n minReviews?: number;\n inStock?: boolean;\n sort?: 'discount' | 'price';\n limit?: number;\n retailers?: string[];\n departmentId?: string | null;\n}): Promise<{ products: Product[]; error?: string }> {\n const query = params.query.trim();\n if (!query) return { products: [] };\n\n const departmentId = params.departmentId ?? undefined;\n const retailers = params.retailers?.length ? params.retailers : catalogRetailersFor(departmentId);\n const [primary, ...rest] = retailers;\n\n const outcome = await invokeShoppingSearchConnector<CatalogSearchPayload>(\n {\n retailer: primary,\n ...(rest.length ? { retailers: rest } : {}),\n query,\n full: true,\n onSale: true,\n sortBy: params.sort === 'price' ? 'price_asc' : 'discount_desc',\n limit: params.limit ?? 24,\n ...(params.minDiscount ? { minDiscountPercent: params.minDiscount } : {}),\n ...(params.maxPrice ? { maxPrice: params.maxPrice } : {}),\n ...(params.minRating ? { minRating: params.minRating } : {}),\n ...(params.minReviews ? { minReviews: params.minReviews } : {}),\n ...(params.inStock ? { inStock: true } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.CATALOG_SEARCH,\n ).catch((reason: unknown) => ({ success: false as const, error: String(reason) }));\n\n if (!outcome.success) return { products: [], error: outcome.error || 'Catalog deal search failed' };\n\n const payload = 'data' in outcome ? outcome.data : undefined;\n const products: Product[] = [];\n for (const card of payload?.products ?? []) {\n const product = catalogCardToProduct(card, departmentId, products.length);\n if (product) products.push(product);\n }\n return { products, ...(payload?.error ? { error: payload.error } : {}) };\n}\n\n/** Cheapest indexed retailer for one shared identifier. */\nexport async function compareRetailers(params: {\n identifier: string;\n lookupType: string;\n inStockOnly?: boolean;\n}): Promise<CompareResult> {\n const result = await invokeShoppingSearchConnector<{\n identifier?: string;\n lookupType?: string;\n count?: number;\n cheapest?: number | null;\n results?: Array<Record<string, unknown>>;\n hint?: string;\n }>(\n {\n identifier: params.identifier,\n lookupType: params.lookupType,\n ...(params.inStockOnly ? { inStock: true } : {}),\n limit: 25,\n },\n SHOPPING_SEARCH_ACTIONS.COMPARE,\n );\n\n if (!result.success) throw new Error(result.error || 'Compare failed');\n const data = result.data ?? {};\n\n return {\n identifier: data.identifier ?? params.identifier,\n lookupType: data.lookupType ?? params.lookupType,\n count: data.count ?? 0,\n ...(typeof data.cheapest === 'number' ? { cheapest: data.cheapest } : {}),\n rows: (data.results ?? []).map((row) => ({\n retailerId: String(row.retailer_id ?? ''),\n productId: String(row.product_id ?? ''),\n ...(row.product_name ? { productName: String(row.product_name) } : {}),\n ...(typeof row.current_price === 'number' ? { currentPrice: row.current_price } : {}),\n ...(typeof row.in_stock === 'boolean' ? { inStock: row.in_stock } : {}),\n ...(typeof row.delta_to_cheapest === 'number' ? { deltaToCheapest: row.delta_to_cheapest } : {}),\n ...(() => {\n const url = row.product_url ? sanitizeRetailerUrl(String(row.product_url).trim()) : undefined;\n return url ? { productUrl: url } : {};\n })(),\n })),\n ...(data.hint ? { hint: data.hint } : {}),\n };\n}\n\n/**\n * Weekly price series for one product.\n *\n * The series carries several price columns (buy box, third-party new, retail, and\n * a Walmart column); the chart wants one line, so pick the first populated column\n * per point in that order of preference.\n */\nexport async function fetchPriceHistory(params: {\n retailer: string;\n productId: string;\n weeks?: number;\n}): Promise<PriceHistory> {\n const result = await invokeShoppingSearchConnector<{\n series?: { series?: Array<Record<string, unknown>> } | Array<Record<string, unknown>>;\n hint?: string;\n planGated?: boolean;\n }>(\n { retailer: params.retailer, productId: params.productId, weeks: params.weeks ?? 26 },\n SHOPPING_SEARCH_ACTIONS.PRICE_HISTORY,\n );\n if (!result.success) throw new Error(result.error || 'Price history failed');\n\n const raw = result.data?.series;\n const rows = Array.isArray(raw) ? raw : (raw?.series ?? []);\n const PRICE_KEYS = ['amz_buy_box', 'amz_3p_new', 'amz_retail', 'walmart_price', 'price'];\n\n const points = rows\n .map((point): PricePoint | null => {\n const ts = String(point.ts ?? '');\n if (!ts) return null;\n for (const key of PRICE_KEYS) {\n const value = point[key];\n if (typeof value === 'number' && Number.isFinite(value) && value > 0) return { ts, price: value };\n }\n return null;\n })\n .filter((p): p is PricePoint => p !== null);\n\n return {\n points,\n ...(result.data?.hint ? { hint: result.data.hint } : {}),\n ...(result.data?.planGated ? { planGated: true } : {}),\n };\n}\n\n/**\n * Pin a product to the caller's watchlist (shared across agent pods). The listing\n * snapshot travels with the pin so the Watchlist can name and link the row - and\n * show a price - before any catalog index has run.\n */\nexport async function addPriceWatch(params: {\n retailer: string;\n productId: string;\n targetPrice?: number;\n name?: string;\n url?: string;\n price?: number;\n currency?: string;\n}): Promise<void> {\n const result = await invokeShoppingSearchConnector<{ success?: boolean }>(\n {\n retailer: params.retailer,\n productId: params.productId,\n ...(params.targetPrice !== undefined ? { targetPrice: params.targetPrice } : {}),\n ...(params.name ? { name: params.name } : {}),\n ...(params.url ? { url: params.url } : {}),\n ...(params.price !== undefined && params.price > 0 ? { price: params.price } : {}),\n ...(params.currency ? { currency: params.currency } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.WATCH_ADD,\n );\n if (!result.success) throw new Error(result.error || 'Could not add the price watch');\n}\n\n/** Every watched product's movement since the last index refresh. */\nexport async function fetchWatchStatus(): Promise<{ rows: WatchRow[]; hint?: string }> {\n const result = await invokeShoppingSearchConnector<{\n watched?: Array<Record<string, unknown>>;\n hint?: string;\n }>({}, SHOPPING_SEARCH_ACTIONS.WATCH_STATUS);\n if (!result.success) throw new Error(result.error || 'Could not read the watchlist');\n\n return {\n rows: (result.data?.watched ?? []).map((row) => ({\n retailerId: String(row.retailer_id ?? ''),\n productId: String(row.product_id ?? ''),\n ...(typeof row.product_name === 'string' && row.product_name ? { name: row.product_name } : {}),\n ...(() => {\n const url = row.product_url ? sanitizeRetailerUrl(String(row.product_url).trim()) : undefined;\n return url ? { url } : {};\n })(),\n ...(row.price_source === 'indexed' || row.price_source === 'live' || row.price_source === 'pinned'\n ? { priceSource: row.price_source }\n : {}),\n ...(typeof row.added_at === 'string' ? { addedAt: row.added_at } : {}),\n ...(typeof row.current_price === 'number' ? { currentPrice: row.current_price } : {}),\n ...(typeof row.previous_price === 'number' ? { previousPrice: row.previous_price } : {}),\n ...(typeof row.delta === 'number' ? { delta: row.delta } : {}),\n ...(typeof row.target_price === 'number' ? { targetPrice: row.target_price } : {}),\n ...(typeof row.hit_target === 'boolean' ? { hitTarget: row.hit_target } : {}),\n })),\n ...(result.data?.hint ? { hint: result.data.hint } : {}),\n };\n}\n"],"names":["_a","_b","_c"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCO,MAAM,4BAA4B,CAAC,SAAA,EAAW,UAAU,UAAY,EAAA,OAAA,EAAS,SAAS,MAAM;AAM5F,MAAM,4BAAyD,GAAA;AAAA,EACpE,aAAa,CAAC,UAAA,EAAY,WAAW,QAAU,EAAA,MAAA,EAAQ,WAAW,MAAM,CAAA;AAAA,EACxE,QAAQ,CAAC,sBAAA,EAAwB,WAAW,SAAW,EAAA,MAAA,EAAQ,WAAW,eAAe,CAAA;AAAA,EACzF,QAAQ,CAAC,MAAA,EAAQ,WAAW,WAAa,EAAA,OAAA,EAAS,WAAW,eAAe,CAAA;AAAA,EAC5E,eAAe,CAAC,WAAA,EAAa,SAAS,SAAW,EAAA,cAAA,EAAgB,WAAW,kBAAkB,CAAA;AAAA,EAC9F,QAAQ,CAAC,SAAA,EAAW,UAAU,UAAY,EAAA,MAAA,EAAQ,oBAAoB,KAAK,CAAA;AAAA,EAC3E,MAAM,CAAC,SAAA,EAAW,UAAU,MAAQ,EAAA,cAAA,EAAgB,iBAAiB,kBAAkB,CAAA;AAAA,EACvF,SAAS,CAAC,OAAA,EAAS,SAAS,MAAQ,EAAA,QAAA,EAAU,WAAW,WAAW,CAAA;AAAA,EACpE,SAAS,CAAC,SAAA,EAAW,UAAU,WAAa,EAAA,QAAA,EAAU,UAAU,WAAW,CAAA;AAAA,EAC3E,MAAM,CAAC,SAAA,EAAW,YAAY,oBAAsB,EAAA,WAAA,EAAa,SAAS,gBAAgB,CAAA;AAAA,EAC1F,MAAM,CAAC,OAAA,EAAS,SAAS,UAAY,EAAA,SAAA,EAAW,UAAU,gBAAgB;AAC5E;AAGO,SAAS,oBA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,GAAc,mBAAoB,CAAA,MAAA,CAAO,IAAI,WAAW,CAAA,CAAE,IAAK,EAAC,CAAI,GAAA,MAAA;AACpF,QAAA,OAAO,GAAM,GAAA;AAAA,UACX;AAAA,YACE,EAAC;AAAA,OACP,GACI,CAAA,EAAA,GAAA,CAAI,YAAiB,KAAA,SAAA,IAAa,IAAI,YAAiB,KAAA,MAAA,IAAU,GAAI,CAAA,YAAA,KAAiB,QAAW,GAAA;AAAA,QACnG,aAAa,GAAI,CAAA;AAAA,UACf,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,aAAa,QAAW,GAAA;AAAA,QACrC,SAAS,GAAI,CAAA;AAAA,UACX,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,kBAAkB,QAAW,GAAA;AAAA,QAC1C,cAAc,GAAI,CAAA;AAAA,UAChB,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,mBAAmB,QAAW,GAAA;AAAA,QAC3C,eAAe,GAAI,CAAA;AAAA,UACjB,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,UAAU,QAAW,GAAA;AAAA,QAClC,OAAO,GAAI,CAAA;AAAA,UACT,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,iBAAiB,QAAW,GAAA;AAAA,QACzC,aAAa,GAAI,CAAA;AAAA,UACf,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,eAAe,SAAY,GAAA;AAAA,QACxC,WAAW,GAAI,CAAA;AAAA,UACb,EAAC,CAAA;AAAA,KACL;AAAA,GACE,EAAA,CAAA,CAAA,EAAA,GAAA,MAAA,CAAO,IAAP,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAa,IAAO,IAAA;AAAA,IACtB,IAAA,EAAM,OAAO,IAAK,CAAA;AAAA,MAChB,EAAC,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"catalogProductSearch.js","sources":["../../../../src/features/shopping/services/catalogProductSearch.ts"],"sourcesContent":["/**\n * The typed-catalog source: LemmeBuyIt through the connector's `lemmebuyit`\n * provider.\n *\n * Every other source on this page is a SERP read - Parallel AI renders a\n * retailer's search-results page and the connector regexes titles, prices and\n * images out of the excerpt text. That is why `Product.price` is so often 0 and\n * why \"who else sells this\" was not a question the page could ask: a rendered\n * page contains neither a reliable price nor a product identifier.\n *\n * This source returns typed rows instead, which unlocks three things the page now\n * shows: the real discount (original price + percent), cross-retailer compare by\n * shared identifier, and a weekly price series.\n *\n * All of it needs a LemmeBuyIt API key. When one is absent the calls fail fast\n * with the connector's own actionable message rather than returning an empty list\n * that would read as \"nothing found\".\n */\nimport { departmentBadge, type Product } from '../catalog';\nimport { getShoppingRuntime } from '../shoppingRuntime';\nimport { reconcilePricing } from './pricing';\nimport { sanitizeRetailerUrl } from './retailerUrl';\nimport {\n invokeShoppingSearchConnector,\n isConnectorLaneAbort,\n SHOPPING_SEARCH_ACTIONS,\n resolveShoppingSearchConnectorCredentials,\n type ConnectorLaneOptions,\n} from './shoppingSearchConnectorClient';\n\n/**\n * Retailers the catalog sweeps when no department is selected.\n *\n * LemmeBuyIt exposes 97 retailers / ~281M products; this page previously asked two\n * of them. The cap is not the API, it is time: the endpoint is retailer-scoped and\n * the free plan allows one concurrent MCP session, so breadth costs roughly a\n * second per retailer. Six is about the most that stays interactive while still\n * making \"who has it cheapest\" a real answer rather than a two-horse race.\n */\nexport const DEFAULT_CATALOG_RETAILERS = ['walmart', 'target', 'best_buy', 'kohls', 'macys', 'woot'];\n\n/**\n * Per-department retailers, so a department chip asks shops that actually stock\n * that department. Ids verified against list_retailers.\n */\nexport const DEPARTMENT_CATALOG_RETAILERS: Record<string, string[]> = {\n 'high-tech': ['best_buy', 'walmart', 'target', 'woot', 'samsung', 'dell'],\n sports: ['dicks_sporting_goods', 'scheels', 'cabelas', 'nike', 'walmart', 'bass_pro_shop'],\n beauty: ['ulta', 'sephora', 'walgreens', 'macys', 'walmart', 'mac_cosmetics'],\n 'home-garden': ['homedepot', 'lowes', 'wayfair', 'ace_hardware', 'walmart', 'ashley_homestore'],\n office: ['walmart', 'target', 'best_buy', 'woot', 'barnes_and_noble', 'qvc'],\n toys: ['walmart', 'target', 'lego', 'disney_store', 'american_girl', 'barnes_and_noble'],\n fashion: ['kohls', 'macys', 'nike', 'target', 'walmart', 'nordstrom'],\n grocery: ['walmart', 'target', 'walgreens', 'kroger', 'costco', 'sams_club'],\n auto: ['walmart', 'autozone', 'advance_auto_parts', 'homedepot', 'lowes', 'harbor_freight'],\n pets: ['chewy', 'petco', 'petsmart', 'walmart', 'target', 'tractor_supply'],\n};\n\n/** The retailer set for a department, falling back to the general default. */\nexport function catalogRetailersFor(departmentId?: string): string[] {\n return (departmentId && DEPARTMENT_CATALOG_RETAILERS[departmentId]) || DEFAULT_CATALOG_RETAILERS;\n}\n\n/** One row as the connector's `toCard` mapper emits it. */\nexport interface CatalogCard {\n id?: string;\n name?: string;\n title?: string;\n price?: number;\n priceText?: string;\n originalPrice?: number;\n discountPercent?: number;\n currency?: string;\n retailer?: string;\n url?: string;\n imageUrl?: string;\n rating?: string | number;\n reviewCount?: number;\n brand?: string;\n category?: string;\n inStock?: boolean;\n upc?: string;\n ean?: string;\n gtin?: string;\n mpn?: string;\n asin?: string;\n sku?: string;\n}\n\nexport interface CatalogSearchPayload {\n success?: boolean;\n query?: string;\n retailer?: string;\n /** Which path produced the rows; `*-sweep` means every retailer was covered. */\n source?: string;\n affiliateDisclosure?: string;\n products?: CatalogCard[];\n totalCount?: number;\n totalHits?: number;\n nextCursor?: string;\n error?: string;\n}\n\n/** `deals` rows come straight from SQL over the indexed store, in snake_case. */\ninterface DealRow {\n retailer_id?: string;\n product_id?: string;\n product_name?: string;\n brand?: string;\n current_price?: number;\n original_price?: number;\n discount_percentage?: number;\n rating?: number;\n in_stock?: boolean;\n product_url?: string;\n}\n\ninterface DealsPayload {\n success?: boolean;\n count?: number;\n deals?: DealRow[];\n /** Set when the result is empty, distinguishing \"no match\" from \"not indexed\". */\n hint?: string;\n}\n\nexport interface CompareRow {\n retailerId: string;\n productId: string;\n productName?: string;\n currentPrice?: number;\n inStock?: boolean;\n deltaToCheapest?: number;\n productUrl?: string;\n}\n\nexport interface CompareResult {\n identifier: string;\n lookupType: string;\n count: number;\n cheapest?: number;\n rows: CompareRow[];\n hint?: string;\n}\n\nexport interface PricePoint {\n ts: string;\n price: number;\n}\n\nexport interface PriceHistory {\n points: PricePoint[];\n /** Why the series is empty when it is (a plan gate, an unindexed product) - in the connector's words. */\n hint?: string;\n /** The provider's plan does not include the series. Not an error. */\n planGated?: boolean;\n}\n\nexport interface WatchRow {\n retailerId: string;\n productId: string;\n /** Listing snapshot kept with the pin, so the row renders without a catalog round-trip. */\n name?: string;\n url?: string;\n currentPrice?: number;\n previousPrice?: number;\n delta?: number;\n targetPrice?: number;\n hitTarget?: boolean;\n /** Where currentPrice came from: this pod's index, a live catalog lookup, or the price at pin time. */\n priceSource?: 'indexed' | 'live' | 'pinned';\n addedAt?: string;\n}\n\n/**\n * True when the catalog-backed views should be shown.\n *\n * Prefers the host's explicit `catalogEnabled` flag and falls back to \"the host\n * gave us a key\". The fallback keeps every existing host working unchanged; the\n * flag exists because a host can be perfectly able to use the provider while\n * holding no key itself - the connector resolves the credential backend-side.\n */\nexport function isCatalogConfigured(): boolean {\n const runtime = getShoppingRuntime().config.shoppingSearch;\n if (typeof runtime?.catalogEnabled === 'boolean') return runtime.catalogEnabled;\n return !!resolveShoppingSearchConnectorCredentials().lemmebuyitApiKey;\n}\n\n/**\n * Placeholder for a catalog row with no image.\n *\n * `Product.icon`/`accent` are a department's, and ProductImage falls back to them\n * when there is no thumbnail. A catalog row does not come from a department\n * search, so it would inherit DEPARTMENTS[0] (\"High-Tech\") and put a laptop emoji\n * on a coffee grinder. A neutral bag says \"no picture\" instead of asserting a\n * category the row never claimed.\n */\nconst CATALOG_PLACEHOLDER = { icon: '\\u{1F6CD}', accent: '#94a3b8' };\n\nfunction ratingNumber(rating: string | number | undefined): number {\n const value = typeof rating === 'number' ? rating : Number.parseFloat(String(rating ?? ''));\n return Number.isFinite(value) ? Math.min(5, Math.max(0, value)) : 0;\n}\n\n/**\n * One connector catalog row as a storefront {@link Product}.\n *\n * Exported because the catalog sweep is no longer its only caller - the\n * better-price lookup (`betterPrice.ts`) runs its own identifier / price-sorted\n * queries against the same action and must map the rows identically, or a row\n * would carry a different id and price shape depending on which question asked\n * for it.\n */\nexport function catalogCardToProduct(\n card: CatalogCard,\n departmentId: string | undefined,\n index: number,\n): Product | null {\n const name = (card.title || card.name || '').trim();\n if (!name) return null;\n const dept = departmentBadge(departmentId);\n const retailerId = (card.retailer || '').trim();\n const key = card.sku || card.id || `${index}`;\n // Catalog rows arrive as affiliate links (Impact `goto.*` redirects, tracking\n // params) that often 404 or come back malformed. Repair them to the canonical\n // retailer product URL so the card actually opens the right page.\n const url = sanitizeRetailerUrl(card.url?.trim());\n\n // The index states a list price and a percent separately; make them agree\n // (and drop a percent nothing backs) before the discount badge reads them.\n return reconcilePricing<Product>({\n id: `cat-${retailerId || 'x'}-${key}`,\n name,\n departmentId: dept.id,\n price: typeof card.price === 'number' && Number.isFinite(card.price) ? card.price : 0,\n rating: ratingNumber(card.rating),\n reviews: typeof card.reviewCount === 'number' ? card.reviewCount : 0,\n icon: CATALOG_PLACEHOLDER.icon,\n accent: CATALOG_PLACEHOLDER.accent,\n ...(card.imageUrl ? { imageUrl: card.imageUrl } : {}),\n ...(url ? { url } : {}),\n source: 'catalog',\n ...(typeof card.originalPrice === 'number' ? { originalPrice: card.originalPrice } : {}),\n ...(typeof card.discountPercent === 'number' ? { discountPercent: card.discountPercent } : {}),\n ...(card.currency ? { currency: card.currency } : {}),\n ...(typeof card.inStock === 'boolean' ? { inStock: card.inStock } : {}),\n ...(card.brand ? { brand: card.brand } : {}),\n ...(card.category?.trim() ? { storeCategory: card.category.trim() } : {}),\n ...(retailerId ? { retailerId } : {}),\n ...(card.sku ? { sku: card.sku } : {}),\n ...(card.upc ? { upc: card.upc } : {}),\n ...(card.ean ? { ean: card.ean } : {}),\n ...(card.gtin ? { gtin: card.gtin } : {}),\n ...(card.mpn ? { mpn: card.mpn } : {}),\n ...(card.asin ? { asin: card.asin } : {}),\n });\n}\n\nexport interface CatalogSearchParams {\n query: string;\n departmentId?: string;\n category?: string;\n budget?: number | string;\n maxResults?: number;\n /** Retailers to fan out across. Defaults to {@link DEFAULT_CATALOG_RETAILERS}. */\n retailers?: string[];\n inStockOnly?: boolean;\n /** Priority and cancellation in the one-at-a-time LemmeBuyIt lane. */\n lane?: ConnectorLaneOptions;\n}\n\n/**\n * Searches the catalog across retailers and merges the rows.\n *\n * The endpoint is retailer-scoped, so N retailers is N calls - run SEQUENTIALLY,\n * not in parallel. On a non-Enterprise LemmeBuyIt plan the connector reaches the\n * catalog over MCP, which allows exactly ONE concurrent session per key: two\n * overlapping retailer calls are two connector invocations, two sessions, and the\n * second gets `429 Concurrent session limit reached`. Sequential costs latency and\n * buys correctness.\n *\n * One retailer failing stays non-fatal - better Walmart's rows than nothing\n * because Target timed out. Every retailer failing rethrows the first error, so a\n * missing key still surfaces instead of looking like an empty catalog.\n */\nexport async function searchCatalogProducts(params: CatalogSearchParams): Promise<{\n products: Product[];\n query: string;\n totalCount: number;\n /** Set when rows came from the free tier, whose product links are affiliate URLs. */\n affiliateDisclosure?: string;\n error?: string;\n}> {\n const query = params.query.trim();\n if (!query) throw new Error('Catalog search requires a query');\n\n const retailers = params.retailers?.length ? params.retailers : catalogRetailersFor(params.departmentId);\n const budget = typeof params.budget === 'string' ? Number.parseFloat(params.budget) : params.budget;\n\n // ONE call sweeping every retailer, not one call per retailer. The connector\n // walks them inside a single MCP session, which is both far faster and the only\n // shape that respects the one-session-per-key limit.\n const [primary, ...rest] = retailers;\n // A cancelled call is not a failed one: it rethrows as the abort it is, so a\n // rail the shopper scrolled away from never reports \"catalog search failed\".\n const failedUnlessAborted = (reason: unknown) => {\n if (isConnectorLaneAbort(reason)) throw reason;\n return { success: false as const, error: String(reason) };\n };\n const outcome = await invokeShoppingSearchConnector<CatalogSearchPayload>(\n {\n retailer: primary,\n ...(rest.length ? { retailers: rest } : {}),\n query,\n limit: params.maxResults ?? 24,\n sortBy: 'relevance',\n ...(Number.isFinite(budget) && (budget as number) > 0 ? { maxPrice: budget } : {}),\n ...(params.inStockOnly ? { inStock: true } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.CATALOG_SEARCH,\n params.lane,\n ).catch(failedUnlessAborted);\n\n const deptId = params.departmentId;\n const products: Product[] = [];\n const failures: string[] = [];\n let affiliateDisclosure: string | undefined;\n\n if (!outcome.success) {\n // Nothing came back at all - surface the reason rather than an empty grid,\n // so a missing key never reads as \"this product does not exist\".\n throw new Error(outcome.error || 'Catalog search failed');\n }\n\n const payload = 'data' in outcome ? outcome.data : undefined;\n affiliateDisclosure = payload?.affiliateDisclosure;\n for (const card of payload?.products ?? []) {\n const product = catalogCardToProduct(card, deptId, products.length);\n if (product) products.push(product);\n }\n if (payload?.error) failures.push(payload.error);\n\n // Compatibility with a connector that predates the multi-retailer sweep: it\n // ignores `retailers` and answers for the primary one only, which would\n // silently narrow the page from six shops to one. Detect it by the source tag\n // and ask the rest one retailer at a time.\n //\n // All of them are queued at ONCE. The lane already runs one call at a time\n // (the MCP plan allows a single concurrent session), so awaiting each before\n // queueing the next bought no safety - it only left a gap after every call\n // for other queued work to take the lane, which is how a search ended up\n // interleaved one call apiece with the landing page's rails.\n const sweptAll = (payload?.source ?? '').includes('sweep');\n if (!sweptAll && rest.length) {\n const walked = await Promise.all(\n rest.map((extra) =>\n invokeShoppingSearchConnector<CatalogSearchPayload>(\n {\n retailer: extra,\n query,\n limit: Math.max(4, Math.ceil((params.maxResults ?? 24) / retailers.length)),\n sortBy: 'relevance',\n ...(Number.isFinite(budget) && (budget as number) > 0 ? { maxPrice: budget } : {}),\n ...(params.inStockOnly ? { inStock: true } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.CATALOG_SEARCH,\n params.lane,\n ).catch(failedUnlessAborted),\n ),\n );\n for (const more of walked) {\n if (!more.success) continue;\n const extraPayload = 'data' in more ? more.data : undefined;\n for (const card of extraPayload?.products ?? []) {\n const product = catalogCardToProduct(card, deptId, products.length);\n if (product) products.push(product);\n }\n }\n }\n\n // The connector already merges cheapest-first across the sweep; re-sort because\n // toProduct can drop rows and the surface owns the final order either way.\n products.sort((a, b) => (a.price || Number.MAX_SAFE_INTEGER) - (b.price || Number.MAX_SAFE_INTEGER));\n\n return {\n products,\n query,\n totalCount: products.length,\n ...(affiliateDisclosure ? { affiliateDisclosure } : {}),\n ...(failures.length ? { error: failures.join(' · ') } : {}),\n };\n}\n\nexport interface DealsQuery {\n minDiscount?: number;\n maxPrice?: number;\n minRating?: number;\n minReviews?: number;\n inStock?: boolean;\n category?: string;\n retailers?: string[];\n sort?: 'discount' | 'price';\n limit?: number;\n}\n\n/** Compound deal finder over the indexed store. */\nexport async function searchCatalogDeals(query: DealsQuery): Promise<{\n products: Product[];\n hint?: string;\n}> {\n const result = await invokeShoppingSearchConnector<DealsPayload>(\n {\n ...(query.minDiscount !== undefined ? { minDiscount: query.minDiscount } : {}),\n ...(query.maxPrice !== undefined ? { maxPrice: query.maxPrice } : {}),\n ...(query.minRating !== undefined ? { minRating: query.minRating } : {}),\n ...(query.minReviews !== undefined ? { minReviews: query.minReviews } : {}),\n ...(query.inStock ? { inStock: true } : {}),\n ...(query.category ? { category: query.category } : {}),\n ...(query.retailers?.length ? { retailers: query.retailers } : {}),\n sort: query.sort ?? 'discount',\n limit: query.limit ?? 24,\n },\n SHOPPING_SEARCH_ACTIONS.DEALS,\n );\n\n if (!result.success) throw new Error(result.error || 'Deal search failed');\n\n const dept = departmentBadge();\n const products = (result.data?.deals ?? [])\n .map((row, index): Product | null => {\n const name = (row.product_name || '').trim();\n if (!name) return null;\n const url = sanitizeRetailerUrl(row.product_url?.trim());\n return reconcilePricing<Product>({\n id: `deal-${row.retailer_id ?? 'x'}-${row.product_id ?? index}`,\n name,\n departmentId: dept.id,\n price: typeof row.current_price === 'number' ? row.current_price : 0,\n rating: typeof row.rating === 'number' ? Math.min(5, Math.max(0, row.rating)) : 0,\n reviews: 0,\n icon: CATALOG_PLACEHOLDER.icon,\n accent: CATALOG_PLACEHOLDER.accent,\n ...(url ? { url } : {}),\n source: 'catalog',\n ...(typeof row.original_price === 'number' ? { originalPrice: row.original_price } : {}),\n ...(typeof row.discount_percentage === 'number' ? { discountPercent: row.discount_percentage } : {}),\n ...(typeof row.in_stock === 'boolean' ? { inStock: row.in_stock } : {}),\n ...(row.brand ? { brand: row.brand } : {}),\n ...(row.retailer_id ? { retailerId: row.retailer_id } : {}),\n ...(row.product_id ? { sku: row.product_id } : {}),\n });\n })\n .filter((p): p is Product => p !== null);\n\n return { products, ...(result.data?.hint ? { hint: result.data.hint } : {}) };\n}\n\n/**\n * Deals for a SEARCH TERM, rather than the whole indexed store.\n *\n * {@link searchCatalogDeals} above ranks everything indexed, which is the right\n * answer to \"what is worth buying right now\" and the wrong one to \"deals on\n * headphones\" — it has no query parameter at all. `CATALOG_SEARCH` does, and it\n * also carries every bar the Deals view sets, so one call answers both halves.\n *\n * `full: true` is REQUIRED, not incidental: the connector gates\n * `minDiscountPercent` / `onSale` / `minRating` / `minReviews` behind it, and\n * without the flag those filters are silently ignored — you get a plain relevance\n * search wearing a deals label.\n */\nexport async function searchCatalogDealsByQuery(params: {\n query: string;\n minDiscount?: number;\n maxPrice?: number;\n minRating?: number;\n minReviews?: number;\n inStock?: boolean;\n sort?: 'discount' | 'price';\n limit?: number;\n retailers?: string[];\n departmentId?: string | null;\n}): Promise<{ products: Product[]; error?: string }> {\n const query = params.query.trim();\n if (!query) return { products: [] };\n\n const departmentId = params.departmentId ?? undefined;\n const retailers = params.retailers?.length ? params.retailers : catalogRetailersFor(departmentId);\n const [primary, ...rest] = retailers;\n\n const outcome = await invokeShoppingSearchConnector<CatalogSearchPayload>(\n {\n retailer: primary,\n ...(rest.length ? { retailers: rest } : {}),\n query,\n full: true,\n onSale: true,\n sortBy: params.sort === 'price' ? 'price_asc' : 'discount_desc',\n limit: params.limit ?? 24,\n ...(params.minDiscount ? { minDiscountPercent: params.minDiscount } : {}),\n ...(params.maxPrice ? { maxPrice: params.maxPrice } : {}),\n ...(params.minRating ? { minRating: params.minRating } : {}),\n ...(params.minReviews ? { minReviews: params.minReviews } : {}),\n ...(params.inStock ? { inStock: true } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.CATALOG_SEARCH,\n ).catch((reason: unknown) => ({ success: false as const, error: String(reason) }));\n\n if (!outcome.success) return { products: [], error: outcome.error || 'Catalog deal search failed' };\n\n const payload = 'data' in outcome ? outcome.data : undefined;\n const products: Product[] = [];\n for (const card of payload?.products ?? []) {\n const product = catalogCardToProduct(card, departmentId, products.length);\n if (product) products.push(product);\n }\n return { products, ...(payload?.error ? { error: payload.error } : {}) };\n}\n\n/** Cheapest indexed retailer for one shared identifier. */\nexport async function compareRetailers(params: {\n identifier: string;\n lookupType: string;\n inStockOnly?: boolean;\n}): Promise<CompareResult> {\n const result = await invokeShoppingSearchConnector<{\n identifier?: string;\n lookupType?: string;\n count?: number;\n cheapest?: number | null;\n results?: Array<Record<string, unknown>>;\n hint?: string;\n }>(\n {\n identifier: params.identifier,\n lookupType: params.lookupType,\n ...(params.inStockOnly ? { inStock: true } : {}),\n limit: 25,\n },\n SHOPPING_SEARCH_ACTIONS.COMPARE,\n );\n\n if (!result.success) throw new Error(result.error || 'Compare failed');\n const data = result.data ?? {};\n\n return {\n identifier: data.identifier ?? params.identifier,\n lookupType: data.lookupType ?? params.lookupType,\n count: data.count ?? 0,\n ...(typeof data.cheapest === 'number' ? { cheapest: data.cheapest } : {}),\n rows: (data.results ?? []).map((row) => ({\n retailerId: String(row.retailer_id ?? ''),\n productId: String(row.product_id ?? ''),\n ...(row.product_name ? { productName: String(row.product_name) } : {}),\n ...(typeof row.current_price === 'number' ? { currentPrice: row.current_price } : {}),\n ...(typeof row.in_stock === 'boolean' ? { inStock: row.in_stock } : {}),\n ...(typeof row.delta_to_cheapest === 'number' ? { deltaToCheapest: row.delta_to_cheapest } : {}),\n ...(() => {\n const url = row.product_url ? sanitizeRetailerUrl(String(row.product_url).trim()) : undefined;\n return url ? { productUrl: url } : {};\n })(),\n })),\n ...(data.hint ? { hint: data.hint } : {}),\n };\n}\n\n/**\n * Weekly price series for one product.\n *\n * The series carries several price columns (buy box, third-party new, retail, and\n * a Walmart column); the chart wants one line, so pick the first populated column\n * per point in that order of preference.\n */\nexport async function fetchPriceHistory(params: {\n retailer: string;\n productId: string;\n weeks?: number;\n}): Promise<PriceHistory> {\n const result = await invokeShoppingSearchConnector<{\n series?: { series?: Array<Record<string, unknown>> } | Array<Record<string, unknown>>;\n hint?: string;\n planGated?: boolean;\n }>(\n { retailer: params.retailer, productId: params.productId, weeks: params.weeks ?? 26 },\n SHOPPING_SEARCH_ACTIONS.PRICE_HISTORY,\n );\n if (!result.success) throw new Error(result.error || 'Price history failed');\n\n const raw = result.data?.series;\n const rows = Array.isArray(raw) ? raw : (raw?.series ?? []);\n const PRICE_KEYS = ['amz_buy_box', 'amz_3p_new', 'amz_retail', 'walmart_price', 'price'];\n\n const points = rows\n .map((point): PricePoint | null => {\n const ts = String(point.ts ?? '');\n if (!ts) return null;\n for (const key of PRICE_KEYS) {\n const value = point[key];\n if (typeof value === 'number' && Number.isFinite(value) && value > 0) return { ts, price: value };\n }\n return null;\n })\n .filter((p): p is PricePoint => p !== null);\n\n return {\n points,\n ...(result.data?.hint ? { hint: result.data.hint } : {}),\n ...(result.data?.planGated ? { planGated: true } : {}),\n };\n}\n\n/** Whether watching also turned on price alerts (notification centre + phone). */\nexport interface PriceWatchAlerts {\n armed: boolean;\n error?: string;\n}\n\n/**\n * Pin a product to the caller's watchlist (shared across agent pods). The listing\n * snapshot travels with the pin so the Watchlist can name and link the row - and\n * show a price - before any catalog index has run. The connector arms the\n * person's hourly price alerts on the way; `alerts` says whether that worked\n * (absent from a connector that predates alerts).\n */\nexport async function addPriceWatch(params: {\n retailer: string;\n productId: string;\n targetPrice?: number;\n name?: string;\n url?: string;\n price?: number;\n currency?: string;\n}): Promise<{ alerts?: PriceWatchAlerts }> {\n const result = await invokeShoppingSearchConnector<{ success?: boolean; alerts?: PriceWatchAlerts }>(\n {\n retailer: params.retailer,\n productId: params.productId,\n ...(params.targetPrice !== undefined ? { targetPrice: params.targetPrice } : {}),\n ...(params.name ? { name: params.name } : {}),\n ...(params.url ? { url: params.url } : {}),\n ...(params.price !== undefined && params.price > 0 ? { price: params.price } : {}),\n ...(params.currency ? { currency: params.currency } : {}),\n },\n SHOPPING_SEARCH_ACTIONS.WATCH_ADD,\n );\n if (!result.success) throw new Error(result.error || 'Could not add the price watch');\n const alerts = result.data?.alerts;\n return alerts && typeof alerts.armed === 'boolean'\n ? { alerts: { armed: alerts.armed, ...(alerts.error ? { error: String(alerts.error) } : {}) } }\n : {};\n}\n\n/** Stop watching a product - which also stops its price alerts. */\nexport async function removePriceWatch(params: { retailer: string; productId: string }): Promise<void> {\n const result = await invokeShoppingSearchConnector<{ success?: boolean }>(\n { retailer: params.retailer, productId: params.productId },\n SHOPPING_SEARCH_ACTIONS.WATCH_REMOVE,\n );\n if (!result.success) throw new Error(result.error || 'Could not stop watching this product');\n}\n\n/** Every watched product's movement since the last index refresh. */\nexport async function fetchWatchStatus(): Promise<{ rows: WatchRow[]; hint?: string }> {\n const result = await invokeShoppingSearchConnector<{\n watched?: Array<Record<string, unknown>>;\n hint?: string;\n }>({}, SHOPPING_SEARCH_ACTIONS.WATCH_STATUS);\n if (!result.success) throw new Error(result.error || 'Could not read the watchlist');\n\n return {\n rows: (result.data?.watched ?? []).map((row) => ({\n retailerId: String(row.retailer_id ?? ''),\n productId: String(row.product_id ?? ''),\n ...(typeof row.product_name === 'string' && row.product_name ? { name: row.product_name } : {}),\n ...(() => {\n const url = row.product_url ? sanitizeRetailerUrl(String(row.product_url).trim()) : undefined;\n return url ? { url } : {};\n })(),\n ...(row.price_source === 'indexed' || row.price_source === 'live' || row.price_source === 'pinned'\n ? { priceSource: row.price_source }\n : {}),\n ...(typeof row.added_at === 'string' ? { addedAt: row.added_at } : {}),\n ...(typeof row.current_price === 'number' ? { currentPrice: row.current_price } : {}),\n ...(typeof row.previous_price === 'number' ? { previousPrice: row.previous_price } : {}),\n ...(typeof row.delta === 'number' ? { delta: row.delta } : {}),\n ...(typeof row.target_price === 'number' ? { targetPrice: row.target_price } : {}),\n ...(typeof row.hit_target === 'boolean' ? { hitTarget: row.hit_target } : {}),\n })),\n ...(result.data?.hint ? { hint: result.data.hint } : {}),\n };\n}\n"],"names":["_a","_b","_c"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCO,MAAM,4BAA4B,CAAC,SAAA,EAAW,UAAU,UAAY,EAAA,OAAA,EAAS,SAAS,MAAM;AAM5F,MAAM,4BAAyD,GAAA;AAAA,EACpE,aAAa,CAAC,UAAA,EAAY,WAAW,QAAU,EAAA,MAAA,EAAQ,WAAW,MAAM,CAAA;AAAA,EACxE,QAAQ,CAAC,sBAAA,EAAwB,WAAW,SAAW,EAAA,MAAA,EAAQ,WAAW,eAAe,CAAA;AAAA,EACzF,QAAQ,CAAC,MAAA,EAAQ,WAAW,WAAa,EAAA,OAAA,EAAS,WAAW,eAAe,CAAA;AAAA,EAC5E,eAAe,CAAC,WAAA,EAAa,SAAS,SAAW,EAAA,cAAA,EAAgB,WAAW,kBAAkB,CAAA;AAAA,EAC9F,QAAQ,CAAC,SAAA,EAAW,UAAU,UAAY,EAAA,MAAA,EAAQ,oBAAoB,KAAK,CAAA;AAAA,EAC3E,MAAM,CAAC,SAAA,EAAW,UAAU,MAAQ,EAAA,cAAA,EAAgB,iBAAiB,kBAAkB,CAAA;AAAA,EACvF,SAAS,CAAC,OAAA,EAAS,SAAS,MAAQ,EAAA,QAAA,EAAU,WAAW,WAAW,CAAA;AAAA,EACpE,SAAS,CAAC,SAAA,EAAW,UAAU,WAAa,EAAA,QAAA,EAAU,UAAU,WAAW,CAAA;AAAA,EAC3E,MAAM,CAAC,SAAA,EAAW,YAAY,oBAAsB,EA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IAAI,YAAiB,KAAA,MAAA,IAAU,GAAI,CAAA,YAAA,KAAiB,QAAW,GAAA;AAAA,QACnG,aAAa,GAAI,CAAA;AAAA,UACf,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,aAAa,QAAW,GAAA;AAAA,QACrC,SAAS,GAAI,CAAA;AAAA,UACX,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,kBAAkB,QAAW,GAAA;AAAA,QAC1C,cAAc,GAAI,CAAA;AAAA,UAChB,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,mBAAmB,QAAW,GAAA;AAAA,QAC3C,eAAe,GAAI,CAAA;AAAA,UACjB,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,UAAU,QAAW,GAAA;AAAA,QAClC,OAAO,GAAI,CAAA;AAAA,UACT,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,iBAAiB,QAAW,GAAA;AAAA,QACzC,aAAa,GAAI,CAAA;AAAA,UACf,EAAC,CAAA,EACD,OAAO,GAAA,CAAI,eAAe,SAAY,GAAA;AAAA,QACxC,WAAW,GAAI,CAAA;AAAA,UACb,EAAC,CAAA;AAAA,KACL;AAAA,GACE,EAAA,CAAA,CAAA,EAAA,GAAA,MAAA,CAAO,IAAP,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAa,IAAO,IAAA;AAAA,IACtB,IAAA,EAAM,OAAO,IAAK,CAAA;AAAA,MAChB,EAAC,CAAA;AAET"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {BLACK_FRIDAY_BROWSER_SITES,BLACK_FRIDAY_STORE_GROUPS,BLACK_FRIDAY_SEASON_QUERY}from'./blackFridayBrowserSites.js';import {accessoryTest}from'./searchRelevance.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
function blackFridaySitePage(site, query) {
|
|
18
|
+
return site.url(query.trim() || BLACK_FRIDAY_SEASON_QUERY);
|
|
19
|
+
}
|
|
20
|
+
function serverAnswered(site, answer) {
|
|
21
|
+
if (!answer) return false;
|
|
22
|
+
const label = site.label.toLowerCase();
|
|
23
|
+
const report = answer.sources.find((source) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return source.source === site.id || ((_a = source.label) != null ? _a : "").toLowerCase() === label;
|
|
26
|
+
});
|
|
27
|
+
return !!report && (report.status === "ok" || report.status === "empty" || report.status === "reading");
|
|
28
|
+
}
|
|
29
|
+
const READING_REFETCH_MS = 3e4;
|
|
30
|
+
const READING_REFETCHES = 12;
|
|
31
|
+
function readingRefetch(answer, updates) {
|
|
32
|
+
return (answer == null ? void 0 : answer.sources.some((source) => source.status === "reading")) && updates <= READING_REFETCHES ? READING_REFETCH_MS : false;
|
|
33
|
+
}
|
|
34
|
+
const dealKey = (deal) => `${deal.title.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim()}|${deal.price}`;
|
|
35
|
+
function dedupeDeals(...groups) {
|
|
36
|
+
const byUrl = /* @__PURE__ */ new Set();
|
|
37
|
+
const byKey = /* @__PURE__ */ new Set();
|
|
38
|
+
const merged = [];
|
|
39
|
+
for (const deal of groups.flat()) {
|
|
40
|
+
const key = dealKey(deal);
|
|
41
|
+
if (byUrl.has(deal.url) || byKey.has(key)) continue;
|
|
42
|
+
byUrl.add(deal.url);
|
|
43
|
+
byKey.add(key);
|
|
44
|
+
merged.push(deal);
|
|
45
|
+
}
|
|
46
|
+
return merged;
|
|
47
|
+
}
|
|
48
|
+
const VERDICT_RANK = {
|
|
49
|
+
lowest: 0,
|
|
50
|
+
good: 1,
|
|
51
|
+
new: 2,
|
|
52
|
+
"cheaper-elsewhere": 3,
|
|
53
|
+
usual: 3,
|
|
54
|
+
higher: 4
|
|
55
|
+
};
|
|
56
|
+
function mergeHolidayDeals(server, browser, sort, query = "") {
|
|
57
|
+
const byDiscount = (a, b) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
return b.discountPercent - a.discountPercent || ((_a = b.votes) != null ? _a : 0) - ((_b = a.votes) != null ? _b : 0);
|
|
60
|
+
};
|
|
61
|
+
const isAccessory = accessoryTest(query);
|
|
62
|
+
const tiers = /* @__PURE__ */ new Map();
|
|
63
|
+
const tier = (deal) => {
|
|
64
|
+
if (!tiers.has(deal)) tiers.set(deal, isAccessory(deal.title) ? 1 : 0);
|
|
65
|
+
return tiers.get(deal);
|
|
66
|
+
};
|
|
67
|
+
const extras = dedupeDeals(browser).sort(byDiscount);
|
|
68
|
+
const all = dedupeDeals(server, extras);
|
|
69
|
+
if (sort === "best") {
|
|
70
|
+
const rank = (deal) => {
|
|
71
|
+
var _a, _b, _c;
|
|
72
|
+
return (_c = VERDICT_RANK[(_b = (_a = deal.verdict) == null ? void 0 : _a.kind) != null ? _b : "new"]) != null ? _c : 2;
|
|
73
|
+
};
|
|
74
|
+
const fromServer = new Set(server);
|
|
75
|
+
const placed = all.filter((deal) => fromServer.has(deal)).sort((a, b) => tier(a) - tier(b));
|
|
76
|
+
for (const extra of all.filter((deal) => !fromServer.has(deal))) {
|
|
77
|
+
const at = placed.findIndex((deal) => tier(deal) > tier(extra) || tier(deal) === tier(extra) && (rank(deal) > rank(extra) || rank(deal) === rank(extra) && deal.discountPercent < extra.discountPercent));
|
|
78
|
+
placed.splice(at < 0 ? placed.length : at, 0, extra);
|
|
79
|
+
}
|
|
80
|
+
return placed;
|
|
81
|
+
}
|
|
82
|
+
const order = sort === "votes" ? (a, b) => {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
return ((_a = b.votes) != null ? _a : -1) - ((_b = a.votes) != null ? _b : -1) || byDiscount(a, b);
|
|
85
|
+
} : sort === "price" ? (a, b) => a.price - b.price || byDiscount(a, b) : byDiscount;
|
|
86
|
+
return all.sort((a, b) => tier(a) - tier(b) || order(a, b));
|
|
87
|
+
}
|
|
88
|
+
function holidaySiteStates(answer) {
|
|
89
|
+
var _a;
|
|
90
|
+
const out = {};
|
|
91
|
+
for (const site of BLACK_FRIDAY_BROWSER_SITES) {
|
|
92
|
+
if (site.closed) {
|
|
93
|
+
out[site.id] = {
|
|
94
|
+
kind: "closed",
|
|
95
|
+
note: site.closed
|
|
96
|
+
};
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const label = site.label.toLowerCase();
|
|
100
|
+
const report = site.server ? answer == null ? void 0 : answer.sources.find((source) => {
|
|
101
|
+
var _a2;
|
|
102
|
+
return source.source === site.id || ((_a2 = source.label) != null ? _a2 : "").toLowerCase() === label;
|
|
103
|
+
}) : void 0;
|
|
104
|
+
if (serverAnswered(site, answer)) {
|
|
105
|
+
out[site.id] = __spreadValues({
|
|
106
|
+
kind: "server",
|
|
107
|
+
count: (_a = report == null ? void 0 : report.count) != null ? _a : 0
|
|
108
|
+
}, (report == null ? void 0 : report.status) === "reading" ? {
|
|
109
|
+
reading: true
|
|
110
|
+
} : {});
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
out[site.id] = (report == null ? void 0 : report.status) === "failed" ? {
|
|
114
|
+
kind: "failed"
|
|
115
|
+
} : {
|
|
116
|
+
kind: "unpaired"
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
function holidaySiteStatus(state) {
|
|
122
|
+
if (state.kind === "closed") return "closed";
|
|
123
|
+
if (state.kind === "server" && state.reading) return "reading on Yantra\u2026";
|
|
124
|
+
if (state.kind === "server") return state.count > 0 ? `${state.count} via Yantra` : "checked";
|
|
125
|
+
if (state.kind === "failed") return "could not read";
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const HOLIDAY_SITE_GROUPS = [{
|
|
129
|
+
id: "deals",
|
|
130
|
+
label: "Deal sites",
|
|
131
|
+
sites: BLACK_FRIDAY_BROWSER_SITES.filter((site) => site.kind === "deals")
|
|
132
|
+
}, ...BLACK_FRIDAY_STORE_GROUPS.map((group) => ({
|
|
133
|
+
id: group.id,
|
|
134
|
+
label: group.label,
|
|
135
|
+
sites: BLACK_FRIDAY_BROWSER_SITES.filter((site) => site.group === group.id)
|
|
136
|
+
}))];
|
|
137
|
+
const HOLIDAY_STORE_COUNT = BLACK_FRIDAY_BROWSER_SITES.filter((site) => site.kind === "store").length;
|
|
138
|
+
function serversReadingCount(states) {
|
|
139
|
+
return BLACK_FRIDAY_BROWSER_SITES.filter((site) => {
|
|
140
|
+
const state = states[site.id];
|
|
141
|
+
return (state == null ? void 0 : state.kind) === "server" && state.reading === true;
|
|
142
|
+
}).length;
|
|
143
|
+
}export{HOLIDAY_SITE_GROUPS,HOLIDAY_STORE_COUNT,READING_REFETCHES,READING_REFETCH_MS,blackFridaySitePage,holidaySiteStates,holidaySiteStatus,mergeHolidayDeals,readingRefetch,serverAnswered,serversReadingCount};//# sourceMappingURL=holidayDeals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holidayDeals.js","sources":["../../../../src/features/shopping/services/holidayDeals.ts"],"sourcesContent":["/**\n * The holiday deals section's merging, ordering and site directory - the pure\n * half of the web surface's `services/blackFridayBrowser.ts` (0.49.0).\n *\n * On the web a paired desktop browser also reads the deal sites and stores a\n * server cannot (`readBlackFridaySite`, the deal-reader script, the\n * own-browser queue). A phone has no shopper's browser to read them in, so\n * that half is not ported: the browser's deal list is always empty here, and\n * every site the servers did not read opens on its own search page instead.\n * What is kept is verbatim: how the connector's deals are merged and ordered\n * (`mergeHolidayDeals`, `VERDICT_RANK`, accessories after the product), which\n * sites the servers answered for (`serverAnswered`), the \"still reading\"\n * re-ask (`readingRefetch`), each site's own page (`blackFridaySitePage`) and\n * the query match (`rowMatchesQuery`).\n */\nimport type { BlackFridayAnswer, BlackFridayDeal, BlackFridaySort } from './blackFriday';\nimport {\n BLACK_FRIDAY_BROWSER_SITES,\n BLACK_FRIDAY_SEASON_QUERY,\n BLACK_FRIDAY_STORE_GROUPS,\n type BlackFridaySite,\n} from './blackFridayBrowserSites';\nimport { MODEL_LINE_WORDS as MODEL_LINE } from './modelWords';\nimport { accessoryTest } from './searchRelevance';\n\n/** The page a site is read on, and the query the reader searches for (the season's deals when none was typed). */\nexport function blackFridaySitePage(site: BlackFridaySite, query: string): string {\n return site.url(query.trim() || BLACK_FRIDAY_SEASON_QUERY);\n}\n\nconst tokens = (text: string): string[] =>\n text\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((token) => token.length > 1);\n\n/** A word without its plural s (\"tvs\" → \"tv\", \"laptops\" → \"laptop\"); \"glass\" keeps its own. */\nconst singular = (word: string): string =>\n word.length > 2 && word.endsWith('s') && !word.endsWith('ss') ? word.slice(0, -1) : word;\n\n/**\n * Whether a row answers what the shopper typed. A page that searched for the\n * query needs half its words in the title; a page that lists deals without\n * searching (or a search that fell back to the latest deals) needs all of them.\n *\n * A model-line word counts only right after the word it names, and a title that\n * names that word without it is another line: a store's search for \"macbook pro\"\n * also lists \"Win11 Pro\" laptops, \"Beats Studio Pro\" and the \"MacBook Neo\".\n */\nexport function rowMatchesQuery(title: string, query: string, searched: boolean): boolean {\n const words = tokens(query).map(singular);\n if (words.length === 0) return true;\n // Whole words: \"art\" is not in \"Smart TV\".\n const said = tokens(title).map(singular);\n const inTitle = new Set(said);\n const follows = (head: string, word: string) => said.some((token, at) => token === head && said[at + 1] === word);\n let hits = 0;\n let named = false;\n for (const [at, word] of words.entries()) {\n const head = at > 0 ? words[at - 1] : undefined;\n if (head && MODEL_LINE.has(word) && !MODEL_LINE.has(head)) {\n if (inTitle.has(head) && !follows(head, word)) return false;\n if (follows(head, word)) hits++;\n } else if (head && MODEL_LINE.has(word)) {\n // \"pro max\": the second line word follows the first\n if (follows(head, word)) hits++;\n else if (inTitle.has(head)) return false;\n } else if (inTitle.has(word)) {\n hits++;\n named = true;\n }\n }\n // A product the shopper named must be in the title, not only its line (\"pro\")\n if (!named && words.some((word, at) => !(at > 0 && MODEL_LINE.has(word)))) return false;\n return searched ? hits >= Math.ceil(words.length / 2) : hits === words.length;\n}\n\n/**\n * Whether the connector already read `site` for this search: any site it\n * reports (found deals, found none, or is still reading it - its next answer\n * brings those), not only the sites it read before the deal recipes.\n */\nexport function serverAnswered(site: BlackFridaySite, answer: BlackFridayAnswer | undefined): boolean {\n if (!answer) return false;\n const label = site.label.toLowerCase();\n const report = answer.sources.find(\n (source) => source.source === site.id || (source.label ?? '').toLowerCase() === label,\n );\n return !!report && (report.status === 'ok' || report.status === 'empty' || report.status === 'reading');\n}\n\n/** Ask the connector again this often while it says it is still reading a site, at most READING_REFETCHES times. */\nexport const READING_REFETCH_MS = 30_000;\nexport const READING_REFETCHES = 12;\n\n/** The panel's refetch interval: READING_REFETCH_MS while the server is still reading a site, a few times; else none. */\nexport function readingRefetch(answer: BlackFridayAnswer | undefined, updates: number): number | false {\n return answer?.sources.some((source) => source.status === 'reading') && updates <= READING_REFETCHES\n ? READING_REFETCH_MS\n : false;\n}\n\nconst dealKey = (deal: BlackFridayDeal): string =>\n `${deal.title\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, ' ')\n .trim()}|${deal.price}`;\n\n/** One per link and per product at a store, the first group's first: the order given is kept. */\nfunction dedupeDeals(...groups: BlackFridayDeal[][]): BlackFridayDeal[] {\n const byUrl = new Set<string>();\n const byKey = new Set<string>();\n const merged: BlackFridayDeal[] = [];\n for (const deal of groups.flat()) {\n const key = dealKey(deal);\n if (byUrl.has(deal.url) || byKey.has(key)) continue;\n byUrl.add(deal.url);\n byKey.add(key);\n merged.push(deal);\n }\n return merged;\n}\n\n/** The connector's deals and the browser's, one card per deal, biggest discount first. */\nexport function mergeBlackFridayDeals(...groups: BlackFridayDeal[][]): BlackFridayDeal[] {\n // A stable sort: equal discounts keep the connector's order, which lists its best first.\n return dedupeDeals(...groups).sort((a, b) => b.discountPercent - a.discountPercent);\n}\n\n/** Real lows first, then deals with no history, then ordinary prices (the connector's dealLedger ranks). */\nconst VERDICT_RANK: Record<string, number> = {\n lowest: 0,\n good: 1,\n new: 2,\n 'cheaper-elsewhere': 3,\n usual: 3,\n higher: 4,\n};\n\n/**\n * The connector's deals in the order the shopper picked, with the deals a\n * browser read placed by the same rule (on a phone there are none: pass []).\n * \"Real deals first\" keeps the connector's order and slots the extra deals in\n * by verdict - they have none yet, so among the deals with no history, biggest\n * discount first. Every other order is one sort over all of them. In every\n * order, what was searched for comes first and its accessories after (as the\n * connector orders its own): a store's search for \"macbook pro\" lists laptop\n * bags, hubs and cables too.\n */\nexport function mergeHolidayDeals(\n server: BlackFridayDeal[],\n browser: BlackFridayDeal[],\n sort: BlackFridaySort,\n query = '',\n): BlackFridayDeal[] {\n const byDiscount = (a: BlackFridayDeal, b: BlackFridayDeal) =>\n b.discountPercent - a.discountPercent || (b.votes ?? 0) - (a.votes ?? 0);\n const isAccessory = accessoryTest(query);\n const tiers = new Map<BlackFridayDeal, number>();\n const tier = (deal: BlackFridayDeal): number => {\n if (!tiers.has(deal)) tiers.set(deal, isAccessory(deal.title) ? 1 : 0);\n return tiers.get(deal)!;\n };\n const extras = dedupeDeals(browser).sort(byDiscount);\n const all = dedupeDeals(server, extras);\n if (sort === 'best') {\n // The connector's order stays as it is; each browser deal goes in among the deals of its verdict, by discount\n const rank = (deal: BlackFridayDeal) => VERDICT_RANK[deal.verdict?.kind ?? 'new'] ?? 2;\n const fromServer = new Set(server);\n const placed = all.filter((deal) => fromServer.has(deal)).sort((a, b) => tier(a) - tier(b));\n for (const extra of all.filter((deal) => !fromServer.has(deal))) {\n const at = placed.findIndex(\n (deal) =>\n tier(deal) > tier(extra) ||\n (tier(deal) === tier(extra) &&\n (rank(deal) > rank(extra) ||\n (rank(deal) === rank(extra) && deal.discountPercent < extra.discountPercent))),\n );\n placed.splice(at < 0 ? placed.length : at, 0, extra);\n }\n return placed;\n }\n const order =\n sort === 'votes'\n ? (a: BlackFridayDeal, b: BlackFridayDeal) => (b.votes ?? -1) - (a.votes ?? -1) || byDiscount(a, b)\n : sort === 'price'\n ? (a: BlackFridayDeal, b: BlackFridayDeal) => a.price - b.price || byDiscount(a, b)\n : byDiscount;\n return all.sort((a, b) => tier(a) - tier(b) || order(a, b));\n}\n\n// ─── the site directory ──────────────────────────────────────────────────────\n\n/**\n * What one site did for this search, as the directory says it. The web\n * section's `BlackFridaySiteState` without the shopper's-browser states\n * (`idle`, `queued`, `reading`, `done`): on a phone a site is either one our\n * servers read, one they could not, closed, or one only its own page shows.\n */\nexport type HolidaySiteState =\n | { kind: 'closed'; note: string }\n /** The connector read it; `count` is what it found. `reading`: our servers are still reading it. */\n | { kind: 'server'; count: number; reading?: boolean }\n /** Our servers tried it and could not read it: it opens on its own page. */\n | { kind: 'failed' }\n /** Not read for this search (web: `unpaired`): it opens on its own page. */\n | { kind: 'unpaired' };\n\n/** Each site's state for `answer` (undefined: no answer yet), by site id - the web `useBlackFridayBrowser` states, unpaired. */\nexport function holidaySiteStates(answer: BlackFridayAnswer | undefined): Record<string, HolidaySiteState> {\n const out: Record<string, HolidaySiteState> = {};\n for (const site of BLACK_FRIDAY_BROWSER_SITES) {\n if (site.closed) {\n out[site.id] = { kind: 'closed', note: site.closed };\n continue;\n }\n const label = site.label.toLowerCase();\n const report = site.server\n ? answer?.sources.find(\n (source) => source.source === site.id || (source.label ?? '').toLowerCase() === label,\n )\n : undefined;\n if (serverAnswered(site, answer)) {\n out[site.id] = {\n kind: 'server',\n count: report?.count ?? 0,\n ...(report?.status === 'reading' ? { reading: true } : {}),\n };\n continue;\n }\n // The connector could not reach it, and there is no browser to try.\n out[site.id] = report?.status === 'failed' ? { kind: 'failed' } : { kind: 'unpaired' };\n }\n return out;\n}\n\n/** What a site chip says beside the site's name (web `SiteChip`); null says nothing. */\nexport function holidaySiteStatus(state: HolidaySiteState): string | null {\n if (state.kind === 'closed') return 'closed';\n if (state.kind === 'server' && state.reading) return 'reading on Yantra…';\n if (state.kind === 'server') return state.count > 0 ? `${state.count} via Yantra` : 'checked';\n if (state.kind === 'failed') return 'could not read';\n return null;\n}\n\nexport interface HolidaySiteGroup {\n id: string;\n label: string;\n sites: BlackFridaySite[];\n}\n\n/** Every Black Friday site, grouped as the issue lists them: the deal sites, then the stores by kind. */\nexport const HOLIDAY_SITE_GROUPS: HolidaySiteGroup[] = [\n { id: 'deals', label: 'Deal sites', sites: BLACK_FRIDAY_BROWSER_SITES.filter((site) => site.kind === 'deals') },\n ...BLACK_FRIDAY_STORE_GROUPS.map((group) => ({\n id: group.id,\n label: group.label,\n sites: BLACK_FRIDAY_BROWSER_SITES.filter((site) => site.group === group.id),\n })),\n];\n\n/** How many stores the section covers (\"44 stores in all\"). */\nexport const HOLIDAY_STORE_COUNT = BLACK_FRIDAY_BROWSER_SITES.filter((site) => site.kind === 'store').length;\n\n/** How many stores our servers are still reading for this answer (\"Yantra is reading 3 stores\"). */\nexport function serversReadingCount(states: Record<string, HolidaySiteState>): number {\n return BLACK_FRIDAY_BROWSER_SITES.filter((site) => {\n const state = states[site.id];\n return state?.kind === 'server' && state.reading === true;\n }).length;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;AAqBgB,SAAA,mBAAA,CAAoB,MAAuB,KAAuB,EAAA;AAChF,EAAA,OAAO,IAAK,CAAA,GAAA,CAAI,KAAM,CAAA,IAAA,MAAU,yBAAyB,CAAA;AAC3D;AA+CgB,SAAA,cAAA,CAAe,MAA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function httpsImages(value) {
|
|
2
|
+
return Array.isArray(value) ? value.filter((url) => typeof url === "string" && /^https:\/\//i.test(url)) : [];
|
|
3
|
+
}
|
|
4
|
+
function playableVideos(value) {
|
|
5
|
+
if (!Array.isArray(value)) return [];
|
|
6
|
+
return value.filter((video) => !!video && typeof video === "object" && typeof video.url === "string" && /^https:\/\//i.test(video.url) && typeof video.mime === "string");
|
|
7
|
+
}export{httpsImages,playableVideos};//# sourceMappingURL=mediaShape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediaShape.js","sources":["../../../../src/features/shopping/services/mediaShape.ts"],"sourcesContent":["/**\n * The parts of a gallery answer the surface trusts, wherever it came from (the\n * connector's PRODUCT_MEDIA action, a gallery stored for the tenant): https\n * photos, and https videos with a type the player knows. Anything else is\n * dropped rather than shown as a broken slide.\n */\nimport type { ProductVideo } from '../catalog';\n\nexport function httpsImages(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((url): url is string => typeof url === 'string' && /^https:\\/\\//i.test(url))\n : [];\n}\n\nexport function playableVideos(value: unknown): ProductVideo[] {\n if (!Array.isArray(value)) return [];\n return value.filter(\n (video): video is ProductVideo =>\n !!video &&\n typeof video === 'object' &&\n typeof (video as ProductVideo).url === 'string' &&\n /^https:\\/\\//i.test((video as ProductVideo).url) &&\n typeof (video as ProductVideo).mime === 'string',\n );\n}\n"],"names":[],"mappings":"AAOO,SAAS,YAAY,KAA0B,EAAA;AACpD,EAAA,OAAO,MAAM,OAAQ,CAAA,KAAK,CAAI,GAAA,KAAA,CAAM,OAAO,CAAC,GAAA,KAAuB,OAAO,GAAA,KAAQ,YAAY,cAAe,CAAA,IAAA,CAAK,GAAG,CAAC,IAAI,EAAC;AAC7H;AACO,SAAS,eAAe,KAAgC,EAAA;AAC7D,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAA,SAAU,EAAC;AACnC,EAAO,OAAA,KAAA,CAAM,OAAO,CAAC,KAAA,KAAiC,CAAC,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAY,IAAA,OAAQ,MAAuB,GAAQ,KAAA,QAAA,IAAY,eAAe,IAAM,CAAA,KAAA,CAAuB,GAAG,CAAK,IAAA,OAAQ,KAAuB,CAAA,IAAA,KAAS,QAAQ,CAAA;AACvP"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {deriveAgentEndpoint}from'../../canvas/videoEditor/remoteMediaClient.js';import {shoppingAskModel}from'../shoppingRuntime.js';const TIMEOUT_MS = 2e4;
|
|
2
|
+
let inFlight = Promise.resolve();
|
|
3
|
+
function oneAtATime(work) {
|
|
4
|
+
const run = inFlight.then(work, work);
|
|
5
|
+
inFlight = run.catch(() => void 0);
|
|
6
|
+
return run;
|
|
7
|
+
}
|
|
8
|
+
const askModelOneStep = (ask) => shoppingAskModel()(ask);
|
|
9
|
+
function createModelStep(token, indexUrl, fetchImpl = (url, init) => fetch(url, init)) {
|
|
10
|
+
return (ask) => oneAtATime(() => askNow(token, indexUrl, fetchImpl, ask));
|
|
11
|
+
}
|
|
12
|
+
async function askNow(token, indexUrl, fetchImpl, {
|
|
13
|
+
model,
|
|
14
|
+
system,
|
|
15
|
+
prompt,
|
|
16
|
+
tool,
|
|
17
|
+
timeoutMs
|
|
18
|
+
}) {
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
20
|
+
if (!token) throw new Error("the model is unavailable (signed out)");
|
|
21
|
+
const controller = new AbortController();
|
|
22
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs != null ? timeoutMs : TIMEOUT_MS);
|
|
23
|
+
try {
|
|
24
|
+
const resp = await fetchImpl(`${deriveAgentEndpoint(indexUrl)}/v1/chat/completions`, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
Authorization: `Bearer ${token}`
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify({
|
|
31
|
+
model,
|
|
32
|
+
messages: [{
|
|
33
|
+
role: "system",
|
|
34
|
+
content: system
|
|
35
|
+
}, {
|
|
36
|
+
role: "user",
|
|
37
|
+
content: prompt
|
|
38
|
+
}],
|
|
39
|
+
tools: [tool],
|
|
40
|
+
stream: false
|
|
41
|
+
}),
|
|
42
|
+
signal: controller.signal
|
|
43
|
+
});
|
|
44
|
+
if (!resp.ok) throw new Error(`the model is unavailable (HTTP ${resp.status})`);
|
|
45
|
+
const body = await resp.json();
|
|
46
|
+
const message = (_b = (_a = body.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.message;
|
|
47
|
+
const args = (_e = (_d = (_c = message == null ? void 0 : message.tool_calls) == null ? void 0 : _c[0]) == null ? void 0 : _d.function) == null ? void 0 : _e.arguments;
|
|
48
|
+
if (typeof args === "string" && args.trim()) return args;
|
|
49
|
+
if (args && typeof args === "object") return JSON.stringify(args);
|
|
50
|
+
return typeof (message == null ? void 0 : message.content) === "string" ? message.content : "";
|
|
51
|
+
} finally {
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function extractJson(text) {
|
|
56
|
+
const fenced = [...text.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi)].map((m) => m[1].trim());
|
|
57
|
+
for (const candidate of fenced.reverse()) {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(candidate);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (let end = text.length - 1; end >= 0; end--) {
|
|
64
|
+
const close = text[end];
|
|
65
|
+
if (close !== "}" && close !== "]") continue;
|
|
66
|
+
const open = close === "}" ? "{" : "[";
|
|
67
|
+
const start = balancedStart(text, end, open, close);
|
|
68
|
+
if (start < 0) continue;
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(text.slice(start, end + 1));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
throw new Error("the writer did not answer in the expected format - try again");
|
|
75
|
+
}
|
|
76
|
+
function balancedStart(text, end, open, close) {
|
|
77
|
+
let depth = 0;
|
|
78
|
+
let inString = false;
|
|
79
|
+
for (let i = end; i >= 0; i--) {
|
|
80
|
+
const ch = text[i];
|
|
81
|
+
if (ch === '"' && !isEscaped(text, i)) inString = !inString;
|
|
82
|
+
if (inString) continue;
|
|
83
|
+
if (ch === close) depth++;
|
|
84
|
+
else if (ch === open) {
|
|
85
|
+
depth--;
|
|
86
|
+
if (depth === 0) return i;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return -1;
|
|
90
|
+
}
|
|
91
|
+
function isEscaped(text, index) {
|
|
92
|
+
let slashes = 0;
|
|
93
|
+
for (let i = index - 1; i >= 0 && text[i] === "\\"; i--) slashes++;
|
|
94
|
+
return slashes % 2 === 1;
|
|
95
|
+
}export{askModelOneStep,createModelStep,extractJson};//# sourceMappingURL=modelStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelStep.js","sources":["../../../../src/features/shopping/services/modelStep.ts"],"sourcesContent":["/**\n * One model step through the agent's router: a system prompt, a question and\n * the one tool the model answers through - the caller's own sign-in and\n * billing, no agent loop. Native twin of the web surface's\n * `services/modelStep.ts` (0.49.0).\n *\n * Sending a tool is what makes the agent's /v1/chat/completions take ONE model\n * step, stateless: without one it runs a whole agent turn per request (its\n * session, its tools, its system prompt) - measured live 2026-11-19 at 5-25 s\n * each, and requests sent together waited on one another past their timeout.\n * The AI reading of the search (aiRelevance) asks through it.\n *\n * Native: the transport is built by the host from the session's token and\n * index URL (`createModelStep`, the same endpoint and bearer as\n * `features/design/surface/agentWriter.ts`) and installed on the shopping\n * runtime (`askModel`), so tests inject their own. {@link askModelOneStep}\n * asks whatever the runtime holds, and fails (the rows paint as the word rules\n * left them) when nothing is wired. The brain seam (`brainTask`) cannot carry\n * this: the brain helpers send no `tools`.\n */\nimport { deriveAgentEndpoint } from '../../canvas/videoEditor/remoteMediaClient';\nimport { shoppingAskModel } from '../shoppingRuntime';\n\n/** An OpenAI-shaped function tool. */\nexport interface ModelTool {\n type: 'function';\n function: { name: string; description: string; parameters: Record<string, unknown> };\n}\n\n/** One request to the model: who it is, what it is asked, the tool it answers with, and how long it may take. */\nexport interface ModelAsk {\n model: string;\n system: string;\n prompt: string;\n tool: ModelTool;\n timeoutMs?: number;\n}\n\n/** The model's answer to one {@link ModelAsk}, as text (JSON, here). */\nexport type AskModel = (ask: ModelAsk) => Promise<string>;\n\n/** The fetch the transport calls; the global one unless a test hands in its own. */\nexport type ModelStepFetch = (url: string, init: RequestInit) => Promise<Pick<Response, 'ok' | 'status' | 'json'>>;\n\nconst TIMEOUT_MS = 20_000;\n\n/**\n * One request in flight at a time. Measured live 2026-11-19: on the lane the\n * fast tier lands on, one request answered in 8 s while three sent together\n * all ran past 30 s - they wait on one another there. Queued, each answers in\n * its own few seconds, and its budget starts when its turn comes.\n *\n * Module-level, as web: every transport the host builds (a new one per token)\n * shares the one queue.\n */\nlet inFlight: Promise<unknown> = Promise.resolve();\nfunction oneAtATime<T>(work: () => Promise<T>): Promise<T> {\n const run = inFlight.then(work, work);\n inFlight = run.catch(() => undefined);\n return run;\n}\n\n/**\n * The model step on the runtime's transport. Answers with the tool call's\n * arguments, or the text when the model wrote its JSON instead of calling the tool.\n */\nexport const askModelOneStep: AskModel = (ask) => shoppingAskModel()(ask);\n\n/**\n * The transport the host installs on the shopping runtime: the agent's\n * `/v1/chat/completions` for this index URL, the session's bearer - as\n * `createAgentCompleteJson` (agentWriter) - with a tool, one request at a time.\n */\nexport function createModelStep(\n token: string | null | undefined,\n indexUrl: string,\n fetchImpl: ModelStepFetch = (url, init) => fetch(url, init),\n): AskModel {\n return (ask) => oneAtATime(() => askNow(token, indexUrl, fetchImpl, ask));\n}\n\nasync function askNow(\n token: string | null | undefined,\n indexUrl: string,\n fetchImpl: ModelStepFetch,\n { model, system, prompt, tool, timeoutMs }: ModelAsk,\n): Promise<string> {\n if (!token) throw new Error('the model is unavailable (signed out)');\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs ?? TIMEOUT_MS);\n try {\n const resp = await fetchImpl(`${deriveAgentEndpoint(indexUrl)}/v1/chat/completions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },\n body: JSON.stringify({\n model,\n messages: [\n { role: 'system', content: system },\n { role: 'user', content: prompt },\n ],\n tools: [tool],\n stream: false,\n }),\n signal: controller.signal,\n });\n if (!resp.ok) throw new Error(`the model is unavailable (HTTP ${resp.status})`);\n const body = (await resp.json()) as {\n choices?: Array<{\n message?: { content?: unknown; tool_calls?: Array<{ function?: { arguments?: unknown } }> };\n }>;\n };\n const message = body.choices?.[0]?.message;\n const args = message?.tool_calls?.[0]?.function?.arguments;\n if (typeof args === 'string' && args.trim()) return args;\n if (args && typeof args === 'object') return JSON.stringify(args);\n return typeof message?.content === 'string' ? message.content : '';\n } finally {\n clearTimeout(timer);\n }\n}\n\n/** Test seam: a request a test left hanging would otherwise hold the queue for the next test. */\nexport function resetModelStepForTests(): void {\n inFlight = Promise.resolve();\n}\n\n// ─── JSON in a reply (web `@yantra/surface-kit/agent-complete` `extractJson`, verbatim) ───\n\n/**\n * The last complete JSON object or array in `text`, parsed. Scans from the end\n * for a closing bracket and walks back to its balanced opener, honouring\n * strings, so braces inside quoted copy do not confuse it.\n */\nexport function extractJson<T = unknown>(text: string): T {\n const fenced = [...text.matchAll(/```(?:json)?\\s*([\\s\\S]*?)```/gi)].map((m) => m[1].trim());\n for (const candidate of fenced.reverse()) {\n try {\n return JSON.parse(candidate) as T;\n } catch {\n /* keep looking */\n }\n }\n for (let end = text.length - 1; end >= 0; end--) {\n const close = text[end];\n if (close !== '}' && close !== ']') continue;\n const open = close === '}' ? '{' : '[';\n const start = balancedStart(text, end, open, close);\n if (start < 0) continue;\n try {\n return JSON.parse(text.slice(start, end + 1)) as T;\n } catch {\n /* an inner fragment; keep scanning left */\n }\n }\n throw new Error('the writer did not answer in the expected format - try again');\n}\n\nfunction balancedStart(text: string, end: number, open: string, close: string): number {\n let depth = 0;\n let inString = false;\n for (let i = end; i >= 0; i--) {\n const ch = text[i];\n if (ch === '\"' && !isEscaped(text, i)) inString = !inString;\n if (inString) continue;\n if (ch === close) depth++;\n else if (ch === open) {\n depth--;\n if (depth === 0) return i;\n }\n }\n return -1;\n}\n\nfunction isEscaped(text: string, index: number): boolean {\n let slashes = 0;\n for (let i = index - 1; i >= 0 && text[i] === '\\\\'; i--) slashes++;\n return slashes % 2 === 1;\n}\n"],"names":[],"mappings":"qIA+CA,MAAM,UAAa,GAAA,GAAA;AAWnB,IAAI,QAAA,GAA6B,QAAQ,OAAQ,EAAA;AACjD,SAAS,WAAc,IAAoC,EAAA;AACzD,EAAA,MAAM,GAAM,GAAA,QAAA,CAAS,IAAK,CAAA,IAAA,EAAM,IAAI,CAAA;AACpC,EAAW,QAAA,GAAA,GAAA,CAAI,KAAM,CAAA,MAAM,MAAS,CAAA;AACpC,EAAO,OAAA,GAAA;AACT;AAMO,MAAM,eAA4B,GAAA,CAAA,GAAA,KAAO,gBAAiB,EAAA,CAAE,GAAG;AAOtD,SAAA,eAAA,CAAgB,KAAkC,EAAA,QAAA,EAAkB,SAA4B,GAAA,CAAC,KAAK,IAAS,KAAA,KAAA,CAAM,GAAK,EAAA,IAAI,CAAa,EAAA;AACzJ,EAAO,OAAA,CAAA,GAAA,KAAO,WAAW,MAAM,MAAA,CAAO,OAAO,QAAU,EAAA,SAAA,EAAW,GAAG,CAAC,CAAA;AACxE;AACA,eAAe,MAAA,CAAO,KAAkC,EAAA,QAAA,EAAkB,SAA2B,EAAA;AAAA,EACnG,KAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAA8B,EAAA;AArF9B,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAsFE,EAAA,IAAI,CAAC,KAAA,EAAa,MAAA,IAAI,MAA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